嵌入式linux和uboot中关于读写寄存器的函数(__raw_writel, writel等)

 

uboot中是这么定义的:

u-boot_2.3.5/arch/arm/include/asm/io.h


/*
 * Generic virtual read/write.  Note that we don't support half-word
 * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
 * to the architecture specific code.
 */
#define __arch_getb(a)          (*(volatile unsigned char *)(a))
#define __arch_getw(a)          (*(volatile unsigned short *)(a))
#define __arch_getl(a)          (*(volatile unsigned int *)(a))     //就是把值通过指针读出来

#define __arch_putb(v,a)        (*(volatile unsigned char *)(a) = (v))
#define __arch_putw(v,a)        (*(volatile unsigned short *)(a) = (v))
#define __arch_putl(v,a)        (*(volatile unsigned int *)(a) = (v))   //写入v

 


#define __raw_writeb(v,a)       __arch_putb(v,a)
#define __raw_writew(v,a)       __arch_putw(v,a)
#define __raw_writel(v,a)       __arch_putl(v,a)

#define __raw_readb(a)          __arch_getb(a)
#define __raw_readw(a)          __arch_getw(a)
#define __raw_readl(a)          __arch_getl(a)

#define writeb(v,a)         __arch_putb(v,a)
#define writew(v,a)         __arch_putw(v,a)
#define writel(v,a)         __arch_putl(v,a)  //好像与“__raw_writel”  没有什么区别

#define readb(a)            __arch_getb(a)
#define readw(a)            __arch_getw(a)
#define readl(a)            __arch_getl(a)

 

 

 

你可能感兴趣的:(linux,嵌入式)