Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/i386/i386/machdep.c,v retrieving revision 1.586 retrieving revision 1.586.2.5 diff -u -p -r1.586 -r1.586.2.5 --- src/sys/arch/i386/i386/machdep.c 2006/11/16 01:32:38 1.586 +++ src/sys/arch/i386/i386/machdep.c 2007/08/28 11:46:26 1.586.2.5 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.586 2006/11/16 01:32:38 christos Exp $ */ +/* $NetBSD: machdep.c,v 1.586.2.5 2007/08/28 11:46:26 liamjfoy Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.586 2006/11/16 01:32:38 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.586.2.5 2007/08/28 11:46:26 liamjfoy Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -132,6 +132,8 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include +#include + #include #include #include @@ -183,6 +185,14 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include "npx.h" #include "ksyms.h" +#include "cardbus.h" +#if NCARDBUS > 0 +/* For rbus_min_start hint. */ +#include +#include +#include +#endif + #include "mca.h" #if NMCA > 0 #include /* for mca_busprobe() */ @@ -240,7 +250,11 @@ int i386_has_sse2; int tmx86_has_longrun; vaddr_t msgbuf_vaddr; -paddr_t msgbuf_paddr; +struct { + paddr_t paddr; + psize_t sz; +} msgbuf_p_seg[VM_PHYSSEG_MAX]; +unsigned int msgbuf_p_cnt = 0; vaddr_t idt_vaddr; paddr_t idt_paddr; @@ -396,25 +410,31 @@ native_loader(int bl_boothowto, int bl_b void cpu_startup() { - int x; + int x, y; vaddr_t minaddr, maxaddr; + psize_t sz; char pbuf[9]; /* * Initialize error message buffer (et end of core). */ - msgbuf_vaddr = uvm_km_alloc(kernel_map, x86_round_page(MSGBUFSIZE), 0, - UVM_KMF_VAONLY); + if (msgbuf_p_cnt == 0) + panic("msgbuf paddr map has not been set up"); + for (x = 0, sz = 0; x < msgbuf_p_cnt; sz += msgbuf_p_seg[x++].sz) + continue; + msgbuf_vaddr = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_VAONLY); if (msgbuf_vaddr == 0) panic("failed to valloc msgbuf_vaddr"); /* msgbuf_paddr was init'd in pmap */ - for (x = 0; x < btoc(MSGBUFSIZE); x++) - pmap_kenter_pa((vaddr_t)msgbuf_vaddr + x * PAGE_SIZE, - msgbuf_paddr + x * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE); + for (y = 0, sz = 0; y < msgbuf_p_cnt; y++) { + for (x = 0; x < btoc(msgbuf_p_seg[y].sz); x++, sz += PAGE_SIZE) + pmap_kenter_pa((vaddr_t)msgbuf_vaddr + sz, + msgbuf_p_seg[y].paddr + x * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE); + } pmap_update(pmap_kernel()); - initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE)); + initmsgbuf((caddr_t)msgbuf_vaddr, sz); printf("%s%s", copyright, version); @@ -432,6 +452,11 @@ cpu_startup() format_bytes(pbuf, sizeof(pbuf), ptoa(physmem)); printf("total memory = %s\n", pbuf); +#if NCARDBUS > 0 + /* Tell RBUS how much RAM we have, so it can use heuristics. */ + rbus_min_start_hint(ptoa(physmem)); +#endif + minaddr = 0; /* @@ -458,6 +483,8 @@ cpu_startup() /* Safe for i/o port / memory space allocation to use malloc now. */ x86_bus_space_mallocok(); + + x86_init(); } /* @@ -1589,6 +1616,13 @@ init386(paddr_t first_avail) } /* + * If the segment is smaller than a page, skip it. + */ + if (bim->entry[x].size < NBPG) { + continue; + } + + /* * Sanity check the entry. * XXX Need to handle uint64_t in extent code * XXX and 64-bit physical addresses in i386 @@ -1813,6 +1847,7 @@ init386(paddr_t first_avail) psize_t sz = round_page(MSGBUFSIZE); psize_t reqsz = sz; + search_again: for (x = 0; x < vm_nphysseg; x++) { vps = &vm_physmem[x]; if (ptoa(vps->avail_end) == avail_end) @@ -1827,7 +1862,8 @@ init386(paddr_t first_avail) vps->avail_end -= atop(sz); vps->end -= atop(sz); - msgbuf_paddr = ptoa(vps->avail_end); + msgbuf_p_seg[msgbuf_p_cnt].sz = sz; + msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end); /* Remove the last segment if it now has no pages. */ if (vps->start == vps->end) { @@ -1841,10 +1877,17 @@ init386(paddr_t first_avail) avail_end = vm_physmem[x].avail_end; avail_end = ptoa(avail_end); + if (sz != reqsz) { + reqsz -= sz; + if (msgbuf_p_cnt != VM_PHYSSEG_MAX) { + /* if still segments available, get memory from next one ... */ + sz = reqsz; + goto search_again; + } /* Warn if the message buffer had to be shrunk. */ - if (sz != reqsz) printf("WARNING: %ld bytes not available for msgbuf " - "in last cluster (%ld used)\n", reqsz, sz); + "in last cluster (%ld used)\n", (long)MSGBUFSIZE, MSGBUFSIZE - reqsz); + } } /*