Changeset 67069 in vbox for trunk/src/VBox
- Timestamp:
- May 24, 2017 6:59:06 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS/floppy.c
r63562 r67069 46 46 extern uint16_t get_floppy_dpt(uint8_t drive_type); 47 47 48 // Local copies to slihgtly reduce stack usage. 49 inline uint8_t read_byte(uint16_t seg, uint16_t offset) 50 { 51 return( *(seg:>(uint8_t *)offset) ); 52 } 53 54 inline void write_byte(uint16_t seg, uint16_t offset, uint8_t data) 55 { 56 *(seg:>(uint8_t *)offset) = data; 57 } 58 59 48 60 ////////////////////// 49 61 // FLOPPY functions // 50 62 ////////////////////// 51 63 52 void set_diskette_ret_status(uint8_t value)64 inline void set_diskette_ret_status(uint8_t value) 53 65 { 54 66 write_byte(0x0040, 0x0041, value); … … 222 234 uint8_t val8; 223 235 #endif 224 uint8_t return_status[7];225 236 int i; 226 237 … … 248 259 249 260 // read 7 return status bytes from controller 250 for (i = 0; i < 7; ++i) { 251 return_status[i] = inb(0x3f5); 252 } 253 254 if ( (return_status[0] & 0xc0) != 0 ) 261 for (i = 0; i < 7; ++i) 262 write_byte(0x0040, 0x0042 + i, inb(0x3f5)); 263 264 if ((read_byte(0x0040, 0x0042 + 0) & 0xc0) != 0) 255 265 return 0; 256 266 else … … 445 455 #define CX r.gr.u.r16.cx 446 456 #define DX r.gr.u.r16.dx 447 #define SI r.gr.u.r16.si 457 #define SI r.gr.u.r16.si // not used 448 458 #define DI r.gr.u.r16.di 449 #define BP r.gr.u.r16.bp 459 #define BP r.gr.u.r16.bp // not used 450 460 #define ELDX r.gr.u.r16.sp 451 #define DS r.ds 461 #define DS r.ds // not used 452 462 #define ES r.es 453 463 #define FLAGS r.ra.flags.u.r16.flags … … 458 468 uint16_t base_address, base_count, base_es; 459 469 uint8_t page, mode_register, val8, media_state; 460 uint8_t return_status[7]; 461 uint8_t drive_type, num_floppies, ah; 470 uint8_t drive_type, num_floppies; 462 471 uint16_t last_addr; 463 472 int i; … … 465 474 BX_DEBUG_INT13_FL("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES); 466 475 467 ah = GET_AH(); 468 469 switch ( ah ) { 476 switch ( GET_AH() ) { 470 477 case 0x00: // diskette controller reset 471 478 BX_DEBUG_INT13_FL("floppy f00\n"); … … 549 556 } 550 557 551 if ( ah== 0x02) {558 if (GET_AH() == 0x02) { 552 559 // Read Diskette Sectors 553 560 … … 671 678 672 679 // read 7 return status bytes from controller and store in BDA 673 for (i = 0; i < 7; ++i) { 674 return_status[i] = inb(0x3f5); 675 write_byte(0x0040, 0x0042 + i, return_status[i]); 676 } 677 678 if ( (return_status[0] & 0xc0) != 0 ) { 680 for (i = 0; i < 7; ++i) 681 write_byte(0x0040, 0x0042 + i, inb(0x3f5)); 682 683 if ((read_byte(0x0040, 0x0042 + 0) & 0xc0) != 0) { 679 684 BX_DEBUG_INT13_FL("failed (FDC failure)\n"); 680 685 floppy_reset_controller(drive); … … 696 701 CLEAR_CF(); // success 697 702 return; 698 } else if ( ah== 0x03) {703 } else if (GET_AH() == 0x03) { 699 704 // Write Diskette Sectors 700 705 … … 810 815 811 816 // read 7 return status bytes from controller and store in BDA 812 for (i = 0; i < 7; ++i) { 813 return_status[i] = inb(0x3f5); 814 write_byte(0x0040, 0x0042 + i, return_status[i]); 815 } 816 817 if ( (return_status[0] & 0xc0) != 0 ) { 818 if ( (return_status[1] & 0x02) != 0 ) { 817 for (i = 0; i < 7; ++i) 818 write_byte(0x0040, 0x0042 + i, inb(0x3f5)); 819 820 if ((read_byte(0x0040, 0x0042 + 0) & 0xc0) != 0) { 821 if ((read_byte(0x0040, 0x0042 + 1) & 0x02) != 0) { 819 822 // diskette not writable. 820 823 // AH=status code=0x03 (tried to write on write-protected disk) … … 975 978 976 979 // read 7 return status bytes from controller and store in BDA 977 for (i = 0; i < 7; ++i) { 978 return_status[i] = inb(0x3f5); 979 write_byte(0x0040, 0x0042 + i, return_status[i]); 980 } 981 982 if ( (return_status[0] & 0xc0) != 0 ) { 983 if ( (return_status[1] & 0x02) != 0 ) { 980 for (i = 0; i < 7; ++i) 981 write_byte(0x0040, 0x0042 + i, inb(0x3f5)); 982 983 if ((read_byte(0x0040, 0x0042 + 0) & 0xc0) != 0) { 984 if ((read_byte(0x0040, 0x0042 + 1) & 0x02) != 0) { 984 985 // diskette not writable. 985 986 // AH=status code=0x03 (tried to write on write-protected disk) … … 1352 1353 #endif // #if BX_SUPPORT_FLOPPY 1353 1354 1354 #if 0 1355 void determine_floppy_media(uint16_t drive) 1356 { 1357 uint8_t val8, DOR, ctrl_info; 1358 1359 ctrl_info = read_byte(0x0040, 0x008F); 1360 if (drive==1) 1361 ctrl_info >>= 4; 1362 else 1363 ctrl_info &= 0x0f; 1364 1365 #if 0 1366 if (drive == 0) { 1367 DOR = 0x1c; // DOR: drive0 motor on, DMA&int enabled, normal op, drive select 0 1368 } 1369 else { 1370 DOR = 0x2d; // DOR: drive1 motor on, DMA&int enabled, normal op, drive select 1 1371 } 1372 #endif 1373 1374 if ( (ctrl_info & 0x04) != 0x04 ) { 1375 // Drive not determined means no drive exists, done. 1376 return; 1377 } 1378 1379 #if 0 1380 // check Main Status Register for readiness 1381 val8 = inb(0x03f4) & 0x80; // Main Status Register 1382 if (val8 != 0x80) 1383 BX_PANIC("d_f_m: MRQ bit not set\n"); 1384 1385 // change line 1386 1387 // existing BDA values 1388 1389 // turn on drive motor 1390 outb(0x03f2, DOR); // Digital Output Register 1391 // 1392 #endif 1393 BX_PANIC("d_f_m: OK so far\n"); 1394 } 1395 #endif 1396 1355 /* Avoid saving general registers already saved by caller (PUSHA). */ 1356 #pragma aux int13_diskette_function modify [di si cx dx bx];
Note:
See TracChangeset
for help on using the changeset viewer.