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

📄 misc.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char *sccsid = "@(#)misc.c	4.1      (ULTRIX)        7/17/90";#endif/************************************************************************ *									* *			Copyright (c) 1988-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.			* *									* *   This software is  derived  from  software  received  from  the	* *   University    of   California,   Berkeley,   and   from   Bell	* *   Laboratories.  Use, duplication, or disclosure is  subject  to	* *   restrictions  under  license  agreements  with  University  of	* *   California and with AT&T.						* *									* *   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.	* *									* ************************************************************************//* * History: * * 02-Mar-90  Janet Schank *      siisc is no longer used.  Both vax and mips now use sz_softc. *      Changed Nscsi to Nscsibus. * */#include	<sys/types.h>#define KERNEL#include <sys/time.h>#undef KERNEL#include	"crash.h"#include	<sys/gnode.h>#include	<sys/proc.h>#include	<sys/smp_lock.h>#define KERNEL#include	<sys/file.h>#include	<sys/text.h>#include	<sys/buf.h>#include	<sys/callout.h>#include	<sys/mount.h>#undef KERNEL#include	<strings.h>#include	<sys/cmap.h>#include	<sys/socket.h>#include	<sys/socketvar.h>#include	<net/if.h>#include	<netinet/in.h>#include	<arpa/inet.h>#include	<netinet/if_ether.h>#include	<nfs/dnlc.h>#define	SEGBYTES	0x40000000L	/* power of 2 to the 30th */#define	CORECLKS	512		/* Core Clicks */#define	BITMASK		0777		/* Remove low order bits */extern	struct	dstk	dmpstack;extern	struct	glop	dumpglop;extern	struct	uarea	x;fatal(str)	char	*str;{	printf("error: %s\n", str);	(void)exit(1);}error(str)	char	*str;{	printf("error: %s\n", str);}#ifdef notdefintatoi(s)	char *s;{	int i;	if (s == NULL) error ("illegal integer");	if(s[0] != '0') {		if (!sscanf(s,"%d",&i)) {			error ("illegal integer");			return(-1);		}		return(i);	}	if (s[1] == '\0') return(0);	if ((s[1] == 'x') || (s[1] == 'X')) {		if (s[2] == '\0') {			error ("illegal integer");			return(-1);		}		if (!sscanf(&s[2],"%x",&i)) {			error ("illegal integer");			return(-1);		}		return(i);	}	if (!sscanf(s,"%o",&i)) {		error ("illegal integer");		return(-1);	}	return(i);}#endifunsigned intscan_vaddr(s)	char *s;{	unsigned i;	if (s == NULL) error ("bad address format");	if (s[0] == '0') {		if (s[1] == '\0') return(0);		if (((s[1] != 'x') && (s[1] != 'X')) || 		    (s[2] == '\0') || !sscanf(&s[2],"%x",&i))			error ("bad address format");	}	else if (!sscanf(s,"%x",&i)) error ("bad address format");	return(i);}		struct tabsum tab[TABSUM_MAX];struct mapsum map[MAPSUM_MAX];unsigned int slr, sbr;struct buckets *gnodebuckets[GNODEBUCKETS];struct buckets *filebuckets[FILEBUCKETS];struct buckets *mountbuckets[MOUNTBUCKETS];struct buckets *bufbuckets[BUFBUCKETS];struct buckets *procbuckets[PROCBUCKETS];init(){	extern	char	*dumpfile;	extern	struct	dstk	dmpstack;	extern	int	Kfp;	extern	char	*namelist;	extern	struct	Symbol	*stbl;	extern	void	sigint();	extern  struct user USER;	extern  struct buf bfreelist[];	struct	sigvec	vec;	int	i;	struct	Symbol *mapsym;	char *malloc();	struct	Symbol	*symsrch(), *tmp;		/*	 * Initialize the Symbol structures for devices which	 * might NOT exist.	 */	bzero(&Mscp_classb, sizeof(struct Symbol));	bzero(&Tmscp_classb, sizeof(struct Symbol));	bzero(&Mscp_utable, sizeof(struct Symbol));	bzero(&Tmscp_utable, sizeof(struct Symbol));	bzero(&Sz_softc, sizeof(struct Symbol));	bzero(&Nscsibus, sizeof(struct Symbol));	bzero(&Scs_config_db, sizeof(struct Symbol));	bzero(&Ports, sizeof(struct Symbol));		if ((mem = open (dumpfile,O_RDONLY,0)) < 0)		fatal("cannot open dump file");	rdsymtab();		/*	 * Find the symbol table entries for the symbols we need.	 */#ifdef vax	Usrptma = *symsrch("_Usrptma"); #endif vax#ifdef mips	Usrptma = *symsrch("_Usrptmap");#endif mips	Arptab = *symsrch("_arptab");	Text = *symsrch("_text");	Swap = *symsrch("_swapmap");	Sptbase = *symsrch("_Sysmap");	Sys = *symsrch("_utsname");	Lbolt = *symsrch("_lbolt");	Panic = *symsrch("_panicstr");	Callout = *symsrch("_callout");	Usrpt = *symsrch("_usrpt");	Cmap = *symsrch("_cmap");	Dnlcache = *symsrch("_ncache");	Buffree = *symsrch("_bfreelist");	/* Now we initialize values which are, currently,		configuration dependent */	if ((tmp = symsrch("_mscp_classb")) != NULL)		Mscp_classb = *tmp;	if ((tmp = symsrch("_tmscp_classb")) != NULL)		Tmscp_classb = *tmp;	if ((tmp = symsrch("_mscp_unit_tbl")) != NULL)		Mscp_utable = *tmp;	if ((tmp = symsrch("_tmscp_unit_tbl")) != NULL)		Tmscp_utable = *tmp;	if ((tmp = symsrch("_scs_config_db")) != NULL) 		Scs_config_db = *tmp;	if ((tmp = symsrch("_scs_lport_db")) != NULL) 		Ports = *tmp;	if ((tmp = symsrch("_sz_softc")) != NULL)		Sz_softc = *tmp;	if ((tmp = symsrch("_nNSCSIBUS")) != NULL)		Nscsibus = *tmp;		vaddrinit();	/*	 * Collect some information about kernel tables and store it	 * in the tabsum array for later use.	 */			initfile();	initgnode();	initmount();	initbuf();	initproc();		tab[ARP_T].first = Arptab.s_value;	readsym (symsrch("_arptab_size"), (char *)&tab[ARP_T].ents,		 sizeof(int));	tab[ARP_T].name = "arptab";	tab[ARP_T].size = sizeof(struct arptab);		readsym (&Text, (char *)&tab[TEXT_T].first,sizeof(unsigned));	readsym (symsrch("_ntext"), (char *)&tab[TEXT_T].ents,sizeof(int));	tab[TEXT_T].name = "text";	tab[TEXT_T].size = sizeof(struct text);	readsym (symsrch("_firstfree"),&firstfree,sizeof(int));	readsym (&Cmap, (char *)&tab[CMAP_T].first, sizeof(unsigned));	readsym (symsrch("_ncmap"), (char *)&tab[CMAP_T].ents,sizeof(int));	tab[CMAP_T].name = "cmap";	tab[CMAP_T].size = sizeof(struct cmap);	readsym (&Callout, (char *)&tab[CALLOUT_T].first, sizeof(unsigned));	readsym (symsrch("_ncallout"), (char *)&tab[CALLOUT_T].ents,	    sizeof(int));	tab[CALLOUT_T].name = "callout";	tab[CALLOUT_T].size = sizeof(struct callout);/*	tab[DNLC_T].first = Dnlcache.s_value; */	readsym (&Dnlcache, (char *)&tab[DNLC_T].first, sizeof(unsigned));	readsym (symsrch("_ncsize"), &tab[DNLC_T].ents, sizeof(int));	tab[DNLC_T].name = "dnlcache";	tab[DNLC_T].size = sizeof(struct ncache);	for (i = 0; i < TABSUM_MAX; i++)		tab[i].last = tab[i].first + (tab[i].ents * tab[i].size);	tab[PROC_T].last = (unsigned) 0;	tab[FILE_T].last = (unsigned) 0;	tab[MOUNT_T].last = (unsigned) 0;	tab[GNODE_T].last = (unsigned) 0;	tab[BUF_T].last = (unsigned) 0;	tab[BUFH_T].last = (unsigned) 0;		/*	 * Set up the page table map summaries.	 * WARNING: this code is dependent on the ordering of page	 * table allocations in spt.s.	 */#ifdef vax	mapsym = symsrch("_mbutl");	map[MBUF_SPT].first = mapsym->s_value;	map[MBUF_SPT].name = "Mbmap";	map[MBUF_SPT].descrip = "mbuf pool"; 	mapsym = symsrch("_dmempt");	map[MBUF_SPT].last = mapsym->s_value - 1;	map[DMEM_SPT].first = mapsym->s_value;	map[DMEM_SPT].name = "dmemptmap";	map[DMEM_SPT].descrip = "km_alloc pool";#endif		tab[CMHASH_T].first = Cmhash.s_value;	tab[CMHASH_T].ents = CMHSIZ;	tab[CMHASH_T].name = "cmhash";	tab[CMHASH_T].size = sizeof(int);#ifdef vax	mapsym = symsrch("_vmb_info");	map[DMEM_SPT].last = mapsym->s_value - 1;	readsym (symsrch("_Syssize"), (char *)&slr, sizeof(int));	sbr = Sys.s_value;#endif	/*	 * Set up signal handler so we can trap ctrl-c.	 */	vec.sv_handler = sigint;	vec.sv_mask = 0;	vec.sv_onstack = 0;	if (sigvec(SIGINT, &vec, NULL) < 0)		error ("Trouble with sigvec call.");	}prod(addr, units, style)	unsigned	addr;	int	units;	char	*style;{	register  int  i;	register  struct  prmode  *pp;	int	word;	long	lword;	char	ch;	extern	struct	prmode	prm[];	if(units == -1)		return;	for(pp = prm; pp->pr_sw != 0; pp++) {		if(strcmp(pp->pr_name, style) == 0)			break;	}	if (addr > (unsigned)VIRT_MEM)		addr = sysvad(addr);	if(lseek(mem, (int)(addr & VIRT_MEM), 0) == -1) {		error("bad seek of addr");	}	switch(pp->pr_sw) {	default:	case NULL:		error("invalid mode");		break;	case OCTAL:	case DECIMAL:		if(addr & 03) {			printf("warning: address not word aligned\n");		}		for(i = 0; i < units; i++) {			if(i % 8 == 0) {				if(i != 0)					printf("\n");				printf(FMT, (unsigned)addr + i * NBPW);				printf(":");			}			if(read(mem, (char *)&word, NBPW) != NBPW) {				printf("  read error");				break;			}			printf(pp->pr_sw == OCTAL ? " %7.7o" :				"  %5u", word);		}		break;	case LOCT:	case LDEC:		if(addr & 03) {			printf("warning: address not word aligned\n");		}		for(i = 0; i < units; i++) {			if(i % 4 == 0) {				if(i != 0)					printf("\n");				printf(FMT, (int)addr + i * NBPW);				printf(":");			}			if(read(mem, (char *)&lword, sizeof (long))			    != sizeof (long)) {				printf("  read error");				break;			}			printf(pp->pr_sw == LOCT ? " %12.12lo" :				"  %10lu", lword);		}		break;	case CHAR:	case BYTE:		for(i = 0; i < units; i++) {			if(i % (pp->pr_sw == CHAR ? 16 : 8) == 0) {				if(i != 0)					printf("\n");				printf(FMT, (int)addr + i * sizeof (char));				printf(":");			}			if(read(mem, (char *)&ch, sizeof (char)) !=			    sizeof (char)) {				printf("  read error");				break;

⌨️ 快捷键说明

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