📄 stream.h
字号:
/***************************************************************************
*
* Copyright (c) 1993 READY SYSTEMS CORPORATION.
*
* All rights reserved. READY SYSTEMS' source code is an unpublished
* work and the use of a copyright notice does not imply otherwise.
* This source code contains confidential, trade secret material of
* READY SYSTEMS. Any attempt or participation in deciphering, decoding,
* reverse engineering or in any way altering the source code is
* strictly prohibited, unless the prior written consent of
* READY SYSTEMS is obtained.
*
*
* Module Name: stream.h
*
* Identification: @(#) 1.5 stream.h
*
* Date: 1/6/94 16:29:55
*
****************************************************************************
*/
/* $Id: stream.h,v 1.3 1995/02/23 21:40:06 sford Exp $ */
/*
* Copyrighted as an unpublished work.
* (c) Copyright 1993 Lachman Technology, Incorporated
* All rights reserved.
*
* RESTRICTED RIGHTS
*
* These programs are supplied under a license. They may be used,
* disclosed, and/or copied only as permitted under such license
* agreement. Any copy must contain the above copyright notice and
* this restricted rights notice. Use, copying, and/or disclosure
* of the programs is strictly prohibited unless otherwise provided
* in the license agreement.
*/
#ifndef __STREAM_H
#define __STREAM_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef KERNEL
#include "kernel/swktypes.h"
#include "kernel/swkdefs.h"
#endif /* KERNEL */
#include "sys/cred.h"
#include "exec/ipl.h" /* definition of splstr */
/*******************************************************************************
* driver/module utility macros
*/
#define OTHERQ(q) ((q)->q_flag&QREADR ? (q)+1 : (q)-1)
#define RD(q) ((q)-1)
#define WR(q) ((q)+1)
#define datamsg(typ) ((typ) == M_DATA || (typ) == M_PROTO || \
(typ) == M_PCPROTO || (typ) == M_DELAY || \
(typ) == M_DATA_HIPRI)
#define putnext(q, mp) ((*(q)->q_next->q_qinfo->qi_putp)((q)->q_next,(mp)))
#define linkb(mp, bp) /* concatenate two messages into one */ \
{ \
mblk_t *mp1 = mp; \
while (mp1->b_cont != NULL) \
mp1 = mp1->b_cont; \
mp1->b_cont = bp; \
}
#define noenable(q) ((q)->q_flag |= QNOENB)
#define enableok(q) ((q)->q_flag &= ~QNOENB)
#define FAKE_WSIZE 1 /* use reserved fields for wsize */
/*******************************************************************************
* (SPG A-4)
*/
struct module_info {
ushort mi_idnum; /* module ID number */
char *mi_idname; /* module name */
#ifdef _STYPES
short mi_minpsz; /* min packet size accepted */
short mi_maxpsz; /* max packet size accepted */
ushort mi_hiwat; /* high water mark, for flow control */
ushort mi_lowat; /* low water mark, for flow control */
#else /* large definition */
long mi_minpsz; /* min packet size accepted */
long mi_maxpsz; /* max packet size accepted */
ulong mi_hiwat; /* high water mark, for flow control */
ulong mi_lowat; /* low water mark, for flow control */
#endif /*_STYPES */
};
/*******************************************************************************
* streamtab defines a module or driver (SPG A-1)
*/
struct streamtab {
struct qinit *st_rdinit; /* defines read queue */
struct qinit *st_wrinit; /* defines write queue */
struct qinit *st_muxrinit; /* for multiplexing drivers only */
struct qinit *st_muxwinit; /* for multiplexing drivers only */
};
/*******************************************************************************
* (SPG 5-61)
*/
struct free_rtn {
/* driver dependent free routine */
void (*free_func) (char *);
char *free_arg; /* argument for free_rtn */
};
typedef struct free_rtn frtn_t;
/*******************************************************************************
* data block structure (SPG A-8)
*/
struct datab {
union {
struct datab *freep;
struct free_rtn *frtnp;
} db_f;
unsigned char *db_base; /* first byte of buffer */
unsigned char *db_lim; /* last byte+1 of buffer */
unsigned char db_ref; /* count of messages pointing to this block */
unsigned char db_type; /* message type */
#ifdef _STYPES
unsigned char db_band; /* message priority, determines where a
message is placed when enqueued */
unsigned char db_iswhat; /* status of message/data/buffer triplet */
unsigned int db_size; /* used internally */
unsigned short db_flag; /* data block flag */
unsigned short db_pad;
caddr_t db_msgaddr; /* triplet message header pointer to datab */
#else /* large definition */
unsigned char db_iswhat; /* status of message/data/buffer triplet */
unsigned int db_size; /* used internally */
caddr_t db_msgaddr; /* triplet message header pointer to datab */
long db_filler; /* reserved */
#endif /*_STYPES */
};
typedef struct datab dblk_t;
#define db_freep db_f.freep
#define db_frtnp db_f.frtnp
/*
* message types
*/
/* Ordinary Messages (SPG B-2) */
#define M_BREAK 1
#define M_CTL 2
#define M_DATA 3
#define M_DELAY 4
#define M_IOCTL 5
#define M_PASSFP 6
#define M_PROTO 7
#define M_RSE 8
#define M_SETOPTS 9
#define M_SIG 10
/* value used in insq to allow putq to add high priority message to
* tail of queue. This is last low priority value.
*/
#define M_INSQ_KLUDGE 11
/* First high priority message value */
#define QPCTL 12
/* High Priority Messages (SPG B-14) */
#define M_COPYIN 12
#define M_COPYOUT 13
#define M_ERROR 14
#define M_FLUSH 15
#define M_HANGUP 16
#define M_IOCACK 17
#define M_IOCDATA 18
#define M_IOCNAK 19
#define M_PCPROTO 20
#define M_PCRSE 21
#define M_PCSIG 22
#define M_READ 23
#define M_START 24
#define M_STOP 25
#define M_STARTI 26
#define M_STOPI 27
#define M_DATA_HIPRI 28 /* for data fragments of high priority messages */
/*
* priority parameter to allocb() (not used any longer)
*/
#define BPRI_LO 1
#define BPRI_MED 2
#define BPRI_HI 3
/*******************************************************************************
* the data buffer class structure
*/
struct strclass {
unsigned int size; /* size of buffers in this class */
struct datab *freelist; /* free list of data buffers */
#ifdef TUNE
unsigned int maxcnt; /* number of pre-allocated buffers */
unsigned int freecnt; /* data buffers on free list */
int alloccnt; /* number of current allocations */
int allocmax; /* max number of allocations */
int totalcnt; /* total number of allocations */
int overcnt; /* number of alloc overflows */
#endif /* TUNE */
};
/******************************************************************************* * the structure for STREAMS statistics
*
*/
#define NUM_BUF_SIZES 9 /* number of different sizes of preallocated buffers * in SNX; buf16, buf32, ..., buf4560 */
struct snx_stats {
int SNX_curr_num; /* cuurent number of structures/buffers in use */
int SNX_max_num; /* maximum number of structures/buffers beeing
* used until statistics task has been invoked */
int SNX_static_num; /* number of structures/buffers allocated from
* preallocated pool */
int SNX_dynamic_num; /* number of structures/buffers allocated dynamically
* from snx_heap */
int SNX_free_num; /* number of free structures/buffers left from
* preallocated pool */
};
struct snx_funct {
int SNX_invoc_num; /* total number of invocations of the certain function */
int SNX_failed_num; /* total number of invocations when the function failed */
};
struct lg_stats {
int lg_total_num;
int lg_total_copy;
int lg_max_num;
int lg_curr_num;
int lg_trsh_num;
};
struct km_stats {
unsigned long max_levels; /* max search levels */
unsigned long inserts; /* total number of heap inserts */
unsigned long deletes; /* total number of heap deletes */
unsigned long failed; /* total number of alloc. failures */
unsigned long allocs; /* total number of alloc. successes */
unsigned long frees; /* total number of free successes */
unsigned long maxobj; /* max size of a single obj */
unsigned long heap_sz; /* original heap size */
unsigned long mem_left; /* how much free heap left */
unsigned long min_left; /* smalled free left ever */
unsigned long free_nodes; /* current # of free nodes */
unsigned long max_free_nodes; /* greatest # of free nodes */
};
struct str_stats {
struct snx_stats mblks;
struct snx_stats dblks;
struct snx_stats bufs[NUM_BUF_SIZES];
struct snx_stats largebuf;
struct snx_stats timers;
struct snx_stats syscall;
struct snx_stats stacks;
};
/*******************************************************************************
* the message block structure (SPG A-7)
*/
struct msgb {
struct msgb *b_next; /* next message on queue */
struct msgb *b_prev; /* previous message on queue */
struct msgb *b_cont; /* next message block of message */
unsigned char *b_rptr; /* first unread data byte in buffer */
unsigned char *b_wptr; /* first unwritten data byte in buffer */
struct datab *b_datap; /* data block */
#ifdef _STYPES
#define b_band b_datap->db_band
#define b_flag b_datap->db_flag
#else /* large definition */
unsigned char b_band; /* message priority */
unsigned char b_pad1;
unsigned short b_flag; /* message flags (see below) */
#ifndef FAKE_WSIZE
long b_pad2;
#endif /* FAKE_WSIZE */
#endif /*_STYPES */
unsigned int b_wsize; /* weighted size (SWK-specific) */
unsigned int b_size; /* used internally (SWK-specific) */
};
typedef struct msgb mblk_t;
/*
* Message flags. These are interpreted by the Stream head.
*/
#define MSGMARK 0x01 /* last byte of message is "marked" */
#define MSGNOLOOP 0x02 /* don't loop message around to write-side of Stream */
#define MSGDELIM 0x04 /* message is delimited */
/*******************************************************************************
* Structure that describes the separate information for each priority
* band in the queue. (SPG A-6)
*/
/*
* To simplify priority band routines, improve performance, and
* reduce memory requirements for priority bands, the qb_pad1
* member of the qband structure is replaced with a union, and
* the following definition for qb_band. This is not in strict
* accordance with standard STREAMS definitions; if modules or drivers
* elsewhere in the system use the qb_pad1 member, or if future
* versions of STREAMS use it or eliminate it, this will have to change.
* To use the standard qband structure, comment out the definition of
* the qb_band macro below.
* Lachman Technology, Inc. 11 March, 1993
*/
#define qb_band qb_u.qbu_cpad[0] /* band info */
struct qband {
struct qband *qb_next; /* next band's info */
ulong qb_count; /* number of bytes in band */
struct msgb *qb_first; /* beginning of band's data */
struct msgb *qb_last; /* end of band's data */
ulong qb_hiwat; /* high water mark for band */
ulong qb_lowat; /* low water mark for band */
ulong qb_flag; /* flag, QB_FULL, denotes that a band
of data flow is flow controlled */
#ifdef qb_band /* hi-performance mod */
union {
long qbu_pad1; /* reserved */
uchar qbu_cpad[4]; /* general purpose bytes */
} qb_u;
#define qb_pad1 qb_u.qbu_pad1
#else /* original recipe */
long qb_pad1; /* reserved */
#endif
long qb_wcount; /* weighted byte count */
};
typedef struct qband qband_t;
/*
* qband flags
*/
#define QB_FULL 0x01 /* band is considered full */
#define QB_WANTW 0x02 /* someone wants to write to band */
#define QB_BACK 0x04 /* queue has been back-enabled */
#ifdef _STYPES
/*******************************************************************************
* the extended queue structure contains a link to next queue on STREAMS
* scheduling queue, a pointer to an array of structures containing the
* flow control parameters for each priority, and number of priority bands
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -