Changeset 80596 in vbox for trunk/src/VBox/Devices/VirtIO
- Timestamp:
- Sep 5, 2019 7:12:46 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/VirtIO
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r80575 r80596 81 81 if (pszDepiction[i] == ' ' && first++) 82 82 pszDepiction[i] = '.'; 83 Log 3Func(("%s: Guest %s %s 0x%s\n",83 Log6Func(("%s: Guest %s %s 0x%s\n", 84 84 pszFunc, fWrite ? "wrote" : "read ", pszDepiction, pszFormattedVal)); 85 85 } 86 86 else /* odd number or oversized access, ... log inline hex-dump style */ 87 87 { 88 Log 3Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n",88 Log6Func(("%s: Guest %s %s%s[%d:%d]: %.*Rhxs\n", 89 89 pszFunc, fWrite ? "wrote" : "read ", pszMember, 90 90 pszIdx, uOffset, uOffset + cb, cb, pv)); … … 199 199 uint16_t uDescIdx = pDescChain->uHeadIdx; 200 200 201 Log 3Func(("%s DESC CHAIN: (head) desc_idx=%u [avail_idx=%u]\n",201 Log6Func(("%s DESC CHAIN: (head) desc_idx=%u [avail_idx=%u]\n", 202 202 pVirtqProxy->szVirtqName, pDescChain->uHeadIdx, pVirtqProxy->uAvailIdx)); 203 203 … … 238 238 if (desc.fFlags & VIRTQ_DESC_F_WRITE) 239 239 { 240 Log 3Func(("%s IN desc_idx=%u seg=%u addr=%RGp cb=%u\n",240 Log6Func(("%s IN desc_idx=%u seg=%u addr=%RGp cb=%u\n", 241 241 QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsIn, desc.pGcPhysBuf, desc.cb)); 242 242 cbIn += desc.cb; … … 245 245 else 246 246 { 247 Log 3Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n",247 Log6Func(("%s OUT desc_idx=%u seg=%u addr=%RGp cb=%u\n", 248 248 QUEUENAME(qIdx), uDescIdx, pDescChain->cSegsOut, desc.pGcPhysBuf, desc.cb)); 249 249 cbOut += desc.cb; … … 261 261 262 262 if (ppInSegs) 263 *ppInSegs 263 *ppInSegs = &pVirtqProxy->inSgBuf; 264 264 265 265 if (ppOutSegs) 266 266 *ppOutSegs = &pVirtqProxy->outSgBuf; 267 267 268 Log 3Func(("%s -- segs OUT: %u (%u bytes) IN: %u (%u bytes) --\n",268 Log6Func(("%s -- segs OUT: %u (%u bytes) IN: %u (%u bytes) --\n", 269 269 pVirtqProxy->szVirtqName, pDescChain->cSegsOut, cbOut, pDescChain->cSegsIn, cbIn)); 270 270 … … 292 292 size_t cbRemain = RTSgBufCalcTotalLength(pBufSrc); 293 293 uint16_t uUsedIdx = virtioReadUsedRingIdx(pVirtio, qIdx); 294 Log 3Func(("Copying client data to %s, desc chain (head desc_idx %d)\n",294 Log6Func(("Copying client data to %s, desc chain (head desc_idx %d)\n", 295 295 QUEUENAME(qIdx), uUsedIdx)); 296 296 … … 328 328 size_t cbInSgBuf = RTSgBufCalcTotalLength(pBufDst); 329 329 size_t cbWritten = cbInSgBuf - RTSgBufCalcLengthLeft(pBufDst); 330 Log2Func((" Copied %u bytes to %u byte buffer, residual=%d\n",330 Log2Func((".... Copied %u bytes to %u byte buffer, residual=%d\n", 331 331 cbWritten, cbInSgBuf, cbInSgBuf - cbWritten)); 332 332 } 333 Log 3Func(("Write ahead used_idx=%d, %s used_idx=%d\n",333 Log6Func(("Write ahead used_idx=%d, %s used_idx=%d\n", 334 334 pVirtqProxy->uUsedIdx, QUEUENAME(qIdx), uUsedIdx)); 335 335 … … 351 351 352 352 uint16_t uIdx = virtioReadUsedRingIdx(pVirtio, qIdx); 353 Log 3Func(("Updating %s used_idx from %u to %u\n",353 Log6Func(("Updating %s used_idx from %u to %u\n", 354 354 QUEUENAME(qIdx), uIdx, pVirtqProxy->uUsedIdx)); 355 355 … … 368 368 369 369 PVIRTQ_PROXY_T pVirtqProxy = &pVirtio->virtqProxy[qIdx]; 370 Log 3Func(("%s\n", pVirtqProxy->szVirtqName));370 Log6Func(("%s\n", pVirtqProxy->szVirtqName)); 371 371 372 372 … … 398 398 return; 399 399 } 400 Log 3Func(("...skipping interrupt: VIRTIO_F_EVENT_IDX set but threshold not reached\n"));400 Log6Func(("...skipping interrupt: VIRTIO_F_EVENT_IDX set but threshold not reached\n")); 401 401 } 402 402 else … … 408 408 return; 409 409 } 410 Log 3Func(("...skipping interrupt. Guest flagged VIRTQ_AVAIL_F_NO_INTERRUPT for queue\n"));410 Log6Func(("...skipping interrupt. Guest flagged VIRTQ_AVAIL_F_NO_INTERRUPT for queue\n")); 411 411 412 412 } … … 456 456 { 457 457 if (uCause == VIRTIO_ISR_VIRTQ_INTERRUPT) 458 Log 3Func(("reason: buffer added to 'used' ring.\n"));458 Log6Func(("reason: buffer added to 'used' ring.\n")); 459 459 else 460 460 if (uCause == VIRTIO_ISR_DEVICE_CONFIG) 461 Log 3Func(("reason: device config change\n"));461 Log6Func(("reason: device config change\n")); 462 462 463 463 pVirtio->uISR |= uCause; … … 642 642 { 643 643 pVirtio->uDeviceStatus = *(uint8_t *)pv; 644 Log 3Func(("Guest wrote uDeviceStatus ................ ("));644 Log6Func(("Guest wrote uDeviceStatus ................ (")); 645 645 virtioLogDeviceStatus(pVirtio->uDeviceStatus); 646 Log 3((")\n"));646 Log6((")\n")); 647 647 if (pVirtio->uDeviceStatus == 0) 648 648 virtioGuestResetted(pVirtio); … … 659 659 else /* Guest READ pCommonCfg->uDeviceStatus */ 660 660 { 661 Log 3Func(("Guest read uDeviceStatus ................ ("));661 Log6Func(("Guest read uDeviceStatus ................ (")); 662 662 *(uint32_t *)pv = pVirtio->uDeviceStatus; 663 663 virtioLogDeviceStatus(pVirtio->uDeviceStatus); 664 Log 3((")\n"));664 Log6((")\n")); 665 665 } 666 666 } … … 764 764 { 765 765 ++pVirtio->uConfigGeneration; 766 Log 3Func(("Bumped cfg. generation to %d because %s%s\n",766 Log6Func(("Bumped cfg. generation to %d because %s%s\n", 767 767 pVirtio->uConfigGeneration, 768 768 fDevSpecificFieldChanged ? "<dev cfg changed> " : "", … … 781 781 { 782 782 *(uint8_t *)pv = pVirtio->uISR; 783 Log 3Func(("Read and clear ISR\n"));783 Log6Func(("Read and clear ISR\n")); 784 784 pVirtio->uISR = 0; /** VirtIO specification requires reads of ISR to clear it */ 785 785 virtioLowerInterrupt(pVirtio); … … 832 832 { 833 833 pVirtio->uISR = *(uint8_t *)pv; 834 Log 3Func(("Setting uISR = 0x%02x (virtq interrupt: %d, dev confg interrupt: %d)\n",834 Log6Func(("Setting uISR = 0x%02x (virtq interrupt: %d, dev confg interrupt: %d)\n", 835 835 pVirtio->uISR & 0xff, 836 836 pVirtio->uISR & VIRTIO_ISR_VIRTQ_INTERRUPT, … … 1045 1045 1046 1046 int rc = VINF_SUCCESS; 1047 1048 1047 1049 1048 PVIRTIOSTATE pVirtio = (PVIRTIOSTATE)RTMemAllocZ(sizeof(VIRTIOSTATE)); … … 1463 1462 } 1464 1463 1464 /** 1465 * Do a hex dump of a buffer. 1466 * 1467 * @param pv Pointer to array to dump 1468 * @param cb Number of characters to dump 1469 * @param uBase Base address of offset addresses displayed 1470 * @param pszTitle Header line/title for the dump 1471 * 1472 */ 1473 void virtioHexDump(uint8_t *pv, size_t cb, uint32_t uBase, const char *pszTitle) 1474 { 1475 if (pszTitle) 1476 Log(("%s [%d bytes]:\n", pszTitle, cb)); 1477 for (uint32_t row = 0; row < RT_MAX(1, (cb / 16) + 1); row++) 1478 { 1479 uint32_t uAddr = row * 16 + uBase; 1480 Log(("%x%x%x%x: ", (uAddr >> 12) & 0xf, (uAddr >> 8) & 0xf, (uAddr >> 4) & 0xf, uAddr & 0xf)); 1481 for (int col = 0; col < 16; col++) 1482 { 1483 uint32_t idx = row * 16 + col; 1484 uint8_t u8 = pv[idx]; 1485 if (idx >= cb) 1486 Log(("-- %s", (col + 1) % 8 ? "" : " ")); 1487 else 1488 Log(("%x%x %s", u8 >> 4 & 0xf, u8 & 0xf, (col + 1) % 8 ? "" : " ")); 1489 } 1490 for (int col = 0; col < 16; col++) 1491 { 1492 uint32_t idx = row * 16 + col; 1493 uint8_t u8 = pv[idx]; 1494 if (idx >= cb) 1495 Log((" ")); 1496 else 1497 Log(("%c", u8 >= 0x20 && u8 <= 0x7e ? u8 : '.')); 1498 } 1499 Log(("\n")); 1500 } 1501 Log(("\n")); 1502 } 1465 1503 1466 1504 #endif /* IN_RING3 */ -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h
r80522 r80596 41 41 #define VIRTIOSCSI_REGION_PORT_IO 1 /**< BAR for PORT I/O (impl specific) */ 42 42 #define VIRTIOSCSI_REGION_PCI_CAP 2 /**< BAR for VirtIO Cap. MMIO (impl specific) */ 43 44 #define VIRTIO_HEX_DUMP(logLevel, pv, cb, base, title) \ 45 do { \ 46 if (LogIsItEnabled(logLevel, LOG_GROUP)) \ 47 virtioHexDump((pv), (cb), (base), (title)); \ 48 } while (0) 43 49 44 50 /** … … 320 326 bool fWrite, bool fHasIndex, uint32_t idx); 321 327 328 /** 329 * Does a formatted hex dump using Log(()), recommend using VIRTIO_HEX_DUMP() macro to 330 * control enabling of logging efficiently. 331 * 332 * @param pv - pointer to buffer to dump contents of 333 * @param cb - count of characters to dump from buffer 334 * @param uBase - base address of per-row address prefixing of hex output 335 * @param pszTitle - Optional title. If present displays title that lists 336 * provided text with value of cb to indicate size next to it. 337 */ 338 void virtioHexDump(uint8_t *pv, size_t cb, uint32_t uBase, const char *pszTitle); 322 339 323 340 #endif /* !VBOX_INCLUDED_SRC_VirtIO_Virtio_1_0_h */ -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h
r80527 r80596 409 409 pVirtio->pGcPhysQueueAvail[qIdx] + RT_UOFFSETOF(VIRTQ_AVAIL_T, uIdx), 410 410 &uIdx, sizeof(uIdx)); 411 Log3Func(("%s actual avail_idx=%d\n", pVirtio->virtqProxy[qIdx].szVirtqName, uIdx));412 411 return uIdx; 413 412 } … … 512 511 { 513 512 if (status == 0) 514 Log 3(("RESET"));513 Log6(("RESET")); 515 514 else 516 515 { 517 516 int primed = 0; 518 517 if (status & VIRTIO_STATUS_ACKNOWLEDGE) 519 Log 3(("ACKNOWLEDGE", primed++));518 Log6(("ACKNOWLEDGE", primed++)); 520 519 if (status & VIRTIO_STATUS_DRIVER) 521 Log 3(("%sDRIVER", primed++ ? " | " : ""));520 Log6(("%sDRIVER", primed++ ? " | " : "")); 522 521 if (status & VIRTIO_STATUS_FEATURES_OK) 523 Log 3(("%sFEATURES_OK", primed++ ? " | " : ""));522 Log6(("%sFEATURES_OK", primed++ ? " | " : "")); 524 523 if (status & VIRTIO_STATUS_DRIVER_OK) 525 Log 3(("%sDRIVER_OK", primed++ ? " | " : ""));524 Log6(("%sDRIVER_OK", primed++ ? " | " : "")); 526 525 if (status & VIRTIO_STATUS_FAILED) 527 Log 3(("%sFAILED", primed++ ? " | " : ""));526 Log6(("%sFAILED", primed++ ? " | " : "")); 528 527 if (status & VIRTIO_STATUS_DEVICE_NEEDS_RESET) 529 Log 3(("%sNEEDS_RESET", primed++ ? " | " : ""));528 Log6(("%sNEEDS_RESET", primed++ ? " | " : "")); 530 529 } 531 530 }
Note:
See TracChangeset
for help on using the changeset viewer.