]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiNotTiano.c
Added an extra GDT entry to the GDT used by thunk code. SS register will always be...
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
index f883c1d3c6247233ac44ff55647978f2ceb4795b..7797608b13023de5494599b66bb856ff1fc0e4ca 100644 (file)
@@ -3,7 +3,8 @@
 \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
+  (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
@@ -17,6 +18,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\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
+  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
+  \r
+**/\r
+VOID
+EFIAPI
+InternalEmptyFuntion (
+  IN EFI_EVENT                Event,
+  IN VOID                     *Context
+  )
+{
+  return;
+}\r
 \r
 /**\r
   Create a Legacy Boot Event.  \r
@@ -25,7 +42,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   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 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,40 +56,80 @@ EFIAPI
 EfiCreateEventLegacyBoot (\r
   OUT EFI_EVENT  *LegacyBootEvent\r
   )\r
+{\r
+  return EfiCreateEventLegacyBootEx (\r
+           EFI_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
+#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
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
                   LegacyBootEvent\r
                   );\r
-#else\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
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\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
+\r
   return Status;\r
 }\r
 \r
-\r
-\r
 /**\r
   Create a Read to Boot Event.  \r
   \r
@@ -80,7 +137,7 @@ EfiCreateEventLegacyBoot (
   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 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,34 +151,75 @@ EFIAPI
 EfiCreateEventReadyToBoot (\r
   OUT EFI_EVENT  *ReadyToBootEvent\r
   )\r
+{\r
+  return EfiCreateEventReadyToBootEx (\r
+           EFI_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
+#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
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
                   ReadyToBootEvent\r
                   );\r
-#else\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
-                  EFI_TPL_CALLBACK,\r
-                  NULL,\r
-                  NULL,\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
 \r
   return Status;\r
@@ -181,7 +279,7 @@ EfiSignalEventLegacyBoot (
   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
+  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
@@ -201,7 +299,7 @@ EfiGetNameGuidFromFwVolDevicePathNode (
 {\r
   ASSERT (FvDevicePathNode != NULL);\r
 \r
-#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
+#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
   //\r
   // Use old Device Path that conflicts with UEFI\r
   //\r
@@ -210,14 +308,14 @@ EfiGetNameGuidFromFwVolDevicePathNode (
     return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
   }\r
 \r
-#else\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->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
+  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
@@ -233,7 +331,7 @@ EfiGetNameGuidFromFwVolDevicePathNode (
   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
+  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
@@ -263,19 +361,19 @@ EfiInitializeFwVolDevicepathNode (
   //\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
+  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 PIWG device paths\r
+  // Add the GUID for generic Tiano device paths\r
   //\r
-  CopyGuid (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
+  CopyGuid (&FvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
 \r
   //\r
-  // Add in the FW Vol File Path PIWG defined inforation\r
+  // Add in the FW Vol File Path Tiano defined information\r
   //\r
-  FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
+  FvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
 \r
 #endif\r
 \r