
/*****************************************************************************
* Copyright (c) 1990-96 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/

/*
 * $Id: slot.h,v 1.3 1997/10/21 20:48:02 gary Exp $
 */

#define BEGIN_STRUCT(x)  struct x {
#  define END_STRUCT               } ;
#  define S4(t,x)          t x ;
#  define S4A(t,x, n)              t x[n] ;

/********************************************************************
 ***  Coroutine support.
 ********************************************************************/

BEGIN_STRUCT(cocall)
    S4(ulong,  co_start)                /* Start address */
    S4(ulong,  co_resume)               /* Procedure resume address */
    S4(ulong,  co_tstack)               /* Top of stack */
    S4(ulong,  co_stack)                /* Stack pointer */
    S4(ulong,  co_frame)                /* Frame pointer */
    S4A(ulong, co_save, 32)              /* S registers */
END_STRUCT
typedef struct cocall COCALL ;             /* Structure typedefs */

/*
 * Local stacks
 */

/*
 * LOCAL_STACK_SIZE:
 *
 * The size, in bytes, of a local stack.  Increase only if required.
 */
#define	LOCAL_STACK_SIZE	900

/*
 * TOTAL_LOCAL_STACKS:
 *
 * The total number of local stacks to allocate from the dual-ported
 * memory pool.  This number MUST be equal to or greater than the total
 * number of individual stream sessions which may be sleeping simultaneously.
 * For example, the only STREAM module or driver that sleeps in its open
 * or close routine currently is XXX.  Since there is a maximum of 64 XXX
 * sessions allowed (under 2 meg platforms), this number must be at least
 * 64.  If the maximum is increased, then TOTAL_LOCAL_STACKS must also be
 * increased to compensate.  Or, if another sleeping driver or module is
 * developed, then TOTAL_LOCAL_STACKS must be increased by that
 * module/driver's maximum number of sessions.
 *
 * An extra local stack will be allocated automatically.  This extra stack is
 * allocated so that other non-sleeping streams can open and close, even if
 * all potentially sleeping streams were to do so simultaneously.
 */
#define	TOTAL_LOCAL_STACKS	64

struct local_stack {
	struct local_stack *next_stack;
	unsigned char stack_space[LOCAL_STACK_SIZE];
};

typedef struct local_stack local_stack_t;

/*
 * The message slot is the structure which ties the IPC mechanism to the
 * associated stream head
 *
 */

#ifdef	SQUEEZE
struct mslt {
#else
struct mslot {
#endif
        strm_t  *strm;          /* Pointer to stream structure */
        int     qfd;            /* Index of queue */
        int     avail;          /* Messages ready to output */
        mblk_t  *repl;          /* Message currently being read by host side */
	unsigned long w_command ;
	unsigned long datalen ;
	unsigned long dataptr ;
	unsigned long misc_info ;
	int	spec_action;	/* Read put action switch */
	int	defer;		/* Must stop output for unusual reasons */
        local_stack_t *stack;	/* stack for open/close co-routine */
        COCALL ms_co_open;	/* co-routine structure for this slot */
        caddr_t s_token;	/* token for wakeup */

	uint16	rs_produced ;	/* Read-Side Bytes Produced */
	uint16	rs_consumed ;	/* Read-Side Bytes Consumed */
	uint16	rs_fcost ;	/* Read-Side Fixed Cost */
	uint16	rs_max ;	/* Read-Side Maximum */

	uint16	ws_produced ;	/* Write-Side Bytes Produced */
	uint16	ws_consumed ;	/* Write-Side Bytes Consumed */
	uint16	ws_fcost ;	/* Write-Side Fixed Cost */
	uint16	ws_max ;	/* Write-Side Maximum */
	uint16	ws_pending_pos_rpt ; /* Write-Side Pending Position Report */	
	uint16	ws_position_rpt_state ; /* 0=Not scheduled;
					 * 1=scheduled, delay send 
					 * 2=scheduled, send 
					 */
					  
					/* Linked list entry for mslots to
					 * send position reports on
					 */ 
	uint8	w_error ;		/* Write side error code */
	uint8	r_error ;		/* Read side error code */
#ifdef	SQUEEZE
	struct mslt *ws_next_position_rpt_slot ; 
#else
	struct mslot *ws_next_position_rpt_slot ; 
#endif

};
