mirror of
https://github.com/tailix/kernel.git
synced 2024-10-30 12:03:52 -04:00
Add IO helper methods
This commit is contained in:
parent
28cca159e5
commit
49a3b5b8f9
1 changed files with 48 additions and 0 deletions
48
arch/io.h
Normal file
48
arch/io.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef KERNELMQ_INCLUDED_IO
|
||||||
|
#define KERNELMQ_INCLUDED_IO 1
|
||||||
|
|
||||||
|
inline static unsigned char inb(unsigned short port);
|
||||||
|
inline static unsigned short inw(unsigned short port);
|
||||||
|
inline static unsigned int ind(unsigned short port);
|
||||||
|
|
||||||
|
inline static void outb(unsigned short port, unsigned char value);
|
||||||
|
inline static void outw(unsigned short port, unsigned short value);
|
||||||
|
inline static void outd(unsigned short port, unsigned int value);
|
||||||
|
|
||||||
|
unsigned char inb(unsigned short port)
|
||||||
|
{
|
||||||
|
register unsigned char result;
|
||||||
|
asm volatile("inb %1, %0" : "=a" (result) : "dN" (port));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short inw(unsigned short port)
|
||||||
|
{
|
||||||
|
register unsigned short result;
|
||||||
|
asm volatile("inw %1, %0" : "=a" (result) : "dN" (port));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ind(unsigned short port)
|
||||||
|
{
|
||||||
|
register unsigned int result;
|
||||||
|
asm volatile("ind %1, %0" : "=a" (result) : "dN" (port));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void outb(unsigned short port, unsigned char value)
|
||||||
|
{
|
||||||
|
asm volatile("outb %1, %0" : : "dN" (port), "a" (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void outw(unsigned short port, unsigned short value)
|
||||||
|
{
|
||||||
|
asm volatile("outw %1, %0" : : "dN" (port), "a" (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void outd(unsigned short port, unsigned int value)
|
||||||
|
{
|
||||||
|
asm volatile("outd %1, %0" : : "dN" (port), "a" (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue