]> git.saurik.com Git - apple/xnu.git/blame - SETUP/config/mkioconf.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / SETUP / config / mkioconf.c
CommitLineData
6d2010ae
A
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
0a7de745 5 *
6d2010ae
A
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
12 * this file.
0a7de745 13 *
6d2010ae
A
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
20 * under the License."
0a7de745 21 *
6d2010ae
A
22 * @APPLE_LICENSE_HEADER_END@
23 */
0a7de745 24/*
6d2010ae
A
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.
32 */
0a7de745 33
6d2010ae
A
34/*
35 * Copyright (c) 1980 Regents of the University of California.
36 * All rights reserved.
37 *
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.
49 */
50
51#include <stdio.h>
0a7de745 52#include <unistd.h> /* for unlink */
6d2010ae
A
53#include "parser.h"
54#include "config.h"
55
56/*
57 * build the ioconf.c file
58 */
0a7de745 59void pseudo_inits(FILE *fp);
6d2010ae
A
60
61void
fe8ab488 62mkioconf(void)
6d2010ae
A
63{
64 FILE *fp;
65
66 unlink(path("ioconf.c"));
67 fp = fopen(path("ioconf.c"), "w");
68 if (fp == 0) {
69 perror(path("ioconf.c"));
70 exit(1);
71 }
72 fprintf(fp, "#include <dev/busvar.h>\n");
73 fprintf(fp, "\n");
0a7de745 74 pseudo_inits(fp);
6d2010ae
A
75 (void) fclose(fp);
76}
77
78void
fe8ab488 79pseudo_inits(FILE *fp)
6d2010ae 80{
39037602 81 struct device *dp;
6d2010ae
A
82 int count;
83
84 fprintf(fp, "\n");
85 for (dp = dtab; dp != 0; dp = dp->d_next) {
0a7de745 86 if (dp->d_type != PSEUDO_DEVICE || dp->d_init == 0) {
6d2010ae 87 continue;
0a7de745 88 }
6d2010ae
A
89 fprintf(fp, "extern int %s(int);\n", dp->d_init);
90 }
91 fprintf(fp, "\nstruct pseudo_init pseudo_inits[] = {\n");
92 for (dp = dtab; dp != 0; dp = dp->d_next) {
0a7de745 93 if (dp->d_type != PSEUDO_DEVICE || dp->d_init == 0) {
6d2010ae 94 continue;
0a7de745 95 }
6d2010ae 96 count = dp->d_slave;
0a7de745 97 if (count <= 0) {
6d2010ae 98 count = 1;
0a7de745 99 }
6d2010ae
A
100 fprintf(fp, "\t{%d,\t%s},\n", count, dp->d_init);
101 }
102 fprintf(fp, "\t{0,\t0},\n};\n");
103}