Annotation of sys/arch/vax/vax/sbi.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: sbi.c,v 1.12 2006/07/24 17:25:11 miod Exp $ */
2: /* $NetBSD: sbi.c,v 1.20 1999/08/07 10:36:50 ragge Exp $ */
3: /*
4: * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
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: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed at Ludd, University of Lule}.
18: * 4. The name of the author may not be used to endorse or promote products
19: * derived from this software without specific prior written permission
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31: */
32:
33: /*
34: * Still to do: Write all SBI error handling.
35: */
36:
37: #include <sys/types.h>
38: #include <sys/param.h>
39: #include <sys/device.h>
40: #include <sys/systm.h>
41:
42: #include <machine/sid.h>
43: #include <machine/cpu.h>
44: #include <machine/nexus.h>
45:
46: static int sbi_print(void *, const char *);
47: static int sbi_match_abus(struct device *, struct cfdata *, void *);
48: static int sbi_match_mainbus(struct device *, struct cfdata *, void *);
49: static void sbi_attach(struct device *, struct device *, void *);
50:
51: struct cfdriver sbi_cd = {
52: NULL, "sbi", DV_DULL
53: };
54:
55: int
56: sbi_print(aux, name)
57: void *aux;
58: const char *name;
59: {
60: struct sbi_attach_args *sa = (struct sbi_attach_args *)aux;
61: int unsupp = 0;
62:
63: if (name) {
64: switch (sa->type) {
65: case NEX_MBA:
66: printf("mba at %s", name);
67: break;
68: default:
69: printf("unknown device 0x%x at %s", sa->type, name);
70: unsupp++;
71: }
72: }
73: printf(" tr%d", sa->nexnum);
74: return (unsupp ? UNSUPP : UNCONF);
75: }
76:
77: int
78: sbi_match_mainbus(parent, cf, aux)
79: struct device *parent;
80: struct cfdata *cf;
81: void *aux;
82: {
83: struct mainbus_attach_args *maa = aux;
84:
85: if (maa->maa_bustype == VAX_SBIBUS)
86: return 1;
87: return 0;
88: }
89:
90: int
91: sbi_match_abus(parent, cf, aux)
92: struct device *parent;
93: struct cfdata *cf;
94: void *aux;
95: {
96: struct bp_conf *bp = aux;
97:
98: if (strcmp(bp->type, sbi_cd.cd_name) == 0)
99: return 1;
100:
101: return 0;
102: }
103:
104: void
105: sbi_attach(parent, self, aux)
106: struct device *parent, *self;
107: void *aux;
108: {
109: u_int nexnum, minnex;
110: struct sbi_attach_args sa;
111:
112: printf("\n");
113:
114: #define NEXPAGES (sizeof(struct nexus) / VAX_NBPG)
115: minnex = self->dv_unit * NNEXSBI;
116: for (nexnum = minnex; nexnum < minnex + NNEXSBI; nexnum++) {
117: struct nexus *nexusP = 0;
118: volatile int tmp;
119:
120: nexusP = (struct nexus *)vax_map_physmem((paddr_t)NEXA8600 +
121: sizeof(struct nexus) * nexnum, NEXPAGES);
122: if (badaddr((caddr_t)nexusP, 4)) {
123: vax_unmap_physmem((vaddr_t)nexusP, NEXPAGES);
124: } else {
125: tmp = nexusP->nexcsr.nex_csr; /* no byte reads */
126: sa.type = tmp & 255;
127:
128: sa.nexnum = nexnum;
129: sa.nexaddr = nexusP;
130: config_found(self, (void *)&sa, sbi_print);
131: }
132: }
133: }
134:
135: struct cfattach sbi_mainbus_ca = {
136: sizeof(struct device), sbi_match_mainbus, sbi_attach
137: };
138:
139: struct cfattach sbi_abus_ca = {
140: sizeof(struct device), sbi_match_abus, sbi_attach
141: };
CVSweb