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
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
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
{\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
{\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
{\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
{\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
{\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
{\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
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
return CpuIo->IoRead8 (PeiServices, CpuIo, (UINT64) Port);\r
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
CpuIo->IoWrite8 (PeiServices, CpuIo, (UINT64) Port, Value);\r
\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
\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
\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
\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
\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
\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
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
return CpuIo->MemRead8 (PeiServices, CpuIo, (UINT64) Address);\r
\r
PeiServices = GetPeiServicesTablePointer ();\r
CpuIo = (*PeiServices)->CpuIo;\r
-\r
ASSERT (CpuIo != NULL);\r
\r
CpuIo->MemWrite8 (PeiServices, CpuIo, (UINT64) Address, Value);\r
\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
\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
\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
\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
\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
\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
{\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
{\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
{\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
{\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
\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
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
//\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
//\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
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
//\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
//\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