Overview
Portix OS implements a bare-metal driver architecture supporting storage, input, and bus enumeration without relying on external frameworks. All drivers operate in kernel space with direct hardware access via x86 port I/O instructions.ATA/IDE Driver
The ATA driver (~/workspace/source/kernel/src/drivers/storage/ata.rs) implements Programmed I/O (PIO) mode for hard disk access with support for both LBA28 and LBA48 addressing.
Key Features
- Dual-channel support: Primary (0x1F0) and Secondary (0x170) buses
- LBA28: Up to 128 GiB per drive (sector < 0x0FFF_FFFF)
- LBA48: Up to 128 PiB per drive (full 48-bit LBA)
- Automatic detection: IDENTIFY command with ATAPI fallback
- Caching layer: Static drive info cache eliminates redundant bus resets
Architecture
Drive Info Caching (v0.8.0)
To prevent multiple hardware resets that can cause drive disappearance in QEMU/VirtualBox:Cache API
Important:
AtaBus::scan() performs a soft-reset of the ATA bus. Calling it multiple times can cause the controller to become unresponsive on some virtual machines. Use the caching API for repeated access.Error Handling
Error Types
~/workspace/source/kernel/src/drivers/storage/ata.rs:166
PS/2 Input Drivers
Keyboard Driver
Location:~/workspace/source/kernel/src/drivers/input/keyboard.rs
- Extended scancode support (0xE0 prefix for arrow keys)
- Caps lock state tracking
- Shift + key translation for uppercase/symbols
- Unified buffer draining (avoids conflicts with mouse)
Mouse Driver
Location:~/workspace/source/kernel/src/drivers/input/mouse.rs
- PS/2 auxiliary channel initialization
- 3-byte packet protocol (flags + dx + dy)
- 9-bit signed delta reconstruction
- Teleport detection (threshold: 120 pixels)
- Automatic controller reset on error accumulation
- Sensitivity scaling (2x multiplier)
~/workspace/source/kernel/src/drivers/input/mouse.rs:192
PCI Bus Enumeration
Location:~/workspace/source/kernel/src/drivers/bus/pci.rs
PCI Scanning
Device Structure
PCI Device
~/workspace/source/kernel/src/drivers/bus/pci.rs:70
Serial Port Driver
Location:~/workspace/source/kernel/src/drivers/serial.rs
Configuration
- Port: COM1 (0x3F8)
- Baud rate: 38400
- Format: 8N1 (8 data bits, no parity, 1 stop bit)
- FIFO: Enabled with 14-byte threshold
Initialization with Self-Test
Serial Init
~/workspace/source/kernel/src/drivers/serial.rs:38
Log Levels
Logging API
ACPI Power Management
Location:~/workspace/source/kernel/src/drivers/bus/acpi.rs
Provides system power control via ACPI S5 state and keyboard controller reset.
Power Control
Driver Initialization Order
- Serial - COM1 for early boot logging
- PCI - Enumerate devices and bridges
- ATA - Detect storage devices (once, with caching)
- PS/2 - Initialize keyboard and mouse controllers
- ACPI - Parse tables for power management
Boot Sequence
See Also
Filesystem
FAT32 and VFS implementation
Graphics
Framebuffer and rendering
Console
Terminal interface