2 The driver binding for VLAN configuration module.
4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The full
8 text of the license may be found at<BR>
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "VlanConfigImpl.h"
18 EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding
= {
19 VlanConfigDriverBindingSupported
,
20 VlanConfigDriverBindingStart
,
21 VlanConfigDriverBindingStop
,
28 The entry point for IP4 config driver which install the driver
29 binding and component name protocol on its image.
31 @param[in] ImageHandle The image handle of the driver.
32 @param[in] SystemTable The system table.
34 @retval EFI_SUCCES All the related protocols are installed on the driver.
35 @retval Others Failed to install protocols.
40 VlanConfigDriverEntryPoint (
41 IN EFI_HANDLE ImageHandle
,
42 IN EFI_SYSTEM_TABLE
*SystemTable
45 return EfiLibInstallDriverBindingComponentName2 (
48 &gVlanConfigDriverBinding
,
50 &gVlanConfigComponentName
,
51 &gVlanConfigComponentName2
57 Test to see if this driver supports ControllerHandle.
59 @param[in] This Protocol instance pointer.
60 @param[in] ControllerHandle Handle of device to test
61 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
64 @retval EFI_SUCCES This driver supports this device
65 @retval EFI_ALREADY_STARTED This driver is already running on this device
66 @retval other This driver does not support this device
71 VlanConfigDriverBindingSupported (
72 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
73 IN EFI_HANDLE ControllerHandle
,
74 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
78 EFI_VLAN_CONFIG_PROTOCOL
*VlanConfig
;
80 Status
= gBS
->OpenProtocol (
82 &gEfiVlanConfigProtocolGuid
,
83 (VOID
**) &VlanConfig
,
84 This
->DriverBindingHandle
,
86 EFI_OPEN_PROTOCOL_BY_DRIVER
88 if (EFI_ERROR (Status
)) {
93 // Close the VlanConfig protocol opened for supported test
97 &gEfiVlanConfigProtocolGuid
,
98 This
->DriverBindingHandle
,
107 Start this driver on ControllerHandle.
109 @param[in] This Protocol instance pointer.
110 @param[in] ControllerHandle Handle of device to bind driver to
111 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
114 @retval EFI_SUCCES This driver is added to ControllerHandle
115 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
116 @retval other This driver does not support this device
121 VlanConfigDriverBindingStart (
122 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
123 IN EFI_HANDLE ControllerHandle
,
124 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
128 EFI_VLAN_CONFIG_PROTOCOL
*VlanConfig
;
129 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
130 VLAN_CONFIG_PRIVATE_DATA
*PrivateData
;
133 // Check for multiple start
135 Status
= gBS
->OpenProtocol (
138 (VOID
**) &PrivateData
,
139 This
->DriverBindingHandle
,
141 EFI_OPEN_PROTOCOL_GET_PROTOCOL
143 if (!EFI_ERROR (Status
)) {
144 return EFI_ALREADY_STARTED
;
148 // Open VlanConfig protocol by driver
150 Status
= gBS
->OpenProtocol (
152 &gEfiVlanConfigProtocolGuid
,
153 (VOID
**) &VlanConfig
,
154 This
->DriverBindingHandle
,
156 EFI_OPEN_PROTOCOL_BY_DRIVER
158 if (EFI_ERROR (Status
)) {
163 // Get parent device path
165 Status
= gBS
->OpenProtocol (
167 &gEfiDevicePathProtocolGuid
,
168 (VOID
**) &DevicePath
,
169 This
->DriverBindingHandle
,
171 EFI_OPEN_PROTOCOL_GET_PROTOCOL
173 if (EFI_ERROR (Status
)) {
178 // Create a private data for this network device
180 PrivateData
= AllocateCopyPool (sizeof (VLAN_CONFIG_PRIVATE_DATA
), &mVlanConfigPrivateDateTemplate
);
181 if (PrivateData
== NULL
) {
182 Status
= EFI_OUT_OF_RESOURCES
;
186 PrivateData
->ImageHandle
= This
->DriverBindingHandle
;
187 PrivateData
->ControllerHandle
= ControllerHandle
;
188 PrivateData
->VlanConfig
= VlanConfig
;
189 PrivateData
->ParentDevicePath
= DevicePath
;
192 // Install VLAN configuration form
194 Status
= InstallVlanConfigForm (PrivateData
);
195 if (EFI_ERROR (Status
)) {
200 // Install private GUID
202 Status
= gBS
->InstallMultipleProtocolInterfaces (
208 if (EFI_ERROR (Status
)) {
216 &gEfiVlanConfigProtocolGuid
,
217 This
->DriverBindingHandle
,
223 &gEfiDevicePathProtocolGuid
,
224 This
->DriverBindingHandle
,
228 if (PrivateData
!= NULL
) {
229 UninstallVlanConfigForm (PrivateData
);
230 FreePool (PrivateData
);
238 Stop this driver on ControllerHandle.
240 @param[in] This Protocol instance pointer.
241 @param[in] ControllerHandle Handle of device to stop driver on
242 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
243 of children is zero stop the entire bus driver.
244 @param[in] ChildHandleBuffer List of Child Handles to Stop.
246 @retval EFI_SUCCES This driver is removed ControllerHandle
247 @retval other This driver was not removed from this device
252 VlanConfigDriverBindingStop (
253 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
254 IN EFI_HANDLE ControllerHandle
,
255 IN UINTN NumberOfChildren
,
256 IN EFI_HANDLE
*ChildHandleBuffer
260 VLAN_CONFIG_PRIVATE_DATA
*PrivateData
;
263 // Retrieve the PrivateData from ControllerHandle
265 Status
= gBS
->OpenProtocol (
268 (VOID
**) &PrivateData
,
269 This
->DriverBindingHandle
,
271 EFI_OPEN_PROTOCOL_GET_PROTOCOL
273 if (EFI_ERROR (Status
)) {
276 ASSERT (PrivateData
->Signature
== VLAN_CONFIG_PRIVATE_DATA_SIGNATURE
);
278 if (NumberOfChildren
!= 0) {
279 if (NumberOfChildren
!= 1 || ChildHandleBuffer
[0] != PrivateData
->DriverHandle
) {
280 return EFI_DEVICE_ERROR
;
283 return UninstallVlanConfigForm (PrivateData
);
287 // Uninstall the private GUID
289 Status
= gBS
->UninstallMultipleProtocolInterfaces (
295 if (EFI_ERROR (Status
)) {
299 Status
= gBS
->CloseProtocol (
301 &gEfiVlanConfigProtocolGuid
,
302 This
->DriverBindingHandle
,