SCSI and ST506 support for the VAXstation architecture.
This commit is contained in:
parent
a8f6512e6d
commit
38b1264285
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,170 @@
|
|||
/* $NetBSD: dc7085cons.h,v 1.1 1996/07/20 18:55:10 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Ralph Campbell and Rick Macklem.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)dc7085cons.h 8.1 (Berkeley) 6/10/93
|
||||
*
|
||||
* dc7085.h --
|
||||
*
|
||||
* Definitions for the dc7085 chip.
|
||||
*
|
||||
* Copyright (C) 1989 Digital Equipment Corporation.
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appears in all copies.
|
||||
* Digital Equipment Corporation makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* from: Header: /sprite/src/kernel/dev/ds3100.md/RCS/dc7085.h,
|
||||
*
|
||||
* v 1.4 89/08/15 19:52:46 rab Exp SPRITE (DECWRL)
|
||||
*/
|
||||
|
||||
#ifndef _DC7085
|
||||
#define _DC7085
|
||||
|
||||
typedef volatile struct dc7085regs {
|
||||
u_short dc_csr; /* control and status (R/W) */
|
||||
u_short pad0;
|
||||
short dc_rbuf_lpr; /* receiver data (R), line params (W) */
|
||||
u_short pad1;
|
||||
u_short dc_tcr; /* transmitter control (R/W) */
|
||||
u_short pad2;
|
||||
u_short dc_msr_tdr; /* modem status (R), transmit data (W) */
|
||||
} dcregs;
|
||||
#define dc_rbuf dc_rbuf_lpr
|
||||
#define dc_lpr dc_rbuf_lpr
|
||||
#define dc_msr dc_msr_tdr
|
||||
#define dc_tdr dc_msr_tdr
|
||||
|
||||
/*
|
||||
* Control status register bits.
|
||||
*/
|
||||
#define CSR_TRDY 0x8000
|
||||
#define CSR_TIE 0x4000 /* not avail on VS2000 */
|
||||
#define CSR_TX_LINE_NUM 0x0300
|
||||
#define CSR_RDONE 0x0080
|
||||
#define CSR_RIE 0x0040 /* not avail on VS2000 */
|
||||
#define CSR_MSE 0x0020
|
||||
#define CSR_CLR 0x0010
|
||||
#define CSR_MAINT 0x0008
|
||||
|
||||
/*
|
||||
* Receiver buffer register bits.
|
||||
*/
|
||||
#define RBUF_DVAL 0x8000
|
||||
#define RBUF_OERR 0x4000
|
||||
#define RBUF_FERR 0x2000
|
||||
#define RBUF_PERR 0x1000
|
||||
#define RBUF_LINE_NUM 0x0300
|
||||
#define RBUF_LINE_NUM_SHIFT 8
|
||||
#define RBUF_CHAR 0x00FF
|
||||
|
||||
/*
|
||||
* Transmit control register values.
|
||||
*/
|
||||
#define TCR_DTR2 0x0400
|
||||
#define TCR_EN3 0x0008
|
||||
#define TCR_EN2 0x0004
|
||||
#define TCR_EN1 0x0002
|
||||
#define TCR_EN0 0x0001
|
||||
|
||||
#define TCR_RTS2 0x0800 /* VS2000: LLBK_2 */
|
||||
#define TCR_RTS3 0x0200 /* VS2000: DSRS_2 */
|
||||
#define TCR_DTR3 0x0100 /* VS2000: RTS_2 */
|
||||
|
||||
/*
|
||||
* Line parameter register bits.
|
||||
*/
|
||||
#define LPR_RXENAB 0x1000
|
||||
#define LPR_B50 0x0000
|
||||
#define LPR_B75 0x0100
|
||||
#define LPR_B110 0x0200
|
||||
#define LPR_B134 0x0300
|
||||
#define LPR_B150 0x0400
|
||||
#define LPR_B300 0x0500
|
||||
#define LPR_B600 0x0600
|
||||
#define LPR_B1200 0x0700
|
||||
#define LPR_B1800 0x0800
|
||||
#define LPR_B2000 0x0900
|
||||
#define LPR_B2400 0x0A00
|
||||
#define LPR_B3600 0x0B00
|
||||
#define LPR_B4800 0x0C00
|
||||
#define LPR_B7200 0x0D00
|
||||
#define LPR_B9600 0x0E00
|
||||
#define LPR_B19200 0x0F00
|
||||
#define LPR_B38400 0x0F00
|
||||
#define LPR_OPAR 0x0080
|
||||
#define LPR_PARENB 0x0040
|
||||
#define LPR_2_STOP 0x0020
|
||||
#define LPR_8_BIT_CHAR 0x0018
|
||||
#define LPR_7_BIT_CHAR 0x0010
|
||||
#define LPR_6_BIT_CHAR 0x0008
|
||||
#define LPR_5_BIT_CHAR 0x0000
|
||||
|
||||
/*
|
||||
* Modem status register bits.
|
||||
*/
|
||||
#define MSR_DSR2 0x0200
|
||||
|
||||
#define MSR_RI2 0x0800 /* VS2000: 0x0004 */
|
||||
#define MSR_CD2 0x0400
|
||||
#define MSR_CTS2 0x0100
|
||||
#define MSR_RI3 0x0008 /* VS2000: not used/available */
|
||||
#define MSR_CD3 0x0004 /* VS2000: RI2 */
|
||||
#define MSR_DSR3 0x0002 /* VS2000: MBZ */
|
||||
#define MSR_CTS3 0x0001 /* VS2000: TMI_2 */
|
||||
|
||||
/*
|
||||
* The four serial ports.
|
||||
*/
|
||||
#define DCKBD_PORT 0
|
||||
#define DCMOUSE_PORT 1
|
||||
#define DCCOMM_PORT 2
|
||||
#define DCPRINTER_PORT 3
|
||||
|
||||
/* bits in dm lsr, copied from dmreg.h */
|
||||
#define DML_DSR 0000400 /* data set ready, not a real DM bit */
|
||||
#define DML_RNG 0000200 /* ring */
|
||||
#define DML_CAR 0000100 /* carrier detect */
|
||||
#define DML_CTS 0000040 /* clear to send */
|
||||
#define DML_SR 0000020 /* secondary receive */
|
||||
#define DML_ST 0000010 /* secondary transmit */
|
||||
#define DML_RTS 0000004 /* request to send */
|
||||
#define DML_DTR 0000002 /* data terminal ready */
|
||||
#define DML_LE 0000001 /* line enable */
|
||||
|
||||
#endif /* _DC7085 */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,196 @@
|
|||
/* $NetBSD: hdc9224.h,v 1.1 1996/07/20 18:55:12 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Ludd by Bertram Barth.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed at Ludd, University of
|
||||
* Lule}, Sweden and its contributors.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
struct hdc9224_DKCreg {
|
||||
unsigned char dkc_reg; /* Disk Register Data Access Port (rw)*/
|
||||
unsigned char fill[3]; /* bytes are longword aligned */
|
||||
unsigned char dkc_cmd; /* Disk Controller Command Port (wo) */
|
||||
#define dkc_stat dkc_cmd /* Interrupt Status Port (ro) */
|
||||
};
|
||||
|
||||
/*
|
||||
* definition of some commands (constant bits only, incomplete!)
|
||||
*/
|
||||
#define DKC_CMD_RESET 0x00 /* terminate non-data-transfer cmds */
|
||||
#define DKC_CMD_DRDESELECT 0x01 /* done when no drive is in use */
|
||||
#define DKC_CMD_SETREGPTR 0x40 /* logically or-ed with reg-number */
|
||||
#define DKC_CMD_DRSELECT 0x20
|
||||
#define DKC_CMD_DRSEL_HDD 0x24 /* select HDD, or-ed with unit-numb. */
|
||||
#define DKC_CMD_DRSEL_RX33 0x28 /* or-ed with unit-number of RX33 */
|
||||
#define DKC_CMD_DRSEL_RX50 0x2C /* or-ed with unit-number of RX50 */
|
||||
#define DKC_CMD_RESTORE 0x02
|
||||
#define DKC_CMD_STEP 0x04
|
||||
#define DKC_CMD_STEPIN_FDD 0x04 /* one step inward for floppy */
|
||||
#define DKC_CMD_STEPOUT_FDD 0x06 /* one step outward (toward cyl #0) */
|
||||
#define DKC_CMD_POLLDRIVE 0x10
|
||||
#define DKC_CMD_SEEKREADID 0x50
|
||||
#define DKC_CMD_FORMATTRACK 0x60
|
||||
#define DKC_CMD_READTRACK 0x5A
|
||||
#define DKC_CMD_READPHYSICAL 0x58
|
||||
#define DKC_CMD_READLOGICAL 0x5C
|
||||
#define DKC_CMD_READ_HDD 0x5D /* read-logical, bypass=0, xfer=1 */
|
||||
#define DKC_CMD_READ_RX33 0x5D /* ??? */
|
||||
#define DKC_CMD_WRITEPHYSICAL 0x80
|
||||
#define DKC_CMD_WRITELOGICAL 0xC0
|
||||
#define DKC_CMD_WRITE_HDD 0xA0 /* bypass=0, ddmark=0 */
|
||||
#define DKC_CMD_WRITE_RX33 0xA1 /* precompensation differs... */
|
||||
#define DKC_CMD_WRITE_RX50 0xA4
|
||||
|
||||
/*
|
||||
* Definition of bits in the DKC_STAT register
|
||||
*/
|
||||
#define DKC_ST_INTPEND (1<<7) /* interrupt pending */
|
||||
#define DKC_ST_DMAREQ (1<<6) /* DMA request */
|
||||
#define DKC_ST_DONE (1<<5) /* command done */
|
||||
#define DKC_ST_TERMCOD (3<<3) /* termination code (see below) */
|
||||
#define DKC_ST_RDYCHNG (1<<2) /* ready change */
|
||||
#define DKC_ST_OVRUN (1<<1) /* overrun/underrun */
|
||||
#define DKC_ST_BADSECT (1<<0) /* bad sector */
|
||||
|
||||
/*
|
||||
* Definition of the termination codes
|
||||
*/
|
||||
#define DKC_TC_SUCCESS (0<<3) /* Successful completion */
|
||||
#define DKC_TC_RDIDERR (1<<3) /* Error in READ-ID sequence */
|
||||
#define DKC_TC_VRFYERR (2<<3) /* Error in VERIFY sequence */
|
||||
#define DKC_TC_DATAERR (3<<3) /* Error in DATA-TRANSFER seq. */
|
||||
|
||||
/*
|
||||
* Definitions of delays neccessary for floppy-operation
|
||||
*/
|
||||
#define DKC_DELAY_MOTOR 500 /* allow 500 ms to reach speed */
|
||||
#define DKC_DELAY_SELECT 70 /* 70 ms for data-recovery-circuit */
|
||||
#define DKC_DELAY_POSITION 59 /* 59 ms for RX33, 100 ms for RX50 */
|
||||
#define DKC_DELAY_HEADSET 18 /* 18 ms when changing head-number */
|
||||
|
||||
/*
|
||||
* The HDC9224 has 11/15(?) internal registers which are accessible via
|
||||
* the Disk-Register-Data-Access-Port DKC_REG
|
||||
*/
|
||||
struct hdc9224_UDCreg { /* internal disk controller registers */
|
||||
u_char udc_dma7; /* 0: DMA adress bits 0 - 7 */
|
||||
u_char udc_dma15; /* 1: DMA adress bits 8 - 15 */
|
||||
u_char udc_dma23; /* 2: DMA adress bits 16 - 23 */
|
||||
u_char udc_dsect; /* 3: desired/starting sector number */
|
||||
#define udc_csect udc_dsect /* current sector number */
|
||||
u_char udc_dhead; /* 4: cyl-bits 8-10, desired head number */
|
||||
#define udc_chead udc_dhead /* current head number */
|
||||
u_char udc_dcyl; /* 5: desired cylinder number */
|
||||
#define udc_ccyl udc_dcyl /* current cylinder number */
|
||||
u_char udc_scnt; /* 6: sector count register */
|
||||
u_char udc_rtcnt; /* 7: retry count register */
|
||||
u_char udc_mode; /* 8: operation mode/chip status */
|
||||
#define udc_cstat udc_mode /* chip status register */
|
||||
u_char udc_term; /* 9: termination conditions/drive status */
|
||||
#define udc_dstat udc_term /* drive status register */
|
||||
u_char udc_data; /* 10: data */
|
||||
};
|
||||
|
||||
/*
|
||||
* Definition of bits in the Current-Head register
|
||||
*/
|
||||
#define UDC_CH_BADSECT (1<<7) /* indicates a bad sector (if bypass=0) */
|
||||
#define UDC_CH_CYLBITS (0x70) /* bits 10-8 of current cylinder number */
|
||||
#define UDC_CH_HEADNO (0x0F) /* current head number */
|
||||
|
||||
/*
|
||||
* Definition of bits in the Retry-Count register
|
||||
*/
|
||||
#define UDC_RC_RTRYCNT (0xF0) /* 1's compl. in read-log, 0 all others */
|
||||
#define UDC_RC_RXDISAB (1<<3) /* must/should be 0 for normal operation */
|
||||
#define UDC_RC_INVRDY (1<<2) /* polarity of floppy-status, important! */
|
||||
#define UDC_RC_MOTOR (1<<1) /* turn on floppy-motor, no effect on HDD */
|
||||
#define UDC_RC_LOSPEED (1<<0) /* floppy-speed select, RX33: 0, RX50: 1 */
|
||||
|
||||
#define UDC_RC_HDD_READ 0xF2 /* 0x72 ??? */
|
||||
#define UDC_RC_HDD_WRT 0xF2 /* 0xF0 ??? */
|
||||
#define UDC_RC_RX33READ 0x76 /* enable retries when reading floppies */
|
||||
#define UDC_RC_RX33WRT 0xF6
|
||||
#define UDC_RC_RX50READ 0x77 /* enable retries when reading floppies */
|
||||
#define UDC_RC_RX50WRT 0xF7
|
||||
|
||||
/*
|
||||
* Definition of bits in the Operating-Mode register
|
||||
*/
|
||||
#define UDC_MD_HDMODE (1<<7) /* must be 1 for all FDD and HDD */
|
||||
#define UDC_MD_CHKCOD (3<<5) /* error-check: FDD/CRC: 0, HDD/ECC: 1 */
|
||||
#define UDC_MD_DENS (1<<4) /* density select, must be 0 */
|
||||
#define UDC_MD_UNUSED (1<<3) /* bit 3 is not used and must be 0 */
|
||||
#define UDC_MD_SRATE (7<<0) /* seek step rate */
|
||||
|
||||
#define UDC_MD_HDD 0xC0
|
||||
#define UDC_MD_RX33 0x82
|
||||
#define UDC_MD_RX50 0x81
|
||||
|
||||
/*
|
||||
* Definition of bits in the Chip-Status register
|
||||
*/
|
||||
#define UDC_CS_RETREQ (1<<7) /* retry required */
|
||||
#define UDC_CS_ECCATT (1<<6) /* error correction attempted */
|
||||
#define UDC_CS_ECCERR (1<<5) /* ECC/CRC error */
|
||||
#define UDC_CS_DELDATA (1<<4) /* deleted data mark */
|
||||
#define UDC_CS_SYNCERR (1<<3) /* synchronization error */
|
||||
#define UDC_CS_COMPERR (1<<2) /* compare error */
|
||||
#define UDC_CS_PRESDRV (0x3) /* present drive selected */
|
||||
|
||||
/*
|
||||
* Definition of bits in the Termination-Conditions register
|
||||
*/
|
||||
#define UDC_TC_CRCPRE (1<<7) /* CRC register preset, must be 1 */
|
||||
#define UDC_TC_UNUSED (1<<6) /* bit 6 is not used and must be 0 */
|
||||
#define UDC_TC_INTDONE (1<<5) /* interrupt on done */
|
||||
#define UDC_TC_TDELDAT (1<<4) /* terminate on deleted data */
|
||||
#define UDC_TC_TDSTAT3 (1<<3) /* terminate on drive status 3 change */
|
||||
#define UDC_TC_TWPROT (1<<2) /* terminate on write-protect (FDD only) */
|
||||
#define UDC_TC_INTRDCH (1<<1) /* interrupt on ready change (FDD only) */
|
||||
#define UDC_TC_TWRFLT (1<<0) /* interrupt on write-fault (HDD only) */
|
||||
|
||||
#define UDC_TC_HDD 0xA5 /* 0xB5 ??? */
|
||||
#define UDC_TC_FDD 0xA0 /* 0xAA ??? 0xB4 ??? */
|
||||
|
||||
/*
|
||||
* Definition of bits in the Disk-Status register
|
||||
*/
|
||||
#define UDC_DS_SELACK (1<<7) /* select acknowledge (harddisk only!) */
|
||||
#define UDC_DS_INDEX (1<<6) /* index point */
|
||||
#define UDC_DS_SKCOM (1<<5) /* seek complete */
|
||||
#define UDC_DS_TRK00 (1<<4) /* track 0 */
|
||||
#define UDC_DS_DSTAT3 (1<<3) /* drive status 3 (MBZ) */
|
||||
#define UDC_DS_WRPROT (1<<2) /* write protect (floppy only!) */
|
||||
#define UDC_DS_READY (1<<1) /* drive ready bit */
|
||||
#define UDC_DS_WRFAULT (1<<0) /* write fault */
|
||||
|
||||
|
|
@ -0,0 +1,394 @@
|
|||
/*
|
||||
* The LK201 keycode mapping routine is here, along with initialization
|
||||
* functions for the keyboard and mouse.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/select.h>
|
||||
#include <dev/cons.h>
|
||||
|
||||
#include <pmax/include/pmioctl.h>
|
||||
|
||||
#include <pmax/dev/lk201.h>
|
||||
|
||||
|
||||
/* Exported functions */
|
||||
extern int kbdMapChar __P((int keycode));
|
||||
|
||||
extern void KBDReset __P(( dev_t dev, void (*putc) (dev_t, int) ));
|
||||
|
||||
/*
|
||||
* Keyboard to Ascii, unshifted.
|
||||
*/
|
||||
static unsigned char unshiftedAscii[] = {
|
||||
/* 0 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 4 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 8 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 10 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 14 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 18 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 1c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 20 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 24 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 28 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 2c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 30 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 34 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 38 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 3c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 40 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 44 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 48 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 4c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 50 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 54 */ KBD_NOKEY, KBD_NOKEY, KBD_F1, KBD_F2,
|
||||
/* 58 */ KBD_F3, KBD_F4, KBD_F5, KBD_NOKEY,
|
||||
/* 5c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 60 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 64 */ KBD_F6, KBD_F7, KBD_F8, KBD_F9,
|
||||
/* 68 */ KBD_F10, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 6c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 70 */ KBD_NOKEY, '\033', KBD_F12, KBD_F13,
|
||||
/* 74 */ KBD_F14, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 78 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 7c */ KBD_HELP, KBD_DO, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 80 */ KBD_F17, KBD_F18, KBD_F19, KBD_F20,
|
||||
/* 84 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 88 */ KBD_NOKEY, KBD_NOKEY, KBD_FIND, KBD_INSERT,
|
||||
/* 8c */ KBD_REMOVE, KBD_SELECT, KBD_PREVIOUS, KBD_NEXT,
|
||||
/* 90 */ KBD_NOKEY, KBD_NOKEY, '0', KBD_NOKEY,
|
||||
/* 94 */ '.', KBD_KP_ENTER, '1', '2',
|
||||
/* 98 */ '3', '4', '5', '6',
|
||||
/* 9c */ ',', '7', '8', '9',
|
||||
/* a0 */ '-', KBD_KP_F1, KBD_KP_F2, KBD_KP_F3,
|
||||
/* a4 */ KBD_KP_F4, KBD_NOKEY, KBD_NOKEY, KBD_LEFT,
|
||||
/* a8 */ KBD_RIGHT, KBD_DOWN, KBD_UP, KBD_NOKEY,
|
||||
/* ac */ KBD_NOKEY, KBD_NOKEY, KBD_SHIFT, KBD_CONTROL,
|
||||
/* b0 */ KBD_CAPSLOCK, KBD_ALTERNATE, KBD_NOKEY, KBD_NOKEY,
|
||||
/* b4 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* b8 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* bc */ KBD_DEL, KBD_RET, KBD_TAB, '`',
|
||||
/* c0 */ '1', 'q', 'a', 'z',
|
||||
/* c4 */ KBD_NOKEY, '2', 'w', 's',
|
||||
/* c8 */ 'x', '<', KBD_NOKEY, '3',
|
||||
/* cc */ 'e', 'd', 'c', KBD_NOKEY,
|
||||
/* d0 */ '4', 'r', 'f', 'v',
|
||||
/* d4 */ ' ', KBD_NOKEY, '5', 't',
|
||||
/* d8 */ 'g', 'b', KBD_NOKEY, '6',
|
||||
/* dc */ 'y', 'h', 'n', KBD_NOKEY,
|
||||
/* e0 */ '7', 'u', 'j', 'm',
|
||||
/* e4 */ KBD_NOKEY, '8', 'i', 'k',
|
||||
/* e8 */ ',', KBD_NOKEY, '9', 'o',
|
||||
/* ec */ 'l', '.', KBD_NOKEY, '0',
|
||||
/* f0 */ 'p', KBD_NOKEY, ';', '/',
|
||||
/* f4 */ KBD_NOKEY, '=', ']', '\\',
|
||||
/* f8 */ KBD_NOKEY, '-', '[', '\'',
|
||||
/* fc */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
};
|
||||
|
||||
/*
|
||||
* Keyboard to Ascii, shifted.
|
||||
*/
|
||||
static unsigned char shiftedAscii[] = {
|
||||
/* 0 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 4 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 8 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 10 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 14 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 18 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 1c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 20 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 24 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 28 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 2c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 30 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 34 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 38 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 3c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 40 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 44 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 48 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 4c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 50 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 54 */ KBD_NOKEY, KBD_NOKEY, KBD_F1, KBD_F2,
|
||||
/* 58 */ KBD_F3, KBD_F4, KBD_F5, KBD_NOKEY,
|
||||
/* 5c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 60 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 64 */ KBD_F6, KBD_F7, KBD_F8, KBD_F9,
|
||||
/* 68 */ KBD_F10, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 6c */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 70 */ KBD_NOKEY, KBD_F11, KBD_F12, KBD_F13,
|
||||
/* 74 */ KBD_F14, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 78 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 7c */ KBD_HELP, KBD_DO, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 80 */ KBD_F17, KBD_F18, KBD_F19, KBD_F20,
|
||||
/* 84 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* 88 */ KBD_NOKEY, KBD_NOKEY, KBD_FIND, KBD_INSERT,
|
||||
/* 8c */ KBD_REMOVE, KBD_SELECT, KBD_PREVIOUS, KBD_NEXT,
|
||||
/* 90 */ KBD_NOKEY, KBD_NOKEY, '0', KBD_NOKEY,
|
||||
/* 94 */ '.', KBD_KP_ENTER, '1', '2',
|
||||
/* 98 */ '3', '4', '5', '6',
|
||||
/* 9c */ ',', '7', '8', '9',
|
||||
/* a0 */ '-', KBD_KP_F1, KBD_KP_F2, KBD_KP_F3,
|
||||
/* a4 */ KBD_KP_F4, KBD_NOKEY, KBD_NOKEY, KBD_LEFT,
|
||||
/* a8 */ KBD_RIGHT, KBD_DOWN, KBD_UP, KBD_NOKEY,
|
||||
/* ac */ KBD_NOKEY, KBD_NOKEY, KBD_SHIFT, KBD_CONTROL,
|
||||
/* b0 */ KBD_CAPSLOCK, KBD_ALTERNATE, KBD_NOKEY, KBD_NOKEY,
|
||||
/* b4 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* b8 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
/* bc */ KBD_DEL, KBD_RET, KBD_TAB, '~',
|
||||
/* c0 */ '!', 'q', 'a', 'z',
|
||||
/* c4 */ KBD_NOKEY, '@', 'w', 's',
|
||||
/* c8 */ 'x', '>', KBD_NOKEY, '#',
|
||||
/* cc */ 'e', 'd', 'c', KBD_NOKEY,
|
||||
/* d0 */ '$', 'r', 'f', 'v',
|
||||
/* d4 */ ' ', KBD_NOKEY, '%', 't',
|
||||
/* d8 */ 'g', 'b', KBD_NOKEY, '^',
|
||||
/* dc */ 'y', 'h', 'n', KBD_NOKEY,
|
||||
/* e0 */ '&', 'u', 'j', 'm',
|
||||
/* e4 */ KBD_NOKEY, '*', 'i', 'k',
|
||||
/* e8 */ '<', KBD_NOKEY, '(', 'o',
|
||||
/* ec */ 'l', '>', KBD_NOKEY, ')',
|
||||
/* f0 */ 'p', KBD_NOKEY, ':', '?',
|
||||
/* f4 */ KBD_NOKEY, '+', '}', '|',
|
||||
/* f8 */ KBD_NOKEY, '_', '{', '"',
|
||||
/* fc */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
|
||||
};
|
||||
|
||||
/*
|
||||
* Keyboard initialization string.
|
||||
*/
|
||||
static u_char kbdInitString[] = {
|
||||
LK_LED_ENABLE, LED_ALL, /* show we are resetting keyboard */
|
||||
LK_DEFAULTS,
|
||||
LK_CMD_MODE(LK_AUTODOWN, 1),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 2),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 3),
|
||||
LK_CMD_MODE(LK_DOWN, 4), /* could also be LK_AUTODOWN */
|
||||
LK_CMD_MODE(LK_UPDOWN, 5),
|
||||
LK_CMD_MODE(LK_UPDOWN, 6),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 7),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 8),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 9),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 10),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 11),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 12),
|
||||
LK_CMD_MODE(LK_DOWN, 13),
|
||||
LK_CMD_MODE(LK_AUTODOWN, 14),
|
||||
LK_AR_ENABLE, /* we want autorepeat by default */
|
||||
LK_CL_ENABLE, 0x83, /* keyclick, volume */
|
||||
LK_KBD_ENABLE, /* the keyboard itself */
|
||||
LK_BELL_ENABLE, 0x83, /* keyboard bell, volume */
|
||||
LK_LED_DISABLE, LED_ALL, /* clear keyboard leds */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the Keyboard.
|
||||
*/
|
||||
void
|
||||
KBDReset(kbddev, putc)
|
||||
dev_t kbddev;
|
||||
void (*putc) __P((dev_t, int));
|
||||
{
|
||||
register int i;
|
||||
static int inKBDReset;
|
||||
|
||||
if (inKBDReset)
|
||||
return;
|
||||
inKBDReset = 1;
|
||||
for (i = 0; i < sizeof(kbdInitString); i++)
|
||||
(*putc)(kbddev, (int)kbdInitString[i]);
|
||||
inKBDReset = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* kbdMapChar --
|
||||
*
|
||||
* Map characters from the keyboard to ASCII. Return -1 if there is
|
||||
* no valid mapping.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* Remember state of shift and control keys.
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
kbdMapChar(cc)
|
||||
int cc;
|
||||
{
|
||||
static u_char shiftDown;
|
||||
static u_char ctrlDown;
|
||||
static u_char lastChar;
|
||||
|
||||
switch (cc) {
|
||||
case KEY_REPEAT:
|
||||
cc = lastChar;
|
||||
goto done;
|
||||
|
||||
case KEY_UP:
|
||||
shiftDown = 0;
|
||||
ctrlDown = 0;
|
||||
return (-1);
|
||||
|
||||
case KEY_SHIFT:
|
||||
case KEY_R_SHIFT:
|
||||
if (ctrlDown || shiftDown)
|
||||
shiftDown = 0;
|
||||
else
|
||||
shiftDown = 1;
|
||||
return (-1);
|
||||
|
||||
case KEY_CONTROL:
|
||||
if (shiftDown || ctrlDown)
|
||||
ctrlDown = 0;
|
||||
else
|
||||
ctrlDown = 1;
|
||||
return (-1);
|
||||
|
||||
case LK_POWER_ERROR:
|
||||
case LK_KDOWN_ERROR:
|
||||
case LK_INPUT_ERROR:
|
||||
case LK_OUTPUT_ERROR:
|
||||
log(LOG_WARNING,
|
||||
"lk201: keyboard error, code=%x\n", cc);
|
||||
return (-1);
|
||||
}
|
||||
if (shiftDown)
|
||||
cc = shiftedAscii[cc];
|
||||
else
|
||||
cc = unshiftedAscii[cc];
|
||||
if (cc >= KBD_NOKEY) {
|
||||
/*
|
||||
* A function key was typed - ignore it.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
if (cc >= 'a' && cc <= 'z') {
|
||||
if (ctrlDown)
|
||||
cc = cc - 'a' + '\1'; /* ^A */
|
||||
else if (shiftDown)
|
||||
cc = cc - 'a' + 'A';
|
||||
} else if (ctrlDown) {
|
||||
if (cc >= '[' && cc <= '_')
|
||||
cc = cc - '@';
|
||||
else if (cc == ' ' || cc == '@')
|
||||
cc = '\0';
|
||||
}
|
||||
lastChar = cc;
|
||||
done:
|
||||
return (cc);
|
||||
}
|
||||
|
||||
|
||||
static int (*raw_kbd_getc) __P((dev_t dev)) = NULL;
|
||||
static dev_t lk_in_dev = NODEV;
|
||||
|
||||
/*
|
||||
* Divert input from a serial port to the lk-201 keyboard handler.
|
||||
*/
|
||||
void
|
||||
lk_divert(getfn, in_dev)
|
||||
int (*getfn) __P ((dev_t dev)) ;
|
||||
dev_t in_dev;
|
||||
{
|
||||
raw_kbd_getc = getfn;
|
||||
lk_in_dev = in_dev;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get an ASCII character off of the keyboard.
|
||||
* Simply pass the getc request onto the underlying
|
||||
* serial driver, and map the resulting LK-201 keycode to ASCII.
|
||||
* FIXME: this design can't handle cursor or keypad keys,
|
||||
* and should be thrown away and replaced with a stackable
|
||||
* "Bstreams"-style driver.
|
||||
*/
|
||||
int
|
||||
LKgetc(dev)
|
||||
dev_t dev; /* ignored */
|
||||
{
|
||||
register int c;
|
||||
|
||||
extern sccGetc();
|
||||
|
||||
#if 0
|
||||
/*XXX*/ printf("LK-201 getc 0x%x( [%d %d]) in_dev [%d %d]\n",
|
||||
raw_kbd_getc,
|
||||
major(dev), minor(dev),
|
||||
major(lk_in_dev), minor(lk_in_dev));
|
||||
#endif
|
||||
|
||||
if (raw_kbd_getc == NULL) {
|
||||
panic("Reading from LK-201 before keyboard driver diverted\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
/* c = (*cn_tab.cn_kbdgetc)(cn_tab.cn_dev); */
|
||||
c = (*raw_kbd_getc) (lk_in_dev);
|
||||
#if 0
|
||||
/*XXX*/ printf(" 0x%x [%c]", c, c);
|
||||
#endif
|
||||
if (c == 0)
|
||||
return (-1);
|
||||
if ((c = kbdMapChar(c & 0xff)) >= 0)
|
||||
break;
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the mouse. (Doesn't really belong here.)
|
||||
*/
|
||||
void
|
||||
MouseInit(mdev, putc, getc)
|
||||
dev_t mdev;
|
||||
void (*putc) __P((dev_t, int));
|
||||
int (*getc) __P((dev_t));
|
||||
{
|
||||
int id_byte1, id_byte2, id_byte3, id_byte4;
|
||||
|
||||
/*
|
||||
* Initialize the mouse.
|
||||
*/
|
||||
(*putc)(mdev, MOUSE_SELF_TEST);
|
||||
id_byte1 = (*getc)(mdev);
|
||||
if (id_byte1 < 0) {
|
||||
printf("MouseInit: Timeout on 1st byte of self-test report\n");
|
||||
return;
|
||||
}
|
||||
id_byte2 = (*getc)(mdev);
|
||||
if (id_byte2 < 0) {
|
||||
printf("MouseInit: Timeout on 2nd byte of self-test report\n");
|
||||
return;
|
||||
}
|
||||
id_byte3 = (*getc)(mdev);
|
||||
if (id_byte3 < 0) {
|
||||
printf("MouseInit: Timeout on 3rd byte of self-test report\n");
|
||||
return;
|
||||
}
|
||||
id_byte4 = (*getc)(mdev);
|
||||
if (id_byte4 < 0) {
|
||||
printf("MouseInit: Timeout on 4th byte of self-test report\n");
|
||||
return;
|
||||
}
|
||||
if ((id_byte2 & 0x0f) != 0x2)
|
||||
printf("MouseInit: We don't have a mouse!!!\n");
|
||||
/*
|
||||
* For some reason, the mouse doesn't see this command if it comes
|
||||
* too soon after a self test.
|
||||
*/
|
||||
DELAY(100);
|
||||
(*putc)(mdev, MOUSE_INCREMENTAL);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,75 @@
|
|||
/* $NetBSD: ncr.h,v 1.1 1996/07/20 18:55:15 ragge Exp $ */
|
||||
|
||||
/*
|
||||
* Register map for the Sun3 SCSI Interface (si)
|
||||
* The first part of this register map is an NCR5380
|
||||
* SCSI Bus Interface Controller (SBIC). The rest is a
|
||||
* DMA controller and custom logic in one of two flavors,
|
||||
* one for the OBIO interface (3/50,3/60) and one for the
|
||||
* VME interface (3/160,3/260,etc.), where some registers
|
||||
* are implemented only on one or the other, some on both.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some of these registers apply to only one interface and some
|
||||
* apply to both. The registers which apply to the Sun3/50 onboard
|
||||
* version only are udc_rdata and udc_raddr. The registers which
|
||||
* apply to the Sun3 vme version only are dma_addr, dma_count, bpr,
|
||||
* iv_am, and bcrh. Thus, the sbc registers, fifo_data, bcr, and csr
|
||||
* apply to both interfaces.
|
||||
* One other feature of the vme interface: a write to the dma count
|
||||
* register also causes a write to the fifo byte count register and
|
||||
* vis versa.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NCR5380 Register map (byte-registers at longword addresses)
|
||||
*/
|
||||
struct ncr5380regs {
|
||||
volatile u_long sci_r0; /* 200C.0080: CUR_DATA/OUT_DATA (rw) */
|
||||
volatile u_long sci_r1; /* 200C.0084: INI_CMD (rw) */
|
||||
volatile u_long sci_r2; /* 200C.0088: MODE (rw) */
|
||||
volatile u_long sci_r3; /* 200C.008C: TAR_CMD (rw) */
|
||||
volatile u_long sci_r4; /* 200C.0090: CUR_STAT/SEL_ENA (rw) */
|
||||
volatile u_long sci_r5; /* 200C.0094: STATUS/DMA_SEND (rw) */
|
||||
volatile u_long sci_r6; /* 200C.0098: IN_DATA/DMA_TRCV (rw) */
|
||||
volatile u_long sci_r7; /* 200C.009C: RESET/DMA_IRCV (rw) */
|
||||
};
|
||||
|
||||
struct si_regs {
|
||||
struct ncr5380regs sci;
|
||||
};
|
||||
|
||||
/* possible values for the address modifier, sun3 vme version only */
|
||||
#define VME_SUPV_DATA_24 0x3d00
|
||||
|
||||
/*
|
||||
* Status Register.
|
||||
* Note:
|
||||
* (r) indicates bit is read only.
|
||||
* (rw) indicates bit is read or write.
|
||||
* (v) vme host adaptor interface only.
|
||||
* (o) sun3/50 onboard host adaptor interface only.
|
||||
* (b) both vme and sun3/50 host adaptor interfaces.
|
||||
*/
|
||||
#define SI_CSR_DMA_ACTIVE 0x8000 /* (r,o) dma transfer active */
|
||||
#define SI_CSR_DMA_CONFLICT 0x4000 /* (r,b) reg accessed while dmaing */
|
||||
#define SI_CSR_DMA_BUS_ERR 0x2000 /* (r,b) bus error during dma */
|
||||
#define SI_CSR_ID 0x1000 /* (r,b) 0 for 3/50, 1 for SCSI-3, */
|
||||
/* 0 if SCSI-3 unmodified */
|
||||
#define SI_CSR_FIFO_FULL 0x0800 /* (r,b) fifo full */
|
||||
#define SI_CSR_FIFO_EMPTY 0x0400 /* (r,b) fifo empty */
|
||||
#define SI_CSR_SBC_IP 0x0200 /* (r,b) sbc interrupt pending */
|
||||
#define SI_CSR_DMA_IP 0x0100 /* (r,b) dma interrupt pending */
|
||||
#define SI_CSR_LOB 0x00c0 /* (r,v) number of leftover bytes */
|
||||
#define SI_CSR_LOB_THREE 0x00c0 /* (r,v) three leftover bytes */
|
||||
#define SI_CSR_LOB_TWO 0x0080 /* (r,v) two leftover bytes */
|
||||
#define SI_CSR_LOB_ONE 0x0040 /* (r,v) one leftover byte */
|
||||
#define SI_CSR_BPCON 0x0020 /* (rw,v) byte packing control */
|
||||
/* dma is in 0=longwords, 1=words */
|
||||
#define SI_CSR_DMA_EN 0x0010 /* (rw,v) dma/interrupt enable */
|
||||
#define SI_CSR_SEND 0x0008 /* (rw,b) dma dir, 1=to device */
|
||||
#define SI_CSR_INTR_EN 0x0004 /* (rw,b) interrupts enable */
|
||||
#define SI_CSR_FIFO_RES 0x0002 /* (rw,b) inits fifo, 0=reset */
|
||||
#define SI_CSR_SCSI_RES 0x0001 /* (rw,b) reset sbc and udc, 0=reset */
|
||||
|
|
@ -0,0 +1,652 @@
|
|||
/* $NetBSD: vsbus.c,v 1.1 1996/07/20 18:55:16 ragge Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Ludd by Bertram Barth.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed at Ludd, University of
|
||||
* Lule}, Sweden and its contributors.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/map.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/dkstat.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <machine/pte.h>
|
||||
#include <machine/sid.h>
|
||||
#include <machine/scb.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/trap.h>
|
||||
#include <machine/nexus.h>
|
||||
|
||||
#include <machine/uvax.h>
|
||||
#include <machine/ka410.h>
|
||||
#include <machine/ka43.h>
|
||||
|
||||
#include <machine/vsbus.h>
|
||||
|
||||
#define trace(x)
|
||||
#define debug(x)
|
||||
|
||||
int vsbus_match __P((struct device *, void *, void *));
|
||||
void vsbus_attach __P((struct device *, struct device *, void *));
|
||||
int vsbus_print __P((void *, char *));
|
||||
|
||||
void ka410_attach __P((struct device *, struct device *, void *));
|
||||
void ka43_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfdriver vsbus_cd = {
|
||||
NULL, "vsbus", DV_DULL
|
||||
};
|
||||
struct cfattach vsbus_ca = {
|
||||
sizeof(struct device), vsbus_match, vsbus_attach
|
||||
};
|
||||
|
||||
/*
|
||||
void vsbus_intr_register __P((struct confargs *ca, int (*)(void*), void*));
|
||||
void vsbus_intr_unregister __P((struct confargs *));
|
||||
*/
|
||||
|
||||
void vsbus_intr_dispatch __P((int i));
|
||||
|
||||
#define VSBUS_MAXDEVS 8
|
||||
#define VSBUS_MAXINTR 8
|
||||
|
||||
struct confargs *vsbus_devs = NULL;
|
||||
|
||||
#ifdef VAX410 /* also: KA420 */
|
||||
struct confargs ka410_devs[] = {
|
||||
/* name intslot intpri intvec intbit ioaddr */
|
||||
{ "dc", 7, 7, 0x2C0, (1<<7), KA410_SER_BASE,
|
||||
6, 6, 0x2C4, (1<<6), 0x01, },
|
||||
{ "dc (xmit)", 6, 6, 0x2C4, (1<<6), KA410_SER_BASE, },
|
||||
{ "le", 5, 5, 0x250, (1<<5), KA410_LAN_BASE,
|
||||
KA410_NWA_BASE, 0x00, },
|
||||
{ "ncr", 1, 1, 0x3F8, (1<<1), KA410_SCS_BASE,
|
||||
KA410_SCS_DADR, KA410_SCS_DCNT, KA410_SCS_DDIR,
|
||||
KA410_DMA_BASE, KA410_DMA_SIZE, 0x00, 0x07, },
|
||||
{ "hdc", 0, 0, 0x3FC, (1<<0), KA410_DKC_BASE,
|
||||
0, 0, 0,
|
||||
KA410_DMA_BASE, KA410_DMA_SIZE, 0x00, },
|
||||
#if 0
|
||||
{ "dc (recv)", 7, 7, 0x2C0, (1<<7), KA410_SER_BASE, },
|
||||
{ "dc (xmit)", 6, 6, 0x2C4, (1<<6), KA410_SER_BASE, },
|
||||
{ "hdc9224", 0, 0, 0x3FC, (1<<0), KA410_DKC_BASE, },
|
||||
{ "ncr5380", 1, 1, 0x3F8, (1<<1), KA410_SCS_BASE, },
|
||||
{ "am7990", 5, 5, 0x250, (1<<5), KA410_LAN_BASE, },
|
||||
{ "NETOPT", 4, 4, 0x254, (1<<4), KA410_LAN_BASE, },
|
||||
#endif
|
||||
{ "" },
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef VAX43
|
||||
struct confargs ka43_devs[] = {
|
||||
/* name intslot intpri intvec intbit ioaddr */
|
||||
{ "dc", 7, 7, 0x2C0, (1<<7), KA43_SER_BASE,
|
||||
6, 6, 0x2C4, (1<<6), 0x01, },
|
||||
{ "dc (xmit)", 6, 6, 0x2C4, (1<<6), KA43_SER_BASE, },
|
||||
{ "le", 5, 5, 0x250, (1<<5), KA43_LAN_BASE,
|
||||
KA43_NWA_BASE, 0x00, },
|
||||
{ "ncr", 1, 1, 0x3F8, (1<<1), KA43_SC1_BASE,
|
||||
KA43_SC1_DADR, KA43_SC1_DCNT, KA43_SC1_DDIR,
|
||||
KA43_DMA_BASE, KA43_DMA_SIZE, 0x01, 0x06, },
|
||||
{ "ncr", 0, 0, 0x3FC, (1<<0), KA43_SC2_BASE,
|
||||
KA43_SC2_DADR, KA43_SC2_DCNT, KA43_SC2_DDIR,
|
||||
KA43_DMA_BASE, KA43_DMA_SIZE, 0x01, 0x06, },
|
||||
#if 0
|
||||
{ "le (2nd)", 4, 4, 0x254, (1<<4), 0x???, },
|
||||
{ "NETOPT", 4, 4, 0x254, (1<<4), 0x???, },
|
||||
#endif
|
||||
{ "" },
|
||||
};
|
||||
#endif
|
||||
|
||||
int
|
||||
vsbus_print(aux, name)
|
||||
void *aux;
|
||||
char *name;
|
||||
{
|
||||
struct confargs *ca = aux;
|
||||
|
||||
trace(("vsbus_print(%x, %s)\n", ca->ca_name, name));
|
||||
|
||||
if (name) {
|
||||
printf ("device %s at %s", ca->ca_name, name);
|
||||
return (UNSUPP);
|
||||
}
|
||||
return (UNCONF);
|
||||
}
|
||||
|
||||
int
|
||||
vsbus_match(parent, cf, aux)
|
||||
struct device *parent;
|
||||
void *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct bp_conf *bp = aux;
|
||||
|
||||
trace(("vsbus_match: bp->type = \"%s\"\n", bp->type));
|
||||
|
||||
if (strcmp(bp->type, "vsbus"))
|
||||
return 0;
|
||||
/*
|
||||
* on machines which can have it, the vsbus is always there
|
||||
*/
|
||||
if ((vax_bustype & VAX_VSBUS) == 0)
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
#if 1 /*------------------------------------------------------------*/
|
||||
#if 1
|
||||
#define REG(name) short name; short X##name##X;
|
||||
#else
|
||||
#define REG(name) int name;
|
||||
#endif
|
||||
static volatile struct {/* base address of DZ-controller: 0x200A0000 */
|
||||
REG(csr); /* 00 Csr: control/status register */
|
||||
REG(rbuf); /* 04 Rbuf/Lpr: receive buffer/line param reg. */
|
||||
REG(tcr); /* 08 Tcr: transmit console register */
|
||||
REG(tdr); /* 0C Msr/Tdr: modem status reg/transmit data reg */
|
||||
REG(lpr0); /* 10 Lpr0: */
|
||||
REG(lpr1); /* 14 Lpr0: */
|
||||
REG(lpr2); /* 18 Lpr0: */
|
||||
REG(lpr3); /* 1C Lpr0: */
|
||||
} *dz = (void*)0x200A0000;
|
||||
extern int dzcnrint();
|
||||
extern int dzcntint();
|
||||
int hardclock_count = 0;
|
||||
int
|
||||
ka410_consintr_enable()
|
||||
{
|
||||
vsbus_intr_enable(&ka410_devs[0]);
|
||||
vsbus_intr_enable(&ka410_devs[1]);
|
||||
}
|
||||
|
||||
int
|
||||
ka410_consRecv_intr(p)
|
||||
void *p;
|
||||
{
|
||||
/* printf("ka410_consRecv_intr: hc-count=%d\n", hardclock_count); */
|
||||
dzcnrint();
|
||||
/* printf("gencnrint() returned.\n"); */
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
ka410_consXmit_intr(p)
|
||||
void *p;
|
||||
{
|
||||
/* printf("ka410_consXmit_intr: hc-count=%d\n", hardclock_count); */
|
||||
dzcntint();
|
||||
/* printf("gencntint() returned.\n"); */
|
||||
return(0);
|
||||
}
|
||||
#endif /*------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
vsbus_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct confargs *ca;
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
trace (("vsbus_attach()\n"));
|
||||
|
||||
printf("vsbus_attach: boardtype = %x\n", vax_boardtype);
|
||||
|
||||
switch (vax_boardtype) {
|
||||
case VAX_BTYP_410:
|
||||
case VAX_BTYP_420:
|
||||
vsbus_devs = ka410_devs;
|
||||
break;
|
||||
|
||||
case VAX_BTYP_43:
|
||||
case VAX_BTYP_46:
|
||||
case VAX_BTYP_49:
|
||||
vsbus_devs = ka43_devs;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("unsupported boardtype 0x%x in vsbus_attach()\n",
|
||||
vax_boardtype);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* first setup interrupt-table, so that devices can register
|
||||
* their interrupt-routines...
|
||||
*/
|
||||
vsbus_intr_setup();
|
||||
|
||||
/*
|
||||
* now check for all possible devices on this "bus"
|
||||
*/
|
||||
for (i=0; i<VSBUS_MAXDEVS; i++) {
|
||||
ca = &vsbus_devs[i];
|
||||
if (*ca->ca_name == '\0')
|
||||
break;
|
||||
config_found(self, (void*)ca, vsbus_print);
|
||||
}
|
||||
|
||||
/*
|
||||
* as long as there's no working DZ-driver, we use this dummy
|
||||
*/
|
||||
vsbus_intr_register(&ka410_devs[0], ka410_consRecv_intr, NULL);
|
||||
vsbus_intr_register(&ka410_devs[1], ka410_consXmit_intr, NULL);
|
||||
}
|
||||
|
||||
#define VSBUS_MAX_INTR 8 /* 64? */
|
||||
/*
|
||||
* interrupt service routines are given an int as argument, which is
|
||||
* pushed onto stack as LITERAL. Thus the value is between 0-63.
|
||||
* This array of 64 might be oversized for now, but it's all which
|
||||
* ever will be possible.
|
||||
*/
|
||||
struct vsbus_ivec {
|
||||
struct ivec_dsp intr_vec; /* this is referenced in SCB */
|
||||
int intr_count; /* keep track of interrupts */
|
||||
int intr_flags; /* valid, etc. */
|
||||
void (*enab)(int); /* enable interrupt */
|
||||
void (*disab)(int); /* disable interrupt */
|
||||
void (*prep)(int); /* need pre-processing? */
|
||||
int (*handler)(void*); /* isr-routine to call */
|
||||
void *hndlarg; /* args to this routine */
|
||||
void (*postp)(int); /* need post-processing? */
|
||||
} vsbus_ivtab[VSBUS_MAX_INTR];
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
int
|
||||
vsbus_intr_setup()
|
||||
{
|
||||
int i;
|
||||
struct vsbus_ivec *ip;
|
||||
extern struct ivec_dsp idsptch; /* subr.s */
|
||||
|
||||
for (i=0; i<VSBUS_MAX_INTR; i++) {
|
||||
ip = &vsbus_ivtab[i];
|
||||
bcopy(&idsptch, &ip->intr_vec, sizeof(struct ivec_dsp));
|
||||
ip->intr_vec.pushlarg = i;
|
||||
ip->intr_vec.hoppaddr = vsbus_intr_dispatch;
|
||||
ip->intr_count = 0;
|
||||
ip->intr_flags = 0;
|
||||
ip->enab = NULL;
|
||||
ip->disab = NULL;
|
||||
ip->postp = NULL;
|
||||
}
|
||||
switch (vax_boardtype) {
|
||||
case VAX_BTYP_410:
|
||||
case VAX_BTYP_420:
|
||||
case VAX_BTYP_43:
|
||||
case VAX_BTYP_46:
|
||||
case VAX_BTYP_49:
|
||||
ka410_intr_setup();
|
||||
return(0);
|
||||
default:
|
||||
printf("unsupported board-type 0x%x in vsbus_intr_setup()\n",
|
||||
vax_boardtype);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
vsbus_intr_register(ca, handler, arg)
|
||||
struct confargs *ca;
|
||||
int (*handler)(void*);
|
||||
void *arg;
|
||||
{
|
||||
/* struct device *dev = arg; */
|
||||
int i = ca->ca_intslot;
|
||||
struct vsbus_ivec *ip = &vsbus_ivtab[i];
|
||||
|
||||
trace (("vsbus_intr_register(%s/%d)\n", ca->ca_name, ca->ca_intslot));
|
||||
|
||||
ip->handler = handler;
|
||||
ip->hndlarg = arg;
|
||||
}
|
||||
|
||||
int
|
||||
vsbus_intr_enable(ca)
|
||||
struct confargs *ca;
|
||||
{
|
||||
int i = ca->ca_intslot;
|
||||
struct vsbus_ivec *ip = &vsbus_ivtab[i];
|
||||
|
||||
trace (("vsbus_intr_enable(%s/%d)\n", ca->ca_name, ca->ca_intslot));
|
||||
|
||||
/* XXX check for valid handler etc. !!! */
|
||||
if (ip->handler == NULL) {
|
||||
printf("interrupts for \"%s\"(%d) not enabled: null-handler\n",
|
||||
ca->ca_name, ca->ca_intslot);
|
||||
return;
|
||||
}
|
||||
|
||||
ip->enab(i);
|
||||
}
|
||||
|
||||
int
|
||||
vsbus_intr_disable(ca)
|
||||
struct confargs *ca;
|
||||
{
|
||||
int i = ca->ca_intslot;
|
||||
struct vsbus_ivec *ip = &vsbus_ivtab[i];
|
||||
|
||||
trace (("vsbus_intr_disable(%s/%d)\n", ca->ca_name, i));
|
||||
|
||||
ip->disab(i);
|
||||
}
|
||||
|
||||
int
|
||||
vsbus_intr_unregister(ca)
|
||||
struct confargs *ca;
|
||||
{
|
||||
int i = ca->ca_intslot;
|
||||
struct vsbus_ivec *ip = &vsbus_ivtab[i];
|
||||
|
||||
trace (("vsbus_intr_unregister(%s/%d)\n", ca->ca_name, i));
|
||||
|
||||
ip->handler = NULL;
|
||||
ip->hndlarg = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
vsbus_intr_dispatch(i)
|
||||
register int i;
|
||||
{
|
||||
register struct vsbus_ivec *ip = &vsbus_ivtab[i];
|
||||
|
||||
trace (("vsbus_intr_dispatch(%d)", i));
|
||||
|
||||
if (i < VSBUS_MAX_INTR && ip->handler != NULL) {
|
||||
ip->intr_count++;
|
||||
debug (("intr-count[%d] = %d\n", i, ip->intr_count));
|
||||
(ip->handler)(ip->hndlarg);
|
||||
if (ip->postp)
|
||||
(ip->postp)(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if (i < 0 || i >= VSBUS_MAX_INTR) {
|
||||
printf ("stray interrupt %d on vsbus.\n", i);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ip->handler) {
|
||||
printf ("unhandled interrupt %d on vsbus.\n", i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* These addresses are invalid and will be updated/corrected by
|
||||
* ka410_intr_setup(), but having them this way helps debugging
|
||||
*/
|
||||
static volatile u_char *ka410_intmsk = (void*)KA410_INTMSK;
|
||||
static volatile u_char *ka410_intreq = (void*)KA410_INTREQ;
|
||||
static volatile u_char *ka410_intclr = (void*)KA410_INTCLR;
|
||||
|
||||
static void
|
||||
ka410_intr_enable(i)
|
||||
int i;
|
||||
{
|
||||
trace (("ka410_intr_enable(%d)\n", i));
|
||||
*ka410_intmsk |= (1<<i);
|
||||
}
|
||||
|
||||
static void
|
||||
ka410_intr_disable(i)
|
||||
int i;
|
||||
{
|
||||
trace (("ka410_intr_disable(%d)\n", i));
|
||||
*ka410_intmsk &= ~(1<<i);
|
||||
}
|
||||
|
||||
static void
|
||||
ka410_intr_clear(i)
|
||||
int i;
|
||||
{
|
||||
trace (("ka410_intr_clear(%d)\n", i));
|
||||
*ka410_intclr = (1<<i);
|
||||
}
|
||||
|
||||
ka410_intr_setup()
|
||||
{
|
||||
int i;
|
||||
struct vsbus_ivec *ip;
|
||||
void **scbP = (void*)scb;
|
||||
|
||||
trace (("ka410_intr_setup()\n"));
|
||||
|
||||
ka410_intmsk = (void*)uvax_phys2virt(KA410_INTMSK);
|
||||
ka410_intreq = (void*)uvax_phys2virt(KA410_INTREQ);
|
||||
ka410_intclr = (void*)uvax_phys2virt(KA410_INTCLR);
|
||||
|
||||
*ka410_intmsk = 0; /* disable all interrupts */
|
||||
*ka410_intclr = 0xFF; /* clear all old interrupts */
|
||||
|
||||
/*
|
||||
* insert the VS2000-specific routines into ivec-table...
|
||||
*/
|
||||
for (i=0; i<8; i++) {
|
||||
ip = &vsbus_ivtab[i];
|
||||
ip->enab = ka410_intr_enable;
|
||||
ip->disab = ka410_intr_disable;
|
||||
/* ip->postp = ka410_intr_clear; bertram XXX */
|
||||
}
|
||||
/*
|
||||
* ...and register the interrupt-vectors in SCB
|
||||
*/
|
||||
scbP[IVEC_DC/4] = &vsbus_ivtab[0].intr_vec;
|
||||
scbP[IVEC_SC/4] = &vsbus_ivtab[1].intr_vec;
|
||||
scbP[IVEC_VS/4] = &vsbus_ivtab[2].intr_vec;
|
||||
scbP[IVEC_VF/4] = &vsbus_ivtab[3].intr_vec;
|
||||
scbP[IVEC_NS/4] = &vsbus_ivtab[4].intr_vec;
|
||||
scbP[IVEC_NP/4] = &vsbus_ivtab[5].intr_vec;
|
||||
scbP[IVEC_ST/4] = &vsbus_ivtab[6].intr_vec;
|
||||
scbP[IVEC_SR/4] = &vsbus_ivtab[7].intr_vec;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static volatile struct dma_lock {
|
||||
int dl_locked;
|
||||
int dl_wanted;
|
||||
void *dl_owner;
|
||||
int dl_count;
|
||||
} dmalock = { 0, 0, NULL, 0 };
|
||||
|
||||
int
|
||||
vsbus_lockDMA(ca)
|
||||
struct confargs *ca;
|
||||
{
|
||||
while (dmalock.dl_locked) {
|
||||
dmalock.dl_wanted++;
|
||||
sleep((caddr_t)&dmalock, PRIBIO); /* PLOCK or PRIBIO ? */
|
||||
dmalock.dl_wanted--;
|
||||
}
|
||||
dmalock.dl_locked++;
|
||||
dmalock.dl_owner = ca;
|
||||
|
||||
/*
|
||||
* no checks yet, no timeouts, nothing...
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
if ((++dmalock.dl_count % 1000) == 0)
|
||||
printf("%d locks, owner: %s\n", dmalock.dl_count, ca->ca_name);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
vsbus_unlockDMA(ca)
|
||||
struct confargs *ca;
|
||||
{
|
||||
if (dmalock.dl_locked != 1 || dmalock.dl_owner != ca) {
|
||||
printf("locking-problem: %d, %s\n", dmalock.dl_locked,
|
||||
(dmalock.dl_owner ? dmalock.dl_owner : "null"));
|
||||
dmalock.dl_locked = 0;
|
||||
return (-1);
|
||||
}
|
||||
dmalock.dl_owner = NULL;
|
||||
dmalock.dl_locked = 0;
|
||||
if (dmalock.dl_wanted) {
|
||||
wakeup((caddr_t)&dmalock);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#if 0
|
||||
/*
|
||||
* small set of routines needed for mapping when doing pseudo-DMA,
|
||||
* quasi-DMA or virtual-DMA (choose whatever name you like).
|
||||
*
|
||||
* Once I know how VS3100 is doing real DMA (I hope it does), this
|
||||
* should be rewritten to present a general interface...
|
||||
*
|
||||
*/
|
||||
|
||||
extern u_long uVAX_physmap;
|
||||
|
||||
u_long
|
||||
vsdma_mapin(bp, len)
|
||||
struct buf *bp;
|
||||
int len;
|
||||
{
|
||||
pt_entry_t *pte; /* pointer to Page-Table-Entry */
|
||||
struct pcb *pcb; /* pointer to Process-Controll-Block */
|
||||
pt_entry_t *xpte;
|
||||
caddr_t addr;
|
||||
int pgoff; /* offset into 1st page */
|
||||
int pgcnt; /* number of pages needed */
|
||||
int pfnum;
|
||||
int i;
|
||||
|
||||
trace(("mapin(bp=%x, bp->data=%x)\n", bp, bp->b_data));
|
||||
|
||||
addr = bp->b_data;
|
||||
pgoff = (int)bp->b_data & PGOFSET; /* get starting offset */
|
||||
pgcnt = btoc(bp->b_bcount + pgoff) + 1; /* one more than needed */
|
||||
|
||||
/*
|
||||
* Get a pointer to the pte pointing out the first virtual address.
|
||||
* Use different ways in kernel and user space.
|
||||
*/
|
||||
if ((bp->b_flags & B_PHYS) == 0) {
|
||||
pte = kvtopte(addr);
|
||||
} else {
|
||||
pcb = bp->b_proc->p_vmspace->vm_pmap.pm_pcb;
|
||||
pte = uvtopte(addr, pcb);
|
||||
}
|
||||
|
||||
/*
|
||||
* When we are doing DMA to user space, be sure that all pages
|
||||
* we want to transfer to are mapped. WHY DO WE NEED THIS???
|
||||
* SHOULDN'T THEY ALWAYS BE MAPPED WHEN DOING THIS???
|
||||
*/
|
||||
for (i=0; i<(pgcnt-1); i++) {
|
||||
if ((pte + i)->pg_pfn == 0) {
|
||||
int rv;
|
||||
rv = vm_fault(&bp->b_proc->p_vmspace->vm_map,
|
||||
(unsigned)addr + i * NBPG,
|
||||
VM_PROT_READ|VM_PROT_WRITE, FALSE);
|
||||
if (rv)
|
||||
panic("vs-DMA to nonexistent page, %d", rv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* now insert new mappings for this memory area into kernel's
|
||||
* mapping-table
|
||||
*/
|
||||
xpte = kvtopte(uVAX_physmap);
|
||||
while (--pgcnt > 0) {
|
||||
pfnum = pte->pg_pfn;
|
||||
if (pfnum == 0)
|
||||
panic("vsbus: zero entry");
|
||||
*(int *)xpte++ = *(int *)pte++;
|
||||
}
|
||||
*(int *)xpte = 0; /* mark last mapped page as invalid! */
|
||||
|
||||
debug(("uVAX: 0x%x\n", uVAX_physmap + pgoff));
|
||||
|
||||
return (uVAX_physmap + pgoff); /* ??? */
|
||||
}
|
||||
#endif
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Here follows some currently(?) unused stuff. Someday this should be removed
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Configure devices on VS2000/KA410 directly attached to vsbus
|
||||
*/
|
||||
void
|
||||
ka410_attach(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
{
|
||||
struct confargs *ca;
|
||||
int i;
|
||||
|
||||
for (i=0; i<KA410_MAXDEVS; i++) {
|
||||
ca = &ka410_devs[i];
|
||||
if (*ca->ca_name == '\0')
|
||||
break;
|
||||
config_found(self, (void*)ca, vsbus_print);
|
||||
}
|
||||
/*
|
||||
* as long as there's no real DZ-driver, we used this dummy
|
||||
*/
|
||||
vsbus_intr_register(&ka410_devs[0], ka410_consRecv_intr, NULL);
|
||||
vsbus_intr_register(&ka410_devs[1], ka410_consXmit_intr, NULL);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue