I/O 端口分配
#include
struct resource *request_region(ulong first, ulong n, const char *name);
告诉内核, 从 first 开始要使用 n 个端口, name 参数应当是你的设备的名子. 分配成功返回非 NULL.
当你用完一组 I/O 端口(在模块卸载时), 应当返回它们给系统, 使用:
void release_region(ulong start, ulong n);
操作 I/O 端口
unsigned inb(unsigned port);
void outb(unsigned char byte, unsigned port); //8 bit
unsigned inw(unsigned port);
void outw(unsigned short word, unsigned port); //16 bit
unsigned inl(unsigned port);
void outl(unsigned longword, unsigned port); // 32 bit
|
字串操作
void insb(unsigned port, void *addr, unsigned long count);
void outsb(unsigned port, void *addr, unsigned long count);
读或写从内存地址 addr 开始的 count 字节. 数据读自或者写入单个 port 端口.
void insw(unsigned port, void *addr, unsigned long count);
void outsw(unsigned port, void *addr, unsigned long count);
读或写 16-位 值到一个单个 16-位 端口.
void insl(unsigned port, void *addr, unsigned long count);
void outsl(unsigned port, void *addr, unsigned long count);
读或写 32-位 值到一个单个 32-位 端口.
|
阅读(2899) | 评论(0) | 转发(0) |