VirtualBox

Changeset 6879 in vbox


Ignore:
Timestamp:
Feb 10, 2008 11:41:03 PM (17 years ago)
Author:
vboxsync
Message:

BIOS: fix booting from more than 4 drives

Location:
trunk/src/VBox/Devices/PC/BIOS
Files:
2 edited

Legend:

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

    r6870 r6879  
    586586{
    587587    Bit16u ebda_seg=read_word(0x0040,0x000E);
    588     Bit8u actual_device;
    589     Bit8u detected_devices = 0;
     588    Bit8u actual_device = 0;
    590589    Bit8u first_ctrl_printed = 0;
    591590    Bit8u second_ctrl_printed = 0;
    592 
    593     for (actual_device = 0; actual_device < BX_MAX_ATA_DEVICES; actual_device++)
     591    Bit8u device;
     592
     593    device = read_byte(ebda_seg, &EbdaData->ata.hdidmap[actual_device]);
     594
     595    while ((actual_device < BX_MAX_ATA_DEVICES) && (device < BX_MAX_ATA_DEVICES))
    594596    {
    595597        Bit8u device_position;
    596         Bit8u device = read_byte(ebda_seg, &EbdaData->ata.devices[actual_device].device);
    597 
    598         if (device == 0xff) /* logo.c is included before ATA_DEVICE_HD is defined */
    599         {
    600             if ((actual_device < 4) && (first_ctrl_printed == 0))
    601             {
    602                 printf("IDE controller:\n");
    603                 first_ctrl_printed = 1;
    604             }
    605             else if ((actual_device >= 4) && (second_ctrl_printed == 0))
    606             {
    607                 printf("AHCI controller:\n");
    608                 second_ctrl_printed = 1;
    609             }
    610 
    611             detected_devices++;
    612 
    613             printf("\n    %d) ", detected_devices);
    614 
    615             /* If actual_device bigger than or equal 4
    616              * this is the next controller and
    617              * the positions start at the beginning.
    618              */
    619             device_position = actual_device;
    620             if (actual_device >= 4)
    621                 device_position -= 4;
    622 
    623             if (device_position / 2)
    624                 printf("Secondary ");
    625             else
    626                 printf("Primary ");
    627 
    628             if (device_position % 2)
    629                 printf("Slave");
    630             else
    631                 printf("Master");
    632         }
     598
     599        device_position = device;
     600
     601        if ((device_position < 4) && (first_ctrl_printed == 0))
     602        {
     603            printf("IDE controller:\n");
     604            first_ctrl_printed = 1;
     605        }
     606        else if ((device_position >= 4) && (second_ctrl_printed == 0))
     607        {
     608            printf("\n\nAHCI controller:\n");
     609            second_ctrl_printed = 1;
     610        }
     611
     612        printf("\n    %d) ", actual_device+1);
     613
     614        /*
     615         * If actual_device is bigger than or equal 4
     616         * this is the next controller and
     617         * the positions start at the beginning.
     618         */
     619        if (device_position >= 4)
     620            device_position -= 4;
     621
     622        if (device_position / 2)
     623            printf("Primary ");
     624        else
     625            printf("Secondary ");
     626
     627        if (device_position % 2)
     628            printf("Slave");
     629        else
     630            printf("Master");
     631
     632        actual_device++;
     633        device = read_byte(ebda_seg, &EbdaData->ata.hdidmap[actual_device]);
    633634    }
    634635
     
    645646    for (actual_device = 0; actual_device < BX_MAX_ATA_DEVICES; actual_device++)
    646647    {
    647         Bit8u device = read_byte(ebda_seg, &EbdaData->ata.devices[actual_device].device);
    648 
    649         if (device == 0xff) /* logo.c is included before ATA_DEVICE_HD is defined */
    650             detected_devices++;
    651     }
    652 
    653     if ((scode-0x01) <= detected_devices)
    654         return scode-0x02;
     648        Bit8u device = read_byte(ebda_seg, &EbdaData->ata.hdidmap[actual_device]);
     649
     650        if (device < BX_MAX_ATA_DEVICES)
     651        {
     652            scode--;
     653            if (scode == 0x01)
     654                return actual_device;
     655        }
     656    }
    655657
    656658    /* Scancode is higher than number of available devices */
  • trunk/src/VBox/Devices/PC/BIOS/rombios.c

    r6870 r6879  
    23712371      sc = inb(iobase1+ATA_CB_SC);
    23722372      sn = inb(iobase1+ATA_CB_SN);
     2373
    23732374      if ((sc==0x01) && (sn==0x01)) {
    23742375        cl = inb(iobase1+ATA_CB_CL);
     
    24522453      else
    24532454      {
     2455          Bit32u temp_sectors = sectors;
     2456
     2457          //FIXME: only valid for LBA translation
     2458          lspt = 63;
     2459          temp_sectors /= 63;
     2460          lheads = temp_sectors / 1024;
     2461          if (lheads>128) lheads = 255;
     2462          else if (lheads>64) lheads = 128;
     2463          else if (lheads>32) lheads = 64;
     2464          else if (lheads>16) lheads = 32;
     2465          else lheads=16;
     2466          lcylinders = temp_sectors / lheads;
     2467
     2468          // clip to 1024 cylinders
     2469          if (lcylinders > 1024) lcylinders=1024;
     2470
     2471#if 0
    24542472          lcylinders = 0;
    24552473          lheads = 0;
    24562474          lspt = 0;
     2475#endif
    24572476      }
    24582477      BX_INFO("ata%d-%d: PCHS=%u/%d/%d LCHS=%u/%u/%u\n", channel, slave, cylinders, heads, spt, lcylinders, lheads, lspt);
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