aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/sys/devconf.h108
-rw-r--r--sys/sys/dkstat.h4
-rw-r--r--sys/sys/sysctl.h10
3 files changed, 117 insertions, 5 deletions
diff --git a/sys/sys/devconf.h b/sys/sys/devconf.h
new file mode 100644
index 000000000000..855daddc490b
--- /dev/null
+++ b/sys/sys/devconf.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 1994, Garrett A. Wollman. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: sysctl.h,v 1.17 1994/10/10 00:58:34 phk Exp $
+ */
+
+/*
+ * devconf.h - device configuration table
+ *
+ * Garrett A. Wollman, October 1994.
+ */
+
+#ifndef _SYS_DEVCONF_H_
+#define _SYS_DEVCONF_H_ 1
+
+#include <machine/devconf.h>
+
+#define MAXDEVNAME 32
+
+struct devconf {
+ char dc_name[MAXDEVNAME]; /* name of the device */
+ int dc_unit; /* unit number of the device */
+ int dc_number; /* device unique id */
+ struct machdep_devconf dc_md; /* machine-dependent stuff */
+ size_t dc_datalen; /* length of data */
+ char dc_data[1]; /* variable-length data */
+};
+
+#ifdef KERNEL
+
+struct kern_devconf; /* forward declaration */
+
+/*
+ * These four routines are called from the generic configuration
+ * table code to allow devices to provide their information in a
+ * more useful form.
+ *
+ * EXTERNALIZE: convert internal representation to external and copy out
+ * into user space.
+ */
+typedef int (*kdc_externalize_t)(struct proc *, struct kern_devconf *, void *,
+ size_t);
+/*
+ * INTERNALIZE: copy in from user space, convert to internal representation,
+ * validate, and set configuration.
+ */
+typedef int (*kdc_internalize_t)(struct proc *, struct kern_devconf *, void *,
+ size_t);
+/*
+ * DATALEN: calculate the length of the externalized form
+ */
+typedef size_t (*kdc_datalen_t)(struct kern_devconf *);
+/*
+ * GOAWAY: shut the device down, if possible, and prepare to exit.
+ */
+typedef int (*kdc_goaway_t)(struct kern_devconf *, int);
+
+struct kern_devconf {
+ struct kern_devconf *kdc_next; /* filled in by kern_devconf */
+ struct kern_devconf **kdc_rlink; /* filled in by kern_devconf */
+ int kdc_number; /* filled in by kern_devconf */
+ const char *kdc_name; /* filled in by driver */
+ int kdc_unit; /* filled in by driver */
+ struct machdep_devconf kdc_md; /* filled in by driver */
+ kdc_externalize_t kdc_externalize; /* filled in by driver */
+ kdc_internalize_t kdc_internalize; /* filled in by driver */
+ kdc_datalen_t kdc_datalen; /* filled in by driver */
+ kdc_goaway_t kdc_goaway; /* filled in by driver */
+};
+
+int dev_attach(struct kern_devconf *);
+int dev_detach(struct kern_devconf *);
+int dev_goawayall(int);
+
+#endif /* KERNEL */
+
+/*
+ * HW_DEVCONF sysctl(3) identifiers
+ */
+#define DEVCONF_NUMBER 0 /* get number of devices */
+#define DEVCONF_MAXID 1 /* number of items (not really) */
+
+#define CTL_DEVCONF_NAMES { \
+ { "number", CTLTYPE_INT }, \
+}
+
+#endif /* _SYS_DEVCONF_H_ */
diff --git a/sys/sys/dkstat.h b/sys/sys/dkstat.h
index 2486ddbfcff1..e7716be20a86 100644
--- a/sys/sys/dkstat.h
+++ b/sys/sys/dkstat.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)dkstat.h 8.2 (Berkeley) 1/21/94
- * $Id: dkstat.h,v 1.2 1994/08/02 07:52:51 davidg Exp $
+ * $Id: dkstat.h,v 1.3 1994/08/18 22:35:42 wollman Exp $
*/
#ifndef _SYS_DKSTAT_H_
@@ -50,6 +50,7 @@
#define CPUSTATES 5
#define DK_NDRIVE 8
+#define DK_NAMELEN 8
#ifdef KERNEL
extern long cp_time[CPUSTATES];
extern long dk_seek[DK_NDRIVE];
@@ -57,6 +58,7 @@ extern long dk_time[DK_NDRIVE];
extern long dk_wds[DK_NDRIVE];
extern long dk_wpms[DK_NDRIVE];
extern long dk_xfer[DK_NDRIVE];
+extern char dk_names[DK_NDRIVE][DK_NAMELEN];
extern int dk_busy;
extern int dk_ndrive;
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index c33aa9457f8b..ccad56caada7 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
- * $Id: sysctl.h,v 1.16 1994/10/08 03:31:53 phk Exp $
+ * $Id: sysctl.h,v 1.17 1994/10/10 00:58:34 phk Exp $
*/
#ifndef _SYS_SYSCTL_H_
@@ -239,7 +239,8 @@ struct kinfo_proc {
#define HW_DISKNAMES 8 /* strings: disk drive names */
#define HW_DISKSTATS 9 /* struct: diskstats[] */
#define HW_FLOATINGPT 10 /* int: has HW floating point? */
-#define HW_MAXID 11 /* number of valid hw ids */
+#define HW_DEVCONF 11 /* node: device configuration */
+#define HW_MAXID 12 /* number of valid hw ids */
#define CTL_HW_NAMES { \
{ 0, 0 }, \
@@ -253,6 +254,7 @@ struct kinfo_proc {
{ "disknames", CTLTYPE_STRUCT }, \
{ "diskstats", CTLTYPE_STRUCT }, \
{ "floatingpoint", CTLTYPE_INT }, \
+ { "devconf", CTLTYPE_NODE }, \
}
/*
@@ -361,8 +363,8 @@ int sysctl_clockrate __P((char *, size_t*));
int sysctl_vnode __P((char *, size_t*));
int sysctl_file __P((char *, size_t*));
int sysctl_doproc __P((int *, u_int, char *, size_t*));
-int kern_sysctl __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
-int hw_sysctl __P((int *, u_int, void *, size_t *, void *, size_t, struct proc *));
+
+sysctlfn dev_sysctl;
#else /* !KERNEL */
#include <sys/cdefs.h>