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