关于寄存器的定义__REG
生活随笔
收集整理的這篇文章主要介紹了
关于寄存器的定义__REG
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在linux/include/asm-arm/arch-s3c2410/hardware.h中
下面那個
#ifndef __ASSEMBLY__
#else
#endif
中的__REG定義想了半天沒想明白,大家?guī)臀医忉屜潞脝?#xff1f; 謝謝
還有就是#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__ */
下面那個
#ifndef __ASSEMBLY__
#else
#endif
中的__REG定義想了半天沒想明白,大家?guī)臀医忉屜潞脝?#xff1f; 謝謝
還有就是#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__ */
總結(jié)
以上是生活随笔為你收集整理的关于寄存器的定义__REG的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 编译arm版本驱动模块
- 下一篇: Eclipse-cdt 配合 gdbse