• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Master header file for SecCore.
3 
4 Copyright (c) 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 
15 #ifndef _SEC_CORE_H_
16 #define _SEC_CORE_H_
17 
18 
19 #include <PiPei.h>
20 
21 #include <Ppi/SecPlatformInformation.h>
22 #include <Ppi/TemporaryRamSupport.h>
23 
24 #include <Library/BaseLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/UefiCpuLib.h>
29 #include <Library/PeCoffGetEntryPointLib.h>
30 #include <Library/PeCoffExtraActionLib.h>
31 #include <Library/DebugAgentLib.h>
32 
33 
34 #define SEC_IDT_ENTRY_COUNT  34
35 
36 typedef struct _SEC_IDT_TABLE {
37   //
38   // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since IDT base
39   // address should be 8-byte alignment.
40   // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store
41   // EFI_PEI_SERVICES**
42   //
43   UINT64            PeiService;
44   UINT64            IdtTable[SEC_IDT_ENTRY_COUNT];
45 } SEC_IDT_TABLE;
46 
47 /**
48   Switch the stack in the temporary memory to the one in the permanent memory.
49 
50   This function must be invoked after the memory migration immediately. The relative
51   position of the stack in the temporary and permanent memory is same.
52 
53   @param TemporaryMemoryBase  Base address of the temporary memory.
54   @param PermenentMemoryBase  Base address of the permanent memory.
55 **/
56 VOID
57 EFIAPI
58 SecSwitchStack (
59   UINT32   TemporaryMemoryBase,
60   UINT32   PermenentMemoryBase
61   );
62 
63 /**
64   This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into
65   permanent memory.
66 
67   @param PeiServices            Pointer to the PEI Services Table.
68   @param TemporaryMemoryBase    Source Address in temporary memory from which the SEC or PEIM will copy the
69                                 Temporary RAM contents.
70   @param PermanentMemoryBase    Destination Address in permanent memory into which the SEC or PEIM will copy the
71                                 Temporary RAM contents.
72   @param CopySize               Amount of memory to migrate from temporary to permanent memory.
73 
74   @retval EFI_SUCCESS           The data was successfully returned.
75   @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when
76                                 TemporaryMemoryBase > PermanentMemoryBase.
77 
78 **/
79 EFI_STATUS
80 EFIAPI
81 SecTemporaryRamSupport (
82   IN CONST EFI_PEI_SERVICES   **PeiServices,
83   IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,
84   IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,
85   IN UINTN                    CopySize
86   );
87 
88 /**
89   Entry point to the C language phase of SEC. After the SEC assembly
90   code has initialized some temporary memory and set up the stack,
91   the control is transferred to this function.
92 
93   @param SizeOfRam           Size of the temporary memory available for use.
94   @param TempRamBase         Base address of tempory ram
95   @param BootFirmwareVolume  Base address of the Boot Firmware Volume.
96 **/
97 VOID
98 EFIAPI
99 SecStartup (
100   IN UINT32                   SizeOfRam,
101   IN UINT32                   TempRamBase,
102   IN VOID                     *BootFirmwareVolume
103   );
104 
105 /**
106   Find and return Pei Core entry point.
107 
108   It also find SEC and PEI Core file debug inforamtion. It will report them if
109   remote debug is enabled.
110 
111   @param  BootFirmwareVolumePtr  Point to the boot firmware volume.
112   @param  PeiCoreEntryPoint      Point to the PEI core entry point.
113 
114 **/
115 VOID
116 EFIAPI
117 FindAndReportEntryPoints (
118   IN  EFI_FIRMWARE_VOLUME_HEADER       *BootFirmwareVolumePtr,
119   OUT EFI_PEI_CORE_ENTRY_POINT         *PeiCoreEntryPoint
120   );
121 
122 /**
123   Autogenerated function that calls the library constructors for all of the module's
124   dependent libraries.  This function must be called by the SEC Core once a stack has
125   been established.
126 
127 **/
128 VOID
129 EFIAPI
130 ProcessLibraryConstructorList (
131   VOID
132   );
133 
134 #endif
135