TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeRestExLib.c
Go to the documentation of this file.
1
11#include <Uefi.h>
13#include <Library/DebugLib.h>
15#include <Library/NetLib.h>
17#include <Protocol/Http.h>
18#include <Protocol/RestEx.h>
19
20#define REST_EX_CONFIG_DATA_LEN_UNKNOWN 0xff
21
39 IN EFI_HANDLE Controller,
40 IN EFI_HANDLE Image,
41 IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode,
42 IN EFI_REST_EX_CONFIG_TYPE ConfigType,
43 IN EFI_REST_EX_SERVICE_TYPE ServiceType,
44 OUT EFI_HANDLE *ChildInstanceHandle
45 )
46{
47 EFI_STATUS Status;
48 EFI_HANDLE ChildHandle;
50 EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
51 UINT8 LenOfConfig;
52
53 if ((Image == NULL) ||
54 (AccessMode >= EfiRestExServiceModeMax) ||
55 (ConfigType >= EfiRestExConfigTypeMax) ||
56 (ServiceType >= EfiRestExServiceTypeMax) ||
57 (ChildInstanceHandle == NULL)
58 )
59 {
60 return EFI_INVALID_PARAMETER;
61 }
62
63 *ChildInstanceHandle = NULL;
64
65 ChildHandle = NULL;
67 Controller,
68 Image,
69 &gEfiRestExServiceBindingProtocolGuid,
70 &ChildHandle
71 );
72 if (EFI_ERROR (Status)) {
73 DEBUG ((
74 DEBUG_ERROR,
75 "%a: Failed to create service child - %r \n",
76 __func__,
77 Status
78 ));
79 return Status;
80 }
81
82 Status = gBS->OpenProtocol (
83 ChildHandle,
84 &gEfiRestExProtocolGuid,
85 (VOID **)&RestEx,
86 Image,
87 NULL,
88 EFI_OPEN_PROTOCOL_GET_PROTOCOL
89 );
90 if (EFI_ERROR (Status)) {
91 goto ON_ERROR;
92 }
93
94 //
95 // Get the information of REST service provided by this EFI REST EX driver
96 //
97 Status = RestEx->GetService (
98 RestEx,
99 &RestExServiceInfo
100 );
101 if (EFI_ERROR (Status)) {
102 goto ON_ERROR;
103 }
104
105 //
106 // Check REST EX property.
107 //
108 switch (ConfigType) {
109 case EfiRestExConfigHttp:
110 LenOfConfig = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA);
111 break;
112
113 case EfiRestExConfigUnspecific:
114 LenOfConfig = REST_EX_CONFIG_DATA_LEN_UNKNOWN;
115 break;
116
117 default:
118 goto ON_ERROR;
119 }
120
121 if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
122 (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
123 (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
124 ((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
125 {
126 goto ON_ERROR;
127 }
128
129 //
130 // This is proper REST EX instance.
131 //
132 *ChildInstanceHandle = ChildHandle;
133 return EFI_SUCCESS;
134
135ON_ERROR:;
137 Controller,
138 Image,
139 &gEfiRestExServiceBindingProtocolGuid,
140 ChildHandle
141 );
142 return EFI_NOT_FOUND;
143}
EFI_STATUS RestExLibCreateChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode, IN EFI_REST_EX_CONFIG_TYPE ConfigType, IN EFI_REST_EX_SERVICE_TYPE ServiceType, OUT EFI_HANDLE *ChildInstanceHandle)
Definition: DxeRestExLib.c:38
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
Definition: DxeNetLib.c:1967
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
Definition: DxeNetLib.c:2020
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS