xref: /xnu-11417.101.15/SETUP/config/config.h (revision e3723e1f17661b24996789d8afc084c0c3303b26)
1 /*
2  * Copyright (c) 1999-2009 Apple Inc. All rights reserved.
3  *
4  * @APPLE_LICENSE_HEADER_START@
5  *
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.
13  *
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."
21  *
22  * @APPLE_LICENSE_HEADER_END@
23  */
24 /*
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  */
33 
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  *	@(#)config.h	5.8 (Berkeley) 6/18/88
51  */
52 
53 /*
54  * Config.
55  */
56 
57 #include <stdio.h>
58 #include <sys/types.h>
59 #include <sys/param.h>
60 #include <stdlib.h>
61 #include <string.h>
62 
63 struct file_list {
64 	struct  file_list *f_next;
65 	char    *f_fn;                  /* the name */
66 	u_char  f_type;                 /* see below */
67 	u_char  f_flags;                /* see below */
68 	short   f_special;              /* requires special make rule */
69 	char    *f_needs;
70 	char    *f_extra;               /* stuff to add to make line */
71 };
72 
73 /*
74  * Types.
75  */
76 #define DRIVER          1
77 #define NORMAL          2
78 #define INVISIBLE       3
79 #define PROFILING       4
80 
81 /*
82  * Attributes (flags).
83  */
84 #define CONFIGDEP            0x01    /* obsolete? */
85 #define OPTIONSDEF           0x02    /* options definition entry */
86 #define LIBRARYDEP           0x04    /* include file in library build */
87 #define BOUND_CHECKS_MASK        0x78    /* options for -fbounds-safety */
88 
89 #define BOUND_CHECKS_NONE        0x00    /* do not use -fbounds-safety */
90 #define BOUND_CHECKS_PENDING 0x08        /* do not use -fbounds-safety but disable associated warnings */
91 #define BOUND_CHECKS         0x10    /* build with -fbounds-safety */
92 #define BOUND_CHECKS_SOFT    0x18    /* emit non-panicking traps for bound-checked source */
93 #define BOUND_CHECKS_DEBUG   0x20    /* emit one panicking trap per bounds check */
94 #define BOUND_CHECKS_SEED    0x40    /* emit panicking traps on !RELEASE builds */
95 #define BOUND_CHECKS_NEW_CHECKS 0x80 /* build with -fbounds-safety-bringup-missing-checks if building with -fbounds-safety*/
96 
97 struct device {
98 	int     d_type;                 /* CONTROLLER, DEVICE, bus adaptor */
99 	const char      *d_name;        /* name of device (e.g. rk11) */
100 	int     d_slave;                /* slave number */
101 #define QUES    -1      /* -1 means '?' */
102 #define UNKNOWN -2      /* -2 means not set yet */
103 	int     d_flags;                /* nlags for device init */
104 	struct  device *d_next;         /* Next one in list */
105 	char    *d_init;                /* pseudo device init routine name */
106 };
107 
108 /*
109  * Config has a global notion of which machine type is
110  * being used.  It uses the name of the machine in choosing
111  * files and directories.  Thus if the name of the machine is ``vax'',
112  * it will build from ``Makefile.vax'' and use ``../vax/inline''
113  * in the makerules, etc.
114  */
115 extern const char       *machinename;
116 
117 /*
118  * In order to configure and build outside the kernel source tree,
119  * we may wish to specify where the source tree lives.
120  */
121 extern const char *source_directory;
122 extern const char *object_directory;
123 extern char *config_directory;
124 
125 FILE *fopenp(const char *fpath, char *file, char *complete, const char *ftype);
126 const char *get_VPATH(void);
127 #define VPATH   get_VPATH()
128 
129 /*
130  * A set of options may also be specified which are like CPU types,
131  * but which may also specify values for the options.
132  * A separate set of options may be defined for make-style options.
133  */
134 struct opt {
135 	char    *op_name;
136 	char    *op_value;
137 	struct  opt *op_next;
138 };
139 
140 extern struct opt *opt, *mkopt, *opt_tail, *mkopt_tail;
141 
142 const char      *get_word(FILE *fp);
143 char    *ns(const char *str);
144 char    *qu(int num);
145 char    *path(const char *file);
146 
147 extern int      do_trace;
148 
149 extern struct   device *dtab;
150 dev_t   nametodev(char *name, int defunit, char defpartition);
151 char    *devtoname(dev_t dev);
152 
153 extern char     errbuf[80];
154 extern int      yyline;
155 
156 extern struct   file_list *ftab, *conf_list, **confp;
157 extern char     *build_directory;
158 
159 extern int      profiling;
160 
161 #define eq(a, b) (!strcmp(a,b))
162 
163 #define DEV_MASK 0x7
164 #define DEV_SHIFT  3
165 
166 /* External function references */
167 char *get_rest(FILE *fp);
168 
169 int yyparse(void);
170 void yyerror(const char *s);
171 
172 void mkioconf(void);
173 
174 void makefile(void);
175 void headers(void);
176 int opteq(const char *cp, const char *dp);
177 
178 void init_dev(struct device *dp);
179 void newdev(struct device *dp);
180 void dev_param(struct device *dp, const char *str, long num);
181 
182 int searchp(const char *spath, char *file, char *fullname, int (*func)(char *));
183