| 1 |
.\" Copyright 1995, Paul Gortmaker <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
.\" |
| 6 |
.TH outb 2 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
outb, outw, outl, outsb, outsw, outsl, |
| 9 |
inb, inw, inl, insb, insw, insl, |
| 10 |
outb_p, outw_p, outl_p, inb_p, inw_p, inl_p \- port I/O |
| 11 |
.SH LIBRARY |
| 12 |
Standard C library |
| 13 |
.RI ( libc ,\~ \-lc ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.B #include <sys/io.h> |
| 17 |
.P |
| 18 |
.BI "unsigned char inb(unsigned short " port ); |
| 19 |
.BI "unsigned char inb_p(unsigned short " port ); |
| 20 |
.BI "unsigned short inw(unsigned short " port ); |
| 21 |
.BI "unsigned short inw_p(unsigned short " port ); |
| 22 |
.BI "unsigned int inl(unsigned short " port ); |
| 23 |
.BI "unsigned int inl_p(unsigned short " port ); |
| 24 |
.P |
| 25 |
.BI "void outb(unsigned char " value ", unsigned short " port ); |
| 26 |
.BI "void outb_p(unsigned char " value ", unsigned short " port ); |
| 27 |
.BI "void outw(unsigned short " value ", unsigned short " port ); |
| 28 |
.BI "void outw_p(unsigned short " value ", unsigned short " port ); |
| 29 |
.BI "void outl(unsigned int " value ", unsigned short " port ); |
| 30 |
.BI "void outl_p(unsigned int " value ", unsigned short " port ); |
| 31 |
.P |
| 32 |
.BR "void insb(" "unsigned long count;" |
| 33 |
.BI " unsigned short " port ", void " addr [ count ], |
| 34 |
.BI " unsigned long " count ); |
| 35 |
.BR "void insw(" "unsigned long count;" |
| 36 |
.BI " unsigned short " port ", void " addr [ count ], |
| 37 |
.BI " unsigned long " count ); |
| 38 |
.BR "void insl(" "unsigned long count;" |
| 39 |
.BI " unsigned short " port ", void " addr [ count ], |
| 40 |
.BI " unsigned long " count ); |
| 41 |
.BR "void outsb(" "unsigned long count;" |
| 42 |
.BI " unsigned short " port ", const void " addr [ count ], |
| 43 |
.BI " unsigned long " count ); |
| 44 |
.BR "void outsw(" "unsigned long count;" |
| 45 |
.BI " unsigned short " port ", const void " addr [ count ], |
| 46 |
.BI " unsigned long " count ); |
| 47 |
.BR "void outsl(" "unsigned long count;" |
| 48 |
.BI " unsigned short " port ", const void " addr [ count ], |
| 49 |
.BI " unsigned long " count ); |
| 50 |
.fi |
| 51 |
.SH DESCRIPTION |
| 52 |
This family of functions is used to do low-level port input and output. |
| 53 |
The out* functions do port output, |
| 54 |
the in* functions do port input; |
| 55 |
the b-suffix functions are byte-width |
| 56 |
and the w-suffix functions word-width; |
| 57 |
the _p-suffix functions pause until the I/O completes. |
| 58 |
.P |
| 59 |
They are primarily designed for internal kernel use, |
| 60 |
but can be used from user space. |
| 61 |
.\" , given the following information |
| 62 |
.\" in addition to that given in |
| 63 |
.\" .BR outb (9). |
| 64 |
.P |
| 65 |
You must compile with |
| 66 |
.B \-O |
| 67 |
or |
| 68 |
.B \-O2 |
| 69 |
or similar. |
| 70 |
The functions |
| 71 |
are defined as inline macros, and will not be substituted in without |
| 72 |
optimization enabled, causing unresolved references at link time. |
| 73 |
.P |
| 74 |
You use |
| 75 |
.BR ioperm (2) |
| 76 |
or alternatively |
| 77 |
.BR iopl (2) |
| 78 |
to tell the kernel to allow the user space application to access the |
| 79 |
I/O ports in question. |
| 80 |
Failure to do this will cause the application |
| 81 |
to receive a segmentation fault. |
| 82 |
.SH VERSIONS |
| 83 |
.BR outb () |
| 84 |
and friends are hardware-specific. |
| 85 |
The |
| 86 |
.I value |
| 87 |
argument is passed first and the |
| 88 |
.I port |
| 89 |
argument is passed second, |
| 90 |
which is the opposite order from most DOS implementations. |
| 91 |
.SH STANDARDS |
| 92 |
None. |
| 93 |
.SH SEE ALSO |
| 94 |
.BR ioperm (2), |
| 95 |
.BR iopl (2) |