From 922f0e9b7817d50ff95bf369f206751741e586e9 Mon Sep 17 00:00:00 2001 From: thorpej Date: Thu, 27 Feb 2003 01:39:56 +0000 Subject: [PATCH] Add hw.physpages and hw.userpages, which return the physmem and usermem values as a u_quad (page count). Necessary for reporting memory on systems with >=4G. Per disussion on wasabisystems.com!bsd-api-discuss. --- sys/kern/kern_sysctl.c | 9 +++++++-- sys/sys/sysctl.h | 12 ++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index dcfa472bc714..d9d814920321 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sysctl.c,v 1.126 2003/02/15 18:47:41 dsl Exp $ */ +/* $NetBSD: kern_sysctl.c,v 1.127 2003/02/27 01:39:56 thorpej Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.126 2003/02/15 18:47:41 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.127 2003/02/27 01:39:56 thorpej Exp $"); #include "opt_ddb.h" #include "opt_insecure.h" @@ -693,9 +693,14 @@ hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (sysctl_rdint(oldp, oldlenp, newp, BYTE_ORDER)); case HW_PHYSMEM: return (sysctl_rdint(oldp, oldlenp, newp, ctob(physmem))); + case HW_PHYSPAGES: + return (sysctl_rdquad(oldp, oldlenp, newp, physmem)); case HW_USERMEM: return (sysctl_rdint(oldp, oldlenp, newp, ctob(physmem - uvmexp.wired))); + case HW_USERPAGES: + return (sysctl_rdquad(oldp, oldlenp, newp, + physmem - uvmexp.wired)); case HW_PAGESIZE: return (sysctl_rdint(oldp, oldlenp, newp, PAGE_SIZE)); case HW_ALIGNBYTES: diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index b733199b36bb..6c3793b2d1a5 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.h,v 1.90 2003/02/10 00:35:15 atatat Exp $ */ +/* $NetBSD: sysctl.h,v 1.91 2003/02/27 01:39:56 thorpej Exp $ */ /* * Copyright (c) 1989, 1993 @@ -522,15 +522,17 @@ struct kinfo_lwp { #define HW_MODEL 2 /* string: specific machine model */ #define HW_NCPU 3 /* int: number of cpus */ #define HW_BYTEORDER 4 /* int: machine byte order */ -#define HW_PHYSMEM 5 /* int: total memory */ -#define HW_USERMEM 6 /* int: non-kernel memory */ +#define HW_PHYSMEM 5 /* int: total memory (bytes) */ +#define HW_USERMEM 6 /* int: non-kernel memory (bytes) */ #define HW_PAGESIZE 7 /* int: software page size */ #define HW_DISKNAMES 8 /* string: disk drive names */ #define HW_DISKSTATS 9 /* struct: diskstats[] */ #define HW_MACHINE_ARCH 10 /* string: machine architecture */ #define HW_ALIGNBYTES 11 /* int: ALIGNBYTES for the kernel */ #define HW_CNMAGIC 12 /* string: console magic sequence(s) */ -#define HW_MAXID 13 /* number of valid hw ids */ +#define HW_PHYSPAGES 13 /* quad: total memory (pages) */ +#define HW_USERPAGES 14 /* quad: non-kernel memory (pages) */ +#define HW_MAXID 15 /* number of valid hw ids */ #define CTL_HW_NAMES { \ { 0, 0 }, \ @@ -546,6 +548,8 @@ struct kinfo_lwp { { "machine_arch", CTLTYPE_STRING }, \ { "alignbytes", CTLTYPE_INT }, \ { "cnmagic", CTLTYPE_STRING }, \ + { "physpages", CTLTYPE_QUAD }, \ + { "userpages", CTLTYPE_QUAD }, \ } /*