#3: 磁盘控制器
ATA (Advanced Technology Attachment)
- IDE 接口磁盘 (40pin data 很 “肥” 的数据线 + 4pin 电源)
- primary: 0x1f0 - 0x1f7; secondary: 0x170 - 0x177
void readsect(void *dst, int sect) {
waitdisk();
out_byte(0x1f2, 1);
out_byte(0x1f3, sect);
out_byte(0x1f4, sect >> 8);
out_byte(0x1f5, sect >> 16);
out_byte(0x1f6, (sect >> 24) | 0xe0);
out_byte(0x1f7, 0x20);
waitdisk();
for (int i = 0; i < SECTSIZE / 4; i ++)
((uint32_t *)dst)[i] = in_long(0x1f0);
}