diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-10 21:26:24 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-10 21:26:24 +0200 |
commit | d6d1bdfefafff50b7b6d15d218c0a188570be541 (patch) | |
tree | 15ee8de727d0be5d126efda146b2879de0a72773 /src/hardware/interrupts.asm | |
parent | eea5bf4b859eb56c5772c58ca54937a90a10e7ee (diff) | |
download | abaos-d6d1bdfefafff50b7b6d15d218c0a188570be541.tar.gz abaos-d6d1bdfefafff50b7b6d15d218c0a188570be541.tar.bz2 |
some big renames into subdirs of aspects
updated README
removed size_t in sys/types.h and sys/types.h itself, size_t is in stddef.h
Diffstat (limited to 'src/hardware/interrupts.asm')
-rw-r--r-- | src/hardware/interrupts.asm | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/hardware/interrupts.asm b/src/hardware/interrupts.asm new file mode 100644 index 0000000..155b2af --- /dev/null +++ b/src/hardware/interrupts.asm @@ -0,0 +1,90 @@ +[bits 32] + +global interrupts_enable +global interrupts_disable +global interrupts_load_idt +extern interrupts_handle_static_interrupt + +; void interrupts_enable( void ) +interrupts_enable: + push ebp + mov ebp, esp + sti + leave + ret + +; void interrupts_disable( void ) +interrupts_disable: + push ebp + mov ebp, esp + cli + leave + ret + +; void interrupts_load_idt( interrupt_descriptor_table_pointer_t *idt_pointer ) +interrupts_load_idt: + push ebp + mov ebp, esp + mov ecx, [ebp+8] + lidt [ecx] + leave + ret + +; the handler to ignore interrupts +global interrupts_ignore_request +interrupts_ignore_request: + iret + +; void interrupts_handle_request_0x00( ); +%macro exception_stub 1 +global interrupts_handle_exception_%1 +interrupts_handle_exception_%1: + mov [interrupt_no], byte %1 + jmp int_entry +%endmacro + +exception_stub 0x00 + +; IRQs and exceptions would normally collidate, that's why the +; hardware interrupts must be transposed by an offset +IRQ_BASE equ 0x20 + +%macro irq_stub 1 +global interrupts_handle_irq_%1 +interrupts_handle_irq_%1: + mov [interrupt_no], byte IRQ_BASE + %1 + jmp int_entry +%endmacro + +irq_stub 0x00 +irq_stub 0x01 +irq_stub 0x0C + +int_entry: + ; safe state of interrupted code + pusha + push ds + push es + push fs + push gs + + ; call the static C handler with the correct interrupt number + ; uint32_t interrupts_handle_interrupt( uint8_t interrupt_no, uint32_t esp ); + push esp + mov eax, [interrupt_no] + push eax + call interrupts_handle_static_interrupt + ;add esp, 8 + mov esp, eax + + ; restore state + pop gs + pop fs + pop es + pop ds + popa + + iret + +interrupt_no: + db 0 |