2 The driver binding for VLAN configuration module.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "VlanConfigImpl.h"
11 EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding
= {
12 VlanConfigDriverBindingSupported
,
13 VlanConfigDriverBindingStart
,
14 VlanConfigDriverBindingStop
,
21 The entry point for IP4 config driver which install the driver
22 binding and component name protocol on its image.
24 @param[in] ImageHandle The image handle of the driver.
25 @param[in] SystemTable The system table.
27 @retval EFI_SUCCES All the related protocols are installed on the driver.
28 @retval Others Failed to install protocols.
33 VlanConfigDriverEntryPoint (
34 IN EFI_HANDLE ImageHandle
,
35 IN EFI_SYSTEM_TABLE
*SystemTable
38 return EfiLibInstallDriverBindingComponentName2 (
41 &gVlanConfigDriverBinding
,
43 &gVlanConfigComponentName
,
44 &gVlanConfigComponentName2
50 Test to see if this driver supports ControllerHandle.
52 @param[in] This Protocol instance pointer.
53 @param[in] ControllerHandle Handle of device to test
54 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
57 @retval EFI_SUCCES This driver supports this device
58 @retval EFI_ALREADY_STARTED This driver is already running on this device
59 @retval other This driver does not support this device
64 VlanConfigDriverBindingSupported (
65 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
66 IN EFI_HANDLE ControllerHandle
,
67 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
71 EFI_VLAN_CONFIG_PROTOCOL
*VlanConfig
;
73 Status
= gBS
->OpenProtocol (
75 &gEfiVlanConfigProtocolGuid
,
76 (VOID
**) &VlanConfig
,
77 This
->DriverBindingHandle
,
79 EFI_OPEN_PROTOCOL_BY_DRIVER
81 if (EFI_ERROR (Status
)) {
86 // Close the VlanConfig protocol opened for supported test
90 &gEfiVlanConfigProtocolGuid
,
91 This
->DriverBindingHandle
,
100 Start this driver on ControllerHandle.
102 @param[in] This Protocol instance pointer.
103 @param[in] ControllerHandle Handle of device to bind driver to
104 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
107 @retval EFI_SUCCES This driver is added to ControllerHandle
108 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
109 @retval other This driver does not support this device
114 VlanConfigDriverBindingStart (
115 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
116 IN EFI_HANDLE ControllerHandle
,
117 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
121 EFI_VLAN_CONFIG_PROTOCOL
*VlanConfig
;
122 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
123 VLAN_CONFIG_PRIVATE_DATA
*PrivateData
;
126 // Check for multiple start
128 Status
= gBS
->OpenProtocol (
131 (VOID
**) &PrivateData
,
132 This
->DriverBindingHandle
,
134 EFI_OPEN_PROTOCOL_GET_PROTOCOL
136 if (!EFI_ERROR (Status
)) {
137 return EFI_ALREADY_STARTED
;
141 // Open VlanConfig protocol by driver
143 Status
= gBS
->OpenProtocol (
145 &gEfiVlanConfigProtocolGuid
,
146 (VOID
**) &VlanConfig
,
147 This
->DriverBindingHandle
,
149 EFI_OPEN_PROTOCOL_BY_DRIVER
151 if (EFI_ERROR (Status
)) {
156 // Get parent device path
158 Status
= gBS
->OpenProtocol (
160 &gEfiDevicePathProtocolGuid
,
161 (VOID
**) &DevicePath
,
162 This
->DriverBindingHandle
,
164 EFI_OPEN_PROTOCOL_GET_PROTOCOL
166 if (EFI_ERROR (Status
)) {
171 // Create a private data for this network device
173 PrivateData
= AllocateCopyPool (sizeof (VLAN_CONFIG_PRIVATE_DATA
), &mVlanConfigPrivateDateTemplate
);
174 if (PrivateData
== NULL
) {
175 Status
= EFI_OUT_OF_RESOURCES
;
179 PrivateData
->ImageHandle
= This
->DriverBindingHandle
;
180 PrivateData
->ControllerHandle
= ControllerHandle
;
181 PrivateData
->VlanConfig
= VlanConfig
;
182 PrivateData
->ParentDevicePath
= DevicePath
;
185 // Install VLAN configuration form
187 Status
= InstallVlanConfigForm (PrivateData
);
188 if (EFI_ERROR (Status
)) {
193 // Install private GUID
195 Status
= gBS
->InstallMultipleProtocolInterfaces (
201 if (EFI_ERROR (Status
)) {
209 &gEfiVlanConfigProtocolGuid
,
210 This
->DriverBindingHandle
,
216 &gEfiDevicePathProtocolGuid
,
217 This
->DriverBindingHandle
,
221 if (PrivateData
!= NULL
) {
222 UninstallVlanConfigForm (PrivateData
);
223 FreePool (PrivateData
);
231 Stop this driver on ControllerHandle.
233 @param[in] This Protocol instance pointer.
234 @param[in] ControllerHandle Handle of device to stop driver on
235 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
236 of children is zero stop the entire bus driver.
237 @param[in] ChildHandleBuffer List of Child Handles to Stop.
239 @retval EFI_SUCCES This driver is removed ControllerHandle
240 @retval other This driver was not removed from this device
245 VlanConfigDriverBindingStop (
246 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
247 IN EFI_HANDLE ControllerHandle
,
248 IN UINTN NumberOfChildren
,
249 IN EFI_HANDLE
*ChildHandleBuffer
253 VLAN_CONFIG_PRIVATE_DATA
*PrivateData
;
256 // Retrieve the PrivateData from ControllerHandle
258 Status
= gBS
->OpenProtocol (
261 (VOID
**) &PrivateData
,
262 This
->DriverBindingHandle
,
264 EFI_OPEN_PROTOCOL_GET_PROTOCOL
266 if (EFI_ERROR (Status
)) {
269 ASSERT (PrivateData
->Signature
== VLAN_CONFIG_PRIVATE_DATA_SIGNATURE
);
271 if (NumberOfChildren
!= 0) {
272 if (NumberOfChildren
!= 1 || ChildHandleBuffer
[0] != PrivateData
->DriverHandle
) {
273 return EFI_DEVICE_ERROR
;
276 return UninstallVlanConfigForm (PrivateData
);
280 // Uninstall the private GUID
282 Status
= gBS
->UninstallMultipleProtocolInterfaces (
288 if (EFI_ERROR (Status
)) {
292 Status
= gBS
->CloseProtocol (
294 &gEfiVlanConfigProtocolGuid
,
295 This
->DriverBindingHandle
,