From e8c6577617bffa4402c07c7aa20e3c24f03c1c20 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 6 Sep 2020 00:48:07 -0400 Subject: program loading, others big kernel additions: paging, elf loading, separate kernel and user page allocation it now properly loads and runs sd0:bin/init.elf still need to determine which disk was booted from, and start the init on that disk --- src/kernel/drive.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/kernel/drive.c') diff --git a/src/kernel/drive.c b/src/kernel/drive.c index 38fef38..c3aa5b2 100644 --- a/src/kernel/drive.c +++ b/src/kernel/drive.c @@ -2,23 +2,27 @@ #include "panic.h" #include "fat.h" -uint8_t n_drives = 0; +uint8_t n_drives; struct drive drives[256]; +void init_drives() { + n_drives = 0; +} + __attribute__ ((const)) -static drive_file_id_t unknown_get_file(const struct drive *d, const char *path) { +static file_id_t unknown_get_file(const struct drive *d, const char *path) { return 0; } -static void unknown_free_file(const struct drive *d, drive_file_id_t fid) { +static void unknown_free_file(const struct drive *d, file_id_t fid) { panic("Free file called on unknown file system"); } -static void unknown_load_sector(const struct drive *d, drive_file_id_t fid, uint32_t sector, void *at) { +static void unknown_load_sector(const struct drive *d, file_id_t fid, uint32_t sector, void *at) { panic("Load sector called on unknown file system"); } -static uint32_t unknown_get_file_length(const struct drive *d, drive_file_id_t fid) { +static uint32_t unknown_get_file_length(const struct drive *d, file_id_t fid) { panic("Get file length called on unknown file system"); } @@ -32,7 +36,7 @@ static uint32_t unknown_enumerate_dir(const struct drive *d, const char *path, s return 0; } -static void determine_fs(struct drive *d) { +static inline void determine_fs(struct drive *d) { if (try_fat_init_drive(d)) return; @@ -45,7 +49,12 @@ static void determine_fs(struct drive *d) { d->get_free_sectors = &unknown_get_free_sectors; } +//drive should be ready before this. +//determine_fs and its children +//do not need to make ready or done void commit_drive(struct drive data) { determine_fs(&data); - drives[n_drives++] = data; + drives[n_drives] = data; + data.done(drives + n_drives); + ++n_drives; } \ No newline at end of file -- cgit v1.2.3