]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeHstiLib/HstiDxe.c
MdePkg: Change use of EFI_D_* to DEBUG_*
[mirror_edk2.git] / MdePkg / Library / DxeHstiLib / HstiDxe.c
CommitLineData
aaedfe3c
JY
1/** @file\r
2\r
ebe8ef86 3 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 4 SPDX-License-Identifier: BSD-2-Clause-Patent\r
aaedfe3c
JY
5\r
6**/\r
7\r
8#include "HstiDxe.h"\r
9\r
10/**\r
11 Find HSTI table in AIP protocol, and return the data.\r
12 This API will return the HSTI table with indicated Role and ImplementationID,\r
13 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
14\r
15 @param Role Role of HSTI data.\r
16 @param ImplementationID ImplementationID of HSTI data.\r
17 NULL means find the first one match Role.\r
18 @param HstiData HSTI data. This buffer is allocated by callee, and it\r
19 is the responsibility of the caller to free it after\r
20 using it.\r
21 @param HstiSize HSTI size\r
22\r
23 @return Aip The AIP protocol having this HSTI.\r
24 @return NULL There is not HSTI table with the Role and ImplementationID published in system.\r
25**/\r
26VOID *\r
27InternalHstiFindAip (\r
28 IN UINT32 Role,\r
29 IN CHAR16 *ImplementationID OPTIONAL,\r
30 OUT VOID **HstiData OPTIONAL,\r
31 OUT UINTN *HstiSize OPTIONAL\r
32 )\r
33{\r
34 EFI_STATUS Status;\r
35 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
36 UINTN NoHandles;\r
37 EFI_HANDLE *Handles;\r
38 UINTN Index;\r
39 EFI_GUID *InfoTypesBuffer;\r
40 UINTN InfoTypesBufferCount;\r
41 UINTN InfoTypesIndex;\r
42 EFI_ADAPTER_INFORMATION_PROTOCOL *AipCandidate;\r
43 VOID *InformationBlock;\r
44 UINTN InformationBlockSize;\r
45 ADAPTER_INFO_PLATFORM_SECURITY *Hsti;\r
46\r
47 Status = gBS->LocateHandleBuffer (\r
48 ByProtocol,\r
49 &gEfiAdapterInformationProtocolGuid,\r
50 NULL,\r
51 &NoHandles,\r
52 &Handles\r
53 );\r
54 if (EFI_ERROR (Status)) {\r
55 return NULL;\r
56 }\r
57\r
58 Hsti = NULL;\r
59 Aip = NULL;\r
60 InformationBlock = NULL;\r
61 InformationBlockSize = 0;\r
62 for (Index = 0; Index < NoHandles; Index++) {\r
63 Status = gBS->HandleProtocol (\r
64 Handles[Index],\r
65 &gEfiAdapterInformationProtocolGuid,\r
66 (VOID **)&Aip\r
67 );\r
68 if (EFI_ERROR (Status)) {\r
69 continue;\r
70 }\r
71\r
72 //\r
73 // Check AIP\r
74 //\r
75 Status = Aip->GetSupportedTypes (\r
76 Aip,\r
77 &InfoTypesBuffer,\r
78 &InfoTypesBufferCount\r
79 );\r
17f8c9e9 80 if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL) || (InfoTypesBufferCount == 0)) {\r
aaedfe3c
JY
81 continue;\r
82 }\r
83\r
84 AipCandidate = NULL;\r
85 for (InfoTypesIndex = 0; InfoTypesIndex < InfoTypesBufferCount; InfoTypesIndex++) {\r
86 if (CompareGuid (&InfoTypesBuffer[InfoTypesIndex], &gAdapterInfoPlatformSecurityGuid)) {\r
87 AipCandidate = Aip;\r
88 break;\r
89 }\r
90 }\r
91 FreePool (InfoTypesBuffer);\r
92\r
93 if (AipCandidate == NULL) {\r
94 continue;\r
95 }\r
96\r
97 //\r
98 // Check HSTI Role\r
99 //\r
100 Aip = AipCandidate;\r
101 Status = Aip->GetInformation (\r
102 Aip,\r
103 &gAdapterInfoPlatformSecurityGuid,\r
104 &InformationBlock,\r
105 &InformationBlockSize\r
106 );\r
107 if (EFI_ERROR (Status)) {\r
108 continue;\r
109 }\r
110\r
111 Hsti = InformationBlock;\r
9095d37b 112 if ((Hsti->Role == Role) &&\r
aaedfe3c
JY
113 ((ImplementationID == NULL) || (StrCmp (ImplementationID, Hsti->ImplementationID) == 0))) {\r
114 break;\r
115 } else {\r
116 Hsti = NULL;\r
117 FreePool (InformationBlock);\r
118 continue;\r
119 }\r
120 }\r
121 FreePool (Handles);\r
122\r
123 if (Hsti == NULL) {\r
124 return NULL;\r
125 }\r
126\r
127 if (HstiData != NULL) {\r
128 *HstiData = InformationBlock;\r
129 }\r
130 if (HstiSize != NULL) {\r
131 *HstiSize = InformationBlockSize;\r
132 }\r
133 return Aip;\r
134}\r
135\r
136/**\r
137 Return if input HSTI data follows HSTI specification.\r
138\r
139 @param HstiData HSTI data\r
140 @param HstiSize HSTI size\r
141\r
142 @retval TRUE HSTI data follows HSTI specification.\r
143 @retval FALSE HSTI data does not follow HSTI specification.\r
144**/\r
145BOOLEAN\r
146InternalHstiIsValidTable (\r
147 IN VOID *HstiData,\r
148 IN UINTN HstiSize\r
149 )\r
150{\r
151 ADAPTER_INFO_PLATFORM_SECURITY *Hsti;\r
152 UINTN Index;\r
153 CHAR16 *ErrorString;\r
154 CHAR16 ErrorChar;\r
155 UINTN ErrorStringSize;\r
156 UINTN ErrorStringLength;\r
157\r
158 Hsti = HstiData;\r
159\r
160 //\r
161 // basic check for header\r
162 //\r
163 if (HstiData == NULL) {\r
5f289f3a 164 DEBUG ((DEBUG_ERROR, "HstiData == NULL\n"));\r
aaedfe3c
JY
165 return FALSE;\r
166 }\r
167 if (HstiSize < sizeof(ADAPTER_INFO_PLATFORM_SECURITY)) {\r
5f289f3a 168 DEBUG ((DEBUG_ERROR, "HstiSize < sizeof(ADAPTER_INFO_PLATFORM_SECURITY)\n"));\r
aaedfe3c
JY
169 return FALSE;\r
170 }\r
171 if (((HstiSize - sizeof(ADAPTER_INFO_PLATFORM_SECURITY)) / 3) < Hsti->SecurityFeaturesSize) {\r
5f289f3a 172 DEBUG ((DEBUG_ERROR, "((HstiSize - sizeof(ADAPTER_INFO_PLATFORM_SECURITY)) / 3) < SecurityFeaturesSize\n"));\r
aaedfe3c
JY
173 return FALSE;\r
174 }\r
175\r
176 //\r
177 // Check Version\r
178 //\r
179 if (Hsti->Version != PLATFORM_SECURITY_VERSION_VNEXTCS) {\r
5f289f3a 180 DEBUG ((DEBUG_ERROR, "Version != PLATFORM_SECURITY_VERSION_VNEXTCS\n"));\r
aaedfe3c
JY
181 return FALSE;\r
182 }\r
183\r
184 //\r
185 // Check Role\r
186 //\r
187 if ((Hsti->Role < PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE) ||\r
188 (Hsti->Role > PLATFORM_SECURITY_ROLE_IMPLEMENTOR_ODM)) {\r
5f289f3a
MK
189 DEBUG ((DEBUG_ERROR, "Role < PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE ||\n"));\r
190 DEBUG ((DEBUG_ERROR, "Role > PLATFORM_SECURITY_ROLE_IMPLEMENTOR_ODM\n"));\r
aaedfe3c
JY
191 return FALSE;\r
192 }\r
193\r
194 //\r
195 // Check ImplementationID\r
196 //\r
57ce74ac 197 for (Index = 0; Index < sizeof(Hsti->ImplementationID)/sizeof(Hsti->ImplementationID[0]); Index++) {\r
aaedfe3c
JY
198 if (Hsti->ImplementationID[Index] == 0) {\r
199 break;\r
200 }\r
201 }\r
57ce74ac 202 if (Index == sizeof(Hsti->ImplementationID)/sizeof(Hsti->ImplementationID[0])) {\r
5f289f3a 203 DEBUG ((DEBUG_ERROR, "ImplementationID has no NUL CHAR\n"));\r
aaedfe3c
JY
204 return FALSE;\r
205 }\r
206\r
207 ErrorStringSize = HstiSize - sizeof(ADAPTER_INFO_PLATFORM_SECURITY) - Hsti->SecurityFeaturesSize * 3;\r
ebe8ef86 208 ErrorString = (CHAR16 *)((UINTN)Hsti + sizeof(ADAPTER_INFO_PLATFORM_SECURITY) + Hsti->SecurityFeaturesSize * 3);\r
aaedfe3c
JY
209\r
210 //\r
211 // basic check for ErrorString\r
212 //\r
213 if (ErrorStringSize == 0) {\r
5f289f3a 214 DEBUG ((DEBUG_ERROR, "ErrorStringSize == 0\n"));\r
aaedfe3c
JY
215 return FALSE;\r
216 }\r
217 if ((ErrorStringSize & BIT0) != 0) {\r
5f289f3a 218 DEBUG ((DEBUG_ERROR, "(ErrorStringSize & BIT0) != 0\n"));\r
aaedfe3c
JY
219 return FALSE;\r
220 }\r
221\r
222 //\r
223 // ErrorString might not be CHAR16 aligned.\r
224 //\r
225 CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));\r
226 for (ErrorStringLength = 0; (ErrorChar != 0) && (ErrorStringLength < (ErrorStringSize/2)); ErrorStringLength++) {\r
227 ErrorString++;\r
228 CopyMem (&ErrorChar, ErrorString, sizeof(ErrorChar));\r
229 }\r
230\r
231 //\r
232 // check the length of ErrorString\r
233 //\r
234 if (ErrorChar != 0) {\r
5f289f3a 235 DEBUG ((DEBUG_ERROR, "ErrorString has no NUL CHAR\n"));\r
aaedfe3c
JY
236 return FALSE;\r
237 }\r
238 if (ErrorStringLength == (ErrorStringSize/2)) {\r
5f289f3a 239 DEBUG ((DEBUG_ERROR, "ErrorString Length incorrect\n"));\r
aaedfe3c
JY
240 return FALSE;\r
241 }\r
242\r
243 return TRUE;\r
244}\r
245\r
246/**\r
247 Publish HSTI table in AIP protocol.\r
248\r
249 One system should have only one PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE.\r
250\r
251 If the Role is NOT PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE,\r
252 SecurityFeaturesRequired field will be ignored.\r
253\r
254 @param Hsti HSTI data\r
255 @param HstiSize HSTI size\r
256\r
257 @retval EFI_SUCCESS The HSTI data is published in AIP protocol.\r
258 @retval EFI_ALREADY_STARTED There is already HSTI table with Role and ImplementationID published in system.\r
259 @retval EFI_VOLUME_CORRUPTED The input HSTI data does not follow HSTI specification.\r
260 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to publish HSTI data in AIP protocol.\r
261**/\r
262EFI_STATUS\r
263EFIAPI\r
264HstiLibSetTable (\r
265 IN VOID *Hsti,\r
266 IN UINTN HstiSize\r
267 )\r
268{\r
269 EFI_STATUS Status;\r
270 EFI_HANDLE Handle;\r
271 HSTI_AIP_PRIVATE_DATA *HstiAip;\r
272 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
273 UINT32 Role;\r
274 CHAR16 *ImplementationID;\r
275 UINT32 SecurityFeaturesSize;\r
276 UINT8 *SecurityFeaturesRequired;\r
277\r
278 if (!InternalHstiIsValidTable (Hsti, HstiSize)) {\r
279 return EFI_VOLUME_CORRUPTED;\r
280 }\r
281\r
282 Role = ((ADAPTER_INFO_PLATFORM_SECURITY *)Hsti)->Role;\r
283 ImplementationID = ((ADAPTER_INFO_PLATFORM_SECURITY *)Hsti)->ImplementationID;\r
284 Aip = InternalHstiFindAip (Role, ImplementationID, NULL, NULL);\r
285 if (Aip != NULL) {\r
286 return EFI_ALREADY_STARTED;\r
287 }\r
288\r
289 HstiAip = AllocateZeroPool (sizeof(HSTI_AIP_PRIVATE_DATA));\r
290 if (HstiAip == NULL) {\r
291 return EFI_OUT_OF_RESOURCES;\r
292 }\r
293 HstiAip->Hsti = AllocateCopyPool (HstiSize, Hsti);\r
d3858e10 294 if (HstiAip->Hsti == NULL) {\r
aaedfe3c
JY
295 FreePool (HstiAip);\r
296 return EFI_OUT_OF_RESOURCES;\r
297 }\r
298 if (Role != PLATFORM_SECURITY_ROLE_PLATFORM_REFERENCE) {\r
299 SecurityFeaturesRequired = (UINT8 *)HstiAip->Hsti + sizeof(ADAPTER_INFO_PLATFORM_SECURITY);\r
300 SecurityFeaturesSize = ((ADAPTER_INFO_PLATFORM_SECURITY *)Hsti)->SecurityFeaturesSize;\r
301 ZeroMem (SecurityFeaturesRequired, SecurityFeaturesSize);\r
302 }\r
303\r
304 HstiAip->Signature = HSTI_AIP_PRIVATE_SIGNATURE;\r
305 CopyMem (&HstiAip->Aip, &mAdapterInformationProtocol, sizeof(EFI_ADAPTER_INFORMATION_PROTOCOL));\r
306 HstiAip->HstiSize = HstiSize;\r
307 HstiAip->HstiMaxSize = HstiSize;\r
9095d37b 308\r
aaedfe3c
JY
309 Handle = NULL;\r
310 Status = gBS->InstallMultipleProtocolInterfaces (\r
311 &Handle,\r
312 &gEfiAdapterInformationProtocolGuid,\r
313 &HstiAip->Aip,\r
314 NULL\r
315 );\r
316 if (EFI_ERROR (Status)) {\r
317 FreePool (HstiAip->Hsti);\r
318 FreePool (HstiAip);\r
319 }\r
320\r
321 return Status;\r
322}\r
323\r
324/**\r
325 Search HSTI table in AIP protocol, and return the data.\r
326 This API will return the HSTI table with indicated Role and ImplementationID,\r
327 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
328\r
329 @param Role Role of HSTI data.\r
330 @param ImplementationID ImplementationID of HSTI data.\r
331 NULL means find the first one match Role.\r
332 @param Hsti HSTI data. This buffer is allocated by callee, and it\r
333 is the responsibility of the caller to free it after\r
334 using it.\r
335 @param HstiSize HSTI size\r
336\r
337 @retval EFI_SUCCESS The HSTI data in AIP protocol is returned.\r
338 @retval EFI_NOT_FOUND There is not HSTI table with the Role and ImplementationID published in system.\r
339**/\r
340EFI_STATUS\r
341EFIAPI\r
342HstiLibGetTable (\r
343 IN UINT32 Role,\r
344 IN CHAR16 *ImplementationID OPTIONAL,\r
345 OUT VOID **Hsti,\r
346 OUT UINTN *HstiSize\r
347 )\r
348{\r
349 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
350\r
351 Aip = InternalHstiFindAip (Role, ImplementationID, Hsti, HstiSize);\r
352 if (Aip == NULL) {\r
353 return EFI_NOT_FOUND;\r
354 }\r
355 return EFI_SUCCESS;\r
356}\r
357\r
358/**\r
359 Record FeaturesVerified in published HSTI table.\r
360 This API will update the HSTI table with indicated Role and ImplementationID,\r
361 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
362\r
363 @param Role Role of HSTI data.\r
364 @param ImplementationID ImplementationID of HSTI data.\r
365 NULL means find the first one match Role.\r
366 @param ByteIndex Byte index of FeaturesVerified of HSTI data.\r
367 @param BitMask Bit mask of FeaturesVerified of HSTI data.\r
368 @param Set TRUE means to set the FeaturesVerified bit.\r
369 FALSE means to clear the FeaturesVerified bit.\r
370\r
371 @retval EFI_SUCCESS The FeaturesVerified of HSTI data updated in AIP protocol.\r
372 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
373 @retval EFI_UNSUPPORTED The ByteIndex is invalid.\r
374**/\r
375EFI_STATUS\r
376InternalHstiRecordFeaturesVerified (\r
377 IN UINT32 Role,\r
378 IN CHAR16 *ImplementationID, OPTIONAL\r
379 IN UINT32 ByteIndex,\r
380 IN UINT8 Bit,\r
381 IN BOOLEAN Set\r
382 )\r
383{\r
384 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
385 ADAPTER_INFO_PLATFORM_SECURITY *Hsti;\r
386 UINTN HstiSize;\r
387 UINT8 *SecurityFeaturesVerified;\r
388 EFI_STATUS Status;\r
389\r
6a39a6a1 390 Aip = InternalHstiFindAip (Role, ImplementationID, (VOID **)&Hsti, &HstiSize);\r
aaedfe3c
JY
391 if (Aip == NULL) {\r
392 return EFI_NOT_STARTED;\r
393 }\r
394\r
395 if (ByteIndex >= Hsti->SecurityFeaturesSize) {\r
396 return EFI_UNSUPPORTED;\r
397 }\r
398\r
399 SecurityFeaturesVerified = (UINT8 *)((UINTN)Hsti + sizeof(ADAPTER_INFO_PLATFORM_SECURITY) + Hsti->SecurityFeaturesSize * 2);\r
400\r
401 if (Set) {\r
402 SecurityFeaturesVerified[ByteIndex] = (UINT8)(SecurityFeaturesVerified[ByteIndex] | (Bit));\r
403 } else {\r
404 SecurityFeaturesVerified[ByteIndex] = (UINT8)(SecurityFeaturesVerified[ByteIndex] & (~Bit));\r
405 }\r
406\r
407 Status = Aip->SetInformation (\r
408 Aip,\r
409 &gAdapterInfoPlatformSecurityGuid,\r
410 Hsti,\r
411 HstiSize\r
412 );\r
357c4825 413 FreePool (Hsti);\r
aaedfe3c
JY
414 return Status;\r
415}\r
416\r
417/**\r
418 Set FeaturesVerified in published HSTI table.\r
419 This API will update the HSTI table with indicated Role and ImplementationID,\r
420 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
421\r
422 @param Role Role of HSTI data.\r
423 @param ImplementationID ImplementationID of HSTI data.\r
424 NULL means find the first one match Role.\r
425 @param ByteIndex Byte index of FeaturesVerified of HSTI data.\r
426 @param BitMask Bit mask of FeaturesVerified of HSTI data.\r
427\r
428 @retval EFI_SUCCESS The FeaturesVerified of HSTI data updated in AIP protocol.\r
429 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
430 @retval EFI_UNSUPPORTED The ByteIndex is invalid.\r
431**/\r
432EFI_STATUS\r
433EFIAPI\r
434HstiLibSetFeaturesVerified (\r
435 IN UINT32 Role,\r
436 IN CHAR16 *ImplementationID, OPTIONAL\r
437 IN UINT32 ByteIndex,\r
438 IN UINT8 BitMask\r
439 )\r
440{\r
441 return InternalHstiRecordFeaturesVerified (\r
442 Role,\r
443 ImplementationID,\r
444 ByteIndex,\r
445 BitMask,\r
446 TRUE\r
447 );\r
448}\r
449\r
450/**\r
451 Clear FeaturesVerified in published HSTI table.\r
452 This API will update the HSTI table with indicated Role and ImplementationID,\r
453 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
454\r
455 @param Role Role of HSTI data.\r
456 @param ImplementationID ImplementationID of HSTI data.\r
457 NULL means find the first one match Role.\r
458 @param ByteIndex Byte index of FeaturesVerified of HSTI data.\r
459 @param BitMask Bit mask of FeaturesVerified of HSTI data.\r
460\r
461 @retval EFI_SUCCESS The FeaturesVerified of HSTI data updated in AIP protocol.\r
462 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
463 @retval EFI_UNSUPPORTED The ByteIndex is invalid.\r
464**/\r
465EFI_STATUS\r
466EFIAPI\r
467HstiLibClearFeaturesVerified (\r
468 IN UINT32 Role,\r
469 IN CHAR16 *ImplementationID, OPTIONAL\r
470 IN UINT32 ByteIndex,\r
471 IN UINT8 BitMask\r
472 )\r
473{\r
474 return InternalHstiRecordFeaturesVerified (\r
475 Role,\r
476 ImplementationID,\r
477 ByteIndex,\r
478 BitMask,\r
479 FALSE\r
480 );\r
481}\r
482\r
483/**\r
484 Record ErrorString in published HSTI table.\r
485 This API will update the HSTI table with indicated Role and ImplementationID,\r
486 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
487\r
488 @param Role Role of HSTI data.\r
489 @param ImplementationID ImplementationID of HSTI data.\r
490 NULL means find the first one match Role.\r
491 @param ErrorString ErrorString of HSTI data.\r
492 @param Append TRUE means to append the ErrorString to HSTI table.\r
493 FALSE means to set the ErrorString in HSTI table.\r
494\r
495 @retval EFI_SUCCESS The ErrorString of HSTI data is published in AIP protocol.\r
496 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
497 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.\r
498**/\r
499EFI_STATUS\r
500InternalHstiRecordErrorString (\r
501 IN UINT32 Role,\r
502 IN CHAR16 *ImplementationID, OPTIONAL\r
503 IN CHAR16 *ErrorString,\r
504 IN BOOLEAN Append\r
505 )\r
506{\r
507 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
508 ADAPTER_INFO_PLATFORM_SECURITY *Hsti;\r
509 UINTN HstiSize;\r
510 UINTN StringSize;\r
511 VOID *NewHsti;\r
512 UINTN NewHstiSize;\r
513 UINTN Offset;\r
514 EFI_STATUS Status;\r
515\r
6a39a6a1 516 Aip = InternalHstiFindAip (Role, ImplementationID, (VOID **)&Hsti, &HstiSize);\r
aaedfe3c
JY
517 if (Aip == NULL) {\r
518 return EFI_NOT_STARTED;\r
519 }\r
520\r
521 if (Append) {\r
522 Offset = HstiSize - sizeof(CHAR16);\r
523 } else {\r
524 Offset = sizeof(ADAPTER_INFO_PLATFORM_SECURITY) + Hsti->SecurityFeaturesSize * 3;\r
525 }\r
526 StringSize = StrSize (ErrorString);\r
527\r
528 NewHstiSize = Offset + StringSize;\r
529 NewHsti = AllocatePool (NewHstiSize);\r
530 if (NewHsti == NULL) {\r
531 return EFI_OUT_OF_RESOURCES;\r
532 }\r
533\r
534 CopyMem (NewHsti, Hsti, Offset);\r
535 CopyMem ((UINT8 *)NewHsti + Offset, ErrorString, StringSize);\r
536\r
537 Status = Aip->SetInformation (\r
538 Aip,\r
539 &gAdapterInfoPlatformSecurityGuid,\r
540 NewHsti,\r
541 NewHstiSize\r
542 );\r
357c4825
SZ
543 FreePool (Hsti);\r
544 FreePool (NewHsti);\r
aaedfe3c
JY
545 return Status;\r
546}\r
547\r
548/**\r
549 Append ErrorString in published HSTI table.\r
550 This API will update the HSTI table with indicated Role and ImplementationID,\r
551 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
552\r
553 @param Role Role of HSTI data.\r
554 @param ImplementationID ImplementationID of HSTI data.\r
555 NULL means find the first one match Role.\r
556 @param ErrorString ErrorString of HSTI data.\r
557\r
558 @retval EFI_SUCCESS The ErrorString of HSTI data is updated in AIP protocol.\r
559 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
560 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.\r
561**/\r
562EFI_STATUS\r
563EFIAPI\r
564HstiLibAppendErrorString (\r
565 IN UINT32 Role,\r
566 IN CHAR16 *ImplementationID, OPTIONAL\r
567 IN CHAR16 *ErrorString\r
568 )\r
569{\r
570 return InternalHstiRecordErrorString (\r
571 Role,\r
572 ImplementationID,\r
573 ErrorString,\r
574 TRUE\r
575 );\r
576}\r
577\r
578/**\r
579 Set a new ErrorString in published HSTI table.\r
580 This API will update the HSTI table with indicated Role and ImplementationID,\r
581 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
582\r
583 @param Role Role of HSTI data.\r
584 @param ImplementationID ImplementationID of HSTI data.\r
585 NULL means find the first one match Role.\r
586 @param ErrorString ErrorString of HSTI data.\r
587\r
588 @retval EFI_SUCCESS The ErrorString of HSTI data is updated in AIP protocol.\r
589 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
590 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.\r
591**/\r
592EFI_STATUS\r
593EFIAPI\r
594HstiLibSetErrorString (\r
595 IN UINT32 Role,\r
596 IN CHAR16 *ImplementationID, OPTIONAL\r
597 IN CHAR16 *ErrorString\r
598 )\r
599{\r
600 return InternalHstiRecordErrorString (\r
601 Role,\r
602 ImplementationID,\r
603 ErrorString,\r
604 FALSE\r
605 );\r
606}\r