]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiNotTiano.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
index ce59eaf417c0e4dab77d3f8354ef41e5f7f6e88a..5e32f4abf4632ba3148349087197b80b538a7f76 100644 (file)
@@ -1,50 +1,30 @@
 /** @file\r
-  Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r
+  Library functions that abstract areas of conflict between framework and UEFI 2.0.\r
 \r
-  Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r
-  oldconflicts with library functions and supporting implementations of the old \r
-  (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as \r
+  Help Port Framework code that has conflicts with UEFI 2.0 by hiding the\r
+  old conflicts with library functions and supporting implementations of the old\r
+  (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, 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
-  An empty function to pass error checking of CreateEventEx (). \r
-  \r
-  This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r
-  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
-  \r
-**/\r
-STATIC\r
-VOID\r
-EFIAPI\r
-InternalEmptyFuntion (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  return;\r
-}\r
+\r
+#include "UefiLibInternal.h"\r
 \r
 /**\r
-  Create a Legacy Boot Event.  \r
-  \r
-  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
-  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
-  added and now it's possible to not voilate the UEFI specification by \r
-  declaring a GUID for the legacy boot event class. This library supports\r
-  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
-  work both ways.\r
+  Creates an EFI event in the Legacy Boot Event Group.\r
+\r
+  Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library\r
+  abstracts the implementation mechanism of this event from the caller. This function\r
+  abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary\r
+  to UEFI 2.0 based mechanism.  This library abstracts the caller from how this event\r
+  is created to prevent to code form having to change with the version of the\r
+  specification supported.\r
+  If LegacyBootEvent is NULL, then ASSERT().\r
 \r
   @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
 \r
@@ -59,8 +39,8 @@ EfiCreateEventLegacyBoot (
   )\r
 {\r
   return EfiCreateEventLegacyBootEx (\r
-           EFI_TPL_CALLBACK,\r
-           InternalEmptyFuntion,\r
+           TPL_CALLBACK,\r
+           EfiEventEmptyFunction,\r
            NULL,\r
            LegacyBootEvent\r
            );\r
@@ -68,8 +48,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
@@ -94,54 +74,54 @@ EfiCreateEventLegacyBootEx (
   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 ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
-  //\r
-  // prior to UEFI 2.0 use Tiano extension to EFI\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
-                  NotifyTpl,\r
-                  NotifyFunction,\r
-                  NotifyContext,\r
-                  LegacyBootEvent\r
-                  );\r
-#elif (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  //\r
-  // For UEFI 2.0 and the future use an Event Group\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVENT_NOTIFY_SIGNAL,\r
-                  NotifyTpl,\r
-                  NotifyFunction,\r
-                  NotifyContext,\r
-                  &gEfiEventLegacyBootGuid,\r
-                  LegacyBootEvent\r
-                  );\r
-#else\r
-  //\r
-  // For EFI 1.10 with no Tiano extensions return unsupported\r
-  //\r
-  Status = EFI_UNSUPORTED;\r
-#endif\r
+  if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
+    DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r
+    ASSERT (FALSE);\r
+\r
+    return EFI_UNSUPPORTED;\r
+  } else {\r
+    //\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
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    NotifyTpl,\r
+                    WorkerNotifyFunction,\r
+                    NotifyContext,\r
+                    &gEfiEventLegacyBootGuid,\r
+                    LegacyBootEvent\r
+                    );\r
+  }\r
 \r
   return Status;\r
 }\r
 \r
 /**\r
-  Create a Read to Boot Event.  \r
-  \r
-  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
-  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
-  added and now it's possible to not voilate the UEFI specification and use \r
-  the ready to boot event class defined in UEFI 2.0. This library supports\r
-  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
-  work both ways.\r
+  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
+  change with the version of the specification supported.\r
+  If ReadyToBootEvent is NULL, then ASSERT().\r
 \r
-  @param  LegacyBootEvent   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
@@ -154,8 +134,8 @@ EfiCreateEventReadyToBoot (
   )\r
 {\r
   return EfiCreateEventReadyToBootEx (\r
-           EFI_TPL_CALLBACK,\r
-           InternalEmptyFuntion,\r
+           TPL_CALLBACK,\r
+           EfiEventEmptyFunction,\r
            NULL,\r
            ReadyToBootEvent\r
            );\r
@@ -163,8 +143,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
@@ -174,7 +154,7 @@ EfiCreateEventReadyToBoot (
   @param  NotifyTpl         The task priority level of the event.\r
   @param  NotifyFunction    The notification function to call when the event is signaled.\r
   @param  NotifyContext     The content to pass to NotifyFunction when the event is signaled.\r
-  @param  LegacyBootEvent   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
@@ -189,49 +169,50 @@ EfiCreateEventReadyToBootEx (
   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 ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
-  //\r
-  // prior to UEFI 2.0 use Tiano extension to EFI\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
-                  NotifyTpl,\r
-                  NotifyFunction,\r
-                  NotifyContext,\r
-                  ReadyToBootEvent\r
-                  );\r
-#elif (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  //\r
-  // For UEFI 2.0 and the future use an Event Group\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVENT_NOTIFY_SIGNAL,\r
-                  NotifyTpl,\r
-                  NotifyFunction,\r
-                  NotifyContext,\r
-                  &gEfiEventReadyToBootGuid,\r
-                  ReadyToBootEvent\r
-                  );\r
-#else\r
-  //\r
-  // For EFI 1.10 with no Tiano extensions return unsupported\r
-  //\r
-  Status = EFI_UNSUPORTED;\r
-#endif\r
+  if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
+    DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r
+    ASSERT (FALSE);\r
+\r
+    return EFI_UNSUPPORTED;\r
+  } else {\r
+    //\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
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    NotifyTpl,\r
+                    WorkerNotifyFunction,\r
+                    NotifyContext,\r
+                    &gEfiEventReadyToBootGuid,\r
+                    ReadyToBootEvent\r
+                    );\r
+  }\r
 \r
   return Status;\r
 }\r
 \r
 \r
 /**\r
-  Signal a Ready to Boot Event.  \r
-  \r
-  Create a Ready to Boot Event. Signal it and close it. This causes other \r
-  events of the same event group to be signaled in other modules. \r
+  Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().\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
+  version of the specification supported.\r
 \r
 **/\r
 VOID\r
