kern
diff src/intr-asm.S @ 25:9939a6d7a45a
protected critical sections in VM and the physical memory manager by disabling interrupts
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 06 Apr 2011 07:42:44 +0300 |
parents | cccaa40f5432 |
children | f65b348780e3 |
line diff
1.1 --- a/src/intr-asm.S Tue Apr 05 02:09:02 2011 +0300 1.2 +++ b/src/intr-asm.S Wed Apr 06 07:42:44 2011 +0300 1.3 @@ -17,6 +17,28 @@ 1.4 lidt (lim) 1.5 ret 1.6 1.7 +/* get_intr_state() 1.8 + * returns 1 if interrutps are enabled, 0 if disabled */ 1.9 + .globl get_intr_state 1.10 +get_intr_state: 1.11 + pushf 1.12 + popl %eax 1.13 + shr $9, %eax /* bit 9 of eflags is IF */ 1.14 + andl $1, %eax 1.15 + ret 1.16 + 1.17 +/* set_intr_state(int state) 1.18 + * enables interrupts if the argument is non-zero, disables them otherwise */ 1.19 + .globl set_intr_state 1.20 +set_intr_state: 1.21 + cmpl $0, 4(%esp) 1.22 + jz 0f 1.23 + sti 1.24 + ret 1.25 +0: cli 1.26 + ret 1.27 + 1.28 + 1.29 /* interrupt entry with error code macro 1.30 * this macro generates an interrupt entry point for the 1.31 * exceptions which include error codes in the stack frame