]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiNotTiano.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
index 16ae959a71b6bbe3c962f278f2ffe43ac8f615f8..8c8d9b29f8c876acbc3085244a43117e7c784ef1 100644 (file)
@@ -6,42 +6,13 @@
   (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as\r
   it contains DXE enum extensions for EFI event services.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
-All rights reserved. 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\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-\r
-\r
 #include "UefiLibInternal.h"\r
 \r
-/**\r
-  An empty function to pass error checking of CreateEventEx ().\r
-\r
-  This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error\r
-  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
\r
-  @param  Event                 Event whose notification function is being invoked.\r
-  @param  Context               Pointer to the notification function's context,\r
-                                which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InternalEmptyFuntion (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  return;\r
-}\r
-\r
 /**\r
   Creates an EFI event in the Legacy Boot Event Group.\r
 \r
@@ -67,7 +38,7 @@ EfiCreateEventLegacyBoot (
 {\r
   return EfiCreateEventLegacyBootEx (\r
            TPL_CALLBACK,\r
-           InternalEmptyFuntion,\r
+           EfiEventEmptyFunction,\r
            NULL,\r
            LegacyBootEvent\r
            );\r
@@ -75,8 +46,8 @@ EfiCreateEventLegacyBoot (
 \r
 /**\r
   Create an EFI event in the Legacy Boot Event Group and allows\r
-  the caller to specify a notification function.  \r
-  \r
+  the caller to specify a notification function.\r
+\r
   This function abstracts the creation of the Legacy Boot Event.\r
   The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
   This library abstracts the caller from how this event is created to prevent\r
@@ -96,17 +67,18 @@ EFI_STATUS
 EFIAPI\r
 EfiCreateEventLegacyBootEx (\r
   IN  EFI_TPL           NotifyTpl,\r
-  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
-  IN  VOID              *NotifyContext,  OPTIONAL\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction   OPTIONAL,\r
+  IN  VOID              *NotifyContext   OPTIONAL,\r
   OUT EFI_EVENT         *LegacyBootEvent\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
+  EFI_STATUS        Status;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
 \r
   ASSERT (LegacyBootEvent != NULL);\r
 \r
   if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
-    DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r
+    DEBUG ((DEBUG_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r
     ASSERT (FALSE);\r
 \r
     return EFI_UNSUPPORTED;\r
@@ -114,10 +86,20 @@ EfiCreateEventLegacyBootEx (
     //\r
     // For UEFI 2.0 and the future use an Event Group\r
     //\r
+    if (NotifyFunction == NULL) {\r
+      //\r
+      // CreateEventEx will check NotifyFunction is NULL or not and return error.\r
+      // Use dummy routine for the case NotifyFunction is NULL.\r
+      //\r
+      WorkerNotifyFunction = EfiEventEmptyFunction;\r
+    } else {\r
+      WorkerNotifyFunction = NotifyFunction;\r
+    }\r
+\r
     Status = gBS->CreateEventEx (\r
                     EVT_NOTIFY_SIGNAL,\r
                     NotifyTpl,\r
-                    NotifyFunction,\r
+                    WorkerNotifyFunction,\r
                     NotifyContext,\r
                     &gEfiEventLegacyBootGuid,\r
                     LegacyBootEvent\r
@@ -131,14 +113,14 @@ EfiCreateEventLegacyBootEx (
   Create an EFI event in the Ready To Boot Event Group.\r
 \r
   Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library\r
-  abstracts the implementation mechanism of this event from the caller.   \r
-  This function abstracts the creation of the Ready to Boot Event.  The Framework \r
-  moved from a proprietary to UEFI 2.0-based mechanism.  This library abstracts \r
-  the caller from how this event is created to prevent the code form having to \r
+  abstracts the implementation mechanism of this event from the caller.\r
+  This function abstracts the creation of the Ready to Boot Event.  The Framework\r
+  moved from a proprietary to UEFI 2.0-based mechanism.  This library abstracts\r
+  the caller from how this event is created to prevent the code form having to\r
   change with the version of the specification supported.\r
   If ReadyToBootEvent is NULL, then ASSERT().\r
 \r
-  @param  ReadyToBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+  @param  ReadyToBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex).\r
 \r
   @retval EFI_SUCCESS       Event was created.\r
   @retval Other             Event was not created.\r
@@ -152,7 +134,7 @@ EfiCreateEventReadyToBoot (
 {\r
   return EfiCreateEventReadyToBootEx (\r
            TPL_CALLBACK,\r
-           InternalEmptyFuntion,\r
+           EfiEventEmptyFunction,\r
            NULL,\r
            ReadyToBootEvent\r
            );\r
@@ -160,8 +142,8 @@ EfiCreateEventReadyToBoot (
 \r
 /**\r
   Create an EFI event in the Ready To Boot Event Group and allows\r
-  the caller to specify a notification function.  \r
-  \r
+  the caller to specify a notification function.\r
+\r
   This function abstracts the creation of the Ready to Boot Event.\r
   The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
   This library abstracts the caller from how this event is created to prevent\r
@@ -181,17 +163,18 @@ EFI_STATUS
 EFIAPI\r
 EfiCreateEventReadyToBootEx (\r
   IN  EFI_TPL           NotifyTpl,\r
-  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
-  IN  VOID              *NotifyContext,  OPTIONAL\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction   OPTIONAL,\r
+  IN  VOID              *NotifyContext   OPTIONAL,\r
   OUT EFI_EVENT         *ReadyToBootEvent\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
+  EFI_STATUS        Status;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
 \r
   ASSERT (ReadyToBootEvent != NULL);\r
 \r
   if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
-    DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r
+    DEBUG ((DEBUG_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r
     ASSERT (FALSE);\r
 \r
     return EFI_UNSUPPORTED;\r
@@ -199,10 +182,20 @@ EfiCreateEventReadyToBootEx (
     //\r
     // For UEFI 2.0 and the future use an Event Group\r
     //\r
+    if (NotifyFunction == NULL) {\r
+      //\r
+      // CreateEventEx will check NotifyFunction is NULL or not and return error.\r
+      // Use dummy routine for the case NotifyFunction is NULL.\r
+      //\r
+      WorkerNotifyFunction = EfiEventEmptyFunction;\r
+    } else {\r
+      WorkerNotifyFunction = NotifyFunction;\r
+    }\r
+\r
     Status = gBS->CreateEventEx (\r
                     EVT_NOTIFY_SIGNAL,\r
                     NotifyTpl,\r
-                    NotifyFunction,\r
+                    WorkerNotifyFunction,\r
                     NotifyContext,\r
                     &gEfiEventReadyToBootGuid,\r
                     ReadyToBootEvent\r
@@ -212,10 +205,9 @@ EfiCreateEventReadyToBootEx (
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().\r
-  \r
+\r
   This function abstracts the signaling of the Ready to Boot Event. The Framework moved\r
   from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller\r
   from how this event is created to prevent to code form having to change with the\r
@@ -228,14 +220,28 @@ EfiSignalEventReadyToBoot (
   VOID\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
-  EFI_EVENT     ReadyToBootEvent;\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   ReadyToBootEvent;\r
+  EFI_EVENT   AfterReadyToBootEvent;\r
 \r
   Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
   if (!EFI_ERROR (Status)) {\r
     gBS->SignalEvent (ReadyToBootEvent);\r
     gBS->CloseEvent (ReadyToBootEvent);\r
   }\r
+\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  EfiEventEmptyFunction,\r
+                  NULL,\r
+                  &gEfiEventAfterReadyToBootGuid,\r
+                  &AfterReadyToBootEvent\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->SignalEvent (AfterReadyToBootEvent);\r
+    gBS->CloseEvent (AfterReadyToBootEvent);\r
+  }\r
 }\r
 \r
 /**\r
@@ -253,8 +259,8 @@ EfiSignalEventLegacyBoot (
   VOID\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
-  EFI_EVENT     LegacyBootEvent;\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   LegacyBootEvent;\r
 \r
   Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r
   if (!EFI_ERROR (Status)) {\r
@@ -263,20 +269,19 @@ EfiSignalEventLegacyBoot (
   }\r
 }\r
 \r
-\r
 /**\r
-  Check to see if the Firmware Volume (FV) Media Device Path is valid \r
-  \r
-  The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.  \r
+  Check to see if the Firmware Volume (FV) Media Device Path is valid\r
+\r
+  The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.\r
   This library function abstracts validating a device path node.\r
-  Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.  \r
-  If it is valid, then return the GUID file name from the device path node.  Otherwise, \r
-  return NULL.  This device path changed in the DXE CIS version 0.92 in a non back ward \r
-  compatible way to not conflict with the UEFI 2.0 specification.  This function abstracts \r
+  Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.\r
+  If it is valid, then return the GUID file name from the device path node.  Otherwise,\r
+  return NULL.  This device path changed in the DXE CIS version 0.92 in a non back ward\r
+  compatible way to not conflict with the UEFI 2.0 specification.  This function abstracts\r
   the differences from the caller.\r
   If FvDevicePathNode is NULL, then ASSERT().\r
 \r
-  @param  FvDevicePathNode  Pointer to FV device path to check.\r
+  @param  FvDevicePathNode  The pointer to FV device path to check.\r
 \r
   @retval NULL              FvDevicePathNode is not valid.\r
   @retval Other             FvDevicePathNode is valid and pointer to NameGuid was returned.\r
@@ -290,28 +295,28 @@ EfiGetNameGuidFromFwVolDevicePathNode (
 {\r
   ASSERT (FvDevicePathNode != NULL);\r
 \r
-  if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
-      DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r
-    return (EFI_GUID *) &FvDevicePathNode->FvFileName;\r
+  if ((DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH) &&\r
+      (DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP))\r
+  {\r
+    return (EFI_GUID *)&FvDevicePathNode->FvFileName;\r
   }\r
 \r
   return NULL;\r
 }\r
 \r
-\r
 /**\r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
-  \r
-  The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.  \r
-  This library function abstracts initializing a device path node.  \r
-  Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure.  This device \r
-  path changed in the DXE CIS version 0.92 in a non back ward compatible way to \r
-  not conflict with the UEFI 2.0 specification.  This function abstracts the \r
+\r
+  The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.\r
+  This library function abstracts initializing a device path node.\r
+  Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure.  This device\r
+  path changed in the DXE CIS version 0.92 in a non back ward compatible way to\r
+  not conflict with the UEFI 2.0 specification.  This function abstracts the\r
   differences from the caller.\r
   If FvDevicePathNode is NULL, then ASSERT().\r
   If NameGuid is NULL, then ASSERT().\r
-  \r
-  @param  FvDevicePathNode  Pointer to a FV device path node to initialize\r
+\r
+  @param  FvDevicePathNode  The pointer to a FV device path node to initialize\r
   @param  NameGuid          FV file name to use in FvDevicePathNode\r
 \r
 **/\r
@@ -328,10 +333,9 @@ EfiInitializeFwVolDevicepathNode (
   //\r
   // Use the new Device path that does not conflict with the UEFI\r
   //\r
-  FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
-  FvDevicePathNode->Header.SubType  = MEDIA_PIWG_FW_FILE_DP;\r
+  FvDevicePathNode->Header.Type    = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r
   SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
 \r
   CopyGuid (&FvDevicePathNode->FvFileName, NameGuid);\r
 }\r
-\r