42#define IA16_INT_STEP 1
50#define IA16_INT_BREAK 3
54#define IA16_INT_INTO 4
58#define IA16_INT_BOUNDS 5
63#define IA16_FLAG_CF 0x0001
67#define IA16_FLAG_PF 0x0004
71#define IA16_FLAG_AF 0x0010
75#define IA16_FLAG_ZF 0x0040
79#define IA16_FLAG_SF 0x0080
83#define IA16_FLAG_TF 0x0100
87#define IA16_FLAG_IF 0x0200
91#define IA16_FLAG_DF 0x0400
95#define IA16_FLAG_OF 0x0800
99#define IA16_FLAG_MD 0x8000
103#ifdef __IA16_CMODEL_IS_FAR_TEXT
108#define IA16_CALL_STACK_OFFSET(n) ((n)+4)
113.macro IA16_CALL tgt:req
114 .reloc .+3, R_386_SEG16,
"\tgt\()!"
122.macro IA16_CALL_LOCAL tgt:req
129.macro IA16_JMP tgt:req
130 .reloc .+3, R_386_SEG16,
"\tgt\()!"
138#define IA16_CALL_STACK_OFFSET(n) ((n)+2)
143.macro IA16_CALL tgt:req
151.macro IA16_CALL_LOCAL tgt:req
157.macro IA16_JMP tgt:req
170#define FP_SEG(x) __builtin_ia16_selector ((uint16_t) (((uint32_t) ((void __far*) (x))) >> 16))
175#define FP_OFF(x) __builtin_ia16_FP_OFF ((x))
180#define MK_FP(seg, ofs) ((void __far*) (((uint16_t) ofs) | (((uint32_t) ((uint16_t) seg)) << 16)))
181#define _CS ia16_get_cs()
182#define _DS ia16_get_ds()
183#define _ES ia16_get_es()
184#define _SS ia16_get_ss()
201#define ia16_get_ds __builtin_ia16_near_data_segment
218#define ia16_get_ss __builtin_ia16_ss
266 :
"Nd" ((uint16_t) port)
282 :
"Nd" ((uint16_t) port)
293static inline void outportb(uint8_t port, uint8_t value) {
297 :
"Ral" (value),
"Nd" ((uint16_t) port)
307static inline void outportw(uint8_t port, uint16_t value) {
311 :
"a" (value),
"Nd" ((uint16_t) port)
315#define ia16_port_inb(port) inportb(port)
316#define ia16_port_inw(port) inportw(port)
317#define ia16_port_outb(value, port) outportb(port, value)
318#define ia16_port_outw(value, port) outportw(port, value)
324 __asm
volatile (
"hlt");
331 __asm
volatile (
"sti");
338 __asm
volatile (
"cli");
346#define ia16_critical(...) \
348 ia16_disable_irq(); \
static void outportw(uint8_t port, uint16_t value)
Write a word to the given port.
static void outportb(uint8_t port, uint8_t value)
Write a byte to the given port.
static void ia16_disable_irq(void)
Disable jumping to interrupt vectors on an interrupt being received by the CPU.
static uint8_t inportb(uint8_t port)
Read a byte from the given port.
static uint16_t ia16_get_flags()
Retrieve the current value of the CPU flag register.
static void ia16_enable_irq(void)
Enable jumping to interrupt vectors on an interrupt being received by the CPU.
static __segment ia16_get_cs()
Retrieve the current value of the code segment CS.
static uint16_t ia16_get_sp()
Retrieve the current value of the stack pointer SP.
void ia16_int_set_handler(uint8_t idx, ia16_int_handler_t handler)
Register a CPU interrupt handler.
static uint16_t inportw(uint8_t port)
Read a word from the given port.
static __segment ia16_get_es()
Retrieve the current value of the data segment ES.
void __far(* ia16_int_handler_t)(void)
static void ia16_halt(void)
Halt the CPU until an interrupt is received.
static void ia16_set_flags(uint16_t flags)
Set the CPU flag register to a new value.