summaryrefslogtreecommitdiff
path: root/src/kernel/drive.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-06 00:48:07 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-06 00:48:07 -0400
commite8c6577617bffa4402c07c7aa20e3c24f03c1c20 (patch)
tree2fb9230b62d2344a44453117de9e656892219788 /src/kernel/drive.c
parent7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 (diff)
downloadportland-os-e8c6577617bffa4402c07c7aa20e3c24f03c1c20.tar.gz
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
Diffstat (limited to 'src/kernel/drive.c')
-rw-r--r--src/kernel/drive.c23
1 files changed, 16 insertions, 7 deletions
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