]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Application/Ping6/Ping6.c
1. Fix a bug in PXE driver that the PXE boot do not restart if a new boot option...
[mirror_edk2.git] / NetworkPkg / Application / Ping6 / Ping6.c
index b86ee18ae5bf01ada301491b0d8806e00ed75a74..0de332fcce456f70f14be225c06a465968b8080f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation for Ping6 application.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -58,8 +58,7 @@ SHELL_PARAM_ITEM    Ping6ParamList[] = {
 EFI_HII_HANDLE    mHiiHandle;\r
 CONST CHAR16      *mIp6DstString;\r
 CONST CHAR16      *mIp6SrcString;\r
-EFI_GUID          mEfiPing6Guid = EFI_PING6_GUID;\r
-UINT32            mFrequency = 0;\r
+UINT64            mFrequency = 0;\r
 /**\r
   Get and caculate the frequency in tick/ms.\r
   The result is saved in the globle variable mFrequency\r
@@ -76,7 +75,7 @@ Ping6GetFrequency (
   EFI_STATUS               Status;\r
   EFI_CPU_ARCH_PROTOCOL    *Cpu;\r
   UINT64                   CurrentTick;\r
-  UINT32                   TimerPeriod;\r
+  UINT64                   TimerPeriod;\r
 \r
   Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &Cpu);\r
 \r
@@ -84,20 +83,20 @@ Ping6GetFrequency (
     return Status;\r
   }\r
 \r
-  Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTick, (UINT64 *) &TimerPeriod);\r
+  Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTick, &TimerPeriod);\r
 \r
   if (EFI_ERROR (Status)) {\r
     //\r
     // For NT32 Simulator only. 358049 is a similar value to keep timer granularity.\r
     // Set the timer period by ourselves.\r
     //\r
-    TimerPeriod = NTTIMERPERIOD;\r
+    TimerPeriod = (UINT64) NTTIMERPERIOD;\r
   }\r
   //\r
   // The timer period is in femtosecond (1 femtosecond is 1e-15 second).\r
   // So 1e+12 is divided by timer period to produce the freq in tick/ms.\r
   //\r
-  mFrequency = (UINT32) DivU64x32 (1000000000000ULL, TimerPeriod);\r
+  mFrequency = DivU64x64Remainder (1000000000000ULL, TimerPeriod, NULL);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -111,14 +110,14 @@ Ping6GetFrequency (
   @return The duration in ms.\r
 \r
 **/\r
-UINT32\r
+UINT64\r
 Ping6CalculateTick (\r
   IN UINT64    Begin,\r
   IN UINT64    End\r
   )\r
 {\r
   ASSERT (End > Begin);\r
-  return (UINT32) DivU64x32 (End - Begin, mFrequency);\r
+  return DivU64x64Remainder (End - Begin, mFrequency, NULL);\r
 }\r
 \r
 /**\r
@@ -242,7 +241,7 @@ Ping6OnEchoReplyReceived (
   EFI_IP6_RECEIVE_DATA        *RxData;\r
   ICMP6_ECHO_REQUEST_REPLY    *Reply;\r
   UINT32                      PayLoad;\r
-  UINT32                      Rtt;\r
+  UINT64                      Rtt;\r
   CHAR8                       Near;\r
 \r
   Private = (PING6_PRIVATE_DATA *) Context;\r
@@ -524,7 +523,7 @@ Ping6OnTimerRoutine (
   PING6_ICMP6_TX_INFO    *TxInfo;\r
   LIST_ENTRY             *Entry;\r
   LIST_ENTRY             *NextEntry;\r
-  UINT32                 Time;\r
+  UINT64                 Time;\r
 \r
   Private = (PING6_PRIVATE_DATA *) Context;\r
 \r
@@ -803,13 +802,13 @@ ON_ERROR:
 }\r
 \r
 /**\r
-  Destory the IP6 instance.\r
+  Destroy the IP6 instance.\r
 \r
   @param[in]    Private    The pointer of PING6_PRIVATE_DATA.\r
 \r
 **/\r
 VOID\r
-Ping6DestoryIp6Instance (\r
+Ping6DestroyIp6Instance (\r
   IN PING6_PRIVATE_DATA    *Private\r
   )\r
 {\r
@@ -870,7 +869,7 @@ Ping6 (
   Private->ImageHandle = ImageHandle;\r
   Private->SendNum     = SendNumber;\r
   Private->BufferSize  = BufferSize;\r
-  Private->RttMin      = 0xFFFF;\r
+  Private->RttMin      = ~((UINT64 )(0x0));\r
   Private->Status      = EFI_NOT_READY;\r
 \r
   InitializeListHead (&Private->TxList);\r
@@ -989,7 +988,7 @@ ON_STAT:
       mHiiHandle,\r
       Private->RttMin,\r
       Private->RttMax,\r
-      Private->RttSum / Private->RxCount\r
+      DivU64x64Remainder (Private->RttSum, Private->RxCount, NULL)\r
       );\r
   }\r
 \r
@@ -1020,7 +1019,7 @@ ON_EXIT:
     }\r
 \r
     if (Private->Ip6ChildHandle != NULL) {\r
-      Ping6DestoryIp6Instance (Private);\r
+      Ping6DestroyIp6Instance (Private);\r
     }\r
 \r
     FreePool (Private);\r