|
@@ -325,15 +325,20 @@ static int int13_get_extended_parameters ( struct int13_drive *drive,
|
325
|
325
|
static __cdecl void int13 ( struct i386_all_regs *ix86 ) {
|
326
|
326
|
int command = ix86->regs.ah;
|
327
|
327
|
unsigned int bios_drive = ix86->regs.dl;
|
328
|
|
- unsigned int original_bios_drive = bios_drive;
|
329
|
328
|
struct int13_drive *drive;
|
330
|
329
|
int status;
|
331
|
330
|
|
332
|
331
|
list_for_each_entry ( drive, &drives, list ) {
|
333
|
|
- if ( drive->drive > bios_drive )
|
334
|
|
- continue;
|
335
|
|
- if ( drive->drive < bios_drive ) {
|
336
|
|
- original_bios_drive--;
|
|
332
|
+
|
|
333
|
+ if ( bios_drive != drive->drive ) {
|
|
334
|
+ /* Remap any accesses to this drive's natural number */
|
|
335
|
+ if ( bios_drive == drive->natural_drive ) {
|
|
336
|
+ DBG ( "INT 13,%04x (%02x) remapped to "
|
|
337
|
+ "(%02x)\n", ix86->regs.ax,
|
|
338
|
+ bios_drive, drive->drive );
|
|
339
|
+ ix86->regs.dl = drive->drive;
|
|
340
|
+ return;
|
|
341
|
+ }
|
337
|
342
|
continue;
|
338
|
343
|
}
|
339
|
344
|
|
|
@@ -393,13 +398,6 @@ static __cdecl void int13 ( struct i386_all_regs *ix86 ) {
|
393
|
398
|
|
394
|
399
|
return;
|
395
|
400
|
}
|
396
|
|
-
|
397
|
|
- /* Remap BIOS drive */
|
398
|
|
- if ( bios_drive != original_bios_drive ) {
|
399
|
|
- DBG ( "INT 13,%04x (%02x) remapped to (%02x)\n",
|
400
|
|
- ix86->regs.ax, bios_drive, original_bios_drive );
|
401
|
|
- }
|
402
|
|
- ix86->regs.dl = original_bios_drive;
|
403
|
401
|
}
|
404
|
402
|
|
405
|
403
|
/**
|
|
@@ -542,19 +540,28 @@ void register_int13_drive ( struct int13_drive *drive ) {
|
542
|
540
|
/* Give drive a default geometry if none specified */
|
543
|
541
|
guess_int13_geometry ( drive );
|
544
|
542
|
|
545
|
|
- /* Assign drive number if none specified, update BIOS drive count */
|
|
543
|
+ /* Assign natural drive number */
|
546
|
544
|
get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
|
547
|
|
- if ( ( drive->drive & 0xff ) == 0xff )
|
548
|
|
- drive->drive = num_drives;
|
549
|
|
- drive->drive |= 0x80;
|
|
545
|
+ drive->natural_drive = ( num_drives | 0x80 );
|
550
|
546
|
num_drives++;
|
551
|
|
- if ( num_drives <= ( drive->drive & 0x7f ) )
|
552
|
|
- num_drives = ( ( drive->drive & 0x7f ) + 1 );
|
|
547
|
+
|
|
548
|
+ /* Assign drive number */
|
|
549
|
+ if ( ( drive->drive & 0xff ) == 0xff ) {
|
|
550
|
+ /* Drive number == -1 => use natural drive number */
|
|
551
|
+ drive->drive = drive->natural_drive;
|
|
552
|
+ } else {
|
|
553
|
+ /* Use specified drive number (+0x80 if necessary) */
|
|
554
|
+ drive->drive |= 0x80;
|
|
555
|
+ if ( num_drives <= ( drive->drive & 0x7f ) )
|
|
556
|
+ num_drives = ( ( drive->drive & 0x7f ) + 1 );
|
|
557
|
+ }
|
|
558
|
+
|
|
559
|
+ /* Update BIOS drive count */
|
553
|
560
|
put_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
|
554
|
561
|
|
555
|
|
- DBG ( "Registered INT13 drive %02x with C/H/S geometry %d/%d/%d\n",
|
556
|
|
- drive->drive, drive->cylinders, drive->heads,
|
557
|
|
- drive->sectors_per_track );
|
|
562
|
+ DBG ( "Registered INT13 drive %02x (naturally %02x) with C/H/S "
|
|
563
|
+ "geometry %d/%d/%d\n", drive->drive, drive->natural_drive,
|
|
564
|
+ drive->cylinders, drive->heads, drive->sectors_per_track );
|
558
|
565
|
|
559
|
566
|
/* Hook INT 13 vector if not already hooked */
|
560
|
567
|
if ( list_empty ( &drives ) )
|