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