Storage Drivers
Overview
The FreeWorld OS storage driver system provides comprehensive support for all major storage interfaces, including AHCI/SATA, NVMe, USB storage, SCSI, and CD/DVD drives.
AHCI/SATA Driver
File: kernel/drivers/ahci.asm
Full implementation of the Advanced Host Controller Interface (AHCI) for SATA devices.
Features
- AHCI controller initialization and configuration
- Port enumeration (up to 32 ports per controller)
- Device type detection (ATA, ATAPI, SEMB, PM)
- Native Command Queuing (NCQ)
- DMA transfers
- Device identification (IDENTIFY command)
- LBA48 support (large disk support)
- Read/write operations
- Error handling and recovery
API
ahci_init()- Initialize AHCI controllerahci_read_sectors()- Read sectors from portahci_write_sectors()- Write sectors to portahci_find_controller()- Find controller by PCI device
NVMe Driver
File: kernel/drivers/nvme.asm
Complete implementation of Non-Volatile Memory Express (NVMe) for modern SSDs.
Features
- NVMe controller initialization
- Admin queue support (1024 entries)
- I/O queue support (up to 16 queues)
- Command submission and completion
- Multiple namespace support (up to 32 namespaces)
- Controller identification
- Namespace identification
- LBA64 support (very large disk support)
- Read/write operations
API
nvme_init()- Initialize NVMe controllernvme_read_sectors()- Read sectors from namespacenvme_write_sectors()- Write sectors to namespace
USB Storage Driver
File: kernel/drivers/usb_storage.asm
USB Mass Storage Class driver with Bulk-Only Transport (BOT) protocol support.
Features
- USB Mass Storage Class detection
- Bulk-Only Transport (BOT) protocol
- SCSI command passthrough
- Multiple LUN support (up to 8 LUNs)
- Device identification (INQUIRY)
- Capacity reading (READ CAPACITY)
- Read/write operations
- Command Block Wrapper (CBW) handling
- Command Status Wrapper (CSW) handling
API
usb_storage_init()- Initialize USB storage deviceusb_storage_read_sectors()- Read sectors from LUNusb_storage_write_sectors()- Write sectors to LUN
SCSI Driver
File: kernel/drivers/scsi.asm
SCSI command set implementation with support for multiple controller types.
Features
- SCSI command set implementation
- Multiple controller type support (AHCI, USB, NVMe, ATA)
- Command routing to appropriate controller
- INQUIRY command support
- READ CAPACITY command support
- Read/write operations
Controller Types
- AHCI - SATA devices via AHCI
- USB - USB storage devices
- NVMe - NVMe SSDs
- ATA - Legacy ATA devices
API
scsi_init()- Initialize SCSI devicescsi_read_sectors()- Read sectors via SCSIscsi_write_sectors()- Write sectors via SCSI
CD/DVD Driver
File: kernel/drivers/cddvd.asm
ATAPI-based driver for optical disc drives (CD, DVD, Blu-ray).
Features
- ATAPI device detection
- Drive type detection (CD, DVD, Blu-ray)
- Disc type detection (CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R, DVD-RW, DVD-RAM, BD-ROM, BD-R, BD-RE)
- Disc presence detection
- Table of Contents (TOC) reading
- Capacity reading
- Track information
- Read operations (2048-byte sectors)
- Eject/close tray support
API
cddvd_init()- Initialize CD/DVD drivecddvd_read_sectors()- Read sectors from disccddvd_eject()- Eject disccddvd_close_tray()- Close tray
Implementation Statistics
Total Lines of Code: ~3,448 lines
- AHCI/SATA: ~1,200 lines
- NVMe: ~900 lines
- USB Storage: ~800 lines
- SCSI: ~300 lines
- CD/DVD: ~250 lines
Integration
All storage drivers are integrated with:
- Kernel initialization sequence
- PCI enumeration (for AHCI, NVMe)
- USB system (for USB storage)
- Filesystem layer (for block device access)