forked from ArthurHeymans/openSIL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SocLogicalId.c
163 lines (149 loc) · 4.58 KB
/
SocLogicalId.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/**
* @file SocLogicalId.c
* @brief OpenSIL SoC logical ID functions
*
*/
/* Copyright 2021-2023 Advanced Micro Devices, Inc. All rights reserved. */
// SPDX-License-Identifier: MIT
#include <SilCommon.h>
#include <BaseSocLogicalIdXlat.h>
/**
* SocConvertRawToLogical
* @brief Translates the given raw ID into the appropriate logical
* family / logical revision
*
* @param[in] RawId Raw CPU ID to convert
* @param[out] LogicalId Logical family and logical revision for the given raw ID
*
* @retval true Logical ID was successfully found
* @retval false Family is unknown
*/
bool
SocConvertRawToLogical (
uint32_t RawId,
SOC_LOGICAL_ID *LogicalId
)
{
SOC_LOGICAL_FAMILY_XLAT *LogicalFamilyTable;
SOC_LOGICAL_REVISION_XLAT *LogicalRevisionTable;
bool LogicalIdValid;
LogicalIdValid = SocFindApplicableLogicalTableEntries (
RawId,
&LogicalFamilyTable,
&LogicalRevisionTable
);
if (LogicalIdValid) {
LogicalId->Family = LogicalFamilyTable->LogicalFamily;
LogicalId->Revision = LogicalRevisionTable->LogicalRevision;
}
return LogicalIdValid;
}
/**
* BaseCoreConvertRawToLogical
* @brief Translates the given raw ID into the appropriate
* logical family / logical revision
*
* @param[in] RawId Raw CPU ID to convert
* @param[out] LogicalId Logical family and logical revision for
* the given raw ID
*
* @retval true Logical ID was successfully found
* @retval false Family is unknown
*/
static bool
BaseCoreConvertRawToLogical (
uint32_t RawId,
CORE_LOGICAL_ID *LogicalId
)
{
SOC_LOGICAL_FAMILY_XLAT *LogicalFamilyTable = {0};
SOC_LOGICAL_REVISION_XLAT *LogicalRevisionTable = {0};
bool LogicalIdValid;
LogicalIdValid = SocFindApplicableLogicalTableEntries (RawId,
&LogicalFamilyTable,
&LogicalRevisionTable
);
if (LogicalIdValid) {
LogicalId->CoreFamily = LogicalFamilyTable->LogicalCoreFamily;
LogicalId->CoreRevision = LogicalRevisionTable->LogicalCoreRev;
}
return LogicalIdValid;
}
/**
* GetSocLogicalIdOnCurrentCore
* @brief This service retrieves the logical family and revision for the executing core.
*
* @param[out] LogicalId Pointer to the logical ID for the executing core.
*
* @retval SilPass The executing core's logical ID was successfully retrieved.
* @retval SilInvalidParameter All output parameter pointers are NULL.
* @retval SilDeviceError Unknown processor family found.
*
**/
SIL_STATUS GetSocLogicalIdOnCurrentCore (SOC_LOGICAL_ID *LogicalId)
{
if (LogicalId == NULL) {
return SilInvalidParameter;
}
if (SocConvertRawToLogical (xUslGetRawIdOnExecutingCore (), LogicalId)) {
return SilPass;
} else {
return SilDeviceError;
}
}
/**
* SocFamilyIdCheck
*
* @brief SocFamilyIDCheck function compare the logical family of the
* executing core received from "GetSocLogicalIdOnCurrentCore"
* function with input logic family parameter.
* if both logical family info match, return true as SOC Family ID check pass.
* else return false as SOC Family ID check fail.
*
* @param[in] SocFamilyId FamailyId
*
* @return TRUE - SOC Family ID check pass.
* FALSE - SOC Family ID check fail.
*
*/
bool
SocFamilyIdCheck (
uint32_t SocFamilyId
)
{
SOC_LOGICAL_ID LogicalId;
SIL_STATUS Status;
// Get logical family and revision for the executing core
Status = GetSocLogicalIdOnCurrentCore(&LogicalId);
if (Status == SilPass) {
if ( LogicalId.Family == SocFamilyId ) {
return true;
}
}
return false;
}
/**
* GetCoreLogicalIdOnCurrentCore
* @brief This service retrieves the core logical family and revision for the executing core.
*
* @param[out] CoreLogicalId Pointer to the core logical ID for the executing core.
*
* @retval SilPass The executing core's logical ID was successfully retrieved.
* @retval SilInvalidParameter All output parameter pointers are NULL.
* @retval SilDeviceError Unknown processor family found.
*
**/
SIL_STATUS
GetCoreLogicalIdOnCurrentCore (
CORE_LOGICAL_ID *CoreLogicalId
)
{
if (CoreLogicalId == NULL) {
return SilInvalidParameter;
}
if ((BaseCoreConvertRawToLogical (xUslGetRawIdOnExecutingCore (), CoreLogicalId))) {
return SilPass;
} else {
return SilDeviceError;
}
}