summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c')
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c201
1 files changed, 85 insertions, 116 deletions
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
index 60cf318772..fdbb26cd78 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
@@ -1,8 +1,8 @@
/** @file
The driver binding for IP4 CONFIG protocol.
-Copyright (c) 2006 - 2009, Intel Corporation.<BR>
-All rights reserved. This program and the accompanying materials
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+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<BR>
http://opensource.org/licenses/bsd-license.php
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Ip4Config.h"
#include "Ip4ConfigNv.h"
+#include "NicIp4Variable.h"
EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {
Ip4ConfigDriverBindingSupported,
@@ -25,41 +26,59 @@ EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {
NULL
};
-/**
- Stop all the auto configuration when the IP4 configure driver is
- being unloaded.
-
- @param ImageHandle The driver that is being unloaded
-
- @retval EFI_SUCCESS The driver has been ready for unload.
-
-**/
-EFI_STATUS
-EFIAPI
-EfiIp4ConfigUnload (
- IN EFI_HANDLE ImageHandle
- )
-{
- UINT32 Index;
-
- //
- // Stop all the IP4_CONFIG instances
- //
- for (Index = 0; Index < MAX_IP4_CONFIG_IN_VARIABLE; Index++) {
- if (mIp4ConfigNicList[Index] == NULL) {
- continue;
+//
+// The intance of template of IP4 Config private data
+//
+IP4_CONFIG_INSTANCE mIp4ConfigTemplate = {
+ IP4_CONFIG_INSTANCE_SIGNATURE,
+ NULL,
+ NULL,
+ (EFI_DEVICE_PATH_PROTOCOL *) NULL,
+ {
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ NULL,
+ NULL,
+ NULL
+ },
+ NULL,
+ (EFI_DEVICE_PATH_PROTOCOL *) NULL,
+ NULL,
+ {
+ FALSE,
+ FALSE,
+ {
+ 0
+ },
+ {
+ 0
+ },
+ {
+ 0
}
-
- gIp4ConfigDriverBinding.Stop (
- &gIp4ConfigDriverBinding,
- mIp4ConfigNicList[Index]->MnpHandle,
- 0,
- NULL
- );
- }
-
- return NetLibDefaultUnload (ImageHandle);
-}
+ },
+ 0,
+ (EFI_MANAGED_NETWORK_PROTOCOL *) NULL,
+ NULL,
+ NULL,
+ NULL,
+ EFI_NOT_READY,
+ {
+ 0,
+ 0,
+ {
+ 0
+ }
+ },
+ (CHAR16 *) NULL,
+ (NIC_IP4_CONFIG_INFO *) NULL,
+ (EFI_DHCP4_PROTOCOL *) NULL,
+ NULL,
+ NULL
+};
/**
The entry point for IP4 config driver which install the driver
@@ -152,13 +171,10 @@ Ip4ConfigDriverBindingStart (
EFI_HANDLE MnpHandle;
IP4_CONFIG_INSTANCE *Instance;
EFI_SIMPLE_NETWORK_MODE SnpMode;
- IP4_CONFIG_VARIABLE *Variable;
NIC_IP4_CONFIG_INFO *NicConfig;
- IP4_CONFIG_VARIABLE *NewVariable;
EFI_STATUS Status;
- UINT32 Index;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
+
Status = gBS->HandleProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
@@ -218,14 +234,13 @@ Ip4ConfigDriverBindingStart (
//
// Allocate an instance then initialize it
//
- Instance = AllocatePool (sizeof (IP4_CONFIG_INSTANCE));
+ Instance = AllocateCopyPool (sizeof (IP4_CONFIG_INSTANCE), &mIp4ConfigTemplate);
if (Instance == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
- Instance->Signature = IP4_CONFIG_INSTANCE_SIGNATURE;
Instance->Controller = ControllerHandle;
Instance->Image = This->DriverBindingHandle;
Instance->ParentDevicePath = ParentDevicePath;
@@ -236,15 +251,6 @@ Ip4ConfigDriverBindingStart (
Instance->Mnp = Mnp;
Instance->MnpHandle = MnpHandle;
- Instance->DoneEvent = NULL;
- Instance->ReconfigEvent = NULL;
- Instance->Result = EFI_NOT_READY;
- Instance->NicConfig = NULL;
-
- Instance->Dhcp4 = NULL;
- Instance->Dhcp4Handle = NULL;
- Instance->Dhcp4Event = NULL;
-
Status = Mnp->GetModeData (Mnp, NULL, &SnpMode);
if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
@@ -258,30 +264,15 @@ Ip4ConfigDriverBindingStart (
//
// Add it to the global list, and compose the name
//
- for (Index = 0; Index < MAX_IP4_CONFIG_IN_VARIABLE; Index++) {
- if (mIp4ConfigNicList[Index] == NULL) {
- mIp4ConfigNicList[Index] = Instance;
- Instance->NicIndex = Index;
-
- if (Instance->NicAddr.Type == NET_IFTYPE_ETHERNET) {
- UnicodeSPrint (Instance->NicName, (UINTN) IP4_NIC_NAME_LENGTH, L"eth%d", Index);
- } else {
- UnicodeSPrint (Instance->NicName, (UINTN) IP4_NIC_NAME_LENGTH, L"unk%d", Index);
- }
-
- break;
- }
- }
-
- if (Index == MAX_IP4_CONFIG_IN_VARIABLE) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = NetLibGetMacString (Instance->Controller, Instance->Image, &Instance->MacString);
+ if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = Ip4ConfigDeviceInit (Instance);
//
- // Install the IP4_CONFIG and NIC_IP4CONFIG protocols
+ // Install the IP4_CONFIG protocols
//
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
@@ -291,7 +282,6 @@ Ip4ConfigDriverBindingStart (
);
if (EFI_ERROR (Status)) {
- mIp4ConfigNicList[Index] = NULL;
goto ON_ERROR;
}
@@ -299,50 +289,27 @@ Ip4ConfigDriverBindingStart (
// Get the previous configure parameters. If an error happend here,
// just ignore it because the driver should be able to operate.
//
- Variable = Ip4ConfigReadVariable ();
-
- if (Variable == NULL) {
- return EFI_SUCCESS;
- }
-
- NicConfig = Ip4ConfigFindNicVariable (Variable, &Instance->NicAddr);
-
- if (NicConfig == NULL) {
- goto ON_EXIT;
- }
-
- //
- // Don't modify the permant static configuration
- //
- if (NicConfig->Perment && (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC)) {
- goto ON_EXIT;
- }
-
- //
- // Delete the non-permant configuration and remove the previous
- // acquired DHCP parameters. Only doing DHCP itself is permant
- //
- NewVariable = NULL;
-
- if (!NicConfig->Perment) {
- NewVariable = Ip4ConfigModifyVariable (Variable, &Instance->NicAddr, NULL);
-
- } else if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {
- ZeroMem (&NicConfig->Ip4Info, sizeof (EFI_IP4_IPCONFIG_DATA));
- NewVariable = Ip4ConfigModifyVariable (Variable, &Instance->NicAddr, NicConfig);
-
- }
-
- Ip4ConfigWriteVariable (NewVariable);
-
- if (NewVariable != NULL) {
- FreePool (NewVariable);
- }
-
-ON_EXIT:
- FreePool (Variable);
-
+ NicConfig = Ip4ConfigReadVariable (Instance);
if (NicConfig != NULL) {
+ if (NicConfig->Perment) {
+ if (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC) {
+ //
+ // Don't modify the permanent static configuration.
+ //
+ } else if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {
+ //
+ // Remove the previous acquired DHCP parameters.
+ //
+ ZeroMem (&NicConfig->Ip4Info, sizeof (EFI_IP4_IPCONFIG_DATA));
+ Ip4ConfigWriteVariable (Instance, NicConfig);
+ }
+ } else {
+ //
+ // Delete the non-permanent configuration.
+ //
+ Ip4ConfigWriteVariable (Instance, NULL);
+ }
+
FreePool (NicConfig);
}
@@ -365,7 +332,7 @@ ON_ERROR:
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
- &gEfiManagedNetworkProtocolGuid,
+ &gEfiManagedNetworkServiceBindingProtocolGuid,
MnpHandle
);
@@ -505,10 +472,12 @@ Ip4ConfigDriverBindingStop (
Instance->MnpHandle = NULL;
}
+ if (Instance->MacString != NULL) {
+ FreePool (Instance->MacString);
+ }
+
Ip4ConfigCleanConfig (Instance);
- mIp4ConfigNicList[Instance->NicIndex] = NULL;
FreePool (Instance);
return EFI_SUCCESS;
}
-