]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/MetronomeDxe/Metronome.c
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / EmbeddedPkg / MetronomeDxe / Metronome.c
index f8b1fcb8d83f1324d02b2314f84b948d678b0db9..b43bf9558b4fce28ac34587102881852af5a5cb1 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  \r
+  Copyright (c) 2013, ARM Ltd. All rights reserved.\r
+\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 \r
 #include <Protocol/Metronome.h>\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+WaitForTick (\r
+  IN EFI_METRONOME_ARCH_PROTOCOL  *This,\r
+  IN UINT32                       TickNumber\r
+  );\r
+\r
+/**\r
+  Interface structure for the Metronome Architectural Protocol.\r
+\r
+  @par Protocol Description:\r
+  This protocol provides access to a known time source in the platform to the\r
+  core.  The core uses this known time source to produce core services that\r
+  require calibrated delays.\r
+\r
+  @param WaitForTick\r
+  Waits for a specified number of ticks from a known time source\r
+  in the platform.  The actual time passed between entry of this\r
+  function and the first tick is between 0 and TickPeriod 100 nS\r
+  units.  If you want to guarantee that at least TickPeriod time\r
+  has elapsed, wait for two ticks.\r
+\r
+  @param TickPeriod\r
+  The period of platform's known time source in 100 nS units.\r
+  This value on any platform must be at least 10 uS, and must not\r
+  exceed 200 uS.  The value in this field is a constant that must\r
+  not be modified after the Metronome architectural protocol is\r
+  installed.  All consumers must treat this as a read-only field.\r
+\r
+**/\r
+EFI_METRONOME_ARCH_PROTOCOL gMetronome = {\r
+  WaitForTick,\r
+  FixedPcdGet32 (PcdMetronomeTickPeriod)\r
+};\r
 \r
 \r
 /**\r
-  The WaitForTick() function waits for the number of ticks specified by \r
-  TickNumber from a known time source in the platform.  If TickNumber of \r
-  ticks are detected, then EFI_SUCCESS is returned.  The actual time passed \r
-  between entry of this function and the first tick is between 0 and \r
-  TickPeriod 100 nS units.  If you want to guarantee that at least TickPeriod \r
-  time has elapsed, wait for two ticks.  This function waits for a hardware \r
-  event to determine when a tick occurs.  It is possible for interrupt \r
-  processing, or exception processing to interrupt the execution of the \r
-  WaitForTick() function.  Depending on the hardware source for the ticks, it \r
-  is possible for a tick to be missed.  This function cannot guarantee that \r
-  ticks will not be missed.  If a timeout occurs waiting for the specified \r
+  The WaitForTick() function waits for the number of ticks specified by\r
+  TickNumber from a known time source in the platform.  If TickNumber of\r
+  ticks are detected, then EFI_SUCCESS is returned.  The actual time passed\r
+  between entry of this function and the first tick is between 0 and\r
+  TickPeriod 100 nS units.  If you want to guarantee that at least TickPeriod\r
+  time has elapsed, wait for two ticks.  This function waits for a hardware\r
+  event to determine when a tick occurs.  It is possible for interrupt\r
+  processing, or exception processing to interrupt the execution of the\r
+  WaitForTick() function.  Depending on the hardware source for the ticks, it\r
+  is possible for a tick to be missed.  This function cannot guarantee that\r
+  ticks will not be missed.  If a timeout occurs waiting for the specified\r
   number of ticks, then EFI_TIMEOUT is returned.\r
 \r
   @param  This             The EFI_METRONOME_ARCH_PROTOCOL instance.\r
@@ -56,43 +91,15 @@ WaitForTick (
   )\r
 {\r
   //\r
-  // Fill me in\r
+  // Compute how long to stall the CPU.\r
+  // gMetronome.TickPeriod is in 100 ns units so it needs to be divided by 10\r
+  // to get it in microseconds units.\r
   //\r
-  MicroSecondDelay (10 * TickNumber);\r
-  return EFI_UNSUPPORTED;\r
+  MicroSecondDelay (TickNumber * gMetronome.TickPeriod / 10);\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
-\r
-/**\r
-  Interface structure for the Metronome Architectural Protocol.\r
-\r
-  @par Protocol Description:\r
-  This protocol provides access to a known time source in the platform to the\r
-  core.  The core uses this known time source to produce core services that \r
-  require calibrated delays.  \r
-\r
-  @param WaitForTick\r
-  Waits for a specified number of ticks from a known time source \r
-  in the platform.  The actual time passed between entry of this \r
-  function and the first tick is between 0 and TickPeriod 100 nS \r
-  units.  If you want to guarantee that at least TickPeriod time \r
-  has elapsed, wait for two ticks.\r
-\r
-  @param TickPeriod\r
-  The period of platform's known time source in 100 nS units.  \r
-  This value on any platform must be at least 10 uS, and must not \r
-  exceed 200 uS.  The value in this field is a constant that must \r
-  not be modified after the Metronome architectural protocol is \r
-  installed.  All consumers must treat this as a read-only field.\r
-\r
-**/\r
-EFI_METRONOME_ARCH_PROTOCOL gMetronome = {\r
-  WaitForTick,\r
-  100              \r
-};\r
-\r
-\r
 EFI_HANDLE  gMetronomeHandle = NULL;\r
 \r
 \r
@@ -115,7 +122,7 @@ MetronomeInitialize (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  \r
+\r
   //\r
   // Do any hardware init required to make WaitForTick () to work here.\r
   //\r