created /kernel/isr subdir, moved isr.asm from boot to isr module, added interrupts.cc for isr() main function and isr_bootstrap() routine

git-svn-id: svn://anubis/hos/trunk@66 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh committed 2009-07-24 14:19:31 +00:00
1 parent d352afd079
commit d7be0159c9
5 files changed
+39 -1

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
include $(HOS_TOPLEVEL)/subdir.mak
+19
View File
@@ -0,0 +1,19 @@
#include "hos_types.h"
#include "interrupts.h"
extern "C" {
void isr(u8_t int_num, int_stack_t * int_stack)
{
switch (int_num)
{
}
}
} /* extern "C" */
void interrupts_bootstrap()
{
/* TODO: set up IDTR, IDT */
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef INTERRUPTS_H
#define INTERRUPTS_H
#ifdef __cplusplus
extern "C" {
#endif
void isr(u8_t int_num, int_stack_t * int_stack);
#ifdef __cplusplus
}
#endif
void interrupts_bootstrap();
#endif
+57
View File
@@ -0,0 +1,57 @@
; C ISR routine
[extern isr]
; Macro for creating a single ISR label
; We need to push a junk value on the stack first
; if the interrupt number is not 8 or 10-14.
; This is to properly align the stack for both exceptions
; having and not having error codes.
%macro isr_label 1
[global isr_%1]
isr_%1:
%if ( (%1 != 8) && (%1 < 10 || %1 > 14) )
push eax ; junk value to take error code stack space
%endif
pusha ; eax, ecx, edx, ebx, esp, ebp, esi, edi
mov al, %1 ; save interrupt number in al
%if ($ - isr_common) < 127 ; do a short jump and save 3 bytes if we can
jmp short isr_common
%else
jmp isr_common
%endif
%endmacro
; The common ISR routine
isr_common:
push ds
push es
push fs
push gs
push esp ; pointer to interrupt stack
push eax ; interrupt number
; TODO: uncomment when isr() is defined so the build won't break
; call isr
pop eax ; restore stack pointer (this is shorter
pop eax ; than "add esp, 8" and "lea esp, [esp+8]")
pop gs
pop fs
pop es
pop ds
popa ; edi, esi, ebp, <null>, ebx, edx, ecx, eax
lea esp, [esp+4] ; bypass error code
iret
; Loop to create all of our ISR entry points
%assign i 0
%rep 50
isr_label i
%assign i i+1
%endrep