]>
git.saurik.com Git - apple/xnu.git/blob - SETUP/config/mkioconf.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Mach Operating System
26 * Copyright (c) 1990 Carnegie-Mellon University
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * Copyright (c) 1988 Carnegie-Mellon University
29 * Copyright (c) 1987 Carnegie-Mellon University
30 * All rights reserved. The CMU software License Agreement specifies
31 * the terms and conditions for use and redistribution.
35 * Copyright (c) 1980 Regents of the University of California.
36 * All rights reserved.
38 * Redistribution and use in source and binary forms are permitted
39 * provided that the above copyright notice and this paragraph are
40 * duplicated in all such forms and that any documentation,
41 * advertising materials, and other materials related to such
42 * distribution and use acknowledge that the software was developed
43 * by the University of California, Berkeley. The name of the
44 * University may not be used to endorse or promote products derived
45 * from this software without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
47 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
48 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
52 #include <unistd.h> /* for unlink */
57 * build the ioconf.c file
59 char *intv(struct device
*dev
);
60 char *intv2(struct device
*dev
);
61 void i386_pseudo_inits(FILE *fp
); /* XXX function in wrong block */
62 void check_vector(struct idlst
*vec
);
63 void nrw_ioconf(void);
64 void m88k_pseudo_inits(FILE *fp
);
65 void m98k_pseudo_inits(FILE *fp
);
66 char *m88k_dn(char *name
);
67 char *m98k_dn(char *name
);
68 char *concat3(char *buf
, const char *p1
, const char *p2
, const char *p3
);
75 register struct device
*dp
, *mp
, *np
;
76 register int uba_n
, slave
;
79 fp
= fopen(path("ioconf.c"), "w");
81 perror(path("ioconf.c"));
85 fprintf(fp
, "#ifndef MACH_KERNEL\n");
87 fprintf(fp
, "#include <machine/pte.h>\n");
88 fprintf(fp
, "#include <sys/param.h>\n");
89 fprintf(fp
, "#include <sys/buf.h>\n");
90 fprintf(fp
, "#include <sys/map.h>\n");
91 fprintf(fp
, "#include <sys/vm.h>\n");
93 fprintf(fp
, "#endif MACH_KERNEL\n");
96 fprintf(fp
, "#include <vaxmba/mbavar.h>\n");
97 fprintf(fp
, "#include <vaxuba/ubavar.h>\n\n");
99 fprintf(fp
, "#define C (caddr_t)\n\n");
101 * First print the mba initialization structures
104 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
106 if (mp
== 0 || mp
== TO_NEXUS
||
107 !eq(mp
->d_name
, "mba"))
109 fprintf(fp
, "extern struct mba_driver %sdriver;\n",
112 fprintf(fp
, "\nstruct mba_device mbdinit[] = {\n");
113 fprintf(fp
, "\t/* Device, Unit, Mba, Drive, Dk */\n");
114 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
116 if (dp
->d_unit
== QUES
|| mp
== 0 ||
117 mp
== TO_NEXUS
|| !eq(mp
->d_name
, "mba"))
120 printf("can't specify csr address on mba for %s%d\n",
121 dp
->d_name
, dp
->d_unit
);
124 if (dp
->d_vec
!= 0) {
125 printf("can't specify vector for %s%d on mba\n",
126 dp
->d_name
, dp
->d_unit
);
129 if (dp
->d_drive
== UNKNOWN
) {
130 printf("drive not specified for %s%d\n",
131 dp
->d_name
, dp
->d_unit
);
134 if (dp
->d_slave
!= UNKNOWN
) {
135 printf("can't specify slave number for %s%d\n",
136 dp
->d_name
, dp
->d_unit
);
139 fprintf(fp
, "\t{ &%sdriver, %d, %s,",
140 dp
->d_name
, dp
->d_unit
, qu(mp
->d_unit
));
141 fprintf(fp
, " %s, %d },\n",
142 qu(dp
->d_drive
), dp
->d_dk
);
144 fprintf(fp
, "\t0\n};\n\n");
146 * Print the mbsinit structure
147 * Driver Controller Unit Slave
149 fprintf(fp
, "struct mba_slave mbsinit [] = {\n");
150 fprintf(fp
, "\t/* Driver, Ctlr, Unit, Slave */\n");
151 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
153 * All slaves are connected to something which
154 * is connected to the massbus.
156 if ((mp
= dp
->d_conn
) == 0 || mp
== TO_NEXUS
)
159 if (np
== 0 || np
== TO_NEXUS
||
160 !eq(np
->d_name
, "mba"))
162 fprintf(fp
, "\t{ &%sdriver, %s",
163 mp
->d_name
, qu(mp
->d_unit
));
164 fprintf(fp
, ", %2d, %s },\n",
165 dp
->d_unit
, qu(dp
->d_slave
));
167 fprintf(fp
, "\t0\n};\n\n");
170 * Now generate interrupt vectors for the unibus
172 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
173 if (dp
->d_vec
!= 0) {
176 if (mp
== 0 || mp
== TO_NEXUS
||
177 !eq(mp
->d_name
, "uba"))
180 "extern struct uba_driver %sdriver;\n",
182 fprintf(fp
, "extern ");
185 fprintf(fp
, "X%s%d()", ip
->id
, dp
->d_unit
);
192 fprintf(fp
, "int\t (*%sint%d[])() = { ", dp
->d_name
,
196 fprintf(fp
, "X%s%d", ip
->id
, dp
->d_unit
);
202 fprintf(fp
, ", 0 } ;\n");
205 fprintf(fp
, "\nstruct uba_ctlr ubminit[] = {\n");
206 fprintf(fp
, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n");
207 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
209 if (dp
->d_type
!= CONTROLLER
|| mp
== TO_NEXUS
|| mp
== 0 ||
210 !eq(mp
->d_name
, "uba"))
212 if (dp
->d_vec
== 0) {
213 printf("must specify vector for %s%d\n",
214 dp
->d_name
, dp
->d_unit
);
217 if (dp
->d_addr
== 0) {
218 printf("must specify csr address for %s%d\n",
219 dp
->d_name
, dp
->d_unit
);
222 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
223 printf("drives need their own entries; dont ");
224 printf("specify drive or slave for %s%d\n",
225 dp
->d_name
, dp
->d_unit
);
229 printf("controllers (e.g. %s%d) ",
230 dp
->d_name
, dp
->d_unit
);
231 printf("don't have flags, only devices do\n");
235 "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n",
236 dp
->d_name
, dp
->d_unit
, qu(mp
->d_unit
),
237 dp
->d_name
, dp
->d_unit
, dp
->d_addr
);
239 fprintf(fp
, "\t0\n};\n");
241 fprintf(fp
, "\nstruct uba_device ubdinit[] = {\n");
243 "\t/* driver, unit, ctlr, ubanum, slave, intr, addr, dk, flags*/\n");
244 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
246 if (dp
->d_unit
== QUES
|| dp
->d_type
!= DEVICE
|| mp
== 0 ||
247 mp
== TO_NEXUS
|| mp
->d_type
== MASTER
||
248 eq(mp
->d_name
, "mba"))
251 if (np
!= 0 && np
!= TO_NEXUS
&& eq(np
->d_name
, "mba"))
254 if (eq(mp
->d_name
, "uba")) {
255 if (dp
->d_vec
== 0) {
256 printf("must specify vector for device %s%d\n",
257 dp
->d_name
, dp
->d_unit
);
260 if (dp
->d_addr
== 0) {
261 printf("must specify csr for device %s%d\n",
262 dp
->d_name
, dp
->d_unit
);
265 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
266 printf("drives/slaves can be specified ");
267 printf("only for controllers, ");
268 printf("not for device %s%d\n",
269 dp
->d_name
, dp
->d_unit
);
275 if ((np
= mp
->d_conn
) == 0) {
276 printf("%s%d isn't connected to anything ",
277 mp
->d_name
, mp
->d_unit
);
278 printf(", so %s%d is unattached\n",
279 dp
->d_name
, dp
->d_unit
);
283 if (dp
->d_drive
== UNKNOWN
) {
284 printf("must specify ``drive number'' ");
285 printf("for %s%d\n", dp
->d_name
, dp
->d_unit
);
288 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
289 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
290 if (dp
->d_slave
!= UNKNOWN
) {
291 printf("slave numbers should be given only ");
292 printf("for massbus tapes, not for %s%d\n",
293 dp
->d_name
, dp
->d_unit
);
296 if (dp
->d_vec
!= 0) {
297 printf("interrupt vectors should not be ");
298 printf("given for drive %s%d\n",
299 dp
->d_name
, dp
->d_unit
);
302 if (dp
->d_addr
!= 0) {
303 printf("csr addresses should be given only ");
304 printf("on controllers, not on %s%d\n",
305 dp
->d_name
, dp
->d_unit
);
310 fprintf(fp
, "\t{ &%sdriver, %2d, %s,",
311 eq(mp
->d_name
, "uba") ? dp
->d_name
: mp
->d_name
, dp
->d_unit
,
312 eq(mp
->d_name
, "uba") ? " -1" : qu(mp
->d_unit
));
313 fprintf(fp
, " %s, %2d, %s, C 0%-6o, %d, 0x%x },\n",
314 qu(uba_n
), slave
, intv(dp
), dp
->d_addr
, dp
->d_dk
,
317 fprintf(fp
, "\t0\n};\n");
323 #define SP_OBIO 0x0004 /* on board i/o (for sun/autoconf.h) */
328 void pseudo_inits(FILE *fp
);
331 check_vector(struct idlst
*vec
)
334 if (vec
->id_vec
== 0)
335 fprintf(stderr
, "vector number for %s not given\n", vec
->id
);
336 else if (vec
->id_vec
< VEC_LO
|| vec
->id_vec
> VEC_HI
)
338 "vector number %d for %s is not between %d and %d\n",
339 vec
->id_vec
, vec
->id
, VEC_LO
, VEC_HI
);
345 register struct device
*dp
, *mp
;
347 register struct idlst
*vp
;
350 fp
= fopen(path("ioconf.c"), "w");
352 perror(path("ioconf.c"));
356 fprintf(fp
, "#ifndef MACH_KERNEL\n");
358 fprintf(fp
, "#include <sys/param.h>\n");
359 fprintf(fp
, "#include <sys/buf.h>\n");
360 fprintf(fp
, "#include <sys/map.h>\n");
361 fprintf(fp
, "#include <sys/vm.h>\n");
363 fprintf(fp
, "#endif MACH_KERNEL\n");
366 fprintf(fp
, "#include <sundev/mbvar.h>\n");
368 fprintf(fp
, "#define C (caddr_t)\n\n");
372 * Now generate interrupt vectors for the Mainbus
374 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
376 if (mp
== TO_NEXUS
|| mp
== 0 || mp
->d_conn
!= TO_NEXUS
)
378 fprintf(fp
, "extern struct mb_driver %sdriver;\n",
380 if (dp
->d_vec
!= 0) {
383 "no priority specified for %s%d\n",
384 dp
->d_name
, dp
->d_unit
);
385 fprintf(fp
, "extern ");
386 for (vp
= dp
->d_vec
;;) {
387 if (machine
== MACHINE_SUN4
)
388 fprintf(fp
, "%s()", vp
->id
);
390 fprintf(fp
, "X%s%d()",
399 for (vp
= dp
->d_vec
; vp
; vp
= vp
->id_next
) {
400 fprintf(fp
, "int V%s%d = %d;\n",
401 vp
->id
, dp
->d_unit
, dp
->d_unit
);
404 fprintf(fp
, "struct vec %s[] = { ", intv(dp
));
405 for (vp
= dp
->d_vec
; vp
!= 0; vp
= vp
->id_next
) {
406 if (machine
== MACHINE_SUN4
)
407 fprintf(fp
, "{ %s, %d, &V%s%d }, ",
411 fprintf(fp
, "{ X%s%d, %d, &V%s%d }, ",
412 vp
->id
, dp
->d_unit
, vp
->id_vec
,
416 fprintf(fp
, "0 };\n");
421 * Now spew forth the mb_ctlr structures
423 fprintf(fp
, "\nstruct mb_ctlr mbcinit[] = {\n");
425 "/* driver,\tctlr,\talive,\taddress,\tintpri,\t intr,\tspace */\n");
426 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
428 if (dp
->d_type
!= CONTROLLER
|| mp
== TO_NEXUS
|| mp
== 0 ||
429 mp
->d_conn
!= TO_NEXUS
)
431 if (dp
->d_addr
== UNKNOWN
) {
432 printf("must specify csr address for %s%d\n",
433 dp
->d_name
, dp
->d_unit
);
436 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
437 printf("drives need their own entries; ");
438 printf("don't specify drive or slave for %s%d\n",
439 dp
->d_name
, dp
->d_unit
);
443 printf("controllers (e.g. %s%d) don't have flags, ",
444 dp
->d_name
, dp
->d_unit
);
445 printf("only devices do\n");
448 if (machine
== MACHINE_SUN4
)
450 "{ &%sdriver,\t%d,\t0,\tC 0x%08x,\t%d,\t%s, 0x%x },\n",
451 dp
->d_name
, dp
->d_unit
, dp
->d_addr
,
452 (dp
->d_bus
==SP_OBIO
) ? (dp
->d_pri
<< 1) : (dp
->d_pri
<<1)-1,
453 intv(dp
), ((dp
->d_mach
<< 16) | dp
->d_bus
));
456 "{ &%sdriver,\t%d,\t0,\tC 0x%08x,\t%d,\t%s, 0x%x },\n",
457 dp
->d_name
, dp
->d_unit
, dp
->d_addr
,
458 dp
->d_pri
, intv(dp
), ((dp
->d_mach
<< 16) | dp
->d_bus
));
460 fprintf(fp
, "\t0\n};\n");
463 * Now we go for the mb_device stuff
465 fprintf(fp
, "\nstruct mb_device mbdinit[] = {\n");
467 "/* driver,\tunit, ctlr, slave, address, pri, dk, flags, intr, space */\n");
468 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
470 if (dp
->d_unit
== QUES
|| dp
->d_type
!= DEVICE
|| mp
== 0 ||
471 mp
== TO_NEXUS
|| mp
->d_type
== MASTER
)
473 if (mp
->d_conn
== TO_NEXUS
) {
474 if (dp
->d_addr
== UNKNOWN
) {
475 printf("must specify csr for device %s%d\n",
476 dp
->d_name
, dp
->d_unit
);
479 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
480 printf("drives/slaves can be specified only ");
481 printf("for controllers, not for device %s%d\n",
482 dp
->d_name
, dp
->d_unit
);
487 if (mp
->d_conn
== 0) {
488 printf("%s%d isn't connected to anything, ",
489 mp
->d_name
, mp
->d_unit
);
490 printf("so %s%d is unattached\n",
491 dp
->d_name
, dp
->d_unit
);
494 if (dp
->d_drive
== UNKNOWN
) {
495 printf("must specify ``drive number'' for %s%d\n",
496 dp
->d_name
, dp
->d_unit
);
499 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
500 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
501 if (dp
->d_slave
!= UNKNOWN
) {
502 printf("slave numbers should be given only ");
503 printf("for massbus tapes, not for %s%d\n",
504 dp
->d_name
, dp
->d_unit
);
507 if (dp
->d_pri
!= 0) {
508 printf("interrupt priority should not be ");
509 printf("given for drive %s%d\n",
510 dp
->d_name
, dp
->d_unit
);
513 if (dp
->d_addr
!= UNKNOWN
) {
514 printf("csr addresses should be given only");
515 printf(" on controllers, not on %s%d\n",
516 dp
->d_name
, dp
->d_unit
);
521 if (machine
== MACHINE_SUN4
)
523 "{ &%sdriver,\t%d, %s, %2d, C 0x%08x, %d, %d, 0x%x, %s, 0x%x },\n",
524 mp
->d_conn
== TO_NEXUS
? dp
->d_name
: mp
->d_name
, dp
->d_unit
,
525 mp
->d_conn
== TO_NEXUS
? " -1" : qu(mp
->d_unit
),
527 dp
->d_addr
== UNKNOWN
? 0 : dp
->d_addr
,
528 dp
->d_pri
* 2, dp
->d_dk
, dp
->d_flags
, intv(dp
),
529 ((dp
->d_mach
<< 16) | dp
->d_bus
));
532 "{ &%sdriver,\t%d, %s, %2d, C 0x%08x, %d, %d, 0x%x, %s, 0x%x },\n",
533 mp
->d_conn
== TO_NEXUS
? dp
->d_name
: mp
->d_name
, dp
->d_unit
,
534 mp
->d_conn
== TO_NEXUS
? " -1" : qu(mp
->d_unit
),
536 dp
->d_addr
== UNKNOWN
? 0 : dp
->d_addr
,
537 dp
->d_pri
, dp
->d_dk
, dp
->d_flags
, intv(dp
),
538 ((dp
->d_mach
<< 16) | dp
->d_bus
));
540 fprintf(fp
, "\t0\n};\n");
546 pseudo_inits(FILE *fp
)
549 register struct device
*dp
;
552 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
553 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
555 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
558 fprintf(fp
, "struct pseudo_init {\n");
559 fprintf(fp
, "\tint\tps_count;\n\tint\t(*ps_func)();\n");
560 fprintf(fp
, "} pseudo_inits[] = {\n");
562 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
563 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
568 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
571 fprintf(fp
, "\t{0,\t0},\n};\n");
579 register struct device
*dp
, *mp
;
583 fp
= fopen(path("ioconf.c"), "w");
585 perror(path("ioconf.c"));
589 fprintf(fp
, "#ifndef MACH_KERNEL\n");
591 fprintf(fp
, "#include <sys/param.h>\n");
592 fprintf(fp
, "#include <sys/buf.h>\n");
593 fprintf(fp
, "#include <sys/map.h>\n");
594 fprintf(fp
, "#include <sys/vm.h>\n");
596 fprintf(fp
, "#endif MACH_KERNEL\n");
599 fprintf(fp
, "#include <caio/ioccvar.h>\n");
601 fprintf(fp
, "#define C (caddr_t)\n\n");
604 fprintf (fp
, "struct iocc_hd iocc_hd[] = {{C 0xF0000000,}};\n");
606 * Now generate interrupt vectors for the Winnerbus
608 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
609 if (dp
->d_pri
!= 0) {
611 if (mp
== 0 || mp
== TO_NEXUS
||
612 !eq(mp
->d_name
, "iocc"))
614 fprintf(fp
, "extern struct iocc_driver %sdriver;\n",
619 * Now spew forth the iocc_cinfo structure
621 fprintf(fp
, "\nstruct iocc_ctlr iocccinit[] = {\n");
622 fprintf(fp
, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n");
623 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
625 if (dp
->d_type
!= CONTROLLER
)
627 if (mp
== TO_NEXUS
|| mp
== 0 || !eq(mp
->d_name
, "iocc"))
629 if (dp
->d_unit
== QUES
&& eq(dp
->d_name
,"hdc"))
631 if (dp
->d_unit
== QUES
&& eq(dp
->d_name
,"fdc"))
633 if (dp
->d_pri
== 0) {
634 printf("must specify priority for %s%d\n",
635 dp
->d_name
, dp
->d_unit
);
638 if (dp
->d_addr
== 0) {
639 printf("must specify csr address for %s%d\n",
640 dp
->d_name
, dp
->d_unit
);
643 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
644 printf("drives need their own entries; ");
645 printf("dont specify drive or slave for %s%d\n",
646 dp
->d_name
, dp
->d_unit
);
650 printf("controllers (e.g. %s%d) don't have flags, ",
651 dp
->d_name
, dp
->d_unit
);
652 printf("only devices do\n");
655 fprintf(fp
, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n",
656 dp
->d_name
, dp
->d_unit
, dp
->d_addr
, dp
->d_pri
);
658 fprintf(fp
, "\t0\n};\n");
660 * Now we go for the iocc_device stuff
662 fprintf(fp
, "\nstruct iocc_device ioccdinit[] = {\n");
664 "\t/* driver, unit, ctlr, slave, addr, pri, dk, flags*/\n");
665 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
667 if (dp
->d_unit
== QUES
|| dp
->d_type
!= DEVICE
|| mp
== 0 ||
668 mp
== TO_NEXUS
|| mp
->d_type
== MASTER
||
669 eq(mp
->d_name
, "iocca"))
671 if (eq(mp
->d_name
, "iocc")) {
672 if (dp
->d_pri
== 0) {
673 printf("must specify vector for device %s%d\n",
674 dp
->d_name
, dp
->d_unit
);
677 if (dp
->d_addr
== 0) {
678 printf("must specify csr for device %s%d\n",
679 dp
->d_name
, dp
->d_unit
);
682 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
683 printf("drives/slaves can be specified only ");
684 printf("for controllers, not for device %s%d\n",
685 dp
->d_name
, dp
->d_unit
);
690 if (mp
->d_conn
== 0) {
691 printf("%s%d isn't connected to anything, ",
692 mp
->d_name
, mp
->d_unit
);
693 printf("so %s%d is unattached\n",
694 dp
->d_name
, dp
->d_unit
);
697 if (dp
->d_drive
== UNKNOWN
) {
698 printf("must specify ``drive number'' for %s%d\n",
699 dp
->d_name
, dp
->d_unit
);
702 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
703 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
704 if (dp
->d_slave
!= UNKNOWN
) {
705 printf("slave numbers should be given only ");
706 printf("for massbus tapes, not for %s%d\n",
707 dp
->d_name
, dp
->d_unit
);
710 if (dp
->d_pri
!= 0) {
711 printf("interrupt priority should not be ");
712 printf("given for drive %s%d\n",
713 dp
->d_name
, dp
->d_unit
);
716 if (dp
->d_addr
!= 0) {
717 printf("csr addresses should be given only");
718 printf("on controllers, not on %s%d\n",
719 dp
->d_name
, dp
->d_unit
);
725 "\t{ &%sdriver, %2d, %s, %2d, C 0x%x, %d, %d, 0x%x },\n",
726 eq(mp
->d_name
, "iocc") ? dp
->d_name
: mp
->d_name
, dp
->d_unit
,
727 eq(mp
->d_name
, "iocc") ? " -1" : qu(mp
->d_unit
),
728 slave
, dp
->d_addr
, dp
->d_pri
, dp
->d_dk
, dp
->d_flags
);
730 fprintf(fp
, "\t0\n};\n");
734 #endif /* MACHINE_ROMP */
740 register struct device
*dp
, *dp1
, *mp
;
744 fp
= fopen(path("ioconf.c"), "w");
746 perror(path("ioconf.c"));
749 fprintf(fp
, "#include <mmaxio/io.h>\n\n");
752 * Multimax code is a little messy because we have to
753 * scan the entire list for each device to generate the
754 * structures correctly. We cheat and use the d->d_pri
755 * field to avoid doing anything twice. -1000 is an obvious
756 * bogus value for this field.
759 for (dp1
= dtab
; dp1
!= 0; dp1
= dp1
->d_next
) {
761 * If pri is not -1000, then haven't seen device yet.
763 if (dp1
->d_pri
!= -1000) switch (dp1
->d_type
) {
766 fprintf(fp
,"struct devaddr %s_devaddr[] = {\n",
769 * Now scan entire list and get all of them. Use
770 * unit to make sure unit numbers are right.
773 for (dp
= dp1
; dp
!= 0; dp
= dp
->d_next
) {
774 if (!strcmp(dp
->d_name
, dp1
->d_name
)) {
777 printf("%s%d: controller must be connected to slot.\n",
778 dp
->d_name
, dp
->d_unit
);
781 if (dp
->d_vec
!= 0) {
782 printf("%s%d: cannot configure multimax interrupt vectors.\n",
783 dp
->d_name
, dp
->d_unit
);
785 if (dp
->d_pri
!= 0) {
786 printf("%s%d: interrupt priority is nonsense on multimax.\n",
787 dp
->d_name
, dp
->d_unit
);
789 if ((dp
->d_drive
!= UNKNOWN
) ||
790 (dp
->d_slave
!=UNKNOWN
)) {
791 printf("%s%d: don't specify drive or slave for controller.\n",
792 dp
->d_name
, dp
->d_unit
);
795 * Fix unit number if bogus
797 if(dp
->d_unit
!= unit
) {
798 printf("Warning: %s%d configured as %s%d -- fix config file.\n",
799 dp
->d_name
,dp
->d_unit
,dp
->d_name
,unit
);
803 fprintf(fp
,"\t{ %d, 0, 0},\n",dp
->d_addr
);
804 dp
->d_pri
= -1000; /* done this one */
807 fprintf(fp
,"} ;\n\n");
811 fprintf(fp
,"struct subdevaddr %s_subdevaddr[] = {\n",
814 * Now scan entire list and get all of them. Use
815 * unit to make sure unit numbers are right.
818 for (dp
= dp1
; dp
!= 0; dp
= dp
->d_next
) {
819 if (!strcmp(dp
->d_name
, dp1
->d_name
)) {
821 if ( (mp
== 0) || (mp
== TO_SLOT
) ||
822 (mp
->d_type
!= CONTROLLER
)) {
823 printf("%s%d: device has no controller.\n",
824 dp
->d_name
, dp
->d_unit
);
827 if (dp
->d_vec
!= 0) {
828 printf("%s%d: cannot configure multimax interrupt vectors.\n",
829 dp
->d_name
, dp
->d_unit
);
831 if (dp
->d_pri
!= 0) {
832 printf("%s%d: interrupt priority is nonsense on multimax.\n",
833 dp
->d_name
, dp
->d_unit
);
835 if ((dp
->d_drive
!= UNKNOWN
) ||
836 (dp
->d_slave
!=UNKNOWN
)) {
837 printf("%s%d: use 'unit' instead of 'drive' or 'slave'.\n",
838 dp
->d_name
, dp
->d_unit
);
841 * Fix unit number if bogus
843 if(dp
->d_unit
!= unit
) {
844 printf("Warning: %s%d configured as %s%d -- fix config file.\n",
845 dp
->d_name
,dp
->d_unit
,dp
->d_name
,unit
);
849 if((dp
->d_addr
== 0) || (dp
->d_addr
== QUES
)){
850 printf("%s%d: must specify logical unit number.\n",
851 dp
->d_name
,dp
->d_unit
);
854 fprintf(fp
,"\t{ %d, %d, 0},\n",mp
->d_unit
,
856 dp
->d_pri
= -1000; /* don't do this again */
859 fprintf(fp
,"} ;\n\n");
864 * Doesn't exist as far as ioconf.c is concerned.
869 printf("Bogus device type for %s\n", dp1
->d_name
);
878 #endif /* MACHINE_MMAX */
883 * Define prototype device spec lines.
885 * For now, have static set of controller prototypes. This should be
886 * upgraded to using (eg) controllers.balance (ala Sequent /etc/config)
887 * to support custom boards without need to edit this file.
891 * flags for indicating presence of upper and lower bound values
898 const char *p_name
; /* name of field */
899 long p_def
; /* default value */
900 long p_lb
; /* lower bound for field */
901 long p_ub
; /* upper bound of field */
902 char p_flags
; /* bound valid flags */
906 const char *p_name
; /* name of controller type */
907 struct p_entry p_fields
[NFIELDS
]; /* ordered list of fields */
908 int p_seen
; /* any seen? */
913 * type mbad index csr flags maps[0,256] bin[0,7] intr[0,7]
916 static struct proto mbad_proto
= {
918 {{ "index", 0, 0, 0, 0 },
919 { "csr", 0, 0, 0, 0 },
920 { "flags", 0, 0, 0, 0 },
921 { "maps", 0, 0, 256, P_LB
|P_UB
},
922 { "bin", 0, 0, 7, P_LB
|P_UB
},
923 { "intr", 0, 0, 7, P_LB
|P_UB
},},
928 * SCSI/Ether Controller:
929 * type sec flags bin[0,7] req doneq index target[0,7]=-1 unit
932 static struct proto sec_proto
= {
934 {{ "flags", 0, 0, 0, 0 },
935 { "bin", 0, 0, 7, P_LB
|P_UB
} ,
936 { "req", 0, 0, 0, 0 },
937 { "doneq", 0, 0, 0, 0 },
938 { "index", 0, 0, 0, 0 },
939 { "target", -1, 0, 7, P_LB
|P_UB
},
940 { "unit", 0, 0, 0, 0 },},
945 * "Zeke" (FAST) Disk Controller (Dual-Channel Disk Controller):
946 * type zdc index[0,31] drive[-1,7] drive_type[-1,1]
948 * Levgal values for drive_type:
949 * M2333K = 0 (swallow)
951 * wildcard = -1 (run-time determined)
954 static struct proto zdc_proto
= {
956 {{ "index", 0, 0, 31, P_LB
|P_UB
},
957 { "drive", 0, -1, 7, P_LB
|P_UB
},
958 { "drive_type", 0, -1, 1, P_LB
|P_UB
},},
962 static struct proto
*ptab
[] = {
970 * locate a prototype structure in the queue of such structures.
971 * return NULL if not found.
974 static struct proto
*
975 find_proto(const char *str
)
977 register struct proto
*ptp
;
980 for (ptbx
= 0; (ptp
= ptab
[ptbx
]) != NULL
; ptbx
++) {
981 if (eq(str
, ptp
->p_name
))
988 dev_param(struct device
*dp
, const char *str
, long num
)
990 register struct p_entry
*entry
;
991 register struct proto
*ptp
;
993 ptp
= find_proto(dp
->d_conn
->d_name
);
995 fprintf(stderr
,"dev %s cont %s", dp
->d_name
, dp
->d_conn
->d_name
);
996 yyerror("invalid controller");
1000 for (entry
= ptp
->p_fields
; entry
->p_name
!= NULL
; entry
++) {
1001 if (eq(entry
->p_name
, str
)) {
1002 if ((entry
->p_flags
& P_LB
) && (num
< entry
->p_lb
)) {
1003 yyerror("parameter below range");
1006 if ((entry
->p_flags
& P_UB
) && (num
> entry
->p_ub
)) {
1007 yyerror("parameter above range");
1010 dp
->d_fields
[entry
-ptp
->p_fields
] = num
;
1015 yyerror("invalid parameter");
1021 register struct device
*dp
, *mp
;
1024 register struct proto
*ptp
;
1025 register struct p_entry
*entry
;
1031 for (count
= 0; count
< 8; count
++)
1032 bin_table
[count
] = 0;
1033 fp
= fopen(path("ioconf.c"), "w");
1035 perror(path("ioconf.c"));
1039 fprintf(fp
, "#ifndef MACH_KERNEL\n");
1041 fprintf(fp
, "#include <sys/param.h>\n");
1042 fprintf(fp
, "#include <sys/systm.h>\n");
1044 fprintf(fp
, "#endif MACH_KERNEL\n");
1047 fprintf(fp
, "#include <machine/ioconf.h>\n");
1049 fprintf(fp
, "\nu_long\tMBAd_IOwindow =\t\t3*256*1024;\t/* top 1/4 Meg */\n\n");
1051 for (ptbx
= 0; (ptp
= ptab
[ptbx
]) != NULL
; ptbx
++) {
1053 fprintf(fp
, "/*\n");
1054 fprintf(fp
, " * %s device configuration.\n", ptp
->p_name
);
1055 fprintf(fp
, " */\n\n");
1057 fprintf(fp
, "#include <sqt%s/ioconf.h>\n", ptp
->p_name
);
1061 * Generate dev structures for this controller
1063 for (dp
= dtab
, namep
= NULL
; dp
!= 0; dp
= dp
->d_next
) {
1065 if (mp
== 0 || mp
== TO_NEXUS
||
1066 !eq(mp
->d_name
, ptp
->p_name
) ||
1067 (namep
!= NULL
&& eq(dp
->d_name
, namep
)) )
1069 fprintf(fp
, "extern\tstruct\t%s_driver\t%s_driver;\n",
1070 ptp
->p_name
, namep
= dp
->d_name
);
1075 for (dp
= dtab
, namep
= NULL
; dp
!= 0; dp
= dp
->d_next
) {
1077 if (mp
== 0 || mp
== TO_NEXUS
||
1078 !eq(mp
->d_name
, ptp
->p_name
))
1080 if (namep
== NULL
|| !eq(namep
, dp
->d_name
)) {
1083 fprintf(fp
, "};\n");
1085 fprintf(fp
, "\nstruct\t%s_dev %s_%s[] = {\n",
1088 namep
= dp
->d_name
);
1090 entry
= ptp
->p_fields
;
1091 for (; entry
->p_name
!= NULL
; entry
++)
1092 fprintf(fp
, "\t%s",entry
->p_name
);
1093 fprintf(fp
, " */\n");
1095 if (dp
->d_bin
!= UNKNOWN
)
1096 bin_table
[dp
->d_bin
]++;
1098 for (entry
= ptp
->p_fields
; entry
->p_name
!= NULL
; entry
++) {
1099 if (eq(entry
->p_name
,"index"))
1100 fprintf(fp
, "\t%d,", mp
->d_unit
);
1102 fprintf(fp
, "\t%lu,",
1103 dp
->d_fields
[entry
-ptp
->p_fields
]);
1105 fprintf(fp
, "\t},\t/* %s%d */\n", dp
->d_name
, count
++);
1108 fprintf(fp
, "};\n\n");
1111 * Generate conf array
1113 fprintf(fp
, "/*\n");
1114 fprintf(fp
, " * %s_conf array collects all %s devices\n",
1115 ptp
->p_name
, ptp
->p_name
);
1116 fprintf(fp
, " */\n\n");
1117 fprintf(fp
, "struct\t%s_conf %s_conf[] = {\n",
1118 ptp
->p_name
, ptp
->p_name
);
1119 fprintf(fp
, "/*\tDriver\t\t#Entries\tDevices\t\t*/\n");
1120 for (dp
= dtab
, namep
= NULL
; dp
!= 0; dp
= dp
->d_next
) {
1122 if (mp
== 0 || mp
== TO_NEXUS
||
1123 !eq(mp
->d_name
, ptp
->p_name
))
1125 if (namep
== NULL
|| !eq(namep
, dp
->d_name
)) {
1128 "{\t&%s_driver,\t%d,\t\t%s_%s,\t},\t/* %s */\n",
1129 namep
, count
, ptp
->p_name
, namep
, namep
);
1135 if (namep
!= NULL
) {
1137 "{\t&%s_driver,\t%d,\t\t%s_%s,\t},\t/* %s */\n",
1138 namep
, count
, ptp
->p_name
, namep
, namep
);
1140 fprintf(fp
, "\t{ 0 },\n");
1141 fprintf(fp
, "};\n\n");
1149 fprintf(fp
, "/*\n");
1150 fprintf(fp
, " * Pseudo-device configuration\n");
1151 fprintf(fp
, " */\n\n");
1152 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1153 if (dp
->d_type
== PSEUDO_DEVICE
) {
1154 fprintf(fp
, "extern\tint\t%sboot();\n", dp
->d_name
);
1157 fprintf(fp
, "\nstruct\tpseudo_dev pseudo_dev[] = {\n");
1158 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1159 if (dp
->d_type
== PSEUDO_DEVICE
) {
1160 fprintf(fp
, "\t{ \"%s\",\t%d,\t%sboot,\t},\n",
1162 dp
->d_slave
== UNKNOWN
? 32 : dp
->d_slave
,
1166 fprintf(fp
, "\t{ 0 },\n");
1167 fprintf(fp
, "};\n\n");
1170 * Bin interrupt table and misc
1173 fprintf(fp
, "/*\n");
1174 fprintf(fp
, " * Interrupt table\n");
1175 fprintf(fp
, " */\n\n");
1176 fprintf(fp
, "int\tbin_intr[8] = {\n");
1177 fprintf(fp
, "\t\t0,\t\t\t\t/* bin 0, always zero */\n");
1178 for (count
=1; count
< 8; count
++) {
1179 fprintf(fp
, "\t\t%d,\t\t\t\t/* bin %d */\n",
1180 bin_table
[count
], count
);
1182 fprintf(fp
, "};\n");
1188 fprintf(fp
, "/*\n");
1189 fprintf(fp
, " * b8k_cntlrs array collects all controller entries\n");
1190 fprintf(fp
, " */\n\n");
1191 for (ptbx
= 0; (ptp
= ptab
[ptbx
]) != NULL
; ptbx
++) {
1193 fprintf(fp
, "extern int conf_%s(),\tprobe_%s_devices(),\t%s_map();\n",
1194 ptp
->p_name
, ptp
->p_name
, ptp
->p_name
);
1196 fprintf(fp
, "\n\nstruct\tcntlrs b8k_cntlrs[] = {\n");
1197 fprintf(fp
, "/*\tconf\t\tprobe_devs\t\tmap\t*/\n");
1199 for (ptbx
= 0; (ptp
= ptab
[ptbx
]) != NULL
; ptbx
++) {
1201 fprintf(fp
, "{\tconf_%s,\tprobe_%s_devices,\t%s_map\t}, \n",
1202 ptp
->p_name
, ptp
->p_name
, ptp
->p_name
);
1204 fprintf(fp
, "{\t0,\t},\n");
1205 fprintf(fp
, "};\n");
1210 #endif /* MACHINE_SQT */
1217 unlink(path("ioconf.c"));
1218 fp
= fopen(path("ioconf.c"), "w");
1220 perror(path("ioconf.c"));
1223 fprintf(fp
, "#include <dev/busvar.h>\n");
1225 fprintf(fp
, "#define C (void *)\n");
1228 i386_pseudo_inits (fp
);
1231 #endif /* MACHINE_I386 */
1233 #if MACHINE_MIPSY || MACHINE_MIPS
1235 void declare(const char *cp
);
1236 int is_declared(const char *cp
);
1241 register struct device
*dp
, *mp
, *np
;
1244 char buf1
[64], buf2
[64];
1246 unlink(path("ioconf.c"));
1247 fp
= fopen(path("ioconf.c"), "w");
1249 perror(path("ioconf.c"));
1253 fprintf(fp
, "#ifndef MACH_KERNEL\n");
1255 fprintf(fp
, "#include <sys/param.h>\n");
1256 fprintf(fp
, "#include <sys/buf.h>\n");
1257 fprintf(fp
, "#include <sys/map.h>\n");
1258 fprintf(fp
, "#include <sys/vm.h>\n");
1260 fprintf(fp
, "#endif MACH_KERNEL\n");
1263 if (seen_mbii
&& seen_vme
) {
1264 printf("can't have both vme and mbii devices\n");
1268 fprintf(fp
, "#include <mipsmbii/mbiivar.h>\n");
1270 fprintf(fp
, "#include <mipsvme/vmevar.h>\n");
1272 fprintf(fp
, "#define C (caddr_t)\n");
1273 fprintf(fp
, "#define NULL 0\n\n");
1277 * MBII stuff should go here
1284 * Now generate interrupt vectors for the vme bus
1286 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1287 if (dp
->d_vec
!= 0) {
1290 if (mp
== 0 || mp
== TO_NEXUS
|| !eq(mp
->d_name
, "vme"))
1292 if (is_declared(dp
->d_name
))
1294 declare(dp
->d_name
);
1295 fprintf(fp
, "extern struct vme_driver %sdriver;\n",
1297 fprintf(fp
, "extern ");
1300 fprintf(fp
, "%s()", ip
->id
);
1307 fprintf(fp
, "int (*_%sint%d[])() = { ", dp
->d_name
,
1311 fprintf(fp
, "%s", ip
->id
);
1317 fprintf(fp
, ", 0 } ;\n\n");
1320 fprintf(fp
, "\nstruct vme_ctlr vmminit[] = {\n");
1322 " /* driver ctlr alive intr addr am */\n");
1323 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1325 if (dp
->d_type
!= CONTROLLER
|| mp
== TO_NEXUS
|| mp
== 0 ||
1326 !eq(mp
->d_name
, "vme"))
1328 if (dp
->d_vec
== 0) {
1329 printf("must specify vector for %s%d\n",
1330 dp
->d_name
, dp
->d_unit
);
1333 if (dp
->d_addr
== 0) {
1334 printf("must specify csr address for %s%d\n",
1335 dp
->d_name
, dp
->d_unit
);
1338 if (dp
->d_addrmod
== 0) {
1339 printf("must specify address modifier for %s%d\n",
1340 dp
->d_name
, dp
->d_unit
);
1343 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
1344 printf("drives need their own entries; dont ");
1345 printf("specify drive or slave for %s%d\n",
1346 dp
->d_name
, dp
->d_unit
);
1350 printf("controllers (e.g. %s%d) ",
1351 dp
->d_name
, dp
->d_unit
);
1352 printf("don't have flags, only devices do\n");
1356 " { %14s, %3d, 0, %11s, C 0x%08x, 0x%02x },\n",
1357 concat3(buf1
, "&", dp
->d_name
, "driver"),
1359 concat3(buf2
, "_", dp
->d_name
, "int"),
1363 fprintf(fp
, " { NULL }\n};\n");
1367 fprintf(fp
, "\nstruct vme_device vmdinit[] = {\n");
1369 "/* driver unit ctlr slave intr addr am dk flags */\n"
1371 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1373 if (dp
->d_unit
== QUES
|| dp
->d_type
!= DEVICE
|| mp
== 0 ||
1374 mp
== TO_NEXUS
|| mp
->d_type
== MASTER
)
1376 for (np
= mp
; np
&& np
!= TO_NEXUS
; np
= np
->d_conn
)
1377 if (eq(np
->d_name
, "vme"))
1379 if (np
!= 0 && np
!= TO_NEXUS
&& !eq(np
->d_name
, "vme"))
1382 if (eq(mp
->d_name
, "vme")) {
1383 if (dp
->d_vec
== 0) {
1384 printf("must specify vector for device %s%d\n",
1385 dp
->d_name
, dp
->d_unit
);
1388 if (dp
->d_addr
== 0) {
1389 printf("must specify csr for device %s%d\n",
1390 dp
->d_name
, dp
->d_unit
);
1393 if (dp
->d_addrmod
== 0) {
1395 "must specify address modifier for device %s%d\n",
1396 dp
->d_name
, dp
->d_unit
);
1399 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
1400 printf("drives/slaves can be specified ");
1401 printf("only for controllers, ");
1402 printf("not for device %s%d\n",
1403 dp
->d_name
, dp
->d_unit
);
1408 if ((np
= mp
->d_conn
) == 0) {
1409 printf("%s%d isn't connected to anything ",
1410 mp
->d_name
, mp
->d_unit
);
1411 printf(", so %s%d is unattached\n",
1412 dp
->d_name
, dp
->d_unit
);
1415 if (dp
->d_drive
== UNKNOWN
) {
1416 printf("must specify ``drive number'' ");
1417 printf("for %s%d\n", dp
->d_name
, dp
->d_unit
);
1420 if (dp
->d_slave
!= UNKNOWN
) {
1421 printf("slave numbers should be given only ");
1422 printf("for massbus tapes, not for %s%d\n",
1423 dp
->d_name
, dp
->d_unit
);
1426 if (dp
->d_vec
!= 0) {
1427 printf("interrupt vectors should not be ");
1428 printf("given for drive %s%d\n",
1429 dp
->d_name
, dp
->d_unit
);
1432 if (dp
->d_addr
!= 0) {
1433 printf("csr addresses should be given only ");
1434 printf("on controllers, not on %s%d\n",
1435 dp
->d_name
, dp
->d_unit
);
1438 if (dp
->d_addrmod
!= 0) {
1439 printf("address modifiers should be given only ");
1440 printf("on controllers, not on %s%d\n",
1441 dp
->d_name
, dp
->d_unit
);
1444 slave
= dp
->d_drive
;
1447 "{%14s, %3d, %3s, %4d,%10s, C 0x%08x, 0x%02x, %1d, 0x%08x },\n",
1449 eq(mp
->d_name
, "vme") ? dp
->d_name
: mp
->d_name
,
1452 eq(mp
->d_name
, "vme") ? "-1" : qu(mp
->d_unit
),
1460 fprintf(fp
, "{ NULL }\n};\n");
1466 intv2(struct device
*dev
)
1468 static char buf
[20];
1470 if (dev
->d_vec
== 0) {
1471 strcpy(buf
, "NULL");
1473 (void) sprintf(buf
, "_%sint", dev
->d_name
);
1479 concat3(char *buf
, const char *p1
, const char *p2
, const char *p3
)
1481 (void) sprintf(buf
, "%s%s%s", p1
, p2
, p3
);
1487 char decl_devices
[MAXDEVS
][DEVLEN
];
1490 declare(const char *cp
)
1494 for (i
= 0; i
< MAXDEVS
; i
++)
1495 if (decl_devices
[i
][0] == 0) {
1496 strncpy(decl_devices
[i
], cp
, DEVLEN
);
1499 printf("device table full, fix mkioconf.c\n");
1504 is_declared(const char *cp
)
1508 for (i
= 0; i
< MAXDEVS
; i
++) {
1509 if (decl_devices
[i
][0] == 0)
1511 if (strncmp(decl_devices
[i
], cp
, DEVLEN
) == 0)
1516 #endif /* MACHINE_MIPSY || MACHINE_MIPS */
1519 char *m68k_dn(const char *name
);
1520 void m68k_pseudo_inits(FILE *fp
);
1525 register struct device
*dp
, *mp
;
1529 unlink(path("ioconf.c"));
1530 fp
= fopen(path("ioconf.c"), "w");
1532 perror(path("ioconf.c"));
1535 fprintf(fp
, "#include <dev/m68k/busvar.h>\n");
1537 fprintf(fp
, "#define C (void *)\n");
1541 * Now generate interrupt vectors for the bus
1543 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1545 if (mp
== TO_NEXUS
|| mp
== 0 || mp
->d_conn
!= TO_NEXUS
)
1547 fprintf(fp
, "extern struct bus_driver %sdriver;\n",
1552 * Now spew forth the bus_ctrl structures
1554 fprintf(fp
, "\nstruct bus_ctrl bus_cinit[] = {\n");
1556 " /* driver ctrl ipl address */\n");
1557 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1559 if (dp
->d_type
!= CONTROLLER
|| mp
== TO_NEXUS
|| mp
== 0 ||
1560 mp
->d_conn
!= TO_NEXUS
|| dp
->d_unit
== QUES
)
1562 if (dp
->d_addr
== UNKNOWN
) {
1563 printf("must specify csr address for %s%d\n",
1564 dp
->d_name
, dp
->d_unit
);
1567 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
1568 printf("drives need their own entries; ");
1569 printf("don't specify drive or slave for %s%d\n",
1570 dp
->d_name
, dp
->d_unit
);
1574 printf("controllers (e.g. %s%d) don't have flags, ",
1575 dp
->d_name
, dp
->d_unit
);
1576 printf("only devices do\n");
1580 " { %-12s, %5d, %4d, C 0x%08x },\n",
1581 m68k_dn(dp
->d_name
), dp
->d_unit
, dp
->d_pri
, dp
->d_addr
);
1583 fprintf(fp
, " 0\n};\n");
1586 * Now we go for the bus_device stuff
1588 fprintf(fp
, "\nstruct bus_device bus_dinit[] = {\n");
1590 " /* driver unit ctrl slave ipl dk flags address name */\n");
1591 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1593 if (dp
->d_unit
== QUES
|| dp
->d_type
!= DEVICE
|| mp
== 0 ||
1594 mp
== TO_NEXUS
|| mp
->d_type
== MASTER
)
1596 if (mp
->d_conn
== TO_NEXUS
) {
1597 if (dp
->d_addr
== UNKNOWN
) {
1598 printf("must specify csr for device %s%d\n",
1599 dp
->d_name
, dp
->d_unit
);
1602 if (dp
->d_drive
!= UNKNOWN
|| dp
->d_slave
!= UNKNOWN
) {
1603 printf("drives/slaves can be specified only ");
1604 printf("for controllers, not for device %s%d\n",
1605 dp
->d_name
, dp
->d_unit
);
1610 if (mp
->d_conn
== 0) {
1611 printf("%s%d isn't connected to anything, ",
1612 mp
->d_name
, mp
->d_unit
);
1613 printf("so %s%d is unattached\n",
1614 dp
->d_name
, dp
->d_unit
);
1617 if (dp
->d_drive
== UNKNOWN
) {
1618 printf("must specify ``drive number'' for %s%d\n",
1619 dp
->d_name
, dp
->d_unit
);
1622 /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
1623 /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
1624 if (dp
->d_slave
!= UNKNOWN
) {
1625 printf("slave numbers should be given only ");
1626 printf("for massbus tapes, not for %s%d\n",
1627 dp
->d_name
, dp
->d_unit
);
1630 if (dp
->d_pri
!= 0) {
1631 printf("interrupt priority should not be ");
1632 printf("given for drive %s%d\n",
1633 dp
->d_name
, dp
->d_unit
);
1636 if (dp
->d_addr
!= 0) {
1637 printf("csr addresses should be given only");
1638 printf(" on controllers, not on %s%d\n",
1639 dp
->d_name
, dp
->d_unit
);
1642 slave
= dp
->d_drive
;
1645 " { %-12s, %3d, %s, %s,%3d,%3d, %#10x, C 0x%08x, \"%s\" },\n",
1646 m68k_dn(mp
->d_conn
== TO_NEXUS
? dp
->d_name
: mp
->d_name
),
1648 mp
->d_conn
== TO_NEXUS
? " -1" : qu(mp
->d_unit
),
1650 dp
->d_pri
, -dp
->d_dk
, dp
->d_flags
,
1651 dp
->d_addr
== UNKNOWN
? 0 : dp
->d_addr
,
1654 fprintf(fp
, " 0\n};\n");
1655 m68k_pseudo_inits (fp
);
1660 m68k_pseudo_inits(FILE *fp
)
1662 register struct device
*dp
;
1666 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1667 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1669 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
1671 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
1672 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1673 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1675 count
= dp
->d_slave
;
1678 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
1680 fprintf(fp
, "\t{0,\t0},\n};\n");
1684 i386_pseudo_inits(FILE *fp
)
1686 register struct device
*dp
;
1690 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1691 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1693 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
1695 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
1696 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1697 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1699 count
= dp
->d_slave
;
1702 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
1704 fprintf(fp
, "\t{0,\t0},\n};\n");
1708 m68k_dn(const char *name
)
1710 sprintf(errbuf
, "&%sdriver", name
); return ns(errbuf
);
1712 #endif /* MACHINE_M68K */
1714 #if MACHINE_M88K || MACHINE_M98K
1715 char *nrw_dn(char *name
);
1716 void nrw_pseudo_inits(FILE *fp
);
1723 unlink(path("ioconf.c"));
1724 fp
= fopen(path("ioconf.c"), "w");
1726 perror(path("ioconf.c"));
1729 fprintf(fp
, "#include <dev/nrw/busvar.h>\n");
1731 nrw_pseudo_inits (fp
);
1736 nrw_pseudo_inits(FILE *fp
)
1738 register struct device
*dp
;
1742 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1743 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1745 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
1747 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
1748 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1749 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1751 count
= dp
->d_slave
;
1754 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
1756 fprintf(fp
, "\t{0,\t0},\n};\n");
1762 sprintf(errbuf
, "&%sdriver,", name
);
1779 m88k_pseudo_inits(FILE *fp
)
1781 nrw_pseudo_inits(fp
);
1785 m98k_pseudo_inits(FILE *fp
)
1787 nrw_pseudo_inits(fp
);
1793 return(nrw_dn(name
));
1799 return(nrw_dn(name
));
1803 #endif /* MACHINE_M88K || MACHINE_M98K */
1806 char *hppa_dn(char *name
);
1807 void hppa_pseudo_inits(FILE *fp
);
1814 unlink(path("ioconf.c"));
1815 fp
= fopen(path("ioconf.c"), "w");
1817 perror(path("ioconf.c"));
1820 fprintf(fp
, "#include <dev/hppa/busvar.h>\n");
1822 hppa_pseudo_inits (fp
);
1827 hppa_pseudo_inits(FILE *fp
)
1829 register struct device
*dp
;
1833 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1834 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1836 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
1838 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
1839 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1840 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1842 count
= dp
->d_slave
;
1845 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
1847 fprintf(fp
, "\t{0,\t0},\n};\n");
1853 sprintf(errbuf
, "&%sdriver,", name
);
1858 #endif /* MACHINE_HPPA */
1860 #ifdef MACHINE_SPARC
1861 char *sparc_dn(char *name
);
1862 void sparc_pseudo_inits(FILE *fp
);
1869 unlink(path("ioconf.c"));
1870 fp
= fopen(path("ioconf.c"), "w");
1872 perror(path("ioconf.c"));
1875 fprintf(fp
, "#include <dev/busvar.h>\n");
1877 sparc_pseudo_inits (fp
);
1882 sparc_pseudo_inits(FILE *fp
)
1884 register struct device
*dp
;
1888 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1889 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1891 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
1893 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
1894 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1895 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1897 count
= dp
->d_slave
;
1900 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
1902 fprintf(fp
, "\t{0,\t0},\n};\n");
1906 sparc_dn(char *name
)
1908 sprintf(errbuf
, "&%sdriver,", name
);
1912 #endif /* MACHINE_SPARC */
1915 char *ppc_dn(char *name
);
1916 void ppc_pseudo_inits(FILE *fp
);
1923 unlink(path("ioconf.c"));
1924 fp
= fopen(path("ioconf.c"), "w");
1926 perror(path("ioconf.c"));
1929 fprintf(fp
, "#include <dev/busvar.h>\n");
1931 ppc_pseudo_inits (fp
);
1936 ppc_pseudo_inits(FILE *fp
)
1938 register struct device
*dp
;
1942 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1943 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1945 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
1947 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
1948 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1949 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1951 count
= dp
->d_slave
;
1954 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
1956 fprintf(fp
, "\t{0,\t0},\n};\n");
1963 sprintf(errbuf
, "&%sdriver,", name
);
1967 #endif /* MACHINE_PPC */
1970 void arm_pseudo_inits(FILE *fp
);
1977 unlink(path("ioconf.c"));
1978 fp
= fopen(path("ioconf.c"), "w");
1980 perror(path("ioconf.c"));
1983 fprintf(fp
, "#include <dev/busvar.h>\n");
1985 arm_pseudo_inits (fp
);
1990 arm_pseudo_inits(FILE *fp
)
1992 register struct device
*dp
;
1996 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
1997 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
1999 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
2001 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
2002 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
2003 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
2005 count
= dp
->d_slave
;
2008 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
2010 fprintf(fp
, "\t{0,\t0},\n};\n");
2013 #endif /* MACHINE_ARM */
2015 #ifdef MACHINE_X86_64
2016 void x86_64_pseudo_inits(FILE *fp
);
2023 unlink(path("ioconf.c"));
2024 fp
= fopen(path("ioconf.c"), "w");
2026 perror(path("ioconf.c"));
2029 fprintf(fp
, "#include <dev/busvar.h>\n");
2031 x86_64_pseudo_inits (fp
);
2036 x86_64_pseudo_inits(FILE *fp
)
2038 register struct device
*dp
;
2042 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
2043 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
2045 fprintf(fp
, "extern int %s(int);\n", dp
->d_init
);
2047 fprintf(fp
, "\nstruct pseudo_init pseudo_inits[] = {\n");
2048 for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
) {
2049 if (dp
->d_type
!= PSEUDO_DEVICE
|| dp
->d_init
== 0)
2051 count
= dp
->d_slave
;
2054 fprintf(fp
, "\t{%d,\t%s},\n", count
, dp
->d_init
);
2056 fprintf(fp
, "\t{0,\t0},\n};\n");
2059 #endif /* MACHINE_X86_64 */
2062 intv(struct device
*dev
)
2064 static char buf
[20];
2066 if (dev
->d_vec
== 0) {
2069 (void) sprintf(buf
, "%sint%d", dev
->d_name
, dev
->d_unit
);
2079 strcpy(errbuf
, "'?'");
2080 } else if (num
== UNKNOWN
) {
2081 strcpy(errbuf
, " -1");
2083 (void) sprintf(errbuf
, "%3d", num
);