Annotation of sys/arch/mac68k/dev/obio.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: obio.c,v 1.6 2005/12/21 18:52:28 miod Exp $ */
2: /* $NetBSD: obio.c,v 1.7 1997/02/13 19:01:07 scottr Exp $ */
3:
4: /*
5: * Copyright (c) 1996 The NetBSD Foundation, Inc.
6: * All rights reserved.
7: *
8: * This code is derived from software contributed to the NetBSD Foundation
9: * by Jason R. Thorpe.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: * 3. All advertising materials mentioning features or use of this software
20: * must display the following acknowledgement:
21: * This product includes software developed by the NetBSD
22: * Foundation, Inc. and its contributors.
23: * 4. Neither the name of The NetBSD Foundation nor the names of its
24: * contributors may be used to endorse or promote products derived
25: * from this software without specific prior written permission.
26: *
27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
31: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37: * POSSIBILITY OF SUCH DAMAGE.
38: */
39:
40: #include <sys/param.h>
41: #include <sys/systm.h>
42: #include <sys/device.h>
43:
44: #include <machine/bus.h>
45:
46: #include <mac68k/dev/obiovar.h>
47:
48: static int obio_match(struct device *, void *, void *);
49: static void obio_attach(struct device *, struct device *, void *);
50: static int obio_print(void *, const char *);
51: static int obio_search(struct device *, void *, void *);
52:
53: struct cfattach obio_ca = {
54: sizeof(struct device), obio_match, obio_attach
55: };
56:
57: struct cfdriver obio_cd = {
58: NULL, "obio", DV_DULL
59: };
60:
61: static int
62: obio_match(parent, vcf, aux)
63: struct device *parent;
64: void *vcf;
65: void *aux;
66: {
67: static int obio_matched = 0;
68:
69: /* Allow only one instance. */
70: if (obio_matched)
71: return (0);
72:
73: obio_matched = 1;
74: return (1);
75: }
76:
77: static void
78: obio_attach(parent, self, aux)
79: struct device *parent;
80: struct device *self;
81: void *aux;
82: {
83: printf("\n");
84:
85: /* Search for and attach children. */
86: (void)config_search(obio_search, self, aux);
87: }
88:
89: int
90: obio_print(args, name)
91: void *args;
92: const char *name;
93: {
94: struct obio_attach_args *oa = (struct obio_attach_args *)args;
95:
96: if (oa->oa_addr != (-1))
97: printf(" addr %x", oa->oa_addr);
98:
99: return (UNCONF);
100: }
101:
102: int
103: obio_search(parent, vcf, aux)
104: struct device *parent;
105: void *vcf;
106: void *aux;
107: {
108: struct obio_attach_args oa;
109: struct cfdata *cf = (struct cfdata *) vcf;
110:
111: oa.oa_addr = cf->cf_loc[0];
112: oa.oa_tag = MAC68K_BUS_SPACE_MEM;
113:
114: if ((*cf->cf_attach->ca_match)(parent, cf, &oa) > 0)
115: config_attach(parent, cf, &oa, obio_print);
116:
117: return (0);
118: }
CVSweb