diff options
-rw-r--r-- | sys/alpha/alpha/clock_if.m | 46 | ||||
-rw-r--r-- | sys/alpha/include/clockvar.h | 52 | ||||
-rw-r--r-- | sys/dev/dec/mcclock_if.m | 46 | ||||
-rw-r--r-- | sys/kern/bus_if.m | 82 | ||||
-rw-r--r-- | sys/kern/device_if.m | 69 | ||||
-rw-r--r-- | sys/kern/makedevops.sh | 232 |
6 files changed, 527 insertions, 0 deletions
diff --git a/sys/alpha/alpha/clock_if.m b/sys/alpha/alpha/clock_if.m new file mode 100644 index 0000000..cc0d265 --- /dev/null +++ b/sys/alpha/alpha/clock_if.m @@ -0,0 +1,46 @@ +# +# Copyright (c) 1998 Doug Rabson +# 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$ +# + +#include <machine/clockvar.h> + +INTERFACE clock + +METHOD void init { + device_t dev; +}; + +METHOD void get { + device_t dev; + time_t base; + struct clocktime *ct; +}; + +METHOD void set { + device_t dev; + struct clocktime *ct; +}; diff --git a/sys/alpha/include/clockvar.h b/sys/alpha/include/clockvar.h new file mode 100644 index 0000000..a34be18 --- /dev/null +++ b/sys/alpha/include/clockvar.h @@ -0,0 +1,52 @@ +/* $NetBSD: clockvar.h,v 1.4 1997/06/22 08:02:18 jonathan Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Definitions for cpu-independent clock handling for the alpha and pmax. + */ + +/* + * clocktime structure: + * + * structure passed to TOY clocks when setting them. broken out this + * way, so that the time_t -> field conversion can be shared. + */ +struct clocktime { + int year; /* year - 1900 */ + int mon; /* month (1 - 12) */ + int day; /* day (1 - 31) */ + int hour; /* hour (0 - 23) */ + int min; /* minute (0 - 59) */ + int sec; /* second (0 - 59) */ + int dow; /* day of week (0 - 6; 0 = Sunday) */ +}; + +#include "clock_if.h" + +void clockattach(device_t); diff --git a/sys/dev/dec/mcclock_if.m b/sys/dev/dec/mcclock_if.m new file mode 100644 index 0000000..39a06ba --- /dev/null +++ b/sys/dev/dec/mcclock_if.m @@ -0,0 +1,46 @@ +# +# Copyright (c) 1998 Doug Rabson +# 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$ +# + +INTERFACE mcclock + +# +# Read an RTC register and return its value. +# +METHOD u_int read { + device_t dev; + u_int reg; +}; + +# +# Write an RTC register. +# +METHOD void write { + device_t dev; + u_int reg; + u_int value; +}; diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m new file mode 100644 index 0000000..789c191 --- /dev/null +++ b/sys/kern/bus_if.m @@ -0,0 +1,82 @@ +# +# Copyright (c) 1998 Doug Rabson +# 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$ +# + +INTERFACE bus + +# +# This is called from system code which prints out a description of a +# device. It should describe the attachment that the child has with +# the parent. For instance the TurboLaser bus prints which node the +# device is attached to. +# +METHOD void print_child { + device_t dev; + device_t child; +}; + +# +# These two methods manage a bus specific set of instance variables of +# a child device. The intention is that each different type of bus +# defines a set of appropriate instance variables (such as ports and +# irqs for ISA bus etc.) +# +# This information could be given to the child device as a struct but +# that makes it hard for a bus to add or remove variables without +# forcing an edit and recompile for all drivers which may not be +# possible for vendor supplied binary drivers. + +# +# Read an instance variable. Return 0 on success. +# +METHOD int read_ivar { + device_t dev; + device_t child; + int index; + u_long *result; +}; + +# +# Write an instance variable. Return 0 on success. +# +METHOD int write_ivar { + device_t dev; + device_t child; + int index; + u_long value; +}; + +# +# Register an interrupt handler for the child device. The handler +# will be called with the value 'arg' as its only argument. +# +METHOD int map_intr { + device_t dev; + device_t child; + driver_intr_t *intr; + void *arg; +}; diff --git a/sys/kern/device_if.m b/sys/kern/device_if.m new file mode 100644 index 0000000..4ae1df8 --- /dev/null +++ b/sys/kern/device_if.m @@ -0,0 +1,69 @@ +# +# Copyright (c) 1998 Doug Rabson +# 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$ +# + +INTERFACE device + +# +# Probe to see if the device is present. Return 0 if the device exists, +# ENXIO if it cannot be found. +# +# Devices which implement busses should use this method to probe for +# the existence of devices attached to the bus and add them as +# children. If this is combined with the use of bus_generic_attach, +# the child devices will be automatically probed and attached. +# +METHOD int probe { + device_t dev; +}; + +# +# Attach a device to the system. The probe method will have been +# called and will have indicated that the device exists. This routine +# should initialise the hardware and allocate other system resources +# (such as devfs entries). Returns 0 on success. +# +METHOD int attach { + device_t dev; +}; + +# +# Detach a device. This can be called if the user is replacing the +# driver software or if a device is about to be physically removed +# from the system (e.g. for pccard devices). Returns 0 on success. +# +METHOD int detach { + device_t dev; +}; + +# +# This is called during system shutdown to allow the driver to put the +# hardware into a consistent state for rebooting the computer. +# +METHOD int shutdown { + device_t dev; +}; diff --git a/sys/kern/makedevops.sh b/sys/kern/makedevops.sh new file mode 100644 index 0000000..07b4ab0 --- /dev/null +++ b/sys/kern/makedevops.sh @@ -0,0 +1,232 @@ +#!/bin/sh - +# +# Copyright (c) 1992, 1993 +# The Regents of the University of California. 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. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. +# +# From @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93 +# $Id$ +# + +# Script to produce device front-end sugar. +# +# usage: makedevops.sh srcfile +# +# These awk scripts are not particularly well written, specifically they +# don't use arrays well and figure out the same information repeatedly. +# Please rewrite them if you actually understand how to use awk. Note, +# they use nawk extensions and gawk's toupper. + +if [ $# -ne 2 ] ; then + echo 'usage: makedevops.sh [-c|-h] srcfile' + exit 1 +fi + +makec=0 +makeh=0 + +if [ "$1" = "-c" ]; then + makec=1 +fi + +if [ "$1" = "-h" ]; then + makeh=1 +fi + +# Name of the source file. +SRC=$2 + +# Names of the created files. +CTMP=ctmp$$ +HTMP=htmp$$ + +CFILE=`basename $SRC .m`.c +HFILE=`basename $SRC .m`.h + +# Awk program (must support nawk extensions and gawk's "toupper") +# Use "awk" at Berkeley, "gawk" elsewhere. +AWK=awk + +# Awk script to take file.do and turn it into file.h and file.c +$AWK " + BEGIN { + src = \"$SRC\"; + header = \"$HTMP\"; + cfile = \"$CTMP\"; + hfile = \"$HFILE\"; + "' + + printf("/*\n") > header; + printf(" * This file is produced automatically.\n") > header; + printf(" * Do not modify anything in here by hand.\n") > header; + printf(" *\n") > header; + printf(" * Created from %s with makedevops.sh\n", src) > header; + printf(" */\n\n") > header; + + printf("/*\n") > cfile; + printf(" * This file is produced automatically.\n") > cfile; + printf(" * Do not modify anything in here by hand.\n") > cfile; + printf(" *\n") > cfile; + printf(" * Created from %s with makedevops.sh\n", src) > cfile; + printf(" */\n\n") > cfile; + printf("#include <sys/param.h>\n") > cfile; + printf("#include <sys/queue.h>\n") > cfile; + printf("#include <sys/bus_private.h>\n") > cfile; + + methodcount = 0 + } + NF == 0 { + next; + } + /^#include/ { + print $0 > cfile; + } + /^#/ { + next; + } + /^INTERFACE/ { + intname = $2; + printf("#ifndef _%s_if_h_\n", intname) > header; + printf("#define _%s_if_h_\n\n", intname) > header; + printf("#include \"%s\"\n\n", hfile) > cfile; + } + /^METHOD/ { + # Get the function name and return type. + ret = ""; + sep = ""; + for (i = 2; i < NF - 1; i++) { + ret = sep $i; + sep = " "; + } + name = $i; + + # Get the function arguments. + for (c1 = 0;; ++c1) { + if (getline <= 0) + exit + if ($0 ~ "^};") + break; + a[c1] = $0; + } + + methods[methodcount++] = name; + + mname = intname "_" name; + umname = toupper(mname); + + # Print out the method declaration + printf("extern struct device_op_desc %s_desc;\n", mname) > header; + printf("%s %s(", ret, umname) > header; + sep = ", "; + for (c2 = 0; c2 < c1; ++c2) { + if (c2 == c1 - 1) + sep = " );\n"; + c3 = split(a[c2], t); + for (c4 = 0; c4 < c3; ++c4) + printf("%s ", t[c4]) > header; + beg = match(t[c3], "[^*]"); + end = match(t[c3], ";"); + printf("%s%s%s", + substr(t[c4], 0, beg - 1), + substr(t[c4], beg, end - beg), sep) > header; + } + + # Print the method desc + printf("struct device_op_desc %s_desc = {\n", mname) > cfile; + printf("\t0,\n") > cfile; + printf("\t\"%s\"\n", name) > cfile; + printf("};\n\n") > cfile; + + # Print out the method typedef + printf("typedef %s %s_t(\n", ret, mname) > cfile; + sep = ",\n"; + for (c2 = 0; c2 < c1; ++c2) { + if (c2 == c1 - 1) + sep = ");\n"; + c3 = split(a[c2], t); + printf("\t") > cfile; + for (c4 = 0; c4 < c3; ++c4) + printf("%s ", t[c4]) > cfile; + beg = match(t[c3], "[^*]"); + end = match(t[c3], ";"); + printf("%s%s%s", + substr(t[c4], 0, beg - 1), + substr(t[c4], beg, end - beg), sep) > cfile; + } + + # Print out the method itself + printf("%s %s(\n", ret, umname) > cfile; + sep = ",\n"; + for (c2 = 0; c2 < c1; ++c2) { + if (c2 == c1 - 1) + sep = ")\n"; + c3 = split(a[c2], t); + printf("\t") > cfile; + for (c4 = 0; c4 < c3; ++c4) + printf("%s ", t[c4]) > cfile; + beg = match(t[c3], "[^*]"); + end = match(t[c3], ";"); + printf("%s%s%s", + substr(t[c4], 0, beg - 1), + substr(t[c4], beg, end - beg), sep) > cfile; + } + printf("{\n") > cfile; + printf("\t%s_t *m = (%s_t *) DEVOPMETH(dev, %s);\n", + mname, mname, mname) > cfile; + if (ret != "void") + printf("\treturn m(") > cfile; + else + printf("\tm(") > cfile; + sep = ", "; + for (c2 = 0; c2 < c1; ++c2) { + if (c2 == c1 - 1) + sep = ");\n"; + c3 = split(a[c2], t); + beg = match(t[c3], "[^*]"); + end = match(t[c3], ";"); + printf("%s%s", substr(t[c3], beg, end - beg), sep) > cfile; + } + printf("}\n\n") > cfile; + } + END { + printf("\n#endif /* _%s_if_h_ */\n", intname) > header; + }' < $SRC + +if [ $makec = 1 ]; then + mv $CTMP $CFILE +else + rm $CTMP +fi + +if [ $makeh = 1 ]; then + mv $HTMP $HFILE +else + rm $HTMP +fi |