2010-02-02 18:56:00 +01:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; @file
|
|
|
|
; Main routine of the pre-SEC code up through the jump into SEC
|
|
|
|
;
|
2010-04-24 14:25:26 +02:00
|
|
|
; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:07:22 +02:00
|
|
|
; SPDX-License-Identifier: BSD-2-Clause-Patent
|
2010-02-02 18:56:00 +01:00
|
|
|
;
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
BITS 16
|
|
|
|
|
|
|
|
;
|
|
|
|
; Modified: EBX, ECX, EDX, EBP
|
|
|
|
;
|
|
|
|
; @param[in,out] RAX/EAX Initial value of the EAX register
|
|
|
|
; (BIST: Built-in Self Test)
|
|
|
|
; @param[in,out] DI 'BP': boot-strap processor, or
|
|
|
|
; 'AP': application processor
|
|
|
|
; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV)
|
UefiCpuPkg/ResetVector/Vtf0: document segment register setup
"Main.asm" calls TransitionFromReal16To32BitFlat (and does some other
things) before it jumps to the platform's SEC entry point.
TransitionFromReal16To32BitFlat enters big real mode, and sets the DS, ES,
FS, GS, and SS registers to offset ("selector") LINEAR_SEL in the GDT
(defined in "UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm"). The
GDT entry ("segment descriptor") at LINEAR_SEL defines a segment covering
the full 32-bit address space, meant for "read/write data".
Document this fact for all the affected segment registers, as output
parameters for TransitionFromReal16To32BitFlat, saying "Selector allowing
flat access to all addresses".
For 64-bit SEC, "Main.asm" calls Transition32FlatTo64Flat in addition,
between calling TransitionFromReal16To32BitFlat and jumping to the SEC
entry point. Transition32FlatTo64Flat enters long mode. In long mode,
segmentation is largely ignored:
- all segments are considered flat (covering the whole 64-bit address
space),
- with the (possible) exception of FS and GS, whose bases can still be
changed, albeit with new methods, not through the GDT. (Through the
IA32_FS_BASE and IA32_GS_BASE Model Specific Registers, and/or the
WRFSBASE, WRGSBASE and SWAPGS instructions.)
Thus, document the segment registers with the same "Selector allowing flat
access to all addresses" language on the "Main.asm" level too, since that
is valid for both 32-bit and 64-bit modes.
(Technically, "Main.asm" does not return, but RBP/EBP, passed similarly to
the SEC entry point, is already documented as an output parameter.)
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Suggested-by: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-11-15 19:00:17 +01:00
|
|
|
; @param[out] DS Selector allowing flat access to all addresses
|
|
|
|
; @param[out] ES Selector allowing flat access to all addresses
|
|
|
|
; @param[out] FS Selector allowing flat access to all addresses
|
|
|
|
; @param[out] GS Selector allowing flat access to all addresses
|
|
|
|
; @param[out] SS Selector allowing flat access to all addresses
|
2010-02-02 18:56:00 +01:00
|
|
|
;
|
|
|
|
; @return None This routine jumps to SEC and does not return
|
|
|
|
;
|
|
|
|
Main16:
|
|
|
|
OneTimeCall EarlyInit16
|
|
|
|
|
|
|
|
;
|
|
|
|
; Transition the processor from 16-bit real mode to 32-bit flat mode
|
|
|
|
;
|
|
|
|
OneTimeCall TransitionFromReal16To32BitFlat
|
|
|
|
|
|
|
|
BITS 32
|
|
|
|
|
|
|
|
;
|
|
|
|
; Search for the Boot Firmware Volume (BFV)
|
|
|
|
;
|
|
|
|
OneTimeCall Flat32SearchForBfvBase
|
|
|
|
|
|
|
|
;
|
|
|
|
; EBP - Start of BFV
|
|
|
|
;
|
|
|
|
|
|
|
|
;
|
|
|
|
; Search for the SEC entry point
|
|
|
|
;
|
|
|
|
OneTimeCall Flat32SearchForSecEntryPoint
|
|
|
|
|
|
|
|
;
|
|
|
|
; ESI - SEC Core entry point
|
|
|
|
; EBP - Start of BFV
|
|
|
|
;
|
|
|
|
|
|
|
|
%ifdef ARCH_IA32
|
|
|
|
|
|
|
|
;
|
|
|
|
; Restore initial EAX value into the EAX register
|
|
|
|
;
|
|
|
|
mov eax, esp
|
|
|
|
|
|
|
|
;
|
|
|
|
; Jump to the 32-bit SEC entry point
|
|
|
|
;
|
|
|
|
jmp esi
|
|
|
|
|
|
|
|
%else
|
|
|
|
|
|
|
|
;
|
|
|
|
; Transition the processor from 32-bit flat mode to 64-bit flat mode
|
|
|
|
;
|
|
|
|
OneTimeCall Transition32FlatTo64Flat
|
|
|
|
|
|
|
|
BITS 64
|
|
|
|
|
|
|
|
;
|
|
|
|
; Some values were calculated in 32-bit mode. Make sure the upper
|
|
|
|
; 32-bits of 64-bit registers are zero for these values.
|
|
|
|
;
|
|
|
|
mov rax, 0x00000000ffffffff
|
|
|
|
and rsi, rax
|
|
|
|
and rbp, rax
|
|
|
|
and rsp, rax
|
|
|
|
|
|
|
|
;
|
|
|
|
; RSI - SEC Core entry point
|
|
|
|
; RBP - Start of BFV
|
|
|
|
;
|
|
|
|
|
|
|
|
;
|
|
|
|
; Restore initial EAX value into the RAX register
|
|
|
|
;
|
|
|
|
mov rax, rsp
|
|
|
|
|
|
|
|
;
|
|
|
|
; Jump to the 64-bit SEC entry point
|
|
|
|
;
|
|
|
|
jmp rsi
|
|
|
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
|