Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[comboot] Restore the real-mode stack pointer on exit from a COMBOOT …
…image COMBOOT images use INTs to issue API calls; these end up making calls into gPXE from real mode, and so temporarily change the real-mode stack pointer. When our COMBOOT code uses a longjmp() to implement the various "exit COMBOOT image" API calls, this leaves the real-mode stack pointer stuck with its temporary value, which causes problems if we eventually try to exit out of gPXE back to the BIOS. Fix by adding rmsetjmp() and rmlongjmp() calls (analogous to sigsetjmp()/siglongjmp()); these save and restore the additional state needed for real-mode calls to function correctly.
- Loading branch information
Michael Brown
committed
Feb 17, 2009
1 parent
7f903f0
commit 5026a35
Showing
5 changed files
with
40 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
#ifndef ETHERBOOT_SETJMP_H | ||
#define ETHERBOOT_SETJMP_H | ||
|
||
#include <stdint.h> | ||
#include <realmode.h> | ||
|
||
/* Define a type for use by setjmp and longjmp */ | ||
#define JBLEN 6 | ||
typedef unsigned long jmp_buf[JBLEN]; | ||
/** A jump buffer */ | ||
typedef struct { | ||
uint32_t retaddr; | ||
uint32_t ebx; | ||
uint32_t esp; | ||
uint32_t ebp; | ||
uint32_t esi; | ||
uint32_t edi; | ||
} jmp_buf[1]; | ||
|
||
extern int __asmcall setjmp (jmp_buf env); | ||
extern void __asmcall longjmp (jmp_buf env, int val); | ||
/** A real-mode-extended jump buffer */ | ||
typedef struct { | ||
jmp_buf env; | ||
uint16_t rm_ss; | ||
uint16_t rm_sp; | ||
} rmjmp_buf[1]; | ||
|
||
extern int __asmcall setjmp ( jmp_buf env ); | ||
extern void __asmcall longjmp ( jmp_buf env, int val ); | ||
|
||
#define rmsetjmp( _env ) ( { \ | ||
(_env)->rm_ss = rm_ss; \ | ||
(_env)->rm_sp = rm_sp; \ | ||
setjmp ( (_env)->env ); } ) \ | ||
|
||
#define rmlongjmp( _env, _val ) do { \ | ||
rm_ss = (_env)->rm_ss; \ | ||
rm_sp = (_env)->rm_sp; \ | ||
longjmp ( (_env)->env, (_val) ); \ | ||
} while ( 0 ) | ||
|
||
#endif /* ETHERBOOT_SETJMP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters