#include <Library/DebugLib.h>\r
#include <Library/TimerLib.h>\r
\r
-#define DEFAULT_DELAY_TIME_IN_MICROSECONDS 10\r
+#define DEFAULT_DELAY_TIME_IN_MICROSECONDS 10\r
\r
/**\r
Using the TimerLib GetPerformanceCounterProperties() we delay\r
VOID\r
)\r
{\r
- UINT64 CounterHz;\r
+ UINT64 CounterHz;\r
\r
// Get the counter properties\r
CounterHz = GetPerformanceCounterProperties (NULL, NULL);\r
// Make sure we won't divide by zero\r
if (CounterHz == 0) {\r
- ASSERT(CounterHz != 0); // Assert so the developer knows something is wrong\r
+ ASSERT (CounterHz != 0); // Assert so the developer knows something is wrong\r
return DEFAULT_DELAY_TIME_IN_MICROSECONDS;\r
}\r
+\r
// Calculate the minimum delay based on 1.5 microseconds divided by the hertz.\r
// We calculate the length of a cycle (1/CounterHz) and multiply it by 1.5 microseconds\r
// This ensures that the performance counter has increased by at least one\r
- return (UINT32)(MAX (DivU64x64Remainder (1500000,CounterHz, NULL), 1));\r
+ return (UINT32)(MAX (DivU64x64Remainder (1500000, CounterHz, NULL), 1));\r
}\r
\r
-\r
/**\r
Generates a 16-bit random number.\r
\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber16 (\r
- OUT UINT16 *Rand\r
+ OUT UINT16 *Rand\r
)\r
{\r
UINT32 Index;\r
- UINT8 *RandPtr;\r
+ UINT8 *RandPtr;\r
UINT32 DelayInMicroSeconds;\r
\r
ASSERT (Rand != NULL);\r
if (Rand == NULL) {\r
return FALSE;\r
}\r
+\r
DelayInMicroSeconds = CalculateMinimumDecentDelayInMicroseconds ();\r
- RandPtr = (UINT8*)Rand;\r
+ RandPtr = (UINT8 *)Rand;\r
// Get 2 bytes of random ish data\r
- for (Index = 0; Index < sizeof(UINT16); Index ++) {\r
+ for (Index = 0; Index < sizeof (UINT16); Index++) {\r
*RandPtr = (UINT8)(GetPerformanceCounter () & 0xFF);\r
// Delay to give the performance counter a chance to change\r
MicroSecondDelay (DelayInMicroSeconds);\r
RandPtr++;\r
}\r
+\r
return TRUE;\r
}\r
\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber32 (\r
- OUT UINT32 *Rand\r
+ OUT UINT32 *Rand\r
)\r
{\r
UINT32 Index;\r
- UINT8 *RandPtr;\r
+ UINT8 *RandPtr;\r
UINT32 DelayInMicroSeconds;\r
\r
ASSERT (Rand != NULL);\r
return FALSE;\r
}\r
\r
- RandPtr = (UINT8 *) Rand;\r
+ RandPtr = (UINT8 *)Rand;\r
DelayInMicroSeconds = CalculateMinimumDecentDelayInMicroseconds ();\r
// Get 4 bytes of random ish data\r
- for (Index = 0; Index < sizeof(UINT32); Index ++) {\r
+ for (Index = 0; Index < sizeof (UINT32); Index++) {\r
*RandPtr = (UINT8)(GetPerformanceCounter () & 0xFF);\r
// Delay to give the performance counter a chance to change\r
MicroSecondDelay (DelayInMicroSeconds);\r
RandPtr++;\r
}\r
+\r
return TRUE;\r
}\r
\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber64 (\r
- OUT UINT64 *Rand\r
+ OUT UINT64 *Rand\r
)\r
{\r
UINT32 Index;\r
- UINT8 *RandPtr;\r
+ UINT8 *RandPtr;\r
UINT32 DelayInMicroSeconds;\r
\r
ASSERT (Rand != NULL);\r
return FALSE;\r
}\r
\r
- RandPtr = (UINT8 *)Rand;\r
+ RandPtr = (UINT8 *)Rand;\r
DelayInMicroSeconds = CalculateMinimumDecentDelayInMicroseconds ();\r
// Get 8 bytes of random ish data\r
- for (Index = 0; Index < sizeof(UINT64); Index ++) {\r
+ for (Index = 0; Index < sizeof (UINT64); Index++) {\r
*RandPtr = (UINT8)(GetPerformanceCounter () & 0xFF);\r
// Delay to give the performance counter a chance to change\r
MicroSecondDelay (DelayInMicroSeconds);\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber128 (\r
- OUT UINT64 *Rand\r
+ OUT UINT64 *Rand\r
)\r
{\r
ASSERT (Rand != NULL);\r