getconfig.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 721 行 · 第 1/2 页

C
721
字号
     	     */    	    udevice_offset = reset_anythg(NL_ubdinit);    	    udevice_cnt = 0;	    while(get_uba_device(ui)) {	        if(ui->ui_alive == 0) {		    switch(CPU) {		    case DS_3100:		    case DS_5100:		    case DS_5000:		    case DS_5000_100:		    case C_VAXSTAR:		    case VAX_60:	        	if(strcmp(ui->ui_devname,"rz") != 0 && 				strcmp(ui->ui_devname, "tz") != 0)			    continue;			break;		    default:			continue;			break;		    }		}		/* Check if device belongs to this controller */		if((um->um_ctlr == ui->ui_ctlr) &&		    		(um->um_driver == ui->ui_driver))		    add_alive_device(UNIBUS, DEVICE, 0, um, ui, 0, 0);    	    }        }	/* Found a DEVICE type reference */        else if(c_adpt->c_type == 'D') {	    ui = (struct uba_device *)c_adpt->c_ptr;	    if(ui == NULL || ui->ui_alive == 0)	        continue;	    add_alive_device(UNIBUS, DEVICE, c_adpt, 0, ui, 0, 0);        }    }    /*     * Now loop through the "mbdinit" and "mbsinit" structures      * and find all the alive controllers and devices on the      * MASSBUS. This is done only if the system has any MASSBUS     * ADAPTERS. The variable "nummbas" is set to the number of     * MASSBUS ADAPTERS the system has.     */    if(nl[NL_mbhead].n_type != N_UNDF)        nummbas = get_nummbas();	    adapter.c_name = "mba";    adapter.p_name = "nexus";    adapter.p_num = (int) '?';    for(i=0; i<nummbas; i++) {	adapter.c_num = i;	add_alive_device(MASSBUS, ADAPTER, &adapter, 0, 0, 0, 0);    }    /* Find number of MASSBUS DEVICE CONTROLLERS */    mdevice_offset = reset_anythg(NL_mbdinit);    mdevice_cnt = 0;    while(nl[NL_mbdinit].n_type != N_UNDF && nummbas && get_mba_device(mi)) {    	if(mi->mi_alive == 0)    	    continue;        add_alive_device(MASSBUS, CONTROLLER, 0, 0, 0, mi, 0);    }    /* Find number of MASSBUS SLAVE DEVICES */    mslave_offset = reset_anythg(NL_mbsinit);    mslave_cnt = 0;    while(nl[NL_mbsinit].n_type != N_UNDF && nummbas && get_mba_slave(ms)) {	if(ms->ms_alive == 0)	    continue;	add_alive_device(MASSBUS, DEVICE, 0, 0, 0, 0, ms);    }    /* Now find devices in FLOATING ADDRESS SPACE */    getfloat(numubas);    /* Print out configuration information for all device types */    printdevice();}/***************************************************************** Name:		printdevice					**    								** Abstract:	Print out the alive device information to the 	**		configuration file. This routine loops through	**		the alive device list table "adltbl[]" and 	**		prints out the alive ADAPTERS, CONTROLLERS, and **		DEVICES information to the configuration file.	**								** Inputs:	None.						**								** Outputs:	None.						**								** Return Values: None.						*****************************************************************/printdevice(){	struct alive_device_list *adl;	int index, nodeindex, i;	char tdevname[DEVNAMESIZE], tconname[DEVNAMESIZE];	char *unsupported = "#UNSUPPORTED";	char *harddevstr;	/* Loop through the alive device linked list */	for(i=0; i<ADLINDEX; i++) {		/* Get device index and node index */		index = adltbl[i].device_index;		nodeindex = adltbl[i].node_index;		/* Print out for an unsupported device */		if(index == -1) {			sprintf(tdevname, "%s", adltbl[i].unsupp_devname);			if(adltbl[i].conn_number == (int) '?')			    sprintf(tconname, "%s?", adltbl[i].conn_name);			else			    sprintf(tconname, "%s%d",		    	    	adltbl[i].conn_name, adltbl[i].conn_number);			fprintf(fp, "%-16s%-10s at %-10s", unsupported,					tdevname, tconname);			if(nodeindex != -1) {		    	    if(nodetbl[nodeindex].nodetype == VAXBINODE)	        		fprintf(fp, "%s%d  ", 					nodetbl[nodeindex].nodename,						adltbl[i].node_number);		    	    else if(nodetbl[nodeindex].nodetype == XMINODE)	        		fprintf(fp, "%s%d  ", 					nodetbl[nodeindex].nodename,						adltbl[i].node_number);		    	    else if(nodetbl[nodeindex].nodetype == CINODE)	        		fprintf(fp, "%s %d  ", 					nodetbl[nodeindex].nodename,						adltbl[i].rctlr);		    	    else if(nodetbl[nodeindex].nodetype == MSINODE)	        		fprintf(fp, "%s %d  ", 					nodetbl[nodeindex].nodename,						adltbl[i].rctlr);			}			if(adltbl[i].csr != -1)		    		printcsr(i);			if(adltbl[i].device_drive != -1)				fprintf(fp, "drive %d", adltbl[i].device_drive);			fprintf(fp, "\n");			continue;		}		/* Print out the device type */		harddevstr = hardtbl[devtbl[index].devtype].typename;		if(devtbl[index].supportedflag)		    	fprintf(fp, "%-16s", harddevstr);		else		    	fprintf(fp, "#%-16s", harddevstr);		/* Print out the device name and the connection name */		sprintf(tdevname, "%s%d",				devtbl[index].devname, adltbl[i].device_unit);		if(devtbl[index].devtype == ADAPTER &&				adltbl[i].conn_number == (int) '?')			sprintf(tconname, "%s?", adltbl[i].conn_name);		else			sprintf(tconname, "%s%d",		    	    	adltbl[i].conn_name, adltbl[i].conn_number);		if(strncmp(tconname,"ibus",4) == 0)			strcpy(tconname, "ibus?");		fprintf(fp, "%-10s at %-10s", tdevname, tconname);		/* If device is a "ci" adapter then set "scs_sysidflag" */		if(devtbl[index].devtype == ADAPTER &&				strcmp(devtbl[index].devname,"ci") == 0)			scs_sysidflag++;		/* Print out the node type if one exists */		if(nodeindex != -1) {		    if(nodetbl[nodeindex].nodetype == VAXBINODE)	        	fprintf(fp, "%s%d  ", nodetbl[nodeindex].nodename,					adltbl[i].node_number);		    else if(nodetbl[nodeindex].nodetype == XMINODE)	        	fprintf(fp, "%s%d  ", nodetbl[nodeindex].nodename,					adltbl[i].node_number);		    else if(nodetbl[nodeindex].nodetype == CINODE)	        	fprintf(fp, "%s %d  ", nodetbl[nodeindex].nodename,					adltbl[i].rctlr);		    else if(nodetbl[nodeindex].nodetype == MSINODE)	        	fprintf(fp, "%s %d  ", nodetbl[nodeindex].nodename,					adltbl[i].rctlr);		}		/* Print out the csr if one exists */		if(adltbl[i].csr != -1)		    	printcsr(i);		/* Print out the flags if any exists */	    	if(devtbl[index].flags)			fprintf(fp, "flags 0x%x  ", devtbl[index].flags);		/* Print out the interrupt vectors if any exists */	    	if(strlen(devtbl[index].ivectors) != 0)			fprintf(fp, "vector %s ", devtbl[index].ivectors);		/* Print out the drive or slave number if one exists */		if(adltbl[i].device_drive != -1) {		    if((adltbl[i].bus_type == MASSBUS) && 			(devtbl[index].devtype == TAPE))			fprintf(fp, "slave %d", adltbl[i].device_drive);		    else			fprintf(fp, "drive %d", adltbl[i].device_drive);		}		fprintf(fp, "\n");		/* Make special file for this device */		if(devtbl[index].makedevflag && adltbl[i].alive_unit)			printmakedev(i);	}}/***************************************************************** Name:		printcsr					**    								** Abstract:	Print out the CSR address of a device to the	**		configuration file.				**								** Inputs:							** i		The current index in the alive device table.	**								** Outputs:	None.						**								** Return Values: None.						*****************************************************************/printcsr(i)int i;{	long csr;	int index, j;	char tdevname[DEVNAMESIZE], tconname[DEVNAMESIZE];	index = adltbl[i].device_index;	if(index != -1 && strcmp(devtbl[index].devname,"idc") == 0)		adltbl[i].csr = 0175606;	/* Print out the CSR address for this device */	switch(CPU) {	case MVAX_I:	case MVAX_II:	case VAXSTAR:	case VAX_3400:	case VAX_3600:	case VAX_3900:	case C_VAXSTAR:	case VAX_60:	case DS_5400:	case DS_5500:	case DS_5800:		if(CPUSUB == ST_VAXSTAR) {			csr = adltbl[i].csr;			fprintf(fp, "csr 0x%8x  ", csr);		}		else {			csr = adltbl[i].csr;			csr |= 0160000;			fprintf(fp, "csr 0%6o  ", csr);		}		break;	default:		csr = adltbl[i].csr;		fprintf(fp, "csr 0%6o  ", csr);		break;	}	/* Check for a floating address device */	if(csr > 0160000 && csr < 0170000) {		if(!float_flag) {			fprintf(stdout, "The installation software found ");			fprintf(stdout, "these devices in the floating\n");			fprintf(stdout, "address space:\n\n");			float_flag = 1;		}		if(index != -1) {			if(devtbl[index].devtype == CONTROLLER)				j = i - 1;			else				j = i;			index = adltbl[j].device_index;			sprintf(tdevname, "%s%d",				devtbl[index].devname, adltbl[j].device_unit);		}		else {			j = i;			sprintf(tdevname, "%s", adltbl[j].unsupp_devname);		}		sprintf(tconname, "%s%d",		    		adltbl[j].conn_name, adltbl[j].conn_number);		fprintf(stdout, "\t%-10s\t", tdevname);		fprintf(stdout, "on %-10s\t", tconname);		fprintf(stdout, "at 0%o\n", csr);	}}/***************************************************************** Name:		printmakedev					**    								** Abstract:	Print out the MAKEDEVICE information to the 	**		makedevices file.				**								** Inputs:							** i		The current index in the alive device table.	**								** Outputs:	None.						**								** Return Values: None.						*****************************************************************/printmakedev(i)int i;{	int index, number;	long offset;	char devname[20];	/* Print the the MAKEDEV entry for this device */	index = adltbl[i].device_index;	sprintf(devname, "%s%d", devtbl[index].devname,			adltbl[i].device_unit);	switch(CPU) {	case MVAX_I:	case MVAX_II:	case VAXSTAR:	case VAX_3400:	case VAX_3600:	case VAX_3900:	case C_VAXSTAR:	case VAX_60:	case DS_5400:	case DS_5500:	case DS_5800:		/* Special cases for "dz" and "dhu" devices */		if(strcmp(devtbl[index].devname, "dz") == 0)		    sprintf(devname, "dzv%d", adltbl[i].device_unit);		else if(strcmp(devtbl[index].devname, "dhu") == 0)		    sprintf(devname, "dhv%d", adltbl[i].device_unit);		break;	default:		break;	}	/* Special cases for "dmb" devices */	if(strcmp(devtbl[index].devname, "dmb") == 0) {		number = adltbl[i].device_unit;		offset = reset_anythg(NL_dmb_lines);		offset = lseek(kmem,offset+number*4, 0);		read(kmem, &number, sizeof(number));		if(number == 16)			sprintf(devname,"dhb%d",adltbl[i].device_unit);		else			sprintf(devname,"dmb%d",adltbl[i].device_unit);	}	fprintf(fpdevs, "%s  ", devname);}

⌨️ 快捷键说明

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