2 EFI_PEI_STALL implementation for NT32 simulation environment.
4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include "WinNtPeim.h"
16 #include <Ppi/NtThunk.h>
17 #include <Ppi/Stall.h>
18 #include <Library/DebugLib.h>
23 IN CONST EFI_PEI_SERVICES
**PeiServices
,
24 IN CONST EFI_PEI_STALL_PPI
*This
,
28 EFI_PEI_STALL_PPI mStallPpi
= {1000, Stall
};
30 EFI_PEI_PPI_DESCRIPTOR mPpiListStall
[1] = {
32 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
42 This routine installs the simulation instance of EFI_PEI_STALL_PPI based
45 @param FileHandle Handle of the file being invoked.
46 @param PeiServices Describes the list of possible PEI Services.
48 @retval EFI_SUCCESS The PEIM executed normally.
49 @retval !EFI_SUCCESS The PEIM failed to execute normally.
54 IN EFI_PEI_FILE_HANDLE FileHandle
,
55 IN CONST EFI_PEI_SERVICES
**PeiServices
59 Status
= (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListStall
[0]);
60 ASSERT_EFI_ERROR (Status
);
66 The Stall() function provides a blocking stall for at least the number
67 of microseconds stipulated in the final argument of the API.
69 @param PeiServices An indirect pointer to the PEI Services Table
70 published by the PEI Foundation.
71 @param This Pointer to the local data for the interface.
72 @param Microseconds Number of microseconds for which to stall.
74 @retval EFI_SUCCESS The service provided at least the required delay.
80 IN CONST EFI_PEI_SERVICES
**PeiServices
,
81 IN CONST EFI_PEI_STALL_PPI
*This
,
86 PEI_NT_THUNK_PPI
*PeiNtService
;
87 EFI_WIN_NT_THUNK_PROTOCOL
*NtThunk
;
89 Status
= (**PeiServices
).LocatePpi (
90 (const EFI_PEI_SERVICES
**)PeiServices
,
96 ASSERT_EFI_ERROR (Status
);
99 // Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec
100 // so micro second units need be divided by 1000 to convert to ms
102 NtThunk
= (EFI_WIN_NT_THUNK_PROTOCOL
*) PeiNtService
->NtThunk();
103 NtThunk
->Sleep ((Microseconds
+ 999) / 1000);