Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Apr 2003 16:43:17 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 28371 for review
Message-ID:  <200304062343.h36NhHQ2091120@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28371

Change 28371 by peter@peter_overcee on 2003/04/06 16:43:17

	Make this actually work.
	Compensate for BTX having %cs/%ds at 0xa000.  Hardcoded for now.
	This is run after BTX has shut down.

Affected files ...

.. //depot/projects/hammer/sys/boot/i386/libi386/x86_64_tramp.S#2 edit

Differences ...

==== //depot/projects/hammer/sys/boot/i386/libi386/x86_64_tramp.S#2 (text+ko) ====

@@ -1,7 +1,13 @@
 #define MSR_EFER	0xc0000080
 #define EFER_LME	0x00000100
 #define CR4_PAE		0x00000020
+#define CR4_PSE		0x00000010
 #define CR0_PG		0x80000000
+
+/* GRRR. Deal with BTX that links us for a non-zero location */
+#define VPBASE	0xa000
+#define VTOP(x)	((x) + VPBASE)
+
 	.data
 
 	.p2align 12,0x40
@@ -14,11 +20,11 @@
 	.space	0x1000
 	.globl	PT2
 PT2:
-	.space	0x4000
+	.space	0x1000
 
 gdtdesc:
 	.word	gdtend - gdt
-	.long	gdt			# low
+	.long	VTOP(gdt)		# low
 	.long	0			# high
 
 gdt:
@@ -30,17 +36,12 @@
 	.long	0x00008000
 gdtend:
 	
-
-farjmp:
-	.long	longmode
-	.word	0x8	# segment 1 is %cs
-
 	.text
 	.code32
 
 	.globl	x86_64_tramp
 x86_64_tramp:
-	/* Interrupts disabled */
+	/* Be sure that interrupts are disabled */
 	cli
 
 	/* Turn on EFER.LME */
@@ -51,32 +52,30 @@
 
 	/* Turn on PAE */
 	movl	%cr4, %eax
-	orl	$CR4_PAE, %eax
+	orl	$(CR4_PAE | CR4_PSE), %eax
 	movl	%eax, %cr4
 
 	/* Set %cr3 for PT4 */
-	movl	$PT4, %eax
+	movl	$VTOP(PT4), %eax
 	movl	%eax, %cr3
 
 	/* Turn on paging (implicitly sets EFER.LMA) */
 	movl	%cr0, %eax
 	orl	$CR0_PG, %eax
 	movl	%eax, %cr0
-	jmp	1f
-1:
 	
 	/* Now we're in compatability mode. set %cs for long mode */
-	movl	$gdtdesc, %eax
-	movl	$farjmp, %edx
-	movl	entry_hi, %ebx
-	movl	entry_lo, %ecx
+	movl	$VTOP(gdtdesc), %eax
+	movl	VTOP(entry_hi), %esi
+	movl	VTOP(entry_lo), %edi
 	lgdt	(%eax)
-	ljmp	*(%edx)
+	ljmp	$0x8, $VTOP(longmode)
 
 	.code64
 longmode:
 	/* We're still running V=P, jump to entry point */
-	movl	%ebx, %eax
+	movl	%esi, %eax
 	salq	$32, %rax
-	movl	%ecx, %eax
-	jmp	*%rax
+	movl	%edi, %eax
+	pushq	%rax
+	ret



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304062343.h36NhHQ2091120>