@@ -251,10 +232,12 @@ EfiSignalEventReadyToBoot (
 }\r
 \r
 /**\r
-  Signal a Legacy Boot Event.  \r
-  \r
-  Create a legacy Boot Event. Signal it and close it. This causes other \r
-  events of the same event group to be signaled in other modules. \r
+  Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().\r
+\r
+  This function abstracts the signaling of the Legacy Boot Event. The Framework moved from\r
+  a proprietary to UEFI 2.0 based mechanism.  This library abstracts the caller from how\r
+  this event is created to prevent to code form having to change with the version of the\r
+  specification supported.\r
 \r
 **/\r
 VOID\r
@@ -275,18 +258,18 @@ EfiSignalEventLegacyBoot (
 \r
 \r
 /**\r
-  Check to see if the Firmware Volume (FV) Media Device Path is valid \r
-  \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for Tiano extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability. The return value to this\r
-  function points to a location in FvDevicePathNode and it does not allocate\r
-  new memory for the GUID pointer that is returned.\r
-\r
-  @param  FvDevicePathNode  Pointer to FV device path to check.\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
+  the differences from the caller.\r
+  If FvDevicePathNode is NULL, then ASSERT().\r
+\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
@@ -300,43 +283,28 @@ EfiGetNameGuidFromFwVolDevicePathNode (
 {\r
   ASSERT (FvDevicePathNode != NULL);\r
 \r
-#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
-  //\r
-  // Use old Device Path that conflicts with UEFI\r
-  //\r
-  if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH ||\r
-      DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
-    return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
+  if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r
+    return (EFI_GUID *) &FvDevicePathNode->FvFileName;\r
   }\r
 \r
-#elif ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION >= 0x00020000))\r
-  //\r
-  // Use the new Device path that does not conflict with the UEFI\r
-  //\r
-  if (FvDevicePathNode->Tiano.Header.Type == MEDIA_DEVICE_PATH ||\r
-      FvDevicePathNode->Tiano.Header.SubType == MEDIA_VENDOR_DP) {\r
-    if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Tiano.TianoSpecificDevicePath)) {\r
-      if (FvDevicePathNode->Tiano.Type == TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
-        return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
-      }\r
-    }\r
-  }\r
-#endif  \r
   return NULL;\r
 }\r
 \r
 \r
 /**\r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
-  \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for Tiano extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability.\r
-\r
-  @param  FvDevicePathNode  Pointer to a FV device path node to initialize\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  The pointer to a FV device path node to initialize\r
   @param  NameGuid          FV file name to use in FvDevicePathNode\r
 \r
 **/\r
@@ -347,38 +315,16 @@ EfiInitializeFwVolDevicepathNode (
   IN CONST EFI_GUID                         *NameGuid\r
   )\r
 {\r
-  ASSERT (FvDevicePathNode  != NULL);\r
+  ASSERT (FvDevicePathNode != NULL);\r
   ASSERT (NameGuid          != NULL);\r
 \r
-#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
   //\r
-  // Use old Device Path that conflicts with UEFI\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_FV_FILEPATH_DP;\r
+  FvDevicePathNode->Header.SubType  = MEDIA_PIWG_FW_FILE_DP;\r
   SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
-  \r
-#else\r
-  //\r
-  // Use the new Device path that does not conflict with the UEFI\r
-  //\r
-  FvDevicePathNode->Tiano.Header.Type     = MEDIA_DEVICE_PATH;\r
-  FvDevicePathNode->Tiano.Header.SubType  = MEDIA_VENDOR_DP;\r
-  SetDevicePathNodeLength (&FvDevicePathNode->Tiano.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
-\r
-  //\r
-  // Add the GUID for generic Tiano device paths\r
-  //\r
-  CopyGuid (&FvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
-\r
-  //\r
-  // Add in the FW Vol File Path Tiano defined information\r
-  //\r
-  FvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
-\r
-#endif\r
-\r
-  CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
 \r
+  CopyGuid (&FvDevicePathNode->FvFileName, NameGuid);\r
 }\r
 \r