- #include <linux/kernel.h>
-
- void barrier(void)
这个"软件"内存屏蔽要求编译器对待所有内存是跨这个指令而非易失的.
- #include <asm/system.h>
-
- void rmb(void);
-
- void read_barrier_depends(void);
-
- void wmb(void);
-
- void mb(void);
硬件内存屏障. 它们请求 CPU(和编译器)来检查所有的跨这个指令的内存读, 写, 或都有.
- #include <asm/io.h>
-
- unsigned inb(unsigned port);
-
- void outb(unsigned char byte, unsigned port);
-
- unsigned inw(unsigned port);
-
- void outw(unsigned short word, unsigned port);
-
- unsigned inl(unsigned port);
-
- void outl(unsigned doubleword, unsigned port);
用来读和写 I/O 端口的函数. 它们还可以被用户空间程序调用, 如果它们有正当的权限来存取端口.
- unsigned inb_p(unsigned port);
如果在一次 I/O 操作后需要一个小延时, 你可以使用在前一项中介绍的这些函数的 6 个暂停对应部分; 这些暂停函数有以 _p 结尾的名子.
- void insb(unsigned port, void *addr, unsigned long count);
-
- void outsb(unsigned port, void *addr, unsigned long count);
-
- void insw(unsigned port, void *addr, unsigned long count);
-
- void outsw(unsigned port, void *addr, unsigned long count);
-
- void insl(unsigned port, void *addr, unsigned long count);
-
- void outsl(unsigned port, void *addr, unsigned long count);
这些"字串函数"被优化为传送数据从一个输入端口到一个内存区, 或者其他的方式. 这些传送通过读或写到同一端口 count 次来完成.
- #include <linux/ioport.h>
-
- struct resource *request_region(unsigned long start, unsigned long len, char *name);
-
- void release_region(unsigned long start, unsigned long len);
-
- int check_region(unsigned long start, unsigned long len);
I/O 端口的资源分配器. 这个检查函数成功返回 0 并且在错误时小于 0.
- struct resource *request_mem_region(unsigned long start, unsigned long len,
char *name);
-
- void release_mem_region(unsigned long start, unsigned long len);
-
- int check_mem_region(unsigned long start, unsigned long len);
为内存区处理资源分配的函数
- #include <asm/io.h>
-
- void *ioremap(unsigned long phys_addr, unsigned long size);
-
- void *ioremap_nocache(unsigned long phys_addr, unsigned long size);
-
- void iounmap(void *virt_addr);
ioremap 重映射一个物理地址范围到处理器的虚拟地址空间, 使它对内核可用. iounmap 释放映射当不再需要它时.
- #include <asm/io.h>
-
- unsigned int ioread8(void *addr);
-
- unsigned int ioread16(void *addr);
-
- unsigned int ioread32(void *addr);
-
- void iowrite8(u8 value, void *addr);
-
- void iowrite16(u16 value, void *addr);
-
- void iowrite32(u32 value, void *addr);
用来使用 I/O 内存的存取者函数.
- void ioread8_rep(void *addr, void *buf, unsigned long count);
-
- void ioread16_rep(void *addr, void *buf, unsigned long count);
-
- void ioread32_rep(void *addr, void *buf, unsigned long count);
-
- void iowrite8_rep(void *addr, const void *buf, unsigned long count);
-
- void iowrite16_rep(void *addr, const void *buf, unsigned long count);
-
- void iowrite32_rep(void *addr, const void *buf, unsigned long count);
I/O 内存原语的"重复"版本.
- unsigned readb(address);
-
- unsigned readw(address);
-
- unsigned readl(address);
-
- void writeb(unsigned value, address);
-
- void writew(unsigned value, address);
-
- void writel(unsigned value, address);
-
- memset_io(address, value, count);
-
- memcpy_fromio(dest, source, nbytes);
-
- memcpy_toio(dest, source, nbytes);
旧的, 类型不安全的存取 I/O 内存的函数.
- void *ioport_map(unsigned long port, unsigned int count);
-
- void ioport_unmap(void *addr);
一个想对待 I/O 端口如同它们是 I/O 内存的驱动作者, 可以传递它们的端口给 ioport_map. 这个映射应当在不需要的时候恢复( 使用 ioport_unmap )