summaryrefslogtreecommitdiff
path: root/src/kernel/diskio.c
diff options
context:
space:
mode:
authorBenji Dial <benji3.141@gmail.com>2020-01-05 22:26:40 -0500
committerBenji Dial <benji3.141@gmail.com>2020-01-05 22:26:40 -0500
commit243e28075e223bd9be145251161b692873918764 (patch)
treeb8b2314ae2e7303149780b7bfb25a7e61c6ebcfa /src/kernel/diskio.c
parent3ec928b8ca8cbf51310bce62afafe0874e920c24 (diff)
downloadportland-os-243e28075e223bd9be145251161b692873918764.tar.gz
function to return pointers to functions to read from a constant interface, so we only have to check the interface once per macro operation
Diffstat (limited to 'src/kernel/diskio.c')
-rw-r--r--src/kernel/diskio.c29
1 files changed, 21 insertions, 8 deletions
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) {