summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwes <wes@FreeBSD.org>2005-02-28 21:42:56 +0000
committerwes <wes@FreeBSD.org>2005-02-28 21:42:56 +0000
commit881fdd1aeade7114ad8d3441739b0aeb0299b92b (patch)
tree95254ba12da8a1f31b12d42b940ce82ab64ceab9
parentd89679b3edb0937fc7ea9449b2fa1ba70233425d (diff)
downloadFreeBSD-src-881fdd1aeade7114ad8d3441739b0aeb0299b92b.zip
FreeBSD-src-881fdd1aeade7114ad8d3441739b0aeb0299b92b.tar.gz
Add a sysctl that records the amount of physical memory in the machine.
Submitted by: Nicko Dehaine <nicko@stbernard.com> MFC after: 1 day
-rw-r--r--sys/i386/i386/machdep.c2
-rw-r--r--sys/kern/kern_mib.c9
-rw-r--r--sys/sys/sysctl.h4
-rw-r--r--sys/sys/systm.h1
4 files changed, 15 insertions, 1 deletions
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index bd2a9cf..09e8304 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -182,6 +182,7 @@ static void freebsd4_sendsig(sig_t catcher, int sig, sigset_t *mask,
#endif
long Maxmem = 0;
+long realmem = 0;
vm_paddr_t phys_avail[10];
@@ -214,6 +215,7 @@ cpu_startup(dummy)
#endif
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.
*/
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index e7e548c..8f0d585 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -167,6 +167,15 @@ SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_ULONG | CTLFLAG_RD,
0, 0, sysctl_hw_physmem, "LU", "");
static int
+sysctl_hw_realmem(SYSCTL_HANDLER_ARGS)
+{
+ u_long val;
+ val = ctob(realmem);
+ return (sysctl_handle_long(oidp, &val, 0, req));
+}
+SYSCTL_PROC(_hw, HW_REALMEM, realmem, CTLTYPE_ULONG | CTLFLAG_RD,
+ 0, 0, sysctl_hw_realmem, "LU", "");
+static int
sysctl_hw_usermem(SYSCTL_HANDLER_ARGS)
{
u_long val;
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 7919db2..a91f5cb 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -458,7 +458,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define HW_DISKSTATS 9 /* struct: diskstats[] */
#define HW_FLOATINGPT 10 /* int: has HW floating point? */
#define HW_MACHINE_ARCH 11 /* string: machine architecture */
-#define HW_MAXID 12 /* number of valid hw ids */
+#define HW_REALMEM 12 /* int: 'real' memory */
+#define HW_MAXID 13 /* number of valid hw ids */
#define CTL_HW_NAMES { \
{ 0, 0 }, \
@@ -472,6 +473,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
{ "disknames", CTLTYPE_STRUCT }, \
{ "diskstats", CTLTYPE_STRUCT }, \
{ "floatingpoint", CTLTYPE_INT }, \
+ { "realmem", CTLTYPE_ULONG }, \
}
/*
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 4fc149b..8c2435e 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -61,6 +61,7 @@ extern struct mtx sellock; /* select lock variable */
extern struct cv selwait; /* select conditional variable */
extern long physmem; /* physical memory */
+extern long realmem; /* 'real' memory */
extern char *rootdevnames[2]; /* names of possible root devices */
OpenPOWER on IntegriCloud