mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-14 18:47:15 +03:00
60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
|
#ifndef __CIO_H__
|
||
|
#define __CIO_H__
|
||
|
|
||
|
#include <stdint.h>
|
||
|
|
||
|
#define port_out_b(port, value) ({ \
|
||
|
asm volatile ( "out dx, al" \
|
||
|
: \
|
||
|
: "a" (value), "d" (port) \
|
||
|
: ); \
|
||
|
})
|
||
|
|
||
|
#define port_out_w(port, value) ({ \
|
||
|
asm volatile ( "out dx, ax" \
|
||
|
: \
|
||
|
: "a" (value), "d" (port) \
|
||
|
: ); \
|
||
|
})
|
||
|
|
||
|
#define port_out_d(port, value) ({ \
|
||
|
asm volatile ( "out dx, eax" \
|
||
|
: \
|
||
|
: "a" (value), "d" (port) \
|
||
|
: ); \
|
||
|
})
|
||
|
|
||
|
#define port_in_b(port) ({ \
|
||
|
uint8_t value; \
|
||
|
asm volatile ( "in al, dx" \
|
||
|
: "=a" (value) \
|
||
|
: "d" (port) \
|
||
|
: ); \
|
||
|
value; \
|
||
|
})
|
||
|
|
||
|
#define port_in_w(port) ({ \
|
||
|
uint16_t value; \
|
||
|
asm volatile ( "in ax, dx" \
|
||
|
: "=a" (value) \
|
||
|
: "d" (port) \
|
||
|
: ); \
|
||
|
value; \
|
||
|
})
|
||
|
|
||
|
#define port_in_d(port) ({ \
|
||
|
uint32_t value; \
|
||
|
asm volatile ( "in eax, dx" \
|
||
|
: "=a" (value) \
|
||
|
: "d" (port) \
|
||
|
: ); \
|
||
|
value; \
|
||
|
})
|
||
|
|
||
|
#define io_wait() ({ port_out_b(0x80, 0x00); })
|
||
|
|
||
|
#define disable_interrupts() ({ asm volatile ("cli"); })
|
||
|
#define enable_interrupts() ({ asm volatile ("sti"); })
|
||
|
|
||
|
#endif
|