Date: Mon, 16 May 2011 15:19:30 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r221987 - projects/pseries/powerpc/ofw Message-ID: <201105161519.p4GFJUh7087760@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Mon May 16 15:19:30 2011 New Revision: 221987 URL: http://svn.freebsd.org/changeset/base/221987 Log: Correct for some SLOF shenanigans. Modified: projects/pseries/powerpc/ofw/ofw_machdep.c Modified: projects/pseries/powerpc/ofw/ofw_machdep.c ============================================================================== --- projects/pseries/powerpc/ofw/ofw_machdep.c Mon May 16 13:12:09 2011 (r221986) +++ projects/pseries/powerpc/ofw/ofw_machdep.c Mon May 16 15:19:30 2011 (r221987) @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #define OFMEM_REGIONS 32 static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3]; static struct mem_region OFfree[OFMEM_REGIONS + 3]; -static int nOFmem; extern register_t ofmsr[5]; static int (*ofwcall)(void *); @@ -269,17 +268,28 @@ ofw_mem_regions(struct mem_region **memp phandle = OF_finddevice("/memory@0"); msz = parse_ofw_memory(phandle, "reg", OFmem); - nOFmem = msz / sizeof(struct mem_region); + msz /= sizeof(struct mem_region); asz = parse_ofw_memory(phandle, "available", OFavail); + asz /= sizeof(struct mem_region); *memp = OFmem; - *memsz = nOFmem; - + *memsz = msz; + + /* + * On some firmwares (SLOF), some memory may be marked available that + * doesn't actually exist. This manifests as an extension of the last + * available segment past the end of physical memory, so truncate that + * one. + */ + if (OFavail[asz - 1].mr_start + OFavail[asz - 1].mr_size > + OFmem[msz - 1].mr_start + OFmem[msz - 1].mr_size) + OFavail[asz - 1].mr_size = (OFmem[msz - 1].mr_start + + OFmem[msz - 1].mr_size) - OFavail[asz - 1].mr_start; + /* * OFavail may have overlapping regions - collapse these * and copy out remaining regions to OFfree */ - asz /= sizeof(struct mem_region); do { still_merging = FALSE; for (i = 0; i < asz; i++) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105161519.p4GFJUh7087760>