Home | History | Annotate | Line # | Download | only in dev
mscreg.h revision 1.5.42.1
      1  1.5.42.1  jdolecek /*	$NetBSD: mscreg.h,v 1.5.42.1 2002/02/11 20:07:04 jdolecek Exp $ */
      2       1.1    chopps 
      3       1.1    chopps /*
      4       1.1    chopps  * Copyright (c) 1993 Zik.
      5       1.1    chopps  * Copyright (c) 1995 Jukka Marin <jmarin (at) teeri.jmp.fi>.
      6       1.1    chopps  * Copyright (c) 1995 Rob Healey <rhealey (at) kas.helios.mn.org>.
      7       1.1    chopps  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
      8       1.1    chopps  * All rights reserved.
      9       1.1    chopps  *
     10       1.1    chopps  * Redistribution and use in source and binary forms, with or without
     11       1.1    chopps  * modification, are permitted provided that the following conditions
     12       1.1    chopps  * are met:
     13       1.1    chopps  * 1. Redistributions of source code must retain the above copyright
     14       1.1    chopps  *    notice, this list of conditions and the following disclaimer.
     15       1.1    chopps  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1    chopps  *    notice, this list of conditions and the following disclaimer in the
     17       1.1    chopps  *    documentation and/or other materials provided with the distribution.
     18       1.1    chopps  * 3. All advertising materials mentioning features or use of this software
     19       1.1    chopps  *    must display the following acknowledgement:
     20       1.1    chopps  *	This product includes software developed by the University of
     21       1.1    chopps  *	California, Berkeley and its contributors.
     22       1.1    chopps  * 4. Neither the name of the University nor the names of its contributors
     23       1.1    chopps  *    may be used to endorse or promote products derived from this software
     24       1.1    chopps  *    without specific prior written permission.
     25       1.1    chopps  *
     26       1.1    chopps  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27       1.1    chopps  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28       1.1    chopps  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29       1.1    chopps  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30       1.1    chopps  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31       1.1    chopps  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32       1.1    chopps  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33       1.1    chopps  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34       1.1    chopps  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35       1.1    chopps  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36       1.1    chopps  * SUCH DAMAGE.
     37       1.1    chopps  *
     38       1.1    chopps  *    - created by zik 931207
     39       1.1    chopps  *    - Fixed break value. 950108 RFH
     40       1.1    chopps  *    - Added 6502 field to mscmemory so board can be halted while
     41       1.1    chopps  *	it's memory is being reloaded. 950108 RFH
     42       1.1    chopps  *    - Ripped out structure guts and replaced with Jukka Marin's stuff for his
     43       1.1    chopps  *	freely redistributable version of the 2232 6502c code. Yea!!!!!!
     44       1.1    chopps  *	950916 RFH
     45       1.1    chopps  *    - Added Jukka's turbo board detection support and tmpbuf for copys. 950918
     46       1.1    chopps  *    - Change to NetBSD style for integration in to the main tree. 950919
     47       1.1    chopps  */
     48       1.1    chopps 
     49       1.5        is #define	NUMLINES	7	/* number of lines per card */
     50       1.5        is #define	IOBUFLEN	256	/* number of bytes per buffer */
     51       1.2    chopps #define	IOBUFLENMASK	0xff	/* mask for maximum number of bytes */
     52       1.2    chopps #define	IOBUFHIGHWATER	192	/* point at which to enable output */
     53       1.2    chopps #define	IOBUFLOWWATER	128	/* point at which to wake output */
     54       1.1    chopps 
     55       1.2    chopps #define	MSC_VBL_PRIORITY	1	/* priority of vbl interrupt handler */
     56       1.1    chopps 
     57       1.1    chopps #define	MSC_UNKNOWN	0	/* crystal not known */
     58       1.1    chopps #define	MSC_NORMAL	1	/* normal A2232 (1.8432 MHz oscillator) */
     59       1.1    chopps #define	MSC_TURBO	2	/* turbo A2232 (3.6864 MHz oscillator) */
     60       1.1    chopps 
     61       1.1    chopps 
     62       1.1    chopps struct msccommon {
     63       1.1    chopps 	char   Crystal;	/* normal (1) or turbo (2) board? */
     64       1.1    chopps 	u_char Pad_a;
     65       1.1    chopps 	u_char TimerH;	/* timer value after speed check */
     66       1.1    chopps 	u_char TimerL;
     67       1.5        is 	u_char CDHead;	/* head pointer for CD message queue */
     68       1.5        is 	u_char CDTail;	/* tail pointer for CD message queue */
     69       1.5        is 	u_char CDStatus;
     70       1.5        is 	u_char Pad_b;
     71       1.1    chopps };
     72       1.1    chopps 
     73       1.1    chopps struct mscstatus {
     74       1.2    chopps 	u_char InHead;		/* input queue head */
     75       1.2    chopps 	u_char InTail;		/* input queue tail */
     76       1.1    chopps 	u_char OutDisable;	/* disables output */
     77       1.2    chopps 	u_char OutHead;		/* output queue head */
     78       1.2    chopps 	u_char OutTail;		/* output queue tail */
     79       1.2    chopps 	u_char OutCtrl;		/* soft flow control character to send */
     80       1.1    chopps 	u_char OutFlush;	/* flushes output buffer */
     81       1.2    chopps 	u_char Setup;		/* causes reconfiguration */
     82       1.2    chopps 	u_char Param;		/* parameter byte - see MSCPARAM */
     83       1.2    chopps 	u_char Command;		/* command byte - see MSCCMD */
     84       1.1    chopps 	u_char SoftFlow;	/* enables xon/xoff flow control */
     85       1.1    chopps 	/* private 65C02 fields: */
     86       1.2    chopps 	u_char XonOff;		/* stores XON/XOFF enable/disable */
     87       1.1    chopps };
     88       1.1    chopps 
     89       1.5        is #define	MSC_MEMPAD1	\
     90       1.2    chopps     (0x0200 - NUMLINES * sizeof(struct mscstatus) - sizeof(struct msccommon))
     91       1.5        is #define	MSC_MEMPAD2	(0x2000 - NUMLINES * IOBUFLEN - IOBUFLEN)
     92  1.5.42.1  jdolecek 
     93       1.1    chopps struct mscmemory {
     94       1.2    chopps 	struct mscstatus Status[NUMLINES];	/* 0x0000-0x006f status areas */
     95       1.5        is 	struct msccommon Common;		/* 0x0070-0x0077 common flags */
     96       1.5        is 	u_char Dummy1[MSC_MEMPAD1];		/* 0x00XX-0x01ff */
     97       1.2    chopps 	u_char OutBuf[NUMLINES][IOBUFLEN];	/* 0x0200-0x08ff output bufs */
     98       1.2    chopps 	u_char InBuf[NUMLINES][IOBUFLEN];	/* 0x0900-0x0fff input bufs */
     99       1.2    chopps 	u_char InCtl[NUMLINES][IOBUFLEN];	/* 0x1000-0x16ff control data */
    100       1.5        is 	u_char CDBuf[IOBUFLEN];			/* 0x1700-0x17ff CD event buffer */
    101       1.5        is 	u_char Dummy2[MSC_MEMPAD2];		/* 0x1800-0x2fff */
    102       1.2    chopps 	u_char Code[0x1000];			/* 0x3000-0x3fff code area */
    103       1.2    chopps 	u_short InterruptAck;			/* 0x4000        intr ack */
    104       1.2    chopps 	u_char Dummy3[0x3ffe];			/* 0x4002-0x7fff */
    105       1.2    chopps 	u_short Enable6502Reset;		/* 0x8000 Stop board, */
    106       1.2    chopps 						/*  6502 RESET line held low */
    107       1.2    chopps 	u_char Dummy4[0x3ffe];			/* 0x8002-0xbfff */
    108       1.2    chopps 	u_short ResetBoard;			/* 0xc000 reset board & run, */
    109       1.2    chopps 						/*  6502 RESET line held high */
    110       1.1    chopps };
    111       1.1    chopps 
    112       1.5        is #undef MSC_MEMPAD1
    113       1.5        is #undef MSC_MEMPAD2
    114       1.2    chopps 
    115       1.1    chopps struct mscdevice {
    116       1.1    chopps 	volatile struct mscmemory *board;	/* where the board is located */
    117       1.1    chopps 	int flags;			/* modem control flags */
    118       1.1    chopps 	int openflags;			/* flags for device open */
    119       1.5        is 	u_char unit;			/* which unit (ie. which board) */
    120       1.1    chopps 	u_char port;			/* which port on the board (0-6) */
    121       1.1    chopps 	u_char active;			/* does this port have hardware? */
    122       1.1    chopps 	u_char closing;			/* are we flushing before close? */
    123       1.1    chopps 	char tmpbuf[IOBUFLEN];		/* temp buffer for data transfers */
    124       1.1    chopps };
    125       1.1    chopps 
    126       1.2    chopps #define	MSCINCTL_CHAR	0	/* corresponding byte in InBuf is a character */
    127       1.2    chopps #define	MSCINCTL_EVENT	1	/* corresponding byte in InBuf is an event */
    128       1.2    chopps 
    129       1.2    chopps #define	MSCEVENT_Break		1	/* break set */
    130       1.2    chopps #define	MSCEVENT_CarrierOn	2	/* carrier raised */
    131       1.2    chopps #define	MSCEVENT_CarrierOff	3	/* carrier dropped */
    132       1.2    chopps 
    133       1.2    chopps #define	MSCCMD_Enable		0x1	/* enable/DTR bit */
    134       1.2    chopps #define	MSCCMD_Close		0x2	/* close the device */
    135       1.2    chopps #define	MSCCMD_Open		0xb	/* open the device */
    136       1.2    chopps #define	MSCCMD_CMask		0xf	/* command mask */
    137       1.2    chopps #define	MSCCMD_RTSOff		0x0  	/* turn off RTS */
    138       1.2    chopps #define	MSCCMD_RTSOn		0x8	/* turn on RTS */
    139       1.4    chopps #define	MSCCMD_Break		0xd	/* transmit a break */
    140       1.2    chopps #define	MSCCMD_RTSMask		0xc	/* mask for RTS stuff */
    141       1.2    chopps #define	MSCCMD_NoParity		0x00	/* don't use parity */
    142       1.2    chopps #define	MSCCMD_OddParity	0x20	/* odd parity */
    143       1.2    chopps #define	MSCCMD_EvenParity	0x60	/* even parity */
    144       1.2    chopps #define	MSCCMD_ParityMask	0xe0	/* parity mask */
    145       1.2    chopps 
    146       1.2    chopps #define	MSCPARAM_B115200	0x0	/* baud rates */
    147       1.2    chopps #define	MSCPARAM_B50		0x1
    148       1.2    chopps #define	MSCPARAM_B75		0x2
    149       1.2    chopps #define	MSCPARAM_B110		0x3
    150       1.2    chopps #define	MSCPARAM_B134		0x4
    151       1.2    chopps #define	MSCPARAM_B150		0x5
    152       1.2    chopps #define	MSCPARAM_B300		0x6
    153       1.2    chopps #define	MSCPARAM_B600		0x7
    154       1.2    chopps #define	MSCPARAM_B1200		0x8
    155       1.2    chopps #define	MSCPARAM_B1800		0x9
    156       1.2    chopps #define	MSCPARAM_B2400		0xa
    157       1.2    chopps #define	MSCPARAM_B3600		0xb
    158       1.2    chopps #define	MSCPARAM_B4800		0xc
    159       1.2    chopps #define	MSCPARAM_B7200		0xd
    160       1.2    chopps #define	MSCPARAM_B9600		0xe
    161       1.2    chopps #define	MSCPARAM_B19200		0xf
    162       1.2    chopps #define	MSCPARAM_BaudMask	0xf	/* baud rate mask */
    163       1.2    chopps #define	MSCPARAM_RcvBaud	0x10	/* enable receive baud rate */
    164       1.2    chopps #define	MSCPARAM_8Bit		0x00	/* numbers of bits */
    165       1.2    chopps #define	MSCPARAM_7Bit		0x20
    166       1.2    chopps #define	MSCPARAM_6Bit		0x40
    167       1.2    chopps #define	MSCPARAM_5Bit		0x60
    168       1.2    chopps #define	MSCPARAM_BitMask	0x60	/* numbers of bits mask */
    169       1.2    chopps 
    170       1.2    chopps /* tty number from device */
    171       1.2    chopps #define	MSCTTY(dev)	(minor(dev) & 0x7e)
    172       1.2    chopps 
    173       1.2    chopps /* slot number from device */
    174       1.2    chopps #define	MSCSLOT(dev)	((minor(dev) & 0x7e)>>1)
    175       1.2    chopps 
    176       1.2    chopps /* dialin mode from device */
    177       1.2    chopps #define	MSCDIALIN(dev)	(minor(dev) & 0x01)
    178       1.2    chopps 
    179       1.2    chopps /* board number from device */
    180       1.2    chopps #define	MSCBOARD(dev)	((minor(dev))>>4)
    181       1.2    chopps 
    182       1.2    chopps /* line number from device */
    183       1.2    chopps #define	MSCLINE(dev)	(((minor(dev)) & 0xe)>>1)
    184       1.2    chopps 
    185       1.2    chopps /* number of slots */
    186       1.2    chopps #define	MSCSLOTS	((NMSC-1)*8+7)
    187       1.2    chopps 
    188       1.2    chopps /* number of ttys */
    189       1.2    chopps #define	MSCTTYS		(MSCSLOTS*2)
    190       1.2    chopps 
    191       1.2    chopps /* board number given slot number */
    192       1.2    chopps #define	MSCUNIT(slot)	((slot)>>3)
    193       1.2    chopps 
    194       1.2    chopps /* slot number given unit and line */
    195       1.2    chopps #define	MSCSLOTUL(unit,line)	(((unit)<<3)+(line))
    196       1.1    chopps 
    197       1.2    chopps /* tty number given slot */
    198       1.2    chopps #define	MSCTTYSLOT(slot)	((slot)<<1)
    199       1.1    chopps 
    200       1.1    chopps #ifndef TRUE
    201       1.2    chopps #define	TRUE	1
    202       1.2    chopps #define	FALSE	0
    203       1.1    chopps #endif
    204