aboutsummaryrefslogtreecommitdiff
path: root/kernel/inc/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/inc/drivers')
-rw-r--r--kernel/inc/drivers/cpu.h9
-rw-r--r--kernel/inc/drivers/int.h52
-rw-r--r--kernel/inc/drivers/interrupts.h95
-rw-r--r--kernel/inc/drivers/pic.h11
-rw-r--r--kernel/inc/drivers/timer.h5
5 files changed, 68 insertions, 104 deletions
diff --git a/kernel/inc/drivers/cpu.h b/kernel/inc/drivers/cpu.h
index 75e0495..36b8928 100644
--- a/kernel/inc/drivers/cpu.h
+++ b/kernel/inc/drivers/cpu.h
@@ -4,6 +4,7 @@
#define CPU_H
#include <def.h>
+#include <proc.h>
UNUSED_FUNC static inline void spinlock(u32 *ptr)
{
@@ -21,9 +22,12 @@ void outb(u16 port, u8 data);
void outw(u16 port, u16 data);
void outl(u16 port, u32 data);
+void fpu_init(struct proc *proc);
+void fpu_save(struct proc *proc);
+void fpu_restore(struct proc *proc);
+
void cpu_print(void);
void cpu_enable_features(void);
-void fpu_restore(void);
u32 cr0_get(void);
void cr0_set(u32 cr0);
@@ -35,9 +39,6 @@ void cr4_set(u32 cr4);
void clac(void);
void stac(void);
-void cli(void);
-void sti(void);
-
struct cpuid {
u32 eax;
u32 ebx;
diff --git a/kernel/inc/drivers/int.h b/kernel/inc/drivers/int.h
new file mode 100644
index 0000000..8146898
--- /dev/null
+++ b/kernel/inc/drivers/int.h
@@ -0,0 +1,52 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef IDT_H
+#define IDT_H
+
+#include <def.h>
+
+#define INT_GATE 0x8e
+#define INT_TRAP 0xef
+#define INT_USER 0x60
+#define IDT_ENTRY(offset, selector, type) \
+ (struct idt_entry) \
+ { \
+ .base_low = (u16)((offset)&0xffff), .sel = (selector), .zero = 0, .flags = (type), \
+ .base_high = (u16)(((offset) >> 16) & 0xffff), \
+ }
+
+struct int_frame {
+ u32 gs, fs, es, ds;
+ u32 edi, esi, ebp, esp, ebx, edx, ecx, eax;
+ u32 int_no, err_code;
+ u32 eip, cs, eflags;
+} PACKED;
+
+struct int_frame_user {
+ u32 gs, fs, es, ds;
+ u32 edi, esi, ebp, esp, ebx, edx, ecx, eax;
+ u32 int_no, err_code;
+ u32 eip, cs, eflags;
+ u32 useresp, ss;
+} PACKED;
+
+struct idt_entry {
+ u16 base_low;
+ u16 sel; // Kernel segment
+ u8 zero; // Always 0
+ u8 flags;
+ u16 base_high;
+} PACKED;
+
+struct idt_ptr {
+ u16 size;
+ void *base;
+} PACKED;
+
+void idt_install(void);
+
+void int_trap_handler_add(u32 int_no, void (*handler)(u32 esp));
+void int_event_handler_add(u32 int_no, void (*handler)(void));
+void int_special_handler_add(u32 int_no, u32 (*handler)(u32 esp));
+
+#endif
diff --git a/kernel/inc/drivers/interrupts.h b/kernel/inc/drivers/interrupts.h
deleted file mode 100644
index 7c0c1e7..0000000
--- a/kernel/inc/drivers/interrupts.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#ifndef IDT_H
-#define IDT_H
-
-#include <def.h>
-
-struct regs {
- u32 gs, fs, es, ds;
- u32 edi, esi, ebp, esp, ebx, edx, ecx, eax;
- u32 int_no, err_code;
- u32 eip, cs, eflags, useresp, ss;
-};
-
-struct idt_entry {
- u16 base_low;
- u16 sel; // Kernel segment
- u8 always0; // Always 0
- u8 flags;
- u16 base_high;
-} PACKED;
-
-struct idt_ptr {
- u16 limit;
- void *base;
-} PACKED;
-
-void idt_set_gate(u8 num, u32 base, u16 sel, u8 flags);
-
-void irq_install_handler(int irq, void (*handler)(struct regs *r)) NONNULL;
-void irq_uninstall_handler(int irq);
-
-void isr_install_handler(int isr, void (*handler)(struct regs *r)) NONNULL;
-void isr_uninstall_handler(int isr);
-void isr_panic(struct regs *r) NONNULL;
-
-void interrupts_install(void);
-
-// External handlers (ASM)
-
-extern void isr0(struct regs *r);
-extern void isr1(struct regs *r);
-extern void isr2(struct regs *r);
-extern void isr3(struct regs *r);
-extern void isr4(struct regs *r);
-extern void isr5(struct regs *r);
-extern void isr6(struct regs *r);
-extern void isr7(struct regs *r);
-extern void isr8(struct regs *r);
-extern void isr9(struct regs *r);
-extern void isr10(struct regs *r);
-extern void isr11(struct regs *r);
-extern void isr12(struct regs *r);
-extern void isr13(struct regs *r);
-extern void isr14(struct regs *r);
-extern void isr15(struct regs *r);
-extern void isr16(struct regs *r);
-extern void isr17(struct regs *r);
-extern void isr18(struct regs *r);
-extern void isr19(struct regs *r);
-extern void isr20(struct regs *r);
-extern void isr21(struct regs *r);
-extern void isr22(struct regs *r);
-extern void isr23(struct regs *r);
-extern void isr24(struct regs *r);
-extern void isr25(struct regs *r);
-extern void isr26(struct regs *r);
-extern void isr27(struct regs *r);
-extern void isr28(struct regs *r);
-extern void isr29(struct regs *r);
-extern void isr30(struct regs *r);
-extern void isr31(struct regs *r);
-extern void isr127(struct regs *r);
-extern void isr128(struct regs *r);
-
-extern void irq0(struct regs *r);
-extern void irq1(struct regs *r);
-extern void irq2(struct regs *r);
-extern void irq3(struct regs *r);
-extern void irq4(struct regs *r);
-extern void irq5(struct regs *r);
-extern void irq6(struct regs *r);
-extern void irq7(struct regs *r);
-extern void irq8(struct regs *r);
-extern void irq9(struct regs *r);
-extern void irq10(struct regs *r);
-extern void irq11(struct regs *r);
-extern void irq12(struct regs *r);
-extern void irq13(struct regs *r);
-extern void irq14(struct regs *r);
-extern void irq15(struct regs *r);
-extern void irq127(struct regs *r);
-extern void irq128(struct regs *r);
-
-#endif
diff --git a/kernel/inc/drivers/pic.h b/kernel/inc/drivers/pic.h
new file mode 100644
index 0000000..c2a7d87
--- /dev/null
+++ b/kernel/inc/drivers/pic.h
@@ -0,0 +1,11 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef PIC_H
+#define PIC_H
+
+#include <def.h>
+
+void pic_install(void);
+void pic_ack(u32 int_no);
+
+#endif
diff --git a/kernel/inc/drivers/timer.h b/kernel/inc/drivers/timer.h
index 9ff23f8..ea1643b 100644
--- a/kernel/inc/drivers/timer.h
+++ b/kernel/inc/drivers/timer.h
@@ -4,14 +4,9 @@
#define TIMER_H
#include <def.h>
-#include <drivers/interrupts.h>
u32 timer_get(void);
void timer_wait(u32 ticks);
void timer_install(void);
-void timer_handler(struct regs *r) NONNULL;
-
-void scheduler_enable(void);
-void scheduler_disable(void);
#endif