diff --git a/doc/fdisk/CHANGES.md b/doc/fdisk/CHANGES.md index 76adcaf..b4953bd 100644 --- a/doc/fdisk/CHANGES.md +++ b/doc/fdisk/CHANGES.md @@ -8,6 +8,14 @@ Bug classification: - LOW: Cosmetic bugs, like display issues etc. +Version 1.3.14 (2024-02-04) +--------------------------- +Fixes: + - HIGH: Prevent querying LBA capabilities via INT13,41 if LBA is disabled + by the user via command line argument /X. This caused some broken + BIOS to crash the system, like BIOS version 0.9.4 of Book8088 and Xi8088. + + Version 1.3.13 (2024-01-16) --------------------------- Changes: diff --git a/source/fdisk/cmd.c b/source/fdisk/cmd.c index 0dc3c1b..945a174 100644 --- a/source/fdisk/cmd.c +++ b/source/fdisk/cmd.c @@ -514,35 +514,6 @@ void Command_Line_Test_Flag( void ) } } -/* /X command line option */ -void Command_Line_X( void ) -{ - int index; - - /* Ask the user if FAT32 is desired. */ - /*if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) { - Ask_User_About_FAT32_Support(); - }*/ - - flags.use_extended_int_13 = FALSE; - index = 0; - do { - part_table[index].ext_int_13 = FALSE; - index++; - } while ( index < MAX_DISKS ); - - if ( Read_Partition_Tables() != 0 ) { - /* NLS:Error reading partition tables. */ - con_print( svarlang_str( 255, 0 ) ); - exit( 1 ); - } - /*if ( flags.maximum_drive_number == 0 ) { - Color_Print( "\n No fixed disks present.\n" ); - exit( 6 ); - } - - Interactive_User_Interface();*/ -} /* Get the command line options */ int Get_Options( char *argv[], int argc ) diff --git a/source/fdisk/cmd.h b/source/fdisk/cmd.h index 1adcb0b..793e2c6 100644 --- a/source/fdisk/cmd.h +++ b/source/fdisk/cmd.h @@ -45,7 +45,6 @@ void Command_Line_Status( void ); void Command_Line_Move( void ); void Command_Line_Swap( void ); void Command_Line_Test_Flag( void ); -void Command_Line_X( void ); void Shift_Command_Line_Options( int number_of_places ); #endif /* CMD_H */ diff --git a/source/fdisk/main.c b/source/fdisk/main.c index d3f7b9c..1d956c2 100644 --- a/source/fdisk/main.c +++ b/source/fdisk/main.c @@ -243,7 +243,7 @@ static int Get_Environment_Settings( char *environment[] ) } /* Initialize flags, variables, load fdisk.ini, load part.ini, etc. */ -static void Initialization( char *environment[] ) +static void InitOptions( char *environment[] ) { int index; @@ -258,6 +258,7 @@ static void Initialization( char *environment[] ) flags.use_iui = TRUE; flags.using_default_drive_number = TRUE; flags.version = COMP_W95B; + flags.use_extended_int_13 = TRUE; /* Clear the user_defined_chs_settings structure */ index = 0; @@ -284,21 +285,21 @@ static void Initialization( char *environment[] ) /* monochrome mode, if it is desired. */ con_enable_attr( !flags.monochrome ); - /* Check for interrupt 0x13 extensions (If the proper version is set.) */ - if ( flags.version >= COMP_W95 ) { - Check_For_INT13_Extensions(); - } - /* If the version is W95B or later then default to FAT32 support. */ if ( flags.version >= COMP_W95B ) { flags.fat32 = TRUE; } +} - /* Initialize LBA structures, if necessary. */ - if ( flags.use_extended_int_13 == TRUE ) { - Initialize_LBA_Structures(); +static void InitDisks( void ) +{ + /* Check for interrupt 0x13 extensions (If the proper version is set.) */ + if ( flags.version >= COMP_W95 ) { + Check_For_INT13_Extensions(); } + Initialize_LBA_Structures(); + if ( Read_Partition_Tables() != 0 ) { con_puts( svarlang_str(255, 0) ); exit( 1 ); @@ -307,9 +308,10 @@ static void Initialization( char *environment[] ) if ( flags.maximum_drive_number == 0 ) { con_puts( svarlang_str(255, 1) ); exit( 6 ); - } + } } + /* Reboot the PC */ void Reboot_PC( void ) { @@ -360,6 +362,7 @@ static void Ensure_Drive_Number( void ) */ int main( int argc, char *argv[] ) { + char **argp; int command_ok; int index; int location; @@ -451,9 +454,21 @@ int main( int argc, char *argv[] ) else { path[0] = 0; } + + InitOptions( environ ); + + /* Check if LBA is forbidden by the user before querying BIOS + capabilities, because some BIOS INT13,41h is broken, like + XT-IDE 2.03 beta without LBA support */ + argp = argv+1; + while ( *argp ) { + if ( !strcmp( *argp, "/x" ) || !strcmp( *argp, "/X" ) ) { + flags.use_extended_int_13 = FALSE; + } + argp++; + } - Initialization( environ ); - + InitDisks(); /* New Parsing Routine */ /* The command line format is: */ @@ -485,11 +500,9 @@ int main( int argc, char *argv[] ) } if ( 0 == strcmp( arg[0].choice, "ACTOK" ) ) { - /* - if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) { - Ask_User_About_FAT32_Support(); - } - */ + /* ignored */ + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); } if ( 0 == strcmp( arg[0].choice, "AUTO" ) ) { @@ -796,7 +809,8 @@ int main( int argc, char *argv[] ) #endif if ( 0 == strcmp( arg[0].choice, "X" ) ) { - Command_Line_X(); + /* handled above, but still have to check to not misdetect + it as invalid parameter */ Shift_Command_Line_Options( 1 ); command_ok = TRUE; } diff --git a/source/fdisk/main.h b/source/fdisk/main.h index c30aefa..bb467af 100644 --- a/source/fdisk/main.h +++ b/source/fdisk/main.h @@ -4,7 +4,7 @@ #define FD_NAME "Free FDISK" #endif -#define VERSION "1.3.13" +#define VERSION "1.3.14" #define COPYLEFT "1998 - 2024" #define SIZE_OF_IPL ( 512 - 4 * 16 - 2 - 6 ) diff --git a/source/fdisk/pdiskio.c b/source/fdisk/pdiskio.c index 194e0d1..5fc42b3 100644 --- a/source/fdisk/pdiskio.c +++ b/source/fdisk/pdiskio.c @@ -110,22 +110,24 @@ void Check_For_INT13_Extensions( void ) pDrive = part_table; + memset( &r, 0, sizeof(r) ); for ( drive = 0x80; drive < 0x88; drive++, pDrive++ ) { - r.h.ah = 0x41; - r.w.bx = 0x55aa; - r.h.dl = drive; - intr( 0x13, &r ); - pDrive->ext_int_13 = FALSE; pDrive->ext_int_13_version = 0; - if ( ( ( r.w.flags & INTR_CF ) == 0 ) && ( r.w.bx == 0xaa55 ) ) { - flags.use_extended_int_13 = TRUE; - pDrive->ext_int_13_version = r.h.ah; - - if ( ( r.w.cx & 1 ) == 1 ) { - /* ext INT 13 functions 42, 43 and 48 actually usable? */ - pDrive->ext_int_13 = TRUE; + if ( flags.use_extended_int_13 ) { + r.h.ah = 0x41; + r.w.bx = 0x55aa; + r.h.dl = drive; + intr( 0x13, &r ); + + if ( ( ( r.w.flags & INTR_CF ) == 0 ) && ( r.w.bx == 0xaa55 ) ) { + pDrive->ext_int_13_version = r.h.ah; + + if ( ( r.w.cx & 1 ) == 1 ) { + /* ext INT 13 functions 42, 43 and 48 actually usable? */ + pDrive->ext_int_13 = TRUE; + } } } }