1 /*++ @file
2   UEFI/PI PEIM to abstract construction of firmware volume in a Unix environment.
3 
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 
8 **/
9 
10 #include <PiPei.h>
11 
12 #include <Library/DebugLib.h>
13 #include <Library/PeimEntryPoint.h>
14 #include <Library/HobLib.h>
15 #include <Library/PeiServicesLib.h>
16 #include <Library/PeiServicesTablePointerLib.h>
17 
18 #include <Ppi/EmuThunk.h>
19 #include <Protocol/EmuThunk.h>
20 
21 
22 
23 EFI_STATUS
24 EFIAPI
PeiInitialzeThunkPpiToProtocolPei(IN EFI_PEI_FILE_HANDLE FileHandle,IN CONST EFI_PEI_SERVICES ** PeiServices)25 PeiInitialzeThunkPpiToProtocolPei (
26   IN       EFI_PEI_FILE_HANDLE       FileHandle,
27   IN CONST EFI_PEI_SERVICES          **PeiServices
28   )
29 /*++
30 
31 Routine Description:
32 
33   Perform a call-back into the SEC simulator to get Unix Stuff
34 
35 Arguments:
36 
37   PeiServices - General purpose services available to every PEIM.
38 
39 Returns:
40 
41   None
42 
43 **/
44 {
45   EFI_STATUS              Status;
46   EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;
47   EMU_THUNK_PPI           *Thunk;
48   VOID                    *Ptr;
49 
50   DEBUG ((EFI_D_ERROR, "Emu Thunk PEIM Loaded\n"));
51 
52   Status = PeiServicesLocatePpi (
53               &gEmuThunkPpiGuid,        // GUID
54               0,                        // INSTANCE
55               &PpiDescriptor,           // EFI_PEI_PPI_DESCRIPTOR
56               (VOID **)&Thunk           // PPI
57               );
58   ASSERT_EFI_ERROR (Status);
59 
60   Ptr = Thunk->Thunk ();
61 
62   BuildGuidDataHob (
63     &gEmuThunkProtocolGuid,              // Guid
64     &Ptr,                                // Buffer
65     sizeof (VOID *)                      // Sizeof Buffer
66     );
67   return Status;
68 }
69