+\r
+/**\r
+ Calculate the elapsed time.\r
+\r
+ @param[in] Private The pointer to PXE private data\r
+\r
+**/\r
+VOID\r
+CalcElapsedTime (\r
+ IN PXEBC_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ EFI_TIME Time;\r
+ UINT64 CurrentStamp;\r
+ UINT64 ElapsedTimeValue;\r
+\r
+ //\r
+ // Generate a time stamp of the centiseconds from 1900/1/1, assume 30day/month.\r
+ //\r
+ ZeroMem (&Time, sizeof (EFI_TIME));\r
+ gRT->GetTime (&Time, NULL);\r
+ CurrentStamp = MultU64x32 (\r
+ ((((UINT32)(Time.Year - 1900) * 360 + (Time.Month - 1) * 30 + (Time.Day - 1)) * 24 + Time.Hour) * 60 + Time.Minute) * 60 + Time.Second,\r
+ 100\r
+ ) +\r
+ DivU64x32 (\r
+ Time.Nanosecond,\r
+ 10000000\r
+ );\r
+\r
+ //\r
+ // Sentinel value of 0 means that this is the first DHCP packet that we are\r
+ // sending and that we need to initialize the value. First DHCP Solicit\r
+ // gets 0 elapsed-time. Otherwise, calculate based on StartTime.\r
+ //\r
+ if (Private->ElapsedTime == 0) {\r
+ Private->ElapsedTime = CurrentStamp;\r
+ } else {\r
+ ElapsedTimeValue = CurrentStamp - Private->ElapsedTime;\r
+\r
+ //\r
+ // If elapsed time cannot fit in two bytes, set it to 0xffff.\r
+ //\r
+ if (ElapsedTimeValue > 0xffff) {\r
+ ElapsedTimeValue = 0xffff;\r
+ }\r
+ //\r
+ // Save the elapsed time\r
+ //\r
+ Private->ElapsedTime = ElapsedTimeValue;\r
+ }\r
+}\r
+\r