TianoCore EDK2 master
Loading...
Searching...
No Matches
VlanConfigDriver.c
Go to the documentation of this file.
1
9#include "VlanConfigImpl.h"
10
11EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding = {
15 0xa,
16 NULL,
17 NULL
18};
19
32EFIAPI
34 IN EFI_HANDLE ImageHandle,
35 IN EFI_SYSTEM_TABLE *SystemTable
36 )
37{
39 ImageHandle,
40 SystemTable,
41 &gVlanConfigDriverBinding,
42 ImageHandle,
43 &gVlanConfigComponentName,
44 &gVlanConfigComponentName2
45 );
46}
47
62EFIAPI
65 IN EFI_HANDLE ControllerHandle,
66 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
67 )
68{
69 EFI_STATUS Status;
70 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
71
72 Status = gBS->OpenProtocol (
73 ControllerHandle,
74 &gEfiVlanConfigProtocolGuid,
75 (VOID **)&VlanConfig,
76 This->DriverBindingHandle,
77 ControllerHandle,
78 EFI_OPEN_PROTOCOL_BY_DRIVER
79 );
80 if (EFI_ERROR (Status)) {
81 return Status;
82 }
83
84 //
85 // Close the VlanConfig protocol opened for supported test
86 //
87 gBS->CloseProtocol (
88 ControllerHandle,
89 &gEfiVlanConfigProtocolGuid,
90 This->DriverBindingHandle,
91 ControllerHandle
92 );
93
94 return Status;
95}
96
111EFIAPI
114 IN EFI_HANDLE ControllerHandle,
115 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
116 )
117{
118 EFI_STATUS Status;
119 EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
120 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
121 VLAN_CONFIG_PRIVATE_DATA *PrivateData;
122
123 //
124 // Check for multiple start
125 //
126 Status = gBS->OpenProtocol (
127 ControllerHandle,
128 &gEfiCallerIdGuid,
129 (VOID **)&PrivateData,
130 This->DriverBindingHandle,
131 ControllerHandle,
132 EFI_OPEN_PROTOCOL_GET_PROTOCOL
133 );
134 if (!EFI_ERROR (Status)) {
135 return EFI_ALREADY_STARTED;
136 }
137
138 //
139 // Open VlanConfig protocol by driver
140 //
141 Status = gBS->OpenProtocol (
142 ControllerHandle,
143 &gEfiVlanConfigProtocolGuid,
144 (VOID **)&VlanConfig,
145 This->DriverBindingHandle,
146 ControllerHandle,
147 EFI_OPEN_PROTOCOL_BY_DRIVER
148 );
149 if (EFI_ERROR (Status)) {
150 return Status;
151 }
152
153 //
154 // Get parent device path
155 //
156 Status = gBS->OpenProtocol (
157 ControllerHandle,
158 &gEfiDevicePathProtocolGuid,
159 (VOID **)&DevicePath,
160 This->DriverBindingHandle,
161 ControllerHandle,
162 EFI_OPEN_PROTOCOL_GET_PROTOCOL
163 );
164 if (EFI_ERROR (Status)) {
165 goto ErrorExit;
166 }
167
168 //
169 // Create a private data for this network device
170 //
171 PrivateData = AllocateCopyPool (sizeof (VLAN_CONFIG_PRIVATE_DATA), &mVlanConfigPrivateDateTemplate);
172 if (PrivateData == NULL) {
173 Status = EFI_OUT_OF_RESOURCES;
174 goto ErrorExit;
175 }
176
177 PrivateData->ImageHandle = This->DriverBindingHandle;
178 PrivateData->ControllerHandle = ControllerHandle;
179 PrivateData->VlanConfig = VlanConfig;
180 PrivateData->ParentDevicePath = DevicePath;
181
182 //
183 // Install VLAN configuration form
184 //
185 Status = InstallVlanConfigForm (PrivateData);
186 if (EFI_ERROR (Status)) {
187 goto ErrorExit;
188 }
189
190 //
191 // Install private GUID
192 //
193 Status = gBS->InstallMultipleProtocolInterfaces (
194 &ControllerHandle,
195 &gEfiCallerIdGuid,
196 PrivateData,
197 NULL
198 );
199 if (EFI_ERROR (Status)) {
200 goto ErrorExit;
201 }
202
203 return Status;
204
205ErrorExit:
206 gBS->CloseProtocol (
207 ControllerHandle,
208 &gEfiVlanConfigProtocolGuid,
209 This->DriverBindingHandle,
210 ControllerHandle
211 );
212
213 gBS->CloseProtocol (
214 ControllerHandle,
215 &gEfiDevicePathProtocolGuid,
216 This->DriverBindingHandle,
217 ControllerHandle
218 );
219
220 if (PrivateData != NULL) {
221 UninstallVlanConfigForm (PrivateData);
222 FreePool (PrivateData);
223 }
224
225 return Status;
226}
227
242EFIAPI
245 IN EFI_HANDLE ControllerHandle,
246 IN UINTN NumberOfChildren,
247 IN EFI_HANDLE *ChildHandleBuffer
248 )
249{
250 EFI_STATUS Status;
251 VLAN_CONFIG_PRIVATE_DATA *PrivateData;
252
253 //
254 // Retrieve the PrivateData from ControllerHandle
255 //
256 Status = gBS->OpenProtocol (
257 ControllerHandle,
258 &gEfiCallerIdGuid,
259 (VOID **)&PrivateData,
260 This->DriverBindingHandle,
261 ControllerHandle,
262 EFI_OPEN_PROTOCOL_GET_PROTOCOL
263 );
264 if (EFI_ERROR (Status)) {
265 return Status;
266 }
267
268 ASSERT (PrivateData->Signature == VLAN_CONFIG_PRIVATE_DATA_SIGNATURE);
269
270 if (NumberOfChildren != 0) {
271 if ((NumberOfChildren != 1) || (ChildHandleBuffer[0] != PrivateData->DriverHandle)) {
272 return EFI_DEVICE_ERROR;
273 }
274
275 return UninstallVlanConfigForm (PrivateData);
276 }
277
278 //
279 // Uninstall the private GUID
280 //
281 Status = gBS->UninstallMultipleProtocolInterfaces (
282 ControllerHandle,
283 &gEfiCallerIdGuid,
284 PrivateData,
285 NULL
286 );
287 if (EFI_ERROR (Status)) {
288 return Status;
289 }
290
291 Status = gBS->CloseProtocol (
292 ControllerHandle,
293 &gEfiVlanConfigProtocolGuid,
294 This->DriverBindingHandle,
295 ControllerHandle
296 );
297 return Status;
298}
UINT64 UINTN
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI VlanConfigDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI VlanConfigDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI VlanConfigDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI VlanConfigDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS UninstallVlanConfigForm(IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS InstallVlanConfigForm(IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData)