Home | History | Annotate | Download | only in Ppi
      1 /** @file
      2   Emulator Thunk to abstract OS services from pure EFI code
      3 
      4   Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
      5 
      6   This program and the accompanying materials
      7   are licensed and made available under the terms and conditions of the BSD License
      8   which accompanies this distribution.  The full text of the license may be found at
      9   http://opensource.org/licenses/bsd-license.php
     10 
     11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #ifndef __EMU_THUNK_PPI_H__
     17 #define __EMU_THUNK_PPI_H__
     18 
     19 #define EMU_THUNK_PPI_GUID  \
     20  { 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }
     21 
     22 
     23 
     24 /*++
     25 
     26 Routine Description:
     27   This service is called from Index == 0 until it returns EFI_UNSUPPORTED.
     28   It allows discontinuous memory regions to be supported by the emulator.
     29 
     30 Arguments:
     31   Index      - Which memory region to use
     32   MemoryBase - Return Base address of memory region
     33   MemorySize - Return size in bytes of the memory region
     34 
     35 Returns:
     36   EFI_SUCCESS - If memory region was mapped
     37   EFI_UNSUPPORTED - If Index is not supported
     38 
     39 **/
     40 typedef
     41 EFI_STATUS
     42 (EFIAPI *EMU_PEI_AUTOSCAN) (
     43   IN  UINTN                 Index,
     44   OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
     45   OUT UINT64                *MemorySize
     46   );
     47 
     48 
     49 /*++
     50 
     51 Routine Description:
     52   Return the FD Size and base address. Since the FD is loaded from a
     53   file into host memory only the SEC will know it's address.
     54 
     55 Arguments:
     56   Index  - Which FD, starts at zero.
     57   FdSize - Size of the FD in bytes
     58   FdBase - Start address of the FD. Assume it points to an FV Header
     59   FixUp  - Difference between actual FD address and build address
     60 
     61 Returns:
     62   EFI_SUCCESS     - Return the Base address and size of the FV
     63   EFI_UNSUPPORTED - Index does nto map to an FD in the system
     64 
     65 **/
     66 typedef
     67 EFI_STATUS
     68 (EFIAPI *EMU_PEI_FD_INFORMATION) (
     69   IN     UINTN                  Index,
     70   IN OUT EFI_PHYSICAL_ADDRESS   *FdBase,
     71   IN OUT UINT64                 *FdSize,
     72   IN OUT EFI_PHYSICAL_ADDRESS   *FixUp
     73   );
     74 
     75 
     76 /*++
     77 
     78 Routine Description:
     79   Export of EMU_THUNK_PROTOCOL from the SEC.
     80 
     81 Returns:
     82   EFI_SUCCESS - Data returned
     83 
     84 **/
     85 typedef
     86 VOID *
     87 (EFIAPI *EMU_PEI_THUNK_INTERFACE) (
     88   VOID
     89   );
     90 
     91 
     92 
     93 /*++
     94 
     95 Routine Description:
     96   Loads and relocates a PE/COFF image into memory.
     97 
     98 Arguments:
     99   Pe32Data         - The base address of the PE/COFF file that is to be loaded and relocated
    100   ImageAddress     - The base address of the relocated PE/COFF image
    101   ImageSize        - The size of the relocated PE/COFF image
    102   EntryPoint       - The entry point of the relocated PE/COFF image
    103 
    104 Returns:
    105   EFI_SUCCESS   - The file was loaded and relocated
    106   EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
    107 
    108 **/
    109 typedef
    110 EFI_STATUS
    111 (EFIAPI *EMU_PEI_LOAD_FILE) (
    112   VOID                  *Pe32Data,
    113   EFI_PHYSICAL_ADDRESS  *ImageAddress,
    114   UINT64                *ImageSize,
    115   EFI_PHYSICAL_ADDRESS  *EntryPoint
    116   );
    117 
    118 
    119 typedef struct {
    120   EMU_PEI_AUTOSCAN                  MemoryAutoScan;
    121   EMU_PEI_FD_INFORMATION            FirmwareDevices;
    122   EMU_PEI_THUNK_INTERFACE           Thunk;
    123 } EMU_THUNK_PPI;
    124 
    125 extern EFI_GUID gEmuThunkPpiGuid;
    126 
    127 #endif
    128