http://blog.csdn.net/hudaweikevin/article/details/18562757 writel() 往内存映射的 I/O 空间上写数据, wirtel() I/O 上写入 32 位数据 (4字节)。 原型:引用#include <asm/io.h> void writel (unsigned char data , unsigned short addr )
readl() 从内存映射的 I/O 空间读取数据, readl 从 I/O 读取 32 位数据 ( 4 字节 )。 原型:#include <asm/io.h> unsigned char readl (unsigned int addr ) 注:变量 addr 是 I/O 地址。 返回值 : 从 I/O 空间读取的数值。
readb(), readw(), readl() 宏函数 功能:
从内存映射的 I/O 空间读取数据。 readb 从 I/O 读取 8 位数据 ( 1 字节 ); readw 从 I/O 读取 16 位数据 ( 2 字节 ); readl 从 I/O 读取 32 位数据 ( 4 字节 )。 原型:#include <asm/io.h> unsigned char readb (unsigned int addr ) unsigned char readw (unsigned int addr ) unsigned char readl (unsigned int addr ) 变量: addr I/O 地址。 返回值: 从 I/O 空间读取的数值。
__raw_readl和__raw_writel Linux对I/O的操作都定义在asm/io.h中,相应的在arm平台下,就在asm-arm/io.h中。
#define __raw_readl(a) (__chk_io_ptr(a), *(volatile unsigned int __force *)(a)) 在include\linux\compiler.h中:
#ifdef __CHECKER__ __raw_readl(a)展开是:((void)0, *(volatile unsigned int _force *)(a))。在定义了__CHECKER__的时候先调用__chk_io_ptr检查该地址,否则__chk_io_ptr什么也不做,*(volatile unsigned int _force *)(a)就是返回地址为a处的值。(void)xx的做法有时候是有用的,例如编译器打开了检查未使用的参数的时候需要将没有用到的参数这么弄一下才能编译通过。 CPU对I/O的物理地址的编程方式有两种:一种是I/O映射,一种是内存映射。__raw_readl和__raw_writel等是原始的操作I/O的方法,由此派生出来的操作方法有:inb、outb、_memcpy_fromio、readb、writeb、ioread8、iowrite8等。 |
|