2 SocketDxe support routines
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.
19 Creates a child handle and installs gEfiSocketProtocolGuid.
21 This routine creates a child handle for the socket driver and
22 installs the ::gEfiSocketProtocolGuid on that handle with a pointer
23 to the ::EFI_SOCKET_PROTOCOL structure address.
25 This routine is called by ::EslServiceGetProtocol in UseSocketDxe
26 when the socket application is linked with UseSocketDxe.
28 @param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.
29 @param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,
30 then a new handle is created. If it is a pointer to an existing UEFI handle,
31 then the protocol is added to the existing UEFI handle.
33 @retval EFI_SUCCESS The protocol was added to ChildHandle.
34 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
35 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
37 @retval other The child handle was not created
43 IN EFI_SERVICE_BINDING_PROTOCOL
* pThis
,
44 IN OUT EFI_HANDLE
* pChildHandle
53 // Create a socket structure
55 Status
= EslSocketAllocate ( pChildHandle
,
60 // Return the operation status
62 DBG_EXIT_STATUS ( Status
);
68 Removes gEfiSocketProtocolGuid and destroys the child handle.
70 This routine uninstalls ::gEfiSocketProtocolGuid from the child handle
71 and destroys the child handle if necessary.
73 This routine is called from ???.
75 @param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.
76 @param [in] ChildHandle Handle of the child to destroy
78 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
79 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
80 @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
81 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
82 because its services are being used.
83 @retval other The child handle was not destroyed
89 IN EFI_SERVICE_BINDING_PROTOCOL
* pThis
,
90 IN EFI_HANDLE ChildHandle
94 EFI_SOCKET_PROTOCOL
* pSocketProtocol
;
100 // Locate the socket control structure
103 Status
= gBS
->OpenProtocol (
105 &gEfiSocketProtocolGuid
,
106 (VOID
**)&pSocketProtocol
,
109 EFI_OPEN_PROTOCOL_GET_PROTOCOL
111 if ( !EFI_ERROR ( Status
)) {
113 // Free the socket resources
115 Status
= EslSocketFree ( pSocketProtocol
, NULL
);
118 DEBUG (( DEBUG_ERROR
,
119 "ERROR - Failed to open socket protocol on 0x%08x, Status; %r\r\n",
125 // Return the operation status
127 DBG_EXIT_STATUS ( Status
);
133 Install the socket service
135 This routine installs the ::gEfiSocketServiceBindingProtocolGuid
136 on the SocketDxe image handle to announce the availability
137 of the socket layer to the rest of EFI.
139 SocketDxe's EntryPoint routine calls this routine to
140 make the socket layer available.
142 @param [in] pImageHandle Address of the image handle
144 @retval EFI_SUCCESS Service installed successfully
149 IN EFI_HANDLE
* pImageHandle
155 // Install the socket service binding protocol
157 Status
= gBS
->InstallMultipleProtocolInterfaces (
159 &gEfiSocketServiceBindingProtocolGuid
,
160 mEslLayer
.pServiceBinding
,
163 if ( !EFI_ERROR ( Status
)) {
164 DEBUG (( DEBUG_POOL
| DEBUG_INIT
| DEBUG_INFO
,
165 "Installed: gEfiSocketServiceBindingProtocolGuid on 0x%08x\r\n",
169 DEBUG (( DEBUG_ERROR
| DEBUG_POOL
| DEBUG_INIT
,
170 "ERROR - InstallMultipleProtocolInterfaces failed, Status: %r\r\n",
175 // Return the operation status
182 Uninstall the socket service
184 This routine removes the gEfiSocketServiceBindingProtocolGuid from
185 the SocketDxe image handle to notify EFI that the socket layer
186 is no longer available.
188 SocketDxe's DriverUnload routine calls this routine to remove the
191 @param [in] ImageHandle Handle for the image.
193 @retval EFI_SUCCESS Service installed successfully
198 IN EFI_HANDLE ImageHandle
204 // Install the socket service binding protocol
206 Status
= gBS
->UninstallMultipleProtocolInterfaces (
208 &gEfiSocketServiceBindingProtocolGuid
,
209 mEslLayer
.pServiceBinding
,
212 if ( !EFI_ERROR ( Status
)) {
213 DEBUG (( DEBUG_POOL
| DEBUG_INIT
,
214 "Removed: gEfiSocketServiceBindingProtocolGuid from 0x%08x\r\n",
218 DEBUG (( DEBUG_ERROR
| DEBUG_POOL
| DEBUG_INIT
,
219 "ERROR - Failed to remove gEfiSocketServiceBindingProtocolGuid from 0x%08x, Status: %r\r\n",
225 // Return the operation status