summaryrefslogtreecommitdiff
path: root/src/kernel/drive.c
diff options
context:
space:
mode:
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