--- xinu/con/y.tab.c 2018/04/24 17:39:04 1.1 +++ xinu/con/y.tab.c 2018/04/24 17:40:16 1.1.1.2 @@ -27,15 +27,10 @@ #define CONFIGC "../sys/conf.c" /* name of .c output */ #define CONFIGH "../h/conf.h" /* name of .h output */ -#define DISPCONF "../h/dispconf.h" /* name of dispatcher .h*/ -#define IODISP "../h/iodisp.h" /* name of dispat loc .h*/ -#define CONFHREF "" /* how conf.h referenced*/ #define CONFIGIN "Configuration" /* name of input file */ FILE *confc; FILE *confh; -FILE *dispconf; -FILE *iodisp; char *dbstr; extern char *malloc(); @@ -84,10 +79,8 @@ typedef struct dvtype *dvptr; dvptr currtype = NIL; char *ftout[] = - {"#ifndef\tASM\n", - "struct\tdevsw\t{\t\t\t/* device table entry */\n", + {"struct\tdevsw\t{\t\t\t/* device table entry */\n", "\tint\tdvnum;\n", - "\tchar\t*dvname;\n", "\tint\t(*dvinit)();\n", "\tint\t(*dvopen)();\n", "\tint\t(*dvclose)();\n", @@ -106,8 +99,7 @@ char *ftout[] = "\tint\tdvminor;\n", "\t};\n\n", "extern\tstruct\tdevsw devtab[];", - "\t\t/* one entry per device */\n", - "#endif\n\n", + "\t\t/* one entry per device */\n\n", NULL}; #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 @@ -122,7 +114,7 @@ extern short yyerrflag; YYSTYPE yylval, yyval; # define YYERRCODE 256 -# line 176 "config.y" +# line 168 "config.y" #include "lex.yy.c" main(argc, argv) @@ -178,23 +170,11 @@ main(argc, argv) fprintf(stderr, "Can't write on %s\n", CONFIGH); exit(1); } - if ( (dispconf=fopen(DISPCONF,"w") ) == NULL) { - fprintf(stderr, "Can't write on %s\n",DISPCONF); - exit(1); - } - if ( (iodisp=fopen(IODISP,"w") ) == NULL) { - fprintf(stderr, "Can't write on %s\n",IODISP); - exit(1); - } fprintf(confh, "/* conf.h (GENERATED FILE; DO NOT EDIT) */\n"); fprintf(confc, "/* conf.c (GENERATED FILE; DO NOT EDIT) */\n"); - fprintf(dispconf, - "/* dispconf.h (GENERATED FILE; DO NOT EDIT) */\n"); - fprintf(iodisp, - "/* iodisp.h (GENERATED FILE; DO NOT EDIT) */\n"); - fprintf(confc, "\n#include %s\n", CONFHREF); + fprintf(confc, "\n#include \"%s\"\n", CONFIGH); fprintf(confh, "\n#define\tNULLPTR\t(char *)0\n"); @@ -203,8 +183,7 @@ main(argc, argv) fprintf(confh,"\n/* Device table declarations */\n"); for (i=0 ; (p=ftout[i])!=NULL ; i++) fprintf(confh, "%s", p); - fprintf(dispconf,"\n/* vector-to points for each device */\n\n"); - fprintf(iodisp,"\n/* i/o dispatch vector-to location externs */\n\n"); + /* write device declarations and definitions; count type refs. */ fprintf(confh, "\n/* Device name definitions */\n\n"); @@ -244,30 +223,18 @@ main(argc, argv) } fprintf(confh, "/* Declarations of I/O routines referenced */\n\n"); - fprintf(confh, "#ifndef\tASM\n"); for (i=0 ; i 0) { + if (ndevs > 0) fprintf(confc, "struct\tdevsw\tdevtab[NDEVS] = {\n"); - fprintf(confc, "\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", - "/* Format of entries is:", - "device-number, device-name,", - "init, open, close,", - "read, write, seek,", - "getc, putc, cntl,", - "device-csr-address, input-vector, output-vector,", - "iint-handler, oint-handler, control-block, minor-device,", - "*/"); - } for (fcount=0,s=devs ; s!=NIL ; s=s->dvnext,fcount++) { - fprintf(confc, "\n/* %s is %s */\n\n",s->dvname,s->dvtname); - fprintf(confc, "%d, \"%s\",\n", fcount, s->dvname); + fprintf(confc, "\n/* %s */\n", s->dvname, s->dvtname); + fprintf(confc, "%d,\n", fcount); fprintf(confc, "%s, %s, %s,\n", s->dvinit, s->dvopen, s->dvclose); fprintf(confc, "%s, %s, %s,\n", @@ -283,20 +250,6 @@ main(argc, argv) else fprintf(confc, "\n\t};"); } - for (i=0; i &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); } + if( ++yyps>= &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); } *yyps = yystate; ++yypv; *yypv = yyval; @@ -816,78 +767,78 @@ yyparse() { switch(yym){ case 2: -# line 97 "config.y" +# line 89 "config.y" {doing = "device definitions";} break; case 8: -# line 108 "config.y" +# line 100 "config.y" {mktype(yypvt[-0]);} break; case 9: -# line 111 "config.y" +# line 103 "config.y" {yyval = currtname = cktname(yypvt[-1]);} break; case 10: -# line 114 "config.y" +# line 106 "config.y" {yyval = currname = lookup(yytext,yyleng); } break; case 13: -# line 122 "config.y" +# line 114 "config.y" {newattr(CSR,yypvt[-0]);} break; case 14: -# line 124 "config.y" +# line 116 "config.y" {newattr(IVEC,yypvt[-0]);} break; case 15: -# line 126 "config.y" +# line 118 "config.y" {newattr(OVEC,yypvt[-0]);} break; case 16: -# line 128 "config.y" +# line 120 "config.y" {newattr(IINT,yypvt[-0]);} break; case 17: -# line 130 "config.y" +# line 122 "config.y" {newattr(OINT,yypvt[-0]);} break; case 18: -# line 132 "config.y" +# line 124 "config.y" {newattr(OPEN,yypvt[-0]);} break; case 19: -# line 134 "config.y" +# line 126 "config.y" {newattr(CLOSE,yypvt[-0]);} break; case 20: -# line 136 "config.y" +# line 128 "config.y" {newattr(INIT,yypvt[-0]);} break; case 21: -# line 138 "config.y" +# line 130 "config.y" {newattr(GETC,yypvt[-0]);} break; case 22: -# line 140 "config.y" +# line 132 "config.y" {newattr(PUTC,yypvt[-0]);} break; case 23: -# line 142 "config.y" +# line 134 "config.y" {newattr(READ,yypvt[-0]);} break; case 24: -# line 144 "config.y" +# line 136 "config.y" {newattr(WRITE,yypvt[-0]);} break; case 25: -# line 146 "config.y" +# line 138 "config.y" {newattr(SEEK,yypvt[-0]);} break; case 26: -# line 148 "config.y" +# line 140 "config.y" {newattr(CNTL,yypvt[-0]);} break; case 27: -# line 156 "config.y" +# line 148 "config.y" {yyval = otoi(yytext,yyleng);} break; case 28: -# line 158 "config.y" +# line 150 "config.y" {yyval = otoi(yytext,yyleng);} break; case 32: -# line 166 "config.y" +# line 158 "config.y" {mkdev(yypvt[-3],yypvt[-1],yypvt[-0]);} break; case 33: -# line 169 "config.y" +# line 161 "config.y" {yyval = currdname = ckdname(yypvt[-0]);} break; case 34: -# line 172 "config.y" +# line 164 "config.y" {yyval = 0;} break; case 35: -# line 174 "config.y" +# line 166 "config.y" {yyval = yypvt[-0];} break; } goto yystack; /* stack new state and value */