2 The driver binding for VLAN configuration module.
4 Copyright (c) 2009, 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_GUID gVlanConfigPrivateGuid
= VLAN_CONFIG_PRIVATE_GUID
;
20 EFI_DRIVER_BINDING_PROTOCOL gVlanConfigDriverBinding
= {
21 VlanConfigDriverBindingSupported
,
22 VlanConfigDriverBindingStart
,
23 VlanConfigDriverBindingStop
,
30 The entry point for IP4 config driver which install the driver
31 binding and component name protocol on its image.
33 @param[in] ImageHandle The image handle of the driver.
34 @param[in] SystemTable The system table.
36 @retval EFI_SUCCES All the related protocols are installed on the driver.
37 @retval Others Failed to install protocols.
42 VlanConfigDriverEntryPoint (
43 IN EFI_HANDLE ImageHandle
,
44 IN EFI_SYSTEM_TABLE
*SystemTable
47 return EfiLibInstallDriverBindingComponentName2 (
50 &gVlanConfigDriverBinding
,
52 &gVlanConfigComponentName
,
53 &gVlanConfigComponentName2
59 Test to see if this driver supports ControllerHandle.
61 @param[in] This Protocol instance pointer.
62 @param[in] ControllerHandle Handle of device to test
63 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
66 @retval EFI_SUCCES This driver supports this device
67 @retval EFI_ALREADY_STARTED This driver is already running on this device
68 @retval other This driver does not support this device
73 VlanConfigDriverBindingSupported (
74 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
75 IN EFI_HANDLE ControllerHandle
,
76 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
80 EFI_VLAN_CONFIG_PROTOCOL
*VlanConfig
;
82 Status
= gBS
->OpenProtocol (
84 &gEfiVlanConfigProtocolGuid
,
85 (VOID
**) &VlanConfig
,
86 This
->DriverBindingHandle
,
88 EFI_OPEN_PROTOCOL_BY_DRIVER
90 if (EFI_ERROR (Status
)) {
95 // Close the VlanConfig protocol opened for supported test
99 &gEfiVlanConfigProtocolGuid
,
100 This
->DriverBindingHandle
,
109 Start this driver on ControllerHandle.
111 @param[in] This Protocol instance pointer.
112 @param[in] ControllerHandle Handle of device to bind driver to
113 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
116 @retval EFI_SUCCES This driver is added to ControllerHandle
117 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
118 @retval other This driver does not support this device
123 VlanConfigDriverBindingStart (
124 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
125 IN EFI_HANDLE ControllerHandle
,
126 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
130 EFI_VLAN_CONFIG_PROTOCOL
*VlanConfig
;
131 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
132 VLAN_CONFIG_PRIVATE_DATA
*PrivateData
;
135 // Check for multiple start
137 Status
= gBS
->OpenProtocol (
139 &gVlanConfigPrivateGuid
,
140 (VOID
**) &PrivateData
,
141 This
->DriverBindingHandle
,
143 EFI_OPEN_PROTOCOL_GET_PROTOCOL
145 if (!EFI_ERROR (Status
)) {
146 return EFI_ALREADY_STARTED
;
150 // Open VlanConfig protocol by driver
152 Status
= gBS
->OpenProtocol (
154 &gEfiVlanConfigProtocolGuid
,
155 (VOID
**) &VlanConfig
,
156 This
->DriverBindingHandle
,
158 EFI_OPEN_PROTOCOL_BY_DRIVER
160 if (EFI_ERROR (Status
)) {
165 // Get parent device path
167 Status
= gBS
->OpenProtocol (
169 &gEfiDevicePathProtocolGuid
,
170 (VOID
**) &DevicePath
,
171 This
->DriverBindingHandle
,
173 EFI_OPEN_PROTOCOL_GET_PROTOCOL
175 if (EFI_ERROR (Status
)) {
180 // Create a private data for this network device
182 PrivateData
= AllocateCopyPool (sizeof (VLAN_CONFIG_PRIVATE_DATA
), &mVlanConfigPrivateDateTemplate
);
183 if (PrivateData
== NULL
) {
184 Status
= EFI_OUT_OF_RESOURCES
;
188 PrivateData
->ImageHandle
= This
->DriverBindingHandle
;
189 PrivateData
->ControllerHandle
= ControllerHandle
;
190 PrivateData
->VlanConfig
= VlanConfig
;
191 PrivateData
->ParentDevicePath
= DevicePath
;
194 // Install VLAN configuration form
196 Status
= InstallVlanConfigForm (PrivateData
);
197 if (EFI_ERROR (Status
)) {
202 // Install private GUID
204 Status
= gBS
->InstallMultipleProtocolInterfaces (
206 &gVlanConfigPrivateGuid
,
210 if (EFI_ERROR (Status
)) {
218 &gEfiVlanConfigProtocolGuid
,
219 This
->DriverBindingHandle
,
225 &gEfiDevicePathProtocolGuid
,
226 This
->DriverBindingHandle
,
230 if (PrivateData
!= NULL
) {
231 UninstallVlanConfigForm (PrivateData
);
232 FreePool (PrivateData
);
240 Stop this driver on ControllerHandle.
242 @param[in] This Protocol instance pointer.
243 @param[in] ControllerHandle Handle of device to stop driver on
244 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number
245 of children is zero stop the entire bus driver.
246 @param[in] ChildHandleBuffer List of Child Handles to Stop.
248 @retval EFI_SUCCES This driver is removed ControllerHandle
249 @retval other This driver was not removed from this device
254 VlanConfigDriverBindingStop (
255 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
256 IN EFI_HANDLE ControllerHandle
,
257 IN UINTN NumberOfChildren
,
258 IN EFI_HANDLE
*ChildHandleBuffer
262 VLAN_CONFIG_PRIVATE_DATA
*PrivateData
;
265 // Retrieve the PrivateData from ControllerHandle
267 Status
= gBS
->OpenProtocol (
269 &gVlanConfigPrivateGuid
,
270 (VOID
**) &PrivateData
,
271 This
->DriverBindingHandle
,
273 EFI_OPEN_PROTOCOL_GET_PROTOCOL
275 if (EFI_ERROR (Status
)) {
278 ASSERT (PrivateData
->Signature
== VLAN_CONFIG_PRIVATE_DATA_SIGNATURE
);
281 // Uninstall VLAN configuration Form
283 UninstallVlanConfigForm (PrivateData
);
286 // Uninstall the private GUID
288 Status
= gBS
->UninstallMultipleProtocolInterfaces (
290 &gVlanConfigPrivateGuid
,
294 if (EFI_ERROR (Status
)) {
298 Status
= gBS
->CloseProtocol (
300 &gEfiVlanConfigProtocolGuid
,
301 This
->DriverBindingHandle
,