]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Misc/Stall.c
Assert() break point default is DEADLOOP().
[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
23EFI_STATUS\r
24EFIAPI\r
25CoreStall (\r
26 IN UINTN Microseconds\r
27 )\r
28/*++\r
29\r
30Routine Description:\r
31\r
32 Introduces a fine-grained stall.\r
33\r
34Arguments:\r
35\r
36 Microseconds The number of microseconds to stall execution\r
37\r
38Returns:\r
39\r
40 EFI_SUCCESS - Execution was stalled for at least the requested amount\r
41 of microseconds.\r
42\r
43 EFI_NOT_AVAILABLE_YET - gMetronome is not available yet\r
44\r
45--*/\r
46{\r
47 UINT32 Counter;\r
48 UINT32 Remainder;\r
49\r
50 if (gMetronome == NULL) {\r
51 return EFI_NOT_AVAILABLE_YET;\r
52 }\r
53\r
54 //\r
55 // Calculate the number of ticks by dividing the number of microseconds by\r
56 // the TickPeriod.\r
57 // Calcullation is based on 100ns unit.\r
58 //\r
59 Counter = (UINT32) DivU64x32Remainder (\r
60 Microseconds * 10,\r
61 gMetronome->TickPeriod,\r
62 &Remainder\r
63 );\r
64\r
65 //\r
66 // Call WaitForTick for Counter + 1 ticks to try to guarantee Counter tick\r
67 // periods, thus attempting to ensure Microseconds of stall time.\r
68 //\r
69 if (Remainder != 0) {\r
70 Counter++;\r
71 }\r
72\r
73 gMetronome->WaitForTick (gMetronome, Counter);\r
74\r
75 return EFI_SUCCESS;\r
76}\r