Changeset 39575 in vbox for trunk/src/VBox/Devices/PC/BIOS-new
- Timestamp:
- Dec 9, 2011 5:14:36 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/eltorito.c
r39571 r39575 254 254 if (device >= BX_MAX_STORAGE_DEVICES) 255 255 return 2; 256 256 257 257 /* Read the Boot Record Volume Descriptor (BRVD). */ 258 258 _fmemset(&atapicmd, 0, sizeof(atapicmd)); … … 288 288 //@todo: this swaps the LBA back and forth for no good reason??! 289 289 // 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]); 291 291 BX_DEBUG_ELTORITO("BRVD at LBA %lx\n", lba); 292 292 … … 304 304 if (error != 0) 305 305 return 7; 306 306 307 //@todo: Define a struct for the Boot Catalog, the hardcoded offsets are so dumb... 308 307 309 /* Check if the Boot Catalog looks valid. */ 308 310 if (buffer[0x00] != 0x01) … … 314 316 if (buffer[0x1F] != 0xAA) 315 317 return 10; // key 2 316 318 317 319 // Initial/Default Entry 318 320 if (buffer[0x20] != 0x88) 319 321 return 11; // Bootable 320 322 321 BX_DEBUG_ELTORITO("Emulate drive %x\n", buffer[0x21]);322 323 cdemu->media = buffer[0x21]; 323 324 if (buffer[0x21] == 0) { … … 330 331 else 331 332 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 339 341 cdemu->load_segment = boot_segment; 340 342 cdemu->buffer_segment = 0x0000; 341 342 nbsectors =buffer[0x27]*0x100+buffer[0x26];343 344 nbsectors = ((uint16_t *)buffer)[0x26 / 2]; 343 345 cdemu->sector_count = nbsectors; 344 346 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]); 347 348 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. */ 350 354 _fmemset(&atapicmd, 0, sizeof(atapicmd)); //@todo: should be redundant 351 355 atapicmd.command = 0x28; // READ 10 command … … 359 363 if (error != 0) 360 364 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. */ 363 369 switch (cdemu->media) { 364 case 0x01: / / 1.2M floppy370 case 0x01: /* 1.2M floppy */ 365 371 cdemu->vdevice.spt = 15; 366 372 cdemu->vdevice.cylinders = 80; 367 373 cdemu->vdevice.heads = 2; 368 374 break; 369 case 0x02: / / 1.44M floppy375 case 0x02: /* 1.44M floppy */ 370 376 cdemu->vdevice.spt = 18; 371 377 cdemu->vdevice.cylinders = 80; 372 378 cdemu->vdevice.heads = 2; 373 379 break; 374 case 0x03: / / 2.88M floppy380 case 0x03: /* 2.88M floppy */ 375 381 cdemu->vdevice.spt = 36; 376 382 cdemu->vdevice.cylinders = 80; 377 383 cdemu->vdevice.heads = 2; 378 384 break; 379 case 0x04: / / Harddrive385 case 0x04: /* Hard disk */ 380 386 cdemu->vdevice.spt = read_byte(boot_segment,446+6)&0x3f; 381 387 cdemu->vdevice.cylinders = (read_byte(boot_segment,446+6)<<2) + read_byte(boot_segment,446+7) + 1; … … 383 389 break; 384 390 } 385 391 BX_DEBUG_ELTORITO("VCHS=%u/%u/%u\n", cdemu->vdevice.cylinders, 392 cdemu->vdevice.heads, cdemu->vdevice.spt); 393 386 394 if (cdemu->media != 0) { 387 395 /* Increase BIOS installed number of drives (floppy or fixed). */ … … 391 399 write_byte(ebda_seg,(uint16_t)&EbdaData->bdisk.hdcount, read_byte(ebda_seg, (uint16_t)&EbdaData->bdisk.hdcount) + 1); 392 400 } 393 394 401 395 402 // everything is ok, so from now on, the emulation is active 396 if (cdemu->media != 0)403 if (cdemu->media != 0) 397 404 cdemu->active = 0x01; 398 405 399 406 // return the boot drive + no error 400 407 return (cdemu->emulated_drive*0x100)+0;
Note:
See TracChangeset
for help on using the changeset viewer.