]> git.proxmox.com Git - mirror_edk2.git/blame - 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
504214c4
LG
1/** @file \r
2\r
3 UEFI Miscellaneous boot Services Stall service implementation\r
28a00297 4\r
504214c4 5Copyright (c) 2006 - 2008, Intel Corporation\r
28a00297 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
504214c4 14**/\r
28a00297 15\r
16//\r
17// Include statements\r
18//\r
19\r
20#include <DxeMain.h>\r
21\r
22\r
28a00297 23\r
162ed594 24/**\r
28a00297 25 Introduces a fine-grained stall.\r
26\r
162ed594 27 @param Microseconds The number of microseconds to stall execution.\r
28a00297 28\r
162ed594 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
28a00297 32\r
162ed594 33**/\r
34EFI_STATUS\r
35EFIAPI\r
36CoreStall (\r
37 IN UINTN Microseconds\r
38 )\r
28a00297 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