summaryrefslogtreecommitdiffstats
path: root/StdLib/SocketDxe
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-30 00:30:44 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-30 00:30:44 +0000
commitd7ce700605e1af0e455e31ec11f19ff21d26b525 (patch)
tree243b582ac3350e8c6ce6ca96fff13805318fd65c /StdLib/SocketDxe
parentf766dd76fde231ecd4f2e9faf99293e90902cebb (diff)
downloadedk2-d7ce700605e1af0e455e31ec11f19ff21d26b525.tar.gz
edk2-d7ce700605e1af0e455e31ec11f19ff21d26b525.tar.bz2
edk2-d7ce700605e1af0e455e31ec11f19ff21d26b525.zip
Add Socket Libraries.
Add Posix functions for porting compatibility. Fix compliance issues with ISO/IEC 9899:199409 New Functions: setenv(), fparseln(), GetFileNameFromPath(), rename(), realpath(), setprogname(), getprogname(), strlcat(), strlcpy(), strsep(), setitimer(), getitimer(), timegm(), getopt(), basename(), mkstemp(), ffs(), vsnprintf(), snprintf(), getpass(), usleep(), select(), writev(), strcasecmp(), getcwd(), chdir(), tcgetpgrp(), getpgrp(), gettimeofday(), bcopy(), git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12061 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/SocketDxe')
-rw-r--r--StdLib/SocketDxe/ComponentName.c182
-rw-r--r--StdLib/SocketDxe/DriverBinding.c198
-rw-r--r--StdLib/SocketDxe/EntryUnload.c296
-rw-r--r--StdLib/SocketDxe/Socket.h175
-rw-r--r--StdLib/SocketDxe/SocketDxe.inf62
5 files changed, 913 insertions, 0 deletions
diff --git a/StdLib/SocketDxe/ComponentName.c b/StdLib/SocketDxe/ComponentName.c
new file mode 100644
index 0000000000..7fe9c711ee
--- /dev/null
+++ b/StdLib/SocketDxe/ComponentName.c
@@ -0,0 +1,182 @@
+/** @file
+ UEFI Component Name(2) protocol implementation.
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "Socket.h"
+
+/**
+ EFI Component Name Protocol declaration
+**/
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
+ GetDriverName,
+ GetControllerName,
+ "eng"
+};
+
+/**
+ EFI Component Name 2 Protocol declaration
+**/
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) GetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) GetControllerName,
+ "en"
+};
+
+
+/**
+ Driver name table declaration
+**/
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
+mDriverNameTable[] = {
+ {"eng;en", L"Socket Layer Driver"},
+ {NULL, NULL}
+};
+
+/**
+ Retrieves a Unicode string that is the user readable name of the driver.
+
+ This function retrieves the user readable name of a driver in the form of a
+ Unicode string. If the driver specified by This has a user readable name in
+ the language specified by Language, then a pointer to the driver name is
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
+ by This does not support the language specified by Language,
+ then EFI_UNSUPPORTED is returned.
+
+ @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param [in] pLanguage A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified
+ in RFC 3066 or ISO 639-2 language code format.
+ @param [out] ppDriverName A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ driver specified by This in the language
+ specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by
+ This and the language specified by Language was
+ returned in DriverName.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+GetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
+ IN CHAR8 * pLanguage,
+ OUT CHAR16 ** ppDriverName
+ )
+{
+ EFI_STATUS Status;
+
+ Status = LookupUnicodeString2 (
+ pLanguage,
+ pThis->SupportedLanguages,
+ mDriverNameTable,
+ ppDriverName,
+ (BOOLEAN)(pThis == &gComponentName)
+ );
+ return Status;
+}
+
+/**
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by a driver.
+
+ This function retrieves the user readable name of the controller specified by
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the
+ driver specified by This has a user readable name in the language specified by
+ Language, then a pointer to the controller name is returned in ControllerName,
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently
+ managing the controller specified by ControllerHandle and ChildHandle,
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.
+
+ @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param [in] ControllerHandle The handle of a controller that the driver
+ specified by This is managing. This handle
+ specifies the controller whose name is to be
+ returned.
+ @param [in] ChildHandle The handle of the child controller to retrieve
+ the name of. This is an optional parameter that
+ may be NULL. It will be NULL for device
+ drivers. It will also be NULL for a bus drivers
+ that wish to retrieve the name of the bus
+ controller. It will not be NULL for a bus
+ driver that wishes to retrieve the name of a
+ child controller.
+ @param [in] pLanguage A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified in
+ RFC 3066 or ISO 639-2 language code format.
+ @param [out] ppControllerName A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ controller specified by ControllerHandle and
+ ChildHandle in the language specified by
+ Language from the point of view of the driver
+ specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in
+ the language specified by Language for the
+ driver specified by This was returned in
+ DriverName.
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+GetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
+ IN EFI_HANDLE ControllerHandle,
+ IN OPTIONAL EFI_HANDLE ChildHandle,
+ IN CHAR8 * pLanguage,
+ OUT CHAR16 ** ppControllerName
+ )
+{
+ EFI_STATUS Status;
+
+ DBG_ENTER ( );
+
+ //
+ // Set the controller name
+ //
+ *ppControllerName = L"Socket Layer";
+ Status = EFI_SUCCESS;
+
+ //
+ // Return the operation status
+ //
+ DBG_EXIT_HEX ( Status );
+ return Status;
+}
diff --git a/StdLib/SocketDxe/DriverBinding.c b/StdLib/SocketDxe/DriverBinding.c
new file mode 100644
index 0000000000..7de7f62a35
--- /dev/null
+++ b/StdLib/SocketDxe/DriverBinding.c
@@ -0,0 +1,198 @@
+/** @file
+ Implement the driver binding protocol for the socket layer.
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "Socket.h"
+
+/**
+ Verify the controller type
+
+ Determine if any of the network service binding protocols exist on
+ the controller handle. If so, verify that these protocols are not
+ already in use. Call ::DriverStart for any network service binding
+ protocol that is not in use.
+
+ @param [in] pThis Protocol instance pointer.
+ @param [in] Controller Handle of device to test.
+ @param [in] pRemainingDevicePath Not used.
+
+ @retval EFI_SUCCESS This driver supports this device.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+DriverSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL * pThis,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath
+ )
+{
+ CONST DT_SOCKET_BINDING * pEnd;
+ VOID * pInterface;
+ CONST DT_SOCKET_BINDING * pSocketBinding;
+ EFI_STATUS Status;
+
+ //
+ // Assume the list is empty
+ //
+ Status = EFI_UNSUPPORTED;
+
+ //
+ // Walk the list of network connection points
+ //
+ pSocketBinding = &cEslSocketBinding[0];
+ pEnd = &pSocketBinding[ cEslSocketBindingEntries ];
+ while ( pEnd > pSocketBinding ) {
+ //
+ // Determine if the controller supports the network protocol
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ pSocketBinding->pNetworkBinding,
+ &pInterface,
+ pThis->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Determine if the driver is already connected
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ (EFI_GUID *)pSocketBinding->pTagGuid,
+ &pInterface,
+ pThis->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if ( !EFI_ERROR ( Status )) {
+ Status = EFI_ALREADY_STARTED;
+ }
+ else {
+ if ( EFI_UNSUPPORTED == Status ) {
+ //
+ // Connect the driver since the tag is not present
+ //
+ Status = EFI_SUCCESS;
+ }
+ }
+ }
+
+ //
+ // Set the next network protocol
+ //
+ pSocketBinding += 1;
+ }
+
+ //
+ // Return the device supported status
+ //
+ return Status;
+}
+
+
+/**
+ Connect to the network service bindings
+
+ Walk the network service protocols on the controller handle and
+ locate any that are not in use. Create service structures to
+ manage the service binding for the socket driver.
+
+ @param [in] pThis Protocol instance pointer.
+ @param [in] Controller Handle of device to work with.
+ @param [in] pRemainingDevicePath Not used, always produce all possible children.
+
+ @retval EFI_SUCCESS This driver is added to Controller.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+DriverStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL * pThis,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+
+ DBG_ENTER ( );
+
+ //
+ // Connect to this network adapter
+ //
+ Status = EslServiceConnect ( pThis->DriverBindingHandle,
+ Controller );
+
+ //
+ // Display the driver start status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
+}
+
+
+/**
+ Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and
+ closing the DevicePath and PciIo protocols on Controller.
+
+ @param [in] pThis Protocol instance pointer.
+ @param [in] Controller Handle of device to stop driver on.
+ @param [in] NumberOfChildren How many children need to be stopped.
+ @param [in] pChildHandleBuffer Not used.
+
+ @retval EFI_SUCCESS This driver is removed Controller.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+ @retval other This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+DriverStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL * pThis,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE * pChildHandleBuffer
+ )
+{
+ EFI_STATUS Status;
+
+ DBG_ENTER ( );
+
+ //
+ // Disconnect the network adapters
+ //
+ Status = EslServiceDisconnect ( pThis->DriverBindingHandle,
+ Controller );
+
+ //
+ // Display the driver start status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
+}
+
+
+/**
+ Driver binding protocol definition
+**/
+EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
+ DriverSupported,
+ DriverStart,
+ DriverStop,
+ 0xa,
+ NULL,
+ NULL
+};
diff --git a/StdLib/SocketDxe/EntryUnload.c b/StdLib/SocketDxe/EntryUnload.c
new file mode 100644
index 0000000000..6afd8e6b48
--- /dev/null
+++ b/StdLib/SocketDxe/EntryUnload.c
@@ -0,0 +1,296 @@
+/** @file
+ Implement the entry and unload for the socket driver.
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "Socket.h"
+
+
+CONST EFI_GUID mEslRawServiceGuid = {
+ 0xf9f5d280, 0x8a4b, 0x48e2, { 0x96, 0x28, 0xda, 0xfa, 0xa7, 0x70, 0x54, 0x5d }
+};
+
+CONST EFI_GUID mEslTcp4ServiceGuid = {
+ 0x4dcaab0a, 0x1990, 0x4352, { 0x8d, 0x2f, 0x2d, 0x8f, 0x13, 0x55, 0x98, 0xa5 }
+};
+
+CONST EFI_GUID mEslUdp4ServiceGuid = {
+ 0x43a110ce, 0x9ccd, 0x402b, { 0x8c, 0x29, 0x4a, 0x6d, 0x8a, 0xf7, 0x79, 0x90 }
+};
+
+
+/**
+ Socket driver unload routine.
+
+ @param [in] ImageHandle Handle for the image.
+
+ @retval EFI_SUCCESS Image may be unloaded
+
+**/
+EFI_STATUS
+EFIAPI
+DriverUnload (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ UINTN BufferSize;
+ UINTN Index;
+ UINTN Max;
+ EFI_HANDLE * pHandle;
+ EFI_STATUS Status;
+
+ //
+ // Determine which devices are using this driver
+ //
+ BufferSize = 0;
+ pHandle = NULL;
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiCallerIdGuid,
+ NULL,
+ &BufferSize,
+ NULL );
+ if ( EFI_BUFFER_TOO_SMALL == Status ) {
+ for ( ; ; ) {
+ //
+ // One or more block IO devices are present
+ //
+ Status = gBS->AllocatePool (
+ EfiRuntimeServicesData,
+ BufferSize,
+ (VOID **) &pHandle
+ );
+ if ( EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Insufficient memory, failed handle buffer allocation\r\n" ));
+ break;
+ }
+
+ //
+ // Locate the block IO devices
+ //
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiCallerIdGuid,
+ NULL,
+ &BufferSize,
+ pHandle );
+ if ( EFI_ERROR ( Status )) {
+ //
+ // Error getting handles
+ //
+ DEBUG (( DEBUG_ERROR | DEBUG_INIT | DEBUG_INFO,
+ "Failure getting Telnet handles\r\n" ));
+ break;
+ }
+
+ //
+ // Remove any use of the driver
+ //
+ Max = BufferSize / sizeof ( pHandle[ 0 ]);
+ for ( Index = 0; Max > Index; Index++ ) {
+ Status = DriverStop ( &gDriverBinding,
+ pHandle[ Index ],
+ 0,
+ NULL );
+ if ( EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_WARN | DEBUG_INIT | DEBUG_INFO,
+ "WARNING - Failed to shutdown the driver on handle %08x\r\n", pHandle[ Index ]));
+ break;
+ }
+ }
+ break;
+ }
+ }
+ else {
+ if ( EFI_NOT_FOUND == Status ) {
+ //
+ // No devices were found
+ //
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ //
+ // Free the handle array
+ //
+ if ( NULL != pHandle ) {
+ gBS->FreePool ( pHandle );
+ }
+
+ //
+ // Done with the socket layer
+ //
+ if ( !EFI_ERROR ( Status )) {
+ Status = EslServiceUninstall ( ImageHandle );
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Remove the protocols installed by the EntryPoint routine.
+ //
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gDriverBinding,
+ &gEfiComponentNameProtocolGuid,
+ &gComponentName,
+ &gEfiComponentName2ProtocolGuid,
+ &gComponentName2,
+ NULL
+ );
+ if ( !EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Removed: gEfiComponentName2ProtocolGuid from 0x%08x\r\n",
+ ImageHandle ));
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Removed: gEfiComponentNameProtocolGuid from 0x%08x\r\n",
+ ImageHandle ));
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Removed: gEfiDriverBindingProtocolGuid from 0x%08x\r\n",
+ ImageHandle ));
+ }
+ else {
+ DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
+ "ERROR - Failed to remove gEfiDriverBindingProtocolGuid from 0x%08x, Status: %r\r\n",
+ ImageHandle,
+ Status ));
+ }
+ }
+ }
+
+ //
+ // Disconnect the network services
+ //
+ if ( !EFI_ERROR ( Status )) {
+ EslServiceUnload ( );
+ }
+
+ //
+ // Return the unload status
+ //
+ return Status;
+}
+
+
+/**
+Socket driver entry point.
+
+@param [in] ImageHandle Handle for the image.
+@param [in] pSystemTable Address of the system table.
+
+@retval EFI_SUCCESS Image successfully loaded.
+
+**/
+EFI_STATUS
+EFIAPI
+EntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE * pSystemTable
+ )
+{
+ EFI_LOADED_IMAGE_PROTOCOL * pLoadedImage;
+ EFI_STATUS Status;
+
+ DBG_ENTER ( );
+
+ //
+ // Display the image handle
+ //
+ DEBUG (( DEBUG_INFO,
+ "ImageHandle: 0x%08x\r\n",
+ ImageHandle ));
+
+ //
+ // Enable unload support
+ //
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&pLoadedImage
+ );
+ if (!EFI_ERROR (Status)) {
+ pLoadedImage->Unload = DriverUnload;
+
+ //
+ // Add the driver to the list of drivers
+ //
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ pSystemTable,
+ &gDriverBinding,
+ ImageHandle,
+ &gComponentName,
+ &gComponentName2
+ );
+ if ( !EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Installed: gEfiDriverBindingProtocolGuid on 0x%08x\r\n",
+ ImageHandle ));
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Installed: gEfiComponentNameProtocolGuid on 0x%08x\r\n",
+ ImageHandle ));
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Installed: gEfiComponentName2ProtocolGuid on 0x%08x\r\n",
+ ImageHandle ));
+
+ //
+ // Initialize the service layer
+ //
+ EslServiceLoad ( ImageHandle );
+
+ //
+ // Make the socket serivces available to other drivers
+ // and applications
+ //
+ Status = EslServiceInstall ( &ImageHandle );
+ if ( EFI_ERROR ( Status )) {
+ //
+ // Disconnect from the network
+ //
+ EslServiceUnload ( );
+
+ //
+ // Remove the driver bindings
+ //
+ gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gDriverBinding,
+ &gEfiComponentNameProtocolGuid,
+ &gComponentName,
+ &gEfiComponentName2ProtocolGuid,
+ &gComponentName2,
+ NULL
+ );
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Removed: gEfiComponentName2ProtocolGuid from 0x%08x\r\n",
+ ImageHandle ));
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Removed: gEfiComponentNameProtocolGuid from 0x%08x\r\n",
+ ImageHandle ));
+ DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
+ "Removed: gEfiDriverBindingProtocolGuid from 0x%08x\r\n",
+ ImageHandle ));
+ }
+ }
+ else {
+ DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
+ "ERROR - EfiLibInstallDriverBindingComponentName2 failed, Status: %r\r\n",
+ Status ));
+ }
+ }
+ DBG_EXIT_STATUS ( Status );
+ return Status;
+}
+
+
+PFN_ESL_xSTRUCTOR mpfnEslConstructor = NULL;
+PFN_ESL_xSTRUCTOR mpfnEslDestructor = NULL;
diff --git a/StdLib/SocketDxe/Socket.h b/StdLib/SocketDxe/Socket.h
new file mode 100644
index 0000000000..dfa4dad51b
--- /dev/null
+++ b/StdLib/SocketDxe/Socket.h
@@ -0,0 +1,175 @@
+/** @file
+ Definitions for the Socket layer driver.
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef _SOCKET_H_
+#define _SOCKET_H_
+
+#include <Library/UefiDriverEntryPoint.h>
+#include <Efi/EfiSocketLib.h>
+
+#include <Protocol/LoadedImage.h>
+
+//------------------------------------------------------------------------------
+// Protocol Declarations
+//------------------------------------------------------------------------------
+
+extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration
+extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration
+extern EFI_DRIVER_BINDING_PROTOCOL gDriverBinding; ///< Driver binding protocol declaration
+extern EFI_SERVICE_BINDING_PROTOCOL mServiceBinding; ///< Service binding protocol delcaration
+
+//------------------------------------------------------------------------------
+// Driver Binding Protocol Support
+//------------------------------------------------------------------------------
+
+/**
+ Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and
+ closing the DevicePath and PciIo protocols on Controller.
+
+ @param [in] pThis Protocol instance pointer.
+ @param [in] Controller Handle of device to stop driver on.
+ @param [in] NumberOfChildren How many children need to be stopped.
+ @param [in] pChildHandleBuffer Not used.
+
+ @retval EFI_SUCCESS This driver is removed Controller.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+ @retval other This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+DriverStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL * pThis,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE * pChildHandleBuffer
+ );
+
+//------------------------------------------------------------------------------
+// EFI Component Name Protocol Support
+//------------------------------------------------------------------------------
+
+/**
+ Retrieves a Unicode string that is the user readable name of the driver.
+
+ This function retrieves the user readable name of a driver in the form of a
+ Unicode string. If the driver specified by This has a user readable name in
+ the language specified by Language, then a pointer to the driver name is
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
+ by This does not support the language specified by Language,
+ then EFI_UNSUPPORTED is returned.
+
+ @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param [in] pLanguage A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified
+ in RFC 3066 or ISO 639-2 language code format.
+ @param [out] ppDriverName A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ driver specified by This in the language
+ specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by
+ This and the language specified by Language was
+ returned in DriverName.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+GetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
+ IN CHAR8 * pLanguage,
+ OUT CHAR16 ** ppDriverName
+ );
+
+
+/**
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by a driver.
+
+ This function retrieves the user readable name of the controller specified by
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the
+ driver specified by This has a user readable name in the language specified by
+ Language, then a pointer to the controller name is returned in ControllerName,
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently
+ managing the controller specified by ControllerHandle and ChildHandle,
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.
+
+ @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param [in] ControllerHandle The handle of a controller that the driver
+ specified by This is managing. This handle
+ specifies the controller whose name is to be
+ returned.
+ @param [in] ChildHandle The handle of the child controller to retrieve
+ the name of. This is an optional parameter that
+ may be NULL. It will be NULL for device
+ drivers. It will also be NULL for a bus drivers
+ that wish to retrieve the name of the bus
+ controller. It will not be NULL for a bus
+ driver that wishes to retrieve the name of a
+ child controller.
+ @param [in] pLanguage A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified in
+ RFC 3066 or ISO 639-2 language code format.
+ @param [out] ppControllerName A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ controller specified by ControllerHandle and
+ ChildHandle in the language specified by
+ Language from the point of view of the driver
+ specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in
+ the language specified by Language for the
+ driver specified by This was returned in
+ DriverName.
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+GetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
+ IN EFI_HANDLE ControllerHandle,
+ IN OPTIONAL EFI_HANDLE ChildHandle,
+ IN CHAR8 * pLanguage,
+ OUT CHAR16 ** ppControllerName
+ );
+
+//------------------------------------------------------------------------------
+
+#endif // _SOCKET_H_
diff --git a/StdLib/SocketDxe/SocketDxe.inf b/StdLib/SocketDxe/SocketDxe.inf
new file mode 100644
index 0000000000..1b459bafc8
--- /dev/null
+++ b/StdLib/SocketDxe/SocketDxe.inf
@@ -0,0 +1,62 @@
+#/** @file
+# Component description file for the socket layer driver.
+#
+# This module implements the socket layer.
+# Copyright (c) 2011, Intel Corporation
+#
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SocketDxe
+ FILE_GUID = 2A43BA5F-AC29-4fdc-8A3B-0328D0256F8C
+ MODULE_TYPE = DXE_RUNTIME_DRIVER
+ VERSION_STRING = 1.0
+
+ ENTRY_POINT = EntryPoint
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources.common]
+ Socket.h
+ ComponentName.c
+ DriverBinding.c
+ EntryUnload.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ StdLib/StdLib.dec
+
+[LibraryClasses]
+ EfiSocketLib
+ UefiLib
+ UefiBootServicesTableLib
+ BaseMemoryLib
+ DebugLib
+ UefiRuntimeLib
+ UefiDriverEntryPoint
+
+[Protocols]
+ gEfiTcp4ProtocolGuid
+ gEfiTcp4ServiceBindingProtocolGuid
+ gEfiUdp4ProtocolGuid
+ gEfiUdp4ServiceBindingProtocolGuid
+ gEfiSocketProtocolGuid
+ gEfiSocketServiceBindingProtocolGuid
+
+[Depex]
+ gEfiBdsArchProtocolGuid AND
+ gEfiCpuArchProtocolGuid AND
+ gEfiTcp4ServiceBindingProtocolGuid AND
+ gEfiTimerArchProtocolGuid AND
+ gEfiUdp4ServiceBindingProtocolGuid