Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | #ifndef lint | |
35 | static char sccsid[] = "@(#)mkubglue.c 5.3 (Berkeley) 4/19/91"; | |
36 | #endif /* not lint */ | |
37 | ||
38 | /* | |
39 | * Make the uba interrupt file ubglue.s | |
40 | */ | |
41 | #include <stdio.h> | |
42 | #include "config.h" | |
43 | #include "y.tab.h" | |
44 | ||
45 | ubglue() | |
46 | { | |
47 | register FILE *fp; | |
48 | register struct device *dp, *mp; | |
49 | ||
50 | fp = fopen(path("ubglue.s"), "w"); | |
51 | if (fp == 0) { | |
52 | perror(path("ubglue.s")); | |
53 | exit(1); | |
54 | } | |
55 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
56 | mp = dp->d_conn; | |
57 | if (mp != 0 && mp != (struct device *)-1 && | |
58 | !eq(mp->d_name, "mba")) { | |
59 | struct idlst *id, *id2; | |
60 | ||
61 | for (id = dp->d_vec; id; id = id->id_next) { | |
62 | for (id2 = dp->d_vec; id2; id2 = id2->id_next) { | |
63 | if (id2 == id) { | |
64 | dump_vec(fp, id->id, dp->d_unit); | |
65 | break; | |
66 | } | |
67 | if (!strcmp(id->id, id2->id)) | |
68 | break; | |
69 | } | |
70 | } | |
71 | } | |
72 | } | |
73 | dump_std(fp); | |
74 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
75 | mp = dp->d_conn; | |
76 | if (mp != 0 && mp != (struct device *)-1 && | |
77 | !eq(mp->d_name, "mba")) { | |
78 | struct idlst *id, *id2; | |
79 | ||
80 | for (id = dp->d_vec; id; id = id->id_next) { | |
81 | for (id2 = dp->d_vec; id2; id2 = id2->id_next) { | |
82 | if (id2 == id) { | |
83 | dump_intname(fp, id->id, | |
84 | dp->d_unit); | |
85 | break; | |
86 | } | |
87 | if (!strcmp(id->id, id2->id)) | |
88 | break; | |
89 | } | |
90 | } | |
91 | } | |
92 | } | |
93 | dump_ctrs(fp); | |
94 | (void) fclose(fp); | |
95 | } | |
96 | ||
97 | static int cntcnt = 0; /* number of interrupt counters allocated */ | |
98 | ||
99 | /* | |
100 | * print an interrupt vector | |
101 | */ | |
102 | dump_vec(fp, vector, number) | |
103 | register FILE *fp; | |
104 | char *vector; | |
105 | int number; | |
106 | { | |
107 | char nbuf[80]; | |
108 | register char *v = nbuf; | |
109 | ||
110 | (void) sprintf(v, "%s%d", vector, number); | |
111 | fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", | |
112 | v, v); | |
113 | fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); | |
114 | if (strncmp(vector, "dzx", 3) == 0) | |
115 | fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); | |
116 | else if (strncmp(vector, "dpx", 3) == 0) | |
117 | fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number); | |
118 | else if (strncmp(vector, "dpr", 3) == 0) | |
119 | fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number); | |
120 | else { | |
121 | if (strncmp(vector, "uur", 3) == 0) { | |
122 | fprintf(fp, "#ifdef UUDMA\n"); | |
123 | fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); | |
124 | fprintf(fp, "#endif\n"); | |
125 | } | |
126 | fprintf(fp, "\tpushl\t$%d\n", number); | |
127 | fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); | |
128 | fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); | |
129 | } | |
130 | } | |
131 | ||
132 | /* | |
133 | * Start the interrupt name table with the names | |
134 | * of the standard vectors not on the unibus. | |
135 | * The number and order of these names should correspond | |
136 | * with the definitions in scb.s. | |
137 | */ | |
138 | dump_std(fp) | |
139 | register FILE *fp; | |
140 | { | |
141 | fprintf(fp, "\n\t.globl\t_intrnames\n"); | |
142 | fprintf(fp, "\n\t.globl\t_eintrnames\n"); | |
143 | fprintf(fp, "\t.data\n"); | |
144 | fprintf(fp, "_intrnames:\n"); | |
145 | fprintf(fp, "\t.asciz\t\"clock\"\n"); | |
146 | fprintf(fp, "\t.asciz\t\"cnr\"\n"); | |
147 | fprintf(fp, "\t.asciz\t\"cnx\"\n"); | |
148 | fprintf(fp, "\t.asciz\t\"tur\"\n"); | |
149 | fprintf(fp, "\t.asciz\t\"tux\"\n"); | |
150 | fprintf(fp, "\t.asciz\t\"mba0\"\n"); | |
151 | fprintf(fp, "\t.asciz\t\"mba1\"\n"); | |
152 | fprintf(fp, "\t.asciz\t\"mba2\"\n"); | |
153 | fprintf(fp, "\t.asciz\t\"mba3\"\n"); | |
154 | fprintf(fp, "\t.asciz\t\"uba0\"\n"); | |
155 | fprintf(fp, "\t.asciz\t\"uba1\"\n"); | |
156 | fprintf(fp, "\t.asciz\t\"uba2\"\n"); | |
157 | fprintf(fp, "\t.asciz\t\"uba3\"\n"); | |
158 | #define I_FIXED 13 /* number of names above */ | |
159 | } | |
160 | ||
161 | dump_intname(fp, vector, number) | |
162 | register FILE *fp; | |
163 | char *vector; | |
164 | int number; | |
165 | { | |
166 | register char *cp = vector; | |
167 | ||
168 | fprintf(fp, "\t.asciz\t\""); | |
169 | /* | |
170 | * Skip any "int" or "intr" in the name. | |
171 | */ | |
172 | while (*cp) | |
173 | if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { | |
174 | cp += 3; | |
175 | if (*cp == 'r') | |
176 | cp++; | |
177 | } else { | |
178 | putc(*cp, fp); | |
179 | cp++; | |
180 | } | |
181 | fprintf(fp, "%d\"\n", number); | |
182 | } | |
183 | ||
184 | dump_ctrs(fp) | |
185 | register FILE *fp; | |
186 | { | |
187 | fprintf(fp, "_eintrnames:\n"); | |
188 | fprintf(fp, "\n\t.globl\t_intrcnt\n"); | |
189 | fprintf(fp, "\n\t.globl\t_eintrcnt\n"); | |
190 | fprintf(fp, "_intrcnt:\n", I_FIXED); | |
191 | fprintf(fp, "\t.space\t4 * %d\n", I_FIXED); | |
192 | fprintf(fp, "_fltintrcnt:\n", cntcnt); | |
193 | fprintf(fp, "\t.space\t4 * %d\n", cntcnt); | |
194 | fprintf(fp, "_eintrcnt:\n\n"); | |
195 | fprintf(fp, "\t.text\n"); | |
196 | } |