Changeset 80647 in vbox
- Timestamp:
- Sep 6, 2019 9:20:04 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r80639 r80647 131 131 132 132 #define SCSI_CONFIG_ACCESSOR(member) \ 133 do \ 133 134 { \ 134 135 uint32_t uIntraOffset = uOffset - RT_UOFFSETOF(VIRTIOSCSI_CONFIG_T, member); \ … … 138 139 memcpy((char *)pv, (const char *)(((char *)&pThis->virtioScsiConfig.member) + uIntraOffset), cb); \ 139 140 LOG_ACCESSOR(member); \ 140 } 141 } while(0) 141 142 142 143 #define SCSI_CONFIG_ACCESSOR_READONLY(member) \ 144 do \ 143 145 { \ 144 146 uint32_t uIntraOffset = uOffset - RT_UOFFSETOF(VIRTIOSCSI_CONFIG_T, member); \ … … 150 152 LOG_ACCESSOR(member); \ 151 153 } \ 152 } 154 } while(0) 153 155 154 156 #define VIRTIO_IN_DIRECTION(pMediaExTxDirEnumValue) \ … … 1450 1452 int rc = VINF_SUCCESS; 1451 1453 if (MATCH_SCSI_CONFIG(uNumQueues)) 1452 {1453 1454 SCSI_CONFIG_ACCESSOR_READONLY(uNumQueues); 1454 }1455 1455 else 1456 1456 if (MATCH_SCSI_CONFIG(uSegMax)) 1457 {1458 1457 SCSI_CONFIG_ACCESSOR_READONLY(uSegMax); 1459 }1460 1458 else 1461 1459 if (MATCH_SCSI_CONFIG(uMaxSectors)) 1462 {1463 1460 SCSI_CONFIG_ACCESSOR_READONLY(uMaxSectors); 1464 }1465 1461 else 1466 1462 if (MATCH_SCSI_CONFIG(uCmdPerLun)) 1467 {1468 1463 SCSI_CONFIG_ACCESSOR_READONLY(uCmdPerLun); 1469 }1470 1464 else 1471 1465 if (MATCH_SCSI_CONFIG(uEventInfoSize)) 1472 {1473 1466 SCSI_CONFIG_ACCESSOR_READONLY(uEventInfoSize); 1474 }1475 1467 else 1476 1468 if (MATCH_SCSI_CONFIG(uSenseSize)) 1477 {1478 1469 SCSI_CONFIG_ACCESSOR(uSenseSize); 1479 }1480 1470 else 1481 1471 if (MATCH_SCSI_CONFIG(uCdbSize)) 1482 {1483 1472 SCSI_CONFIG_ACCESSOR(uCdbSize); 1484 }1485 1473 else 1486 1474 if (MATCH_SCSI_CONFIG(uMaxChannel)) 1487 {1488 1475 SCSI_CONFIG_ACCESSOR_READONLY(uMaxChannel); 1489 }1490 1476 else 1491 1477 if (MATCH_SCSI_CONFIG(uMaxTarget)) 1492 {1493 1478 SCSI_CONFIG_ACCESSOR_READONLY(uMaxTarget); 1494 }1495 1479 else 1496 1480 if (MATCH_SCSI_CONFIG(uMaxLun)) 1497 {1498 1481 SCSI_CONFIG_ACCESSOR_READONLY(uMaxLun); 1499 }1500 1482 else 1501 1483 { … … 2110 2092 PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI); 2111 2093 2112 for (int qIdx = 0; qIdx < VIRT Q_MAX_CNT; qIdx++)2094 for (int qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++) 2113 2095 { 2114 2096 PWORKER pWorker = &pThis->aWorker[qIdx]; -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r80639 r80647 36 36 #define QUEUENAME(qIdx) (pVirtio->virtqProxy[qIdx].szVirtqName) 37 37 38 /**39 * Formats the logging of a memory-mapped I/O input or output value40 *41 * @param pszFunc - To avoid displaying this function's name via __FUNCTION__ or Log2Func()42 * @param pszMember - Name of struct member43 * @param pv - Pointer to value44 * @param cb - Size of value45 * @param uOffset - Offset into member where value starts46 * @param fWrite - True if write I/O47 * @param fHasIndex - True if the member is indexed48 * @param idx - The index, if fHasIndex is true49 */50 void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, size_t uMemberSize,51 const void *pv, uint32_t cb, uint32_t uOffset, bool fWrite,52 bool fHasIndex, uint32_t idx)53 {54 55 #define FMTHEX(fmtout, val, cNybbles) \56 fmtout[cNybbles] = '\0'; \57 for (uint8_t i = 0; i < cNybbles; i++) \58 fmtout[(cNybbles - i) - 1] = "0123456789abcdef"[(val >> (i * 4)) & 0xf];59 60 #define MAX_STRING 6461 char pszIdx[MAX_STRING] = { 0 };62 char pszDepiction[MAX_STRING] = { 0 };63 char pszFormattedVal[MAX_STRING] = { 0 };64 if (fHasIndex)65 RTStrPrintf(pszIdx, sizeof(pszIdx), "[%d]", idx);66 if (cb == 1 || cb == 2 || cb == 4 || cb == 8)67 {68 /* manually padding with 0's instead of \b due to different impl of %x precision than printf() */69 uint64_t val = 0;70 memcpy((char *)&val, pv, cb);71 FMTHEX(pszFormattedVal, val, cb * 2);72 if (uOffset != 0 || cb != uMemberSize) /* display bounds if partial member access */73 RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s[%d:%d]",74 pszMember, pszIdx, uOffset, uOffset + cb - 1);75 else76 RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s", pszMember, pszIdx);77 RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%-30s", pszDepiction);78 uint32_t first = 0;79 for (uint8_t i = 0; i < sizeof(pszDepiction); i++)80 if (pszDepiction[i] == ' ' && first++)81 pszDepiction[i] = '.';82 Log6Func(("%s: Guest %s %s 0x%s\n",83 pszFunc, fWrite ? "wrote" : "read ", pszDepiction, pszFormattedVal));84 }85 else /* odd number or oversized access, ... log inline hex-dump style */86 {87 Log6Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n",88 pszFunc, fWrite ? "wrote" : "read ", pszMember,89 pszIdx, uOffset, uOffset + cb, cb, pv));90 }91 }92 38 93 39 /** … … 664 610 } 665 611 } 666 else if (MATCH_COMMON_CFG(uMsixConfig))667 {612 else 613 if (MATCH_COMMON_CFG(uMsixConfig)) 668 614 COMMON_CFG_ACCESSOR(uMsixConfig); 669 } 670 else if (MATCH_COMMON_CFG(uDeviceFeaturesSelect)) 671 { 615 else 616 if (MATCH_COMMON_CFG(uDeviceFeaturesSelect)) 672 617 COMMON_CFG_ACCESSOR(uDeviceFeaturesSelect); 673 } 674 else if (MATCH_COMMON_CFG(uDriverFeaturesSelect)) 675 { 618 else 619 if (MATCH_COMMON_CFG(uDriverFeaturesSelect)) 676 620 COMMON_CFG_ACCESSOR(uDriverFeaturesSelect); 677 } 678 else if (MATCH_COMMON_CFG(uConfigGeneration)) 679 { 621 else 622 if (MATCH_COMMON_CFG(uConfigGeneration)) 680 623 COMMON_CFG_ACCESSOR_READONLY(uConfigGeneration); 681 } 682 else if (MATCH_COMMON_CFG(uQueueSelect)) 683 { 624 else 625 if (MATCH_COMMON_CFG(uQueueSelect)) 684 626 COMMON_CFG_ACCESSOR(uQueueSelect); 685 } 686 else if (MATCH_COMMON_CFG(uQueueSize)) 687 { 627 else 628 if (MATCH_COMMON_CFG(uQueueSize)) 688 629 COMMON_CFG_ACCESSOR_INDEXED(uQueueSize, pVirtio->uQueueSelect); 689 } 690 else if (MATCH_COMMON_CFG(uQueueMsixVector)) 691 { 630 else 631 if (MATCH_COMMON_CFG(uQueueMsixVector)) 692 632 COMMON_CFG_ACCESSOR_INDEXED(uQueueMsixVector, pVirtio->uQueueSelect); 693 } 694 else if (MATCH_COMMON_CFG(uQueueEnable)) 695 { 633 else 634 if (MATCH_COMMON_CFG(uQueueEnable)) 696 635 COMMON_CFG_ACCESSOR_INDEXED(uQueueEnable, pVirtio->uQueueSelect); 697 } 698 else if (MATCH_COMMON_CFG(uQueueNotifyOff)) 699 { 636 else 637 if (MATCH_COMMON_CFG(uQueueNotifyOff)) 700 638 COMMON_CFG_ACCESSOR_INDEXED_READONLY(uQueueNotifyOff, pVirtio->uQueueSelect); 701 } 702 else if (MATCH_COMMON_CFG(pGcPhysQueueDesc)) 703 { 639 else 640 if (MATCH_COMMON_CFG(pGcPhysQueueDesc)) 704 641 COMMON_CFG_ACCESSOR_INDEXED(pGcPhysQueueDesc, pVirtio->uQueueSelect); 705 } 706 else if (MATCH_COMMON_CFG(pGcPhysQueueAvail)) 707 { 642 else 643 if (MATCH_COMMON_CFG(pGcPhysQueueAvail)) 708 644 COMMON_CFG_ACCESSOR_INDEXED(pGcPhysQueueAvail, pVirtio->uQueueSelect); 709 } 710 else if (MATCH_COMMON_CFG(pGcPhysQueueUsed)) 711 { 645 else 646 if (MATCH_COMMON_CFG(pGcPhysQueueUsed)) 712 647 COMMON_CFG_ACCESSOR_INDEXED(pGcPhysQueueUsed, pVirtio->uQueueSelect); 713 }714 648 else 715 649 { … … 1458 1392 1459 1393 return rc; 1460 1461 1394 } 1462 1395 … … 1492 1425 } 1493 1426 1427 1428 /** 1429 * Formats the logging of a memory-mapped I/O input or output value 1430 * 1431 * @param pszFunc - To avoid displaying this function's name via __FUNCTION__ or Log2Func() 1432 * @param pszMember - Name of struct member 1433 * @param pv - Pointer to value 1434 * @param cb - Size of value 1435 * @param uOffset - Offset into member where value starts 1436 * @param fWrite - True if write I/O 1437 * @param fHasIndex - True if the member is indexed 1438 * @param idx - The index, if fHasIndex is true 1439 */ 1440 void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, size_t uMemberSize, 1441 const void *pv, uint32_t cb, uint32_t uOffset, bool fWrite, 1442 bool fHasIndex, uint32_t idx) 1443 { 1444 1445 #define FMTHEX(fmtout, val, cNybbles) \ 1446 fmtout[cNybbles] = '\0'; \ 1447 for (uint8_t i = 0; i < cNybbles; i++) \ 1448 fmtout[(cNybbles - i) - 1] = "0123456789abcdef"[(val >> (i * 4)) & 0xf]; 1449 1450 #define MAX_STRING 64 1451 char pszIdx[MAX_STRING] = { 0 }; 1452 char pszDepiction[MAX_STRING] = { 0 }; 1453 char pszFormattedVal[MAX_STRING] = { 0 }; 1454 if (fHasIndex) 1455 RTStrPrintf(pszIdx, sizeof(pszIdx), "[%d]", idx); 1456 if (cb == 1 || cb == 2 || cb == 4 || cb == 8) 1457 { 1458 /* manually padding with 0's instead of \b due to different impl of %x precision than printf() */ 1459 uint64_t val = 0; 1460 memcpy((char *)&val, pv, cb); 1461 FMTHEX(pszFormattedVal, val, cb * 2); 1462 if (uOffset != 0 || cb != uMemberSize) /* display bounds if partial member access */ 1463 RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s[%d:%d]", 1464 pszMember, pszIdx, uOffset, uOffset + cb - 1); 1465 else 1466 RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%s%s", pszMember, pszIdx); 1467 RTStrPrintf(pszDepiction, sizeof(pszDepiction), "%-30s", pszDepiction); 1468 uint32_t first = 0; 1469 for (uint8_t i = 0; i < sizeof(pszDepiction); i++) 1470 if (pszDepiction[i] == ' ' && first++) 1471 pszDepiction[i] = '.'; 1472 Log6Func(("%s: Guest %s %s 0x%s\n", 1473 pszFunc, fWrite ? "wrote" : "read ", pszDepiction, pszFormattedVal)); 1474 } 1475 else /* odd number or oversized access, ... log inline hex-dump style */ 1476 { 1477 Log6Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n", 1478 pszFunc, fWrite ? "wrote" : "read ", pszMember, 1479 pszIdx, uOffset, uOffset + cb, cb, pv)); 1480 } 1481 } 1482 1494 1483 #endif /* IN_RING3 */ 1495 1484 -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h
r80596 r80647 300 300 301 301 #define COMMON_CFG_ACCESSOR(member) \ 302 do \ 302 303 { \ 303 304 uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \ … … 307 308 memcpy((char *)pv, (const char *)(((char *)&pVirtio->member) + uIntraOff), cb); \ 308 309 LOG_COMMON_CFG_ACCESS(member); \ 309 } 310 } while(0) 310 311 311 312 #define COMMON_CFG_ACCESSOR_INDEXED(member, idx) \ 313 do \ 312 314 { \ 313 315 uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \ … … 317 319 memcpy((char *)pv, (const char *)(((char *)(pVirtio->member + idx)) + uIntraOff), cb); \ 318 320 LOG_COMMON_CFG_ACCESS_INDEXED(member, idx); \ 319 } 321 } while(0) 320 322 321 323 #define COMMON_CFG_ACCESSOR_READONLY(member) \ 324 do \ 322 325 { \ 323 326 uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \ … … 329 332 LOG_COMMON_CFG_ACCESS(member); \ 330 333 } \ 331 } 334 } while(0) 332 335 333 336 #define COMMON_CFG_ACCESSOR_INDEXED_READONLY(member, idx) \ 337 do \ 334 338 { \ 335 339 uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \ … … 341 345 LOG_COMMON_CFG_ACCESS_INDEXED(member, idx); \ 342 346 } \ 343 } 347 } while(0) 344 348 345 349 #define DRIVER_OK(pVirtio) (pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK)
Note:
See TracChangeset
for help on using the changeset viewer.