aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/include/dev
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-09 20:21:20 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-09 20:21:20 +0100
commitf6acdfb863038a45709f0dc57884742c51fa6f07 (patch)
treed6a6e5a463ecf7a5f09dbc5a0cb73da32dc2b449 /src/kernel/include/dev
parent45e1c020ae18c18ed0b31f7c12c53ccda2e4ac3a (diff)
downloadkogata-f6acdfb863038a45709f0dc57884742c51fa6f07.tar.gz
kogata-f6acdfb863038a45709f0dc57884742c51fa6f07.zip
Implement V86 monitor and VESA mode detection.
Diffstat (limited to 'src/kernel/include/dev')
-rw-r--r--src/kernel/include/dev/v86.h43
-rw-r--r--src/kernel/include/dev/vesa.h7
2 files changed, 50 insertions, 0 deletions
diff --git a/src/kernel/include/dev/v86.h b/src/kernel/include/dev/v86.h
new file mode 100644
index 0000000..b260fa7
--- /dev/null
+++ b/src/kernel/include/dev/v86.h
@@ -0,0 +1,43 @@
+#pragma once
+
+// This is in no way a complete 16-bit PC virtualizer, only a way
+// to call BIOS functions.
+// It is very ugly: it uses a global mutex and a lot of global variables.
+
+#include <thread.h>
+#include <mutex.h>
+
+#define V86_ALLOC_ADDR 0x20000
+#define V86_STACK_TOP 0x80000
+#define V86_BIOS_BEGIN 0xA0000
+#define V86_BIOS_END 0x100000
+
+typedef uint32_t v86_farptr_t;
+
+#define V86_SEG_OF_LIN(x) ((size_t)(x) >> 4)
+#define V86_OFF_OF_LIN(x) ((size_t)(x) & 0x0F)
+#define V86_LIN_OF_SEG_OFF(seg, off) ((((size_t)(seg)) << 4) + ((size_t)(off)))
+inline void* v86_lin_of_fp(v86_farptr_t x) {
+ return (void*)V86_LIN_OF_SEG_OFF(x>>16, x & 0xFFFF);
+}
+inline v86_farptr_t v86_fp_of_lin(void* p) {
+ return (V86_SEG_OF_LIN(p) << 16) | V86_OFF_OF_LIN(p);
+}
+
+typedef struct {
+ uint16_t ax, bx, cx, dx, di, si;
+ uint16_t cs, ds, es, fs, gs, ss;
+ uint16_t ip, sp;
+} v86_regs_t;
+extern v86_regs_t v86_regs;
+
+bool v86_begin_session();
+
+void* v86_alloc(size_t size);
+
+bool v86_bios_int(uint8_t int_no);
+
+void v86_end_session();
+
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/kernel/include/dev/vesa.h b/src/kernel/include/dev/vesa.h
new file mode 100644
index 0000000..326e54c
--- /dev/null
+++ b/src/kernel/include/dev/vesa.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include <vfs.h>
+
+void vesa_detect(fs_t *iofs);
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/