struct file_operations fops;
unsigned long start, len;
int init_module (void)
{
int status;
start = 0xff90;
len = 0x90;
register_chrdev(254,"your_device",&fops);
status = check_region (start, len);
if (status == 0) {
printk ("The ports are available in that range。\n");
request_region(start,len,"your_device");
} else {
printk ("The ports are already in use。 Try other range。\n");
return (status);
}
return 0;
}
void cleanup_module (void)
{
release_region(start, len);
printk (" ports are freed successfully\n");
unregister_chrdev(254,"your_device");}
printk (" your device is unregistered\n");
}
void insb(unsigned int port, void *addr, unsigned long count);
void outsb(unsigned int port, void *addr, unsigned long count);
addr 是被传入或传出的内存单元地址,count是被传输单元的数量。 Data 则是被读取或 写入到"port"端口的数据。
void insw(unsigned int port, void *addr, unsigned long count);
void outsw(unsigned int port, void *addr, unsigned long count);
向16位端口读写16位数据
void insl(unsigned int port, void *addr, unsigned long count);
void outsl(unsigned int port, void *addr, unsigned long count);
向32位端口读写32位数据