Not logged inTalkContributionsCreate accountLog in

Devices

From nexOS Wiki
VBE display, PS/2 controller, keyboard, mouse, PIT, ACPI

Contents

[hide]

nexOS has no formal HAL — each driver is static functions + globals in kernel.c (plus ata.c/fat32.c/net.c). Programmed devices: VBE display, PS/2 keyboard/mouse, PIT timer, ATA disk, RTL8139 NIC, ACPI power port.

Display — VBE/VESA

Framebuffer-only, no acceleration. Bootloader picks the mode; kernel reads 0x5000 block. Preferred target is 800×600 (QEMU -vga vmware -m 256), with 1024×768 tried first in the current table.

vbe_init():
  lfb = VBE_LFB; front_lfb = lfb;
  scr_w/ scr_h/ pitch/ bpp from block; r/g/b_pos for draw_pixel()

PS/2 controller

init_ps2():
  mw(1); outb(0x64,0xA8);                 // enable aux port
  mw(1); outb(0x64,0x20); mw(0); s=inb(0x60)|2;
  mw(1); outb(0x64,0x60); mw(1); outb(0x60,s);
  mw(1); outb(0x64,0xD4); mw(1); outb(0x60,0xF6); mw(0); inb(0x60); // defaults
  mw(1); outb(0x64,0xD4); mw(1); outb(0x60,0xF4); mw(0); inb(0x60); // enable

mw(0) waits for output-full, mw(1) for input-empty (100k timeout). See Interrupts for IRQ routing.

Keyboard — scancode set 1

Handler reads 0x60 when status bit 0 set and bit 5 clear. Bytes < 0x3A translate via 128-entry map; release (0x80 bit) ignored. Routes to terminal if open, else Notepad text_buf. Recent fix: IRQ1 is now installed and drained/ACKed instead of dispatching through an empty IDT entry (which froze the VM).

Mouse — 3-byte packet

ByteMeaning
0Buttons (bits 0–2), X/Y sign (0x10/0x20), overflow (0x40/0x80 discards packet)
1X delta (minus 256 if sign)
2Y delta (inverted: mouse_y -= yd)

Current behavior: 2× gain, clamp to true edges, 4-deep press-edge queue so fast clicks survive long renders, ghost-free (cursor only on front buffer), 1:1 dragging.

ATA and RTL8139

Disk and network have their own pages: Filesystem (ATA + FAT32) covers ports 0x1F0–0x1F7 PIO; Networking covers RTL8139 base 0x300 IRQ11. ACPI shutdown (outw(0x604,0x2000)) is documented under Interrupts.