1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)mkglue.c 5.7 (Berkeley) 05/16/90"; 20 #endif /* not lint */ 21 22 /* 23 * Make the bus adaptor interrupt glue files. 24 */ 25 #include <stdio.h> 26 #include "config.h" 27 #include "y.tab.h" 28 #include <ctype.h> 29 30 /* 31 * Create the UNIBUS interrupt vector glue file. 32 */ 33 ubglue() 34 { 35 register FILE *fp, *gp; 36 register struct device *dp, *mp; 37 38 fp = fopen(path("ubglue.s"), "w"); 39 if (fp == 0) { 40 perror(path("ubglue.s")); 41 exit(1); 42 } 43 gp = fopen(path("ubvec.s"), "w"); 44 if (gp == 0) { 45 perror(path("ubvec.s")); 46 exit(1); 47 } 48 for (dp = dtab; dp != 0; dp = dp->d_next) { 49 mp = dp->d_conn; 50 if (mp != 0 && mp != (struct device *)-1 && 51 !eq(mp->d_name, "mba")) { 52 struct idlst *id, *id2; 53 54 for (id = dp->d_vec; id; id = id->id_next) { 55 for (id2 = dp->d_vec; id2; id2 = id2->id_next) { 56 if (id2 == id) { 57 dump_ubavec(fp, id->id, 58 dp->d_unit); 59 break; 60 } 61 if (!strcmp(id->id, id2->id)) 62 break; 63 } 64 } 65 } 66 } 67 dump_std(fp, gp); 68 for (dp = dtab; dp != 0; dp = dp->d_next) { 69 mp = dp->d_conn; 70 if (mp != 0 && mp != (struct device *)-1 && 71 !eq(mp->d_name, "mba")) { 72 struct idlst *id, *id2; 73 74 for (id = dp->d_vec; id; id = id->id_next) { 75 for (id2 = dp->d_vec; id2; id2 = id2->id_next) { 76 if (id2 == id) { 77 dump_intname(fp, id->id, 78 dp->d_unit); 79 break; 80 } 81 if (!strcmp(id->id, id2->id)) 82 break; 83 } 84 } 85 } 86 } 87 dump_ctrs(fp); 88 (void) fclose(fp); 89 (void) fclose(gp); 90 } 91 92 static int cntcnt = 0; /* number of interrupt counters allocated */ 93 94 /* 95 * Print a UNIBUS interrupt vector. 96 */ 97 dump_ubavec(fp, vector, number) 98 register FILE *fp; 99 char *vector; 100 int number; 101 { 102 char nbuf[80]; 103 register char *v = nbuf; 104 105 (void) sprintf(v, "%s%d", vector, number); 106 fprintf(fp, "\t.globl\t_X%s\n\t.align\t2\n_X%s:\n\tpushr\t$0x3f\n", 107 v, v); 108 fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); 109 if (strncmp(vector, "dzx", 3) == 0) 110 fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number); 111 else { 112 if (strncmp(vector, "uur", 3) == 0) { 113 fprintf(fp, "#ifdef UUDMA\n"); 114 fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number); 115 fprintf(fp, "#endif\n"); 116 } 117 fprintf(fp, "\tpushl\t$%d\n", number); 118 fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector); 119 fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n"); 120 } 121 } 122 123 /* 124 * Create the VERSAbus interrupt vector glue file. 125 */ 126 vbglue() 127 { 128 register FILE *fp, *gp; 129 register struct device *dp, *mp; 130 131 fp = fopen(path("vbglue.s"), "w"); 132 if (fp == 0) { 133 perror(path("vbglue.s")); 134 exit(1); 135 } 136 gp = fopen(path("vbvec.s"), "w"); 137 if (gp == 0) { 138 perror(path("vbvec.s")); 139 exit(1); 140 } 141 for (dp = dtab; dp != 0; dp = dp->d_next) { 142 struct idlst *id, *id2; 143 144 mp = dp->d_conn; 145 if (mp == 0 || mp == (struct device *)-1 || 146 eq(mp->d_name, "mba")) 147 continue; 148 for (id = dp->d_vec; id; id = id->id_next) 149 for (id2 = dp->d_vec; id2; id2 = id2->id_next) { 150 if (id == id2) { 151 dump_vbavec(fp, id->id, dp->d_unit); 152 break; 153 } 154 if (eq(id->id, id2->id)) 155 break; 156 } 157 } 158 dump_std(fp, gp); 159 for (dp = dtab; dp != 0; dp = dp->d_next) { 160 mp = dp->d_conn; 161 if (mp != 0 && mp != (struct device *)-1 && 162 !eq(mp->d_name, "mba")) { 163 struct idlst *id, *id2; 164 165 for (id = dp->d_vec; id; id = id->id_next) { 166 for (id2 = dp->d_vec; id2; id2 = id2->id_next) { 167 if (id2 == id) { 168 dump_intname(fp, id->id, 169 dp->d_unit); 170 break; 171 } 172 if (eq(id->id, id2->id)) 173 break; 174 } 175 } 176 } 177 } 178 dump_ctrs(fp); 179 (void) fclose(fp); 180 (void) fclose(gp); 181 } 182 183 /* 184 * Print a VERSAbus interrupt vector 185 */ 186 dump_vbavec(fp, vector, number) 187 register FILE *fp; 188 char *vector; 189 int number; 190 { 191 char nbuf[80]; 192 register char *v = nbuf; 193 194 (void) sprintf(v, "%s%d", vector, number); 195 fprintf(fp, "SCBVEC(%s):\n", v); 196 fprintf(fp, "\tCHECK_SFE(4)\n"); 197 fprintf(fp, "\tSAVE_FPSTAT(4)\n"); 198 fprintf(fp, "\tPUSHR\n"); 199 fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++); 200 fprintf(fp, "\tpushl\t$%d\n", number); 201 fprintf(fp, "\tcallf\t$8,_%s\n", vector); 202 fprintf(fp, "\tincl\t_cnt+V_INTR\n"); 203 fprintf(fp, "\tPOPR\n"); 204 fprintf(fp, "\tREST_FPSTAT\n"); 205 fprintf(fp, "\trei\n\n"); 206 } 207 208 /* 209 * HP9000/300 interrupts are auto-vectored. 210 * Code is hardwired in locore.s 211 */ 212 hpglue() {} 213 214 static char *vaxinames[] = { 215 "clock", "cnr", "cnx", "tur", "tux", 216 "mba0", "mba1", "mba2", "mba3", 217 "uba0", "uba1", "uba2", "uba3" 218 }; 219 static char *tahoeinames[] = { 220 "clock", "cnr", "cnx", "rmtr", "rmtx", "buserr", 221 }; 222 static struct stdintrs { 223 char **si_names; /* list of standard interrupt names */ 224 int si_n; /* number of such names */ 225 } stdintrs[] = { 226 { vaxinames, sizeof (vaxinames) / sizeof (vaxinames[0]) }, 227 { tahoeinames, (sizeof (tahoeinames) / sizeof (tahoeinames[0])) } 228 }; 229 /* 230 * Start the interrupt name table with the names 231 * of the standard vectors not directly associated 232 * with a bus. Also, dump the defines needed to 233 * reference the associated counters into a separate 234 * file which is prepended to locore.s. 235 */ 236 dump_std(fp, gp) 237 register FILE *fp, *gp; 238 { 239 register struct stdintrs *si = &stdintrs[machine-1]; 240 register char **cpp; 241 register int i; 242 243 fprintf(fp, "\n\t.globl\t_intrnames\n"); 244 fprintf(fp, "\n\t.globl\t_eintrnames\n"); 245 fprintf(fp, "\t.data\n"); 246 fprintf(fp, "_intrnames:\n"); 247 cpp = si->si_names; 248 for (i = 0; i < si->si_n; i++) { 249 register char *cp, *tp; 250 char buf[80]; 251 252 cp = *cpp; 253 if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { 254 cp += 3; 255 if (*cp == 'r') 256 cp++; 257 } 258 for (tp = buf; *cp; cp++) 259 if (islower(*cp)) 260 *tp++ = toupper(*cp); 261 else 262 *tp++ = *cp; 263 *tp = '\0'; 264 fprintf(gp, "#define\tI_%s\t%d\n", buf, i*sizeof (long)); 265 fprintf(fp, "\t.asciz\t\"%s\"\n", *cpp); 266 cpp++; 267 } 268 } 269 270 dump_intname(fp, vector, number) 271 register FILE *fp; 272 char *vector; 273 int number; 274 { 275 register char *cp = vector; 276 277 fprintf(fp, "\t.asciz\t\""); 278 /* 279 * Skip any "int" or "intr" in the name. 280 */ 281 while (*cp) 282 if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') { 283 cp += 3; 284 if (*cp == 'r') 285 cp++; 286 } else { 287 putc(*cp, fp); 288 cp++; 289 } 290 fprintf(fp, "%d\"\n", number); 291 } 292 293 /* 294 * Reserve space for the interrupt counters. 295 */ 296 dump_ctrs(fp) 297 register FILE *fp; 298 { 299 struct stdintrs *si = &stdintrs[machine-1]; 300 301 fprintf(fp, "_eintrnames:\n"); 302 fprintf(fp, "\n\t.globl\t_intrcnt\n"); 303 fprintf(fp, "\n\t.globl\t_eintrcnt\n"); 304 fprintf(fp, "\t.align 2\n"); 305 fprintf(fp, "_intrcnt:\n"); 306 fprintf(fp, "\t.space\t4 * %d\n", si->si_n); 307 fprintf(fp, "_fltintrcnt:\n"); 308 fprintf(fp, "\t.space\t4 * %d\n", cntcnt); 309 fprintf(fp, "_eintrcnt:\n\n"); 310 fprintf(fp, "\t.text\n"); 311 } 312