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

📄 scs_subr.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef	lintstatic char *sccsid = "@(#)scs_subr.c	4.1	(ULTRIX)	7/2/90";#endif	lint/************************************************************************ *                                                                      * *                      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.                   * *                                                                      * *   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:	Systems Communication Architecture *		Systems Communication Services * *   Abstract:	This module contains Systems Communication Services( SCS ) *		miscellaneous routines and functions.  Some of these functions *		are invokable only by port drivers while others are for use *		only by SCS.  Still others may be invoked by anyone( SYSAPs, *		SCS, PDs ). * *   Creator:	Todd M. Katz	Creation Date:	July 7, 1985 * *   Function/Routines: * *   scs_alloc_buf		Allocate all Message and Datagram Buffers *   scs_choose_path		Choose Path for New Connection *   scs_dealloc_buf		Deallocate all Message and Datagram Buffers *   scs_dispose_msg		Dispose of Application Message Buffer *   scs_init_cmsb		Initialize CMSB for Notifying SYSAP of Event *   scs_initialize		Initialize SCS *   scs_unix_to_vms		Convert UNIX Time to VMS Time * *   Modification History: * *   14-Sep-1989	Pete Keilty *	1. Add bcopy for strings instead of cast u_long assign. *	   Mips cpu's needed this for alignment. *	2. Removed ifdef mips and ifdef vax which where no longer needed. * *   30-May-89		Darrell A. Dunnuck *	Added include of ../../machine/common/cpuconf.h -- cpu types *	were moved there.  Removed the include of ../machine/cpu.h. * *   06-Apr-1989	Pete Keilty *	Added include file smp_lock.h * *   03-Mar-1989	Todd M. Katz		TMK0003 *	1. Modify scs_init_cmsb() to always return the connection *	   identification number regardless of event status. *	2. Include header file ../vaxmsi/msisysap.h. *	3. Use the ../machine link to refer to machine specific header files. * *   05-Jul-1988	Todd M. Katz		TMK0002 *	1. Include limits.h from ../h instead of from /usr/include. *	2. Macros Copy_name() and Copy_data() have been renamed to Move_name() *	   and Move_data() respectively. * *   02-Jun-1988	Ricky S. Palmer *	Removed inclusion of header file ../vaxmsi/msisysap.h * *   08-Jan-1988	Todd M. Katz		TMK0001 *	Formated module, revised comments, increased robustness, restructured *	code paths, and added SMP support. *//* Libraries and Include Files. */#include		"../h/types.h"#include		"../h/time.h"#include		"../h/param.h"#include		"../h/ksched.h"#include		"../h/dyntypes.h"#include		"../h/limits.h"#include		"../h/utsname.h"#ifdef vax#include		"../machine/mtpr.h"#endif vax#include		 "../../machine/common/cpuconf.h"#include		"../h/kmalloc.h"#include		"../h/errlog.h"#include		"../h/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"/* External Variables and Routines. */extern	struct timezone	tz;extern	int		cpu;extern	SCSIB		lscs;extern	struct utsname	utsname;extern	struct timeval  boottime;extern	struct lock_t	lk_scadb;extern	CBVTDB		*scs_cbvtdb;extern	scaaddr		scs_system_id;extern	void		( *scs_disable )(), scs_shutdown(), scs_unix_to_vms();extern	u_char		*cpu_types[], scs_node_name[];extern	u_long		scs_cushion, scs_dg_size, scs_max_conns, scs_msg_size;/*   Name:	scs_alloc_buf	- Allocate all Message and Datagram Buffers * *   Abstract:	This function allocates all requested message and datagram *		buffers and adds them to the appropriate port's free message *		and datagram pools. * *		Partial allocation of either datagram or message buffers may *		occur. * *   Inputs: * *   IPL_SCS			- Interrupt processor level *   cb				- Connection Block pointer *   ndgs			- Number of datagrams to allocate and add *   nmsgs			- Number of messages to allocate and add * *   Outputs: * *   IPL_SCS			- Interrupt processor level *   cb				- Connection Block pointer *	cinfo.dg_credit		-  Number of datagram credits *	cinfo.pend_rec_credit	-  Number of credits pending extension * *   Return Values: * *   RET_SUCCESS		- Successful buffer allocation *   RET_ALLOCFAIL		- Unsuccessful buffer allocation * *   SMP:	The CB is locked( EXTERNALLY ) to synchronize access and *		prevent premature deletion whenever it formerly resided within *		the system-wide configuration database.  It is locked through *		its CBVTE. * *		The PB itself must NOT be EXTERNALLY locked as required by the *		PD routines which add datagram and message buffers to the *		appropriate local port datagram and message free pools. */u_longscs_alloc_buf( cb, nmsgs, ndgs )    register CB		*cb;    u_long		nmsgs;    u_long		ndgs;{    register SCSH	*scsbp;    /* Allocate the specified number of message and datagram buffers and add     * them to the appropriate port's free message and datagram pools     * respectively.  Return immediately on allocation errors without removing     * allocated buffers from the appropriate pools and deallocating them.     */    for( ; nmsgs; --nmsgs, ++cb->cinfo.pend_rec_credit ) {	if(( scsbp = ( *cb->Alloc_msg )( cb->pccb ))) {	    ( void )( *cb->Add_msg )( cb->pccb, scsbp );	} else {	    return( RET_ALLOCFAIL );	}    }    for( ; ndgs; --ndgs, ++cb->cinfo.dg_credit ) {	if(( scsbp = ( *cb->Alloc_dg )( cb->pccb ))) {	    ( void )( *cb->Add_dg )( cb->pccb, scsbp );	} else {	    return( RET_ALLOCFAIL );	}    }    return( RET_SUCCESS );}/*   Name:	scs_choose_path	- Choose Path for New Connection * *   Abstract:	This function chooses the path over which an attempt is made to *		establish a new logical SCS connection.  The current algorithm *		is to choose an open path to the target system with the least *		number of logical SCS connections. * *   Inputs: * *   IPL_SCS			- Interrupt processor level *   sb				- System Block pointer * *   Outputs: * *   IPL_SCS			- Interrupt processor level * *   Return Values: * *   Address of Path Block representing the chosen path *   Otherwise NULL if path could not be chosen * *   SMP:	The SCA database is locked( EXTERNALLY ) allowing for traversal *		of the system-wide configuration database. */PB *scs_choose_path( sb )    register SB		*sb;{    register pbq	*pb;    register PB		*save = NULL;    for( pb = sb->pbs.flink; pb != &sb->pbs; pb = pb->flink ) {	if( Pb->pinfo.state == PS_OPEN ) {	    if( save == NULL || save->pinfo.nconns > Pb->pinfo.nconns ) {		save = Pb;	    }	}    }    return( save );}/*   Name:	scs_dealloc_buf	- Deallocate all Message and Datagram Buffers * *   Abstract:	This function deallocates all of a CB's datagram and message *		buffers which it removes from the appropriate port's free *		datagram and message pools.  It also removes and deallocates *		one message buffer for each block data transfer currently in *		progress. * *		Partial removal of either datagram or message buffers may *		occur. * *		NOTE: The appropriate port drivers are always responsible for *		      the clean up of all port specific resources associated *		      with failed local ports including free datagram and *		      message buffers.  SCS must never attempt to dispose of *		      such resources during clean up of the paths and *		      connections associated with such failed ports. *		 *   Inputs: * *   IPL_SCS			- Interrupt processor level *   cb				- Connection Block pointer * *   Outputs: * *   IPL_SCS			- Interrupt processor level *   cb				- Connection Block pointer *	cinfo.dg_credit		-  0 *	cinfo.ntransfers	-  0 *	cinfo.pend_rec_credit	-  0 *	cinfo.rec_credit	-  0 * *   Return Values: * *   RET_SUCCESS		- Successful deallocation of all buffers *   RET_FAILURE		- Error encountered deallocating buffers * *   SMP:	The CB is locked( EXTERNALLY ) to synchronize access and *		prevent premature deletion.  It is locked through its CBVTE. * *		The PB itself must NOT be EXTERNALLY locked as required by the *		PD routines which remove datagram and message buffers from the *		appropriate local port datagram and message free pools. */u_longscs_dealloc_buf( cb )    register CB		*cb;{    register u_long	nbs;    register SCSH	*scsbp,			*( *remove )() = cb->Remove_msg;    register void	( *dealloc )() = cb->Dealloc_msg;    register u_long	status = RET_SUCCESS;    for( nbs = ( cb->cinfo.rec_credit	   +		 cb->cinfo.pend_rec_credit +		 cb->cinfo.ntransfers ),	 cb->cinfo.rec_credit = 0,	 cb->cinfo.pend_rec_credit = 0,	 cb->cinfo.ntransfers = 0;	 nbs;	 --nbs ) {	if(( scsbp = ( *remove )( cb->pccb ))) {	    ( void )( *dealloc )( cb->pccb, scsbp );	} else {	    status = RET_FAILURE;	    break;	}    }    for( remove = cb->Remove_dg,	 dealloc = cb->Dealloc_dg,	 nbs = cb->cinfo.dg_credit,	 cb->cinfo.dg_credit = 0;	 nbs;	 --nbs ) {	if(( scsbp = ( *remove )( cb->pccb ))) {	    ( void )( *dealloc )( cb->pccb, scsbp );	} else {	    status = RET_FAILURE;	    break;	}    }    return( status );}/*   Name:	scs_dispose_msg	- Dispose of Application Message Buffer * *   Abstract:	This function disposes of an application message buffer on a *		specific logical SCS connection according to the connection's *		current credit situation.  The buffer is either deallocated or *		converted into a receive message buffer for the connection. * *		Conversion of the application message buffer into a receive *		message buffer may trigger explicit extension of send credits *		across the logical SCS connection. * *   Inputs: * *   IPL_SCS			- Interrupt processor level *   cb				- Connection Block pointer *	cinfo.cstate		-  CS_OPEN

⌨️ 快捷键说明

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