initial commit
[pfinal.git] / Routix / src / int.asm
blob560854de152854c2711db0b9bb72d2d82d04184e
1 ; int.asm
3 segment .text
4 use32
6 [global _intDefaultHandler]
7 [global _intTeclado]
8 [global _intFloppy]
9 [global _intSysCall]
11 ;[global _int_timertick_handler]
12 [extern _DefaultHandler]
13 [extern _Teclado]
14 ;[extern _timertick_handler]
15 [extern _ExcepcionHandler]
16 [extern _Floppy]
17 [extern _syscall]
19 %macro excepcion 1
20 [global _excepcion%1]
21 _excepcion%1:
22 push dword %1
23 call _ExcepcionHandler
24 add esp, 4
25 iret
26 %endmacro
28 %macro SAVE_ALL 0
29 push eax
30 push ebx
31 push ecx
32 push edx
33 push ebp
34 push esi
35 push edi
36 %endmacro
38 %macro RESTORE_ALL 0
39 pop edi
40 pop esi
41 pop ebp
42 pop edx
43 pop ecx
44 pop ebx
45 pop eax
46 %endmacro
49 %assign i 0
50 %rep 20
51 excepcion i
52 %assign i i+1
53 %endrep
57 _intDefaultHandler:
58 SAVE_ALL
59 call _DefaultHandler
60 RESTORE_ALL
61 iret
64 ;_int_timertick_handler:
65 ; SAVE_ALL
66 ; call _timertick_handler
67 ; RESTORE_ALL
68 ; iret
70 _intTeclado:
71 SAVE_ALL
72 call _Teclado
73 RESTORE_ALL
74 iret
76 %define KERNEL_STACK_TOP 0xd8000000
78 %macro SWITCH_TO_KERNEL_STACK 0
79 ; Tenemos que utilizar en stack del kernel
80 mov eax, esp
82 mov ebx, KERNEL_STACK_TOP
83 mov esp, ebx
85 ; Guardamos el stack pointer de la tarea
86 push eax
87 %endmacro
89 %macro SWITCH_TO_TASK_STACK 0
90 ; Recuperamos el stack pointer de la tarea
91 pop eax
93 ; y lo ponemos en funcionamiento
94 mov esp, eax
95 %endmacro
98 _intFloppy:
99 SAVE_ALL
101 ; Aca deberiamos switchear el cr3 de la tarea por el del kernel
102 ;mov eax, cr3
103 ;push eax
106 ; Comente esta macro porque genera problemas cuando no hay tareas activas y
107 ; el codigo que esta ejecutandose es el kernel
108 ;SWITCH_TO_KERNEL_STACK
110 call _Floppy
112 ;SWITCH_TO_TASK_STACK
114 ; y aca recuperar el cr3
115 ;pop eax
116 ;mov cr3, eax
118 RESTORE_ALL
119 iret