29 IN CHAR16 *ImplementationID OPTIONAL,
30 OUT VOID **HstiData OPTIONAL,
40 UINTN InfoTypesBufferCount;
43 VOID *InformationBlock;
44 UINTN InformationBlockSize;
47 Status =
gBS->LocateHandleBuffer (
49 &gEfiAdapterInformationProtocolGuid,
54 if (EFI_ERROR (Status)) {
60 InformationBlock =
NULL;
61 InformationBlockSize = 0;
62 for (Index = 0; Index < NoHandles; Index++) {
63 Status =
gBS->HandleProtocol (
65 &gEfiAdapterInformationProtocolGuid,
68 if (EFI_ERROR (Status)) {
75 Status = Aip->GetSupportedTypes (
80 if (EFI_ERROR (Status) || (InfoTypesBuffer ==
NULL) || (InfoTypesBufferCount == 0)) {
85 for (InfoTypesIndex = 0; InfoTypesIndex < InfoTypesBufferCount; InfoTypesIndex++) {
86 if (
CompareGuid (&InfoTypesBuffer[InfoTypesIndex], &gAdapterInfoPlatformSecurityGuid)) {
94 if (AipCandidate ==
NULL) {
102 Status = Aip->GetInformation (
104 &gAdapterInfoPlatformSecurityGuid,
106 &InformationBlockSize
108 if (EFI_ERROR (Status)) {
112 Hsti = InformationBlock;
113 if ((Hsti->Role == Role) &&
114 ((ImplementationID ==
NULL) || (
StrCmp (ImplementationID, Hsti->ImplementationID) == 0)))
130 if (HstiData !=
NULL) {
131 *HstiData = InformationBlock;
134 if (HstiSize !=
NULL) {
135 *HstiSize = InformationBlockSize;
160 UINTN ErrorStringSize;
161 UINTN ErrorStringLength;
168 if (HstiData ==
NULL) {
169 DEBUG ((DEBUG_ERROR,
"HstiData == NULL\n"));
174 DEBUG ((DEBUG_ERROR,
"HstiSize < sizeof(ADAPTER_INFO_PLATFORM_SECURITY)\n"));
179 DEBUG ((DEBUG_ERROR,
"((HstiSize - sizeof(ADAPTER_INFO_PLATFORM_SECURITY)) / 3) < SecurityFeaturesSize\n"));
186 if (Hsti->Version != PLATFORM_SECURITY_VERSION_VNEXTCS) {
187 DEBUG ((DEBUG_ERROR,
"Version != PLATFORM_SECURITY_VERSION_VNEXTCS\n"));
194 if ((Hsti->Role < PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE) ||
195 (Hsti->Role > PLATFORM_SECURITY_ROLE_IMPLEMENTOR_ODM))
197 DEBUG ((DEBUG_ERROR,
"Role < PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE ||\n"));
198 DEBUG ((DEBUG_ERROR,
"Role > PLATFORM_SECURITY_ROLE_IMPLEMENTOR_ODM\n"));
205 for (Index = 0; Index <
sizeof (Hsti->ImplementationID)/
sizeof (Hsti->ImplementationID[0]); Index++) {
206 if (Hsti->ImplementationID[Index] == 0) {
211 if (Index ==
sizeof (Hsti->ImplementationID)/
sizeof (Hsti->ImplementationID[0])) {
212 DEBUG ((DEBUG_ERROR,
"ImplementationID has no NUL CHAR\n"));
222 if (ErrorStringSize == 0) {
223 DEBUG ((DEBUG_ERROR,
"ErrorStringSize == 0\n"));
227 if ((ErrorStringSize & BIT0) != 0) {
228 DEBUG ((DEBUG_ERROR,
"(ErrorStringSize & BIT0) != 0\n"));
235 CopyMem (&ErrorChar, ErrorString,
sizeof (ErrorChar));
236 for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringSize/2)); ErrorStringLength++) {
238 CopyMem (&ErrorChar, ErrorString,
sizeof (ErrorChar));
244 if (ErrorChar != 0) {
245 DEBUG ((DEBUG_ERROR,
"ErrorString has no NUL CHAR\n"));
249 if (ErrorStringLength == (ErrorStringSize/2)) {
250 DEBUG ((DEBUG_ERROR,
"ErrorString Length incorrect\n"));
285 CHAR16 *ImplementationID;
286 UINT32 SecurityFeaturesSize;
287 UINT8 *SecurityFeaturesRequired;
290 return EFI_VOLUME_CORRUPTED;
297 return EFI_ALREADY_STARTED;
301 if (HstiAip ==
NULL) {
302 return EFI_OUT_OF_RESOURCES;
306 if (HstiAip->Hsti ==
NULL) {
308 return EFI_OUT_OF_RESOURCES;
311 if (Role != PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE) {
314 ZeroMem (SecurityFeaturesRequired, SecurityFeaturesSize);
317 HstiAip->Signature = HSTI_AIP_PRIVATE_SIGNATURE;
319 HstiAip->HstiSize = HstiSize;
320 HstiAip->HstiMaxSize = HstiSize;
323 Status =
gBS->InstallMultipleProtocolInterfaces (
325 &gEfiAdapterInformationProtocolGuid,
329 if (EFI_ERROR (Status)) {
357 IN CHAR16 *ImplementationID OPTIONAL,
366 return EFI_NOT_FOUND;
392 IN CHAR16 *ImplementationID OPTIONAL,
401 UINT8 *SecurityFeaturesVerified;
406 return EFI_NOT_STARTED;
409 if (ByteIndex >= Hsti->SecurityFeaturesSize) {
410 return EFI_UNSUPPORTED;
416 SecurityFeaturesVerified[ByteIndex] = (UINT8)(SecurityFeaturesVerified[ByteIndex] | (Bit));
418 SecurityFeaturesVerified[ByteIndex] = (UINT8)(SecurityFeaturesVerified[ByteIndex] & (~Bit));
421 Status = Aip->SetInformation (
423 &gAdapterInfoPlatformSecurityGuid,
450 IN CHAR16 *ImplementationID OPTIONAL,
483 IN CHAR16 *ImplementationID OPTIONAL,
516 IN CHAR16 *ImplementationID OPTIONAL,
517 IN CHAR16 *ErrorString,
532 return EFI_NOT_STARTED;
536 Offset = HstiSize -
sizeof (CHAR16);
541 StringSize =
StrSize (ErrorString);
543 NewHstiSize = Offset + StringSize;
545 if (NewHsti ==
NULL) {
546 return EFI_OUT_OF_RESOURCES;
549 CopyMem (NewHsti, Hsti, Offset);
550 CopyMem ((UINT8 *)NewHsti + Offset, ErrorString, StringSize);
552 Status = Aip->SetInformation (
554 &gAdapterInfoPlatformSecurityGuid,
581 IN CHAR16 *ImplementationID OPTIONAL,
582 IN CHAR16 *ErrorString
611 IN CHAR16 *ImplementationID OPTIONAL,
612 IN CHAR16 *ErrorString
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS EFIAPI HstiLibGetTable(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, OUT VOID **Hsti, OUT UINTN *HstiSize)
EFI_STATUS EFIAPI HstiLibSetErrorString(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN CHAR16 *ErrorString)
EFI_STATUS EFIAPI HstiLibClearFeaturesVerified(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN UINT32 ByteIndex, IN UINT8 BitMask)
EFI_STATUS EFIAPI HstiLibAppendErrorString(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN CHAR16 *ErrorString)
BOOLEAN InternalHstiIsValidTable(IN VOID *HstiData, IN UINTN HstiSize)
EFI_STATUS InternalHstiRecordErrorString(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN CHAR16 *ErrorString, IN BOOLEAN Append)
EFI_STATUS InternalHstiRecordFeaturesVerified(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN UINT32 ByteIndex, IN UINT8 Bit, IN BOOLEAN Set)
EFI_STATUS EFIAPI HstiLibSetFeaturesVerified(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN UINT32 ByteIndex, IN UINT8 BitMask)
VOID * InternalHstiFindAip(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, OUT VOID **HstiData OPTIONAL, OUT UINTN *HstiSize OPTIONAL)
EFI_STATUS EFIAPI HstiLibSetTable(IN VOID *Hsti, IN UINTN HstiSize)
#define DEBUG(Expression)
EFI_STATUS EFIAPI Set(IN EMBEDDED_GPIO *This, IN EMBEDDED_GPIO_PIN Gpio, IN EMBEDDED_GPIO_MODE Mode)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)