2 Platform SEC Library for Quark.
4 Copyright (c) 2013-2015 Intel Corporation.
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
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.
19 #include <Ppi/SecPlatformInformation.h>
20 #include <Ppi/TemporaryRamSupport.h>
21 #include <Library/PcdLib.h>
22 #include <Library/BaseLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/HobLib.h>
26 #include <Library/MtrrLib.h>
30 Entry point to the C language phase of SEC. After the SEC assembly
31 code has initialized some temporary memory and set up the stack,
32 the control is transferred to this function.
34 @param SizeOfRam Size of the temporary memory available for use.
35 @param TempRamBase Base address of temporary ram
36 @param BootFirmwareVolume Base address of the Boot Firmware Volume.
43 IN UINT32 TempRamBase
,
44 IN VOID
*BootFirmwareVolume
48 Auto-generated function that calls the library constructors for all of the module's
49 dependent libraries. This function must be called by the SEC Core once a stack has
55 ProcessLibraryConstructorList (
61 Entry point to the C language phase of PlatformSecLib. After the SEC assembly
62 code has initialized some temporary memory and set up the stack, control is
63 transferred to this function.
68 PlatformSecLibStartup (
73 // Process all library constructor functions linked to SecCore.
74 // This function must be called before any library functions are called
76 ProcessLibraryConstructorList ();
79 // Set write back cache attribute for SPI FLASH
81 MtrrSetMemoryAttribute (
82 PcdGet32 (PcdFlashAreaBaseAddress
),
83 PcdGet32 (PcdFlashAreaSize
),
88 // Set write back cache attribute for 512KB Embedded SRAM
90 MtrrSetMemoryAttribute (
91 PcdGet32 (PcdEsramStage1Base
),
97 // Pass control to SecCore module passing in the size of the temporary RAM in
98 // Embedded SRAM, the base address of the temporary RAM in Embedded SRAM, and
99 // the base address of the boot firmware volume. The top 32KB of the 512 KB
100 // embedded SRAM are used as temporary RAM.
104 PcdGet32 (PcdEsramStage1Base
) + SIZE_512KB
- SIZE_32KB
,
105 (VOID
*)(UINTN
)PcdGet32 (PcdFlashFvRecoveryBase
)
110 A developer supplied function to perform platform specific operations.
112 It's a developer supplied function to perform any operations appropriate to a
113 given platform. It's invoked just before passing control to PEI core by SEC
114 core. Platform developer may modify the SecCoreData and PPI list that is
117 @param SecCoreData The same parameter as passing to PEI core. It
118 could be overridden by this function.
119 @param PpiList The default PPI list passed from generic SEC
122 @return The final PPI list that platform wishes to passed to PEI core.
125 EFI_PEI_PPI_DESCRIPTOR
*
128 IN OUT EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
129 IN EFI_PEI_PPI_DESCRIPTOR
*PpiList
136 This interface conveys state information out of the Security (SEC) phase into PEI.
138 @param PeiServices Pointer to the PEI Services Table.
139 @param StructureSize Pointer to the variable describing size of the input buffer.
140 @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
142 @retval EFI_SUCCESS The data was successfully returned.
143 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
148 SecPlatformInformation (
149 IN CONST EFI_PEI_SERVICES
**PeiServices
,
150 IN OUT UINT64
*StructureSize
,
151 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD
*PlatformInformationRecord
157 EFI_HOB_GUID_TYPE
*GuidHob
;
161 // Top of the stack is the top of the 512KB Embedded SRAM region
163 TopOfStack
= (UINT32
*)(UINTN
)(PcdGet32 (PcdEsramStage1Base
) + SIZE_512KB
);
165 GuidHob
= GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid
);
166 if (GuidHob
!= NULL
) {
167 Size
= GET_GUID_HOB_DATA_SIZE (GuidHob
);
168 BIST
= GET_GUID_HOB_DATA (GuidHob
);
171 // The entries of BIST information, together with the number of them,
172 // reside in the bottom of stack, left untouched by normal stack operation.
173 // This routine copies the BIST information to the buffer pointed by
174 // PlatformInformationRecord for output.
176 Count
= *(TopOfStack
- 1);
177 Size
= Count
* sizeof (IA32_HANDOFF_STATUS
);
178 BIST
= (UINT32
*) ((UINT32
) TopOfStack
- sizeof (UINT32
) - Size
);
181 // Copy Data from Stack to Hob to avoid data is lost after memory is ready.
184 &gEfiSecPlatformInformationPpiGuid
,
188 GuidHob
= GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid
);
189 Size
= GET_GUID_HOB_DATA_SIZE (GuidHob
);
190 BIST
= GET_GUID_HOB_DATA (GuidHob
);
193 if ((*StructureSize
) < (UINT64
) Size
) {
194 *StructureSize
= Size
;
195 return EFI_BUFFER_TOO_SMALL
;
198 *StructureSize
= Size
;
199 CopyMem (PlatformInformationRecord
, BIST
, Size
);
205 This interface disables temporary memory in SEC Phase.
209 SecPlatformDisableTemporaryMemory (