From d3649351f10c9f53f8146de20852ba1877c370fb Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 7 Jun 2000 04:59:28 +0000 Subject: [PATCH] Add support for machdep.console_device, machdep.booted_device, and machdep.booted_kernel sysctl variables on arm32. (booted_kernel only currently available on Sharks) --- sys/arch/arm32/arm32/machdep.c | 32 +++++++++++++++++++++++++++- sys/arch/arm32/include/cpu.h | 10 +++++++-- sys/arch/arm32/shark/shark_machdep.c | 16 ++++++++++++-- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/sys/arch/arm32/arm32/machdep.c b/sys/arch/arm32/arm32/machdep.c index 4fa69cae3b71..f0a86fdf71fb 100644 --- a/sys/arch/arm32/arm32/machdep.c +++ b/sys/arch/arm32/arm32/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.78 2000/05/26 21:19:31 thorpej Exp $ */ +/* $NetBSD: machdep.c,v 1.79 2000/06/07 04:59:28 matt Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -142,6 +143,10 @@ extern void dumpsys __P((void)); extern void pmap_debug __P((int level)); #endif /* PMAP_DEBUG */ +#if defined(SHARK) +int shark_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen, struct proc *p); +#endif /* * Debug function just to park the CPU */ @@ -773,6 +778,31 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case CPU_DEBUG: return(sysctl_int(oldp, oldlenp, newp, newlen, &kernel_debug)); + case CPU_BOOTED_DEVICE: + if (booted_device != NULL) + return (sysctl_rdstring(oldp, oldlenp, newp, + booted_device->dv_xname)); + return (EOPNOTSUPP); + + case CPU_CONSDEV: { + dev_t consdev; + if (cn_tab != NULL) + consdev = cn_tab->cn_dev; + else + consdev = NODEV; + return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev, + sizeof consdev)); + } +#if defined(SHARK) + case CPU_BOOTED_KERNEL: { + extern char *boot_kernel; + if (boot_kernel != NULL && boot_kernel[0] != '\0') + return sysctl_rdstring(oldp, oldlenp, newp, + boot_kernel); + return (EOPNOTSUPP); + } +#endif + default: return (EOPNOTSUPP); } diff --git a/sys/arch/arm32/include/cpu.h b/sys/arch/arm32/include/cpu.h index 3e5428368775..1dd4db98c01f 100644 --- a/sys/arch/arm32/include/cpu.h +++ b/sys/arch/arm32/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.20 2000/05/26 21:19:32 thorpej Exp $ */ +/* $NetBSD: cpu.h,v 1.21 2000/06/07 04:59:29 matt Exp $ */ /* * Copyright (c) 1994-1996 Mark Brinicombe. @@ -283,11 +283,17 @@ void child_return __P((void *)); * CTL_MACHDEP definitions. */ #define CPU_DEBUG 1 /* int: misc kernel debug control */ -#define CPU_MAXID 2 /* number of valid machdep ids */ +#define CPU_BOOTED_DEVICE 2 /* string: device we booted from */ +#define CPU_BOOTED_KERNEL 3 /* string: kernel we booted */ +#define CPU_CONSDEV 4 /* struct: dev_t of our console */ +#define CPU_MAXID 5 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ { "debug", CTLTYPE_INT }, \ + { "booted_device", CTLTYPE_STRING }, \ + { "booted_kernel", CTLTYPE_STRING }, \ + { "console_device", CTLTYPE_STRUCT }, \ } #endif /* !_ARM32_CPU_H_ */ diff --git a/sys/arch/arm32/shark/shark_machdep.c b/sys/arch/arm32/shark/shark_machdep.c index d0ccb2475934..a4d26d68a480 100644 --- a/sys/arch/arm32/shark/shark_machdep.c +++ b/sys/arch/arm32/shark/shark_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: shark_machdep.c,v 1.16 2000/06/06 20:17:36 matt Exp $ */ +/* $NetBSD: shark_machdep.c,v 1.17 2000/06/07 04:59:30 matt Exp $ */ /* * Copyright 1997 @@ -119,6 +119,7 @@ void ofbus_attach __P((struct device *, struct device *, void *)); BootConfig bootconfig; char *boot_args = NULL; char *boot_file = NULL; +char *boot_kernel = NULL; #ifndef PMAP_STATIC_L1S int max_processes = 64; /* Default number */ #endif /* !PMAP_STATIC_L1S */ @@ -398,8 +399,19 @@ ofw_device_register(struct device *dev, void *aux) char name[64]; int i; - if (boot_component == NULL) + if (boot_component == NULL) { + char *cp; boot_component = boot_file; + if (boot_component == NULL) + return; + cp = strrchr(boot_component, ':'); + if (cp != NULL) { + *cp++ = '\0'; + if (cp[0] == '\\') + cp++; + boot_kernel = cp; + } + } if (booted_device != NULL || boot_component == NULL