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

📄 scs.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
#ifndef	lint static char *sccsid = "@(#)scs.c	4.1      (ULTRIX)        7/17/90";#endif	lint/************************************************************************ *                                                                      * *                      Copyright (c) 1989 by                           * *              Digital Equipment Corporation, Maynard, MA              * *                      All rights reserved.                            * *                                                                      * *   This software is furnished under a license and may be used and     * *   copied  only  in accordance with the terms of such license and     * *   with the  inclusion  of  the  above  copyright  notice.   This     * *   software  or  any  other copies thereof may not be provided or     * *   otherwise made available to any other person.  No title to and     * *   ownership of the software is hereby transferred.                   * *                                                                      * *   The information in this software is subject to change  without     * *   notice  and should not be construed as a commitment by Digital     * *   Equipment Corporation.                                             * *                                                                      * *   Digital assumes no responsibility for the use  or  reliability     * *   of its software on equipment which is not supplied by Digital.     * *                                                                      * ************************************************************************ * * *   Facility:	SCS data structure formatter for the crash utility. * *   Abstract:	This module contains the routines used to display the *		contents of SCS data structures.  Routines are also *		provided to traverse data structure lists. * *   Author:	Tim Burke	November 22, 1989 * *   Modification History: * */#include 	<ctype.h>#include 	<sys/types.h>#include 	<sys/time.h>#include 	<sys/param.h>#include 	<sys/ksched.h>#include 	<sys/dyntypes.h>#include 	<sys/limits.h>#include 	<sys/utsname.h>#include 	<sys/kmalloc.h>#include 	<sys/errlog.h>#include 	<sys/smp_lock.h>#include	<io/scs/sca.h>#include	<io/scs/scaparam.h>#include	<io/scs/scamachmac.h>#include	<io/ci/cippdsysap.h>#include	<io/ci/cisysap.h>#include	<io/msi/msisysap.h>#include	<io/bi/bvpsysap.h>#include	<io/gvp/gvpsysap.h>#include	<io/uba/uqsysap.h>#include	<io/sysap/sysap.h>#include	<io/ci/cippdscs.h>#include	<io/ci/ciscs.h>#include	<io/msi/msiscs.h>#include	<io/bi/bvpscs.h>#include	<io/gvp/gvpscs.h>#include	<io/uba/uqscs.h>#include	<io/scs/scs.h>#include        "crash.h"#include        <stdio.h>/* * Defines local to this program. *//* * MSCP printing levels - controls ammount of output. */#define MSCP_PRINTFULL	0x01		/* Verbose printing		*/#define MSCP_PRINTBRIEF	0x02		/* Brief printing		*//* * SCS printing levels - controls ammount of output. */#define SCS_PRINTFULL   0x01            /* Verbose printing             */#define SCS_PRINTBRIEF  0x02            /* Brief printing               *//* * Types of queues pointed to by _pbq's and _cbq's. */#define	X_PATHB		1	/* Path block queue			*/#define	X_TIMEOUT	2	/* SCS protocol seq timeout pb queue	*/#define	X_CBS		3	/* Connection block queue		*/#define	X_SCS_CB	4	/* SCS waiting connection block queue	*/char *token();c_scs(c)	char *c;{	char *arg;	int index;	unsigned int addr;		arg = token();	if (arg == NULL) {		(void)printscs(0, SCS_PRINTFULL);		return;	}	else if (strcmp(arg,"-sb") == 0) {		arg = token();		if (arg == NULL) {			printf("usage: -sb requires address\n");			return;		}		addr = scan_vaddr(arg);		(void)printscs_system_block(addr, SCS_PRINTFULL);	}	else if (strcmp(arg,"-pb") == 0) {		arg = token();		if (arg == NULL) {			printf("usage: -pb requires address\n");			return;		}		addr = scan_vaddr(arg);		(void)printscs_pb(addr, SCS_PRINTFULL);	}	else if (strcmp(arg,"-pib") == 0) {		arg = token();		if (arg == NULL) {			printf("usage: -pib requires address\n");			return;		}		addr = scan_vaddr(arg);		(void)printscs_pib(addr, SCS_PRINTFULL);	}	else if (strcmp(arg,"-cb") == 0) {		arg = token();		if (arg == NULL) {			printf("usage: -cb requires address\n");			return;		}		addr = scan_vaddr(arg);		(void)printscs_cb(addr, SCS_PRINTFULL);	}	else if (strcmp(arg,"-sib") == 0) {		arg = token();		if (arg == NULL) {			printf("usage: -sib requires address\n");			return;		}		addr = scan_vaddr(arg);		(void)printscs_sib(addr, SCS_PRINTFULL);	}	else if (strcmp(arg,"-cib") == 0) {		arg = token();		if (arg == NULL) {			printf("usage: -cib requires address\n");			return;		}		addr = scan_vaddr(arg);		(void)printscs_cib(addr, SCS_PRINTFULL);	}	else {		printf("Invalid scs parameter: %s\n",arg);	}	while(token()!=NULL);}/* * *   Name:	printscs	- Traverse and display data structs * *   Abstract:	This routine will start at the globaly defined scs  *		scs configuration database pointer (scs_config_db) and *	        traverse the data structures printing results. * *   Inputs:    subsys_name 	- The name of the particular subsystem. *		printmode	- Controlls output level. * *   Return	NONE *   Values: */int printscs(subsys_name, printmode)    int		subsys_name;    int		printmode;{        sbq *scs_config_db;	printf("\n.................... SCS SUBSYSTEM  .....................\n");	scs_config_db = (sbq *)Scs_config_db.s_value;	printf("\tscs_config_db address is 0x%x\n",scs_config_db);	scs_follow_systems(printmode);}/* * *   Name:	scs_follow_systems	- Follow a list of system blocks *			starting at the global address "_scs_config_db". * *   Abstract:	This routine is used to traverse the scs system blocks. *		call the appropriate routine to print out the contents of *		the system blocks. * *   Inputs:     *		printmode	- Controlls output level. * *   Return	NONE *   Values: */int scs_follow_systems(printmode)    int		printmode;{	sbq *scs_config_db;	sbq config_db;	sbq *sb_ptr;	SB sb_st;	scs_config_db = (sbq *)Scs_config_db.s_value;	if (scs_config_db == 0) {		printf("\tNULL scs_config_db\n");		return;	}	if(readmem((char *) &config_db, (int)scs_config_db, sizeof(sbq)) !=	    sizeof(sbq)) {		printf("could not read scs_config_db at 0x%x.\n",scs_config_db);		return;	}	if ((config_db.flink == config_db.blink) &&	    (config_db.flink == (sbq *)scs_config_db)) {		printf("\n\tThe forward and backward pointer of the\n");		printf("\tscs_config_db are the same and point to the\n");		printf("\ttscs_config_db itself.\n");		return;	}		sb_ptr = config_db.flink;	do {	    printscs_system_block(sb_ptr, printmode);	    if(readmem((char *) &sb_st, (int)sb_ptr, sizeof(SB)) !=	        sizeof(SB)) {		    printf("could not read system block at 0x%x\n",sb_ptr);		    return;	    }	    sb_ptr = sb_st.flink;	} while  (sb_ptr != (sbq *)scs_config_db);}/* * *   Name:	printscs_system_block	- Print contents of a system block * *   Abstract:	Disect and display a system block. * *   Inputs:    sb_ptr	 	- Pointer to a system block *		printmode	- Controlls output level. * *   Return	NONE *   Values: */int printscs_system_block(sb_ptr, printmode)    sbq		*sb_ptr;    int		printmode;{	SB sb_st;	int offset;	printf("\n\t*****************  SYSTEM BLOCK  ******************\n");	if (sb_ptr == 0) {		printf("\tNULL system block pointer\n");		return;	}	if(readmem((char *) &sb_st, (int)sb_ptr, sizeof(SB)) !=	    sizeof(SB)) {		printf("could not read system block at 0x%x.\n",sb_ptr);		return;	}    if (printmode & SCS_PRINTFULL) {	printf("\tSystem block address is 0x%x\n",sb_ptr);	printf("\tflink: 0x%x, blink: 0x%x\n",sb_st.flink, sb_st.blink);	printf("\tsize: %d, type: 0x%x\n",sb_st.size, sb_st.type);	offset = (int)(&sb_st.pbs.flink) - (int)(&sb_st.flink);	printscs_pbq((char *) ((char *)sb_ptr + offset), printmode, X_PATHB);	offset = (int)(&sb_st.sinfo.sysid) - (int)(&sb_st.flink);	printscs_sib((char *) ((char *)sb_ptr + offset), printmode);    }}/* * *   Name:	printscs_pbq	- Print contents of a path block queue head. * *   Abstract:	Disect and display a path block queue head. * *   Inputs:    pbq_ptr	 	- Pointer to a path block queue head. *		printmode	- Controlls output level. * *   Return	NONE *   Values: */int printscs_pbq(pbq_ptr, printmode, pbq_type)    pbq		*pbq_ptr;    int		printmode;    int		pbq_type;{	pbq pbq_st;	char *printstring;	switch (pbq_type) {		case X_PATHB: printstring = "path block"; break;		case X_TIMEOUT: printstring = "timeout"; break;		default: printstring = "UNKNOWN"; 	}        if (pbq_ptr == 0) {	    printf("\tNULL %s queue head.\n",printstring);	    return;        }	printf("\t%s queue: ", printstring);	if(readmem((char *) &pbq_st, (int)pbq_ptr, sizeof(pbq)) !=	    sizeof(pbq)) {		printf("could not read %s queue head at 0x%x.\n", printstring,			pbq_ptr);		return;	}    if (printmode & SCS_PRINTFULL) {	printf("flink 0x%x, blink 0x%x",pbq_st.flink, pbq_st.blink);    }    printf("\n");    printscs_follow_pbq(pbq_ptr, printmode); }/* * *   Name:	printscs_sib	- Print contents of a system information block. * *   Abstract:	Disect and display a system information block queue head. * *   Inputs:    sib_ptr	 	- Pointer to a system information block. *		printmode	- Controlls output level. * *   Return	NONE *   Values: */int printscs_sib(sib_ptr, printmode)    SIB		*sib_ptr;    int		printmode;{	SIB sib_st;	int i;	char c;	printf("\t------------- SYSTEM INFORMATION BLOCK ----------\n");        if (sib_ptr == 0) {	    printf("\tNULL system information block pointer.\n");	    return;        }	if(readmem((char *) &sib_st, (int)sib_ptr, sizeof(SIB)) !=	    sizeof(SIB)) {		printf("could not read system information block at 0x%x.\n",			sib_ptr);		return;	}    if (printmode & SCS_PRINTFULL) {	printf("\tSystem information block address is 0x%x\n",sib_ptr);	printscs_scaddr((c_scaaddr *) sib_ptr, printmode); 	printf("\tnpaths: %d, max_dg: %d, max_msg: %d\n", sib_st.npaths,		sib_st.max_dg, sib_st.max_msg);	printf("\tswtype: ");		for (i=0; i < 4; i++) {			c = (u_char)(sib_st.swtype >> 8*i);			if (isprint(c))				printf("%c",c);		}	printf(", swver: ");		for (i=0; i < 4; i++) {			c = (u_char)(sib_st.swver >> 8*i);			if (isprint(c))				printf("%c",c);		}	printf(", swincrn: 0x%x\n", sib_st.swincrn);	printf("\thwtype: ");		for (i=0; i < 4; i++) {			c = (u_char)(sib_st.hwtype >> 8*i);			if (isprint(c))				printf("%c",c);		}	printf(", hwver: %d, %d, %d\n", 		sib_st.hwver.val[0], sib_st.hwver.val[1], sib_st.hwver.val[2]);	printf("\tnode_name: ");	for (i=0; i < NODENAME_SIZE; i++) {	    if (isprint(sib_st.node_name[i]))		printf("%c",sib_st.node_name[i]);	}    }    printf("\n");}/* * *   Name:	printscs_scaddr	- Print a system identification number. * *   Abstract:	Disect and display a system identification number. * *   Inputs:    scaddr_ptr	 	- Pointer to a system type c_scaaddr *		printmode		- Controlls output level. * *   Return	NONE *   Values: */int printscs_scaddr(scaddr_ptr, printmode)    c_scaaddr	*scaddr_ptr;    int		printmode;{	c_scaaddr scaddr_st;	int i;	printf("\tSystem Identification Number: ");        if (scaddr_ptr == 0) {	    printf("\tNULL System ID pointer.\n");	    return;        }

⌨️ 快捷键说明

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