Sync machdep sysctls with sparc.
This commit is contained in:
parent
21f56aa969
commit
4cd21bc0aa
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: cpu.h,v 1.32 2002/09/29 04:12:02 chs Exp $ */
|
/* $NetBSD: cpu.h,v 1.33 2002/11/27 18:00:28 pk Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -51,11 +51,17 @@
|
||||||
* CTL_MACHDEP definitions.
|
* CTL_MACHDEP definitions.
|
||||||
*/
|
*/
|
||||||
#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */
|
#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */
|
||||||
#define CPU_MAXID 2 /* number of valid machdep ids */
|
#define CPU_BOOTED_DEVICE 2 /* string: device booted from */
|
||||||
|
#define CPU_BOOT_ARGS 3 /* string: args booted with */
|
||||||
|
#define CPU_ARCH 4 /* integer: cpu architecture version */
|
||||||
|
#define CPU_MAXID 5 /* number of valid machdep ids */
|
||||||
|
|
||||||
#define CTL_MACHDEP_NAMES { \
|
#define CTL_MACHDEP_NAMES { \
|
||||||
{ 0, 0 }, \
|
{ 0, 0 }, \
|
||||||
{ "booted_kernel", CTLTYPE_STRING }, \
|
{ "booted_kernel", CTLTYPE_STRING }, \
|
||||||
|
{ "booted_device", CTLTYPE_STRING }, \
|
||||||
|
{ "boot_args", CTLTYPE_STRING }, \
|
||||||
|
{ "cpu_arch", CTLTYPE_INT }, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: machdep.c,v 1.133 2002/10/16 16:11:41 martin Exp $ */
|
/* $NetBSD: machdep.c,v 1.134 2002/11/27 18:00:27 pk Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
||||||
|
@ -395,6 +395,62 @@ struct sigframe {
|
||||||
struct sigcontext sf_sc; /* actual sigcontext */
|
struct sigcontext sf_sc; /* actual sigcontext */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static char *parse_bootfile(char *);
|
||||||
|
static char *parse_bootargs(char *);
|
||||||
|
|
||||||
|
static char *
|
||||||
|
parse_bootfile(args)
|
||||||
|
char *args;
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bootargs is of the form: [kernelname] [args...]
|
||||||
|
* It can be the empty string if we booted from the default
|
||||||
|
* kernel name.
|
||||||
|
*/
|
||||||
|
cp = args;
|
||||||
|
for (cp = args; *cp != 0 && *cp != ' ' && *cp != '\t'; cp++) {
|
||||||
|
if (*cp == '-') {
|
||||||
|
int c;
|
||||||
|
/*
|
||||||
|
* If this `-' is most likely the start of boot
|
||||||
|
* options, we're done.
|
||||||
|
*/
|
||||||
|
if (cp == args)
|
||||||
|
break;
|
||||||
|
if ((c = *(cp-1)) == ' ' || c == '\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Now we've separated out the kernel name from the args */
|
||||||
|
*cp = '\0';
|
||||||
|
return (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
parse_bootargs(args)
|
||||||
|
char *args;
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
for (cp = args; *cp != '\0'; cp++) {
|
||||||
|
if (*cp == '-') {
|
||||||
|
int c;
|
||||||
|
/*
|
||||||
|
* Looks like options start here, but check this
|
||||||
|
* `-' is not part of the kernel name.
|
||||||
|
*/
|
||||||
|
if (cp == args)
|
||||||
|
break;
|
||||||
|
if ((c = *(cp-1)) == ' ' || c == '\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (cp);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* machine dependent system variables.
|
* machine dependent system variables.
|
||||||
*/
|
*/
|
||||||
|
@ -418,31 +474,42 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||||
|
|
||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
case CPU_BOOTED_KERNEL:
|
case CPU_BOOTED_KERNEL:
|
||||||
if (((chosen = OF_finddevice("/chosen")) != -1) &&
|
if (((chosen = OF_finddevice("/chosen")) == -1) ||
|
||||||
((OF_getprop(chosen, "bootargs", bootargs, sizeof bootargs))
|
((OF_getprop(chosen, "bootargs", bootargs, sizeof bootargs))
|
||||||
>= 0)) {
|
< 0))
|
||||||
/*
|
return (ENOENT);
|
||||||
* bootargs is of the form: [kernelname] [args...]
|
|
||||||
* It can be the empty string if we booted from the default
|
cp = parse_bootfile(bootargs);
|
||||||
* kernel name.
|
if (cp == NULL)
|
||||||
*/
|
return (ENOENT);
|
||||||
for (cp = bootargs;
|
if (*cp == '\0')
|
||||||
*cp && *cp != ' ' && *cp != '\t' && *cp != '\n';
|
/* Unknown to firmware, return default name */
|
||||||
cp++);
|
cp = "netbsd";
|
||||||
*cp = 0;
|
return (sysctl_rdstring(oldp, oldlenp, newp, cp));
|
||||||
/* Now we've separated out the kernel name from the args */
|
|
||||||
cp = bootargs;
|
case CPU_BOOT_ARGS:
|
||||||
if (*cp == 0 || *cp == '-')
|
if (((chosen = OF_finddevice("/chosen")) == -1) ||
|
||||||
/*
|
((OF_getprop(chosen, "bootargs", bootargs, sizeof bootargs))
|
||||||
* We can leave it NULL && let userland handle
|
< 0))
|
||||||
* the failure or set it to the default name,
|
return (ENOENT);
|
||||||
* `netbsd'
|
|
||||||
*/
|
cp = parse_bootargs(bootargs);
|
||||||
cp = "netbsd";
|
|
||||||
}
|
|
||||||
if (cp == NULL || cp[0] == '\0')
|
if (cp == NULL || cp[0] == '\0')
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
return (sysctl_rdstring(oldp, oldlenp, newp, cp));
|
return (sysctl_rdstring(oldp, oldlenp, newp, cp));
|
||||||
|
|
||||||
|
case CPU_BOOTED_DEVICE:
|
||||||
|
if (((chosen = OF_finddevice("/chosen")) == -1) ||
|
||||||
|
((OF_getprop(chosen, "bootpath", bootargs, sizeof bootargs))
|
||||||
|
< 0))
|
||||||
|
return (ENOENT);
|
||||||
|
|
||||||
|
return (sysctl_rdstring(oldp, oldlenp, newp, bootargs));
|
||||||
|
|
||||||
|
case CPU_ARCH:
|
||||||
|
/* CPU architecture version */
|
||||||
|
return (sysctl_rdint(oldp, oldlenp, newp, 9));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (EOPNOTSUPP);
|
return (EOPNOTSUPP);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue