1*5084Sjohnlev /* 2*5084Sjohnlev * CDDL HEADER START 3*5084Sjohnlev * 4*5084Sjohnlev * The contents of this file are subject to the terms of the 5*5084Sjohnlev * Common Development and Distribution License (the "License"). 6*5084Sjohnlev * You may not use this file except in compliance with the License. 7*5084Sjohnlev * 8*5084Sjohnlev * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5084Sjohnlev * or http://www.opensolaris.org/os/licensing. 10*5084Sjohnlev * See the License for the specific language governing permissions 11*5084Sjohnlev * and limitations under the License. 12*5084Sjohnlev * 13*5084Sjohnlev * When distributing Covered Code, include this CDDL HEADER in each 14*5084Sjohnlev * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5084Sjohnlev * If applicable, add the following below this CDDL HEADER, with the 16*5084Sjohnlev * fields enclosed by brackets "[]" replaced with your own identifying 17*5084Sjohnlev * information: Portions Copyright [yyyy] [name of copyright owner] 18*5084Sjohnlev * 19*5084Sjohnlev * CDDL HEADER END 20*5084Sjohnlev */ 21*5084Sjohnlev 22*5084Sjohnlev /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 23*5084Sjohnlev /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 24*5084Sjohnlev /* All Rights Reserved */ 25*5084Sjohnlev 26*5084Sjohnlev /* 27*5084Sjohnlev * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 28*5084Sjohnlev * Use is subject to license terms. 29*5084Sjohnlev */ 30*5084Sjohnlev 31*5084Sjohnlev #ifndef _SYS_XENCONS_H 32*5084Sjohnlev #define _SYS_XENCONS_H 33*5084Sjohnlev 34*5084Sjohnlev #pragma ident "%Z%%M% %I% %E% SMI" 35*5084Sjohnlev 36*5084Sjohnlev #ifdef __cplusplus 37*5084Sjohnlev extern "C" { 38*5084Sjohnlev #endif 39*5084Sjohnlev 40*5084Sjohnlev #include <sys/tty.h> 41*5084Sjohnlev #include <sys/ksynch.h> 42*5084Sjohnlev #include <sys/dditypes.h> 43*5084Sjohnlev #include <xen/public/io/console.h> 44*5084Sjohnlev 45*5084Sjohnlev 46*5084Sjohnlev /* 47*5084Sjohnlev * Xencons tracing macros. These are a similar to some macros in sys/vtrace.h. 48*5084Sjohnlev * 49*5084Sjohnlev * XXX - Needs review: would it be better to use the macros in sys/vtrace.h ? 50*5084Sjohnlev */ 51*5084Sjohnlev #ifdef DEBUG 52*5084Sjohnlev #define DEBUGWARN0(fac, format) \ 53*5084Sjohnlev if (debug & (fac)) \ 54*5084Sjohnlev cmn_err(CE_WARN, format) 55*5084Sjohnlev #define DEBUGNOTE0(fac, format) \ 56*5084Sjohnlev if (debug & (fac)) \ 57*5084Sjohnlev cmn_err(CE_NOTE, format) 58*5084Sjohnlev #define DEBUGNOTE1(fac, format, arg1) \ 59*5084Sjohnlev if (debug & (fac)) \ 60*5084Sjohnlev cmn_err(CE_NOTE, format, arg1) 61*5084Sjohnlev #define DEBUGNOTE2(fac, format, arg1, arg2) \ 62*5084Sjohnlev if (debug & (fac)) \ 63*5084Sjohnlev cmn_err(CE_NOTE, format, arg1, arg2) 64*5084Sjohnlev #define DEBUGNOTE3(fac, format, arg1, arg2, arg3) \ 65*5084Sjohnlev if (debug & (fac)) \ 66*5084Sjohnlev cmn_err(CE_NOTE, format, arg1, arg2, arg3) 67*5084Sjohnlev #define DEBUGCONT0(fac, format) \ 68*5084Sjohnlev if (debug & (fac)) \ 69*5084Sjohnlev cmn_err(CE_CONT, format) 70*5084Sjohnlev #define DEBUGCONT1(fac, format, arg1) \ 71*5084Sjohnlev if (debug & (fac)) \ 72*5084Sjohnlev cmn_err(CE_CONT, format, arg1) 73*5084Sjohnlev #define DEBUGCONT2(fac, format, arg1, arg2) \ 74*5084Sjohnlev if (debug & (fac)) \ 75*5084Sjohnlev cmn_err(CE_CONT, format, arg1, arg2) 76*5084Sjohnlev #define DEBUGCONT3(fac, format, arg1, arg2, arg3) \ 77*5084Sjohnlev if (debug & (fac)) \ 78*5084Sjohnlev cmn_err(CE_CONT, format, arg1, arg2, arg3) 79*5084Sjohnlev #define DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) \ 80*5084Sjohnlev if (debug & (fac)) \ 81*5084Sjohnlev cmn_err(CE_CONT, format, arg1, arg2, arg3, arg4) 82*5084Sjohnlev #define DEBUGCONT10(fac, format, \ 83*5084Sjohnlev arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) \ 84*5084Sjohnlev if (debug & (fac)) \ 85*5084Sjohnlev cmn_err(CE_CONT, format, \ 86*5084Sjohnlev arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) 87*5084Sjohnlev #else 88*5084Sjohnlev #define DEBUGWARN0(fac, format) 89*5084Sjohnlev #define DEBUGNOTE0(fac, format) 90*5084Sjohnlev #define DEBUGNOTE1(fac, format, arg1) 91*5084Sjohnlev #define DEBUGNOTE2(fac, format, arg1, arg2) 92*5084Sjohnlev #define DEBUGNOTE3(fac, format, arg1, arg2, arg3) 93*5084Sjohnlev #define DEBUGCONT0(fac, format) 94*5084Sjohnlev #define DEBUGCONT1(fac, format, arg1) 95*5084Sjohnlev #define DEBUGCONT2(fac, format, arg1, arg2) 96*5084Sjohnlev #define DEBUGCONT3(fac, format, arg1, arg2, arg3) 97*5084Sjohnlev #define DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) 98*5084Sjohnlev #define DEBUGCONT10(fac, format, \ 99*5084Sjohnlev arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) 100*5084Sjohnlev #endif 101*5084Sjohnlev 102*5084Sjohnlev /* enum value for sw and hw flow control action */ 103*5084Sjohnlev typedef enum { 104*5084Sjohnlev FLOW_CHECK, 105*5084Sjohnlev FLOW_STOP, 106*5084Sjohnlev FLOW_START 107*5084Sjohnlev } async_flowc_action; 108*5084Sjohnlev 109*5084Sjohnlev #define async_stopc async_ttycommon.t_stopc 110*5084Sjohnlev #define async_startc async_ttycommon.t_startc 111*5084Sjohnlev 112*5084Sjohnlev /* 113*5084Sjohnlev * Console instance data. 114*5084Sjohnlev * Each of the fields in this structure is required to be protected by a 115*5084Sjohnlev * mutex lock at the highest priority at which it can be altered. 116*5084Sjohnlev */ 117*5084Sjohnlev 118*5084Sjohnlev struct xencons { 119*5084Sjohnlev int flags; /* random flags */ 120*5084Sjohnlev struct asyncline *priv; /* protocol private data -- asyncline */ 121*5084Sjohnlev dev_info_t *dip; /* dev_info */ 122*5084Sjohnlev int unit; /* which port */ 123*5084Sjohnlev kmutex_t excl; /* adaptive mutex */ 124*5084Sjohnlev kcondvar_t excl_cv; /* condition variable */ 125*5084Sjohnlev struct cons_polledio polledio; /* polled I/O functions */ 126*5084Sjohnlev unsigned char pollbuf[60]; /* polled I/O data */ 127*5084Sjohnlev int polldix; /* polled data buffer index */ 128*5084Sjohnlev int polllen; /* polled data buffer length */ 129*5084Sjohnlev volatile struct xencons_interface *ifp; /* console ring buffers */ 130*5084Sjohnlev int console_irq; /* dom0 console interrupt */ 131*5084Sjohnlev int evtchn; /* console event channel */ 132*5084Sjohnlev }; 133*5084Sjohnlev 134*5084Sjohnlev /* 135*5084Sjohnlev * Asychronous protocol private data structure for ASY. 136*5084Sjohnlev * Each of the fields in the structure is required to be protected by 137*5084Sjohnlev * the lower priority lock except the fields that are set only at 138*5084Sjohnlev * base level but cleared (with out lock) at interrupt level. 139*5084Sjohnlev */ 140*5084Sjohnlev 141*5084Sjohnlev struct asyncline { 142*5084Sjohnlev int async_flags; /* random flags */ 143*5084Sjohnlev kcondvar_t async_flags_cv; /* condition variable for flags */ 144*5084Sjohnlev dev_t async_dev; /* device major/minor numbers */ 145*5084Sjohnlev mblk_t *async_xmitblk; /* transmit: active msg block */ 146*5084Sjohnlev struct xencons *async_common; /* device common data */ 147*5084Sjohnlev tty_common_t async_ttycommon; /* tty driver common data */ 148*5084Sjohnlev bufcall_id_t async_wbufcid; /* id for pending write-side bufcall */ 149*5084Sjohnlev timeout_id_t async_polltid; /* softint poll timeout id */ 150*5084Sjohnlev timeout_id_t async_dtrtid; /* delaying DTR turn on */ 151*5084Sjohnlev timeout_id_t async_utbrktid; /* hold minimum untimed break time id */ 152*5084Sjohnlev 153*5084Sjohnlev /* 154*5084Sjohnlev * The following fields are protected by the excl_hi lock. 155*5084Sjohnlev * Some, such as async_flowc, are set only at the base level and 156*5084Sjohnlev * cleared (without the lock) only by the interrupt level. 157*5084Sjohnlev */ 158*5084Sjohnlev uchar_t *async_optr; /* output pointer */ 159*5084Sjohnlev int async_ocnt; /* output count */ 160*5084Sjohnlev ushort_t async_rput; /* producing pointer for input */ 161*5084Sjohnlev ushort_t async_rget; /* consuming pointer for input */ 162*5084Sjohnlev int async_inflow_source; /* input flow control type */ 163*5084Sjohnlev 164*5084Sjohnlev union { 165*5084Sjohnlev struct { 166*5084Sjohnlev uchar_t _hw; /* overrun (hw) */ 167*5084Sjohnlev uchar_t _sw; /* overrun (sw) */ 168*5084Sjohnlev } _a; 169*5084Sjohnlev ushort_t uover_overrun; 170*5084Sjohnlev } async_uover; 171*5084Sjohnlev #define async_overrun async_uover._a.uover_overrun 172*5084Sjohnlev #define async_hw_overrun async_uover._a._hw 173*5084Sjohnlev #define async_sw_overrun async_uover._a._sw 174*5084Sjohnlev short async_ext; /* modem status change count */ 175*5084Sjohnlev short async_work; /* work to do flag */ 176*5084Sjohnlev }; 177*5084Sjohnlev 178*5084Sjohnlev /* definitions for async_flags field */ 179*5084Sjohnlev #define ASYNC_EXCL_OPEN 0x10000000 /* exclusive open */ 180*5084Sjohnlev #define ASYNC_WOPEN 0x00000001 /* waiting for open to complete */ 181*5084Sjohnlev #define ASYNC_ISOPEN 0x00000002 /* open is complete */ 182*5084Sjohnlev #define ASYNC_STOPPED 0x00000010 /* output is stopped */ 183*5084Sjohnlev #define ASYNC_PROGRESS 0x00001000 /* made progress on output effort */ 184*5084Sjohnlev #define ASYNC_CLOSING 0x00002000 /* processing close on stream */ 185*5084Sjohnlev #define ASYNC_SW_IN_FLOW 0x00020000 /* sw input flow control in effect */ 186*5084Sjohnlev #define ASYNC_SW_OUT_FLW 0x00040000 /* sw output flow control in effect */ 187*5084Sjohnlev #define ASYNC_SW_IN_NEEDED 0x00080000 /* sw input flow control char is */ 188*5084Sjohnlev /* needed to be sent */ 189*5084Sjohnlev #define ASYNC_OUT_FLW_RESUME 0x00100000 /* output need to be resumed */ 190*5084Sjohnlev /* because of transition of flow */ 191*5084Sjohnlev /* control from stop to start */ 192*5084Sjohnlev 193*5084Sjohnlev 194*5084Sjohnlev /* definitions for asy_flags field */ 195*5084Sjohnlev #define ASY_CONSOLE 0x00000080 196*5084Sjohnlev 197*5084Sjohnlev /* definitions for async_inflow_source field in struct asyncline */ 198*5084Sjohnlev #define IN_FLOW_NULL 0x00000000 199*5084Sjohnlev #define IN_FLOW_STREAMS 0x00000002 200*5084Sjohnlev #define IN_FLOW_USER 0x00000004 201*5084Sjohnlev 202*5084Sjohnlev #define XENCONS_BURST 128 /* burst size for console writes */ 203*5084Sjohnlev 204*5084Sjohnlev #ifdef __cplusplus 205*5084Sjohnlev } 206*5084Sjohnlev #endif 207*5084Sjohnlev 208*5084Sjohnlev #endif /* _SYS_XENCONS_H */ 209