summaryrefslogtreecommitdiffstats
path: root/include/device
diff options
context:
space:
mode:
Diffstat (limited to 'include/device')
-rw-r--r--include/device/initrd.h29
-rw-r--r--include/device/portio.h26
-rw-r--r--include/device/portio_uart.h27
-rw-r--r--include/device/processor.h22
-rw-r--r--include/device/uart.h11
5 files changed, 115 insertions, 0 deletions
diff --git a/include/device/initrd.h b/include/device/initrd.h
new file mode 100644
index 0000000..eaf3157
--- /dev/null
+++ b/include/device/initrd.h
@@ -0,0 +1,29 @@
+#ifndef _JOVE_DEV_INITRD_H
+#define _JOVE_DEV_INITRD_H 1
+
+#include <stddef.h>
+
+typedef struct tarHeader
+{
+ char name[100];
+ char mode[8];
+ char owner[8];
+ char group[8];
+ char size[12];
+ char modified[12];
+ char checksum[8];
+ char link;
+ char linkname[100];
+} tar_header_t;
+
+typedef union tarBlock {
+ tar_header_t header;
+ char data[512];
+} tar_block_t;
+
+void initrd_setup(void);
+
+tar_header_t *initrd_find_file(const char *filename);
+int initrd_file_size(tar_header_t *header);
+
+#endif
diff --git a/include/device/portio.h b/include/device/portio.h
new file mode 100644
index 0000000..76b28c4
--- /dev/null
+++ b/include/device/portio.h
@@ -0,0 +1,26 @@
+#ifndef _JOVE_PORTIO_H
+#define _JOVE_PORTIO_H 1
+
+#include <stdint.h>
+
+typedef uint16_t ioport_t;
+
+static inline uint8_t port_inb(ioport_t port)
+{ uint8_t r; __asm__ volatile("inb %w1, %b0": "=a"(r): "Nd"(port): "memory"); return r; }
+
+static inline uint16_t port_inw(ioport_t port)
+{ uint16_t r; __asm__ volatile("inw %w1, %w0": "=a"(r): "Nd"(port): "memory"); return r; }
+
+static inline uint32_t port_inl(ioport_t port)
+{ uint32_t r; __asm__ volatile("inl %d1, %l0": "=a"(r): "Nd"(port): "memory"); return r; }
+
+static inline void port_outb(ioport_t port, uint8_t v)
+{ __asm__ volatile("outb %b0, %w1":: "a"(v), "Nd"(port): "memory"); }
+
+static inline void port_outw(ioport_t port, uint16_t v)
+{ __asm__ volatile("outb %w0, %w1":: "a"(v), "Nd"(port): "memory"); }
+
+static inline void port_outl(ioport_t port, uint32_t v)
+{ __asm__ volatile("outb %d0, %w1":: "a"(v), "Nd"(port): "memory"); }
+
+#endif
diff --git a/include/device/portio_uart.h b/include/device/portio_uart.h
new file mode 100644
index 0000000..1b521a1
--- /dev/null
+++ b/include/device/portio_uart.h
@@ -0,0 +1,27 @@
+#ifndef _JOVE_DEVICE_PORTIO_UART
+#define _JOVE_DEVICE_PORTIO_UART 1
+
+#include <stdint.h>
+
+#define PORTIO_UART_COM1 0x3F8
+
+#define PORTIO_UART_COM_THR(COM) COM
+#define PORTIO_UART_COM_RBR(COM) COM
+#define PORTIO_UART_COM_DLAB_DLL(COM) COM
+#define PORTIO_UART_COM_IER(COM) (COM + 1)
+#define PORTIO_UART_COM_DLAB_DLH(COM) (COM + 1)
+#define PORTIO_UART_COM_IIR(COM) (COM + 2)
+#define PORTIO_UART_COM_FCR(COM) (COM + 2)
+#define PORTIO_UART_COM_LCR(COM) (COM + 3)
+#define PORTIO_UART_COM_MCR(COM) (COM + 4)
+#define PORTIO_UART_COM_LSR(COM) (COM + 5)
+#define PORTIO_UART_COM_MSR(COM) (COM + 6)
+#define PORTIO_UART_COM_SR(COM) (COM + 7)
+
+void
+portio_uart_setup(void);
+
+void
+portio_uart_write(uint64_t dev, const char *s, int n);
+
+#endif
diff --git a/include/device/processor.h b/include/device/processor.h
new file mode 100644
index 0000000..33deed4
--- /dev/null
+++ b/include/device/processor.h
@@ -0,0 +1,22 @@
+#ifndef _JOVE_DEVICE_PROCESSOR_H
+#define _JOVE_DEVICE_PROCESSOR_H 1
+
+#if defined(__x86_64__)
+#include "arch/x86_64/processor.h"
+#endif
+
+/**@FUNC Initialize the bootstrap processor.*/
+void bsp_setup(void);
+/**@FUNC Initialize the given processor with kernel-specific values.
+ * Generically:
+ * Instantiates a new kernel object representing the passed processor.
+ * For x86_64:
+ * Loads and uses the generic GDT and IDT.
+ * @PARAM processor processor to initialize.*/
+void processor_setup(void* processor);
+
+/**@FUNC Returns the processor struct this function is called by.
+ * @RET pointer to current processor.*/
+void *processor_current(void);
+
+#endif
diff --git a/include/device/uart.h b/include/device/uart.h
new file mode 100644
index 0000000..3d481a2
--- /dev/null
+++ b/include/device/uart.h
@@ -0,0 +1,11 @@
+#ifndef _JOVE_DEVICE_UART_H
+#define _JOVE_DEVICE_UART_H 1
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include "object.h"
+
+void uart_write(objdir_t *dir, uint64_t entryi, const char *s, size_t w);
+
+#endif