2 ; Copyright
(C
) 2007 Tomas
'ZeXx86' Jedrzejek
(zexx86@gmail.com
)
3 ; Copyright
(C
) 2008 Tomas
'ZeXx86' Jedrzejek
(zexx86@gmail.com
)
5 ; This program is free software
: you can redistribute it
and/or modify
6 ; it under the terms of the GNU General Public License as published by
7 ; the Free Software Foundation
, either version
3 of the License
, or
8 ;
(at your option
) any later version.
10 ; This program is distributed in the hope that it will
be useful
,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY
or FITNESS FOR
A PARTICULAR PURPOSE. See the
13 ; GNU General Public License for more details.
15 ; You should have received
a copy of the GNU General Public License
16 ; along with this program. If
not, see
<http
://www.gnu.org
/licenses
/>.
46 ; This will set up our new segment registers. We need to do
47 ; something special in order to set CS. We do what is called
a
48 ; far jump.
A jump that includes
a segment as well as an offset.
49 ; This is declared in C as
'extern void gdt_flush();'
50 EXP gdt_flush ; Allows the C code to link to this
51 IMP gp ; Says that
'_gp' is in another file
53 lgdt
[gp
] ; Load the GDT with our
'_gp' which is
a special pointer
54 mov ax
, 0x10 ;
0x10 is the offset in the GDT to our data segment
59 jmp
0x08:flush2 ;
0x08 is the offset to our code segment
: Far jump
!
61 ret ; Returns back to the C code
!
63 ; Loads the IDT defined in
'_idtp' into the processor.
64 ; This is declared in C as
'extern void idt_load();'
70 ;
0: Divide By Zero Exception
84 ;
2: Non Maskable Interrupt Exception
105 ;
5: Out of Bounds Exception
112 ;
6: Invalid Opcode Exception
119 ;
7: Coprocessor
Not Available Exception
126 ;
8: Double Fault Exception
(With Error Code
!)
132 ;
9: Coprocessor Segment Overrun Exception
139 ;
10: Bad TSS Exception
(With Error Code
!)
145 ;
11: Segment
Not Present Exception
(With Error Code
!)
151 ;
12: Stack Fault Exception
(With Error Code
!)
157 ;
13: General Protection Fault Exception
(With Error Code
!)
163 ;
14: Page Fault Exception
(With Error Code
!)
169 ;
15: Reserved Exception
176 ;
16: Floating Point Exception
183 ;
17: Alignment Check Exception
190 ;
18: Machine Check Exception
289 ; We call
a C function in here. We need to let the assembler know
290 ; that
'_fault_handler' exists in another file
293 ; This is our common ISR stub. It saves the processor state
, sets
294 ; up for kernel mode segments
, calls the C-level fault handler
,
295 ;
and finally restores the stack frame.
310 mov eax
, fault_handler
486 ; syscall with
0 args
490 ; push ds ; switch to kernel space
496 ; call syscall_handler ; make call
498 ; pop es ; back to userland
524 call syscall_handler ; make call