2 SocketDxe support routines
4 Copyright (c) 2011, Intel Corporation. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 Creates a child handle and installs gEfiSocketProtocolGuid.
15 This routine creates a child handle for the socket driver and
16 installs the ::gEfiSocketProtocolGuid on that handle with a pointer
17 to the ::EFI_SOCKET_PROTOCOL structure address.
19 This routine is called by ::EslServiceGetProtocol in UseSocketDxe
20 when the socket application is linked with UseSocketDxe.
22 @param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.
23 @param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,
24 then a new handle is created. If it is a pointer to an existing UEFI handle,
25 then the protocol is added to the existing UEFI handle.
27 @retval EFI_SUCCESS The protocol was added to ChildHandle.
28 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
29 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
31 @retval other The child handle was not created
37 IN EFI_SERVICE_BINDING_PROTOCOL
* pThis
,
38 IN OUT EFI_HANDLE
* pChildHandle
47 // Create a socket structure
49 Status
= EslSocketAllocate ( pChildHandle
,
54 // Return the operation status
56 DBG_EXIT_STATUS ( Status
);
62 Removes gEfiSocketProtocolGuid and destroys the child handle.
64 This routine uninstalls ::gEfiSocketProtocolGuid from the child handle
65 and destroys the child handle if necessary.
67 This routine is called from ???.
69 @param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.
70 @param [in] ChildHandle Handle of the child to destroy
72 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
73 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
74 @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
75 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
76 because its services are being used.
77 @retval other The child handle was not destroyed
83 IN EFI_SERVICE_BINDING_PROTOCOL
* pThis
,
84 IN EFI_HANDLE ChildHandle
88 EFI_SOCKET_PROTOCOL
* pSocketProtocol
;
94 // Locate the socket control structure
97 Status
= gBS
->OpenProtocol (
99 &gEfiSocketProtocolGuid
,
100 (VOID
**)&pSocketProtocol
,
103 EFI_OPEN_PROTOCOL_GET_PROTOCOL
105 if ( !EFI_ERROR ( Status
)) {
107 // Free the socket resources
109 Status
= EslSocketFree ( pSocketProtocol
, NULL
);
112 DEBUG (( DEBUG_ERROR
,
113 "ERROR - Failed to open socket protocol on 0x%08x, Status; %r\r\n",
119 // Return the operation status
121 DBG_EXIT_STATUS ( Status
);
127 Install the socket service
129 This routine installs the ::gEfiSocketServiceBindingProtocolGuid
130 on the SocketDxe image handle to announce the availability
131 of the socket layer to the rest of EFI.
133 SocketDxe's EntryPoint routine calls this routine to
134 make the socket layer available.
136 @param [in] pImageHandle Address of the image handle
138 @retval EFI_SUCCESS Service installed successfully
143 IN EFI_HANDLE
* pImageHandle
149 // Install the socket service binding protocol
151 Status
= gBS
->InstallMultipleProtocolInterfaces (
153 &gEfiSocketServiceBindingProtocolGuid
,
154 mEslLayer
.pServiceBinding
,
157 if ( !EFI_ERROR ( Status
)) {
158 DEBUG (( DEBUG_POOL
| DEBUG_INIT
| DEBUG_INFO
,
159 "Installed: gEfiSocketServiceBindingProtocolGuid on 0x%08x\r\n",
163 DEBUG (( DEBUG_ERROR
| DEBUG_POOL
| DEBUG_INIT
,
164 "ERROR - InstallMultipleProtocolInterfaces failed, Status: %r\r\n",
169 // Return the operation status
176 Uninstall the socket service
178 This routine removes the gEfiSocketServiceBindingProtocolGuid from
179 the SocketDxe image handle to notify EFI that the socket layer
180 is no longer available.
182 SocketDxe's DriverUnload routine calls this routine to remove the
185 @param [in] ImageHandle Handle for the image.
187 @retval EFI_SUCCESS Service installed successfully
192 IN EFI_HANDLE ImageHandle
198 // Install the socket service binding protocol
200 Status
= gBS
->UninstallMultipleProtocolInterfaces (
202 &gEfiSocketServiceBindingProtocolGuid
,
203 mEslLayer
.pServiceBinding
,
206 if ( !EFI_ERROR ( Status
)) {
207 DEBUG (( DEBUG_POOL
| DEBUG_INIT
,
208 "Removed: gEfiSocketServiceBindingProtocolGuid from 0x%08x\r\n",
212 DEBUG (( DEBUG_ERROR
| DEBUG_POOL
| DEBUG_INIT
,
213 "ERROR - Failed to remove gEfiSocketServiceBindingProtocolGuid from 0x%08x, Status: %r\r\n",
219 // Return the operation status