mirror of https://github.com/tailix/libkernaux.git
Add port I/O functions
This commit is contained in:
parent
5d2f20f6b3
commit
372a26612f
|
@ -5,6 +5,19 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
inline static unsigned char kernaux_arch_i386_inportb(unsigned short port);
|
||||
inline static unsigned short kernaux_arch_i386_inportw(unsigned short port);
|
||||
inline static unsigned int kernaux_arch_i386_inportd(unsigned short port);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_i386_outportb(unsigned short port, unsigned char value);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_i386_outportw(unsigned short port, unsigned short value);
|
||||
|
||||
inline static void
|
||||
kernaux_arch_i386_outportd(unsigned short port, unsigned int value);
|
||||
|
||||
void kernaux_arch_i386_hang() __attribute__((noreturn));
|
||||
|
||||
unsigned long kernaux_arch_i386_read_cr0();
|
||||
|
@ -14,6 +27,48 @@ void kernaux_arch_i386_write_cr0(volatile unsigned long value);
|
|||
void kernaux_arch_i386_write_cr3(volatile unsigned long value);
|
||||
void kernaux_arch_i386_write_cr4(volatile unsigned long value);
|
||||
|
||||
unsigned char kernaux_arch_i386_inportb(const unsigned short port)
|
||||
{
|
||||
register unsigned char result;
|
||||
asm volatile("inb %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned short kernaux_arch_i386_inportw(const unsigned short port)
|
||||
{
|
||||
register unsigned short result;
|
||||
asm volatile("inw %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int kernaux_arch_i386_inportd(const unsigned short port)
|
||||
{
|
||||
register unsigned int result;
|
||||
asm volatile("ind %1, %0" : "=a" (result) : "dN" (port));
|
||||
return result;
|
||||
}
|
||||
|
||||
void kernaux_arch_i386_outportb(
|
||||
const unsigned short port,
|
||||
const unsigned char value
|
||||
) {
|
||||
asm volatile("outb %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
void kernaux_arch_i386_outportw(
|
||||
const unsigned short port,
|
||||
const unsigned short value
|
||||
) {
|
||||
asm volatile("outw %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
void kernaux_arch_i386_outportd(
|
||||
const unsigned short port,
|
||||
const unsigned int value
|
||||
) {
|
||||
asm volatile("outd %1, %0" : : "dN" (port), "a" (value));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue