Changeset 39571 in vbox for trunk/src/VBox/Devices/PC/BIOS-new
- Timestamp:
- Dec 9, 2011 2:24:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/eltorito.c
r39567 r39571 80 80 #define FLAGS r.ra.flags.u.r16.flags 81 81 82 #pragma pack(1) 83 84 /* READ_10/WRITE_10 CDB padded to 12 bytes for ATAPI. */ 85 typedef struct { 86 uint16_t command; /* Command. */ 87 uint32_t lba; /* LBA, MSB first! */ 88 uint8_t pad1; /* Unused. */ 89 uint16_t nsect; /* Sector count, MSB first! */ 90 uint8_t pad2[3]; /* Unused. */ 91 } cdb_atapi; 92 93 #pragma pack() 94 95 ct_assert(sizeof(cdb_atapi) == 12); 82 96 83 97 // --------------------------------------------------------------------------- … … 221 235 // @TODO: a macro or a function for getting the EBDA segment 222 236 uint16_t ebda_seg=read_word(0x0040,0x000E); 223 uint8_t atacmd[12], buffer[2048]; 237 uint8_t buffer[2048]; 238 cdb_atapi atapicmd; 224 239 uint32_t lba; 225 240 uint16_t boot_segment, nbsectors, i, error; … … 241 256 242 257 /* Read the Boot Record Volume Descriptor (BRVD). */ 243 _fmemset(&atacmd, 0, 12); 244 //@todo: use some sane byte swapping routines here 245 atacmd[0] = 0x28; // READ command 246 atacmd[7] = (0x01 & 0xff00) >> 8; // Sectors 247 atacmd[8] = (0x01 & 0x00ff); // Sectors 248 atacmd[2] = (0x11 & 0xff000000) >> 24; // LBA 249 atacmd[3] = (0x11 & 0x00ff0000) >> 16; 250 atacmd[4] = (0x11 & 0x0000ff00) >> 8; 251 atacmd[5] = (0x11 & 0x000000ff); 258 _fmemset(&atapicmd, 0, sizeof(atapicmd)); 259 atapicmd.command = 0x28; // READ 10 command 260 atapicmd.lba = swap_32(0x11); 261 atapicmd.nsect = swap_16(0x01); 252 262 253 263 for (read_try = 0; read_try <= 4; ++read_try) … … 255 265 //@todo: Use indirect calls instead? 256 266 if (device > BX_MAX_ATA_DEVICES) 257 error = ahci_cmd_packet(device, 12, &atacmd, 0, 2048L, ATA_DATA_IN, &buffer);267 error = ahci_cmd_packet(device, 12, (char __far *)&atapicmd, 0, 2048L, ATA_DATA_IN, &buffer); 258 268 else 259 error = ata_cmd_packet(device, 12, &atacmd, 0, 2048L, ATA_DATA_IN, &buffer);269 error = ata_cmd_packet(device, 12, (char __far *)&atapicmd, 0, 2048L, ATA_DATA_IN, &buffer); 260 270 if (!error) 261 271 break; … … 282 292 283 293 /* Now we read the Boot Catalog. */ 284 _fmemset(&atacmd,0,12); 285 //@todo: use some sane byte swapping routines here 286 atacmd[0] = 0x28; // READ command 287 atacmd[7] = (0x01 & 0xff00) >> 8; // Sectors 288 atacmd[8] = (0x01 & 0x00ff); // Sectors 289 atacmd[2] = (lba & 0xff000000) >> 24; // LBA 290 atacmd[3] = (lba & 0x00ff0000) >> 16; 291 atacmd[4] = (lba & 0x0000ff00) >> 8; 292 atacmd[5] = (lba & 0x000000ff); 294 _fmemset(&atapicmd, 0, sizeof(atapicmd)); //@todo: should be redundant 295 atapicmd.command = 0x28; // READ 10 command 296 atapicmd.lba = swap_32(lba); 297 atapicmd.nsect = swap_16(0x01); 293 298 294 299 if (device > BX_MAX_ATA_DEVICES) 295 error = ahci_cmd_packet(device, 12, &atacmd, 0, 2048L, ATA_DATA_IN, &buffer);300 error = ahci_cmd_packet(device, 12, (char __far *)&atapicmd, 0, 2048L, ATA_DATA_IN, &buffer); 296 301 else 297 error = ata_cmd_packet(device, 12, &atacmd, 0, 2048L, ATA_DATA_IN, &buffer);302 error = ata_cmd_packet(device, 12, (char __far *)&atapicmd, 0, 2048L, ATA_DATA_IN, &buffer); 298 303 299 304 if (error != 0) … … 343 348 344 349 /* Read the image into memory. */ 345 _fmemset(&atacmd, 0, 12); 346 atacmd[0] = 0x28; // READ command 347 atacmd[7] = ((1+(nbsectors-1)/4) & 0xff00) >> 8;// Sectors 348 atacmd[8] = ((1+(nbsectors-1)/4) & 0x00ff); // Sectors 349 atacmd[2] = (lba & 0xff000000) >> 24; // LBA 350 atacmd[3] = (lba & 0x00ff0000) >> 16; 351 atacmd[4] = (lba & 0x0000ff00) >> 8; 352 atacmd[5] = (lba & 0x000000ff); 350 _fmemset(&atapicmd, 0, sizeof(atapicmd)); //@todo: should be redundant 351 atapicmd.command = 0x28; // READ 10 command 352 atapicmd.lba = swap_32(lba); 353 atapicmd.nsect = swap_16(1 + (nbsectors - 1) / 4); 353 354 354 355 if (device > BX_MAX_ATA_DEVICES) 355 error = ahci_cmd_packet(device, 12, &atacmd, 0, nbsectors*512L, ATA_DATA_IN, MK_FP(boot_segment,0));356 error = ahci_cmd_packet(device, 12, (char __far *)&atapicmd, 0, nbsectors*512L, ATA_DATA_IN, MK_FP(boot_segment,0)); 356 357 else 357 error = ata_cmd_packet(device, 12, &atacmd, 0, nbsectors*512L, ATA_DATA_IN, MK_FP(boot_segment,0));358 error = ata_cmd_packet(device, 12, (char __far *)&atapicmd, 0, nbsectors*512L, ATA_DATA_IN, MK_FP(boot_segment,0)); 358 359 if (error != 0) 359 360 return 12; … … 417 418 uint32_t vlba, ilba, slba, elba; 418 419 uint16_t before, segment, offset; 419 uint8_t atacmd[12];420 cdb_atapi atapicmd; 420 421 cdemu_t __far *cdemu; 421 422 … … 515 516 // end lba on cd 516 517 elba = (uint32_t)(vlba+nbsectors-1)/4; 517 518 _fmemset(&atacmd, 0, 12); 519 //@todo: use some sane byte swapping routines here 520 atacmd[0] = 0x28; // READ command 521 atacmd[7] = ((uint16_t)(elba-slba+1) & 0xff00) >> 8;// Sectors 522 atacmd[8] = ((uint16_t)(elba-slba+1) & 0x00ff); // Sectors 523 atacmd[2] = (ilba+slba & 0xff000000) >> 24; // LBA 524 atacmd[3] = (ilba+slba & 0x00ff0000) >> 16; 525 atacmd[4] = (ilba+slba & 0x0000ff00) >> 8; 526 atacmd[5] = (ilba+slba & 0x000000ff); 518 519 _fmemset(&atapicmd, 0, sizeof(atapicmd)); 520 atapicmd.command = 0x28; // READ 10 command 521 atapicmd.lba = swap_32(ilba + slba); 522 atapicmd.nsect = swap_16(elba - slba + 1); 527 523 528 524 if (device > BX_MAX_ATA_DEVICES) 529 status = ahci_cmd_packet(device, 12, &atacmd, before*512, nbsectors*512L, ATA_DATA_IN, MK_FP(segment,offset));525 status = ahci_cmd_packet(device, 12, (char __far *)&atapicmd, before*512, nbsectors*512L, ATA_DATA_IN, MK_FP(segment,offset)); 530 526 else 531 status = ata_cmd_packet(device, 12, &atacmd, before*512, nbsectors*512L, ATA_DATA_IN, MK_FP(segment,offset));527 status = ata_cmd_packet(device, 12, (char __far *)&atapicmd, before*512, nbsectors*512L, ATA_DATA_IN, MK_FP(segment,offset)); 532 528 533 529 if (status != 0) { … … 617 613 uint16_t ebda_seg = read_word(0x0040,0x000E); 618 614 uint8_t device, status, locks; 619 uint8_t atacmd[12];615 cdb_atapi atapicmd; 620 616 uint32_t lba; 621 617 uint16_t count, segment, offset, size; … … 719 715 __func__, count, lba, segment, offset); 720 716 721 _fmemset(&atacmd, 0, 12); 722 //@todo: use some sane byte swapping routines here 723 atacmd[0] = 0x28; // READ command 724 atacmd[7] = (count & 0xff00) >> 8; // Sectors 725 atacmd[8] = (count & 0x00ff); // Sectors 726 atacmd[2] = (lba & 0xff000000) >> 24; // LBA 727 atacmd[3] = (lba & 0x00ff0000) >> 16; 728 atacmd[4] = (lba & 0x0000ff00) >> 8; 729 atacmd[5] = (lba & 0x000000ff); 717 _fmemset(&atapicmd, 0, sizeof(atapicmd)); 718 atapicmd.command = 0x28; // READ 10 command 719 atapicmd.lba = swap_32(lba); 720 atapicmd.nsect = swap_16(count); 730 721 731 722 if (device > BX_MAX_ATA_DEVICES) 732 status = ahci_cmd_packet(device, 12, &atacmd, 0, count*2048L, ATA_DATA_IN, MK_FP(segment,offset));723 status = ahci_cmd_packet(device, 12, (char __far *)&atapicmd, 0, count*2048L, ATA_DATA_IN, MK_FP(segment,offset)); 733 724 else 734 status = ata_cmd_packet(device, 12, &atacmd, 0, count*2048L, ATA_DATA_IN, MK_FP(segment,offset));725 status = ata_cmd_packet(device, 12, (char __far *)&atapicmd, 0, count*2048L, ATA_DATA_IN, MK_FP(segment,offset)); 735 726 736 727 count = (uint16_t)(bios_dsk->drqp.trsfbytes >> 11);
Note:
See TracChangeset
for help on using the changeset viewer.