2 EFI_PEI_STALL implementation for NT32 simulation environment.
4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Ppi/NtThunk.h>
11 #include <Ppi/Stall.h>
12 #include <Library/DebugLib.h>
17 IN CONST EFI_PEI_SERVICES
**PeiServices
,
18 IN CONST EFI_PEI_STALL_PPI
*This
,
22 EFI_PEI_STALL_PPI mStallPpi
= {1000, Stall
};
24 EFI_PEI_PPI_DESCRIPTOR mPpiListStall
[1] = {
26 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
36 This routine installs the simulation instance of EFI_PEI_STALL_PPI based
39 @param FileHandle Handle of the file being invoked.
40 @param PeiServices Describes the list of possible PEI Services.
42 @retval EFI_SUCCESS The PEIM executed normally.
43 @retval !EFI_SUCCESS The PEIM failed to execute normally.
48 IN EFI_PEI_FILE_HANDLE FileHandle
,
49 IN CONST EFI_PEI_SERVICES
**PeiServices
53 Status
= (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListStall
[0]);
54 ASSERT_EFI_ERROR (Status
);
60 The Stall() function provides a blocking stall for at least the number
61 of microseconds stipulated in the final argument of the API.
63 @param PeiServices An indirect pointer to the PEI Services Table
64 published by the PEI Foundation.
65 @param This Pointer to the local data for the interface.
66 @param Microseconds Number of microseconds for which to stall.
68 @retval EFI_SUCCESS The service provided at least the required delay.
74 IN CONST EFI_PEI_SERVICES
**PeiServices
,
75 IN CONST EFI_PEI_STALL_PPI
*This
,
80 PEI_NT_THUNK_PPI
*PeiNtService
;
81 EFI_WIN_NT_THUNK_PROTOCOL
*NtThunk
;
83 Status
= (**PeiServices
).LocatePpi (
84 (const EFI_PEI_SERVICES
**)PeiServices
,
90 ASSERT_EFI_ERROR (Status
);
93 // Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec
94 // so micro second units need be divided by 1000 to convert to ms
96 NtThunk
= (EFI_WIN_NT_THUNK_PROTOCOL
*) PeiNtService
->NtThunk();
97 NtThunk
->Sleep ((DWORD
)((Microseconds
+ 999) / 1000));