#include <asm/io.h>
void
outb (unsigned
char data,
unsigned short
port);
void
outw (unsigned
short data,
unsigned short
port);
void
outl (unsigned
long data,
unsigned short
port);
变量:引用#include <asm/io.h>
void outb (unsigned char data, unsigned short port);
void outw (unsigned short data, unsigned short port);
void outl (unsigned long data, unsigned short port);
在linux的驱动程序中,都会使用大量的outb、outw、inb、inw等等宏来访问硬件或寄存器。这些宏的定义都在相应处理器体系下的include/asm目录下的io.h中定义。追究下去,这些宏最终就是一个volatile变量的的赋值:
#define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v))
#define __raw_writeb(v,a) __arch_putb(v,a)
#define outb(v,p) __raw_writeb(v,__io(p))
当读入数据时使用in(x),类似inb、inw、inl,参数与out(x)函数一致。
in、out都是对I/O端口进行操作。ioreadb、iowriteb等是对I/O内存操作。(详见博客http://blog.csdn.net/haozhao_blog/article/details/24005323)
outb,inb等I/O端口操作函数,布布扣,bubuko.com
原文:http://blog.csdn.net/haozhao_blog/article/details/24004021