nuclear@11: .data nuclear@11: .align 4 nuclear@11: .short 0 nuclear@11: /* memory reserved for set_idt */ nuclear@11: lim:.short 0 nuclear@11: addr:.long 0 nuclear@11: nuclear@11: .text nuclear@11: /* set_idt(uint32_t addr, uint16_t limit) nuclear@11: * loads the IDTR with the new address and limit for the IDT */ nuclear@11: .globl set_idt nuclear@11: set_idt: nuclear@11: movl 4(%esp), %eax nuclear@11: movl %eax, (addr) nuclear@11: movw 8(%esp), %ax nuclear@11: movw %ax, (lim) nuclear@11: lidt (lim) nuclear@11: ret nuclear@11: nuclear@25: /* get_intr_state() nuclear@25: * returns 1 if interrutps are enabled, 0 if disabled */ nuclear@25: .globl get_intr_state nuclear@25: get_intr_state: nuclear@25: pushf nuclear@25: popl %eax nuclear@25: shr $9, %eax /* bit 9 of eflags is IF */ nuclear@25: andl $1, %eax nuclear@25: ret nuclear@25: nuclear@25: /* set_intr_state(int state) nuclear@25: * enables interrupts if the argument is non-zero, disables them otherwise */ nuclear@25: .globl set_intr_state nuclear@25: set_intr_state: nuclear@25: cmpl $0, 4(%esp) nuclear@25: jz 0f nuclear@25: sti nuclear@25: ret nuclear@25: 0: cli nuclear@25: ret nuclear@25: nuclear@25: nuclear@11: /* interrupt entry with error code macro nuclear@11: * this macro generates an interrupt entry point for the nuclear@11: * exceptions which include error codes in the stack frame nuclear@11: */ nuclear@11: .macro ientry_err n name nuclear@11: .globl intr_entry_\name nuclear@11: intr_entry_\name: nuclear@11: pushl $\n nuclear@11: jmp intr_entry_common nuclear@11: .endm nuclear@11: nuclear@11: /* interrupt entry without error code macro nuclear@11: * this macro generates an interrupt entry point for the interrupts nuclear@11: * and exceptions which do not include error codes in the stack frame nuclear@11: * it pushes a dummy error code (0), to make the stack frame identical nuclear@11: */ nuclear@11: .macro ientry_noerr n name nuclear@11: .globl intr_entry_\name nuclear@11: intr_entry_\name: nuclear@11: pushl $0 nuclear@11: pushl $\n nuclear@11: jmp intr_entry_common nuclear@11: .endm nuclear@11: nuclear@11: /* common code used by all entry points. calls dispatch_intr() nuclear@11: * defined in intr.c nuclear@11: */ nuclear@11: .extern dispatch_intr nuclear@11: intr_entry_common: nuclear@11: pusha nuclear@11: call dispatch_intr nuclear@11: popa nuclear@11: /* remove error code and intr num from stack */ nuclear@11: add $8, %esp nuclear@11: iret nuclear@11: nuclear@11: /* by including interrupts.h with ASM defined, the macros above nuclear@11: * are expanded to generate all required interrupt entry points nuclear@11: */ nuclear@11: #define ASM nuclear@11: #include