+++ /dev/null
-/** @file\r
- Implement the entry and unload for the socket driver.\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
- The following GUID values are only used by the SocketDxe driver. An\r
- alternative set of values exists in EfiSocketLib\UseEfiSocketLib.c\r
- which an application uses when it links against EfiSocketLib. These\r
- two sets of values allow the SocketDxe driver to coexist with socket\r
- applications.\r
-\r
- Tag GUID - IPv4 in use by SocketDxe\r
-**/\r
-CONST EFI_GUID mEslIp4ServiceGuid = {\r
- 0x4e3a82e6, 0xe43f, 0x460a, { 0x86, 0x6e, 0x9b, 0x5a, 0xab, 0x80, 0x44, 0x48 }\r
-};\r
-\r
-\r
-/**\r
- Tag GUID - IPv6 in use by SocketDxe\r
-**/\r
-CONST EFI_GUID mEslIp6ServiceGuid = {\r
- 0x2fc3b2d3, 0x6eba, 0x42b0, { 0xa4, 0xa7, 0x14, 0xc7, 0xa8, 0x4b, 0x5d, 0x22 }\r
-};\r
-\r
-\r
-/**\r
- Tag GUID - TCPv4 in use by SocketDxe\r
-**/\r
-CONST EFI_GUID mEslTcp4ServiceGuid = {\r
- 0x4dcaab0a, 0x1990, 0x4352, { 0x8d, 0x2f, 0x2d, 0x8f, 0x13, 0x55, 0x98, 0xa5 }\r
-};\r
-\r
-\r
-/**\r
- Tag GUID - TCPv6 in use by SocketDxe\r
-**/\r
-CONST EFI_GUID mEslTcp6ServiceGuid = {\r
- 0xdd455a69, 0xec75, 0x456c, { 0x84, 0xd2, 0x95, 0xca, 0xe7, 0xd3, 0xc6, 0xd3 }\r
-};\r
-\r
-\r
-/**\r
- Tag GUID - UDPv4 in use by SocketDxe\r
-**/\r
-CONST EFI_GUID mEslUdp4ServiceGuid = {\r
- 0x43a110ce, 0x9ccd, 0x402b, { 0x8c, 0x29, 0x4a, 0x6d, 0x8a, 0xf7, 0x79, 0x90 }\r
-};\r
-\r
-\r
-/**\r
- Tag GUID - UDPv6 in use by SocketDxe\r
-**/\r
-CONST EFI_GUID mEslUdp6ServiceGuid = {\r
- 0x32ff59cd, 0xc33, 0x48d0, { 0xa2, 0x44, 0x4b, 0xb8, 0x11, 0x33, 0x64, 0x3 }\r
-};\r
-\r
-\r
-/**\r
- Socket driver unload routine.\r
-\r
- @param [in] ImageHandle Handle for the image.\r
-\r
- @retval EFI_SUCCESS Image may be unloaded\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DriverUnload (\r
- IN EFI_HANDLE ImageHandle\r
- )\r
-{\r
- UINTN BufferSize;\r
- UINTN Index;\r
- UINTN Max;\r
- EFI_HANDLE * pHandle;\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Determine which devices are using this driver\r
- //\r
- BufferSize = 0;\r
- pHandle = NULL;\r
- Status = gBS->LocateHandle (\r
- ByProtocol,\r
- &gEfiCallerIdGuid,\r
- NULL,\r
- &BufferSize,\r
- NULL );\r
- if ( EFI_BUFFER_TOO_SMALL == Status ) {\r
- for ( ; ; ) {\r
- //\r
- // One or more block IO devices are present\r
- //\r
- Status = gBS->AllocatePool (\r
- EfiRuntimeServicesData,\r
- BufferSize,\r
- (VOID **) &pHandle\r
- );\r
- if ( EFI_ERROR ( Status )) {\r
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Insufficient memory, failed handle buffer allocation\r\n" ));\r
- break;\r
- }\r
-\r
- //\r
- // Locate the block IO devices\r
- //\r
- Status = gBS->LocateHandle (\r
- ByProtocol,\r
- &gEfiCallerIdGuid,\r
- NULL,\r
- &BufferSize,\r
- pHandle );\r
- if ( EFI_ERROR ( Status )) {\r
- //\r
- // Error getting handles\r
- //\r
- DEBUG (( DEBUG_ERROR | DEBUG_INIT | DEBUG_INFO,\r
- "Failure getting Telnet handles\r\n" ));\r
- break;\r
- }\r
- \r
- //\r
- // Remove any use of the driver\r
- //\r
- Max = BufferSize / sizeof ( pHandle[ 0 ]);\r
- for ( Index = 0; Max > Index; Index++ ) {\r
- Status = DriverStop ( &mDriverBinding,\r
- pHandle[ Index ],\r
- 0,\r
- NULL );\r
- if ( EFI_ERROR ( Status )) {\r
- DEBUG (( DEBUG_WARN | DEBUG_INIT | DEBUG_INFO,\r
- "WARNING - Failed to shutdown the driver on handle %08x\r\n", pHandle[ Index ]));\r
- break;\r
- }\r
- }\r
- break;\r
- }\r
- }\r
- else {\r
- if ( EFI_NOT_FOUND == Status ) {\r
- //\r
- // No devices were found\r
- //\r
- Status = EFI_SUCCESS;\r
- }\r
- }\r
-\r
- //\r
- // Free the handle array\r
- //\r
- if ( NULL != pHandle ) {\r
- gBS->FreePool ( pHandle );\r
- }\r
-\r
- //\r
- // Done with the socket layer\r
- //\r
- if ( !EFI_ERROR ( Status )) {\r
- Status = EslDxeUninstall ( ImageHandle );\r
- if ( !EFI_ERROR ( Status )) {\r
- //\r
- // Remove the protocols installed by the EntryPoint routine.\r
- //\r
- Status = gBS->UninstallMultipleProtocolInterfaces (\r
- ImageHandle,\r
- &gEfiDriverBindingProtocolGuid,\r
- &mDriverBinding,\r
- &gEfiComponentNameProtocolGuid,\r
- &mComponentName,\r
- &gEfiComponentName2ProtocolGuid,\r
- &mComponentName2,\r
- NULL\r
- );\r
- if ( !EFI_ERROR ( Status )) {\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Removed: gEfiComponentName2ProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Removed: gEfiComponentNameProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Removed: gEfiDriverBindingProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- }\r
- else {\r
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,\r
- "ERROR - Failed to remove gEfiDriverBindingProtocolGuid from 0x%08x, Status: %r\r\n",\r
- ImageHandle,\r
- Status ));\r
- }\r
- }\r
- }\r
-\r
- //\r
- // Disconnect the network services\r
- //\r
- if ( !EFI_ERROR ( Status )) {\r
- EslServiceUnload ( );\r
- }\r
-\r
- //\r
- // Return the unload status\r
- //\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
-Socket driver entry point.\r
-\r
-@param [in] ImageHandle Handle for the image.\r
-@param [in] pSystemTable Address of the system table.\r
-\r
-@retval EFI_SUCCESS Image successfully loaded.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE * pSystemTable\r
- )\r
-{\r
- EFI_LOADED_IMAGE_PROTOCOL * pLoadedImage;\r
- EFI_STATUS Status;\r
-\r
- DBG_ENTER ( );\r
-\r
- //\r
- // Display the image handle\r
- //\r
- DEBUG (( DEBUG_INFO,\r
- "ImageHandle: 0x%08x\r\n",\r
- ImageHandle ));\r
-\r
- //\r
- // Enable unload support\r
- //\r
- Status = gBS->HandleProtocol (\r
- gImageHandle,\r
- &gEfiLoadedImageProtocolGuid,\r
- (VOID **)&pLoadedImage\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- pLoadedImage->Unload = DriverUnload;\r
-\r
- //\r
- // Add the driver to the list of drivers\r
- //\r
- Status = EfiLibInstallDriverBindingComponentName2 (\r
- ImageHandle,\r
- pSystemTable,\r
- &mDriverBinding,\r
- ImageHandle,\r
- &mComponentName,\r
- &mComponentName2\r
- );\r
- if ( !EFI_ERROR ( Status )) {\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Installed: gEfiDriverBindingProtocolGuid on 0x%08x\r\n",\r
- ImageHandle ));\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Installed: gEfiComponentNameProtocolGuid on 0x%08x\r\n",\r
- ImageHandle ));\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Installed: gEfiComponentName2ProtocolGuid on 0x%08x\r\n",\r
- ImageHandle ));\r
-\r
- //\r
- // Initialize the service layer\r
- //\r
- EslServiceLoad ( ImageHandle );\r
-\r
- //\r
- // Make the socket serivces available to other drivers\r
- // and applications\r
- //\r
- Status = EslDxeInstall ( &ImageHandle );\r
- if ( EFI_ERROR ( Status )) {\r
- //\r
- // Disconnect from the network\r
- //\r
- EslServiceUnload ( );\r
-\r
- //\r
- // Remove the driver bindings\r
- //\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- ImageHandle,\r
- &gEfiDriverBindingProtocolGuid,\r
- &mDriverBinding,\r
- &gEfiComponentNameProtocolGuid,\r
- &mComponentName,\r
- &gEfiComponentName2ProtocolGuid,\r
- &mComponentName2,\r
- NULL\r
- );\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Removed: gEfiComponentName2ProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Removed: gEfiComponentNameProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,\r
- "Removed: gEfiDriverBindingProtocolGuid from 0x%08x\r\n",\r
- ImageHandle ));\r
- }\r
- }\r
- else {\r
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,\r
- "ERROR - EfiLibInstallDriverBindingComponentName2 failed, Status: %r\r\n",\r
- Status ));\r
- }\r
- }\r
- DBG_EXIT_STATUS ( Status );\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Socket layer's service binding protocol delcaration.\r
-**/\r
-CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {\r
- EslDxeCreateChild,\r
- EslDxeDestroyChild\r
-};\r
-\r
-\r
-/**\r
- The following entries disable the constructor and destructor\r
- for the SocketDxe driver. Note that socket applications linking\r
- against EfiSocketLib use different redirection.\r
-**/\r
-PFN_ESL_xSTRUCTOR mpfnEslConstructor = NULL; ///< No EfiSocketLib constructor needed for SocketDxe\r
-PFN_ESL_xSTRUCTOR mpfnEslDestructor = NULL; ///< No EfiSocketLib destructor needed for SocketDxe\r