Began work FAT32 drivers in KBOOT

This commit is contained in:
2025-01-10 11:30:24 +01:00
parent 23ab5d7bfb
commit 295e3d9c18
8 changed files with 220 additions and 27 deletions
+16 -2
View File
@@ -19,6 +19,20 @@ void readSectors(uint32_t lba, size_t count, void* dst) {
}
}
/* TODO */
void writeSectors(uint32_t lba, size_t count, void* src) {}
void writeSectors(uint32_t lba, size_t count, void* src) {
outb(PIO_PORT + 6, ((lba >> 24) & 0x0f) | 0xe0);
outb(PIO_PORT + 2, count);
outb(PIO_PORT + 3, lba & 0xff);
outb(PIO_PORT + 4, (lba >> 8) & 0xff);
outb(PIO_PORT + 5, (lba >> 16) & 0xff);
outb(PIO_PORT + 7, PIO_CMD_WRITE);
uint16_t* buf = (uint16_t*)src;
for (size_t i = 0; i < count; i++) {
while (inb(PIO_PORT + 7) & (1 << 7)); // Wait until BSY is cleared
for (size_t j = 0; j < SECTOR_SIZE / 2; j++) outw(PIO_PORT, *buf++);
for (uint8_t wait = 0; wait < 4; wait++) inb(PIO_ALT_STATUS);
}
}