This chapter introduced the following symbols related to hardware management:
#include <asm/io.h>
,
unsigned inb(unsigned port);
,
void outb(unsigned char byte, unsigned port);
,
unsigned inw(unsigned port);
,
void outw(unsigned short word, unsigned port);
,
unsigned inl(unsigned port);
,
void outl(unsigned doubleword, unsigned port);
These functions are used to read and write I/O ports. They can also be called by user-space programs, provided they have the right privileges to access ports. Not all the platforms support all the functions, which depend on underlying hardware design.
SLOW_DOWN_IO;
,
unsigned inb_p(unsigned port);
,
...
The statement SLOW_DOWN_IO
is sometimes needed to
deal with slow ISA boards on the x86 platform. If a small delay
is needed after an I/O operation, you can use the six pausing
counterparts of the functions introduced above, whose
names end in _p
.
void insb(unsigned port, void *addr, unsigned long count);
,
void outsb(unsigned port, void *addr, unsigned long count);
,
void insw(unsigned port, void *addr, unsigned long count);
,
void outsw(unsigned port, void *addr, unsigned long count);
,
void insl(unsigned port, void *addr, unsigned long count);
,
void outsl(unsigned port, void *addr, unsigned long count);
The ``string functions'' are optimized to transfer
data from an input port to a region of memory, or the other
way round. Such transfers are performed by reading or
writing the same port count
times.
unsigned readb(address);
,
unsigned readw(address);
,
unsigned readl(address);
,
void writeb(unsigned value, address);
,
void writew(unsigned value, address);
,
void writel(unsigned value, address);
,
memset_io(address, value, count);
,
memcpy_fromio(dest, source, nbytes);
,
memcpy_toio(dest, source, nbytes);
All of these functions are used to access I/O memory regions, either low ISA memory or high PCI buffers (after calling vremap).
3.149.234.141