MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / GetTiming

Function GetTiming

Library/OcDebugLogLib/OcLog.c:40–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38#include "OcLogInternal.h"
39
40STATIC
41CHAR8 *
42GetTiming (
43 IN OC_LOG_PROTOCOL *This
44 )
45{
46 OC_LOG_PRIVATE_DATA *Private = NULL;
47
48 UINT64 dTStartSec = 0;
49 UINT64 dTStartMs = 0;
50 UINT64 dTLastSec = 0;
51 UINT64 dTLastMs = 0;
52 UINT64 CurrentTsc = 0;
53
54 if (This == NULL) {
55 return NULL;
56 }
57
58 Private = OC_LOG_PRIVATE_DATA_FROM_OC_LOG_THIS (This);
59
60 //
61 // Calibrate TSC for timings.
62 //
63
64 if (Private->TscFrequency == 0) {
65 Private->TscFrequency = OcGetTSCFrequency ();
66
67 if (Private->TscFrequency != 0) {
68 CurrentTsc = AsmReadTsc ();
69
70 Private->TscStart = CurrentTsc;
71 Private->TscLast = CurrentTsc;
72 }
73 }
74
75 if (Private->TscFrequency > 0) {
76 CurrentTsc = AsmReadTsc ();
77
78 dTStartMs = DivU64x64Remainder (MultU64x32 (CurrentTsc - Private->TscStart, 1000), Private->TscFrequency, NULL);
79 dTStartSec = DivU64x64Remainder (dTStartMs, 1000, &dTStartMs);
80 dTLastMs = DivU64x64Remainder (MultU64x32 (CurrentTsc - Private->TscLast, 1000), Private->TscFrequency, NULL);
81 dTLastSec = DivU64x64Remainder (dTLastMs, 1000, &dTLastMs);
82
83 Private->TscLast = CurrentTsc;
84 }
85
86 AsciiSPrint (
87 Private->TimingTxt,
88 OC_LOG_TIMING_BUFFER_SIZE,
89 "%02d:%03d %02d:%03d ",
90 dTStartSec,
91 dTStartMs,
92 dTLastSec,
93 dTLastMs
94 );
95
96 return Private->TimingTxt;
97}

Callers 1

OcLogAddEntryFunction · 0.70

Calls 5

OcGetTSCFrequencyFunction · 0.85
DivU64x64RemainderFunction · 0.85
MultU64x32Function · 0.85
AsmReadTscFunction · 0.50
AsciiSPrintFunction · 0.50

Tested by

no test coverage detected