delete sys/vm.h include file
[unix-history] / usr / src / usr.sbin / config / mkubglue.c
CommitLineData
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
e9cccb71 8static char sccsid[] = "@(#)mkubglue.c 5.2 (Berkeley) %G%";
cd68466f 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
18ubglue()
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
70static int cntcnt = 0; /* number of interrupt counters allocated */
71
e1f7f2fb 72/*
22d68ad0 73 * print an interrupt vector
e1f7f2fb 74 */
e1f7f2fb 75dump_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);
e9cccb71
KS
89 else if (strncmp(vector, "dpx", 3) == 0)
90 fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdpxdma\n\n", number);
91 else if (strncmp(vector, "dpr", 3) == 0)
92 fprintf(fp, "\tmovl\t$%d,r0\n\tjmp\tdprdma\n\n", number);
22d68ad0 93 else {
a71ca461
SL
94 if (strncmp(vector, "uur", 3) == 0) {
95 fprintf(fp, "#ifdef UUDMA\n");
96 fprintf(fp, "\tmovl\t$%d,r0\n\tjsb\tuudma\n", number);
97 fprintf(fp, "#endif\n");
98 }
dde2b2cb 99 fprintf(fp, "\tpushl\t$%d\n", number);
c1531e50 100 fprintf(fp, "\tcalls\t$1,_%s\n\tpopr\t$0x3f\n", vector);
c9f74970 101 fprintf(fp, "\tincl\t_cnt+V_INTR\n\trei\n\n");
22d68ad0 102 }
e1f7f2fb 103}
64cfcf9e
MK
104
105/*
106 * Start the interrupt name table with the names
107 * of the standard vectors not on the unibus.
108 * The number and order of these names should correspond
109 * with the definitions in scb.s.
110 */
111dump_std(fp)
112 register FILE *fp;
113{
114 fprintf(fp, "\n\t.globl\t_intrnames\n");
115 fprintf(fp, "\n\t.globl\t_eintrnames\n");
116 fprintf(fp, "\t.data\n");
117 fprintf(fp, "_intrnames:\n");
118 fprintf(fp, "\t.asciz\t\"clock\"\n");
119 fprintf(fp, "\t.asciz\t\"cnr\"\n");
120 fprintf(fp, "\t.asciz\t\"cnx\"\n");
121 fprintf(fp, "\t.asciz\t\"tur\"\n");
122 fprintf(fp, "\t.asciz\t\"tux\"\n");
123 fprintf(fp, "\t.asciz\t\"mba0\"\n");
124 fprintf(fp, "\t.asciz\t\"mba1\"\n");
125 fprintf(fp, "\t.asciz\t\"mba2\"\n");
126 fprintf(fp, "\t.asciz\t\"mba3\"\n");
127 fprintf(fp, "\t.asciz\t\"uba0\"\n");
128 fprintf(fp, "\t.asciz\t\"uba1\"\n");
129 fprintf(fp, "\t.asciz\t\"uba2\"\n");
130 fprintf(fp, "\t.asciz\t\"uba3\"\n");
131#define I_FIXED 13 /* number of names above */
132}
133
134dump_intname(fp, vector, number)
135 register FILE *fp;
136 char *vector;
137 int number;
138{
139 register char *cp = vector;
140
141 fprintf(fp, "\t.asciz\t\"");
142 /*
143 * Skip any "int" or "intr" in the name.
144 */
145 while (*cp)
146 if (cp[0] == 'i' && cp[1] == 'n' && cp[2] == 't') {
147 cp += 3;
148 if (*cp == 'r')
149 cp++;
150 } else {
151 putc(*cp, fp);
152 cp++;
153 }
154 fprintf(fp, "%d\"\n", number);
155}
156
157dump_ctrs(fp)
158 register FILE *fp;
159{
160 fprintf(fp, "_eintrnames:\n");
161 fprintf(fp, "\n\t.globl\t_intrcnt\n");
162 fprintf(fp, "\n\t.globl\t_eintrcnt\n");
163 fprintf(fp, "_intrcnt:\n", I_FIXED);
164 fprintf(fp, "\t.space\t4 * %d\n", I_FIXED);
165 fprintf(fp, "_fltintrcnt:\n", cntcnt);
166 fprintf(fp, "\t.space\t4 * %d\n", cntcnt);
167 fprintf(fp, "_eintrcnt:\n\n");
168 fprintf(fp, "\t.text\n");
169}