Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 1 | /**@file
|
| 2 | EFI_PEI_STALL implementation for NT32 simulation environment.
|
| 3 |
|
| 4 | Copyright (c) 2009 - 2013, 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
|
| 9 |
|
| 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.
|
| 12 |
|
| 13 | **/
|
| 14 | #include "WinNtPeim.h"
|
| 15 |
|
| 16 | #include <Ppi/NtThunk.h>
|
| 17 | #include <Ppi/Stall.h>
|
| 18 | #include <Library/DebugLib.h>
|
| 19 |
|
| 20 | EFI_STATUS
|
| 21 | EFIAPI
|
| 22 | Stall (
|
| 23 | IN CONST EFI_PEI_SERVICES **PeiServices,
|
| 24 | IN CONST EFI_PEI_STALL_PPI *This,
|
| 25 | IN UINTN Microseconds
|
| 26 | );
|
| 27 |
|
| 28 | EFI_PEI_STALL_PPI mStallPpi = {1000, Stall};
|
| 29 |
|
| 30 | EFI_PEI_PPI_DESCRIPTOR mPpiListStall[1] = {
|
| 31 | {
|
| 32 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
| 33 | &gEfiPeiStallPpiGuid,
|
| 34 | &mStallPpi
|
| 35 | }
|
| 36 | };
|
| 37 |
|
| 38 |
|
| 39 | /**
|
| 40 | PEIM's entry point.
|
| 41 |
|
| 42 | This routine installs the simulation instance of EFI_PEI_STALL_PPI based
|
| 43 | on Win API Sleep().
|
| 44 |
|
| 45 | @param FileHandle Handle of the file being invoked.
|
| 46 | @param PeiServices Describes the list of possible PEI Services.
|
| 47 |
|
| 48 | @retval EFI_SUCCESS The PEIM executed normally.
|
| 49 | @retval !EFI_SUCCESS The PEIM failed to execute normally.
|
| 50 | **/
|
| 51 | EFI_STATUS
|
| 52 | EFIAPI
|
| 53 | InitializeStall (
|
| 54 | IN EFI_PEI_FILE_HANDLE FileHandle,
|
| 55 | IN CONST EFI_PEI_SERVICES **PeiServices
|
| 56 | )
|
| 57 | {
|
| 58 | EFI_STATUS Status;
|
| 59 | Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiListStall[0]);
|
| 60 | ASSERT_EFI_ERROR (Status);
|
| 61 |
|
| 62 | return Status;
|
| 63 | }
|
| 64 |
|
| 65 | /**
|
| 66 | The Stall() function provides a blocking stall for at least the number
|
| 67 | of microseconds stipulated in the final argument of the API.
|
| 68 |
|
| 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.
|
| 73 |
|
| 74 | @retval EFI_SUCCESS The service provided at least the required delay.
|
| 75 |
|
| 76 | **/
|
| 77 | EFI_STATUS
|
| 78 | EFIAPI
|
| 79 | Stall (
|
| 80 | IN CONST EFI_PEI_SERVICES **PeiServices,
|
| 81 | IN CONST EFI_PEI_STALL_PPI *This,
|
| 82 | IN UINTN Microseconds
|
| 83 | )
|
| 84 | {
|
| 85 | EFI_STATUS Status;
|
| 86 | PEI_NT_THUNK_PPI *PeiNtService;
|
| 87 | EFI_WIN_NT_THUNK_PROTOCOL *NtThunk;
|
| 88 |
|
| 89 | Status = (**PeiServices).LocatePpi (
|
| 90 | (const EFI_PEI_SERVICES **)PeiServices,
|
| 91 | &gPeiNtThunkPpiGuid,
|
| 92 | 0,
|
| 93 | NULL,
|
| 94 | (VOID**)&PeiNtService
|
| 95 | );
|
| 96 | ASSERT_EFI_ERROR (Status);
|
| 97 |
|
| 98 | //
|
| 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
|
| 101 | //
|
| 102 | NtThunk = (EFI_WIN_NT_THUNK_PROTOCOL*) PeiNtService->NtThunk();
|
| 103 | NtThunk->Sleep ((DWORD)((Microseconds + 999) / 1000));
|
| 104 |
|
| 105 | return EFI_SUCCESS;
|
| 106 | }
|