//#include typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #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 serial_write(const char *msg) { for (const char *c = msg; *c; c++) { outb(0xE9, *c); //serial_write_char(*c); } } extern void bios_write(const char *msg, unsigned length); extern void *bios_getmap(void *buffer); unsigned char memmap[24 * 128]; void main() { bios_write("init\r\n", 6); void *end = bios_getmap(memmap); bios_write("karlos\r\n", 8); for (int i = 0; ; i++) { unsigned char *entry = memmap + 24 * i; if ((void *)entry >= end) break; unsigned char type = *(entry + 16); char c = type < 10 ? type + '0' : '?'; bios_write(&c, 1); } for (;;) { __asm__ ("hlt" :); } }