Sun Jan 4 00:36:01 2009 UTC ()
device_t/softc split for unixbp(4)


(bjh21)
diff -r1.5 -r1.6 src/sys/arch/acorn26/podulebus/unixbp.c
diff -r1.2 -r1.3 src/sys/arch/acorn26/podulebus/unixbpvar.h

cvs diff -r1.5 -r1.6 src/sys/arch/acorn26/podulebus/Attic/unixbp.c (expand / switch to unified diff)

--- src/sys/arch/acorn26/podulebus/Attic/unixbp.c 2002/10/02 03:25:47 1.5
+++ src/sys/arch/acorn26/podulebus/Attic/unixbp.c 2009/01/04 00:36:00 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: unixbp.c,v 1.5 2002/10/02 03:25:47 thorpej Exp $ */ 1/* $NetBSD: unixbp.c,v 1.6 2009/01/04 00:36:00 bjh21 Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 Ben Harris 4 * Copyright (c) 2000 Ben Harris
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,86 +22,87 @@ @@ -22,86 +22,87 @@
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29/* 29/*
30 * unixbp.c - driver for the Unix Backplane, found in the R140 etc  30 * unixbp.c - driver for the Unix Backplane, found in the R140 etc
31 */ 31 */
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34 34
35__KERNEL_RCSID(0, "$NetBSD: unixbp.c,v 1.5 2002/10/02 03:25:47 thorpej Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: unixbp.c,v 1.6 2009/01/04 00:36:00 bjh21 Exp $");
36 36
37#include <sys/device.h> 37#include <sys/device.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <machine/bus.h> 39#include <machine/bus.h>
40#include <arch/acorn26/iobus/iocvar.h> 40#include <arch/acorn26/iobus/iocvar.h>
41#include <arch/acorn26/podulebus/unixbpreg.h> 41#include <arch/acorn26/podulebus/unixbpreg.h>
42#include <arch/acorn26/podulebus/unixbpvar.h> 42#include <arch/acorn26/podulebus/unixbpvar.h>
43 43
44struct unixbp_softc { 44struct unixbp_softc {
45 struct device sc_dev; 45 device_t sc_dev;
46 bus_space_tag_t sc_iot; 46 bus_space_tag_t sc_iot;
47 bus_space_handle_t sc_ioh; 47 bus_space_handle_t sc_ioh;
48}; 48};
49 49
50static int unixbp_match(struct device *, struct cfdata *, void *); 50static int unixbp_match(device_t, cfdata_t, void *);
51static void unixbp_attach(struct device *, struct device *, void *); 51static void unixbp_attach(device_t, device_t, void *);
52 52
53CFATTACH_DECL(unixbp, sizeof(struct unixbp_softc), 53CFATTACH_DECL_NEW(unixbp, sizeof(struct unixbp_softc),
54 unixbp_match, unixbp_attach, NULL, NULL); 54 unixbp_match, unixbp_attach, NULL, NULL);
55 55
56struct device *the_unixbp; 56device_t the_unixbp;
57 57
58static int 58static int
59unixbp_match(struct device *parent, struct cfdata *cf, void *aux) 59unixbp_match(device_t parent, cfdata_t cf, void *aux)
60{ 60{
61 struct ioc_attach_args *ioc = aux; 61 struct ioc_attach_args *ioc = aux;
62 bus_space_tag_t bst = ioc->ioc_fast_t; 62 bus_space_tag_t bst = ioc->ioc_fast_t;
63 bus_space_handle_t bsh = ioc->ioc_fast_h; 63 bus_space_handle_t bsh = ioc->ioc_fast_h;
64 64
65 /* Ask to disable all interrupts and check the request lines go low. */ 65 /* Ask to disable all interrupts and check the request lines go low. */
66 bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0); 66 bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0);
67 if ((bus_space_read_1(bst, bsh, UNIXBP_REG_REQUEST) & 0xf) != 0) 67 if ((bus_space_read_1(bst, bsh, UNIXBP_REG_REQUEST) & 0xf) != 0)
68 return 0; 68 return 0;
69 /* Re-enable interrupts. */ 69 /* Re-enable interrupts. */
70 bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0xf); 70 bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0xf);
71 return 1; 71 return 1;
72} 72}
73 73
74static void 74static void
75unixbp_attach(struct device *parent, struct device *self, void *aux) 75unixbp_attach(device_t parent, device_t self, void *aux)
76{ 76{
77 struct ioc_attach_args *ioc = aux; 77 struct ioc_attach_args *ioc = aux;
78 struct unixbp_softc *sc = (void *)self; 78 struct unixbp_softc *sc = device_private(self);
79 79
 80 sc->sc_dev = self;
80 if (the_unixbp == NULL) 81 if (the_unixbp == NULL)
81 the_unixbp = self; 82 the_unixbp = self;
82 sc->sc_iot = ioc->ioc_fast_t; 83 sc->sc_iot = ioc->ioc_fast_t;
83 sc->sc_ioh = ioc->ioc_fast_h; 84 sc->sc_ioh = ioc->ioc_fast_h;
84 85
85 printf("\n"); 86 aprint_normal("\n");
86} 87}
87 88
88int 89int
89unixbp_irq_status_full() 90unixbp_irq_status_full()
90{ 91{
91 struct unixbp_softc *sc = (void *)the_unixbp; 92 struct unixbp_softc *sc = device_private(the_unixbp);
92 93
93 if (sc == NULL) 94 if (sc == NULL)
94 return 0; 95 return 0;
95 return bus_space_read_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_REQUEST) 96 return bus_space_read_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_REQUEST)
96 & 0xf; 97 & 0xf;
97} 98}
98 99
99void 100void
100unixbp_irq_setmask(int mask) 101unixbp_irq_setmask(int mask)
101{ 102{
102 struct unixbp_softc *sc = (void *)the_unixbp; 103 struct unixbp_softc *sc = device_private(the_unixbp);
103 104
104 if (sc == NULL) 105 if (sc == NULL)
105 return; 106 return;
106 bus_space_write_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_MASK, mask & 0xf); 107 bus_space_write_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_MASK, mask & 0xf);
107} 108}

cvs diff -r1.2 -r1.3 src/sys/arch/acorn26/podulebus/Attic/unixbpvar.h (expand / switch to unified diff)

--- src/sys/arch/acorn26/podulebus/Attic/unixbpvar.h 2002/03/24 23:37:45 1.2
+++ src/sys/arch/acorn26/podulebus/Attic/unixbpvar.h 2009/01/04 00:36:00 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: unixbpvar.h,v 1.2 2002/03/24 23:37:45 bjh21 Exp $ */ 1/* $NetBSD: unixbpvar.h,v 1.3 2009/01/04 00:36:00 bjh21 Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 Ben Harris 4 * Copyright (c) 2000 Ben Harris
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -26,16 +26,16 @@ @@ -26,16 +26,16 @@
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29/* 29/*
30 * Unix Backplane interface 30 * Unix Backplane interface
31 */ 31 */
32 32
33#ifndef _UNIXBP_H 33#ifndef _UNIXBP_H
34#define _UNIXBP_H 34#define _UNIXBP_H
35 35
36extern int unixbp_irq_status_full(void); 36extern int unixbp_irq_status_full(void);
37extern void unixbp_irq_setmask(int); 37extern void unixbp_irq_setmask(int);
38 38
39extern struct device *the_unixbp; 39device_t the_unixbp;
40 40
41#endif 41#endif