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

Function GetPcdName

MdeModulePkg/Universal/PCD/Dxe/Service.c:114–182  ·  view source on GitHub ↗

Get PCD name. @param[in] OnlyTokenSpaceName If TRUE, only need to get the TokenSpaceCName. If FALSE, need to get the full PCD name. @param[in] IsPeiDb If TRUE, the pcd entry is initialized in PEI phase, If FALSE, the pcd entry is initialized in DXE phase. @param[in] TokenNumber The PC

Source from the content-addressed store, hash-verified

112 @return The TokenSpaceCName or full PCD name.
113**/
114CHAR8 *
115GetPcdName (
116 IN BOOLEAN OnlyTokenSpaceName,
117 IN BOOLEAN IsPeiDb,
118 IN UINTN TokenNumber
119 )
120{
121 PCD_DATABASE_INIT *Database;
122 UINT8 *StringTable;
123 UINTN NameSize;
124 PCD_NAME_INDEX *PcdNameIndex;
125 CHAR8 *TokenSpaceName;
126 CHAR8 *PcdName;
127 CHAR8 *Name;
128
129 //
130 // Return NULL when PCD name table is absent.
131 //
132 if (IsPeiDb) {
133 if (mPcdDatabase.PeiDb->PcdNameTableOffset == 0) {
134 return NULL;
135 }
136 } else {
137 if (mPcdDatabase.DxeDb->PcdNameTableOffset == 0) {
138 return NULL;
139 }
140 }
141
142 //
143 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
144 // We have to decrement TokenNumber by 1 to make it usable
145 // as the array index.
146 //
147 TokenNumber--;
148
149 Database = IsPeiDb ? mPcdDatabase.PeiDb: mPcdDatabase.DxeDb;
150 TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount;
151
152 StringTable = (UINT8 *) Database + Database->StringTableOffset;
153
154 //
155 // Get the PCD name index.
156 //
157 PcdNameIndex = (PCD_NAME_INDEX *)((UINT8 *) Database + Database->PcdNameTableOffset) + TokenNumber;
158 TokenSpaceName = (CHAR8 *)&StringTable[PcdNameIndex->TokenSpaceCNameIndex];
159 PcdName = (CHAR8 *)&StringTable[PcdNameIndex->PcdCNameIndex];
160
161 if (OnlyTokenSpaceName) {
162 //
163 // Only need to get the TokenSpaceCName.
164 //
165 Name = AllocateCopyPool(AsciiStrSize (TokenSpaceName), TokenSpaceName);
166 } else {
167 //
168 // Need to get the full PCD name.
169 //
170 NameSize = AsciiStrSize (TokenSpaceName) + AsciiStrSize (PcdName);
171 Name = AllocateZeroPool(NameSize);

Callers 2

ExGetPcdInfoFunction · 0.70
DxeGetPcdInfoFunction · 0.70

Calls 4

AllocateCopyPoolFunction · 0.85
AsciiStrSizeFunction · 0.85
AsciiStrCatSFunction · 0.85
AllocateZeroPoolFunction · 0.50

Tested by

no test coverage detected