Updated to REAL_CODE().

int13_boot() now does its own segment register save and restore, ready
for the removal of segment register restoration from the libkir
generic code.
This commit is contained in:
Michael Brown
2006-05-24 13:48:16 +00:00
parent e8550035af
commit 595f161b51

View File

@@ -503,25 +503,26 @@ void unregister_int13_drive ( struct int13_drive *drive ) {
*/ */
int int13_boot ( unsigned int drive ) { int int13_boot ( unsigned int drive ) {
int status, signature; int status, signature;
int d0, d1; int discard_c, discard_d;
DBG ( "Booting from INT 13 drive %02x\n", drive ); DBG ( "Booting from INT 13 drive %02x\n", drive );
/* Use INT 13 to read the boot sector */ /* Use INT 13 to read the boot sector */
REAL_EXEC ( rm_int13_boot, __asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
"pushw $0\n\t" "pushw $0\n\t"
"popw %%es\n\t" "popw %%es\n\t"
"int $0x13\n\t" "stc\n\t"
"jc 1f\n\t" "int $0x13\n\t"
"xorl %%eax, %%eax\n\t" "sti\n\t" /* BIOS bugs */
"\n1:\n\t" "jc 1f\n\t"
"movzwl %%es:0x7dfe, %%ebx\n\t", "xorl %%eax, %%eax\n\t"
4, "\n1:\n\t"
OUT_CONSTRAINTS ( "=a" ( status ), "=b" ( signature ), "movzwl %%es:0x7dfe, %%ebx\n\t"
"=c" ( d0 ), "=d" ( drive ) ), "popw %%es\n\t" )
IN_CONSTRAINTS ( "0" ( 0x0201 ), "1" ( 0x7c00 ), : "=a" ( status ), "=b" ( signature ),
"2" ( 0x0001 ), "3" ( drive ) ), "=c" ( discard_c ), "=d" ( discard_d )
CLOBBER ( "ebp" ) ); : "a" ( 0x0201 ), "b" ( 0x7c00 ),
"c" ( 1 ), "d" ( drive ) );
if ( status ) if ( status )
return -EIO; return -EIO;
@@ -539,22 +540,28 @@ int int13_boot ( unsigned int drive ) {
&int19_vector ); &int19_vector );
/* Boot the loaded sector */ /* Boot the loaded sector */
REAL_EXEC ( rm_int13_exec, __asm__ __volatile__ ( REAL_CODE ( /* Save segment registers */
"movw %%ss, %%ax\n\t" /* Preserve stack pointer */ "pushw %%ds\n\t"
"movw %%ax, %%cs:int13_exec_saved_ss\n\t" "pushw %%es\n\t"
"movw %%sp, %%cs:int13_exec_saved_sp\n\t" "pushw %%fs\n\t"
"ljmp $0, $0x7c00\n\t" "pushw %%gs\n\t"
"\nint13_exec_saved_ss: .word 0\n\t" /* Save stack pointer */
"\nint13_exec_saved_sp: .word 0\n\t" "movw %%ss, %%ax\n\t"
"\nint13_exec_fail:\n\t" "movw %%ax, %%cs:int13_saved_ss\n\t"
"movw %%cs:int13_exec_saved_ss, %%ax\n\t" "movw %%sp, %%cs:int13_saved_sp\n\t"
"movw %%ax, %%ss\n\t" "ljmp $0, $0x7c00\n\t"
"movw %%cs:int13_exec_saved_sp, %%sp\n\t" "\nint13_saved_ss: .word 0\n\t"
"\n99:\n\t", "\nint13_saved_sp: .word 0\n\t"
1, "\nint13_exec_fail:\n\t"
OUT_CONSTRAINTS ( "=d" ( d1 ) ), "movw %%cs:int13_saved_ss, %%ax\n\t"
IN_CONSTRAINTS ( "0" ( drive ) ), "movw %%ax, %%ss\n\t"
CLOBBER ( "eax", "ebx", "ecx", "esi", "edi", "ebp" ) ); "movw %%cs:int13_saved_sp, %%sp\n\t"
"popw %%gs\n\t"
"popw %%fs\n\t"
"popw %%es\n\t"
"popw %%ds\n\t" )
: "=d" ( discard_d ) : "d" ( drive )
: "eax", "ebx", "ecx", "esi", "edi", "ebp" );
DBG ( "Booted disk returned via INT 18 or 19\n" ); DBG ( "Booted disk returned via INT 18 or 19\n" );