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