Skip to content

Commit

Permalink
suppress checking for LBA support via INT13,41 if LBA disabled by user
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckmann committed Feb 5, 2024
1 parent 66694cb commit fb3a37a
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 61 deletions.
8 changes: 8 additions & 0 deletions doc/fdisk/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 0 additions & 29 deletions source/fdisk/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
1 change: 0 additions & 1 deletion source/fdisk/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
50 changes: 32 additions & 18 deletions source/fdisk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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 );
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: */
Expand Down Expand Up @@ -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" ) ) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source/fdisk/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
26 changes: 14 additions & 12 deletions source/fdisk/pdiskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit fb3a37a

Please sign in to comment.