forked from apple/darwin-xnu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkioconf.c
100 lines (93 loc) · 3.13 KB
/
mkioconf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License."
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1990 Carnegie-Mellon University
* Copyright (c) 1989 Carnegie-Mellon University
* Copyright (c) 1988 Carnegie-Mellon University
* Copyright (c) 1987 Carnegie-Mellon University
* All rights reserved. The CMU software License Agreement specifies
* the terms and conditions for use and redistribution.
*/
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <stdio.h>
#include <unistd.h> /* for unlink */
#include "parser.h"
#include "config.h"
/*
* build the ioconf.c file
*/
void pseudo_inits(FILE *fp);
void
mkioconf(void)
{
FILE *fp;
unlink(path("ioconf.c"));
fp = fopen(path("ioconf.c"), "w");
if (fp == 0) {
perror(path("ioconf.c"));
exit(1);
}
fprintf(fp, "#include <dev/busvar.h>\n");
fprintf(fp, "\n");
pseudo_inits (fp);
(void) fclose(fp);
}
void
pseudo_inits(FILE *fp)
{
struct device *dp;
int count;
fprintf(fp, "\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_type != PSEUDO_DEVICE || dp->d_init == 0)
continue;
fprintf(fp, "extern int %s(int);\n", dp->d_init);
}
fprintf(fp, "\nstruct pseudo_init pseudo_inits[] = {\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_type != PSEUDO_DEVICE || dp->d_init == 0)
continue;
count = dp->d_slave;
if (count <= 0)
count = 1;
fprintf(fp, "\t{%d,\t%s},\n", count, dp->d_init);
}
fprintf(fp, "\t{0,\t0},\n};\n");
}