]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Ip6Dxe/Ip6Driver.c
SecurityPkg: Add TPM PTP support in TCG2 SMM.
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6Driver.c
index 8095ed1ae20e15ecca540236122e581e7c0837bb..076dc605e6df8eb798ee0046efbf8f2abc021bc9 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   The driver binding and service binding protocol for IP6 driver.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -24,6 +25,32 @@ EFI_DRIVER_BINDING_PROTOCOL gIp6DriverBinding = {
   NULL\r
 };\r
 \r
+BOOLEAN  mIpSec2Installed = FALSE;\r
+\r
+/**\r
+   Callback function for IpSec2 Protocol install.\r
+\r
+   @param[in] Event           Event whose notification function is being invoked\r
+   @param[in] Context         Pointer to the notification function's context\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IpSec2InstalledCallback (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+{\r
+  //\r
+  // Close the event so it does not get called again.\r
+  //\r
+  gBS->CloseEvent (Event);\r
+\r
+  mIpSec2Installed = TRUE;\r
+\r
+  return;\r
+}\r
+\r
 /**\r
   This is the declaration of an EFI image entry point. This entry point is\r
   the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
@@ -46,6 +73,16 @@ Ip6DriverEntryPoint (
   IN EFI_SYSTEM_TABLE       *SystemTable\r
   )\r
 {\r
+  VOID            *Registration;\r
+\r
+  EfiCreateProtocolNotifyEvent (\r
+    &gEfiIpSec2ProtocolGuid,\r
+    TPL_CALLBACK,\r
+    IpSec2InstalledCallback,\r
+    NULL,\r
+    &Registration\r
+    );\r
+\r
   return EfiLibInstallDriverBindingComponentName2 (\r
            ImageHandle,\r
            SystemTable,\r
@@ -412,22 +449,21 @@ Ip6CreateService (
     goto ON_ERROR;\r
   }\r
 \r
-  //\r
-  // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds.\r
-  //\r
-  Status = gBS->SetTimer (IpSb->FasterTimer, TimerPeriodic, TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS);\r
+  Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);\r
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
 \r
-  //\r
-  // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds.\r
-  //\r
-  Status = gBS->SetTimer (IpSb->Timer, TimerPeriodic, TICKS_PER_MS * IP6_ONE_SECOND_IN_MS);\r
+  Status = Ip6ConfigInitInstance (&IpSb->Ip6ConfigInstance);\r
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
 \r
+  IpSb->DefaultInterface = Ip6CreateInterface (IpSb, TRUE);\r
+  if (IpSb->DefaultInterface == NULL) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto ON_ERROR;\r
+  }\r
 \r
   Status = gBS->CreateEvent (\r
                   EVT_NOTIFY_SIGNAL,\r
@@ -440,27 +476,6 @@ Ip6CreateService (
     goto ON_ERROR;\r
   }\r
 \r
-  Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
-\r
-  Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
-\r
-  Status = Ip6ConfigInitInstance (&IpSb->Ip6ConfigInstance);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
-\r
-  IpSb->DefaultInterface = Ip6CreateInterface (IpSb, TRUE);\r
-  if (IpSb->DefaultInterface == NULL) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto ON_ERROR;\r
-  }\r
-\r
   //\r
   // If there is any manual address, set it.\r
   //\r
@@ -557,19 +572,50 @@ Ip6DriverBindingStart (
                   NULL\r
                   );\r
 \r
-  if (EFI_ERROR (Status)) {\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // ready to go: start the receiving and timer\r
+    //\r
+    Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
+\r
+    //\r
+    // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds.\r
+    //\r
+    Status = gBS->SetTimer (\r
+                    IpSb->FasterTimer,\r
+                    TimerPeriodic,\r
+                    TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
+\r
+    //\r
+    // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds.\r
+    //\r
+    Status = gBS->SetTimer (\r
+                    IpSb->Timer,\r
+                    TimerPeriodic,\r
+                    TICKS_PER_MS * IP6_ONE_SECOND_IN_MS\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }    \r
 \r
-    Ip6CleanService (IpSb);\r
-    FreePool (IpSb);\r
-  } else {\r
     //\r
     // Initialize the IP6 ID\r
     //\r
     mIp6Id = NET_RANDOM (NetRandomInitSeed ());\r
 \r
-    Ip6SetVariableData (IpSb);\r
+    return EFI_SUCCESS;\r
   }\r
 \r
+ON_ERROR:\r
+  Ip6CleanService (IpSb);\r
+  FreePool (IpSb);\r
   return Status;\r
 }\r
 \r
@@ -690,11 +736,6 @@ Ip6DriverBindingStop (
     State           = IpSb->State;\r
     IpSb->State     = IP6_SERVICE_DESTROY;\r
 \r
-    //\r
-    // Clear the variable data.\r
-    //\r
-    Ip6ClearVariableData (IpSb);\r
-\r
     Status = Ip6CleanService (IpSb);\r
     if (EFI_ERROR (Status)) {\r
       IpSb->State = State;\r
@@ -932,9 +973,6 @@ Ip6ServiceBindingDestroyChild (
   }\r
 \r
   Status = Ip6CleanProtocol (IpInstance);\r
-\r
-  Ip6SetVariableData (IpSb);\r
-\r
   if (EFI_ERROR (Status)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
            &ChildHandle,\r