54 (ToStructure ==
NULL) ||
56 (DestroyStructure ==
NULL) ||
57 (JsonStructureSupported ==
NULL)
60 return EFI_INVALID_PARAMETER;
66 ThisList = &JsonStructureSupported->NextSupportedRsrcInterp;
69 if (ThisList->ForwardLink == &JsonStructureSupported->NextSupportedRsrcInterp) {
72 ThisList = ThisList->ForwardLink;
77 DEBUG ((DEBUG_MANAGEABILITY,
"%a: %d REST JSON-C interpreter(s) to register for the name spaces.\n", __func__, NumberOfNS));
81 if (Instance ==
NULL) {
82 return EFI_OUT_OF_RESOURCES;
92 ThisSupportedInterp = JsonStructureSupported;
93 for (Index = 0; Index < NumberOfNS; Index++) {
100 CloneSupportedInterpId++;
128 IN CHAR8 *ResourceRaw,
136 DEBUG ((DEBUG_MANAGEABILITY,
"%a: Entry\n", __func__));
138 if ((This ==
NULL) ||
139 (InterpreterInstance ==
NULL) ||
140 (ResourceRaw ==
NULL) ||
141 (RestJSonHeader ==
NULL)
144 return EFI_INVALID_PARAMETER;
147 Status = EFI_UNSUPPORTED;
148 if (RsrcTypeIdentifier ==
NULL) {
153 Status = InterpreterInstance->JsonToStructure (
159 if (EFI_ERROR (Status)) {
160 if (Status == EFI_UNSUPPORTED) {
163 "%a %a.%a.%a REST JSON to C structure interpreter has no capability to interpret the resource.\n",
164 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.ResourceTypeName,
165 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.MajorVersion,
166 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.MinorVersion,
167 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.ErrataVersion
170 DEBUG ((DEBUG_MANAGEABILITY,
"REST JsonToStructure returns failure - %r\n", Status));
177 ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
178 for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
180 RsrcTypeIdentifier->NameSpace.ResourceTypeName,
184 if ((RsrcTypeIdentifier->NameSpace.MajorVersion ==
NULL) &&
185 (RsrcTypeIdentifier->NameSpace.MinorVersion ==
NULL) &&
186 (RsrcTypeIdentifier->NameSpace.ErrataVersion ==
NULL)
192 Status = InterpreterInstance->JsonToStructure (
198 if (EFI_ERROR (Status)) {
199 DEBUG ((DEBUG_MANAGEABILITY,
"Don't check version of this resource type identifier JsonToStructure returns %r\n", Status));
209 RsrcTypeIdentifier->NameSpace.MajorVersion,
213 RsrcTypeIdentifier->NameSpace.MinorVersion,
217 RsrcTypeIdentifier->NameSpace.ErrataVersion,
221 Status = InterpreterInstance->JsonToStructure (
227 if (EFI_ERROR (Status)) {
228 DEBUG ((DEBUG_MANAGEABILITY,
"Check version of this resource type identifier JsonToStructure returns %r\n", Status));
240 ThisSupportedRsrcTypeId++;
264 OUT CHAR8 **ResourceRaw
272 DEBUG ((DEBUG_MANAGEABILITY,
"%a: Entry\n", __func__));
274 if ((This ==
NULL) ||
275 (InterpreterInstance ==
NULL) ||
276 (RestJSonHeader ==
NULL) ||
277 (ResourceRaw ==
NULL)
280 return EFI_INVALID_PARAMETER;
283 RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
284 if ((RsrcTypeIdentifier ==
NULL) ||
291 return EFI_INVALID_PARAMETER;
297 Status = EFI_UNSUPPORTED;
298 ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
299 for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
321 Status = InterpreterInstance->StructureToJson (
326 if (EFI_ERROR (Status)) {
327 DEBUG ((DEBUG_MANAGEABILITY,
"StructureToJson returns %r\n", Status));
338 ThisSupportedRsrcTypeId++;
366 if ((This ==
NULL) ||
367 (InterpreterInstance ==
NULL) ||
368 (RestJSonHeader ==
NULL)
371 return EFI_INVALID_PARAMETER;
374 Status = EFI_UNSUPPORTED;
378 ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
379 for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
381 RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName,
385 if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion ==
NULL) &&
386 (RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion ==
NULL) &&
387 (RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion ==
NULL)
393 Status = InterpreterInstance->DestroyStructure (
403 RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion,
407 RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion,
411 RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion,
415 Status = InterpreterInstance->DestroyStructure (
424 ThisSupportedRsrcTypeId++;
447 IN CHAR8 *ResourceJsonText,
454 if ((This ==
NULL) ||
455 (ResourceJsonText ==
NULL) ||
456 (JsonStructure ==
NULL)
459 return EFI_INVALID_PARAMETER;
463 return EFI_UNSUPPORTED;
466 if (RsrcTypeIdentifier !=
NULL) {
467 DEBUG ((DEBUG_MANAGEABILITY,
"%a: Looking for the REST JSON to C Structure converter:\n", __func__));
468 if (RsrcTypeIdentifier->NameSpace.ResourceTypeName !=
NULL) {
469 DEBUG ((DEBUG_MANAGEABILITY,
" ResourceType: %a\n", RsrcTypeIdentifier->NameSpace.ResourceTypeName));
471 DEBUG ((DEBUG_MANAGEABILITY,
" ResourceType: NULL"));
474 if (RsrcTypeIdentifier->NameSpace.MajorVersion !=
NULL) {
475 DEBUG ((DEBUG_MANAGEABILITY,
" MajorVersion: %a\n", RsrcTypeIdentifier->NameSpace.MajorVersion));
477 DEBUG ((DEBUG_MANAGEABILITY,
" MajorVersion: NULL"));
480 if (RsrcTypeIdentifier->NameSpace.MinorVersion !=
NULL) {
481 DEBUG ((DEBUG_MANAGEABILITY,
" MinorVersion: %a\n", RsrcTypeIdentifier->NameSpace.MinorVersion));
483 DEBUG ((DEBUG_MANAGEABILITY,
" MinorVersion: NULL"));
486 if (RsrcTypeIdentifier->NameSpace.ErrataVersion !=
NULL) {
487 DEBUG ((DEBUG_MANAGEABILITY,
" ErrataVersion: %a\n", RsrcTypeIdentifier->NameSpace.ErrataVersion));
489 DEBUG ((DEBUG_MANAGEABILITY,
" ErrataVersion: NULL"));
492 DEBUG ((DEBUG_MANAGEABILITY,
"%a: RsrcTypeIdentifier is given as NULL, go through all of the REST JSON to C structure interpreters.\n", __func__));
505 if (!EFI_ERROR (Status)) {
506 DEBUG ((DEBUG_MANAGEABILITY,
"%a: REST JSON to C structure is interpreted successfully.\n", __func__));
511 DEBUG ((DEBUG_ERROR,
"%a: No REST JSON to C structure interpreter found.\n", __func__));
512 Status = EFI_UNSUPPORTED;
543 if ((This ==
NULL) || (RestJSonHeader ==
NULL)) {
544 return EFI_INVALID_PARAMETER;
548 return EFI_UNSUPPORTED;
559 if (!EFI_ERROR (Status)) {
564 DEBUG ((DEBUG_ERROR,
"%a: No REST JSON to C structure interpreter found.\n", __func__));
565 Status = EFI_UNSUPPORTED;
591 OUT CHAR8 **ResourceRaw
598 if ((This ==
NULL) || (RestJSonHeader ==
NULL) || (ResourceRaw ==
NULL)) {
599 return EFI_INVALID_PARAMETER;
603 return EFI_UNSUPPORTED;
606 RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
607 DEBUG ((DEBUG_MANAGEABILITY,
"Looking for the REST C Structure to JSON resource converter:\n"));
622 if (!EFI_ERROR (Status)) {
627 DEBUG ((DEBUG_ERROR,
"%a: No REST C structure to JSON interpreter found.\n", __func__));
628 Status = EFI_UNSUPPORTED;
667 mProtocolHandle =
NULL;
668 Status =
gBS->InstallProtocolInterface (
670 &gEfiRestJsonStructureProtocolGuid,
672 (VOID *)&mRestJsonStructureProtocol
699 Status =
gBS->UninstallProtocolInterface (
701 &gEfiRestJsonStructureProtocolGuid,
702 (VOID *)&mRestJsonStructureProtocol
720 Instance = NextInstance;
721 }
while (Instance !=
NULL);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
BOOLEAN EFIAPI IsNodeAtEnd(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
EFI_STATUS(EFIAPI * EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE)(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_HEADER *JsonStructureHeader)
struct _EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER
EFI_STATUS(EFIAPI * EFI_REST_JSON_STRUCTURE_TO_STRUCTURE)(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *JsonRsrcIdentifier OPTIONAL, IN CHAR8 *ResourceJsonText, OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure)
EFI_STATUS(EFIAPI * EFI_REST_JSON_STRUCTURE_TO_JSON)(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_HEADER *JsonStructureHeader, OUT CHAR8 **ResourceJsonText)
EFI_STATUS EFIAPI RestJsonStructureRegister(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_SUPPORTED *JsonStructureSupported, IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE ToStructure, IN EFI_REST_JSON_STRUCTURE_TO_JSON ToJson, IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure)
EFI_STATUS EFIAPI RestJsonStructureEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI RestJsonStructureToStruct(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL, IN CHAR8 *ResourceJsonText, OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure)
EFI_STATUS EFIAPI RestJsonStructureUnload(IN EFI_HANDLE ImageHandle)
EFI_STATUS InterpreterInstanceDestoryJsonStruct(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader)
EFI_STATUS InterpreterEfiStructToInstance(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, OUT CHAR8 **ResourceRaw)
EFI_STATUS InterpreterInstanceToStruct(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL, IN CHAR8 *ResourceRaw, OUT EFI_REST_JSON_STRUCTURE_HEADER **RestJSonHeader)
EFI_STATUS EFIAPI RestJsonStructureToJson(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, OUT CHAR8 **ResourceRaw)
EFI_STATUS EFIAPI RestJsonStructureDestroyStruct(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader)
EFI_REST_JSON_RESOURCE_TYPE_NAMESPACE NameSpace
Namespace of this resource type.
CHAR8 * ResourceTypeName
Resource type name.
CHAR8 * MinorVersion
Resource minor version.
CHAR8 * ErrataVersion
Resource errata version.
CHAR8 * MajorVersion
Resource major version.
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER RestResourceInterp
JSON resource type this convertor supports.
LIST_ENTRY NextSupportedRsrcInterp
Linklist to next supported conversion.
UINTN NumberOfNameSpaceToConvert
Number of resource type this convertor supports.
EFI_REST_JSON_STRUCTURE_TO_STRUCTURE JsonToStructure
JSON to C structure function.
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER * SupportedRsrcIndentifier
The supported resource type array.
EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure
Destory C struture function.
LIST_ENTRY NextRestJsonStructureInstance
Next convertor instance.
EFI_REST_JSON_STRUCTURE_TO_JSON StructureToJson
C structure to JSON function.