📄 sio.h
字号:
/* sio.h,v 1.5 1995/02/23 21:48:08 sford Exp */
/***************************************************************************
*
* Copyright (c) 1995 Microtec Research, Inc.
*
* All rights reserved. MICROTEC RESEARCH's 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
* MICROTEC RESEARCH. 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
* MICROTEC RESEARCH is obtained.
*
*
* Module Name: sio.h
*
* Identification: @(#) 1.1 sio.h
*
* Date: 9/16/94 17:54:04
*
****************************************************************************
*/
/*
;* Confidential and Proprietary.
;* Copyrighted as an unpublished work.
;* (c) Copyright 1987-1995 Legent Corporation.
;* All rights reserved.
;*
;* RESTRICTED RIGHTS
;*
;* These programs contain trade secrets and are supplied under a license
;* agreement. 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.
;*
* Copyrighted as an unpublished work.
* (c) Copyright Lachman Technology, Inc. 1993-1994
* 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.
*/
/*
* Device independent header file for the sio driver
*/
/*
* SWK SIO Configuration
*/
#define SWK_CONSOLE_BUF_SZ 256 /* Console Buffer size */
#define SWK_CON_ADAPTER 0 /* Adapter 0 */
#define SWK_CON_PORT 0 /* port 0 */
/*
* Misc. Defines
*/
#define SIO_PUT_BACK_Q 0x01
#define SIO_MAX_PORTS 16
/*
* When receiving data and our upstream queue reaches it's high-water mark,
* we will send an xoff and continue to send data upstream to allow the
* sender to skid to a halt. If he skids too far, then we'll start dropping
* the data. This tells how may bytes we'll allow him to skid. See
* the "ixoff_skid_dist" field in the "sio_port_t" structure.
*/
#define SIO_IXOFF_SKID 64
#define GET_PORT(devp) (getminor(*(devp)))
/*
* Defines used by sio_parity_err function
*/
#define SIO_RET_MBLK 0x01
#define SIO_SEND_MBLK 0x02
/*
* ddl_info_t
*
* Structure to hold pointers to Device Dependent Layer (DDL)
* functions. This provides the main interface between
* the DDL and the Device Independent Layer (DIL).
*/
typedef struct {
int (*ddl_set_modem_status)(int , int, int);
int (*ddl_clear_modem_status)(int, int, int);
int (*ddl_get_modem_status)(int, int);
int (*ddl_first_open)(int, int);
int (*ddl_open)(int, int);
int (*ddl_close)(int, int);
int (*ddl_ioctl)(int, int, mblk_t *);
int (*ddl_tx_data)(int, int, mblk_t *);
int (*ddl_set_port_params)(int, int, int, int, int);
int (*ddl_init)(int);
int (*ddl_tx_break)(int, int);
int (*ddl_control_io)(int, int, int, int);
int (*ddl_putc)(int, int, char);
char (*ddl_getc)(int, int);
} ddl_info_t;
/*
* Interface function defines
*
* fp is assumed to point to a ddl_info_t struct
*/
#define DDL_SET_MODEM_STATUS (*fp->ddl_set_modem_status)
#define DDL_CLEAR_MODEM_STATUS (*fp->ddl_clear_modem_status)
#define DDL_GET_MODEM_STATUS (*fp->ddl_get_modem_status)
#define DDL_FIRST_OPEN (*fp->ddl_first_open)
#define DDL_OPEN (*fp->ddl_open)
#define DDL_CLOSE (*fp->ddl_close)
#define DDL_IOCTL (*fp->ddl_ioctl)
#define DDL_TX_DATA (*fp->ddl_tx_data)
#define DDL_SET_PORT_PARAMS (*fp->ddl_set_port_params)
#define DDL_INIT (*fp->ddl_init)
#define DDL_TX_BREAK (*fp->ddl_tx_break)
#define DDL_CONTROL_IO (*fp->ddl_control_io)
#define DDL_PUTC (*fp->ddl_putc)
#define DDL_GETC (*fp->ddl_getc)
/* Parms to DDL_CONTROL_IO() */
#define SIO_SUS_IN 0x00000001 /* Suspend Input */
#define SIO_RES_IN 0x00000002 /* Resume Suspended Input */
#define SIO_SUS_OUT 0x00000004 /* Suspend Output */
#define SIO_RES_OUT 0x00000008 /* Resume Suspended Output */
#define SIO_MAP_CR_NL 0x00000010 /* Map NL to CR-NL */
#define SIO_NOMAP_CR_NL 0x00000020 /* Don't Map NL to CR-NL */
#define GET_FTP(adapt_p) ((adapt_p)->fpt)
#define SIO_GET_DDL_ADAPT_STRUCT(adapter) (sio_adapters[(adapter)].dev_dep)
#define SIO_GET_DDL_PORT_STRUCT(adapter, port) (sio_adapters[(adapter)].ports[(port)]->dev_dep)
#define SIO_SET_DDL_ADAPT_DEV_DEP(adapter, ddp) ((sio_adapters[(adapter)].dev_dep) = (ddp))
#define SIO_SET_DDL_PORT_DEV_DEP(adapter, port, ddp) ((sio_adapters[(adapter)].ports[(port)]->dev_dep) = (ddp))
/*
* sio_adapt_t
*
* Per Adapter Structure
*
* One structure allocaed per adapter in the system
*/
typedef struct sio_port_type sio_port_t;
typedef struct {
sio_port_t *ports[SIO_MAX_PORTS]; /* Per port structures */
char *drv_name; /* Driver Name */
ddl_info_t *fpt; /* Ptr to structure of func. ptrs */
int dev_maj; /* Major Number of device */
int state; /* Flags relating to state of driver */
int adapt_no; /* Adapter Number */
void *dev_dep; /* Device Dependent Structure */
} sio_adapt_t;
/* Flags for state field of sio_adapt_t structure */
#define SIO_ADAPT_INIT 0x00000001 /* Adapter is present and initialized */
/*
* sio_port_type (sio_port_t)
*
* Per Port Structure
*
* One structure allocated per port on an adapter
*/
struct sio_port_type {
int state; /* State of the port */
int ixoff_skid_dist; /* how far sender has skidded so far */
sio_adapt_t *adapt_p; /* Adapter Structure for this port */
struct termios term; /* Current termios settings */
int port; /* port Number */
queue_t *rdq; /* Read queue */
queue_t *wrq; /* Write queue */
void *dev_dep; /* Device Dependant Structure */
int close_sleep; /* true if close is waiting for drain */
mblk_t *ioctl_msg; /* Current Ioctl message */
cc_t xstart; /* XON/XOFF start Character */
cc_t xstop; /* XON/XOFF stop Character */
};
/* Flags for state field of sio_port_t structure */
#define SIO_PORT_OPEN 0x00000002 /* Port Open */
#define SIO_WOPEN 0x00000004 /* Port waiting for carrier */
#define SIO_WCLOSE 0x00000008 /* Port waiting to close */
#define SIO_EXCL 0x00000010 /* Port is open for exclusive access */
#define SIO_TX_BUSY 0x00000020 /* Port is busy Xmitting a message */
#define SIO_WDRAIN 0x00000040 /* Port is waiting for output to drain */
#define SIO_SET_PARAMS 0x00000080 /* Set Parms after data has drained */
#define SIO_SEND_BRK 0x00000100 /* Send break after data has drained */
#define SIO_TX_SUS 0x00000200 /* Data Transmission Suspended */
#define SIO_RX_SUS 0x00000400 /* Input Suspended */
/*
* Command Defines for varios Hardware Independent Funtions
*/
/* DIL modem status related defines */
#define SIO_DTR 0x00000001
#define SIO_RTS 0x00000002
#define SIO_DCD 0x00000004
#define SIO_CTS 0x00000008
/*
* Macros called by DDL (Device Dependent Layer) to
* perform DIL (Device Independent Layer) functions
*/
#define SIO_RX_DATA(port_p, mp) { \
if (! putq((port_p)->rdq, (mp))) \
freemsg((mp)) \
}
#define SIO_CLEAR_TX_BUSY(adapter, port) (sio_adapters[(adapter)].ports[(port)]->state &= ~SIO_TX_BUSY)
#define SIO_IS_TX_BUSY(adapter, port) (sio_adapters[(adapter)].ports[(port)]->state & SIO_TX_BUSY)
/*
* Macro to shift chars in message to the left
* one place, used to remove start, stop chars
* from a message.
*
* This is not ment to be the most efficient
* macro, it will only be used until we
* have an ldterm module.
*
* start - pointer character to be removed
*
* end - first unused slot in string
*/
#define SIO_RM_CHAR(start, end) { \
char *temp_ptr; \
temp_ptr = (start); \
while (temp_ptr < (char *) (end)) { \
*temp_ptr = *(temp_ptr+1); \
temp_ptr++; \
} \
}
extern int sio_no_ldterm;
/*
* Function Prototypes
*/
mblk_t *sio_get_next_msg(int, int);
int sio_init(void);
int sioopen(queue_t *, dev_t *, int, int, cred_t *);
int sioclose(queue_t *, int flag, cred_t *);
int siowsrv(queue_t *);
int siorsrv(queue_t *);
int sio_can_recv(int , int);
int sio_wdata(sio_port_t *, mblk_t *);
int sio_doioctl(sio_port_t *, mblk_t *);
int sio_port_params(sio_port_t *, struct termios *);
int sio_recv_data(int , int, mblk_t *);
int sio_rx_break(int, int);
char sio_getc(int, int);
int sio_putc(int, int, char);
mblk_t *sio_parity_err(int, int, char, int);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -