kern
annotate src/intr-asm.S @ 28:bdd9bf70269d
implemented malloc
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 27 May 2011 12:05:38 +0300 |
parents | cccaa40f5432 |
children | f65b348780e3 |
rev | line source |
---|---|
nuclear@11 | 1 .data |
nuclear@11 | 2 .align 4 |
nuclear@11 | 3 .short 0 |
nuclear@11 | 4 /* memory reserved for set_idt */ |
nuclear@11 | 5 lim:.short 0 |
nuclear@11 | 6 addr:.long 0 |
nuclear@11 | 7 |
nuclear@11 | 8 .text |
nuclear@11 | 9 /* set_idt(uint32_t addr, uint16_t limit) |
nuclear@11 | 10 * loads the IDTR with the new address and limit for the IDT */ |
nuclear@11 | 11 .globl set_idt |
nuclear@11 | 12 set_idt: |
nuclear@11 | 13 movl 4(%esp), %eax |
nuclear@11 | 14 movl %eax, (addr) |
nuclear@11 | 15 movw 8(%esp), %ax |
nuclear@11 | 16 movw %ax, (lim) |
nuclear@11 | 17 lidt (lim) |
nuclear@11 | 18 ret |
nuclear@11 | 19 |
nuclear@25 | 20 /* get_intr_state() |
nuclear@25 | 21 * returns 1 if interrutps are enabled, 0 if disabled */ |
nuclear@25 | 22 .globl get_intr_state |
nuclear@25 | 23 get_intr_state: |
nuclear@25 | 24 pushf |
nuclear@25 | 25 popl %eax |
nuclear@25 | 26 shr $9, %eax /* bit 9 of eflags is IF */ |
nuclear@25 | 27 andl $1, %eax |
nuclear@25 | 28 ret |
nuclear@25 | 29 |
nuclear@25 | 30 /* set_intr_state(int state) |
nuclear@25 | 31 * enables interrupts if the argument is non-zero, disables them otherwise */ |
nuclear@25 | 32 .globl set_intr_state |
nuclear@25 | 33 set_intr_state: |
nuclear@25 | 34 cmpl $0, 4(%esp) |
nuclear@25 | 35 jz 0f |
nuclear@25 | 36 sti |
nuclear@25 | 37 ret |
nuclear@25 | 38 0: cli |
nuclear@25 | 39 ret |
nuclear@25 | 40 |
nuclear@25 | 41 |
nuclear@11 | 42 /* interrupt entry with error code macro |
nuclear@11 | 43 * this macro generates an interrupt entry point for the |
nuclear@11 | 44 * exceptions which include error codes in the stack frame |
nuclear@11 | 45 */ |
nuclear@11 | 46 .macro ientry_err n name |
nuclear@11 | 47 .globl intr_entry_\name |
nuclear@11 | 48 intr_entry_\name: |
nuclear@11 | 49 pushl $\n |
nuclear@11 | 50 jmp intr_entry_common |
nuclear@11 | 51 .endm |
nuclear@11 | 52 |
nuclear@11 | 53 /* interrupt entry without error code macro |
nuclear@11 | 54 * this macro generates an interrupt entry point for the interrupts |
nuclear@11 | 55 * and exceptions which do not include error codes in the stack frame |
nuclear@11 | 56 * it pushes a dummy error code (0), to make the stack frame identical |
nuclear@11 | 57 */ |
nuclear@11 | 58 .macro ientry_noerr n name |
nuclear@11 | 59 .globl intr_entry_\name |
nuclear@11 | 60 intr_entry_\name: |
nuclear@11 | 61 pushl $0 |
nuclear@11 | 62 pushl $\n |
nuclear@11 | 63 jmp intr_entry_common |
nuclear@11 | 64 .endm |
nuclear@11 | 65 |
nuclear@11 | 66 /* common code used by all entry points. calls dispatch_intr() |
nuclear@11 | 67 * defined in intr.c |
nuclear@11 | 68 */ |
nuclear@11 | 69 .extern dispatch_intr |
nuclear@11 | 70 intr_entry_common: |
nuclear@11 | 71 pusha |
nuclear@11 | 72 call dispatch_intr |
nuclear@11 | 73 popa |
nuclear@11 | 74 /* remove error code and intr num from stack */ |
nuclear@11 | 75 add $8, %esp |
nuclear@11 | 76 iret |
nuclear@11 | 77 |
nuclear@11 | 78 /* by including interrupts.h with ASM defined, the macros above |
nuclear@11 | 79 * are expanded to generate all required interrupt entry points |
nuclear@11 | 80 */ |
nuclear@11 | 81 #define ASM |
nuclear@11 | 82 #include <interrupts.h> |