]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiLib:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 4 Jun 2006 13:08:25 +0000 (13:08 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 4 Jun 2006 13:08:25 +0000 (13:08 +0000)
Add two new interfaces of EfiCreateEventLegacyBootEx & EfiCreateEventReadyToBootEx
Fix a bug in EfiCreateEventLegacyBoot & EfiCreateEventReadyToBoot. (#51)
PciLib:
Add missing ASSERT()s in PciReadBuffer() & PciWriteBuffer() (#70)
IoLib
Add ASSERT()s to check alignment.
MemoryAllocationLib:
For AllocateXXXCopyBuffer(). Add ASSERT()s for cases when allocations fails.
BaseLib:
Change the return type of InternalMathModU64x32 from UINT64 to UINT32

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@416 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/UefiLib.h
MdePkg/Library/BaseLib/Math64.c
MdePkg/Library/BasePciCf8Lib/PciLib.c
MdePkg/Library/BasePciExpressLib/PciLib.c
MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
MdePkg/Library/PeiIoLibCpuIo/IoLib.c
MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
MdePkg/Library/UefiLib/UefiNotTiano.c

index fd3bdac53e5af7b01fd3ef923272b4b9d9e04557..428235cbf23640a4406100614c0089a224743eae 100644 (file)
@@ -415,6 +415,34 @@ EfiCreateEventLegacyBoot (
   OUT EFI_EVENT  *LegacyBootEvent\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
 /**\r
   Create a Read to Boot Event.  \r
   \r
@@ -437,6 +465,34 @@ EfiCreateEventReadyToBoot (
   OUT EFI_EVENT  *ReadyToBootEvent\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
 /**\r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
   \r
index 27d75232c504bc2d8124c64eb564004ddebb9e0d..57dcca387faaecbe0b2c793e133cb71b3545a4f2 100644 (file)
@@ -121,14 +121,14 @@ InternalMathDivU64x32 (
   return Dividend / Divisor;\r
 }\r
 \r
-UINT64\r
+UINT32\r
 EFIAPI\r
 InternalMathModU64x32 (\r
   IN      UINT64                    Dividend,\r
   IN      UINT32                    Divisor\r
   )\r
 {\r
-  return Dividend % Divisor;\r
+  return (UINT32)(Dividend % Divisor);\r
 }\r
 \r
 UINT64\r
index fe27c850c1f2e9064dce78c4f1477222e62efb24..108c95291c0da95863c34c73c030741f43573f4c 100644 (file)
@@ -1298,6 +1298,11 @@ PciCf8ReadBuffer (
 {\r
   UINTN                             EndAddress;\r
 \r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
+  ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF);\r
+  ASSERT (Buffer != NULL);\r
+\r
   EndAddress = StartAddress + Size;\r
 \r
   if (StartAddress < EndAddress && (StartAddress & 1)) {\r
@@ -1382,6 +1387,11 @@ PciCf8WriteBuffer (
 {\r
   UINTN                             EndAddress;\r
 \r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
+  ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF);\r
+  ASSERT (Buffer != NULL);\r
+\r
   EndAddress = StartAddress + Size;\r
 \r
   if ((StartAddress < EndAddress) && ((StartAddress & 1)!= 0)) {\r
index 3003613486a9bce2906c1de844a80d543890e8ca..de33bf30555a5b4d89623b3d63777e26706a90ec 100644 (file)
@@ -1195,6 +1195,11 @@ PciExpressReadBuffer (
 {\r
   UINTN                             EndAddress;\r
 \r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
+  ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF);\r
+  ASSERT (Buffer != NULL);\r
+\r
   EndAddress = StartAddress + Size;\r
 \r
   if (StartAddress < EndAddress && (StartAddress & 1)) {\r
@@ -1278,6 +1283,11 @@ PciExpressWriteBuffer (
 {\r
   UINTN                             EndAddress;\r
 \r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
+  ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF);\r
+  ASSERT (Buffer != NULL);\r
+\r
   EndAddress = StartAddress + Size;\r
 \r
   if ((StartAddress < EndAddress) && ((StartAddress & 1)!= 0)) {\r
index 088a10bb5623f5f27bb67084f979226909a91c18..15a419bc566af3dc8e6f178e5c4afb1418ee51a9 100644 (file)
@@ -474,6 +474,9 @@ InternalAllocateCopyPool (
 {\r
   VOID  *Memory;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
   Memory = InternalAllocatePool (PoolType, AllocationSize);\r
   if (Memory != NULL) {\r
      Memory = CopyMem (Memory, Buffer, AllocationSize);\r
@@ -793,6 +796,9 @@ InternalAllocateAlignedCopyPool (
 {\r
   VOID  *Memory;\r
   \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
   Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
   if (Memory != NULL) {\r
     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
index 2156f6b480f27de6dbc599c129785d8f70fd5ce9..1da0203b5c936c3d0cb09004448dd640599d917a 100644 (file)
@@ -39,7 +39,6 @@ IoRead8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   return CpuIo->IoRead8 (PeiServices, CpuIo, (UINT64) Port);\r
@@ -72,7 +71,6 @@ IoWrite8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   CpuIo->IoWrite8 (PeiServices, CpuIo, (UINT64) Port, Value);\r
@@ -104,9 +102,11 @@ IoRead16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
   return CpuIo->IoRead16 (PeiServices, CpuIo, (UINT64) Port);\r
 }\r
 \r
@@ -137,9 +137,11 @@ IoWrite16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
   CpuIo->IoWrite16 (PeiServices, CpuIo, (UINT64) Port, Value);\r
   return Value;\r
 }\r
@@ -169,9 +171,11 @@ IoRead32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
   return CpuIo->IoRead32 (PeiServices, CpuIo, (UINT64) Port);\r
 }\r
 \r
@@ -202,9 +206,11 @@ IoWrite32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
   CpuIo->IoWrite32 (PeiServices, CpuIo, (UINT64) Port, Value);\r
   return Value;\r
 }\r
@@ -234,9 +240,11 @@ IoRead64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
   return CpuIo->IoRead64 (PeiServices, CpuIo, (UINT64) Port);\r
 }\r
 \r
@@ -267,9 +275,11 @@ IoWrite64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
   CpuIo->IoWrite64 (PeiServices, CpuIo, (UINT64) Port, Value);\r
   return Value;;\r
 }\r
@@ -299,7 +309,6 @@ MmioRead8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   return CpuIo->MemRead8 (PeiServices, CpuIo, (UINT64) Address);\r
@@ -330,7 +339,6 @@ MmioWrite8 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
 \r
   CpuIo->MemWrite8 (PeiServices, CpuIo, (UINT64) Address, Value);\r
@@ -362,9 +370,11 @@ MmioRead16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
   return CpuIo->MemRead16 (PeiServices, CpuIo, (UINT64) Address);\r
 \r
 }\r
@@ -394,9 +404,11 @@ MmioWrite16 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
   CpuIo->MemWrite16 (PeiServices, CpuIo, (UINT64) Address, Value);\r
   return Value;\r
 }\r
@@ -426,9 +438,11 @@ MmioRead32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
   return CpuIo->MemRead32 (PeiServices, CpuIo, (UINT64) Address);\r
 \r
 }\r
@@ -458,9 +472,11 @@ MmioWrite32 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
   CpuIo->MemWrite32 (PeiServices, CpuIo, (UINT64) Address, Value);\r
   return Value;\r
 }\r
@@ -490,9 +506,11 @@ MmioRead64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
   return CpuIo->MemRead64 (PeiServices, CpuIo, (UINT64) Address);\r
 \r
 }\r
@@ -522,9 +540,11 @@ MmioWrite64 (
 \r
   PeiServices = GetPeiServicesTablePointer ();\r
   CpuIo       = (*PeiServices)->CpuIo;\r
-\r
   ASSERT (CpuIo != NULL);\r
-\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
   CpuIo->MemWrite64 (PeiServices, CpuIo, (UINT64) Address, Value);\r
   return Value;\r
 }\r
index 274287cf035e216cc537f3c6aff59750efcac32a..59e9a262386ed5d779685e51d53ad86960ab3343 100644 (file)
@@ -451,6 +451,9 @@ InternalAllocateCopyPool (
 {\r
   VOID  *Memory;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
   Memory = InternalAllocatePool (PoolType, AllocationSize);\r
   if (Memory != NULL) {\r
      Memory = CopyMem (Memory, Buffer, AllocationSize);\r
@@ -477,6 +480,9 @@ AllocateCopyPool (
 {\r
   VOID  *Memory;\r
 \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
   Memory = AllocatePool (AllocationSize);\r
   if (Memory != NULL) {\r
      Memory = CopyMem (Memory, Buffer, AllocationSize);\r
@@ -791,6 +797,9 @@ InternalAllocateAlignedCopyPool (
 {\r
   VOID  *Memory;\r
   \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
   Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
   if (Memory != NULL) {\r
     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
@@ -820,6 +829,9 @@ AllocateAlignedCopyPool (
 {\r
   VOID  *Memory;\r
   \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
   Memory = AllocateAlignedPool (AllocationSize, Alignment);\r
   if (Memory != NULL) {\r
     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
index f883c1d3c6247233ac44ff55647978f2ceb4795b..770d76df7eda02ab579752d6ec2e4e649f8ea77a 100644 (file)
@@ -16,7 +16,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-\r
+/**\r
+  An empty function to pass error checking of CreateEventEx (). \r
+  \r
+  This empty function enusres that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
+  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
+  \r
+**/\r
+VOID
+InternalEmptyFuntion (
+  IN EFI_EVENT                Event,
+  IN VOID                     *Context
+  )
+{
+  return;
+}\r
 \r
 /**\r
   Create a Legacy Boot Event.  \r
@@ -39,6 +53,42 @@ 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
@@ -50,9 +100,9 @@ EfiCreateEventLegacyBoot (
   //\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
@@ -61,18 +111,17 @@ EfiCreateEventLegacyBoot (
   //\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
 #endif\r
+\r
   return Status;\r
 }\r
 \r
-\r
-\r
 /**\r
   Create a Read to Boot Event.  \r
   \r
@@ -94,6 +143,42 @@ 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
@@ -105,9 +190,9 @@ EfiCreateEventReadyToBoot (
   //\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
@@ -116,9 +201,9 @@ EfiCreateEventReadyToBoot (
   //\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