Home | History | Annotate | Download | only in include
      1 #ifndef ETHERBOOT_SETJMP_H
      2 #define ETHERBOOT_SETJMP_H
      3 
      4 FILE_LICENCE ( GPL2_OR_LATER );
      5 
      6 #include <stdint.h>
      7 #include <realmode.h>
      8 
      9 /** A jump buffer */
     10 typedef struct {
     11 	uint32_t retaddr;
     12 	uint32_t ebx;
     13 	uint32_t esp;
     14 	uint32_t ebp;
     15 	uint32_t esi;
     16 	uint32_t edi;
     17 } jmp_buf[1];
     18 
     19 /** A real-mode-extended jump buffer */
     20 typedef struct {
     21 	jmp_buf env;
     22 	uint16_t rm_ss;
     23 	uint16_t rm_sp;
     24 } rmjmp_buf[1];
     25 
     26 extern int __asmcall setjmp ( jmp_buf env );
     27 extern void __asmcall longjmp ( jmp_buf env, int val );
     28 
     29 #define rmsetjmp( _env ) ( {			\
     30 	(_env)->rm_ss = rm_ss;			\
     31 	(_env)->rm_sp = rm_sp;			\
     32 	setjmp ( (_env)->env ); } )		\
     33 
     34 #define rmlongjmp( _env, _val ) do {		\
     35 	rm_ss = (_env)->rm_ss;			\
     36 	rm_sp = (_env)->rm_sp;			\
     37 	longjmp ( (_env)->env, (_val) );	\
     38 	} while ( 0 )
     39 
     40 #endif /* ETHERBOOT_SETJMP_H */
     41