OUTB - Linux手册页

Linux程序员手册 第2部分
更新日期: 2017-09-15

遵循规范

outb()和朋友是特定于硬件的。首先传递value参数,然后传递port参数,这与大多数DOS实现的顺序相反。

语法

#include <sys/io.h>

unsigned char inb(unsigned short int port);
unsigned char inb_p(unsigned short int port);
unsigned short int inw(unsigned short int port);
unsigned short int inw_p(unsigned short int port);
unsigned int inl(unsigned short int port);
unsigned int inl_p(unsigned short int port);

void outb(unsigned char value, unsigned short int port);
void outb_p(unsigned char value, unsigned short int port);
void outw(unsigned short int value, unsigned short int port);
void outw_p(unsigned short int value, unsigned short int port);
void outl(unsigned int value, unsigned short int port);
void outl_p(unsigned int value, unsigned short int port);

void insb(unsigned short int port, void *addr,
           unsigned long int count);
void insw(unsigned short int port, void *addr,
           unsigned long int count);
void insl(unsigned short int port, void *addr,
           unsigned long int count);
void outsb(unsigned short int port, const void *addr,
           unsigned long int count);
void outsw(unsigned short int port, const void *addr,
           unsigned long int count);
void outsl(unsigned short int port, const void *addr,
           unsigned long int count);

出版信息

这个页面是Linux手册页项目5.08版的一部分。有关项目的说明、有关报告错误的信息以及此页面的最新版本,请访问https://www.kernel.org/doc/man-pages/

名称

outb,outw,outl,outsb,outsw,outsl,inb,inw,inl,insb,insw,insl,outb_p,outw_p,outl_p,inb_p,inw_p,inl_p-端口I / O

另外参见

ioperm(2),iopl(2)

说明

该功能系列用于执行低级端口输入和输出。 out *功能用于端口输出,in *功能用于端口输入; b后缀函数为字节宽度,w后缀函数为字宽; _p后缀功能暂停,直到I / O完成。

它们主要是为内部内核使用而设计的,但是可以在用户空间中使用。

您必须使用-O或-O2或类似的语言进行编译。这些函数被定义为内联宏,并且在未启用优化的情况下不会被替换,从而导致链接时无法解析的引用。

您可以使用ioperm(2)或iopl(2)告诉内核,以允许用户空间应用程序访问有问题的I / O端口。否则,将导致应用程序收到分段错误。

日期:2019-08-20 17:59:06 来源:oir作者:oir