kern

view src/intr-asm.S @ 47:f65b348780e3

continuing with the process implementation. not done yet, panics.
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 28 Jul 2011 05:43:04 +0300
parents 9939a6d7a45a
children 50730d42d2d3
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 /* get_intr_state()
21 * returns 1 if interrutps are enabled, 0 if disabled */
22 .globl get_intr_state
23 get_intr_state:
24 pushf
25 popl %eax
26 shr $9, %eax /* bit 9 of eflags is IF */
27 andl $1, %eax
28 ret
30 /* set_intr_state(int state)
31 * enables interrupts if the argument is non-zero, disables them otherwise */
32 .globl set_intr_state
33 set_intr_state:
34 cmpl $0, 4(%esp)
35 jz 0f
36 sti
37 ret
38 0: cli
39 ret
42 /* interrupt entry with error code macro
43 * this macro generates an interrupt entry point for the
44 * exceptions which include error codes in the stack frame
45 */
46 .macro ientry_err n name
47 .globl intr_entry_\name
48 intr_entry_\name:
49 pushl $\n
50 jmp intr_entry_common
51 .endm
53 /* interrupt entry without error code macro
54 * this macro generates an interrupt entry point for the interrupts
55 * and exceptions which do not include error codes in the stack frame
56 * it pushes a dummy error code (0), to make the stack frame identical
57 */
58 .macro ientry_noerr n name
59 .globl intr_entry_\name
60 intr_entry_\name:
61 pushl $0
62 pushl $\n
63 jmp intr_entry_common
64 .endm
66 /* common code used by all entry points. calls dispatch_intr()
67 * defined in intr.c
68 */
69 .extern dispatch_intr
70 intr_entry_common:
71 pusha
72 call dispatch_intr
74 .globl intr_ret
75 intr_ret:
76 popa
77 /* remove error code and intr num from stack */
78 add $8, %esp
79 iret
81 /* by including interrupts.h with ASM defined, the macros above
82 * are expanded to generate all required interrupt entry points
83 */
84 #define ASM
85 #include <interrupts.h>