From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.5424.1626052808517988836 for ; Sun, 11 Jul 2021 18:20:16 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: min.m.xu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10042"; a="209726408" X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="209726408" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2021 18:20:16 -0700 X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="459018165" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.4.4]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2021 18:20:14 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Eric Dong , Jiewen Yao , Ray Ni , Laszlo Ersek Subject: [PATCH 4/6] UefiCpuPkg/ResetVector: Add ReloadFlat32 in UefiCpuPkg Date: Mon, 12 Jul 2021 09:19:40 +0800 Message-Id: <4a08dc5d3adbc83f8048db44a6937138048d4435.1626050798.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Load the GDT and set the default CR0, then jump to Flat 32 protected mode. Cc: Eric Dong Cc: Jiewen Yao Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Min Xu --- .../ResetVector/Vtf0/Ia32/ReloadFlat32.asm | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm new file mode 100644 index 000000000000..e8a4c47762df --- /dev/null +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia32/ReloadFlat32.asm @@ -0,0 +1,43 @@ +;------------------------------------------------------------------------------ +; @file +; Load the GDT and set the CR0, then jump to Flat 32 protected mode. +; +; Copyright (c) 2021, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +;------------------------------------------------------------------------------ + +%define SEC_DEFAULT_CR0 0x00000023 +%define SEC_DEFAULT_CR4 0x640 + +BITS 32 + +; +; Modified: EAX, EBX, CR0, CR4, DS, ES, FS, GS, SS +; +ReloadFlat32: + + cli + mov ebx, ADDR_OF(gdtr) + lgdt [ebx] + + mov eax, SEC_DEFAULT_CR0 + mov cr0, eax + + jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpToFlat32BitAndLandHere) +BITS 32 +jumpToFlat32BitAndLandHere: + + mov eax, SEC_DEFAULT_CR4 + mov cr4, eax + + debugShowPostCode POSTCODE_32BIT_MODE + + mov ax, LINEAR_SEL + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + + OneTimeCallRet ReloadFlat32 -- 2.29.2.windows.2