From 7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 13 Aug 2020 23:59:14 -0400 Subject: FAT16 directory enumeration, making many functions static, new 'log' functions to wrap vga and serial --- src/kernel/ide.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'src/kernel/ide.c') diff --git a/src/kernel/ide.c b/src/kernel/ide.c index a32f149..a4ba34c 100644 --- a/src/kernel/ide.c +++ b/src/kernel/ide.c @@ -14,25 +14,13 @@ struct ide_drive_info { bool slave; }; -struct ide_drive_info ide_drives[MAX_IDE_DRIVES]; -drive_id_t n_ide_drives = 0; +static struct ide_drive_info ide_drives[MAX_IDE_DRIVES]; +static drive_id_t n_ide_drives = 0; typedef uint16_t spinner_t; //returns the status after waiting -uint8_t wait_after_cmd(uint16_t base_port) { - for (spinner_t n = -1; n; --n) { - uint8_t s = inb(base_port | ATA_REG_STATUS); - if (s & ATA_STATUS_ERROR) - panic("Error status in IDE driver."); - if (!(s & ATA_STATUS_BUSY)) - return s; - } - panic("Spun out in IDE driver."); -} - -//returns the status after waiting -uint8_t wait_for_ready(uint16_t base_port) { +static uint8_t wait_for_ready(uint16_t base_port) { for (spinner_t n = -1; n; --n) { uint8_t s = inb(base_port | ATA_REG_STATUS); if (s & ATA_STATUS_ERROR) @@ -44,7 +32,7 @@ uint8_t wait_for_ready(uint16_t base_port) { } //returns the status after waiting -uint8_t wait_for_error_or_ready(uint16_t base_port) { +static uint8_t wait_for_error_or_ready(uint16_t base_port) { for (spinner_t n = -1; n; --n) { uint8_t s = inb(base_port | ATA_REG_STATUS); if (s & (ATA_STATUS_DRIVE_READY | ATA_STATUS_ERROR)) @@ -54,7 +42,7 @@ uint8_t wait_for_error_or_ready(uint16_t base_port) { } //returns the status after waiting -uint8_t wait_for_data_ready_not_busy(uint16_t base_port) { +static uint8_t wait_for_data_ready_not_busy(uint16_t base_port) { for (spinner_t n = -1; n; --n) { uint8_t s = inb(base_port | ATA_REG_STATUS); if (!(s & ATA_STATUS_BUSY) && (s & ATA_STATUS_DATA_READY)) @@ -65,7 +53,7 @@ uint8_t wait_for_data_ready_not_busy(uint16_t base_port) { panic("Spun out in IDE driver."); } -uint8_t ide_ata_rs(const struct drive *d, uint32_t start, uint32_t count, void *buffer) { +static uint8_t ide_ata_rs(const struct drive *d, uint32_t start, uint32_t count, void *buffer) { if (start >= d->n_sectors) return 0; if (start + count > d->n_sectors) @@ -103,17 +91,17 @@ uint8_t ide_ata_rs(const struct drive *d, uint32_t start, uint32_t count, void * return count; } -uint8_t ide_ata_ws(const struct drive *d, uint32_t start, uint32_t count, const void *buffer) { +static uint8_t ide_ata_ws(const struct drive *d, uint32_t start, uint32_t count, const void *buffer) { panic("IDE ATA writing not implemented yet"); return 0; } -uint8_t ide_atapi_rs(const struct drive *d, uint32_t start, uint32_t count, void *buffer) { +static uint8_t ide_atapi_rs(const struct drive *d, uint32_t start, uint32_t count, void *buffer) { //panic("IDE ATAPI reading not implemented yet"); return 0; } -uint8_t ide_atapi_ws(const struct drive *d, uint32_t start, uint32_t count, const void *buffer) { +static uint8_t ide_atapi_ws(const struct drive *d, uint32_t start, uint32_t count, const void *buffer) { panic("IDE ATAPI writing not implemented yet"); return 0; } @@ -124,9 +112,7 @@ struct id_space { uint8_t skip2[512 - (120 + 4)]; } __attribute__ ((__packed__ )); -void vga_printsz(char *s); - -void test_drive(uint16_t base_port, uint16_t alt_port, bool slave) { +static void test_drive(uint16_t base_port, uint16_t alt_port, bool slave) { if (n_ide_drives == MAX_IDE_DRIVES) panic("Maximum number of IDE drives reached."); -- cgit v1.2.3