Changeset 32734 in vbox
- Timestamp:
- Sep 23, 2010 3:57:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pci.h
r32722 r32734 198 198 #define VBOX_PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ 199 199 200 201 /* Command bitmask */ 202 #define VBOX_PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ 203 #define VBOX_PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ 204 #define VBOX_PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ 205 #define VBOX_PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ 206 #define VBOX_PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ 207 #define VBOX_PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ 208 #define VBOX_PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ 209 #define VBOX_PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ 210 #define VBOX_PCI_COMMAND_SERR 0x100 /* Enable SERR */ 211 #define VBOX_PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ 212 #define VBOX_PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ 213 214 200 215 /* Capability list values (capability offset 0) */ 201 216 /* Next value pointer in offset 1, or 0 if none */ … … 218 233 #define VBOX_PCI_CAP_ID_AF 0x13 /* PCI Advanced Features */ 219 234 220 /* MSI flags (capability offset 2) */ 235 /* Extended Capabilities (PCI-X 2.0 and Express)*/ 236 #define VBOX_PCI_EXT_CAP_ID_ERR 0x01 237 #define VBOX_PCI_EXT_CAP_ID_VC 0x02 238 #define VBOX_PCI_EXT_CAP_ID_DSN 0x03 239 #define VBOX_PCI_EXT_CAP_ID_PWR 0x04 240 #define VBOX_PCI_EXT_CAP_ID_ARI 0x0e 241 #define VBOX_PCI_EXT_CAP_ID_ATS 0x0f 242 #define VBOX_PCI_EXT_CAP_ID_SRIOV 0x10 243 244 245 /* MSI flags (2 bytes, capability offset 2) */ 221 246 #define VBOX_PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ 222 247 #define VBOX_PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ … … 225 250 #define VBOX_PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */ 226 251 227 /* MSI-X flags (capability offset 2) */ 228 #define VBOX_PCI_MSIX_FLAGS_QSIZE 0x07FF 252 /* MSI-X flags (2 bytes, capability offset 2) */ 229 253 #define VBOX_PCI_MSIX_FLAGS_ENABLE 0x8000 230 #define PCI_MSIX_FLAGS_MASKALL 0x4000231 #define PCI_MSIX_FLAGS_BIRMASK 0x0007254 #define VBOX_PCI_MSIX_FLAGS_MASKALL 0x4000 255 #define VBOX_PCI_MSIX_FLAGS_BIRMASK 0x0007 232 256 233 257 /* Power management flags (2 bytes, capability offset 2) */ … … 351 375 } PCIDEVICE; 352 376 377 /* @todo: handle extended space access */ 378 DECLINLINE(void) PCIDevSetByte(PPCIDEVICE pPciDev, uint32_t uOffset, uint8_t u8Value) 379 { 380 pPciDev->config[uOffset] = u8Value; 381 } 382 383 DECLINLINE(uint8_t) PCIDevGetByte(PPCIDEVICE pPciDev, uint32_t uOffset) 384 { 385 return pPciDev->config[uOffset]; 386 } 387 388 DECLINLINE(void) PCIDevSetWord(PPCIDEVICE pPciDev, uint32_t uOffset, uint16_t u16Value) 389 { 390 *(uint16_t*)&pPciDev->config[uOffset] = RT_H2LE_U16(u16Value); 391 } 392 393 DECLINLINE(uint16_t) PCIDevGetWord(PPCIDEVICE pPciDev, uint32_t uOffset) 394 { 395 uint16_t u16Value = *(uint16_t*)&pPciDev->config[uOffset]; 396 return RT_H2LE_U16(u16Value); 397 } 398 399 DECLINLINE(void) PCIDevSetDWord(PPCIDEVICE pPciDev, uint32_t uOffset, uint32_t u32Value) 400 { 401 *(uint32_t*)&pPciDev->config[uOffset] = RT_H2LE_U32(u32Value); 402 } 403 404 DECLINLINE(uint32_t) PCIDevGetDWord(PPCIDEVICE pPciDev, uint32_t uOffset) 405 { 406 uint32_t u32Value = *(uint32_t*)&pPciDev->config[uOffset]; 407 return RT_H2LE_U32(u32Value); 408 } 409 410 DECLINLINE(void) PCIDevSetQWord(PPCIDEVICE pPciDev, uint32_t uOffset, uint64_t u64Value) 411 { 412 *(uint64_t*)&pPciDev->config[uOffset] = RT_H2LE_U64(u64Value); 413 } 414 415 DECLINLINE(uint64_t) PCIDevGetQWord(PPCIDEVICE pPciDev, uint32_t uOffset) 416 { 417 uint64_t u64Value = *(uint64_t*)&pPciDev->config[uOffset]; 418 return RT_H2LE_U64(u64Value); 419 } 353 420 354 421 /** … … 359 426 DECLINLINE(void) PCIDevSetVendorId(PPCIDEVICE pPciDev, uint16_t u16VendorId) 360 427 { 361 u16VendorId = RT_H2LE_U16(u16VendorId); 362 pPciDev->config[VBOX_PCI_VENDOR_ID] = u16VendorId & 0xff; 363 pPciDev->config[VBOX_PCI_VENDOR_ID + 1] = u16VendorId >> 8; 428 PCIDevSetWord(pPciDev, VBOX_PCI_VENDOR_ID, u16VendorId); 364 429 } 365 430 … … 371 436 DECLINLINE(uint16_t) PCIDevGetVendorId(PPCIDEVICE pPciDev) 372 437 { 373 return RT_LE2H_U16(RT_MAKE_U16(pPciDev->config[VBOX_PCI_VENDOR_ID], pPciDev->config[VBOX_PCI_VENDOR_ID + 1]));438 return PCIDevGetWord(pPciDev, VBOX_PCI_VENDOR_ID); 374 439 } 375 440 … … 382 447 DECLINLINE(void) PCIDevSetDeviceId(PPCIDEVICE pPciDev, uint16_t u16DeviceId) 383 448 { 384 u16DeviceId = RT_H2LE_U16(u16DeviceId); 385 pPciDev->config[VBOX_PCI_DEVICE_ID] = u16DeviceId & 0xff; 386 pPciDev->config[VBOX_PCI_DEVICE_ID + 1] = u16DeviceId >> 8; 449 PCIDevSetWord(pPciDev, VBOX_PCI_DEVICE_ID, u16DeviceId); 387 450 } 388 451 … … 394 457 DECLINLINE(uint16_t) PCIDevGetDeviceId(PPCIDEVICE pPciDev) 395 458 { 396 return RT_LE2H_U16(RT_MAKE_U16(pPciDev->config[VBOX_PCI_DEVICE_ID], pPciDev->config[VBOX_PCI_DEVICE_ID + 1])); 397 } 398 459 return PCIDevGetWord(pPciDev, VBOX_PCI_DEVICE_ID); 460 } 399 461 400 462 /** … … 406 468 DECLINLINE(void) PCIDevSetCommand(PPCIDEVICE pPciDev, uint16_t u16Command) 407 469 { 408 u16Command = RT_H2LE_U16(u16Command); 409 pPciDev->config[VBOX_PCI_COMMAND] = u16Command & 0xff; 410 pPciDev->config[VBOX_PCI_COMMAND + 1] = u16Command >> 8; 470 PCIDevSetWord(pPciDev, VBOX_PCI_COMMAND, u16Command); 411 471 } 412 472 … … 419 479 DECLINLINE(uint16_t) PCIDevGetCommand(PPCIDEVICE pPciDev) 420 480 { 421 return RT_LE2H_U16(RT_MAKE_U16(pPciDev->config[VBOX_PCI_COMMAND], pPciDev->config[VBOX_PCI_COMMAND + 1]));481 return PCIDevGetWord(pPciDev, VBOX_PCI_COMMAND); 422 482 } 423 483 … … 431 491 DECLINLINE(void) PCIDevSetStatus(PPCIDEVICE pPciDev, uint16_t u16Status) 432 492 { 433 u16Status = RT_H2LE_U16(u16Status); 434 pPciDev->config[VBOX_PCI_STATUS] = u16Status & 0xff; 435 pPciDev->config[VBOX_PCI_STATUS + 1] = u16Status >> 8; 493 PCIDevSetWord(pPciDev, VBOX_PCI_STATUS, u16Status); 436 494 } 437 495 … … 445 503 DECLINLINE(void) PCIDevSetRevisionId(PPCIDEVICE pPciDev, uint8_t u8RevisionId) 446 504 { 447 pPciDev->config[VBOX_PCI_REVISION_ID] = u8RevisionId;505 PCIDevSetByte(pPciDev, VBOX_PCI_REVISION_ID, u8RevisionId); 448 506 } 449 507 … … 457 515 DECLINLINE(void) PCIDevSetClassProg(PPCIDEVICE pPciDev, uint8_t u8ClassProg) 458 516 { 459 pPciDev->config[VBOX_PCI_CLASS_PROG] = u8ClassProg;517 PCIDevSetByte(pPciDev, VBOX_PCI_CLASS_PROG, u8ClassProg); 460 518 } 461 519 … … 469 527 DECLINLINE(void) PCIDevSetClassSub(PPCIDEVICE pPciDev, uint8_t u8SubClass) 470 528 { 471 pPciDev->config[VBOX_PCI_CLASS_SUB] = u8SubClass;529 PCIDevSetByte(pPciDev, VBOX_PCI_CLASS_SUB, u8SubClass); 472 530 } 473 531 … … 481 539 DECLINLINE(void) PCIDevSetClassBase(PPCIDEVICE pPciDev, uint8_t u8BaseClass) 482 540 { 483 pPciDev->config[VBOX_PCI_CLASS_BASE] = u8BaseClass;541 PCIDevSetByte(pPciDev, VBOX_PCI_CLASS_BASE, u8BaseClass); 484 542 } 485 543 … … 492 550 DECLINLINE(void) PCIDevSetHeaderType(PPCIDEVICE pPciDev, uint8_t u8HdrType) 493 551 { 494 pPciDev->config[VBOX_PCI_HEADER_TYPE] = u8HdrType;552 PCIDevSetByte(pPciDev, VBOX_PCI_HEADER_TYPE, u8HdrType); 495 553 } 496 554 … … 503 561 DECLINLINE(uint8_t) PCIDevGetHeaderType(PPCIDEVICE pPciDev) 504 562 { 505 return pPciDev->config[VBOX_PCI_HEADER_TYPE];563 return PCIDevGetByte(pPciDev, VBOX_PCI_HEADER_TYPE); 506 564 } 507 565 … … 514 572 DECLINLINE(void) PCIDevSetBIST(PPCIDEVICE pPciDev, uint8_t u8Bist) 515 573 { 516 pPciDev->config[VBOX_PCI_BIST] = u8Bist;574 PCIDevSetByte(pPciDev, VBOX_PCI_BIST, u8Bist); 517 575 } 518 576 … … 525 583 DECLINLINE(uint8_t) PCIDevGetBIST(PPCIDEVICE pPciDev) 526 584 { 527 return pPciDev->config[VBOX_PCI_BIST];585 return PCIDevGetByte(pPciDev, VBOX_PCI_BIST); 528 586 } 529 587 … … 564 622 } 565 623 566 u32Addr = RT_H2LE_U32(u32Addr); 567 pPciDev->config[iReg] = u32Addr & 0xff; 568 pPciDev->config[iReg + 1] = (u32Addr >> 8) & 0xff; 569 pPciDev->config[iReg + 2] = (u32Addr >> 16) & 0xff; 570 pPciDev->config[iReg + 3] = (u32Addr >> 24) & 0xff; 624 PCIDevSetDWord(pPciDev, iReg, u32Addr); 571 625 } 572 626 … … 580 634 DECLINLINE(void) PCIDevSetSubSystemVendorId(PPCIDEVICE pPciDev, uint16_t u16SubSysVendorId) 581 635 { 582 u16SubSysVendorId = RT_H2LE_U16(u16SubSysVendorId); 583 pPciDev->config[VBOX_PCI_SUBSYSTEM_VENDOR_ID] = u16SubSysVendorId & 0xff; 584 pPciDev->config[VBOX_PCI_SUBSYSTEM_VENDOR_ID + 1] = u16SubSysVendorId >> 8; 636 PCIDevSetWord(pPciDev, VBOX_PCI_SUBSYSTEM_VENDOR_ID, u16SubSysVendorId); 585 637 } 586 638 … … 592 644 DECLINLINE(uint16_t) PCIDevGetSubSystemVendorId(PPCIDEVICE pPciDev) 593 645 { 594 return RT_LE2H_U16(RT_MAKE_U16(pPciDev->config[VBOX_PCI_SUBSYSTEM_VENDOR_ID], pPciDev->config[VBOX_PCI_SUBSYSTEM_VENDOR_ID + 1]));646 return PCIDevGetWord(pPciDev, VBOX_PCI_SUBSYSTEM_VENDOR_ID); 595 647 } 596 648 … … 604 656 DECLINLINE(void) PCIDevSetSubSystemId(PPCIDEVICE pPciDev, uint16_t u16SubSystemId) 605 657 { 606 u16SubSystemId = RT_H2LE_U16(u16SubSystemId); 607 pPciDev->config[VBOX_PCI_SUBSYSTEM_ID] = u16SubSystemId & 0xff; 608 pPciDev->config[VBOX_PCI_SUBSYSTEM_ID + 1] = u16SubSystemId >> 8; 658 PCIDevSetWord(pPciDev, VBOX_PCI_SUBSYSTEM_ID, u16SubSystemId); 609 659 } 610 660 … … 616 666 DECLINLINE(uint16_t) PCIDevGetSubSystemId(PPCIDEVICE pPciDev) 617 667 { 618 return RT_LE2H_U16(RT_MAKE_U16(pPciDev->config[VBOX_PCI_SUBSYSTEM_ID], pPciDev->config[VBOX_PCI_SUBSYSTEM_ID + 1]));668 return PCIDevGetWord(pPciDev, VBOX_PCI_SUBSYSTEM_ID); 619 669 } 620 670 … … 627 677 DECLINLINE(void) PCIDevSetCapabilityList(PPCIDEVICE pPciDev, uint8_t u8Offset) 628 678 { 629 pPciDev->config[VBOX_PCI_CAPABILITY_LIST] = u8Offset;679 PCIDevSetByte(pPciDev, VBOX_PCI_CAPABILITY_LIST, u8Offset); 630 680 } 631 681 … … 638 688 DECLINLINE(uint8_t) PCIDevGetCapabilityList(PPCIDEVICE pPciDev) 639 689 { 640 return pPciDev->config[VBOX_PCI_CAPABILITY_LIST];690 return PCIDevGetByte(pPciDev, VBOX_PCI_CAPABILITY_LIST); 641 691 } 642 692 … … 649 699 DECLINLINE(void) PCIDevSetInterruptLine(PPCIDEVICE pPciDev, uint8_t u8Line) 650 700 { 651 pPciDev->config[VBOX_PCI_INTERRUPT_LINE] = u8Line;701 PCIDevSetByte(pPciDev, VBOX_PCI_INTERRUPT_LINE, u8Line); 652 702 } 653 703 … … 660 710 DECLINLINE(uint8_t) PCIDevGetInterruptLine(PPCIDEVICE pPciDev) 661 711 { 662 return pPciDev->config[VBOX_PCI_INTERRUPT_LINE];712 return PCIDevGetByte(pPciDev, VBOX_PCI_INTERRUPT_LINE); 663 713 } 664 714 … … 671 721 DECLINLINE(void) PCIDevSetInterruptPin(PPCIDEVICE pPciDev, uint8_t u8Pin) 672 722 { 673 pPciDev->config[VBOX_PCI_INTERRUPT_PIN] = u8Pin;723 PCIDevSetByte(pPciDev, VBOX_PCI_INTERRUPT_PIN, u8Pin); 674 724 } 675 725 … … 683 733 DECLINLINE(uint8_t) PCIDevGetInterruptPin(PPCIDEVICE pPciDev) 684 734 { 685 return pPciDev->config[VBOX_PCI_INTERRUPT_PIN];735 return PCIDevGetByte(pPciDev, VBOX_PCI_INTERRUPT_PIN); 686 736 } 687 737 … … 690 740 691 741 #endif 692
Note:
See TracChangeset
for help on using the changeset viewer.