kern

view src/intr-asm.S @ 22:7ece008f09c5

writing the vm
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 03 Apr 2011 18:42:19 +0300
parents
children 9939a6d7a45a
line source
1 .data
2 .align 4
3 .short 0
4 /* memory reserved for set_idt */
5 lim:.short 0
6 addr:.long 0
8 .text
9 /* set_idt(uint32_t addr, uint16_t limit)
10 * loads the IDTR with the new address and limit for the IDT */
11 .globl set_idt
12 set_idt:
13 movl 4(%esp), %eax
14 movl %eax, (addr)
15 movw 8(%esp), %ax
16 movw %ax, (lim)
17 lidt (lim)
18 ret
20 /* interrupt entry with error code macro
21 * this macro generates an interrupt entry point for the
22 * exceptions which include error codes in the stack frame
23 */
24 .macro ientry_err n name
25 .globl intr_entry_\name
26 intr_entry_\name:
27 pushl $\n
28 jmp intr_entry_common
29 .endm
31 /* interrupt entry without error code macro
32 * this macro generates an interrupt entry point for the interrupts
33 * and exceptions which do not include error codes in the stack frame
34 * it pushes a dummy error code (0), to make the stack frame identical
35 */
36 .macro ientry_noerr n name
37 .globl intr_entry_\name
38 intr_entry_\name:
39 pushl $0
40 pushl $\n
41 jmp intr_entry_common
42 .endm
44 /* common code used by all entry points. calls dispatch_intr()
45 * defined in intr.c
46 */
47 .extern dispatch_intr
48 intr_entry_common:
49 pusha
50 call dispatch_intr
51 popa
52 /* remove error code and intr num from stack */
53 add $8, %esp
54 iret
56 /* by including interrupts.h with ASM defined, the macros above
57 * are expanded to generate all required interrupt entry points
58 */
59 #define ASM
60 #include <interrupts.h>