da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or http://www.opensolaris.org/os/licensing.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
7257d1b4d25bfac0c802847390e98a464fd787acraf
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
575bd8a230f2c20b1878ebb473c30a12f0eb1b2emarks * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifndef _SGCN_H
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define _SGCN_H
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#pragma ident "%Z%%M% %I% %E% SMI"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifdef __cplusplus
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern "C" {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Console driver
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * There is no hardware serial port is provided. A standalone
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * co-processor SC acts as console device. The communication
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * between SC and a domain is via SRAM on the choosen I/O board.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This driver manipulates SRAM from domain Solaris side.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Logically there are two sets of interfaces defined here.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The first part describes IOSRAM structures and will be
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * exposed to all relevant clients, like SC, OBP.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The second part defines internal driver data structure
575bd8a230f2c20b1878ebb473c30a12f0eb1b2emarks * used by sgcn dirver.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/types.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/stream.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/tty.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/ddi.h>
575bd8a230f2c20b1878ebb473c30a12f0eb1b2emarks#include <sys/sunddi.h>
575bd8a230f2c20b1878ebb473c30a12f0eb1b2emarks
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * IOSRAM structure
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Solaris and OBP use separate console buffers. But they share
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the same console buffer structure.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ <- console buffer base address (BASE)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | header |
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ <- cnsram_in_begin + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | input |
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | buffer | <- cnsram_in_rdptr + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | | <- cnsram_in_wrptr + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | |
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ <- cnsram_in_end + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * |///////////////|
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * |///////////////| <- reserved for future expansion
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * |///////////////|
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ <- cnsram_out_begin + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | output |
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | buffer | <- cnsram_out_rdptr + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | | <- cnsram_out_wrptr + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ <- cnsram_out_end + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * |///////////////|
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * |///////////////| <- reserved for future expansion
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * |///////////////|
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ <- cnsram_size + BASE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Console IOSRAM header structure
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The header size is fixed, despite of 32-bit or 64-bit Solaris
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_magic; /* magic number, CNSRAM_MAGIC */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_version; /* verison number */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_size; /* console buffer size */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the followings are all relative to beginning of console buffer
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_in_begin;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_in_end;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_in_rdptr;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_in_wrptr;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_out_begin;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_out_end;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_out_rdptr;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int32_t cnsram_out_wrptr;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw} cnsram_header;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define CNSRAM_MAGIC 0x434F4E00 /* "CON" */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define CNSRAM_VERSION_1 1
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sgcn driver's soft state structure
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct sgcn {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* mutexes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw kmutex_t sgcn_lock; /* protects sgcn_t (soft state) */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* these are required by sbbc driver */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw kmutex_t sgcn_sbbc_in_lock; /* input data lock */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw kmutex_t sgcn_sbbc_outspace_lock; /* output data lock */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw kmutex_t sgcn_sbbc_brk_lock; /* break sequence lock */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint_t sgcn_sbbc_in_state; /* input data state */
uint_t sgcn_sbbc_outspace_state; /* output data state */
uint_t sgcn_sbbc_brk_state; /* break sequence state */
/* stream queues */
queue_t *sgcn_writeq; /* stream write queue */
queue_t *sgcn_readq; /* stream read queue */
/* pre-allocated console input buffer */
char *sgcn_inbuf; /* console input buffer */
uint_t sgcn_inbuf_size; /* buffer size */
/* dev info */
dev_info_t *sgcn_dip; /* dev_info */
/* for handling IOCTL messages */
bufcall_id_t sgcn_wbufcid; /* for console ioctl */
tty_common_t sgcn_tty; /* for console ioctl */
/* for console output timeout */
time_t sgcn_sc_active; /* last time (sec) SC was active */
} sgcn_t;
/* Constants used by promif routines */
#define SGCN_CLNT_STR "CON_CLNT"
#define SGCN_OBP_STR "CON_OBP"
/* alternate break sequence */
extern void (*abort_seq_handler)();
extern struct mod_ops mod_driverops;
#ifdef __cplusplus
}
#endif
#endif /* _SGCN_H */