);\r
\r
/**\r
- Initialize a random seed using current time.\r
+ Initialize a random seed using current time and monotonic count.\r
\r
- Get current time first. Then initialize a random seed based on some basic\r
- mathematical operations on the hour, day, minute, second, nanosecond and year\r
- of the current time.\r
+ Get current time and monotonic count first. Then initialize a random seed \r
+ based on some basic mathematics operation on the hour, day, minute, second,\r
+ nanosecond and year of the current time and the monotonic count value.\r
\r
- @return The random seed, initialized with current time.\r
+ @return The random seed initialized with current time.\r
\r
**/\r
UINT32\r
}\r
\r
/**\r
- Initialize a random seed using current time.\r
+ Initialize a random seed using current time and monotonic count.\r
\r
- Get current time first. Then initialize a random seed based on some basic\r
- mathematics operation on the hour, day, minute, second, nanosecond and year\r
- of the current time.\r
+ Get current time and monotonic count first. Then initialize a random seed \r
+ based on some basic mathematics operation on the hour, day, minute, second,\r
+ nanosecond and year of the current time and the monotonic count value.\r
\r
@return The random seed initialized with current time.\r
\r
{\r
EFI_TIME Time;\r
UINT32 Seed;\r
+ UINT64 MonotonicCount;\r
\r
gRT->GetTime (&Time, NULL);\r
Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);\r
Seed ^= Time.Nanosecond;\r
Seed ^= Time.Year << 7;\r
\r
+ gBS->GetNextMonotonicCount (&MonotonicCount);\r
+ Seed += (UINT32) MonotonicCount;\r
+\r
return Seed;\r
}\r
\r