diff --git a/sys/arch/pmax/include/dec_prom.h b/sys/arch/pmax/include/dec_prom.h index 7ec31bda9da1..2aa4012dd45e 100644 --- a/sys/arch/pmax/include/dec_prom.h +++ b/sys/arch/pmax/include/dec_prom.h @@ -1,4 +1,4 @@ -/* $NetBSD: dec_prom.h,v 1.16 2001/07/30 17:05:51 mhitch Exp $ */ +/* $NetBSD: dec_prom.h,v 1.17 2001/08/24 15:33:17 mhitch Exp $ */ /* * Copyright (c) 1992, 1993 @@ -76,7 +76,7 @@ #define DEC_PROM_MAGIC 0x30464354 -typedef struct { +typedef struct memmap { int pagesize; /* system page size */ u_char bitmap[15360]; /* bit for each page indicating safe to use */ } memmap; diff --git a/sys/arch/pmax/include/vmparam.h b/sys/arch/pmax/include/vmparam.h index 8d73b93efdbe..dfa04f57be2f 100644 --- a/sys/arch/pmax/include/vmparam.h +++ b/sys/arch/pmax/include/vmparam.h @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.13 2000/01/11 20:36:17 ad Exp $ */ +/* $NetBSD: vmparam.h,v 1.14 2001/08/24 15:33:17 mhitch Exp $ */ #ifndef _PMAX_VMPARAM_H_ #define _PMAX_VMPARAM_H_ @@ -15,6 +15,6 @@ #define VM_FREELIST_DEFAULT 0 #define VM_FREELIST_FIRST8 1 -#define VM_PHYSSEG_MAX 2 +#define VM_PHYSSEG_MAX 16 /* 15 + 1 free lists */ #endif /* !_PMAX_VMPARAM_H_ */ diff --git a/sys/arch/pmax/pmax/dec_3max.c b/sys/arch/pmax/pmax/dec_3max.c index 18aeef5b5d73..52e1b2ed78ad 100644 --- a/sys/arch/pmax/pmax/dec_3max.c +++ b/sys/arch/pmax/pmax/dec_3max.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_3max.c,v 1.33 2001/08/22 06:59:39 nisimura Exp $ */ +/* $NetBSD: dec_3max.c,v 1.34 2001/08/24 15:33:16 mhitch Exp $ */ /* * Copyright (c) 1998 Jonathan Stone. All rights reserved. @@ -73,7 +73,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_3max.c,v 1.33 2001/08/22 06:59:39 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_3max.c,v 1.34 2001/08/24 15:33:16 mhitch Exp $"); #include #include @@ -115,7 +115,7 @@ dec_3max_init() platform.cons_init = dec_3max_cons_init; platform.iointr = dec_3max_intr; platform.intr_establish = dec_3max_intr_establish; - platform.memsize = memsize_scan; + platform.memsize = memsize_bitmap; /* no high resolution timer available */ /* clear any memory errors */ diff --git a/sys/arch/pmax/pmax/dec_3maxplus.c b/sys/arch/pmax/pmax/dec_3maxplus.c index 1d978f09befe..c79652142974 100644 --- a/sys/arch/pmax/pmax/dec_3maxplus.c +++ b/sys/arch/pmax/pmax/dec_3maxplus.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_3maxplus.c,v 1.44 2001/08/22 06:59:40 nisimura Exp $ */ +/* $NetBSD: dec_3maxplus.c,v 1.45 2001/08/24 15:33:16 mhitch Exp $ */ /* * Copyright (c) 1998 Jonathan Stone. All rights reserved. @@ -73,7 +73,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_3maxplus.c,v 1.44 2001/08/22 06:59:40 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_3maxplus.c,v 1.45 2001/08/24 15:33:16 mhitch Exp $"); #include #include @@ -123,7 +123,7 @@ dec_3maxplus_init() platform.cons_init = dec_3maxplus_cons_init; platform.iointr = dec_3maxplus_intr; platform.intr_establish = dec_3maxplus_intr_establish; - platform.memsize = memsize_scan; + platform.memsize = memsize_bitmap; platform.clkread = kn03_clkread; /* 3MAX+ has IOASIC free-running high resolution timer */ diff --git a/sys/arch/pmax/pmax/dec_3min.c b/sys/arch/pmax/pmax/dec_3min.c index fa4b5d0862c0..202b4307b998 100644 --- a/sys/arch/pmax/pmax/dec_3min.c +++ b/sys/arch/pmax/pmax/dec_3min.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_3min.c,v 1.46 2001/08/22 06:59:40 nisimura Exp $ */ +/* $NetBSD: dec_3min.c,v 1.47 2001/08/24 15:33:16 mhitch Exp $ */ /* * Copyright (c) 1998 Jonathan Stone. All rights reserved. @@ -73,7 +73,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.46 2001/08/22 06:59:40 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.47 2001/08/24 15:33:16 mhitch Exp $"); #include #include @@ -126,7 +126,7 @@ dec_3min_init() platform.cons_init = dec_3min_cons_init; platform.iointr = dec_3min_intr; platform.intr_establish = dec_3min_intr_establish; - platform.memsize = memsize_scan; + platform.memsize = memsize_bitmap; platform.clkread = kn02ba_clkread; /* clear any memory errors */ diff --git a/sys/arch/pmax/pmax/dec_maxine.c b/sys/arch/pmax/pmax/dec_maxine.c index 5b067a345ba0..0a3873a8b2ea 100644 --- a/sys/arch/pmax/pmax/dec_maxine.c +++ b/sys/arch/pmax/pmax/dec_maxine.c @@ -1,4 +1,4 @@ -/* $NetBSD: dec_maxine.c,v 1.37 2001/08/22 06:59:41 nisimura Exp $ */ +/* $NetBSD: dec_maxine.c,v 1.38 2001/08/24 15:33:16 mhitch Exp $ */ /* * Copyright (c) 1998 Jonathan Stone. All rights reserved. @@ -73,7 +73,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_maxine.c,v 1.37 2001/08/22 06:59:41 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_maxine.c,v 1.38 2001/08/24 15:33:16 mhitch Exp $"); #include #include @@ -123,7 +123,7 @@ dec_maxine_init() platform.cons_init = dec_maxine_cons_init; platform.iointr = dec_maxine_intr; platform.intr_establish = dec_maxine_intr_establish; - platform.memsize = memsize_scan; + platform.memsize = memsize_bitmap; platform.clkread = kn02ca_clkread; /* MAXINE has 1 microsec. free-running high resolution timer */ diff --git a/sys/arch/pmax/pmax/machdep.c b/sys/arch/pmax/pmax/machdep.c index d1c76de00a42..20852a720855 100644 --- a/sys/arch/pmax/pmax/machdep.c +++ b/sys/arch/pmax/pmax/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.193 2001/08/22 06:59:42 nisimura Exp $ */ +/* $NetBSD: machdep.c,v 1.194 2001/08/24 15:33:16 mhitch Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,7 +43,7 @@ */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.193 2001/08/22 06:59:42 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.194 2001/08/24 15:33:16 mhitch Exp $"); #include "fs_mfs.h" #include "opt_ddb.h" @@ -332,14 +332,6 @@ mach_init(argc, argv, code, cv, bim, bip) /* Find out how much memory is available. */ physmem = (*platform.memsize)(kernend); - /* - * Now that we know how much memory we have, initialize the - * mem cluster array. - */ - mem_clusters[0].start = 0; /* XXX is this correct? */ - mem_clusters[0].size = ctob(physmem); - mem_cluster_cnt = 1; - /* * Load the rest of the available pages into the VM system. * Put the first 8M of RAM onto a lower-priority free list, since @@ -347,16 +339,21 @@ mach_init(argc, argv, code, cv, bim, bip) * into this region, and we want them to have a fighting chance of * allocating their DMA memory during autoconfiguration. */ - first = round_page(MIPS_KSEG0_TO_PHYS(kernend)); - last = mem_clusters[0].start + mem_clusters[0].size; - if (last <= (8 * 1024 * 1024)) { - uvm_page_physload(atop(first), atop(last), atop(first), - atop(last), VM_FREELIST_DEFAULT); - } else { - uvm_page_physload(atop(first), atop(8 * 1024 * 1024), - atop(first), atop(8 * 1024 * 1024), VM_FREELIST_FIRST8); - uvm_page_physload(atop(8 * 1024 * 1024), atop(last), - atop(8 * 1024 * 1024), atop(last), VM_FREELIST_DEFAULT); + for (i = 0, physmem = 0; i < mem_cluster_cnt; ++i) { + first = mem_clusters[i].start; + if (first == 0) + first = round_page(MIPS_KSEG0_TO_PHYS(kernend)); + last = mem_clusters[i].start + mem_clusters[i].size; + physmem += atop(mem_clusters[i].size); + if (i != 0 || last <= (8 * 1024 * 1024)) { + uvm_page_physload(atop(first), atop(last), atop(first), + atop(last), VM_FREELIST_DEFAULT); + } else { + uvm_page_physload(atop(first), atop(8 * 1024 * 1024), + atop(first), atop(8 * 1024 * 1024), VM_FREELIST_FIRST8); + uvm_page_physload(atop(8 * 1024 * 1024), atop(last), + atop(8 * 1024 * 1024), atop(last), VM_FREELIST_DEFAULT); + } } /* @@ -654,6 +651,14 @@ memsize_scan(first) mem++; } + /* + * Now that we know how much memory we have, initialize the + * mem cluster array. + */ + mem_clusters[0].start = 0; /* XXX is this correct? */ + mem_clusters[0].size = ctob(physmem); + mem_cluster_cnt = 1; + /* clear any memory error conditions possibly caused by probe */ (*platform.bus_reset)(); return (mem); @@ -666,8 +671,38 @@ int memsize_bitmap(first) caddr_t first; { + memmap *prom_memmap = (memmap *)first; + int i, mapbytes; + int segstart, curaddr, xsize, segnum; - panic("memsize_bitmap not implemented"); + mapbytes = prom_getbitmap(prom_memmap); + if (mapbytes == 0) + return (memsize_scan(first)); + + segstart = curaddr = i = segnum = 0; + xsize = prom_memmap->pagesize * 8; + while (i < mapbytes) { + while (prom_memmap->bitmap[i] == 0xff && i < mapbytes) { + ++i; + curaddr += xsize; + } + if (curaddr > segstart) { + mem_clusters[segnum].start = segstart; + mem_clusters[segnum].size = curaddr - segstart; + ++segnum; + } + while (i < mapbytes && prom_memmap->bitmap[i] != 0xff) { + ++i; + curaddr += xsize; + } + segstart = curaddr; + } + mem_cluster_cnt = segnum; + for (i = 0; i < segnum; ++i) { + printf("segment %2d start %08lx size %08lx\n", i, + (long)mem_clusters[i].start, (long)mem_clusters[i].size); + } + return (mapbytes * 8); } /* diff --git a/sys/arch/pmax/pmax/machdep.h b/sys/arch/pmax/pmax/machdep.h index 1100c79328cd..19ca7e0720c5 100644 --- a/sys/arch/pmax/pmax/machdep.h +++ b/sys/arch/pmax/pmax/machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.h,v 1.8 2000/03/28 23:57:30 simonb Exp $ */ +/* $NetBSD: machdep.h,v 1.9 2001/08/24 15:33:17 mhitch Exp $ */ /* * Copyright (c) 1998 Jonathan Stone. All rights reserved. @@ -33,6 +33,8 @@ /* max memory for a model */ extern int physmem_boardmax; /* {model,simm}-specific bound on physmem */ +struct memmap; + /* PROM callback routines - see pmax/promcall.c */ void prom_findcons __P((int *, int *, int *)); void prom_halt __P((int, char *)) __attribute__((__noreturn__)); @@ -40,3 +42,4 @@ void prom_haltbutton __P((void)); int prom_scsiid __P((int)); char *prom_getenv __P((char *)); int prom_systype __P((void)); +int prom_getbitmap __P((struct memmap *)); diff --git a/sys/arch/pmax/pmax/promcall.c b/sys/arch/pmax/pmax/promcall.c index 64945613a9bf..6ccc943ebbc2 100644 --- a/sys/arch/pmax/pmax/promcall.c +++ b/sys/arch/pmax/pmax/promcall.c @@ -1,4 +1,4 @@ -/* $NetBSD: promcall.c,v 1.7 2000/03/30 14:45:13 simonb Exp $ */ +/* $NetBSD: promcall.c,v 1.8 2001/08/24 15:33:17 mhitch Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,7 +43,7 @@ */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.7 2000/03/30 14:45:13 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.8 2001/08/24 15:33:17 mhitch Exp $"); #include #include @@ -234,3 +234,30 @@ prom_scsiid(cnum) cp = prom_getenv(scsiid_var); return (cp != NULL) ? strtoul(cp, NULL, 0) : DEFAULT_SCSIID; } + +/* + * Get the memory bitmap from the PROM if we can + */ +int +prom_getbitmap(map) + struct memmap *map; +{ + char *cp; + int len; + + if (callv->_getbitmap != NULL) + return (callv->_getbitmap(map)); + /* + * See if we can get the bitmap from the environment variables + */ + cp = prom_getenv("bitmaplen"); + if (cp == NULL) + return (0); + len = (int)strtoul(cp, NULL, 0) * 4; + cp = prom_getenv("bitmap"); + if (cp == NULL) + return (0); + bcopy((char *)strtoul(cp, NULL, 0), &map->bitmap, len); + map->pagesize = 4096; + return (len); +}