diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-04 15:43:28 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-03-04 15:43:28 +0200 |
commit | 5f0006cfa7c499a501969641ac7bd630cb4706de (patch) | |
tree | 68e792da03c4ec36241dee787bc0dd7835dfd907 /src/cpu | |
parent | Add some comments to keyboard driver (diff) | |
download | kernel.cpp-5f0006cfa7c499a501969641ac7bd630cb4706de.tar.xz |
pass cpu_state_t to interrupt handler
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/exceptions.s | 51 | ||||
-rw-r--r-- | src/cpu/interrupts.s | 50 | ||||
-rw-r--r-- | src/cpu/registers.h | 26 |
3 files changed, 26 insertions, 101 deletions
diff --git a/src/cpu/exceptions.s b/src/cpu/exceptions.s deleted file mode 100644 index 9736be1..0000000 --- a/src/cpu/exceptions.s +++ /dev/null @@ -1,51 +0,0 @@ -.section .text -.extern print_exception - -.macro exception num -.global exception\num -exception\num: - movb $\num, (exc) - jmp exception_common -.endm - -exception 0x00 -exception 0x01 -exception 0x02 -exception 0x03 -exception 0x04 -exception 0x05 -exception 0x06 -exception 0x07 -exception 0x08 -exception 0x09 -exception 0x0a -exception 0x0b -exception 0x0c -exception 0x0d -exception 0x0e -exception 0x0f -exception 0x10 -exception 0x11 -exception 0x12 -exception 0x13 - -exception_common: - pusha - pushl %ds - pushl %es - pushl %fs - pushl %gs - - push (exc) - call print_exception - - popl %gs - popl %fs - popl %es - popl %ds - popa - iret - -.data - exc: .byte 0 - diff --git a/src/cpu/interrupts.s b/src/cpu/interrupts.s deleted file mode 100644 index 17c39e9..0000000 --- a/src/cpu/interrupts.s +++ /dev/null @@ -1,50 +0,0 @@ -.section .text -.extern handle_interrupt - -.macro interrupt num -.global interrupt\num -interrupt\num: - movb $\num, (irq) - jmp interrupt_common -.endm - -interrupt 0x00 # system timer -interrupt 0x01 # keyboard controller -interrupt 0x02 # slave pic -interrupt 0x03 # serial port 2 and 4 -interrupt 0x04 # serial port 1 and 3 -interrupt 0x05 # parallel port 2 and 3, sound card -interrupt 0x06 # floppy controller -interrupt 0x07 # parallel port 1 - -interrupt 0x08 # real-time clock -interrupt 0x09 # acpi -interrupt 0x0a # -interrupt 0x0b # -interrupt 0x0c # mouse on ps/2 -interrupt 0x0d # fpu -interrupt 0x0e # primary ATA -interrupt 0x0f # secondary ATA - -interrupt_common: - pusha - pushl %ds - pushl %es - pushl %fs - pushl %gs - - pushl %esp - push (irq) - call handle_interrupt - mov %eax, %esp - - popl %gs - popl %fs - popl %es - popl %ds - popa - iret - -.data - irq: .byte 0 - diff --git a/src/cpu/registers.h b/src/cpu/registers.h new file mode 100644 index 0000000..edb6b7b --- /dev/null +++ b/src/cpu/registers.h @@ -0,0 +1,26 @@ +#pragma once + +#include <types.h> + +namespace x86 { + +struct cpu_state { + /* pusha */ + uint32_t edi, esi; // destination index, source index + uint32_t ebp, esp; // base pointer, stack pointer + uint32_t ebx, edx, ecx, eax; // general registers + + uint32_t irq; + uint32_t error; + + /* stack frame, pushed by cpu */ + uint32_t eip; + uint32_t cs; + uint32_t eflags; + uint32_t __esp; + uint32_t ss; +} __attribute__((packed)); + +} // namespace x86 + +typedef x86::cpu_state cpu_state_t; |