Date: Sun, 6 Apr 2003 20:16:47 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 28391 for review Message-ID: <200304070316.h373GlIx015940@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28391 Change 28391 by peter@peter_overcee on 2003/04/06 20:15:58 Correct the types if IdleP*. They're physical addresses, not pointers. fix bzero (doh!) tidy up locore rename init386() to hammer_time() start replacing the create_pagetables code from old locore Affected files ... .. //depot/projects/hammer/sys/x86_64/include/pmap.h#14 edit .. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#31 edit .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#41 edit .. //depot/projects/hammer/sys/x86_64/x86_64/pmap.c#16 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/include/pmap.h#14 (text+ko) ==== @@ -155,9 +155,9 @@ extern pd_entry_t PTD[]; extern pd_entry_t PTDpde[]; -extern pml4_entry_t *IdlePML4; /* physical address of "Idle" state directory */ -extern pdp_entry_t *IdlePDP; /* physical address of "Idle" state directory */ -extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */ +extern u_int64_t IdlePML4; /* physical address of "Idle" state directory */ +extern u_int64_t IdlePDP; /* physical address of "Idle" state directory */ +extern u_int64_t IdlePTD; /* physical address of "Idle" state directory */ #endif #ifdef _KERNEL ==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#31 (text+ko) ==== @@ -70,6 +70,12 @@ * * This is where the loader trampoline start us, set the ball rolling... * + * We are called with the stack looking like this: + * 0(%rsp) = 32 bit return address + * 4(%rsp) = 32 bit modulep + * 8(%rsp) = 32 bit kernend + * + * We are already in long mode, on a 64 bit %cs and running at KERNBASE. */ NON_GPROF_ENTRY(btext) @@ -82,41 +88,22 @@ call init_serial - movq $str, %rdi - call serial_puts - - movq $prf, %rdi - movl $0x12ab34ef, %esi - xorl %eax, %eax - call printf - /* Find the metadata pointers before we lose them */ - movq 32(%rbp),%rax /* modulep */ + movq %rsp, %rbp + xorq %rax, %rax + movl 4(%rbp),%eax /* modulep */ movq %rax,modulep - movq 36(%rbp),%rax /* kernend */ - movq %rax,KERNend + movl 8(%rbp),%eax /* kernend */ + movq %rax,physfree /* Get onto a stack that we can trust and set up a real frame. */ - movq $HIDENAME(tmpstk),%rsp + movq $bootstack,%rsp pushq %rbp movq %rsp, %rbp - hlt - -str: - .asciz "Hello, World!\n" -prf: - .asciz "This is a number: %#x\n" #if 0 - PING('i'); call identify_cpu - PING('T'); - PING('h'); - PING('e'); - PING('r'); - PING('e'); - /* set up bootstrap stack */ movq proc0kstack,%rax /* location of in-kernel stack */ /* bootstrap stack end location */ @@ -126,24 +113,15 @@ movq IdlePML4,%rsi movq %rsi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%rax) +#endif - pushq physfree /* value of first for init386(first) */ - call init386 /* wire 386 chip for unix operation */ - - /* - * Clean up the stack in a way that db_numargs() understands, so - * that backtraces in ddb don't underrun the stack. Traps for - * inaccessible memory are more fatal than usual this early. - */ - addq $8,%rsp - + call hammer_time /* set up cpu for unix operation */ call mi_startup /* autoconfiguration, mountroot etc */ - /* NOTREACHED */ - addq $0,%rsp /* for db_numargs() again */ 0: hlt jmp 0b +#if 0 /********************************************************************** * * Identify the CPU and initialize anything special about it @@ -170,28 +148,11 @@ /***********************************************************************/ - .bss - ALIGN_DATA /* just to be sure */ - .globl HIDENAME(tmpstk) - .space 0x1000 /* space for tmpstk - temporary stack */ -HIDENAME(tmpstk): -#if 0 -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 */ -#endif - #define COMBRD(x) (1843200 / (16*(x))) #define COMCONSOLE 0x3f8 #define CONSPEED 9600 - .text -/* - * void serial_putc(int ch); - * Write character `ch' to port COMCONSOLE. - */ .globl serial_putc .type serial_putc@function serial_putc: @@ -211,11 +172,6 @@ 2: ret -/* - * void init_serial(void); - * Initialize port COMCONSOLE to speed CONSPEED, line settings 8N1. - */ - .globl init_serial .type init_serial@function init_serial: @@ -252,3 +208,8 @@ jne 1b # more ret + + .bss + ALIGN_DATA /* just to be sure */ + .space 0x1000 /* space for bootstack - temporary stack */ +bootstack: ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#41 (text+ko) ==== @@ -110,7 +110,7 @@ #include <sys/ptrace.h> #include <machine/sigframe.h> -extern void init386(int first); +extern void hammer_time(void); #if 0 extern void dblfault_handler(void); #endif @@ -134,11 +134,11 @@ int _udatasel, _ucodesel; u_int atdevbase; -/* These are written in 32 bit mode */ -u_int32_t modulep; /* phys addr of metadata table */ -pd_entry_t *IdlePTD; /* phys addr of kernel PTD */ -pdp_entry_t *IdlePDP; /* phys addr of kernel level 3 */ -pml4_entry_t *IdlePML4; /* phys addr of kernel level 4 */ +u_int64_t modulep; /* phys addr of metadata table */ +u_int64_t physfree; /* first free page after kernel */ +u_int64_t IdlePTD; /* phys addr of kernel PTD */ +u_int64_t IdlePDP; /* phys addr of kernel level 3 */ +u_int64_t IdlePML4; /* phys addr of kernel level 4 */ struct user *proc0uarea; /* address of proc 0 uarea space */ vm_offset_t proc0kstack; /* address of proc 0 kstack space */ @@ -736,7 +736,7 @@ * XXX first should be vm_paddr_t. */ static void -getmemsize(int first) +getmemsize(u_int64_t first) { int i, physmap_idx, pa_indx; u_int basemem, extmem; @@ -747,6 +747,7 @@ bzero(physmap, sizeof(physmap)); basemem = 0; + smap = 0; /* * map page 1 R/W into the kernel page table so we can use it @@ -1030,15 +1031,47 @@ avail_end = phys_avail[pa_indx]; } +static u_int64_t +allocpages(int n) +{ + u_int64_t ret; + + ret = physfree; + bzero((void *)ret, n * PAGE_SIZE); + physfree += n * PAGE_SIZE; + return (ret); +} + void -init386(first) - int first; +hammer_time(void) { caddr_t kmdp; int gsel_tss, off, x; struct region_descriptor r_gdt, r_idt; struct pcpu *pc; + u_int64_t p0kpa; + u_int64_t p0upa; + u_int64_t KPTphys; + u_int64_t first; + + first = physfree; +printf("made it to hammer_time! first = 0x%x\n", first); + KPTphys = allocpages(NKPT); + printf("KPTphys = 0x%lx\n", KPTphys); + IdlePML4 = allocpages(1); + printf("IdlePML4 = 0x%lx\n", IdlePML4); + IdlePDP = allocpages(1); + printf("IdlePDP = 0x%lx\n", IdlePDP); + IdlePTD = allocpages(NPGPTD); + printf("IdlePTD = 0x%lx\n", IdlePTD); + p0upa = allocpages(UAREA_PAGES); + printf("p0upa = 0x%lx\n", p0upa); + p0kpa = allocpages(KSTACK_PAGES); + printf("p0kpa = 0x%lx\n", p0kpa); + +for(;;); + proc0.p_uarea = proc0uarea; thread0.td_kstack = proc0kstack; thread0.td_pcb = (struct pcb *) @@ -1192,9 +1225,9 @@ dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 = dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL); #ifdef PAE - dblfault_tss.tss_cr3 = (int)IdlePDPT; + dblfault_tss.tss_cr3 = IdlePDPT; #else - dblfault_tss.tss_cr3 = (int)IdlePTD; + dblfault_tss.tss_cr3 = IdlePTD; #endif dblfault_tss.tss_eip = (int)dblfault_handler; dblfault_tss.tss_rflags = PSL_KERNEL; @@ -1216,7 +1249,7 @@ /* setup proc 0's pcb */ thread0.td_pcb->pcb_flags = 0; /* XXXKSE */ - thread0.td_pcb->pcb_cr3 = (long)IdlePML4; + thread0.td_pcb->pcb_cr3 = IdlePML4; thread0.td_frame = &proc0_tf; } @@ -1629,7 +1662,7 @@ size_t i; cbuf = (char *)buf; - for (i = len - 1; i >= 0; i--) + for (i = 0; i < len; i++) cbuf[i] = 0; } ==== //depot/projects/hammer/sys/x86_64/x86_64/pmap.c#16 (text+ko) ==== @@ -185,7 +185,6 @@ static int nkpt; vm_offset_t kernel_vm_end; -u_int32_t KERNend; /* Written in 32 bit mode */ static uma_zone_t pdpzone; static uma_zone_t pml4zone; @@ -301,9 +300,9 @@ /* * Initialize the kernel pmap (which is statically allocated). */ - kernel_pmap->pm_pdir = (pd_entry_t *) (KERNBASE + (u_long)IdlePTD); - kernel_pmap->pm_pdp = (pdp_entry_t *) (KERNBASE + (u_long)IdlePDP); - kernel_pmap->pm_pml4 = (pdp_entry_t *) (KERNBASE + (u_long)IdlePML4); + kernel_pmap->pm_pdir = (pd_entry_t *) (KERNBASE + IdlePTD); + kernel_pmap->pm_pdp = (pdp_entry_t *) (KERNBASE + IdlePDP); + kernel_pmap->pm_pml4 = (pdp_entry_t *) (KERNBASE + IdlePML4); kernel_pmap->pm_active = -1; /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvlist); LIST_INIT(&allpmaps); @@ -1012,9 +1011,9 @@ struct pmap *pmap; { - pmap->pm_pdir = (pd_entry_t *)(KERNBASE + (vm_offset_t)IdlePTD); - pmap->pm_pdp = (pdp_entry_t *)(KERNBASE + (vm_offset_t)IdlePDP); - pmap->pm_pml4 = (pml4_entry_t *)(KERNBASE + (vm_offset_t)IdlePML4); + pmap->pm_pdir = (pd_entry_t *)(KERNBASE + IdlePTD); + pmap->pm_pdp = (pdp_entry_t *)(KERNBASE + IdlePDP); + pmap->pm_pml4 = (pml4_entry_t *)(KERNBASE + IdlePML4); pmap->pm_active = 0; TAILQ_INIT(&pmap->pm_pvlist); bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304070316.h373GlIx015940>