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