Changeset 104920 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 14, 2024 12:02:03 PM (9 months ago)
- svn:sync-xref-src-repo-rev:
- 163522
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Trace/VBoxTraceLogDecoders.cpp
r104919 r104920 46 46 /** 47 47 */ 48 typedef DECLCALLBACKTYPE(void, FNDECODETPM2CC, (P CTPMREQHDR pHdr, size_t cb));48 typedef DECLCALLBACKTYPE(void, FNDECODETPM2CC, (PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb)); 49 49 /** Pointer to an event decode callback. */ 50 50 typedef FNDECODETPM2CC *PFNFNDECODETPM2CC; … … 60 60 *********************************************************************************************************************************/ 61 61 62 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdown(P CTPMREQHDR pHdr, size_t cb)62 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdown(PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb) 63 63 { 64 64 if (cb >= sizeof(uint16_t)) … … 74 74 } 75 75 76 RTMsgError("Malformed TPM2_CC_STARTUP/TPM2_CC_SHUTDOWN command, not enough room for TPM_SU constant\n");76 pHlp->pfnErrorMsg(pHlp, "Malformed TPM2_CC_STARTUP/TPM2_CC_SHUTDOWN command, not enough room for TPM_SU constant\n"); 77 77 } 78 78 … … 97 97 }; 98 98 99 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapability(P CTPMREQHDR pHdr, size_t cb)99 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeGetCapability(PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb) 100 100 { 101 101 if (cb >= sizeof(TPM2REQGETCAPABILITY)) … … 118 118 } 119 119 120 RTMsgError("Malformed TPM2_CC_GET_CAPABILITY command, not enough room for the input\n");121 } 122 123 124 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublic(P CTPMREQHDR pHdr, size_t cb)120 pHlp->pfnErrorMsg(pHlp, "Malformed TPM2_CC_GET_CAPABILITY command, not enough room for the input\n"); 121 } 122 123 124 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeReadPublic(PRTTRACELOGDECODERHLP pHlp, PCTPMREQHDR pHdr, size_t cb) 125 125 { 126 126 if (cb >= sizeof(TPM2REQREADPUBLIC)) … … 132 132 } 133 133 134 RTMsgError("Malformed TPM2_CC_READ_PUBLIC command, not enough room for the input\n");134 pHlp->pfnErrorMsg(pHlp, "Malformed TPM2_CC_READ_PUBLIC command, not enough room for the input\n"); 135 135 } 136 136 … … 271 271 }; 272 272 273 static void vboxTraceLogDecodeEvtTpmDecodeCmdBuffer( const uint8_t *pbCmd, size_t cbCmd)273 static void vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbCmd, size_t cbCmd) 274 274 { 275 275 PCTPMREQHDR pHdr = (PCTPMREQHDR)pbCmd; … … 283 283 RTMsgInfo(" %s:\n", s_aTpmCmdCodes[i].pszCmdCode); 284 284 if (s_aTpmCmdCodes[i].pfnDecode) 285 s_aTpmCmdCodes[i].pfnDecode(pH dr, RT_BE2H_U32(pHdr->cbReq));285 s_aTpmCmdCodes[i].pfnDecode(pHlp, pHdr, RT_BE2H_U32(pHdr->cbReq)); 286 286 return; 287 287 } … … 294 294 295 295 296 static void vboxTraceLogDecodeEvtTpmDecodeRespBuffer(const uint8_t *pbResp, size_t cbResp) 297 { 296 static void vboxTraceLogDecodeEvtTpmDecodeRespBuffer(PRTTRACELOGDECODERHLP pHlp, const uint8_t *pbResp, size_t cbResp) 297 { 298 RT_NOREF(pHlp); 299 298 300 PCTPMRESPHDR pHdr = (PCTPMRESPHDR)pbResp; 299 301 if (cbResp >= sizeof(*pHdr)) … … 306 308 307 309 308 static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpm CmdExecReq(RTTRACELOGRDREVT hTraceLogEvt, PCRTTRACELOGEVTDESC pEvtDesc,309 310 static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpm(PRTTRACELOGDECODERHLP pHlp, uint32_t idDecodeEvt, RTTRACELOGRDREVT hTraceLogEvt, 311 PCRTTRACELOGEVTDESC pEvtDesc, PRTTRACELOGEVTVAL paVals, uint32_t cVals) 310 312 { 311 313 RT_NOREF(hTraceLogEvt, pEvtDesc); 312 for (uint32_t i = 0; i < cVals; i++) 313 { 314 /* Look for the pvCmd item which stores the command buffer. */ 315 if ( !strcmp(paVals[i].pItemDesc->pszName, "pvCmd") 316 && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA) 314 if (idDecodeEvt == 0) 315 { 316 for (uint32_t i = 0; i < cVals; i++) 317 317 { 318 vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(paVals[i].u.RawData.pb, paVals[i].u.RawData.cb); 319 return VINF_SUCCESS; 318 /* Look for the pvCmd item which stores the command buffer. */ 319 if ( !strcmp(paVals[i].pItemDesc->pszName, "pvCmd") 320 && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA) 321 { 322 vboxTraceLogDecodeEvtTpmDecodeCmdBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb); 323 return VINF_SUCCESS; 324 } 320 325 } 321 } 322 RTMsgError("Failed to find the TPM command data buffer for the given event\n"); 326 327 pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command data buffer for the given event\n"); 328 } 329 else if (idDecodeEvt == 1) 330 { 331 for (uint32_t i = 0; i < cVals; i++) 332 { 333 /* Look for the pvCmd item which stores the response buffer. */ 334 if ( !strcmp(paVals[i].pItemDesc->pszName, "pvResp") 335 && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA) 336 { 337 vboxTraceLogDecodeEvtTpmDecodeRespBuffer(pHlp, paVals[i].u.RawData.pb, paVals[i].u.RawData.cb); 338 return VINF_SUCCESS; 339 } 340 } 341 pHlp->pfnErrorMsg(pHlp, "Failed to find the TPM command response buffer for the given event\n"); 342 } 343 344 pHlp->pfnErrorMsg(pHlp, "Decode event ID %u is not known to this decoder\n", idDecodeEvt); 323 345 return VERR_NOT_FOUND; 324 346 } 325 347 326 348 327 static DECLCALLBACK(int) vboxTraceLogDecodeEvtTpmCmdExecResp(RTTRACELOGRDREVT hTraceLogEvt, PCRTTRACELOGEVTDESC pEvtDesc,328 PRTTRACELOGEVTVAL paVals, uint32_t cVals)329 {330 RT_NOREF(hTraceLogEvt, pEvtDesc);331 for (uint32_t i = 0; i < cVals; i++)332 {333 /* Look for the pvCmd item which stores the response buffer. */334 if ( !strcmp(paVals[i].pItemDesc->pszName, "pvResp")335 && paVals[i].pItemDesc->enmType == RTTRACELOGTYPE_RAWDATA)336 {337 vboxTraceLogDecodeEvtTpmDecodeRespBuffer(paVals[i].u.RawData.pb, paVals[i].u.RawData.cb);338 return VINF_SUCCESS;339 }340 }341 RTMsgError("Failed to find the TPM command data buffer for the given event\n");342 return VERR_NOT_FOUND;343 }344 345 346 349 /** 347 * Filter plugin interface. 348 */ 349 const RTTRACELOGDECODERDECODEEVENT g_aTraceLogDecode[] = 350 { 351 { "ITpmConnector.CmdExecReq", vboxTraceLogDecodeEvtTpmCmdExecReq }, 352 { "ITpmConnector.CmdExecResp", vboxTraceLogDecodeEvtTpmCmdExecResp }, 350 * TPM decoder event IDs. 351 */ 352 static const RTTRACELOGDECODEEVT s_aDecodeEvtTpm[] = 353 { 354 { "ITpmConnector.CmdExecReq", 0 }, 355 { "ITpmConnector.CmdExecResp", 1 }, 356 { NULL, UINT32_MAX } 357 }; 358 359 360 /** 361 * Decoder plugin interface. 362 */ 363 static const RTTRACELOGDECODERREG g_TraceLogDecoderTpm = 364 { 365 /** pszName */ 366 "TPM", 367 /** pszDesc */ 368 "Decodes events from the ITpmConnector interface generated with the IfTrace driver.", 369 /** paEvtIds */ 370 s_aDecodeEvtTpm, 371 /** pfnDecode */ 372 vboxTraceLogDecodeEvtTpm, 353 373 }; 354 374 … … 364 384 VERR_VERSION_MISMATCH); 365 385 366 return pRegisterCallbacks->pfnRegisterDecoders(pvUser, &g_ aTraceLogDecode[0], RT_ELEMENTS(g_aTraceLogDecode));367 } 368 386 return pRegisterCallbacks->pfnRegisterDecoders(pvUser, &g_TraceLogDecoderTpm, 1); 387 } 388
Note:
See TracChangeset
for help on using the changeset viewer.