2 Implement the driver binding protocol for the socket layer.
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Verify the controller type
20 Determine if any of the network service binding protocols exist on
21 the controller handle. If so, verify that these protocols are not
22 already in use. Call ::DriverStart for any network service binding
23 protocol that is not in use.
25 @param [in] pThis Protocol instance pointer.
26 @param [in] Controller Handle of device to test.
27 @param [in] pRemainingDevicePath Not used.
29 @retval EFI_SUCCESS This driver supports this device.
30 @retval other This driver does not support this device.
36 IN EFI_DRIVER_BINDING_PROTOCOL
* pThis
,
37 IN EFI_HANDLE Controller
,
38 IN EFI_DEVICE_PATH_PROTOCOL
* pRemainingDevicePath
41 CONST DT_SOCKET_BINDING
* pEnd
;
43 CONST DT_SOCKET_BINDING
* pSocketBinding
;
47 // Assume the list is empty
49 Status
= EFI_UNSUPPORTED
;
52 // Walk the list of network connection points
54 pSocketBinding
= &cEslSocketBinding
[0];
55 pEnd
= &pSocketBinding
[ cEslSocketBindingEntries
];
56 while ( pEnd
> pSocketBinding
) {
58 // Determine if the controller supports the network protocol
60 Status
= gBS
->OpenProtocol (
62 pSocketBinding
->pNetworkBinding
,
64 pThis
->DriverBindingHandle
,
66 EFI_OPEN_PROTOCOL_GET_PROTOCOL
68 if ( !EFI_ERROR ( Status
)) {
70 // Determine if the driver is already connected
72 Status
= gBS
->OpenProtocol (
74 (EFI_GUID
*)pSocketBinding
->pTagGuid
,
76 pThis
->DriverBindingHandle
,
78 EFI_OPEN_PROTOCOL_GET_PROTOCOL
80 if ( !EFI_ERROR ( Status
)) {
81 Status
= EFI_ALREADY_STARTED
;
84 if ( EFI_UNSUPPORTED
== Status
) {
86 // Connect the driver since the tag is not present
94 // Set the next network protocol
100 // Return the device supported status
107 Connect to the network service bindings
109 Walk the network service protocols on the controller handle and
110 locate any that are not in use. Create service structures to
111 manage the service binding for the socket driver.
113 @param [in] pThis Protocol instance pointer.
114 @param [in] Controller Handle of device to work with.
115 @param [in] pRemainingDevicePath Not used, always produce all possible children.
117 @retval EFI_SUCCESS This driver is added to Controller.
118 @retval other This driver does not support this device.
124 IN EFI_DRIVER_BINDING_PROTOCOL
* pThis
,
125 IN EFI_HANDLE Controller
,
126 IN EFI_DEVICE_PATH_PROTOCOL
* pRemainingDevicePath
134 // Connect to this network adapter
136 Status
= EslServiceConnect ( pThis
->DriverBindingHandle
,
140 // Display the driver start status
142 DBG_EXIT_STATUS ( Status
);
148 Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and
149 closing the DevicePath and PciIo protocols on Controller.
151 @param [in] pThis Protocol instance pointer.
152 @param [in] Controller Handle of device to stop driver on.
153 @param [in] NumberOfChildren How many children need to be stopped.
154 @param [in] pChildHandleBuffer Not used.
156 @retval EFI_SUCCESS This driver is removed Controller.
157 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
158 @retval other This driver was not removed from this device.
164 IN EFI_DRIVER_BINDING_PROTOCOL
* pThis
,
165 IN EFI_HANDLE Controller
,
166 IN UINTN NumberOfChildren
,
167 IN EFI_HANDLE
* pChildHandleBuffer
175 // Disconnect the network adapters
177 Status
= EslServiceDisconnect ( pThis
->DriverBindingHandle
,
181 // Display the driver start status
183 DBG_EXIT_STATUS ( Status
);
189 Driver binding protocol definition
191 EFI_DRIVER_BINDING_PROTOCOL gDriverBinding
= {