break out special local mail processing (e.g., mapping to the
[unix-history] / usr / src / usr.sbin / config / mkubglue.c
CommitLineData
a9647b53 1/*-
f3c08ca3
KB
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
a9647b53
KB
4 *
5 * %sccs.include.redist.c%
cd68466f
DF
6 */
7
524aa063 8#ifndef lint
f3c08ca3 9static char sccsid[] = "@(#)mkubglue.c 8.1 (Berkeley) %G%";
a9647b53 10#endif /* not lint */
ba6a61e0 11
e1f7f2fb
MT
12/*
13 * Make the uba interrupt file ubglue.s
14 */
15#include <stdio.h>
16#include "config.h"
17#include "y.tab.h"
18
19ubglue()
20{
22d68ad0
BJ
21 register FILE *fp;
22 register struct device *dp, *mp;
e1f7f2fb 23
22d68ad0
BJ
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 }
08f9a943 45 }
e1f7f2fb 46 }
64cfcf9e
MK
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);
22d68ad0 68 (void) fclose(fp);
e1f7f2fb
MT
69}
70
64cfcf9e
MK
71static int cntcnt = 0; /* number of interrupt counters allocated */
72
e1f7f2fb 73/*
22d68ad0 74 * print an interrupt vector
e1f7f2fb 75 */
e1f7f2fb 76dump_vec(fp, vector, number)
22d68ad0
BJ
77 register FILE *fp;
78 char *vector;
79 int number;
e1f7f2fb 80{
22d68ad0
BJ
81 char nbuf[80];
82 register char *v = nbuf;
e1f7f2fb 83
22d68ad0
BJ
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);
64cfcf9e 87 fprintf(fp, "\tincl\t_fltintrcnt+(4*%d)\n", cntcnt++);
22d68ad0 88 if (strncmp(vector, "dzx", 3) == 0)
a71ca461 89 fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdzdma\n\n", number);
e9cccb71
KS
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);
22d68ad0 94 else {
a71ca461
SL
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 }
dde2b2cb 100 fprintf(fp, "\tpushl\t$%d\n", number);
c1531e50 101 fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector);
c9f74970 102 fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n");
22d68ad0 103 }
e1f7f2fb 104}
64cfcf9e
MK
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 */
112dump_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
135dump_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
158dump_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}