1139749Simp/*- 2136467Ssimokawa * Copyright (C) 2002-2004 3121468Ssimokawa * Hidetoshi Shimokawa. All rights reserved. 4121468Ssimokawa * 5121468Ssimokawa * Redistribution and use in source and binary forms, with or without 6121468Ssimokawa * modification, are permitted provided that the following conditions 7121468Ssimokawa * are met: 8121468Ssimokawa * 1. Redistributions of source code must retain the above copyright 9121468Ssimokawa * notice, this list of conditions and the following disclaimer. 10121468Ssimokawa * 2. Redistributions in binary form must reproduce the above copyright 11121468Ssimokawa * notice, this list of conditions and the following disclaimer in the 12121468Ssimokawa * documentation and/or other materials provided with the distribution. 13121468Ssimokawa * 3. All advertising materials mentioning features or use of this software 14121468Ssimokawa * must display the following acknowledgement: 15121468Ssimokawa * 16121468Ssimokawa * This product includes software developed by Hidetoshi Shimokawa. 17121468Ssimokawa * 18121468Ssimokawa * 4. Neither the name of the author nor the names of its contributors 19121468Ssimokawa * may be used to endorse or promote products derived from this software 20121468Ssimokawa * without specific prior written permission. 21121468Ssimokawa * 22121468Ssimokawa * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23121468Ssimokawa * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24121468Ssimokawa * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25121468Ssimokawa * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26121468Ssimokawa * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27121468Ssimokawa * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28121468Ssimokawa * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29121468Ssimokawa * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30121468Ssimokawa * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31121468Ssimokawa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32121468Ssimokawa * SUCH DAMAGE. 33121468Ssimokawa * 34121468Ssimokawa * $Id: dcons.h,v 1.15 2003/10/23 15:05:31 simokawa Exp $ 35121468Ssimokawa * $FreeBSD$ 36121468Ssimokawa */ 37121468Ssimokawa 38136781Ssimokawa#if defined(_KERNEL) || defined(_BOOT) 39121468Ssimokawa#define V volatile 40121468Ssimokawa#else 41121468Ssimokawa#define V 42121468Ssimokawa#endif 43121468Ssimokawa 44121468Ssimokawa#define DCONS_NPORT 2 45121468Ssimokawa#define DCONS_CON 0 46121468Ssimokawa#define DCONS_GDB 1 47121468Ssimokawa 48121468Ssimokawastruct dcons_buf { 49121468Ssimokawa#define DCONS_VERSION 2 50121468Ssimokawa V u_int32_t version; 51121468Ssimokawa V u_int32_t ooffset[DCONS_NPORT]; 52121468Ssimokawa V u_int32_t ioffset[DCONS_NPORT]; 53121468Ssimokawa V u_int32_t osize[DCONS_NPORT]; 54121468Ssimokawa V u_int32_t isize[DCONS_NPORT]; 55121468Ssimokawa#define DCONS_MAGIC 0x64636f6e /* "dcon" */ 56121468Ssimokawa V u_int32_t magic; 57121468Ssimokawa#define DCONS_GEN_SHIFT (24) 58121468Ssimokawa#define DCONS_GEN_MASK (0xff) 59121468Ssimokawa#define DCONS_POS_MASK ((1<< DCONS_GEN_SHIFT) - 1) 60121468Ssimokawa V u_int32_t optr[DCONS_NPORT]; 61121468Ssimokawa V u_int32_t iptr[DCONS_NPORT]; 62121468Ssimokawa V char buf[0]; 63121468Ssimokawa}; 64121468Ssimokawa 65121468Ssimokawa#define DCONS_CSR_VAL_VER 0x64636f /* "dco" */ 66121468Ssimokawa#define DCONS_CSR_KEY_HI 0x3a 67121468Ssimokawa#define DCONS_CSR_KEY_LO 0x3b 68170420Ssimokawa#define DCONS_CSR_KEY_RESET_HI 0x3c 69170420Ssimokawa#define DCONS_CSR_KEY_RESET_LO 0x3d 70121468Ssimokawa 71121468Ssimokawa#define DCONS_HEADER_SIZE sizeof(struct dcons_buf) 72121468Ssimokawa#define DCONS_MAKE_PTR(x) htonl(((x)->gen << DCONS_GEN_SHIFT) | (x)->pos) 73121468Ssimokawa#define DCONS_NEXT_GEN(x) (((x) + 1) & DCONS_GEN_MASK) 74121468Ssimokawa 75121468Ssimokawastruct dcons_ch { 76121468Ssimokawa u_int32_t size; 77121468Ssimokawa u_int32_t gen; 78121468Ssimokawa u_int32_t pos; 79136781Ssimokawa#if defined(_KERNEL) || defined(_BOOT) 80121468Ssimokawa V u_int32_t *ptr; 81121468Ssimokawa V char *buf; 82121468Ssimokawa#else 83121468Ssimokawa off_t buf; 84121468Ssimokawa#endif 85121468Ssimokawa}; 86121468Ssimokawa 87121468Ssimokawa#define KEY_CTRLB 2 /* ^B */ 88121468Ssimokawa#define KEY_CR 13 /* CR '\r' */ 89121468Ssimokawa#define KEY_TILDE 126 /* ~ */ 90121468Ssimokawa#define STATE0 0 91121468Ssimokawa#define STATE1 1 92121468Ssimokawa#define STATE2 2 93170420Ssimokawa#define STATE3 3 94121468Ssimokawa 95136781Ssimokawa#if defined(_KERNEL) || defined(_BOOT) 96136467Ssimokawastruct dcons_softc { 97136467Ssimokawa struct dcons_ch o, i; 98136467Ssimokawa int brk_state; 99136467Ssimokawa#define DC_GDB 1 100136467Ssimokawa int flags; 101181905Sed void *tty; 102125862Ssimokawa}; 103136467Ssimokawa 104136467Ssimokawaint dcons_checkc(struct dcons_softc *); 105136467Ssimokawaint dcons_ischar(struct dcons_softc *); 106136467Ssimokawavoid dcons_putc(struct dcons_softc *, int); 107136467Ssimokawaint dcons_load_buffer(struct dcons_buf *, int, struct dcons_softc *); 108136467Ssimokawavoid dcons_init(struct dcons_buf *, int, struct dcons_softc *); 109121468Ssimokawa#endif 110