17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5136097ceSjb145095 * Common Development and Distribution License (the "License"). 6136097ceSjb145095 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*1b83305cSjm22469 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _QCN_H 277c478bd9Sstevel@tonic-gate #define _QCN_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * sun4v Console driver 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <sys/types.h> 407c478bd9Sstevel@tonic-gate #include <sys/stream.h> 417c478bd9Sstevel@tonic-gate #include <sys/tty.h> 427c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 437c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 44*1b83305cSjm22469 #include <sys/consdev.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #define RINGBITS 8 /* # of bits in ring ptrs */ 477c478bd9Sstevel@tonic-gate #define RINGSIZE (1<<RINGBITS) /* size of ring */ 487c478bd9Sstevel@tonic-gate #define RINGMASK (RINGSIZE-1) 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #define RING_INIT(qsp) ((qsp)->qcn_rput = (qsp)->qcn_rget = 0) 517c478bd9Sstevel@tonic-gate #define RING_CNT(qsp) (((qsp)->qcn_rput - (qsp)->qcn_rget) & RINGMASK) 527c478bd9Sstevel@tonic-gate #define RING_POK(qsp, n) ((int)RING_CNT(qsp) < (int)(RINGSIZE-(n))) 537c478bd9Sstevel@tonic-gate #define RING_PUT(qsp, c) \ 547c478bd9Sstevel@tonic-gate ((qsp)->qcn_ring[(qsp)->qcn_rput++ & RINGMASK] = (uchar_t)(c)) 557c478bd9Sstevel@tonic-gate #define RING_GET(qsp) ((qsp)->qcn_ring[(qsp)->qcn_rget++ & RINGMASK]) 56136097ceSjb145095 #define RING_ADDR(qsp) (&((qsp)->qcn_ring[(qsp)->qcn_rget & RINGMASK])) 57136097ceSjb145095 #define RING_POFF(qsp) ((qsp)->qcn_rput & RINGMASK) 58136097ceSjb145095 #define RING_GOFF(qsp) ((qsp)->qcn_rget & RINGMASK) 59136097ceSjb145095 #define RING_LEFT(qsp) (RING_POFF(qsp) >= RING_GOFF(qsp) ? (RINGSIZE) - \ 60136097ceSjb145095 RING_POFF(qsp) : RING_GOFF(qsp) - RING_POFF(qsp)) 61136097ceSjb145095 62136097ceSjb145095 #define RING_UPD(qsp, n) ((qsp)->qcn_rput += (n)) 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * qcn driver's soft state structure 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate typedef struct qcn { 687c478bd9Sstevel@tonic-gate /* mutexes */ 697c478bd9Sstevel@tonic-gate kmutex_t qcn_hi_lock; /* protects qcn_t (soft state) */ 707c478bd9Sstevel@tonic-gate kmutex_t qcn_lock; /* protects output queue */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* stream queues */ 737c478bd9Sstevel@tonic-gate queue_t *qcn_writeq; /* stream write queue */ 747c478bd9Sstevel@tonic-gate queue_t *qcn_readq; /* stream read queue */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* dev info */ 777c478bd9Sstevel@tonic-gate dev_info_t *qcn_dip; /* dev_info */ 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* for handling IOCTL messages */ 807c478bd9Sstevel@tonic-gate bufcall_id_t qcn_wbufcid; /* for console ioctl */ 817c478bd9Sstevel@tonic-gate tty_common_t qcn_tty; /* for console ioctl */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* for console output timeout */ 847c478bd9Sstevel@tonic-gate time_t qcn_sc_active; /* last time (sec) SC was active */ 857c478bd9Sstevel@tonic-gate uint_t qcn_polling; 867c478bd9Sstevel@tonic-gate uchar_t qcn_rget; 877c478bd9Sstevel@tonic-gate uchar_t qcn_rput; 8832179a93Sjb145095 8932179a93Sjb145095 /* the following is protected by atomic operations */ 9032179a93Sjb145095 volatile unsigned int qcn_soft_pend; 9132179a93Sjb145095 927c478bd9Sstevel@tonic-gate ddi_softint_handle_t qcn_softint_hdl; 93136097ceSjb145095 uchar_t *qcn_ring; 947c478bd9Sstevel@tonic-gate ushort_t qcn_hangup; 957c478bd9Sstevel@tonic-gate ddi_intr_handle_t *qcn_htable; /* For array of interrupts */ 967c478bd9Sstevel@tonic-gate int qcn_intr_type; /* What type of interrupt */ 977c478bd9Sstevel@tonic-gate int qcn_intr_cnt; /* # of intrs count returned */ 987c478bd9Sstevel@tonic-gate size_t qcn_intr_size; /* Size of intr array */ 997c478bd9Sstevel@tonic-gate uint_t qcn_intr_pri; /* Interrupt priority */ 1007c478bd9Sstevel@tonic-gate uint_t qcn_rbuf_overflow; 101136097ceSjb145095 /* 102136097ceSjb145095 * support for console read/write support 103136097ceSjb145095 */ 104136097ceSjb145095 int (*cons_transmit)(queue_t *, mblk_t *); 105136097ceSjb145095 void (*cons_receive)(void); 106136097ceSjb145095 char *cons_write_buffer; 107136097ceSjb145095 uint64_t cons_write_buf_ra; 108136097ceSjb145095 uint64_t cons_read_buf_ra; 109*1b83305cSjm22469 110*1b83305cSjm22469 /* 111*1b83305cSjm22469 * support for polled io 112*1b83305cSjm22469 */ 113*1b83305cSjm22469 cons_polledio_t qcn_polledio; 114*1b83305cSjm22469 boolean_t qcn_char_available; 115*1b83305cSjm22469 uint8_t qcn_hold_char; 1167c478bd9Sstevel@tonic-gate } qcn_t; 1177c478bd9Sstevel@tonic-gate 11832179a93Sjb145095 /* Constants for qcn_soft_pend */ 11932179a93Sjb145095 #define QCN_SP_IDL 0 /* qcn_soft_pend is idle - do trigger */ 12032179a93Sjb145095 #define QCN_SP_DO 1 /* soft interrupt needs to be processed */ 12132179a93Sjb145095 #define QCN_SP_IP 2 /* in process, if interrupt, set DO, no trig */ 12232179a93Sjb145095 1237c478bd9Sstevel@tonic-gate /* Constants used by promif routines */ 1247c478bd9Sstevel@tonic-gate #define QCN_CLNT_STR "CON_CLNT" 1257c478bd9Sstevel@tonic-gate #define QCN_OBP_STR "CON_OBP" 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* alternate break sequence */ 1287c478bd9Sstevel@tonic-gate extern void (*abort_seq_handler)(); 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops; 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #define QCN_TXINT_ENABLE 0x1 1337c478bd9Sstevel@tonic-gate #define QCN_RXINT_ENABLE 0x2 1347c478bd9Sstevel@tonic-gate 135136097ceSjb145095 /* 136136097ceSjb145095 * API major/minor definitions for console 137136097ceSjb145095 * read/write support. 138136097ceSjb145095 */ 139136097ceSjb145095 140136097ceSjb145095 #define QCN_API_MAJOR 1 141136097ceSjb145095 #define QCN_API_MINOR 1 142136097ceSjb145095 143136097ceSjb145095 /* 144136097ceSjb145095 * The buffer size must be a power of 2 or contig_mem_alloc will fail 145136097ceSjb145095 */ 146136097ceSjb145095 #define CONS_WR_BUF_SIZE 64 147136097ceSjb145095 1487c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate #endif 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #endif /* _QCN_H */ 153