- arch/x86_64/boot.s: Map 8GB..512GB using 1GB huge pages in PDPT; set Multiboot2 FB tag to required native 32bpp - drivers/serial.c: Add scratch register hardware probe & 50k timeout guard to prevent infinite polling hang on modern AMD chipsets - drivers/rtc.c: Add timeout guard to CMOS status register polling - drivers/vga.c: Bypass legacy 0x3D4/0x3D5 CRT ports in GOP mode; mirror all characters to active hardware framebuffer - drivers/vbe.c: Implement vbe_early_boot_splash, direct front-buffer console rendering & dynamic backbuffer allocation - kernel/kmain.c: Initialize GOP linear framebuffer at Step 0 for instant physical screen illumination; use pause+counter in render loop - scripts/build_iso.sh: Support universal GOP/VBE/VGA multi-resolution auto-detect for both bare metal and VirtualBox
52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
#include <airlys/serial.h>
|
|
#include <airlys/io.h>
|
|
|
|
static bool s_com1_present = false;
|
|
|
|
void serial_init(void) {
|
|
/* Test if COM1 actually exists using UART scratch register (offset +7) */
|
|
outb(COM1_PORT + 7, 0x55);
|
|
if (inb(COM1_PORT + 7) != 0x55) {
|
|
s_com1_present = false;
|
|
return;
|
|
}
|
|
outb(COM1_PORT + 7, 0xAA);
|
|
if (inb(COM1_PORT + 7) != 0xAA) {
|
|
s_com1_present = false;
|
|
return;
|
|
}
|
|
|
|
s_com1_present = true;
|
|
outb(COM1_PORT + 1, 0x00); /* Disable all interrupts */
|
|
outb(COM1_PORT + 3, 0x80); /* Enable DLAB (set baud rate divisor) */
|
|
outb(COM1_PORT + 0, 0x01); /* Set divisor to 1 (115200 baud) */
|
|
outb(COM1_PORT + 1, 0x00);
|
|
outb(COM1_PORT + 3, 0x03); /* 8 bits, no parity, one stop bit */
|
|
outb(COM1_PORT + 2, 0xC7); /* Enable FIFO, clear them, with 14-byte threshold */
|
|
outb(COM1_PORT + 4, 0x0B); /* IRQs enabled, RTS/DSR set */
|
|
}
|
|
|
|
static inline bool is_transmit_empty(void) {
|
|
return (inb(COM1_PORT + 5) & 0x20) != 0;
|
|
}
|
|
|
|
void serial_putchar(char c) {
|
|
if (!s_com1_present) return;
|
|
|
|
uint32_t timeout = 50000;
|
|
while (!is_transmit_empty() && --timeout > 0) {}
|
|
if (timeout > 0) {
|
|
outb(COM1_PORT, c);
|
|
}
|
|
}
|
|
|
|
void serial_puts(const char* str) {
|
|
if (!s_com1_present || !str) return;
|
|
while (*str) {
|
|
if (*str == '\n') {
|
|
serial_putchar('\r');
|
|
}
|
|
serial_putchar(*str++);
|
|
}
|
|
}
|