diff options
Diffstat (limited to 'src/loader/impl')
-rw-r--r-- | src/loader/impl/all.c | 18 | ||||
-rw-r--r-- | src/loader/impl/mb1.c | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/loader/impl/all.c b/src/loader/impl/all.c index 1f19b1e..a5c93b1 100644 --- a/src/loader/impl/all.c +++ b/src/loader/impl/all.c @@ -2,6 +2,7 @@ #include <impl/all.h> #include <impl/mb1.h> +#include <pnc.h> u8 impl_detect(struct dev *dev, const char *path) { @@ -10,3 +11,20 @@ u8 impl_detect(struct dev *dev, const char *path) return 0; } + +void impl_exec(struct dev *dev, const char *path) +{ + assert(dev->type == DEV_DISK); + + switch (dev->p.disk.impl.type) { + case IMPL_MB1: + mb1_exec(dev, path); + break; + case IMPL_MB2: + case IMPL_NONE: + default: + panic("Invalid implementation\n"); + } + + panic("Couldn't execute implementation\n"); +} diff --git a/src/loader/impl/mb1.c b/src/loader/impl/mb1.c index cb75976..765433e 100644 --- a/src/loader/impl/mb1.c +++ b/src/loader/impl/mb1.c @@ -1,6 +1,7 @@ // MIT License, Copyright (c) 2021 Marvin Borner // Everything according to spec +#include <elf.h> #include <impl/mb1.h> #include <pnc.h> @@ -58,3 +59,14 @@ u8 mb1_detect(struct dev *dev, const char *path) return 1; } + +// Execute mb1 type kernel +void mb1_exec(struct dev *dev, const char *path) +{ + u32 entry = elf_load(dev, path); + void (*kernel)(void *); + *(void **)(&kernel) = (void *)entry; + + // TODO: Push mb1 stuff + kernel(dev); +} |