]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiNotTiano.c
Removed CommonHeader.h generated file from the MdePkg.
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
index f883c1d3c6247233ac44ff55647978f2ceb4795b..f51a16cb7e7a2a648bddd7c557c97f24b2a9f880 100644 (file)
@@ -2,10 +2,11 @@
   Library functions that abstract areas of conflict between Tiano an 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
-  (R8.5/EFI 1.10) and new (R9/UEFI 2.0) way.\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
+  it contains DXE enum extensions for EFI event services.\r
 \r
-Copyright (c) 2006, Intel Corporation<BR>\r
+Copyright (c) 2006 - 2007, 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
@@ -17,15 +18,37 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 \r
+//\r
+// Include common header file for this module.\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
+  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
+/**\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
+  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 R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to \r
+  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r
   work both ways.\r
 \r
   @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
@@ -39,48 +62,77 @@ EFIAPI
 EfiCreateEventLegacyBoot (\r
   OUT EFI_EVENT  *LegacyBootEvent\r
   )\r
+{\r
+  return EfiCreateEventLegacyBootEx (\r
+           TPL_CALLBACK,\r
+           InternalEmptyFuntion,\r
+           NULL,\r
+           LegacyBootEvent\r
+           );\r
+}\r
+\r
+/**\r
+  Create an EFI event in the Legacy Boot Event Group and allows\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
+  to code form having to change with the version of the specification supported.\r
+  If LegacyBootEvent is NULL, then ASSERT().\r
+\r
+  @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
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventLegacyBootEx (\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT EFI_EVENT         *LegacyBootEvent\r
+  )\r
 {\r
   EFI_STATUS    Status;\r
 \r
   ASSERT (LegacyBootEvent != NULL);\r
 \r
-#if (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
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\r
-                  LegacyBootEvent\r
-                  );\r
-#else\r
-  //\r
-  // For UEFI 2.0 and the future use an Event Group\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVENT_NOTIFY_SIGNAL,\r
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\r
-                  &gEfiEventLegacyBootGuid,\r
-                  LegacyBootEvent\r
-                  );\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
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    NotifyTpl,\r
+                    NotifyFunction,\r
+                    NotifyContext,\r
+                    &gEfiEventLegacyBootGuid,\r
+                    LegacyBootEvent\r
+                    );\r
+  }\r
+\r
   return Status;\r
 }\r
 \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
+  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
+  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 R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to \r
+  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r
   work both ways.\r
 \r
   @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
@@ -94,45 +146,75 @@ EFIAPI
 EfiCreateEventReadyToBoot (\r
   OUT EFI_EVENT  *ReadyToBootEvent\r
   )\r
+{\r
+  return EfiCreateEventReadyToBootEx (\r
+           TPL_CALLBACK,\r
+           InternalEmptyFuntion,\r
+           NULL,\r
+           ReadyToBootEvent\r
+           );\r
+}\r
+\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
+  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
+  to code form having to change with the version of the specification supported.\r
+  If ReadyToBootEvent is NULL, then ASSERT().\r
+\r
+  @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
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventReadyToBootEx (\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT EFI_EVENT         *ReadyToBootEvent\r
+  )\r
 {\r
   EFI_STATUS    Status;\r
 \r
   ASSERT (ReadyToBootEvent != NULL);\r
 \r
-#if (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
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\r
-                  ReadyToBootEvent\r
-                  );\r
-#else\r
-  //\r
-  // For UEFI 2.0 and the future use an Event Group\r
-  //\r
-  Status = gBS->CreateEventEx (\r
-                  EVENT_NOTIFY_SIGNAL,\r
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\r
-                  &gEfiEventReadyToBootGuid,\r
-                  ReadyToBootEvent\r
-                  );\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
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    NotifyTpl,\r
+                    NotifyFunction,\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
+  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
 \r
 **/\r
 VOID\r
@@ -152,10 +234,10 @@ 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
+  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
 \r
 **/\r
 VOID\r
@@ -176,12 +258,12 @@ EfiSignalEventLegacyBoot (
 \r
 \r
 /**\r
-  Check to see if the Firmware Volume (FV) Media Device Path is valid \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 PIWG extensions of device path. If the code \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
@@ -193,47 +275,31 @@ EfiSignalEventLegacyBoot (
   @retval Other             FvDevicePathNode is valid and pointer to NameGuid was returned.\r
 \r
 **/\r
-EFI_GUID *\r
+EFI_GUID*\r
 EFIAPI\r
 EfiGetNameGuidFromFwVolDevicePathNode (\r
-  IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode\r
+  IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvFileDevicePathNode\r
   )\r
 {\r
-  ASSERT (FvDevicePathNode != NULL);\r
+  ASSERT (FvFileDevicePathNode != NULL);\r
 \r
-#if (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 (FvFileDevicePathNode->Header.Type == MEDIA_DEVICE_PATH &&\r
+      FvFileDevicePathNode->Header.SubType == MEDIA_PIWG_FW_FILE_DP\r
+     ) {\r
+    return (EFI_GUID *) &FvFileDevicePathNode->FvFileName;\r
   }\r
 \r
-#else\r
-  //\r
-  // Use the new Device path that does not conflict with the UEFI\r
-  //\r
-  if (FvDevicePathNode->Piwg.Header.Type == MEDIA_DEVICE_PATH ||\r
-      FvDevicePathNode->Piwg.Header.SubType == MEDIA_VENDOR_DP) {\r
-    if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r
-      if (FvDevicePathNode->Piwg.Type == PIWG_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
+\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 PIWG extensions of device path. If the code \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
@@ -244,42 +310,20 @@ EfiGetNameGuidFromFwVolDevicePathNode (
 VOID\r
 EFIAPI\r
 EfiInitializeFwVolDevicepathNode (\r
-  IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode,\r
-  IN CONST EFI_GUID                         *NameGuid\r
+  IN OUT    MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode,\r
+  IN CONST  EFI_GUID                          *NameGuid\r
   )\r
 {\r
-  ASSERT (FvDevicePathNode  != NULL);\r
+  ASSERT (FvFileDevicePathNode  != NULL);\r
   ASSERT (NameGuid          != NULL);\r
 \r
-#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
-  //\r
-  // Use old Device Path that conflicts with UEFI\r
-  //\r
-  FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
-  FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_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->Piwg.Header.Type     = MEDIA_DEVICE_PATH;\r
-  FvDevicePathNode->Piwg.Header.SubType  = MEDIA_VENDOR_DP;\r
-  SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
-\r
-  //\r
-  // Add the GUID for generic PIWG device paths\r
-  //\r
-  CopyGuid (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
-\r
-  //\r
-  // Add in the FW Vol File Path PIWG defined inforation\r
-  //\r
-  FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
-\r
-#endif\r
-\r
-  CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
+  FvFileDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvFileDevicePathNode->Header.SubType  = MEDIA_PIWG_FW_FILE_DP;\r
+  SetDevicePathNodeLength (&FvFileDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
 \r
+  CopyGuid (&FvFileDevicePathNode->FvFileName, NameGuid);\r
 }\r
 \r