diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.asm | 20 | ||||
-rw-r--r-- | src/gdt/gdt.asm | 14 | ||||
-rw-r--r-- | src/interrupts/irq.asm | 157 | ||||
-rw-r--r-- | src/interrupts/isr.asm | 158 |
4 files changed, 176 insertions, 173 deletions
diff --git a/src/boot.asm b/src/boot.asm index 5e6c812..681bf10 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -20,7 +20,7 @@ mboot: dd MULTIBOOT_HEADER_MAGIC dd MULTIBOOT_HEADER_FLAGS dd MULTIBOOT_CHECKSUM - + ; AOUT kludge dd mboot dd code @@ -34,24 +34,14 @@ stublet: call kernel_main jmp $ -; GDT flush function -global gdt_flush -extern gp -gdt_flush: - lgdt [gp] - mov ax, 0x10 ; Data segment offset of GDT - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - jmp 0x08:flush2 ; Code segment offset -flush2: - ret ; Returns to C code +%include "src/gdt/gdt.asm" %include "src/interrupts/idt.asm" + %include "src/interrupts/isr.asm" +%include "src/interrupts/irq.asm" + ; Store the stack SECTION .bss resb 8192 ; Reserve 8KiB diff --git a/src/gdt/gdt.asm b/src/gdt/gdt.asm new file mode 100644 index 0000000..c2128e4 --- /dev/null +++ b/src/gdt/gdt.asm @@ -0,0 +1,14 @@ +; GDT flush function +global gdt_flush +extern gp +gdt_flush: + lgdt [gp] + mov ax, 0x10 ; Data segment offset of GDT + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + jmp 0x08:flush2 ; Code segment offset +flush2: + ret ; Returns to C code
\ No newline at end of file diff --git a/src/interrupts/irq.asm b/src/interrupts/irq.asm new file mode 100644 index 0000000..c485613 --- /dev/null +++ b/src/interrupts/irq.asm @@ -0,0 +1,157 @@ +global irq0 +global irq1 +global irq2 +global irq3 +global irq4 +global irq5 +global irq6 +global irq7 +global irq8 +global irq9 +global irq10 +global irq11 +global irq12 +global irq13 +global irq14 +global irq15 + +; 32: IRQ0 +irq0: + cli + push byte 0 + push byte 32 + jmp irq_common_stub + +; 33: IRQ1 +irq1: + cli + push byte 0 + push byte 33 + jmp irq_common_stub + +; 34: IRQ2 +irq2: + cli + push byte 0 + push byte 34 + jmp irq_common_stub + +; 35: IRQ3 +irq3: + cli + push byte 0 + push byte 35 + jmp irq_common_stub + +; 36: IRQ4 +irq4: + cli + push byte 0 + push byte 36 + jmp irq_common_stub + +; 37: IRQ5 +irq5: + cli + push byte 0 + push byte 37 + jmp irq_common_stub + +; 38: IRQ6 +irq6: + cli + push byte 0 + push byte 38 + jmp irq_common_stub + +; 39: IRQ7 +irq7: + cli + push byte 0 + push byte 39 + jmp irq_common_stub + +; 40: IRQ8 +irq8: + cli + push byte 0 + push byte 40 + jmp irq_common_stub + +; 41: IRQ9 +irq9: + cli + push byte 0 + push byte 41 + jmp irq_common_stub + +; 42: IRQ10 +irq10: + cli + push byte 0 + push byte 42 + jmp irq_common_stub + +; 43: IRQ11 +irq11: + cli + push byte 0 + push byte 43 + jmp irq_common_stub + +; 44: IRQ12 +irq12: + cli + push byte 0 + push byte 44 + jmp irq_common_stub + +; 45: IRQ13 +irq13: + cli + push byte 0 + push byte 45 + jmp irq_common_stub + +; 46: IRQ14 +irq14: + cli + push byte 0 + push byte 46 + jmp irq_common_stub + +; 47: IRQ15 +irq15: + cli + push byte 0 + push byte 47 + jmp irq_common_stub + +extern irq_handler + +irq_common_stub: + pusha + push ds + push es + push fs + push gs + + mov ax, 0x10 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov eax, esp + + push eax + mov eax, irq_handler + call eax + pop eax + + pop gs + pop fs + pop es + pop ds + popa + add esp, 8 + iret diff --git a/src/interrupts/isr.asm b/src/interrupts/isr.asm index 713fecf..d99a3dc 100644 --- a/src/interrupts/isr.asm +++ b/src/interrupts/isr.asm @@ -276,161 +276,3 @@ isr_common_stub: popa add esp, 8 iret - -global irq0 -global irq1 -global irq2 -global irq3 -global irq4 -global irq5 -global irq6 -global irq7 -global irq8 -global irq9 -global irq10 -global irq11 -global irq12 -global irq13 -global irq14 -global irq15 - -; 32: IRQ0 -irq0: - cli - push byte 0 - push byte 32 - jmp irq_common_stub - -; 33: IRQ1 -irq1: - cli - push byte 0 - push byte 33 - jmp irq_common_stub - -; 34: IRQ2 -irq2: - cli - push byte 0 - push byte 34 - jmp irq_common_stub - -; 35: IRQ3 -irq3: - cli - push byte 0 - push byte 35 - jmp irq_common_stub - -; 36: IRQ4 -irq4: - cli - push byte 0 - push byte 36 - jmp irq_common_stub - -; 37: IRQ5 -irq5: - cli - push byte 0 - push byte 37 - jmp irq_common_stub - -; 38: IRQ6 -irq6: - cli - push byte 0 - push byte 38 - jmp irq_common_stub - -; 39: IRQ7 -irq7: - cli - push byte 0 - push byte 39 - jmp irq_common_stub - -; 40: IRQ8 -irq8: - cli - push byte 0 - push byte 40 - jmp irq_common_stub - -; 41: IRQ9 -irq9: - cli - push byte 0 - push byte 41 - jmp irq_common_stub - -; 42: IRQ10 -irq10: - cli - push byte 0 - push byte 42 - jmp irq_common_stub - -; 43: IRQ11 -irq11: - cli - push byte 0 - push byte 43 - jmp irq_common_stub - -; 44: IRQ12 -irq12: - cli - push byte 0 - push byte 44 - jmp irq_common_stub - -; 45: IRQ13 -irq13: - cli - push byte 0 - push byte 45 - jmp irq_common_stub - -; 46: IRQ14 -irq14: - cli - push byte 0 - push byte 46 - jmp irq_common_stub - -; 47: IRQ15 -irq15: - cli - push byte 0 - push byte 47 - jmp irq_common_stub - -extern irq_handler - -irq_common_stub: - pusha - push ds - push es - push fs - push gs - - mov ax, 0x10 - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov eax, esp - - push eax - mov eax, irq_handler - call eax - pop eax - - pop gs - pop fs - pop es - pop ds - popa - add esp, 8 - iret |