]>
Commit | Line | Data |
---|---|---|
91a03f78 TK |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
3 | ; Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r | |
4 | ; SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
5 | ;\r | |
6 | ; Module Name:\r | |
7 | ;\r | |
8 | ; SecEntry.asm\r | |
9 | ;\r | |
10 | ; Abstract:\r | |
11 | ;\r | |
12 | ; This is the code that calls TempRamInit API from FSP binary and passes\r | |
13 | ; control into PEI core.\r | |
14 | ;\r | |
15 | ;------------------------------------------------------------------------------\r | |
16 | \r | |
17 | #include "Fsp.h"\r | |
18 | \r | |
19 | IA32_CR4_OSFXSR equ 200h\r | |
20 | IA32_CR4_OSXMMEXCPT equ 400h\r | |
21 | IA32_CR0_MP equ 2h\r | |
22 | \r | |
23 | IA32_CPUID_SSE2 equ 02000000h\r | |
24 | IA32_CPUID_SSE2_B equ 26\r | |
25 | \r | |
26 | SECTION .text\r | |
27 | \r | |
28 | extern ASM_PFX(CallPeiCoreEntryPoint)\r | |
29 | extern ASM_PFX(FsptUpdDataPtr)\r | |
30 | \r | |
31 | ; Pcds\r | |
32 | extern ASM_PFX(PcdGet32 (PcdFsptBaseAddress))\r | |
33 | \r | |
34 | ;----------------------------------------------------------------------------\r | |
35 | ;\r | |
36 | ; Procedure: _ModuleEntryPoint\r | |
37 | ;\r | |
38 | ; Input: None\r | |
39 | ;\r | |
40 | ; Output: None\r | |
41 | ;\r | |
42 | ; Destroys: Assume all registers\r | |
43 | ;\r | |
44 | ; Description:\r | |
45 | ;\r | |
46 | ; Call TempRamInit API from FSP binary. After TempRamInit done, pass\r | |
47 | ; control into PEI core.\r | |
48 | ;\r | |
49 | ; Return: None\r | |
50 | ;\r | |
51 | ; MMX Usage:\r | |
52 | ; MM0 = BIST State\r | |
53 | ;\r | |
54 | ;----------------------------------------------------------------------------\r | |
55 | \r | |
56 | BITS 64\r | |
57 | align 16\r | |
58 | global ASM_PFX(ModuleEntryPoint)\r | |
59 | ASM_PFX(ModuleEntryPoint):\r | |
60 | fninit ; clear any pending Floating point exceptions\r | |
61 | ;\r | |
62 | ; Store the BIST value in mm0\r | |
63 | ;\r | |
64 | movd mm0, eax\r | |
65 | \r | |
66 | ; Find the fsp info header\r | |
67 | mov rax, ASM_PFX(PcdGet32 (PcdFsptBaseAddress))\r | |
68 | mov edi, [eax]\r | |
69 | \r | |
70 | mov eax, dword [edi + FVH_SIGINATURE_OFFSET]\r | |
71 | cmp eax, FVH_SIGINATURE_VALID_VALUE\r | |
72 | jnz FspHeaderNotFound\r | |
73 | \r | |
74 | xor eax, eax\r | |
75 | mov ax, word [edi + FVH_EXTHEADER_OFFSET_OFFSET]\r | |
76 | cmp ax, 0\r | |
77 | jnz FspFvExtHeaderExist\r | |
78 | \r | |
79 | xor eax, eax\r | |
80 | mov ax, word [edi + FVH_HEADER_LENGTH_OFFSET] ; Bypass Fv Header\r | |
81 | add edi, eax\r | |
82 | jmp FspCheckFfsHeader\r | |
83 | \r | |
84 | FspFvExtHeaderExist:\r | |
85 | add edi, eax\r | |
86 | mov eax, dword [edi + FVH_EXTHEADER_SIZE_OFFSET] ; Bypass Ext Fv Header\r | |
87 | add edi, eax\r | |
88 | \r | |
89 | ; Round up to 8 byte alignment\r | |
90 | mov eax, edi\r | |
91 | and al, 07h\r | |
92 | jz FspCheckFfsHeader\r | |
93 | \r | |
94 | and edi, 0FFFFFFF8h\r | |
95 | add edi, 08h\r | |
96 | \r | |
97 | FspCheckFfsHeader:\r | |
98 | ; Check the ffs guid\r | |
99 | mov eax, dword [edi]\r | |
100 | cmp eax, FSP_HEADER_GUID_DWORD1\r | |
101 | jnz FspHeaderNotFound\r | |
102 | \r | |
103 | mov eax, dword [edi + 4]\r | |
104 | cmp eax, FSP_HEADER_GUID_DWORD2\r | |
105 | jnz FspHeaderNotFound\r | |
106 | \r | |
107 | mov eax, dword [edi + 8]\r | |
108 | cmp eax, FSP_HEADER_GUID_DWORD3\r | |
109 | jnz FspHeaderNotFound\r | |
110 | \r | |
111 | mov eax, dword [edi + 0Ch]\r | |
112 | cmp eax, FSP_HEADER_GUID_DWORD4\r | |
113 | jnz FspHeaderNotFound\r | |
114 | \r | |
115 | add edi, FFS_HEADER_SIZE_VALUE ; Bypass the ffs header\r | |
116 | \r | |
117 | ; Check the section type as raw section\r | |
118 | mov al, byte [edi + SECTION_HEADER_TYPE_OFFSET]\r | |
119 | cmp al, 019h\r | |
120 | jnz FspHeaderNotFound\r | |
121 | \r | |
122 | add edi, RAW_SECTION_HEADER_SIZE_VALUE ; Bypass the section header\r | |
123 | jmp FspHeaderFound\r | |
124 | \r | |
125 | FspHeaderNotFound:\r | |
126 | jmp $\r | |
127 | \r | |
128 | FspHeaderFound:\r | |
129 | ; Get the fsp TempRamInit Api address\r | |
130 | mov eax, dword [edi + FSP_HEADER_IMAGEBASE_OFFSET]\r | |
131 | add eax, dword [edi + FSP_HEADER_TEMPRAMINIT_OFFSET]\r | |
132 | \r | |
df1c7e91 DC |
133 | ; Pass Fsp T Upd pointer as Input parameter\r |
134 | mov rcx, ASM_PFX(FsptUpdDataPtr)\r | |
135 | \r | |
91a03f78 TK |
136 | ; Setup the hardcode stack\r |
137 | mov rsp, TempRamInitStack\r | |
138 | \r | |
139 | ; Call the fsp TempRamInit Api\r | |
140 | jmp rax\r | |
141 | \r | |
142 | TempRamInitDone:\r | |
143 | cmp rax, 0800000000000000Eh ; Check if EFI_NOT_FOUND returned. Error code for Microcode Update not found.\r | |
144 | je CallSecFspInit ; If microcode not found, don't hang, but continue.\r | |
145 | \r | |
146 | cmp rax, 0 ; Check if EFI_SUCCESS returned.\r | |
147 | jnz FspApiFailed\r | |
148 | \r | |
149 | ; RDX: start of range\r | |
150 | ; R8: end of range\r | |
151 | CallSecFspInit:\r | |
152 | \r | |
153 | mov r8, rdx\r | |
154 | mov rdx, rcx\r | |
155 | xor ecx, ecx ; zero - no Hob List Yet\r | |
156 | mov rsp, r8\r | |
157 | \r | |
158 | ;\r | |
159 | ; Per X64 calling convention, make sure RSP is 16-byte aligned.\r | |
160 | ;\r | |
161 | mov rax, rsp\r | |
162 | and rax, 0fh\r | |
163 | sub rsp, rax\r | |
164 | \r | |
165 | call ASM_PFX(CallPeiCoreEntryPoint)\r | |
166 | \r | |
167 | FspApiFailed:\r | |
168 | jmp $\r | |
169 | \r | |
170 | align 10h\r | |
171 | TempRamInitStack:\r | |
172 | DQ TempRamInitDone\r | |
91a03f78 | 173 | \r |