summaryrefslogtreecommitdiff
path: root/src/arch/x86_common/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86_common/include')
-rw-r--r--src/arch/x86_common/include/bindings.h53
-rw-r--r--src/arch/x86_common/include/mboot.h11
-rw-r--r--src/arch/x86_common/include/pic.h31
3 files changed, 95 insertions, 0 deletions
diff --git a/src/arch/x86_common/include/bindings.h b/src/arch/x86_common/include/bindings.h
new file mode 100644
index 0000000..9406774
--- /dev/null
+++ b/src/arch/x86_common/include/bindings.h
@@ -0,0 +1,53 @@
+#pragma once
+
+#include <stdint.h>
+
+static inline uint8_t inb(uint16_t port) {
+ uint8_t ret;
+ __asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+static inline void outb(uint16_t port, uint8_t val) {
+ __asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
+}
+
+static inline uint16_t inw(uint16_t port) {
+ uint16_t ret;
+ __asm__ volatile ("inw %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+static inline void outw(uint16_t port, uint16_t val) {
+ __asm__ volatile ("outw %0, %1" : : "a"(val), "Nd"(port));
+}
+
+static inline uint32_t inl(uint16_t port) {
+ uint32_t ret;
+ __asm__ volatile ("inl %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+static inline void outl(uint16_t port, uint32_t val) {
+ __asm__ volatile ("outl %0, %1" : : "a"(val), "Nd"(port));
+}
+
+static inline void io_wait(void) {
+ outb(0x80, 0);
+}
+
+static inline void sti(void) {
+ __asm__ volatile ("sti");
+}
+
+static inline void cli(void) {
+ __asm__ volatile ("cli");
+}
+
+static inline void int_wait(void) {
+ __asm__ volatile ("sti; hlt");
+}
+
+static inline void halt(void) {
+ __asm__ volatile ("cli; hlt");
+}
diff --git a/src/arch/x86_common/include/mboot.h b/src/arch/x86_common/include/mboot.h
new file mode 100644
index 0000000..d1ca1a0
--- /dev/null
+++ b/src/arch/x86_common/include/mboot.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <shim.h>
+#include <memory.h>
+
+/**
+ * Loads the multi boot information
+ * @param mboot_info - the pointer passed from multiboot2
+ * @param shim_info - the info to be collected by shim
+ */
+void mboot_load_info(long mboot_magic, const volatile void *mboot_data_ptr, volatile struct boot_info *shim_info);
diff --git a/src/arch/x86_common/include/pic.h b/src/arch/x86_common/include/pic.h
new file mode 100644
index 0000000..2a4670e
--- /dev/null
+++ b/src/arch/x86_common/include/pic.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#define PIC_REMAP_OFFSET 0x20
+
+/**
+ * Remaps the pie, i.e. initializes it
+ */
+void pic_remap(void);
+
+/**
+ * Masks an external irq to stop firing until un masked
+ * @param irq - the irq to mask
+ */
+void pic_mask(int irq);
+
+/**
+ * Unmasks an external irq to allow interrupts to continue for that irq
+ * @param irq - the irq to unmask
+ */
+void pic_unmask(int irq);
+
+/**
+ * Disabled the pick
+ */
+void pic_disable(void);
+
+/**
+ * Tells the pick that the interrupt has ended
+ * @param irq - the irq that has ended
+ */
+void pic_eoi(int irq);