fernlader2/Qcommon.c

39 lines
552 B
C
Raw Normal View History

2026-02-17 19:44:29 +01:00
#include <stdint.h>
#define COM1_BASE_PORT 0x3F8
static inline uint8_t
inb(uint16_t port)
{
uint8_t data;
__asm__ ("inb %%dx, %%al" : "=a"(data) : "d"(port));
return data;
}
static inline void
outb(uint16_t port, uint8_t data)
{
__asm__ ("outb %%al, %%dx" :: "a"(data), "d"(port));
}
void serial_write_char(char c)
{
while (1) {
int line_status = inb(COM1_BASE_PORT + 5);
if (line_status & 0x20) {
break;
}
}
outb(COM1_BASE_PORT, c);
}
void
main()
{
outb(0xE9, 'X');
serial_write_char('X');
for (;;) {
__asm__ ("hlt" :);
}
}