Changeset 39583 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Dec 12, 2011 3:03:44 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75347
- Location:
- trunk/src/VBox/Devices/PC/BIOS-new
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/ahci.c
r39573 r39583 26 26 #include "vds.h" 27 27 28 #define VBOX_AHCI_DEBUG 0 29 30 #if VBOX_AHCI_DEBUG 31 # define VBOXAHCI_DEBUG(...) BX_INFO(__VA_ARGS__) 28 #if DEBUG_AHCI 29 # define DBG_AHCI(...) BX_INFO(__VA_ARGS__) 32 30 #else 33 # define VBOXAHCI_DEBUG(...)31 # define DBG_AHCI(...) 34 32 #endif 35 33 … … 258 256 259 257 /* Wait for a D2H FIS. */ 260 VBOXAHCI_DEBUG("AHCI: Waiting for D2H FIS\n");258 DBG_AHCI("AHCI: Waiting for D2H FIS\n"); 261 259 while (ahci_ctrl_is_bit_set(io_base, AHCI_PORT_REG(port, AHCI_REG_PORT_IS), 262 260 AHCI_REG_PORT_IS_DHRS) == 0) … … 275 273 } 276 274 else 277 VBOXAHCI_DEBUG("AHCI: Invalid port given\n");275 DBG_AHCI("AHCI: Invalid port given\n"); 278 276 } 279 277 … … 353 351 AHCI_REG_PORT_CMD_FRE | AHCI_REG_PORT_CMD_ST | AHCI_REG_PORT_CMD_FR | AHCI_REG_PORT_CMD_CR) == 1) 354 352 { 355 VBOXAHCI_DEBUG("AHCI: Waiting for the port to idle\n");353 DBG_AHCI("AHCI: Waiting for the port to idle\n"); 356 354 } 357 355 … … 394 392 AHCI_REG_PORT_CMD_FRE | AHCI_REG_PORT_CMD_ST | AHCI_REG_PORT_CMD_FR | AHCI_REG_PORT_CMD_CR) == 1) 395 393 { 396 VBOXAHCI_DEBUG("AHCI: Waiting for the port to idle\n");394 DBG_AHCI("AHCI: Waiting for the port to idle\n"); 397 395 } 398 396 … … 406 404 _fmemset(&ahci->abFisRecv[0], 0, sizeof(ahci->abFisRecv)); 407 405 408 VBOXAHCI_DEBUG("AHCI: FIS receive area %lx from %x:%x\n", ahci_addr_to_phys(&ahci->abFisRecv), FP_SEG(ahci), &AhciData->abFisRecv); 406 DBG_AHCI("AHCI: FIS receive area %lx from %x:%x\n", 407 ahci_addr_to_phys(&ahci->abFisRecv), FP_SEG(ahci), &AhciData->abFisRecv); 409 408 VBOXAHCI_PORT_WRITE_REG(ahci->iobase, u8Port, AHCI_REG_PORT_FB, ahci_addr_to_phys(&ahci->abFisRecv)); 410 409 VBOXAHCI_PORT_WRITE_REG(ahci->iobase, u8Port, AHCI_REG_PORT_FBU, 0); 411 410 412 VBOXAHCI_DEBUG("AHCI: CMD list area %lx\n", ahci_addr_to_phys(&ahci->aCmdHdr));411 DBG_AHCI("AHCI: CMD list area %lx\n", ahci_addr_to_phys(&ahci->aCmdHdr)); 413 412 VBOXAHCI_PORT_WRITE_REG(ahci->iobase, u8Port, AHCI_REG_PORT_CLB, ahci_addr_to_phys(&ahci->aCmdHdr)); 414 413 VBOXAHCI_PORT_WRITE_REG(ahci->iobase, u8Port, AHCI_REG_PORT_CLBU, 0); … … 438 437 BX_PANIC("%s: device_id out of range %d\n", __func__, device_id); 439 438 440 VBOXAHCI_DEBUG("%s: %u sectors @ LBA %lu, device %d, port %d\n", __func__,441 442 439 DBG_AHCI("%s: %u sectors @ LBA %lu, device %d, port %d\n", __func__, 440 bios_dsk->drqp.nsect, bios_dsk->drqp.lba, device_id, 441 bios_dsk->ahcidev[device_id].port); 443 442 444 443 ahci_port_init(bios_dsk->ahci_seg :> 0, bios_dsk->ahcidev[device_id].port); … … 465 464 BX_PANIC("%s: device_id out of range %d\n", __func__, device_id); 466 465 467 VBOXAHCI_DEBUG("%s: %u sectors @ LBA %lu, device %d, port %d\n", __func__,468 469 466 DBG_AHCI("%s: %u sectors @ LBA %lu, device %d, port %d\n", __func__, 467 bios_dsk->drqp.nsect, bios_dsk->drqp.lba, device_id, 468 bios_dsk->ahcidev[device_id].port); 470 469 471 470 ahci_port_init(bios_dsk->ahci_seg :> 0, bios_dsk->ahcidev[device_id].port); … … 493 492 /* The header length must be even. */ 494 493 if (header & 1) { 495 VBOXAHCI_DEBUG("%s: header must be even (%04x)\n", __func__, header);494 DBG_AHCI("%s: header must be even (%04x)\n", __func__, header); 496 495 return 1; 497 496 } … … 500 499 device_id = device_id - BX_MAX_ATA_DEVICES - BX_MAX_SCSI_DEVICES; 501 500 502 VBOXAHCI_DEBUG("%s: reading %lu bytes, header %u, device %d, port %d\n", __func__, 503 length, header, device_id, bios_dsk->ahcidev[device_id].port); 501 DBG_AHCI("%s: reading %lu bytes, header %u, device %d, port %d\n", __func__, 502 length, header, device_id, bios_dsk->ahcidev[device_id].port); 503 DBG_AHCI("%s: reading %u %u-byte sectors\n", __func__, 504 bios_dsk->drqp.nsect, bios_dsk->drqp.sect_sz); 504 505 505 506 bios_dsk->drqp.lba = (uint32_t)length << 8; //@todo: xfer length limit 506 507 bios_dsk->drqp.buffer = buffer; 507 bios_dsk->drqp.nsect = length / 2048;508 bios_dsk->drqp.sect_sz = 2048;508 // bios_dsk->drqp.nsect = length / 2048; 509 // bios_dsk->drqp.sect_sz = 2048; 509 510 510 511 ahci_port_init(bios_dsk->ahci_seg :> 0, bios_dsk->ahcidev[device_id].port); … … 519 520 520 521 ahci_cmd_data(bios_dsk, ATA_CMD_PACKET); 521 VBOXAHCI_DEBUG("%s: transferred %lu bytes\n", __func__, ahci->aCmdHdr[1]);522 DBG_AHCI("%s: transferred %lu bytes\n", __func__, ahci->aCmdHdr[1]); 522 523 bios_dsk->drqp.trsfbytes = ahci->aCmdHdr[1]; 523 524 #ifdef DMA_WORKAROUND … … 556 557 devcount_ahci = bios_dsk->ahci_devcnt; 557 558 558 VBOXAHCI_DEBUG("AHCI: Device detected on port %d\n", u8Port);559 DBG_AHCI("AHCI: Device detected on port %d\n", u8Port); 559 560 560 561 //@todo: Merge common HD/CDROM detection code … … 573 574 uint8_t idxCmosChsBase; 574 575 575 VBOXAHCI_DEBUG("AHCI: Detected hard disk\n");576 DBG_AHCI("AHCI: Detected hard disk\n"); 576 577 577 578 /* Identify device. */ … … 595 596 cSectors = *(uint16_t *)(abBuffer+(100*2)); // words 100 to 103 (someday) 596 597 597 VBOXAHCI_DEBUG("AHCI: %ld sectors\n", cSectors);598 DBG_AHCI("AHCI: %ld sectors\n", cSectors); 598 599 599 600 bios_dsk->ahcidev[devcount_ahci].port = u8Port; … … 640 641 cSectorsPerTrack = 0; 641 642 } 642 VBOXAHCI_DEBUG("AHCI: Dev %d LCHS=%d/%d/%d\n",643 643 DBG_AHCI("AHCI: Dev %d LCHS=%d/%d/%d\n", 644 devcount_ahci, cCylinders, cHeads, cSectorsPerTrack); 644 645 645 646 bios_dsk->devices[hd_index].lchs.heads = cHeads; … … 660 661 else if (val == 0xeb140101) 661 662 { 662 VBOXAHCI_DEBUG("AHCI: Detected ATAPI device\n");663 DBG_AHCI("AHCI: Detected ATAPI device\n"); 663 664 664 665 /* Identify packet device. */ … … 687 688 } 688 689 else 689 VBOXAHCI_DEBUG("AHCI: Ignoring unknown device\n");690 DBG_AHCI("AHCI: Ignoring unknown device\n"); 690 691 691 692 devcount_ahci++; … … 693 694 } 694 695 else 695 VBOXAHCI_DEBUG("AHCI: Reached maximum device count, skipping\n");696 DBG_AHCI("AHCI: Reached maximum device count, skipping\n"); 696 697 } 697 698 } … … 707 708 base_mem_kb = read_word(0x00, 0x0413); 708 709 709 VBOXAHCI_DEBUG("AHCI: %dK of base mem\n", base_mem_kb);710 DBG_AHCI("AHCI: %dK of base mem\n", base_mem_kb); 710 711 711 712 if (base_mem_kb == 0) … … 733 734 734 735 AHCI_READ_REG(io_base, AHCI_REG_VS, val); 735 VBOXAHCI_DEBUG("AHCI: Controller hasversion: 0x%x (major) 0x%x (minor)\n",736 737 736 DBG_AHCI("AHCI: Controller version: 0x%x (major) 0x%x (minor)\n", 737 ahci_ctrl_extract_bits(val, 0xffff0000, 16), 738 ahci_ctrl_extract_bits(val, 0x0000ffff, 0)); 738 739 739 740 /* Allocate 1K of base memory. */ … … 741 742 if (ahci_seg == 0) 742 743 { 743 VBOXAHCI_DEBUG("AHCI: Could not allocate 1K of memory, can't boot from controller\n");744 DBG_AHCI("AHCI: Could not allocate 1K of memory, can't boot from controller\n"); 744 745 return 0; 745 746 } 746 VBOXAHCI_DEBUG("AHCI: ahci_seg=%04x, size=%04x, pointer at EBDA:%04x (EBDA size=%04x)\n",747 747 DBG_AHCI("AHCI: ahci_seg=%04x, size=%04x, pointer at EBDA:%04x (EBDA size=%04x)\n", 748 ahci_seg, sizeof(ahci_t), (uint16_t)&EbdaData->bdisk.ahci_seg, sizeof(ebda_data_t)); 748 749 749 750 write_word(ebda_seg, (uint16_t)&EbdaData->bdisk.ahci_seg, ahci_seg); … … 762 763 cPorts = ahci_ctrl_extract_bits(val, 0x1f, 0) + 1; /* Extract number of ports.*/ 763 764 764 VBOXAHCI_DEBUG("AHCI: HBA has %u ports\n", cPorts);765 DBG_AHCI("AHCI: HBA has %u ports\n", cPorts); 765 766 766 767 /* Go through the ports. */ … … 770 771 if (ahci_ctrl_is_bit_set(io_base, AHCI_REG_PI, RT_BIT_32(i)) != 0) 771 772 { 772 VBOXAHCI_DEBUG("AHCI: Port %u is present\n", i);773 DBG_AHCI("AHCI: Port %u is present\n", i); 773 774 ahci_port_detect_device(ahci_seg :> 0, i); 774 775 cPorts--; … … 798 799 u8DevFn = busdevfn & 0x00ff; 799 800 800 VBOXAHCI_DEBUG("AHCI HBA at Bus %u DevFn 0x%x (raw 0x%x)\n", u8Bus, u8DevFn, busdevfn);801 DBG_AHCI("AHCI HBA at Bus %u DevFn 0x%x (raw 0x%x)\n", u8Bus, u8DevFn, busdevfn); 801 802 802 803 /* Examine the capability list and search for the Serial ATA Capability Register. */ … … 807 808 uint8_t u8PciCapId = pci_read_config_byte(u8Bus, u8DevFn, u8PciCapOff); 808 809 809 VBOXAHCI_DEBUG("Capability ID 0x%x at 0x%x\n", u8PciCapId, u8PciCapOff);810 DBG_AHCI("Capability ID 0x%x at 0x%x\n", u8PciCapId, u8PciCapOff); 810 811 811 812 if (u8PciCapId == PCI_CAP_ID_SATACR) … … 820 821 uint8_t u8Rev; 821 822 822 VBOXAHCI_DEBUG("AHCI HBA with SATA Capability register at 0x%x\n", u8PciCapOff);823 DBG_AHCI("AHCI HBA with SATA Capability register at 0x%x\n", u8PciCapOff); 823 824 824 825 /* Advance to the stuff behind the id and next capability pointer. */ … … 833 834 uint16_t u16BarOff = pci_read_config_word(u8Bus, u8DevFn, u8PciCapOff + 2); 834 835 835 VBOXAHCI_DEBUG("SATACR1: 0x%x\n", u16BarOff);836 DBG_AHCI("SATACR1: 0x%x\n", u16BarOff); 836 837 837 838 switch (u16BarOff & 0xf) … … 858 859 default: 859 860 /* Reserved or unsupported. */ 860 VBOXAHCI_DEBUG("BAR 0x%x unsupported\n", u16BarOff & 0xf);861 DBG_AHCI("BAR 0x%x unsupported\n", u16BarOff & 0xf); 861 862 } 862 863 … … 868 869 uint32_t u32Bar = pci_read_config_dword(u8Bus, u8DevFn, u8Bar); 869 870 870 VBOXAHCI_DEBUG("BAR at 0x%x : 0x%x\n", u8Bar, u32Bar);871 DBG_AHCI("BAR at 0x%x : 0x%x\n", u8Bar, u32Bar); 871 872 872 873 if ((u32Bar & 0x01) != 0) … … 875 876 uint16_t u16AhciIoBase = (u32Bar & 0xfff0) + u16Off; 876 877 877 VBOXAHCI_DEBUG("I/O base: 0x%x\n", u16AhciIoBase);878 DBG_AHCI("I/O base: 0x%x\n", u16AhciIoBase); 878 879 rc = ahci_hba_init(u16AhciIoBase); 879 880 } 880 881 else 881 VBOXAHCI_DEBUG("BAR is MMIO\n");882 DBG_AHCI("BAR is MMIO\n"); 882 883 } 883 884 } 884 885 else 885 VBOXAHCI_DEBUG("Invalid revision 0x%x\n", u8Rev);886 DBG_AHCI("Invalid revision 0x%x\n", u8Rev); 886 887 } 887 888 else 888 VBOXAHCI_DEBUG("AHCI HBA with no usable Index/Data register pair!\n");889 DBG_AHCI("AHCI HBA with no usable Index/Data register pair!\n"); 889 890 } 890 891 else 891 VBOXAHCI_DEBUG("No AHCI HBA!\n");892 } 892 DBG_AHCI("No AHCI HBA!\n"); 893 } -
trunk/src/VBox/Devices/PC/BIOS-new/biosint.h
r39366 r39583 52 52 53 53 #define DEBUG_ATA 0 54 #define DEBUG_AHCI 0 55 #define DEBUG_CD_BOOT 0 54 56 #define DEBUG_ELTORITO 0 55 57 #define DEBUG_INT13_HD 0 -
trunk/src/VBox/Devices/PC/BIOS-new/eltorito.c
r39575 r39583 59 59 #endif 60 60 61 //@todo: call this something else? ET_BOOT? 62 #if DEBUG_ELTORITO 61 #if DEBUG_CD_BOOT 63 62 # define BX_DEBUG_ELTORITO(...) BX_DEBUG(__VA_ARGS__) 64 63 #else … … 234 233 { 235 234 // @TODO: a macro or a function for getting the EBDA segment 236 uint16_t ebda_seg=read_word(0x0040,0x000E); 237 uint8_t buffer[2048]; 238 cdb_atapi atapicmd; 239 uint32_t lba; 240 uint16_t boot_segment, nbsectors, i, error; 241 uint8_t device; 242 uint8_t read_try; 243 cdemu_t __far *cdemu; 244 245 cdemu = ebda_seg :> &EbdaData->cdemu; 235 uint16_t ebda_seg=read_word(0x0040,0x000E); 236 uint8_t buffer[2048]; 237 cdb_atapi atapicmd; 238 uint32_t lba; 239 uint16_t boot_segment, nbsectors, i, error; 240 uint8_t device; 241 uint8_t read_try; 242 cdemu_t __far *cdemu; 243 bio_dsk_t __far *bios_dsk; 244 245 cdemu = ebda_seg :> &EbdaData->cdemu; 246 bios_dsk = ebda_seg :> &EbdaData->bdisk; 246 247 247 248 /* Find the first CD-ROM. */ … … 259 260 atapicmd.command = 0x28; // READ 10 command 260 261 atapicmd.lba = swap_32(0x11); 261 atapicmd.nsect = swap_16(0x01); 262 atapicmd.nsect = swap_16(1); 263 264 bios_dsk->drqp.nsect = 1; 265 bios_dsk->drqp.sect_sz = 2048; 262 266 263 267 for (read_try = 0; read_try <= 4; ++read_try) … … 286 290 return 6; 287 291 288 //@todo: this swaps the LBA back and forth for no good reason??!289 292 // ok, now we calculate the Boot catalog address 290 293 lba = *((uint32_t *)&buffer[0x47]); … … 292 295 293 296 /* Now we read the Boot Catalog. */ 294 _fmemset(&atapicmd, 0, sizeof(atapicmd)); //@todo: should be redundant295 297 atapicmd.command = 0x28; // READ 10 command 296 298 atapicmd.lba = swap_32(lba); 297 atapicmd.nsect = swap_16(0x01); 299 atapicmd.nsect = swap_16(1); 300 301 #if 0 // Not necessary as long as previous values are reused 302 bios_dsk->drqp.nsect = 1; 303 bios_dsk->drqp.sect_sz = 512; 304 #endif 298 305 299 306 if (device > BX_MAX_ATA_DEVICES) … … 352 359 353 360 /* Read the disk image's boot sector into memory. */ 354 _fmemset(&atapicmd, 0, sizeof(atapicmd)); //@todo: should be redundant355 361 atapicmd.command = 0x28; // READ 10 command 356 362 atapicmd.lba = swap_32(lba); 357 363 atapicmd.nsect = swap_16(1 + (nbsectors - 1) / 4); 364 365 bios_dsk->drqp.nsect = 1 + (nbsectors - 1) / 4; 366 bios_dsk->drqp.sect_sz = 512; 358 367 359 368 if (device > BX_MAX_ATA_DEVICES) … … 419 428 { 420 429 // @TODO: a macro or a function for getting the EBDA segment 421 uint16_t ebda_seg=read_word(0x0040,0x000E); 422 uint8_t device, status; 423 uint16_t vheads, vspt, vcylinders; 424 uint16_t head, sector, cylinder, nbsectors; 425 uint32_t vlba, ilba, slba, elba; 426 uint16_t before, segment, offset; 427 cdb_atapi atapicmd; 428 cdemu_t __far *cdemu; 429 430 cdemu = ebda_seg :> &EbdaData->cdemu; 430 uint16_t ebda_seg=read_word(0x0040,0x000E); 431 uint8_t device, status; 432 uint16_t vheads, vspt, vcylinders; 433 uint16_t head, sector, cylinder, nbsectors; 434 uint32_t vlba, ilba, slba, elba; 435 uint16_t before, segment, offset; 436 cdb_atapi atapicmd; 437 cdemu_t __far *cdemu; 438 bio_dsk_t __far *bios_dsk; 439 440 cdemu = ebda_seg :> &EbdaData->cdemu; 441 bios_dsk = ebda_seg :> &EbdaData->bdisk; 431 442 432 443 BX_DEBUG_INT13_ET("%s: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", __func__, AX, BX, CX, DX, ES); … … 528 539 atapicmd.lba = swap_32(ilba + slba); 529 540 atapicmd.nsect = swap_16(elba - slba + 1); 541 542 bios_dsk->drqp.nsect = elba - slba + 1; 543 bios_dsk->drqp.sect_sz = 512; 530 544 531 545 if (device > BX_MAX_ATA_DEVICES) … … 726 740 atapicmd.lba = swap_32(lba); 727 741 atapicmd.nsect = swap_16(count); 742 743 bios_dsk->drqp.nsect = count; 744 bios_dsk->drqp.sect_sz = 2048; 728 745 729 746 if (device > BX_MAX_ATA_DEVICES)
Note:
See TracChangeset
for help on using the changeset viewer.