Resolve buffer check overrun issue.
[mirror_edk2.git] / MdePkg / Library / DxeHstiLib / HstiDxe.c
CommitLineData
aaedfe3c
JY
1/** @file\r
2\r
3 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
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
aaedfe3c
JY
209 DEBUG ((EFI_D_ERROR, "ImplementationID is no NUL CHAR\n"));\r
210 return FALSE;\r
211 }\r
212\r
213 ErrorStringSize = HstiSize - sizeof(ADAPTER_INFO_PLATFORM_SECURITY) - Hsti->SecurityFeaturesSize * 3;\r
214 ErrorString = (CHAR16 *)((UINTN)Hsti + sizeof(ADAPTER_INFO_PLATFORM_SECURITY) - Hsti->SecurityFeaturesSize * 3);\r
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
300 if (HstiAip == NULL) {\r
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
419 return Status;\r
420}\r
421\r
422/**\r
423 Set FeaturesVerified in published HSTI table.\r
424 This API will update the HSTI table with indicated Role and ImplementationID,\r
425 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
426\r
427 @param Role Role of HSTI data.\r
428 @param ImplementationID ImplementationID of HSTI data.\r
429 NULL means find the first one match Role.\r
430 @param ByteIndex Byte index of FeaturesVerified of HSTI data.\r
431 @param BitMask Bit mask of FeaturesVerified of HSTI data.\r
432\r
433 @retval EFI_SUCCESS The FeaturesVerified of HSTI data updated in AIP protocol.\r
434 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
435 @retval EFI_UNSUPPORTED The ByteIndex is invalid.\r
436**/\r
437EFI_STATUS\r
438EFIAPI\r
439HstiLibSetFeaturesVerified (\r
440 IN UINT32 Role,\r
441 IN CHAR16 *ImplementationID, OPTIONAL\r
442 IN UINT32 ByteIndex,\r
443 IN UINT8 BitMask\r
444 )\r
445{\r
446 return InternalHstiRecordFeaturesVerified (\r
447 Role,\r
448 ImplementationID,\r
449 ByteIndex,\r
450 BitMask,\r
451 TRUE\r
452 );\r
453}\r
454\r
455/**\r
456 Clear FeaturesVerified in published HSTI table.\r
457 This API will update the HSTI table with indicated Role and ImplementationID,\r
458 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
459\r
460 @param Role Role of HSTI data.\r
461 @param ImplementationID ImplementationID of HSTI data.\r
462 NULL means find the first one match Role.\r
463 @param ByteIndex Byte index of FeaturesVerified of HSTI data.\r
464 @param BitMask Bit mask of FeaturesVerified of HSTI data.\r
465\r
466 @retval EFI_SUCCESS The FeaturesVerified of HSTI data updated in AIP protocol.\r
467 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
468 @retval EFI_UNSUPPORTED The ByteIndex is invalid.\r
469**/\r
470EFI_STATUS\r
471EFIAPI\r
472HstiLibClearFeaturesVerified (\r
473 IN UINT32 Role,\r
474 IN CHAR16 *ImplementationID, OPTIONAL\r
475 IN UINT32 ByteIndex,\r
476 IN UINT8 BitMask\r
477 )\r
478{\r
479 return InternalHstiRecordFeaturesVerified (\r
480 Role,\r
481 ImplementationID,\r
482 ByteIndex,\r
483 BitMask,\r
484 FALSE\r
485 );\r
486}\r
487\r
488/**\r
489 Record ErrorString in published HSTI table.\r
490 This API will update the HSTI table with indicated Role and ImplementationID,\r
491 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
492\r
493 @param Role Role of HSTI data.\r
494 @param ImplementationID ImplementationID of HSTI data.\r
495 NULL means find the first one match Role.\r
496 @param ErrorString ErrorString of HSTI data.\r
497 @param Append TRUE means to append the ErrorString to HSTI table.\r
498 FALSE means to set the ErrorString in HSTI table.\r
499\r
500 @retval EFI_SUCCESS The ErrorString of HSTI data is published in AIP protocol.\r
501 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
502 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.\r
503**/\r
504EFI_STATUS\r
505InternalHstiRecordErrorString (\r
506 IN UINT32 Role,\r
507 IN CHAR16 *ImplementationID, OPTIONAL\r
508 IN CHAR16 *ErrorString,\r
509 IN BOOLEAN Append\r
510 )\r
511{\r
512 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;\r
513 ADAPTER_INFO_PLATFORM_SECURITY *Hsti;\r
514 UINTN HstiSize;\r
515 UINTN StringSize;\r
516 VOID *NewHsti;\r
517 UINTN NewHstiSize;\r
518 UINTN Offset;\r
519 EFI_STATUS Status;\r
520\r
6a39a6a1 521 Aip = InternalHstiFindAip (Role, ImplementationID, (VOID **)&Hsti, &HstiSize);\r
aaedfe3c
JY
522 if (Aip == NULL) {\r
523 return EFI_NOT_STARTED;\r
524 }\r
525\r
526 if (Append) {\r
527 Offset = HstiSize - sizeof(CHAR16);\r
528 } else {\r
529 Offset = sizeof(ADAPTER_INFO_PLATFORM_SECURITY) + Hsti->SecurityFeaturesSize * 3;\r
530 }\r
531 StringSize = StrSize (ErrorString);\r
532\r
533 NewHstiSize = Offset + StringSize;\r
534 NewHsti = AllocatePool (NewHstiSize);\r
535 if (NewHsti == NULL) {\r
536 return EFI_OUT_OF_RESOURCES;\r
537 }\r
538\r
539 CopyMem (NewHsti, Hsti, Offset);\r
540 CopyMem ((UINT8 *)NewHsti + Offset, ErrorString, StringSize);\r
541\r
542 Status = Aip->SetInformation (\r
543 Aip,\r
544 &gAdapterInfoPlatformSecurityGuid,\r
545 NewHsti,\r
546 NewHstiSize\r
547 );\r
548 return Status;\r
549}\r
550\r
551/**\r
552 Append ErrorString in published HSTI table.\r
553 This API will update the HSTI table with indicated Role and ImplementationID,\r
554 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
555\r
556 @param Role Role of HSTI data.\r
557 @param ImplementationID ImplementationID of HSTI data.\r
558 NULL means find the first one match Role.\r
559 @param ErrorString ErrorString of HSTI data.\r
560\r
561 @retval EFI_SUCCESS The ErrorString of HSTI data is updated in AIP protocol.\r
562 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
563 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.\r
564**/\r
565EFI_STATUS\r
566EFIAPI\r
567HstiLibAppendErrorString (\r
568 IN UINT32 Role,\r
569 IN CHAR16 *ImplementationID, OPTIONAL\r
570 IN CHAR16 *ErrorString\r
571 )\r
572{\r
573 return InternalHstiRecordErrorString (\r
574 Role,\r
575 ImplementationID,\r
576 ErrorString,\r
577 TRUE\r
578 );\r
579}\r
580\r
581/**\r
582 Set a new ErrorString in published HSTI table.\r
583 This API will update the HSTI table with indicated Role and ImplementationID,\r
584 NULL ImplementationID means to find the first HSTI table with indicated Role.\r
585\r
586 @param Role Role of HSTI data.\r
587 @param ImplementationID ImplementationID of HSTI data.\r
588 NULL means find the first one match Role.\r
589 @param ErrorString ErrorString of HSTI data.\r
590\r
591 @retval EFI_SUCCESS The ErrorString of HSTI data is updated in AIP protocol.\r
592 @retval EFI_NOT_STARTED There is not HSTI table with the Role and ImplementationID published in system.\r
593 @retval EFI_OUT_OF_RESOURCES There is not enough system resource to update ErrorString.\r
594**/\r
595EFI_STATUS\r
596EFIAPI\r
597HstiLibSetErrorString (\r
598 IN UINT32 Role,\r
599 IN CHAR16 *ImplementationID, OPTIONAL\r
600 IN CHAR16 *ErrorString\r
601 )\r
602{\r
603 return InternalHstiRecordErrorString (\r
604 Role,\r
605 ImplementationID,\r
606 ErrorString,\r
607 FALSE\r
608 );\r
609}\r