diff options
author | peter <peter@FreeBSD.org> | 1995-12-30 19:02:48 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-12-30 19:02:48 +0000 |
commit | ab124e78b0271ddb904b761b31e5c9a0cf24e070 (patch) | |
tree | 0cf1447720c45721ed3d214a4eaaa6834bda155d /sys | |
parent | 15748830d0fcd29294a1969a1012655e74908c1e (diff) | |
download | FreeBSD-src-ab124e78b0271ddb904b761b31e5c9a0cf24e070.zip FreeBSD-src-ab124e78b0271ddb904b761b31e5c9a0cf24e070.tar.gz |
recording cvs-1.6 file death
Diffstat (limited to 'sys')
135 files changed, 0 insertions, 58644 deletions
diff --git a/sys/conf/nfsswapvmunix.c b/sys/conf/nfsswapvmunix.c deleted file mode 100644 index 7ca9a1d..0000000 --- a/sys/conf/nfsswapvmunix.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * 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. - * - * @(#)nfsswapvmunix.c 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -/* - * Sample NFS swapvmunix configuration file. - * This should be filled in by the bootstrap program. - * See /sys/nfs/nfsdiskless.h for details of the fields. - */ - -#include <sys/param.h> -#include <sys/conf.h> -#include <sys/socket.h> -#include <sys/mount.h> - -#include <net/if.h> -#include <nfs/nfsv2.h> -#include <nfs/nfsdiskless.h> - -extern int nfs_mountroot(); -int (*mountroot)() = nfs_mountroot; - -dev_t rootdev = NODEV; -dev_t argdev = NODEV; -dev_t dumpdev = NODEV; - -struct swdevt swdevt[] = { - { NODEV, 0, 5000 }, /* happy:/u/swap.dopey */ - { 0, 0, 0 } -}; -struct nfs_diskless nfs_diskless = { - { { 'q', 'e', '0', '\0' }, - { 0x10, 0x2, { 0x0, 0x0, 0x83, 0x68, 0x30, 0x2, } }, - { 0x10, 0x2, { 0x0, 0x0, 0x83, 0x68, 0x30, 0xff, } }, - { 0x10, 0x0, { 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, } }, - }, - { 0x10, 0x2, { 0x0, 0x0, 0x83, 0x68, 0x30, 0x12, } }, - { - (struct sockaddr *)0, SOCK_DGRAM, 0, (nfsv2fh_t *)0, - 0, 8192, 8192, 10, 100, (char *)0, - }, - { - 0xf, - 0x9, - 0x0, - 0x0, - 0x1, - 0x0, - 0x0, - 0x0, - 0xc, - 0x0, - 0x0, - 0x0, - 0x6, - 0x0, - 0x0, - 0x0, - 0x27, - 0x18, - 0x79, - 0x27, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - }, - { 0x10, 0x2, { 0x8, 0x1, 0x83, 0x68, 0x30, 0x5, } }, - "happy", - { - (struct sockaddr *)0, SOCK_DGRAM, 0, (nfsv2fh_t *)0, - 0, 8192, 8192, 10, 100, (char *)0, - }, - { - 0x0, - 0x9, - 0x0, - 0x0, - 0x1, - 0x0, - 0x0, - 0x0, - 0xc, - 0x0, - 0x0, - 0x0, - 0x2, - 0x0, - 0x0, - 0x0, - 0xd0, - 0x48, - 0x42, - 0x25, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - }, - { 0x10, 0x2, { 0x8, 0x1, 0x83, 0x68, 0x30, 0x5, } }, - "happy", -}; diff --git a/sys/gnu/i386/fpemul/bde_trapinfo.mail b/sys/gnu/i386/fpemul/bde_trapinfo.mail deleted file mode 100644 index 2749e04..0000000 --- a/sys/gnu/i386/fpemul/bde_trapinfo.mail +++ /dev/null @@ -1,35 +0,0 @@ -From bde@kralizec.zeta.org.au Sun Jun 27 01:18:32 1993 -Received: from ultima.socs.uts.EDU.AU by bsd.coe.montana.edu (5.67/KAOS-1) - id AA11952; Sun, 27 Jun 93 01:18:32 -0600 -Received: by ultima.socs.uts.EDU.AU (5.65+/SMI-3.3) - id AA03033; Sun, 27 Jun 93 17:10:22 +1000 -Received: by kralizec.zeta.org.au (4.0/SMI-4.0) - id AA15074; Sat, 26 Jun 93 02:32:58 EST -Date: Sat, 26 Jun 93 02:32:58 EST -From: bde@kralizec.zeta.org.au (Bruce Evans) -Message-Id: <9306251632.AA15074@kralizec.zeta.org.au> -To: nate@bsd.coe.montana.edu -Subject: Re: Trapframe information -Status: OR - -tf_isp original esp (probably spare - popal ignores it) -tf_trapno s/w trap no (may be spare - trap.c has already looked at it) -tf_err h/w error code (probably spare - gets discarded before iret) - -___fs not stored in 386BSD pcb. Constant anyway unless user has - screwed with it (?). -___gs ditto -___orig_eip in linux, this is on the stack just before the call to the - emulator. The reason that it's not a local variable is to - avoid passing around pointers to it - current->frame (or - whatever) points to everything in the stack frame. The - macros hide a lot of slow memory references - current->frame->var. - ->(And I need to see if I can map orig_eip to one of the three that I'm unsure of ->in the BSD sources) - -tf_isp is the least evil. - -Bruce - diff --git a/sys/gnu/i386/isa/scd.c b/sys/gnu/i386/isa/scd.c deleted file mode 100644 index 92d31de..0000000 --- a/sys/gnu/i386/isa/scd.c +++ /dev/null @@ -1,1530 +0,0 @@ -/*- - * Copyright (c) 1995 Mikael Hybsch - * - * Portions of this file are copied from mcd.c - * which has the following copyrights: - * - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * Changes Copyright 1993 by Gary Clark II - * Changes Copyright (C) 1994 by Andrew A. Chernov - * - * Rewrote probe routine to work on newer Mitsumi drives. - * Additional changes (C) 1994 by Jordan K. Hubbard - * - * The Linux driver cdu31a has been used as a reference when writing this - * code, there fore bringing it under the GNU Public License. The following - * conditions of redistribution therefore apply: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - - -/* $Id: scd.c,v 1.7 1995/02/09 11:30:07 jkh Exp $ */ - -/* Please send any comments to micke@dynas.se */ - -#define SCD_DEBUG 0 - -#include "scd.h" -#if NSCD > 0 -#include <sys/types.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/buf.h> -#include <sys/stat.h> -#include <sys/uio.h> -#include <sys/ioctl.h> -#include <sys/cdio.h> -#include <sys/errno.h> -#include <sys/dkbad.h> -#include <sys/disklabel.h> -#include <sys/devconf.h> -#include <machine/stdarg.h> - -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#include <gnu/i386/isa/scdreg.h> - -#define scd_part(dev) ((minor(dev)) & 7) -#define scd_unit(dev) (((minor(dev)) & 0x38) >> 3) -#define scd_phys(dev) (((minor(dev)) & 0x40) >> 6) -#define RAW_PART 2 - -/* flags */ -#define SCDOPEN 0x0001 /* device opened */ -#define SCDVALID 0x0002 /* parameters loaded */ -#define SCDINIT 0x0004 /* device is init'd */ -#define SCDPROBING 0x0020 /* probing */ -#define SCDTOC 0x0100 /* already read toc */ -#define SCDMBXBSY 0x0200 /* local mbx is busy */ -#define SCDSPINNING 0x0400 /* drive is spun up */ - -#define SCD_S_BEGIN 0 -#define SCD_S_BEGIN1 1 -#define SCD_S_WAITSTAT 2 -#define SCD_S_WAITFIFO 3 -#define SCD_S_WAITSPIN 4 -#define SCD_S_WAITREAD 5 -#define SCD_S_WAITPARAM 6 - -#define RDELAY_WAIT 300 -#define RDELAY_WAITREAD 300 - -#define SCDBLKSIZE 2048 - -#ifdef SCD_DEBUG - int scd_debuglevel = SCD_DEBUG; -# define XDEBUG(level, data) {if (scd_debuglevel >= level) printf data;} -#else -# define XDEBUG(level, data) -#endif - -struct scd_mbx { - short unit; - short port; - short retry; - short nblk; - int sz; - u_long skip; - struct buf *bp; - int p_offset; - short count; -}; - -struct scd_data { - int iobase; - char double_speed; - char *name; - short flags; - int blksize; - u_long disksize; - struct disklabel dlabel; - int openflag; - struct { - unsigned char adr :4; - unsigned char ctl :4; /* xcdplayer needs this */ - unsigned char start_msf[3]; - } toc[MAX_TRACKS]; - short first_track; - short last_track; - struct ioc_play_msf last_play; - - short audio_status; - struct buf head; /* head of buf queue */ - struct scd_mbx mbx; -} scd_data[NSCD]; - -/* prototypes */ -int scdopen(dev_t dev); -int scdclose(dev_t dev); -void scdstrategy(struct buf *bp); -int scdioctl(dev_t dev, int cmd, caddr_t addr, int flags); -int scdsize(dev_t dev); - -static int bcd2bin(bcd_t b); -static bcd_t bin2bcd(int b); -static void hsg2msf(int hsg, bcd_t *msf); -static int msf2hsg(bcd_t *msf); - -static void process_attention(unsigned unit); -static inline void write_control(unsigned port, unsigned data); -static int waitfor_status_bits(int unit, int bits_set, int bits_clear); -static int waitfor_attention(int unit); -static int send_cmd(u_int unit, u_char cmd, u_int nargs, ...); -static void init_drive(unsigned unit); -static int spin_up(unsigned unit); -static int read_toc(dev_t dev); -static int get_result(u_int unit, int result_len, u_char *result); -static void print_error(int unit, int errcode); - -static void scd_start(int unit); -static void scd_doread(int state, struct scd_mbx *mbxin); - -static int scd_eject(int unit); -static int scd_stop(int unit); -static int scd_pause(int unit); -static int scd_resume(int unit); -static int scd_playtracks(int unit, struct ioc_play_track *pt); -static int scd_playmsf(int unit, struct ioc_play_msf *msf); -static int scd_play(int unit, struct ioc_play_msf *msf); -static int scd_subchan(int unit, struct ioc_read_subchannel *sc); -static int read_subcode(int unit, struct sony_subchannel_position_data *sc); - -/* for xcdplayer */ -static int scd_toc_header(int unit, struct ioc_toc_header *th); -static int scd_toc_entrys(int unit, struct ioc_read_toc_entry *te); -#define SCD_LASTPLUS1 170 /* don't ask, xcdplayer passes this in */ - -extern int hz; - -int scd_probe(struct isa_device *dev); -int scd_attach(struct isa_device *dev); -struct isa_driver scddriver = { scd_probe, scd_attach, "scd" }; - -static struct kern_devconf kdc_scd[NSCD] = { { - 0, 0, 0, /* filled in by dev_attach */ - "scd", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_IDLE, /* status */ - "Sony CD-ROM drive" /* properly filled later */ -} }; - -static inline void -scd_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_scd[id->id_unit] = kdc_scd[0]; - kdc_scd[id->id_unit].kdc_unit = id->id_unit; - kdc_scd[id->id_unit].kdc_isa = id; - dev_attach(&kdc_scd[id->id_unit]); -} - -int scd_attach(struct isa_device *dev) -{ - struct scd_data *cd = scd_data + dev->id_unit; - int i; - - cd->iobase = dev->id_iobase; /* Already set by probe, but ... */ - - scd_registerdev(dev); - /* name filled in probe */ - kdc_scd[dev->id_unit].kdc_description = scd_data[dev->id_unit].name; - printf("scd%d: <%s>\n", dev->id_unit, scd_data[dev->id_unit].name); - - init_drive(dev->id_unit); - - cd->flags = SCDINIT; - cd->audio_status = CD_AS_AUDIO_INVALID; - - return 1; -} - -int -scdopen(dev_t dev) -{ - int unit,part,phys; - int rc; - struct scd_data *cd; - - unit = scd_unit(dev); - if (unit >= NSCD) - return ENXIO; - - cd = scd_data + unit; - part = scd_part(dev); - phys = scd_phys(dev); - - /* not initialized*/ - if (!(cd->flags & SCDINIT)) - return ENXIO; - - /* invalidated in the meantime? mark all open part's invalid */ - if (cd->openflag) - return ENXIO; - - XDEBUG(1,("scd%d: DEBUG: status = 0x%x\n", unit, inb(cd->iobase+IREG_STATUS))); - - if ((rc = spin_up(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - if (!(cd->flags & SCDTOC)) { - int loop_count = 3; - - while (loop_count-- > 0 && (rc = read_toc(dev)) != 0) { - if (rc == ERR_NOT_SPINNING) { - rc = spin_up(unit); - if (rc) { - print_error(unit, rc);\ - return EIO; - } - continue; - } - printf("scd%d: TOC read error 0x%x\n", unit, rc); - return EIO; - } - } - - cd->openflag = 1; - cd->flags |= SCDVALID; - kdc_scd[unit].kdc_state = DC_BUSY; - - return 0; -} - -int -scdclose(dev_t dev) -{ - int unit,part,phys; - struct scd_data *cd; - int rlen; - char rdata[10]; - - unit = scd_unit(dev); - if (unit >= NSCD) - return ENXIO; - - cd = scd_data + unit; - part = scd_part(dev); - phys = scd_phys(dev); - - if (!(cd->flags & SCDINIT) || !cd->openflag) - return ENXIO; - - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) { - (void)send_cmd(unit, CMD_SPIN_DOWN, 0); - cd->flags &= ~SCDSPINNING; - } - - kdc_scd[unit].kdc_state = DC_IDLE; - - /* close channel */ - cd->openflag = 0; - - return 0; -} - -void -scdstrategy(struct buf *bp) -{ - struct scd_data *cd; - struct buf *qp; - int s; - int unit = scd_unit(bp->b_dev); - - cd = scd_data + unit; - - XDEBUG(2, ("scd%d: DEBUG: strategy: block=%ld, bcount=%ld\n", unit, bp->b_blkno, bp->b_bcount)); - - if (unit >= NSCD || bp->b_blkno < 0 || (bp->b_bcount % SCDBLKSIZE)) { - printf("scd%d: strategy failure: blkno = %d, bcount = %d\n", - unit, bp->b_blkno, bp->b_bcount); - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto bad; - } - - /* if device invalidated (e.g. media change, door open), error */ - if (!(cd->flags & SCDVALID)) { - printf("scd%d: media changed\n", unit); - bp->b_error = EIO; - goto bad; - } - - /* read only */ - if (!(bp->b_flags & B_READ)) { - bp->b_error = EROFS; - goto bad; - } - - /* no data to read */ - if (bp->b_bcount == 0) - goto done; - - if (!(cd->flags & SCDTOC)) { - bp->b_error = EIO; - goto bad; - } - /* adjust transfer if necessary */ - if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) - goto done; - - bp->b_pblkno = bp->b_blkno; - bp->b_resid = 0; - - /* queue it */ - qp = &cd->head; - s = splbio(); - disksort(qp,bp); - splx(s); - - /* now check whether we can perform processing */ - scd_start(unit); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - bp->b_resid = bp->b_bcount; - biodone(bp); - return; -} - -static void -scd_start(int unit) -{ - struct scd_data *cd = scd_data + unit; - struct buf *bp, *qp = &cd->head; - struct partition *p; - int part; - register s = splbio(); - - if (cd->flags & SCDMBXBSY) { - splx(s); - return; - } - - if ((bp = qp->b_actf) != 0) { - /* block found to process, dequeue */ - qp->b_actf = bp->b_actf; - cd->flags |= SCDMBXBSY; - splx(s); - } else { - /* nothing to do */ - splx(s); - return; - } - - p = cd->dlabel.d_partitions + scd_part(bp->b_dev); - - cd->mbx.unit = unit; - cd->mbx.port = cd->iobase; - cd->mbx.retry = 3; - cd->mbx.bp = bp; - cd->mbx.p_offset = p->p_offset; - splx(s); - - scd_doread(SCD_S_BEGIN,&(cd->mbx)); - return; -} - -int -scdioctl(dev_t dev, int cmd, caddr_t addr, int flags) -{ - struct scd_data *cd; - int unit,part; - - unit = scd_unit(dev); - part = scd_part(dev); - cd = scd_data + unit; - - XDEBUG(1, ("scd%d: ioctl: cmd=0x%lx\n", unit, cmd)); - - if (!(cd->flags & SCDVALID)) - return EIO; - - switch (cmd) { - case DIOCSBAD: - return EINVAL; - case DIOCGDINFO: - *(struct disklabel *)addr = cd->dlabel; - return 0; - case DIOCGPART: - ((struct partinfo *)addr)->disklab = &cd->dlabel; - ((struct partinfo *)addr)->part = - &cd->dlabel.d_partitions[0]; - return 0; - case CDIOCPLAYTRACKS: - return scd_playtracks(unit, (struct ioc_play_track *) addr); - case CDIOCPLAYBLOCKS: - return EINVAL; - case CDIOCPLAYMSF: - return scd_playmsf(unit, (struct ioc_play_msf *) addr); - case CDIOCREADSUBCHANNEL: - return scd_subchan(unit, (struct ioc_read_subchannel *) addr); - case CDIOREADTOCHEADER: - return scd_toc_header (unit, (struct ioc_toc_header *) addr); - case CDIOREADTOCENTRYS: - return scd_toc_entrys (unit, (struct ioc_read_toc_entry*) addr); - case CDIOCSETPATCH: - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTERIO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: - return EINVAL; - case CDIOCRESUME: - return scd_resume(unit); - case CDIOCPAUSE: - return scd_pause(unit); - case CDIOCSTART: - return EINVAL; - case CDIOCSTOP: - return scd_stop(unit); - case CDIOCEJECT: - return scd_eject(unit); - case CDIOCALLOW: - return 0; - case CDIOCSETDEBUG: -#ifdef SCD_DEBUG - scd_debuglevel++; -#endif - return 0; - case CDIOCCLRDEBUG: -#ifdef SCD_DEBUG - scd_debuglevel = 0; - -#endif - return 0; - default: - printf("scd%d: unsupported ioctl (cmd=0x%lx)\n", unit, cmd); - return ENOTTY; - } -} - -int -scdsize(dev_t dev) -{ - return -1; -} - -void -scdintr() -{ - return; -} - -/*************************************************************** - * lower level of driver starts here - **************************************************************/ - -static int -scd_playtracks(int unit, struct ioc_play_track *pt) -{ - struct scd_data *cd = scd_data + unit; - struct ioc_play_msf msf; - int a = pt->start_track; - int z = pt->end_track; - int rc, i; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - if (rc == -ERR_NOT_SPINNING) { - if (spin_up(unit) != 0) - return EIO; - rc = read_toc(unit); - } - if (rc != 0) { - print_error(unit, rc); - return EIO; - } - } - - XDEBUG(1, ("scd%d: playtracks from %d:%d to %d:%d\n", unit, - a, pt->start_index, z, pt->end_index)); - - if ( a < cd->first_track - || a > cd->last_track - || a > z - || z > cd->last_track) - return EINVAL; - - bcopy(cd->toc[a].start_msf, &msf.start_m, 3); - hsg2msf(msf2hsg(cd->toc[z+1].start_msf)-1, &msf.end_m); - - return scd_play(unit, &msf); -} - -/* The start/end msf is expected to be in bin format */ -static int -scd_playmsf(int unit, struct ioc_play_msf *msfin) -{ - struct ioc_play_msf msf; - - msf.start_m = bin2bcd(msfin->start_m); - msf.start_s = bin2bcd(msfin->start_s); - msf.start_f = bin2bcd(msfin->start_f); - msf.end_m = bin2bcd(msfin->end_m); - msf.end_s = bin2bcd(msfin->end_s); - msf.end_f = bin2bcd(msfin->end_f); - - return scd_play(unit, &msf); -} - -/* The start/end msf is expected to be in bcd format */ -static int -scd_play(int unit, struct ioc_play_msf *msf) -{ - struct scd_data *cd = scd_data + unit; - int i, rc; - - XDEBUG(1, ("scd%d: playing: %02x:%02x:%02x -> %02x:%02x:%02x\n", unit, - msf->start_m, msf->start_s, msf->start_f, - msf->end_m, msf->end_s, msf->end_f)); - - for (i = 0; i < 2; i++) { - rc = send_cmd(unit, CMD_PLAY_AUDIO, 7, - 0x03, - msf->start_m, msf->start_s, msf->start_f, - msf->end_m, msf->end_s, msf->end_f); - if (rc == -ERR_NOT_SPINNING) { - cd->flags &= ~SCDSPINNING; - if (spin_up(unit) != 0) - return EIO; - } else if (rc < 0) { - print_error(unit, rc); - return EIO; - } else { - break; - } - } - cd->audio_status = CD_AS_PLAY_IN_PROGRESS; - bcopy((char *)msf, (char *)&cd->last_play, sizeof(struct ioc_play_msf)); - return 0; -} - -static int -scd_stop(int unit) -{ - struct scd_data *cd = scd_data + unit; - - (void)send_cmd(unit, CMD_STOP_AUDIO, 0); - cd->audio_status = CD_AS_PLAY_COMPLETED; - return 0; -} - -static int -scd_pause(int unit) -{ - struct scd_data *cd = scd_data + unit; - struct sony_subchannel_position_data subpos; - - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) - return EINVAL; - - if (read_subcode(unit, &subpos) != 0) - return EIO; - - if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0) - return EIO; - - cd->last_play.start_m = subpos.abs_msf[0]; - cd->last_play.start_s = subpos.abs_msf[1]; - cd->last_play.start_f = subpos.abs_msf[2]; - cd->audio_status = CD_AS_PLAY_PAUSED; - - XDEBUG(1, ("scd%d: pause @ %02x:%02x:%02x\n", unit, - cd->last_play.start_m, - cd->last_play.start_s, - cd->last_play.start_f)); - - return 0; -} - -static int -scd_resume(int unit) -{ - if (scd_data[unit].audio_status != CD_AS_PLAY_PAUSED) - return EINVAL; - return scd_play(unit, &scd_data[unit].last_play); -} - -static int -scd_eject(int unit) -{ - struct scd_data *cd = scd_data + unit; - int port = cd->iobase; - - cd->audio_status = CD_AS_AUDIO_INVALID; - cd->flags &= ~(SCDSPINNING|SCDTOC); - - if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0 || - send_cmd(unit, CMD_SPIN_DOWN, 0) != 0 || - send_cmd(unit, CMD_EJECT, 0) != 0) - { - return EIO; - } - return 0; -} - -static int -scd_subchan(int unit, struct ioc_read_subchannel *sc) -{ - struct scd_data *cd = scd_data + unit; - struct sony_subchannel_position_data q; - struct cd_sub_channel_info data; - - XDEBUG(1, ("scd%d: subchan af=%d, df=%d\n", unit, - sc->address_format, - sc->data_format)); - - if (sc->address_format != CD_MSF_FORMAT) - return EINVAL; - - if (sc->data_format != CD_CURRENT_POSITION) - return EINVAL; - - if (read_subcode(unit, &q) != 0) - return EIO; - - data.header.audio_status = cd->audio_status; - data.what.position.data_format = CD_MSF_FORMAT; - data.what.position.track_number = bcd2bin(q.track_number); - data.what.position.reladdr.msf.unused = 0; - data.what.position.reladdr.msf.minute = bcd2bin(q.rel_msf[0]); - data.what.position.reladdr.msf.second = bcd2bin(q.rel_msf[1]); - data.what.position.reladdr.msf.frame = bcd2bin(q.rel_msf[2]); - data.what.position.absaddr.msf.unused = 0; - data.what.position.absaddr.msf.minute = bcd2bin(q.abs_msf[0]); - data.what.position.absaddr.msf.second = bcd2bin(q.abs_msf[1]); - data.what.position.absaddr.msf.frame = bcd2bin(q.abs_msf[2]); - - if (copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len))!=0) - return EFAULT; - return 0; -} - -int -scd_probe(struct isa_device *dev) -{ - struct sony_drive_configuration drive_config; - int unit = dev->id_unit; - int rc; - static char namebuf[8+16+8+3]; - char *s = namebuf; - int loop_count = 0; - - scd_data[unit].flags = SCDPROBING; - scd_data[unit].iobase = dev->id_iobase; - - bzero(&drive_config, sizeof(drive_config)); - -again: - /* Reset drive */ - write_control(dev->id_iobase, CBIT_RESET_DRIVE); - - /* Calm down */ - DELAY(300000); - - /* Only the ATTENTION bit may be set */ - if ((inb(dev->id_iobase+IREG_STATUS) & ~1) != 0) { - XDEBUG(1, ("scd: too many bits set. probe failed.\n")); - return 0; - } - rc = send_cmd(unit, CMD_GET_DRIVE_CONFIG, 0); - if (rc != sizeof(drive_config)) { - /* Sometimes if the drive is playing audio I get */ - /* the bad result 82. Fix by repeating the reset */ - if (rc > 0 && loop_count++ == 0) - goto again; - return 0; - } - if (get_result(unit, rc, (u_char *)&drive_config) != 0) - return 0; - - bcopy(drive_config.vendor, namebuf, 8); - s = namebuf+8; - while (*(s-1) == ' ') /* Strip trailing spaces */ - s--; - *s++ = ' '; - bcopy(drive_config.product, s, 16); - s += 16; - while (*(s-1) == ' ') - s--; - *s++ = ' '; - bcopy(drive_config.revision, s, 8); - s += 8; - while (*(s-1) == ' ') - s--; - *s = 0; - - scd_data[unit].name = namebuf; - - if (drive_config.config & 0x10) - scd_data[unit].double_speed = 1; - else - scd_data[unit].double_speed = 0; - - return 4; -} - -static int -read_subcode(int unit, struct sony_subchannel_position_data *sc) -{ - int rc; - - rc = send_cmd(unit, CMD_GET_SUBCHANNEL_DATA, 0); - if (rc < 0 || rc < sizeof(*sc)) - return EIO; - if (get_result(unit, rc, (u_char *)sc) != 0) - return EIO; - return 0; -} - -/* State machine copied from mcd.c */ - -/* This (and the code in mcd.c) will not work with more than one drive */ -/* because there is only one mbxsave below. Should fix that some day. */ -/* (mbxsave & state should probably be included in the scd_data struct and */ -/* the unit number used as first argument to scd_doread().) /Micke */ - -/* state machine to process read requests - * initialize with SCD_S_BEGIN: reset state machine - * SCD_S_WAITSTAT: wait for ready (!busy) - * SCD_S_WAITSPIN: wait for drive to spin up (if not spinning) - * SCD_S_WAITFIFO: wait for param fifo to get ready, them exec. command. - * SCD_S_WAITREAD: wait for data ready, read data - * SCD_S_WAITPARAM: wait for command result params, read them, error if bad data read. - */ - -static struct scd_mbx *mbxsave; - -static void -scd_doread(int state, struct scd_mbx *mbxin) -{ - struct scd_mbx *mbx = (state!=SCD_S_BEGIN) ? mbxsave : mbxin; - int unit = mbx->unit; - int port = mbx->port; - struct buf *bp = mbx->bp; - struct scd_data *cd = scd_data + unit; - int reg,i,k,c; - int blknum; - caddr_t addr; - char rdata[10]; - static char sdata[3]; /* Must be preserved between calls to this function */ - -loop: - switch (state) { - case SCD_S_BEGIN: - mbx = mbxsave = mbxin; - - case SCD_S_BEGIN1: - /* get status */ - mbx->count = RDELAY_WAIT; - - process_attention(unit); - goto trystat; - - case SCD_S_WAITSTAT: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSTAT); - if (mbx->count-- <= 0) { - printf("scd%d: timeout. drive busy.\n",unit); - goto harderr; - } - -trystat: - if (IS_BUSY(port)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSTAT,hz/100); /* XXX */ - return; - } - - process_attention(unit); - - /* reject, if audio active */ - if (cd->audio_status & CD_AS_PLAY_IN_PROGRESS) { - printf("scd%d: audio is active\n",unit); - goto harderr; - } - - mbx->sz = cd->blksize; - -firstblock: - /* for first block */ - mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz; - mbx->skip = 0; - -nextblock: - if (!(cd->flags & SCDVALID)) - goto changed; - - blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE)) - + mbx->p_offset + mbx->skip/mbx->sz; - - XDEBUG(2, ("scd%d: scd_doread: read blknum=%d\n", unit, blknum)); - - /* build parameter block */ - hsg2msf(blknum, sdata); - - write_control(port, CBIT_RESULT_READY_CLEAR); - write_control(port, CBIT_RPARAM_CLEAR); - write_control(port, CBIT_DATA_READY_CLEAR); - - if (FSTATUS_BIT(port, FBIT_WPARAM_READY)) - goto writeparam; - - mbx->count = 100; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */ - return; - - case SCD_S_WAITSPIN: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSPIN); - if (mbx->count-- <= 0) { - printf("scd%d: timeout waiting for drive to spin up.\n", unit); - goto harderr; - } - if (!STATUS_BIT(port, SBIT_RESULT_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */ - return; - } - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((i = inb(port+IREG_RESULT)) & 0xf0) { - case 0x20: - i = inb(port+IREG_RESULT); - print_error(unit, i); - goto harderr; - case 0x00: - (void)inb(port+IREG_RESULT); - cd->flags |= SCDSPINNING; - break; - } - XDEBUG(1, ("scd%d: DEBUG: spin up complete\n", unit)); - - state = SCD_S_BEGIN1; - goto loop; - - case SCD_S_WAITFIFO: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITFIFO); - if (mbx->count-- <= 0) { - printf("scd%d: timeout. write param not ready.\n",unit); - goto harderr; - } - if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */ - return; - } - XDEBUG(1, ("scd%d: mbx->count (writeparamwait) = %d(%d)\n", unit, mbx->count, 100)); - -writeparam: - /* The reason this test isn't done 'till now is to make sure */ - /* that it is ok to send the SPIN_UP cmd below. */ - if (!(cd->flags & SCDSPINNING)) { - XDEBUG(1, ("scd%d: spinning up drive ...\n", unit)); - outb(port+OREG_COMMAND, CMD_SPIN_UP); - mbx->count = 300; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */ - return; - } - - reg = port + OREG_WPARAMS; - /* send the read command */ - disable_intr(); - outb(reg, sdata[0]); - outb(reg, sdata[1]); - outb(reg, sdata[2]); - outb(reg, 0); - outb(reg, 0); - outb(reg, 1); - outb(port+OREG_COMMAND, CMD_READ); - enable_intr(); - - mbx->count = RDELAY_WAITREAD; - for (i = 0; i < 50; i++) { - if (STATUS_BIT(port, SBIT_DATA_READY)) - goto got_data; - DELAY(100); - } - - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */ - return; - - case SCD_S_WAITREAD: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITREAD); - if (mbx->count-- <= 0) { - if (STATUS_BIT(port, SBIT_RESULT_READY)) - goto got_param; - printf("scd%d: timeout while reading data\n",unit); - goto readerr; - } - if (!STATUS_BIT(port, SBIT_DATA_READY)) { - process_attention(unit); - if (!(cd->flags & SCDVALID)) - goto changed; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */ - return; - } - XDEBUG(2, ("scd%d: mbx->count (after RDY_BIT) = %d(%d)\n", unit, mbx->count, RDELAY_WAITREAD)); - -got_data: - /* data is ready */ - addr = bp->b_un.b_addr + mbx->skip; - write_control(port, CBIT_DATA_READY_CLEAR); - insb(port+IREG_DATA, addr, mbx->sz); - - mbx->count = 100; - for (i = 0; i < 20; i++) { - if (STATUS_BIT(port, SBIT_RESULT_READY)) - goto waitfor_param; - DELAY(100); - } - goto waitfor_param; - - case SCD_S_WAITPARAM: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITPARAM); - if (mbx->count-- <= 0) { - printf("scd%d: timeout waiting for params\n",unit); - goto readerr; - } - -waitfor_param: - if (!STATUS_BIT(port, SBIT_RESULT_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITPARAM,hz/100); /* XXX */ - return; - } -#if SCD_DEBUG - if (mbx->count < 100 && scd_debuglevel > 0) - printf("scd%d: mbx->count (paramwait) = %d(%d)\n", unit, mbx->count, 100); -#endif - -got_param: - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((i = inb(port+IREG_RESULT)) & 0xf0) { - case 0x50: - switch (i) { - case ERR_FATAL_READ_ERROR1: - case ERR_FATAL_READ_ERROR2: - printf("scd%d: unrecoverable read error 0x%x\n", unit, i); - goto harderr; - } - break; - case 0x20: - i = inb(port+IREG_RESULT); - switch (i) { - case ERR_NOT_SPINNING: - XDEBUG(1, ("scd%d: read error: drive not spinning\n", unit)); - if (mbx->retry-- > 0) { - state = SCD_S_BEGIN1; - cd->flags &= ~SCDSPINNING; - goto loop; - } - goto harderr; - default: - print_error(unit, i); - goto readerr; - } - case 0x00: - i = inb(port+IREG_RESULT); - break; - } - - if (--mbx->nblk > 0) { - mbx->skip += mbx->sz; - goto nextblock; - } - - /* return buffer */ - bp->b_resid = 0; - biodone(bp); - - cd->flags &= ~SCDMBXBSY; - scd_start(mbx->unit); - return; - } - -readerr: - if (mbx->retry-- > 0) { - printf("scd%d: retrying ...\n",unit); - state = SCD_S_BEGIN1; - goto loop; - } -harderr: - /* invalidate the buffer */ - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - biodone(bp); - - cd->flags &= ~SCDMBXBSY; - scd_start(mbx->unit); - return; - -changed: - printf("scd%d: media changed\n", unit); - goto harderr; -} - -static int -bcd2bin(bcd_t b) -{ - return (b >> 4) * 10 + (b & 15); -} - -static bcd_t -bin2bcd(int b) -{ - return ((b / 10) << 4) | (b % 10); -} - -static void -hsg2msf(int hsg, bcd_t *msf) -{ - hsg += 150; - M_msf(msf) = bin2bcd(hsg / 4500); - hsg %= 4500; - S_msf(msf) = bin2bcd(hsg / 75); - F_msf(msf) = bin2bcd(hsg % 75); -} - -static int -msf2hsg(bcd_t *msf) -{ - return (bcd2bin(M_msf(msf)) * 60 + - bcd2bin(S_msf(msf))) * 75 + - bcd2bin(F_msf(msf)) - 150; -} - -static void -process_attention(unsigned unit) -{ - unsigned port = scd_data[unit].iobase; - unsigned char code; - int count = 0; - int i; - - while (IS_ATTENTION(port) && count++ < 30) { - write_control(port, CBIT_ATTENTION_CLEAR); - code = inb(port+IREG_RESULT); - -#if SCD_DEBUG - if (scd_debuglevel > 0) { - if (count == 1) - printf("scd%d: DEBUG: ATTENTIONS = 0x%x", unit, code); - else - printf(",0x%x", code); - } -#endif - - switch (code) { - case ATTEN_SPIN_DOWN: - scd_data[unit].flags &= ~SCDSPINNING; - break; - - case ATTEN_SPIN_UP_DONE: - scd_data[unit].flags |= SCDSPINNING; - break; - - case ATTEN_AUDIO_DONE: - scd_data[unit].audio_status = CD_AS_PLAY_COMPLETED; - break; - - case ATTEN_DRIVE_LOADED: - scd_data[unit].flags &= ~(SCDTOC|SCDSPINNING|SCDVALID); - scd_data[unit].audio_status = CD_AS_AUDIO_INVALID; - break; - - case ATTEN_EJECT_PUSHED: - scd_data[unit].flags &= ~SCDVALID; - break; - } - DELAY(100); - } -#if SCD_DEBUG - if (scd_debuglevel > 0 && count > 0) - printf("\n"); -#endif -} - -/* Returns 0 OR sony error code */ -static int -spin_up(unsigned unit) -{ - unsigned char res_reg[12]; - unsigned int res_size; - int rc; - int loop_count = 0; - -again: - rc = send_cmd(unit, CMD_SPIN_UP, NULL, 0, res_reg, &res_size); - if (rc != 0) { - XDEBUG(2, ("scd%d: CMD_SPIN_UP error 0x%x\n", unit, rc)); - return rc; - } - - if (!(scd_data[unit].flags & SCDTOC)) { - rc = send_cmd(unit, CMD_READ_TOC, 0); - if (rc == ERR_NOT_SPINNING) { - if (loop_count++ < 3) - goto again; - return rc; - } - if (rc != 0) - return rc; - } - - scd_data[unit].flags |= SCDSPINNING; - - return 0; -} - -static struct sony_tracklist * -get_tl(struct sony_toc *toc, int size) -{ - struct sony_tracklist *tl = &toc->tracks[0]; - - if (tl->track != 0xb0) - return tl; - (char *)tl += 9; - if (tl->track != 0xb1) - return tl; - (char *)tl += 9; - if (tl->track != 0xb2) - return tl; - (char *)tl += 9; - if (tl->track != 0xb3) - return tl; - (char *)tl += 9; - if (tl->track != 0xb4) - return tl; - (char *)tl += 9; - if (tl->track != 0xc0) - return tl; - (char *)tl += 9; - return tl; -} - -static int -read_toc(dev_t dev) -{ - unsigned unit; - struct scd_data *cd; - unsigned part = 0; /* For now ... */ - struct sony_toc toc; - struct sony_tracklist *tl; - int rc, i, j; - u_long first, last; - - unit = scd_unit(dev); - cd = scd_data + unit; - - rc = send_cmd(unit, CMD_GET_TOC, 1, part+1); - if (rc < 0) - return rc; - if (rc > sizeof(toc)) { - printf("scd%d: program error: toc too large (%d)\n", unit, rc); - return EIO; - } - if (get_result(unit, rc, (u_char *)&toc) != 0) - return EIO; - - XDEBUG(1, ("scd%d: toc read. len = %d, sizeof(toc) = %d\n", unit, rc, sizeof(toc))); - - tl = get_tl(&toc, rc); - first = msf2hsg(tl->start_msf); - last = msf2hsg(toc.lead_out_start_msf); - cd->blksize = SCDBLKSIZE; - cd->disksize = last*cd->blksize/DEV_BSIZE; - - XDEBUG(1, ("scd%d: firstsector = %d, lastsector = %d", unit, - first, last)); - - cd->first_track = bcd2bin(toc.first_track); - cd->last_track = bcd2bin(toc.last_track); - if (cd->last_track > (MAX_TRACKS-2)) - cd->last_track = MAX_TRACKS-2; - for (j = 0, i = cd->first_track; i <= cd->last_track; i++, j++) { - cd->toc[i].adr = tl[j].adr; - cd->toc[i].ctl = tl[j].ctl; /* for xcdplayer */ - bcopy(tl[j].start_msf, cd->toc[i].start_msf, 3); -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) { - if ((j % 3) == 0) - printf("\nscd%d: tracks ", unit); - printf("[%03d: %2d %2d %2d] ", i, - bcd2bin(cd->toc[i].start_msf[0]), - bcd2bin(cd->toc[i].start_msf[1]), - bcd2bin(cd->toc[i].start_msf[2])); - } -#endif - } - bcopy(toc.lead_out_start_msf, cd->toc[cd->last_track+1].start_msf, 3); -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) { - i = cd->last_track+1; - printf("[END: %2d %2d %2d]\n", - bcd2bin(cd->toc[i].start_msf[0]), - bcd2bin(cd->toc[i].start_msf[1]), - bcd2bin(cd->toc[i].start_msf[2])); - } -#endif - - bzero(&cd->dlabel,sizeof(struct disklabel)); - /* filled with spaces first */ - strncpy(cd->dlabel.d_typename," ", - sizeof(cd->dlabel.d_typename)); - strncpy(cd->dlabel.d_typename, cd->name, - min(strlen(cd->name), sizeof(cd->dlabel.d_typename) - 1)); - strncpy(cd->dlabel.d_packname,"unknown ", - sizeof(cd->dlabel.d_packname)); - cd->dlabel.d_secsize = cd->blksize; - cd->dlabel.d_nsectors = 100; - cd->dlabel.d_ntracks = 1; - cd->dlabel.d_ncylinders = (cd->disksize/100)+1; - cd->dlabel.d_secpercyl = 100; - cd->dlabel.d_secperunit = cd->disksize; - cd->dlabel.d_rpm = 300; - cd->dlabel.d_interleave = 1; - cd->dlabel.d_flags = D_REMOVABLE; - cd->dlabel.d_npartitions= 1; - cd->dlabel.d_partitions[0].p_offset = 0; - cd->dlabel.d_partitions[0].p_size = cd->disksize; - cd->dlabel.d_partitions[0].p_fstype = 9; - cd->dlabel.d_magic = DISKMAGIC; - cd->dlabel.d_magic2 = DISKMAGIC; - cd->dlabel.d_checksum = dkcksum(&cd->dlabel); - - cd->flags |= SCDTOC; - - return 0; -} - -static inline void -write_control(unsigned port, unsigned data) -{ - outb(port + OREG_CONTROL, data); -} - -static void -init_drive(unsigned unit) -{ - int rc; - - rc = send_cmd(unit, CMD_SET_DRIVE_PARAM, 2, - 0x05, 0x03 | ((scd_data[unit].double_speed) ? 0x04: 0)); - if (rc != 0) - printf("scd%d: Unable to set parameters. Errcode = 0x%x\n", unit, rc); -} - -/* Returns 0 or errno */ -static int -get_result(u_int unit, int result_len, u_char *result) -{ - unsigned int port = scd_data[unit].iobase; - unsigned int res_reg = port + IREG_RESULT; - unsigned char c; - int loop_index = 2; /* send_cmd() reads two bytes ... */ - - XDEBUG(1, ("scd%d: DEBUG: get_result: bytes=%d\n", unit, result_len)); - - while (result_len-- > 0) { - if (loop_index++ >= 10) { - loop_index = 1; - if (waitfor_status_bits(unit, SBIT_RESULT_READY, 0)) - return EIO; - write_control(port, CBIT_RESULT_READY_CLEAR); - } - if (result) - *result++ = inb(res_reg); - else - (void)inb(res_reg); - } - return 0; -} - -/* Returns -0x100 for timeout, -(drive error code) OR number of result bytes */ -static int -send_cmd(u_int unit, u_char cmd, u_int nargs, ...) -{ - va_list ap; - u_int port = scd_data[unit].iobase; - u_int reg; - u_char c; - int rc; - int i; - - if (waitfor_status_bits(unit, 0, SBIT_BUSY)) { - printf("scd%d: drive busy\n", unit); - return -0x100; - } - - XDEBUG(1,("scd%d: DEBUG: send_cmd: cmd=0x%x nargs=%d", unit, cmd, nargs)); - - write_control(port, CBIT_RESULT_READY_CLEAR); - write_control(port, CBIT_RPARAM_CLEAR); - - for (i = 0; i < 100; i++) - if (FSTATUS_BIT(port, FBIT_WPARAM_READY)) - break; - if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) { - XDEBUG(1, ("\nscd%d: wparam timeout\n", unit)); - return -EIO; - } - - va_start(ap, nargs); - reg = port + OREG_WPARAMS; - for (i = 0; i < nargs; i++) { - c = (u_char)va_arg(ap, int); - outb(reg, c); - XDEBUG(1, (",{0x%x}", c)); - } - va_end(ap); - XDEBUG(1, ("\n")); - - outb(port+OREG_COMMAND, cmd); - - if (rc = waitfor_status_bits(unit, SBIT_RESULT_READY, SBIT_BUSY)) - return -0x100; - - reg = port + IREG_RESULT; - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((rc = inb(reg)) & 0xf0) { - case 0x20: - rc = inb(reg); - /* FALL TROUGH */ - case 0x50: - XDEBUG(1, ("scd%d: DEBUG: send_cmd: drive_error=0x%x\n", unit, rc)); - return -rc; - case 0x00: - default: - rc = inb(reg); - XDEBUG(1, ("scd%d: DEBUG: send_cmd: result_len=%d\n", unit, rc)); - return rc; - } -} - -static void -print_error(int unit, int errcode) -{ - switch (errcode) { - case -ERR_CD_NOT_LOADED: - printf("scd%d: door is open\n", unit); - break; - case -ERR_NO_CD_INSIDE: - printf("scd%d: no cd inside\n", unit); - break; - default: - if (errcode == -0x100 || errcode > 0) - printf("scd%d: device timeout\n", unit); - else - printf("scd%d: unexpected error 0x%x\n", unit, -errcode); - break; - } -} - -/* Returns 0 or errno value */ -static int -waitfor_status_bits(int unit, int bits_set, int bits_clear) -{ - u_int port = scd_data[unit].iobase; - u_int flags = scd_data[unit].flags; - u_int reg = port + IREG_STATUS; - u_int max_loop; - u_char c = 0; - - if (flags & SCDPROBING) { - max_loop = 0; - while (max_loop++ < 1000) { - c = inb(reg); - if (c == 0xff) - return EIO; - if (c & SBIT_ATTENTION) { - process_attention(unit); - continue; - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - break; - } - DELAY(10000); - } - } else { - max_loop = 100; - while (max_loop-- > 0) { - c = inb(reg); - if (c & SBIT_ATTENTION) { - process_attention(unit); - continue; - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - break; - } - tsleep(waitfor_status_bits, PZERO - 1, "waitfor", hz/10); - } - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - return 0; - } -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) - printf("scd%d: DEBUG: waitfor: TIMEOUT (0x%x,(0x%x,0x%x))\n", unit, c, bits_set, bits_clear); - else -#endif - printf("scd%d: timeout.\n", unit); - return EIO; -} - -/* these two routines for xcdplayer - "borrowed" from mcd.c */ -static int -scd_toc_header (int unit, struct ioc_toc_header* th) -{ - struct scd_data *cd = scd_data + unit; - int rc; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - - th->starting_track = cd->first_track; - th->ending_track = cd->last_track; - th->len = 0; /* not used */ - - return 0; -} - -static int -scd_toc_entrys (int unit, struct ioc_read_toc_entry *te) -{ - struct scd_data *cd = scd_data + unit; - struct cd_toc_entry toc_entry; - int rc, i, len = te->data_len; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - - /* find the toc to copy*/ - i = te->starting_track; - if (i == SCD_LASTPLUS1) - i = cd->last_track + 1; - - /* verify starting track */ - if (i < cd->first_track || i > cd->last_track+1) - return EINVAL; - - /* valid length ? */ - if (len < sizeof(struct cd_toc_entry) - || (len % sizeof(struct cd_toc_entry)) != 0) - return EINVAL; - - /* copy the toc data */ - toc_entry.control = cd->toc[i].ctl; - toc_entry.addr_type = te->address_format; - toc_entry.track = i; - if (te->address_format == CD_MSF_FORMAT) { - toc_entry.addr.msf.unused = 0; - toc_entry.addr.msf.minute = bcd2bin(cd->toc[i].start_msf[0]); - toc_entry.addr.msf.second = bcd2bin(cd->toc[i].start_msf[1]); - toc_entry.addr.msf.frame = bcd2bin(cd->toc[i].start_msf[2]); - } - - /* copy the data back */ - if (copyout(&toc_entry, te->data, sizeof(struct cd_toc_entry)) != 0) - return EFAULT; - - return 0; -} - - -#endif /* NSCD > 0 */ diff --git a/sys/gnu/i386/isa/scdreg.h b/sys/gnu/i386/isa/scdreg.h deleted file mode 100644 index 93ace5c..0000000 --- a/sys/gnu/i386/isa/scdreg.h +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 1995 Mikael Hybsch - * - * The Linux driver cdu31a has been used as a reference when writing this - * code, therefore bringing it under the GNU Public License. The following - * conditions of redistribution therefore apply: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: scdreg.h,v 1.2 1995/01/29 22:51:41 jkh Exp $ - * - */ - -#ifndef SCD_H -#define SCD_H - -#ifdef __GNUC__ -#if __GNUC__ >= 2 -#pragma pack(1) -#endif -#endif - -typedef unsigned char bcd_t; -#define M_msf(msf) msf[0] -#define S_msf(msf) msf[1] -#define F_msf(msf) msf[2] - -#define IS_ATTENTION(port) ((inb(port+IREG_STATUS) & SBIT_ATTENTION) != 0) -#define IS_BUSY(port) ((inb(port+IREG_STATUS) & SBIT_BUSY) != 0) -#define IS_DATA_RDY(port) ((inb(port+IREG_STATUS) & SBIT_DATA_READY) != 0) -#define STATUS_BIT(port, bit) ((inb(port+IREG_STATUS) & (bit)) != 0) -#define FSTATUS_BIT(port, bit) ((inb(port+IREG_FSTATUS) & (bit)) != 0) - -#define OREG_COMMAND 0 -#define OREG_WPARAMS 1 -#define OREG_CONTROL 3 -#define CBIT_ATTENTION_CLEAR 0x01 -#define CBIT_RESULT_READY_CLEAR 0x02 -#define CBIT_DATA_READY_CLEAR 0x04 -#define CBIT_RPARAM_CLEAR 0x40 -#define CBIT_RESET_DRIVE 0x80 - -#define IREG_STATUS 0 -#define SBIT_ATTENTION 0x01 -#define SBIT_RESULT_READY 0x02 -#define SBIT_DATA_READY 0x04 -#define SBIT_BUSY 0x80 - -#define IREG_RESULT 1 -#define IREG_DATA 2 -#define IREG_FSTATUS 3 -#define FBIT_WPARAM_READY 0x01 - -#define CMD_GET_DRIVE_CONFIG 0x00 -#define CMD_SET_DRIVE_PARAM 0x10 -#define CMD_GET_SUBCHANNEL_DATA 0x21 -#define CMD_GET_TOC 0x24 -#define CMD_READ_TOC 0x30 -#define CMD_READ 0x34 -#define CMD_PLAY_AUDIO 0x40 -#define CMD_STOP_AUDIO 0x41 -#define CMD_EJECT 0x50 -#define CMD_SPIN_UP 0x51 -#define CMD_SPIN_DOWN 0x52 - -#define ERR_CD_NOT_LOADED 0x20 -#define ERR_NO_CD_INSIDE 0x21 -#define ERR_NOT_SPINNING 0x22 -#define ERR_FATAL_READ_ERROR1 0x53 -#define ERR_FATAL_READ_ERROR2 0x57 - -#define ATTEN_DRIVE_LOADED 0x80 -#define ATTEN_EJECT_PUSHED 0x81 -#define ATTEN_AUDIO_DONE 0x90 -#define ATTEN_SPIN_UP_DONE 0x24 -#define ATTEN_SPIN_DOWN 0x27 -#define ATTEN_EJECT_DONE 0x28 - - -struct sony_drive_configuration { - char vendor[8]; - char product[16]; - char revision[8]; - u_short config; -}; - -/* Almost same as cd_sub_channel_position_data */ -struct sony_subchannel_position_data { - u_char control:4; - u_char addr_type:4; - u_char track_number; - u_char index_number; - u_char rel_msf[3]; - u_char dummy; - u_char abs_msf[3]; -}; - -struct sony_tracklist { - u_char adr :4; /* xcdplayer needs these two values */ - u_char ctl :4; - u_char track; - u_char start_msf[3]; -}; - -#define MAX_TRACKS 100 - -struct sony_toc { - u_char session_number; - - u_char :8; - u_char :8; - u_char first_track; - u_char :8; - u_char :8; - - u_char :8; - u_char :8; - u_char last_track; - u_char :8; - u_char :8; - - u_char :8; - u_char :8; - u_char lead_out_start_msf[3]; - - struct sony_tracklist tracks[MAX_TRACKS]; - - /* The rest is just to take space in case all data is returned */ - - u_char dummy[6*9]; -}; - -#endif /* SCD_H */ diff --git a/sys/gnu/i386/scd.c b/sys/gnu/i386/scd.c deleted file mode 100644 index 2ea212e..0000000 --- a/sys/gnu/i386/scd.c +++ /dev/null @@ -1,1530 +0,0 @@ -/*- - * Copyright (c) 1995 Mikael Hybsch - * - * Portions of this file are copied from mcd.c - * which has the following copyrights: - * - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * Changes Copyright 1993 by Gary Clark II - * Changes Copyright (C) 1994 by Andrew A. Chernov - * - * Rewrote probe routine to work on newer Mitsumi drives. - * Additional changes (C) 1994 by Jordan K. Hubbard - * - * The Linux driver cdu31a has been used as a reference when writing this - * code, there fore bringing it under the GNU Public License. The following - * conditions of redistribution therefore apply: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - - -/* $Id: scd.c,v 1.6 1995/02/06 22:35:06 jkh Exp $ */ - -/* Please send any comments to micke@dynas.se */ - -#define SCD_DEBUG 0 - -#include "scd.h" -#if NSCD > 0 -#include <sys/types.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/buf.h> -#include <sys/stat.h> -#include <sys/uio.h> -#include <sys/ioctl.h> -#include <sys/cdio.h> -#include <sys/errno.h> -#include <sys/dkbad.h> -#include <sys/disklabel.h> -#include <sys/devconf.h> -#include <machine/stdarg.h> - -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#include <gnu/i386/scdreg.h> - -#define scd_part(dev) ((minor(dev)) & 7) -#define scd_unit(dev) (((minor(dev)) & 0x38) >> 3) -#define scd_phys(dev) (((minor(dev)) & 0x40) >> 6) -#define RAW_PART 2 - -/* flags */ -#define SCDOPEN 0x0001 /* device opened */ -#define SCDVALID 0x0002 /* parameters loaded */ -#define SCDINIT 0x0004 /* device is init'd */ -#define SCDPROBING 0x0020 /* probing */ -#define SCDTOC 0x0100 /* already read toc */ -#define SCDMBXBSY 0x0200 /* local mbx is busy */ -#define SCDSPINNING 0x0400 /* drive is spun up */ - -#define SCD_S_BEGIN 0 -#define SCD_S_BEGIN1 1 -#define SCD_S_WAITSTAT 2 -#define SCD_S_WAITFIFO 3 -#define SCD_S_WAITSPIN 4 -#define SCD_S_WAITREAD 5 -#define SCD_S_WAITPARAM 6 - -#define RDELAY_WAIT 300 -#define RDELAY_WAITREAD 300 - -#define SCDBLKSIZE 2048 - -#ifdef SCD_DEBUG - int scd_debuglevel = SCD_DEBUG; -# define XDEBUG(level, data) {if (scd_debuglevel >= level) printf data;} -#else -# define XDEBUG(level, data) -#endif - -struct scd_mbx { - short unit; - short port; - short retry; - short nblk; - int sz; - u_long skip; - struct buf *bp; - int p_offset; - short count; -}; - -struct scd_data { - int iobase; - char double_speed; - char *name; - short flags; - int blksize; - u_long disksize; - struct disklabel dlabel; - int openflag; - struct { - unsigned char adr :4; - unsigned char ctl :4; /* xcdplayer needs this */ - unsigned char start_msf[3]; - } toc[MAX_TRACKS]; - short first_track; - short last_track; - struct ioc_play_msf last_play; - - short audio_status; - struct buf head; /* head of buf queue */ - struct scd_mbx mbx; -} scd_data[NSCD]; - -/* prototypes */ -int scdopen(dev_t dev); -int scdclose(dev_t dev); -void scdstrategy(struct buf *bp); -int scdioctl(dev_t dev, int cmd, caddr_t addr, int flags); -int scdsize(dev_t dev); - -static int bcd2bin(bcd_t b); -static bcd_t bin2bcd(int b); -static void hsg2msf(int hsg, bcd_t *msf); -static int msf2hsg(bcd_t *msf); - -static void process_attention(unsigned unit); -static inline void write_control(unsigned port, unsigned data); -static int waitfor_status_bits(int unit, int bits_set, int bits_clear); -static int waitfor_attention(int unit); -static int send_cmd(u_int unit, u_char cmd, u_int nargs, ...); -static void init_drive(unsigned unit); -static int spin_up(unsigned unit); -static int read_toc(dev_t dev); -static int get_result(u_int unit, int result_len, u_char *result); -static void print_error(int unit, int errcode); - -static void scd_start(int unit); -static void scd_doread(int state, struct scd_mbx *mbxin); - -static int scd_eject(int unit); -static int scd_stop(int unit); -static int scd_pause(int unit); -static int scd_resume(int unit); -static int scd_playtracks(int unit, struct ioc_play_track *pt); -static int scd_playmsf(int unit, struct ioc_play_msf *msf); -static int scd_play(int unit, struct ioc_play_msf *msf); -static int scd_subchan(int unit, struct ioc_read_subchannel *sc); -static int read_subcode(int unit, struct sony_subchannel_position_data *sc); - -/* for xcdplayer */ -static int scd_toc_header(int unit, struct ioc_toc_header *th); -static int scd_toc_entrys(int unit, struct ioc_read_toc_entry *te); -#define SCD_LASTPLUS1 170 /* don't ask, xcdplayer passes this in */ - -extern int hz; - -int scd_probe(struct isa_device *dev); -int scd_attach(struct isa_device *dev); -struct isa_driver scddriver = { scd_probe, scd_attach, "scd" }; - -static struct kern_devconf kdc_scd[NSCD] = { { - 0, 0, 0, /* filled in by dev_attach */ - "scd", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_IDLE, /* status */ - "Sony CD-ROM drive" /* properly filled later */ -} }; - -static inline void -scd_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_scd[id->id_unit] = kdc_scd[0]; - kdc_scd[id->id_unit].kdc_unit = id->id_unit; - kdc_scd[id->id_unit].kdc_isa = id; - dev_attach(&kdc_scd[id->id_unit]); -} - -int scd_attach(struct isa_device *dev) -{ - struct scd_data *cd = scd_data + dev->id_unit; - int i; - - cd->iobase = dev->id_iobase; /* Already set by probe, but ... */ - - scd_registerdev(dev); - /* name filled in probe */ - kdc_scd[dev->id_unit].kdc_description = scd_data[dev->id_unit].name; - printf("scd%d: <%s>\n", dev->id_unit, scd_data[dev->id_unit].name); - - init_drive(dev->id_unit); - - cd->flags = SCDINIT; - cd->audio_status = CD_AS_AUDIO_INVALID; - - return 1; -} - -int -scdopen(dev_t dev) -{ - int unit,part,phys; - int rc; - struct scd_data *cd; - - unit = scd_unit(dev); - if (unit >= NSCD) - return ENXIO; - - cd = scd_data + unit; - part = scd_part(dev); - phys = scd_phys(dev); - - /* not initialized*/ - if (!(cd->flags & SCDINIT)) - return ENXIO; - - /* invalidated in the meantime? mark all open part's invalid */ - if (cd->openflag) - return ENXIO; - - XDEBUG(1,("scd%d: DEBUG: status = 0x%x\n", unit, inb(cd->iobase+IREG_STATUS))); - - if ((rc = spin_up(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - if (!(cd->flags & SCDTOC)) { - int loop_count = 3; - - while (loop_count-- > 0 && (rc = read_toc(dev)) != 0) { - if (rc == ERR_NOT_SPINNING) { - rc = spin_up(unit); - if (rc) { - print_error(unit, rc);\ - return EIO; - } - continue; - } - printf("scd%d: TOC read error 0x%x\n", unit, rc); - return EIO; - } - } - - cd->openflag = 1; - cd->flags |= SCDVALID; - kdc_scd[unit].kdc_state = DC_BUSY; - - return 0; -} - -int -scdclose(dev_t dev) -{ - int unit,part,phys; - struct scd_data *cd; - int rlen; - char rdata[10]; - - unit = scd_unit(dev); - if (unit >= NSCD) - return ENXIO; - - cd = scd_data + unit; - part = scd_part(dev); - phys = scd_phys(dev); - - if (!(cd->flags & SCDINIT) || !cd->openflag) - return ENXIO; - - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) { - (void)send_cmd(unit, CMD_SPIN_DOWN, 0); - cd->flags &= ~SCDSPINNING; - } - - kdc_scd[unit].kdc_state = DC_IDLE; - - /* close channel */ - cd->openflag = 0; - - return 0; -} - -void -scdstrategy(struct buf *bp) -{ - struct scd_data *cd; - struct buf *qp; - int s; - int unit = scd_unit(bp->b_dev); - - cd = scd_data + unit; - - XDEBUG(2, ("scd%d: DEBUG: strategy: block=%ld, bcount=%ld\n", unit, bp->b_blkno, bp->b_bcount)); - - if (unit >= NSCD || bp->b_blkno < 0 || (bp->b_bcount % SCDBLKSIZE)) { - printf("scd%d: strategy failure: blkno = %d, bcount = %d\n", - unit, bp->b_blkno, bp->b_bcount); - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto bad; - } - - /* if device invalidated (e.g. media change, door open), error */ - if (!(cd->flags & SCDVALID)) { - printf("scd%d: media changed\n", unit); - bp->b_error = EIO; - goto bad; - } - - /* read only */ - if (!(bp->b_flags & B_READ)) { - bp->b_error = EROFS; - goto bad; - } - - /* no data to read */ - if (bp->b_bcount == 0) - goto done; - - if (!(cd->flags & SCDTOC)) { - bp->b_error = EIO; - goto bad; - } - /* adjust transfer if necessary */ - if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) - goto done; - - bp->b_pblkno = bp->b_blkno; - bp->b_resid = 0; - - /* queue it */ - qp = &cd->head; - s = splbio(); - disksort(qp,bp); - splx(s); - - /* now check whether we can perform processing */ - scd_start(unit); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - bp->b_resid = bp->b_bcount; - biodone(bp); - return; -} - -static void -scd_start(int unit) -{ - struct scd_data *cd = scd_data + unit; - struct buf *bp, *qp = &cd->head; - struct partition *p; - int part; - register s = splbio(); - - if (cd->flags & SCDMBXBSY) { - splx(s); - return; - } - - if ((bp = qp->b_actf) != 0) { - /* block found to process, dequeue */ - qp->b_actf = bp->b_actf; - cd->flags |= SCDMBXBSY; - splx(s); - } else { - /* nothing to do */ - splx(s); - return; - } - - p = cd->dlabel.d_partitions + scd_part(bp->b_dev); - - cd->mbx.unit = unit; - cd->mbx.port = cd->iobase; - cd->mbx.retry = 3; - cd->mbx.bp = bp; - cd->mbx.p_offset = p->p_offset; - splx(s); - - scd_doread(SCD_S_BEGIN,&(cd->mbx)); - return; -} - -int -scdioctl(dev_t dev, int cmd, caddr_t addr, int flags) -{ - struct scd_data *cd; - int unit,part; - - unit = scd_unit(dev); - part = scd_part(dev); - cd = scd_data + unit; - - XDEBUG(1, ("scd%d: ioctl: cmd=0x%lx\n", unit, cmd)); - - if (!(cd->flags & SCDVALID)) - return EIO; - - switch (cmd) { - case DIOCSBAD: - return EINVAL; - case DIOCGDINFO: - *(struct disklabel *)addr = cd->dlabel; - return 0; - case DIOCGPART: - ((struct partinfo *)addr)->disklab = &cd->dlabel; - ((struct partinfo *)addr)->part = - &cd->dlabel.d_partitions[0]; - return 0; - case CDIOCPLAYTRACKS: - return scd_playtracks(unit, (struct ioc_play_track *) addr); - case CDIOCPLAYBLOCKS: - return EINVAL; - case CDIOCPLAYMSF: - return scd_playmsf(unit, (struct ioc_play_msf *) addr); - case CDIOCREADSUBCHANNEL: - return scd_subchan(unit, (struct ioc_read_subchannel *) addr); - case CDIOREADTOCHEADER: - return scd_toc_header (unit, (struct ioc_toc_header *) addr); - case CDIOREADTOCENTRYS: - return scd_toc_entrys (unit, (struct ioc_read_toc_entry*) addr); - case CDIOCSETPATCH: - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTERIO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: - return EINVAL; - case CDIOCRESUME: - return scd_resume(unit); - case CDIOCPAUSE: - return scd_pause(unit); - case CDIOCSTART: - return EINVAL; - case CDIOCSTOP: - return scd_stop(unit); - case CDIOCEJECT: - return scd_eject(unit); - case CDIOCALLOW: - return 0; - case CDIOCSETDEBUG: -#ifdef SCD_DEBUG - scd_debuglevel++; -#endif - return 0; - case CDIOCCLRDEBUG: -#ifdef SCD_DEBUG - scd_debuglevel = 0; - -#endif - return 0; - default: - printf("scd%d: unsupported ioctl (cmd=0x%lx)\n", unit, cmd); - return ENOTTY; - } -} - -int -scdsize(dev_t dev) -{ - return -1; -} - -void -scdintr() -{ - return; -} - -/*************************************************************** - * lower level of driver starts here - **************************************************************/ - -static int -scd_playtracks(int unit, struct ioc_play_track *pt) -{ - struct scd_data *cd = scd_data + unit; - struct ioc_play_msf msf; - int a = pt->start_track; - int z = pt->end_track; - int rc, i; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - if (rc == -ERR_NOT_SPINNING) { - if (spin_up(unit) != 0) - return EIO; - rc = read_toc(unit); - } - if (rc != 0) { - print_error(unit, rc); - return EIO; - } - } - - XDEBUG(1, ("scd%d: playtracks from %d:%d to %d:%d\n", unit, - a, pt->start_index, z, pt->end_index)); - - if ( a < cd->first_track - || a > cd->last_track - || a > z - || z > cd->last_track) - return EINVAL; - - bcopy(cd->toc[a].start_msf, &msf.start_m, 3); - hsg2msf(msf2hsg(cd->toc[z+1].start_msf)-1, &msf.end_m); - - return scd_play(unit, &msf); -} - -/* The start/end msf is expected to be in bin format */ -static int -scd_playmsf(int unit, struct ioc_play_msf *msfin) -{ - struct ioc_play_msf msf; - - msf.start_m = bin2bcd(msfin->start_m); - msf.start_s = bin2bcd(msfin->start_s); - msf.start_f = bin2bcd(msfin->start_f); - msf.end_m = bin2bcd(msfin->end_m); - msf.end_s = bin2bcd(msfin->end_s); - msf.end_f = bin2bcd(msfin->end_f); - - return scd_play(unit, &msf); -} - -/* The start/end msf is expected to be in bcd format */ -static int -scd_play(int unit, struct ioc_play_msf *msf) -{ - struct scd_data *cd = scd_data + unit; - int i, rc; - - XDEBUG(1, ("scd%d: playing: %02x:%02x:%02x -> %02x:%02x:%02x\n", unit, - msf->start_m, msf->start_s, msf->start_f, - msf->end_m, msf->end_s, msf->end_f)); - - for (i = 0; i < 2; i++) { - rc = send_cmd(unit, CMD_PLAY_AUDIO, 7, - 0x03, - msf->start_m, msf->start_s, msf->start_f, - msf->end_m, msf->end_s, msf->end_f); - if (rc == -ERR_NOT_SPINNING) { - cd->flags &= ~SCDSPINNING; - if (spin_up(unit) != 0) - return EIO; - } else if (rc < 0) { - print_error(unit, rc); - return EIO; - } else { - break; - } - } - cd->audio_status = CD_AS_PLAY_IN_PROGRESS; - bcopy((char *)msf, (char *)&cd->last_play, sizeof(struct ioc_play_msf)); - return 0; -} - -static int -scd_stop(int unit) -{ - struct scd_data *cd = scd_data + unit; - - (void)send_cmd(unit, CMD_STOP_AUDIO, 0); - cd->audio_status = CD_AS_PLAY_COMPLETED; - return 0; -} - -static int -scd_pause(int unit) -{ - struct scd_data *cd = scd_data + unit; - struct sony_subchannel_position_data subpos; - - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) - return EINVAL; - - if (read_subcode(unit, &subpos) != 0) - return EIO; - - if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0) - return EIO; - - cd->last_play.start_m = subpos.abs_msf[0]; - cd->last_play.start_s = subpos.abs_msf[1]; - cd->last_play.start_f = subpos.abs_msf[2]; - cd->audio_status = CD_AS_PLAY_PAUSED; - - XDEBUG(1, ("scd%d: pause @ %02x:%02x:%02x\n", unit, - cd->last_play.start_m, - cd->last_play.start_s, - cd->last_play.start_f)); - - return 0; -} - -static int -scd_resume(int unit) -{ - if (scd_data[unit].audio_status != CD_AS_PLAY_PAUSED) - return EINVAL; - return scd_play(unit, &scd_data[unit].last_play); -} - -static int -scd_eject(int unit) -{ - struct scd_data *cd = scd_data + unit; - int port = cd->iobase; - - cd->audio_status = CD_AS_AUDIO_INVALID; - cd->flags &= ~(SCDSPINNING|SCDTOC); - - if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0 || - send_cmd(unit, CMD_SPIN_DOWN, 0) != 0 || - send_cmd(unit, CMD_EJECT, 0) != 0) - { - return EIO; - } - return 0; -} - -static int -scd_subchan(int unit, struct ioc_read_subchannel *sc) -{ - struct scd_data *cd = scd_data + unit; - struct sony_subchannel_position_data q; - struct cd_sub_channel_info data; - - XDEBUG(1, ("scd%d: subchan af=%d, df=%d\n", unit, - sc->address_format, - sc->data_format)); - - if (sc->address_format != CD_MSF_FORMAT) - return EINVAL; - - if (sc->data_format != CD_CURRENT_POSITION) - return EINVAL; - - if (read_subcode(unit, &q) != 0) - return EIO; - - data.header.audio_status = cd->audio_status; - data.what.position.data_format = CD_MSF_FORMAT; - data.what.position.track_number = bcd2bin(q.track_number); - data.what.position.reladdr.msf.unused = 0; - data.what.position.reladdr.msf.minute = bcd2bin(q.rel_msf[0]); - data.what.position.reladdr.msf.second = bcd2bin(q.rel_msf[1]); - data.what.position.reladdr.msf.frame = bcd2bin(q.rel_msf[2]); - data.what.position.absaddr.msf.unused = 0; - data.what.position.absaddr.msf.minute = bcd2bin(q.abs_msf[0]); - data.what.position.absaddr.msf.second = bcd2bin(q.abs_msf[1]); - data.what.position.absaddr.msf.frame = bcd2bin(q.abs_msf[2]); - - if (copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len))!=0) - return EFAULT; - return 0; -} - -int -scd_probe(struct isa_device *dev) -{ - struct sony_drive_configuration drive_config; - int unit = dev->id_unit; - int rc; - static char namebuf[8+16+8+3]; - char *s = namebuf; - int loop_count = 0; - - scd_data[unit].flags = SCDPROBING; - scd_data[unit].iobase = dev->id_iobase; - - bzero(&drive_config, sizeof(drive_config)); - -again: - /* Reset drive */ - write_control(dev->id_iobase, CBIT_RESET_DRIVE); - - /* Calm down */ - DELAY(300000); - - /* Only the ATTENTION bit may be set */ - if ((inb(dev->id_iobase+IREG_STATUS) & ~1) != 0) { - XDEBUG(1, ("scd: too many bits set. probe failed.\n")); - return 0; - } - rc = send_cmd(unit, CMD_GET_DRIVE_CONFIG, 0); - if (rc != sizeof(drive_config)) { - /* Sometimes if the drive is playing audio I get */ - /* the bad result 82. Fix by repeating the reset */ - if (rc > 0 && loop_count++ == 0) - goto again; - return 0; - } - if (get_result(unit, rc, (u_char *)&drive_config) != 0) - return 0; - - bcopy(drive_config.vendor, namebuf, 8); - s = namebuf+8; - while (*(s-1) == ' ') /* Strip trailing spaces */ - s--; - *s++ = ' '; - bcopy(drive_config.product, s, 16); - s += 16; - while (*(s-1) == ' ') - s--; - *s++ = ' '; - bcopy(drive_config.revision, s, 8); - s += 8; - while (*(s-1) == ' ') - s--; - *s = 0; - - scd_data[unit].name = namebuf; - - if (drive_config.config & 0x10) - scd_data[unit].double_speed = 1; - else - scd_data[unit].double_speed = 0; - - return 4; -} - -static int -read_subcode(int unit, struct sony_subchannel_position_data *sc) -{ - int rc; - - rc = send_cmd(unit, CMD_GET_SUBCHANNEL_DATA, 0); - if (rc < 0 || rc < sizeof(*sc)) - return EIO; - if (get_result(unit, rc, (u_char *)sc) != 0) - return EIO; - return 0; -} - -/* State machine copied from mcd.c */ - -/* This (and the code in mcd.c) will not work with more than one drive */ -/* because there is only one mbxsave below. Should fix that some day. */ -/* (mbxsave & state should probably be included in the scd_data struct and */ -/* the unit number used as first argument to scd_doread().) /Micke */ - -/* state machine to process read requests - * initialize with SCD_S_BEGIN: reset state machine - * SCD_S_WAITSTAT: wait for ready (!busy) - * SCD_S_WAITSPIN: wait for drive to spin up (if not spinning) - * SCD_S_WAITFIFO: wait for param fifo to get ready, them exec. command. - * SCD_S_WAITREAD: wait for data ready, read data - * SCD_S_WAITPARAM: wait for command result params, read them, error if bad data read. - */ - -static struct scd_mbx *mbxsave; - -static void -scd_doread(int state, struct scd_mbx *mbxin) -{ - struct scd_mbx *mbx = (state!=SCD_S_BEGIN) ? mbxsave : mbxin; - int unit = mbx->unit; - int port = mbx->port; - struct buf *bp = mbx->bp; - struct scd_data *cd = scd_data + unit; - int reg,i,k,c; - int blknum; - caddr_t addr; - char rdata[10]; - static char sdata[3]; /* Must be preserved between calls to this function */ - -loop: - switch (state) { - case SCD_S_BEGIN: - mbx = mbxsave = mbxin; - - case SCD_S_BEGIN1: - /* get status */ - mbx->count = RDELAY_WAIT; - - process_attention(unit); - goto trystat; - - case SCD_S_WAITSTAT: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSTAT); - if (mbx->count-- <= 0) { - printf("scd%d: timeout. drive busy.\n",unit); - goto harderr; - } - -trystat: - if (IS_BUSY(port)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSTAT,hz/100); /* XXX */ - return; - } - - process_attention(unit); - - /* reject, if audio active */ - if (cd->audio_status & CD_AS_PLAY_IN_PROGRESS) { - printf("scd%d: audio is active\n",unit); - goto harderr; - } - - mbx->sz = cd->blksize; - -firstblock: - /* for first block */ - mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz; - mbx->skip = 0; - -nextblock: - if (!(cd->flags & SCDVALID)) - goto changed; - - blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE)) - + mbx->p_offset + mbx->skip/mbx->sz; - - XDEBUG(2, ("scd%d: scd_doread: read blknum=%d\n", unit, blknum)); - - /* build parameter block */ - hsg2msf(blknum, sdata); - - write_control(port, CBIT_RESULT_READY_CLEAR); - write_control(port, CBIT_RPARAM_CLEAR); - write_control(port, CBIT_DATA_READY_CLEAR); - - if (FSTATUS_BIT(port, FBIT_WPARAM_READY)) - goto writeparam; - - mbx->count = 100; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */ - return; - - case SCD_S_WAITSPIN: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSPIN); - if (mbx->count-- <= 0) { - printf("scd%d: timeout waiting for drive to spin up.\n", unit); - goto harderr; - } - if (!STATUS_BIT(port, SBIT_RESULT_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */ - return; - } - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((i = inb(port+IREG_RESULT)) & 0xf0) { - case 0x20: - i = inb(port+IREG_RESULT); - print_error(unit, i); - goto harderr; - case 0x00: - (void)inb(port+IREG_RESULT); - cd->flags |= SCDSPINNING; - break; - } - XDEBUG(1, ("scd%d: DEBUG: spin up complete\n", unit)); - - state = SCD_S_BEGIN1; - goto loop; - - case SCD_S_WAITFIFO: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITFIFO); - if (mbx->count-- <= 0) { - printf("scd%d: timeout. write param not ready.\n",unit); - goto harderr; - } - if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */ - return; - } - XDEBUG(1, ("scd%d: mbx->count (writeparamwait) = %d(%d)\n", unit, mbx->count, 100)); - -writeparam: - /* The reason this test isn't done 'till now is to make sure */ - /* that it is ok to send the SPIN_UP cmd below. */ - if (!(cd->flags & SCDSPINNING)) { - XDEBUG(1, ("scd%d: spinning up drive ...\n", unit)); - outb(port+OREG_COMMAND, CMD_SPIN_UP); - mbx->count = 300; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */ - return; - } - - reg = port + OREG_WPARAMS; - /* send the read command */ - disable_intr(); - outb(reg, sdata[0]); - outb(reg, sdata[1]); - outb(reg, sdata[2]); - outb(reg, 0); - outb(reg, 0); - outb(reg, 1); - outb(port+OREG_COMMAND, CMD_READ); - enable_intr(); - - mbx->count = RDELAY_WAITREAD; - for (i = 0; i < 50; i++) { - if (STATUS_BIT(port, SBIT_DATA_READY)) - goto got_data; - DELAY(100); - } - - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */ - return; - - case SCD_S_WAITREAD: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITREAD); - if (mbx->count-- <= 0) { - if (STATUS_BIT(port, SBIT_RESULT_READY)) - goto got_param; - printf("scd%d: timeout while reading data\n",unit); - goto readerr; - } - if (!STATUS_BIT(port, SBIT_DATA_READY)) { - process_attention(unit); - if (!(cd->flags & SCDVALID)) - goto changed; - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */ - return; - } - XDEBUG(2, ("scd%d: mbx->count (after RDY_BIT) = %d(%d)\n", unit, mbx->count, RDELAY_WAITREAD)); - -got_data: - /* data is ready */ - addr = bp->b_un.b_addr + mbx->skip; - write_control(port, CBIT_DATA_READY_CLEAR); - insb(port+IREG_DATA, addr, mbx->sz); - - mbx->count = 100; - for (i = 0; i < 20; i++) { - if (STATUS_BIT(port, SBIT_RESULT_READY)) - goto waitfor_param; - DELAY(100); - } - goto waitfor_param; - - case SCD_S_WAITPARAM: - untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITPARAM); - if (mbx->count-- <= 0) { - printf("scd%d: timeout waiting for params\n",unit); - goto readerr; - } - -waitfor_param: - if (!STATUS_BIT(port, SBIT_RESULT_READY)) { - timeout((timeout_func_t)scd_doread, - (caddr_t)SCD_S_WAITPARAM,hz/100); /* XXX */ - return; - } -#if SCD_DEBUG - if (mbx->count < 100 && scd_debuglevel > 0) - printf("scd%d: mbx->count (paramwait) = %d(%d)\n", unit, mbx->count, 100); -#endif - -got_param: - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((i = inb(port+IREG_RESULT)) & 0xf0) { - case 0x50: - switch (i) { - case ERR_FATAL_READ_ERROR1: - case ERR_FATAL_READ_ERROR2: - printf("scd%d: unrecoverable read error 0x%x\n", unit, i); - goto harderr; - } - break; - case 0x20: - i = inb(port+IREG_RESULT); - switch (i) { - case ERR_NOT_SPINNING: - XDEBUG(1, ("scd%d: read error: drive not spinning\n", unit)); - if (mbx->retry-- > 0) { - state = SCD_S_BEGIN1; - cd->flags &= ~SCDSPINNING; - goto loop; - } - goto harderr; - default: - print_error(unit, i); - goto readerr; - } - case 0x00: - i = inb(port+IREG_RESULT); - break; - } - - if (--mbx->nblk > 0) { - mbx->skip += mbx->sz; - goto nextblock; - } - - /* return buffer */ - bp->b_resid = 0; - biodone(bp); - - cd->flags &= ~SCDMBXBSY; - scd_start(mbx->unit); - return; - } - -readerr: - if (mbx->retry-- > 0) { - printf("scd%d: retrying ...\n",unit); - state = SCD_S_BEGIN1; - goto loop; - } -harderr: - /* invalidate the buffer */ - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - biodone(bp); - - cd->flags &= ~SCDMBXBSY; - scd_start(mbx->unit); - return; - -changed: - printf("scd%d: media changed\n", unit); - goto harderr; -} - -static int -bcd2bin(bcd_t b) -{ - return (b >> 4) * 10 + (b & 15); -} - -static bcd_t -bin2bcd(int b) -{ - return ((b / 10) << 4) | (b % 10); -} - -static void -hsg2msf(int hsg, bcd_t *msf) -{ - hsg += 150; - M_msf(msf) = bin2bcd(hsg / 4500); - hsg %= 4500; - S_msf(msf) = bin2bcd(hsg / 75); - F_msf(msf) = bin2bcd(hsg % 75); -} - -static int -msf2hsg(bcd_t *msf) -{ - return (bcd2bin(M_msf(msf)) * 60 + - bcd2bin(S_msf(msf))) * 75 + - bcd2bin(F_msf(msf)) - 150; -} - -static void -process_attention(unsigned unit) -{ - unsigned port = scd_data[unit].iobase; - unsigned char code; - int count = 0; - int i; - - while (IS_ATTENTION(port) && count++ < 30) { - write_control(port, CBIT_ATTENTION_CLEAR); - code = inb(port+IREG_RESULT); - -#if SCD_DEBUG - if (scd_debuglevel > 0) { - if (count == 1) - printf("scd%d: DEBUG: ATTENTIONS = 0x%x", unit, code); - else - printf(",0x%x", code); - } -#endif - - switch (code) { - case ATTEN_SPIN_DOWN: - scd_data[unit].flags &= ~SCDSPINNING; - break; - - case ATTEN_SPIN_UP_DONE: - scd_data[unit].flags |= SCDSPINNING; - break; - - case ATTEN_AUDIO_DONE: - scd_data[unit].audio_status = CD_AS_PLAY_COMPLETED; - break; - - case ATTEN_DRIVE_LOADED: - scd_data[unit].flags &= ~(SCDTOC|SCDSPINNING|SCDVALID); - scd_data[unit].audio_status = CD_AS_AUDIO_INVALID; - break; - - case ATTEN_EJECT_PUSHED: - scd_data[unit].flags &= ~SCDVALID; - break; - } - DELAY(100); - } -#if SCD_DEBUG - if (scd_debuglevel > 0 && count > 0) - printf("\n"); -#endif -} - -/* Returns 0 OR sony error code */ -static int -spin_up(unsigned unit) -{ - unsigned char res_reg[12]; - unsigned int res_size; - int rc; - int loop_count = 0; - -again: - rc = send_cmd(unit, CMD_SPIN_UP, NULL, 0, res_reg, &res_size); - if (rc != 0) { - XDEBUG(2, ("scd%d: CMD_SPIN_UP error 0x%x\n", unit, rc)); - return rc; - } - - if (!(scd_data[unit].flags & SCDTOC)) { - rc = send_cmd(unit, CMD_READ_TOC, 0); - if (rc == ERR_NOT_SPINNING) { - if (loop_count++ < 3) - goto again; - return rc; - } - if (rc != 0) - return rc; - } - - scd_data[unit].flags |= SCDSPINNING; - - return 0; -} - -static struct sony_tracklist * -get_tl(struct sony_toc *toc, int size) -{ - struct sony_tracklist *tl = &toc->tracks[0]; - - if (tl->track != 0xb0) - return tl; - (char *)tl += 9; - if (tl->track != 0xb1) - return tl; - (char *)tl += 9; - if (tl->track != 0xb2) - return tl; - (char *)tl += 9; - if (tl->track != 0xb3) - return tl; - (char *)tl += 9; - if (tl->track != 0xb4) - return tl; - (char *)tl += 9; - if (tl->track != 0xc0) - return tl; - (char *)tl += 9; - return tl; -} - -static int -read_toc(dev_t dev) -{ - unsigned unit; - struct scd_data *cd; - unsigned part = 0; /* For now ... */ - struct sony_toc toc; - struct sony_tracklist *tl; - int rc, i, j; - u_long first, last; - - unit = scd_unit(dev); - cd = scd_data + unit; - - rc = send_cmd(unit, CMD_GET_TOC, 1, part+1); - if (rc < 0) - return rc; - if (rc > sizeof(toc)) { - printf("scd%d: program error: toc too large (%d)\n", unit, rc); - return EIO; - } - if (get_result(unit, rc, (u_char *)&toc) != 0) - return EIO; - - XDEBUG(1, ("scd%d: toc read. len = %d, sizeof(toc) = %d\n", unit, rc, sizeof(toc))); - - tl = get_tl(&toc, rc); - first = msf2hsg(tl->start_msf); - last = msf2hsg(toc.lead_out_start_msf); - cd->blksize = SCDBLKSIZE; - cd->disksize = last*cd->blksize/DEV_BSIZE; - - XDEBUG(1, ("scd%d: firstsector = %d, lastsector = %d", unit, - first, last)); - - cd->first_track = bcd2bin(toc.first_track); - cd->last_track = bcd2bin(toc.last_track); - if (cd->last_track > (MAX_TRACKS-2)) - cd->last_track = MAX_TRACKS-2; - for (j = 0, i = cd->first_track; i <= cd->last_track; i++, j++) { - cd->toc[i].adr = tl[j].adr; - cd->toc[i].ctl = tl[j].ctl; /* for xcdplayer */ - bcopy(tl[j].start_msf, cd->toc[i].start_msf, 3); -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) { - if ((j % 3) == 0) - printf("\nscd%d: tracks ", unit); - printf("[%03d: %2d %2d %2d] ", i, - bcd2bin(cd->toc[i].start_msf[0]), - bcd2bin(cd->toc[i].start_msf[1]), - bcd2bin(cd->toc[i].start_msf[2])); - } -#endif - } - bcopy(toc.lead_out_start_msf, cd->toc[cd->last_track+1].start_msf, 3); -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) { - i = cd->last_track+1; - printf("[END: %2d %2d %2d]\n", - bcd2bin(cd->toc[i].start_msf[0]), - bcd2bin(cd->toc[i].start_msf[1]), - bcd2bin(cd->toc[i].start_msf[2])); - } -#endif - - bzero(&cd->dlabel,sizeof(struct disklabel)); - /* filled with spaces first */ - strncpy(cd->dlabel.d_typename," ", - sizeof(cd->dlabel.d_typename)); - strncpy(cd->dlabel.d_typename, cd->name, - min(strlen(cd->name), sizeof(cd->dlabel.d_typename) - 1)); - strncpy(cd->dlabel.d_packname,"unknown ", - sizeof(cd->dlabel.d_packname)); - cd->dlabel.d_secsize = cd->blksize; - cd->dlabel.d_nsectors = 100; - cd->dlabel.d_ntracks = 1; - cd->dlabel.d_ncylinders = (cd->disksize/100)+1; - cd->dlabel.d_secpercyl = 100; - cd->dlabel.d_secperunit = cd->disksize; - cd->dlabel.d_rpm = 300; - cd->dlabel.d_interleave = 1; - cd->dlabel.d_flags = D_REMOVABLE; - cd->dlabel.d_npartitions= 1; - cd->dlabel.d_partitions[0].p_offset = 0; - cd->dlabel.d_partitions[0].p_size = cd->disksize; - cd->dlabel.d_partitions[0].p_fstype = 9; - cd->dlabel.d_magic = DISKMAGIC; - cd->dlabel.d_magic2 = DISKMAGIC; - cd->dlabel.d_checksum = dkcksum(&cd->dlabel); - - cd->flags |= SCDTOC; - - return 0; -} - -static inline void -write_control(unsigned port, unsigned data) -{ - outb(port + OREG_CONTROL, data); -} - -static void -init_drive(unsigned unit) -{ - int rc; - - rc = send_cmd(unit, CMD_SET_DRIVE_PARAM, 2, - 0x05, 0x03 | ((scd_data[unit].double_speed) ? 0x04: 0)); - if (rc != 0) - printf("scd%d: Unable to set parameters. Errcode = 0x%x\n", unit, rc); -} - -/* Returns 0 or errno */ -static int -get_result(u_int unit, int result_len, u_char *result) -{ - unsigned int port = scd_data[unit].iobase; - unsigned int res_reg = port + IREG_RESULT; - unsigned char c; - int loop_index = 2; /* send_cmd() reads two bytes ... */ - - XDEBUG(1, ("scd%d: DEBUG: get_result: bytes=%d\n", unit, result_len)); - - while (result_len-- > 0) { - if (loop_index++ >= 10) { - loop_index = 1; - if (waitfor_status_bits(unit, SBIT_RESULT_READY, 0)) - return EIO; - write_control(port, CBIT_RESULT_READY_CLEAR); - } - if (result) - *result++ = inb(res_reg); - else - (void)inb(res_reg); - } - return 0; -} - -/* Returns -0x100 for timeout, -(drive error code) OR number of result bytes */ -static int -send_cmd(u_int unit, u_char cmd, u_int nargs, ...) -{ - va_list ap; - u_int port = scd_data[unit].iobase; - u_int reg; - u_char c; - int rc; - int i; - - if (waitfor_status_bits(unit, 0, SBIT_BUSY)) { - printf("scd%d: drive busy\n", unit); - return -0x100; - } - - XDEBUG(1,("scd%d: DEBUG: send_cmd: cmd=0x%x nargs=%d", unit, cmd, nargs)); - - write_control(port, CBIT_RESULT_READY_CLEAR); - write_control(port, CBIT_RPARAM_CLEAR); - - for (i = 0; i < 100; i++) - if (FSTATUS_BIT(port, FBIT_WPARAM_READY)) - break; - if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) { - XDEBUG(1, ("\nscd%d: wparam timeout\n", unit)); - return -EIO; - } - - va_start(ap, nargs); - reg = port + OREG_WPARAMS; - for (i = 0; i < nargs; i++) { - c = (u_char)va_arg(ap, int); - outb(reg, c); - XDEBUG(1, (",{0x%x}", c)); - } - va_end(ap); - XDEBUG(1, ("\n")); - - outb(port+OREG_COMMAND, cmd); - - if (rc = waitfor_status_bits(unit, SBIT_RESULT_READY, SBIT_BUSY)) - return -0x100; - - reg = port + IREG_RESULT; - write_control(port, CBIT_RESULT_READY_CLEAR); - switch ((rc = inb(reg)) & 0xf0) { - case 0x20: - rc = inb(reg); - /* FALL TROUGH */ - case 0x50: - XDEBUG(1, ("scd%d: DEBUG: send_cmd: drive_error=0x%x\n", unit, rc)); - return -rc; - case 0x00: - default: - rc = inb(reg); - XDEBUG(1, ("scd%d: DEBUG: send_cmd: result_len=%d\n", unit, rc)); - return rc; - } -} - -static void -print_error(int unit, int errcode) -{ - switch (errcode) { - case -ERR_CD_NOT_LOADED: - printf("scd%d: door is open\n", unit); - break; - case -ERR_NO_CD_INSIDE: - printf("scd%d: no cd inside\n", unit); - break; - default: - if (errcode == -0x100 || errcode > 0) - printf("scd%d: device timeout\n", unit); - else - printf("scd%d: unexpected error 0x%x\n", unit, -errcode); - break; - } -} - -/* Returns 0 or errno value */ -static int -waitfor_status_bits(int unit, int bits_set, int bits_clear) -{ - u_int port = scd_data[unit].iobase; - u_int flags = scd_data[unit].flags; - u_int reg = port + IREG_STATUS; - u_int max_loop; - u_char c = 0; - - if (flags & SCDPROBING) { - max_loop = 0; - while (max_loop++ < 1000) { - c = inb(reg); - if (c == 0xff) - return EIO; - if (c & SBIT_ATTENTION) { - process_attention(unit); - continue; - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - break; - } - DELAY(10000); - } - } else { - max_loop = 100; - while (max_loop-- > 0) { - c = inb(reg); - if (c & SBIT_ATTENTION) { - process_attention(unit); - continue; - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - break; - } - tsleep(waitfor_status_bits, PZERO - 1, "waitfor", hz/10); - } - } - if ((c & bits_set) == bits_set && - (c & bits_clear) == 0) - { - return 0; - } -#ifdef SCD_DEBUG - if (scd_debuglevel > 0) - printf("scd%d: DEBUG: waitfor: TIMEOUT (0x%x,(0x%x,0x%x))\n", unit, c, bits_set, bits_clear); - else -#endif - printf("scd%d: timeout.\n", unit); - return EIO; -} - -/* these two routines for xcdplayer - "borrowed" from mcd.c */ -static int -scd_toc_header (int unit, struct ioc_toc_header* th) -{ - struct scd_data *cd = scd_data + unit; - int rc; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - - th->starting_track = cd->first_track; - th->ending_track = cd->last_track; - th->len = 0; /* not used */ - - return 0; -} - -static int -scd_toc_entrys (int unit, struct ioc_read_toc_entry *te) -{ - struct scd_data *cd = scd_data + unit; - struct cd_toc_entry toc_entry; - int rc, i, len = te->data_len; - - if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) { - print_error(unit, rc); - return EIO; - } - - /* find the toc to copy*/ - i = te->starting_track; - if (i == SCD_LASTPLUS1) - i = cd->last_track + 1; - - /* verify starting track */ - if (i < cd->first_track || i > cd->last_track+1) - return EINVAL; - - /* valid length ? */ - if (len < sizeof(struct cd_toc_entry) - || (len % sizeof(struct cd_toc_entry)) != 0) - return EINVAL; - - /* copy the toc data */ - toc_entry.control = cd->toc[i].ctl; - toc_entry.addr_type = te->address_format; - toc_entry.track = i; - if (te->address_format == CD_MSF_FORMAT) { - toc_entry.addr.msf.unused = 0; - toc_entry.addr.msf.minute = bcd2bin(cd->toc[i].start_msf[0]); - toc_entry.addr.msf.second = bcd2bin(cd->toc[i].start_msf[1]); - toc_entry.addr.msf.frame = bcd2bin(cd->toc[i].start_msf[2]); - } - - /* copy the data back */ - if (copyout(&toc_entry, te->data, sizeof(struct cd_toc_entry)) != 0) - return EFAULT; - - return 0; -} - - -#endif /* NSCD > 0 */ diff --git a/sys/gnu/i386/scdreg.h b/sys/gnu/i386/scdreg.h deleted file mode 100644 index 93ace5c..0000000 --- a/sys/gnu/i386/scdreg.h +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 1995 Mikael Hybsch - * - * The Linux driver cdu31a has been used as a reference when writing this - * code, therefore bringing it under the GNU Public License. The following - * conditions of redistribution therefore apply: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: scdreg.h,v 1.2 1995/01/29 22:51:41 jkh Exp $ - * - */ - -#ifndef SCD_H -#define SCD_H - -#ifdef __GNUC__ -#if __GNUC__ >= 2 -#pragma pack(1) -#endif -#endif - -typedef unsigned char bcd_t; -#define M_msf(msf) msf[0] -#define S_msf(msf) msf[1] -#define F_msf(msf) msf[2] - -#define IS_ATTENTION(port) ((inb(port+IREG_STATUS) & SBIT_ATTENTION) != 0) -#define IS_BUSY(port) ((inb(port+IREG_STATUS) & SBIT_BUSY) != 0) -#define IS_DATA_RDY(port) ((inb(port+IREG_STATUS) & SBIT_DATA_READY) != 0) -#define STATUS_BIT(port, bit) ((inb(port+IREG_STATUS) & (bit)) != 0) -#define FSTATUS_BIT(port, bit) ((inb(port+IREG_FSTATUS) & (bit)) != 0) - -#define OREG_COMMAND 0 -#define OREG_WPARAMS 1 -#define OREG_CONTROL 3 -#define CBIT_ATTENTION_CLEAR 0x01 -#define CBIT_RESULT_READY_CLEAR 0x02 -#define CBIT_DATA_READY_CLEAR 0x04 -#define CBIT_RPARAM_CLEAR 0x40 -#define CBIT_RESET_DRIVE 0x80 - -#define IREG_STATUS 0 -#define SBIT_ATTENTION 0x01 -#define SBIT_RESULT_READY 0x02 -#define SBIT_DATA_READY 0x04 -#define SBIT_BUSY 0x80 - -#define IREG_RESULT 1 -#define IREG_DATA 2 -#define IREG_FSTATUS 3 -#define FBIT_WPARAM_READY 0x01 - -#define CMD_GET_DRIVE_CONFIG 0x00 -#define CMD_SET_DRIVE_PARAM 0x10 -#define CMD_GET_SUBCHANNEL_DATA 0x21 -#define CMD_GET_TOC 0x24 -#define CMD_READ_TOC 0x30 -#define CMD_READ 0x34 -#define CMD_PLAY_AUDIO 0x40 -#define CMD_STOP_AUDIO 0x41 -#define CMD_EJECT 0x50 -#define CMD_SPIN_UP 0x51 -#define CMD_SPIN_DOWN 0x52 - -#define ERR_CD_NOT_LOADED 0x20 -#define ERR_NO_CD_INSIDE 0x21 -#define ERR_NOT_SPINNING 0x22 -#define ERR_FATAL_READ_ERROR1 0x53 -#define ERR_FATAL_READ_ERROR2 0x57 - -#define ATTEN_DRIVE_LOADED 0x80 -#define ATTEN_EJECT_PUSHED 0x81 -#define ATTEN_AUDIO_DONE 0x90 -#define ATTEN_SPIN_UP_DONE 0x24 -#define ATTEN_SPIN_DOWN 0x27 -#define ATTEN_EJECT_DONE 0x28 - - -struct sony_drive_configuration { - char vendor[8]; - char product[16]; - char revision[8]; - u_short config; -}; - -/* Almost same as cd_sub_channel_position_data */ -struct sony_subchannel_position_data { - u_char control:4; - u_char addr_type:4; - u_char track_number; - u_char index_number; - u_char rel_msf[3]; - u_char dummy; - u_char abs_msf[3]; -}; - -struct sony_tracklist { - u_char adr :4; /* xcdplayer needs these two values */ - u_char ctl :4; - u_char track; - u_char start_msf[3]; -}; - -#define MAX_TRACKS 100 - -struct sony_toc { - u_char session_number; - - u_char :8; - u_char :8; - u_char first_track; - u_char :8; - u_char :8; - - u_char :8; - u_char :8; - u_char last_track; - u_char :8; - u_char :8; - - u_char :8; - u_char :8; - u_char lead_out_start_msf[3]; - - struct sony_tracklist tracks[MAX_TRACKS]; - - /* The rest is just to take space in case all data is returned */ - - u_char dummy[6*9]; -}; - -#endif /* SCD_H */ diff --git a/sys/gnu/misc/aha274x.seq b/sys/gnu/misc/aha274x.seq deleted file mode 100644 index 9b83b84..0000000 --- a/sys/gnu/misc/aha274x.seq +++ /dev/null @@ -1,1064 +0,0 @@ -# @(#)aic7xxx.seq 1.30 94/11/09 jda -# -# Adaptec 274x device driver for Linux. -# Copyright (c) 1994 The University of Calgary Department of Computer Science. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -VERSION AIC7XXX_SEQ_VERSION 1.30 - -MAXSCB-1 = 0xf - -SCSISEQ = 0x00 -SXFRCTL0 = 0x01 -SXFRCTL1 = 0x02 -SCSISIGI = 0x03 -SCSISIGO = 0x03 -SCSIRATE = 0x04 -SCSIID = 0x05 -SCSIDATL = 0x06 -STCNT = 0x08 -STCNT+0 = 0x08 -STCNT+1 = 0x09 -STCNT+2 = 0x0a -SSTAT0 = 0x0b -CLRSINT1 = 0x0c -SSTAT1 = 0x0c -SIMODE1 = 0x11 -SCSIBUSL = 0x12 -SHADDR = 0x14 -SELID = 0x19 -SBLKCTL = 0x1f -SEQCTL = 0x60 -A = 0x64 # == ACCUM -SINDEX = 0x65 -DINDEX = 0x66 -ALLZEROS = 0x6a -NONE = 0x6a -SINDIR = 0x6c -DINDIR = 0x6d -FUNCTION1 = 0x6e -HADDR = 0x88 -HCNT = 0x8c -HCNT+0 = 0x8c -HCNT+1 = 0x8d -HCNT+2 = 0x8e -SCBPTR = 0x90 -INTSTAT = 0x91 -DFCNTRL = 0x93 -DFSTATUS = 0x94 -DFDAT = 0x99 -QINFIFO = 0x9b -QINCNT = 0x9c -QOUTFIFO = 0x9d - -SCSICONF = 0x5a - -# The two reserved bytes at SCBARRAY+1[23] are expected to be set to -# zero, and the reserved bit in SCBARRAY+0 is used as an internal flag -# to indicate whether or not to reload scatter-gather parameters after -# a disconnect. -# -SCBARRAY+0 = 0xa0 -SCBARRAY+1 = 0xa1 -SCBARRAY+2 = 0xa2 -SCBARRAY+3 = 0xa3 -SCBARRAY+7 = 0xa7 -SCBARRAY+11 = 0xab -SCBARRAY+14 = 0xae -SCBARRAY+15 = 0xaf -SCBARRAY+16 = 0xb0 -SCBARRAY+17 = 0xb1 -SCBARRAY+18 = 0xb2 -SCBARRAY+19 = 0xb3 -SCBARRAY+20 = 0xb4 -SCBARRAY+21 = 0xb5 -SCBARRAY+22 = 0xb6 -SCBARRAY+23 = 0xb7 -SCBARRAY+24 = 0xb8 -SCBARRAY+25 = 0xb9 - -SIGNAL_0 = 0x01 # unknown scsi bus phase -SIGNAL_1 = 0x11 # message reject -SIGNAL_2 = 0x21 # no IDENTIFY after reconnect -SIGNAL_3 = 0x31 # no cmd match for reconnect -SIGNAL_4 = 0x41 # SDTR -> SCSIRATE conversion -STATUS_ERROR = 0x51 - -# The host adapter card (at least the BIOS) uses 20-2f for SCSI -# device information, 32-33 and 5a-5f as well. Since we don't support -# wide or twin-bus SCSI, 28-2f can be reclaimed. As it turns out, the -# BIOS trashes 20-27 anyway, writing the synchronous negotiation results -# on top of the BIOS values, so we re-use those for our per-target -# scratchspace (actually a value that can be copied directly into -# SCSIRATE). This implies, since we can't get the BIOS config values, -# that all targets will be negotiated with for synchronous transfer. -# NEEDSDTR has one bit per target indicating if an SDTR message is -# needed for that device - this will be set initially, as well as -# after a bus reset condition. -# -# The high bit of DROPATN is set if ATN should be dropped before the ACK -# when outb is called. REJBYTE contains the first byte of a MESSAGE IN -# message, so the driver can report an intelligible error if a message is -# rejected. -# -# RESELECT's high bit is true if we are currently handling a reselect; -# its next-highest bit is true ONLY IF we've seen an IDENTIFY message -# from the reselecting target. If we haven't had IDENTIFY, then we have -# no idea what the lun is, and we can't select the right SCB register -# bank, so force a kernel panic if the target attempts a data in/out or -# command phase instead of corrupting something. -# -# Note that SG_NEXT occupies four bytes. -# -SYNCNEG = 0x20 -DISC_DSB_A = 0x32 - -DROPATN = 0x30 -REJBYTE = 0x31 -RESELECT = 0x34 - -MSG_FLAGS = 0x35 -MSG_LEN = 0x36 -MSG_START+0 = 0x37 -MSG_START+1 = 0x38 -MSG_START+2 = 0x39 -MSG_START+3 = 0x3a -MSG_START+4 = 0x3b -MSG_START+5 = 0x3c --MSG_START+0 = 0xc9 # 2's complement of MSG_START+0 - -ARG_1 = 0x4c # sdtr conversion args & return -ARG_2 = 0x4d -RETURN_1 = 0x4c - -SIGSTATE = 0x4e # value written to SCSISIGO -NEEDSDTR = 0x4f # send SDTR message, 1 bit/trgt - -SG_SIZEOF = 0x8 # sizeof(struct scatterlist) -SG_NOLOAD = 0x50 # load SG pointer/length? -SG_COUNT = 0x51 # working value of SG count -SG_NEXT = 0x52 # working value of SG pointer -SG_NEXT+0 = 0x52 -SG_NEXT+1 = 0x53 -SG_NEXT+2 = 0x54 -SG_NEXT+3 = 0x55 - -SCBCOUNT = 0x56 # the actual number of SCBs -ACTIVE_A = 0x57 - -# Poll QINCNT for work - the lower three bits contain -# the number of entries in the Queue In FIFO. -# -start: - test SCSISIGI,0x4 jnz reselect # BSYI - test QINCNT,MAXSCB-1 jz start - -# We have at least one queued SCB now. Set the SCB pointer -# from the FIFO so we see the right bank of SCB registers, -# then set SCSI options and set the initiator and target -# SCSI IDs. -# - mov SCBPTR,QINFIFO - -# See if there is not already an active SCB for this target. This code -# will have to be modified when we add support for dual and wide busses. - - and FUNCTION1,0x70,SCBARRAY+1 - mov A,FUNCTION1 - test ACTIVE_A,A jz active -# Place the currently active back on the queue for later processing - mov QINFIFO, SCBPTR - jmp start - -# Mark the current target as busy and get working on the SCB -active: - or ACTIVE_A,A - mov SCBARRAY+1 call initialize - clr SG_NOLOAD - clr RESELECT - -# As soon as we get a successful selection, the target should go -# into the message out phase since we have ATN asserted. Prepare -# the message to send, locking out the device driver. If the device -# driver hasn't beaten us with an ABORT or RESET message, then tack -# on a SDTR negotation if required. -# -# Messages are stored in scratch RAM starting with a flag byte (high bit -# set means active message), one length byte, and then the message itself. -# - mov SCBARRAY+1 call disconnect # disconnect ok? - - and SINDEX,0x7,SCBARRAY+1 # lun - or SINDEX,A # return value from disconnect - or SINDEX,0x80 call mk_mesg # IDENTIFY message - - mov A,SINDEX - cmp MSG_START+0,A jne !message # did driver beat us? - mvi MSG_START+1 call mk_sdtr # build SDTR message if needed - -!message: - -# Enable selection phase as an initiator, and do automatic ATN -# after the selection. -# - mvi SCSISEQ,0x48 # ENSELO|ENAUTOATNO - -# Wait for successful arbitration. The AIC-7770 documentation says -# that SELINGO indicates successful arbitration, and that it should -# be used to look for SELDO. However, if the sequencer is paused at -# just the right time - a parallel fsck(8) on two drives did it for -# me - then SELINGO can flip back to false before we've seen it. This -# makes the sequencer sit in the arbitration loop forever. This is -# Not Good. -# -# Therefore, I've added a check in the arbitration loop for SELDO -# too. This could arguably be made a critical section by disabling -# pauses, but I don't want to make a potentially infinite loop a CS. -# I suppose you could fold it into the select loop, too, but since -# I've been hunting this bug for four days it's kinda like a trophy. -# -arbitrate: - test SSTAT0,0x40 jnz *select # SELDO - test SSTAT0,0x10 jz arbitrate # SELINGO - -# Wait for a successful selection. If the hardware selection -# timer goes off, then the driver gets the interrupt, so we don't -# need to worry about it. -# -select: - test SSTAT0,0x40 jz select # SELDO - jmp *select - -# Reselection is being initiated by a target - we've seen the BSY -# line driven active, and we didn't do it! Enable the reselection -# hardware, and wait for it to finish. Make a note that we've been -# reselected, but haven't seen an IDENTIFY message from the target -# yet. -# -reselect: - mvi SCSISEQ,0x10 # ENRSELI - -reselect1: - test SSTAT0,0x20 jz reselect1 # SELDI - mov SELID call initialize - - mvi RESELECT,0x80 # reselected, no IDENTIFY - -# After the [re]selection, make sure that the [re]selection enable -# bit is off. This chip is flaky enough without extra things -# turned on. Also clear the BUSFREE bit in SSTAT1 since we'll be -# using it shortly. -# -*select: - clr SCSISEQ - mvi CLRSINT1,0x8 # CLRBUSFREE - -# Main loop for information transfer phases. If BSY is false, then -# we have a bus free condition, expected or not. Otherwise, wait -# for the target to assert REQ before checking MSG, C/D and I/O -# for the bus phase. -# -# We can't simply look at the values of SCSISIGI here (if we want -# to do synchronous data transfer), because the target won't assert -# REQ if it's already sent us some data that we haven't acknowledged -# yet. -# -ITloop: - test SSTAT1,0x8 jnz p_busfree # BUSFREE - test SSTAT1,0x1 jz ITloop # REQINIT - - and A,0xe0,SCSISIGI # CDI|IOI|MSGI - - cmp ALLZEROS,A je p_dataout - cmp A,0x40 je p_datain - cmp A,0x80 je p_command - cmp A,0xc0 je p_status - cmp A,0xa0 je p_mesgout - cmp A,0xe0 je p_mesgin - - mvi INTSTAT,SIGNAL_0 # unknown - signal driver - -p_dataout: - mvi 0 call scsisig # !CDO|!IOO|!MSGO - call assert - call sg_load - - mvi A,3 - mvi DINDEX,HCNT - mvi SCBARRAY+23 call bcopy - - mvi A,3 - mvi DINDEX,STCNT - mvi SCBARRAY+23 call bcopy - - mvi A,4 - mvi DINDEX,HADDR - mvi SCBARRAY+19 call bcopy - - mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - -# After a DMA finishes, save the final transfer pointer and count -# back into the SCB, in case a device disconnects in the middle of -# a transfer. Use SHADDR and STCNT instead of HADDR and HCNT, since -# it's a reflection of how many bytes were transferred on the SCSI -# (as opposed to the host) bus. -# - mvi A,3 - mvi DINDEX,SCBARRAY+23 - mvi STCNT call bcopy - - mvi A,4 - mvi DINDEX,SCBARRAY+19 - mvi SHADDR call bcopy - - call sg_advance - mov SCBARRAY+18,SG_COUNT # residual S/G count - - jmp ITloop - -p_datain: - mvi 0x40 call scsisig # !CDO|IOO|!MSGO - call assert - call sg_load - - mvi A,3 - mvi DINDEX,HCNT - mvi SCBARRAY+23 call bcopy - - mvi A,3 - mvi DINDEX,STCNT - mvi SCBARRAY+23 call bcopy - - mvi A,4 - mvi DINDEX,HADDR - mvi SCBARRAY+19 call bcopy - - mvi 0x39 call dma # SCSIEN|SDMAEN|HDMAEN| - # !DIRECTION|FIFORESET - mvi A,3 - mvi DINDEX,SCBARRAY+23 - mvi STCNT call bcopy - - mvi A,4 - mvi DINDEX,SCBARRAY+19 - mvi SHADDR call bcopy - - call sg_advance - mov SCBARRAY+18,SG_COUNT # residual S/G count - - jmp ITloop - -# Command phase. Set up the DMA registers and let 'er rip - the -# two bytes after the SCB SCSI_cmd_length are zeroed by the driver, -# so we can copy those three bytes directly into HCNT. -# -p_command: - mvi 0x80 call scsisig # CDO|!IOO|!MSGO - call assert - - mvi A,3 - mvi DINDEX,HCNT - mvi SCBARRAY+11 call bcopy - - mvi A,3 - mvi DINDEX,STCNT - mvi SCBARRAY+11 call bcopy - - mvi A,4 - mvi DINDEX,HADDR - mvi SCBARRAY+7 call bcopy - - mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - jmp ITloop - -# Status phase. Wait for the data byte to appear, then read it -# and store it into the SCB. -# -p_status: - mvi 0xc0 call scsisig # CDO|IOO|!MSGO - - mvi SCBARRAY+14 call inb - jmp ITloop - -# Message out phase. If there is no active message, but the target -# took us into this phase anyway, build a no-op message and send it. -# -p_mesgout: - mvi 0xa0 call scsisig # CDO|!IOO|MSGO - mvi 0x8 call mk_mesg # build NOP message - -# Set up automatic PIO transfer from MSG_START. Bit 3 in -# SXFRCTL0 (SPIOEN) is already on. -# - mvi SINDEX,MSG_START+0 - mov DINDEX,MSG_LEN - clr A - -# When target asks for a byte, drop ATN if it's the last one in -# the message. Otherwise, keep going until the message is exhausted. -# (We can't use outb for this since it wants the input in SINDEX.) -# -# Keep an eye out for a phase change, in case the target issues -# a MESSAGE REJECT. -# -p_mesgout2: - test SSTAT0,0x2 jz p_mesgout2 # SPIORDY - test SSTAT1,0x10 jnz p_mesgout6 # PHASEMIS - - cmp DINDEX,1 jne p_mesgout3 # last byte? - mvi CLRSINT1,0x40 # CLRATNO - drop ATN - -# Write a byte to the SCSI bus. The AIC-7770 refuses to automatically -# send ACKs in automatic PIO or DMA mode unless you make sure that the -# "expected" bus phase in SCSISIGO matches the actual bus phase. This -# behaviour is completely undocumented and caused me several days of -# grief. -# -# After plugging in different drives to test with and using a longer -# SCSI cable, I found that I/O in Automatic PIO mode ceased to function, -# especially when transferring >1 byte. It seems to be much more stable -# if STCNT is set to one before the transfer, and SDONE (in SSTAT0) is -# polled for transfer completion - for both output _and_ input. The -# only theory I have is that SPIORDY doesn't drop right away when SCSIDATL -# is accessed (like the documentation says it does), and that on a longer -# cable run, the sequencer code was fast enough to loop back and see -# an SPIORDY that hadn't dropped yet. -# -p_mesgout3: - call one_stcnt - mov SCSIDATL,SINDIR - -p_mesgout4: - test SSTAT0,0x4 jz p_mesgout4 # SDONE - dec DINDEX - inc A - cmp MSG_LEN,A jne p_mesgout2 - -# If the next bus phase after ATN drops is a message out, it means -# that the target is requesting that the last message(s) be resent. -# -p_mesgout5: - test SSTAT1,0x8 jnz p_mesgout6 # BUSFREE - test SSTAT1,0x1 jz p_mesgout5 # REQINIT - - and A,0xe0,SCSISIGI # CDI|IOI|MSGI - cmp A,0xa0 jne p_mesgout6 - mvi 0x10 call scsisig # ATNO - re-assert ATN - - jmp ITloop - -p_mesgout6: - mvi CLRSINT1,0x40 # CLRATNO - in case of PHASEMIS - clr MSG_FLAGS # no active msg - jmp ITloop - -# Message in phase. Bytes are read using Automatic PIO mode, but not -# using inb. This alleviates a race condition, namely that if ATN had -# to be asserted under Automatic PIO mode, it had to beat the SCSI -# circuitry sending an ACK to the target. This showed up under heavy -# loads and really confused things, since ABORT commands wouldn't be -# seen by the drive after an IDENTIFY message in until it had changed -# to a data I/O phase. -# -p_mesgin: - mvi 0xe0 call scsisig # CDO|IOO|MSGO - mvi A call inb_first # read the 1st message byte - mvi REJBYTE,A # save it for the driver - - cmp ALLZEROS,A jne p_mesgin1 - -# We got a "command complete" message, so put the SCB pointer -# into the Queue Out, and trigger a completion interrupt. -# Check status for non zero return and interrupt driver if needed -# This allows the driver to do a sense command to find out the -# source of error. We don't bother to post to the QOUTFIFO in -# the error case since it would require extra work in the kernel -# driver to ensure that the entry was removed before the command -# complete code tried processing it. - -# First, mark this target as free. - and FUNCTION1,0x70,SCBARRAY+1 - mov A,FUNCTION1 - xor ACTIVE_A,A - - test SCBARRAY+14,0xff jz status_ok # 0 Status? - call inb_last # ack & turn auto PIO back on - mvi INTSTAT,STATUS_ERROR # let driver know - jmp ITloop -status_ok: - mov QOUTFIFO,SCBPTR - mvi INTSTAT,0x2 # CMDCMPLT - jmp p_mesgin_done - -# Is it an extended message? We only support the synchronous data -# transfer request message, which will probably be in response to -# an SDTR message out from us. If it's not an SDTR, reject it - -# apparently this can be done after any message in byte, according -# to the SCSI-2 spec. -# -# XXX - we should really reject this if we didn't initiate the SDTR -# negotiation; this may cause problems with unusual devices. -# -p_mesgin1: - cmp A,1 jne p_mesgin2 # extended message code? - - mvi A call inb_next - cmp A,3 jne p_mesginN # extended mesg length = 3 - mvi A call inb_next - cmp A,1 jne p_mesginN # SDTR code - - mvi ARG_1 call inb_next # xfer period - mvi ARG_2 call inb_next # REQ/ACK offset - mvi INTSTAT,SIGNAL_4 # call driver to convert - - call ndx_sdtr # index sync config for target - mov DINDEX,SINDEX - mov DINDIR,RETURN_1 # save returned value - - not A # turn off "need sdtr" flag - and NEEDSDTR,A - -# Even though the SCSI-2 specification says that a device responding -# to our SDTR message should honor our parameters for transmitting -# to us, it doesn't seem to work too well in real life. In particular, -# a lot of CD-ROM and tape units don't function: try using the SDTR -# parameters the device sent us for both transmitting and receiving. -# - mov SCSIRATE,RETURN_1 - jmp p_mesgin_done - -# Is it a disconnect message? Set a flag in the SCB to remind us -# and await the bus going free. -# -p_mesgin2: - cmp A,4 jne p_mesgin3 # disconnect code? - - or SCBARRAY+0,0x4 # set "disconnected" bit - jmp p_mesgin_done - -# Save data pointers message? Copy working values into the SCB, -# usually in preparation for a disconnect. -# -p_mesgin3: - cmp A,2 jne p_mesgin4 # save data pointers code? - - call sg_ram2scb - jmp p_mesgin_done - -# Restore pointers message? Data pointers are recopied from the -# SCB anyway at the start of any DMA operation, so the only thing -# to copy is the scatter-gather values. -# -p_mesgin4: - cmp A,3 jne p_mesgin5 # restore pointers code? - - call sg_scb2ram - jmp p_mesgin_done - -# Identify message? For a reconnecting target, this tells us the lun -# that the reconnection is for - find the correct SCB and switch to it, -# clearing the "disconnected" bit so we don't "find" it by accident later. -# -p_mesgin5: - test A,0x80 jz p_mesgin6 # identify message? - - test A,0x78 jnz p_mesginN # !DiscPriv|!LUNTAR|!Reserved - - mov A call findSCB # switch to correct SCB - -# If a active message is present after calling findSCB, then either it -# or the driver is trying to abort the command. Either way, something -# untoward has happened and we should just leave it alone. -# - test MSG_FLAGS,0x80 jnz p_mesgin_done - - xor SCBARRAY+0,0x4 # clear disconnect bit in SCB - mvi RESELECT,0xc0 # make note of IDENTIFY - - call sg_scb2ram # implied restore pointers - # required on reselect - jmp p_mesgin_done - -# Message reject? If we have an outstanding SDTR negotiation, assume -# that it's a response from the target selecting asynchronous transfer, -# otherwise just ignore it since we have no clue what it pertains to. -# -# XXX - I don't have a device that responds this way. Does this code -# actually work? -# -p_mesgin6: - cmp A,7 jne p_mesgin7 # message reject code? - - and FUNCTION1,0x70,SCSIID # outstanding SDTR message? - mov A,FUNCTION1 - test NEEDSDTR,A jz p_mesgin_done # no - ignore rejection - - call ndx_sdtr # note use of asynch xfer - mov DINDEX,SINDEX - clr DINDIR - - not A # turn off "active sdtr" flag - and NEEDSDTR,A - - clr SCSIRATE # select asynch xfer - jmp p_mesgin_done - -# [ ADD MORE MESSAGE HANDLING HERE ] -# -p_mesgin7: - -# We have no idea what this message in is, and there's no way -# to pass it up to the kernel, so we issue a message reject and -# hope for the best. Since we're now using manual PIO mode to -# read in the message, there should no longer be a race condition -# present when we assert ATN. In any case, rejection should be a -# rare occurrence - signal the driver when it happens. -# -p_mesginN: - or SINDEX,0x10,SIGSTATE # turn on ATNO - call scsisig - mvi INTSTAT,SIGNAL_1 # let driver know - - mvi 0x7 call mk_mesg # MESSAGE REJECT message - -p_mesgin_done: - call inb_last # ack & turn auto PIO back on - jmp ITloop - -# Bus free phase. It might be useful to interrupt the device -# driver if we aren't expecting this. For now, make sure that -# ATN isn't being asserted and look for a new command. -# -p_busfree: - mvi CLRSINT1,0x40 # CLRATNO - clr SIGSTATE - jmp start - -# Bcopy: number of bytes to transfer should be in A, DINDEX should -# contain the destination address, and SINDEX should contain the -# source address. All input parameters are trashed on return. -# -bcopy: - mov DINDIR,SINDIR - dec A - cmp ALLZEROS,A jne bcopy - ret - -# Locking the driver out, build a one-byte message passed in SINDEX -# if there is no active message already. SINDEX is returned intact. -# -mk_mesg: - mvi SEQCTL,0x40 # PAUSEDIS - test MSG_FLAGS,0x80 jnz mk_mesg1 # active message? - - mvi MSG_FLAGS,0x80 # if not, there is now - mvi MSG_LEN,1 # length = 1 - mov MSG_START+0,SINDEX # 1-byte message - -mk_mesg1: - clr SEQCTL # !PAUSEDIS - ret - -# Input byte in Automatic PIO mode. The address to store the byte -# in should be in SINDEX. DINDEX will be used by this routine. -# -inb: - test SSTAT0,0x2 jz inb # SPIORDY - mov DINDEX,SINDEX - call one_stcnt # xfer one byte - mov DINDIR,SCSIDATL -inb1: - test SSTAT0,0x4 jz inb1 # SDONE - wait to "finish" - ret - -# Carefully read data in Automatic PIO mode. I first tried this using -# Manual PIO mode, but it gave me continual underrun errors, probably -# indicating that I did something wrong, but I feel more secure leaving -# Automatic PIO on all the time. -# -# According to Adaptec's documentation, an ACK is not sent on input from -# the target until SCSIDATL is read from. So we wait until SCSIDATL is -# latched (the usual way), then read the data byte directly off the bus -# using SCSIBUSL. When we have pulled the ATN line, or we just want to -# acknowledge the byte, then we do a dummy read from SCISDATL. The SCSI -# spec guarantees that the target will hold the data byte on the bus until -# we send our ACK. -# -# The assumption here is that these are called in a particular sequence, -# and that REQ is already set when inb_first is called. inb_{first,next} -# use the same calling convention as inb. -# -inb_first: - mov DINDEX,SINDEX - mov DINDIR,SCSIBUSL ret # read byte directly from bus - -inb_next: - mov DINDEX,SINDEX # save SINDEX - - call one_stcnt # xfer one byte - mov NONE,SCSIDATL # dummy read from latch to ACK -inb_next1: - test SSTAT0,0x4 jz inb_next1 # SDONE -inb_next2: - test SSTAT0,0x2 jz inb_next2 # SPIORDY - wait for next byte - mov DINDIR,SCSIBUSL ret # read byte directly from bus - -inb_last: - call one_stcnt # ACK with dummy read - mov NONE,SCSIDATL -inb_last1: - test SSTAT0,0x4 jz inb_last1 # wait for completion - ret - -# Output byte in Automatic PIO mode. The byte to output should be -# in SINDEX. If DROPATN's high bit is set, then ATN will be dropped -# before the byte is output. -# -outb: - test SSTAT0,0x2 jz outb # SPIORDY - call one_stcnt # xfer one byte - - test DROPATN,0x80 jz outb1 - mvi CLRSINT1,0x40 # CLRATNO - clr DROPATN -outb1: - mov SCSIDATL,SINDEX -outb2: - test SSTAT0,0x4 jz outb2 # SDONE - ret - -# Write the value "1" into the STCNT registers, for Automatic PIO -# transfers. -# -one_stcnt: - clr STCNT+2 - clr STCNT+1 - mvi STCNT+0,1 ret - -# DMA data transfer. HADDR and HCNT must be loaded first, and -# SINDEX should contain the value to load DFCNTRL with - 0x3d for -# host->scsi, or 0x39 for scsi->host. The SCSI channel is cleared -# during initialization. -# -dma: - mov DFCNTRL,SINDEX -dma1: -dma2: - test SSTAT0,0x1 jnz dma3 # DMADONE - test SSTAT1,0x10 jz dma1 # PHASEMIS, ie. underrun - -# We will be "done" DMAing when the transfer count goes to zero, or -# the target changes the phase (in light of this, it makes sense that -# the DMA circuitry doesn't ACK when PHASEMIS is active). If we are -# doing a SCSI->Host transfer, flush the data FIFO. -# -dma3: - test SINDEX,0x4 jnz dma5 # DIRECTION - and SINDEX,0xfe # mask out FIFORESET - or DFCNTRL,0x2,SINDEX # FIFOFLUSH -dma4: - test DFCNTRL,0x2 jnz dma4 # FIFOFLUSHACK - -# Now shut the DMA enables off, and copy STCNT (ie. the underrun -# amount, if any) to the SCB registers; SG_COUNT will get copied to -# the SCB's residual S/G count field after sg_advance is called. Make -# sure that the DMA enables are actually off first lest we get an ILLSADDR. -# -dma5: - clr DFCNTRL # disable DMA -dma6: - test DFCNTRL,0x38 jnz dma6 # SCSIENACK|SDMAENACK|HDMAENACK - - mvi A,3 - mvi DINDEX,SCBARRAY+15 - mvi STCNT call bcopy - - ret - -# Common SCSI initialization for selection and reselection. Expects -# the target SCSI ID to be in the upper four bits of SINDEX, and A's -# contents are stomped on return. -# -initialize: - clr SBLKCTL # channel A, !wide - and SCSIID,0xf0,SINDEX # target ID - and A,0x7,SCSICONF # SCSI_ID_A[210] - or SCSIID,A - -# Esundry initialization. -# - clr DROPATN - clr SIGSTATE - -# Turn on Automatic PIO mode now, before we expect to see an REQ -# from the target. It shouldn't hurt anything to leave it on. Set -# CLRCHN here before the target has entered a data transfer mode - -# with synchronous SCSI, if you do it later, you blow away some -# data in the SCSI FIFO that the target has already sent to you. -# - mvi SXFRCTL0,0xa # SPIOEN|CLRCHN - -# Set SCSI bus parity checking and the selection timeout value, -# and enable the hardware selection timer. Set the SELTO interrupt -# to signal the driver. -# - and A,0x38,SCSICONF # PARITY_ENB_A|SEL_TIM_A[10] - or SXFRCTL1,0x4,A # ENSTIMER - mvi SIMODE1,0x84 # ENSELTIMO|ENSCSIPERR - -# Initialize scatter-gather pointers by setting up the working copy -# in scratch RAM. -# - call sg_scb2ram - -# Initialize SCSIRATE with the appropriate value for this target. -# - call ndx_sdtr - mov SCSIRATE,SINDIR - ret - -# Assert that if we've been reselected, then we've seen an IDENTIFY -# message. -# -assert: - test RESELECT,0x80 jz assert1 # reselected? - test RESELECT,0x40 jnz assert1 # seen IDENTIFY? - - mvi INTSTAT,SIGNAL_2 # no - cause a kernel panic - -assert1: - ret - -# Find out if disconnection is ok from the information the BIOS has left -# us. The target ID should be in the upper four bits of SINDEX; A will -# contain either 0x40 (disconnection ok) or 0x00 (diconnection not ok) -# on exit. -# -# This is the only place the target ID is limited to three bits, so we -# can use the FUNCTION1 register. -# -disconnect: - and FUNCTION1,0x70,SINDEX # strip off extra just in case - mov A,FUNCTION1 - test DISC_DSB_A,A jz disconnect1 # bit nonzero if DISabled - - clr A ret -disconnect1: - mvi A,0x40 ret - -# Locate the SCB matching the target ID in SELID and the lun in the lower -# three bits of SINDEX, and switch the SCB to it. Have the kernel print -# a warning message if it can't be found, and generate an ABORT message -# to the target. We keep the value of the t/c/l that we are trying to -# in DINDEX so it is not overwritten during our check to see if we are -# at the last SCB. -# -findSCB: - and A,0x7,SINDEX # lun in lower three bits - or DINDEX,A,SELID # can I do this? - and DINDEX,0xf7 # only channel A implemented - - clr SINDEX - -findSCB1: - mov SCBPTR,SINDEX # switch to new SCB - mov A,DINDEX - cmp SCBARRAY+1,A jne findSCB2 # target ID/channel/lun match? - test SCBARRAY+0,0x4 jz findSCB2 # should be disconnected - - ret - -findSCB2: - inc SINDEX - mov A,SCBCOUNT - cmp SINDEX,A jne findSCB1 - - mvi INTSTAT,SIGNAL_3 # not found - signal kernel - mvi 0x6 call mk_mesg # ABORT message - - or SINDEX,0x10,SIGSTATE # assert ATNO - call scsisig - ret - -# Make a working copy of the scatter-gather parameters in the SCB. -# -sg_scb2ram: - mov SG_COUNT,SCBARRAY+2 - - mvi A,4 - mvi DINDEX,SG_NEXT - mvi SCBARRAY+3 call bcopy - - mvi SG_NOLOAD,0x80 - test SCBARRAY+0,0x10 jnz sg_scb2ram1 # don't reload s/g? - clr SG_NOLOAD - -sg_scb2ram1: - ret - -# Copying RAM values back to SCB, for Save Data Pointers message. -# -sg_ram2scb: - mov SCBARRAY+2,SG_COUNT - - mvi A,4 - mvi DINDEX,SCBARRAY+3 - mvi SG_NEXT call bcopy - - and SCBARRAY+0,0xef,SCBARRAY+0 - test SG_NOLOAD,0x80 jz sg_ram2scb1 # reload s/g? - or SCBARRAY+0,0x10 - -sg_ram2scb1: - ret - -# Load a struct scatter if needed and set up the data address and -# length. If the working value of the SG count is nonzero, then -# we need to load a new set of values. -# -# This, like the above DMA, assumes a little-endian host data storage. -# -sg_load: - test SG_COUNT,0xff jz sg_load3 # SG being used? - test SG_NOLOAD,0x80 jnz sg_load3 # don't reload s/g? - - clr HCNT+2 - clr HCNT+1 - mvi HCNT+0,SG_SIZEOF - - mvi A,4 - mvi DINDEX,HADDR - mvi SG_NEXT call bcopy - - mvi DFCNTRL,0xd # HDMAEN|DIRECTION|FIFORESET - -# Wait for DMA from host memory to data FIFO to complete, then disable -# DMA and wait for it to acknowledge that it's off. -# -sg_load1: - test DFSTATUS,0x8 jz sg_load1 # HDONE - - clr DFCNTRL # disable DMA -sg_load2: - test DFCNTRL,0x8 jnz sg_load2 # HDMAENACK - -# Copy data from FIFO into SCB data pointer and data count. This assumes -# that the struct scatterlist has this structure (this and sizeof(struct -# scatterlist) == 12 are asserted in aic7xxx.c): -# -# struct scatterlist { -# char *address; /* four bytes, little-endian order */ -# ... /* four bytes, ignored */ -# unsigned short length; /* two bytes, little-endian order */ -# } -# - -# Not in FreeBSD. the scatter list is only 8 bytes. -# -# struct ahc_dma_seg { -# physaddr addr; /* four bytes, little-endian order */ -# long len; /* four bytes, little endian order */ -# }; -# - - mov SCBARRAY+19,DFDAT # new data address - mov SCBARRAY+20,DFDAT - mov SCBARRAY+21,DFDAT - mov SCBARRAY+22,DFDAT - - mov SCBARRAY+23,DFDAT - mov SCBARRAY+24,DFDAT - mov SCBARRAY+25,DFDAT - mov NONE,DFDAT #Only support 24 bit length. - -sg_load3: - ret - -# Advance the scatter-gather pointers only IF NEEDED. If SG is enabled, -# and the SCSI transfer count is zero (note that this should be called -# right after a DMA finishes), then move the working copies of the SG -# pointer/length along. If the SCSI transfer count is not zero, then -# presumably the target is disconnecting - do not reload the SG values -# next time. -# -sg_advance: - test SG_COUNT,0xff jz sg_advance2 # s/g enabled? - - test STCNT+0,0xff jnz sg_advance1 # SCSI transfer count nonzero? - test STCNT+1,0xff jnz sg_advance1 - test STCNT+2,0xff jnz sg_advance1 - - clr SG_NOLOAD # reload s/g next time - dec SG_COUNT # one less segment to go - - clr A # add sizeof(struct scatter) - add SG_NEXT+0,SG_SIZEOF,SG_NEXT+0 - adc SG_NEXT+1,A,SG_NEXT+1 - adc SG_NEXT+2,A,SG_NEXT+2 - adc SG_NEXT+3,A,SG_NEXT+3 - - ret - -sg_advance1: - mvi SG_NOLOAD,0x80 # don't reload s/g next time -sg_advance2: - ret - -# Add the array base SYNCNEG to the target offset (the target address -# is in SCSIID), and return the result in SINDEX. The accumulator -# contains the 3->8 decoding of the target ID on return. -# -ndx_sdtr: - shr A,SCSIID,4 - and A,0x7 - add SINDEX,SYNCNEG,A - - and FUNCTION1,0x70,SCSIID # 3-bit target address decode - mov A,FUNCTION1 ret - -# If we need to negotiate transfer parameters, build the SDTR message -# starting at the address passed in SINDEX. DINDEX is modified on return. -# -mk_sdtr: - mov DINDEX,SINDEX # save SINDEX - - call ndx_sdtr - test NEEDSDTR,A jnz mk_sdtr1 # do we need negotiation? - ret - -mk_sdtr1: - mvi DINDIR,1 # extended message - mvi DINDIR,3 # extended message length = 3 - mvi DINDIR,1 # SDTR code - mvi DINDIR,25 # REQ/ACK transfer period - mvi DINDIR,15 # REQ/ACK offset - - add MSG_LEN,-MSG_START+0,DINDEX # update message length - ret - -# Set SCSI bus control signal state. This also saves the last-written -# value into a location where the higher-level driver can read it - if -# it has to send an ABORT or RESET message, then it needs to know this -# so it can assert ATN without upsetting SCSISIGO. The new value is -# expected in SINDEX. Change the actual state last to avoid contention -# from the driver. -# -scsisig: - mov SIGSTATE,SINDEX - mov SCSISIGO,SINDEX ret - diff --git a/sys/gnu/misc/aha274x_seq.c b/sys/gnu/misc/aha274x_seq.c deleted file mode 100644 index 46bb647..0000000 --- a/sys/gnu/misc/aha274x_seq.c +++ /dev/null @@ -1,355 +0,0 @@ -#define AIC7XXX_SEQ_VERSION "1.30" -unsigned char seqprog[] = { - 0x04, 0x03, 0x18, 0x1a, - 0x0f, 0x9c, 0x00, 0x1e, - 0xff, 0x9b, 0x90, 0x02, - 0x70, 0xa1, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x57, 0x08, 0x1e, - 0xff, 0x90, 0x9b, 0x02, - 0x00, 0x65, 0x00, 0x10, - 0x00, 0x57, 0x57, 0x00, - 0x00, 0xa1, 0xf3, 0x16, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x6a, 0x34, 0x02, - 0x00, 0xa1, 0x05, 0x17, - 0x07, 0xa1, 0x65, 0x02, - 0x00, 0x65, 0x65, 0x00, - 0x80, 0x65, 0xc2, 0x16, - 0xff, 0x65, 0x64, 0x02, - 0x00, 0x37, 0x13, 0x18, - 0x38, 0x6a, 0x53, 0x17, - 0x48, 0x6a, 0x00, 0x00, - 0x40, 0x0b, 0x1c, 0x1a, - 0x10, 0x0b, 0x14, 0x1e, - 0x40, 0x0b, 0x16, 0x1e, - 0x00, 0x65, 0x1c, 0x10, - 0x10, 0x6a, 0x00, 0x00, - 0x20, 0x0b, 0x19, 0x1e, - 0x00, 0x19, 0xf3, 0x16, - 0x80, 0x6a, 0x34, 0x00, - 0xff, 0x6a, 0x00, 0x02, - 0x08, 0x6a, 0x0c, 0x00, - 0x08, 0x0c, 0xbb, 0x1a, - 0x01, 0x0c, 0x1e, 0x1e, - 0xe0, 0x03, 0x64, 0x02, - 0x00, 0x6a, 0x28, 0x1c, - 0x40, 0x64, 0x3e, 0x1c, - 0x80, 0x64, 0x54, 0x1c, - 0xc0, 0x64, 0x61, 0x1c, - 0xa0, 0x64, 0x64, 0x1c, - 0xe0, 0x64, 0x7c, 0x1c, - 0x01, 0x6a, 0x91, 0x00, - 0x00, 0x6a, 0x5e, 0x17, - 0x00, 0x65, 0x01, 0x17, - 0x00, 0x65, 0x2b, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xb3, 0x6a, 0xbe, 0x16, - 0x3d, 0x6a, 0xe6, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0xb7, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0xb3, 0x6a, 0x66, 0x00, - 0x14, 0x6a, 0xbe, 0x16, - 0x00, 0x65, 0x40, 0x17, - 0xff, 0x51, 0xb2, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x5e, 0x17, - 0x00, 0x65, 0x01, 0x17, - 0x00, 0x65, 0x2b, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xb3, 0x6a, 0xbe, 0x16, - 0x39, 0x6a, 0xe6, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0xb7, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0xb3, 0x6a, 0x66, 0x00, - 0x14, 0x6a, 0xbe, 0x16, - 0x00, 0x65, 0x40, 0x17, - 0xff, 0x51, 0xb2, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0x80, 0x6a, 0x5e, 0x17, - 0x00, 0x65, 0x01, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xab, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xab, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xa7, 0x6a, 0xbe, 0x16, - 0x3d, 0x6a, 0xe6, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0xc0, 0x6a, 0x5e, 0x17, - 0xae, 0x6a, 0xc9, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0xa0, 0x6a, 0x5e, 0x17, - 0x08, 0x6a, 0xc2, 0x16, - 0x37, 0x6a, 0x65, 0x00, - 0xff, 0x36, 0x66, 0x02, - 0xff, 0x6a, 0x64, 0x02, - 0x02, 0x0b, 0x69, 0x1e, - 0x10, 0x0c, 0x79, 0x1a, - 0x01, 0x66, 0x6d, 0x18, - 0x40, 0x6a, 0x0c, 0x00, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x6c, 0x06, 0x02, - 0x04, 0x0b, 0x6f, 0x1e, - 0xff, 0x66, 0x66, 0x06, - 0x01, 0x64, 0x64, 0x06, - 0x00, 0x36, 0x69, 0x18, - 0x08, 0x0c, 0x79, 0x1a, - 0x01, 0x0c, 0x73, 0x1e, - 0xe0, 0x03, 0x64, 0x02, - 0xa0, 0x64, 0x79, 0x18, - 0x10, 0x6a, 0x5e, 0x17, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x35, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0xe0, 0x6a, 0x5e, 0x17, - 0x64, 0x6a, 0xcf, 0x16, - 0x00, 0x6a, 0x31, 0x00, - 0x00, 0x6a, 0x8a, 0x18, - 0x70, 0xa1, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x57, 0x57, 0x04, - 0xff, 0xae, 0x87, 0x1e, - 0x00, 0x65, 0xd7, 0x16, - 0x51, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0x1e, 0x10, - 0xff, 0x90, 0x9d, 0x02, - 0x02, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0xb9, 0x10, - 0x01, 0x64, 0x99, 0x18, - 0x64, 0x6a, 0xd1, 0x16, - 0x03, 0x64, 0xb5, 0x18, - 0x64, 0x6a, 0xd1, 0x16, - 0x01, 0x64, 0xb5, 0x18, - 0x4c, 0x6a, 0xd1, 0x16, - 0x4d, 0x6a, 0xd1, 0x16, - 0x41, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0x4e, 0x17, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x4c, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x04, - 0x00, 0x4f, 0x4f, 0x02, - 0xff, 0x4c, 0x04, 0x02, - 0x00, 0x65, 0xb9, 0x10, - 0x04, 0x64, 0x9c, 0x18, - 0x04, 0xa0, 0xa0, 0x00, - 0x00, 0x65, 0xb9, 0x10, - 0x02, 0x64, 0x9f, 0x18, - 0x00, 0x65, 0x23, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x03, 0x64, 0xa2, 0x18, - 0x00, 0x65, 0x1b, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x80, 0x64, 0xaa, 0x1e, - 0x78, 0x64, 0xb5, 0x1a, - 0x00, 0x64, 0x0a, 0x17, - 0x80, 0x35, 0xb9, 0x1a, - 0x04, 0xa0, 0xa0, 0x04, - 0xc0, 0x6a, 0x34, 0x00, - 0x00, 0x65, 0x1b, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x07, 0x64, 0xb5, 0x18, - 0x70, 0x05, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x4f, 0xb9, 0x1e, - 0x00, 0x65, 0x4e, 0x17, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x6a, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x04, - 0x00, 0x4f, 0x4f, 0x02, - 0xff, 0x6a, 0x04, 0x02, - 0x00, 0x65, 0xb9, 0x10, - 0x10, 0x4e, 0x65, 0x00, - 0x00, 0x65, 0x5e, 0x17, - 0x11, 0x6a, 0x91, 0x00, - 0x07, 0x6a, 0xc2, 0x16, - 0x00, 0x65, 0xd7, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x4e, 0x02, - 0x00, 0x65, 0x00, 0x10, - 0xff, 0x6c, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x06, - 0x00, 0x6a, 0xbe, 0x18, - 0xff, 0x6a, 0x6a, 0x03, - 0x40, 0x6a, 0x60, 0x00, - 0x80, 0x35, 0xc7, 0x1a, - 0x80, 0x6a, 0x35, 0x00, - 0x01, 0x6a, 0x36, 0x00, - 0xff, 0x65, 0x37, 0x02, - 0xff, 0x6a, 0x60, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0x02, 0x0b, 0xc9, 0x1e, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6d, 0x02, - 0x04, 0x0b, 0xcd, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x12, 0x6d, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6a, 0x02, - 0x04, 0x0b, 0xd4, 0x1e, - 0x02, 0x0b, 0xd5, 0x1e, - 0xff, 0x12, 0x6d, 0x03, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6a, 0x02, - 0x04, 0x0b, 0xd9, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0x02, 0x0b, 0xdb, 0x1e, - 0x00, 0x65, 0xe3, 0x16, - 0x80, 0x30, 0xe0, 0x1e, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x30, 0x02, - 0xff, 0x65, 0x06, 0x02, - 0x04, 0x0b, 0xe1, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x6a, 0x0a, 0x02, - 0xff, 0x6a, 0x09, 0x02, - 0x01, 0x6a, 0x08, 0x01, - 0xff, 0x65, 0x93, 0x02, - 0x01, 0x0b, 0xe9, 0x1a, - 0x10, 0x0c, 0xe7, 0x1e, - 0x04, 0x65, 0xed, 0x1a, - 0xfe, 0x65, 0x65, 0x02, - 0x02, 0x65, 0x93, 0x00, - 0x02, 0x93, 0xec, 0x1a, - 0xff, 0x6a, 0x93, 0x02, - 0x38, 0x93, 0xee, 0x1a, - 0x03, 0x6a, 0x64, 0x00, - 0xaf, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x6a, 0x1f, 0x02, - 0xf0, 0x65, 0x05, 0x02, - 0x07, 0x5a, 0x64, 0x02, - 0x00, 0x05, 0x05, 0x00, - 0xff, 0x6a, 0x30, 0x02, - 0xff, 0x6a, 0x4e, 0x02, - 0x0a, 0x6a, 0x01, 0x00, - 0x38, 0x5a, 0x64, 0x02, - 0x04, 0x64, 0x02, 0x00, - 0x84, 0x6a, 0x11, 0x00, - 0x00, 0x65, 0x1b, 0x17, - 0x00, 0x65, 0x4e, 0x17, - 0xff, 0x6c, 0x04, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0x80, 0x34, 0x04, 0x1f, - 0x40, 0x34, 0x04, 0x1b, - 0x21, 0x6a, 0x91, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x70, 0x65, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x32, 0x09, 0x1f, - 0xff, 0x6a, 0x64, 0x03, - 0x40, 0x6a, 0x64, 0x01, - 0x07, 0x65, 0x64, 0x02, - 0x00, 0x19, 0x66, 0x00, - 0xf7, 0x66, 0x66, 0x02, - 0xff, 0x6a, 0x65, 0x02, - 0xff, 0x65, 0x90, 0x02, - 0xff, 0x66, 0x64, 0x02, - 0x00, 0xa1, 0x13, 0x19, - 0x04, 0xa0, 0x13, 0x1f, - 0xff, 0x6a, 0x6a, 0x03, - 0x01, 0x65, 0x65, 0x06, - 0xff, 0x56, 0x64, 0x02, - 0x00, 0x65, 0x0e, 0x19, - 0x31, 0x6a, 0x91, 0x00, - 0x06, 0x6a, 0xc2, 0x16, - 0x10, 0x4e, 0x65, 0x00, - 0x00, 0x65, 0x5e, 0x17, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0xa2, 0x51, 0x02, - 0x04, 0x6a, 0x64, 0x00, - 0x52, 0x6a, 0x66, 0x00, - 0xa3, 0x6a, 0xbe, 0x16, - 0x80, 0x6a, 0x50, 0x00, - 0x10, 0xa0, 0x22, 0x1b, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0xa2, 0x02, - 0x04, 0x6a, 0x64, 0x00, - 0xa3, 0x6a, 0x66, 0x00, - 0x52, 0x6a, 0xbe, 0x16, - 0xef, 0xa0, 0xa0, 0x02, - 0x80, 0x50, 0x2a, 0x1f, - 0x10, 0xa0, 0xa0, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0x3f, 0x1f, - 0x80, 0x50, 0x3f, 0x1b, - 0xff, 0x6a, 0x8e, 0x02, - 0xff, 0x6a, 0x8d, 0x02, - 0x08, 0x6a, 0x8c, 0x00, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0x52, 0x6a, 0xbe, 0x16, - 0x0d, 0x6a, 0x93, 0x00, - 0x08, 0x94, 0x34, 0x1f, - 0xff, 0x6a, 0x93, 0x02, - 0x08, 0x93, 0x36, 0x1b, - 0xff, 0x99, 0xb3, 0x02, - 0xff, 0x99, 0xb4, 0x02, - 0xff, 0x99, 0xb5, 0x02, - 0xff, 0x99, 0xb6, 0x02, - 0xff, 0x99, 0xb7, 0x02, - 0xff, 0x99, 0xb8, 0x02, - 0xff, 0x99, 0xb9, 0x02, - 0xff, 0x99, 0x6a, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0x4d, 0x1f, - 0xff, 0x08, 0x4c, 0x1b, - 0xff, 0x09, 0x4c, 0x1b, - 0xff, 0x0a, 0x4c, 0x1b, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x51, 0x51, 0x06, - 0xff, 0x6a, 0x64, 0x02, - 0x08, 0x52, 0x52, 0x06, - 0x00, 0x53, 0x53, 0x08, - 0x00, 0x54, 0x54, 0x08, - 0x00, 0x55, 0x55, 0x08, - 0xff, 0x6a, 0x6a, 0x03, - 0x80, 0x6a, 0x50, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x4c, 0x05, 0x64, 0x0a, - 0x07, 0x64, 0x64, 0x02, - 0x20, 0x64, 0x65, 0x06, - 0x70, 0x05, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0x4e, 0x17, - 0x00, 0x4f, 0x57, 0x1b, - 0xff, 0x6a, 0x6a, 0x03, - 0x01, 0x6a, 0x6d, 0x00, - 0x03, 0x6a, 0x6d, 0x00, - 0x01, 0x6a, 0x6d, 0x00, - 0x19, 0x6a, 0x6d, 0x00, - 0x0f, 0x6a, 0x6d, 0x00, - 0xc9, 0x66, 0x36, 0x06, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x65, 0x4e, 0x02, - 0xff, 0x65, 0x03, 0x03, -}; diff --git a/sys/gnu/misc/aic7770/COPYING b/sys/gnu/misc/aic7770/COPYING deleted file mode 100644 index a43ea21..0000000 --- a/sys/gnu/misc/aic7770/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/sys/gnu/misc/aic7770/COPYRIGHT b/sys/gnu/misc/aic7770/COPYRIGHT deleted file mode 100644 index 905285d..0000000 --- a/sys/gnu/misc/aic7770/COPYRIGHT +++ /dev/null @@ -1,16 +0,0 @@ -Adaptec 274x device driver for Linux. -Copyright (c) 1994 The University of Calgary Department of Computer Science. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/sys/gnu/misc/aic7770/README b/sys/gnu/misc/aic7770/README deleted file mode 100644 index 1e4e5a0..0000000 --- a/sys/gnu/misc/aic7770/README +++ /dev/null @@ -1,94 +0,0 @@ -@(#)README 1.16 94/11/09 jda - -AHA274x/284x DRIVER - -*** THIS SHOULD BE CONSIDERED BETA SOFTWARE *** - -BACKGROUND & LIMITATIONS - -For various reasons, we ended up with one of these cards under the -impression that support was soon forthcoming. In mid-May, I asked -Scott Ferris (the official person who's supposed to be writing this -driver) what documentation he used, _finally_ got it from Adaptec, -and started writing this driver. It is now at what I would consider -a stable state - it runs our news server and is battered by SCSI -requests 24 hours a day without dying. There are a few devices it -reportedly doesn't like working with - those are being sorted out. Due -to some unexpected equipment loans, I am able to support this at least -for the time being. - -YOU MUST HAVE THE BIOS ENABLED OR THIS WILL NOT WORK. The BIOS extracts -some configuration information that I cannot get to portably yet, as -well as provides some self-tests which this driver does not attempt to -duplicate. - -Scott's driver development is stalled for now, and after discussions -with him, this is now officially out of "pre-alpha" status and into -beta until the remaining device problems can be resolved. The latest -patches can be obtained via anonymous ftp from ftp.cpsc.ucalgary.ca in -/pub/systems/linux/aha274x. - -It supports both EISA 274x and VL-bus 284x, either single or twin-bus cards -(but not the second SCSI bus of twin cards - see aha274x.c), and supports -disconnection, synchronous SCSI, and scatter-gather. Unlike previous -versions, abort() and reset() are now implemented, and both hosts.c and -aha274x.c should give a clean compile. Code is now present to detect parity -errors, but has not been tested. - -I wrote this using a 1.0.9 kernel. Unfortunately, I'm getting tired of -#ifdef'ing everything to handle two or three different evolutionary steps -in the SCSI kernel code, so I've upgraded my system to 1.1.49, and will -only leave in code to support versions from about 1.1.45 onward. - -Thanks to patches supplied by Mark Olson <molson@tricord.com>, this driver -will now work with the 284x series (the VL-bus version of this card). The -294x (PCI-bus) support is based on patches sent to me by Mark Olson and -Alan Hourihane <alanh@fairlite.demon.co.uk>. - -Under protest, this driver is subject to the GPL - see the file -COPYING for details. - -Thanks to the following people for bug fixes/code improvements (also -thanks to the people who have sent me feedback): - - "David F. Carlson" <dave@ee.rochester.edu> - Jimen Ching <jiching@wiliki.eng.hawaii.edu> - mday@artisoft.com (Matt Day) - "Dean W. Gehnert" <deang@ims.com> - Darcy Grant <darcy@cpsc.ucalgary.ca> - Alan Hourihane <alanh@fairlite.demon.co.uk> - isely@fncrd8.fnal.gov (Mike Isely) - Mike Jerger <jerger@ux1.cso.uiuc.edu> - tm@netcom.com (Toshiyasu Morita) - neal@interact.org (Neal Norwitz) - Mark Olson <molson@tricord.com> - map@europa.ecn.uoknor.edu (Michael A. Parker) - Thomas Scheunemann <thomas@dagobert.uni-duisburg.de> - -Special thanks to Drew Eckhardt <drew@kinglear.cs.Colorado.EDU> for -fielding my questions about synchronous negotiation. Steffen Moeller -<smoe0024@rz.uni-hildesheim.de> sent me installation instructions which -were previously included in this README. - -David Pirie <pirie@cpsc.ucalgary.ca> was nice enough to loan me his -2842 card for a week so I could track down one bug, as well as his -CD-ROM drive later, and also thanks to Doug Fortune at Riley's Data Share -in Calgary, who arranged a long-term loan of a 2842 board for further work. - -Many thanks to the fearless prerelease testers! Dean Gehnert has been -building Slackware boot disks for the driver, which are available from -ftp.cpsc.ucalgary.ca in /pub/systems/linux/aha274x/slackware_boot. - -Carl Riches <cgr@poplar1.cfr.washington.edu> has set up a mailing list -for aic7xxx driver development. To subscribe, send a message to -aic7770-list@poplar1.cfr.washington.edu with a message body of: - - subscribe AIC7770-LIST <your name here, without the angle brackets> - -Please direct questions and discussions to that list instead of me. When -sending bug reports, please include a description of your hardware, the -release numbers displayed by the driver at boot time, and as accurate a -facsimilie of any error message you're mailing about. - -John Aycock -aycock@cpsc.ucalgary.ca diff --git a/sys/gnu/misc/aic7770/README-FIRST b/sys/gnu/misc/aic7770/README-FIRST deleted file mode 100644 index 056dbc8..0000000 --- a/sys/gnu/misc/aic7770/README-FIRST +++ /dev/null @@ -1,19 +0,0 @@ -This is VERY MUCH ALPHA SOFTWARE. You MUST know what you're doing to -use this, or else!!! - -Ok, everything's been renamed to reference an "aic7xxx" driver instead -of "aha274x", and a merger of the two PCI patches I had has been put in, -along with re-doing the detection and configuration routines. To summarize -the status: it compiles cleanly. I don't expect it to work off the bat, -but it's for the 294x development people to synchronize their code -together. - -The file scsi-diffs-1.1.59 is NOT a proper patch file, but some diffs -to kernel files concatenated together. I've sent these off to Drew, -but if you're testing this you'll have to apply them - it allows a -per-driver-instance can_queue variable, which for the aic7xxx driver -is the number of SCBs the card supports. - -Good luck! I await your comments.. Mark, Alan - let me know where I -broke it, please ;-) -:ja diff --git a/sys/gnu/misc/aic7770/aic7770.1 b/sys/gnu/misc/aic7770/aic7770.1 deleted file mode 100644 index 2009f8c..0000000 --- a/sys/gnu/misc/aic7770/aic7770.1 +++ /dev/null @@ -1,54 +0,0 @@ -.\" Copyright (c) 1994 -.\" Justin T. Gibbs. All rights reserved. -.\" -.\" 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 Justin T. Gibbs. -.\" 4. The name of Justin T. Gibbs may not be used to endorse or promote -.\" products derived from this software without specific prior written -.\" permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JUSTIN T. GIBBS ``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. -.\" -.\" @(#)aic7770.1 11/15/94 -.\" -.Dd November 11, 1994 -.Dt AIC7770 1 -.Os BSD 4 -.Sh NAME -.Nm aic7770 -.Nd aic7770 SCSI controller assembler -.Sh SYNOPSIS -.Nm aic7770 -.Op Fl o destination -.Ar source-file -.Sh DESCRIPTION -.Ar Source-file -is a file containing Aic7770 compatible assembly code. The output of the -assembler defaults to -.Ar a.out -but can be optionally redirected to -.Ar destination. -.Pp -.Sh AUTHOR -This aic7770 compiler was written by John Aycock (aycock@cpsc.ucalgary.ca) and -is subject to the GNU Public License. - diff --git a/sys/gnu/misc/aic7770/aic7770.c b/sys/gnu/misc/aic7770/aic7770.c deleted file mode 100644 index 417a352..0000000 --- a/sys/gnu/misc/aic7770/aic7770.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Adaptec 274x device driver for Linux. - * Copyright (c) 1994 The University of Calgary Department of Computer Science. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Comments are started by `#' and continue to the end of the line; lines - * may be of the form: - * - * <label>* - * <label>* <undef-sym> = <value> - * <label>* <opcode> <operand>* - * - * A <label> is an <undef-sym> ending in a colon. Spaces, tabs, and commas - * are token separators. - */ - -/* #define _POSIX_SOURCE 1 */ -#define _POSIX_C_SOURCE 2 - -#include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#define MEMORY 512 /* 2^9 29-bit words */ -#define MAXLINE 1024 -#define MAXTOKEN 32 -#define ADOTOUT "a.out" -#define NOVALUE -1 - -/* - * AIC-7770 register definitions - */ -#define R_SINDEX 0x65 -#define R_ALLONES 0x69 -#define R_ALLZEROS 0x6a -#define R_NONE 0x6a - -static -char sccsid[] = - "@(#)aic7770.c 1.10 94/07/22 jda"; - -int debug; -int lineno, LC; -char *filename; -FILE *ifp, *ofp; -unsigned char M[MEMORY][4]; - -void error(char *s) -{ - fprintf(stderr, "%s: %s at line %d\n", filename, s, lineno); - exit(EXIT_FAILURE); -} - -void *Malloc(size_t size) -{ - void *p = malloc(size); - if (!p) - error("out of memory"); - return(p); -} - -void *Realloc(void *ptr, size_t size) -{ - void *p = realloc(ptr, size); - if (!p) - error("out of memory"); - return(p); -} - -char *Strdup(char *s) -{ - char *p = (char *)Malloc(strlen(s) + 1); - strcpy(p, s); - return(p); -} - -typedef struct sym_t { - struct sym_t *next; /* MUST BE FIRST */ - char *name; - int value; - int npatch, *patch; -} sym_t; - -sym_t *head; - -void define(char *name, int value) -{ - sym_t *p, *q; - - for (p = head, q = (sym_t *)&head; p; p = p->next) { - if (!strcmp(p->name, name)) - error("redefined symbol"); - q = p; - } - - p = q->next = (sym_t *)Malloc(sizeof(sym_t)); - p->next = NULL; - p->name = Strdup(name); - p->value = value; - p->npatch = 0; - p->patch = NULL; - - if (debug) { - fprintf(stderr, "\"%s\" ", p->name); - if (p->value != NOVALUE) - fprintf(stderr, "defined as 0x%x\n", p->value); - else - fprintf(stderr, "undefined\n"); - } -} - -sym_t *lookup(char *name) -{ - sym_t *p; - - for (p = head; p; p = p->next) - if (!strcmp(p->name, name)) - return(p); - return(NULL); -} - -void patch(sym_t *p, int location) -{ - p->npatch += 1; - p->patch = (int *)Realloc(p->patch, p->npatch * sizeof(int *)); - - p->patch[p->npatch - 1] = location; -} - -void backpatch(void) -{ - int i; - sym_t *p; - - for (p = head; p; p = p->next) { - - if (p->value == NOVALUE) { - fprintf(stderr, - "%s: undefined symbol \"%s\"\n", - filename, p->name); - exit(EXIT_FAILURE); - } - - if (p->npatch) { - if (debug) - fprintf(stderr, - "\"%s\" (0x%x) patched at", - p->name, p->value); - - for (i = 0; i < p->npatch; i++) { - M[p->patch[i]][0] &= ~1; - M[p->patch[i]][0] |= ((p->value >> 8) & 1); - M[p->patch[i]][1] = p->value & 0xff; - - if (debug) - fprintf(stderr, " 0x%x", p->patch[i]); - } - - if (debug) - fputc('\n', stderr); - } - } -} - -/* - * Output words in byte-reversed order (least significant first) - * since the sequencer RAM is loaded that way. - */ -void output(FILE *fp) -{ - int i; - - for (i = 0; i < LC; i++) - fprintf(fp, "\t0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", - M[i][3], - M[i][2], - M[i][1], - M[i][0]); -} - -char **getl(int *n) -{ - int i; - char *p; - static char buf[MAXLINE]; - static char *a[MAXTOKEN]; - - i = 0; - - while (fgets(buf, sizeof(buf), ifp)) { - - lineno += 1; - - if (buf[strlen(buf)-1] != '\n') - error("line too long"); - - p = strchr(buf, '#'); - if (p) - *p = '\0'; - - for (p = strtok(buf, ", \t\n"); p; p = strtok(NULL, ", \t\n")) - if (i < MAXTOKEN-1) - a[i++] = p; - else - error("too many tokens"); - if (i) { - *n = i; - return(a); - } - } - return(NULL); -} - -#define A 0x8000 /* `A'ccumulator ok */ -#define I 0x4000 /* use as immediate value */ -#define SL 0x2000 /* shift left */ -#define SR 0x1000 /* shift right */ -#define RL 0x0800 /* rotate left */ -#define RR 0x0400 /* rotate right */ -#define LO 0x8000 /* lookup: ori-{jmp,jc,jnc,call} */ -#define LA 0x4000 /* lookup: and-{jz,jnz} */ -#define LX 0x2000 /* lookup: xor-{je,jne} */ -#define NA -1 /* not applicable */ - -struct { - char *name; - int n; /* number of operands, including opcode */ - unsigned int op; /* immediate or L?|pos_from_0 */ - unsigned int dest; /* NA, pos_from_0, or I|immediate */ - unsigned int src; /* NA, pos_from_0, or I|immediate */ - unsigned int imm; /* pos_from_0, A|pos_from_0, or I|immediate */ - unsigned int addr; /* NA or pos_from_0 */ - int fmt; /* instruction format - 1, 2, or 3 */ -} instr[] = { -/* - * N OP DEST SRC IMM ADDR FMT - */ - "mov", 3, 1, 1, 2, I|0xff, NA, 1, - "mov", 4, LO|2, NA, 1, I|0, 3, 3, - "mvi", 3, 0, 1, I|R_ALLZEROS, A|2, NA, 1, - "mvi", 4, LO|2, NA, I|R_ALLZEROS, 1, 3, 3, - "not", 2, 2, 1, 1, I|0xff, NA, 1, - "not", 3, 2, 1, 2, I|0xff, NA, 1, - "and", 3, 1, 1, 1, A|2, NA, 1, - "and", 4, 1, 1, 3, A|2, NA, 1, - "or", 3, 0, 1, 1, A|2, NA, 1, - "or", 4, 0, 1, 3, A|2, NA, 1, - "or", 5, LO|3, NA, 1, 2, 4, 3, - "xor", 3, 2, 1, 1, A|2, NA, 1, - "xor", 4, 2, 1, 3, A|2, NA, 1, - "nop", 1, 1, I|R_NONE, I|R_ALLZEROS, I|0xff, NA, 1, - "inc", 2, 3, 1, 1, I|1, NA, 1, - "inc", 3, 3, 1, 2, I|1, NA, 1, - "dec", 2, 3, 1, 1, I|0xff, NA, 1, - "dec", 3, 3, 1, 2, I|0xff, NA, 1, - "jmp", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3, - "jc", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3, - "jnc", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3, - "call", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3, - "test", 5, LA|3, NA, 1, A|2, 4, 3, - "cmp", 5, LX|3, NA, 1, A|2, 4, 3, - "ret", 1, 1, I|R_NONE, I|R_ALLZEROS, I|0xff, NA, 1, - "clc", 1, 3, I|R_NONE, I|R_ALLZEROS, I|1, NA, 1, - "clc", 4, 3, 2, I|R_ALLZEROS, A|3, NA, 1, - "stc", 1, 3, I|R_NONE, I|R_ALLONES, I|1, NA, 1, - "stc", 2, 3, 1, I|R_ALLONES, I|1, NA, 1, - "add", 3, 3, 1, 1, A|2, NA, 1, - "add", 4, 3, 1, 3, A|2, NA, 1, - "adc", 3, 4, 1, 1, A|2, NA, 1, - "adc", 4, 4, 1, 3, A|2, NA, 1, - "shl", 3, 5, 1, 1, SL|2, NA, 2, - "shl", 4, 5, 1, 2, SL|3, NA, 2, - "shr", 3, 5, 1, 1, SR|2, NA, 2, - "shr", 4, 5, 1, 2, SR|3, NA, 2, - "rol", 3, 5, 1, 1, RL|2, NA, 2, - "rol", 4, 5, 1, 2, RL|3, NA, 2, - "ror", 3, 5, 1, 1, RR|2, NA, 2, - "ror", 4, 5, 1, 2, RR|3, NA, 2, - /* - * Extensions (note also that mvi allows A) - */ - "clr", 2, 1, 1, I|R_ALLZEROS, I|0xff, NA, 1, - 0 -}; - -int eval_operand(char **a, int spec) -{ - int i; - unsigned int want = spec & (LO|LA|LX); - - static struct { - unsigned int what; - char *name; - int value; - } jmptab[] = { - LO, "jmp", 8, - LO, "jc", 9, - LO, "jnc", 10, - LO, "call", 11, - LA, "jz", 15, - LA, "jnz", 13, - LX, "je", 14, - LX, "jne", 12, - }; - - spec &= ~(LO|LA|LX); - - for (i = 0; i < sizeof(jmptab)/sizeof(jmptab[0]); i++) - if (jmptab[i].what == want && - !strcmp(jmptab[i].name, a[spec])) - { - return(jmptab[i].value); - } - - if (want) - error("invalid jump"); - - return(spec); /* "case 0" - no flags set */ -} - -int eval_sdi(char **a, int spec) -{ - sym_t *p; - unsigned val; - - if (spec == NA) - return(NA); - - switch (spec & (A|I|SL|SR|RL|RR)) { - case SL: - case SR: - case RL: - case RR: - if (isdigit(*a[spec &~ (SL|SR|RL|RR)])) - val = strtol(a[spec &~ (SL|SR|RL|RR)], NULL, 0); - else { - p = lookup(a[spec &~ (SL|SR|RL|RR)]); - if (!p) - error("undefined symbol used"); - val = p->value; - } - - switch (spec & (SL|SR|RL|RR)) { /* blech */ - case SL: - if (val > 7) - return(0xf0); - return(((val % 8) << 4) | - (val % 8)); - case SR: - if (val > 7) - return(0xf0); - return(((val % 8) << 4) | - (1 << 3) | - ((8 - (val % 8)) % 8)); - case RL: - return(val % 8); - case RR: - return((8 - (val % 8)) % 8); - } - case I: - return(spec &~ I); - case A: - /* - * An immediate field of zero selects - * the accumulator. Vigorously object - * if zero is given otherwise - it's - * most likely an error. - */ - spec &= ~A; - if (!strcmp("A", a[spec])) - return(0); - if (isdigit(*a[spec]) && - strtol(a[spec], NULL, 0) == 0) - { - error("immediate value of zero selects accumulator"); - } - /* falls through */ - case 0: - if (isdigit(*a[spec])) - return(strtol(a[spec], NULL, 0)); - p = lookup(a[spec]); - if (p) - return(p->value); - error("undefined symbol used"); - } - - return(NA); /* shut the compiler up */ -} - -int eval_addr(char **a, int spec) -{ - sym_t *p; - - if (spec == NA) - return(NA); - if (isdigit(*a[spec])) - return(strtol(a[spec], NULL, 0)); - - p = lookup(a[spec]); - - if (p) { - if (p->value != NOVALUE) - return(p->value); - patch(p, LC); - } else { - define(a[spec], NOVALUE); - p = lookup(a[spec]); - patch(p, LC); - } - - return(NA); /* will be patched in later */ -} - -int crack(char **a, int n) -{ - int i; - int I_imm, I_addr; - int I_op, I_dest, I_src, I_ret; - - /* - * Check for "ret" at the end of the line; remove - * it unless it's "ret" alone - we still want to - * look it up in the table. - */ - I_ret = (strcmp(a[n-1], "ret") ? 0 : !0); - if (I_ret && n > 1) - n -= 1; - - for (i = 0; instr[i].name; i++) { - /* - * Look for match in table given constraints, - * currently just the name and the number of - * operands. - */ - if (!strcmp(instr[i].name, *a) && instr[i].n == n) - break; - } - if (!instr[i].name) - error("unknown opcode or wrong number of operands"); - - I_op = eval_operand(a, instr[i].op); - I_src = eval_sdi(a, instr[i].src); - I_imm = eval_sdi(a, instr[i].imm); - I_dest = eval_sdi(a, instr[i].dest); - I_addr = eval_addr(a, instr[i].addr); - - switch (instr[i].fmt) { - case 1: - case 2: - M[LC][0] = (I_op << 1) | I_ret; - M[LC][1] = I_dest; - M[LC][2] = I_src; - M[LC][3] = I_imm; - break; - case 3: - if (I_ret) - error("illegal use of \"ret\""); - M[LC][0] = (I_op << 1) | ((I_addr >> 8) & 1); - M[LC][1] = I_addr & 0xff; - M[LC][2] = I_src; - M[LC][3] = I_imm; - break; - } - - return(1); /* no two-byte instructions yet */ -} - -#undef SL -#undef SR -#undef RL -#undef RR -#undef LX -#undef LA -#undef LO -#undef I -#undef A - -void assemble(void) -{ - int n; - char **a; - sym_t *p; - - while ((a = getl(&n))) { - - while (a[0][strlen(*a)-1] == ':') { - a[0][strlen(*a)-1] = '\0'; - p = lookup(*a); - if (p) - p->value = LC; - else - define(*a, LC); - a += 1; - n -= 1; - } - - if (!n) /* line was all labels */ - continue; - - if (n == 3 && !strcmp("VERSION", *a)) - fprintf(ofp, "#define %s \"%s\"\n", a[1], a[2]); - else { - if (n == 3 && !strcmp("=", a[1])) - define(*a, strtol(a[2], NULL, 0)); - else - LC += crack(a, n); - } - } - - backpatch(); - output(ofp); - - if (debug) - output(stderr); -} - -int main(int argc, char **argv) -{ - int c; - - while ((c = getopt(argc, argv, "dho:")) != EOF) { - switch (c) { - case 'd': - debug = !0; - break; - case 'o': - ofp = fopen(optarg, "w"); - if (!ofp) { - perror(optarg); - exit(EXIT_FAILURE); - } - break; - case 'h': - printf("usage: %s [-d] [-ooutput] input\n", *argv); - exit(EXIT_SUCCESS); - case NULL: - /* - * An impossible option to shut the compiler - * up about sccsid[]. - */ - exit((int)sccsid); - default: - exit(EXIT_FAILURE); - } - } - - if (argc - optind != 1) { - fprintf(stderr, "%s: must have one input file\n", *argv); - exit(EXIT_FAILURE); - } - filename = argv[optind]; - - ifp = fopen(filename, "r"); - if (!ifp) { - perror(filename); - exit(EXIT_FAILURE); - } - - if (!ofp) { - ofp = fopen(ADOTOUT, "w"); - if (!ofp) { - perror(ADOTOUT); - exit(EXIT_FAILURE); - } - } - - assemble(); - exit(EXIT_SUCCESS); -} diff --git a/sys/gnu/misc/aic7770/aic7770.seq b/sys/gnu/misc/aic7770/aic7770.seq deleted file mode 100644 index a112033..0000000 --- a/sys/gnu/misc/aic7770/aic7770.seq +++ /dev/null @@ -1,1157 +0,0 @@ -# @(#)aic7xxx.seq 1.31 94/11/25 jda -# -# Adaptec 274x device driver for Linux. -# Copyright (c) 1994 The University of Calgary Department of Computer Science. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -VERSION AIC7XXX_SEQ_VERSION 1.31 - -SCBMASK = 0x1f - -SCSISEQ = 0x00 -SXFRCTL0 = 0x01 -SXFRCTL1 = 0x02 -SCSISIGI = 0x03 -SCSISIGO = 0x03 -SCSIRATE = 0x04 -SCSIID = 0x05 -SCSIDATL = 0x06 -STCNT = 0x08 -STCNT+0 = 0x08 -STCNT+1 = 0x09 -STCNT+2 = 0x0a -SSTAT0 = 0x0b -CLRSINT1 = 0x0c -SSTAT1 = 0x0c -SIMODE1 = 0x11 -SCSIBUSL = 0x12 -SHADDR = 0x14 -SELID = 0x19 -SBLKCTL = 0x1f -SEQCTL = 0x60 -A = 0x64 # == ACCUM -SINDEX = 0x65 -DINDEX = 0x66 -ALLZEROS = 0x6a -NONE = 0x6a -SINDIR = 0x6c -DINDIR = 0x6d -FUNCTION1 = 0x6e -HADDR = 0x88 -HCNT = 0x8c -HCNT+0 = 0x8c -HCNT+1 = 0x8d -HCNT+2 = 0x8e -SCBPTR = 0x90 -INTSTAT = 0x91 -DFCNTRL = 0x93 -DFSTATUS = 0x94 -DFDAT = 0x99 -QINFIFO = 0x9b -QINCNT = 0x9c -QOUTFIFO = 0x9d - -SCSICONF_A = 0x5a -SCSICONF_B = 0x5b - -# The two reserved bytes at SCBARRAY+1[23] are expected to be set to -# zero, and the reserved bit in SCBARRAY+0 is used as an internal flag -# to indicate whether or not to reload scatter-gather parameters after -# a disconnect. -# -SCBARRAY+0 = 0xa0 -SCBARRAY+1 = 0xa1 -SCBARRAY+2 = 0xa2 -SCBARRAY+3 = 0xa3 -SCBARRAY+7 = 0xa7 -SCBARRAY+11 = 0xab -SCBARRAY+14 = 0xae -SCBARRAY+15 = 0xaf -SCBARRAY+16 = 0xb0 -SCBARRAY+17 = 0xb1 -SCBARRAY+18 = 0xb2 -SCBARRAY+19 = 0xb3 -SCBARRAY+20 = 0xb4 -SCBARRAY+21 = 0xb5 -SCBARRAY+22 = 0xb6 -SCBARRAY+23 = 0xb7 -SCBARRAY+24 = 0xb8 -SCBARRAY+25 = 0xb9 - -SIGNAL_0 = 0x01 # unknown scsi bus phase -SIGNAL_1 = 0x11 # message reject -SIGNAL_2 = 0x21 # no IDENTIFY after reconnect -SIGNAL_3 = 0x31 # no cmd match for reconnect -SIGNAL_4 = 0x41 # SDTR -> SCSIRATE conversion -STATUS_ERROR = 0x51 - -# The host adapter card (at least the BIOS) uses 20-2f for SCSI -# device information, 32-33 and 5a-5f as well. As it turns out, the -# BIOS trashes 20-2f, writing the synchronous negotiation results -# on top of the BIOS values, so we re-use those for our per-target -# scratchspace (actually a value that can be copied directly into -# SCSIRATE). The kernel driver will enable synchronous negotiation -# for all targets that have a value other than 0 in the lower four -# bits of the target scratch space. This should work irregardless of -# whether the bios has been installed. NEEDSDTR has one bit per target -# indicating if an SDTR message is needed for that device - this will -# be set initially (based on a search through the target scratch space), -# as well as after a bus reset condition. -# -# The high bit of DROPATN is set if ATN should be dropped before the ACK -# when outb is called. REJBYTE contains the first byte of a MESSAGE IN -# message, so the driver can report an intelligible error if a message is -# rejected. -# -# RESELECT's high bit is true if we are currently handling a reselect; -# its next-highest bit is true ONLY IF we've seen an IDENTIFY message -# from the reselecting target. If we haven't had IDENTIFY, then we have -# no idea what the lun is, and we can't select the right SCB register -# bank, so force a kernel panic if the target attempts a data in/out or -# command phase instead of corrupting something. -# -# Note that SG_NEXT occupies four bytes. -# -SYNCNEG = 0x20 - -DROPATN = 0x30 -REJBYTE = 0x31 -DISC_DSB_A = 0x32 -DISC_DSB_B = 0x33 -RESELECT = 0x34 - -MSG_FLAGS = 0x35 -MSG_LEN = 0x36 -MSG_START+0 = 0x37 -MSG_START+1 = 0x38 -MSG_START+2 = 0x39 -MSG_START+3 = 0x3a -MSG_START+4 = 0x3b -MSG_START+5 = 0x3c --MSG_START+0 = 0xc9 # 2's complement of MSG_START+0 - -ARG_1 = 0x4c # sdtr conversion args & return -RETURN_1 = 0x4c - -SIGSTATE = 0x4d # value written to SCSISIGO -NEEDSDTR_A = 0x4e # send SDTR message, 1 bit/trgt -NEEDSDTR_B = 0x4f - -SG_SIZEOF = 0x8 # sizeof(struct scatterlist) -SG_NOLOAD = 0x50 # load SG pointer/length? -SG_COUNT = 0x51 # working value of SG count -SG_NEXT = 0x52 # working value of SG pointer -SG_NEXT+0 = 0x52 -SG_NEXT+1 = 0x53 -SG_NEXT+2 = 0x54 -SG_NEXT+3 = 0x55 - -SCBCOUNT = 0x56 # the actual number of SCBs -FLAGS = 0x57 # Device configuration flags -TWIN_BUS = 0x01 -WIDE_BUS = 0x02 - -ACTIVE_A = 0x58 -ACTIVE_B = 0x59 - -# Poll QINCNT for work - the lower bits contain -# the number of entries in the Queue In FIFO. -# -start: - test FLAGS,TWIN_BUS jz start2 # Are we a twin channel device? -# For fairness, we check the other bus first, since we just finished a -# transaction on the current channel. - xor SBLKCTL,0x08 # Toggle to the other bus - test SCSISIGI,0x4 jnz reselect # BSYI - xor SBLKCTL,0x08 # Toggle to the original bus -start2: - test SCSISIGI,0x4 jnz reselect # BSYI - test QINCNT,SCBMASK jz start - -# We have at least one queued SCB now. Set the SCB pointer -# from the FIFO so we see the right bank of SCB registers, -# then set SCSI options and set the initiator and target -# SCSI IDs. -# - mov SCBPTR,QINFIFO - -# See if there is not already an active SCB for this target. This code -# locks out on a per target basis instead of target/lun. Although this -# is not ideal for devices that have multiple luns active at the same -# time, it is faster than looping through all SCB's looking for active -# commands. It may be benificial to make findscb a more general procedure -# to see if the added cost of the search is negligible. This code also -# assumes that the kernel driver will clear the active flags on board -# initialization, board reset, and a target's SELTO. - - and FUNCTION1,0x70,SCBARRAY+1 - mov A,FUNCTION1 - test SCBARRAY+1,0x88 jz test_a # Id < 8 && A channel - - test ACTIVE_B,A jnz requeue - or ACTIVE_B,A # Mark the current target as busy - jmp start_scb - -# Place the currently active back on the queue for later processing -requeue: - mov QINFIFO, SCBPTR - jmp start - -test_a: - test ACTIVE_A,A jnz requeue - or ACTIVE_A,A # Mark the current target as busy - -start_scb: - and A,0x08,SCBARRAY+1 - mov SBLKCTL,A # select channel, !wide - mov SCBARRAY+1 call initialize - clr SG_NOLOAD - clr RESELECT - -# As soon as we get a successful selection, the target should go -# into the message out phase since we have ATN asserted. Prepare -# the message to send, locking out the device driver. If the device -# driver hasn't beaten us with an ABORT or RESET message, then tack -# on an SDTR negotiation if required. -# -# Messages are stored in scratch RAM starting with a flag byte (high bit -# set means active message), one length byte, and then the message itself. -# - mov SCBARRAY+1 call disconnect # disconnect ok? - - and SINDEX,0x7,SCBARRAY+1 # lun - or SINDEX,A # return value from disconnect - or SINDEX,0x80 call mk_mesg # IDENTIFY message - - mov A,SINDEX - cmp MSG_START+0,A jne !message # did driver beat us? - mvi MSG_START+1 call mk_sdtr # build SDTR message if needed - -!message: - -# Enable selection phase as an initiator, and do automatic ATN -# after the selection. -# - mvi SCSISEQ,0x48 # ENSELO|ENAUTOATNO - -# Wait for successful arbitration. The AIC-7770 documentation says -# that SELINGO indicates successful arbitration, and that it should -# be used to look for SELDO. However, if the sequencer is paused at -# just the right time - a parallel fsck(8) on two drives did it for -# me - then SELINGO can flip back to false before we've seen it. This -# makes the sequencer sit in the arbitration loop forever. This is -# Not Good. -# -# Therefore, I've added a check in the arbitration loop for SELDO -# too. This could arguably be made a critical section by disabling -# pauses, but I don't want to make a potentially infinite loop a CS. -# I suppose you could fold it into the select loop, too, but since -# I've been hunting this bug for four days it's kinda like a trophy. -# -arbitrate: - test SSTAT0,0x40 jnz *select # SELDO - test SSTAT0,0x10 jz arbitrate # SELINGO - -# Wait for a successful selection. If the hardware selection -# timer goes off, then the driver gets the interrupt, so we don't -# need to worry about it. -# -select: - test SSTAT0,0x40 jz select # SELDO - jmp *select - -# Reselection is being initiated by a target - we've seen the BSY -# line driven active, and we didn't do it! Enable the reselection -# hardware, and wait for it to finish. Make a note that we've been -# reselected, but haven't seen an IDENTIFY message from the target -# yet. -# -reselect: - mvi SCSISEQ,0x10 # ENRSELI - -reselect1: - test SSTAT0,0x20 jz reselect1 # SELDI - mov SELID call initialize - - mvi RESELECT,0x80 # reselected, no IDENTIFY - -# After the [re]selection, make sure that the [re]selection enable -# bit is off. This chip is flaky enough without extra things -# turned on. Also clear the BUSFREE bit in SSTAT1 since we'll be -# using it shortly. -# -*select: - clr SCSISEQ - mvi CLRSINT1,0x8 # CLRBUSFREE - -# Main loop for information transfer phases. If BSY is false, then -# we have a bus free condition, expected or not. Otherwise, wait -# for the target to assert REQ before checking MSG, C/D and I/O -# for the bus phase. -# -# We can't simply look at the values of SCSISIGI here (if we want -# to do synchronous data transfer), because the target won't assert -# REQ if it's already sent us some data that we haven't acknowledged -# yet. -# -ITloop: - test SSTAT1,0x8 jnz p_busfree # BUSFREE - test SSTAT1,0x1 jz ITloop # REQINIT - - and A,0xe0,SCSISIGI # CDI|IOI|MSGI - - cmp ALLZEROS,A je p_dataout - cmp A,0x40 je p_datain - cmp A,0x80 je p_command - cmp A,0xc0 je p_status - cmp A,0xa0 je p_mesgout - cmp A,0xe0 je p_mesgin - - mvi INTSTAT,SIGNAL_0 # unknown - signal driver - -p_dataout: - mvi 0 call scsisig # !CDO|!IOO|!MSGO - call assert - call sg_load - - mvi A,3 - mvi DINDEX,HCNT - mvi SCBARRAY+23 call bcopy - - mvi A,3 - mvi DINDEX,STCNT - mvi SCBARRAY+23 call bcopy - - mvi A,4 - mvi DINDEX,HADDR - mvi SCBARRAY+19 call bcopy - - mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - -# After a DMA finishes, save the final transfer pointer and count -# back into the SCB, in case a device disconnects in the middle of -# a transfer. Use SHADDR and STCNT instead of HADDR and HCNT, since -# it's a reflection of how many bytes were transferred on the SCSI -# (as opposed to the host) bus. -# - mvi A,3 - mvi DINDEX,SCBARRAY+23 - mvi STCNT call bcopy - - mvi A,4 - mvi DINDEX,SCBARRAY+19 - mvi SHADDR call bcopy - - call sg_advance - mov SCBARRAY+18,SG_COUNT # residual S/G count - - jmp ITloop - -p_datain: - mvi 0x40 call scsisig # !CDO|IOO|!MSGO - call assert - call sg_load - - mvi A,3 - mvi DINDEX,HCNT - mvi SCBARRAY+23 call bcopy - - mvi A,3 - mvi DINDEX,STCNT - mvi SCBARRAY+23 call bcopy - - mvi A,4 - mvi DINDEX,HADDR - mvi SCBARRAY+19 call bcopy - - mvi 0x39 call dma # SCSIEN|SDMAEN|HDMAEN| - # !DIRECTION|FIFORESET - mvi A,3 - mvi DINDEX,SCBARRAY+23 - mvi STCNT call bcopy - - mvi A,4 - mvi DINDEX,SCBARRAY+19 - mvi SHADDR call bcopy - - call sg_advance - mov SCBARRAY+18,SG_COUNT # residual S/G count - - jmp ITloop - -# Command phase. Set up the DMA registers and let 'er rip - the -# two bytes after the SCB SCSI_cmd_length are zeroed by the driver, -# so we can copy those three bytes directly into HCNT. -# -p_command: - mvi 0x80 call scsisig # CDO|!IOO|!MSGO - call assert - - mvi A,3 - mvi DINDEX,HCNT - mvi SCBARRAY+11 call bcopy - - mvi A,3 - mvi DINDEX,STCNT - mvi SCBARRAY+11 call bcopy - - mvi A,4 - mvi DINDEX,HADDR - mvi SCBARRAY+7 call bcopy - - mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - jmp ITloop - -# Status phase. Wait for the data byte to appear, then read it -# and store it into the SCB. -# -p_status: - mvi 0xc0 call scsisig # CDO|IOO|!MSGO - - mvi SCBARRAY+14 call inb - jmp ITloop - -# Message out phase. If there is no active message, but the target -# took us into this phase anyway, build a no-op message and send it. -# -p_mesgout: - mvi 0xa0 call scsisig # CDO|!IOO|MSGO - mvi 0x8 call mk_mesg # build NOP message - -# Set up automatic PIO transfer from MSG_START. Bit 3 in -# SXFRCTL0 (SPIOEN) is already on. -# - mvi SINDEX,MSG_START+0 - mov DINDEX,MSG_LEN - clr A - -# When target asks for a byte, drop ATN if it's the last one in -# the message. Otherwise, keep going until the message is exhausted. -# (We can't use outb for this since it wants the input in SINDEX.) -# -# Keep an eye out for a phase change, in case the target issues -# a MESSAGE REJECT. -# -p_mesgout2: - test SSTAT0,0x2 jz p_mesgout2 # SPIORDY - test SSTAT1,0x10 jnz p_mesgout6 # PHASEMIS - - cmp DINDEX,1 jne p_mesgout3 # last byte? - mvi CLRSINT1,0x40 # CLRATNO - drop ATN - -# Write a byte to the SCSI bus. The AIC-7770 refuses to automatically -# send ACKs in automatic PIO or DMA mode unless you make sure that the -# "expected" bus phase in SCSISIGO matches the actual bus phase. This -# behaviour is completely undocumented and caused me several days of -# grief. -# -# After plugging in different drives to test with and using a longer -# SCSI cable, I found that I/O in Automatic PIO mode ceased to function, -# especially when transferring >1 byte. It seems to be much more stable -# if STCNT is set to one before the transfer, and SDONE (in SSTAT0) is -# polled for transfer completion - for both output _and_ input. The -# only theory I have is that SPIORDY doesn't drop right away when SCSIDATL -# is accessed (like the documentation says it does), and that on a longer -# cable run, the sequencer code was fast enough to loop back and see -# an SPIORDY that hadn't dropped yet. -# -p_mesgout3: - call one_stcnt - mov SCSIDATL,SINDIR - -p_mesgout4: - test SSTAT0,0x4 jz p_mesgout4 # SDONE - dec DINDEX - inc A - cmp MSG_LEN,A jne p_mesgout2 - -# If the next bus phase after ATN drops is a message out, it means -# that the target is requesting that the last message(s) be resent. -# -p_mesgout5: - test SSTAT1,0x8 jnz p_mesgout6 # BUSFREE - test SSTAT1,0x1 jz p_mesgout5 # REQINIT - - and A,0xe0,SCSISIGI # CDI|IOI|MSGI - cmp A,0xa0 jne p_mesgout6 - mvi 0x10 call scsisig # ATNO - re-assert ATN - - jmp ITloop - -p_mesgout6: - mvi CLRSINT1,0x40 # CLRATNO - in case of PHASEMIS - clr MSG_FLAGS # no active msg - jmp ITloop - -# Message in phase. Bytes are read using Automatic PIO mode, but not -# using inb. This alleviates a race condition, namely that if ATN had -# to be asserted under Automatic PIO mode, it had to beat the SCSI -# circuitry sending an ACK to the target. This showed up under heavy -# loads and really confused things, since ABORT commands wouldn't be -# seen by the drive after an IDENTIFY message in until it had changed -# to a data I/O phase. -# -p_mesgin: - mvi 0xe0 call scsisig # CDO|IOO|MSGO - mvi A call inb_first # read the 1st message byte - mvi REJBYTE,A # save it for the driver - - cmp ALLZEROS,A jne p_mesgin1 - -# We got a "command complete" message, so put the SCB pointer -# into the Queue Out, and trigger a completion interrupt. -# Check status for non zero return and interrupt driver if needed -# This allows the driver to interpret errors only when they occur -# instead of always uploading the scb. If the status is SCSI_CHECK, -# the driver will download a new scb requesting sense, to replace -# the old one and the sequencer code will imediately jump to start -# working on it. If the kernel driver does not wish to request sense, -# the sequencer program counter is incremented by 1, preventing another run -# on the current SCB and the command is allowed to complete. We don't -# bother to post to the QOUTFIFO in the error case since it would require -# extra work in the kernel driver to ensure that the entry was removed -# before the command complete code tried processing it. - - test SCBARRAY+14,0xff jz status_ok # 0 Status? - call inb_last # ack & turn auto PIO back on - mvi INTSTAT,STATUS_ERROR # let driver know - jmp start_scb - -status_ok: - -# First, mark this target as free. - and FUNCTION1,0x70,SCBARRAY+1 - mov A,FUNCTION1 - test SCBARRAY+1,0x88 jz clear_a - xor ACTIVE_B,A - jmp complete - -clear_a: - xor ACTIVE_A,A - -complete: - mov QOUTFIFO,SCBPTR - mvi INTSTAT,0x02 # CMDCMPLT - jmp p_mesgin_done - -# Is it an extended message? We only support the synchronous data -# transfer request message, which will probably be in response to -# an SDTR message out from us. If it's not an SDTR, reject it - -# apparently this can be done after any message in byte, according -# to the SCSI-2 spec. -# -# XXX - we should really reject this if we didn't initiate the SDTR -# negotiation; this may cause problems with unusual devices. -# -p_mesgin1: - cmp A,1 jne p_mesgin2 # extended message code? - - mvi A call inb_next - cmp A,3 jne p_mesginN # extended mesg length = 3 - mvi A call inb_next - cmp A,1 jne p_mesginN # SDTR code - - mvi ARG_1 call inb_next # xfer period - mvi A call inb_next # REQ/ACK offset - mvi INTSTAT,SIGNAL_4 # call driver to convert - - call ndx_sdtr # index sync config for target - mov DINDEX,SINDEX - not A # turn off "need sdtr" flag - test SBLKCTL,0x08 jnz p_mesgin1_b - test SCSIID,0x80 jnz p_mesgin1_b - and NEEDSDTR_A,A - jmp p_mesgin1_save - -p_mesgin1_b: - and NEEDSDTR_B,A - -p_mesgin1_save: - and A,0x80,SINDIR # get the WIDEXFER flag - or RETURN_1,A # Set WIDEXFER if necessary - mov DINDIR,RETURN_1 # save returned value - -# Even though the SCSI-2 specification says that a device responding -# to our SDTR message should honor our parameters for transmitting -# to us, it doesn't seem to work too well in real life. In particular, -# a lot of CD-ROM and tape units don't function: try using the SDTR -# parameters the device sent us for both transmitting and receiving. -# - mov SCSIRATE,RETURN_1 - jmp p_mesgin_done - -# Is it a disconnect message? Set a flag in the SCB to remind us -# and await the bus going free. -# -p_mesgin2: - cmp A,4 jne p_mesgin3 # disconnect code? - - or SCBARRAY+0,0x4 # set "disconnected" bit - jmp p_mesgin_done - -# Save data pointers message? Copy working values into the SCB, -# usually in preparation for a disconnect. -# -p_mesgin3: - cmp A,2 jne p_mesgin4 # save data pointers code? - - call sg_ram2scb - jmp p_mesgin_done - -# Restore pointers message? Data pointers are recopied from the -# SCB anyway at the start of any DMA operation, so the only thing -# to copy is the scatter-gather values. -# -p_mesgin4: - cmp A,3 jne p_mesgin5 # restore pointers code? - - call sg_scb2ram - jmp p_mesgin_done - -# Identify message? For a reconnecting target, this tells us the lun -# that the reconnection is for - find the correct SCB and switch to it, -# clearing the "disconnected" bit so we don't "find" it by accident later. -# -p_mesgin5: - test A,0x80 jz p_mesgin6 # identify message? - - test A,0x78 jnz p_mesginN # !DiscPriv|!LUNTAR|!Reserved - - mov A call findSCB # switch to correct SCB - -# If a active message is present after calling findSCB, then either it -# or the driver is trying to abort the command. Either way, something -# untoward has happened and we should just leave it alone. -# - test MSG_FLAGS,0x80 jnz p_mesgin_done - - and SCBARRAY+0,0xfb # clear disconnect bit in SCB - mvi RESELECT,0xc0 # make note of IDENTIFY - - call sg_scb2ram # implied restore pointers - # required on reselect - jmp p_mesgin_done - -# Message reject? If we have an outstanding SDTR negotiation, assume -# that it's a response from the target selecting asynchronous transfer, -# otherwise just ignore it since we have no clue what it pertains to. -# -# XXX - I don't have a device that responds this way. Does this code -# actually work? -# -p_mesgin6: - cmp A,7 jne p_mesgin7 # message reject code? - - and FUNCTION1,0x70,SCSIID # outstanding SDTR message? - mov A,FUNCTION1 - - test SBLKCTL,0x08 jnz p_mesgin6_b - test SCSIID,0x80 jnz p_mesgin6_b - test NEEDSDTR_A,A jz p_mesgin_done # no - ignore rejection - call ndx_sdtr # note use of asynch xfer - mov DINDEX,SINDEX - clr DINDIR - - not A - and NEEDSDTR_A,A - jmp p_mesgin6_done - -p_mesgin6_b: - test NEEDSDTR_B,A jz p_mesgin_done # no - ignore rejection - call ndx_sdtr # note use of asynch xfer - mov DINDEX,SINDEX - clr DINDIR - - not A - and NEEDSDTR_B,A - -p_mesgin6_done: - - clr SCSIRATE # select asynch xfer - jmp p_mesgin_done - -# [ ADD MORE MESSAGE HANDLING HERE ] -# -p_mesgin7: - -# We have no idea what this message in is, and there's no way -# to pass it up to the kernel, so we issue a message reject and -# hope for the best. Since we're now using manual PIO mode to -# read in the message, there should no longer be a race condition -# present when we assert ATN. In any case, rejection should be a -# rare occurrence - signal the driver when it happens. -# -p_mesginN: - or SINDEX,0x10,SIGSTATE # turn on ATNO - call scsisig - mvi INTSTAT,SIGNAL_1 # let driver know - - mvi 0x7 call mk_mesg # MESSAGE REJECT message - -p_mesgin_done: - call inb_last # ack & turn auto PIO back on - jmp ITloop - -# Bus free phase. It might be useful to interrupt the device -# driver if we aren't expecting this. For now, make sure that -# ATN isn't being asserted and look for a new command. -# -p_busfree: - mvi CLRSINT1,0x40 # CLRATNO - clr SIGSTATE - jmp start - -# Bcopy: number of bytes to transfer should be in A, DINDEX should -# contain the destination address, and SINDEX should contain the -# source address. All input parameters are trashed on return. -# -bcopy: - mov DINDIR,SINDIR - dec A - cmp ALLZEROS,A jne bcopy - ret - -# Locking the driver out, build a one-byte message passed in SINDEX -# if there is no active message already. SINDEX is returned intact. -# -mk_mesg: - mvi SEQCTL,0x50 # PAUSEDIS|FASTMODE - test MSG_FLAGS,0x80 jnz mk_mesg1 # active message? - - mvi MSG_FLAGS,0x80 # if not, there is now - mvi MSG_LEN,1 # length = 1 - mov MSG_START+0,SINDEX # 1-byte message - -mk_mesg1: - mvi SEQCTL,0x10 # !PAUSEDIS|FASTMODE - ret - -# Input byte in Automatic PIO mode. The address to store the byte -# in should be in SINDEX. DINDEX will be used by this routine. -# -inb: - test SSTAT0,0x2 jz inb # SPIORDY - mov DINDEX,SINDEX - call one_stcnt # xfer one byte - mov DINDIR,SCSIDATL -inb1: - test SSTAT0,0x4 jz inb1 # SDONE - wait to "finish" - ret - -# Carefully read data in Automatic PIO mode. I first tried this using -# Manual PIO mode, but it gave me continual underrun errors, probably -# indicating that I did something wrong, but I feel more secure leaving -# Automatic PIO on all the time. -# -# According to Adaptec's documentation, an ACK is not sent on input from -# the target until SCSIDATL is read from. So we wait until SCSIDATL is -# latched (the usual way), then read the data byte directly off the bus -# using SCSIBUSL. When we have pulled the ATN line, or we just want to -# acknowledge the byte, then we do a dummy read from SCISDATL. The SCSI -# spec guarantees that the target will hold the data byte on the bus until -# we send our ACK. -# -# The assumption here is that these are called in a particular sequence, -# and that REQ is already set when inb_first is called. inb_{first,next} -# use the same calling convention as inb. -# -inb_first: - mov DINDEX,SINDEX - mov DINDIR,SCSIBUSL ret # read byte directly from bus - -inb_next: - mov DINDEX,SINDEX # save SINDEX - - call one_stcnt # xfer one byte - mov NONE,SCSIDATL # dummy read from latch to ACK -inb_next1: - test SSTAT0,0x4 jz inb_next1 # SDONE -inb_next2: - test SSTAT0,0x2 jz inb_next2 # SPIORDY - wait for next byte - mov DINDIR,SCSIBUSL ret # read byte directly from bus - -inb_last: - call one_stcnt # ACK with dummy read - mov NONE,SCSIDATL -inb_last1: - test SSTAT0,0x4 jz inb_last1 # wait for completion - ret - -# Output byte in Automatic PIO mode. The byte to output should be -# in SINDEX. If DROPATN's high bit is set, then ATN will be dropped -# before the byte is output. -# -outb: - test SSTAT0,0x2 jz outb # SPIORDY - call one_stcnt # xfer one byte - - test DROPATN,0x80 jz outb1 - mvi CLRSINT1,0x40 # CLRATNO - clr DROPATN -outb1: - mov SCSIDATL,SINDEX -outb2: - test SSTAT0,0x4 jz outb2 # SDONE - ret - -# Write the value "1" into the STCNT registers, for Automatic PIO -# transfers. -# -one_stcnt: - clr STCNT+2 - clr STCNT+1 - mvi STCNT+0,1 ret - -# DMA data transfer. HADDR and HCNT must be loaded first, and -# SINDEX should contain the value to load DFCNTRL with - 0x3d for -# host->scsi, or 0x39 for scsi->host. The SCSI channel is cleared -# during initialization. -# -dma: - mov DFCNTRL,SINDEX -dma1: -dma2: - test SSTAT0,0x1 jnz dma3 # DMADONE - test SSTAT1,0x10 jz dma1 # PHASEMIS, ie. underrun - -# We will be "done" DMAing when the transfer count goes to zero, or -# the target changes the phase (in light of this, it makes sense that -# the DMA circuitry doesn't ACK when PHASEMIS is active). If we are -# doing a SCSI->Host transfer, the data FIFO should be flushed auto- -# magically on STCNT=0 or a phase change, so just wait for FIFO empty -# status. -# -dma3: - test SINDEX,0x4 jnz dma5 # DIRECTION -dma4: - test DFSTATUS,0x1 jz dma4 # FIFOEMP - -# Now shut the DMA enables off, and copy STCNT (ie. the underrun -# amount, if any) to the SCB registers; SG_COUNT will get copied to -# the SCB's residual S/G count field after sg_advance is called. Make -# sure that the DMA enables are actually off first lest we get an ILLSADDR. -# -dma5: - clr DFCNTRL # disable DMA -dma6: - test DFCNTRL,0x38 jnz dma6 # SCSIENACK|SDMAENACK|HDMAENACK - - mvi A,3 - mvi DINDEX,SCBARRAY+15 - mvi STCNT call bcopy - - ret - -# Common SCSI initialization for selection and reselection. Expects -# the target SCSI ID to be in the upper four bits of SINDEX, and A's -# contents are stomped on return. -# -initialize: - and SCSIID,0xf0,SINDEX # target ID - test SBLKCTL,0x08 jnz initialize_b - mvi SINDEX,SCSICONF_A - test FLAGS,WIDE_BUS jnz initialize_wide - and A,0x7,SCSICONF_A # SCSI_ID_A[210] - jmp initialize_2 -initialize_b: - and A,0x7,SCSICONF_B # SCSI_ID_B[210] - mvi SCSICONF_B jmp initialize_2 - -initialize_wide: - and A, 0xf,SCSICONF_B - -initialize_2: - or SCSIID,A - -# Esundry initialization. -# - clr DROPATN - clr SIGSTATE - -# Turn on Automatic PIO mode now, before we expect to see an REQ -# from the target. It shouldn't hurt anything to leave it on. Set -# CLRCHN here before the target has entered a data transfer mode - -# with synchronous SCSI, if you do it later, you blow away some -# data in the SCSI FIFO that the target has already sent to you. -# -# DFON is a 7870 bit enabling digital filtering of REQ and ACK signals. -# - mvi SXFRCTL0,0x8a # DFON|SPIOEN|CLRCHN - -# Set SCSI bus parity checking and the selection timeout value, -# and enable the hardware selection timer. Set the SELTO interrupt -# to signal the driver. -# -# STPWEN is 7870-specific, enabling an external termination power source. -# - and A,0x38,SINDIR # PARITY_ENB|SEL_TIM[10] - or SXFRCTL1,0x7,A # ENSTIMER|ACTNEGEN|STPWEN - mvi SIMODE1,0x84 # ENSELTIMO|ENSCSIPERR - -# Initialize scatter-gather pointers by setting up the working copy -# in scratch RAM. -# - call sg_scb2ram - -# Initialize SCSIRATE with the appropriate value for this target. -# - call ndx_sdtr - mov SCSIRATE,SINDIR - ret - -# Assert that if we've been reselected, then we've seen an IDENTIFY -# message. -# -assert: - test RESELECT,0x80 jz assert1 # reselected? - test RESELECT,0x40 jnz assert1 # seen IDENTIFY? - - mvi INTSTAT,SIGNAL_2 # no - cause a kernel panic - -assert1: - ret - -# Find out if disconnection is ok from the information the BIOS has left -# us. The tcl from SCBARRAY+1 should be in SINDEX; A will -# contain either 0x40 (disconnection ok) or 0x00 (disconnection not ok) -# on exit. -# -# To allow for wide or twin busses, we check the upper bit of the target ID -# and the channel ID and look at the appropriate disconnect register. -# -disconnect: - and FUNCTION1,0x70,SINDEX # strip off extra just in case - mov A,FUNCTION1 - test SINDEX, 0x88 jz disconnect_a - - test DISC_DSB_B,A jz disconnect1 # bit nonzero if DISabled - clr A ret - -disconnect_a: - test DISC_DSB_A,A jz disconnect1 # bit nonzero if DISabled - clr A ret - -disconnect1: - mvi A,0x40 ret - -# Locate the SCB matching the target ID in SELID and the lun in the lower -# three bits of SINDEX, and switch the SCB to it. Have the kernel print -# a warning message if it can't be found, and generate an ABORT message -# to the target. We keep the value of the t/c/l that we are trying to find -# in DINDEX so it is not overwritten during our check to see if we are -# at the last SCB. -# -findSCB: - and A,0x7,SINDEX # lun in lower three bits - or DINDEX,A,SELID - and DINDEX,0xf7 - and A,0x08,SBLKCTL # B Channel?? - or DINDEX,A - clr SINDEX - -findSCB1: - mov A,DINDEX - mov SCBPTR,SINDEX # switch to new SCB - cmp SCBARRAY+1,A jne findSCB2 # target ID/channel/lun match? - test SCBARRAY+0,0x4 jz findSCB2 # should be disconnected - ret - -findSCB2: - inc SINDEX - mov A,SCBCOUNT - cmp SINDEX,A jne findSCB1 - - mvi INTSTAT,SIGNAL_3 # not found - signal kernel - mvi 0x6 call mk_mesg # ABORT message - - or SINDEX,0x10,SIGSTATE # assert ATNO - call scsisig - ret - -# Make a working copy of the scatter-gather parameters in the SCB. -# -sg_scb2ram: - mov SG_COUNT,SCBARRAY+2 - - mvi A,4 - mvi DINDEX,SG_NEXT - mvi SCBARRAY+3 call bcopy - - mvi SG_NOLOAD,0x80 - test SCBARRAY+0,0x10 jnz sg_scb2ram1 # don't reload s/g? - clr SG_NOLOAD - -sg_scb2ram1: - ret - -# Copying RAM values back to SCB, for Save Data Pointers message. -# -sg_ram2scb: - mov SCBARRAY+2,SG_COUNT - - mvi A,4 - mvi DINDEX,SCBARRAY+3 - mvi SG_NEXT call bcopy - - and SCBARRAY+0,0xef,SCBARRAY+0 - test SG_NOLOAD,0x80 jz sg_ram2scb1 # reload s/g? - or SCBARRAY+0,0x10 - -sg_ram2scb1: - ret - -# Load a struct scatter if needed and set up the data address and -# length. If the working value of the SG count is nonzero, then -# we need to load a new set of values. -# -# This, like the above DMA, assumes a little-endian host data storage. -# -sg_load: - test SG_COUNT,0xff jz sg_load3 # SG being used? - test SG_NOLOAD,0x80 jnz sg_load3 # don't reload s/g? - - clr HCNT+2 - clr HCNT+1 - mvi HCNT+0,SG_SIZEOF - - mvi A,4 - mvi DINDEX,HADDR - mvi SG_NEXT call bcopy - - mvi DFCNTRL,0xd # HDMAEN|DIRECTION|FIFORESET - -# Wait for DMA from host memory to data FIFO to complete, then disable -# DMA and wait for it to acknowledge that it's off. -# -sg_load1: - test DFSTATUS,0x8 jz sg_load1 # HDONE - - clr DFCNTRL # disable DMA -sg_load2: - test DFCNTRL,0x8 jnz sg_load2 # HDMAENACK - -# Copy data from FIFO into SCB data pointer and data count. This assumes -# that the struct scatterlist has this structure (this and sizeof(struct -# scatterlist) == 12 are asserted in aic7xxx.c): -# -# struct scatterlist { -# char *address; /* four bytes, little-endian order */ -# ... /* four bytes, ignored */ -# unsigned short length; /* two bytes, little-endian order */ -# } -# - -# Not in FreeBSD. the scatter list is only 8 bytes. -# -# struct ahc_dma_seg { -# physaddr addr; /* four bytes, little-endian order */ -# long len; /* four bytes, little endian order */ -# }; -# - - mov SCBARRAY+19,DFDAT # new data address - mov SCBARRAY+20,DFDAT - mov SCBARRAY+21,DFDAT - mov SCBARRAY+22,DFDAT - - mov SCBARRAY+23,DFDAT - mov SCBARRAY+24,DFDAT - mov SCBARRAY+25,DFDAT - mov NONE,DFDAT #Only support 24 bit length. - -sg_load3: - ret - -# Advance the scatter-gather pointers only IF NEEDED. If SG is enabled, -# and the SCSI transfer count is zero (note that this should be called -# right after a DMA finishes), then move the working copies of the SG -# pointer/length along. If the SCSI transfer count is not zero, then -# presumably the target is disconnecting - do not reload the SG values -# next time. -# -sg_advance: - test SG_COUNT,0xff jz sg_advance2 # s/g enabled? - - test STCNT+0,0xff jnz sg_advance1 # SCSI transfer count nonzero? - test STCNT+1,0xff jnz sg_advance1 - test STCNT+2,0xff jnz sg_advance1 - - clr SG_NOLOAD # reload s/g next time - dec SG_COUNT # one less segment to go - - clr A # add sizeof(struct scatter) - add SG_NEXT+0,SG_SIZEOF,SG_NEXT+0 - adc SG_NEXT+1,A,SG_NEXT+1 - adc SG_NEXT+2,A,SG_NEXT+2 - adc SG_NEXT+3,A,SG_NEXT+3 - - ret - -sg_advance1: - mvi SG_NOLOAD,0x80 # don't reload s/g next time -sg_advance2: - ret - -# Add the array base SYNCNEG to the target offset (the target address -# is in SCSIID), and return the result in SINDEX. The accumulator -# contains the 3->8 decoding of the target ID on return. -# -ndx_sdtr: - shr A,SCSIID,4 - test SBLKCTL,0x08 jz ndx_sdtr_2 - or A,0x08 # Channel B entries add 8 -ndx_sdtr_2: - add SINDEX,SYNCNEG,A - - and FUNCTION1,0x70,SCSIID # 3-bit target address decode - mov A,FUNCTION1 ret - -# If we need to negotiate transfer parameters, build the SDTR message -# starting at the address passed in SINDEX. DINDEX is modified on return. -# -mk_sdtr: - mov DINDEX,SINDEX # save SINDEX - - call ndx_sdtr - test SCBARRAY+1,0x88 jz mk_sdtr1_a - test NEEDSDTR_B,A jnz mk_sdtr1 # do we need negotiation? - ret -mk_sdtr1_a: - test NEEDSDTR_A,A jnz mk_sdtr1 # do we need negotiation? - ret - -mk_sdtr1: - mvi DINDIR,1 # extended message - mvi DINDIR,3 # extended message length = 3 - mvi DINDIR,1 # SDTR code - mvi DINDIR,25 # REQ/ACK transfer period - mvi DINDIR,15 # REQ/ACK offset - - add MSG_LEN,-MSG_START+0,DINDEX # update message length - ret - -# Set SCSI bus control signal state. This also saves the last-written -# value into a location where the higher-level driver can read it - if -# it has to send an ABORT or RESET message, then it needs to know this -# so it can assert ATN without upsetting SCSISIGO. The new value is -# expected in SINDEX. Change the actual state last to avoid contention -# from the driver. -# -scsisig: - mov SIGSTATE,SINDEX - mov SCSISIGO,SINDEX ret diff --git a/sys/gnu/misc/aic7770/aic7770_seq.h b/sys/gnu/misc/aic7770/aic7770_seq.h deleted file mode 100644 index 24fa91b..0000000 --- a/sys/gnu/misc/aic7770/aic7770_seq.h +++ /dev/null @@ -1,351 +0,0 @@ -#define AIC7XXX_SEQ_VERSION "1.31" - 0x04, 0x03, 0x18, 0x1a, - 0x1f, 0x9c, 0x00, 0x1e, - 0xff, 0x9b, 0x90, 0x02, - 0x70, 0xa1, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x57, 0x08, 0x1e, - 0xff, 0x90, 0x9b, 0x02, - 0x00, 0x65, 0x00, 0x10, - 0x00, 0x57, 0x57, 0x00, - 0x00, 0xa1, 0xf1, 0x16, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x6a, 0x34, 0x02, - 0x00, 0xa1, 0x03, 0x17, - 0x07, 0xa1, 0x65, 0x02, - 0x00, 0x65, 0x65, 0x00, - 0x80, 0x65, 0xc2, 0x16, - 0xff, 0x65, 0x64, 0x02, - 0x00, 0x37, 0x13, 0x18, - 0x38, 0x6a, 0x51, 0x17, - 0x48, 0x6a, 0x00, 0x00, - 0x40, 0x0b, 0x1c, 0x1a, - 0x10, 0x0b, 0x14, 0x1e, - 0x40, 0x0b, 0x16, 0x1e, - 0x00, 0x65, 0x1c, 0x10, - 0x10, 0x6a, 0x00, 0x00, - 0x20, 0x0b, 0x19, 0x1e, - 0x00, 0x19, 0xf1, 0x16, - 0x80, 0x6a, 0x34, 0x00, - 0xff, 0x6a, 0x00, 0x02, - 0x08, 0x6a, 0x0c, 0x00, - 0x08, 0x0c, 0xbb, 0x1a, - 0x01, 0x0c, 0x1e, 0x1e, - 0xe0, 0x03, 0x64, 0x02, - 0x00, 0x6a, 0x28, 0x1c, - 0x40, 0x64, 0x3e, 0x1c, - 0x80, 0x64, 0x54, 0x1c, - 0xc0, 0x64, 0x61, 0x1c, - 0xa0, 0x64, 0x64, 0x1c, - 0xe0, 0x64, 0x7c, 0x1c, - 0x01, 0x6a, 0x91, 0x00, - 0x00, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0xff, 0x16, - 0x00, 0x65, 0x29, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xb3, 0x6a, 0xbe, 0x16, - 0x3d, 0x6a, 0xe6, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0xb7, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0xb3, 0x6a, 0x66, 0x00, - 0x14, 0x6a, 0xbe, 0x16, - 0x00, 0x65, 0x3e, 0x17, - 0xff, 0x51, 0xb2, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0xff, 0x16, - 0x00, 0x65, 0x29, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xb3, 0x6a, 0xbe, 0x16, - 0x39, 0x6a, 0xe6, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0xb7, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0xb3, 0x6a, 0x66, 0x00, - 0x14, 0x6a, 0xbe, 0x16, - 0x00, 0x65, 0x3e, 0x17, - 0xff, 0x51, 0xb2, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0x80, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0xff, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xab, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xab, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xa7, 0x6a, 0xbe, 0x16, - 0x3d, 0x6a, 0xe6, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0xc0, 0x6a, 0x5c, 0x17, - 0xae, 0x6a, 0xc9, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0xa0, 0x6a, 0x5c, 0x17, - 0x08, 0x6a, 0xc2, 0x16, - 0x37, 0x6a, 0x65, 0x00, - 0xff, 0x36, 0x66, 0x02, - 0xff, 0x6a, 0x64, 0x02, - 0x02, 0x0b, 0x69, 0x1e, - 0x10, 0x0c, 0x79, 0x1a, - 0x01, 0x66, 0x6d, 0x18, - 0x40, 0x6a, 0x0c, 0x00, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x6c, 0x06, 0x02, - 0x04, 0x0b, 0x6f, 0x1e, - 0xff, 0x66, 0x66, 0x06, - 0x01, 0x64, 0x64, 0x06, - 0x00, 0x36, 0x69, 0x18, - 0x08, 0x0c, 0x79, 0x1a, - 0x01, 0x0c, 0x73, 0x1e, - 0xe0, 0x03, 0x64, 0x02, - 0xa0, 0x64, 0x79, 0x18, - 0x10, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x35, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0xe0, 0x6a, 0x5c, 0x17, - 0x64, 0x6a, 0xcf, 0x16, - 0x00, 0x6a, 0x31, 0x00, - 0x00, 0x6a, 0x8a, 0x18, - 0x70, 0xa1, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x57, 0x57, 0x04, - 0xff, 0xae, 0x87, 0x1e, - 0x00, 0x65, 0xd7, 0x16, - 0x51, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0x1e, 0x10, - 0xff, 0x90, 0x9d, 0x02, - 0x02, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0xb9, 0x10, - 0x01, 0x64, 0x99, 0x18, - 0x64, 0x6a, 0xd1, 0x16, - 0x03, 0x64, 0xb5, 0x18, - 0x64, 0x6a, 0xd1, 0x16, - 0x01, 0x64, 0xb5, 0x18, - 0x4c, 0x6a, 0xd1, 0x16, - 0x4d, 0x6a, 0xd1, 0x16, - 0x41, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0x4c, 0x17, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x4c, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x04, - 0x00, 0x4f, 0x4f, 0x02, - 0xff, 0x4c, 0x04, 0x02, - 0x00, 0x65, 0xb9, 0x10, - 0x04, 0x64, 0x9c, 0x18, - 0x04, 0xa0, 0xa0, 0x00, - 0x00, 0x65, 0xb9, 0x10, - 0x02, 0x64, 0x9f, 0x18, - 0x00, 0x65, 0x21, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x03, 0x64, 0xa2, 0x18, - 0x00, 0x65, 0x19, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x80, 0x64, 0xaa, 0x1e, - 0x78, 0x64, 0xb5, 0x1a, - 0x00, 0x64, 0x08, 0x17, - 0x80, 0x35, 0xb9, 0x1a, - 0x04, 0xa0, 0xa0, 0x04, - 0xc0, 0x6a, 0x34, 0x00, - 0x00, 0x65, 0x19, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x07, 0x64, 0xb5, 0x18, - 0x70, 0x05, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x4f, 0xb9, 0x1e, - 0x00, 0x65, 0x4c, 0x17, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x6a, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x04, - 0x00, 0x4f, 0x4f, 0x02, - 0xff, 0x6a, 0x04, 0x02, - 0x00, 0x65, 0xb9, 0x10, - 0x10, 0x4e, 0x65, 0x00, - 0x00, 0x65, 0x5c, 0x17, - 0x11, 0x6a, 0x91, 0x00, - 0x07, 0x6a, 0xc2, 0x16, - 0x00, 0x65, 0xd7, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x4e, 0x02, - 0x00, 0x65, 0x00, 0x10, - 0xff, 0x6c, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x06, - 0x00, 0x6a, 0xbe, 0x18, - 0xff, 0x6a, 0x6a, 0x03, - 0x50, 0x6a, 0x60, 0x00, - 0x80, 0x35, 0xc7, 0x1a, - 0x80, 0x6a, 0x35, 0x00, - 0x01, 0x6a, 0x36, 0x00, - 0xff, 0x65, 0x37, 0x02, - 0x10, 0x6a, 0x60, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x02, 0x0b, 0xc9, 0x1e, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6d, 0x02, - 0x04, 0x0b, 0xcd, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x12, 0x6d, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6a, 0x02, - 0x04, 0x0b, 0xd4, 0x1e, - 0x02, 0x0b, 0xd5, 0x1e, - 0xff, 0x12, 0x6d, 0x03, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6a, 0x02, - 0x04, 0x0b, 0xd9, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0x02, 0x0b, 0xdb, 0x1e, - 0x00, 0x65, 0xe3, 0x16, - 0x80, 0x30, 0xe0, 0x1e, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x30, 0x02, - 0xff, 0x65, 0x06, 0x02, - 0x04, 0x0b, 0xe1, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x6a, 0x0a, 0x02, - 0xff, 0x6a, 0x09, 0x02, - 0x01, 0x6a, 0x08, 0x01, - 0xff, 0x65, 0x93, 0x02, - 0x01, 0x0b, 0xe9, 0x1a, - 0x10, 0x0c, 0xe7, 0x1e, - 0x04, 0x65, 0xeb, 0x1a, - 0x01, 0x94, 0xea, 0x1e, - 0xff, 0x6a, 0x93, 0x02, - 0x38, 0x93, 0xec, 0x1a, - 0x03, 0x6a, 0x64, 0x00, - 0xaf, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x6a, 0x1f, 0x02, - 0xf0, 0x65, 0x05, 0x02, - 0x07, 0x5a, 0x64, 0x02, - 0x00, 0x05, 0x05, 0x00, - 0xff, 0x6a, 0x30, 0x02, - 0xff, 0x6a, 0x4e, 0x02, - 0x8a, 0x6a, 0x01, 0x00, - 0x38, 0x5a, 0x64, 0x02, - 0x05, 0x64, 0x02, 0x00, - 0x84, 0x6a, 0x11, 0x00, - 0x00, 0x65, 0x19, 0x17, - 0x00, 0x65, 0x4c, 0x17, - 0xff, 0x6c, 0x04, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0x80, 0x34, 0x02, 0x1f, - 0x40, 0x34, 0x02, 0x1b, - 0x21, 0x6a, 0x91, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x70, 0x65, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x32, 0x07, 0x1f, - 0xff, 0x6a, 0x64, 0x03, - 0x40, 0x6a, 0x64, 0x01, - 0x07, 0x65, 0x64, 0x02, - 0x00, 0x19, 0x66, 0x00, - 0xf7, 0x66, 0x66, 0x02, - 0xff, 0x6a, 0x65, 0x02, - 0xff, 0x66, 0x64, 0x02, - 0xff, 0x65, 0x90, 0x02, - 0x00, 0xa1, 0x11, 0x19, - 0x04, 0xa0, 0x11, 0x1f, - 0xff, 0x6a, 0x6a, 0x03, - 0x01, 0x65, 0x65, 0x06, - 0xff, 0x56, 0x64, 0x02, - 0x00, 0x65, 0x0c, 0x19, - 0x31, 0x6a, 0x91, 0x00, - 0x06, 0x6a, 0xc2, 0x16, - 0x10, 0x4e, 0x65, 0x00, - 0x00, 0x65, 0x5c, 0x17, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0xa2, 0x51, 0x02, - 0x04, 0x6a, 0x64, 0x00, - 0x52, 0x6a, 0x66, 0x00, - 0xa3, 0x6a, 0xbe, 0x16, - 0x80, 0x6a, 0x50, 0x00, - 0x10, 0xa0, 0x20, 0x1b, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0xa2, 0x02, - 0x04, 0x6a, 0x64, 0x00, - 0xa3, 0x6a, 0x66, 0x00, - 0x52, 0x6a, 0xbe, 0x16, - 0xef, 0xa0, 0xa0, 0x02, - 0x80, 0x50, 0x28, 0x1f, - 0x10, 0xa0, 0xa0, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0x3d, 0x1f, - 0x80, 0x50, 0x3d, 0x1b, - 0xff, 0x6a, 0x8e, 0x02, - 0xff, 0x6a, 0x8d, 0x02, - 0x08, 0x6a, 0x8c, 0x00, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0x52, 0x6a, 0xbe, 0x16, - 0x0d, 0x6a, 0x93, 0x00, - 0x08, 0x94, 0x32, 0x1f, - 0xff, 0x6a, 0x93, 0x02, - 0x08, 0x93, 0x34, 0x1b, - 0xff, 0x99, 0xb3, 0x02, - 0xff, 0x99, 0xb4, 0x02, - 0xff, 0x99, 0xb5, 0x02, - 0xff, 0x99, 0xb6, 0x02, - 0xff, 0x99, 0xb7, 0x02, - 0xff, 0x99, 0xb8, 0x02, - 0xff, 0x99, 0xb9, 0x02, - 0xff, 0x99, 0x6a, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0x4b, 0x1f, - 0xff, 0x08, 0x4a, 0x1b, - 0xff, 0x09, 0x4a, 0x1b, - 0xff, 0x0a, 0x4a, 0x1b, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x51, 0x51, 0x06, - 0xff, 0x6a, 0x64, 0x02, - 0x08, 0x52, 0x52, 0x06, - 0x00, 0x53, 0x53, 0x08, - 0x00, 0x54, 0x54, 0x08, - 0x00, 0x55, 0x55, 0x08, - 0xff, 0x6a, 0x6a, 0x03, - 0x80, 0x6a, 0x50, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x4c, 0x05, 0x64, 0x0a, - 0x07, 0x64, 0x64, 0x02, - 0x20, 0x64, 0x65, 0x06, - 0x70, 0x05, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0x4c, 0x17, - 0x00, 0x4f, 0x55, 0x1b, - 0xff, 0x6a, 0x6a, 0x03, - 0x01, 0x6a, 0x6d, 0x00, - 0x03, 0x6a, 0x6d, 0x00, - 0x01, 0x6a, 0x6d, 0x00, - 0x19, 0x6a, 0x6d, 0x00, - 0x0f, 0x6a, 0x6d, 0x00, - 0xc9, 0x66, 0x36, 0x06, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x65, 0x4e, 0x02, - 0xff, 0x65, 0x03, 0x03, diff --git a/sys/gnu/misc/aic7xxx/COPYING b/sys/gnu/misc/aic7xxx/COPYING deleted file mode 100644 index a43ea21..0000000 --- a/sys/gnu/misc/aic7xxx/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/sys/gnu/misc/aic7xxx/COPYRIGHT b/sys/gnu/misc/aic7xxx/COPYRIGHT deleted file mode 100644 index 905285d..0000000 --- a/sys/gnu/misc/aic7xxx/COPYRIGHT +++ /dev/null @@ -1,16 +0,0 @@ -Adaptec 274x device driver for Linux. -Copyright (c) 1994 The University of Calgary Department of Computer Science. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/sys/gnu/misc/aic7xxx/README b/sys/gnu/misc/aic7xxx/README deleted file mode 100644 index 1e4e5a0..0000000 --- a/sys/gnu/misc/aic7xxx/README +++ /dev/null @@ -1,94 +0,0 @@ -@(#)README 1.16 94/11/09 jda - -AHA274x/284x DRIVER - -*** THIS SHOULD BE CONSIDERED BETA SOFTWARE *** - -BACKGROUND & LIMITATIONS - -For various reasons, we ended up with one of these cards under the -impression that support was soon forthcoming. In mid-May, I asked -Scott Ferris (the official person who's supposed to be writing this -driver) what documentation he used, _finally_ got it from Adaptec, -and started writing this driver. It is now at what I would consider -a stable state - it runs our news server and is battered by SCSI -requests 24 hours a day without dying. There are a few devices it -reportedly doesn't like working with - those are being sorted out. Due -to some unexpected equipment loans, I am able to support this at least -for the time being. - -YOU MUST HAVE THE BIOS ENABLED OR THIS WILL NOT WORK. The BIOS extracts -some configuration information that I cannot get to portably yet, as -well as provides some self-tests which this driver does not attempt to -duplicate. - -Scott's driver development is stalled for now, and after discussions -with him, this is now officially out of "pre-alpha" status and into -beta until the remaining device problems can be resolved. The latest -patches can be obtained via anonymous ftp from ftp.cpsc.ucalgary.ca in -/pub/systems/linux/aha274x. - -It supports both EISA 274x and VL-bus 284x, either single or twin-bus cards -(but not the second SCSI bus of twin cards - see aha274x.c), and supports -disconnection, synchronous SCSI, and scatter-gather. Unlike previous -versions, abort() and reset() are now implemented, and both hosts.c and -aha274x.c should give a clean compile. Code is now present to detect parity -errors, but has not been tested. - -I wrote this using a 1.0.9 kernel. Unfortunately, I'm getting tired of -#ifdef'ing everything to handle two or three different evolutionary steps -in the SCSI kernel code, so I've upgraded my system to 1.1.49, and will -only leave in code to support versions from about 1.1.45 onward. - -Thanks to patches supplied by Mark Olson <molson@tricord.com>, this driver -will now work with the 284x series (the VL-bus version of this card). The -294x (PCI-bus) support is based on patches sent to me by Mark Olson and -Alan Hourihane <alanh@fairlite.demon.co.uk>. - -Under protest, this driver is subject to the GPL - see the file -COPYING for details. - -Thanks to the following people for bug fixes/code improvements (also -thanks to the people who have sent me feedback): - - "David F. Carlson" <dave@ee.rochester.edu> - Jimen Ching <jiching@wiliki.eng.hawaii.edu> - mday@artisoft.com (Matt Day) - "Dean W. Gehnert" <deang@ims.com> - Darcy Grant <darcy@cpsc.ucalgary.ca> - Alan Hourihane <alanh@fairlite.demon.co.uk> - isely@fncrd8.fnal.gov (Mike Isely) - Mike Jerger <jerger@ux1.cso.uiuc.edu> - tm@netcom.com (Toshiyasu Morita) - neal@interact.org (Neal Norwitz) - Mark Olson <molson@tricord.com> - map@europa.ecn.uoknor.edu (Michael A. Parker) - Thomas Scheunemann <thomas@dagobert.uni-duisburg.de> - -Special thanks to Drew Eckhardt <drew@kinglear.cs.Colorado.EDU> for -fielding my questions about synchronous negotiation. Steffen Moeller -<smoe0024@rz.uni-hildesheim.de> sent me installation instructions which -were previously included in this README. - -David Pirie <pirie@cpsc.ucalgary.ca> was nice enough to loan me his -2842 card for a week so I could track down one bug, as well as his -CD-ROM drive later, and also thanks to Doug Fortune at Riley's Data Share -in Calgary, who arranged a long-term loan of a 2842 board for further work. - -Many thanks to the fearless prerelease testers! Dean Gehnert has been -building Slackware boot disks for the driver, which are available from -ftp.cpsc.ucalgary.ca in /pub/systems/linux/aha274x/slackware_boot. - -Carl Riches <cgr@poplar1.cfr.washington.edu> has set up a mailing list -for aic7xxx driver development. To subscribe, send a message to -aic7770-list@poplar1.cfr.washington.edu with a message body of: - - subscribe AIC7770-LIST <your name here, without the angle brackets> - -Please direct questions and discussions to that list instead of me. When -sending bug reports, please include a description of your hardware, the -release numbers displayed by the driver at boot time, and as accurate a -facsimilie of any error message you're mailing about. - -John Aycock -aycock@cpsc.ucalgary.ca diff --git a/sys/gnu/misc/aic7xxx/README-FIRST b/sys/gnu/misc/aic7xxx/README-FIRST deleted file mode 100644 index 056dbc8..0000000 --- a/sys/gnu/misc/aic7xxx/README-FIRST +++ /dev/null @@ -1,19 +0,0 @@ -This is VERY MUCH ALPHA SOFTWARE. You MUST know what you're doing to -use this, or else!!! - -Ok, everything's been renamed to reference an "aic7xxx" driver instead -of "aha274x", and a merger of the two PCI patches I had has been put in, -along with re-doing the detection and configuration routines. To summarize -the status: it compiles cleanly. I don't expect it to work off the bat, -but it's for the 294x development people to synchronize their code -together. - -The file scsi-diffs-1.1.59 is NOT a proper patch file, but some diffs -to kernel files concatenated together. I've sent these off to Drew, -but if you're testing this you'll have to apply them - it allows a -per-driver-instance can_queue variable, which for the aic7xxx driver -is the number of SCBs the card supports. - -Good luck! I await your comments.. Mark, Alan - let me know where I -broke it, please ;-) -:ja diff --git a/sys/gnu/misc/aic7xxx/aic7770_seq.h b/sys/gnu/misc/aic7xxx/aic7770_seq.h deleted file mode 100644 index 24fa91b..0000000 --- a/sys/gnu/misc/aic7xxx/aic7770_seq.h +++ /dev/null @@ -1,351 +0,0 @@ -#define AIC7XXX_SEQ_VERSION "1.31" - 0x04, 0x03, 0x18, 0x1a, - 0x1f, 0x9c, 0x00, 0x1e, - 0xff, 0x9b, 0x90, 0x02, - 0x70, 0xa1, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x57, 0x08, 0x1e, - 0xff, 0x90, 0x9b, 0x02, - 0x00, 0x65, 0x00, 0x10, - 0x00, 0x57, 0x57, 0x00, - 0x00, 0xa1, 0xf1, 0x16, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x6a, 0x34, 0x02, - 0x00, 0xa1, 0x03, 0x17, - 0x07, 0xa1, 0x65, 0x02, - 0x00, 0x65, 0x65, 0x00, - 0x80, 0x65, 0xc2, 0x16, - 0xff, 0x65, 0x64, 0x02, - 0x00, 0x37, 0x13, 0x18, - 0x38, 0x6a, 0x51, 0x17, - 0x48, 0x6a, 0x00, 0x00, - 0x40, 0x0b, 0x1c, 0x1a, - 0x10, 0x0b, 0x14, 0x1e, - 0x40, 0x0b, 0x16, 0x1e, - 0x00, 0x65, 0x1c, 0x10, - 0x10, 0x6a, 0x00, 0x00, - 0x20, 0x0b, 0x19, 0x1e, - 0x00, 0x19, 0xf1, 0x16, - 0x80, 0x6a, 0x34, 0x00, - 0xff, 0x6a, 0x00, 0x02, - 0x08, 0x6a, 0x0c, 0x00, - 0x08, 0x0c, 0xbb, 0x1a, - 0x01, 0x0c, 0x1e, 0x1e, - 0xe0, 0x03, 0x64, 0x02, - 0x00, 0x6a, 0x28, 0x1c, - 0x40, 0x64, 0x3e, 0x1c, - 0x80, 0x64, 0x54, 0x1c, - 0xc0, 0x64, 0x61, 0x1c, - 0xa0, 0x64, 0x64, 0x1c, - 0xe0, 0x64, 0x7c, 0x1c, - 0x01, 0x6a, 0x91, 0x00, - 0x00, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0xff, 0x16, - 0x00, 0x65, 0x29, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xb3, 0x6a, 0xbe, 0x16, - 0x3d, 0x6a, 0xe6, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0xb7, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0xb3, 0x6a, 0x66, 0x00, - 0x14, 0x6a, 0xbe, 0x16, - 0x00, 0x65, 0x3e, 0x17, - 0xff, 0x51, 0xb2, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0xff, 0x16, - 0x00, 0x65, 0x29, 0x17, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xb7, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xb3, 0x6a, 0xbe, 0x16, - 0x39, 0x6a, 0xe6, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0xb7, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0xb3, 0x6a, 0x66, 0x00, - 0x14, 0x6a, 0xbe, 0x16, - 0x00, 0x65, 0x3e, 0x17, - 0xff, 0x51, 0xb2, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0x80, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0xff, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x8c, 0x6a, 0x66, 0x00, - 0xab, 0x6a, 0xbe, 0x16, - 0x03, 0x6a, 0x64, 0x00, - 0x08, 0x6a, 0x66, 0x00, - 0xab, 0x6a, 0xbe, 0x16, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0xa7, 0x6a, 0xbe, 0x16, - 0x3d, 0x6a, 0xe6, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0xc0, 0x6a, 0x5c, 0x17, - 0xae, 0x6a, 0xc9, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0xa0, 0x6a, 0x5c, 0x17, - 0x08, 0x6a, 0xc2, 0x16, - 0x37, 0x6a, 0x65, 0x00, - 0xff, 0x36, 0x66, 0x02, - 0xff, 0x6a, 0x64, 0x02, - 0x02, 0x0b, 0x69, 0x1e, - 0x10, 0x0c, 0x79, 0x1a, - 0x01, 0x66, 0x6d, 0x18, - 0x40, 0x6a, 0x0c, 0x00, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x6c, 0x06, 0x02, - 0x04, 0x0b, 0x6f, 0x1e, - 0xff, 0x66, 0x66, 0x06, - 0x01, 0x64, 0x64, 0x06, - 0x00, 0x36, 0x69, 0x18, - 0x08, 0x0c, 0x79, 0x1a, - 0x01, 0x0c, 0x73, 0x1e, - 0xe0, 0x03, 0x64, 0x02, - 0xa0, 0x64, 0x79, 0x18, - 0x10, 0x6a, 0x5c, 0x17, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x35, 0x02, - 0x00, 0x65, 0x1e, 0x10, - 0xe0, 0x6a, 0x5c, 0x17, - 0x64, 0x6a, 0xcf, 0x16, - 0x00, 0x6a, 0x31, 0x00, - 0x00, 0x6a, 0x8a, 0x18, - 0x70, 0xa1, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x57, 0x57, 0x04, - 0xff, 0xae, 0x87, 0x1e, - 0x00, 0x65, 0xd7, 0x16, - 0x51, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0x1e, 0x10, - 0xff, 0x90, 0x9d, 0x02, - 0x02, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0xb9, 0x10, - 0x01, 0x64, 0x99, 0x18, - 0x64, 0x6a, 0xd1, 0x16, - 0x03, 0x64, 0xb5, 0x18, - 0x64, 0x6a, 0xd1, 0x16, - 0x01, 0x64, 0xb5, 0x18, - 0x4c, 0x6a, 0xd1, 0x16, - 0x4d, 0x6a, 0xd1, 0x16, - 0x41, 0x6a, 0x91, 0x00, - 0x00, 0x65, 0x4c, 0x17, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x4c, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x04, - 0x00, 0x4f, 0x4f, 0x02, - 0xff, 0x4c, 0x04, 0x02, - 0x00, 0x65, 0xb9, 0x10, - 0x04, 0x64, 0x9c, 0x18, - 0x04, 0xa0, 0xa0, 0x00, - 0x00, 0x65, 0xb9, 0x10, - 0x02, 0x64, 0x9f, 0x18, - 0x00, 0x65, 0x21, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x03, 0x64, 0xa2, 0x18, - 0x00, 0x65, 0x19, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x80, 0x64, 0xaa, 0x1e, - 0x78, 0x64, 0xb5, 0x1a, - 0x00, 0x64, 0x08, 0x17, - 0x80, 0x35, 0xb9, 0x1a, - 0x04, 0xa0, 0xa0, 0x04, - 0xc0, 0x6a, 0x34, 0x00, - 0x00, 0x65, 0x19, 0x17, - 0x00, 0x65, 0xb9, 0x10, - 0x07, 0x64, 0xb5, 0x18, - 0x70, 0x05, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x4f, 0xb9, 0x1e, - 0x00, 0x65, 0x4c, 0x17, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x6a, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x04, - 0x00, 0x4f, 0x4f, 0x02, - 0xff, 0x6a, 0x04, 0x02, - 0x00, 0x65, 0xb9, 0x10, - 0x10, 0x4e, 0x65, 0x00, - 0x00, 0x65, 0x5c, 0x17, - 0x11, 0x6a, 0x91, 0x00, - 0x07, 0x6a, 0xc2, 0x16, - 0x00, 0x65, 0xd7, 0x16, - 0x00, 0x65, 0x1e, 0x10, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x4e, 0x02, - 0x00, 0x65, 0x00, 0x10, - 0xff, 0x6c, 0x6d, 0x02, - 0xff, 0x64, 0x64, 0x06, - 0x00, 0x6a, 0xbe, 0x18, - 0xff, 0x6a, 0x6a, 0x03, - 0x50, 0x6a, 0x60, 0x00, - 0x80, 0x35, 0xc7, 0x1a, - 0x80, 0x6a, 0x35, 0x00, - 0x01, 0x6a, 0x36, 0x00, - 0xff, 0x65, 0x37, 0x02, - 0x10, 0x6a, 0x60, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x02, 0x0b, 0xc9, 0x1e, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6d, 0x02, - 0x04, 0x0b, 0xcd, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0xff, 0x12, 0x6d, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6a, 0x02, - 0x04, 0x0b, 0xd4, 0x1e, - 0x02, 0x0b, 0xd5, 0x1e, - 0xff, 0x12, 0x6d, 0x03, - 0x00, 0x65, 0xe3, 0x16, - 0xff, 0x06, 0x6a, 0x02, - 0x04, 0x0b, 0xd9, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0x02, 0x0b, 0xdb, 0x1e, - 0x00, 0x65, 0xe3, 0x16, - 0x80, 0x30, 0xe0, 0x1e, - 0x40, 0x6a, 0x0c, 0x00, - 0xff, 0x6a, 0x30, 0x02, - 0xff, 0x65, 0x06, 0x02, - 0x04, 0x0b, 0xe1, 0x1e, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x6a, 0x0a, 0x02, - 0xff, 0x6a, 0x09, 0x02, - 0x01, 0x6a, 0x08, 0x01, - 0xff, 0x65, 0x93, 0x02, - 0x01, 0x0b, 0xe9, 0x1a, - 0x10, 0x0c, 0xe7, 0x1e, - 0x04, 0x65, 0xeb, 0x1a, - 0x01, 0x94, 0xea, 0x1e, - 0xff, 0x6a, 0x93, 0x02, - 0x38, 0x93, 0xec, 0x1a, - 0x03, 0x6a, 0x64, 0x00, - 0xaf, 0x6a, 0x66, 0x00, - 0x08, 0x6a, 0xbe, 0x16, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x6a, 0x1f, 0x02, - 0xf0, 0x65, 0x05, 0x02, - 0x07, 0x5a, 0x64, 0x02, - 0x00, 0x05, 0x05, 0x00, - 0xff, 0x6a, 0x30, 0x02, - 0xff, 0x6a, 0x4e, 0x02, - 0x8a, 0x6a, 0x01, 0x00, - 0x38, 0x5a, 0x64, 0x02, - 0x05, 0x64, 0x02, 0x00, - 0x84, 0x6a, 0x11, 0x00, - 0x00, 0x65, 0x19, 0x17, - 0x00, 0x65, 0x4c, 0x17, - 0xff, 0x6c, 0x04, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0x80, 0x34, 0x02, 0x1f, - 0x40, 0x34, 0x02, 0x1b, - 0x21, 0x6a, 0x91, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x70, 0x65, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x02, - 0x00, 0x32, 0x07, 0x1f, - 0xff, 0x6a, 0x64, 0x03, - 0x40, 0x6a, 0x64, 0x01, - 0x07, 0x65, 0x64, 0x02, - 0x00, 0x19, 0x66, 0x00, - 0xf7, 0x66, 0x66, 0x02, - 0xff, 0x6a, 0x65, 0x02, - 0xff, 0x66, 0x64, 0x02, - 0xff, 0x65, 0x90, 0x02, - 0x00, 0xa1, 0x11, 0x19, - 0x04, 0xa0, 0x11, 0x1f, - 0xff, 0x6a, 0x6a, 0x03, - 0x01, 0x65, 0x65, 0x06, - 0xff, 0x56, 0x64, 0x02, - 0x00, 0x65, 0x0c, 0x19, - 0x31, 0x6a, 0x91, 0x00, - 0x06, 0x6a, 0xc2, 0x16, - 0x10, 0x4e, 0x65, 0x00, - 0x00, 0x65, 0x5c, 0x17, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0xa2, 0x51, 0x02, - 0x04, 0x6a, 0x64, 0x00, - 0x52, 0x6a, 0x66, 0x00, - 0xa3, 0x6a, 0xbe, 0x16, - 0x80, 0x6a, 0x50, 0x00, - 0x10, 0xa0, 0x20, 0x1b, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0xa2, 0x02, - 0x04, 0x6a, 0x64, 0x00, - 0xa3, 0x6a, 0x66, 0x00, - 0x52, 0x6a, 0xbe, 0x16, - 0xef, 0xa0, 0xa0, 0x02, - 0x80, 0x50, 0x28, 0x1f, - 0x10, 0xa0, 0xa0, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0x3d, 0x1f, - 0x80, 0x50, 0x3d, 0x1b, - 0xff, 0x6a, 0x8e, 0x02, - 0xff, 0x6a, 0x8d, 0x02, - 0x08, 0x6a, 0x8c, 0x00, - 0x04, 0x6a, 0x64, 0x00, - 0x88, 0x6a, 0x66, 0x00, - 0x52, 0x6a, 0xbe, 0x16, - 0x0d, 0x6a, 0x93, 0x00, - 0x08, 0x94, 0x32, 0x1f, - 0xff, 0x6a, 0x93, 0x02, - 0x08, 0x93, 0x34, 0x1b, - 0xff, 0x99, 0xb3, 0x02, - 0xff, 0x99, 0xb4, 0x02, - 0xff, 0x99, 0xb5, 0x02, - 0xff, 0x99, 0xb6, 0x02, - 0xff, 0x99, 0xb7, 0x02, - 0xff, 0x99, 0xb8, 0x02, - 0xff, 0x99, 0xb9, 0x02, - 0xff, 0x99, 0x6a, 0x02, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x51, 0x4b, 0x1f, - 0xff, 0x08, 0x4a, 0x1b, - 0xff, 0x09, 0x4a, 0x1b, - 0xff, 0x0a, 0x4a, 0x1b, - 0xff, 0x6a, 0x50, 0x02, - 0xff, 0x51, 0x51, 0x06, - 0xff, 0x6a, 0x64, 0x02, - 0x08, 0x52, 0x52, 0x06, - 0x00, 0x53, 0x53, 0x08, - 0x00, 0x54, 0x54, 0x08, - 0x00, 0x55, 0x55, 0x08, - 0xff, 0x6a, 0x6a, 0x03, - 0x80, 0x6a, 0x50, 0x00, - 0xff, 0x6a, 0x6a, 0x03, - 0x4c, 0x05, 0x64, 0x0a, - 0x07, 0x64, 0x64, 0x02, - 0x20, 0x64, 0x65, 0x06, - 0x70, 0x05, 0x6e, 0x02, - 0xff, 0x6e, 0x64, 0x03, - 0xff, 0x65, 0x66, 0x02, - 0x00, 0x65, 0x4c, 0x17, - 0x00, 0x4f, 0x55, 0x1b, - 0xff, 0x6a, 0x6a, 0x03, - 0x01, 0x6a, 0x6d, 0x00, - 0x03, 0x6a, 0x6d, 0x00, - 0x01, 0x6a, 0x6d, 0x00, - 0x19, 0x6a, 0x6d, 0x00, - 0x0f, 0x6a, 0x6d, 0x00, - 0xc9, 0x66, 0x36, 0x06, - 0xff, 0x6a, 0x6a, 0x03, - 0xff, 0x65, 0x4e, 0x02, - 0xff, 0x65, 0x03, 0x03, diff --git a/sys/gnu/misc/aic7xxx/aic7xxx.1 b/sys/gnu/misc/aic7xxx/aic7xxx.1 deleted file mode 100644 index 2ff33b7..0000000 --- a/sys/gnu/misc/aic7xxx/aic7xxx.1 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1994, 1995 -.\" Justin T. Gibbs. All rights reserved. -.\" -.\" 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. 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. -.\" -.\" -.Dd November 11, 1994 -.Dt AIC7XXX_ASM 1 -.Os BSD 4 -.Sh NAME -.Nm aic7xxx_asm -.Nd Assembler for the Adaptec aic7xxx family of asics -.Sh SYNOPSIS -.Nm aic7xxx_asm -.Op Fl d -.Op Fl D Ar variable=value -.Op Fl v -.Op Fl o Ar file -.Ar source-file -.Sh DESCRIPTION -The Adaptec aic7xxx family of asics are single chip SCSI controllers with a -RISC like command processor. This assembler parses the language outlined -in the Adaptec technical document -.%T "AIC-7770 (EISA/ISA Bus Master Single-Chip SCSI Host Adaptor) Data Book" -and produces ascii output intended for a C byte array. -.Pp -The aic7xxx assembler is required to compile kernels with aic7xxx SCSI -adaptor support (AHA-274x, AHA-284x, AHA-294x controllers) and is compiled, -installed, and used automatically in the kernel compile directory when -necessary. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl D Ar variable=value -Define -.Ar variable -to be -.Ar value -in the global context -.It Fl d -Turn on debugging -.It Fl v -Print version information -.It Fl o Ar file -Redirect assembler output to -.Ar file -.Pp -.Sh AUTHOR -This aic7770 assembler was written by -John Aycock (aycock@cpsc.ucalgary.ca) diff --git a/sys/gnu/misc/aic7xxx/aic7xxx.c b/sys/gnu/misc/aic7xxx/aic7xxx.c deleted file mode 100644 index 5f910d4..0000000 --- a/sys/gnu/misc/aic7xxx/aic7xxx.c +++ /dev/null @@ -1,643 +0,0 @@ -/*+M************************************************************************* - * Adaptec AIC7770/AIC7870 sequencer code assembler. - * - * Copyright (c) 1994 John Aycock - * The University of Calgary Department of Computer Science. - * All rights reserved. - * - * 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 Calgary - * Department of Computer Science 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 AUTHOR 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 AUTHOR 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. - * - * Comments are started by `#' and continue to the end of the line; lines - * may be of the form: - * <label>* - * <label>* <undef-sym> = <value> - * <label>* <opcode> <operand>* - * - * A <label> is an <undef-sym> ending in a colon. Spaces, tabs, and commas - * are token separators. - * - *-M*************************************************************************/ -static char id[] = "$Id$"; -#include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#define MEMORY 448 -#define MAXLINE 1024 -#define MAXTOKEN 32 -#define ADOTOUT "a.out" -#define NOVALUE -1 - -/* - * AIC-7770/AIC-7870 register definitions - */ -#define R_SINDEX 0x65 -#define R_ALLONES 0x69 -#define R_ALLZEROS 0x6a -#define R_NONE 0x6a - -int debug; -int lineno, LC; -char *filename; -FILE *ifp, *ofp; -unsigned char M[MEMORY][4]; - -void -error(char *s) -{ - fprintf(stderr, "%s: %s at line %d\n", filename, s, lineno); - exit(EXIT_FAILURE); -} - -void * -Malloc(size_t size) -{ - void *p = malloc(size); - if (!p) - error("out of memory"); - return(p); -} - -void * -Realloc(void *ptr, size_t size) -{ - void *p = realloc(ptr, size); - if (!p) - error("out of memory"); - return(p); -} - -char * -Strdup(char *s) -{ - char *p = (char *)Malloc(strlen(s) + 1); - strcpy(p, s); - return(p); -} - -typedef struct sym_t { - struct sym_t *next; /* MUST BE FIRST */ - char *name; - int value; - int npatch; - int *patch; -} sym_t; - -sym_t *head; - -void -define(char *name, int value) -{ - sym_t *p, *q; - - for (p = head, q = (sym_t *)&head; p; p = p->next) { - if (!strcmp(p->name, name)) - error("redefined symbol"); - q = p; - } - - p = q->next = (sym_t *)Malloc(sizeof(sym_t)); - p->next = NULL; - p->name = Strdup(name); - p->value = value; - p->npatch = 0; - p->patch = NULL; - - if (debug) { - fprintf(stderr, "\"%s\" ", p->name); - if (p->value != NOVALUE) - fprintf(stderr, "defined as 0x%x\n", p->value); - else - fprintf(stderr, "undefined\n"); - } -} - -sym_t * -lookup(char *name) -{ - sym_t *p; - - for (p = head; p; p = p->next) - if (!strcmp(p->name, name)) - return(p); - return(NULL); -} - -void -patch(sym_t *p, int location) -{ - p->npatch += 1; - p->patch = (int *)Realloc(p->patch, p->npatch * sizeof(int *)); - - p->patch[p->npatch - 1] = location; -} - -void backpatch(void) -{ - int i; - sym_t *p; - - for (p = head; p; p = p->next) { - - if (p->value == NOVALUE) { - fprintf(stderr, - "%s: undefined symbol \"%s\"\n", - filename, p->name); - exit(EXIT_FAILURE); - } - - if (p->npatch) { - if (debug) - fprintf(stderr, - "\"%s\" (0x%x) patched at", - p->name, p->value); - - for (i = 0; i < p->npatch; i++) { - M[p->patch[i]][0] &= ~1; - M[p->patch[i]][0] |= ((p->value >> 8) & 1); - M[p->patch[i]][1] = p->value & 0xff; - - if (debug) - fprintf(stderr, " 0x%x", p->patch[i]); - } - - if (debug) - fputc('\n', stderr); - } - } -} - -/* - * Output words in byte-reversed order (least significant first) - * since the sequencer RAM is loaded that way. - */ -void -output(FILE *fp) -{ - int i; - - for (i = 0; i < LC; i++) - fprintf(fp, "\t0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", - M[i][3], - M[i][2], - M[i][1], - M[i][0]); - printf("%d out of %d instructions used.\n", LC, MEMORY); -} - -char ** -getl(int *n) -{ - int i; - char *p, *quote; - static char buf[MAXLINE]; - static char *a[MAXTOKEN]; - - i = 0; - - while (fgets(buf, sizeof(buf), ifp)) { - - lineno += 1; - - if (buf[strlen(buf)-1] != '\n') - error("line too long"); - - p = strchr(buf, '#'); - if (p) - *p = '\0'; - p = buf; -rescan: - quote = strchr(p, '\"'); - if (quote) - *quote = '\0'; - for (p = strtok(p, ", \t\n"); p; p = strtok(NULL, ", \t\n")) - if (i < MAXTOKEN-1) - a[i++] = p; - else - error("too many tokens"); - if (quote) { - quote++; - p = strchr(quote, '\"'); - if (!p) - error("unterminated string constant"); - else if (i < MAXTOKEN-1) { - a[i++] = quote; - *p = '\0'; - p++; - } - else - error("too many tokens"); - goto rescan; - } - if (i) { - *n = i; - return(a); - } - } - return(NULL); -} - -#define A 0x8000 /* `A'ccumulator ok */ -#define I 0x4000 /* use as immediate value */ -#define SL 0x2000 /* shift left */ -#define SR 0x1000 /* shift right */ -#define RL 0x0800 /* rotate left */ -#define RR 0x0400 /* rotate right */ -#define LO 0x8000 /* lookup: ori-{jmp,jc,jnc,call} */ -#define LA 0x4000 /* lookup: and-{jz,jnz} */ -#define LX 0x2000 /* lookup: xor-{je,jne} */ -#define NA -1 /* not applicable */ - -struct { - char *name; - int n; /* number of operands, including opcode */ - unsigned int op; /* immediate or L?|pos_from_0 */ - unsigned int dest; /* NA, pos_from_0, or I|immediate */ - unsigned int src; /* NA, pos_from_0, or I|immediate */ - unsigned int imm; /* pos_from_0, A|pos_from_0, or I|immediate */ - unsigned int addr; /* NA or pos_from_0 */ - int fmt; /* instruction format - 1, 2, or 3 */ -} instr[] = { -/* - * N OP DEST SRC IMM ADDR FMT - */ - { "mov", 3, 1, 1, 2, I|0xff, NA, 1 }, - { "mov", 4, LO|2, NA, 1, I|0, 3, 3 }, - { "mvi", 3, 0, 1, I|R_ALLZEROS, A|2, NA, 1 }, - { "mvi", 4, LO|2, NA, I|R_ALLZEROS, 1, 3, 3 }, - { "not", 2, 2, 1, 1, I|0xff, NA, 1 }, - { "and", 3, 1, 1, 1, A|2, NA, 1 }, - { "and", 4, 1, 1, 3, A|2, NA, 1 }, - { "or", 3, 0, 1, 1, A|2, NA, 1 }, - { "or", 4, 0, 1, 3, A|2, NA, 1 }, - { "or", 5, LO|3, NA, 1, 2, 4, 3 }, - { "xor", 3, 2, 1, 1, A|2, NA, 1 }, - { "xor", 4, 2, 1, 3, A|2, NA, 1 }, - { "nop", 1, 1, I|R_NONE, I|R_ALLZEROS, I|0xff, NA, 1 }, - { "inc", 2, 3, 1, 1, I|1, NA, 1 }, - { "inc", 3, 3, 1, 2, I|1, NA, 1 }, - { "dec", 2, 3, 1, 1, I|0xff, NA, 1 }, - { "dec", 3, 3, 1, 2, I|0xff, NA, 1 }, - { "jmp", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3 }, - { "jc", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3 }, - { "jnc", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3 }, - { "call", 2, LO|0, NA, I|R_SINDEX, I|0, 1, 3 }, - { "test", 5, LA|3, NA, 1, A|2, 4, 3 }, - { "cmp", 5, LX|3, NA, 1, A|2, 4, 3 }, - { "ret", 1, 1, I|R_NONE, I|R_ALLZEROS, I|0xff, NA, 1 }, - { "ret", 1, 1, I|R_NONE, I|R_ALLZEROS, I|0xff, NA, 1 }, - { "clc", 1, 3, I|R_NONE, I|R_ALLZEROS, I|1, NA, 1 }, - { "clc", 4, 3, 2, I|R_ALLZEROS, A|3, NA, 1 }, - { "stc", 2, 3, 1, I|R_ALLONES, I|1, NA, 1 }, - { "add", 3, 3, 1, 1, A|2, NA, 1 }, - { "add", 4, 3, 1, 3, A|2, NA, 1 }, - { "adc", 3, 4, 1, 1, A|2, NA, 1 }, - { "adc", 4, 4, 1, 3, A|2, NA, 1 }, - { "shl", 3, 5, 1, 1, SL|2, NA, 2 }, - { "shl", 4, 5, 1, 2, SL|3, NA, 2 }, - { "shr", 3, 5, 1, 1, SR|2, NA, 2 }, - { "shr", 4, 5, 1, 2, SR|3, NA, 2 }, - { "rol", 3, 5, 1, 1, RL|2, NA, 2 }, - { "rol", 4, 5, 1, 2, RL|3, NA, 2 }, - { "ror", 3, 5, 1, 1, RR|2, NA, 2 }, - { "ror", 4, 5, 1, 2, RR|3, NA, 2 }, - /* - * Extensions (note also that mvi allows A) - */ - { "clr", 2, 1, 1, I|R_ALLZEROS, I|0xff, NA, 1 }, - { 0, 0, 0, 0, 0, 0, 0, 0 } -}; - -int -eval_operand(char **a, int spec) -{ - int i; - unsigned int want = spec & (LO|LA|LX); - - static struct { - unsigned int what; - char *name; - int value; - } jmptab[] = { - { LO, "jmp", 8 }, - { LO, "jc", 9 }, - { LO, "jnc", 10 }, - { LO, "call", 11 }, - { LA, "jz", 15 }, - { LA, "jnz", 13 }, - { LX, "je", 14 }, - { LX, "jne", 12 }, - }; - - spec &= ~(LO|LA|LX); - - for (i = 0; i < sizeof(jmptab)/sizeof(jmptab[0]); i++) - if (jmptab[i].what == want && - !strcmp(jmptab[i].name, a[spec])) - { - return(jmptab[i].value); - } - - if (want) - error("invalid jump"); - - return(spec); /* "case 0" - no flags set */ -} - -int -eval_sdi(char **a, int spec) -{ - sym_t *p; - unsigned val; - - if (spec == NA) - return(NA); - - switch (spec & (A|I|SL|SR|RL|RR)) { - case SL: - case SR: - case RL: - case RR: - if (isdigit(*a[spec &~ (SL|SR|RL|RR)])) - val = strtol(a[spec &~ (SL|SR|RL|RR)], NULL, 0); - else { - p = lookup(a[spec &~ (SL|SR|RL|RR)]); - if (!p) - error("undefined symbol used"); - val = p->value; - } - - switch (spec & (SL|SR|RL|RR)) { /* blech */ - case SL: - if (val > 7) - return(0xf0); - return(((val % 8) << 4) | - (val % 8)); - case SR: - if (val > 7) - return(0xf0); - return(((val % 8) << 4) | - (1 << 3) | - ((8 - (val % 8)) % 8)); - case RL: - return(val % 8); - case RR: - return((8 - (val % 8)) % 8); - } - case I: - return(spec &~ I); - case A: - /* - * An immediate field of zero selects - * the accumulator. Vigorously object - * if zero is given otherwise - it's - * most likely an error. - */ - spec &= ~A; - if (!strcmp("A", a[spec])) - return(0); - if (isdigit(*a[spec]) && - strtol(a[spec], NULL, 0) == 0) - { - error("immediate value of zero selects accumulator"); - } - /* falls through */ - case 0: - if (isdigit(*a[spec])) - return(strtol(a[spec], NULL, 0)); - p = lookup(a[spec]); - if (p) - return(p->value); - error("undefined symbol used"); - } - - return(NA); /* shut the compiler up */ -} - -int -eval_addr(char **a, int spec) -{ - sym_t *p; - - if (spec == NA) - return(NA); - if (isdigit(*a[spec])) - return(strtol(a[spec], NULL, 0)); - - p = lookup(a[spec]); - - if (p) { - if (p->value != NOVALUE) - return(p->value); - patch(p, LC); - } else { - define(a[spec], NOVALUE); - p = lookup(a[spec]); - patch(p, LC); - } - - return(NA); /* will be patched in later */ -} - -int -crack(char **a, int n) -{ - int i; - int I_imm, I_addr; - int I_op, I_dest, I_src, I_ret; - - /* - * Check for "ret" at the end of the line; remove - * it unless it's "ret" alone - we still want to - * look it up in the table. - */ - I_ret = (strcmp(a[n-1], "ret") ? 0 : !0); - if (I_ret && n > 1) - n -= 1; - - for (i = 0; instr[i].name; i++) { - /* - * Look for match in table given constraints, - * currently just the name and the number of - * operands. - */ - if (!strcmp(instr[i].name, *a) && instr[i].n == n) - break; - } - if (!instr[i].name) - error("unknown opcode or wrong number of operands"); - - I_op = eval_operand(a, instr[i].op); - I_src = eval_sdi(a, instr[i].src); - I_imm = eval_sdi(a, instr[i].imm); - I_dest = eval_sdi(a, instr[i].dest); - I_addr = eval_addr(a, instr[i].addr); - - if( LC >= MEMORY ) - error("Memory exhausted!\n"); - - switch (instr[i].fmt) { - case 1: - case 2: - M[LC][0] = (I_op << 1) | I_ret; - M[LC][1] = I_dest; - M[LC][2] = I_src; - M[LC][3] = I_imm; - break; - case 3: - if (I_ret) - error("illegal use of \"ret\""); - M[LC][0] = (I_op << 1) | ((I_addr >> 8) & 1); - M[LC][1] = I_addr & 0xff; - M[LC][2] = I_src; - M[LC][3] = I_imm; - break; - } - - return (1); /* no two-byte instructions yet */ -} - -#undef SL -#undef SR -#undef RL -#undef RR -#undef LX -#undef LA -#undef LO -#undef I -#undef A - -void -assemble(void) -{ - int n; - char **a; - sym_t *p; - - while ((a = getl(&n))) { - - while (a[0][strlen(*a)-1] == ':') { - a[0][strlen(*a)-1] = '\0'; - p = lookup(*a); - if (p) - p->value = LC; - else - define(*a, LC); - a += 1; - n -= 1; - } - - if (!n) /* line was all labels */ - continue; - - if (n == 3 && !strcmp("VERSION", *a)) - fprintf(ofp, "#define %s \"%s\"\n", a[1], a[2]); - else { - if (n == 3 && !strcmp("=", a[1])) - define(*a, strtol(a[2], NULL, 0)); - else - LC += crack(a, n); - } - } - - backpatch(); - output(ofp); - - if (debug) - output(stderr); -} - -int -main(int argc, char **argv) -{ - int c; - - while ((c = getopt(argc, argv, "dho:vD")) != EOF) { - switch (c) { - case 'd': - debug = !0; - break; - case 'D': - { - char *p; - if ((p = strchr(optarg, '=')) != NULL) { - *p = '\0'; - define(optarg, strtol(p + 1, NULL, 0)); - } - else - define(optarg, 1); - break; - } - case 'o': - ofp = fopen(optarg, "w"); - if (!ofp) { - perror(optarg); - exit(EXIT_FAILURE); - } - break; - case 'h': - printf("usage: %s [-d] [-Dname] [-ooutput] input\n", - *argv); - exit(EXIT_SUCCESS); - break; - case 'v': - printf("%s\n", id); - exit(EXIT_SUCCESS); - break; - default: - exit(EXIT_FAILURE); - break; - } - } - - if (argc - optind != 1) { - fprintf(stderr, "%s: must have one input file\n", *argv); - exit(EXIT_FAILURE); - } - filename = argv[optind]; - - ifp = fopen(filename, "r"); - if (!ifp) { - perror(filename); - exit(EXIT_FAILURE); - } - - if (!ofp) { - ofp = fopen(ADOTOUT, "w"); - if (!ofp) { - perror(ADOTOUT); - exit(EXIT_FAILURE); - } - } - - assemble(); - exit(EXIT_SUCCESS); -} diff --git a/sys/gnu/misc/aic7xxx/aic7xxx.seq b/sys/gnu/misc/aic7xxx/aic7xxx.seq deleted file mode 100644 index 435da74..0000000 --- a/sys/gnu/misc/aic7xxx/aic7xxx.seq +++ /dev/null @@ -1,1253 +0,0 @@ -##+M######################################################################### -# Adaptec 274x/284x/294x device driver for Linux and FreeBSD. -# -# Copyright (c) 1994 John Aycock -# The University of Calgary Department of Computer Science. -# All rights reserved. -# -# Modifications/enhancements: -# Copyright (c) 1994, 1995 Justin Gibbs. All rights reserved. -# -# 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 Calgary -# Department of Computer Science 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 AUTHOR 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 AUTHOR 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. -# -# FreeBSD, Twin, Wide, 2 command per target support, tagged queuing and other -# optimizations provided by Justin T. Gibbs (gibbs@FreeBSD.org) -# -##-M######################################################################### - -VERSION AIC7XXX_SEQ_VER "$Id: aic7xxx.seq,v 1.13 1995/04/09 06:40:16 gibbs Exp $" - -SCBMASK = 0x1f - -SCSISEQ = 0x00 -SXFRCTL0 = 0x01 -SXFRCTL1 = 0x02 -SCSISIGI = 0x03 -SCSISIGO = 0x03 -SCSIRATE = 0x04 -SCSIID = 0x05 -SCSIDATL = 0x06 -STCNT = 0x08 -STCNT+0 = 0x08 -STCNT+1 = 0x09 -STCNT+2 = 0x0a -SSTAT0 = 0x0b -CLRSINT1 = 0x0c -SSTAT1 = 0x0c -SIMODE1 = 0x11 -SCSIBUSL = 0x12 -SHADDR = 0x14 -SELID = 0x19 -SBLKCTL = 0x1f -SEQCTL = 0x60 -A = 0x64 # == ACCUM -SINDEX = 0x65 -DINDEX = 0x66 -ALLZEROS = 0x6a -NONE = 0x6a -SINDIR = 0x6c -DINDIR = 0x6d -FUNCTION1 = 0x6e -HADDR = 0x88 -HADDR+1 = 0x89 -HADDR+2 = 0x8a -HADDR+3 = 0x8b -HCNT = 0x8c -HCNT+0 = 0x8c -HCNT+1 = 0x8d -HCNT+2 = 0x8e -SCBPTR = 0x90 -INTSTAT = 0x91 -DFCNTRL = 0x93 -DFSTATUS = 0x94 -DFDAT = 0x99 -QINFIFO = 0x9b -QINCNT = 0x9c -QOUTFIFO = 0x9d - -SCSICONF_A = 0x5a -SCSICONF_B = 0x5b - -# The two reserved bytes at SCBARRAY+1[23] are expected to be set to -# zero, and the reserved bit in SCBARRAY+0 is used as an internal flag -# to indicate whether or not to reload scatter-gather parameters after -# a disconnect. We also use bits 6 & 7 to indicate whether or not to -# initiate SDTR or WDTR repectively when starting this command. -# -SCBARRAY+0 = 0xa0 - -DISCONNECTED = 0x04 -NEEDDMA = 0x08 -SG_LOAD = 0x10 -TAG_ENB = 0x20 -NEEDSDTR = 0x40 -NEEDWDTR = 0x80 - -SCBARRAY+1 = 0xa1 -SCBARRAY+2 = 0xa2 -SCBARRAY+3 = 0xa3 -SCBARRAY+4 = 0xa4 -SCBARRAY+5 = 0xa5 -SCBARRAY+6 = 0xa6 -SCBARRAY+7 = 0xa7 -SCBARRAY+8 = 0xa8 -SCBARRAY+9 = 0xa9 -SCBARRAY+10 = 0xaa -SCBARRAY+11 = 0xab -SCBARRAY+12 = 0xac -SCBARRAY+13 = 0xad -SCBARRAY+14 = 0xae -SCBARRAY+15 = 0xaf -SCBARRAY+16 = 0xb0 -SCBARRAY+17 = 0xb1 -SCBARRAY+18 = 0xb2 -SCBARRAY+19 = 0xb3 -SCBARRAY+20 = 0xb4 -SCBARRAY+21 = 0xb5 -SCBARRAY+22 = 0xb6 -SCBARRAY+23 = 0xb7 -SCBARRAY+24 = 0xb8 -SCBARRAY+25 = 0xb9 -SCBARRAY+26 = 0xba -SCBARRAY+27 = 0xbb -SCBARRAY+28 = 0xbc -SCBARRAY+29 = 0xbd - -BAD_PHASE = 0x01 # unknown scsi bus phase -CMDCMPLT = 0x02 -SEND_REJECT = 0x11 # sending a message reject -NO_IDENT = 0x21 # no IDENTIFY after reconnect -NO_MATCH = 0x31 # no cmd match for reconnect -MSG_SDTR = 0x41 # SDTR message recieved -MSG_WDTR = 0x51 # WDTR message recieved -MSG_REJECT = 0x61 # Reject message recieved -BAD_STATUS = 0x71 # Bad status from target -RESIDUAL = 0x81 # Residual byte count != 0 -ABORT_TAG = 0x91 # Sent an ABORT_TAG message - -# The host adapter card (at least the BIOS) uses 20-2f for SCSI -# device information, 32-33 and 5a-5f as well. As it turns out, the -# BIOS trashes 20-2f, writing the synchronous negotiation results -# on top of the BIOS values, so we re-use those for our per-target -# scratchspace (actually a value that can be copied directly into -# SCSIRATE). The kernel driver will enable synchronous negotiation -# for all targets that have a value other than 0 in the lower four -# bits of the target scratch space. This should work irregardless of -# whether the bios has been installed. NEEDWDTR and NEEDSDTR are the top -# two bits of the SCB control byte. The kernel driver will set these -# when a WDTR or SDTR message should be sent to the target the SCB's -# command references. -# -# The high bit of DROPATN is set if ATN should be dropped before the ACK -# when outb is called. REJBYTE contains the first byte of a MESSAGE IN -# message, so the driver can report an intelligible error if a message is -# rejected. -# -# FLAGS's high bit is true if we are currently handling a reselect; -# its next-highest bit is true ONLY IF we've seen an IDENTIFY message -# from the reselecting target. If we haven't had IDENTIFY, then we have -# no idea what the lun is, and we can't select the right SCB register -# bank, so force a kernel panic if the target attempts a data in/out or -# command phase instead of corrupting something. -# -# Note that SG_NEXT occupies four bytes. -# -SYNCNEG = 0x20 - -DROPATN = 0x30 -REJBYTE = 0x31 -DISC_DSB_A = 0x32 -DISC_DSB_B = 0x33 - -MSG_LEN = 0x34 -MSG_START+0 = 0x35 -MSG_START+1 = 0x36 -MSG_START+2 = 0x37 -MSG_START+3 = 0x38 -MSG_START+4 = 0x39 -MSG_START+5 = 0x3a --MSG_START+0 = 0xcb # 2's complement of MSG_START+0 - -ARG_1 = 0x4a # sdtr conversion args & return -BUS_16_BIT = 0x01 -RETURN_1 = 0x4a - -SIGSTATE = 0x4b # value written to SCSISIGO - -# Linux users should use 0xc (12) for SG_SIZEOF -SG_SIZEOF = 0x8 # sizeof(struct ahc_dma) -#SG_SIZEOF = 0xc # sizeof(struct scatterlist) -SCB_SIZEOF = 0x13 # sizeof SCB to DMA (19 bytes) - -SG_NOLOAD = 0x4c # load SG pointer/length? -SG_COUNT = 0x4d # working value of SG count -SG_NEXT = 0x4e # working value of SG pointer -SG_NEXT+0 = 0x4e -SG_NEXT+1 = 0x4f -SG_NEXT+2 = 0x50 -SG_NEXT+3 = 0x51 - -SCBCOUNT = 0x52 # the actual number of SCBs -FLAGS = 0x53 # Device configuration flags -TWIN_BUS = 0x01 -WIDE_BUS = 0x02 -MAX_SYNC = 0x08 -SENSE = 0x10 -ACTIVE_MSG = 0x20 -IDENTIFY_SEEN = 0x40 -RESELECTED = 0x80 - -ACTIVE_A = 0x54 -ACTIVE_B = 0x55 -SAVED_TCL = 0x56 -# Poll QINCNT for work - the lower bits contain -# the number of entries in the Queue In FIFO. -# -start: - test FLAGS,SENSE jnz start_sense -start_nosense: - test FLAGS,TWIN_BUS jz start2 # Are we a twin channel device? -# For fairness, we check the other bus first, since we just finished a -# transaction on the current channel. - xor SBLKCTL,0x08 # Toggle to the other bus - test SCSISIGI,0x4 jnz reselect # BSYI - xor SBLKCTL,0x08 # Toggle to the original bus -start2: - test SCSISIGI,0x4 jnz reselect # BSYI - test QINCNT,SCBMASK jz start_nosense - -# We have at least one queued SCB now. Set the SCB pointer -# from the FIFO so we see the right bank of SCB registers, -# then set SCSI options and set the initiator and target -# SCSI IDs. -# - mov SCBPTR,QINFIFO - -# If the control byte of this SCB has the NEEDDMA flag set, we have -# yet to DMA it from host memory - -test SCBARRAY+0,NEEDDMA jz test_busy - clr HCNT+2 - clr HCNT+1 - mvi HCNT+0,SCB_SIZEOF - - mvi DINDEX,HADDR - mvi SCBARRAY+26 call bcopy_4 - - mvi DFCNTRL,0xd # HDMAEN|DIRECTION|FIFORESET - -# Wait for DMA from host memory to data FIFO to complete, then disable -# DMA and wait for it to acknowledge that it's off. -# - call dma_finish - -# Copy the SCB from the FIFO to the SCBARRAY - - mvi DINDEX, SCBARRAY+0 - call bcopy_3_dfdat - call bcopy_4_dfdat - call bcopy_4_dfdat - call bcopy_4_dfdat - call bcopy_4_dfdat - -# See if there is not already an active SCB for this target. This code -# locks out on a per target basis instead of target/lun. Although this -# is not ideal for devices that have multiple luns active at the same -# time, it is faster than looping through all SCB's looking for active -# commands. It may be benificial to make findscb a more general procedure -# to see if the added cost of the search is negligible. This code also -# assumes that the kernel driver will clear the active flags on board -# initialization, board reset, and a target's SELTO. - -test_busy: - test SCBARRAY+0,0x20 jnz start_scb - and FUNCTION1,0x70,SCBARRAY+1 - mov A,FUNCTION1 - test SCBARRAY+1,0x88 jz test_a # Id < 8 && A channel - - test ACTIVE_B,A jnz requeue - or ACTIVE_B,A # Mark the current target as busy - jmp start_scb - -start_sense: -# Clear the SENSE flag first, then do a normal start_scb - and FLAGS,0xef - jmp start_scb - -# Place the currently active back on the queue for later processing -requeue: - mov QINFIFO, SCBPTR - jmp start_nosense - -test_a: - test ACTIVE_A,A jnz requeue - or ACTIVE_A,A # Mark the current target as busy - -start_scb: - or SCBARRAY+0,NEEDDMA - and SINDEX,0xf7,SBLKCTL #Clear the channel select bit - and A,0x08,SCBARRAY+1 #Get new channel bit - or SINDEX,A - mov SBLKCTL,SINDEX # select channel - mov SCBARRAY+1 call initialize - clr SG_NOLOAD - and FLAGS,0x3f # !RESELECTING - -# As soon as we get a successful selection, the target should go -# into the message out phase since we have ATN asserted. Prepare -# the message to send, locking out the device driver. If the device -# driver hasn't beaten us with an ABORT or RESET message, then tack -# on an SDTR negotiation if required. -# -# Messages are stored in scratch RAM starting with a flag byte (high bit -# set means active message), one length byte, and then the message itself. -# - mov SCBARRAY+1 call disconnect # disconnect ok? - - and SINDEX,0x7,SCBARRAY+1 # lun - or SINDEX,A # return value from disconnect - or SINDEX,0x80 call mk_mesg # IDENTIFY message - - mov A,SINDEX - test SCBARRAY+0,0xe0 jz !message # WDTR, SDTR or TAG?? - cmp MSG_START+0,A jne !message # did driver beat us? - -# Tag Message if Tag enabled in SCB control block. Use SCBPTR as the tag -# value - -mk_tag: - mvi DINDEX, MSG_START+1 - test SCBARRAY+0,TAG_ENB jz mk_tag_done - and A,0x23,SCBARRAY+0 - mov DINDIR,A - mov DINDIR,SCBPTR - - add MSG_LEN,-MSG_START+0,DINDEX # update message length - -mk_tag_done: - - mov DINDEX call mk_dtr # build DTR message if needed - -!message: - -# Enable selection phase as an initiator, and do automatic ATN -# after the selection. -# - mvi SCSISEQ,0x48 # ENSELO|ENAUTOATNO - -# Wait for successful arbitration. The AIC-7770 documentation says -# that SELINGO indicates successful arbitration, and that it should -# be used to look for SELDO. However, if the sequencer is paused at -# just the right time - a parallel fsck(8) on two drives did it for -# me - then SELINGO can flip back to false before we've seen it. This -# makes the sequencer sit in the arbitration loop forever. This is -# Not Good. -# -# Therefore, I've added a check in the arbitration loop for SELDO -# too. This could arguably be made a critical section by disabling -# pauses, but I don't want to make a potentially infinite loop a CS. -# I suppose you could fold it into the select loop, too, but since -# I've been hunting this bug for four days it's kinda like a trophy. -# -arbitrate: - test SSTAT0,0x40 jnz *select # SELDO - test SSTAT0,0x10 jz arbitrate # SELINGO - -# Wait for a successful selection. If the hardware selection -# timer goes off, then the driver gets the interrupt, so we don't -# need to worry about it. -# -select: - test SSTAT0,0x40 jz select # SELDO - jmp *select - -# Reselection is being initiated by a target - we've seen the BSY -# line driven active, and we didn't do it! Enable the reselection -# hardware, and wait for it to finish. Make a note that we've been -# reselected, but haven't seen an IDENTIFY message from the target -# yet. -# -reselect: - mvi SCSISEQ,0x10 # ENRSELI - -reselect1: - test SSTAT0,0x20 jz reselect1 # SELDI - mov SELID call initialize - - and FLAGS,0x3f # reselected, no IDENTIFY - or FLAGS,RESELECTED - -# After the [re]selection, make sure that the [re]selection enable -# bit is off. This chip is flaky enough without extra things -# turned on. Also clear the BUSFREE bit in SSTAT1 since we'll be -# using it shortly. -# -*select: - clr SCSISEQ - mvi CLRSINT1,0x8 # CLRBUSFREE - -# Main loop for information transfer phases. If BSY is false, then -# we have a bus free condition, expected or not. Otherwise, wait -# for the target to assert REQ before checking MSG, C/D and I/O -# for the bus phase. -# -# We can't simply look at the values of SCSISIGI here (if we want -# to do synchronous data transfer), because the target won't assert -# REQ if it's already sent us some data that we haven't acknowledged -# yet. -# -ITloop: - test SSTAT1,0x8 jnz p_busfree # BUSFREE - test SSTAT1,0x1 jz ITloop # REQINIT - - and A,0xe0,SCSISIGI # CDI|IOI|MSGI - - cmp ALLZEROS,A je p_dataout - cmp A,0x40 je p_datain - cmp A,0x80 je p_command - cmp A,0xc0 je p_status - cmp A,0xa0 je p_mesgout - cmp A,0xe0 je p_mesgin - - mvi INTSTAT,BAD_PHASE # unknown - signal driver - -p_dataout: - mvi 0 call scsisig # !CDO|!IOO|!MSGO - call assert - call sg_load - - mvi DINDEX,HADDR - mvi SCBARRAY+19 call bcopy_4 - -# mvi DINDEX,HCNT # implicit since HCNT is next to HADDR - mvi SCBARRAY+23 call bcopy_3 - - mvi DINDEX,STCNT - mvi SCBARRAY+23 call bcopy_3 - -# If we are the last SG block, don't set wideodd. - test SCBARRAY+18,0xff jnz p_dataout_wideodd - mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - jmp p_dataout_rest - -p_dataout_wideodd: - mvi 0xbd call dma # WIDEODD|SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - -p_dataout_rest: -# After a DMA finishes, save the final transfer pointer and count -# back into the SCB, in case a device disconnects in the middle of -# a transfer. Use SHADDR and STCNT instead of HADDR and HCNT, since -# it's a reflection of how many bytes were transferred on the SCSI -# (as opposed to the host) bus. -# - mvi DINDEX,SCBARRAY+23 - mvi STCNT call bcopy_3 - - mvi DINDEX,SCBARRAY+19 - mvi SHADDR call bcopy_4 - - call sg_advance - mov SCBARRAY+18,SG_COUNT # residual S/G count - - jmp ITloop - -p_datain: - mvi 0x40 call scsisig # !CDO|IOO|!MSGO - call assert - call sg_load - - mvi DINDEX,HADDR - mvi SCBARRAY+19 call bcopy_4 - -# mvi DINDEX,HCNT # implicit since HCNT is next to HADDR - mvi SCBARRAY+23 call bcopy_3 - - mvi DINDEX,STCNT - mvi SCBARRAY+23 call bcopy_3 - -# If we are the last SG block, don't set wideodd. - test SCBARRAY+18,0xff jnz p_datain_wideodd - mvi 0x39 call dma # SCSIEN|SDMAEN|HDMAEN| - # !DIRECTION|FIFORESET - jmp p_datain_rest -p_datain_wideodd: - mvi 0xb9 call dma # WIDEODD|SCSIEN|SDMAEN|HDMAEN| - # !DIRECTION|FIFORESET -p_datain_rest: - mvi DINDEX,SCBARRAY+23 - mvi STCNT call bcopy_3 - - mvi DINDEX,SCBARRAY+19 - mvi SHADDR call bcopy_4 - - call sg_advance - mov SCBARRAY+18,SG_COUNT # residual S/G count - - jmp ITloop - -# Command phase. Set up the DMA registers and let 'er rip - the -# two bytes after the SCB SCSI_cmd_length are zeroed by the driver, -# so we can copy those three bytes directly into HCNT. -# -p_command: - mvi 0x80 call scsisig # CDO|!IOO|!MSGO - call assert - - mvi DINDEX,HADDR - mvi SCBARRAY+7 call bcopy_4 - -# mvi DINDEX,HCNT # implicit since HCNT is next to HADDR - mvi SCBARRAY+11 call bcopy_3 - - mvi DINDEX,STCNT - mvi SCBARRAY+11 call bcopy_3 - - mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN| - # DIRECTION|FIFORESET - jmp ITloop - -# Status phase. Wait for the data byte to appear, then read it -# and store it into the SCB. -# -p_status: - mvi 0xc0 call scsisig # CDO|IOO|!MSGO - - mvi SCBARRAY+14 call inb_first - jmp p_mesgin_done - -# Message out phase. If there is no active message, but the target -# took us into this phase anyway, build a no-op message and send it. -# -p_mesgout: - mvi 0xa0 call scsisig # CDO|!IOO|MSGO - mvi 0x8 call mk_mesg # build NOP message - - clr STCNT+2 - clr STCNT+1 - -# Set up automatic PIO transfer from MSG_START. Bit 3 in -# SXFRCTL0 (SPIOEN) is already on. -# - mvi SINDEX,MSG_START+0 - mov DINDEX,MSG_LEN - -# When target asks for a byte, drop ATN if it's the last one in -# the message. Otherwise, keep going until the message is exhausted. -# (We can't use outb for this since it wants the input in SINDEX.) -# -# Keep an eye out for a phase change, in case the target issues -# a MESSAGE REJECT. -# -p_mesgout2: - test SSTAT0,0x2 jz p_mesgout2 # SPIORDY - test SSTAT1,0x10 jnz p_mesgout6 # PHASEMIS - - cmp DINDEX,1 jne p_mesgout3 # last byte? - mvi CLRSINT1,0x40 # CLRATNO - drop ATN - -# Write a byte to the SCSI bus. The AIC-7770 refuses to automatically -# send ACKs in automatic PIO or DMA mode unless you make sure that the -# "expected" bus phase in SCSISIGO matches the actual bus phase. This -# behaviour is completely undocumented and caused me several days of -# grief. -# -# After plugging in different drives to test with and using a longer -# SCSI cable, I found that I/O in Automatic PIO mode ceased to function, -# especially when transferring >1 byte. It seems to be much more stable -# if STCNT is set to one before the transfer, and SDONE (in SSTAT0) is -# polled for transfer completion - for both output _and_ input. The -# only theory I have is that SPIORDY doesn't drop right away when SCSIDATL -# is accessed (like the documentation says it does), and that on a longer -# cable run, the sequencer code was fast enough to loop back and see -# an SPIORDY that hadn't dropped yet. -# -p_mesgout3: - mvi STCNT+0, 0x01 - mov SCSIDATL,SINDIR - -p_mesgout4: - test SSTAT0,0x4 jz p_mesgout4 # SDONE - dec DINDEX - test DINDEX,0xff jnz p_mesgout2 - -# If the next bus phase after ATN drops is a message out, it means -# that the target is requesting that the last message(s) be resent. -# -p_mesgout5: - test SSTAT1,0x8 jnz p_mesgout6 # BUSFREE - test SSTAT1,0x1 jz p_mesgout5 # REQINIT - - and A,0xe0,SCSISIGI # CDI|IOI|MSGI - cmp A,0xa0 jne p_mesgout6 - mvi 0x10 call scsisig # ATNO - re-assert ATN - - jmp ITloop - -p_mesgout6: - mvi CLRSINT1,0x40 # CLRATNO - in case of PHASEMIS - and FLAGS,0xdf # no active msg - jmp ITloop - -# Message in phase. Bytes are read using Automatic PIO mode, but not -# using inb. This alleviates a race condition, namely that if ATN had -# to be asserted under Automatic PIO mode, it had to beat the SCSI -# circuitry sending an ACK to the target. This showed up under heavy -# loads and really confused things, since ABORT commands wouldn't be -# seen by the drive after an IDENTIFY message in until it had changed -# to a data I/O phase. -# -p_mesgin: - mvi 0xe0 call scsisig # CDO|IOO|MSGO - mvi A call inb_first # read the 1st message byte - mvi REJBYTE,A # save it for the driver - - cmp ALLZEROS,A jne p_mesgin1 - -# We got a "command complete" message, so put the SCB pointer -# into the Queue Out, and trigger a completion interrupt. -# Check status for non zero return and interrupt driver if needed -# This allows the driver to interpret errors only when they occur -# instead of always uploading the scb. If the status is SCSI_CHECK, -# the driver will download a new scb requesting sense, to replace -# the old one and set the SENSE sequencer flag. If the sense flag is -# set, the sequencer imediately jumps to start working on the sense -# command. If the kernel driver does not wish to request sense, it need -# do nothing, and the command is allowed to complete. We don't -# bother to post to the QOUTFIFO in the error case since it would require -# extra work in the kernel driver to ensure that the entry was removed -# before the command complete code tried processing it. - -# First check for residuals - test SCBARRAY+15,0xff jnz resid - test SCBARRAY+16,0xff jnz resid - test SCBARRAY+17,0xff jnz resid - -check_status: - test SCBARRAY+14,0xff jz status_ok # 0 Status? - mvi INTSTAT,BAD_STATUS # let driver know - test FLAGS,SENSE jz status_ok - jmp p_mesgin_done - -status_ok: -# First, mark this target as free. - test SCBARRAY+0,0x20 jnz complete # Tagged command - and FUNCTION1,0x70,SCBARRAY+1 - mov A,FUNCTION1 - test SCBARRAY+1,0x88 jz clear_a - xor ACTIVE_B,A - jmp complete - -clear_a: - xor ACTIVE_A,A - -complete: - mov QOUTFIFO,SCBPTR - mvi INTSTAT,CMDCMPLT - jmp p_mesgin_done - -# If we have a residual count, interrupt and tell the host. Other -# alternatives are to pause the sequencer on all command completes (yuck), -# dma the resid directly to the host (slick, but a ton of instructions), or -# have the sequencer pause itself when it encounters a non-zero resid -# (unecessary pause just to flag the command -- yuck, but takes few instructions -# and since it shouldn't happen that often is good enough for our purposes). - -resid: - mvi INTSTAT,RESIDUAL - jmp check_status - -# Is it an extended message? We only support the synchronous and wide data -# transfer request messages, which will probably be in response to -# WDTR or SDTR message outs from us. If it's not SDTR or WDTR, reject it - -# apparently this can be done after any message in byte, according -# to the SCSI-2 spec. -# -p_mesgin1: - cmp A,1 jne p_mesgin2 # extended message code? - - mvi ARG_1 call inb_next # extended message length - mvi A call inb_next # extended message code - - cmp A,1 je p_mesginSDTR # Syncronous negotiation message - cmp A,3 je p_mesginWDTR # Wide negotiation message - jmp p_mesginN - -p_mesginWDTR: - cmp ARG_1,2 jne p_mesginN # extended mesg length = 2 - mvi A call inb_next # Width of bus - mvi INTSTAT,MSG_WDTR # let driver know - test RETURN_1,0x80 jz p_mesgin_done# Do we need to send WDTR? - -# We didn't initiate the wide negotiation, so we must respond to the request - and RETURN_1,0x7f # Clear the SEND_WDTR Flag - or FLAGS,ACTIVE_MSG - mvi DINDEX,MSG_START+0 - mvi MSG_START+0 call mk_wdtr # build WDTR message - or SINDEX,0x10,SIGSTATE # turn on ATNO - call scsisig - jmp p_mesgin_done - -p_mesginSDTR: - cmp ARG_1,3 jne p_mesginN # extended mesg length = 3 - mvi ARG_1 call inb_next # xfer period - mvi A call inb_next # REQ/ACK offset - mvi INTSTAT,MSG_SDTR # call driver to convert - - test RETURN_1,0xc0 jz p_mesgin_done# Do we need to mk_sdtr or rej? - test RETURN_1,0x40 jnz p_mesginN # Requested SDTR too small - rej - or FLAGS,ACTIVE_MSG - mvi DINDEX, MSG_START+0 - mvi MSG_START+0 call mk_sdtr - or SINDEX,0x10,SIGSTATE # turn on ATNO - call scsisig - jmp p_mesgin_done - -# Is it a disconnect message? Set a flag in the SCB to remind us -# and await the bus going free. -# -p_mesgin2: - cmp A,4 jne p_mesgin3 # disconnect code? - - or SCBARRAY+0,0x4 # set "disconnected" bit - jmp p_mesgin_done - -# Save data pointers message? Copy working values into the SCB, -# usually in preparation for a disconnect. -# -p_mesgin3: - cmp A,2 jne p_mesgin4 # save data pointers code? - - call sg_ram2scb - jmp p_mesgin_done - -# Restore pointers message? Data pointers are recopied from the -# SCB anyway at the start of any DMA operation, so the only thing -# to copy is the scatter-gather values. -# -p_mesgin4: - cmp A,3 jne p_mesgin5 # restore pointers code? - - call sg_scb2ram - jmp p_mesgin_done - -# Identify message? For a reconnecting target, this tells us the lun -# that the reconnection is for - find the correct SCB and switch to it, -# clearing the "disconnected" bit so we don't "find" it by accident later. -# -p_mesgin5: - test A,0x80 jz p_mesgin6 # identify message? - - test A,0x78 jnz p_mesginN # !DiscPriv|!LUNTAR|!Reserved - - and A,0x07 # lun in lower three bits - or SAVED_TCL,A,SELID - and SAVED_TCL,0xf7 - and A,0x08,SBLKCTL # B Channel?? - or SAVED_TCL,A - call inb_last # ACK - mov ALLZEROS call findSCB -setup_SCB: - and SCBARRAY+0,0xfb # clear disconnect bit in SCB - or FLAGS,IDENTIFY_SEEN # make note of IDENTIFY - - call sg_scb2ram # implied restore pointers - # required on reselect - jmp ITloop -get_tag: - mvi A call inb_first - cmp A,0x20 jne return # Simple Tag message? - mvi A call inb_next - call inb_last - test A,0xf0 jnz abort_tag # Tag in range? - mov SCBPTR,A - mov A,SAVED_TCL - cmp SCBARRAY+1,A jne abort_tag - test SCBARRAY+0,TAG_ENB jz abort_tag - ret -abort_tag: - or SINDEX,0x10,SIGSTATE # turn on ATNO - call scsisig - mvi INTSTAT,ABORT_TAG # let driver know - mvi 0xd call mk_mesg # ABORT TAG message - ret - -# Message reject? Let the kernel driver handle this. If we have an -# outstanding WDTR or SDTR negotiation, assume that it's a response from -# the target selecting 8bit or asynchronous transfer, otherwise just ignore -# it since we have no clue what it pertains to. -# -p_mesgin6: - cmp A,7 jne p_mesgin7 # message reject code? - - mvi INTSTAT, MSG_REJECT - jmp p_mesgin_done - -# [ ADD MORE MESSAGE HANDLING HERE ] -# -p_mesgin7: - -# We have no idea what this message in is, and there's no way -# to pass it up to the kernel, so we issue a message reject and -# hope for the best. Since we're now using manual PIO mode to -# read in the message, there should no longer be a race condition -# present when we assert ATN. In any case, rejection should be a -# rare occurrence - signal the driver when it happens. -# -p_mesginN: - or SINDEX,0x10,SIGSTATE # turn on ATNO - call scsisig - mvi INTSTAT,SEND_REJECT # let driver know - - mvi 0x7 call mk_mesg # MESSAGE REJECT message - -p_mesgin_done: - call inb_last # ack & turn auto PIO back on - jmp ITloop - - -# Bus free phase. It might be useful to interrupt the device -# driver if we aren't expecting this. For now, make sure that -# ATN isn't being asserted and look for a new command. -# -p_busfree: - mvi CLRSINT1,0x40 # CLRATNO - clr SIGSTATE - jmp start - -# Instead of a generic bcopy routine that requires an argument, we unroll -# the two cases that are actually used, and call them explicitly. This -# not only reduces the overhead of doing a bcopy by 2/3rds, but ends up -# saving space in the program since you don't have to put the argument -# into the accumulator before the call. Both functions expect DINDEX to -# contain the destination address and SINDEX to contain the source -# address. -bcopy_3: - mov DINDIR,SINDIR - mov DINDIR,SINDIR - mov DINDIR,SINDIR ret - -bcopy_4: - mov DINDIR,SINDIR - mov DINDIR,SINDIR - mov DINDIR,SINDIR - mov DINDIR,SINDIR ret - -bcopy_3_dfdat: - mov DINDIR,DFDAT - mov DINDIR,DFDAT - mov DINDIR,DFDAT ret - -bcopy_4_dfdat: - mov DINDIR,DFDAT - mov DINDIR,DFDAT - mov DINDIR,DFDAT - mov DINDIR,DFDAT ret - -# Locking the driver out, build a one-byte message passed in SINDEX -# if there is no active message already. SINDEX is returned intact. -# -mk_mesg: - mvi SEQCTL,0x50 # PAUSEDIS|FASTMODE - test FLAGS,ACTIVE_MSG jnz mk_mesg1 # active message? - - or FLAGS,ACTIVE_MSG # if not, there is now - mvi MSG_LEN,1 # length = 1 - mov MSG_START+0,SINDEX # 1-byte message - -mk_mesg1: - mvi SEQCTL,0x10 ret # !PAUSEDIS|FASTMODE - -# Carefully read data in Automatic PIO mode. I first tried this using -# Manual PIO mode, but it gave me continual underrun errors, probably -# indicating that I did something wrong, but I feel more secure leaving -# Automatic PIO on all the time. -# -# According to Adaptec's documentation, an ACK is not sent on input from -# the target until SCSIDATL is read from. So we wait until SCSIDATL is -# latched (the usual way), then read the data byte directly off the bus -# using SCSIBUSL. When we have pulled the ATN line, or we just want to -# acknowledge the byte, then we do a dummy read from SCISDATL. The SCSI -# spec guarantees that the target will hold the data byte on the bus until -# we send our ACK. -# -# The assumption here is that these are called in a particular sequence, -# and that REQ is already set when inb_first is called. inb_{first,next} -# use the same calling convention as inb. -# -inb_first: - clr STCNT+2 - clr STCNT+1 - mov DINDEX,SINDEX - mov DINDIR,SCSIBUSL ret # read byte directly from bus - -inb_next: - mov DINDEX,SINDEX # save SINDEX - - mvi STCNT+0,1 # xfer one byte - mov NONE,SCSIDATL # dummy read from latch to ACK -inb_next1: - test SSTAT0,0x4 jz inb_next1 # SDONE -inb_next2: - test SSTAT0,0x2 jz inb_next2 # SPIORDY - wait for next byte - mov DINDIR,SCSIBUSL ret # read byte directly from bus - -inb_last: - mvi STCNT+0,1 # ACK with dummy read - mov NONE,SCSIDATL -inb_last1: - test SSTAT0,0x4 jz inb_last1 # wait for completion - ret - -# DMA data transfer. HADDR and HCNT must be loaded first, and -# SINDEX should contain the value to load DFCNTRL with - 0x3d for -# host->scsi, or 0x39 for scsi->host. The SCSI channel is cleared -# during initialization. -# -dma: - mov DFCNTRL,SINDEX -dma1: -dma2: - test SSTAT0,0x1 jnz dma3 # DMADONE - test SSTAT1,0x10 jz dma1 # PHASEMIS, ie. underrun - -# We will be "done" DMAing when the transfer count goes to zero, or -# the target changes the phase (in light of this, it makes sense that -# the DMA circuitry doesn't ACK when PHASEMIS is active). If we are -# doing a SCSI->Host transfer, the data FIFO should be flushed auto- -# magically on STCNT=0 or a phase change, so just wait for FIFO empty -# status. -# -dma3: - test SINDEX,0x4 jnz dma5 # DIRECTION -dma4: - test DFSTATUS,0x1 jz dma4 # !FIFOEMP - -# Now shut the DMA enables off, and copy STCNT (ie. the underrun -# amount, if any) to the SCB registers; SG_COUNT will get copied to -# the SCB's residual S/G count field after sg_advance is called. Make -# sure that the DMA enables are actually off first lest we get an ILLSADDR. -# -dma5: - clr DFCNTRL # disable DMA -dma6: - test DFCNTRL,0x38 jnz dma6 # SCSIENACK|SDMAENACK|HDMAENACK - - mvi DINDEX,SCBARRAY+15 - mvi STCNT call bcopy_3 - - ret - -dma_finish: - test DFSTATUS,0x8 jz dma_finish # HDONE - - clr DFCNTRL # disable DMA -dma_finish2: - test DFCNTRL,0x8 jnz dma_finish2 # HDMAENACK - ret - -# Common SCSI initialization for selection and reselection. Expects -# the target SCSI ID to be in the upper four bits of SINDEX, and A's -# contents are stomped on return. -# -initialize: - and SINDEX,0xf0 # Get target ID - and A,0x0f,SCSIID - or SINDEX,A - mov SCSIID,SINDEX - -# Esundry initialization. -# - clr DROPATN - clr SIGSTATE - -# Turn on Automatic PIO mode now, before we expect to see a REQ -# from the target. It shouldn't hurt anything to leave it on. Set -# CLRCHN here before the target has entered a data transfer mode - -# with synchronous SCSI, if you do it later, you blow away some -# data in the SCSI FIFO that the target has already sent to you. -# - mvi SXFRCTL0,0x8a # DFON|SPIOEN|CLRCHN - -# Initialize scatter-gather pointers by setting up the working copy -# in scratch RAM. -# - call sg_scb2ram - -# Initialize SCSIRATE with the appropriate value for this target. -# - call ndx_dtr - mov SCSIRATE,SINDIR ret - -# Assert that if we've been reselected, then we've seen an IDENTIFY -# message. -# -assert: - test FLAGS,RESELECTED jz return # reselected? - test FLAGS,IDENTIFY_SEEN jnz return # seen IDENTIFY? - - mvi INTSTAT,NO_IDENT ret # no - cause a kernel panic - -# Find out if disconnection is ok from the information the BIOS has left -# us. The tcl from SCBARRAY+1 should be in SINDEX; A will -# contain either 0x40 (disconnection ok) or 0x00 (disconnection not ok) -# on exit. -# -# To allow for wide or twin busses, we check the upper bit of the target ID -# and the channel ID and look at the appropriate disconnect register. -# -disconnect: - and FUNCTION1,0x70,SINDEX # strip off extra just in case - mov A,FUNCTION1 - test SINDEX, 0x88 jz disconnect_a - - test DISC_DSB_B,A jz disconnect1 # bit nonzero if DISabled - clr A ret - -disconnect_a: - test DISC_DSB_A,A jz disconnect1 # bit nonzero if DISabled - clr A ret - -disconnect1: - mvi A,0x40 ret - -# Locate the SCB matching the target ID/channel/lun in SAVED_TCL and switch -# the SCB to it. Have the kernel print a warning message if it can't be -# found, and generate an ABORT message to the target. SINDEX should be -# cleared on call. -# -findSCB: - mov A,SAVED_TCL - mov SCBPTR,SINDEX # switch to new SCB - cmp SCBARRAY+1,A jne findSCB1 # target ID/channel/lun match? - test SCBARRAY+0,0x4 jz findSCB1 # should be disconnected - test SCBARRAY+0,TAG_ENB jnz get_tag - ret - -findSCB1: - inc SINDEX - mov A,SCBCOUNT - cmp SINDEX,A jne findSCB - - mvi INTSTAT,NO_MATCH # not found - signal kernel - mvi 0x6 call mk_mesg # ABORT message - - or SINDEX,0x10,SIGSTATE # assert ATNO - call scsisig - ret - -# Make a working copy of the scatter-gather parameters in the SCB. -# -sg_scb2ram: - mov SG_COUNT,SCBARRAY+2 - - mvi DINDEX,SG_NEXT - mvi SCBARRAY+3 call bcopy_4 - - mvi SG_NOLOAD,0x80 - test SCBARRAY+0,0x10 jnz return # don't reload s/g? - clr SG_NOLOAD ret - -# Copying RAM values back to SCB, for Save Data Pointers message. -# -sg_ram2scb: - mov SCBARRAY+2,SG_COUNT - - mvi DINDEX,SCBARRAY+3 - mvi SG_NEXT call bcopy_4 - - and SCBARRAY+0,0xef,SCBARRAY+0 - test SG_NOLOAD,0x80 jz return # reload s/g? - or SCBARRAY+0,SG_LOAD ret - -# Load a struct scatter if needed and set up the data address and -# length. If the working value of the SG count is nonzero, then -# we need to load a new set of values. -# -# This, like the above DMA, assumes a little-endian host data storage. -# -sg_load: - test SG_COUNT,0xff jz return # SG being used? - test SG_NOLOAD,0x80 jnz return # don't reload s/g? - - clr HCNT+2 - clr HCNT+1 - mvi HCNT+0,SG_SIZEOF - - mvi DINDEX,HADDR - mvi SG_NEXT call bcopy_4 - - mvi DFCNTRL,0xd # HDMAEN|DIRECTION|FIFORESET - -# Wait for DMA from host memory to data FIFO to complete, then disable -# DMA and wait for it to acknowledge that it's off. -# - - call dma_finish - -# Copy data from FIFO into SCB data pointer and data count. This assumes -# that the struct scatterlist has this structure (this and sizeof(struct -# scatterlist) == 12 are asserted in aic7xxx.c): -# -# struct scatterlist { -# char *address; /* four bytes, little-endian order */ -# ... /* four bytes, ignored */ -# unsigned short length; /* two bytes, little-endian order */ -# } -# - -# Not in FreeBSD. the scatter list entry is only 8 bytes. -# -# struct ahc_dma_seg { -# physaddr addr; /* four bytes, little-endian order */ -# long len; /* four bytes, little endian order */ -# }; -# - - mvi DINDEX, SCBARRAY+19 - call bcopy_4_dfdat - -# For Linux, we must throw away four bytes since there is a 32bit gap -# in the middle of a struct scatterlist -# mov NONE,DFDAT -# mov NONE,DFDAT -# mov NONE,DFDAT -# mov NONE,DFDAT - - call bcopy_3_dfdat #Only support 24 bit length. - ret - -# Advance the scatter-gather pointers only IF NEEDED. If SG is enabled, -# and the SCSI transfer count is zero (note that this should be called -# right after a DMA finishes), then move the working copies of the SG -# pointer/length along. If the SCSI transfer count is not zero, then -# presumably the target is disconnecting - do not reload the SG values -# next time. -# -sg_advance: - test SG_COUNT,0xff jz return # s/g enabled? - - test STCNT+0,0xff jnz sg_advance1 # SCSI transfer count nonzero? - test STCNT+1,0xff jnz sg_advance1 - test STCNT+2,0xff jnz sg_advance1 - - clr SG_NOLOAD # reload s/g next time - dec SG_COUNT # one less segment to go - - clr A # add sizeof(struct scatter) - add SG_NEXT+0,SG_SIZEOF,SG_NEXT+0 - adc SG_NEXT+1,A,SG_NEXT+1 - adc SG_NEXT+2,A,SG_NEXT+2 - adc SG_NEXT+3,A,SG_NEXT+3 ret - -sg_advance1: - mvi SG_NOLOAD,0x80 ret # don't reload s/g next time - -# Add the array base SYNCNEG to the target offset (the target address -# is in SCSIID), and return the result in SINDEX. The accumulator -# contains the 3->8 decoding of the target ID on return. -# -ndx_dtr: - shr A,SCSIID,4 - test SBLKCTL,0x08 jz ndx_dtr_2 - or A,0x08 # Channel B entries add 8 -ndx_dtr_2: - add SINDEX,SYNCNEG,A - - and FUNCTION1,0x70,SCSIID # 3-bit target address decode - mov A,FUNCTION1 ret - -# If we need to negotiate transfer parameters, build the WDTR or SDTR message -# starting at the address passed in SINDEX. DINDEX is modified on return. -# The SCSI-II spec requires that Wide negotiation occur first and you can -# only negotiat one or the other at a time otherwise in the event of a message -# reject, you wouldn't be able to tell which message was the culpret. -# -mk_dtr: - test SCBARRAY+0,0xc0 jz return # NEEDWDTR|NEEDSDTR - test SCBARRAY+0,NEEDWDTR jnz mk_wdtr_16bit - or FLAGS, MAX_SYNC # Force an offset of 15 - -mk_sdtr: - mvi DINDIR,1 # extended message - mvi DINDIR,3 # extended message length = 3 - mvi DINDIR,1 # SDTR code - call sdtr_to_rate - mov DINDIR,RETURN_1 # REQ/ACK transfer period - test FLAGS, MAX_SYNC jnz mk_sdtr_max_sync - and DINDIR,0xf,SINDIR # Sync Offset - -mk_sdtr_done: - add MSG_LEN,-MSG_START+0,DINDEX ret # update message length - -mk_sdtr_max_sync: -# We're initiating sync negotiation, so request the max offset we can (15) - mvi DINDIR, 0x0f - xor FLAGS, MAX_SYNC - jmp mk_sdtr_done - -mk_wdtr_16bit: - mvi ARG_1,BUS_16_BIT -mk_wdtr: - mvi DINDIR,1 # extended message - mvi DINDIR,2 # extended message length = 2 - mvi DINDIR,3 # WDTR code - mov DINDIR,ARG_1 # bus width - - add MSG_LEN,-MSG_START+0,DINDEX ret # update message length - -# Set SCSI bus control signal state. This also saves the last-written -# value into a location where the higher-level driver can read it - if -# it has to send an ABORT or RESET message, then it needs to know this -# so it can assert ATN without upsetting SCSISIGO. The new value is -# expected in SINDEX. Change the actual state last to avoid contention -# from the driver. -# -scsisig: - mov SIGSTATE,SINDEX - mov SCSISIGO,SINDEX ret - -sdtr_to_rate: - call ndx_dtr # index scratch space for target - shr A,SINDIR,0x4 - dec SINDEX #Preserve SINDEX - and A,0x7 - clr RETURN_1 -sdtr_to_rate_loop: - test A,0x0f jz sdtr_to_rate_done - add RETURN_1,0x18 - dec A - jmp sdtr_to_rate_loop -sdtr_to_rate_done: - shr RETURN_1,0x2 - add RETURN_1,0x18 ret - -return: - ret diff --git a/sys/gnu/scsi/nic5000.c b/sys/gnu/scsi/nic5000.c deleted file mode 100644 index d4271df..0000000 --- a/sys/gnu/scsi/nic5000.c +++ /dev/null @@ -1,1476 +0,0 @@ -static char rcsid[] = "@(#)$Id: nic5000.c,v 1.1 1995/02/14 15:00:37 jkh Exp $"; -/******************************************************************************* - * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ - * - * Copyright 1994 Dietmar Friede - ******************************************************************************* - * Bug reports, patches, comments, suggestions should be sent to: - * - * jkr@saarlink.de or jkrause@guug.de - * - ******************************************************************************* - * $Log: nic5000.c,v $ - * Revision 1.1 1995/02/14 15:00:37 jkh - * An ISDN driver that supports the EDSS1 and the 1TR6 ISDN interfaces. - * EDSS1 is the "Euro-ISDN", 1TR6 is the soon obsolete german ISDN Interface. - * Obtained from: Dietmar Friede <dfriede@drnhh.neuhaus.de> and - * Juergen Krause <jkr@saarlink.de> - * - * This is only one part - the rest to follow in a couple of hours. - * This part is a benign import, since it doesn't affect anything else. - * - * - ******************************************************************************/ - -/* - * - * Copyright (c) 1994 Dietmar Friede (dietmar@friede.de) All rights reserved. - * FSF/FSAG GNU Copyright applies - * - * A low level driver for the NICCY-5000 ISDN/SCSI device - * - */ - -#include "snic.h" -#if NSNIC > 0 - -#define SPLSNIC splbio -#define ESUCCESS 0 -#define SNIC_RETRIES 8 -#include "sys/types.h" -#include "sys/param.h" -#include "sys/ioctl.h" -#include "sys/malloc.h" -#include "sys/kernel.h" - -#include "scsi/scsi_all.h" -#include "scsi/scsiconf.h" -#include "gnu/isdn/isdn_ioctl.h" -#include "gnu/i386/isa/niccyreg.h" -#include "gnu/scsi/scsi_nic.h" -/* #define NETBSD */ - -#undef SCSI_NOMASK -#define OPEN 1 -#define LOAD_HEAD 2 -#define LOAD_DATA 4 -#define LOAD_ENTITY 8 -#define IS_DIAL(p) (((p)&0x20)==0) -#define IS_LISTEN(p) ((p)&0x20) -#define CHAN(pl) (((pl)&7)-1) -#define C_CHAN(x) ((x)&1) -#define APPL(pl) ((((pl)>>6)&0x7f)-1) -#define CARD(pl) (((pl)>>13)&7) -#define MK_APPL(pl) (((pl)+1)<<6) -#define min(a,b) ((a)<(b)?(a):(b)) - -#define SNICOUTSTANDING 2 - -extern int hz; - -struct snic_data -{ - struct scsi_switch *sc_sw; /* address of scsi low level switch */ - int ctrl; /* so they know which one we want */ - int targ; /* our scsi target ID */ - int lu; /* out scsi lu */ - int cmdscount; /* cmds allowed outstanding by board*/ - int xfer_block_wait; - struct scsi_xfer *free_xfer; - struct scsi_xfer scsi_xfer[SNICOUTSTANDING]; /* XXX */ -}; - -struct snic_driver -{ - int size; - struct snic_data **snic_data; -}*snic_driver; - -static int next_snic_unit = 0; -static unsigned dnlnum = 0; - -static u_char ack_msg= 0xff; -static u_char snic_nxt_b; - -typedef enum -{ - DISCON, ISDISCON, DIAL, CALLED, CONNECT, IDLE, ACTIVE, WAITING, WAIT_ACK -} io_state; - -typedef struct -{ - char ctrl; - u_char msg_nr; - short plci; - short ncci; - short state; - Buffer o_buf; -} chan_t; - -struct snic_softc -{ - short sc_stat; - u_char sc_flags; - u_char sc_unit; - u_char sc_ctrl; - u_char sc_type; - u_short sc_istat; - struct scsi_msg sc_icmd; - Buffer sc_imsg; - Header sc_imsg0; - u_short sc_ostat; - struct scsi_msg sc_ocmd; - Buffer sc_omsg; - chan_t sc_chan[2]; - u_char sc_state_ind[8]; - u_char sc_gotack; -} snic_sc[NSNIC]; - -extern isdn_appl_t isdn_appl[]; -extern isdn_ctrl_t isdn_ctrl[]; -extern u_short isdn_state; -extern int ispy_applnr; -extern int Isdn_Appl, Isdn_Ctrl, Isdn_Typ; -extern void isdn_start_out(); - -static old_spy= 0; -static void snic_interupt(); -static int snic_get_msg(); -static void snic_start(); - -int snic_connect(), snic_listen(), snic_disconnect(), snic_accept(); -int snic_output(); - -#ifdef NETBSD -int snicattach(int ctrl, struct scsi_switch *scsi_switch, int physid, int *sunit) -{ - int targ, lu; -#else /* FreeBSD */ -int snicattach(int ctrl, int targ, int lu, struct scsi_switch *scsi_switch) -{ -#endif - int unit,i; - struct snic_data *snic, **snicrealloc; - struct snic_softc *sc; - int cn; - isdn_ctrl_t *ctrl0, *ctrl1; - -#ifdef NETBSD - targ = physid >> 3; - lu = physid & 7; -#endif - - if(next_snic_unit >= NSNIC) - return(0); - - unit = next_snic_unit; - if (next_snic_unit == 0) - { - snic_driver = - malloc(sizeof(struct snic_driver),M_DEVBUF,M_NOWAIT); - if(!snic_driver) - { - printf("snic%d: malloc failed\n",unit); - return(0); - } - bzero(snic_driver,sizeof(snic_driver)); - snic_driver->size = 0; - } - next_snic_unit++; - - if(unit >= snic_driver->size) - { - snicrealloc = - malloc(sizeof(snic_driver->snic_data) * next_snic_unit, - M_DEVBUF,M_NOWAIT); - if(!snicrealloc) - { - printf("snic%d: malloc failed\n",unit); - return(0); - } - /* Make sure we have something to copy before we copy it */ - bzero(snicrealloc,sizeof(snic_driver->snic_data) * next_snic_unit); - if(snic_driver->size) - { - bcopy(snic_driver->snic_data,snicrealloc, - sizeof(snic_driver->snic_data) * snic_driver->size); - free(snic_driver->snic_data,M_DEVBUF); - } - snic_driver->snic_data = snicrealloc; - snic_driver->snic_data[unit] = NULL; - snic_driver->size++; - } - - if(snic_driver->snic_data[unit]) - { - return(0); - } - - snic = snic_driver->snic_data[unit] = - malloc(sizeof(struct snic_data),M_DEVBUF,M_NOWAIT); - if(!snic) - { - printf("snic%d: malloc failed\n",unit); - return(0); - } -#ifdef NETBSD - *sunit= unit; -#endif - bzero(snic,sizeof(struct snic_data)); - - snic->sc_sw = scsi_switch; - snic->ctrl = ctrl; - snic->targ = targ; - snic->lu = lu; - snic->cmdscount = SNICOUTSTANDING; /* XXX (ask the board) */ - - i = snic->cmdscount; - while(i-- ) - { - snic->scsi_xfer[i].next = snic->free_xfer; - snic->free_xfer = &snic->scsi_xfer[i]; - } - - sc = &snic_sc[unit]; - sc->sc_ctrl = -1; - sc->sc_gotack= 1; - if ((cn = isdn_ctrl_attach(2)) == -1) - { - return (0); - } - sc->sc_ctrl = cn; - - sc->sc_chan[0].plci = sc->sc_chan[1].plci = -1; - - ctrl0 = &isdn_ctrl[cn]; - ctrl1 = &isdn_ctrl[cn + 1]; - sc->sc_chan[0].ctrl = ctrl0->ctrl = cn; - sc->sc_chan[1].ctrl = ctrl1->ctrl = cn + 1; - ctrl0->o_buf = &sc->sc_chan[0].o_buf.Data[5]; - ctrl1->o_buf = &sc->sc_chan[1].o_buf.Data[5]; - - ctrl0->listen = ctrl1->listen = snic_listen; - ctrl0->disconnect = ctrl1->disconnect = snic_disconnect; - ctrl0->accept = ctrl1->accept = snic_accept; - ctrl0->connect = ctrl1->connect = snic_connect; - ctrl0->output = ctrl1->output = snic_output; - ctrl0->unit = ctrl1->unit = unit; - ctrl0->appl = ctrl1->appl = -1; - ctrl0->o_len = ctrl1->o_len = -1; - sc->sc_flags= LOAD_ENTITY; - return(1); -} - -static -struct scsi_xfer *snic_get_xs(int unit) -{ - struct scsi_xfer *xs; - struct snic_data *snic; - int s; - - snic = snic_driver->snic_data[unit]; - if (xs = snic->free_xfer) - { - snic->free_xfer = xs->next; - xs->flags = 0; - } - return(xs); -} - -static void -snic_free_xs(int unit, struct scsi_xfer *xs) -{ - struct snic_data *snic; - - snic = snic_driver->snic_data[unit]; - xs->next = snic->free_xfer; - snic->free_xfer = xs; -} - -static void -snic_timout(int unit) -{ - struct snic_softc * sc= &snic_sc[unit&0xff]; - - if(sc->sc_istat&0x100) - { - snic_interupt(unit); - return; - } - if(sc->sc_istat & 2) - sc->sc_istat= sc->sc_ostat= 0; - else if((sc->sc_istat & 0x200) == 0 ) return; - if(sc->sc_ostat & 0xff) - { - sc->sc_istat|= 0x200; - timeout(snic_timout,unit,2); - return; - } - if(sc->sc_gotack) snic_start(unit); - snic_get_msg(unit); -} - -static int -isdn_small_interupt(int unit, struct scsi_xfer *xs) -{ - struct snic_data *snic = snic_driver->snic_data[unit]; - struct snic_softc * sc= &snic_sc[unit]; - Header *msg = &sc->sc_imsg0; - int c; - - switch (msg->Type) - { - case 0: - if(sc->sc_istat&0x200) - break; - sc->sc_istat|= 0x200; - timeout(snic_timout,unit,2); - break; - case 0xff: - sc->sc_gotack= 1; - break; - case 0xfe: -printf("f"); - sc->sc_gotack= 1; - for(c= 0; c < 2; c++) - { - chan_t *chan = &sc->sc_chan[c]; - if(chan->state == WAIT_ACK) - { - chan->state = WAITING; - sc->sc_ostat |= c?0x800:0x400; - } - } - break; - case 0xfd: -printf("fd"); - break; - default: - return(0); - } - sc->sc_istat&= ~0xff; - sc->sc_imsg0.Type= 0; - return(1); -} - -static void -snic_get_done(int unit, struct scsi_xfer *xs) -{ - struct snic_data *snic = snic_driver->snic_data[unit]; - struct snic_softc * sc= &snic_sc[unit]; - Header *msg = &sc->sc_imsg0; - int len, error; - - error= xs->error; - - switch(error) - { - case XS_NOERROR: - if(xs->datalen == 0) - sc->sc_imsg.h.Type= 0; - - if(isdn_small_interupt(unit,xs)) break; - - if(xs->datalen < (len=(msg->DataLen + 10))) - { - struct scsi_msg *scsi_cmd= &sc->sc_icmd; - /* resubmit it */ - - sc->sc_imsg.h.Type= 0xba; - scsi_cmd->len[1]= (len>>8)&0xff; - scsi_cmd->len[2]= len&0xff; - xs->retries= SNIC_RETRIES; - xs->error = XS_NOERROR; - xs->flags &= ~ITSDONE; - xs->data = (char *) &sc->sc_imsg; - xs->datalen = len; - xs->resid = len; - - if ((*(snic->sc_sw->scsi_cmd))(xs) == SUCCESSFULLY_QUEUED) - { - return; - } - error= xs->error | 0x1000; - break; - } - if(xs->datalen <= 10) - { - sc->sc_istat|= 0x400; - sc->sc_imsg.h = sc->sc_imsg0; - } - sc->sc_imsg0.Type= 0; - break; - - case XS_TIMEOUT: - case XS_BUSY: - case XS_DRIVER_STUFFUP: - break; - default: - printf("snic%d: unknown error %x\n",unit,xs->error); - } - - if(error) - { - sc->sc_imsg.h.Type= sc->sc_imsg0.Type= 0; - sc->sc_istat&= 0x200; - if((sc->sc_istat&0x200) == 0) - { - sc->sc_istat= 0x200; - timeout(snic_timout,unit,2); - } - } - - snic_free_xs(unit,xs); - if(sc->sc_istat&0x4ff == 0x400 ) - sc->sc_istat|= 1; - if(sc->sc_istat&0xff) - { - snic_interupt(unit); - return; - } - if(sc->sc_gotack) snic_start(unit); - if(sc->sc_istat & 0x200) - return; - sc->sc_istat|= 0x200; - timeout(snic_timout,unit,2); -} - -static int -snic_get_msg(unit) -int unit; -{ - struct snic_data *snic = snic_driver->snic_data[unit]; - struct snic_softc * sc= &snic_sc[unit]; - struct scsi_msg *scsi_cmd= &sc->sc_icmd; - struct scsi_xfer *xs; - Header *data= &sc->sc_imsg0; - int retval; - - if(sc->sc_istat&0xff) - return(-1); - sc->sc_istat |= 1; - - data->Type= 0xbb; - sc->sc_istat &= ~0x200; - - bzero(scsi_cmd, sizeof(struct scsi_msg)); - bzero(data,10); - - scsi_cmd->op_code = GET_MSG_COMMAND; - scsi_cmd->len[2]= 10; - - xs = snic_get_xs(unit); - if(!xs) - { - sc->sc_istat&= ~0xff; - data->Type= 0; - return(EBUSY); - } - - xs->flags |= (INUSE | SCSI_DATA_IN | SCSI_NOSLEEP); - xs->adapter = snic->ctrl; - xs->targ = snic->targ; - xs->lu = snic->lu; - xs->retries = SNIC_RETRIES; - xs->timeout = 2000; - xs->cmd = (struct scsi_generic *) scsi_cmd; - xs->cmdlen = sizeof(struct scsi_msg); - xs->data = (char *) data; - xs->datalen = 10; - xs->resid = 10; - xs->when_done = snic_get_done; - xs->done_arg = unit; - xs->done_arg2 = (int)xs; - xs->bp = NULL; - xs->error = XS_NOERROR; - - if(retval = (*(snic->sc_sw->scsi_cmd))(xs)) - { - sc->sc_istat= ~0xff; - data->Type= 0; - snic_free_xs(unit,xs); - } - return (retval); -} - -static void -snic_put_done(int unit, struct scsi_xfer *xs) -{ - int retval; - struct snic_data *snic = snic_driver->snic_data[unit]; - struct snic_softc * sc= &snic_sc[unit]; - Header *b= (Header *) xs->data; - int c; - - sc->sc_ostat&= ~0xff; - if(xs->error != XS_NOERROR) - { - snic_free_xs(unit,xs); - switch(b->Type) - { - case 0: - return; - case 0xff: - sc->sc_ostat|= 0x100; - return; - case BD_DATA_B3_REQ | 0x40: - case BD_DATA_B3_REQ: - sc->sc_ostat|= 0x400; - return; - default: - sc->sc_ostat|= 0x200; - return; - } - } - - snic_free_xs(unit,xs); - - c= 0; - switch(b->Type) - { - case 0xff: break; - case BD_DATA_B3_REQ | 0x40: - c= 1; - case BD_DATA_B3_REQ: - sc->sc_chan[c].state = WAIT_ACK; - break; - default: - b->Type= 0; - } - - if(sc->sc_istat&0x100) - { - snic_interupt(unit); - return; - } - - if(sc->sc_ostat&0x100) - { - sc->sc_ostat&= ~0x100; - if(snic_put_msg(unit,&ack_msg,1,0)) - sc->sc_ostat|= 0x100; - else return; - } - - if(sc->sc_gotack) snic_start(unit); - if(sc->sc_istat&0x200) - return; - sc->sc_istat|= 0x200; - timeout(snic_timout,unit,2); -} - -static void -snic_start(int unit) -{ - int retval; - struct snic_softc * sc= &snic_sc[unit]; - Header *b; - int c; - - if(sc->sc_ostat&0x200) - { - b= &sc->sc_omsg.h; - sc->sc_ostat&= ~0x200; - if(snic_put_msg(unit,b, b->DataLen+10,2)) - sc->sc_ostat|= 0x200; - else return; - } - - - for(c= 0; c<2; c++) - { - int cc= (snic_nxt_b++)&1; - u_short m= 0x400 << cc; - - if(sc->sc_ostat&m) - { - chan_t *chan= &sc->sc_chan[cc]; - b= &chan->o_buf.h; - sc->sc_ostat&= ~m; - if(chan->state == WAITING) - { - chan->state= ACTIVE; - if(snic_put_msg(unit,b, b->DataLen+10,4)) - { - chan->state= WAITING; - sc->sc_ostat|= m; - } - else return; - } - } - } -} - -int -snic_put_msg(int unit, Header *data, unsigned len, int w) -{ - struct snic_softc *sc = &snic_sc[unit]; - struct scsi_msg *scsi_cmd = &sc->sc_ocmd; - int retval; - struct scsi_xfer *xs; - struct snic_data *snic = snic_driver->snic_data[unit]; - - if(data->Type==0) - return(0); - - if(sc->sc_ostat&0xff) - return(EBUSY); - - sc->sc_ostat |= 1; - if((data->Type == 0xa8) || (data->Type == 0xe8)) - { - if(sc->sc_gotack==0) - { - sc->sc_ostat &= ~0xff; - return(EBUSY); - } - } - if(data->Type != 0xff) - sc->sc_gotack= 0; - bzero(scsi_cmd, sizeof(struct scsi_msg)); - - scsi_cmd->op_code = PUT_MSG_COMMAND; - if(len > 2063) - { - printf("snic%d: unsupported length %d\n",unit,len); - sc->sc_ostat &= ~0xff; - return(ENODEV); - } - scsi_cmd->len[1]= (len >> 8) & 0xff; - scsi_cmd->len[2]= len & 0xff; - - xs = snic_get_xs(unit); - if(!xs) - { - printf("snic pm%d: busy %d\n", unit, w); - sc->sc_ostat &= ~0xff; - return(EBUSY); - } - xs->flags |= (INUSE | SCSI_DATA_OUT | SCSI_NOSLEEP); - xs->adapter = snic->ctrl; - xs->targ = snic->targ; - xs->lu = snic->lu; - xs->retries = SNIC_RETRIES; - xs->timeout = 2000; - xs->cmd = (struct scsi_generic *) scsi_cmd; - xs->cmdlen = sizeof(struct scsi_msg); - xs->data = (char *)data; - xs->datalen = len; - xs->resid = len; - xs->when_done = snic_put_done; - xs->done_arg = unit; - xs->done_arg2 = (int)xs; - xs->bp = NULL; - xs->error = XS_NOERROR; - - if(retval = (*(snic->sc_sw->scsi_cmd))(xs)) - { - sc->sc_ostat &= ~0xff; - snic_free_xs(unit,xs); - return(EBUSY); - } - - return(0); -} - -int -snicopen(dev_t dev, int flag) -{ - struct snic_softc *sc; - u_char unit; - int x; - unsigned error; - u_char b= 0xff; - - unit = minor(dev); - /* minor number out of limits ? */ - if (unit >= next_snic_unit) - return (ENXIO); - sc = &snic_sc[unit]; - - x= splhigh(); - /* Card busy ? */ - if (sc->sc_flags & 7) - { - splx(x); - return (EBUSY); - } - sc->sc_flags |= OPEN; - - if(sc->sc_flags & LOAD_ENTITY) - { - snic_get_msg(unit); -/* - if(snic_put_msg(unit,(Header *) &ack_msg,1,5)) - sc->sc_ostat|= 0x100; -*/ - } - - splx(x); - return (0); -} - -int -snicclose(dev_t dev, int flag) -{ - struct snic_softc *sc = &snic_sc[minor(dev)]; - - sc->sc_flags &= ~7; - return (0); -} - -int -snicioctl(dev_t dev, int cmd, caddr_t data, int flag) -{ - int error; - u_char unit= minor(dev); - int i, x; - struct snic_softc *sc = &snic_sc[minor(dev)]; - Buffer *b= &sc->sc_omsg; - - error = 0; - x= splhigh(); - while(sc->sc_ostat || (sc->sc_gotack==0)) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "ioctl", 2); - if (error != EWOULDBLOCK) - { - splx(x); - return(error); - } - } - - switch (cmd) - { - case NICCY_DEBUG: - data[0]= 0x50; - bcopy(sc->sc_state_ind,data+1,8); - break; - case NICCY_LOAD: - { - struct head *head = (struct head *) data; - int len, l, off; - - bzero(b, 22); - b->h.Type = MD_DNL_MOD_REQ; - sc->sc_type = head->typ; - b->h.SubType = head->typ; - b->h.DataLen = 12; - bcopy(head->nam, b->Data, 8); - bcopy(&head->len, &b->Data[8], 4); - - sc->sc_flags |= LOAD_HEAD; - sc->sc_stat = -1; - while((error= snic_put_msg(unit,(Header *) b,22,6)) == EBUSY) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic1", 1); - if (error != EWOULDBLOCK) - break; - } - if(error == 0) - { - while (sc->sc_flags & LOAD_HEAD) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic2", 1); - if (error != EWOULDBLOCK) - break; - error= 0; - } - } - if (sc->sc_flags & 7) - sc->sc_flags = (sc->sc_flags & ~7 ) | OPEN; - if(error) - { - head->status = sc->sc_stat; - splx(x); - return (error); - } - - len= head->d_len; - off= 0; - while(len > 0) - { - while(sc->sc_ostat || (sc->sc_gotack==0)) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic7", 2); - if (error != EWOULDBLOCK) - { - splx(x); - return(error); - } - } - bzero(b,10); - b->h.Type = MD_DNL_MOD_DATA; - sc->sc_type = head->typ; - b->h.SubType = head->typ; - l= min(len,512); - len-= l; - b->h.DataLen = l + 8; - b->h.Number = dnlnum++; - b->h.MoreData= len>0; - bcopy(head->nam, b->Data, 8); - if(error= copyin(head->data+off, b->Data+8, l)) - { - splx(x); - return(error); - } - off+= l; - sc->sc_flags |= LOAD_DATA; - sc->sc_stat = -1; - - while((error= snic_put_msg(unit,(Header *) b,b->h.DataLen+10,7)) == EBUSY) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic3", 1); - if (error != EWOULDBLOCK) - break; - } - } - - if(error == 0) - { - while (sc->sc_flags & LOAD_DATA) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic4", 1); - if (error != EWOULDBLOCK) - break; - error= 0; - } - } - if (sc->sc_flags & 7) - sc->sc_flags = (sc->sc_flags & ~7 ) | OPEN; - head->status = sc->sc_stat; - splx(x); - return (error); - } - case NICCY_SET_CLOCK: - bzero(b,10); - b->h.Type = MD_SET_CLOCK_REQ; - b->h.DataLen = 14; - bcopy(data, b->Data,14); - while((error= snic_put_msg(unit,(Header *) b,24,8)) == EBUSY) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic5", 1); - if (error != EWOULDBLOCK) - break; - } - splx(x); - return (error); - case NICCY_SPY: - bzero(b,10); - b->h.Type = MD_MANUFACT_REQ; - b->h.SubType = 18; - b->h.DataLen = 1; -/* There are ilegal states. So I use them to toggle */ - if((data[0] == 0) && (old_spy == 0)) data[0]= 255; - else if(data[0] && old_spy ) data[0]= 0; - old_spy= b->Data[0]= data[0]; - while((error= snic_put_msg(unit,(Header *) b,11,9)) == EBUSY) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic6", 1); - if (error != EWOULDBLOCK) - break; - } - splx(x); - return (error); - case NICCY_RESET: - bzero(b,10); - b->h.Type = MD_RESET_REQ; - while((error= snic_put_msg(unit,(Header *) b,10,9)) == EBUSY) - { - error = tsleep((caddr_t) sc, PZERO | PCATCH, "nic6", 1); - if (error != EWOULDBLOCK) - break; - } - sc->sc_flags|= LOAD_ENTITY; - splx(x); - return (error); - - default: - error = ENODEV; - } - splx(x); - return (error); -} - -#define con_b3_req(unit,mb,pl) en_q(unit,mb|BD_CONN_B3_REQ,0,pl,0,NULL) -#define con_act_resp(unit,pl) en_q(unit,DD_CONN_ACT_RSP,0, pl,0,NULL) -#define discon_resp(sc,pl) en_q(unit,DD_DISC_RSP,0, pl,0,NULL) -#define inf_resp(unit,pl) en_q(unit,DD_INFO_RSP,0, pl,0,NULL) -#define listen_b3_req(unit,mb,pl) en_q(unit,mb|BD_LIST_B3_REQ,0,pl,0,NULL) -#define con_resp(unit,pl,rea) en_q(unit,DD_CONN_RSP,0, pl, 1,(u_char *) &rea) - -static int -en_q(int unit, int t, int st, int pl, int l, u_char *val) -{ - struct snic_softc * sc= &snic_sc[unit]; - Buffer *b= &sc->sc_omsg; - int error= 0; - - if(b->h.Type) - { - return(EBUSY); - } - bzero(b,10); -if(( t >= 0x80) && CHAN(pl) && ((t & 0x40) == 0)) -printf("?%x %x",t,pl); -if(t>=0x40) -printf("S%x %x",t,pl); - - b->h.Type = t; - b->h.SubType = st; - b->h.PLCI = pl; - if(l) - { - b->h.DataLen= l; - bcopy(val,b->Data,l); - } - - if((error= snic_put_msg(unit,(Header *) b,10+l,13)) == EBUSY) - { - sc->sc_ostat|= 0x200; - return(0); - } - return(error); -} - -static int -reset_plci(int w, chan_t * chan, short p) -{ - isdn_ctrl_t *ctrl; - - if (p == -1) - return (-1); - - if(chan == NULL) - return(p); - - ctrl = &isdn_ctrl[chan->ctrl]; - if(chan->plci == p) - { - if (ISBUSY(ctrl->appl)) - { - isdn_disconn_ind(ctrl->appl); - isdn_appl[ctrl->appl].ctrl = -1; - isdn_appl[ctrl->appl].state = 0; - } - ctrl->appl = -1; - ctrl->o_len = -1; - chan->plci = -1; - chan->ncci = -1; - chan->state = DISCON; - chan->o_buf.h.Type= 0; - } - return (p); -} - -static int -sel_b2_prot_req(int unit, int c, int pl, dlpd_t * dlpd) -{ - return(en_q(unit, (c ? 0x40 : 0)| BD_SEL_PROT_REQ, 2, pl, sizeof(dlpd_t), (u_char *) dlpd)); -} - -static int -sel_b3_prot_req(int unit, int mb, u_short pl, ncpd_t * ncpd) -{ - return(en_q(unit, mb | BD_SEL_PROT_REQ, 3, pl, sizeof(ncpd_t), (u_char *) ncpd)); -} - -static int -discon_req(int w, int unit , int pl, int rea, int err) -{ - if((pl == 0) || (pl == -1)) - return(0); - return(en_q(unit, DD_DISC_REQ,0, pl, 1, (u_char *) &rea)); -} - -static int -state_ind(int unit, int api, int spv) -{ - u_char buf[3]; - - buf[0]= unit; buf[1]= api; buf[2]= spv; - return(en_q(unit, MD_STATE_IND,0, 0, 3, buf)); -} - -static int -con_b3_resp(int unit, int mb, u_short ncci, u_short pl, u_char reject) -{ - u_char buf[32]; - int l = 4; - - bzero(buf, 32); - *(u_short *) buf = ncci; - buf[2] = reject; - buf[3] = 0; /* ncpi ??? */ - l += 15; - return(en_q(unit, mb | BD_CONN_B3_RSP,0, pl, l, buf)); -} - -int -snic_connect(int cn, int ap, int b_channel, int inf_mask, int out_serv - ,int out_serv_add, int src_subadr, unsigned ad_len - ,char *dest_addr, int spv) -{ - char buf[128]; - - if (ad_len > 118) - return (-1); - - buf[0] = spv ? 0x53 : 0; - buf[1] = b_channel; - if (spv) - inf_mask |= 0x40000000; - *(u_long *) & buf[2] = inf_mask; - buf[6] = out_serv; - buf[7] = out_serv_add; - buf[8] = src_subadr; - buf[9] = ad_len; - bcopy(dest_addr, &buf[10], ad_len); - return (en_q(isdn_ctrl[cn].unit, DD_CONN_REQ, 0, MK_APPL(ap), ad_len + 10, buf)); -} - -int -snic_listen(int cn, int ap, int inf_mask, int subadr_mask, int si_mask, int spv) -{ - u_short sbuf[4]; - - if (spv) - inf_mask |= 0x40000000; - *(u_long *) sbuf = inf_mask; - sbuf[2] = subadr_mask; - sbuf[3] = si_mask; - return (en_q(isdn_ctrl[cn].unit, DD_LISTEN_REQ, 0, MK_APPL(ap), 8, (u_char *) sbuf)); -} - -int -snic_disconnect(int cn, int rea) -{ - isdn_ctrl_t *ctrl = &isdn_ctrl[cn]; - chan_t *chan = &snic_sc[ctrl->unit].sc_chan[C_CHAN(cn)]; - int p, err; - u_char buf[16]; - - if(chan->ncci != -1) - { - bzero(buf,16); - *(u_short *) buf = chan->ncci; - err= en_q(ctrl->unit, (C_CHAN(cn)?0x40:0)|BD_DISC_B3_REQ, 0 - , chan->plci, 3+sizeof(ncpi_t), buf); - if((err==0) && (ctrl->o_len == 0)) - ctrl->o_len= -1; - return(err); - } - p = chan->plci; - if ((p == 0) || (p == -1)) - return (ENODEV); - - err= en_q(ctrl->unit, DD_DISC_REQ, 0, p, 1, (u_char *) &rea); - if((err==0) && (ctrl->o_len == 0)) - ctrl->o_len= -1; - return(err); -} - -int -snic_accept(int cn, int an, int rea) -{ - isdn_ctrl_t *ctrl = &isdn_ctrl[cn]; - struct snic_softc *sc = &snic_sc[ctrl->unit]; - chan_t *chan = &sc->sc_chan[C_CHAN(cn)]; - isdn_appl_t *appl = &isdn_appl[an]; - - if(ISFREE(ctrl->appl)) - return(ENODEV); - - if (rea) - { - ctrl->appl= -1; - return(discon_req(1, ctrl->unit, chan->plci, rea, 0)); - } - ctrl->appl= an; - ctrl->lastact = time.tv_sec; - appl->ctrl= cn; - appl->state= 4; - - return(sel_b2_prot_req(ctrl->unit, C_CHAN(cn), chan->plci, &appl->dlpd)); -} - -int -snic_output(int cn) -{ - isdn_ctrl_t *ctrl = &isdn_ctrl[cn]; - struct snic_softc *sc = &snic_sc[ctrl->unit]; - chan_t *chan = &sc->sc_chan[C_CHAN(cn)]; - int len= ctrl->o_len; - Buffer *b= &chan->o_buf; - int error= 0; - - if (sc->sc_state_ind[1] || (chan->ncci == -1)) - return (ENODEV); - - if(chan->state != IDLE) - return(EBUSY); - chan->state= WAITING; - - bzero(b,10); - - b->h.Type = BD_DATA_B3_REQ; - if(C_CHAN(cn)) b->h.Type |= 0x40; - b->h.PLCI = chan->plci; - b->h.DataLen= len+5; - *(u_short *) b->Data = chan->ncci; - *(u_short *) &b->Data[2] = 0; - b->h.Number = b->Data[4] = chan->msg_nr++; - - chan->state = ACTIVE; - ctrl->lastact = time.tv_sec; - - if((error= snic_put_msg(ctrl->unit,(Header *) b,15+len,14)) == EBUSY) - { - sc->sc_ostat|= C_CHAN(cn)?0x800:0x400; - chan->state= WAITING; - return(0); - } - return(error); -} - -static void -badstate(Header *h, int n) -{ - int i; - u_char *p= (u_char *)h; - printf("Niccy: not implemented %x.%x len %d at %d", h->Type, - h->SubType, h->DataLen,n); - if(h->DataLen) - { - p+= 10; - for(i=0; i < h->DataLen ; i++) printf(" %x",p[i]); - } - printf("\n"); -} - -unsigned SavMsgTyp; - -static void -snic_interupt(unsigned unit) -{ - struct snic_softc * sc= &snic_sc[unit&0xff]; - Buffer *msg; - chan_t *chan; - u_short n, mb, c, pl, err = 0; - isdn_ctrl_t *ctrl; - isdn_appl_t *appl; - int error= 0; - - msg = &sc->sc_imsg; - chan= NULL; - ctrl= NULL; - appl= NULL; - -SavMsgTyp= msg->h.Type; - - if(sc->sc_istat & 2) - return; - - if(sc->sc_ostat&0xff) - { - sc->sc_istat|= 0x101; - if(sc->sc_istat&0x200) - return; - sc->sc_istat|= 0x200; - timeout(snic_timout,unit,2); - return; - } - - mb= 0; - pl = msg->h.PLCI; - if(pl && (msg->h.Type >= 0x40) && (msg->h.Type < 0xfd) && (msg->h.Type != 0x47)) - { - if ((c = CHAN(pl)) < 2) - { - chan = &sc->sc_chan[c]; - ctrl = &isdn_ctrl[chan->ctrl]; - } else - { - c = 0xffff; - chan= NULL; - ctrl= NULL; - } - - if(ctrl && (ctrl->appl & 0xC0) == 0) - appl= &isdn_appl[ctrl->appl]; - else if( APPL(pl) < 0x30) - appl = &isdn_appl[APPL(pl)]; - else if( APPL(pl) < 0x40) - appl= NULL; - else goto fin; - - if(msg->h.Type >= 0x80) - { - mb= msg->h.Type & 0x40; - msg->h.Type &= 0xbf; - } - } -SavMsgTyp|= 0x100; - -if(msg->h.Type>=0x40) -printf("I%x %x %x",msg->h.Type,pl,mb); - switch (msg->h.Type) - { - case 0x01: /* INIT IND */ - case 0x15: /* POLL IND */ - error= en_q(unit,msg->h.Type|0x20,0,0,0,NULL); - break; - case 0x04: /* DNL MOD CONF */ - sc->sc_stat = msg->Data[0]; - if (sc->sc_flags & 7) - sc->sc_flags = (sc->sc_flags & ~7) | OPEN; - break; - case 0x06: /* DNL MOD IND */ - sc->sc_stat = msg->Data[0]; - error= en_q(unit,msg->h.Type|0x20,sc->sc_type,0,1, &msg->Data[1]); - if(sc->sc_flags & LOAD_ENTITY) - { - sc->sc_istat= sc->sc_ostat= 2; - timeout(snic_timout,unit,hz); - msg->h.Type= 0; - return; - } - if (sc->sc_flags) - sc->sc_flags = OPEN; - break; - case 0x0e: /* SET CLOCK CONF */ - error= state_ind(unit,1,0); - break; - case 0x16: /* STATE IND */ - if(sc->sc_flags & LOAD_ENTITY) - { - if(sc->sc_flags & 7) - sc->sc_flags = OPEN; - else sc->sc_flags= 0; - } - bcopy( msg->Data, sc->sc_state_ind, 8); - error= en_q(unit,msg->h.Type|0x20,0,0,0,NULL); - break; - case 0x17: /* STATE RESP */ - bcopy( msg->Data, sc->sc_state_ind, 8); - break; - case 0x1e: /* MANUFACT CONF */ - if(msg->h.SubType == 18) - break; - badstate(&msg->h,1); - break; - case 0x1f: /* MANUFACT IND */ - if(msg->h.SubType == 19) - { - isdn_input(ispy_applnr, msg->h.DataLen, msg->Data,0); - error= en_q(unit,msg->h.Type|0x20,msg->h.SubType,0,0,NULL); - break; - } - badstate(&msg->h,2); - break; - case 0x40: /* CONNECT CONF */ - err = *(u_short *) msg->Data; - if (err || (appl == NULL) || (chan == NULL) || (ctrl == NULL)) - { - if(chan) reset_plci(3, chan, pl); - if(appl) appl->state= 0; - break; - } - if (ISBUSY(ctrl->appl)) - { - error= discon_req(2, unit, pl, 0, 0); - break; - } - chan->plci = pl; - chan->msg_nr = 0; - chan->ncci = -1; - ctrl->lastact = time.tv_sec; - ctrl->appl = APPL(pl); - appl->ctrl = chan->ctrl; - ctrl->islisten= 0; - chan->state = DIAL; - appl->state= 3; - break; - - case 0x41: /* CONNECT IND */ - if (ISBUSY(ctrl->appl)) - { - error= discon_req(3, unit, pl, 0, 0); - break; - } - chan->plci = pl; - chan->msg_nr = 0; - chan->ncci = -1; - ctrl->lastact = time.tv_sec; - ctrl->appl = 0x7f; - ctrl->islisten= 1; - chan->state = CALLED; - msg->Data[msg->Data[3] + 4] = 0; - isdn_accept_con_ind(APPL(pl), chan->ctrl, msg->Data[0], msg->Data[1] - ,msg->Data[2], msg->Data[3], (char *) &msg->Data[4]); - break; - - case 0x42: /* CONNECT ACTIVE IND */ - error= con_act_resp(unit, pl); - if (IS_LISTEN(pl)) - { - isdn_conn_ind(ctrl->appl,chan->ctrl,0); - break; - } - isdn_conn_ind(APPL(pl),chan->ctrl,1); - chan->state = CONNECT; - ctrl->appl = APPL(pl); - appl->ctrl = chan->ctrl; - break; - - case 0x43: /* DISCONNECT CONF */ - reset_plci(4, chan, pl); - break; - - case 0x44: /* DISCONNECT IND */ - error= discon_resp(unit, reset_plci(5, chan, pl)); - break; - - case 0x47: /* LISTEN CONF */ - isdn_state = *(u_short *) msg->Data; - break; - - case 0x4a: /* INFO IND */ - isdn_info(APPL(pl),*(u_short *)msg->Data, msg->Data[2], msg->Data+3); - error= inf_resp(unit, pl); - break; - case 0x80: /* SELECT PROT CONF */ - err = *(u_short *) msg->Data; - if (err) - { - error= discon_req(4, unit, pl, 0, err); - break; - } - - switch (msg->h.SubType) - { - case 2:/* SELECT B2 PROTOCOL */ - if(ISFREE(ctrl->appl)) - break; - error= sel_b3_prot_req(unit, mb, pl, &isdn_appl[ctrl->appl].ncpd); - break; - - case 3:/* SELECT B3 PROTOCOL */ - if (IS_DIAL(pl)) - error= con_b3_req(unit, mb, pl); - else - error= listen_b3_req(unit, mb, pl); - break; - } - break; - - case 0x81: /* LISTEN B3 CONF */ - err = *(u_short *) msg->Data; - if (err) - { - error= discon_req(5, unit, pl, 0, err); - break; - } - error= con_resp(unit, pl, err); - break; - - case 0x82: /* CONNECT B3 CONF */ - err = *(u_short *) (msg->Data + 2); - n = *(u_short *) msg->Data; - - if (err) - { - error= discon_req(6, unit, pl, 0, err); - break; - } - if(ISFREE(ctrl->appl)) - break; - chan->ncci = n; - chan->state = CONNECT; - break; - - case 0x83: /* CONNECT B3 IND */ - if(ISFREE(ctrl->appl)) - break; - n = *(u_short *) msg->Data; - chan->ncci = n; - chan->state = CONNECT; - error= con_b3_resp(unit, mb, n, pl, 0); - break; - - case 0x84: /* CONNECT B3 ACTIVE IND */ - if(ISFREE(ctrl->appl)) - break; - if (chan->state < IDLE) - { - chan->state = IDLE; - ctrl->o_len = 0; - timeout(isdn_start_out,chan->ctrl,hz/5); - } - break; - - case 0x85: /* DISCONNECT B3 CONF */ - if(ISBUSY(ctrl->appl)) - chan->state = ISDISCON; - err = *(u_short *) (msg->Data + 2); - if (err) - { - error= discon_req(7, unit, pl, 0, err); - break; - } - break; - case 0x86: /* DISCONNECT B3 IND */ - if(ISBUSY(ctrl->appl)) - chan->state = ISDISCON; - err = *(u_short *) (msg->Data + 2); - error= discon_req(8, unit, pl, 0, err); - break; - - case 0x88: /* DATA B3 CONF */ - if(ISFREE(ctrl->appl)) - break; - err = *(u_short *) (msg->Data + 2); - if (err) - { -printf("e%x\n",err); - ctrl->send_err++; - isdn_appl[ctrl->appl].send_err++; - } - chan->state = IDLE; - chan->o_buf.h.Type= 0; - ctrl->o_len = 0; - isdn_start_out(chan->ctrl); - break; - - case 0x89: /* DATA B3 IND */ - if(ISFREE(ctrl->appl)) - break; - if(isdn_input(ctrl->appl, msg->h.DataLen-5, msg->Data+5,ctrl->islisten)) - ctrl->lastact = time.tv_sec; - break; - - default: - badstate(&msg->h,3); - break; - } - -fin: - if(error) - { -printf("x%x %x %x %x %x\n",error,msg->h.Type,sc->sc_istat,sc->sc_ostat,sc->sc_omsg.h.Type); - sc->sc_istat|= 0x101; - if(sc->sc_istat&0x200) - return; - sc->sc_istat|= 0x200; - timeout(snic_timout,unit,2); - return; - } - - msg->h.Type= 0; - if(snic_put_msg(unit,(Header *) &ack_msg,1,15)) - sc->sc_ostat|= 0x100; - sc->sc_istat= 0x200; - snic_get_msg(unit); -} - -#endif /* NSNIC > 0 */ diff --git a/sys/gnu/scsi/scsi_nic.h b/sys/gnu/scsi/scsi_nic.h deleted file mode 100644 index 4847df8..0000000 --- a/sys/gnu/scsi/scsi_nic.h +++ /dev/null @@ -1,53 +0,0 @@ -static char rcsid[] = "@(#)$Id: scsi_nic.h,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; -/******************************************************************************* - * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ - * - * Copyright 1994 Dietmar Friede - ******************************************************************************* - * Bug reports, patches, comments, suggestions should be sent to: - * - * jkr@saarlink.de or jkrause@guug.de - * - ******************************************************************************* - * $Log: scsi_nic.h,v $ - * - ******************************************************************************/ - -/* - * This file defines the NICCY 5000 Interface. - * Copyright Dr. Neuhaus GmbH, Hamburg and Dietmar Friede - * -*/ -#define GET_MSG_COMMAND 0x08 -#define PUT_MSG_COMMAND 0x0a - -#pragma pack (1) -struct scsi_msg -{ - u_char op_code; - u_char dummy; - u_char len[3]; - u_char control; -}; - -typedef struct -{ - unsigned char Type; - unsigned char SubType; - unsigned short Number ; - unsigned char MoreData ; - unsigned char Reserved[1] ; - unsigned short DataLen ; - unsigned short PLCI; -} Header; - -#define SNIC_BUF_SIZE 2048+15 - -typedef struct -{ - Header h; - unsigned char Data[SNIC_BUF_SIZE]; -} Buffer; - -#pragma pack () - diff --git a/sys/i386/boot/README.386BSD b/sys/i386/boot/README.386BSD deleted file mode 100644 index cc5cb8f..0000000 --- a/sys/i386/boot/README.386BSD +++ /dev/null @@ -1,151 +0,0 @@ -This Boot code is different from the original boot code that came with -386BSD in that it uses the BIOS to load the kernel and to provide all i/o -services. The advantage ofthis is that the same boot code exactly, can run -on any device that is supported by the BIOS. (That's most of them) -This is important for the 'generic scsi' project because it means we can -write drivers for new scsi adapters without having to develop an new -set of boot blocks for each. - -At this point you should read the first part of README.MACH... come back here -when you have done that: - -In normal operation, when co-existing with other operating systems, the -following operations occur: - -1/ the BIOS loads the first block of the disk (called the Master Boot Record -or MBR) and if it has the correct magic numbers, jumps into it: - -2/ The MBR code, looks at the Partition table that is embedded within it, -to detirmine which is the partition to boot from. If you are using the os-bs -bootblocks (highly recommended) then it will give you a menu to choose from. - -3/ The MBR will load the first record of the selected partition and -if it has (the same) magic numbers, jumps into it. In 386bsd this is the -first stage boot, (or boot1) it is represented in /usr/mdec by -wdboot, asboot and sdboot. If the disk has been set up without DOS partitioning -then this block will be at block zero, and will have been loaded directly by -the BIOS. - -4/ Boot1 will look at block0 (which might be itself if there are no DOS -partitions) and will find the 386bsd partition, and using the information -regarding the start position of that partition, will load the next 13 sectors -or so, to around 90000 (640k - 64k). and will jump into it at the appropriate -entry point. Since boot1 and boot2 were compiled together as one file -and then split later, boot1 knows the exact position within boot2 of the -entry point. - -Boot 1 also contains a compiled in DOS partition table -(in case it is at block 0), which contains a 386bsd partition starting -at 0. This ensures that the same code can work whether or not -boot1 is at block 0. - -5/ Boot2 asks the user for a boot device, partition and filename, and then -loads the MBR of the selected device. This may or may not be the device -which was originally used to boot the first MBR. The partition table -of the new MBR is searched for a 386bsd partition, and if one is found, -that is then in turn searched for the disklabel. This could all be on the -second disk at this point, if the user selected it. - -6/On finding the disklabel, boot2 can find the correct unix partition -within the 386bsd partition, and using cutdown filesystem code, -look for the file to boot (e.g. 386bsd). - -7/ Boot2 loads this file starting at the location specified by the a.out header, -(see later) and leaps into it at the location specified in he header. - -if the file does not exist or cannot be loaded, boot2 goes back to step 5. - -386bsd is now running and will hopefully start vm etc. and get to multi-user -mode. - -########################################################################## -During all these steps, all i/o is performed using the BIOS. This has a number -of side effects: - -1/ Since BIOS disk calls are specified in terms of cylinder,head and sector, -and the BIOS read the disk information from either the CMOS or from some other -location which is un-available to us, we must use the cyl,head,sec information -that is given in the MBR, rather than the start address in the MBR, because -we cannot guarentee that we can corectly calculate C,H,S from the start address. - -Therefore, the C,H,S information in the MBR must be as correct for this boot -to work as it would be for DOS to boot. For example, adaptec BIOS routines -assume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder. -You must use these figures to calculate the correct values. Luckily, the DOS -fdisk program will do all this for you if you tell it to give you a DOS -partition, and you can change it to a 386BSD partition later. If you use -no DOS partitioning, then the compiled in table in Boot1 will do just fine. - -If you want to do it by hand remember that BIOS counts sectors starting at 1. -(cylinders and heads start at 0 (??)) - -2/ you cannot overwrite the bottom 4k of ram until you have finished ALL -bios calls, as BIOS uses this area as scratch memory. - -3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode, -Boot 2 switches back to real mode just before each BIOS call and then -back to protected mode on each return. Touch this at your peril.! - -######################################################################### -In answering the prompt from Boot2: -you can, -1/ leave it alone.. it will boot the indicated file from the first -partition of the first drive seen by the BIOS (C:) - -2/ enter only "-s" to boot the default to single user mode - -3/ enter only a filename (optionally with -s) to boot that kernel, - -4/ enter a whole line of the form shown in the prompt. This allows you to -boot some other partition, possibly on the second drive, as root. - - -########################################################################## -In the case you have two drives the same type (both scsi or bith IDE/ESDI), -wd(0,a)xxx - will boot xxx from drive 0, a partition. -wd(1,a)xxx - will boot xxx from drive 1, a partition. - -similarly for sd. - -if you have one wd drive and one scsi drive, then you MUST -use device 'hd' - -otherwise the following will happen: - -with wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive. -it boots the kernel correctly, then tells the kernel to use sd1 as root. -you however may not have an sd1, and problems arise. - -hd is special in that the kernel is always told to use unit 0, -The correct TYPE of device will be specified too, so the kernel -will be told either sd0 or wd0. - -Whether sd or wd is specified to the kernel is read from the disklabel, -so ensure that all SCSI disks have type SCSI in their disklabel or the -boot code will assume they are ESDI or IDE. (Remember, because it is -working through the BIOS it has ho idea what kind of disk it is. - -########################################################################## -Installing: -The makefile supplied has a target install which will create the -files wdboot,bootwd ,sdboot and bootsd in /usr/mdec. -BEWARE these will overwrite the existing wdboot and bootwd. (so back -them up) - -there are also targets wd and sd which wil only do one of them - -The commented out targets wd0 and sd0 are examples of how to -load the new bootblocks, however,make sure you change the -device type and label to suit your drive if you uncomment them. -(see 'man disklabel') - -If you already have made partitions using the old bootblocks -these should install painlessly. - -Before you do this ensure you have a booting floppy with correct -disktab and bootblock files on it so that if it doesn't work, you can -re-disklabel from the floppy. - -$Id$ diff --git a/sys/i386/boot/README.MACH b/sys/i386/boot/README.MACH deleted file mode 100644 index cb62329..0000000 --- a/sys/i386/boot/README.MACH +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:33:55 rpd - * $Id$ - */ - -********NOTE: This is not all relevant to the 386BSD version********** - - AT386 Protected Mode Bootstrap Loader - ===================================== - -1. Overview of Startup - ------------------- - - After the system is rebooted, the BIOS bootstrap routine reads Sector - 1, Track 0 into memory at location 0000:7C00H. If location 0000:7DFEH - (last two bytes of that sector) contains the value AA55H, the BIOS - bootstrap routine will transfer control to 0000:7C00H. Otherwise, the - boot code in that sector is bad and the boot routine stops. - - For DOS compatibility reason, one extra stage of boot is required if - the boot device is a hard disk. The first sector of the hard disk will - contain the MOS-DOS boot code and a boot record partition table. - When this sector is loaded into 0000:7C00H, it will relocate itself - to somewhere else and then load the first sector of the active - partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk" -[ 386bsd does not have an 'fdisk' (yet) ] - to install this first sector into the hard disk and to manipulate - the hard disk partitions. - - - -2. The First Stage Bootstrap Loader - -------------------------------- - - After startup, the first stage boot is loaded at 0000:7C00H. This - first stage boot will load itself and the second stage boot into - memory at location 0000:1000H. For floppy disks, the first cylinder - is reserved as the boot cylinder, and the boot code (first and second) - will be loaded from there. Currently, only double sided, high density - (15 sectors per track) floppies are supported. For hard disks, the - first 29 sectors of the active partition is reserved for boot code - which will be loaded by the first stage boot. All the disk types - recognized by BIOS are supported by this bootstrap loader. -[for 386bsd we load the second stage booter to 9000:0] - - - -3. The Second Stage Bootstrap Loader - -------------------------------- - - After the boot code is loaded, the control is passed to the second - stage bootstrap loader "boot2()". In order to be able to load the - big kernel image (bigger than 512K or 640K, depends on the memory - configuration), the second stage boot loader will run on the protected - mode. This bootstarp loader does not have any stand alone device - drivers, all the I/O's are through the BIOS calls. Since the first - stage boot code will no longer be used at this moment, the memory - location of the first stage boot code (0000:1000H to 0000:1200H) will - be used as an internal buffer for BIOS calls. Immediately after this - internal buffer is the GDT table for the second stage boot loader. - Since this boot loader needs to switch back and forth between protected - and real mode in order to use BIOS calls, the limit of the boot code - and boot data segments must not be greater than 64K. - - The boot loader loads the kernel image at memory location above 1 MB - to skip the memory hole between 521K/640K and 1MB. After the kernel - is loaded, the boot loader stores the information in the stack and - then passes control to kernel. Currently, the three information passed - fromm the boot loader to the kernel are type of the boot device, size - of the base memory and size of the extended memory. - -[ 386bsd receives: howto, bootdev] - -[ 386bsd is loaded where-ever the "MByte" bits of the load address specify, -so if you link it for FE100000 it will load to 1MB, but if you link -it for FE000000 it will load ad 0MB] - -[for machines with only 512KB normal ram the kernel will need to be linked -for 1MB and the bootblocks modified to run below 512KB. (8000:0)] - - -4. The UNIX Startup - ---------------- - - Since the boot loader loads the kernel image at memory location above - 1MB, the kernel has to start as protected mode. In addition, the - link editor description file (vuifile) has to indicate that - the text and data segments start above 1MB. Also, the boot loader - passes the infomation to the kernel through the stack. - -[MOST of what is mentionned below is NOT relevant to 386bsd] - -5. Disk Layout and Bad Block Handling - --------------------------------- - - The System V/386 Release 3.2 (AT) disk layout will be used as the disk - layout for the MACH System on the AT platform. - - This disk layout is as follows: - - * Reserve the first sector of cylinder 0 for the DOS boot record which - contains the master boot code (446 bytes) and the partition table. - (Refer to DOS Technical Reference Manual page 9-6 to 9-10). - - * Reserve the first 29 sectors of the UNIX partition for the first - and the second stage bootstrap. - - * Reserve the 30th sector of the UNIX partition for the pdinfo and - the vtoc tables. - - * Reserve the 31st to the 34th sectors of the UNIX partition for the - bad track and the bad block mapping tables. - - * Reserve up to 253 consecutive tracks when required, beginning with - the 35th sector of the UNIX partition, for alternate tracks. - - * Reserve up to 253 consecutive blocks, beginning with the first - sector after the alternate tracks area, for alternate blocks. - - SEC - 1 - ---------------------------------------------------- - | X | | CYL 0, TRK 0 - ---------------- .......... -------------------- - | .......... | - ---------------- .......... -------------------- - | .......... | - =============================================================== - ^ | BOOTSTRAP | CYL N, TRK M - | ---------------------------------------------------- - | | |30 |31 |32 |33 |34 | - ---------------------------------------------------- --- - U | .......... | ^ - N ---------------- .......... --------------------- | - I | .......... | Alternate Tracks - X ---------------- .......... --------------------- | - | .......... | V - P ---------------------------------------------------- --- - A | .......... | ^ - R ---------------- .......... --------------------- | - T | .......... | Alternate Blocks - I ---------------- .......... -------------------- | - T | .......... | V - I ---------------------------------------------------- --- - O | Unix root partition starts from here | - N ---------------- ----------------- - | | - ---------------------------------------------------- - | | - ---------------------------------------------------- - | | - | --------------------------------------------------- - | | | - | ---------------------------------------------------- - V | | - =============================================================== - | ........ | - --------------- ........ -------------- - | ........ | - ---------------------------------------------------- - - - The bad block handling mechanism is as follows: - - * Use the alternate track in the alternate tracks area if the - track containing the target sector is bad. - - * Use the alternate block in the alternate blocks area if the - target sector is bad. - - - - -6. How to make: - ----------- - - Since the kernel image is loaded above 1 MB, the kernel must start - as protected mode. This means that this bootstrap loader will work - only when the corresponding changes on the kernel startup code are done. - - The make command to generate this bootstrap loader is: - - make -f boot.mk fdboot (floppy boot loader) - make -f boot.mk hdboot (wini boot loader) -[to make 386bsd bootblocks "make sd wd" (warning: they will be installed -in /dev/mdec.. take backups)] diff --git a/sys/i386/boot/asm.S b/sys/i386/boot/asm.S deleted file mode 100644 index 90f523f..0000000 --- a/sys/i386/boot/asm.S +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:13 rpd - * $Id: asm.S,v 1.4 1994/10/02 05:18:24 rgrimes Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "asm.s" - -#include "asm.h" - - -CR0_PE_ON = 0x1 -CR0_PE_OFF = 0xfffffffe - -.globl _ouraddr - .text - -/* - * - * real_to_prot() - * transfer from real mode to protected mode. - */ - -ENTRY(real_to_prot) - /* guarantee that interrupt is disabled when in prot mode */ - cli - - /* load the gdtr */ - addr32 - data32 - lgdt EXT(Gdtr) - - /* set the PE bit of CR0 */ - mov %cr0, %eax - - data32 - or $CR0_PE_ON, %eax - mov %eax, %cr0 - - /* - * make intrasegment jump to flush the processor pipeline and - * reload CS register - */ - data32 - ljmp $0x18, $xprot - -xprot: - /* - * we are in USE32 mode now - * set up the protected mode segment registers : DS, SS, ES - */ - mov $0x20, %eax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - -#ifdef BDE_DEBUGGER - /* load idtr so we can debug */ - lidt EXT(Idtr_prot) -#endif - - ret - -/* - * - * prot_to_real() - * transfer from protected mode to real mode - * - */ - -ENTRY(prot_to_real) - - /* set up a dummy stack frame for the second seg change. */ - movl _ouraddr, %eax - sarl $4, %eax - pushw %ax - movw $xreal, %ax /* gas botches pushw $xreal, extra bytes 0, 0 */ - pushw %ax /* decode to add %al, (%eax) (%al usually 0) */ - - /* Change to use16 mode. */ - ljmp $0x28, $x16 - -x16: - /* clear the PE bit of CR0 */ - mov %cr0, %eax - data32 - and $CR0_PE_OFF, %eax - mov %eax, %cr0 - - /* - * make intersegment jmp to flush the processor pipeline - * using the fake stack frame set up earlier - * and reload CS register - */ - lret - -xreal: - /* - * we are in real mode now - * set up the real mode segment registers : DS, SS, ES - */ - movw %cs, %ax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - -#ifdef BDE_DEBUGGER - /* load idtr so we can debug */ - addr32 - data32 - lidt EXT(Idtr_real) -#endif - - data32 - ret - -/* - * startprog(phyaddr) - * start the program on protected mode where phyaddr is the entry point - * - * XXX This whole mess should go away and we should run the boot code in - * flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for - * how this is done. - */ - -ENTRY(startprog) - push %ebp - mov %esp, %ebp - movl %esp, %eax /* Use eax as the old stack pointer */ - - /* convert the current stack to a 32 bit flat model */ - mov $0x10, %ebx - movw %bx, %ss - addl $(BOOTSEG<<4),%esp - - /* copy the arguments from the old stack to the new stack */ - pushl 0x14(%eax) /* &bootinfo */ - pushl $0 /* was &nfsdiskless */ - pushl $0 /* was esym */ - pushl $0 /* was cyloffset */ - pushl 0x10(%eax) /* bootdev */ - pushl 0x0C(%eax) /* howto */ - movl $(ourreturn),%ebx - addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */ - pushl %ebx /* our return address */ - - /* push on our entry address */ - pushl $0x08 /* segment selector */ - pushl 0x08(%eax) /* kernel entry address */ - - /* convert over the other data segs */ - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - - /* convert the PC (and code seg) */ - lret -ourreturn: - /* For now there is not much we can do, just lock in a loop */ - jmp ourreturn - -/* - * - * pbzero( dst, cnt) - * where src is a virtual address and dst is a physical address - */ - -ENTRY(pbzero) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - /* set %es to point at the flat segment */ - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %edi /* destination */ - mov 0xc(%ebp), %ecx /* count */ - mov $0x0, %eax /* value */ - - rep - stosb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret -/* - * pcpy(src, dst, cnt) - * where src is a virtual address and dst is a physical address - */ - -ENTRY(pcpy) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - /* set %es to point at the flat segment */ - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %esi /* source */ - mov 0xc(%ebp), %edi /* destination */ - mov 0x10(%ebp), %ecx /* count */ - - rep - movsb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret - diff --git a/sys/i386/boot/asm.h b/sys/i386/boot/asm.h deleted file mode 100644 index 43242bd..0000000 --- a/sys/i386/boot/asm.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.7 92/02/29 15:33:41 rpd - * $Id$ - */ - -#define S_ARG0 4(%esp) -#define S_ARG1 8(%esp) -#define S_ARG2 12(%esp) -#define S_ARG3 16(%esp) - -#define FRAME pushl %ebp; movl %esp, %ebp -#define EMARF leave - -#define B_ARG0 8(%ebp) -#define B_ARG1 12(%ebp) -#define B_ARG2 16(%ebp) -#define B_ARG3 20(%ebp) - -#ifdef wheeze - -#define ALIGN 4 -#define EXT(x) x -#define LEXT(x) x: -#define LCL(x) ./**/x - -#define LB(x,n) ./**/x -#define LBb(x,n) ./**/x -#define LBf(x,n) ./**/x - -#define SVC lcall $7,$0 - -#define String .string -#define Value .value -#define Times(a,b) [a\*b] -#define Divide(a,b) [a\\b] - -#define INB inb (%dx) -#define OUTB outb (%dx) -#define INL inl (%dx) -#define OUTL outl (%dx) - -#else wheeze -#define ALIGN -#define LCL(x) x - -#define LB(x,n) n -#ifdef __STDC__ -#define EXT(x) _ ## x -#define LEXT(x) _ ## x ## : - -#define LBb(x,n) n ## b -#define LBf(x,n) n ## f -#else __STDC__ -#define EXT(x) _/**/x -#define LEXT(x) _/**/x/**/: -#define LBb(x,n) n/**/b -#define LBf(x,n) n/**/f -#endif __STDC__ -#define SVC .byte 0x9a; .long 0; .word 0x7 - -#define String .ascii -#define Value .word -#define Times(a,b) (a*b) -#define Divide(a,b) (a/b) - -#define INB inb %dx, %al -#define OUTB outb %al, %dx -#define INL inl %dx, %eax -#define OUTL outl %eax, %dx - -#endif wheeze - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -#ifdef GPROF -#ifdef __STDC__ - -#define MCOUNT .data; LB(x, 9); .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ASENTRY(x) .globl x; .align ALIGN; x ## : ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#else __STDC__ - -#define MCOUNT .data; LB(x, 9): .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#endif __STDC__ -#else GPROF -#ifdef __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x ## : - -#else __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: - -#endif __STDC__ -#endif GPROF - -#define Entry(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define DATA(x) .globl EXT(x); .align ALIGN; LEXT(x) diff --git a/sys/i386/boot/bios.S b/sys/i386/boot/bios.S deleted file mode 100644 index 16ded4d..0000000 --- a/sys/i386/boot/bios.S +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id: bios.S,v 1.2 1993/10/16 19:11:30 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "bios.s" - -#include "asm.h" - .text - -/* - * biosread(dev, cyl, head, sec, nsec, offset) - * Read "nsec" sectors from disk to offset "offset" in boot segment - * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory - * Call with %ah = 0x2 - * %al = number of sectors - * %ch = cylinder - * %cl = sector - * %dh = head - * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) - * %es:%bx = segment:offset of buffer - * Return: - * %al = 0x0 on success; err code on failure - */ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - /* cylinder; the highest 2 bits of cyl is in %cl */ - xchgb %ch, %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl /* sector; sec starts from 1, not 0 */ - movb 0x8(%ebp), %dl /* device */ - movl 0x1c(%ebp), %ebx /* offset */ - - /* prot_to_real will set %es to BOOTSEG */ - call EXT(prot_to_real) /* enter real mode */ - movb $0x2, %ah /* subfunction */ - addr32 - movb 0x18(%ebp), %al /* number of sectors */ - - sti - int $0x13 - cli - - /* save return value (actually movw %ax, %bx) */ - mov %eax, %ebx - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - movb %bh, %al /* return value in %ax */ - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - - -/* - * putc(ch) - * BIOS call "INT 10H Function 0Eh" to write character to console - * Call with %ah = 0x0e - * %al = character - * %bh = page - * %bl = foreground color ( graphics modes) - */ - - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %ebx - push %ecx - - movb 0x8(%ebp), %cl - - call EXT(prot_to_real) - - data32 - mov $0x1, %ebx /* %bh=0, %bl=1 (blue) */ - movb $0xe, %ah - movb %cl, %al - sti - int $0x10 /* display a byte */ - cli - - data32 - call EXT(real_to_prot) - - pop %ecx - pop %ebx - pop %ebp - ret - - -/* - * getc() - * BIOS call "INT 16H Function 00H" to read character from keyboard - * Call with %ah = 0x0 - * Return: %ah = keyboard scan code - * %al = ASCII character - */ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %ebx /* save %ebx */ - - call EXT(prot_to_real) - - movb $0x0, %ah - sti - int $0x16 - cli - - movb %al, %bl /* real_to_prot uses %eax */ - - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret -/* - * ischar() - * if there is a character pending, return it; otherwise return 0 - * BIOS call "INT 16H Function 01H" to check whether a character is pending - * Call with %ah = 0x1 - * Return: - * If key waiting to be input: - * %ah = keyboard scan code - * %al = ASCII character - * Zero flag = clear - * else - * Zero flag = set - */ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %ebx - - call EXT(prot_to_real) /* enter real mode */ - - xor %ebx, %ebx - movb $0x1, %ah - sti - int $0x16 - cli - data32 - jz nochar - movb %al, %bl - -nochar: - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret - -/* - * - * get_diskinfo(): return a word that represents the - * max number of sectors and heads and drives for this device - * - */ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl /* diskinfo(drive #) */ - call EXT(prot_to_real) /* enter real mode */ - - movb $0x8, %ah /* ask for disk info */ - - sti - int $0x13 - cli - - jnc ok - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ - subb %ah, %ah /* %ax = 0 */ - movb %al, %al - movb %ah, %bh /* %bh = 0 */ - movb $2, %bl /* %bl bits 0-3 = drive type, - bit 2 = 1.2M */ - movb $79, %ch /* max track */ - movb $15, %cl /* max sector */ - movb $1, %dh /* max head */ - movb $1, %dl /* # floppy drives installed */ - /* es:di = parameter table */ - /* carry = 0 */ -ok: - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - - /* form a longword representing all this gunk */ - movb %dh, %ah /* max head */ - andb $0x3f, %cl /* mask of cylinder gunk */ - movb %cl, %al /* max sector (and # sectors) */ - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* - * - * memsize(i) : return the memory size in KB. i == 0 for conventional memory, - * i == 1 for extended memory - * BIOS call "INT 12H" to get conventional memory size - * BIOS call "INT 15H, AH=88H" to get extended memory size - * Both have the return value in AX. - * - */ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) /* enter real mode */ - - cmpb $0x1, %bl - data32 - je xext - - sti - int $0x12 - cli - data32 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data32 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret diff --git a/sys/i386/boot/boot.c b/sys/i386/boot/boot.c deleted file mode 100644 index a64ee21..0000000 --- a/sys/i386/boot/boot.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.19 1994/10/26 20:22:10 jkh Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <sys/param.h> -#include "boot.h" -#include <a.out.h> -#include <sys/reboot.h> -#include <machine/bootinfo.h> - -struct exec head; -struct bootinfo_t bootinfo; -char *name; -char *names[] = { - "/kernel" -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -extern int end; -boot(drive) -int drive; -{ - int loadflags, currname = 0; - char *t; - - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n", - ouraddr, - memsize(0), - memsize(1)); - printf("use hd(1,a)/kernel to boot sd0 when wd0 is also installed\n"); - gateA20(); -loadstart: - /***************************************************************\ - * As a default set it to the first partition of the first * - * floppy or hard drive * - \***************************************************************/ - part = unit = 0; - maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - name = names[currname++]; - - loadflags = 0; - if (currname == NUMNAMES) - currname = 0; - getbootdev(&loadflags); - if (openrd()) { - printf("Can't find %s\n", name); - goto loadstart; - } -/* if (inode.i_mode&IEXEC) - loadflags |= RB_KDB; -*/ - loadprog(loadflags); - goto loadstart; -} - -loadprog(howto) - int howto; -{ - long int startaddr; - long int addr; /* physical address.. not directly useable */ - long int bootdev; - long int total; - int i; - unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ - - read(&head, sizeof(head)); - if ( N_BADMAG(head)) { - printf("Invalid format!\n"); - return; - } - - poff = N_TXTOFF(head); - /*if(poff==0) - poff = 32;*/ - - startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */ - addr = startaddr; - printf("Booting %s(%d,%c)%s @ 0x%x\n" - , devs[maj] - , unit - , 'a'+part - , name - , addr); - if(addr < ouraddr) - { - if((addr + head.a_text + head.a_data) > ouraddr) - { - printf("kernel overlaps loader\n"); - return; - } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) - { - printf("bss exceeds 640k limit\n"); - return; - } - } - printf("text=0x%x ", head.a_text); - /********************************************************/ - /* LOAD THE TEXT SEGMENT */ - /* don't clobber the first 4k yet (BIOS NEEDS IT) */ - /********************************************************/ - read(tmpbuf,4096); - addr += 4096; - xread(addr, head.a_text - 4096); - addr += head.a_text - 4096; - - /********************************************************/ - /* Load the Initialised data after the text */ - /********************************************************/ - while (addr & CLOFSET) - *(char *)addr++ = 0; - - printf("data=0x%x ", head.a_data); - xread(addr, head.a_data); - addr += head.a_data; - - /********************************************************/ - /* Skip over the uninitialised data */ - /* (but clear it) */ - /********************************************************/ - printf("bss=0x%x ", head.a_bss); - if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) - { - pbzero(addr,ouraddr - (int)addr); - } - else - { - pbzero(addr,head.a_bss); - } - addr += head.a_bss; - -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) - { - /********************************************************/ - /*copy in the symbol header */ - /********************************************************/ - pcpy(&head.a_syms, addr, sizeof(head.a_syms)); - addr += sizeof(head.a_syms); - - /********************************************************/ - /* READ in the symbol table */ - /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); - xread(addr, head.a_syms); - addr += head.a_syms; - - /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ - /********************************************************/ - read(&i, sizeof(int)); - pcpy(&i, addr, sizeof(int)); - i -= sizeof(int); - addr += sizeof(int); - - - /********************************************************/ - /* and that many bytes of (debug symbols?) */ - /********************************************************/ - printf("+0x%x] ", i); - xread(addr, i); - addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - - total = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ", total); - bootdev = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ; - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ - printf("entry point=0x%x\n" ,(int)startaddr); - /* Under no circumstances overwrite precious BIOS variables! */ - pcpy(tmpbuf, startaddr, 0x400); - pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500); - bootinfo.version=1; - bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4)); - bootinfo.nfs_diskless=0; - startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4)); - return; -} - -#define NAMEBUF_LEN 100 - -char namebuf[NAMEBUF_LEN]; -getbootdev(howto) - int *howto; -{ - char c, *ptr = namebuf; - printf("Boot: [[[%s(%d,%c)]%s][-s][-r][-a][-c][-d][-b]] :- " - , devs[maj] - , unit - , 'a'+part - , name); - if (gets(namebuf)) { - while (c=*ptr) { - while (c==' ') - c = *++ptr; - if (!c) - return; - if (c=='-') - while ((c = *++ptr) && c!=' ') - switch (c) { - case 'r': - *howto |= RB_DFLTROOT; continue; - case 'a': - *howto |= RB_ASKNAME; continue; - case 'c': - *howto |= RB_CONFIG; continue; - case 's': - *howto |= RB_SINGLE; continue; - case 'd': - *howto |= RB_KDB; continue; - case 'b': - *howto |= RB_HALT; continue; - } - else { - name = ptr; - while ((c = *++ptr) && c!=' '); - if (c) - *ptr++ = 0; - } - } - if (name[0] != '/') { - int i; - /* This is incredibly gross, but nonetheless compact */ - /* which is a good thing for a boot block to be */ - for (i = NAMEBUF_LEN - 1; i; i--) - name[i] = name[i - 1]; - name[0] = '/'; - } - } else - printf("\n"); -} - diff --git a/sys/i386/boot/boot.h b/sys/i386/boot/boot.h deleted file mode 100644 index 2046990..0000000 --- a/sys/i386/boot/boot.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:03 rpd - * $Id: boot.h,v 1.3 1993/10/16 19:11:32 rgrimes Exp $ - */ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/time.h> -#include <ufs/ufs/quota.h> -#include <ufs/ffs/fs.h> -#include <ufs/ufs/inode.h> - -extern char *devs[], *name, *iodest; -extern struct fs *fs; -extern struct inode inode; -extern int dosdev, unit, part, maj, boff, poff, bnum, cnt; -extern long int ouraddr; diff --git a/sys/i386/boot/boot2.S b/sys/i386/boot/boot2.S deleted file mode 100644 index 5984f83..0000000 --- a/sys/i386/boot/boot2.S +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:26 rpd - * $Id: boot2.S,v 1.4 1994/06/22 05:52:25 jkh Exp $ - */ - -#include "asm.h" - -/* Conventional GDT indexes. */ -#define BOOT_CS_INDEX 3 -#define BOOT_CS16_INDEX 5 -#define BOOT_DS_INDEX 4 - -#ifdef BDE_DEBUGGER -#define DB_CS_INDEX 14 -#define DB_CS16_INDEX 15 -#define DB_DS_INDEX 16 -#define GDT_INDEX 17 -#endif - -/* Vector numbers. */ -#define BREAKPOINT_VECTOR 3 -#define DEBUG_VECTOR 1 - -/* - * boot2() -- second stage boot - */ - -.globl EXT(ouraddr) - -ENTRY(boot2) - data32 - subl %eax, %eax - mov %cs, %ax - mov %ax, %ds - mov %ax, %es - data32 - shll $4, %eax - addr32 - data32 - movl %eax, EXT(ouraddr) - - /* fix up GDT entries for bootstrap */ -#define FIXUP(gdt_index) \ - addr32; \ - movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \ - addr32; \ - movb %bl, EXT(Gdt)+(8*gdt_index)+4 - - data32 - shld $16, %eax, %ebx - FIXUP(BOOT_CS_INDEX) - FIXUP(BOOT_CS16_INDEX) - FIXUP(BOOT_DS_INDEX) - - /* fix up GDT pointer */ - data32 - movl %eax, %ecx - data32 - addl $ EXT(Gdt), %eax - addr32 - data32 - movl %eax, EXT(Gdtr)+2 - -#ifdef BDE_DEBUGGER - /* fix up GDT entry for GDT */ - data32 - shld $16, %eax, %ebx - FIXUP(GDT_INDEX) - - /* fix up IDT pointer */ - data32 - addl $ EXT(Idt), %ecx - addr32 - data32 - movl %ecx, EXT(Idtr_prot)+2 - - /* %es = vector table segment for a while */ - push %es - data32 - subl %eax, %eax - mov %ax, %es - - /* fix up GDT entries for bdb */ - data32 - movl $4*DEBUG_VECTOR, %esi - addr32 - movl %es: 2(%esi), %eax /* actually movw to %ax */ - data32 - shll $4, %eax - data32 - shld $16, %eax, %ebx - FIXUP(DB_CS_INDEX) - FIXUP(DB_CS16_INDEX) - FIXUP(DB_DS_INDEX) - - /* Fetch entry points of bdb's protected mode trap handlers. These - * are stored at 2 before the corresponding entry points for real mode. - */ - data32 - subl %ebx, %ebx - addr32 - movl %es: (%esi), %ebx /* actually movw to %bx */ - data32 - subl %ecx, %ecx - addr32 - movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx - /* actually movw to %cx */ - - /* %es = bdb segment for a while */ - data32 - shrl $4, %eax - mov %ax, %es - - /* fix up IDT entries for bdb */ - data32 - subl $2, %ebx /* calculate EA to check it */ - jb 1f /* give up if it would trap */ - addr32 - movl %es: (%ebx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */ -1: - data32 - subl $2, %ecx - jb 1f - addr32 - movl %es: (%ecx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */ -1: - - /* finished with groping in real mode segments */ - pop %es -#endif /* BDE_DEBUGGER */ - - /* change to protected mode */ - data32 - call EXT(real_to_prot) - - /* clear the bss */ - movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */ - movl $ EXT(end), %ecx /* or EXT(_end) */ - subl %edi, %ecx - subb %al, %al - rep - stosb - - movzbl %dl, %edx /* discard head (%dh) and random high bits */ - pushl %edx - call EXT(boot) -oops: - hlt - jmp oops - - .data - .align 2 -#if 0 /* XXX this would give losing "_ouraddr :". Better declared in C */ -EXT(ouraddr): -#else -_ouraddr: -#endif - .long 0 diff --git a/sys/i386/boot/disk.c b/sys/i386/boot/disk.c deleted file mode 100644 index a63ca5a..0000000 --- a/sys/i386/boot/disk.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd - * $Id: disk.c,v 1.4 1994/02/22 22:59:40 rgrimes Exp $ - */ - -/* - * 93/10/08 bde - * If there is no 386BSD partition, initialize the label sector with - * LABELSECTOR instead of with garbage. - * - * 93/08/22 bde - * Fixed reading of bad sector table. It is at the end of the 'c' - * partition, which is not always at the end of the disk. - */ - -#include "boot.h" -#ifdef DO_BAD144 -#include <sys/dkbad.h> -#endif DO_BAD144 -#include <sys/disklabel.h> - -#define BIOS_DEV_FLOPPY 0x0 -#define BIOS_DEV_WIN 0x80 - -#define BPS 512 -#define SPT(di) ((di)&0xff) -#define HEADS(di) ((((di)>>8)&0xff)+1) - -char *devs[] = {"wd", "hd", "fd", "wt", "sd", 0}; - -#ifdef DO_BAD144 -struct dkbad dkb; -int do_bad144; -int bsize; -#endif DO_BAD144 - -int spt, spc; - -char *iodest; -struct fs *fs; -struct inode inode; -int dosdev, unit, part, maj, boff, poff, bnum, cnt; - -/*#define EMBEDDED_DISKLABEL 1*/ -extern struct disklabel disklabel; -/*struct disklabel disklabel;*/ - -devopen() -{ - struct dos_partition *dptr; - struct disklabel *dl; - int dosdev = inode.i_dev; - int i, sector, di; - - di = get_diskinfo(dosdev); - spc = (spt = SPT(di)) * HEADS(di); - if (dosdev == 2) - { - boff = 0; - part = (spt == 15 ? 3 : 1); - } - else - { -#ifdef EMBEDDED_DISKLABEL - dl = &disklabel; -#else EMBEDDED_DISKLABEL - Bread(dosdev, 0); - dptr = (struct dos_partition *)(((char *)0)+DOSPARTOFF); - sector = LABELSECTOR; - for (i = 0; i < NDOSPART; i++, dptr++) - if (dptr->dp_typ == DOSPTYP_386BSD) { - sector = dptr->dp_start + LABELSECTOR; - break; - } - Bread(dosdev, sector++); - dl=((struct disklabel *)0); - disklabel = *dl; /* structure copy (maybe useful later)*/ -#endif EMBEDDED_DISKLABEL - if (dl->d_magic != DISKMAGIC) { - printf("bad disklabel"); - return 1; - } - if( (maj == 4) || (maj == 0) || (maj == 1)) - { - if (dl->d_type == DTYPE_SCSI) - { - maj = 4; /* use scsi as boot dev */ - } - else - { - maj = 0; /* must be ESDI/IDE */ - } - } - boff = dl->d_partitions[part].p_offset; -#ifdef DO_BAD144 - bsize = dl->d_partitions[part].p_size; - do_bad144 = 0; - if (dl->d_flags & D_BADSECT) { - /* this disk uses bad144 */ - int i; - int dkbbnum; - struct dkbad *dkbptr; - - /* find the first readable bad sector table */ - /* some of this code is copied from ufs/ufs_disksubr.c */ - /* including the bugs :-( */ - /* read a bad sector table */ - -#define BAD144_PART 2 /* XXX scattered magic numbers */ -#define BSD_PART 0 /* XXX should be 2 but bad144.c uses 0 */ - if (dl->d_partitions[BSD_PART].p_offset != 0) - dkbbnum = dl->d_partitions[BAD144_PART].p_offset - + dl->d_partitions[BAD144_PART].p_size; - else - dkbbnum = dl->d_secperunit; - dkbbnum -= dl->d_nsectors; - - if (dl->d_secsize > DEV_BSIZE) - dkbbnum *= dl->d_secsize / DEV_BSIZE; - else - dkbbnum /= DEV_BSIZE / dl->d_secsize; - i = 0; - do_bad144 = 0; - do { - /* XXX: what if the "DOS sector" < 512 bytes ??? */ - Bread(dosdev, dkbbnum + i); - dkbptr = (struct dkbad *) 0; -/* XXX why is this not in <sys/dkbad.h> ??? */ -#define DKBAD_MAGIC 0x4321 - if (dkbptr->bt_mbz == 0 && - dkbptr->bt_flag == DKBAD_MAGIC) { - dkb = *dkbptr; /* structure copy */ - do_bad144 = 1; - break; - } - i += 2; - } while (i < 10 && i < dl->d_nsectors); - if (!do_bad144) - printf("Bad bad sector table\n"); - else - printf("Using bad sector table at %d\n", dkbbnum+i); - } -#endif DO_BAD144 - } - return 0; -} - -devread() -{ - int offset, sector = bnum; - int dosdev = inode.i_dev; - for (offset = 0; offset < cnt; offset += BPS) - { - Bread(dosdev, badsect(dosdev, sector++)); - bcopy(0, iodest+offset, BPS); - } -} - -#define I_ADDR ((void *) 0) /* XXX where all reads go */ - -/* Read ahead buffer large enough for one track on a 1440K floppy. For - * reading from floppies, the bootstrap has to be loaded on a 64K boundary - * to ensure that this buffer doesn't cross a 64K DMA boundary. - */ -#define RA_SECTORS 18 -static char ra_buf[RA_SECTORS * BPS]; -static int ra_dev; -static int ra_end; -static int ra_first; - -Bread(dosdev,sector) - int dosdev,sector; -{ - if (dosdev != ra_dev || sector < ra_first || sector >= ra_end) - { - int cyl, head, sec, nsec; - - cyl = sector/spc; - head = (sector % spc) / spt; - sec = sector % spt; - nsec = spt - sec; - if (nsec > RA_SECTORS) - nsec = RA_SECTORS; - twiddle(); - if (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) - { - nsec = 1; - twiddle(); - while (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) { - printf("Error: C:%d H:%d S:%d\n", cyl, head, sec); - twiddle(); - } - } - ra_dev = dosdev; - ra_first = sector; - ra_end = sector + nsec; - } - bcopy(ra_buf + (sector - ra_first) * BPS, I_ADDR, BPS); -} - -badsect(dosdev, sector) - int dosdev, sector; -{ - int i; -#ifdef DO_BAD144 - if (do_bad144) { - u_short cyl; - u_short head; - u_short sec; - int newsec; - struct disklabel *dl = &disklabel; - - /* XXX */ - /* from wd.c */ - /* bt_cyl = cylinder number in sorted order */ - /* bt_trksec is actually (head << 8) + sec */ - - /* only remap sectors in the partition */ - if (sector < boff || sector >= boff + bsize) { - goto no_remap; - } - - cyl = sector / dl->d_secpercyl; - head = (sector % dl->d_secpercyl) / dl->d_nsectors; - sec = sector % dl->d_nsectors; - sec = (head<<8) + sec; - - /* now, look in the table for a possible bad sector */ - for (i=0; i<126; i++) { - if (dkb.bt_bad[i].bt_cyl == cyl) { - /* found same cylinder */ - if (dkb.bt_bad[i].bt_trksec == sec) { - /* FOUND! */ - break; - } - } else if (dkb.bt_bad[i].bt_cyl > cyl) { - i = 126; - break; - } - } - if (i == 126) { - /* didn't find bad sector */ - goto no_remap; - } - /* otherwise find replacement sector */ - if (dl->d_partitions[BSD_PART].p_offset != 0) - newsec = dl->d_partitions[BAD144_PART].p_offset - + dl->d_partitions[BAD144_PART].p_size; - else - newsec = dl->d_secperunit; - newsec -= dl->d_nsectors + i + 1; - return newsec; - } -#endif DO_BAD144 - no_remap: - return sector; -} diff --git a/sys/i386/boot/io.c b/sys/i386/boot/io.c deleted file mode 100644 index ce2b1fe..0000000 --- a/sys/i386/boot/io.c +++ /dev/null @@ -1,225 +0,0 @@ - -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:57 rpd - * $Id: io.c,v 1.8 1994/09/18 07:39:55 swallace Exp $ - */ - -#include <machine/cpufunc.h> - -#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ -#define K_STATUS 0x64 /* keyboard status */ -#define K_CMD 0x64 /* keybd ctlr command (write-only) */ - -#define K_OBUF_FUL 0x01 /* output buffer full */ -#define K_IBUF_FUL 0x02 /* input buffer full */ - -#define KC_CMD_WIN 0xd0 /* read output port */ -#define KC_CMD_WOUT 0xd1 /* write output port */ -#define KB_A20 0xdf /* enable A20, - enable output buffer full interrupt - enable data line - enable clock line */ - -/* - * Gate A20 for high memory - */ -unsigned char x_20 = KB_A20; -gateA20() -{ -#ifdef IBM_L40 - outb(0x92, 0x2); -#else IBM_L40 - while (inb(K_STATUS) & K_IBUF_FUL); - while (inb(K_STATUS) & K_OBUF_FUL) - (void)inb(K_RDWR); - - outb(K_CMD, KC_CMD_WOUT); - while (inb(K_STATUS) & K_IBUF_FUL); - outb(K_RDWR, x_20); - while (inb(K_STATUS) & K_IBUF_FUL); -#endif IBM_L40 -} - -/* printf - only handles %d as decimal, %c as char, %s as string */ - -printf(format,data) - char *format; - int data; -{ - int *dataptr = &data; - char c; - - reset_twiddle(); - while (c = *format++) - if (c != '%') - putchar(c); - else - switch (c = *format++) { - case 'd': { - int num = *dataptr++; - char buf[10], *ptr = buf; - if (num<0) { - num = -num; - putchar('-'); - } - do - *ptr++ = '0'+num%10; - while (num /= 10); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'x': { - int num = *dataptr++, dig; - char buf[8], *ptr = buf; - do - *ptr++ = (dig=(num&0xf)) > 9? - 'a' + dig - 10 : - '0' + dig; - while (num >>= 4); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'c': putchar((*dataptr++)&0xff); break; - case 's': { - char *ptr = (char *)*dataptr++; - while (c = *ptr++) - putchar(c); - break; - } - } -} - -putchar(c) -{ - if (c == '\n') - putc('\r'); - putc(c); -} - -getchar() -{ - int c; - - if ((c=getc()) == '\r') - c = '\n'; - if (c == '\b') { - putchar('\b'); - putchar(' '); - } - putchar(c); - return(c); -} - -#if BOOTWAIT -/* - * This routine uses an inb to an unused port, the time to execute that - * inb is approximately 1.25uS. This value is pretty constant across - * all CPU's and all buses, with the exception of some PCI implentations - * that do not forward this I/O adress to the ISA bus as they know it - * is not a valid ISA bus address, those machines execute this inb in - * 60 nS :-(. - * - * XXX we need to use BIOS timer calls or something more reliable to - * produce timeouts in the boot code. - */ -delay1ms() -{ - int i = 800; - while (--i >= 0) - (void)inb(0x84); -} -#endif - -gets(buf) -char *buf; -{ - int i; - char *ptr=buf; - -#if BOOTWAIT - for (i = BOOTWAIT; i>0; delay1ms(),i--) -#endif - if (ischar()) - for (;;) - switch(*ptr = getchar() & 0xff) { - case '\n': - case '\r': - *ptr = '\0'; - return 1; - case '\b': - if (ptr > buf) ptr--; - continue; - default: - ptr++; - } - return 0; -} - -strcmp(s1, s2) -char *s1, *s2; -{ - while (*s1 == *s2) { - if (!*s1++) - return 0; - s2++; - } - return 1; -} - -bcopy(from, to, len) -char *from, *to; -int len; -{ - while (len-- > 0) - *to++ = *from++; -} - -static int tw_on; -static int tw_pos; -static char tw_chars[] = "|/-\\"; - -reset_twiddle() -{ - if (tw_on) - putchar('\b'); - tw_on = 0; - tw_pos = 0; -} - -twiddle() -{ - if (tw_on) - putchar('\b'); - else - tw_on = 1; - putchar(tw_chars[tw_pos++]); - tw_pos %= (sizeof(tw_chars) - 1); -} diff --git a/sys/i386/boot/netboot/509.doc b/sys/i386/boot/netboot/509.doc deleted file mode 100644 index 1908c64..0000000 --- a/sys/i386/boot/netboot/509.doc +++ /dev/null @@ -1,21 +0,0 @@ -During adding of 3C509 support I made following changes: - -1) File if_epreg.h added - it is slightly different from one in -/usr/src/sys/i386/isa ! - -2) Support of 3C509 added to ether.c - -3) Flag -DINCLUDE_3C509 added (to ether.h, ether.c, Makefile) - -4) Routine eth_fillname() added to ether.c because 3C509 has -different driver (ep0 instead of ed0). Main.c was changed -according to this. - -I had tested this version with 3C509 only, but I see no reasons -why it must not work with other cards. - -But don't try to link it for both 3C509 and 8390-based cards. In -this case object file grows behind 16K and everything fails -to work. I don't know how correct this trouble. - - Serge Babkin (babkin@hq.icb.chel.su) diff --git a/sys/i386/boot/netboot/ether.c b/sys/i386/boot/netboot/ether.c deleted file mode 100644 index 1077ab0..0000000 --- a/sys/i386/boot/netboot/ether.c +++ /dev/null @@ -1,1243 +0,0 @@ - -/************************************************************************** -NETBOOT - BOOTP/TFTP Bootstrap Program - -Author: Martin Renters. - Date: Mar 22 1995 - - This code is based heavily on David Greenman's if_ed.c driver and - Andres Vega Garcia's if_ep.c driver. - - Copyright (C) 1993-1994, David Greenman, Martin Renters. - Copyright (C) 1993-1995, Andres Vega Garcia. - Copyright (C) 1995, Serge Babkin. - This software may be used, modified, copied, distributed, and sold, in - both source and binary form provided that the above copyright and these - terms are retained. Under no circumstances are the authors responsible for - the proper functioning of this software, nor do the authors assume any - responsibility for damages incurred with its use. - -3c503 support added by Bill Paul (wpaul@ctr.columbia.edu) on 11/15/94 -SMC8416 support added by Bill Paul (wpaul@ctr.columbia.edu) on 12/25/94 -3c509 support added by Serge Babkin (babkin@hq.icb.chel.su) on 03/22/95 - -***************************************************************************/ - -/* #define EDEBUG */ - -#include "netboot.h" -#include "ether.h" - -#ifdef INCLUDE_3C509 -# include "if_epreg.h" -#endif - -extern short aui; -char bnc=0, utp=0; /* for 3C509 */ -unsigned short eth_nic_base; -unsigned short eth_asic_base; -unsigned short eth_base; -unsigned char eth_tx_start; -unsigned char eth_laar; -unsigned char eth_flags; -unsigned char eth_vendor; -unsigned char eth_memsize; -unsigned char *eth_bmem; -unsigned char *eth_rmem; -unsigned char *eth_node_addr; - -#ifdef INCLUDE_3C509 - -static send_ID_sequence(); -static get_eeprom_data(); -static get_e(); - -#endif - -/************************************************************************** -The following two variables are used externally -***************************************************************************/ -char packet[ETH_MAX_PACKET]; -int packetlen; - -/************************************************************************* -ETH_FILLNAME - Fill name of adapter in NFS structure -**************************************************************************/ - -eth_fillname(where) -char *where; -{ - switch(eth_vendor) { - case VENDOR_3C509: - where[0]='e'; where[1]='p'; where[2]='0'; where[3]=0; - break; - case VENDOR_WD: - case VENDOR_NOVELL: - case VENDOR_3COM: - where[0]='e'; where[1]='d'; where[2]='0'; where[3]=0; - break; - default: - where[0]='?'; where[1]='?'; where[2]='?'; where[3]=0; - break; - } -} - -/************************************************************************** -ETH_PROBE - Look for an adapter -***************************************************************************/ -eth_probe() -{ - /* common variables */ - int i; -#ifdef INCLUDE_3C509 - /* variables for 3C509 */ - int data, j, io_base, id_port = EP_ID_PORT; - int nisa = 0, neisa = 0; - u_short k; - int ep_current_tag = EP_LAST_TAG + 1; - short *p; -#endif -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - /* varaibles for 8390 */ - struct wd_board *brd; - char *name; - unsigned short chksum; - unsigned char c; -#endif - - eth_vendor = VENDOR_NONE; - -#ifdef INCLUDE_3C509 - - /********************************************************* - Search for 3Com 509 card - ***********************************************************/ - - /* Look for the EISA boards, leave them activated */ - /* search for the first card, ignore all others */ - for(j = 1; j < 16 && eth_vendor==VENDOR_NONE ; j++) { - io_base = (j * EP_EISA_START) | EP_EISA_W0; - if (inw(io_base + EP_W0_MFG_ID) != MFG_ID) - continue; - - /* we must found 0x1f if the board is EISA configurated */ - if ((inw(io_base + EP_W0_ADDRESS_CFG) & 0x1f) != 0x1f) - continue; - - /* Reset and Enable the card */ - outb(io_base + EP_W0_CONFIG_CTRL, W0_P4_CMD_RESET_ADAPTER); - DELAY(1000); /* we must wait at least 1 ms */ - outb(io_base + EP_W0_CONFIG_CTRL, W0_P4_CMD_ENABLE_ADAPTER); - - /* - * Once activated, all the registers are mapped in the range - * x000 - x00F, where x is the slot number. - */ - eth_base = j * EP_EISA_START; - eth_vendor = VENDOR_3C509; - } - ep_current_tag--; - - /* Look for the ISA boards. Init and leave them actived */ - /* search for the first card, ignore all others */ - outb(id_port, 0xc0); /* Global reset */ - DELAY(1000); - for (i = 0; i < EP_MAX_BOARDS && eth_vendor==VENDOR_NONE; i++) { - outb(id_port, 0); - outb(id_port, 0); - send_ID_sequence(id_port); - - data = get_eeprom_data(id_port, EEPROM_MFG_ID); - if (data != MFG_ID) - break; - - /* resolve contention using the Ethernet address */ - for (j = 0; j < 3; j++) - data = get_eeprom_data(id_port, j); - - eth_base = - (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x10 + 0x200; - outb(id_port, ep_current_tag); /* tags board */ - outb(id_port, ACTIVATE_ADAPTER_TO_CONFIG); - eth_vendor = VENDOR_3C509; - ep_current_tag--; - } - - if(eth_vendor != VENDOR_3C509) - goto no3c509; - - /* - * The iobase was found and MFG_ID was 0x6d50. PROD_ID should be - * 0x9[0-f]50 - */ - GO_WINDOW(0); - k = get_e(EEPROM_PROD_ID); - if ((k & 0xf0ff) != (PROD_ID & 0xf0ff)) - goto no3c509; - - if(eth_base >= EP_EISA_START) { - printf("3C5x9 board on EISA at 0x%x - ",eth_base); - } else { - printf("3C5x9 board on ISA at 0x%x - ",eth_base); - } - - /* test for presence of connectors */ - i = inw(IS_BASE + EP_W0_CONFIG_CTRL); - j = inw(IS_BASE + EP_W0_ADDRESS_CFG) >> 14; - - switch(j) { - case 0: - if(i & IS_UTP) { - printf("10baseT\r\n"); - utp=1; - } - else { - printf("10baseT not present\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - - break; - case 1: - if(i & IS_AUI) - printf("10base5\r\n"); - else { - printf("10base5 not present\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - - break; - case 3: - if(i & IS_BNC) { - printf("10base2\r\n"); - bnc=1; - } - else { - printf("10base2 not present\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - - break; - default: - printf("unknown connector\r\n"); - eth_vendor=VENDOR_NONE; - goto no3c509; - } - /* - * Read the station address from the eeprom - */ - p = (u_short *) arptable[ARP_CLIENT].node; - for (i = 0; i < 3; i++) { - GO_WINDOW(0); - p[i] = htons(get_e(i)); - GO_WINDOW(2); - outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i])); - } - - printf("Ethernet address: "); - for(i=0; i<5; i++) { - printf("%b:",arptable[ARP_CLIENT].node[i]); - } - printf("%b\n",arptable[ARP_CLIENT].node[i]); - - eth_node_addr = arptable[ARP_CLIENT].node; - eth_reset(); - return eth_vendor; -no3c509: - eth_vendor = VENDOR_NONE; -#endif - -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) -#ifdef INCLUDE_WD - /****************************************************************** - Search for WD/SMC cards - *******************************************************************/ - for (eth_asic_base = WD_LOW_BASE; eth_asic_base <= WD_HIGH_BASE; - eth_asic_base += 0x20) { - chksum = 0; - for (i=8; i<16; i++) - chksum += inb(i+eth_asic_base); - if ((chksum & 0x00FF) == 0x00FF) - break; - } - if (eth_asic_base <= WD_HIGH_BASE) { /* We've found a board */ - eth_vendor = VENDOR_WD; - eth_nic_base = eth_asic_base + WD_NIC_ADDR; - c = inb(eth_asic_base+WD_BID); /* Get board id */ - for (brd = wd_boards; brd->name; brd++) - if (brd->id == c) break; - if (!brd->name) { - printf("\r\nUnknown Ethernet type %x\r\n", c); - return(0); /* Unknown type */ - } - eth_flags = brd->flags; - eth_memsize = brd->memsize; - eth_tx_start = 0; - if ((c == TYPE_WD8013EP) && - (inb(eth_asic_base + WD_ICR) & WD_ICR_16BIT)) { - eth_flags = FLAG_16BIT; - eth_memsize = MEM_16384; - } - if ((c & WD_SOFTCONFIG) && (!(eth_flags & FLAG_790))) { - eth_bmem = (char *)(0x80000 | - ((inb(eth_asic_base + WD_MSR) & 0x3F) << 13)); - } else - eth_bmem = (char *)WD_DEFAULT_MEM; - if (brd->id == TYPE_SMC8216T || brd->id == TYPE_SMC8216C) { - (unsigned int) *(eth_bmem + 8192) = (unsigned int)0; - if ((unsigned int) *(eth_bmem + 8192)) { - brd += 2; - eth_memsize = brd->memsize; - } - } - outb(eth_asic_base + WD_MSR, 0x80); /* Reset */ - printf("\r\n%s base 0x%x, memory 0x%X, addr ", - brd->name, eth_asic_base, eth_bmem); - for (i=0; i<6; i++) { - printf("%b",(int)(arptable[ARP_CLIENT].node[i] = - inb(i+eth_asic_base+WD_LAR))); - if (i < 5) printf (":"); - } - if (eth_flags & FLAG_790) { - outb(eth_asic_base+WD_MSR, WD_MSR_MENB); - outb(eth_asic_base+0x04, (inb(eth_asic_base+0x04) | - 0x80)); - outb(eth_asic_base+0x0B, - (((unsigned)eth_bmem >> 13) & 0x0F) | - (((unsigned)eth_bmem >> 11) & 0x40) | - (inb(eth_asic_base+0x0B) & 0xB0)); - outb(eth_asic_base+0x04, (inb(eth_asic_base+0x04) & - ~0x80)); - } else { - outb(eth_asic_base+WD_MSR, - (((unsigned)eth_bmem >> 13) & 0x3F) | 0x40); - } - if (eth_flags & FLAG_16BIT) { - if (eth_flags & FLAG_790) { - eth_laar = inb(eth_asic_base + WD_LAAR); - outb(eth_asic_base + WD_LAAR, WD_LAAR_M16EN); - inb(0x84); - } else { - outb(eth_asic_base + WD_LAAR, (eth_laar = - WD_LAAR_M16EN | WD_LAAR_L16EN | 1)); - } - } - printf("\r\n"); - - } -#endif -#ifdef INCLUDE_3COM - /****************************************************************** - Search for 3Com 3c503 if no WD/SMC cards - *******************************************************************/ - if (eth_vendor == VENDOR_NONE) { - eth_asic_base = _3COM_BASE + _3COM_ASIC_OFFSET; - eth_nic_base = _3COM_BASE; - eth_vendor = VENDOR_3COM; - /* - * Note that we use the same settings for both 8 and 16 bit cards: - * both have an 8K bank of memory at page 1 while only the 16 bit - * cards have a bank at page 0. - */ - eth_memsize = MEM_16384; - eth_tx_start = 32; - - /* Check our base address */ - - switch(inb(eth_asic_base + _3COM_BCFR)) { - case _3COM_BCFR_300: - if ((int)eth_nic_base != 0x300) - return(0); - break; - case _3COM_BCFR_310: - if ((int)eth_nic_base != 0x310) - return(0); - break; - case _3COM_BCFR_330: - if ((int)eth_nic_base != 0x330) - return(0); - break; - case _3COM_BCFR_350: - if ((int)eth_nic_base != 0x350) - return(0); - break; - case _3COM_BCFR_250: - if ((int)eth_nic_base != 0x250) - return(0); - break; - case _3COM_BCFR_280: - if ((int)eth_nic_base != 0x280) - return(0); - break; - case _3COM_BCFR_2A0: - if ((int)eth_nic_base != 0x2a0) - return(0); - break; - case _3COM_BCFR_2E0: - if ((int)eth_nic_base != 0x2e0) - return(0); - break; - default: - return (0); - } - - /* Now get the shared memory address */ - - switch (inb(eth_asic_base + _3COM_PCFR)) { - case _3COM_PCFR_DC000: - eth_bmem = (char *)0xdc000; - break; - case _3COM_PCFR_D8000: - eth_bmem = (char *)0xd8000; - break; - case _3COM_PCFR_CC000: - eth_bmem = (char *)0xcc000; - break; - case _3COM_PCFR_C8000: - eth_bmem = (char *)0xc8000; - break; - default: - return (0); - } - - /* Need this to make eth_poll() happy. */ - - eth_rmem = eth_bmem - 0x2000; - - /* Reset NIC and ASIC */ - - outb (eth_asic_base + _3COM_CR , _3COM_CR_RST | _3COM_CR_XSEL); - outb (eth_asic_base + _3COM_CR , _3COM_CR_XSEL); - - /* Get our ethernet address */ - - outb(eth_asic_base + _3COM_CR, _3COM_CR_EALO | _3COM_CR_XSEL); - printf("\r\n3Com 3c503 base 0x%x, memory 0x%X addr ", - eth_nic_base, eth_bmem); - for (i=0; i<6; i++) { - printf("%b",(int)(arptable[ARP_CLIENT].node[i] = - inb(eth_nic_base+i))); - if (i < 5) printf (":"); - } - outb(eth_asic_base + _3COM_CR, _3COM_CR_XSEL); - /* - * Initialize GA configuration register. Set bank and enable shared - * mem. We always use bank 1. - */ - outb(eth_asic_base + _3COM_GACFR, _3COM_GACFR_RSEL | - _3COM_GACFR_MBS0); - - outb(eth_asic_base + _3COM_VPTR2, 0xff); - outb(eth_asic_base + _3COM_VPTR1, 0xff); - outb(eth_asic_base + _3COM_VPTR0, 0x00); - /* - * Clear memory and verify that it worked (we use only 8K) - */ - bzero(eth_bmem, 0x2000); - for(i = 0; i < 0x2000; ++i) - if (*((eth_bmem)+i)) { - printf ("Failed to clear 3c503 shared mem.\r\n"); - return (0); - } - /* - * Initialize GA page/start/stop registers. - */ - outb(eth_asic_base + _3COM_PSTR, eth_tx_start); - outb(eth_asic_base + _3COM_PSPR, eth_memsize); - - printf ("\r\n"); - - } -#endif -#ifdef INCLUDE_NE - /****************************************************************** - Search for NE1000/2000 if no WD/SMC or 3com cards - *******************************************************************/ - if (eth_vendor == VENDOR_NONE) { - char romdata[16], testbuf[32]; - char test[] = "NE1000/2000 memory"; - eth_bmem = (char *)0; /* No shared memory */ - eth_asic_base = NE_BASE + NE_ASIC_OFFSET; - eth_nic_base = NE_BASE; - eth_vendor = VENDOR_NOVELL; - eth_flags = FLAG_PIO; - eth_memsize = MEM_16384; - eth_tx_start = 32; - c = inb(eth_asic_base + NE_RESET); - outb(eth_asic_base + NE_RESET, c); - inb(0x84); - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_STP | - D8390_COMMAND_RD2); - outb(eth_nic_base + D8390_P0_RCR, D8390_RCR_MON); - outb(eth_nic_base + D8390_P0_DCR, D8390_DCR_FT1 | D8390_DCR_LS); - outb(eth_nic_base + D8390_P0_PSTART, MEM_8192); - outb(eth_nic_base + D8390_P0_PSTOP, MEM_16384); - eth_pio_write(test, 8192, sizeof(test)); - eth_pio_read(8192, testbuf, sizeof(test)); - if (!bcompare(test, testbuf, sizeof(test))) { - eth_flags |= FLAG_16BIT; - eth_memsize = MEM_32768; - eth_tx_start = 64; - outb(eth_nic_base + D8390_P0_DCR, D8390_DCR_WTS | - D8390_DCR_FT1 | D8390_DCR_LS); - outb(eth_nic_base + D8390_P0_PSTART, MEM_16384); - outb(eth_nic_base + D8390_P0_PSTOP, MEM_32768); - eth_pio_write(test, 16384, sizeof(test)); - eth_pio_read(16384, testbuf, sizeof(test)); - if (!bcompare(testbuf, test, sizeof(test))) return (0); - } - eth_pio_read(0, romdata, 16); - printf("\r\nNE1000/NE2000 base 0x%x, addr ", eth_nic_base); - for (i=0; i<6; i++) { - printf("%b",(int)(arptable[ARP_CLIENT].node[i] = romdata[i - + ((eth_flags & FLAG_16BIT) ? i : 0)])); - if (i < 5) printf (":"); - } - printf("\r\n"); - } - if (eth_vendor == VENDOR_NONE) - goto no8390; - - if (eth_vendor != VENDOR_3COM) eth_rmem = eth_bmem; - eth_node_addr = arptable[ARP_CLIENT].node; - eth_reset(); - return(eth_vendor); -#endif /* NE */ -no8390: -#endif /*8390 */ - - return VENDOR_NONE; -} - -/************************************************************************** -ETH_RESET - Reset adapter -***************************************************************************/ -eth_reset() -{ - int s, i; - -#ifdef INCLUDE_3C509 - - /*********************************************************** - Reset 3Com 509 card - *************************************************************/ - - if(eth_vendor != VENDOR_3C509) - goto no3c509; - - /* stop card */ - outw(BASE + EP_COMMAND, RX_DISABLE); - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - outw(BASE + EP_COMMAND, TX_DISABLE); - outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - outw(BASE + EP_COMMAND, SET_RD_0_MASK); - outw(BASE + EP_COMMAND, SET_INTR_MASK); - outw(BASE + EP_COMMAND, SET_RX_FILTER); - - /* - /* initialize card - */ - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - - GO_WINDOW(0); - - /* Disable the card */ - outw(BASE + EP_W0_CONFIG_CTRL, 0); - - /* Configure IRQ to none */ - outw(BASE + EP_W0_RESOURCE_CFG, SET_IRQ(0)); - - /* Enable the card */ - outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); - - GO_WINDOW(2); - - /* Reload the ether_addr. */ - for (i = 0; i < 6; i++) - outb(BASE + EP_W2_ADDR_0 + i, arptable[ARP_CLIENT].node[i]); - - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - - /* Window 1 is operating window */ - GO_WINDOW(1); - for (i = 0; i < 31; i++) - inb(BASE + EP_W1_TX_STATUS); - - /* get rid of stray intr's */ - outw(BASE + EP_COMMAND, ACK_INTR | 0xff); - - outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS); - - outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS); - - outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | - FIL_BRDCST); - - /* configure BNC */ - if(bnc) { - outw(BASE + EP_COMMAND, START_TRANSCEIVER); - DELAY(1000); - } - /* configure UTP */ - if(utp) { - GO_WINDOW(4); - outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP); - GO_WINDOW(1); - } - - /* start tranciever and receiver */ - outw(BASE + EP_COMMAND, RX_ENABLE); - outw(BASE + EP_COMMAND, TX_ENABLE); - - /* set early threshold for minimal packet length */ - outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | 64); - - outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16); - - return 1; -no3c509: - -#endif - -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - - /************************************************************** - Reset cards based on 8390 chip - ****************************************************************/ - - if(eth_vendor!=VENDOR_WD && eth_vendor!=VENDOR_NOVELL - && eth_vendor!=VENDOR_3COM) - goto no8390; - - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, - D8390_COMMAND_PS0 | D8390_COMMAND_STP); - else - outb(eth_nic_base+D8390_P0_COMMAND, - D8390_COMMAND_PS0 | D8390_COMMAND_RD2 | - D8390_COMMAND_STP); - if (eth_flags & FLAG_16BIT) - outb(eth_nic_base+D8390_P0_DCR, 0x49); - else - outb(eth_nic_base+D8390_P0_DCR, 0x48); - outb(eth_nic_base+D8390_P0_RBCR0, 0); - outb(eth_nic_base+D8390_P0_RBCR1, 0); - outb(eth_nic_base+D8390_P0_RCR, 4); /* allow broadcast frames */ - outb(eth_nic_base+D8390_P0_TCR, 2); - outb(eth_nic_base+D8390_P0_TPSR, eth_tx_start); - outb(eth_nic_base+D8390_P0_PSTART, eth_tx_start + D8390_TXBUF_SIZE); - if (eth_flags & FLAG_790) outb(eth_nic_base + 0x09, 0); - outb(eth_nic_base+D8390_P0_PSTOP, eth_memsize); - outb(eth_nic_base+D8390_P0_BOUND, eth_tx_start + D8390_TXBUF_SIZE); - outb(eth_nic_base+D8390_P0_ISR, 0xFF); - outb(eth_nic_base+D8390_P0_IMR, 0); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1 | - D8390_COMMAND_STP); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1 | - D8390_COMMAND_RD2 | D8390_COMMAND_STP); - for (i=0; i<6; i++) - outb(eth_nic_base+D8390_P1_PAR0+i, eth_node_addr[i]); - for (i=0; i<6; i++) - outb(eth_nic_base+D8390_P1_MAR0+i, 0xFF); - outb(eth_nic_base+D8390_P1_CURR, eth_tx_start + D8390_TXBUF_SIZE+1); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_STA); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_RD2 | D8390_COMMAND_STA); - outb(eth_nic_base+D8390_P0_ISR, 0xFF); - outb(eth_nic_base+D8390_P0_TCR, 0); -#ifdef INCLUDE_3COM - if (eth_vendor == VENDOR_3COM) { - /* - * No way to tell whether or not we're supposed to use - * the 3Com's transceiver unless the user tells us. - * 'aui' should have some compile time default value - * which can be changed from the command menu. - */ - if (aui) - outb(eth_asic_base + _3COM_CR, 0); - else - outb(eth_asic_base + _3COM_CR, _3COM_CR_XSEL); - } -#endif - return(1); -no8390: -#endif /* 8390 */ -} - -/************************************************************************** -ETH_TRANSMIT - Transmit a frame -***************************************************************************/ -static const char padmap[] = { - 0, 3, 2, 1}; - -eth_transmit(d,t,s,p) -char *d; /* Destination */ -unsigned short t; /* Type */ -unsigned short s; /* size */ -char *p; /* Packet */ -{ - register u_int len; - int pad; - int status; - unsigned char c; - -#ifdef INCLUDE_3C509 - - if(eth_vendor != VENDOR_3C509) - goto no3c509; - -#ifdef EDEBUG - printf("{l=%d,t=%x}",s+14,t); -#endif - - /* swap bytes of type */ - t=(( t&0xFF )<<8) | ((t>>8) & 0xFF); - - len=s+14; /* actual length of packet */ - pad = padmap[len & 3]; - - /* - * The 3c509 automatically pads short packets to minimum ethernet length, - * but we drop packets that are too large. Perhaps we should truncate - * them instead? - */ - if (len + pad > ETHER_MAX_LEN) { - return 0; - } - - /* drop acknowledgements */ - while(( status=inb(BASE + EP_W1_TX_STATUS) )& TXS_COMPLETE ) { - if(status & (TXS_UNDERRUN|TXS_MAX_COLLISION|TXS_STATUS_OVERFLOW)) { - outw(BASE + EP_COMMAND, TX_RESET); - outw(BASE + EP_COMMAND, TX_ENABLE); - } - - outb(BASE + EP_W1_TX_STATUS, 0x0); - } - - while (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) { - /* no room in FIFO */ - } - - outw(BASE + EP_W1_TX_PIO_WR_1, len); - outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */ - - /* write packet */ - outsw(BASE + EP_W1_TX_PIO_WR_1, d, 3); - outsw(BASE + EP_W1_TX_PIO_WR_1, eth_node_addr, 3); - outw(BASE + EP_W1_TX_PIO_WR_1, t); - outsw(BASE + EP_W1_TX_PIO_WR_1, p, s / 2); - if (s & 1) - outb(BASE + EP_W1_TX_PIO_WR_1, *(p+s - 1)); - - while (pad--) - outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */ - - /* timeout after sending */ - DELAY(1000); - return 0; -no3c509: -#endif /* 3C509 */ - -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - - if(eth_vendor!=VENDOR_WD && eth_vendor!=VENDOR_NOVELL - && eth_vendor!=VENDOR_3COM) - goto no8390; - -#ifdef INCLUDE_3COM - if (eth_vendor == VENDOR_3COM) { - bcopy(d, eth_bmem, 6); /* dst */ - bcopy(eth_node_addr, eth_bmem+6, ETHER_ADDR_SIZE); /* src */ - *(eth_bmem+12) = t>>8; /* type */ - *(eth_bmem+13) = t; - bcopy(p, eth_bmem+14, s); - s += 14; - while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0; - } -#endif -#ifdef INCLUDE_WD - if (eth_vendor == VENDOR_WD) { /* Memory interface */ - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar | WD_LAAR_M16EN); - inb(0x84); - } - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, WD_MSR_MENB); - inb(0x84); - } - inb(0x84); - bcopy(d, eth_bmem, 6); /* dst */ - bcopy(eth_node_addr, eth_bmem+6, ETHER_ADDR_SIZE); /* src */ - *(eth_bmem+12) = t>>8; /* type */ - *(eth_bmem+13) = t; - bcopy(p, eth_bmem+14, s); - s += 14; - while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0; - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, 0); - inb(0x84); - } - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar & ~WD_LAAR_M16EN); - inb(0x84); - } - } -#endif -#ifdef INCLUDE_NE - if (eth_vendor == VENDOR_NOVELL) { /* Programmed I/O */ - unsigned short type; - type = (t >> 8) | (t << 8); - eth_pio_write(d, eth_tx_start<<8, 6); - eth_pio_write(eth_node_addr, (eth_tx_start<<8)+6, 6); - eth_pio_write(&type, (eth_tx_start<<8)+12, 2); - eth_pio_write(p, (eth_tx_start<<8)+14, s); - s += 14; - if (s < ETH_MIN_PACKET) s = ETH_MIN_PACKET; - } -#endif - twiddle(); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_STA); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_RD2 | D8390_COMMAND_STA); - outb(eth_nic_base+D8390_P0_TPSR, eth_tx_start); - outb(eth_nic_base+D8390_P0_TBCR0, s); - outb(eth_nic_base+D8390_P0_TBCR1, s>>8); - if (eth_flags & FLAG_790) - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_TXP | D8390_COMMAND_STA); - else - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0 | - D8390_COMMAND_TXP | D8390_COMMAND_RD2 | - D8390_COMMAND_STA); - return(0); - -no8390: -#endif /* 8390 */ -} - -/************************************************************************** -ETH_POLL - Wait for a frame -***************************************************************************/ -eth_poll() -{ - /* common variables */ - unsigned short type = 0; - unsigned short len; - /* variables for 3C509 */ -#ifdef INCLUDE_3C509 - struct ether_header *eh; - int lenthisone; - short rx_fifo2, status, cst; - register short rx_fifo; -#endif - /* variables for 8390 */ -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - int ret = 0; - unsigned char bound,curr,rstat; - unsigned short pktoff; - unsigned char *p; - struct ringbuffer pkthdr; -#endif - -#ifdef INCLUDE_3C509 - - if(eth_vendor!=VENDOR_3C509) - goto no3c509; - - cst=inw(BASE + EP_STATUS); - -#ifdef EDEBUG - if(cst & 0x1FFF) - printf("-%x-",cst); -#endif - - if( (cst & (S_RX_COMPLETE|S_RX_EARLY) )==0 ) { - /* acknowledge everything */ - outw(BASE + EP_COMMAND, ACK_INTR| (cst & S_5_INTS)); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - - return 0; - } - - status = inw(BASE + EP_W1_RX_STATUS); -#ifdef EDEBUG - printf("*%x*",status); -#endif - - if (status & ERR_RX) { - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - return 0; - } - - rx_fifo = status & RX_BYTES_MASK; - if (rx_fifo==0) - return 0; - - /* read packet */ -#ifdef EDEBUG - printf("[l=%d",rx_fifo); -#endif - insw(BASE + EP_W1_RX_PIO_RD_1, packet, rx_fifo / 2); - if(rx_fifo & 1) - packet[rx_fifo-1]=inb(BASE + EP_W1_RX_PIO_RD_1); - packetlen=rx_fifo; - - while(1) { - status = inw(BASE + EP_W1_RX_STATUS); -#ifdef EDEBUG - printf("*%x*",status); -#endif - rx_fifo = status & RX_BYTES_MASK; - - if(rx_fifo>0) { - insw(BASE + EP_W1_RX_PIO_RD_1, packet+packetlen, rx_fifo / 2); - if(rx_fifo & 1) - packet[packetlen+rx_fifo-1]=inb(BASE + EP_W1_RX_PIO_RD_1); - packetlen+=rx_fifo; -#ifdef EDEBUG - printf("+%d",rx_fifo); -#endif - } - - if(( status & RX_INCOMPLETE )==0) { -#ifdef EDEBUG - printf("=%d",packetlen); -#endif - break; - } - - DELAY(1000); - } - - /* acknowledge reception of packet */ - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - - type = (packet[12]<<8) | packet[13]; - -#ifdef EDEBUG - if(packet[0]+packet[1]+packet[2]+packet[3]+packet[4]+ - packet[5] == 0xFF*6) - printf(",t=0x%x,b]",type); - else - printf(",t=0x%x]",type); -#endif - - - if (type == ARP) { - struct arprequest *arpreq; - unsigned long reqip; - - arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE]; - -#ifdef EDEBUG - printf("(ARP %I->%I)",ntohl(*(int*)arpreq->sipaddr), - ntohl(*(int*)arpreq->tipaddr)); -#endif - - convert_ipaddr(&reqip, arpreq->tipaddr); - if ((ntohs(arpreq->opcode) == ARP_REQUEST) && - (reqip == arptable[ARP_CLIENT].ipaddr)) { - arpreq->opcode = htons(ARP_REPLY); - bcopy(arpreq->sipaddr, arpreq->tipaddr, 4); - bcopy(arpreq->shwaddr, arpreq->thwaddr, 6); - bcopy(arptable[ARP_CLIENT].node, arpreq->shwaddr, 6); - convert_ipaddr(arpreq->sipaddr, &reqip); - eth_transmit(arpreq->thwaddr, ARP, sizeof(struct arprequest), - arpreq); - return(0); - } - } else if(type==IP) { - struct iphdr *iph; - - iph = (struct iphdr *)&packet[ETHER_HDR_SIZE]; -#ifdef EDEBUG - printf("(IP %I-%d->%I)",ntohl(*(int*)iph->src), - ntohs(iph->protocol),ntohl(*(int*)iph->dest)); -#endif - } - - return 1; - -no3c509: -#endif /* 3C509 */ -#if defined(INCLUDE_3COM) || defined(INCLUDE_WD) || defined(INCLUDE_NE) - - if(eth_vendor!=VENDOR_WD && eth_vendor!=VENDOR_NOVELL - && eth_vendor!=VENDOR_3COM) - goto no8390; - - rstat = inb(eth_nic_base+D8390_P0_RSR); - if (rstat & D8390_RSTAT_OVER) { - eth_reset(); - return(0); - } - if (!(rstat & D8390_RSTAT_PRX)) return(0); - bound = inb(eth_nic_base+D8390_P0_BOUND)+1; - if (bound == eth_memsize) bound = eth_tx_start + D8390_TXBUF_SIZE; - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS1); - curr = inb(eth_nic_base+D8390_P1_CURR); - outb(eth_nic_base+D8390_P0_COMMAND, D8390_COMMAND_PS0); - if (curr == eth_memsize) curr=eth_tx_start + D8390_TXBUF_SIZE; - if (curr == bound) return(0); - if (eth_vendor == VENDOR_WD) { - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar | WD_LAAR_M16EN); - inb(0x84); - } - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, WD_MSR_MENB); - inb(0x84); - } - inb(0x84); - } - pktoff = (bound << 8); - if (eth_flags & FLAG_PIO) - eth_pio_read(pktoff, &pkthdr, 4); - else - bcopy(eth_rmem + pktoff, &pkthdr, 4); - len = pkthdr.len - 4; /* sub CRC */ - pktoff += 4; - if (len > 1514) len = 1514; - bound = pkthdr.bound; /* New bound ptr */ - if ( (pkthdr.status & D8390_RSTAT_PRX) && (len > 14) && (len < 1518)) { - p = packet; - packetlen = len; - len = (eth_memsize << 8) - pktoff; - if (packetlen > len) { /* We have a wrap-around */ - if (eth_flags & FLAG_PIO) - eth_pio_read(pktoff, p, len); - else - bcopy(eth_rmem + pktoff, p, len); - pktoff = (eth_tx_start + D8390_TXBUF_SIZE) << 8; - p += len; - packetlen -= len; - } - if (eth_flags & FLAG_PIO) - eth_pio_read(pktoff, p, packetlen); - else - bcopy(eth_rmem + pktoff, p, packetlen); - - type = (packet[12]<<8) | packet[13]; - ret = 1; - } - if (eth_vendor == VENDOR_WD) { - if (eth_flags & FLAG_790) { - outb(eth_asic_base + WD_MSR, 0); - inb(0x84); - } - if (eth_flags & FLAG_16BIT) { - outb(eth_asic_base + WD_LAAR, eth_laar & - ~WD_LAAR_M16EN); - inb(0x84); - } - inb(0x84); - } - if (bound == (eth_tx_start + D8390_TXBUF_SIZE)) - bound = eth_memsize; - outb(eth_nic_base+D8390_P0_BOUND, bound-1); - if (ret && (type == ARP)) { - struct arprequest *arpreq; - unsigned long reqip; - arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE]; - convert_ipaddr(&reqip, arpreq->tipaddr); - if ((ntohs(arpreq->opcode) == ARP_REQUEST) && - (reqip == arptable[ARP_CLIENT].ipaddr)) { - arpreq->opcode = htons(ARP_REPLY); - bcopy(arpreq->sipaddr, arpreq->tipaddr, 4); - bcopy(arpreq->shwaddr, arpreq->thwaddr, 6); - bcopy(arptable[ARP_CLIENT].node, arpreq->shwaddr, 6); - convert_ipaddr(arpreq->sipaddr, &reqip); - eth_transmit(arpreq->thwaddr, ARP, sizeof(struct arprequest), - arpreq); - return(0); - } - } - return(ret); -no8390: -#endif /* 8390 */ -} - -#ifdef INCLUDE_NE -/************************************************************************** -NE1000/NE2000 Support Routines -***************************************************************************/ - -/* inw and outw are not needed more - standard version of them is used */ - -/************************************************************************** -ETH_PIO_READ - Read a frame via Programmed I/O -***************************************************************************/ -eth_pio_read(src, dst, cnt, init) -unsigned short src; -unsigned char *dst; -unsigned short cnt; -int init; -{ - if (cnt & 1) cnt++; - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD2 | - D8390_COMMAND_STA); - outb(eth_nic_base + D8390_P0_RBCR0, cnt); - outb(eth_nic_base + D8390_P0_RBCR1, cnt>>8); - outb(eth_nic_base + D8390_P0_RSAR0, src); - outb(eth_nic_base + D8390_P0_RSAR1, src>>8); - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD0 | - D8390_COMMAND_STA); - if (eth_flags & FLAG_16BIT) { - while (cnt) { - *((unsigned short *)dst) = inw(eth_asic_base + NE_DATA); - dst += 2; - cnt -= 2; - } - } - else { - while (cnt--) - *(dst++) = inb(eth_asic_base + NE_DATA); - } -} - -/************************************************************************** -ETH_PIO_WRITE - Write a frame via Programmed I/O -***************************************************************************/ -eth_pio_write(src, dst, cnt, init) -unsigned char *src; -unsigned short dst; -unsigned short cnt; -int init; -{ - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD2 | - D8390_COMMAND_STA); - outb(eth_nic_base + D8390_P0_ISR, D8390_ISR_RDC); - outb(eth_nic_base + D8390_P0_RBCR0, cnt); - outb(eth_nic_base + D8390_P0_RBCR1, cnt>>8); - outb(eth_nic_base + D8390_P0_RSAR0, dst); - outb(eth_nic_base + D8390_P0_RSAR1, dst>>8); - outb(eth_nic_base + D8390_P0_COMMAND, D8390_COMMAND_RD1 | - D8390_COMMAND_STA); - if (eth_flags & FLAG_16BIT) { - if (cnt & 1) cnt++; /* Round up */ - while (cnt) { - outw(eth_asic_base + NE_DATA, *((unsigned short *)src)); - src += 2; - cnt -= 2; - } - } - else { - while (cnt--) - outb(eth_asic_base + NE_DATA, *(src++)); - } - while((inb(eth_nic_base + D8390_P0_ISR) & D8390_ISR_RDC) - != D8390_ISR_RDC); -} -#else -/************************************************************************** -ETH_PIO_READ - Dummy routine when NE2000 not compiled in -***************************************************************************/ -eth_pio_read() { -} -#endif - -#ifdef INCLUDE_3C509 -/************************************************************************* - 3Com 509 - specific routines -**************************************************************************/ - -static int -eeprom_rdy() -{ - int i; - - for (i = 0; is_eeprom_busy(IS_BASE) && i < MAX_EEPROMBUSY; i++); - if (i >= MAX_EEPROMBUSY) { - printf("3c509: eeprom failed to come ready.\r\n"); - return (0); - } - return (1); -} - -/* - * get_e: gets a 16 bits word from the EEPROM. we must have set the window - * before - */ -static int -get_e(offset) -int offset; -{ - if (!eeprom_rdy()) - return (0xffff); - outw(IS_BASE + EP_W0_EEPROM_COMMAND, EEPROM_CMD_RD | offset); - if (!eeprom_rdy()) - return (0xffff); - return (inw(IS_BASE + EP_W0_EEPROM_DATA)); -} - -static int -send_ID_sequence(port) -int port; -{ - int cx, al; - - for (al = 0xff, cx = 0; cx < 255; cx++) { - outb(port, al); - al <<= 1; - if (al & 0x100) - al ^= 0xcf; - } - return (1); -} - - -/* - * We get eeprom data from the id_port given an offset into the eeprom. - * Basically; after the ID_sequence is sent to all of the cards; they enter - * the ID_CMD state where they will accept command requests. 0x80-0xbf loads - * the eeprom data. We then read the port 16 times and with every read; the - * cards check for contention (ie: if one card writes a 0 bit and another - * writes a 1 bit then the host sees a 0. At the end of the cycle; each card - * compares the data on the bus; if there is a difference then that card goes - * into ID_WAIT state again). In the meantime; one bit of data is returned in - * the AX register which is conveniently returned to us by inb(). Hence; we - * read 16 times getting one bit of data with each read. - */ -static int -get_eeprom_data(id_port, offset) -int id_port; -int offset; -{ - int i, data = 0; - outb(id_port, 0x80 + offset); - DELAY(1000); - for (i = 0; i < 16; i++) - data = (data << 1) | (inw(id_port) & 1); - return (data); -} - -/* a surrogate */ - -DELAY(val) -{ - int c; - - for(c=0; c<val; c+=20) { - twiddle(); - } -} - -#endif - diff --git a/sys/i386/boot/netboot/ether.h b/sys/i386/boot/netboot/ether.h deleted file mode 100644 index 8cd4df4..0000000 --- a/sys/i386/boot/netboot/ether.h +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************************** -NETBOOT - BOOTP/TFTP Bootstrap Program - -Author: Martin Renters - Date: Jun/94 - -**************************************************************************/ - -#define TRUE 1 -#define FALSE 0 - -#define ETH_MIN_PACKET 64 -#define ETH_MAX_PACKET 1518 - -#define VENDOR_NONE 0 -#define VENDOR_WD 1 -#define VENDOR_NOVELL 2 -#define VENDOR_3COM 3 -#define VENDOR_3C509 4 - -#define FLAG_PIO 0x01 -#define FLAG_16BIT 0x02 -#define FLAG_790 0x04 - -#define MEM_8192 32 -#define MEM_16384 64 -#define MEM_32768 128 - -/************************************************************************** -Western Digital/SMC Board Definitions -**************************************************************************/ -#define WD_LOW_BASE 0x200 -#define WD_HIGH_BASE 0x3e0 -#ifndef WD_DEFAULT_MEM -#define WD_DEFAULT_MEM 0xD0000 -#endif -#define WD_NIC_ADDR 0x10 - -/************************************************************************** -Western Digital/SMC ASIC Addresses -**************************************************************************/ -#define WD_MSR 0x00 -#define WD_ICR 0x01 -#define WD_IAR 0x02 -#define WD_BIO 0x03 -#define WD_IRR 0x04 -#define WD_LAAR 0x05 -#define WD_IJR 0x06 -#define WD_GP2 0x07 -#define WD_LAR 0x08 -#define WD_BID 0x0E - -#define WD_ICR_16BIT 0x01 - -#define WD_MSR_MENB 0x40 - -#define WD_LAAR_L16EN 0x40 -#define WD_LAAR_M16EN 0x80 - -#define WD_SOFTCONFIG 0x20 - -/************************************************************************** -Western Digital/SMC Board Types -**************************************************************************/ -#define TYPE_WD8003S 0x02 -#define TYPE_WD8003E 0x03 -#define TYPE_WD8013EBT 0x05 -#define TYPE_WD8003W 0x24 -#define TYPE_WD8003EB 0x25 -#define TYPE_WD8013W 0x26 -#define TYPE_WD8013EP 0x27 -#define TYPE_WD8013WC 0x28 -#define TYPE_WD8013EPC 0x29 -#define TYPE_SMC8216T 0x2a -#define TYPE_SMC8216C 0x2b -#define TYPE_SMC8416T 0x00 /* Bogus entries: the 8416 generates the */ -#define TYPE_SMC8416C 0x00 /* the same codes as the 8216. */ -#define TYPE_SMC8013EBP 0x2c - -#ifdef INCLUDE_WD -struct wd_board { - char *name; - char id; - char flags; - char memsize; -} wd_boards[] = { - {"WD8003S", TYPE_WD8003S, 0, MEM_8192}, - {"WD8003E", TYPE_WD8003E, 0, MEM_8192}, - {"WD8013EBT", TYPE_WD8013EBT, FLAG_16BIT, MEM_16384}, - {"WD8003W", TYPE_WD8003W, 0, MEM_8192}, - {"WD8003EB", TYPE_WD8003EB, 0, MEM_8192}, - {"WD8013W", TYPE_WD8013W, FLAG_16BIT, MEM_16384}, - {"WD8003EP/WD8013EP", - TYPE_WD8013EP, 0, MEM_8192}, - {"WD8013WC", TYPE_WD8013WC, FLAG_16BIT, MEM_16384}, - {"WD8013EPC", TYPE_WD8013EPC, FLAG_16BIT, MEM_16384}, - {"SMC8216T", TYPE_SMC8216T, FLAG_16BIT | FLAG_790, MEM_16384}, - {"SMC8216C", TYPE_SMC8216C, FLAG_16BIT | FLAG_790, MEM_16384}, - {"SMC8416T", TYPE_SMC8416T, FLAG_16BIT | FLAG_790, MEM_8192}, - {"SMC8416C/BT", TYPE_SMC8416C, FLAG_16BIT | FLAG_790, MEM_8192}, - {"SMC8013EBP", TYPE_SMC8013EBP,FLAG_16BIT, MEM_16384}, - {NULL, 0, 0} -}; -#endif -/************************************************************************** -3com 3c503 definitions -**************************************************************************/ - -#ifndef _3COM_BASE -#define _3COM_BASE 0x300 -#endif - -#define _3COM_TX_PAGE_OFFSET_8BIT 0x20 -#define _3COM_TX_PAGE_OFFSET_16BIT 0x0 -#define _3COM_RX_PAGE_OFFSET_16BIT 0x20 - -#define _3COM_ASIC_OFFSET 0x400 -#define _3COM_NIC_OFFSET 0x0 - -#define _3COM_PSTR 0 -#define _3COM_PSPR 1 - -#define _3COM_BCFR 3 -#define _3COM_BCFR_2E0 0x01 -#define _3COM_BCFR_2A0 0x02 -#define _3COM_BCFR_280 0x04 -#define _3COM_BCFR_250 0x08 -#define _3COM_BCFR_350 0x10 -#define _3COM_BCFR_330 0x20 -#define _3COM_BCFR_310 0x40 -#define _3COM_BCFR_300 0x80 -#define _3COM_PCFR 4 -#define _3COM_PCFR_C8000 0x10 -#define _3COM_PCFR_CC000 0x20 -#define _3COM_PCFR_D8000 0x40 -#define _3COM_PCFR_DC000 0x80 -#define _3COM_CR 6 -#define _3COM_CR_RST 0x01 /* Reset GA and NIC */ -#define _3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */ -#define _3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */ -#define _3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */ -#define _3COM_CR_SHARE 0x10 /* select interrupt sharing option */ -#define _3COM_CR_DBSEL 0x20 /* Double buffer select */ -#define _3COM_CR_DDIR 0x40 /* DMA direction select */ -#define _3COM_CR_START 0x80 /* Start DMA controller */ -#define _3COM_GACFR 5 -#define _3COM_GACFR_MBS0 0x01 -#define _3COM_GACFR_MBS1 0x02 -#define _3COM_GACFR_MBS2 0x04 -#define _3COM_GACFR_RSEL 0x08 /* enable shared memory */ -#define _3COM_GACFR_TEST 0x10 /* for GA testing */ -#define _3COM_GACFR_OWS 0x20 /* select 0WS access to GA */ -#define _3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */ -#define _3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */ -#define _3COM_STREG 7 -#define _3COM_STREG_REV 0x07 /* GA revision */ -#define _3COM_STREG_DIP 0x08 /* DMA in progress */ -#define _3COM_STREG_DTC 0x10 /* DMA terminal count */ -#define _3COM_STREG_OFLW 0x20 /* Overflow */ -#define _3COM_STREG_UFLW 0x40 /* Underflow */ -#define _3COM_STREG_DPRDY 0x80 /* Data port ready */ -#define _3COM_IDCFR 8 -#define _3COM_IDCFR_DRQ0 0x01 /* DMA request 1 select */ -#define _3COM_IDCFR_DRQ1 0x02 /* DMA request 2 select */ -#define _3COM_IDCFR_DRQ2 0x04 /* DMA request 3 select */ -#define _3COM_IDCFR_UNUSED 0x08 /* not used */ -#define _3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */ -#define _3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */ -#define _3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */ -#define _3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */ -#define _3COM_IRQ2 2 -#define _3COM_IRQ3 3 -#define _3COM_IRQ4 4 -#define _3COM_IRQ5 5 -#define _3COM_DAMSB 9 -#define _3COM_DALSB 0x0a -#define _3COM_VPTR2 0x0b -#define _3COM_VPTR1 0x0c -#define _3COM_VPTR0 0x0d -#define _3COM_RFMSB 0x0e -#define _3COM_RFLSB 0x0f - -/************************************************************************** -NE1000/2000 definitions -**************************************************************************/ -#ifndef NE_BASE -#define NE_BASE 0x320 -#endif -#define NE_ASIC_OFFSET 0x10 -#define NE_RESET 0x0F /* Used to reset card */ -#define NE_DATA 0x00 /* Used to read/write NIC mem */ - -/************************************************************************** -8390 Register Definitions -**************************************************************************/ -#define D8390_P0_COMMAND 0x00 -#define D8390_P0_PSTART 0x01 -#define D8390_P0_PSTOP 0x02 -#define D8390_P0_BOUND 0x03 -#define D8390_P0_TSR 0x04 -#define D8390_P0_TPSR 0x04 -#define D8390_P0_TBCR0 0x05 -#define D8390_P0_TBCR1 0x06 -#define D8390_P0_ISR 0x07 -#define D8390_P0_RSAR0 0x08 -#define D8390_P0_RSAR1 0x09 -#define D8390_P0_RBCR0 0x0A -#define D8390_P0_RBCR1 0x0B -#define D8390_P0_RSR 0x0C -#define D8390_P0_RCR 0x0C -#define D8390_P0_TCR 0x0D -#define D8390_P0_DCR 0x0E -#define D8390_P0_IMR 0x0F -#define D8390_P1_COMMAND 0x00 -#define D8390_P1_PAR0 0x01 -#define D8390_P1_PAR1 0x02 -#define D8390_P1_PAR2 0x03 -#define D8390_P1_PAR3 0x04 -#define D8390_P1_PAR4 0x05 -#define D8390_P1_PAR5 0x06 -#define D8390_P1_CURR 0x07 -#define D8390_P1_MAR0 0x08 - -#define D8390_COMMAND_PS0 0x0 /* Page 0 select */ -#define D8390_COMMAND_PS1 0x40 /* Page 1 select */ -#define D8390_COMMAND_PS2 0x80 /* Page 2 select */ -#define D8390_COMMAND_RD2 0x20 /* Remote DMA control */ -#define D8390_COMMAND_RD1 0x10 -#define D8390_COMMAND_RD0 0x08 -#define D8390_COMMAND_TXP 0x04 /* transmit packet */ -#define D8390_COMMAND_STA 0x02 /* start */ -#define D8390_COMMAND_STP 0x01 /* stop */ - -#define D8390_RCR_MON 0x20 /* monitor mode */ - -#define D8390_DCR_FT1 0x40 -#define D8390_DCR_LS 0x08 /* Loopback select */ -#define D8390_DCR_WTS 0x01 /* Word transfer select */ - -#define D8390_ISR_PRX 0x01 /* successful recv */ -#define D8390_ISR_PTX 0x02 /* successful xmit */ -#define D8390_ISR_RXE 0x04 /* receive error */ -#define D8390_ISR_TXE 0x08 /* transmit error */ -#define D8390_ISR_OVW 0x10 /* Overflow */ -#define D8390_ISR_CNT 0x20 /* Counter overflow */ -#define D8390_ISR_RDC 0x40 /* Remote DMA complete */ -#define D8390_ISR_RST 0x80 /* reset */ - -#define D8390_RSTAT_PRX 0x01 /* successful recv */ -#define D8390_RSTAT_CRC 0x02 /* CRC error */ -#define D8390_RSTAT_FAE 0x04 /* Frame alignment error */ -#define D8390_RSTAT_OVER 0x08 /* overflow */ - -#define D8390_TXBUF_SIZE 6 -#define D8390_RXBUF_END 32 -#define D8390_PAGE_SIZE 256 - -struct ringbuffer { - unsigned char status; - unsigned char bound; - unsigned short len; -}; diff --git a/sys/i386/boot/netboot/if_epreg.h b/sys/i386/boot/netboot/if_epreg.h deleted file mode 100644 index 049f235..0000000 --- a/sys/i386/boot/netboot/if_epreg.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved. - * - * 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. The name - * of the author may not be used to endorse or promote products derived from - * this software withough 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. - * - * if_epreg.h,v 1.4 1994/11/13 10:12:37 gibbs Exp Modified by: - * - October 2, 1994 - - Modified by: Andres Vega Garcia - - INRIA - Sophia Antipolis, France - e-mail: avega@sophia.inria.fr - finger: avega@pax.inria.fr - - */ - -/* - * Ethernet software status per interface. - */ -/* - * Some global constants - */ -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -#define TX_INIT_RATE 16 -#define TX_INIT_MAX_RATE 64 -#define RX_INIT_LATENCY 64 -#define RX_INIT_EARLY_THRESH 64 -#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */ -#define MIN_RX_EARLY_THRESHL 4 - -#define EEPROMSIZE 0x40 -#define MAX_EEPROMBUSY 1000 -#define EP_LAST_TAG 0xd7 -#define EP_MAX_BOARDS 16 -#define EP_ID_PORT 0x100 - -/* - * some macros to acces long named fields - */ -#define IS_BASE (eth_base) -#define BASE (eth_base) - -/* - * Commands to read/write EEPROM trough EEPROM command register (Window 0, - * Offset 0xa) - */ -#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */ -#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */ -#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */ -#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */ - -#define EEPROM_BUSY (1<<15) -#define EEPROM_TST_MODE (1<<14) - -/* - * Some short functions, worth to let them be a macro - */ -#define is_eeprom_busy(b) (inw((b)+EP_W0_EEPROM_COMMAND)&EEPROM_BUSY) -#define GO_WINDOW(x) outw(BASE+EP_COMMAND, WINDOW_SELECT|(x)) - -/************************************************************************** - * * - * These define the EEPROM data structure. They are used in the probe - * function to verify the existance of the adapter after having sent - * the ID_Sequence. - * - * There are others but only the ones we use are defined here. - * - **************************************************************************/ - -#define EEPROM_NODE_ADDR_0 0x0 /* Word */ -#define EEPROM_NODE_ADDR_1 0x1 /* Word */ -#define EEPROM_NODE_ADDR_2 0x2 /* Word */ -#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */ -#define EEPROM_MFG_ID 0x7 /* 0x6d50 */ -#define EEPROM_ADDR_CFG 0x8 /* Base addr */ -#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */ - -/************************************************************************** - * * - * These are the registers for the 3Com 3c509 and their bit patterns when * - * applicable. They have been taken out the the "EtherLink III Parallel * - * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual * - * from 3com. * - * * - **************************************************************************/ - -#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a - * command reg. */ -#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status - * reg. */ -#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window - * reg. */ -/* - * Window 0 registers. Setup. - */ -/* Write */ -#define EP_W0_EEPROM_DATA 0x0c -#define EP_W0_EEPROM_COMMAND 0x0a -#define EP_W0_RESOURCE_CFG 0x08 -#define EP_W0_ADDRESS_CFG 0x06 -#define EP_W0_CONFIG_CTRL 0x04 -/* Read */ -#define EP_W0_PRODUCT_ID 0x02 -#define EP_W0_MFG_ID 0x00 - -/* - * Window 1 registers. Operating Set. - */ -/* Write */ -#define EP_W1_TX_PIO_WR_2 0x02 -#define EP_W1_TX_PIO_WR_1 0x00 -/* Read */ -#define EP_W1_FREE_TX 0x0c -#define EP_W1_TX_STATUS 0x0b /* byte */ -#define EP_W1_TIMER 0x0a /* byte */ -#define EP_W1_RX_STATUS 0x08 -#define EP_W1_RX_PIO_RD_2 0x02 -#define EP_W1_RX_PIO_RD_1 0x00 - -/* - * Window 2 registers. Station Address Setup/Read - */ -/* Read/Write */ -#define EP_W2_ADDR_5 0x05 -#define EP_W2_ADDR_4 0x04 -#define EP_W2_ADDR_3 0x03 -#define EP_W2_ADDR_2 0x02 -#define EP_W2_ADDR_1 0x01 -#define EP_W2_ADDR_0 0x00 - -/* - * Window 3 registers. FIFO Management. - */ -/* Read */ -#define EP_W3_FREE_TX 0x0c -#define EP_W3_FREE_RX 0x0a - -/* - * Window 4 registers. Diagnostics. - */ -/* Read/Write */ -#define EP_W4_MEDIA_TYPE 0x0a -#define EP_W4_CTRLR_STATUS 0x08 -#define EP_W4_NET_DIAG 0x06 -#define EP_W4_FIFO_DIAG 0x04 -#define EP_W4_HOST_DIAG 0x02 -#define EP_W4_TX_DIAG 0x00 - -/* - * Window 5 Registers. Results and Internal status. - */ -/* Read */ -#define EP_W5_READ_0_MASK 0x0c -#define EP_W5_INTR_MASK 0x0a -#define EP_W5_RX_FILTER 0x08 -#define EP_W5_RX_EARLY_THRESH 0x06 -#define EP_W5_TX_AVAIL_THRESH 0x02 -#define EP_W5_TX_START_THRESH 0x00 - -/* - * Window 6 registers. Statistics. - */ -/* Read/Write */ -#define TX_TOTAL_OK 0x0c -#define RX_TOTAL_OK 0x0a -#define TX_DEFERRALS 0x08 -#define RX_FRAMES_OK 0x07 -#define TX_FRAMES_OK 0x06 -#define RX_OVERRUNS 0x05 -#define TX_COLLISIONS 0x04 -#define TX_AFTER_1_COLLISION 0x03 -#define TX_AFTER_X_COLLISIONS 0x02 -#define TX_NO_SQE 0x01 -#define TX_CD_LOST 0x00 - -/**************************************** - * - * Register definitions. - * - ****************************************/ - -/* - * Command register. All windows. - * - * 16 bit register. - * 15-11: 5-bit code for command to be executed. - * 10-0: 11-bit arg if any. For commands with no args; - * this can be set to anything. - */ -#define GLOBAL_RESET (u_short) 0x0000 /* Wait at least 1ms - * after issuing */ -#define WINDOW_SELECT (u_short) (0x1<<11) -#define START_TRANSCEIVER (u_short) (0x2<<11) /* Read ADDR_CFG reg to - * determine whether - * this is needed. If - * so; wait 800 uSec - * before using trans- - * ceiver. */ -#define RX_DISABLE (u_short) (0x3<<11) /* state disabled on - * power-up */ -#define RX_ENABLE (u_short) (0x4<<11) -#define RX_RESET (u_short) (0x5<<11) -#define RX_DISCARD_TOP_PACK (u_short) (0x8<<11) -#define TX_ENABLE (u_short) (0x9<<11) -#define TX_DISABLE (u_short) (0xa<<11) -#define TX_RESET (u_short) (0xb<<11) -#define REQ_INTR (u_short) (0xc<<11) -#define SET_INTR_MASK (u_short) (0xe<<11) -#define SET_RD_0_MASK (u_short) (0xf<<11) -#define SET_RX_FILTER (u_short) (0x10<<11) -#define FIL_INDIVIDUAL (u_short) (0x1) -#define FIL_GROUP (u_short) (0x2) -#define FIL_BRDCST (u_short) (0x4) -#define FIL_ALL (u_short) (0x8) -#define SET_RX_EARLY_THRESH (u_short) (0x11<<11) -#define SET_TX_AVAIL_THRESH (u_short) (0x12<<11) -#define SET_TX_START_THRESH (u_short) (0x13<<11) -#define STATS_ENABLE (u_short) (0x15<<11) -#define STATS_DISABLE (u_short) (0x16<<11) -#define STOP_TRANSCEIVER (u_short) (0x17<<11) -/* - * The following C_* acknowledge the various interrupts. Some of them don't - * do anything. See the manual. - */ -#define ACK_INTR (u_short) (0x6800) -#define C_INTR_LATCH (u_short) (ACK_INTR|0x1) -#define C_CARD_FAILURE (u_short) (ACK_INTR|0x2) -#define C_TX_COMPLETE (u_short) (ACK_INTR|0x4) -#define C_TX_AVAIL (u_short) (ACK_INTR|0x8) -#define C_RX_COMPLETE (u_short) (ACK_INTR|0x10) -#define C_RX_EARLY (u_short) (ACK_INTR|0x20) -#define C_INT_RQD (u_short) (ACK_INTR|0x40) -#define C_UPD_STATS (u_short) (ACK_INTR|0x80) - -/* - * Status register. All windows. - * - * 15-13: Window number(0-7). - * 12: Command_in_progress. - * 11: reserved. - * 10: reserved. - * 9: reserved. - * 8: reserved. - * 7: Update Statistics. - * 6: Interrupt Requested. - * 5: RX Early. - * 4: RX Complete. - * 3: TX Available. - * 2: TX Complete. - * 1: Adapter Failure. - * 0: Interrupt Latch. - */ -#define S_INTR_LATCH (u_short) (0x1) -#define S_CARD_FAILURE (u_short) (0x2) -#define S_TX_COMPLETE (u_short) (0x4) -#define S_TX_AVAIL (u_short) (0x8) -#define S_RX_COMPLETE (u_short) (0x10) -#define S_RX_EARLY (u_short) (0x20) -#define S_INT_RQD (u_short) (0x40) -#define S_UPD_STATS (u_short) (0x80) -#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\ - S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY) -#define S_COMMAND_IN_PROGRESS (u_short) (0x1000) - -/* - * FIFO Registers. - * RX Status. Window 1/Port 08 - * - * 15: Incomplete or FIFO empty. - * 14: 1: Error in RX Packet 0: Incomplete or no error. - * 13-11: Type of error. - * 1000 = Overrun. - * 1011 = Run Packet Error. - * 1100 = Alignment Error. - * 1101 = CRC Error. - * 1001 = Oversize Packet Error (>1514 bytes) - * 0010 = Dribble Bits. - * (all other error codes, no errors.) - * - * 10-0: RX Bytes (0-1514) - */ -#define ERR_RX_INCOMPLETE (u_short) (0x1<<15) -#define ERR_RX (u_short) (0x1<<14) -#define ERR_RX_OVERRUN (u_short) (0x8<<11) -#define ERR_RX_RUN_PKT (u_short) (0xb<<11) -#define ERR_RX_ALIGN (u_short) (0xc<<11) -#define ERR_RX_CRC (u_short) (0xd<<11) -#define ERR_RX_OVERSIZE (u_short) (0x9<<11) -#define ERR_RX_DRIBBLE (u_short) (0x2<<11) - -/* - * FIFO Registers. - * TX Status. Window 1/Port 0B - * - * Reports the transmit status of a completed transmission. Writing this - * register pops the transmit completion stack. - * - * Window 1/Port 0x0b. - * - * 7: Complete - * 6: Interrupt on successful transmission requested. - * 5: Jabber Error (TP Only, TX Reset required. ) - * 4: Underrun (TX Reset required. ) - * 3: Maximum Collisions. - * 2: TX Status Overflow. - * 1-0: Undefined. - * - */ -#define TXS_COMPLETE 0x80 -#define TXS_SUCCES_INTR_REQ 0x40 -#define TXS_JABBER 0x20 -#define TXS_UNDERRUN 0x10 -#define TXS_MAX_COLLISION 0x8 -#define TXS_STATUS_OVERFLOW 0x4 - -/* - * Configuration control register. - * Window 0/Port 04 - */ -/* Read */ -#define IS_AUI (1<<13) -#define IS_BNC (1<<12) -#define IS_UTP (1<<9) -/* Write */ -#define ENABLE_DRQ_IRQ 0x0001 -#define W0_P4_CMD_RESET_ADAPTER 0x4 -#define W0_P4_CMD_ENABLE_ADAPTER 0x1 -/* - * Media type and status. - * Window 4/Port 0A - */ -#define ENABLE_UTP 0xc0 -#define DISABLE_UTP 0x0 - -/* - * Resource control register - */ - -#define SET_IRQ(i) ( ((i)<<12) | 0xF00) /* set IRQ i */ - -/* - * Receive status register - */ - -#define RX_BYTES_MASK (u_short) (0x07ff) -#define RX_ERROR 0x4000 -#define RX_INCOMPLETE 0x8000 - - -/* - * Misc defines for various things. - */ -#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */ -#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */ -#define PROD_ID 0x9150 - -#define AUI 0x1 -#define BNC 0x2 -#define UTP 0x4 - -#define ETHER_ADDR_LEN 6 -#define ETHER_MAX 1536 -#define RX_BYTES_MASK (u_short) (0x07ff) - - /* EISA support */ -#define EP_EISA_START 0x1000 -#define EP_EISA_W0 0x0c80 diff --git a/sys/i386/boot/netboot/netboot.doc b/sys/i386/boot/netboot/netboot.doc deleted file mode 100644 index d9d261e..0000000 --- a/sys/i386/boot/netboot/netboot.doc +++ /dev/null @@ -1,42 +0,0 @@ - -Configuring FreeBSD to run diskless Oct 15/1994 -=================================== - -1) Find a machine that will be your server. This machine will require - enough disk space to hold the FreeBSD 2.0 binaries and have bootp and - tftp services available. - -2) Create a bootptab entry for the diskless FreeBSD machine. - - sample entry: - - diskless:\ - :ht=ether:\ - :ha=0000c01f848a:\ - :sm=255.255.255.0:\ - :hn:\ - :ds=192.1.2.3:\ - :ip=192.1.2.4:\ - :vm=rfc1048: - - -3) Create a cfg.x.x.x.x file for your diskless machine. This is now an - ASCII file with netboot commands in it. - - sample cfg.x.x.x.x: - - hostname diskless.freebsd.com - rootfs server.freebsd.com:/var/rootfs/diskless - swapfs server.freebsd.com:/var/swap/diskless - -4) On the server, export the root and swap filesystems to the client. This - usually involves putting them in the /etc/exports file and one some - machines running /usr/etc/exportfs -av - -5) Make a BOOTROM by copying netboot.rom to an EPROM, or copy netboot.com to - a DOS diskette. - -6) Boot the diskless machine and run netboot.com if you're using DOS. - - -Martin Renters martin@innovus.com diff --git a/sys/i386/boot/rmaouthdr b/sys/i386/boot/rmaouthdr deleted file mode 100644 index 4bb9c84..0000000 --- a/sys/i386/boot/rmaouthdr +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/csh -f -# -# from: Mach, Revision 2.2 92/04/04 11:36:01 rpd -# $Id$ -# -dd if=$1 of=$2 ibs=32 skip=1 obs=1024b diff --git a/sys/i386/boot/serialboot/Makefile b/sys/i386/boot/serialboot/Makefile deleted file mode 100644 index a282843..0000000 --- a/sys/i386/boot/serialboot/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# $Id: Makefile,v 1.22 1994/11/05 21:06:16 ache Exp $ -# - -PROG= boot - -.PATH: ${.CURDIR}/../biosboot -# Order is very important on the SRCS line for this prog -SRCS= start.S table.c boot2.S boot.c asm.S bios.S io.c disk.c sys.c - -BINDIR= /usr/mdec -BINMODE= 444 -CFLAGS= -O -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} -DCOMCONSOLE=0x3F8 -CFLAGS+= -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK} -CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../biosboot -I${.CURDIR}/../.. -CLEANFILES+= boot.nohdr boot.strip boot1 boot2 -DPADD= ${LIBC} -LDFLAGS+= -N -T 0 -nostdlib -LDADD= -lc -LINKS= ${BINDIR}/sdboot ${BINDIR}/wdboot\ - ${BINDIR}/sdboot ${BINDIR}/fdboot\ - ${BINDIR}/bootsd ${BINDIR}/bootwd\ - ${BINDIR}/bootsd ${BINDIR}/bootfd -NOSHARED= YES -NOMAN= -STRIP= - -# tunable timeout parameter, waiting for keypress, calibrated in mS -BOOTWAIT?= 5000 - -# Location that boot2 is loaded at -BOOTSEG= 0x1000 - -# Offset in BOOTSEG for the top of the stack, keep this 16 byte aligned -BOOTSTACK= 0xFFF0 - -boot.strip: boot - cp -p boot boot.strip - strip boot.strip - size boot.strip - -boot.nohdr: boot.strip - dd if=boot.strip of=boot.nohdr ibs=32 skip=1 obs=1024b - ls -l boot.nohdr - -boot1: boot.nohdr - dd if=boot.nohdr of=boot1 bs=512 count=1 - -boot2: boot.nohdr - dd if=boot.nohdr of=boot2 bs=512 skip=1 - -all: boot1 boot2 - -beforeinstall: - install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ - boot1 ${DESTDIR}${BINDIR}/sdboot - install ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}\ - boot2 ${DESTDIR}${BINDIR}/bootsd - -.include <bsd.prog.mk> diff --git a/sys/i386/boot/serialboot/bios.S b/sys/i386/boot/serialboot/bios.S deleted file mode 100644 index c292452..0000000 --- a/sys/i386/boot/serialboot/bios.S +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id: bios.S,v 1.3 1994/10/02 05:18:25 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* - * Serial bootblock interface routines - * Copyright (c) 1994, J"org Wunsch - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * THE AUTHOR ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. THE AUTHOR DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - */ - - .file "bios.s" - -#include "asm.h" - .text - -/* - * biosread(dev, cyl, head, sec, nsec, offset) - * Read "nsec" sectors from disk to offset "offset" in boot segment - * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory - * Call with %ah = 0x2 - * %al = number of sectors - * %ch = cylinder - * %cl = sector - * %dh = head - * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) - * %es:%bx = segment:offset of buffer - * Return: - * %al = 0x0 on success; err code on failure - */ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - /* cylinder; the highest 2 bits of cyl is in %cl */ - xchgb %ch, %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl /* sector; sec starts from 1, not 0 */ - movb 0x8(%ebp), %dl /* device */ - movl 0x1c(%ebp), %ebx /* offset */ - - /* prot_to_real will set %es to BOOTSEG */ - call EXT(prot_to_real) /* enter real mode */ - movb $0x2, %ah /* subfunction */ - addr32 - movb 0x18(%ebp), %al /* number of sectors */ - - sti - int $0x13 - cli - - /* save return value (actually movw %ax, %bx) */ - mov %eax, %ebx - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - movb %bh, %al /* return value in %ax */ - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - -/* - * The serial port interface routines implement a simple polled i/o - * interface to a standard serial port. Due to the space restrictions - * for the boot blocks, no BIOS support is used (since BIOS requires - * expensive real/protected mode switches), instead the rudimentary - * BIOS support is duplicated here. - * - * The base address for the i/o port is passed from the Makefile in - * the COMCONSOLE preprocessor macro. Console parameters are currently - * hard-coded to 9600 Bd, 8 bit. This can be changed in the - * init_serial() function. - */ - -/* - * void putc(char ch) - * send ch to serial port - * - */ - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %edx - - mov $COMCONSOLE + 5, %edx # line status reg -1: inb %dx, %al - test $0x20, %al - jz 1b # TX buffer not empty - - movb 0x8(%ebp), %al - - sub $5, %edx # TX output reg - outb %al, %dx # send this one - - pop %edx - pop %ebp - ret - -/* - * int getc(void) - * read a character from serial port - */ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %edx - - mov $COMCONSOLE + 5, %edx # line status reg -1: - inb %dx, %al - testb $0x01, %al - jz 1b # no RX char available - - xor %eax, %eax - sub $5, %edx # RX buffer reg - inb %dx, %al # fetch (first) character - - cmp $0x7F, %eax # make DEL... - jne 2f - mov $0x08, %eax # look like BS -2: - pop %edx - pop %ebp - ret - -/* - * int ischar(void) - * if there is a character pending, return true; otherwise return 0 - */ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %edx - - xorl %eax, %eax - mov $COMCONSOLE + 5, %edx # line status reg - inb %dx, %al - andb $0x01, %al # RX char available? - - pop %edx - pop %ebp - ret - -/* - * void init_serial(void) - * initialize the serial console port to 9600 Bd, 8 bpc - */ -ENTRY(init_serial) - push %ebp - mov %esp, %ebp - push %edx - - mov $COMCONSOLE + 3, %edx # line control reg - movb $0x80, %al - outb %al, %dx # enable DLAB - - sub $3, %edx # divisor latch, low byte - mov $12, %ax # divisor 12: 9600 Bd - outb %al, %dx - inc %edx # divisor latch, high byte - movb %ah, %al - outb %al, %dx - - add $2, %edx # line control reg - movb $0x13, %al - outb %al, %dx # 8 bit, no parity, 1 stop bit - - inc %edx # modem control reg - mov $3, %al - outb %al, %dx # enable DTR/RTS - - /* now finally, flush the input buffer */ - inc %edx # line status reg -1: - inb %dx, %al - testb $0x01, %al - jz 2f # no more characters buffered - sub $5, %edx # rx buffer reg - inb %dx, %al # throw away - add $5, %edx - jmp 1b -2: - pop %edx - pop %ebp - ret - -/* - * - * get_diskinfo(): return a word that represents the - * max number of sectors and heads and drives for this device - * - */ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl /* diskinfo(drive #) */ - call EXT(prot_to_real) /* enter real mode */ - - movb $0x8, %ah /* ask for disk info */ - - sti - int $0x13 - cli - - jnc ok - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ - subb %ah, %ah /* %ax = 0 */ - movb %al, %al - movb %ah, %bh /* %bh = 0 */ - movb $2, %bl /* %bl bits 0-3 = drive type, - bit 2 = 1.2M */ - movb $79, %ch /* max track */ - movb $15, %cl /* max sector */ - movb $1, %dh /* max head */ - movb $1, %dl /* # floppy drives installed */ - /* es:di = parameter table */ - /* carry = 0 */ -ok: - - data32 - call EXT(real_to_prot) /* back to protected mode */ - - xor %eax, %eax - - /* form a longword representing all this gunk */ - movb %dh, %ah /* max head */ - andb $0x3f, %cl /* mask of cylinder gunk */ - movb %cl, %al /* max sector (and # sectors) */ - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* - * - * memsize(i) : return the memory size in KB. i == 0 for conventional memory, - * i == 1 for extended memory - * BIOS call "INT 12H" to get conventional memory size - * BIOS call "INT 15H, AH=88H" to get extended memory size - * Both have the return value in AX. - * - */ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) /* enter real mode */ - - cmpb $0x1, %bl - data32 - je xext - - sti - int $0x12 - cli - data32 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data32 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret - diff --git a/sys/i386/boot/serialboot/boot.c b/sys/i386/boot/serialboot/boot.c deleted file mode 100644 index 06bd6ba..0000000 --- a/sys/i386/boot/serialboot/boot.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.22 1994/11/07 11:26:26 davidg Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <sys/param.h> -#include "boot.h" -#include <a.out.h> -#include <sys/reboot.h> -#include <machine/bootinfo.h> - -struct exec head; -struct bootinfo_t bootinfo; -char *name; -char *names[] = { - "/kernel" -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -extern void init_serial(void); -extern int end; -boot(drive) -int drive; -{ - int loadflags, currname = 0, ret; - char *t; - - init_serial(); - - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n", - ouraddr, - memsize(0), - memsize(1)); - printf("Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.\n"); - printf("Usage: [[[%s(0,a)]%s][-s][-r][-a][-c][-d][-b]]\nUse ? for file list.\n\n" - , devs[(drive & 0x80) ? 0 : 2] - , names[0]); - gateA20(); -loadstart: - /***************************************************************\ - * As a default set it to the first partition of the first * - * floppy or hard drive * - \***************************************************************/ - part = unit = 0; - maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - name = names[currname++]; - - loadflags = 0; - if (currname == NUMNAMES) - currname = 0; - printf("Boot: "); - getbootdev(&loadflags); - ret = openrd(); - if (ret != 0) { - if (ret > 0) - printf("Can't find %s\n", name); - goto loadstart; - } -/* if (inode.i_mode&IEXEC) - loadflags |= RB_KDB; -*/ - loadprog(loadflags); - goto loadstart; -} - -loadprog(howto) - int howto; -{ - long int startaddr; - long int addr; /* physical address.. not directly useable */ - long int bootdev; - long int total; - int i; - unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ - - read(&head, sizeof(head)); - if ( N_BADMAG(head)) { - printf("Invalid format!\n"); - return; - } - - poff = N_TXTOFF(head); - /*if(poff==0) - poff = 32;*/ - - startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */ - addr = startaddr; - printf("Booting %s(%d,%c)%s @ 0x%x\n" - , devs[maj] - , unit - , 'a'+part - , name - , addr); - if(addr < ouraddr) - { - if((addr + head.a_text + head.a_data) > ouraddr) - { - printf("kernel overlaps loader\n"); - return; - } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) - { - printf("bss exceeds 640k limit\n"); - return; - } - } - printf("text=0x%x ", head.a_text); - /********************************************************/ - /* LOAD THE TEXT SEGMENT */ - /* don't clobber the first 4k yet (BIOS NEEDS IT) */ - /********************************************************/ - read(tmpbuf,4096); - addr += 4096; - xread(addr, head.a_text - 4096); - addr += head.a_text - 4096; - - /********************************************************/ - /* Load the Initialised data after the text */ - /********************************************************/ - while (addr & CLOFSET) - *(char *)addr++ = 0; - - printf("data=0x%x ", head.a_data); - xread(addr, head.a_data); - addr += head.a_data; - - /********************************************************/ - /* Skip over the uninitialised data */ - /* (but clear it) */ - /********************************************************/ - printf("bss=0x%x ", head.a_bss); - if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) - { - pbzero(addr,ouraddr - (int)addr); - } - else - { - pbzero(addr,head.a_bss); - } - addr += head.a_bss; - -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) - { - /********************************************************/ - /*copy in the symbol header */ - /********************************************************/ - pcpy(&head.a_syms, addr, sizeof(head.a_syms)); - addr += sizeof(head.a_syms); - - /********************************************************/ - /* READ in the symbol table */ - /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); - xread(addr, head.a_syms); - addr += head.a_syms; - - /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ - /********************************************************/ - read(&i, sizeof(int)); - pcpy(&i, addr, sizeof(int)); - i -= sizeof(int); - addr += sizeof(int); - - - /********************************************************/ - /* and that many bytes of (debug symbols?) */ - /********************************************************/ - printf("+0x%x] ", i); - xread(addr, i); - addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - - total = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ", total); - bootdev = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ; - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ - printf("entry point=0x%x\n" ,(int)startaddr); - /* Under no circumstances overwrite precious BIOS variables! */ - pcpy(tmpbuf, startaddr, 0x400); - pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500); - bootinfo.version=1; - bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4)); - bootinfo.nfs_diskless=0; - startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4)); - return; -} - -#define NAMEBUF_LEN 100 - -char namebuf[NAMEBUF_LEN]; -getbootdev(howto) - int *howto; -{ - char c, *ptr = namebuf; - if (gets(namebuf)) { - while (c=*ptr) { - while (c==' ') - c = *++ptr; - if (!c) - return; - if (c=='-') - while ((c = *++ptr) && c!=' ') - switch (c) { - case 'r': - *howto |= RB_DFLTROOT; continue; - case 'a': - *howto |= RB_ASKNAME; continue; - case 'c': - *howto |= RB_CONFIG; continue; - case 's': - *howto |= RB_SINGLE; continue; - case 'd': - *howto |= RB_KDB; continue; - case 'b': - *howto |= RB_HALT; continue; - } - else { - name = ptr; - while ((c = *++ptr) && c!=' '); - if (c) - *ptr++ = 0; - } - } - } else - printf("\n"); -} - diff --git a/sys/i386/boot/start.S b/sys/i386/boot/start.S deleted file mode 100644 index d0bcbf8..0000000 --- a/sys/i386/boot/start.S +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd - * $Id: start.S,v 1.4 1994/10/02 05:18:26 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#include "asm.h" - - .file "start.s" - -SIGNATURE= 0xaa55 -LOADSZ= 15 /* size of unix boot */ -PARTSTART= 0x1be /* starting address of partition table */ -NUMPART= 4 /* number of partitions in partition table */ -PARTSZ= 16 /* each partition table entry is 16 bytes */ -BSDPART= 0xA5 /* value of boot_ind, means bootable partition */ -BOOTABLE= 0x80 /* value of boot_ind, means bootable partition */ - - .text - -ENTRY(boot1) - /* - * start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - * ljmp to the next instruction to adjust %cs - */ - data32 - ljmp $0x7c0, $start - -start: - /* set up %ds */ - mov %cs, %ax - mov %ax, %ds - - /* set up %ss and %esp */ - data32 - mov $BOOTSEG, %eax - mov %ax, %ss - data32 - mov $BOOTSTACK, %esp - - /* set up %es, (where we will load boot2 to) */ - mov %ax, %es - -#ifdef DEBUG - data32 - mov $one, %esi - data32 - call message -#endif - - /* bootstrap passes us drive number in %dl */ - cmpb $0x80, %dl - data32 - jae hd - -fd: - mov $0x0, %dl - /* reset the disk system */ -#ifdef DEBUG - data32 - mov $two, %esi - data32 - call message -#endif - movb $0x0, %ah - int $0x13 - data32 - mov $0x0001, %ecx /* cyl 0, sector 1 */ - movb $0, %dh /* head */ -#ifdef DEBUG - data32 - mov $three, %esi - data32 - call message -#endif - data32 - jmp load - -hd: /**** load sector 0 into the BOOTSEG ****/ -#ifdef DEBUG - data32 - mov $four, %esi - data32 - call message -#endif - data32 - mov $0x0201, %eax - xor %ebx, %ebx /* %bx = 0 */ - data32 - mov $0x0001, %ecx -#ifdef DEBUG - data32 - mov $five, %esi - data32 - call message -#endif - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /* find the first 386BSD partition */ - data32 - mov $PARTSTART, %ebx - data32 - mov $NUMPART, %ecx -again: - addr32 - movb %es:4(%ebx), %al - cmpb $BSDPART, %al - data32 - je found - data32 - add $PARTSZ, %ebx - data32 - loop again - data32 - mov $enoboot, %esi - data32 - jmp err_stop - - -/* - * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory - * Call with %ah = 0x2 - * %al = number of sectors - * %ch = cylinder - * %cl = sector - * %dh = head - * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) - * %es:%bx = segment:offset of buffer - * Return: - * %al = 0x0 on success; err code on failure - */ - -found: - addr32 - movb %es:1(%ebx), %dh /* head */ - addr32 - movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - /* - * ljmp to the second stage boot loader (boot2). - * After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - * as an internal buffer "intbuf". - */ - -#ifdef DEBUG - data32 - mov $six, %esi - data32 - call message -#endif - data32 - ljmp $BOOTSEG, $ EXT(boot2) - -/* - * read_error - */ -read_error: - data32 - mov $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -/* - * message: write the error message in %ds:%esi to console - */ -message: - /* - * Use BIOS "int 10H Function 0Eh" to write character in teletype mode - * %ah = 0xe %al = character - * %bh = page %bl = foreground color (graphics modes) - */ - - data32 - push %eax - data32 - push %ebx - data32 - mov $0x0001, %ebx - cld - -nextb: - lodsb /* load a byte into %al */ - cmpb $0x0, %al - data32 - je done - movb $0xe, %ah - int $0x10 /* display a byte */ - data32 - jmp nextb -done: - data32 - pop %ebx - data32 - pop %eax - data32 - ret - -stop: hlt - data32 - jmp stop /* halt doesnt actually halt forever */ - -/* error messages */ - -#ifdef DEBUG -one: String "1\r\n\0" -two: String "2\r\n\0" -three: String "3\r\n\0" -four: String "4\r\n\0" -five: String "5\r\n\0" -six: String "6\r\n\0" -seven: String "7\r\n\0" -#endif DEBUG -eread: String "Read error\r\n\0" -enoboot: String "No bootable partition\r\n\0" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ - . = EXT(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = EXT(boot1) + 0x1fe - .value SIGNATURE -ENTRY(disklabel) - . = EXT(boot1) + 0x400 diff --git a/sys/i386/boot/sys.c b/sys/i386/boot/sys.c deleted file mode 100644 index 48cbade..0000000 --- a/sys/i386/boot/sys.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:34 rpd - * $Id: sys.c,v 1.4 1994/08/21 17:47:26 paul Exp $ - */ - -#include "boot.h" -#include <sys/dir.h> -#include <sys/reboot.h> - -#ifdef 0 -/* #define BUFSIZE 4096 */ -#define BUFSIZE MAXBSIZE - -char buf[BUFSIZE], fsbuf[SBSIZE], iobuf[MAXBSIZE]; -#endif - -#define BUFSIZE 8192 -#define MAPBUFSIZE BUFSIZE -char buf[BUFSIZE], fsbuf[BUFSIZE], iobuf[BUFSIZE]; - -int xread(addr, size) - char * addr; - int size; -{ - int count = BUFSIZE; - while (size > 0) { - if (BUFSIZE > size) - count = size; - read(buf, count); - pcpy(buf, addr, count); - size -= count; - addr += count; - } -} - -read(buffer, count) - int count; - char *buffer; -{ - int logno, off, size; - int cnt2, bnum2; - - while (count) { - off = blkoff(fs, poff); - logno = lblkno(fs, poff); - cnt2 = size = blksize(fs, &inode, logno); - bnum2 = fsbtodb(fs, block_map(logno)) + boff; - cnt = cnt2; - bnum = bnum2; - if ( (!off) && (size <= count)) - { - iodest = buffer; - devread(); - } - else - { - iodest = iobuf; - size -= off; - if (size > count) - size = count; - devread(); - bcopy(iodest+off,buffer,size); - } - buffer += size; - count -= size; - poff += size; - } -} - -find(path) - char *path; -{ - char *rest, ch; - int block, off, loc, ino = ROOTINO; - struct direct *dp; -loop: iodest = iobuf; - cnt = fs->fs_bsize; - bnum = fsbtodb(fs,ino_to_fsba(fs,ino)) + boff; - devread(); - bcopy(&((struct dinode *)iodest)[ino % fs->fs_inopb], - &inode.i_din, - sizeof (struct dinode)); - if (!*path) - return 1; - while (*path == '/') - path++; - if (!inode.i_size || ((inode.i_mode&IFMT) != IFDIR)) - return 0; - for (rest = path; (ch = *rest) && ch != '/'; rest++) ; - *rest = 0; - loc = 0; - do { - if (loc >= inode.i_size) - return 0; - if (!(off = blkoff(fs, loc))) { - block = lblkno(fs, loc); - cnt = blksize(fs, &inode, block); - bnum = fsbtodb(fs, block_map(block)) + boff; - iodest = iobuf; - devread(); - } - dp = (struct direct *)(iodest + off); - loc += dp->d_reclen; - } while (!dp->d_ino || strcmp(path, dp->d_name)); - ino = dp->d_ino; - *(path = rest) = ch; - goto loop; -} - -char mapbuf[MAPBUFSIZE]; -int mapblock = 0; - -block_map(file_block) - int file_block; -{ - if (file_block < NDADDR) - return(inode.i_db[file_block]); - if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) { - iodest = mapbuf; - cnt = fs->fs_bsize; - devread(); - mapblock = bnum; - } - return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]); -} - -openrd() -{ - char **devp, *cp = name; - /*******************************************************\ - * If bracket given look for preceding device name * - \*******************************************************/ - while (*cp && *cp!='(') - cp++; - if (!*cp) - { - cp = name; - } - else - { - if (cp++ != name) - { - for (devp = devs; *devp; devp++) - if (name[0] == (*devp)[0] && - name[1] == (*devp)[1]) - break; - if (!*devp) - { - printf("Unknown device\n"); - return 1; - } - maj = devp-devs; - } - /*******************************************************\ - * Look inside brackets for unit number, and partition * - \*******************************************************/ - /* - * Allow any valid digit as the unit number, as the BIOS - * will complain if the unit number is out of range. - * Restricting the range here prevents the possibilty of using - * BIOSes that support more than 2 units. - * XXX Bad values may cause strange errors, need to check if - * what happens when a value out of range is supplied. - */ - if (*cp >= '0' && *cp <= '9') - unit = *cp++ - '0'; - if (!*cp || (*cp == ',' && !*++cp)) - return 1; - if (*cp >= 'a' && *cp <= 'p') - part = *cp++ - 'a'; - while (*cp && *cp++!=')') ; - if (!*cp) - return 1; - } - switch(maj) - { - case 1: - dosdev = unit | 0x80; - unit = 0; - break; - case 0: - case 4: - dosdev = unit | 0x80; - break; - case 2: - dosdev = unit; - break; - case 3: - printf("Wangtek unsupported\n"); - return 1; - break; - } - inode.i_dev = dosdev; - /***********************************************\ - * Now we know the disk unit and part, * - * Load disk info, (open the device) * - \***********************************************/ - if (devopen()) - return 1; - - /***********************************************\ - * Load Filesystem info (mount the device) * - \***********************************************/ - iodest = (char *)(fs = (struct fs *)fsbuf); - cnt = SBSIZE; - bnum = SBLOCK + boff; - devread(); - /***********************************************\ - * Find the actual FILE on the mounted device * - \***********************************************/ - if (!find(cp)) - { - return 1; - } - poff = 0; - name = cp; - return 0; -} diff --git a/sys/i386/boot/table.c b/sys/i386/boot/table.c deleted file mode 100644 index 677a12f..0000000 --- a/sys/i386/boot/table.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:43 rpd - * $Id: table.c,v 1.3 1993/10/16 19:11:40 rgrimes Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -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 and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* Segment Descriptor - * - * 31 24 19 16 7 0 - * ------------------------------------------------------------ - * | | |B| |A| | | |1|0|E|W|A| | - * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 | - * | | |D| |L| 19..16| | |1|1|C|R|A| | - * ------------------------------------------------------------ - * | | | - * | BASE 15..0 | LIMIT 15..0 | - * | | | - * ------------------------------------------------------------ - */ - -struct seg_desc { - unsigned short limit_15_0; - unsigned short base_15_0; - unsigned char base_23_16; - unsigned char p_dpl_type; - unsigned char g_b_a_limit; - unsigned char base_31_24; - }; - -#define RUN 0 /* not really 0, but filled in at boot time */ - -struct seg_desc Gdt[] = { - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* 0x0 : null */ - {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0}, /* 0x08 : kernel code */ - /* 0x9E? */ - {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0}, /* 0x10 : kernel data */ - /* 0x92? */ - {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0}, /* 0x18 : boot code */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* 0x20 : boot data */ - {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0}, /* 0x28 : boot code, 16 bits */ -#ifdef BDE_DEBUGGER - /* More for bdb. */ - {}, /* BIOS_CS_INDEX = 6 : null */ - {}, /* BIOS_TMP_INDEX = 7 : null */ - {}, /* TSS_INDEX = 8 : null */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* DS_286_INDEX = 9 */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* ES_286_INDEX = 10 */ - {}, /* Unused = 11 : null */ - {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */ - {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0}, /* MONO_INDEX = 13 */ - {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0}, /* DB_CS_INDEX = 14 */ - {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0}, /* DB_CS16_INDEX = 15 */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* DB_DS_INDEX = 16 */ - {8*18-1, RUN, RUN, 0x92, 0x40, 0x0}, /* GDT_INDEX = 17 */ -#endif /* BDE_DEBUGGER */ -}; - -#ifdef BDE_DEBUGGER -struct idt_desc { - unsigned short entry_15_0; - unsigned short selector; - unsigned char padding; - unsigned char p_dpl_type; - unsigned short entry_31_16; -}; - -struct idt_desc Idt[] = { - {}, /* Null (int 0) */ - {RUN, 0x70, 0, 0x8E, 0}, /* DEBUG_VECTOR = 1 */ - {}, /* Null (int 2) */ - {RUN, 0x70, 0, 0xEE, 0}, /* BREAKPOINT_VECTOR = 3 */ -}; -#endif /* BDE_DEBUGGER */ - -struct pseudo_desc { - unsigned short limit; - unsigned short base_low; - unsigned short base_high; - }; - -struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN }; -#ifdef BDE_DEBUGGER -struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN }; -struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 }; -#endif diff --git a/sys/i386/conf/ATAPI b/sys/i386/conf/ATAPI deleted file mode 100644 index bf04ac1..0000000 --- a/sys/i386/conf/ATAPI +++ /dev/null @@ -1,123 +0,0 @@ -# -# ATAPI -- GENERIC kernel with ATAPI (IDE) CDROM support added. -# -# $Id: ATAPI,v 1.1 1995/10/04 08:25:24 jkh Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident ATAPIKERN -maxusers 10 - -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options FFS #Berkeley Fast Filesystem -options NFS #Network Filesystem -options MSDOSFS #MSDOS Filesystem -options "CD9660" #ISO 9660 Filesystem -options PROCFS #Process filesystem -options "COMPAT_43" #Compatible with BSD 4.3 -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options BOUNCE_BUFFERS #include support for DMA bounce buffers -options UCONSOLE #Allow users to grab the console - -options SYSVSHM -options SYSVSEM -options SYSVMSG - -config kernel root on wd0 - -controller isa0 -controller pci0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -tape ft0 at fdc0 drive 2 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -options ATAPI #Enable ATAPI support for IDE bus -device wcd0 #IDE CD-ROM - -controller ncr0 -controller ahc0 - -controller bt0 at isa? port "IO_BT0" bio irq ? vector btintr -controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr -controller ahc1 at isa? bio irq ? vector ahcintr -controller ahb0 at isa? bio irq ? vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr -controller aic0 at isa? port 0x340 bio irq 11 vector aicintr -controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr -controller nca1 at isa? port 0x350 bio irq 5 vector ncaintr -controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr - -controller scbus0 - -device sd0 - -device st0 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mcd1 at isa? port 0x340 bio irq 11 vector mcdintr - -controller matcd0 at isa? port ? bio - -device scd0 at isa? port 0x230 bio - -# syscons is the default console driver, resembling an SCO console -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -# Enable this and PCVT_FREEBSD for pcvt vt220 compatible console driver -#device vt0 at isa? port "IO_KBD" tty irq 1 vector pcrint -#options "PCVT_FREEBSD=210" # pcvt running on FreeBSD 2.1 -#options XSERVER # include code for XFree86 - -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port? tty irq 7 vector lptintr -device lpt1 at isa? port? tty -device lpt2 at isa? port? tty -device mse0 at isa? port 0x23c tty irq 5 vector mseintr - -# Order is important here due to intrusive probes, do *not* alphabetize -# this list of network interfaces until the probes have been fixed. -# Right now it appears that the ie0 must be probed before ep0. See -# revision 1.20 of this file. -device de0 -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device ep0 at isa? port 0x300 net irq 10 vector epintr -device ix0 at isa? port 0x300 net irq 10 iomem 0xd0000 iosiz 32768 vector ixintr -device le0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector le_intr -device lnc0 at isa? port 0x280 net irq 10 drq 0 vector lncintr -device lnc1 at isa? port 0x300 net irq 10 drq 0 vector lncintr -device ze0 at isa? port 0x300 net irq 5 iomem 0xd8000 vector zeintr -device zp0 at isa? port 0x300 net irq 10 iomem 0xd8000 vector zpintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 1 -# ijppp uses tun instead of ppp device -#pseudo-device ppp 1 -pseudo-device tun 1 -pseudo-device pty 16 -pseudo-device gzip # Exec gzipped a.out's diff --git a/sys/i386/conf/BOOTFLP b/sys/i386/conf/BOOTFLP deleted file mode 100644 index 1bb3bd4..0000000 --- a/sys/i386/conf/BOOTFLP +++ /dev/null @@ -1,70 +0,0 @@ -# -# GENERIC -- Generic machine with WD/AHx/NCR/BTx family disks -# -# $Id: BOOTFLP,v 1.2 1995/02/21 13:42:57 jkh Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident BOOTFLP -maxusers 10 - -options MATH_EMULATE #Support for x87 emulation -options FFS #Berkeley Fast Filesystem -options "CD9660" #ISO 9660 Filesystem -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options "SCSI_NCR_MAX_SYNC=0" #Restrict NCR to asynch. transfers -options BOUNCE_BUFFERS #include support for DMA bounce buffers -options UCONSOLE #Allow users to grab the console - -config kernel root on wd0 swap on vn0 dumps on wd0 - -controller isa0 -controller pci0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr - -controller ncr0 -controller ahc0 - -controller bt0 at isa? port "IO_BT0" bio irq ? vector btintr -controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr -controller ahc1 at isa? bio irq ? vector ahcintr -controller ahb0 at isa? bio irq ? vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr -controller aic0 at isa? port 0x340 bio irq 11 vector aicintr -controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr -controller nca1 at isa? port 0x350 bio irq 5 vector ncaintr -controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr - -controller scbus0 - -device sd0 - -device st0 #Only need one of these, the code dynamically grows - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mcd1 at isa? port 0x340 bio irq 11 vector mcdintr - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -pseudo-device log -pseudo-device gzip # Exec gzipped a.out's -pseudo-device vn diff --git a/sys/i386/conf/CORBIN b/sys/i386/conf/CORBIN deleted file mode 100644 index 165e97c..0000000 --- a/sys/i386/conf/CORBIN +++ /dev/null @@ -1,116 +0,0 @@ -# -# 'CORBIN' Kernel Configuration -# -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident CORBIN - -timezone 8 dst -maxusers 16 - -options "i486" - -options INET,GATEWAY -#options MULTICAST,MROUTING -options FFS -options MFS -options NFS -options LFS -options FIFO -options PROCFS -options UNION -options KERNFS -options FDESC -options PORTAL -options NULLFS -options UMAPFS -options "CD9660" - -options KTRACE #kernel syscall tracing -options "COMPAT_43" #sycall compatibility -#options "TCP_COMPAT_42" -#options UCONSOLE #allow non-root console switch -#options "COMCONSOLE=0" #serial console -options COM_BIDIR #"bidirectional" serial ports -options COM_MULTIPORT #multiport serial cards -options MATH_EMULATE #i387 math emulator -#options SYSVSHM #SYSV shared memory -#options "SHMMAXPGS=1024" #max sysvshm shared pages -options DUMMY_NOPS #no nops in inb/outb -options FAT_CURSOR #block cursor -options "NCONS=4" #four virtual consoles -options "SYMTAB_SPACE=92000" #space for debugging symbols -options "NFS_MAXATTRTIMO=10" #maximum NFS attribute cache timeout - -options USER_LDT - -config kernel root on sd0 swap on sd0 dumps on sd0 - -#ISA bus -controller isa0 - -#MFM disk -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -#Floppy disk -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 - -#IO_AHA0 = 0x330 IO_AHA1 = 0x334 -controller ahb0 at isa? bio irq 11 vector ahbintr -#controller aha0 at isa? port 0x330 bio irq 11 drq 5 vector ahaintr -#controller aha1 at isa? port "IO_AHA1" bio irq 12 drq 7 vector ahaintr -controller scbus0 -device sd0 -device sd1 -device sd2 -device sd3 -# -device st0 -device cd0 -# -#device mcd0 at isa? port 0x320 bio irq 5 vector mcdintr - -#PC console - "syscons" -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr - -#Numeric processor (FPU) -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -#16450/16550 UARTs -#device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -#device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -#device com2 at isa? port 0x3e8 tty irq 9 vector comintr -#device com3 at isa? port 0x2e8 tty irq 2 vector comintr -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port 0x3e8 tty irq 9 vector siointr -#device sio3 at isa? port 0x2e8 tty irq 2 vector siointr - -#device ep0 at isa? port 0x300 net irq 10 vector epintr - -#Western Digital WD8003/WD8013 ethernet -#device ed0 at isa? port 0x300 net flags 0x04 irq 10 iomem 0xcc000 iosiz 16384 vector edintr -device ed0 at isa? port 0x300 net irq 10 iomem 0xcc000 vector edintr - -#device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -#device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -#device sb0 at isa? port 0x220 irq 5 drq 1 vector sbintr - -#device snd3 at isa? port 0x388 irq 12 drq 3 vector pasintr -#device snd2 at isa? port 0x220 irq 7 drq 1 vector sbintr - -pseudo-device loop -pseudo-device ether -pseudo-device sl 2 -pseudo-device log -pseudo-device pty 16 -pseudo-device bpfilter 4 -pseudo-device ddb -#pseudo-device speaker diff --git a/sys/i386/conf/GENERICAH b/sys/i386/conf/GENERICAH deleted file mode 100644 index 3022340..0000000 --- a/sys/i386/conf/GENERICAH +++ /dev/null @@ -1,92 +0,0 @@ -# -# GENERICAH -- Generic machine with WD/AHx/NCR family disks -# -# $Id: GENERICAH,v 1.53 1994/10/20 00:53:26 phk Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident GENERICAH -maxusers 10 - -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options FFS #Berkeley Fast File System -options PROCFS #Process filesystem -options NFS #Network File System -options "CD9660" #CD ISO9660 File System -options "COMPAT_43" #Compatible with BSD 4.3 -options UCONSOLE #X Console support -options "FAT_CURSOR" #block cursor in syscons or pccons -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options "NCONS=4" #4 virtual consoles -options BOUNCE_BUFFERS #include support for DMA bounce buffers - -config kernel root on wd0 swap on wd0 and wd1 and sd0 and sd1 dumps on wd0 - -controller isa0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -#tape ft0 at fdc0 drive 2 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -controller ahb0 at isa? bio irq ? vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr -controller pas0 at isa? port 0x1f88 bio -controller aic0 at isa? port 0x340 bio irq 11 vector aicintr -controller pci0 -controller ncr0 - -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mcd1 at isa? port 0x340 bio irq 11 vector mcdintr - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port? tty irq 7 vector lptintr -device lpt1 at isa? port? tty -device lpt2 at isa? port? tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ed2 at isa? port 0x300 net irq 10 iomem 0xcc000 vector edintr -device ep0 at isa? port 0x300 net irq 10 vector epintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 16 -pseudo-device speaker -pseudo-device gzip # Exec gzipped a.out's diff --git a/sys/i386/conf/GENERICBT b/sys/i386/conf/GENERICBT deleted file mode 100644 index 9c1009e..0000000 --- a/sys/i386/conf/GENERICBT +++ /dev/null @@ -1,87 +0,0 @@ -# -# GENERICBT -- Generic machine with WD/BTx family disks -# -# $Id: GENERICBT,v 1.49 1994/10/20 00:53:28 phk Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident GENERICBT -maxusers 10 - -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options FFS #Berkeley Fast File System -options PROCFS #Process filesystem -options NFS #Network File System -options "CD9660" #CD ISO9660 File System -options "COMPAT_43" #Compatible with BSD 4.3 -options UCONSOLE #X Console support -options "FAT_CURSOR" #block cursor in syscons or pccons -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options "NCONS=4" #4 virtual consoles -options BOUNCE_BUFFERS #include support for DMA bounce buffers - -config kernel root on wd0 swap on wd0 and wd1 and sd0 and sd1 dumps on wd0 - -controller isa0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -#tape ft0 at fdc0 drive 2 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -controller bt0 at isa? port "IO_BT0" bio irq ? vector btintr -controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mcd1 at isa? port 0x340 bio irq 11 vector mcdintr - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port? tty irq 7 vector lptintr -device lpt1 at isa? port? tty -device lpt2 at isa? port? tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ed2 at isa? port 0x300 net irq 10 iomem 0xcc000 vector edintr -device ep0 at isa? port 0x300 net irq 10 vector epintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 16 -pseudo-device speaker -pseudo-device gzip # Exec gzipped a.out's diff --git a/sys/i386/conf/IPFIREWALL b/sys/i386/conf/IPFIREWALL deleted file mode 100644 index 9371286..0000000 --- a/sys/i386/conf/IPFIREWALL +++ /dev/null @@ -1,101 +0,0 @@ -# -# IPFIREWALL -- Sample Generic kernel suitable for building an IP firewall. -# -# $Id: IPFIREWALL,v 1.1 1994/10/28 15:09:36 jkh Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident GENERIC -maxusers 10 - -options INET #InterNETworking -options FFS #Berkeley Fast File System -options NFS #Network File system -options PROCFS #Process filesystem -options "COMPAT_43" #Compatible with BSD 4.3 -options UCONSOLE #X Console support -options "FAT_CURSOR" #block cursor in syscons or pccons -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options "NCONS=4" #4 virtual consoles -options BOUNCE_BUFFERS #include support for DMA bounce buffers -options USERCONFIG #Allow user configuration with -c -options GATEWAY #Pass packets -options IPFIREWALL #firewall code -options IPFIREWALL_VERBOSE #print information about dropped packets -options IPBROADCASTECHO=1 #send reply to broadcast pings -options IPMASKAGENT=1 #send reply to icmp mask requests - -config kernel root on wd0 swap on wd0 and wd1 and sd0 and sd1 dumps on wd0 - -controller isa0 -controller pci0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -#tape ft0 at fdc0 drive 2 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -controller ncr0 - -controller bt0 at isa? port "IO_BT0" bio irq ? vector btintr -controller ahb0 at isa? bio irq ? vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr -controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr -controller aic0 at isa? port 0x340 bio irq 11 vector aicintr -controller pas0 at isa? port 0x1f88 bio -controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mcd1 at isa? port 0x340 bio irq 11 vector mcdintr - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port? tty irq 7 vector lptintr -device lpt1 at isa? port? tty -device lpt2 at isa? port? tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ed2 at isa? port 0x300 net irq 10 iomem 0xcc000 vector edintr -device ep0 at isa? port 0x300 net irq 10 vector epintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device ppp 2 -pseudo-device sl 2 -pseudo-device pty 16 -pseudo-device speaker -pseudo-device gzip # Exec gzipped a.out's -pseudo-device bpfilter 1 diff --git a/sys/i386/conf/MINI b/sys/i386/conf/MINI deleted file mode 100644 index e038ee5..0000000 --- a/sys/i386/conf/MINI +++ /dev/null @@ -1,56 +0,0 @@ -# -# MINI -- A kernel to get FreeBSD on onto a disk. -# -# $Id: MINI,v 1.4 1994/10/20 00:19:37 phk Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident MINI -maxusers 1 - -options MATH_EMULATE #Support for x87 emulation -options FFS #Berkeley Fast File System -options "FAT_CURSOR" #block cursor in syscons or pccons -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options "NCONS=1" #1 virtual consoles -options BOUNCE_BUFFERS #include support for DMA bounce buffers - -config kernel root on wd0 swap on wd0 and wd1 and sd0 and sd1 dumps on wd0 - -controller isa0 -controller pci0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -controller ncr0 - -controller bt0 at isa? port "IO_BT0" bio irq ? vector btintr -controller ahb0 at isa? bio irq ? vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr -controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr -controller aic0 at isa? port 0x340 bio irq 11 vector aicintr - -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -#pseudo-device gzip # Exec gzipped a.out's diff --git a/sys/i386/conf/PCVT b/sys/i386/conf/PCVT deleted file mode 100644 index 00e927f..0000000 --- a/sys/i386/conf/PCVT +++ /dev/null @@ -1,103 +0,0 @@ -# -# PCVT - based on $Id: GENERIC,v 1.30 1995/01/28 05:01:43 jkh Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -cpu "I586_CPU" -ident GENERIC -maxusers 10 - -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options FFS #Berkeley Fast Filesystem -options NFS #Network Filesystem -options MSDOSFS #MSDOS Filesystem -options "CD9660" #ISO 9660 Filesystem -options PROCFS #Process filesystem -options "COMPAT_43" #Compatible with BSD 4.3 -options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device -options BOUNCE_BUFFERS #include support for DMA bounce buffers -options UCONSOLE #Allow users to grab the console - -# pcvt needs XCONSOLE for Xfree -options XCONSOLE -options "PCVT_FREEBSD=210" # pcvt running on FreeBSD 2.1 - -config kernel root on wd0 swap on wd0 and wd1 and sd0 and sd1 and vn0 dumps on wd0 - -controller isa0 -controller pci0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -tape ft0 at fdc0 drive 2 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -controller ncr0 -controller ahc0 - -controller bt0 at isa? port "IO_BT0" bio irq ? vector btintr -controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr -controller ahc1 at isa? bio irq ? vector ahcintr -controller ahb0 at isa? bio irq ? vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr -controller aic0 at isa? port 0x340 bio irq 11 vector aicintr -controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr -controller nca1 at isa? port 0x350 bio irq 5 vector ncaintr -controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr - -controller scbus0 - -device sd0 - -device st0 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mcd1 at isa? port 0x340 bio irq 11 vector mcdintr - -device scd0 at isa? port 0x230 bio - -# device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device vt0 at isa? port "IO_KBD" tty irq 1 vector pcrint - -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port? tty irq 7 vector lptintr -device lpt1 at isa? port? tty -device lpt2 at isa? port? tty - -device de0 -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device ep0 at isa? port 0x300 net irq 10 vector epintr -device lnc0 at isa? port 0x280 net irq 10 drq 0 vector lncintr -device le0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector le_intr -device ze0 at isa? port 0x300 net irq 5 iomem 0xd8000 vector zeintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 16 -pseudo-device speaker -pseudo-device gzip # Exec gzipped a.out's -pseudo-device vn diff --git a/sys/i386/conf/SYSCONS b/sys/i386/conf/SYSCONS deleted file mode 100644 index 5c1fb04..0000000 --- a/sys/i386/conf/SYSCONS +++ /dev/null @@ -1,87 +0,0 @@ -# -# SYSCONS -- Generic machine with WD/AHx family disks and syscons -# -# $Id: SYSCONS,v 1.20 1994/03/01 01:27:03 alm Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident SYSCONS -timezone 8 dst -maxusers 10 -maxfdescs 2048 #Max file descriptors per process -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options ISOFS #ISO File System -options NFS #Network File System -options PCFS #MSDOS File System -options "COMPAT_43" #Compatible with BSD 4.3 -options "TCP_COMPAT_42" #TCP/IP compatible with 4.2 -options XSERVER #Xserver -options UCONSOLE #X Console support -options "NCONS=8" #8 virtual consoles -options "FAT_CURSOR" #block cursor in syscons -options "STAR_SAVER" #syscons "stars" screen saver -#options GATEWAY #Host is a Gateway (forwards packets) - -config "386bsd" root on wd0 swap on wd0 and sd0 dumps on wd0 - -controller isa0 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -#tape ft0 at fdc0 drive 2 - -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr -disk wd2 at wdc1 drive 0 -disk wd3 at wdc1 drive 1 - -controller ahb0 at isa? bio irq 11 vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 16 -pseudo-device speaker - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/i386/eisa/eisadevs.c b/sys/i386/eisa/eisadevs.c deleted file mode 100644 index 0b7087f..0000000 --- a/sys/i386/eisa/eisadevs.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Written by Billie Alsup (balsup@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5)and OSF/1 operating - * systems. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * $Id: eisadevs.c,v 1.1 1995/04/23 08:55:43 julian Exp $ - */ - -/* - * Ported to run under FreeBSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ -/* This needs to be automatically generated.. */ - -#include <sys/param.h> -#include <sys/systm.h> /* isn't it a joy */ -#include <sys/kernel.h> /* to have three of these */ -#include <sys/conf.h> - -#include "i386/isa/isa_device.h" -#include "eisaconf.h" -#include "bt.h" -#if NBT > 0 -extern struct isa_driver btdriver; -int btintr(); -#endif -#if NSI > 0 -extern struct isa_driver sidriver; -int siintr(); -#endif - -struct eisa_dev eisa_dev[] = { -#if NBT > 0 - { "BUS",0x420,0,&bio_imask,{-1,&btdriver,0,0,-1,0,0,btintr,0,0,0,0,0}}, - { "BUS",0x470,0,&bio_imask,{-1,&btdriver,0,0,-1,0,0,btintr,0,0,0,0,0}}, -#endif /* NBT > 0 */ -/* add your devices here */ -#if NSI > 0 - { "SLX",0x411,0,&tty_imask,{-1,&sidriver,0,0,-1,0,0,siintr,0,0,0,0,0}}, -#endif /* NSI > 0 */ - - {0,0,0} -}; - diff --git a/sys/i386/ibcs2/README.iBCS2 b/sys/i386/ibcs2/README.iBCS2 deleted file mode 100644 index 2977b09..0000000 --- a/sys/i386/ibcs2/README.iBCS2 +++ /dev/null @@ -1,124 +0,0 @@ -What it is -========== - -This is a project that Sean Eric Fagan (sef@kithrup.com) started, and -Soren Schmidt (sos@login.dknet.dk, author of syscons) picked up. It allows -SYSVr3.2 i386 binaries (iBCS2 compatible) to run under FreeBSD-2.0. -We haven't been able to do an exhaustive test, of course, but we are able -to run at least the following programs: - - ISC 2.2 sh, vi, dd, date, wc, chmod, etc. - - SCO 3.2v2 runs most (coff) utils on a chroot'ed filesystem - Informix-2.10, gcc, bash, tcsh .... - - SCO 3.2v4 sh, gzip, GNU make, tcsh - -Some of those, for both ISC and SCO, used the shared libraries that are -available for those systems. Currently, the only way to run them, is to -get a copy of the shared libraries in question (e.g. /shlib/libc_s). -There might be a way to generate them from a package available for Linux, -but we haven't had the time or energy to do it ourself, and the last call -for volunteers resulted in nothing. If someone else wants to volunteer, -we would be grateful. - - -How to get it into the system -============================= - -There are two ways of getting iBCS2 support into the system. One is to use -Loadable Kernel Modules (LKM) to put it into the kernel at run-time. This -demands a kernel compiled with: - - options "COMPAT_IBCS2" - -This puts in the nessesary hooks to let the iBCS2 support do its thing. -One loads the iBCS2 support by using the command 'ibcs2' (in /usr/bin). -You can use 'modstat' to see the loaded modules. - -Another way is to compile it into the kernel. This is accomplished using: - - options "COMPAT_IBCS2" - options "IBCS2" - -in the kernel config file. - - -Where's what -============ - -The ibcs2 package consists of quite a few files located in ./sys/i386/ibcs2. -Here is a brief description of them: - -ibcs2.h: Basic header file defines iBCS2 types etc. - -ibcs2_dummy.c: Stubs to system calls not yet supported, or not feasible - to emulate. - -ibcs2_ioctl.c: Probably the single-most complicated part of it, this deals - with translating as many ioctl calls as possible between - BSD and iBCS2. - -ibcs2_misc.c: This has all of the wrapping routines that were thought - "easy" (at least initially) or that didn't fit anywhere else. - -ibcs2_file.c: Functions that deals with file I/O, such as getdents and read - which are more complex than one should expect. - -ibcs2_signal.c: This deals with the signal cruft, including both system - calls and signal translation. - -ibcs2_stats.c: This has all of the filesystem statistic wrappers - (stat, fstat, statfs, etc.). - -ibcs2_sysent.c: This has the system call table for iBCS2 programs, and is - NOT generated automatically. - -ibcs2_ipc.c: Stubs for the iBCS2 ipc calls (shm, msg, sem). - -ibcs2_isc.c: This deals with the ISC specific system call (cisc()). - -ibcs2_sysi86.c: This deals with the i86 specific system call (sysi86()). - -ibcs2_xenix.c: This deals with the Xenix specific system call (cxenix()). - (This also has some of SCO's POSIX-conformant functions.) - -imgact_coff.c: This is the functions that alllows the kernel to load - COFF programs. It also deals with shared library loading. - -There also exist two files (ibcs2_socksys.[ch]) which contains a proto -implementation of the SYSVr3 socket system, donated by Mostyn Lewis -(mostyn@mrl.com). It has not been tested much but is included as a basis -for network support, which is nessesary to run X and the likes. - - -What's Next -=========== - -Much needs to be done yet, mainly the socksys emulation should be looked -at to get socket support going. There currently also is no ipc support. -The sem & msg functions should map fairly easy to the BSD ones, but our -current BSD shm implementation is not even close to SYSV behavior, if it -works at all. -We currently have loaders or "image_activators" for other binary formats, -but none of them is really usefull yet (xout, elf). -Also most of the wrappers for the extra syscalls used by SYSVr4 has been -done, but not much testing yet because of lacks in the elf loader (but it -will run a statically linked SYSVr4 shell). - -All the wrappers should be tested one by one using every aspect of use -by the iBCS2 system. The tests we have done so far is to run small -testprograms to check a limited set of the emulation. When this proved -that the basics was functional, we tried with what iBCS2 programs where -at hand. This is by no means an exhaustive test or to say that the -emulation is errorfree, only a statement of overall functionality of -the emulator. - -Surely much work can be done here, but we are both kind of lazy, and did -the whole thing just for the fun of it, and mainly as a "can it be done" -project. - - Soren Schmidt (sos@login.dknet.dk) - Sean Eric Fagan (sef@kithrup.com) - - diff --git a/sys/i386/ibcs2/ibcs2.h b/sys/i386/ibcs2/ibcs2.h deleted file mode 100644 index 8063c7b..0000000 --- a/sys/i386/ibcs2/ibcs2.h +++ /dev/null @@ -1,280 +0,0 @@ -/*- - * Copyright (c) 1994 Søren Schmidt - * Copyright (c) 1994 Sean Eric Fagan - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - * $Id: ibcs2.h,v 1.3 1994/10/17 22:13:06 sos Exp $ - */ - -/* trace all iBCS2 system calls */ -extern int ibcs2_trace; - -/* convert signals between bsd & iBCS2 */ -extern int bsd_to_ibcs2_signal[]; -extern int ibcs2_to_bsd_signal[]; -char *ibcs2_sig_to_str(int); - -/* iBCS2 type definitions */ -typedef char * ibcs2_caddr_t; -typedef long ibcs2_daddr_t; -typedef long ibcs2_off_t; -typedef long ibcs2_key_t; -typedef unsigned short ibcs2_uid_t; -typedef unsigned long ibcs2_x_uid_t; -typedef unsigned short ibcs2_gid_t; -typedef unsigned long ibcs2_x_gid_t; -typedef short ibcs2_nlink_t; -typedef unsigned long ibcs2_x_nlink_t; -typedef short ibcs2_dev_t; -typedef long ibcs2_x_dev_t; -typedef unsigned short ibcs2_ino_t; -typedef unsigned long ibcs2_x_ino_t; -typedef unsigned short ibcs2_mode_t; -typedef unsigned long ibcs2_x_mode_t; -typedef short ibcs2_pid_t; -typedef long ibcs2_x_pid_t; -typedef unsigned int ibcs2_size_t; -typedef unsigned long ibcs2_time_t; -typedef struct timespec ibcs2_timestruc_t; -typedef long ibcs2_clock_t; -typedef unsigned int ibcs2_sigset_t; -typedef void (*ibcs2_sig_t) (int); - -/* misc defines */ -#define UA_ALLOC() \ - (ALIGN(((caddr_t)PS_STRINGS) + sizeof(struct ps_strings))) -#define IBCS2_RETVAL_SIZE (3 * sizeof(int)) -#define IBCS2_MAGIC_IN 0xe215 -#define IBCS2_MAGIC_OUT 0x8e11 -#define IBCS2_MAGIC_RETURN(arg) *(((int *)arg) - 3) = IBCS2_MAGIC_OUT; \ - *(((int *)arg) - 2) = retval[0]; \ - *(((int *)arg) - 1) = retval[1]; \ - return(0); - -/* iBCS2 signal numbers */ -#define IBCS2_SIGHUP 1 -#define IBCS2_SIGINT 2 -#define IBCS2_SIGQUIT 3 -#define IBCS2_SIGILL 4 -#define IBCS2_SIGTRAP 5 -#define IBCS2_SIGIOT 6 -#define IBCS2_SIGABRT 6 -#define IBCS2_SIGEMT 7 -#define IBCS2_SIGFPE 8 -#define IBCS2_SIGKILL 9 -#define IBCS2_SIGBUS 10 -#define IBCS2_SIGSEGV 11 -#define IBCS2_SIGSYS 12 -#define IBCS2_SIGPIPE 13 -#define IBCS2_SIGALRM 14 -#define IBCS2_SIGTERM 15 -#define IBCS2_SIGUSR1 16 -#define IBCS2_SIGUSR2 17 -#define IBCS2_SIGCLD 18 -#define IBCS2_SIGCHLD 18 -#define IBCS2_SIGPWR 19 -#define IBCS2_SIGWINCH 20 -#define IBCS2_SIGURG 21 -#define IBCS2_SIGPOLL 22 -#define IBCS2_SIGIO 22 -#define IBCS2_SIGSTOP 23 -#define IBCS2_SIGTSTP 24 -#define IBCS2_SIGCONT 25 -#define IBCS2_SIGTTIN 26 -#define IBCS2_SIGTTOU 27 -#define IBCS2_SIGVTALRM 28 -#define IBCS2_SIGPROF 29 -#define IBCS2_SIGGXCPU 30 -#define IBCS2_SIGGXFSZ 31 -#define IBCS2_NSIG 32 -#define IBCS2_SIGMASK 0xFF - -#define IBCS2_SA_NOCLDSTOP 0x01 -#define IBCS2_SIG_DFL (void (*)())0 -#define IBCS2_SIG_IGN (void (*)())1 -#define IBCS2_SIG_HOLD (void (*)())2 - -/* iBCS2 open & fcntl file modes */ -#define IBCS2_RDONLY 0x000 -#define IBCS2_WRONLY 0x001 -#define IBCS2_RDWR 0x002 -#define IBCS2_NDELAY 0x004 -#define IBCS2_APPEND 0x008 -#define IBCS2_SYNC 0x010 -#define IBCS2_NONBLOCK 0x080 -#define IBCS2_CREAT 0x100 -#define IBCS2_TRUNC 0x200 -#define IBCS2_EXCL 0x400 -#define IBCS2_NOCTTY 0x800 -#define IBCS2_PRIV 0x1000 - -/* iBCS2 fcntl commands */ -#define IBCS2_F_DUPFD 0 -#define IBCS2_F_GETFD 1 -#define IBCS2_F_SETFD 2 -#define IBCS2_F_GETFL 3 -#define IBCS2_F_SETFL 4 -#define IBCS2_F_GETLK 5 -#define IBCS2_F_SETLK 6 -#define IBCS2_F_SETLKW 7 - -#define IBCS2_F_RDLCK 1 -#define IBCS2_F_WRLCK 2 -#define IBCS2_F_UNLCK 3 - -/* iBCS2 poll commands */ -#define IBCS2_POLLIN 0x0001 -#define IBCS2_POLLPRI 0x0002 -#define IBCS2_POLLOUT 0x0004 -#define IBCS2_POLLERR 0x0008 -#define IBCS2_POLLHUP 0x0010 -#define IBCS2_POLLNVAL 0x0020 -#define IBCS2_POLLRDNORM 0x0040 -#define IBCS2_POLLWRNORM 0x0004 -#define IBCS2_POLLRDBAND 0x0080 -#define IBCS2_POLLWRBAND 0x0100 -#define IBCS2_READPOLL (IBCS2_POLLIN|IBCS2_POLLRDNORM|IBCS2_POLLRDBAND) -#define IBCS2_WRITEPOLL (IBCS2_POLLOUT|IBCS2_POLLWRNORM|IBCS2_POLLWRBAND) - -/* iBCS2 termio input modes */ -#define IBCS2_IGNBRK 0x0001 -#define IBCS2_BRKINT 0x0002 -#define IBCS2_IGNPAR 0x0004 -#define IBCS2_PARMRK 0x0008 -#define IBCS2_INPCK 0x0010 -#define IBCS2_ISTRIP 0x0020 -#define IBCS2_INLCR 0x0040 -#define IBCS2_IGNCR 0x0080 -#define IBCS2_ICRNL 0x0100 -#define IBCS2_IUCLC 0x0200 -#define IBCS2_IXON 0x0400 -#define IBCS2_IXANY 0x0800 -#define IBCS2_IXOFF 0x1000 -#define IBCS2_DOSMODE 0x8000 - -/* iBCS2 termio output modes */ -#define IBCS2_OPOST 0x0001 -#define IBCS2_OLCUC 0x0002 -#define IBCS2_ONLCR 0x0004 -#define IBCS2_OCRNL 0x0008 -#define IBCS2_ONOCR 0x0010 -#define IBCS2_ONLRET 0x0020 -#define IBCS2_OFILL 0x0040 -#define IBCS2_OFDEL 0x0080 -#define IBCS2_NL1 0x0100 -#define IBCS2_CR1 0x0200 -#define IBCS2_CR2 0x0400 -#define IBCS2_TAB1 0x0800 -#define IBCS2_TAB2 0x1000 -#define IBCS2_BS1 0x2000 -#define IBCS2_VT1 0x4000 -#define IBCS2_FF1 0x8000 - -/* iBCS2 termio control modes */ -#define IBCS2_CBAUD 0x000F -#define IBCS2_B0 0x0 -#define IBCS2_B50 0x0001 -#define IBCS2_B75 0x0002 -#define IBCS2_B110 0x0003 -#define IBCS2_B134 0x0004 -#define IBCS2_B150 0x0005 -#define IBCS2_B200 0x0006 -#define IBCS2_B300 0x0007 -#define IBCS2_B600 0x0008 -#define IBCS2_B1200 0x0009 -#define IBCS2_B1800 0x000A -#define IBCS2_B2400 0x000B -#define IBCS2_B4800 0x000C -#define IBCS2_B9600 0x000D -#define IBCS2_B19200 0x000E -#define IBCS2_B38400 0x000F -#define IBCS2_CSIZE 0x0030 -#define IBCS2_CS5 0x0 -#define IBCS2_CS6 0x0010 -#define IBCS2_CS7 0x0020 -#define IBCS2_CS8 0x0030 -#define IBCS2_CSTOPB 0x0040 -#define IBCS2_CREAD 0x0080 -#define IBCS2_PARENB 0x0100 -#define IBCS2_PARODD 0x0200 -#define IBCS2_HUPCL 0x0400 -#define IBCS2_CLOCAL 0x0800 -#define IBCS2_RCV1EN 0x1000 -#define IBCS2_XMT1EN 0x2000 -#define IBCS2_LOBLK 0x4000 -#define IBCS2_XCLUDE 0x8000 - -/* iBCS2 termio line discipline 0 modes */ -#define IBCS2_ISIG 0x0001 -#define IBCS2_ICANON 0x0002 -#define IBCS2_XCASE 0x0004 -#define IBCS2_ECHO 0x0008 -#define IBCS2_ECHOE 0x0010 -#define IBCS2_ECHOK 0x0020 -#define IBCS2_ECHONL 0x0040 -#define IBCS2_NOFLSH 0x0080 - -/* iBCS2 control characters */ -#define IBCS2_VINTR 0 -#define IBCS2_VQUIT 1 -#define IBCS2_VERASE 2 -#define IBCS2_VKILL 3 -#define IBCS2_VEOF 4 /* ICANON */ -#define IBCS2_VEOL 5 /* ICANON */ -#define IBCS2_VEOL2 6 -#define IBCS2_VSWTCH 7 -#define IBCS2_VMIN 4 /* !ICANON */ -#define IBCS2_VTIME 5 /* !ICANON */ -#define IBCS2_VSUSP 10 -#define IBCS2_VSTART 11 -#define IBCS2_VSTOP 12 -#define IBCS2_NCC 8 /* termio */ -#define IBCS2_NCCS 13 /* termios */ - -/* iBCS2 ulimit commands */ -#define IBCS2_GETFSIZE 1 -#define IBCS2_SETFSIZE 2 -#define IBCS2_GETPSIZE 3 -#define IBCS2_GETMOPEN 4 - -/* iBCS2 emulator trace control */ -#define IBCS2_TRACE_FILE 0x00000001 -#define IBCS2_TRACE_IOCTL 0x00000002 -#define IBCS2_TRACE_ISC 0x00000004 -#define IBCS2_TRACE_MISC 0x00000008 -#define IBCS2_TRACE_SIGNAL 0x00000010 -#define IBCS2_TRACE_STATS 0x00000020 -#define IBCS2_TRACE_XENIX 0x00000040 -#define IBCS2_TRACE_IOCTLCNV 0x00000080 -#define IBCS2_TRACE_COFF 0x01000000 -#define IBCS2_TRACE_ELF 0x02000000 -#define IBCS2_TRACE_ALL 0x0300007f - -#define IBCS2_FP_NO 0 /* no fp support */ -#define IBCS2_FP_SW 1 /* software emulator */ -#define IBCS2_FP_287 2 /* 80287 FPU */ -#define IBCS2_FP_387 3 /* 80387 FPU */ - diff --git a/sys/i386/ibcs2/ibcs2_dummy.c b/sys/i386/ibcs2/ibcs2_dummy.c deleted file mode 100644 index 7a7c102..0000000 --- a/sys/i386/ibcs2/ibcs2_dummy.c +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * Copyright (c) 1994 Søren Schmidt - * Copyright (c) 1994 Sean Eric Fagan - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - * $Id: ibcs2_dummy.c,v 1.1 1994/10/14 08:52:59 sos Exp $ - */ - -#include <i386/ibcs2/ibcs2.h> -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/sysent.h> -#include <sys/errno.h> -#include <machine/cpu.h> -#include <machine/psl.h> -#include <machine/reg.h> - -int -ibcs2_nosys(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: no such syscall eax = %d(0x%x)\n", - ((struct trapframe*)p->p_md.md_regs)->tf_eax, - ((struct trapframe*)p->p_md.md_regs)->tf_eax); - return ENOSYS; -} - -int -ibcs2_clocal(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'clocal' not implemented yet\n"); - return EINVAL; -} - -int -ibcs2_sysfs(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'sysfs' not implemented yet\n"); - return EINVAL; -} - -int -ibcs2_uadmin(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'uadmin' not implemented yet\n"); - return EINVAL; -} - -int -ibcs2_advfs(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'advfs' not implemented yet\n"); - return EINVAL; -} - -int -ibcs2_unadvfs(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'unadvfs' not implemented yet\n"); - return EINVAL; -} - -int -ibcs2_libattach(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'libattach' obsolete\n"); - return EINVAL; -} - -int -ibcs2_libdetach(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'libdetach' obsolete\n"); - return EINVAL; -} - -int -ibcs2_plock(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'plock' not supported\n"); - return 0; -} - - -/* - * getmsg/putmsg are STREAMS related system calls - * We don't have STREAMS (yet??) but fake it anyways - */ -int -ibcs2_getmsg(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'getmsg' not supported\n"); - return 0; -} - -int -ibcs2_putmsg(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'putmsg' not supported\n"); - return 0; -} - -/* - * The following are RFS system calls - * We don't have RFS. - */ -int -ibcs2_rfdebug(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'rdebug' not supported\n"); - return EINVAL; -} - -int -ibcs2_rfstart(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'rfstart' not supported\n"); - return EINVAL; -} - -int -ibcs2_rfstop(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'rfstop' not supported\n"); - return EINVAL; -} - -int -ibcs2_rfsys(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'rfsys' not supported\n"); - return EINVAL; -} - -int -ibcs2_rmount(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'rmount' not supported\n"); - return EINVAL; -} - -int -ibcs2_rumount(struct proc *p, void *args, int *retval) -{ - printf("IBCS2: 'rumount' not supported\n"); - return EINVAL; -} diff --git a/sys/i386/ibcs2/ibcs2_file.c b/sys/i386/ibcs2/ibcs2_file.c deleted file mode 100644 index c621758..0000000 --- a/sys/i386/ibcs2/ibcs2_file.c +++ /dev/null @@ -1,525 +0,0 @@ -/*- - * Copyright (c) 1994 Søren Schmidt - * Copyright (c) 1994 Sean Eric Fagan - * All rights reserved. - * - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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. - * - * $Id: ibcs2_file.c,v 1.2 1994/12/14 22:03:48 sos Exp $ - */ - -#include <i386/ibcs2/ibcs2.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/fcntl.h> -#include <sys/file.h> -#include <sys/filedesc.h> -#include <sys/proc.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/vnode.h> -#include <sys/malloc.h> -#include <sys/exec.h> -#include <vm/vm.h> -#include <ufs/ufs/dir.h> - - -struct ibcs2_close_args { - int fd; -}; - -int -ibcs2_close(struct proc *p, struct ibcs2_close_args *args, int *retval) -{ - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'close' fd=%d\n", args->fd); - return close(p, args, retval); -} - -struct ibcs2_creat_args { - char *fname; - int fmode; -}; - -int -ibcs2_creat(struct proc *p, struct ibcs2_creat_args *args, int *retval) -{ - struct args { - char *fname; - int mode; - int crtmode; - } bsd_open_args; - - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'creat' name=%s, mode=%x\n", - args->fname, args->fmode); - bsd_open_args.fname = args->fname; - bsd_open_args.crtmode = args->fmode; - bsd_open_args.mode = O_WRONLY | O_CREAT | O_TRUNC; - return open(p, &bsd_open_args, retval); -} - -int -ibcs2_dup(struct proc *p, void *args, int *retval) -{ - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'dup'\n"); - return dup(p, args, retval); -} - -struct ibcs2_flock { - short l_type; - short l_whence; - ibcs2_off_t l_start; - ibcs2_off_t l_len; - short l_sysid; - ibcs2_pid_t l_pid; -}; - -static void -ibcs2_to_bsd_flock(struct ibcs2_flock *ibcs2_flock, struct flock *bsd_flock) -{ - switch (ibcs2_flock->l_type) { - case IBCS2_F_RDLCK: - bsd_flock->l_type = F_RDLCK; - break; - case IBCS2_F_WRLCK: - bsd_flock->l_type = F_WRLCK; - break; - case IBCS2_F_UNLCK: - bsd_flock->l_type = F_UNLCK; - break; - } - bsd_flock->l_whence = ibcs2_flock->l_whence; - bsd_flock->l_start = (off_t)ibcs2_flock->l_start; - bsd_flock->l_len = (off_t)ibcs2_flock->l_len; - bsd_flock->l_pid = (pid_t)ibcs2_flock->l_pid; -} - -static void -bsd_to_ibcs2_flock(struct flock *bsd_flock, struct ibcs2_flock *ibcs2_flock) -{ - switch (bsd_flock->l_type) { - case F_RDLCK: - ibcs2_flock->l_type = IBCS2_F_RDLCK; - break; - case F_WRLCK: - ibcs2_flock->l_type = IBCS2_F_WRLCK; - break; - case F_UNLCK: - ibcs2_flock->l_type = IBCS2_F_UNLCK; - break; - } - ibcs2_flock->l_whence = bsd_flock->l_whence; - ibcs2_flock->l_start = (ibcs2_off_t)bsd_flock->l_start; - ibcs2_flock->l_len = (ibcs2_off_t)bsd_flock->l_len; - ibcs2_flock->l_sysid = 0; - ibcs2_flock->l_pid = (ibcs2_pid_t)bsd_flock->l_pid; -} - -struct ibcs2_fcntl_args { - int fd; - int cmd; - int arg; -}; - -int -ibcs2_fcntl(struct proc *p, struct ibcs2_fcntl_args *args, int *retval) -{ - int error, result; - struct fcntl_args { - int fd; - int cmd; - int arg; - } fcntl_args; - struct ibcs2_flock ibcs2_flock; - struct flock *bsd_flock = (struct flock *)UA_ALLOC(); - - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'fcntl' fd=%d, cmd=%d arg=%d\n", - args->fd, args->cmd, args->arg); - - fcntl_args.fd = args->fd; - fcntl_args.arg = 0; - - switch (args->cmd) { - case IBCS2_F_DUPFD: - fcntl_args.cmd = F_DUPFD; - return fcntl(p, &fcntl_args, retval); - - case IBCS2_F_GETFD: - fcntl_args.cmd = F_GETFD; - return fcntl(p, &fcntl_args, retval); - - case IBCS2_F_SETFD: - fcntl_args.cmd = F_SETFD; - return fcntl(p, &fcntl_args, retval); - - case IBCS2_F_GETFL: - fcntl_args.cmd = F_GETFL; - error = fcntl(p, &fcntl_args, &result); - *retval = 0; - if (result & O_RDONLY) *retval |= IBCS2_RDONLY; - if (result & O_WRONLY) *retval |= IBCS2_WRONLY; - if (result & O_RDWR) *retval |= IBCS2_RDWR; - if (result & O_NDELAY) *retval |= IBCS2_NONBLOCK; - if (result & O_APPEND) *retval |= IBCS2_APPEND; - if (result & O_FSYNC) *retval |= IBCS2_SYNC; - return error; - - case IBCS2_F_SETFL: - if (args->arg & IBCS2_NDELAY) fcntl_args.arg |= O_NONBLOCK; - if (args->arg & IBCS2_APPEND) fcntl_args.arg |= O_APPEND; - if (args->arg & IBCS2_SYNC) fcntl_args.arg |= O_FSYNC; - fcntl_args.cmd = F_SETFL; - return fcntl(p, &fcntl_args, retval); - - case IBCS2_F_GETLK: - if ((error = copyin((caddr_t)args->arg, (caddr_t)&ibcs2_flock, - sizeof(struct ibcs2_flock)))) - return error; - ibcs2_to_bsd_flock(&ibcs2_flock, bsd_flock); - fcntl_args.cmd = F_GETLK; - fcntl_args.arg = (int)bsd_flock; - if (error = fcntl(p, &fcntl_args, retval)) - return error; - bsd_to_ibcs2_flock(bsd_flock, &ibcs2_flock); - return copyout((caddr_t)&ibcs2_flock, (caddr_t)args->arg, - sizeof(struct ibcs2_flock)); - - case IBCS2_F_SETLK: - if ((error = copyin((caddr_t)args->arg, (caddr_t)&ibcs2_flock, - sizeof(struct ibcs2_flock)))) - return error; - ibcs2_to_bsd_flock(&ibcs2_flock, bsd_flock); - fcntl_args.cmd = F_SETLK; - fcntl_args.arg = (int)bsd_flock; - return fcntl(p, &fcntl_args, retval); - - case IBCS2_F_SETLKW: - if ((error = copyin((caddr_t)args->arg, (caddr_t)&ibcs2_flock, - sizeof(struct ibcs2_flock)))) - return error; - ibcs2_to_bsd_flock(&ibcs2_flock, bsd_flock); - fcntl_args.cmd = F_SETLKW; - fcntl_args.arg = (int)bsd_flock; - return fcntl(p, &fcntl_args, retval); - } - return EINVAL; -} - -struct ibcs2_dirent { - ibcs2_ino_t d_ino; - ibcs2_off_t d_off; - unsigned short d_reclen; - char d_name[256]; -}; - -struct ibcs2_getdents_args { - int fd; - char *buf; - int nbytes; -}; - -#define BSD_DIRENT(cp) ((struct direct *)(cp)) -#define IBCS2_RECLEN(p) \ - (((2*sizeof(long)+sizeof(short)+BSD_DIRENT(p)->d_namlen+1)+3)&~3) - -int -ibcs2_getdents(struct proc *p, struct ibcs2_getdents_args *args, int *retval) -{ - struct vnode *vp; - struct ibcs2_dirent dir; - struct file *fp; - struct uio auio; - struct iovec aiov; - off_t off; - caddr_t inp, buf, outp; - int len, reclen, resid; - int buflen, error, eofflag; - - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'getdents' fd = %d, size = %d\n", - args->fd, args->nbytes); - if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) - return error; - if ((fp->f_flag & FREAD) == 0) - return EBADF; - vp = (struct vnode *)fp->f_data; - if (vp->v_type != VDIR) - return EINVAL; - buflen = min(DEFAULT_PAGE_SIZE, max(DIRBLKSIZ, args->nbytes)); - buf = malloc(buflen, M_TEMP, M_WAITOK); - VOP_LOCK(vp); - off = fp->f_offset; -again: - aiov.iov_base = buf; - aiov.iov_len = buflen; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; - auio.uio_resid = buflen; - auio.uio_offset = off & ~(DIRBLKSIZ-1); - if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, NULL)) - goto out; - inp = buf + (off & (DIRBLKSIZ-1)); - buflen -= off & (DIRBLKSIZ-1); - outp = args->buf; - resid = args->nbytes; - if ((len = (buflen - auio.uio_resid)) <= 0) - goto eof; - for (; len > 0 && resid > 0; len -= reclen) { - reclen = BSD_DIRENT(inp)->d_reclen; - if (reclen & 3) - panic("ibcs2_getdents"); - if (BSD_DIRENT(inp)->d_ino == 0) { - off += reclen; - inp += reclen; - continue; - } - if (IBCS2_RECLEN(inp) > len || resid < IBCS2_RECLEN(inp)) { - outp++; - break; - } - bzero(&dir, sizeof(struct ibcs2_dirent)); - dir.d_ino = BSD_DIRENT(inp)->d_ino; - dir.d_off = (ibcs2_off_t)off; - dir.d_reclen = IBCS2_RECLEN(inp); - bcopy(BSD_DIRENT(inp)->d_name, &dir.d_name, - BSD_DIRENT(inp)->d_namlen); - if (error = copyout(&dir, outp, dir.d_reclen)) - goto out; - outp += IBCS2_RECLEN(inp); - resid -= IBCS2_RECLEN(inp); - off += reclen; - inp += reclen; - } - if (outp == args->buf) - goto again; - fp->f_offset = off; -eof: - *retval = args->nbytes - resid; -out: - VOP_UNLOCK(vp); - free(buf, M_TEMP); - return error; -} - -struct ibcs2_open_args { - char *fname; - int fmode; - int crtmode; -}; - -int -ibcs2_open(struct proc *p, struct ibcs2_open_args *args, int *retval) -{ - int bsd_mode = 0; - int noctty = args->fmode & 0x8000; - int error; - - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'open' name=%s, flags=%x, mode=%x\n", - args->fname, args->fmode, args->crtmode); - if (args->fmode & IBCS2_RDONLY) bsd_mode |= O_RDONLY; - if (args->fmode & IBCS2_WRONLY) bsd_mode |= O_WRONLY; - if (args->fmode & IBCS2_RDWR) bsd_mode |= O_RDWR; - if (args->fmode & IBCS2_NDELAY) bsd_mode |= O_NONBLOCK; - if (args->fmode & IBCS2_APPEND) bsd_mode |= O_APPEND; - if (args->fmode & IBCS2_SYNC) bsd_mode |= O_FSYNC; - if (args->fmode & IBCS2_NONBLOCK) bsd_mode |= O_NONBLOCK; - if (args->fmode & IBCS2_PRIV) bsd_mode |= O_EXLOCK; - if (args->fmode & IBCS2_CREAT) bsd_mode |= O_CREAT; - if (args->fmode & IBCS2_TRUNC) bsd_mode |= O_TRUNC | O_CREAT; - if (args->fmode & IBCS2_EXCL) bsd_mode |= O_EXCL; - if (args->fmode & IBCS2_NOCTTY) bsd_mode |= O_NOCTTY; - args->fmode = bsd_mode; - error = open(p, args, retval); - if (!error && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { - struct filedesc *fdp = p->p_fd; - struct file *fp = fdp->fd_ofiles[*retval]; - - if (fp->f_type == DTYPE_VNODE) - (fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t) 0, p); - } - return error; -} - -struct ibcs2_read_args { - int fd; - char *buffer; - unsigned int count; -}; - -int -ibcs2_read(struct proc *p, struct ibcs2_read_args *args, int *retval) -{ - struct ibcs2_dir { - ibcs2_ino_t inode; - char fname[14]; - } dirbuf; - struct vnode *vp; - struct file *fp; - struct uio auio; - struct iovec aiov; - caddr_t inp, buf, outp; - off_t off; - int buflen, error, eofflag; - int len, reclen, resid; - - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'read' fd=%d, count=%d\n", - args->fd, args->count); - - if (error = getvnode(p->p_fd, args->fd, &fp)) - if (error == EINVAL) - return read(p, args, retval); - else - return error; - if ((fp->f_flag & FREAD) == 0) - return EBADF; - vp = (struct vnode *)fp->f_data; - if (vp->v_type != VDIR) { - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("normal read\n"); - return read(p, args, retval); - } - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("read directory\n"); - buflen = min(DEFAULT_PAGE_SIZE, max(DIRBLKSIZ, args->count)); - buf = malloc(buflen, M_TEMP, M_WAITOK); - VOP_LOCK(vp); - off = fp->f_offset; -again: - aiov.iov_base = buf; - aiov.iov_len = buflen; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; - auio.uio_resid = buflen; - auio.uio_offset = off & ~(DIRBLKSIZ-1); - if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, NULL)) - goto out; - inp = buf + (off & (DIRBLKSIZ-1)); - buflen -= off & (DIRBLKSIZ-1); - outp = args->buffer; - resid = args->count; - if ((len = (buflen - auio.uio_resid)) == 0) - goto eof; - for (; len > 0 && resid > 0; len -= reclen) { - reclen = BSD_DIRENT(inp)->d_reclen; - if (reclen & 3) - panic("ibcs2_read"); - if (BSD_DIRENT(inp)->d_ino == 0) { - inp += reclen; - off += reclen; - continue; - } - if (reclen > len || resid < sizeof(struct ibcs2_dir)) { - outp++; - break; - } - /* - * TODO: break up name if > 14 chars - * put 14 chars in each dir entry wtih d_ino = 0xffff - * and set the last dir entry's d_ino = inode - */ - dirbuf.inode = (BSD_DIRENT(inp)->d_ino > 0x0000fffe) ? - 0xfffe : BSD_DIRENT(inp)->d_ino; - bcopy(BSD_DIRENT(inp)->d_name, &dirbuf.fname, 14); /* XXX */ - if (error = copyout(&dirbuf, outp, sizeof(dirbuf))) - goto out; - off += reclen; - inp += reclen; - outp += sizeof(struct ibcs2_dir); - resid -= sizeof(struct ibcs2_dir); - } - if (outp == args->buffer) - goto again; - fp->f_offset = off; -eof: - *retval = args->count - resid; -out: - VOP_UNLOCK(vp); - free(buf, M_TEMP); - return error; -} - -struct ibcs2_seek_args { - int fdes; - ibcs2_off_t off; - int whence; -}; - -int -ibcs2_seek(struct proc *p, struct ibcs2_seek_args *args, int *retval) -{ - - struct seek_args { - int fdes; - int pad; - off_t off; - int whence; - } tmp_args; - off_t tmp_retval; - int error; - - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'seek' fd=%d, offset=%d, how=%d\n", - args->fdes, args->off, args->whence); - tmp_args.fdes = args->fdes; - tmp_args.off = (off_t)args->off; - tmp_args.whence = args->whence; - error = lseek(p, &tmp_args, &tmp_retval); - *retval = (int)tmp_retval; - return error; -} - -struct ibcs2_write_args { - int fd; - char *buffer; - unsigned int count; -}; - -int -ibcs2_write(struct proc *p, struct ibcs2_write_args *args, int *retval) -{ - if (ibcs2_trace & IBCS2_TRACE_FILE) - printf("IBCS2: 'write' fd=%d, count=%d\n", - args->fd, args->count); - return write(p, args, retval); -} diff --git a/sys/i386/ibcs2/ibcs2_stats.c b/sys/i386/ibcs2/ibcs2_stats.c deleted file mode 100644 index 4a8a80c..0000000 --- a/sys/i386/ibcs2/ibcs2_stats.c +++ /dev/null @@ -1,274 +0,0 @@ -/*- - * Copyright (c) 1994 Sean Eric Fagan - * Copyright (c) 1994 Søren Schmidt - * All rights reserved. - * - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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. - * - * $Id: ibcs2_stats.c,v 1.2 1995/05/30 08:00:11 rgrimes Exp $ - */ - -#include <i386/ibcs2/ibcs2.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> -#include <sys/file.h> -#include <sys/filedesc.h> -#include <sys/mount.h> -#include <sys/namei.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/vnode.h> -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/vm_map.h> -#include <vm/vm_kern.h> - -struct ibcs2_stat { - ibcs2_dev_t stat_dev; - ibcs2_ino_t stat_ino; - ibcs2_mode_t stat_mode; - ibcs2_nlink_t stat_nlink; - ibcs2_uid_t stat_uid; - ibcs2_gid_t stat_gid; - ibcs2_dev_t stat_rdev; - ibcs2_size_t stat_size; - ibcs2_time_t stat_atime; - ibcs2_time_t stat_mtime; - ibcs2_time_t stat_ctime; -}; - -struct ibcs2_stat_args { - char *path; - struct ibcs2_stat *buf; -}; - -static int -stat_copyout(struct stat *buf, void *ubuf) -{ - struct ibcs2_stat tbuf; - - tbuf.stat_dev = buf->st_dev; - tbuf.stat_ino = buf->st_ino; - tbuf.stat_mode = buf->st_mode; - tbuf.stat_nlink = buf->st_nlink; - tbuf.stat_uid = buf->st_uid; - tbuf.stat_gid = buf->st_gid; - tbuf.stat_rdev = buf->st_rdev; - tbuf.stat_size = buf->st_size; - tbuf.stat_atime = buf->st_atime; - tbuf.stat_mtime = buf->st_mtime; - tbuf.stat_ctime = buf->st_ctime; - return copyout(&tbuf, ubuf, sizeof(tbuf)); -} - -int -ibcs2_stat(struct proc *p, struct ibcs2_stat_args *args, int *retval) -{ - struct stat buf; - struct ibcs2_stat tbuf; - struct nameidata nd; - int error; - - if (ibcs2_trace & IBCS2_TRACE_STATS) - printf("IBCS2: 'stat' path=%s\n", args->path); - - /* XXX use of 'curproc' should be 'p'?*/ - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, args->path, curproc); - error = namei(&nd); - - if (!error) { - error = vn_stat(nd.ni_vp, &buf, p); - vput(nd.ni_vp); - } - - if (!error) - error = stat_copyout(&buf, args->buf); - - return error; -} - -int -ibcs2_lstat(struct proc *p, struct ibcs2_stat_args *args, int *retval) -{ - struct stat buf; - struct ibcs2_stat tbuf; - struct nameidata nd; - int error; - - if (ibcs2_trace & IBCS2_TRACE_STATS) - printf("IBCS2: 'lstat' path=%s\n", args->path); - - /* XXX use of 'curproc' should be 'p'?*/ - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, args->path, curproc); - error = namei(&nd); - - if (!error) { - error = vn_stat(nd.ni_vp, &buf, p); - vput(nd.ni_vp); - } - - if (!error) - error = stat_copyout(&buf, args->buf); - - return error; -} - -struct ibcs2_fstat_args { - int fd; - struct ibcs2_stat *buf; -}; - -int -ibcs2_fstat(struct proc *p, struct ibcs2_fstat_args *args, int *retval) -{ - struct ibcs2_stat tbuf; - struct filedesc *fdp = p->p_fd; - struct file *fp; - struct stat buf; - int error; - - if (ibcs2_trace & IBCS2_TRACE_STATS) - printf("IBCS2: 'fstat' fd=%d\n", args->fd); - if ((unsigned)args->fd >= fdp->fd_nfiles - || (fp = fdp->fd_ofiles[args->fd]) == NULL) - return EBADF; - - switch (fp->f_type) { - case DTYPE_VNODE: - error = vn_stat((struct vnode *)fp->f_data, &buf, p); - break; - - case DTYPE_SOCKET: - error = soo_stat((struct socket *)fp->f_data, &buf); - break; - - default: - panic("IBCS2 fstat"); - /*NOTREACHED*/ - } - if (!error) - error = stat_copyout(&buf, args->buf); - - return error; -} - -struct ibcs2_statfs { - short f_fstyp; - long f_bsize; - long f_frsize; - long f_blocks; - long f_bfree; - long f_files; - long f_ffree; - char f_fname[6]; - char f_fpack[6]; -}; - -struct ibcs2_statfs_args { - char *path; - struct statfs *buf; - int len; - int fstyp; -}; - -int -ibcs2_statfs(struct proc *p, struct ibcs2_statfs_args *args, int *retval) -{ - struct mount *mp; - struct nameidata *ndp; - struct statfs *sp; - struct nameidata nd; - struct ibcs2_statfs tmp; - int error; - - if (ibcs2_trace & IBCS2_TRACE_STATS) - printf("IBCS2: 'statfs' path=%s\n", args->path); - ndp = &nd; - /* XXX use of 'curproc' should be 'p'?*/ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc); - if (error = namei(ndp)) - return error; - mp = ndp->ni_vp->v_mount; - sp = &mp->mnt_stat; - vrele(ndp->ni_vp); - if (error = VFS_STATFS(mp, sp, p)) - return error; - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - tmp.f_fstyp = sp->f_type; - tmp.f_bsize = sp->f_bsize; - tmp.f_frsize = sp->f_iosize; - tmp.f_blocks = sp->f_blocks; - tmp.f_bfree = sp->f_bfree; - tmp.f_ffree = sp->f_ffree; - tmp.f_files = sp->f_files; - bcopy (sp->f_mntonname, tmp.f_fname, 6); - bcopy (sp->f_mntfromname, tmp.f_fpack, 6); - return copyout((caddr_t)&tmp, (caddr_t)args->buf, args->len); -} - -struct ibcs2_fstatfs_args { - int fd; - struct statfs *buf; -}; - -int -ibcs2_fstatfs(struct proc *p, struct ibcs2_fstatfs_args *args, int *retval) -{ - struct file *fp; - struct mount *mp; - struct statfs *sp; - struct ibcs2_statfs tmp; - int error; - - if (ibcs2_trace & IBCS2_TRACE_STATS) - printf("IBCS2: 'fstatfs' fd=%d\n", args->fd); - if (error = getvnode(p->p_fd, args->fd, &fp)) - return error; - mp = ((struct vnode *)fp->f_data)->v_mount; - sp = &mp->mnt_stat; - if (error = VFS_STATFS(mp, sp, p)) - return error; - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - tmp.f_fstyp = sp->f_type; - tmp.f_bsize = sp->f_bsize; - tmp.f_frsize = sp->f_iosize; - tmp.f_blocks = sp->f_blocks; - tmp.f_bfree = sp->f_bfree; - tmp.f_ffree = sp->f_ffree; - tmp.f_files = sp->f_files; - bcopy (sp->f_mntonname, tmp.f_fname, 6); - bcopy (sp->f_mntfromname, tmp.f_fpack, 6); - return copyout((caddr_t)&tmp, (caddr_t)args->buf, - sizeof(struct statfs)); -} diff --git a/sys/i386/include/dkio.h b/sys/i386/include/dkio.h deleted file mode 100644 index c6d78d5..0000000 --- a/sys/i386/include/dkio.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)dkio.h 5.2 (Berkeley) 1/18/91 - * $Id: dkio.h,v 1.3 1993/11/07 17:42:51 wollman Exp $ - */ - -#ifndef _MACHINE_DKIO_H_ -#define _MACHINE_DKIO_H_ - -/* - * Structures and definitions for disk io control commands - * - * THIS WHOLE AREA NEEDS MORE THOUGHT. FOR NOW JUST IMPLEMENT - * ENOUGH TO READ AND WRITE HEADERS ON MASSBUS DISKS. EVENTUALLY - * SHOULD BE ABLE TO DETERMINE DRIVE TYPE AND DO OTHER GOOD STUFF. - */ - -/* disk io control commands */ -#define DKIOCHDR _IO('d', 1) /* next I/O will read/write header */ - -#endif /* !_MACHINE_DKIO_H_ */ diff --git a/sys/i386/include/eflags.h b/sys/i386/include/eflags.h deleted file mode 100644 index 663b317..0000000 --- a/sys/i386/include/eflags.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * $Id$ - */ - -#ifndef _I386_EFLAGS_H_ -#define _I386_EFLAGS_H_ - -/* - * i386 flags register - */ -#define EFL_CF 0x00000001 /* carry */ -#define EFL_PF 0x00000004 /* parity of low 8 bits */ -#define EFL_AF 0x00000010 /* carry out of bit 3 */ -#define EFL_ZF 0x00000040 /* zero */ -#define EFL_SF 0x00000080 /* sign */ -#define EFL_TF 0x00000100 /* trace trap */ -#define EFL_IF 0x00000200 /* interrupt enable */ -#define EFL_DF 0x00000400 /* direction */ -#define EFL_OF 0x00000800 /* overflow */ -#define EFL_IOPL 0x00003000 /* IO privilege level: */ -#define EFL_IOPL_KERNEL 0x00000000 /* kernel */ -#define EFL_IOPL_USER 0x00003000 /* user */ -#define EFL_NT 0x00004000 /* nested task */ -#define EFL_RF 0x00010000 /* resume without tracing */ -#define EFL_VM 0x00020000 /* virtual 8086 mode */ - -#define EFL_USER_SET (EFL_IF) -#define EFL_USER_CLEAR (EFL_IOPL|EFL_NT|EFL_RF) - -#endif _I386_EFLAGS_H_ diff --git a/sys/i386/include/ioctl_pc.h b/sys/i386/include/ioctl_pc.h deleted file mode 100644 index bc6a255..0000000 --- a/sys/i386/include/ioctl_pc.h +++ /dev/null @@ -1,797 +0,0 @@ -/* Copyright 1992,1993 by Holger Veit - * May be freely used with Bill Jolitz's port of - * 386bsd and may be included in a 386bsd collection - * as long as binary and source are available and reproduce the above - * copyright. - * - * You may freely modify this code and contribute improvements based - * on this code as long as you don't claim to be the original author. - * Commercial use of this source requires permittance of the copyright - * holder. A general license for 386bsd will override this restriction. - * - * Use at your own risk. The copyright holder or any person who makes - * this code available for the public (administrators of public archives - * for instance) are not responsible for any harm to hardware or software - * that might happen due to wrong application or program faults. - * - * Addendum: The XFree86 developers and maintainers are hereby granted the - * right to distribute this file together with their source distributions - * and patchkits of XFree86 without further explicit permission of the - * above copyright holder. - * This and another file is a necessary include file for the unified - * pccons/codrv implementation of XFree86. This file is needed if - * someone wants to compile an Xserver on a system which does not have, - * for some reasons, the codrv console driver which comes with this file. The - * availability of this file avoids a large number of #ifdef's and - * allows to make the xserver code easier runtime-configurable. - * To make use of this file, it must be installed in /usr/include/sys. - * This file is not the complete console device driver, so it is possible - * that properties described in this file do not work without having the - * complete driver distribution. This is not a fault of the Xserver that - * was built with this file. - * - * - * - * From: @(#)$RCSfile: ioctl_pc.h,v - * Revision: 1.1.1.1 (Contributed to 386bsd) - * Date: 1993/06/12 14:58:11 - * - * Important notice: #defined values are subject to be changed!!! - * Don't use the constant, use the name instead! - * - * codrv1-style uses ioctls 'K': 1-33,255 - * 'V': 100-109 - * - * -hv- Holger Veit, Holger.Veit@gmd.de - * -hm Hellmuth Michaelis, hm@hcshh.hcs.de - * -vak- Sergey Vakulenko, vak@kiae.su - * - * 25-07-92 -hv- First version - * 16-08-92 -hm adding vga ioctl for cursor shape - * 25-10-92 -hv- X11 + video related ioctls - * 01/12/92 -vak- 8x16 font loading, beep ioctl, - * LED reassignment ioctl. - * 22-04-93 -hv- unified most CODRV1/CODRV2 codes - * 24-04-93 -hv- revised parts of keymap structures - * - * $Id$ - */ - -#ifndef _IOCTL_PC_H_ -#define _IOCTL_PC_H_ - -#ifdef NOTDEF -#if __GNUC__ >= 2 -#pragma pack(1) -#endif -#endif - -#ifndef KERNEL -#include <sys/ioctl.h> -#ifndef _TYPES_H_ -#include <sys/types.h> -#endif -#else -#include "ioctl.h" -#endif - - -/*************************************************************************** - * Basic definitions - ***************************************************************************/ - -/* Use this data type when manipulating characters, don't use 'char' or 'u_char' - * some day this will be changed to 'u_short' or 'u_long' size to allow - * characters > 255 - */ -typedef u_char XCHAR; - -/*************************************************************************** - * driver identification - ***************************************************************************/ - -/* - * This defines the CONSOLE INFORMATION data structure, used to - * describe console capabilities, to distinguish between different - * versions. If this ioctl fail, you probably have an old style "pccons" - * driver (or an "improved" console driver, whose writer is not interested - * in providing compatibility for anything). - * In this case, a considerable number of features may not work as expected, - * or do not work at all. - */ - -#define MAXINFOSIZE 16 -struct consinfo { - u_long info1; - u_long __reserved1__; - u_long __reserved2__; - u_long __reserved3__; - XCHAR drv_name[MAXINFOSIZE+1]; - XCHAR emul_name[MAXINFOSIZE+1]; - XCHAR __reserved1_name__[MAXINFOSIZE+1]; - XCHAR __reserved2_name__[MAXINFOSIZE+1]; -}; - -struct oldconsinfo { - u_long info1; - u_long __reserved__; -}; - -#define CONSGINFO _IOR('K',255,struct consinfo) /* Get console capabilities */ -#define OLDCONSGINFO _IOR('K',255,struct oldconsinfo) /* compatibility */ -#define CONS_ISPC 0x00000001 /* is derived from old PCCONS */ -#define CONS_ISCO 0x00000002 /* is derived from CO driver */ -#define CONS_reserved1 0x00000004 /* reserved for other console drivers */ -#define CONS_reserved2 0x00000008 /* reserved for other console drivers */ -#define CONS_HASKBD 0x00000010 /* has /dev/kbd */ -#define CONS_HASSCAN 0x00000020 /* uses Scan codes */ -#define CONS_HASKEYNUM 0x00000040 /* uses KEYNUMS */ -#define CONS_HASVTY 0x00000080 /* has /dev/vty* */ -#define CONS_HASPC3 0x00000100 /* unused, historical */ -#define CONS_HASVTHP 0x00000200 /* unused, historical */ -#define CONS_reserved3 0x00000400 /* reserved */ -#define CONS_reserved4 0x00000800 /* reserved */ -#define CONS_HASPX386 0x00001000 /* has X386 probing support +new CONSOLE_X_MODE */ -#define CONS_HASOX386 0x00002000 /* has old X386 support CONSOLE_X_MODE_ON/OFF */ -#define CONS_reserved5 0x00004000 /* reserved */ -#define CONS_reserved6 0x00008000 /* reserved */ -#define CONS_HASKCAP 0x00010000 /* has ioctl keycap support */ -#define CONS_HASFNT 0x00020000 /* has ioctl font support */ -#define CONS_reserved7 0x00040000 /* reserved */ -#define CONS_reserved8 0x00080000 /* reserved */ -#define CONS_USE7BIT 0x00100000 /* does not support 8bit characters */ -#define CONS_USEPC8 0x00200000 /* uses PC8 8-bit mapping */ -#define CONS_USELATIN1 0x00400000 /* uses ISO LATIN1 mapping */ -#define CONS_HAS10646 0x00800000 /* has /dev/unicode */ -#define CONS_PCCONS2 0x01000000 /* modified pccons */ -#define CONS_CODRV1 0x02000000 /* old codrv ioctls */ -#define CONS_CODRV2 0x04000000 /* codrv ioctls 0.1.2 */ -#define CONS_reserved9 0x08000000 /* reserved */ -#define CONS_reserved10 0x10000000 /* reserved */ -#define CONS_reserved11 0x20000000 /* reserved */ -#define CONS_reserved12 0x40000000 /* reserved */ -#define CONS_reserved13 0x80000000 /* reserved */ - - -/*************************************************************************** - * IOCTLs for AT Keyboard - ***************************************************************************/ - -/**** initializing the keyboard ****/ - -/* reset keyboard, run selftests and set default values: - * default keymap, no overloaded keys, default typematic rate - * KBD_TPD500|KBD_TPM100, repetition on - */ -#define KBDCOLDRESET _IO('K', 1) /* reset keyboard and set default - * values: - * default keymap, no overloaded - * keys, default typematic rate - * KBD_TPD500|KBD_TPM100 - */ -/* resets the mode in keyboard controller only */ -#define KBDWARMRESET _IO('K', 23) - - - -/**** key repetition (typematic) feature ****/ - -/* get (G) / set (S) key repetition rate and delay - * see below for a definition of rate and delay and the necessary - * argument - */ -#define KBDGTPMAT _IOR('K', 2, int) -#define KBDSTPMAT _IOW('K', 3, int) - -/* Typematic rates: - * Rate = 1 / Period, with - * Period = (8+ (Val&7)) * 2^((Val>>3)&3) * 0.00417 seconds, - * and Val the typematic value below - * - * The typematic delay is determined by - * Delay = (1+((Val>>5)&3)) * 250 msec +/- 20 % - * - * Source IBM/AT reference manual, 1987 - * - * Note that you have to pass one TPD* and one TPM* value to the KBDSTPMAT - * ioctl: they are different flags of the same data word. Also note that - * 0x00 is a valid value: KBD_TPD250|KBD_TPM300 which is really fast, instead - * of turning off key repetition entirely. You can turn off key repetition - * with the ioctls KBDGREPSW/KBDSREPSW. -*/ - -#define KBD_TPD250 0x0000 /* 250 ms */ -#define KBD_TPD500 0x0020 /* 500 ms */ -#define KBD_TPD750 0x0040 /* 750 ms */ -#define KBD_TPD1000 0x0060 /* 1000 ms */ - -#define KBD_TPM300 0x0000 /* 30.0 rate */ -#define KBD_TPM267 0x0001 /* 26.7 rate */ -#define KBD_TPM240 0x0002 /* 24.0 rate */ -#define KBD_TPM218 0x0003 /* 21.8 rate */ -#define KBD_TPM200 0x0004 /* 20.0 rate */ -#define KBD_TPM185 0x0005 /* 18.5 rate */ -#define KBD_TPM171 0x0006 /* 17.1 rate */ -#define KBD_TPM160 0x0007 /* 16.0 rate */ -#define KBD_TPM150 0x0008 /* 15.0 rate */ -#define KBD_TPM133 0x0009 /* 13.3 rate */ -#define KBD_TPM120 0x000a /* 12.0 rate */ -#define KBD_TPM109 0x000b /* 10.9 rate */ -#define KBD_TPM100 0x000c /* 10.0 rate */ -#define KBD_TPM92 0x000d /* 9.2 rate */ -#define KBD_TPM86 0x000e /* 8.6 rate */ -#define KBD_TPM80 0x000f /* 8.0 rate */ -#define KBD_TPM75 0x0010 /* 7.5 rate */ -#define KBD_TPM67 0x0011 /* 6.7 rate */ -#define KBD_TPM60 0x0012 /* 6.0 rate */ -#define KBD_TPM55 0x0013 /* 5.5 rate */ -#define KBD_TPM50 0x0014 /* 5.0 rate */ -#define KBD_TPM46 0x0015 /* 4.6 rate */ -#define KBD_TPM43 0x0016 /* 4.3 rate */ -#define KBD_TPM40 0x0017 /* 4.0 rate */ -#define KBD_TPM37 0x0018 /* 3.7 rate */ -#define KBD_TPM33 0x0019 /* 3.3 rate */ -#define KBD_TPM30 0x001a /* 3.0 rate */ -#define KBD_TPM27 0x001b /* 2.7 rate */ -#define KBD_TPM25 0x001c /* 2.5 rate */ -#define KBD_TPM23 0x001d /* 2.3 rate */ -#define KBD_TPM21 0x001e /* 2.1 rate */ -#define KBD_TPM20 0x001f /* 2.0 rate */ - - -/* get (G) / set (S) the key repetition switch */ -#define KBD_REPEATOFF 0 -#define KBD_REPEATON 1 -#define KBDGREPSW _IOR('K', 4, int) -#define KBDSREPSW _IOW('K', 5, int) - - - -/**** handling keyboard LEDS and Lock keys ****/ - -/* get (G) / set (S) the keyboard LEDs, - * does not influence the state of the lock keys. - * Note: if keyboard serves tty console mode (VTYs have keyboard focus), - * the lock keys will still modify the state when used - */ -#define KBDGLEDS _IOR('K', 6, int) -#define KBDSLEDS _IOW('K', 7, int) - -/* get (G) / set (S) the SCROLL, NUM, CAPS ALTGRLOCK keys - * (note: ALTGRLOCK or SHIFTLOCK are not necessarily accessible - * on your keyboard) - */ -#define KBD_LOCKSCROLL 0x0001 -#define KBD_LOCKNUM 0x0002 -#define KBD_LOCKCAPS 0x0004 -#define KBD_LOCKALTGR 0x0008 -#define KBD_LOCKSHIFT 0x0010 -#define KBDGLOCK _IOR('K', 8, int) -#define KBDSLOCK _IOW('K', 9, int) - - - -/**** making noise ****/ - -/* get (G) / set (S) the beeper frequency and tone duration - * the nr param determines the VTY which parameters are changed - * VTY# = 0...n, n < max_vtys - * nr = -1: actual vty - * nr = -2: Set the system default beep frequency - * - * in some emulations, you can also set pitch and duration by an ESC code - */ -#define KBD_ACTVTY -1 -#define KBD_DEFLT -2 -struct kbd_bell { - int pitch; - int duration; - int nr; -}; - -#define KBDGETBEEP _IOWR('K',28, struct kbd_bell) -#define KBDSETBEEP _IOW('K',29, struct kbd_bell) - -/* do a beep of specified frequency and duration - * the argument nr is unused - * a NULL arg performs a default system beep - */ -#define KBDBELL _IOW('K',30, struct kbd_bell) - - - -/**** I/O access ****/ - -/* This call allows programs to access I/O ports. - * The ioctl is intended to perform several tasks for the XFree86 Xserver, - * but currently has other interesting applications. This is why it is - * priviledged and can only be executed by root (or with setuid-root). - * In future the ioctl might be restricted to allow access to video ports - * only. - */ -#define X_MODE_ON 1 -#define X_MODE_OFF 0 -#define CONSOLE_X_MODE _IOW('K',22,int) - - -/**** keyboard overloading ****/ - -/* Codrv allows loading of strings to keys in six layers. - * Any string may have a length of up to KBDMAXOVLKEYSIZE XCHARS. - * !!! Warning: This ioctl uses the type XCHAR. In future, this may - * !!! no longer be a char type, so str*** functions might not work any more - * !!! some day. - * The available layers are: - * - * - unshifted - * - with shift key - * - with ctrl key - * - with meta key (usually ALT-left) - * - with altgr key (usually ALT-right) - * - with shift+altgr key - * - * There are no combinations: shift-ctrl, ctrl-alt, shift-meta. - * The combination ctrl-altleft-somekey is reserved for system purposes. - * These keys are usually processed before the above keys. To gain control - * over these keys, you must run the keyboard in raw mode (/dev/kbd) and - * do ALL the processing yourself. The Xserver for instance does it this way. - * The following special keys are currently defined: - * - * CTRL-ALTLEFT-DELETE: Reboot - * CTRL-ALTLEFT-ESCAPE: Call the debugger (if compiled into the kernel) - * CTRL-ALTLEFT-KP+: Switch to next resolution (Xserver only) - * CTRL-ALTLEFT-KP-: Switch to previous resolution (Xserver only) - */ - -/* values for type field of various kbd_overload ioctls */ -#define KBD_NONE 0 /* no function, key is disabled */ -#define KBD_SHIFT 1 /* keyboard shift */ -#define KBD_META 2 /* (ALT) alternate shift, sets bit8 to ASCII code */ -#define KBD_NUM 3 /* numeric shift cursors vs. numeric */ -#define KBD_CTL 4 /* control shift -- allows ctl function */ -#define KBD_CAPS 5 /* caps shift -- swaps case of letter */ -#define KBD_ASCII 6 /* ascii code for this key */ -#define KBD_SCROLL 7 /* stop output */ -#define KBD_FUNC 8 /* function key */ -#define KBD_KP 9 /* Keypad keys */ -#define KBD_BREAK 10 /* The damned BREAK key, ignored in ioctl */ -#define KBD_ALTGR 11 /* AltGr Translation feature */ -#define KBD_SHFTLOCK 12 /* some people are accustomed to this nonsense */ -#define KBD_ALTGRLOCK 13 /* Useful for 8-bit national kbds (cyrillic) */ -#define KBD_DOALTCAPS 0x0400 /* change by altgr + caps shift */ -#define KBD_DOCAPS 0x0800 /* change by caps shift */ -#define KBD_DIACPFX 0x4000 /* Key carries a diacritical prefix */ -#define KBD_OVERLOAD 0x8000 /* Key is overloaded, ignored in ioctl */ -#define KBD_MASK 0x001f /* mask for type */ - -#define KBDMAXOVLKEYSIZE 15 /* excl. zero byte */ -struct kbd_ovlkey { - u_short keynum; - u_short type; - XCHAR unshift[KBDMAXOVLKEYSIZE+1]; - XCHAR shift[KBDMAXOVLKEYSIZE+1]; - XCHAR ctrl[KBDMAXOVLKEYSIZE+1]; - XCHAR meta[KBDMAXOVLKEYSIZE+1]; - XCHAR altgr[KBDMAXOVLKEYSIZE+1]; - XCHAR shiftaltgr[KBDMAXOVLKEYSIZE+1]; -}; - - -/* Get (G) / Set (S) a key assignment. This will influence the current - * key value only - */ -#define KBDGCKEY _IOWR('K',16, struct kbd_ovlkey) -#define KBDSCKEY _IOW('K',17, struct kbd_ovlkey) - -/* Get (G) the default (old) key assignment. You cannot overwrite the - * default setting, so this ioctl is unpaired - */ -#define KBDGOKEY _IOWR('K',18, struct kbd_ovlkey) - - - -/* Remove a key assignment for a key, i.e. restore default setting for key - * arg = keynum - */ -#define KBDRMKEY _IOW('K', 19, int) - -/* Restore the default key setting */ -#define KBDDEFAULT _IO('K',20) - - - -/* Set behavior of unassigned key layers - * Note that there is a hack from further versions which uses - * the flags KBD_C0 and KBD_A0 for this. This is still supported, but - * is not recommended way to do. It may disappear in future - * (what means that it won't :-)) - */ -#define KBD_CLEARCTRL 2 -#define KBD_CLEARMETA 4 -#define KBD_CLEARALT 1 -#ifdef notyet - #define KBD_CLEARNORM 8 - #define KBD_CLEARSHIFT 16 - #define KBD_CLEARSHALT 32 -#endif -#define KBDSCLRLYR _IOW('K',31,int) - -/* get (G) / set (S) CAPSLOCK LED behaviour. - * Not all of this keys may be accessible at your keyboard - * Note: For compatibility, the S ioctl returns the old state in arg - */ -#define KBD_CAPSCAPS 0 /* LED follows CAPSLOCK state */ -#define KBD_CAPSSHIFT 1 /* LED follows SHIFTLOCK state */ -#define KBD_CAPSALTGR 2 /* LED follows ALTGRLOCK state */ -#define KBD_CAPSINIT 0x04 /* bit to set to set a default for all VTYs */ -#define KBDGCAPSLED _IOR('K',27,int) -#define KBDSCAPSLED _IOWR('K',25,int) - -/* extended functions: functions that are triggered by a keypress - * before key is converted to ASCII - * - * use function KBD_HOTKEYDELETE to remove a hotkey from a key - */ -struct kbd_hotkey { - u_short key; - u_short modifier; - u_short function; -}; -#define KBDGSPECF _IOWR('K',32,struct kbd_hotkey) -#define KBDSSPECF _IOW('K',33,struct kbd_hotkey) - -/* extended function prefixes (in modifier field) - * bit set triggers a special function on the key layer - */ -#define KBD_NOEXT 0x00 /* trigger never */ -#define KBD_EXT_N 0x01 /* on normal key (normal layer) */ -#define KBD_EXT_S 0x02 /* on shift key (shift layer) */ -#define KBD_EXT_C 0x04 /* on ctrl key (ctrl layer) */ -#define KBD_EXT_A 0x08 /* on alt key (alt layer) */ -#define KBD_EXT_SK 0x10 /* on syskey (PRINTSCREEN) (Meta Layer) */ -#define KBD_EXT_CA 0x20 /* on ctrl-alt (shift alt layer) */ - -/* extended functions (in function field) */ -#define KBD_VTY0 0 /* select vty 0 */ -#define KBD_VTY1 1 /* select vty 1 */ -#define KBD_VTY2 2 /* select vty 2 */ -#define KBD_VTY3 3 /* select vty 3 */ -#define KBD_VTY4 4 /* select vty 4 */ -#define KBD_VTY5 5 /* select vty 5 */ -#define KBD_VTY6 6 /* select vty 6 */ -#define KBD_VTY7 7 /* select vty 7 */ -#define KBD_VTY8 8 /* select vty 8 */ -#define KBD_VTY9 9 /* select vty 9 */ -#define KBD_VTY10 10 /* select vty 10 */ -#define KBD_VTY11 11 /* select vty 11 */ -#define KBD_VTYUP 0x80 /* select next vty */ -#define KBD_VTYDOWN 0x81 /* select previous vty */ -#define KBD_RESETKEY 0x82 /* the CTRL-ALT-DEL key (movable) */ -#define KBD_DEBUGKEY 0x83 /* the CTRL-ALT-ESC key (debugger) */ - -#define KBD_HOTKEYDELETE 0xff /* use to delete a hotkey KBDSSPECF */ - - - -/* These are names used in older versions of keycap/codrv */ -/* do not use the following functions any longer in future */ -#ifdef COMPAT_CO011 -#define KBDRESET KBDCOLDRESET -#define KBDRESET8042 KBDWARMRESET -#define KBDFORCEASCII _IOW('K', 24, int) /* no op in codrv-0.1.2 */ -#define KBD_SCROLLLOCK KBD_LOCKSCROLL -#define KBD_NUMLOCK KBD_LOCKNUM -#define KBD_CAPSLOCK KBD_LOCKCAPS -#define KBDASGNLEDS KBDSCAPSLED -#ifndef KERNEL -struct kbd_sound { - int pitch; /* Frequency in Hz */ - int duration; /* Time in msec */ -}; -#endif -#define KBDSETBELL _IOW('K',21, struct kbd_sound) /* do some music */ -#define OLDKBDSETBEEP _IOW('K',26, struct kbd_sound) /* change beep settings */ - -struct oldkbd_ovlkey { - u_short keynum; - u_short type; - char unshift[KBDMAXOVLKEYSIZE+1]; - char shift[KBDMAXOVLKEYSIZE+1]; - char ctrl[KBDMAXOVLKEYSIZE+1]; - char altgr[KBDMAXOVLKEYSIZE+1]; -}; -#define OLDKBDGCKEY _IOWR('K',16, struct oldkbd_ovlkey) /* get current key values */ - - - -#endif /*COMPAT_CO011*/ - -/*************************************************************************** - * IOCTLs for Video Adapter - ***************************************************************************/ - -/* to define the cursor shape for ioctl */ -struct cursorshape { - int start; /* topmost scanline, range 0...31 */ - int end; /* bottom scanline, range 0...31 */ -}; - -#define VGAGCURSOR _IOR('V',100, struct cursorshape) /* get cursor shape */ -#define VGASCURSOR _IOW('V',101, struct cursorshape) /* set cursor shape */ - - - -/**** information ****/ - -/* the video information structure for ioctl */ -struct videoinfo { - char name[20]; /* ASCIZ name of detected card */ - short type; /* Adapter type, see below */ - short subtype; /* Adapter specific subtype */ - short ram; /* in KBytes */ - short iobase; /* Address of 6845: 0x3b0 / 0x3d0 */ -}; - -/* Get information about the videoboard */ -#define VGAGINFO _IOR('V',102, struct videoinfo) - -/* recognized Adapter types */ -#define VG_UNKNOWN 0 -#define VG_MONO 1 -#define VG_CGA 2 -#define VG_EGA 3 -#define VG_VGA 4 -#define VG_CHIPS 5 -/* CHIPS & TECHNOLOGIES has subtypes: - * 0x10 82c451 - * 0x11 82c452 - * 0x20 82c455 - * 0x30 82c453 - * 0x50 82c455 - */ -#define VG_GENOA 6 -/* GENOA has subtypes: - * 0x33/0x55 5100-5400, ET3000 based - * 0x22 6100 - * 0x00 6200,6300 - * 0x11 6400,6600 - */ -#define VG_PARADISE 7 -/* PARADISE has subtypes: - * 01 PVGA1A,WD90C90 - * 02 WD90C00 - * 03 WD90C10 - * 04 WD90C11 - */ -#define VG_TVGA 8 -/* TVGA has subtypes: - * 00-02 8800 - * 03 8900B - * 04 8900C - * 13 8900C - * 23 9000 - */ -#define VG_ET3000 9 -#define VG_ET4000 10 -#define VG_VIDEO7 11 -/* VIDEO7 has subtypes: - * 0x80-0xfe VEGA VGA - * 0x70-0x7e V7VGA FASTWRITE/VRAM - * 0x50-0x59 V7VGA version 5 - * 0x41-0x49 1024i - */ -#define VG_ATI 12 -/* ATI has subtypes: - * 0x01nn 18800 - * 0x02nn 18800-1 - * 0x03nn 28800-2 - * 0x04nn-05nn - * with nn: - * 0x01 VGA WONDER - * 0x02 EGA WONDER800+ - * 0x03 VGA BASIC 16+ - */ - - - -/**** Screen blanking ****/ - -/* Get (G) / Set (S) screen blanker timeout (seconds), - * time=0 disables blanking - * - * The blanking state is coded in bits 31 and 30 of word returned by get - */ -#define VGA_BLANKOFF 0x00000000 /* display is on, no blanking */ -#define VGA_BLANKON 0x40000000 /* display is on, wait for blank */ -#define VGA_BLANKED 0x80000000 /* display is dark */ -#define VGAGBLANK _IOR('V',2,int) -#define VGASBLANK _IOW('V',3,int) - - - -/**** Text/Attribute direct access, block move ****/ - -struct vga_block { - short mode; - short pagenum; - short x0,y0; /* upper left coordinates 0..x-1, 0..y-1 */ - short x1,y1; /* lower right coordinates >= x0,y0 */ - u_char *map; /* must be allocated by user process ! */ -}; - -/* mode word */ -#define VGA_SCREEN 0x01 /* entire screen, ignore x,y */ -#define VGA_WINDOW 0x02 /* use x,y for a rectangular window */ -#define VGA_TEXT 0x10 /* copy text information only */ -#define VGA_ATTR 0x20 /* copy attribute information only */ -#define VGA_BOTH 0x30 /* copy text and attribute */ -#define VGA_ALL 0x31 /* copy complete screen */ - -/* Get (G) / Set (S) a rectangular block of screen - * The virtual screen need not be visible. - * The buffer must be provided by the user process and must be large enough - * use VGAGVRES to find out how many bytes - * pagenum: 0..n, n < max_vty, VTY number - * -1, actual VTY - */ -#define VGAGBLOCK _IOWR('V',4,struct vga_block) -#define VGASBLOCK _IOW('V',5,struct vga_block) - - - -#define VGA_TXTPAGE0 0 -#define VGA_TXTPAGE1 1 -#ifdef notyet -#define VGA_GFXPAGE 2 -#endif -#define VGA_PC8CODING 0x80 /* obsolete ! */ - -/* maximum dimension of pixels - * Note: this is the space reserved in the fontchar map, but - * does not mean, that this resolution is accepted in the current release - * codrv-0.1.2 accepts 8x16 / "9x16" fonts only - */ -#define VGA_MAXX 16 -#define VGA_MAXY 16 - -struct fchar { - XCHAR encoding; /* encoding of character */ - char _f1_,_f2_,_f3_; /* filler */ - u_char map[VGA_MAXX/8*VGA_MAXY]; -}; - -struct fmap { - short page; /* page to load */ - short nr; /* nr of characters to load */ - char x,y; /* x,y pixel width */ - XCHAR start; /* first character in sequence (get only) */ - struct fchar *fntmap; /* allocated by user process */ -}; - -/* get (G) / set (S) font map. Must provide page,nr,start for get */ -#define VGAGFONTMAP _IOWR('V',6,struct fmap) -#define VGASFONTMAP _IOW('V',7,struct fmap) - - - -/* do not use the following functions any longer in future */ -#ifdef COMPAT_CO011 -/* miscellaneous functions: */ -#define VGA_DIS1 1 /* disable font 1 */ -#define VGA_GTENC 2 /* get current encoding */ -#define VGA_SBLANK 3 /* set screen blanking timeout (use VGASBLANK!) */ -#define VGA_GBLANK 4 /* get screen blanking timeout (use VGAGBLANK!) */ - -struct miscfcns { - u_char cmd; - union { - short enc[2]; - int timeout; - } u; -}; -#define VGAMISCFCNS _IOWR('V',107,struct miscfcns) /* misc functions */ - - -/* Font mapping this needs at least an EGA card (else EINVAL) */ -#define VGAFNTLATIN1 0x00 -#define VGAFNTEXTEND1 0x01 -#define VGAFNTEXTEND2 0x02 -#define VGAFNTGREEK 0x03 -#define VGAFNTCYRILLIC 0x04 -#define VGAFNTHEBREW 0x05 -#define VGAFNTARABIAN 0x06 - -#define VGA_FNTNCHARS 256 -#define VGA_FNTCSIZE 15 - -struct fontchar { - u_char page; /* which font page */ - u_char idx; /* which char in font page */ - u_char cmap[VGA_FNTCSIZE]; /* character bitmap */ -}; - -#define OLDVGAGCHAR _IOWR('V',105,struct fontchar) /* get character of font */ -#define OLDVGASCHAR _IOW('V',106,struct fontchar) /* set character in font */ - -struct fontmap { - u_char page; /* page to load */ - u_short encoding; /* font encoding */ - u_char map[VGA_FNTNCHARS*VGA_FNTCSIZE]; -}; - -#define OLDVGAGFNTMAP _IOWR('V',103,struct fontmap) /* get font */ -#define VGAGFNTMAP OLDVGAGFNTMAP -#define OLDVGASFNTMAP _IOW('V',104,struct fontmap) /* set font */ -#define VGASFNTMAP OLDVGASFNTMAP - -#endif - - - - -struct textpage { - u_char pagenum; /* note: only page 0 used by vtys */ -#define VGA_TEXTATTR 0 -#define VGA_TEXTDATA 1 - u_char ad; -#define VGA_LINES 50 /* only 25 used for now */ -#define VGA_COLUMNS 80 - u_char map[VGA_LINES*VGA_COLUMNS]; -}; - -#define VGAGPAGE _IOWR('V',108,struct textpage) /* get a data page */ -#define VGASPAGE _IOW('V',109,struct textpage) /* set a data page */ - -/**** Signalling access ****/ - -/* Use "take control" in an application program to signal the kernel - * that the program wants to use video memory (such as Xserver) - * before the program switches modes - * - * Use "give control" to return the control to the kernel. The application - * should have restored the original state before giving back control. - * Close /dev/vga also returns control. - * - * However, the kernel remains the master in the house, and reserves the right - * to grab control back at any time. (It usually doesn't). - * - */ -#define VGATAKECTRL _IO('V',8) -#define VGAGIVECTRL _IO('V',9) - -/*************************************************************************** - * Pandora's box, don't even think of using the following ioctl's - * (if you happen to find some; codrv_experimental might not be - * available at your system) - ***************************************************************************/ - -#ifdef PANDORA -#include "codrv_experimental.h" -#endif - - - -/*************************************************************************** - * XFree86 pccons support - ***************************************************************************/ - -#ifdef COMPAT_PCCONS -/* The following calls are special to the old pccons driver and are - * not understood or supported by codrv. - * This file serves as a central definition base for these calls - * in order to avoid defining them in applications that want to - * use them. - * - * One word of warning: There are different purpose tty ioctls - * with the same encoding, see <sys/ioctl.h> - * TIOCSDTR = _IO('t', 121) - * TIOCCBRK = _IO('t', 122) - * - */ -#define CONSOLE_X_MODE_ON _IO('t',121) -#define CONSOLE_X_MODE_OFF _IO('t',122) -#define CONSOLE_X_BELL _IOW('t',123,int[2]) -#endif /* COMPAT_PCCONS */ - -#endif /* _IOCTL_PC_H_ */ - diff --git a/sys/i386/include/pio.h b/sys/i386/include/pio.h deleted file mode 100644 index ef9aba3..0000000 --- a/sys/i386/include/pio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1990 Carnegie-Mellon University - * All rights reserved. The CMU software License Agreement specifies - * the terms and conditions for use and redistribution. - * - * from: Mach, unknown, 386BSD patch kit - * $Id: pio.h,v 1.2 1993/10/16 14:39:23 rgrimes Exp $ - */ - -#ifndef _MACHINE_PIO_H_ -#define _MACHINE_PIO_H_ 1 - -#define inl(y) \ -({ unsigned long _tmp__; \ - asm volatile("inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ - _tmp__; }) - -#define inw(y) \ -({ unsigned short _tmp__; \ - asm volatile(".byte 0x66; inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ - _tmp__; }) - -/* - * only do this if it has not already be defined.. this is a crock for the - * patch kit for right now. Need to clean up all the inx, outx stuff for - * 0.1.5 to use 1 common header file, that has Bruces fast mode inb/outb - * stuff in it. Rgrimes 5/27/93 - */ -#ifndef inb -#define inb(y) \ -({ unsigned char _tmp__; \ - asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ - _tmp__; }) -#endif - - -#define outl(x, y) \ -{ asm volatile("outl %0, %1" : : "a" (y) , "d" ((unsigned short)(x))); } - - -#define outw(x, y) \ -{asm volatile(".byte 0x66; outl %0, %1" : : "a" ((unsigned short)(y)) , "d" ((unsigned short)(x))); } - - -#define outb(x, y) \ -{ asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); } -#endif /* _MACHINE_PIO_H_ */ diff --git a/sys/i386/isa/aha1742.c b/sys/i386/isa/aha1742.c deleted file mode 100644 index 6b65be5..0000000 --- a/sys/i386/isa/aha1742.c +++ /dev/null @@ -1,1273 +0,0 @@ -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * commenced: Sun Sep 27 18:14:01 PDT 1992 - * - * $Id: aha1742.c,v 1.38 1995/10/28 15:38:42 phk Exp $ - */ - -#include <sys/types.h> - -#ifdef KERNEL /* don't laugh, it compiles as a program too.. look */ -#include "ahb.h" -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/proc.h> -#include <sys/user.h> -#include <machine/clock.h> -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#else -#define NAHB 1 -#endif /*KERNEL */ -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> -#include <sys/devconf.h> - -/* */ - -#ifdef KERNEL -# ifdef DDB -#define fatal_if_no_DDB() -# else -#define fatal_if_no_DDB() panic("panic for historical reasons") -# endif -#endif - -typedef unsigned long int physaddr; -#include <sys/kernel.h> - -#define KVTOPHYS(x) vtophys(x) - -#define AHB_ECB_MAX 32 /* store up to 32ECBs at any one time */ - /* in aha1742 H/W ( Not MAX ? ) */ -#define ECB_HASH_SIZE 32 /* when we have a physical addr. for */ - /* a ecb and need to find the ecb in */ - /* space, look it up in the hash table */ -#define ECB_HASH_SHIFT 9 /* only hash on multiples of 512 */ -#define ECB_HASH(x) ((((long int)(x))>>ECB_HASH_SHIFT) % ECB_HASH_SIZE) - -#define AHB_NSEG 33 /* number of dma segments supported */ - -/* - * AHA1740 standard EISA Host ID regs (Offset from slot base) - */ -#define HID0 0xC80 /* 0,1: msb of ID2, 3-7: ID1 */ -#define HID1 0xC81 /* 0-4: ID3, 4-7: LSB ID2 */ -#define HID2 0xC82 /* product, 0=174[20] 1 = 1744 */ -#define HID3 0xC83 /* firmware revision */ - -#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@') -#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@') -#define CHAR3(B1,B2) ((B2 & 0x1F) | '@') - -/* AHA1740 EISA board control registers (Offset from slot base) */ -#define EBCTRL 0xC84 -#define CDEN 0x01 -/* - * AHA1740 EISA board mode registers (Offset from slot base) - */ -#define PORTADDR 0xCC0 -#define PORTADDR_ENHANCED 0x80 -#define BIOSADDR 0xCC1 -#define INTDEF 0xCC2 -#define SCSIDEF 0xCC3 -#define BUSDEF 0xCC4 -#define RESV0 0xCC5 -#define RESV1 0xCC6 -#define RESV2 0xCC7 -/**** bit definitions for INTDEF ****/ -#define INT9 0x00 -#define INT10 0x01 -#define INT11 0x02 -#define INT12 0x03 -#define INT14 0x05 -#define INT15 0x06 -#define INTHIGH 0x08 /* int high=ACTIVE (else edge) */ -#define INTEN 0x10 -/**** bit definitions for SCSIDEF ****/ -#define HSCSIID 0x0F /* our SCSI ID */ -#define RSTPWR 0x10 /* reset scsi bus on power up or reset */ -/**** bit definitions for BUSDEF ****/ -#define B0uS 0x00 /* give up bus immediatly */ -#define B4uS 0x01 /* delay 4uSec. */ -#define B8uS 0x02 -/* - * AHA1740 ENHANCED mode mailbox control regs (Offset from slot base) - */ -#define MBOXOUT0 0xCD0 -#define MBOXOUT1 0xCD1 -#define MBOXOUT2 0xCD2 -#define MBOXOUT3 0xCD3 - -#define ATTN 0xCD4 -#define G2CNTRL 0xCD5 -#define G2INTST 0xCD6 -#define G2STAT 0xCD7 - -#define MBOXIN0 0xCD8 -#define MBOXIN1 0xCD9 -#define MBOXIN2 0xCDA -#define MBOXIN3 0xCDB - -#define G2STAT2 0xCDC - -/* - * Bit definitions for the 5 control/status registers - */ -#define ATTN_TARGET 0x0F -#define ATTN_OPCODE 0xF0 -#define OP_IMMED 0x10 -#define AHB_TARG_RESET 0x80 -#define OP_START_ECB 0x40 -#define OP_ABORT_ECB 0x50 - -#define G2CNTRL_SET_HOST_READY 0x20 -#define G2CNTRL_CLEAR_EISA_INT 0x40 -#define G2CNTRL_HARD_RESET 0x80 - -#define G2INTST_TARGET 0x0F -#define G2INTST_INT_STAT 0xF0 -#define AHB_ECB_OK 0x10 -#define AHB_ECB_RECOVERED 0x50 -#define AHB_HW_ERR 0x70 -#define AHB_IMMED_OK 0xA0 -#define AHB_ECB_ERR 0xC0 -#define AHB_ASN 0xD0 /* for target mode */ -#define AHB_IMMED_ERR 0xE0 - -#define G2STAT_BUSY 0x01 -#define G2STAT_INT_PEND 0x02 -#define G2STAT_MBOX_EMPTY 0x04 - -#define G2STAT2_HOST_READY 0x01 - -struct ahb_dma_seg { - physaddr addr; - long len; -}; - -struct ahb_ecb_status { - u_short status; -#define ST_DON 0x0001 -#define ST_DU 0x0002 -#define ST_QF 0x0008 -#define ST_SC 0x0010 -#define ST_DO 0x0020 -#define ST_CH 0x0040 -#define ST_INT 0x0080 -#define ST_ASA 0x0100 -#define ST_SNS 0x0200 -#define ST_INI 0x0800 -#define ST_ME 0x1000 -#define ST_ECA 0x4000 - u_char ha_status; -#define HS_OK 0x00 -#define HS_CMD_ABORTED_HOST 0x04 -#define HS_CMD_ABORTED_ADAPTER 0x05 -#define HS_TIMED_OUT 0x11 -#define HS_HARDWARE_ERR 0x20 -#define HS_SCSI_RESET_ADAPTER 0x22 -#define HS_SCSI_RESET_INCOMING 0x23 - u_char targ_status; -#define TS_OK 0x00 -#define TS_CHECK_CONDITION 0x02 -#define TS_BUSY 0x08 - u_long resid_count; - u_long resid_addr; - u_short addit_status; - u_char sense_len; - u_char unused[9]; - u_char cdb[6]; -}; - - -struct ecb { - u_char opcode; -#define ECB_SCSI_OP 0x01 - u_char:4; - u_char options:3; - u_char:1; - short opt1; -#define ECB_CNE 0x0001 -#define ECB_DI 0x0080 -#define ECB_SES 0x0400 -#define ECB_S_G 0x1000 -#define ECB_DSB 0x4000 -#define ECB_ARS 0x8000 - short opt2; -#define ECB_LUN 0x0007 -#define ECB_TAG 0x0008 -#define ECB_TT 0x0030 -#define ECB_ND 0x0040 -#define ECB_DAT 0x0100 -#define ECB_DIR 0x0200 -#define ECB_ST 0x0400 -#define ECB_CHK 0x0800 -#define ECB_REC 0x4000 -#define ECB_NRB 0x8000 - u_short unused1; - physaddr data; - u_long datalen; - physaddr status; - physaddr chain; - short unused2; - short unused3; - physaddr sense; - u_char senselen; - u_char cdblen; - short cksum; - u_char cdb[12]; - /*-----------------end of hardware supported fields----------------*/ - struct ecb *next; /* in free list */ - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; -#define ECB_FREE 0 -#define ECB_ACTIVE 1 -#define ECB_ABORTED 2 -#define ECB_IMMED 4 -#define ECB_IMMED_FAIL 8 - struct ahb_dma_seg ahb_dma[AHB_NSEG]; - struct ahb_ecb_status ecb_status; - struct scsi_sense_data ecb_sense; - struct ecb *nexthash; - physaddr hashkey; /* physaddr of this struct */ -}; - -struct ahb_data { - int flags; -#define AHB_INIT 0x01; - int baseport; - struct ecb *ecbhash[ECB_HASH_SIZE]; - struct ecb *free_ecb; - int our_id; /* our scsi id */ - int vect; - struct ecb *immed_ecb; /* an outstanding immediete command */ - struct scsi_link sc_link; - int numecbs; -} *ahbdata[NAHB]; - -static int ahbprobe(); -static int ahbprobe1 __P((struct isa_device *dev)); -static int ahb_attach(); -static int ahb_init __P((int unit)); -static int32 ahb_scsi_cmd(); -static timeout_t ahb_timeout; -static void ahb_done(); -static struct ecb *cheat; -static void ahb_free_ecb(); -static void ahbminphys(); -static struct ecb *ahb_ecb_phys_kv(); -static u_int32 ahb_adapter_info(); - -#define EISA_MAX_SLOTS 16 /* XXX This should go into a comon header */ -static int ahb_slot = 0; /* slot last board was found in */ -static int ahb_unit = 0; -static int ahb_debug = 0; -#define AHB_SHOWECBS 0x01 -#define AHB_SHOWINTS 0x02 -#define AHB_SHOWCMDS 0x04 -#define AHB_SHOWMISC 0x08 -#define FAIL 1 -#define SUCCESS 0 -#define PAGESIZ 4096 - -#ifdef KERNEL -struct isa_driver ahbdriver = -{ - ahbprobe, - ahb_attach, - "ahb" -}; - -static struct scsi_adapter ahb_switch = -{ - ahb_scsi_cmd, - ahbminphys, - 0, - 0, - ahb_adapter_info, - "ahb", - { 0, 0 } -}; - -/* the below structure is so we have a default dev struct for our link struct */ -static struct scsi_device ahb_dev = -{ - NULL, /* Use default error handler */ - NULL, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ - "ahb", - 0, - { 0, 0 } -}; - -static struct kern_devconf kdc_ahb[NAHB] = { { - 0, 0, 0, /* filled in by dev_attach */ - "ahb", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_UNCONFIGURED, /* always start out here in probe */ - "Adaptec 174x-series SCSI host adapter", - DC_CLS_MISC /* host adapters aren't special */ -} }; - -static inline void -ahb_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_ahb[id->id_unit] = kdc_ahb[0]; - kdc_ahb[id->id_unit].kdc_unit = id->id_unit; - kdc_ahb[id->id_unit].kdc_parentdata = id; - dev_attach(&kdc_ahb[id->id_unit]); -} - -#endif /*KERNEL */ - -#ifndef KERNEL -main() -{ - printf("ahb_data size is %d\n", sizeof(struct ahb_data)); - printf("ecb size is %d\n", sizeof(struct ecb)); -} - -#else /*KERNEL */ - -/* - * Function to send a command out through a mailbox - */ -static void -ahb_send_mbox(int unit, int opcode, int target, struct ecb *ecb) -{ - int port = ahbdata[unit]->baseport; - int wait = 300; /* 3ms should be enough */ - int stport = port + G2STAT; - int s = splbio(); - - while (--wait) { - if ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY)) - == (G2STAT_MBOX_EMPTY)) - break; - DELAY(10); - } - if (wait == 0) { - printf("ahb%d: board not responding\n", unit); - Debugger("aha1742"); - fatal_if_no_DDB(); - } - outl(port + MBOXOUT0, KVTOPHYS(ecb)); /* don't know this will work */ - outb(port + ATTN, opcode | target); - - splx(s); -} - -/* - * Function to poll for command completion when in poll mode - */ -static int -ahb_poll(int unit, int wait) -{ /* in msec */ - struct ahb_data *ahb = ahbdata[unit]; - int port = ahb->baseport; - int stport = port + G2STAT; - - retry: - while (--wait) { - if (inb(stport) & G2STAT_INT_PEND) - break; - DELAY(1000); - } if (wait == 0) { - printf("ahb%d: board not responding\n", unit); - return (EIO); - } - if (cheat != ahb_ecb_phys_kv(ahb, inl(port + MBOXIN0))) { - printf("discarding 0x%lx ", inl(port + MBOXIN0)); - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); - DELAY(50000); - goto retry; - } - /* don't know this will work */ - ahbintr(unit); - return (0); -} - -/* - * Function to send an immediate type command to the adapter - */ -static void -ahb_send_immed(int unit, int target, u_long cmd) -{ - int port = ahbdata[unit]->baseport; - int s = splbio(); - int stport = port + G2STAT; - int wait = 100; /* 1 ms enough? */ - - while (--wait) { - if ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY)) - == (G2STAT_MBOX_EMPTY)) - break; - DELAY(10); - } if (wait == 0) { - printf("ahb%d: board not responding\n", unit); - Debugger("aha1742"); - fatal_if_no_DDB(); - } - outl(port + MBOXOUT0, cmd); /* don't know this will work */ - outb(port + G2CNTRL, G2CNTRL_SET_HOST_READY); - outb(port + ATTN, OP_IMMED | target); - splx(s); -} - -/* - * Check the slots looking for a board we recognise - * If we find one, note it's address (slot) and call - * the actual probe routine to check it out. - */ -static int -ahbprobe(dev) - struct isa_device *dev; -{ - int port; - u_char byte1, byte2, byte3; - - ahb_slot++; - while (ahb_slot < EISA_MAX_SLOTS) { - port = 0x1000 * ahb_slot; - byte1 = inb(port + HID0); - byte2 = inb(port + HID1); - byte3 = inb(port + HID2); - if (byte1 == 0xff) { - ahb_slot++; - continue; - } - if ((CHAR1(byte1, byte2) == 'A') - && (CHAR2(byte1, byte2) == 'D') - && (CHAR3(byte1, byte2) == 'P') - && ((byte3 == 0) || (byte3 == 1))) { - dev->id_iobase = port; - return ahbprobe1(dev); - } - ahb_slot++; - } - return 0; -} - -/* - * Check if the device can be found at the port given - * and if so, set it up ready for further work - * as an argument, takes the isa_device structure from - * autoconf.c. - */ -static int -ahbprobe1(dev) - struct isa_device *dev; -{ - /* - * find unit and check we have that many defined - */ - int unit = ahb_unit; - struct ahb_data *ahb; - - if (unit >= NAHB) { - printf("ahb: unit number (%d) too high\n", unit); - return 0; - } - dev->id_unit = unit; - - /* - * Allocate a storage area for us - */ - if (ahbdata[unit]) { - printf("ahb%d: memory already allocated\n", unit); - return 0; - } - ahb = malloc(sizeof(struct ahb_data), M_TEMP, M_NOWAIT); - if (!ahb) { - printf("ahb%d: cannot malloc!\n", unit); - return 0; - } - bzero(ahb, sizeof(struct ahb_data)); - ahbdata[unit] = ahb; - ahb->baseport = dev->id_iobase; -#ifndef DEV_LKM - ahb_registerdev(dev); -#endif /* DEV_LKM */ - - /* - * Try initialise a unit at this location - * sets up dma and bus speed, loads ahb->vect - */ - if (ahb_init(unit) != 0) { - ahbdata[unit] = NULL; - free(ahb, M_TEMP); - return (0); - } - /* - * If it's there, put in it's interrupt vectors - */ - dev->id_irq = (1 << ahb->vect); - dev->id_drq = -1; /* use EISA dma */ - - ahb_unit++; - return IO_EISASIZE; -} - -/* - * Attach all the sub-devices we can find - */ -static int -ahb_attach(dev) - struct isa_device *dev; -{ - int unit = dev->id_unit; - struct ahb_data *ahb = ahbdata[unit]; - struct scsibus_data *scbus; - - /* - * fill in the prototype scsi_link. - */ - ahb->sc_link.adapter_unit = unit; - ahb->sc_link.adapter_targ = ahb->our_id; - ahb->sc_link.adapter = &ahb_switch; - ahb->sc_link.device = &ahb_dev; - - /* - * Prepare the scsibus_data area for the upperlevel - * scsi code. - */ - scbus = scsi_alloc_bus(); - if(!scbus) - return 0; - scbus->adapter_link = &ahb->sc_link; - - kdc_ahb[unit].kdc_state = DC_BUSY; /* host adapters are always busy */ - /* - * ask the adapter what subunits are present - */ - scsi_attachdevs(scbus); - - return 1; -} - -/* - * Return some information to the caller about - * the adapter and it's capabilities - */ -static u_int32 -ahb_adapter_info(unit) - int unit; -{ - return (2); /* 2 outstanding requests at a time per device */ -} - -/* - * Catch an interrupt from the adaptor - */ -void -ahbintr(unit) - int unit; -{ - struct ecb *ecb; - unsigned char stat; - u_char ahbstat; - int target; - long int mboxval; - struct ahb_data *ahb = ahbdata[unit]; - - int port = ahb->baseport; - -#ifdef AHBDEBUG - printf("ahbintr "); -#endif /*AHBDEBUG */ - - while (inb(port + G2STAT) & G2STAT_INT_PEND) { - /* - * First get all the information and then - * acknowlege the interrupt - */ - ahbstat = inb(port + G2INTST); - target = ahbstat & G2INTST_TARGET; - stat = ahbstat & G2INTST_INT_STAT; - mboxval = inl(port + MBOXIN0); /* don't know this will work */ - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); -#ifdef AHBDEBUG - printf("status = 0x%x ", stat); -#endif /*AHBDEBUG */ - /* - * Process the completed operation - */ - - if (stat == AHB_ECB_OK) { /* common case is fast */ - ecb = ahb_ecb_phys_kv(ahb, mboxval); - } else { - switch (stat) { - case AHB_IMMED_OK: - ecb = ahb->immed_ecb; - ahb->immed_ecb = 0; - break; - case AHB_IMMED_ERR: - ecb = ahb->immed_ecb; - ecb->flags |= ECB_IMMED_FAIL; - ahb->immed_ecb = 0; - break; - case AHB_ASN: /* for target mode */ - printf("ahb%d: " - "Unexpected ASN interrupt(0x%lx)\n", - unit, mboxval); - ecb = 0; - break; - case AHB_HW_ERR: - printf("ahb%d: " - "Hardware error interrupt(0x%lx)\n", - unit, mboxval); - ecb = 0; - break; - case AHB_ECB_RECOVERED: - ecb = ahb_ecb_phys_kv(ahb, mboxval); - break; - case AHB_ECB_ERR: - ecb = ahb_ecb_phys_kv(ahb, mboxval); - break; - default: - printf(" Unknown return from ahb%d(%x)\n", unit, ahbstat); - ecb = 0; - } - } if (ecb) { -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWCMDS) { - show_scsi_cmd(ecb->xs); - } - if ((ahb_debug & AHB_SHOWECBS) && ecb) - printf("<int ecb(%x)>", ecb); -#endif /*AHBDEBUG */ - untimeout(ahb_timeout, (caddr_t)ecb); - ahb_done(unit, ecb, ((stat == AHB_ECB_OK) ? SUCCESS : FAIL)); - } - } -} - -/* - * We have a ecb which has been processed by the - * adaptor, now we look to see how the operation - * went. - */ -static void -ahb_done(unit, ecb, state) - int unit, state; - struct ecb *ecb; -{ - struct ahb_ecb_status *stat = &ecb->ecb_status; - struct scsi_sense_data *s1, *s2; - struct scsi_xfer *xs = ecb->xs; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahb_done\n")); - /* - * Otherwise, put the results of the operation - * into the xfer and call whoever started it - */ - if (ecb->flags & ECB_IMMED) { - if (ecb->flags & ECB_IMMED_FAIL) { - xs->error = XS_DRIVER_STUFFUP; - } - goto done; - } - if ((state == SUCCESS) || (xs->flags & SCSI_ERR_OK)) { /* All went correctly OR errors expected */ - xs->resid = 0; - xs->error = 0; - } else { - - s1 = &(ecb->ecb_sense); - s2 = &(xs->sense); - - if (stat->ha_status) { - switch (stat->ha_status) { - case HS_SCSI_RESET_ADAPTER: - break; - case HS_SCSI_RESET_INCOMING: - break; - case HS_CMD_ABORTED_HOST: /* No response */ - case HS_CMD_ABORTED_ADAPTER: /* No response */ - break; - case HS_TIMED_OUT: /* No response */ -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) { - printf("timeout reported back\n"); - } -#endif /*AHBDEBUG */ - xs->error = XS_TIMEOUT; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) { - printf("unexpected ha_status: %x\n", - stat->ha_status); - } -#endif /*AHBDEBUG */ - } - } else { - switch (stat->targ_status) { - case TS_CHECK_CONDITION: - /* structure copy!!!!! */ - *s2 = *s1; - xs->error = XS_SENSE; - break; - case TS_BUSY: - xs->error = XS_BUSY; - break; - default: -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) { - printf("unexpected targ_status: %x\n", - stat->targ_status); - } -#endif /*AHBDEBUG */ - xs->error = XS_DRIVER_STUFFUP; - } - } - } -done: xs->flags |= ITSDONE; - ahb_free_ecb(unit, ecb, xs->flags); - scsi_done(xs); -} - -/* - * A ecb (and hence a mbx-out is put onto the - * free list. - */ -static void -ahb_free_ecb(unit, ecb, flags) - int unit, flags; - struct ecb *ecb; -{ - unsigned int opri = 0; - struct ahb_data *ahb = ahbdata[unit]; - - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - ecb->next = ahb->free_ecb; - ahb->free_ecb = ecb; - ecb->flags = ECB_FREE; - /* - * If there were none, wake abybody waiting for - * one to come free, starting with queued entries - */ - if (!ecb->next) { - wakeup((caddr_t)&ahb->free_ecb); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/* - * Get a free ecb - * If there are none, see if we can allocate a - * new one. If so, put it in the hash table too - * otherwise either return an error or sleep - */ -static struct ecb * -ahb_get_ecb(unit, flags) - int unit, flags; -{ - struct ahb_data *ahb = ahbdata[unit]; - unsigned opri = 0; - struct ecb *ecbp; - int hashnum; - - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - /* - * If we can and have to, sleep waiting for one to come free - * but only if we can't allocate a new one. - */ - while (!(ecbp = ahb->free_ecb)) { - if (ahb->numecbs < AHB_ECB_MAX) { - ecbp = (struct ecb *) malloc(sizeof(struct ecb), - M_TEMP, - M_NOWAIT); - if (ecbp) { - bzero(ecbp, sizeof(struct ecb)); - ahb->numecbs++; - ecbp->flags = ECB_ACTIVE; - /* - * put in the phystokv hash table - * Never gets taken out. - */ - ecbp->hashkey = KVTOPHYS(ecbp); - hashnum = ECB_HASH(ecbp->hashkey); - ecbp->nexthash = ahb->ecbhash[hashnum]; - ahb->ecbhash[hashnum] = ecbp; - } else { - printf("ahb%d: Can't malloc ECB\n", unit); - } goto gottit; - } else { - if (!(flags & SCSI_NOSLEEP)) { - tsleep((caddr_t)&ahb->free_ecb, PRIBIO, - "ahbecb", 0); - } - } - } if (ecbp) { - /* Get ECB from from free list */ - ahb->free_ecb = ecbp->next; - ecbp->flags = ECB_ACTIVE; - } -gottit: if (!(flags & SCSI_NOMASK)) - splx(opri); - - return (ecbp); -} - -/* - * given a physical address, find the ecb that - * it corresponds to: - */ -static struct ecb * -ahb_ecb_phys_kv(ahb, ecb_phys) - struct ahb_data *ahb; - physaddr ecb_phys; -{ - int hashnum = ECB_HASH(ecb_phys); - struct ecb *ecbp = ahb->ecbhash[hashnum]; - - while (ecbp) { - if (ecbp->hashkey == ecb_phys) - break; - ecbp = ecbp->nexthash; - } - return ecbp; -} - -/* - * Start the board, ready for normal operation - */ -static int -ahb_init(unit) - int unit; -{ - struct ahb_data *ahb = ahbdata[unit]; - int port = ahb->baseport; - int intdef; - int wait = 1000; /* 1 sec enough? */ - int i; - int stport = port + G2STAT; -#define NO_NO 1 -#ifdef NO_NO - /* - * reset board, If it doesn't respond, assume - * that it's not there.. good for the probe - */ - outb(port + EBCTRL, CDEN); /* enable full card */ - outb(port + PORTADDR, PORTADDR_ENHANCED); - - outb(port + G2CNTRL, G2CNTRL_HARD_RESET); - DELAY(1000); - outb(port + G2CNTRL, 0); - DELAY(10000); - while (--wait) { - if ((inb(stport) & G2STAT_BUSY) == 0) - break; - DELAY(1000); - } if (wait == 0) { -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - printf("ahb_init: No answer from aha1742 board\n"); -#endif /*AHBDEBUG */ - return (ENXIO); - } - i = inb(port + MBOXIN0) & 0xff; - if (i) { - printf("self test failed, val = 0x%x\n", i); - return (EIO); - } -#endif - while (inb(stport) & G2STAT_INT_PEND) { - printf("."); - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); - DELAY(10000); - } - outb(port + EBCTRL, CDEN); /* enable full card */ - outb(port + PORTADDR, PORTADDR_ENHANCED); - /* - * Assume we have a board at this stage - * setup dma channel from jumpers and save int - * level - */ - printf("ahb%d: reading board settings, ", unit); - - intdef = inb(port + INTDEF); - switch (intdef & 0x07) { - case INT9: - ahb->vect = 9; - break; - case INT10: - ahb->vect = 10; - break; - case INT11: - ahb->vect = 11; - break; - case INT12: - ahb->vect = 12; - break; - case INT14: - ahb->vect = 14; - break; - case INT15: - ahb->vect = 15; - break; - default: - printf("illegal int setting\n"); - return (EIO); - } - printf("int=%d\n", ahb->vect); - - outb(port + INTDEF, (intdef | INTEN)); /* make sure we can interrupt */ - - /* who are we on the scsi bus? */ - ahb->our_id = (inb(port + SCSIDEF) & HSCSIID); - - /* - * Note that we are going and return (to probe) - */ - ahb->flags |= AHB_INIT; - return (0); -} - -#ifndef min -#define min(x,y) (x < y ? x : y) -#endif /* min */ - -static void -ahbminphys(bp) - struct buf *bp; -{ - if (bp->b_bcount > ((AHB_NSEG - 1) * PAGESIZ)) { - bp->b_bcount = ((AHB_NSEG - 1) * PAGESIZ); - } -} - -/* - * start a scsi operation given the command and - * the data address. Also needs the unit, target - * and lu - */ -static int32 -ahb_scsi_cmd(xs) - struct scsi_xfer *xs; -{ - struct ecb *ecb; - struct ahb_dma_seg *sg; - int seg; /* scatter gather seg being worked on */ - int thiskv; - physaddr thisphys, nextphys; - int unit = xs->sc_link->adapter_unit; - int bytes_this_seg, bytes_this_page, datalen, flags; - struct ahb_data *ahb = ahbdata[unit]; - int s; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahb_scsi_cmd\n")); - /* - * get a ecb (mbox-out) to use. If the transfer - * is from a buf (possibly from interrupt time) - * then we can't allow it to sleep - */ - flags = xs->flags; - if (xs->bp) - flags |= (SCSI_NOSLEEP); /* just to be sure */ - if (flags & ITSDONE) { - printf("ahb%d: Already done?", unit); - xs->flags &= ~ITSDONE; - } - if (!(flags & INUSE)) { - printf("ahb%d: Not in use?", unit); - xs->flags |= INUSE; - } - if (!(ecb = ahb_get_ecb(unit, flags))) { - xs->error = XS_DRIVER_STUFFUP; - return (TRY_AGAIN_LATER); - } - cheat = ecb; - SC_DEBUG(xs->sc_link, SDEV_DB3, ("start ecb(%p)\n", ecb)); - ecb->xs = xs; - /* - * If it's a reset, we need to do an 'immediate' - * command, and store it's ecb for later - * if there is already an immediate waiting, - * then WE must wait - */ - if (flags & SCSI_RESET) { - ecb->flags |= ECB_IMMED; - if (ahb->immed_ecb) { - return (TRY_AGAIN_LATER); - } - ahb->immed_ecb = ecb; - if (!(flags & SCSI_NOMASK)) { - s = splbio(); - ahb_send_immed(unit, xs->sc_link->target, AHB_TARG_RESET); - timeout(ahb_timeout, (caddr_t)ecb, (xs->timeout * hz) / 1000); - splx(s); - return (SUCCESSFULLY_QUEUED); - } else { - ahb_send_immed(unit, xs->sc_link->target, AHB_TARG_RESET); - /* - * If we can't use interrupts, poll on completion - */ - SC_DEBUG(xs->sc_link, SDEV_DB3, ("wait\n")); - if (ahb_poll(unit, xs->timeout)) { - ahb_free_ecb(unit, ecb, flags); - xs->error = XS_TIMEOUT; - return (HAD_ERROR); - } - return (COMPLETE); - } - } - /* - * Put all the arguments for the xfer in the ecb - */ - ecb->opcode = ECB_SCSI_OP; - ecb->opt1 = ECB_SES | ECB_DSB | ECB_ARS; - if (xs->datalen) { - ecb->opt1 |= ECB_S_G; - } - ecb->opt2 = xs->sc_link->lun | ECB_NRB; - ecb->cdblen = xs->cmdlen; - ecb->sense = KVTOPHYS(&(ecb->ecb_sense)); - ecb->senselen = sizeof(ecb->ecb_sense); - ecb->status = KVTOPHYS(&(ecb->ecb_status)); - - if (xs->datalen) { /* should use S/G only if not zero length */ - ecb->data = KVTOPHYS(ecb->ahb_dma); - sg = ecb->ahb_dma; - seg = 0; -#ifdef TFS - if (flags & SCSI_DATA_UIO) { - iovp = ((struct uio *) xs->data)->uio_iov; - datalen = ((struct uio *) xs->data)->uio_iovcnt; - xs->datalen = 0; - while ((datalen) && (seg < AHB_NSEG)) { - sg->addr = (physaddr) iovp->iov_base; - xs->datalen += sg->len = iovp->iov_len; - SC_DEBUGN(xs->sc_link, SDEV_DB4, - ("(0x%x@0x%x)", iovp->iov_len - ,iovp->iov_base)); - sg++; - iovp++; - seg++; - datalen--; - } - } - else -#endif /*TFS */ - { - /* - * Set up the scatter gather block - */ - - SC_DEBUG(xs->sc_link, SDEV_DB4, - ("%ld @%p:- ", xs->datalen, xs->data)); - datalen = xs->datalen; - thiskv = (int) xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < AHB_NSEG)) { - bytes_this_seg = 0; - - /* put in the base address */ - sg->addr = thisphys; - - SC_DEBUGN(xs->sc_link, SDEV_DB4, ("0x%lx", - thisphys)); - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) { - /* - * This page is contiguous (physically) with - * the the last, just extend the length - */ - /* how far to the end of the page */ - nextphys = (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if (datalen) - thisphys = KVTOPHYS(thiskv); - } - /* - * next page isn't contiguous, finish the seg - */ - SC_DEBUGN(xs->sc_link, SDEV_DB4, - ("(0x%x)", bytes_this_seg)); - sg->len = bytes_this_seg; - sg++; - seg++; - } - } /*end of iov/kv decision */ - ecb->datalen = seg * sizeof(struct ahb_dma_seg); - SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n")); - if (datalen) { /* there's still data, must have run out of segs! */ - printf("ahb_scsi_cmd%d: more than %d DMA segs\n", - unit, AHB_NSEG); - xs->error = XS_DRIVER_STUFFUP; - ahb_free_ecb(unit, ecb, flags); - return (HAD_ERROR); - } - } else { /* No data xfer, use non S/G values */ - ecb->data = (physaddr) 0; - ecb->datalen = 0; - } ecb->chain = (physaddr) 0; - /* - * Put the scsi command in the ecb and start it - */ - bcopy(xs->cmd, ecb->cdb, xs->cmdlen); - /* - * Usually return SUCCESSFULLY QUEUED - */ - if (!(flags & SCSI_NOMASK)) { - s = splbio(); - ahb_send_mbox(unit, OP_START_ECB, xs->sc_link->target, ecb); - timeout(ahb_timeout, (caddr_t)ecb, (xs->timeout * hz) / 1000); - splx(s); - SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n")); - return (SUCCESSFULLY_QUEUED); - } - /* - * If we can't use interrupts, poll on completion - */ - ahb_send_mbox(unit, OP_START_ECB, xs->sc_link->target, ecb); - SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_wait\n")); - do { - if (ahb_poll(unit, xs->timeout)) { - if (!(xs->flags & SCSI_SILENT)) - printf("cmd fail\n"); - ahb_send_mbox(unit, OP_ABORT_ECB, xs->sc_link->target, ecb); - if (ahb_poll(unit, 2000)) { - printf("abort failed in wait\n"); - ahb_free_ecb(unit, ecb, flags); - } - xs->error = XS_DRIVER_STUFFUP; - return (HAD_ERROR); - } - } while (!(xs->flags & ITSDONE)); /* something (?) else finished */ - if (xs->error) { - return (HAD_ERROR); - } - return (COMPLETE); -} - -static void -ahb_timeout(void *arg1) -{ - struct ecb * ecb = (struct ecb *)arg1; - int unit; - struct ahb_data *ahb; - int s = splbio(); - - unit = ecb->xs->sc_link->adapter_unit; - ahb = ahbdata[unit]; - printf("ahb%d:%d:%d (%s%d) timed out ", unit - ,ecb->xs->sc_link->target - ,ecb->xs->sc_link->lun - ,ecb->xs->sc_link->device->name - ,ecb->xs->sc_link->dev_unit); - -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWECBS) - ahb_print_active_ecb(unit); -#endif /*AHBDEBUG */ - - /* - * If it's immediate, don't try abort it - */ - if (ecb->flags & ECB_IMMED) { - ecb->xs->retries = 0; /* I MEAN IT ! */ - ecb->flags |= ECB_IMMED_FAIL; - ahb_done(unit, ecb, FAIL); - splx(s); - return; - } - /* - * If it has been through before, then - * a previous abort has failed, don't - * try abort again - */ - if (ecb->flags == ECB_ABORTED) { - /* - * abort timed out - */ - printf("AGAIN"); - ecb->xs->retries = 0; /* I MEAN IT ! */ - ecb->ecb_status.ha_status = HS_CMD_ABORTED_HOST; - ahb_done(unit, ecb, FAIL); - } else { /* abort the operation that has timed out */ - printf("\n"); - ahb_send_mbox(unit, OP_ABORT_ECB, ecb->xs->sc_link->target, ecb); - /* 2 secs for the abort */ - timeout(ahb_timeout, (caddr_t)ecb, 2 * hz); - ecb->flags = ECB_ABORTED; - } - splx(s); -} - -#ifdef AHBDEBUG -static void -ahb_print_ecb(ecb) - struct ecb *ecb; -{ - printf("ecb:%x op:%x cmdlen:%d senlen:%d\n" - ,ecb - ,ecb->opcode - ,ecb->cdblen - ,ecb->senselen); - printf(" datlen:%d hstat:%x tstat:%x flags:%x\n" - ,ecb->datalen - ,ecb->ecb_status.ha_status - ,ecb->ecb_status.targ_status - ,ecb->flags); - show_scsi_cmd(ecb->xs); -} - -static void -ahb_print_active_ecb(int unit) -{ - struct ahb_data *ahb = ahbdata[unit]; - struct ecb *ecb; - int i = 0; - - while (i < ECB_HASH_SIZE) { - ecb = ahb->ecbhash[i]; - while (ecb) { - if (ecb->flags != ECB_FREE) { - ahb_print_ecb(ecb); - } - ecb = ecb->nexthash; - } i++; - } -} -#endif /*AHBDEBUG */ -#endif /*KERNEL */ diff --git a/sys/i386/isa/aha2742.c b/sys/i386/isa/aha2742.c deleted file mode 100644 index 81c46dc..0000000 --- a/sys/i386/isa/aha2742.c +++ /dev/null @@ -1,1710 +0,0 @@ -/* - * Driver for the 27/284X series adaptec SCSI controllers written by - * Justin T. Gibbs. Much of this driver was taken from Julian Elischer's - * 1742 driver, so it bears his copyright. - * - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * commenced: Sun Sep 27 18:14:01 PDT 1992 - * - * $Id: aha2742.c,v 1.3 1994/11/18 07:25:02 jkh Exp $ - */ -/* - * TODO: - * Add support for dual and wide busses - * Implement Target Mode - * Implement Tagged Queuing - * Add target reset capabilities - * Test the check SCSI sense code - * Write a message abort procedure for use in ahc_timeout - * Add support for the 294X series cards - * - * This driver is very stable, and seems to offer performance - * comprable to the 1742 FreeBSD driver. The only timeouts - * I have ever experienced were due to critical driver bugs - * where an abort wouldn't have helped me anyway. So I haven't - * written code to actually search the QINFIFO and/or kill an - * active command. Same goes for target reset. - */ - -#define AHC_SCB_MAX 16 /* - * Up to 16 SCBs on some types of aic7xxx based - * boards. The aic7770 family only have 4 - */ - -#include "ahc.h" /* for NAHC from config */ - -#include <sys/param.h> -#include <sys/systm.h> - -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/proc.h> -#include <sys/user.h> -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#include <machine/cpufunc.h> -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> - -#define AHC_NSEG 256 /* number of dma segments supported */ -#define PAGESIZ 4096 -#if 0 -#define AHCDEBUG -#endif - -/* - * I don't know if this is correct, but Justin screwed the pooch here too - * so I have to guess. ARGH! -jkh - */ -#ifndef IO_EISASIZE -#define IO_EISASIZE 0x1000 -#endif - -typedef unsigned long int physaddr; - -#include <sys/kernel.h> -#define KVTOPHYS(x) vtophys(x) - -typedef enum { - AHC_274, /* Single Channel */ - AHC_274T, /* Twin Channel */ - AHC_274W, /* Wide Channel */ - AHC_284, /* VL Single Channel */ - AHC_284T, /* VL Twin Channel */ - AHC_284W, /* VL Wide Channel - Do these exist?? */ -}ahc_type; - -int ahcprobe(); -int ahcprobe1 __P((struct isa_device *dev, ahc_type type)); -int ahc_attach(); -int ahc_init __P((int unit)); -void ahc_loadseq __P((int port)); -int ahcintr(); -int32 ahc_scsi_cmd(); -timeout_t ahc_timeout; -void ahc_done(); -struct scb *ahc_get_scb __P((int unit, int flags)); -void ahc_free_scb(); -void ahcminphys(); -struct scb *ahc_scb_phys_kv(); -u_int32 ahc_adapter_info(); - -#define MAX_SLOTS 8 /* XXX should this be 16?? Need EISA spec */ -static ahc_slot = 0; /* slot last board was found in */ -static ahc_unit = 0; - -/* Different debugging levels - only one so-far */ -#define AHC_SHOWMISC 0x0001 -int ahc_debug = AHC_SHOWMISC; -/* - * Standard EISA Host ID regs (Offset from slot base) - */ - -#define HID0 0xC80 /* 0,1: msb of ID2, 2-7: ID1 */ -#define HID1 0xC81 /* 0-4: ID3, 5-7: LSB ID2 */ -#define HID2 0xC82 /* product, 0=174[20] 1 = 1744 */ -#define HID3 0xC83 /* firmware revision */ - -/**** bit definitions for SCSIDEF ****/ -#define HSCSIID 0x07 /* our SCSI ID */ - -typedef struct -{ - ahc_type type; - unsigned char id; /* The Last EISA Host ID reg */ -} ahc_sig; - -#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@') -#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@') -#define CHAR3(B1,B2) ((B2 & 0x1F) | '@') - -struct isa_driver ahcdriver = {ahcprobe, ahc_attach, "ahc"}; - -struct scsi_adapter ahc_switch = -{ - ahc_scsi_cmd, - ahcminphys, - 0, - 0, - ahc_adapter_info, - "ahc", - { 0, 0 } -}; - -/* the below structure is so we have a default dev struct for our link struct */ -struct scsi_device ahc_dev = -{ - NULL, /* Use default error handler */ - NULL, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ - "ahc", - 0, - { 0, 0 } -}; - -/* - * All of these should be in a separate header file shared by the sequencer - * code and the kernel level driver. The only catch is that we would need to - * add an additional 0xc00 offset when using them in the kernel driver. The - * aic7770 assembler must be modified to allow include files as well. All - * page numbers refer to the Adaptec AIC-7770 Data Book availible from - * Adaptec's Technical Documents Department 1-800-634-2766 - */ - -/* -------------------- AIC-7770 offset definitions ----------------------- */ - -/* - * SCSI Sequence Control (p. 3-11). - * Each bit, when set starts a specific SCSI sequence on the bus - */ -#define SCSISEQ 0xc00 -#define TEMODEO 0x80 -#define ENSELO 0x40 -#define ENSELI 0x20 -#define ENRSELI 0x10 -#define ENAUTOATNO 0x08 -#define ENAUTOATNI 0x04 -#define ENAUTOATNP 0x02 -#define SCSIRSTO 0x01 - -/* - * SCSI Control Signal Read Register (p. 3-15). - * Reads the actual state of the SCSI bus pins - */ -#define SCSISIGI 0xc03 -#define CDI 0x80 -#define IOI 0x40 -#define MSGI 0x20 -#define ATNI 0x10 -#define SELI 0x08 -#define BSYI 0x04 -#define REQI 0x02 -#define ACKI 0x01 - -/* - * SCSI Contol Signal Write Register (p. 3-16). - * Writing to this register modifies the control signals on the bus. Only - * those signals that are allowed in the current mode (Initiator/Target) are - * asserted. - */ -#define SCSISIGO 0xc03 -#define CDO 0x80 -#define IOO 0x40 -#define MSGO 0x20 -#define ATNO 0x10 -#define SELO 0x08 -#define BSYO 0x04 -#define REQO 0x02 -#define ACKO 0x01 - -/* - * SCSI ID (p. 3-18). - * Contains the ID of the board and the current target on the - * selected channel - */ -#define SCSIID 0xc05 -#define TID 0xf0 /* Target ID mask */ -#define OID 0x0f /* Our ID mask */ - -/* - * SCSI Status 0 (p. 3-21) - * Contains one set of SCSI Interrupt codes - * These are most likely of interest to the sequencer - */ -#define SSTAT0 0xc0b -#define TARGET 0x80 /* Board is a target */ -#define SELDO 0x40 /* Selection Done */ -#define SELDI 0x20 /* Board has been selected */ -#define SELINGO 0x10 /* Selection In Progress */ -#define SWRAP 0x08 /* 24bit counter wrap */ -#define SDONE 0x04 /* STCNT = 0x000000 */ -#define SPIORDY 0x02 /* SCSI PIO Ready */ -#define DMADONE 0x01 /* DMA transfer completed */ - -/* - * Clear SCSI Interrupt 1 (p. 3-23) - * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1. - */ -#define CLRSINT1 0xc0c -#define CLRSELTIMEO 0x80 -#define CLRATNO 0x40 -#define CLRSCSIRSTI 0x20 -/* UNUSED 0x10 */ -#define CLRBUSFREE 0x08 -#define CLRSCSIPERR 0x04 -#define CLRPHASECHG 0x02 -#define CLRREQINIT 0x01 - -/* - * SCSI Status 1 (p. 3-24) - * These interrupt bits are of interest to the kernel driver - */ -#define SSTAT1 0xc0c -#define SELTO 0x80 -#define ATNTARG 0x40 -#define SCSIRSTI 0x20 -#define PHASEMIS 0x10 -#define BUSFREE 0x08 -#define SCSIPERR 0x04 -#define PHASECHG 0x02 -#define REQINIT 0x01 - -/* - * Selection/Reselection ID (p. 3-31) - * Upper four bits are the device id. The ONEBIT is set when the re/selecting - * device did not set its own ID. - */ -#define SELID 0xc19 -#define SELID_MASK 0xf0 -#define ONEBIT 0x08 -/* UNUSED 0x07 */ - -/* - * SCSI Block Control (p. 3-32) - * Controls Bus type and channel selection. In a twin channel configuration - * addresses 0x00-0x1e are gated to the appropriate channel based on this - * register. SELWIDE allows for the coexistence of 8bit and 16bit devices - * on a wide bus. - */ -#define SBLKCTL 0xc1f -/* UNUSED 0xc0 */ -#define AUTOFLUSHDIS 0x20 -/* UNUSED 0x10 */ -#define SELBUSB 0x08 -/* UNUSED 0x04 */ -#define SELWIDE 0x02 -/* UNUSED 0x01 */ - -/* - * Sequencer Control (p. 3-33) - * Error detection mode and speed configuration - */ -#define SEQCTL 0xc60 -#define PERRORDIS 0x80 -#define PAUSEDIS 0x40 -#define FAILDIS 0x20 -#define FASTMODE 0x10 -#define BRKADRINTEN 0x08 -#define STEP 0x04 -#define SEQRESET 0x02 -#define LOADRAM 0x01 - -/* - * Sequencer RAM Data (p. 3-34) - * Single byte window into the Scratch Ram area starting at the address - * specified by SEQADDR0 and SEQADDR1. To write a full word, simply write - * four bytes in sucessesion. The SEQADDRs will increment after the most - * significant byte is written - */ -#define SEQRAM 0xc61 - -/* - * Sequencer Address Registers (p. 3-35) - * Only the first bit of SEQADDR1 holds addressing information - */ -#define SEQADDR0 0xc62 -#define SEQADDR1 0xc63 -#define SEQADDR1_MASK 0x01 - -/* - * Accumulator - * We cheat by passing arguments in the Accumulator up to the kernel driver - */ -#define ACCUM 0xc64 - -/* - * Board Control (p. 3-43) - */ -#define BCTL 0xc84 -/* RSVD 0xf0 */ -#define ACE 0x08 /* Support for external processors */ -/* RSVD 0x06 */ -#define ENABLE 0x01 - -/* - * Host Control (p. 3-47) R/W - * Overal host control of the device. - */ -#define HCNTRL 0xc87 -/* UNUSED 0x80 */ -#define POWRDN 0x40 -/* UNUSED 0x20 */ -#define SWINT 0x10 -#define IRQMS 0x08 -#define PAUSE 0x04 -#define INTEN 0x02 -#define CHIPRST 0x01 -#define REQ_PAUSE IRQMS | PAUSE | INTEN -#define UNPAUSE_274X IRQMS | INTEN -#define UNPAUSE_284X INTEN - -/* - * SCB Pointer (p. 3-49) - * Gate one of the four SCBs into the SCBARRAY window. - */ -#define SCBPTR 0xc90 - -/* - * Interrupt Status (p. 3-50) - * Status for system interrupts - */ -#define INTSTAT 0xc91 -#define SEQINT_MASK 0xf0 /* SEQINT Status Codes */ -#define BAD_PHASE 0x00 -#define MSG_REJECT 0x10 -#define NO_IDENT 0x20 -#define NO_MATCH 0x30 -#define TRANS_RATE 0x40 -#define BAD_STATUS 0x50 -#define BRKADRINT 0x08 -#define SCSIINT 0x04 -#define CMDCMPLT 0x02 -#define SEQINT 0x01 -#define INT_PEND SEQINT | SCSIINT | CMDCMPLT /* For polling */ - -/* - * Hard Error (p. 3-53) - * Reporting of catastrophic errors. You usually cannot recover from - * these without a full board reset. - */ -#define ERROR 0xc92 -/* UNUSED 0xf0 */ -#define PARERR 0x08 -#define ILLOPCODE 0x04 -#define ILLSADDR 0x02 -#define ILLHADDR 0x01 - -/* - * Clear Interrupt Status (p. 3-52) - */ -#define CLRINT 0xc92 -#define CLRBRKADRINT 0x08 -#define CLRINTSTAT 0x04 /* UNDOCUMENTED - must be unpaused */ -#define CLRCMDINT 0x02 -#define CLRSEQINT 0x01 - -/* - * SCB Auto Increment (p. 3-59) - * Byte offset into the SCB Array and an optional bit to allow auto - * incrementing of the address during download and upload operations - */ -#define SCBCNT 0xc9a -#define SCBAUTO 0x80 -#define SCBCNT_MASK 0x1f - -/* - * Queue In FIFO (p. 3-60) - * Input queue for queued SCBs (commands that the seqencer has yet to start) - */ -#define QINFIFO 0xc9b - -/* - * Queue In Count (p. 3-60) - * Number of queued SCBs - */ -#define QINCNT 0xc9c - -/* - * Queue Out FIFO (p. 3-61) - * Queue of SCBs that have completed and await the host - */ -#define QOUTFIFO 0xc9d - -/* - * Queue Out Count (p. 3-61) - * Number of queued SCBs in the Out FIFO - */ -#define QOUTCNT 0xc9e - -#define SCBARRAY 0xca0 - -/* ---------------- END AIC-7770 Register Definitions ----------------- */ - -/* ---------------------- Scratch RAM Offsets ------------------------- */ -/* These offsets are either to values that are initialized by the board's - * BIOS or are specified by the Linux sequencer code. If I can figure out - * how to read the EISA configuration info at probe time, the cards could - * be run without BIOS support installed - */ - -/* - * The sequencer will stick the frist byte of any rejected message here so - * we can see what is getting thrown away. - */ -#define HA_REJBYTE 0xc31 - -/* - * Pending message flag - */ -#define HA_MSG_FLAGS 0xc35 - -/* - * Length of pending message - */ -#define HA_MSG_LEN 0xc36 - -/* - * message body - */ -#define HA_MSG_START 0xc37 /* outgoing message body */ - -/* - * These are offsets into the card's scratch ram. Some of the values are - * specified in the AHA2742 technical reference manual and are initialized - * by the BIOS at boot time. - */ -#define HA_ARG_1 0xc4c -#define HA_ARG_2 0xc4d -#define HA_RETURN_1 0xc4c - -#define HA_SIGSTATE 0xc4e -#define HA_NEEDSDTR 0xc4f - -#define HA_SCSICONF 0xc5a -#define INTDEF 0xc5c -#define HA_HOSTCONF 0xc5d -#define HA_SCBCOUNT 0xc56 -#define ACTIVE_A 0xc57 -#define MSG_ABORT 0x06 - -/* - * Since the sequencer can disable pausing in a critical section, we - * must loop until it actually stops. - * XXX Should add a timeout in here!! - */ -#define PAUSE_SEQUENCER(ahc) \ - outb(HCNTRL + ahc->baseport, REQ_PAUSE); \ - \ - while ((inb(HCNTRL + ahc->baseport) & PAUSE) == 0) \ - ; - -#define UNPAUSE_SEQUENCER(ahc) \ - outb( HCNTRL + ahc->baseport, ahc->unpause ) - -/* - * Restart the sequencer program from address zero - */ -#define RESTART_SEQUENCER(ahc) \ - do { \ - outb( SEQCTL + ahc->baseport, SEQRESET ); \ - } while (inw(SEQADDR0 + ahc->baseport) != 0); \ - \ - UNPAUSE_SEQUENCER(ahc); - - -struct ahc_dma_seg { - physaddr addr; - long len; -}; - -/* - * The driver keeps up to four scb structures per card in memory. Only the - * first 26 bytes of the structure are valid for the hardware, the rest used - * for driver level bookeeping. The "__attribute ((packed))" tags ensure that - * gcc does not attempt to pad the long ints in the structure to word - * boundaries since the first 26 bytes of this structure must have the correct - * offsets for the hardware to find them. The driver should be further - * optimized so that we only have to download the first 14 bytes since as long - * as we always use S/G, the last fields should be zero anyway. Its mostly a - * matter of looking through the sequencer code and ensuring that those fields - * are cleared or loaded with a valid value before being read. - */ -struct scb { -/* ------------ Begin hardware supported fields ---------------- */ -/*1*/ u_char control; -#define SCB_REJ_MDP 0x80 /* Reject MDP message */ -#define SCB_DCE 0x40 /* Disconnect enable */ -#define SCB_TE 0x20 /* Tag enable */ -#define SCB_WAITING 0x06 -#define SCB_DIS 0x04 -#define SCB_TAG_TYPE 0x3 -#define SIMPLE_QUEUE 0x0 -#define HEAD_QUEUE 0x1 -#define OR_QUEUE 0x2 -/*2*/ u_char target_channel_lun; /* 4/1/3 bits */ -/*3*/ u_char SG_segment_count; -/*7*/ physaddr SG_list_pointer __attribute__ ((packed)); -/*11*/ physaddr cmdpointer __attribute__ ((packed)); -/*12*/ u_char cmdlen; -/*14*/ u_char RESERVED[2]; /* must be zero */ -/*15*/ u_char target_status; -/*18*/ u_char residual_data_count[3]; -/*19*/ u_char residual_SG_segment_count; -/*23*/ physaddr data __attribute__ ((packed)); -/*26*/ u_char datalen[3]; -#define SCB_SIZE 26 /* amount to actually download */ -#if 0 - /* - * No real point in transferring this to the - * SCB registers. - */ - unsigned char RESERVED[6]; -#endif - /*-----------------end of hardware supported fields----------------*/ - struct scb *next; /* in free list */ - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; - int position; /* Position in scbarray */ -#define SCB_FREE 0 -#define SCB_ACTIVE 1 -#define SCB_ABORTED 2 -#define SCB_IMMED 4 -#define SCB_IMMED_FAIL 8 -#define SCB_SENSE 16 - struct ahc_dma_seg ahc_dma[AHC_NSEG] __attribute__ ((packed)); - struct scsi_sense sense_cmd; /* SCSI command block */ -}; - -struct ahc_data { - ahc_type type; - int flags; -#define AHC_INIT 0x01; - int baseport; - struct scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */ - struct scb *free_scb; - int our_id; /* our scsi id */ - int vect; - struct scb *immed_ecb; /* an outstanding immediete command */ - struct scsi_link sc_link; - int numscbs; - u_char maxscbs; - int unpause; -} *ahcdata[NAHC]; - - -#ifdef AHCDEBUG -void -ahc_print_scb(scb) - struct scb *scb; -{ - printf("scb:%x control:%x tcl:%x cmdlen:%d cmdpointer:%x\n" - ,scb - ,scb->control - ,scb->target_channel_lun - ,scb->cmdlen - ,scb->cmdpointer ); - printf(" datlen:%d data:%x res:%x segs:%x segp:%x\n" - ,scb->datalen[2] << 16 | scb->datalen[1] << 8 | scb->datalen[0] - ,scb->data - ,scb->RESERVED[1] << 8 | scb->RESERVED[0] - ,scb->SG_segment_count - ,scb->SG_list_pointer); - printf(" sg_addr:%x sg_len:%d\n" - ,scb->ahc_dma[0].addr - ,scb->ahc_dma[0].len); - printf(" size:%d\n" - ,(int)&(scb->next) - (int)scb); -} - -void -ahc_print_active_scb(ahc) - struct ahc_data *ahc; -{ - int cur_scb_offset; - int port = ahc->baseport; - PAUSE_SEQUENCER(ahc); - cur_scb_offset = inb(SCBPTR + port); - UNPAUSE_SEQUENCER(ahc); - ahc_print_scb(ahc->scbarray[cur_scb_offset]); -} - -#define PARERR 0x08 -#define ILLOPCODE 0x04 -#define ILLSADDR 0x02 -#define ILLHADDR 0x01 - -#endif - -static struct { - u_char errno; - char *errmesg; -} hard_error[] = { - ILLHADDR, "Illegal Host Access", - ILLSADDR, "Illegal Sequencer Address referrenced", - ILLOPCODE, "Illegal Opcode in sequencer program", - PARERR, "Sequencer Ram Parity Error", -}; - - -/* - * Valid SCSIRATE values. (p. 3-17) - * Provides a mapping of tranfer periods in ns to the proper value to - * stick in the scsiscfr reg to use that transfer rate. - */ -static struct { - short sxfr; - short period; /* in ns */ - char *rate; -} ahc_syncrates[] = { - 0x00, 100, "10.0", - 0x10, 125, "8.0", - 0x20, 150, "6.67", - 0x30, 175, "5.7", - 0x40, 200, "5.0", - 0x50, 225, "4.4", - 0x60, 250, "4.0", - 0x70, 275, "3.6" -}; - -static int ahc_num_syncrates = - sizeof(ahc_syncrates) / sizeof(ahc_syncrates[0]); - -int -ahcprobe(struct isa_device *dev) -{ - int port; - int i; - u_char sig_id[4]; - - ahc_sig valid_ids[] = { - /* Entries of other tested adaptors should be added here */ - AHC_274, 0x71, /*274x, Card*/ - AHC_274, 0x70, /*274x, Motherboard*/ - AHC_284, 0x56, /*284x, BIOS enabled*/ - AHC_284, 0x57, /*284x, BIOS disabled*/ - }; - - - ahc_slot++; - while (ahc_slot <= MAX_SLOTS) { - port = 0x1000 * ahc_slot; - for( i = 0; i < sizeof(sig_id); i++ ) - { - /* - * An outb is required to prime these registers on - * VL cards - */ - outb( port + HID0, HID0 + i ); - sig_id[i] = inb(port + HID0 + i); - } - if (sig_id[0] == 0xff) { - ahc_slot++; - continue; - } - /* Check manufacturer's ID. */ - if ((CHAR1(sig_id[0], sig_id[1]) == 'A') - && (CHAR2(sig_id[0], sig_id[1]) == 'D') - && (CHAR3(sig_id[0], sig_id[1]) == 'P') - && (sig_id[2] == 0x77)) { - for( i = 0; i < sizeof(valid_ids)/sizeof(ahc_sig); i++) - if ( sig_id[3] == valid_ids[i].id ) { - dev->id_iobase = port; - return ahcprobe1(dev, valid_ids[i].type); - } - } - ahc_slot++; - } - return 0; -} - -/* - * Check if the device can be found at the port given - * and if so, determine configuration and set it up for further work. - * As an argument, takes the isa_device structure from - * autoconf.c. - */ - -int -ahcprobe1(dev, type) - struct isa_device *dev; - ahc_type type; -{ - - /* - * find unit and check we have that many defined - */ - - int unit = dev->id_unit; - struct ahc_data *ahc; - - if (unit >= NAHC) { - printf("ahc: unit number (%d) too high\n", unit); - return 0; - } - - /* - * Allocate a storage area for us - */ - - if (ahcdata[unit]) { - printf("ahc%d: memory already allocated\n", unit); - return 0; - } - ahc = malloc(sizeof(struct ahc_data), M_TEMP, M_NOWAIT); - if (!ahc) { - printf("ahc%d: cannot malloc!\n", unit); - return 0; - } - bzero(ahc, sizeof(struct ahc_data)); - ahcdata[unit] = ahc; - ahc->baseport = dev->id_iobase; - ahc->type = type; - - /* - * Try to initialize a unit at this location - * reset the AIC-7770, read its registers, - * and fill in the dev structure accordingly - */ - - if (ahc_init(unit) != 0) { - ahcdata[unit] = NULL; - free(ahc, M_TEMP); - return (0); - } - - /* - * If it's there, put in it's interrupt vectors - */ - - dev->id_irq = (1 << ahc->vect); - dev->id_drq = -1; /* use EISA dma */ - - ahc_unit++; - return IO_EISASIZE; -} - - -/* - * Look up the valid period to SCSIRATE conversion in our table. - */ -static -void ahc_scsirate(scsirate, period, offset, unit, target ) - u_char *scsirate; - u_char period, offset; - int unit, target; -{ - int i; - - for (i = 0; i < ahc_num_syncrates; i++) { - - if ((ahc_syncrates[i].period - period) >= 0) { - *scsirate = (ahc_syncrates[i].sxfr) | (offset & 0x0f); -#ifdef AHCDEBUG - printf("ahc%d: target %d synchronous at %sMb/s\n", - unit, target, ahc_syncrates[i].rate ); -#endif /* AHCDEBUG */ - return; - } - } - /* Default to asyncronous transfer */ - *scsirate = 0; -#ifdef AHCDEBUG - printf("ahc%d: target %d using asyncronous transfers\n", - unit, target ); -#endif /* AHCDEBUG */ - -} - - -/* - * Attach all the sub-devices we can find - */ -int -ahc_attach(dev) - struct isa_device *dev; -{ - int unit = dev->id_unit; - struct ahc_data *ahc = ahcdata[unit]; - - /* - * fill in the prototype scsi_link. - */ - ahc->sc_link.adapter_unit = unit; - ahc->sc_link.adapter_targ = ahc->our_id; - ahc->sc_link.adapter = &ahc_switch; - ahc->sc_link.device = &ahc_dev; - ahc->sc_link.flags = DEBUGLEVEL; - - /* - * Here, we should really fill in up to two different sc_links, - * making use of the extra fields in the sc_link structure so - * we can know which channel any requests are for. Then its just - * a matter of doing a scsi_attachdevs to both instead of the one. - * This should be done when we get or write sequencer code that - * supports more than one channel. XXX - */ - - /* - * ask the adapter what subunits are present - */ - scsi_attachdevs(&(ahc->sc_link)); - - return 1; -} - -void -ahc_send_scb( ahc, scb ) - struct ahc_data *ahc; - struct scb *scb; -{ - int old_scbptr; - int base = ahc->baseport; - - PAUSE_SEQUENCER(ahc); - - old_scbptr = inb(SCBPTR + base); - outb(SCBPTR + base, scb->position); - - outb(SCBCNT + base, SCBAUTO); - - outsb(SCBARRAY + base, scb, SCB_SIZE); - - outb(SCBCNT + base, 0); - - outb(QINFIFO + base, scb->position); - outb(SCBPTR + base, old_scbptr); - - UNPAUSE_SEQUENCER(ahc); -} - -static -void ahc_getscb(base, scb) - int base; - struct scb *scb; -{ - outb(SCBCNT + base, 0x80); /* SCBAUTO */ - - insb(SCBARRAY + base, scb, SCB_SIZE); - - outb(SCBCNT + base, 0); -} - -/* - * Catch an interrupt from the adaptor - */ -int -ahcintr(unit) - int unit; -{ - int intstat; - u_char status; - struct ahc_data *ahc = ahcdata[unit]; - int port = ahc->baseport; - struct scb *scb = NULL; - struct scsi_xfer *xs = NULL; - - intstat = inb(INTSTAT + port); - - if (intstat & BRKADRINT) { - /* We upset the sequencer :-( */ - - /* Lookup the error message */ - int i, error = inb(ERROR + port); - int num_errors = sizeof(hard_error)/sizeof(hard_error[0]); - for(i = 0; error != 1 && i < num_errors; i++) - error >>= 1; - panic("ahc%d: brkadrint, %s at seqaddr = 0x%x\n", - unit, hard_error[i].errmesg, inw(SEQADDR0 + port)); - } - if (intstat & SEQINT) { - unsigned char transfer, offset, rate; - - switch (intstat & SEQINT_MASK) { - case BAD_PHASE: - panic("ahc%d: unknown scsi bus phase. " - "Attempting to continue\n", unit); - break; - case MSG_REJECT: - printf("ahc%d: Warning - " - "message reject, message type: 0x%x\n", unit, - inb(HA_REJBYTE + port)); - break; - case NO_IDENT: - panic("ahc%d: No IDENTIFY message from reconnecting " - "target %d\n", - unit, (inb(SELID + port) >> 4) & 0xf); - break; - case NO_MATCH: - { - u_char active; - int target = (inb(SELID + port) >> 4) & 0x4; - printf("ahc%d: no active SCB for reconnecting " - "target %d - issuing ABORT\n", - unit, target); - active = inb(HA_SCBCOUNT + port); - printf("SCBCOUNT is %d\n", active); - DELAY(10000); - active = inb(ACTIVE_A + port); - active &= ~(0x01 << target); - outb(ACTIVE_A + port, active); - outb(CLRSINT1 + port, CLRSELTIMEO); - RESTART_SEQUENCER(ahc); - break; - } - case TRANS_RATE: - /* - * Help the sequencer to translate the negotiated - * transfer rate. Transfer is 1/4 the period - * in ns as is returned by the sync negotiation - * message. So, we must multiply by four - */ - transfer = inb(HA_ARG_1 + port) << 2; - /* The bottom half of SCSIXFER*/ - offset = inb(HA_ARG_2 + port); - ahc_scsirate(&rate, transfer, offset, unit, - inb(SCSIID + port) >> 0x4); - outb(HA_RETURN_1 + port, rate); - break; - case BAD_STATUS: - { - int scb_index, saved_scb_index; - - /* The sequencer will notify us when a command - * has an error that would be of interest to - * the kernel. This allows us to leave the sequencer - * running in the common case of command completes - * without error. - */ - - scb_index = inb(SCBPTR + port); - scb = ahc->scbarray[scb_index]; - if (!scb || !(scb->flags & SCB_ACTIVE)) { - printf("ahc%d: ahcintr - referenced scb not " - "valid during seqint 0x%x scb(%d)\n", - unit, intstat, scb_index); - goto clear; - } - - xs = scb->xs; - - ahc_getscb(port, scb); - -#ifdef AHCDEBUG - if(xs->sc_link->target == DEBUGTARG) - ahc_print_scb(scb); -#endif - xs->status = scb->target_status; - xs->resid = ((scb->residual_data_count[2] << 16) | - (scb->residual_data_count[1] << 8) | - scb->residual_data_count[0]); - switch(scb->target_status){ - case SCSI_OK: - printf("ahc%d: Interrupted for staus of " - "0???\n", unit); - break; - case SCSI_CHECK: -#ifdef AHCDEBUG - printf("ahc%d: SCSI Check requested\n", unit); -#endif - /*Priliminary code for requesting Sense */ - /* Enable at your own risk */ -#if STILL_NEEDS_TESTING - if((xs->error == XS_NOERROR) && - !(scb->flags & SCB_SENSE)) - { - struct ahc_dma_seg *sg = scb->ahc_dma; - struct scsi_sense *sc = &(scb->sense_cmd); - int scbsave[AHC_SCB_MAX], i; - int queued = inb(QINCNT + port); -#ifdef AHCDEBUG - printf("SENDING SENSE.\n"); -#endif - bzero(scb, SCB_SIZE); - scb->flags |= SCB_SENSE; - xs->error = XS_SENSE; - sc->op_code = REQUEST_SENSE; - sc->byte2 = xs->sc_link->lun << 5; - sc->length = sizeof(struct scsi_sense_data); - scb->cmdlen = sizeof(*sc); - scb->cmdpointer = KVTOPHYS(sc); - scb->SG_segment_count = 1; - scb->SG_list_pointer = KVTOPHYS(sg); - sg->addr = KVTOPHYS(&xs->sense); - sg->len = sizeof(struct scsi_sense_data); - /* - * Reinsert us at head of - * queue - */ - outb(SCBCNT + port, 0x80); - outsb(SCBARRAY + port, scb, SCB_SIZE); - outb(SCBCNT + port, 0); - - for (i = 0; i < queued; i++) - scbsave[i] = inb(QINFIFO + port); - - outb(QINFIFO + port, scb->position); - - for (i = 0; i < queued; i++) - outb(QINFIFO + port, scbsave[i]); - - /* New lease on life */ - untimeout(ahc_timeout, (caddr_t)scb); - timeout(ahc_timeout, (caddr_t)scb, - (xs->timeout * hz) / 1000); - - goto clear; - } -#endif - xs->error = XS_DRIVER_STUFFUP; - break; - case SCSI_BUSY: - xs->error = XS_BUSY; - printf("ahc%d: Target Busy\n", unit); - break; - default: -#ifdef AHCDEBUG - if (ahc_debug & AHC_SHOWMISC) - { - printf("unexpected targ_status: %x\n", - scb->target_status); - } -#endif /*AHCDEBUG */ - xs->error = XS_DRIVER_STUFFUP; - break; - } - untimeout(ahc_timeout, (caddr_t)scb); - ahc_done(unit, scb); - break; - } - default: - printf("ahc: seqint, " - "intstat = 0x%x, scsisigi = 0x%x\n", - intstat, inb(SCSISIGI + port)); - break; - } - - /* - * Clear the upper byte that holds SEQINT status - * codes and clear the SEQINT bit. - */ -clear: - outb(CLRINT + port, CLRSEQINT); - - /* - * The sequencer is paused immediately on - * a SEQINT, so we should restart it when - * we leave this section. - */ - UNPAUSE_SEQUENCER(ahc); - } - - - if (intstat & SCSIINT) { - - int scb_index = inb(SCBPTR + port); - status = inb(SSTAT1 + port); - - scb = ahc->scbarray[scb_index]; - if (!scb || scb->flags != SCB_ACTIVE) { - printf("ahc%d: ahcintr - referenced scb not " - "valid during scsiint 0x%x scb(%d)\n", - unit, status, scb_index); - outb(CLRSINT1 + port, status); - UNPAUSE_SEQUENCER(ahc); - outb(CLRINT + port, CLRINTSTAT); - scb = NULL; - goto cmdcomplete; - } - xs = scb->xs; - - if (status & SELTO) { - u_char active; - outb(SCSISEQ + port, 0); - xs->error = XS_TIMEOUT; - /* - * Clear any pending messages for the timed out - * target, and mark the target as free - */ - outb(HA_MSG_FLAGS + port, 0); - active = inb(ACTIVE_A + port); - active &= ~(0x01 << xs->sc_link->target); - outb(ACTIVE_A + port, active); - - outb(CLRSINT1 + port, CLRSELTIMEO); - RESTART_SEQUENCER(ahc); - - outb(CLRINT + port, CLRINTSTAT); - } - - if (status & SCSIPERR) { - printf("ahc%d: parity error on channel A " - "target %d, lun %d\n", - unit, - xs->sc_link->target, - xs->sc_link->lun); - xs->error = XS_DRIVER_STUFFUP; - - outb(CLRSINT1 + port, CLRSCSIPERR); - UNPAUSE_SEQUENCER(ahc); - - outb(CLRINT + port, CLRINTSTAT); - scb = NULL; - } - if (status & BUSFREE) { -#if 0 - /* - * Has seen busfree since selection, i.e. - * a "spurious" selection. Shouldn't happen. - */ - printf("ahc: unexpected busfree\n"); - xs->error = XS_DRIVER_STUFFUP; - outb(CLRSINT1 + port, BUSFREE); /* CLRBUSFREE */ -#endif - } - - else { - printf("ahc%d: Unknown SCSIINT. Status = 0x%x\n", - unit, status); - outb(CLRSINT1 + port, status); - UNPAUSE_SEQUENCER(ahc); - outb(CLRINT + port, CLRINTSTAT); - scb = NULL; - } - if(scb != NULL) { - /* We want to process the command */ - untimeout(ahc_timeout, (caddr_t)scb); - ahc_done(unit, scb); - } - } -cmdcomplete: - if (intstat & CMDCMPLT) { - int scb_index, saved_scb_index; - - do { - scb_index = inb(QOUTFIFO + port); - scb = ahc->scbarray[scb_index]; - if (!scb || !(scb->flags & SCB_ACTIVE)) { - printf("ahc%d: WARNING " - "no command for scb %d (cmdcmplt)\n", - unit, scb_index); - outb(CLRINT + port, CLRCMDINT); - continue; - } - - outb(CLRINT+ port, CLRCMDINT); - untimeout(ahc_timeout, (caddr_t)scb); - ahc_done(unit, scb); - - } while (inb(QOUTCNT + port)); - } - - return 1; -} - -/* - * We have a scb which has been processed by the - * adaptor, now we look to see how the operation - * went. - */ -void -ahc_done(unit, scb) - int unit; - struct scb *scb; -{ - struct scsi_xfer *xs = scb->xs; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_done\n")); - /* - * Put the results of the operation - * into the xfer and call whoever started it - */ - if ((xs->flags & SCSI_ERR_OK) && !(xs->error == XS_SENSE)) { - /* All went correctly OR errors expected */ - xs->error = 0; - } - xs->flags |= ITSDONE; - ahc_free_scb(unit, scb, xs->flags); - scsi_done(xs); -} - -/* - * Start the board, ready for normal operation - */ -int -ahc_init(unit) - int unit; -{ - struct ahc_data *ahc = ahcdata[unit]; - int port = ahc->baseport; - int intdef; - - /* - * Assume we have a board at this stage - * Find out the configured interupt and the card type. - */ - - printf("ahc%d: scb %d; SCB_SIZE %d, ahc_dma %d\n", unit, - sizeof(struct scb), SCB_SIZE, sizeof(struct ahc_dma_seg)); - printf("ahc%d: reading board settings\n", unit); - - outb(HCNTRL + port, CHIPRST); - switch( ahc->type ) { - case AHC_274: - printf("ahc%d: 274x", unit); - ahc->unpause = UNPAUSE_274X; - ahc->maxscbs = 0x4; - break; - case AHC_284: - printf("ahc%d: 284x", unit); - ahc->unpause = UNPAUSE_284X; - ahc->maxscbs = 0x4; - break; - default: - }; - - - /* Determine channel configuration. */ - switch ( inb(SBLKCTL + port) ) { - case 0: - printf(" Single Channel, "); - break; - case 2: - printf(" Wide SCSI configuration - Unsupported\n"); - ahc->type += 2; - return(-1); - break; - case 8: - printf(" Twin Channel - ignoring channel B, "); - ahc->type += 1; - break; - default: - printf(" Unsupported adapter type. Ignoring\n"); - return(-1); - } - - intdef = inb(INTDEF + port); - switch (intdef & 0xf) { - case 9: - ahc->vect = 9; - break; - case 10: - ahc->vect = 10; - break; - case 11: - ahc->vect = 11; - break; - case 12: - ahc->vect = 12; - break; - case 14: - ahc->vect = 14; - break; - case 15: - ahc->vect = 15; - break; - default: - printf("illegal irq setting\n"); - return (EIO); - } - printf("int=%d, ", ahc->vect); - - /* who are we on the scsi bus? */ - ahc->our_id = (inb(HA_SCSICONF + port) & HSCSIID); - printf("SCSI Id=%d\n", ahc->our_id); - - /* - * Load the Sequencer program and Enable the adapter - */ - - printf("ahc%d: Downloading Sequencer Program\n", unit); - ahc_loadseq(port); - outb(BCTL + port, ENABLE); - - /* Reset the SCSI bus. Is this necessary? */ - outb(SCSISEQ + port, SCSIRSTO); - DELAY(500); - outb(SCSISEQ + port, 0); - - /* - * Attempt syncronous negotiation for all targets. - * Clear the pending messages flag - */ - outb( HA_NEEDSDTR + port, 0xff ); - outb( HA_MSG_FLAGS + port, 0); - printf("SCBCOUNT == %d\n", ahc->maxscbs); - outb(HA_SCBCOUNT + port, ahc->maxscbs); - outb( ACTIVE_A + port, 0 ); - - UNPAUSE_SEQUENCER(ahc); - - /* - * Note that we are going and return (to probe) - */ - ahc->flags |= AHC_INIT; - return (0); -} - -void -ahcminphys(bp) - struct buf *bp; -{ -/* Even though the card can transfer up to 16megs per command - * we are limited by the number of segments in the dma segment - * list that we can hold. The worst case is that all pages are - * discontinuous physically, hense the "page per segment" limit - * enforced here. - */ - if (bp->b_bcount > ((AHC_NSEG - 1) * PAGESIZ)) { - bp->b_bcount = ((AHC_NSEG - 1) * PAGESIZ); - } -} - -/* - * start a scsi operation given the command and - * the data address, target, and lun all of which - * are stored in the scsi_xfer struct - */ -int32 -ahc_scsi_cmd(xs) - struct scsi_xfer *xs; -{ - struct scb *scb = NULL; - struct ahc_dma_seg *sg; - int seg; /* scatter gather seg being worked on */ - int thiskv; - physaddr thisphys, nextphys; - int unit = xs->sc_link->adapter_unit; - int bytes_this_seg, bytes_this_page, datalen, flags; - struct ahc_data *ahc = ahcdata[unit]; - int s; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_scsi_cmd\n")); - /* - * get an scb to use. If the transfer - * is from a buf (possibly from interrupt time) - * then we can't allow it to sleep - */ - flags = xs->flags; - if (xs->bp) - flags |= (SCSI_NOSLEEP); /* just to be sure */ - if (flags & ITSDONE) { - printf("ahc%d: Already done?", unit); - xs->flags &= ~ITSDONE; - } - if (!(flags & INUSE)) { - printf("ahc%d: Not in use?", unit); - xs->flags |= INUSE; - } - if (!(scb = ahc_get_scb(unit, flags))) { - xs->error = XS_DRIVER_STUFFUP; - return (TRY_AGAIN_LATER); - } - SC_DEBUG(xs->sc_link, SDEV_DB3, ("start scb(%x)\n", scb)); - scb->xs = xs; - - if (flags & SCSI_RESET) { - /* AR: Needs Implementation */ - printf("ahc0: SCSI_RESET called.\n"); - } - /* - * Put all the arguments for the xfer in the scb - */ - - /* Note, Linux sequencer code does not support extra channels */ - scb->target_channel_lun = ((xs->sc_link->target << 4) & 0xF0) | - xs->sc_link->lun & 0x7; - scb->cmdlen = xs->cmdlen; - scb->cmdpointer = KVTOPHYS(xs->cmd); - if (xs->datalen) { /* should use S/G only if not zero length */ - scb->SG_list_pointer = KVTOPHYS(scb->ahc_dma); - sg = scb->ahc_dma; - seg = 0; - { - /* - * Set up the scatter gather block - */ - SC_DEBUG(xs->sc_link, SDEV_DB4, - ("%d @0x%x:- ", xs->datalen, xs->data)); - datalen = xs->datalen; - thiskv = (int) xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < AHC_NSEG)) { - bytes_this_seg = 0; - - /* put in the base address */ - sg->addr = thisphys; - - SC_DEBUGN(xs->sc_link, SDEV_DB4, ("0x%x", thisphys)); - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) { - /* - * This page is contiguous (physically) - * with the the last, just extend the - * length - */ - /* how far to the end of the page */ - nextphys = (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if (datalen) - thisphys = KVTOPHYS(thiskv); - } - /* - * next page isn't contiguous, finish the seg - */ - SC_DEBUGN(xs->sc_link, SDEV_DB4, - ("(0x%x)", bytes_this_seg)); - sg->len = bytes_this_seg; - sg++; - seg++; - } - } /*end of iov/kv decision */ - scb->SG_segment_count = seg; - SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n")); - if (datalen) { /* there's still data, must have run out of segs! */ - printf("ahc_scsi_cmd%d: more than %d DMA segs\n", - unit, AHC_NSEG); - xs->error = XS_DRIVER_STUFFUP; - ahc_free_scb(unit, scb, flags); - return (HAD_ERROR); - } - } - /* else No data xfer, use non S/G values - * the SG_segment_count and SG_list_pointer are pre-zeroed, so - * we don't have to do anything - */ - - /* - * Usually return SUCCESSFULLY QUEUED - */ -#ifdef AHCDEBUG - if(xs->sc_link->target == DEBUGTARG) - ahc_print_scb(scb); -#endif - if (!(flags & SCSI_NOMASK)) { - s = splbio(); - ahc_send_scb(ahc, scb); - timeout(ahc_timeout, (caddr_t)scb, (xs->timeout * hz) / 1000); - splx(s); - SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n")); - return (SUCCESSFULLY_QUEUED); - } - /* - * If we can't use interrupts, poll on completion - */ - ahc_send_scb(ahc, scb); - SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_wait\n")); - do { - if (ahc_poll(unit, xs->timeout)) { - if (!(xs->flags & SCSI_SILENT)) - printf("cmd fail\n"); - printf("cmd fail\n"); - printf("Abort called. Someone implement me please!\n"); - xs->error = XS_DRIVER_STUFFUP; - return (HAD_ERROR); - } - } while (!(xs->flags & ITSDONE)); /* something (?) else finished */ - if (xs->error) { - return (HAD_ERROR); - } - return (COMPLETE); -} - - -/* - * Return some information to the caller about - * the adapter and it's capabilities. - */ -u_int32 -ahc_adapter_info(unit) - int unit; -{ - return (2); /* 2 outstanding requests at a time per device */ -} - -/* - * A scb (and hence an scb entry on the board is put onto the - * free list. - */ -void -ahc_free_scb(unit, scb, flags) - int unit, flags; - struct scb *scb; -{ - unsigned int opri = 0; - struct ahc_data *ahc = ahcdata[unit]; - - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - scb->next = ahc->free_scb; - ahc->free_scb = scb; - scb->flags = SCB_FREE; - /* - * If there were none, wake abybody waiting for - * one to come free, starting with queued entries - */ - if (!scb->next) { - wakeup((caddr_t)&ahc->free_scb); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/* - * Get a free scb - * If there are none, see if we can allocate a - * new one. Otherwise either return an error or sleep - */ -struct scb * -ahc_get_scb(unit, flags) - int unit, flags; -{ - struct ahc_data *ahc = ahcdata[unit]; - unsigned opri = 0; - struct scb *scbp; - int position; - - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - /* - * If we can and have to, sleep waiting for one to come free - * but only if we can't allocate a new one. - */ - while (!(scbp = ahc->free_scb)) { - if (ahc->numscbs < ahc->maxscbs) { - scbp = (struct scb *) malloc(sizeof(struct scb), - M_TEMP, M_NOWAIT); - if (scbp) { - bzero(scbp, sizeof(struct scb)); - scbp->position = ahc->numscbs; - ahc->numscbs++; - scbp->flags = SCB_ACTIVE; - /* - * Place in the scbarray - * Never is removed. Position - * in ahc->scbarray is the scbarray - * position on the board we will - * load it into. - */ - ahc->scbarray[scbp->position] = scbp; - } else { - printf("ahc%d: Can't malloc SCB\n", unit); - } goto gottit; - } else { - if (!(flags & SCSI_NOSLEEP)) { - tsleep((caddr_t)&ahc->free_scb, PRIBIO, - "ahcscb", 0); - } - } - } if (scbp) { - /* Get SCB from from free list */ - ahc->free_scb = scbp->next; - /* preserve the position */ - position = scbp->position; - bzero(scbp, sizeof(struct scb)); - scbp->flags = SCB_ACTIVE; - scbp->position = position; - } -gottit: if (!(flags & SCSI_NOMASK)) - splx(opri); - - return (scbp); -} - -void ahc_loadseq(port) - int port; -{ - extern unsigned char seqprog[]; - - outb(SEQCTL + port, PERRORDIS|SEQRESET|LOADRAM); - - outsb(SEQRAM + port, seqprog, sizeof(seqprog)); - - outb(SEQCTL + port, 0); - do { - /* XXX Need a timer here? */ - outb(SEQCTL + port, SEQRESET); - - } while (inw(SEQADDR0 + port) != 0); -} - -/* - * Function to poll for command completion when in poll mode - */ -int -ahc_poll(int unit, int wait) -{ /* in msec */ - struct ahc_data *ahc = ahcdata[unit]; - int port = ahc->baseport; - int stport = INTSTAT + port; - - retry: - while (--wait) { - if (inb(stport) & INT_PEND) - break; - DELAY(1000); - } if (wait == 0) { - printf("ahc%d: board not responding\n", unit); - return (EIO); - } - ahcintr(unit); - return (0); -} - -void -ahc_timeout(void *arg1) -{ - struct scb *scb = (struct scb *)arg1; - int unit, cur_scb_offset, port; - struct ahc_data *ahc; - int s = splbio(); - - unit = scb->xs->sc_link->adapter_unit; - ahc = ahcdata[unit]; - port = ahc->baseport; - printf("ahc%d: target %d, lun %d (%s%d) timed out ", unit - ,scb->xs->sc_link->target - ,scb->xs->sc_link->lun - ,scb->xs->sc_link->device->name - ,scb->xs->sc_link->dev_unit); -#if 0 -#ifdef AHCDEBUG - if (ahc_debug & AHC_SHOWMISC) - ahc_print_active_scb(unit); -#endif /*AHCDEBUG */ -#endif - - /* - * If it's immediate, don't try abort it - */ - if (scb->flags & SCB_IMMED) { - scb->xs->retries = 0; /* I MEAN IT ! */ - scb->flags |= SCB_IMMED_FAIL; - ahc_done(unit, scb); - splx(s); - return; - } - /* - * If it has been through before, then - * a previous abort has failed, don't - * try abort again - */ - if (scb->flags == SCB_ABORTED) { - /* - * abort timed out - */ - printf("AGAIN"); - scb->xs->retries = 0; /* I MEAN IT ! */ - ahc_done(unit, scb); - } else { /* abort the operation that has timed out */ - printf("Abort unsupported!!!\n"); - } - splx(s); -} - diff --git a/sys/i386/isa/aic7770.c b/sys/i386/isa/aic7770.c deleted file mode 100644 index e7963d7..0000000 --- a/sys/i386/isa/aic7770.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Product specific probe and attach routines for: - * 27/284X and aic7770 motherboard SCSI controllers - * - * Copyright (c) 1995 Justin T. Gibbs - * All rights reserved. - * - * 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 immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * Justin T. Gibbs. - * 4. Modifications may be freely made to this file if the above conditions - * are met. - * - * $Id: aic7770.c,v 1.15 1995/07/04 21:14:16 gibbs Exp $ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> -#include <sys/devconf.h> -#include <machine/cpufunc.h> -#include <i386/scsi/aic7xxx.h> - -int aic7770probe __P((struct isa_device *dev)); -int aic7770_attach __P((struct isa_device *dev)); - -/* - * Standard EISA Host ID regs (Offset from slot base) - */ - -#define HID0 0xC80 /* 0,1: msb of ID2, 2-7: ID1 */ -#define HID1 0xC81 /* 0-4: ID3, 5-7: LSB ID2 */ -#define HID2 0xC82 /* product */ -#define HID3 0xC83 /* firmware revision */ - -#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@') -#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@') -#define CHAR3(B1,B2) ((B2 & 0x1F) | '@') - -#define EISA_MAX_SLOTS 16 /* XXX should be defined in a common header */ -static ahc_slot = 0; /* slot last board was found in */ - -struct isa_driver ahcdriver = {aic7770probe, aic7770_attach, "ahc"}; - -typedef struct -{ - ahc_type type; - unsigned char id; /* The Last EISA Host ID reg */ -} aic7770_sig; - -static struct kern_devconf kdc_aic7770[NAHC] = { { - 0, 0, 0, /* filled in by dev_attach */ - "ahc", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_UNCONFIGURED, /* always start out here */ - "Adaptec aic7770 based SCSI host adapter", - DC_CLS_MISC /* host adapters aren't special */ -} }; - -static inline void -aic7770_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_aic7770[id->id_unit] = kdc_aic7770[0]; - kdc_aic7770[id->id_unit].kdc_unit = id->id_unit; - kdc_aic7770[id->id_unit].kdc_parentdata = id; - dev_attach(&kdc_aic7770[id->id_unit]); -} - -int -aic7770probe(struct isa_device *dev) -{ - u_long port; - int i; - u_char sig_id[4]; - - aic7770_sig valid_ids[] = { - /* Entries of other tested adaptors should be added here */ - { AHC_274, 0x71 }, /*274x*/ - { AHC_AIC7770, 0x70 }, /*aic7770 on Motherboard*/ - { AHC_284, 0x56 }, /*284x, BIOS enabled*/ - { AHC_284, 0x57 } /*284x, BIOS disabled*/ - }; - - - ahc_slot++; - while (ahc_slot < EISA_MAX_SLOTS) { - port = 0x1000 * ahc_slot; - for( i = 0; i < sizeof(sig_id); i++ ) - { - /* - * An outb is required to prime these registers on - * VL cards - */ - outb( port + HID0, HID0 + i ); - sig_id[i] = inb(port + HID0 + i); - } - if (sig_id[0] == 0xff) { - ahc_slot++; - continue; - } - /* Check manufacturer's ID. */ - if ((CHAR1(sig_id[0], sig_id[1]) == 'A') - && (CHAR2(sig_id[0], sig_id[1]) == 'D') - && (CHAR3(sig_id[0], sig_id[1]) == 'P') - && (sig_id[2] == 0x77)) { - for(i=0; i < sizeof(valid_ids)/sizeof(aic7770_sig);i++) - if ( sig_id[3] == valid_ids[i].id ) { - int unit = dev->id_unit; - dev->id_iobase = port; -#ifndef DEV_LKM - aic7770_registerdev(dev); -#endif /* DEV_LKM */ - if(ahcprobe(unit, port, - valid_ids[i].type, AHC_FNONE)){ - /* - * If it's there, put in it's - * interrupt vectors - */ - dev->id_irq = (1 << - ahcdata[unit]->vect); - dev->id_drq = -1; /* EISA dma */ - ahc_unit++; - return IO_EISASIZE; - } - } - } - ahc_slot++; - } - return 0; -} - -int -aic7770_attach(dev) - struct isa_device *dev; -{ - int unit = dev->id_unit; - kdc_aic7770[unit].kdc_state = DC_BUSY; /* host adapters always busy */ - return ahc_attach(unit); -} - diff --git a/sys/i386/isa/bt742a.c b/sys/i386/isa/bt742a.c deleted file mode 100644 index ebc6941..0000000 --- a/sys/i386/isa/bt742a.c +++ /dev/null @@ -1,1764 +0,0 @@ -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * $Id: bt742a.c,v 1.47 1995/12/10 13:38:22 phk Exp $ - */ - -/* - * Bulogic/Bustek 32 bit Addressing Mode SCSI driver. - * - * NOTE: 1. Some bt5xx card can NOT handle 32 bit addressing mode. - * 2. OLD bt445s Revision A,B,C,D(nowired) + any firmware version - * has broken busmaster for handling 32 bit addressing on H/W bus - * side. - * - * 3. Extended probing still needs confirmation from our user base, due - * to several H/W and firmware dependencies. If you have a problem - * with extended probing, please contact 'amurai@spec.co.jp' - * - * amurai@spec.co.jp 94/6/16 - */ - -/* - * bt742a SCSI driver - */ - -#include <sys/types.h> - -#ifdef KERNEL /* don't laugh.. it compiles to a program too.. look */ -#include "bt.h" -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/sysctl.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/proc.h> -#endif /* KERNEL */ - -#include <machine/clock.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/pmap.h> - -#include <i386/isa/isa_device.h> -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> -#include <sys/devconf.h> - -#ifdef KERNEL -#include <sys/kernel.h> -#else /*KERNEL */ -#define NBT 1 -#endif /*KERNEL */ - -typedef unsigned long int physaddr; - -/* - * I/O Port Interface - */ - -#define BT_BASE bt->bt_base -#define BT_CTRL_STAT_PORT (BT_BASE + 0x0) /* control & status */ -#define BT_CMD_DATA_PORT (BT_BASE + 0x1) /* cmds and datas */ -#define BT_INTR_PORT (BT_BASE + 0x2) /* Intr. stat */ - -/* - * BT_CTRL_STAT bits (write) - */ - -#define BT_HRST 0x80 /* Hardware reset */ -#define BT_SRST 0x40 /* Software reset */ -#define BT_IRST 0x20 /* Interrupt reset */ -#define BT_SCRST 0x10 /* SCSI bus reset */ - -/* - * BT_CTRL_STAT bits (read) - */ - -#define BT_STST 0x80 /* Self test in Progress */ -#define BT_DIAGF 0x40 /* Diagnostic Failure */ -#define BT_INIT 0x20 /* Mbx Init required */ -#define BT_IDLE 0x10 /* Host Adapter Idle */ -#define BT_CDF 0x08 /* cmd/data out port full */ -#define BT_DF 0x04 /* Data in port full */ -#define BT_INVDCMD 0x01 /* Invalid command */ - -/* - * BT_CMD_DATA bits (write) - */ - -#define BT_NOP 0x00 /* No operation */ -#define BT_MBX_INIT 0x01 /* Mbx initialization */ -#define BT_START_SCSI 0x02 /* start scsi command */ -#define BT_START_BIOS 0x03 /* start bios command */ -#define BT_INQUIRE 0x04 /* Adapter Inquiry */ -#define BT_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */ -#define BT_SEL_TIMEOUT_SET 0x06 /* set selection time-out */ -#define BT_BUS_ON_TIME_SET 0x07 /* set bus-on time */ -#define BT_BUS_OFF_TIME_SET 0x08 /* set bus-off time */ -#define BT_SPEED_SET 0x09 /* set transfer speed */ -#define BT_DEV_GET 0x0a /* return installed devices */ -#define BT_CONF_GET 0x0b /* return configuration data */ -#define BT_TARGET_EN 0x0c /* enable target mode */ -#define BT_SETUP_GET 0x0d /* return setup data */ -#define BT_WRITE_CH2 0x1a /* write channel 2 buffer */ -#define BT_READ_CH2 0x1b /* read channel 2 buffer */ -#define BT_WRITE_FIFO 0x1c /* write fifo buffer */ -#define BT_READ_FIFO 0x1d /* read fifo buffer */ -#define BT_ECHO 0x1e /* Echo command data */ -#define BT_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */ -#define BT_INQUIRE_EXTENDED 0x8D /* Adapter Setup Inquiry */ - -/* The following command appeared at FirmWare 3.31 */ -#define BT_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */ -#define BT_STRICT_ROUND_ROBIN 0x00 /* Parameter value for strict mode */ -#define BT_AGRES_ROUND_ROBIN 0x01 /* Parameter value for backword comp */ - -struct bt_cmd_buf { - u_char byte[16]; -}; - -/* - * BT_INTR_PORT bits (read) - */ - -#define BT_ANY_INTR 0x80 /* Any interrupt */ -#define BT_SCRD 0x08 /* SCSI reset detected */ -#define BT_HACC 0x04 /* Command complete */ -#define BT_MBOA 0x02 /* MBX out empty */ -#define BT_MBIF 0x01 /* MBX in full */ - -/* - * Mail box defs etc. - * these could be bigger but we need the bt_data to fit on a single page.. - */ - -#define BT_MBX_SIZE 32 /* mail box size (MAX 255 MBxs) */ - /* don't need that many really */ -#define BT_CCB_MAX 32 /* store up to 32CCBs at any one time */ - /* in bt742a H/W ( Not MAX ? ) */ -#define CCB_HASH_SIZE 32 /* when we have a physical addr. for */ - /* a ccb and need to find the ccb in */ - /* space, look it up in the hash table */ -#define CCB_HASH_SHIFT 9 /* only hash on multiples of 512 */ -#define CCB_HASH(x) ((((long int)(x))>>CCB_HASH_SHIFT) % CCB_HASH_SIZE) - -#define bt_nextmbx( wmb, mbx, mbio ) \ - if ( (wmb) == &((mbx)->mbio[BT_MBX_SIZE - 1 ]) ) \ - (wmb) = &((mbx)->mbio[0]); \ - else \ - (wmb)++; - -typedef struct bt_mbx_out { - physaddr ccb_addr; - unsigned char dummy[3]; - unsigned char cmd; -} BT_MBO; - -typedef struct bt_mbx_in { - physaddr ccb_addr; - unsigned char btstat; - unsigned char sdstat; - unsigned char dummy; - unsigned char stat; -} BT_MBI; - -struct bt_mbx { - BT_MBO mbo[BT_MBX_SIZE]; - BT_MBI mbi[BT_MBX_SIZE]; - BT_MBO *tmbo; /* Target Mail Box out */ - BT_MBI *tmbi; /* Target Mail Box in */ -}; - -/* - * mbo.cmd values - */ - -#define BT_MBO_FREE 0x0 /* MBO entry is free */ -#define BT_MBO_START 0x1 /* MBO activate entry */ -#define BT_MBO_ABORT 0x2 /* MBO abort entry */ - -/* - * mbi.stat values - */ - -#define BT_MBI_FREE 0x0 /* MBI entry is free */ -#define BT_MBI_OK 0x1 /* completed without error */ -#define BT_MBI_ABORT 0x2 /* aborted ccb */ -#define BT_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */ -#define BT_MBI_ERROR 0x4 /* Completed with error */ - -#if defined(BIG_DMA) -WARNING...THIS WON'T WORK(won't fit on 1 page) -/* #define BT_NSEG 2048*/ /* Number of scatter gather segments - to much vm */ -#define BT_NSEG 128 -#else -#define BT_NSEG 33 -#endif /* BIG_DMA */ - -struct bt_scat_gath { - unsigned long seg_len; - physaddr seg_addr; -}; - -struct bt_ccb { - unsigned char opcode; - unsigned char:3, data_in:1, data_out:1,:3; - unsigned char scsi_cmd_length; - unsigned char req_sense_length; - /*------------------------------------longword boundary */ - unsigned long data_length; - /*------------------------------------longword boundary */ - physaddr data_addr; - /*------------------------------------longword boundary */ - unsigned char dummy[2]; - unsigned char host_stat; - unsigned char target_stat; - /*------------------------------------longword boundary */ - unsigned char target; - unsigned char lun; - unsigned char scsi_cmd[12]; /* 12 bytes (bytes only) */ - unsigned char dummy2[1]; - unsigned char link_id; - /*------------------------------------4 longword boundary */ - physaddr link_addr; - /*------------------------------------longword boundary */ - physaddr sense_ptr; -/*-----end of HW fields-------------------------------longword boundary */ - struct scsi_sense_data scsi_sense; - /*------------------------------------longword boundary */ - struct bt_scat_gath scat_gath[BT_NSEG]; - /*------------------------------------longword boundary */ - struct bt_ccb *next; - /*------------------------------------longword boundary */ - struct scsi_xfer *xfer; /* the scsi_xfer for this cmd */ - /*------------------------------------longword boundary */ - struct bt_mbx_out *mbx; /* pointer to mail box */ - /*------------------------------------longword boundary */ - int flags; -#define CCB_FREE 0 -#define CCB_ACTIVE 1 -#define CCB_ABORTED 2 - /*------------------------------------longword boundary */ - struct bt_ccb *nexthash; /* if two hash the same */ - /*------------------------------------longword boundary */ - physaddr hashkey; /*physaddr of this ccb */ - /*------------------------------------longword boundary */ -}; - -/* - * opcode fields - */ - -#define BT_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */ -#define BT_TARGET_CCB 0x01 /* SCSI Target CCB */ -#define BT_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */ -#define BT_RESET_CCB 0x81 /* SCSI Bus reset */ - -/* - * bt_ccb.host_stat values - */ - -#define BT_OK 0x00 /* cmd ok */ -#define BT_LINK_OK 0x0a /* Link cmd ok */ -#define BT_LINK_IT 0x0b /* Link cmd ok + int */ -#define BT_SEL_TIMEOUT 0x11 /* Selection time out */ -#define BT_OVER_UNDER 0x12 /* Data over/under run */ -#define BT_BUS_FREE 0x13 /* Bus dropped at unexpected time */ -#define BT_INV_BUS 0x14 /* Invalid bus phase/sequence */ -#define BT_BAD_MBO 0x15 /* Incorrect MBO cmd */ -#define BT_BAD_CCB 0x16 /* Incorrect ccb opcode */ -#define BT_BAD_LINK 0x17 /* Not same values of LUN for links */ -#define BT_INV_TARGET 0x18 /* Invalid target direction */ -#define BT_CCB_DUP 0x19 /* Duplicate CCB received */ -#define BT_INV_CCB 0x1a /* Invalid CCB or segment list */ -#define BT_ABORTED 42 /* pseudo value from driver */ - -struct bt_boardID { - u_char board_type; - u_char custom_feture; - char firm_revision; - u_char firm_version; -}; - -struct bt_setup { - u_char sync_neg:1; - u_char parity:1; - u_char :6; - u_char speed; - u_char bus_on; - u_char bus_off; - u_char num_mbx; - u_char mbx[3]; /* for backwards compatibility */ - struct { - u_char offset:4; - u_char period:3; - u_char valid:1; - } sync[8]; - u_char disc_sts; -}; - -struct bt_config { - u_char chan; - u_char intr; - u_char scsi_dev:3; - u_char :5; -}; - -#define BT_INQUIRE_REV_THIRD 0x84 /* Get Adapter FirmWare version #3 */ -#define BT_INQUIRE_REV_FOURTH 0x85 /* Get Adapter FirmWare version #4 */ - -/* - * Determine 32bit address/Data firmware functionality from the bus type - * Note: bt742a/747[s|d]/757/946/445s will return 'E' - * bt542b/545s/545d will return 'A' - * 94/05/18 amurai@spec.co.jp - */ -#define BT_BUS_TYPE_24bit 'A' /* PC/AT 24 bit address bus type */ -#define BT_BUS_TYPE_32bit 'E' /* EISA/VLB/PCI 32 bit address bus type */ -#define BT_BUS_TYPE_MCA 'M' /* Micro chanel is ? forget it right now */ -struct bt_ext_info { - u_char bus_type; /* Host adapter bus type */ - u_char bios_addr; /* Bios Address-Not used */ - u_short max_seg; /* Max segment List */ - u_char num_mbx; /* Number of mailbox */ - int32 mbx_base; /* mailbox base address */ - struct { - u_char resv1:1; /* ??? */ - u_char force:1; /* ON: force sync */ - u_char maxsync:1; /* ON: 10MB/s , OFF: 5MB/s */ - u_char resv2:2; /* ??? */ - u_char sync:1; /* ON: Sync, OFF: async ONLY!! */ - u_char resv3:2; /* ??? */ - } s; - u_char firmid[3]; /* Firmware ver. & rev. w/o last char */ -}; - -#define BT_GET_BOARD_INFO 0x8b /* Get H/W ID and Revision */ -struct bt_board_info { - u_char id[4]; /* i.e bt742a -> '7','4','2','A' */ - u_char ver[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */ -}; - -#define BT_GET_SYNC_VALUE 0x8c /* Get Synchronous Value */ -struct bt_sync_value { - u_char value[8]; /* Synchrnous value (value * 10 nsec) */ -}; - -#define INT9 0x01 -#define INT10 0x02 -#define INT11 0x04 -#define INT12 0x08 -#define INT14 0x20 -#define INT15 0x40 - -#define EISADMA 0x00 -#define CHAN0 0x01 -#define CHAN5 0x20 -#define CHAN6 0x40 -#define CHAN7 0x80 - -#define KVTOPHYS(x) vtophys(x) -#define PAGESIZ 4096 -#define INVALIDATE_CACHE {asm volatile( ".byte 0x0F ;.byte 0x08" ); } - -static struct bt_data { - short bt_base; /* base port for each board */ - struct bt_mbx bt_mbx; /* all our mailboxes */ - struct bt_ccb *bt_ccb_free; /* list of free CCBs */ - struct bt_ccb *ccbhash[CCB_HASH_SIZE]; /* phys to kv hash */ - int bt_int; /* int. read off board */ - int bt_dma; /* DMA channel read of board */ - int bt_scsi_dev; /* adapters scsi id */ - int numccbs; /* how many we have malloc'd */ - int bt_bounce; /* should we bounce? */ - struct scsi_link sc_link; /* prototype for devs */ -} *btdata[NBT]; - -/***********debug values *************/ -#define BT_SHOWCCBS 0x01 -#define BT_SHOWINTS 0x02 -#define BT_SHOWCMDS 0x04 -#define BT_SHOWMISC 0x08 -static int bt_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, bt742a_debug, CTLFLAG_RW, &bt_debug, 0, ""); - -#ifdef KERNEL -static int btprobe(); -static int btattach(); -static int32 bt_scsi_cmd(); -static int bt_poll __P((int unit, struct scsi_xfer *xs, struct bt_ccb *ccb)); -static void bt_timeout(void *); -static int bt_init __P((int unit)); -static void bt_inquire_setup_information(); -static void bt_done(); -static void btminphys(); -static u_int32 bt_adapter_info(); -static struct bt_ccb *bt_get_ccb(); -static struct bt_ccb *bt_ccb_phys_kv(); - -static int btunit = 0; -static int btprobing = 0; - -struct isa_driver btdriver = -{ - btprobe, - btattach, - "bt" -}; - -static struct scsi_adapter bt_switch = -{ - bt_scsi_cmd, - btminphys, - 0, - 0, - bt_adapter_info, - "bt", - { 0, 0 } -}; - -/* the below structure is so we have a default dev struct for out link struct */ -static struct scsi_device bt_dev = -{ - NULL, /* Use default error handler */ - NULL, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ - "bt", - 0, - { 0, 0 } -}; - -static struct kern_devconf kdc_bt[NBT] = { { - 0, 0, 0, /* filled in by dev_attach */ - "bt", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_UNCONFIGURED, /* always start here */ - "Buslogic 742-compatible SCSI host adapter", - DC_CLS_MISC /* host adapters aren't special */ -} }; - -static inline void -bt_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_bt[id->id_unit] = kdc_bt[0]; - kdc_bt[id->id_unit].kdc_unit = id->id_unit; - kdc_bt[id->id_unit].kdc_parentdata = id; - dev_attach(&kdc_bt[id->id_unit]); -} - -#endif /*KERNEL */ - -#define BT_RESET_TIMEOUT 1000 -#ifndef KERNEL -main() -{ - printf("bt_data is %d bytes\n", sizeof(struct bt_data)); - printf("bt_ccb is %d bytes\n", sizeof(struct bt_ccb)); - printf("bt_mbx is %d bytes\n", sizeof(struct bt_mbx)); -} - -#else /*KERNEL */ - -/* - * bt_cmd(unit, icnt, ocnt, wait, retval, opcode, args) - * - * Activate Adapter command - * icnt: number of args (outbound bytes written after opcode) - * ocnt: number of expected returned bytes - * wait: number of seconds to wait for response - * retval: buffer where to place returned bytes - * opcode: opcode BT_NOP, BT_MBX_INIT, BT_START_SCSI ... - * args: parameters - * - * Performs an adapter command through the ports. Not to be confused with a - * scsi command, which is read in via the dma; one of the adapter commands - * tells it to read in a scsi command. - */ -static int -bt_cmd(unit, icnt, ocnt, wait, retval, opcode, args) - int unit; - int icnt; - int ocnt; - int wait; - u_char *retval; - unsigned opcode; - u_char args; -{ - struct bt_data *bt = btdata[unit]; - unsigned *ic = &opcode; - u_char oc; - register i; - int sts; - - /* - * multiply the wait argument by a big constant - * zero defaults to 1 - */ - if (wait) - wait *= 100000; - else - wait = 100000; - /* - * Wait for the adapter to go idle, unless it's one of - * the commands which don't need this - */ - if (opcode != BT_MBX_INIT && opcode != BT_START_SCSI) { - i = 100000; /* 1 sec? */ - while (--i) { - sts = inb(BT_CTRL_STAT_PORT); - if (sts & BT_IDLE) { - break; - } - DELAY(10); - } - if (i == 0) { - if(!btprobing) - printf("bt%d: bt_cmd, host not idle(0x%x)\n", - unit, sts); - return (ENXIO); - } - } - /* - * Now that it is idle, if we expect output, preflush the - * queue feeding to us. - */ - if (ocnt) { - while ((inb(BT_CTRL_STAT_PORT)) & BT_DF) - inb(BT_CMD_DATA_PORT); - } - /* - * Output the command and the number of arguments given - * for each byte, first check the port is empty. - */ - icnt++; - /* include the command */ - while (icnt--) { - sts = inb(BT_CTRL_STAT_PORT); - for (i = wait; i; i--) { - sts = inb(BT_CTRL_STAT_PORT); - if (!(sts & BT_CDF)) - break; - DELAY(10); - } - if (i == 0) { - if(!btprobing) - printf("bt%d: bt_cmd, cmd/data port full\n", - unit); - outb(BT_CTRL_STAT_PORT, BT_SRST); - return (ENXIO); - } - outb(BT_CMD_DATA_PORT, (u_char) (*ic++)); - } - /* - * If we expect input, loop that many times, each time, - * looking for the data register to have valid data - */ - while (ocnt--) { - sts = inb(BT_CTRL_STAT_PORT); - for (i = wait; i; i--) { - sts = inb(BT_CTRL_STAT_PORT); - if (sts & BT_DF) - break; - DELAY(10); - } - if (i == 0) { - if(!btprobing) - printf("bt%d: bt_cmd, cmd/data port empty %d\n", - unit, ocnt); - return (ENXIO); - } - oc = inb(BT_CMD_DATA_PORT); - if (retval) - *retval++ = oc; - } - /* - * Wait for the board to report a finised instruction - */ - i = 100000; /* 1 sec? */ - while (--i) { - sts = inb(BT_INTR_PORT); - if (sts & BT_HACC) { - break; - } - DELAY(10); - } - if (i == 0) { - if(!btprobing) - printf("bt%d: bt_cmd, host not finished(0x%x)\n", - unit, sts); - return (ENXIO); - } - outb(BT_CTRL_STAT_PORT, BT_IRST); - return (0); -} - -/* - * Check if the device can be found at the port given - * and if so, set it up ready for further work - * as an argument, takes the isa_device structure from - * autoconf.c - */ -static int -btprobe(dev) - struct isa_device *dev; -{ - /* - * find unit and check we have that many defined - */ - int unit = btunit; - struct bt_data *bt; - - btprobing = 1; - if (unit >= NBT) { - printf("bt%d: unit number too high\n", unit); - return 0; - } - /* - * Allocate a storage area for us - */ - if (btdata[unit]) { - printf("bt%d: memory already allocated\n", unit); - return 0; - } - bt = malloc(sizeof(struct bt_data), M_TEMP, M_NOWAIT); - if (!bt) { - printf("bt%d: cannot malloc!\n", unit); - return 0; - } - bzero(bt, sizeof(struct bt_data)); - btdata[unit] = bt; - if(dev->id_iobase > 0xFFF) /* an EISA card, we have an EISA port */ - { - int i = inb(dev->id_iobase + 0x0C); - static unsigned long bt_iobase[8] = - { 0x330,0x334,0x230,0x234,0x130,0x134,0x00,0x00 }; - - if (!(dev->id_iobase = bt_iobase[i&7])) { - printf("bt_iobase disabled or invalid; index %d\n" - ,i&7); - return 0; - } -#if defined(DEBUG) - printf("btprobe: Trying iobase 0x%x\n",dev->dev_addr); -#endif /* defined(DEBUG) */ - } - - bt->bt_base = dev->id_iobase; - -#ifndef DEV_LKM - bt_registerdev(dev); -#endif /* not DEV_LKM */ - - /* - * Try initialise a unit at this location - * sets up dma and bus speed, loads bt->bt_int - */ - if (bt_init(unit) != 0) { - btdata[unit] = NULL; - free(bt, M_TEMP); - return 0; - } - /* - * If it's there, put in it's interrupt vectors - */ - dev->id_unit = unit; - dev->id_irq = (1 << bt->bt_int); - dev->id_drq = bt->bt_dma; - - btunit++; - return 1; -} - -/* - * Attach all the sub-devices we can find - */ -static int -btattach(dev) - struct isa_device *dev; -{ - int unit = dev->id_unit; - struct bt_data *bt = btdata[unit]; - struct scsibus_data *scbus; - - btprobing = 0; - /* - * fill in the prototype scsi_link. - */ - bt->sc_link.adapter_unit = unit; - bt->sc_link.adapter_targ = bt->bt_scsi_dev; - bt->sc_link.adapter = &bt_switch; - bt->sc_link.device = &bt_dev; - bt->sc_link.flags = bt->bt_bounce ? SDEV_BOUNCE : 0; - - /* - * Prepare the scsibus_data area for the upperlevel - * scsi code. - */ - scbus = scsi_alloc_bus(); - /* XXX scbus->magtarg should be adjusted for Wide cards */ - if(!scbus) - return 0; - scbus->adapter_link = &bt->sc_link; - - kdc_bt[unit].kdc_state = DC_BUSY; /* host adapters are always busy */ - - /* - * ask the adapter what subunits are present - */ - scsi_attachdevs(scbus); - return 1; -} - -/* - * Return some information to the caller about the adapter and its - * capabilities. - */ -static u_int32 -bt_adapter_info(unit) - int unit; -{ - return (2); /* 2 outstanding requests at a time per device */ -} - -/* - * Catch an interrupt from the adaptor - */ -void -btintr(unit) - int unit; -{ - struct bt_data *bt = btdata[unit]; - BT_MBI *wmbi; - struct bt_mbx *wmbx; - struct bt_ccb *ccb; - unsigned char stat; - int i, wait; - int found = 0; - -#ifdef UTEST - printf("btintr "); -#endif - /* - * First acknowlege the interrupt, Then if it's - * not telling about a completed operation - * just return. - */ - stat = inb(BT_INTR_PORT); - - /* Mail Box out empty ? */ - if (stat & BT_MBOA) { - printf("bt%d: Available Free mbo post\n", unit); - /* Disable MBO available interrupt */ - outb(BT_CMD_DATA_PORT, BT_MBO_INTR_EN); - wait = 100000; /* 1 sec enough? */ - for (i = wait; i; i--) { - if (!(inb(BT_CTRL_STAT_PORT) & BT_CDF)) - break; - DELAY(10); - } - if (i == 0) { - printf("bt%d: bt_intr, cmd/data port full\n", unit); - outb(BT_CTRL_STAT_PORT, BT_SRST); - return; - } - outb(BT_CMD_DATA_PORT, 0x00); /* Disable */ - wakeup((caddr_t)&bt->bt_mbx); - outb(BT_CTRL_STAT_PORT, BT_IRST); - return; - } - if (!(stat & BT_MBIF)) { - outb(BT_CTRL_STAT_PORT, BT_IRST); - return; - } - /* - * If it IS then process the competed operation - */ - wmbx = &bt->bt_mbx; - wmbi = wmbx->tmbi; - AGAIN: - while (wmbi->stat != BT_MBI_FREE) { - ccb = bt_ccb_phys_kv(bt, (wmbi->ccb_addr)); - if (!ccb) { - wmbi->stat = BT_MBI_FREE; - printf("bt: BAD CCB ADDR!\n"); - continue; - } - found++; - if ((stat = wmbi->stat) != BT_MBI_OK) { - switch (stat) { - case BT_MBI_ABORT: -#ifdef UTEST - if (bt_debug & BT_SHOWMISC) - printf("abort "); -#endif - ccb->host_stat = BT_ABORTED; - break; - - case BT_MBI_UNKNOWN: - ccb = (struct bt_ccb *) 0; -#ifdef UTEST - if (bt_debug & BT_SHOWMISC) - printf("unknown ccb for abort"); -#endif - break; - - case BT_MBI_ERROR: - break; - - default: - panic("Impossible mbxi status"); - - } -#ifdef UTEST - if ((bt_debug & BT_SHOWCMDS) && ccb) { - u_char *cp; - cp = ccb->scsi_cmd; - printf("op=%x %x %x %x %x %x\n", - cp[0], cp[1], cp[2], - cp[3], cp[4], cp[5]); - printf("stat %x for mbi addr = 0x%08x\n" - ,wmbi->stat, wmbi); - printf("addr = 0x%x\n", ccb); - } -#endif - } - wmbi->stat = BT_MBI_FREE; - if (ccb) { - untimeout(bt_timeout, (caddr_t)ccb); - bt_done(unit, ccb); - } - /* Set the IN mail Box pointer for next */ bt_nextmbx(wmbi, wmbx, mbi); - } - if (!found) { - for (i = 0; i < BT_MBX_SIZE; i++) { - if (wmbi->stat != BT_MBI_FREE) { - found++; - break; - } - bt_nextmbx(wmbi, wmbx, mbi); - } - if (!found) { -#ifdef DEBUG - printf("bt%d: mbi at 0x%08x should be found, stat=%02x..resync\n", - unit, wmbi, stat); -#endif - } else { - found = 0; - goto AGAIN; - } - } - wmbx->tmbi = wmbi; - outb(BT_CTRL_STAT_PORT, BT_IRST); -} - -/* - * A ccb is put onto the free list. - */ -static void -bt_free_ccb(unit, ccb, flags) - int unit; - struct bt_ccb *ccb; - int flags; -{ - struct bt_data *bt = btdata[unit]; - unsigned int opri; - - opri = splbio(); - - ccb->next = bt->bt_ccb_free; - bt->bt_ccb_free = ccb; - ccb->flags = CCB_FREE; - /* - * If there were none, wake anybody waiting for one to come free, - * starting with queued entries. - */ - if (!ccb->next) { - wakeup((caddr_t)&bt->bt_ccb_free); - } - - splx(opri); -} - -/* - * Get a free ccb - * - * If there are none, see if we can allocate a new one. If so, put it in - * the hash table too otherwise either return an error or sleep. - */ -static struct bt_ccb * -bt_get_ccb(unit, flags) - int unit; - int flags; -{ - struct bt_data *bt = btdata[unit]; - unsigned opri; - struct bt_ccb *ccbp; - int hashnum; - - opri = splbio(); - /* - * If we can and have to, sleep waiting for one to come free - * but only if we can't allocate a new one. - */ - while (!(ccbp = bt->bt_ccb_free)) { - if (bt->numccbs < BT_CCB_MAX) { - if (ccbp = (struct bt_ccb *) malloc(sizeof(struct bt_ccb), - M_TEMP, - M_NOWAIT)) { - bzero(ccbp, sizeof(struct bt_ccb)); - bt->numccbs++; - ccbp->flags = CCB_ACTIVE; - /* - * put in the phystokv hash table - * Never gets taken out. - */ - ccbp->hashkey = KVTOPHYS(ccbp); - hashnum = CCB_HASH(ccbp->hashkey); - ccbp->nexthash = bt->ccbhash[hashnum]; - bt->ccbhash[hashnum] = ccbp; - } else { - printf("bt%d: Can't malloc CCB\n", unit); - } - goto gottit; - } else { - if (!(flags & SCSI_NOSLEEP)) { - tsleep((caddr_t)&bt->bt_ccb_free, PRIBIO, - "btccb", 0); - continue; - } - break; - } - } - if (ccbp) { - /* Get CCB from from free list */ - bt->bt_ccb_free = ccbp->next; - ccbp->flags = CCB_ACTIVE; - } - gottit: - splx(opri); - - return (ccbp); -} - -/* - * given a physical address, find the ccb that - * it corresponds to: - */ -static struct bt_ccb * -bt_ccb_phys_kv(bt, ccb_phys) - struct bt_data *bt; - physaddr ccb_phys; -{ - int hashnum = CCB_HASH(ccb_phys); - struct bt_ccb *ccbp = bt->ccbhash[hashnum]; - - while (ccbp) { - if (ccbp->hashkey == ccb_phys) - break; - ccbp = ccbp->nexthash; - } - return ccbp; -} - -/* - * Get a MBO and then Send it - */ -static BT_MBO * -bt_send_mbo(int unit, int flags, int cmd, struct bt_ccb *ccb) -{ - struct bt_data *bt = btdata[unit]; - unsigned opri; - BT_MBO *wmbo; /* Mail Box Out pointer */ - struct bt_mbx *wmbx; /* Mail Box pointer specified unit */ - int i, wait; - - wmbx = &bt->bt_mbx; - - opri = splbio(); - - /* Get the Target OUT mail Box pointer and move to Next */ - wmbo = wmbx->tmbo; - wmbx->tmbo = (wmbo == &(wmbx->mbo[BT_MBX_SIZE - 1]) ? - &(wmbx->mbo[0]) : wmbo + 1); - - /* - * Check the outmail box is free or not. - * Note: Under the normal operation, it shuld NOT happen to wait. - */ - while (wmbo->cmd != BT_MBO_FREE) { - wait = 100000; /* 1 sec enough? */ - /* Enable MBO available interrupt */ - outb(BT_CMD_DATA_PORT, BT_MBO_INTR_EN); - for (i = wait; i; i--) { - if (!(inb(BT_CTRL_STAT_PORT) & BT_CDF)) - break; - DELAY(10); - } - if (i == 0) { - printf("bt%d: bt_send_mbo, cmd/data port full\n", unit); - outb(BT_CTRL_STAT_PORT, BT_SRST); - return ((BT_MBO *) 0); - } - outb(BT_CMD_DATA_PORT, 0x01); /* Enable */ - tsleep((caddr_t)wmbx, PRIBIO, "btsend", 0); - /* XXX */ /*can't do this! */ - /* May be servicing an int */ - } - /* Link CCB to the Mail Box */ - wmbo->ccb_addr = KVTOPHYS(ccb); - ccb->mbx = wmbo; - wmbo->cmd = cmd; - - /* Send it! */ - outb(BT_CMD_DATA_PORT, BT_START_SCSI); - - splx(opri); - - return (wmbo); -} - -/* - * We have a ccb which has been processed by the - * adaptor, now we look to see how the operation - * went. Wake up the owner if waiting - */ -static void -bt_done(unit, ccb) - int unit; - struct bt_ccb *ccb; -{ - struct scsi_sense_data *s1, *s2; - struct scsi_xfer *xs = ccb->xfer; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("bt_done\n")); - /* - * Otherwise, put the results of the operation - * into the xfer and call whoever started it - */ - if ((ccb->host_stat != BT_OK || ccb->target_stat != SCSI_OK) - && (!(xs->flags & SCSI_ERR_OK))) { - - s1 = &(ccb->scsi_sense); - s2 = &(xs->sense); - - if (ccb->host_stat) { - switch (ccb->host_stat) { - case BT_ABORTED: /* No response */ - case BT_SEL_TIMEOUT: /* No response */ - SC_DEBUG(xs->sc_link, SDEV_DB3, - ("timeout reported back\n")); - xs->error = XS_TIMEOUT; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; - SC_DEBUG(xs->sc_link, SDEV_DB3, - ("unexpected host_stat: %x\n", - ccb->host_stat)); - } - } else { - switch (ccb->target_stat) { - case 0x02: - *s2 = *s1; - xs->error = XS_SENSE; - break; - case 0x08: - xs->error = XS_BUSY; - break; - default: - SC_DEBUG(xs->sc_link, SDEV_DB3, - ("unexpected target_stat: %x\n", - ccb->target_stat)); - xs->error = XS_DRIVER_STUFFUP; - } - } - } else { /* All went correctly OR errors expected */ - xs->resid = 0; - } - xs->flags |= ITSDONE; - bt_free_ccb(unit, ccb, xs->flags); - scsi_done(xs); -} - -/* - * Start the board, ready for normal operation - */ -static int -bt_init(unit) - int unit; -{ - struct bt_data *bt = btdata[unit]; - unsigned char ad[4]; - volatile int i, sts; - struct bt_config conf; - struct bt_ext_info info; - struct bt_board_info binfo; - - /* - * reset board, If it doesn't respond, assume - * that it's not there.. good for the probe - */ - - outb(BT_CTRL_STAT_PORT, BT_HRST | BT_SRST); - - DELAY(10000); - - for (i = BT_RESET_TIMEOUT; i; i--) { - sts = inb(BT_CTRL_STAT_PORT); - if (sts == (BT_IDLE | BT_INIT)) - break; - DELAY(1000); - } - if (i == 0) { -#ifdef UTEST - printf("bt_init: No answer from board\n"); -#endif - return (ENXIO); - } - - DELAY(10000); - - /* - * Displaying Board ID and Hardware Revision - * 94/05/18 amurai@spec.co.jp - */ - i = bt_cmd(unit, 1, sizeof(binfo),0, - &binfo,BT_GET_BOARD_INFO,sizeof(binfo)); - if(i) - return i; - printf("bt%d: Bt%c%c%c%c/%c%d-", unit, - binfo.id[0], - binfo.id[1], - binfo.id[2], - binfo.id[3], - binfo.ver[0], - (unsigned) binfo.ver[1] - ); - - /* - * Make sure board has a capability of 32bit addressing. - * and Firmware also need a capability of 32bit addressing pointer - * in Extended mailbox and ccb structure. - * 94/05/18 amurai@spec.co.jp - */ - bt_cmd(unit, 1, sizeof(info),0,&info, BT_INQUIRE_EXTENDED,sizeof(info)); - switch (info.bus_type) { - case BT_BUS_TYPE_24bit: /* PC/AT 24 bit address bus */ - printf("ISA(24bit) bus\n"); - break; - case BT_BUS_TYPE_32bit: /* EISA/VLB/PCI 32 bit bus */ - printf("PCI/EISA/VLB(32bit) bus\n"); - break; - case BT_BUS_TYPE_MCA: /* forget it right now */ - printf("MCA bus architecture..."); - printf("giving up\n"); - return (ENXIO); - break; - default: - printf("Unknown state..."); - printf("giving up\n"); - return (ENXIO); - break; - } - if ( binfo.id[0] == '4' && binfo.id[1] == '4' && binfo.id[2] == '5' && - binfo.id[3] == 'S' ) { - printf("bt%d: Your card cannot DMA above 16MB boundary. Bounce buffering enabled.\n", unit); - bt->bt_bounce++; - } else if ( binfo.id[0] == '5' ) { - printf("bt%d: This driver is designed for using 32 bit addressing\n",unit); - printf("bt%d: mode firmware and EISA/PCI/VLB bus architectures\n",unit); - printf("bt%d: Bounce-buffering will be used (and is necessary)\n", unit); - printf("bt%d: if you have more than 16MBytes memory.\n",unit); - bt->bt_bounce++; - } else if ( info.bus_type == BT_BUS_TYPE_24bit ) { - printf("bt%d: Your board should report a 32bit bus architecture type..\n",unit); - printf("bt%d: The firmware on your board may have a problem with over\n",unit); - printf("bt%d: 16MBytes memory handling with this driver.\n",unit); - bt->bt_bounce++; - } - - /* - * Assume we have a board at this stage - * setup dma channel from jumpers and save int - * level - */ - printf("bt%d: reading board settings, ", unit); - - bt_cmd(unit, 0, sizeof(conf), 0, &conf, BT_CONF_GET); - switch (conf.chan) { - case EISADMA: - bt->bt_dma = -1; - break; - case CHAN0: - outb(0x0b, 0x0c); - outb(0x0a, 0x00); - bt->bt_dma = 0; - break; - case CHAN5: - outb(0xd6, 0xc1); - outb(0xd4, 0x01); - bt->bt_dma = 5; - break; - case CHAN6: - outb(0xd6, 0xc2); - outb(0xd4, 0x02); - bt->bt_dma = 6; - break; - case CHAN7: - outb(0xd6, 0xc3); - outb(0xd4, 0x03); - bt->bt_dma = 7; - break; - default: - printf("illegal dma setting %x\n", conf.chan); - return (EIO); - } - if (bt->bt_dma == -1) - printf("busmastering, "); - else - printf("dma=%d, ", bt->bt_dma); - - switch (conf.intr) { - case INT9: - bt->bt_int = 9; - break; - case INT10: - bt->bt_int = 10; - break; - case INT11: - bt->bt_int = 11; - break; - case INT12: - bt->bt_int = 12; - break; - case INT14: - bt->bt_int = 14; - break; - case INT15: - bt->bt_int = 15; - break; - default: - printf("illegal int setting\n"); - return (EIO); - } - printf("int=%d\n", bt->bt_int); - - /* who are we on the scsi bus */ - bt->bt_scsi_dev = conf.scsi_dev; - /* - * Initialize mail box - */ - *((physaddr *) ad) = KVTOPHYS(&bt->bt_mbx); - bt_cmd(unit, 5, 0, 0, 0, BT_MBX_INIT_EXTENDED - ,BT_MBX_SIZE - ,ad[0] - ,ad[1] - ,ad[2] - ,ad[3]); - - /* - * Set Pointer chain null for just in case - * Link the ccb's into a free-list W/O mbox - * Initialize mail box status to free - */ - if (bt->bt_ccb_free != (struct bt_ccb *) 0) { - printf("bt%d: bt_ccb_free is NOT initialized but init here\n", - unit); - bt->bt_ccb_free = (struct bt_ccb *) 0; - } - for (i = 0; i < BT_MBX_SIZE; i++) { - bt->bt_mbx.mbo[i].cmd = BT_MBO_FREE; - bt->bt_mbx.mbi[i].stat = BT_MBI_FREE; - } - /* - * Set up initial mail box for round-robin operation. - */ - bt->bt_mbx.tmbo = &bt->bt_mbx.mbo[0]; - bt->bt_mbx.tmbi = &bt->bt_mbx.mbi[0]; - bt_inquire_setup_information(unit, &info); - - /* - * Note that we are going and return (to probe) - */ - return 0; -} - -static void -bt_inquire_setup_information( - int unit, - struct bt_ext_info *info ) -{ - struct bt_setup setup; - struct bt_sync_value sync; - char dummy[8]; - char sub_ver[3]; - struct bt_boardID bID; - int i; - - /* Inquire Installed Devices */ - bzero( &dummy[0], sizeof(dummy) ); - bt_cmd(unit, 0, sizeof(dummy), 100, &dummy[0], BT_DEV_GET); - - /* - * If board has a capbility of Syncrhonouse mode, - * Get a SCSI Synchronous value - */ - - if (info->s.force) { /* Assume fast sync capability */ - info->s.sync = 1; /* It's appear at 4.25? version */ - info->s.maxsync = 1; - } - if ( info->s.sync ) { - bt_cmd(unit, 1, sizeof(sync), 100, - &sync,BT_GET_SYNC_VALUE,sizeof(sync)); - } - - /* - * Inquire Board ID to board for firmware version - */ - bt_cmd(unit, 0, sizeof(bID), 0, &bID, BT_INQUIRE); - bt_cmd(unit, 0, 1, 0, &sub_ver[0], BT_INQUIRE_REV_THIRD ); - i = ((int)(bID.firm_revision-'0')) * 10 + (int)(bID.firm_version-'0'); - if ( i >= 33 ) { - bt_cmd(unit, 0, 1, 0, &sub_ver[1], BT_INQUIRE_REV_FOURTH ); - } else { - /* - * Below rev 3.3 firmware has a problem for issuing - * the BT_INQUIRE_REV_FOURTH command. - */ - sub_ver[1]='\0'; - } - sub_ver[2]='\0'; - if (sub_ver[1]==' ') - sub_ver[1]='\0'; - printf("bt%d: version %c.%c%s, ", - unit, bID.firm_revision, bID.firm_version, sub_ver ); - - /* - * Obtain setup information from board. - */ - bt_cmd(unit, 1, sizeof(setup), 0, &setup, BT_SETUP_GET, sizeof(setup)); - - if (setup.sync_neg && info->s.sync ) { - if ( info->s.maxsync ) { - printf("fast sync, "); /* Max 10MB/s */ - } else { - printf("sync, "); /* Max 5MB/s */ - } - } else { - if ( info->s.sync ) { - printf("async, "); /* Never try by board */ - } else { - printf("async only, "); /* Doesn't has a capability on board */ - } - } - if (setup.parity) { - printf("parity, "); - } else { - printf("no parity, "); - } - printf("%d mbxs, %d ccbs\n", setup.num_mbx, BT_CCB_MAX); - - /* - * Displayi SCSI negotiation value by each target. - * amurai@spec.co.jp - */ - for (i = 0; i < 8; i++) { - if (!setup.sync[i].valid ) - continue; - if ( (!setup.sync[i].offset && !setup.sync[i].period) - || !info->s.sync ) { - printf("bt%d: targ %d async\n", unit, i); - } else { - printf("bt%d: targ %d sync rate=%2d.%02dMB/s(%dns), offset=%02d\n", - unit, i, - 100 / sync.value[i], - (100 % sync.value[i]) * 100 / sync.value[i], - sync.value[i] * 10, - setup.sync[i].offset ); - } - } - - /* - * Enable round-robin scheme - appeared at firmware rev. 3.31 - * Below rev 3.XX firmware has a problem for issuing - * BT_ROUND_ROBIN command amurai@spec.co.jp - */ - if ( bID.firm_revision >= '3' ) { - printf("bt%d: Using Strict Round robin scheme\n", unit); - bt_cmd(unit, 1, 0, 0, 0, BT_ROUND_ROBIN, BT_STRICT_ROUND_ROBIN); - } else { - printf("bt%d: Not using Strict Round robin scheme\n", unit); - } - -} - -#ifndef min -#define min(x,y) (x < y ? x : y) -#endif /* min */ - -static void -btminphys(bp) - struct buf *bp; -{ - if (bp->b_bcount > ((BT_NSEG - 1) * PAGESIZ)) { - bp->b_bcount = ((BT_NSEG - 1) * PAGESIZ); - } -} - -/* - * start a scsi operation given the command and the data address. Also needs - * the unit, target and lu. - */ -static int32 -bt_scsi_cmd(xs) - struct scsi_xfer *xs; -{ - struct bt_ccb *ccb; - struct bt_scat_gath *sg; - int seg; /* scatter gather seg being worked on */ - int thiskv; - physaddr thisphys, nextphys; - int unit = xs->sc_link->adapter_unit; - int bytes_this_seg, bytes_this_page, datalen, flags; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("bt_scsi_cmd\n")); - /* - * get a ccb (mbox-out) to use. If the transfer - * is from a buf (possibly from interrupt time) - * then we can't allow it to sleep - */ - flags = xs->flags; - if (flags & ITSDONE) { - printf("bt%d: Already done?\n", unit); - xs->flags &= ~ITSDONE; - } - if (!(flags & INUSE)) { - printf("bt%d: Not in use?\n", unit); - xs->flags |= INUSE; - } - if (!(ccb = bt_get_ccb(unit, flags))) { - xs->error = XS_DRIVER_STUFFUP; - return (TRY_AGAIN_LATER); - } - SC_DEBUG(xs->sc_link, SDEV_DB3, - ("start ccb(%p)\n", ccb)); - /* - * Put all the arguments for the xfer in the ccb - */ - ccb->xfer = xs; - if (flags & SCSI_RESET) { - ccb->opcode = BT_RESET_CCB; - } else { - /* can't use S/G if zero length */ - ccb->opcode = (xs->datalen ? - BT_INIT_SCAT_GATH_CCB - : BT_INITIATOR_CCB); - } - ccb->target = xs->sc_link->target; - ccb->data_out = 0; - ccb->data_in = 0; - ccb->lun = xs->sc_link->lun; - ccb->scsi_cmd_length = xs->cmdlen; - ccb->sense_ptr = KVTOPHYS(&(ccb->scsi_sense)); - ccb->req_sense_length = sizeof(ccb->scsi_sense); - - if ((xs->datalen) && (!(flags & SCSI_RESET))) { /* can use S/G only if not zero length */ - ccb->data_addr = KVTOPHYS(ccb->scat_gath); - sg = ccb->scat_gath; - seg = 0; -#ifdef TFS - if (flags & SCSI_DATA_UIO) { - iovp = ((struct uio *) xs->data)->uio_iov; - datalen = ((struct uio *) xs->data)->uio_iovcnt; - xs->datalen = 0; - while ((datalen) && (seg < BT_NSEG)) { - sg->seg_addr = (physaddr) iovp->iov_base; - xs->datalen += sg->seg_len = iovp->iov_len; - SC_DEBUGN(xs->sc_link, SDEV_DB4, ("(0x%x@0x%x)" - ,iovp->iov_len, iovp->iov_base)); - sg++; - iovp++; - seg++; - datalen--; - } - } else -#endif /* TFS */ - { - /* - * Set up the scatter gather block - */ - - SC_DEBUG(xs->sc_link, SDEV_DB4, - ("%ld @%p:- ", xs->datalen, xs->data)); - datalen = xs->datalen; - thiskv = (int) xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < BT_NSEG)) { - bytes_this_seg = 0; - - /* put in the base address */ - sg->seg_addr = thisphys; - - SC_DEBUGN(xs->sc_link, SDEV_DB4, - ("0x%lx", thisphys)); - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) - /* - * This page is contiguous (physically) with - * the the last, just extend the length - */ - { - /* how far to the end of the page */ - nextphys = (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if (datalen) - thisphys = KVTOPHYS(thiskv); - } - /* - * next page isn't contiguous, finish the seg - */ - SC_DEBUGN(xs->sc_link, SDEV_DB4, - ("(0x%x)", bytes_this_seg)); - sg->seg_len = bytes_this_seg; - sg++; - seg++; - } - } - /* end of iov/kv decision */ - ccb->data_length = seg * sizeof(struct bt_scat_gath); - SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n")); - if (datalen) { - /* - * there's still data, must have run out of segs! - */ - printf("bt%d: bt_scsi_cmd, more than %d DMA segs\n", - unit, BT_NSEG); - xs->error = XS_DRIVER_STUFFUP; - bt_free_ccb(unit, ccb, flags); - return (HAD_ERROR); - } - } else { /* No data xfer, use non S/G values */ - ccb->data_addr = (physaddr) 0; - ccb->data_length = 0; - } - ccb->link_id = 0; - ccb->link_addr = (physaddr) 0; - /* - * Put the scsi command in the ccb and start it - */ - if (!(flags & SCSI_RESET)) { - bcopy(xs->cmd, ccb->scsi_cmd, ccb->scsi_cmd_length); - } - if (bt_send_mbo(unit, flags, BT_MBO_START, ccb) == (BT_MBO *) 0) { - xs->error = XS_DRIVER_STUFFUP; - bt_free_ccb(unit, ccb, flags); - return (TRY_AGAIN_LATER); - } - /* - * Usually return SUCCESSFULLY QUEUED - */ - SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n")); - if (!(flags & SCSI_NOMASK)) { - timeout(bt_timeout, (caddr_t)ccb, (xs->timeout * hz) / 1000); - return (SUCCESSFULLY_QUEUED); - } - /* - * If we can't use interrupts, poll on completion - */ - return (bt_poll(unit, xs, ccb)); -} - -/* - * Poll a particular unit, looking for a particular xs - */ -static int -bt_poll(unit, xs, ccb) - int unit; - struct scsi_xfer *xs; - struct bt_ccb *ccb; -{ - struct bt_data *bt = btdata[unit]; - int count = xs->timeout; - u_char stat; - - /* timeouts are in msec, so we loop in 1000 usec cycles */ - while (count) { - /* - * If we had interrupts enabled, would we - * have got an interrupt? - */ - stat = inb(BT_INTR_PORT); - if (stat & BT_ANY_INTR) { - btintr(unit); - } - if (xs->flags & ITSDONE) { - break; - } - DELAY(1000); /* only happens in boot so ok */ - count--; - } - if (count == 0) { - /* - * We timed out, so call the timeout handler manually, - * accounting for the fact that the clock is not running yet - * by taking out the clock queue entry it makes. - */ - bt_timeout(ccb); - - /* - * because we are polling, take out the timeout entry - * bt_timeout made - */ - untimeout(bt_timeout, (caddr_t)ccb); - count = 2000; - while (count) { - /* - * Once again, wait for the int bit - */ - stat = inb(BT_INTR_PORT); - if (stat & BT_ANY_INTR) { - btintr(unit); - } - if (xs->flags & ITSDONE) { - break; - } - DELAY(1000); /* only happens in boot so ok */ - count--; - } - if (count == 0) { - /* - * We timed out again... This is bad. Notice that - * this time there is no clock queue entry to remove. - */ - bt_timeout(ccb); - } - } - if (xs->error) - return (HAD_ERROR); - return (COMPLETE); -} - -static void -bt_timeout(void *arg1) -{ - struct bt_ccb * ccb = (struct bt_ccb *)arg1; - int unit; - struct bt_data *bt; - int s = splbio(); - - /* - * A timeout routine in kernel DONOT unlink - * Entry chains when time outed....So infinity Loop.. - * 94/04/20 amurai@spec.co.jp - */ - untimeout(bt_timeout, (caddr_t)ccb); - - unit = ccb->xfer->sc_link->adapter_unit; - bt = btdata[unit]; - -#ifdef UTEST - bt_print_active_ccbs(unit); -#endif - - /* - * If the ccb's mbx is not free, then the board has gone Far East? - */ - if (bt_ccb_phys_kv(bt, ccb->mbx->ccb_addr) == ccb && - ccb->mbx->cmd != BT_MBO_FREE) { - printf("bt%d: not taking commands!\n", unit); - Debugger("bt742a"); - } - /* - * If it has been through before, then - * a previous abort has failed, don't - * try abort again - */ - if (ccb->flags == CCB_ABORTED) { - /* - * abort timed out - */ - printf("bt%d: Abort Operation has timed out\n", unit); - ccb->xfer->retries = 0; /* I MEAN IT ! */ - ccb->host_stat = BT_ABORTED; - bt_done(unit, ccb); - } else { - /* abort the operation that has timed out */ - printf("bt%d: Try to abort\n", unit); - bt_send_mbo(unit, ~SCSI_NOMASK, - BT_MBO_ABORT, ccb); - /* 2 secs for the abort */ - ccb->flags = CCB_ABORTED; - timeout(bt_timeout, (caddr_t)ccb, 2 * hz); - } - splx(s); -} - -#ifdef UTEST -static void -bt_print_ccb(ccb) - struct bt_ccb *ccb; -{ - printf("ccb:%x op:%x cmdlen:%d senlen:%d\n" - ,ccb - ,ccb->opcode - ,ccb->scsi_cmd_length - ,ccb->req_sense_length); - printf(" datlen:%d hstat:%x tstat:%x flags:%x\n" - ,ccb->data_length - ,ccb->host_stat - ,ccb->target_stat - ,ccb->flags); -} - -static void -bt_print_active_ccbs(int unit) -{ - struct bt_data *bt = btdata[unit]; - struct bt_ccb *ccb; - int i = 0; - - while (i < CCB_HASH_SIZE) { - ccb = bt->ccbhash[i]; - while (ccb) { - if (ccb->flags != CCB_FREE) - bt_print_ccb(ccb); - ccb = ccb->nexthash; - } - i++; - } -} -#endif /*UTEST */ -#endif /*KERNEL */ diff --git a/sys/i386/isa/creative.h b/sys/i386/isa/creative.h deleted file mode 100644 index ed7e1dd..0000000 --- a/sys/i386/isa/creative.h +++ /dev/null @@ -1,129 +0,0 @@ -/*creative.h------------------------------------------------------------------- - Matsushita(Panasonic) / Creative CD-ROM Driver (matcd) - Authored by Frank Durda IV - - Copyright 1994, 1995 Frank Durda IV. All rights reserved. - "FDIV" is a trademark of Frank Durda IV. - - 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 positioned at the very beginning of this file without - modification, all copyright strings, all related programming - codes that display the copyright strings, this list of - conditions and the following disclaimer. - 2. Redistributions in binary form must contain all copyright strings - and related programming code that display the copyright strings. - 3. 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. - 4. All advertising materials mentioning features or use of this - software must display the following acknowledgement: - "The Matsushita/Panasonic CD-ROM driver was developed - by Frank Durda IV for use with "FreeBSD" and similar - operating systems." - "Similar operating systems" includes mainly non-profit oriented - systems for research and education, including but not restricted - to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the - acknowledgement (in electronic form or printed text) may not be - changed without permission from the author. - 5. Absolutely no warranty of function, fitness or purpose is made - by the author Frank Durda IV. - 6. Neither the name of the author nor the name "FreeBSD" may - be used to endorse or promote products derived from this software - without specific prior written permission. - (The author can be reached at bsdmail@nemesis.lonestar.org) - 7. The product containing this software must meet all of these - conditions even if it is unsupported, not a complete system - and/or does not contain compiled code. - 8. These conditions will be in force for the full life of the - copyright. - 9. If all the above conditions are met, modifications to other - parts of this file may be freely made, although any person - or persons making changes do not receive the right to add their - name or names to the copyright strings and notices in this - software. Persons making changes are encouraged to insert edit - history in matcd.c and to put your name and details of the - change there. - 10. You must have prior written permission from the author to - deviate from these terms. - - Vendors who produce product(s) containing this code are encouraged - (but not required) to provide copies of the finished product(s) to - the author and to correspond with the author about development - activity relating to this code. Donations of development hardware - and/or software are also welcome. (This is one of the faster ways - to get a driver developed for a device.) - - THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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. ------------------------------------------------------------------------------ -See matcd.c for Edit History - - These are the I/O port mapping offsets and bit assignments used - by Creative Labs in their implementation of the host interface for - the Matsushita CD-ROM drive. These may be different in the adapter - cards (including sound cards) made by other vendors. - It is unknown if the Creative interface is based on a reference design - provided by Matsushita (other interface vendors would similar or - identical if this was the case). - - The drive is actually capable of some things that the Creative - interface doesn't implement, such as DMA and interrupts. - - See matcd.h for defines related to the Matsushita drive itself. -*/ - - -/* Creative Labs (and compatible) I/O port mapping offsets -*/ - -#define NUMPORTS 4 /*Four ports are decoded by the i/f*/ - -#define CMD 0 /*Write - commands*/ -#define DATA 0 /*Read - data/status from drive*/ -#define PHASE 1 /*Write - switch between data/status*/ -#define STATUS 1 /*Read - buss status*/ -#define RESET 2 /*Write - reset all attached drives*/ - /*Any value written will reset*/ -#define SELECT 3 /*Write - drive select*/ - - -/* Creative PHASE port bit assignments -*/ - -#define PHASENA 1 /*Access data bytes instead of status*/ - - -/* Creative STATUS port register bits -*/ - -#define DTEN 2 /*When low, in data xfer phase*/ -#define STEN 4 /*When low, in status phase*/ -#define TEST 1 /*Function is unknown*/ - - -/* Creative drive SELECT port bit assignments - Note that in the Creative interface, DS0==Bit 1 and - DS1==Bit 0 (DS is Drive Select). -*/ - -#define CRDRIVE0 0x00 -#define CRDRIVE1 0x02 -#define CRDRIVE2 0x01 -#define CRDRIVE3 0x03 - -/*End of creative.h*/ - - diff --git a/sys/i386/isa/ic/ncr_5380.h b/sys/i386/isa/ic/ncr_5380.h deleted file mode 100644 index 0a05bff..0000000 --- a/sys/i386/isa/ic/ncr_5380.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $Id$ - * - * Definitions for 5380 SCSI-controller chip. - * - * Derived from "NCR 53C80 Family SCSI Protocol Controller Data Manual" - */ - -#ifndef _IC_NCR_5380_H_ -#define _IC_NCR_5380_H_ - -#if 0 /* XXX */ -/* - * Register map - */ - -typedef struct { - volatile u_char sci_data; /* r: Current data */ -#define sci_odata sci_data /* w: Out data */ - - volatile u_char sci_icmd; /* rw:Initiator command */ - - volatile u_char sci_mode; /* rw:Mode */ - - volatile u_char sci_tcmd; /* rw:Target command */ - - volatile u_char sci_bus_csr;/* r: Bus Status */ -#define sci_sel_enb sci_bus_csr /* w: Select enable */ - - volatile u_char sci_csr; /* r: Status */ -#define sci_dma_send sci_csr /* w: Start dma send data */ - - volatile u_char sci_idata; /* r: Input data */ -#define sci_trecv sci_idata /* w: Start dma recv, target */ - - volatile u_char sci_iack; /* r: Interrupt Acknowledge */ -#define sci_irecv sci_iack /* w: Start dma recv, initiator */ -} sci_regmap_t; - - -/* - * Initiator command register - */ - -#define SCI_ICMD_DATA 0x01 /* rw:Assert data bus */ -#define SCI_ICMD_ATN 0x02 /* rw:Assert ATN signal */ -#define SCI_ICMD_SEL 0x04 /* rw:Assert SEL signal */ -#define SCI_ICMD_BSY 0x08 /* rw:Assert BSY signal */ -#define SCI_ICMD_ACK 0x10 /* rw:Assert ACK signal */ -#define SCI_ICMD_LST 0x20 /* r: Lost arbitration */ -#define SCI_ICMD_DIFF SCI_ICMD_LST /* w: Differential cable */ -#define SCI_ICMD_AIP 0x40 /* r: Arbitration in progress */ -#define SCI_ICMD_TEST SCI_ICMD_AIP /* w: Test mode */ -#define SCI_ICMD_RST 0x80 /* rw:Assert RST signal */ - - -/* - * Mode register - */ - -#define SCI_MODE_ARB 0x01 /* rw: Start arbitration */ -#define SCI_MODE_DMA 0x02 /* rw: Enable DMA xfers */ -#define SCI_MODE_MONBSY 0x04 /* rw: Monitor BSY signal */ -#define SCI_MODE_DMA_IE 0x08 /* rw: Enable DMA complete interrupt */ -#define SCI_MODE_PERR_IE 0x10 /* rw: Interrupt on parity errors */ -#define SCI_MODE_PAR_CHK 0x20 /* rw: Check parity */ -#define SCI_MODE_TARGET 0x40 /* rw: Target mode (Initiator if 0) */ -#define SCI_MODE_BLOCKDMA 0x80 /* rw: Block-mode DMA handshake (MBZ) */ - - -/* - * Target command register - */ - -#define SCI_TCMD_IO 0x01 /* rw: Assert I/O signal */ -#define SCI_TCMD_CD 0x02 /* rw: Assert C/D signal */ -#define SCI_TCMD_MSG 0x04 /* rw: Assert MSG signal */ -#define SCI_TCMD_PHASE_MASK 0x07 /* r: Mask for current bus phase */ -#define SCI_TCMD_REQ 0x08 /* rw: Assert REQ signal */ -#define SCI_TCMD_LAST_SENT 0x80 /* ro: Last byte was xferred - * (not on 5380/1) */ - -#define SCI_PHASE(x) SCSI_PHASE(x) - -/* - * Current (SCSI) Bus status - */ - -#define SCI_BUS_DBP 0x01 /* r: Data Bus parity */ -#define SCI_BUS_SEL 0x02 /* r: SEL signal */ -#define SCI_BUS_IO 0x04 /* r: I/O signal */ -#define SCI_BUS_CD 0x08 /* r: C/D signal */ -#define SCI_BUS_MSG 0x10 /* r: MSG signal */ -#define SCI_BUS_REQ 0x20 /* r: REQ signal */ -#define SCI_BUS_BSY 0x40 /* r: BSY signal */ -#define SCI_BUS_RST 0x80 /* r: RST signal */ - -#define SCI_CUR_PHASE(x) SCSI_PHASE((x)>>2) - -/* - * Bus and Status register - */ - -#define SCI_CSR_ACK 0x01 /* r: ACK signal */ -#define SCI_CSR_ATN 0x02 /* r: ATN signal */ -#define SCI_CSR_DISC 0x04 /* r: Disconnected (BSY==0) */ -#define SCI_CSR_PHASE_MATCH 0x08 /* r: Bus and SCI_TCMD match */ -#define SCI_CSR_INT 0x10 /* r: Interrupt request */ -#define SCI_CSR_PERR 0x20 /* r: Parity error */ -#define SCI_CSR_DREQ 0x40 /* r: DMA request */ -#define SCI_CSR_DONE 0x80 /* r: DMA count is zero */ - -#endif /* XXX */ - -#define R_CSDR 0 /* R Current SCSI Data Reg. */ -#define W_ODR 0 /* W Output Data Reg. */ - -#define R_ICR 1 /* R Initiator Command Reg. */ -#define R_ICR_ASSERT_RST 0x80 -#define R_ICR_ARBITRATION_IN_PROGRESS 0x40 -#define R_ICR_LOST_ARBITRATION 0x20 -#define R_ICR_ASSERT_ACK 0x10 -#define R_ICR_ASSERT_BSY 0x08 -#define R_ICR_ASSERT_SEL 0x04 -#define R_ICR_ASSERT_ATN 0x02 -#define R_ICR_ASSERT_DATA_BUS 0x01 - -#define W_ICR 1 /* W Initiator Command Reg. */ -#define W_ICR_ASSERT_RST 0x80 -#define W_ICR_TRI_STATE_MODE 0x40 -#define W_ICR_DIFF_ENABLE 0x20 -#define W_ICR_ASSERT_ACK 0x10 -#define W_ICR_ASSERT_BSY 0x08 -#define W_ICR_ASSERT_SEL 0x04 -#define W_ICR_ASSERT_ATN 0x02 -#define W_ICR_ASSERT_DATA_BUS 0x01 - -/* - * The mask to use when doing read_modify_write on ICR. - */ -#define RW_ICR_MASK (~(W_ICR_DIFF_ENABLE|W_ICR_TRI_STATE_MODE)) - -#define RW_MR 2 /* RW Mode Reg. */ -#define RW_MR_BLOCK_MODE_DMA 0x80 -#define RW_MR_TARGET_MODE 0x40 -#define RW_MR_ENABLE_PARITY_CHECKING 0x20 -#define RW_MR_ENABLE_PARITY_INTERRUPT 0x10 -#define RW_MR_ENABLE_EOP_INTERRUPT 0x08 -#define RW_MR_MONITOR_BUSY 0x04 -#define RW_MR_DMA_MODE 0x02 -#define RW_MR_ARBITRATE 0x01 - -#define R_TCR 3 /* R Target Command Reg. */ -#define R_TCR_LAST_BYTE_SENT 0x80 -/* R_TCR_RESERVED 0x40 */ -/* R_TCR_RESERVED 0x20 */ -/* R_TCR_RESERVED 0x10 */ -#define R_TCR_ASSERT_REQ 0x08 -#define R_TCR_ASSERT_MSG 0x04 -#define R_TCR_ASSERT_CD 0x02 -#define R_TCR_ASSERT_IO 0x01 - -#define W_TCR 3 /* W Target Command Reg. */ -/* W_TCR_RESERVED 0x80 */ -/* W_TCR_RESERVED 0x40 */ -/* W_TCR_RESERVED 0x20 */ -/* W_TCR_RESERVED 0x10 */ -#define W_TCR_ASSERT_REQ 0x08 -#define W_TCR_ASSERT_MSG 0x04 -#define W_TCR_ASSERT_CD 0x02 -#define W_TCR_ASSERT_IO 0x01 - -#define R_CSCR 4 /* R Current SCSI Bus Status Reg. */ -#define R_CSCR_RST 0x80 -#define R_CSCR_BSY 0x40 -#define R_CSCR_REQ 0x20 -#define R_CSCR_MSG 0x10 -#define R_CSCR_CD 0x08 -#define R_CSCR_IO 0x04 -#define R_CSCR_SEL 0x02 -#define R_CSCR_ACK 0x01 - -#define W_SER 4 /* W Select Enable Reg. */ -#define W_SER_SCSI_ID_7 0x80 -#define W_SER_SCSI_ID_6 0x40 -#define W_SER_SCSI_ID_5 0x20 -#define W_SER_SCSI_ID_4 0x10 -#define W_SER_SCSI_ID_3 0x08 -#define W_SER_SCSI_ID_2 0x04 -#define W_SER_SCSI_ID_1 0x02 -#define W_SER_SCSI_ID_0 0x01 - -#define R_BSR 5 /* R Bus and Status Reg. */ -#define R_BSR_END_OF_DMA_XFER 0x80 -#define R_BSR_DMA_REQUEST 0x40 -#define R_BSR_PARITY_ERROR 0x20 -#define R_BSR_INTERRUPT_REQUEST_ACTIVE 0x10 -#define R_BSR_PHASE_MISMATCH 0x08 -#define R_BSR_BUSY_ERROR 0x04 -#define R_BSR_ATN 0x02 -#define R_BSR_ACK 0x01 - -#define W_SDSR 5 /* W Start DMA Send Reg. */ -#define R_IDR 6 /* R Input Data Reg. */ -#define W_SDTR 6 /* W Start DMA Target Receive Reg. */ -#define R_RPIR 7 /* R Reset Parity/Interrupt Reg. */ -#define W_SDIR 7 /* W Start DMA Initiator Receive Reg. */ - -#endif /* _IC_NCR_5380_H_ */ diff --git a/sys/i386/isa/if_is.c b/sys/i386/isa/if_is.c deleted file mode 100644 index b374c10..0000000 --- a/sys/i386/isa/if_is.c +++ /dev/null @@ -1,1102 +0,0 @@ -/* - * Isolan AT 4141-0 Ethernet driver - * Isolink 4110 - * - * By Paul Richards - * - * Copyright (C) 1993, Paul Richards. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - * - * $Id: if_is.c,v 1.32 1994/11/24 14:29:22 davidg Exp $ - */ - -/* TODO - -1) Add working multicast support -2) Use better allocation of memory to card -3) Advertise for more packets until all transmit buffers are full -4) Add more of the timers/counters e.g. arpcom.opackets etc. -*/ - -#include "is.h" -#if NIS > 0 - -#include "bpfilter.h" - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/mbuf.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/devconf.h> - -#include <net/if.h> -#include <net/if_dl.h> -#include <net/if_types.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#include <netinet/if_ether.h> -#endif - -#ifdef NS -#include <netns/ns.h> -#include <netns/ns_if.h> -#endif - -#if NBPFILTER > 0 -#include <net/bpf.h> -#include <net/bpfdesc.h> -#endif - -#include <i386/isa/isa_device.h> -#include <i386/isa/if_isreg.h> -#include <i386/isa/icu.h> - -#include <vm/vm.h> - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -char *card_type[] = {"Unknown", - "BICC Isolan", - "NE2100"}; - -char *ic_type[] = {"Unknown", - "Am7990 LANCE", - "Am79960 PCnet_ISA"}; - - -struct is_softc { - struct arpcom arpcom; /* Ethernet common part */ - int iobase; - int rap; - int rdp; - int ic_type; /* Am 7990 or Am79960 */ - int card_type; - int is_debug; - struct init_block *init_block; /* Lance initialisation block */ - struct mds *rd; - struct mds *td; - unsigned char *rbuf; - unsigned char *tbuf; - int last_rd; - int last_td; - int no_td; - caddr_t bpf; /* BPF "magic cookie" */ - -} is_softc[NIS] ; - - -/* Function prototypes */ -static int is_probe(struct isa_device *); -static int is_attach(struct isa_device *); -static void is_watchdog(int); -static int is_ioctl(struct ifnet *, int, caddr_t); -static void is_init(int); -static void is_start(struct ifnet *); -static void istint(int); -#ifdef ISDEBUG -static void recv_print(int, int); -static void xmit_print(int, int); -#endif ISDEBUG -static int ne2100_probe(int); -static int bicc_probe(int); -static int lance_probe(int); - - - -static inline void is_rint(int unit); -static inline void isread(struct is_softc*, unsigned char*, int); - -struct mbuf *isget(); - -struct isa_driver isdriver = { - is_probe, - is_attach, - "is" -}; - -void -iswrcsr(unit,port,val) - int unit; - u_short port; - u_short val; -{ - outw(is_softc[unit].rap,port); - outw(is_softc[unit].rdp,val); -} - -u_short isrdcsr(unit,port) - int unit; - u_short port; -{ - outw(is_softc[unit].rap,port); - return(inw(is_softc[unit].rdp)); -} - -static struct kern_devconf kdc_is[NIS] = { { - 0, 0, 0, /* filled in by dev_attach */ - "is", 0, { MDDT_ISA, 0, "net" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_BUSY, /* network interfaces are always busy */ - "Isolan AT 4141-0, Isolink 4110, or NE2100 Ethernet adapter" -} }; - -static inline void -is_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_is[id->id_unit] = kdc_is[0]; - kdc_is[id->id_unit].kdc_unit = id->id_unit; - kdc_is[id->id_unit].kdc_isa = id; - dev_attach(&kdc_is[id->id_unit]); -} - -int -is_probe(isa_dev) - struct isa_device *isa_dev; -{ - int unit = isa_dev->id_unit ; - int nports; - - is_softc[unit].iobase = isa_dev->id_iobase; - - /* - * It's impossible to do a non-invasive probe of the - * LANCE and PCnet_ISA. The LANCE requires setting the - * STOP bit to access the registers and the PCnet_ISA - * address port resets to an unknown state!! - */ - - /* - * Check for BICC cards first since for the NE2100 and - * PCnet-ISA cards this write will hit the Address PROM. - */ - -#ifdef DEBUG - printf("Dumping io space for is%d starting at %x\n",unit,is_softc[unit].iobase); - for (i=0; i< 32; i++) - printf(" %x ",inb(is_softc[unit].iobase+i)); - printf("\n"); -#endif /* DEBUG*/ - - nports = bicc_probe(unit); - if (nports) - return (nports); - nports = ne2100_probe(unit); - if (nports) - return (nports); - - - return (0); -} - -int -ne2100_probe(unit) - int unit; -{ -struct is_softc *is = &is_softc[unit]; -int i; - - is->rap = is->iobase + NE2100_RAP; - is->rdp = is->iobase + NE2100_RDP; - - is->ic_type = lance_probe(unit); - if (is->ic_type) { - is->card_type = NE2100; - /* - * Extract the physical MAC address from ROM - */ - for(i=0;i<ETHER_ADDR_LEN;i++) - is->arpcom.ac_enaddr[i]=inb(is->iobase+i); - - /* - * Return number of I/O ports used by card - */ - return (24); - } - return (0); -} - - -int -bicc_probe(unit) - int unit; -{ -struct is_softc *is = &is_softc[unit]; -int i; - - is->rap = is->iobase + BICC_RAP; - is->rdp = is->iobase + BICC_RDP; - - is->ic_type = lance_probe(unit); - if (is->ic_type) { - is->card_type = BICC; - - /* - * Extract the physical ethernet address from ROM - */ - - for(i=0;i<ETHER_ADDR_LEN;i++) - is->arpcom.ac_enaddr[i]=inb(is->iobase+(i*2)); - - /* - * Return number of I/O ports used by card - */ - return (16); - } - return (0); -} - - -/* - * Determine which, if any, of the LANCE or - * PCnet-ISA are present on the card. - */ - -int -lance_probe(unit) - int unit; -{ -int type=0; - - /* - * Have to reset the LANCE to get any - * stable information from it. - */ - - iswrcsr(unit,0,STOP); - DELAY(100); - - if (isrdcsr(unit,0) != STOP) - /* - * This either isn't a LANCE - * or there's a major problem. - */ - return(0); - - /* - * Depending on which controller it is, CSR3 will have - * different settable bits. Write to them all and see which ones - * get set. - */ - - iswrcsr(unit,3, LANCE_MASK); - - if (isrdcsr(unit,3) == LANCE_MASK) - type = LANCE; - - if (isrdcsr(unit,3) == PCnet_ISA_MASK) - type = PCnet_ISA; - - return (type); -} - -/* - * Reset of interface. - */ -static void -is_reset(int unit) -{ - if (unit >= NIS) - return; - printf("is%d: reset\n", unit); - is_init(unit); -} - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. We get the ethernet address here. - */ -int -is_attach(isa_dev) - struct isa_device *isa_dev; -{ - int unit = isa_dev->id_unit; - struct is_softc *is = &is_softc[unit]; - struct ifnet *ifp = &is->arpcom.ac_if; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - - ifp->if_unit = unit; - ifp->if_name = isdriver.name ; - ifp->if_mtu = ETHERMTU; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - ifp->if_init = is_init; - ifp->if_output = ether_output; - ifp->if_start = is_start; - ifp->if_ioctl = is_ioctl; - ifp->if_reset = is_reset; - ifp->if_watchdog = is_watchdog; - - /* - * XXX -- not sure this is right place to do this - * Allocate memory for use by Lance - * Memory allocated for: - * initialisation block, - * ring descriptors, - * transmit and receive buffers. - */ - - /* - * XXX - hopefully have better way to get dma'able memory later, - * this code assumes that the physical memory address returned - * from malloc will be below 16Mb. The Lance's address registers - * are only 16 bits wide! - */ - -#define ISMAXMEM ((NRBUF+NTBUF)*(BUFSIZE) + (NRBUF+NTBUF)*sizeof(struct mds) \ - + sizeof(struct init_block) + 8) - is->init_block = (struct init_block *)malloc(ISMAXMEM,M_TEMP,M_NOWAIT); - if (!is->init_block) { - printf("is%d : Couldn't allocate memory for card\n",unit); - } - /* - * XXX -- should take corrective action if not - * quadword alilgned, the 8 byte slew factor in ISMAXMEM - * allows for this. - */ - - if ((u_long)is->init_block & 0x3) - printf("is%d: memory allocated not quadword aligned\n", - isa_dev->id_unit); - - /* Set up DMA */ - isa_dmacascade(isa_dev->id_drq); - - if_attach(ifp); - is_registerdev(isa_dev); - - /* - * Search down the ifa address list looking - * for the AF_LINK type entry - */ - - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - - /* - * If we find an AF_LINK type entry, we will fill - * in the hardware address for this interface. - */ - - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - - /* - * Fill in the link level address for this interface - */ - - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(is->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } - - printf ("is%d: address %s\n", unit, - ether_sprintf(is->arpcom.ac_enaddr)) ; - printf("%s, %s\n",ic_type[is->ic_type],card_type[is->card_type]); - -#if NBPFILTER > 0 - bpfattach(&is->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - return 1; -} - -static void -is_watchdog(unit) - int unit; -{ - log(LOG_ERR, "is%d: device timeout\n", unit); - is_reset(unit); -} - - -/* Lance initialisation block set up */ -void -init_mem(unit) - int unit; -{ - int i; - void *temp; - struct is_softc *is = &is_softc[unit]; - - /* - * At this point we assume that the - * memory allocated to the Lance is - * quadword aligned. If it isn't - * then the initialisation is going - * fail later on. - */ - - - /* - * Set up lance initialisation block - */ - - temp = (void *)is->init_block; - temp += sizeof(struct init_block); - is->rd = (struct mds *) temp; - is->td = (struct mds *) (temp + (NRBUF*sizeof(struct mds))); - temp += (NRBUF+NTBUF) * sizeof(struct mds); - - is->init_block->mode = 0; - for (i=0; i<ETHER_ADDR_LEN; i++) - is->init_block->padr[i] = is->arpcom.ac_enaddr[i]; - for (i = 0; i < 8; ++i) - is->init_block->ladrf[i] = MULTI_INIT_ADDR; - is->init_block->rdra = kvtop(is->rd); - is->init_block->rlen = ((kvtop(is->rd) >> 16) & 0xff) | (RLEN<<13); - is->init_block->tdra = kvtop(is->td); - is->init_block->tlen = ((kvtop(is->td) >> 16) & 0xff) | (TLEN<<13); - - - /* - * Set up receive ring descriptors - */ - - is->rbuf = (unsigned char *)temp; - for (i=0; i<NRBUF; i++) { - (is->rd+i)->addr = kvtop(temp); - (is->rd+i)->flags= ((kvtop(temp) >> 16) & 0xff) | OWN; - (is->rd+i)->bcnt = -BUFSIZE; - (is->rd+i)->mcnt = 0; - temp += BUFSIZE; - } - - /* - * Set up transmit ring descriptors - */ - - is->tbuf = (unsigned char *)temp; - for (i=0; i<NTBUF; i++) { - (is->td+i)->addr = kvtop(temp); - (is->td+i)->flags= ((kvtop(temp) >> 16) & 0xff); - (is->td+i)->bcnt = 0; - (is->td+i)->mcnt = 0; - temp += BUFSIZE; - } - -} - -/* - * Initialization of interface; set up initialization block - * and transmit/receive descriptor rings. - */ - -static void -is_init(unit) - int unit; -{ - register struct is_softc *is = &is_softc[unit]; - struct ifnet *ifp = &is->arpcom.ac_if; - int s; - register i; - - /* Address not known */ - if (ifp->if_addrlist == (struct ifaddr *)0) return; - - s = splimp(); - - /* - * Lance must be stopped - * to access registers. - */ - - iswrcsr(unit,0,STOP); - - is->last_rd = is->last_td = is->no_td = 0; - - /* Set up lance's memory area */ - init_mem(unit); - - /* No byte swapping etc */ - iswrcsr(unit,3,0); - - /* Give lance the physical address of its memory area */ - iswrcsr(unit,1,kvtop(is->init_block)); - iswrcsr(unit,2,(kvtop(is->init_block) >> 16) & 0xff); - - /* OK, let's try and initialise the Lance */ - iswrcsr(unit,0,INIT); - - /* Wait for initialisation to finish */ - for(i=0; i<1000; i++){ - if (isrdcsr(unit,0)&IDON) - break; - } - if (isrdcsr(unit,0)&IDON) { - /* Start lance */ - iswrcsr(unit,0,STRT|IDON|INEA); - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - is_start(ifp); - } - else - printf("is%d: card failed to initialise\n", unit); - - (void) splx(s); -} - -/* - * Setup output on interface. - * Get another datagram to send off of the interface queue, - * and map it to the interface before starting the output. - * called only at splimp or interrupt level. - */ -static void -is_start(ifp) - struct ifnet *ifp; -{ - int unit = ifp->if_unit; - register struct is_softc *is = &is_softc[unit]; - struct mbuf *m0, *m; - unsigned char *buffer; - u_short len; - struct mds *cdm; - - - if ((is->arpcom.ac_if.if_flags & IFF_RUNNING) == 0) - return; - - do { - cdm = (is->td + is->last_td); - if (cdm->flags&OWN) - return; - - IF_DEQUEUE(&is->arpcom.ac_if.if_snd, m); - - if (m == 0) - return; - - /* - * Copy the mbuf chain into the transmit buffer - */ - - buffer = is->tbuf+(BUFSIZE*is->last_td); - len=0; - for (m0=m; m != 0; m=m->m_next) { - bcopy(mtod(m,caddr_t),buffer,m->m_len); - buffer += m->m_len; - len += m->m_len; - } -#if NBPFILTER > 0 - if (is->bpf) { - bpf_mtap(is->bpf, m0); - } -#endif - - - m_freem(m0); - len = max(len,ETHER_MIN_LEN); - - /* - * Init transmit registers, and set transmit start flag. - */ - - cdm->flags |= (OWN|STP|ENP); - cdm->bcnt = -len; - cdm->mcnt = 0; -#ifdef ISDEBUG - if (is->is_debug) - xmit_print(unit,is->last_td); -#endif - - iswrcsr(unit,0,TDMD|INEA); - if (++is->last_td >= NTBUF) - is->last_td=0; - }while(++is->no_td < NTBUF); - is->no_td = NTBUF; - is->arpcom.ac_if.if_flags |= IFF_OACTIVE; -#ifdef ISDEBUG - if (is->is_debug) - printf("no_td = %x, last_td = %x\n",is->no_td, is->last_td); -#endif -} - - -/* - * Controller interrupt. - */ -void -isintr(unit) - int unit; -{ - register struct is_softc *is = &is_softc[unit]; - u_short isr; - - while((isr=isrdcsr(unit,0))&INTR) { - if (isr&ERR) { - if (isr&BABL){ - printf("is%d: BABL\n",unit); - is->arpcom.ac_if.if_oerrors++; - } - if (isr&CERR) { - printf("is%d: CERR\n",unit); - is->arpcom.ac_if.if_collisions++; - } - if (isr&MISS) { - printf("is%d: MISS\n",unit); - is->arpcom.ac_if.if_ierrors++; - } - if (isr&MERR) - printf("is%d: MERR\n",unit); - iswrcsr(unit,0,BABL|CERR|MISS|MERR|INEA); - } - if (!(isr&RXON)) { - printf("is%d: !(isr&RXON)\n", unit); - is->arpcom.ac_if.if_ierrors++; - is_reset(unit); - return; - } - if (!(isr&TXON)) { - printf("is%d: !(isr&TXON)\n", unit); - is->arpcom.ac_if.if_oerrors++; - is_reset(unit); - return; - } - - if (isr&RINT) { - /* reset watchdog timer */ - is->arpcom.ac_if.if_timer = 0; - is_rint(unit); - } - if (isr&TINT) { - /* reset watchdog timer */ - is->arpcom.ac_if.if_timer = 0; - iswrcsr(unit,0,TINT|INEA); - istint(unit); - } - } -} - -static void -istint(unit) - int unit; -{ - struct is_softc *is = &is_softc[unit]; - register struct ifnet *ifp = &is->arpcom.ac_if; - int i,loopcount=0; - struct mds *cdm; - - is->arpcom.ac_if.if_opackets++; - do { - if ((i=is->last_td - is->no_td) < 0) - i+=NTBUF; - cdm = (is->td+i); -#ifdef ISDEBUG - if (is->is_debug) - printf("Trans cdm = %x\n",cdm); -#endif - if (cdm->flags&OWN) { - if (loopcount) - break; - return; - } - loopcount++; - is->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - }while(--is->no_td > 0); - is_start(ifp); - -} - -#define NEXTRDS \ - if (++rmd == NRBUF) rmd=0, cdm=is->rd; else ++cdm - -/* only called from one place, so may as well integrate */ -static inline void is_rint(int unit) -{ - register struct is_softc *is=&is_softc[unit]; - register int rmd = is->last_rd; - struct mds *cdm = (is->rd + rmd); - - /* Out of sync with hardware, should never happen */ - - if (cdm->flags & OWN) { - printf("is%d: error: out of sync\n",unit); - iswrcsr(unit,0,RINT|INEA); - return; - } - - /* Process all buffers with valid data */ - while (!(cdm->flags&OWN)) { - /* Clear interrupt to avoid race condition */ - iswrcsr(unit,0,RINT|INEA); - if (cdm->flags&ERR) { - if (cdm->flags&FRAM) - printf("is%d: FRAM\n",unit); - if (cdm->flags&OFLO) - printf("is%d: OFLO\n",unit); - if (cdm->flags&CRC) - printf("is%d: CRC\n",unit); - if (cdm->flags&RBUFF) - printf("is%d: RBUFF\n",unit); - }else - if (cdm->flags&(STP|ENP) != (STP|ENP)) { - do { - iswrcsr(unit,0,RINT|INEA); - cdm->mcnt = 0; - cdm->flags |= OWN; - NEXTRDS; - }while (!(cdm->flags&(OWN|ERR|STP|ENP))); - is->last_rd = rmd; - printf("is%d: Chained buffer\n",unit); - if ((cdm->flags & (OWN|ERR|STP|ENP)) != ENP) { - is_reset(unit); - return; - } - }else - { -#ifdef ISDEBUG - if (is->is_debug) - recv_print(unit,is->last_rd); -#endif - isread(is,is->rbuf+(BUFSIZE*rmd),(int)cdm->mcnt); - is->arpcom.ac_if.if_ipackets++; - } - - cdm->flags |= OWN; - cdm->mcnt = 0; - NEXTRDS; -#ifdef ISDEBUG - if (is->is_debug) - printf("is->last_rd = %x, cdm = %x\n",is->last_rd,cdm); -#endif - } /* while */ - is->last_rd = rmd; -} /* is_rint */ - - -/* - * Pass a packet to the higher levels. - * We deal with the trailer protocol here. - */ -static inline void -isread(struct is_softc *is, unsigned char *buf, int len) -{ - register struct ether_header *eh; - struct mbuf *m; - - eh = (struct ether_header *)buf; - len = len - sizeof(struct ether_header) - 4; - - if (len == 0) return; - - /* - * Pull packet off interface. Off is nonzero if packet - * has trailing header; neget will then force this header - * information to be at the front, but we still have to drop - * the type and length which are at the front of any trailer data. - */ - m = isget(buf, len, 0, &is->arpcom.ac_if); - if (m == 0) return; -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to bpf. - */ - if (is->bpf) { - bpf_mtap(is->bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - * - * XXX This test does not support multicasts. - */ - if ((is->arpcom.ac_if.if_flags & IFF_PROMISC) && - bcmp(eh->ether_dhost, is->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - - m_freem(m); - return; - } - } -#endif - - - ether_input(&is->arpcom.ac_if, eh, m); -} - -/* - * Supporting routines - */ - -/* - * Pull read data off a interface. - * Len is length of data, with local net header stripped. - * Off is non-zero if a trailer protocol was used, and - * gives the offset of the trailer information. - * We copy the trailer information and then all the normal - * data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -isget(buf, totlen, off0, ifp) - caddr_t buf; - int totlen, off0; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m; - int off = off0, len; - register caddr_t cp = buf; - char *epkt; - - buf += sizeof(struct ether_header); - cp = buf; - epkt = cp + totlen; - - - if (off) { - cp += off + 2 * sizeof(u_short); - totlen -= 2 * sizeof(u_short); - } - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - m->m_len = MHLEN; - top = 0; - mp = ⊤ - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return (0); - } - m->m_len = MLEN; - } - len = min(totlen, epkt - cp); - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = len = min(len, MCLBYTES); - else - len = m->m_len; - } else { - /* - * Place initial small packet/header at end of mbuf. - */ - if (len < m->m_len) { - if (top == 0 && len + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = len; - } else - len = m->m_len; - } - bcopy(cp, mtod(m, caddr_t), (unsigned)len); - cp += len; - *mp = m; - mp = &m->m_next; - totlen -= len; - if (cp == epkt) - cp = buf; - } - return (top); -} - - -/* - * Process an ioctl request. - */ -int -is_ioctl(ifp, cmd, data) - register struct ifnet *ifp; - int cmd; - caddr_t data; -{ - register struct ifaddr *ifa = (struct ifaddr *)data; - int unit = ifp->if_unit; - register struct is_softc *is=&is_softc[unit]; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - is_init(ifp->if_unit); /* before arpwhohas */ - arp_ifinit((struct arpcom *)ifp, ifa); - break; -#endif -#ifdef NS - /* - * XXX - This code is probably wrong - */ - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(is->arpcom.ac_enaddr); - else { - /* - * - */ - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)is->arpcom.ac_enaddr, - sizeof(is->arpcom.ac_enaddr)); - } - /* - * Set new address - */ - is_init(ifp->if_unit); - break; - } -#endif - default: - is_init(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if ((ifp->if_flags & IFF_UP) == 0 && - ifp->if_flags & IFF_RUNNING) { - iswrcsr(unit,0,STOP); - ifp->if_flags &= ~IFF_RUNNING; - } else { - /* - * If interface is marked up and it is stopped, then start it - */ - if ((ifp->if_flags & IFF_UP) && - (ifp->if_flags & IFF_RUNNING) == 0) - is_init(ifp->if_unit); - } -#ifdef ISDEBUG - if (ifp->if_flags & IFF_DEBUG) - is->is_debug = 1; - else - is->is_debug = 0; -#endif -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) { - /* - * Set promiscuous mode on interface. - * XXX - for multicasts to work, we would need to - * write 1's in all bits of multicast - * hashing array. For now we assume that - * this was done in is_init(). - */ - is->init_block->mode = PROM; - } else - /* - * XXX - for multicasts to work, we would need to - * rewrite the multicast hashing array with the - * proper hash (would have been destroyed above). - */ - { /* Don't know about this */}; -#endif - break; - -#ifdef notdef - case SIOCGHWADDR: - bcopy((caddr_t)is->arpcom.ac_enaddr, (caddr_t) &ifr->ifr_data, - sizeof(is->arpcom.ac_enaddr)); - break; -#endif - - case SIOCSIFMTU: - - /* - * Set the interface MTU. - */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; - - default: - error = EINVAL; - } - (void) splx(s); - return (error); -} - -#ifdef ISDEBUG -staic void -recv_print(unit,no) - int unit,no; -{ - register struct is_softc *is=&is_softc[unit]; - struct mds *rmd; - int len,i,printed=0; - - rmd = (is->rd+no); - len = rmd->mcnt; - printf("is%d: Receive buffer %d, len = %d\n",unit,no,len); - printf("is%d: Status %x\n",unit,isrdcsr(unit,0)); - for (i=0; i<len; i++) { - if (!printed) { - printed=1; - printf("is%d: data: ", unit); - } - printf("%x ",*(is->rbuf+(BUFSIZE*no)+i)); - } - if (printed) - printf("\n"); -} - -static void -xmit_print(unit,no) - int unit,no; -{ - register struct is_softc *is=&is_softc[unit]; - struct mds *rmd; - int i, printed=0; - u_short len; - - rmd = (is->td+no); - len = -(rmd->bcnt); - printf("is%d: Transmit buffer %d, len = %d\n",unit,no,len); - printf("is%d: Status %x\n",unit,isrdcsr(unit,0)); - printf("is%d: addr %x, flags %x, bcnt %x, mcnt %x\n", - unit,rmd->addr,rmd->flags,rmd->bcnt,rmd->mcnt); - for (i=0; i<len; i++) { - if (!printed) { - printed = 1; - printf("is%d: data: ", unit); - } - printf("%x ",*(is->tbuf+(BUFSIZE*no)+i)); - } - if (printed) - printf("\n"); -} -#endif /* ISDEBUG */ - -#endif /* NIS > 0 */ diff --git a/sys/i386/isa/if_isreg.h b/sys/i386/isa/if_isreg.h deleted file mode 100644 index b4b4ece..0000000 --- a/sys/i386/isa/if_isreg.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Isolan AT 4141-0 Ethernet driver header file - * Isolink 4110 - * - * By Paul Richards - * - * Copyright (C) 1993, Paul Richards. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - * - * $Id: if_isreg.h,v 1.3 1993/10/24 04:27:00 paul Exp $ - */ - -/* - * Initialize multicast address hashing registers to accept - * all multicasts (only used when in promiscuous mode) - */ -#if NBPFILTER > 0 -#define MULTI_INIT_ADDR 0xff -#else -#define MULTI_INIT_ADDR 0 -#endif - -/* Declarations specific to this driver */ -#define NTBUF 2 -#define TLEN 1 -#define NRBUF 8 -#define RLEN 3 -#define BUFSIZE 1518 -#define BICC_RDP 0xc -#define BICC_RAP 0xe -#define NE2100_RDP 0x10 -#define NE2100_RAP 0x12 - -/* Board types */ -#define BICC 1 -#define NE2100 2 - -/* Am7990 or Am79960 */ -#define LANCE 1 -#define LANCE_MASK 0x07 -#define PCnet_ISA 2 -#define PCnet_ISA_MASK 0x0 - - -/* Control and status register 0 flags */ - -#define ERR 0x8000 -#define BABL 0x4000 -#define CERR 0x2000 -#define MISS 0x1000 -#define MERR 0x0800 -#define RINT 0x0400 -#define TINT 0x0200 -#define IDON 0x0100 -#define INTR 0x0080 -#define INEA 0x0040 -#define RXON 0x0020 -#define TXON 0x0010 -#define TDMD 0x0008 -#define STOP 0x0004 -#define STRT 0x0002 -#define INIT 0x0001 - -/* Coontrol and status register 3 flags */ - -#define BSWP 0x0004 -#define ACON 0x0002 -#define BCON 0x0001 - -/* Initialisation block (must be on word boundary) */ - -struct init_block { - u_short mode; /* Mode register */ - u_char padr[6]; /* Ethernet address */ - u_char ladrf[8]; /* Logical address filter (multicast) */ - u_short rdra; /* Low order pointer to receive ring */ - u_short rlen; /* High order pointer and no. rings */ - u_short tdra; /* Low order pointer to transmit ring */ - u_short tlen; /* High order pointer and no rings */ - }; - -/* Mode settings */ - -#define PROM 0x8000 /* Promiscuous */ -#define INTL 0x0040 /* Internal loopback */ -#define DRTY 0x0020 /* Disable retry */ -#define COLL 0x0010 /* Force collision */ -#define DTCR 0x0008 /* Disable transmit crc */ -#define LOOP 0x0004 /* Loop back */ -#define DTX 0x0002 /* Disable transmitter */ -#define DRX 0x0001 /* Disable receiver */ - -/* Message descriptor structure */ - -struct mds { - u_short addr; - u_short flags; - u_short bcnt; - u_short mcnt; - }; - -/* Receive ring status flags */ - -#define OWN 0x8000 /* Owner bit, 0=host, 1=Lance */ -#define MDERR 0x4000 /* Error */ -#define FRAM 0x2000 /* Framing error error */ -#define OFLO 0x1000 /* Silo overflow */ -#define CRC 0x0800 /* CRC error */ -#define RBUFF 0x0400 /* Buffer error */ -#define STP 0x0200 /* Start of packet */ -#define ENP 0x0100 /* End of packet */ - -/* Transmit ring flags */ - -#define MORE 0x1000 /* More than 1 retry */ -#define ONE 0x0800 /* One retry */ -#define DEF 0x0400 /* Deferred transmit */ - -/* Transmit errors */ - -#define TBUFF 0x8000 /* Buffer error */ -#define UFLO 0x4000 /* Silo underflow */ -#define LCOL 0x1000 /* Late collision */ -#define LCAR 0x0800 /* Loss of carrier */ -#define RTRY 0x0400 /* Tried 16 times */ diff --git a/sys/i386/isa/if_zereg.h b/sys/i386/isa/if_zereg.h deleted file mode 100644 index 7eefd61..0000000 --- a/sys/i386/isa/if_zereg.h +++ /dev/null @@ -1,859 +0,0 @@ -/* - * National Semiconductor DS8390 NIC register definitions - * - * if_edreg.h,v - * Revision 1.1.2.1 1993/07/21 13:50:04 cgd - * from davidg: - * Added config file override for memory size and added flags to force - * 8bit or 16bit operation, and a flag to disable transmitter double buffering. - * See the updated "ed.relnotes" file for information about how to set - * the flags. - * This should be considered the first "production" release. It still - * needs a manual page, though. - * - * Revision 1.1 1993/07/03 12:21:07 cgd - * add support for David Greenman "ed" driver - * - * Revision 1.2 93/06/23 03:03:05 davidg - * added some additional definitions for the 83C584 bus interface - * chip (SMC/WD boards) - * - * Revision 1.1 93/06/23 03:01:07 davidg - * Initial revision - * - */ - -/* - * Page 0 register offsets - */ -#define ZE_P0_CR 0x00 /* Command Register */ - -#define ZE_P0_CLDA0 0x01 /* Current Local DMA Addr low (read) */ -#define ZE_P0_PSTART 0x01 /* Page Start register (write) */ - -#define ZE_P0_CLDA1 0x02 /* Current Local DMA Addr high (read) */ -#define ZE_P0_PSTOP 0x02 /* Page Stop register (write) */ - -#define ZE_P0_BNRY 0x03 /* Boundary Pointer */ - -#define ZE_P0_TSR 0x04 /* Transmit Status Register (read) */ -#define ZE_P0_TPSR 0x04 /* Transmit Page Start (write) */ - -#define ZE_P0_NCR 0x05 /* Number of Collisions Reg (read) */ -#define ZE_P0_TBCR0 0x05 /* Transmit Byte count, low (write) */ - -#define ZE_P0_FIFO 0x06 /* FIFO register (read) */ -#define ZE_P0_TBCR1 0x06 /* Transmit Byte count, high (write) */ - -#define ZE_P0_ISR 0x07 /* Interrupt Status Register */ - -#define ZE_P0_CRDA0 0x08 /* Current Remote DMA Addr low (read) */ -#define ZE_P0_RSAR0 0x08 /* Remote Start Address low (write) */ - -#define ZE_P0_CRDA1 0x09 /* Current Remote DMA Addr high (read) */ -#define ZE_P0_RSAR1 0x09 /* Remote Start Address high (write) */ - -#define ZE_P0_RBCR0 0x0a /* Remote Byte Count low (write) */ - -#define ZE_P0_RBCR1 0x0b /* Remote Byte Count high (write) */ - -#define ZE_P0_RSR 0x0c /* Receive Status (read) */ -#define ZE_P0_RCR 0x0c /* Receive Configuration Reg (write) */ - -#define ZE_P0_CNTR0 0x0d /* frame alignment error counter (read) */ -#define ZE_P0_TCR 0x0d /* Transmit Configuration Reg (write) */ - -#define ZE_P0_CNTR1 0x0e /* CRC error counter (read) */ -#define ZE_P0_DCR 0x0e /* Data Configuration Reg (write) */ - -#define ZE_P0_CNTR2 0x0f /* missed packet counter (read) */ -#define ZE_P0_IMR 0x0f /* Interrupt Mask Register (write) */ - -/* - * Page 1 register offsets - */ -#define ZE_P1_CR 0x00 /* Command Register */ -#define ZE_P1_PAR0 0x01 /* Physical Address Register 0 */ -#define ZE_P1_PAR1 0x02 /* Physical Address Register 1 */ -#define ZE_P1_PAR2 0x03 /* Physical Address Register 2 */ -#define ZE_P1_PAR3 0x04 /* Physical Address Register 3 */ -#define ZE_P1_PAR4 0x05 /* Physical Address Register 4 */ -#define ZE_P1_PAR5 0x06 /* Physical Address Register 5 */ -#define ZE_P1_CURR 0x07 /* Current RX ring-buffer page */ -#define ZE_P1_MAR0 0x08 /* Multicast Address Register 0 */ -#define ZE_P1_MAR1 0x09 /* Multicast Address Register 1 */ -#define ZE_P1_MAR2 0x0a /* Multicast Address Register 2 */ -#define ZE_P1_MAR3 0x0b /* Multicast Address Register 3 */ -#define ZE_P1_MAR4 0x0c /* Multicast Address Register 4 */ -#define ZE_P1_MAR5 0x0d /* Multicast Address Register 5 */ -#define ZE_P1_MAR6 0x0e /* Multicast Address Register 6 */ -#define ZE_P1_MAR7 0x0f /* Multicast Address Register 7 */ - -/* - * Page 2 register offsets - */ -#define ZE_P2_CR 0x00 /* Command Register */ -#define ZE_P2_PSTART 0x01 /* Page Start (read) */ -#define ZE_P2_CLDA0 0x01 /* Current Local DMA Addr 0 (write) */ -#define ZE_P2_PSTOP 0x02 /* Page Stop (read) */ -#define ZE_P2_CLDA1 0x02 /* Current Local DMA Addr 1 (write) */ -#define ZE_P2_RNPP 0x03 /* Remote Next Packet Pointer */ -#define ZE_P2_TPSR 0x04 /* Transmit Page Start (read) */ -#define ZE_P2_LNPP 0x05 /* Local Next Packet Pointer */ -#define ZE_P2_ACU 0x06 /* Address Counter Upper */ -#define ZE_P2_ACL 0x07 /* Address Counter Lower */ -#define ZE_P2_RCR 0x0c /* Receive Configuration Register (read) */ -#define ZE_P2_TCR 0x0d /* Transmit Configuration Register (read) */ -#define ZE_P2_DCR 0x0e /* Data Configuration Register (read) */ -#define ZE_P2_IMR 0x0f /* Interrupt Mask Register (read) */ - -/* - * Command Register (CR) definitions - */ - -/* - * STP: SToP. Software reset command. Takes the controller offline. No - * packets will be received or transmitted. Any reception or - * transmission in progress will continue to completion before - * entering reset state. To exit this state, the STP bit must - * reset and the STA bit must be set. The software reset has - * executed only when indicated by the RST bit in the ISR being - * set. - */ -#define ZE_CR_STP 0x01 - -/* - * STA: STArt. This bit is used to activate the NIC after either power-up, - * or when the NIC has been put in reset mode by software command - * or error. - */ -#define ZE_CR_STA 0x02 - -/* - * TXP: Transmit Packet. This bit must be set to indicate transmission of - * a packet. TXP is internally reset either after the transmission is - * completed or aborted. This bit should be set only after the Transmit - * Byte Count and Transmit Page Start register have been programmed. - */ -#define ZE_CR_TXP 0x04 - -/* - * RD0, RD1, RD2: Remote DMA Command. These three bits control the operation - * of the remote DMA channel. RD2 can be set to abort any remote DMA - * command in progress. The Remote Byte Count registers should be cleared - * when a remote DMA has been aborted. The Remote Start Addresses are not - * restored to the starting address if the remote DMA is aborted. - * - * RD2 RD1 RD0 function - * 0 0 0 not allowed - * 0 0 1 remote read - * 0 1 0 remote write - * 0 1 1 send packet - * 1 X X abort - */ -#define ZE_CR_RD0 0x08 -#define ZE_CR_RD1 0x10 -#define ZE_CR_RD2 0x20 - -/* - * PS0, PS1: Page Select. The two bits select which register set or 'page' to - * access. - * - * PS1 PS0 page - * 0 0 0 - * 0 1 1 - * 1 0 2 - * 1 1 reserved - */ -#define ZE_CR_PS0 0x40 -#define ZE_CR_PS1 0x80 -/* bit encoded aliases */ -#define ZE_CR_PAGE_0 0x00 /* (for consistency) */ -#define ZE_CR_PAGE_1 0x40 -#define ZE_CR_PAGE_2 0x80 - -/* - * Interrupt Status Register (ISR) definitions - */ - -/* - * PRX: Packet Received. Indicates packet received with no errors. - */ -#define ZE_ISR_PRX 0x01 - -/* - * PTX: Packet Transmitted. Indicates packet transmitted with no errors. - */ -#define ZE_ISR_PTX 0x02 - -/* - * RXE: Receive Error. Indicates that a packet was received with one or more - * the following errors: CRC error, frame alignment error, FIFO overrun, - * missed packet. - */ -#define ZE_ISR_RXE 0x04 - -/* - * TXE: Transmission Error. Indicates that an attempt to transmit a packet - * resulted in one or more of the following errors: excessive - * collisions, FIFO underrun. - */ -#define ZE_ISR_TXE 0x08 - -/* - * OVW: OverWrite. Indicates a receive ring-buffer overrun. Incoming network - * would exceed (has exceeded?) the boundry pointer, resulting in data - * that was previously received and not yet read from the buffer to be - * overwritten. - */ -#define ZE_ISR_OVW 0x10 - -/* - * CNT: Counter Overflow. Set when the MSB of one or more of the Network Talley - * Counters has been set. - */ -#define ZE_ISR_CNT 0x20 - -/* - * RDC: Remote Data Complete. Indicates that a Remote DMA operation has completed. - */ -#define ZE_ISR_RDC 0x40 - -/* - * RST: Reset status. Set when the NIC enters the reset state and cleared when a - * Start Command is issued to the CR. This bit is also set when a receive - * ring-buffer overrun (OverWrite) occurs and is cleared when one or more - * packets have been removed from the ring. This is a read-only bit. - */ -#define ZE_ISR_RST 0x80 - -/* - * Interrupt Mask Register (IMR) definitions - */ - -/* - * PRXE: Packet Received interrupt Enable. If set, a received packet will cause - * an interrupt. - */ -#define ZE_IMR_PRXE 0x01 - -/* - * PTXE: Packet Transmit interrupt Enable. If set, an interrupt is generated when - * a packet transmission completes. - */ -#define ZE_IMR_PTXE 0x02 - -/* - * RXEE: Receive Error interrupt Enable. If set, an interrupt will occur whenever a - * packet is received with an error. - */ -#define ZE_IMR_RXEE 0x04 - -/* - * TXEE: Transmit Error interrupt Enable. If set, an interrupt will occur whenever - * a transmission results in an error. - */ -#define ZE_IMR_TXEE 0x08 - -/* - * OVWE: OverWrite error interrupt Enable. If set, an interrupt is generated whenever - * the receive ring-buffer is overrun. i.e. when the boundry pointer is exceeded. - */ -#define ZE_IMR_OVWE 0x10 - -/* - * CNTE: Counter overflow interrupt Enable. If set, an interrupt is generated whenever - * the MSB of one or more of the Network Statistics counters has been set. - */ -#define ZE_IMR_CNTE 0x20 - -/* - * RDCE: Remote DMA Complete interrupt Enable. If set, an interrupt is generated - * when a remote DMA transfer has completed. - */ -#define ZE_IMR_RDCE 0x40 - -/* - * bit 7 is unused/reserved - */ - -/* - * Data Configuration Register (DCR) definitions - */ - -/* - * WTS: Word Transfer Select. WTS establishes byte or word transfers for - * both remote and local DMA transfers - */ -#define ZE_DCR_WTS 0x01 - -/* - * BOS: Byte Order Select. BOS sets the byte order for the host. - * Should be 0 for 80x86, and 1 for 68000 series processors - */ -#define ZE_DCR_BOS 0x02 - -/* - * LAS: Long Address Select. When LAS is 1, the contents of the remote - * DMA registers RSAR0 and RSAR1 are used to provide A16-A31 - */ -#define ZE_DCR_LAS 0x04 - -/* - * LS: Loopback Select. When 0, loopback mode is selected. Bits D1 and D2 - * of the TCR must also be programmed for loopback operation. - * When 1, normal operation is selected. - */ -#define ZE_DCR_LS 0x08 - -/* - * AR: Auto-initialize Remote. When 0, data must be removed from ring-buffer - * under program control. When 1, remote DMA is automatically initiated - * and the boundry pointer is automatically updated - */ -#define ZE_DCR_AR 0x10 - -/* - * FT0, FT1: Fifo Threshold select. - * FT1 FT0 Word-width Byte-width - * 0 0 1 word 2 bytes - * 0 1 2 words 4 bytes - * 1 0 4 words 8 bytes - * 1 1 8 words 12 bytes - * - * During transmission, the FIFO threshold indicates the number of bytes - * or words that the FIFO has filled from the local DMA before BREQ is - * asserted. The transmission threshold is 16 bytes minus the receiver - * threshold. - */ -#define ZE_DCR_FT0 0x20 -#define ZE_DCR_FT1 0x40 - -/* - * bit 7 (0x80) is unused/reserved - */ - -/* - * Transmit Configuration Register (TCR) definitions - */ - -/* - * CRC: Inhibit CRC. If 0, CRC will be appended by the transmitter, if 0, CRC - * is not appended by the transmitter. - */ -#define ZE_TCR_CRC 0x01 - -/* - * LB0, LB1: Loopback control. These two bits set the type of loopback that is - * to be performed. - * - * LB1 LB0 mode - * 0 0 0 - normal operation (DCR_LS = 0) - * 0 1 1 - internal loopback (DCR_LS = 0) - * 1 0 2 - external loopback (DCR_LS = 1) - * 1 1 3 - external loopback (DCR_LS = 0) - */ -#define ZE_TCR_LB0 0x02 -#define ZE_TCR_LB1 0x04 - -/* - * ATD: Auto Transmit Disable. Clear for normal operation. When set, allows - * another station to disable the NIC's transmitter by transmitting to - * a multicast address hashing to bit 62. Reception of a multicast address - * hashing to bit 63 enables the transmitter. - */ -#define ZE_TCR_ATD 0x08 - -/* - * OFST: Collision Offset enable. This bit when set modifies the backoff - * algorithm to allow prioritization of nodes. - */ -#define ZE_TCR_OFST 0x10 - -/* - * bits 5, 6, and 7 are unused/reserved - */ - -/* - * Transmit Status Register (TSR) definitions - */ - -/* - * PTX: Packet Transmitted. Indicates successful transmission of packet. - */ -#define ZE_TSR_PTX 0x01 - -/* - * bit 1 (0x02) is unused/reserved - */ - -/* - * COL: Transmit Collided. Indicates that the transmission collided at least - * once with another station on the network. - */ -#define ZE_TSR_COL 0x04 - -/* - * ABT: Transmit aborted. Indicates that the transmission was aborted due to - * excessive collisions. - */ -#define ZE_TSR_ABT 0x08 - -/* - * CRS: Carrier Sense Lost. Indicates that carrier was lost during the - * transmission of the packet. (Transmission is not aborted because - * of a loss of carrier) - */ -#define ZE_TSR_CRS 0x10 - -/* - * FU: FIFO Underrun. Indicates that the NIC wasn't able to access bus/ - * transmission memory before the FIFO emptied. Transmission of the - * packet was aborted. - */ -#define ZE_TSR_FU 0x20 - -/* - * CDH: CD Heartbeat. Indicates that the collision detection circuitry - * isn't working correctly during a collision heartbeat test. - */ -#define ZE_TSR_CDH 0x40 - -/* - * OWC: Out of Window Collision: Indicates that a collision occurred after - * a slot time (51.2us). The transmission is rescheduled just as in - * normal collisions. - */ -#define ZE_TSR_OWC 0x80 - -/* - * Receiver Configuration Register (RCR) definitions - */ - -/* - * SEP: Save Errored Packets. If 0, error packets are discarded. If set to 1, - * packets with CRC and frame errors are not discarded. - */ -#define ZE_RCR_SEP 0x01 - -/* - * AR: Accept Runt packet. If 0, packet with less than 64 byte are discarded. - * If set to 1, packets with less than 64 byte are not discarded. - */ -#define ZE_RCR_AR 0x02 - -/* - * AB: Accept Broadcast. If set, packets sent to the broadcast address will be - * accepted. - */ -#define ZE_RCR_AB 0x04 - -/* - * AM: Accept Multicast. If set, packets sent to a multicast address are checked - * for a match in the hashing array. If clear, multicast packets are ignored. - */ -#define ZE_RCR_AM 0x08 - -/* - * PRO: Promiscuous Physical. If set, all packets with a physical addresses are - * accepted. If clear, a physical destination address must match this - * station's address. Note: for full promiscuous mode, RCR_AB and RCR_AM - * must also be set. In addition, the multicast hashing array must be set - * to all 1's so that all multicast addresses are accepted. - */ -#define ZE_RCR_PRO 0x10 - -/* - * MON: Monitor Mode. If set, packets will be checked for good CRC and framing, - * but are not stored in the ring-buffer. If clear, packets are stored (normal - * operation). - */ -#define ZE_RCR_MON 0x20 - -/* - * bits 6 and 7 are unused/reserved. - */ - -/* - * Receiver Status Register (RSR) definitions - */ - -/* - * PRX: Packet Received without error. - */ -#define ZE_RSR_PRX 0x01 - -/* - * CRC: CRC error. Indicates that a packet has a CRC error. Also set for frame - * alignment errors. - */ -#define ZE_RSR_CRC 0x02 - -/* - * FAE: Frame Alignment Error. Indicates that the incoming packet did not end on - * a byte boundry and the CRC did not match at the last byte boundry. - */ -#define ZE_RSR_FAE 0x04 - -/* - * FO: FIFO Overrun. Indicates that the FIFO was not serviced (during local DMA) - * causing it to overrun. Reception of the packet is aborted. - */ -#define ZE_RSR_FO 0x08 - -/* - * MPA: Missed Packet. Indicates that the received packet couldn't be stored in - * the ring-buffer because of insufficient buffer space (exceeding the - * boundry pointer), or because the transfer to the ring-buffer was inhibited - * by RCR_MON - monitor mode. - */ -#define ZE_RSR_MPA 0x10 - -/* - * PHY: Physical address. If 0, the packet received was sent to a physical address. - * If 1, the packet was accepted because of a multicast/broadcast address - * match. - */ -#define ZE_RSR_PHY 0x20 - -/* - * DIS: Receiver Disabled. Set to indicate that the receiver has enetered monitor - * mode. Cleared when the receiver exits monitor mode. - */ -#define ZE_RSR_DIS 0x40 - -/* - * DFR: Deferring. Set to indicate a 'jabber' condition. The CRS and COL inputs - * are active, and the transceiver has set the CD line as a result of the - * jabber. - */ -#define ZE_RSR_DFR 0x80 - -/* - * receive ring discriptor - * - * The National Semiconductor DS8390 Network interface controller uses - * the following receive ring headers. The way this works is that the - * memory on the interface card is chopped up into 256 bytes blocks. - * A contiguous portion of those blocks are marked for receive packets - * by setting start and end block #'s in the NIC. For each packet that - * is put into the receive ring, one of these headers (4 bytes each) is - * tacked onto the front. - */ -struct ze_ring { - struct edr_status { /* received packet status */ - u_char rs_prx:1, /* packet received intack */ - rs_crc:1, /* crc error */ - rs_fae:1, /* frame alignment error */ - rs_fo:1, /* fifo overrun */ - rs_mpa:1, /* packet received intack */ - rs_phy:1, /* packet received intack */ - rs_dis:1, /* packet received intack */ - rs_dfr:1; /* packet received intack */ - } ze_rcv_status; /* received packet status */ - u_char next_packet; /* pointer to next packet */ - u_short count; /* bytes in packet (length + 4) */ -}; - -/* - * Common constants - */ -#define ZE_PAGE_SIZE 256 /* Size of RAM pages in bytes */ -#define ZE_TXBUF_SIZE 6 /* Size of TX buffer in pages */ -#define ZE_PAGE_OFFSET 0x40 /* mem buffer starts at 0x4000 */ - -/* - * Vendor types - */ -#define ZE_VENDOR_WD_SMC 0x00 /* Western Digital/SMC */ -#define ZE_VENDOR_3COM 0x01 /* 3Com */ - -/* - * Compile-time config flags - */ -/* - * this sets the default for enabling/disablng the tranceiver - */ -#define ZE_FLAGS_DISABLE_TRANCEIVER 0x01 - -/* - * This forces the board to be used in 8/16bit mode even if it - * autoconfigs differently - */ -#define ZE_FLAGS_FORCE_8BIT_MODE 0x02 -#define ZE_FLAGS_FORCE_16BIT_MODE 0x04 - -/* - * This disables the use of double transmit buffers. - */ -#define ZE_FLAGS_NO_DOUBLE_BUFFERING 0x08 - -/* - * definitions for IBM credit card adapter for ethernet - */ - -#define ZE_DATA_IO 0x10 -#define ZE_MISC 0x18 -#define ZE_RESET 0x1F - -#if 0 -/* - * Definitions for Western digital/SMC WD80x3 series ASIC - */ -/* - * Memory Select Register (MSR) - */ -#define ZE_WD_MSR 0 - -#define ZE_WD_MSR_ADDR 0x3f /* Memory decode bits 18-13 */ -#define ZE_WD_MSR_MENB 0x40 /* Memory enable */ -#define ZE_WD_MSR_RST 0x80 /* Reset board */ - -/* - * Interface Configuration Register (ICR) - */ -#define ZE_WD_ICR 1 - -#define ZE_WD_ICR_16BIT 0x01 /* 16-bit interface */ -#define ZE_WD_ICR_OAR 0x02 /* select register. 0=BIO 1=EAR */ -#define ZE_WD_ICR_IR2 0x04 /* high order bit of encoded IRQ */ -#define ZE_WD_ICR_MSZ 0x08 /* memory size (0=8k 1=32k) */ -#define ZE_WD_ICR_RLA 0x10 /* recall LAN address */ -#define ZE_WD_ICR_RX7 0x20 /* recall all but i/o and LAN address */ -#define ZE_WD_ICR_RIO 0x40 /* recall i/o address */ -#define ZE_WD_ICR_STO 0x80 /* store to non-volatile memory */ - -/* - * IO Address Register (IAR) - */ -#define ZE_WD_IAR 2 - -/* - * EEROM Address Register - */ -#define ZE_WD_EAR 3 - -/* - * Interrupt Request Register (IRR) - */ -#define ZE_WD_IRR 4 - -#define ZE_WD_IRR_0WS 0x01 /* use 0 wait-states on 8 bit bus */ -#define ZE_WD_IRR_OUT1 0x02 /* WD83C584 pin 1 output */ -#define ZE_WD_IRR_OUT2 0x04 /* WD83C584 pin 2 output */ -#define ZE_WD_IRR_OUT3 0x08 /* WD83C584 pin 3 output */ -#define ZE_WD_IRR_FLASH 0x10 /* Flash RAM is in the ROM socket */ - -/* - * The three bit of the encoded IRQ are decoded as follows: - * - * IR2 IR1 IR0 IRQ - * 0 0 0 2/9 - * 0 0 1 3 - * 0 1 0 5 - * 0 1 1 7 - * 1 0 0 10 - * 1 0 1 11 - * 1 1 0 15 - * 1 1 1 4 - */ -#define ZE_WD_IRR_IR0 0x20 /* bit 0 of encoded IRQ */ -#define ZE_WD_IRR_IR1 0x40 /* bit 1 of encoded IRQ */ -#define ZE_WD_IRR_IEN 0x80 /* Interrupt enable */ - -/* - * LA Address Register (LAAR) - */ -#define ZE_WD_LAAR 5 - -#define ZE_WD_LAAR_ADDRHI 0x1f /* bits 23-19 of RAM address */ -#define ZE_WD_LAAR_0WS16 0x20 /* enable 0 wait-states on 16 bit bus */ -#define ZE_WD_LAAR_L16EN 0x40 /* enable 16-bit operation */ -#define ZE_WD_LAAR_M16EN 0x80 /* enable 16-bit memory access */ - -/* i/o base offset to station address/card-ID PROM */ -#define ZE_WD_PROM 8 - -/* i/o base offset to CARD ID */ -#define ZE_WD_CARD_ID ZE_WD_PROM+6 - -#define ZE_TYPE_WD8003S 0x02 -#define ZE_TYPE_WD8003E 0x03 -#define ZE_TYPE_WD8013EBT 0x05 -#define ZE_TYPE_WD8013EB 0x27 -#define ZE_TYPE_WD8013EBP 0x2c -#define ZE_TYPE_WD8013EPC 0x29 - -/* Bit definitions in card ID */ -#define ZE_WD_REV_MASK 0x1f /* Revision mask */ -#define ZE_WD_SOFTCONFIG 0x20 /* Soft config */ -#define ZE_WD_LARGERAM 0x40 /* Large RAM */ -#define ZE_MICROCHANEL 0x80 /* Microchannel bus (vs. isa) */ - -/* - * Checksum total. All 8 bytes in station address PROM will add up to this - */ -#define ZE_WD_ROM_CHECKSUM_TOTAL 0xFF - -#define ZE_WD_NIC_OFFSET 0x10 /* I/O base offset to NIC */ -#define ZE_WD_ASIC_OFFSET 0 /* I/O base offset to ASIC */ -#define ZE_WD_IO_PORTS 32 /* # of i/o addresses used */ - -#define ZE_WD_PAGE_OFFSET 0 /* page offset for NIC access to mem */ - -/* - * Definitions for 3Com 3c503 - */ -#define ZE_3COM_NIC_OFFSET 0 -#define ZE_3COM_ASIC_OFFSET 0x400 /* offset to nic i/o regs */ - -/* - * XXX - The I/O address range is fragmented in the 3c503; this is the - * number of regs at iobase. - */ -#define ZE_3COM_IO_PORTS 16 /* # of i/o addresses used */ - -#define ZE_3COM_PAGE_OFFSET 0x20 /* memory starts in second bank */ - -/* - * Page Start Register. Must match PSTART in NIC - */ -#define ZE_3COM_PSTR 0 - -/* - * Page Stop Register. Must match PSTOP in NIC - */ -#define ZE_3COM_PSPR 1 - -/* - * Drq Timer Register. Determines number of bytes to be transfered during - * a DMA burst. - */ -#define ZE_3COM_DQTR 2 - -/* - * Base Configuration Register. Read-only register which contains the - * board-configured I/O base address of the adapter. Bit encoded. - */ -#define ZE_3COM_BCFR 3 - -#define ZE_3COM_BCFR_2E0 0x01 -#define ZE_3COM_BCFR_2A0 0x02 -#define ZE_3COM_BCFR_280 0x04 -#define ZE_3COM_BCFR_250 0x08 -#define ZE_3COM_BCFR_350 0x10 -#define ZE_3COM_BCFR_330 0x20 -#define ZE_3COM_BCFR_310 0x40 -#define ZE_3COM_BCFR_300 0x80 - -/* - * EPROM Configuration Register. Read-only register which contains the - * board-configured memory base address. Bit encoded. - */ -#define ZE_3COM_PCFR 4 - -#define ZE_3COM_PCFR_C8000 0x10 -#define ZE_3COM_PCFR_CC000 0x20 -#define ZE_3COM_PCFR_D8000 0x40 -#define ZE_3COM_PCFR_DC000 0x80 - -/* - * GA Configuration Register. Gate-Array Configuration Register. - */ -#define ZE_3COM_GACFR 5 - -/* - * mbs2 mbs1 mbs0 start address - * 0 0 0 0x0000 - * 0 0 1 0x2000 - * 0 1 0 0x4000 - * 0 1 1 0x6000 - * - * Note that with adapters with only 8K, the setting for 0x2000 must - * always be used. - */ -#define ZE_3COM_GACFR_MBS0 0x01 -#define ZE_3COM_GACFR_MBS1 0x02 -#define ZE_3COM_GACFR_MBS2 0x04 - -#define ZE_3COM_GACFR_RSEL 0x08 /* enable shared memory */ -#define ZE_3COM_GACFR_TEST 0x10 /* for GA testing */ -#define ZE_3COM_GACFR_OWS 0x20 /* select 0WS access to GA */ -#define ZE_3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */ -#define ZE_3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */ - -/* - * Control Register. Miscellaneous control functions. - */ -#define ZE_3COM_CR 6 - -#define ZE_3COM_CR_RST 0x01 /* Reset GA and NIC */ -#define ZE_3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */ -#define ZE_3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */ -#define ZE_3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */ -#define ZE_3COM_CR_SHARE 0x10 /* select interrupt sharing option */ -#define ZE_3COM_CR_DBSEL 0x20 /* Double buffer select */ -#define ZE_3COM_CR_DDIR 0x40 /* DMA direction select */ -#define ZE_3COM_CR_START 0x80 /* Start DMA controller */ - -/* - * Status Register. Miscellaneous status information. - */ -#define ZE_3COM_STREG 7 - -#define ZE_3COM_STREG_REV 0x07 /* GA revision */ -#define ZE_3COM_STREG_DIP 0x08 /* DMA in progress */ -#define ZE_3COM_STREG_DTC 0x10 /* DMA terminal count */ -#define ZE_3COM_STREG_OFLW 0x20 /* Overflow */ -#define ZE_3COM_STREG_UFLW 0x40 /* Underflow */ -#define ZE_3COM_STREG_DPRDY 0x80 /* Data port ready */ - -/* - * Interrupt/DMA Configuration Register - */ -#define ZE_3COM_IDCFR 8 - -#define ZE_3COM_IDCFR_DRQ0 0x01 /* DMA request 1 select */ -#define ZE_3COM_IDCFR_DRQ1 0x02 /* DMA request 2 select */ -#define ZE_3COM_IDCFR_DRQ2 0x04 /* DMA request 3 select */ -#define ZE_3COM_IDCFR_UNUSED 0x08 /* not used */ -#define ZE_3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */ -#define ZE_3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */ -#define ZE_3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */ -#define ZE_3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */ - -/* - * DMA Address Register MSB - */ -#define ZE_3COM_DAMSB 9 - -/* - * DMA Address Register LSB - */ -#define ZE_3COM_DALSB 0x0a - -/* - * Vector Pointer Register 2 - */ -#define ZE_3COM_VPTR2 0x0b - -/* - * Vector Pointer Register 1 - */ -#define ZE_3COM_VPTR1 0x0c - -/* - * Vector Pointer Register 0 - */ -#define ZE_3COM_VPTR0 0x0d - -/* - * Register File Access MSB - */ -#define ZE_3COM_RFMSB 0x0e - -/* - * Register File Access LSB - */ -#define ZE_3COM_RFLSB 0x0f -#endif diff --git a/sys/i386/isa/iso8859.font b/sys/i386/isa/iso8859.font deleted file mode 100644 index 0553a6b..0000000 --- a/sys/i386/isa/iso8859.font +++ /dev/null @@ -1,1254 +0,0 @@ -/*- - * Copyright (c) 1992-1994 Søren Schmidt - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - * $Id$ - */ - -char font_8x8[256*8] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E, -0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, -0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, -0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, -0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C, -0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, -0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, -0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, -0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, -0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, -0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, -0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, -0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, -0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, -0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, -0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00, -0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, -0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, -0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, -0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, -0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0xCC, 0x78, -0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, -0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, -0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, -0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, -0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, -0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, -0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, -0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, -0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, -0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00, -0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, -0x30, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x30, 0x00, -0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, -0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, -0x60, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, -0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, -0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, -0x00, 0x30, 0x30, 0xFC, 0x30, 0x30, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, -0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, -0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, -0x7C, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x7C, 0x00, -0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00, -0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, -0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00, -0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, -0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, -0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, -0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, -0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, -0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, -0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, -0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60, -0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, -0x00, 0x00, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x00, -0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, -0x78, 0xCC, 0x0C, 0x18, 0x30, 0x00, 0x30, 0x00, -0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x78, 0x00, -0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, -0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, -0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, -0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, -0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, -0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, -0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00, -0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, -0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, -0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, -0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, -0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, -0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, -0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, -0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, -0x78, 0xCC, 0xCC, 0xCC, 0xDC, 0x78, 0x1C, 0x00, -0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, -0x78, 0xCC, 0xE0, 0x70, 0x1C, 0xCC, 0x78, 0x00, -0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, -0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, -0xC6, 0xC6, 0x6C, 0x38, 0x38, 0x6C, 0xC6, 0x00, -0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, -0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, -0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00, -0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, -0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, -0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00, -0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, -0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00, -0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x38, 0x6C, 0x60, 0xF0, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, -0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, -0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, -0x0C, 0x00, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, -0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, -0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xC6, 0x00, -0x00, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, -0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, -0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, -0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, -0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x00, -0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, -0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00, -0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, -0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, -0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00, -0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, -0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00, -0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x7E, 0xFF, 0x7E, 0x18, 0x00, -0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, -0x44, 0x44, 0x44, 0x44, 0x1F, 0x04, 0x04, 0x04, -0x7C, 0x40, 0x40, 0x40, 0x1F, 0x10, 0x10, 0x10, -0x38, 0x44, 0x44, 0x38, 0x1E, 0x11, 0x14, 0x13, -0x40, 0x40, 0x40, 0x7C, 0x1F, 0x10, 0x10, 0x10, -0x38, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, -0x44, 0x64, 0x4C, 0x44, 0x10, 0x10, 0x10, 0x1F, -0x44, 0x44, 0x28, 0x10, 0x1F, 0x04, 0x04, 0x04, -0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x00, 0x0C, 0x30, 0x60, 0x18, 0x0C, 0x7E, 0x00, -0x00, 0x30, 0x0C, 0x06, 0x18, 0x30, 0x7E, 0x00, -0x00, 0x00, 0x03, 0x3E, 0x36, 0x36, 0x6C, 0x00, -0x00, 0x00, 0x04, 0x7E, 0x10, 0x7E, 0x40, 0x00, -0x00, 0x1C, 0x30, 0x30, 0x30, 0x30, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x30, 0x00, 0x30, 0x30, 0x78, 0x78, 0x30, 0x00, -0x00, 0x00, 0x10, 0x7C, 0xC0, 0xC0, 0x7C, 0x10, -0x00, 0x38, 0x60, 0x60, 0xF0, 0x60, 0xFC, 0x00, -0x00, 0xC3, 0x3C, 0x66, 0x66, 0x3C, 0xC3, 0x00, -0x00, 0xCC, 0xCC, 0x78, 0x30, 0xFC, 0x30, 0x00, -0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, -0x7E, 0xC0, 0x7C, 0xC6, 0x7C, 0x06, 0xFC, 0x00, -0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7C, 0x82, 0xBA, 0xA2, 0xBA, 0x82, 0x7C, 0x00, -0x1C, 0x06, 0x1E, 0x22, 0x1F, 0x3F, 0x00, 0x00, -0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, -0x00, 0xFE, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7C, 0x82, 0xBA, 0xB2, 0xAA, 0x82, 0x7C, 0x00, -0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x7C, 0x10, 0x00, 0x7C, 0x00, 0x00, -0x1C, 0x36, 0x06, 0x18, 0x3E, 0x00, 0x00, 0x00, -0x1E, 0x02, 0x0E, 0x02, 0x1E, 0x00, 0x00, 0x00, -0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0xC0, -0x7E, 0xCA, 0xCA, 0x7E, 0x0A, 0x0A, 0x0A, 0x00, -0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, -0x06, 0x0E, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, -0x0E, 0x11, 0x11, 0x11, 0x0E, 0x1F, 0x00, 0x00, -0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00, -0x60, 0xE0, 0x66, 0x6C, 0x33, 0x67, 0x0F, 0x03, -0x60, 0xE0, 0x66, 0x6C, 0x36, 0x6A, 0x04, 0x0E, -0xF0, 0x20, 0x96, 0x6C, 0x33, 0x67, 0x0F, 0x03, -0x30, 0x00, 0x30, 0x60, 0xC0, 0xCC, 0x78, 0x00, -0x18, 0x0C, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x60, 0xC0, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x78, 0x84, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x66, 0x98, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0xCC, 0x00, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x30, 0x48, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x3E, 0x78, 0x98, 0x9C, 0xF8, 0x98, 0x9E, 0x00, -0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x1C, 0x30, -0x30, 0x18, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x18, 0x30, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x38, 0x44, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x66, 0x00, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x60, 0x30, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0x18, 0x30, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0x78, 0x84, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0xCC, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0x78, 0x6C, 0x66, 0xF6, 0x66, 0x6C, 0x78, 0x00, -0x66, 0x98, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0x00, -0x30, 0x18, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x18, 0x30, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x38, 0x44, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x66, 0x98, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x00, 0xC6, 0x6C, 0x38, 0x38, 0x6C, 0xC6, 0x00, -0x06, 0x7C, 0xCE, 0x9A, 0xB2, 0xE6, 0x78, 0xC0, -0x60, 0x30, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0x18, 0x30, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0x78, 0x84, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0x18, 0x30, 0xCC, 0xCC, 0x78, 0x30, 0x78, 0x00, -0x60, 0x78, 0x6C, 0x78, 0x60, 0x60, 0x60, 0x00, -0x78, 0xCC, 0xC4, 0xDC, 0xC6, 0xC6, 0xDC, 0xC0, -0x30, 0x18, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x18, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x78, 0x84, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x66, 0x98, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x30, 0x48, 0x38, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x00, 0x00, 0xEC, 0x32, 0x7E, 0xB0, 0x6E, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC0, 0x66, 0x1C, 0x30, -0x30, 0x18, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x18, 0x30, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x78, 0x84, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x60, 0x30, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0x18, 0x30, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0x70, 0x88, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0xCC, 0x00, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0x6C, 0x38, 0x6C, 0x0C, 0x6C, 0xCC, 0x78, 0x00, -0x66, 0x98, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, -0x60, 0x30, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x18, 0x30, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x38, 0x44, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x66, 0x98, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x00, 0x00, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x00, -0x00, 0x00, 0x06, 0x7C, 0xDE, 0xF6, 0x7C, 0xC0, -0x60, 0x30, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x18, 0x30, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x30, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0xCC, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x18, 0x30, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, -0xE0, 0x78, 0x6C, 0x66, 0x6C, 0x78, 0xE0, 0x00, -0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8 -}; - -char font_8x14[256*14] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD, 0x99, 0x81, -0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xFF, -0xDB, 0xFF, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x7F, 0x7F, -0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, -0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x3C, 0x3C, 0xE7, 0xE7, 0xE7, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, -0x7E, 0xFF, 0xFF, 0x7E, 0x18, 0x18, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, -0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x24, 0x42, 0x42, 0x24, 0x3C, -0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, -0xC3, 0xDB, 0xBD, 0xBD, 0xDB, 0xC3, 0xFF, 0xFF, -0xFF, 0xFF, 0x00, 0x00, 0x1F, 0x07, 0x0D, 0x19, -0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, -0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x0A, 0x09, 0x09, 0x09, 0x0A, 0x08, 0x38, -0x78, 0x78, 0x30, 0x00, 0x00, 0x00, 0x1F, 0x11, -0x1F, 0x11, 0x11, 0x11, 0x13, 0x37, 0x77, 0x72, -0x20, 0x00, 0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, -0xE7, 0x3C, 0xDB, 0x18, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x40, 0x60, 0x70, 0x7C, 0x7F, 0x7C, -0x70, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x03, 0x07, 0x1F, 0x7F, 0x1F, 0x07, 0x03, -0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, -0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, -0x33, 0x33, 0x00, 0x33, 0x33, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, -0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x30, 0x1C, 0x36, 0x63, 0x63, 0x36, 0x1C, -0x06, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, -0x18, 0x18, 0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x06, 0x7F, 0x06, 0x0C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, -0x7F, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, -0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x24, 0x42, 0xFF, 0x42, 0x24, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, -0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7F, 0x36, -0x36, 0x36, 0x7F, 0x36, 0x36, 0x00, 0x00, 0x00, -0x08, 0x08, 0x3E, 0x63, 0x60, 0x60, 0x3E, 0x03, -0x03, 0x63, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x00, -0x00, 0x61, 0x63, 0x06, 0x0C, 0x18, 0x30, 0x63, -0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, -0x36, 0x1C, 0x3B, 0x6E, 0x66, 0x66, 0x3B, 0x00, -0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, -0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, -0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x66, 0x3C, 0x7E, 0x3C, 0x66, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, -0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, -0x18, 0x30, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x63, 0x67, 0x6F, 0x7B, 0x73, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x1C, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, -0x03, 0x06, 0x0C, 0x18, 0x30, 0x63, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x03, 0x03, -0x1E, 0x03, 0x03, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x06, 0x0E, 0x1E, 0x36, 0x66, 0x7F, -0x06, 0x06, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7E, 0x60, 0x60, 0x60, 0x7E, 0x03, 0x03, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x30, -0x60, 0x60, 0x7E, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7F, 0x63, 0x03, 0x06, -0x0C, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x3E, 0x63, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3E, 0x63, 0x63, 0x63, 0x3F, 0x03, 0x03, 0x06, -0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, -0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, -0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x30, -0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, -0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x63, 0x06, -0x0C, 0x0C, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x63, 0x63, 0x6F, 0x6F, 0x6F, -0x6E, 0x60, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x08, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, -0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x33, -0x33, 0x33, 0x3E, 0x33, 0x33, 0x33, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, 0x60, 0x60, -0x60, 0x60, 0x60, 0x33, 0x1E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0x36, 0x33, 0x33, 0x33, 0x33, -0x33, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7F, 0x33, 0x30, 0x34, 0x3C, 0x34, 0x30, 0x33, -0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x33, -0x30, 0x34, 0x3C, 0x34, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, 0x60, 0x60, -0x60, 0x6F, 0x63, 0x33, 0x1D, 0x00, 0x00, 0x00, -0x00, 0x00, 0x63, 0x63, 0x63, 0x63, 0x7F, 0x63, -0x63, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x06, -0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x73, 0x33, 0x36, 0x36, -0x3C, 0x36, 0x36, 0x33, 0x73, 0x00, 0x00, 0x00, -0x00, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, -0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, -0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63, 0x63, -0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x73, -0x7B, 0x7F, 0x6F, 0x67, 0x63, 0x63, 0x63, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, 0x63, 0x63, -0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x33, 0x33, 0x33, 0x3E, 0x30, -0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x63, 0x63, 0x6B, 0x3E, -0x1C, 0x06, 0x03, 0x00, 0x00, 0x00, 0x7E, 0x33, -0x33, 0x33, 0x3E, 0x36, 0x33, 0x33, 0x73, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x63, 0x30, -0x1C, 0x06, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x08, 0x00, -0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x63, 0x63, -0x63, 0x6B, 0x6B, 0x7F, 0x36, 0x00, 0x00, 0x00, -0x00, 0x00, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x36, -0x63, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x63, -0x06, 0x0C, 0x18, 0x30, 0x60, 0x63, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, -0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, -0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x3C, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x63, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x30, -0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x60, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0E, 0x06, 0x06, 0x3E, 0x66, 0x66, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, -0x30, 0x7C, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, -0x66, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00, -0x00, 0x00, 0x70, 0x30, 0x30, 0x36, 0x3B, 0x33, -0x33, 0x33, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, -0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, -0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xCC, -0x78, 0x00, 0x00, 0x00, 0x70, 0x30, 0x30, 0x33, -0x36, 0x3C, 0x36, 0x33, 0x73, 0x00, 0x00, 0x00, -0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x66, 0x7F, 0x6B, 0x6B, 0x6B, -0x6B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x6E, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x33, 0x33, -0x33, 0x3E, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3B, 0x66, 0x66, 0x66, 0x3E, -0x06, 0x06, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x6E, 0x33, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x38, 0x0E, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x18, 0x7E, 0x18, 0x18, -0x18, 0x1B, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x08, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, -0x63, 0x6B, 0x6B, 0x7F, 0x36, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1C, -0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x63, 0x66, 0x66, 0x66, 0x3E, -0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x7F, 0x66, 0x0C, 0x18, 0x33, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, -0x70, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x70, 0x18, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x18, -0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, -0x36, 0x63, 0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x3C, -0x18, 0x00, 0x00, 0x00, 0x55, 0xAA, 0x55, 0xAA, -0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -0x55, 0xAA, 0x00, 0x44, 0x44, 0x7C, 0x44, 0x44, -0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, -0x00, 0x7C, 0x40, 0x78, 0x40, 0x40, 0x00, 0x1F, -0x10, 0x1E, 0x10, 0x10, 0x00, 0x00, 0x00, 0x38, -0x44, 0x40, 0x44, 0x38, 0x00, 0x1E, 0x11, 0x1E, -0x14, 0x13, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, -0x40, 0x7C, 0x00, 0x1F, 0x10, 0x1E, 0x10, 0x10, -0x00, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, -0x18, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x44, -0x64, 0x54, 0x4C, 0x44, 0x00, 0x10, 0x10, 0x10, -0x10, 0x1F, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, -0x28, 0x10, 0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x0C, 0x18, -0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x0C, 0x06, -0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0x3E, 0x76, 0x36, -0x36, 0x36, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x04, 0x7E, 0x08, 0x10, 0x7E, 0x20, -0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, -0x30, 0x30, 0x7C, 0x30, 0x30, 0x73, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x3C, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x08, 0x3E, 0x63, 0x60, 0x60, 0x63, 0x3E, 0x08, -0x08, 0x00, 0x00, 0x00, 0x1C, 0x36, 0x30, 0x30, -0x7C, 0x30, 0x30, 0x73, 0x7E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x42, 0x3C, 0x66, 0x66, 0x66, -0x3C, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x7E, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, -0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, -0x00, 0x00, 0x00, 0x3E, 0x63, 0x30, 0x1C, 0x36, -0x63, 0x63, 0x36, 0x1C, 0x06, 0x63, 0x3E, 0x00, -0x00, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x3E, 0x41, 0x5D, 0x51, 0x51, 0x5D, 0x41, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, -0x44, 0x3C, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x36, -0x6C, 0x36, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x03, -0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x41, 0x5D, 0x55, 0x59, 0x55, 0x41, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, -0x7E, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C, 0x18, -0x30, 0x64, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x7C, 0x0C, 0x38, 0x0C, 0x6C, -0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x06, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, -0x3B, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x7F, 0xDB, -0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x0C, 0x06, 0x1C, 0x00, 0x30, -0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, -0x44, 0x38, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x36, -0x1B, 0x36, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0xE0, 0x63, 0x66, 0x6C, 0x18, 0x33, -0x67, 0xCF, 0x1F, 0x03, 0x03, 0x00, 0x00, 0x60, -0xE0, 0x63, 0x66, 0x6C, 0x18, 0x30, 0x6E, 0xC3, -0x06, 0x0C, 0x1F, 0x00, 0x00, 0xF0, 0x30, 0x63, -0xF6, 0x6C, 0x18, 0x33, 0x67, 0xCF, 0x1F, 0x03, -0x03, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, -0x18, 0x30, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x1C, 0x36, 0x63, 0x63, -0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x03, 0x06, -0x0C, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, -0x63, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, -0x00, 0x00, 0x3B, 0x6E, 0x00, 0x08, 0x1C, 0x36, -0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, -0x00, 0x63, 0x63, 0x08, 0x1C, 0x36, 0x63, 0x63, -0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x1C, 0x36, -0x1C, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, -0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x36, -0x66, 0x66, 0x67, 0x7E, 0x66, 0x66, 0x67, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, 0x60, 0x60, -0x60, 0x60, 0x60, 0x33, 0x1E, 0x0C, 0x06, 0x1C, -0x60, 0x30, 0x18, 0x00, 0x7F, 0x33, 0x30, 0x3E, -0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, 0x06, 0x0C, -0x18, 0x00, 0x7F, 0x33, 0x30, 0x3E, 0x30, 0x33, -0x7F, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, -0x7F, 0x33, 0x30, 0x3E, 0x30, 0x33, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x63, 0x63, 0x00, 0x7F, 0x33, -0x30, 0x3E, 0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x06, 0x0C, -0x18, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x66, 0x00, -0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x3C, 0x18, -0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x36, 0x33, 0x33, 0x7B, 0x33, -0x33, 0x36, 0x3C, 0x00, 0x00, 0x00, 0x3B, 0x6E, -0x00, 0x63, 0x73, 0x7B, 0x7F, 0x6F, 0x67, 0x63, -0x63, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, -0x00, 0x00, 0x03, 0x06, 0x0C, 0x00, 0x1C, 0x36, -0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, -0x08, 0x1C, 0x36, 0x00, 0x1C, 0x36, 0x63, 0x63, -0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x3B, -0x6E, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, -0x1C, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1C, -0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, -0x00, 0x03, 0x1E, 0x36, 0x67, 0x6F, 0x6B, 0x7B, -0x73, 0x36, 0x3C, 0x60, 0x00, 0x00, 0x60, 0x30, -0x18, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x03, 0x06, 0x0C, 0x00, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x63, 0x63, 0x00, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x06, 0x0C, -0x18, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x78, 0x30, 0x3E, -0x33, 0x33, 0x3E, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, 0x63, 0x66, -0x6C, 0x67, 0x63, 0x6B, 0x6E, 0x60, 0x60, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x3C, 0x06, 0x3E, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x06, -0x0C, 0x18, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, -0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, 0x00, 0x3C, -0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x66, 0x00, 0x3C, 0x06, 0x3E, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x1C, -0x36, 0x1C, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x76, 0x0B, 0x3B, 0x6E, 0x68, 0x37, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x60, 0x60, 0x63, 0x3E, 0x0C, 0x06, 0x1C, -0x00, 0x30, 0x18, 0x0C, 0x00, 0x3E, 0x63, 0x7F, -0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x03, -0x06, 0x0C, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, -0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x00, 0x3E, -0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x06, -0x0C, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x66, -0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x38, -0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x36, 0x1C, 0x36, 0x06, 0x3E, 0x66, -0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3B, 0x6E, 0x00, 0x6E, 0x33, 0x33, 0x33, 0x33, -0x33, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, -0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x00, 0x3E, -0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x08, 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x63, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3B, 0x6E, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, -0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, -0x7E, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0x3E, 0x67, 0x6F, -0x7B, 0x73, 0x3E, 0x60, 0x00, 0x00, 0x00, 0x60, -0x30, 0x18, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, -0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x66, 0x00, 0x66, -0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x06, -0x0C, 0x18, 0x00, 0x63, 0x66, 0x66, 0x66, 0x3E, -0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x78, -0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x3E, 0x30, -0x78, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, -0x66, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00 -}; - -char font_8x16[256*16] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD, -0x99, 0x81, 0x81, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0xFF, 0xDB, 0xFF, 0xFF, 0xC3, -0xE7, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0xFE, 0xFE, -0xFE, 0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7C, 0xFE, -0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0xE7, 0xE7, -0xE7, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, -0x7E, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, -0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, -0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x42, -0x42, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x99, 0xBD, -0xBD, 0x99, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -0x00, 0x00, 0x1E, 0x0E, 0x1A, 0x32, 0x78, 0xCC, -0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, -0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x30, -0x30, 0x70, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x63, -0x63, 0x67, 0xE7, 0xE6, 0xC0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, 0xE7, -0x3C, 0xDB, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0xF8, -0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0xFE, 0x3E, -0x1E, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, -0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, -0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, -0x00, 0x7C, 0xC6, 0x60, 0x38, 0x6C, 0xC6, 0xC6, -0x6C, 0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0C, 0xFE, -0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xFE, -0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, -0xC0, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xFF, -0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7C, -0x7C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x7C, 0x7C, -0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x18, -0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, -0x6C, 0xFE, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x7C, 0xC6, 0xC2, 0xC0, 0x7C, 0x06, -0x06, 0x86, 0xC6, 0x7C, 0x18, 0x18, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xC2, 0xC6, 0x0C, 0x18, -0x30, 0x60, 0xC6, 0x86, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x76, 0xDC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, -0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, -0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, -0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, -0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0C, 0x18, -0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC3, 0xC3, 0xDB, 0xDB, -0xC3, 0xC3, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x06, 0x0C, 0x18, 0x30, -0x60, 0xC0, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, -0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, -0x0C, 0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0xC0, 0xC0, 0xC0, 0xFC, 0x06, -0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x60, 0xC0, 0xC0, 0xFC, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0xC6, 0x06, 0x06, 0x0C, 0x18, -0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, -0x06, 0x06, 0x0C, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, -0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, -0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, -0x30, 0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, -0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, -0x0C, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x0C, 0x18, 0x18, -0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xDE, 0xDE, -0xDE, 0xDC, 0xC0, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, -0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, -0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, -0xC0, 0xC2, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x66, -0x66, 0x66, 0x6C, 0xF8, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, -0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xDE, -0xC6, 0xC6, 0x66, 0x3A, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, -0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xE6, 0x66, 0x66, 0x6C, 0x78, 0x78, -0x6C, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x60, 0x60, -0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xE7, 0xFF, 0xFF, 0xDB, 0xC3, -0xC3, 0xC3, 0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, -0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x60, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xD6, 0xDE, 0x7C, 0x0C, 0x0E, 0x00, 0x00, -0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x6C, -0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x60, 0x38, 0x0C, -0x06, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFF, 0xDB, 0x99, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, -0xC3, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xDB, -0xDB, 0xFF, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0x66, 0x3C, 0x18, 0x18, -0x3C, 0x66, 0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0xC3, 0x66, 0x3C, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFF, 0xC3, 0x86, 0x0C, 0x18, 0x30, -0x60, 0xC1, 0xC3, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, -0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, -0x1C, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, -0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xE0, 0x60, 0x60, 0x78, 0x6C, 0x66, -0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x3C, 0x6C, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xCC, 0x78, 0x00, -0x00, 0x00, 0xE0, 0x60, 0x60, 0x6C, 0x76, 0x66, -0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, -0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, 0x00, -0x00, 0x00, 0xE0, 0x60, 0x60, 0x66, 0x6C, 0x78, -0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0xFF, 0xDB, -0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, -0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, -0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0x0C, 0x1E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x76, 0x66, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x60, -0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x10, 0x30, 0x30, 0xFC, 0x30, 0x30, -0x30, 0x30, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, -0xC3, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, -0xDB, 0xDB, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x66, 0x3C, -0x18, 0x3C, 0x66, 0xC3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0xF8, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xCC, 0x18, -0x30, 0x60, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, 0x70, 0x18, -0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0E, 0x18, -0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, -0xC6, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, -0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -0x00, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88, 0x00, -0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, -0x00, 0xF8, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, -0x3E, 0x20, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00, -0x00, 0x70, 0x88, 0x80, 0x80, 0x88, 0x70, 0x00, -0x3C, 0x22, 0x3C, 0x28, 0x24, 0x22, 0x00, 0x00, -0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8, 0x00, -0x3E, 0x20, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, -0x18, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x88, 0xC8, 0xA8, 0xA8, 0x98, 0x88, 0x00, -0x20, 0x20, 0x20, 0x20, 0x20, 0x3E, 0x00, 0x00, -0x00, 0x88, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00, -0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x60, 0x30, -0x18, 0x0C, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x18, 0x0C, 0x06, 0x0C, -0x18, 0x30, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x02, 0x7E, 0xEC, 0x6C, 0x6C, -0x6C, 0x6C, 0x6C, 0xCC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x06, 0x0C, 0x7E, 0x18, 0x18, -0x7E, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, -0x60, 0x60, 0xE6, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, -0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x18, 0x7E, 0xC3, 0xC0, 0xC0, 0xC0, -0xC3, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, -0x60, 0x60, 0xE6, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x82, 0xC6, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0x7C, 0xC6, 0x82, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0x66, 0x3C, 0x18, 0xFF, 0x18, -0xFF, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x7C, 0xC6, 0x60, 0x38, 0x6C, 0xC6, 0xC6, -0x6C, 0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x82, 0xBA, 0xA2, 0xA2, -0xBA, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x70, 0x18, 0x78, 0xC8, 0x78, 0x00, 0xF8, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6C, 0xD8, -0x6C, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, -0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x82, 0xBA, 0xAA, 0xB2, -0xAA, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, -0x18, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x70, 0xD8, 0x30, 0x60, 0xC8, 0xF8, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xF8, 0x18, 0x30, 0x18, 0xD8, 0x70, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, -0x66, 0x7E, 0x63, 0x60, 0xC0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, -0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x0C, 0x06, 0x3C, 0x00, 0x00, -0x00, 0x60, 0xE0, 0x60, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x70, 0xD8, 0x88, 0xD8, 0x70, 0x00, 0xF8, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x6C, 0x36, -0x6C, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC0, 0xC0, 0xC2, 0xC6, 0xCC, 0x18, 0x30, -0x66, 0xCE, 0x96, 0x3E, 0x06, 0x06, 0x00, 0x00, -0x00, 0xC0, 0xC0, 0xC2, 0xC6, 0xCC, 0x18, 0x30, -0x60, 0xCE, 0x9B, 0x06, 0x0C, 0x1F, 0x00, 0x00, -0x00, 0xF0, 0x30, 0x72, 0x36, 0xEC, 0x18, 0x30, -0x66, 0xCE, 0x96, 0x3E, 0x06, 0x06, 0x00, 0x00, -0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, -0xC0, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x76, 0xDC, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x38, 0x6C, 0x38, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x6C, 0xCC, 0xCC, 0xFE, 0xCC, -0xCC, 0xCC, 0xCC, 0xCE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, -0xC2, 0x66, 0x3C, 0x0C, 0x06, 0x7C, 0x00, 0x00, -0x30, 0x18, 0x0C, 0x00, 0xFE, 0x66, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x18, 0x30, 0x60, 0x00, 0xFE, 0x66, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0xFE, 0x66, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0xFE, 0x66, 0x60, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x30, 0x18, 0x0C, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x18, 0x3C, 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x78, 0x6C, 0x66, 0x66, 0x66, 0xF6, -0x66, 0x66, 0x6C, 0x78, 0x00, 0x00, 0x00, 0x00, -0x76, 0xDC, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, -0xCE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x76, 0xDC, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x10, -0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x06, 0x7C, 0xCE, 0xCE, 0xDE, 0xD6, 0xD6, -0xF6, 0xE6, 0xE6, 0x7C, 0xC0, 0x80, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0xC3, 0xC3, 0x66, 0x3C, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0xF0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x6C, 0xC6, 0xCE, 0xDC, 0xD8, -0xCC, 0xC6, 0xD6, 0xDC, 0xC0, 0x80, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xCC, 0x00, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x38, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x3B, 0x1B, -0x7E, 0xD8, 0xDC, 0x77, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x60, -0x66, 0x3C, 0x0C, 0x06, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x0C, 0x18, 0x30, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x06, 0x0C, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x3C, 0x66, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x6C, 0x38, 0x38, 0x6C, 0x0C, 0x3C, 0x6C, -0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0xDC, 0x66, 0x66, -0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7E, -0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x02, 0x06, 0x7C, 0xCE, 0xDE, -0xD6, 0xF6, 0xE6, 0x7C, 0xC0, 0x80, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x30, 0x78, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xCC, 0x00, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0xF8, 0x00, -0x00, 0x00, 0x00, 0xF0, 0x60, 0x7C, 0x66, 0x66, -0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x66, 0x66, 0x00, 0xEE, 0x66, 0x66, -0x66, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00 -}; diff --git a/sys/i386/isa/matcd.c b/sys/i386/isa/matcd.c deleted file mode 100644 index ae6ecd7..0000000 --- a/sys/i386/isa/matcd.c +++ /dev/null @@ -1,2286 +0,0 @@ -/*matcd.c-------------------------------------------------------------------- - Matsushita(Panasonic) / Creative CD-ROM Driver (matcd) - Authored by Frank Durda IV - - Copyright 1994, 1995 Frank Durda IV. All rights reserved. - "FDIV" is a trademark of Frank Durda IV. - - - 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 positioned at the very beginning of this file without - modification, all copyright strings, all related programming - codes that display the copyright strings, this list of - conditions and the following disclaimer. - 2. Redistributions in binary form must contain all copyright strings - and related programming code that display the copyright strings. - 3. 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. - 4. All advertising materials mentioning features or use of this - software must display the following acknowledgement: - "The Matsushita/Panasonic CD-ROM driver was developed - by Frank Durda IV for use with "FreeBSD" and similar - operating systems." - "Similar operating systems" includes mainly non-profit oriented - systems for research and education, including but not restricted - to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the - acknowledgement (in electronic form or printed text) may not be - changed without permission from the author. - 5. Absolutely no warranty of function, fitness or purpose is made - by the author Frank Durda IV. - 6. Neither the name of the author nor the name "FreeBSD" may - be used to endorse or promote products derived from this software - without specific prior written permission. - (The author can be reached at bsdmail@nemesis.lonestar.org) - 7. The product containing this software must meet all of these - conditions even if it is unsupported, not a complete system - and/or does not contain compiled code. - 8. These conditions will be in force for the full life of the - copyright. - 9. If all the above conditions are met, modifications to other - parts of this file may be freely made, although any person - or persons making changes do not receive the right to add their - name or names to the copyright strings and notices in this - software. Persons making changes are encouraged to insert edit - history in matcd.c and to put your name and details of the - change there. - 10. You must have prior written permission from the author to - deviate from these terms. - - Vendors who produce product(s) containing this code are encouraged - (but not required) to provide copies of the finished product(s) to - the author and to correspond with the author about development - activity relating to this code. Donations of development hardware - and/or software are also welcome. (This is one of the faster ways - to get a driver developed for a device.) - - THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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. ------------------------------------------------------------------------------ -Dedicated to: My family and Max, my Golden Retriever - -Thanks to: Jordan Hubbard (jkh) for getting me ramped-up to 2.x system - quickly enough to make the 2.1 release. He put up with - plenty of silly questions. - -and The people who donated equipment and other material to make - development of this driver possible. Donations and - sponsors for projects are appreciated. - - ------------------------------------------------------------------------------ -Edit History - (should be in sync with any source control log entries) - - Never seen one of these before? Ok, here is how it works. - Every time you change the code, you increment the edit number, - that number over there in the <%d> and in the (%d) in the - version string. You never set this number lower than it is. - Near, or preferably on lines that change, insert the edit - number. If there is a number there already, you can replace it - with a newer one. - - In the edit history, start with the edit number, and a good - description of what changes were made. Then follow it with - the date, your name and an EMAIL address where you can be reached. - - Please follow this practice; it helps leave understandable code in - your wake. - - FYI, you have major and minor release codes. These are numbered - 1 thru n. Major feature additions should get a new major release - number. Minor releases start with a null and then letters - A thru Z. So 3A(456) is Major release 3, Minor release 1, - Edit 456 (in Microsoft-ese that would be 03.01.456), and 5(731) - is Major release 5, Minor release 0, Edit 731. Typically only the - author will change the major and minor release codes. - - EDIT edit Edit HISTORY history History - -<1> This initial version is to get basic filesystem I/O working - using the SoundBlaster 16 interface. The stand-alone adapter - card doesn't work yet. - December 1994 Frank Durda IV bsdmail@nemesis.lonestar.org - -<2> Corrections to resolve a race condition when multiple drives - on the same controller was active. Fixed drive 1 & 2 swap - problem. See selectdrive(). - 21-Jan-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<3> Added automatic probing and support for all Creative Labs sound - cards with the Creative/Panasonic interface and the stand-alone - interface adapters. See AUTOHUNT and FULLCONFIG conditionals - for more information. - 21-Jan-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<4> Rebundled debug conditionals. - 14-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<5> Changes needed to work on FreeBSD 2.1. Also added draincmd - since some conditions cause the drive to produce surprise data. - See setmode and draincmd - 19-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<6> Got rid of some redundant error code by creating chk_error(). - Also built a nice generic buss-lock function. - 20-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<7> Improved comments, general structuring. - Fixed a problem with disc eject not working if LOCKDRIVE was set. - Apparently the drive will reject an EJECT command if the drive - is LOCKED. - 21-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -Edit number code marking begins here - earlier edits were during development. - -<8> Final device name selected and actually made to compile under - >2.0. For newer systems, it is "matcd", for older it is "mat". - 24-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<9> Added some additional disk-related ioctl functions that didn't - make it into earlier versions. - 26-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - -<10> Updated some conditionals so the code will compile under - 1.1.5.1, although this is not the supported platform. - Also found that some other devices probe code was changing the - settings for the port 0x302 debug board, so added code to set it - to a sane state before we use it. - 26-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org - - ----------------------------------------------------------------------------*/ - -/*Match this format: Version__dc(d)__dd-mmm-yy */ -static char MATCDVERSION[]="Version 1(10) 26-Feb-95"; - -/* The following strings may not be changed*/ -static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank Durda IV"; -/* The proceeding strings may not be changed*/ - - -/*--------------------------------------------------------------------------- - Include declarations ----------------------------------------------------------------------------*/ - -#include "types.h" -#include "param.h" -#include "systm.h" - -#include "buf.h" -#include "dkbad.h" -#include "cdio.h" -#include "conf.h" -#include "disklabel.h" -#include "errno.h" -#include "file.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "ioctl.h" -#include "proc.h" -#include "stat.h" -#include "uio.h" - -#include "options.h" /*Conditional compile options and - probe port hints*/ -#include "matcd.h" /*Drive-related defines and strings*/ -#include "creative.h" /*Host interface related defines*/ - - -/*--------------------------------------------------------------------------- - Defines and structures ----------------------------------------------------------------------------*/ - -#ifdef FULLCONFIG -#define NUMCTRLRS 4 /*With modern boards, four is max*/ -#else /*FULLCONFIG*/ -#define NUMCTRLRS 1 /*Produces a slightly smaller kernel*/ -#endif /*FULLCONFIG*/ -#define DRIVESPERC 4 /*This is a constant*/ -#define TOTALDRIVES NUMCTRLRS*DRIVESPERC /*Max possible drives*/ -#if DIAGPORT > 0xff /*<10>*/ -#define DIAGOUT outw /*<10>*/ -#else /*DIAGPORT*/ /*<10>*/ -#define DIAGOUT outb /*<10>*/ -#endif /*DIAGPORT*/ /*<10>*/ -#ifdef DIAGPORT -int diagloop; /*Used to show looping*/ -#endif /*DIAGPORT*/ - - -#define TICKRES 10 /*Our coarse timer resolution*/ -#define ISABUSKHZ 8330 /*Number of IN/OUT ISA/sec*/ - -#ifndef FREE2 -#define RAW_PART 2 /*Needs to be defined in 1.1.5.1*/ -#endif /*FREE2*/ - - -#define MATCDBLK 2048 /*Standard block size*/ -#define MATCDRBLK 2352 /*Raw and/or DA block size*/ -#define MATCD_RETRYS 5 /*Number of retries for read ops*/ -#define MATCD_READ_1 0x80 /*Read state machine defines*/ -#define MATCD_READ_2 0x90 /*Read state machine defines*/ - -struct matcd_volinfo { - unsigned char type; /*00 CD-DA or CD-ROM - 10 CD-I - 20 XA */ - unsigned char trk_low; /*Normally 1*/ - unsigned char trk_high; /*Highest track number*/ - unsigned char vol_msf[3]; /*Size of disc in min/sec/frame*/ -}; - - -struct matcd_mbx { - short controller; - short ldrive; - short partition; - short port; - short retry; - short nblk; - int sz; - u_long skip; - struct buf *bp; - int p_offset; - short count; -}; - - -struct matcd_data { - short config; - short drivemode; /*Last state drive was set to*/ - short flags; - short status; - int blksize; - u_long disksize; - int iobase; - struct disklabel dlabel; - int partflags[MAXPARTITIONS]; - int openflags; - struct matcd_volinfo volinfo; - short debug; - struct matcd_mbx mbx; -} matcd_data[TOTALDRIVES]; - - -/* Bit equates for matcd_data.flags*/ - -#define MATCDINIT 0x0001 /*Probe ran on host adapter*/ -#define MATCDLABEL 0x0004 /*Valid TOC exists*/ -#define MATCDWARN 0x0020 /*Have reported an open disc change*/ - - -/* Bit equates for matcd_data.partflags*/ - -#define MATCDOPEN 0x0001 -#define MATCDREADRAW 0x0002 - - -#define DELAY_STATUS 10000l /* 10000 * 1us */ -#define DELAY_GETREPLY 200000l /* 200000 * 2us */ -#define DELAY_SEEKREAD 20000l /* 20000 * 1us */ -#define matcd_delay DELAY - - - -/* Error classes returned by chk_error()*/ - -#define ERR_RETRY 1 /*A retry might recover this*/ -#define ERR_INIT 2 /*A retry almost certainly will get this*/ -#define ERR_FATAL 3 /*This cannot be recovered from*/ - - -struct buf request_head[NUMCTRLRS]; /*A queue for each host interface*/ - int nextcontroller=0; /*Number of interface units found*/ - int drivepresent=0; /*Don't change this - see license*/ -static struct matcd_mbx *mbxsave; - -unsigned char if_state[4]={0,0,0,0}; /*State of the host I/F and buss*/ - -/* Flags in the if_state array -*/ - -#define BUSSBUSY 0x01 /*Buss is already busy*/ - - - -struct matcd_read2 { - unsigned char start_msf[3]; - unsigned char end_msf[3]; -}; - -/*--------------------------------------------------------------------------- - These macros take apart the minor number and yield the - partition, drive on controller, and controller. - This must match the settings in /dev/MAKEDEV. ----------------------------------------------------------------------------*/ - -#define matcd_partition(dev) ((minor(dev)) & 0x07) -#define matcd_ldrive(dev) (((minor(dev)) & 0x78) >> 3) -#define matcd_cdrive(dev) (((minor(dev)) & 0x18) >> 3) -#define matcd_controller(dev) (((minor(dev)) & 0x60) >> 5) - - -#ifndef FREE2 -/*--------------------------------------------------------------------------- - This makes the long function names shorter for systems - using the older kernel config program ----------------------------------------------------------------------------*/ -#define matcdopen matopen /*<8>*/ -#define matcdclose matclose /*<8>*/ -#define matcdstrategy matstrategy /*<8>*/ -#define matcdioctl matioctl /*<8>*/ -#define matcdsize matsize /*<8>*/ -#define matcddriver matdriver /*<10>*/ -#endif /*FREE2*/ - - -/*--------------------------------------------------------------------------- - Entry points and other connections to/from kernel - see conf.c ----------------------------------------------------------------------------*/ - - int matcdopen(dev_t dev); - int matcdclose(dev_t dev); - void matcdstrategy(struct buf *bp); - int matcdioctl(dev_t dev, int command, caddr_t addr, int flags); - int matcdsize(dev_t dev); -extern int hz; -extern int matcd_probe(struct isa_device *dev); -extern int matcd_attach(struct isa_device *dev); -struct isa_driver matcddriver={matcd_probe, matcd_attach, - "matcd"}; - - -/*--------------------------------------------------------------------------- - Internal function declarations ----------------------------------------------------------------------------*/ - -static int matcd_getdisklabel(int ldrive); -static void matcd_start(struct buf *dp); -static void zero_cmd(char *); -static void matcd_pread(int port, int count, unsigned char * data); -static int matcd_fastcmd(int port,int ldrive,int cdrive, - unsigned char * cp); -static void matcd_slowcmd(int port,int ldrive,int cdrive, - unsigned char * cp); -static int matcd_getstat(int ldrive, int sflg); -static void matcd_setflags(int ldrive, struct matcd_data *cd); -static int msf2hsg(unsigned char *msf); -static void matcd_blockread(int state); -static int matcd_getreply(int ldrive, int dly); -static void selectdrive(int port,int drive); -static void doreset(int port,int cdrive); -static int doprobe(int port,int cdrive); -static void watchdog(int state, char * foo); -static void lockbuss(int controller, int ldrive); -static void unlockbuss(int controller, int ldrive); -static int matcd_volinfo(int ldrive); -static void draincmd(int port,int cdrive,int ldrive); -static int get_error(int port, int ldrive, int cdrive); -static int chk_error(int errnum); -static int msf_to_blk(unsigned char * cd); - int docmd(char *cmd, int ldrive, int cdrive, int controller, - int port); - int get_stat(int port, int ldrive); - int matcd_eject(int ldrive, int cdrive, int controller); - int media_chk(struct matcd_data *cd, int errnum, int ldrive); - int waitforit(int timelimit, int state, int port, char *where); -#ifdef FULLDRIVER -static int matcd_playtracks(int ldrive, int cdrive, int controller, - struct ioc_play_track *pt); -static int matcd_playmsf(int ldrive, int cdrive, int controller, - struct ioc_play_msf *pt); -static int matcd_pause(int ldrive, int cdrive, int controller, - struct ioc_play_msf * addr,int action); -static int matcd_stop(int ldrive, int cdrive, int controller, - struct ioc_play_msf * addr); -#endif /*FULLDRIVER*/ - - -/*---------------------------------------------------------------------- - matcdopen - Open the device - - This routine actually gets called every time anybody opens - any partition on a drive. But the first call is the one that - does all the work. - - If you #define LOCKDRIVE, the drive eject button will be ignored - while any partition on the drive is open. -----------------------------------------------------------------------*/ -int matcdopen(dev_t dev) -{ - int cdrive,ldrive,partition,controller; - struct matcd_data *cd; - int i,z,port; - unsigned char cmd[MAXCMDSIZ]; - -#if DIAGPORT == 0x302 /*<10>*/ - DIAGOUT(0x300,0x00); /*<10>Init diag board in case some - other device probe scrambled it*/ -#endif /*<10>DIAGPORT*/ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x10); /*Show where we are*/ -#endif /*DIAGPORT*/ - ldrive=matcd_ldrive(dev); - cdrive=matcd_cdrive(dev); - partition=matcd_partition(dev); - controller=matcd_controller(dev); - cd= &matcd_data[ldrive]; - port=cd->iobase; /*and port#*/ - - if (ldrive >= TOTALDRIVES) return(ENXIO); - - -#ifdef DEBUGOPEN - printf("matcd%d: Open: dev %x partition %x controller %x flags %x cdrive %x\n", - ldrive,dev,partition,controller,cd->flags,matcd_cdrive(dev)); -#endif /*DEBUGOPEN*/ - - if (!(cd->flags & MATCDINIT)) { /*Did probe find this drive*/ - return(ENXIO); - } - - if (!(cd->flags & MATCDLABEL) && - cd->openflags) { /*Has drive completely closed?*/ - return(ENXIO); /*No, all partitions must close*/ - } - - -/* Now, test to see if the media is ready -*/ - - lockbuss(controller,ldrive); - zero_cmd(cmd); - cmd[0]=NOP; /*Test drive*/ - matcd_slowcmd(port,ldrive,cdrive,cmd); - i=waitforit(10*TICKRES,DTEN,port,"matcdopen"); - z=get_stat(port,ldrive); /*Read and toss status byte*/ - unlockbuss(controller, ldrive); /*Release buss lock*/ - if ((z & MATCD_ST_DSKIN)==0) { /*Is there a disc in the drive?*/ -#ifdef DEBUGOPEN - printf("matcd%d: No Disc in open\n",ldrive); -#endif /*DEBUGOPEN*/ - return(ENXIO); - } - if (z & MATCD_ST_ERROR) { /*Was there an error*/ - i=get_error(port,ldrive,cdrive); /*Find out what it was*/ - if (cd->openflags) { /*Any parts open?*/ - if (media_chk(cd,i,ldrive)) { /*Was it a disc chg?*/ -#ifdef DEBUGOPEN - printf("matcd%d: Disc change detected i %x z %x\n", - ldrive,i,z); -#endif /*DEBUGOPEN*/ - return(ENOTTY); - } - } - } - -/* Here we fill in the disklabel structure although most is - hardcoded. -*/ - - if ((cd->flags & MATCDLABEL)==0) { - bzero(&cd->dlabel,sizeof(struct disklabel)); - - -/* Now we query the drive for the actual size of the media. - This is where we find out of there is any media or if the - media isn't a Mode 1 or Mode 2/XA disc. - See version information about Mode 2/XA support. -*/ - lockbuss(controller,ldrive); - i=matcdsize(dev); - unlockbuss(controller, ldrive); /*Release buss lock*/ -#ifdef DEBUGOPEN - printf("matcd%d: Buss unlocked in open\n",ldrive); -#endif /*DEBUGOPEN*/ - if (i < 0) { - printf("matcd%d: Could not read the disc size\n",ldrive); - return(ENXIO); - } /*matcdsize filled in rest of dlabel*/ - -/* Based on the results, fill in the variable entries in the disklabel -*/ - cd->dlabel.d_secsize=cd->blksize; - cd->dlabel.d_ncylinders=(cd->disksize/100)+1; - cd->dlabel.d_secperunit=cd->disksize; - cd->dlabel.d_partitions[0].p_size=cd->disksize; - cd->dlabel.d_checksum=dkcksum(&cd->dlabel); - - -/* Now fill in the hardcoded section -*/ - /*123456789012345678*/ - strncpy(cd->dlabel.d_typename,"Matsushita CDR ",16); - strncpy(cd->dlabel.d_packname,"(c) 1994, fdiv ",16); - cd->dlabel.d_magic=DISKMAGIC; - cd->dlabel.d_magic2=DISKMAGIC; - cd->dlabel.d_nsectors=100; - cd->dlabel.d_secpercyl=100; - cd->dlabel.d_ntracks=1; - cd->dlabel.d_interleave=1; - cd->dlabel.d_rpm=300; - cd->dlabel.d_npartitions=1; /*See note below*/ - cd->dlabel.d_partitions[0].p_offset=0; - cd->dlabel.d_partitions[0].p_fstype=9; - cd->dlabel.d_flags=D_REMOVABLE; - -/* I originally considered allowing the partition match tracks or - sessions on the media, but since you are allowed up to 99 - tracks in the RedBook world, this would not fit in with the - BSD fixed partition count scheme. So ioctls are used to shift - the track to be accessed into partition 1. -*/ - - cd->flags |= MATCDLABEL; /*Mark drive as having TOC*/ - } - -#ifdef DEBUGOPEN - printf("matcd%d open2: partition=%d disksize=%d blksize=%x flags=%x\n", - ldrive,partition,cd->disksize,cd->blksize,cd->flags); -#endif /*DEBUGOPEN*/ - -#ifdef LOCKDRIVE - if (cd->openflags==0) { - lockbuss(controller,ldrive); - zero_cmd(cmd); - cmd[0]=LOCK; /*Lock drive*/ - cmd[1]=1; - matcd_slowcmd(port,ldrive,cdrive,cmd); - i=waitforit(10*TICKRES,DTEN,port,"matcdopen"); - z=get_stat(port,ldrive);/*Read and toss status byte*/ - unlockbuss(controller, ldrive); /*Release buss lock*/ - } -#endif /*LOCKDRIVE*/ - cd->openflags |= (1<<partition);/*Mark partition open*/ - - if (partition==RAW_PART || - (partition < cd->dlabel.d_npartitions && - cd->dlabel.d_partitions[partition].p_fstype != FS_UNUSED)) { - cd->partflags[partition] |= MATCDOPEN; - if (partition == RAW_PART) { - cd->partflags[partition] |= MATCDREADRAW; - } -#ifdef DEBUGOPEN - printf("matcd%d: Open is complete\n",ldrive); -#endif /*DEBUGOPEN*/ - return(0); - } -#ifdef DEBUGOPEN - printf("matcd%d: Open FAILED\n",ldrive); -#endif /*DEBUGOPEN*/ - return(ENXIO); -} - - -/*---------------------------------------------------------------------- - matcdclose - Close the device - - Depending on how you compiled the driver, close may not - do much other than clear some driver settings. - Note that audio playback will continue. - - If you did #define LOCKDRIVE, the drive was locked when the - matcdopen call is done. If we did that, then we unlock the - drive now. -----------------------------------------------------------------------*/ - -int matcdclose(dev_t dev) -{ - int ldrive,cdrive,port,partition,controller,i,z; - struct matcd_data *cd; - unsigned char cmd[MAXCMDSIZ]; - - ldrive = matcd_ldrive(dev); - cdrive=matcd_cdrive(dev); - cd=matcd_data + ldrive; - port=cd->iobase; /*and port#*/ - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x20); /*Show where we are*/ -#endif /*DIAGPORT*/ - if (ldrive >= TOTALDRIVES) - return(ENXIO); - - partition = matcd_partition(dev); - controller=matcd_controller(dev); -#ifdef DEBUGOPEN - printf("matcd%d: Close partition=%d\n", ldrive, partition); -#endif /*DEBUGOPEN*/ - - if (!(cd->flags & MATCDINIT)) - return(ENXIO); - - cd->partflags[partition] &= ~(MATCDOPEN|MATCDREADRAW); - cd->openflags &= ~(1<<partition); -#ifdef LOCKDRIVE - if (cd->openflags==0) { - lockbuss(controller,ldrive); - zero_cmd(cmd); - cmd[0]=LOCK; /*Unlock drive*/ - matcd_slowcmd(port,ldrive,cdrive,cmd); - i=waitforit(10*TICKRES,DTEN,port,"matcdopen"); - z=get_stat(port,ldrive);/*Read and toss status byte*/ - unlockbuss(controller, ldrive); /*Release buss lock*/ - } -#endif /*LOCKDRIVE*/ - cd->flags &= ~MATCDWARN; /*Clear any warning flag*/ - return(0); -} - - -/*---------------------------------------------------------------------- - matcdstrategy - Accepts I/O requests from kernel for processing - - This routine accepts a read request block pointer (historically - but somewhat inaccurately called *bp for buffer pointer). - Various sanity checks are performed on the request. - When we are happy with the request and the state of the device, - the request is added to the queue of requests for the controller - that the drive is connected to. We support multiple controllers - so there are multiple queues. Once the request is added, we - call the matcd_start routine to start the device in case it isn't - doing something already. All I/O including ioctl requests - rely on the current request starting the next one before exiting. -----------------------------------------------------------------------*/ - -void matcdstrategy(struct buf *bp) -{ - struct matcd_data *cd; - struct buf *dp; - int s; - int ldrive,controller; - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x30); /*Show where we are*/ -#endif /*DIAGPORT*/ - ldrive=matcd_ldrive(bp->b_dev); - controller=matcd_controller(bp->b_dev); - cd= &matcd_data[ldrive]; - -#ifdef DEBUGIO - printf("matcd%d: Strategy: buf=0x%lx, block#=%ld bcount=%ld\n", - ldrive,bp,bp->b_blkno,bp->b_bcount); -#endif /*DEBUGIO*/ - - - if (ldrive >= TOTALDRIVES || bp->b_blkno < 0) { - printf("matcd%d: Bogus parameters received - kernel may be corrupted\n",ldrive); - bp->b_error=EINVAL; - bp->b_flags|=B_ERROR; - goto bad; - } - - if (!(cd->flags & MATCDLABEL)) { - bp->b_error = EIO; - goto bad; - } - - if (!(bp->b_flags & B_READ)) { - bp->b_error = EROFS; - goto bad; - } - - if (bp->b_bcount==0) /*Request is zero-length - all done*/ - goto done; - - if (matcd_partition(bp->b_dev) != RAW_PART) { - if (!(cd->flags & MATCDLABEL)) { - bp->b_error = EIO; - goto bad; - } - if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) { - goto done; - } - } else { - bp->b_pblkno=bp->b_blkno; - bp->b_resid=0; - } - - s=splbio(); /*Make sure we don't get intr'ed*/ - dp=&request_head[controller]; /*Pointer to controller queue*/ - disksort(dp,bp); /*Add new request (bp) to queue (dp - and sort the requests in a way that - may not be ideal for CD-ROM media*/ - -#ifdef DEBUGQUEUE - printf("matcd%d: Dump BP chain: -------\n",ldrive); - while (bp) { - printf("Block %d\n",bp->b_pblkno); -#ifdef FREE2 - bp=bp->b_actf; -#else /*FREE2*/ - bp=bp->av_forw; -#endif /*FREE2*/ - } - printf("matcd%d: ---------------------\n",ldrive); -#endif /*DEBUGQUEUE*/ - - matcd_start(dp); /*Ok, with our newly sorted queue, - see if we can start an I/O operation - right now*/ - splx(s); /*Return priorities to normal*/ - return; /*All done*/ - -bad: bp->b_flags |= B_ERROR; /*Request bad in some way*/ -done: bp->b_resid = bp->b_bcount; /*Show un read amount*/ - biodone(bp); /*Signal we have done all we plan to*/ - return; -} - - -/*---------------------------------------------------------------------- - matcd_start - Pull a request from the queue and consider doing it. -----------------------------------------------------------------------*/ - -static void matcd_start(struct buf *dp) -{ - struct matcd_data *cd; - struct buf *bp; - struct partition *p; - int part,ldrive,controller; - register s; - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x40); /*Show where we are*/ - diagloop=0; -#endif /*DIAGPORT*/ - if ((bp=dp->b_actf) == NULL) { /*Nothing on read queue to do?*/ - wakeup((caddr_t)&matcd_data->status); /*Wakeup any blocked*/ - return; /* opens, ioctls, etc*/ - } - - ldrive=matcd_ldrive(bp->b_dev); /*Get logical drive#*/ - cd=&matcd_data[ldrive]; /*Get pointer to data for this drive*/ - controller=matcd_controller(bp->b_dev); /*Also get interface #*/ -#ifdef DEBUGIO - printf("matcd%d: In start controller %d\n",ldrive,controller); -#endif /*DEBUGIO*/ - - if (if_state[controller] & BUSSBUSY) { -#ifdef DEBUGIO - printf("matcd%d: Dropping thread in start, controller %d\n", - ldrive,controller); -#endif /*DEBUGIO*/ - return; - } - -#ifdef FREE2 - dp->b_actf = bp->b_actf; -#else /*FREE2*/ - dp->b_actf = bp->av_forw; /*Get next request from queue*/ -#endif /*FREE2*/ - - part=matcd_partition(bp->b_dev); - p=cd->dlabel.d_partitions + part; - - if_state[controller] |= BUSSBUSY;/*Mark buss as busy*/ - cd->mbx.ldrive=ldrive; /*Save current logical drive*/ - cd->mbx.controller=controller; /*and controller*/ - cd->mbx.partition=part; /*and partition (2048 vs 2532)*/ - cd->mbx.port=cd->iobase; /*and port#*/ - cd->mbx.retry=MATCD_RETRYS; /*and the retry count*/ - cd->mbx.bp=bp; /*and the bp*/ - cd->mbx.p_offset=p->p_offset; /*and where the data will go*/ - matcd_blockread(MATCD_READ_1+ldrive); /*Actually start the read*/ - return; /*Dropping thread. matcd_blockread - must have scheduled a timeout or - we will go to sleep forever*/ -} - - -/*---------------------------------------------------------------------- - matcdioctl - Process things that aren't block reads - - In this driver, ioctls are used mainly to change - the mode the drive is running in, play audio and other - things that don't fit into the block read scheme of things. -----------------------------------------------------------------------*/ - -int matcdioctl(dev_t dev, int command, caddr_t addr, int flags) -{ - struct matcd_data *cd; - int ldrive,cdrive,partition; - int i,z; - unsigned char * p; - int port, controller; - unsigned char zz; - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x50); /*Show where we are*/ -#endif /*DIAGPORT*/ - ldrive=matcd_ldrive(dev); - cdrive=matcd_cdrive(dev); - partition=matcd_partition(dev); - controller=ldrive>>2; - cd = &matcd_data[ldrive]; - port=cd->iobase; - -#ifdef DEBUGIOCTL - printf("matcd%d: ioctl %x cdrive %x parms ",ldrive,command,cdrive); - for (i=0;i<10;i++) { - zz=addr[i]; - printf("%02x ",zz); - } - printf(" flags %x\n",cd->flags); -#endif /*DEBUGIOCTL*/ - - if (!(cd->flags & MATCDLABEL)) /*Did we read TOC OK?*/ - return(EIO); - - switch(command) { - case DIOCSBAD: /*<9>*/ - return(EINVAL); /*<9>*/ - case DIOCGDINFO: /*<9>*/ - *(struct disklabel *) addr = cd->dlabel; /*<9>*/ - return(0); /*<9>*/ - case DIOCGPART: /*<9>*/ - ((struct partinfo *) addr)->disklab=&cd->dlabel;/*<9>*/ - ((struct partinfo *) addr)->part= /*<9>*/ - &cd->dlabel.d_partitions[matcd_partition(dev)];/*<9>*/ - return(0); /*<9>*/ - case DIOCWDINFO: /*<9>*/ - case DIOCSDINFO: /*<9>*/ -#ifdef FREE2 /*<10>*/ - if ((flags & FWRITE) == 0) { /*<9>*/ - return(EBADF); /*<9>*/ - } /*<9>*/ - else { /*<9>*/ - return setdisklabel(&cd->dlabel, /*<9>*/ - (struct disklabel *) addr, 0);/*<9>*/ - } /*<9>*/ -#endif /*<10>FREE2*/ - case DIOCWLABEL: /*<9>*/ - return(EBADF); /*<9>*/ - case CDIOCEJECT: - return(matcd_eject(ldrive, cdrive, controller)); -#ifdef FULLDRIVER - case CDIOCPLAYTRACKS: - return(matcd_playtracks(ldrive, cdrive, controller, - (struct ioc_play_track *) addr)); - case CDIOCPLAYMSF: - return(matcd_playmsf(ldrive, cdrive, controller, - (struct ioc_play_msf *) addr)); - case CDIOCRESUME: - return(matcd_pause(ldrive, cdrive, controller, - (struct ioc_play_msf *) addr,RESUME)); - case CDIOCPAUSE: - return(matcd_pause(ldrive, cdrive, controller, - (struct ioc_play_msf *) addr,0)); - case CDIOCSTOP: - return(matcd_stop(ldrive, cdrive, controller, - (struct ioc_play_msf *) addr)); - - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTERIO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: -#endif /*FULLDRIVER*/ - - case CDIOCREADSUBCHANNEL: - case CDIOREADTOCHEADER: - case CDIOREADTOCENTRYS: - - case CDIOCSETPATCH: - case CDIOCSTART: - case CDIOCRESET: - return(EINVAL); - default: - return(ENOTTY); - } -} - -/*---------------------------------------------------------------------- - matcdsize - Reports how many blocks exist on the disc. -----------------------------------------------------------------------*/ - -int matcdsize(dev_t dev) -{ - int size,blksize; - int ldrive,part; - struct matcd_data *cd; - - ldrive=matcd_ldrive(dev); - part=matcd_partition(dev); - if (part==RAW_PART) - blksize=MATCDRBLK; /*2353*/ - else - blksize=MATCDBLK; /*2048*/ - - cd = &matcd_data[ldrive]; - - if (matcd_volinfo(ldrive) >= 0) { - cd->blksize=blksize; - size=msf_to_blk((char * )&cd->volinfo.vol_msf); - - cd->disksize=size*(blksize/DEV_BSIZE); -#ifdef DEBUGOPEN - printf("matcd%d: Media size %d\n",ldrive,size); -#endif /*DEBUGOPEN*/ - return(0); - } - return(-1); -} - -/*---------------------------------------------------------------------- - matcd_probe - Search for host interface/adapters - - The probe routine hunts for the first drive on the interface since - there is no way to locate just the adapter. It also resets the - entire drive chain while it is there. matcd_attach() takes care of - the rest of the initialization. - - The probe routine can be compiled two ways. In AUTOHUNT mode, - the kernel config file can say "port?" and we will check all ports - listed in the port_hint array (see above). - - Without AUTOHUNT set, the config file must list a specific port - address to check. - - Note that specifying the explicit addresses makes boot-up a lot - faster. - - The probe will locate Panasonic/Creative interface on the following - Creative adapter boards: - #1730 Sound Blaster 16 - #1740 Sound Blaster 16 (cost reduced) - #1810 omniCD upgrade kit adapter card (stand-alone CD) - #3100 PhoneBlaster SB16 + Sierra 14.4K modem combo - Creative releases a newer and cheaper-to-make Sound Blaster - board every few months, so by the original release date of this - software, there are probably 8 different board models called - Sound Blaster 16. These include "Vibra", "Value", etc. - - Please report additional part numbers and board descriptions - and new port numbers that work to the author. - -----------------------------------------------------------------------*/ - -int matcd_probe(struct isa_device *dev) -{ - int i,cdrive; - unsigned char y,z,drive; - int level; - int port = dev->id_iobase; /*Take port hint from config file*/ - cdrive=nextcontroller; /*Controller defined by pass for now*/ - -#if DIAGPORT == 0x302 /*<10>*/ - DIAGOUT(0x300,0x00); /*<10>Init diag board in case some - other device probe scrambled it*/ -#endif /*<10>DIAGPORT*/ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x60); /*Show where we are*/ -#endif /*DIAGPORT*/ - if (nextcontroller==NUMCTRLRS) { - printf("matcdc%d: - Too many interfaces specified in config\n", - nextcontroller); - return(0); - } - if (nextcontroller==0) { /*Very first time to be called*/ - for (i=0; i<TOTALDRIVES; i++) { - matcd_data[i].drivemode=MODE_UNKNOWN; - matcd_data[i].flags=0; - } - } - - i=nextcontroller*DRIVESPERC; /*Precompute controller offset*/ - for (y=0; y<DRIVESPERC; y++) { - matcd_data[i+y].flags=0; - matcd_data[i+y].config=0; - } - -#ifdef DEBUGPROBE - printf("matcdc%d: In probe i %d y %d port %x\n", - nextcontroller,i,y,port); -#endif /*DEBUGPROBE*/ -#ifdef AUTOHUNT -#ifdef DEBUGPROBE - printf("matcd%d: size of port_hints %d\n", - nextcontroller,sizeof(port_hints)); -#endif /*DEBUGPROBE*/ - if (port==-1) { - for(i=0;i<(sizeof(port_hints)/sizeof(short));i++) { - port=port_hints[i]; -#ifdef DEBUGPROBE - printf("matcdc%d: Port hint %x\n",nextcontroller,port); -#endif /*DEBUGPROBE*/ - if (port==-1) { - dev->id_iobase=-1; /*Put port ? back*/ - return(0);/*Nothing left to try*/ - } - if (port!=0) { /*Unused port found*/ - dev->id_iobase=port; - port_hints[i]=0;/*Don't use that port again*/ - if (doprobe(port,cdrive)==0) return(NUMPORTS); - } - } - dev->id_iobase=-1; /*Put port ? back as it was*/ - return(0); /*Interface not found*/ - - } else { /*Config specified a port*/ - i=0; /*so eliminate it from the hint list*/ - for(i=0;;i++) { /*or we might try to assign it again*/ - if (port_hints[i]== -1) break; /*End of list*/ - if (port_hints[i]==port) { - port_hints[i]=0; /*Clear duplicate*/ - break; - } - } - if (doprobe(port,cdrive)==0) return(NUMPORTS); - else return(0); - } -#else /*AUTOHUNT*/ - if (port==-1) { - printf("matcd%d: AUTOHUNT disabled but port? specified in config\n", - nextcontroller); - return(0); - } - if (doprobe(port,cdrive)==0) return(NUMPORTS); - else return(0); -#endif /*AUTOHUNT*/ -} - -/*---------------------------------------------------------------------- - doprobe - Common probe code that actually checks the ports we - have decided to test. -----------------------------------------------------------------------*/ - -int doprobe(int port,int cdrive) -{ - unsigned char cmd[MAXCMDSIZ]; - -#ifdef RESETONBOOT - doreset(port,cdrive); /*Reset what might be our device*/ -#endif /*RESETONBOOT*/ - - zero_cmd(cmd); - cmd[0]=NOP; /*A reasonably harmless command. - This command will fail after - power-up or after reset. That's OK*/ - if (matcd_fastcmd(port,0,0,cmd)==0) {/*Issue command*/ - inb(port+CMD); /*Read status byte*/ -#ifdef DEBUGPROBE - printf("matcdc%d: Probe found something\n",nextcontroller); -#endif /*DEBUGPROBE*/ - if (drivepresent==0) { /*Don't change this - see license*/ - printf("matcd - Matsushita (Panasonic) CD-ROM Driver by FDIV, %s\n",MATCDVERSION); - /*Don't change this - see license*/ - drivepresent++; /*Don't change this - see license*/ - } /*Don't change this - see license*/ - return(0); /*Drive 0 detected*/ - } -#ifdef DEBUGPROBE - printf("matcdc%d: Probe DID NOT find something\n",nextcontroller); -#endif /*DEBUGPROBE*/ - return(1); /*Nothing detected*/ -} - - -/*---------------------------------------------------------------------- - matcd_attach - Locates drives on the adapters that were located. - If we got here, we located a interface and at least one - drive. Now we figure out how many drives are under that - interface. The Panasonic interface is too simple to call - it a controller, but in the existing PDP model, that is - what it would be. -----------------------------------------------------------------------*/ - -int matcd_attach(struct isa_device *dev) -{ - int i; - unsigned char y,z,cdrive; - int level; - unsigned char cmd[MAXCMDSIZ]; - unsigned char data[12]; - struct matcd_data *cd; - int port = dev->id_iobase; /*Take port ID selected in probe()*/ - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x70); /*Show where we are*/ -#endif /*DIAGPORT*/ -#ifdef DEBUGPROBE - printf("matcdc: Attach dev %x id_unit %d\n",dev,dev->id_unit); -#endif /*DEBUGPROBE*/ - for (cdrive=0; cdrive<4; cdrive++) { /*We're hunting drives...*/ - zero_cmd(cmd); - cmd[0]=NOP; /*A reasonably harmless command. - This command will fail after - power-up or after reset. It's OK*/ - i=cdrive+(DRIVESPERC*nextcontroller); - if (matcd_fastcmd(port,i,cdrive,cmd)==0) { /*Issue command*/ - z=get_stat(port,cdrive);/*Read and toss status byte*/ - if ((z & MATCD_ST_ERROR)) { /*If there was an error, - we must ask for error info - or subsequent cmds fail*/ - zero_cmd(cmd); - cmd[0]=READERROR; /*Inquire*/ - matcd_fastcmd(port,i,cdrive,cmd); - matcd_pread(port,8,data);/*Read data returned*/ - z=get_stat(port,i);/*Read and toss status byte*/ -#ifdef DEBUGPROBE - printf("matcd%d: Status byte %x ",i,z); -#endif /*DEBUGPROBE*/ - } - zero_cmd(cmd); - cmd[0]=READID; /*Get drive ID*/ - matcd_fastcmd(port,i,cdrive,cmd); - matcd_pread(port,10,data);/*Read Drive Parm*/ - z=get_stat(port,i); /*Read and toss status byte*/ - data[10]=0; /*Build ASCIZ string*/ - printf("matcd%d: [%s] ",i,data); - cd=&matcd_data[i]; - cd->flags |= MATCDINIT; - cd->iobase=dev->id_iobase; - cd->openflags=0; - for (i=0; i<MAXPARTITIONS; i++) { - cd->partflags[i]=0; - } - } - } - nextcontroller++; /*Bump ctlr assign to next number*/ - printf("\n"); /*End line of drive reports*/ - return(1); -} - - -/*---------------------------------------------------------------------- - zero_cmd - Initialize command buffer -----------------------------------------------------------------------*/ - -void zero_cmd(char * lcmd) -{ - int i; - for (i=0; i<MAXCMDSIZ; lcmd[i++]=0); - return; -} - - -/*---------------------------------------------------------------------- - doreset - Resets all the drives connected to a interface -----------------------------------------------------------------------*/ - -void doreset(int port,int cdrive) -{ - register int i,z; -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x80); /*Show where we are*/ -#endif /*DIAGPORT*/ - outb(port+RESET,0); /*Reset what might be our device*/ - /*Although this ensures a known - state, it does close the drive - door (if open) and aborts any - audio playback in progress. */ - for (i=0;i<(125*ISABUSKHZ);i++){/*DELAY 500msec minimum. Worst - case is door open and none or - unreadable media */ - z=inb(port+CMD); /*This makes the loop run at a - known speed. This value is ok - for 8.33MHz bus*/ - } - for (i=0;i<4;i++) { - matcd_data[(cdrive*4)+i].drivemode=MODE_UNKNOWN; - } - return; -} - - -/*---------------------------------------------------------------------- - matcd_fastcmd - Send a command to a drive - - This routine executed commands that return instantly (or reasonably - quick), such as RESET, NOP, READ ERROR, etc. The only difference - between it and handling for slower commands, is the slower commands - will invoke a timeout/sleep if they don't get an instant response. - - Fastcmd is mainly used in probe(), attach() and error related - functions. Every attempt should be made to NOT use this - function for any command that might be executed when the system - is up. -----------------------------------------------------------------------*/ - -int matcd_fastcmd(int port,int ldrive,int cdrive,unsigned char * cp) -{ - unsigned int i; - unsigned char z; - int level; -#ifdef DEBUGCMD - unsigned char *cx; -#endif /*DEBUGCMD*/ - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0x90); /*Show where we are*/ -#endif /*DIAGPORT*/ - - - draincmd(port,cdrive,ldrive); /*Make sure buss is really idle*/ -#ifdef DEBUGCMD - cx=cp; - printf("matcd%d: Fast Send port %x sel %d command %x %x %x %x %x %x %x\n", - ldrive,port,cdrive,cx[0],cx[1],cx[2],cx[3],cx[4],cx[5],cx[6]); -#endif /*DEBUGCMD*/ - selectdrive(port,cdrive); /*Enable the desired target drive*/ - level=splhigh(); /*----------------------------------------*/ - for (i=0; i<7; i++) { /*The seven bytes of the command*/ - outb(port+CMD,*cp++); /*must be sent within 10msec or*/ - } /*the drive will ignore the cmd*/ - splx(level); /*------------------------------------------------*/ - -/* Now we wait a maximum of 240msec for a response. - Only in a few rare cases does it take this long. - If it is longer, the command should probably be slept on - rather than increasing the timing value -*/ - - for (i=0; i<(60*ISABUSKHZ); i++) { - z = (inb(port+STATUS)) & (DTEN|STEN); - if (z != (DTEN|STEN)) break; - } - -/* We are now either in a data or status phase, OR we timed-out.*/ - - if (z == (DTEN|STEN)) { -#ifdef DEBUGCMD - printf("matcd%d: Command time-out\n",ldrive); -#endif /*DEBUGCMD*/ - return(-1); - } - if (z != DTEN) { - return(1); - } - return(0); -} - - -/*---------------------------------------------------------------------- - matcd_slowcmd - Issue a command to the drive - - This routine is for commands that might take a long time, such - as a read or seek. The caller must determine if the command - completes instantly or schedule a poll later on. -----------------------------------------------------------------------*/ - -void matcd_slowcmd(int port,int ldrive,int cdrive,unsigned char * cp) -{ - unsigned int i; - unsigned char z; - int level,size; -#ifdef DEBUGCMD - unsigned char *cx; -#endif /*DEBUGCMD*/ - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xa0); /*Show where we are*/ -#endif /*DIAGPORT*/ - - draincmd(port,cdrive,ldrive); /*Make sure buss is really idle*/ - -#ifdef DEBUGCMD - cx=cp; - printf("matcd%d: Slow Send port %x sel %d command %x %x %x %x %x %x %x\n", - ldrive,port,cdrive,cx[0],cx[1],cx[2],cx[3],cx[4],cx[5],cx[6]); -#endif /*DEBUGCMD*/ - selectdrive(port,cdrive); /*Enable the desired target drive*/ - if (*cp==ABORT) size=1; - else size=7; - level=splhigh(); /*----------------------------------------*/ - for (i=0; i<size; i++) { /*The seven bytes of the command*/ - outb(port+CMD,*cp++); /*must be sent within 10msec or*/ - } /*the drive will ignore the cmd*/ - splx(level); /*------------------------------------------------*/ - return; -} - - -/*---------------------------------------------------------------------- - draincmd - Makes certain the buss is idle and throws away - any residual data from the drive if there is any. - Called as preface to most commands. - Added in Edit 5. - - This was added because switching drive modes causes - the drive to emit buffers that were meant to be sent - to the D-to-A to be sent to the host. See setmode. -----------------------------------------------------------------------*/ -void draincmd(int port,int cdrive,int ldrive) -{ - int i,z; - - i=inb(port+STATUS); - if (i==0xff) return; - - printf("matcd%d: in draincmd: buss not idle %x - trying to fix\n", - ldrive,inb(port+STATUS)); - if ((i & DTEN|STEN) == STEN) { -#ifdef DEBUGCMD - printf("matcd%d: Data present READING - ",ldrive); -#endif /*DEBUGCMD*/ - i=0; - outb(port+STATUS,1); /*Enable data read*/ - while ((inb(port+STATUS) & (DTEN|STEN)) == STEN) { - inb(port+DATA); - i++; - } - outb(port+STATUS,0); -#ifdef DEBUGCMD - printf("%d bytes read\n",i); -#endif /*DEBUGCMD*/ - } -#ifdef DEBUGCMD - printf("matcd%d: Now read status: ",ldrive); -#endif /*DEBUGCMD*/ - i=get_stat(port,ldrive); /*Read and toss status byte*/ - z=inb(port+STATUS); /*Read buss status*/ -#ifdef DEBUGCMD - printf("Data byte %x and status is now %x\n",i,z); -#endif /*DEBUGCMD*/ - if (z!=0xff) { - printf("matcd%d: Buss not idle %x - resetting\n", - cdrive,inb(port+STATUS)); - doreset(port,cdrive); - } - return; -} - - -/*---------------------------------------------------------------------- - selectdrive - Swaps drive select bits - - On Creative SB/SB16/stand-alone adapters, possibly to make them - to reverse engineer. On these boards, the drive select signals - are swapped. -----------------------------------------------------------------------*/ - -void selectdrive(int port,int drive) -{ - switch(drive) { - case 0: /*0x00 -> 0x00*/ - outb(port+SELECT,CRDRIVE0); - break; - case 1: /*0x01 -> 0x02*/ - outb(port+SELECT,CRDRIVE1); - break; - case 2: /*0x02 -> 0x01*/ - outb(port+SELECT,CRDRIVE2); - break; - case 3: /*0x03 -> 0x03*/ - outb(port+SELECT,CRDRIVE3); - break; - } - return; -} - - -/*---------------------------------------------------------------------- - matcd_pread - Read small blocks of control data from a drive -----------------------------------------------------------------------*/ - -void matcd_pread(int port, int count, unsigned char * data) -{ - int i; - - for (i=0; i<count; i++) { - *data++ = inb(port+CMD); - } - return; -} - - -/*---------------------------------------------------------------------- - matcd_setmode - Configures disc to run in the desired data mode - - This routine assumes the drive is already idle. - -NOTE - Undocumented action of hardware: If you change (or reaffirm) data - modes with MODESELECT + BLOCKPARAM immediately after a command was - issued that aborted a DA play operation, the drive will unexpectedly - return 2532 bytes of data in a data phase on the first or second - subsequent command. - - Original Symptom: drive will refuse to go idle after reading data - and status expected for a command. State mechanics for this are - not fully understood. -----------------------------------------------------------------------*/ - -int matcd_setmode(int ldrive, int mode) -{ - struct matcd_data *cd; - int retries; - int i,z,port,cdrive; - unsigned char cmd[MAXCMDSIZ]; - - cd = matcd_data + ldrive; - retries=3; - cdrive=ldrive&0x03; - port=cd->iobase; - if (cd->drivemode==mode) { - return(0); /*Drive already set*/ - } - -/* The drive is not in the right mode, so we need to set it. -*/ - - zero_cmd(cmd); - cmd[0]=MODESELECT; /*Set drive transfer modes*/ -/* cmd[1]=BLOCKPARAM; BLOCKPARAM==0*/ - cmd[2]=mode; - switch(mode) { - case MODE_DATA: - cmd[3]=0x08; /*2048 bytes*/ - break; - case MODE_USER: - cmd[3]=0x09; /*2352 bytes*/ - cmd[4]=0x30; - break; - case MODE_DA: - cmd[3]=0x09; /*2352 bytes*/ - cmd[4]=0x30; - break; - } - i=0; - while(retries-- > 0) { - i=matcd_fastcmd(port,ldrive,cdrive,cmd); - z=get_stat(port,ldrive);/*Read and toss status byte*/ - if (i==0) { - cd->drivemode=mode; /*Set new mode*/ - return(i); - } - get_error(port,ldrive,cdrive); - } - cd->drivemode=MODE_UNKNOWN; /*We failed*/ - return(i); -} - - -/*---------------------------------------------------------------------- - matcd_volinfo - Read information from disc Table of Contents -----------------------------------------------------------------------*/ - -static int matcd_volinfo(int ldrive) -{ - struct matcd_data *cd; - int port,i; - int z,cdrive; - int retry; - unsigned char cmd[MAXCMDSIZ]; - unsigned char data[12]; - - retry=5; - cd = &matcd_data[ldrive]; - cdrive=ldrive&0x03; - port=cd->iobase; - -#ifdef DEBUGOPEN - printf("matcd%d: In volinfo, port %x\n",ldrive,port); -#endif /*DEBUGOPEN*/ - - while(retry>0) { -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xB0); /*Show where we are*/ -#endif /*DIAGPORT*/ - zero_cmd(cmd); - cmd[0]=READDINFO; /*Read Disc Info*/ - matcd_slowcmd(port,ldrive,cdrive,cmd); - i=waitforit(10*TICKRES,DTEN,port,"volinfo"); - if (i) { /*THIS SHOULD NOT HAPPEN*/ - z=get_stat(port,ldrive);/*Read and toss status byte*/ - printf("matcd%d: command failed, status %x\n", - ldrive,z); - return(-1); - } - matcd_pread(port, 6, data); /*Read data returned*/ - z=get_stat(port,ldrive);/*Read and toss status byte*/ -#ifdef DEBUGOPEN - printf("matcd%d: Data got was %x %x %x %x %x %x ",ldrive, - data[0],data[1],data[2], data[3],data[4],data[5]); - printf("status byte %x\n",z); -#endif /*DEBUGOPEN*/ - if ((z & MATCD_ST_ERROR)==0) - break; /*No Error*/ - -/* If media change or other error, you have to read error data or - the drive will reject subsequent commands. -*/ - - if (chk_error(get_error(port, ldrive, cdrive))==ERR_FATAL) { -#ifdef DEBUGOPEN - printf("matcd%d: command failed, status %x\n", - ldrive,z); -#endif /*DEBUGOPEN*/ - return(-1); - } - if ((--retry)==0) return(-1); -#ifdef DEBUGOPEN - printf("matcd%d: Retrying",ldrive); -#endif /*DEBUGOPEN*/ - } -#ifdef DEBUGOPEN - printf("matcd%d: Status port %x \n",ldrive,inb(port+STATUS)); -#endif /*DEBUGOPEN*/ - - cd->volinfo.type=data[0]; - cd->volinfo.trk_high=data[2]; - cd->volinfo.trk_low=data[1]; - cd->volinfo.vol_msf[0]=data[3]; - cd->volinfo.vol_msf[1]=data[4]; - cd->volinfo.vol_msf[2]=data[5]; - - if (cd->volinfo.trk_low + cd->volinfo.trk_high) { - cd->flags |= MATCDLABEL; - return(0); - } - return(-1); -} - - -/*---------------------------------------------------------------------- - blk_to_msf - Convert block numbers into CD disk block ids -----------------------------------------------------------------------*/ - -static void blk_to_msf(int blk, unsigned char *msf) -{ - blk += 150; /*2 seconds skip required to - reach ISO data*/ - msf[0] = blk/4500; - blk %= 4500; - msf[1] = blk / 75; - msf[2] = blk % 75; - return; -} - - -/*---------------------------------------------------------------------- - msf_to_blk - Convert CD disk block ids into block numbers -----------------------------------------------------------------------*/ - -static int msf_to_blk(unsigned char * cd) -{ - return(((cd[0]*60) /*Convert MSF to*/ - +cd[1])*75 /*Blocks minus 2*/ - +cd[2]-150); /*seconds*/ -} - - -/*---------------------------------------------------------------------- - matcd_blockread - Performs actual background disc I/O operations - - This routine is handed the block number to read, issues the - command to the drive, waits for it to complete, reads the - data or error, retries if needed, and returns the results - to the host. -----------------------------------------------------------------------*/ - -static void matcd_blockread(int state) -{ - struct matcd_mbx *mbx; - int ldrive,cdrive; - int port; - struct buf *bp; - struct buf *dp; - struct matcd_data *cd; - int i,k,z; - int l,m; - struct matcd_read2 rbuf; - int blknum; - caddr_t addr; - int status; - int errtyp; - int phase; - unsigned char cmd[MAXCMDSIZ]; - -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xC0 + (diagloop * 0x100));/*Show where we are*/ -#endif /*DIAGPORT*/ - mbx = &matcd_data[state & 0x0f].mbx; - ldrive=mbx->ldrive; /*ldrive is logical drive #*/ - cdrive=ldrive & 0x03; /*cdrive is drive # on a controller*/ - port=mbx->port; /*port is base port for i/f*/ - bp= mbx->bp; - cd=&matcd_data[ldrive]; - - dp=&request_head[mbx->controller]; - -#ifdef DEBUGIO - printf("matcd%d: Show state %x cdrive %d partition %d\n", - ldrive,state,cdrive,mbx->partition); -#endif /*DEBUGIO*/ - -loop: -#ifdef DEBUGIO - printf("matcd%d: Top dp %x\n",ldrive,dp); -#endif /*DEBUGIO*/ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xCF + (diagloop * 0x100));/*Show where we are*/ -#endif /*DIAGPORT*/ - switch (state & 0xf0) { - case MATCD_READ_1: -#ifdef DEBUGIO - printf("matcd%d: State 1 cd->flags %x\n",ldrive,cd->flags); -#endif /*DEBUGIO*/ -#ifdef DIAGPORT - diagloop=0; - DIAGOUT(DIAGPORT,0xC1); /*Show where we are*/ -#endif /*DIAGPORT*/ - /* to check for raw/cooked mode */ - if (cd->partflags[mbx->partition] & MATCDREADRAW) { - mbx->sz = MATCDRBLK; - i=matcd_setmode(ldrive, MODE_DA); -#ifdef DEBUGIO - printf("matcd%d: Set MODE_DA result %d\n",ldrive,i); -#endif /*DEBUGIO*/ - } else { - mbx->sz = cd->blksize; - i=matcd_setmode(ldrive, MODE_DATA); -#ifdef DEBUGIO - printf("matcd%d: Set MODE_DATA result %d\n",ldrive,i); -#endif /*DEBUGIO*/ - } - /*for first block*/ -#ifdef DEBUGIO - printf("matcd%d: A mbx %x bp %x b_bcount %x sz %x\n", - ldrive,mbx,bp,bp->b_bcount,mbx->sz); -#endif /*DEBUGIO*/ - mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz; - mbx->skip=0; -nextblock: -#ifdef DEBUGIO - printf("matcd%d: at Nextblock b_blkno %d\n", - ldrive,bp->b_blkno); -#endif /*DEBUGIO*/ - - blknum=(bp->b_blkno / (mbx->sz/DEV_BSIZE)) - + mbx->p_offset + mbx->skip/mbx->sz; - - blk_to_msf(blknum,rbuf.start_msf); - - zero_cmd(cmd); - cmd[0]=READ; /*Get drive ID*/ - cmd[1]=rbuf.start_msf[0]; - cmd[2]=rbuf.start_msf[1]; - cmd[3]=rbuf.start_msf[2]; - cmd[6]=1; - matcd_slowcmd(port,ldrive,cdrive,cmd); - -/* Now that we have issued the command, check immediately to - see if data is ready. The drive has read-ahead caching, so - it is possible the data is already in the drive buffer. - - If the data is not ready, schedule a wakeup and later on this - code will run again to see if the data is ready then. -*/ - - case MATCD_READ_2: - state=MATCD_READ_2+ldrive; - phase = (inb(port+STATUS)) & (DTEN|STEN); -#ifdef DEBUGIO - printf("matcd%d: In state 2 status %x ",ldrive,phase); -#endif /*DEBUGIO*/ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xC2 + (diagloop++ * 0x100));/*Show where we are*/ -#endif /*DIAGPORT*/ - switch(phase) { - case (DTEN|STEN): /*DTEN==H STEN==H*/ -#ifdef DEBUGIO - printf("matcd%d: Sleeping\n",ldrive); -#endif /*DEBUGIO*/ - timeout((timeout_func_t)matcd_blockread, - (caddr_t)MATCD_READ_2+ldrive,hz/100); - return; - - - case STEN: /*DTEN=L STEN=H*/ - case 0: /*DTEN=L STEN=L*/ -#ifdef DEBUGIO - printf("matcd%d: Data Phase\n",ldrive); -#endif /*DEBUGIO*/ - outb(port+STATUS,1); /*Enable data read*/ - addr=bp->b_un.b_addr + mbx->skip; -#ifdef DEBUGIO - printf("matcd%d: Xfer Addr %x size %x", - ldrive,addr,mbx->sz); -#endif /*DEBUGIO*/ - i=0; - while(inb(port+STATUS)==0xfd) { - *addr++=inb(port+DATA); - i++; - } -#ifdef DEBUGIO - printf("matcd%d: Read %d bytes\n",ldrive,i); -#endif /*DEBUGIO*/ - outb(port+STATUS,0); /*Disable data read*/ - - -/* Now, wait for the Status phase to arrive. This will also - tell us if any went wrong with the request. -*/ - while((inb(port+STATUS)&(DTEN|STEN)) != DTEN); - status=get_stat(port,ldrive); /*Read and toss status byte*/ -#ifdef DEBUGIO - printf("matcd%d: Status port %x byte %x ", - ldrive,i,status); -#endif /*DEBUGIO*/ - if (status & MATCD_ST_ERROR) { - i=get_error(port,ldrive,cdrive); - printf("matcd%d: %s while reading block %d [Soft]\n", - ldrive,matcderrors[i],bp->b_blkno); - } - media_chk(cd,i,ldrive); - - if (--mbx->nblk > 0) { - mbx->skip += mbx->sz; - goto nextblock; /*Oooooh, you flunk the course*/ - } - bp->b_resid=0; - biodone(bp); - - unlockbuss(ldrive>>2, ldrive); /*Release buss lock*/ - matcd_start(dp); - return; - -/* Here we skipped the data phase and went directly to status. - This indicates a hard error. -*/ - - case DTEN: /*DTEN=H STEN=L*/ - status=get_stat(port,ldrive); /*Read and toss status byte*/ -#ifdef DEBUGIO - printf("matcd%d: error, status was %x\n", - ldrive,status); -#endif /*DEBUGIO*/ - -/* Ok, we need more details, so read error. This is needed to issue - any further commands anyway -*/ - - errtyp=get_error(port,ldrive,cdrive); - printf("matcd%d: %s while reading block %d\n", - ldrive,matcderrors[errtyp],bp->b_blkno); - - if (media_chk(cd,errtyp,ldrive)) - goto giveup; - - errtyp=chk_error(errtyp); - switch(errtyp) { - case ERR_RETRY: /*We can retry this error, but the - drive probably has already*/ - if (mbx->retry-- > 0 ) { - state=MATCD_READ_1+ldrive; -#ifdef DEBUGIO - printf("matcd%d: Attempting retry\n", - ldrive); -#endif /*DEBUGIO*/ - goto loop; - } - goto giveup; - -/* These errors usually indicate the user took the media from the - drive while the dev was open. We will invalidate the unit - until it closes when we see this. -*/ - case ERR_INIT:/*Media probably was removed - while the dev was open. - Invalidate the unit until - it is closed.*/ - - case ERR_FATAL:/*This type of error is so - bad we will never recover - even if we retry.*/ - default: -giveup: -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xCE + (diagloop * 0x100));/*Show where we are*/ -#endif /*DIAGPORT*/ - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - biodone(bp); - unlockbuss(ldrive>>2, ldrive); - matcd_start(dp); - return; - } - } - } -} - - -/*---------------------------------------------------------------------- - matcd_eject - Open drive tray -----------------------------------------------------------------------*/ - -int matcd_eject(int ldrive, int cdrive, int controller) -{ - int retries,i,z,port; - struct matcd_data *cd; - unsigned char cmd[MAXCMDSIZ]; - - cd=&matcd_data[ldrive]; - port=cd->iobase; /*Get I/O port base*/ - - zero_cmd(cmd); /*Initialize command buffer*/ -#ifdef LOCKDRIVE - cmd[0]=LOCK; /*Unlock drive*/ - i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/ -#endif /*LOCKDRIVE*/ - cmd[0]=DOOROPEN; /*Open Door*/ - i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/ - cd->flags &= ~MATCDLABEL; /*Mark volume info invalid*/ - return(i); /*Return result we got*/ -} - - -/*---------------------------------------------------------------------- - docmd - Get the buss, do the command, wait for completion, - attempt retries, give up the buss. - For commands that do not return data. -----------------------------------------------------------------------*/ - -int docmd(char * cmd, int ldrive, int cdrive, int controller, int port) -{ - int retries,i,z; - - lockbuss(controller, ldrive); /*Request buss*/ - retries=3; - while(retries-- > 0) { -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xD0); /*Show where we are*/ -#endif /*DIAGPORT*/ - matcd_slowcmd(port,ldrive,cdrive,cmd); - i=waitforit(80*TICKRES,DTEN,port,"cmd"); - z=get_stat(port,ldrive);/*Read and toss status byte*/ - if ((z & MATCD_ST_ERROR)==0) break; - i=chk_error(get_error(port,ldrive,cdrive)); - if (i!=ERR_INIT) { - unlockbuss(controller, ldrive); /*Release buss*/ - return(EFAULT); - } - } - unlockbuss(controller, ldrive); /*Release buss*/ - return(i); -} - - -/*---------------------------------------------------------------------- - get_error - Read the error that aborted a command. - Created in Edit 6 -----------------------------------------------------------------------*/ - -int get_error(int port, int ldrive, int cdrive) -{ - int status,errnum; - unsigned char cmd1[MAXCMDSIZ]; - unsigned char data[12]; - - zero_cmd(cmd1); - cmd1[0]=READERROR; /*Enquire*/ - matcd_fastcmd(port,ldrive,cdrive,cmd1); - matcd_pread(port, 8, data); /*Read data returned*/ - errnum=data[2]; /*Caller wants it classified*/ - status=get_stat(port,ldrive); /*Read and toss status byte*/ - -#ifdef DEBUGCMD - printf("matcd%d: Chkerror found %x on command %x addrval %x statusdata %x statusport %x\n", - ldrive,errnum,data[1],data[0],status,inb(port+STATUS)); -#endif /*DEBUGCMD*/ - return(errnum); -} - - -/*---------------------------------------------------------------------- - chk_error - Classify the error that the drive reported - Created in Edit 6 -----------------------------------------------------------------------*/ - -int chk_error(int errnum) -{ - switch(errnum) { -/* These are errors we can attempt a retry for, although the drive - has already done so. -*/ - case UNRECV_ERROR: - case SEEK_ERROR: - case TRACK_ERROR: - case FOCUS_ERROR: - case CLV_ERROR: - case DATA_ERROR: - return(ERR_RETRY); - -/* These errors usually indicate the user took the media from the - drive while the dev was open. We will invalidate the unit - until it closes when we see this. -*/ - case NOT_READY: - case MEDIA_CHANGED: - case DISC_OUT: - case HARD_RESET: - return (ERR_INIT); - -/* These errors indicate the system is confused about the drive - or media, and point to bugs in the driver or OS. These errors - cannot be retried since you will always get the same error. -*/ - - case RAM_ERROR: - case DIAG_ERROR: - case CDB_ERROR: - case END_ADDRESS: - case MODE_ERROR: - case ILLEGAL_REQ: - case ADDRESS_ERROR: - default: - return (ERR_FATAL); - } -} - - -/*---------------------------------------------------------------------- - get_stat - Reads status byte - - This routine should be totally unnecessary, performing the - task with a single line of in-line code. However in special - cases, the drives return blocks of data that are not associated - with the command in question. This appears to be a firmware - error and the rest of the driver makes an effort to avoid - triggering the fault. However, reading and throwing this - bogus data is faster and less destructive than resetting all - the drives on a given controller, plus it leaves the other drives - unaffected. -----------------------------------------------------------------------*/ - -int get_stat(int port,int ldrive) -{ - int status; - status=inb(port+DATA); /*Read the status byte, last step of cmd*/ - while ((inb(port+STATUS))!=0xff) { - printf("matcd%d: get_stat: After reading status byte, buss didn't go idle\n",ldrive); - if (( status & DTEN|STEN) == STEN) { - int k; - k=0; -#ifdef DEBUGCMD - printf("matcd%d: DATA PRESENT!!!! DISCARDING\n",ldrive); -#endif /*DEBUGCMD*/ - outb(port+STATUS,1); /*Enable data read*/ - while ((inb(port+STATUS) & (DTEN|STEN)) == STEN) { - inb(port+DATA); -/* printf("%2x ",inb(port+DATA));*/ - k++; - } - outb(port+STATUS,0); -#ifdef DEBUGCMD - printf("\nmatcd%d: BYTES READ IN DATA was %d\n", - ldrive,k); -#endif /*DEBUGCMD*/ - } - status=inb(port+DATA); /*Read the status byte again*/ -#ifdef DEBUGCMD - printf("matcd%d: Next status byte is %x\n",ldrive,status); -#endif /*DEBUGCMD*/ - } - return(status); -} - - -/*---------------------------------------------------------------------- - waitforit - Waits for a command started by slowcmd to complete. -----------------------------------------------------------------------*/ - -int waitforit(int timelimit, int state, int port, char * where) -{ - int i,j; - - j=i=0; -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xE0); /*Show where we are*/ - diagloop=0; -#endif /*DIAGPORT*/ -#ifdef DEBUGCMD - printf("matcd: waitforit port %x timelimit %x hz %x\n", - port,timelimit,hz); -#endif /*DEBUGCMD*/ - while (i<timelimit) { - j=inb(port+STATUS) & (STEN|DTEN); /*Read status*/ - if (j!=(STEN|DTEN)) break; - timeout((timeout_func_t)watchdog, (caddr_t)0,hz/100); - tsleep((caddr_t)&port_hints, PRIBIO, where, 0); - i++; -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xE1+(diagloop++ * 0x100)); /*Show where we are*/ -#endif /*DIAGPORT*/ - } -#ifdef DEBUGCMD - printf("matcd: Count was %d\n",i); -#endif /*DEBUGCMD*/ - if (j==state) return(0); /*Command complete*/ -#ifdef DEBUGCMD - printf("matcd: Timeout!"); -#endif /*DEBUGCMD*/ - return(1); /*Timeout occurred*/ -} - - -/*---------------------------------------------------------------------- - watchdog - Gives us a heartbeat for things we are waiting on -----------------------------------------------------------------------*/ - -static void watchdog(int state, char * foo) -{ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xF0); /*Show where we are*/ -#endif /*DIAGPORT*/ - wakeup((caddr_t)&port_hints); - return; -} - - -/*---------------------------------------------------------------------- - lockbuss - Wait for the buss on the requested driver interface - to go idle and acquire it. - Created in Edit 6 -----------------------------------------------------------------------*/ - -void lockbuss(int controller, int ldrive) -{ - while ((if_state[controller] & BUSSBUSY)) { -#ifdef DEBUGSLEEP - printf("matcd%d: Can't do it now - going to sleep\n, - ldrive"); -#endif /*DEBUGSLEEP*/ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xF1); /*Show where we are*/ -#endif /*DIAGPORT*/ - tsleep((caddr_t)&matcd_data->status, PRIBIO, - "matcdopen", 0); - } - if_state[controller] |= BUSSBUSY; /*It's ours NOW*/ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xF2); /*Show where we are*/ -#endif /*DIAGPORT*/ -#ifdef DEBUGSLEEP - printf("matcd%d: BUSS locked in lockbuss\n",ldrive); -#endif /*DEBUGSLEEP*/ -} - - -/*---------------------------------------------------------------------- - lockbuss - Wait for the buss on the requested driver interface - to go idle and acquire it. - Created in Edit 6 -----------------------------------------------------------------------*/ - -void unlockbuss(int controller, int ldrive) -{ -#ifdef DIAGPORT - DIAGOUT(DIAGPORT,0xF4); /*Show where we are*/ -#endif /*DIAGPORT*/ - if_state[controller] &= ~BUSSBUSY; -#ifdef DEBUGSLEEP - printf("matcd%d: bussunlocked\n",ldrive); -#endif /*DEBUGSLEEP*/ - wakeup((caddr_t)&matcd_data->status); /*Wakeup other users*/ - matcd_start(&request_head[controller]); /*Wake up any block I/O*/ -} - - -/*---------------------------------------------------------------------- - media_chk - Checks error for types related to media - changes. -----------------------------------------------------------------------*/ - -int media_chk(struct matcd_data *cd,int errnum,int ldrive) -{ - if (errnum==NOT_READY || - errnum==MEDIA_CHANGED || - errnum==HARD_RESET || - errnum==DISC_OUT) { - cd->flags &= ~MATCDLABEL; /*Mark label as invalid*/ - - if ((cd->flags & MATCDWARN)==0) { /*Have we said this*/ - printf("matcd%d: Media changed - Further I/O aborted until device closed\n",ldrive); - cd->flags |= MATCDWARN; - } - return(1); - } - return(0); -} - - -/*---------------------------------------------------------------------- - The following functions are related to the audio playback - capabilities of the drive. They can be omitted from the - finished driver using the FULLDRIVER conditional. - - The full set of features the drive is capable of are currently - not implemented but will be added in an upcoming release. -----------------------------------------------------------------------*/ -#ifdef FULLDRIVER -/*---------------------------------------------------------------------- - matcd_playtracks - Plays one or more audio tracks -----------------------------------------------------------------------*/ - -static int matcd_playtracks(int ldrive, int cdrive, int controller, - struct ioc_play_track *pt) -{ - struct matcd_data *cd; - int start,end; - int i,port; - unsigned char cmd[MAXCMDSIZ]; - - cd=&matcd_data[ldrive]; - port=cd->iobase; - - if ((cd->flags & MATCDLABEL)==0) - return(EIO); /*Refuse after chg error*/ - - start=pt->start_track; - end=pt->end_track; - - if (start < 1 || /*Starting track valid?*/ - end < 1 || /*Ending track valid?*/ - start > end || /*Start higher than end?*/ - end > cd->volinfo.trk_high) /*End track higher than disc size?*/ - return(ESPIPE); /*Track out of range*/ - - lockbuss(controller, ldrive); /*Request buss*/ - i=matcd_setmode(ldrive, MODE_DA);/*Force drive into audio mode*/ - unlockbuss(controller, ldrive); /*Release buss*/ - if (i!=0) { - return(i); /*Not legal for this media?*/ - } - zero_cmd(cmd); - cmd[0]=PLAYTRKS; /*Play Audio Track/Index*/ - cmd[1]=start; - cmd[2]=pt->start_index; - cmd[3]=end; - cmd[4]=pt->end_index; - i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/ -#ifdef DEBUGIOCTL - printf("matcd%d: Play track results %d \n",ldrive,i); -#endif /*DEBUGIOCTL*/ - return(i); -} - - -/*---------------------------------------------------------------------- - matcd_playmsf - Plays between a range of blocks -----------------------------------------------------------------------*/ - -static int matcd_playmsf(int ldrive, int cdrive, int controller, - struct ioc_play_msf *pt) -{ - struct matcd_data *cd; - int i,port; - unsigned char cmd[MAXCMDSIZ]; - - cd=&matcd_data[ldrive]; - port=cd->iobase; - -#ifdef DEBUGIOCTL - printf("matcd%d: playmsf %2x %2x %2x -> %2x %2x %2x\n", - ldrive,pt->start_m, pt->start_s, pt->start_f, pt->end_m, - pt->end_s,pt->end_f); -#endif /*DEBUGIOCTL*/ - - if ((cd->flags & MATCDLABEL)==0) - return(EIO); /*Refuse after chg error*/ - - if ((cd->volinfo.vol_msf[0]==0 && - cd->volinfo.vol_msf[1]<2) || /*Must be after 0'1"75F*/ - msf_to_blk((char *)&pt->start_m) > - msf_to_blk((char *)&cd->volinfo.vol_msf)) { -#ifdef DEBUGIOCTL - printf("matcd%d: Invalid block combination\n",ldrive); -#endif /*DEBUGIOCTL*/ - return(ESPIPE); /*Track out of range*/ - } - - - lockbuss(controller, ldrive); /*Request buss*/ - i=matcd_setmode(ldrive, MODE_DA);/*Force drive into audio mode*/ - unlockbuss(controller, ldrive); /*Release buss*/ - if (i!=0) { - return(i); /*Not legal for this media?*/ - } - zero_cmd(cmd); - cmd[0]=PLAYBLOCKS; /*Play Audio Blocks*/ - cmd[1]=pt->start_m; - cmd[2]=pt->start_s; - cmd[3]=pt->start_f; - cmd[4]=pt->end_m; - cmd[5]=pt->end_s; - cmd[6]=pt->end_f; - i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/ - return(i); -} - - -/*---------------------------------------------------------------------- - matcd_pause - Pause or Resume audio playback -----------------------------------------------------------------------*/ - -static int matcd_pause(int ldrive, int cdrive, int controller, - struct ioc_play_msf * addr,int action) -{ - struct matcd_data *cd; - int i,port; - unsigned char cmd[MAXCMDSIZ]; - - cd=&matcd_data[ldrive]; - port=cd->iobase; - - if ((cd->flags & MATCDLABEL)==0) - return(EIO); /*Refuse after chg error*/ - - zero_cmd(cmd); - cmd[0]=PAUSE; /*Pause or Resume playing audio*/ - cmd[1]=action; - i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/ -#ifdef DEBUGIOCTL - printf("matcd%d: Pause / Resume results %d \n",ldrive,i); -#endif /*DEBUGIOCTL*/ - return(i); -} - - -/*---------------------------------------------------------------------- - matcd_stop - Stop audio playback -----------------------------------------------------------------------*/ - -static int matcd_stop(int ldrive, int cdrive, int controller, - struct ioc_play_msf * addr) -{ - struct matcd_data *cd; - int i,port; - unsigned char cmd[MAXCMDSIZ]; - - cd=&matcd_data[ldrive]; - port=cd->iobase; - - if ((cd->flags & MATCDLABEL)==0) - return(EIO); /*Refuse after chg error*/ - - zero_cmd(cmd); - cmd[0]=ABORT; /*Abort playing audio*/ - i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/ -#ifdef DEBUGIOCTL - printf("matcd%d: Abort results %d \n",ldrive,i); -#endif /*DEBUGIOCTL*/ - return(i); -} - -#endif /*FULLDRIVER*/ - -/*End of matcd.c*/ - diff --git a/sys/i386/isa/matcd.h b/sys/i386/isa/matcd.h deleted file mode 100644 index 827f0a9..0000000 --- a/sys/i386/isa/matcd.h +++ /dev/null @@ -1,183 +0,0 @@ -/*matcd.h--------------------------------------------------------------------- - Matsushita(Panasonic) / Creative CD-ROM Driver (matcd) - Authored by Frank Durda IV - - Copyright 1994, 1995 Frank Durda IV. All rights reserved. - "FDIV" is a trademark of Frank Durda IV. - - - 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 positioned at the very beginning of this file without - modification, all copyright strings, all related programming - codes that display the copyright strings, this list of - conditions and the following disclaimer. - 2. Redistributions in binary form must contain all copyright strings - and related programming code that display the copyright strings. - 3. 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. - 4. All advertising materials mentioning features or use of this - software must display the following acknowledgement: - "The Matsushita/Panasonic CD-ROM driver was developed - by Frank Durda IV for use with "FreeBSD" and similar - operating systems." - "Similar operating systems" includes mainly non-profit oriented - systems for research and education, including but not restricted - to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the - acknowledgement (in electronic form or printed text) may not be - changed without permission from the author. - 5. Absolutely no warranty of function, fitness or purpose is made - by the author Frank Durda IV. - 6. Neither the name of the author nor the name "FreeBSD" may - be used to endorse or promote products derived from this software - without specific prior written permission. - (The author can be reached at bsdmail@nemesis.lonestar.org) - 7. The product containing this software must meet all of these - conditions even if it is unsupported, not a complete system - and/or does not contain compiled code. - 8. These conditions will be in force for the full life of the - copyright. - 9. If all the above conditions are met, modifications to other - parts of this file may be freely made, although any person - or persons making changes do not receive the right to add their - name or names to the copyright strings and notices in this - software. Persons making changes are encouraged to insert edit - history in matcd.c and to put your name and details of the - change there. - 10. You must have prior written permission from the author to - deviate from these terms. - - Vendors who produce product(s) containing this code are encouraged - (but not required) to provide copies of the finished product(s) to - the author and to correspond with the author about development - activity relating to this code. Donations of development hardware - and/or software are also welcome. (This is one of the faster ways - to get a driver developed for a device.) - - THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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. ------------------------------------------------------------------------------ -See matcd.c for Edit History information. - - - Matsushita CR562/CR563 Commands - This is not a complete list - just the ones this version uses -*/ - -#define NOP 0x05 /*No action - just return status*/ -#define DOOROPEN 0x06 /*Open tray*/ -#define DOORCLOSE 0x07 /*Close tray*/ -#define ABORT 0x08 /*Abort command*/ -#define MODESELECT 0x09 /*Set drive parameters*/ -#define LOCK 0x0c /*Prevent/Allow medium removal*/ -#define PAUSE 0x0d /*Pause/Resume playback*/ -#define PLAYBLOCKS 0x0e /*Play audio - block to block*/ -#define PLAYTRKS 0x0f /*Play audio - tracks & index*/ -#define READ 0x10 /*Read data*/ -#define READERROR 0x82 /*Read Error*/ -#define READID 0x83 /*Read Drive Type & Firmware Info*/ -#define READDINFO 0x8b /*Read TOC tracks & drive size*/ - -#define BLOCKPARAM 0x00 /*Used with MODESELECT command*/ -#define RESUME 0x80 /*Used with PAUSE command*/ - -#define MAXCMDSIZ 12 /*Max command size with NULL*/ - -/* Possible data transfers for MODESELECT + BLOCKPARAM */ - -#define MODE_DATA 0x00 /*2048, 2340*/ -#define MODE_DA 0x82 /*2352*/ -#define MODE_USER 0x01 /*2048, 2052, 2336, 2340, 2352*/ -#define MODE_UNKNOWN 0xff /*Uninitialized state*/ - -/*The following two modes are not implemented in the driver at this time*/ - -#define MODE_XA 0x81 /*2048, 2060, 2324, 2336, 2340, 2352*/ - - -/* Matsushita CR562/CR563 Status bits*/ - -#define MATCD_ST_DOOROPEN 0x80 /*Door is open right now*/ -#define MATCD_ST_DSKIN 0x40 /*Disc in drive*/ -#define MATCD_ST_SPIN 0x20 /*Disc is spinning*/ -#define MATCD_ST_ERROR 0x10 /*Error on command*/ -#define MATCD_ST_BUSY 0x04 /*Drive is busy*/ -#define MATCD_ST_AUDIOBSY 0x02 /*Drive is playing audio*/ - -#define MATCDAUDIOBSY MATCD_ST_AUDIOBSY -#define MATCDDSKCHNG MATCD_ST_DSKCHNG -#define MATCDDSKIN MATCD_ST_DSKIN -#define MATCDDOOROPEN MATCD_ST_DOOROPEN - - -/* Error codes returned from READERROR command.*/ - -#define NO_ERROR 0x00 -#define RECV_RETRY 0x01 -#define RECV_ECC 0x02 -#define NOT_READY 0x03 -#define TOC_ERROR 0x04 -#define UNRECV_ERROR 0x05 -#define SEEK_ERROR 0x06 -#define TRACK_ERROR 0x07 -#define RAM_ERROR 0x08 -#define DIAG_ERROR 0x09 -#define FOCUS_ERROR 0x0a -#define CLV_ERROR 0x0b -#define DATA_ERROR 0x0c -#define ADDRESS_ERROR 0x0d -#define CDB_ERROR 0x0e -#define END_ADDRESS 0x0f -#define MODE_ERROR 0x10 -#define MEDIA_CHANGED 0x11 -#define HARD_RESET 0x12 -#define ROM_ERROR 0x13 -#define CMD_ERROR 0x14 -#define DISC_OUT 0x15 -#define HARD_ERROR 0x16 -#define ILLEGAL_REQ 0x17 - - -/* Human-readable error messages - what a concept!*/ - -static unsigned char * matcderrors[]={"No error", /* 00 */ - "Soft read error after retry", /* 01 */ - "Soft read error after error-correction", /* 02 */ - "Not ready", /* 03 */ - "Unable to read TOC", /* 04 */ - "Hard read error of data track",/* 05 */ - "Seek did not complete", /* 06 */ - "Tracking servo failure", /* 07 */ - "Drive RAM failure", /* 08 */ - "Drive self-test failed", /* 09 */ - "Focusing servo failure", /* 0a */ - "Spindle servo failure", /* 0b */ - "Data path failure", /* 0c */ - "Illegal logical block address",/* 0d */ - "Illegal field in CDB", /* 0e */ - "End of user encountered on this track", /* 0f */ - "Illegal data mode for this track", /* 10 */ - "Media changed", /* 11 */ - "Power-on or drive reset occurred", /* 12 */ - "Drive ROM failure", /* 13 */ - "Illegal drive command received from host",/* 14 */ - "Disc removed during operation",/* 15 */ - "Drive Hardware error", /* 16 */ - "Illegal request from host"}; /* 17 */ - -/*End of matcd.h*/ - - diff --git a/sys/i386/isa/matcd/matcd.h b/sys/i386/isa/matcd/matcd.h deleted file mode 100644 index 8802149..0000000 --- a/sys/i386/isa/matcd/matcd.h +++ /dev/null @@ -1,198 +0,0 @@ -/*matcd.h--------------------------------------------------------------------- - - Matsushita(Panasonic) / Creative CD-ROM Driver (matcd) - Authored by Frank Durda IV - - Copyright 1994, 1995 Frank Durda IV. All rights reserved. - "FDIV" is a trademark of Frank Durda IV. - - - 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 positioned at the very beginning of this file without - modification, all copyright strings, all related programming - codes that display the copyright strings, this list of - conditions and the following disclaimer. - 2. Redistributions in binary form must contain all copyright strings - and related programming code that display the copyright strings. - 3. 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. - 4. All advertising materials mentioning features or use of this - software must display the following acknowledgement: - "The Matsushita/Panasonic CD-ROM driver was developed - by Frank Durda IV for use with "FreeBSD" and similar - operating systems." - "Similar operating systems" includes mainly non-profit oriented - systems for research and education, including but not restricted - to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the - acknowledgement (in electronic form or printed text) may not be - changed without permission from the author. - 5. Absolutely no warranty of function, fitness or purpose is made - by the author Frank Durda IV. - 6. Neither the name of the author nor the name "FreeBSD" may - be used to endorse or promote products derived from this software - without specific prior written permission. - (The author can be reached at bsdmail@nemesis.lonestar.org) - 7. The product containing this software must meet all of these - conditions even if it is unsupported, not a complete system - and/or does not contain compiled code. - 8. These conditions will be in force for the full life of the - copyright. - 9. If all the above conditions are met, modifications to other - parts of this file may be freely made, although any person - or persons making changes do not receive the right to add their - name or names to the copyright strings and notices in this - software. Persons making changes are encouraged to insert edit - history in matcd.c and to put your name and details of the - change there. - 10. You must have prior written permission from the author to - deviate from these terms. - - Vendors who produce product(s) containing this code are encouraged - (but not required) to provide copies of the finished product(s) to - the author and to correspond with the author about development - activity relating to this code. Donations of development hardware - and/or software are also welcome. (This is one of the faster ways - to get a driver developed for a device.) - - THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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. - - ------No changes are allowed above this line------------------------------------ - -See matcd.c for Edit History information. - - - Matsushita CR562/CR563 Commands - This is not a complete list - just the ones this version uses -*/ - -#define NOP 0x05 /*No action - just return status*/ -#define DOOROPEN 0x06 /*Open tray*/ -#define DOORCLOSE 0x07 /*Close tray*/ -#define ABORT 0x08 /*Abort command*/ -#define MODESELECT 0x09 /*Set drive parameters*/ -#define LOCK 0x0c /*Prevent/Allow medium removal*/ -#define PAUSE 0x0d /*Pause/Resume playback*/ -#define PLAYBLOCKS 0x0e /*Play audio - block to block*/ -#define PLAYTRKS 0x0f /*Play audio - tracks & index*/ -#define READ 0x10 /*Read data*/ -#define READERROR 0x82 /*Read Error*/ -#define READID 0x83 /*Read Drive Type & Firmware Info*/ -#define MODESENSE 0x84 /*<12>Report drive settings*/ -#define READSUBQ 0x87 /*<14>Read Q channel information*/ -#define READDINFO 0x8b /*<13>Read TOC tracks & drive size*/ -#define READTOC 0x8c /*<13>Read entry from TOC*/ - -#define BLOCKPARAM 0x00 /*Used with MODESELECT command*/ -#define SPEEDPARM 0x03 /*<12>Adjust audio playback speed*/ -#define AUDIOPARM 0x05 /*<12>Set/read audio levels & routing*/ -#define RESUME 0x80 /*Used with PAUSE command*/ - -#define MAXCMDSIZ 12 /*Max command size with NULL*/ - -/* Possible data transfers for MODESELECT + BLOCKPARAM */ - -#define MODE_DATA 0x00 /*2048, 2340*/ -#define MODE_DA 0x82 /*2352*/ -#define MODE_USER 0x01 /*2048, 2052, 2336, 2340, 2352*/ -#define MODE_UNKNOWN 0xff /*Uninitialized state*/ - -/*<12>The following mode is not implemented in the driver at this time*/ - -#define MODE_XA 0x81 /*2048, 2060, 2324, 2336, 2340, 2352*/ - -#define DEFVOL 0xff /*<12>Default drive volume level, 100% - volume. Based on drive action.*/ -#define OUTLEFT 0x01 /*Output on Left*/ -#define OUTRIGHT 0x02 /*Output on Right*/ - -/* Matsushita CR562/CR563 Status bits*/ - -#define MATCD_ST_DOOROPEN 0x80 /*Door is open right now*/ -#define MATCD_ST_DSKIN 0x40 /*Disc in drive*/ -#define MATCD_ST_SPIN 0x20 /*Disc is spinning*/ -#define MATCD_ST_ERROR 0x10 /*Error on command*/ -#define MATCD_ST_AUDIOBSY 0x08 /*Drive is playing audio*/ -#define MATCD_ST_LOCK 0x04 /*<14>Drive is locked*/ -#define MATCD_ST_X2 0x02 /*<14>Media is at double-speed*/ -#define MATCD_ST_READY 0x01 /*<14>Drive is ready*/ - -#define MATCDAUDIOBSY MATCD_ST_AUDIOBSY -#define MATCDDSKCHNG MATCD_ST_DSKCHNG -#define MATCDDSKIN MATCD_ST_DSKIN -#define MATCDDOOROPEN MATCD_ST_DOOROPEN - - -/* Error codes returned from READERROR command.*/ - -#define NO_ERROR 0x00 -#define RECV_RETRY 0x01 -#define RECV_ECC 0x02 -#define NOT_READY 0x03 -#define TOC_ERROR 0x04 -#define UNRECV_ERROR 0x05 -#define SEEK_ERROR 0x06 -#define TRACK_ERROR 0x07 -#define RAM_ERROR 0x08 -#define DIAG_ERROR 0x09 -#define FOCUS_ERROR 0x0a -#define CLV_ERROR 0x0b -#define DATA_ERROR 0x0c -#define ADDRESS_ERROR 0x0d -#define CDB_ERROR 0x0e -#define END_ADDRESS 0x0f -#define MODE_ERROR 0x10 -#define MEDIA_CHANGED 0x11 -#define HARD_RESET 0x12 -#define ROM_ERROR 0x13 -#define CMD_ERROR 0x14 -#define DISC_OUT 0x15 -#define HARD_ERROR 0x16 -#define ILLEGAL_REQ 0x17 - - -/* Human-readable error messages - what a concept!*/ - -static unsigned char * matcderrors[]={"No error", /* 00 */ - "Soft read error after retry", /* 01 */ - "Soft read error after error-correction", /* 02 */ - "Not ready", /* 03 */ - "Unable to read TOC", /* 04 */ - "Hard read error of data track",/* 05 */ - "Seek did not complete", /* 06 */ - "Tracking servo failure", /* 07 */ - "Drive RAM failure", /* 08 */ - "Drive self-test failed", /* 09 */ - "Focusing servo failure", /* 0a */ - "Spindle servo failure", /* 0b */ - "Data path failure", /* 0c */ - "Illegal logical block address",/* 0d */ - "Illegal field in CDB", /* 0e */ - "End of user encountered on this track", /* 0f */ - "Illegal data mode for this track", /* 10 */ - "Media changed", /* 11 */ - "Power-on or drive reset occurred", /* 12 */ - "Drive ROM failure", /* 13 */ - "Illegal drive command received from host",/* 14 */ - "Disc removed during operation",/* 15 */ - "Drive Hardware error", /* 16 */ - "Illegal request from host"}; /* 17 */ - -/*End of matcd.h*/ - - diff --git a/sys/i386/isa/npx.c.orig b/sys/i386/isa/npx.c.orig deleted file mode 100644 index dd425d7..0000000 --- a/sys/i386/isa/npx.c.orig +++ /dev/null @@ -1,555 +0,0 @@ -/*- - * Copyright (c) 1990 William Jolitz. - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * 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. - * - * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.11 1994/09/09 23:12:32 wollman Exp $ - */ - -#include "npx.h" -#if NNPX > 0 - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/proc.h> -#include <machine/cpu.h> -#include <machine/pcb.h> -#include <machine/trap.h> -#include <sys/ioctl.h> -#include <machine/specialreg.h> -#include <i386/isa/icu.h> -#include <i386/isa/isa_device.h> -#include <i386/isa/isa.h> - -/* - * 387 and 287 Numeric Coprocessor Extension (NPX) Driver. - */ - -#ifdef __GNUC__ - -#define disable_intr() __asm("cli") -#define enable_intr() __asm("sti") -#define fldcw(addr) __asm("fldcw %0" : : "m" (*addr)) -#define fnclex() __asm("fnclex") -#define fninit() __asm("fninit") -#define fnsave(addr) __asm("fnsave %0" : "=m" (*addr) : "0" (*addr)) -#define fnstcw(addr) __asm("fnstcw %0" : "=m" (*addr) : "0" (*addr)) -#define fnstsw(addr) __asm("fnstsw %0" : "=m" (*addr) : "0" (*addr)) -#define fp_divide_by_0() __asm("fldz; fld1; fdiv %st,%st(1); fwait") -#define frstor(addr) __asm("frstor %0" : : "m" (*addr)) -#define fwait() __asm("fwait") -#define read_eflags() ({u_long ef; \ - __asm("pushf; popl %0" : "=a" (ef)); \ - ef; }) -#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \ - : : "n" (CR0_TS) : "ax") -#define stop_emulating() __asm("clts") -#define write_eflags(ef) __asm("pushl %0; popf" : : "a" ((u_long) ef)) - -#else /* not __GNUC__ */ - -void disable_intr __P((void)); -void enable_intr __P((void)); -void fldcw __P((caddr_t addr)); -void fnclex __P((void)); -void fninit __P((void)); -void fnsave __P((caddr_t addr)); -void fnstcw __P((caddr_t addr)); -void fnstsw __P((caddr_t addr)); -void fp_divide_by_0 __P((void)); -void frstor __P((caddr_t addr)); -void fwait __P((void)); -u_long read_eflags __P((void)); -void start_emulating __P((void)); -void stop_emulating __P((void)); -void write_eflags __P((u_long ef)); - -#endif /* __GNUC__ */ - -typedef u_char bool_t; - -extern struct gate_descriptor idt[]; - -int npxdna __P((void)); -void npxexit __P((struct proc *p)); -void npxinit __P((u_int control)); -void npxintr __P((struct intrframe frame)); -void npxsave __P((struct save87 *addr)); -static int npxattach __P((struct isa_device *dvp)); -static int npxprobe __P((struct isa_device *dvp)); -static int npxprobe1 __P((struct isa_device *dvp)); - -struct isa_driver npxdriver = { - npxprobe, npxattach, "npx", -}; - -u_int npx0_imask; -struct proc *npxproc; - -static bool_t npx_ex16; -static bool_t npx_exists; -int hw_float; -static struct gate_descriptor npx_idt_probeintr; -static int npx_intrno; -static volatile u_int npx_intrs_while_probing; -static bool_t npx_irq13; -static volatile u_int npx_traps_while_probing; - -/* - * Special interrupt handlers. Someday intr0-intr15 will be used to count - * interrupts. We'll still need a special exception 16 handler. The busy - * latch stuff in probintr() can be moved to npxprobe(). - */ -void probeintr(void); -asm -(" - .text -_probeintr: - ss - incl _npx_intrs_while_probing - pushl %eax - movb $0x20,%al # EOI (asm in strings loses cpp features) - outb %al,$0xa0 # IO_ICU2 - outb %al,$0x20 #IO_ICU1 - movb $0,%al - outb %al,$0xf0 # clear BUSY# latch - popl %eax - iret -"); - -void probetrap(void); -asm -(" - .text -_probetrap: - ss - incl _npx_traps_while_probing - fnclex - iret -"); - -/* - * Probe routine. Initialize cr0 to give correct behaviour for [f]wait - * whether the device exists or not (XXX should be elsewhere). Set flags - * to tell npxattach() what to do. Modify device struct if npx doesn't - * need to use interrupts. Return 1 if device exists. - */ -static int -npxprobe(dvp) - struct isa_device *dvp; -{ - int result; - u_long save_eflags; - u_char save_icu1_mask; - u_char save_icu2_mask; - struct gate_descriptor save_idt_npxintr; - struct gate_descriptor save_idt_npxtrap; - /* - * This routine is now just a wrapper for npxprobe1(), to install - * special npx interrupt and trap handlers, to enable npx interrupts - * and to disable other interrupts. Someday isa_configure() will - * install suitable handlers and run with interrupts enabled so we - * won't need to do so much here. - */ - npx_intrno = NRSVIDT + ffs(dvp->id_irq) - 1; - save_eflags = read_eflags(); - disable_intr(); - save_icu1_mask = inb(IO_ICU1 + 1); - save_icu2_mask = inb(IO_ICU2 + 1); - save_idt_npxintr = idt[npx_intrno]; - save_idt_npxtrap = idt[16]; - outb(IO_ICU1 + 1, ~(IRQ_SLAVE | dvp->id_irq)); - outb(IO_ICU2 + 1, ~(dvp->id_irq >> 8)); - setidt(16, probetrap, SDT_SYS386TGT, SEL_KPL); - setidt(npx_intrno, probeintr, SDT_SYS386IGT, SEL_KPL); - npx_idt_probeintr = idt[npx_intrno]; - enable_intr(); - result = npxprobe1(dvp); - disable_intr(); - outb(IO_ICU1 + 1, save_icu1_mask); - outb(IO_ICU2 + 1, save_icu2_mask); - idt[npx_intrno] = save_idt_npxintr; - idt[16] = save_idt_npxtrap; - write_eflags(save_eflags); - return (result); -} - -static int -npxprobe1(dvp) - struct isa_device *dvp; -{ - int control; - int status; -#ifdef lint - npxintr(); -#endif - /* - * Partially reset the coprocessor, if any. Some BIOS's don't reset - * it after a warm boot. - */ - outb(0xf1, 0); /* full reset on some systems, NOP on others */ - outb(0xf0, 0); /* clear BUSY# latch */ - /* - * Prepare to trap all ESC (i.e., NPX) instructions and all WAIT - * instructions. We must set the CR0_MP bit and use the CR0_TS - * bit to control the trap, because setting the CR0_EM bit does - * not cause WAIT instructions to trap. It's important to trap - * WAIT instructions - otherwise the "wait" variants of no-wait - * control instructions would degenerate to the "no-wait" variants - * after FP context switches but work correctly otherwise. It's - * particularly important to trap WAITs when there is no NPX - - * otherwise the "wait" variants would always degenerate. - * - * Try setting CR0_NE to get correct error reporting on 486DX's. - * Setting it should fail or do nothing on lesser processors. - */ - load_cr0(rcr0() | CR0_MP | CR0_NE); - /* - * But don't trap while we're probing. - */ - stop_emulating(); - /* - * Finish resetting the coprocessor, if any. If there is an error - * pending, then we may get a bogus IRQ13, but probeintr() will handle - * it OK. Bogus halts have never been observed, but we enabled - * IRQ13 and cleared the BUSY# latch early to handle them anyway. - */ - fninit(); - DELAY(1000); /* wait for any IRQ13 (fwait might hang) */ -#ifdef DIAGNOSTIC - if (npx_intrs_while_probing != 0) - printf("fninit caused %u bogus npx interrupt(s)\n", - npx_intrs_while_probing); - if (npx_traps_while_probing != 0) - printf("fninit caused %u bogus npx trap(s)\n", - npx_traps_while_probing); -#endif - /* - * Check for a status of mostly zero. - */ - status = 0x5a5a; - fnstsw(&status); - if ((status & 0xb8ff) == 0) { - /* - * Good, now check for a proper control word. - */ - control = 0x5a5a; - fnstcw(&control); - if ((control & 0x1f3f) == 0x033f) { - hw_float = npx_exists = 1; - /* - * We have an npx, now divide by 0 to see if exception - * 16 works. - */ - control &= ~(1 << 2); /* enable divide by 0 trap */ - fldcw(&control); - npx_traps_while_probing = npx_intrs_while_probing = 0; - fp_divide_by_0(); - if (npx_traps_while_probing != 0) { - /* - * Good, exception 16 works. - */ - npx_ex16 = 1; - dvp->id_irq = 0; /* zap the interrupt */ - /* - * special return value to flag that we do not - * actually use any I/O registers - */ - return (-1); - } - if (npx_intrs_while_probing != 0) { - /* - * Bad, we are stuck with IRQ13. - */ - npx_irq13 = 1; - npx0_imask = dvp->id_irq; /* npxattach too late */ - return (IO_NPXSIZE); - } - /* - * Worse, even IRQ13 is broken. Use emulator. - */ - } - } - /* - * Probe failed, but we want to get to npxattach to initialize the - * emulator and say that it has been installed. XXX handle devices - * that aren't really devices better. - */ - dvp->id_irq = 0; - /* - * special return value to flag that we do not - * actually use any I/O registers - */ - return (-1); -} - -/* - * Attach routine - announce which it is, and wire into system - */ -int -npxattach(dvp) - struct isa_device *dvp; -{ - if (!npx_ex16 && !npx_irq13) { - if (npx_exists) { - printf("npx%d: Error reporting broken, using 387 emulator\n",dvp->id_unit); - hw_float = npx_exists = 0; - } else { - printf("npx%d: 387 Emulator\n",dvp->id_unit); - } - } - npxinit(__INITIAL_NPXCW__); - return (1); /* XXX unused */ -} - -/* - * Initialize floating point unit. - */ -void -npxinit(control) - u_int control; -{ - struct save87 dummy; - - if (!npx_exists) - return; - /* - * fninit has the same h/w bugs as fnsave. Use the detoxified - * fnsave to throw away any junk in the fpu. fnsave initializes - * the fpu and sets npxproc = NULL as important side effects. - */ - npxsave(&dummy); - stop_emulating(); - fldcw(&control); - if (curpcb != NULL) - fnsave(&curpcb->pcb_savefpu); - start_emulating(); -} - -/* - * Free coprocessor (if we have it). - */ -void -npxexit(p) - struct proc *p; -{ - - if (p == npxproc) { - start_emulating(); - npxproc = NULL; - } -} - -/* - * Record the FPU state and reinitialize it all except for the control word. - * Then generate a SIGFPE. - * - * Reinitializing the state allows naive SIGFPE handlers to longjmp without - * doing any fixups. - * - * XXX there is currently no way to pass the full error state to signal - * handlers, and if this is a nested interrupt there is no way to pass even - * a status code! So there is no way to have a non-naive SIGFPE handler. At - * best a handler could do an fninit followed by an fldcw of a static value. - * fnclex would be of little use because it would leave junk on the FPU stack. - * Returning from the handler would be even less safe than usual because - * IRQ13 exception handling makes exceptions even less precise than usual. - */ -void -npxintr(frame) - struct intrframe frame; -{ - int code; - - if (npxproc == NULL || !npx_exists) { - /* XXX no %p in stand/printf.c. Cast to quiet gcc -Wall. */ - printf("npxintr: npxproc = %lx, curproc = %lx, npx_exists = %d\n", - (u_long) npxproc, (u_long) curproc, npx_exists); - panic("npxintr from nowhere"); - } - if (npxproc != curproc) { - printf("npxintr: npxproc = %lx, curproc = %lx, npx_exists = %d\n", - (u_long) npxproc, (u_long) curproc, npx_exists); - panic("npxintr from non-current process"); - } - /* - * Save state. This does an implied fninit. It had better not halt - * the cpu or we'll hang. - */ - outb(0xf0, 0); - fnsave(&curpcb->pcb_savefpu); - fwait(); - /* - * Restore control word (was clobbered by fnsave). - */ - fldcw(&curpcb->pcb_savefpu.sv_env.en_cw); - fwait(); - /* - * Remember the exception status word and tag word. The current - * (almost fninit'ed) fpu state is in the fpu and the exception - * state just saved will soon be junk. However, the implied fninit - * doesn't change the error pointers or register contents, and we - * preserved the control word and will copy the status and tag - * words, so the complete exception state can be recovered. - */ - curpcb->pcb_savefpu.sv_ex_sw = curpcb->pcb_savefpu.sv_env.en_sw; - curpcb->pcb_savefpu.sv_ex_tw = curpcb->pcb_savefpu.sv_env.en_tw; - - /* - * Pass exception to process. - */ - if (ISPL(frame.if_cs) == SEL_UPL) { - /* - * Interrupt is essentially a trap, so we can afford to call - * the SIGFPE handler (if any) as soon as the interrupt - * returns. - * - * XXX little or nothing is gained from this, and plenty is - * lost - the interrupt frame has to contain the trap frame - * (this is otherwise only necessary for the rescheduling trap - * in doreti, and the frame for that could easily be set up - * just before it is used). - */ - curproc->p_md.md_regs = (int *)&frame.if_es; -#ifdef notyet - /* - * Encode the appropriate code for detailed information on - * this exception. - */ - code = XXX_ENCODE(curpcb->pcb_savefpu.sv_ex_sw); -#else - code = 0; /* XXX */ -#endif - trapsignal(curproc, SIGFPE, code); - } else { - /* - * Nested interrupt. These losers occur when: - * o an IRQ13 is bogusly generated at a bogus time, e.g.: - * o immediately after an fnsave or frstor of an - * error state. - * o a couple of 386 instructions after - * "fstpl _memvar" causes a stack overflow. - * These are especially nasty when combined with a - * trace trap. - * o an IRQ13 occurs at the same time as another higher- - * priority interrupt. - * - * Treat them like a true async interrupt. - */ - psignal(npxproc, SIGFPE); - } -} - -/* - * Implement device not available (DNA) exception - * - * It would be better to switch FP context here (only). This would require - * saving the state in the proc table instead of in the pcb. - */ -int -npxdna() -{ - if (!npx_exists) - return (0); - if (npxproc != NULL) { - printf("npxdna: npxproc = %lx, curproc = %lx\n", - (u_long) npxproc, (u_long) curproc); - panic("npxdna"); - } - stop_emulating(); - /* - * Record new context early in case frstor causes an IRQ13. - */ - npxproc = curproc; - /* - * The following frstor may cause an IRQ13 when the state being - * restored has a pending error. The error will appear to have been - * triggered by the current (npx) user instruction even when that - * instruction is a no-wait instruction that should not trigger an - * error (e.g., fnclex). On at least one 486 system all of the - * no-wait instructions are broken the same as frstor, so our - * treatment does not amplify the breakage. On at least one - * 386/Cyrix 387 system, fnclex works correctly while frstor and - * fnsave are broken, so our treatment breaks fnclex if it is the - * first FPU instruction after a context switch. - */ - frstor(&curpcb->pcb_savefpu); - - return (1); -} - -/* - * Wrapper for fnsave instruction to handle h/w bugs. If there is an error - * pending, then fnsave generates a bogus IRQ13 on some systems. Force - * any IRQ13 to be handled immediately, and then ignore it. This routine is - * often called at splhigh so it must not use many system services. In - * particular, it's much easier to install a special handler than to - * guarantee that it's safe to use npxintr() and its supporting code. - */ -void -npxsave(addr) - struct save87 *addr; -{ - u_char icu1_mask; - u_char icu2_mask; - u_char old_icu1_mask; - u_char old_icu2_mask; - struct gate_descriptor save_idt_npxintr; - - disable_intr(); - old_icu1_mask = inb(IO_ICU1 + 1); - old_icu2_mask = inb(IO_ICU2 + 1); - save_idt_npxintr = idt[npx_intrno]; - outb(IO_ICU1 + 1, old_icu1_mask & ~(IRQ_SLAVE | npx0_imask)); - outb(IO_ICU2 + 1, old_icu2_mask & ~(npx0_imask >> 8)); - idt[npx_intrno] = npx_idt_probeintr; - enable_intr(); - stop_emulating(); - fnsave(addr); - fwait(); - start_emulating(); - npxproc = NULL; - disable_intr(); - icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */ - icu2_mask = inb(IO_ICU2 + 1); - outb(IO_ICU1 + 1, - (icu1_mask & ~npx0_imask) | (old_icu1_mask & npx0_imask)); - outb(IO_ICU2 + 1, - (icu2_mask & ~(npx0_imask >> 8)) - | (old_icu2_mask & (npx0_imask >> 8))); - idt[npx_intrno] = save_idt_npxintr; - enable_intr(); /* back to usual state */ -} - -#endif /* NNPX > 0 */ diff --git a/sys/i386/isa/options.h b/sys/i386/isa/options.h deleted file mode 100644 index 3dd1b5f8..0000000 --- a/sys/i386/isa/options.h +++ /dev/null @@ -1,250 +0,0 @@ -/*options.h-------------------------------------------------------------------- - Matsushita(Panasonic) / Creative CD-ROM Driver (matcd) - Authored by Frank Durda IV - - Copyright 1994, 1995 Frank Durda IV. All rights reserved. - "FDIV" is a trademark of Frank Durda IV. - - - 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 positioned at the very beginning of this file without - modification, all copyright strings, all related programming - codes that display the copyright strings, this list of - conditions and the following disclaimer. - 2. Redistributions in binary form must contain all copyright strings - and related programming code that display the copyright strings. - 3. 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. - 4. All advertising materials mentioning features or use of this - software must display the following acknowledgement: - "The Matsushita/Panasonic CD-ROM driver was developed - by Frank Durda IV for use with "FreeBSD" and similar - operating systems." - "Similar operating systems" includes mainly non-profit oriented - systems for research and education, including but not restricted - to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the - acknowledgement (in electronic form or printed text) may not be - changed without permission from the author. - 5. Absolutely no warranty of function, fitness or purpose is made - by the author Frank Durda IV. - 6. Neither the name of the author nor the name "FreeBSD" may - be used to endorse or promote products derived from this software - without specific prior written permission. - (The author can be reached at bsdmail@nemesis.lonestar.org) - 7. The product containing this software must meet all of these - conditions even if it is unsupported, not a complete system - and/or does not contain compiled code. - 8. These conditions will be in force for the full life of the - copyright. - 9. If all the above conditions are met, modifications to other - parts of this file may be freely made, although any person - or persons making changes do not receive the right to add their - name or names to the copyright strings and notices in this - software. Persons making changes are encouraged to insert edit - history in matcd.c and to put your name and details of the - change there. - 10. You must have prior written permission from the author to - deviate from these terms. - - Vendors who produce product(s) containing this code are encouraged - (but not required) to provide copies of the finished product(s) to - the author and to correspond with the author about development - activity relating to this code. Donations of development hardware - and/or software are also welcome. (This is one of the faster ways - to get a driver developed for a device.) - - THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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. ------------------------------------------------------------------------------ - Conditional compilation flags - change to suit your system ----------------------------------------------------------------------------*/ - -/* AUTOHUNT Adds extra code that allows the driver to search - for interface cards rather than having to hard-code - the locations in the kernel conf file. - Leaving AUTOHUNT enabled is the recommended setting. -*/ - -#define AUTOHUNT - - -/* FULLCONFIG Allows up to four host interface boards for a - total of 16 drives. If disabled, only a single - host interface (of any type) is allowed. The - additional driver size is insignificant. - Leaving FULLCONFIG enabled is the recommended setting. -*/ - -#define FULLCONFIG - - -/* FULLDRIVER If not set, the audio, non-data functions and - some error recovery functions are eliminated from - the compiled driver. The resulting driver will be - smaller and may help a kernel fit on a boot floppy. - Leaving FULLDRIVER enabled is the recommended setting. -*/ - -#define FULLDRIVER - - -/* RESETONBOOT causes the driver to reset the drive(s) to be - reset during probing. This causes any audio - playback to be aborted and the drives will close - their trays if they are open. - Leaving RESETONBOOT enabled is the recommended setting. -*/ - -#define RESETONBOOT - - -/* LOCKDRIVE If enabled, the when the drive is open, the - door is locked. The front panel eject button - is ignored. When the drive is completely closed, - the eject button will be honored. - Leaving LOCKDRIVE disabled is the recommended setting. -*/ - -/*#define LOCKDRIVE*/ - - -/*<5> FREE2 If enabled, the changes are inserted so this -<5> module will compile in the world of FreeBSD 2.x. -<5> Without this, it is known to work in -<5> FreeBSD 1.1.5.1. -<5>*/ - -#define FREE2 /*<5>Correct setting for 2.x*/ - - -/*--------------------------------------------------------------------------- - This structure contains the hints for where we should look for the - host adapter. If you want to change where we search or reduce the - places we search to avoid confusing some other device, either - specify explicit addresses in the kernel config file (preferred) - or change this array. - - If the kernel config fuke has multiple ? entries, the probe routines - will use this table multiple times and will eliminate each failed - entry probe tries. - - WARNING: The number of controller entries for this driver in config - must be less than or equal to the number of hints if hints are used. - - If you add entries to the table, add them immediately before - the -1 end-of-table marker. The values already present are - the ones found on standard SoundBlaster 16 and standalone cards. ----------------------------------------------------------------------------*/ - - -#ifdef AUTOHUNT -int port_hints[]={ - 0x230,0x240, /*Ports SB audio boards can use*/ - 0x250,0x260, /*Ports standalone CD/IF board can*/ - -1}; /*use. Table MUST end with -1*/ -#endif /*AUTOHUNT*/ - - -/*--------------------------------------------------------------------------- - Debugging flags - Turn these on only if you are looking at a - problem. ----------------------------------------------------------------------------*/ - -/* DEBUGOPEN If enabled, debug messages for open and close - operations. -*/ - -/*#define DEBUGOPEN*/ - - -/* DEBUGIO If enabled, reports on calls to strategy, start - and other I/O related functions. -*/ - -/*#define DEBUGIO*/ - - -/* DEBUGQUEUE If enabled, shows activity on disk request queues. - Warning - This debug is VERY VERY NOISY and will - loop endlessly if queues are not null terminated - as they should be. -*/ - -/*#define DEBUGQUEUE*/ - - -/* DEBUGCMD If enabled, shows the actual commands being issued - to the CD-ROM drives. -*/ - -/*#define DEBUGCMD*/ - - -/* DEBUGSLEEP If enabled, reports on timeouts, wakeups, dropped - threads, etc. -*/ - -/*#define DEBUGSLEEP*/ - - -/* DEBUGIOCTL If enabled, reports on the various ioctl-related - calls and operations. You might have to enable - DEBUGCMD as well to get enough debugging information. -*/ - -/*#define DEBUGIOCTL*/ - - -/* DEBUGPROBE If enabled, reports on the process of locating - adapters and drives. The debugging in matcdprobe() - and matcdattach() routines is enabled with this - flag. -*/ - -/*#define DEBUGPROBE*/ - - -/* DIAGPORT If enabled, additional code is added to send - debugging state to a debug port. This should - not be enabled in production. The value - can be set to 0x80 or 0x302, depending on what - type of debugging board you own. The global variable - diagloop is used to make looping reports on these - devices. - - Some other drivers and possible the kernel fiddle - with the 0x80 debug port, so it may not be usable - for isolating failures that result in a kernel panic. - The 0x302 debug board is recommended in these cases. - It also displays a word of data, so you get more - detail. - -<10> It was discovered the 0x302 board was getting set -<10> into a strange state by the probes for other -<10> devices. To resolve this, the display control port -<10> (0x300) is reset in our probe and open routines. -<10> DO NOT use DIAGPORT 0x302 if an adapter is present -<10> at that address. It could ruin the EEPROM settings -<10> on the device. -*/ - -/*#define DIAGPORT 0x80*/ -/*#define DIAGPORT 0x302*/ - -/*End of options.h*/ - - diff --git a/sys/i386/isa/pas.c b/sys/i386/isa/pas.c deleted file mode 100644 index 2bd8718..0000000 --- a/sys/i386/isa/pas.c +++ /dev/null @@ -1,974 +0,0 @@ -/* - * Copyright (C) 1994 Poul-Henning Kamp - * - * All rights reserved. - * - * This file contains some material which are covered by the message after - * this message. - * - * The rest of this file is covered by the following clause: - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $Id: pas.c,v 1.5 1994/10/18 03:53:12 phk Exp $ - * - * This is a driver for the one particular kind of the "ProAudioSpectrum" - * card from MediaVision. To find out if your card is supported, you can - * either try out the driver, or you can look for a chip a little less than - * 1" square in one end of the card, with writing on it that say ...5380... - * - * Up to four of these cards can be in the same computer. If you have - * multiple cards, you need to set the "card-id" jumpers correspondingly. - * - * The driver uses no interrupts, so don't expect record-breaking performance. - * - * Poul-Henning Kamp <phk@freefall.cdrom.com> - */ - -/* - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * All rights reserved. - * - * 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 Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. - * - * Was: Id: pas.c,v 1.8.2.1 1994/07/11 00:02:32 cgd Exp - * - * Modified for use with the pc532 by Phil Nelson, Feb 94. - */ - - -#include "pas.h" -#if NPAS > 0 - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> -#include <sys/devconf.h> - -#include <i386/isa/isa_device.h> -#include <i386/isa/ic/ncr_5380.h> -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> - -/* - * Define this macro to disable the PSEUDO-DMA transfers. - */ -#undef NO_PAS16_PSEUDO_DMA - -/* - * This parameter determines how many byte we "insb" between each check for - * a change of phase. - */ - -#ifndef PAS16_PSEUDO_DMA_SIZE -# define PAS16_PSEUDO_DMA_SIZE 512 -#endif - -/* - * How many times we attempt to select a device. - */ -#ifndef ATTEMPT_SELECTION -# define ATTEMPT_SELECTION 5 -#endif /* ATTEMPT_SELECTION */ - -/* - * How many microseconds between each attempt. - */ -#ifndef SELECTION_DELAY -# define SELECTION_DELAY 10000 -#endif /* SELECTION_DELAY */ - -#ifndef PAS16_TIMEOUT -# define PAS16_TIMEOUT 1000000 -#endif /* PAS16_TIMEOUT */ -/* What we need to debug the driver */ - -#ifdef PAS_DEBUG -# if PAS_DEBUG == 0 -# undef PAS_DEBUG -# else - static int pas_show_scsi_cmd(struct scsi_xfer *xs); -# ifndef PAS_DEBUG_REQUEST_SENSE -# define PAS_DEBUG_REQUEST_SENSE -# endif -# endif -#endif /* PAS_DEBUG */ - -#define SCSI_PHASE_DATA_OUT 0x0 -#define SCSI_PHASE_DATA_IN 0x1 -#define SCSI_PHASE_CMD 0x2 -#define SCSI_PHASE_STATUS 0x3 -#define SCSI_PHASE_UNSPEC1 0x4 -#define SCSI_PHASE_UNSPEC2 0x5 -#define SCSI_PHASE_MESSAGE_OUT 0x6 -#define SCSI_PHASE_MESSAGE_IN 0x7 - -#define SCSI_CUR_PHASE(x) ((x>>2)&0x7) - -#define SCSI_RET_SUCCESS 0 -#define SCSI_RET_RETRY 1 -#define SCSI_RET_DEVICE_DOWN 2 -#define SCSI_RET_COMMAND_FAIL 3 - - -/* Our per device (card) structure */ -static -struct pas_softc { - struct scsi_link sc_link; - int mv_unit; - u_short iobase; -#define xor_0000 iobase - u_short xor_0001; - u_short xor_0002; - u_short xor_0003; - u_short xor_2000; - u_short xor_2001; - u_short xor_2002; - u_short xor_2003; - u_short xor_4000; - u_short xor_4001; - u_short xor_4003; -} s_pas[NPAS]; - -/* - * Register Access-macros use these - */ -#define r_csdr(ptr) (ptr->xor_0000) -#define w_odr(ptr) (ptr->xor_0000) -#define r_icr(ptr) (ptr->xor_0001) -#define w_icr(ptr) (ptr->xor_0001) -#define rw_mr(ptr) (ptr->xor_0002) -#define r_tcr(ptr) (ptr->xor_0003) -#define w_tcr(ptr) (ptr->xor_0003) -#define r_cscr(ptr) (ptr->xor_2000) -#define w_ser(ptr) (ptr->xor_2000) -#define r_bsr(ptr) (ptr->xor_2001) -#define w_sdsr(ptr) (ptr->xor_2001) -#define r_idr(ptr) (ptr->xor_2002) -#define w_sdtr(ptr) (ptr->xor_2002) -#define r_rpir(ptr) (ptr->xor_2003) -#define w_sdir(ptr) (ptr->xor_2003) -#define pas_data(ptr) (ptr->xor_4000) -#define pas_stat(ptr) (ptr->xor_4001) -#define R_PAS_STAT_DREQ 0x80 -#define pas_irq(ptr) (ptr->xor_4003) - -/* - * The actual macros used to access the chip - */ -#define P_PAS struct pas_softc * -#define R_PAS(ptr,foo) inb(foo(ptr)) -#define W_PAS(ptr,foo,val) outb(foo(ptr),val) -#define M_PAS(ptr,foo,opr,arg) outb(foo(ptr),R_PAS(ptr,foo) opr arg) - -#define WAIT_FOR_NOT_REQ(ptr) { \ - int scsi_timeout = PAS16_TIMEOUT; \ - while ( (R_PAS(ptr,r_cscr) & R_CSCR_REQ) && \ - (R_PAS(ptr,r_cscr) & R_CSCR_REQ) && \ - (R_PAS(ptr,r_cscr) & R_CSCR_REQ) && \ - (--scsi_timeout) ); \ - if (!scsi_timeout) { \ - printf("scsi timeout--WAIT_FOR_NOT_REQ-- pas.c:%d.\n", __LINE__); \ - goto scsi_timeout_error; \ - } \ -} -#define WAIT_FOR_REQ(ptr) { \ - int scsi_timeout = PAS16_TIMEOUT; \ - while ( ((R_PAS(ptr,r_cscr) & R_CSCR_REQ) == 0) && \ - ((R_PAS(ptr,r_cscr) & R_CSCR_REQ) == 0) && \ - ((R_PAS(ptr,r_cscr) & R_CSCR_REQ) == 0) && \ - (--scsi_timeout) ); \ - if (!scsi_timeout) { \ - printf("scsi timeout--WAIT_FOR_REQ-- pas.c:%d.\n", __LINE__); \ - goto scsi_timeout_error; \ - } \ -} - -static u_int32 pas_adapter_info(int adapter_number); -static void pas_minphys(struct buf *bp); -static int32 pas_scsi_cmd(struct scsi_xfer *xs); -static int pas_reset(int); -static int pas_send_cmd(struct scsi_xfer *xs); -static int scsi_req(P_PAS,int,int,u_char *,int, - u_char *, int , int *, int *); -static int sci_data_out(P_PAS, int, int, u_char *); -static int sci_data_in(P_PAS, int, int, u_char *); -static int select_target(P_PAS, int); - -extern int pasprobe(struct isa_device *dev); -extern int pasattach(struct isa_device *dev); -struct isa_driver pasdriver = { pasprobe, pasattach, "pas" }; - - -static -struct scsi_adapter pas_adapter = { - pas_scsi_cmd, /* scsi_cmd() */ - pas_minphys, /* scsi_minphys() */ - 0, /* open_target_lu() */ - 0, /* close_target_lu() */ - pas_adapter_info, /* adapter_info() */ - "pas", /* name */ - { 0, 0 } /* spare[2] */ -}; - -static -struct scsi_device pas_dev = { - NULL, /* Use default error handler. */ - NULL, /* have a queue, served by this (?) */ - NULL, /* have no async handler. */ - NULL, /* Use default "done" routine. */ - "pas", - 0, - { 0, 0 } -}; - -static char *mv_type[] = { - 0,0,0,0,0,0,"PAS+",0,0,0,0,0,"PAS16D",0,"CDPC","PAS16"}; - -int -pasprobe(struct isa_device *dev) -{ - int port = dev->id_iobase; - int base = port - 0x1c00; - int unit = dev->id_unit; - int i, j; - - if(base & 3) { - printf("pas%d cannot operate on address %x.", unit,port); - printf(" Address must be a multiple of four.\n"); - return 0; - } - /* Tell the PAS16 we want to talk to, where to listen */ - outb(0x9a01,0xbc + unit); - outb(0x9a01,base >> 2); - -#ifdef PAS_DEBUG - printf("%x: 0x803=%x 0xec03=%x 0xff88=%x\n", - base,inb(base^0x803),inb(base^0xec03),inb(base^0xfc00)); -#endif - - /* Killer one */ - i = inb(base ^ 0x803); - if(i == 0xff) return 0; - - /* killer two */ - if((0x03 & inb(base^0xec03)) != 0x03) return 0; - - /* killer three */ - for(i=0;i<4;i++) { - if(inb(port) != 0xff || inb(port^0x2000) != 0xff) - goto ok; - } - return 0; -ok: - /* killer four */ - i = inb(base ^ 0x803); - outb(base^0x803,i ^ 0xe0); - j = inb(base^0x803); - outb(base^0x803,1); - if(i != j) return 0; - - return 4; -} - -static u_int32 -pas_adapter_info(int adapter_number) -{ - return 1; -} - -static struct kern_devconf kdc_pas[NPAS] = { { - 0, 0, 0, /* filled in by dev_attach */ - "pas", 0, { MDDT_ISA, 0, "bio" }, - isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, - &kdc_isa0, /* parent */ - 0, /* parentdata */ - DC_BUSY, /* host adapters are always busy */ - "Media Vision ProAudioSpectrum SCSI host adapter" -} }; - -static inline void -pas_registerdev(struct isa_device *id) -{ - if(id->id_unit) - kdc_pas[id->id_unit] = kdc_pas[0]; - kdc_pas[id->id_unit].kdc_unit = id->id_unit; - kdc_pas[id->id_unit].kdc_parentdata = id; - dev_attach(&kdc_pas[id->id_unit]); -} - -int -pasattach(struct isa_device *dev) -{ - int i,base=dev->id_iobase-0x1c00; - struct pas_softc *ppas; - i = inb(base^0xEC03) & 0x0f; - printf("pas%d: Type = %d <%s>\n",dev->id_unit,i,mv_type[i]); - ppas = s_pas + dev->id_unit; - ppas->sc_link.adapter_unit = dev->id_unit; - ppas->sc_link.adapter_targ = 7; - ppas->sc_link.adapter = &pas_adapter; - ppas->sc_link.device = &pas_dev; - ppas->iobase=dev->id_iobase; - ppas->xor_0001 = ppas->iobase^0x0001; - ppas->xor_0002 = ppas->iobase^0x0002; - ppas->xor_0003 = ppas->iobase^0x0003; - ppas->xor_2000 = ppas->iobase^0x2000; - ppas->xor_2001 = ppas->iobase^0x2001; - ppas->xor_2002 = ppas->iobase^0x2002; - ppas->xor_2003 = ppas->iobase^0x2003; - ppas->xor_4000 = ppas->iobase^0x4000; - ppas->xor_4001 = ppas->iobase^0x4001; - ppas->xor_4003 = ppas->iobase^0x4003; - - /* Various magic */ - outb(base^0x4000,0x30); - outb(base^0x4001,0x01); - outb(base^0xbc00,0x01); - outb(base^0x8003,0x4d); - - pas_registerdev(dev); - scsi_attachdevs(&(ppas->sc_link)); - pas_reset(dev->id_unit); - return 1; -} - -static void -pas_minphys(struct buf *bp) -{ -#define MIN_PHYS 65536 /*BARF!!!!*/ - if (bp->b_bcount > MIN_PHYS) { - printf("Uh-oh... pas_minphys setting bp->b_bcount = %x.\n", MIN_PHYS); - bp->b_bcount = MIN_PHYS; - } -#undef MIN_PHYS -} - -static int32 -pas_scsi_cmd(struct scsi_xfer *xs) -{ - int flags, s, r; - - flags = xs->flags; - if (xs->bp) flags |= (SCSI_NOSLEEP); - if ( flags & ITSDONE ) { - printf("Already done?"); - xs->flags &= ~ITSDONE; - } - if ( ! ( flags & INUSE ) ) { - printf("Not in use?"); - xs->flags |= INUSE; - } - - if ( flags & SCSI_RESET ) { - printf("flags & SCSIRESET.\n"); - if ( ! ( flags & SCSI_NOSLEEP ) ) { - s = splbio(); - pas_reset(xs->sc_link->adapter_unit); - splx(s); - return(SUCCESSFULLY_QUEUED); - } else { - pas_reset(xs->sc_link->adapter_unit); - return (COMPLETE); - } - } - - r = pas_send_cmd(xs); - xs->flags |= ITSDONE; - scsi_done(xs); - if (xs->flags&SCSI_NOMASK) { - return (r); - } - return SUCCESSFULLY_QUEUED; -} - -#ifdef PAS_DEBUG -static int -pas_show_scsi_cmd(struct scsi_xfer *xs) -{ - u_char *b = (u_char *) xs->cmd; - int i = 0; - - if ( ! ( xs->flags & SCSI_RESET ) ) { - printf("pas(%d:%d:%d) ", - xs->sc_link->adapter_unit, xs->sc_link->target, xs->sc_link->lun); - printf("%d@%x, %d@%x <",xs->cmdlen,(u_long)xs->cmd, - xs->datalen,(u_long)xs->data); - while (i < xs->cmdlen) { - if (i) printf(","); - printf("%x",b[i++]); - } - printf(">\n"); - } else { - printf("pas(%d:%d:%d)-RESET-\n", - xs->sc_link->adapter_unit, xs->sc_link->target, - xs->sc_link->lun); - } - return 0; -} -#endif /* PAS_DEBUG */ - -static int -pas_reset(int adapter) -{ - struct pas_softc *ppas = s_pas + adapter; - - /* - * Reset Hold Time is 25 uSec - */ - W_PAS(ppas,w_icr,W_ICR_ASSERT_RST); - DELAY(25); - W_PAS(ppas,w_icr,0); - - W_PAS(ppas,rw_mr,0); - W_PAS(ppas,w_ser,0); - - return 0; -} - -static int -pas_send_cmd(struct scsi_xfer *xs) -{ - P_PAS ptr = s_pas + xs->sc_link->adapter_unit; - int s,sent,ret; - int sense; - u_char cmd[6]; - -#ifdef PAS_DEBUG - pas_show_scsi_cmd(xs); -#endif /* PAS_DEBUG */ - s = splbio(); - sense = scsi_req(ptr, - xs->sc_link->target, xs->sc_link->lun, - (u_char*)xs->cmd, xs->cmdlen, xs->data, xs->datalen, - &sent, &ret); - splx(s); - switch (sense) { - case 0x00: - xs->error = XS_NOERROR; - xs->resid = sent; - return (COMPLETE); - case 0x02: /* Check condition */ - -#ifdef PAS_DEBUG_REQUEST_SENSE - printf("pas%d, target%d: sent=%d,ret=%d,sense=%x check. cond.\n", - xs->sc_link->adapter_unit, xs->sc_link->target,sent,ret,sense); - printf("Cmd:<%x",((u_char*)(xs->cmd))[0]); - for(sent=1;sent < sizeof xs->cmdlen;sent++) { - printf(",%x",((u_char*)(xs->cmd))[sent]); - } - printf(">\n"); -#endif /* PAS_DEBUG_REQUEST_SENSE */ - cmd[0] = 3; - cmd[1] = xs->sc_link->lun<<5; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = sizeof xs->sense; - cmd[5] = 0; - - DELAY(10); - s = splbio(); - scsi_req(ptr, xs->sc_link->target, xs->sc_link->lun, - cmd, sizeof cmd, - (caddr_t) &(xs->sense), sizeof xs->sense, - &sent, &ret); - splx(s); -#ifdef PAS_DEBUG_REQUEST_SENSE - printf("Sense result: (sent=%d, ret=%d)\n",sent,ret); - printf("<%x",((u_char*)(&xs->sense))[0]); - for(sent=1;sent < sizeof xs->sense;sent++) { - printf(",%x",((u_char*)(&xs->sense))[sent]); - } - printf(">\n"); -#endif /* PAS_DEBUG_REQUEST_SENSE */ - xs->error = XS_SENSE; - return HAD_ERROR; - case 0x08: /* Busy */ - xs->error = XS_BUSY; - return HAD_ERROR; - default: - xs->error = XS_DRIVER_STUFFUP; - return HAD_ERROR; - } -} - -/* - * Perform arbitration and selection. Figure 5-1, more or less. - */ - -static int -select_target(P_PAS ptr, int tid) -{ - int myid = ptr->sc_link.adapter_targ; - int ret = SCSI_RET_RETRY; - int tries = ATTEMPT_SELECTION; - int delay = SELECTION_DELAY; - int i; - - /* - * Convert the ID's to bit-maps. - */ - myid = 1 << myid; - tid = 1 << tid; - - /* - * Not documented, but clearly needed for now. - * XXX is this missing somewhere else, and this is just a hack ? - */ -loop: - W_PAS(ptr,w_tcr,0); - - - /* - * Write ID Bit to Output Register. - */ - W_PAS(ptr,w_odr,myid); - - /* - * Set "ARBITRATE" Bit. - */ - W_PAS(ptr,rw_mr,RW_MR_ARBITRATE); - - /* - * Check "Arbitration in progress" Bit. - */ - for (i = 0; i < 20; i++) /* 20usec circa */ - if (R_PAS(ptr,r_icr) & R_ICR_ARBITRATION_IN_PROGRESS) - goto aip; - goto lost; - -aip: - /* - * Wait 2.2 usec Arbitration Delay. - */ - DELAY(2); - - /* - * Check "Lost Arbitration" Bit. - */ - if (R_PAS(ptr,r_icr) & R_ICR_LOST_ARBITRATION) - goto lost; - - /* - * Higher priority ID present ? - */ - if ((R_PAS(ptr,r_csdr) & ~myid) > myid) - goto lost; - - /* - * Check "Lost Arbitration" Bit. - */ - if (R_PAS(ptr,r_icr) & R_ICR_LOST_ARBITRATION) - goto lost; - - /* - * Set "Assert SEL/". - */ - W_PAS(ptr,w_icr,W_ICR_ASSERT_SEL); - - /* - * Check "Lost Arbitration" Bit. - */ - if (R_PAS(ptr,r_icr) & R_ICR_LOST_ARBITRATION) { - goto nosel; - } - - /* - * Wait 1.2 usec minimum. (Bus Clear + Settle) - */ - DELAY(2); - - /* - * Write Target and Initiator's ID bits to output Register. - */ - W_PAS(ptr,w_odr,myid|tid); - - /* - * Set "Assert BSY/" + "Assert Data Bus". - */ - W_PAS(ptr,w_icr, - W_ICR_ASSERT_SEL | W_ICR_ASSERT_BSY | W_ICR_ASSERT_DATA_BUS); - - /* - * Reset "ARBITRATE" Bit. - */ - W_PAS(ptr,rw_mr,0); - - /* - * Reset "Select Enable" Register. - */ - W_PAS(ptr,w_ser,0); - - /* - * Reset "Assert BSY/". - */ - W_PAS(ptr,w_icr, - W_ICR_ASSERT_SEL | W_ICR_ASSERT_DATA_BUS); - - /* - * "BSY/" Asserted within 250 msec ? - */ - for(i=0;i<250000;i+=100) { - if (R_PAS(ptr,r_cscr) & R_CSCR_BSY) - goto resp; - DELAY(100); - } - goto nodev; -resp: - - /* - * Reset "Assert SEL/" + "Assert Data Bus". - */ - W_PAS(ptr,w_icr,0); - - return SCSI_RET_SUCCESS; - -nodev: - ret = SCSI_RET_DEVICE_DOWN; - -nosel: - W_PAS(ptr,w_icr,0); - -lost: - W_PAS(ptr,rw_mr,0); - if(--tries) { - DELAY(delay); - goto loop; - } - - return ret; -} - -/* - * Figure 5-2. - */ - -static int -sci_data_out(P_PAS ptr, int phase, int count, u_char *data) -{ - register unsigned char icmd; - register int cnt=0,zonk; - - if (SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - - icmd = R_PAS(ptr,r_icr) & RW_ICR_MASK; - -#ifndef NO_PAS16_PSEUDO_DMA - /* - * The PAS16 has special provisions for doing pseudo-dma. - */ - - /* - * Don't use pseudo-dma unless we need much data. This way we avoid all - * the variable length stuff entirely. - * - * XXX something screws up for big transfers :-( - */ - - if(count >= 128 && count <= 8192) { - - M_PAS(ptr,rw_mr,|,RW_MR_DMA_MODE); - - W_PAS(ptr,w_icr,icmd | W_ICR_ASSERT_DATA_BUS); - - W_PAS(ptr,w_sdsr,0); - - while(count >= PAS16_PSEUDO_DMA_SIZE) { - zonk=0; - while(!(R_PAS(ptr,pas_stat) & R_PAS_STAT_DREQ)) - if (++zonk > 1000 || SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - - outsb(pas_data(ptr),data,PAS16_PSEUDO_DMA_SIZE); - - data += PAS16_PSEUDO_DMA_SIZE; - cnt += PAS16_PSEUDO_DMA_SIZE; - count -= PAS16_PSEUDO_DMA_SIZE; - - } - - if(count) { - while(!(R_PAS(ptr,pas_stat) & R_PAS_STAT_DREQ)) - if (SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - outsb(pas_data(ptr),data,count); - cnt += count; - data += count; - } - - M_PAS(ptr,rw_mr,&,~RW_MR_DMA_MODE); - W_PAS(ptr,w_icr,icmd); - return cnt; - } -#endif /* NO_PAS16_PSEUDO_DMA */ -loop: - if (SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - - W_PAS(ptr,w_odr, *data); - WAIT_FOR_REQ(ptr); - icmd |= W_ICR_ASSERT_DATA_BUS; - W_PAS(ptr,w_icr,icmd); - icmd |= W_ICR_ASSERT_ACK; - W_PAS(ptr,w_icr,icmd); - - icmd &= ~(W_ICR_ASSERT_DATA_BUS|W_ICR_ASSERT_ACK); - WAIT_FOR_NOT_REQ(ptr); - W_PAS(ptr,w_icr,icmd); - ++cnt; - data++; - if (--count > 0) - goto loop; -scsi_timeout_error: - return cnt; -} - -static int -sci_data_in(P_PAS ptr, int phase, int count, u_char *data) -{ - unsigned char icmd; - int cnt=0; - - if (SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - -#ifndef NO_PAS16_PSEUDO_DMA - /* - * The PAS16 has special provisions for doing pseudo-dma. - */ - - /* - * Don't use pseudo-dma unless we need much data. This way we avoid all - * the variable length stuff entirely. - */ - if(count >= 128) { - - M_PAS(ptr,rw_mr,|,RW_MR_DMA_MODE); - - W_PAS(ptr,w_sdir,0); - - while(count > PAS16_PSEUDO_DMA_SIZE) { - while(!(R_PAS(ptr,pas_stat) & R_PAS_STAT_DREQ)) ; - - insb(pas_data(ptr),data,PAS16_PSEUDO_DMA_SIZE); - - data += PAS16_PSEUDO_DMA_SIZE; - cnt += PAS16_PSEUDO_DMA_SIZE; - count -= PAS16_PSEUDO_DMA_SIZE; - - if (SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - } - - while(!(R_PAS(ptr,pas_stat) & R_PAS_STAT_DREQ)) ; - - insb(pas_data(ptr),data,count-1); - cnt += count-1; - data += count-1; - - while(!(R_PAS(ptr,pas_stat) & R_PAS_STAT_DREQ)) ; - while((R_PAS(ptr,r_cscr) & R_CSCR_REQ)); - *data = R_PAS(ptr,r_idr); - cnt++; - M_PAS(ptr,rw_mr,&,~RW_MR_DMA_MODE); - return cnt; - } -#endif /* NO_PAS16_PSEUDO_DMA */ - - icmd = R_PAS(ptr,r_icr) & RW_ICR_MASK; - -loop: - if (SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)) != phase) - return cnt; - - WAIT_FOR_REQ(ptr); - *data++ = R_PAS(ptr,r_csdr); - - icmd |= W_ICR_ASSERT_ACK; - W_PAS(ptr,w_icr,icmd); - icmd &= ~W_ICR_ASSERT_ACK; - - WAIT_FOR_NOT_REQ(ptr); - W_PAS(ptr,w_icr,icmd); - ++cnt; - if (--count > 0) - goto loop; - -scsi_timeout_error: - return cnt; -} - - -static int -cmd_xfer(P_PAS ptr, int maxlen, u_char *data, u_char *status, u_char *msg) -{ - int xfer=0, phase; - - W_PAS(ptr,w_icr,0); - - while (1) { - - WAIT_FOR_REQ(ptr); - - phase = SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)); - - switch (phase) { - case SCSI_PHASE_CMD: - W_PAS(ptr,w_tcr,SCSI_PHASE_CMD); - xfer += sci_data_out(ptr, SCSI_PHASE_CMD, maxlen, data); - return xfer; - case SCSI_PHASE_DATA_IN: - printf("Data in phase in cmd_xfer?\n"); - return 0; - case SCSI_PHASE_DATA_OUT: - printf("Data out phase in cmd_xfer?\n"); - return 0; - case SCSI_PHASE_STATUS: - W_PAS(ptr,w_tcr,SCSI_PHASE_STATUS); - printf("status in cmd_xfer.\n"); - sci_data_in(ptr, SCSI_PHASE_STATUS, 1, status); - break; - case SCSI_PHASE_MESSAGE_IN: - W_PAS(ptr,w_tcr,SCSI_PHASE_MESSAGE_IN); - printf("msgin in cmd_xfer.\n"); - sci_data_in(ptr, SCSI_PHASE_MESSAGE_IN, 1, msg); - break; - case SCSI_PHASE_MESSAGE_OUT: - W_PAS(ptr,w_tcr,SCSI_PHASE_MESSAGE_OUT); - sci_data_out(ptr, SCSI_PHASE_MESSAGE_OUT, 1, msg); - break; - default: - printf("Unexpected phase 0x%x in cmd_xfer()\n", phase); -scsi_timeout_error: - return xfer; - break; - } - } -} - -static int -data_xfer(P_PAS ptr, int maxlen, u_char *data, u_char *status, u_char *msg) -{ - int retlen = 0, xfer, phase; - - W_PAS(ptr,w_icr,0); - - *status = 0; - - while (1) { - - WAIT_FOR_REQ(ptr); - - phase = SCSI_CUR_PHASE(R_PAS(ptr,r_cscr)); - switch (phase) { - case SCSI_PHASE_CMD: - printf("Command phase in data_xfer().\n"); - return retlen; - case SCSI_PHASE_DATA_IN: - W_PAS(ptr,w_tcr,SCSI_PHASE_DATA_IN); - xfer = sci_data_in (ptr, SCSI_PHASE_DATA_IN, maxlen, data); - retlen += xfer; - maxlen -= xfer; - break; - case SCSI_PHASE_DATA_OUT: - W_PAS(ptr,w_tcr,SCSI_PHASE_DATA_OUT); - xfer = sci_data_out (ptr, SCSI_PHASE_DATA_OUT, maxlen, data); - retlen += xfer; - maxlen -= xfer; - break; - case SCSI_PHASE_STATUS: - W_PAS(ptr,w_tcr,SCSI_PHASE_STATUS); - sci_data_in(ptr, SCSI_PHASE_STATUS, 1, status); - break; - case SCSI_PHASE_MESSAGE_IN: - W_PAS(ptr,w_tcr,SCSI_PHASE_MESSAGE_IN); - sci_data_in(ptr, SCSI_PHASE_MESSAGE_IN, 1, msg); - if (*msg == 0) { - return retlen; - } else { - printf( "message 0x%x in data_xfer.\n", *msg); - } - break; - case SCSI_PHASE_MESSAGE_OUT: - W_PAS(ptr,w_tcr,SCSI_PHASE_MESSAGE_OUT); - sci_data_out(ptr, SCSI_PHASE_MESSAGE_OUT, 1, msg); - break; - default: - printf( "Unexpected phase 0x%x in data_xfer().\n", - phase); -scsi_timeout_error: - return retlen; - break; - } - } -} - -static int -scsi_req(P_PAS ptr, int target, int lun, u_char *cmd, int cmdlen, - u_char *databuf, int datalen, int *sent, int *ret) -{ -/* Returns 0 on success, -1 on internal error, or the status byte */ - int cmd_bytes_sent, r; - u_char stat, msg, c; - - *sent = 0; - if ( ( r = select_target(ptr, target) ) != SCSI_RET_SUCCESS) { - *ret = r; - switch (r) { - case SCSI_RET_RETRY: - return 0x08; - default: - printf("select_target(target %d, lun %d) failed(%d).\n", - target, lun, r); - case SCSI_RET_DEVICE_DOWN: - return -1; - } - } - - c = 0x80 | lun; - - if ((cmd_bytes_sent = cmd_xfer(ptr, cmdlen, cmd, &stat, &c)) != cmdlen) { - *ret = SCSI_RET_COMMAND_FAIL; - printf("Data underrun sending CCB (%d bytes of %d, sent).\n", - cmd_bytes_sent, cmdlen); - return -1; - } - - *sent=data_xfer(ptr, datalen, databuf, &stat, &msg); - - *ret = 0; - return stat; -} - -#endif /* NPAS */ diff --git a/sys/i386/isa/pcic.c b/sys/i386/isa/pcic.c deleted file mode 100644 index f5b31c9..0000000 --- a/sys/i386/isa/pcic.c +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * TODO: - * [1] integrate into current if_ed.c - * [2] parse tuples to find out where to map the shared memory buffer, - * and what to write into the configuration register - * [3] move pcic-specific code into a separate module. - * - * Device driver for IBM PCMCIA Credit Card Adapter for Ethernet, - * if_ze.c - * - * Based on the Device driver for National Semiconductor DS8390 ethernet - * adapters by David Greenman. Modifications for PCMCIA by Keith Moore. - * Adapted for FreeBSD 1.1.5 by Jordan Hubbard. - * - * Currently supports only the IBM Credit Card Adapter for Ethernet, but - * could probably work with other PCMCIA cards also, if it were modified - * to get the locations of the PCMCIA configuration option register (COR) - * by parsing the configuration tuples, rather than by hard-coding in - * the value expected by IBM's card. - * - * Sources for data on the PCMCIA/IBM CCAE specific portions of the driver: - * - * [1] _Local Area Network Credit Card Adapters Technical Reference_, - * IBM Corp., SC30-3585-00, part # 33G9243. - * [2] "pre-alpha" PCMCIA support code for Linux by Barry Jaspan. - * [3] Intel 82536SL PC Card Interface Controller Data Sheet, Intel - * Order Number 290423-002 - * [4] National Semiconductor DP83902A ST-NIC (tm) Serial Network - * Interface Controller for Twisted Pair data sheet. - * - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - */ -#include <sys/param.h> -#if defined(__FreeBSD__) -#include <sys/systm.h> -#include <sys/kernel.h> -#include <machine/clock.h> -#endif -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#include <i386/isa/icu.h> -#include <i386/isa/pcic.h> - -void -pcic_print_regs (int slot) -{ - int i, j; - - for (i = 0; i < 0x40; i += 16) { - for (j = 0; j < 16; ++j) - printf ("%02x ", pcic_getb (slot, i + j)); - printf ("\n"); - } -} - -/* - * map a portion of the card's memory space into system memory - * space. - * - * slot = # of the slot the card is plugged into - * window = which pcic memory map registers to use (0..4) - * sys_addr = base system PHYSICAL memory address where we want it. must - * be on an appropriate boundary (lower 12 bits are zero). - * card_addr = the base address of the card's memory to correspond - * to sys_addr - * length = length of the segment to map (may be rounded up as necessary) - * type = which card memory space to map (attribute or shared) - * width = 1 for byte-wide mapping; 2 for word (16-bit) mapping. - */ - -void -pcic_map_memory (int slot, int window, unsigned long sys_addr, - unsigned long card_addr, unsigned long length, - enum memtype type, int width) -{ - unsigned short offset; - unsigned short mem_start_addr; - unsigned short mem_stop_addr; - - sys_addr >>= 12; - card_addr >>= 12; - length >>= 12; - /* - * compute an offset for the chip such that - * (sys_addr + offset) = card_addr - * but the arithmetic is done modulo 2^14 - */ - offset = (card_addr - sys_addr) & 0x3FFF; - /* - * now OR in the bit for "attribute memory" if necessary - */ - if (type == ATTRIBUTE) { - offset |= (PCIC_REG << 8); - /* REG == "region active" pin on card */ - } - /* - * okay, set up the chip memory mapping registers, and turn - * on the enable bit for this window. - * if we are doing 16-bit wide accesses (width == 2), - * turn on the appropriate bit. - * - * XXX for now, we set all of the wait state bits to zero. - * Not really sure how they should be set. - */ - mem_start_addr = sys_addr & 0xFFF; - if (width == 2) - mem_start_addr |= (PCIC_DATA16 << 8); - mem_stop_addr = (sys_addr + length) & 0xFFF; - - pcic_putw (slot, MEM_START_ADDR(window), mem_start_addr); - pcic_putw (slot, MEM_STOP_ADDR(window), mem_stop_addr); - pcic_putw (slot, MEM_OFFSET(window), offset); - /* - * Assert the bit (PCIC_MEMCS16) that says to decode all of - * the address lines. - */ - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) | - MEM_ENABLE_BIT(window) | PCIC_MEMCS16); -} - -void -pcic_unmap_memory (int slot, int window) -{ - /* - * seems like we need to turn off the enable bit first, after which - * we can clear the registers out just to be sure. - */ - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) & ~MEM_ENABLE_BIT(window)); - pcic_putw (slot, MEM_START_ADDR(window), 0); - pcic_putw (slot, MEM_STOP_ADDR(window), 0); - pcic_putw (slot, MEM_OFFSET(window), 0); -} - -/* - * map a range of addresses into system i/o space - * (no translation of i/o addresses is possible) - * - * 'width' is: - * + 0 to tell the PCIC to generate the ISA IOCS16* signal from - * the PCMCIA IOIS16* signal. - * + 1 to select 8-bit width - * + 2 to select 16-bit width - */ - -void -pcic_map_io (int slot, int window, unsigned short base, unsigned short length, - unsigned short width) -{ - unsigned char x; - - pcic_putw (slot, IO_START_ADDR(window), base); - pcic_putw (slot, IO_STOP_ADDR(window), base+length-1); - /* - * select the bits that determine whether - * an i/o operation is 8 or 16 bits wide - */ - x = pcic_getb (slot, PCIC_IOCTL); - switch (width) { - case 0: /* PCMCIA card decides */ - if (window) - x = (x & 0xf0) | PCIC_IO1_CS16; - else - x = (x & 0x0f) | PCIC_IO0_CS16; - break; - case 1: /* 8 bits wide */ - break; - case 2: /* 16 bits wide */ - if (window) - x = (x & 0xf0) | PCIC_IO1_16BIT; - else - x = (x & 0x0f) | PCIC_IO0_16BIT; - break; - } - pcic_putb (slot, PCIC_IOCTL, x); - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) | IO_ENABLE_BIT(window)); -} - -#ifdef TEST -void -pcic_unmap_io (int slot, int window) -{ - pcic_putb (slot, PCIC_ADDRWINE, - pcic_getb (slot, PCIC_ADDRWINE) & ~IO_ENABLE_BIT(window)); - pcic_putw (slot, IO_START_ADDR(window), 0); - pcic_putw (slot, IO_STOP_ADDR(window), 0); -} -#endif /* TEST */ - -/* - * tell the PCIC which irq we want to use. only the following are legal: - * 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 - * - * NB: 'irq' is an interrupt NUMBER, not a MASK as in struct isa_device. - */ - -void -pcic_map_irq (int slot, int irq) -{ - if (irq < 3 || irq == 6 || irq == 8 || irq == 13 || irq > 15) { - printf ("zp: pcic_map_irq (slot %d): illegal irq %d\n", slot, irq); - return; - } - pcic_putb (slot, PCIC_INT_GEN, - pcic_getb (slot, PCIC_INT_GEN) | (irq & 0x0F)); -} - -void -pcic_power_on (int slot) -{ - pcic_putb (slot, PCIC_STATUS, - pcic_getb (slot, PCIC_STATUS) | PCIC_POW); - DELAY (100000); - pcic_putb (slot, PCIC_POWER, - pcic_getb (slot, PCIC_POWER) | PCIC_DISRST | PCIC_PCPWRE); - DELAY (100000); - pcic_putb (slot, PCIC_POWER, - pcic_getb (slot, PCIC_POWER) | PCIC_OUTENA); -} - -void -pcic_power_off (int slot) -{ - pcic_putb (slot, PCIC_POWER, - pcic_getb (slot, PCIC_POWER) & ~(PCIC_OUTENA|PCIC_PCPWRE)); -} - -void -pcic_reset (int slot) -{ - /* assert RESET (by clearing a bit!), wait a bit, and de-assert it */ - pcic_putb (slot, PCIC_INT_GEN, - pcic_getb (slot, PCIC_INT_GEN) & ~PCIC_CARDRESET); - DELAY (100000); - pcic_putb (slot, PCIC_INT_GEN, - pcic_getb (slot, PCIC_INT_GEN) | PCIC_CARDRESET); -} - diff --git a/sys/i386/isa/readMBR.c b/sys/i386/isa/readMBR.c deleted file mode 100644 index 7515723..0000000 --- a/sys/i386/isa/readMBR.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * - * THIS SOFTWARE IS PROVIDED BY THE WRITERS ``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 WRITERS 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. - * - * written by julian elischer (julian@tfs.com) - * - * @(#)readMBR.c 8.5 (tfs) 1/21/94 - * $Id: readMBR.c,v 1.4 1994/11/14 13:22:41 bde Exp $ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> -#include <sys/disklabel.h> - -#define b_cylinder b_resid - -/* - * Attempt to read a machine-type dependent Device partitioning table - * In this case a PC BIOS MBR. - * Destroys the original disklabel if it finds an MBR, so you'd better - * know what you're doing. It assumes that the label you've given it - * Is the one that controls the device, so that it can fiddle with it - * to make sure it's reading absolute sectors. - * On exit: - * Leaves the disklabel set up with the various partitions - * in the last 4 entries, - * the A partition pointing to the BSD part - * the C partition set as the BSD partition, (read the disklabel from there) and - * the D partition set as the whole disk for beating up - * will also give you a copy of the machine dependent table if you ask.. - * returns 0 for success, - * On failure, restores the disklabel and returns a messages pointer. - */ -char * -readMBRtolabel(dev, strat, lp, dp, cyl) - dev_t dev; - void (*strat)(); - register struct disklabel *lp; - struct dos_partition *dp; - int *cyl; -{ - register struct buf *bp; - struct disklabel *dlp; - struct disklabel labelsave; - char *msg = NULL; - int i; - int pseudopart = 4; /* we fill in pseudoparts from e through h*/ - int seenBSD = 0; - - /* - * Save a copy of the disklabel in case we return with an error - */ - bcopy(lp,&labelsave,sizeof(labelsave)); - - /* - * Set the disklabel to some useable partitions in case it's rubbish - */ - if (lp->d_secperunit == 0) - lp->d_secperunit = 0x1fffffff; - lp->d_npartitions = 4; - for (i=0; i<MAXPARTITIONS; i++) { - lp->d_partitions[i].p_offset = 0; - lp->d_partitions[i].p_size = 0; - } - lp->d_partitions[RAWPART].p_size = DOSBBSECTOR + 1; /* start low */ - strcpy(lp->d_packname,"MBR based label"); /* Watch the length ! */ - - /* - * Get a buffer and get ready to read the MBR - */ - bp = geteblk((int)lp->d_secsize); - /* read master boot record */ - bp->b_dev = makedev(major(dev), dkminor(dkunit(dev), RAWPART)); - bp->b_blkno = DOSBBSECTOR; - bp->b_bcount = lp->d_secsize; - bp->b_flags = B_BUSY | B_READ; - bp->b_cylinder = DOSBBSECTOR / lp->d_secpercyl; - (*strat)(bp); - - /* if successful, wander through dos partition table */ - if ( biowait(bp)) { - msg = "dos partition I/O error"; - goto bad; - } else { - /* - * If there seems to be BIOS bootblock and partition table - * in that block, then try interpret it, otherwise - * give up and use whatever we have synthesised so far - */ - if ((*(bp->b_un.b_addr + 510) != (char) 0x55) - ||(*(bp->b_un.b_addr + 511) != (char) 0xaa)) { - printf("disk doesn't have an MBR\n"); - if(dp) - bzero(bp->b_un.b_addr + DOSPARTOFF, - NDOSPART * sizeof(*dp)); - goto hrumpf; - } - - if(dp) { /* if they asked for a copy, give it to them */ - bcopy(bp->b_un.b_addr + DOSPARTOFF, dp, - NDOSPART * sizeof(*dp)); - } - dp = (struct dos_partition *)(bp->b_un.b_addr + DOSPARTOFF); - /* - * We have a DOS MBR.. - * We set up the last 4 partitions in the - * disklabel to reflect the DOS partitions - * In case we never find a disklabel, in which - * case this information will be all we have - * but it might be all we need to access a DOS - * partition. - */ - for (i = 0; i < NDOSPART; i++, dp++,pseudopart++) { - - if (!dp->dp_size) - continue; - /* - * Set this DOS part into the disklabel - */ - lp->d_partitions[pseudopart].p_size = - dp->dp_size; - lp->d_partitions[pseudopart].p_offset = - dp->dp_start; - - /* - * make sure the D part can hold it all - */ - if((dp->dp_start + dp->dp_size) - > lp->d_partitions[3].p_size) { - lp->d_partitions[3].p_size - = (dp->dp_start + dp->dp_size); - } - - /* - * If we haven't seen a *BSD partition then - * check if this is a valid part.. - * if it is it may be the best we are going to - * to see, so take note of it to deduce a - * geometry in case we never find a disklabel. - */ - switch(dp->dp_typ) { - case DOSPTYP_386BSD: - /* - * at a pinch we could throw - * a FFS on here - */ - lp->d_partitions[pseudopart].p_fstype - = FS_BSDFFS; - /* - * Only get a disklabel from the - * first one we see.. - */ - if (seenBSD == 0) { - /* - * If it IS our part, then we - * need sector address for - * SCSI/IDE, cylinder for - * ESDI/ST506/RLL - */ - seenBSD = 1; - *cyl = DPCYL(dp->dp_scyl, - dp->dp_ssect); - - /* - * Note which part we are in (?) - */ - lp->d_subtype &= ~3; - lp->d_subtype |= i & 3; - lp->d_subtype - |= DSTYPE_INDOSPART; - - /* - * update disklabel with - * details for reading the REAL - * disklabel it it exists - */ - lp->d_partitions[OURPART].p_size = - dp->dp_size; - lp->d_partitions[OURPART].p_offset = - dp->dp_start; - } - break; - case 0xB7: /* BSDI (?)*//* doubtful */ - lp->d_partitions[pseudopart].p_fstype - = FS_BSDFFS; - break; - case 1: - case 4: - case 6: - case 0xF2: - lp->d_partitions[pseudopart].p_fstype - = FS_MSDOS; - break; - } - - /* - * Try deduce the geometry, working - * on the principle that this - * partition PROBABLY ends on a - * cylinder boundary. - * This is really a kludge, but we are - * forced into it by the PC's design. - * If we've seen a 386bsd part, - * believe it and check no further. - */ - if (seenBSD) continue; - lp->d_ntracks = dp->dp_ehd + 1; - lp->d_nsectors = DPSECT(dp->dp_esect); - lp->d_secpercyl = lp->d_ntracks * - lp->d_nsectors; - } - lp->d_npartitions = 8; - } -hrumpf: - bp->b_flags = B_INVAL | B_AGE; - brelse(bp); - return 0; -bad: - bcopy(&labelsave,lp,sizeof(labelsave)); - bp->b_flags = B_INVAL | B_AGE; - brelse(bp); - return msg; -} - - diff --git a/sys/i386/isa/sound/HOWTO_MIDI b/sys/i386/isa/sound/HOWTO_MIDI deleted file mode 100644 index f0601e5..0000000 --- a/sys/i386/isa/sound/HOWTO_MIDI +++ /dev/null @@ -1,51 +0,0 @@ -The following file describes the procedure for adding modules to MIDI -Please READ the main documentation files for the driver first!!! - - - Example: We have a sound card with a MIDI chip & port on it - and, we call it the 'MYBLASTER' card: - - ************************************************************************** - - 0: Run 'configure'. Select the MIDI on CHIP support option. - - 1: Write a midi driver module; 'blast_midi.c' - (with functions for open,close,read,write,attach.) - - 1a: Write all functions except the 'attach' the way you want. - - For the 'attach' function, look at a model in the 'pro_midi.c' - file. Just dup it in the same fashion. For the 'generic_midi_operations' - structure which is required, see file 'dev_table.h'. - - 2: We called the 'attach' function: 'blast_attach'. - - Go to the file 'dev_table.h' and add your driver name and the function - pointer ( which is 'blast_attach' ) to the 'midi_supported' table. - - 3: You are almost set. Go and make a reference - to an 'exclude constant'; say EXLCUDE_BLAST_MIDI in your module - (refer to the 'pro_midi.c' file for model). Also make sure to - add the constant to the file 'sound_config.h' (for example, look - where the constant EXCLUDE_PRO_MIDI is in the file.) - - 4: Add the line - - #define ALL_EXTERNAL_TO_ME - - as the 1st line of your 'blast_midi.c' file. This happily, makes - you ignorant of everything else specific to the driver! :). - - 4a: And of course, don't forget to make a device :). Note that your - minor number should be = ( 15 + position of your driver in the - 'midi_supported' table in the 'dev_table.h' file ). - - Eg: Your driver is the second one in the table. viz midi_supported[1]. - Your device minor number should be ( 15 + 1 = 16 ). Then, make the - reference to your device as, say CMIDI_DEV_BLAST in the file - 'sound_config.h'. Also add this in 'soundcard.c' for the open, read, - write and close routines. See files for example using CMIDI_DEV_PRO - (which is the ProAudioSpectrum on chip MIDI). - - 5: You are all set. If ever you have problems, follow the same model - as the file 'pro_midi.c', except for substituting your own functions! diff --git a/sys/i386/isa/sound/RELNOTES b/sys/i386/isa/sound/RELNOTES deleted file mode 100644 index 03d492d..0000000 --- a/sys/i386/isa/sound/RELNOTES +++ /dev/null @@ -1,38 +0,0 @@ -Welcome to use the Linux sound driver for FreeBSD. This -driver supports the SoundBlaster, SB Pro, Pro Audio Spectrum 16, -AdLib and Gravis UltraSound sound cards. - -In addition there is rather limited support for MPU-401 -(and compatible) midi cards. Also, the OPL-3 synthesizer -of the SB Pro and PAS16 cards is now supported in the 4 OP -modes. - -Most of the features of the /dev/sequencer device file are -available just for GUS owners. - -The SoundBlaster 16 and SB 16 ASP cards are not supported, -though they may work in mono mode with speeds < 22 kHz. -The OPL-3 chicp of the SB 16 should work (without problems?). -Is there anybody willing to implement the SB 16 support -(have the SB 16 and the SDK for it)? - -Since this driver is a sound driver, it does not contain support -for SCSI/CD-ROM/Joystick -devices. - -Known bugs ----------- - -- It's not possible to open /dev/dsp (or /dev/audio) while the - /dev/sequencer is open for output and GUS is the only soundcard - installed. It's possible if /dev/dsp is opened before /dev/sequencer - but at this time the GUS is not available for access via /dev/sequencer. - This is a limitation of the driver. -- MPU-401 driver hangs the computer on boot if there is no MPU-401 installed. - It uses by default the I/O port 0x330, which is also used by the - Adaptec 1542 SCSI adapter. -- The /dev/sequencer playback to GUS sounds sometimes rather weird. Hitting - ^C and playing again should solve this problem. This is probably caused by - incompatibilities between the GUS and certain VLB motherboards. Try to avoid - switching between VTs while patches are being loaded to the GUS. -- There is a skeleton of the patch manager support. It doesn't work in - this version. diff --git a/sys/i386/isa/sound/RELNOTES.Linux b/sys/i386/isa/sound/RELNOTES.Linux deleted file mode 100644 index ea57d0a..0000000 --- a/sys/i386/isa/sound/RELNOTES.Linux +++ /dev/null @@ -1,255 +0,0 @@ -Release notes for the Linux Sound Driver 2.5 --------------------------------------------- -There is also a version called 2.5-beta floating around the net. This -version contains some fixes after it. Mainly to the SB and GUS code. - -CAUTION! The SVR4.2 port has not been tested much. Backup your system - carefully before trying it. - -This is mainly a bug fix release. There are couple of new things such as -linear volume mode for GUS and MIDI recording for SB 2.0 and SB Pro. -Also this version supports the mixer of GUS v3.7. (Support for GUS MAX and -the 16-bit daughtercard is coming sooner or later). - -NOTE! The sound driver is a part of the Linux kernel distribution also. - Check that your kernel doesn't have more recent version than this - when installing a separately distributed sound driver. The - version number of this driver is defined in the makefile. - -This version contains a driver for the SB16 also. -The SB16 driver requires separate DMA channels for the 8 and 16 bit -modes. There should be a way to share the 8 bit DMA channels between -these modes but this feature is not supported yet. -The SB16 DSP support is by Joerg Schubert (jsb@sth.ruhr-uni-bochum.de). - -The SB16 driver has also the Midi input capability even at the same -time with the /dev/dsp. Also the WaveBlaster daughter board is supported. -No support for the ASP chip yet (the ASP chip can be installed but it's -not used by the driver). - -You will need the snd-util-2.5.tar.gz and snd-data-0.1.tar.Z -packages to use this driver. They should be in the same -ftp site or BBS from where you got this driver. For -example at nic.funet.fi:pub/OS/Linux/*. - -If you are looking for the installation instructions, please -look at $OS/Readme. - -This version supports the following soundcards: -GUS, SoundBlaster, SB Pro, SB16, Pro Audio Spectrum 16 and AdLib. -In addition there is rather limited support for MPU-401. -(and compatible) midi cards. Also the OPL-3 synthesizer -Most of the features of the /dev/sequencer device file are -available just for GUS owners. - -NOTE! There are separate driver for CD-ROMS supported by - some soundcards. The driver for CDU31A (Fusion 16) is - called cdu31a-0.6.diff.z. It will be contained in the - Linux version 0.99.12. The driver for the CD-ROM of SB Pro - is sbpcd0.4.tar.gz (these were the latest versions when I wrote - this). These files should be at least at sunsite.unc.edu. - Also the SCSI interface of the PAS16 should be supported by - Linux 0.99.13k and later. - - There is also a driver for joystick. Look for file joystick-0.5.tar.gz - (sunsite). - - -Compatibility with the earlier versions ---------------------------------------- - -In this version the ultrasound.h no longer includes the sys/soundcard.h -You have to change the gmod.c of the snd-util-2.0 package and to add an -include for it. - -IMPORTANT!!!!!!!!!!!!!!!!!!!!!! - -This version is not binary or source compatible with the version 1.0c. - -The ioctl() interface has changed completely since version 1.0c. All -programs using this driver must be at least recompiled. -The snd-util-2.0 package contains some utilities for this version. - -The version 1.0c and earlier used a 'nonportable' ioctl calling scheme -where the input argument was passed by value and the output value was -returned as the functional return. For example setting the speed of -/dev/dsp were done as the following: - - int actual_speed; - actual_speed = ioctl(fd, SOUND_PCM_WRITE_RATE, 44100); - -After version 1.99.0 this must be done as the following: - - int actual_speed = 44100; - ioctl(fd, SOUND_PCM_WRITE_RATE, &actual_speed); - -If you have an application written for the version 1.0, you should search -for the strings SNDCTL_ and SOUND_ and to check the parameters. -The following ioctl calls have changed: - - SNDCTL_SEQ_GETOUTCOUNT - SNDCTL_SEQ_GETINCOUNT - SNDCTL_SEQ_TESTMIDI - SNDCTL_DSP_SPEED - SNDCTL_DSP_STEREO - SNDCTL_DSP_GETBLKSIZE - SNDCTL_DSP_SAMPLESIZE - SOUND_PCM_WRITE_CHANNELS - SOUND_PCM_WRITE_FILTER - SOUND_PCM_READ_RATE - SOUND_PCM_READ_CHANNELS - SOUND_PCM_READ_BITS - SOUND_PCM_READ_FILTER - SOUND_PCM_WRITE_BITS - SOUND_PCM_WRITE_RATE - SOUND_MIXER_READ_* (several ones) - SOUND_MIXER_WRITE_* (several ones) - -Since the this version will support more than one synthesizer devices -at the same time, the ioctl(SNDCTL_FM_LOAD_INSTR) is obsolete. In addition -there is some new fields which must be initialized. Look at the sbiset.c in -the snd-util-2.0 package for further info. - -This version is almost 100% compatible with the alpha test version (1.99.9). The -difference is in the installation procedure. - -Using this driver with other operating systems than Linux ---------------------------------------------------------- - -This package contains just the Linux version. The version 2.3 -for SCO is available at nic.funet.fi:pub/OS/Linux/ALPHA/sound. -The version 2.3 doesn't work well with xxxxxBSD. Use the version -2.3 for them. - -/dev/sndstat ------------- - -The /dev/sndstat is now available in the SCO and BSD versions also. - -This is a new devicefile for debugging purposes. A better place for -it is in the /proc -directory but I was just too lazy to implement it -properly. The /dev/sndstat (major 14, minor 6) is a file which returns -info about the current configuration (see the example below). If you -send me a error/problem report, please include a printout from this -device to your message (cat /dev/sndstat). - -Note! This device file is currently present only in the Linux version - of this driver. - ------- cut here --- cat /dev/sndstat example -------- -Sound Driver:1.99.7 (Fri Jul 9 17:01:47 GMT 1993 root@lucifer.savolai.fi) -Config options: 0x00000d4b - -HW config: -Type 4: Gravis Ultrasound at 0x210 irq 15 drq 6 -Type 3: ProAudioSpectrum at 0x388 irq 10 drq 3 -Type 2: SoundBlaster at 0x220 irq 7 drq 1 -Type 1: AdLib at 0x388 irq 0 drq 0 - -PCM devices: -00: Gravis UltraSound -01: Pro Audio Spectrum -02: SoundBlaster 2.0 - -Synth devices: -00: Gravis UltraSound -01: Yamaha OPL-3 - -Midi devices: -00: Gravis UltraSound -01: Pro Audio Spectrum - -Mixer(s) installed ------- cut here ---- End of Example ----------- - -Known bugs/limitations ----------------------- - -- High speed recording of long audio samples (>20 second) to disk - is not possible. Everything works until next sync() which delays the - recording process too much. A delay longer than 0.1 to 0.3 seconds is - too much. -- The SB16 driver sometimes swaps the left and right channels together. -- Midi input doesn't work with SB and SB Pro (SB16 works). -- It's not possible to open /dev/dsp (or /dev/audio) while the - /dev/sequencer is open for output and GUS is the only soundcard - installed. It's possible if /dev/dsp is opened before /dev/sequencer - but at this time the GUS is not available for access via /dev/sequencer. - This is a limitation of the driver. -- MPU-401 driver hangs the computer on boot if there is no MPU-401 installed. - It uses by default the I/O port 0x330 whic is used by Adaptec 1542 SCSI - adapter. -- There are some problems in midi input with MPU-401 and the SB16 midi - (MPU-401 emulation). This makes it impossible to read long sysex dumps - using these devices. -- The /dev/sequencer playback to GUS sounds sometimes rather weird. Hitting - ^C and playing again should solve this problem. This is propably caused by - incompatibilities between GUS and certain VLB motherboards (like mine). - Try to avoid - switching between VTs while patches are being loaded to the GUS. - This problem disappears completely if you define GUS_PATCH_NO_DMA in the - local.h (after make config in linux). The drawback is that patch loading - without DMA takes several times longer than with DMA. -- There is a skeleton of the patch manager support. It don't work in - this version. - - -Future development ------------------- - -- Since this driver is no longer just the Linux Sound Driver, it's time - to give it a new name. I have planned to use name VoxWare. -- I'm writing a Hacker's guide to the VoxWare sound driver. Should - be ready within this(/next) year (alpha version). -- Completion of the ISC, SCO and BSD ports. Port to SVR4.2. -- I'm interested to implement/include support for new soundcards and - operating systems. - - Hint for the soundcard and OS manufacturers: - I'm collecting soundcards (high end ones) and SDKs for them. In - addition I'm collecting PC operating systems. I will be happy if - somebody sends me such items. In addition such kind of donation - makes it easier to change the VoxWare driver to support your - soundcard or operating system. However, please contact me before - sending anything. - -I will propably release some fix versions within this and next year. At -least when the non-Linux versions get ready. The next major release (3.0) -will be quite complete rewrite and released after about a year (end of 94 or -beginning of 95). - - -Contributors ------------- - -This driver contains code by several contributors. In addition several other -persons have given usefull suggestions. The following is a list of major -contributors. (I could have forgotten some names.) - - Craig Metz 1/2 of the PAS16 Mixer and PCM support - Rob Hooft Volume computation algorithm for the FM synth. - Mika Liljeberg uLaw encoding and decoding routines - Greg Lee Volume computation algorithm for the GUS and - lot's of valuable suggestions. - Andy Warner Initial ISC port - Jim Lowe Initial FreeBSD port - Anders Baekgaard Bughunting and valuable suggestions. - Joerg Schubert SB16 DSP support. - Andrew Robinson Improvements to the GUS driver - Megens SA MIDI recording for SB and SB Pro. - Mikael Nordqvist Linear volume support for GUS. - Ian Hartas SVR4.2 port - Markus Aroharju and - Risto Kankkunen Major contributions to the mixer support - of GUS v3.7. - Hunyue Yau Sound Galaxy NX Pro mixer support. - -Regards, - -Hannu Savolainen -hannu@voxware.pp.fi, Hannu.Savolainen@Helsinki.fi - -Snail mail: Hannu Savolainen - Pallaksentie 4 A 2 - 00970 Helsinki - Finland diff --git a/sys/i386/isa/sound/Readme.freebsd b/sys/i386/isa/sound/Readme.freebsd deleted file mode 100644 index 03f96f4..0000000 --- a/sys/i386/isa/sound/Readme.freebsd +++ /dev/null @@ -1,36 +0,0 @@ - -This driver was updated to VoxWare v3.0 pre-release and ad1848 support was -enabled (since it works for me :) - -To configure the sound driver, one or more of these entries should go in your -config file: - -device snd5 at isa? port 0x330 irq 6 vector mpuintr # MPU-401 -device snd4 at isa? port 0x220 irq 15 drq 6 vector gusintr # GUS -device snd3 at isa? port 0x388 irq 10 drq 6 vector pasintr # PAS -device snd2 at isa? port 0x220 irq 7 drq 1 vector sbintr # SB -device snd6 at isa? port 0x220 irq 7 drq 5 vector sbintr # SB16 ? -device snd7 at isa? port 0x300 # YM3812 ??? -device snd1 at isa? port 0x388 # YM3812 -device snd10 at isa? port 0x530 irq 10 drq 1 vector adintr # MSS - -Then add some of these (no need for EXCLUDE_BLAH anymore): - -[ Need to know if multiple entries required! - jkh ] - -options AUDIO_PAS -options AUDIO_SB -options AUDIO_GUS -options AUDIO_MPU401 -options AUDIO_UART6850 -options AUDIO_PSS -options AUDIO_GUS16 -options AUDIO_GUSMAX -options AUDIO_MSS -options AUDIO_SBPRO -options AUDIO_SB16 -options AUDIO_YM3812 - - - --Sujal Patel (smpatel@wam.umd.edu) diff --git a/sys/i386/isa/sound/gustest/Makefile b/sys/i386/isa/sound/gustest/Makefile deleted file mode 100644 index d161e5b..0000000 --- a/sys/i386/isa/sound/gustest/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -all: gustest gusload gmod midithru - -gustest: gustest.c - $(CC) -o gustest gustest.c -lm - -gusload: gusload.c - $(CC) -o gusload gusload.c - -gmod: gmod.c - $(CC) -o gmod gmod.c - -midithru: midithru.c - $(CC) -o midithru midithru.c - -clean: - rm -f gusload gustest gmod midithru *.o diff --git a/sys/i386/isa/sound/gustest/Readme b/sys/i386/isa/sound/gustest/Readme deleted file mode 100644 index 7640bf8..0000000 --- a/sys/i386/isa/sound/gustest/Readme +++ /dev/null @@ -1,67 +0,0 @@ -The programs in this directory are more or less incompletely implemented. -I have used them for debugging purposes while developing the driver. - -Files in this directory: - - -../ultrasound.h (sys/ultrasound.h) - This file contains some macros which are similar than - the procedures provided by GUSUNIT.PAS. See gustest.c - for more information. - INSTALL THIS FILE TO YOUR /usr/include/sys !!!!!!!!!!!! - -gusload.c This program can be used to load patches (samples) to - the DRAM of GUS. It understands the format used in the - .pat files shipped with GUS. - - Usage: gusload pgm# patchfile. - or gusload reset #Removes all patches from memory. - - You should load just the patches you will need to play - a Midi file, since the memory capacity of GUS is rather - limited (256k-1M). - - Example: - - gusload 0 acpiano.pat - gusload 1 britepno.pat - gusload 19 church.pat - - This program is not required if the adagio package is - used. It can do the patch uploading itself. - -gmod.c This is a simple module player which demonstrates - programming with GUS. It doesn't try to interpret - most of the effect commands. In fact this program - may interpret the modules incorrectly since I am - not a module player expert. - This version plays .MOD, .STM and .669 modules. - -midithru.c This program reads messages from the Midi interface - and plays the notes with an internal synthesizer - (FM or GUS). The program accepts one argument, the - synthesizer device number. In addition to the note on - and note off messages it interprets also program changes - and channel pressure messages. - If you need an example on programming the /dev/sequencer, - this is a good one. The voice allocation algorithm is - not good so don't look at it. - - NOTE! This program is useful with gmod. Jus load - a module with gmod. Wait until the module has - finished or hit ^C. Now you can play the samples - with the midithru program. - - NOTE2! You need a Midi keyboard to use this program. In - addition the Midi interface of GUS is not supported - yet which means you need also PAS16 or MPU-401. - -pmtest.c -gpatinfo.c ******* For information only ******* - These programs demonstrate the patch manager interface - which will be included to some later driver version. - This interface is not complete in version 1.99.9. - Using pmtest will hang your system sooner or later. - -Hannu Savolainen -hsavolai@cs.helsinki.fi diff --git a/sys/i386/isa/sound/gustest/gmidi.h b/sys/i386/isa/sound/gustest/gmidi.h deleted file mode 100644 index 106cfa2..0000000 --- a/sys/i386/isa/sound/gustest/gmidi.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $Id$ - */ - char patch_names[][9] = - { - /* 0 */ "acpiano", - /* 1 */ "britepno", - /* 2 */ "synpiano", - /* 3 */ "honktonk", - /* 4 */ "epiano1", - /* 5 */ "epiano2", - /* 6 */ "hrpschrd", - /* 7 */ "clavinet", - /* 8 */ "celeste", - /* 9 */ "glocken", - /* 10 */ "musicbox", - /* 11 */ "vibes", - /* 12 */ "marimba", - /* 13 */ "xylophon", - /* 14 */ "tubebell", - /* 15 */ "santur", - /* 16 */ "homeorg", - /* 17 */ "percorg", - /* 18 */ "rockorg", - /* 19 */ "church", - /* 20 */ "reedorg", - /* 21 */ "accordn", - /* 22 */ "harmonca", - /* 23 */ "concrtna", - /* 24 */ "nyguitar", - /* 25 */ "acguitar", - /* 26 */ "jazzgtr", - /* 27 */ "cleangtr", - /* 28 */ "mutegtr", - /* 29 */ "odguitar", - /* 30 */ "distgtr", - /* 31 */ "gtrharm", - /* 32 */ "acbass", - /* 33 */ "fngrbass", - /* 34 */ "pickbass", - /* 35 */ "fretless", - /* 36 */ "slapbas1", - /* 37 */ "slapbas2", - /* 38 */ "synbass1", - /* 39 */ "synbass2", - /* 40 */ "violin", - /* 41 */ "viola", - /* 42 */ "cello", - /* 43 */ "contraba", - /* 44 */ "marcato", - /* 45 */ "pizzcato", - /* 46 */ "harp", - /* 47 */ "timpani", - /* 48 */ "marcato", - /* 49 */ "slowstr", - /* 50 */ "synstr1", - /* 51 */ "synstr2", - /* 52 */ "choir", - /* 53 */ "doo", - /* 54 */ "voices", - /* 55 */ "orchhit", - /* 56 */ "trumpet", - /* 57 */ "trombone", - /* 58 */ "tuba", - /* 59 */ "mutetrum", - /* 60 */ "frenchrn", - /* 61 */ "hitbrass", - /* 62 */ "synbras1", - /* 63 */ "synbras2", - /* 64 */ "sprnosax", - /* 65 */ "altosax", - /* 66 */ "tenorsax", - /* 67 */ "barisax", - /* 68 */ "oboe", - /* 69 */ "englhorn", - /* 70 */ "bassoon", - /* 71 */ "clarinet", - /* 72 */ "piccolo", - /* 73 */ "flute", - /* 74 */ "recorder", - /* 75 */ "woodflut", - /* 76 */ "bottle", - /* 77 */ "shakazul", - /* 78 */ "whistle", - /* 79 */ "ocarina", - /* 80 */ "sqrwave", - /* 81 */ "sawwave", - /* 82 */ "calliope", - /* 83 */ "chiflead", - /* 84 */ "voxlead", - /* 85 */ "voxlead", - /* 86 */ "lead5th", - /* 87 */ "basslead", - /* 88 */ "fantasia", - /* 89 */ "warmpad", - /* 90 */ "polysyn", - /* 91 */ "ghostie", - /* 92 */ "bowglass", - /* 93 */ "metalpad", - /* 94 */ "halopad", - /* 95 */ "sweeper", - /* 96 */ "aurora", - /* 97 */ "soundtrk", - /* 98 */ "crystal", - /* 99 */ "atmosphr", - /* 100 */ "freshair", - /* 101 */ "unicorn", - /* 102 */ "sweeper", - /* 103 */ "startrak", - /* 104 */ "sitar", - /* 105 */ "banjo", - /* 106 */ "shamisen", - /* 107 */ "koto", - /* 108 */ "kalimba", - /* 109 */ "bagpipes", - /* 110 */ "fiddle", - /* 111 */ "Shannai", - /* 112 */ "carillon", - /* 113 */ "agogo", - /* 114 */ "steeldrm", - /* 115 */ "woodblk", - /* 116 */ "taiko", - /* 117 */ "toms", - /* 118 */ "syntom", - /* 119 */ "revcym", - /* 120 */ "fx-fret", - /* 121 */ "fx-blow", - /* 122 */ "seashore", - /* 123 */ "jungle", - /* 124 */ "telephon", - /* 125 */ "helicptr", - /* 126 */ "applause", - /* 127 */ "ringwhsl" - }; diff --git a/sys/i386/isa/sound/gustest/gmod.c b/sys/i386/isa/sound/gustest/gmod.c deleted file mode 100644 index 2988783..0000000 --- a/sys/i386/isa/sound/gustest/gmod.c +++ /dev/null @@ -1,1589 +0,0 @@ -/* - * gmod.c - Module player for GUS and Linux. - * (C) Hannu Savolainen, 1993 - * - * NOTE! This program doesn't try to be a complete module player. - * It's just a too I used while developing the driver. In - * addition it can be used as an example on programming - * the LInux Sound Driver with GUS. - * $Id$ - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <machine/ultrasound.h> -#include <fcntl.h> -#include <math.h> -#include <string.h> - -#define CMD_ARPEG 0x00 -#define CMD_SLIDEUP 0x01 -#define CMD_SLIDEDOWN 0x02 -#define CMD_SLIDETO 0x03 -#define SLIDE_SIZE 8 -#define CMD_VOLSLIDE 0x0a -#define CMD_JUMP 0x0b -#define CMD_VOLUME 0x0c -#define CMD_BREAK 0x0d -#define CMD_SPEED 0x0f -#define CMD_NOP 0xfe -#define CMD_NONOTE 0xff - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#define MAX_TRACK 8 -#define MAX_PATTERN 128 -#define MAX_POSITION 128 - -struct note_info - { - unsigned char note; - unsigned char vol; - unsigned char sample; - unsigned char command; - short parm1, parm2; - }; - -struct voice_info - { - int sample; - int note; - int volume; - int pitchbender; - - /* Pitch sliding */ - - int slide_pitch; - int slide_goal; - int slide_rate; - - int volslide; - }; - -typedef struct note_info pattern[MAX_TRACK][64]; -int pattern_len[MAX_POSITION]; -int pattern_tempo[MAX_POSITION]; -pattern *pattern_table[MAX_PATTERN]; - -struct voice_info voices[MAX_TRACK]; - -int nr_channels, nr_patterns, songlength; -int tune[MAX_POSITION]; -double tick_duration; - -int period_table[] = -{ - 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453, - 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226, - 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113 -}; - -SEQ_DEFINEBUF (2048); - -int seqfd; -int sample_ok[128], sample_vol[128]; -int tmp, gus_dev; -double this_time, next_time; -int ticks_per_division; -double clock_rate; /* HZ */ - -/* - * The function seqbuf_dump() must always be provided - */ - -void play_module (char *name); -int load_module (char *name); -int play_note (int channel, struct note_info *pat); -void lets_play_voice (int channel, struct voice_info *v); - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -void -init_voices () -{ - int i; - - for (i = 0; i < MAX_TRACK; i++) - { - voices[i].sample = 0; - voices[i].note = 0; - voices[i].volume = 64; - - voices[i].slide_pitch = 0; - voices[i].slide_goal = 0; - voices[i].slide_rate = 0; - voices[i].pitchbender = 0; - - voices[i].volslide = 0; - } -} - -int -main (int argc, char *argv[]) -{ - int i, n, j; - struct synth_info info; - - if ((seqfd = open ("/dev/sequencer", O_WRONLY, 0)) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Gravis Ultrasound not detected\n"); - exit (-1); - } - - GUS_NUMVOICES (gus_dev, 14); - - for (i = 1; i < argc; i++) - { - for (j = 0; j < MAX_PATTERN; j++) - pattern_table[j] = NULL; - - if (load_module (argv[i])) - { - tick_duration = 100.0 / clock_rate; - play_module (argv[i]); - } - - } - - SEQ_DUMPBUF (); - close (seqfd); - - exit (0); -} - -unsigned short -intelize (unsigned short v) -{ - return ((v & 0xff) << 8) | ((v >> 8) & 0xff); -} - -unsigned long -intelize4 (unsigned long v) -{ - return - (((v >> 16) & 0xff) << 8) | (((v >> 16) >> 8) & 0xff) | - (((v & 0xff) << 8) | ((v >> 8) & 0xff) << 16); -} - -int -load_stm_module (int mod_fd, char *name) -{ - - struct sample_header - { - char name[12]; - unsigned char instr_disk; - unsigned short reserved1; - unsigned short length; /* In bytes */ - unsigned short loop_start; - unsigned short loop_end; - unsigned char volume; - unsigned char reserved2; - unsigned short C2_speed; - unsigned short reserved3; - - }; - - int i, total_mem; - int sample_ptr; - - int position; - - unsigned char *tune_ptr; /* array 0-127 */ - - char header[1105], sname[21]; - - int nr_samples; /* 16 or 32 samples (or 64 or ???) */ - int slen, npat; - - fprintf (stderr, "Loading .STM module: %s\n", name); - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - strncpy (sname, header, 20); - - fprintf (stderr, "\nModule: %s - ", sname); - - if (header[28] != 0x1a) - { - fprintf (stderr, "Not a STM module\n"); - close (mod_fd); - return 0; - } - - npat = header[33]; - slen = 0; - tune_ptr = &header[48 + (31 * 32)]; - - for (i = 0; i < 64; i++) - { - tune[i] = tune_ptr[i]; - if (tune[i] < npat) - slen = i; - } - - fprintf (stderr, "Song lenght %d, %d patterns.\n", slen, npat); - - nr_samples = 31; - - sample_ptr = 48 + (31 * 32) + 64 + (npat * 1024); /* Location where the - * first sample is - * stored */ - total_mem = 0; - - for (i = 0; i < 32; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end, base_freq; - unsigned short loop_flags = 0; - - struct sample_header *sample; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[48 + (i * 32)]; - - len = sample->length; - loop_start = sample->loop_start; - loop_end = sample->loop_end; - base_freq = sample->C2_speed; - - if (strlen (sample->name) > 21) - { - fprintf (stderr, "\nInvalid name for sample #%d\n", i); - close (mod_fd); - return 0; - } - - if (len > 0) - { - int x; - - if (loop_end > len) - loop_end = 1; - else if (loop_end < loop_start) - { - loop_start = 0; - loop_end = 0; - } - else - loop_flags = WAVE_LOOPING; - - total_mem += len; - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_freq = base_freq; - patch->base_note = 261630; /* Mid C */ - patch->low_note = 0; - patch->high_note = 0x7fffffff; - patch->volume = 120; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if ((x = read (mod_fd, patch->data, len)) != len) - { - fprintf (stderr, "Short file (sample at %d (%d!=%d)\n", sample_ptr, x, len); - close (mod_fd); - free (patch); - return 0; - } - - fprintf (stderr, "Sample %02d: %05d, %05d, %05d, %07d %s\n", - i, - len, - loop_start, - loop_end, - base_freq, - sample->name); - - if (write (seqfd, patch, sizeof (*patch) + len) == -1) - { - perror ("ioctl /dev/sequencer"); - exit (-1); - } - else - sample_ok[i] = 1; - - free (patch); - } - } - - nr_patterns = slen; - songlength = slen; - nr_channels = 4; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[64][4][4]; - int pat, channel, x; - - int pp = 1104 + (position * 1024); - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if ((x = read (mod_fd, patterns, 1024)) != 1024) - { - fprintf (stderr, "Short file (pattern at %d), %d!=%d\n", pp, x, 1024); - close (mod_fd); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - - for (channel = 0; channel < 4; channel++) - { - unsigned char *p; - - unsigned vol, note, octave, sample, effect, params; - - p = &patterns[pat][channel][0]; - - if (p[0] < 251) - { - note = p[0] & 15; - octave = p[0] / 16; - - note = 48 + octave * 12 + note; - - sample = p[1] / 8; - vol = (p[1] & 7) + (p[2] / 2); - effect = p[2] & 0xF; - params = p[3]; - } - else - { - note = 0; - octave = 0; - - sample = 0; - vol = 0; - effect = CMD_NONOTE; - params = 0; - } - - (*pattern_table[position])[channel][pat].note = note; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - - } - - } - - close (mod_fd); - return 1; -} - -int -load_669_module (int mod_fd, char *name) -{ - struct sample_header - { - char name[13]; - unsigned long length; /* In bytes */ - unsigned long loop_start; - unsigned long loop_end; - }; - - int i, total_mem; - int sample_ptr; - - int position; - - unsigned char *tune_ptr, *len_ptr, *tempo_ptr; /* array 0-127 */ - - char header[1084]; - char msg[110]; - - int nr_samples; /* 16 or 32 samples */ - int slen, npat; - - clock_rate = 25.0; - - fprintf (stderr, "Loading .669 module: %s\n", name); - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - if (*(unsigned short *) &header[0] != 0x6669) - { - fprintf (stderr, "Not a 669 file\n"); - close (mod_fd); - return 0; - } - - strncpy (msg, &header[2], 108); - - for (i = 0; i < strlen (msg); i++) - if ((msg[i] >= ' ' && msg[i] <= 'z') || msg[i] == '\n') - printf ("%c", msg[i]); - printf ("\n"); - - npat = header[0x6f]; - - tune_ptr = &header[0x71]; - - for (slen = 0; slen < 128 && tune_ptr[slen] != 0xff; slen++); - slen--; - - for (i = 0; i < slen; i++) - tune[i] = tune_ptr[i]; - - len_ptr = &header[0x171]; - for (i = 0; i < slen; i++) - pattern_len[i] = len_ptr[i] - 1; - - tempo_ptr = &header[0xf1]; - for (i = 0; i < slen; i++) - pattern_tempo[i] = tempo_ptr[i]; - - nr_samples = header[0x6e]; - - fprintf (stderr, "Song lenght %d, %d patterns, %d samples.\n", slen, npat, nr_samples); - - sample_ptr = 0x1f1 + (nr_samples * 0x19) + (npat * 0x600); /* Location where the - * first sample is - * stored */ - total_mem = 0; - - for (i = 0; i < 64; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end; - unsigned short loop_flags = 0; - - struct sample_header *sample; - char sname[14]; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[0x1f1 + (i * 0x19)]; - - len = *(unsigned long *) &sample->name[13]; - loop_start = *(unsigned long *) &sample->name[17]; - loop_end = *(unsigned long *) &sample->name[21]; - if (loop_end > len) - loop_end = 1; - else if (loop_end == len) - loop_end--; - - if (loop_end < loop_start) - { - loop_start = 0; - loop_end = 0; - } - - strncpy (sname, sample->name, 13); - - if (len > 0 && len < 200000) - { - total_mem += len; - - fprintf (stderr, "Sample %02d: %05d, %05d, %05d %s\n", - i, - len, - loop_start, - loop_end, - sname); - - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - if (loop_end == 0) - loop_end = 1; - if (loop_end >= len) - loop_end = 1; - - if (loop_end > 1) loop_flags = WAVE_LOOPING; - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = WAVE_UNSIGNED | loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_freq = 8448; - patch->base_note = 261630; - patch->low_note = 1000; - patch->high_note = 0x7fffffff; - patch->volume = 120; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - fprintf (stderr, "Seek failed\n"); - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if (read (mod_fd, patch->data, len) != len) - { - fprintf (stderr, "Short file (sample at %d)\n", sample_ptr); - close (mod_fd); - free (patch); - return 0; - } - - if (write (seqfd, patch, sizeof (*patch) + len) == -1) - { - perror ("ioctl /dev/sequencer"); - /* exit (-1); */ - } - else - sample_ok[i] = 1; - - free (patch); - } - } - - nr_patterns = slen; - songlength = slen; - nr_channels = 8; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[0x600]; - int pat, channel, x; - - int pp = 0x1f1 + (nr_samples * 0x19) + (position * 0x600); - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if ((x = read (mod_fd, patterns, 1024)) != 1024) - { - fprintf (stderr, "Short file (pattern at %d) %d!=1024\n", pp, x); - close (mod_fd); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - - for (channel = 0; channel < 8; channel++) - { - unsigned char *p; - - unsigned vol, period, sample, effect, params; - - p = &patterns[pat * 24 + channel * 3]; - - if (p[0] >= 0xfe || - (p[0] == 0xff && p[1] == 0xff && p[2] == 0xff) || - (p[0] == 0 && p[1] == 0 && p[2] == 0) || - *(int *) p == -1) - { - period = 0; - effect = CMD_NONOTE; - sample = 0; - vol = 0; - params = 0; - - if (p[0] == 0) - { - effect = CMD_BREAK; - params = -2; - } - } - else - { - period = (p[0] >> 2) + 48; - effect = (p[2] >> 4); - params = p[2] & 0x0f; - vol = p[1] & 0x0f; - - if (p[2] == 0xfe) - { - effect = CMD_VOLUME; - params = vol; - } - else if (p[2] == 0xff) - { - effect = CMD_NOP; - } - else - switch (effect) - { - case 0: /* a - Portamento up */ - effect = CMD_SLIDEUP; - break; - - case 1: /* b - Portamento down */ - effect = CMD_SLIDEDOWN; - break; - - case 2: /* c - Port to note */ - effect = CMD_SLIDETO; - break; - - case 3: /* d - Frequency adjust */ - effect = CMD_NOP; /* To be implemented */ - break; - - case 4: /* e - Frequency vibrato */ - effect = CMD_NOP; /* To be implemented */ - break; - - case 5: /* f - Set tempo */ - effect = CMD_SPEED; - break; - - default: - effect = CMD_NOP; - } - - sample = (((p[0] << 4) & 0x30) | ((p[1] >> 4) & 0x0f)) + 1; - } - - (*pattern_table[position])[channel][pat].note = period; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - - } - - } - - close (mod_fd); - return 1; -} - -int -load_mmd0_module (int mod_fd, char *name) -{ - - struct sample_header - { - unsigned short loop_start; - unsigned short loop_end; - unsigned char midich; - unsigned char midipreset; - unsigned char volume; - unsigned char strans; - }; - - int i, total_mem; - int sample_ptr; - - int position; - - unsigned char *tune_ptr; /* array 0-127 */ - - char header[1105]; - - int nr_samples; /* 16 or 32 samples (or 64 or ???) */ - int slen, npat; - - fprintf (stderr, "Loading .MED module: %s\n", name); - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - if (strncmp (header, "MMD0", 4)) - { - fprintf (stderr, "Not a MED module\n"); - close (mod_fd); - return 0; - } - - printf ("Module len %d\n", intelize4 (*(long *) &header[4])); - printf ("Song info %d\n", intelize4 (*(long *) &header[8])); - printf ("Song len %d\n", intelize4 (*(long *) &header[12])); - printf ("Blockarr %x\n", intelize4 (*(long *) &header[16])); - printf ("Blockarr len %d\n", intelize4 (*(long *) &header[20])); - printf ("Sample array %x\n", intelize4 (*(long *) &header[24])); - printf ("Sample array len %d\n", intelize4 (*(long *) &header[28])); - printf ("Exp data %x\n", intelize4 (*(long *) &header[32])); - printf ("Exp size %d\n", intelize4 (*(long *) &header[36])); - printf ("Pstate %d\n", intelize (*(long *) &header[40])); - printf ("Pblock %d\n", intelize (*(long *) &header[42])); - - return 0; - - npat = header[33]; - slen = 0; - tune_ptr = &header[48 + (31 * 32)]; - - for (i = 0; i < 64; i++) - { - tune[i] = tune_ptr[i]; - if (tune[i] < npat) - slen = i; - } - - fprintf (stderr, "Song lenght %d, %d patterns.\n", slen, npat); - - nr_samples = 31; - - sample_ptr = 48 + (31 * 32) + 64 + (npat * 1024); /* Location where the - * first sample is - * stored */ - total_mem = 0; - - for (i = 0; i < 32; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end, base_freq; - unsigned short loop_flags = 0; - - struct sample_header *sample; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[48 + (i * 32)]; - - /* - * len = sample->length; loop_start = sample->loop_start; loop_end = - * sample->loop_end; base_freq = sample->C2_speed; - * - * if (strlen (sample->name) > 21) { fprintf (stderr, "\nInvalid name for - * sample #%d\n", i); close (mod_fd); return 0; } - */ - if (len > 0) - { - int x; - - if (loop_end > len) - loop_end = 1; - - if (loop_end < loop_start) - { - loop_start = 0; - loop_end = 0; - } - - if (loop_end > 2) loop_flags = WAVE_LOOPING; - - total_mem += len; - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_freq = base_freq; - patch->base_note = 261630; /* Mid C */ - patch->low_note = 0; - patch->high_note = 0x7fffffff; - patch->volume = 120; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if ((x = read (mod_fd, patch->data, len)) != len) - { - fprintf (stderr, "Short file (sample at %d (%d!=%d)\n", sample_ptr, x, len); - close (mod_fd); - free (patch); - return 0; - } - /* - * fprintf (stderr, "Sample %02d: %05d, %05d, %05d, %07d %s\n", i, - * len, loop_start, loop_end, base_freq, sample->name); - */ - if (write (seqfd, patch, sizeof (*patch) + len) == -1) - { - perror ("ioctl /dev/sequencer"); - exit (-1); - } - else - sample_ok[i] = 1; - - free (patch); - } - } - - nr_patterns = slen; - songlength = slen; - nr_channels = 4; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[64][4][4]; - int pat, channel, x; - - int pp = 1104 + (position * 1024); - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if ((x = read (mod_fd, patterns, 1024)) != 1024) - { - fprintf (stderr, "Short file (pattern at %d), %d!=%d\n", pp, x, 1024); - close (mod_fd); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - - for (channel = 0; channel < 4; channel++) - { - unsigned char *p; - - unsigned vol, note, octave, sample, effect, params; - - p = &patterns[pat][channel][0]; - - if (p[0] < 251) - { - note = p[0] & 15; - octave = p[0] / 16; - - note = 48 + octave * 12 + note; - - sample = p[1] / 8; - vol = (p[1] & 7) + (p[2] / 2); - effect = p[2] & 0xF; - params = p[3]; - } - else - { - note = 0; - octave = 0; - - sample = 0; - vol = 0; - effect = CMD_NONOTE; - params = 0; - } - - (*pattern_table[position])[channel][pat].note = note; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - - } - - } - - close (mod_fd); - return 1; -} - -int -load_module (char *name) -{ - - struct sample_header - { - char name[22]; - unsigned short length; /* In words */ - - unsigned char finetune; - unsigned char volume; - - unsigned short repeat_point; /* In words */ - unsigned short repeat_length; /* In words */ - }; - - int i, mod_fd, total_mem; - int sample_ptr, pattern_loc; - - int position; - - unsigned char *tune_ptr; /* array 0-127 */ - - char header[1084]; - - int nr_samples; /* 16 or 32 samples */ - int slen, npat; - char mname[23]; - - ioctl (seqfd, SNDCTL_SEQ_SYNC, 0); - ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev); - - clock_rate = 50.0; - - for (i = 0; i < MAX_POSITION; i++) - pattern_len[i] = 64; - - for (i = 0; i < MAX_POSITION; i++) - pattern_tempo[i] = 0; - - if ((mod_fd = open (name, O_RDONLY, 0)) == -1) - { - perror (name); - return 0; - } - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - if (lseek (mod_fd, 0, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if (header[28] == 0x1a) - return load_stm_module (mod_fd, name); - - if (*(unsigned short *) &header[0] == 0x6669) - return load_669_module (mod_fd, name); - - if (!strncmp (header, "MMD0", 4)) - return load_mmd0_module (mod_fd, name); - - fprintf (stderr, "Loading .MOD module: %s\n", name); - - strncpy (mname, header, 22); - fprintf (stderr, "\nModule: %s - ", mname); - - if (!strncmp (&header[1080], "M.K.", 4) || !strncmp (&header[1080], "FLT8", 4)) - { - fprintf (stderr, "31 samples\n"); - nr_samples = 31; - } - else - { - fprintf (stderr, "15 samples\n"); - nr_samples = 15; - } - - if (nr_samples == 31) - { - sample_ptr = pattern_loc = 1084; - slen = header[950]; - tune_ptr = (unsigned char *) &header[952]; - } - else - { - sample_ptr = pattern_loc = 600; - slen = header[470]; - tune_ptr = (unsigned char *) &header[472]; - } - - npat = 0; - for (i = 0; i < 128; i++) - { - tune[i] = tune_ptr[i]; - - if (tune_ptr[i] > npat) - npat = tune_ptr[i]; - } - npat++; - - fprintf (stderr, "Song lenght %d, %d patterns.\n", slen, npat); - - sample_ptr += (npat * 1024); /* Location where the first sample is stored */ - total_mem = 0; - - for (i = 0; i < 32; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end; - unsigned short loop_flags = 0; - char pname[22]; - - struct sample_header *sample; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[20 + (i * 30)]; - - len = intelize (sample->length) * 2; - loop_start = intelize (sample->repeat_point) * 2; - loop_end = loop_start + (intelize (sample->repeat_length) * 2); - - if (loop_start > len) - loop_start = 0; - if (loop_end > len) - loop_end = len; - - if (loop_end <= loop_start) - loop_end = loop_start + 1; - - if (loop_end > 2 && loop_end > loop_start) - loop_flags = WAVE_LOOPING; - - strncpy (pname, sample->name, 20); - - if (len > 0) - { - fprintf (stderr, "Sample %02d: L%05d, S%05d, E%05d V%02d %s\n", - i, - len, - loop_start, - loop_end, - sample->volume, - pname); - - total_mem += len; - - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_note = 261630; /* Middle C */ - patch->base_freq = 8448; - patch->low_note = 0; - patch->high_note = 20000000; - patch->volume = 120; - patch->panning = 0; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if (read (mod_fd, patch->data, len) != len) - { - fprintf (stderr, "Short file (sample) %d\n", sample_ptr); - close (mod_fd); - free (patch); - return 0; - } - - SEQ_WRPATCH (patch, sizeof (*patch) + len); - - sample_ok[i] = 1; - if (sample->volume == 0) sample->volume = 64; - sample_vol[i] = sample->volume; - - free (patch); - } - } - - nr_patterns = npat; - songlength = slen; - nr_channels = 4; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[64][4][4]; - int pat, channel; - - int pp = pattern_loc + (position * 1024); - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if (read (mod_fd, patterns, 1024) != 1024) - { - fprintf (stderr, "Short file (pattern %d) %d\n", tune[position], pp); - close (mod_fd); - return 0; - } - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - for (channel = 0; channel < 4; channel++) - { - unsigned short tmp; - unsigned char *p; - - unsigned period, sample, effect, params, note, vol; - - p = &patterns[pat][channel][0]; - - tmp = (p[0] << 8) | p[1]; - sample = (tmp >> 8) & 0x10; - period = - MIN (tmp & 0xFFF, 1023); - tmp = (p[2] << 8) | p[3]; - sample |= tmp >> 12; - effect = (tmp >> 8) & 0xF; - params = tmp & 0xFF; - - note = 0; - - if (period) - { - /* - * Convert period to a Midi note number - */ - - for (note = 0; note < 37 && period != period_table[note]; note++); - if (note >= 37) - note = 0; - - note += 48; - } - - vol = 64; - - if (sample) - if (effect == 0xc) - { - vol = params; - } - else - vol = sample_vol[sample - 1]; - - vol *= 2; - if (vol>64)vol--; - - (*pattern_table[position])[channel][pat].note = note; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - } - } - - close (mod_fd); - return 1; -} - -int -panning (int ch) -{ - static int panning_tab[] = - {-110, 110, 110, -110}; - - return panning_tab[ch % 4]; -} - -void -set_speed (int parm) -{ - if (!parm) - parm = 1; - - if (parm < 32) - { - ticks_per_division = parm; - } - else - { - tick_duration = (60.0 / parm) * 10.0; - } - -} - -void -play_module (char *name) -{ - int i, position, jump_to_pos; - - init_voices (); - - SEQ_START_TIMER (); -#if 1 - for (i=0;i<32;i++) - { - SEQ_EXPRESSION(gus_dev, i, 127); - SEQ_MAIN_VOLUME(gus_dev, i, 100); - } -#endif - next_time = 0.0; - - set_speed (6); - - for (position = 0; position < songlength; position++) - { - int tick, pattern, channel, pos, go_to; - - pos = tune[position]; - if (pattern_tempo[position]) - set_speed (pattern_tempo[position]); - - jump_to_pos = -1; - for (pattern = 0; pattern < pattern_len[position] && jump_to_pos == -1; pattern++) - { - this_time = 0.0; - - for (channel = 0; channel < nr_channels; channel++) - { - if ((go_to = play_note (channel, &(*pattern_table[pos])[channel][pattern])) != -1) - jump_to_pos = go_to; - - } - - next_time += tick_duration; - - for (tick = 1; tick < ticks_per_division; tick++) - { - for (channel = 0; channel < nr_channels; channel++) - lets_play_voice (channel, &voices[channel]); - next_time += tick_duration; - } - - } - - if (jump_to_pos >= 0) - position = jump_to_pos; - } - - SEQ_WAIT_TIME ((int) next_time + 200); /* Wait extra 2 secs */ - - for (i = 0; i < nr_channels; i++) - SEQ_STOP_NOTE (gus_dev, i, 0, 127); - SEQ_DUMPBUF (); - - for (i = 0; i < nr_patterns; i++) - free (pattern_table[i]); -} - -void -sync_time () -{ - if (next_time > this_time) - { - SEQ_WAIT_TIME ((long) next_time); - this_time = next_time; - } -} - -void -set_volslide (int channel, struct note_info *pat) -{ - int n; - - voices[channel].volslide = 0; - - if ((n = (pat->parm1 & 0xf0) >> 4)) - voices[channel].volslide = n; - else - voices[channel].volslide = pat->parm1 & 0xf; -} - -void -set_slideto (int channel, struct note_info *pat) -{ - int size, rate, dir, range = 200; - - rate = pat->parm1; - size = voices[channel].note - pat->note; - if (!size) - return; - - if (size < 0) - { - size *= -1; - dir = -1; - } - else - dir = 1; - - if (size > 2) - { - range = size * 100; - rate = rate * size / 200; - } - - rate = pat->parm1 * dir / 30; - if (!rate) - rate = 1; - - voices[channel].slide_pitch = 1; - voices[channel].slide_goal = (dir * 8192 * 200 * 2 / size) / range; - voices[channel].pitchbender = 0; - voices[channel].slide_rate = rate; - SEQ_BENDER_RANGE (gus_dev, channel, range); -} - -int -play_note (int channel, struct note_info *pat) -{ - int jump = -1; - int sample; - - if (pat->sample == 0x3f) - pat->sample = 0; - - if (pat->command == CMD_NONOTE) - return -1; /* Undefined */ - - sample = pat->sample; - - if (sample && !pat->note) - { - pat->note = voices[channel].note; - } - - if (sample) - voices[channel].sample = sample; - else - sample = voices[channel].sample; - - sample--; - - if (pat->note && pat->command != 3) /* Have a note -> play */ - { - if (sample < 0) - sample = voices[channel].sample - 1; - - if (!sample_ok[sample]) - sample = voices[channel].sample - 1; - - if (sample < 0) - sample = 0; - - if (sample_ok[sample]) - { - sync_time (); - - if (pat->vol > 127) pat->vol=127; - SEQ_SET_PATCH (gus_dev, channel, sample); - SEQ_PANNING (gus_dev, channel, panning (channel)); - SEQ_PITCHBEND (gus_dev, channel, 0); - SEQ_START_NOTE (gus_dev, channel, pat->note, pat->vol); - - voices[channel].volume = pat->vol; - voices[channel].note = pat->note; - voices[channel].slide_pitch = 0; - } - else - SEQ_STOP_NOTE (gus_dev, channel, pat->note, pat->vol); - } - - switch (pat->command) - { - - case CMD_NOP:; - break; - - case CMD_JUMP: - jump = pat->parm1; - break; - - case CMD_BREAK: - jump = -2; - break; - - case CMD_SPEED: - set_speed (pat->parm1); - break; - - case CMD_SLIDEUP: - voices[channel].slide_pitch = 1; - voices[channel].slide_goal = 8191; - voices[channel].pitchbender = 0; - voices[channel].slide_rate = pat->parm1 * SLIDE_SIZE; - SEQ_BENDER_RANGE (gus_dev, channel, 200); - break; - - case CMD_SLIDEDOWN: - voices[channel].slide_pitch = 1; - voices[channel].slide_goal = -8192; - voices[channel].pitchbender = 0; - voices[channel].slide_rate = -pat->parm1 * SLIDE_SIZE; - SEQ_BENDER_RANGE (gus_dev, channel, 200); - break; - - case CMD_SLIDETO: - set_slideto (channel, pat); - break; - - case CMD_VOLUME: - { - int vol = pat->parm1*2; - if (vol>127) vol=127; - if (pat->note && pat->command != 3) - break; - SEQ_START_NOTE (gus_dev, channel, 255, vol); - } - break; - - case CMD_ARPEG: - break; - - case 0x0e: - /* printf ("Cmd 0xE%02x\n", pat->parm1); */ - break; - - case CMD_VOLSLIDE: - set_slideto (channel, pat); - break; - - default: - /* printf ("Command %x %02x\n", pat->command, pat->parm1); */ - } - - return jump; -} - -void -lets_play_voice (int channel, struct voice_info *v) -{ - if (v->slide_pitch) - { - v->pitchbender += v->slide_rate; - if (v->slide_goal < 0) - { - if (v->pitchbender <= v->slide_goal) - { - v->pitchbender = v->slide_goal; - v->slide_pitch = 0; /* Stop */ - } - } - else - { - if (v->pitchbender >= v->slide_goal) - { - v->pitchbender = v->slide_goal; - v->slide_pitch = 0; /* Stop */ - } - } - - sync_time (); - SEQ_PITCHBEND (gus_dev, channel, v->pitchbender); - } - - if (v->volslide) - { - v->volume += v->volslide; - sync_time (); - - if (v->volume > 127) v->volume = 127; - SEQ_START_NOTE (gus_dev, channel, 255, v->volume); - } -} diff --git a/sys/i386/isa/sound/gustest/gpatinfo.c b/sys/i386/isa/sound/gustest/gpatinfo.c deleted file mode 100644 index 17dcb12..0000000 --- a/sys/i386/isa/sound/gustest/gpatinfo.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * gpatinfo.c: This program demonstrates the patch management - * interface of the GUS driver. - * - * NOTE! The patch manager interface is highly device dependent, - * currently incompletely implemented prototype and - * will change before final implementation. - * - * $Id$ - */ - -#include <stdio.h> -#include <machine/ultrasound.h> -#include <stdlib.h> -#include <strings.h> -#include <unistd.h> -#include <fcntl.h> -#include "gmidi.h" - -#define GUS_DEV gus_dev - -#define patch_access(cmd, rec) \ - rec.command = cmd;\ - rec.device = gus_dev;\ - if (ioctl(seqfd, SNDCTL_PMGR_IFACE, &rec)==-1)\ - {\ - perror("/dev/sequencer(SNDCTL_PMGR_IFACE/" #cmd ")");\ - exit(-1);\ - } - -SEQ_DEFINEBUF (2048); - -int seqfd; - -int gus_dev = -1; - -/* - * The function seqbuf_dump() must always be provided - */ - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -int -main (int argc, char *argv[]) -{ - int i, j, n; - struct synth_info info; - struct patch_info *patch; - struct patmgr_info mgr, mgr2, mgr3; - - if ((seqfd = open ("/dev/sequencer", O_WRONLY, 0)) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - -/* - * First locate the GUS device - */ - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Error: Gravis Ultrasound not detected\n"); - exit (-1); - } - - printf("Gravis UltraSound device = %d\n", gus_dev); - - /* - * Get type of the Patch Manager interface of the GUS device - */ - - patch_access(PM_GET_DEVTYPE, mgr); - printf("Patch manager type: %d\n", mgr.parm1); - - if (mgr.parm1 != PMTYPE_WAVE) - { - fprintf(stderr, "Hups, this program seems to be obsolete\n"); - exit(-1); - } - - /* - * The GUS driver supports up to 256 different midi program numbers but - * this limit can be changed before compiling the driver. The following - * call returns the value compiled to the driver. - */ - - patch_access(PM_GET_PGMMAP, mgr); - printf("Device supports %d midi programs.\n", mgr.parm1); - - /* - * Each program can be undefined or it may have one or more patches. - * A patch consists of header and the waveform data. If there is more - * than one patch in a program, the right one is selected by checking the - * note number when the program is played. - * - * The following call reads an array indexed by program number. Each - * element defines the number of patches defined for the corresponding - * program. - */ - printf("Loaded programs:\n"); - - for (i=0;i<mgr.parm1;i++) - if (mgr.data.data8[i]) - { - printf("%03d: %2d patches\n", i, mgr.data.data8[i]); - - /* - * Next get the magic keys of the patches associated with this program. - * This key can be used to access the patc data. - */ - mgr2.parm1=i; - patch_access(PM_GET_PGM_PATCHES, mgr2); - for (j = 0;j<mgr2.parm1;j++) - { - printf("\tPatch %d: %3d ", j, mgr2.data.data32[j]); - - /* - * The last step is to read the patch header (without wave data). - * The header is returned in the mgr3.data. The field parm1 returns - * address of the wave data in tge GUS DRAM. Parm2 returns - * size of the struct patch_info in the kernel. - * - * There is also the PM_SET_PATCH call which allows modification of the - * header data. The only limitation is that the sample len cannot be - * increased. - */ - mgr3.parm1 = mgr2.data.data32[j]; - patch_access(PM_GET_PATCH, mgr3); - patch = (struct patch_info *)&mgr3.data; /* Pointer to the patch hdr */ - - printf("DRAM ptr = %7d, sample len =%6d bytes.\n", - mgr3.parm1, patch->len); - - } - } - - i = gus_dev; - - if (ioctl(seqfd, SNDCTL_SYNTH_MEMAVL, &i)==-1) exit(-1); - printf("%d bytes of DRAM available for wave data\n", i); - - - exit(0); -} diff --git a/sys/i386/isa/sound/gustest/gusload.c b/sys/i386/isa/sound/gustest/gusload.c deleted file mode 100644 index 1ed9a3b..0000000 --- a/sys/i386/isa/sound/gustest/gusload.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * $Id$ - */ -/* - * patutil.c - A sample program which loads patches to the Gravis - * Ultrasound - * - */ - -#ifndef PATCH_PATH -#define PATCH_PATH "/D/ultrasnd/midi" -#endif - -#include <stdio.h> -#include <machine/ultrasound.h> -#include <stdlib.h> -#include <strings.h> -#include <unistd.h> -#include <fcntl.h> -#include "gmidi.h" - -struct pat_header - { - char magic[12]; - char version[10]; - char description[60]; - unsigned char instruments; - char voices; - char channels; - unsigned short nr_waveforms; - unsigned short master_volume; - unsigned long data_size; - }; - -struct sample_header - { - char name[7]; - unsigned char fractions; - long len; - long loop_start; - long loop_end; - unsigned short base_freq; - long low_note; - long high_note; - long base_note; - short detune; - unsigned char panning; - - unsigned char envelope_rate[6]; - unsigned char envelope_offset[6]; - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - char modes; - - short scale_frequency; - unsigned short scale_factor; - }; - -#define GUS_DEV gus_dev - -SEQ_DEFINEBUF (2048); - -int seqfd; - -int gus_dev = -1; - -struct patch_info *patch; - -/* - * The function seqbuf_dump() must always be provided - */ - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -int -main (int argc, char *argv[]) -{ - int i, n, patfd, pgm, print_only = 0; - struct synth_info info; - struct pat_header header; - struct sample_header sample; - char buf[256]; - char name[256]; - long offset; - - if ((seqfd = open ("/dev/sequencer", O_WRONLY, 0)) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Error: Gravis Ultrasound not detected\n"); - exit (-1); - } - - if (argc == 2) - { - if (!strcmp (argv[1], "reset")) - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - perror ("Sample reset"); - exit (0); - } - - if (argc != 3) - { - fprintf (stderr, "Usage: %s pgm# patchfile\n", argv[0]); - fprintf (stderr, " or : %s pgm# GM\n", argv[0]); - fprintf (stderr, " or : %s pgm# -l\n", argv[0]); - fprintf (stderr, " or : %s reset\n", argv[0]); - fprintf (stderr, " or : %s -l patchfile\n", argv[0]); - exit (-1); - } - - pgm = atoi (argv[1]); - strcpy (name, argv[2]); - - if (strcmp (name, "GM") == 0 || strcmp(name, "-l")==0) - { - if (strcmp (name, "-l") == 0) print_only = 1; - if (pgm < 0 || pgm > 127) - { - fprintf (stderr, "pgm# must be between 0 and 127\n"); - exit (-1); - } - - sprintf (name, PATCH_PATH "/%s.pat", patch_names[pgm]); - - if (!print_only) - fprintf (stderr, "Loading program %d from %s\n", pgm, name); - } - else if (strcmp (argv[1], "-l") == 0) - print_only = 1; - - if ((patfd = open (name, O_RDONLY, 0)) == -1) - { - perror (name); - exit (-1); - } - - if (read (patfd, buf, 0xef) != 0xef) - { - fprintf (stderr, "%s: Short file\n", name); - exit (-1); - } - - memcpy ((char *) &header, buf, sizeof (header)); - - if (strncmp (header.magic, "GF1PATCH110", 12)) - { - fprintf (stderr, "%s: Not a patch file\n", name); - exit (-1); - } - - if (strncmp (header.version, "ID#000002", 10)) - { - fprintf (stderr, "%s: Incompatible patch file version\n", name); - exit (-1); - } - - header.nr_waveforms = *(unsigned short *) &buf[85]; - header.master_volume = *(unsigned short *) &buf[87]; - - if (print_only) - { - printf ("Patch file: %s contains %d samples\n\n", name, header.nr_waveforms); - printf ("Master volume: %d\n", header.master_volume); - } - - offset = 0xef; - - for (i = 0; i < header.nr_waveforms; i++) - { - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - exit (-1); - } - - if (read (patfd, &buf, sizeof (sample)) != sizeof (sample)) - { - fprintf (stderr, "%s: Short file\n", name); - exit (-1); - } - - memcpy ((char *) &sample, buf, sizeof (sample)); - - /* - * Since some fields of the patch record are not 32bit aligned, we must - * handle them specially. - */ - sample.low_note = *(long *) &buf[22]; - sample.high_note = *(long *) &buf[26]; - sample.base_note = *(long *) &buf[30]; - sample.detune = *(short *) &buf[34]; - sample.panning = (unsigned char) buf[36]; - - memcpy (sample.envelope_rate, &buf[37], 6); - memcpy (sample.envelope_offset, &buf[43], 6); - - sample.tremolo_sweep = (unsigned char) buf[49]; - sample.tremolo_rate = (unsigned char) buf[50]; - sample.tremolo_depth = (unsigned char) buf[51]; - - sample.vibrato_sweep = (unsigned char) buf[52]; - sample.vibrato_rate = (unsigned char) buf[53]; - sample.vibrato_depth = (unsigned char) buf[54]; - sample.modes = (unsigned char) buf[55]; - sample.scale_frequency = *(short *) &buf[56]; - sample.scale_factor = *(unsigned short *) &buf[58]; - - if (print_only) - { - printf("\nSample: %03d / %s\n", i, sample.name); - printf ("Len: %d, Loop start: %d, Loop end: %d\n", sample.len, sample.loop_start, sample.loop_end); - printf ("Flags: "); - if (sample.modes & WAVE_16_BITS) - printf ("16 bit "); - if (sample.modes & WAVE_UNSIGNED) - printf ("unsigned "); - if (sample.modes & WAVE_LOOP_BACK) - printf("reverse "); - if (sample.modes & WAVE_BIDIR_LOOP) - printf("bidir "); - if (sample.modes & WAVE_LOOPING) - printf ("looping "); else printf("one_shot" ); - if (sample.modes & WAVE_SUSTAIN_ON) - printf ("sustain "); - if (sample.modes & WAVE_ENVELOPES) - printf ("enveloped "); - printf ("\n"); - - if (sample.modes & WAVE_ENVELOPES) - { - int i; - - printf ("Envelope info: "); - for (i = 0; i < 6; i++) - { - printf ("%d/%d ", sample.envelope_rate[i], - sample.envelope_offset[i]); - } - printf ("\n"); - } - - printf("Tremolo: sweep=%d, rate=%d, depth=%d\n", - sample.tremolo_sweep, - sample.tremolo_rate, - sample.tremolo_depth); - - printf("Vibrato: sweep=%d, rate=%d, depth=%d\n", - sample.vibrato_sweep, - sample.vibrato_rate, - sample.vibrato_depth); - } - - offset = offset + 96; - patch = (struct patch_info *) malloc (sizeof (*patch) + sample.len); - - patch->key = GUS_PATCH; - patch->device_no = GUS_DEV; - patch->instr_no = pgm; - patch->mode = sample.modes | WAVE_TREMOLO | - WAVE_VIBRATO | WAVE_SCALE; - patch->len = sample.len; - patch->loop_start = sample.loop_start; - patch->loop_end = sample.loop_end; - patch->base_note = sample.base_note; - patch->high_note = sample.high_note; - patch->low_note = sample.low_note; - patch->base_freq = sample.base_freq; - patch->detuning = sample.detune; - patch->panning = (sample.panning - 7) * 16; - - memcpy (patch->env_rate, sample.envelope_rate, 6); - memcpy (patch->env_offset, sample.envelope_offset, 6); - - patch->tremolo_sweep = sample.tremolo_sweep; - patch->tremolo_rate = sample.tremolo_rate; - patch->tremolo_depth = sample.tremolo_depth; - - patch->vibrato_sweep = sample.vibrato_sweep; - patch->vibrato_rate = sample.vibrato_rate; - patch->vibrato_depth = sample.vibrato_depth; - - patch->scale_frequency = sample.scale_frequency; - patch->scale_factor = sample.scale_factor; - - patch->volume = header.master_volume; - - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - exit (-1); - } - - if (!print_only) - { - if (read (patfd, patch->data, sample.len) != sample.len) - { - fprintf (stderr, "%s: Short file\n", name); - exit (-1); - } - - SEQ_WRPATCH (patch, sizeof (*patch) + sample.len); - } - - offset = offset + sample.len; - } - - exit (0); -} diff --git a/sys/i386/isa/sound/gustest/midithru.c b/sys/i386/isa/sound/gustest/midithru.c deleted file mode 100644 index c4fab7f..0000000 --- a/sys/i386/isa/sound/gustest/midithru.c +++ /dev/null @@ -1,328 +0,0 @@ -/* - * $Id$ - */ -#include <stdio.h> -#include <machine/soundcard.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> -#include <sys/errno.h> - -SEQ_DEFINEBUF (2048); -SEQ_PM_DEFINES; - -int seqfd, dev = 0; -unsigned char buf[100]; -int bufp; - -/* LRU list for free operators */ - -unsigned char free_list[256]; -int fhead=0, ftail=0, flen=0; - -/* LRU list for still playing notes */ - -unsigned char note_list[256]; -int nhead=0, ntail=0, nlen=0; -unsigned char oper_note[32]; - -int pgm = 0; -int num_voices; -int bender = 0; /* Initially off */ - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -void -stop_note(int note, int velocity) -{ - int i, op; - - op=255; - - for (i=0;i<num_voices && op==255;i++) - { - if (oper_note[i]== note) op=i; - } - - if (op==255) - { - fprintf(stderr, "Note %d off, note not started\n", note); - fprintf(stderr, "%d, %d\n", flen, nlen); - return; /* Has already been killed ??? */ - } - - SEQ_STOP_NOTE(dev, op, note, velocity); - SEQ_DUMPBUF(); - - oper_note[op] = 255; - - free_list[ftail]=op; - flen++; - ftail = (ftail+1) % num_voices; - - for (i=0;i<16;i++) - if (note_list[i] == op) note_list[i] = 255; - - while (nlen && note_list[nhead] == 255) - { - nlen--; - /* printf("Remove from note queue %d, len %d\n", nhead, nlen); */ - nhead = (nhead+1) % 256; - } -} - -void -kill_one_note() -{ - int oldest; - - if (!nlen) {fprintf(stderr, "Free list empty but no notes playing\n");return;} /* No notes playing */ - - oldest = note_list[nhead]; - nlen--; - nhead = (nhead+1) % 256; - - fprintf(stderr, "Killing oper %d, note %d\n", oldest, oper_note[oldest]); - - if (oldest== 255) return; /* Was already stopped. Why? */ - - stop_note(oper_note[oldest], 127); -} - -void -start_note(int note, int velocity) -{ - int free; - - if (!flen) kill_one_note(); - - if (!flen) {printf("** no free voices\n");return;} /* Panic??? */ - - free = free_list[fhead]; - flen--; - fhead = (fhead+1) % num_voices; - - note_list[ntail] = free; - - if (nlen>255) - { -#if 0 - fprintf(stderr, "Note list overflow %d, %d, %d\n", - nlen, nhead, ntail); -#endif - nlen=0; /* Overflow -> hard reset */ - } - nlen++; - ntail = (ntail+1) % 256; - - oper_note[free] = note; - - SEQ_SET_PATCH(dev, free, pgm); - SEQ_PITCHBEND(dev, free, bender); - SEQ_START_NOTE(dev, free, note, velocity); - SEQ_DUMPBUF(); -} - -void -channel_pressure(int ch, int pressure) -{ - int i; - - for (i=0;i<num_voices;i++) - { - if (oper_note[i] != 255) - { -#if 1 - SEQ_CHN_PRESSURE(dev, i, pressure); -#else - SEQ_EXPRESSION(dev, i, pressure); -#endif - SEQ_DUMPBUF(); - } - } -} - -void -pitch_bender(int ch, int value) -{ - int i; - - value -= 8192; - - bender = value; - - for (i=0;i<num_voices;i++) - { - if (oper_note[i] != 255) - { - bender = value; - SEQ_PITCHBEND(dev, i, value); - SEQ_DUMPBUF(); - } - } -} - -void -do_buf() -{ - int ch = buf[0] & 0x0f; - int value; - - switch (buf[0] & 0xf0) - { - case 0x90: /* Note on */ - if (bufp < 3) break; - /* printf("Note on %d %d %d\n", ch, buf[1], buf[2]); */ - if (buf[2]) - start_note(buf[1], buf[2]); - else - stop_note(buf[1], buf[2]); - bufp=1; - break; - - case 0xb0: /* Control change */ - if (bufp < 3) break; - /* printf("Control change %d %d %d\n", ch, buf[1], buf[2]); */ - bufp=1; - break; - - case 0x80: /* Note off */ - if (bufp < 3) break; - /* printf("Note off %d %d %d\n", ch, buf[1], buf[2]); */ - stop_note(buf[1], buf[2]); - bufp=1; - break; - - case 0xe0: /* Pitch bender */ - if (bufp < 3) break; - value = ((buf[2] & 0x7f) << 7) | (buf[1] & 0x7f); - /* printf("Pitch bender %d %d\n", ch, value >> 7); */ - pitch_bender(ch, value); - bufp=1; - break; - - case 0xc0: /* Pgm change */ - if (bufp < 2) break; - /* printf("Pgm change %d %d\n", ch, buf[1]); */ - pgm = buf[1]; - if (PM_LOAD_PATCH(dev, 0, pgm) < 0) - if (errno != ESRCH) /* No such process */ - perror("PM_LOAD_PATCH"); - bufp=0; - break; - - case 0xd0: /* Channel pressure */ - if (bufp < 2) break; - /* printf("Channel pressure %d %d\n", ch, buf[1]); */ - channel_pressure(ch, buf[1]); - bufp=1; - break; - - default: - bufp=0; - } -} - -int -main (int argc, char *argv[]) -{ - int i, n, max_voice = 999; - - struct synth_info info; - - unsigned char ev[4], *p; - - if (argc >= 2) dev = atoi(argv[1]); - - for (i=0;i<16;i++) oper_note[i] = 255; - - if ((seqfd = open ("/dev/sequencer", O_RDWR, 0)) == -1) - { - perror ("open /dev/sequencer"); - exit (-1); - } - - if (argc >= 3) - { - int d = dev; - ioctl(seqfd, SNDCTL_FM_4OP_ENABLE, &d); - } - - info.device = dev; - - if (ioctl(seqfd, SNDCTL_SYNTH_INFO, &info)==-1) - { - perror ("info /dev/sequencer"); - exit (-1); - } - - num_voices = info.nr_voices; - if (num_voices>max_voice)num_voices = max_voice; - fprintf(stderr, "Output to synth device %d (%s)\n", dev, info.name); - fprintf(stderr, "%d voices available\n", num_voices); - - for (i=0;i<num_voices;i++) - { - flen++; - free_list[fhead] = i; - fhead = (fhead+1) % num_voices; - } - - bufp = 0; - if (PM_LOAD_PATCH(dev, 0, 0) < 0) /* Load the default instrument */ - if (errno != ESRCH) /* No such process */ - perror("PM_LOAD_PATCH"); - - while (1) - { - if ((n = read (seqfd, ev, sizeof (ev))) == -1) - { - perror ("read /dev/sequencer"); - exit (-1); - } - - for (i = 0; i <= (n / 4); i++) - { - p = &ev[i * 4]; - - if (p[0] == SEQ_MIDIPUTC && p[2] == 0 /* Midi if# == 0 */) - { -/* printf("%02x ", p[1]);fflush(stdout); */ - if (p[1] & 0x80) /* Status */ - { - if (bufp) - do_buf (); - buf[0] = p[1]; - bufp = 1; - } - else if (bufp) - { - buf[bufp++] = p[1]; - if ((buf[0] & 0xf0) == 0x90 || (buf[0] & 0xf0) == 0x80 || (buf[0] & 0xf0) == 0xb0 || - (buf[0] & 0xf0) == 0xe0) - { - if (bufp == 3) - do_buf (); - } - else - if ((buf[0] & 0xf0) == 0xc0 || (buf[0] & 0xf0) == 0xd0) - { - if (bufp == 2) do_buf(); - } - } - } - } - } - - exit (0); -} diff --git a/sys/i386/isa/sound/gustest/pmtest.c b/sys/i386/isa/sound/gustest/pmtest.c deleted file mode 100644 index 0520545..0000000 --- a/sys/i386/isa/sound/gustest/pmtest.c +++ /dev/null @@ -1,412 +0,0 @@ -/* - * $Id$ - */ -/* - * CAUTION! This program is just an incompletely implemented version - * of the patch manager daemon for GUS. Using this program - * with the driver version 1.99.9 will hang your system - * completely (sooner or later). - * - * This program is for information only. The final - * implementation of the patch manager will not be - * compatible with this one. - */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <machine/ultrasound.h> -#include <strings.h> -#include <sys/errno.h> -#include "gmidi.h" - -#ifndef PATCH_PATH -#define PATCH_PATH "/D/ultrasnd/midi" -#endif - -char loadmap[256] = -{0}; /* 1 if the patch is already loaded */ - -struct pat_header - { - char magic[12]; - char version[10]; - char description[60]; - unsigned char instruments; - char voices; - char channels; - unsigned short nr_waveforms; - unsigned short master_volume; - unsigned long data_size; - }; - -struct sample_header - { - char name[7]; - unsigned char fractions; - long len; - long loop_start; - long loop_end; - unsigned short base_freq; - long low_note; - long high_note; - long base_note; - short detune; - unsigned char panning; - - unsigned char envelope_rate[6]; - unsigned char envelope_offset[6]; - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - char modes; - - short scale_frequency; - unsigned short scale_factor; - }; -int seqfd = 0, gus_dev = -1; - -struct patch_info *patch; - -int -do_load_patch (struct patmgr_info *rec) -{ - int i, patfd, pgm, print_only = 0; - struct pat_header header; - struct sample_header sample; - char buf[256]; - char name[256]; - long offset; - - pgm = rec->data.data8[0]; - - if (loadmap[pgm]) - return 0; /* Already loaded */ - - sprintf (name, PATCH_PATH "/%s.pat", patch_names[pgm]); - - if ((patfd = open (name, O_RDONLY, 0)) == -1) - { - perror (name); - return errno; - } - - if (read (patfd, buf, 0xef) != 0xef) - { - fprintf (stderr, "%s: Short file\n", name); - return EIO; - } - - memcpy ((char *) &header, buf, sizeof (header)); - - if (strncmp (header.magic, "GF1PATCH110", 12)) - { - fprintf (stderr, "%s: Not a patch file\n", name); - return EINVAL; - } - - if (strncmp (header.version, "ID#000002", 10)) - { - fprintf (stderr, "%s: Incompatible patch file version\n", name); - return EINVAL; - } - - header.nr_waveforms = *(unsigned short *) &buf[85]; - header.master_volume = *(unsigned short *) &buf[87]; - - printf ("GUS: Loading: %s\n", name); - - offset = 0xef; - - for (i = 0; i < header.nr_waveforms; i++) - { - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - return errno; - } - - if (read (patfd, &buf, sizeof (sample)) != sizeof (sample)) - { - fprintf (stderr, "%s: Short file\n", name); - return EIO; - } - - memcpy ((char *) &sample, buf, sizeof (sample)); - - /* - * Since some fields of the patch record are not 32bit aligned, we must - * handle them specially. - */ - sample.low_note = *(long *) &buf[22]; - sample.high_note = *(long *) &buf[26]; - sample.base_note = *(long *) &buf[30]; - sample.detune = *(short *) &buf[34]; - sample.panning = (unsigned char) buf[36]; - - memcpy (sample.envelope_rate, &buf[37], 6); - memcpy (sample.envelope_offset, &buf[43], 6); - - sample.tremolo_sweep = (unsigned char) buf[49]; - sample.tremolo_rate = (unsigned char) buf[50]; - sample.tremolo_depth = (unsigned char) buf[51]; - - sample.vibrato_sweep = (unsigned char) buf[52]; - sample.vibrato_rate = (unsigned char) buf[53]; - sample.vibrato_depth = (unsigned char) buf[54]; - sample.modes = (unsigned char) buf[55]; - sample.scale_frequency = *(short *) &buf[56]; - sample.scale_factor = *(unsigned short *) &buf[58]; - - if (print_only) - { - printf ("\nSample: %03d / %s\n", i, sample.name); - printf ("Len: %d, Loop start: %d, Loop end: %d\n", sample.len, sample.loop_start, sample.loop_end); - printf ("Flags: "); - if (sample.modes & WAVE_16_BITS) - printf ("16 bit "); - if (sample.modes & WAVE_UNSIGNED) - printf ("unsigned "); - if (sample.modes & WAVE_LOOP_BACK) - printf ("reverse "); - if (sample.modes & WAVE_BIDIR_LOOP) - printf ("bidir "); - if (sample.modes & WAVE_LOOPING) - printf ("looping "); - else - printf ("one_shot"); - if (sample.modes & WAVE_SUSTAIN_ON) - printf ("sustain "); - if (sample.modes & WAVE_ENVELOPES) - printf ("enveloped "); - printf ("\n"); - - if (sample.modes & WAVE_ENVELOPES) - { - int i; - - printf ("Envelope info: "); - for (i = 0; i < 6; i++) - { - printf ("%d/%d ", sample.envelope_rate[i], - sample.envelope_offset[i]); - } - printf ("\n"); - } - - printf ("Tremolo: sweep=%d, rate=%d, depth=%d\n", - sample.tremolo_sweep, - sample.tremolo_rate, - sample.tremolo_depth); - - printf ("Vibrato: sweep=%d, rate=%d, depth=%d\n", - sample.vibrato_sweep, - sample.vibrato_rate, - sample.vibrato_depth); - } - - offset = offset + 96; - patch = (struct patch_info *) malloc (sizeof (*patch) + sample.len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = pgm; - patch->mode = sample.modes | WAVE_TREMOLO | - WAVE_VIBRATO | WAVE_SCALE; - patch->len = sample.len; - patch->loop_start = sample.loop_start; - patch->loop_end = sample.loop_end; - patch->base_note = sample.base_note; - patch->high_note = sample.high_note; - patch->low_note = sample.low_note; - patch->base_freq = sample.base_freq; - patch->detuning = sample.detune; - patch->panning = (sample.panning - 7) * 16; - - memcpy (patch->env_rate, sample.envelope_rate, 6); - memcpy (patch->env_offset, sample.envelope_offset, 6); - - patch->tremolo_sweep = sample.tremolo_sweep; - patch->tremolo_rate = sample.tremolo_rate; - patch->tremolo_depth = sample.tremolo_depth; - - patch->vibrato_sweep = sample.vibrato_sweep; - patch->vibrato_rate = sample.vibrato_rate; - patch->vibrato_depth = sample.vibrato_depth; - - patch->scale_frequency = sample.scale_frequency; - patch->scale_factor = sample.scale_factor; - - patch->volume = header.master_volume; - - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - return errno; - } - - if (!print_only) - { - if (read (patfd, patch->data, sample.len) != sample.len) - { - fprintf (stderr, "%s: Short file\n", name); - return EIO; - } - - if (write (seqfd, patch, sizeof (*patch) + sample.len) == -1) - { - perror ("/dev/pmgr0"); - return errno; - } - } - - offset = offset + sample.len; - } - - loadmap[pgm] = 1; - return 0; -} - -int -main (int argc, char *argv[]) -{ - struct patmgr_info inf; - int err, i, n; - struct synth_info info; - - if ((seqfd = open ("/dev/patmgr0", O_RDWR, 0)) == -1) - { - fprintf (stderr, "Cannot open\n"); - perror ("/dev/patmgr0"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("NRSYNTH: /dev/patmgr0"); - exit (-1); - } - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("SYNTH_INFO: /dev/patmgr0"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Error: Gravis Ultrasound not detected\n"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - perror ("Sample reset"); - - for (i = 0; i < 256; i++) - loadmap[i] = 0; - - while (1) - { - if (read (seqfd, (char *) &inf, sizeof (inf)) != sizeof (inf)) - { - perror ("Read"); - exit (-1); - } - - if (inf.key == PM_K_EVENT) - switch (inf.command) - { - case PM_E_OPENED: - printf ("Opened\n"); - break; - - case PM_E_CLOSED: - printf ("Closed\n"); - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - perror ("Sample reset"); - for (i = 0; i < 256; i++) - loadmap[i] = 0; - break; - - case PM_E_PATCH_RESET: - printf ("Patch reset called\n"); - for (i = 0; i < 256; i++) - loadmap[i] = 0; - break; - - case PM_E_PATCH_LOADED: - printf ("Patch loaded by client\n"); - break; - - default: - printf ("Unknown event %d\n", inf.command); - inf.key = PM_ERROR; - inf.parm1 = EINVAL; - } - else if (inf.key == PM_K_COMMAND) - switch (inf.command) - { - case _PM_LOAD_PATCH: - if ((err = do_load_patch (&inf))) - if (err == ENOSPC) - { - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - { - perror ("Sample reset"); - return errno; - } - - for (i = 0; i < 256; i++) - loadmap[i] = 0; - err = do_load_patch (&inf); - } - - if (err) - { - inf.key = PM_ERROR; - inf.parm1 = err; - printf("Error = %d\n", err); - } - else - { - inf.key = PM_K_COMMAND; - inf.parm1 = 0; - } - break; - - default: - printf ("Unknown command %d\n", inf.command); - inf.key = PM_ERROR; - inf.parm1 = EINVAL; - } - else - { - printf ("Unknown event %d/%d\n", inf.key, inf.command); - inf.key = PM_ERROR; - inf.parm1 = EINVAL; - } - - if (write (seqfd, (char *) &inf, sizeof (inf)) != sizeof (inf)) - { - perror ("write"); - exit (-1); - } - } - - exit (0); -} diff --git a/sys/i386/isa/sound/midi.c b/sys/i386/isa/sound/midi.c deleted file mode 100644 index a11a4df..0000000 --- a/sys/i386/isa/sound/midi.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright by UWM - comments to soft-eng@cs.uwm.edu - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id$ - */ -#define _MIDI_TABLE_C_ -#include "sound_config.h" - -#ifdef CONFIGURE_SOUNDCARD - -#ifndef EXCLUDE_CHIP_MIDI - - -static int generic_midi_busy[MAX_MIDI_DEV]; - -long -CMIDI_init (long mem_start) -{ - - int i; - int n = num_midi_drivers; - - /* - * int n = sizeof (midi_supported) / sizeof( struct generic_midi_info ); - */ - for (i = 0; i < n; i++) - { - if (midi_supported[i].attach (mem_start)) - { - printk ("MIDI: Successfully attached %s\n", midi_supported[i].name); - } - - } - return (mem_start); -} - - -int -CMIDI_open (int dev, struct fileinfo *file) -{ - - int mode, err, retval; - - dev = dev >> 4; - - mode = file->mode & O_ACCMODE; - - - if (generic_midi_busy[dev]) - return (RET_ERROR (EBUSY)); - - - if (dev >= num_generic_midis) - { - printk (" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - if (!generic_midi_devs[dev]) - { - printk (" MIDI device %d not initialized\n", dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - retval = generic_midi_devs[dev]->open (dev, mode); - - /* If everything ok, set device as busy */ - - if (retval >= 0) - generic_midi_busy[dev] = 1; - - return (retval); - -} - -int -CMIDI_write (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) -{ - - int retval; - - dev = dev >> 4; - - if (dev >= num_generic_midis) - { - printk (" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - /* - * Make double sure of healthiness -- doubt Need we check this again?? - * - */ - - if (!generic_midi_devs[dev]) - { - printk (" MIDI device %d not initialized\n", dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - retval = generic_midi_devs[dev]->write (dev, buf); - - return (retval); - -} - -int -CMIDI_read (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) -{ - int retval; - - dev = dev >> 4; - - if (dev >= num_generic_midis) - { - printk (" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - /* - * Make double sure of healthiness -- doubt Need we check this again?? - * - */ - - if (!generic_midi_devs[dev]) - { - printk (" MIDI device %d not initialized\n", dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - retval = generic_midi_devs[dev]->read (dev, buf); - - return (retval); - -} - -int -CMIDI_close (int dev, struct fileinfo *file) -{ - - int retval; - - dev = dev >> 4; - - if (dev >= num_generic_midis) - { - printk (" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - /* - * Make double sure of healthiness -- doubt Need we check this again?? - * - */ - - if (!generic_midi_devs[dev]) - { - printk (" MIDI device %d not initialized\n", dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - generic_midi_devs[dev]->close (dev); - - generic_midi_busy[dev] = 0; /* Free the device */ - - return (0); - -} - -#endif - -#endif diff --git a/sys/i386/isa/sound/pro_midi.c b/sys/i386/isa/sound/pro_midi.c deleted file mode 100644 index 93c1937..0000000 --- a/sys/i386/isa/sound/pro_midi.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright by UWM - comments to soft-eng@cs.uwm.edu - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id$ - */ -#define ALL_EXTERNAL_TO_ME -#include "sound_config.h" - -#ifdef CONFIGURE_SOUNDCARD - -#include "pas.h" -#define ESUCCESS 0 - -#if !defined(EXCLUDE_PRO_MIDI) && !defined(EXCLUDE_CHIP_MIDI) - - -/** Structure for handling operations **/ - - -static struct generic_midi_operations pro_midi_operations = -{ - - {"Pro_Audio_Spectrum 16 MV101", 0}, - pro_midi_open, - pro_midi_close, - pro_midi_write, - pro_midi_read -}; - -/* - * Note! Note! Note! Follow the same model for any other attach function you - * may write - */ - -long -pro_midi_attach (long mem_start) -{ - pro_midi_dev = num_generic_midis; - generic_midi_devs[num_generic_midis++] = &pro_midi_operations; - return mem_start; -} - -int -pro_midi_open (int dev, int mode) -{ - - int intr_mask, s; - - - s = splhigh (); - - - /* Reset the input and output FIFO pointers */ - - - outb (MIDI_CONTROL, M_C_RESET_INPUT_FIFO | M_C_RESET_OUTPUT_FIFO); - - /* Get the interrupt status */ - - intr_mask = inb (INTERRUPT_MASK); - - - /* Enable MIDI IRQ */ - - intr_mask |= I_M_MIDI_IRQ_ENABLE; - outb (INTERRUPT_MASK, intr_mask); - - - /* Enable READ/WRITE on MIDI port. This part is quite unsure though */ - - outb (MIDI_CONTROL, M_C_ENA_OUTPUT_IRQ | M_C_ENA_INPUT_IRQ); - - /* Acknowledge pending interrupts */ - - outb (MIDI_STATUS, 0xff); - - - splx (s); - - return (ESUCCESS); - - -} - - -void -pro_midi_close (int dev) -{ - - int intr_mask; - - /* Clean up */ - - outb (MIDI_CONTROL, M_C_RESET_INPUT_FIFO | M_C_RESET_OUTPUT_FIFO); - intr_mask = inb (INTERRUPT_MASK); - intr_mask &= ~I_M_MIDI_IRQ_ENABLE; - outb (INTERRUPT_MASK, intr_mask); - - return; -} - -int -pro_midi_write (int dev, struct uio *uio) -{ - - int s; - unsigned char data; - - /* printf("midi: Going to do write routine..\n"); */ - while (uio->uio_resid) - { - - if (uiomove (&data, 1, uio)) - return (ENOTTY); - - s = splhigh (); - - DELAY (30); - outb (MIDI_DATA, data); - DELAY (70); /* Ze best pause.. find a better one if you - * can :) */ - splx (s); - } - - return (ESUCCESS); - -} - - -int -pro_midi_read (int dev, struct uio *uio) -{ - - int s; - unsigned char data; - - s = splhigh (); - - /* For each uio_iov[] entry .... */ - - while (uio->uio_resid) - { - - if (((inb (MIDI_STATUS) & M_S_INPUT_AVAIL) == 0) && - ((inb (MIDI_FIFO_STATUS) & MIDI_INPUT_AVAILABLE) == 0)) - - data = 0xfe; - else - data = inb (MIDI_DATA); - - if (uiomove (&data, 1, uio)) - { - - printf ("midi: Bad copyout()!\n"); - return (ENOTTY); - - } - - } - splx (s); - return (ESUCCESS); - -} - -#endif - -#endif diff --git a/sys/i386/isa/sound/pss.c b/sys/i386/isa/sound/pss.c deleted file mode 100644 index 839f142..0000000 --- a/sys/i386/isa/sound/pss.c +++ /dev/null @@ -1,925 +0,0 @@ -/* Marc.Hoffman@analog.com - - This is a pss driver. - - it is based on Greg.Yukna@analog.com @file{host} for DOG - - Unfortunately I can't distribute the ld file needed to - make the pss card to emulate the SB stuff. - - I have provided a simple interface to the PSS unlike the - DOG version. to download a new algorithm just cat it to - /dev/pss 14,9. - - You really need to rebuild this with the synth.ld file - - get the <synth>.ld from your dos directory maybe - voyetra\dsp001.ld - - ld2inc < synth.ld > synth-ld.h - (make config does the same). - - rebuild - - Okay if you blow things away no problem just - - main(){ioctl(open("/dev/pss"),SNDCTL_PSS_RESET)}; - - and everything will be okay. - - At first I was going to worry about applications that were using - the sound stuff and disallow the use of /dev/pss. But for - now I figured it doesn't matter. - - And if you change algos all the other applications running die off - due to DMA problems. Yeah just pull the plug and watch em die. - - If the registers get hosed - main(){ioctl(open("/dev/pss"),SNDCTL_PSS_SETUP_REGISTERS)}; - - Probably everything else can be done via mmap - - Oh if you want to develop code for the ADSP-21xx or Program the - 1848 just send me mail and I will hook you up. - - marc.hoffman@analog.com - - * $Id: pss.c,v 1.2 1994/10/01 02:17:00 swallace Exp $ - */ -#include "sound_config.h" - -#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_PSS) - -#ifndef PSS_MSS_BASE -#define PSS_MSS_BASE 0 -#endif - -#ifndef PSS_MPU_BASE -#define PSS_MPU_BASE 0 -#endif - -#ifndef PSS_MPU_IRQ -#define PSS_MPU_IRQ 0 -#endif - -#undef DEB -#define DEB(x) x - -#include "pss.h" - -static int pss_ok = 0; -static int sb_ok = 0; - -static int pss_base; -static int pss_irq; -static int pss_dma; - -static int gamePort = 0; - -static int sbInt; -static int cdPol; -static int cdAddr = 0; /* 0x340; */ -static int cdInt = 10; - -/* Define these by hand in local.h */ -static int wssAddr = PSS_MSS_BASE; -static int midiAddr = PSS_MPU_BASE; -static int midiInt = PSS_MPU_IRQ; - -static int SoundPortAddress; -static int SoundPortData; -static int speaker = 1; - - -static struct pss_speaker default_speaker = -{0, 0, 0, PSS_STEREO}; - -DEFINE_WAIT_QUEUE (pss_sleeper, pss_sleep_flag); - -#include "synth-ld.h" - -static int pss_download_boot (unsigned char *block, int size); -static int pss_reset_dsp (void); - -static inline void -pss_outpw (unsigned short port, unsigned short value) -{ - __asm__ __volatile__ ("outw %w0, %w1" - : /* no outputs */ - :"a" (value), "d" (port)); -} - -static inline unsigned int -pss_inpw (unsigned short port) -{ - unsigned int _v; - __asm__ __volatile__ ("inw %w1,%w0" - :"=a" (_v):"d" (port), "0" (0)); - - return _v; -} - -static void -PSS_write (int data) -{ - int i, limit; - - limit = GET_TIME () + 10; /* The timeout is 0.1 seconds */ - /* - * Note! the i<5000000 is an emergency exit. The dsp_command() is sometimes - * called while interrupts are disabled. This means that the timer is - * disabled also. However the timeout situation is a abnormal condition. - * Normally the DSP should be ready to accept commands after just couple of - * loops. - */ - - for (i = 0; i < 5000000 && GET_TIME () < limit; i++) - { - if (pss_inpw (pss_base + PSS_STATUS) & PSS_WRITE_EMPTY) - { - pss_outpw (pss_base + PSS_DATA, data); - return; - } - } - printk ("PSS: DSP Command (%04x) Timeout.\n", data); - printk ("IRQ conflict???\n"); -} - - -static void -pss_setaddr (int addr, int configAddr) -{ - int val; - - val = pss_inpw (configAddr); - val &= ADDR_MASK; - val |= (addr << 4); - pss_outpw (configAddr, val); -} - -/*_____ pss_checkint - This function tests an interrupt number to see if - it is available. It takes the interrupt button - as it's argument and returns TRUE if the interrupt - is ok. -*/ -static int -pss_checkint (int intNum) -{ - int val; - int ret; - int i; - - /*_____ Set the interrupt bits */ - switch (intNum) - { - case 3: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_3_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - case 5: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_5_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - case 7: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_7_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - case 9: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_9_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - case 10: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_10_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - case 11: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_11_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - case 12: - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_MASK; - val |= INT_12_BITS; - pss_outpw (pss_base + PSS_CONFIG, val); - break; - default: - printk ("unknown interrupt selected. %d\n", intNum); - return 0; - } - - /*_____ Set the interrupt test bit */ - val = pss_inpw (pss_base + PSS_CONFIG); - val |= INT_TEST_BIT; - pss_outpw (pss_base + PSS_CONFIG, val); - - /*_____ Check if the interrupt is in use */ - /*_____ Do it a few times in case there is a delay */ - ret = 0; - for (i = 0; i < 5; i++) - { - val = pss_inpw (pss_base + PSS_CONFIG); - if (val & INT_TEST_PASS) - { - ret = 1; - break; - } - } - /*_____ Clear the Test bit and the interrupt bits */ - val = pss_inpw (pss_base + PSS_CONFIG); - val &= INT_TEST_BIT_MASK; - val &= INT_MASK; - pss_outpw (pss_base + PSS_CONFIG, val); - return (ret); -} - -/*____ pss_setint - This function sets the correct bits in the - configuration register to - enable the chosen interrupt. -*/ -static void -pss_setint (int intNum, int configAddress) -{ - int val; - - switch (intNum) - { - case 0: - val = pss_inpw (configAddress); - val &= INT_MASK; - pss_outpw (configAddress, val); - break; - case 3: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_3_BITS; - pss_outpw (configAddress, val); - break; - case 5: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_5_BITS; - pss_outpw (configAddress, val); - break; - case 7: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_7_BITS; - pss_outpw (configAddress, val); - break; - case 9: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_9_BITS; - pss_outpw (configAddress, val); - break; - case 10: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_10_BITS; - pss_outpw (configAddress, val); - break; - case 11: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_11_BITS; - pss_outpw (configAddress, val); - break; - case 12: - val = pss_inpw (configAddress); - val &= INT_MASK; - val |= INT_12_BITS; - pss_outpw (configAddress, val); - break; - default: - printk ("pss_setint unknown int\n"); - } -} - - -/*____ pss_setsbint - This function sets the correct bits in the - SoundBlaster configuration PSS register to - enable the chosen interrupt. - It takes a interrupt button as its argument. -*/ -static void -pss_setsbint (int intNum) -{ - int val; - int sbConfigAddress; - - sbConfigAddress = pss_base + SB_CONFIG; - switch (intNum) - { - case 3: - val = pss_inpw (sbConfigAddress); - val &= INT_MASK; - val |= INT_3_BITS; - pss_outpw (sbConfigAddress, val); - break; - case 5: - val = pss_inpw (sbConfigAddress); - val &= INT_MASK; - val |= INT_5_BITS; - pss_outpw (sbConfigAddress, val); - break; - case 7: - val = pss_inpw (sbConfigAddress); - val &= INT_MASK; - val |= INT_7_BITS; - pss_outpw (sbConfigAddress, val); - break; - default: - printk ("pss_setsbint: unknown_int\n"); - } -} - -/*____ pss_setsbdma - This function sets the correct bits in the - SoundBlaster configuration PSS register to - enable the chosen DMA channel. - It takes a DMA button as its argument. -*/ -static void -pss_setsbdma (int dmaNum) -{ - int val; - int sbConfigAddress; - - sbConfigAddress = pss_base + SB_CONFIG; - - switch (dmaNum) - { - case 1: - val = pss_inpw (sbConfigAddress); - val &= DMA_MASK; - val |= DMA_1_BITS; - pss_outpw (sbConfigAddress, val); - break; - default: - printk ("Personal Sound System ERROR! pss_setsbdma: unknown_dma\n"); - } -} - -/*____ pss_setwssdma - This function sets the correct bits in the - WSS configuration PSS register to - enable the chosen DMA channel. - It takes a DMA button as its argument. -*/ -static void -pss_setwssdma (int dmaNum) -{ - int val; - int wssConfigAddress; - - wssConfigAddress = pss_base + PSS_WSS_CONFIG; - - switch (dmaNum) - { - case 0: - val = pss_inpw (wssConfigAddress); - val &= DMA_MASK; - val |= DMA_0_BITS; - pss_outpw (wssConfigAddress, val); - break; - case 1: - val = pss_inpw (wssConfigAddress); - val &= DMA_MASK; - val |= DMA_1_BITS; - pss_outpw (wssConfigAddress, val); - break; - case 3: - val = pss_inpw (wssConfigAddress); - val &= DMA_MASK; - val |= DMA_3_BITS; - pss_outpw (wssConfigAddress, val); - break; - default: - printk ("Personal Sound System ERROR! pss_setwssdma: unknown_dma\n"); - } -} - - -/*_____ SetSpeakerOut - This function sets the Volume, Bass, Treble and Mode of - the speaker out channel. - */ -void -pss_setspeaker (struct pss_speaker *spk) -{ - PSS_write (SET_MASTER_COMMAND); - if (spk->volume > PHILLIPS_VOL_MAX) - spk->volume = PHILLIPS_VOL_MAX; - if (spk->volume < PHILLIPS_VOL_MIN) - spk->volume = PHILLIPS_VOL_MIN; - - PSS_write (MASTER_VOLUME_LEFT - | (PHILLIPS_VOL_CONSTANT + spk->volume / PHILLIPS_VOL_STEP)); - PSS_write (SET_MASTER_COMMAND); - PSS_write (MASTER_VOLUME_RIGHT - | (PHILLIPS_VOL_CONSTANT + spk->volume / PHILLIPS_VOL_STEP)); - - if (spk->bass > PHILLIPS_BASS_MAX) - spk->bass = PHILLIPS_BASS_MAX; - if (spk->bass < PHILLIPS_BASS_MIN) - spk->bass = PHILLIPS_BASS_MIN; - PSS_write (SET_MASTER_COMMAND); - PSS_write (MASTER_BASS - | (PHILLIPS_BASS_CONSTANT + spk->bass / PHILLIPS_BASS_STEP)); - - if (spk->treb > PHILLIPS_TREBLE_MAX) - spk->treb = PHILLIPS_TREBLE_MAX; - if (spk->treb < PHILLIPS_TREBLE_MIN) - spk->treb = PHILLIPS_TREBLE_MIN; - PSS_write (SET_MASTER_COMMAND); - PSS_write (MASTER_TREBLE - | (PHILLIPS_TREBLE_CONSTANT + spk->treb / PHILLIPS_TREBLE_STEP)); - - PSS_write (SET_MASTER_COMMAND); - PSS_write (MASTER_SWITCH | spk->mode); -} - -static void -pss_init1848 (void) -{ - /*_____ Wait for 1848 to init */ - while (INB (SoundPortAddress) & SP_IN_INIT); - - /*_____ Wait for 1848 to autocal */ - OUTB (SoundPortAddress, SP_TEST_AND_INIT); - while (INB (SoundPortData) & AUTO_CAL_IN_PROG); -} - -static int -pss_configure_registers_to_look_like_sb (void) -{ - pss_setaddr (wssAddr, pss_base + PSS_WSS_CONFIG); - - SoundPortAddress = wssAddr + 4; - SoundPortData = wssAddr + 5; - - DEB (printk ("Turning Game Port %s.\n", - gamePort ? "On" : "Off")); - - /*_____ Turn on the Game port */ - if (gamePort) - pss_outpw (pss_base + PSS_STATUS, - pss_inpw (pss_base + PSS_STATUS) | GAME_BIT); - else - pss_outpw (pss_base + PSS_STATUS, - pss_inpw (pss_base + PSS_STATUS) & GAME_BIT_MASK); - - - DEB (printk ("PSS attaching base %x irq %d dma %d\n", - pss_base, pss_irq, pss_dma)); - - /* Check if sb is enabled if it is check the interrupt */ - pss_outpw (pss_base + SB_CONFIG, 0); - - if (pss_irq != 0) - { - DEB (printk ("PSS Emulating Sound Blaster ADDR %04x\n", pss_base)); - DEB (printk ("PSS SBC: attaching base %x irq %d dma %d\n", - SBC_BASE, SBC_IRQ, SBC_DMA)); - - if (pss_checkint (SBC_IRQ) == 0) - { - printk ("PSS! attach: int_error\n"); - return 0; - } - - pss_setsbint (SBC_IRQ); - pss_setsbdma (SBC_DMA); - sb_ok = 1; - } - else - { - sb_ok = 0; - printk ("PSS: sound blaster error init\n"); - } - - /* Check if cd is enabled if it is check the interrupt */ - pss_outpw (pss_base + CD_CONFIG, 0); - - if (cdAddr != 0) - { - DEB (printk ("PSS:CD drive %x irq: %d", cdAddr, cdInt)); - if (cdInt != 0) - { - if (pss_checkint (cdInt) == 0) - { - printk ("Can't allocate cdInt %d\n", cdInt); - } - else - { - int val; - - printk ("CD poll "); - pss_setaddr (cdAddr, pss_base + CD_CONFIG); - pss_setint (cdInt, pss_base + CD_CONFIG); - - /* set the correct bit in the - configuration register to - set the irq polarity for the CD-Rom. - NOTE: This bit is in the address config - field, It must be configured after setting - the CD-ROM ADDRESS!!! */ - val = pss_inpw (pss_base + CD_CONFIG); - pss_outpw (pss_base + CD_CONFIG, 0); - val &= CD_POL_MASK; - if (cdPol) - val |= CD_POL_BIT; - pss_outpw (pss_base + CD_CONFIG, val); - } - } - } - - /* Check if midi is enabled if it is check the interrupt */ - pss_outpw (pss_base + MIDI_CONFIG, 0); - if (midiAddr != 0) - { - printk ("midi init %x %d\n", midiAddr, midiInt); - if (pss_checkint (midiInt) == 0) - { - printk ("midi init int error %x %d\n", midiAddr, midiInt); - } - else - { - pss_setaddr (midiAddr, pss_base + MIDI_CONFIG); - pss_setint (midiInt, pss_base + MIDI_CONFIG); - } - } - return 1; -} - -long -attach_pss (long mem_start, struct address_info *hw_config) -{ - if (pss_ok) - { - if (hw_config) - { - printk (" <PSS-ESC614>"); - } - - return mem_start; - } - - pss_ok = 1; - - if (pss_configure_registers_to_look_like_sb () == 0) - return mem_start; - - if (sb_ok) - if (pss_synthLen - && pss_download_boot (pss_synth, pss_synthLen)) - { - if (speaker) - pss_setspeaker (&default_speaker); - pss_ok = 1; - } - else - pss_reset_dsp (); - - return mem_start; -} - -int -probe_pss (struct address_info *hw_config) -{ - pss_base = hw_config->io_base; - pss_irq = hw_config->irq; - pss_dma = hw_config->dma; - - if ((pss_inpw (pss_base + 4) & 0xff00) == 0x4500) - { - attach_pss (0, hw_config); - return 1; - } - printk (" fail base %x irq %d dma %d\n", pss_base, pss_irq, pss_dma); - return 0; -} - - -static int -pss_reattach (void) -{ - pss_ok = 0; - attach_pss (0, 0); - return 1; -} - -static int -pss_reset_dsp () -{ - unsigned long i, limit = GET_TIME () + 10; - - pss_outpw (pss_base + PSS_CONTROL, 0x2000); - - for (i = 0; i < 32768 && GET_TIME () < limit; i++) - pss_inpw (pss_base + PSS_CONTROL); - - pss_outpw (pss_base + PSS_CONTROL, 0x0000); - - return 1; -} - - -static int -pss_download_boot (unsigned char *block, int size) -{ - int i, limit, val, count; - - printk ("PSS: downloading boot code synth.ld... "); - - /*_____ Warn DSP software that a boot is coming */ - pss_outpw (pss_base + PSS_DATA, 0x00fe); - - limit = GET_TIME () + 10; - - for (i = 0; i < 32768 && GET_TIME () < limit; i++) - if (pss_inpw (pss_base + PSS_DATA) == 0x5500) - break; - - pss_outpw (pss_base + PSS_DATA, *block++); - - pss_reset_dsp (); - printk ("start "); - - count = 1; - while (1) - { - int j; - - for (j = 0; j < 327670; j++) - { - /*_____ Wait for BG to appear */ - if (pss_inpw (pss_base + PSS_STATUS) & PSS_FLAG3) - break; - } - - if (j == 327670) - { - /* It's ok we timed out when the file was empty */ - if (count >= size) - break; - else - { - printk ("\nPSS: DownLoad timeout problems, byte %d=%d\n", - count, size); - return 0; - } - } - /*_____ Send the next byte */ - pss_outpw (pss_base + PSS_DATA, *block++); - count++; - } - - /*_____ Why */ - pss_outpw (pss_base + PSS_DATA, 0); - - limit = GET_TIME () + 10; - for (i = 0; i < 32768 && GET_TIME () < limit; i++) - val = pss_inpw (pss_base + PSS_STATUS); - - printk ("downloaded\n"); - - limit = GET_TIME () + 10; - for (i = 0; i < 32768 && GET_TIME () < limit; i++) - { - val = pss_inpw (pss_base + PSS_STATUS); - if (val & 0x4000) - break; - } - - /* now read the version */ - for (i = 0; i < 32000; i++) - { - val = pss_inpw (pss_base + PSS_STATUS_REG); - if (val & PSS_READ_FULL) - break; - } - if (i == 32000) - return 0; - - val = pss_inpw (pss_base + PSS_DATA_REG); - - return 1; -} - - -/* The following is a simple device driver for the pss. - All I really care about is communication to and from the pss. - - The ability to reinitialize the <synth.ld> This will be - default when release is chosen. - - SNDCTL_PSS_DOWNLOAD: - - Okay we need to creat new minor numbers for the - DOWNLOAD functionality. - - 14,0x19 -- /dev/pssld where a read operation would output the - current ld to user space - where a write operation would effectively - download a new ld. - - 14,0x09 -- /dev/psecho would open up a communication path to the - esc614 asic. Given the ability to send - messages to the asic and receive messages too. - - All messages would get read and written in the - same manner. It would be up to the application - and the ld to maintain a relationship - of what the messages mean. - - for this device we need to implement select. */ -#define CODE_BUFFER_LEN (64*1024) -static char *code_buffer; -static int code_length; - -static int lock_pss = 0; - -int -pss_open (int dev, struct fileinfo *file) -{ - int mode; - - DEB (printk ("pss_open\n")); - - if (pss_ok == 0) - return RET_ERROR (EIO); - - if (lock_pss) - return 0; - - lock_pss = 1; - - dev = dev >> 4; - mode = file->mode & O_ACCMODE; - if (mode == O_WRONLY) - { - printk ("pss-open for WRONLY\n"); - code_length = 0; - } - - RESET_WAIT_QUEUE (pss_sleeper, pss_sleep_flag); - return 1; -} - -void -pss_release (int dev, struct fileinfo *file) -{ - int mode; - - DEB (printk ("pss_release\n")); - if (pss_ok == 0) - return RET_ERROR (EIO); - - dev = dev >> 4; - mode = file->mode & O_ACCMODE; - if (mode == O_WRONLY && code_length > 0) - { -#ifdef linux - /* This just allows interrupts while the conversion is running */ - __asm__ ("sti"); -#endif - if (!pss_download_boot (code_buffer, code_length)) - { - pss_reattach (); - } - } - lock_pss = 0; -} - -int -pss_read (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) -{ - int c, p; - - DEB (printk ("pss_read\n")); - if (pss_ok == 0) - return RET_ERROR (EIO); - - dev = dev >> 4; - p = 0; - c = count; - - return count - c; -} - -int -pss_write (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) -{ - DEB (printk ("pss_write\n")); - if (pss_ok == 0) - return RET_ERROR (EIO); - dev = dev >> 4; - - if (count) /* Flush output */ - { - COPY_FROM_USER (&code_buffer[code_length], buf, 0, count); - code_length += count; - } - return count; -} - - -int -pss_ioctl (int dev, struct fileinfo *file, - unsigned int cmd, unsigned int arg) -{ - DEB (printk ("pss_ioctl dev=%d cmd=%x\n", dev, cmd)); - if (pss_ok == 0) - return RET_ERROR (EIO); - - dev = dev >> 4; - - switch (cmd) - { - case SNDCTL_PSS_RESET: - pss_reattach (); - return 1; - - case SNDCTL_PSS_SETUP_REGISTERS: - pss_configure_registers_to_look_like_sb (); - return 1; - - case SNDCTL_PSS_SPEAKER: - { - struct pss_speaker params; - COPY_FROM_USER (¶ms, (char *) arg, 0, sizeof (struct pss_speaker)); - - pss_setspeaker (¶ms); - return 0; - } - default: - return RET_ERROR (EIO); - } -} - -/* This is going to be used to implement - waiting on messages sent from the DSP and to the - DSP when communication is used via the pss directly. - - We need to find out if the pss can generate a different - interrupt other than the one it has been setup for. - - This way we can carry on a conversation with the pss - on a separate channel. This would be useful for debugging. */ - -pss_select (int dev, struct fileinfo * file, int sel_type, select_table * wait) -{ - return 0; - if (pss_ok == 0) - return RET_ERROR (EIO); - - dev = dev >> 4; - - switch (sel_type) - { - case SEL_IN: - select_wait (&pss_sleeper, wait); - return 0; - break; - - case SEL_OUT: - select_wait (&pss_sleeper, wait); - return 0; - break; - - case SEL_EX: - return 0; - } - - return 0; -} - -long -pss_init (long mem_start) -{ - DEB (printk ("pss_init\n")); - if (pss_ok) - { - code_buffer = mem_start; - mem_start += CODE_BUFFER_LEN; - } - return mem_start; -} - -#endif diff --git a/sys/i386/isa/sound/pss.h b/sys/i386/isa/sound/pss.h deleted file mode 100644 index e020af6..0000000 --- a/sys/i386/isa/sound/pss.h +++ /dev/null @@ -1,371 +0,0 @@ -/****************************************************************************** - - def.h - - Version 1.3 11/2/93 - - Copyright (c) 1993 Analog Devices Inc. All rights reserved - -******************************************************************************/ -/* Port offsets from base port for Sound Blaster DSP */ -#define DSP_PORT_CMSD0 0x00 /* C/MS music voice 1-6 data port, write only */ -#define DSP_PORT_CMSR0 0x01 /* C/MS music voice 1-6 register port, write only */ -#define DSP_PORT_CMSD1 0x02 /* C/MS music voice 7-12 data port, write only */ -#define DSP_PORT_CMSR1 0x03 /* C/MS music voice 7-12 register port, write only */ - -#define DSP_PORT_STATUS 0x04 /* DSP Status bits, read only */ -#define DSP_PORT_CONTROL 0x04 /* DSP Control bits, write only */ -#define DSP_PORT_DATA_LSB 0x05 /* Read or write LSB of 16 bit data */ - - -#define DSP_PORT_RESET 0x06 /* DSP Reset, write only */ -#define DSP_PORT_07h 0x07 /* reserved port */ - -#define DSP_PORT_FMD0 0x08 /* FM music data/status port, read/write */ -#define DSP_PORT_FMR0 0x09 /* FM music data/status port, write only */ - -#define DSP_PORT_RDDATA 0x0A /* DSP Read data, read only reading signals DSP */ -#define DSP_PORT_0Bh 0x0B /* reserved port */ -#define DSP_PORT_WRDATA 0x0C /* DSP Write data or command, write */ -#define DSP_PORT_WRBUSY 0x0C /* DSP Write buffer status (bit 7), read */ -#define DSP_PORT_0Dh 0x0D /* reserved port */ -#define DSP_PORT_DATAAVAIL 0x0E /* DSP Data available status (bit 7), read only */ -#define DSP_PORT_INTERFACE 0x0E /* Sets DMA Channel and Interrupt, write only */ -#define DSP_PORT_0Fh 0x0F /* reserved port (used on Pro cards) */ - -#define ADDR_MASK 0x003f - -#define INT_MASK 0xffc7 -#define INT_3_BITS 0x0008 -#define INT_5_BITS 0x0010 -#define INT_7_BITS 0x0018 -#define INT_9_BITS 0x0020 -#define INT_10_BITS 0x0028 -#define INT_11_BITS 0x0030 -#define INT_12_BITS 0x0038 - -#define GAME_BIT 0x0400 -#define GAME_BIT_MASK 0xfbff - -#define INT_TEST_BIT 0x0200 -#define INT_TEST_PASS 0x0100 -#define INT_TEST_BIT_MASK 0xFDFF - -#define DMA_MASK 0xfff8 -#define DMA_0_BITS 0x0001 -#define DMA_1_BITS 0x0002 -#define DMA_3_BITS 0x0003 -#define DMA_5_BITS 0x0004 -#define DMA_6_BITS 0x0005 -#define DMA_7_BITS 0x0006 - -#define DMA_TEST_BIT 0x0080 -#define DMA_TEST_PASS 0x0040 -#define DMA_TEST_BIT_MASK 0xFF7F - - -/* Echo DSP Flags */ - -#define DSP_FLAG3 0x10 -#define DSP_FLAG2 0x08 -#define DSP_FLAG1 0x80 -#define DSP_FLAG0 0x40 - -#define PSS_CONFIG 0x10 -#define PSS_WSS_CONFIG 0x12 -#define SB_CONFIG 0x14 -#define MIDI_CONFIG 0x18 -#define CD_CONFIG 0x16 -#define UART_CONFIG 0x1a - -#define PSS_DATA 0x00 -#define PSS_STATUS 0x02 -#define PSS_CONTROL 0x02 -#define PSS_ID_VERS 0x04 - -#define PSS_FLAG3 0x0800 -#define PSS_FLAG2 0x0400 -#define PSS_FLAG1 0x1000 -#define PSS_FLAG0 0x0800 - -/*_____ WSS defines */ -#define WSS_BASE_ADDRESS 0x530 -#define WSS_CONFIG 0x0 -#define WSS_VERSION 0x03 -#define WSS_SP0 0x04 -#define WSS_SP1 0x05 -#define WSS_SP2 0x06 -#define WSS_SP3 0x07 - -/*_____ SoundPort register addresses */ - -#define SP_LIN_SOURCE_CTRL 0x00 -#define SP_RIN_SOURCE_CTRL 0x01 -#define SP_LIN_GAIN_CTRL 0x10 -#define SP_RIN_GAIN_CTRL 0x11 -#define SP_LAUX1_CTRL 0x02 -#define SP_RAUX1_CTRL 0x03 -#define SP_LAUX2_CTRL 0x04 -#define SP_RAUX2_CTRL 0x05 -#define SP_LOUT_CTRL 0x06 -#define SP_ROUT_CTRL 0x07 -#define SP_CLK_FORMAT 0x48 -#define SP_INT_CONF 0x09 -#define SP_INT_CONF_MCE 0x49 -#define SP_PIN_CTRL 0x0a -#define SP_TEST_INIT 0x0b -#define SP_MISC_CTRL 0x0c -#define SP_MIX_CTRL 0x0d -#define SP_DMA_UCNT 0x0e -#define SP_DMA_LCNT 0x0f - -/*_____ Gain constants */ - -#define GAIN_0 0x00 -#define GAIN_1_5 0x01 -#define GAIN_3 0x02 -#define GAIN_4_5 0x03 -#define GAIN_6 0x04 -#define GAIN_7_5 0x05 -#define GAIN_9 0x06 -#define GAIN_10_5 0x07 -#define GAIN_12 0x08 -#define GAIN_13_5 0x09 -#define GAIN_15 0x0a -#define GAIN_16_5 0x0b -#define GAIN_18 0x0c -#define GAIN_19_5 0x0d -#define GAIN_21 0x0e -#define GAIN_22_5 0x0f -#define MUTE 0XFFFF - -/*_____ Attenuation constants */ - -#define ATTEN_0 0x00 -#define ATTEN_1_5 0x01 -#define ATTEN_3 0x02 -#define ATTEN_4_5 0x03 -#define ATTEN_6 0x04 -#define ATTEN_7_5 0x05 -#define ATTEN_9 0x06 -#define ATTEN_10_5 0x07 -#define ATTEN_12 0x08 -#define ATTEN_13_5 0x09 -#define ATTEN_15 0x0a -#define ATTEN_16_5 0x0b -#define ATTEN_18 0x0c -#define ATTEN_19_5 0x0d -#define ATTEN_21 0x0e -#define ATTEN_22_5 0x0f - - -#define PSS_WRITE_EMPTY 0x8000 - -#define CD_POL_MASK 0xFFBF -#define CD_POL_BIT 0x0040 - - - -/****************************************************************************** - - host.h - - Version 1.2 9/27/93 - - Copyright (c) 1993 Analog Devices Inc. All rights reserved - -******************************************************************************/ -#define SB_WRITE_FULL 0x80 -#define SB_READ_FULL 0x80 -#define SB_WRITE_STATUS 0x0C -#define SB_READ_STATUS 0x0E -#define SB_READ_DATA 0x0A -#define SB_WRITE_DATA 0x0C - -#define PSS_DATA_REG 0x00 -#define PSS_STATUS_REG 0x02 -#define PSS_WRITE_EMPTY 0x8000 -#define PSS_READ_FULL 0x4000 - -/*_____ 1848 Sound Port bit defines */ - -#define SP_IN_INIT 0x80 -#define MODE_CHANGE_ENABLE 0x40 -#define MODE_CHANGE_MASK 0xbf -#define TRANSFER_DISABLE 0x20 -#define TRANSFER_DISABLE_MASK 0xdf -#define ADDRESS_MASK 0xf0 - -/*_____ Status bits */ -#define INTERRUPT_STATUS 0x01 -#define PLAYBACK_READY 0x02 -#define PLAYBACK_LEFT 0x04 -/*_____ pbright is not left */ -#define PLAYBACK_UPPER 0x08 -/*_____ bplower is not upper */ - -#define SAMPLE_OVERRUN 0x10 -#define SAMPLE_UNDERRUN 0x10 -#define CAPTURE_READY 0x20 -#define CAPTURE_LEFT 0x40 -/*_____ cpright is not left */ -#define CAPTURE_UPPER 0x08 -/*_____ cplower is not upper */ - -/*_____ Input & Output regs bits */ -#define LINE_INPUT 0x80 -#define AUX_INPUT 0x40 -#define MIC_INPUT 0x80 -#define MIXED_DAC_INPUT 0xC0 -#define INPUT_GAIN_MASK 0xf0 -#define INPUT_MIC_GAIN_ENABLE 0x20 -#define INPUT_MIC_GAIN_MASK 0xdf -#define INPUT_SOURCE_MASK 0x3f -#define AUX_INPUT_ATTEN_MASK 0xf0 -#define AUX_INPUT_MUTE 0x80 -#define AUX_INPUT_MUTE_MASK 0x7f -#define OUTPUT_MUTE 0x80 -#define OUTPUT_MUTE_MASK 0x7f -#define OUTPUT_ATTEN_MASK 0xc0 - -/*_____ Clock and Data format reg bits */ -#define CLOCK_SELECT_MASK 0xfe -#define CLOCK_XTAL2 0x01 -#define CLOCK_XTAL1 0x00 -#define CLOCK_FREQ_MASK 0xf1 -#define STEREO_MONO_MASK 0xef -#define STEREO 0x10 -#define AUDIO_MONO 0x00 -#define LINEAR_COMP_MASK 0xdf -#define LINEAR 0x00 -#define COMPANDED 0x20 -#define FORMAT_MASK 0xbf -#define PCM 0x00 -#define ULAW 0x00 -#define TWOS_COMP 0x40 -#define ALAW 0x40 - -/*_____ Interface Configuration reg bits */ -#define PLAYBACK_ENABLE 0x01 -#define PLAYBACK_ENABLE_MASK 0xfe -#define CAPTURE_ENABLE 0x02 -#define CAPTURE_ENABLE_MASK 0xfd -#define SINGLE_DMA 0x04 -#define SINGLE_DMA_MASK 0xfb -#define DUAL_DMA 0x00 -#define AUTO_CAL_ENABLE 0x08 -#define AUTO_CAL_DISABLE_MASK 0xf7 -#define PLAYBACK_PIO_ENABLE 0x40 -#define PLAYBACK_DMA_MASK 0xbf -#define CAPTURE_PIO_ENABLE 0x80 -#define CAPTURE_DMA_MASK 0x7f - -/*_____ Pin control bits */ -#define INTERRUPT_ENABLE 0x02 -#define INTERRUPT_MASK 0xfd - -/*_____ Test and init reg bits */ -#define OVERRANGE_LEFT_MASK 0xfc -#define OVERRANGE_RIGHT_MASK 0xf3 -#define DATA_REQUEST_STATUS 0x10 -#define AUTO_CAL_IN_PROG 0x20 -#define PLAYBACK_UNDERRUN 0x40 -#define CAPTURE_UNDERRUN 0x80 - -/*_____ Miscellaneous Control reg bits */ -#define ID_MASK 0xf0 - -/*_____ Digital Mix Control reg bits */ -#define DIGITAL_MIX1_MUTE_MASK 0xfe -#define MIX_ATTEN_MASK 0x03 - -/*_____ 1848 Sound Port reg defines */ - -#define SP_LEFT_INPUT_CONTROL 0x0 -#define SP_RIGHT_INPUT_CONTROL 0x1 -#define SP_LEFT_AUX1_CONTROL 0x2 -#define SP_RIGHT_AUX1_CONTROL 0x3 -#define SP_LEFT_AUX2_CONTROL 0x4 -#define SP_RIGHT_AUX2_CONTROL 0x5 -#define SP_LEFT_OUTPUT_CONTROL 0x6 -#define SP_RIGHT_OUTPUT_CONTROL 0x7 -#define SP_CLOCK_DATA_FORMAT 0x8 -#define SP_INTERFACE_CONFIG 0x9 -#define SP_PIN_CONTROL 0xA -#define SP_TEST_AND_INIT 0xB -#define SP_MISC_INFO 0xC -#define SP_DIGITAL_MIX 0xD -#define SP_UPPER_BASE_COUNT 0xE -#define SP_LOWER_BASE_COUNT 0xF - -#define HOST_SP_ADDR (0x534) -#define HOST_SP_DATA (0x535) - - -/****************************************************************************** - - phillips.h - - Version 1.2 9/27/93 - - Copyright (c) 1993 Analog Devices Inc. All rights reserved - -******************************************************************************/ -/*_____ Phillips control SW defines */ - -/*_____ Settings and ranges */ -#define VOLUME_MAX 6 -#define VOLUME_MIN (-64) -#define VOLUME_RANGE 70 -#define VOLUME_STEP 2 -#define BASS_MAX 15 -#define BASS_MIN (-12) -#define BASS_STEP 2 -#define BASS_RANGE 27 -#define TREBLE_MAX 12 -#define TREBLE_MIN (-12) -#define TREBLE_STEP 2 -#define TREBLE_RANGE 24 - -#define VOLUME_CONSTANT 252 -#define BASS_CONSTANT 246 -#define TREBLE_CONSTANT 246 - -/*_____ Software commands */ -#define SET_MASTER_COMMAND 0x0010 -#define MASTER_VOLUME_LEFT 0x0000 -#define MASTER_VOLUME_RIGHT 0x0100 -#define MASTER_BASS 0x0200 -#define MASTER_TREBLE 0x0300 -#define MASTER_SWITCH 0x0800 - -#define STEREO_MODE 0x00ce -#define PSEUDO_MODE 0x00d6 -#define SPATIAL_MODE 0x00de -#define MONO_MODE 0x00c6 - - -#define PSS_STEREO 0x00ce -#define PSS_PSEUDO 0x00d6 -#define PSS_SPATIAL 0x00de -#define PSS_MONO 0x00c6 - -#define PHILLIPS_VOL_MIN -64 -#define PHILLIPS_VOL_MAX 6 -#define PHILLIPS_VOL_DELTA 70 -#define PHILLIPS_VOL_INITIAL -20 -#define PHILLIPS_VOL_CONSTANT 252 -#define PHILLIPS_VOL_STEP 2 -#define PHILLIPS_BASS_MIN -12 -#define PHILLIPS_BASS_MAX 15 -#define PHILLIPS_BASS_DELTA 27 -#define PHILLIPS_BASS_INITIAL 0 -#define PHILLIPS_BASS_CONSTANT 246 -#define PHILLIPS_BASS_STEP 2 -#define PHILLIPS_TREBLE_MIN -12 -#define PHILLIPS_TREBLE_MAX 12 -#define PHILLIPS_TREBLE_DELTA 24 -#define PHILLIPS_TREBLE_INITIAL 0 -#define PHILLIPS_TREBLE_CONSTANT 246 -#define PHILLIPS_TREBLE_STEP 2 - diff --git a/sys/i386/isa/sound/soundcard.h b/sys/i386/isa/sound/soundcard.h deleted file mode 100644 index 02d0da7..0000000 --- a/sys/i386/isa/sound/soundcard.h +++ /dev/null @@ -1,1045 +0,0 @@ -#ifndef SOUNDCARD_H -#define SOUNDCARD_H -/* - * Copyright by Hannu Savolainen 1993 - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * - */ - - /* - * If you make modifications to this file, please contact me before - * distributing the modified version. There is already enough - * divercity in the world. - * - * Regards, - * Hannu Savolainen - * hannu@voxware.pp.fi - */ - -#define SOUND_VERSION 301 -#define VOXWARE - -#include <sys/ioctl.h> - -/* - * Supported card ID numbers (Should be somewhere else?) - */ - -#define SNDCARD_ADLIB 1 -#define SNDCARD_SB 2 -#define SNDCARD_PAS 3 -#define SNDCARD_GUS 4 -#define SNDCARD_MPU401 5 -#define SNDCARD_SB16 6 -#define SNDCARD_SB16MIDI 7 -#define SNDCARD_UART6850 8 -#define SNDCARD_GUS16 9 -#define SNDCARD_MSS 10 -#define SNDCARD_PSS 11 -#define SNDCARD_SSCAPE 12 -#define SNDCARD_PSS_MPU 13 -#define SNDCARD_PSS_MSS 14 -#define SNDCARD_SSCAPE_MSS 15 -#define SNDCARD_TRXPRO 16 -#define SNDCARD_TRXPRO_SB 17 -#define SNDCARD_TRXPRO_MPU 18 - -/*********************************** - * IOCTL Commands for /dev/sequencer - */ - -#ifndef _IOWR -/* @(#)ioctlp.h */ - -/* Ioctl's have the command encoded in the lower word, - * and the size of any in or out parameters in the upper - * word. The high 2 bits of the upper word are used - * to encode the in/out status of the parameter; for now - * we restrict parameters to at most 128 bytes. - */ -/* #define IOCTYPE (0xff<<8) */ -#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ -#define IOC_VOID 0x00000000 /* no parameters */ -#define IOC_OUT 0x20000000 /* copy out parameters */ -#define IOC_IN 0x40000000 /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) -/* the 0x20000000 is so we can distinguish new ioctl's from old */ -#define _IO(x,y) ((int)(IOC_VOID|(x<<8)|y)) -#define _IOR(x,y,t) ((int)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) -#define _IOW(x,y,t) ((int)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) -/* this should be _IORW, but stdio got there first */ -#define _IOWR(x,y,t) ((int)(IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) -#endif /* !_IOWR */ - -#define SNDCTL_SEQ_RESET _IO ('Q', 0) -#define SNDCTL_SEQ_SYNC _IO ('Q', 1) -#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) -#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ -#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) -#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) -#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) -#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ -#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) -#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) -#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) -#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) -#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) -#define SNDCTL_SEQ_TRESHOLD _IOW ('Q',13, int) -#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ -#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ -#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) -#define SNDCTL_SEQ_PANIC _IO ('Q',17) -#define SNDCTL_SEQ_OUTOFBAND _IOW ('Q',18, struct seq_event_rec) - - struct seq_event_rec { - unsigned char arr[8]; - }; - -#define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int) -#define SNDCTL_TMR_START _IO ('T', 2) -#define SNDCTL_TMR_STOP _IO ('T', 3) -#define SNDCTL_TMR_CONTINUE _IO ('T', 4) -#define SNDCTL_TMR_TEMPO _IOWR('T', 5, int) -#define SNDCTL_TMR_SOURCE _IOWR('T', 6, int) -# define TMR_INTERNAL 0x00000001 -# define TMR_EXTERNAL 0x00000002 -# define TMR_MODE_MIDI 0x00000010 -# define TMR_MODE_FSK 0x00000020 -# define TMR_MODE_CLS 0x00000040 -# define TMR_MODE_SMPTE 0x00000080 -#define SNDCTL_TMR_METRONOME _IOW ('T', 7, int) -#define SNDCTL_TMR_SELECT _IOW ('T', 8, int) - -/* - * Sample loading mechanism for internal synthesizers (/dev/sequencer) - * The following patch_info structure has been designed to support - * Gravis UltraSound. It tries to be universal format for uploading - * sample based patches but is propably too limited. - */ - -struct patch_info { - short key; /* Use GUS_PATCH here */ -#define GUS_PATCH 0x04fd -#define OBSOLETE_GUS_PATCH 0x02fd - short device_no; /* Synthesizer number */ - short instr_no; /* Midi pgm# */ - - unsigned long mode; -/* - * The least significant byte has the same format than the GUS .PAT - * files - */ -#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ -#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ -#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ -#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ -#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ -#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ -#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ - /* (use the env_rate/env_offs fields). */ -/* Linux specific bits */ -#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ -#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ -#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ -/* Other bits must be zeroed */ - - long len; /* Size of the wave data in bytes */ - long loop_start, loop_end; /* Byte offsets from the beginning */ - -/* - * The base_freq and base_note fields are used when computing the - * playback speed for a note. The base_note defines the tone frequency - * which is heard if the sample is played using the base_freq as the - * playback speed. - * - * The low_note and high_note fields define the minimum and maximum note - * frequencies for which this sample is valid. It is possible to define - * more than one samples for a instrument number at the same time. The - * low_note and high_note fields are used to select the most suitable one. - * - * The fields base_note, high_note and low_note should contain - * the note frequency multiplied by 1000. For example value for the - * middle A is 440*1000. - */ - - unsigned int base_freq; - unsigned long base_note; - unsigned long high_note; - unsigned long low_note; - int panning; /* -128=left, 127=right */ - int detuning; - -/* New fields introduced in version 1.99.5 */ - - /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ - unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ - unsigned char env_offset[ 6 ]; /* 255 == 100% */ - - /* - * The tremolo, vibrato and scale info are not supported yet. - * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or - * WAVE_SCALE - */ - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - int scale_frequency; - unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ - - int volume; - int spare[4]; - char data[1]; /* The waveform data starts here */ - }; - - -struct sysex_info { - short key; /* Use GUS_PATCH here */ -#define SYSEX_PATCH 0x05fd - short device_no; /* Synthesizer number */ - long len; /* Size of the sysex data in bytes */ - unsigned char data[1]; /* Sysex data starts here */ - }; - -/* - * Patch management interface (/dev/sequencer, /dev/patmgr#) - * Don't use these calls if you want to maintain compatibility with - * the future versions of the driver. - */ - -#define PS_NO_PATCHES 0 /* No patch support on device */ -#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ -#define PS_MGR_OK 2 /* Patch manager supported */ -#define PS_MANAGED 3 /* Patch manager running */ - -#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) - -/* - * The patmgr_info is a fixed size structure which is used for two - * different purposes. The intended use is for communication between - * the application using /dev/sequencer and the patch manager daemon - * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). - * - * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows - * a patch manager daemon to read and write device parameters. This - * ioctl available through /dev/sequencer also. Avoid using it since it's - * extremely hardware dependent. In addition access trough /dev/sequencer - * may confuse the patch manager daemon. - */ - -struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ - unsigned long key; /* Don't worry. Reserved for communication - between the patch manager and the driver. */ -#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ -#define PM_K_COMMAND 2 /* Request from a application */ -#define PM_K_RESPONSE 3 /* From patmgr to application */ -#define PM_ERROR 4 /* Error returned by the patmgr */ - int device; - int command; - -/* - * Commands 0x000 to 0xfff reserved for patch manager programs - */ -#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ -#define PMTYPE_FM2 1 /* 2 OP fm */ -#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ -#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ -#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ -#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ -#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ -#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ -#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ -#define PM_READ_PATCH 7 /* Read patch (wave) data */ -#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ - -/* - * Commands 0x1000 to 0xffff are for communication between the patch manager - * and the client - */ -#define _PM_LOAD_PATCH 0x100 - -/* - * Commands above 0xffff reserved for device specific use - */ - - long parm1; - long parm2; - long parm3; - - union { - unsigned char data8[4000]; - unsigned short data16[2000]; - unsigned long data32[1000]; - struct patch_info patch; - } data; - }; - -/* - * When a patch manager daemon is present, it will be informed by the - * driver when something important happens. For example when the - * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is - * returned. The command field contains the event type: - */ -#define PM_E_OPENED 1 /* /dev/sequencer opened */ -#define PM_E_CLOSED 2 /* /dev/sequencer closed */ -#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ -#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ - -/* - * /dev/sequencer input events. - * - * The data written to the /dev/sequencer is a stream of events. Events - * are records of 4 or 8 bytes. The first byte defines the size. - * Any number of events can be written with a write call. There - * is a set of macros for sending these events. Use these macros if you - * want to maximize portability of your program. - * - * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. - * (All input events are currently 4 bytes long. Be prepared to support - * 8 byte events also. If you receive any event having first byte >= 128, - * it's a 8 byte event. - * - * The events are documented at the end of this file. - * - * Normal events (4 bytes) - * There is also a 8 byte version of most of the 4 byte events. The - * 8 byte one is recommended. - */ -#define SEQ_NOTEOFF 0 -#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ -#define SEQ_NOTEON 1 -#define SEQ_FMNOTEON SEQ_NOTEON -#define SEQ_WAIT TMR_WAIT_ABS -#define SEQ_PGMCHANGE 3 -#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE -#define SEQ_SYNCTIMER TMR_START -#define SEQ_MIDIPUTC 5 -#define SEQ_DRUMON 6 /*** OBSOLETE ***/ -#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ -#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ -#define SEQ_AFTERTOUCH 9 -#define SEQ_CONTROLLER 10 - -/******************************************* - * Midi controller numbers - ******************************************* - * Controllers 0 to 31 (0x00 to 0x1f) and - * 32 to 63 (0x20 to 0x3f) are continuous - * controllers. - * In the MIDI 1.0 these controllers are sent using - * two messages. Controller numbers 0 to 31 are used - * to send the MSB and the controller numbers 32 to 63 - * are for the LSB. Note that just 7 bits are used in MIDI bytes. - */ - -#define CTL_BANK_SELECT 0x00 -#define CTL_MODWHEEL 0x01 -#define CTL_BREATH 0x02 -/* undefined 0x03 */ -#define CTL_FOOT 0x04 -#define CTL_PORTAMENTO_TIME 0x05 -#define CTL_DATA_ENTRY 0x06 -#define CTL_MAIN_VOLUME 0x07 -#define CTL_BALANCE 0x08 -/* undefined 0x09 */ -#define CTL_PAN 0x0a -#define CTL_EXPRESSION 0x0b -/* undefined 0x0c */ -/* undefined 0x0d */ -/* undefined 0x0e */ -/* undefined 0x0f */ -#define CTL_GENERAL_PURPOSE1 0x10 -#define CTL_GENERAL_PURPOSE2 0x11 -#define CTL_GENERAL_PURPOSE3 0x12 -#define CTL_GENERAL_PURPOSE4 0x13 -/* undefined 0x14 - 0x1f */ - -/* undefined 0x20 */ -/* The controller numbers 0x21 to 0x3f are reserved for the */ -/* least significant bytes of the controllers 0x00 to 0x1f. */ -/* These controllers are not recognised by the driver. */ - -/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */ -/* 0=OFF and 127=ON (intermediate values are possible) */ -#define CTL_DAMPER_PEDAL 0x40 -#define CTL_SUSTAIN 0x40 /* Alias */ -#define CTL_HOLD 0x40 /* Alias */ -#define CTL_PORTAMENTO 0x41 -#define CTL_SOSTENUTO 0x42 -#define CTL_SOFT_PEDAL 0x43 -/* undefined 0x44 */ -#define CTL_HOLD2 0x45 -/* undefined 0x46 - 0x4f */ - -#define CTL_GENERAL_PURPOSE5 0x50 -#define CTL_GENERAL_PURPOSE6 0x51 -#define CTL_GENERAL_PURPOSE7 0x52 -#define CTL_GENERAL_PURPOSE8 0x53 -/* undefined 0x54 - 0x5a */ -#define CTL_EXT_EFF_DEPTH 0x5b -#define CTL_TREMOLO_DEPTH 0x5c -#define CTL_CHORUS_DEPTH 0x5d -#define CTL_DETUNE_DEPTH 0x5e -#define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */ -#define CTL_PHASER_DEPTH 0x5f -#define CTL_DATA_INCREMENT 0x60 -#define CTL_DATA_DECREMENT 0x61 -#define CTL_NONREG_PARM_NUM_LSB 0x62 -#define CTL_NONREG_PARM_NUM_MSB 0x63 -#define CTL_REGIST_PARM_NUM_LSB 0x64 -#define CTL_REGIST_PARM_NUM_MSB 0x65 -/* undefined 0x66 - 0x78 */ -/* reserved 0x79 - 0x7f */ - -/* Pseudo controllers (not midi compatible) */ -#define CTRL_PITCH_BENDER 255 -#define CTRL_PITCH_BENDER_RANGE 254 -#define CTRL_EXPRESSION 253 /* Obsolete */ -#define CTRL_MAIN_VOLUME 252 /* Obsolete */ -#define SEQ_BALANCE 11 -#define SEQ_VOLMODE 12 - -/* - * Volume mode decides how volumes are used - */ - -#define VOL_METHOD_ADAGIO 1 -#define VOL_METHOD_LINEAR 2 - -/* - * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as - * input events. - */ - -/* - * Event codes 0xf0 to 0xfc are reserved for future extensions. - */ - -#define SEQ_FULLSIZE 0xfd /* Long events */ -/* - * SEQ_FULLSIZE events are used for loading patches/samples to the - * synthesizer devices. These events are passed directly to the driver - * of the associated synthesizer device. There is no limit to the size - * of the extended events. These events are not queued but executed - * immediately when the write() is called (execution can take several - * seconds of time). - * - * When a SEQ_FULLSIZE message is written to the device, it must - * be written using exactly one write() call. Other events cannot - * be mixed to the same write. - * - * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the - * /dev/sequencer. Don't write other data together with the instrument structure - * Set the key field of the structure to FM_PATCH. The device field is used to - * route the patch to the corresponding device. - * - * For Gravis UltraSound use struct patch_info. Initialize the key field - * to GUS_PATCH. - */ -#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ -#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ - -/* - * Record for FM patches - */ - -typedef unsigned char sbi_instr_data[32]; - -struct sbi_instrument { - unsigned short key; /* Initialize to FM_PATCH or OPL3_PATCH */ -#define FM_PATCH 0x01fd -#define OPL3_PATCH 0x03fd - short device; /* Synth# (0-4) */ - int channel; /* Program# to be initialized */ - sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ - }; - -struct synth_info { /* Read only */ - char name[30]; - int device; /* 0-N. INITIALIZE BEFORE CALLING */ - int synth_type; -#define SYNTH_TYPE_FM 0 -#define SYNTH_TYPE_SAMPLE 1 -#define SYNTH_TYPE_MIDI 2 /* Midi interface */ - - int synth_subtype; -#define FM_TYPE_ADLIB 0x00 -#define FM_TYPE_OPL3 0x01 - -#define SAMPLE_TYPE_GUS 0x10 - - int perc_mode; /* No longer supported */ - int nr_voices; - int nr_drums; /* Obsolete field */ - int instr_bank_size; - unsigned long capabilities; -#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ -#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ -#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ - int dummies[19]; /* Reserve space */ - }; - -struct sound_timer_info { - char name[30]; - int caps; - }; - -#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ - -struct midi_info { - char name[30]; - int device; /* 0-N. INITIALIZE BEFORE CALLING */ - unsigned long capabilities; /* To be defined later */ - int dev_type; - int dummies[18]; /* Reserve space */ - }; - -/******************************************** - * ioctl commands for the /dev/midi## - */ -typedef struct { - unsigned char cmd; - char nr_args, nr_returns; - unsigned char data[30]; - } mpu_command_rec; - -#define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int) -#define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int) -#define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) - -/******************************************** - * IOCTL commands for /dev/dsp and /dev/audio - */ - -#define SNDCTL_DSP_RESET _IO ('P', 0) -#define SNDCTL_DSP_SYNC _IO ('P', 1) -#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) -#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) -#define SNDCTL_DSP_GETBLKSIZE _IOR('P', 4, int) -#define SNDCTL_DSP_SETBLKSIZE _IOW('P', 4, int) -#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT -#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) -#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) -#define SNDCTL_DSP_POST _IO ('P', 8) -#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) -#define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int) - -/* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */ -#define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */ -#define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/ -# define AFMT_QUERY 0x00000000 /* Return current fmt */ -# define AFMT_MU_LAW 0x00000001 -# define AFMT_A_LAW 0x00000002 -# define AFMT_IMA_ADPCM 0x00000004 -# define AFMT_U8 0x00000008 -# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ -# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ -# define AFMT_S8 0x00000040 -# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ -# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ -# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ - -/* - * Buffer status queries. - */ -typedef struct audio_buf_info { - int fragments; /* # of available fragments (partially usend ones not counted) */ - int fragsize; /* Size of a fragment in bytes */ - - int bytes; /* Available space in bytes (includes partially used fragments) */ - /* Note! 'bytes' could be more than fragments*fragsize */ - } audio_buf_info; - -#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, audio_buf_info) -#define SNDCTL_DSP_GETISPACE _IOR ('P',13, audio_buf_info) -#define SNDCTL_DSP_NONBLOCK _IO ('P',14) - -#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) -#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) -#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) -#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) - -/* Some alias names */ -#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT -#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED -#define SOUND_PCM_POST SNDCTL_DSP_POST -#define SOUND_PCM_RESET SNDCTL_DSP_RESET -#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC -#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE -#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT -#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS -#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT -#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE -#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE -#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK - -/* - * ioctl calls to be used in communication with coprocessors and - * DSP chips. - */ - -typedef struct copr_buffer { - int command; /* Set to 0 if not used */ - int flags; -#define CPF_NONE 0x0000 -#define CPF_FIRST 0x0001 /* First block */ -#define CPF_LAST 0x0002 /* Last block */ - int len; - int offs; /* If required by the device (0 if not used) */ - - unsigned char data[4000]; /* NOTE! 4000 is not 4k */ - } copr_buffer; - -typedef struct copr_debug_buf { - int command; /* Used internally. Set to 0 */ - int parm1; - int parm2; - int flags; - int len; /* Length of data in bytes */ - } copr_debug_buf; - -typedef struct copr_msg { - int len; - unsigned char data[4000]; - } copr_msg; - -#define SNDCTL_COPR_RESET _IO ('C', 0) -#define SNDCTL_COPR_LOAD _IOWR('C', 1, copr_buffer) -#define SNDCTL_COPR_RDATA _IOWR('C', 2, copr_debug_buf) -#define SNDCTL_COPR_RCODE _IOWR('C', 3, copr_debug_buf) -#define SNDCTL_COPR_WDATA _IOW ('C', 4, copr_debug_buf) -#define SNDCTL_COPR_WCODE _IOW ('C', 5, copr_debug_buf) -#define SNDCTL_COPR_RUN _IOWR('C', 6, copr_debug_buf) -#define SNDCTL_COPR_HALT _IOWR('C', 7, copr_debug_buf) -#define SNDCTL_COPR_SENDMSG _IOW ('C', 8, copr_msg) -#define SNDCTL_COPR_RCVMSG _IOR ('C', 9, copr_msg) - -/********************************************* - * IOCTL commands for /dev/mixer - */ - -/* - * Mixer devices - * - * There can be up to 20 different analog mixer channels. The - * SOUND_MIXER_NRDEVICES gives the currently supported maximum. - * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells - * the devices supported by the particular mixer. - */ - -#define SOUND_MIXER_NRDEVICES 17 -#define SOUND_MIXER_VOLUME 0 -#define SOUND_MIXER_BASS 1 -#define SOUND_MIXER_TREBLE 2 -#define SOUND_MIXER_SYNTH 3 -#define SOUND_MIXER_PCM 4 -#define SOUND_MIXER_SPEAKER 5 -#define SOUND_MIXER_LINE 6 -#define SOUND_MIXER_MIC 7 -#define SOUND_MIXER_CD 8 -#define SOUND_MIXER_IMIX 9 /* Recording monitor */ -#define SOUND_MIXER_ALTPCM 10 -#define SOUND_MIXER_RECLEV 11 /* Recording level */ -#define SOUND_MIXER_IGAIN 12 /* Input gain */ -#define SOUND_MIXER_OGAIN 13 /* Output gain */ -/* - * The AD1848 codec and compatibles have three line level inputs - * (line, aux1 and aux2). Since each card manufacturer have assigned - * different meanings to these inputs, it's inpractical to assign - * specific meanings (line, cd, synth etc.) to them. - */ -#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ -#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ -#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ - -/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ -/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ -#define SOUND_ONOFF_MIN 28 -#define SOUND_ONOFF_MAX 30 -#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ -#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ -#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ - -/* Note! Number 31 cannot be used since the sign bit is reserved */ - -#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ - "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ - "Line1", "Line2", "Line3"} - -#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ - "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ - "line1", "line2", "line3"} - -/* Device bitmask identifiers */ - -#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ -#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ -#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ -#define SOUND_MIXER_CAPS 0xfc - #define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ -#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ - -/* Device mask bits */ - -#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) -#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) -#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) -#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) -#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) -#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) -#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) -#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) -#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) -#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) -#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) -#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) -#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) -#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) -#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) -#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) -#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) - -#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) -#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) -#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) - -#define MIXER_READ(dev) _IOR('M', dev, int) -#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) -#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) -#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) -#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) -#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) -#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) -#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) -#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) -#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) -#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) -#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) -#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) -#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) -#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) -#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) -#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) -#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) -#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) -#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) -#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) - -#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) -#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) -#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) -#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) -#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) - -#define MIXER_WRITE(dev) _IOWR('M', dev, int) -#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) -#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) -#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) -#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) -#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) -#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) -#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) -#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) -#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) -#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) -#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) -#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) -#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) -#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) -#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) -#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) -#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) -#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) -#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) -#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) - -#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) - -/* - * Level 2 event types for /dev/sequencer - */ - -/* - * The 4 most significant bits of byte 0 specify the class of - * the event: - * - * 0x8X = system level events, - * 0x9X = device/port specific events, event[1] = device/port, - * The last 4 bits give the subtype: - * 0x02 = Channel event (event[3] = chn). - * 0x01 = note event (event[4] = note). - * (0x01 is not used alone but always with bit 0x02). - * event[2] = MIDI message code (0x80=note off etc.) - * - */ - -#define EV_SEQ_LOCAL 0x80 -#define EV_TIMING 0x81 -#define EV_CHN_COMMON 0x92 -#define EV_CHN_VOICE 0x93 -/* - * Event types 200 to 220 are reserved for application use. - * These numbers will not be used by the driver. - */ - -/* - * Events for event type EV_CHN_VOICE - */ - -#define MIDI_NOTEOFF 0x80 -#define MIDI_NOTEON 0x90 -#define MIDI_KEY_PRESSURE 0xA0 - -/* - * Events for event type EV_CHN_COMMON - */ - -#define MIDI_CTL_CHANGE 0xB0 -#define MIDI_PGM_CHANGE 0xC0 -#define MIDI_CHN_PRESSURE 0xD0 -#define MIDI_PITCH_BEND 0xE0 - -#define MIDI_SYSTEM_PREFIX 0xF0 - -/* - * Timer event types - */ -#define TMR_WAIT_REL 1 /* Time relative to the prev time */ -#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ -#define TMR_STOP 3 -#define TMR_START 4 -#define TMR_CONTINUE 5 -#define TMR_TEMPO 6 -#define TMR_ECHO 8 -#define TMR_CLOCK 9 /* MIDI clock */ -#define TMR_SPP 10 /* Song position pointer */ -#define TMR_TIMESIG 11 /* Time signature */ - -#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) -/* - * Some convenience macros to simplify programming of the - * /dev/sequencer interface - * - * These macros define the API which should be used when possible. - */ - -#ifndef USE_SIMPLE_MACROS -void seqbuf_dump(void); /* This function must be provided by programs */ - -/* Sample seqbuf_dump() implementation: - * - * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes - * - * int seqfd; -- The file descriptor for /dev/sequencer. - * - * void - * seqbuf_dump () - * { - * if (_seqbufptr) - * if (write (seqfd, _seqbuf, _seqbufptr) == -1) - * { - * perror ("write /dev/sequencer"); - * exit (-1); - * } - * _seqbufptr = 0; - * } - */ - -#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 -#define SEQ_USE_EXTBUF() extern unsigned char _seqbuf[]; extern int _seqbuflen;extern int _seqbufptr -#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() -#define SEQ_PM_DEFINES struct patmgr_info _pm_info -#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() -#define _SEQ_ADVBUF(len) _seqbufptr += len -#define SEQ_DUMPBUF seqbuf_dump -#else -/* - * This variation of the sequencer macros is used just to format one event - * using fixed buffer. - * - * The program using the macro library must define the following macros before - * using this library. - * - * #define _seqbuf name of the buffer (unsigned char[]) - * #define _SEQ_ADVBUF(len) If the applic needs to know the exact - * size of the event, this macro can be used. - * Otherwise this must be defined as empty. - * #define _seqbufptr Define the name of index variable or 0 if - * not required. - */ -#define _SEQ_NEEDBUF(len) /* empty */ -#endif - -#define PM_LOAD_PATCH(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ - _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ - _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ - ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) -#define PM_LOAD_PATCHES(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ - _pm_info.device=dev, memcpy(_pm_info.data.data8, pgm, 128), \ - _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ - ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) - -#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (mode);\ - _seqbuf[_seqbufptr+4] = 0;\ - _seqbuf[_seqbufptr+5] = 0;\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -/* - * Midi voice messages - */ - -#define _CHN_VOICE(dev, event, chn, note, parm) \ - {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ - _seqbuf[_seqbufptr+1] = (dev);\ - _seqbuf[_seqbufptr+2] = (event);\ - _seqbuf[_seqbufptr+3] = (chn);\ - _seqbuf[_seqbufptr+4] = (note);\ - _seqbuf[_seqbufptr+5] = (parm);\ - _seqbuf[_seqbufptr+6] = (0);\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_START_NOTE(dev, chn, note, vol) \ - _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) - -#define SEQ_STOP_NOTE(dev, chn, note, vol) \ - _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) - -#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ - _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) - -/* - * Midi channel messages - */ - -#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \ - {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ - _seqbuf[_seqbufptr+1] = (dev);\ - _seqbuf[_seqbufptr+2] = (event);\ - _seqbuf[_seqbufptr+3] = (chn);\ - _seqbuf[_seqbufptr+4] = (p1);\ - _seqbuf[_seqbufptr+5] = (p2);\ - *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ - _SEQ_ADVBUF(8);} - -#define SEQ_CHN_PRESSURE(dev, chn, pressure) \ - _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) - -#define SEQ_SET_PATCH(dev, chn, patch) \ - _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) - -#define SEQ_CONTROL(dev, chn, controller, value) \ - _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) - -#define SEQ_BENDER(dev, chn, value) \ - _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) - - -#define SEQ_V2_X_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - _seqbuf[_seqbufptr+4] = (controller);\ - *(short *)&_seqbuf[_seqbufptr+5] = (value);\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} -/* - * The following 5 macros are incorrectly implemented and obsolete. - * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. - */ -#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) -#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) -#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) -#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) -#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) -#if 0 -#define SEQ_PANNING(dev, voice, pos) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_BALANCE;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - (char)_seqbuf[_seqbufptr+4] = (pos);\ - _seqbuf[_seqbufptr+5] = 0;\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 1;\ - _SEQ_ADVBUF(8);} -#endif - -/* - * Timing and syncronization macros - */ - -#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr+0] = EV_TIMING; \ - _seqbuf[_seqbufptr+1] = (ev); \ - _seqbuf[_seqbufptr+2] = 0;\ - _seqbuf[_seqbufptr+3] = 0;\ - *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ - _SEQ_ADVBUF(8);} - -#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) -#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) -#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) -#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) -#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) -#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) -#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) -#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) -#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) - -/* - * Events for the level 1 interface only - */ - -#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ - _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ - _seqbuf[_seqbufptr+1] = (byte);\ - _seqbuf[_seqbufptr+2] = (device);\ - _seqbuf[_seqbufptr+3] = 0;\ - _SEQ_ADVBUF(4);} - -/* - * Patch loading. - */ -#define SEQ_WRPATCH(patchx, len) {if (_seqbufptr) seqbuf_dump();\ - if (write(seqfd, (char*)(patchx), len)==-1) \ - perror("Write patch: /dev/sequencer");} -#define SEQ_WRPATCH2(patchx, len) (seqbuf_dump(), write(seqfd, (char*)(patchx), len)) - -#endif -#endif diff --git a/sys/i386/isa/sound/ultrasound.h b/sys/i386/isa/sound/ultrasound.h deleted file mode 100644 index 40e2443..0000000 --- a/sys/i386/isa/sound/ultrasound.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _ULTRASOUND_H_ -#define _ULTRASOUND_H_ -/* - * Copyright by Hannu Savolainen 1993 - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - */ - -/* - * ultrasound.h - Macros for programming the Gravis Ultrasound - * These macros are extremely device dependent - * and not portable. - */ - -/* - * Private events for Gravis Ultrasound (GUS) - * - * Format: - * byte 0 - SEQ_PRIVATE (0xfe) - * byte 1 - Synthesizer device number (0-N) - * byte 2 - Command (see below) - * byte 3 - Voice number (0-31) - * bytes 4 and 5 - parameter P1 (unsigned short) - * bytes 6 and 7 - parameter P2 (unsigned short) - * - * Commands: - * Each command affects one voice defined in byte 3. - * Unused parameters (P1 and/or P2 *MUST* be initialized to zero). - * _GUS_NUMVOICES - Sets max. number of concurrent voices (P1=14-31, default 16) - * _GUS_VOICESAMPLE- ************ OBSOLETE ************* - * _GUS_VOICEON - Starts voice (P1=voice mode) - * _GUS_VOICEOFF - Stops voice (no parameters) - * _GUS_VOICEFADE - Stops the voice smoothly. - * _GUS_VOICEMODE - Alters the voice mode, don't start or stop voice (P1=voice mode) - * _GUS_VOICEBALA - Sets voice balence (P1, 0=left, 7=middle and 15=right, default 7) - * _GUS_VOICEFREQ - Sets voice (sample) playback frequency (P1=Hz) - * _GUS_VOICEVOL - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off) - * _GUS_VOICEVOL2 - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off) - * (Like GUS_VOICEVOL but doesn't change the hw - * volume. It just updates volume in the voice table). - * - * _GUS_RAMPRANGE - Sets limits for volume ramping (P1=low volume, P2=high volume) - * _GUS_RAMPRATE - Sets the speed for volume ramping (P1=scale, P2=rate) - * _GUS_RAMPMODE - Sets the volume ramping mode (P1=ramping mode) - * _GUS_RAMPON - Starts volume ramping (no parameters) - * _GUS_RAMPOFF - Stops volume ramping (no parameters) - * _GUS_VOLUME_SCALE - Changes the volume calculation constants - * for all voices. - */ - -#define _GUS_NUMVOICES 0x00 -#define _GUS_VOICESAMPLE 0x01 /* OBSOLETE */ -#define _GUS_VOICEON 0x02 -#define _GUS_VOICEOFF 0x03 -#define _GUS_VOICEMODE 0x04 -#define _GUS_VOICEBALA 0x05 -#define _GUS_VOICEFREQ 0x06 -#define _GUS_VOICEVOL 0x07 -#define _GUS_RAMPRANGE 0x08 -#define _GUS_RAMPRATE 0x09 -#define _GUS_RAMPMODE 0x0a -#define _GUS_RAMPON 0x0b -#define _GUS_RAMPOFF 0x0c -#define _GUS_VOICEFADE 0x0d -#define _GUS_VOLUME_SCALE 0x0e -#define _GUS_VOICEVOL2 0x0f -#define _GUS_VOICE_POS 0x10 - -/* - * GUS API macros - */ - -#define _GUS_CMD(chn, voice, cmd, p1, p2) \ - {_SEQ_NEEDBUF(8); _seqbuf[_seqbufptr] = SEQ_PRIVATE;\ - _seqbuf[_seqbufptr+1] = (chn); _seqbuf[_seqbufptr+2] = cmd;\ - _seqbuf[_seqbufptr+3] = voice;\ - *(unsigned short*)&_seqbuf[_seqbufptr+4] = p1;\ - *(unsigned short*)&_seqbuf[_seqbufptr+6] = p2;\ - _SEQ_ADVBUF(8);} - -#define GUS_NUMVOICES(chn, p1) _GUS_CMD(chn, 0, _GUS_NUMVOICES, (p1), 0) -#define GUS_VOICESAMPLE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICESAMPLE, (p1), 0) /* OBSOLETE */ -#define GUS_VOICEON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEON, (p1), 0) -#define GUS_VOICEOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEOFF, 0, 0) -#define GUS_VOICEFADE(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEFADE, 0, 0) -#define GUS_VOICEMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEMODE, (p1), 0) -#define GUS_VOICEBALA(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEBALA, (p1), 0) -#define GUS_VOICEFREQ(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICEFREQ, \ - (p) & 0xffff, ((p) >> 16) & 0xffff) -#define GUS_VOICEVOL(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL, (p1), 0) -#define GUS_VOICEVOL2(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL2, (p1), 0) -#define GUS_RAMPRANGE(chn, voice, low, high) _GUS_CMD(chn, voice, _GUS_RAMPRANGE, (low), (high)) -#define GUS_RAMPRATE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_RAMPRATE, (p1), (p2)) -#define GUS_RAMPMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPMODE, (p1), 0) -#define GUS_RAMPON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPON, (p1), 0) -#define GUS_RAMPOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_RAMPOFF, 0, 0) -#define GUS_VOLUME_SCALE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_VOLUME_SCALE, (p1), (p2)) -#define GUS_VOICE_POS(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICE_POS, \ - (p) & 0xffff, ((p) >> 16) & 0xffff) - -#endif diff --git a/sys/i386/isa/sound/vat_audio.c b/sys/i386/isa/sound/vat_audio.c deleted file mode 100644 index 74f0bdd..0000000 --- a/sys/i386/isa/sound/vat_audio.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Minimally compliant SunOS compatible audio driver front-end - * for use with VAT. - * - * This is a front end for the voxware based drivers that form the standard - * audio driver system for FreeBSD. It will not operate without the voxware - * package. - * - * This is not a full implementation of the SunOS audio driver, don't - * expect anything other than vat to operate with it. - * - * ---WARNING - * ---WARNING this work is not complete, it still doesn't work - * ---WARNING - * - * Copyright (C) 1993-1994 Jim Lowe - * Additional development by Amancio Hasty - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation. - * - * This software is provided `as-is'. The author disclaims all - * warranties with regard to this software, including without - * limitation all implied warranties of merchantability, fitness for - * a particular purpose, or noninfringement. In no event shall the - * author be liable for any damages whatsoever, including - * special, incidental or consequential damages, including loss of - * use, data, or profits, even if advised of the possibility thereof, - * and regardless of whether in an action in contract, tort or - * negligence, arising out of or in connection with the use or - * performance of this software. - * - */ - -#include "vat_audio.h" -#include "snd.h" /* Generic Sound Driver (voxware) */ - -#if (NVAT_AUDIO > 0) && (NSND > 0) - -#include "sound_config.h" -#include "os.h" -#include "vat_audioio.h" - -#define splaudio splclock - -extern int sndopen (dev_t dev, int flags); -extern int sndclose (dev_t dev, int flags); -extern int sndioctl (dev_t dev, int cmd, void *arg, int mode); -extern int sndread (int dev, struct uio *uio); -extern int sndwrite (int dev, struct uio *uio); - -struct va_softc { - dev_t rdev; /* record device */ - dev_t pdev; /* playback device */ - dev_t mixer; /* mixer device */ - struct selinfo wsel; /* write select info */ - struct selinfo rsel; /* read select info */ - int rlevel; - int plevel; - int open; -} va_softc; - -#define DEF_SAMPLE_RATE 8007 - -#ifndef AUDIOBLOCKSIZE -#define AUDIOBLOCKSIZE 160 /* 20ms at 8khz */ -#endif - -static int iblocksize = AUDIOBLOCKSIZE; -static int oblocksize = 1024; - -static u_int record_devices = (SOUND_MASK_MIC|SOUND_MASK_LINE|SOUND_MASK_CD); - -static int default_level[SOUND_MIXER_NRDEVICES] = { /* max = 0x64 */ - 0x3232, /* Master Volume */ - 0x3232, /* Bass */ - 0x3232, /* Treble */ - 0x0000, /* FM */ - 0x6464, /* PCM */ - 0x0000, /* PC Speaker */ - 0x6464, /* Ext Line */ - 0x6464, /* Mic */ - 0x4b4b, /* CD */ - 0x0000, /* Recording monitor (input mixer) -- avoid feedback */ - 0x4b4b, /* SB PCM */ - 0x6464, /* Record Level -- to ADC */ -}; - - -static void -setpgain(int level) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - int arg; - - level = (level * 100 / 255) & 0x7f; - arg = (level << 8) | level; - - sndioctl(va->mixer, MIXER_WRITE(SOUND_MIXER_PCM), &arg, 0); -} - -static void -setrgain(int level) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - int arg, arg1; - - level = (level * 100 / 255) & 0x7f; - arg = (level << 8) | level; - - sndioctl(va->mixer, SOUND_MIXER_WRITE_LINE, &arg, 0); - sndioctl(va->mixer, SOUND_MIXER_WRITE_MIC, &arg, 0); - sndioctl(va->mixer, SOUND_MIXER_WRITE_CD, &arg, 0); -} - -static int -setprate(int rate) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - register int dev; - - dev = va->pdev >> 4; - return (audio_devs[dev]->ioctl(dev, SOUND_PCM_WRITE_RATE, rate, 1)); -} - -static int -setrrate(int rate) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - register int dev; - - dev = va->rdev >> 4; - return (audio_devs[dev]->ioctl(dev, SOUND_PCM_WRITE_RATE, rate, 1)); -} - -int -vaopen(dev_t dev, int flags) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - int s; - - if (va->open) - return(EBUSY); - else - va->open = 1; - -#ifdef SND_BIDIR - va->rdev = SND_DEV_AUDIO | (1<<4); /* first and second device */ - va->pdev = SND_DEV_AUDIO | (0<<4); - va->mixer = SND_DEV_CTL; - - s = sndopen(va->rdev, FREAD); - if (s) { - va->open = 0; - return(s); - } - - s = sndopen(va->pdev, FWRITE); - if (s) { - va->open = 0; - sndclose(va->rdev, FREAD); - return(s); - } -#else - va->rdev = SND_DEV_AUDIO | (0<<4); /* first attached device */ - va->pdev = SND_DEV_AUDIO | (0<<4); - va->mixer = SND_DEV_CTL; - - s = sndopen(va->rdev, flags); - if (s) { - va->open = 0; - return(s); - } -#endif - - /* set sample rates */ - setprate(DEF_SAMPLE_RATE); - setrrate(DEF_SAMPLE_RATE); - - /* set block size for I/O samples */ - sndioctl(va->rdev, SNDCTL_DSP_GETBLKSIZE, &iblocksize, 0); - sndioctl(va->pdev, SNDCTL_DSP_GETBLKSIZE, &oblocksize, 0); - - /* initialize mixer controls the way we want them */ - sndioctl(va->mixer, SOUND_MIXER_WRITE_RECSRC, &record_devices, 0); - - for (s = 0; s < SOUND_MIXER_NRDEVICES; s++) - sndioctl(va->mixer, MIXER_WRITE(s), &default_level[s], 0); - - va->rlevel = (default_level[SOUND_MASK_MIC] & 0x7f) * 255 / 100; - va->plevel = (default_level[SOUND_MASK_PCM] & 0x7f) * 255 / 100; - - if (flags & FREAD) /* start the read process */ - DMAbuf_start_input(va->rdev>>4); - - return(0); -} - -int -vaclose(dev_t dev, int flags) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - - va->open = 0; - - sndioctl(va->mixer, SNDCTL_DSP_RESET, NULL, 0); - -#ifdef SND_BIDIR - sndclose(va->pdev, FWRITE); - sndclose(va->rdev, FREAD); -#else - sndclose(va->rdev, flags); -#endif - return (0); -} - -int -varead(dev_t dev, struct uio *buf) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - - return sndread(va->rdev, buf); -} - -int -vawrite(dev_t dev, struct uio *buf) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - - return sndwrite(va->pdev, buf); -} - -void -audio_get_info(struct va_softc *va, struct audio_info *ai) -{ - struct audio_prinfo *r, *p; - int rdev = va->rdev >> 4; - int pdev = va->pdev >> 4; - - r = &ai->record; - p = &ai->play; - - p->sample_rate = - audio_devs[pdev]->ioctl(pdev, SOUND_PCM_READ_RATE, 0, 1); - r->sample_rate = - audio_devs[rdev]->ioctl(rdev, SOUND_PCM_READ_RATE, 0, 1); - - p->channels = - audio_devs[pdev]->ioctl(pdev, SOUND_PCM_READ_CHANNELS, 0, 1); - r->channels = - audio_devs[rdev]->ioctl(rdev, SOUND_PCM_READ_CHANNELS, 0, 1); - - p->precision = audio_devs[pdev]->ioctl(pdev, SOUND_PCM_READ_BITS, 0, 1); - r->precision = audio_devs[rdev]->ioctl(rdev, SOUND_PCM_READ_BITS, 0, 1); - - p->encoding = r->encoding = AUDIO_ENCODING_ULAW; - - ai->monitor_gain = 0; - - r->gain = va->rlevel; - p->gain = va->plevel; - - r->port = 1; - p->port = AUDIO_SPEAKER; - - p->open = r->open = va->open; -} - -void -audio_set_info(struct va_softc *va, struct audio_info *ai) -{ - struct audio_prinfo *r, *p; - int rdev = va->rdev >> 4; - int pdev = va->pdev >> 4; - - r = &ai->record; - p = &ai->play; - - /* Only set gains if mode == -1, I think this is a bug in vat. */ - - if (ai->mode == ~0) { - if (p->gain != ~0) { - va->plevel = p->gain; - setpgain(va->plevel); - } - if (r->gain != ~0) { - va->rlevel = r->gain; - setrgain(va->rlevel); - } - } - - if (p->sample_rate != ~0) - p->sample_rate = setprate(p->sample_rate); - - if (r->sample_rate != ~0) - r->sample_rate = setrrate(r->sample_rate); - - DMAbuf_start_input(rdev); -} - -int -vaioctl(dev_t dev, int cmd, caddr_t arg, int mode) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - int s; - - switch(cmd) { - case FIONBIO: - break; /* handled above in file i/o routines */ - case AUDIO_GETINFO: - audio_get_info(va, (struct audio_info *)arg); - break; - case AUDIO_SETINFO: - audio_set_info(va, (struct audio_info *)arg); - break; - default: - printf("vaioctl: cmd=0x%x, '%c', num = %d, len=%d, %s\n", - cmd, IOCGROUP(cmd), cmd & 0xff, IOCPARM_LEN(cmd), - cmd&IOC_IN ? "in" : "out"); - - s = sndioctl(va->rdev, cmd, arg, mode); - - if (s == 0) - s = sndioctl(va->pdev, cmd, arg, mode); - break; - } - return(0); -} - -int -vaselect(dev_t dev, int rw, struct proc *p) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - int s, r; - - r = 0; - s = splaudio(); - - switch (rw) { - case FREAD: - if (DMAbuf_input_ready(va->rdev>>4)) - r = 1; - else - selrecord(p, &va->rsel); - break; - case FWRITE: - if (DMAbuf_output_ready(va->pdev>>4)) - r = 1; - else - selrecord(p, &va->wsel); - break; - } - - splx(s); - return(r); -} - -void -audio_rint(void) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - - if (!va->open) - return; - - selwakeup(&va->rsel); -} - -void -audio_pint(void) -{ - register struct va_softc *va = (struct va_softc *)&va_softc; - - if (!va->open) - return; - - selwakeup(&va->wsel); -} -#else - -void audio_rint(void) {} -void audio_pint(void) {} - -#endif /* NVAT_AUDIO && NSND */ diff --git a/sys/i386/isa/sound/vat_audioio.h b/sys/i386/isa/sound/vat_audioio.h deleted file mode 100644 index 03cff23..0000000 --- a/sys/i386/isa/sound/vat_audioio.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 1991-1993 Regents of the University of California. - * All rights reserved. - * - * 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 Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory 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. - * - * /home/ncvs/src/sys/i386/isa/sound/vat_audioio.h,v 1.1 1994/12/16 04:59:18 pst Exp (LBL) - */ - -#ifndef _BSD_AUDIOIO_H_ -#define _BSD_AUDIOIO_H_ - -/* - * /dev/audio ioctls. needs comments! - */ -#define AUDIO_MIN_GAIN (0) -#define AUDIO_MAX_GAIN (255) - -#define AUDIO_ENCODING_ULAW (1) -#define AUDIO_ENCODING_ALAW (2) -#define AUDIO_ENCODING_LINEAR (3) - -struct audio_prinfo { - u_int sample_rate; - u_int channels; - u_int precision; - u_int encoding; - u_int gain; - u_int port; - u_long seek; /* BSD extension */ - u_int ispare[3]; - u_int samples; - u_int eof; - - u_char pause; - u_char error; - u_char waiting; - u_char cspare[3]; - u_char open; - u_char active; - -}; - -struct audio_info { - struct audio_prinfo play; - struct audio_prinfo record; - u_int monitor_gain; - /* BSD extensions */ - u_int blocksize; /* input blocking threshold */ - u_int hiwat; /* output high water mark */ - u_int lowat; /* output low water mark */ - u_int backlog; /* samples of output backlog to gen. */ -#define AUMODE_PLAY 0 -#define AUMODE_RECORD 1 - u_int mode; -}; -typedef struct audio_info audio_info_t; - -#define AUDIO_INITINFO(p)\ - (void)memset((void *)(p), 0xff, sizeof(struct audio_info)) - -#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__) -#define AUDIO_GETINFO _IOR(A, 21, struct audio_info) -#define AUDIO_SETINFO _IOWR(A, 22, struct audio_info) -#define AUDIO_DRAIN _IO(A, 23) -#define AUDIO_FLUSH _IO(A, 24) -#define AUDIO_WSEEK _IOR(A, 25, u_long) -#define AUDIO_RERROR _IOR(A, 26, int) -#define AUDIO_GETMAP _IOR(A, 27, struct mapreg) -#define AUDIO_SETMAP _IOW(A, 28, struct mapreg) -#else -#define AUDIO_GETINFO _IOR('A', 21, struct audio_info) -#define AUDIO_SETINFO _IOWR('A', 22, struct audio_info) -#define AUDIO_DRAIN _IO('A', 23) -#define AUDIO_FLUSH _IO('A', 24) -#define AUDIO_WSEEK _IOR('A', 25, u_long) -#define AUDIO_RERROR _IOR('A', 26, int) -#define AUDIO_GETMAP _IOR('A', 27, struct mapreg) -#define AUDIO_SETMAP _IOW('A', 28, struct mapreg) -#endif - -#define AUDIO_SPEAKER 1 -#define AUDIO_HEADPHONE 2 - -#endif /* _BSD_AUDIOIO_H_ */ diff --git a/sys/i386/pci/README.de b/sys/i386/pci/README.de deleted file mode 100644 index fb81945..0000000 --- a/sys/i386/pci/README.de +++ /dev/null @@ -1,48 +0,0 @@ -$Id: README.de,v 1.3 1994/10/12 11:19:36 se Exp $ - ----------------- - -The enclosed driver should be considered as beta-test software. It -has run on exactly one machine. Therefore testing has been limited. -This driver is in no way supported by Digital Equipment. See the -disclaimers in the sources for more. - -This driver the DEC DE435 PCI NIC. It should also work with other PCI -boards that use the DC21040-AA chip (also known as TULIP). This -driver requires the DC21040-AA to be pass 2.3 or later. If you are -using a eariler pass chip, you may encounter undetected transmit -corruptions. This driver also requires that DC21040-AA use a serial -Ethernet address ROM as described in the DC21040 specification. - -The DEC DE425 EISA NIC based on the DC21040-AA is not support at -this time. A future update will include support for it. - -The driver includes full support for both BPF and IP Multicast. -If the autosensing of the driver fails, you can use ifconfig(8) to -switch the driver to the correct port. - - ifconfig de0 altphys Thinwire/AUI port - ifconfig de0 -altphys 10baseT/UTP port - -To enable this driver, you first need to add the following lines to -your config file (in i386/conf): - - controller pci0 - device de0 - -The PCI support code will automatically determine and enable the -correct IRQ. - -Now you are ready to rebuild your kernel, reboot, and see if the -driver can configure your board. When the system boots, you will -hopefully something close to: - - de0 <digital dc21040 ethernet> int a irq 9 on pci0:7 - reg20: virtual=0xf290a000 physical=0xc0001000 - de0: enabling Thinwire/AUI port - de0: DC21040 [10Mb/s] pass 2.3 ethernet address 08:00:2b:e2:1e:09 - bpf: de0 attached - -in the startup log. If so, the board configured properly and -should be ready to use. - diff --git a/sys/i386/pci/README.de-le b/sys/i386/pci/README.de-le deleted file mode 100644 index 60cd2e2..0000000 --- a/sys/i386/pci/README.de-le +++ /dev/null @@ -1,33 +0,0 @@ -$Id: README.de-le,v 1.1 1994/10/01 20:16:44 wollman Exp $ - ----------------- - -The enclosed drivers should be considered beta-test software. These -drivers are in no way supported by Digital Equipment. See the -disclaimers in the sources for more information. Please be aware that -Digital does not employee me to write drivers for FreeBSD. - -This kit contains one driver: - - de DEC DE435 PCI NIC or compatible - -See README.de for information and installation instruction specific to this -driver. - -Could you please send me the startup messages in the boot -long along with the type of your PC once the driver configures? - -If you have any problems, comments, suggestions, rant or raves, don't -hesitate to send me mail @ thomas@lkg.dec.com. - -Lastly, if you change or modify the code, I want context diffs of your -changes. I want this to the canonical DEC EtherWORKS driver kit for -FreeBSD, NetBSD, BSD/386, and any other BSD based O/S. Please make -sure your diffs are approriate conditionalized. - -Thanks, -Matt Thomas --- -Mail: thomas@lkg.dec.com -URL: http://ftp.digital.com/~thomas/ - diff --git a/sys/i386/pci/aic7870.c b/sys/i386/pci/aic7870.c deleted file mode 100644 index 373fea5..0000000 --- a/sys/i386/pci/aic7870.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Product specific probe and attach routines for: - * 294X and aic7870 motherboard SCSI controllers - * - * Copyright (c) 1995 Justin T. Gibbs - * All rights reserved. - * - * 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 immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * Justin T. Gibbs. - * 4. Modifications may be freely made to this file if the above conditions - * are met. - * - * $Id: aic7870.c,v 1.2 1995/01/16 16:31:57 gibbs Exp $ - */ - -#include <pci.h> -#if NPCI > 0 -#include <sys/param.h> -#include <sys/systm.h> -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> -#include <i386/pci/pcireg.h> -#include <i386/scsi/aic7xxx.h> - -#define PCI_BASEADR0 PCI_MAP_REG_START -#define PCI_DEVICE_ID_ADAPTEC_2940 0x71789004ul -#define PCI_DEVICE_ID_ADAPTEC_AIC7870 0x70789004ul - -static char* aic7870_probe __P((pcici_t tag, pcidi_t type)); -void aic7870_attach __P((pcici_t config_id, int unit)); - -static u_long aic7870_count; - -struct pci_driver ahc_device = { - aic7870_probe, - aic7870_attach, - &aic7870_count -}; - -static char* -aic7870_probe (pcici_t tag, pcidi_t type) -{ - switch(type) { - case PCI_DEVICE_ID_ADAPTEC_2940: - return ("Adaptec 294X SCSI host adapter"); - break; - case PCI_DEVICE_ID_ADAPTEC_AIC7870: - return ("Adaptec aic7870 SCSI host adapter"); - break; - default: - break; - } - return (0); - -} - -void -aic7870_attach(config_id, unit) - pcici_t config_id; - int unit; -{ - u_long io_port; - if(!(io_port = pci_conf_read(config_id, PCI_BASEADR0))) - return; - io_port -= 0xc01ul; /* - printf("io_port = 0x%lx\n", io_port); - * Make the offsets the same as for EISA - * The first bit of PCI_BASEADR0 is always - * set hence we subtract 0xc01 instead of the - * 0xc00 that you would expect. - */ - if(ahcprobe(unit, io_port, AHC_294)){ - ahc_unit++; - if(ahc_attach(unit)) - /* - * To be compatible with the isa style of - * interrupt handler, we pass the unit number - * not a pointer to our per device structure. - */ - pci_map_int (config_id, ahcintr, (void *)unit, - &bio_imask); - } - return; -} - -#endif /* NPCI > 0 */ diff --git a/sys/i386/pci/dc21040.h b/sys/i386/pci/dc21040.h deleted file mode 100644 index 4afa274..0000000 --- a/sys/i386/pci/dc21040.h +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * Copyright (c) 1994 Matt Thomas (thomas@lkg.dec.com) - * All rights reserved. - * - * 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - * $Id: dc21040.h,v 1.2 1994/08/15 20:42:25 thomas Exp thomas $ - * - * $Log: dc21040.h,v $ - * Revision 1.2 1994/08/15 20:42:25 thomas - * misc additions - * - * Revision 1.1 1994/08/12 21:02:46 thomas - * Initial revision - * - * Revision 1.8 1994/08/05 20:20:54 thomas - * Enable change log - * - * Revision 1.7 1994/08/05 20:20:14 thomas - * *** empty log message *** - * - */ - -#if !defined(_DC21040_H) -#define _DC21040_H - -typedef signed int tulip_sint32_t; -typedef unsigned int tulip_uint32_t; - -#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN -#define TULIP_BITFIELD2(a, b) b, a -#define TULIP_BITFIELD3(a, b, c) c, b, a -#define TULIP_BITFIELD4(a, b, c, d) d, c, b, a -#else -#define TULIP_BITFIELD2(a, b) a, b -#define TULIP_BITFIELD3(a, b, c) a, b, c -#define TULIP_BITFIELD4(a, b, c, d) a, b, c, d -#endif - -typedef struct { - tulip_uint32_t d_status; - tulip_uint32_t TULIP_BITFIELD3(d_length1 : 11, - d_length2 : 11, - d_flag : 10); - tulip_uint32_t d_addr1; - tulip_uint32_t d_addr2; -} tulip_desc_t; - -#define TULIP_DSTS_OWNER 0x80000000 /* Owner (1 = DC21040) */ -#define TULIP_DSTS_ERRSUM 0x00008000 /* Error Summary */ -/* - * Transmit Status - */ -#define TULIP_DSTS_TxBABBLE 0x00004000 /* Transmitter Babbled */ -#define TULIP_DSTS_TxCARRLOSS 0x00000800 /* Carrier Loss */ -#define TULIP_DSTS_TxNOCARR 0x00000400 /* No Carrier */ -#define TULIP_DSTS_TxLATECOLL 0x00000200 /* Late Collision */ -#define TULIP_DSTS_TxEXCCOLL 0x00000100 /* Excessive Collisions */ -#define TULIP_DSTS_TxNOHRTBT 0x00000080 /* No Heartbeat */ -#define TULIP_DSTS_TxCOLLMASK 0x00000078 /* Collision Count (mask) */ -#define TULIP_DSTS_V_TxCOLLCNT 0x00000003 /* Collision Count (bit) */ -#define TULIP_DSTS_TxLINKFAIL 0x00000004 /* Link Failure */ -#define TULIP_DSTS_TxUNDERFLOW 0x00000002 /* Underflow Error */ -#define TULIP_DSTS_TxDEFERRED 0x00000001 /* Initially Deferred */ -/* - * Receive Status - */ -#define TULIP_DSTS_RxBADLENGTH 0x00004000 /* Length Error */ -#define TULIP_DSTS_RxDATATYPE 0x00003000 /* Data Type */ -#define TULIP_DSTS_RxRUNT 0x00000800 /* Runt Frame */ -#define TULIP_DSTS_RxMULTICAST 0x00000400 /* Multicast Frame */ -#define TULIP_DSTS_RxFIRSTDESC 0x00000200 /* First Descriptor */ -#define TULIP_DSTS_RxLASTDESC 0x00000100 /* Last Descriptor */ -#define TULIP_DSTS_RxTOOLONG 0x00000080 /* Frame Too Long */ -#define TULIP_DSTS_RxCOLLSEEN 0x00000040 /* Collision Seen */ -#define TULIP_DSTS_RxFRAMETYPE 0x00000020 /* Frame Type */ -#define TULIP_DSTS_RxWATCHDOG 0x00000010 /* Receive Watchdog */ -#define TULIP_DSTS_RxDRBBLBIT 0x00000004 /* Dribble Bit */ -#define TULIP_DSTS_RxBADCRC 0x00000002 /* CRC Error */ -#define TULIP_DSTS_RxOVERFLOW 0x00000001 /* Overflow */ - - -#define TULIP_DFLAG_ENDRING 0x0008 /* End of Transmit Ring */ -#define TULIP_DFLAG_CHAIN 0x0004 /* Chain using d_addr2 */ - -#define TULIP_DFLAG_TxWANTINTR 0x0200 /* Signal Interrupt on Completion */ -#define TULIP_DFLAG_TxLASTSEG 0x0100 /* Last Segment */ -#define TULIP_DFLAG_TxFIRSTSEG 0x0080 /* First Segment */ -#define TULIP_DFLAG_TxINVRSFILT 0x0040 /* Inverse Filtering */ -#define TULIP_DFLAG_TxSETUPPKT 0x0020 /* Setup Packet */ -#define TULIP_DFLAG_TxHASCRC 0x0010 /* Don't Append the CRC */ -#define TULIP_DFLAG_TxNOPADDING 0x0002 /* Don't AutoPad */ -#define TULIP_DFLAG_TxHASHFILT 0x0001 /* Hash/Perfect Filtering */ - -/* - * The DC21040 Registers (IO Space Addresses) - */ -#define TULIP_REG_BUSMODE 0x00 /* CSR0 -- Bus Mode */ -#define TULIP_REG_TXPOLL 0x08 /* CSR1 -- Transmit Poll Demand */ -#define TULIP_REG_RXPOLL 0x10 /* CSR2 -- Receive Poll Demand */ -#define TULIP_REG_RXLIST 0x18 /* CSR3 -- Receive List Base Addr */ -#define TULIP_REG_TXLIST 0x20 /* CSR4 -- Transmit List Base Addr */ -#define TULIP_REG_STATUS 0x28 /* CSR5 -- Status */ -#define TULIP_REG_CMD 0x30 /* CSR6 -- Command */ -#define TULIP_REG_INTR 0x38 /* CSR7 -- Interrupt Control */ -#define TULIP_REG_MISSES 0x40 /* CSR8 -- Missed Frame Counter */ -#define TULIP_REG_ADDRROM 0x48 /* CSR9 -- ENET ROM Register */ -#define TULIP_REG_RSRVD 0x50 /* CSR10 -- Reserved */ -#define TULIP_REG_FULL_DUPLEX 0x58 /* CSR11 -- Full Duplex */ -#define TULIP_REG_SIA_STATUS 0x60 /* CSR12 -- SIA Status */ -#define TULIP_REG_SIA_CONN 0x68 /* CSR13 -- SIA Connectivity */ -#define TULIP_REG_SIA_TXRX 0x70 /* CSR14 -- SIA Tx Rx */ -#define TULIP_REG_SIA_GEN 0x78 /* CSR15 -- SIA General */ - -/* - * CSR5 -- Status Register - * CSR7 -- Interrupt Control - */ -#define TULIP_STS_ERRORMASK 0x03800000L /* ( R) Error Bits (Valid when SYSERROR is set) */ -#define TULIP_STS_ERR_PARITY 0x00000000L /* 000 - Parity Error (Perform Reset) */ -#define TULIP_STS_ERR_MASTER 0x00800000L /* 001 - Master Abort */ -#define TULIP_STS_ERR_TARGET 0x01000000L /* 010 - Target Abort */ -#define TULIP_STS_TXSTATEMASK 0x00700000L /* ( R) Transmission Process State */ -#define TULIP_STS_TXS_RESET 0x00000000L /* 000 - Rset or transmit jabber expired */ -#define TULIP_STS_TXS_FETCH 0x00100000L /* 001 - Fetching transmit descriptor */ -#define TULIP_STS_TXS_WAITEND 0x00200000L /* 010 - Wait for end of transmission */ -#define TULIP_STS_TXS_READING 0x00300000L /* 011 - Read buffer and enqueue data */ -#define TULIP_STS_TXS_RSRVD 0x00400000L /* 100 - Reserved */ -#define TULIP_STS_TXS_SETUP 0x00500000L /* 101 - Setup Packet */ -#define TULIP_STS_TXS_SUSPEND 0x00600000L /* 110 - Transmit FIFO underflow or an - unavailable transmit descriptor */ -#define TULIP_STS_TXS_CLOSE 0x00700000L /* 111 - Close transmit descriptor */ -#define TULIP_STS_RXSTATEMASK 0x000E0000L /* ( R) Receive Process State*/ -#define TULIP_STS_RXS_STOPPED 0x00000000L /* 000 - Stopped */ -#define TULIP_STS_RXS_FETCH 0x00020000L /* 001 - Running -- Fetch receive descriptor */ -#define TULIP_STS_RXS_ENDCHECK 0x00040000L /* 010 - Running -- Check for end of receive - packet before prefetch of next descriptor */ -#define TULIP_STS_RXS_WAIT 0x00060000L /* 011 - Running -- Wait for receive packet */ -#define TULIP_STS_RXS_SUSPEND 0x00080000L /* 100 - Suspended -- As a result of - unavailable receive buffers */ -#define TULIP_STS_RXS_CLOSE 0x000A0000L /* 101 - Running -- Close receive descriptor */ -#define TULIP_STS_RXS_FLUSH 0x000C0000L /* 110 - Running -- Flush the current frame - from the receive FIFO as a result of - an unavailable receive buffer */ -#define TULIP_STS_RXS_DEQUEUE 0x000E0000L /* 111 - Running -- Dequeue the receive frame - from the receive FIFO into the receive - buffer. */ -#define TULIP_STS_NORMALINTR 0x00010000L /* (RW) Normal Interrupt */ -#define TULIP_STS_ABNRMLINTR 0x00008000L /* (RW) Abnormal Interrupt */ -#define TULIP_STS_SYSERROR 0x00002000L /* (RW) System Error */ -#define TULIP_STS_LINKFAIL 0x00001000L /* (RW) Link Failure */ -#define TULIP_STS_FULDPLXSHRT 0x00000800L /* (RW) Full Duplex Short Fram Rcvd */ -#define TULIP_STS_AUI 0x00000400L /* (RW) AUI/TP Switch */ -#define TULIP_STS_RXTIMEOUT 0x00000200L /* (RW) Receive Watchbog Timeout */ -#define TULIP_STS_RXSTOPPED 0x00000100L /* (RW) Receive Process Stopped */ -#define TULIP_STS_RXNOBUF 0x00000080L /* (RW) Receive Buffer Unavailable */ -#define TULIP_STS_RXINTR 0x00000040L /* (RW) Receive Interrupt */ -#define TULIP_STS_TXUNDERFLOW 0x00000020L /* (RW) Transmit Underflow */ -#define TULIP_STS_TXBABBLE 0x00000008L /* (RW) Transmit Jabber Timeout */ -#define TULIP_STS_TXNOBUF 0x00000004L /* (RW) Transmit Buffer Unavailable */ -#define TULIP_STS_TXSTOPPED 0x00000002L /* (RW) Transmit Process Stopped */ -#define TULIP_STS_TXINTR 0x00000001L /* (RW) Transmit Interrupt */ - -/* - * CSR6 -- Command (Operation Mode) Register - */ -#define TULIP_CMD_CAPTREFFCT 0x00020000L /* (RW) Capture Effect (!802.3) */ -#define TULIP_CMD_BACKPRESSURE 0x00010000L /* (RW) Back Pressure (!802.3) */ -#define TULIP_CMD_THRESHOLDCTL 0x0000C000L /* (RW) Threshold Control */ -#define TULIP_CMD_THRSHLD72 0x00000000L /* 00 - 72 Bytes */ -#define TULIP_CMD_THRSHLD96 0x00004000L /* 01 - 96 Bytes */ -#define TULIP_CMD_THRSHLD128 0x00008000L /* 10 - 128 bytes */ -#define TULIP_CMD_THRSHLD160 0x0000C000L /* 11 - 160 Bytes */ -#define TULIP_CMD_TXRUN 0x00002000L /* (RW) Start/Stop Transmitter */ -#define TULIP_CMD_FORCECOLL 0x00001000L /* (RW) Force Collisions */ -#define TULIP_CMD_OPERMODE 0x00000C00L /* (RW) Operating Mode */ -#define TULIP_CMD_FULLDULPEX 0x00000200L /* (RW) Full Duplex Mode */ -#define TULIP_CMD_FLAKYOSCDIS 0x00000100L /* (RW) Flakey Oscillator Disable */ -#define TULIP_CMD_ALLMULTI 0x00000080L /* (RW) Pass All Multicasts */ -#define TULIP_CMD_PROMISCUOUS 0x00000040L /* (RW) Promiscuous Mode */ -#define TULIP_CMD_BACKOFFCTR 0x00000020L /* (RW) Start/Stop Backoff Counter (!802.3) */ -#define TULIP_CMD_INVFILTER 0x00000010L /* (R ) Inverse Filtering */ -#define TULIP_CMD_PASSBADPKT 0x00000008L /* (RW) Pass Bad Frames */ -#define TULIP_CMD_HASHONLYFLTR 0x00000004L /* (R ) Hash Only Filtering */ -#define TULIP_CMD_RXRUN 0x00000002L /* (RW) Start/Stop Receive Filtering */ -#define TULIP_CMD_HASHPRFCTFLTR 0x00000001L /* (R ) Hash/Perfect Receive Filtering */ - - -#define TULIP_SIASTS_LINKFAIL 0x00000004L -#define TULIP_SIACONN_RESET 0x00000000L - -#define TULIP_SIACONN_AUI 0x0000000DL -#define TULIP_SIACONN_10BASET 0x00000005L - -#define TULIP_BUSMODE_SWRESET 0x00000001L - -#endif /* !defined(_DC21040_H) */ diff --git a/sys/i386/pci/if_de.c b/sys/i386/pci/if_de.c deleted file mode 100644 index 0c0ac6b..0000000 --- a/sys/i386/pci/if_de.c +++ /dev/null @@ -1,1155 +0,0 @@ -/*- - * Copyright (c) 1994 Matt Thomas (thomas@lkg.dec.com) - * All rights reserved. - * - * 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - * $Id: if_de.c,v 1.12 1994/12/22 21:56:19 wollman Exp $ - * - */ - -/* - * DEC DC21040 PCI Ethernet Controller - * - * Written by Matt Thomas - * BPF support code stolen directly from if_ec.c - * - * This driver supports the DEC DE435 or any other PCI - * board which support DC21040. - */ - -#include "de.h" -#if NDE > 0 - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/mbuf.h> -#include <sys/protosw.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <sys/errno.h> -#include <sys/malloc.h> - -#include <net/if.h> -#include <net/if_types.h> -#include <net/if_dl.h> -#include <net/route.h> - -#include "bpfilter.h" -#if NBPFILTER > 0 -#include <net/bpf.h> -#include <net/bpfdesc.h> -#endif - -#ifdef INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#include <netinet/if_ether.h> -#endif - -#ifdef NS -#include <netns/ns.h> -#include <netns/ns_if.h> -#endif - -#include <vm/vm.h> -#include <vm/vm_kern.h> -#include <vm/vm_param.h> - - -#include <pci.h> -#if NPCI > 0 -#include <i386/pci/pcireg.h> -#endif -#include <i386/isa/icu.h> -#include <i386/pci/dc21040.h> - -/* - * This module supports the DEC DC21040 PCI Ethernet Controller. - */ - -typedef struct { - unsigned long addr; - unsigned long length; -} tulip_addrvec_t; - -typedef struct { - tulip_desc_t *ri_first; - tulip_desc_t *ri_last; - tulip_desc_t *ri_nextin; - tulip_desc_t *ri_nextout; - int ri_max; - int ri_free; -} tulip_ringinfo_t; - -typedef struct { - volatile tulip_uint32_t *csr_busmode; /* CSR0 */ - volatile tulip_uint32_t *csr_txpoll; /* CSR1 */ - volatile tulip_uint32_t *csr_rxpoll; /* CSR2 */ - volatile tulip_uint32_t *csr_rxlist; /* CSR3 */ - volatile tulip_uint32_t *csr_txlist; /* CSR4 */ - volatile tulip_uint32_t *csr_status; /* CSR5 */ - volatile tulip_uint32_t *csr_command; /* CSR6 */ - volatile tulip_uint32_t *csr_intr; /* CSR7 */ - volatile tulip_uint32_t *csr_missed_frame; /* CSR8 */ - volatile tulip_sint32_t *csr_enetrom; /* CSR9 */ - volatile tulip_uint32_t *csr_reserved; /* CSR10 */ - volatile tulip_uint32_t *csr_full_duplex; /* CSR11 */ - volatile tulip_uint32_t *csr_sia_status; /* CSR12 */ - volatile tulip_uint32_t *csr_sia_connectivity; /* CSR13 */ - volatile tulip_uint32_t *csr_sia_tx_rx; /* CSR14 */ - volatile tulip_uint32_t *csr_sia_general; /* CSR15 */ -} tulip_regfile_t; - -/* - * The DC21040 has a stupid restriction in that the receive - * buffers must be longword aligned. But since Ethernet - * headers are not a multiple of longwords in size this forces - * the data to non-longword aligned. Since IP requires the - * data to be longword aligned, we need to copy it after it has - * been DMA'ed in our memory. - * - * Since we have to copy it anyways, we might as well as allocate - * dedicated receive space for the input. This allows to use a - * small receive buffer size and more ring entries to be able to - * better keep with a flood of tiny Ethernet packets. - * - * The receive space MUST ALWAYS be a multiple of the page size. - * And the number of receive descriptors multiplied by the size - * of the receive buffers must equal the recevive space. This - * is so that we can manipulate the page tables so that even if a - * packet wraps around the end of the receive space, we can - * treat it as virtually contiguous. - */ -#define TULIP_RXBUFSIZE 512 -#define TULIP_RXDESCS 128 -#define TULIP_RXSPACE (TULIP_RXBUFSIZE * TULIP_RXDESCS) -#define TULIP_TXDESCS 128 - -typedef struct { - struct arpcom tulip_ac; - tulip_regfile_t tulip_csrs; - vm_offset_t tulip_rxspace; - unsigned tulip_flags; -#define TULIP_WANTSETUP 0x01 -#define TULIP_WANTHASH 0x02 -#define TULIP_DOINGSETUP 0x04 -#define TULIP_ALTPHYS 0x08 /* use AUI */ - unsigned char tulip_rombuf[32]; - tulip_uint32_t tulip_setupbuf[192/sizeof(tulip_uint32_t)]; - tulip_uint32_t tulip_setupdata[192/sizeof(tulip_uint32_t)]; - tulip_uint32_t tulip_intrmask; - tulip_uint32_t tulip_cmdmode; - tulip_uint32_t tulip_revinfo; -#if NBPFILTER > 0 - caddr_t tulip_bpf; /* BPF context */ -#endif - struct ifqueue tulip_txq; - tulip_ringinfo_t tulip_rxinfo; - tulip_ringinfo_t tulip_txinfo; -} tulip_softc_t; - -#ifndef IFF_ALTPHYS -#define IFF_ALTPHYS IFF_LINK0 /* In case it isn't defined */ -#endif -typedef enum { TULIP_DC21040, TULIP_DC21140 } tulip_chipid_t; -const char *tulip_chipdescs[] = { - "DC21040 [10Mb/s]", - "DC21140 [100Mb/s]", -}; - -tulip_softc_t *tulips[NDE]; -tulip_chipid_t tulip_chipids[NDE]; - -#define tulip_if tulip_ac.ac_if -#define tulip_unit tulip_ac.ac_if.if_unit -#define tulip_name tulip_ac.ac_if.if_name -#define tulip_hwaddr tulip_ac.ac_enaddr - -#define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */ -#define TULIP_CHECK_RXCRC 0 -#define TULIP_MAX_TXSEG 30 - -#define TULIP_ADDREQUAL(a1, a2) \ - (((u_short *)a1)[0] == ((u_short *)a2)[0] \ - && ((u_short *)a1)[1] == ((u_short *)a2)[1] \ - && ((u_short *)a1)[2] == ((u_short *)a2)[2]) -#define TULIP_ADDRBRDCST(a1) \ - (((u_short *)a1)[0] == 0xFFFFU \ - && ((u_short *)a1)[1] == 0xFFFFU \ - && ((u_short *)a1)[2] == 0xFFFFU) - -static void tulip_start(struct ifnet *ifp); -static void tulip_addr_filter(tulip_softc_t *sc); - -#if __FreeBSD__ > 1 -#define TULIP_IFRESET_ARGS int unit -#define TULIP_RESET(sc) tulip_reset((sc)->tulip_unit) -#else -#define TULIP_IFRESET_ARGS int unit, int uban -#define TULIP_RESET(sc) tulip_reset((sc)->tulip_unit, 0) -#endif - -static void -tulip_reset( - TULIP_IFRESET_ARGS) -{ - tulip_softc_t *sc = tulips[unit]; - tulip_ringinfo_t *ri; - tulip_desc_t *di; - vm_offset_t vmoff; - - *sc->tulip_csrs.csr_busmode = TULIP_BUSMODE_SWRESET; - DELAY(10); /* Wait 10 microsends (actually 50 PCI cycles but at - 33MHz that comes to two microseconds but wait a - bit longer anyways) */ - - /* - * Use the - */ - *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_RESET; - if (sc->tulip_if.if_flags & IFF_ALTPHYS) { - if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) - printf("%s%d: enabling Thinwire/AUI port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); - *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_AUI; - sc->tulip_flags |= TULIP_ALTPHYS; - } else { - if (sc->tulip_flags & TULIP_ALTPHYS) - printf("%s%d: enabling 10baseT/UTP port\n", - sc->tulip_if.if_name, sc->tulip_if.if_unit); - *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_10BASET; - sc->tulip_flags &= ~TULIP_ALTPHYS; - } - *sc->tulip_csrs.csr_txlist = vtophys(&sc->tulip_txinfo.ri_first[0]); - *sc->tulip_csrs.csr_rxlist = vtophys(&sc->tulip_rxinfo.ri_first[0]); - *sc->tulip_csrs.csr_intr = 0; - *sc->tulip_csrs.csr_busmode = 0x4800; - - sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS; - /* - * Free all the mbufs that were on the transmit ring. - */ - for (;;) { - struct mbuf *m; - IF_DEQUEUE(&sc->tulip_txq, m); - if (m == NULL) - break; - m_freem(m); - } - - ri = &sc->tulip_txinfo; - ri->ri_nextin = ri->ri_nextout = ri->ri_first; - ri->ri_free = ri->ri_max; - for (di = ri->ri_first; di < ri->ri_last; di++) - di->d_status = 0; - - /* - * We need to collect all the mbufs were on the - * receive ring before we reinit it either to put - * them back on or to know if we have to allocate - * more. - */ - ri = &sc->tulip_rxinfo; - ri->ri_nextin = ri->ri_nextout = ri->ri_first; - ri->ri_free = ri->ri_max; - for (vmoff = vtophys(sc->tulip_rxspace), di = ri->ri_first; - di < ri->ri_last; di++, vmoff += TULIP_RXBUFSIZE) { - di->d_status |= TULIP_DSTS_OWNER; - di->d_length1 = TULIP_RXBUFSIZE; di->d_addr1 = vmoff; - di->d_length2 = 0; di->d_addr2 = 0; - } - - sc->tulip_intrmask = TULIP_STS_NORMALINTR|TULIP_STS_RXINTR|TULIP_STS_TXINTR - |TULIP_STS_ABNRMLINTR|TULIP_STS_SYSERROR|TULIP_STS_TXSTOPPED - |TULIP_STS_TXBABBLE|TULIP_STS_LINKFAIL|TULIP_STS_RXSTOPPED; - sc->tulip_flags &= ~(TULIP_DOINGSETUP|TULIP_WANTSETUP); - tulip_addr_filter(sc); -} - -static void -tulip_init( - int unit) -{ - tulip_softc_t *sc = tulips[unit]; - - if (sc->tulip_if.if_flags & IFF_UP) { - sc->tulip_if.if_flags |= IFF_RUNNING; - if (sc->tulip_if.if_flags & IFF_PROMISC) { - sc->tulip_cmdmode |= TULIP_CMD_PROMISCUOUS; - } else { - sc->tulip_cmdmode &= ~TULIP_CMD_PROMISCUOUS; - if (sc->tulip_if.if_flags & IFF_ALLMULTI) { - sc->tulip_cmdmode |= TULIP_CMD_ALLMULTI; - } else { - sc->tulip_cmdmode &= ~TULIP_CMD_ALLMULTI; - } - } - sc->tulip_cmdmode |= TULIP_CMD_TXRUN; - if ((sc->tulip_flags & TULIP_WANTSETUP) == 0) { - sc->tulip_cmdmode |= TULIP_CMD_RXRUN; - sc->tulip_intrmask |= TULIP_STS_RXSTOPPED; - } else { - sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED; - tulip_start(&sc->tulip_if); - } - sc->tulip_cmdmode |= TULIP_CMD_THRSHLD160; - *sc->tulip_csrs.csr_intr = sc->tulip_intrmask; - *sc->tulip_csrs.csr_command = sc->tulip_cmdmode; - } else { - TULIP_RESET(sc); - sc->tulip_if.if_flags &= ~IFF_RUNNING; - } -} - - -#if TULIP_CHECK_RXCRC -static unsigned -tulip_crc32( - u_char *addr, - int len) -{ - unsigned int crc = 0xFFFFFFFF; - static unsigned int crctbl[256]; - int idx; - static int done; - /* - * initialize the multicast address CRC table - */ - for (idx = 0; !done && idx < 256; idx++) { - unsigned int tmp = idx; - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ - crctbl[idx] = tmp; - } - done = 1; - - while (len-- > 0) - crc = (crc >> 8) ^ crctbl[*addr++] ^ crctbl[crc & 0xFF]; - - return crc; -} -#endif - -static void -tulip_rx_intr( - tulip_softc_t *sc) -{ - tulip_ringinfo_t *ri = &sc->tulip_rxinfo; - struct ifnet *ifp = &sc->tulip_if; - - for (;;) { - tulip_desc_t *eop; - int total_len, ndescs; - caddr_t bufaddr = (caddr_t) sc->tulip_rxspace; - - for (ndescs = 1, eop = ri->ri_nextin;; ndescs++) { - if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER) - return; - - if (eop->d_status & TULIP_DSTS_RxLASTDESC) - break; - if (++eop == ri->ri_last) - eop = ri->ri_first; - } - - bufaddr += TULIP_RXBUFSIZE * (ri->ri_nextin - ri->ri_first); - total_len = ((eop->d_status >> 16) & 0x7FF) - 4; - - if ((eop->d_status & TULIP_DSTS_ERRSUM) == 0) { - struct ether_header eh; - struct mbuf *m; - -#if TULIP_CHECK_RXCRC - unsigned crc = tulip_crc32(bufaddr, total_len); - if (~crc != *((unsigned *) &bufaddr[total_len])) { - printf("de0: bad rx crc: %08x [rx] != %08x\n", - *((unsigned *) &bufaddr[total_len]), ~crc); - goto next; - } -#endif - eh = *(struct ether_header *) bufaddr; -#if NBPFILTER > 0 - if (sc->tulip_bpf != NULL) { - bpf_tap(sc->tulip_bpf, bufaddr, total_len); - if ((eh.ether_dhost[0] & 1) == 0 && - !TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_ac.ac_enaddr)) - goto next; - } else if (!TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_ac.ac_enaddr) - && !TULIP_ADDRBRDCST(eh.ether_dhost)) { - goto next; - } -#endif - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m != NULL) { - m->m_pkthdr.rcvif = ifp; - total_len -= sizeof(eh); - if (total_len > MHLEN) { - MCLGET(m, M_DONTWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); - ifp->if_ierrors++; - goto next; - } - } - bcopy(bufaddr + sizeof(eh), mtod(m, caddr_t), total_len); - m->m_len = m->m_pkthdr.len = total_len; - ether_input(ifp, &eh, m); - } else { - ifp->if_ierrors++; - } - } else { - ifp->if_ierrors++; - } -next: - ifp->if_ipackets++; - while (ndescs-- > 0) { - ri->ri_nextin->d_status |= TULIP_DSTS_OWNER; - if (++ri->ri_nextin == ri->ri_last) - ri->ri_nextin = ri->ri_first; - } - } -} - -static int -tulip_tx_intr( - tulip_softc_t *sc) -{ - tulip_ringinfo_t *ri = &sc->tulip_txinfo; - struct mbuf *m; - int xmits = 0; - - while (ri->ri_free < ri->ri_max) { - if (((volatile tulip_desc_t *) ri->ri_nextin)->d_status & TULIP_DSTS_OWNER) - break; - - if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxLASTSEG) { - if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxSETUPPKT) { - /* - * We've just finished processing a setup packet. - * Mark that we can finished it. If there's not - * another pending, startup the TULIP receiver. - * Make sure we ack the RXSTOPPED so we won't get - * an abormal interrupt indication. - */ - sc->tulip_flags &= ~TULIP_DOINGSETUP; - if ((sc->tulip_flags & TULIP_WANTSETUP) == 0) { - sc->tulip_cmdmode |= TULIP_CMD_RXRUN; - sc->tulip_intrmask |= TULIP_STS_RXSTOPPED; - *sc->tulip_csrs.csr_status = TULIP_STS_RXSTOPPED; - *sc->tulip_csrs.csr_command = sc->tulip_cmdmode; - *sc->tulip_csrs.csr_intr = sc->tulip_intrmask; - } - } else { - IF_DEQUEUE(&sc->tulip_txq, m); - m_freem(m); - sc->tulip_if.if_collisions += - (ri->ri_nextin->d_status & TULIP_DSTS_TxCOLLMASK) - >> TULIP_DSTS_V_TxCOLLCNT; - if (ri->ri_nextin->d_status & TULIP_DSTS_ERRSUM) - sc->tulip_if.if_oerrors++; - xmits++; - } - } - - if (++ri->ri_nextin == ri->ri_last) - ri->ri_nextin = ri->ri_first; - ri->ri_free++; - sc->tulip_if.if_flags &= ~IFF_OACTIVE; - } - sc->tulip_if.if_opackets += xmits; - return xmits; -} - -static int -tulip_txsegment( - tulip_softc_t *sc, - struct mbuf *m, - tulip_addrvec_t *avp, - size_t maxseg) -{ - int segcnt; - - for (segcnt = 0; m; m = m->m_next) { - int len = m->m_len; - caddr_t addr = mtod(m, caddr_t); - unsigned clsize = CLBYTES - (((u_long) addr) & (CLBYTES-1)); - - while (len > 0) { - unsigned slen = min(len, clsize); - if (segcnt < maxseg) { - avp->addr = vtophys(addr); - avp->length = slen; - } - len -= slen; - addr += slen; - clsize = CLBYTES; - avp++; - segcnt++; - } - } - if (segcnt >= maxseg) { - printf("%s%d: tulip_txsegment: extremely fragmented packet encountered (%d segments)\n", - sc->tulip_name, sc->tulip_unit, segcnt); - return -1; - } - avp->addr = 0; - avp->length = 0; - return segcnt; -} - -static void -tulip_start( - struct ifnet *ifp) -{ - tulip_softc_t *sc = (tulip_softc_t *) ifp; - struct ifqueue *ifq = &ifp->if_snd; - tulip_ringinfo_t *ri = &sc->tulip_txinfo; - tulip_desc_t *sop, *eop; - struct mbuf *m; - tulip_addrvec_t addrvec[TULIP_MAX_TXSEG+1], *avp; - int segcnt; - tulip_uint32_t d_status; - - if ((ifp->if_flags & IFF_RUNNING) == 0) - return; - - for (;;) { - if (sc->tulip_flags & TULIP_WANTSETUP) { - if ((sc->tulip_flags & TULIP_DOINGSETUP) || ri->ri_free == 1) { - ifp->if_flags |= IFF_OACTIVE; - return; - } - bcopy(sc->tulip_setupdata, sc->tulip_setupbuf, - sizeof(sc->tulip_setupbuf)); - sc->tulip_flags &= ~TULIP_WANTSETUP; - sc->tulip_flags |= TULIP_DOINGSETUP; - ri->ri_free--; - ri->ri_nextout->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN; - ri->ri_nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG|TULIP_DFLAG_TxLASTSEG - |TULIP_DFLAG_TxSETUPPKT|TULIP_DFLAG_TxWANTINTR; - if (sc->tulip_flags & TULIP_WANTHASH) - ri->ri_nextout->d_flag |= TULIP_DFLAG_TxHASHFILT; - ri->ri_nextout->d_length1 = sizeof(sc->tulip_setupbuf); - ri->ri_nextout->d_addr1 = vtophys(sc->tulip_setupbuf); - ri->ri_nextout->d_length2 = 0; - ri->ri_nextout->d_addr2 = 0; - ri->ri_nextout->d_status = TULIP_DSTS_OWNER; - *sc->tulip_csrs.csr_txpoll = 1; - /* - * Advance the ring for the next transmit packet. - */ - if (++ri->ri_nextout == ri->ri_last) - ri->ri_nextout = ri->ri_first; - } - - IF_DEQUEUE(ifq, m); - if (m == NULL) - break; - - /* - * First find out how many and which different pages - * the mbuf data occupies. Then check to see if we - * have enough descriptor space in our transmit ring - * to actually send it. - */ - segcnt = tulip_txsegment(sc, m, addrvec, - min(ri->ri_max - 1, TULIP_MAX_TXSEG)); - if (segcnt < 0) { - struct mbuf *m0; - MGETHDR(m0, M_DONTWAIT, MT_DATA); - if (m0 != NULL) { - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m0, M_DONTWAIT); - if ((m0->m_flags & M_EXT) == 0) { - m_freem(m); - continue; - } - } - m_copydata(m, 0, m0->m_pkthdr.len, mtod(m0, caddr_t)); - m0->m_pkthdr.len = m0->m_len = m->m_pkthdr.len; - m_freem(m); - IF_PREPEND(ifq, m0); - continue; - } else { - m_freem(m); - continue; - } - } - if (ri->ri_free - 2 <= (segcnt + 1) >> 1) - break; - - ri->ri_free -= (segcnt + 1) >> 1; - /* - * Now we fill in our transmit descriptors. This is - * a bit reminiscent of going on the Ark two by two - * since each descriptor for the TULIP can describe - * two buffers. So we advance through the address - * vector two entries at a time to to fill each - * descriptor. Clear the first and last segment bits - * in each descriptor (actually just clear everything - * but the end-of-ring or chain bits) to make sure - * we don't get messed up by previously sent packets. - */ - sop = ri->ri_nextout; - d_status = 0; - avp = addrvec; - do { - eop = ri->ri_nextout; - eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN; - eop->d_status = d_status; - eop->d_addr1 = avp->addr; eop->d_length1 = avp->length; avp++; - eop->d_addr2 = avp->addr; eop->d_length2 = avp->length; avp++; - d_status = TULIP_DSTS_OWNER; - if (++ri->ri_nextout == ri->ri_last) - ri->ri_nextout = ri->ri_first; - } while ((segcnt -= 2) > 0); -#if NBPFILTER > 0 - if (sc->tulip_bpf != NULL) - bpf_mtap(sc->tulip_bpf, m); -#endif - /* - * The descriptors have been filled in. Mark the first - * and last segments, indicate we want a transmit complete - * interrupt, give the descriptors to the TULIP, and tell - * it to transmit! - */ - - IF_ENQUEUE(&sc->tulip_txq, m); - eop->d_flag |= TULIP_DFLAG_TxLASTSEG|TULIP_DFLAG_TxWANTINTR; - sop->d_flag |= TULIP_DFLAG_TxFIRSTSEG; - sop->d_status = TULIP_DSTS_OWNER; - - *sc->tulip_csrs.csr_txpoll = 1; - } - if (m != NULL) { - ifp->if_flags |= IFF_OACTIVE; - IF_PREPEND(ifq, m); - } -} - -static int -tulip_intr( - tulip_softc_t *sc) -{ - tulip_uint32_t csr; - - while ((csr = *sc->tulip_csrs.csr_status) & (TULIP_STS_NORMALINTR|TULIP_STS_ABNRMLINTR)) { - *sc->tulip_csrs.csr_status = csr & sc->tulip_intrmask; - - if (csr & TULIP_STS_SYSERROR) { - if ((csr & TULIP_STS_ERRORMASK) == TULIP_STS_ERR_PARITY) { - TULIP_RESET(sc); - tulip_init(sc->tulip_unit); - return 1; - } - } - if (csr & TULIP_STS_ABNRMLINTR) { - printf("%s%d: abnormal interrupt: 0x%05x [0x%05x]\n", - sc->tulip_name, sc->tulip_unit, csr, csr & sc->tulip_intrmask); - *sc->tulip_csrs.csr_command = sc->tulip_cmdmode; - } - if (csr & TULIP_STS_RXINTR) - tulip_rx_intr(sc); - if (sc->tulip_txinfo.ri_free < sc->tulip_txinfo.ri_max) { - tulip_tx_intr(sc); - tulip_start(&sc->tulip_if); - } - } - return 1; -} - -/* - * This is the standard method of reading the DEC Address ROMS. - */ -static int -tulip_read_macaddr( - tulip_softc_t *sc) -{ - int cksum, rom_cksum, idx; - tulip_sint32_t csr; - unsigned char tmpbuf[8]; - static u_char testpat[] = { 0xFF, 0, 0x55, 0xAA, 0xFF, 0, 0x55, 0xAA }; - - *sc->tulip_csrs.csr_enetrom = 1; - for (idx = 0; idx < 32; idx++) { - int cnt = 0; - while ((csr = *sc->tulip_csrs.csr_enetrom) < 0 && cnt < 10000) - cnt++; - sc->tulip_rombuf[idx] = csr & 0xFF; - } - - if (bcmp(&sc->tulip_rombuf[0], &sc->tulip_rombuf[16], 8) != 0) { - /* - * Some folks don't use the standard ethernet rom format - * but instead just put the address in the first 6 bytes - * of the rom and let the rest be all 0xffs. (Can we say - * ZNYX???) - */ - for (idx = 6; idx < 32; idx++) { - if (sc->tulip_rombuf[idx] != 0xFF) - return -4; - } - /* - * Make sure the address is not multicast or locally assigned - * that the OUI is not 00-00-00. - */ - if ((sc->tulip_rombuf[0] & 3) != 0) - return -4; - if (sc->tulip_rombuf[0] == 0 && sc->tulip_rombuf[1] == 0 - && sc->tulip_rombuf[2] == 0) - return -4; - bcopy(sc->tulip_rombuf, sc->tulip_hwaddr, 6); - return 0; - } - if (bcmp(&sc->tulip_rombuf[24], testpat, 8) != 0) - return -3; - - tmpbuf[0] = sc->tulip_rombuf[15]; tmpbuf[1] = sc->tulip_rombuf[14]; - tmpbuf[2] = sc->tulip_rombuf[13]; tmpbuf[3] = sc->tulip_rombuf[12]; - tmpbuf[4] = sc->tulip_rombuf[11]; tmpbuf[5] = sc->tulip_rombuf[10]; - tmpbuf[6] = sc->tulip_rombuf[9]; tmpbuf[7] = sc->tulip_rombuf[8]; - if (bcmp(&sc->tulip_rombuf[0], tmpbuf, 8) != 0) - return -2; - - bcopy(sc->tulip_rombuf, sc->tulip_hwaddr, 6); - - cksum = *(u_short *) &sc->tulip_hwaddr[0]; - cksum *= 2; - if (cksum > 65535) cksum -= 65535; - cksum += *(u_short *) &sc->tulip_hwaddr[2]; - if (cksum > 65535) cksum -= 65535; - cksum *= 2; - if (cksum > 65535) cksum -= 65535; - cksum += *(u_short *) &sc->tulip_hwaddr[4]; - if (cksum >= 65535) cksum -= 65535; - - rom_cksum = *(u_short *) &sc->tulip_rombuf[6]; - - if (cksum != rom_cksum) - return -1; - return 0; -} - -static unsigned -tulip_mchash( - unsigned char *mca) -{ - u_int idx, bit, data, crc = 0xFFFFFFFFUL; - -#ifdef __alpha - for (data = *(__unaligned u_long *) mca, bit = 0; bit < 48; bit++, data >>= -1) - crc = (crc >> 1) ^ (((crc ^ data) & 1) ? TULIP_CRC32_POLY : 0); -#else - for (idx = 0; idx < 6; idx++) - for (data = *mca++, bit = 0; bit < 8; bit++, data >>= 1) - crc = (crc >> 1) ^ (((crc ^ data) & 1) ? TULIP_CRC32_POLY : 0); -#endif - return crc & 0x1FF; -} - -static void -tulip_addr_filter( - tulip_softc_t *sc) -{ - tulip_uint32_t *sp = sc->tulip_setupdata; - struct ether_multistep step; - struct ether_multi *enm; - int i; - - sc->tulip_flags &= ~TULIP_WANTHASH; - sc->tulip_flags |= TULIP_WANTSETUP; - sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN; - sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED; - if (sc->tulip_ac.ac_multicnt > 14) { - unsigned hash; - /* - * If we have more than 14 multicasts, we have - * go into hash perfect mode (512 bit multicast - * hash and one perfect hardware). - */ - - bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata)); - hash = tulip_mchash(etherbroadcastaddr); - sp[hash >> 4] |= 1 << (hash & 0xF); - ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); - while (enm != NULL) { - hash = tulip_mchash(enm->enm_addrlo); - sp[hash >> 4] |= 1 << (hash & 0xF); - ETHER_NEXT_MULTI(step, enm); - } - sc->tulip_cmdmode |= TULIP_WANTHASH; - sp[40] = ((u_short *) sc->tulip_ac.ac_enaddr)[0]; - sp[41] = ((u_short *) sc->tulip_ac.ac_enaddr)[1]; - sp[42] = ((u_short *) sc->tulip_ac.ac_enaddr)[2]; - } else { - /* - * Else can get perfect filtering for 16 addresses. - */ - i = 0; - ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); - for (; enm != NULL; i++) { - *sp++ = ((u_short *) enm->enm_addrlo)[0]; - *sp++ = ((u_short *) enm->enm_addrlo)[1]; - *sp++ = ((u_short *) enm->enm_addrlo)[2]; - ETHER_NEXT_MULTI(step, enm); - } - /* - * If an IP address is enabled, turn on broadcast - */ - if (sc->tulip_ac.ac_ipaddr.s_addr != 0) { - i++; - *sp++ = 0xFFFF; - *sp++ = 0xFFFF; - *sp++ = 0xFFFF; - } - /* - * Pad the rest with our hardware address - */ - for (; i < 16; i++) { - *sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[0]; - *sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[1]; - *sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[2]; - } - } -} - -static int -tulip_ioctl( - struct ifnet *ifp, - int cmd, - caddr_t data) -{ - tulip_softc_t *sc = tulips[ifp->if_unit]; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *) data; - int s, error = 0; - - s = splimp(); - - switch (cmd) { - case SIOCSIFADDR: { - - ifp->if_flags |= IFF_UP; - switch(ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: { - ((struct arpcom *)ifp)->ac_ipaddr = IA_SIN(ifa)->sin_addr; - tulip_addr_filter(sc); /* reset multicast filtering */ - (*ifp->if_init)(ifp->if_unit); - arp_ifinit((struct arpcom *)ifp, ifa); - break; - } -#endif /* INET */ - -#ifdef NS - /* This magic copied from if_is.c; I don't use XNS, - * so I have no way of telling if this actually - * works or not. - */ - case AF_NS: { - struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - if (ns_nullhost(*ina)) { - ina->x_host = *(union ns_host *)(sc->tulip_ac.ac_enaddr); - } else { - ifp->if_flags &= ~IFF_RUNNING; - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)sc->tulip_ac.ac_enaddr, - sizeof sc->tulip_ac.ac_enaddr); - } - - (*ifp->if_init)(ifp->if_unit); - break; - } -#endif /* NS */ - - default: { - (*ifp->if_init)(ifp->if_unit); - break; - } - } - break; - } - - case SIOCSIFFLAGS: { - /* - * Changing the connection forces a reset. - */ - if (sc->tulip_flags & TULIP_ALTPHYS) { - if ((ifp->if_flags & IFF_ALTPHYS) == 0) - TULIP_RESET(sc); - } else { - if (ifp->if_flags & IFF_ALTPHYS) - TULIP_RESET(sc); - } - (*ifp->if_init)(ifp->if_unit); - break; - } - - case SIOCADDMULTI: - case SIOCDELMULTI: { - /* - * Update multicast listeners - */ - if (cmd == SIOCADDMULTI) - error = ether_addmulti(ifr, &sc->tulip_ac); - else - error = ether_delmulti(ifr, &sc->tulip_ac); - - if (error == ENETRESET) { - tulip_addr_filter(sc); /* reset multicast filtering */ - (*ifp->if_init)(ifp->if_unit); - error = 0; - } - break; - } - case SIOCSIFMTU: - /* - * Set the interface MTU. - */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; - - default: { - error = EINVAL; - break; - } - } - - splx(s); - return error; -} - -static void -tulip_attach( - tulip_softc_t *sc) -{ - struct ifnet *ifp = &sc->tulip_if; - int cnt; - - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - - *sc->tulip_csrs.csr_sia_connectivity = 0; - *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_10BASET; - for (cnt = 0; cnt < 240000; cnt++) { - if ((*sc->tulip_csrs.csr_sia_status & TULIP_SIASTS_LINKFAIL) == 0) - break; - DELAY(10); - } - if (*sc->tulip_csrs.csr_sia_status & TULIP_SIASTS_LINKFAIL) { - ifp->if_flags |= IFF_ALTPHYS; - } else { - sc->tulip_flags |= TULIP_ALTPHYS; - } - TULIP_RESET(sc); - - ifp->if_init = tulip_init; - ifp->if_ioctl = tulip_ioctl; - ifp->if_output = ether_output; - ifp->if_reset = tulip_reset; - ifp->if_start = tulip_start; - - printf("%s%d: %s pass %d.%d ethernet address %s\n", - sc->tulip_name, sc->tulip_unit, - tulip_chipdescs[tulip_chipids[sc->tulip_unit]], - (sc->tulip_revinfo & 0xF0) >> 4, - sc->tulip_revinfo & 0x0F, - ether_sprintf(sc->tulip_hwaddr)); - - if_attach(ifp); - -#if NBPFILTER > 0 - bpfattach(&sc->tulip_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif -} - -static void -tulip_initcsrs( - tulip_softc_t *sc, - volatile tulip_uint32_t *va_csrs, - size_t csr_size) -{ - sc->tulip_csrs.csr_busmode = va_csrs + 0 * csr_size; - sc->tulip_csrs.csr_txpoll = va_csrs + 1 * csr_size; - sc->tulip_csrs.csr_rxpoll = va_csrs + 2 * csr_size; - sc->tulip_csrs.csr_rxlist = va_csrs + 3 * csr_size; - sc->tulip_csrs.csr_txlist = va_csrs + 4 * csr_size; - sc->tulip_csrs.csr_status = va_csrs + 5 * csr_size; - sc->tulip_csrs.csr_command = va_csrs + 6 * csr_size; - sc->tulip_csrs.csr_intr = va_csrs + 7 * csr_size; - sc->tulip_csrs.csr_missed_frame = va_csrs + 8 * csr_size; - sc->tulip_csrs.csr_enetrom = va_csrs + 9 * csr_size; - sc->tulip_csrs.csr_reserved = va_csrs + 10 * csr_size; - sc->tulip_csrs.csr_full_duplex = va_csrs + 11 * csr_size; - sc->tulip_csrs.csr_sia_status = va_csrs + 12 * csr_size; - sc->tulip_csrs.csr_sia_connectivity = va_csrs + 13 * csr_size; - sc->tulip_csrs.csr_sia_tx_rx = va_csrs + 14 * csr_size; - sc->tulip_csrs.csr_sia_general = va_csrs + 15 * csr_size; -} - -static void -tulip_initring( - tulip_softc_t *sc, - tulip_ringinfo_t *ri, - tulip_desc_t *descs, - int ndescs) -{ - ri->ri_max = ndescs; - ri->ri_first = descs; - ri->ri_last = ri->ri_first + ri->ri_max; - bzero((caddr_t) ri->ri_first, sizeof(ri->ri_first[0]) * ri->ri_max); - ri->ri_last[-1].d_flag = TULIP_DFLAG_ENDRING; -} - -#if NPCI > 0 -/* - * This is the PCI configuration support. Since the DC21040 is available - * on both EISA and PCI boards, one must be careful in how defines the - * DC21040 in the config file. - */ -static char* tulip_pci_probe (pcici_t config_id, pcidi_t device_id); -static void tulip_pci_attach(pcici_t config_id, int unit); -static u_long tulip_count; - -struct pci_driver dedevice = { - tulip_pci_probe, - tulip_pci_attach, - &tulip_count, -}; - -#define PCI_CFID 0x00 /* Configuration ID */ -#define PCI_CFCS 0x04 /* Configurtion Command/Status */ -#define PCI_CFRV 0x08 /* Configuration Revision */ -#define PCI_CFLT 0x0c /* Configuration Latency Timer */ -#define PCI_CBIO 0x10 /* Configuration Base IO Address */ -#define PCI_CBMA 0x14 /* Configuration Base Memory Address */ -#define PCI_CFIT 0x3c /* Configuration Interrupt */ -#define PCI_CFDA 0x40 /* Configuration Driver Area */ - -#define TULIP_PCI_CSRSIZE (8 / sizeof(tulip_uint32_t)) -static char* -tulip_pci_probe( - pcici_t config_id, - pcidi_t device_id) -{ - int idx; - for (idx = 0; idx < NDE; idx++) { - if (tulips[idx] == NULL) { - if (device_id == 0x00021011ul) { - tulip_chipids[idx] = TULIP_DC21040; - return "Digital DC21040 Ethernet"; - } - if (device_id == 0x00091011ul) { - tulip_chipids[idx] = TULIP_DC21140; - return "Digital DC21140 Fast Ethernet"; - } - return NULL; - } - } - return NULL; -} - -static void -tulip_pci_attach( - pcici_t config_id, - int unit) -{ - tulip_softc_t *sc; - int retval, idx; - vm_offset_t va_csrs, pa_csrs; - tulip_desc_t *rxdescs, *txdescs; - - sc = (tulip_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); - if (sc == NULL) - return; - - rxdescs = (tulip_desc_t *) - malloc(sizeof(tulip_desc_t) * TULIP_RXDESCS, M_DEVBUF, M_NOWAIT); - if (rxdescs == NULL) { - free((caddr_t) sc, M_DEVBUF); - return; - } - - txdescs = (tulip_desc_t *) - malloc(sizeof(tulip_desc_t) * TULIP_TXDESCS, M_DEVBUF, M_NOWAIT); - if (txdescs == NULL) { - free((caddr_t) rxdescs, M_DEVBUF); - free((caddr_t) sc, M_DEVBUF); - return; - } - - bzero(sc, sizeof(*sc)); /* Zero out the softc*/ - sc->tulip_rxspace = vm_page_alloc_contig(TULIP_RXSPACE + NBPG, 0, 0xffffffff, PAGE_SIZE); - /* - * We've allocated an extra page of receive space so we can double map - * the first page of the receive space into the page after the last page - * of the receive space. This means that even if a receive wraps around - * the end of the receive space, it will still virtually contiguous and - * that greatly simplifies the recevie logic. - */ - pmap_enter(pmap_kernel(), sc->tulip_rxspace + TULIP_RXSPACE, - vtophys(sc->tulip_rxspace), VM_PROT_READ|VM_PROT_WRITE, TRUE); - - sc->tulip_unit = unit; - sc->tulip_name = "de"; - retval = pci_map_mem(config_id, PCI_CBMA, &va_csrs, &pa_csrs); - if (!retval) { - kmem_free(kernel_map, sc->tulip_rxspace, TULIP_RXSPACE + NBPG); - free((caddr_t) txdescs, M_DEVBUF); - free((caddr_t) rxdescs, M_DEVBUF); - free((caddr_t) sc, M_DEVBUF); - return; - } - tulips[unit] = sc; - tulip_initcsrs(sc, (volatile tulip_uint32_t *) va_csrs, TULIP_PCI_CSRSIZE); - tulip_initring(sc, &sc->tulip_rxinfo, rxdescs, TULIP_RXDESCS); - tulip_initring(sc, &sc->tulip_txinfo, txdescs, TULIP_TXDESCS); - sc->tulip_revinfo = pci_conf_read(config_id, PCI_CFRV); - if ((retval = tulip_read_macaddr(sc)) < 0) { - printf("de%d: can't read ENET ROM (why=%d) (", sc->tulip_unit, retval); - for (idx = 0; idx < 32; idx++) - printf("%02x", sc->tulip_rombuf[idx]); - printf("\n"); - printf("%s%d: %s pass %d.%d ethernet address %s\n", - sc->tulip_name, sc->tulip_unit, - tulip_chipdescs[tulip_chipids[sc->tulip_unit]], - (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F, - "unknown"); - } else { - TULIP_RESET(sc); - tulip_attach(sc); - pci_map_int (config_id, tulip_intr, (void*) sc, &net_imask); - } -} -#endif /* NPCI > 0 */ -#endif /* NDE > 0 */ diff --git a/sys/i386/pci/ncr.c b/sys/i386/pci/ncr.c deleted file mode 100644 index 8a10ddd..0000000 --- a/sys/i386/pci/ncr.c +++ /dev/null @@ -1,6505 +0,0 @@ -/************************************************************************** -** -** $Id: ncr.c,v 1.13 1994/11/28 23:18:46 se Exp $ -** -** Device driver for the NCR 53C810 PCI-SCSI-Controller. -** -** 386bsd / FreeBSD / NetBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** Wolfgang Stanglmeier <wolf@dentaro.gun.de> -** Stefan Esser <se@mi.Uni-Koeln.de> -** -** Ported to NetBSD by -** Charles M. Hannum <mycroft@gnu.ai.mit.edu> -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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. -** -*************************************************************************** -*/ - -#define NCR_VERSION (2) -#define MAX_UNITS (16) - - -/*========================================================== -** -** Configuration and Debugging -** -** May be overwritten in <i386/conf/XXXXX> -** -**========================================================== -*/ - -/* -** SCSI address of this device. -** The boot routines should have set it. -** If not, use this. -*/ - -#ifndef SCSI_NCR_MYADDR -#define SCSI_NCR_MYADDR (7) -#endif /* SCSI_NCR_MYADDR */ - -/* -** The maximal synchronous frequency in kHz. -** (0=asynchronous) -*/ - -#ifndef SCSI_NCR_MAX_SYNC -#define SCSI_NCR_MAX_SYNC (10000) -#endif /* SCSI_NCR_MAX_SYNC */ - -/* -** The maximal bus with (in log2 byte) -** (0=8 bit, 1=16 bit) -*/ - -#ifndef SCSI_NCR_MAX_WIDE -#define SCSI_NCR_MAX_WIDE (1) -#endif /* SCSI_NCR_MAX_WIDE */ - -/* -** The maximum number of tags per logic unit. -** Used only for disk devices that support tags. -*/ - -#ifndef SCSI_NCR_MAX_TAGS -#define SCSI_NCR_MAX_TAGS (4) -#endif /* SCSI_NCR_MAX_TAGS */ - -/*========================================================== -** -** Configuration and Debugging -** -**========================================================== -*/ - -/* -** Number of targets supported by the driver. -** n permits target numbers 0..n-1. -** Default is 7, meaning targets #0..#6. -** #7 .. is myself. -*/ - -#define MAX_TARGET (7) - -/* -** Number of logic units supported by the driver. -** n enables logic unit numbers 0..n-1. -** The common SCSI devices require only -** one lun, so take 1 as the default. -*/ - -#define MAX_LUN (1) - -/* -** The maximum number of jobs scheduled for starting. -** There should be one slot per target, and one slot -** for each tag of each target. -*/ - -#define MAX_START (7 * SCSI_NCR_MAX_TAGS) - -/* -** The maximum number of segments a transfer is split into. -*/ - -#define MAX_SCATTER (33) - -/* -** The maximum transfer length (should be >= 64k). -** MUST NOT be greater than (MAX_SCATTER-1) * NBPG. -*/ - -#define MAX_SIZE ((MAX_SCATTER-1) * NBPG) - -/* -** Write disk status information to dkstat ? -*/ - -/* #define DK */ - -/*========================================================== -** -** Include files -** -**========================================================== -*/ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/time.h> -#include <sys/proc.h> - -#ifdef KERNEL -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/kernel.h> -#ifdef DK -#include <sys/dkstat.h> -#endif /* DK */ -#include <vm/vm.h> -#endif /* KERNEL */ - -#include <i386/pci/ncrreg.h> - -#ifdef __NetBSD__ -#include <sys/device.h> -#include <i386/pci/pcivar.h> -#endif /* __NetBSD */ -#include <i386/pci/pcireg.h> - -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> - - -/*========================================================== -** -** Debugging tags -** -**========================================================== -*/ - -#define DEBUG_ALLOC (0x0001) -#define DEBUG_PHASE (0x0002) -#define DEBUG_POLL (0x0004) -#define DEBUG_QUEUE (0x0008) -#define DEBUG_RESULT (0x0010) -#define DEBUG_SCATTER (0x0020) -#define DEBUG_SCRIPT (0x0040) -#define DEBUG_TINY (0x0080) -#define DEBUG_TIMING (0x0100) -#define DEBUG_NEGO (0x0200) -#define DEBUG_TAGS (0x0400) -#define DEBUG_FREEZE (0x0800) -#define DEBUG_RESTART (0x1000) - -/* -** Enable/Disable debug messages. -** Can be changed at runtime too. -*/ - -#ifdef SCSI_DEBUG_FLAGS - #define DEBUG_FLAGS ncr_debug; -#else /* SCSI_DEBUG_FLAGS */ - #define SCSI_DEBUG_FLAGS 0 - #define DEBUG_FLAGS 0 -#endif /* SCSI_DEBUG_FLAGS */ - - - -/*========================================================== -** -** assert () -** -**========================================================== -** -** modified copy from 386bsd:/usr/include/sys/assert.h -** -**---------------------------------------------------------- -*/ - -#define assert(expression) { \ - if (!(expression)) { \ - (void)printf(\ - "assertion \"%s\" failed: file \"%s\", line %d\n", \ - #expression, \ - __FILE__, __LINE__); \ - } \ -} - -/*========================================================== -** -** Access to the controller chip. -** -**========================================================== -*/ - -#define INB(r) (np->reg->r) -#define INW(r) (np->reg->r) -#define INL(r) (np->reg->r) - -#define OUTB(r, val) np->reg->r = val -#define OUTW(r, val) np->reg->r = val -#define OUTL(r, val) np->reg->r = val - -/*========================================================== -** -** Command control block states. -** -**========================================================== -*/ - -#define HS_IDLE (0) -#define HS_BUSY (1) -#define HS_NEGOTIATE (2) /* sync/wide data transfer*/ -#define HS_DISCONNECT (3) /* Disconnected by target */ - -#define HS_COMPLETE (4) -#define HS_SEL_TIMEOUT (5) /* Selection timeout */ -#define HS_RESET (6) /* SCSI reset */ -#define HS_ABORTED (7) /* Transfer aborted */ -#define HS_TIMEOUT (8) /* Software timeout */ -#define HS_FAIL (9) /* SCSI or PCI bus errors */ -#define HS_UNEXPECTED (10) /* Unexpected disconnect */ - -#define HS_DONEMASK (0xfc) - -/*========================================================== -** -** Software Interrupt Codes -** -**========================================================== -*/ - -#define SIR_SENSE_RESTART (1) -#define SIR_SENSE_FAILED (2) -#define SIR_STALL_RESTART (3) -#define SIR_STALL_QUEUE (4) -#define SIR_NEGO_SYNC (5) -#define SIR_NEGO_WIDE (6) -#define SIR_NEGO_FAILED (7) -#define SIR_NEGO_PROTO (8) -#define SIR_REJECT_RECEIVED (9) -#define SIR_REJECT_SENT (10) -#define SIR_IGN_RESIDUE (11) -#define SIR_MISSING_SAVE (12) -#define SIR_MAX (12) - -/*========================================================== -** -** Extended error codes. -** xerr_status field of struct ccb. -** -**========================================================== -*/ - -#define XE_OK (0) -#define XE_EXTRA_DATA (1) /* unexpected data phase */ -#define XE_BAD_PHASE (2) /* illegal phase (4/5) */ - -/*========================================================== -** -** Negotiation status. -** nego_status field of struct ccb. -** -**========================================================== -*/ - -#define NS_SYNC (1) -#define NS_WIDE (2) - -/*========================================================== -** -** "Special features" of targets. -** quirks field of struct tcb. -** actualquirks field of struct ccb. -** -**========================================================== -*/ - -#define QUIRK_AUTOSAVE (0x01) -#define QUIRK_NOMSG (0x02) -#define QUIRK_UPDATE (0x80) - -/*========================================================== -** -** Capability bits in Inquire response byte 7. -** -**========================================================== -*/ - -#define INQ7_QUEUE (0x02) -#define INQ7_SYNC (0x10) -#define INQ7_WIDE16 (0x20) - -/*========================================================== -** -** Misc. -** -**========================================================== -*/ - -#define CCB_MAGIC (0xf2691ad2) -#define MAX_TAGS (16) /* hard limit */ - -/*========================================================== -** -** OS dependencies. -** -**========================================================== -*/ - -#ifndef __FreeBSD__ -#ifndef __NetBSD__ - #define ANCIENT -#endif /*__NetBSD__*/ -#endif /*__FreeBSD__*/ - -#ifdef ANCIENT -#ifdef KERNEL - extern int splbio(void); - extern void splx(int level); - extern int wakeup(void* channel); - extern int tsleep(); - extern int DELAY(); - extern int scsi_attachdevs(); - extern void timeout(); - extern void untimeout(); -#endif /* KERNEL */ - #define bio_imask biomask - #define LUN lu - #define TARGET targ - #define PRINT_ADDR(xp) printf ("ncr0: targ %d lun %d ",xp->targ,xp->lu) - #define INT32 int - #define U_INT32 long - #define TIMEOUT -#else /* !ANCIENT */ - #define LUN sc_link->lun - #define TARGET sc_link->target - #define PRINT_ADDR(xp) sc_print_addr(xp->sc_link) -#ifdef __NetBSD__ - #define INT32 int - #define U_INT32 u_int - #define TIMEOUT (void*) -#else /*__NetBSD__*/ - #define INT32 int32 - #define U_INT32 u_int32 - #define TIMEOUT (timeout_func_t) -#endif /*__NetBSD__*/ -#endif /* ANCIENT */ - -/*========================================================== -** -** Declaration of structs. -** -**========================================================== -*/ - -struct tcb; -struct lcb; -struct ccb; -struct ncb; -struct script; - -typedef struct ncb * ncb_p; -typedef struct tcb * tcb_p; -typedef struct lcb * lcb_p; -typedef struct ccb * ccb_p; - -struct link { - u_long l_cmd; - u_long l_paddr; -}; - -struct usrcmd { - u_long target; - u_long lun; - u_long data; - u_long cmd; -}; - -#define UC_SETSYNC 10 -#define UC_SETTAGS 11 -#define UC_SETDEBUG 12 -#define UC_SETORDER 13 -#define UC_SETWIDE 14 -#define UC_SETFLAG 15 - -#define UF_TRACE (0x01) - - -/*========================================================== -** -** Access to fields of structs. -** -**========================================================== -*/ - -#define offsetof(type, member) ((size_t)(&((type *)0)->member)) - -/*--------------------------------------- -** -** Timestamps for profiling -** -**--------------------------------------- -*/ - -struct tstamp { - struct timeval start; - struct timeval end; - struct timeval select; - struct timeval command; - struct timeval data; - struct timeval status; - struct timeval disconnect; - struct timeval reselect; -}; - -/* -** profiling data (per device) -*/ - -struct profile { - u_long num_trans; - u_long num_bytes; - u_long num_disc; - u_long num_break; - u_long num_int; - u_long num_fly; - u_long ms_setup; - u_long ms_data; - u_long ms_disc; - u_long ms_post; -}; - -/*========================================================== -** -** Declaration of structs: TARGET control block -** -**========================================================== -*/ - -struct tcb { - /* - ** during reselection the ncr jumps to this point - ** with SFBR set to the encoded TARGET number - ** with bit 7 set. - ** if it's not this target, jump to the next. - ** - ** JUMP IF (SFBR != #TARGET#) - ** @(next tcb) - */ - - struct link jump_tcb; - - /* - ** load the actual values for the sxfer and the scntl3 - ** register (sync/wide mode). - ** - ** SCR_COPY (1); - ** @(sval field of this tcb) - ** @(sxfer register) - ** SCR_COPY (1); - ** @(wval field of this tcb) - ** @(scntl3 register) - */ - - ncrcmd getscr[6]; - - /* - ** if next message is "identify" - ** then load the message to SFBR, - ** else load 0 to SFBR. - ** - ** CALL - ** <RESEL_LUN> - */ - - struct link call_lun; - - /* - ** now look for the right lun. - ** - ** JUMP - ** @(first ccb of this lun) - */ - - struct link jump_lcb; - - /* - ** pointer to interrupted getcc ccb - */ - - ccb_p hold_cp; - - /* - ** statistical data - */ - - u_long transfers; - u_long bytes; - - /* - ** user settable limits for sync transfer - ** and tagged commands. - */ - - u_char usrsync; - u_char usrtags; - u_char usrwide; - u_char usrflag; - - /* - ** negotiation of wide and synch transfer. - ** device quirks. - */ - -/*0*/ u_char minsync; -/*1*/ u_char sval; -/*2*/ u_short period; -/*0*/ u_char maxoffs; - -/*1*/ u_char quirks; - -/*2*/ u_char widedone; -/*3*/ u_char wval; - /* - ** inquire data - */ -#define MAX_INQUIRE 36 - u_char inqdata[MAX_INQUIRE]; - - /* - ** the lcb's of this tcb - */ - - lcb_p lp[MAX_LUN]; -}; - -/*========================================================== -** -** Declaration of structs: LUN control block -** -**========================================================== -*/ - -struct lcb { - /* - ** during reselection the ncr jumps to this point - ** with SFBR set to the "Identify" message. - ** if it's not this lun, jump to the next. - ** - ** JUMP IF (SFBR == #LUN#) - ** @(next lcb of this target) - */ - - struct link jump_lcb; - - /* - ** if next message is "simple tag", - ** then load the tag to SFBR, - ** else load 0 to SFBR. - ** - ** CALL - ** <RESEL_TAG> - */ - - struct link call_tag; - - /* - ** now look for the right ccb. - ** - ** JUMP - ** @(first ccb of this lun) - */ - - struct link jump_ccb; - - /* - ** start of the ccb chain - */ - - ccb_p next_ccb; - - /* - ** Control of tagged queueing - */ - - u_char reqccbs; - u_char actccbs; - u_char reqlink; - u_char actlink; - u_char usetags; - u_char lasttag; -}; - -/*========================================================== -** -** Declaration of structs: COMMAND control block -** -**========================================================== -** -** This substructure is copied from the ccb to a -** global address after selection (or reselection) -** and copied back before disconnect. -** -** These fields are accessible to the script processor. -** -**---------------------------------------------------------- -*/ - -struct head { - /* - ** Execution of a ccb starts at this point. - ** It's a jump to the "SELECT" label - ** of the script. - ** - ** After successful selection the script - ** processor overwrites it with a jump to - ** the IDLE label of the script. - */ - - struct link launch; - - /* - ** Saved data pointer. - ** Points to the position in the script - ** responsible for the actual transfer - ** of data. - ** It's written after reception of a - ** "SAVE_DATA_POINTER" message. - ** The goalpointer points after - ** the last transfer command. - */ - - u_long savep; - u_long lastp; - u_long goalp; - - /* - ** The virtual address of the ccb - ** containing this header. - */ - - ccb_p cp; - - /* - ** space for some timestamps to gather - ** profiling data about devices and this driver. - */ - - struct tstamp stamp; - - /* - ** status fields. - */ - - u_char status[8]; -}; - -/* -** The status bytes are used by the host and the script processor. -** -** The first four byte are copied to the scratchb register -** (declared as scr0..scr3 in ncr_reg.h) just after the select/reselect, -** and copied back just after disconnecting. -** Inside the script the XX_REG are used. -** -** The last four bytes are used inside the script by "COPY" commands. -** Because source and destination must have the same alignment -** in a longword, the fields HAVE to be on the selected offsets. -** xerr_st (4) 0 (0x34) scratcha -** sync_st (5) 1 (0x05) sxfer -** wide_st (7) 3 (0x03) scntl3 -*/ - -/* -** First four bytes (script) -*/ -#define QU_REG scr0 -#define HS_REG scr1 -#define HS_PRT nc_scr1 -#define SS_REG scr2 -#define PS_REG scr3 - -/* -** First four bytes (host) -*/ -#define actualquirks phys.header.status[0] -#define host_status phys.header.status[1] -#define scsi_status phys.header.status[2] -#define parity_status phys.header.status[3] - -/* -** Last four bytes (script) -*/ -#define xerr_st header.status[4] /* MUST be ==0 mod 4 */ -#define sync_st header.status[5] /* MUST be ==1 mod 4 */ -#define nego_st header.status[6] -#define wide_st header.status[7] /* MUST be ==3 mod 4 */ - -/* -** Last four bytes (host) -*/ -#define xerr_status phys.xerr_st -#define sync_status phys.sync_st -#define nego_status phys.nego_st -#define wide_status phys.wide_st - -/*========================================================== -** -** Declaration of structs: Data structure block -** -**========================================================== -** -** During execution of a ccb by the script processor, -** the DSA (data structure address) register points -** to this substructure of the ccb. -** This substructure contains the header with -** the script-processor-changable data and -** data blocks for the indirect move commands. -** -**---------------------------------------------------------- -*/ - -struct dsb { - - /* - ** Header. - ** Has to be the first entry, - ** because it's jumped to by the - ** script processor - */ - - struct head header; - - /* - ** Table data for Script - */ - - struct scr_tblsel select; - struct scr_tblmove smsg ; - struct scr_tblmove smsg2 ; - struct scr_tblmove cmd ; - struct scr_tblmove sense ; - struct scr_tblmove data [MAX_SCATTER]; -}; - -/*========================================================== -** -** Declaration of structs: Command control block. -** -**========================================================== -** -** During execution of a ccb by the script processor, -** the DSA (data structure address) register points -** to this substructure of the ccb. -** This substructure contains the header with -** the script-processor-changable data and then -** data blocks for the indirect move commands. -** -**---------------------------------------------------------- -*/ - - -struct ccb { - /* - ** during reselection the ncr jumps to this point. - ** If a "SIMPLE_TAG" message was received, - ** then SFBR is set to the tag. - ** else SFBR is set to 0 - ** If looking for another tag, jump to the next ccb. - ** - ** JUMP IF (SFBR != #TAG#) - ** @(next ccb of this lun) - */ - - struct link jump_ccb; - - /* - ** After execution of this call, the return address - ** (in the TEMP register) points to the following - ** data structure block. - ** So copy it to the DSA register, and start - ** processing of this data structure. - ** - ** CALL - ** <RESEL_TMP> - */ - - struct link call_tmp; - - /* - ** This is the data structure which is - ** to be executed by the script processor. - */ - - struct dsb phys; - - /* - ** If a data transfer phase is terminated too early - ** (after reception of a message (i.e. DISCONNECT)), - ** we have to prepare a mini script to transfer - ** the rest of the data. - */ - - u_long patch[8]; - - /* - ** The general SCSI driver provides a - ** pointer to a control block. - */ - - struct scsi_xfer *xfer; - -#ifdef ANCIENT - /* - ** We copy the SCSI command, because it - ** may be volatile (on the stack). - ** - */ - struct scsi_generic cmd; -#endif /* ANCIENT */ - - /* - ** We prepare a message to be sent after selection, - ** and a second one to be sent after getcc selection. - ** Contents are IDENTIFY and SIMPLE_TAG. - ** While negotiating sync or wide transfer, - ** a SDTM or WDTM message is appended. - */ - - u_char scsi_smsg [8]; - u_char scsi_smsg2[8]; - - /* - ** Lock this ccb. - ** Flag is used while looking for a free ccb. - */ - - u_long magic; - - /* - ** Completion time out for this job. - ** It's set to time of start + allowed number of seconds. - */ - - u_long tlimit; - - /* - ** All ccbs of one hostadapter are linked. - */ - - ccb_p link_ccb; - - /* - ** All ccbs of one target/lun are linked. - */ - - ccb_p next_ccb; - - /* - ** Tag for this transfer. - ** It's patched into jump_ccb. - ** If it's not zero, a SIMPLE_TAG - ** message is included in smsg. - */ - - u_char tag; -}; - -/*========================================================== -** -** Declaration of structs: NCR device descriptor -** -**========================================================== -*/ - -struct ncb { -#ifdef __NetBSD__ - struct device sc_dev; - struct intrhand sc_ih; -#else /* !__NetBSD__ */ - int unit; -#endif /* __NetBSD__ */ - - /*----------------------------------------------- - ** Scripts .. - **----------------------------------------------- - ** - ** During reselection the ncr jumps to this point. - ** The SFBR register is loaded with the encoded target id. - ** - ** Jump to the first target. - ** - ** JUMP - ** @(next tcb) - */ - struct link jump_tcb; - - /*----------------------------------------------- - ** Configuration .. - **----------------------------------------------- - ** - ** virtual and physical addresses - ** of the 53c810 chip. - */ - vm_offset_t vaddr; - vm_offset_t paddr; - - /* - ** pointer to the chip's registers. - */ - volatile - struct ncr_reg* reg; - - /* - ** A copy of the script, relocated for this ncb. - */ - struct script *script; - u_long p_script; - - /* - ** The SCSI address of the host adapter. - */ - u_char myaddr; - - /* - ** timing parameters - */ - u_char ns_async; - u_char ns_sync; - u_char rv_scntl3; - -#ifndef ANCIENT - /*----------------------------------------------- - ** Link to the generic SCSI driver - **----------------------------------------------- - */ - - struct scsi_link sc_link; -#endif /* ANCIENT */ - - /*----------------------------------------------- - ** Job control - **----------------------------------------------- - ** - ** Commands from user - */ - struct usrcmd user; - u_char order; - - /* - ** Target data - */ - struct tcb target[MAX_TARGET]; - - /* - ** Start queue. - */ - u_long squeue [MAX_START]; - u_short squeueput; - u_short actccbs; - - /* - ** Timeout handler - */ - u_long heartbeat; - u_short ticks; - u_short latetime; - u_long lasttime; - - /*----------------------------------------------- - ** Debug and profiling - **----------------------------------------------- - ** - ** register dump - */ - struct ncr_reg regdump; - struct timeval regtime; - - /* - ** Profiling data - */ - struct profile profile; - u_long disc_phys; - u_long disc_ref; - - /* - ** The global header. - ** Accessible to both the host and the - ** script-processor. - */ - struct head header; - - /* - ** The global control block. - ** It's used only during the configuration phase. - ** A target control block will be created - ** after the first successful transfer. - */ - struct ccb ccb; - - /* - ** message buffers. - ** Should be longword aligned, - ** because they're written with a - ** COPY script command. - */ - u_char msgout[8]; - u_char msgin [8]; - u_long lastmsg; - - /* - ** Buffer for STATUS_IN phase. - */ - u_char scratch; - - /* - ** controller chip dependent maximal transfer width. - */ - u_char maxwide; - - /* - ** lockout of execption handler call while starting command. - */ - u_char lock; -}; - -/*========================================================== -** -** -** Script for NCR-Processor. -** -** Use ncr_script_fill() to create the variable parts. -** Use ncr_script_copy_and_bind() to make a copy and -** bind to physical addresses. -** -** -**========================================================== -** -** We have to know the offsets of all labels before -** we reach them (for forward jumps). -** Therefore we declare a struct here. -** If you make changes inside the script, -** DONT FORGET TO CHANGE THE LENGTHS HERE! -** -**---------------------------------------------------------- -*/ - -struct script { - ncrcmd start [ 7]; - ncrcmd start0 [ 2]; - ncrcmd start1 [ 3]; - ncrcmd startpos [ 1]; - ncrcmd tryloop [MAX_START*5+2]; - ncrcmd trysel [ 8]; - ncrcmd skip [ 8]; - ncrcmd skip2 [ 3]; - ncrcmd idle [ 2]; - ncrcmd select [ 24]; - ncrcmd prepare [ 4]; - ncrcmd loadpos [ 14]; - ncrcmd prepare2 [ 24]; - ncrcmd setmsg [ 5]; - ncrcmd clrack [ 2]; - ncrcmd dispatch [ 31]; - ncrcmd no_data [ 17]; - ncrcmd checkatn [ 10]; - ncrcmd command [ 15]; - ncrcmd status [ 27]; - ncrcmd msg_in [ 26]; - ncrcmd msg_bad [ 6]; - ncrcmd msg_parity [ 6]; - ncrcmd msg_reject [ 8]; - ncrcmd msg_ign_residue [ 32]; - ncrcmd msg_extended [ 18]; - ncrcmd msg_ext_2 [ 18]; - ncrcmd msg_wdtr [ 27]; - ncrcmd msg_ext_3 [ 18]; - ncrcmd msg_sdtr [ 27]; - ncrcmd complete [ 13]; - ncrcmd cleanup [ 12]; - ncrcmd cleanup0 [ 11]; - ncrcmd signal [ 10]; - ncrcmd save_dp [ 5]; - ncrcmd restore_dp [ 5]; - ncrcmd disconnect [ 12]; - ncrcmd disconnect0 [ 5]; - ncrcmd disconnect1 [ 23]; - ncrcmd msg_out [ 9]; - ncrcmd msg_out_done [ 7]; - ncrcmd msg_out_abort [ 10]; - ncrcmd getcc [ 4]; - ncrcmd getcc1 [ 5]; - ncrcmd getcc2 [ 33]; - ncrcmd getcc3 [ 10]; - ncrcmd badgetcc [ 6]; - ncrcmd reselect [ 12]; - ncrcmd reselect2 [ 6]; - ncrcmd resel_tmp [ 5]; - ncrcmd resel_lun [ 18]; - ncrcmd resel_tag [ 24]; - ncrcmd data_in [MAX_SCATTER * 4 + 7]; - ncrcmd data_out [MAX_SCATTER * 4 + 7]; - ncrcmd aborttag [ 4]; - ncrcmd abort [ 20]; - ncrcmd snooptest [ 11]; -}; - -/*========================================================== -** -** -** Function headers. -** -** -**========================================================== -*/ - -#ifdef KERNEL -static void ncr_alloc_ccb (ncb_p np, struct scsi_xfer * xp); -static void ncr_complete (ncb_p np, ccb_p cp); -static int ncr_delta (struct timeval * from, struct timeval * to); -static void ncr_exception (ncb_p np); -static void ncr_free_ccb (ncb_p np, ccb_p cp, int flags); -static void ncr_getclock (ncb_p np); -static ccb_p ncr_get_ccb (ncb_p np, u_long flags, u_long t,u_long l); -static U_INT32 ncr_info (int unit); -static void ncr_init (ncb_p np, char * msg, u_long code); -static int ncr_intr (ncb_p np); -static void ncr_int_ma (ncb_p np); -static void ncr_int_sir (ncb_p np); -static void ncr_int_sto (ncb_p np); -#ifndef NEW_SCSICONF -static u_long ncr_lookup (char* id); -#endif /* NEW_SCSICONF */ -static void ncr_min_phys (struct buf *bp); -static void ncr_negotiate (struct ncb* np, struct tcb* tp); -static void ncr_opennings (ncb_p np, lcb_p lp, struct scsi_xfer * xp); -static void ncb_profile (ncb_p np, ccb_p cp); -static void ncr_script_copy_and_bind - (struct script * script, ncb_p np); -static void ncr_script_fill (struct script * scr); -static int ncr_scatter (struct dsb* phys,u_long vaddr,u_long datalen); -static void ncr_setmaxtags (tcb_p tp, u_long usrtags); -static void ncr_setsync (ncb_p np, ccb_p cp, u_char sxfer); -static void ncr_settags (tcb_p tp, lcb_p lp); -static void ncr_setwide (ncb_p np, ccb_p cp, u_char wide); -static int ncr_show_msg (u_char * msg); -static int ncr_snooptest (ncb_p np); -static INT32 ncr_start (struct scsi_xfer *xp); -static void ncr_timeout (ncb_p np); -static void ncr_usercmd (ncb_p np); -static void ncr_wakeup (ncb_p np, u_long code); - -#ifdef __NetBSD__ -static int ncr_probe (struct device *, struct device *, void *); -static void ncr_attach (struct device *, struct device *, void *); -#else /* !__NetBSD */ -static char* ncr_probe (pcici_t tag, pcidi_t type); -static void ncr_attach (pcici_t tag, int unit); -#endif /* __NetBSD__ */ - -#endif /* KERNEL */ - -/*========================================================== -** -** -** Global static data. -** -** -**========================================================== -*/ - - -static char ident[] = - "\n$Id: ncr.c,v 1.13 1994/11/28 23:18:46 se Exp $\n"; - -u_long ncr_version = NCR_VERSION - + (u_long) sizeof (struct ncb) - * (u_long) sizeof (struct ccb) - * (u_long) sizeof (struct lcb) - * (u_long) sizeof (struct tcb); - -#ifdef KERNEL - -#ifndef __NetBSD__ -u_long nncr=MAX_UNITS; -ncb_p ncrp [MAX_UNITS]; -#endif - -static int ncr_debug = SCSI_DEBUG_FLAGS; - -int ncr_cache; /* to be alligned _NOT_ static */ - -/* -** SCSI cmd to get the SCSI sense data -*/ - -static u_char rs_cmd [6] = - { 0x03, 0, 0, 0, sizeof (struct scsi_sense_data), 0 }; - -/*========================================================== -** -** -** Global static data: auto configure -** -** -**========================================================== -*/ - -#define NCR_810_ID (0x00011000ul) -#define NCR_815_ID (0x00041000ul) -#define NCR_825_ID (0x00031000ul) - -#ifdef __NetBSD__ - -struct cfdriver ncrcd = { - NULL, "ncr", ncr_probe, ncr_attach, DV_DISK, sizeof(struct ncb) -}; - -#else /* !__NetBSD__ */ - -static u_long ncr_count; - -struct pci_driver ncr_device = { - ncr_probe, - ncr_attach, - &ncr_count -}; - -#endif /* !__NetBSD__ */ - -#ifndef ANCIENT -struct scsi_adapter ncr_switch = -{ - ncr_start, - ncr_min_phys, - 0, - 0, - ncr_info, - "ncr", -}; - -struct scsi_device ncr_dev = -{ - NULL, /* Use default error handler */ - NULL, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ - "ncr", -}; -#else /* ANCIENT */ -struct scsi_switch ncr_switch = -{ - ncr_start, - ncr_min_phys, - 0, - 0, - ncr_info, - 0,0,0 -}; -#endif /* ANCIENT */ - -#ifdef __NetBSD__ - -#define ncr_name(np) (np->sc_dev.dv_xname) - -#else /* !__NetBSD__ */ - -static char *ncr_name (ncb_p np) -{ - static char name[10]; - sprintf(name, "ncr%d", np->unit); - return (name); -} -#endif - -/*========================================================== -** -** -** Scripts for NCR-Processor. -** -** Use ncr_script_bind for binding to physical addresses. -** -** -**========================================================== -** -** NADDR generates a reference to a field of the controller data. -** PADDR generates a reference to another part of the script. -** RADDR generates a reference to a script processor register. -** FADDR generates a reference to a script processor register -** with offset. -** -**---------------------------------------------------------- -*/ - -#define RELOC_SOFTC 0x40000000 -#define RELOC_LABEL 0x50000000 -#define RELOC_REGISTER 0x60000000 -#define RELOC_MASK 0xf0000000 - -#define NADDR(label) (RELOC_SOFTC | offsetof(struct ncb, label)) -#define PADDR(label) (RELOC_LABEL | offsetof(struct script, label)) -#define RADDR(label) (RELOC_REGISTER | REG(label)) -#define FADDR(label,ofs)(RELOC_REGISTER | ((REG(label))+(ofs))) - -static struct script script0 = { -/*--------------------------< START >-----------------------*/ { - /* - ** Claim to be still alive ... - */ - SCR_COPY (sizeof (((struct ncb *)0)->heartbeat)), - (ncrcmd) &time.tv_sec, - NADDR (heartbeat), - /* - ** Make data structure address invalid. - ** clear SIGP. - */ - SCR_LOAD_REG (dsa, 0xff), - 0, - SCR_FROM_REG (ctest2), - 0, -}/*-------------------------< START0 >----------------------*/,{ - /* - ** Hook for interrupted GetConditionCode. - ** Will be patched to ... IFTRUE by - ** the interrupt handler. - */ - SCR_INT ^ IFFALSE (0), - SIR_SENSE_RESTART, - -}/*-------------------------< START1 >----------------------*/,{ - /* - ** Hook for stalled start queue. - ** Will be patched to IFTRUE by the interrupt handler. - */ - SCR_INT ^ IFFALSE (0), - SIR_STALL_RESTART, - /* - ** Then jump to a certain point in tryloop. - ** Due to the lack of indirect addressing the code - ** is self modifying here. - */ - SCR_JUMP, -}/*-------------------------< STARTPOS >--------------------*/,{ - PADDR(tryloop), -}/*-------------------------< TRYLOOP >---------------------*/,{ -/* -** Load an entry of the start queue into dsa -** and try to start it by jumping to TRYSEL. -** -** Because the size depends on the -** #define MAX_START parameter, it is filled -** in at runtime. -** -**----------------------------------------------------------- -** -** ##===========< I=0; i<MAX_START >=========== -** || SCR_COPY (4), -** || NADDR (squeue[i]), -** || RADDR (dsa), -** || SCR_CALL, -** || PADDR (trysel), -** ##========================================== -** -** SCR_JUMP, -** PADDR(tryloop), -** -**----------------------------------------------------------- -*/ -0 - -}/*-------------------------< TRYSEL >----------------------*/,{ - /* - ** Now: - ** DSA: Address of a Data Structure - ** or Address of the IDLE-Label. - ** - ** TEMP: Address of a script, which tries to - ** start the NEXT entry. - ** - ** Save the TEMP register into the SCRATCHA register. - ** Then copy the DSA to TEMP and RETURN. - ** This is kind of an indirect jump. - ** (The script processor has NO stack, so the - ** CALL is actually a jump and link, and the - ** RETURN is an indirect jump.) - ** - ** If the slot was empty, DSA contains the address - ** of the IDLE part of this script. The processor - ** jumps to IDLE and waits for a reselect. - ** It will wake up and try the same slot again - ** after the SIGP bit becomes set by the host. - ** - ** If the slot was not empty, DSA contains - ** the address of the phys-part of a ccb. - ** The processor jumps to this address. - ** phys starts with head, - ** head starts with launch, - ** so actually the processor jumps to - ** the lauch part. - ** If the entry is scheduled to be executed, - ** then launch contains a jump to SELECT. - ** If it's not scheduled, it contains a jump to IDLE. - */ - SCR_COPY (4), - RADDR (temp), - RADDR (scratcha), - SCR_COPY (4), - RADDR (dsa), - RADDR (temp), - SCR_RETURN, - 0 - -}/*-------------------------< SKIP >------------------------*/,{ - /* - ** This entry has been canceled. - ** Next time use the next slot. - */ - SCR_COPY (4), - RADDR (scratcha), - PADDR (startpos), - /* - ** patch the launch field. - ** should look like an idle process. - */ - SCR_COPY (4), - RADDR (dsa), - PADDR (skip2), - SCR_COPY (8), - PADDR (idle), -}/*-------------------------< SKIP2 >-----------------------*/,{ - 0, - SCR_JUMP, - PADDR(start), -}/*-------------------------< IDLE >------------------------*/,{ - /* - ** Nothing to do? - ** Wait for reselect. - */ - SCR_JUMP, - PADDR(reselect), - -}/*-------------------------< SELECT >----------------------*/,{ - /* - ** DSA contains the address of a scheduled - ** data structure. - ** - ** SCRATCHA contains the address of the script, - ** which starts the next entry. - ** - ** Set Initiator mode. - ** - ** (Target mode is left as an exercise for the student) - */ - - SCR_CLR (SCR_TRG), - 0, - SCR_LOAD_REG (HS_REG, 0xff), - 0, - - /* - ** And try to select this target. - */ - SCR_SEL_TBL_ATN ^ offsetof (struct dsb, select), - PADDR (reselect), - - /* - ** Now there are 4 possibilities: - ** - ** (1) The ncr looses arbitration. - ** This is ok, because it will try again, - ** when the bus becomes idle. - ** (But beware of the timeout function!) - ** - ** (2) The ncr is reselected. - ** Then the script processor takes the jump - ** to the RESELECT label. - ** - ** (3) The ncr completes the selection. - ** Then it will execute the next statement. - ** - ** (4) There is a selection timeout. - ** Then the ncr should interrupt the host and stop. - ** Unfortunately, it seems to continue execution - ** of the script. But it will fail with an - ** IID-interrupt on the next WHEN. - */ - - SCR_JUMPR ^ IFTRUE (WHEN (SCR_MSG_IN)), - 0, - - /* - ** Save target id to ctest0 register - */ - - SCR_FROM_REG (sdid), - 0, - SCR_TO_REG (ctest0), - 0, - /* - ** Send the IDENTIFY and SIMPLE_TAG messages - ** (and the M_X_SYNC_REQ message) - */ - SCR_MOVE_TBL ^ SCR_MSG_OUT, - offsetof (struct dsb, smsg), - SCR_JUMPR ^ IFTRUE (WHEN (SCR_MSG_OUT)), - -16, - SCR_CLR (SCR_ATN), - 0, - SCR_COPY (1), - RADDR (sfbr), - NADDR (lastmsg), - /* - ** Selection complete. - ** Next time use the next slot. - */ - SCR_COPY (4), - RADDR (scratcha), - PADDR (startpos), -}/*-------------------------< PREPARE >----------------------*/,{ - /* - ** The ncr doesn't have an indirect load - ** or store command. So we have to - ** copy part of the control block to a - ** fixed place, where we can access it. - ** - ** We patch the address part of a - ** COPY command with the DSA-register. - */ - SCR_COPY (4), - RADDR (dsa), - PADDR (loadpos), - /* - ** then we do the actual copy. - */ - SCR_COPY (sizeof (struct head)), - /* - ** continued after the next label ... - */ - -}/*-------------------------< LOADPOS >---------------------*/,{ - 0, - NADDR (header), - /* - ** Mark this ccb as not scheduled. - */ - SCR_COPY (8), - PADDR (idle), - NADDR (header.launch), - /* - ** Set a time stamp for this selection - */ - SCR_COPY (sizeof (struct timeval)), - (ncrcmd) &time, - NADDR (header.stamp.select), - /* - ** load the savep (saved pointer) into - ** the TEMP register (actual pointer) - */ - SCR_COPY (4), - NADDR (header.savep), - RADDR (temp), - /* - ** Initialize the status registers - */ - SCR_COPY (4), - NADDR (header.status), - RADDR (scr0), - -}/*-------------------------< PREPARE2 >---------------------*/,{ - /* - ** Load the synchronous mode register - */ - SCR_COPY (1), - NADDR (sync_st), - RADDR (sxfer), - /* - ** Load the wide mode and timing register - */ - SCR_COPY (1), - NADDR (wide_st), - RADDR (scntl3), - /* - ** Initialize the msgout buffer with a NOOP message. - */ - SCR_LOAD_REG (scratcha, M_NOOP), - 0, - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgout), - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgin), - /* - ** Message in phase ? - */ - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** Extended or reject message ? - */ - SCR_FROM_REG (sbdl), - 0, - SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)), - PADDR (msg_in), - SCR_JUMP ^ IFTRUE (DATA (M_REJECT)), - PADDR (msg_reject), - /* - ** normal processing - */ - SCR_JUMP, - PADDR (dispatch), -}/*-------------------------< SETMSG >----------------------*/,{ - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgout), - SCR_SET (SCR_ATN), - 0, -}/*-------------------------< CLRACK >----------------------*/,{ - /* - ** Terminate possible pending message phase. - */ - SCR_CLR (SCR_ACK), - 0, - -}/*-----------------------< DISPATCH >----------------------*/,{ - SCR_FROM_REG (HS_REG), - 0, - SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)), - SIR_NEGO_FAILED, - SCR_RETURN ^ IFTRUE (WHEN (SCR_DATA_OUT)), - 0, - SCR_RETURN ^ IFTRUE (IF (SCR_DATA_IN)), - 0, - SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)), - PADDR (msg_out), - SCR_JUMP ^ IFTRUE (IF (SCR_MSG_IN)), - PADDR (msg_in), - SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)), - PADDR (command), - SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)), - PADDR (status), - /* - ** Discard one illegal phase byte, if required. - */ - SCR_LOAD_REG (scratcha, XE_BAD_PHASE), - 0, - SCR_COPY (1), - RADDR (scratcha), - NADDR (xerr_st), - SCR_JUMPR ^ IFFALSE (IF (SCR_ILG_OUT)), - 8, - SCR_MOVE_ABS (1) ^ SCR_ILG_OUT, - NADDR (scratch), - SCR_JUMPR ^ IFFALSE (IF (SCR_ILG_IN)), - 8, - SCR_MOVE_ABS (1) ^ SCR_ILG_IN, - NADDR (scratch), - SCR_JUMP, - PADDR (dispatch), - -}/*-------------------------< NO_DATA >--------------------*/,{ - /* - ** The target wants to tranfer too much data - ** or in the wrong direction. - ** Remember that in extended error. - */ - SCR_LOAD_REG (scratcha, XE_EXTRA_DATA), - 0, - SCR_COPY (1), - RADDR (scratcha), - NADDR (xerr_st), - /* - ** Discard one data byte, if required. - */ - SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_OUT)), - 8, - SCR_MOVE_ABS (1) ^ SCR_DATA_OUT, - NADDR (scratch), - SCR_JUMPR ^ IFFALSE (IF (SCR_DATA_IN)), - 8, - SCR_MOVE_ABS (1) ^ SCR_DATA_IN, - NADDR (scratch), - /* - ** .. and repeat as required. - */ - SCR_CALL, - PADDR (dispatch), - SCR_JUMP, - PADDR (no_data), -}/*-------------------------< CHECKATN >--------------------*/,{ - /* - ** If AAP (bit 1 of scntl0 register) is set - ** and a parity error is detected, - ** the script processor asserts ATN. - ** - ** The target should switch to a MSG_OUT phase - ** to get the message. - */ - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFFALSE (MASK (CATN, CATN)), - PADDR (dispatch), - /* - ** count it - */ - SCR_REG_REG (PS_REG, SCR_ADD, 1), - 0, - /* - ** Prepare a M_ID_ERROR message - ** (initiator detected error). - ** The target should retry the transfer. - */ - SCR_LOAD_REG (scratcha, M_ID_ERROR), - 0, - SCR_JUMP, - PADDR (setmsg), - -}/*-------------------------< COMMAND >--------------------*/,{ - /* - ** If this is not a GETCC transfer ... - */ - SCR_FROM_REG (SS_REG), - 0, -/*<<<*/ SCR_JUMPR ^ IFTRUE (DATA (S_CHECK_COND)), - 28, - /* - ** ... set a timestamp ... - */ - SCR_COPY (sizeof (struct timeval)), - (ncrcmd) &time, - NADDR (header.stamp.command), - /* - ** ... and send the command - */ - SCR_MOVE_TBL ^ SCR_COMMAND, - offsetof (struct dsb, cmd), - SCR_JUMP, - PADDR (dispatch), - /* - ** Send the GETCC command - */ -/*>>>*/ SCR_MOVE_ABS (6) ^ SCR_COMMAND, - (ncrcmd) &rs_cmd, - SCR_JUMP, - PADDR (dispatch), - -}/*-------------------------< STATUS >--------------------*/,{ - /* - ** set the timestamp. - */ - SCR_COPY (sizeof (struct timeval)), - (ncrcmd) &time, - NADDR (header.stamp.status), - /* - ** If this is a GETCC transfer, - */ - SCR_FROM_REG (SS_REG), - 0, -/*<<<*/ SCR_JUMPR ^ IFFALSE (DATA (S_CHECK_COND)), - 40, - /* - ** get the status - */ - SCR_MOVE_ABS (1) ^ SCR_STATUS, - NADDR (scratch), - /* - ** Save status to scsi_status. - ** Mark as complete. - ** And wait for disconnect. - */ - SCR_TO_REG (SS_REG), - 0, - SCR_REG_REG (SS_REG, SCR_OR, S_SENSE), - 0, - SCR_LOAD_REG (HS_REG, HS_COMPLETE), - 0, - SCR_JUMP, - PADDR (checkatn), - /* - ** If it was no GETCC transfer, - ** save the status to scsi_status. - */ -/*>>>*/ SCR_MOVE_ABS (1) ^ SCR_STATUS, - NADDR (scratch), - SCR_TO_REG (SS_REG), - 0, - /* - ** if it was no check condition ... - */ - SCR_JUMP ^ IFTRUE (DATA (S_CHECK_COND)), - PADDR (checkatn), - /* - ** ... mark as complete. - */ - SCR_LOAD_REG (HS_REG, HS_COMPLETE), - 0, - SCR_JUMP, - PADDR (checkatn), - -}/*-------------------------< MSG_IN >--------------------*/,{ - /* - ** Get the first byte of the message - ** and save it to SCRATCHA. - ** - ** The script processor doesn't negate the - ** ACK signal after this transfer. - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin[0]), - /* - ** Check for message parity error. - */ - SCR_TO_REG (scratcha), - 0, - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - SCR_FROM_REG (scratcha), - 0, - /* - ** Parity was ok, handle this message. - */ - SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)), - PADDR (complete), - SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)), - PADDR (save_dp), - SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)), - PADDR (restore_dp), - SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)), - PADDR (disconnect), - SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)), - PADDR (msg_extended), - SCR_JUMP ^ IFTRUE (DATA (M_NOOP)), - PADDR (clrack), - SCR_JUMP ^ IFTRUE (DATA (M_REJECT)), - PADDR (msg_reject), - SCR_JUMP ^ IFTRUE (DATA (M_IGN_RESIDUE)), - PADDR (msg_ign_residue), - /* - ** Rest of the messages left as - ** an exercise ... - ** - ** Unimplemented messages: - ** fall through to MSG_BAD. - */ -}/*-------------------------< MSG_BAD >------------------*/,{ - /* - ** unimplemented message - reject it. - */ - SCR_INT, - SIR_REJECT_SENT, - SCR_LOAD_REG (scratcha, M_REJECT), - 0, - SCR_JUMP, - PADDR (setmsg), - -}/*-------------------------< MSG_PARITY >---------------*/,{ - /* - ** count it - */ - SCR_REG_REG (PS_REG, SCR_ADD, 0x01), - 0, - /* - ** send a "message parity error" message. - */ - SCR_LOAD_REG (scratcha, M_PARITY), - 0, - SCR_JUMP, - PADDR (setmsg), -}/*-------------------------< MSG_REJECT >---------------*/,{ - /* - ** If a negotiation was in progress, - ** negotiation failed. - */ - SCR_FROM_REG (HS_REG), - 0, - SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)), - SIR_NEGO_FAILED, - /* - ** else make host log this message - */ - SCR_INT ^ IFFALSE (DATA (HS_NEGOTIATE)), - SIR_REJECT_RECEIVED, - SCR_JUMP, - PADDR (clrack), - -}/*-------------------------< MSG_IGN_RESIDUE >----------*/,{ - /* - ** Terminate cycle - */ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** get residue size. - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin[1]), - /* - ** Check for message parity error. - */ - SCR_TO_REG (scratcha), - 0, - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - SCR_FROM_REG (scratcha), - 0, - /* - ** Size is 0 .. ignore message. - */ - SCR_JUMP ^ IFTRUE (DATA (0)), - PADDR (clrack), - /* - ** Size is not 1 .. have to interrupt. - */ -/*<<<*/ SCR_JUMPR ^ IFFALSE (DATA (1)), - 40, - /* - ** Check for residue byte in swide register - */ - SCR_FROM_REG (scntl2), - 0, -/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)), - 16, - /* - ** There IS data in the swide register. - ** Discard it. - */ - SCR_REG_REG (scntl2, SCR_OR, WSR), - 0, - SCR_JUMP, - PADDR (clrack), - /* - ** Load again the size to the sfbr register. - */ -/*>>>*/ SCR_FROM_REG (scratcha), - 0, -/*>>>*/ SCR_INT, - SIR_IGN_RESIDUE, - SCR_JUMP, - PADDR (clrack), - -}/*-------------------------< MSG_EXTENDED >-------------*/,{ - /* - ** Terminate cycle - */ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** get length. - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin[1]), - /* - ** Check for message parity error. - */ - SCR_TO_REG (scratcha), - 0, - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - SCR_FROM_REG (scratcha), - 0, - /* - */ - SCR_JUMP ^ IFTRUE (DATA (3)), - PADDR (msg_ext_3), - SCR_JUMP ^ IFFALSE (DATA (2)), - PADDR (msg_bad), -}/*-------------------------< MSG_EXT_2 >----------------*/,{ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** get extended message code. - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin[2]), - /* - ** Check for message parity error. - */ - SCR_TO_REG (scratcha), - 0, - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - SCR_FROM_REG (scratcha), - 0, - SCR_JUMP ^ IFTRUE (DATA (M_X_WIDE_REQ)), - PADDR (msg_wdtr), - /* - ** unknown extended message - */ - SCR_JUMP, - PADDR (msg_bad) -}/*-------------------------< MSG_WDTR >-----------------*/,{ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** get data bus width - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin[3]), - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - /* - ** let the host do the real work. - */ - SCR_INT, - SIR_NEGO_WIDE, - /* - ** let the target fetch our answer. - */ - SCR_SET (SCR_ATN), - 0, - SCR_CLR (SCR_ACK), - 0, - - SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)), - SIR_NEGO_PROTO, - /* - ** Send the M_X_WIDE_REQ - */ - SCR_MOVE_ABS (4) ^ SCR_MSG_OUT, - NADDR (msgout), - SCR_CLR (SCR_ATN), - 0, - SCR_COPY (1), - RADDR (sfbr), - NADDR (lastmsg), - SCR_JUMP, - PADDR (msg_out_done), - -}/*-------------------------< MSG_EXT_3 >----------------*/,{ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** get extended message code. - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin[2]), - /* - ** Check for message parity error. - */ - SCR_TO_REG (scratcha), - 0, - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - SCR_FROM_REG (scratcha), - 0, - SCR_JUMP ^ IFTRUE (DATA (M_X_SYNC_REQ)), - PADDR (msg_sdtr), - /* - ** unknown extended message - */ - SCR_JUMP, - PADDR (msg_bad) - -}/*-------------------------< MSG_SDTR >-----------------*/,{ - SCR_CLR (SCR_ACK), - 0, - SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)), - PADDR (dispatch), - /* - ** get period and offset - */ - SCR_MOVE_ABS (2) ^ SCR_MSG_IN, - NADDR (msgin[3]), - SCR_FROM_REG (socl), - 0, - SCR_JUMP ^ IFTRUE (MASK (CATN, CATN)), - PADDR (msg_parity), - /* - ** let the host do the real work. - */ - SCR_INT, - SIR_NEGO_SYNC, - /* - ** let the target fetch our answer. - */ - SCR_SET (SCR_ATN), - 0, - SCR_CLR (SCR_ACK), - 0, - - SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)), - SIR_NEGO_PROTO, - /* - ** Send the M_X_SYNC_REQ - */ - SCR_MOVE_ABS (5) ^ SCR_MSG_OUT, - NADDR (msgout), - SCR_CLR (SCR_ATN), - 0, - SCR_COPY (1), - RADDR (sfbr), - NADDR (lastmsg), - SCR_JUMP, - PADDR (msg_out_done), - -}/*-------------------------< COMPLETE >-----------------*/,{ - /* - ** Complete message. - ** - ** If it's not the get condition code, - ** copy TEMP register to LASTP in header. - */ - SCR_FROM_REG (SS_REG), - 0, -/*<<<*/ SCR_JUMPR ^ IFTRUE (MASK (S_SENSE, S_SENSE)), - 12, - SCR_COPY (4), - RADDR (temp), - NADDR (header.lastp), -/*>>>*/ /* - ** When we terminate the cycle by clearing ACK, - ** the target may disconnect immediately. - ** - ** We don't want to be told of an - ** "unexpected disconnect", - ** so we disable this feature. - */ - SCR_REG_REG (scntl2, SCR_AND, 0x7f), - 0, - /* - ** Terminate cycle ... - */ - SCR_CLR (SCR_ACK), - 0, - /* - ** ... and wait for the disconnect. - */ - SCR_WAIT_DISC, - 0, -}/*-------------------------< CLEANUP >-------------------*/,{ - /* - ** dsa: Pointer to ccb - ** or xxxxxxFF (no ccb) - ** - ** HS_REG: Host-Status (<>0!) - */ - SCR_FROM_REG (dsa), - 0, - SCR_JUMP ^ IFTRUE (DATA (0xff)), - PADDR (signal), - /* - ** dsa is valid. - ** save the status registers - */ - SCR_COPY (4), - RADDR (scr0), - NADDR (header.status), - /* - ** and copy back the header to the ccb. - */ - SCR_COPY (4), - RADDR (dsa), - PADDR (cleanup0), - SCR_COPY (sizeof (struct head)), - NADDR (header), -}/*-------------------------< CLEANUP0 >--------------------*/,{ - 0, - - /* - ** If command resulted in "check condition" - ** status and is not yet completed, - ** try to get the condition code. - */ - SCR_FROM_REG (HS_REG), - 0, -/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (0, HS_DONEMASK)), - 16, - SCR_FROM_REG (SS_REG), - 0, - SCR_JUMP ^ IFTRUE (DATA (S_CHECK_COND)), - PADDR(getcc2), - /* - ** And make the DSA register invalid. - */ -/*>>>*/ SCR_LOAD_REG (dsa, 0xff), /* invalid */ - 0, -}/*-------------------------< SIGNAL >----------------------*/,{ - /* - ** if status = queue full, - ** reinsert in startqueue and stall queue. - */ - SCR_FROM_REG (SS_REG), - 0, - SCR_INT ^ IFTRUE (DATA (S_QUEUE_FULL)), - SIR_STALL_QUEUE, - /* - ** if job completed ... - */ - SCR_FROM_REG (HS_REG), - 0, - /* - ** ... signal completion to the host - */ - SCR_INT_FLY ^ IFFALSE (MASK (0, HS_DONEMASK)), - 0, - /* - ** Auf zu neuen Schandtaten! - */ - SCR_JUMP, - PADDR(start), - -}/*-------------------------< SAVE_DP >------------------*/,{ - /* - ** SAVE_DP message: - ** Copy TEMP register to SAVEP in header. - */ - SCR_COPY (4), - RADDR (temp), - NADDR (header.savep), - SCR_JUMP, - PADDR (clrack), -}/*-------------------------< RESTORE_DP >---------------*/,{ - /* - ** RESTORE_DP message: - ** Copy SAVEP in header to TEMP register. - */ - SCR_COPY (4), - NADDR (header.savep), - RADDR (temp), - SCR_JUMP, - PADDR (clrack), - -}/*-------------------------< DISCONNECT >---------------*/,{ - /* - ** If QUIRK_AUTOSAVE is set, - ** do an "save pointer" operation. - */ - SCR_FROM_REG (QU_REG), - 0, -/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (QUIRK_AUTOSAVE, QUIRK_AUTOSAVE)), - 12, - /* - ** like SAVE_DP message: - ** Copy TEMP register to SAVEP in header. - */ - SCR_COPY (4), - RADDR (temp), - NADDR (header.savep), -/*>>>*/ /* - ** Check if temp==savep or temp==goalp: - ** if not, log a missing save pointer message. - ** In fact, it's a comparation mod 256. - ** - ** Hmmm, I hadn't thought that I would be urged to - ** write this kind of ugly self modifying code. - ** - ** It's unbelievable, but the ncr53c8xx isn't able - ** to subtract one register from another. - */ - SCR_FROM_REG (temp), - 0, - /* - ** You are not expected to understand this .. - */ - SCR_COPY (1), - NADDR (header.savep), - PADDR (disconnect0), -}/*-------------------------< DISCONNECT0 >--------------*/,{ -/*<<<*/ SCR_JUMPR ^ IFTRUE (DATA (1)), - 20, - /* - ** neither this - */ - SCR_COPY (1), - NADDR (header.goalp), - PADDR (disconnect1), -}/*-------------------------< DISCONNECT1 >--------------*/,{ - SCR_INT ^ IFFALSE (DATA (1)), - SIR_MISSING_SAVE, -/*>>>*/ - - /* - ** DISCONNECTing ... - ** - ** Disable the "unexpected disconnect" feature. - */ - SCR_REG_REG (scntl2, SCR_AND, 0x7f), - 0, - SCR_CLR (SCR_ACK), - 0, - /* - ** Wait for the disconnect. - */ - SCR_WAIT_DISC, - 0, - /* - ** Profiling: - ** Set a time stamp, - ** and count the disconnects. - */ - SCR_COPY (sizeof (struct timeval)), - (ncrcmd) &time, - NADDR (header.stamp.disconnect), - SCR_COPY (4), - NADDR (disc_phys), - RADDR (temp), - SCR_REG_REG (temp, SCR_ADD, 0x01), - 0, - SCR_COPY (4), - RADDR (temp), - NADDR (disc_phys), - /* - ** Status is: DISCONNECTED. - */ - SCR_LOAD_REG (HS_REG, HS_DISCONNECT), - 0, - SCR_JUMP, - PADDR (cleanup), - -}/*-------------------------< MSG_OUT >-------------------*/,{ - /* - ** The target requests a message. - ** First remove ATN so the target will - ** not continue fetching messages. - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_OUT, - NADDR (msgout), - SCR_COPY (1), - RADDR (sfbr), - NADDR (lastmsg), - /* - ** If it was no ABORT message ... - */ - SCR_JUMP ^ IFTRUE (DATA (M_ABORT)), - PADDR (msg_out_abort), - /* - ** ... wait for the next phase - ** if it's a message out, send it again, ... - */ - SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)), - PADDR (msg_out), -}/*-------------------------< MSG_OUT_DONE >--------------*/,{ - /* - ** ... else clear the message ... - */ - SCR_LOAD_REG (scratcha, M_NOOP), - 0, - SCR_COPY (4), - RADDR (scratcha), - NADDR (msgout), - /* - ** ... and process the next phase - */ - SCR_JUMP, - PADDR (dispatch), -}/*-------------------------< MSG_OUT_ABORT >-------------*/,{ - /* - ** After ABORT message, - ** - ** expect an immediate disconnect, ... - */ - SCR_REG_REG (scntl2, SCR_AND, 0x7f), - 0, - SCR_CLR (SCR_ACK), - 0, - SCR_WAIT_DISC, - 0, - /* - ** ... and set the status to "ABORTED" - */ - SCR_LOAD_REG (HS_REG, HS_ABORTED), - 0, - SCR_JUMP, - PADDR (cleanup), - -}/*-------------------------< GETCC >-----------------------*/,{ - /* - ** The ncr doesn't have an indirect load - ** or store command. So we have to - ** copy part of the control block to a - ** fixed place, where we can modify it. - ** - ** We patch the address part of a COPY command - ** with the address of the dsa register ... - */ - SCR_COPY (4), - RADDR (dsa), - PADDR (getcc1), - /* - ** ... then we do the actual copy. - */ - SCR_COPY (sizeof (struct head)), -}/*-------------------------< GETCC1 >----------------------*/,{ - 0, - NADDR (header), - /* - ** Initialize the status registers - */ - SCR_COPY (4), - NADDR (header.status), - RADDR (scr0), -}/*-------------------------< GETCC2 >----------------------*/,{ - /* - ** Get the condition code from a target. - ** - ** DSA points to a data structure. - ** Set TEMP to the script location - ** that receives the condition code. - ** - ** Because there is no script command - ** to load a longword into a register, - ** we use a CALL command. - */ -/*<<<*/ SCR_CALLR, - 24, - /* - ** Get the condition code. - */ - SCR_MOVE_TBL ^ SCR_DATA_IN, - offsetof (struct dsb, sense), - /* - ** No data phase may follow! - */ - SCR_CALL, - PADDR (checkatn), - SCR_JUMP, - PADDR (no_data), -/*>>>*/ - - /* - ** The CALL jumps to this point. - ** Prepare for a RESTORE_POINTER message. - ** Save the TEMP register into the saved pointer. - */ - SCR_COPY (4), - RADDR (temp), - NADDR (header.savep), - /* - ** Load scratcha, because in case of a selection timeout, - ** the host will expect a new value for startpos in - ** the scratcha register. - */ - SCR_COPY (4), - PADDR (startpos), - RADDR (scratcha), - /* - ** If QUIRK_NOMSG is set, select without ATN. - ** and don't send a message. - */ - SCR_FROM_REG (QU_REG), - 0, - SCR_JUMP ^ IFTRUE (MASK (QUIRK_NOMSG, QUIRK_NOMSG)), - PADDR(getcc3), - /* - ** Then try to connect to the target. - ** If we are reselected, special treatment - ** of the current job is required before - ** accepting the reselection. - */ - SCR_SEL_TBL_ATN ^ offsetof (struct dsb, select), - PADDR(badgetcc), - /* - ** save target id. - */ - SCR_FROM_REG (sdid), - 0, - SCR_TO_REG (ctest0), - 0, - /* - ** Send the IDENTIFY message. - ** In case of short transfer, remove ATN. - */ - SCR_MOVE_TBL ^ SCR_MSG_OUT, - offsetof (struct dsb, smsg2), - SCR_CLR (SCR_ATN), - 0, - /* - ** save the first byte of the message. - */ - SCR_COPY (1), - RADDR (sfbr), - NADDR (lastmsg), - SCR_JUMP, - PADDR (prepare2), - -}/*-------------------------< GETCC3 >----------------------*/,{ - /* - ** Try to connect to the target. - ** If we are reselected, special treatment - ** of the current job is required before - ** accepting the reselection. - ** - ** Silly target won't accept a message. - ** Select without ATN. - */ - SCR_SEL_TBL ^ offsetof (struct dsb, select), - PADDR(badgetcc), - /* - ** save target id. - */ - SCR_FROM_REG (sdid), - 0, - SCR_TO_REG (ctest0), - 0, - /* - ** Force error if selection timeout - */ - SCR_JUMPR ^ IFTRUE (WHEN (SCR_MSG_IN)), - 0, - /* - ** don't negotiate. - */ - SCR_JUMP, - PADDR (prepare2), - -}/*------------------------< BADGETCC >---------------------*/,{ - /* - ** If SIGP was set, clear it and try again. - */ - SCR_FROM_REG (ctest2), - 0, - SCR_JUMP ^ IFTRUE (MASK (CSIGP,CSIGP)), - PADDR (getcc2), - SCR_INT, - SIR_SENSE_FAILED, -}/*-------------------------< RESELECT >--------------------*/,{ - /* - ** make the DSA invalid. - */ - SCR_LOAD_REG (dsa, 0xff), - 0, - SCR_CLR (SCR_TRG), - 0, - /* - ** Sleep waiting for a reselection. - ** If SIGP is set, special treatment. - ** - ** Zu allem bereit .. - */ - SCR_WAIT_RESEL, - PADDR(reselect2), - /* - ** ... zu nichts zu gebrauchen ? - ** - ** load the target id into the SFBR - ** and jump to the control block. - ** - ** Look at the declarations of - ** - struct ncb - ** - struct tcb - ** - struct lcb - ** - struct ccb - ** to understand what's going on. - */ - SCR_REG_SFBR (ssid, SCR_AND, 0x87), - 0, - SCR_TO_REG (ctest0), - 0, - SCR_JUMP, - NADDR (jump_tcb), -}/*-------------------------< RESELECT2 >-------------------*/,{ - /* - ** If it's not connected :( - ** -> interrupted by SIGP bit. - ** Jump to start. - */ - SCR_FROM_REG (ctest2), - 0, - SCR_JUMP ^ IFTRUE (MASK (CSIGP,CSIGP)), - PADDR (start), - SCR_JUMP, - PADDR (reselect), - -}/*-------------------------< RESEL_TMP >-------------------*/,{ - /* - ** The return address in TEMP - ** is in fact the data structure address, - ** so copy it to the DSA register. - */ - SCR_COPY (4), - RADDR (temp), - RADDR (dsa), - SCR_JUMP, - PADDR (prepare), - -}/*-------------------------< RESEL_LUN >-------------------*/,{ - /* - ** come back to this point - ** to get an IDENTIFY message - ** Wait for a msg_in phase. - */ -/*<<<*/ SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), - 48, - /* - ** message phase - ** It's not a sony, it's a trick: - ** read the data without acknowledging it. - */ - SCR_FROM_REG (sbdl), - 0, -/*<<<*/ SCR_JUMPR ^ IFFALSE (MASK (M_IDENTIFY, 0x98)), - 32, - /* - ** It WAS an Identify message. - ** get it and ack it! - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin), - SCR_CLR (SCR_ACK), - 0, - /* - ** Mask out the LUN. - */ - SCR_REG_REG (sfbr, SCR_AND, 0x07), - 0, - SCR_RETURN, - 0, - /* - ** No message phase or no IDENTIFY message: - ** return 0. - */ -/*>>>*/ SCR_LOAD_SFBR (0), - 0, - SCR_RETURN, - 0, - -}/*-------------------------< RESEL_TAG >-------------------*/,{ - /* - ** come back to this point - ** to get a SIMPLE_TAG message - ** Wait for a MSG_IN phase. - */ -/*<<<*/ SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), - 64, - /* - ** message phase - ** It's a trick - read the data - ** without acknowledging it. - */ - SCR_FROM_REG (sbdl), - 0, -/*<<<*/ SCR_JUMPR ^ IFFALSE (DATA (M_SIMPLE_TAG)), - 48, - /* - ** It WAS a SIMPLE_TAG message. - ** get it and ack it! - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin), - SCR_CLR (SCR_ACK), - 0, - /* - ** Wait for the second byte (the tag) - */ -/*<<<*/ SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_IN)), - 24, - /* - ** Get it and ack it! - */ - SCR_MOVE_ABS (1) ^ SCR_MSG_IN, - NADDR (msgin), - SCR_CLR (SCR_ACK|SCR_CARRY), - 0, - SCR_RETURN, - 0, - /* - ** No message phase or no SIMPLE_TAG message - ** or no second byte: return 0. - */ -/*>>>*/ SCR_LOAD_SFBR (0), - 0, - SCR_SET (SCR_CARRY), - 0, - SCR_RETURN, - 0, - -}/*-------------------------< DATA_IN >--------------------*/,{ -/* -** Because the size depends on the -** #define MAX_SCATTER parameter, -** it is filled in at runtime. -** -** SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)), -** PADDR (no_data), -** SCR_COPY (sizeof (struct timeval)), -** (ncrcmd) &time, -** NADDR (header.stamp.data), -** SCR_MOVE_TBL ^ SCR_DATA_IN, -** offsetof (struct dsb, data[ 0]), -** -** ##===========< i=1; i<MAX_SCATTER >========= -** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_IN)), -** || PADDR (checkatn), -** || SCR_MOVE_TBL ^ SCR_DATA_IN, -** || offsetof (struct dsb, data[ i]), -** ##========================================== -** -** SCR_CALL, -** PADDR (checkatn), -** SCR_JUMP, -** PADDR (no_data), -*/ -0 -}/*-------------------------< DATA_OUT >-------------------*/,{ -/* -** Because the size depends on the -** #define MAX_SCATTER parameter, -** it is filled in at runtime. -** -** SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)), -** PADDR (no_data), -** SCR_COPY (sizeof (struct timeval)), -** (ncrcmd) &time, -** NADDR (header.stamp.data), -** SCR_MOVE_TBL ^ SCR_DATA_OUT, -** offsetof (struct dsb, data[ 0]), -** -** ##===========< i=1; i<MAX_SCATTER >========= -** || SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_OUT)), -** || PADDR (dispatch), -** || SCR_MOVE_TBL ^ SCR_DATA_OUT, -** || offsetof (struct dsb, data[ i]), -** ##========================================== -** -** SCR_CALL, -** PADDR (dispatch), -** SCR_JUMP, -** PADDR (no_data), -** -**--------------------------------------------------------- -*/ -(u_long)&ident - -}/*-------------------------< ABORTTAG >-------------------*/,{ - /* - ** Abort a bad reselection. - ** Set the message to ABORT vs. ABORT_TAG - */ - SCR_LOAD_REG (scratcha, M_ABORT_TAG), - 0, - SCR_JUMPR ^ IFFALSE (CARRYSET), - 8, -}/*-------------------------< ABORT >----------------------*/,{ - SCR_LOAD_REG (scratcha, M_ABORT), - 0, - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgout), - SCR_SET (SCR_ATN), - 0, - SCR_CLR (SCR_ACK), - 0, - /* - ** and send it. - ** we expect an immediate disconnect - */ - SCR_REG_REG (scntl2, SCR_AND, 0x7f), - 0, - SCR_MOVE_ABS (1) ^ SCR_MSG_OUT, - NADDR (msgout), - SCR_COPY (1), - RADDR (sfbr), - NADDR (lastmsg), - SCR_WAIT_DISC, - 0, - SCR_JUMP, - PADDR (start), -}/*-------------------------< SNOOPTEST >-------------------*/,{ - /* - ** Read the variable. - */ - SCR_COPY (4), - (ncrcmd) &ncr_cache, - RADDR (scratcha), - /* - ** Write the variable. - */ - SCR_COPY (4), - RADDR (temp), - (ncrcmd) &ncr_cache, - /* - ** Read back the variable. - */ - SCR_COPY (4), - (ncrcmd) &ncr_cache, - RADDR (temp), - /* - ** And stop. - */ - SCR_INT, - 99, -}/*--------------------------------------------------------*/ -}; - -/*========================================================== -** -** -** Fill in #define dependent parts of the script -** -** -**========================================================== -*/ - -void ncr_script_fill (struct script * scr) -{ - int i; - ncrcmd *p; - - p = scr->tryloop; - for (i=0; i<MAX_START; i++) { - *p++ =SCR_COPY (4); - *p++ =NADDR (squeue[i]); - *p++ =RADDR (dsa); - *p++ =SCR_CALL; - *p++ =PADDR (trysel); - }; - *p++ =SCR_JUMP; - *p++ =PADDR(tryloop); - - assert ((u_long)p == (u_long)&scr->tryloop + sizeof (scr->tryloop)); - - p = scr->data_in; - - *p++ =SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)); - *p++ =PADDR (no_data); - *p++ =SCR_COPY (sizeof (struct timeval)); - *p++ =(ncrcmd) &time; - *p++ =NADDR (header.stamp.data); - *p++ =SCR_MOVE_TBL ^ SCR_DATA_IN; - *p++ =offsetof (struct dsb, data[ 0]); - - for (i=1; i<MAX_SCATTER; i++) { - *p++ =SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_IN)); - *p++ =PADDR (checkatn); - *p++ =SCR_MOVE_TBL ^ SCR_DATA_IN; - *p++ =offsetof (struct dsb, data[i]); - }; - - *p++ =SCR_CALL; - *p++ =PADDR (checkatn); - *p++ =SCR_JUMP; - *p++ =PADDR (no_data); - - assert ((u_long)p == (u_long)&scr->data_in + sizeof (scr->data_in)); - - p = scr->data_out; - - *p++ =SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_OUT)); - *p++ =PADDR (no_data); - *p++ =SCR_COPY (sizeof (struct timeval)); - *p++ =(ncrcmd) &time; - *p++ =NADDR (header.stamp.data); - *p++ =SCR_MOVE_TBL ^ SCR_DATA_OUT; - *p++ =offsetof (struct dsb, data[ 0]); - - for (i=1; i<MAX_SCATTER; i++) { - *p++ =SCR_CALL ^ IFFALSE (WHEN (SCR_DATA_OUT)); - *p++ =PADDR (dispatch); - *p++ =SCR_MOVE_TBL ^ SCR_DATA_OUT; - *p++ =offsetof (struct dsb, data[i]); - }; - - *p++ =SCR_CALL; - *p++ =PADDR (dispatch); - *p++ =SCR_JUMP; - *p++ =PADDR (no_data); - - assert ((u_long)p == (u_long)&scr->data_out + sizeof (scr->data_out)); -} - -/*========================================================== -** -** -** Copy and rebind a script. -** -** -**========================================================== -*/ - -static void ncr_script_copy_and_bind (struct script *script, ncb_p np) -{ - ncrcmd opcode, new, old; - ncrcmd *src, *dst, *start, *end; - int relocs; - - np->script = (struct script *) - malloc (sizeof (struct script), M_DEVBUF, M_WAITOK); - np->p_script = vtophys(np->script); - - src = script->start; - dst = np->script->start; - - start = src; - end = src + (sizeof(struct script) / 4); - - while (src < end) { - - *dst++ = opcode = *src++; - - /* - ** If we forget to change the length - ** in struct script, a field will be - ** padded with 0. This is an illegal - ** command. - */ - - if (opcode == 0) { - printf ("%s: ERROR0 IN SCRIPT at %d.\n", - ncr_name(np), src-start-1); - DELAY (1000000); - }; - - if (DEBUG_FLAGS & DEBUG_SCRIPT) - printf ("%x: <%x>\n", - (unsigned)(src-1), (unsigned)opcode); - - /* - ** We don't have to decode ALL commands - */ - switch (opcode >> 28) { - - case 0xc: - /* - ** COPY has TWO arguments. - */ - relocs = 2; - if ((src[0] ^ src[1]) & 3) { - printf ("%s: ERROR1 IN SCRIPT at %d.\n", - ncr_name(np), src-start-1); - DELAY (1000000); - }; - break; - - case 0x0: - /* - ** MOVE (absolute address) - */ - relocs = 1; - break; - - case 0x8: - /* - ** JUMP / CALL - ** dont't relocate if relative :-) - */ - if (opcode & 0x00800000) - relocs = 0; - else - relocs = 1; - break; - - case 0x4: - case 0x5: - case 0x6: - case 0x7: - relocs = 1; - break; - - default: - relocs = 0; - break; - }; - - if (relocs) { - while (relocs--) { - old = *src++; - - switch (old & RELOC_MASK) { - case RELOC_REGISTER: - new = (old & ~RELOC_MASK) + np->paddr; - break; - case RELOC_LABEL: - new = (old & ~RELOC_MASK) + vtophys(np->script); - break; - case RELOC_SOFTC: - new = (old & ~RELOC_MASK) + vtophys(np); - break; - case 0: - /* Don't relocate a 0 address. */ - if (old == 0) { - new = old; - break; - } - /* fall through */ - default: - new = vtophys(old); - break; - } - - *dst++ = new; - } - } else - *dst++ = *src++; - - }; -} - -/*========================================================== -** -** -** Auto configuration. -** -** -**========================================================== -*/ - -/*---------------------------------------------------------- -** -** Reduce the transfer length to the max value -** we can transfer safely. -** -** Reading a block greater then MAX_SIZE from the -** raw (character) device exercises a memory leak -** in the vm subsystem. This is common to ALL devices. -** We have submitted a description of this bug to -** <FreeBSD-bugs@freefall.cdrom.com>. -** It should be fixed in the current release. -** -**---------------------------------------------------------- -*/ - -void ncr_min_phys (struct buf *bp) -{ - if (bp->b_bcount > MAX_SIZE) bp->b_bcount = MAX_SIZE; -} - -/*---------------------------------------------------------- -** -** Maximal number of outstanding requests per target. -** -**---------------------------------------------------------- -*/ - -U_INT32 ncr_info (int unit) -{ - return (1); /* may be changed later */ -} - -/*---------------------------------------------------------- -** -** Probe the hostadapter. -** -**---------------------------------------------------------- -*/ - -#ifdef __NetBSD__ - -int -ncr_probe(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct cfdata *cf = self->dv_cfdata; - struct pci_attach_args *pa = aux; - - if (!pci_targmatch(cf, pa)) - return 0; - if (pa->pa_id != NCR_810_ID && - pa->pa_id != NCR_815_ID && - pa->pa_id != NCR_825_ID) - return 0; - - return 1; -} - -#else /* !__NetBSD__ */ - - -static char* ncr_probe (pcici_t tag, pcidi_t type) -{ - switch (type) { - - case NCR_810_ID: - return ("ncr 53c810 scsi"); - - case NCR_815_ID: - return ("ncr 53c815 scsi"); - - case NCR_825_ID: - return ("ncr 53c825 wide scsi"); - } - return (0); -} - -#endif /* !__NetBSD__ */ - - -/*========================================================== -** -** -** Auto configuration: attach and init a host adapter. -** -** -**========================================================== -*/ - -#define MIN_ASYNC_PD 40 -#define MIN_SYNC_PD 20 - -#ifdef __NetBSD__ - -int -ncr_print() -{ -} - -void -ncr_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct pci_attach_args *pa = aux; - int retval; - ncb_p np = (void *)self; - - /* - ** XXX - ** Perhaps try to figure what which model chip it is and print that - ** out. - */ - printf("\n"); - - /* - ** Try to map the controller chip to - ** virtual and physical memory. - */ - - retval = pci_map_mem(pa->pa_tag, 0x14, &np->vaddr, &np->paddr); - if (retval) - return; - - np->sc_ih.ih_fun = ncr_intr; - np->sc_ih.ih_arg = np; - np->sc_ih.ih_level = IPL_BIO; - - retval = pci_map_int(pa->pa_tag, &np->sc_ih); - if (retval) - return; - -#else /* !__NetBSD__ */ - -static void ncr_attach (pcici_t config_id, int unit) -{ - ncb_p np; -#if ! (__FreeBSD__ >= 2) - extern unsigned bio_imask; -#endif - - - /* - ** allocate structure - */ - - np = (ncb_p) malloc (sizeof (struct ncb), M_DEVBUF, M_WAITOK); - if (!np) return; - ncrp[unit]=np; - - /* - ** initialize structure. - */ - - bzero (np, sizeof (*np)); - np->unit = unit; - - /* - ** Try to map the controller chip to - ** virtual and physical memory. - */ - - if (!pci_map_mem (config_id, 0x14, &np->vaddr, &np->paddr)) - return; - -#endif /* !__NetBSD__ */ - - /* - ** Do chip dependent initialization. - */ - -#ifdef __NetBSD__ - switch (pa->pa_id) { -#else - switch (pci_conf_read (config_id, PCI_ID_REG)) { -#endif - case NCR_810_ID: - np->maxwide = 0; - break; - case NCR_815_ID: - case NCR_825_ID: - np->maxwide = 1; - break; - } - - /* - ** Patch script to physical addresses - */ - - ncr_script_fill (&script0); - ncr_script_copy_and_bind (&script0, np); - - /* - ** init data structure - */ - - np -> jump_tcb.l_cmd = SCR_JUMP ; - np -> jump_tcb.l_paddr = vtophys (&np->script->abort); - - /* - ** Make the controller's registers available. - ** Now the INB INW INL OUTB OUTW OUTL macros - ** can be used safely. - */ - - np->reg = (struct ncr_reg*) np->vaddr; - - /* - ** Get SCSI addr of host adapter (set by bios?). - */ - - np->myaddr = INB(nc_scid) & 0x07; - if (!np->myaddr) np->myaddr = SCSI_NCR_MYADDR; - - /* - ** Get the value of the chip's clock. - ** Find the right value for scntl3. - */ - - ncr_getclock (np); - - /* - ** Reset chip. - */ - - OUTB (nc_istat, SRST); - OUTB (nc_istat, 0 ); - - /* - ** Now check the cache handling of the pci chipset. - */ - - if (ncr_snooptest (np)) { - printf ("CACHE INCORRECTLY CONFIGURED.\n"); - return; - }; - -#ifndef __NetBSD__ - /* - ** Install the interrupt handler. - */ - - if (!pci_map_int (config_id, ncr_intr, np, &bio_imask)) - printf ("\tinterruptless mode: reduced performance.\n"); -#endif - - /* - ** After SCSI devices have been opened, we cannot - ** reset the bus safely, so we do it here. - ** Interrupt handler does the real work. - */ - - OUTB (nc_scntl1, CRST); - - /* - ** process the reset exception, - ** if interrupts are not enabled yet. - */ - ncr_exception (np); - -#ifdef ANCIENT - printf ("%s: waiting for scsi devices to settle\n", - ncr_name (np)); - DELAY (1000000); -#endif - printf ("%s scanning for targets 0..%d ($Revision: 1.13 $)\n", - ncr_name (np), MAX_TARGET-1); - - /* - ** Now let the generic SCSI driver - ** look for the SCSI devices on the bus .. - */ - -#ifndef ANCIENT -#ifdef __NetBSD__ - np->sc_link.adapter_softc = np; -#else /* !__NetBSD__ */ - np->sc_link.adapter_unit = unit; -#endif /* !__NetBSD__ */ - np->sc_link.adapter_targ = np->myaddr; - np->sc_link.adapter = &ncr_switch; - np->sc_link.device = &ncr_dev; - -#ifdef __NetBSD__ - config_found(self, &np->sc_link, ncr_print); -#else /* !__NetBSD__ */ - scsi_attachdevs (&np->sc_link); -#endif /* !__NetBSD__ */ -#else /* ANCIENT */ - scsi_attachdevs (unit, np->myaddr, &ncr_switch); -#endif /* ANCIENT */ - - /* - ** start the timeout daemon - */ - ncr_timeout (np); - np->lasttime=0; - - /* - ** Done. - */ - - return; -} - -/*========================================================== -** -** -** Process pending device interrupts. -** -** -**========================================================== -*/ - -int -ncr_intr(np) - ncb_p np; -{ - int n = 0; - - if (DEBUG_FLAGS & DEBUG_TINY) printf ("["); - - if (INB(nc_istat) & (INTF|SIP|DIP)) { - /* - ** Repeat until no outstanding ints - */ - do { - ncr_exception (np); - } while (INB(nc_istat) & (INTF|SIP|DIP)); - - n=1; - np->ticks = 100; - }; - - if (DEBUG_FLAGS & DEBUG_TINY) printf ("]\n"); - - return (n); -} - -/*========================================================== -** -** -** Start execution of a SCSI command. -** This is called from the generic SCSI driver. -** -** -**========================================================== -*/ - -static INT32 ncr_start (struct scsi_xfer * xp) -{ -#ifndef ANCIENT -#ifdef __NetBSD__ - ncb_p np = xp->sc_link->adapter_softc; -#else /*__NetBSD__*/ - ncb_p np = ncrp[xp->sc_link->adapter_unit]; -#endif/*__NetBSD__*/ -#else /* ANCIENT */ - ncb_p np = ncrp[xp->adapter]; -#endif /* ANCIENT */ - - struct scsi_generic * cmd = xp->cmd; - ccb_p cp; - lcb_p lp; - tcb_p tp = &np->target[xp->TARGET]; - - int i, oldspl, segments, flags = xp->flags; - u_char ptr, nego, idmsg; - u_long msglen, msglen2; - - - - /*--------------------------------------------- - ** - ** Reset SCSI bus - ** - ** Interrupt handler does the real work. - ** - **--------------------------------------------- - */ - - if (flags & SCSI_RESET) { - OUTB (nc_scntl1, CRST); - return(COMPLETE); - }; - - /*--------------------------------------------- - ** - ** Some shortcuts ... - ** - **--------------------------------------------- - */ - - if ((xp->TARGET == np->myaddr ) || - (xp->TARGET >= MAX_TARGET) || - (xp->LUN >= MAX_LUN ) || - (flags & SCSI_DATA_UIO)) { - xp->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - }; - - /*--------------------------------------------- - ** - ** Diskaccess to partial blocks? - ** - **--------------------------------------------- - */ - - if ((xp->datalen & 0x1ff) && !(tp->inqdata[0] & 0x1f)) { - switch (cmd->opcode) { - case 0x28: /* READ_BIG (10) */ - case 0xa8: /* READ_HUGE (12) */ - case 0x2a: /* WRITE_BIG (10) */ - case 0xaa: /* WRITE_HUGE(12) */ - PRINT_ADDR(xp); - printf ("access to partial disk block refused.\n"); - xp->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - }; - }; - -#ifdef ANCIENT - /*--------------------------------------------- - ** Ancient version of <sys/scsi/sd.c> - ** doesn't set the DATA_IN/DATA_OUT bits. - ** So we have to fix it .. - **--------------------------------------------- - */ - - switch (cmd->opcode) { - case 0x1a: /* MODE_SENSE */ - case 0x25: /* READ_CAPACITY */ - case 0x28: /* READ_BIG (10) */ - xp->flags |= SCSI_DATA_IN; - break; - case 0x2a: /* WRITE_BIG(10) */ - xp->flags |= SCSI_DATA_OUT; - break; - }; -#endif /* ANCIENT */ - - if (DEBUG_FLAGS & DEBUG_TINY) { - PRINT_ADDR(xp); - printf ("CMD=%x F=%x L=%x ", cmd->opcode, - (unsigned)xp->flags, (unsigned) xp->datalen); - } - - /*-------------------------------------------- - ** - ** Sanity checks ... - ** copied from Elischer's Adaptec driver. - ** - **-------------------------------------------- - */ - - flags = xp->flags; - if (!(flags & INUSE)) { - printf("%s: ?INUSE?\n", ncr_name (np)); - xp->flags |= INUSE; - }; - - if(flags & ITSDONE) { - printf("%s: ?ITSDONE?\n", ncr_name (np)); - xp->flags &= ~ITSDONE; - }; - - if (xp->bp) - flags |= (SCSI_NOSLEEP); /* just to be sure */ - - /*--------------------------------------------------- - ** - ** Assign a ccb / bind xp - ** - **---------------------------------------------------- - */ - - if (!(cp=ncr_get_ccb (np, flags, xp->TARGET, xp->LUN))) { - printf ("%s: no ccb.\n", ncr_name (np)); - xp->error = XS_DRIVER_STUFFUP; - return(TRY_AGAIN_LATER); - }; - cp->xfer = xp; - - /*--------------------------------------------------- - ** - ** timestamp - ** - **---------------------------------------------------- - */ - - bzero (&cp->phys.header.stamp, sizeof (struct tstamp)); - cp->phys.header.stamp.start = time; - - /*---------------------------------------------------- - ** - ** Get device quirks from a speciality table. - ** - ** @GENSCSI@ - ** This should be a part of the device table - ** in "scsi_conf.c". - ** - **---------------------------------------------------- - */ - - if (tp->quirks & QUIRK_UPDATE) { -#ifdef NEW_SCSICONF - tp->quirks = xp->sc_link->quirks; -#else - tp->quirks = ncr_lookup ((char*) &tp->inqdata[0]); -#endif - if (tp->quirks) { - PRINT_ADDR(xp); - printf ("quirks=%x.\n", tp->quirks); - }; - }; - - /*--------------------------------------------------- - ** - ** negotiation required? - ** - **---------------------------------------------------- - */ - - nego = 0; - - if (tp->inqdata[7]) { - /* - ** negotiate synchronous transfers? - */ - - if (!tp->period) { - if (tp->inqdata[7] & INQ7_SYNC) { - nego = NS_SYNC; - } else { - tp->period =0xffff; - tp->sval = 0xe0; - PRINT_ADDR(xp); - printf ("asynchronous.\n"); - }; - }; - - /* - ** negotiate wide transfers ? - */ - - if (!tp->widedone) { - if (tp->inqdata[7] & INQ7_WIDE16) { - if (!nego) nego = NS_WIDE; - } else - tp->widedone=1; - }; - }; - - /*--------------------------------------------------- - ** - ** choose a new tag ... - ** - **---------------------------------------------------- - */ - - if ((lp = tp->lp[xp->LUN]) && (lp->usetags)) { - /* - ** assign a tag to this ccb! - */ - while (!cp->tag) { - ccb_p cp2 = lp->next_ccb; - lp->lasttag = lp->lasttag % 255 + 1; - while (cp2 && cp2->tag != lp->lasttag) - cp2 = cp2->next_ccb; - if (cp2) continue; - cp->tag=lp->lasttag; - if (DEBUG_FLAGS & DEBUG_TAGS) { - PRINT_ADDR(xp); - printf ("using tag #%d.\n", cp->tag); - }; - }; - } else { - cp->tag=0; -#if !defined(ANCIENT) && !defined(__NetBSD__) && !(__FreeBSD__ >= 2) - /* - ** @GENSCSI@ Bug in "/sys/scsi/cd.c" - ** - ** /sys/scsi/cd.c initializes opennings with 2. - ** Our info value of 1 is not respected. - */ - if (xp->sc_link && xp->sc_link->opennings) { - PRINT_ADDR(xp); - printf ("opennings set to 0.\n"); - xp->sc_link->opennings = 0; - }; -#endif - }; - - /*---------------------------------------------------- - ** - ** Build the identify / tag / sdtr message - ** - **---------------------------------------------------- - */ - - idmsg = (cp==&np->ccb ? 0x80 : 0xc0) | xp->LUN; - - cp -> scsi_smsg [0] = idmsg; - msglen=1; - - if (cp->tag) { - - /* - ** Ordered write ops, unordered read ops. - */ - switch (cmd->opcode) { - case 0x08: /* READ_SMALL (6) */ - case 0x28: /* READ_BIG (10) */ - case 0xa8: /* READ_HUGE (12) */ - cp -> scsi_smsg [msglen] = M_SIMPLE_TAG; - break; - default: - cp -> scsi_smsg [msglen] = M_ORDERED_TAG; - } - - /* - ** can be overwritten by ncrcontrol - */ - switch (np->order) { - case M_SIMPLE_TAG: - case M_ORDERED_TAG: - cp -> scsi_smsg [msglen] = np->order; - }; - msglen++; - cp -> scsi_smsg [msglen++] = cp -> tag; - } - - switch (nego) { - case NS_SYNC: - cp -> scsi_smsg [msglen++] = M_EXTENDED; - cp -> scsi_smsg [msglen++] = 3; - cp -> scsi_smsg [msglen++] = M_X_SYNC_REQ; - cp -> scsi_smsg [msglen++] = tp->minsync; - cp -> scsi_smsg [msglen++] = tp->maxoffs; - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("sync msgout: "); - ncr_show_msg (&cp->scsi_smsg [msglen-5]); - printf (".\n"); - }; - break; - case NS_WIDE: - cp -> scsi_smsg [msglen++] = M_EXTENDED; - cp -> scsi_smsg [msglen++] = 2; - cp -> scsi_smsg [msglen++] = M_X_WIDE_REQ; - cp -> scsi_smsg [msglen++] = tp->usrwide; - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("wide msgout: "); - ncr_show_msg (&cp->scsi_smsg [msglen-4]); - printf (".\n"); - }; - break; - }; - - /*---------------------------------------------------- - ** - ** Build the identify message for getcc. - ** - **---------------------------------------------------- - */ - - cp -> scsi_smsg2 [0] = idmsg; - msglen2 = 1; - - /*---------------------------------------------------- - ** - ** Build the data descriptors - ** - **---------------------------------------------------- - */ - - segments = ncr_scatter (&cp->phys, (vm_offset_t) xp->data, - (vm_size_t) xp->datalen); - - if (segments < 0) { - xp->error = XS_DRIVER_STUFFUP; - ncr_free_ccb(np, cp, flags); - return(HAD_ERROR); - }; - - /*---------------------------------------------------- - ** - ** Set the SAVED_POINTER. - ** - **---------------------------------------------------- - */ - - if (flags & SCSI_DATA_IN) { - cp->phys.header.savep = vtophys (&np->script->data_in); - cp->phys.header.goalp = cp->phys.header.savep +20 +segments*16; - } else if (flags & SCSI_DATA_OUT) { - cp->phys.header.savep = vtophys (&np->script->data_out); - cp->phys.header.goalp = cp->phys.header.savep +20 +segments*16; - } else { - cp->phys.header.savep = vtophys (&np->script->no_data); - cp->phys.header.goalp = cp->phys.header.savep; - }; - cp->phys.header.lastp = cp->phys.header.savep; - - - /*---------------------------------------------------- - ** - ** fill ccb - ** - **---------------------------------------------------- - ** - ** - ** physical -> virtual backlink - ** Generic SCSI command - */ - cp->phys.header.cp = cp; - /* - ** Startqueue - */ - cp->phys.header.launch.l_paddr = vtophys (&np->script->select); - cp->phys.header.launch.l_cmd = SCR_JUMP; - /* - ** select - */ - cp->phys.select.sel_id = xp->TARGET; - cp->phys.select.sel_scntl3 = tp->wval; - cp->phys.select.sel_sxfer = tp->sval; - /* - ** message - */ - cp->phys.smsg.addr = vtophys (&cp->scsi_smsg ); - cp->phys.smsg.size = msglen; - cp->phys.smsg2.addr = vtophys (&cp->scsi_smsg2); - cp->phys.smsg2.size = msglen2; - /* - ** command - */ -#ifdef ANCIENT - bcopy (cmd, &cp->cmd, sizeof (cp->cmd)); - cp->phys.cmd.addr = vtophys (&cp->cmd); -#else /* ANCIENT */ - cp->phys.cmd.addr = vtophys (cmd); -#endif /* ANCIENT */ - cp->phys.cmd.size = xp->cmdlen; - /* - ** sense data - */ - cp->phys.sense.addr = vtophys (&cp->xfer->sense); - cp->phys.sense.size = sizeof(struct scsi_sense_data); - /* - ** status - */ - cp->actualquirks = tp->quirks; - cp->host_status = nego ? HS_NEGOTIATE : HS_BUSY; - cp->scsi_status = S_ILLEGAL; - cp->parity_status = 0; - - cp->xerr_status = XE_OK; - cp->sync_status = tp->sval; - cp->nego_status = nego; - cp->wide_status = tp->wval; - - /*---------------------------------------------------- - ** - ** Critical region: starting this job. - ** - **---------------------------------------------------- - */ - - oldspl = 0; /* for the sake of gcc */ - if (!(flags & SCSI_NOMASK)) oldspl = splbio(); - np->lock++; - - /* - ** reselect pattern and activate this job. - */ - - cp->jump_ccb.l_cmd = (SCR_JUMP ^ IFFALSE (DATA (cp->tag))); - cp->tlimit = time.tv_sec + xp->timeout / 1000 + 2; - cp->magic = CCB_MAGIC; - - /* - ** insert into startqueue. - */ - - ptr = np->squeueput + 1; - if (ptr >= MAX_START) ptr=0; - np->squeue [ptr ] = vtophys(&np->script->idle); - np->squeue [np->squeueput] = vtophys(&cp->phys); - np->squeueput = ptr; - - if(DEBUG_FLAGS & DEBUG_QUEUE) - printf ("%s: queuepos=%d tryoffset=%d.\n", ncr_name (np), - np->squeueput, - (unsigned)(np->script->startpos[0]- - (vtophys(&np->script->tryloop)))); - - /* - ** Script processor may be waiting for reconnect. - ** Wake it up. - */ - OUTB (nc_istat, SIGP); - - /* - ** If interrupts are enabled, return now. - ** Command is successfully queued. - */ - - np->lock--; - if (!(flags & SCSI_NOMASK)) { - splx (oldspl); - if (np->lasttime) { - if(DEBUG_FLAGS & DEBUG_TINY) printf ("Q"); - return(SUCCESSFULLY_QUEUED); - }; - }; - - /*---------------------------------------------------- - ** - ** Interrupts not yet enabled - have to poll. - ** - **---------------------------------------------------- - */ - - if (DEBUG_FLAGS & DEBUG_POLL) printf("P"); - - for (i=xp->timeout; i && !(xp->flags & ITSDONE);i--) { - if ((DEBUG_FLAGS & DEBUG_POLL) && (cp->host_status)) - printf ("%c", (cp->host_status & 0xf) + '0'); - DELAY (1000); - ncr_exception (np); - }; - - /* - ** Abort if command not done. - */ - if (!(xp->flags & ITSDONE)) { - printf ("%s: aborting job ...\n", ncr_name (np)); - OUTB (nc_istat, CABRT); - DELAY (100000); - OUTB (nc_istat, SIGP); - ncr_exception (np); - }; - - if (!(xp->flags & ITSDONE)) { - printf ("%s: abortion failed at %x.\n", - ncr_name (np), (unsigned) INL(nc_dsp)); - ncr_init (np, "timeout", HS_TIMEOUT); - }; - - if (!(xp->flags & ITSDONE)) { - cp-> host_status = HS_SEL_TIMEOUT; - ncr_complete (np, cp); - }; - - if (DEBUG_FLAGS & DEBUG_RESULT) { - printf ("%s: result: %x %x.\n", - ncr_name (np), cp->host_status, cp->scsi_status); - }; - if (!(flags & SCSI_NOMASK)) - return (SUCCESSFULLY_QUEUED); - switch (xp->error) { - case 0 : return (COMPLETE); - case XS_BUSY: return (TRY_AGAIN_LATER); - }; - return (HAD_ERROR); -} - -/*========================================================== -** -** -** Complete execution of a SCSI command. -** Signal completion to the generic SCSI driver. -** -** -**========================================================== -*/ - -void ncr_complete (ncb_p np, ccb_p cp) -{ - struct scsi_xfer * xp; - tcb_p tp; - lcb_p lp; - - /* - ** Sanity check - */ - - if (!cp || !cp->magic || !cp->xfer) return; - cp->magic = 1; - cp->tlimit= 0; - - /* - ** No Reselect anymore. - */ - cp->jump_ccb.l_cmd = (SCR_JUMP); - - /* - ** No starting. - */ - cp->phys.header.launch.l_paddr= vtophys (&np->script->idle); - - /* - ** timestamp - */ - ncb_profile (np, cp); - - if (DEBUG_FLAGS & DEBUG_TINY) - printf ("CCB=%x STAT=%x/%x\n", (unsigned)cp & 0xfff, - cp->host_status,cp->scsi_status); - - xp = cp->xfer; - cp->xfer = NULL; - tp = &np->target[xp->TARGET]; - lp = tp->lp[xp->LUN]; - - /* - ** Check for parity errors. - */ - - if (cp->parity_status) { - PRINT_ADDR(xp); - printf ("%d parity error(s), fallback.\n", cp->parity_status); - /* - ** fallback to asynch transfer. - */ - tp->usrsync=255; - tp->period = 0; - }; - - /* - ** Check for extended errors. - */ - - if (cp->xerr_status != XE_OK) { - PRINT_ADDR(xp); - switch (cp->xerr_status) { - case XE_EXTRA_DATA: - printf ("extraneous data discarded.\n"); - break; - case XE_BAD_PHASE: - printf ("illegal scsi phase (4/5).\n"); - break; - default: - printf ("extended error %d.\n", cp->xerr_status); - break; - }; - if (cp->host_status==HS_COMPLETE) - cp->host_status = HS_FAIL; - }; - - /* - ** Check the status. - */ - if ( (cp->host_status == HS_COMPLETE) - && (cp->scsi_status == S_GOOD)) { - - /* - ** All went well. - */ - - xp->resid = 0; - - /* - ** if (cp->phys.header.lastp != cp->phys.header.goalp)... - ** - ** @RESID@ - ** Could dig out the correct value for resid, - ** but it would be quite complicated. - ** - ** The ah1542.c driver sets it to 0 too ... - */ - - /* - ** Try to assign a ccb to this nexus - */ - ncr_alloc_ccb (np, xp); - - /* - ** On inquire cmd (0x12) save some data. - */ -#ifdef ANCIENT - if (cp->cmd.opcode == 0x12) { -#else /* ANCIENT */ - if (xp->cmd->opcode == 0x12) { -#endif /* ANCIENT */ - bcopy ( xp->data, - &tp->inqdata, - sizeof (tp->inqdata)); - - /* - ** set number of tags - */ - ncr_setmaxtags (tp, tp->usrtags); - - /* - ** prepare negotiation of synch and wide. - */ - ncr_negotiate (np, tp); - - /* - ** force quirks update before next command start - */ - tp->quirks |= QUIRK_UPDATE; - }; - - /* - ** Announce changes to the generic driver - */ - if (lp) { - ncr_settags (tp, lp); - if (lp->reqlink != lp->actlink) - ncr_opennings (np, lp, xp); - }; - -#ifdef DK - dk_xfer[DK] ++; - dk_wds [DK] += xp->datalen/64; - dk_wpms[DK] = 1000000; -#endif /* DK */ - - tp->bytes += xp->datalen; - tp->transfers ++; - - } else if (xp->flags & SCSI_ERR_OK) { - - /* - ** Not correct, but errors expected. - */ - xp->resid = 0; - - } else if ((cp->host_status == HS_COMPLETE) - && (cp->scsi_status == (S_SENSE|S_GOOD))) { - - /* - ** Check condition code - */ - xp->error = XS_SENSE; - - if (DEBUG_FLAGS & (DEBUG_RESULT|DEBUG_TINY)) { - u_char * p = (u_char*) & xp->sense; - int i; - printf ("\n%s: sense data:", ncr_name (np)); - for (i=0; i<14; i++) printf (" %x", *p++); - printf (".\n"); - }; - - } else if ((cp->host_status == HS_COMPLETE) - && (cp->scsi_status == S_BUSY)) { - - /* - ** Target is busy. - */ - xp->error = XS_BUSY; - - } else if ((cp->host_status == HS_SEL_TIMEOUT) - || (cp->host_status == HS_TIMEOUT)) { - - /* - ** No response - */ - xp->error = XS_TIMEOUT; - - } else { - - /* - ** Other protocol messes - */ - PRINT_ADDR(xp); - printf ("COMMAND FAILED (%x %x) @%x.\n", - cp->host_status, cp->scsi_status, (unsigned)cp); - - xp->error = XS_DRIVER_STUFFUP; - } - - xp->flags |= ITSDONE; - - /* - ** trace output - */ - - if (tp->usrflag & UF_TRACE) { - u_char * p; - int i; - PRINT_ADDR(xp); - printf (" CMD:"); -#ifdef ANCIENT - p = (u_char*) &cp->cmd.opcode; -#else /* ANCIENT */ - p = (u_char*) &xp->cmd->opcode; -#endif /* ANCIENT */ - for (i=0; i<xp->cmdlen; i++) printf (" %x", *p++); - - if (cp->host_status==HS_COMPLETE) { - switch (cp->scsi_status) { - case S_GOOD: - printf (" GOOD"); - break; - case S_CHECK_COND: - printf (" SENSE:"); - p = (u_char*) &xp->sense; -#ifdef ANCIENT - for (i=0; i<sizeof(xp->sense); i++) -#else /* ANCIENT */ - for (i=0; i<xp->req_sense_length; i++) -#endif /* ANCIENT */ - printf (" %x", *p++); - break; - default: - printf (" STAT: %x\n", cp->scsi_status); - break; - }; - } else printf (" HOSTERROR: %x", cp->host_status); - printf ("\n"); - }; - - /* - ** Free this ccb - */ - ncr_free_ccb (np, cp, xp->flags); - - /* - ** signal completion to generic driver. - */ -#ifdef ANCIENT - if (xp->when_done) - (*(xp->when_done))(xp->done_arg,xp->done_arg2); -#else /* ANCIENT */ - scsi_done (xp); -#endif /* ANCIENT */ -} - -/*========================================================== -** -** -** Signal all (or one) control block done. -** -** -**========================================================== -*/ - -void ncr_wakeup (ncb_p np, u_long code) -{ - /* - ** Starting at the default ccb and following - ** the links, complete all jobs with a - ** host_status greater than "disconnect". - ** - ** If the "code" parameter is not zero, - ** complete all jobs that are not IDLE. - */ - - int s=splbio(); - - ccb_p cp = &np->ccb; - while (cp) { - switch (cp->host_status) { - - case HS_IDLE: - break; - - case HS_DISCONNECT: - if(DEBUG_FLAGS & DEBUG_TINY) printf ("D"); - /* fall through */ - - case HS_BUSY: - case HS_NEGOTIATE: - if (!code) break; - cp->host_status = code; - - /* fall through */ - - default: - ncr_complete (np, cp); - break; - }; - cp = cp -> link_ccb; - }; - splx (s); -} - -/*========================================================== -** -** -** Start NCR chip. -** -** -**========================================================== -*/ - -void ncr_init (ncb_p np, char * msg, u_long code) -{ - int i; - u_long usrsync; - u_char usrwide; - - /* - ** Reset chip. - */ - - OUTB (nc_istat, SRST ); - - /* - ** Message. - */ - - if (msg) printf ("%s: restart (%s).\n", ncr_name (np), msg); - - /* - ** Clear Start Queue - */ - - for (i=0;i<MAX_START;i++) - np -> squeue [i] = vtophys (&np->script->idle); - - /* - ** Start at first entry. - */ - - np->squeueput = 0; - np->script->startpos[0] = vtophys (&np->script->tryloop); - np->script->start0 [0] = SCR_INT ^ IFFALSE (0); - - /* - ** Wakeup all pending jobs. - */ - - ncr_wakeup (np, code); - - /* - ** Init chip. - */ - - OUTB (nc_istat, 0 ); /* Remove Reset, abort ... */ - OUTB (nc_scntl0, 0xca ); /* full arb., ena parity, par->ATN */ - OUTB (nc_scntl1, 0x00 ); /* odd parity, and remove CRST!! */ - OUTB (nc_scntl3, np->rv_scntl3);/* timing prescaler */ - OUTB (nc_scid , 0x40|np->myaddr);/* host adapter SCSI address */ - OUTW (nc_respid, 1ul<<np->myaddr);/* id to respond to */ - OUTB (nc_istat , SIGP ); /* Signal Process */ - OUTB (nc_dmode , 0xc0 ); /* Burst length = 16 transfer */ - OUTB (nc_dcntl , NOCOM ); /* no single step mode, protect SFBR*/ - OUTB (nc_ctest4, 0x08 ); /* enable master parity checking */ - OUTB (nc_stest2, EXT ); /* Extended Sreq/Sack filtering */ - OUTB (nc_stest3, TE ); /* TolerANT enable */ - OUTB (nc_stime0, 0xfb ); /* HTH = 1.6sec STO = 0.1 sec. */ - - /* - ** Reinitialize usrsync. - ** Have to renegotiate synch mode. - */ - - usrsync = 255; - if (SCSI_NCR_MAX_SYNC) { - u_long period; - period =1000000/SCSI_NCR_MAX_SYNC; /* ns = 10e6 / kHz */ - if (period <= 11 * np->ns_sync) { - if (period < 4 * np->ns_sync) - usrsync = np->ns_sync; - else - usrsync = period / 4; - }; - }; - - /* - ** Reinitialize usrwide. - ** Have to renegotiate wide mode. - */ - - usrwide = (SCSI_NCR_MAX_WIDE); - if (usrwide > np->maxwide) usrwide=np->maxwide; - - /* - ** Fill in target structure. - */ - - for (i=0;i<MAX_TARGET;i++) { - tcb_p tp = &np->target[i]; - - tp->sval = 0; - tp->wval = np->rv_scntl3; - - tp->usrsync = usrsync; - tp->usrwide = usrwide; - - ncr_negotiate (np, tp); - } - - /* - ** enable ints - */ - - OUTW (nc_sien , STO|HTH|MA|SGE|UDC|RST); - OUTB (nc_dien , MDPE|BF|ABRT|SSI|SIR|IID); - - /* - ** Start script processor. - */ - - OUTL (nc_dsp, vtophys (&np->script->start)); -} - -/*========================================================== -** -** Prepare the negotiation values for wide and -** synchronous transfers. -** -**========================================================== -*/ - -static void ncr_negotiate (struct ncb* np, struct tcb* tp) -{ - /* - ** minsync unit is 4ns ! - */ - - u_long minsync = tp->usrsync; - - if (minsync < 25) minsync=25; - - /* - ** if not scsi 2 - ** don't believe FAST! - */ - - if ((minsync < 50) && (tp->inqdata[2] & 0x0f) < 2) - minsync=50; - - /* - ** our limit .. - */ - - if (minsync < np->ns_sync) - minsync = np->ns_sync; - - /* - ** divider limit - */ - - if (minsync > (np->ns_sync * 11) / 4) - minsync = 255; - - tp->minsync = minsync; - tp->maxoffs = (minsync<255 ? 8 : 0); - - /* - ** period=0: has to negotiate sync transfer - */ - - tp->period=0; - - /* - ** widedone=0: has to negotiate wide transfer - */ - tp->widedone=0; -} - -/*========================================================== -** -** Switch sync mode for current job and it's target -** -**========================================================== -*/ - -static void ncr_setsync (ncb_p np, ccb_p cp, u_char sxfer) -{ - struct scsi_xfer *xp; - tcb_p tp; - u_char target = INB (nc_ctest0)&7; - - assert (cp); - if (!cp) return; - - xp = cp->xfer; - assert (xp); - if (!xp) return; - assert (target == xp->TARGET & 7); - - tp = &np->target[target]; - tp->period= sxfer&0xf ? ((sxfer>>5)+4) * np->ns_sync : 0xffff; - - if (tp->sval == sxfer) return; - tp->sval = sxfer; - - /* - ** Bells and whistles ;-) - */ - PRINT_ADDR(xp); - if (sxfer & 0x0f) { - /* - ** Disable extended Sreq/Sack filtering - */ - if (tp->period <= 200) OUTB (nc_stest2, 0); - printf ("%s%dns (%d Mb/sec) offset %d.\n", - tp->period<200 ? "FAST SCSI-2 ":"", - tp->period, (1000+tp->period/2)/tp->period, - sxfer & 0x0f); - } else printf ("asynchronous.\n"); - - /* - ** set actual value and sync_status - */ - OUTB (nc_sxfer, sxfer); - np->sync_st = sxfer; - - /* - ** patch ALL ccbs of this target. - */ - for (cp = &np->ccb; cp; cp = cp->link_ccb) { - if (!cp->xfer) continue; - if (cp->xfer->TARGET != target) continue; - cp->sync_status = sxfer; - }; -} - -/*========================================================== -** -** Switch wide mode for current job and it's target -** -**========================================================== -*/ - -static void ncr_setwide (ncb_p np, ccb_p cp, u_char wide) -{ - struct scsi_xfer *xp; - u_short target = INB (nc_ctest0)&7; - tcb_p tp; - u_char scntl3 = np->rv_scntl3 | (wide ? EWS : 0); - - assert (cp); - if (!cp) return; - - xp = cp->xfer; - assert (xp); - if (!xp) return; - assert (target == xp->TARGET & 7); - - tp = &np->target[target]; - tp->widedone = wide+1; - if (tp->wval == scntl3) return; - tp->wval = scntl3; - - /* - ** Bells and whistles ;-) - */ - PRINT_ADDR(xp); - if (scntl3 & EWS) - printf ("WIDE SCSI (16 bit) enabled.\n"); - else - printf ("WIDE SCSI disabled.\n"); - - /* - ** set actual value and sync_status - */ - OUTB (nc_scntl3, scntl3); - np->wide_st = scntl3; - - /* - ** patch ALL ccbs of this target. - */ - for (cp = &np->ccb; cp; cp = cp->link_ccb) { - if (!cp->xfer) continue; - if (cp->xfer->TARGET != target) continue; - cp->wide_status = scntl3; - }; -} - -/*========================================================== -** -** Switch tagged mode for a target. -** -**========================================================== -*/ - -static void ncr_setmaxtags (tcb_p tp, u_long usrtags) -{ - int l; - tp->usrtags = usrtags; - for (l=0; l<MAX_LUN; l++) { - lcb_p lp; - if (!tp) break; - lp=tp->lp[l]; - if (!lp) continue; - ncr_settags (tp, lp); - }; -} - -static void ncr_settags (tcb_p tp, lcb_p lp) -{ - u_char reqtags, tmp; - - if ((!tp) || (!lp)) return; - - /* - ** only devices capable of tagges commands - ** only disk devices - ** only if enabled by user .. - */ - if (( tp->inqdata[7] & INQ7_QUEUE) && ((tp->inqdata[0] & 0x1f)==0x00) - && tp->usrtags) { - reqtags = tp->usrtags; - if (lp->actlink <= 1) - lp->usetags=reqtags; - } else { - reqtags = 1; - if (lp->actlink <= 1) - lp->usetags=0; - }; - - /* - ** don't announce more than available. - */ - tmp = lp->actccbs; - if (tmp > reqtags) tmp = reqtags; - lp->reqlink = tmp; - - /* - ** don't discard if announced. - */ - tmp = lp->actlink; - if (tmp < reqtags) tmp = reqtags; - lp->reqccbs = tmp; -} - -/*---------------------------------------------------- -** -** handle user commands -** -**---------------------------------------------------- -*/ - -static void ncr_usercmd (ncb_p np) -{ - u_char t; - tcb_p tp; - - switch (np->user.cmd) { - - case 0: return; - - case UC_SETSYNC: - for (t=0; t<MAX_TARGET; t++) { - if (!((np->user.target>>t)&1)) continue; - tp = &np->target[t]; - tp->usrsync = np->user.data; - ncr_negotiate (np, tp); - }; - break; - - case UC_SETTAGS: - if (np->user.data > MAX_TAGS) - break; - for (t=0; t<MAX_TARGET; t++) { - if (!((np->user.target>>t)&1)) continue; - ncr_setmaxtags (&np->target[t], np->user.data); - }; - break; - - case UC_SETDEBUG: - ncr_debug = np->user.data; - break; - - case UC_SETORDER: - np->order = np->user.data; - break; - - case UC_SETWIDE: - for (t=0; t<MAX_TARGET; t++) { - u_long size; - if (!((np->user.target>>t)&1)) continue; - tp = &np->target[t]; - size = np->user.data; - if (size > np->maxwide) size=np->maxwide; - tp->usrwide = size; - ncr_negotiate (np, tp); - }; - break; - - case UC_SETFLAG: - for (t=0; t<MAX_TARGET; t++) { - if (!((np->user.target>>t)&1)) continue; - tp = &np->target[t]; - tp->usrflag = np->user.data; - }; - break; - } - np->user.cmd=0; -} - - - - -/*========================================================== -** -** -** ncr timeout handler. -** -** -**========================================================== -** -** Misused to keep the driver running when -** interrupts are not configured correctly. -** -**---------------------------------------------------------- -*/ - -static void ncr_timeout (ncb_p np) -{ - u_long thistime = time.tv_sec; - u_long step = np->ticks; - u_long count = 0; - long signed t; - ccb_p cp; - - if (np->lasttime != thistime) { - np->lasttime = thistime; - - ncr_usercmd (np); - - /*---------------------------------------------------- - ** - ** handle ncr chip timeouts - ** - ** Assumption: - ** We have a chance to arbitrate for the - ** SCSI bus at least every 10 seconds. - ** - **---------------------------------------------------- - */ - - t = thistime - np->heartbeat; - - if (t<2) np->latetime=0; else np->latetime++; - - if (np->latetime>2) { - /* - ** If there are no requests, the script - ** processor will sleep on SEL_WAIT_RESEL. - ** But we have to check whether it died. - ** Let's wake it up. - */ - OUTB (nc_istat, SIGP); - }; - - if (np->latetime>10) { - /* - ** Although we tried to wakeup it, - ** the script processor didn't answer. - ** - ** May be a target is hanging, - ** or another initator lets a tape device - ** rewind with disconnect disabled :-( - ** - ** We won't accept that. - */ - printf ("%s: reset by timeout.\n", ncr_name (np)); - OUTB (nc_istat, SRST); - OUTB (nc_istat, 0); - if (INB (nc_sbcl) & CBSY) - OUTB (nc_scntl1, CRST); - ncr_init (np, NULL, HS_TIMEOUT); - np->heartbeat = thistime; - }; - - /*---------------------------------------------------- - ** - ** handle ccb timeouts - ** - **---------------------------------------------------- - */ - - for (cp=&np->ccb; cp; cp=cp->link_ccb) { - /* - ** look for timed out ccbs. - */ - if (!cp->host_status) continue; - count++; - if (cp->tlimit > thistime) continue; - - /* - ** Disable reselect. - ** Remove it from startqueue. - */ - cp->jump_ccb.l_cmd = (SCR_JUMP); - if (cp->phys.header.launch.l_paddr == - vtophys (&np->script->select)) { - printf ("%s: timeout ccb=%x (skip)\n", - ncr_name (np), (unsigned)cp); - cp->phys.header.launch.l_paddr - = vtophys (&np->script->skip); - }; - - switch (cp->host_status) { - - case HS_BUSY: - case HS_NEGOTIATE: - /* - ** still in start queue ? - */ - if (cp->phys.header.launch.l_paddr == - vtophys (&np->script->skip)) - continue; - - /* fall through */ - case HS_DISCONNECT: - cp->host_status=HS_TIMEOUT; - }; - cp->tag = 0; - - /* - ** wakeup this ccb. - */ - { - int oldspl = splbio(); - ncr_complete (np, cp); - splx (oldspl); - }; - }; - } - - timeout (TIMEOUT ncr_timeout, (caddr_t) np, step ? step : 1); - - if ((INB(nc_istat) & (INTF|SIP|DIP)) && !np->lock) { - - /* - ** Process pending interrupts. - */ - - int oldspl = splbio (); - if (DEBUG_FLAGS & DEBUG_TINY) printf ("{"); - ncr_exception (np); - if (DEBUG_FLAGS & DEBUG_TINY) printf ("}"); - splx (oldspl); - }; -} - -/*========================================================== -** -** -** ncr chip exception handler. -** -** -**========================================================== -*/ - -void ncr_exception (ncb_p np) -{ - u_char istat, dstat; - u_short sist; - u_long dsp; - - /* - ** interrupt on the fly ? - */ - while ((istat = INB (nc_istat)) & INTF) { - if (DEBUG_FLAGS & DEBUG_TINY) printf ("F"); - OUTB (nc_istat, INTF); - np->profile.num_fly++; - ncr_wakeup (np, 0); - }; - - if (!(istat & (SIP|DIP))) return; - - /* - ** Steinbach's Guideline for Systems Programming: - ** Never test for an error condition you don't know how to handle. - */ - - dstat = INB (nc_dstat); - sist = INW (nc_sist) ; - np->profile.num_int++; - - if (DEBUG_FLAGS & DEBUG_TINY) - printf ("<%d|%x:%x|%x:%x>", - INB(nc_scr0), - dstat,sist, - (unsigned)INL(nc_dsp), - (unsigned)INL(nc_dbc)); - if ((dstat==DFE) && (sist==PAR)) return; - -/*========================================================== -** -** First the normal cases. -** -**========================================================== -*/ - /*------------------------------------------- - ** SCSI reset - **------------------------------------------- - */ - - if (sist & RST) { - ncr_init (np, "scsi reset", HS_RESET); - return; - }; - - /*------------------------------------------- - ** selection timeout - ** - ** IID excluded from dstat mask! - ** (chip bug) - **------------------------------------------- - */ - - if ((sist & STO) && - !(sist & (GEN|HTH|MA|SGE|UDC|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|SIR))) { - ncr_int_sto (np); - return; - }; - - /*------------------------------------------- - ** Phase mismatch. - **------------------------------------------- - */ - - if ((sist & MA) && - !(sist & (STO|GEN|HTH|SGE|UDC|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|SIR|IID))) { - ncr_int_ma (np); - return; - }; - - /*---------------------------------------- - ** move command with length 0 - **---------------------------------------- - */ - - if ((dstat & IID) && - !(sist & (STO|GEN|HTH|MA|SGE|UDC|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|SIR)) && - ((INL(nc_dbc) & 0xf8000000) == SCR_MOVE_TBL)) { - /* - ** Target wants more data than available. - ** The "no_data" script will do it. - */ - OUTL (nc_dsp, vtophys(&np->script->no_data)); - return; - }; - - /*------------------------------------------- - ** Programmed interrupt - **------------------------------------------- - */ - - if ((dstat & SIR) && - !(sist & (STO|GEN|HTH|MA|SGE|UDC|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|IID)) && - (INB(nc_dsps) <= SIR_MAX)) { - ncr_int_sir (np); - return; - }; - - /*======================================== - ** do the register dump - **======================================== - */ - - if (time.tv_sec - np->regtime.tv_sec>10) { - int i; - np->regtime = time; - for (i=0; i<sizeof(np->regdump); i++) - ((char*)&np->regdump)[i] = ((char*)np->reg)[i]; - np->regdump.nc_dstat = dstat; - np->regdump.nc_sist = sist; - }; - - printf ("%s targ %d?: ERROR (%x:%x:%x) (%x/%x) @ (%x:%x).\n", - ncr_name (np), INB (nc_ctest0)&7, dstat, sist, - INB (nc_sbcl), - INB (nc_sxfer),INB (nc_scntl3), - (unsigned) (dsp = INL (nc_dsp)), - (unsigned) INL (nc_dbc)); - - /*---------------------------------------- - ** clean up the dma fifo - **---------------------------------------- - */ - - if ( (INB(nc_sstat0) & (ILF|ORF|OLF) ) || - (INB(nc_sstat1) & (FF3210) ) || - (INB(nc_sstat2) & (ILF1|ORF1|OLF1)) || /* wide .. */ - !(dstat & DFE)) { - printf ("%s: have to clear fifos.\n", ncr_name (np)); - OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */ - OUTB (nc_ctest3, CLF); /* clear dma fifo */ - } - - /*---------------------------------------- - ** unexpected disconnect - **---------------------------------------- - */ - - if ((sist & UDC) && - !(sist & (STO|GEN|HTH|MA|SGE|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|SIR|IID))) { - OUTB (nc_scr0, HS_UNEXPECTED); - OUTL (nc_dsp, vtophys(&np->script->cleanup)); - return; - }; - - /*---------------------------------------- - ** cannot disconnect - **---------------------------------------- - */ - - if ((dstat & IID) && - !(sist & (STO|GEN|HTH|MA|SGE|UDC|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|SIR)) && - ((INL(nc_dbc) & 0xf8000000) == SCR_WAIT_DISC)) { - /* - ** Data cycles while waiting for disconnect. - ** Force disconnect. - */ - OUTB (nc_scntl1, 0); - /* - ** System may hang, but timeout will handle that. - ** In fact, timeout can handle ALL problems :-) - */ - OUTB (nc_dcntl, (STD|NOCOM)); - return; - }; - - /*---------------------------------------- - ** single step - **---------------------------------------- - */ - - if ((dstat & SSI) && - !(sist & (STO|GEN|HTH|MA|SGE|UDC|RST|PAR)) && - !(dstat & (MDPE|BF|ABRT|SIR|IID))) { - OUTB (nc_dcntl, (STD|NOCOM)); - return; - }; - -/* -** @RECOVER@ HTH, SGE, ABRT. -** -** We should try to recover from these interrupts. -** They may occur if there are problems with synch transfers, -** or if targets are powerswitched while the driver is running. -*/ - - if (sist & SGE) { - OUTB (nc_ctest3, CLF); /* clear scsi offsets */ - } - - /* - ** Freeze controller to be able to read the messages. - */ - - if (DEBUG_FLAGS & DEBUG_FREEZE) { - int i; - unsigned char val; - for (i=0; i<0x60; i++) { - switch (i%16) { - - case 0: - printf ("%s: reg[%d0]: ", - ncr_name(np),i/16); - break; - case 4: - case 8: - case 12: - printf (" "); - break; - }; - val = ((unsigned char*) np->vaddr) [i]; - printf (" %x%x", val/16, val%16); - if (i%16==15) printf (".\n"); - }; - - untimeout (TIMEOUT ncr_timeout, (caddr_t) np); - - printf ("%s: halted!\n", ncr_name(np)); - /* - ** don't restart controller ... - */ - OUTB (nc_istat, SRST); - return; - }; - - /* - ** sorry, have to kill ALL jobs ... - */ - - ncr_init (np, "fatal error", HS_FAIL); -} - -/*========================================================== -** -** ncr chip exception handler for selection timeout -** -**========================================================== -** -** There seems to be a bug in the 53c810. -** Although a STO-interrupt is pending, -** it continues executing script commands. -** But it will fail and interrupt (IID) on -** the next instruction where it's looking -** for a valid phase. -** -**---------------------------------------------------------- -*/ - -void ncr_int_sto (ncb_p np) -{ - u_long dsa, scratcha, diff; - ccb_p cp; - if (DEBUG_FLAGS & DEBUG_TINY) printf ("T"); - - /* - ** look for ccb and set the status. - */ - - dsa = INL (nc_dsa); - cp = &np->ccb; - while (cp && (vtophys(&cp->phys) != dsa)) - cp = cp->link_ccb; - - if (cp) { - cp-> host_status = HS_SEL_TIMEOUT; - ncr_complete (np, cp); - }; - - /* - ** repair start queue - */ - - scratcha = INL (nc_scratcha); - diff = scratcha - vtophys(&np->script->tryloop); - - assert ((diff <= MAX_START * 20) && !(diff % 20)); - - if ((diff <= MAX_START * 20) && !(diff % 20)) { - np->script->startpos[0] = scratcha; - OUTL (nc_dsp, vtophys (&np->script->start)); - return; - }; - ncr_init (np, "selection timeout", HS_FAIL); -} - -/*========================================================== -** -** -** ncr chip exception handler for phase errors. -** -** -**========================================================== -** -** We have to construct a new transfer descriptor, -** to transfer the rest of the current block. -** -**---------------------------------------------------------- -*/ - -static void ncr_int_ma (ncb_p np) -{ - u_long dbc; - u_long rest; - u_long dsa; - u_long dsp; - u_long nxtdsp; - u_long *vdsp; - u_long oadr, olen; - u_long *tblp, *newcmd; - u_char cmd, sbcl, delta, ss0, ss2; - ccb_p cp; - - dsp = INL (nc_dsp); - dsa = INL (nc_dsa); - dbc = INL (nc_dbc); - ss0 = INB (nc_sstat0); - ss2 = INB (nc_sstat2); - sbcl= INB (nc_sbcl); - - cmd = dbc >> 24; - rest= dbc & 0xffffff; - delta=(INB (nc_dfifo) - rest) & 0x7f; - - /* - ** The data in the dma fifo has not been transfered to - ** the target -> add the amount to the rest - ** and clear the data. - ** Check the sstat2 register in case of wide transfer. - */ - - if (! (INB(nc_dstat) & DFE)) rest += delta; - if (ss0 & OLF) rest++; - if (ss0 & ORF) rest++; - if (INB(nc_scntl3) & EWS) { - if (ss2 & OLF1) rest++; - if (ss2 & ORF1) rest++; - }; - OUTB (nc_ctest3, CLF ); /* clear dma fifo */ - OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */ - - /* - ** verify cp - */ - dsa = INL (nc_dsa); - cp = &np->ccb; - while (cp && (vtophys(&cp->phys) != dsa)) - cp = cp->link_ccb; - - assert (cp == np->header.cp); - assert (cp); - if (!cp) - return; - - /* - ** find the interrupted script command, - ** and the address at where to continue. - */ - - if (dsp == vtophys (&cp->patch[2])) { - vdsp = &cp->patch[0]; - nxtdsp = vdsp[3]; - } else if (dsp == vtophys (&cp->patch[6])) { - vdsp = &cp->patch[4]; - nxtdsp = vdsp[3]; - } else { - vdsp = (u_long*) ((char*)np->script - vtophys(np->script) + dsp -8); - nxtdsp = dsp; - }; - - /* - ** log the information - */ - if (DEBUG_FLAGS & (DEBUG_TINY|DEBUG_PHASE)) { - printf ("P%d%d ",cmd&7, sbcl&7); - printf ("RL=%d D=%d SS0=%x ", - (unsigned) rest, (unsigned) delta, ss0); - }; - if (DEBUG_FLAGS & DEBUG_PHASE) { - printf ("\nCP=%x CP2=%x DSP=%x NXT=%x VDSP=%x CMD=%x ", - (unsigned)cp, (unsigned)np->header.cp, - (unsigned)dsp, - (unsigned)nxtdsp, (unsigned)vdsp, cmd); - }; - - /* - ** get old startaddress and old length. - */ - - oadr = vdsp[1]; - - if (cmd & 0x10) { /* Table indirect */ - tblp = (u_long*) ((char*) &cp->phys + oadr); - olen = tblp[0]; - oadr = tblp[1]; - } else { - tblp = (u_long*) 0; - olen = vdsp[0] & 0xffffff; - }; - - if (DEBUG_FLAGS & DEBUG_PHASE) { - printf ("OCMD=%x\nTBLP=%x OLEN=%x OADR=%x\n", - (unsigned) (vdsp[0] >> 24), - (unsigned) tblp, - (unsigned) olen, - (unsigned) oadr); - }; - - /* - ** if old phase not dataphase, leave here. - */ - - assert (cmd == (vdsp[0] >> 24)); - if (cmd & 0x06) { - PRINT_ADDR(cp->xfer); - printf ("phase change %d-%d %d@%x resid=%d.\n", - cmd&7, sbcl&7, (unsigned)olen, - (unsigned)oadr, (unsigned)rest); - - OUTB (nc_dcntl, (STD|NOCOM)); - return; - }; - - /* - ** choose the correct patch area. - ** if savep points to one, choose the other. - */ - - newcmd = cp->patch; - if (cp->phys.header.savep == vtophys (newcmd)) newcmd+=4; - - /* - ** fillin the commands - */ - - newcmd[0] = ((cmd & 0x0f) << 24) | rest; - newcmd[1] = oadr + olen - rest; - newcmd[2] = SCR_JUMP; - newcmd[3] = nxtdsp; - - if (DEBUG_FLAGS & DEBUG_PHASE) { - PRINT_ADDR(cp->xfer); - printf ("newcmd[%d] %x %x %x %x.\n", - newcmd - cp->patch, - (unsigned)newcmd[0], - (unsigned)newcmd[1], - (unsigned)newcmd[2], - (unsigned)newcmd[3]); - } - /* - ** fake the return address (to the patch). - ** and restart script processor at dispatcher. - */ - np->profile.num_break++; - OUTL (nc_temp, vtophys (newcmd)); - OUTL (nc_dsp, vtophys (&np->script->dispatch)); -} - -/*========================================================== -** -** -** ncr chip exception handler for programmed interrupts. -** -** -**========================================================== -*/ - -static int ncr_show_msg (u_char * msg) -{ - u_char i; - printf ("%x",*msg); - if (*msg==M_EXTENDED) { - for (i=1;i<8;i++) { - if (i-1>msg[1]) break; - printf ("-%x",msg[i]); - }; - return (i+1); - } else if ((*msg & 0xf0) == 0x20) { - printf ("-%x",msg[1]); - return (2); - }; - return (1); -} - -void ncr_int_sir (ncb_p np) -{ - u_char chg, ofs, per, fak, wide; - u_char num = INB (nc_dsps); - ccb_p cp=0; - u_long dsa; - u_char target = INB (nc_ctest0) & 7; - tcb_p tp = &np->target[target]; - int i; - if (DEBUG_FLAGS & DEBUG_TINY) printf ("I#%d", num); - - switch (num) { - case SIR_SENSE_RESTART: - case SIR_STALL_RESTART: - break; - - default: - /* - ** lookup the ccb - */ - dsa = INL (nc_dsa); - cp = &np->ccb; - while (cp && (vtophys(&cp->phys) != dsa)) - cp = cp->link_ccb; - - assert (cp == np->header.cp); - assert (cp); - if (!cp) - goto out; - } - - switch (num) { - -/*-------------------------------------------------------------------- -** -** Processing of interrupted getcc selects -** -**-------------------------------------------------------------------- -*/ - - case SIR_SENSE_RESTART: - /*------------------------------------------ - ** Script processor is idle. - ** Look for interrupted "check cond" - **------------------------------------------ - */ - - if (DEBUG_FLAGS & DEBUG_RESTART) - printf ("%s: int#%d",ncr_name (np),num); - cp = (ccb_p) 0; - for (i=0; i<MAX_TARGET; i++) { - if (DEBUG_FLAGS & DEBUG_RESTART) printf (" t%d", i); - tp = &np->target[i]; - if (DEBUG_FLAGS & DEBUG_RESTART) printf ("+"); - cp = tp->hold_cp; - if (!cp) continue; - if (DEBUG_FLAGS & DEBUG_RESTART) printf ("+"); - if ((cp->host_status==HS_BUSY) && - (cp->scsi_status==S_CHECK_COND)) - break; - if (DEBUG_FLAGS & DEBUG_RESTART) printf ("- (remove)"); - tp->hold_cp = cp = (ccb_p) 0; - }; - - if (cp) { - if (DEBUG_FLAGS & DEBUG_RESTART) - printf ("+ restart job ..\n"); - OUTL (nc_dsa, vtophys (&cp->phys)); - OUTL (nc_dsp, vtophys (&np->script->getcc)); - return; - }; - - /* - ** no job, resume normal processing - */ - if (DEBUG_FLAGS & DEBUG_RESTART) printf (" -- remove trap\n"); - np->script->start0[0] = SCR_INT ^ IFFALSE (0); - break; - - case SIR_SENSE_FAILED: - /*------------------------------------------- - ** While trying to reselect for - ** getting the condition code, - ** a target reselected us. - **------------------------------------------- - */ - PRINT_ADDR(cp->xfer); - if (DEBUG_FLAGS & DEBUG_RESTART) - printf ("in getcc reselect by t%d.\n", - INB(nc_ssid)&7); - - /* - ** Mark this job - */ - cp->host_status = HS_BUSY; - cp->scsi_status = S_CHECK_COND; - np->target[cp->xfer->TARGET].hold_cp = cp; - - /* - ** And patch code to restart it. - */ - np->script->start0[0] = SCR_INT; - break; - -/*----------------------------------------------------------------------------- -** -** Was Sie schon immer ueber transfermode negotiation wissen wollten ... -** -** We try to negotiate sync and wide transfer only after -** a successfull inquire command. We look to byte 7 of the -** inquire data to determine the capabilities if the target. -** -** When we try to negotiate, we append the negotiation message -** to the identify and (maybe) simpletag message. -** The host status field is set to HS_NEGOTIATE to mark this -** situation. -** -** If the target doesn't answer this message immidiately -** (as required by the standard), the SIR_NEGO_FAIL interrupt -** will be raised eventually. -** The handler removes the HS_NEGOTIATE status, and sets the -** negotiated value to the default (async / nowide). -** -** If we receive a matching answer immediately, we check it -** for validity, and set the values. -** -** If we receive a Reject message immediately, we assume the -** negotiation has failed, and set to the standard values. -** -** If we receive a negotiation message while not in HS_NEGOTIATE -** state, it's a target initiated negotiation. We prepare a -** (hopefully) valid answer, set the values, and send this -** answer back to the target. -** -** If the target doesn't fetch the answer (no message out phase), -** we assume the negotiation has failed, and set the values to -** the default. -** -** When we set the values, we set in all ccbs belonging to this -** target, in the controllers register, and in the "phys" -** field of the controllers struct ncb. -** -** Possible cases: hs sir msg_in value send goto -** We try try to negotiate: -** -> target doesnt't msgin NEG FAIL noop defa. - dispatch -** -> target rejected our msg NEG FAIL reject defa. - dispatch -** -> target answered (ok) NEG SYNC sdtr set - clrack -** -> target answered (!ok) NEG SYNC sdtr defa. REJ--->msg_bad -** -> target answered (ok) NEG WIDE wdtr set - clrack -** -> target answered (!ok) NEG WIDE wdtr defa. REJ--->msg_bad -** -> any other msgin NEG FAIL noop defa - dispatch -** -** Target tries to negotiate: -** -> incoming message --- SYNC sdtr set SDTR - -** -> incoming message --- WIDE wdtr set WDTR - -** We sent our answer: -** -> target doesn't msgout --- PROTO ? defa. - dispatch -** -**----------------------------------------------------------------------------- -*/ - - case SIR_NEGO_FAILED: - /*------------------------------------------------------- - ** - ** Negotiation failed. - ** Target doesn't send an answer message, - ** or target rejected our message. - ** - ** Remove negotiation request. - ** - **------------------------------------------------------- - */ - OUTB (HS_PRT, HS_BUSY); - - /* fall through */ - - case SIR_NEGO_PROTO: - /*------------------------------------------------------- - ** - ** Negotiation failed. - ** Target doesn't fetch the answer message. - ** - **------------------------------------------------------- - */ - - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("negotiation failed sir=%x status=%x.\n", - num, cp->nego_status); - }; - - /* - ** any error in negotiation: - ** fall back to default mode. - */ - switch (cp->nego_status) { - - case NS_SYNC: - ncr_setsync (np, cp, 0xe0); - break; - - case NS_WIDE: - ncr_setwide (np, cp, 0); - break; - - }; - np->msgin [0] = M_NOOP; - np->msgout[0] = M_NOOP; - cp->nego_status = 0; - OUTL (nc_dsp,vtophys (&np->script->dispatch)); - break; - - case SIR_NEGO_SYNC: - /* - ** Synchronous request message received. - */ - - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("sync msgin: "); - (void) ncr_show_msg (np->msgin); - printf (".\n"); - }; - - /* - ** get requested values. - */ - - chg = 0; - per = np->msgin[3]; - ofs = np->msgin[4]; - if (ofs==0) per=255; - - /* - ** if target sends SDTR message, - ** it CAN transfer synch. - */ - - if (ofs) - tp->inqdata[7] |= INQ7_SYNC; - - /* - ** check values against driver limits. - */ - - if (per < np->ns_sync) - {chg = 1; per = np->ns_sync;} - if (per < tp->minsync) - {chg = 1; per = tp->minsync;} - if (ofs > tp->maxoffs) - {chg = 1; ofs = tp->maxoffs;} - - /* - ** Check against controller limits. - */ - fak = (4ul * per - 1) / np->ns_sync - 3; - if (ofs && (fak>7)) {chg = 1; ofs = 0;} - if (!ofs) fak=7; - - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("sync: per=%d ofs=%d fak=%d chg=%d.\n", - per, ofs, fak, chg); - } - - if (INB (HS_PRT) == HS_NEGOTIATE) { - OUTB (HS_PRT, HS_BUSY); - switch (cp->nego_status) { - - case NS_SYNC: - /* - ** This was an answer message - */ - if (chg) { - /* - ** Answer wasn't acceptable. - */ - ncr_setsync (np, cp, 0xe0); - OUTL (nc_dsp,vtophys (&np->script->msg_bad)); - } else { - /* - ** Answer is ok. - */ - ncr_setsync (np, cp, (fak<<5)|ofs); - OUTL (nc_dsp,vtophys (&np->script->clrack)); - }; - return; - - case NS_WIDE: - ncr_setwide (np, cp, 0); - break; - }; - }; - - /* - ** It was a request. Set value and - ** prepare an answer message - */ - - ncr_setsync (np, cp, (fak<<5)|ofs); - - np->msgout[0] = M_EXTENDED; - np->msgout[1] = 3; - np->msgout[2] = M_X_SYNC_REQ; - np->msgout[3] = per; - np->msgout[4] = ofs; - - np->msgin [0] = M_NOOP; - - cp->nego_status = NS_SYNC; - - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("sync msgout: "); - (void) ncr_show_msg (np->msgin); - printf (".\n"); - } - break; - - case SIR_NEGO_WIDE: - /* - ** Wide request message received. - */ - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("wide msgin: "); - (void) ncr_show_msg (np->msgin); - printf (".\n"); - }; - - /* - ** get requested values. - */ - - chg = 0; - wide = np->msgin[3]; - - /* - ** if target sends WDTR message, - ** it CAN transfer wide. - */ - - if (wide) - tp->inqdata[7] |= INQ7_WIDE16; - - /* - ** check values against driver limits. - */ - - if (wide > tp->usrwide) - {chg = 1; wide = tp->usrwide;} - - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("wide: wide=%d chg=%d.\n", wide, chg); - } - - if (INB (HS_PRT) == HS_NEGOTIATE) { - OUTB (HS_PRT, HS_BUSY); - switch (cp->nego_status) { - - case NS_WIDE: - /* - ** This was an answer message - */ - if (chg) { - /* - ** Answer wasn't acceptable. - */ - ncr_setwide (np, cp, 0); - OUTL (nc_dsp,vtophys (&np->script->msg_bad)); - } else { - /* - ** Answer is ok. - */ - ncr_setwide (np, cp, wide); - OUTL (nc_dsp,vtophys (&np->script->clrack)); - }; - return; - - case NS_SYNC: - ncr_setsync (np, cp, 0xe0); - break; - }; - }; - - /* - ** It was a request, set value and - ** prepare an answer message - */ - - ncr_setwide (np, cp, wide); - - np->msgout[0] = M_EXTENDED; - np->msgout[1] = 2; - np->msgout[2] = M_X_WIDE_REQ; - np->msgout[3] = wide; - - np->msgin [0] = M_NOOP; - - cp->nego_status = NS_WIDE; - - if (DEBUG_FLAGS & DEBUG_NEGO) { - PRINT_ADDR(cp->xfer); - printf ("wide msgout: "); - (void) ncr_show_msg (np->msgin); - printf (".\n"); - } - break; - -/*-------------------------------------------------------------------- -** -** Processing of special messages -** -**-------------------------------------------------------------------- -*/ - - case SIR_REJECT_RECEIVED: - /*----------------------------------------------- - ** - ** We received a M_REJECT message. - ** - **----------------------------------------------- - */ - - PRINT_ADDR(cp->xfer); - printf ("M_REJECT received (%x:%x).\n", - (unsigned)np->lastmsg, np->msgout[0]); - break; - - case SIR_REJECT_SENT: - /*----------------------------------------------- - ** - ** We received an unknown message - ** - **----------------------------------------------- - */ - - PRINT_ADDR(cp->xfer); - printf ("M_REJECT sent for "); - (void) ncr_show_msg (np->msgin); - printf (".\n"); - break; - -/*-------------------------------------------------------------------- -** -** Processing of special messages -** -**-------------------------------------------------------------------- -*/ - - case SIR_IGN_RESIDUE: - /*----------------------------------------------- - ** - ** We received an IGNORE RESIDUE message, - ** which couldn't be handled by the script. - ** - **----------------------------------------------- - */ - - PRINT_ADDR(cp->xfer); - printf ("M_IGN_RESIDUE received, but not yet implemented.\n"); - break; - - case SIR_MISSING_SAVE: - /*----------------------------------------------- - ** - ** We received an DISCONNECT message, - ** but the datapointer wasn't saved before. - ** - **----------------------------------------------- - */ - - PRINT_ADDR(cp->xfer); - printf ("M_DISCONNECT received, but datapointer not saved:\n" - "\tdata=%x save=%x goal=%x.\n", - (unsigned) INL (nc_temp), - (unsigned) np->header.savep, - (unsigned) np->header.goalp); - break; - -/*-------------------------------------------------------------------- -** -** Processing of a "S_QUEUE_FULL" status. -** -** The current command has been rejected, -** because there are too many in the command queue. -** We have started too many commands for that target. -** -** If possible, reinsert at head of queue. -** Stall queue until there are no disconnected jobs -** (ncr is REALLY idle). Then restart processing. -** -** We should restart the current job after the controller -** has become idle. But this is not yet implemented. -** -**-------------------------------------------------------------------- -*/ - case SIR_STALL_QUEUE: - /*----------------------------------------------- - ** - ** Stall the start queue. - ** - **----------------------------------------------- - */ - PRINT_ADDR(cp->xfer); - printf ("queue full.\n"); - - np->script->start1[0] = SCR_INT; - - /* - ** Try to disable tagged transfers. - */ - ncr_setmaxtags (&np->target[target], 0); - - /* - ** @QUEUE@ - ** - ** Should update the launch field of the - ** current job to be able to restart it. - ** Then prepend it to the start queue. - */ - - /* fall through */ - - case SIR_STALL_RESTART: - /*----------------------------------------------- - ** - ** Enable selecting again, - ** if NO disconnected jobs. - ** - **----------------------------------------------- - */ - /* - ** Look for a disconnected job. - */ - cp = &np->ccb; - while (cp && cp->host_status != HS_DISCONNECT) - cp = cp->link_ccb; - - /* - ** if there is one, ... - */ - if (cp) { - /* - ** wait for reselection - */ - OUTL (nc_dsp, vtophys (&np->script->reselect)); - return; - }; - - /* - ** else remove the interrupt. - */ - - printf ("%s: queue empty.\n", ncr_name (np)); - np->script->start1[0] = SCR_INT ^ IFFALSE (0); - break; - }; - -out: - OUTB (nc_dcntl, (STD|NOCOM)); -} - -/*========================================================== -** -** -** Aquire a control block -** -** -**========================================================== -*/ - -static ccb_p ncr_get_ccb - (ncb_p np, u_long flags, u_long target, u_long lun) -{ - lcb_p lp; - ccb_p cp = (ccb_p ) 0; - - /* - ** Lun structure available ? - */ - - lp = np->target[target].lp[lun]; - if (lp) - cp = lp->next_ccb; - - /* - ** Look for free CCB - */ - - while (cp && cp->magic) cp = cp->next_ccb; - - /* - ** if nothing available, take the default. - */ - - if (!cp) cp = &np->ccb; - - /* - ** Wait until available. - */ - - while (cp->magic) { - if (flags & SCSI_NOSLEEP) break; - if (tsleep ((caddr_t)cp, PZERO|PCATCH, "ncr", 0)) - break; - }; - - if (cp->magic) - return ((ccb_p) 0); - - cp->magic = 1; - return (cp); -} - -/*========================================================== -** -** -** Release one control block -** -** -**========================================================== -*/ - -void ncr_free_ccb (ncb_p np, ccb_p cp, int flags) -{ - /* - ** sanity - */ - - if (!cp) return; - - cp -> host_status = HS_IDLE; - cp -> magic = 0; - if (cp == &np->ccb) - wakeup ((caddr_t) cp); -} - -/*========================================================== -** -** -** Allocation of resources for Targets/Luns/Tags. -** -** -**========================================================== -*/ - -static void ncr_alloc_ccb (ncb_p np, struct scsi_xfer * xp) -{ - tcb_p tp; - lcb_p lp; - ccb_p cp; - - u_long target; - u_long lun; - - if (!np) return; - if (!xp) return; - - target = xp->TARGET; - lun = xp->LUN; - - if (target>=MAX_TARGET) return; - if (lun >=MAX_LUN ) return; - - tp=&np->target[target]; - - if (!tp->jump_tcb.l_cmd) { - - /* - ** initialize it. - */ - tp->jump_tcb.l_cmd = (SCR_JUMP^IFFALSE (DATA (0x80 + target))); - tp->jump_tcb.l_paddr = np->jump_tcb.l_paddr; - - tp->getscr[0] = SCR_COPY (1); - tp->getscr[1] = vtophys (&tp->sval); - tp->getscr[2] = np->paddr + offsetof (struct ncr_reg, nc_sxfer); - tp->getscr[3] = SCR_COPY (1); - tp->getscr[4] = vtophys (&tp->wval); - tp->getscr[5] = np->paddr + offsetof (struct ncr_reg, nc_scntl3); - - assert (( (offsetof(struct ncr_reg, nc_sxfer) ^ - offsetof(struct tcb , sval )) &3) == 0); - assert (( (offsetof(struct ncr_reg, nc_scntl3) ^ - offsetof(struct tcb , wval )) &3) == 0); - - tp->call_lun.l_cmd = (SCR_CALL); - tp->call_lun.l_paddr = vtophys (&np->script->resel_lun); - - tp->jump_lcb.l_cmd = (SCR_JUMP); - tp->jump_lcb.l_paddr = vtophys (&np->script->abort); - np->jump_tcb.l_paddr = vtophys (&tp->jump_tcb); - - ncr_setmaxtags (tp, SCSI_NCR_MAX_TAGS); - } - - /* - ** Logic unit control block - */ - lp = tp->lp[lun]; - if (!lp) { - /* - ** Allocate a lcb - */ - lp = (lcb_p) malloc (sizeof (struct lcb), M_DEVBUF, M_NOWAIT); - if (!lp) return; - - /* - ** Initialize it - */ - bzero (lp, sizeof (*lp)); - lp->jump_lcb.l_cmd = (SCR_JUMP ^ IFFALSE (DATA (lun))); - lp->jump_lcb.l_paddr = tp->jump_lcb.l_paddr; - - lp->call_tag.l_cmd = (SCR_CALL); - lp->call_tag.l_paddr = vtophys (&np->script->resel_tag); - - lp->jump_ccb.l_cmd = (SCR_JUMP); - lp->jump_ccb.l_paddr = vtophys (&np->script->aborttag); - - lp->actlink = 1; - /* - ** Link into Lun-Chain - */ - - tp->jump_lcb.l_paddr = vtophys (&lp->jump_lcb); - tp->lp[lun] = lp; - - } - - /* - ** Limit possible number of ccbs. - ** - ** If tagged command queueing is enabled, - ** can use more than one ccb. - */ - - if (np->actccbs >= MAX_START-2) return; - if (lp->actccbs && (lp->actccbs >= lp->reqccbs)) - return; - - /* - ** Allocate a ccb - */ - cp = (ccb_p) malloc (sizeof (struct ccb), M_DEVBUF, M_NOWAIT); - - if (!cp) - return; - - if (DEBUG_FLAGS & DEBUG_ALLOC) { - PRINT_ADDR(xp); - printf ("new ccb @%x.\n", (unsigned) cp); - } - - /* - ** Count it - */ - lp->actccbs++; - np->actccbs++; - - /* - ** Initialize it. - */ - bzero (cp, sizeof (*cp)); - - /* - ** link in reselect chain. - */ - cp->jump_ccb.l_cmd = SCR_JUMP; - cp->jump_ccb.l_paddr = lp->jump_ccb.l_paddr; - lp->jump_ccb.l_paddr = vtophys(&cp->jump_ccb); - cp->call_tmp.l_cmd = SCR_CALL; - cp->call_tmp.l_paddr = vtophys(&np->script->resel_tmp); - - /* - ** link in wakeup chain - */ - cp->link_ccb = np->ccb.link_ccb; - np->ccb.link_ccb = cp; - - /* - ** Link into CCB-Chain - */ - cp->next_ccb = lp->next_ccb; - lp->next_ccb = cp; -} - -/*========================================================== -** -** -** Announce the number of ccbs/tags to the scsi driver. -** -** -**========================================================== -*/ - -static void ncr_opennings (ncb_p np, lcb_p lp, struct scsi_xfer * xp) -{ -#ifndef ANCIENT - /* - ** want to reduce the number ... - */ - if (lp->actlink > lp->reqlink) { - - /* - ** Try to reduce the count. - ** We assume to run at splbio .. - */ - u_char diff = lp->actlink - lp->reqlink; - - if (!diff) return; - - if (diff > xp->sc_link->opennings) - diff = xp->sc_link->opennings; - - xp->sc_link->opennings -= diff; - lp->actlink -= diff; - if (DEBUG_FLAGS & DEBUG_TAGS) - printf ("%s: actlink: diff=%d, new=%d, req=%d\n", - ncr_name(np), diff, lp->actlink, lp->reqlink); - return; - }; - - /* - ** want to increase the number ? - */ - if (lp->reqlink > lp->actlink) { - u_char diff = lp->reqlink - lp->actlink; - - xp->sc_link->opennings += diff; - lp->actlink += diff; - wakeup ((caddr_t) xp->sc_link); - if (DEBUG_FLAGS & DEBUG_TAGS) - printf ("%s: actlink: diff=%d, new=%d, req=%d\n", - ncr_name(np), diff, lp->actlink, lp->reqlink); - }; -#endif -} - -/*========================================================== -** -** -** Build Scatter Gather Block -** -** -**========================================================== -** -** The transfer area may be scattered among -** several non adjacent physical pages. -** -** We may use MAX_SCATTER blocks. -** -**---------------------------------------------------------- -*/ - -static int ncr_scatter - (struct dsb* phys, vm_offset_t vaddr, vm_size_t datalen) -{ - u_long paddr, pnext; - - u_short segment = 0; - u_long segsize, segaddr; - u_long size, csize = 0; - u_long chunk = MAX_SIZE; - int free; - - bzero (&phys->data, sizeof (phys->data)); - if (!datalen) return (0); - - paddr = vtophys (vaddr); - - /* - ** insert extra break points at a distance of chunk. - ** We try to reduce the number of interrupts due to - ** unexpected phase changes due to disconnects. - ** A typical harddisk may disconnect before ANY block. - ** If we want to avoid unexpected phase changes at all - ** we have to use a break point every 512 bytes. - ** Of course the number of scatter/gather blocks is - ** limited. - */ - - free = MAX_SCATTER - 1; - - if (vaddr & (NBPG-1)) free -= datalen / NBPG; - - if (free>1) - while ((chunk * free >= 2 * datalen) && (chunk>=1024)) - chunk /= 2; - - if(DEBUG_FLAGS & DEBUG_SCATTER) - printf("ncr?:\tscattering virtual=0x%x size=%d chunk=%d.\n", - (unsigned) vaddr, (unsigned) datalen, (unsigned) chunk); - - /* - ** Build data descriptors. - */ - while (datalen && (segment < MAX_SCATTER)) { - - /* - ** this segment is empty - */ - segsize = 0; - segaddr = paddr; - pnext = paddr; - - if (!csize) csize = chunk; - - while ((datalen) && (paddr == pnext) && (csize)) { - - /* - ** continue this segment - */ - pnext = (paddr & (~(NBPG - 1))) + NBPG; - - /* - ** Compute max size - */ - - size = pnext - paddr; /* page size */ - if (size > datalen) size = datalen; /* data size */ - if (size > csize ) size = csize ; /* chunksize */ - - segsize += size; - vaddr += size; - csize -= size; - datalen -= size; - paddr = vtophys (vaddr); - }; - - if(DEBUG_FLAGS & DEBUG_SCATTER) - printf ("\tseg #%d addr=%x size=%d (rest=%d).\n", - segment, - (unsigned) segaddr, - (unsigned) segsize, - (unsigned) datalen); - - phys->data[segment].addr = segaddr; - phys->data[segment].size = segsize; - segment++; - } - - if (datalen) { - printf("ncr?: scatter/gather failed (residue=%d).\n", - (unsigned) datalen); - return (-1); - }; - - return (segment); -} - -/*========================================================== -** -** -** Test the pci bus snoop logic :-( -** -** Has to be called with interrupts disabled. -** -** -**========================================================== -*/ - -static int ncr_snooptest (struct ncb* np) -{ - u_long ncr_rd, ncr_wr, ncr_bk, host_rd, host_wr, pc, err=0; - /* - ** init - */ - pc = vtophys (&np->script->snooptest); - host_wr = 1; - ncr_wr = 2; - /* - ** Set memory and register. - */ - ncr_cache = host_wr; - OUTL (nc_temp, ncr_wr); - /* - ** Start script (exchange values) - */ - OUTL (nc_dsp, pc); - /* - ** Wait 'til done - */ - while (!(INB(nc_istat) & (INTF|SIP|DIP))); - /* - ** Read memory and register. - */ - host_rd = ncr_cache; - ncr_rd = INL (nc_scratcha); - ncr_bk = INL (nc_temp); - /* - ** Reset ncr chip - */ - OUTB (nc_istat, SRST); - OUTB (nc_istat, 0 ); - /* - ** Show results. - */ - if (host_wr != ncr_rd) { - printf ("CACHE TEST FAILED: host wrote %d, ncr read %d.\n", - (int) host_wr, (int) ncr_rd); - err |= 1; - }; - if (host_rd != ncr_wr) { - printf ("CACHE TEST FAILED: ncr wrote %d, host read %d.\n", - (int) ncr_wr, (int) host_rd); - err |= 2; - }; - if (ncr_bk != ncr_wr) { - printf ("CACHE TEST FAILED: ncr wrote %d, read back %d.\n", - (int) ncr_wr, (int) ncr_bk); - err |= 4; - }; - return (err); -} - -/*========================================================== -** -** -** Profiling the drivers and targets performance. -** -** -**========================================================== -*/ - -/* -** Compute the difference in milliseconds. -**/ - -static int ncr_delta (struct timeval * from, struct timeval * to) -{ - if (!from->tv_sec) return (-1); - if (!to ->tv_sec) return (-2); - return ( (to->tv_sec - from->tv_sec - 2)*1000+ - +(to->tv_usec - from->tv_usec + 2000000)/1000); -} - -#define PROFILE cp->phys.header.stamp -static void ncb_profile (ncb_p np, ccb_p cp) -{ - int co, da, st, en, di, se, post,work,disc; - u_long diff; - - PROFILE.end = time; - - st = ncr_delta (&PROFILE.start,&PROFILE.status); - if (st<0) return; /* status not reached */ - - da = ncr_delta (&PROFILE.start,&PROFILE.data); - if (da<0) return; /* No data transfer phase */ - - co = ncr_delta (&PROFILE.start,&PROFILE.command); - if (co<0) return; /* command not executed */ - - en = ncr_delta (&PROFILE.start,&PROFILE.end), - di = ncr_delta (&PROFILE.start,&PROFILE.disconnect), - se = ncr_delta (&PROFILE.start,&PROFILE.select); - post = en - st; - - /* - ** @PROFILE@ Disconnect time invalid if multiple disconnects - */ - - if (di>=0) disc = se-di; else disc = 0; - - work = (st - co) - disc; - - diff = (np->disc_phys - np->disc_ref) & 0xff; - np->disc_ref += diff; - - np->profile.num_trans += 1; - if (cp->xfer) - np->profile.num_bytes += cp->xfer->datalen; - np->profile.num_disc += diff; - np->profile.ms_setup += co; - np->profile.ms_data += work; - np->profile.ms_disc += disc; - np->profile.ms_post += post; -} -#undef PROFILE - -/*========================================================== -** -** -** Device lookup. -** -** @GENSCSI@ should be integrated to scsiconf.c -** -** -**========================================================== -*/ - -#ifndef NEW_SCSICONF - -struct table_entry { - char * manufacturer; - char * model; - char * version; - u_long info; -}; - -static struct table_entry device_tab[] = -{ - {"SONY", "SDT-5000", "3.17", QUIRK_NOMSG}, - {"WangDAT", "Model 2600", "01.7", QUIRK_NOMSG}, - {"WangDAT", "Model 3200", "02.2", QUIRK_NOMSG}, - {"WangDAT", "Model 1300", "02.4", QUIRK_NOMSG}, - {"", "", "", 0} /* catch all: must be last entry. */ -}; - -static u_long ncr_lookup(char * id) -{ - struct table_entry * p = device_tab; - char *d, *r, c; - - for (;;p++) { - - d = id+8; - r = p->manufacturer; - while ((c=*r++)) if (c!=*d++) break; - if (c) continue; - - d = id+16; - r = p->model; - while ((c=*r++)) if (c!=*d++) break; - if (c) continue; - - d = id+32; - r = p->version; - while ((c=*r++)) if (c!=*d++) break; - if (c) continue; - - return (p->info); - } -} -#endif - -/*========================================================== -** -** Determine the ncr's clock frequency. -** This is important for the negotiation -** of the synchronous transfer rate. -** -**========================================================== -** -** Note: we have to return the correct value. -** THERE IS NO SAVE DEFAULT VALUE. -** -** We assume that all NCR based boards are delivered -** with a 40Mhz clock. Because we have to divide -** by an integer value greater than 3, only clock -** frequencies of 40Mhz (/4) or 50MHz (/5) permit -** the FAST-SCSI rate of 10MHz. -** -**---------------------------------------------------------- -*/ - -#ifndef NCR_CLOCK -# define NCR_CLOCK 40 -#endif /* NCR_CLOCK */ - - -static void ncr_getclock (ncb_p np) -{ - u_char tbl[5] = {6,2,3,4,6}; - u_char f; - u_char ns_clock = (1000/NCR_CLOCK); - - /* - ** Compute the best value for scntl3. - */ - - f = (2 * MIN_SYNC_PD - 1) / ns_clock; - if (!f ) f=1; - if (f>4) f=4; - np -> ns_sync = (ns_clock * tbl[f]) / 2; - np -> rv_scntl3 = f<<4; - - f = (2 * MIN_ASYNC_PD - 1) / ns_clock; - if (!f ) f=1; - if (f>4) f=4; - np -> ns_async = (ns_clock * tbl[f]) / 2; - np -> rv_scntl3 |= f; - if (DEBUG_FLAGS & DEBUG_TIMING) - printf ("%s: sclk=%d async=%d sync=%d (ns) scntl3=0x%x\n", - ncr_name (np), ns_clock, np->ns_async, np->ns_sync, np->rv_scntl3); -} - -/*=========================================================================*/ -#endif /* KERNEL */ - - diff --git a/sys/i386/pci/ncr_reg.h b/sys/i386/pci/ncr_reg.h deleted file mode 100644 index 1d2b7da..0000000 --- a/sys/i386/pci/ncr_reg.h +++ /dev/null @@ -1,547 +0,0 @@ -/************************************************************************** -** -** $Id: ncr_reg.h,v 2.1 94/09/16 08:01:34 wolf Rel $ -** -** Device driver for the NCR 53C810 PCI-SCSI-Controller. -** -** 386bsd / FreeBSD / NetBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** wolf@dentaro.gun.de Wolfgang Stanglmeier -** se@mi.Uni-Koeln.de Stefan Esser -** -** Ported to NetBSD by -** mycroft@gnu.ai.mit.edu -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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. -** -**------------------------------------------------------------------------- -*/ - -#ifndef __NCR_REG_H__ -#define __NCR_REG_H__ - - -/*----------------------------------------------------------------- -** -** The ncr 53c810 register structure. -** -**----------------------------------------------------------------- -*/ - -struct ncr_reg { -/*00*/ u_char nc_scntl0; /* full arb., ena parity, par->ATN */ - -/*01*/ u_char nc_scntl1; /* no reset */ - #define ISCON 0x10 /* connected to scsi */ - #define CRST 0x08 /* force reset */ - -/*02*/ u_char nc_scntl2; /* no disconnect expected */ - #define SDU 0x80 /* cmd: disconnect will raise error */ - #define CHM 0x40 /* sta: chained mode */ - #define WSS 0x08 /* sta: wide scsi send [W]*/ - #define WSR 0x01 /* sta: wide scsi received [W]*/ - -/*03*/ u_char nc_scntl3; /* cnf system clock dependent */ - #define EWS 0x08 /* cmd: enable wide scsi [W]*/ - -/*04*/ u_char nc_scid; /* cnf host adapter scsi address */ - #define RRE 0x40 /* r/w:e enable response to resel. */ - #define SRE 0x20 /* r/w:e enable response to select */ - -/*05*/ u_char nc_sxfer; /* ### Sync speed and count */ - -/*06*/ u_char nc_sdid; /* ### Destination-ID */ - -/*07*/ u_char nc_gpreg; /* ??? IO-Pins */ - -/*08*/ u_char nc_sfbr; /* ### First byte in phase */ - -/*09*/ u_char nc_socl; - #define CREQ 0x80 /* r/w: SCSI-REQ */ - #define CACK 0x40 /* r/w: SCSI-ACK */ - #define CBSY 0x20 /* r/w: SCSI-BSY */ - #define CSEL 0x10 /* r/w: SCSI-SEL */ - #define CATN 0x08 /* r/w: SCSI-ATN */ - #define CMSG 0x04 /* r/w: SCSI-MSG */ - #define CC_D 0x02 /* r/w: SCSI-C_D */ - #define CI_O 0x01 /* r/w: SCSI-I_O */ - -/*0a*/ u_char nc_ssid; - -/*0b*/ u_char nc_sbcl; - -/*0c*/ u_char nc_dstat; - #define DFE 0x80 /* sta: dma fifo empty */ - #define MDPE 0x40 /* int: master data parity error */ - #define BF 0x20 /* int: script: bus fault */ - #define ABRT 0x10 /* int: script: command aborted */ - #define SSI 0x08 /* int: script: single step */ - #define SIR 0x04 /* int: script: interrupt instruct. */ - #define IID 0x01 /* int: script: illegal instruct. */ - -/*0d*/ u_char nc_sstat0; - #define ILF 0x80 /* sta: data in SIDL register lsb */ - #define ORF 0x40 /* sta: data in SODR register lsb */ - #define OLF 0x20 /* sta: data in SODL register lsb */ - #define AIP 0x10 /* sta: arbitration in progress */ - #define LOA 0x08 /* sta: arbitration lost */ - #define WOA 0x04 /* sta: arbitration won */ - #define IRST 0x02 /* sta: scsi reset signal */ - #define SDP 0x01 /* sta: scsi parity signal */ - -/*0e*/ u_char nc_sstat1; - #define FF3210 0xf0 /* sta: bytes in the scsi fifo */ - -/*0f*/ u_char nc_sstat2; - #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/ - #define ORF1 0x40 /* sta: data in SODR register msb[W]*/ - #define OLF1 0x20 /* sta: data in SODL register msb[W]*/ - -/*10*/ u_long nc_dsa; /* --> Base page */ - -/*14*/ u_char nc_istat; /* --> Main Command and status */ - #define CABRT 0x80 /* cmd: abort current operation */ - #define SRST 0x40 /* mod: reset chip */ - #define SIGP 0x20 /* r/w: message from host to ncr */ - #define SEM 0x10 /* r/w: message between host + ncr */ - #define CON 0x08 /* sta: connected to scsi */ - #define INTF 0x04 /* sta: int on the fly (reset by wr)*/ - #define SIP 0x02 /* sta: scsi-interupt */ - #define DIP 0x01 /* sta: host/script interupt */ - -/*15*/ u_char nc_15_; -/*16*/ u_char nc_16_; -/*17*/ u_char nc_17_; - -/*18*/ u_char nc_ctest0; -/*19*/ u_char nc_ctest1; - -/*1a*/ u_char nc_ctest2; - #define CSIGP 0x40 - -/*1b*/ u_char nc_ctest3; - #define CLF 0x04 /* clear scsi fifo */ - -/*1c*/ u_long nc_temp; /* ### Temporary stack */ - -/*20*/ u_char nc_dfifo; -/*21*/ u_char nc_ctest4; -/*22*/ u_char nc_ctest5; -/*23*/ u_char nc_ctest6; - -/*24*/ u_long nc_dbc; /* ### Byte count and command */ -/*28*/ u_long nc_dnad; /* ### Next command register */ -/*2c*/ u_long nc_dsp; /* --> Script Pointer */ -/*30*/ u_long nc_dsps; /* --> Script pointer save/opcode#2 */ -/*34*/ u_long nc_scratcha; /* ??? Temporary register a */ - -/*38*/ u_char nc_dmode; -/*39*/ u_char nc_dien; -/*3a*/ u_char nc_dwt; - -/*3b*/ u_char nc_dcntl; /* --> Script execution control */ - #define SSM 0x10 /* mod: single step mode */ - #define STD 0x04 /* cmd: start dma mode */ - #define NOCOM 0x01 /* cmd: protect sfbr while reselect */ - -/*3c*/ u_long nc_adder; - -/*40*/ u_short nc_sien; /* -->: interupt enable */ -/*42*/ u_short nc_sist; /* <--: interupt status */ - #define STO 0x0400/* sta: timeout (select) */ - #define GEN 0x0200/* sta: timeout (general) */ - #define HTH 0x0100/* sta: timeout (handshake) */ - #define MA 0x80 /* sta: phase mismatch */ - #define CMP 0x40 /* sta: arbitration complete */ - #define SEL 0x20 /* sta: selected by another device */ - #define RSL 0x10 /* sta: reselected by another device*/ - #define SGE 0x08 /* sta: gross error (over/underflow)*/ - #define UDC 0x04 /* sta: unexpected disconnect */ - #define RST 0x02 /* sta: scsi bus reset detected */ - #define PAR 0x01 /* sta: scsi parity error */ - -/*44*/ u_char nc_slpar; -/*45*/ u_char nc_swide; -/*46*/ u_char nc_macntl; -/*47*/ u_char nc_gpcntl; -/*48*/ u_char nc_stime0; /* cmd: timeout for select&handshake*/ -/*49*/ u_char nc_stime1; /* cmd: timeout user defined */ -/*4a*/ u_short nc_respid; /* sta: Reselect-IDs */ - -/*4c*/ u_char nc_stest0; - -/*4d*/ u_char nc_stest1; - -/*4e*/ u_char nc_stest2; - #define ROF 0x40 /* reset scsi offset (after gross error!) */ - #define EXT 0x02 /* extended filtering */ - -/*4f*/ u_char nc_stest3; - #define TE 0x80 /* c: tolerAnt enable */ - #define CSF 0x02 /* c: clear scsi fifo */ - -/*50*/ u_short nc_sidl; /* Lowlevel: latched from scsi data */ -/*52*/ u_short nc_52_; -/*54*/ u_short nc_sodl; /* Lowlevel: data out to scsi data */ -/*56*/ u_short nc_56_; -/*58*/ u_short nc_sbdl; /* Lowlevel: data from scsi data */ -/*5a*/ u_short nc_5a_; -/*5c*/ u_char nc_scr0; /* Working register B */ -/*5d*/ u_char nc_scr1; /* */ -/*5e*/ u_char nc_scr2; /* */ -/*5f*/ u_char nc_scr3; /* */ -/*60*/ -}; - -/*----------------------------------------------------------- -** -** Utility macros for the script. -** -**----------------------------------------------------------- -*/ - -#define REGJ(p,r) (offsetof(struct ncr_reg, p ## r)) -#define REG(r) REGJ (nc_, r) - -#ifndef TARGET_MODE -#define TARGET_MODE 0 -#endif - -typedef unsigned long ncrcmd; - -/*----------------------------------------------------------- -** -** SCSI phases -** -**----------------------------------------------------------- -*/ - -#define SCR_DATA_OUT 0x00000000 -#define SCR_DATA_IN 0x01000000 -#define SCR_COMMAND 0x02000000 -#define SCR_STATUS 0x03000000 -#define SCR_ILG_OUT 0x04000000 -#define SCR_ILG_IN 0x05000000 -#define SCR_MSG_OUT 0x06000000 -#define SCR_MSG_IN 0x07000000 - -/*----------------------------------------------------------- -** -** Data transfer via SCSI. -** -**----------------------------------------------------------- -** -** MOVE_ABS (LEN) -** <<start address>> -** -** MOVE_IND (LEN) -** <<dnad_offset>> -** -** MOVE_TBL -** <<dnad_offset>> -** -**----------------------------------------------------------- -*/ - -#define SCR_MOVE_ABS(l) ((0x08000000 ^ (TARGET_MODE << 1ul)) | (l)) -#define SCR_MOVE_IND(l) ((0x28000000 ^ (TARGET_MODE << 1ul)) | (l)) -#define SCR_MOVE_TBL (0x18000000 ^ (TARGET_MODE << 1ul)) - -struct scr_tblmove { - u_long size; - u_long addr; -}; - -/*----------------------------------------------------------- -** -** Selection -** -**----------------------------------------------------------- -** -** SEL_ABS | SCR_ID (0..7) [ | REL_JMP] -** <<alternate_address>> -** -** SEL_TBL | << dnad_offset>> [ | REL_JMP] -** <<alternate_address>> -** -**----------------------------------------------------------- -*/ - -#define SCR_SEL_ABS 0x40000000 -#define SCR_SEL_ABS_ATN 0x41000000 -#define SCR_SEL_TBL 0x42000000 -#define SCR_SEL_TBL_ATN 0x43000000 - -struct scr_tblsel { - u_char sel_0; - u_char sel_sxfer; - u_char sel_id; - u_char sel_scntl3; -}; - -#define SCR_JMP_REL 0x04000000 -#define SCR_ID(id) (((u_long)(id)) << 16) - -/*----------------------------------------------------------- -** -** Waiting for Disconnect or Reselect -** -**----------------------------------------------------------- -** -** WAIT_DISC -** dummy: <<alternate_address>> -** -** WAIT_RESEL -** <<alternate_address>> -** -**----------------------------------------------------------- -*/ - -#define SCR_WAIT_DISC 0x48000000 -#define SCR_WAIT_RESEL 0x50000000 - -/*----------------------------------------------------------- -** -** Bit Set / Reset -** -**----------------------------------------------------------- -** -** SET (flags {|.. }) -** -** CLR (flags {|.. }) -** -**----------------------------------------------------------- -*/ - -#define SCR_SET(f) (0x58000000 | (f)) -#define SCR_CLR(f) (0x60000000 | (f)) - -#define SCR_CARRY 0x00000400 -#define SCR_TRG 0x00000200 -#define SCR_ACK 0x00000040 -#define SCR_ATN 0x00000008 - - - - -/*----------------------------------------------------------- -** -** Memory to memory move -** -**----------------------------------------------------------- -** -** COPY (bytecount) -** << source_address >> -** << destination_address >> -** -**----------------------------------------------------------- -*/ - -#define SCR_COPY(n) (0xc0000000 | (n)) - -/*----------------------------------------------------------- -** -** Register move and binary operations -** -**----------------------------------------------------------- -** -** SFBR_REG (reg, op, data) reg = SFBR op data -** << 0 >> -** -** REG_SFBR (reg, op, data) SFBR = reg op data -** << 0 >> -** -** REG_REG (reg, op, data) reg = reg op data -** << 0 >> -** -**----------------------------------------------------------- -*/ - -#define SCR_REG_OFS(ofs) ((ofs) << 16ul) - -#define SCR_SFBR_REG(reg,op,data) \ - (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | ((data)<<8ul)) - -#define SCR_REG_SFBR(reg,op,data) \ - (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | ((data)<<8ul)) - -#define SCR_REG_REG(reg,op,data) \ - (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | ((data)<<8ul)) - - -#define SCR_LOAD 0x00000000 -#define SCR_SHL 0x01000000 -#define SCR_OR 0x02000000 -#define SCR_XOR 0x03000000 -#define SCR_AND 0x04000000 -#define SCR_SHR 0x05000000 -#define SCR_ADD 0x06000000 -#define SCR_ADDC 0x07000000 - -/*----------------------------------------------------------- -** -** FROM_REG (reg) reg = SFBR -** << 0 >> -** -** TO_REG (reg) SFBR = reg -** << 0 >> -** -** LOAD_REG (reg, data) reg = <data> -** << 0 >> -** -** LOAD_SFBR(data) SFBR = <data> -** << 0 >> -** -**----------------------------------------------------------- -*/ - -#define SCR_FROM_REG(reg) \ - SCR_REG_SFBR(reg,SCR_OR,0) - -#define SCR_TO_REG(reg) \ - SCR_SFBR_REG(reg,SCR_OR,0) - -#define SCR_LOAD_REG(reg,data) \ - SCR_REG_REG(reg,SCR_LOAD,data) - -#define SCR_LOAD_SFBR(data) \ - (SCR_REG_SFBR (gpreg, SCR_LOAD, data)) - -/*----------------------------------------------------------- -** -** Waiting for Disconnect or Reselect -** -**----------------------------------------------------------- -** -** JUMP [ | IFTRUE/IFFALSE ( ... ) ] -** <<address>> -** -** JUMPR [ | IFTRUE/IFFALSE ( ... ) ] -** <<distance>> -** -** CALL [ | IFTRUE/IFFALSE ( ... ) ] -** <<address>> -** -** CALLR [ | IFTRUE/IFFALSE ( ... ) ] -** <<distance>> -** -** RETURN [ | IFTRUE/IFFALSE ( ... ) ] -** <<dummy>> -** -** INT [ | IFTRUE/IFFALSE ( ... ) ] -** <<ident>> -** -** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ] -** <<ident>> -** -** Conditions: -** WHEN (phase) -** IF (phase) -** CARRY -** DATA (data, mask) -** -**----------------------------------------------------------- -*/ - -#define SCR_JUMP 0x80080000 -#define SCR_JUMPR 0x80880000 -#define SCR_CALL 0x88080000 -#define SCR_CALLR 0x88880000 -#define SCR_RETURN 0x90080000 -#define SCR_INT 0x98080000 -#define SCR_INT_FLY 0x98180000 - -#define IFFALSE(arg) (0x00080000 | (arg)) -#define IFTRUE(arg) (0x00000000 | (arg)) - -#define WHEN(phase) (0x00030000 | (phase)) -#define IF(phase) (0x00020000 | (phase)) - -#define DATA(D) (0x00040000 | ((D) & 0xff)) -#define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff)) - -#define CARRYSET (0x00200000) - -/*----------------------------------------------------------- -** -** SCSI constants. -** -**----------------------------------------------------------- -*/ - -/* -** Messages -*/ - -#define M_COMPLETE (0x00) -#define M_EXTENDED (0x01) -#define M_SAVE_DP (0x02) -#define M_RESTORE_DP (0x03) -#define M_DISCONNECT (0x04) -#define M_ID_ERROR (0x05) -#define M_ABORT (0x06) -#define M_REJECT (0x07) -#define M_NOOP (0x08) -#define M_PARITY (0x09) -#define M_LCOMPLETE (0x0a) -#define M_FCOMPLETE (0x0b) -#define M_RESET (0x0c) -#define M_ABORT_TAG (0x0d) -#define M_CLEAR_QUEUE (0x0e) -#define M_INIT_REC (0x0f) -#define M_REL_REC (0x10) -#define M_TERMINATE (0x11) -#define M_SIMPLE_TAG (0x20) -#define M_HEAD_TAG (0x21) -#define M_ORDERED_TAG (0x22) -#define M_IGN_RESIDUE (0x23) -#define M_IDENTIFY (0x80) - -#define M_X_MODIFY_DP (0x00) -#define M_X_SYNC_REQ (0x01) -#define M_X_WIDE_REQ (0x03) - -/* -** Status -*/ - -#define S_GOOD (0x00) -#define S_CHECK_COND (0x02) -#define S_COND_MET (0x04) -#define S_BUSY (0x08) -#define S_INT (0x10) -#define S_INT_COND_MET (0x14) -#define S_CONFLICT (0x18) -#define S_TERMINATED (0x20) -#define S_QUEUE_FULL (0x28) -#define S_ILLEGAL (0xff) -#define S_SENSE (0x80) - -#endif /*__NCR_REG_H__*/ diff --git a/sys/i386/pci/ncrcontrol.c b/sys/i386/pci/ncrcontrol.c deleted file mode 100644 index 5adecbc..0000000 --- a/sys/i386/pci/ncrcontrol.c +++ /dev/null @@ -1,1630 +0,0 @@ -/************************************************************************** -** -** $Id: ncrcontrol.c,v 2.3 94/10/09 21:10:08 wolf Oct11 $ -** -** Utility for NCR 53C810 device driver. -** -** 386bsd / FreeBSD / NetBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** wolf@dentaro.gun.de Wolfgang Stanglmeier -** se@mi.Uni-Koeln.de Stefan Esser -** -** Ported to NetBSD by -** mycroft@gnu.ai.mit.edu -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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/file.h> -#include <sys/types.h> -#ifdef __NetBSD__ -#include <sys/device.h> -#endif -#include <nlist.h> -#include <stdio.h> -#include <errno.h> -#include <paths.h> -#include <limits.h> -#include <kvm.h> -#include <i386/pci/ncr.c> - -/* -** used external functions -*/ - -#if defined(__NetBSD__) || (__FreeBSD__ >= 2) -kvm_t *kvm; -#define KVM_NLIST(n) (kvm_nlist(kvm, (n)) >= 0) -#define KVM_READ(o, p, l) (kvm_read(kvm, (o), (void*)(p), (l)) == (l)) -#else -#define KVM_NLIST(n) (kvm_nlist((n)) >= 0) -#define KVM_READ(o, p, l) (kvm_read((void*)(o), (p), (l)) == (l)) -#endif - -extern void exit(); -extern char* strerror (int num); - -/*=========================================================== -** -** Global variables. -** -**=========================================================== -*/ - -char *prog; -u_long verbose; -u_long wizard; - - - -struct nlist nl[] = { -#define N_NCR_VERSION 0 - { "_ncr_version" }, -#ifdef __NetBSD__ -#define N_NCRCD 1 - { "_ncrcd" }, -#else -#define N_NCRP 1 - { "_ncrp" }, -#define N_NNCR 2 - { "_nncr" }, -#endif - { 0 } -}; - - -char *vmunix = _PATH_UNIX; -char *kmemf = NULL; - -int kvm_isopen; - -u_long ncr_base; -u_long lcb_base; -u_long ccb_base; - -u_long ncr_unit; -#ifdef __NetBSD__ -struct cfdriver ncrcd; -#else -u_long ncr_units; -#endif - -struct ncb ncr; -struct lcb lcb; -struct ccb ccb; - -u_long target_mask; -u_long global_lun_mask; -u_long lun_mask; -u_long interval; - -/*=========================================================== -** -** Accessing kernel memory via kvm library. -** -**=========================================================== -*/ - -read_ccb(u_long base) -{ - ccb_base = base; - if (!KVM_READ ( - base, - &ccb, - sizeof (struct ccb))) { - fprintf (stderr, "%s: bad kvm read at %x.\n", prog, base); - exit (1); - }; -} - -read_lcb(u_long base) -{ - lcb_base = base; - if (!KVM_READ ( - base, - &lcb, - sizeof (struct lcb))) { - fprintf (stderr, "%s: bad kvm read at %x.\n", prog, base); - exit (1); - }; -} - -read_ncr() -{ - if (!KVM_READ ( - ncr_base, - &ncr, - sizeof (ncr))) { - fprintf (stderr, "%s: bad kvm read at %x.\n", prog, ncr_base); - exit (1); - }; -} - -void open_kvm(int flags) -{ - int i; - u_long kernel_version; -#if defined(__NetBSD__) || (__FreeBSD__ >= 2) - char errbuf[_POSIX2_LINE_MAX]; -#endif - - if (kvm_isopen) return; - -#if defined(__NetBSD__) || (__FreeBSD__ >= 2) - kvm = kvm_openfiles(vmunix, kmemf, NULL, flags, errbuf); - if (kvm == NULL) { - fprintf(stderr, "%s: kvm_openfiles: %s\n", prog, errbuf); - exit(1); - } -#else - if (kvm_openfiles(vmunix, kmemf, NULL) == -1) { - fprintf(stderr, "%s: kvm_openfiles: %s\n", prog, kvm_geterr()); - exit(1); - } -#endif - - if (!KVM_NLIST(nl)) { - fprintf(stderr, "%s: no symbols in \"%s\".\n", - prog, vmunix); - exit (2); - }; - - for (i=0; nl[i].n_name; i++) - if (nl[i].n_type == 0) { - fprintf(stderr, "%s: no symbol \"%s\" in \"%s\".\n", - prog, nl[i].n_name, vmunix); - exit(1); - } - - if (!KVM_READ ( - nl[N_NCR_VERSION].n_value, - &kernel_version, - sizeof (kernel_version))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (kernel_version != ncr_version){ - fprintf (stderr, "%s: incompatible with kernel. Rebuild!\n", - prog); - exit (1); - }; - -#ifdef __NetBSD__ - - if (!KVM_READ ( - nl[N_NCRCD].n_value, - &ncrcd, - sizeof (ncrcd))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (ncr_unit >= ncrcd.cd_ndevs){ - fprintf (stderr, "%s: bad unit number (valid range: 0-%d).\n", - prog, ncrcd.cd_ndevs-1); - exit (1); - }; - - if (!KVM_READ ( - ncrcd.cd_devs+4*ncr_unit, - &ncr_base, - sizeof (ncr_base))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (!ncr_base) { - fprintf (stderr, - "%s: control structure not allocated (not found in autoconfig?)\n", prog); - exit (1); - }; - -#else /* !__NetBSD__ */ - - if (!KVM_READ ( - nl[N_NNCR].n_value, - &ncr_units, - sizeof (ncr_units))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (ncr_unit >= ncr_units){ - fprintf (stderr, "%s: bad unit number (valid range: 0-%d).\n", - prog, ncr_units-1); - exit (1); - }; - - if (!KVM_READ ( - nl[N_NCRP].n_value+4*ncr_unit, - &ncr_base, - sizeof (ncr_base))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (!ncr_base) { - fprintf (stderr, - "%s: control structure not allocated (not found in autoconfig?)\n", prog); - exit (1); - }; - -#endif /* !__NetBSD__ */ - - read_ncr(); - - if (!ncr.vaddr) { - fprintf (stderr, - "%s: 53c810 not mapped (not found in autoconfig?)\n", prog); - exit (1); - }; - - kvm_isopen = 1; -} - - - - -void set_target_mask(void) -{ - int t; - if (target_mask) return; - for (t=0; t<MAX_TARGET; t++) - if (ncr.target[t].jump_tcb.l_cmd) target_mask |= (1<<t); -} - -void set_lun_mask(struct tcb * tp) -{ - int l; - lun_mask = global_lun_mask; - if (lun_mask) return; - for (l=0; l<MAX_LUN; l++) - if (tp->lp[l]) lun_mask |= (1<<l); -} - -void printc (u_char*p, int l) -{ - for (;l>0;l--) { - char c=*p++; - printf ("%c", c?c:'_'); - } -} - -/*================================================================ -** -** -** system info -** -** -**================================================================ -*/ - -do_info(void) -{ - int t,l,i,d,f,fl; - struct tcb * tip; - open_kvm(O_RDONLY); - - if (verbose>=3) - printf ("ncr unit=%d data@%x register@%x (pci@%x)\n\n", - ncr_unit, ncr_base, ncr.vaddr, ncr.paddr); - - set_target_mask(); - - printf ("T:L Vendor Device Rev Speed Max Wide Tags\n"); - for (t=0; t<MAX_TARGET;t++) { - if (!((target_mask>>t)&1)) continue; - tip = &ncr.target[t]; - - set_lun_mask(tip); - if (!lun_mask) lun_mask=1; - fl=1; - - for (l=0; l<MAX_LUN; l++) { - if (!((lun_mask>>l)&1)) continue; - - printf ("%d:%d ", t, l); - - if (!tip->jump_tcb.l_cmd) break; - - if (fl) { - fl=0; - printc (&tip->inqdata[ 8], 8);printf(" "); - printc (&tip->inqdata[16],16);printf(" "); - printc (&tip->inqdata[32], 4);printf(" "); - - if (tip->period==0xffff) { - printf ("asyn"); - } else if (tip->period) { - printf ("%4.1f", 1000.0 / tip->period); - } else { - printf (" ?"); - } - - printf (" "); - - if (tip->minsync==255) { - printf ("asyn"); - } else if (tip->minsync) { - printf ("%4.1f", 250.0 / tip->minsync); - } else { - printf (" ?"); - } - } else printf (" "); - - if (!tip->lp[l]) { - printf (" no\n"); - continue; - }; - read_lcb ((u_long) tip->lp[l]); - - switch (tip->widedone) { - case 1: - printf (" 8"); - break; - case 2: - printf (" 16"); - break; - case 3: - printf (" 32"); - break; - default: - printf (" ?"); - }; - - if (lcb.usetags) - printf ("%5d", lcb.actlink); - else - printf (" -"); - - printf ("\n"); - - }; - - if (!tip->jump_tcb.l_cmd) { - printf (" --- no target.\n"); - continue; - }; - - if (verbose<1) continue; - - for (i=0; i<8; i++) { - char* (class[10])={ - "disk","tape","printer","processor", - "worm", "cdrom", "scanner", "optical disk", - "media changer", "communication device"}; - d = tip->inqdata[i]; - printf ("[%02x]: ",d); - - switch (i) { - - case 0: - f = d & 0x1f; - if (f<10) printf (class[f]); - else printf ("unknown (%x)", f); - break; - case 1: - f = (d>>7) & 1; - if (f) printf ("removable media"); - else printf ("fixed media"); - break; - - case 2: - f = d & 7; - switch (f) { - case 0: printf ("SCSI-1"); - break; - case 1: printf ("SCSI-1 with CCS"); - break; - case 2: printf ("SCSI-2"); - break; - default: - printf ("unknown ansi version (%d)", - f); - } - break; - - case 3: - if (d&0xc0) printf ("capabilities:"); - if (d&0x80) printf (" AEN"); - if (d&0x40) printf (" TERMINATE-I/O"); - break; - - case 7: - if (d&0xfb) printf ("capabilities:"); - if (d&0x80) printf (" relative"); - if (d&0x40) printf (" wide32"); - if (d&0x20) printf (" wide"); - if (d&0x10) printf (" synch"); - if (d&0x08) printf (" link"); - if (d&0x02) printf (" tags"); - if (d&0x01) printf (" soft-reset"); - }; - printf ("\n"); - }; - printf ("\n"); - }; - printf ("\n"); -#ifndef __NetBSD__ - if (ncr.imask) { - u_short v; - printf ("Interrupt vector is"); - if (ncr.imask & (ncr.imask-1)) - printf (" one of the following:"); - for (v=15;v>0;v--) - if ((ncr.imask>>v)&1) - printf (" %d",v); - printf (".\n\n"); - }; -#endif -} - -/*================================================================ -** -** -** profiling -** -** -**================================================================ -*/ - -do_profile(void) -{ -#define old backup.profile -#define new ncr.profile - - struct ncb backup; - struct profile diff; - int tra,line,t; - - open_kvm(O_RDONLY); - - set_target_mask(); - - if (interval<1) interval=1; - for (;;) { - /* - ** Header Line 1 - */ - printf (" total "); - - for (t=0; t<MAX_TARGET; t++) { - if (!((target_mask>>t)&1)) continue; - printf (" "); - printc (&ncr.target[t].inqdata[16],8); - }; - - printf (" transf. disconn interru"); - - if (verbose>=1) printf (" ---- ms/transfer ----"); - - printf ("\n"); - - /* - ** Header Line 2 - */ - - printf ("t/s kb/s "); - - for (t=0; t<MAX_TARGET; t++) { - if (!((target_mask>>t)&1)) continue; - printf (" t/s kb/s"); - }; - - printf (" length exp une fly brk"); - - if (verbose>=1) printf (" total pre post disc"); - - printf ("\n"); - - /* - ** Data - */ - - for(line=0;line<20;line++) { - backup = ncr; - read_ncr(); - diff.num_trans = new.num_trans - old.num_trans; - diff.num_bytes = new.num_bytes - old.num_bytes; - diff.num_fly = new.num_fly - old.num_fly ; - diff.num_int = new.num_int - old.num_int ; - diff.ms_setup = new.ms_setup - old.ms_setup; - diff.ms_data = new.ms_data - old.ms_data; - diff.ms_disc = new.ms_disc - old.ms_disc; - diff.ms_post = new.ms_post - old.ms_post; - diff.num_disc = new.num_disc - old.num_disc; - diff.num_break = new.num_break - old.num_break; - - tra = diff.num_trans; - if (!tra) tra=1; - - printf ("%3.0f %4.0f ", - (1.0 * diff.num_trans) / interval, - (1.0 * diff.num_bytes) / (1024*interval)); - - - for (t=0; t<MAX_TARGET; t++) { - if (!((target_mask>>t)&1)) continue; - printf (" %3.0f %4.0f", - ((ncr.target[t].transfers- - backup.target[t].transfers)*1.0) - /interval, - ((ncr.target[t].bytes- - backup.target[t].bytes)*1.0) - /(1024*interval)); - }; - - printf ("%7.0f ", (diff.num_bytes*1.0) / tra); - - printf (" %4.0f", (1.0*(diff.num_disc-diff.num_break)) - /interval); - - printf ("%4.0f", (1.0*diff.num_break)/interval); - - printf ("%4.0f", (1.0*diff.num_fly) / interval); - - printf ("%4.0f", (1.0*diff.num_int) / interval); - - if (verbose >= 1) { - printf ("%7.1f", - (diff.ms_disc+diff.ms_data+diff.ms_setup+diff.ms_post) - * 1.0 / tra); - - printf ("%5.1f%5.1f%6.1f", - 1.0 * diff.ms_setup / tra, - 1.0 * diff.ms_post / tra, - 1.0 * diff.ms_disc / tra); - }; - - printf ("\n"); - fflush (stdout); - sleep (interval); - }; - }; -} - -/*================================================================ -** -** -** Port access -** -** -**================================================================ -*/ - -static int kernelwritefile; -static char* kernelwritefilename = _PATH_KMEM; - -void openkernelwritefile(void) -{ - if (kernelwritefile) return; - - kernelwritefile = open (kernelwritefilename, O_WRONLY); - if (kernelwritefile<3) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - }; -} - -void out (u_char reg, u_char val) -{ - u_long addr = ncr.vaddr + reg; - openkernelwritefile(); - if (lseek (kernelwritefile, addr, 0) != addr) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - } - if (write (kernelwritefile, &val, 1) < 0) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - }; -} - -u_char in (u_char reg) -{ - u_char res; - if (!KVM_READ ( - (ncr.vaddr + reg), - &res, - 1)) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - } - return (res); -} - -/*================================================================ -** -** -** Setting of driver parameters -** -** -**================================================================ -*/ - -void do_set (char * arg) -{ - struct usrcmd user; - u_long addr; - int i; - - open_kvm(O_RDWR); - addr = ncr_base + offsetof (struct ncb, user); - - for (i=3; i; i--) { - if (!KVM_READ ( - (addr), - &user, - sizeof (user))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - } - if (!user.cmd) break; - sleep (1); - } - if (user.cmd) { - fprintf (stderr, "%s: ncb.user busy.\n", prog); - exit (1); - }; - - user.target = target_mask; - user.lun = lun_mask; - user.data = 0; - user.cmd = 0; - - if (!strcmp(arg, "?")) { printf ( -"async: disable synchronous transfers.\n" -"sync=value: set the maximal synchronous transfer rate (MHz).\n" -"fast: set FAST SCSI-2.\n" -"\n" -"wide=value: set the bus width (0=8bit 1=16bit).\n" -"\n" -"tags=value: use this number of tags.\n" -"orderedtag: use ordered tags only.\n" -"simpletag: use simple tags only.\n" -"orderedwrite: use simple tags for read, else ordered tags.\n" -"\n" -"debug=value: set debug mode.\n" -"\n"); - return; - }; - - if (!strcmp(arg, "async")) { - user.data = 255; - user.cmd = UC_SETSYNC; - }; - - if (!strcmp(arg, "fast")) { - user.data = 25; - user.cmd = UC_SETSYNC; - }; - - if (!strncmp(arg, "sync=", 5)) { - float f = strtod (arg+5, NULL); - if (f>=4.0 && f<=10.0) { - user.data = 250.0 / f; - user.cmd = UC_SETSYNC; - }; - }; - - if (!strncmp(arg, "wide=", 5)) { - u_char t = strtoul (arg+5, (char**)0, 0); - if (t<=1) { - user.data = t; - user.cmd = UC_SETWIDE; - }; - }; - - if (!strncmp(arg, "tags=", 5)) { - u_char t = strtoul (arg+5, (char**)0, 0); - if (t<=MAX_TAGS) { - user.data = t; - user.cmd = UC_SETTAGS; - }; - }; - - if (!strncmp(arg, "flags=", 6)) { - u_char t = strtoul (arg+6, (char**)0, 0); - if (t<=0xff) { - user.data = t; - user.cmd = UC_SETFLAG; - }; - }; - - if (!strncmp(arg, "debug=", 6)) { - user.data = strtoul (arg+6, (char**)0, 0); - user.cmd = UC_SETDEBUG; - }; - - if (!strcmp(arg, "orderedtag")) { - user.data = M_ORDERED_TAG; - user.cmd = UC_SETORDER; - }; - - if (!strcmp(arg, "simpletag")) { - user.data = M_SIMPLE_TAG; - user.cmd = UC_SETORDER; - }; - - if (!strcmp(arg, "orderedwrite")) { - user.data = 0; - user.cmd = UC_SETORDER; - }; - - if (user.cmd) { - openkernelwritefile(); - - if (lseek (kernelwritefile, addr, 0) != addr) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - } - if (write (kernelwritefile, &user, sizeof (user)) < 0) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - } - - return; - }; - - fprintf (stderr, "%s: do_set \"%s\" not (yet) implemented.\n", - prog, arg); -} - -/*================================================================ -** -** -** D O _ K I L L -** -** -**================================================================ -*/ - -do_kill(char * arg) -{ - open_kvm(O_RDWR); - - if (!strcmp(arg, "?")) { printf ( -"scsireset: force SCSI bus reset.\n" -"scriptabort: send an abort cmd to the script processor.\n" -"scriptstart: start script processind (set SIGP bit).\n" -"evenparity: force even parity.\n" -"oddparity: force odd parity.\n" -"noreselect: disable reselect (force timeouts).\n" -"doreselect: enable reselect.\n" -"\n"); - return; - }; - - if (!wizard) { - fprintf (stderr, "%s: You are NOT a wizard!\n", prog); - exit (2); - }; - - if (!strcmp(arg, "scsireset")) { - out (0x01, 0x08); - out (0x01, 0x00); - return; - }; - if (!strcmp(arg, "scriptabort")) { - out (0x14, 0x80); - out (0x14, 0x20); - return; - }; - if (!strcmp(arg, "scriptstart")) { - out (0x14, 0x20); - return; - }; - if (!strcmp(arg, "evenparity")) { - out (0x01, 0x04); - return; - }; - if (!strcmp(arg, "oddparity")) { - out (0x01, 0x00); - return; - }; - if (!strcmp(arg, "noreselect")) { - out (0x04, in (0x04) & ~RRE); - return; - }; - if (!strcmp(arg, "doreselect")) { - out (0x04, in (0x04) | RRE); - return; - }; - fprintf (stderr, "%s: do_kill \"%s\" not (yet) implemented.\n", - prog, arg); -} - -/*================================================================ -** -** -** Write debug info: utilities: write symbolname. -** -** -**================================================================ -*/ - -static const char * sn (u_long a) -{ - static char buffer[100]; - - const char * s=""; - u_long d,m; - - a -= ncr.p_script; - m = sizeof (struct script); - - if ((d=a-offsetof(struct script, start))<m) m=d, s="<start>"; - if ((d=a-offsetof(struct script, start1))<m) m=d, s="<start1>"; - if ((d=a-offsetof(struct script, startpos))<m) m=d, s="<startpos>"; - if ((d=a-offsetof(struct script, tryloop))<m) m=d, s="<tryloop>"; - if ((d=a-offsetof(struct script, trysel))<m) m=d, s="<trysel>"; - if ((d=a-offsetof(struct script, skip))<m) m=d, s="<skip>"; - if ((d=a-offsetof(struct script, skip2))<m) m=d, s="<skip2>"; - if ((d=a-offsetof(struct script, idle))<m) m=d, s="<idle>"; - if ((d=a-offsetof(struct script, select))<m) m=d, s="<select>"; - if ((d=a-offsetof(struct script, prepare))<m) m=d, s="<prepare>"; - if ((d=a-offsetof(struct script, loadpos))<m) m=d, s="<loadpos>"; - if ((d=a-offsetof(struct script, prepare2))<m) m=d, s="<prepare2>"; - if ((d=a-offsetof(struct script, setmsg))<m) m=d, s="<setmsg>"; - if ((d=a-offsetof(struct script, clrack))<m) m=d, s="<clrack>"; - if ((d=a-offsetof(struct script, dispatch))<m) m=d, s="<dispatch>"; - if ((d=a-offsetof(struct script, checkatn))<m) m=d, s="<checkatn>"; - if ((d=a-offsetof(struct script, command))<m) m=d, s="<command>"; - if ((d=a-offsetof(struct script, status))<m) m=d, s="<status>"; - if ((d=a-offsetof(struct script, msg_in))<m) m=d, s="<msg_in>"; - if ((d=a-offsetof(struct script, msg_bad))<m) m=d, s="<msg_bad>"; - if ((d=a-offsetof(struct script, msg_parity))<m) m=d, s="<msg_parity>"; - if ((d=a-offsetof(struct script, msg_reject))<m) m=d, s="<msg_reject>"; - if ((d=a-offsetof(struct script, msg_extended))<m) m=d, s="<msg_extended>"; - if ((d=a-offsetof(struct script, msg_sdtr))<m) m=d, s="<msg_sdtr>"; - if ((d=a-offsetof(struct script, complete))<m) m=d, s="<complete>"; - if ((d=a-offsetof(struct script, cleanup))<m) m=d, s="<cleanup>"; - if ((d=a-offsetof(struct script, cleanup0))<m) m=d, s="<cleanup>"; - if ((d=a-offsetof(struct script, signal))<m) m=d, s="<signal>"; - if ((d=a-offsetof(struct script, save_dp))<m) m=d, s="<save_dp>"; - if ((d=a-offsetof(struct script, restore_dp))<m) m=d, s="<restore_dp>"; - if ((d=a-offsetof(struct script, disconnect))<m) m=d, s="<disconnect>"; - if ((d=a-offsetof(struct script, msg_out))<m) m=d, s="<msg_out>"; - if ((d=a-offsetof(struct script, msg_out_done))<m) m=d, s="<msg_out_done>"; - if ((d=a-offsetof(struct script, msg_out_abort))<m) m=d, s="<msg_out_abort>"; - if ((d=a-offsetof(struct script, getcc))<m) m=d, s="<getcc>"; - if ((d=a-offsetof(struct script, getcc1))<m) m=d, s="<getcc1>"; - if ((d=a-offsetof(struct script, getcc2))<m) m=d, s="<getcc2>"; - if ((d=a-offsetof(struct script, badgetcc))<m) m=d, s="<badgetcc>"; - if ((d=a-offsetof(struct script, reselect))<m) m=d, s="<reselect>"; - if ((d=a-offsetof(struct script, reselect2))<m) m=d, s="<reselect2>"; - if ((d=a-offsetof(struct script, resel_tmp))<m) m=d, s="<resel_tmp>"; - if ((d=a-offsetof(struct script, resel_lun))<m) m=d, s="<resel_lun>"; - if ((d=a-offsetof(struct script, resel_tag))<m) m=d, s="<resel_tag>"; - if ((d=a-offsetof(struct script, data_in))<m) m=d, s="<data_in>"; - if ((d=a-offsetof(struct script, data_out))<m) m=d, s="<data_out>"; - if ((d=a-offsetof(struct script, no_data))<m) m=d, s="<no_data>"; - if ((d=a-offsetof(struct script, aborttag))<m) m=d, s="<aborttag>"; - if ((d=a-offsetof(struct script, abort))<m) m=d, s="<abort>"; - - if (!*s) return s; - - sprintf (buffer, "%s:%d%c", s, m/4, 0); - return (buffer); -} - -/*================================================================ -** -** -** Write debug info: utilities: write misc. fields. -** -** -**================================================================ -*/ - -static void printm (u_char * msg, int len) -{ - u_char l; - do { - if (*msg==M_EXTENDED) - l=msg[1]+2; - else if ((*msg & 0xf0)==0x20) - l=2; - else l=1; - len-=l; - - printf (" %x",*msg++); - while (--l>0) printf ("-%x",*msg++); - } while (len>0); -} - -void dump_table (const char * str, struct scr_tblmove * p, int l) -{ - int i; - for (i=0;l>0;i++,p++,l--) if (p->size) { - printf (" %s[%d]: %5d @ 0x%08x\n", - str, i, p->size, p->addr); - }; -} - -void dump_link (const char* name, struct link * link) -{ - printf ("%s: cmd=%08x pa=%08x %s\n", - name, link->l_cmd, link->l_paddr, sn(link->l_paddr)); -} - -/*================================================================ -** -** -** Write debug info: utilities: write time fields. -** -** -**================================================================ -*/ - -void dump_tstamp (const char* name, struct tstamp * p) -#define P(id,fld)\ - if (p->fld.tv_sec) \ - printf ("%s: "id" at %s.%06d",\ - name,ctime(&p->fld.tv_sec),p->fld.tv_usec); -{ - P ("started ", start); - P ("ended ", end ); - P ("selected ", select); - P ("command ", command); - P ("data ", data); - P ("status ", status); - P ("disconnected", disconnect); - P ("reselected ", reselect); - printf ("\n"); -} - - - - -void dump_profile (const char* name, struct profile * p) -{ - printf ("%s: %10d transfers.\n" ,name,p->num_trans); - printf ("%s: %10d bytes transferred.\n",name,p->num_bytes); - printf ("%s: %10d disconnects.\n" ,name,p->num_disc); - printf ("%s: %10d short transfers.\n" ,name,p->num_break); - printf ("%s: %10d interrupts.\n" ,name,p->num_int); - printf ("%s: %10d on the fly ints.\n" ,name,p->num_fly); - printf ("%s: %10d ms setup time.\n" ,name,p->ms_setup); - printf ("%s: %10d ms data transfer.\n" ,name,p->ms_data); - printf ("%s: %10d ms disconnected.\n" ,name,p->ms_disc); - printf ("%s: %10d ms postprocessing.\n",name,p->ms_post); - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: utilities: write script registers. -** -** -**================================================================ -*/ - -static void dump_reg(struct ncr_reg * rp) -{ - u_char *reg = (u_char*) rp; -#define l(i) (reg[i]+(reg[i+1]<<8ul)+(reg[i+2]<<16ul)+(reg[i+3]<<24ul)) - int ad; - - char*(phasename[8])={"DATA-OUT","DATA-IN","COMMAND","STATUS", - "ILG-OUT","ILG-IN","MESSAGE-OUT","MESSAGE-IN"}; - for (ad=0x00;ad<0x80;ad++) { - switch (ad % 16) { - - case 0: - printf (" %02x:\t",ad); - break; - case 8: - printf (" : "); - break; - default: - printf (" "); - }; - printf ("%02x", reg[ad]); - if (ad % 16 == 15) printf ("\n"); - }; - printf ("\n"); - printf (" DSP %08x %-20s CMD %08x DSPS %08x %s\n", - l(0x2c),sn(l(0x2c)),l(0x24),l(0x30), sn(l(0x30))); - printf (" TEMP %08x %-20s DSA %08x\n", - l(0x1c),sn(l(0x1c)),l(0x10)); - printf ("\n"); - printf (" Busstatus: "); - if ((reg[0x0b]>>7)&1) printf (" Req"); - if ((reg[0x0b]>>6)&1) printf (" Ack"); - if ((reg[0x0b]>>5)&1) printf (" Bsy"); - if ((reg[0x0b]>>4)&1) printf (" Sel"); - if ((reg[0x0b]>>3)&1) printf (" Atn"); - printf (" %s\n", phasename[reg[0x0b]&7]); - - printf (" Dmastatus: "); - if ((reg[0x0c]>>7)&1) printf (" FifoEmpty"); - if ((reg[0x0c]>>6)&1) printf (" MasterParityError"); - if ((reg[0x0c]>>5)&1) printf (" BusFault"); - if ((reg[0x0c]>>4)&1) printf (" Aborted"); - if ((reg[0x0c]>>3)&1) printf (" SingleStep"); - if ((reg[0x0c]>>2)&1) printf (" Interrupt"); - if ((reg[0x0c]>>0)&1) printf (" IllegalInstruction"); - printf ("\n"); - printf (" Intstatus: "); - if ((reg[0x14]>>7)&1) printf (" Abort"); - if ((reg[0x14]>>6)&1) printf (" SoftwareReset"); - if ((reg[0x14]>>5)&1) printf (" SignalProcess"); - if ((reg[0x14]>>4)&1) printf (" Semaphore"); - if ((reg[0x14]>>3)&1) printf (" Connected"); - if ((reg[0x14]>>2)&1) printf (" IntOnTheFly"); - if ((reg[0x14]>>1)&1) printf (" SCSI-Interrupt"); - if ((reg[0x14]>>0)&1) printf (" DMA-Interrupt"); - printf ("\n"); - printf (" ScsiIstat: "); - if ((reg[0x42]>>7)&1) printf (" PhaseMismatch"); - if ((reg[0x42]>>6)&1) printf (" Complete"); - if ((reg[0x42]>>5)&1) printf (" Selected"); - if ((reg[0x42]>>4)&1) printf (" Reselected"); - if ((reg[0x42]>>3)&1) printf (" GrossError"); - if ((reg[0x42]>>2)&1) printf (" UnexpectedDisconnect"); - if ((reg[0x42]>>1)&1) printf (" ScsiReset"); - if ((reg[0x42]>>0)&1) printf (" ParityError"); - if ((reg[0x43]>>2)&1) printf (" SelectionTimeout"); - if ((reg[0x43]>>1)&1) printf (" TimerExpired"); - if ((reg[0x43]>>0)&1) printf (" HandshakeTimeout"); - printf ("\n"); - printf (" ID=%d DEST-ID=%d RESEL-ID=%d\n", reg[4]&7, reg[6]&7, reg[0xa]&7); - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: utilities: write header. -** -** -**================================================================ -*/ - -char * debug_opt; - -dump_head (struct head * hp) -{ - dump_link (" launch", & hp->launch); - printf (" savep: %08x %s\n", - hp->savep, sn((u_long) hp->savep)); - printf (" cp: %08x %s\n", - hp->cp, sn((u_long)hp->cp)); - if (strchr (debug_opt, 'y')) { - printf ("\n"); - dump_tstamp (" timestamp", &hp->stamp); - }; - - printf (" status: %x %x %x %x %x %x %x %x\n", - hp->status[0], hp->status[1], hp->status[2], hp->status[3], - hp->status[4], hp->status[5], hp->status[6], hp->status[7]); - - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: utilities: write ccb. -** -** -**================================================================ -*/ - -void dump_ccb (struct ccb * cp, u_long base) -{ - printf ("----------------------\n"); - printf ("struct ccb @ %08x:\n", base); - printf ("----------------------\n"); - - dump_link (" next", &cp->jump_ccb); - dump_link (" call", &cp->call_tmp); - - dump_head (&cp->phys.header); - - if (strchr (debug_opt, 's')) { - dump_table(" smsg", &cp->phys.smsg, 1); - dump_table("smsg2", &cp->phys.smsg2, 1); - dump_table(" cmd", &cp->phys.cmd, 1); - dump_table(" data", &cp->phys.data[0],MAX_SCATTER); - dump_table("sense", &cp->phys.sense, 1); - }; - - if (strchr (debug_opt, 'a')) { - int i; - for (i=0; i<8; i++) - printf (" patch[%d]: %08x\n", i, cp->patch[i]); - }; - - if (strchr (debug_opt, 'x')) { - printf (" xfer: -- dump not yet implemented.\n"); - }; - - if (strchr (debug_opt, 'm')) { - printf (" smsg:"); - printm (cp->scsi_smsg, cp->phys.smsg.size); - printf ("\n"); - printf (" smsg2:"); - printm (cp->scsi_smsg2, cp->phys.smsg2.size); - printf ("\n"); - }; - - printf (" magic: %x\n", cp->magic); - if (cp->tlimit) - printf (" timeout at: %s", ctime((time_t*)&cp->tlimit)); - printf (" link_ccb: %08x\n", (u_long) cp->link_ccb); - printf (" next_ccb: %08x\n", (u_long) cp->next_ccb); - printf (" tag: %d\n", cp->tag); - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: struct lcb -** -** -**================================================================ -*/ - -static void dump_lcb (u_long base) -{ - struct lcb l; - struct ccb c; - u_long cp,cn; - - printf ("----------------------\n"); - printf ("struct lcb @ %08x:\n", base); - printf ("----------------------\n"); - - if (!KVM_READ ( - base, - &l, - sizeof (struct lcb))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - printf (" reqccbs: %d\n", l.reqccbs); - printf (" actccbs: %d\n", l.actccbs); - printf (" reqlink: %d\n", l.reqlink); - printf (" actlink: %d\n", l.actlink); - printf (" usetags: %d\n", l.usetags); - dump_link (" jump_lcb", &l.jump_lcb); - dump_link (" call_tag", &l.call_tag); - dump_link (" jump_ccb", &l.jump_ccb); - printf ("\n"); - cp = (u_long) l.next_ccb; - cn = 0; - while (cp) { - cn++; - printf ("ccb #%d:\n", cn); - if (!KVM_READ ( - cp, - &c, - sizeof (struct ccb))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - dump_ccb (&c, cp); - cp= (u_long) c.next_ccb; - }; -} - -/*================================================================ -** -** -** Write debug info: struct tcb -** -** -**================================================================ -*/ - -static void dump_tip (struct tcb * tip) -{ - int i; - u_long lp; - - printf ("----------------------\n"); - printf ("struct tcb:\n"); - printf ("----------------------\n"); - - printf (" transfers:%10d.\n", tip->transfers); - printf (" bytes:%10d.\n", tip->bytes ); - printf (" user limits: usrsync=%d usrwide=%d usrtags=%d.\n", - tip->usrsync, tip->usrwide, tip->usrtags); - printf (" sync: minsync=%d, maxoffs=%d, period=%d ns, sval=%x.\n", - tip->minsync, tip->maxoffs, tip->period, tip->sval); - printf (" wide: widedone=%d, wval=%x.\n", - tip->widedone, tip->wval); - - printf (" hold_cp: %x\n", tip->hold_cp); - dump_link (" jump_tcb", &tip->jump_tcb); - dump_link (" call_lun", &tip->call_lun); - dump_link (" jump_lcb", &tip->jump_lcb); - if (tip->hold_cp) printf (" hold_cp: @ %x\n", tip->hold_cp); - printf ("\n"); - - if (strchr (debug_opt, 'l')) { - for (i=0;i<MAX_LUN;i++) { - lp= (u_long) tip->lp[i]; - printf ("logic unit #%d:\n", i); - if (lp) dump_lcb (lp); - }; - } -} - -/*================================================================ -** -** -** Write debug info: struct ncb -** -** -**================================================================ -*/ - - -static void dump_ncr (void) -{ - u_long tp; - int i; - - printf ("----------------------\n"); - printf ("struct ncb @ %x:\n", ncr_base); - printf ("----------------------\n"); - - dump_link (" jump_tcb", &ncr.jump_tcb); - printf (" register: @ %x (p=%x)\n", ncr.vaddr, ncr.paddr); - - if (strchr (debug_opt, 'r')) { - struct ncr_reg reg; - - if (!KVM_READ ( - ncr.vaddr, - ®, - sizeof (reg))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - printf ("\n"); - dump_reg (®); - }; - - printf (" script: @ %x (p=%x)\n", ncr.script, ncr.p_script); - - printf ("hostscsiaddr: %d\n", ncr.myaddr); - printf (" ns_async: %d ns\n", ncr.ns_async); - printf (" ns_sync : %d ns\n", ncr.ns_sync); - printf (" scntl3: 0x%02x\n", ncr.rv_scntl3); - printf ("\n"); - - /* sc_link not dumped */ - - if (strchr (debug_opt, 'u')) { - printf (" usercmd: cmd=%x data=%x target=%x lun=%x\n", - ncr.user.cmd, - ncr.user.data, - ncr.user.target, - ncr.user.lun); - }; - - printf (" actccbs: %d\n", ncr.actccbs); - - if (strchr (debug_opt, 'q')) { - - u_long startpos; - - if (!KVM_READ ( - ((u_long)ncr.script - +offsetof(struct script, startpos)), - &startpos, - sizeof (startpos))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - printf (" startpos: %x\n", startpos); - printf (" slot: %d\n", (startpos- - (ncr.p_script+offsetof(struct script, tryloop)))/20); - printf (" squeuput: %d\n", ncr.squeueput); - for (i=0; i<MAX_START; i++) - printf ("%12d: %08x %s\n", i, - ncr.squeue[i], sn(ncr.squeue[i])); - - printf ("\n"); - }; - - printf (" ticks: %d ms\n", ncr.ticks * 10); - printf (" heartbeat: %s", ctime ((time_t*)&ncr.heartbeat)); - printf (" lasttime: %s", ctime ((time_t*)&ncr.lasttime)); -#ifndef __NetBSD__ - printf ("imask/mcount: %x / %d\n", ncr.imask, ncr.mcount); -#endif - printf ("\n"); - - if (strchr (debug_opt, 'd') && ncr.regtime.tv_sec) { - printf (" regdump: %s", ctime (&ncr.regtime.tv_sec)); - dump_reg (&ncr.regdump); - }; - - if (strchr (debug_opt, 'p')) { - printf ("\n"); - dump_profile (" profile", &ncr.profile); - }; - - if (strchr (debug_opt, 'h')) { - printf ("\n"); - dump_head ( &ncr.header); - }; - - if (strchr (debug_opt, 'c')) { - dump_ccb (&ncr.ccb, ncr_base + offsetof (struct ncb, ccb)); - }; - - if (strchr (debug_opt, 'm')) { - printf (" msgout:"); printm (ncr.msgout,0); printf ("\n"); - printf (" msg in:"); printm (ncr.msgin,0); printf ("\n"); - printf ("\n"); - }; - - if (strchr (debug_opt, 't')) { - struct tcb * tip; - for (i=0;i<MAX_TARGET;i++) { - tip = &ncr.target[i]; - if (!tip->jump_tcb.l_cmd) continue; - printf ("target #%d:\n", i); - dump_tip (tip); - } - } -} - -/*================================================================ -** -** -** D O _ D E B U G -** -** -**================================================================ -*/ - - -do_debug(char * arg) -{ - open_kvm(O_RDONLY); - debug_opt = arg; - if (strchr (debug_opt, '?')) printf ( -"'?': list debug options [sic].\n" -"'a': show patchfields in ccbs (requires c).\n" -"'c': show ccbs.\n" -"'d': show register dump.\n" -"'h': show header information.\n" -"'m': show message buffers.\n" -"'n': show ncr main control block.\n" -"'p': show profiling information.\n" -"'q': show start queue.\n" -"'r': show registers (*DANGEROUS*).\n" -"'s': show scatter/gather info.\n" -"'t': show target control blocks.\n" -"'u': show user cmd field.\n" -"'x': show generic xfer structure.\n" -"'y': show timestamps.\n" -"\n" - ); - - if (strchr (debug_opt, 'n')) dump_ncr (); - if (strchr (debug_opt, 'r')) { - struct ncr_reg reg; - if (!KVM_READ ( - ncr.vaddr, - ®, - sizeof (reg))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - dump_reg (®); - }; -} - - -/*================================================================ -** -** -** Main function -** -** -**================================================================ -*/ - -void main(argc, argv) - int argc; - char **argv; -{ - extern char *optarg; - extern int optind; - int usage=0; - char * charp; - int ch, getopt(),atoi(); - int i,step; - - prog = *argv; - while ((ch = getopt(argc, argv, "M:N:u:f:t:l:p:s:k:d:vwhin:?")) != -1) - switch((char)ch) { - case 'M': - if (kvm_isopen) { - fprintf (stderr, - "%s: -M: kernel file already open.\n", - prog); - exit (1); - }; - kmemf = optarg; - break; - case 'N': - if (kvm_isopen) { - fprintf (stderr, - "%s: -N: symbol table already open.\n", - prog); - exit (1); - }; - vmunix = optarg; - break; - case 'f': - fprintf (stderr, - "%s: -f: option not yet implemented.\n", - prog); - exit (1); - - case 'u': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<0)) { - fprintf (stderr, - "%s: bad unit number \"%s\".\n", - prog, optarg); - exit (1); - } - ncr_unit = i; - break; - case 't': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<0) || (i>=MAX_TARGET)) { - fprintf (stderr, - "%s: bad target number \"%s\" (valid range: 0-%d).\n", - prog, optarg, MAX_TARGET-1); - exit (1); - } - target_mask |= 1ul << i; - break; - case 'n': - open_kvm(O_RDONLY); - i = strtoul (optarg, &charp, 0); - printf ("addr %d (0x%x) has label %s.\n", - i,i,sn(i)); - break; - case 'l': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<0) || (i>=MAX_LUN)) { - fprintf (stderr, - "%s: bad logic unit number \"%s\" (valid range: 0-%d).\n", - prog, optarg, MAX_LUN); - exit (1); - } - global_lun_mask |= 1ul << i; - break; - case 'p': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<1) || (i>60)) { - fprintf (stderr, - "%s: bad interval \"%s\".\n", - prog, optarg); - exit (1); - } - interval = i; - do_profile(); - break; - - case 'w': - wizard=1; - break; - case 'v': - verbose++; - break; - case 'i': - do_info(); - break; - - case 's': - do_set(optarg); - break; - case 'd': - do_debug(optarg); - break; - case 'k': - do_kill(optarg); - break; - case 'h': - case '?': - usage++; - break; - default:(void)fprintf(stderr, - "%s: illegal option \"%c\".\n", prog, ch); - usage++; - } - - argv += optind; - argc -= optind; - - if (argc) printf ("%s: rest of line starting with \"%s\" ignored.\n", - prog, *argv); - - if (verbose&&!kvm_isopen) usage++; - if (usage) { - fprintf (stderr, - "Usage:\n" - "\n" - "%s [-M$] [-N$] {-f$} {-t#} {-l#} [-hivw?] [-d$] [-s$] [-k] [[-p] <time>]\n" - "\n" - "-t <#> select target number\n" - "-l <#> select lun number\n" - "-i get info\n" - "-v verbose\n" - "-p <seconds> performance data\n" - "\n" - "Wizards only (proceed on your own risk):\n" - "-n <#> get the name for address #\n" - "-w wizard mode\n" - "-d <options> debug info\n" - "-d? list debug options\n" - "-s <param=value> set parameter\n" - "-s? list parameters\n" - "-k <torture> torture driver by simulating errors\n" - "-k? list tortures\n" - "-M <kernelimage> (default: %s)\n" - "-N <symboltable> (default: %s)\n" - , prog, _PATH_KMEM, _PATH_UNIX); - if (verbose) fprintf (stderr, ident); - exit (1); - } - - if (!kvm_isopen) { - do_info(); - do_profile(); - }; - exit (0); -} diff --git a/sys/i386/pci/ncrreg.h b/sys/i386/pci/ncrreg.h deleted file mode 100644 index 1a22aee..0000000 --- a/sys/i386/pci/ncrreg.h +++ /dev/null @@ -1,547 +0,0 @@ -/************************************************************************** -** -** $Id: ncrreg.h,v 2.3 94/10/09 21:10:34 wolf Oct11 $ -** -** Device driver for the NCR 53C810 PCI-SCSI-Controller. -** -** 386bsd / FreeBSD / NetBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** wolf@dentaro.gun.de Wolfgang Stanglmeier -** se@mi.Uni-Koeln.de Stefan Esser -** -** Ported to NetBSD by -** mycroft@gnu.ai.mit.edu -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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. -** -*************************************************************************** -*/ - -#ifndef __NCR_REG_H__ -#define __NCR_REG_H__ - - -/*----------------------------------------------------------------- -** -** The ncr 53c810 register structure. -** -**----------------------------------------------------------------- -*/ - -struct ncr_reg { -/*00*/ u_char nc_scntl0; /* full arb., ena parity, par->ATN */ - -/*01*/ u_char nc_scntl1; /* no reset */ - #define ISCON 0x10 /* connected to scsi */ - #define CRST 0x08 /* force reset */ - -/*02*/ u_char nc_scntl2; /* no disconnect expected */ - #define SDU 0x80 /* cmd: disconnect will raise error */ - #define CHM 0x40 /* sta: chained mode */ - #define WSS 0x08 /* sta: wide scsi send [W]*/ - #define WSR 0x01 /* sta: wide scsi received [W]*/ - -/*03*/ u_char nc_scntl3; /* cnf system clock dependent */ - #define EWS 0x08 /* cmd: enable wide scsi [W]*/ - -/*04*/ u_char nc_scid; /* cnf host adapter scsi address */ - #define RRE 0x40 /* r/w:e enable response to resel. */ - #define SRE 0x20 /* r/w:e enable response to select */ - -/*05*/ u_char nc_sxfer; /* ### Sync speed and count */ - -/*06*/ u_char nc_sdid; /* ### Destination-ID */ - -/*07*/ u_char nc_gpreg; /* ??? IO-Pins */ - -/*08*/ u_char nc_sfbr; /* ### First byte in phase */ - -/*09*/ u_char nc_socl; - #define CREQ 0x80 /* r/w: SCSI-REQ */ - #define CACK 0x40 /* r/w: SCSI-ACK */ - #define CBSY 0x20 /* r/w: SCSI-BSY */ - #define CSEL 0x10 /* r/w: SCSI-SEL */ - #define CATN 0x08 /* r/w: SCSI-ATN */ - #define CMSG 0x04 /* r/w: SCSI-MSG */ - #define CC_D 0x02 /* r/w: SCSI-C_D */ - #define CI_O 0x01 /* r/w: SCSI-I_O */ - -/*0a*/ u_char nc_ssid; - -/*0b*/ u_char nc_sbcl; - -/*0c*/ u_char nc_dstat; - #define DFE 0x80 /* sta: dma fifo empty */ - #define MDPE 0x40 /* int: master data parity error */ - #define BF 0x20 /* int: script: bus fault */ - #define ABRT 0x10 /* int: script: command aborted */ - #define SSI 0x08 /* int: script: single step */ - #define SIR 0x04 /* int: script: interrupt instruct. */ - #define IID 0x01 /* int: script: illegal instruct. */ - -/*0d*/ u_char nc_sstat0; - #define ILF 0x80 /* sta: data in SIDL register lsb */ - #define ORF 0x40 /* sta: data in SODR register lsb */ - #define OLF 0x20 /* sta: data in SODL register lsb */ - #define AIP 0x10 /* sta: arbitration in progress */ - #define LOA 0x08 /* sta: arbitration lost */ - #define WOA 0x04 /* sta: arbitration won */ - #define IRST 0x02 /* sta: scsi reset signal */ - #define SDP 0x01 /* sta: scsi parity signal */ - -/*0e*/ u_char nc_sstat1; - #define FF3210 0xf0 /* sta: bytes in the scsi fifo */ - -/*0f*/ u_char nc_sstat2; - #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/ - #define ORF1 0x40 /* sta: data in SODR register msb[W]*/ - #define OLF1 0x20 /* sta: data in SODL register msb[W]*/ - -/*10*/ u_long nc_dsa; /* --> Base page */ - -/*14*/ u_char nc_istat; /* --> Main Command and status */ - #define CABRT 0x80 /* cmd: abort current operation */ - #define SRST 0x40 /* mod: reset chip */ - #define SIGP 0x20 /* r/w: message from host to ncr */ - #define SEM 0x10 /* r/w: message between host + ncr */ - #define CON 0x08 /* sta: connected to scsi */ - #define INTF 0x04 /* sta: int on the fly (reset by wr)*/ - #define SIP 0x02 /* sta: scsi-interrupt */ - #define DIP 0x01 /* sta: host/script interrupt */ - -/*15*/ u_char nc_15_; -/*16*/ u_char nc_16_; -/*17*/ u_char nc_17_; - -/*18*/ u_char nc_ctest0; -/*19*/ u_char nc_ctest1; - -/*1a*/ u_char nc_ctest2; - #define CSIGP 0x40 - -/*1b*/ u_char nc_ctest3; - #define CLF 0x04 /* clear scsi fifo */ - -/*1c*/ u_long nc_temp; /* ### Temporary stack */ - -/*20*/ u_char nc_dfifo; -/*21*/ u_char nc_ctest4; -/*22*/ u_char nc_ctest5; -/*23*/ u_char nc_ctest6; - -/*24*/ u_long nc_dbc; /* ### Byte count and command */ -/*28*/ u_long nc_dnad; /* ### Next command register */ -/*2c*/ u_long nc_dsp; /* --> Script Pointer */ -/*30*/ u_long nc_dsps; /* --> Script pointer save/opcode#2 */ -/*34*/ u_long nc_scratcha; /* ??? Temporary register a */ - -/*38*/ u_char nc_dmode; -/*39*/ u_char nc_dien; -/*3a*/ u_char nc_dwt; - -/*3b*/ u_char nc_dcntl; /* --> Script execution control */ - #define SSM 0x10 /* mod: single step mode */ - #define STD 0x04 /* cmd: start dma mode */ - #define NOCOM 0x01 /* cmd: protect sfbr while reselect */ - -/*3c*/ u_long nc_adder; - -/*40*/ u_short nc_sien; /* -->: interrupt enable */ -/*42*/ u_short nc_sist; /* <--: interrupt status */ - #define STO 0x0400/* sta: timeout (select) */ - #define GEN 0x0200/* sta: timeout (general) */ - #define HTH 0x0100/* sta: timeout (handshake) */ - #define MA 0x80 /* sta: phase mismatch */ - #define CMP 0x40 /* sta: arbitration complete */ - #define SEL 0x20 /* sta: selected by another device */ - #define RSL 0x10 /* sta: reselected by another device*/ - #define SGE 0x08 /* sta: gross error (over/underflow)*/ - #define UDC 0x04 /* sta: unexpected disconnect */ - #define RST 0x02 /* sta: scsi bus reset detected */ - #define PAR 0x01 /* sta: scsi parity error */ - -/*44*/ u_char nc_slpar; -/*45*/ u_char nc_swide; -/*46*/ u_char nc_macntl; -/*47*/ u_char nc_gpcntl; -/*48*/ u_char nc_stime0; /* cmd: timeout for select&handshake*/ -/*49*/ u_char nc_stime1; /* cmd: timeout user defined */ -/*4a*/ u_short nc_respid; /* sta: Reselect-IDs */ - -/*4c*/ u_char nc_stest0; - -/*4d*/ u_char nc_stest1; - -/*4e*/ u_char nc_stest2; - #define ROF 0x40 /* reset scsi offset (after gross error!) */ - #define EXT 0x02 /* extended filtering */ - -/*4f*/ u_char nc_stest3; - #define TE 0x80 /* c: tolerAnt enable */ - #define CSF 0x02 /* c: clear scsi fifo */ - -/*50*/ u_short nc_sidl; /* Lowlevel: latched from scsi data */ -/*52*/ u_short nc_52_; -/*54*/ u_short nc_sodl; /* Lowlevel: data out to scsi data */ -/*56*/ u_short nc_56_; -/*58*/ u_short nc_sbdl; /* Lowlevel: data from scsi data */ -/*5a*/ u_short nc_5a_; -/*5c*/ u_char nc_scr0; /* Working register B */ -/*5d*/ u_char nc_scr1; /* */ -/*5e*/ u_char nc_scr2; /* */ -/*5f*/ u_char nc_scr3; /* */ -/*60*/ -}; - -/*----------------------------------------------------------- -** -** Utility macros for the script. -** -**----------------------------------------------------------- -*/ - -#define REGJ(p,r) (offsetof(struct ncr_reg, p ## r)) -#define REG(r) REGJ (nc_, r) - -#ifndef TARGET_MODE -#define TARGET_MODE 0 -#endif - -typedef unsigned long ncrcmd; - -/*----------------------------------------------------------- -** -** SCSI phases -** -**----------------------------------------------------------- -*/ - -#define SCR_DATA_OUT 0x00000000 -#define SCR_DATA_IN 0x01000000 -#define SCR_COMMAND 0x02000000 -#define SCR_STATUS 0x03000000 -#define SCR_ILG_OUT 0x04000000 -#define SCR_ILG_IN 0x05000000 -#define SCR_MSG_OUT 0x06000000 -#define SCR_MSG_IN 0x07000000 - -/*----------------------------------------------------------- -** -** Data transfer via SCSI. -** -**----------------------------------------------------------- -** -** MOVE_ABS (LEN) -** <<start address>> -** -** MOVE_IND (LEN) -** <<dnad_offset>> -** -** MOVE_TBL -** <<dnad_offset>> -** -**----------------------------------------------------------- -*/ - -#define SCR_MOVE_ABS(l) ((0x08000000 ^ (TARGET_MODE << 1ul)) | (l)) -#define SCR_MOVE_IND(l) ((0x28000000 ^ (TARGET_MODE << 1ul)) | (l)) -#define SCR_MOVE_TBL (0x18000000 ^ (TARGET_MODE << 1ul)) - -struct scr_tblmove { - u_long size; - u_long addr; -}; - -/*----------------------------------------------------------- -** -** Selection -** -**----------------------------------------------------------- -** -** SEL_ABS | SCR_ID (0..7) [ | REL_JMP] -** <<alternate_address>> -** -** SEL_TBL | << dnad_offset>> [ | REL_JMP] -** <<alternate_address>> -** -**----------------------------------------------------------- -*/ - -#define SCR_SEL_ABS 0x40000000 -#define SCR_SEL_ABS_ATN 0x41000000 -#define SCR_SEL_TBL 0x42000000 -#define SCR_SEL_TBL_ATN 0x43000000 - -struct scr_tblsel { - u_char sel_0; - u_char sel_sxfer; - u_char sel_id; - u_char sel_scntl3; -}; - -#define SCR_JMP_REL 0x04000000 -#define SCR_ID(id) (((u_long)(id)) << 16) - -/*----------------------------------------------------------- -** -** Waiting for Disconnect or Reselect -** -**----------------------------------------------------------- -** -** WAIT_DISC -** dummy: <<alternate_address>> -** -** WAIT_RESEL -** <<alternate_address>> -** -**----------------------------------------------------------- -*/ - -#define SCR_WAIT_DISC 0x48000000 -#define SCR_WAIT_RESEL 0x50000000 - -/*----------------------------------------------------------- -** -** Bit Set / Reset -** -**----------------------------------------------------------- -** -** SET (flags {|.. }) -** -** CLR (flags {|.. }) -** -**----------------------------------------------------------- -*/ - -#define SCR_SET(f) (0x58000000 | (f)) -#define SCR_CLR(f) (0x60000000 | (f)) - -#define SCR_CARRY 0x00000400 -#define SCR_TRG 0x00000200 -#define SCR_ACK 0x00000040 -#define SCR_ATN 0x00000008 - - - - -/*----------------------------------------------------------- -** -** Memory to memory move -** -**----------------------------------------------------------- -** -** COPY (bytecount) -** << source_address >> -** << destination_address >> -** -**----------------------------------------------------------- -*/ - -#define SCR_COPY(n) (0xc0000000 | (n)) - -/*----------------------------------------------------------- -** -** Register move and binary operations -** -**----------------------------------------------------------- -** -** SFBR_REG (reg, op, data) reg = SFBR op data -** << 0 >> -** -** REG_SFBR (reg, op, data) SFBR = reg op data -** << 0 >> -** -** REG_REG (reg, op, data) reg = reg op data -** << 0 >> -** -**----------------------------------------------------------- -*/ - -#define SCR_REG_OFS(ofs) ((ofs) << 16ul) - -#define SCR_SFBR_REG(reg,op,data) \ - (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | ((data)<<8ul)) - -#define SCR_REG_SFBR(reg,op,data) \ - (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | ((data)<<8ul)) - -#define SCR_REG_REG(reg,op,data) \ - (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | ((data)<<8ul)) - - -#define SCR_LOAD 0x00000000 -#define SCR_SHL 0x01000000 -#define SCR_OR 0x02000000 -#define SCR_XOR 0x03000000 -#define SCR_AND 0x04000000 -#define SCR_SHR 0x05000000 -#define SCR_ADD 0x06000000 -#define SCR_ADDC 0x07000000 - -/*----------------------------------------------------------- -** -** FROM_REG (reg) reg = SFBR -** << 0 >> -** -** TO_REG (reg) SFBR = reg -** << 0 >> -** -** LOAD_REG (reg, data) reg = <data> -** << 0 >> -** -** LOAD_SFBR(data) SFBR = <data> -** << 0 >> -** -**----------------------------------------------------------- -*/ - -#define SCR_FROM_REG(reg) \ - SCR_REG_SFBR(reg,SCR_OR,0) - -#define SCR_TO_REG(reg) \ - SCR_SFBR_REG(reg,SCR_OR,0) - -#define SCR_LOAD_REG(reg,data) \ - SCR_REG_REG(reg,SCR_LOAD,data) - -#define SCR_LOAD_SFBR(data) \ - (SCR_REG_SFBR (gpreg, SCR_LOAD, data)) - -/*----------------------------------------------------------- -** -** Waiting for Disconnect or Reselect -** -**----------------------------------------------------------- -** -** JUMP [ | IFTRUE/IFFALSE ( ... ) ] -** <<address>> -** -** JUMPR [ | IFTRUE/IFFALSE ( ... ) ] -** <<distance>> -** -** CALL [ | IFTRUE/IFFALSE ( ... ) ] -** <<address>> -** -** CALLR [ | IFTRUE/IFFALSE ( ... ) ] -** <<distance>> -** -** RETURN [ | IFTRUE/IFFALSE ( ... ) ] -** <<dummy>> -** -** INT [ | IFTRUE/IFFALSE ( ... ) ] -** <<ident>> -** -** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ] -** <<ident>> -** -** Conditions: -** WHEN (phase) -** IF (phase) -** CARRY -** DATA (data, mask) -** -**----------------------------------------------------------- -*/ - -#define SCR_JUMP 0x80080000 -#define SCR_JUMPR 0x80880000 -#define SCR_CALL 0x88080000 -#define SCR_CALLR 0x88880000 -#define SCR_RETURN 0x90080000 -#define SCR_INT 0x98080000 -#define SCR_INT_FLY 0x98180000 - -#define IFFALSE(arg) (0x00080000 | (arg)) -#define IFTRUE(arg) (0x00000000 | (arg)) - -#define WHEN(phase) (0x00030000 | (phase)) -#define IF(phase) (0x00020000 | (phase)) - -#define DATA(D) (0x00040000 | ((D) & 0xff)) -#define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff)) - -#define CARRYSET (0x00200000) - -/*----------------------------------------------------------- -** -** SCSI constants. -** -**----------------------------------------------------------- -*/ - -/* -** Messages -*/ - -#define M_COMPLETE (0x00) -#define M_EXTENDED (0x01) -#define M_SAVE_DP (0x02) -#define M_RESTORE_DP (0x03) -#define M_DISCONNECT (0x04) -#define M_ID_ERROR (0x05) -#define M_ABORT (0x06) -#define M_REJECT (0x07) -#define M_NOOP (0x08) -#define M_PARITY (0x09) -#define M_LCOMPLETE (0x0a) -#define M_FCOMPLETE (0x0b) -#define M_RESET (0x0c) -#define M_ABORT_TAG (0x0d) -#define M_CLEAR_QUEUE (0x0e) -#define M_INIT_REC (0x0f) -#define M_REL_REC (0x10) -#define M_TERMINATE (0x11) -#define M_SIMPLE_TAG (0x20) -#define M_HEAD_TAG (0x21) -#define M_ORDERED_TAG (0x22) -#define M_IGN_RESIDUE (0x23) -#define M_IDENTIFY (0x80) - -#define M_X_MODIFY_DP (0x00) -#define M_X_SYNC_REQ (0x01) -#define M_X_WIDE_REQ (0x03) - -/* -** Status -*/ - -#define S_GOOD (0x00) -#define S_CHECK_COND (0x02) -#define S_COND_MET (0x04) -#define S_BUSY (0x08) -#define S_INT (0x10) -#define S_INT_COND_MET (0x14) -#define S_CONFLICT (0x18) -#define S_TERMINATED (0x20) -#define S_QUEUE_FULL (0x28) -#define S_ILLEGAL (0xff) -#define S_SENSE (0x80) - -#endif /*__NCR_REG_H__*/ diff --git a/sys/i386/pci/ncrstat.c b/sys/i386/pci/ncrstat.c deleted file mode 100644 index d7208b4..0000000 --- a/sys/i386/pci/ncrstat.c +++ /dev/null @@ -1,1630 +0,0 @@ -/************************************************************************** -** -** $Id: ncrstat.c,v 2.0.0.10 94/09/16 09:38:24 wolf Exp $ -** -** Utility for NCR 53C810 device driver. -** -** 386bsd / FreeBSD / NetBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** wolf@dentaro.gun.de Wolfgang Stanglmeier -** se@mi.Uni-Koeln.de Stefan Esser -** -** Ported to NetBSD by -** mycroft@gnu.ai.mit.edu -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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/file.h> -#include <sys/types.h> -#ifdef __NetBSD__ -#include <sys/device.h> -#endif -#include <nlist.h> -#include <stdio.h> -#include <errno.h> -#include <paths.h> -#include <limits.h> -#include <kvm.h> -#include <i386/pci/ncr.c> - -/* -** used external functions -*/ - -#if defined(__NetBSD__) || (__FreeBSD__ >= 2) -kvm_t *kvm; -#define KVM_NLIST(n) (kvm_nlist(kvm, (n)) >= 0) -#define KVM_READ(o, p, l) (kvm_read(kvm, (o), (void*)(p), (l)) == (l)) -#else -#define KVM_NLIST(n) (kvm_nlist((n)) >= 0) -#define KVM_READ(o, p, l) (kvm_read((void*)(o), (p), (l)) == (l)) -#endif - -extern void exit(); -extern char* strerror (int num); - -/*=========================================================== -** -** Global variables. -** -**=========================================================== -*/ - -char *prog; -u_long verbose; -u_long wizard; - - - -struct nlist nl[] = { -#define N_NCR_VERSION 0 - { "_ncr_version" }, -#ifdef __NetBSD__ -#define N_NCRCD 1 - { "_ncrcd" }, -#else -#define N_NCRP 1 - { "_ncrp" }, -#define N_NNCR 2 - { "_nncr" }, -#endif - { 0 } -}; - - -char *vmunix = _PATH_UNIX; -char *kmemf = NULL; - -int kvm_isopen; - -u_long ncr_base; -u_long lcb_base; -u_long ccb_base; - -u_long ncr_unit; -#ifdef __NetBSD__ -struct cfdriver ncrcd; -#else -u_long ncr_units; -#endif - -struct ncb ncr; -struct lcb lcb; -struct ccb ccb; - -u_long target_mask; -u_long global_lun_mask; -u_long lun_mask; -u_long interval; - -/*=========================================================== -** -** Accessing kernel memory via kvm library. -** -**=========================================================== -*/ - -read_ccb(u_long base) -{ - ccb_base = base; - if (!KVM_READ ( - base, - &ccb, - sizeof (struct ccb))) { - fprintf (stderr, "%s: bad kvm read at %x.\n", prog, base); - exit (1); - }; -} - -read_lcb(u_long base) -{ - lcb_base = base; - if (!KVM_READ ( - base, - &lcb, - sizeof (struct lcb))) { - fprintf (stderr, "%s: bad kvm read at %x.\n", prog, base); - exit (1); - }; -} - -read_ncr() -{ - if (!KVM_READ ( - ncr_base, - &ncr, - sizeof (ncr))) { - fprintf (stderr, "%s: bad kvm read at %x.\n", prog, ncr_base); - exit (1); - }; -} - -void open_kvm(int flags) -{ - int i; - u_long kernel_version; -#if defined(__NetBSD__) || (__FreeBSD__ >= 2) - char errbuf[_POSIX2_LINE_MAX]; -#endif - - if (kvm_isopen) return; - -#if defined(__NetBSD__) || (__FreeBSD__ >= 2) - kvm = kvm_openfiles(vmunix, kmemf, NULL, flags, errbuf); - if (kvm == NULL) { - fprintf(stderr, "%s: kvm_openfiles: %s\n", prog, errbuf); - exit(1); - } -#else - if (kvm_openfiles(vmunix, kmemf, NULL) == -1) { - fprintf(stderr, "%s: kvm_openfiles: %s\n", prog, kvm_geterr()); - exit(1); - } -#endif - - if (!KVM_NLIST(nl)) { - fprintf(stderr, "%s: no symbols in \"%s\".\n", - prog, vmunix); - exit (2); - }; - - for (i=0; nl[i].n_name; i++) - if (nl[i].n_type == 0) { - fprintf(stderr, "%s: no symbol \"%s\" in \"%s\".\n", - prog, nl[i].n_name, vmunix); - exit(1); - } - - if (!KVM_READ ( - nl[N_NCR_VERSION].n_value, - &kernel_version, - sizeof (kernel_version))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (kernel_version != ncr_version){ - fprintf (stderr, "%s: incompatible with kernel. Rebuild!\n", - prog); - exit (1); - }; - -#ifdef __NetBSD__ - - if (!KVM_READ ( - nl[N_NCRCD].n_value, - &ncrcd, - sizeof (ncrcd))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (ncr_unit >= ncrcd.cd_ndevs){ - fprintf (stderr, "%s: bad unit number (valid range: 0-%d).\n", - prog, ncrcd.cd_ndevs-1); - exit (1); - }; - - if (!KVM_READ ( - ncrcd.cd_devs+4*ncr_unit, - &ncr_base, - sizeof (ncr_base))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (!ncr_base) { - fprintf (stderr, - "%s: control structure not allocated (not found in autoconfig?)\n", prog); - exit (1); - }; - -#else /* !__NetBSD__ */ - - if (!KVM_READ ( - nl[N_NNCR].n_value, - &ncr_units, - sizeof (ncr_units))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (ncr_unit >= ncr_units){ - fprintf (stderr, "%s: bad unit number (valid range: 0-%d).\n", - prog, ncr_units-1); - exit (1); - }; - - if (!KVM_READ ( - nl[N_NCRP].n_value+4*ncr_unit, - &ncr_base, - sizeof (ncr_base))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - if (!ncr_base) { - fprintf (stderr, - "%s: control structure not allocated (not found in autoconfig?)\n", prog); - exit (1); - }; - -#endif /* !__NetBSD__ */ - - read_ncr(); - - if (!ncr.vaddr) { - fprintf (stderr, - "%s: 53c810 not mapped (not found in autoconfig?)\n", prog); - exit (1); - }; - - kvm_isopen = 1; -} - - - - -void set_target_mask(void) -{ - int t; - if (target_mask) return; - for (t=0; t<MAX_TARGET; t++) - if (ncr.target[t].jump_tcb.l_cmd) target_mask |= (1<<t); -} - -void set_lun_mask(struct tcb * tp) -{ - int l; - lun_mask = global_lun_mask; - if (lun_mask) return; - for (l=0; l<MAX_LUN; l++) - if (tp->lp[l]) lun_mask |= (1<<l); -} - -void printc (u_char*p, int l) -{ - for (;l>0;l--) { - char c=*p++; - printf ("%c", c?c:'_'); - } -} - -/*================================================================ -** -** -** system info -** -** -**================================================================ -*/ - -do_info(void) -{ - int t,l,i,d,f,fl; - struct tcb * tip; - open_kvm(O_RDONLY); - - if (verbose>=3) - printf ("ncr unit=%d data@%x register@%x (pci@%x)\n\n", - ncr_unit, ncr_base, ncr.vaddr, ncr.paddr); - - set_target_mask(); - - printf ("T:L Vendor Device Rev Speed Max Wide Tags\n"); - for (t=0; t<MAX_TARGET;t++) { - if (!((target_mask>>t)&1)) continue; - tip = &ncr.target[t]; - - set_lun_mask(tip); - if (!lun_mask) lun_mask=1; - fl=1; - - for (l=0; l<MAX_LUN; l++) { - if (!((lun_mask>>l)&1)) continue; - - printf ("%d:%d ", t, l); - - if (!tip->jump_tcb.l_cmd) break; - - if (fl) { - fl=0; - printc (&tip->inqdata[ 8], 8);printf(" "); - printc (&tip->inqdata[16],16);printf(" "); - printc (&tip->inqdata[32], 4);printf(" "); - - if (tip->period==0xffff) { - printf ("asyn"); - } else if (tip->period) { - printf ("%4.1f", 1000.0 / tip->period); - } else { - printf (" ?"); - } - - printf (" "); - - if (tip->minsync==255) { - printf ("asyn"); - } else if (tip->minsync) { - printf ("%4.1f", 250.0 / tip->minsync); - } else { - printf (" ?"); - } - } else printf (" "); - - if (!tip->lp[l]) { - printf (" no\n"); - continue; - }; - read_lcb ((u_long) tip->lp[l]); - - switch (tip->widedone) { - case 1: - printf (" 8"); - break; - case 2: - printf (" 16"); - break; - case 3: - printf (" 32"); - break; - default: - printf (" ?"); - }; - - if (lcb.usetags) - printf ("%5d", lcb.actlink); - else - printf (" -"); - - printf ("\n"); - - }; - - if (!tip->jump_tcb.l_cmd) { - printf (" --- no target.\n"); - continue; - }; - - if (verbose<1) continue; - - for (i=0; i<8; i++) { - char* (class[10])={ - "disk","tape","printer","processor", - "worm", "cdrom", "scanner", "optical disk", - "media changer", "communication device"}; - d = tip->inqdata[i]; - printf ("[%02x]: ",d); - - switch (i) { - - case 0: - f = d & 0x1f; - if (f<10) printf (class[f]); - else printf ("unknown (%x)", f); - break; - case 1: - f = (d>>7) & 1; - if (f) printf ("removable media"); - else printf ("fixed media"); - break; - - case 2: - f = d & 7; - switch (f) { - case 0: printf ("SCSI-1"); - break; - case 1: printf ("SCSI-1 with CCS"); - break; - case 2: printf ("SCSI-2"); - break; - default: - printf ("unknown ansi version (%d)", - f); - } - break; - - case 3: - if (d&0xc0) printf ("capabilities:"); - if (d&0x80) printf (" AEN"); - if (d&0x40) printf (" TERMINATE-I/O"); - break; - - case 7: - if (d&0xfb) printf ("capabilities:"); - if (d&0x80) printf (" relative"); - if (d&0x40) printf (" wide32"); - if (d&0x20) printf (" wide"); - if (d&0x10) printf (" synch"); - if (d&0x08) printf (" link"); - if (d&0x02) printf (" tags"); - if (d&0x01) printf (" soft-reset"); - }; - printf ("\n"); - }; - printf ("\n"); - }; - printf ("\n"); -#ifndef __NetBSD__ - if (ncr.imask) { - u_short v; - printf ("Interrupt vector is"); - if (ncr.imask & (ncr.imask-1)) - printf (" one of the following:"); - for (v=15;v>0;v--) - if ((ncr.imask>>v)&1) - printf (" %d",v); - printf (".\n\n"); - }; -#endif -} - -/*================================================================ -** -** -** profiling -** -** -**================================================================ -*/ - -do_profile(void) -{ -#define old backup.profile -#define new ncr.profile - - struct ncb backup; - struct profile diff; - int tra,line,t; - - open_kvm(O_RDONLY); - - set_target_mask(); - - if (interval<1) interval=1; - for (;;) { - /* - ** Header Line 1 - */ - printf (" total "); - - for (t=0; t<MAX_TARGET; t++) { - if (!((target_mask>>t)&1)) continue; - printf (" "); - printc (&ncr.target[t].inqdata[16],8); - }; - - printf (" transf. disconn interru"); - - if (verbose>=1) printf (" ---- ms/transfer ----"); - - printf ("\n"); - - /* - ** Header Line 2 - */ - - printf ("t/s kb/s "); - - for (t=0; t<MAX_TARGET; t++) { - if (!((target_mask>>t)&1)) continue; - printf (" t/s kb/s"); - }; - - printf (" length exp une fly brk"); - - if (verbose>=1) printf (" total pre post disc"); - - printf ("\n"); - - /* - ** Data - */ - - for(line=0;line<20;line++) { - backup = ncr; - read_ncr(); - diff.num_trans = new.num_trans - old.num_trans; - diff.num_bytes = new.num_bytes - old.num_bytes; - diff.num_fly = new.num_fly - old.num_fly ; - diff.num_int = new.num_int - old.num_int ; - diff.ms_setup = new.ms_setup - old.ms_setup; - diff.ms_data = new.ms_data - old.ms_data; - diff.ms_disc = new.ms_disc - old.ms_disc; - diff.ms_post = new.ms_post - old.ms_post; - diff.num_disc = new.num_disc - old.num_disc; - diff.num_break = new.num_break - old.num_break; - - tra = diff.num_trans; - if (!tra) tra=1; - - printf ("%3.0f %4.0f ", - (1.0 * diff.num_trans) / interval, - (1.0 * diff.num_bytes) / (1024*interval)); - - - for (t=0; t<MAX_TARGET; t++) { - if (!((target_mask>>t)&1)) continue; - printf (" %3.0f %4.0f", - ((ncr.target[t].transfers- - backup.target[t].transfers)*1.0) - /interval, - ((ncr.target[t].bytes- - backup.target[t].bytes)*1.0) - /(1024*interval)); - }; - - printf ("%7.0f ", (diff.num_bytes*1.0) / tra); - - printf (" %4.0f", (1.0*(diff.num_disc-diff.num_break)) - /interval); - - printf ("%4.0f", (1.0*diff.num_break)/interval); - - printf ("%4.0f", (1.0*diff.num_fly) / interval); - - printf ("%4.0f", (1.0*diff.num_int) / interval); - - if (verbose >= 1) { - printf ("%7.1f", - (diff.ms_disc+diff.ms_data+diff.ms_setup+diff.ms_post) - * 1.0 / tra); - - printf ("%5.1f%5.1f%6.1f", - 1.0 * diff.ms_setup / tra, - 1.0 * diff.ms_post / tra, - 1.0 * diff.ms_disc / tra); - }; - - printf ("\n"); - fflush (stdout); - sleep (interval); - }; - }; -} - -/*================================================================ -** -** -** Port access -** -** -**================================================================ -*/ - -static int kernelwritefile; -static char* kernelwritefilename = _PATH_KMEM; - -void openkernelwritefile(void) -{ - if (kernelwritefile) return; - - kernelwritefile = open (kernelwritefilename, O_WRONLY); - if (kernelwritefile<3) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - }; -} - -void out (u_char reg, u_char val) -{ - u_long addr = ncr.vaddr + reg; - openkernelwritefile(); - if (lseek (kernelwritefile, addr, 0) != addr) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - } - if (write (kernelwritefile, &val, 1) < 0) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - }; -} - -u_char in (u_char reg) -{ - u_char res; - if (!KVM_READ ( - (ncr.vaddr + reg), - &res, - 1)) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - } - return (res); -} - -/*================================================================ -** -** -** Setting of driver parameters -** -** -**================================================================ -*/ - -void do_set (char * arg) -{ - struct usrcmd user; - u_long addr; - int i; - - open_kvm(O_RDWR); - addr = ncr_base + offsetof (struct ncb, user); - - for (i=3; i; i--) { - if (!KVM_READ ( - (addr), - &user, - sizeof (user))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - } - if (!user.cmd) break; - sleep (1); - } - if (user.cmd) { - fprintf (stderr, "%s: ncb.user busy.\n", prog); - exit (1); - }; - - user.target = target_mask; - user.lun = lun_mask; - user.data = 0; - user.cmd = 0; - - if (!strcmp(arg, "?")) { printf ( -"async: disable synchronous transfers.\n" -"sync=value: set the maximal synchronous transfer rate (MHz).\n" -"fast: set FAST SCSI-2.\n" -"\n" -"wide=value: set the bus width (0=8bit 1=16bit).\n" -"\n" -"tags=value: use this number of tags.\n" -"orderedtag: use ordered tags only.\n" -"simpletag: use simple tags only.\n" -"orderedwrite: use simple tags for read, else ordered tags.\n" -"\n" -"debug=value: set debug mode.\n" -"\n"); - return; - }; - - if (!strcmp(arg, "async")) { - user.data = 255; - user.cmd = UC_SETSYNC; - }; - - if (!strcmp(arg, "fast")) { - user.data = 25; - user.cmd = UC_SETSYNC; - }; - - if (!strncmp(arg, "sync=", 5)) { - float f = strtod (arg+5, NULL); - if (f>=4.0 && f<=10.0) { - user.data = 250.0 / f; - user.cmd = UC_SETSYNC; - }; - }; - - if (!strncmp(arg, "wide=", 5)) { - u_char t = strtoul (arg+5, (char**)0, 0); - if (t<=1) { - user.data = t; - user.cmd = UC_SETWIDE; - }; - }; - - if (!strncmp(arg, "tags=", 5)) { - u_char t = strtoul (arg+5, (char**)0, 0); - if (t<=SCSI_NCR_MAX_TAGS) { - user.data = t; - user.cmd = UC_SETTAGS; - }; - }; - - if (!strncmp(arg, "flags=", 6)) { - u_char t = strtoul (arg+6, (char**)0, 0); - if (t<=0xff) { - user.data = t; - user.cmd = UC_SETFLAG; - }; - }; - - if (!strncmp(arg, "debug=", 6)) { - user.data = strtoul (arg+6, (char**)0, 0); - user.cmd = UC_SETDEBUG; - }; - - if (!strcmp(arg, "orderedtag")) { - user.data = M_ORDERED_TAG; - user.cmd = UC_SETORDER; - }; - - if (!strcmp(arg, "simpletag")) { - user.data = M_SIMPLE_TAG; - user.cmd = UC_SETORDER; - }; - - if (!strcmp(arg, "orderedwrite")) { - user.data = 0; - user.cmd = UC_SETORDER; - }; - - if (user.cmd) { - openkernelwritefile(); - - if (lseek (kernelwritefile, addr, 0) != addr) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - } - if (write (kernelwritefile, &user, sizeof (user)) < 0) { - fprintf (stderr, "%s: %s: %s\n", - prog, kernelwritefilename, strerror(errno)); - exit (1); - } - - return; - }; - - fprintf (stderr, "%s: do_set \"%s\" not (yet) implemented.\n", - prog, arg); -} - -/*================================================================ -** -** -** D O _ K I L L -** -** -**================================================================ -*/ - -do_kill(char * arg) -{ - open_kvm(O_RDWR); - - if (!strcmp(arg, "?")) { printf ( -"scsireset: force SCSI bus reset.\n" -"scriptabort: send an abort cmd to the script processor.\n" -"scriptstart: start script processind (set SIGP bit).\n" -"evenparity: force even parity.\n" -"oddparity: force odd parity.\n" -"noreselect: disable reselect (force timeouts).\n" -"doreselect: enable reselect.\n" -"\n"); - return; - }; - - if (!wizard) { - fprintf (stderr, "%s: You are NOT a wizard!\n", prog); - exit (2); - }; - - if (!strcmp(arg, "scsireset")) { - out (0x01, 0x08); - out (0x01, 0x00); - return; - }; - if (!strcmp(arg, "scriptabort")) { - out (0x14, 0x80); - out (0x14, 0x20); - return; - }; - if (!strcmp(arg, "scriptstart")) { - out (0x14, 0x20); - return; - }; - if (!strcmp(arg, "evenparity")) { - out (0x01, 0x04); - return; - }; - if (!strcmp(arg, "oddparity")) { - out (0x01, 0x00); - return; - }; - if (!strcmp(arg, "noreselect")) { - out (0x04, in (0x04) & ~RRE); - return; - }; - if (!strcmp(arg, "doreselect")) { - out (0x04, in (0x04) | RRE); - return; - }; - fprintf (stderr, "%s: do_kill \"%s\" not (yet) implemented.\n", - prog, arg); -} - -/*================================================================ -** -** -** Write debug info: utilities: write symbolname. -** -** -**================================================================ -*/ - -static const char * sn (u_long a) -{ - static char buffer[100]; - - const char * s=""; - u_long d,m; - - a -= ncr.p_script; - m = sizeof (struct script); - - if ((d=a-offsetof(struct script, start))<m) m=d, s="<start>"; - if ((d=a-offsetof(struct script, start1))<m) m=d, s="<start1>"; - if ((d=a-offsetof(struct script, startpos))<m) m=d, s="<startpos>"; - if ((d=a-offsetof(struct script, tryloop))<m) m=d, s="<tryloop>"; - if ((d=a-offsetof(struct script, trysel))<m) m=d, s="<trysel>"; - if ((d=a-offsetof(struct script, skip))<m) m=d, s="<skip>"; - if ((d=a-offsetof(struct script, skip2))<m) m=d, s="<skip2>"; - if ((d=a-offsetof(struct script, idle))<m) m=d, s="<idle>"; - if ((d=a-offsetof(struct script, select))<m) m=d, s="<select>"; - if ((d=a-offsetof(struct script, prepare))<m) m=d, s="<prepare>"; - if ((d=a-offsetof(struct script, loadpos))<m) m=d, s="<loadpos>"; - if ((d=a-offsetof(struct script, prepare2))<m) m=d, s="<prepare2>"; - if ((d=a-offsetof(struct script, setmsg))<m) m=d, s="<setmsg>"; - if ((d=a-offsetof(struct script, clrack))<m) m=d, s="<clrack>"; - if ((d=a-offsetof(struct script, dispatch))<m) m=d, s="<dispatch>"; - if ((d=a-offsetof(struct script, checkatn))<m) m=d, s="<checkatn>"; - if ((d=a-offsetof(struct script, command))<m) m=d, s="<command>"; - if ((d=a-offsetof(struct script, status))<m) m=d, s="<status>"; - if ((d=a-offsetof(struct script, msg_in))<m) m=d, s="<msg_in>"; - if ((d=a-offsetof(struct script, msg_bad))<m) m=d, s="<msg_bad>"; - if ((d=a-offsetof(struct script, msg_parity))<m) m=d, s="<msg_parity>"; - if ((d=a-offsetof(struct script, msg_reject))<m) m=d, s="<msg_reject>"; - if ((d=a-offsetof(struct script, msg_extended))<m) m=d, s="<msg_extended>"; - if ((d=a-offsetof(struct script, msg_sdtr))<m) m=d, s="<msg_sdtr>"; - if ((d=a-offsetof(struct script, complete))<m) m=d, s="<complete>"; - if ((d=a-offsetof(struct script, cleanup))<m) m=d, s="<cleanup>"; - if ((d=a-offsetof(struct script, cleanup0))<m) m=d, s="<cleanup>"; - if ((d=a-offsetof(struct script, signal))<m) m=d, s="<signal>"; - if ((d=a-offsetof(struct script, save_dp))<m) m=d, s="<save_dp>"; - if ((d=a-offsetof(struct script, restore_dp))<m) m=d, s="<restore_dp>"; - if ((d=a-offsetof(struct script, disconnect))<m) m=d, s="<disconnect>"; - if ((d=a-offsetof(struct script, msg_out))<m) m=d, s="<msg_out>"; - if ((d=a-offsetof(struct script, msg_out_done))<m) m=d, s="<msg_out_done>"; - if ((d=a-offsetof(struct script, msg_out_abort))<m) m=d, s="<msg_out_abort>"; - if ((d=a-offsetof(struct script, getcc))<m) m=d, s="<getcc>"; - if ((d=a-offsetof(struct script, getcc1))<m) m=d, s="<getcc1>"; - if ((d=a-offsetof(struct script, getcc2))<m) m=d, s="<getcc2>"; - if ((d=a-offsetof(struct script, badgetcc))<m) m=d, s="<badgetcc>"; - if ((d=a-offsetof(struct script, reselect))<m) m=d, s="<reselect>"; - if ((d=a-offsetof(struct script, reselect2))<m) m=d, s="<reselect2>"; - if ((d=a-offsetof(struct script, resel_tmp))<m) m=d, s="<resel_tmp>"; - if ((d=a-offsetof(struct script, resel_lun))<m) m=d, s="<resel_lun>"; - if ((d=a-offsetof(struct script, resel_tag))<m) m=d, s="<resel_tag>"; - if ((d=a-offsetof(struct script, data_in))<m) m=d, s="<data_in>"; - if ((d=a-offsetof(struct script, data_out))<m) m=d, s="<data_out>"; - if ((d=a-offsetof(struct script, no_data))<m) m=d, s="<no_data>"; - if ((d=a-offsetof(struct script, aborttag))<m) m=d, s="<aborttag>"; - if ((d=a-offsetof(struct script, abort))<m) m=d, s="<abort>"; - - if (!*s) return s; - - sprintf (buffer, "%s:%d%c", s, m/4, 0); - return (buffer); -} - -/*================================================================ -** -** -** Write debug info: utilities: write misc. fields. -** -** -**================================================================ -*/ - -static void printm (u_char * msg, int len) -{ - u_char l; - do { - if (*msg==M_EXTENDED) - l=msg[1]+2; - else if ((*msg & 0xf0)==0x20) - l=2; - else l=1; - len-=l; - - printf (" %x",*msg++); - while (--l>0) printf ("-%x",*msg++); - } while (len>0); -} - -void dump_table (const char * str, struct scr_tblmove * p, int l) -{ - int i; - for (i=0;l>0;i++,p++,l--) if (p->size) { - printf (" %s[%d]: %5d @ 0x%08x\n", - str, i, p->size, p->addr); - }; -} - -void dump_link (const char* name, struct link * link) -{ - printf ("%s: cmd=%08x pa=%08x %s\n", - name, link->l_cmd, link->l_paddr, sn(link->l_paddr)); -} - -/*================================================================ -** -** -** Write debug info: utilities: write time fields. -** -** -**================================================================ -*/ - -void dump_tstamp (const char* name, struct tstamp * p) -#define P(id,fld)\ - if (p->fld.tv_sec) \ - printf ("%s: "id" at %s.%06d",\ - name,ctime(&p->fld.tv_sec),p->fld.tv_usec); -{ - P ("started ", start); - P ("ended ", end ); - P ("selected ", select); - P ("command ", command); - P ("data ", data); - P ("status ", status); - P ("disconnected", disconnect); - P ("reselected ", reselect); - printf ("\n"); -} - - - - -void dump_profile (const char* name, struct profile * p) -{ - printf ("%s: %10d transfers.\n" ,name,p->num_trans); - printf ("%s: %10d bytes transferred.\n",name,p->num_bytes); - printf ("%s: %10d disconnects.\n" ,name,p->num_disc); - printf ("%s: %10d short transfers.\n" ,name,p->num_break); - printf ("%s: %10d interrupts.\n" ,name,p->num_int); - printf ("%s: %10d on the fly ints.\n" ,name,p->num_fly); - printf ("%s: %10d ms setup time.\n" ,name,p->ms_setup); - printf ("%s: %10d ms data transfer.\n" ,name,p->ms_data); - printf ("%s: %10d ms disconnected.\n" ,name,p->ms_disc); - printf ("%s: %10d ms postprocessing.\n",name,p->ms_post); - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: utilities: write script registers. -** -** -**================================================================ -*/ - -static void dump_reg(struct ncr_reg * rp) -{ - u_char *reg = (u_char*) rp; -#define l(i) (reg[i]+(reg[i+1]<<8ul)+(reg[i+2]<<16ul)+(reg[i+3]<<24ul)) - int ad; - - char*(phasename[8])={"DATA-OUT","DATA-IN","COMMAND","STATUS", - "ILG-OUT","ILG-IN","MESSAGE-OUT","MESSAGE-IN"}; - for (ad=0x00;ad<0x80;ad++) { - switch (ad % 16) { - - case 0: - printf (" %02x:\t",ad); - break; - case 8: - printf (" : "); - break; - default: - printf (" "); - }; - printf ("%02x", reg[ad]); - if (ad % 16 == 15) printf ("\n"); - }; - printf ("\n"); - printf (" DSP %08x %-20s CMD %08x DSPS %08x %s\n", - l(0x2c),sn(l(0x2c)),l(0x24),l(0x30), sn(l(0x30))); - printf (" TEMP %08x %-20s DSA %08x\n", - l(0x1c),sn(l(0x1c)),l(0x10)); - printf ("\n"); - printf (" Busstatus: "); - if ((reg[0x0b]>>7)&1) printf (" Req"); - if ((reg[0x0b]>>6)&1) printf (" Ack"); - if ((reg[0x0b]>>5)&1) printf (" Bsy"); - if ((reg[0x0b]>>4)&1) printf (" Sel"); - if ((reg[0x0b]>>3)&1) printf (" Atn"); - printf (" %s\n", phasename[reg[0x0b]&7]); - - printf (" Dmastatus: "); - if ((reg[0x0c]>>7)&1) printf (" FifoEmpty"); - if ((reg[0x0c]>>6)&1) printf (" MasterParityError"); - if ((reg[0x0c]>>5)&1) printf (" BusFault"); - if ((reg[0x0c]>>4)&1) printf (" Aborted"); - if ((reg[0x0c]>>3)&1) printf (" SingleStep"); - if ((reg[0x0c]>>2)&1) printf (" Interrupt"); - if ((reg[0x0c]>>0)&1) printf (" IllegalInstruction"); - printf ("\n"); - printf (" Intstatus: "); - if ((reg[0x14]>>7)&1) printf (" Abort"); - if ((reg[0x14]>>6)&1) printf (" SoftwareReset"); - if ((reg[0x14]>>5)&1) printf (" SignalProcess"); - if ((reg[0x14]>>4)&1) printf (" Semaphore"); - if ((reg[0x14]>>3)&1) printf (" Connected"); - if ((reg[0x14]>>2)&1) printf (" IntOnTheFly"); - if ((reg[0x14]>>1)&1) printf (" SCSI-Interrupt"); - if ((reg[0x14]>>0)&1) printf (" DMA-Interrupt"); - printf ("\n"); - printf (" ScsiIstat: "); - if ((reg[0x42]>>7)&1) printf (" PhaseMismatch"); - if ((reg[0x42]>>6)&1) printf (" Complete"); - if ((reg[0x42]>>5)&1) printf (" Selected"); - if ((reg[0x42]>>4)&1) printf (" Reselected"); - if ((reg[0x42]>>3)&1) printf (" GrossError"); - if ((reg[0x42]>>2)&1) printf (" UnexpectedDisconnect"); - if ((reg[0x42]>>1)&1) printf (" ScsiReset"); - if ((reg[0x42]>>0)&1) printf (" ParityError"); - if ((reg[0x43]>>2)&1) printf (" SelectionTimeout"); - if ((reg[0x43]>>1)&1) printf (" TimerExpired"); - if ((reg[0x43]>>0)&1) printf (" HandshakeTimeout"); - printf ("\n"); - printf (" ID=%d DEST-ID=%d RESEL-ID=%d\n", reg[4]&7, reg[6]&7, reg[0xa]&7); - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: utilities: write header. -** -** -**================================================================ -*/ - -char * debug_opt; - -dump_head (struct head * hp) -{ - dump_link (" launch", & hp->launch); - printf (" savep: %08x %s\n", - hp->savep, sn((u_long) hp->savep)); - printf (" cp: %08x %s\n", - hp->cp, sn((u_long)hp->cp)); - if (strchr (debug_opt, 'y')) { - printf ("\n"); - dump_tstamp (" timestamp", &hp->stamp); - }; - - printf (" status: %x %x %x %x %x %x %x %x\n", - hp->status[0], hp->status[1], hp->status[2], hp->status[3], - hp->status[4], hp->status[5], hp->status[6], hp->status[7]); - - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: utilities: write ccb. -** -** -**================================================================ -*/ - -void dump_ccb (struct ccb * cp, u_long base) -{ - printf ("----------------------\n"); - printf ("struct ccb @ %08x:\n", base); - printf ("----------------------\n"); - - dump_link (" next", &cp->jump_ccb); - dump_link (" call", &cp->call_tmp); - - dump_head (&cp->phys.header); - - if (strchr (debug_opt, 's')) { - dump_table(" smsg", &cp->phys.smsg, 1); - dump_table("smsg2", &cp->phys.smsg2, 1); - dump_table(" cmd", &cp->phys.cmd, 1); - dump_table(" data", &cp->phys.data[0],MAX_SCATTER); - dump_table("sense", &cp->phys.sense, 1); - }; - - if (strchr (debug_opt, 'a')) { - int i; - for (i=0; i<8; i++) - printf (" patch[%d]: %08x\n", i, cp->patch[i]); - }; - - if (strchr (debug_opt, 'x')) { - printf (" xfer: -- dump not yet implemented.\n"); - }; - - if (strchr (debug_opt, 'm')) { - printf (" smsg:"); - printm (cp->scsi_smsg, cp->phys.smsg.size); - printf ("\n"); - printf (" smsg2:"); - printm (cp->scsi_smsg2, cp->phys.smsg2.size); - printf ("\n"); - }; - - printf (" magic: %x\n", cp->magic); - if (cp->tlimit) - printf (" timeout at: %s", ctime((time_t*)&cp->tlimit)); - printf (" link_ccb: %08x\n", (u_long) cp->link_ccb); - printf (" next_ccb: %08x\n", (u_long) cp->next_ccb); - printf (" tag: %d\n", cp->tag); - printf ("\n"); -} - -/*================================================================ -** -** -** Write debug info: struct lcb -** -** -**================================================================ -*/ - -static void dump_lcb (u_long base) -{ - struct lcb l; - struct ccb c; - u_long cp,cn; - - printf ("----------------------\n"); - printf ("struct lcb @ %08x:\n", base); - printf ("----------------------\n"); - - if (!KVM_READ ( - base, - &l, - sizeof (struct lcb))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - printf (" reqccbs: %d\n", l.reqccbs); - printf (" actccbs: %d\n", l.actccbs); - printf (" reqlink: %d\n", l.reqlink); - printf (" actlink: %d\n", l.actlink); - printf (" usetags: %d\n", l.usetags); - dump_link (" jump_lcb", &l.jump_lcb); - dump_link (" call_tag", &l.call_tag); - dump_link (" jump_ccb", &l.jump_ccb); - printf ("\n"); - cp = (u_long) l.next_ccb; - cn = 0; - while (cp) { - cn++; - printf ("ccb #%d:\n", cn); - if (!KVM_READ ( - cp, - &c, - sizeof (struct ccb))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - dump_ccb (&c, cp); - cp= (u_long) c.next_ccb; - }; -} - -/*================================================================ -** -** -** Write debug info: struct tcb -** -** -**================================================================ -*/ - -static void dump_tip (struct tcb * tip) -{ - int i; - u_long lp; - - printf ("----------------------\n"); - printf ("struct tcb:\n"); - printf ("----------------------\n"); - - printf (" transfers:%10d.\n", tip->transfers); - printf (" bytes:%10d.\n", tip->bytes ); - printf (" user limits: usrsync=%d usrwide=%d usrtags=%d.\n", - tip->usrsync, tip->usrwide, tip->usrtags); - printf (" sync: minsync=%d, maxoffs=%d, period=%d ns, sval=%x.\n", - tip->minsync, tip->maxoffs, tip->period, tip->sval); - printf (" wide: widedone=%d, wval=%x.\n", - tip->widedone, tip->wval); - - printf (" hold_cp: %x\n", tip->hold_cp); - dump_link (" jump_tcb", &tip->jump_tcb); - dump_link (" call_lun", &tip->call_lun); - dump_link (" jump_lcb", &tip->jump_lcb); - if (tip->hold_cp) printf (" hold_cp: @ %x\n", tip->hold_cp); - printf ("\n"); - - if (strchr (debug_opt, 'l')) { - for (i=0;i<MAX_LUN;i++) { - lp= (u_long) tip->lp[i]; - printf ("logic unit #%d:\n", i); - if (lp) dump_lcb (lp); - }; - } -} - -/*================================================================ -** -** -** Write debug info: struct ncb -** -** -**================================================================ -*/ - - -static void dump_ncr (void) -{ - u_long tp; - int i; - - printf ("----------------------\n"); - printf ("struct ncb @ %x:\n", ncr_base); - printf ("----------------------\n"); - - dump_link (" jump_tcb", &ncr.jump_tcb); - printf (" register: @ %x (p=%x)\n", ncr.vaddr, ncr.paddr); - - if (strchr (debug_opt, 'r')) { - struct ncr_reg reg; - - if (!KVM_READ ( - ncr.vaddr, - ®, - sizeof (reg))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - printf ("\n"); - dump_reg (®); - }; - - printf (" script: @ %x (p=%x)\n", ncr.script, ncr.p_script); - - printf ("hostscsiaddr: %d\n", ncr.myaddr); - printf (" ns_async: %d ns\n", ncr.ns_async); - printf (" ns_sync : %d ns\n", ncr.ns_sync); - printf (" scntl3: 0x%02x\n", ncr.rv_scntl3); - printf ("\n"); - - /* sc_link not dumped */ - - if (strchr (debug_opt, 'u')) { - printf (" usercmd: cmd=%x data=%x target=%x lun=%x\n", - ncr.user.cmd, - ncr.user.data, - ncr.user.target, - ncr.user.lun); - }; - - printf (" actccbs: %d\n", ncr.actccbs); - - if (strchr (debug_opt, 'q')) { - - u_long startpos; - - if (!KVM_READ ( - ((u_long)ncr.script - +offsetof(struct script, startpos)), - &startpos, - sizeof (startpos))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - - printf (" startpos: %x\n", startpos); - printf (" slot: %d\n", (startpos- - (ncr.p_script+offsetof(struct script, tryloop)))/20); - printf (" squeuput: %d\n", ncr.squeueput); - for (i=0; i<MAX_START; i++) - printf ("%12d: %08x %s\n", i, - ncr.squeue[i], sn(ncr.squeue[i])); - - printf ("\n"); - }; - - printf (" ticks: %d ms\n", ncr.ticks * 10); - printf (" heartbeat: %s", ctime ((time_t*)&ncr.heartbeat)); - printf (" lasttime: %s", ctime ((time_t*)&ncr.lasttime)); -#ifndef __NetBSD__ - printf ("imask/mcount: %x / %d\n", ncr.imask, ncr.mcount); -#endif - printf ("\n"); - - if (strchr (debug_opt, 'd') && ncr.regtime.tv_sec) { - printf (" regdump: %s", ctime (&ncr.regtime.tv_sec)); - dump_reg (&ncr.regdump); - }; - - if (strchr (debug_opt, 'p')) { - printf ("\n"); - dump_profile (" profile", &ncr.profile); - }; - - if (strchr (debug_opt, 'h')) { - printf ("\n"); - dump_head ( &ncr.header); - }; - - if (strchr (debug_opt, 'c')) { - dump_ccb (&ncr.ccb, ncr_base + offsetof (struct ncb, ccb)); - }; - - if (strchr (debug_opt, 'm')) { - printf (" msgout:"); printm (ncr.msgout,0); printf ("\n"); - printf (" msg in:"); printm (ncr.msgin,0); printf ("\n"); - printf ("\n"); - }; - - if (strchr (debug_opt, 't')) { - struct tcb * tip; - for (i=0;i<MAX_TARGET;i++) { - tip = &ncr.target[i]; - if (!tip->jump_tcb.l_cmd) continue; - printf ("target #%d:\n", i); - dump_tip (tip); - } - } -} - -/*================================================================ -** -** -** D O _ D E B U G -** -** -**================================================================ -*/ - - -do_debug(char * arg) -{ - open_kvm(O_RDONLY); - debug_opt = arg; - if (strchr (debug_opt, '?')) printf ( -"'?': list debug options [sic].\n" -"'a': show patchfields in ccbs (requires c).\n" -"'c': show ccbs.\n" -"'d': show register dump.\n" -"'h': show header information.\n" -"'m': show message buffers.\n" -"'n': show ncr main control block.\n" -"'p': show profiling information.\n" -"'q': show start queue.\n" -"'r': show registers (*DANGEROUS*).\n" -"'s': show scatter/gather info.\n" -"'t': show target control blocks.\n" -"'u': show user cmd field.\n" -"'x': show generic xfer structure.\n" -"'y': show timestamps.\n" -"\n" - ); - - if (strchr (debug_opt, 'n')) dump_ncr (); - if (strchr (debug_opt, 'r')) { - struct ncr_reg reg; - if (!KVM_READ ( - ncr.vaddr, - ®, - sizeof (reg))) { - fprintf (stderr, "%s: bad kvm read.\n", prog); - exit (1); - }; - dump_reg (®); - }; -} - - -/*================================================================ -** -** -** Main function -** -** -**================================================================ -*/ - -void main(argc, argv) - int argc; - char **argv; -{ - extern char *optarg; - extern int optind; - int usage=0; - char * charp; - int ch, getopt(),atoi(); - int i,step; - - prog = *argv; - while ((ch = getopt(argc, argv, "M:N:u:f:t:l:p:s:k:d:vwhin:?")) != -1) - switch((char)ch) { - case 'M': - if (kvm_isopen) { - fprintf (stderr, - "%s: -M: kernel file already open.\n", - prog); - exit (1); - }; - kmemf = optarg; - break; - case 'N': - if (kvm_isopen) { - fprintf (stderr, - "%s: -N: symbol table already open.\n", - prog); - exit (1); - }; - vmunix = optarg; - break; - case 'f': - fprintf (stderr, - "%s: -f: option not yet implemented.\n", - prog); - exit (1); - - case 'u': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<0)) { - fprintf (stderr, - "%s: bad unit number \"%s\".\n", - prog, optarg); - exit (1); - } - ncr_unit = i; - break; - case 't': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<0) || (i>=MAX_TARGET)) { - fprintf (stderr, - "%s: bad target number \"%s\" (valid range: 0-%d).\n", - prog, optarg, MAX_TARGET-1); - exit (1); - } - target_mask |= 1ul << i; - break; - case 'n': - open_kvm(O_RDONLY); - i = strtoul (optarg, &charp, 0); - printf ("addr %d (0x%x) has label %s.\n", - i,i,sn(i)); - break; - case 'l': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<0) || (i>=MAX_LUN)) { - fprintf (stderr, - "%s: bad logic unit number \"%s\" (valid range: 0-%d).\n", - prog, optarg, MAX_LUN); - exit (1); - } - global_lun_mask |= 1ul << i; - break; - case 'p': - i = strtoul (optarg, &charp, 0); - if (!*optarg || *charp || (i<1) || (i>60)) { - fprintf (stderr, - "%s: bad interval \"%s\".\n", - prog, optarg); - exit (1); - } - interval = i; - do_profile(); - break; - - case 'w': - wizard=1; - break; - case 'v': - verbose++; - break; - case 'i': - do_info(); - break; - - case 's': - do_set(optarg); - break; - case 'd': - do_debug(optarg); - break; - case 'k': - do_kill(optarg); - break; - case 'h': - case '?': - usage++; - break; - default:(void)fprintf(stderr, - "%s: illegal option \"%c\".\n", prog, ch); - usage++; - } - - argv += optind; - argc -= optind; - - if (argc) printf ("%s: rest of line starting with \"%s\" ignored.\n", - prog, *argv); - - if (verbose&&!kvm_isopen) usage++; - if (usage) { - fprintf (stderr, - "Usage:\n" - "\n" - "%s [-M$] [-N$] {-f$} {-t#} {-l#} [-hivw?] [-d$] [-s$] [-k] [[-p] <time>]\n" - "\n" - "-t <#> select target number\n" - "-l <#> select lun number\n" - "-i get info\n" - "-v verbose\n" - "-p <seconds> performance data\n" - "\n" - "Wizards only (proceed on your own risk):\n" - "-n <#> get the name for address #\n" - "-w wizard mode\n" - "-d <options> debug info\n" - "-d? list debug options\n" - "-s <param=value> set parameter\n" - "-s? list parameters\n" - "-k <torture> torture driver by simulating errors\n" - "-k? list tortures\n" - "-M <kernelimage> (default: %s)\n" - "-N <symboltable> (default: %s)\n" - , prog, _PATH_KMEM, _PATH_UNIX); - if (verbose) fprintf (stderr, ident); - exit (1); - } - - if (!kvm_isopen) { - do_info(); - do_profile(); - }; - exit (0); -} diff --git a/sys/i386/pci/pci.c b/sys/i386/pci/pci.c deleted file mode 100644 index 6ef7163..0000000 --- a/sys/i386/pci/pci.c +++ /dev/null @@ -1,778 +0,0 @@ -/************************************************************************** -** -** $Id: pci.c,v 1.8 1994/10/25 23:09:08 se Exp $ -** -** General subroutines for the PCI bus on 80*86 systems. -** pci_configure () -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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 <pci.h> -#if NPCI > 0 - -#ifndef __FreeBSD2__ -#if __FreeBSD__ >= 2 -#define __FreeBSD2__ -#endif -#endif - -/*======================================================== -** -** #includes and declarations -** -**======================================================== -*/ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/errno.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> - -#include <i386/isa/isa.h> -#include <i386/isa/isa_device.h> -#include <i386/isa/icu.h> -#include <i386/pci/pcireg.h> - -#ifdef __FreeBSD2__ -#include <sys/devconf.h> - -struct pci_devconf { - struct kern_devconf pdc_kdc; - struct pci_info pdc_pi; -}; -#endif - -/* -** Function prototypes missing in system headers -*/ - -#ifndef __FreeBSD2__ -extern pmap_t pmap_kernel(void); -static vm_offset_t pmap_mapdev (vm_offset_t paddr, vm_size_t vsize); - -/* - * Type of the first (asm) part of an interrupt handler. - */ -typedef void inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss)); - -/* - * Usual type of the second (C) part of an interrupt handler. Some bogus - * ones need the arg to be the interrupt frame (and not a copy of it, which - * is all that is possible in C). - */ -typedef void inthand2_t __P((int unit)); - -/* -** XXX @FreeBSD2@ -** -** Unfortunately, the mptr argument is _no_ pointer in 2.0 FreeBSD. -** We would prefer a pointer because it enables us to install -** new interrupt handlers at any time. -** (This is just going to be changed ... <se> :) -** In 2.0 FreeBSD later installed interrupt handlers may change -** the xyz_imask, but this would not be recognized by handlers -** which are installed before. -*/ - -static int -register_intr __P((int intr, int device_id, unsigned int flags, - inthand2_t *handler, unsigned int * mptr, int unit)); -extern unsigned intr_mask[ICU_LEN]; - -#endif /* !__FreeBSD2__ */ - -/*======================================================== -** -** Autoconfiguration of pci devices. -** -** This is reverse to the isa configuration. -** (1) find a pci device. -** (2) look for a driver. -** -**======================================================== -*/ - -/*-------------------------------------------------------- -** -** The pci devices can be mapped to any address. -** As default we start at the last gigabyte. -** -**-------------------------------------------------------- -*/ - -#ifndef PCI_PMEM_START -#define PCI_PMEM_START 0xc0000000 -#endif - -static vm_offset_t pci_paddr = PCI_PMEM_START; - -/*-------------------------------------------------------- -** -** The pci device interrupt lines should have been -** assigned by the bios. But if the bios failed to -** to it, we set it. -** -**-------------------------------------------------------- -*/ - -#ifndef PCI_IRQ -#define PCI_IRQ 0 -#endif - -static u_long pci_irq = PCI_IRQ; - -/*--------------------------------------------------------- -** -** pci_configure () -** -** Probe all devices on pci bus and attach them. -** -** May be called more than once. -** Any device is attached only once. -** (Attached devices are remembered in pci_seen.) -** -**--------------------------------------------------------- -*/ - -static void not_supported (pcici_t tag, u_long type); - -static unsigned long pci_seen[NPCI]; - -static int pci_conf_count; - -#ifdef __FreeBSD2__ -static int -pci_externalize (struct proc *, struct kern_devconf *, void *, size_t); - -static int -pci_internalize (struct proc *, struct kern_devconf *, void *, size_t); - -#endif /* __FreeBSD2__ */ - -void pci_configure() -{ - u_char device,last_device; - u_short bus; - pcici_t tag; - pcidi_t type; - u_long data; - int unit; - int pci_mechanism; - int pciint; - int irq; - char* name=0; - vm_offset_t old_addr=pci_paddr; - - struct pci_driver *drp=0; - struct pci_device *dvp; - -#ifdef __FreeBSD2__ - struct pci_devconf *pdcp; -#endif - - /* - ** check pci bus present - */ - - pci_mechanism = pci_conf_mode (); - if (!pci_mechanism) return; - last_device = pci_mechanism==1 ? 31 : 15; - - /* - ** hello world .. - */ - - - for (bus=0;bus<NPCI;bus++) { -#ifndef PCI_QUIET - printf ("pci%d: scanning device 0..%d, mechanism=%d.\n", - bus, last_device, pci_mechanism); -#endif - for (device=0; device<=last_device; device ++) { - - if (pci_seen[bus] & (1ul << device)) - continue; - - tag = pcitag (bus, device, 0); - type = pci_conf_read (tag, PCI_ID_REG); - - if ((!type) || (type==0xfffffffful)) continue; - - /* - ** lookup device in ioconfiguration: - */ - - for (dvp = pci_devtab; dvp->pd_name; dvp++) { - drp = dvp->pd_driver; - if (!drp) - continue; - if ((name=(*drp->probe)(tag, type))) - break; - }; - - if (!dvp->pd_name) { -#ifndef PCI_QUIET - if (pci_conf_count) - continue; - printf("pci%d:%d: ", bus, device); - not_supported (tag, type); -#endif - continue; - }; - - pci_seen[bus] |= (1ul << device); - /* - ** Get and increment the unit. - */ - - unit = (*drp->count)++; - - /* - ** ignore device ? - */ - - if (!*name) continue; - - /* - ** Announce this device - */ - - printf ("%s%d <%s>", dvp->pd_name, unit, name); - - /* - ** Get the int pin number (pci interrupt number a-d) - ** from the pci configuration space. - */ - - data = pci_conf_read (tag, PCI_INTERRUPT_REG); - pciint = PCI_INTERRUPT_PIN_EXTRACT(data); - - if (pciint) { - - printf (" int %c", 0x60+pciint); - - /* - ** If the interrupt line register is not set, - ** set it now from PCI_IRQ. - */ - - if (!(PCI_INTERRUPT_LINE_EXTRACT(data))) { - - irq = pci_irq & 0x0f; - pci_irq >>= 4; - - data = PCI_INTERRUPT_LINE_INSERT(data, irq); - printf (" (config)"); - pci_conf_write (tag, PCI_INTERRUPT_REG, data); - }; - - irq = PCI_INTERRUPT_LINE_EXTRACT(data); - - /* - ** If it's zero, the isa irq number is unknown, - ** and we cannot bind the pci interrupt to isa. - */ - - if (irq) - printf (" irq %d", irq); - else - printf (" not bound"); - }; - - /* - ** enable memory access - */ - - data = (pci_conf_read (tag, PCI_COMMAND_STATUS_REG) - & 0xffff) | PCI_COMMAND_MEM_ENABLE; - - pci_conf_write (tag, (u_char) PCI_COMMAND_STATUS_REG, data); - - /* - ** show pci slot. - */ - - printf (" on pci%d:%d\n", bus, device); - -#ifdef __FreeBSD2__ - - /* - ** Allocate a devconf structure - */ - - pdcp = (struct pci_devconf *) - malloc (sizeof (struct pci_devconf),M_DEVBUF,M_WAITOK); - - /* - ** Fill in. - ** - ** Sorry, this is not yet complete. - ** We should, and eventually will, set the - ** parent pointer to a pci bus devconf structure, - ** and arrange to set the state field dynamically. - ** - ** But I'll go to vacation today, and after all, - ** wasn't there a new feature freeze on Oct 1.? - */ - - pdcp -> pdc_pi.pi_bus = bus; - pdcp -> pdc_pi.pi_device = device; - - pdcp -> pdc_kdc.kdc_name = dvp->pd_name; - pdcp -> pdc_kdc.kdc_unit = unit; - - pdcp -> pdc_kdc.kdc_md.mddc_devtype = MDDT_PCI; - - pdcp -> pdc_kdc.kdc_externalize = pci_externalize; - pdcp -> pdc_kdc.kdc_internalize = pci_internalize; - - pdcp -> pdc_kdc.kdc_datalen = PCI_EXTERNAL_LEN; - pdcp -> pdc_kdc.kdc_parentdata = &pdcp->pdc_pi; - pdcp -> pdc_kdc.kdc_state = DC_UNKNOWN; - pdcp -> pdc_kdc.kdc_description = name; - - /* - ** And register this device - */ - - dev_attach (&pdcp->pdc_kdc); - -#endif /* __FreeBSD2__ */ - - - /* - ** attach device - ** may produce additional log messages, - ** i.e. when installing subdevices. - */ - - (*drp->attach) (tag, unit); - }; - }; - -#ifndef PCI_QUIET - if (pci_paddr != old_addr) - printf ("pci uses physical addresses from 0x%lx to 0x%lx\n", - (u_long)PCI_PMEM_START, (u_long)pci_paddr); -#endif - pci_conf_count++; -} - -/*----------------------------------------------------------------------- -** -** Map device into port space. -** -** PCI-Specification: 6.2.5.1: address maps -** -**----------------------------------------------------------------------- -*/ - -int pci_map_port (pcici_t tag, u_long reg, u_short* pa) -{ - /* - ** @MAPIO@ not yet implemented. - */ - printf ("pci_map_port failed: not yet implemented\n"); - return (0); -} - -/*----------------------------------------------------------------------- -** -** Map device into virtual and physical space -** -** PCI-Specification: 6.2.5.1: address maps -** -**----------------------------------------------------------------------- -*/ - -int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa) -{ - u_long data; - vm_size_t vsize; - vm_offset_t vaddr; - - /* - ** sanity check - */ - - if (reg < PCI_MAP_REG_START || reg >= PCI_MAP_REG_END || (reg & 3)) { - printf ("pci_map_mem failed: bad register=0x%x\n", - (unsigned)reg); - return (0); - }; - - /* - ** get size and type of memory - ** - ** type is in the lowest four bits. - ** If device requires 2^n bytes, the next - ** n-4 bits are read as 0. - */ - - pci_conf_write (tag, reg, 0xfffffffful); - data = pci_conf_read (tag, reg); - - switch (data & 0x0f) { - - case PCI_MAP_MEMORY_TYPE_32BIT: /* 32 bit non cachable */ - break; - - default: /* unknown */ - printf ("pci_map_mem failed: bad memory type=0x%x\n", - (unsigned) data); - return (0); - }; - - /* - ** mask out the type, - ** and round up to a page size - */ - - vsize = round_page (-(data & PCI_MAP_MEMORY_ADDRESS_MASK)); - - if (!vsize) return (0); - - /* - ** align physical address to virtual size - */ - - if ((data = pci_paddr % vsize)) - pci_paddr += vsize - data; - - vaddr = (vm_offset_t) pmap_mapdev (pci_paddr, vsize); - - - if (!vaddr) return (0); - -#ifndef PCI_QUIET - /* - ** display values. - */ - - printf ("\treg%d: virtual=0x%lx physical=0x%lx\n", - (unsigned) reg, (u_long)vaddr, (u_long)pci_paddr); -#endif - - /* - ** return them to the driver - */ - - *va = vaddr; - *pa = pci_paddr; - - /* - ** set device address - */ - - pci_conf_write (tag, reg, pci_paddr); - - /* - ** and don't forget to increment pci_paddr - */ - - pci_paddr += vsize; - - return (1); -} - -/*------------------------------------------------------------ -** -** Interface functions for the devconf module. -** -**------------------------------------------------------------ -*/ - -static int -pci_externalize (struct proc *p, struct kern_devconf *kdcp, void *u, size_t l) -{ - struct pci_externalize_buffer buffer; - struct pci_info * pip = kdcp->kdc_parentdata; - pcici_t tag; - int i; - - if (l < sizeof buffer) { - return ENOMEM; - }; - - tag = pcitag (pip->pi_bus, pip->pi_device, 0); - - buffer.peb_pci_info = *pip; - - for (i=0; i<PCI_EXT_CONF_LEN; i++) { - buffer.peb_config[i] = pci_conf_read (tag, i*4); - }; - - return copyout(&buffer, u, sizeof buffer); -} - - -static int -pci_internalize (struct proc *p, struct kern_devconf *kdcp, void *u, size_t s) -{ - return EOPNOTSUPP; -} - -/*----------------------------------------------------------------------- -** -** Map pci interrupts to isa interrupts. -** -**----------------------------------------------------------------------- -*/ - -static unsigned int pci_int_mask [16]; - -int pci_map_int (pcici_t tag, int(*func)(), void* arg, unsigned* maskptr) -{ - int irq; - unsigned mask; - - irq = PCI_INTERRUPT_LINE_EXTRACT( - pci_conf_read (tag, PCI_INTERRUPT_REG)); - - if (irq >= 16 || irq <= 0) { - printf ("pci_map_int failed: no int line set.\n"); - return (0); - } - - mask = 1ul << irq; - - if (!maskptr) - maskptr = &pci_int_mask[irq]; - - INTRMASK (*maskptr, mask); - - register_intr( - irq, /* isa irq */ - 0, /* deviced?? */ - 0, /* flags? */ - (inthand2_t*) func, /* handler */ - maskptr, /* mask pointer */ - (int) arg); /* handler arg */ - -#ifdef __FreeBSD2__ - /* - ** XXX See comment at beginning of file. - ** - ** Have to update all the interrupt masks ... Grrrrr!!! - */ - { - unsigned * mp = &intr_mask[0]; - /* - ** update the isa interrupt masks. - */ - for (mp=&intr_mask[0]; mp<&intr_mask[ICU_LEN]; mp++) - if (*mp & *maskptr) - *mp |= mask; - /* - ** update the pci interrupt masks. - */ - for (mp=&pci_int_mask[0]; mp<&pci_int_mask[16]; mp++) - if (*mp & *maskptr) - *mp |= mask; - }; -#endif - - INTREN (mask); - - return (1); -} - -/*----------------------------------------------------------- -** -** Display of unknown devices. -** -**----------------------------------------------------------- -*/ -struct vt { - u_short ident; - char* name; -}; - -static struct vt VendorTable[] = { - {0x1002, "ATI TECHNOLOGIES INC"}, - {0x1011, "DIGITAL EQUIPMENT CORPORATION"}, - {0x101A, "NCR"}, - {0x102B, "MATROX"}, - {0x1045, "OPTI"}, - {0x5333, "S3 INC."}, - {0x8086, "INTEL CORPORATION"}, - {0,0} -}; - -static const char *const majclasses[] = { - "old", "storage", "network", "display", - "multimedia", "memory", "bridge" -}; - -void not_supported (pcici_t tag, u_long type) -{ - u_char reg; - u_long data; - struct vt * vp; - - /* - ** lookup the names. - */ - - for (vp=VendorTable; vp->ident; vp++) - if (vp->ident == (type & 0xffff)) - break; - - /* - ** and display them. - */ - - if (vp->ident) printf (vp->name); - else printf ("vendor=0x%lx", type & 0xffff); - - printf (", device=0x%lx", type >> 16); - - data = (pci_conf_read(tag, PCI_CLASS_REG) >> 24) & 0xff; - if (data < sizeof(majclasses) / sizeof(majclasses[0])) - printf(", class=%s", majclasses[data]); - - printf (" [not supported]\n"); - - for (reg=PCI_MAP_REG_START; reg<PCI_MAP_REG_END; reg+=4) { - data = pci_conf_read (tag, reg); - if (!data) continue; - switch (data&7) { - - case 1: - case 5: - printf (" map(%x): io(%lx)\n", - reg, data & ~3); - break; - case 0: - printf (" map(%x): mem32(%lx)\n", - reg, data & ~7); - break; - case 2: - printf (" map(%x): mem20(%lx)\n", - reg, data & ~7); - break; - case 4: - printf (" map(%x): mem64(%lx)\n", - reg, data & ~7); - break; - } - } -} - -#ifndef __FreeBSD2__ -/*----------------------------------------------------------- -** -** Mapping of physical to virtual memory -** -**----------------------------------------------------------- -*/ - -extern vm_map_t kernel_map; - -static vm_offset_t pmap_mapdev (vm_offset_t paddr, vm_size_t vsize) -{ - vm_offset_t vaddr,value; - u_long result; - - vaddr = vm_map_min (kernel_map); - - result = vm_map_find (kernel_map, (void*)0, (vm_offset_t) 0, - &vaddr, vsize, TRUE); - - if (result != KERN_SUCCESS) { - printf (" vm_map_find failed(%d)\n", result); - return (0); - }; - - /* - ** map physical - */ - - value = vaddr; - while (vsize >= NBPG) { - pmap_enter (pmap_kernel(), vaddr, paddr, - VM_PROT_READ|VM_PROT_WRITE, TRUE); - vaddr += NBPG; - paddr += NBPG; - vsize -= NBPG; - }; - return (value); -} - -/*------------------------------------------------------------ -** -** Emulate the register_intr() function of FreeBSD 2.0 -** -** requires a patch: -** FreeBSD 2.0: "/sys/i386/isa/vector.s" -** 386bsd0.1: "/sys/i386/isa/icu.s" -** 386bsd1.0: Please ask Jesus Monroy Jr. -** -**------------------------------------------------------------ -*/ - -#include <machine/segments.h> - -int pci_int_unit [16]; -inthand2_t* (pci_int_hdlr [16]); -unsigned int * pci_int_mptr [16]; -unsigned int pci_int_count[16]; - -extern void - Vpci3(), Vpci4(), Vpci5(), Vpci6(), Vpci7(), Vpci8(), Vpci9(), - Vpci10(), Vpci11(), Vpci12(), Vpci13(), Vpci14(), Vpci15(); - -static inthand_t* pci_int_glue[16] = { - 0, 0, 0, Vpci3, Vpci4, Vpci5, Vpci6, Vpci7, Vpci8, - Vpci9, Vpci10, Vpci11, Vpci12, Vpci13, Vpci14, Vpci15 }; - -static int -register_intr __P((int intr, int device_id, unsigned int flags, - inthand2_t *handler, unsigned int* mptr, int unit)) -{ - if (intr >= 16 || intr <= 2) - return (EINVAL); - if (pci_int_hdlr [intr]) - return (EBUSY); - - pci_int_hdlr [intr] = handler; - pci_int_unit [intr] = unit; - pci_int_mptr [intr] = mptr; - - setidt(NRSVIDT + intr, pci_int_glue[intr], SDT_SYS386IGT, SEL_KPL); - return (0); -} -#endif /* __FreeBSD2__ */ -#endif /* NPCI */ diff --git a/sys/i386/pci/pci.h b/sys/i386/pci/pci.h deleted file mode 100644 index 359bc96..0000000 --- a/sys/i386/pci/pci.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** $Id: pci.h,v 2.1 94/09/16 08:01:35 wolf Rel $ -** -** #define for pci bus device drivers -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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. -** -**------------------------------------------------------------------------- -*/ - -#ifndef __PCI_H__ -#define __PCI_H__ - -/* -** main pci initialization function. -** called at boot time from autoconf.c -*/ - -void pci_configure(void); - -/* -** pci configuration id -** -** is constructed from: bus, device & function numbers. -*/ - -typedef union { - u_long cfg1; - struct { - u_char enable; - u_char forward; - u_short port; - } cfg2; - } pcici_t; - -/* -** Each pci device has an unique device id. -** It is used to find a matching driver. -*/ - -typedef u_long pcidi_t; - -#endif /*__PCI_H__*/ diff --git a/sys/i386/pci/pci_config.c b/sys/i386/pci/pci_config.c deleted file mode 100644 index d7a41c0..0000000 --- a/sys/i386/pci/pci_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** -** -** $Id: pci_config.c,v 1.9 1994/10/13 01:12:30 se Exp $ -** -** @PCI@ this should be part of "ioconf.c". -** -** The config-utility should build it! -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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/types.h> -#include <i386/pci/pcireg.h> - -#include <ncr.h> -#if NNCR>0 -extern struct pci_driver ncr_device; -#endif - -#include <de.h> -#if NDE > 0 -extern struct pci_driver dedevice; -#endif - -#include <ahc.h> -#if NAHC > 0 -extern struct pci_driver ahc_device; -#endif - -extern struct pci_driver chipset_device; -extern struct pci_driver vga_device; -extern struct pci_driver ign_device; -extern struct pci_driver lkm_device; - -struct pci_device pci_devtab[] = { - -#if NNCR>0 - {&ncr_device, "ncr", 0 }, -#endif - -#if NDE>0 - {&dedevice, "de", 0 }, -#endif - -#if NAHC>0 - {&ahc_device, "ahc", 0 }, -#endif - - {&chipset_device, "chip", 0 }, - {&vga_device, "graphics", 0 }, - {&ign_device, "ign", 0 }, - {&lkm_device, "lkm", 0 }, - {0, 0, 0 } -}; diff --git a/sys/i386/pci/pci_device.h b/sys/i386/pci/pci_device.h deleted file mode 100644 index aecbd6e..0000000 --- a/sys/i386/pci/pci_device.h +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************************** -** -** $Id: pci_device.h,v 1.5 1994/09/28 16:34:10 se Exp $ -** -** #define for pci based device drivers -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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. -** -**------------------------------------------------------------------------- -*/ - -#ifndef __PCI_DEVICE_H__ -#define __PCI_DEVICE_H__ - -/*------------------------------------------------------------ -** -** Per driver structure. -** -**------------------------------------------------------------ -*/ - -struct pci_driver { - int (*probe )(pcici_t pci_ident); /* test whether device is present */ - int (*attach)(pcici_t pci_ident); /* setup driver for a device */ - pcidi_t device_id; /* device pci id */ - char *name; /* device (long) name */ - int (*intr)(int); /* interupt handler */ -}; - -/*----------------------------------------------------------- -** -** Per device structure. -** -** It is initialized by the config utility and should live in -** "ioconf.c". At the moment there is only one field. -** -** This is a first attempt to include the pci bus to 386bsd. -** So this structure may grow .. -** -** Extended by Garrett Wollman <wollman@halloran-eldar.lcs.mit.edu> -** for future loadable drivers . -** -**----------------------------------------------------------- -*/ - -struct pci_device { - struct - pci_driver* pd_driver; - pcidi_t pd_device_id; /* device pci id */ - const char * pd_name; /* for future loadable drivers */ - int pd_flags; - int pd_npresent; /* for future loadable drivers */ -}; - -#define PDF_LOADABLE 0x01 -#define PDF_COVERED 0x02 - -/*----------------------------------------------------------- -** -** This table should be generated in file "ioconf.c" -** by the config program. -** It is used at boot time by the configuration function -** pci_configure() -** -**----------------------------------------------------------- -*/ - -extern struct pci_device pci_devtab[]; - -/*----------------------------------------------------------- -** -** This functions may be used by drivers to map devices -** to virtual and physical addresses. The va and pa -** addresses are "in/out" parameters. If they are 0 -** on entry, the mapping function assigns an address. -** -**----------------------------------------------------------- -*/ - -int pci_map_mem (pcici_t tag, u_long entry, u_long * va, u_long * pa); - -int pci_map_port(pcici_t tag, u_long entry, u_short * pa); - -#endif /*__PCI_DEVICE_H__*/ diff --git a/sys/i386/pci/pci_intel.c b/sys/i386/pci/pci_intel.c deleted file mode 100644 index 48451f5..0000000 --- a/sys/i386/pci/pci_intel.c +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************** -** -** $Id: pci_intel.c,v 2.1 94/09/16 08:02:42 wolf Rel $ -** -** Device driver for INTEL PCI chipsets. -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** wolf@dentaro.gun.de Wolfgang Stanglmeier -** se@mi.Uni-Koeln.de Stefan Esser -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Stefan Esser. All rights reserved. -** -** 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. 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 files -** -**========================================================== -*/ - -#include <sys/types.h> - -#include <i386/pci/pci.h> -#include <i386/pci/pcibios.h> -#include <i386/pci/pci_device.h> - -static int probe1(pcici_t config_id); -static int return0(int unit); -static int intel_attach(pcici_t config_id); -static int intel_82424zx_attach(pcici_t config_id); -static int intel_82434lx_attach(pcici_t config_id); -extern void printf(); -static char confread(pcici_t config_id, int port); - -struct condmsg { - unsigned char port; - unsigned char mask; - unsigned char value; - char flags; - char *text; -}; - -#define M_EQ 0 /* mask and return true if equal */ -#define M_NE 1 /* mask and return true if not equal */ -#define TRUE 2 /* don't read config, always true */ - - -struct pci_driver intel82378_device = { - probe1, - intel_attach, - 0x04848086, - "intel 82378IB pci-isa bridge", - return0 -}; - -struct pci_driver intel82424_device = { - probe1, - intel_82424zx_attach, - 0x04838086, - "intel 82424ZX cache dram controller", - return0 -}; - -struct pci_driver intel82375_device = { - probe1, - intel_attach, - 0x04828086, - "intel 82375EB pci-eisa bridge", - return0 -}; - -struct pci_driver intel82434_device = { - probe1, - intel_82434lx_attach, - 0x04a38086, - "intel 82434LX pci cache memory controller", - return0 -}; - -struct condmsg conf82424zx[] = -{ - { 0x00, 0x00, 0x00, TRUE, "\tCPU: " }, - { 0x50, 0xe0, 0x00, M_EQ, "486DX" }, - { 0x50, 0xe0, 0x20, M_EQ, "486SX" }, - { 0x50, 0xe0, 0x40, M_EQ, "486DX2 or 486DX4" }, - { 0x50, 0xe0, 0x80, M_EQ, "Overdrive (writeback)" }, - - { 0x00, 0x00, 0x00, TRUE, ", bus=" }, - { 0x50, 0x03, 0x00, M_EQ, "25MHz" }, - { 0x50, 0x03, 0x01, M_EQ, "33MHz" }, - { 0x53, 0x01, 0x01, TRUE, ", CPU->Memory posting "}, - { 0x53, 0x01, 0x00, M_EQ, "OFF" }, - { 0x53, 0x01, 0x01, M_EQ, "ON" }, - - { 0x56, 0x30, 0x00, M_NE, "\n\tWarning:" }, - { 0x56, 0x20, 0x00, M_NE, " NO cache parity!" }, - { 0x56, 0x10, 0x00, M_NE, " NO DRAM parity!" }, - { 0x55, 0x04, 0x04, M_EQ, "\n\tWarning: refresh OFF! " }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tCache: " }, - { 0x52, 0x01, 0x00, M_EQ, "None" }, - { 0x52, 0xc1, 0x01, M_EQ, "64KB" }, - { 0x52, 0xc1, 0x41, M_EQ, "128KB" }, - { 0x52, 0xc1, 0x81, M_EQ, "256KB" }, - { 0x52, 0xc1, 0xc1, M_EQ, "512KB" }, - { 0x52, 0x03, 0x01, M_EQ, " writethrough" }, - { 0x52, 0x03, 0x03, M_EQ, " writeback" }, - - { 0x52, 0x01, 0x01, M_EQ, ", cache clocks=" }, - { 0x52, 0x05, 0x01, M_EQ, "3-1-1-1" }, - { 0x52, 0x05, 0x05, M_EQ, "2-1-1-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tDRAM:" }, - { 0x55, 0x43, 0x00, M_NE, " page mode" }, - { 0x55, 0x02, 0x02, M_EQ, " code fetch" }, - { 0x55, 0x43, 0x43, M_EQ, "," }, - { 0x55, 0x43, 0x42, M_EQ, " and" }, - { 0x55, 0x40, 0x40, M_EQ, " read" }, - { 0x55, 0x03, 0x03, M_EQ, " and" }, - { 0x55, 0x43, 0x41, M_EQ, " and" }, - { 0x55, 0x01, 0x01, M_EQ, " write" }, - { 0x55, 0x43, 0x00, M_NE, "," }, - - { 0x00, 0x00, 0x00, TRUE, " memory clocks=" }, - { 0x55, 0x20, 0x00, M_EQ, "X-2-2-2" }, - { 0x55, 0x20, 0x20, M_EQ, "X-1-2-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tPCI: CPU->PCI posting " }, - { 0x53, 0x02, 0x02, M_EQ, "ON" }, - { 0x53, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, ", CPU->PCI burst mode " }, - { 0x54, 0x02, 0x02, M_EQ, "ON" }, - { 0x54, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, ", PCI->Memory posting " }, - { 0x54, 0x01, 0x01, M_EQ, "ON" }, - { 0x54, 0x01, 0x00, M_EQ, "OFF" }, - - { 0x00, 0x00, 0x00, TRUE, "\n" }, - -/* end marker */ - { 0 } -}; - -struct condmsg conf82434lx[] = -{ - { 0x00, 0x00, 0x00, TRUE, "\tCPU: " }, - { 0x50, 0xe0, 0x80, M_EQ, "Pentium" }, - { 0x50, 0xe0, 0x80, M_NE, "???" }, - { 0x50, 0x02, 0x00, M_EQ, ", ???MHz" }, - { 0x50, 0x03, 0x02, M_EQ, ", 60MHz" }, - { 0x50, 0x03, 0x03, M_EQ, ", 66MHz" }, - { 0x50, 0x04, 0x00, M_EQ, " (primary cache OFF)" }, - - { 0x53, 0x01, 0x01, TRUE, ", CPU->Memory posting "}, - { 0x53, 0x01, 0x00, M_EQ, "OFF" }, - { 0x53, 0x01, 0x01, M_NE, "ON" }, - - { 0x53, 0x04, 0x00, M_NE, ", read around write"}, - - { 0x71, 0xc0, 0x00, M_NE, "\n\tWarning: NO cache parity!" }, - { 0x57, 0x20, 0x00, M_NE, "\n\tWarning: NO DRAM parity!" }, - { 0x55, 0x01, 0x01, M_EQ, "\n\tWarning: refresh OFF! " }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tCache: " }, - { 0x52, 0x01, 0x00, M_EQ, "None" }, - { 0x52, 0x81, 0x01, M_EQ, "" }, - { 0x52, 0xc1, 0x81, M_EQ, "256KB" }, - { 0x52, 0xc1, 0xc1, M_EQ, "512KB" }, - { 0x52, 0x03, 0x01, M_EQ, " writethrough" }, - { 0x52, 0x03, 0x03, M_EQ, " writeback" }, - - { 0x52, 0x01, 0x01, M_EQ, ", cache clocks=" }, - { 0x52, 0x20, 0x00, M_EQ, "3-2-2-2/4-2-2-2" }, - { 0x52, 0x20, 0x00, M_NE, "3-1-1-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tDRAM:" }, - { 0x57, 0x10, 0x00, M_EQ, " page mode" }, - - { 0x00, 0x00, 0x00, TRUE, " memory clocks=" }, - { 0x57, 0xc0, 0x00, M_EQ, "X-4-4-4 (70ns)" }, - { 0x57, 0xc0, 0x40, M_EQ, "X-4-4-4/X-3-3-3 (60ns)" }, - { 0x57, 0xc0, 0x80, M_EQ, "???" }, - { 0x57, 0xc0, 0xc0, M_EQ, "X-3-3-3 (50ns)" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tPCI: CPU->PCI posting " }, - { 0x53, 0x02, 0x02, M_EQ, "ON" }, - { 0x53, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, ", CPU->PCI burst mode " }, - { 0x54, 0x02, 0x00, M_NE, "ON" }, - { 0x54, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, ", PCI->Memory posting " }, - { 0x54, 0x01, 0x00, M_NE, "ON" }, - { 0x54, 0x01, 0x00, M_EQ, "OFF" }, - { 0x54, 0x04, 0x00, TRUE, ", PCI clocks=" }, - { 0x54, 0x04, 0x00, M_EQ, "2-2-2-2" }, - { 0x54, 0x04, 0x00, M_NE, "2-1-1-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n" }, - -/* end marker */ - { 0 } -}; - -int return0(int unit) -{ - return (0); -} - -int probe1(pcici_t config_id) -{ - return (1); -} - -static char confread (pcici_t config_id, int port) -{ - unsigned long portw = port & ~3; - unsigned long ports = (port - portw) << 3; - - unsigned long l = pci_conf_read (config_id, portw); - return (l >> ports); -} - -static void writeconfig(pcici_t config_id, struct condmsg *tbl) -{ - while (tbl->text) { - int cond = 0; - if (tbl->flags == TRUE) { - cond = 1; - } else { - unsigned char v = (unsigned char) confread(config_id, tbl->port); - switch (tbl->flags) { - case M_EQ: - if ((v & tbl->mask) == tbl->value) cond = 1; - break; - case M_NE: - if ((v & tbl->mask) != tbl->value) cond = 1; - break; - } - } - if (cond) printf ("%s", tbl->text); - tbl++; - } -} - -int intel_attach(pcici_t config_id) -{ - printf ("\t[40] %lx [50] %lx [54] %lx\n", - pci_conf_read (config_id, 0x40), - pci_conf_read (config_id, 0x50), - pci_conf_read (config_id, 0x54)); - return(0); -} - -int intel_82424zx_attach(pcici_t config_id) -{ - writeconfig (config_id, conf82424zx); - return (0); -} - -int intel_82434lx_attach(pcici_t config_id) -{ - writeconfig (config_id, conf82434lx); - return (0); -} - diff --git a/sys/i386/pci/pcibios.c b/sys/i386/pci/pcibios.c deleted file mode 100644 index 2069387..0000000 --- a/sys/i386/pci/pcibios.c +++ /dev/null @@ -1,276 +0,0 @@ -/************************************************************************** -** -** $Id: pcibios.c,v 2.6 94/10/11 19:01:25 wolf Oct11 $ -** -** #define for pci-bus bios functions. -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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 <pci.h> -#if NPCI > 0 - -#if __FreeBSD__ >= 2 -#define HAS_CPUFUNC_H -#endif - -#include <types.h> -#include <i386/isa/isa.h> -#include <i386/pci/pcireg.h> -#ifdef HAS_CPUFUNC_H -#include <i386/include/cpufunc.h> -#endif - -extern int printf(); - -static char pci_mode; - - -/*-------------------------------------------------------------------- -** -** Port access -** -**-------------------------------------------------------------------- -*/ - -#ifndef HAS_CPUFUNC_H - -#undef inl -#define inl(port) \ -({ u_long data; \ - __asm __volatile("inl %1, %0": "=a" (data): "d" ((u_short)(port))); \ - data; }) - - -#undef outl -#define outl(port, data) \ -{__asm __volatile("outl %0, %1"::"a" ((u_long)(data)), "d" ((u_short)(port)));} - - -#undef inb -#define inb(port) \ -({ u_char data; \ - __asm __volatile("inb %1, %0": "=a" (data): "d" ((u_short)(port))); \ - data; }) - - -#undef outb -#define outb(port, data) \ -{__asm __volatile("outb %0, %1"::"a" ((u_char)(data)), "d" ((u_short)(port)));} - -#endif /* HAS_CPUFUNC_H */ - -/*-------------------------------------------------------------------- -** -** Determine configuration mode -** -**-------------------------------------------------------------------- -*/ - - -#define CONF1_ENABLE 0x80000000ul -#define CONF1_ADDR_PORT 0x0cf8 -#define CONF1_DATA_PORT 0x0cfc - - -#define CONF2_ENABLE_PORT 0x0cf8 -#define CONF2_FORWARD_PORT 0x0cfa - - -int pci_conf_mode (void) -{ -#ifdef PCI_CONF_MODE - return (PCI_CONF_MODE) -#else /* PCI_CONF_MODE */ - u_long result, oldval; - - /*--------------------------------------- - ** Configuration mode 2 ? - **--------------------------------------- - */ - - outb (CONF2_ENABLE_PORT, 0); - outb (CONF2_FORWARD_PORT, 0); - if (!inb (CONF2_ENABLE_PORT) && !inb (CONF2_FORWARD_PORT)) { - pci_mode = 2; - return (2); - }; - - /*--------------------------------------- - ** Configuration mode 1 ? - **--------------------------------------- - */ - - oldval = inl (CONF1_ADDR_PORT); - outl (CONF1_ADDR_PORT, CONF1_ENABLE); - result = inl (CONF1_ADDR_PORT); - outl (CONF1_ADDR_PORT, oldval); - - if (result == CONF1_ENABLE) { - pci_mode = 1; - return (1); - }; - - /*--------------------------------------- - ** No PCI bus available. - **--------------------------------------- - */ - return (0); -#endif /* PCI_CONF_MODE */ -} - -/*-------------------------------------------------------------------- -** -** Build a pcitag from bus, device and function number -** -**-------------------------------------------------------------------- -*/ - -pcici_t pcitag (unsigned char bus, - unsigned char device, - unsigned char func) -{ - pcici_t tag; - - tag.cfg1 = 0; - if (device >= 32) return tag; - if (func >= 8) return tag; - - switch (pci_mode) { - - case 1: - tag.cfg1 = CONF1_ENABLE - | (((u_long) bus ) << 16ul) - | (((u_long) device) << 11ul) - | (((u_long) func ) << 8ul); - break; - case 2: - if (device >= 16) break; - tag.cfg2.port = 0xc000 | (device << 8ul); - tag.cfg2.enable = 0xf1 | (func << 1ul); - tag.cfg2.forward = bus; - break; - }; - return tag; -} - -/*-------------------------------------------------------------------- -** -** Read register from configuration space. -** -**-------------------------------------------------------------------- -*/ - - -u_long pci_conf_read (pcici_t tag, u_long reg) -{ - u_long addr, data = 0; - - if (!tag.cfg1) return (0xfffffffful); - - switch (pci_mode) { - - case 1: - addr = tag.cfg1 | (reg & 0xfc); -#ifdef PCI_DEBUG - printf ("pci_conf_read(1): addr=%x ", addr); -#endif - outl (CONF1_ADDR_PORT, addr); - data = inl (CONF1_DATA_PORT); - outl (CONF1_ADDR_PORT, 0 ); - break; - - case 2: - addr = tag.cfg2.port | (reg & 0xfc); -#ifdef PCI_DEBUG - printf ("pci_conf_read(2): addr=%x ", addr); -#endif - outb (CONF2_ENABLE_PORT , tag.cfg2.enable ); - outb (CONF2_FORWARD_PORT, tag.cfg2.forward); - - data = inl ((u_short) addr); - - outb (CONF2_ENABLE_PORT, 0); - outb (CONF2_FORWARD_PORT, 0); - break; - }; - -#ifdef PCI_DEBUG - printf ("data=%x\n", data); -#endif - - return (data); -} - -/*-------------------------------------------------------------------- -** -** Write register into configuration space. -** -**-------------------------------------------------------------------- -*/ - - -void pci_conf_write (pcici_t tag, u_long reg, u_long data) -{ - u_long addr; - - if (!tag.cfg1) return; - - switch (pci_mode) { - - case 1: - addr = tag.cfg1 | (reg & 0xfc); -#ifdef PCI_DEBUG - printf ("pci_conf_write(1): addr=%x data=%x\n", - addr, data); -#endif - outl (CONF1_ADDR_PORT, addr); - outl (CONF1_DATA_PORT, data); - outl (CONF1_ADDR_PORT, 0 ); - break; - - case 2: - addr = tag.cfg2.port | (reg & 0xfc); -#ifdef PCI_DEBUG - printf ("pci_conf_write(2): addr=%x data=%x\n", - addr, data); -#endif - outb (CONF2_ENABLE_PORT, tag.cfg2.enable); - outb (CONF2_FORWARD_PORT, tag.cfg2.forward); - - outl ((u_short) addr, data); - - outb (CONF2_ENABLE_PORT, 0); - outb (CONF2_FORWARD_PORT, 0); - break; - }; -} -#endif /* NPCI > 0 */ diff --git a/sys/i386/pci/pcibios.h b/sys/i386/pci/pcibios.h deleted file mode 100644 index 7d240f5..0000000 --- a/sys/i386/pci/pcibios.h +++ /dev/null @@ -1,209 +0,0 @@ -/************************************************************************** -** -** $Id: pcibios.h,v 2.1 94/09/16 08:01:37 wolf Rel $ -** -** #define for pci-bus bios functions. -** #define for pci configuration space registers. -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** Copyright (c) 1994 Charles Hannum. All rights reserved. -** -** 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. 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. -** -**------------------------------------------------------------------------- -*/ - -#ifndef __PCIBIOS_H__ -#define __PCIBIOS_H__ - -/* -** the availability of a pci bus. -** configuration mode (1 or 2) -** 0 if no pci bus found. -*/ - -int pci_conf_mode (void); - -/* -** The number of the last available pci bus. -*/ - -int pci_last_bus (void); - -/* -** get a "ticket" for accessing a pci device -** configuration space. -*/ - -pcici_t pcitag (unsigned char bus, - unsigned char device, - unsigned char func); - -/* -** read or write the configuration space. -*/ - -u_long pci_conf_read (pcici_t tag, u_long reg ); -void pci_conf_write (pcici_t tag, u_long reg, u_long data); - - -/*------------------------------------------------------------------ -** -** Names for PCI configuration space registers. -** -** Copyright (c) 1994 Charles Hannum. All rights reserved. -** -**------------------------------------------------------------------ -*/ - -/* - * Device identification register; contains a vendor ID and a device ID. - * We have little need to distinguish the two parts. - */ -#define PCI_ID_REG 0x00 - -/* - * Command and status register. - */ -#define PCI_COMMAND_STATUS_REG 0x04 - -#define PCI_COMMAND_IO_ENABLE 0x00000001 -#define PCI_COMMAND_MEM_ENABLE 0x00000002 -#define PCI_COMMAND_MASTER_ENABLE 0x00000004 -#define PCI_COMMAND_SPECIAL_ENABLE 0x00000008 -#define PCI_COMMAND_INVALIDATE_ENABLE 0x00000010 -#define PCI_COMMAND_PALETTE_ENABLE 0x00000020 -#define PCI_COMMAND_PARITY_ENABLE 0x00000040 -#define PCI_COMMAND_STEPPING_ENABLE 0x00000080 -#define PCI_COMMAND_SERR_ENABLE 0x00000100 -#define PCI_COMMAND_BACKTOBACK_ENABLE 0x00000200 - -#define PCI_STATUS_BACKTOBACK_OKAY 0x00800000 -#define PCI_STATUS_PARITY_ERROR 0x01000000 -#define PCI_STATUS_DEVSEL_FAST 0x00000000 -#define PCI_STATUS_DEVSEL_MEDIUM 0x02000000 -#define PCI_STATUS_DEVSEL_SLOW 0x04000000 -#define PCI_STATUS_DEVSEL_MASK 0x06000000 -#define PCI_STATUS_TARGET_TARGET_ABORT 0x08000000 -#define PCI_STATUS_MASTER_TARGET_ABORT 0x10000000 -#define PCI_STATUS_MASTER_ABORT 0x20000000 -#define PCI_STATUS_SPECIAL_ERROR 0x40000000 -#define PCI_STATUS_PARITY_DETECT 0x80000000 - -/* - * Class register; defines basic type of device. - */ -#define PCI_CLASS_REG 0x08 - -#define PCI_CLASS_MASK 0xff000000 -#define PCI_SUBCLASS_MASK 0x00ff0000 - -/* base classes */ -#define PCI_CLASS_PREHISTORIC 0x00000000 -#define PCI_CLASS_MASS_STORAGE 0x01000000 -#define PCI_CLASS_NETWORK 0x02000000 -#define PCI_CLASS_DISPLAY 0x03000000 -#define PCI_CLASS_MULTIMEDIA 0x04000000 -#define PCI_CLASS_MEMORY 0x05000000 -#define PCI_CLASS_BRIDGE 0x06000000 -#define PCI_CLASS_UNDEFINED 0xff000000 - -/* 0x00 prehistoric subclasses */ -#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00000000 -#define PCI_SUBCLASS_PREHISTORIC_VGA 0x00010000 - -/* 0x01 mass storage subclasses */ -#define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00000000 -#define PCI_SUBCLASS_MASS_STORAGE_IDE 0x00010000 -#define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x00020000 -#define PCI_SUBCLASS_MASS_STORAGE_IPI 0x00030000 -#define PCI_SUBCLASS_MASS_STORAGE_MISC 0x00800000 - -/* 0x02 network subclasses */ -#define PCI_SUBCLASS_NETWORK_ETHERNET 0x00000000 -#define PCI_SUBCLASS_NETWORK_TOKENRING 0x00010000 -#define PCI_SUBCLASS_NETWORK_FDDI 0x00020000 -#define PCI_SUBCLASS_NETWORK_MISC 0x00800000 - -/* 0x03 display subclasses */ -#define PCI_SUBCLASS_DISPLAY_VGA 0x00000000 -#define PCI_SUBCLASS_DISPLAY_XGA 0x00010000 -#define PCI_SUBCLASS_DISPLAY_MISC 0x00800000 - -/* 0x04 multimedia subclasses */ -#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00000000 -#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x00010000 -#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x00800000 - -/* 0x05 memory subclasses */ -#define PCI_SUBCLASS_MEMORY_RAM 0x00000000 -#define PCI_SUBCLASS_MEMORY_FLASH 0x00010000 -#define PCI_SUBCLASS_MEMORY_MISC 0x00800000 - -/* 0x06 bridge subclasses */ -#define PCI_SUBCLASS_BRIDGE_HOST 0x00000000 -#define PCI_SUBCLASS_BRIDGE_ISA 0x00010000 -#define PCI_SUBCLASS_BRIDGE_EISA 0x00020000 -#define PCI_SUBCLASS_BRIDGE_MC 0x00030000 -#define PCI_SUBCLASS_BRIDGE_PCI 0x00040000 -#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x00050000 -#define PCI_SUBCLASS_BRIDGE_MISC 0x00800000 - -/* - * Mapping registers - */ -#define PCI_MAP_REG_START 0x10 -#define PCI_MAP_REG_END 0x28 - -#define PCI_MAP_MEMORY 0x00000000 -#define PCI_MAP_IO 0x00000001 - -#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 -#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 -#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 -#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 -#define PCI_MAP_MEMORY_CACHABLE 0x00000008 -#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 - -/* - * Interrupt configuration register - */ -#define PCI_INTERRUPT_REG 0x3c - -#define PCI_INTERRUPT_PIN_MASK 0x0000ff00 -#define PCI_INTERRUPT_PIN_EXTRACT(x) ((((x) & PCI_INTERRUPT_PIN_MASK) >> 8) & 0xff) -#define PCI_INTERRUPT_PIN_NONE 0x00 -#define PCI_INTERRUPT_PIN_A 0x01 -#define PCI_INTERRUPT_PIN_B 0x02 -#define PCI_INTERRUPT_PIN_C 0x03 -#define PCI_INTERRUPT_PIN_D 0x04 - -#define PCI_INTERRUPT_LINE_MASK 0x000000ff -#define PCI_INTERRUPT_LINE_EXTRACT(x) ((((x) & PCI_INTERRUPT_LINE_MASK) >> 0) & 0xff) -#define PCI_INTERRUPT_LINE_INSERT(x,v) (((x) & ~PCI_INTERRUPT_LINE_MASK) | ((v) << 0)) - -#endif diff --git a/sys/i386/pci/pcireg.h b/sys/i386/pci/pcireg.h deleted file mode 100644 index dd1f1cc..0000000 --- a/sys/i386/pci/pcireg.h +++ /dev/null @@ -1,423 +0,0 @@ -/************************************************************************** -** -** $Id: pcireg.h,v 1.1 1994/10/12 02:25:03 se Exp $ -** -** Declarations for pci bus drivers. -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved. -** -** 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. 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. -** -*************************************************************************** -*/ - -#ifndef __PCI_REG_H__ -#define __PCI_REG_H__ - -/*----------------------------------------------------------------- -** -** main pci initialization function. -** called at boot time from autoconf.c -** -**----------------------------------------------------------------- -*/ - -void pci_configure (void); - -/*----------------------------------------------------------------- -** -** The pci configuration id describes a pci device on the bus. -** It is constructed from: bus, device & function numbers. -** -**----------------------------------------------------------------- -*/ - -typedef union { - u_long cfg1; - struct { - u_char enable; - u_char forward; - u_short port; - } cfg2; - } pcici_t; - -/*----------------------------------------------------------------- -** -** Each pci device has an unique device id. -** It is used to find a matching driver. -** -**----------------------------------------------------------------- -*/ - -typedef u_long pcidi_t; - -/*----------------------------------------------------------------- -** -** The pci driver structure. -** -** probe: Checks if the driver can support a device -** with this type. The tag may be used to get -** more info with pci_read_conf(). See below. -** It returns a string with the devices name, -** or a NULL pointer, if the driver cannot -** support this device. -** -** attach: Allocate a control structure and prepare -** it. This function may use the pci mapping -** functions. See below. -** (configuration id) or type. -** -** count: A pointer to a unit counter. -** It's used by the pci configurator to -** allocate unit numbers. -** -**----------------------------------------------------------------- -*/ - -struct pci_driver { - char* (*probe ) (pcici_t tag, pcidi_t type); - void (*attach) (pcici_t tag, int unit); - u_long *count; -}; - -/*----------------------------------------------------------------- -** -** The pci-devconf interface. -** -**----------------------------------------------------------------- -*/ - -struct pci_info { - u_short pi_bus; - u_short pi_device; -}; - -#define PCI_EXT_CONF_LEN (16) -#define PCI_EXTERNAL_LEN (sizeof(struct pci_externalize_buffer)) - -struct pci_externalize_buffer { - struct pci_info peb_pci_info; - u_long peb_config[PCI_EXT_CONF_LEN]; -}; - - -/*----------------------------------------------------------------- -** -** Per device structure. -** -** An array of this structure should be created by the -** config utility and live in "ioconf.c". -** -** At the moment it's created by hand and lives in -** pci_config.c -** -** pd_driver: -** a pointer to the driver structure. -** -** pd_name: -** the name of the devices which are supported -** by this driver for kernel messages. -** -** pd_flags: -** for further study. -** -**----------------------------------------------------------------- -*/ - -struct pci_device { - struct - pci_driver* pd_driver; - const char * pd_name; - int pd_flags; -}; - -/*----------------------------------------------------------------- -** -** This table should be generated in file "ioconf.c" -** by the config program. -** It is used at boot time by the configuration function -** pci_configure() -** -**----------------------------------------------------------------- -*/ - -extern struct pci_device pci_devtab[]; - -/*----------------------------------------------------------------- -** -** Map a pci device to physical and virtual memory. -** -** The va and pa addresses are "in/out" parameters. -** If they are 0 on entry, the function assigns an address. -** -** Entry selects the register in the pci configuration -** space, which supplies the size of the region, and -** receives the physical address. -** -** If there is any error, a message is written, and -** the function returns with zero. -** Else it returns with a value different to zero. -** -**----------------------------------------------------------------- -*/ - -int pci_map_mem (pcici_t tag, u_long entry, u_long * va, u_long * pa); - -/*----------------------------------------------------------------- -** -** Map a pci device to an io port area. -** -** *pa is an "in/out" parameter. -** If it's 0 on entry, the function assigns an port number.. -** -** Entry selects the register in the pci configuration -** space, which supplies the size of the region, and -** receives the port number. -** -** If there is any error, a message is written, and -** the function returns with zero. -** Else it returns with a value different to zero. -** -**----------------------------------------------------------------- -*/ - -int pci_map_port(pcici_t tag, u_long entry, u_short * pa); - -/*----------------------------------------------------------------- -** -** Map a pci interrupt to an isa irq line, -** and enable the interrupt. -** -** func is the interrupt handler, arg is the argument -** to this function. -** -** The maskptr argument should be &bio_imask, -** &net_imask etc. or NULL. -** -** If there is any error, a message is written, and -** the function returns with zero. -** Else it returns with a value different to zero. -** -** A word of caution for FreeBSD 2.0: -** -** We use the register_intr() function. -** -** The interrupt line of the selected device is included -** into the supplied mask: after the corresponding splXXX -** this drivers interrupts are blocked. -** -** But in the interrupt handlers startup code ONLY -** the interrupt of the driver is blocked, and NOT -** all interrupts of the spl group. -** -** It may be required to additional block the group -** interrupts by splXXX() inside the interrupt handler. -** -** In pre 2.0 kernels we emulate the register_intr -** function. The emulating function blocks all interrupts -** of the group in the interrupt handler prefix code. -** -**----------------------------------------------------------------- -*/ - -int pci_map_int (pcici_t tag, int (*func)(), void* arg, unsigned * maskptr); - -/*----------------------------------------------------------------- -** -** The following functions are provided by the pci bios. -** They are used only by the pci configuration. -** -** pci_conf_mode(): -** Probes for a pci system. -** Returns 1 or 2 for pci configuration mechanism. -** Returns 0 if no pci system. -** -** pcitag(): -** Gets a handle for accessing the pci configuration -** space. -** This handle is given to the mapping functions (see -** above) or to the read/write functions. -** -** pci_conf_read(): -** Read a long word from the pci configuration space. -** Requires a tag (from pcitag) and the register -** number (should be a long word alligned one). -** -** pci_conf_write(): -** Writes a long word to the pci configuration space. -** Requires a tag (from pcitag), the register number -** (should be a long word alligned one), and a value. -** -**----------------------------------------------------------------- -*/ - -int pci_conf_mode (void); - -pcici_t pcitag (unsigned char bus, - unsigned char device, - unsigned char func); - -u_long pci_conf_read (pcici_t tag, u_long reg ); -void pci_conf_write (pcici_t tag, u_long reg, u_long data); - - -/*------------------------------------------------------------------ -** -** Names for PCI configuration space registers. -** -** Copyright (c) 1994 Charles Hannum. All rights reserved. -** -**------------------------------------------------------------------ -*/ - -/* - * Device identification register; contains a vendor ID and a device ID. - * We have little need to distinguish the two parts. - */ -#define PCI_ID_REG 0x00 - -/* - * Command and status register. - */ -#define PCI_COMMAND_STATUS_REG 0x04 - -#define PCI_COMMAND_IO_ENABLE 0x00000001 -#define PCI_COMMAND_MEM_ENABLE 0x00000002 -#define PCI_COMMAND_MASTER_ENABLE 0x00000004 -#define PCI_COMMAND_SPECIAL_ENABLE 0x00000008 -#define PCI_COMMAND_INVALIDATE_ENABLE 0x00000010 -#define PCI_COMMAND_PALETTE_ENABLE 0x00000020 -#define PCI_COMMAND_PARITY_ENABLE 0x00000040 -#define PCI_COMMAND_STEPPING_ENABLE 0x00000080 -#define PCI_COMMAND_SERR_ENABLE 0x00000100 -#define PCI_COMMAND_BACKTOBACK_ENABLE 0x00000200 - -#define PCI_STATUS_BACKTOBACK_OKAY 0x00800000 -#define PCI_STATUS_PARITY_ERROR 0x01000000 -#define PCI_STATUS_DEVSEL_FAST 0x00000000 -#define PCI_STATUS_DEVSEL_MEDIUM 0x02000000 -#define PCI_STATUS_DEVSEL_SLOW 0x04000000 -#define PCI_STATUS_DEVSEL_MASK 0x06000000 -#define PCI_STATUS_TARGET_TARGET_ABORT 0x08000000 -#define PCI_STATUS_MASTER_TARGET_ABORT 0x10000000 -#define PCI_STATUS_MASTER_ABORT 0x20000000 -#define PCI_STATUS_SPECIAL_ERROR 0x40000000 -#define PCI_STATUS_PARITY_DETECT 0x80000000 - -/* - * Class register; defines basic type of device. - */ -#define PCI_CLASS_REG 0x08 - -#define PCI_CLASS_MASK 0xff000000 -#define PCI_SUBCLASS_MASK 0x00ff0000 - -/* base classes */ -#define PCI_CLASS_PREHISTORIC 0x00000000 -#define PCI_CLASS_MASS_STORAGE 0x01000000 -#define PCI_CLASS_NETWORK 0x02000000 -#define PCI_CLASS_DISPLAY 0x03000000 -#define PCI_CLASS_MULTIMEDIA 0x04000000 -#define PCI_CLASS_MEMORY 0x05000000 -#define PCI_CLASS_BRIDGE 0x06000000 -#define PCI_CLASS_UNDEFINED 0xff000000 - -/* 0x00 prehistoric subclasses */ -#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00000000 -#define PCI_SUBCLASS_PREHISTORIC_VGA 0x00010000 - -/* 0x01 mass storage subclasses */ -#define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00000000 -#define PCI_SUBCLASS_MASS_STORAGE_IDE 0x00010000 -#define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x00020000 -#define PCI_SUBCLASS_MASS_STORAGE_IPI 0x00030000 -#define PCI_SUBCLASS_MASS_STORAGE_MISC 0x00800000 - -/* 0x02 network subclasses */ -#define PCI_SUBCLASS_NETWORK_ETHERNET 0x00000000 -#define PCI_SUBCLASS_NETWORK_TOKENRING 0x00010000 -#define PCI_SUBCLASS_NETWORK_FDDI 0x00020000 -#define PCI_SUBCLASS_NETWORK_MISC 0x00800000 - -/* 0x03 display subclasses */ -#define PCI_SUBCLASS_DISPLAY_VGA 0x00000000 -#define PCI_SUBCLASS_DISPLAY_XGA 0x00010000 -#define PCI_SUBCLASS_DISPLAY_MISC 0x00800000 - -/* 0x04 multimedia subclasses */ -#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00000000 -#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x00010000 -#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x00800000 - -/* 0x05 memory subclasses */ -#define PCI_SUBCLASS_MEMORY_RAM 0x00000000 -#define PCI_SUBCLASS_MEMORY_FLASH 0x00010000 -#define PCI_SUBCLASS_MEMORY_MISC 0x00800000 - -/* 0x06 bridge subclasses */ -#define PCI_SUBCLASS_BRIDGE_HOST 0x00000000 -#define PCI_SUBCLASS_BRIDGE_ISA 0x00010000 -#define PCI_SUBCLASS_BRIDGE_EISA 0x00020000 -#define PCI_SUBCLASS_BRIDGE_MC 0x00030000 -#define PCI_SUBCLASS_BRIDGE_PCI 0x00040000 -#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x00050000 -#define PCI_SUBCLASS_BRIDGE_MISC 0x00800000 - -/* - * Mapping registers - */ -#define PCI_MAP_REG_START 0x10 -#define PCI_MAP_REG_END 0x28 - -#define PCI_MAP_MEMORY 0x00000000 -#define PCI_MAP_IO 0x00000001 - -#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000 -#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002 -#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004 -#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006 -#define PCI_MAP_MEMORY_CACHABLE 0x00000008 -#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0 - -/* - * Interrupt configuration register - */ -#define PCI_INTERRUPT_REG 0x3c - -#define PCI_INTERRUPT_PIN_MASK 0x0000ff00 -#define PCI_INTERRUPT_PIN_EXTRACT(x) ((((x) & PCI_INTERRUPT_PIN_MASK) >> 8) & 0xff) -#define PCI_INTERRUPT_PIN_NONE 0x00 -#define PCI_INTERRUPT_PIN_A 0x01 -#define PCI_INTERRUPT_PIN_B 0x02 -#define PCI_INTERRUPT_PIN_C 0x03 -#define PCI_INTERRUPT_PIN_D 0x04 - -#define PCI_INTERRUPT_LINE_MASK 0x000000ff -#define PCI_INTERRUPT_LINE_EXTRACT(x) ((((x) & PCI_INTERRUPT_LINE_MASK) >> 0) & 0xff) -#define PCI_INTERRUPT_LINE_INSERT(x,v) (((x) & ~PCI_INTERRUPT_LINE_MASK) | ((v) << 0)) - -#endif /* __PCI_REG_H__ */ diff --git a/sys/i386/pci/pcisupport.c b/sys/i386/pci/pcisupport.c deleted file mode 100644 index 21a25a5..0000000 --- a/sys/i386/pci/pcisupport.c +++ /dev/null @@ -1,397 +0,0 @@ -/************************************************************************** -** -** $Id: pcisupport.c,v 1.5 1994/10/25 18:45:19 se Exp $ -** -** Device driver for INTEL PCI chipsets. -** -** 386bsd / FreeBSD -** -**------------------------------------------------------------------------- -** -** Written for 386bsd and FreeBSD by -** wolf@dentaro.gun.de Wolfgang Stanglmeier -** se@mi.Uni-Koeln.de Stefan Esser -** -**------------------------------------------------------------------------- -** -** Copyright (c) 1994 Stefan Esser. All rights reserved. -** -** 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. 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 files -** -**========================================================== -*/ - -#include <sys/types.h> - -#include <i386/pci/pcireg.h> - -extern void printf(); - -extern int bootverbose; - - -/*--------------------------------------------------------- -** -** Intel chipsets for 486 / Pentium processor -** -**--------------------------------------------------------- -*/ - -static char* chipset_probe (pcici_t tag, pcidi_t type); -static void chipset_attach(pcici_t tag, int unit); -static u_long chipset_count; - -struct pci_driver chipset_device = { - chipset_probe, - chipset_attach, - &chipset_count -}; - -static char confread(pcici_t config_id, int port); - -struct condmsg { - unsigned char port; - unsigned char mask; - unsigned char value; - char flags; - char *text; -}; - -#define M_EQ 0 /* mask and return true if equal */ -#define M_NE 1 /* mask and return true if not equal */ -#define TRUE 2 /* don't read config, always true */ - -static char* chipset_probe (pcici_t tag, pcidi_t type) -{ - switch (type) { - case 0x04848086: - return ("intel 82378IB pci-isa bridge"); - case 0x04838086: - return ("intel 82424ZX cache dram controller"); - case 0x04828086: - return ("intel 82375EB pci-eisa bridge"); - case 0x04a38086: - return ("intel 82434LX pci cache memory controller"); - }; - return ((char*)0); -} - -struct condmsg conf82424zx[] = -{ - { 0x00, 0x00, 0x00, TRUE, "\tCPU: " }, - { 0x50, 0xe0, 0x00, M_EQ, "486DX" }, - { 0x50, 0xe0, 0x20, M_EQ, "486SX" }, - { 0x50, 0xe0, 0x40, M_EQ, "486DX2 or 486DX4" }, - { 0x50, 0xe0, 0x80, M_EQ, "Overdrive (writeback)" }, - - { 0x00, 0x00, 0x00, TRUE, ", bus=" }, - { 0x50, 0x03, 0x00, M_EQ, "25MHz" }, - { 0x50, 0x03, 0x01, M_EQ, "33MHz" }, - { 0x53, 0x01, 0x01, TRUE, ", CPU->Memory posting "}, - { 0x53, 0x01, 0x00, M_EQ, "OFF" }, - { 0x53, 0x01, 0x01, M_EQ, "ON" }, - - { 0x56, 0x30, 0x00, M_NE, "\n\tWarning:" }, - { 0x56, 0x20, 0x00, M_NE, " NO cache parity!" }, - { 0x56, 0x10, 0x00, M_NE, " NO DRAM parity!" }, - { 0x55, 0x04, 0x04, M_EQ, "\n\tWarning: refresh OFF! " }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tCache: " }, - { 0x52, 0x01, 0x00, M_EQ, "None" }, - { 0x52, 0xc1, 0x01, M_EQ, "64KB" }, - { 0x52, 0xc1, 0x41, M_EQ, "128KB" }, - { 0x52, 0xc1, 0x81, M_EQ, "256KB" }, - { 0x52, 0xc1, 0xc1, M_EQ, "512KB" }, - { 0x52, 0x03, 0x01, M_EQ, " writethrough" }, - { 0x52, 0x03, 0x03, M_EQ, " writeback" }, - - { 0x52, 0x01, 0x01, M_EQ, ", cache clocks=" }, - { 0x52, 0x05, 0x01, M_EQ, "3-1-1-1" }, - { 0x52, 0x05, 0x05, M_EQ, "2-1-1-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tDRAM:" }, - { 0x55, 0x43, 0x00, M_NE, " page mode" }, - { 0x55, 0x02, 0x02, M_EQ, " code fetch" }, - { 0x55, 0x43, 0x43, M_EQ, "," }, - { 0x55, 0x43, 0x42, M_EQ, " and" }, - { 0x55, 0x40, 0x40, M_EQ, " read" }, - { 0x55, 0x03, 0x03, M_EQ, " and" }, - { 0x55, 0x43, 0x41, M_EQ, " and" }, - { 0x55, 0x01, 0x01, M_EQ, " write" }, - { 0x55, 0x43, 0x00, M_NE, "," }, - - { 0x00, 0x00, 0x00, TRUE, " memory clocks=" }, - { 0x55, 0x20, 0x00, M_EQ, "X-2-2-2" }, - { 0x55, 0x20, 0x20, M_EQ, "X-1-2-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tCPU->PCI: posting " }, - { 0x53, 0x02, 0x00, M_NE, "ON" }, - { 0x53, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, ", burst mode " }, - { 0x54, 0x02, 0x00, M_NE, "ON" }, - { 0x54, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, "\n\tPCI->Memory: posting " }, - { 0x54, 0x01, 0x00, M_NE, "ON" }, - { 0x54, 0x01, 0x00, M_EQ, "OFF" }, - - { 0x00, 0x00, 0x00, TRUE, "\n" }, - -/* end marker */ - { 0 } -}; - -struct condmsg conf82434lx[] = -{ - { 0x00, 0x00, 0x00, TRUE, "\tCPU: " }, - { 0x50, 0xe3, 0x82, M_EQ, "Pentium, 60MHz" }, - { 0x50, 0xe3, 0x83, M_EQ, "Pentium, 66MHz" }, - { 0x50, 0xe3, 0xa2, M_EQ, "Pentium, 90MHz" }, - { 0x50, 0xe3, 0xa3, M_EQ, "Pentium, 100MHz" }, - { 0x50, 0xc2, 0x82, M_NE, "(unknown)" }, - { 0x50, 0x04, 0x00, M_EQ, " (primary cache OFF)" }, - - { 0x53, 0x01, 0x01, TRUE, ", CPU->Memory posting "}, - { 0x53, 0x01, 0x01, M_NE, "OFF" }, - { 0x53, 0x01, 0x01, M_EQ, "ON" }, - - { 0x53, 0x04, 0x00, M_NE, ", read around write"}, - - { 0x71, 0xc0, 0x00, M_NE, "\n\tWarning: NO cache parity!" }, - { 0x57, 0x20, 0x00, M_NE, "\n\tWarning: NO DRAM parity!" }, - { 0x55, 0x01, 0x01, M_EQ, "\n\tWarning: refresh OFF! " }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tCache: " }, - { 0x52, 0x01, 0x00, M_EQ, "None" }, - { 0x52, 0x81, 0x01, M_EQ, "" }, - { 0x52, 0xc1, 0x81, M_EQ, "256KB" }, - { 0x52, 0xc1, 0xc1, M_EQ, "512KB" }, - { 0x52, 0x03, 0x01, M_EQ, " writethrough" }, - { 0x52, 0x03, 0x03, M_EQ, " writeback" }, - - { 0x52, 0x01, 0x01, M_EQ, ", cache clocks=" }, - { 0x52, 0x20, 0x00, M_EQ, "3-2-2-2/4-2-2-2" }, - { 0x52, 0x20, 0x00, M_NE, "3-1-1-1" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tDRAM:" }, - { 0x57, 0x10, 0x00, M_EQ, " page mode" }, - - { 0x00, 0x00, 0x00, TRUE, " memory clocks=" }, - { 0x57, 0xc0, 0x00, M_EQ, "X-4-4-4 (70ns)" }, - { 0x57, 0xc0, 0x40, M_EQ, "X-4-4-4/X-3-3-3 (60ns)" }, - { 0x57, 0xc0, 0x80, M_EQ, "???" }, - { 0x57, 0xc0, 0xc0, M_EQ, "X-3-3-3 (50ns)" }, - - { 0x00, 0x00, 0x00, TRUE, "\n\tCPU->PCI: posting " }, - { 0x53, 0x02, 0x02, M_EQ, "ON" }, - { 0x53, 0x02, 0x00, M_EQ, "OFF" }, - { 0x00, 0x00, 0x00, TRUE, ", burst mode " }, - { 0x54, 0x02, 0x00, M_NE, "ON" }, - { 0x54, 0x02, 0x00, M_EQ, "OFF" }, - { 0x54, 0x04, 0x00, TRUE, ", PCI clocks=" }, - { 0x54, 0x04, 0x00, M_EQ, "2-2-2-2" }, - { 0x54, 0x04, 0x00, M_NE, "2-1-1-1" }, - { 0x00, 0x00, 0x00, TRUE, "\n\tPCI->Memory: posting " }, - { 0x54, 0x01, 0x00, M_NE, "ON" }, - { 0x54, 0x01, 0x00, M_EQ, "OFF" }, - - { 0x00, 0x00, 0x00, TRUE, "\n" }, - -/* end marker */ - { 0 } -}; - -static char confread (pcici_t config_id, int port) -{ - unsigned long portw = port & ~3; - unsigned long ports = (port - portw) << 3; - - unsigned long l = pci_conf_read (config_id, portw); - return (l >> ports); -} - -static void writeconfig(pcici_t config_id, struct condmsg *tbl) -{ - while (tbl->text) { - int cond = 0; - if (tbl->flags == TRUE) { - cond = 1; - } else { - unsigned char v = (unsigned char) confread(config_id, tbl->port); - switch (tbl->flags) { - case M_EQ: - if ((v & tbl->mask) == tbl->value) cond = 1; - break; - case M_NE: - if ((v & tbl->mask) != tbl->value) cond = 1; - break; - } - } - if (cond) printf ("%s", tbl->text); - tbl++; - } -} - -void chipset_attach(pcici_t config_id, int unit) -{ - if (bootverbose) { - switch (pci_conf_read (config_id, 0)) { - - case 0x04838086: - writeconfig (config_id, conf82424zx); - break; - case 0x04a38086: - writeconfig (config_id, conf82434lx); - break; - case 0x04848086: - case 0x04828086: - printf ("\t[40] %lx [50] %lx [54] %lx\n", - pci_conf_read (config_id, 0x40), - pci_conf_read (config_id, 0x50), - pci_conf_read (config_id, 0x54)); - break; - }; - } -} - -/*--------------------------------------------------------- -** -** Catchall driver for VGA devices -** -** -** By Garrett Wollman -** <wollman@halloran-eldar.lcs.mit.edu> -** -**--------------------------------------------------------- -*/ - -static char* vga_probe (pcici_t tag, pcidi_t type); -static void vga_attach(pcici_t tag, int unit); -static u_long vga_count; - -struct pci_driver vga_device = { - vga_probe, - vga_attach, - &vga_count -}; - -static char* vga_probe (pcici_t tag, pcidi_t type) -{ - int data = pci_conf_read(tag, PCI_CLASS_REG); - - switch (data & PCI_CLASS_MASK) { - - case PCI_CLASS_PREHISTORIC: - if ((data & PCI_SUBCLASS_MASK) - != PCI_SUBCLASS_PREHISTORIC_VGA) - break; - - case PCI_CLASS_DISPLAY: - return ("display device"); - }; - return ((char*)0); -} - -static void vga_attach(pcici_t tag, int unit) -{ -/* -** Breaks some systems. -** The assigned adresses _have_ to be announced to the console driver. -*/ -#if 0 - vm_offset_t va; - vm_offset_t pa; - int reg; - for (reg = PCI_MAP_REG_START; reg < PCI_MAP_REG_END; reg += 4) - (void) pci_map_mem (tag, reg, &va, &pa); -#endif -} - -/*--------------------------------------------------------- -** -** Hook for loadable pci drivers -** -**--------------------------------------------------------- -*/ - -static char* lkm_probe (pcici_t tag, pcidi_t type); -static void lkm_attach(pcici_t tag, int unit); -static u_long lkm_count; - -struct pci_driver lkm_device = { - lkm_probe, - lkm_attach, - &lkm_count -}; - -static char* lkm_probe (pcici_t tag, pcidi_t type) -{ - /* - ** Should try to load a matching driver. - ** XXX Not yet! - */ - return ((char*)0); -} - -static void lkm_attach(pcici_t tag, int unit) -{ -} - -/*--------------------------------------------------------- -** -** Devices to ignore -** -**--------------------------------------------------------- -*/ - -static char* ign_probe (pcici_t tag, pcidi_t type); -static void ign_attach(pcici_t tag, int unit); -static u_long ign_count; - -struct pci_driver ign_device = { - ign_probe, - ign_attach, - &ign_count -}; - -static char* ign_probe (pcici_t tag, pcidi_t type) -{ - switch (type) { - - case 0x10001042ul: /* wd */ - return (""); - - }; - return ((char*)0); -} - -static void ign_attach(pcici_t tag, int unit) -{ -} diff --git a/sys/kern/subr_rmap.c b/sys/kern/subr_rmap.c deleted file mode 100644 index a43899e..0000000 --- a/sys/kern/subr_rmap.c +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * from: @(#)subr_rmap.c 8.1 (Berkeley) 6/10/93 - * $Id$ - */ - -#include <sys/param.h> -#include <sys/map.h> -#include <sys/proc.h> - -void -rminit(a1, a2, a3, a4, a5) - struct map *a1; - long a2, a3; - char *a4; - int a5; -{ - - /* - * Body deleted. - */ - return; -} - -long -rmalloc(a1, a2) - struct map *a1; - long a2; -{ - - /* - * Body deleted. - */ - return (0); -} - -void -rmfree(a1, a2, a3) - struct map *a1; - long a2, a3; -{ - - /* - * Body deleted. - */ - return; -} diff --git a/sys/libkern/libkern.h b/sys/libkern/libkern.h deleted file mode 100644 index e32f72d..0000000 --- a/sys/libkern/libkern.h +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)libkern.h 8.1 (Berkeley) 6/10/93 - * $Id: libkern.h,v 1.5 1994/11/14 14:56:46 bde Exp $ - */ - -#include <sys/types.h> - -static inline int imax(int a, int b) { return (a > b ? a : b); } -static inline int imin(int a, int b) { return (a < b ? a : b); } -static inline long lmax(long a, long b) { return (a > b ? a : b); } -static inline long lmin(long a, long b) { return (a < b ? a : b); } -static inline u_int max(u_int a, u_int b) { return (a > b ? a : b); } -static inline u_int min(u_int a, u_int b) { return (a < b ? a : b); } -static inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); } -static inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } -static inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); } -static inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); } - -/* Prototypes for non-quad routines. */ -int bcmp __P((const void *, const void *, size_t)); -#ifndef HAVE_INLINE_FFS -int ffs __P((int)); -#endif -int locc __P((int, char *, u_int)); -u_long random __P((void)); -char *rindex __P((const char *, int)); -int scanc __P((u_int, u_char *, u_char *, int)); -int skpc __P((int, int, char *)); -char *strcat __P((char *, const char *)); -int strcmp __P((const char *, const char *)); -char *strcpy __P((char *, const char *)); -size_t strlen __P((const char *)); -int strncmp __P((const char *, const char *, size_t)); -char *strncpy __P((char *, const char *, size_t)); diff --git a/sys/libkern/strtol.c b/sys/libkern/strtol.c deleted file mode 100644 index 9c257da..0000000 --- a/sys/libkern/strtol.c +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <machine/limits.h> - - -/* - * Convert a string to a long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - * - * Slightly lobotomized for inclusion in libkern. - */ -long -strtol(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; -{ - register const char *s = nptr; - register unsigned long acc; - register int c; - register unsigned long cutoff; - register int neg = 0, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - do { - c = *s++; - } while (c == ' ' || c == '\t'); - if (c == '-') { - neg = 1; - c = *s++; - } else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; - cutlim = cutoff % (unsigned long)base; - cutoff /= (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) { - if (c >= '0' && c <= '9') - c -= '0'; - else if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) - c -= (c >= 'A' && c <= 'Z') ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = neg ? LONG_MIN : LONG_MAX; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} diff --git a/sys/miscfs/devfs/devfs_back.c b/sys/miscfs/devfs/devfs_back.c deleted file mode 100644 index 20a69e5..0000000 --- a/sys/miscfs/devfs/devfs_back.c +++ /dev/null @@ -1,467 +0,0 @@ - -/* - * Written by Julian Elischer (julian@DIALix.oz.au) - * - * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_back.c,v 1.4 1995/09/03 05:43:38 julian Exp $ - */ - -#include "param.h" -#include "systm.h" -#include "types.h" -#include "kernel.h" -#include "file.h" /* define FWRITE ... */ -#include "conf.h" -#include "stat.h" -#include "mount.h" -#include "vnode.h" -#include "malloc.h" -#include "dir.h" /* defines dirent structure */ -#include "devfsdefs.h" -#include "sys/devfsext.h" - - -SYSINIT(devfs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_sinit, NULL) - -devnm_p dev_root; /* root of the backing tree */ - -/* - * Set up the root directory node in the backing plane - * This is happenning before the vfs system has been - * set up yet, so be careful about what we reference.. - * Notice that the ops are by indirection.. as they haven't - * been set up yet! - */ -void devfs_sinit() /*proto*/ -{ - int retval; /* we will discard this */ - /* - * call the right routine at the right time with the right args.... - */ - retval = dev_add_node("root",NULL,DEV_DIR,NULL,&dev_root); - printf("DEVFS: ready for devices\n"); -} - -/***********************************************************************\ -* Given a starting node (0 for root) and a pathname, return the node * -* for the end item on the path. It MUST BE A DIRECTORY. If the 'CREATE' * -* option is true, then create any missing nodes in the path and create * -* and return the final node as well. * -* Generally, this MUST be the first function called by any module * -* as it also calls the initial setup code, in case it has never been * -* done yet. * -* This is used to set up a directory, before making nodes in it.. * -* * -* Warning: This function is RECURSIVE. * -* char *path, find this dir (err if not dir) * -* dn_p dirnode, starting point (0 = root) * -* int create, create path if not found * -* dn_p *dn_pp) where to return the node of the dir * -\***********************************************************************/ -int dev_finddir(char *orig_path, dn_p dirnode, int create, dn_p *dn_pp) /*proto*/ -{ - devnm_p devnmp; - char pathbuf[DEVMAXPATHSIZE]; - char *path; - char *name; - register char *cp; - int retval; - - - DBPRINT(("dev_finddir\n")); - if(!dirnode) dirnode = dev_root->dnp; - if(dirnode->type != DEV_DIR) return ENOTDIR; - if(strlen(orig_path) > (DEVMAXPATHSIZE - 1)) return ENAMETOOLONG; - path = pathbuf; - strcpy(path,orig_path); - while(*path == '/') path++; /* always absolute, skip leading / */ - /***************************************\ - * find the next segment of the name * - \***************************************/ - cp = name = path; - while((*cp != '/') && (*cp != 0)) - { - cp++; - } - /***********************************************\ - * Check to see if it's the last component * - \***********************************************/ - if(*cp) - { - path = cp + 1; /* path refers to the rest */ - *cp = 0; /* name is now a separate string */ - if(!(*path)) - { - path = (char *)0; /* was trailing slash */ - } - } - else - { - path = (char *)0; /* no more to do */ - } - - /***************************************\ - * Start scanning along the linked list * - \***************************************/ - devnmp = dirnode->by.Dir.dirlist; - while(devnmp && strcmp(devnmp->name,name)) - { - devnmp = devnmp->next; - } - if(devnmp) - { /* check it's a directory */ - if(devnmp->dnp->type != DEV_DIR) return ENOTDIR; - } - else - { - /***************************************\ - * The required element does not exist * - * So we will add it if asked to. * - \***************************************/ - if(!create) return ENOENT; - - if(retval = dev_add_node(name, dirnode ,DEV_DIR, - NULL, &devnmp)) - { - return retval; - } - } - if(path) /* decide whether to recurse more or return */ - { - return (dev_finddir(path,devnmp->dnp,create,dn_pp)); - } - else - { - *dn_pp = devnmp->dnp; - return 0; - } -} - -/***********************************************************************\ -* Add a new element to the devfs backing structure. * -* If we're creating a root node, then dirname is NULL * -\***********************************************************************/ -int dev_add_node(char *name, dn_p dirnode, int entrytype, union typeinfo *by, devnm_p *devnm_pp) /*proto*/ -{ - devnm_p devnmp; - devnm_p realthing; /* needed to create an alias */ - dn_p dnp; - int retval; - - DBPRINT(("dev_add_node\n")); - if(dirnode ) { - if(dirnode->type != DEV_DIR) return(ENOTDIR); - - retval = dev_finddir(name,dirnode,0,&dnp); /*don't create!*/ - dnp = NULL; /*just want the return code..*/ - if(retval != ENOENT) /* only acceptable answer */ - return(EEXIST); - } - /* - * make sure the name is legal - */ - if(strlen(name) > (DEVMAXNAMESIZE - 1)) return (ENAMETOOLONG); - /* - * Allocate and fill out a new backing node - */ - if(!(devnmp = (devnm_p)malloc(sizeof(devnm_t), - M_DEVFSBACK, M_NOWAIT))) - { - return ENOMEM; - } - bzero(devnmp,sizeof(devnm_t)); - if(!(dnp = (dn_p)malloc(sizeof(devnode_t), - M_DEVFSNODE, M_NOWAIT))) - { - free(devnmp,M_DEVFSBACK); - return ENOMEM; - } - bzero(dnp,sizeof(devnode_t)); - /* - * Link hte two together - * include the implicit link in the count of links to the devnode.. - * this stops it from being accidentally freed later. - */ - devnmp->dnp = dnp; - dnp->links = 1; /* implicit from our own name-node */ - - /* - * note the node type we are adding - * and set the creation times to NOW - * put in it's name - */ - strcpy(devnmp->name,name); - dnp->type = entrytype; - TIMEVAL_TO_TIMESPEC(&time,&(dnp->ctime)) - dnp->mtime = dnp->ctime; - dnp->atime = dnp->ctime; - - /* - * And set up a new 'clones' list (empty) - */ - devnmp->prev_frontp = &(devnmp->next_front); - - /* - * Check if we are making a root node.. - * (with no parent) - */ - if(dirnode) { - /* - * Put it on the END of the linked list of directory entries - */ - devnmp->parent = dirnode; - devnmp->prevp = dirnode->by.Dir.dirlast; - devnmp->next = *(devnmp->prevp); /* should be NULL */ /*right?*/ - *(devnmp->prevp) = devnmp; - dirnode->by.Dir.dirlast = &(devnmp->next); - dirnode->by.Dir.entrycount++; - } - /* - * return the answer - */ - switch(entrytype) { - case DEV_DIR: - /* - * As it's a directory, make sure it has a null entries list - */ - dnp->by.Dir.dirlast = - &(dnp->by.Dir.dirlist); - dnp->by.Dir.dirlist = (devnm_p)0; - if ( dirnode ) { - dnp->by.Dir.parent = (dn_p)dirnode; - } else { - /* root loops to self */ - dnp->by.Dir.parent = dnp; - } - dnp->by.Dir.parent->links++; /* account for .. */ - dnp->links++; /* for .*/ - dnp->by.Dir.myname = devnmp; - /* - * make sure that the ops associated with it are the ops - * that we use (by default) for directories - */ - dnp->ops = &devfs_vnodeop_p; - dnp->mode |= 0555; /* default perms */ - break; - case DEV_BDEV: - /* - * Make sure it has DEVICE type ops - * and device specific fields are correct - */ - dnp->ops = &dev_spec_vnodeop_p; - dnp->by.Bdev.bdevsw = by->Bdev.bdevsw; - dnp->by.Bdev.dev = by->Bdev.dev; - break; - case DEV_CDEV: - /* - * Make sure it has DEVICE type ops - * and device specific fields are correct - */ - dnp->ops = &dev_spec_vnodeop_p; - dnp->by.Cdev.cdevsw = by->Cdev.cdevsw; - dnp->by.Cdev.dev = by->Cdev.dev; - break; - case DEV_DDEV: - /* - * store the address of (the address of) the ops - * and the magic cookie to use with them - */ - dnp->by.Ddev.arg = by->Ddev.arg; - dnp->ops = by->Ddev.ops; - break; - - - case DEV_ALIAS: - /* - * point to the node we want to shadow - * Also store the fact we exist so that aliases - * can be deleted accuratly when the original node - * is deleted.. (i.e. when device is removed) - */ - realthing = by->Alias.realthing; - dnp->by.Alias.realthing = realthing; - dnp->by.Alias.next = realthing->as.back.aliases; - realthing->as.back.aliases = devnmp; - realthing->as.back.alias_count++; - break; - } - /* - * If we have a parent, then maybe we should duplicate - * ourselves onto any plane that the parent is on... - * Though this may be better handled elsewhere as - * it stops this routine from being used for front nodes - */ - if(dirnode) { - if(retval = devfs_add_fronts(dirnode->by.Dir.myname,devnmp)) - { - /*XXX*//* no idea what to do if it fails... */ - return retval; - } - } - - *devnm_pp = devnmp; - return 0 ; -} - -/*********************************************************************** - * remove all fronts to this dev and also it's aliases, - * Then remove this node. - * For now only allow DEVICE nodes to go.. XXX - * directory nodes are more complicated and may need more work.. - */ -int dev_remove(devnm_p devnmp) /*proto*/ -{ - devnm_p alias; - - DBPRINT(("dev_remove\n")); - /* - * Check the type of the node.. for now don't allow dirs - */ - switch(devnmp->dnp->type) - { - case DEV_BDEV: - case DEV_CDEV: - case DEV_DDEV: - case DEV_ALIAS: - case DEV_SLNK: - break; - case DEV_DIR: - default: - return(EINVAL); - } - /* - * Free each alias - */ - while ( devnmp->as.back.alias_count) - { - alias = devnmp->as.back.aliases; - devnmp->as.back.aliases = alias->dnp->by.Alias.next; - devnmp->as.back.alias_count--; - devfs_dn_free(alias->dnp); - free (alias, M_DEVFSBACK); - } - /* - * Now remove front items of the Main node itself - */ - devfs_remove_fronts(devnmp); - - /* - * now we should free the main node - */ - devfs_dn_free(devnmp->dnp); - free (devnmp, M_DEVFSBACK); - return 0; -} - -int dev_touch(devnm_p key) /* update the node for this dev */ /*proto*/ -{ - DBPRINT(("dev_touch\n")); - TIMEVAL_TO_TIMESPEC(&time,&(key->dnp->mtime)) - return 0; /*XXX*/ -} - -void devfs_dn_free(dn_p dnp) /*proto*/ -{ - if(dnp->links <= 0) - { - printf("devfs node reference count bogus\n"); - Debugger("devfs_dn_free"); - return; - } - if(--dnp->links == 0 ) - { - devfs_dropvnode(dnp); - free (dnp, M_DEVFSNODE); - } -} -/***********************************************************************\ -* UTILITY routine: * -* Return the major number for the cdevsw entry containing the given * -* address. * -\***********************************************************************/ -int get_cdev_major_num(caddr_t addr) /*proto*/ -{ - int index = 0; - - DBPRINT(("get_cdev_major_num\n")); - while (index < nchrdev) - { - if(((caddr_t)(cdevsw[index].d_open) == addr) - ||((caddr_t)(cdevsw[index].d_read) == addr) - ||((caddr_t)(cdevsw[index].d_ioctl) == addr)) - { - return index; - } - index++; - } - return -1; -} - -int get_bdev_major_num(caddr_t addr) /*proto*/ -{ - int index = 0; - - DBPRINT(("get_bdev_major_num\n")); - while (index < nblkdev) - { - if(((caddr_t)(bdevsw[index].d_open) == addr) - ||((caddr_t)(bdevsw[index].d_strategy) == addr) - ||((caddr_t)(bdevsw[index].d_ioctl) == addr)) - { - return index; - } - index++; - } - return -1; -} - -/***********************************************************************\ -* Add the named device entry into the given directory, and make it * -* The appropriate type... (called (sometimes indirectly) by drivers..) * -\***********************************************************************/ -void *dev_add(char *path, - char *name, - void *funct, - int minor, - int chrblk, - uid_t uid, - gid_t gid, - int perms) -{ - devnm_p new_dev; - dn_p dnp; /* devnode for parent directory */ - int retval; - int major ; - union typeinfo by; - - DBPRINT(("dev_add\n")); - retval = dev_finddir(path,NULL,1,&dnp); - if (retval) return 0; - switch(chrblk) - { - case DV_CHR: - major = get_cdev_major_num(funct); - by.Cdev.cdevsw = cdevsw + major; - by.Cdev.dev = makedev(major, minor); - if( dev_add_node(name, dnp, DEV_CDEV, - &by,&new_dev)) - return 0; - break; - case DV_BLK: - major = get_bdev_major_num(funct); - by.Bdev.bdevsw = bdevsw + major; - by.Bdev.dev = makedev(major, minor); - if( dev_add_node(name, dnp, DEV_BDEV, - &by, &new_dev)) - return 0; - break; - default: - return(0); - } - new_dev->dnp->gid = gid; - new_dev->dnp->uid = uid; - new_dev->dnp->mode |= perms; - return new_dev; -} - - - diff --git a/sys/miscfs/devfs/devfs_front.c b/sys/miscfs/devfs/devfs_front.c deleted file mode 100644 index a3d0255..0000000 --- a/sys/miscfs/devfs/devfs_front.c +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Written by Julian Elischer (julian@DIALix.oz.au) - * - * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_front.c,v 1.3 1995/04/20 07:42:41 julian Exp $ - * - */ - -#include "param.h" -#include "systm.h" -#include "kernel.h" -#include "file.h" /* define FWRITE ... */ -#include "conf.h" -#include "stat.h" -#include "mount.h" -#include "vnode.h" -#include "malloc.h" -#include "dir.h" /* defines dirent structure */ -#include "devfsdefs.h" - - - -/***********************************************************************\ -* Given a directory backing node, and a child backing node, add the * -* appropriate front nodes to the front nodes of the directory to * -* represent the child node to the user * -* * -* on failure, front nodes will either be correct or not exist for each * -* front dir, however dirs completed will not be stripped of completed * -* frontnodes on failure of a later parent frontnode * -* * -\***********************************************************************/ -int devfs_add_fronts(devnm_p parent,devnm_p child) /*proto*/ -{ - devnm_p newfp; - devnm_p falias; - - DBPRINT((" devfs_add_fronts\n")); - /***********************************************\ - * Find the frontnodes of the parent node * - \***********************************************/ - for (falias = parent->next_front; falias; falias = falias->next_front) - { - if(dev_findfront(falias->dnp,child->name)) - { - printf("Device %s not created, already exists\n", - child->name); - continue; - } - if( dev_mk_front(falias->dnp,child,&newfp,NULL)) - { - printf("Device %s: allocation failed\n", - child->name); - continue; - } - - } - return(0); /* for now always succeed */ -} - -/***************************************************************\ -* Search down the linked list off a front dir to find "name" * -* return the dn_p for that node. -\***************************************************************/ -dn_p dev_findfront(dn_p dir,char *name) /*proto*/ -{ - devnm_p newfp; - DBPRINT((" dev_findfront(%s)\n",name)); - if(dir->type != DEV_DIR) return 0;/*XXX*/ /* printf?*/ - - if(name[0] == '.') - { - if(name[1] == 0) - { - return dir; - } - if((name[1] == '.') && (name[2] == 0)) - { - if(dir->by.Dir.parent == dir) /* root? */ - return dir; - else - return dir->by.Dir.parent; - } - } - newfp = dir->by.Dir.dirlist; - while(newfp) - { - if(!(strcmp(name,newfp->name))) - break; - newfp = newfp->next; - } - if(newfp) - return newfp->dnp; - else - return (dn_p)0; -} - -/***************************************************************\ -* Create and link in a new front element.. * -* Parent can be 0 for a root node * -* Not presently usable to make a symlink XXX * -* Must teach this to handle where there is no back node * -* maybe split into two bits? * -\***************************************************************/ -int dev_mk_front(dn_p parent,devnm_p back,devnm_p *devnm_pp , struct devfsmount *dvm) /*proto*/ -{ - devnm_p newfp; - struct devfsmount *dmt; - devnm_p newback; - devnm_p newfront; - int error; - dn_p dnp; - - DBPRINT((" dev_mk_front\n")); - if(parent && (parent->type != DEV_DIR)) return EINVAL; - /*XXX*/ /* printf?*/ - if(!(newfp = malloc(sizeof(devnm_t),M_DEVFSFRONT,M_NOWAIT))) - { - return(ENOMEM); - } - bzero(newfp,sizeof(*newfp)); - strcpy(newfp->name,back->name); - - /*******************************************************\ - * If we are creating an alias, Then we need to find the * - * real object's file_node. (It must pre-exist) * - * this means that aliases have no front nodes... * - * In effect ALIAS back nodes are just place markers * - \*******************************************************/ - if(back->dnp->type == DEV_ALIAS) - { - back = back->dnp->by.Alias.realthing; - } - - /* - * either use the existing devnode or make our own, - * depending on if we are a dev or a dir. - */ - switch(back->dnp->type) { - case DEV_BDEV: - case DEV_CDEV: - case DEV_DDEV: - dnp = newfp->dnp = back->dnp; - newfp->dnp->links++; /* wherever it is.....*/ - break; - case DEV_DIR: - dnp = newfp->dnp = malloc(sizeof(devnode_t), - M_DEVFSNODE,M_NOWAIT); - if(!(dnp)) - { - free(newfp,M_DEVFSFRONT); - return ENOMEM; - } - /* - * we have two options.. bcopy and reset some items, - * or bzero and reset or copy some items... - */ - bcopy(back->dnp,newfp->dnp,sizeof(devnode_t)); - dnp->links = 1; /* EXTRA from '.' */ - dnp->links++; /* wherever it is.....*/ - dnp->by.Dir.dirlast = - &dnp->by.Dir.dirlist; - dnp->by.Dir.dirlist = NULL; - dnp->by.Dir.entrycount = 0; - dnp->vn = NULL; - dnp->vn_id = 0; - break; - case DEV_SLNK: /* should never happen XXX (hmm might)*/ - default: - printf("unknown DEV type\n"); - return EINVAL; - } - /*******************************************************\ - * Put it in the parent's directory list (at the end). * - \*******************************************************/ - if(parent) - { - newfp->next = *parent->by.Dir.dirlast; - newfp->prevp = parent->by.Dir.dirlast; - *parent->by.Dir.dirlast = newfp; - parent->by.Dir.dirlast = &newfp->next; - parent->by.Dir.entrycount++; - newfp->dnp->dvm = parent->dvm; /* XXX bad for devs */ - if(back->dnp->type == DEV_DIR) - { - newfp->dnp->by.Dir.parent - = parent; - parent->links++; /* only dirs have '..'*/ - } - parent->len += strlen(newfp->name) + 8;/*ok, ok?*/ - } else { - /* - * it's the root node, put in the dvm - * and link it to itself... - * we know it's a DIR - */ - dnp->by.Dir.parent = newfp->dnp; - dnp->links++; /* extra for '..'*/ - dnp->dvm = dvm; - } - - /* - * not accounted for in the link counts.. - * only used to get from the front name entries - * to the total length of the names - * which is stored in the parent's devnode - */ - newfp->parent = parent; /* is NULL for root */ - /*******************************************************\ - * Put it in the appropriate back/front list too. * - \*******************************************************/ - newfp->next_front = *back->prev_frontp; - newfp->prev_frontp = back->prev_frontp; - *back->prev_frontp = newfp; - back->prev_frontp = &(newfp->next_front); - back->frontcount++; - newfp->as.front.realthing = back; - - /* - * If it is a directory, then recurse down all the other - * subnodes in it.... - */ - if ( newfp->dnp->type == DEV_DIR) - { - for(newback = back->dnp->by.Dir.dirlist; - newback; newback = newback->next) - { - if(error = dev_mk_front(newfp->dnp, - newback, &newfront, NULL)) - { - return error; - } - } - } - *devnm_pp = newfp; - return(0); -} - -/* - * duplicate the backing tree into a tree of nodes hung off the - * mount point given as the argument. Do this by - * calling dev_mk_front() which recurses all the way - * up the tree.. - */ -int devfs_make_plane(struct devfsmount *devfs_mp_p) /*proto*/ -{ - devnm_p parent; - devnm_p new; - devnm_p realthing; - int error; - - DBPRINT((" devfs_make_plane\n")); - realthing = dev_root; - if(error = dev_mk_front(0, realthing,&new, devfs_mp_p)) - { - return error; - } - devfs_mp_p->plane_root = new; - - return error; -} - -void devfs_free_plane(struct devfsmount *devfs_mp_p) /*proto*/ -{ - devnm_p devfp; - - DBPRINT((" devfs_free_plane\n")); - devfp = devfs_mp_p->plane_root; - if(devfp) dev_free_front(devfp); -} - -/* - * Remove all the front nodes associated with a backing node - */ -void devfs_remove_fronts(devnm_p devbp) /*proto*/ -{ - while(devbp->next_front) - { - dev_free_front(devbp->next_front); - } -} -/***************************************************************\ -* Free a front node (and any below it of it's a directory node) * -\***************************************************************/ -void dev_free_front(devnm_p devfp) /*proto*/ -{ - dn_p parent = devfp->parent; - devnm_p back; - - DBPRINT((" dev_free_front\n")); - if(devfp->dnp->type == DEV_DIR) - { - while(devfp->dnp->by.Dir.dirlist) - { - dev_free_front(devfp->dnp->by.Dir.dirlist); - } - /* - * drop the reference counts on our and our parent's - * nodes for "." and ".." (root has ".." -> "." ) - */ - devfs_dn_free(devfp->dnp); /* account for '.' */ - devfs_dn_free(devfp->dnp->by.Dir.parent); /* and '..' */ - } - /* - * unlink ourselves from the directory on this plane - */ - if(parent) /* if not fs root */ - { - if( *devfp->prevp = devfp->next)/* yes, assign */ - { - devfp->next->prevp = devfp->prevp; - } - else - { - parent->by.Dir.dirlast - = devfp->prevp; - } - parent->by.Dir.entrycount--; - parent->len -= strlen(devfp->name); - } - /* - * If the node has a backing pointer we need to free ourselves - * from that.. - * Remember that we may not HAVE a backing node. - */ - if (back = devfp->as.front.realthing) /* yes an assign */ - { - if( *devfp->prev_frontp = devfp->next_front)/* yes, assign */ - { - devfp->next_front->prev_frontp = devfp->prev_frontp; - } - else - { - back->prev_frontp = devfp->prev_frontp; - } - back->frontcount--; - } - /***************************************************************\ - * If the front node has it's own devnode structure, * - * then free it. * - \***************************************************************/ - devfs_dn_free(devfp->dnp); - free(devfp,M_DEVFSFRONT); - return; -} - -/*******************************************************\ -* Theoretically this could be called for any kind of * -* vnode, however in practice it must be a DEVFS vnode * -\*******************************************************/ -int devfs_vntodn(struct vnode *vn_p, dn_p *dn_pp) /*proto*/ -{ - -DBPRINT((" vntodn ")); - if(vn_p->v_tag != VT_DEVFS) - { - printf("bad-tag "); - Debugger("bad-tag "); - return(EINVAL); - } - if(vn_p->v_usecount == 0) - { - printf("not locked! "); - } - if((vn_p->v_type == VBAD) || (vn_p->v_type == VNON)) - { - printf("bad-type "); - return(EINVAL); - } - *dn_pp = (dn_p)vn_p->v_data; - - return(0); -} - -/***************************************************************\ -* given a dev_node, find the appropriate vnode if one is already* -* associated, or get a new one an associate it with the dev_node* -* need to check about vnode references.. should we increment it?* -\***************************************************************/ -int devfs_dntovn(dn_p dnp, struct vnode **vn_pp) /*proto*/ -{ - struct vnode *vn_p, *nvp; - int error = 0; - - vn_p = dnp->vn; -DBPRINT(("dntovn ")); - if( vn_p) - { - if(vn_p->v_id != dnp->vn_id) - { - printf("bad-id "); - goto skip; - } - if(vn_p->v_tag != VT_DEVFS) - { - printf("bad-tag "); - goto skip; - } - if(vn_p->v_op != *(dnp->ops)) - { - printf("bad-ops "); - goto skip; - } - if((dn_p)(vn_p->v_data) != dnp) - { - printf("bad-rev_link "); - goto skip; - } - if(vn_p->v_type != VNON) - { - vget(vn_p,0/*lockflag ?*/); /*XXX*/ - *vn_pp = vn_p; - return(0); - } - else - { - printf("bad-type"); - } -skip: - vn_p = (struct vnode *) 0; - } - if(!(error = getnewvnode(VT_DEVFS, - dnp->dvm->mount, - *(dnp->ops), - &vn_p))) - { - dnp->vn = vn_p; - dnp->vn_id = vn_p->v_id; - *vn_pp = vn_p; -DBPRINT(("(New vnode)")); - switch(dnp->type) - { - case DEV_SLNK: - break; - case DEV_DIR: - if(dnp->by.Dir.parent == dnp) - { - vn_p->v_flag |= VROOT; - } - vn_p->v_type = VDIR; - break; - case DEV_BDEV: - vn_p->v_type = VBLK; - if (nvp = checkalias(vn_p, - dnp->by.Bdev.dev, - (struct mount *)0)) - { - vput(vn_p); - vn_p = nvp; - } - break; - case DEV_CDEV: - vn_p->v_type = VCHR; - if (nvp = checkalias(vn_p, - dnp->by.Cdev.dev, - (struct mount *)0)) - { - vput(vn_p); - vn_p = nvp; - } - break; - case DEV_DDEV: - break; - } - if ( vn_p) - { - vn_p->v_mount = dnp->dvm->mount;/* XXX Duplicated */ - *vn_pp = vn_p; - vn_p->v_data = (void *)dnp; - } - else - { - error = EINVAL; - } - } - return error; -} diff --git a/sys/sys/map.h b/sys/sys/map.h deleted file mode 100644 index 7c793a3..0000000 --- a/sys/sys/map.h +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * @(#)map.h 8.3 (Berkeley) 1/26/94 - * $Id: map.h,v 1.3 1994/08/21 04:41:50 paul Exp $ - */ - -#ifndef _SYS_MAP_H_ -#define _SYS_MAP_H_ - -struct map { - struct mapent *m_limit; /* address of last slot in map */ - char *m_name; /* name of resource, for messages */ -}; - -struct mapent { - long m_size; /* size of this segment of the map */ - long m_addr; /* start of segment */ -}; - -#ifdef KERNEL -#define ARGMAPSIZE 16 -struct map *kmemmap, *mbmap, *swapmap; -int nswapmap; -#endif - -#endif diff --git a/sys/sys/trace.h b/sys/sys/trace.h deleted file mode 100644 index 85b4759..0000000 --- a/sys/sys/trace.h +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)trace.h 8.1 (Berkeley) 6/2/93 - * $Id: trace.h,v 1.2 1994/08/02 07:53:52 davidg Exp $ - */ - -#ifndef _SYS_TRACE_H_ -#define _SYS_TRACE_H_ - -/* - * File system buffer tracing points; all trace <pack(dev, size), bn> - */ -#define TR_BREADHIT 0 /* buffer read found in cache */ -#define TR_BREADMISS 1 /* buffer read not in cache */ -#define TR_BWRITE 2 /* buffer written */ -#define TR_BREADHITRA 3 /* buffer read-ahead found in cache */ -#define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */ -#define TR_XFODMISS 5 /* exe fod read */ -#define TR_XFODHIT 6 /* exe fod read */ -#define TR_BRELSE 7 /* brelse */ -#define TR_BREALLOC 8 /* expand/contract a buffer */ - -/* - * Memory allocator trace points; all trace the amount of memory involved - */ -#define TR_MALL 10 /* memory allocated */ - -/* - * Paging trace points: all are <vaddr, pid> - */ -#define TR_INTRANS 20 /* page intransit block */ -#define TR_EINTRANS 21 /* page intransit wait done */ -#define TR_FRECLAIM 22 /* reclaim from free list */ -#define TR_RECLAIM 23 /* reclaim from loop */ -#define TR_XSFREC 24 /* reclaim from free list instead of drum */ -#define TR_XIFREC 25 /* reclaim from free list instead of fsys */ -#define TR_WAITMEM 26 /* wait for memory in pagein */ -#define TR_EWAITMEM 27 /* end memory wait in pagein */ -#define TR_ZFOD 28 /* zfod page fault */ -#define TR_EXFOD 29 /* exec fod page fault */ -#define TR_VRFOD 30 /* vread fod page fault */ -#define TR_CACHEFOD 31 /* fod in file system cache */ -#define TR_SWAPIN 32 /* drum page fault */ -#define TR_PGINDONE 33 /* page in done */ -#define TR_SWAPIO 34 /* swap i/o request arrives */ - -/* - * System call trace points. - */ -#define TR_VADVISE 40 /* vadvise occurred with <arg, pid> */ - -/* - * Miscellaneous - */ -#define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */ - -/* - * This defines the size of the trace flags array. - */ -#define TR_NFLAGS 100 /* generous */ - -#define TRCSIZ 4096 - -/* - * Specifications of the vtrace() system call, which takes one argument. - */ -#define VTRACE 64+51 - -#define VTR_DISABLE 0 /* set a trace flag to 0 */ -#define VTR_ENABLE 1 /* set a trace flag to 1 */ -#define VTR_VALUE 2 /* return value of a trace flag */ -#define VTR_UALARM 3 /* set alarm to go off (sig 16) */ - /* in specified number of hz */ -#define VTR_STAMP 4 /* user specified stamp */ - -#ifdef KERNEL -#ifdef TRACE -struct proc *traceproc; -int tracewhich, tracebuf[TRCSIZ]; -u_int tracex; -char traceflags[TR_NFLAGS]; -#define pack(v,b) (((v)->v_mount->mnt_stat.f_fsid.val[0])<<16)|(b) -#define trace(a,b,c) { \ - if (traceflags[a]) \ - trace1(a,b,c); \ -} -#else -#define trace(a,b,c) -#endif -#endif - -#endif diff --git a/sys/ufs/ufs/lockf.h b/sys/ufs/ufs/lockf.h deleted file mode 100644 index f549166..0000000 --- a/sys/ufs/ufs/lockf.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Scooter Morris at Genentech Inc. - * - * 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. - * - * @(#)lockf.h 8.1 (Berkeley) 6/11/93 - * $Id$ - */ - -/* - * The lockf structure is a kernel structure which contains the information - * associated with a byte range lock. The lockf structures are linked into - * the inode structure. Locks are sorted by the starting byte of the lock for - * efficiency. - */ -struct lockf { - short lf_flags; /* Lock semantics: F_POSIX, F_FLOCK, F_WAIT */ - short lf_type; /* Lock type: F_RDLCK, F_WRLCK */ - off_t lf_start; /* The byte # of the start of the lock */ - off_t lf_end; /* The byte # of the end of the lock (-1=EOF)*/ - caddr_t lf_id; /* The id of the resource holding the lock */ - struct inode *lf_inode; /* Back pointer to the inode */ - struct lockf *lf_next; /* A pointer to the next lock on this inode */ - struct lockf *lf_block; /* The list of blocked locks */ -}; - -/* Maximum length of sleep chains to traverse to try and detect deadlock. */ -#define MAXDEPTH 50 - -__BEGIN_DECLS -void lf_addblock __P((struct lockf *, struct lockf *)); -int lf_clearlock __P((struct lockf *)); -int lf_findoverlap __P((struct lockf *, - struct lockf *, int, struct lockf ***, struct lockf **)); -struct lockf * - lf_getblock __P((struct lockf *)); -int lf_getlock __P((struct lockf *, struct flock *)); -int lf_setlock __P((struct lockf *)); -void lf_split __P((struct lockf *, struct lockf *)); -void lf_wakelock __P((struct lockf *)); -__END_DECLS - -#ifdef LOCKF_DEBUG -extern int lockf_debug; - -__BEGIN_DECLS -void lf_print __P((char *, struct lockf *)); -void lf_printlist __P((char *, struct lockf *)); -__END_DECLS -#endif diff --git a/sys/ufs/ufs/ufs_lockf.c b/sys/ufs/ufs/ufs_lockf.c deleted file mode 100644 index bdc22cd..0000000 --- a/sys/ufs/ufs/ufs_lockf.c +++ /dev/null @@ -1,708 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Scooter Morris at Genentech Inc. - * - * 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. - * - * @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94 - * $Id$ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/file.h> -#include <sys/proc.h> -#include <sys/vnode.h> -#include <sys/malloc.h> -#include <sys/fcntl.h> - -#include <ufs/ufs/lockf.h> -#include <ufs/ufs/quota.h> -#include <ufs/ufs/inode.h> -#include <ufs/ufs/ufs_extern.h> - -/* - * This variable controls the maximum number of processes that will - * be checked in doing deadlock detection. - */ -int maxlockdepth = MAXDEPTH; - -#ifdef LOCKF_DEBUG -int lockf_debug = 0; -#endif - -#define NOLOCKF (struct lockf *)0 -#define SELF 0x1 -#define OTHERS 0x2 - -/* - * Set a byte-range lock. - */ -int -lf_setlock(lock) - register struct lockf *lock; -{ - register struct lockf *block; - struct inode *ip = lock->lf_inode; - struct lockf **prev, *overlap, *ltmp; - static char lockstr[] = "lockf"; - int ovcase, priority, needtolink, error; - -#ifdef LOCKF_DEBUG - if (lockf_debug & 1) - lf_print("lf_setlock", lock); -#endif /* LOCKF_DEBUG */ - - /* - * Set the priority - */ - priority = PLOCK; - if (lock->lf_type == F_WRLCK) - priority += 4; - priority |= PCATCH; - /* - * Scan lock list for this file looking for locks that would block us. - */ - while (block = lf_getblock(lock)) { - /* - * Free the structure and return if nonblocking. - */ - if ((lock->lf_flags & F_WAIT) == 0) { - FREE(lock, M_LOCKF); - return (EAGAIN); - } - /* - * We are blocked. Since flock style locks cover - * the whole file, there is no chance for deadlock. - * For byte-range locks we must check for deadlock. - * - * Deadlock detection is done by looking through the - * wait channels to see if there are any cycles that - * involve us. MAXDEPTH is set just to make sure we - * do not go off into neverland. - */ - if ((lock->lf_flags & F_POSIX) && - (block->lf_flags & F_POSIX)) { - register struct proc *wproc; - register struct lockf *waitblock; - int i = 0; - - /* The block is waiting on something */ - wproc = (struct proc *)block->lf_id; - while (wproc->p_wchan && - (wproc->p_wmesg == lockstr) && - (i++ < maxlockdepth)) { - waitblock = (struct lockf *)wproc->p_wchan; - /* Get the owner of the blocking lock */ - waitblock = waitblock->lf_next; - if ((waitblock->lf_flags & F_POSIX) == 0) - break; - wproc = (struct proc *)waitblock->lf_id; - if (wproc == (struct proc *)lock->lf_id) { - free(lock, M_LOCKF); - return (EDEADLK); - } - } - } - /* - * For flock type locks, we must first remove - * any shared locks that we hold before we sleep - * waiting for an exclusive lock. - */ - if ((lock->lf_flags & F_FLOCK) && - lock->lf_type == F_WRLCK) { - lock->lf_type = F_UNLCK; - (void) lf_clearlock(lock); - lock->lf_type = F_WRLCK; - } - /* - * Add our lock to the blocked list and sleep until we're free. - * Remember who blocked us (for deadlock detection). - */ - lock->lf_next = block; - lf_addblock(block, lock); -#ifdef LOCKF_DEBUG - if (lockf_debug & 1) { - lf_print("lf_setlock: blocking on", block); - lf_printlist("lf_setlock", block); - } -#endif /* LOCKF_DEBUG */ - if (error = tsleep((caddr_t)lock, priority, lockstr, 0)) { - /* - * Delete ourselves from the waiting to lock list. - */ - for (block = lock->lf_next; - block != NOLOCKF; - block = block->lf_block) { - if (block->lf_block != lock) - continue; - block->lf_block = block->lf_block->lf_block; - break; - } - /* - * If we did not find ourselves on the list, but - * are still linked onto a lock list, then something - * is very wrong. - */ - if (block == NOLOCKF && lock->lf_next != NOLOCKF) - panic("lf_setlock: lost lock"); - free(lock, M_LOCKF); - return (error); - } - } - /* - * No blocks!! Add the lock. Note that we will - * downgrade or upgrade any overlapping locks this - * process already owns. - * - * Skip over locks owned by other processes. - * Handle any locks that overlap and are owned by ourselves. - */ - prev = &ip->i_lockf; - block = ip->i_lockf; - needtolink = 1; - for (;;) { - if (ovcase = lf_findoverlap(block, lock, SELF, &prev, &overlap)) - block = overlap->lf_next; - /* - * Six cases: - * 0) no overlap - * 1) overlap == lock - * 2) overlap contains lock - * 3) lock contains overlap - * 4) overlap starts before lock - * 5) overlap ends after lock - */ - switch (ovcase) { - case 0: /* no overlap */ - if (needtolink) { - *prev = lock; - lock->lf_next = overlap; - } - break; - - case 1: /* overlap == lock */ - /* - * If downgrading lock, others may be - * able to acquire it. - */ - if (lock->lf_type == F_RDLCK && - overlap->lf_type == F_WRLCK) - lf_wakelock(overlap); - overlap->lf_type = lock->lf_type; - FREE(lock, M_LOCKF); - lock = overlap; /* for debug output below */ - break; - - case 2: /* overlap contains lock */ - /* - * Check for common starting point and different types. - */ - if (overlap->lf_type == lock->lf_type) { - free(lock, M_LOCKF); - lock = overlap; /* for debug output below */ - break; - } - if (overlap->lf_start == lock->lf_start) { - *prev = lock; - lock->lf_next = overlap; - overlap->lf_start = lock->lf_end + 1; - } else - lf_split(overlap, lock); - lf_wakelock(overlap); - break; - - case 3: /* lock contains overlap */ - /* - * If downgrading lock, others may be able to - * acquire it, otherwise take the list. - */ - if (lock->lf_type == F_RDLCK && - overlap->lf_type == F_WRLCK) { - lf_wakelock(overlap); - } else { - ltmp = lock->lf_block; - lock->lf_block = overlap->lf_block; - lf_addblock(lock, ltmp); - } - /* - * Add the new lock if necessary and delete the overlap. - */ - if (needtolink) { - *prev = lock; - lock->lf_next = overlap->lf_next; - prev = &lock->lf_next; - needtolink = 0; - } else - *prev = overlap->lf_next; - free(overlap, M_LOCKF); - continue; - - case 4: /* overlap starts before lock */ - /* - * Add lock after overlap on the list. - */ - lock->lf_next = overlap->lf_next; - overlap->lf_next = lock; - overlap->lf_end = lock->lf_start - 1; - prev = &lock->lf_next; - lf_wakelock(overlap); - needtolink = 0; - continue; - - case 5: /* overlap ends after lock */ - /* - * Add the new lock before overlap. - */ - if (needtolink) { - *prev = lock; - lock->lf_next = overlap; - } - overlap->lf_start = lock->lf_end + 1; - lf_wakelock(overlap); - break; - } - break; - } -#ifdef LOCKF_DEBUG - if (lockf_debug & 1) { - lf_print("lf_setlock: got the lock", lock); - lf_printlist("lf_setlock", lock); - } -#endif /* LOCKF_DEBUG */ - return (0); -} - -/* - * Remove a byte-range lock on an inode. - * - * Generally, find the lock (or an overlap to that lock) - * and remove it (or shrink it), then wakeup anyone we can. - */ -int -lf_clearlock(unlock) - register struct lockf *unlock; -{ - struct inode *ip = unlock->lf_inode; - register struct lockf *lf = ip->i_lockf; - struct lockf *overlap, **prev; - int ovcase; - - if (lf == NOLOCKF) - return (0); -#ifdef LOCKF_DEBUG - if (unlock->lf_type != F_UNLCK) - panic("lf_clearlock: bad type"); - if (lockf_debug & 1) - lf_print("lf_clearlock", unlock); -#endif /* LOCKF_DEBUG */ - prev = &ip->i_lockf; - while (ovcase = lf_findoverlap(lf, unlock, SELF, &prev, &overlap)) { - /* - * Wakeup the list of locks to be retried. - */ - lf_wakelock(overlap); - - switch (ovcase) { - - case 1: /* overlap == lock */ - *prev = overlap->lf_next; - FREE(overlap, M_LOCKF); - break; - - case 2: /* overlap contains lock: split it */ - if (overlap->lf_start == unlock->lf_start) { - overlap->lf_start = unlock->lf_end + 1; - break; - } - lf_split(overlap, unlock); - overlap->lf_next = unlock->lf_next; - break; - - case 3: /* lock contains overlap */ - *prev = overlap->lf_next; - lf = overlap->lf_next; - free(overlap, M_LOCKF); - continue; - - case 4: /* overlap starts before lock */ - overlap->lf_end = unlock->lf_start - 1; - prev = &overlap->lf_next; - lf = overlap->lf_next; - continue; - - case 5: /* overlap ends after lock */ - overlap->lf_start = unlock->lf_end + 1; - break; - } - break; - } -#ifdef LOCKF_DEBUG - if (lockf_debug & 1) - lf_printlist("lf_clearlock", unlock); -#endif /* LOCKF_DEBUG */ - return (0); -} - -/* - * Check whether there is a blocking lock, - * and if so return its process identifier. - */ -int -lf_getlock(lock, fl) - register struct lockf *lock; - register struct flock *fl; -{ - register struct lockf *block; - -#ifdef LOCKF_DEBUG - if (lockf_debug & 1) - lf_print("lf_getlock", lock); -#endif /* LOCKF_DEBUG */ - - if (block = lf_getblock(lock)) { - fl->l_type = block->lf_type; - fl->l_whence = SEEK_SET; - fl->l_start = block->lf_start; - if (block->lf_end == -1) - fl->l_len = 0; - else - fl->l_len = block->lf_end - block->lf_start + 1; - if (block->lf_flags & F_POSIX) - fl->l_pid = ((struct proc *)(block->lf_id))->p_pid; - else - fl->l_pid = -1; - } else { - fl->l_type = F_UNLCK; - } - return (0); -} - -/* - * Walk the list of locks for an inode and - * return the first blocking lock. - */ -struct lockf * -lf_getblock(lock) - register struct lockf *lock; -{ - struct lockf **prev, *overlap, *lf = lock->lf_inode->i_lockf; - int ovcase; - - prev = &lock->lf_inode->i_lockf; - while (ovcase = lf_findoverlap(lf, lock, OTHERS, &prev, &overlap)) { - /* - * We've found an overlap, see if it blocks us - */ - if ((lock->lf_type == F_WRLCK || overlap->lf_type == F_WRLCK)) - return (overlap); - /* - * Nope, point to the next one on the list and - * see if it blocks us - */ - lf = overlap->lf_next; - } - return (NOLOCKF); -} - -/* - * Walk the list of locks for an inode to - * find an overlapping lock (if any). - * - * NOTE: this returns only the FIRST overlapping lock. There - * may be more than one. - */ -int -lf_findoverlap(lf, lock, type, prev, overlap) - register struct lockf *lf; - struct lockf *lock; - int type; - struct lockf ***prev; - struct lockf **overlap; -{ - off_t start, end; - - *overlap = lf; - if (lf == NOLOCKF) - return (0); -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - lf_print("lf_findoverlap: looking for overlap in", lock); -#endif /* LOCKF_DEBUG */ - start = lock->lf_start; - end = lock->lf_end; - while (lf != NOLOCKF) { - if (((type & SELF) && lf->lf_id != lock->lf_id) || - ((type & OTHERS) && lf->lf_id == lock->lf_id)) { - *prev = &lf->lf_next; - *overlap = lf = lf->lf_next; - continue; - } -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - lf_print("\tchecking", lf); -#endif /* LOCKF_DEBUG */ - /* - * OK, check for overlap - * - * Six cases: - * 0) no overlap - * 1) overlap == lock - * 2) overlap contains lock - * 3) lock contains overlap - * 4) overlap starts before lock - * 5) overlap ends after lock - */ - if ((lf->lf_end != -1 && start > lf->lf_end) || - (end != -1 && lf->lf_start > end)) { - /* Case 0 */ -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - printf("no overlap\n"); -#endif /* LOCKF_DEBUG */ - if ((type & SELF) && end != -1 && lf->lf_start > end) - return (0); - *prev = &lf->lf_next; - *overlap = lf = lf->lf_next; - continue; - } - if ((lf->lf_start == start) && (lf->lf_end == end)) { - /* Case 1 */ -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - printf("overlap == lock\n"); -#endif /* LOCKF_DEBUG */ - return (1); - } - if ((lf->lf_start <= start) && - (end != -1) && - ((lf->lf_end >= end) || (lf->lf_end == -1))) { - /* Case 2 */ -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - printf("overlap contains lock\n"); -#endif /* LOCKF_DEBUG */ - return (2); - } - if (start <= lf->lf_start && - (end == -1 || - (lf->lf_end != -1 && end >= lf->lf_end))) { - /* Case 3 */ -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - printf("lock contains overlap\n"); -#endif /* LOCKF_DEBUG */ - return (3); - } - if ((lf->lf_start < start) && - ((lf->lf_end >= start) || (lf->lf_end == -1))) { - /* Case 4 */ -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - printf("overlap starts before lock\n"); -#endif /* LOCKF_DEBUG */ - return (4); - } - if ((lf->lf_start > start) && - (end != -1) && - ((lf->lf_end > end) || (lf->lf_end == -1))) { - /* Case 5 */ -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - printf("overlap ends after lock\n"); -#endif /* LOCKF_DEBUG */ - return (5); - } - panic("lf_findoverlap: default"); - } - return (0); -} - -/* - * Add a lock to the end of the blocked list. - */ -void -lf_addblock(lock, blocked) - struct lockf *lock; - struct lockf *blocked; -{ - register struct lockf *lf; - - if (blocked == NOLOCKF) - return; -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) { - lf_print("addblock: adding", blocked); - lf_print("to blocked list of", lock); - } -#endif /* LOCKF_DEBUG */ - if ((lf = lock->lf_block) == NOLOCKF) { - lock->lf_block = blocked; - return; - } - while (lf->lf_block != NOLOCKF) - lf = lf->lf_block; - lf->lf_block = blocked; - return; -} - -/* - * Split a lock and a contained region into - * two or three locks as necessary. - */ -void -lf_split(lock1, lock2) - register struct lockf *lock1; - register struct lockf *lock2; -{ - register struct lockf *splitlock; - -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) { - lf_print("lf_split", lock1); - lf_print("splitting from", lock2); - } -#endif /* LOCKF_DEBUG */ - /* - * Check to see if spliting into only two pieces. - */ - if (lock1->lf_start == lock2->lf_start) { - lock1->lf_start = lock2->lf_end + 1; - lock2->lf_next = lock1; - return; - } - if (lock1->lf_end == lock2->lf_end) { - lock1->lf_end = lock2->lf_start - 1; - lock2->lf_next = lock1->lf_next; - lock1->lf_next = lock2; - return; - } - /* - * Make a new lock consisting of the last part of - * the encompassing lock - */ - MALLOC(splitlock, struct lockf *, sizeof *splitlock, M_LOCKF, M_WAITOK); - bcopy((caddr_t)lock1, (caddr_t)splitlock, sizeof *splitlock); - splitlock->lf_start = lock2->lf_end + 1; - splitlock->lf_block = NOLOCKF; - lock1->lf_end = lock2->lf_start - 1; - /* - * OK, now link it in - */ - splitlock->lf_next = lock1->lf_next; - lock2->lf_next = splitlock; - lock1->lf_next = lock2; -} - -/* - * Wakeup a blocklist - */ -void -lf_wakelock(listhead) - struct lockf *listhead; -{ - register struct lockf *blocklist, *wakelock; - - blocklist = listhead->lf_block; - listhead->lf_block = NOLOCKF; - while (blocklist != NOLOCKF) { - wakelock = blocklist; - blocklist = blocklist->lf_block; - wakelock->lf_block = NOLOCKF; - wakelock->lf_next = NOLOCKF; -#ifdef LOCKF_DEBUG - if (lockf_debug & 2) - lf_print("lf_wakelock: awakening", wakelock); -#endif /* LOCKF_DEBUG */ - wakeup((caddr_t)wakelock); - } -} - -#ifdef LOCKF_DEBUG -/* - * Print out a lock. - */ -void -lf_print(tag, lock) - char *tag; - register struct lockf *lock; -{ - - printf("%s: lock 0x%lx for ", tag, lock); - if (lock->lf_flags & F_POSIX) - printf("proc %d", ((struct proc *)(lock->lf_id))->p_pid); - else - printf("id 0x%x", lock->lf_id); - printf(" in ino %d on dev <%d, %d>, %s, start %d, end %d", - lock->lf_inode->i_number, - major(lock->lf_inode->i_dev), - minor(lock->lf_inode->i_dev), - lock->lf_type == F_RDLCK ? "shared" : - lock->lf_type == F_WRLCK ? "exclusive" : - lock->lf_type == F_UNLCK ? "unlock" : - "unknown", lock->lf_start, lock->lf_end); - if (lock->lf_block) - printf(" block 0x%x\n", lock->lf_block); - else - printf("\n"); -} - -void -lf_printlist(tag, lock) - char *tag; - struct lockf *lock; -{ - register struct lockf *lf; - - printf("%s: Lock list for ino %d on dev <%d, %d>:\n", - tag, lock->lf_inode->i_number, - major(lock->lf_inode->i_dev), - minor(lock->lf_inode->i_dev)); - for (lf = lock->lf_inode->i_lockf; lf; lf = lf->lf_next) { - printf("\tlock 0x%lx for ", lf); - if (lf->lf_flags & F_POSIX) - printf("proc %d", ((struct proc *)(lf->lf_id))->p_pid); - else - printf("id 0x%x", lf->lf_id); - printf(", %s, start %d, end %d", - lf->lf_type == F_RDLCK ? "shared" : - lf->lf_type == F_WRLCK ? "exclusive" : - lf->lf_type == F_UNLCK ? "unlock" : - "unknown", lf->lf_start, lf->lf_end); - if (lf->lf_block) - printf(" block 0x%x\n", lf->lf_block); - else - printf("\n"); - } -} -#endif /* LOCKF_DEBUG */ diff --git a/sys/vm/vm_user.c b/sys/vm/vm_user.c deleted file mode 100644 index 104e814..0000000 --- a/sys/vm/vm_user.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. - * - * 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. - * - * from: @(#)vm_user.c 8.2 (Berkeley) 1/12/94 - * - * - * Copyright (c) 1987, 1990 Carnegie-Mellon University. - * All rights reserved. - * - * Authors: Avadis Tevanian, Jr., Michael Wayne Young - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * $Id: vm_user.c,v 1.8 1995/02/20 18:08:18 davidg Exp $ - */ - -/* - * User-exported virtual memory functions. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> - -#include <vm/vm.h> - -simple_lock_data_t vm_alloc_lock; /* XXX */ - -/* - * Similar to vm_allocate but assigns an explicit pager. - */ -int -vm_allocate_with_pager(map, addr, size, anywhere, pager, poffset, internal) - register vm_map_t map; - register vm_offset_t *addr; - register vm_size_t size; - boolean_t anywhere; - vm_pager_t pager; - vm_offset_t poffset; - boolean_t internal; -{ - register vm_object_t object; - register int result; - - if (map == NULL) - return (KERN_INVALID_ARGUMENT); - - *addr = trunc_page(*addr); - size = round_page(size); - - /* - * Lookup the pager/paging-space in the object cache. If it's not - * there, then create a new object and cache it. - */ - object = vm_object_lookup(pager); - if (object == NULL) { - object = vm_object_allocate(size); - /* - * From Mike Hibler: "unnamed anonymous objects should never - * be on the hash list ... For now you can just change - * vm_allocate_with_pager to not do vm_object_enter if this is - * an internal object ..." - */ - if (!internal) - vm_object_enter(object, pager); - } - if (internal) - object->flags |= OBJ_INTERNAL; - else { - object->flags &= ~OBJ_INTERNAL; - cnt.v_nzfod -= atop(size); - } - - result = vm_map_find(map, object, poffset, addr, size, anywhere); - if (result != KERN_SUCCESS) - vm_object_deallocate(object); - else if (pager != NULL) - vm_object_setpager(object, pager, (vm_offset_t) 0, TRUE); - return (result); -} diff --git a/sys/vm/vm_vmio.c b/sys/vm/vm_vmio.c deleted file mode 100644 index 8450c92..0000000 --- a/sys/vm/vm_vmio.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 1994 John S. Dyson - * All rights reserved. - * - * 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 immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * John S. Dyson. - * 4. Modifications may be freely made to this file if the above conditions - * are met. - * - * $Id$ - */ -/* - * THIS IS PRELIMINARY, BUGGY AND NON-WORKING CODE - * WHEN THIS NOTICE IS REMOVED -- IT WILL WORK... :-). - * - * THINGS TO DO: - * COMMENTS, THE SYSTEM ALMOST RUNS WITH IT. THIS IS CURRENTLY MEANT - * ONLY AS A PLACEHOLDER!!! - */ -#define VMIO -#include "param.h" -#include "proc.h" -#include "malloc.h" -#include "vm_param.h" -#include "vm.h" -#include "lock.h" -#include "queue.h" -#include "vm_prot.h" -#include "vm_object.h" -#include "vm_page.h" -#include "vnode_pager.h" -#include "vm_map.h" -#include "vm_pageout.h" -#include "vnode.h" -#include "uio.h" -#include "mount.h" - -/* #include "buf.h" */ -#include "miscfs/specfs/specdev.h" -/* #include "vmio.h" */ - -int vnode_pager_initialized; -extern vm_map_t pager_map; - -struct buf * getpbuf(); -void relpbuf(struct buf *bp); - -/* - * map an object into kva - * return 1 if all are in memory, and 0 if any are fake. - */ -int -vmio_alloc_pages( vm_object_t object, vm_offset_t start, - vm_offset_t size, vm_page_t *ms) { - - int pagecount; - vm_page_t m; - int i,j; - int s; - vm_offset_t kva; - struct buf *bp; - int ioneeded=0; - - pagecount = size / PAGE_SIZE; - - for(i=0;i<pagecount;i++) { - vm_page_t m; - m = vm_page_lookup( object, start + i * PAGE_SIZE); - if( m) { - /* - * See if something else has already gotten this page - */ - if( m->busy || (m->flags & (PG_VMIO|PG_BUSY))) { - /* - * Something has the page, so we have to - * release all the pages we've gotten to - * this point, wait for the page to unbusy - * and then start over. - */ - int j; - for(j = 0; j < i; j++) { - vm_page_t n; - n = ms[j]; - if( n) { - /* - * unbusy the page. - */ - PAGE_WAKEUP(n); - if( n->flags & PG_FAKE) - vm_page_free(n); - } - } - m->flags |= PG_WANTED; - tsleep((caddr_t)m, PVM, "vngpwt", 0); - return -1; - } - m->flags |= PG_REFERENCED; - } else { - m = (vm_page_t) vm_page_alloc( object, - start + i * PAGE_SIZE); - if( !m) { - VM_WAIT; - for(j=0;j<i;j++) { - vm_page_t n; - n = ms[j]; - if( n) { - PAGE_WAKEUP(n); - if( n->flags & PG_FAKE) - vm_page_free(n); - } - } - return -1; - } - } - ms[i] = m; - } - /* - * hold the pages and assign them to the mapping - */ - for(i=0;i<pagecount;i++) { - m = ms[i]; - vm_page_hold(m); - if( m->flags & PG_FAKE) - ++ioneeded; - - vm_page_deactivate(m); - if( (m->flags & PG_ACTIVE) == 0) - vm_page_activate(m); - m->flags |= PG_VMIO; - m->flags &= ~PG_BUSY; - ++m->act_count; - pmap_page_protect( VM_PAGE_TO_PHYS(m), VM_PROT_READ); - } - return ioneeded; - -} - -void -vmio_rawiodone( struct buf *bp) { - int s; - int i; - vm_object_t object; - vm_page_t m; - - if( bp->b_bufsize != bp->b_bcount) - bzero( bp->b_data + bp->b_bcount, bp->b_bufsize - bp->b_bcount); - printf("rawdone: (blk: %d, count: %d)\n", - bp->b_blkno, bp->b_bcount); - s = splbio(); - object = bp->b_pages[0]->object; - for( i = 0; i < bp->b_npages; i++) { - m = bp->b_pages[i]; - if( m) { - --m->busy; - if( m->busy == 0) { - m->flags |= PG_CLEAN; - m->flags &= ~(PG_LAUNDRY|PG_FAKE); - PAGE_WAKEUP(m); - } - } else { - panic("vmio_rawiodone: page is gone!!!"); - } - } - HOLDRELE(bp->b_vp); - relpbuf(bp); - --object->paging_in_progress; - if( object->paging_in_progress == 0) - wakeup((caddr_t)object); - splx(s); - return; -} - -void -vmio_get_pager(struct vnode *vp) { - if( vp->v_type == VREG) { - vm_object_t object; - vm_pager_t pager; - if((vp->v_vmdata == NULL) || (vp->v_flag & VVMIO) == 0) { - pager = (vm_pager_t) vnode_pager_alloc(vp, 0, 0, 0); - object = (vm_object_t) vp->v_vmdata; - if( object->pager != pager) - panic("vmio_get_pager: pager/object mismatch"); - (void) vm_object_lookup( pager); - pager_cache( object, TRUE); - vp->v_flag |= VVMIO; - } else { - object = (vm_object_t) vp->v_vmdata; - pager = object->pager; - if( pager == NULL) { - panic("vmio_get_pager: pager missing"); - } - (void) vm_object_lookup( pager); - } - } -} - -void -vmio_free_pager( struct vnode *vp) { - if( vp->v_vmdata == NULL) - panic("vmio_free_pager: object missing"); - vm_object_deallocate( (vm_object_t) vp->v_vmdata); -} - -void -vmio_aread( struct buf *lbp) { - struct vnode *vp, *dp; - vm_object_t object; - vm_offset_t offset; - vm_offset_t size; - vm_offset_t off; - int forcemore; - int runp; - int s; - - s = splbio(); - vp = lbp->b_vp; - object = (vm_object_t) vp->v_vmdata; - offset = trunc_page(lbp->b_lblkno * vp->v_mount->mnt_stat.f_iosize); - size = round_page(lbp->b_bcount); - forcemore = 0; - printf("queueing read: iosize: %d, b_lblkno: %d, offset: %d, size: %d:", - vp->v_mount->mnt_stat.f_iosize, - lbp->b_lblkno, offset, size); - - for(off = 0; off < size; ) { - vm_offset_t curoff; - int pgidx, pgcnt, i; - struct buf *bp; - pgidx = off / PAGE_SIZE; - if( !forcemore) { - while( (off < size) && - (lbp->b_pages[pgidx]->flags & PG_FAKE) == 0) { - off = trunc_page(off) + PAGE_SIZE; - pgidx += 1; - } - } - if( off >= size) - break; - bp = getpbuf(); - - ++object->paging_in_progress; - - curoff = offset + off; - VOP_BMAP( vp, curoff / vp->v_mount->mnt_stat.f_iosize, - &dp, &bp->b_blkno, &runp); - - bp->b_bcount = (runp + 1) * vp->v_mount->mnt_stat.f_iosize; - if( off + bp->b_bcount > size) - bp->b_bcount = size - off; - bp->b_bufsize = round_page(bp->b_bcount); - - pgcnt = bp->b_bufsize / PAGE_SIZE; - for(i=0;i<pgcnt;i++) { - ++lbp->b_pages[pgidx+i]->busy; - bp->b_pages[i] = lbp->b_pages[pgidx+i]; - bp->b_pages[i]->flags |= PG_BUSY; - } - bp->b_npages = pgcnt; - pmap_qenter((vm_offset_t) bp->b_data, &lbp->b_pages[pgidx], pgcnt); - bp->b_data += curoff - trunc_page(curoff); - off += bp->b_bcount; - if( off & (PAGE_SIZE - 1)) - forcemore = 1; - else - forcemore = 0; - /* - * round up physical size for real devices - */ - if( dp->v_type == VBLK || dp->v_type == VCHR) { - bp->b_bcount = (bp->b_bcount + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); - } - /* - * and map the pages to be read into the kva - */ - VHOLD(vp); - /* build a minimal buffer header */ - bp->b_flags = B_BUSY | B_READ | B_CALL | B_ASYNC; - bp->b_iodone = vmio_rawiodone; - /* B_PHYS is not set, but it is nice to fill this in */ - bp->b_proc = curproc; - bp->b_rcred = bp->b_wcred = bp->b_proc->p_ucred; - if( bp->b_rcred != NOCRED) - crhold(bp->b_rcred); - if( bp->b_wcred != NOCRED) - crhold(bp->b_wcred); - bp->b_lblkno = bp->b_blkno; -/* bp->b_vp = dp; */ - bgetvp( dp, bp); - printf(" p: (blk: %d, coff: %d, off: %d, count: %d)", - bp->b_blkno, curoff, off, bp->b_bcount); - - /* Should be a BLOCK or character DEVICE if we get here */ - bp->b_dev = dp->v_rdev; - - /* do the input */ - VOP_STRATEGY(bp); - } - printf("\n"); - splx(s); -} - -int -vmio_getblk( struct buf *bp) { - struct vnode *vp; - vm_object_t object; - vm_offset_t offset; - vm_offset_t size; - vm_page_t ms[(MAXBSIZE + PAGE_SIZE - 1)/PAGE_SIZE]; - int rtval; - - vp = bp->b_vp; - if( (object = (vm_object_t) vp->v_vmdata) == NULL) - panic("vmio_build_bp: object missing"); - - offset = trunc_page(bp->b_lblkno * vp->v_mount->mnt_stat.f_iosize); - size = round_page(bp->b_bcount); - printf("vmio_getblk: off:%d(0x%x) blk: %d, size: %d", - offset, offset, bp->b_lblkno, size); - - bp->b_flags &= ~B_CACHE; - if( (rtval = vmio_alloc_pages( object, offset, size, ms)) == 0) { - bp->b_flags |= B_CACHE; - printf("(cached)\n"); - } else { - printf("(ioneeded:%d)\n", rtval); - } - - if( rtval < 0) { - printf("vmio_getblk: vmio_alloc_pages busy\n"); - return 0; - } - - bp->b_npages = size / PAGE_SIZE; - pmap_qenter((vm_offset_t) bp->b_data, ms, bp->b_npages); - bp->b_flags |= B_VMIO; - bp->b_bufsize = size; - bcopy( ms, bp->b_pages, bp->b_npages * sizeof(vm_page_t)); - return 1; -} - -int -vmio_biowait( struct buf *lbp) { - int i; - int s; - printf("vmio_biowait -->"); -restart: - s = splbio(); - for(i=lbp->b_npages-1;i >= 0; --i) { - if( lbp->b_pages[i]->busy || (lbp->b_pages[i]->flags & PG_BUSY)) { - lbp->b_pages[i]->flags |= PG_WANTED; - printf(" waiting on page %d of xfer at %d, flags: 0x%x\n", - i, lbp->b_blkno, lbp->b_pages[i]->flags); - tsleep( (caddr_t) lbp->b_pages[i], PVM, "vbiowt", 0); - splx(s); - goto restart; - } - } - splx(s); - printf("vmio_biowait: finished\n"); - return 1; -} - -void -vmio_brelse( struct buf *lbp) { - int i; - int nfullpages = lbp->b_bcount / PAGE_SIZE; - pmap_qremove((vm_offset_t) lbp->b_data, lbp->b_npages); - for(i=0;i<lbp->b_npages;i++) { - if( (i < nfullpages) && ((lbp->b_flags & B_DELWRI) == 0)) - lbp->b_pages[i]->flags |= PG_CLEAN; - if( lbp->b_flags & B_DELWRI) - lbp->b_pages[i]->flags &= ~PG_CLEAN; - lbp->b_pages[i]->flags &= ~PG_VMIO; - vm_page_unhold(lbp->b_pages[i]); - PAGE_WAKEUP(lbp->b_pages[i]); - } - lbp->b_flags &= ~B_VMIO; - lbp->b_flags |= B_INVAL; - lbp->b_bufsize = 0; -} |