VirtualBox

Changeset 67069 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 24, 2017 6:59:06 PM (8 years ago)
Author:
vboxsync
Message:

BIOS: Reduced INT 13h floppy service stack usage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/floppy.c

    r63562 r67069  
    4646extern uint16_t get_floppy_dpt(uint8_t drive_type);
    4747
     48// Local copies to slihgtly reduce stack usage.
     49inline uint8_t read_byte(uint16_t seg, uint16_t offset)
     50{
     51    return( *(seg:>(uint8_t *)offset) );
     52}
     53
     54inline void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
     55{
     56    *(seg:>(uint8_t *)offset) = data;
     57}
     58
     59
    4860//////////////////////
    4961// FLOPPY functions //
    5062//////////////////////
    5163
    52 void set_diskette_ret_status(uint8_t value)
     64inline void set_diskette_ret_status(uint8_t value)
    5365{
    5466    write_byte(0x0040, 0x0041, value);
     
    222234    uint8_t     val8;
    223235#endif
    224     uint8_t     return_status[7];
    225236    int         i;
    226237
     
    248259
    249260    // 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)
    255265        return 0;
    256266    else
     
    445455#define CX      r.gr.u.r16.cx
    446456#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
    448458#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
    450460#define ELDX    r.gr.u.r16.sp
    451 #define DS      r.ds
     461#define DS      r.ds            // not used
    452462#define ES      r.es
    453463#define FLAGS   r.ra.flags.u.r16.flags
     
    458468    uint16_t    base_address, base_count, base_es;
    459469    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;
    462471    uint16_t    last_addr;
    463472    int         i;
     
    465474    BX_DEBUG_INT13_FL("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES);
    466475
    467     ah = GET_AH();
    468 
    469     switch ( ah ) {
     476    switch ( GET_AH() ) {
    470477    case 0x00: // diskette controller reset
    471478        BX_DEBUG_INT13_FL("floppy f00\n");
     
    549556        }
    550557
    551         if (ah == 0x02) {
     558        if (GET_AH() == 0x02) {
    552559            // Read Diskette Sectors
    553560
     
    671678
    672679            // 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) {
    679684                BX_DEBUG_INT13_FL("failed (FDC failure)\n");
    680685                floppy_reset_controller(drive);
     
    696701            CLEAR_CF();   // success
    697702            return;
    698         } else if (ah == 0x03) {
     703        } else if (GET_AH() == 0x03) {
    699704            // Write Diskette Sectors
    700705
     
    810815
    811816            // 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) {
    819822                    // diskette not writable.
    820823                    // AH=status code=0x03 (tried to write on write-protected disk)
     
    975978
    976979        // 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) {
    984985                // diskette not writable.
    985986                // AH=status code=0x03 (tried to write on write-protected disk)
     
    13521353#endif  // #if BX_SUPPORT_FLOPPY
    13531354
    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.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette