VirtualBox

Ignore:
Timestamp:
Dec 9, 2011 5:14:36 PM (13 years ago)
Author:
vboxsync
Message:

Cleanup, logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS-new/eltorito.c

    r39571 r39575  
    254254    if (device >= BX_MAX_STORAGE_DEVICES)
    255255        return 2;
    256    
     256
    257257    /* Read the Boot Record Volume Descriptor (BRVD). */
    258258    _fmemset(&atapicmd, 0, sizeof(atapicmd));
     
    288288    //@todo: this swaps the LBA back and forth for no good reason??!
    289289    // ok, now we calculate the Boot catalog address
    290     lba = buffer[0x4A]*0x1000000UL + buffer[0x49]*0x10000UL + buffer[0x48]*0x100UL + buffer[0x47];
     290    lba = *((uint32_t *)&buffer[0x47]);
    291291    BX_DEBUG_ELTORITO("BRVD at LBA %lx\n", lba);
    292292
     
    304304    if (error != 0)
    305305        return 7;
    306    
     306
     307    //@todo: Define a struct for the Boot Catalog, the hardcoded offsets are so dumb...
     308
    307309    /* Check if the Boot Catalog looks valid. */
    308310    if (buffer[0x00] != 0x01)
     
    314316    if (buffer[0x1F] != 0xAA)
    315317        return 10;  // key 2
    316    
     318
    317319    // Initial/Default Entry
    318320    if (buffer[0x20] != 0x88)
    319321        return 11; // Bootable
    320322
    321     BX_DEBUG_ELTORITO("Emulate drive %x\n", buffer[0x21]);
    322323    cdemu->media = buffer[0x21];
    323324    if (buffer[0x21] == 0) {
     
    330331    else
    331332        cdemu->emulated_drive = 0x80;
    332    
    333     cdemu->controller_index = device/2;
    334     cdemu->device_spec      = device%2;
    335    
    336     boot_segment=buffer[0x23]*0x100+buffer[0x22];
    337     if(boot_segment==0x0000)boot_segment=0x07C0;
    338    
     333
     334    cdemu->controller_index = device / 2;
     335    cdemu->device_spec      = device % 2;
     336
     337    boot_segment  = *((uint16_t *)&buffer[0x22]);
     338    if (boot_segment == 0)
     339        boot_segment = 0x07C0;
     340
    339341    cdemu->load_segment   = boot_segment;
    340342    cdemu->buffer_segment = 0x0000;
    341    
    342     nbsectors=buffer[0x27]*0x100+buffer[0x26];
     343
     344    nbsectors = ((uint16_t *)buffer)[0x26 / 2];
    343345    cdemu->sector_count = nbsectors;
    344346
    345     //@todo: pointless swapping of the LBA value?
    346     lba=buffer[0x2B]*0x1000000UL+buffer[0x2A]*0x10000UL+buffer[0x29]*0x100UL+buffer[0x28];
     347    lba = *((uint32_t *)&buffer[0x28]);
    347348    cdemu->ilba = lba;
    348    
    349     /* Read the image into memory. */
     349
     350    BX_DEBUG_ELTORITO("Emulate drive %02x, type %02x, LBA %lu\n",
     351                      cdemu->emulated_drive, cdemu->media, cdemu->ilba);
     352
     353    /* Read the disk image's boot sector into memory. */
    350354    _fmemset(&atapicmd, 0, sizeof(atapicmd));   //@todo: should be redundant
    351355    atapicmd.command = 0x28;    // READ 10 command
     
    359363    if (error != 0)
    360364        return 12;
    361    
    362     // Remember the media type
     365
     366    BX_DEBUG_ELTORITO("Emulate drive %02x, type %02x, LBA %lu\n",
     367                      cdemu->emulated_drive, cdemu->media, cdemu->ilba);
     368    /* Set up emulated drive geometry based on the media type. */
    363369    switch (cdemu->media) {
    364     case 0x01:  // 1.2M floppy
     370    case 0x01:  /* 1.2M floppy */
    365371        cdemu->vdevice.spt       = 15;
    366372        cdemu->vdevice.cylinders = 80;
    367373        cdemu->vdevice.heads     = 2;
    368374        break;
    369     case 0x02:  // 1.44M floppy
     375    case 0x02:  /* 1.44M floppy */
    370376        cdemu->vdevice.spt       = 18;
    371377        cdemu->vdevice.cylinders = 80;
    372378        cdemu->vdevice.heads     = 2;
    373379        break;
    374     case 0x03:  // 2.88M floppy
     380    case 0x03:  /* 2.88M floppy */
    375381        cdemu->vdevice.spt       = 36;
    376382        cdemu->vdevice.cylinders = 80;
    377383        cdemu->vdevice.heads     = 2;
    378384        break;
    379     case 0x04:  // Harddrive
     385    case 0x04:  /* Hard disk */
    380386        cdemu->vdevice.spt       = read_byte(boot_segment,446+6)&0x3f;
    381387        cdemu->vdevice.cylinders = (read_byte(boot_segment,446+6)<<2) + read_byte(boot_segment,446+7) + 1;
     
    383389        break;
    384390    }
    385    
     391    BX_DEBUG_ELTORITO("VCHS=%u/%u/%u\n", cdemu->vdevice.cylinders,
     392                      cdemu->vdevice.heads, cdemu->vdevice.spt);
     393
    386394    if (cdemu->media != 0) {
    387395        /* Increase BIOS installed number of drives (floppy or fixed). */
     
    391399            write_byte(ebda_seg,(uint16_t)&EbdaData->bdisk.hdcount, read_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.hdcount) + 1);
    392400    }
    393    
    394    
     401
    395402    // everything is ok, so from now on, the emulation is active
    396     if (cdemu->media !=0 )
     403    if (cdemu->media != 0)
    397404        cdemu->active = 0x01;
    398    
     405
    399406    // return the boot drive + no error
    400407    return (cdemu->emulated_drive*0x100)+0;
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