Date: Sat, 21 Sep 2002 13:14:22 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 17882 for review Message-ID: <200209212014.g8LKEM6o059038@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17882 Change 17882 by peter@peter_overcee on 2002/09/21 13:10:50 start turning on long mode. We're now as far as running in "compatability mode" (long mode but with a 32 bit app) because the 'long' bit in %cs isn't set yet. This means this has a fair way to go yet.. we'll need to mess with evil gdt stuff before we can reach kernbase. :-( Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#14 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#14 (text+ko) ==== @@ -133,13 +133,13 @@ * prot = protection bits */ #define fillkpt(base, prot) \ - shll $2,%ebx ; \ + shll $3,%ebx ; \ addl base,%ebx ; \ orl $PG_V,%eax ; \ orl prot,%eax ; \ 1: movl %eax,(%ebx) ; \ addl $PAGE_SIZE,%eax ; /* increment physical address */ \ - addl $4,%ebx ; /* next pte */ \ + addl $8,%ebx ; /* next pte */ \ loop 1b /* @@ -185,17 +185,35 @@ call identify_cpu call create_pagetables -/* Now enable paging */ +/* Enable PAE mode (prerequisite for long mode) */ + movl %cr4, %eax + orl $CR4_PAE, %eax + movl %eax, %cr4 + +/* Point to the PML4 */ movl R(IdlePTD), %eax movl %eax,%cr3 /* load ptd addr into mmu */ + +/* 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. + */ + +/* Now enable paging */ movl %cr0,%eax /* get control word */ - orl $CR0_PE|CR0_PG,%eax /* enable paging */ + orl $CR0_PG, %eax /* enable paging */ movl %eax,%cr0 /* and let's page NOW! */ - pushl $begin /* jump to high virtualized address */ + pushl $begin /* 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! */ begin: /* set up bootstrap stack */ movl proc0kstack,%eax /* location of in-kernel stack */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209212014.g8LKEM6o059038>