From owner-p4-projects@FreeBSD.ORG Mon May 12 21:39:15 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2B2EE37B404; Mon, 12 May 2003 21:39:15 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D5E0637B401 for ; Mon, 12 May 2003 21:39:14 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5AA4943FA3 for ; Mon, 12 May 2003 21:39:14 -0700 (PDT) (envelope-from jmallett@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h4D4dE0U068753 for ; Mon, 12 May 2003 21:39:14 -0700 (PDT) (envelope-from jmallett@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4D4dDpt068750 for perforce@freebsd.org; Mon, 12 May 2003 21:39:13 -0700 (PDT) Date: Mon, 12 May 2003 21:39:13 -0700 (PDT) Message-Id: <200305130439.h4D4dDpt068750@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmallett@freebsd.org using -f From: Juli Mallett To: Perforce Change Reviews Subject: PERFORCE change 31051 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2003 04:39:16 -0000 http://perforce.freebsd.org/chv.cgi?CH=31051 Change 31051 by jmallett@jmallett_dalek on 2003/05/12 21:38:17 Print and return error from elf load functions, since we are not doing the right thing yet with regard to modules and whatnot. Add a parameter to pmap_bootstrap, the end of the loaded kernel. This makes it safe to run the system, as we stop overwriting kernel memory, due to using a small block before the kernel. D'oh! Add cpu_startup and related (platform) callouts for great SI_SUB_CPU justice. Add a note about where NetBSD stuff begins in machdep.c, I want to go at it with an axe. If0 some unused stuff accompanying other if0 code. Point to FreeBSD/MIPS list, not NetBSD. Cheat very bad and run without virtual memory. Mark virtual memory beginning at the end of the kernel, and going as far as we have memory. That doesn't really work, but for now, why not. Track loaded program memory, and the top of the kernel. Print such. Affected files ... .. //depot/projects/mips/sys/mips/include/md_var.h#7 edit .. //depot/projects/mips/sys/mips/include/pmap.h#9 edit .. //depot/projects/mips/sys/mips/mips/elf_machdep.c#2 edit .. //depot/projects/mips/sys/mips/mips/machdep.c#23 edit .. //depot/projects/mips/sys/mips/mips/pmap.c#13 edit .. //depot/projects/mips/sys/mips/sgimips/machdep_sgimips.c#16 edit Differences ... ==== //depot/projects/mips/sys/mips/include/md_var.h#7 (text+ko) ==== @@ -39,4 +39,7 @@ void mips_init(void); void swi_vm(void *); +/* Platform call-downs. */ +void platform_identify(void); + #endif /* !_MACHINE_MD_VAR_H_ */ ==== //depot/projects/mips/sys/mips/include/pmap.h#9 (text+ko) ==== @@ -57,7 +57,7 @@ extern vm_offset_t virtual_end; extern struct segtab *segbase; -void pmap_bootstrap(void); +void pmap_bootstrap(vm_offset_t); vm_offset_t pmap_kextract(vm_offset_t); vm_offset_t pmap_steal_memory(vm_size_t); ==== //depot/projects/mips/sys/mips/mips/elf_machdep.c#2 (text+ko) ==== @@ -34,23 +34,27 @@ int elf_cpu_load_file(linker_file_t fil) { - return (0); + printf("%s unimplemented at %s:%d, returning error.\n", __func__, __FILE__, __LINE__); + return (ENXIO); } int elf_cpu_unload_file(linker_file_t fil) { - return (0); + printf("%s unimplemented at %s:%d, returning error.\n", __func__, __FILE__, __LINE__); + return (ENXIO); } int elf_reloc(linker_file_t fil, const void *data, int rmode) { - return (0); + printf("%s unimplemented at %s:%d, returning error.\n", __func__, __FILE__, __LINE__); + return (ENXIO); } int elf_reloc_local(linker_file_t fil, const void *data, int rmode) { - return (0); + printf("%s unimplemented at %s:%d, returning error.\n", __func__, __FILE__, __LINE__); + return (ENXIO); } ==== //depot/projects/mips/sys/mips/mips/machdep.c#23 (text+ko) ==== @@ -147,6 +147,7 @@ #include #include +#include #include #include #include @@ -155,6 +156,9 @@ #include #include +#include +#include + #include #include #include @@ -183,13 +187,18 @@ struct cpu_info cpu_info_store; +struct kva_md_info kmi; + vm_offset_t kstack0; vm_paddr_t kstack0_phys; +static void cpu_identify(void); +void cpu_startup(void *); +SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); + void mips_init(void) { - cpu_identify(); proc_linkup(&proc0, &ksegrp0, &kse0, &thread0); proc0.p_uarea = (struct user *)uarea0; proc0.p_stats = &proc0.p_uarea->u_stats; @@ -203,6 +212,19 @@ } void +cpu_startup(void *dummy) +{ + cpu_identify(); + + printf("real memory = %lu (%lu MB)\n", physsz, physsz / 1024); + + vm_ksubmap_init(&kmi); + bufinit(); + vm_pager_bufferinit(); + +} + +void cpu_halt(void) { printf("Halting...\n"); @@ -310,6 +332,10 @@ return (-1); } +/* + * XXX begin NetBSD stuff, I want to rewrite or move out most. + */ + static void mips64_vector_init(void); extern long *mips64_locoresw[]; @@ -559,8 +585,10 @@ /* Cache error handler */ extern char mips64_cache[], mips64_cacheEnd[]; +#if 0 /* MIPS32/MIPS64 interrupt exception handler */ extern char mips64_intr[], mips64_intrEnd[]; +#endif /* * Copy down exception vector code. @@ -761,7 +789,7 @@ /* * Identify product revision IDs of cpu and fpu. */ -void +static void cpu_identify(void) { static const char * const waynames[] = { @@ -832,7 +860,7 @@ MIPS_PRID_RSVD(cpu_id) != 0) { printf("%s: NOTE: top 8 bits of prehistoric PRID not 0!\n", label); - printf("%s: Please mail port-mips@netbsd.org with cpu0 " + printf("%s: Please mail freebsd-mips@FreeBSD.org with cpu0 " "dmesg lines.\n", label); } @@ -868,4 +896,5 @@ default: panic("cpu_identify: impossible"); } + platform_identify(); } ==== //depot/projects/mips/sys/mips/mips/pmap.c#13 (text+ko) ==== @@ -139,8 +139,9 @@ vm_offset_t pmap_extract(pmap_t pmap, vm_offset_t va) { - UNIMPL(); - return (0); + if (pmap == kernel_pmap) + return (pmap_kextract(va)); + return (va); } void @@ -171,8 +172,7 @@ vm_offset_t pmap_kextract(vm_offset_t va) { - UNIMPL(); - return (0); + return (va); } vm_offset_t @@ -341,7 +341,7 @@ } void -pmap_bootstrap(void) +pmap_bootstrap(vm_offset_t kend) { int i; @@ -368,8 +368,8 @@ /* * Set the start and end of kva. */ - virtual_avail = avail_start; - virtual_end = avail_end; + virtual_avail = kend; + virtual_end = kend + physsz; kernel_vm_end = virtual_end; } ==== //depot/projects/mips/sys/mips/sgimips/machdep_sgimips.c#16 (text+ko) ==== @@ -56,7 +56,7 @@ { NULL, NULL, 0 } }; -int arcsmem, availmem; +int arcsmem, availmem, lpmem; int mach_type, mach_subtype, mach_boardrev; struct platform platform; @@ -82,7 +82,10 @@ struct machine_type *mtp; const char *cpufreq; int first, i, j, last, size; + vm_offset_t kend; + kend = 0; + /* * Initialise the ARCBIOS stuff. */ @@ -129,6 +132,21 @@ case ARCBIOS_MEM_FirmwarePermanent: arcsmem += btoc(size); break; + case ARCBIOS_MEM_LoadedProgram: + /* XXX does not allow for kernels loaded + * at the very end of the available space. + * XXX assumes sorted memory, but it is? + */ + /* + * If this kend is higher than the + * current kend, and we have memory + * before it, then mark the end of + * kernel memory. + */ + if (j > 0 && phys_avail[j - 1] >= kend) + kend = MIPS_PHYS_TO_KSEG0(last); + lpmem += btoc(size); + break; case ARCBIOS_MEM_FreeContiguous: case ARCBIOS_MEM_FreeMemory: availmem += btoc(size); @@ -146,15 +164,26 @@ } physsz += size; } + if (kend == 0) + panic("End of kernel should not be 0"); + printf("kernel memory ends at %lx\n", kend); + + init_param2(ctob(availmem)); + mips_vector_init(); + pmap_bootstrap(kend); + mips_init(); +} + +void +platform_identify(void) +{ printf("ARCS memory = %d (%d KB)\n", ctob(arcsmem), ctob(arcsmem) / 1024); + printf("Loaded program memory = %d (%d KB)\n", ctob(lpmem), + ctob(lpmem) / 1024); printf("avail memory = %d (%d MB)\n", ctob(availmem), ctob(availmem) / (1024 * 1024)); - - init_param2(ctob(availmem)); - mips_vector_init(); - pmap_bootstrap(); - mips_init(); + printf("machine: %s\n", arcbios_system_identifier); } void