diff options
author | jgong5 <jgong5@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-12-30 02:21:34 +0000 |
---|---|---|
committer | jgong5 <jgong5@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-12-30 02:21:34 +0000 |
commit | c8d8f1e3320ebbfc1a4a26cb232cbe54d865b814 (patch) | |
tree | cfa2cc54d7f157665707c71b50781699beeb05a6 /MdeModulePkg/Universal/Network | |
parent | 373ade0eb64a522e45b1b94c15b95fb5ab417c00 (diff) | |
download | edk2-c8d8f1e3320ebbfc1a4a26cb232cbe54d865b814.zip edk2-c8d8f1e3320ebbfc1a4a26cb232cbe54d865b814.tar.gz edk2-c8d8f1e3320ebbfc1a4a26cb232cbe54d865b814.tar.bz2 |
code scrub for Ip4ConfigDxe
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7149 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network')
6 files changed, 366 insertions, 337 deletions
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c index 9d6fe0f..7d149df 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c @@ -1,5 +1,6 @@ /** @file
-
+ UEFI Component Name(2) protocol implementation for Ip4ConfigDxe driver.
+
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -11,140 +12,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/
-
#include "Ip4Config.h"
//
-// EFI Component Name Functions
-//
-/**
- 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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] 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 DriverName[out] 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
-Ip4ConfigComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- 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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] 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 ChildHandle[in] 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 Language[in] 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 ControllerName[out] 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
-Ip4ConfigComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName = {
@@ -168,6 +38,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4ConfigDriverNameTable {NULL, NULL}
};
+//
+// EFI Component Name Functions
+//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -180,7 +54,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4ConfigDriverNameTable @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
-
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
@@ -188,8 +61,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4ConfigDriverNameTable 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.
-
+ in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
@@ -198,11 +70,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4ConfigDriverNameTable @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.
@@ -239,12 +108,10 @@ Ip4ConfigComponentNameGetDriverName ( @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
-
@param ControllerHandle[in] 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 ChildHandle[in] 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
@@ -253,7 +120,6 @@ Ip4ConfigComponentNameGetDriverName ( controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
-
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
@@ -262,32 +128,25 @@ Ip4ConfigComponentNameGetDriverName ( 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 ControllerName[out] 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.
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c index 4c72a54..d7672cb 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c @@ -17,24 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
/**
- Callback function when DHCP process finished. It will save the
- retrieved IP configure parameter from DHCP to the NVRam.
-
- @param Event The callback event
- @param Context Opaque context to the callback
-
- @return None
-
-**/
-VOID
-EFIAPI
-Ip4ConfigOnDhcp4Complete (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-
-/**
Return the name and MAC address for the NIC. The Name, if not NULL,
has at least IP4_NIC_NAME_LENGTH bytes.
@@ -49,9 +31,9 @@ Ip4ConfigOnDhcp4Complete ( EFI_STATUS
EFIAPI
EfiNicIp4ConfigGetName (
- IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
- IN UINT16 *Name, OPTIONAL
- IN NIC_ADDR *NicAddr OPTIONAL
+ IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
+ OUT UINT16 *Name OPTIONAL,
+ OUT NIC_ADDR *NicAddr OPTIONAL
)
{
IP4_CONFIG_INSTANCE *Instance;
@@ -75,13 +57,13 @@ EfiNicIp4ConfigGetName ( /**
- Get the NIC's configure information from the IP4 configure variable.
+ Get the NIC's configure information from the IP4 configure variable.
It will remove the invalid variable.
@param NicAddr The NIC to check
@return NULL if no configure for the NIC in the variable, or it is invalid.
- @return Otherwise the NIC's IP configure parameter.
+ Otherwise the pointer to the NIC's IP configure parameter will be returned.
**/
NIC_IP4_CONFIG_INFO *
@@ -134,14 +116,18 @@ Ip4ConfigGetNicInfo ( /**
Get the configure parameter for this NIC.
- @param This The NIC IP4 CONFIG protocol
+ @param This The NIC IP4 CONFIG protocol.
@param ConfigLen The length of the NicConfig buffer.
@param NicConfig The buffer to receive the NIC's configure
parameter.
- @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL
+ @retval EFI_SUCCESS The configure parameter for this NIC was
+ obtained successfully .
+ @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.
@retval EFI_NOT_FOUND There is no configure parameter for the NIC in
NVRam.
+ @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is
+ NULL.
**/
EFI_STATUS
@@ -192,10 +178,11 @@ EfiNicIp4ConfigGetInfo ( /**
- Set the IP configure parameters for this NIC. If Reconfig is TRUE,
- the IP driver will be informed to discard current auto configure
- parameter and restart the auto configuration process. If current
- there is a pending auto configuration, EFI_ALREADY_STARTED is
+ Set the IP configure parameters for this NIC.
+
+ If Reconfig is TRUE, the IP driver will be informed to discard current
+ auto configure parameter and restart the auto configuration process.
+ If current there is a pending auto configuration, EFI_ALREADY_STARTED is
returned. You can only change the configure setting when either
the configure has finished or not started yet. If NicConfig, the
NIC's configure parameter is removed from the variable.
@@ -204,7 +191,9 @@ EfiNicIp4ConfigGetInfo ( @param NicConfig The new NIC IP4 configure parameter
@param Reconfig Inform the IP4 driver to restart the auto
configuration
-
+
+ @retval EFI_SUCCESS The configure parameter for this NIC was
+ set successfully .
@retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
invalid.
@retval EFI_ALREADY_STARTED There is a pending auto configuration.
@@ -280,6 +269,120 @@ EfiNicIp4ConfigSetInfo ( return Status;
}
+/**
+ Callback function when DHCP process finished. It will save the
+ retrieved IP configure parameter from DHCP to the NVRam.
+
+ @param Event The callback event
+ @param Context Opaque context to the callback
+
+ @return None
+
+**/
+VOID
+EFIAPI
+Ip4ConfigOnDhcp4Complete (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ IP4_CONFIG_INSTANCE *Instance;
+ EFI_DHCP4_MODE_DATA Dhcp4Mode;
+ EFI_IP4_IPCONFIG_DATA *Ip4Config;
+ EFI_STATUS Status;
+ BOOLEAN Perment;
+ IP4_ADDR Subnet;
+ IP4_ADDR Ip1;
+ IP4_ADDR Ip2;
+
+ Instance = (IP4_CONFIG_INSTANCE *) Context;
+ ASSERT (Instance->Dhcp4 != NULL);
+
+ Instance->State = IP4_CONFIG_STATE_CONFIGURED;
+ Instance->Result = EFI_TIMEOUT;
+
+ //
+ // Get the DHCP retrieved parameters
+ //
+ Status = Instance->Dhcp4->GetModeData (Instance->Dhcp4, &Dhcp4Mode);
+
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+
+ if (Dhcp4Mode.State == Dhcp4Bound) {
+ //
+ // Save the new configuration retrieved by DHCP both in
+ // the instance and to NVRam. So, both the IP4 driver and
+ // other user can get that address.
+ //
+ Perment = FALSE;
+
+ if (Instance->NicConfig != NULL) {
+ ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
+ Perment = Instance->NicConfig->Perment;
+ gBS->FreePool (Instance->NicConfig);
+ }
+
+ Instance->NicConfig = AllocatePool (sizeof (NIC_IP4_CONFIG_INFO) + 2* sizeof (EFI_IP4_ROUTE_TABLE));
+
+ if (Instance->NicConfig == NULL) {
+ Instance->Result = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
+
+ Instance->NicConfig->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (Instance->NicConfig + 1);
+
+ CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr));
+ Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP;
+ Instance->NicConfig->Perment = Perment;
+
+ Ip4Config = &Instance->NicConfig->Ip4Info;
+ Ip4Config->StationAddress = Dhcp4Mode.ClientAddress;
+ Ip4Config->SubnetMask = Dhcp4Mode.SubnetMask;
+
+ //
+ // Create a route for the connected network
+ //
+ Ip4Config->RouteTableSize = 1;
+
+ CopyMem (&Ip1, &Dhcp4Mode.ClientAddress, sizeof (IP4_ADDR));
+ CopyMem (&Ip2, &Dhcp4Mode.SubnetMask, sizeof (IP4_ADDR));
+
+ Subnet = Ip1 & Ip2;
+
+ CopyMem (&Ip4Config->RouteTable[0].SubnetAddress, &Subnet, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Ip4Config->RouteTable[0].SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
+ ZeroMem (&Ip4Config->RouteTable[0].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
+
+ //
+ // Create a route if there is a default router.
+ //
+ if (!EFI_IP4_EQUAL (&Dhcp4Mode.RouterAddress, &mZeroIp4Addr)) {
+ Ip4Config->RouteTableSize = 2;
+
+ ZeroMem (&Ip4Config->RouteTable[1].SubnetAddress, sizeof (EFI_IPv4_ADDRESS));
+ ZeroMem (&Ip4Config->RouteTable[1].SubnetMask, sizeof (EFI_IPv4_ADDRESS));
+ CopyMem (&Ip4Config->RouteTable[1].GatewayAddress, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS));
+ }
+
+ Instance->Result = EFI_SUCCESS;
+
+ //
+ // ignore the return status of EfiNicIp4ConfigSetInfo. Network
+ // stack can operate even that failed.
+ //
+ EfiNicIp4ConfigSetInfo (&Instance->NicIp4Protocol, Instance->NicConfig, FALSE);
+ }
+
+ON_EXIT:
+ gBS->SignalEvent (Instance->DoneEvent);
+ Ip4ConfigCleanDhcp4 (Instance);
+
+ NetLibDispatchDpc ();
+
+ return ;
+}
/**
Starts running the configuration policy for the EFI IPv4 Protocol driver.
@@ -557,8 +660,9 @@ ON_EXIT: @retval EFI_INVALID_PARAMETER This is NULL.
@retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol
driver is not running.
- @retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running.
- @retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete.
+ @retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running.
+ @retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete.
+ Currently not implemented.
@retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration
data buffer or ConfigData is NULL.
@@ -623,123 +727,6 @@ ON_EXIT: return Status;
}
-
-/**
- Callback function when DHCP process finished. It will save the
- retrieved IP configure parameter from DHCP to the NVRam.
-
- @param Event The callback event
- @param Context Opaque context to the callback
-
- @return None
-
-**/
-VOID
-EFIAPI
-Ip4ConfigOnDhcp4Complete (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- IP4_CONFIG_INSTANCE *Instance;
- EFI_DHCP4_MODE_DATA Dhcp4Mode;
- EFI_IP4_IPCONFIG_DATA *Ip4Config;
- EFI_STATUS Status;
- BOOLEAN Perment;
- IP4_ADDR Subnet;
- IP4_ADDR Ip1;
- IP4_ADDR Ip2;
-
- Instance = (IP4_CONFIG_INSTANCE *) Context;
- ASSERT (Instance->Dhcp4 != NULL);
-
- Instance->State = IP4_CONFIG_STATE_CONFIGURED;
- Instance->Result = EFI_TIMEOUT;
-
- //
- // Get the DHCP retrieved parameters
- //
- Status = Instance->Dhcp4->GetModeData (Instance->Dhcp4, &Dhcp4Mode);
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- if (Dhcp4Mode.State == Dhcp4Bound) {
- //
- // Save the new configuration retrieved by DHCP both in
- // the instance and to NVRam. So, both the IP4 driver and
- // other user can get that address.
- //
- Perment = FALSE;
-
- if (Instance->NicConfig != NULL) {
- ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
- Perment = Instance->NicConfig->Perment;
- gBS->FreePool (Instance->NicConfig);
- }
-
- Instance->NicConfig = AllocatePool (sizeof (NIC_IP4_CONFIG_INFO) + 2* sizeof (EFI_IP4_ROUTE_TABLE));
-
- if (Instance->NicConfig == NULL) {
- Instance->Result = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
-
- Instance->NicConfig->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (Instance->NicConfig + 1);
-
- CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr));
- Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP;
- Instance->NicConfig->Perment = Perment;
-
- Ip4Config = &Instance->NicConfig->Ip4Info;
- Ip4Config->StationAddress = Dhcp4Mode.ClientAddress;
- Ip4Config->SubnetMask = Dhcp4Mode.SubnetMask;
-
- //
- // Create a route for the connected network
- //
- Ip4Config->RouteTableSize = 1;
-
- CopyMem (&Ip1, &Dhcp4Mode.ClientAddress, sizeof (IP4_ADDR));
- CopyMem (&Ip2, &Dhcp4Mode.SubnetMask, sizeof (IP4_ADDR));
-
- Subnet = Ip1 & Ip2;
-
- CopyMem (&Ip4Config->RouteTable[0].SubnetAddress, &Subnet, sizeof (EFI_IPv4_ADDRESS));
- CopyMem (&Ip4Config->RouteTable[0].SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
- ZeroMem (&Ip4Config->RouteTable[0].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
-
- //
- // Create a route if there is a default router.
- //
- if (!EFI_IP4_EQUAL (&Dhcp4Mode.RouterAddress, &mZeroIp4Addr)) {
- Ip4Config->RouteTableSize = 2;
-
- ZeroMem (&Ip4Config->RouteTable[1].SubnetAddress, sizeof (EFI_IPv4_ADDRESS));
- ZeroMem (&Ip4Config->RouteTable[1].SubnetMask, sizeof (EFI_IPv4_ADDRESS));
- CopyMem (&Ip4Config->RouteTable[1].GatewayAddress, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS));
- }
-
- Instance->Result = EFI_SUCCESS;
-
- //
- // ignore the return status of EfiNicIp4ConfigSetInfo. Network
- // stack can operate even that failed.
- //
- EfiNicIp4ConfigSetInfo (&Instance->NicIp4Protocol, Instance->NicConfig, FALSE);
- }
-
-ON_EXIT:
- gBS->SignalEvent (Instance->DoneEvent);
- Ip4ConfigCleanDhcp4 (Instance);
-
- NetLibDispatchDpc ();
-
- return ;
-}
-
-
/**
Release all the DHCP related resources.
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h index c6c7caa..860ccf0 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h @@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef _EFI_IP4CONFIG_H_
#define _EFI_IP4CONFIG_H_
-#include <PiDxe.h>
+#include <Uefi.h>
#include <Protocol/Dhcp4.h>
#include <Protocol/Ip4Config.h>
@@ -34,15 +34,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;
+//
+// Global variables
+//
+extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;
+
+extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
+extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;
+extern EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate;
+
+#define IP4_PROTO_ICMP 0x01
+#define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
+
typedef enum {
IP4_CONFIG_STATE_IDLE = 0,
IP4_CONFIG_STATE_STARTED,
IP4_CONFIG_STATE_CONFIGURED
} IP4_CONFIG_STATE;
-#define IP4_PROTO_ICMP 0x01
-#define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
-
typedef enum {
DHCP_TAG_PARA_LIST = 55,
DHCP_TAG_NETMASK = 1,
@@ -108,13 +119,6 @@ struct _IP4_CONFIG_INSTANCE { #define IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG(this) \
CR (this, IP4_CONFIG_INSTANCE, NicIp4Protocol, IP4_CONFIG_INSTANCE_SIGNATURE)
-extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;
-extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
-extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;
-extern EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate;
-
/**
Release all the DHCP related resources.
@@ -125,7 +129,7 @@ extern EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate; **/
VOID
Ip4ConfigCleanDhcp4 (
- IN IP4_CONFIG_INSTANCE *This
+ IN IP4_CONFIG_INSTANCE *This
);
/**
@@ -140,4 +144,183 @@ VOID Ip4ConfigCleanConfig (
IN IP4_CONFIG_INSTANCE *Instance
);
+
+//
+// EFI Component Name Functions
+//
+
+/**
+ 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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param Language[in] 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 DriverName[out] 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
+Ip4ConfigComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+/**
+ 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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+ @param ControllerHandle[in] 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 ChildHandle[in] 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 Language[in] 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 ControllerName[out] 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
+Ip4ConfigComponentNameGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to test
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver supports this device
+ @retval EFI_ALREADY_STARTED This driver is already running on this device
+ @retval other This driver does not support this device
+
+**/
+EFI_STATUS
+EFIAPI
+Ip4ConfigDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Start this driver on ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to bind driver to
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval other This driver does not support this device
+
+**/
+EFI_STATUS
+EFIAPI
+Ip4ConfigDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Stop this driver on ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to stop driver on
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ @param ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCES This driver is removed ControllerHandle
+ @retval other This driver was not removed from this device
+
+**/
+EFI_STATUS
+EFIAPI
+Ip4ConfigDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
#endif
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c index d913857..1f8fa92 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c @@ -15,6 +15,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Ip4Config.h"
+EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {
+ Ip4ConfigDriverBindingSupported,
+ Ip4ConfigDriverBindingStart,
+ Ip4ConfigDriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
/**
Stop all the auto configuration when the IP4 configure driver is
@@ -500,11 +508,3 @@ Ip4ConfigDriverBindingStop ( return EFI_SUCCESS;
}
-EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {
- Ip4ConfigDriverBindingSupported,
- Ip4ConfigDriverBindingStart,
- Ip4ConfigDriverBindingStop,
- 0xa,
- NULL,
- NULL
-};
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c index f213dfa..012da5d 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c @@ -12,15 +12,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/
-#include <Uefi.h>
-
-#include <Library/NetLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
#include "NicIp4Variable.h"
@@ -206,7 +197,7 @@ Ip4ConfigWriteVariable ( @param NicAddr The interface address to check
@return The point to the NIC's IP4 configure info if it is found
- @return in the IP4 variable, otherwise NULL.
+ in the IP4 variable, otherwise NULL.
**/
NIC_IP4_CONFIG_INFO *
@@ -263,9 +254,9 @@ Ip4ConfigFindNicVariable ( @param Config The new configuration parameter (NULL to remove the old)
@return The new IP4_CONFIG_VARIABLE variable if the new variable has at
- @return least one NIC configure and no EFI_OUT_OF_RESOURCES failure.
- @return Return NULL either because failed to locate memory for new variable
- @return or the only NIC configure is removed from the Variable.
+ least one NIC configure and no EFI_OUT_OF_RESOURCES failure.
+ Return NULL either because failed to locate memory for new variable
+ or the only NIC configure is removed from the Variable.
**/
IP4_CONFIG_VARIABLE *
@@ -387,7 +378,7 @@ Ip4ConfigModifyVariable ( **/
VOID
Ip4ConfigFixRouteTablePointer (
- IN EFI_IP4_IPCONFIG_DATA *ConfigData
+ IN OUT EFI_IP4_IPCONFIG_DATA *ConfigData
)
{
//
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h index 635ffdb..9d191de 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h @@ -15,9 +15,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef _NIC_IP4_VARIABLE_H_
#define _NIC_IP4_VARIABLE_H_
+#include <Uefi.h>
+
+#include <Library/NetLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
#include <Protocol/NicIp4Config.h>
+
//
// Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA.
// They are of variable size
@@ -75,7 +84,7 @@ Ip4ConfigReadVariable ( **/
EFI_STATUS
Ip4ConfigWriteVariable (
- IN IP4_CONFIG_VARIABLE *Config OPTIONAL
+ IN IP4_CONFIG_VARIABLE *Config OPTIONAL
);
/**
@@ -107,9 +116,9 @@ Ip4ConfigFindNicVariable ( @param Config The new configuration parameter (NULL to remove the old)
@return The new IP4_CONFIG_VARIABLE variable if the new variable has at
- @return least one NIC configure and no EFI_OUT_OF_RESOURCES failure.
- @return Return NULL either because failed to locate memory for new variable
- @return or the only NIC configure is removed from the Variable.
+ least one NIC configure and no EFI_OUT_OF_RESOURCES failure.
+ Return NULL either because failed to locate memory for new variable
+ or the only NIC configure is removed from the Variable.
**/
IP4_CONFIG_VARIABLE *
@@ -130,7 +139,7 @@ Ip4ConfigModifyVariable ( **/
VOID
Ip4ConfigFixRouteTablePointer (
- IN EFI_IP4_IPCONFIG_DATA *ConfigData
+ IN OUT EFI_IP4_IPCONFIG_DATA *ConfigData
);
#endif
|