[syslinux:lwip] core: add a way to invoke a function on return to protmode

syslinux-bot for H. Peter Anvin hpa at zytor.com
Fri Apr 22 20:05:22 PDT 2011


Commit-ID:  e1bee14346ed7bca7773681cb016abe9f9d46134
Gitweb:     http://syslinux.zytor.com/commit/e1bee14346ed7bca7773681cb016abe9f9d46134
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Thu, 10 Sep 2009 17:47:36 -0700
Committer:  Eric W. Biederman <ebiederm at xmission.com>
CommitDate: Sat, 9 Apr 2011 18:27:07 -0700

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 at zytor.com>


---
 core/callback.inc |   13 ++++++++++++-
 core/pm.inc       |   18 ++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/core/callback.inc b/core/callback.inc
index d98d800..d40a452 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
@@ -130,6 +131,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
@@ -145,6 +150,7 @@ core_syscall:
 		global core_cfarcall
 core_cfarcall:
 		pushfd				; Save IF among other things...
+		inc dword [CallbackCtr]
 		push ebx
 		push ebp
 		push esi
@@ -199,6 +205,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
@@ -206,10 +216,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 9584cda..80685e5 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
 ;



More information about the Syslinux-commits mailing list