Date: Mon, 23 Sep 2002 20:02:00 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 18044 for review Message-ID: <200209240302.g8O3206k078910@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=18044 Change 18044 by peter@peter_daintree on 2002/09/23 20:01:41 more fragments. prototype gdt stuff. serial trace hooks. Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#16 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#16 (text+ko) ==== @@ -82,20 +82,6 @@ .globl kernbase .set kernbase,KERNBASE -/* - * Globals - */ - .bss - ALIGN_DATA /* just to be sure */ - .globl HIDENAME(tmpstk) - .space 0x2000 /* space for tmpstk - temporary stack */ -HIDENAME(tmpstk): - -physfree: .space 4 /* phys addr of next free page */ -KPTphys: .space 4 /* phys addr of kernel page tables */ -p0upa: .space 4 /* phys addr of proc0's UAREA */ -p0kpa: .space 4 /* phys addr of proc0's STACK */ - /********************************************************************** * * Some handy macros @@ -145,12 +131,17 @@ shrl $PAGE_SHIFT, %ebx ; \ fillkpt(R(KPTphys), prot) +#define PING(a) \ + movb $(a),%al; \ + call serial_putc + .text /********************************************************************** * * This is where the bootblocks start us, set the ball rolling... * */ + .code32 NON_GPROF_ENTRY(btext) /* Tell the bios to warmboot next time */ @@ -173,19 +164,28 @@ mov %ax, %fs mov %ax, %gs + call init_serial + + PING('H'); call recover_metadata + PING('i'); call identify_cpu + + PING('T'); 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 R(IdlePTD), %eax movl %eax,%cr3 /* load ptd addr into mmu */ + PING('r'); /* Enable long mode */ movl $MSR_EFER, %ecx rdmsr @@ -196,17 +196,27 @@ * 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! */ - pushl $begin /* prepare for jump to virtual address */ + +/* + * 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! */ -begin: +paging: + PING('1') + /* set up bootstrap stack */ movl proc0kstack,%eax /* location of in-kernel stack */ /* bootstrap stack end location */ @@ -370,3 +380,53 @@ fillkpt(R(IdlePTD), $PG_RW) 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 R(gdt) + + .bss + ALIGN_DATA /* just to be sure */ + .globl HIDENAME(tmpstk) + .space 0x1000 /* space for tmpstk - temporary stack */ +HIDENAME(tmpstk): + +physfree: .space 4 /* phys addr of next free page */ +KPTphys: .space 4 /* phys addr of kernel page tables */ +p0upa: .space 4 /* phys addr of proc0's UAREA */ +p0kpa: .space 4 /* phys addr of proc0's 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?200209240302.g8O3206k078910>