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

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

Change 28349 by peter@peter_overcee on 2003/04/06 12:20:50

	strip out some OBE stuff. partial 64 bit conversion.

Affected files ...

.. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#27 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#27 (text+ko) ====

@@ -72,13 +72,13 @@
  */
 
 #define ALLOCPAGES(foo) \
-	movl	physfree, %esi ; \
-	movl	$((foo)*PAGE_SIZE), %eax ; \
-	addl	%esi, %eax ; \
-	movl	%eax, physfree ; \
-	movl	%esi, %edi ; \
-	movl	$((foo)*PAGE_SIZE),%ecx ; \
-	xorl	%eax,%eax ; \
+	movq	physfree, %rsi ; \
+	movq	$((foo)*PAGE_SIZE), %rax ; \
+	addq	%rsi, %rax ; \
+	movq	%rax, physfree ; \
+	movq	%rsi, %rdi ; \
+	movq	$((foo)*PAGE_SIZE), %rcx ; \
+	xorq	%rax, %rax ; \
 	cld ; \
 	rep ; \
 	stosb
@@ -122,28 +122,19 @@
  * This is where the bootblocks start us, set the ball rolling...
  *
  */
-	.code32
 NON_GPROF_ENTRY(btext)
 
 /* Tell the bios to warmboot next time */
 	movw	$0x1234,0x472
 
 /* Get onto a stack that we can trust and set up a real frame. */
-#	movl	$HIDENAME(tmpstk),%esp
-	pushl	%ebp
-	movl	%esp, %ebp
+	movq	$HIDENAME(tmpstk),%rsp
+	pushq	%rbp
+	movq	%rsp, %rbp
 
 /* Don't trust what the BIOS gives for eflags. */
-	pushl	$PSL_KERNEL
-	popfl
-
-/*
- * Don't trust what the BIOS gives for %fs and %gs.  Trust the bootstrap
- * to set %cs, %ds, %es and %ss.
- */
-	mov	%ds, %ax
-	mov	%ax, %fs
-	mov	%ax, %gs
+	pushq	$PSL_KERNEL
+	popfq
 
 	call	init_serial
 
@@ -165,58 +156,24 @@
 	call	create_pagetables
 
 	PING('h');
-/* Enable PAE mode (prerequisite for long mode) */
-	movl	%cr4, %eax
-	orl	$CR4_PAE, %eax
-	movl	%eax, %cr4
-
 	PING('e');
-/* Point to the PML4 */
-	movl	IdlePML4, %eax
-	movl	%eax,%cr3		/* load ptd addr into mmu */
-
 	PING('r');
-/* Enable long mode */
-	movl	$MSR_EFER, %ecx
-	rdmsr
-	orl	$EFER_LME, %eax
-	wrmsr
-/*
- * At this point, we are in 32 bit "compatability" mode, where
- * EFER.LMA = 1, CS.L = 0, CS.D = 0, CR0.PE = 1.
- */
-
 	PING('e');
-/* Now enable paging */
-	movl	%cr0,%eax		/* get control word */
-	orl	$CR0_PG, %eax		/* enable paging */
-	movl	%eax,%cr0		/* and let's page NOW! */
-
-/*
- * Now, we're running with paging turned on, but still running with V==P
- * in low memory.  We are still using the bootblock gdt/idt.  Switch to
- * a gdt that we control so that we can flip on the 'L' bit in %cs.
- */
 	PING('0')
-	pushl	$paging			/* prepare for jump to virtual address */
-	ret
-
-/* now running relocated at KERNBASE where the system is linked to run */
-/* XXX not yet, we have to set the segment 'long' bit first! */
 paging:
 	PING('1')
 
 	/* set up bootstrap stack */
-	movl	proc0kstack,%eax	/* location of in-kernel stack */
+	movq	proc0kstack,%rax	/* location of in-kernel stack */
 			/* bootstrap stack end location */
-	leal	(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp
+	leaq	(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%rax),%rsp
 
-	xorl	%ebp,%ebp		/* mark end of frames */
+	xorq	%rbp,%rbp		/* mark end of frames */
 
-	movl	IdlePML4,%esi
-	movl	%esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax)
+	movq	IdlePML4,%rsi
+	movq	%rsi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%rax)
 
-	pushl	physfree		/* value of first for init386(first) */
+	pushq	physfree		/* value of first for init386(first) */
 	call	init386			/* wire 386 chip for unix operation */
 
 	/*
@@ -224,11 +181,11 @@
 	 * that backtraces in ddb don't underrun the stack.  Traps for
 	 * inaccessible memory are more fatal than usual this early.
 	 */
-	addl	$4,%esp
+	addq	$8,%rsp
 
 	call	mi_startup		/* autoconfiguration, mountroot etc */
 	/* NOTREACHED */
-	addl	$0,%esp			/* for db_numargs() again */
+	addq	$0,%rsp			/* for db_numargs() again */
 0:	hlt
 	jmp	0b
 
@@ -248,10 +205,10 @@
 	 * and old boot code can load new kernels.
 	 */
 
-	movl	32(%ebp),%eax		/* modulep */
-	movl	%eax,modulep
-	movl	36(%ebp),%eax		/* kernend */
-	movl	%eax,KERNend
+	movq	32(%rbp),%rax		/* modulep */
+	movq	%rax,modulep
+	movq	36(%rbp),%rax		/* kernend */
+	movq	%rax,KERNend
 
 	ret
 
@@ -390,45 +347,7 @@
 
 	ret
 
-/**********************************************************************/
-/*
- * We need to switch to a new gdt in order to get from compatability
- * mode to full 64 bit mode. These are 'long mode descriptors', not
- * the old legacy mode descriptors.  The contents are mostly ignored,
- * except for the key flags fields.
- */
-	.data
-	.p2align 4
-gdt:					/* offset = 0x0 */
-	.word	0x0			/* null descriptor (required) */
-	.word	0x0
-	.byte	0x0
-	.byte	0x0
-	.byte	0x0
-	.byte	0x0
-
-kernelcode:				/* offset = 0x8 */
-	.word	0xffff			/* segment limit 0..15 */
-	.word	0x0000			/* segment base 0..15 */
-	.byte	0x0			/* segment base 16..23 */
-	.byte	0x9f			/* flags; Type; P=1,DPL=0,C=1 */
-	.byte	0xaf			/* flags; Limit; D=0,L=1 */
-	.byte	0x0			/* segment base 24..32 */
-
-kerneldata:				/* offset = 0x10 */
-	.word	0xffff			/* segment limit 0..15 */
-	.word	0x0000			/* segment base 0..15 */
-	.byte	0x0			/* segment base 16..23 */
-	.byte	0x93			/* flags; Type; P=1 */
-	.byte	0xcf			/* flags; Limit; */
-	.byte	0x0			/* segment base 24..32 */
-gdt_end:
-
-/* Region descriptor for the gdt above */
-gdt_rd:	.word	(gdt_end - gdt)
-	.word	gdt
 #endif
-
 	.bss
 	ALIGN_DATA			/* just to be sure */
 	.globl	HIDENAME(tmpstk)
@@ -446,7 +365,6 @@
 #define COMCONSOLE	0x3f8
 #define CONSPEED	9600
 
-	.code32
 	.text
 /*
  * void serial_putc(int ch);
@@ -464,7 +382,7 @@
 	testb	$0x20, %al
 	je	1b		# TX buffer not empty
 
-	movb	4(%esp), %al
+	movb	8(%rsp), %al
 
 	subl	$5, %edx	# TX output reg
 	outb	%al, %dx	# send this one



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