Files
claude-os/src/port_io.h
AI c07ec030a7 Add IDE/ATA disk driver with devicefs integration
Implement PIO-mode IDE driver that scans primary and secondary channels
for ATA hard drives and ATAPI CD/DVD drives using IDENTIFY commands.

Features:
- Scans 4 possible devices (2 channels x 2 drives each)
- ATA IDENTIFY DEVICE for hard drives
- ATAPI IDENTIFY PACKET DEVICE for CD/DVD drives
- PIO-mode 28-bit LBA sector read/write for ATA drives
- Model string extraction and sector count parsing
- Registers as kernel driver via REGISTER_DRIVER macro
- Registers devices with devicefs: ATA → hdd class, ATAPI → cd class
- Added inw/outw to port_io.h for 16-bit I/O

Tested: QEMU detects hdd1 (QEMU HARDDISK) and cd1 (QEMU DVD-ROM).
2026-02-23 13:57:00 +00:00

38 lines
804 B
C

#ifndef PORT_IO_H
#define PORT_IO_H
#include <stdint.h>
static inline void outb(uint16_t port, uint8_t val)
{
asm volatile ( "outb %b0, %w1" : : "a"(val), "Nd"(port) );
}
static inline uint8_t inb(uint16_t port)
{
uint8_t ret;
asm volatile ( "inb %w1, %b0" : "=a"(ret) : "Nd"(port) );
return ret;
}
static inline void outw(uint16_t port, uint16_t val)
{
asm volatile ( "outw %w0, %w1" : : "a"(val), "Nd"(port) );
}
static inline uint16_t inw(uint16_t port)
{
uint16_t ret;
asm volatile ( "inw %w1, %w0" : "=a"(ret) : "Nd"(port) );
return ret;
}
static inline void io_wait(void)
{
/* Port 0x80 is used for 'checkpoints' during POST. */
/* The Linux kernel seems to think it is free for use :-/ */
asm volatile ( "outb %%al, $0x80" : : "a"(0) );
}
#endif