1 | /** @file
|
---|
2 | Functions implementation in this file are not common for all type of TraceHubDebugSysTLib.
|
---|
3 |
|
---|
4 | Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
|
---|
5 |
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include <Base.h>
|
---|
11 | #include <Guid/TraceHubDebugInfoHob.h>
|
---|
12 | #include <Library/BaseMemoryLib.h>
|
---|
13 | #include <Library/HobLib.h>
|
---|
14 | #include "InternalTraceHubApi.h"
|
---|
15 |
|
---|
16 | /**
|
---|
17 | Count the total number of Trace Hub debug instance in the system.
|
---|
18 |
|
---|
19 | @retval UINT32 The total number of Trace Hub debug instance in the system.
|
---|
20 | **/
|
---|
21 | UINT32
|
---|
22 | EFIAPI
|
---|
23 | CountThDebugInstance (
|
---|
24 | VOID
|
---|
25 | )
|
---|
26 | {
|
---|
27 | UINT8 *DbgContext;
|
---|
28 | UINT32 DbgInstCount;
|
---|
29 |
|
---|
30 | DbgInstCount = 0;
|
---|
31 |
|
---|
32 | DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
|
---|
33 | if (DbgContext != NULL) {
|
---|
34 | while (DbgContext != NULL) {
|
---|
35 | DbgInstCount++;
|
---|
36 | DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
|
---|
37 | }
|
---|
38 | } else {
|
---|
39 | DbgInstCount++;
|
---|
40 | }
|
---|
41 |
|
---|
42 | return DbgInstCount;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | Pack Trace Hub debug instances in the system.
|
---|
47 |
|
---|
48 | @param[in, out] ThPtr A pointer to TRACEHUB_DEBUG_INFO_HOB structure.
|
---|
49 | @param[in] Count Number of Trace Hub HOBs.
|
---|
50 | **/
|
---|
51 | VOID
|
---|
52 | EFIAPI
|
---|
53 | PackThDebugInstance (
|
---|
54 | IN OUT TRACEHUB_DEBUG_INFO_HOB *ThPtr,
|
---|
55 | IN UINT32 Count
|
---|
56 | )
|
---|
57 | {
|
---|
58 | UINT8 *DbgContext;
|
---|
59 | UINT16 Index;
|
---|
60 |
|
---|
61 | DbgContext = GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
|
---|
62 | if (DbgContext != NULL) {
|
---|
63 | for (Index = 0; Index < Count; Index++) {
|
---|
64 | CopyMem (&ThPtr[Index], GET_GUID_HOB_DATA (DbgContext), sizeof (TRACEHUB_DEBUG_INFO_HOB));
|
---|
65 | DbgContext = GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
|
---|
66 | }
|
---|
67 | } else {
|
---|
68 | for (Index = 0; Index < Count; Index++) {
|
---|
69 | ThPtr[Index].TraceHubMmioAddress = FixedPcdGet64 (PcdTraceHubDebugMmioAddress);
|
---|
70 | ThPtr[Index].Flag = FixedPcdGetBool (PcdEnableTraceHubDebugMsg);
|
---|
71 | ThPtr[Index].DebugLevel = FixedPcdGet8 (PcdTraceHubDebugLevel);
|
---|
72 | }
|
---|
73 | }
|
---|
74 | }
|
---|