+++ /dev/null
-/** @file\r
- SocketDxe support routines\r
-\r
- Copyright (c) 2011, Intel Corporation. All rights reserved.\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Socket.h"\r
-\r
-\r
-/**\r
- Creates a child handle and installs gEfiSocketProtocolGuid.\r
-\r
- This routine creates a child handle for the socket driver and\r
- installs the ::gEfiSocketProtocolGuid on that handle with a pointer\r
- to the ::EFI_SOCKET_PROTOCOL structure address.\r
-\r
- This routine is called by ::EslServiceGetProtocol in UseSocketDxe\r
- when the socket application is linked with UseSocketDxe.\r
-\r
- @param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.\r
- @param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,\r
- then a new handle is created. If it is a pointer to an existing UEFI handle, \r
- then the protocol is added to the existing UEFI handle.\r
-\r
- @retval EFI_SUCCESS The protocol was added to ChildHandle.\r
- @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
- @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create\r
- the child\r
- @retval other The child handle was not created\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EslDxeCreateChild (\r
- IN EFI_SERVICE_BINDING_PROTOCOL * pThis,\r
- IN OUT EFI_HANDLE * pChildHandle\r
- )\r
-{\r
- ESL_SOCKET * pSocket;\r
- EFI_STATUS Status;\r
-\r
- DBG_ENTER ( );\r
-\r
- //\r
- // Create a socket structure\r
- //\r
- Status = EslSocketAllocate ( pChildHandle,\r
- DEBUG_SOCKET,\r
- &pSocket );\r
-\r
- //\r
- // Return the operation status\r
- //\r
- DBG_EXIT_STATUS ( Status );\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Removes gEfiSocketProtocolGuid and destroys the child handle.\r
-\r
- This routine uninstalls ::gEfiSocketProtocolGuid from the child handle\r
- and destroys the child handle if necessary.\r
-\r
- This routine is called from ???.\r
- \r
- @param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.\r
- @param [in] ChildHandle Handle of the child to destroy\r
-\r
- @retval EFI_SUCCESS The protocol was removed from ChildHandle.\r
- @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r
- @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
- @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r
- because its services are being used.\r
- @retval other The child handle was not destroyed\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EslDxeDestroyChild (\r
- IN EFI_SERVICE_BINDING_PROTOCOL * pThis,\r
- IN EFI_HANDLE ChildHandle\r
- )\r
-{\r
- ESL_LAYER * pLayer;\r
- EFI_SOCKET_PROTOCOL * pSocketProtocol;\r
- EFI_STATUS Status;\r
-\r
- DBG_ENTER ( );\r
-\r
- //\r
- // Locate the socket control structure\r
- //\r
- pLayer = &mEslLayer;\r
- Status = gBS->OpenProtocol (\r
- ChildHandle,\r
- &gEfiSocketProtocolGuid,\r
- (VOID **)&pSocketProtocol,\r
- pLayer->ImageHandle,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if ( !EFI_ERROR ( Status )) {\r
- //\r
- // Free the socket resources\r
- //\r
- Status = EslSocketFree ( pSocketProtocol, NULL );\r
- }\r
- else {\r
- DEBUG (( DEBUG_ERROR,\r
- "ERROR - Failed to open socket protocol on 0x%08x, Status; %r\r\n",\r
- ChildHandle,\r
- Status ));\r
- }\r
-\r
- //\r
- // Return the operation status\r
- //\r
- DBG_EXIT_STATUS ( Status );\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
-Install the socket service\r
-\r
-This routine installs the ::gEfiSocketServiceBindingProtocolGuid\r
-on the SocketDxe image handle to announce the availability\r
-of the socket layer to the rest of EFI.\r
-\r
-SocketDxe's EntryPoint routine calls this routine to\r
-make the socket layer available.\r
-\r
-@param [in] pImageHandle Address of the image handle\r
-\r
-@retval EFI_SUCCESS Service installed successfully\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EslDxeInstall (\r
- IN EFI_HANDLE * pImageHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Install the socket service binding protocol\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- pImageHandle,\r
- &gEfiSocketServiceBindingProtocolGuid,\r
- mEslLayer.pServiceBinding,\r
- NULL\r
- );\r
- if ( !EFI_ERROR ( Status )) {\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Installed: gEfiSocketServiceBindingProtocolGuid on 0x%08x\r\n",\r
- *pImageHandle ));\r
- }\r
- else {\r
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,\r
- "ERROR - InstallMultipleProtocolInterfaces failed, Status: %r\r\n",\r
- Status ));\r
- }\r
-\r
- //\r
- // Return the operation status\r
- //\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
-Uninstall the socket service\r
-\r
-This routine removes the gEfiSocketServiceBindingProtocolGuid from\r
-the SocketDxe image handle to notify EFI that the socket layer\r
-is no longer available.\r
-\r
-SocketDxe's DriverUnload routine calls this routine to remove the\r
-socket layer.\r
-\r
-@param [in] ImageHandle Handle for the image.\r
-\r
-@retval EFI_SUCCESS Service installed successfully\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EslDxeUninstall (\r
- IN EFI_HANDLE ImageHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Install the socket service binding protocol\r
- //\r
- Status = gBS->UninstallMultipleProtocolInterfaces (\r
- ImageHandle,\r
- &gEfiSocketServiceBindingProtocolGuid,\r
- mEslLayer.pServiceBinding,\r
- NULL\r
- );\r
- if ( !EFI_ERROR ( Status )) {\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT,\r
- "Removed: gEfiSocketServiceBindingProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- }\r
- else {\r
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,\r
- "ERROR - Failed to remove gEfiSocketServiceBindingProtocolGuid from 0x%08x, Status: %r\r\n",\r
- ImageHandle,\r
- Status ));\r
- }\r
-\r
- //\r
- // Return the operation status\r
- //\r
- return Status;\r
-}\r