Add a sysctl that records the amount of physical memory in the machine.
Submitted by: Nicko Dehaine <nicko@stbernard.com> MFC after: 1 day
This commit is contained in:
parent
528433ba71
commit
a09150446d
@ -182,6 +182,7 @@ static void freebsd4_sendsig(sig_t catcher, int sig, sigset_t *mask,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
long Maxmem = 0;
|
long Maxmem = 0;
|
||||||
|
long realmem = 0;
|
||||||
|
|
||||||
vm_paddr_t phys_avail[10];
|
vm_paddr_t phys_avail[10];
|
||||||
|
|
||||||
@ -214,6 +215,7 @@ cpu_startup(dummy)
|
|||||||
#endif
|
#endif
|
||||||
printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem),
|
printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem),
|
||||||
ptoa((uintmax_t)Maxmem) / 1048576);
|
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.
|
||||||
*/
|
*/
|
||||||
|
@ -167,6 +167,15 @@ SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_ULONG | CTLFLAG_RD,
|
|||||||
0, 0, sysctl_hw_physmem, "LU", "");
|
0, 0, sysctl_hw_physmem, "LU", "");
|
||||||
|
|
||||||
static int
|
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)
|
sysctl_hw_usermem(SYSCTL_HANDLER_ARGS)
|
||||||
{
|
{
|
||||||
u_long val;
|
u_long val;
|
||||||
|
@ -458,7 +458,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
|||||||
#define HW_DISKSTATS 9 /* struct: diskstats[] */
|
#define HW_DISKSTATS 9 /* struct: diskstats[] */
|
||||||
#define HW_FLOATINGPT 10 /* int: has HW floating point? */
|
#define HW_FLOATINGPT 10 /* int: has HW floating point? */
|
||||||
#define HW_MACHINE_ARCH 11 /* string: machine architecture */
|
#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 { \
|
#define CTL_HW_NAMES { \
|
||||||
{ 0, 0 }, \
|
{ 0, 0 }, \
|
||||||
@ -472,6 +473,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
|||||||
{ "disknames", CTLTYPE_STRUCT }, \
|
{ "disknames", CTLTYPE_STRUCT }, \
|
||||||
{ "diskstats", CTLTYPE_STRUCT }, \
|
{ "diskstats", CTLTYPE_STRUCT }, \
|
||||||
{ "floatingpoint", CTLTYPE_INT }, \
|
{ "floatingpoint", CTLTYPE_INT }, \
|
||||||
|
{ "realmem", CTLTYPE_ULONG }, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -61,6 +61,7 @@ extern struct mtx sellock; /* select lock variable */
|
|||||||
extern struct cv selwait; /* select conditional variable */
|
extern struct cv selwait; /* select conditional variable */
|
||||||
|
|
||||||
extern long physmem; /* physical memory */
|
extern long physmem; /* physical memory */
|
||||||
|
extern long realmem; /* 'real' memory */
|
||||||
|
|
||||||
extern char *rootdevnames[2]; /* names of possible root devices */
|
extern char *rootdevnames[2]; /* names of possible root devices */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user