⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkioconf.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
				    dp->d_name, dp->d_unit);				fatal_error++;				continue;			}			if (np != TO_NEXUS) {			    if(needs_pseudo_uba(np->d_name) ||			      ((mp) && needs_pseudo_uba(mp->d_name)				 )) {				if (mp->d_extranum == UNKNOWN) {					uba_n = QUES;				} else {					uba_n = highuba + mp->d_extranum + 1; 				}			    } else {		 		if(mp->d_unit == QUES)				    uba_n = QUES;				else				    uba_n = uba_num(np);			    }			} else {			    uba_n = QUES;			}			if (dp->d_drive == UNKNOWN) {				printf("must specify ``drive number'' ");				printf("for %s%d\n", dp->d_name, dp->d_unit);				fatal_error++;				continue;			}						/* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */			/* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */			if (dp->d_slave != UNKNOWN) {				printf("slave numbers should be given only ");				printf("for massbus tapes, not for %s%d\n",				    dp->d_name, dp->d_unit);				fatal_error++;				continue;			}			if (dp->d_vec != 0) {				printf("interrupt vectors should not be ");				printf("given for drive %s%d\n",				    dp->d_name, dp->d_unit);				fatal_error++;				continue;			}			if (dp->d_addr != 0) {				printf("csr addresses should be given only ");				printf("on controllers, not on %s%d\n",				    dp->d_name, dp->d_unit);				fatal_error++;				continue;			}			slave = dp->d_drive;		}		fprintf(fp, "{ &%sdriver,\t\"%s\",  %2d,  0, %s,",		    directconn? dp->d_name : mp->d_name, 		    dp->d_name, dp->d_unit,		    qu(dp->d_adaptor));		fprintf(fp, "  %s, ",  qu(dp->d_nexus)); 		fprintf(fp, "  %s, ",  qu(dp->d_rcntl)); 		fprintf(fp, "  %s, ", qu(uba_n));		fprintf(fp, "  %s, ",directconn? " -1" : qu(mp->d_unit));		if (dp->d_drive == QUES && can_wildcard(dp->d_name) ) { 			if ((eq(dp->d_name, "ra")) || (eq(dp->d_name, "tms")))			    fprintf(fp, "  %s,",qumscp(slave));			else			    fprintf(fp, "   %s,",qu(slave));			fprintf(fp, "  %s,  C 0%o,  C 0%o,  %d,",			    intv(dp), dp->d_addr,dp->d_addr2,dp->d_dk);		    }		    else			fprintf(fp, "  %2d,  %s,  C 0%o,  C 0%o,  %d,",		    	    slave, intv(dp), dp->d_addr, dp->d_addr2,dp->d_dk);		fprintf(fp, "  0x%x,",		    dp->d_flags);		fprintf(fp,"  %d,  0x%x", dp->d_pri, dp->d_ivnum);		fprintf(fp, " },\n\n");		if(can_connect(mp->d_name)&& directconn) {			/* dump out a bus structure for the unmentioned			 * parent			 */		   print_tree(dp->d_conn,fpb);		   fprintf(fpb,"\t{\"%s\", %s,C &%sdriver, %d, 'D', 0, -1, -1},\n",			mp->d_name, qu(mp->d_unit), dp->d_name, dp->d_unit);		}	}	fprintf(fpb, "\t0\n};\n");	fprintf(fp, "\t0\n};\n\n#include \"iobus.c\"\n\n", extrauba);	/* dump out the error dispatch tables for each bus */	if (ci_bus.max_bus_num > 0) dump_dispatch("ci",fp);	if (vaxbi_bus.max_bus_num > 0) dump_dispatch("vaxbi",fp);	if (xmi_bus.max_bus_num > 0) dump_dispatch("xmi",fp);	if (vba_bus.max_bus_num > 0) dump_dispatch("vba",fp);     /*PAUL*/	(void) fclose(fp);	if (fatal_error)		exit(1);}#if MACHINE_SUNsun_ioconf(){	register struct device *dp, *mp;	register int slave;	FILE *fp;	fp = fopen(path("ioconf.c"), "w");	if (fp == 0) {		perror(path("ioconf.c"));		exit(1);	}	fprintf(fp, "#include \"../h/param.h\"\n");	fprintf(fp, "#include \"../h/buf.h\"\n");	fprintf(fp, "#include \"../h/map.h\"\n");	fprintf(fp, "#include \"../h/vm.h\"\n");	fprintf(fp, "\n");	fprintf(fp, "#include \"../sundev/mbvar.h\"\n");	fprintf(fp, "\n");	fprintf(fp, "#define C (caddr_t)\n\n");	fprintf(fp, "\n");	/*	 * Now generate interrupt vectors for the Multibus	 */	for (dp = dtab; dp != 0; dp = dp->d_next) {		if (dp->d_pri != 0) {			mp = dp->d_conn;			if (mp == 0 || mp == TO_NEXUS ||			    !eq(mp->d_name, "mb"))				continue;			fprintf(fp, "extern struct mb_driver %sdriver;\n",			    dp->d_name);		}	}	/*	 * Now spew forth the mb_cinfo structure	 */	fprintf(fp, "\nstruct mb_ctlr mbcinit[] = {\n");	fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n");	for (dp = dtab; dp != 0; dp = dp->d_next) {		mp = dp->d_conn;		if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||		    !eq(mp->d_name, "mb"))			continue;		if (dp->d_pri == 0) {			printf("must specify priority for %s%d\n",			    dp->d_name, dp->d_unit);			continue;		}		if (dp->d_addr == 0) {			printf("must specify csr address for %s%d\n",			    dp->d_name, dp->d_unit);			continue;		}		if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {			printf("drives need their own entries; ");			printf("dont specify drive or slave for %s%d\n",			    dp->d_name, dp->d_unit);			continue;		}		if (dp->d_flags) {			printf("controllers (e.g. %s%d) don't have flags, ");			printf("only devices do\n",			    dp->d_name, dp->d_unit);			continue;		}		fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n",		    dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri);	}	fprintf(fp, "\t0\n};\n");	/*	 * Now we go for the mb_device stuff	 */	fprintf(fp, "\nstruct mb_device mbdinit[] = {\n");	fprintf(fp,"\t/* driver,  unit, ctlr,  slave,   addr,    pri,    dk, flags*/\n");	for (dp = dtab; dp != 0; dp = dp->d_next) {		mp = dp->d_conn;		if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||		    mp == TO_NEXUS || mp->d_type == MASTER ||		    eq(mp->d_name, "mba"))			continue;		if (eq(mp->d_name, "mb")) {			if (dp->d_pri == 0) {				printf("must specify vector for device %s%d\n",				    dp->d_name, dp->d_unit);				continue;			}			if (dp->d_addr == 0) {				printf("must specify csr for device %s%d\n",				    dp->d_name, dp->d_unit);				continue;			}			if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {				printf("drives/slaves can be specified only ");				printf("for controllers, not for device %s%d\n",				    dp->d_name, dp->d_unit);				continue;			}			slave = QUES;		} else {			if (mp->d_conn == 0) {				printf("%s%d isn't connected to anything, ",				    mp->d_name, mp->d_unit);				printf("so %s%d is unattached\n",				    dp->d_name, dp->d_unit);				continue;			}			if (dp->d_drive == UNKNOWN) {				printf("must specify ``drive number'' for %s%d\n",				   dp->d_name, dp->d_unit);				continue;			}			/* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */			/* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */			if (dp->d_slave != UNKNOWN) {				printf("slave numbers should be given only ");				printf("for massbus tapes, not for %s%d\n",				    dp->d_name, dp->d_unit);				continue;			}			if (dp->d_pri != 0) {				printf("interrupt priority should not be ");				printf("given for drive %s%d\n",				    dp->d_name, dp->d_unit);				continue;			}			if (dp->d_addr != 0) {				printf("csr addresses should be given only");				printf("on controllers, not on %s%d\n",				    dp->d_name, dp->d_unit);				continue;			}			slave = dp->d_drive;		}		fprintf(fp,"\t{ &%sdriver,  %2d,   %s,    %2d,   C 0x%x, %d,  %d,  0x%x },\n",		    eq(mp->d_name, "mb") ? dp->d_name : mp->d_name, dp->d_unit,		    eq(mp->d_name, "mb") ? " -1" : qu(mp->d_unit),		    slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags);	}	fprintf(fp, "\t0\n};\n");	(void) fclose(fp);}#endifchar *intv(dev)	register struct device *dev;{	static char buf[20];	register struct device *mp = dev->d_conn;	if (dev->d_vec == 0)		return ("     0");	return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit));}char *qu(num){	if (num == QUES)		return ("'?'");	if (num == UNKNOWN)		return (" -1");	return (sprintf(errbuf, "%3d", num));}/* * MSCP devices represent wildcards in the kernel via " -1" instead of '?'. * This is necessary because the '?' is actually a 63 which conflicts with * a valid unit number of 63. */char *qumscp(num){	if ((num == QUES) || (num == UNKNOWN))		return ("-1");	return (sprintf(errbuf, "%3d", num));}char  *tbl_can_connect[] = { "uba","mba","vaxbi","vba","kdb","klesib","klesiu",			     "aio","aie", "uda", "ci", "msi","ibus", "xmi", 			     "kdm", 0};/* * can things connect to this name? */can_connect(name)register	char *name;{    register	char	**ptr = tbl_can_connect;        while(*ptr)	{	    if(eq(*ptr,name))return(1);	    ptr++;	}    return(0);}char  *tbl_can_wildcard[] = { "ra","tms" };/* * does this device type allow wildcarded slaves */can_wildcard(name)register	char *name;{    register	char	**ptr = tbl_can_wildcard;        while(*ptr)	{	    if(eq(*ptr,name))return(1);	    ptr++;	}    return(0);}char *tbl_needs_vector[] = {  "uba", "vaxbi","vba","aio","aie", "kdb", "klesib",			      "uda", "klesiu", "klesiq", "xmi", 			      "kdm", 0  };/* * needs_vector(name) things connect to this device need to supply a vector */needs_vector(name)register char *name;{    register char **ptr = tbl_needs_vector;        while(*ptr)	{	    if(eq(*ptr,name))return(1);	    ptr++;	}    return(0);}char *tbl_needs_csr[] = { "uba", "uda", 0};/* * needs_csr(name) * things connect to this device need to specify a csr. */needs_csr(name)register char *name;{    register char **ptr = tbl_needs_csr;        while(*ptr)	{	    if(eq(*ptr,name))return(1);	    ptr++;	}    return(0);}/* * print_tree(dp, fpb) * */print_tree(dp, fpb)register  struct device *dp;register  FILE *fpb;{    register	struct device *mp = dp->d_conn;        if(mp == TO_NEXUS || eq(dp->d_name,"uba") || eq(dp->d_name,"ci") 	|| eq(dp->d_name,"msi") || mp == 0)	return;        print_tree(dp->d_conn,fpb);        fprintf(fpb,"\t{\"%s\", %s, C \"%s\", %d, 'A', 0, -1, -1},\n",	 mp->d_name, qu(mp->d_unit), dp->d_name, dp->d_unit);}/* *dump out a adapter line for the named device. */dump_adapt(str,fpb,bus_info)register	char	*str;register	FILE	*fpb;struct bus_info *bus_info;{    register	struct device *dp, *mp;       bus_info->max_bus_num = 0;    bus_info->cnt = 0;    for (dp = dtab; dp != 0; dp = dp->d_next) {	if(eq(dp->d_name,str)) 	    {		print_tree(dp,fpb);				if ((mp = dp->d_conn) == TO_NEXUS) 		{			fprintf(fpb,"\t{\"%s\", '%s', C \"%s\", %d, 'A', 0, -1, -1},\n",				"nexus", "?", dp->d_name, dp->d_unit);			if ((dp->d_unit+1) > bus_info->max_bus_num) {				 bus_info->max_bus_num = dp->d_unit+1;			}			if (dp->d_unit != -1) bus_info->cnt++;					} else {		    fprintf(fpb,"\t{\"%s\", %s, C \"%s\", %d, 'A', 0, -1, -1},\n",			  mp->d_name, qu(mp->d_unit), dp->d_name, dp->d_unit);		}					    			    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -