diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/ata.asm | 38 | ||||
-rw-r--r-- | src/kernel/ata.h | 23 | ||||
-rw-r--r-- | src/kernel/diskio.c | 29 | ||||
-rw-r--r-- | src/kernel/diskio.h | 9 | ||||
-rw-r--r-- | src/kernel/floppy.asm | 38 | ||||
-rw-r--r-- | src/kernel/floppy.h | 23 | ||||
-rw-r--r-- | src/kernel/ide.asm | 38 | ||||
-rw-r--r-- | src/kernel/ide.h | 23 | ||||
-rw-r--r-- | src/kernel/iso9660.c | 3 |
9 files changed, 213 insertions, 11 deletions
diff --git a/src/kernel/ata.asm b/src/kernel/ata.asm new file mode 100644 index 0000000..40c1cc7 --- /dev/null +++ b/src/kernel/ata.asm @@ -0,0 +1,38 @@ +;Copyright 2019 Benji Dial + +;Permission to use, copy, modify, and/or distribute this +;software for any purpose with or without fee is hereby +;granted, provided that the above copyright notice and this +;permission notice appear in all copies. + +;THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +;ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +;EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +;INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +;RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +;ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +;ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +;OF THIS SOFTWARE. + +global ata_read_sectors +global ata_write_sectors + +section .text +ata_read_sectors:;uint32_t ata_read_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer) + push ebp + mov ebp, esp + + ;TODO + + leave + ret + +ata_write_sectors:;uint32_t ata_write_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer) + push ebp + mov ebp, esp + + ;TODO + + leave + ret
\ No newline at end of file diff --git a/src/kernel/ata.h b/src/kernel/ata.h new file mode 100644 index 0000000..3a1f45e --- /dev/null +++ b/src/kernel/ata.h @@ -0,0 +1,23 @@ +/* +Copyright 2019 Benji Dial + +Permission to use, copy, modify, and/or distribute this +software for any purpose with or without fee is hereby +granted, provided that the above copyright notice and this +permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. +*/ + +#include <stdint.h> + +uint32_t ata_read_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer); +uint32_t ata_write_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer);
\ No newline at end of file diff --git a/src/kernel/diskio.c b/src/kernel/diskio.c index bd08136..69f5964 100644 --- a/src/kernel/diskio.c +++ b/src/kernel/diskio.c @@ -18,17 +18,30 @@ OF THIS SOFTWARE. */ #include "diskio.h" +#include "floppy.h" +#include "ide.h" +#include "ata.h" -uint32_t read_sectors(uint8_t drive, uint32_t start, uint32_t count, void *buffer) { - if ((drive >= 26) || !(drives[drive].flags & DISK_IN)) - return 0; - return 0;//TODO +read_sectors_t read_sectors_functions[] = { + &floppy_read_sectors, + &ide_read_sectors, + &ata_read_sectors +}; + +read_sectors_t get_read_sectors_function(uint8_t drive) { + return (drive >= 26) || !(drives[drive].flags & DISK_IN) ? 0 : + read_sectors_functions[drives[drive].interface]; } -uint32_t write_sectors(uint8_t drive, uint32_t start, uint32_t count, void *buffer) { - if ((drive >= 26) || !(drives[drive].flags & DISK_IN)) - return 0; - return 0;//TODO +write_sectors_t write_sectors_functions[] = { + &floppy_write_sectors, + &ide_write_sectors, + &ata_write_sectors +}; + +write_sectors_t get_write_sectors_function(uint8_t drive) { + return (drive >= 26) || !(drives[drive].flags & DISK_IN) ? 0 : + write_sectors_functions[drives[drive].interface]; } void update_status(uint8_t drive) { diff --git a/src/kernel/diskio.h b/src/kernel/diskio.h index 2f83864..0e16423 100644 --- a/src/kernel/diskio.h +++ b/src/kernel/diskio.h @@ -29,6 +29,11 @@ enum interface { ATA }; +#define N_INTERFACES 3 + +typedef uint32_t (*const read_sectors_t)(uint8_t, uint32_t, uint32_t, void *); +typedef uint32_t (*const write_sectors_t)(uint8_t, uint32_t, uint32_t, void *); + enum drive_flags { SPUN = 0x01, DISK_IN = 0x02, @@ -45,8 +50,8 @@ struct drive_info { struct drive_info drives[26]; -uint32_t read_sectors(uint8_t drive, uint32_t start, uint32_t count, void *buffer); -uint32_t write_sectors(uint8_t drive, uint32_t start, uint32_t count, void *buffer); +read_sectors_t get_read_sectors_function(uint8_t drive); +write_sectors_t get_write_sectors_function(uint8_t drive); void update_status(uint8_t drive); #endif
\ No newline at end of file diff --git a/src/kernel/floppy.asm b/src/kernel/floppy.asm new file mode 100644 index 0000000..3bc02a2 --- /dev/null +++ b/src/kernel/floppy.asm @@ -0,0 +1,38 @@ +;Copyright 2019 Benji Dial + +;Permission to use, copy, modify, and/or distribute this +;software for any purpose with or without fee is hereby +;granted, provided that the above copyright notice and this +;permission notice appear in all copies. + +;THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +;ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +;EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +;INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +;RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +;ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +;ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +;OF THIS SOFTWARE. + +global floppy_read_sectors +global floppy_write_sectors + +section .text +floppy_read_sectors:;uint32_t floppy_read_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer) + push ebp + mov ebp, esp + + ;TODO + + leave + ret + +floppy_write_sectors:;uint32_t floppy_write_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer) + push ebp + mov ebp, esp + + ;TODO + + leave + ret
\ No newline at end of file diff --git a/src/kernel/floppy.h b/src/kernel/floppy.h new file mode 100644 index 0000000..9af534e --- /dev/null +++ b/src/kernel/floppy.h @@ -0,0 +1,23 @@ +/* +Copyright 2019 Benji Dial + +Permission to use, copy, modify, and/or distribute this +software for any purpose with or without fee is hereby +granted, provided that the above copyright notice and this +permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. +*/ + +#include <stdint.h> + +uint32_t floppy_read_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer); +uint32_t floppy_write_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer);
\ No newline at end of file diff --git a/src/kernel/ide.asm b/src/kernel/ide.asm new file mode 100644 index 0000000..b888a06 --- /dev/null +++ b/src/kernel/ide.asm @@ -0,0 +1,38 @@ +;Copyright 2019 Benji Dial + +;Permission to use, copy, modify, and/or distribute this +;software for any purpose with or without fee is hereby +;granted, provided that the above copyright notice and this +;permission notice appear in all copies. + +;THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +;ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +;EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +;INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +;RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +;ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +;ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +;OF THIS SOFTWARE. + +global ide_read_sectors +global ide_write_sectors + +section .text +ide_read_sectors:;uint32_t ide_read_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer) + push ebp + mov ebp, esp + + ;TODO + + leave + ret + +ide_write_sectors:;uint32_t ide_write_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer) + push ebp + mov ebp, esp + + ;TODO + + leave + ret
\ No newline at end of file diff --git a/src/kernel/ide.h b/src/kernel/ide.h new file mode 100644 index 0000000..4592253 --- /dev/null +++ b/src/kernel/ide.h @@ -0,0 +1,23 @@ +/* +Copyright 2019 Benji Dial + +Permission to use, copy, modify, and/or distribute this +software for any purpose with or without fee is hereby +granted, provided that the above copyright notice and this +permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. +*/ + +#include <stdint.h> + +uint32_t ide_read_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer); +uint32_t ide_write_sectors(uint8_t number, uint32_t start, uint32_t count, void *buffer);
\ No newline at end of file diff --git a/src/kernel/iso9660.c b/src/kernel/iso9660.c index 742b34b..ef09116 100644 --- a/src/kernel/iso9660.c +++ b/src/kernel/iso9660.c @@ -24,8 +24,9 @@ OF THIS SOFTWARE. bool iso_9660_parse_ph(uint8_t dn, uint8_t pn, uint32_t sector, uint8_t *buffer) { uint32_t s = sector + 64; + read_sectors_t rsf = get_read_sectors_function(dn); do { - read_sectors(dn, s, 4, buffer); + rsf(drives[dn].number, s, 4, buffer); if ((*buffer == 255) || (*(uint32_t *)&buffer[1] != 0x30304443) || (buffer[5] != (uint8_t)'1')) return false; |