Check whether the SMBIOS reports reasonable amount of memory. If it is

less than "avail memory", fall back to Maxmem to avoid user confusion.
We use SMBIOS information to display "real memory" since r190599 but
some broken SMBIOS implementation reported only half of actual memory.

Tested by:	bz
Approved by:	re (kib)
This commit is contained in:
Jung-uk Kim 2009-08-20 22:58:05 +00:00
parent b4e7e7a065
commit 66406b8f25
2 changed files with 24 additions and 20 deletions

View File

@ -236,19 +236,21 @@ cpu_startup(dummy)
#ifdef PERFMON #ifdef PERFMON
perfmon_init(); perfmon_init();
#endif #endif
realmem = Maxmem;
/*
* Display physical memory if SMBIOS reports reasonable amount.
*/
memsize = 0;
sysenv = getenv("smbios.memory.enabled"); sysenv = getenv("smbios.memory.enabled");
if (sysenv != NULL) { if (sysenv != NULL) {
memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10); memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10;
freeenv(sysenv); freeenv(sysenv);
} else }
memsize = 0; if (memsize < ptoa((uintmax_t)cnt.v_free_count))
if (memsize > 0) memsize = ptoa((uintmax_t)Maxmem);
printf("real memory = %ju (%ju MB)\n", memsize << 10, printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20);
memsize >> 10);
else
printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem),
ptoa((uintmax_t)Maxmem) / 1048576);
realmem = Maxmem;
/* /*
* Display any holes after the first chunk of extended memory. * Display any holes after the first chunk of extended memory.
*/ */

View File

@ -280,19 +280,21 @@ cpu_startup(dummy)
#ifdef PERFMON #ifdef PERFMON
perfmon_init(); perfmon_init();
#endif #endif
realmem = Maxmem;
/*
* Display physical memory if SMBIOS reports reasonable amount.
*/
memsize = 0;
sysenv = getenv("smbios.memory.enabled"); sysenv = getenv("smbios.memory.enabled");
if (sysenv != NULL) { if (sysenv != NULL) {
memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10); memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10;
freeenv(sysenv); freeenv(sysenv);
} else }
memsize = 0; if (memsize < ptoa((uintmax_t)cnt.v_free_count))
if (memsize > 0) memsize = ptoa((uintmax_t)Maxmem);
printf("real memory = %ju (%ju MB)\n", memsize << 10, printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20);
memsize >> 10);
else
printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem),
ptoa((uintmax_t)Maxmem) / 1048576);
realmem = Maxmem;
/* /*
* Display any holes after the first chunk of extended memory. * Display any holes after the first chunk of extended memory.
*/ */