* add machdep.booted_device and machdep.boot_args (both fetched from

appropriate PROM variables).
* return "netbsd" for machdep.booted_kernel if the PROM doesn't return us a
  kernel name.
This commit is contained in:
darrenr 2002-02-03 14:10:02 +00:00
parent 447e6b3ec5
commit 0d5f0d9024
2 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.48 2001/12/11 03:24:46 uwe Exp $ */
/* $NetBSD: cpu.h,v 1.49 2002/02/03 14:10:02 darrenr Exp $ */
/*
* Copyright (c) 1992, 1993
@ -51,11 +51,15 @@
* CTL_MACHDEP definitions.
*/
#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_MAXID 4 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
{ "booted_kernel", CTLTYPE_STRING }, \
{ "booted_device", CTLTYPE_STRING }, \
{ "boot_args", CTLTYPE_STRING }, \
}
#ifdef _KERNEL

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.188 2001/12/04 00:05:07 darrenr Exp $ */
/* $NetBSD: machdep.c,v 1.189 2002/02/03 14:10:03 darrenr Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -472,6 +472,18 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
switch (name[0]) {
case CPU_BOOTED_KERNEL:
cp = prom_getbootfile();
if (cp == NULL)
return (ENOENT);
if (*cp == '\0')
cp = "netbsd";
return (sysctl_rdstring(oldp, oldlenp, newp, cp));
case CPU_BOOTED_DEVICE:
cp = prom_getbootpath();
if (cp == NULL || cp[0] == '\0')
return (ENOENT);
return (sysctl_rdstring(oldp, oldlenp, newp, cp));
case CPU_BOOT_ARGS:
cp = prom_getbootargs();
if (cp == NULL || cp[0] == '\0')
return (ENOENT);
return (sysctl_rdstring(oldp, oldlenp, newp, cp));