linux分配iomem,linux 下__iomem 解析【转】

-iomem解析

在看Linux的i2s源码时,里面有个定义:void __iomem *base;

这个__iomem是个什么东西,蒙蔽了。在include/linux/compile.h这个文件查看其宏定义为:

#ifdef __CHECKER__

# define __user __attribute__((noderef, address_space(1)))

# define __kernel __attribute__((address_space(0)))

# define __safe __attribute__((safe))

# define __force __attribute__((force))

# define __nocast __attribute__((nocast))

# define __iomem __attribute__((noderef, address_space(2)))

# define __must_hold(x) __attribute__((context(x,1,1)))

# define __acquires(x) __attribute__((context(x,0,1)))

# define __releases(x) __attribute__((context(x,1,0)))

# define __acquire(x) __context__(x,1)

# define __release(x) __context__(x,-1)

# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)

# define __percpu __attribute__((noderef, address_space(3)))

#ifdef CONFIG_SPARSE_RCU_POINTER

# define __rcu __attribute__((noderef, address_space(4)))

#else

# define __rcu

#endif

iomem这个特性,即__attribute((noderef, address_space(2))),attribute是用来修饰一个变量的,这个变量必须是非解除参考(no dereference)的,即这个变量地址必须是有效的,而且变量所在的地址空间必须是2,即io存储空间。

0.1.2.3分别对应四个空间

address_space(v)

————————————-

v: 0 内核空间

v: 1 用户空间

v: 2 io存储空间

v: 3 cpu空间

那这个address_space(4)又是啥呢,查了一些资料,如下:

# define __rcu __attribute__((noderef, address_space(4)))

1

RCU代表的是 “read, copy, update”。它是一种算法,允许多个读者访问数据,并且同时允许修改者,删除者能够进行操作。

如果内核使用 CONFIG_SPARSE_RCU_POINTER 的编译, __rcu 就会被定义为上面的定义。

这是一种标记,可以给Sparse code 分析工具来对于某些东西进行警告。

引用 http://stackoverflow.com/questions/17128210/what-does-rcu-stands-for-in-linux

可以知道: __rcu sparse 检查:使用__rcu 附上 RCU保护的数据结构,如果你没有使用rcu_dereference()类中某个函数,Sparse就会警告你这个操作。

————————————————

版权声明:本文为CSDN博主「夜风~」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/u014470361/java/article/details/80682101

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值