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 /* 22136097ceSjb145095 * Copyright 2006 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> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define RINGBITS 8 /* # of bits in ring ptrs */ 467c478bd9Sstevel@tonic-gate #define RINGSIZE (1<<RINGBITS) /* size of ring */ 477c478bd9Sstevel@tonic-gate #define RINGMASK (RINGSIZE-1) 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define RING_INIT(qsp) ((qsp)->qcn_rput = (qsp)->qcn_rget = 0) 507c478bd9Sstevel@tonic-gate #define RING_CNT(qsp) (((qsp)->qcn_rput - (qsp)->qcn_rget) & RINGMASK) 517c478bd9Sstevel@tonic-gate #define RING_POK(qsp, n) ((int)RING_CNT(qsp) < (int)(RINGSIZE-(n))) 527c478bd9Sstevel@tonic-gate #define RING_PUT(qsp, c) \ 537c478bd9Sstevel@tonic-gate ((qsp)->qcn_ring[(qsp)->qcn_rput++ & RINGMASK] = (uchar_t)(c)) 547c478bd9Sstevel@tonic-gate #define RING_GET(qsp) ((qsp)->qcn_ring[(qsp)->qcn_rget++ & RINGMASK]) 55136097ceSjb145095 #define RING_ADDR(qsp) (&((qsp)->qcn_ring[(qsp)->qcn_rget & RINGMASK])) 56136097ceSjb145095 #define RING_POFF(qsp) ((qsp)->qcn_rput & RINGMASK) 57136097ceSjb145095 #define RING_GOFF(qsp) ((qsp)->qcn_rget & RINGMASK) 58136097ceSjb145095 #define RING_LEFT(qsp) (RING_POFF(qsp) >= RING_GOFF(qsp) ? (RINGSIZE) - \ 59136097ceSjb145095 RING_POFF(qsp) : RING_GOFF(qsp) - RING_POFF(qsp)) 60136097ceSjb145095 61136097ceSjb145095 #define RING_UPD(qsp, n) ((qsp)->qcn_rput += (n)) 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * qcn driver's soft state structure 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate typedef struct qcn { 677c478bd9Sstevel@tonic-gate /* mutexes */ 687c478bd9Sstevel@tonic-gate kmutex_t qcn_hi_lock; /* protects qcn_t (soft state) */ 697c478bd9Sstevel@tonic-gate kmutex_t qcn_lock; /* protects output queue */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* stream queues */ 727c478bd9Sstevel@tonic-gate queue_t *qcn_writeq; /* stream write queue */ 737c478bd9Sstevel@tonic-gate queue_t *qcn_readq; /* stream read queue */ 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* dev info */ 767c478bd9Sstevel@tonic-gate dev_info_t *qcn_dip; /* dev_info */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* for handling IOCTL messages */ 797c478bd9Sstevel@tonic-gate bufcall_id_t qcn_wbufcid; /* for console ioctl */ 807c478bd9Sstevel@tonic-gate tty_common_t qcn_tty; /* for console ioctl */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* for console output timeout */ 837c478bd9Sstevel@tonic-gate time_t qcn_sc_active; /* last time (sec) SC was active */ 847c478bd9Sstevel@tonic-gate uint_t qcn_polling; 857c478bd9Sstevel@tonic-gate uchar_t qcn_rget; 867c478bd9Sstevel@tonic-gate uchar_t qcn_rput; 87*32179a93Sjb145095 88*32179a93Sjb145095 /* the following is protected by atomic operations */ 89*32179a93Sjb145095 volatile unsigned int qcn_soft_pend; 90*32179a93Sjb145095 917c478bd9Sstevel@tonic-gate ddi_softint_handle_t qcn_softint_hdl; 92136097ceSjb145095 uchar_t *qcn_ring; 937c478bd9Sstevel@tonic-gate ushort_t qcn_hangup; 947c478bd9Sstevel@tonic-gate ddi_intr_handle_t *qcn_htable; /* For array of interrupts */ 957c478bd9Sstevel@tonic-gate int qcn_intr_type; /* What type of interrupt */ 967c478bd9Sstevel@tonic-gate int qcn_intr_cnt; /* # of intrs count returned */ 977c478bd9Sstevel@tonic-gate size_t qcn_intr_size; /* Size of intr array */ 987c478bd9Sstevel@tonic-gate uint_t qcn_intr_pri; /* Interrupt priority */ 997c478bd9Sstevel@tonic-gate uint_t qcn_rbuf_overflow; 100136097ceSjb145095 /* 101136097ceSjb145095 * support for console read/write support 102136097ceSjb145095 */ 103136097ceSjb145095 int (*cons_transmit)(queue_t *, mblk_t *); 104136097ceSjb145095 void (*cons_receive)(void); 105136097ceSjb145095 char *cons_write_buffer; 106136097ceSjb145095 uint64_t cons_write_buf_ra; 107136097ceSjb145095 uint64_t cons_read_buf_ra; 1087c478bd9Sstevel@tonic-gate } qcn_t; 1097c478bd9Sstevel@tonic-gate 110*32179a93Sjb145095 /* Constants for qcn_soft_pend */ 111*32179a93Sjb145095 #define QCN_SP_IDL 0 /* qcn_soft_pend is idle - do trigger */ 112*32179a93Sjb145095 #define QCN_SP_DO 1 /* soft interrupt needs to be processed */ 113*32179a93Sjb145095 #define QCN_SP_IP 2 /* in process, if interrupt, set DO, no trig */ 114*32179a93Sjb145095 1157c478bd9Sstevel@tonic-gate /* Constants used by promif routines */ 1167c478bd9Sstevel@tonic-gate #define QCN_CLNT_STR "CON_CLNT" 1177c478bd9Sstevel@tonic-gate #define QCN_OBP_STR "CON_OBP" 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* alternate break sequence */ 1207c478bd9Sstevel@tonic-gate extern void (*abort_seq_handler)(); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #define QCN_TXINT_ENABLE 0x1 1257c478bd9Sstevel@tonic-gate #define QCN_RXINT_ENABLE 0x2 1267c478bd9Sstevel@tonic-gate 127136097ceSjb145095 /* 128136097ceSjb145095 * API major/minor definitions for console 129136097ceSjb145095 * read/write support. 130136097ceSjb145095 */ 131136097ceSjb145095 132136097ceSjb145095 #define QCN_API_MAJOR 1 133136097ceSjb145095 #define QCN_API_MINOR 1 134136097ceSjb145095 135136097ceSjb145095 /* 136136097ceSjb145095 * The buffer size must be a power of 2 or contig_mem_alloc will fail 137136097ceSjb145095 */ 138136097ceSjb145095 #define CONS_WR_BUF_SIZE 64 139136097ceSjb145095 1407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate #endif 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate #endif /* _QCN_H */ 145