|
|
1.1 root 1:
2: # line 1 "config.y"
3: typedef union {
4: int i;
5: char *cp;
6: struct idlst *idlst;
7: } YYSTYPE;
8: # define CPU 257
9: # define IDENT 258
10: # define CONFIG 259
11: # define ANY 260
12: # define DEVICE 261
13: # define UBA 262
14: # define MBA 263
15: # define NEXUS 264
16: # define CSR 265
17: # define DRIVE 266
18: # define VECTOR 267
19: # define OPTIONS 268
20: # define CONTROLLER 269
21: # define PSEUDO_DEVICE 270
22: # define FLAGS 271
23: # define ID 272
24: # define SEMICOLON 273
25: # define NUMBER 274
26: # define FPNUMBER 275
27: # define TRACE 276
28: # define DISK 277
29: # define SLAVE 278
30: # define AT 279
31: # define HZ 280
32: # define TIMEZONE 281
33: # define DST 282
34: # define MAXUSERS 283
35: # define MASTER 284
36: # define MAKEFILE 285
37: # define COMMA 286
38: # define MINUS 287
39:
40: # line 13 "config.y"
41: /* config.y 1.11 81/05/22 */
42: #include "config.h"
43: #include <stdio.h>
44: struct device cur;
45: struct device *curp = NULL;
46: char *temp_id;
47: #define yyclearin yychar = -1
48: #define yyerrok yyerrflag = 0
49: extern int yychar;
50: extern short yyerrflag;
51: #ifndef YYMAXDEPTH
52: #define YYMAXDEPTH 150
53: #endif
54: YYSTYPE yylval, yyval;
55: # define YYERRCODE 256
56:
57: # line 169 "config.y"
58:
59:
60: yyerror(s)
61: char *s;
62: {
63: fprintf(stderr, "config: %s at line %d\n", s, yyline);
64: }
65:
66: /*
67: * ns:
68: * Return the passed string in a new space
69: */
70:
71: char *
72: ns(str)
73: register char *str;
74: {
75: register char *cp;
76:
77: cp = malloc(strlen(str)+1);
78: strcpy(cp, str);
79: return cp;
80: }
81:
82: /*
83: * newdev
84: * Add a device to the list
85: */
86:
87: newdev(dp)
88: register struct device *dp;
89: {
90: register struct device *np;
91:
92: np = (struct device *) malloc(sizeof *np);
93: *np = *dp;
94: if (curp == NULL)
95: dtab = np;
96: else
97: curp->d_next = np;
98: curp = np;
99: }
100:
101: /*
102: * mkconf
103: * Note that a configuration should be made
104: */
105:
106: mkconf(dev, sysname)
107: char *dev, *sysname;
108: {
109: register struct file_list *fl;
110:
111: fl = (struct file_list *) malloc(sizeof *fl);
112: fl->f_fn = ns(dev);
113: fl->f_needs = ns(sysname);
114: if (confp == NULL)
115: conf_list = fl;
116: else
117: confp->f_next = fl;
118: confp = fl;
119: }
120:
121: /*
122: * Connect:
123: * Find the pointer to connect to the given device and number.
124: * returns NULL if no such device and prints an error message
125: */
126:
127: struct device *connect(dev, num)
128: register char *dev;
129: register int num;
130: {
131: register struct device *dp;
132: struct device *huhcon();
133:
134: if (num == QUES)
135: return huhcon(dev);
136: for (dp = dtab; dp != NULL; dp = dp->d_next)
137: if ((num == dp->d_unit) && eq(dev, dp->d_name))
138: if (dp->d_type != CONTROLLER && dp->d_type != MASTER)
139: {
140: sprintf(errbuf, "%s connected to non-controller", dev);
141: yyerror(errbuf);
142: return NULL;
143: }
144: else
145: return dp;
146: sprintf(errbuf, "%s %d not defined", dev, num);
147: yyerror(errbuf);
148: return NULL;
149: }
150:
151: /*
152: * huhcon
153: * Connect to an unspecific thing
154: */
155:
156: struct device *huhcon(dev)
157: register char *dev;
158: {
159: register struct device *dp, *dcp;
160: struct device rdev;
161: int oldtype;
162:
163: /*
164: * First make certain that there are some of these to wildcard on
165: */
166: for (dp = dtab; dp != NULL; dp = dp->d_next)
167: if (eq(dp->d_name, dev))
168: break;
169: if (dp == NULL)
170: {
171: sprintf(errbuf, "no %s's to wildcard", dev);
172: yyerror(errbuf);
173: return NULL;
174: }
175: oldtype = dp->d_type;
176: dcp = dp->d_conn;
177: /*
178: * Now see if there is already a wildcard entry for this device
179: * (e.g. Search for a "uba ?")
180: */
181: for (; dp != NULL; dp = dp->d_next)
182: if (eq(dev, dp->d_name) && dp->d_unit == -1)
183: break;
184: /*
185: * If there isn't, make one becuase everything needs to be connected
186: * to something.
187: */
188: if (dp == NULL)
189: {
190: dp = &rdev;
191: init_dev(dp);
192: dp->d_unit = QUES;
193: dp->d_name = ns(dev);
194: dp->d_type = oldtype;
195: newdev(dp);
196: dp = curp;
197: /*
198: * Connect it to the same thing that other similar things are
199: * connected to, but make sure it is a wildcard unit
200: * (e.g. up connected to sc ?, here we make connect sc? to a uba?)
201: * If other things like this are on the NEXUS or if the aren't
202: * connected to anything, then make the same connection, else
203: * call ourself to connect to another unspecific device.
204: */
205: if (dcp == TO_NEXUS || dcp == NULL)
206: dp->d_conn = dcp;
207: else
208: dp->d_conn = connect(dcp->d_name, QUES);
209: }
210: return dp;
211: }
212:
213: /*
214: * init_dev:
215: * Set up the fields in the current device to their
216: * default values.
217: */
218:
219: init_dev(dp)
220: register struct device *dp;
221: {
222: dp->d_name = "OHNO!!!";
223: dp->d_type = DEVICE;
224: dp->d_conn = NULL;
225: dp->d_vec = NULL;
226: dp->d_addr = dp->d_flags = dp->d_dk = 0;
227: dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN;
228: dp->d_count = 0;
229: }
230:
231: /*
232: * Check_nexus:
233: * Make certain that this is a reasonable type of thing to put
234: * on the nexus.
235: */
236:
237: check_nexus(dev, num)
238: register struct device *dev;
239: int num;
240: {
241: if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba"))
242: yyerror("only uba's and mba's should be connected to the nexus");
243: if (num != QUES)
244: yyerror("can't give specific nexus numbers");
245: }
246:
247: /*
248: * Check the timezone to make certain it is sensible
249: */
250:
251: check_tz()
252: {
253: if (timezone > 24 * 60)
254: yyerror("timezone is unreasonable");
255: else
256: hadtz = TRUE;
257: }
258: short yyexca[] ={
259: -1, 1,
260: 0, -1,
261: -2, 0,
262: -1, 2,
263: 0, 1,
264: -2, 0,
265: };
266: # define YYNPROD 53
267: # define YYLAST 138
268: short yyact[]={
269:
270: 8, 14, 16, 17, 57, 9, 75, 74, 60, 59,
271: 79, 80, 15, 12, 13, 43, 82, 7, 48, 26,
272: 6, 11, 89, 81, 18, 19, 88, 22, 10, 21,
273: 87, 20, 61, 62, 41, 42, 50, 51, 67, 86,
274: 84, 83, 72, 68, 50, 51, 52, 45, 34, 40,
275: 25, 24, 23, 58, 52, 44, 38, 64, 37, 76,
276: 63, 36, 49, 28, 78, 65, 46, 27, 47, 35,
277: 5, 4, 3, 33, 2, 1, 39, 32, 29, 30,
278: 31, 0, 0, 0, 0, 0, 0, 0, 0, 0,
279: 0, 0, 0, 0, 0, 56, 53, 54, 55, 0,
280: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
281: 0, 66, 0, 0, 69, 70, 71, 0, 0, 73,
282: 0, 0, 0, 77, 0, 0, 0, 0, 0, 0,
283: 0, 0, 0, 0, 0, 0, 77, 85 };
284: short yypact[]={
285:
286: -1000,-1000,-256,-1000,-221,-222,-223,-1000,-254,-1000,
287: -1000,-1000,-1000,-1000,-224,-224,-216,-224,-225,-240,
288: -266,-217,-227,-1000,-1000,-1000,-1000,-261,-218,-261,
289: -261,-261,-218,-1000,-1000,-282,-1000,-1000,-1000,-219,
290: -1000,-273,-274,-242,-1000,-1000,-210,-1000,-226,-231,
291: -1000,-1000,-1000,-210,-210,-210,-232,-224,-1000,-1000,
292: -1000,-275,-276,-1000,-224,-255,-233,-234,-1000,-1000,
293: -1000,-1000,-1000,-1000,-1000,-1000,-1000,-224,-1000,-235,
294: -244,-248,-252,-1000,-1000,-1000,-1000,-1000,-1000,-1000 };
295: short yypgo[]={
296:
297: 0, 58, 62, 59, 75, 74, 72, 71, 70, 69,
298: 61, 67, 66, 60, 63, 68, 65, 64 };
299: short yyr1[]={
300:
301: 0, 4, 5, 5, 6, 6, 6, 6, 6, 8,
302: 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
303: 8, 8, 8, 8, 9, 9, 10, 1, 2, 2,
304: 2, 7, 7, 7, 7, 7, 7, 11, 14, 12,
305: 12, 15, 15, 16, 16, 17, 17, 17, 17, 13,
306: 13, 3, 3 };
307: short yyr2[]={
308:
309: 0, 1, 2, 0, 2, 2, 2, 1, 2, 2,
310: 2, 2, 3, 2, 2, 3, 2, 3, 3, 4,
311: 3, 4, 2, 2, 3, 1, 1, 1, 1, 1,
312: 1, 4, 4, 4, 4, 3, 4, 3, 0, 2,
313: 0, 3, 3, 2, 0, 2, 2, 2, 2, 2,
314: 0, 1, 2 };
315: short yychk[]={
316:
317: -1000, -4, -5, -6, -7, -8, 276, 273, 256, 261,
318: 284, 277, 269, 270, 257, 268, 258, 259, 280, 281,
319: 287, 285, 283, 273, 273, 273, 273, -11, -14, -11,
320: -11, -11, -14, -1, 272, -9, -10, -1, 272, -1,
321: 274, 274, 275, 281, 272, 274, -12, -15, 279, -2,
322: 262, 263, 272, -12, -12, -12, -2, 286, 272, 282,
323: 282, 274, 275, -13, 267, -16, -2, 264, 274, -13,
324: -13, -13, 274, -10, 282, 282, -3, -1, -17, 265,
325: 266, 278, 271, 274, 274, -3, 274, 274, 274, 274 };
326: short yydef[]={
327:
328: 3, -2, -2, 2, 0, 0, 0, 7, 0, 38,
329: 38, 38, 38, 38, 0, 0, 0, 0, 0, 0,
330: 0, 0, 0, 4, 5, 6, 8, 40, 0, 40,
331: 40, 40, 0, 9, 27, 10, 25, 26, 11, 0,
332: 13, 14, 16, 0, 22, 23, 50, 44, 0, 0,
333: 28, 29, 30, 50, 50, 50, 35, 0, 12, 15,
334: 17, 18, 20, 31, 0, 39, 0, 0, 37, 32,
335: 33, 34, 36, 24, 19, 21, 49, 51, 43, 0,
336: 0, 0, 0, 41, 42, 52, 45, 46, 47, 48 };
337: # ifdef YYDEBUG
338: # include "y.debug"
339: # endif
340:
341: # define YYFLAG -1000
342: # define YYERROR goto yyerrlab
343: # define YYACCEPT return(0)
344: # define YYABORT return(1)
345:
346: /* parser for yacc output */
347:
348: #ifdef YYDEBUG
349: int yydebug = 0; /* 1 for debugging */
350: #endif
351: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
352: int yychar = -1; /* current input token number */
353: int yynerrs = 0; /* number of errors */
354: short yyerrflag = 0; /* error recovery flag */
355:
356: yyparse()
357: { short yys[YYMAXDEPTH];
358: int yyj, yym;
359: register YYSTYPE *yypvt;
360: register int yystate, yyn;
361: register short *yyps;
362: register YYSTYPE *yypv;
363: register short *yyxi;
364:
365: yystate = 0;
366: yychar = -1;
367: yynerrs = 0;
368: yyerrflag = 0;
369: yyps= &yys[-1];
370: yypv= &yyv[-1];
371:
372: yystack: /* put a state and value onto the stack */
373: #ifdef YYDEBUG
374: if(yydebug >= 3)
375: if(yychar < 0 || yytoknames[yychar] == 0)
376: printf("char %d in %s", yychar, yystates[yystate]);
377: else
378: printf("%s in %s", yytoknames[yychar], yystates[yystate]);
379: #endif
380: if( ++yyps >= &yys[YYMAXDEPTH] ) {
381: yyerror( "yacc stack overflow" );
382: return(1);
383: }
384: *yyps = yystate;
385: ++yypv;
386: *yypv = yyval;
387: yynewstate:
388: yyn = yypact[yystate];
389: if(yyn <= YYFLAG) goto yydefault; /* simple state */
390: if(yychar<0) {
391: yychar = yylex();
392: #ifdef YYDEBUG
393: if(yydebug >= 2) {
394: if(yychar <= 0)
395: printf("lex EOF\n");
396: else if(yytoknames[yychar])
397: printf("lex %s\n", yytoknames[yychar]);
398: else
399: printf("lex (%c)\n", yychar);
400: }
401: #endif
402: if(yychar < 0)
403: yychar = 0;
404: }
405: if((yyn += yychar) < 0 || yyn >= YYLAST)
406: goto yydefault;
407: if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
408: yychar = -1;
409: yyval = yylval;
410: yystate = yyn;
411: if( yyerrflag > 0 ) --yyerrflag;
412: goto yystack;
413: }
414: yydefault:
415: /* default state action */
416: if( (yyn=yydef[yystate]) == -2 ) {
417: if(yychar < 0) {
418: yychar = yylex();
419: #ifdef YYDEBUG
420: if(yydebug >= 2)
421: if(yychar < 0)
422: printf("lex EOF\n");
423: else
424: printf("lex %s\n", yytoknames[yychar]);
425: #endif
426: if(yychar < 0)
427: yychar = 0;
428: }
429: /* look through exception table */
430: for(yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate);
431: yyxi += 2 ) ; /* VOID */
432: while( *(yyxi+=2) >= 0 ){
433: if( *yyxi == yychar ) break;
434: }
435: if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
436: }
437: if( yyn == 0 ){ /* error */
438: /* error ... attempt to resume parsing */
439: switch( yyerrflag ){
440: case 0: /* brand new error */
441: #ifdef YYDEBUG
442: yyerror("syntax error\n%s", yystates[yystate]);
443: if(yytoknames[yychar])
444: yyerror("saw %s\n", yytoknames[yychar]);
445: else if(yychar >= ' ' && yychar < '\177')
446: yyerror("saw `%c'\n", yychar);
447: else if(yychar == 0)
448: yyerror("saw EOF\n");
449: else
450: yyerror("saw char 0%o\n", yychar);
451: #else
452: yyerror( "syntax error" );
453: #endif
454: yyerrlab:
455: ++yynerrs;
456: case 1:
457: case 2: /* incompletely recovered error ... try again */
458: yyerrflag = 3;
459: /* find a state where "error" is a legal shift action */
460: while ( yyps >= yys ) {
461: yyn = yypact[*yyps] + YYERRCODE;
462: if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
463: yystate = yyact[yyn]; /* simulate a shift of "error" */
464: goto yystack;
465: }
466: yyn = yypact[*yyps];
467: /* the current yyps has no shift onn "error", pop stack */
468: #ifdef YYDEBUG
469: if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
470: #endif
471: --yyps;
472: --yypv;
473: }
474: /* there is no state on the stack with an error shift ... abort */
475: yyabort:
476: return(1);
477: case 3: /* no shift yet; clobber input char */
478: #ifdef YYDEBUG
479: if( yydebug ) {
480: printf("error recovery discards ");
481: if(yytoknames[yychar])
482: printf("%s\n", yytoknames[yychar]);
483: else if(yychar >= ' ' && yychar < '\177')
484: printf("`%c'\n", yychar);
485: else if(yychar == 0)
486: printf("EOF\n");
487: else
488: printf("char 0%o\n", yychar);
489: }
490: #endif
491: if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
492: yychar = -1;
493: goto yynewstate; /* try again in the same state */
494: }
495: }
496: /* reduction by production yyn */
497: #ifdef YYDEBUG
498: if(yydebug) { char *s;
499: printf("reduce %d in:\n\t", yyn);
500: for(s = yystates[yystate]; *s; s++) {
501: putchar(*s);
502: if(*s == '\n' && *(s+1))
503: putchar('\t');
504: }
505: }
506: #endif
507: yyps -= yyr2[yyn];
508: yypvt = yypv;
509: yypv -= yyr2[yyn];
510: yyval = yypv[1];
511: yym=yyn;
512: /* consult goto table to find next state */
513: yyn = yyr1[yyn];
514: yyj = yypgo[yyn] + *yyps + 1;
515: if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
516: switch(yym){
517:
518: case 4:
519: # line 31 "config.y"
520: { newdev(&cur); } break;
521: case 6:
522: # line 33 "config.y"
523: { do_trace = ! do_trace; } break;
524: case 9:
525: # line 39 "config.y"
526: {
527: struct cputype *cp = (struct cputype *)malloc(sizeof (struct cputype));
528: cp->cpu_name = ns(yypvt[-0].cp);
529: cp->cpu_next = cputype;
530: cputype = cp;
531: free(temp_id);
532: } break;
533: case 11:
534: # line 47 "config.y"
535: { ident = ns(yypvt[-0].cp); } break;
536: case 12:
537: # line 48 "config.y"
538: { mkconf(temp_id, yypvt[-0].cp); free(temp_id); } break;
539: case 13:
540: # line 49 "config.y"
541: {
542: yyerror("HZ specification obsolete; delete");
543: hz = 60;
544: } break;
545: case 14:
546: # line 53 "config.y"
547: { timezone = 60 * yypvt[-0].i; check_tz(); } break;
548: case 15:
549: # line 54 "config.y"
550: { timezone = 60 * yypvt[-1].i; dst = 1; check_tz(); } break;
551: case 16:
552: # line 55 "config.y"
553: { timezone = yypvt[-0].i; check_tz(); } break;
554: case 17:
555: # line 56 "config.y"
556: { timezone = yypvt[-1].i; dst = 1; check_tz(); } break;
557: case 18:
558: # line 57 "config.y"
559:
560: { timezone = -60 * yypvt[-0].i; check_tz(); } break;
561: case 19:
562: # line 59 "config.y"
563:
564: { timezone = -60 * yypvt[-1].i; dst = 1; check_tz(); } break;
565: case 20:
566: # line 61 "config.y"
567:
568: { timezone = -yypvt[-0].i; check_tz(); } break;
569: case 21:
570: # line 63 "config.y"
571:
572: { timezone = -yypvt[-1].i; dst = 1; check_tz(); } break;
573: case 22:
574: # line 65 "config.y"
575:
576: { mkfile = ns(yypvt[-0].cp); } break;
577: case 23:
578: # line 67 "config.y"
579: { maxusers = yypvt[-0].i; } break;
580: case 26:
581: # line 76 "config.y"
582: {
583: struct opt *op = (struct opt *)malloc(sizeof (struct opt));
584: op->op_name = ns(yypvt[-0].cp);
585: op->op_next = opt;
586: opt = op;
587: free(temp_id);
588: } break;
589: case 27:
590: # line 86 "config.y"
591: { yyval.cp = temp_id = ns(yypvt[-0].cp); } break;
592: case 28:
593: # line 90 "config.y"
594: { yyval.cp = ns("uba"); } break;
595: case 29:
596: # line 91 "config.y"
597: { yyval.cp = ns("mba"); } break;
598: case 30:
599: # line 92 "config.y"
600: { yyval.cp = ns(yypvt[-0].cp); } break;
601: case 31:
602: # line 96 "config.y"
603: { cur.d_type = DEVICE; } break;
604: case 32:
605: # line 97 "config.y"
606: { cur.d_type = MASTER; } break;
607: case 33:
608: # line 98 "config.y"
609:
610: { cur.d_dk = 1; cur.d_type = DEVICE; } break;
611: case 34:
612: # line 100 "config.y"
613: { cur.d_type = CONTROLLER; } break;
614: case 35:
615: # line 101 "config.y"
616:
617: { cur.d_name = yypvt[-0].cp; cur.d_type = PSEUDO_DEVICE; } break;
618: case 36:
619: # line 103 "config.y"
620:
621: { cur.d_name = yypvt[-1].cp; cur.d_type = PSEUDO_DEVICE;
622: cur.d_count = yypvt[-0].i; } break;
623: case 37:
624: # line 109 "config.y"
625: {
626: cur.d_name = yypvt[-1].cp;
627: if (eq(yypvt[-1].cp, "mba"))
628: seen_mba = TRUE;
629: else if (eq(yypvt[-1].cp, "uba"))
630: seen_uba = TRUE;
631: cur.d_unit = yypvt[-0].i;
632: } break;
633: case 38:
634: # line 120 "config.y"
635: { init_dev(&cur); } break;
636: case 41:
637: # line 129 "config.y"
638: {
639: if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) {
640: sprintf(errbuf,
641: "%s must be connected to a nexus", cur.d_name);
642: yyerror(errbuf);
643: }
644: cur.d_conn = connect(yypvt[-1].cp, yypvt[-0].i);
645: } break;
646: case 42:
647: # line 137 "config.y"
648: { check_nexus(&cur, yypvt[-0].i); cur.d_conn = TO_NEXUS; } break;
649: case 45:
650: # line 146 "config.y"
651: { cur.d_addr = yypvt[-0].i; } break;
652: case 46:
653: # line 147 "config.y"
654: { cur.d_drive = yypvt[-0].i; } break;
655: case 47:
656: # line 148 "config.y"
657:
658: {
659: if (cur.d_conn != NULL && cur.d_conn != TO_NEXUS
660: && cur.d_conn->d_type == MASTER)
661: cur.d_slave = yypvt[-0].i;
662: else
663: yyerror("can't specify slave--not to master");
664: } break;
665: case 48:
666: # line 156 "config.y"
667: { cur.d_flags = yypvt[-0].i; } break;
668: case 49:
669: # line 160 "config.y"
670: { cur.d_vec = yypvt[-0].idlst; } break;
671: case 51:
672: # line 163 "config.y"
673:
674: { struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst));
675: a->id = yypvt[-0].cp; a->id_next = 0; yyval.idlst = a; } break;
676: case 52:
677: # line 166 "config.y"
678:
679: { struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst));
680: a->id = yypvt[-1].cp; a->id_next = yypvt[-0].idlst; yyval.idlst = a; } break;
681: }
682: goto yystack; /* stack new state and value */
683: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.