summaryrefslogtreecommitdiff
path: root/arch/i386/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/include')
-rw-r--r--arch/i386/include/kernel/asm.h84
-rw-r--r--arch/i386/include/kernel/idt.h1
-rw-r--r--arch/i386/include/kernel/isr.h78
-rw-r--r--arch/i386/include/kernel/keyboard.h3
-rw-r--r--arch/i386/include/kernel/paging.h18
-rw-r--r--arch/i386/include/kernel/pic.h17
-rw-r--r--arch/i386/include/kernel/syscall.h8
-rw-r--r--arch/i386/include/kernel/timer.h4
8 files changed, 98 insertions, 115 deletions
diff --git a/arch/i386/include/kernel/asm.h b/arch/i386/include/kernel/asm.h
index 33ec3d7..615da74 100644
--- a/arch/i386/include/kernel/asm.h
+++ b/arch/i386/include/kernel/asm.h
@@ -1,6 +1,90 @@
#ifndef I386_ASM_H
#define I386_ASM_H
+#include <stdint.h>
+
+struct regs {
+ uint32_t cr4;
+ uint32_t cr3;
+ uint32_t cr2;
+ uint32_t cr0;
+
+ uint32_t edi;
+ uint32_t esi;
+ uint32_t edx;
+ uint32_t ecx;
+ uint32_t ebx;
+ uint32_t eax;
+
+ uint32_t isr_vector;
+ uint32_t isr_err;
+ uint32_t eip;
+ uint32_t cs;
+ uint32_t eflags;
+} __attribute__((packed));
+
+void isr_stub_0(void);
+void isr_stub_1(void);
+void isr_stub_2(void);
+void isr_stub_3(void);
+void isr_stub_4(void);
+void isr_stub_5(void);
+void isr_stub_6(void);
+void isr_stub_7(void);
+void isr_stub_8(void);
+void isr_stub_9(void);
+void isr_stub_10(void);
+void isr_stub_11(void);
+void isr_stub_12(void);
+void isr_stub_13(void);
+void isr_stub_14(void);
+void isr_stub_15(void);
+void isr_stub_16(void);
+void isr_stub_17(void);
+void isr_stub_18(void);
+void isr_stub_19(void);
+void isr_stub_20(void);
+void isr_stub_21(void);
+void isr_stub_22(void);
+void isr_stub_23(void);
+void isr_stub_24(void);
+void isr_stub_25(void);
+void isr_stub_26(void);
+void isr_stub_27(void);
+void isr_stub_28(void);
+void isr_stub_29(void);
+void isr_stub_30(void);
+void isr_stub_31(void);
+
+void irq_stub_0(void);
+void irq_stub_1(void);
+void irq_stub_2(void);
+void irq_stub_3(void);
+void irq_stub_4(void);
+void irq_stub_5(void);
+void irq_stub_6(void);
+void irq_stub_7(void);
+void irq_stub_8(void);
+void irq_stub_9(void);
+void irq_stub_10(void);
+void irq_stub_11(void);
+void irq_stub_12(void);
+void irq_stub_13(void);
+void irq_stub_14(void);
+void irq_stub_15(void);
+
+void syscall_stub(void);
+
+static inline void outb(uint16_t port, uint8_t value) {
+ __asm__ volatile("outb %0, %1" : : "a"(value), "Nd"(port));
+}
+
+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 enable_ints(void) {
__asm__ volatile("sti");
return;
diff --git a/arch/i386/include/kernel/idt.h b/arch/i386/include/kernel/idt.h
index 6873a3b..29ec39f 100644
--- a/arch/i386/include/kernel/idt.h
+++ b/arch/i386/include/kernel/idt.h
@@ -3,7 +3,6 @@
#include <stdint.h>
-// IDT Flags
#define SEGMENT_PRESENT 0x80
#define SEGMENT_RING0 0x00
#define SEGMENT_RING3 0x60
diff --git a/arch/i386/include/kernel/isr.h b/arch/i386/include/kernel/isr.h
deleted file mode 100644
index 4e21f8f..0000000
--- a/arch/i386/include/kernel/isr.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef I386_ISR_H
-#define I386_ISR_H
-
-#include <stdint.h>
-
-struct isr_frame {
- uint32_t cr4;
- uint32_t cr3;
- uint32_t cr2;
- uint32_t cr0;
-
- uint32_t edi;
- uint32_t esi;
- uint32_t edx;
- uint32_t ecx;
- uint32_t ebx;
- uint32_t eax;
-
- uint32_t vector;
- uint32_t errno;
- uint32_t eip;
- uint32_t cs;
- uint32_t eflags;
-} __attribute__((packed));
-
-extern void isr_stub_0(void);
-extern void isr_stub_1(void);
-extern void isr_stub_2(void);
-extern void isr_stub_3(void);
-extern void isr_stub_4(void);
-extern void isr_stub_5(void);
-extern void isr_stub_6(void);
-extern void isr_stub_7(void);
-extern void isr_stub_8(void);
-extern void isr_stub_9(void);
-extern void isr_stub_10(void);
-extern void isr_stub_11(void);
-extern void isr_stub_12(void);
-extern void isr_stub_13(void);
-extern void isr_stub_14(void);
-extern void isr_stub_15(void);
-extern void isr_stub_16(void);
-extern void isr_stub_17(void);
-extern void isr_stub_18(void);
-extern void isr_stub_19(void);
-extern void isr_stub_20(void);
-extern void isr_stub_21(void);
-extern void isr_stub_22(void);
-extern void isr_stub_23(void);
-extern void isr_stub_24(void);
-extern void isr_stub_25(void);
-extern void isr_stub_26(void);
-extern void isr_stub_27(void);
-extern void isr_stub_28(void);
-extern void isr_stub_29(void);
-extern void isr_stub_30(void);
-extern void isr_stub_31(void);
-
-extern void irq_stub_0(void);
-extern void irq_stub_1(void);
-extern void irq_stub_2(void);
-extern void irq_stub_3(void);
-extern void irq_stub_4(void);
-extern void irq_stub_5(void);
-extern void irq_stub_6(void);
-extern void irq_stub_7(void);
-extern void irq_stub_8(void);
-extern void irq_stub_9(void);
-extern void irq_stub_10(void);
-extern void irq_stub_11(void);
-extern void irq_stub_12(void);
-extern void irq_stub_13(void);
-extern void irq_stub_14(void);
-extern void irq_stub_15(void);
-
-extern void syscall_stub(void);
-
-#endif
diff --git a/arch/i386/include/kernel/keyboard.h b/arch/i386/include/kernel/keyboard.h
index 8f39a70..7b63993 100644
--- a/arch/i386/include/kernel/keyboard.h
+++ b/arch/i386/include/kernel/keyboard.h
@@ -1,7 +1,6 @@
#ifndef I386_KEYBOARD_H
#define I386_KEYBOARD_H
-#include <kernel/isr.h>
#include <stdint.h>
#define KB_STAT 0x64
@@ -28,6 +27,6 @@
#define KB_DEL 0xE9
char keyboard_getchar(void);
-void keyboard_handler(struct isr_frame *frame);
+void keyboard_handler(void);
#endif
diff --git a/arch/i386/include/kernel/paging.h b/arch/i386/include/kernel/paging.h
index bb79d09..7f820e8 100644
--- a/arch/i386/include/kernel/paging.h
+++ b/arch/i386/include/kernel/paging.h
@@ -1,7 +1,7 @@
#ifndef I386_PAGING_H
#define I386_PAGING_H
-#include <kernel/isr.h>
+#include <kernel/asm.h>
#include <kernel/multiboot.h>
#include <kernel/data/list.h>
#include <stdint.h>
@@ -25,21 +25,11 @@
#define PAGE_SIZE 4096
-#define DMA_BITMAP_SZ 128
-#define BDY_BITMAP_SZ 32640
-
-struct pfa_buddy {
- uintptr_t start;
- uintptr_t *bitmap;
- uint8_t size;
- struct list_head list;
-};
-
-void load_page_dir(uintptr_t pd_addr);
-void enable_paging(void);
+uint32_t* init_page_table(uint32_t flags);
+void enable_paging(uintptr_t pd_addr);
void paging_init(void);
-void page_fault_handler(struct isr_frame *frame);
+void page_fault_handler(struct regs *regs);
uint32_t get_vaddr(uintptr_t paddr);
diff --git a/arch/i386/include/kernel/pic.h b/arch/i386/include/kernel/pic.h
index ca3cc99..2b757ee 100644
--- a/arch/i386/include/kernel/pic.h
+++ b/arch/i386/include/kernel/pic.h
@@ -1,8 +1,7 @@
#ifndef I386_PIC_H
#define I386_PIC_H
-#include <kernel/isr.h>
-#include <kernel/idt.h>
+#include <kernel/asm.h>
#include <stdint.h>
#define PIC1 0x20
@@ -27,16 +26,6 @@
#define PIC_READ_IRR 0x0A
#define PIC_READ_ISR 0x0B
-static inline void outb(uint16_t port, uint8_t value) {
- __asm__ volatile("outb %0, %1" : : "a"(value), "Nd"(port));
-}
-
-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 io_wait(void) {
outb(0x80, 0);
}
@@ -46,8 +35,8 @@ void pic_remap(void);
uint16_t pic_get_irr(void);
uint16_t pic_get_isr(void);
-void register_irq_handler(uint8_t irq, void (*handler)(struct isr_frame *frame));
-void irq_dispatch(struct isr_frame *frame);
+void register_irq_handler(uint8_t irq, void (*handler)(struct regs *regs));
+void irq_dispatch(struct regs *regs);
void irq_set_mask(uint8_t irq);
void irq_clear_mask(uint8_t irq);
diff --git a/arch/i386/include/kernel/syscall.h b/arch/i386/include/kernel/syscall.h
index 788e5da..88ee59a 100644
--- a/arch/i386/include/kernel/syscall.h
+++ b/arch/i386/include/kernel/syscall.h
@@ -1,7 +1,8 @@
#ifndef I386_SYSCALL_H
#define I386_SYSCALL_H
-#include <kernel/isr.h>
+#include <kernel/asm.h>
+#include <stdint.h>
#include <stddef.h>
// Unix standard calls
@@ -23,11 +24,10 @@
#define SYS_LINK 16
#define SYS_MKDIR 17
#define SYS_CLOSE 18
+#define SYS_EXEC 19
#define SYS_REBOOT 88
-int handle_syscall(struct isr_frame *frame);
-void dump_reg(struct isr_frame *frame);
-void dump_stack(uintptr_t esp, size_t len);
+int handle_syscall(struct regs *regs);
#endif
diff --git a/arch/i386/include/kernel/timer.h b/arch/i386/include/kernel/timer.h
index 0d90369..1bc2855 100644
--- a/arch/i386/include/kernel/timer.h
+++ b/arch/i386/include/kernel/timer.h
@@ -1,9 +1,9 @@
#ifndef I386_TIMER_H
#define I386_TIMER_H
-#include <kernel/isr.h>
+#include <kernel/asm.h>
-void timer_handler(struct isr_frame *frame);
+void timer_handler(struct regs *regs);
void timer_init(void);
#endif