1*1031c584SApple OSS Distributions /*
2*1031c584SApple OSS Distributions * Mach Operating System
3*1031c584SApple OSS Distributions * Copyright (c) 1990 Carnegie-Mellon University
4*1031c584SApple OSS Distributions * Copyright (c) 1989 Carnegie-Mellon University
5*1031c584SApple OSS Distributions * Copyright (c) 1988 Carnegie-Mellon University
6*1031c584SApple OSS Distributions * Copyright (c) 1987 Carnegie-Mellon University
7*1031c584SApple OSS Distributions * All rights reserved. The CMU software License Agreement specifies
8*1031c584SApple OSS Distributions * the terms and conditions for use and redistribution.
9*1031c584SApple OSS Distributions */
10*1031c584SApple OSS Distributions
11*1031c584SApple OSS Distributions /*
12*1031c584SApple OSS Distributions * Copyright (c) 1988 Regents of the University of California.
13*1031c584SApple OSS Distributions * All rights reserved.
14*1031c584SApple OSS Distributions *
15*1031c584SApple OSS Distributions * Redistribution and use in source and binary forms are permitted
16*1031c584SApple OSS Distributions * provided that the above copyright notice and this paragraph are
17*1031c584SApple OSS Distributions * duplicated in all such forms and that any documentation,
18*1031c584SApple OSS Distributions * advertising materials, and other materials related to such
19*1031c584SApple OSS Distributions * distribution and use acknowledge that the software was developed
20*1031c584SApple OSS Distributions * by the University of California, Berkeley. The name of the
21*1031c584SApple OSS Distributions * University may not be used to endorse or promote products derived
22*1031c584SApple OSS Distributions * from this software without specific prior written permission.
23*1031c584SApple OSS Distributions * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
24*1031c584SApple OSS Distributions * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
25*1031c584SApple OSS Distributions * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26*1031c584SApple OSS Distributions *
27*1031c584SApple OSS Distributions * @(#)config.y 5.8 (Berkeley) 6/18/88
28*1031c584SApple OSS Distributions */
29*1031c584SApple OSS Distributions
30*1031c584SApple OSS Distributions %union {
31*1031c584SApple OSS Distributions char *str;
32*1031c584SApple OSS Distributions int val;
33*1031c584SApple OSS Distributions struct file_list *file;
34*1031c584SApple OSS Distributions struct idlst *lst;
35*1031c584SApple OSS Distributions }
36*1031c584SApple OSS Distributions
37*1031c584SApple OSS Distributions %token BUILDDIR
38*1031c584SApple OSS Distributions %token COMMA
39*1031c584SApple OSS Distributions %token EQUALS
40*1031c584SApple OSS Distributions %token INIT
41*1031c584SApple OSS Distributions %token MACHINE
42*1031c584SApple OSS Distributions %token OBJECTDIR
43*1031c584SApple OSS Distributions %token OPTIONS
44*1031c584SApple OSS Distributions %token MAKEOPTIONS
45*1031c584SApple OSS Distributions %token PSEUDO_DEVICE
46*1031c584SApple OSS Distributions %token SEMICOLON
47*1031c584SApple OSS Distributions %token SOURCEDIR
48*1031c584SApple OSS Distributions %token TRACE
49*1031c584SApple OSS Distributions
50*1031c584SApple OSS Distributions %token <str> ID
51*1031c584SApple OSS Distributions %token <val> NUMBER
52*1031c584SApple OSS Distributions
53*1031c584SApple OSS Distributions %type <str> Save_id
54*1031c584SApple OSS Distributions %type <str> Opt_value
55*1031c584SApple OSS Distributions %type <str> Dev
56*1031c584SApple OSS Distributions
57*1031c584SApple OSS Distributions %{
58*1031c584SApple OSS Distributions
59*1031c584SApple OSS Distributions #include "config.h"
60*1031c584SApple OSS Distributions #include <ctype.h>
61*1031c584SApple OSS Distributions #include <stdio.h>
62*1031c584SApple OSS Distributions
63*1031c584SApple OSS Distributions struct device cur;
64*1031c584SApple OSS Distributions struct device *curp = 0;
65*1031c584SApple OSS Distributions char *temp_id;
66*1031c584SApple OSS Distributions char *val_id;
67*1031c584SApple OSS Distributions /* char *malloc(); */
68*1031c584SApple OSS Distributions
69*1031c584SApple OSS Distributions int yylex(void);
70*1031c584SApple OSS Distributions
71*1031c584SApple OSS Distributions void deverror(const char *systemname, const char *devtype);
72*1031c584SApple OSS Distributions
73*1031c584SApple OSS Distributions %}
74*1031c584SApple OSS Distributions %%
75*1031c584SApple OSS Distributions Configuration:
76*1031c584SApple OSS Distributions Many_specs
77*1031c584SApple OSS Distributions ;
78*1031c584SApple OSS Distributions
79*1031c584SApple OSS Distributions Many_specs:
80*1031c584SApple OSS Distributions Many_specs Spec
81*1031c584SApple OSS Distributions |
82*1031c584SApple OSS Distributions /* lambda */
83*1031c584SApple OSS Distributions ;
84*1031c584SApple OSS Distributions
85*1031c584SApple OSS Distributions Spec:
86*1031c584SApple OSS Distributions Device_spec SEMICOLON
87*1031c584SApple OSS Distributions { newdev(&cur); } |
88*1031c584SApple OSS Distributions Config_spec SEMICOLON
89*1031c584SApple OSS Distributions |
90*1031c584SApple OSS Distributions TRACE SEMICOLON
91*1031c584SApple OSS Distributions { do_trace = !do_trace; } |
92*1031c584SApple OSS Distributions SEMICOLON
93*1031c584SApple OSS Distributions |
94*1031c584SApple OSS Distributions error SEMICOLON
95*1031c584SApple OSS Distributions ;
96*1031c584SApple OSS Distributions
97*1031c584SApple OSS Distributions Config_spec:
98*1031c584SApple OSS Distributions MACHINE Save_id
99*1031c584SApple OSS Distributions { machinename = ns($2); }
100*1031c584SApple OSS Distributions |
101*1031c584SApple OSS Distributions OPTIONS Opt_list
102*1031c584SApple OSS Distributions |
103*1031c584SApple OSS Distributions MAKEOPTIONS Mkopt_list
104*1031c584SApple OSS Distributions |
105*1031c584SApple OSS Distributions BUILDDIR Save_id
106*1031c584SApple OSS Distributions { build_directory = ns($2); }
107*1031c584SApple OSS Distributions |
108*1031c584SApple OSS Distributions OBJECTDIR Save_id
109*1031c584SApple OSS Distributions { object_directory = ns($2); }
110*1031c584SApple OSS Distributions |
111*1031c584SApple OSS Distributions SOURCEDIR Save_id
112*1031c584SApple OSS Distributions { source_directory = ns($2); }
113*1031c584SApple OSS Distributions ;
114*1031c584SApple OSS Distributions
115*1031c584SApple OSS Distributions
116*1031c584SApple OSS Distributions Opt_list:
117*1031c584SApple OSS Distributions Opt_list COMMA Option
118*1031c584SApple OSS Distributions |
119*1031c584SApple OSS Distributions Option
120*1031c584SApple OSS Distributions ;
121*1031c584SApple OSS Distributions
122*1031c584SApple OSS Distributions Option:
123*1031c584SApple OSS Distributions Save_id
124*1031c584SApple OSS Distributions {
125*1031c584SApple OSS Distributions struct opt *op = (struct opt *)malloc(sizeof (struct opt));
126*1031c584SApple OSS Distributions op->op_name = ns($1);
127*1031c584SApple OSS Distributions op->op_next = (struct opt *) 0;
128*1031c584SApple OSS Distributions op->op_value = 0;
129*1031c584SApple OSS Distributions if (opt == (struct opt *) 0)
130*1031c584SApple OSS Distributions opt = op;
131*1031c584SApple OSS Distributions else
132*1031c584SApple OSS Distributions opt_tail->op_next = op;
133*1031c584SApple OSS Distributions opt_tail = op;
134*1031c584SApple OSS Distributions free(temp_id);
135*1031c584SApple OSS Distributions } |
136*1031c584SApple OSS Distributions Save_id EQUALS Opt_value
137*1031c584SApple OSS Distributions {
138*1031c584SApple OSS Distributions struct opt *op = (struct opt *)malloc(sizeof (struct opt));
139*1031c584SApple OSS Distributions op->op_name = ns($1);
140*1031c584SApple OSS Distributions op->op_next = (struct opt *) 0;
141*1031c584SApple OSS Distributions op->op_value = ns($3);
142*1031c584SApple OSS Distributions if (opt == (struct opt *) 0)
143*1031c584SApple OSS Distributions opt = op;
144*1031c584SApple OSS Distributions else
145*1031c584SApple OSS Distributions opt_tail->op_next = op;
146*1031c584SApple OSS Distributions opt_tail = op;
147*1031c584SApple OSS Distributions free(temp_id);
148*1031c584SApple OSS Distributions if (val_id)
149*1031c584SApple OSS Distributions free(val_id);
150*1031c584SApple OSS Distributions } ;
151*1031c584SApple OSS Distributions
152*1031c584SApple OSS Distributions Opt_value:
153*1031c584SApple OSS Distributions ID
154*1031c584SApple OSS Distributions { $$ = val_id = ns($1); } |
155*1031c584SApple OSS Distributions NUMBER
156*1031c584SApple OSS Distributions { char nb[16];
157*1031c584SApple OSS Distributions (void) sprintf(nb, "%u", $1);
158*1031c584SApple OSS Distributions $$ = val_id = ns(nb);
159*1031c584SApple OSS Distributions } |
160*1031c584SApple OSS Distributions /* lambda from MIPS -- WHY */
161*1031c584SApple OSS Distributions { $$ = val_id = ns(""); }
162*1031c584SApple OSS Distributions ;
163*1031c584SApple OSS Distributions
164*1031c584SApple OSS Distributions Save_id:
165*1031c584SApple OSS Distributions ID
166*1031c584SApple OSS Distributions { $$ = temp_id = ns($1); }
167*1031c584SApple OSS Distributions ;
168*1031c584SApple OSS Distributions
169*1031c584SApple OSS Distributions Mkopt_list:
170*1031c584SApple OSS Distributions Mkopt_list COMMA Mkoption
171*1031c584SApple OSS Distributions |
172*1031c584SApple OSS Distributions Mkoption
173*1031c584SApple OSS Distributions ;
174*1031c584SApple OSS Distributions
175*1031c584SApple OSS Distributions Mkoption:
176*1031c584SApple OSS Distributions Save_id
177*1031c584SApple OSS Distributions {
178*1031c584SApple OSS Distributions struct opt *op = (struct opt *)malloc(sizeof (struct opt));
179*1031c584SApple OSS Distributions op->op_name = ns($1);
180*1031c584SApple OSS Distributions op->op_next = (struct opt *) 0;
181*1031c584SApple OSS Distributions op->op_value = 0;
182*1031c584SApple OSS Distributions mkopt = op;
183*1031c584SApple OSS Distributions free(temp_id);
184*1031c584SApple OSS Distributions } |
185*1031c584SApple OSS Distributions Save_id EQUALS Opt_value
186*1031c584SApple OSS Distributions {
187*1031c584SApple OSS Distributions struct opt *op = (struct opt *)malloc(sizeof (struct opt));
188*1031c584SApple OSS Distributions op->op_name = ns($1);
189*1031c584SApple OSS Distributions op->op_next = (struct opt *) 0;
190*1031c584SApple OSS Distributions op->op_value = ns($3);
191*1031c584SApple OSS Distributions if (mkopt == (struct opt *) 0)
192*1031c584SApple OSS Distributions mkopt = op;
193*1031c584SApple OSS Distributions else
194*1031c584SApple OSS Distributions mkopt_tail->op_next = op;
195*1031c584SApple OSS Distributions mkopt_tail = op;
196*1031c584SApple OSS Distributions free(temp_id);
197*1031c584SApple OSS Distributions if (val_id)
198*1031c584SApple OSS Distributions free(val_id);
199*1031c584SApple OSS Distributions } ;
200*1031c584SApple OSS Distributions
201*1031c584SApple OSS Distributions Dev:
202*1031c584SApple OSS Distributions ID
203*1031c584SApple OSS Distributions { $$ = ns($1); }
204*1031c584SApple OSS Distributions ;
205*1031c584SApple OSS Distributions
206*1031c584SApple OSS Distributions Device_spec:
207*1031c584SApple OSS Distributions PSEUDO_DEVICE Init_dev Dev
208*1031c584SApple OSS Distributions {
209*1031c584SApple OSS Distributions cur.d_name = $3;
210*1031c584SApple OSS Distributions cur.d_type = PSEUDO_DEVICE;
211*1031c584SApple OSS Distributions } |
212*1031c584SApple OSS Distributions PSEUDO_DEVICE Init_dev Dev NUMBER
213*1031c584SApple OSS Distributions {
214*1031c584SApple OSS Distributions cur.d_name = $3;
215*1031c584SApple OSS Distributions cur.d_type = PSEUDO_DEVICE;
216*1031c584SApple OSS Distributions cur.d_slave = $4;
217*1031c584SApple OSS Distributions } |
218*1031c584SApple OSS Distributions PSEUDO_DEVICE Init_dev Dev INIT ID
219*1031c584SApple OSS Distributions {
220*1031c584SApple OSS Distributions cur.d_name = $3;
221*1031c584SApple OSS Distributions cur.d_type = PSEUDO_DEVICE;
222*1031c584SApple OSS Distributions cur.d_init = ns($5);
223*1031c584SApple OSS Distributions } |
224*1031c584SApple OSS Distributions PSEUDO_DEVICE Init_dev Dev NUMBER INIT ID
225*1031c584SApple OSS Distributions {
226*1031c584SApple OSS Distributions cur.d_name = $3;
227*1031c584SApple OSS Distributions cur.d_type = PSEUDO_DEVICE;
228*1031c584SApple OSS Distributions cur.d_slave = $4;
229*1031c584SApple OSS Distributions cur.d_init = ns($6);
230*1031c584SApple OSS Distributions };
231*1031c584SApple OSS Distributions
232*1031c584SApple OSS Distributions Init_dev:
233*1031c584SApple OSS Distributions /* lambda */
234*1031c584SApple OSS Distributions { init_dev(&cur); };
235*1031c584SApple OSS Distributions
236*1031c584SApple OSS Distributions %%
237*1031c584SApple OSS Distributions
238*1031c584SApple OSS Distributions void
239*1031c584SApple OSS Distributions yyerror(const char *s)
240*1031c584SApple OSS Distributions {
241*1031c584SApple OSS Distributions fprintf(stderr, "config: line %d: %s\n", yyline, s);
242*1031c584SApple OSS Distributions }
243*1031c584SApple OSS Distributions
244*1031c584SApple OSS Distributions /*
245*1031c584SApple OSS Distributions * return the passed string in a new space
246*1031c584SApple OSS Distributions */
247*1031c584SApple OSS Distributions char *
ns(const char * str)248*1031c584SApple OSS Distributions ns(const char *str)
249*1031c584SApple OSS Distributions {
250*1031c584SApple OSS Distributions register char *cp;
251*1031c584SApple OSS Distributions
252*1031c584SApple OSS Distributions cp = malloc((unsigned)(strlen(str)+1));
253*1031c584SApple OSS Distributions (void) strcpy(cp, str);
254*1031c584SApple OSS Distributions return (cp);
255*1031c584SApple OSS Distributions }
256*1031c584SApple OSS Distributions
257*1031c584SApple OSS Distributions /*
258*1031c584SApple OSS Distributions * add a device to the list of devices
259*1031c584SApple OSS Distributions */
260*1031c584SApple OSS Distributions void
newdev(struct device * dp)261*1031c584SApple OSS Distributions newdev(struct device *dp)
262*1031c584SApple OSS Distributions {
263*1031c584SApple OSS Distributions register struct device *np;
264*1031c584SApple OSS Distributions
265*1031c584SApple OSS Distributions np = (struct device *) malloc(sizeof *np);
266*1031c584SApple OSS Distributions *np = *dp;
267*1031c584SApple OSS Distributions if (curp == 0)
268*1031c584SApple OSS Distributions dtab = np;
269*1031c584SApple OSS Distributions else
270*1031c584SApple OSS Distributions curp->d_next = np;
271*1031c584SApple OSS Distributions curp = np;
272*1031c584SApple OSS Distributions curp->d_next = 0;
273*1031c584SApple OSS Distributions }
274*1031c584SApple OSS Distributions
275*1031c584SApple OSS Distributions void
init_dev(struct device * dp)276*1031c584SApple OSS Distributions init_dev(struct device *dp)
277*1031c584SApple OSS Distributions {
278*1031c584SApple OSS Distributions
279*1031c584SApple OSS Distributions dp->d_name = "OHNO!!!";
280*1031c584SApple OSS Distributions dp->d_type = PSEUDO_DEVICE;
281*1031c584SApple OSS Distributions dp->d_flags = 0;
282*1031c584SApple OSS Distributions dp->d_slave = UNKNOWN;
283*1031c584SApple OSS Distributions dp->d_init = 0;
284*1031c584SApple OSS Distributions }
285*1031c584SApple OSS Distributions
286*1031c584SApple OSS Distributions void
deverror(const char * systemname,const char * devtype)287*1031c584SApple OSS Distributions deverror(const char *systemname, const char *devtype)
288*1031c584SApple OSS Distributions {
289*1031c584SApple OSS Distributions
290*1031c584SApple OSS Distributions fprintf(stderr, "config: %s: %s device not configured\n",
291*1031c584SApple OSS Distributions systemname, devtype);
292*1031c584SApple OSS Distributions }
293