summaryrefslogtreecommitdiffhomepage
path: root/src/loader/inc
diff options
context:
space:
mode:
authorMarvin Borner2021-07-05 13:38:33 +0200
committerMarvin Borner2021-07-05 13:38:33 +0200
commit981342ef807ebcefba8eeba74511cdcedf9c36bd (patch)
tree2f641c75edd21f7fb064a163c997f23f9dc68978 /src/loader/inc
parenta6858f40888338608fede867d279831e98ec0766 (diff)
Device manager, panic and IDE read
Diffstat (limited to 'src/loader/inc')
-rw-r--r--src/loader/inc/assert.h17
-rw-r--r--src/loader/inc/def.h1
-rw-r--r--src/loader/inc/dev.h30
-rw-r--r--src/loader/inc/pnc.h21
4 files changed, 52 insertions, 17 deletions
diff --git a/src/loader/inc/assert.h b/src/loader/inc/assert.h
deleted file mode 100644
index 65db119..0000000
--- a/src/loader/inc/assert.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// MIT License, Copyright (c) 2021 Marvin Borner
-
-#ifndef ASSERT_H
-#define ASSERT_H
-
-#include <log.h>
-#define assert(exp) \
- { \
- if (!(exp)) { \
- log("%s:%d: %s: Kernel assertion '%s' failed\n", __FILE__, __LINE__, \
- __func__, #exp); \
- while (1) \
- __asm__ volatile("cli\nhlt"); \
- } \
- }
-
-#endif
diff --git a/src/loader/inc/def.h b/src/loader/inc/def.h
index 8c2f9aa..cb41c78 100644
--- a/src/loader/inc/def.h
+++ b/src/loader/inc/def.h
@@ -22,6 +22,7 @@ typedef __builtin_va_list va_list;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define ABS(a) (((a) < 0) ? -(a) : (a))
+#define COUNT(a) (sizeof(a) / sizeof 0 [a])
#define PACKED __attribute__((packed))
diff --git a/src/loader/inc/dev.h b/src/loader/inc/dev.h
new file mode 100644
index 0000000..930b35c
--- /dev/null
+++ b/src/loader/inc/dev.h
@@ -0,0 +1,30 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef DEV_H
+#define DEV_H
+
+#include <def.h>
+
+enum dev_type {
+ DEV_DISK,
+ DEV_FB,
+};
+
+struct dev {
+ u8 id;
+ enum dev_type type;
+ char name[16];
+
+ s32 (*read)(void *, u32, u32, struct dev *);
+ s32 (*write)(const void *, u32, u32, struct dev *);
+
+ u32 data; // Optional (device-specific) data/information
+ u8 exists : 1;
+};
+
+u32 dev_register(enum dev_type type, char *name, u32 data,
+ s32 (*read)(void *, u32, u32, struct dev *),
+ s32 (*write)(const void *, u32, u32, struct dev *));
+void dev_print(void);
+
+#endif
diff --git a/src/loader/inc/pnc.h b/src/loader/inc/pnc.h
new file mode 100644
index 0000000..3de3364
--- /dev/null
+++ b/src/loader/inc/pnc.h
@@ -0,0 +1,21 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef PNC_H
+#define PNC_H
+
+#include <log.h>
+
+#define panic(reason) \
+ { \
+ log("%s:%d: %s: Panic: %s\n", __FILE__, __LINE__, __func__, (reason)); \
+ while (1) \
+ __asm__ volatile("cli\nhlt"); \
+ }
+
+#define assert(exp) \
+ { \
+ if (!(exp)) \
+ panic("Assertion '" #exp "' failed"); \
+ }
+
+#endif