Not logged inTalkContributionsCreate accountLog in

Devices

From nexOS Wiki
VBE display, PS/2 controller, keyboard, mouse, PIT, PCI, USB, 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. Release codes update shift state (0x2A/0x36) and Caps Lock toggles on 0x3A; digits morph to symbols under shift and the terminal buffer stays uppercase for command matching. Routes to terminal if open, else Notepad text_buf. Full glyph coverage now includes digits and punctuation (digits used to render as the letter O).

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.

PCI — enumeration (pci.c)

Config-space access via 0xCF8/0xCFC, full bus scan across all 8 functions per device (single-function-only scans miss the IDE/USB sub-functions), vendor/device lookup, IO BAR parsing, class names. The NIC and USB drivers probe through it instead of hardcoded ports; LSPCI prints the live table (7 devices on QEMU i440fx).

USB — UHCI bring-up (usb.c)

Finds UHCI controllers by class code, resets the host, runs the frame schedule, resets ports and walks control-transfer enumeration (descriptors, address, config, HID protocol). USB rescans the bus for hotplug. Controller init is proven; device enumeration is still being debugged — USB DEVICES 0 is the honest answer until then.

CPUID and APIC discovery

CPUID prints vendor, family/model and the APIC flag; ACPI walks RSDP→RSDT→MADT through the high-memory windows and reports the LAPIC base and CPU count (MADT presence is machine-config dependent).

ATA and RTL8139

Disk and network have their own pages: Filesystem (ATA + FAT32) covers ports 0x1F0–0x1F7 PIO plus LBA48 and IDENTIFY; Networking covers the PCI-probed RTL8139 with real TX/RX. ACPI shutdown (outw(0x604,0x2000)) is documented under Interrupts.