aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-09-10 17:47:36 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-09-10 17:47:36 -0700
commit506a5baf17a1f005c84cde422d8a6007f94324ee (patch)
tree925fe48d7eeea7533b92eb6d34bf3c951068a65c
parentb486badd04d1d4fc0a44e2417349d4c22960f938 (diff)
downloadlwip-506a5baf17a1f005c84cde422d8a6007f94324ee.tar.gz
lwip-506a5baf17a1f005c84cde422d8a6007f94324ee.tar.xz
lwip-506a5baf17a1f005c84cde422d8a6007f94324ee.zip
core: add a way to invoke a function on return to protmode
Add a hook so we can invoke a protmode function immediately before enabling interrupts on the way back from protected mode. This will *not* be invoked if we are more than one level deep (i.e. [RM(0) ->] PM(0) -> RM(1) -> PM(1) -> RM(2) will not invoke the hook when returning to PM(1).) This is intended to provide a hook for taking an action after a real-mode interrupt did something, i.e. the PXE receive ISR or the timer tick. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--core/callback.inc13
-rw-r--r--core/pm.inc18
2 files changed, 30 insertions, 1 deletions
diff --git a/core/callback.inc b/core/callback.inc
index a33b5825..2c460f6e 100644
--- a/core/callback.inc
+++ b/core/callback.inc
@@ -49,6 +49,7 @@ core_intcall:
core_syscall:
pushfd ; Save IF among other things...
+ inc dword [CallbackCtr]
push ebx
push ebp
push esi
@@ -128,6 +129,10 @@ core_syscall:
; Remove from stack
pop dword [CallbackSP]
+ dec dword [CallbackCtr]
+ jnz .skip
+ call [core_pm_hook]
+.skip:
pop edi
pop esi
pop ebp
@@ -142,6 +147,7 @@ core_syscall:
global core_cfarcall
core_cfarcall:
pushfd ; Save IF among other things...
+ inc dword [CallbackCtr]
push ebx
push ebp
push esi
@@ -192,6 +198,10 @@ core_cfarcall:
mov eax,esi
; EDX already set up to be the RM return value
pop dword [CallbackSP]
+ dec dword [CallbackCtr]
+ jnz .skip
+ call [core_pm_hook]
+.skip:
pop ebx
pop ebp
pop esi
@@ -199,10 +209,11 @@ core_cfarcall:
popfd
ret
- bits 16
section .bss16
alignb 4
+ global core_pm_hook
CallbackSP resd 1 ; SP saved during callback
+CallbackCtr resd 1
bits 16
section .text16
diff --git a/core/pm.inc b/core/pm.inc
index 9584cda1..80685e59 100644
--- a/core/pm.inc
+++ b/core/pm.inc
@@ -194,6 +194,7 @@ PM_IDT_ptr: dw 8*256-1 ; Length
pm_irq:
pushad
movzx esi,byte [esp+8*4] ; Interrupt number
+ inc dword [CallbackCtr]
mov ebx,.rm
jmp enter_rm ; Go to real mode
@@ -208,10 +209,27 @@ pm_irq:
bits 32
section .textnr
.pm:
+ dec dword [CallbackCtr]
+ jnz .skip
+ call [core_pm_hook]
+.skip:
popad
add esp,4 ; Drop interrupt number
iretd
+;
+; Initially, the core_pm_hook does nothing; it is available for the
+; threaded derivatives to run the scheduler, or examine the result from
+; interrupt routines.
+;
+core_pm_null_hook:
+ ret
+
+ section .data16
+ alignz 4
+ global core_pm_hook
+core_pm_hook: dd core_pm_null_hook
+
bits 16
section .text16
;