--- machdep.c (revision 187266) +++ machdep.c (local) @@ -81,10 +81,8 @@ #include #include #include +#include #include -#if 0 -#include -#endif #include #include #include @@ -104,12 +102,7 @@ static char cpu_model[30]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, "Machine model"); -#if 0 /* see comment below */ -static void getmemsize(void); -#endif - int cold = 1; -int Maxmem; long realmem = 0; int cpu_clock = MIPS_DEFAULT_HZ; SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD, @@ -118,6 +111,8 @@ vm_offset_t kstack0; +struct msgbuf *msgbufp=0; + #ifdef SMP struct pcpu __pcpu[32]; char pcpu_boot_stack[KSTACK_PAGES * PAGE_SIZE * (MAXCPU-1)]; @@ -154,10 +149,9 @@ extern char edata[], end[]; -u_int32_t bootdev; +uint32_t bootdev; struct bootinfo bootinfo; - static void cpu_startup(void *dummy) { @@ -165,12 +159,8 @@ if (boothowto & RB_VERBOSE) bootverbose++; - /* - * Good {morning,afternoon,evening,night}. - */ - printf("real memory = %lu (%luK bytes)\n", ptoa(Maxmem), - ptoa(Maxmem) / 1024); - realmem = Maxmem; + printf("real memory = %lu (%luK bytes)\n", ptoa(realmem), + ptoa(realmem) / 1024); /* * Display any holes after the first chunk of extended memory. */ @@ -205,8 +195,8 @@ void cpu_reset(void) { - for (;;) - ; + + platform_reset(); } /* Get current clock frequency for the given cpu id. */ @@ -292,118 +282,6 @@ PCPU_SET(curpcb, thread0.td_pcb); } -struct msgbuf *msgbufp=0; - -#if 0 -/* - * This code has been moved to the platform_init code. The only - * thing that's beign done here that hasn't been moved is the wired tlb - * pool stuff. I'm still trying to understand that feature..., since - * it maps from the end the kernel to 0x08000000 somehow. But the stuff - * was stripped out, so it is hard to say what's going on.... - */ -u_int32_t freemem_start; - -static void -getmemsize() -{ - vm_offset_t kern_start, kern_end; - vm_offset_t AllowMem, memsize; - const char *cp; - size_t sz; - int phys_avail_cnt; - - /* Determine memory layout */ - phys_avail_cnt = 0; - kern_start = mips_trunc_page(MIPS_CACHED_TO_PHYS(btext)); - if (kern_start < freemem_start) -panic("kernel load address too low, overlapping with memory reserved for FPC IPC\n"); - - if (kern_start > freemem_start) { - phys_avail[phys_avail_cnt++] = freemem_start; - /* - * Since the stack is setup just before kern_start, - * leave some space for stack to grow - */ - phys_avail[phys_avail_cnt++] = kern_start - PAGE_SIZE * 3; - MIPS_DEBUG_PRINT("phys_avail : %p - %p", \ - phys_avail[phys_avail_cnt-2], phys_avail[phys_avail_cnt-1]); - } - - kern_end = (vm_offset_t) end; - kern_end = (vm_offset_t) mips_round_page(kern_end); - MIPS_DEBUG_PRINT("kern_start : 0x%x, kern_end : 0x%x", btext, kern_end); - phys_avail[phys_avail_cnt++] = MIPS_CACHED_TO_PHYS(kern_end); - - if (need_wired_tlb_page_pool) { - mips_wired_tlb_physmem_start = MIPS_CACHED_TO_PHYS(kern_end); - mips_wired_tlb_physmem_end = 0x08000000; - MIPS_DEBUG_PRINT("%s: unmapped page start [0x%x] end[0x%x]\n",\ - __FUNCTION__, mips_wired_tlb_physmem_start, \ - mips_wired_tlb_physmem_end); - if (mips_wired_tlb_physmem_start > mips_wired_tlb_physmem_end) - panic("Error in Page table page physical address assignment\n"); - } - - if (bootinfo.bi_memsizes_valid) - memsize = bootinfo.bi_basemem * 1024; - else { - memsize = SDRAM_MEM_SIZE; - } - - /* - * hw.physmem is a size in bytes; we also allow k, m, and g suffixes - * for the appropriate modifiers. - */ - if ((cp = getenv("hw.physmem")) != NULL) { - vm_offset_t sanity; - char *ep; - - sanity = AllowMem = strtouq(cp, &ep, 0); - if ((ep != cp) && (*ep != 0)) { - switch(*ep) { - case 'g': - case 'G': - AllowMem <<= 10; - case 'm': - case 'M': - AllowMem <<= 10; - case 'k': - case 'K': - AllowMem <<= 10; - break; - default: - AllowMem = sanity = 0; - } - if (AllowMem < sanity) - AllowMem = 0; - } - if (!AllowMem || (AllowMem < (kern_end - KERNBASE))) - printf("Ignoring invalid hw.physmem size of '%s'\n", cp); - } else - AllowMem = 0; - - if (AllowMem) - memsize = (memsize > AllowMem) ? AllowMem : memsize; - - phys_avail[phys_avail_cnt++] = SDRAM_ADDR_START + memsize; - MIPS_DEBUG_PRINT("phys_avail : 0x%x - 0x%x", \ - phys_avail[phys_avail_cnt-2], phys_avail[phys_avail_cnt-1]); - phys_avail[phys_avail_cnt] = 0; - - physmem = btoc(memsize); - Maxmem = physmem; - - /* - * Initialize error message buffer (at high end of memory). - */ - sz = round_page(MSGBUF_SIZE); - msgbufp = (struct msgbuf *) pmap_steal_memory(sz); - msgbufinit(msgbufp, sz); - printf("%s: msgbufp[size=%d] = 0x%p\n", __FUNCTION__, sz, msgbufp); -} -#endif - /* * Initialize the hardware exception vectors, and the jump table used to * call locore cache and TLB management functions, based on the kind @@ -514,10 +392,10 @@ restoreintr(td->td_md.md_saved_intr); } -u_int32_t +uint32_t get_cyclecount(void) { - u_int32_t count; + uint32_t count; mfc0_macro(count, 9); return (count); @@ -529,6 +407,7 @@ void cpu_idle(int busy) { + if (mips_cp0_status_read() & SR_INT_ENAB) __asm __volatile ("wait"); else