diff options
author | alc <alc@FreeBSD.org> | 2009-09-18 17:04:57 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2009-09-18 17:04:57 +0000 |
commit | 309c5ab06fe539d4f571d4c3b2acb779c5138fbf (patch) | |
tree | 7d24849cdaea55926149a790b882fea6f17045ab /sys/kern/kern_mib.c | |
parent | 87c8593067033119e40d28b40a47c236b8a5f7ac (diff) | |
download | FreeBSD-src-309c5ab06fe539d4f571d4c3b2acb779c5138fbf.zip FreeBSD-src-309c5ab06fe539d4f571d4c3b2acb779c5138fbf.tar.gz |
Add a new sysctl for reporting all of the supported page sizes.
Reviewed by: jhb
MFC after: 3 weeks
Diffstat (limited to 'sys/kern/kern_mib.c')
-rw-r--r-- | sys/kern/kern_mib.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index d42d31d..04e4dc0 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -204,6 +204,33 @@ SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_ULONG | CTLFLAG_RD, SYSCTL_ULONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, ""); +u_long pagesizes[MAXPAGESIZES] = { PAGE_SIZE }; + +static int +sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS) +{ + int error; +#ifdef SCTL_MASK32 + int i; + uint32_t pagesizes32[MAXPAGESIZES]; + + if (req->flags & SCTL_MASK32) { + /* + * Recreate the "pagesizes" array with 32-bit elements. Truncate + * any page size greater than UINT32_MAX to zero. + */ + for (i = 0; i < MAXPAGESIZES; i++) + pagesizes32[i] = (uint32_t)pagesizes[i]; + + error = SYSCTL_OUT(req, pagesizes32, sizeof(pagesizes32)); + } else +#endif + error = SYSCTL_OUT(req, pagesizes, sizeof(pagesizes)); + return (error); +} +SYSCTL_PROC(_hw, OID_AUTO, pagesizes, CTLTYPE_ULONG | CTLFLAG_RD, + NULL, 0, sysctl_hw_pagesizes, "LU", "Supported page sizes"); + static char machine_arch[] = MACHINE_ARCH; SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD, machine_arch, 0, "System architecture"); |