summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-06-14 13:46:10 +0000
committerdfr <dfr@FreeBSD.org>1998-06-14 13:46:10 +0000
commitdc295ed278eb0235154462b23615e89213bc591c (patch)
tree0734d180ccb27bfdde5cd04d1961394e2e0ac94f /sys/dev
parenta7d3dec6df55d42bcb12806631798932380ce34b (diff)
downloadFreeBSD-src-dc295ed278eb0235154462b23615e89213bc591c.zip
FreeBSD-src-dc295ed278eb0235154462b23615e89213bc591c.tar.gz
Major changes to the generic device framework for FreeBSD/alpha:
* Eliminate bus_t and make it possible for all devices to have attached children. * Support dynamically extendable interfaces for drivers to replace both the function pointers in driver_t and bus_ops_t (which has been removed entirely. Two system defined interfaces have been defined, 'device' which is mandatory for all devices and 'bus' which is recommended for all devices which support attached children. * In addition, the alpha port defines two simple interfaces 'clock' for attaching various real time clocks to the system and 'mcclock' for the many different variations of mc146818 clocks which can be attached to different alpha platforms. This eliminates two more function pointer tables in favour of the generic method dispatch system provided by the device framework. Future device interfaces may include: * cdev and bdev interfaces for devfs to use in replacement for specfs and the fixed interfaces bdevsw and cdevsw. * scsi interface to replace struct scsi_adapter (not sure how this works in CAM but I imagine there is something similar there). * various tailored interfaces for different bus types such as pci, isa, pccard etc.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/dec/clockvar.h62
-rw-r--r--sys/dev/dec/mc146818reg.h26
-rw-r--r--sys/dev/dec/mcclock.c54
-rw-r--r--sys/dev/dec/mcclockvar.h16
-rw-r--r--sys/dev/mc146818/mc146818reg.h26
5 files changed, 36 insertions, 148 deletions
diff --git a/sys/dev/dec/clockvar.h b/sys/dev/dec/clockvar.h
deleted file mode 100644
index 920d162..0000000
--- a/sys/dev/dec/clockvar.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* $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) */
-};
-
-/*
- * clockfns structure:
- *
- * function switch used by chip-independent clock code, to access
- * chip-dependent routines.
- */
-struct clockfns {
- void (*cf_init) __P((struct device *));
- void (*cf_get) __P((struct device *, time_t, struct clocktime *));
- void (*cf_set) __P((struct device *, struct clocktime *));
-};
-
-void clockattach __P((device_t, const struct clockfns *));
diff --git a/sys/dev/dec/mc146818reg.h b/sys/dev/dec/mc146818reg.h
index 95c3ccf..18cc979 100644
--- a/sys/dev/dec/mc146818reg.h
+++ b/sys/dev/dec/mc146818reg.h
@@ -142,14 +142,6 @@
#define MC_BASE_NONE 0x60 /* actually, both of these reset */
#define MC_BASE_RESET 0x70
-
-/*
- * RTC register/NVRAM read and write functions -- machine-dependent.
- * Appropriately manipulate RTC registers to get/put data values.
- */
-u_int mc146818_read __P((void *sc, u_int reg));
-void mc146818_write __P((void *sc, u_int reg, u_int datum));
-
/*
* A collection of TOD/Alarm registers.
*/
@@ -159,36 +151,36 @@ typedef u_int mc_todregs[MC_NTODREGS];
* Get all of the TOD/Alarm registers
* Must be called at splhigh(), and with the RTC properly set up.
*/
-#define MC146818_GETTOD(sc, regs) \
+#define MC146818_GETTOD(dev, regs) \
do { \
int i; \
\
/* update in progress; spin loop */ \
- while (mc146818_read(sc, MC_REGA) & MC_REGA_UIP) \
+ while (MCCLOCK_READ(dev, MC_REGA) & MC_REGA_UIP) \
; \
\
/* read all of the tod/alarm regs */ \
for (i = 0; i < MC_NTODREGS; i++) \
- (*regs)[i] = mc146818_read(sc, i); \
+ (*regs)[i] = MCCLOCK_READ(dev, i); \
} while (0);
/*
* Set all of the TOD/Alarm registers
* Must be called at splhigh(), and with the RTC properly set up.
*/
-#define MC146818_PUTTOD(sc, regs) \
+#define MC146818_PUTTOD(dev, regs) \
do { \
int i; \
\
/* stop updates while setting */ \
- mc146818_write(sc, MC_REGB, \
- mc146818_read(sc, MC_REGB) | MC_REGB_SET); \
+ MCCLOCK_WRITE(dev, MC_REGB, \
+ MCCLOCK_READ(dev, MC_REGB) | MC_REGB_SET); \
\
/* write all of the tod/alarm regs */ \
for (i = 0; i < MC_NTODREGS; i++) \
- mc146818_write(sc, i, (*regs)[i]); \
+ MCCLOCK_WRITE(dev, i, (*regs)[i]); \
\
/* reenable updates */ \
- mc146818_write(sc, MC_REGB, \
- mc146818_read(sc, MC_REGB) & ~MC_REGB_SET); \
+ MCCLOCK_WRITE(dev, MC_REGB, \
+ MCCLOCK_READ(dev, MC_REGB) & ~MC_REGB_SET); \
} while (0);
diff --git a/sys/dev/dec/mcclock.c b/sys/dev/dec/mcclock.c
index 76e3805..3aada8b 100644
--- a/sys/dev/dec/mcclock.c
+++ b/sys/dev/dec/mcclock.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: mcclock.c,v 1.1 1998/06/10 10:56:23 dfr Exp $ */
/* $NetBSD: mcclock.c,v 1.11 1998/04/19 07:50:25 jonathan Exp $ */
/*
@@ -33,7 +33,7 @@
#include <sys/systm.h>
#include <sys/bus.h>
-#include <dev/dec/clockvar.h>
+#include <machine/clockvar.h>
#include <dev/dec/mcclockvar.h>
#include <dev/dec/mc146818reg.h>
@@ -47,41 +47,20 @@
#define MC_DEFAULTRATE MC_RATE_256_Hz
#endif
-
-void mcclock_init __P((struct device *));
-void mcclock_get __P((struct device *, time_t, struct clocktime *));
-void mcclock_set __P((struct device *, struct clocktime *));
-
-const struct clockfns mcclock_clockfns = {
- mcclock_init, mcclock_get, mcclock_set,
-};
-
-#define mc146818_write(dev, reg, datum) \
- (*(dev)->sc_busfns->mc_bf_write)(dev, reg, datum)
-#define mc146818_read(dev, reg) \
- (*(dev)->sc_busfns->mc_bf_read)(dev, reg)
-
void
-mcclock_attach(sc, busfns)
- struct mcclock_softc *sc;
- const struct mcclock_busfns *busfns;
+mcclock_attach(device_t dev)
{
- sc->sc_busfns = busfns;
-
/* Turn interrupts off, just in case. */
- mc146818_write(sc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
+ MCCLOCK_WRITE(dev, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
- clockattach(sc->sc_dev, &mcclock_clockfns);
+ clockattach(dev);
}
void
-mcclock_init(dev)
- device_t dev;
+mcclock_init(device_t dev)
{
- struct mcclock_softc *sc = device_get_softc(dev);
-
- mc146818_write(sc, MC_REGA, MC_BASE_32_KHz | MC_DEFAULTRATE);
- mc146818_write(sc, MC_REGB,
+ MCCLOCK_WRITE(dev, MC_REGA, MC_BASE_32_KHz | MC_DEFAULTRATE);
+ MCCLOCK_WRITE(dev, MC_REGB,
MC_REGB_PIE | MC_REGB_SQWE | MC_REGB_BINARY | MC_REGB_24HR);
}
@@ -89,17 +68,13 @@ mcclock_init(dev)
* Get the time of day, based on the clock's value and/or the base value.
*/
void
-mcclock_get(dev, base, ct)
- struct device *dev;
- time_t base;
- struct clocktime *ct;
+mcclock_get(device_t dev, time_t base, struct clocktime *ct)
{
- struct mcclock_softc *sc = device_get_softc(dev);
mc_todregs regs;
int s;
s = splclock();
- MC146818_GETTOD(sc, &regs)
+ MC146818_GETTOD(dev, &regs)
splx(s);
ct->sec = regs[MC_SEC];
@@ -115,16 +90,13 @@ mcclock_get(dev, base, ct)
* Reset the TODR based on the time value.
*/
void
-mcclock_set(dev, ct)
- struct device *dev;
- struct clocktime *ct;
+mcclock_set(device_t dev, struct clocktime *ct)
{
- struct mcclock_softc *sc = device_get_softc(dev);
mc_todregs regs;
int s;
s = splclock();
- MC146818_GETTOD(sc, &regs);
+ MC146818_GETTOD(dev, &regs);
splx(s);
regs[MC_SEC] = ct->sec;
@@ -136,6 +108,6 @@ mcclock_set(dev, ct)
regs[MC_YEAR] = ct->year;
s = splclock();
- MC146818_PUTTOD(sc, &regs);
+ MC146818_PUTTOD(dev, &regs);
splx(s);
}
diff --git a/sys/dev/dec/mcclockvar.h b/sys/dev/dec/mcclockvar.h
index d2c0ac8..0c9f5df 100644
--- a/sys/dev/dec/mcclockvar.h
+++ b/sys/dev/dec/mcclockvar.h
@@ -27,15 +27,9 @@
* rights to redistribute these changes.
*/
-struct mcclock_softc {
- device_t sc_dev;
- const struct mcclock_busfns *sc_busfns;
-};
+#include "mcclock_if.h"
-struct mcclock_busfns {
- void (*mc_bf_write) __P((struct mcclock_softc *, u_int, u_int));
- u_int (*mc_bf_read) __P((struct mcclock_softc *, u_int));
-};
-
-void mcclock_attach __P((struct mcclock_softc *,
- const struct mcclock_busfns *));
+void mcclock_attach(device_t dev);
+void mcclock_init(device_t);
+void mcclock_get(device_t, time_t, struct clocktime *);
+void mcclock_set(device_t, struct clocktime *);
diff --git a/sys/dev/mc146818/mc146818reg.h b/sys/dev/mc146818/mc146818reg.h
index 95c3ccf..18cc979 100644
--- a/sys/dev/mc146818/mc146818reg.h
+++ b/sys/dev/mc146818/mc146818reg.h
@@ -142,14 +142,6 @@
#define MC_BASE_NONE 0x60 /* actually, both of these reset */
#define MC_BASE_RESET 0x70
-
-/*
- * RTC register/NVRAM read and write functions -- machine-dependent.
- * Appropriately manipulate RTC registers to get/put data values.
- */
-u_int mc146818_read __P((void *sc, u_int reg));
-void mc146818_write __P((void *sc, u_int reg, u_int datum));
-
/*
* A collection of TOD/Alarm registers.
*/
@@ -159,36 +151,36 @@ typedef u_int mc_todregs[MC_NTODREGS];
* Get all of the TOD/Alarm registers
* Must be called at splhigh(), and with the RTC properly set up.
*/
-#define MC146818_GETTOD(sc, regs) \
+#define MC146818_GETTOD(dev, regs) \
do { \
int i; \
\
/* update in progress; spin loop */ \
- while (mc146818_read(sc, MC_REGA) & MC_REGA_UIP) \
+ while (MCCLOCK_READ(dev, MC_REGA) & MC_REGA_UIP) \
; \
\
/* read all of the tod/alarm regs */ \
for (i = 0; i < MC_NTODREGS; i++) \
- (*regs)[i] = mc146818_read(sc, i); \
+ (*regs)[i] = MCCLOCK_READ(dev, i); \
} while (0);
/*
* Set all of the TOD/Alarm registers
* Must be called at splhigh(), and with the RTC properly set up.
*/
-#define MC146818_PUTTOD(sc, regs) \
+#define MC146818_PUTTOD(dev, regs) \
do { \
int i; \
\
/* stop updates while setting */ \
- mc146818_write(sc, MC_REGB, \
- mc146818_read(sc, MC_REGB) | MC_REGB_SET); \
+ MCCLOCK_WRITE(dev, MC_REGB, \
+ MCCLOCK_READ(dev, MC_REGB) | MC_REGB_SET); \
\
/* write all of the tod/alarm regs */ \
for (i = 0; i < MC_NTODREGS; i++) \
- mc146818_write(sc, i, (*regs)[i]); \
+ MCCLOCK_WRITE(dev, i, (*regs)[i]); \
\
/* reenable updates */ \
- mc146818_write(sc, MC_REGB, \
- mc146818_read(sc, MC_REGB) & ~MC_REGB_SET); \
+ MCCLOCK_WRITE(dev, MC_REGB, \
+ MCCLOCK_READ(dev, MC_REGB) & ~MC_REGB_SET); \
} while (0);
OpenPOWER on IntegriCloud