Add machdep sysctl support. Support booted_device, consdev, and
printfataltraps.
This commit is contained in:
parent
67427c17a2
commit
986f7ca902
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpu.h,v 1.65 2003/02/27 07:14:19 matt Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.66 2003/03/01 21:51:59 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden
|
||||
|
@ -38,6 +38,20 @@
|
|||
#include "opt_lockdebug.h"
|
||||
#endif
|
||||
|
||||
#define CPU_PRINTFATALTRAPS 1
|
||||
#define CPU_CONSDEV 2
|
||||
#define CPU_BOOTED_DEVICE 3
|
||||
#define CPU_BOOTED_KERNEL 4
|
||||
#define CPU_MAXID 5
|
||||
|
||||
#define CTL_MACHDEP_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "printfataltraps", CTLTYPE_INT }, \
|
||||
{ "console_device", CTLTYPE_STRUCT }, \
|
||||
{ "booted_device", CTLTYPE_STRING }, \
|
||||
{ "booted_kernel", CTLTYPE_STRING }, \
|
||||
}
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
@ -140,6 +154,8 @@ struct cpu_info {
|
|||
#define CI_RUNNING 2 /* Set when a slave CPU is running */
|
||||
#define CI_STOPPED 4 /* Stopped (in debugger) */
|
||||
|
||||
extern int cpu_printfataltraps;
|
||||
|
||||
#if defined(MULTIPROCESSOR)
|
||||
/*
|
||||
* "helper" struct. All multicpu systems must have the first two field
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.132 2003/01/18 07:10:34 thorpej Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.133 2003/03/01 21:51:59 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, Hugh Graham.
|
||||
|
@ -291,13 +291,44 @@ cpu_dumpconf()
|
|||
}
|
||||
|
||||
int
|
||||
cpu_sysctl(a, b, c, d, e, f, g)
|
||||
int *a;
|
||||
u_int b;
|
||||
void *c, *e;
|
||||
size_t *d, f;
|
||||
struct proc *g;
|
||||
cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
void *oldp;
|
||||
size_t *oldlenp;
|
||||
void *newp;
|
||||
size_t newlen;
|
||||
struct proc *p;
|
||||
{
|
||||
dev_t consdev;
|
||||
|
||||
/* all sysctl names at this level are terminal */
|
||||
if (namelen != 1)
|
||||
return (ENOTDIR);
|
||||
|
||||
switch (name[0]) {
|
||||
case CPU_PRINTFATALTRAPS:
|
||||
return (sysctl_int(oldp, oldlenp, newp, newlen,
|
||||
&cpu_printfataltraps));
|
||||
case CPU_CONSDEV:
|
||||
if (cn_tab != NULL)
|
||||
consdev = cn_tab->cn_dev;
|
||||
else
|
||||
consdev = NODEV;
|
||||
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
|
||||
sizeof(consdev)));
|
||||
case CPU_BOOTED_DEVICE:
|
||||
if (booted_device != NULL)
|
||||
return (sysctl_rdstring(oldp, oldlenp, newp,
|
||||
booted_device->dv_xname));
|
||||
break;
|
||||
case CPU_BOOTED_KERNEL:
|
||||
/*
|
||||
* I don't think this is available to the kernel.
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: trap.c,v 1.77 2003/01/20 04:45:57 matt Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.78 2003/03/01 21:52:00 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
|
||||
|
@ -73,12 +73,14 @@
|
|||
volatile int startsysc = 0, faultdebug = 0;
|
||||
#endif
|
||||
|
||||
int cpu_printfataltraps = 0;
|
||||
|
||||
static __inline void userret (struct lwp *, struct trapframe *, u_quad_t);
|
||||
|
||||
void trap (struct trapframe *);
|
||||
void syscall (struct trapframe *);
|
||||
|
||||
char *traptypes[]={
|
||||
const char * const traptypes[]={
|
||||
"reserved addressing",
|
||||
"privileged instruction",
|
||||
"reserved operand",
|
||||
|
@ -339,12 +341,10 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
|
|||
#endif
|
||||
}
|
||||
if (trapsig) {
|
||||
#ifdef DEBUG
|
||||
if (sig == SIGSEGV || sig == SIGILL)
|
||||
printf("pid %d (%s): sig %d: type %lx, code %lx, pc %lx, psl %lx\n",
|
||||
p->p_pid, p->p_comm, sig, frame->trap,
|
||||
if ((sig == SIGSEGV || sig == SIGILL) && cpu_printfataltraps)
|
||||
printf("pid %d.%d (%s): sig %d: type %lx, code %lx, pc %lx, psl %lx\n",
|
||||
p->p_pid, l->l_lid, p->p_comm, sig, frame->trap,
|
||||
frame->code, frame->pc, frame->psl);
|
||||
#endif
|
||||
KERNEL_PROC_LOCK(l);
|
||||
trapsignal(l, sig, frame->code);
|
||||
KERNEL_PROC_UNLOCK(l);
|
||||
|
|
Loading…
Reference in New Issue