免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2426 | 回复: 0
打印 上一主题 下一主题

关于寄存器的定义__REG [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-30 10:57 |只看该作者 |倒序浏览
在linux/include/asm-arm/arch-s3c2410/hardware.h中
下面那个
#ifndef __ASSEMBLY__
#else
#endif
中的__REG定义想了半天没想明白,大家帮我解释下好吗? 谢谢
还有就是#ifndef __ASSEMBLY__中__ASSEMBLY__什么时候才会定义了的?


/*
* S3C2410 internal I/O mappings
*
* We have the following mapping:
*                phys                virt
*                48000000        e8000000
*/

#define VIO_BASE                0xe8000000        /* virtual start of IO space */
#define PIO_START                0x48000000        /* physical start of IO space */

#define io_p2v(x) ((x) | 0xa0000000)
#define io_v2p(x) ((x) & ~0xa0000000)

#ifndef __ASSEMBLY__
#include <asm/types.h>

/*
* This __REG() version gives the same results as the one above, except
* that we are fooling gcc some how so it generates far better and smaller
* assembly code for access to contigous registers. It's a shame that gcc
* doesn't guess this by itself
*/
typedef struct { volatile u32 offset[4096]; } __regbase;
#define __REGP(x)        ((__regbase *)((x)&~4095))->offset[((x)&4095)>>2]
#define __REG(x)        __REGP(io_p2v(x))

/* Let's kick gcc's ass again... */
# define __REG2(x,y)        \
        ( __builtin_constant_p(y) ? (__REG((x) + (y))) \
                                  : (*(volatile u32 *)((u32)&__REG(x) + (y))) )

#define __PREG(x)        (io_v2p((u32)&(x)))

#else        /* __ASSEMBLY__ */

# define __REG(x)        io_p2v(x)
# define __PREG(x)        io_v2p(x)

#endif        /* __ASSEMBLY__ */
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP