]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/StallPei/Stall.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / Nt32Pkg / StallPei / Stall.c
CommitLineData
ba82cb67 1/**@file\r
2 EFI_PEI_STALL implementation for NT32 simulation environment.\r
3 \r
f66a43b2 4Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
8f2a5f80 5This program and the accompanying materials \r
ba82cb67 6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14#include "WinNtPeim.h"\r
15\r
16#include <Ppi/NtThunk.h>\r
17#include <Ppi/Stall.h>\r
18#include <Library/DebugLib.h>\r
19\r
20EFI_STATUS\r
21EFIAPI \r
22Stall (\r
23 IN CONST EFI_PEI_SERVICES **PeiServices,\r
24 IN CONST EFI_PEI_STALL_PPI *This,\r
25 IN UINTN Microseconds\r
26 );\r
27 \r
28EFI_PEI_STALL_PPI mStallPpi = {1000, Stall};\r
29\r
30EFI_PEI_PPI_DESCRIPTOR mPpiListStall[1] = {\r
31 {\r
32 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
33 &gEfiPeiStallPpiGuid,\r
34 &mStallPpi\r
35 }\r
36};\r
37\r
38\r
39/**\r
40 PEIM's entry point.\r
41 \r
42 This routine installs the simulation instance of EFI_PEI_STALL_PPI based\r
43 on Win API Sleep().\r
44 \r
45 @param FileHandle Handle of the file being invoked. \r
46 @param PeiServices Describes the list of possible PEI Services.\r
47\r
48 @retval EFI_SUCCESS The PEIM executed normally.\r
49 @retval !EFI_SUCCESS The PEIM failed to execute normally.\r
50**/\r
51EFI_STATUS\r
52EFIAPI\r
53InitializeStall (\r
54 IN EFI_PEI_FILE_HANDLE FileHandle,\r
55 IN CONST EFI_PEI_SERVICES **PeiServices\r
56 )\r
57{\r
58 EFI_STATUS Status;\r
59 Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiListStall[0]);\r
60 ASSERT_EFI_ERROR (Status);\r
61\r
62 return Status;\r
63}\r
64\r
65/**\r
66 The Stall() function provides a blocking stall for at least the number \r
67 of microseconds stipulated in the final argument of the API.\r
68\r
69 @param PeiServices An indirect pointer to the PEI Services Table\r
70 published by the PEI Foundation.\r
71 @param This Pointer to the local data for the interface.\r
72 @param Microseconds Number of microseconds for which to stall.\r
73\r
74 @retval EFI_SUCCESS The service provided at least the required delay.\r
75\r
76**/\r
77EFI_STATUS\r
78EFIAPI \r
79Stall (\r
80 IN CONST EFI_PEI_SERVICES **PeiServices,\r
81 IN CONST EFI_PEI_STALL_PPI *This,\r
82 IN UINTN Microseconds\r
83 )\r
84{\r
85 EFI_STATUS Status;\r
86 PEI_NT_THUNK_PPI *PeiNtService;\r
87 EFI_WIN_NT_THUNK_PROTOCOL *NtThunk;\r
88 \r
89 Status = (**PeiServices).LocatePpi (\r
90 (const EFI_PEI_SERVICES **)PeiServices,\r
91 &gPeiNtThunkPpiGuid,\r
92 0, \r
93 NULL,\r
94 (VOID**)&PeiNtService\r
95 );\r
96 ASSERT_EFI_ERROR (Status);\r
97 \r
98 //\r
99 // Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec\r
100 // so micro second units need be divided by 1000 to convert to ms\r
101 //\r
102 NtThunk = (EFI_WIN_NT_THUNK_PROTOCOL*) PeiNtService->NtThunk();\r
f66a43b2 103 NtThunk->Sleep ((DWORD)((Microseconds + 999) / 1000)); \r
ba82cb67 104 \r
105 return EFI_SUCCESS;\r
106}\r