aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/load.c
diff options
context:
space:
mode:
authorMarvin Borner2020-02-22 17:22:17 +0100
committerMarvin Borner2020-02-22 17:22:17 +0100
commitadd6efeb22ffb7695d5c9addcef073fc653f700e (patch)
tree147c99f2f3e037c877a34468f1494c412ec53416 /src/kernel/fs/load.c
parent86ef6a779a42cf5701632ccb82714a006bae4ee9 (diff)
Well basically nothing really works I guess
I've worked quite a while on several small things which I didn't commit but I'm going away for a week (holiday) soooo I synced these useless and dumb files :)
Diffstat (limited to 'src/kernel/fs/load.c')
-rw-r--r--src/kernel/fs/load.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/kernel/fs/load.c b/src/kernel/fs/load.c
index cd422d0..5a476b5 100644
--- a/src/kernel/fs/load.c
+++ b/src/kernel/fs/load.c
@@ -5,6 +5,8 @@
#include <kernel/system.h>
#include <kernel/fs/iso9660/iso9660.h>
#include <kernel/memory/alloc.h>
+#include <kernel/lib/stdio.h>
+#include <kernel/lib/lib.h>
void load_binaries()
{
@@ -31,4 +33,46 @@ void load_binaries()
kfree(user_e);
}
vga_log("Successfully loaded binaries");
+}
+
+#define MAX_LOADERS 16
+
+loader_t **loaders = 0;
+uint8_t last_loader = 0;
+
+uint32_t last_load_loc = 0x400000;
+
+void loader_init()
+{
+ serial_printf("Setting up loader");
+ loaders = (loader_t **) kmalloc(MAX_LOADERS * sizeof(uint32_t));
+ memset(loaders, 0, MAX_LOADERS * sizeof(uint32_t));
+ // _kill();
+}
+
+void register_loader(loader_t *load)
+{
+ if (last_loader + 1 > MAX_LOADERS) return;
+ if (!load) return;
+ loaders[last_loader] = load;
+ last_loader++;
+ serial_printf("Registered %s loader as id %d", load->name, last_loader - 1);
+}
+
+uint32_t loader_get_unused_load_location()
+{
+ last_load_loc += 0x400000;
+ return last_load_loc;
+}
+
+uint8_t exec_start(uint8_t *buf)
+{
+ for (int i = 0; i < MAX_LOADERS; i++) {
+ if (!loaders[i]) break;
+ void *priv = loaders[i]->probe(buf);
+ if (priv) {
+ return loaders[i]->start(buf, priv);
+ }
+ }
+ return 0;
} \ No newline at end of file