summaryrefslogtreecommitdiffhomepage
path: root/src/loader/inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/loader/inc')
-rw-r--r--src/loader/inc/cfg.h1
-rw-r--r--src/loader/inc/dev.h12
-rw-r--r--src/loader/inc/fs/ext2.h4
-rw-r--r--src/loader/inc/impl/all.h23
-rw-r--r--src/loader/inc/impl/mb1.h8
-rw-r--r--src/loader/inc/pnc.h4
6 files changed, 40 insertions, 12 deletions
diff --git a/src/loader/inc/cfg.h b/src/loader/inc/cfg.h
index a214db2..1332fe1 100644
--- a/src/loader/inc/cfg.h
+++ b/src/loader/inc/cfg.h
@@ -17,6 +17,5 @@ enum cfg_key {
const void *cfg_get(u8 index, enum cfg_key key);
void cfg_exec(void);
-void cfg_print(void);
#endif
diff --git a/src/loader/inc/dev.h b/src/loader/inc/dev.h
index 9d9913e..9e64bdb 100644
--- a/src/loader/inc/dev.h
+++ b/src/loader/inc/dev.h
@@ -5,6 +5,7 @@
#include <def.h>
#include <dsk.h>
+#include <impl/all.h>
enum dev_type {
DEV_DISK,
@@ -19,12 +20,19 @@ struct dev {
s32 (*read)(void *, u32, u32, struct dev *);
s32 (*write)(const void *, u32, u32, struct dev *);
- struct fs fs;
+ union {
+ struct {
+ struct fs fs;
+ struct impl impl;
+ } disk;
+ // TODO: Other (framebuffer?)
+ } p; // Prototype union
u32 data; // Optional (device-specific) data/information
};
-struct dev *dev_get(u8 id);
+struct dev *dev_get_by_id(u8 id);
+struct dev *dev_get_by_name(const char *name, u32 len);
void dev_foreach(enum dev_type type, u8 (*cb)(struct dev *)); // cb=1 => break
u8 dev_register(enum dev_type type, char *name, u32 data,
s32 (*read)(void *, u32, u32, struct dev *),
diff --git a/src/loader/inc/fs/ext2.h b/src/loader/inc/fs/ext2.h
index 10650cd..0c2052a 100644
--- a/src/loader/inc/fs/ext2.h
+++ b/src/loader/inc/fs/ext2.h
@@ -1,7 +1,7 @@
// MIT License, Copyright (c) 2021 Marvin Borner
-#ifndef EXT2_H
-#define EXT2_H
+#ifndef FS_EXT2_H
+#define FS_EXT2_H
#include <def.h>
#include <dev.h>
diff --git a/src/loader/inc/impl/all.h b/src/loader/inc/impl/all.h
new file mode 100644
index 0000000..366b1b3
--- /dev/null
+++ b/src/loader/inc/impl/all.h
@@ -0,0 +1,23 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef IMPL_ALL_H
+#define IMPL_ALL_H
+
+#include <def.h>
+
+enum impl_type {
+ IMPL_NONE,
+ IMPL_MB1,
+ IMPL_MB2,
+};
+
+struct impl {
+ enum impl_type type;
+ void *start; // Of header/entry
+};
+
+#include <dev.h>
+
+u8 impl_detect(struct dev *dev, const char *path);
+
+#endif
diff --git a/src/loader/inc/impl/mb1.h b/src/loader/inc/impl/mb1.h
index fa0efc1..fcaf048 100644
--- a/src/loader/inc/impl/mb1.h
+++ b/src/loader/inc/impl/mb1.h
@@ -1,13 +1,11 @@
// MIT License, Copyright (c) 2021 Marvin Borner
-#ifndef MB1_H
-#define MB1_H
+#ifndef IMPL_MB1_H
+#define IMPL_MB1_H
#include <def.h>
#include <dev.h>
-#define MB1_MAGIC 0x1badb002
-
-u8 mb1_probe(struct dev *dev);
+u8 mb1_detect(struct dev *dev, const char *path);
#endif
diff --git a/src/loader/inc/pnc.h b/src/loader/inc/pnc.h
index 3de3364..1630bd9 100644
--- a/src/loader/inc/pnc.h
+++ b/src/loader/inc/pnc.h
@@ -7,7 +7,7 @@
#define panic(reason) \
{ \
- log("%s:%d: %s: Panic: %s\n", __FILE__, __LINE__, __func__, (reason)); \
+ log("%s:%d: %s: Panic: %s", __FILE__, __LINE__, __func__, (reason)); \
while (1) \
__asm__ volatile("cli\nhlt"); \
}
@@ -15,7 +15,7 @@
#define assert(exp) \
{ \
if (!(exp)) \
- panic("Assertion '" #exp "' failed"); \
+ panic("Assertion '" #exp "' failed\n"); \
}
#endif