);\r
}\r
\r
- if (!DXE_EXMAP_TABLE_EMPTY) {\r
+ if ((ExTokenNumber == PCD_INVALID_TOKEN_NUMBER) &&\r
+ !DXE_EXMAP_TABLE_EMPTY\r
+ ) {\r
ExTokenNumber = ExGetNextTokeNumber (\r
Guid,\r
ExTokenNumber,\r
return EFI_SUCCESS;\r
}\r
\r
+\r
+EFI_GUID **\r
+GetDistinctTokenSpace (\r
+ IN OUT UINTN *ExMapTableSize,\r
+ IN DYNAMICEX_MAPPING *ExMapTable,\r
+ IN EFI_GUID *GuidTable\r
+ )\r
+{\r
+ EFI_GUID **DistinctTokenSpace;\r
+ UINTN OldGuidIndex;\r
+ UINTN TsIdx;\r
+ UINTN Idx;\r
+\r
+\r
+ DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));\r
+ ASSERT (DistinctTokenSpace != NULL);\r
+\r
+ TsIdx = 0;\r
+ OldGuidIndex = ExMapTable[0].ExGuidIndex;\r
+ DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];\r
+ for (Idx = 1; Idx < PEI_EXMAPPING_TABLE_SIZE; Idx++) {\r
+ if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {\r
+ OldGuidIndex = ExMapTable[Idx].ExGuidIndex;\r
+ DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];\r
+ }\r
+ }\r
+\r
+ *ExMapTableSize = TsIdx;\r
+ return DistinctTokenSpace;\r
+ \r
+}\r
+ \r
+\r
+STATIC EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxePcdGetNextTokenSpace (\r
+ IN OUT CONST EFI_GUID **Guid\r
+ )\r
+{\r
+ UINTN Idx;\r
+ UINTN Idx2;\r
+ UINTN Idx3;\r
+ UINTN PeiTokenSpaceTableSize;\r
+ UINTN DxeTokenSpaceTableSize;\r
+ EFI_GUID **PeiTokenSpaceTable;\r
+ EFI_GUID **DxeTokenSpaceTable;\r
+ BOOLEAN Match;\r
+\r
+ ASSERT (Guid != NULL);\r
+ \r
+ if (PEI_EXMAP_TABLE_EMPTY && DXE_EXMAP_TABLE_EMPTY) {\r
+ if (*Guid != NULL) {\r
+ return EFI_NOT_FOUND;\r
+ } else {\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ \r
+ \r
+ if (TmpTokenSpaceBuffer[0] != NULL) {\r
+ PeiTokenSpaceTableSize = 0;\r
+\r
+ if (!PEI_EXMAP_TABLE_EMPTY) {\r
+ PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;\r
+ PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,\r
+ mPcdDatabase->PeiDb.Init.ExMapTable,\r
+ mPcdDatabase->PeiDb.Init.GuidTable\r
+ );\r
+ CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);\r
+ }\r
+\r
+ if (!DXE_EXMAP_TABLE_EMPTY) {\r
+ DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;\r
+ DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,\r
+ mPcdDatabase->DxeDb.Init.ExMapTable,\r
+ mPcdDatabase->DxeDb.Init.GuidTable\r
+ );\r
+\r
+ //\r
+ // Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable\r
+ //\r
+ for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {\r
+ Match = FALSE;\r
+ for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {\r
+ if (CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {\r
+ Match = TRUE;\r
+ break;\r
+ }\r
+ }\r
+ if (!Match) {\r
+ TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (*Guid == NULL) {\r
+ *Guid = TmpTokenSpaceBuffer[0];\r
+ return EFI_SUCCESS;\r
+ }\r
+ \r
+ for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {\r
+ if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {\r
+ Idx++;\r
+ *Guid = TmpTokenSpaceBuffer[Idx];\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+\r
+}\r
+\r
+\r
if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
return ExMapTable[Idx].ExTokenNumber;\r
}\r
- \r
+\r
for ( ; Idx < SizeOfExMapTable; Idx++) {\r
if (ExMapTable[Idx].ExTokenNumber == TokenNumber) {\r
Idx++;\r
\r
PeiRegisterCallBackOnSet,\r
PcdUnRegisterCallBackOnSet,\r
- PeiPcdGetNextToken\r
+ PeiPcdGetNextToken,\r
+ PeiPcdGetNextTokenSpace\r
};\r
\r
\r
\r
EFI_STATUS\r
EFIAPI\r
-PeiPcdGetNextTokenSpaceGuid (\r
+PeiPcdGetNextTokenSpace (\r
IN OUT CONST EFI_GUID **Guid\r
)\r
{\r
UINTN i;\r
BOOLEAN Found;\r
\r
- if (*Guid == NULL) {\r
- if (PEI_EXMAP_TABLE_EMPTY) {\r
- return EFI_SUCCESS;\r
+ ASSERT (Guid != NULL);\r
+\r
+ if (PEI_EXMAP_TABLE_EMPTY) {\r
+ if (*Guid != NULL) {\r
+ return EFI_NOT_FOUND;\r
} else {\r
- //\r
- // return the first Token Space Guid.\r
- //\r
- *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];\r
return EFI_SUCCESS;\r
}\r
- }\r
+ }\r
\r
//\r
// Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r
//\r
PeiPcdDb = GetPcdDatabase ();\r
\r
+ ExMapTable = PeiPcdDb->Init.ExMapTable;\r
+\r
+ if (*Guid == NULL) {\r
+ //\r
+ // return the first Token Space Guid.\r
+ //\r
+ *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), *Guid);\r
\r
if (MatchGuid == NULL) {\r
\r
GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
\r
- ExMapTable = PeiPcdDb->Init.ExMapTable;\r
-\r
Found = FALSE;\r
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
}\r
\r
if (Found) {\r
+ i++;\r
for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++ ) {\r
if (ExMapTable[i].ExGuidIndex != GuidTableIdx ) {\r
*Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[i].ExGuidIndex];\r
return EFI_SUCCESS;\r
}\r
}\r
+ *Guid = NULL;\r
+ return EFI_SUCCESS;\r
}\r
\r
return EFI_NOT_FOUND;\r
)\r
;\r
\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiPcdGetNextTokenSpace (\r
+ IN CONST EFI_GUID **Guid\r
+ )\r
+;\r
+\r
extern EFI_GUID gPcdDataBaseHobGuid;\r
\r
extern EFI_GUID gPcdPeiCallbackFnTableHobGuid;\r
\r
/**\r
Sets a buffer for the token specified by TokenNumber to \r
- the value specified by Value. Value is returned.\r
- If Value is NULL, then ASSERT().\r
+ the value specified by Buffer and SizeOfValue. Buffer to\r
+ be set is returned. The content of the buffer could be \r
+ overwritten if a Callback on SET is registered with this\r
+ TokenNumber.\r
+ \r
+ If SizeOfValue is greater than the maximum \r
+ size support by TokenNumber, then set SizeOfValue to the \r
+ maximum size supported by TokenNumber and return NULL to \r
+ indicate that the set operation was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
@param[in] Value A pointer to the buffer to set.\r
\r
@retval VOID* Return the pointer for the buffer been set.\r
VOID*\r
EFIAPI\r
LibPcdSetPtr (\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Value\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Value\r
);\r
\r
\r
\r
\r
/**\r
- Sets a buffer for the token specified by TokenNumber and \r
- Guid to the value specified by Value. Value is returned.\r
- If Guid is NULL, then ASSERT().\r
- If Value is NULL, then ASSERT().\r
+ Sets a buffer for the token specified by TokenNumber to the value specified by \r
+ Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
+ supported by TokenNumber and return NULL to indicate that the set operation \r
+ was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] Guid Pointer to a 128-bit unique value that \r
designates which namespace to set a value from.\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
- @param[in] Value The 8-bit value to set.\r
+ @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to set.\r
\r
- @retval VOID * Return the value been set.\r
+ @retval VOID * Return the pinter to the buffer been set.\r
\r
**/\r
VOID *\r
EFIAPI\r
LibPcdSetExPtr (\r
- IN CONST GUID *Guid,\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Value\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
);\r
\r
\r
IN UINTN TokenNumber\r
);\r
\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token space from a token space specified by Guid.\r
+ Guid of NULL is reserved to mark the default local token namespace on the current\r
+ platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
+ current platform is returned. If Guid is the last non-local token space, \r
+ then NULL is returned. \r
+\r
+ If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
+\r
+\r
+ \r
+ @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
+ to start the search.\r
+\r
+ @retval CONST GUID * The next valid token namespace.\r
+\r
+**/\r
+\r
+CONST GUID* \r
+EFIAPI\r
+LibPcdGetNextTokenSpace (\r
+ IN CONST GUID *Guid\r
+ );\r
+\r
#endif\r
IN OUT UINTN *TokenNumber\r
);\r
\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PCD_PPI_GET_NEXT_TOKENSPACE) (\r
+ IN OUT CONST EFI_GUID **Guid\r
+ );\r
+\r
typedef struct {\r
PCD_PPI_SET_SKU SetSku;\r
\r
PCD_PPI_CALLBACK_ONSET CallbackOnSet;\r
PCD_PPI_CANCEL_CALLBACK CancelCallback;\r
PCD_PPI_GET_NEXT_TOKEN GetNextToken;\r
+ PCD_PPI_GET_NEXT_TOKENSPACE GetNextTokenSpace;\r
} PCD_PPI;\r
\r
\r
IN OUT UINTN *TokenNumber\r
);\r
\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *PCD_PROTOCOL_GET_NEXT_TOKENSPACE) (\r
+ IN CONST EFI_GUID **Guid\r
+ );\r
+\r
+\r
typedef struct {\r
PCD_PROTOCOL_SET_SKU SetSku;\r
\r
PCD_PROTOCOL_CALLBACK_ONSET CallbackOnSet;\r
PCD_PROTOCOL_CANCEL_CALLBACK CancelCallback;\r
PCD_PROTOCOL_GET_NEXT_TOKEN GetNextToken;\r
+ PCD_PROTOCOL_GET_NEXT_TOKENSPACE GetNextTokenSpace;\r
} PCD_PROTOCOL;\r
\r
#endif\r
\r
/**\r
Sets a buffer for the token specified by TokenNumber to \r
- the value specified by Value. Value is returned.\r
- If Value is NULL, then ASSERT().\r
+ the value specified by Buffer and SizeOfValue. Buffer to\r
+ be set is returned. The content of the buffer could be \r
+ overwritten if a Callback on SET is registered with this\r
+ TokenNumber.\r
+ \r
+ If SizeOfValue is greater than the maximum \r
+ size support by TokenNumber, then set SizeOfValue to the \r
+ maximum size supported by TokenNumber and return NULL to \r
+ indicate that the set operation was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
@param[in] Value A pointer to the buffer to set.\r
\r
@retval VOID* Return the pointer for the buffer been set.\r
VOID *\r
EFIAPI\r
LibPcdSetPtr (\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Buffer\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
)\r
{\r
ASSERT (Buffer != NULL);\r
\r
\r
/**\r
- Sets a buffer for the token specified by TokenNumber and \r
- Guid to the value specified by Value. Value is returned.\r
- If Guid is NULL, then ASSERT().\r
- If Value is NULL, then ASSERT().\r
+ Sets a buffer for the token specified by TokenNumber to the value specified by \r
+ Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
+ supported by TokenNumber and return NULL to indicate that the set operation \r
+ was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] Guid Pointer to a 128-bit unique value that \r
designates which namespace to set a value from.\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
- @param[in] Value The 8-bit value to set.\r
+ @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to set.\r
\r
- @retval VOID * Return the value been set.\r
+ @retval VOID * Return the pinter to the buffer been set.\r
\r
**/\r
VOID *\r
EFIAPI\r
LibPcdSetExPtr (\r
- IN CONST GUID *Guid,\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Buffer\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
)\r
{\r
ASSERT (Guid != NULL);\r
{\r
return 0;\r
}\r
+\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token space from a token space specified by Guid.\r
+ Guid of NULL is reserved to mark the default local token namespace on the current\r
+ platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
+ current platform is returned. If Guid is the last non-local token space, \r
+ then NULL is returned. \r
+\r
+ If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
+\r
+\r
+ \r
+ @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
+ to start the search.\r
+\r
+ @retval CONST GUID * The next valid token namespace.\r
+\r
+**/\r
+CONST GUID* \r
+EFIAPI\r
+LibPcdGetNextTokenSpace (\r
+ IN CONST GUID *Guid\r
+ )\r
+{\r
+ return NULL;\r
+}\r
\r
/**\r
Sets a buffer for the token specified by TokenNumber to \r
- the value specified by Value. Value is returned.\r
- If Value is NULL, then ASSERT().\r
+ the value specified by Buffer and SizeOfValue. Buffer to\r
+ be set is returned. The content of the buffer could be \r
+ overwritten if a Callback on SET is registered with this\r
+ TokenNumber.\r
+ \r
+ If SizeOfValue is greater than the maximum \r
+ size support by TokenNumber, then set SizeOfValue to the \r
+ maximum size supported by TokenNumber and return NULL to \r
+ indicate that the set operation was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
@param[in] Value A pointer to the buffer to set.\r
\r
@retval VOID* Return the pointer for the buffer been set.\r
\r
**/\r
+\r
VOID *\r
EFIAPI\r
LibPcdSetPtr (\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Buffer\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
)\r
{\r
EFI_STATUS Status;\r
+ UINTN Size;\r
\r
- ASSERT (Buffer != NULL);\r
+ ASSERT ((*SizeOfBuffer > 0) && Buffer == NULL);\r
\r
- Status = mPcd->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r
+ Size = LibPcdGetSize (TokenNumber);\r
+ \r
+ if (*SizeOfBuffer > Size) {\r
+ *SizeOfBuffer = Size;\r
+ return NULL;\r
+ }\r
+\r
+ Status = mPcd->SetPtr (TokenNumber, *SizeOfBuffer, Buffer);\r
\r
ASSERT_EFI_ERROR (Status);\r
\r
\r
\r
/**\r
- Sets a buffer for the token specified by TokenNumber and \r
- Guid to the value specified by Value. Value is returned.\r
- If Guid is NULL, then ASSERT().\r
- If Value is NULL, then ASSERT().\r
+ Sets a buffer for the token specified by TokenNumber to the value specified by \r
+ Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
+ supported by TokenNumber and return NULL to indicate that the set operation \r
+ was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] Guid Pointer to a 128-bit unique value that \r
designates which namespace to set a value from.\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
- @param[in] Value The 8-bit value to set.\r
+ @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to set.\r
\r
- @retval VOID * Return the value been set.\r
+ @retval VOID * Return the pinter to the buffer been set.\r
\r
**/\r
VOID *\r
EFIAPI\r
LibPcdSetExPtr (\r
- IN CONST GUID *Guid,\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Buffer\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ UINTN Size;\r
\r
ASSERT (Guid != NULL);\r
ASSERT (Buffer != NULL);\r
\r
- Status = mPcd->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
+ Size = LibPcdGetExSize (Guid, TokenNumber);\r
+ if (*SizeOfBuffer > Size) {\r
+ *SizeOfBuffer = Size;\r
+ return NULL;\r
+ }\r
+\r
+ Status = mPcd->SetPtrEx (Guid, TokenNumber, *SizeOfBuffer, Buffer);\r
\r
ASSERT_EFI_ERROR (Status);\r
\r
return TokenNumber;\r
}\r
\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token space from a token space specified by Guid.\r
+ Guid of NULL is reserved to mark the default local token namespace on the current\r
+ platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
+ current platform is returned. If Guid is the last non-local token space, \r
+ then NULL is returned. \r
+\r
+ If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
+\r
+\r
+ \r
+ @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
+ to start the search.\r
+\r
+ @retval CONST GUID * The next valid token namespace.\r
+\r
+**/\r
+CONST GUID* \r
+EFIAPI\r
+LibPcdGetNextTokenSpace (\r
+ IN CONST GUID *Guid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = mPcd->GetNextTokenSpace (&Guid);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Guid;\r
+}\r
+\r
\r
/**\r
Sets a buffer for the token specified by TokenNumber to \r
- the value specified by Value. Value is returned.\r
- If Value is NULL, then ASSERT().\r
+ the value specified by Buffer and SizeOfValue. Buffer to\r
+ be set is returned. The content of the buffer could be \r
+ overwritten if a Callback on SET is registered with this\r
+ TokenNumber.\r
+ \r
+ If SizeOfValue is greater than the maximum \r
+ size support by TokenNumber, then set SizeOfValue to the \r
+ maximum size supported by TokenNumber and return NULL to \r
+ indicate that the set operation was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
+ @param[in,out] SizeOfBuffer The size, in bytes, of Buffer.\r
@param[in] Value A pointer to the buffer to set.\r
\r
@retval VOID* Return the pointer for the buffer been set.\r
VOID *\r
EFIAPI\r
LibPcdSetPtr (\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Buffer\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
)\r
{\r
EFI_STATUS Status;\r
- PCD_PPI * PcdPpi;\r
+ PCD_PPI *PcdPpi;\r
+ UINTN Size;\r
\r
PcdPpi = GetPcdPpiPtr ();\r
+ \r
+ ASSERT ((*SizeOfBuffer > 0) && Buffer == NULL);\r
\r
+ Size = LibPcdGetSize (TokenNumber);\r
+ \r
+ if (*SizeOfBuffer > Size) {\r
+ *SizeOfBuffer = Size;\r
+ return NULL;\r
+ }\r
\r
- Status = PcdPpi->SetPtr (TokenNumber, SizeOfBuffer, Buffer);\r
+ Status = PcdPpi->SetPtr (TokenNumber, *SizeOfBuffer, Buffer);\r
\r
ASSERT_EFI_ERROR (Status);\r
\r
\r
\r
/**\r
- Sets a buffer for the token specified by TokenNumber and \r
- Guid to the value specified by Value. Value is returned.\r
- If Guid is NULL, then ASSERT().\r
- If Value is NULL, then ASSERT().\r
+ Sets a buffer for the token specified by TokenNumber to the value specified by \r
+ Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than \r
+ the maximum size support by TokenNumber, then set SizeOfValue to the maximum size \r
+ supported by TokenNumber and return NULL to indicate that the set operation \r
+ was not actually performed. \r
+ \r
+ If SizeOfValue > 0 and Buffer is NULL, then ASSERT().\r
\r
@param[in] Guid Pointer to a 128-bit unique value that \r
designates which namespace to set a value from.\r
@param[in] TokenNumber The PCD token number to set a current value for.\r
- @param[in] Value The 8-bit value to set.\r
+ @param[in, out] SizeOfBuffer The size, in bytes, of Buffer.\r
+ @param[in] Buffer A pointer to the buffer to set.\r
\r
- @retval VOID * Return the value been set.\r
+ @retval VOID * Return the pinter to the buffer been set.\r
\r
**/\r
VOID *\r
EFIAPI\r
LibPcdSetExPtr (\r
- IN CONST GUID *Guid,\r
- IN UINTN TokenNumber,\r
- IN UINTN SizeOfBuffer,\r
- IN VOID *Buffer\r
+ IN CONST GUID *Guid,\r
+ IN UINTN TokenNumber,\r
+ IN OUT UINTN *SizeOfBuffer,\r
+ IN VOID *Buffer\r
)\r
{\r
- EFI_STATUS Status;\r
- PCD_PPI * PcdPpi;\r
+ EFI_STATUS Status;\r
+ PCD_PPI *PcdPpi;\r
+ UINTN Size;\r
\r
PcdPpi = GetPcdPpiPtr ();\r
\r
- Status = PcdPpi->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer);\r
+ Size = LibPcdGetExSize (Guid, TokenNumber);\r
+ if (*SizeOfBuffer > Size) {\r
+ *SizeOfBuffer = Size;\r
+ return NULL;\r
+ }\r
+\r
+ Status = PcdPpi->SetPtrEx (Guid, TokenNumber, *SizeOfBuffer, Buffer);\r
\r
ASSERT_EFI_ERROR (Status);\r
\r
\r
return TokenNumber;\r
}\r
+\r
+\r
+/**\r
+ Retrieves the next PCD token space from a token space specified by Guid.\r
+ Guid of NULL is reserved to mark the default local token namespace on the current\r
+ platform. If Guid is NULL, then the GUID of the first non-local token space of the \r
+ current platform is returned. If Guid is the last non-local token space, \r
+ then NULL is returned. \r
+\r
+ If Guid is not NULL and is not a valid token space in the current platform, then ASSERT().\r
+\r
+\r
+ \r
+ @param[in] Pointer to a 128-bit unique value that designates from which namespace \r
+ to start the search.\r
+\r
+ @retval CONST GUID * The next valid token namespace.\r
+\r
+**/\r
+CONST GUID* \r
+EFIAPI\r
+LibPcdGetNextTokenSpace (\r
+ IN CONST GUID *Guid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ PCD_PPI * PcdPpi;\r
+\r
+ PcdPpi = GetPcdPpiPtr ();\r
+\r
+\r
+ Status = PcdPpi->GetNextTokenSpace (&Guid);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Guid;\r
+}\r
+\r
*/\r
s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.vpdOffset);\r
} else {\r
- s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.value);\r
+ if (t.isByteStreamType()) {\r
+ //\r
+ // Byte stream type input has their own "{" "}", so we won't help to insert.\r
+ //\r
+ s += tab + tab + String.format(" %s ", t.skuData.get(i).value.value);\r
+ } else {\r
+ s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.value);\r
+ }\r
}\r
\r
if (i != t.skuData.size() - 1) {\r
**/ \r
package org.tianocore.build.pcd.entity;\r
\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
import java.util.List;\r
-import java.util.Map;\r
import java.util.UUID;\r
\r
import org.tianocore.build.pcd.exception.EntityException;\r
\r
return false;\r
}\r
+ \r
+ public boolean isByteStreamType () {\r
+ String str = getDynamicDefaultValue();\r
+\r
+ if (str == null) {\r
+ return false;\r
+ }\r
+\r
+ if (datumType == Token.DATUM_TYPE.POINTER &&\r
+ str.startsWith("{") && \r
+ str.endsWith("}")) {\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ \r
+ }\r
\r
public String getStringTypeString () { \r
return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);\r