- 论坛徽章:
- 0
|
在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__ */ |
|