📄 new_mkconf.c
字号:
/* * pass 2 -- create configuration table */ freopen("c.c", "w", stdout); /* * declarations */ puke(stre); for (i=0; q=btab[i]; i++) { for (p=table; p->name; p++) if (match(q, p->name) && (p->key&BLOCK) && p->count && *p->codef) printf("%s\n", p->codef); } puke(stre1); for(i=0; q=btab[i]; i++) { for(p=table; p->name; p++) if(match(q, p->name) && (p->key&BLOCK) && p->count) { printf("%s /* %s = %d */\n", p->coded, p->name, i); if(p->key & ROOT) rootmaj = i; if (p->key & SWAP) swapmaj = i; if (p->key & PIPE) pipemaj = i; goto newb; } printf(" nodev, nodev, nodev, 0, /* %s = %d */\n", q, i); newb:; } if (swapmaj == -1) { swapmaj = rootmaj; swapmin = rootmin; } if (pipemaj == -1) { pipemaj = rootmaj; pipemin = rootmin; } puke(strf); for (i=0; q=ctab[i]; i++) { for (p=table; p->name; p++) if (match(q, p->name) && (p->key&CHAR) && p->count && *p->codeg) printf("%s\n", p->codeg); } puke(strf1); for(i=0; q=ctab[i]; i++) { for(p=table; p->name; p++) if(match(q, p->name) && (p->key&CHAR) && p->count) { printf("%s /* %s = %d */\n", p->codee, p->name, i); goto newc; } printf(" nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* %s = %d */\n", q, i); newc:; } puke(strh); if (pack) { nldisp++; puke(stri); } puke(strj); if (pack) puke(strk); printf(strg, rootmaj, rootmin, swapmaj, swapmin, pipemaj, pipemin, nldisp, swplo, nswap); printf(strg1); if (!mpx) puke(strg1a); printf(strg2); puke(strg3); if(rootmaj < 0) fprintf(stderr, "No root device given\n"); freopen("mch0.s", "w", stdout); dumpht = 0; dumptm = 0; dumpts = 0; for (i=0; table[i].name; i++) { if (equal(table[i].name, "ht") && table[i].count) dumpht = 1; if (equal(table[i].name, "tm") && table[i].count) dumptm = 1; if (equal(table[i].name, "ts") && table[i].count) dumpts = 1; } if((dump == HT) && dumpht) { dumptm = 0; dumpts = 0; } if((dump == TM) && dumptm) { dumpht = 0; dumpts = 0; } if((dump == TS) && dumpts) { dumpht = 0; dumptm = 0; } if (dumpht) { printf("HTDUMP = 1\n"); printf("TUDUMP = 0\n"); printf("TSDUMP = 0\n"); if(cdcsr) printf("\nHTCS1 = %o\n", cdcsr); else printf("\nHTCS1 = 172440\n"); } else if (dumptm) { printf("HTDUMP = 0\n"); printf("TUDUMP = 1\n"); printf("TSDUMP = 0\n"); if(cdcsr) printf("\nMTS = %o\n", cdcsr); else printf("\nMTS = 172520\n"); printf("MTC = MTS+2\n"); } else if (dumpts) { printf("HTDUMP = 0\n"); printf("TUDUMP = 0\n"); printf("TSDUMP = 1\n"); if(cdcsr) printf("\nTSDB = %o\n", cdcsr); else printf("\nTSDB = 172520\n"); printf("TSSR = TSDB+2\n"); } else { fprintf(stderr, "\n(No tape, so no core dump included)\n"); printf("HTDUMP = 0\n"); printf("TUDUMP = 0\n"); printf("TSDUMP = 0\n"); } if(nfp) printf("\n.fpp\t= 0\n"); else printf("\n.fpp\t= 1\n");/* * pass3 - create "ovload" file * * "ovload" is a shell file used by /sys/conf/makefile * to invoke the covld command to link the overlay * kernel and produce the executable file unix_ov. * * The method to this madness is as follows: * * 1. If the "ov" specification was not present in * the conf file, then skip this pass ! * * 2. Use the size command to create the file text.sizes * containing the text sizes of each object module. * ../ovdev/bio.o 2086+30+0 = 2116b = 04104b, etc. * * 3. Transfer the text size of each object module from the * text.sizes file to that module's slot in the ovtab structure. * * 4. Check each module in the ovtab structure to insure that it's * size was found and initialize the ovdes (overlay descriptor) * array to all zeroes (all overlays empty). * * 5. Scan the ovtab structure and load all of the modules that * are always configured into their designated overlays. * * 6. Search the mkconf "table" to find all configured devices * (count > 0) and mark them as optional configured devices in * the ovtab structure, one exception is "tty" which always included. * If the "hp", "hk", or "hm" disks are configured, * then the "dsort" and "dkleave" modules must be included * in overlay 3. * If the "dh" driver is configured and the "dhdm" module * is not included, then the "dhfdm" module must be included * in overlay 5. * If the "rx" specification is included, it's name is changed * to "rx2" because the rx2.o module supports both rx01 & rx02. * * 7. Check for "mpx" and "pack", if specified mark their object * modules as optional configured devices in the ovtab structure. * * 8. Scan the ovtab and load all optionaly configured modules * that have fixed overlay assignments into their designated overlays. * Except for the following special case any module with a * fixed overlay assignment, which causes that overlay to * overflow will cause a fatal error, i.e., overlay * 3 could overflow if all three big disk drivers (hp, hm, & hk) * are configured. If this occurs the "hm" driver will be * loaded into the first overlay with sufficient free space. * * 9. Scan the ovtab and transfer any configured modules from * pseudo overlays 8 thru 10 to real overlays 1 thru 7. * The modules are placed into the overlays starting at one * on a first fit basis. Actually this is done in two passes, * first the existing overlays are scanned to locate a * slot for the module, if the module will not fit into * any existing overlay, then a new overlay is created and * the module is loaded into it. * * 10. Create the "ovload" shell file by scanning the overlay * descriptor array and writing the pathnames of the * modules to be loaded into the file. *//* 1. */ if(!ov) exit(0);/* 2. */ system(sizcmd); if((fi = fopen("text.sizes", "r")) == 0) { fprintf(stderr, "\nCan't open text.sizes file\n"); exit(); }/* 3. */scanlp: ovcnt = fscanf(fi, "%9s%[^\.]%s%[^+]%[^\n]",trash,omn,trash,mtsize,trash); if(ovcnt == EOF) goto endovs; if(ovcnt != 5) { fprintf(stderr, "\ntext.sizes file format error\n"); exit(); } for(otp = ovt; otp->mn; otp++) { q = &omn; if(equal(otp->mn, q)) { otp->mts = atoi(mtsize); break; } } goto scanlp;endovs: fclose(fi);/* 4. */ for(otp = ovt; otp->mn; otp++) if(otp->mts < 0) fprintf(stderr, "\n%s.o object file size not found\n", otp->mn); for(i=0; i<8; i++) { ovdtab[i].nentry = 0; ovdtab[i].size = 0; }/* 5. */ for(otp = ovt; otp->mn; otp++) if((otp->mc == 1) && (otp->ovno < 6)) { if(ovload(otp, otp->ovno) < 0) goto ovlerr; }/* 6. */ for(p=table; p->name; p++) if(p->count > 0) { if(equal(p->name, "rx")) c = ctab[22]; /* rx2 */ else c = p->name; n = 0; for(otp=ovt; otp->mn; otp++) if(equal(c, q=otp->mn)) { if(otp->mc == 0) otp->mc = 2; n++; break; } if(!n) { fprintf(stderr, "\n%s not in overlay table\n", c); exit(); } } /* if hp, hm or hk configured, must include dsort and dkleave */ n = 0; for(otp=ovt; otp->mn; otp++) { if((equal(otp->mn, "hp") || equal(otp->mn, "hm") || equal(otp->mn, "hk")) && (otp->mc == 2)) n++; if(equal(otp->mn, "dsort") && n) otp->mc = 2; if(equal(otp->mn, "dkleave") && n) { otp->mc = 2; break; } } /* if dh configured without dhdm, must include dhfdm */ n = 0; for(otp=ovt; otp->mn; otp++) if(equal(otp->mn, "dhdm")) break; if(otp->mc == 0) n++; otp++; if((otp->mc == 2) && n) { otp++; otp->mc = 2; }/* 7. */ for(otp=ovt; otp->mn; otp++) { if((otp->ovno == 6) && pack) otp->mc = 2; if((otp->ovno == 7) && mpx) otp->mc = 2; }/* 8. */ for(otp=ovt; otp->mn; otp++) if((otp->mc == 2) && (otp->ovno < 8)) if(ovload(otp, otp->ovno) < 0) { if(otp->ovno == 3) otp->ovno = 8; else goto ovlerr; }/* 9. */ for(otp=ovt; otp->mn; otp++) { if(otp->ovno < 8)ovldok: continue; if(otp->mc) { for(i=1; i<8; i++) { if(ovdtab[i].size) if(ovload(otp, i) >= 0) goto ovldok; } for(i=1; i<8; i++) { if(ovload(otp, i) >= 0) goto ovldok; } fprintf(stderr,"%s will not fit in overlay %d\n",otp->mn,i); exit(); } }/* 10. */ freopen("ovload", "w", stdout); puke(strovh); for(i=1; i<8; i++) { ovdp = &ovdtab[i]; if(ovdp->nentry) { puke(strovz); for(n=0; n < ovdp->nentry; n++) { printf("%s", ovdp->omns[n]); printf("\n"); } } } puke(strovl); printf("\n"); fclose(stdout); system(cmcmd); exit();ovlerr: fprintf(stderr, "\noverlay %d size overflow\n",otp->ovno); exit();}/* * ovload checks to see if the module will fit * into the overlay and then loads it if possible * or returns -1 if it can't be loaded. */ovload(tp, ovn)struct ovtab *tp;{ register struct ovdes *dp; dp = &ovdtab[ovn]; if((dp->nentry >= 12) || (dp->size >= 8192) || ((dp->size + tp->mts) > 8192)) return(-1); dp->omns[dp->nentry] = tp->mpn; dp->size += tp->mts; dp->nentry++; return(1);}puke(s)char **s;{ char *c; while(c = *s++) { printf(c); printf("\n"); }}input(){ char line[100]; register struct tab *q; int count, n; long num; unsigned int onum; char keyw[32], dev[32]; if (fgets(line, 100, stdin) == NULL) return(0); count = -1; sscanf(line, "%d%s%s%o", &count, keyw, dev, &onum); n = sscanf(line, "%d%s%s%ld", &count, keyw, dev, &num); if (count == -1 && n>0) { count = 1; n++; } if (n<2) goto badl; for(q=table; q->name; q++) if(equal(q->name, keyw)) { if(q->count < 0) { fprintf(stderr, "%s: no more, no less\n", keyw); return(1); } q->count += count; if(q->address < 300 && q->count > 1) { q->count = 1; fprintf(stderr, "%s: only one\n", keyw); } return(1); } if (equal(keyw, "nswap")) { if (n<3) goto badl; if (sscanf(dev, "%ld", &num) <= 0) goto badl; nswap = num; return(1); } if (equal(keyw, "swplo")) { if (n<3) goto badl; if (sscanf(dev, "%ld", &num) <= 0) goto badl; swplo = num; return(1); } if (equal(keyw, "pack")) { pack++; return(1); } if (equal(keyw, "mpx")) { mpx++; return(1); } if (equal(keyw, "ov")) { ov++; return; } if (equal(keyw, "nsid")) { nsid++; return(1); } if (equal(keyw, "nfp")) { nfp++; return(1); } dump = 0; if (equal(keyw, "dump")) { if (n<3) goto badl; if (equal(dev, "ht")) dump = HT; else if(equal(dev, "tm")) dump = TM; else if(equal(dev, "ts")) dump = TS; else goto badl; cdcsr = 0; if (n == 4) { if ((onum > 0160006) && (onum < 0177514)) cdcsr = onum & 0177776; else goto badl; } return(1); } if (equal(keyw, "done")) return(0); if (equal(keyw, "root")) { if (n<4) goto badl; for (q=table; q->name; q++) { if (equal(q->name, dev)) { q->key |= ROOT; rootmin = num; return(1); } } fprintf(stderr, "Can't find root\n"); return(1); } if (equal(keyw, "swap")) { if (n<4) goto badl; for (q=table; q->name; q++) { if (equal(q->name, dev)) { q->key |= SWAP; swapmin = num; return(1); } } fprintf(stderr, "Can't find swap\n"); return(1); } if (equal(keyw, "pipe")) { if (n<4) goto badl; for (q=table; q->name; q++) { if (equal(q->name, dev)) { q->key |= PIPE; pipemin = num; return(1); } } fprintf(stderr, "Can't find pipe\n"); return(1); } fprintf(stderr, "%s: cannot find\n", keyw); return(1);badl: fprintf(stderr, "Bad line: %s", line); return(1);}equal(a, b)char *a, *b;{ return(!strcmp(a, b));}match(a, b)register char *a, *b;{ register char *t; for (t = b; *a && *t; a++) { if (*a != *t) { while (*a && *a != '|') a++; if (*a == '\0') return(0); t = b; } else t++; } if (*a == '\0' || *a == '|') return(1); return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -