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