diff options
-rw-r--r-- | sys/alpha/alpha/machdep.c | 55 | ||||
-rw-r--r-- | sys/conf/options.alpha | 2 |
2 files changed, 57 insertions, 0 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 3b62476..04aa677 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -92,6 +92,7 @@ #include "opt_ddb.h" #include "opt_simos.h" #include "opt_msgbuf.h" +#include "opt_maxmem.h" #include <sys/param.h> #include <sys/systm.h> @@ -805,6 +806,60 @@ alpha_init(pfn, ptb, bim, bip, biv) Maxmem = physmem; +#ifdef MAXMEM + /* + * MAXMEM define is in kilobytes. + */ + Maxmem = alpha_btop(MAXMEM * 1024); +#endif + + /* + * hw.physmem is a size in bytes; we also allow k, m, and g suffixes + * for the appropriate modifiers. This overrides MAXMEM. + */ + if ((p = getenv("hw.physmem")) != NULL) { + u_int64_t AllowMem, sanity; + char *ep; + + sanity = AllowMem = strtouq(p, &ep, 0); + if ((ep != p) && (*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 == 0) + printf("Ignoring invalid memory size of '%s'\n", p); + else + Maxmem = alpha_btop(AllowMem); + } + + while (physmem > Maxmem) { + int i = phys_avail_cnt - 2; + size_t sz = alpha_btop(phys_avail[i+1] - phys_avail[i]); + size_t nsz; + if (physmem - sz > Maxmem) { + phys_avail[i] = 0; + phys_avail_cnt -= 2; + } else { + nsz = sz - (physmem - Maxmem); + phys_avail[i+1] = phys_avail[i] + alpha_ptob(nsz); + physmem -= (sz - nsz); + } + } + /* * Initialize error message buffer (at end of core). */ diff --git a/sys/conf/options.alpha b/sys/conf/options.alpha index 5422f00..e44a198 100644 --- a/sys/conf/options.alpha +++ b/sys/conf/options.alpha @@ -18,6 +18,8 @@ DEC_3000_500 opt_cpu.h DEC_1000A opt_cpu.h API_UP1000 opt_cpu.h +MAXMEM + PPC_PROBE_CHIPSET opt_ppc.h PPC_DEBUG opt_ppc.h |