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