]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/Misc/Stall.c
Change the file name case to follow coding style: The first character should be capital.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / Stall.c
... / ...
CommitLineData
1/** @file \r
2\r
3 UEFI Miscellaneous boot Services Stall service implementation\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16//\r
17// Include statements\r
18//\r
19\r
20#include <DxeMain.h>\r
21\r
22\r
23\r
24/**\r
25 Introduces a fine-grained stall.\r
26\r
27 @param Microseconds The number of microseconds to stall execution.\r
28\r
29 @retval EFI_SUCCESS Execution was stalled for at least the requested \r
30 amount of microseconds. \r
31 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet\r
32\r
33**/\r
34EFI_STATUS\r
35EFIAPI\r
36CoreStall (\r
37 IN UINTN Microseconds\r
38 )\r
39{\r
40 UINT32 Counter;\r
41 UINT32 Remainder;\r
42\r
43 if (gMetronome == NULL) {\r
44 return EFI_NOT_AVAILABLE_YET;\r
45 }\r
46\r
47 //\r
48 // Calculate the number of ticks by dividing the number of microseconds by\r
49 // the TickPeriod.\r
50 // Calcullation is based on 100ns unit.\r
51 //\r
52 Counter = (UINT32) DivU64x32Remainder (\r
53 Microseconds * 10,\r
54 gMetronome->TickPeriod,\r
55 &Remainder\r
56 );\r
57\r
58 //\r
59 // Call WaitForTick for Counter + 1 ticks to try to guarantee Counter tick\r
60 // periods, thus attempting to ensure Microseconds of stall time.\r
61 //\r
62 if (Remainder != 0) {\r
63 Counter++;\r
64 }\r
65\r
66 gMetronome->WaitForTick (gMetronome, Counter);\r
67\r
68 return EFI_SUCCESS;\r
69}\r