]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
Fix spelling typo in the NIC_IP4_CONFIG_INFO.Permanent variable name, which was incor...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4ConfigDriver.c
index dfa4cdcd8f9911c5adfd1207d27a4d1c7b47319d..56cce6e6f09817e85774b6bdf2679afc09daaabf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding for IP4 CONFIG protocol.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at<BR>\r
@@ -26,6 +26,71 @@ EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {
   NULL\r
 };\r
 \r
+//\r
+// The intance of template of IP4 Config private data\r
+//\r
+IP4_CONFIG_INSTANCE        mIp4ConfigTemplate = {\r
+  IP4_CONFIG_INSTANCE_SIGNATURE,\r
+  NULL,\r
+  NULL,\r
+  (EFI_DEVICE_PATH_PROTOCOL *) NULL,\r
+  {\r
+    NULL,\r
+    NULL,\r
+    NULL\r
+  },\r
+  {\r
+    NULL,\r
+    NULL,\r
+    NULL\r
+  },\r
+  NULL,\r
+  (EFI_DEVICE_PATH_PROTOCOL *) NULL,\r
+  NULL,\r
+  {\r
+    FALSE,\r
+    FALSE,\r
+    {\r
+      {\r
+        0\r
+      }\r
+    },\r
+    {\r
+      {\r
+        0\r
+      }\r
+    },\r
+    {\r
+      {\r
+        0\r
+      }\r
+    }\r
+  },\r
+  0,\r
+  (EFI_MANAGED_NETWORK_PROTOCOL *) NULL,\r
+  NULL,\r
+  NULL,\r
+  NULL,\r
+  0,\r
+  {\r
+    0,\r
+    0,\r
+    {\r
+      {\r
+        0\r
+      }\r
+    }\r
+  },\r
+  (CHAR16 *) NULL,\r
+  (NIC_IP4_CONFIG_INFO *) NULL,\r
+  (EFI_DHCP4_PROTOCOL *) NULL,\r
+  NULL,\r
+  NULL,\r
+  NULL,\r
+  TRUE,\r
+  FALSE\r
+};\r
+\r
 /**\r
   The entry point for IP4 config driver which install the driver\r
   binding and component name protocol on its image.\r
@@ -44,6 +109,8 @@ Ip4ConfigDriverEntryPoint (
   IN EFI_SYSTEM_TABLE       *SystemTable\r
   )\r
 {\r
+  mIp4ConfigTemplate.Result = EFI_NOT_READY;\r
+\r
   return EfiLibInstallDriverBindingComponentName2 (\r
            ImageHandle,\r
            SystemTable,\r
@@ -180,14 +247,13 @@ Ip4ConfigDriverBindingStart (
   //\r
   // Allocate an instance then initialize it\r
   //\r
-  Instance = AllocateZeroPool (sizeof (IP4_CONFIG_INSTANCE));\r
+  Instance = AllocateCopyPool (sizeof (IP4_CONFIG_INSTANCE), &mIp4ConfigTemplate);\r
 \r
   if (Instance == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto ON_ERROR;\r
   }\r
 \r
-  Instance->Signature         = IP4_CONFIG_INSTANCE_SIGNATURE;\r
   Instance->Controller        = ControllerHandle;\r
   Instance->Image             = This->DriverBindingHandle;\r
   Instance->ParentDevicePath  = ParentDevicePath;\r
@@ -198,15 +264,6 @@ Ip4ConfigDriverBindingStart (
   Instance->Mnp               = Mnp;\r
   Instance->MnpHandle         = MnpHandle;\r
 \r
-  Instance->DoneEvent         = NULL;\r
-  Instance->ReconfigEvent     = NULL;\r
-  Instance->Result            = EFI_NOT_READY;\r
-  Instance->NicConfig         = NULL;\r
-\r
-  Instance->Dhcp4             = NULL;\r
-  Instance->Dhcp4Handle       = NULL;\r
-  Instance->Dhcp4Event        = NULL;\r
-\r
   Status = Mnp->GetModeData (Mnp, NULL, &SnpMode);\r
 \r
   if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {\r
@@ -241,25 +298,28 @@ Ip4ConfigDriverBindingStart (
     goto ON_ERROR;\r
   }\r
 \r
+  //\r
+  // A dedicated timer is used to poll underlying media status.\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
+                  TPL_CALLBACK,\r
+                  MediaChangeDetect,\r
+                  Instance,\r
+                  &Instance->Timer\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
+\r
   //\r
   // Get the previous configure parameters. If an error happend here,\r
   // just ignore it because the driver should be able to operate.\r
   //\r
   NicConfig = Ip4ConfigReadVariable (Instance);\r
   if (NicConfig != NULL) {\r
-    if (NicConfig->Perment) {\r
-      if (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC) {\r
-        //\r
-        // Don't modify the permanent static configuration.\r
-        //\r
-      } else if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {\r
-        //\r
-        // Remove the previous acquired DHCP parameters.\r
-        //\r
-        ZeroMem (&NicConfig->Ip4Info, sizeof (EFI_IP4_IPCONFIG_DATA));\r
-        Ip4ConfigWriteVariable (Instance, NicConfig);\r
-      }\r
-    } else {\r
+    if (!NicConfig->Permanent) {\r
       //\r
       // Delete the non-permanent configuration.\r
       //\r
@@ -288,7 +348,7 @@ ON_ERROR:
   NetLibDestroyServiceChild (\r
     ControllerHandle,\r
     This->DriverBindingHandle,\r
-    &gEfiManagedNetworkProtocolGuid,\r
+    &gEfiManagedNetworkServiceBindingProtocolGuid,\r
     MnpHandle\r
     );\r
 \r
@@ -432,6 +492,12 @@ Ip4ConfigDriverBindingStop (
     FreePool (Instance->MacString);\r
   }\r
 \r
+  if (Instance->Timer != NULL) {\r
+    gBS->SetTimer (Instance->Timer, TimerCancel, 0);\r
+    gBS->CloseEvent (Instance->Timer);\r
+    Instance->Timer = NULL;\r
+  }\r
+  \r
   Ip4ConfigCleanConfig (Instance);\r
   FreePool (Instance);\r
 \r