Annotation of sys/arch/mvme88k/dev/vmes.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: vmes.c,v 1.19 2005/11/25 22:14:32 miod Exp $ */
2:
3: /*
4: * Copyright (c) 1995 Theo de Raadt
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26: */
27:
28: #include <sys/param.h>
29: #include <sys/proc.h>
30: #include <sys/user.h>
31: #include <sys/systm.h>
32: #include <sys/kernel.h>
33: #include <sys/device.h>
34:
35: #include <machine/bus.h>
36: #include <machine/autoconf.h>
37: #include <machine/conf.h>
38: #include <machine/cpu.h>
39:
40: #include <mvme88k/dev/vme.h>
41:
42: /*
43: * The VMES driver deals with D16 transfers on the VME bus. The number
44: * of address bits (A16, A24, A32) is irrelevant since the mapping
45: * functions will decide how many address bits are relevant.
46: */
47:
48: void vmesattach(struct device *, struct device *, void *);
49: int vmesmatch(struct device *, void *, void *);
50: int vmesscan(struct device *, void *, void *);
51:
52: struct cfattach vmes_ca = {
53: sizeof(struct device), vmesmatch, vmesattach
54: };
55:
56: struct cfdriver vmes_cd = {
57: NULL, "vmes", DV_DULL
58: };
59:
60: /*
61: * Configuration glue
62: */
63:
64: int
65: vmesmatch(parent, cf, args)
66: struct device *parent;
67: void *cf, *args;
68: {
69: return (1);
70: }
71:
72: int
73: vmesscan(parent, child, args)
74: struct device *parent;
75: void *child, *args;
76: {
77: return (vmescan(parent, child, args, BUS_VMES));
78: }
79:
80: void
81: vmesattach(parent, self, args)
82: struct device *parent, *self;
83: void *args;
84: {
85: printf("\n");
86:
87: config_search(vmesscan, self, args);
88: }
89:
90: /*ARGSUSED*/
91: int
92: vmesopen(dev, flag, mode, p)
93: dev_t dev;
94: int flag, mode;
95: struct proc *p;
96: {
97: if (minor(dev) >= vmes_cd.cd_ndevs ||
98: vmes_cd.cd_devs[minor(dev)] == NULL)
99: return (ENODEV);
100: return (0);
101: }
102:
103: /*ARGSUSED*/
104: int
105: vmesclose(dev, flag, mode, p)
106: dev_t dev;
107: int flag, mode;
108: struct proc *p;
109: {
110:
111: return (0);
112: }
113:
114: /*ARGSUSED*/
115: int
116: vmesioctl(dev, cmd, data, flag, p)
117: dev_t dev;
118: u_long cmd;
119: caddr_t data;
120: int flag;
121: struct proc *p;
122: {
123: int error = 0;
124:
125: switch (cmd) {
126: default:
127: error = ENOTTY;
128: break;
129: }
130: return (error);
131: }
132:
133: int
134: vmesread(dev, uio, flags)
135: dev_t dev;
136: struct uio *uio;
137: int flags;
138: {
139: int unit = minor(dev);
140: struct device *sc = (struct device *)vmes_cd.cd_devs[unit];
141:
142: return (vmerw(sc->dv_parent, uio, flags, BUS_VMES));
143: }
144:
145: int
146: vmeswrite(dev, uio, flags)
147: dev_t dev;
148: struct uio *uio;
149: int flags;
150: {
151: int unit = minor(dev);
152: struct device *sc = (struct device *)vmes_cd.cd_devs[unit];
153:
154: return (vmerw(sc->dv_parent, uio, flags, BUS_VMES));
155: }
156:
157: paddr_t
158: vmesmmap(dev, off, prot)
159: dev_t dev;
160: off_t off;
161: int prot;
162: {
163: int unit = minor(dev);
164: struct device *sc = (struct device *)vmes_cd.cd_devs[unit];
165: paddr_t pa;
166:
167: pa = vmepmap(sc->dv_parent, off, BUS_VMES);
168: #ifdef DEBUG
169: printf("vmes %llx pa %p\n", off, pa);
170: #endif
171: if (pa == NULL)
172: return (-1);
173: return (atop(pa));
174: }
CVSweb