[coreboot-gerrit] Change in ...coreboot[master]: arch/x86/assembly_entry: Enable long mode in romstage

Patrick Rudolph (Code Review) gerrit at coreboot.org
Sun Dec 9 14:37:45 CET 2018


Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30114


Change subject: arch/x86/assembly_entry: Enable long mode in romstage
......................................................................

arch/x86/assembly_entry: Enable long mode in romstage

* Install page tables for long mode
* Activate long mode

Change-Id: I57974a55f3b778c90b3587f39e86e4eb8692ad48
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
M src/arch/x86/assembly_entry.S
1 file changed, 58 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/30114/1

diff --git a/src/arch/x86/assembly_entry.S b/src/arch/x86/assembly_entry.S
index 02f492c..08e693b 100644
--- a/src/arch/x86/assembly_entry.S
+++ b/src/arch/x86/assembly_entry.S
@@ -26,6 +26,7 @@
  * variables that are stage specific.
  */
 .section ".text._start", "ax", @progbits
+.code32
 .global _start
 _start:
 
@@ -35,6 +36,15 @@
 	/* reset stack pointer to CAR stack */
 	mov	$_car_stack_end, %esp
 
+#ifdef __x86_64__
+#if IS_ENABLED(CONFIG_PAGING_IN_CACHE_AS_RAM)
+	# disable paging, in case page table were in CAR
+	mov	%cr0, %eax
+	btr	$31, %eax
+	mov	%eax, %cr0
+#endif
+#endif
+
 	/* clear CAR_GLOBAL area as it is not shared */
 	cld
 	xor	%eax, %eax
@@ -43,6 +53,54 @@
 	sub	%edi, %ecx
 	rep	stosl
 
+#ifdef __x86_64__
+#if IS_ENABLED(CONFIG_PAGING_IN_CACHE_AS_RAM)
+	/* Setup long mode: identity map 0-4GiB */
+	movl	$(_pagetables), %ecx
+	xor	%eax, %eax
+	/* Generate one PM4LE entry */
+	lea	(0x1000)(%ecx), %edi
+	or	$0x00000623, %edi
+	mov	%edi, (%ecx)
+	mov	%eax, 4(%ecx)
+	/* Generate 4 PDPE entries */
+	lea	(0x1000)(%ecx), %edi
+	movl	$0x000000e3, 0x00(%edi)
+	movl	%eax, 0x04(%edi)
+	movl	$0x400000e3, 0x08(%edi)
+	movl	%eax, 0x0c(%edi)
+	movl	$0x800000e3, 0x10(%edi)
+	movl	%eax, 0x14(%edi)
+	movl	$0xc00000e3, 0x18(%edi)
+	movl	%eax, 0x1c(%edi)
+
+	# load ROM based identity mapped page tables
+	mov	%ecx, %eax
+	mov	%eax, %cr3
+
+	# enable PAE
+	mov	%cr4, %eax
+	bts	$5, %eax
+	mov	%eax, %cr4
+
+	# enable long mode
+	mov	$0xC0000080, %ecx
+	rdmsr
+	bts	$8, %eax
+	wrmsr
+
+	# enable paging
+	mov	%cr0, %eax
+	bts	$31, %eax
+	mov	%eax, %cr0
+
+	# use call far to switch to 64-bit code segment
+	ljmp $0x18, $1f
+.code64
+1:
+#endif
+#endif
+
 #if ((ENV_VERSTAGE && IS_ENABLED(CONFIG_VERSTAGE_DEBUG_SPINLOOP)) \
 	|| (ENV_ROMSTAGE && IS_ENABLED(CONFIG_ROMSTAGE_DEBUG_SPINLOOP)))
 

-- 
To view, visit https://review.coreboot.org/c/coreboot/+/30114
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I57974a55f3b778c90b3587f39e86e4eb8692ad48
Gerrit-Change-Number: 30114
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181209/3e8c9650/attachment-0001.html>


More information about the coreboot-gerrit mailing list