Commit | Line | Data |
---|---|---|
cd68466f DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
524aa063 | 7 | #ifndef lint |
cd68466f DF |
8 | static char sccsid[] = "@(#)mkubglue.c 5.1 (Berkeley) %G%"; |
9 | #endif not lint | |
ba6a61e0 | 10 | |
e1f7f2fb MT |
11 | /* |
12 | * Make the uba interrupt file ubglue.s | |
13 | */ | |
14 | #include <stdio.h> | |
15 | #include "config.h" | |
16 | #include "y.tab.h" | |
17 | ||
18 | ubglue() | |
19 | { | |
22d68ad0 BJ |
20 | register FILE *fp; |
21 | register struct device *dp, *mp; | |
e1f7f2fb | 22 | |
22d68ad0 BJ |
23 | fp = fopen(path("ubglue.s"), "w"); |
24 | if (fp == 0) { | |
25 | perror(path("ubglue.s")); | |
26 | exit(1); | |
27 | } | |
28 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
29 | mp = dp->d_conn; | |
30 | if (mp != 0 && mp != (struct device *)-1 && | |
31 | !eq(mp->d_name, "mba")) { | |
32 | struct idlst *id, *id2; | |
33 | ||
34 | for (id = dp->d_vec; id; id = id->id_next) { | |
35 | for (id2 = dp->d_vec; id2; id2 = id2->id_next) { | |
36 | if (id2 == id) { | |
37 | dump_vec(fp, id->id, dp->d_unit); | |
38 | break; | |
39 | } | |
40 | if (!strcmp(id->id, id2->id)) | |
41 | break; | |
42 | } | |
43 | } | |
08f9a943 | 44 | } |
e1f7f2fb | 45 | } |
64cfcf9e MK |
46 | dump_std(fp); |
47 | for (dp = dtab; dp != 0; dp = dp->d_next) { | |
48 | mp = dp->d_conn; | |
49 | if (mp != 0 && mp != (struct device *)-1 && | |
50 | !eq(mp->d_name, "mba")) { | |
51 | struct idlst *id, *id2; | |
52 | ||
53 | for (id = dp->d_vec; id; id = id->id_next) { | |
54 | for (id2 = dp->d_vec; id2; id2 = id2->id_next) { | |
55 | if (id2 == id) { | |
56 | dump_intname(fp, id->id, | |
57 | dp->d_unit); | |
58 | break; | |
59 | } | |
60 | if (!strcmp(id->id, id2->id)) | |
61 | break; | |
62 | } | |
63 | } | |
64 | } | |
65 | } | |
66 | dump_ctrs(fp); | |
22d68ad0 | 67 | (void) fclose(fp); |
e1f7f2fb MT |
68 | } |
69 | ||
64cfcf9e MK |
70 | static int cntcnt = 0; /* number of interrupt counters allocated */ |
71 | ||
e1f7f2fb | 72 | /* |
22d68ad0 | 73 | * print an interrupt vector |
e1f7f2fb | 74 | */ |
e1f7f2fb | 75 | dump_vec(fp, vector, number) |
22d68ad0 BJ |
76 | register FILE *fp; |
77 | char *vector; | |
78 | int number; | |
e1f7f2fb | 79 | { |
22d68ad0 BJ |
80 | char nbuf[80]; |
81 | register char *v = nbuf; | |
e1f7f2fb | 82 | |
22d68ad0 BJ |
83 | (void) sprintf(v, "%s%d", vector, number); |
84 | fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", | |
85 | v, v); | |
64cfcf9e | 86 | fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); |
22d68ad0 | 87 | if (strncmp(vector, "dzx", 3) == 0) |
a71ca461 | 88 | fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); |
22d68ad0 | 89 | else { |
a71ca461 SL |
90 | if (strncmp(vector, "uur", 3) == 0) { |
91 | fprintf(fp, "#ifdef UUDMA\n"); | |
92 | fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); | |
93 | fprintf(fp, "#endif\n"); | |
94 | } | |
dde2b2cb | 95 | fprintf(fp, "\tpushl\t$%d\n", number); |
c1531e50 | 96 | fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); |
c9f74970 | 97 | fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); |
22d68ad0 | 98 | } |
e1f7f2fb | 99 | } |
64cfcf9e MK |
100 | |
101 | /* | |
102 | * Start the interrupt name table with the names | |
103 | * of the standard vectors not on the unibus. | |
104 | * The number and order of these names should correspond | |
105 | * with the definitions in scb.s. | |
106 | */ | |
107 | dump_std(fp) | |
108 | register FILE *fp; | |
109 | { | |
110 | fprintf(fp, "\n\t.globl\t_intrnames\n"); | |
111 | fprintf(fp, "\n\t.globl\t_eintrnames\n"); | |
112 | fprintf(fp, "\t.data\n"); | |
113 | fprintf(fp, "_intrnames:\n"); | |
114 | fprintf(fp, "\t.asciz\t\"clock\"\n"); | |
115 | fprintf(fp, "\t.asciz\t\"cnr\"\n"); | |
116 | fprintf(fp, "\t.asciz\t\"cnx\"\n"); | |
117 | fprintf(fp, "\t.asciz\t\"tur\"\n"); | |
118 | fprintf(fp, "\t.asciz\t\"tux\"\n"); | |
119 | fprintf(fp, "\t.asciz\t\"mba0\"\n"); | |
120 | fprintf(fp, "\t.asciz\t\"mba1\"\n"); | |
121 | fprintf(fp, "\t.asciz\t\"mba2\"\n"); | |
122 | fprintf(fp, "\t.asciz\t\"mba3\"\n"); | |
123 | fprintf(fp, "\t.asciz\t\"uba0\"\n"); | |
124 | fprintf(fp, "\t.asciz\t\"uba1\"\n"); | |
125 | fprintf(fp, "\t.asciz\t\"uba2\"\n"); | |
126 | fprintf(fp, "\t.asciz\t\"uba3\"\n"); | |
127 | #define I_FIXED 13 /* number of names above */ | |
128 | } | |
129 | ||
130 | dump_intname(fp, vector, number) | |
131 | register FILE *fp; | |
132 | char *vector; | |
133 | int number; | |
134 | { | |
135 | register char *cp = vector; | |
136 | ||
137 | fprintf(fp, "\t.asciz\t\""); | |
138 | /* | |
139 | * Skip any "int" or "intr" in the name. | |
140 | */ | |
141 | while (*cp) | |
142 | if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { | |
143 | cp += 3; | |
144 | if (*cp == 'r') | |
145 | cp++; | |
146 | } else { | |
147 | putc(*cp, fp); | |
148 | cp++; | |
149 | } | |
150 | fprintf(fp, "%d\"\n", number); | |
151 | } | |
152 | ||
153 | dump_ctrs(fp) | |
154 | register FILE *fp; | |
155 | { | |
156 | fprintf(fp, "_eintrnames:\n"); | |
157 | fprintf(fp, "\n\t.globl\t_intrcnt\n"); | |
158 | fprintf(fp, "\n\t.globl\t_eintrcnt\n"); | |
159 | fprintf(fp, "_intrcnt:\n", I_FIXED); | |
160 | fprintf(fp, "\t.space\t4 * %d\n", I_FIXED); | |
161 | fprintf(fp, "_fltintrcnt:\n", cntcnt); | |
162 | fprintf(fp, "\t.space\t4 * %d\n", cntcnt); | |
163 | fprintf(fp, "_eintrcnt:\n\n"); | |
164 | fprintf(fp, "\t.text\n"); | |
165 | } |