summaryrefslogtreecommitdiffhomepage
path: root/src/loader/protocols/all.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/loader/protocols/all.c')
-rw-r--r--src/loader/protocols/all.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/loader/protocols/all.c b/src/loader/protocols/all.c
new file mode 100644
index 0000000..8ea16dd
--- /dev/null
+++ b/src/loader/protocols/all.c
@@ -0,0 +1,36 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#include <protocols/all.h>
+#include <protocols/mb1.h>
+#include <protocols/mb2.h>
+#include <panic.h>
+
+u8 impl_detect(struct config_entry *cfg)
+{
+ if (mb1_detect(cfg))
+ return 1;
+
+ if (mb2_detect(cfg))
+ return 1;
+
+ return 0;
+}
+
+void impl_exec(struct config_entry *cfg)
+{
+ assert(cfg->dev->type == DEVICE_DISK);
+
+ switch (cfg->impl.type) {
+ case IMPL_MB1:
+ mb1_exec(cfg);
+ break;
+ case IMPL_MB2:
+ mb2_exec(cfg);
+ break;
+ case IMPL_NONE:
+ default:
+ panic("Invalid implementation\n");
+ }
+
+ panic("Couldn't execute implementation\n");
+}