Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| int | call_bootsector (unsigned int segment, unsigned int offset, unsigned int drive) |
| Jump to preloaded bootsector. | |
Definition in file bootsector.h.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| int call_bootsector | ( | unsigned int | segment, | |
| unsigned int | offset, | |||
| unsigned int | drive | |||
| ) |
Jump to preloaded bootsector.
| segment | Real-mode segment | |
| offset | Real-mode offset | |
| drive | Drive number to pass to boot sector |
| rc | Return status code |
Definition at line 58 of file bootsector.c.
References __asm__(), bootsector_exec_fail(), DBG, ECANCELED, hook_bios_interrupt(), int18_vector, int19_vector, REAL_CODE, and unhook_bios_interrupt().
Referenced by eltorito_exec(), and int13_boot().
00059 { 00060 int discard_b, discard_D, discard_d; 00061 00062 DBG ( "Booting from boot sector at %04x:%04x\n", segment, offset ); 00063 00064 /* Hook INTs 18 and 19 to capture failure paths */ 00065 hook_bios_interrupt ( 0x18, ( unsigned int ) bootsector_exec_fail, 00066 &int18_vector ); 00067 hook_bios_interrupt ( 0x19, ( unsigned int ) bootsector_exec_fail, 00068 &int19_vector ); 00069 00070 /* Boot the loaded sector 00071 * 00072 * We assume that the boot sector may completely destroy our 00073 * real-mode stack, so we preserve everything we need in 00074 * static storage. 00075 */ 00076 __asm__ __volatile__ ( REAL_CODE ( /* Save return address off-stack */ 00077 "popw %%cs:saved_retaddr\n\t" 00078 /* Save stack pointer */ 00079 "movw %%ss, %%ax\n\t" 00080 "movw %%ax, %%cs:saved_ss\n\t" 00081 "movw %%sp, %%cs:saved_sp\n\t" 00082 /* Jump to boot sector */ 00083 "pushw %%bx\n\t" 00084 "pushw %%di\n\t" 00085 "sti\n\t" 00086 "lret\n\t" 00087 /* Preserved variables */ 00088 "\nsaved_ss: .word 0\n\t" 00089 "\nsaved_sp: .word 0\n\t" 00090 "\nsaved_retaddr: .word 0\n\t" 00091 /* Boot failure return point */ 00092 "\nbootsector_exec_fail:\n\t" 00093 /* Restore stack pointer */ 00094 "movw %%cs:saved_ss, %%ax\n\t" 00095 "movw %%ax, %%ss\n\t" 00096 "movw %%cs:saved_sp, %%sp\n\t" 00097 /* Return via saved address */ 00098 "jmp *%%cs:saved_retaddr\n\t" ) 00099 : "=b" ( discard_b ), "=D" ( discard_D ), 00100 "=d" ( discard_d ) 00101 : "b" ( segment ), "D" ( offset ), 00102 "d" ( drive ) 00103 : "eax", "ecx", "esi", "ebp" ); 00104 00105 DBG ( "Booted disk returned via INT 18 or 19\n" ); 00106 00107 /* Unhook INTs 18 and 19 */ 00108 unhook_bios_interrupt ( 0x18, ( unsigned int ) bootsector_exec_fail, 00109 &int18_vector ); 00110 unhook_bios_interrupt ( 0x19, ( unsigned int ) bootsector_exec_fail, 00111 &int19_vector ); 00112 00113 return -ECANCELED; 00114 }
1.5.7.1