Skip to content

Drivers and Console

Oguzhan KAYNAK edited this page Oct 20, 2026 · 5 revisions

Drivers and Console

Hardware sits behind small interfaces, so a driver can be replaced (PIC by APIC, PIT by the APIC timer) and tested with a fake:

Interface Implementations Used by
Drivers::InterruptController Drivers::PIC (8259) PIT, keyboard, ISR dispatcher
Drivers::TickSource Drivers::PIT Threading::Scheduler
Drivers::CharacterSink Drivers::SerialPort, Drivers::VGATextConsole the console (printf)
Drivers::CharacterSource Drivers::CharacterQueue (fed by the keyboard and COM1) the kernel shell
Drivers::BlockDevice ATAPioDevice, PartitionDevice, MemoryBlockDevice Fs::Fat16
  • PIC: the constructor remaps IRQs to vectors 0x20..0x2F and masks every line; a driver attaches its handler and unmasks its own line (timer and keyboard today).

  • PIT: channel 0 as a periodic tick; periods that do not fit the 16-bit divisor are refused.

  • SerialPort: 16550 UART, 38400 8N1. A loopback test decides whether the port exists; a missing port drops writes instead of hanging.

  • VGATextConsole: 80x25 text mode. The buffer is a constructor parameter (the screen by default), so wrapping and scrolling are tested on RAM.

  • Console: Core::setConsole(sink) decides where printf, logMsg and kernelPanic write. kernelMain starts on the screen and moves to COM1 when it passes its loopback test.

  • PS2Keyboard: IRQ 1; a pure ScancodeDecoder turns scancode set 1 into characters (Shift, Caps Lock, Ctrl, extended keys, US layout), a 64 byte buffer counted by a semaphore lets read() sleep until a key arrives.

  • ATAPioDevice: IDE disk, IDENTIFY, 28-bit LBA PIO with polling and time limits. MBR partitions become PartitionDevices; their FAT16 volumes are mounted by Fs::Vfs as /disk0, /disk1, ... (see kernel/fs/README.md).

Clone this wiki locally