1 ;------------------------------------------------------------------------------
3 ; Main routine of the pre-SEC code up through the jump into SEC
5 ; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
6 ; SPDX-License-Identifier: BSD-2-Clause-Patent
8 ;------------------------------------------------------------------------------
14 ; Modified: EBX, ECX, EDX, EBP
16 ; @param[in,out] RAX/EAX Initial value of the EAX register
17 ; (BIST: Built-in Self Test)
18 ; @param[in,out] DI 'BP': boot-strap processor, or
19 ; 'AP': application processor
20 ; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV)
21 ; @param[out] DS Selector allowing flat access to all addresses
22 ; @param[out] ES Selector allowing flat access to all addresses
23 ; @param[out] FS Selector allowing flat access to all addresses
24 ; @param[out] GS Selector allowing flat access to all addresses
25 ; @param[out] SS Selector allowing flat access to all addresses
27 ; @return None This routine jumps to SEC and does not return
30 OneTimeCall EarlyInit16
33 ; Transition the processor from 16-bit real mode to 32-bit flat mode
35 OneTimeCall TransitionFromReal16To32BitFlat
39 ; Clear the WorkArea header. The SEV probe routines will populate the
40 ; work area when detected.
41 mov byte[WORK_AREA_GUEST_TYPE], 0
48 ; Entry point of Main32
58 ; Search for the Boot Firmware Volume (BFV)
60 OneTimeCall Flat32SearchForBfvBase
67 ; Search for the SEC entry point
69 OneTimeCall Flat32SearchForSecEntryPoint
72 ; ESI - SEC Core entry point
79 ; SEV support can be built and run using the Ia32/X64 split environment.
80 ; Set the OVMF/SEV work area as appropriate.
82 OneTimeCall CheckSevFeatures
85 ; Restore initial EAX value into the EAX register
90 ; Jump to the 32-bit SEC entry point
97 ; Transition the processor from 32-bit flat mode to 64-bit flat mode
99 OneTimeCall Transition32FlatTo64Flat
104 ; Some values were calculated in 32-bit mode. Make sure the upper
105 ; 32-bits of 64-bit registers are zero for these values.
107 mov rax, 0x00000000ffffffff
113 ; RSI - SEC Core entry point
118 ; Restore initial EAX value into the RAX register
123 ; Jump to the 64-bit SEC entry point