summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2000-09-25 21:57:54 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2000-09-25 21:57:54 +0000
commit2641b0c407077fa8c3032d87d15ac6a103b0ed1b (patch)
tree97e7da54e454c6cb23ca18813708e5c453e8de9f /sys
parent57293fdc2cfdd01d9d5e32d0e5243669d7e006e9 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/linux/syscalls.conf12
-rw-r--r--sys/compat/linux/linux_file.c859
-rw-r--r--sys/compat/linux/linux_ioctl.h437
-rw-r--r--sys/compat/linux/linux_ipc.c447
-rw-r--r--sys/compat/linux/linux_ipc.h48
-rw-r--r--sys/compat/linux/linux_mib.c231
-rw-r--r--sys/compat/linux/linux_mib.h43
-rw-r--r--sys/compat/linux/linux_misc.c1120
-rw-r--r--sys/compat/linux/linux_signal.h39
-rw-r--r--sys/compat/linux/linux_socket.c904
-rw-r--r--sys/compat/linux/linux_stats.c377
-rw-r--r--sys/compat/linux/linux_util.c186
-rw-r--r--sys/compat/linux/linux_util.h95
-rw-r--r--sys/contrib/ipfilter/netinet/ip_log.c507
-rw-r--r--sys/contrib/ipfilter/netinet/ip_proxy.c452
-rw-r--r--sys/dev/aac/aac_tables.h117
-rw-r--r--sys/dev/aic7xxx/aic7xxx.c2
-rw-r--r--sys/dev/amr/amr_cam.c452
-rw-r--r--sys/dev/amr/amr_tables.h110
-rw-r--r--sys/dev/awi/README60
-rw-r--r--sys/dev/awi/am79c930.c450
-rw-r--r--sys/dev/awi/am79c930reg.h126
-rw-r--r--sys/dev/awi/am79c930var.h79
-rw-r--r--sys/dev/awi/awireg.h460
-rw-r--r--sys/dev/awi/awivar.h222
-rw-r--r--sys/dev/cs/if_csreg.h544
-rw-r--r--sys/dev/ic/hd64570.h372
-rw-r--r--sys/dev/mii/pnaphy.c282
-rw-r--r--sys/dev/mly/mly_cam.c513
-rw-r--r--sys/dev/mly/mly_pci.c590
-rw-r--r--sys/dev/mly/mly_tables.h335
-rw-r--r--sys/dev/mly/mlyreg.h1270
-rw-r--r--sys/dev/mly/mlyvar.h423
-rw-r--r--sys/dev/rp/rpreg.h1015
-rw-r--r--sys/dev/sound/pci/fm801.c728
-rw-r--r--sys/dev/sound/pci/maestro.c1188
-rw-r--r--sys/dev/sound/pci/maestro_reg.h345
-rw-r--r--sys/dev/sound/pci/via82c686.c689
-rw-r--r--sys/dev/sound/pci/via82c686.h108
-rw-r--r--sys/dev/usb/rio500_usb.h58
-rw-r--r--sys/modules/ip6fw/Makefile17
-rw-r--r--sys/modules/mly/Makefile11
-rw-r--r--sys/modules/pcn/Makefile8
-rw-r--r--sys/modules/sound/driver/fm801/Makefile8
-rw-r--r--sys/modules/sound/driver/maestro/Makefile8
-rw-r--r--sys/modules/sound/driver/via82c686/Makefile8
-rw-r--r--sys/sys/kobj.h169
47 files changed, 1 insertions, 16523 deletions
diff --git a/sys/alpha/linux/syscalls.conf b/sys/alpha/linux/syscalls.conf
deleted file mode 100644
index 01e258801231d..0000000000000
--- a/sys/alpha/linux/syscalls.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-# $FreeBSD$
-sysnames="/dev/null"
-sysproto="linux_proto.h"
-sysproto_h=_LINUX_SYSPROTO_H_
-syshdr="linux_syscall.h"
-syssw="linux_sysent.c"
-sysmk="/dev/null"
-syshide="/dev/null"
-syscallprefix="LINUX_SYS_"
-switchname="linux_sysent"
-namesname="linux_syscallnames"
-sysvec="\n"
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
deleted file mode 100644
index 66e80c60a68b7..0000000000000
--- a/sys/compat/linux/linux_file.c
+++ /dev/null
@@ -1,859 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/lock.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/dirent.h>
-#include <sys/conf.h>
-#include <sys/tty.h>
-
-#include <machine/../linux/linux.h>
-#include <machine/../linux/linux_proto.h>
-#include <compat/linux/linux_util.h>
-
-int
-linux_creat(struct proc *p, struct linux_creat_args *args)
-{
- struct open_args /* {
- char *path;
- int flags;
- int mode;
- } */ bsd_open_args;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTCREAT(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): creat(%s, %d)\n",
- p->p_pid, args->path, args->mode);
-#endif
- bsd_open_args.path = args->path;
- bsd_open_args.mode = args->mode;
- bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC;
- return open(p, &bsd_open_args);
-}
-
-int
-linux_open(struct proc *p, struct linux_open_args *args)
-{
- struct open_args /* {
- char *path;
- int flags;
- int mode;
- } */ bsd_open_args;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
-
- if (args->flags & LINUX_O_CREAT)
- CHECKALTCREAT(p, &sg, args->path);
- else
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): open(%s, 0x%x, 0x%x)\n",
- p->p_pid, args->path, args->flags, args->mode);
-#endif
- bsd_open_args.flags = 0;
- if (args->flags & LINUX_O_RDONLY)
- bsd_open_args.flags |= O_RDONLY;
- if (args->flags & LINUX_O_WRONLY)
- bsd_open_args.flags |= O_WRONLY;
- if (args->flags & LINUX_O_RDWR)
- bsd_open_args.flags |= O_RDWR;
- if (args->flags & LINUX_O_NDELAY)
- bsd_open_args.flags |= O_NONBLOCK;
- if (args->flags & LINUX_O_APPEND)
- bsd_open_args.flags |= O_APPEND;
- if (args->flags & LINUX_O_SYNC)
- bsd_open_args.flags |= O_FSYNC;
- if (args->flags & LINUX_O_NONBLOCK)
- bsd_open_args.flags |= O_NONBLOCK;
- if (args->flags & LINUX_FASYNC)
- bsd_open_args.flags |= O_ASYNC;
- if (args->flags & LINUX_O_CREAT)
- bsd_open_args.flags |= O_CREAT;
- if (args->flags & LINUX_O_TRUNC)
- bsd_open_args.flags |= O_TRUNC;
- if (args->flags & LINUX_O_EXCL)
- bsd_open_args.flags |= O_EXCL;
- if (args->flags & LINUX_O_NOCTTY)
- bsd_open_args.flags |= O_NOCTTY;
- bsd_open_args.path = args->path;
- bsd_open_args.mode = args->mode;
-
- error = open(p, &bsd_open_args);
- if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
- SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
- struct filedesc *fdp = p->p_fd;
- struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
-
- if (fp->f_type == DTYPE_VNODE)
- fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
- }
-#ifdef DEBUG
- printf("Linux-emul(%d): open returns error %d\n",
- p->p_pid, error);
-#endif
- return error;
-}
-
-struct linux_flock {
- short l_type;
- short l_whence;
- linux_off_t l_start;
- linux_off_t l_len;
- linux_pid_t l_pid;
-};
-
-static void
-linux_to_bsd_flock(struct linux_flock *linux_flock, struct flock *bsd_flock)
-{
- switch (linux_flock->l_type) {
- case LINUX_F_RDLCK:
- bsd_flock->l_type = F_RDLCK;
- break;
- case LINUX_F_WRLCK:
- bsd_flock->l_type = F_WRLCK;
- break;
- case LINUX_F_UNLCK:
- bsd_flock->l_type = F_UNLCK;
- break;
- default:
- bsd_flock->l_type = -1;
- break;
- }
- bsd_flock->l_whence = linux_flock->l_whence;
- bsd_flock->l_start = (off_t)linux_flock->l_start;
- bsd_flock->l_len = (off_t)linux_flock->l_len;
- bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
-}
-
-static void
-bsd_to_linux_flock(struct flock *bsd_flock, struct linux_flock *linux_flock)
-{
- switch (bsd_flock->l_type) {
- case F_RDLCK:
- linux_flock->l_type = LINUX_F_RDLCK;
- break;
- case F_WRLCK:
- linux_flock->l_type = LINUX_F_WRLCK;
- break;
- case F_UNLCK:
- linux_flock->l_type = LINUX_F_UNLCK;
- break;
- }
- linux_flock->l_whence = bsd_flock->l_whence;
- linux_flock->l_start = (linux_off_t)bsd_flock->l_start;
- linux_flock->l_len = (linux_off_t)bsd_flock->l_len;
- linux_flock->l_pid = (linux_pid_t)bsd_flock->l_pid;
-}
-
-int
-linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
-{
- int error, result;
- struct fcntl_args /* {
- int fd;
- int cmd;
- int arg;
- } */ fcntl_args;
- struct linux_flock linux_flock;
- struct flock *bsd_flock;
- caddr_t sg;
-
- sg = stackgap_init();
- bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock));
-
-#ifdef DEBUG
- printf("Linux-emul(%d): fcntl(%d, %08x, *)\n",
- p->p_pid, args->fd, args->cmd);
-#endif
- fcntl_args.fd = args->fd;
-
- switch (args->cmd) {
- case LINUX_F_DUPFD:
- fcntl_args.cmd = F_DUPFD;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETFD:
- fcntl_args.cmd = F_GETFD;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_SETFD:
- fcntl_args.cmd = F_SETFD;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETFL:
- fcntl_args.cmd = F_GETFL;
- error = fcntl(p, &fcntl_args);
- result = p->p_retval[0];
- p->p_retval[0] = 0;
- if (result & O_RDONLY) p->p_retval[0] |= LINUX_O_RDONLY;
- if (result & O_WRONLY) p->p_retval[0] |= LINUX_O_WRONLY;
- if (result & O_RDWR) p->p_retval[0] |= LINUX_O_RDWR;
- if (result & O_NDELAY) p->p_retval[0] |= LINUX_O_NONBLOCK;
- if (result & O_APPEND) p->p_retval[0] |= LINUX_O_APPEND;
- if (result & O_FSYNC) p->p_retval[0] |= LINUX_O_SYNC;
- if (result & O_ASYNC) p->p_retval[0] |= LINUX_FASYNC;
- return error;
-
- case LINUX_F_SETFL:
- fcntl_args.arg = 0;
- if (args->arg & LINUX_O_NDELAY) fcntl_args.arg |= O_NONBLOCK;
- if (args->arg & LINUX_O_APPEND) fcntl_args.arg |= O_APPEND;
- if (args->arg & LINUX_O_SYNC) fcntl_args.arg |= O_FSYNC;
- if (args->arg & LINUX_FASYNC) fcntl_args.arg |= O_ASYNC;
- fcntl_args.cmd = F_SETFL;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETLK:
- if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock,
- sizeof(struct linux_flock))))
- return error;
- linux_to_bsd_flock(&linux_flock, bsd_flock);
- fcntl_args.cmd = F_GETLK;
- fcntl_args.arg = (int)bsd_flock;
- error = fcntl(p, &fcntl_args);
- if (error)
- return error;
- bsd_to_linux_flock(bsd_flock, &linux_flock);
- return copyout((caddr_t)&linux_flock, (caddr_t)args->arg,
- sizeof(struct linux_flock));
-
- case LINUX_F_SETLK:
- if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock,
- sizeof(struct linux_flock))))
- return error;
- linux_to_bsd_flock(&linux_flock, bsd_flock);
- fcntl_args.cmd = F_SETLK;
- fcntl_args.arg = (int)bsd_flock;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_SETLKW:
- if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock,
- sizeof(struct linux_flock))))
- return error;
- linux_to_bsd_flock(&linux_flock, bsd_flock);
- fcntl_args.cmd = F_SETLKW;
- fcntl_args.arg = (int)bsd_flock;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETOWN:
- fcntl_args.cmd = F_GETOWN;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_SETOWN:
- fcntl_args.cmd = F_SETOWN;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
- }
- return EINVAL;
-}
-
-int
-linux_lseek(struct proc *p, struct linux_lseek_args *args)
-{
-
- struct lseek_args /* {
- int fd;
- int pad;
- off_t offset;
- int whence;
- } */ tmp_args;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): lseek(%d, %ld, %d)\n",
- (long)p->p_pid, args->fdes, args->off, args->whence);
-#endif
- tmp_args.fd = args->fdes;
- tmp_args.offset = (off_t)args->off;
- tmp_args.whence = args->whence;
- error = lseek(p, &tmp_args);
- return error;
-}
-
-int
-linux_llseek(struct proc *p, struct linux_llseek_args *args)
-{
- struct lseek_args bsd_args;
- int error;
- off_t off;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): llseek(%d, %d:%d, %d)\n",
- p->p_pid, args->fd, args->ohigh, args->olow, args->whence);
-#endif
- off = (args->olow) | (((off_t) args->ohigh) << 32);
-
- bsd_args.fd = args->fd;
- bsd_args.offset = off;
- bsd_args.whence = args->whence;
-
- if ((error = lseek(p, &bsd_args)))
- return error;
-
- if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
- return error;
-
- p->p_retval[0] = 0;
- return 0;
-}
-
-
-struct linux_dirent {
- long dino;
- linux_off_t doff;
- unsigned short dreclen;
- char dname[LINUX_NAME_MAX + 1];
-};
-
-#define LINUX_RECLEN(de,namlen) \
- ALIGN((((char *)&(de)->dname - (char *)de) + (namlen) + 1))
-
-int
-linux_readdir(struct proc *p, struct linux_readdir_args *args)
-{
- struct linux_getdents_args lda;
-
- lda.fd = args->fd;
- lda.dent = args->dent;
- lda.count = 1;
- return linux_getdents(p, &lda);
-}
-
-int
-linux_getdents(struct proc *p, struct linux_getdents_args *args)
-{
- register struct dirent *bdp;
- struct vnode *vp;
- caddr_t inp, buf; /* BSD-format */
- int len, reclen; /* BSD-format */
- caddr_t outp; /* Linux-format */
- int resid, linuxreclen=0; /* Linux-format */
- struct file *fp;
- struct uio auio;
- struct iovec aiov;
- struct vattr va;
- off_t off;
- struct linux_dirent linux_dirent;
- int buflen, error, eofflag, nbytes, justone;
- u_long *cookies = NULL, *cookiep;
- int ncookies;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): getdents(%d, *, %d)\n",
- p->p_pid, args->fd, args->count);
-#endif
- 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);
-
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) {
- return error;
- }
-
- nbytes = args->count;
- if (nbytes == 1) {
- nbytes = sizeof (struct linux_dirent);
- justone = 1;
- }
- else
- justone = 0;
-
- off = fp->f_offset;
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
- buflen = max(DIRBLKSIZ, nbytes);
- buflen = min(buflen, MAXBSIZE);
- buf = malloc(buflen, M_TEMP, M_WAITOK);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-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;
-
- if (cookies) {
- free(cookies, M_TEMP);
- cookies = NULL;
- }
-
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies);
- if (error) {
- goto out;
- }
-
- inp = buf;
- outp = (caddr_t) args->dent;
- resid = nbytes;
- if ((len = buflen - auio.uio_resid) <= 0) {
- goto eof;
- }
-
- cookiep = cookies;
-
- if (cookies) {
- /*
- * When using cookies, the vfs has the option of reading from
- * a different offset than that supplied (UFS truncates the
- * offset to a block boundary to make sure that it never reads
- * partway through a directory entry, even if the directory
- * has been compacted).
- */
- while (len > 0 && ncookies > 0 && *cookiep <= off) {
- bdp = (struct dirent *) inp;
- len -= bdp->d_reclen;
- inp += bdp->d_reclen;
- cookiep++;
- ncookies--;
- }
- }
-
- while (len > 0) {
- if (cookiep && ncookies == 0)
- break;
- bdp = (struct dirent *) inp;
- reclen = bdp->d_reclen;
- if (reclen & 3) {
- printf("linux_readdir: reclen=%d\n", reclen);
- error = EFAULT;
- goto out;
- }
-
- if (bdp->d_fileno == 0) {
- inp += reclen;
- if (cookiep) {
- off = *cookiep++;
- ncookies--;
- } else
- off += reclen;
- len -= reclen;
- continue;
- }
- linuxreclen = LINUX_RECLEN(&linux_dirent, bdp->d_namlen);
- if (reclen > len || resid < linuxreclen) {
- outp++;
- break;
- }
- linux_dirent.dino = (long) bdp->d_fileno;
- if (justone) {
- /*
- * old linux-style readdir usage.
- */
- linux_dirent.doff = (linux_off_t) linuxreclen;
- linux_dirent.dreclen = (u_short) bdp->d_namlen;
- } else {
- linux_dirent.doff = (linux_off_t)(off + reclen);
- linux_dirent.dreclen = (u_short) linuxreclen;
- }
- strcpy(linux_dirent.dname, bdp->d_name);
- if ((error = copyout((caddr_t)&linux_dirent, outp, linuxreclen))) {
- goto out;
- }
- inp += reclen;
- if (cookiep) {
- off = *cookiep++;
- ncookies--;
- } else
- off += reclen;
- outp += linuxreclen;
- resid -= linuxreclen;
- len -= reclen;
- if (justone)
- break;
- }
-
- if (outp == (caddr_t) args->dent)
- goto again;
- fp->f_offset = off;
-
- if (justone)
- nbytes = resid + linuxreclen;
-
-eof:
- p->p_retval[0] = nbytes - resid;
-out:
- if (cookies)
- free(cookies, M_TEMP);
- VOP_UNLOCK(vp, 0, p);
- free(buf, M_TEMP);
- return error;
-}
-
-/*
- * These exist mainly for hooks for doing /compat/linux translation.
- */
-
-int
-linux_access(struct proc *p, struct linux_access_args *args)
-{
- struct access_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): access(%s, %d)\n",
- p->p_pid, args->path, args->flags);
-#endif
- bsd.path = args->path;
- bsd.flags = args->flags;
-
- return access(p, &bsd);
-}
-
-int
-linux_unlink(struct proc *p, struct linux_unlink_args *args)
-{
- struct unlink_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): unlink(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.path = args->path;
-
- return unlink(p, &bsd);
-}
-
-int
-linux_chdir(struct proc *p, struct linux_chdir_args *args)
-{
- struct chdir_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): chdir(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.path = args->path;
-
- return chdir(p, &bsd);
-}
-
-int
-linux_chmod(struct proc *p, struct linux_chmod_args *args)
-{
- struct chmod_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): chmod(%s, %d)\n",
- p->p_pid, args->path, args->mode);
-#endif
- bsd.path = args->path;
- bsd.mode = args->mode;
-
- return chmod(p, &bsd);
-}
-
-int
-linux_chown(struct proc *p, struct linux_chown_args *args)
-{
- struct chown_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): chown(%s, %d, %d)\n",
- p->p_pid, args->path, args->uid, args->gid);
-#endif
- bsd.path = args->path;
- /* XXX size casts here */
- bsd.uid = args->uid;
- bsd.gid = args->gid;
-
- return chown(p, &bsd);
-}
-
-int
-linux_lchown(struct proc *p, struct linux_lchown_args *args)
-{
- struct lchown_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): lchown(%s, %d, %d)\n",
- p->p_pid, args->path, args->uid, args->gid);
-#endif
- bsd.path = args->path;
- /* XXX size casts here */
- bsd.uid = args->uid;
- bsd.gid = args->gid;
-
- return lchown(p, &bsd);
-}
-
-int
-linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
-{
- struct mkdir_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTCREAT(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): mkdir(%s, %d)\n",
- p->p_pid, args->path, args->mode);
-#endif
- bsd.path = args->path;
- bsd.mode = args->mode;
-
- return mkdir(p, &bsd);
-}
-
-int
-linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
-{
- struct rmdir_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): rmdir(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.path = args->path;
-
- return rmdir(p, &bsd);
-}
-
-int
-linux_rename(struct proc *p, struct linux_rename_args *args)
-{
- struct rename_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->from);
- CHECKALTCREAT(p, &sg, args->to);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): rename(%s, %s)\n",
- p->p_pid, args->from, args->to);
-#endif
- bsd.from = args->from;
- bsd.to = args->to;
-
- return rename(p, &bsd);
-}
-
-int
-linux_symlink(struct proc *p, struct linux_symlink_args *args)
-{
- struct symlink_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
- CHECKALTCREAT(p, &sg, args->to);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): symlink(%s, %s)\n",
- p->p_pid, args->path, args->to);
-#endif
- bsd.path = args->path;
- bsd.link = args->to;
-
- return symlink(p, &bsd);
-}
-
-int
-linux_readlink(struct proc *p, struct linux_readlink_args *args)
-{
- struct readlink_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->name);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): readlink(%s, %p, %d)\n",
- (long)p->p_pid, args->name, (void *)args->buf, args->count);
-#endif
- bsd.path = args->name;
- bsd.buf = args->buf;
- bsd.count = args->count;
-
- return readlink(p, &bsd);
-}
-
-int
-linux_truncate(struct proc *p, struct linux_truncate_args *args)
-{
- struct truncate_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): truncate(%s, %ld)\n",
- p->p_pid, args->path, args->length);
-#endif
- bsd.path = args->path;
- bsd.length = args->length;
-
- return truncate(p, &bsd);
-}
-
-int
-linux_link(struct proc *p, struct linux_link_args *args)
-{
- struct link_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
- CHECKALTCREAT(p, &sg, args->to);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): link(%s, %s)\n", p->p_pid, args->path, args->to);
-#endif
-
- bsd.path = args->path;
- bsd.link = args->to;
-
- return link(p, &bsd);
-}
-
-int
-linux_getcwd(struct proc *p, struct linux_getcwd_args *args)
-{
- struct __getcwd_args bsd;
- caddr_t sg;
- int error, len;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid,
- args->buf, args->bufsize);
-#endif
-
- sg = stackgap_init();
- bsd.buf = stackgap_alloc(&sg, SPARE_USRSPACE);
- bsd.buflen = SPARE_USRSPACE;
- error = __getcwd(p, &bsd);
- if (!error) {
- len = strlen(bsd.buf) + 1;
- if (len <= args->bufsize) {
- p->p_retval[0] = len;
- error = copyout(bsd.buf, args->buf, len);
- }
- else
- error = ERANGE;
- }
- return (error);
-}
-
-int
-linux_fdatasync(p, uap)
- struct proc *p;
- struct linux_fdatasync_args *uap;
-{
- struct fsync_args bsd;
-
- bsd.fd = uap->fd;
- return fsync(p, &bsd);
-}
-
-int
-linux_pread(p, uap)
- struct proc *p;
- struct linux_pread_args *uap;
-{
- struct pread_args bsd;
-
- bsd.fd = uap->fd;
- bsd.buf = uap->buf;
- bsd.nbyte = uap->nbyte;
- bsd.offset = uap->offset;
- return pread(p, &bsd);
-}
-
-int
-linux_pwrite(p, uap)
- struct proc *p;
- struct linux_pwrite_args *uap;
-{
- struct pwrite_args bsd;
-
- bsd.fd = uap->fd;
- bsd.buf = uap->buf;
- bsd.nbyte = uap->nbyte;
- bsd.offset = uap->offset;
- return pwrite(p, &bsd);
-}
diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h
deleted file mode 100644
index d5508e6ff5a10..0000000000000
--- a/sys/compat/linux/linux_ioctl.h
+++ /dev/null
@@ -1,437 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_IOCTL_H_
-#define _LINUX_IOCTL_H_
-
-/*
- * disk
- */
-#define LINUX_BLKROSET 0x125d
-#define LINUX_BLKROGET 0x125e
-#define LINUX_BLKRRPART 0x125f
-#define LINUX_BLKGETSIZE 0x1260
-#define LINUX_BLKFLSBUF 0x1261
-#define LINUX_BLKRASET 0x1262
-#define LINUX_BLKRAGET 0x1263
-#define LINUX_BLKFRASET 0x1264
-#define LINUX_BLKFRAGET 0x1265
-#define LINUX_BLKSECTSET 0x1266
-#define LINUX_BLKSECTGET 0x1267
-#define LINUX_BLKSSZGET 0x1268
-
-#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET
-#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET
-
-/*
- * cdrom
- */
-#define LINUX_CDROMPAUSE 0x5301
-#define LINUX_CDROMRESUME 0x5302
-#define LINUX_CDROMPLAYMSF 0x5303
-#define LINUX_CDROMPLAYTRKIND 0x5304
-#define LINUX_CDROMREADTOCHDR 0x5305
-#define LINUX_CDROMREADTOCENTRY 0x5306
-#define LINUX_CDROMSTOP 0x5307
-#define LINUX_CDROMSTART 0x5308
-#define LINUX_CDROMEJECT 0x5309
-#define LINUX_CDROMVOLCTRL 0x530a
-#define LINUX_CDROMSUBCHNL 0x530b
-#define LINUX_CDROMREADMODE2 0x530c
-#define LINUX_CDROMREADMODE1 0x530d
-#define LINUX_CDROMREADAUDIO 0x530e
-#define LINUX_CDROMEJECT_SW 0x530f
-#define LINUX_CDROMMULTISESSION 0x5310
-#define LINUX_CDROM_GET_UPC 0x5311
-#define LINUX_CDROMRESET 0x5312
-#define LINUX_CDROMVOLREAD 0x5313
-#define LINUX_CDROMREADRAW 0x5314
-#define LINUX_CDROMREADCOOKED 0x5315
-#define LINUX_CDROMSEEK 0x5316
-#define LINUX_CDROMPLAYBLK 0x5317
-#define LINUX_CDROMREADALL 0x5318
-#define LINUX_CDROMCLOSETRAY 0x5319
-#define LINUX_CDROMLOADFROMSLOT 0x531a
-
-#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE
-#define LINUX_IOCTL_CDROM_MAX LINUX_CDROMLOADFROMSLOT
-
-#define LINUX_CDROM_LBA 0x01
-#define LINUX_CDROM_MSF 0x02
-
-/*
- * console
- */
-#define LINUX_KIOCSOUND 0x4B2F
-#define LINUX_KDMKTONE 0x4B30
-#define LINUX_KDGETLED 0x4B31
-#define LINUX_KDSETLED 0x4B32
-#define LINUX_KDSETMODE 0x4B3A
-#define LINUX_KDGETMODE 0x4B3B
-#define LINUX_KDGKBMODE 0x4B44
-#define LINUX_KDSKBMODE 0x4B45
-#define LINUX_VT_OPENQRY 0x5600
-#define LINUX_VT_GETMODE 0x5601
-#define LINUX_VT_SETMODE 0x5602
-#define LINUX_VT_GETSTATE 0x5603
-#define LINUX_VT_RELDISP 0x5605
-#define LINUX_VT_ACTIVATE 0x5606
-#define LINUX_VT_WAITACTIVE 0x5607
-
-#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND
-#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE
-
-#define LINUX_LED_SCR 0x01
-#define LINUX_LED_NUM 0x02
-#define LINUX_LED_CAP 0x04
-
-#define LINUX_KD_TEXT 0x0
-#define LINUX_KD_GRAPHICS 0x1
-#define LINUX_KD_TEXT0 0x2
-#define LINUX_KD_TEXT1 0x3
-
-#define LINUX_KBD_RAW 0
-#define LINUX_KBD_XLATE 1
-#define LINUX_KBD_MEDIUMRAW 2
-
-/*
- * socket
- */
-#define LINUX_FIOSETOWN 0x8901
-#define LINUX_SIOCSPGRP 0x8902
-#define LINUX_FIOGETOWN 0x8903
-#define LINUX_SIOCGPGRP 0x8904
-#define LINUX_SIOCATMARK 0x8905
-#define LINUX_SIOCGSTAMP 0x8906
-#define LINUX_SIOCGIFCONF 0x8912
-#define LINUX_SIOCGIFFLAGS 0x8913
-#define LINUX_SIOCGIFADDR 0x8915
-#define LINUX_SIOCGIFDSTADDR 0x8917
-#define LINUX_SIOCGIFBRDADDR 0x8919
-#define LINUX_SIOCGIFNETMASK 0x891b
-#define LINUX_SIOCGIFHWADDR 0x8927
-#define LINUX_SIOCADDMULTI 0x8931
-#define LINUX_SIOCDELMULTI 0x8932
-
-#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN
-#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCDELMULTI
-
-/*
- * sound
- */
-#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00
-#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01
-#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02
-#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03
-#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04
-#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05
-#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06
-#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07
-#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08
-#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09
-#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A
-#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B
-#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C
-#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D
-#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E
-#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F
-#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10
-#define LINUX_OSS_GETVERSION 0x4d76
-#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe
-#define LINUX_SNDCTL_DSP_RESET 0x5000
-#define LINUX_SNDCTL_DSP_SYNC 0x5001
-#define LINUX_SNDCTL_DSP_SPEED 0x5002
-#define LINUX_SNDCTL_DSP_STEREO 0x5003
-#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004
-#define LINUX_SNDCTL_DSP_SETBLKSIZE LINUX_SNDCTL_DSP_GETBLKSIZE
-#define LINUX_SNDCTL_DSP_SETFMT 0x5005
-#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006
-#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007
-#define LINUX_SNDCTL_DSP_POST 0x5008
-#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009
-#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A
-#define LINUX_SNDCTL_DSP_GETFMTS 0x500B
-#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C
-#define LINUX_SNDCTL_DSP_GETISPACE 0x500D
-#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E
-#define LINUX_SNDCTL_DSP_GETCAPS 0x500F
-#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010
-#define LINUX_SNDCTL_DSP_SETTRIGGER LINUX_SNDCTL_DSP_GETTRIGGER
-#define LINUX_SNDCTL_DSP_GETIPTR 0x5011
-#define LINUX_SNDCTL_DSP_GETOPTR 0x5012
-#define LINUX_SNDCTL_DSP_GETODELAY 0x5017
-#define LINUX_SNDCTL_SEQ_RESET 0x5100
-#define LINUX_SNDCTL_SEQ_SYNC 0x5101
-#define LINUX_SNDCTL_SYNTH_INFO 0x5102
-#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103
-#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104
-#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105
-#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106
-#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107
-#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108
-#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109
-#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A
-#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B
-#define LINUX_SNDCTL_MIDI_INFO 0x510C
-#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D
-#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E
-
-#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_VOLUME
-#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SYNTH_MEMAVL
-
-/*
- * termio
- */
-#define LINUX_TCGETS 0x5401
-#define LINUX_TCSETS 0x5402
-#define LINUX_TCSETSW 0x5403
-#define LINUX_TCSETSF 0x5404
-#define LINUX_TCGETA 0x5405
-#define LINUX_TCSETA 0x5406
-#define LINUX_TCSETAW 0x5407
-#define LINUX_TCSETAF 0x5408
-#define LINUX_TCSBRK 0x5409
-#define LINUX_TCXONC 0x540A
-#define LINUX_TCFLSH 0x540B
-#define LINUX_TIOCEXCL 0x540C
-#define LINUX_TIOCNXCL 0x540D
-#define LINUX_TIOCSCTTY 0x540E
-#define LINUX_TIOCGPGRP 0x540F
-#define LINUX_TIOCSPGRP 0x5410
-#define LINUX_TIOCOUTQ 0x5411
-#define LINUX_TIOCSTI 0x5412
-#define LINUX_TIOCGWINSZ 0x5413
-#define LINUX_TIOCSWINSZ 0x5414
-#define LINUX_TIOCMGET 0x5415
-#define LINUX_TIOCMBIS 0x5416
-#define LINUX_TIOCMBIC 0x5417
-#define LINUX_TIOCMSET 0x5418
-#define LINUX_TIOCGSOFTCAR 0x5419
-#define LINUX_TIOCSSOFTCAR 0x541A
-#define LINUX_FIONREAD 0x541B
-#define LINUX_TIOCINQ FIONREAD
-#define LINUX_TIOCLINUX 0x541C
-#define LINUX_TIOCCONS 0x541D
-#define LINUX_TIOCGSERIAL 0x541E
-#define LINUX_TIOCSSERIAL 0x541F
-#define LINUX_TIOCPKT 0x5420
-#define LINUX_FIONBIO 0x5421
-#define LINUX_TIOCNOTTY 0x5422
-#define LINUX_TIOCSETD 0x5423
-#define LINUX_TIOCGETD 0x5424
-#define LINUX_TCSBRKP 0x5425
-#define LINUX_TIOCTTYGSTRUCT 0x5426
-#define LINUX_FIONCLEX 0x5450
-#define LINUX_FIOCLEX 0x5451
-#define LINUX_FIOASYNC 0x5452
-#define LINUX_TIOCSERCONFIG 0x5453
-#define LINUX_TIOCSERGWILD 0x5454
-#define LINUX_TIOCSERSWILD 0x5455
-#define LINUX_TIOCGLCKTRMIOS 0x5456
-#define LINUX_TIOCSLCKTRMIOS 0x5457
-
-#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS
-#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS
-
-/* arguments for tcflow() and LINUX_TCXONC */
-#define LINUX_TCOOFF 0
-#define LINUX_TCOON 1
-#define LINUX_TCIOFF 2
-#define LINUX_TCION 3
-
-/* arguments for tcflush() and LINUX_TCFLSH */
-#define LINUX_TCIFLUSH 0
-#define LINUX_TCOFLUSH 1
-#define LINUX_TCIOFLUSH 2
-
-/* line disciplines */
-#define LINUX_N_TTY 0
-#define LINUX_N_SLIP 1
-#define LINUX_N_MOUSE 2
-#define LINUX_N_PPP 3
-
-/* Linux termio c_cc values */
-#define LINUX_VINTR 0
-#define LINUX_VQUIT 1
-#define LINUX_VERASE 2
-#define LINUX_VKILL 3
-#define LINUX_VEOF 4
-#define LINUX_VTIME 5
-#define LINUX_VMIN 6
-#define LINUX_VSWTC 7
-#define LINUX_NCC 8
-
-/* Linux termios c_cc values */
-#define LINUX_VSTART 8
-#define LINUX_VSTOP 9
-#define LINUX_VSUSP 10
-#define LINUX_VEOL 11
-#define LINUX_VREPRINT 12
-#define LINUX_VDISCARD 13
-#define LINUX_VWERASE 14
-#define LINUX_VLNEXT 15
-#define LINUX_VEOL2 16
-#define LINUX_NCCS 19
-
-#define LINUX_POSIX_VDISABLE '\0'
-
-/* Linux c_iflag masks */
-#define LINUX_IGNBRK 0x0000001
-#define LINUX_BRKINT 0x0000002
-#define LINUX_IGNPAR 0x0000004
-#define LINUX_PARMRK 0x0000008
-#define LINUX_INPCK 0x0000010
-#define LINUX_ISTRIP 0x0000020
-#define LINUX_INLCR 0x0000040
-#define LINUX_IGNCR 0x0000080
-#define LINUX_ICRNL 0x0000100
-#define LINUX_IUCLC 0x0000200
-#define LINUX_IXON 0x0000400
-#define LINUX_IXANY 0x0000800
-#define LINUX_IXOFF 0x0001000
-#define LINUX_IMAXBEL 0x0002000
-
-/* Linux c_oflag masks */
-#define LINUX_OPOST 0x0000001
-#define LINUX_OLCUC 0x0000002
-#define LINUX_ONLCR 0x0000004
-#define LINUX_OCRNL 0x0000008
-#define LINUX_ONOCR 0x0000010
-#define LINUX_ONLRET 0x0000020
-#define LINUX_OFILL 0x0000040
-#define LINUX_OFDEL 0x0000080
-#define LINUX_NLDLY 0x0000100
-
-#define LINUX_NL0 0x0000000
-#define LINUX_NL1 0x0000100
-#define LINUX_CRDLY 0x0000600
-#define LINUX_CR0 0x0000000
-#define LINUX_CR1 0x0000200
-#define LINUX_CR2 0x0000400
-#define LINUX_CR3 0x0000600
-#define LINUX_TABDLY 0x0001800
-#define LINUX_TAB0 0x0000000
-#define LINUX_TAB1 0x0000800
-#define LINUX_TAB2 0x0001000
-#define LINUX_TAB3 0x0001800
-#define LINUX_XTABS 0x0001800
-#define LINUX_BSDLY 0x0002000
-#define LINUX_BS0 0x0000000
-#define LINUX_BS1 0x0002000
-#define LINUX_VTDLY 0x0004000
-#define LINUX_VT0 0x0000000
-#define LINUX_VT1 0x0004000
-#define LINUX_FFDLY 0x0008000
-#define LINUX_FF0 0x0000000
-#define LINUX_FF1 0x0008000
-
-#define LINUX_CBAUD 0x0000100f
-#define LINUX_B0 0x00000000
-#define LINUX_B50 0x00000001
-#define LINUX_B75 0x00000002
-#define LINUX_B110 0x00000003
-#define LINUX_B134 0x00000004
-#define LINUX_B150 0x00000005
-#define LINUX_B200 0x00000006
-#define LINUX_B300 0x00000007
-#define LINUX_B600 0x00000008
-#define LINUX_B1200 0x00000009
-#define LINUX_B1800 0x0000000a
-#define LINUX_B2400 0x0000000b
-#define LINUX_B4800 0x0000000c
-#define LINUX_B9600 0x0000000d
-#define LINUX_B19200 0x0000000e
-#define LINUX_B38400 0x0000000f
-#define LINUX_EXTA LINUX_B19200
-#define LINUX_EXTB LINUX_B38400
-#define LINUX_CBAUDEX 0x00001000
-#define LINUX_B57600 0x00001001
-#define LINUX_B115200 0x00001002
-
-#define LINUX_CSIZE 0x00000030
-#define LINUX_CS5 0x00000000
-#define LINUX_CS6 0x00000010
-#define LINUX_CS7 0x00000020
-#define LINUX_CS8 0x00000030
-#define LINUX_CSTOPB 0x00000040
-#define LINUX_CREAD 0x00000080
-#define LINUX_PARENB 0x00000100
-#define LINUX_PARODD 0x00000200
-#define LINUX_HUPCL 0x00000400
-#define LINUX_CLOCAL 0x00000800
-#define LINUX_CRTSCTS 0x80000000
-
-/* Linux c_lflag masks */
-#define LINUX_ISIG 0x00000001
-#define LINUX_ICANON 0x00000002
-#define LINUX_XCASE 0x00000004
-#define LINUX_ECHO 0x00000008
-#define LINUX_ECHOE 0x00000010
-#define LINUX_ECHOK 0x00000020
-#define LINUX_ECHONL 0x00000040
-#define LINUX_NOFLSH 0x00000080
-#define LINUX_TOSTOP 0x00000100
-#define LINUX_ECHOCTL 0x00000200
-#define LINUX_ECHOPRT 0x00000400
-#define LINUX_ECHOKE 0x00000800
-#define LINUX_FLUSHO 0x00001000
-#define LINUX_PENDIN 0x00002000
-#define LINUX_IEXTEN 0x00008000
-
-/* serial_struct values for TIOC[GS]SERIAL ioctls */
-#define LINUX_ASYNC_CLOSING_WAIT_INF 0
-#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535
-
-#define LINUX_PORT_UNKNOWN 0
-#define LINUX_PORT_8250 1
-#define LINUX_PORT_16450 2
-#define LINUX_PORT_16550 3
-#define LINUX_PORT_16550A 4
-#define LINUX_PORT_CIRRUS 5
-#define LINUX_PORT_16650 6
-
-#define LINUX_PORT_MAX 6
-
-#define LINUX_ASYNC_HUP_NOTIFY 0x0001
-#define LINUX_ASYNC_FOURPORT 0x0002
-#define LINUX_ASYNC_SAK 0x0004
-#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008
-#define LINUX_ASYNC_SPD_MASK 0x0030
-#define LINUX_ASYNC_SPD_HI 0x0010
-#define LINUX_ASYNC_SPD_VHI 0x0020
-#define LINUX_ASYNC_SPD_CUST 0x0030
-#define LINUX_ASYNC_SKIP_TEST 0x0040
-#define LINUX_ASYNC_AUTO_IRQ 0x0080
-#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100
-#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200
-#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400
-#define LINUX_ASYNC_FLAGS 0x0FFF
-
-#endif /* !_LINUX_IOCTL_H_ */
diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c
deleted file mode 100644
index 48e13d5782772..0000000000000
--- a/sys/compat/linux/linux_ipc.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/proc.h>
-#include <sys/sem.h>
-#include <sys/shm.h>
-
-#include <machine/../linux/linux.h>
-#include <machine/../linux/linux_proto.h>
-#include <compat/linux/linux_ipc.h>
-#include <compat/linux/linux_util.h>
-
-struct linux_ipc_perm {
- linux_key_t key;
- unsigned short uid;
- unsigned short gid;
- unsigned short cuid;
- unsigned short cgid;
- unsigned short mode;
- unsigned short seq;
-};
-
-static void
-linux_to_bsd_ipc_perm(struct linux_ipc_perm *lpp, struct ipc_perm *bpp)
-{
- bpp->key = lpp->key;
- bpp->uid = lpp->uid;
- bpp->gid = lpp->gid;
- bpp->cuid = lpp->cuid;
- bpp->cgid = lpp->cgid;
- bpp->mode = lpp->mode;
- bpp->seq = lpp->seq;
-}
-
-
-static void
-bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
-{
- lpp->key = bpp->key;
- lpp->uid = bpp->uid;
- lpp->gid = bpp->gid;
- lpp->cuid = bpp->cuid;
- lpp->cgid = bpp->cgid;
- lpp->mode = bpp->mode;
- lpp->seq = bpp->seq;
-}
-
-struct linux_semid_ds {
- struct linux_ipc_perm sem_perm;
- linux_time_t sem_otime;
- linux_time_t sem_ctime;
- void *sem_base;
- void *sem_pending;
- void *sem_pending_last;
- void *undo;
- ushort sem_nsems;
-};
-
-struct linux_shmid_ds {
- struct linux_ipc_perm shm_perm;
- int shm_segsz;
- linux_time_t shm_atime;
- linux_time_t shm_dtime;
- linux_time_t shm_ctime;
- ushort shm_cpid;
- ushort shm_lpid;
- short shm_nattch;
- ushort private1;
- void *private2;
- void *private3;
-};
-
-static void
-linux_to_bsd_semid_ds(struct linux_semid_ds *lsp, struct semid_ds *bsp)
-{
- linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
- bsp->sem_otime = lsp->sem_otime;
- bsp->sem_ctime = lsp->sem_ctime;
- bsp->sem_nsems = lsp->sem_nsems;
- bsp->sem_base = lsp->sem_base;
-}
-
-static void
-bsd_to_linux_semid_ds(struct semid_ds *bsp, struct linux_semid_ds *lsp)
-{
- bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
- lsp->sem_otime = bsp->sem_otime;
- lsp->sem_ctime = bsp->sem_ctime;
- lsp->sem_nsems = bsp->sem_nsems;
- lsp->sem_base = bsp->sem_base;
-}
-
-static void
-linux_to_bsd_shmid_ds(struct linux_shmid_ds *lsp, struct shmid_ds *bsp)
-{
- linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
- bsp->shm_segsz = lsp->shm_segsz;
- bsp->shm_lpid = lsp->shm_lpid;
- bsp->shm_cpid = lsp->shm_cpid;
- bsp->shm_nattch = lsp->shm_nattch;
- bsp->shm_atime = lsp->shm_atime;
- bsp->shm_dtime = lsp->shm_dtime;
- bsp->shm_ctime = lsp->shm_ctime;
- bsp->shm_internal = lsp->private3; /* this goes (yet) SOS */
-}
-
-static void
-bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct linux_shmid_ds *lsp)
-{
- bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
- lsp->shm_segsz = bsp->shm_segsz;
- lsp->shm_lpid = bsp->shm_lpid;
- lsp->shm_cpid = bsp->shm_cpid;
- lsp->shm_nattch = bsp->shm_nattch;
- lsp->shm_atime = bsp->shm_atime;
- lsp->shm_dtime = bsp->shm_dtime;
- lsp->shm_ctime = bsp->shm_ctime;
- lsp->private3 = bsp->shm_internal; /* this goes (yet) SOS */
-}
-
-int
-linux_semop(struct proc *p, struct linux_ipc_args *args)
-{
- struct semop_args /* {
- int semid;
- struct sembuf *sops;
- int nsops;
- } */ bsd_args;
-
- bsd_args.semid = args->arg1;
- bsd_args.sops = (struct sembuf *)args->ptr;
- bsd_args.nsops = args->arg2;
- return semop(p, &bsd_args);
-}
-
-int
-linux_semget(struct proc *p, struct linux_ipc_args *args)
-{
- struct semget_args /* {
- key_t key;
- int nsems;
- int semflg;
- } */ bsd_args;
-
- bsd_args.key = args->arg1;
- bsd_args.nsems = args->arg2;
- bsd_args.semflg = args->arg3;
- return semget(p, &bsd_args);
-}
-
-int
-linux_semctl(struct proc *p, struct linux_ipc_args *args)
-{
- struct linux_semid_ds linux_semid;
- struct semid_ds bsd_semid;
- struct __semctl_args /* {
- int semid;
- int semnum;
- int cmd;
- union semun *arg;
- } */ bsd_args;
- int error;
- caddr_t sg, unptr, dsp, ldsp;
-
- sg = stackgap_init();
- bsd_args.semid = args->arg1;
- bsd_args.semnum = args->arg2;
- bsd_args.cmd = args->arg3;
- bsd_args.arg = (union semun *)args->ptr;
-
- switch (args->arg3) {
- case LINUX_IPC_RMID:
- bsd_args.cmd = IPC_RMID;
- break;
- case LINUX_GETNCNT:
- bsd_args.cmd = GETNCNT;
- break;
- case LINUX_GETPID:
- bsd_args.cmd = GETPID;
- break;
- case LINUX_GETVAL:
- bsd_args.cmd = GETVAL;
- break;
- case LINUX_GETZCNT:
- bsd_args.cmd = GETZCNT;
- break;
- case LINUX_SETVAL:
- bsd_args.cmd = SETVAL;
- break;
- case LINUX_IPC_SET:
- bsd_args.cmd = IPC_SET;
- error = copyin(args->ptr, &ldsp, sizeof(ldsp));
- if (error)
- return error;
- error = copyin(ldsp, (caddr_t)&linux_semid, sizeof(linux_semid));
- if (error)
- return error;
- linux_to_bsd_semid_ds(&linux_semid, &bsd_semid);
- unptr = stackgap_alloc(&sg, sizeof(union semun));
- dsp = stackgap_alloc(&sg, sizeof(struct semid_ds));
- error = copyout((caddr_t)&bsd_semid, dsp, sizeof(bsd_semid));
- if (error)
- return error;
- error = copyout((caddr_t)&dsp, unptr, sizeof(dsp));
- if (error)
- return error;
- bsd_args.arg = (union semun *)unptr;
- return __semctl(p, &bsd_args);
- case LINUX_IPC_STAT:
- bsd_args.cmd = IPC_STAT;
- unptr = stackgap_alloc(&sg, sizeof(union semun *));
- dsp = stackgap_alloc(&sg, sizeof(struct semid_ds));
- error = copyout((caddr_t)&dsp, unptr, sizeof(dsp));
- if (error)
- return error;
- bsd_args.arg = (union semun *)unptr;
- error = __semctl(p, &bsd_args);
- if (error)
- return error;
- error = copyin(dsp, (caddr_t)&bsd_semid, sizeof(bsd_semid));
- if (error)
- return error;
- bsd_to_linux_semid_ds(&bsd_semid, &linux_semid);
- error = copyin(args->ptr, &ldsp, sizeof(ldsp));
- if (error)
- return error;
- return copyout((caddr_t)&linux_semid, ldsp, sizeof(linux_semid));
- case LINUX_GETALL:
- /* FALLTHROUGH */
- case LINUX_SETALL:
- /* FALLTHROUGH */
- default:
- uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
- return EINVAL;
- }
- return __semctl(p, &bsd_args);
-}
-
-int
-linux_msgsnd(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgsnd_args /* {
- int msqid;
- void *msgp;
- size_t msgsz;
- int msgflg;
- } */ bsd_args;
-
- bsd_args.msqid = args->arg1;
- bsd_args.msgp = args->ptr;
- bsd_args.msgsz = args->arg2;
- bsd_args.msgflg = args->arg3;
- return msgsnd(p, &bsd_args);
-}
-
-int
-linux_msgrcv(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgrcv_args /* {
- int msqid;
- void *msgp;
- size_t msgsz;
- long msgtyp;
- int msgflg;
- } */ bsd_args;
-
- bsd_args.msqid = args->arg1;
- bsd_args.msgp = args->ptr;
- bsd_args.msgsz = args->arg2;
- bsd_args.msgtyp = 0;
- bsd_args.msgflg = args->arg3;
- return msgrcv(p, &bsd_args);
-}
-
-int
-linux_msgget(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgget_args /* {
- key_t key;
- int msgflg;
- } */ bsd_args;
-
- bsd_args.key = args->arg1;
- bsd_args.msgflg = args->arg2;
- return msgget(p, &bsd_args);
-}
-
-int
-linux_msgctl(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgctl_args /* {
- int msqid;
- int cmd;
- struct msqid_ds *buf;
- } */ bsd_args;
- int error;
-
- bsd_args.msqid = args->arg1;
- bsd_args.cmd = args->arg2;
- bsd_args.buf = (struct msqid_ds *)args->ptr;
- error = msgctl(p, &bsd_args);
- return ((args->arg2 == LINUX_IPC_RMID && error == EINVAL) ? 0 : error);
-}
-
-int
-linux_shmat(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmat_args /* {
- int shmid;
- void *shmaddr;
- int shmflg;
- } */ bsd_args;
- int error;
-
- bsd_args.shmid = args->arg1;
- bsd_args.shmaddr = args->ptr;
- bsd_args.shmflg = args->arg2;
- if ((error = shmat(p, &bsd_args)))
- return error;
- if ((error = copyout(p->p_retval, (caddr_t)args->arg3, sizeof(int))))
- return error;
- p->p_retval[0] = 0;
- return 0;
-}
-
-int
-linux_shmdt(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmdt_args /* {
- void *shmaddr;
- } */ bsd_args;
-
- bsd_args.shmaddr = args->ptr;
- return shmdt(p, &bsd_args);
-}
-
-int
-linux_shmget(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmget_args /* {
- key_t key;
- int size;
- int shmflg;
- } */ bsd_args;
-
- bsd_args.key = args->arg1;
- bsd_args.size = args->arg2;
- bsd_args.shmflg = args->arg3;
- return shmget(p, &bsd_args);
-}
-
-int
-linux_shmctl(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmid_ds bsd_shmid;
- struct linux_shmid_ds linux_shmid;
- struct shmctl_args /* {
- int shmid;
- int cmd;
- struct shmid_ds *buf;
- } */ bsd_args;
- int error;
- caddr_t sg = stackgap_init();
-
- switch (args->arg2) {
- case LINUX_IPC_STAT:
- bsd_args.shmid = args->arg1;
- bsd_args.cmd = IPC_STAT;
- bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
- if ((error = shmctl(p, &bsd_args)))
- return error;
- if ((error = copyin((caddr_t)bsd_args.buf, (caddr_t)&bsd_shmid,
- sizeof(struct shmid_ds))))
- return error;
- bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
- return copyout((caddr_t)&linux_shmid, args->ptr, sizeof(linux_shmid));
-
- case LINUX_IPC_SET:
- if ((error = copyin(args->ptr, (caddr_t)&linux_shmid,
- sizeof(linux_shmid))))
- return error;
- linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
- bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
- if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf,
- sizeof(struct shmid_ds))))
- return error;
- bsd_args.shmid = args->arg1;
- bsd_args.cmd = IPC_SET;
- return shmctl(p, &bsd_args);
-
- case LINUX_IPC_RMID:
- bsd_args.shmid = args->arg1;
- bsd_args.cmd = IPC_RMID;
- if (NULL == args->ptr)
- bsd_args.buf = NULL;
- else {
- if ((error = copyin(args->ptr, (caddr_t)&linux_shmid,
- sizeof(linux_shmid))))
- return error;
- linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
- bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
- if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf,
- sizeof(struct shmid_ds))))
- return error;
- }
- return shmctl(p, &bsd_args);
-
- case LINUX_IPC_INFO:
- case LINUX_SHM_STAT:
- case LINUX_SHM_INFO:
- case LINUX_SHM_LOCK:
- case LINUX_SHM_UNLOCK:
- default:
- uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
- return EINVAL;
- }
-}
diff --git a/sys/compat/linux/linux_ipc.h b/sys/compat/linux/linux_ipc.h
deleted file mode 100644
index e51a35ee1c25b..0000000000000
--- a/sys/compat/linux/linux_ipc.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 2000 Marcel Moolenaar
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_IPC_H_
-#define _LINUX_IPC_H_
-
-int linux_msgctl __P((struct proc *, struct linux_ipc_args *));
-int linux_msgget __P((struct proc *, struct linux_ipc_args *));
-int linux_msgrcv __P((struct proc *, struct linux_ipc_args *));
-int linux_msgsnd __P((struct proc *, struct linux_ipc_args *));
-
-int linux_semctl __P((struct proc *, struct linux_ipc_args *));
-int linux_semget __P((struct proc *, struct linux_ipc_args *));
-int linux_semop __P((struct proc *, struct linux_ipc_args *));
-
-int linux_shmat __P((struct proc *, struct linux_ipc_args *));
-int linux_shmctl __P((struct proc *, struct linux_ipc_args *));
-int linux_shmdt __P((struct proc *, struct linux_ipc_args *));
-int linux_shmget __P((struct proc *, struct linux_ipc_args *));
-
-#endif /* _LINUX_IPC_H_ */
diff --git a/sys/compat/linux/linux_mib.c b/sys/compat/linux/linux_mib.c
deleted file mode 100644
index f7d504788b1d0..0000000000000
--- a/sys/compat/linux/linux_mib.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/jail.h>
-
-#include <machine/../linux/linux.h>
-#include <compat/linux/linux_mib.h>
-
-struct linux_prison {
- char pr_osname[LINUX_MAX_UTSNAME];
- char pr_osrelease[LINUX_MAX_UTSNAME];
- int pr_oss_version;
-};
-
-SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0,
- "Linux mode");
-
-static char linux_osname[LINUX_MAX_UTSNAME] = "Linux";
-
-static int
-linux_sysctl_osname(SYSCTL_HANDLER_ARGS)
-{
- char osname[LINUX_MAX_UTSNAME];
- int error;
-
- strcpy(osname, linux_get_osname(req->p));
- error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req);
- if (error || req->newptr == NULL)
- return (error);
- error = linux_set_osname(req->p, osname);
- return (error);
-}
-
-SYSCTL_PROC(_compat_linux, OID_AUTO, osname,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
- 0, 0, linux_sysctl_osname, "A",
- "Linux kernel OS name");
-
-static char linux_osrelease[LINUX_MAX_UTSNAME] = "2.2.12";
-
-static int
-linux_sysctl_osrelease(SYSCTL_HANDLER_ARGS)
-{
- char osrelease[LINUX_MAX_UTSNAME];
- int error;
-
- strcpy(osrelease, linux_get_osrelease(req->p));
- error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req);
- if (error || req->newptr == NULL)
- return (error);
- error = linux_set_osrelease(req->p, osrelease);
- return (error);
-}
-
-SYSCTL_PROC(_compat_linux, OID_AUTO, osrelease,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
- 0, 0, linux_sysctl_osrelease, "A",
- "Linux kernel OS release");
-
-static int linux_oss_version = 0x030600;
-
-static int
-linux_sysctl_oss_version(SYSCTL_HANDLER_ARGS)
-{
- int oss_version;
- int error;
-
- oss_version = linux_get_oss_version(req->p);
- error = sysctl_handle_int(oidp, &oss_version, 0, req);
- if (error || req->newptr == NULL)
- return (error);
- error = linux_set_oss_version(req->p, oss_version);
- return (error);
-}
-
-SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version,
- CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON,
- 0, 0, linux_sysctl_oss_version, "I",
- "Linux OSS version");
-
-static struct linux_prison *
-get_prison(struct proc *p)
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr == NULL)
- return (NULL);
-
- if (pr->pr_linux == NULL) {
- MALLOC(lpr, struct linux_prison *, sizeof *lpr,
- M_PRISON, M_WAITOK);
- bzero((caddr_t)lpr, sizeof *lpr);
- pr->pr_linux = lpr;
- }
-
- return (pr->pr_linux);
-}
-
-char *
-linux_get_osname(p)
- struct proc *p;
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr != NULL && pr->pr_linux != NULL) {
- lpr = pr->pr_linux;
- if (lpr->pr_osname[0])
- return (lpr->pr_osname);
- }
-
- return (linux_osname);
-}
-
-int
-linux_set_osname(p, osname)
- struct proc *p;
- char *osname;
-{
- register struct linux_prison *lpr;
-
- lpr = get_prison(p);
- if (lpr != NULL)
- strcpy(lpr->pr_osname, osname);
- else
- strcpy(linux_osname, osname);
-
- return (0);
-}
-
-char *
-linux_get_osrelease(p)
- struct proc *p;
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr != NULL && pr->pr_linux != NULL) {
- lpr = pr->pr_linux;
- if (lpr->pr_osrelease[0])
- return (lpr->pr_osrelease);
- }
-
- return (linux_osrelease);
-}
-
-int
-linux_set_osrelease(p, osrelease)
- struct proc *p;
- char *osrelease;
-{
- register struct linux_prison *lpr;
-
- lpr = get_prison(p);
- if (lpr != NULL)
- strcpy(lpr->pr_osrelease, osrelease);
- else
- strcpy(linux_osrelease, osrelease);
-
- return (0);
-}
-
-int
-linux_get_oss_version(p)
- struct proc *p;
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr != NULL && pr->pr_linux != NULL) {
- lpr = pr->pr_linux;
- if (lpr->pr_oss_version)
- return (lpr->pr_oss_version);
- }
-
- return (linux_oss_version);
-}
-
-int
-linux_set_oss_version(p, oss_version)
- struct proc *p;
- int oss_version;
-{
- register struct linux_prison *lpr;
-
- lpr = get_prison(p);
- if (lpr != NULL)
- lpr->pr_oss_version = oss_version;
- else
- linux_oss_version = oss_version;
-
- return (0);
-}
diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h
deleted file mode 100644
index 34f5a4eefdf44..0000000000000
--- a/sys/compat/linux/linux_mib.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_MIB_H_
-#define _LINUX_MIB_H_
-
-char* linux_get_osname __P((struct proc *p));
-int linux_set_osname __P((struct proc *p, char *osname));
-
-char* linux_get_osrelease __P((struct proc *p));
-int linux_set_osrelease __P((struct proc *p, char *osrelease));
-
-int linux_get_oss_version __P((struct proc *p));
-int linux_set_oss_version __P((struct proc *p, int oss_version));
-
-#endif /* _LINUX_MIB_H_ */
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
deleted file mode 100644
index 8b326582b11f5..0000000000000
--- a/sys/compat/linux/linux_misc.c
+++ /dev/null
@@ -1,1120 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/mman.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-#include <sys/imgact_aout.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/resourcevar.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/signalvar.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-
-#include <machine/frame.h>
-#include <machine/limits.h>
-#include <machine/psl.h>
-#include <machine/sysarch.h>
-#include <machine/segments.h>
-
-#include <posix4/sched.h>
-
-#include <machine/../linux/linux.h>
-#include <machine/../linux/linux_proto.h>
-#include <compat/linux/linux_mib.h>
-#include <compat/linux/linux_util.h>
-
-#define BSD_TO_LINUX_SIGNAL(sig) \
- (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig)
-
-struct linux_rlimit {
- unsigned long rlim_cur;
- unsigned long rlim_max;
-};
-
-static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] =
-{ RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK,
- RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE,
- RLIMIT_MEMLOCK, -1
-};
-
-int
-linux_alarm(struct proc *p, struct linux_alarm_args *args)
-{
- struct itimerval it, old_it;
- struct timeval tv;
- int s;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs);
-#endif
- if (args->secs > 100000000)
- return EINVAL;
- it.it_value.tv_sec = (long)args->secs;
- it.it_value.tv_usec = 0;
- it.it_interval.tv_sec = 0;
- it.it_interval.tv_usec = 0;
- s = splsoftclock();
- old_it = p->p_realtimer;
- getmicrouptime(&tv);
- if (timevalisset(&old_it.it_value))
- untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
- if (it.it_value.tv_sec != 0) {
- p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value));
- timevaladd(&it.it_value, &tv);
- }
- p->p_realtimer = it;
- splx(s);
- if (timevalcmp(&old_it.it_value, &tv, >)) {
- timevalsub(&old_it.it_value, &tv);
- if (old_it.it_value.tv_usec != 0)
- old_it.it_value.tv_sec++;
- p->p_retval[0] = old_it.it_value.tv_sec;
- }
- return 0;
-}
-
-int
-linux_brk(struct proc *p, struct linux_brk_args *args)
-{
-#if 0
- struct vmspace *vm = p->p_vmspace;
- vm_offset_t new, old;
- int error;
-
- if ((vm_offset_t)args->dsend < (vm_offset_t)vm->vm_daddr)
- return EINVAL;
- if (((caddr_t)args->dsend - (caddr_t)vm->vm_daddr)
- > p->p_rlimit[RLIMIT_DATA].rlim_cur)
- return ENOMEM;
-
- old = round_page((vm_offset_t)vm->vm_daddr) + ctob(vm->vm_dsize);
- new = round_page((vm_offset_t)args->dsend);
- p->p_retval[0] = old;
- if ((new-old) > 0) {
- if (swap_pager_full)
- return ENOMEM;
- error = vm_map_find(&vm->vm_map, NULL, 0, &old, (new-old), FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- return error;
- vm->vm_dsize += btoc((new-old));
- p->p_retval[0] = (int)(vm->vm_daddr + ctob(vm->vm_dsize));
- }
- return 0;
-#else
- struct vmspace *vm = p->p_vmspace;
- vm_offset_t new, old;
- struct obreak_args /* {
- char * nsize;
- } */ tmp;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): brk(%p)\n", (long)p->p_pid, (void *)args->dsend);
-#endif
- old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize);
- new = (vm_offset_t)args->dsend;
- tmp.nsize = (char *) new;
- if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp))
- p->p_retval[0] = (int)new;
- else
- p->p_retval[0] = (int)old;
-
- return 0;
-#endif
-}
-
-int
-linux_uselib(struct proc *p, struct linux_uselib_args *args)
-{
- struct nameidata ni;
- struct vnode *vp;
- struct exec *a_out;
- struct vattr attr;
- vm_offset_t vmaddr;
- unsigned long file_offset;
- vm_offset_t buffer;
- unsigned long bss_size;
- int error;
- caddr_t sg;
- int locked;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->library);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): uselib(%s)\n", (long)p->p_pid, args->library);
-#endif
-
- a_out = NULL;
- locked = 0;
- vp = NULL;
-
- NDINIT(&ni, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, args->library, p);
- error = namei(&ni);
- if (error)
- goto cleanup;
-
- vp = ni.ni_vp;
- /*
- * XXX This looks like a bogus check - a LOCKLEAF namei should not succeed
- * without returning a vnode.
- */
- if (vp == NULL) {
- error = ENOEXEC; /* ?? */
- goto cleanup;
- }
- NDFREE(&ni, NDF_ONLY_PNBUF);
-
- /*
- * From here on down, we have a locked vnode that must be unlocked.
- */
- locked++;
-
- /*
- * Writable?
- */
- if (vp->v_writecount) {
- error = ETXTBSY;
- goto cleanup;
- }
-
- /*
- * Executable?
- */
- error = VOP_GETATTR(vp, &attr, p->p_ucred, p);
- if (error)
- goto cleanup;
-
- if ((vp->v_mount->mnt_flag & MNT_NOEXEC) ||
- ((attr.va_mode & 0111) == 0) ||
- (attr.va_type != VREG)) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /*
- * Sensible size?
- */
- if (attr.va_size == 0) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /*
- * Can we access it?
- */
- error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
- if (error)
- goto cleanup;
-
- error = VOP_OPEN(vp, FREAD, p->p_ucred, p);
- if (error)
- goto cleanup;
-
- /*
- * Lock no longer needed
- */
- VOP_UNLOCK(vp, 0, p);
- locked = 0;
-
- /*
- * Pull in executable header into kernel_map
- */
- error = vm_mmap(kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE,
- VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, 0);
- if (error)
- goto cleanup;
-
- /*
- * Is it a Linux binary ?
- */
- if (((a_out->a_magic >> 16) & 0xff) != 0x64) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /* While we are here, we should REALLY do some more checks */
-
- /*
- * Set file/virtual offset based on a.out variant.
- */
- switch ((int)(a_out->a_magic & 0xffff)) {
- case 0413: /* ZMAGIC */
- file_offset = 1024;
- break;
- case 0314: /* QMAGIC */
- file_offset = 0;
- break;
- default:
- error = ENOEXEC;
- goto cleanup;
- }
-
- bss_size = round_page(a_out->a_bss);
-
- /*
- * Check various fields in header for validity/bounds.
- */
- if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /* text + data can't exceed file size */
- if (a_out->a_data + a_out->a_text > attr.va_size) {
- error = EFAULT;
- goto cleanup;
- }
-
- /*
- * text/data/bss must not exceed limits
- * XXX: this is not complete. it should check current usage PLUS
- * the resources needed by this library.
- */
- if (a_out->a_text > MAXTSIZ ||
- a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) {
- error = ENOMEM;
- goto cleanup;
- }
-
- /*
- * prevent more writers
- */
- vp->v_flag |= VTEXT;
-
- /*
- * Check if file_offset page aligned,.
- * Currently we cannot handle misalinged file offsets,
- * and so we read in the entire image (what a waste).
- */
- if (file_offset & PAGE_MASK) {
-#ifdef DEBUG
-printf("uselib: Non page aligned binary %lu\n", file_offset);
-#endif
- /*
- * Map text+data read/write/execute
- */
-
- /* a_entry is the load address and is page aligned */
- vmaddr = trunc_page(a_out->a_entry);
-
- /* get anon user mapping, read+write+execute */
- error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
- a_out->a_text + a_out->a_data, FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- goto cleanup;
-
- /* map file into kernel_map */
- error = vm_mmap(kernel_map, &buffer,
- round_page(a_out->a_text + a_out->a_data + file_offset),
- VM_PROT_READ, VM_PROT_READ, 0,
- (caddr_t)vp, trunc_page(file_offset));
- if (error)
- goto cleanup;
-
- /* copy from kernel VM space to user space */
- error = copyout((caddr_t)(void *)(uintptr_t)(buffer + file_offset),
- (caddr_t)vmaddr, a_out->a_text + a_out->a_data);
-
- /* release temporary kernel space */
- vm_map_remove(kernel_map, buffer,
- buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
-
- if (error)
- goto cleanup;
- }
- else {
-#ifdef DEBUG
-printf("uselib: Page aligned binary %lu\n", file_offset);
-#endif
- /*
- * for QMAGIC, a_entry is 20 bytes beyond the load address
- * to skip the executable header
- */
- vmaddr = trunc_page(a_out->a_entry);
-
- /*
- * Map it all into the process's space as a single copy-on-write
- * "data" segment.
- */
- error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr,
- a_out->a_text + a_out->a_data,
- VM_PROT_ALL, VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED,
- (caddr_t)vp, file_offset);
- if (error)
- goto cleanup;
- }
-#ifdef DEBUG
-printf("mem=%08x = %08x %08x\n", vmaddr, ((int*)vmaddr)[0], ((int*)vmaddr)[1]);
-#endif
- if (bss_size != 0) {
- /*
- * Calculate BSS start address
- */
- vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + a_out->a_data;
-
- /*
- * allocate some 'anon' space
- */
- error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
- bss_size, FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- goto cleanup;
- }
-
-cleanup:
- /*
- * Unlock vnode if needed
- */
- if (locked)
- VOP_UNLOCK(vp, 0, p);
-
- /*
- * Release the kernel mapping.
- */
- if (a_out)
- vm_map_remove(kernel_map, (vm_offset_t)a_out, (vm_offset_t)a_out + PAGE_SIZE);
-
- return error;
-}
-
-int
-linux_newselect(struct proc *p, struct linux_newselect_args *args)
-{
- struct select_args bsa;
- struct timeval tv0, tv1, utv, *tvp;
- caddr_t sg;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newselect(%d, %p, %p, %p, %p)\n",
- (long)p->p_pid, args->nfds, (void *)args->readfds,
- (void *)args->writefds, (void *)args->exceptfds,
- (void *)args->timeout);
-#endif
- error = 0;
- bsa.nd = args->nfds;
- bsa.in = args->readfds;
- bsa.ou = args->writefds;
- bsa.ex = args->exceptfds;
- bsa.tv = args->timeout;
-
- /*
- * Store current time for computation of the amount of
- * time left.
- */
- if (args->timeout) {
- if ((error = copyin(args->timeout, &utv, sizeof(utv))))
- goto select_out;
-#ifdef DEBUG
- printf("Linux-emul(%ld): incoming timeout (%ld/%ld)\n",
- (long)p->p_pid, utv.tv_sec, utv.tv_usec);
-#endif
- if (itimerfix(&utv)) {
- /*
- * The timeval was invalid. Convert it to something
- * valid that will act as it does under Linux.
- */
- sg = stackgap_init();
- tvp = stackgap_alloc(&sg, sizeof(utv));
- utv.tv_sec += utv.tv_usec / 1000000;
- utv.tv_usec %= 1000000;
- if (utv.tv_usec < 0) {
- utv.tv_sec -= 1;
- utv.tv_usec += 1000000;
- }
- if (utv.tv_sec < 0)
- timevalclear(&utv);
- if ((error = copyout(&utv, tvp, sizeof(utv))))
- goto select_out;
- bsa.tv = tvp;
- }
- microtime(&tv0);
- }
-
- error = select(p, &bsa);
-#ifdef DEBUG
- printf("Linux-emul(%ld): real select returns %d\n", (long)p->p_pid, error);
-#endif
-
- if (error) {
- /*
- * See fs/select.c in the Linux kernel. Without this,
- * Maelstrom doesn't work.
- */
- if (error == ERESTART)
- error = EINTR;
- goto select_out;
- }
-
- if (args->timeout) {
- if (p->p_retval[0]) {
- /*
- * Compute how much time was left of the timeout,
- * by subtracting the current time and the time
- * before we started the call, and subtracting
- * that result from the user-supplied value.
- */
- microtime(&tv1);
- timevalsub(&tv1, &tv0);
- timevalsub(&utv, &tv1);
- if (utv.tv_sec < 0)
- timevalclear(&utv);
- } else
- timevalclear(&utv);
-#ifdef DEBUG
- printf("Linux-emul(%ld): outgoing timeout (%ld/%ld)\n",
- (long)p->p_pid, utv.tv_sec, utv.tv_usec);
-#endif
- if ((error = copyout(&utv, args->timeout, sizeof(utv))))
- goto select_out;
- }
-
-select_out:
-#ifdef DEBUG
- printf("Linux-emul(%ld): newselect_out -> %d\n", (long)p->p_pid, error);
-#endif
- return error;
-}
-
-int
-linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
-{
- struct proc *curp;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid);
-#endif
- if (args->pid != p->p_pid) {
- if (!(curp = pfind(args->pid)))
- return ESRCH;
- }
- else
- curp = p;
- p->p_retval[0] = curp->p_pgid;
- return 0;
-}
-
-int
-linux_mremap(struct proc *p, struct linux_mremap_args *args)
-{
- struct munmap_args /* {
- void *addr;
- size_t len;
- } */ bsd_args;
- int error = 0;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): mremap(%p, %08x, %08x, %08x)\n",
- (long)p->p_pid, (void *)args->addr, args->old_len, args->new_len,
- args->flags);
-#endif
- args->new_len = round_page(args->new_len);
- args->old_len = round_page(args->old_len);
-
- if (args->new_len > args->old_len) {
- p->p_retval[0] = 0;
- return ENOMEM;
- }
-
- if (args->new_len < args->old_len) {
- bsd_args.addr = args->addr + args->new_len;
- bsd_args.len = args->old_len - args->new_len;
- error = munmap(p, &bsd_args);
- }
-
- p->p_retval[0] = error ? 0 : (int)args->addr;
- return error;
-}
-
-int
-linux_msync(struct proc *p, struct linux_msync_args *args)
-{
- struct msync_args bsd_args;
-
- bsd_args.addr = args->addr;
- bsd_args.len = args->len;
- bsd_args.flags = 0; /* XXX ignore */
-
- return msync(p, &bsd_args);
-}
-
-int
-linux_time(struct proc *p, struct linux_time_args *args)
-{
- struct timeval tv;
- linux_time_t tm;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): time(*)\n", (long)p->p_pid);
-#endif
- microtime(&tv);
- tm = tv.tv_sec;
- if (args->tm && (error = copyout(&tm, args->tm, sizeof(linux_time_t))))
- return error;
- p->p_retval[0] = tm;
- return 0;
-}
-
-struct linux_times_argv {
- long tms_utime;
- long tms_stime;
- long tms_cutime;
- long tms_cstime;
-};
-
-#define CLK_TCK 100 /* Linux uses 100 */
-#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
-
-int
-linux_times(struct proc *p, struct linux_times_args *args)
-{
- struct timeval tv;
- struct linux_times_argv tms;
- struct rusage ru;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid);
-#endif
- calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
-
- tms.tms_utime = CONVTCK(ru.ru_utime);
- tms.tms_stime = CONVTCK(ru.ru_stime);
-
- tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime);
- tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime);
-
- if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf,
- sizeof(struct linux_times_argv))))
- return error;
-
- microuptime(&tv);
- p->p_retval[0] = (int)CONVTCK(tv);
- return 0;
-}
-
-int
-linux_newuname(struct proc *p, struct linux_newuname_args *args)
-{
- struct linux_new_utsname utsname;
- char *osrelease, *osname;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid);
-#endif
-
- osname = linux_get_osname(p);
- osrelease = linux_get_osrelease(p);
-
- bzero(&utsname, sizeof(struct linux_new_utsname));
- strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1);
-
- return (copyout((caddr_t)&utsname, (caddr_t)args->buf,
- sizeof(struct linux_new_utsname)));
-}
-
-struct linux_utimbuf {
- linux_time_t l_actime;
- linux_time_t l_modtime;
-};
-
-int
-linux_utime(struct proc *p, struct linux_utime_args *args)
-{
- struct utimes_args /* {
- char *path;
- struct timeval *tptr;
- } */ bsdutimes;
- struct timeval tv[2], *tvp;
- struct linux_utimbuf lut;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->fname);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): utime(%s, *)\n", (long)p->p_pid, args->fname);
-#endif
- if (args->times) {
- if ((error = copyin(args->times, &lut, sizeof lut)))
- return error;
- tv[0].tv_sec = lut.l_actime;
- tv[0].tv_usec = 0;
- tv[1].tv_sec = lut.l_modtime;
- tv[1].tv_usec = 0;
- /* so that utimes can copyin */
- tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv));
- if (tvp == NULL)
- return (ENAMETOOLONG);
- if ((error = copyout(tv, tvp, sizeof(tv))))
- return error;
- bsdutimes.tptr = tvp;
- } else
- bsdutimes.tptr = NULL;
-
- bsdutimes.path = args->fname;
- return utimes(p, &bsdutimes);
-}
-
-#define __WCLONE 0x80000000
-
-int
-linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
-{
- struct wait_args /* {
- int pid;
- int *status;
- int options;
- struct rusage *rusage;
- } */ tmp;
- int error, tmpstat;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): waitpid(%d, %p, %d)\n",
- (long)p->p_pid, args->pid, (void *)args->status, args->options);
-#endif
- tmp.pid = args->pid;
- tmp.status = args->status;
- tmp.options = (args->options & (WNOHANG | WUNTRACED));
- /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
- if (args->options & __WCLONE)
- tmp.options |= WLINUXCLONE;
- tmp.rusage = NULL;
-
- if ((error = wait4(p, &tmp)) != 0)
- return error;
-
- if (args->status) {
- if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0)
- return error;
- tmpstat &= 0xffff;
- if (WIFSIGNALED(tmpstat))
- tmpstat = (tmpstat & 0xffffff80) |
- BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
- else if (WIFSTOPPED(tmpstat))
- tmpstat = (tmpstat & 0xffff00ff) |
- (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
- return copyout(&tmpstat, args->status, sizeof(int));
- } else
- return 0;
-}
-
-int
-linux_wait4(struct proc *p, struct linux_wait4_args *args)
-{
- struct wait_args /* {
- int pid;
- int *status;
- int options;
- struct rusage *rusage;
- } */ tmp;
- int error, tmpstat;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): wait4(%d, %p, %d, %p)\n",
- (long)p->p_pid, args->pid, (void *)args->status, args->options,
- (void *)args->rusage);
-#endif
- tmp.pid = args->pid;
- tmp.status = args->status;
- tmp.options = (args->options & (WNOHANG | WUNTRACED));
- /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
- if (args->options & __WCLONE)
- tmp.options |= WLINUXCLONE;
- tmp.rusage = args->rusage;
-
- if ((error = wait4(p, &tmp)) != 0)
- return error;
-
- SIGDELSET(p->p_siglist, SIGCHLD);
-
- if (args->status) {
- if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0)
- return error;
- tmpstat &= 0xffff;
- if (WIFSIGNALED(tmpstat))
- tmpstat = (tmpstat & 0xffffff80) |
- BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
- else if (WIFSTOPPED(tmpstat))
- tmpstat = (tmpstat & 0xffff00ff) |
- (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
- return copyout(&tmpstat, args->status, sizeof(int));
- } else
- return 0;
-}
-
-int
-linux_mknod(struct proc *p, struct linux_mknod_args *args)
-{
- caddr_t sg;
- struct mknod_args bsd_mknod;
- struct mkfifo_args bsd_mkfifo;
-
- sg = stackgap_init();
-
- CHECKALTCREAT(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): mknod(%s, %d, %d)\n",
- (long)p->p_pid, args->path, args->mode, args->dev);
-#endif
-
- if (args->mode & S_IFIFO) {
- bsd_mkfifo.path = args->path;
- bsd_mkfifo.mode = args->mode;
- return mkfifo(p, &bsd_mkfifo);
- } else {
- bsd_mknod.path = args->path;
- bsd_mknod.mode = args->mode;
- bsd_mknod.dev = args->dev;
- return mknod(p, &bsd_mknod);
- }
-}
-
-/*
- * UGH! This is just about the dumbest idea I've ever heard!!
- */
-int
-linux_personality(struct proc *p, struct linux_personality_args *args)
-{
-#ifdef DEBUG
- printf("Linux-emul(%ld): personality(%d)\n",
- (long)p->p_pid, args->per);
-#endif
- if (args->per != 0)
- return EINVAL;
-
- /* Yes Jim, it's still a Linux... */
- p->p_retval[0] = 0;
- return 0;
-}
-
-/*
- * Wrappers for get/setitimer for debugging..
- */
-int
-linux_setitimer(struct proc *p, struct linux_setitimer_args *args)
-{
- struct setitimer_args bsa;
- struct itimerval foo;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): setitimer(%p, %p)\n",
- (long)p->p_pid, (void *)args->itv, (void *)args->oitv);
-#endif
- bsa.which = args->which;
- bsa.itv = args->itv;
- bsa.oitv = args->oitv;
- if (args->itv) {
- if ((error = copyin((caddr_t)args->itv, (caddr_t)&foo,
- sizeof(foo))))
- return error;
-#ifdef DEBUG
- printf("setitimer: value: sec: %ld, usec: %ld\n",
- foo.it_value.tv_sec, foo.it_value.tv_usec);
- printf("setitimer: interval: sec: %ld, usec: %ld\n",
- foo.it_interval.tv_sec, foo.it_interval.tv_usec);
-#endif
- }
- return setitimer(p, &bsa);
-}
-
-int
-linux_getitimer(struct proc *p, struct linux_getitimer_args *args)
-{
- struct getitimer_args bsa;
-#ifdef DEBUG
- printf("Linux-emul(%ld): getitimer(%p)\n",
- (long)p->p_pid, (void *)args->itv);
-#endif
- bsa.which = args->which;
- bsa.itv = args->itv;
- return getitimer(p, &bsa);
-}
-
-int
-linux_nice(struct proc *p, struct linux_nice_args *args)
-{
- struct setpriority_args bsd_args;
-
- bsd_args.which = PRIO_PROCESS;
- bsd_args.who = 0; /* current process */
- bsd_args.prio = args->inc;
- return setpriority(p, &bsd_args);
-}
-
-int
-linux_setgroups(p, uap)
- struct proc *p;
- struct linux_setgroups_args *uap;
-{
- struct pcred *pc;
- linux_gid_t linux_gidset[NGROUPS];
- gid_t *bsd_gidset;
- int ngrp, error;
-
- pc = p->p_cred;
- ngrp = uap->gidsetsize;
-
- /*
- * cr_groups[0] holds egid. Setting the whole set from
- * the supplied set will cause egid to be changed too.
- * Keep cr_groups[0] unchanged to prevent that.
- */
-
- if ((error = suser(p)) != 0)
- return (error);
-
- if (ngrp >= NGROUPS)
- return (EINVAL);
-
- pc->pc_ucred = crcopy(pc->pc_ucred);
- if (ngrp > 0) {
- error = copyin((caddr_t)uap->gidset, (caddr_t)linux_gidset,
- ngrp * sizeof(linux_gid_t));
- if (error)
- return (error);
-
- pc->pc_ucred->cr_ngroups = ngrp + 1;
-
- bsd_gidset = pc->pc_ucred->cr_groups;
- ngrp--;
- while (ngrp >= 0) {
- bsd_gidset[ngrp + 1] = linux_gidset[ngrp];
- ngrp--;
- }
- }
- else
- pc->pc_ucred->cr_ngroups = 1;
-
- setsugid(p);
- return (0);
-}
-
-int
-linux_getgroups(p, uap)
- struct proc *p;
- struct linux_getgroups_args *uap;
-{
- struct pcred *pc;
- linux_gid_t linux_gidset[NGROUPS];
- gid_t *bsd_gidset;
- int bsd_gidsetsz, ngrp, error;
-
- pc = p->p_cred;
- bsd_gidset = pc->pc_ucred->cr_groups;
- bsd_gidsetsz = pc->pc_ucred->cr_ngroups - 1;
-
- /*
- * cr_groups[0] holds egid. Returning the whole set
- * here will cause a duplicate. Exclude cr_groups[0]
- * to prevent that.
- */
-
- if ((ngrp = uap->gidsetsize) == 0) {
- p->p_retval[0] = bsd_gidsetsz;
- return (0);
- }
-
- if (ngrp < bsd_gidsetsz)
- return (EINVAL);
-
- ngrp = 0;
- while (ngrp < bsd_gidsetsz) {
- linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
- ngrp++;
- }
-
- if ((error = copyout((caddr_t)linux_gidset, (caddr_t)uap->gidset,
- ngrp * sizeof(linux_gid_t))))
- return (error);
-
- p->p_retval[0] = ngrp;
- return (0);
-}
-
-int
-linux_setrlimit(p, uap)
- struct proc *p;
- struct linux_setrlimit_args *uap;
-{
- struct __setrlimit_args bsd;
- struct linux_rlimit rlim;
- int error;
- caddr_t sg = stackgap_init();
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): setrlimit(%d, %p)\n", (long)p->p_pid,
- uap->resource, (void *)uap->rlim);
-#endif
-
- if (uap->resource >= LINUX_RLIM_NLIMITS)
- return (EINVAL);
-
- bsd.which = linux_to_bsd_resource[uap->resource];
- if (bsd.which == -1)
- return (EINVAL);
-
- error = copyin(uap->rlim, &rlim, sizeof(rlim));
- if (error)
- return (error);
-
- bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
- bsd.rlp->rlim_cur = (rlim_t)rlim.rlim_cur;
- bsd.rlp->rlim_max = (rlim_t)rlim.rlim_max;
- return (setrlimit(p, &bsd));
-}
-
-int
-linux_getrlimit(p, uap)
- struct proc *p;
- struct linux_getrlimit_args *uap;
-{
- struct __getrlimit_args bsd;
- struct linux_rlimit rlim;
- int error;
- caddr_t sg = stackgap_init();
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): getrlimit(%d, %p)\n", (long)p->p_pid,
- uap->resource, (void *)uap->rlim);
-#endif
-
- if (uap->resource >= LINUX_RLIM_NLIMITS)
- return (EINVAL);
-
- bsd.which = linux_to_bsd_resource[uap->resource];
- if (bsd.which == -1)
- return (EINVAL);
-
- bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
- error = getrlimit(p, &bsd);
- if (error)
- return (error);
-
- rlim.rlim_cur = (unsigned long)bsd.rlp->rlim_cur;
- if (rlim.rlim_cur == ULONG_MAX)
- rlim.rlim_cur = LONG_MAX;
- rlim.rlim_max = (unsigned long)bsd.rlp->rlim_max;
- if (rlim.rlim_max == ULONG_MAX)
- rlim.rlim_max = LONG_MAX;
- return (copyout(&rlim, uap->rlim, sizeof(rlim)));
-}
-
-int
-linux_sched_setscheduler(p, uap)
- struct proc *p;
- struct linux_sched_setscheduler_args *uap;
-{
- struct sched_setscheduler_args bsd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sched_setscheduler(%d, %d, %p)\n",
- (long)p->p_pid, uap->pid, uap->policy, (const void *)uap->param);
-#endif
-
- switch (uap->policy) {
- case LINUX_SCHED_OTHER:
- bsd.policy = SCHED_OTHER;
- break;
- case LINUX_SCHED_FIFO:
- bsd.policy = SCHED_FIFO;
- break;
- case LINUX_SCHED_RR:
- bsd.policy = SCHED_RR;
- break;
- default:
- return EINVAL;
- }
-
- bsd.pid = uap->pid;
- bsd.param = uap->param;
- return sched_setscheduler(p, &bsd);
-}
-
-int
-linux_sched_getscheduler(p, uap)
- struct proc *p;
- struct linux_sched_getscheduler_args *uap;
-{
- struct sched_getscheduler_args bsd;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sched_getscheduler(%d)\n",
- (long)p->p_pid, uap->pid);
-#endif
-
- bsd.pid = uap->pid;
- error = sched_getscheduler(p, &bsd);
-
- switch (p->p_retval[0]) {
- case SCHED_OTHER:
- p->p_retval[0] = LINUX_SCHED_OTHER;
- break;
- case SCHED_FIFO:
- p->p_retval[0] = LINUX_SCHED_FIFO;
- break;
- case SCHED_RR:
- p->p_retval[0] = LINUX_SCHED_RR;
- break;
- }
-
- return error;
-}
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
deleted file mode 100644
index bdbe4d4d824d6..0000000000000
--- a/sys/compat/linux/linux_signal.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * Copyright (c) 2000 Marcel Moolenaar
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_SIGNAL_H_
-#define _LINUX_SIGNAL_H_
-
-void linux_to_bsd_sigset __P((linux_sigset_t *, sigset_t *));
-
-int linux_do_sigaction __P((struct proc *, int, linux_sigaction_t *,
- linux_sigaction_t *));
-
-#endif /* _LINUX_SIGNAL_H_ */
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
deleted file mode 100644
index b7c9b7da84600..0000000000000
--- a/sys/compat/linux/linux_socket.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/*-
- * Copyright (c) 1995 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.
- *
- * $FreeBSD$
- */
-
-/* XXX we use functions that might not exist. */
-#include "opt_compat.h"
-
-#ifndef COMPAT_43
-#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
-#endif
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-
-#include <machine/../linux/linux.h>
-#include <machine/../linux/linux_proto.h>
-#include <compat/linux/linux_util.h>
-
-static int
-linux_to_bsd_domain(int domain)
-{
-
- switch (domain) {
- case LINUX_AF_UNSPEC:
- return (AF_UNSPEC);
- case LINUX_AF_UNIX:
- return (AF_LOCAL);
- case LINUX_AF_INET:
- return (AF_INET);
- case LINUX_AF_AX25:
- return (AF_CCITT);
- case LINUX_AF_IPX:
- return (AF_IPX);
- case LINUX_AF_APPLETALK:
- return (AF_APPLETALK);
- }
- return (-1);
-}
-
-static int
-linux_to_bsd_sockopt_level(int level)
-{
-
- switch (level) {
- case LINUX_SOL_SOCKET:
- return (SOL_SOCKET);
- }
- return (level);
-}
-
-static int
-linux_to_bsd_ip_sockopt(int opt)
-{
-
- switch (opt) {
- case LINUX_IP_TOS:
- return (IP_TOS);
- case LINUX_IP_TTL:
- return (IP_TTL);
- case LINUX_IP_OPTIONS:
- return (IP_OPTIONS);
- case LINUX_IP_MULTICAST_IF:
- return (IP_MULTICAST_IF);
- case LINUX_IP_MULTICAST_TTL:
- return (IP_MULTICAST_TTL);
- case LINUX_IP_MULTICAST_LOOP:
- return (IP_MULTICAST_LOOP);
- case LINUX_IP_ADD_MEMBERSHIP:
- return (IP_ADD_MEMBERSHIP);
- case LINUX_IP_DROP_MEMBERSHIP:
- return (IP_DROP_MEMBERSHIP);
- case LINUX_IP_HDRINCL:
- return (IP_HDRINCL);
- }
- return (-1);
-}
-
-static int
-linux_to_bsd_so_sockopt(int opt)
-{
-
- switch (opt) {
- case LINUX_SO_DEBUG:
- return (SO_DEBUG);
- case LINUX_SO_REUSEADDR:
- return (SO_REUSEADDR);
- case LINUX_SO_TYPE:
- return (SO_TYPE);
- case LINUX_SO_ERROR:
- return (SO_ERROR);
- case LINUX_SO_DONTROUTE:
- return (SO_DONTROUTE);
- case LINUX_SO_BROADCAST:
- return (SO_BROADCAST);
- case LINUX_SO_SNDBUF:
- return (SO_SNDBUF);
- case LINUX_SO_RCVBUF:
- return (SO_RCVBUF);
- case LINUX_SO_KEEPALIVE:
- return (SO_KEEPALIVE);
- case LINUX_SO_OOBINLINE:
- return (SO_OOBINLINE);
- case LINUX_SO_LINGER:
- return (SO_LINGER);
- }
- return (-1);
-}
-
-/* Return 0 if IP_HDRINCL is set for the given socket. */
-static int
-linux_check_hdrincl(struct proc *p, int s)
-{
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int *avalsize;
- } */ bsd_args;
- int error;
- caddr_t sg, val, valsize;
- int size_val = sizeof val;
- int optval;
-
- sg = stackgap_init();
- val = stackgap_alloc(&sg, sizeof(int));
- valsize = stackgap_alloc(&sg, sizeof(int));
-
- if ((error = copyout(&size_val, valsize, sizeof(size_val))))
- return (error);
-
- bsd_args.s = s;
- bsd_args.level = IPPROTO_IP;
- bsd_args.name = IP_HDRINCL;
- bsd_args.val = val;
- bsd_args.avalsize = (int *)valsize;
- if ((error = getsockopt(p, &bsd_args)))
- return (error);
-
- if ((error = copyin(val, &optval, sizeof(optval))))
- return (error);
-
- return (optval == 0);
-}
-
-/*
- * Updated sendto() when IP_HDRINCL is set:
- * tweak endian-dependent fields in the IP packet.
- */
-static int
-linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args)
-{
-/*
- * linux_ip_copysize defines how many bytes we should copy
- * from the beginning of the IP packet before we customize it for BSD.
- * It should include all the fields we modify (ip_len and ip_off)
- * and be as small as possible to minimize copying overhead.
- */
-#define linux_ip_copysize 8
-
- caddr_t sg;
- struct ip *packet;
- struct msghdr *msg;
- struct iovec *iov;
-
- int error;
- struct sendmsg_args /* {
- int s;
- caddr_t msg;
- int flags;
- } */ sendmsg_args;
-
- /* Check the packet isn't too small before we mess with it */
- if (bsd_args->len < linux_ip_copysize)
- return (EINVAL);
-
- /*
- * Tweaking the user buffer in place would be bad manners.
- * We create a corrected IP header with just the needed length,
- * then use an iovec to glue it to the rest of the user packet
- * when calling sendmsg().
- */
- sg = stackgap_init();
- packet = (struct ip *)stackgap_alloc(&sg, linux_ip_copysize);
- msg = (struct msghdr *)stackgap_alloc(&sg, sizeof(*msg));
- iov = (struct iovec *)stackgap_alloc(&sg, sizeof(*iov)*2);
-
- /* Make a copy of the beginning of the packet to be sent */
- if ((error = copyin(bsd_args->buf, packet, linux_ip_copysize)))
- return (error);
-
- /* Convert fields from Linux to BSD raw IP socket format */
- packet->ip_len = bsd_args->len;
- packet->ip_off = ntohs(packet->ip_off);
-
- /* Prepare the msghdr and iovec structures describing the new packet */
- msg->msg_name = bsd_args->to;
- msg->msg_namelen = bsd_args->tolen;
- msg->msg_iov = iov;
- msg->msg_iovlen = 2;
- msg->msg_control = NULL;
- msg->msg_controllen = 0;
- msg->msg_flags = 0;
- iov[0].iov_base = (char *)packet;
- iov[0].iov_len = linux_ip_copysize;
- iov[1].iov_base = (char *)(bsd_args->buf) + linux_ip_copysize;
- iov[1].iov_len = bsd_args->len - linux_ip_copysize;
-
- sendmsg_args.s = bsd_args->s;
- sendmsg_args.msg = (caddr_t)msg;
- sendmsg_args.flags = bsd_args->flags;
- return (sendmsg(p, &sendmsg_args));
-}
-
-struct linux_socket_args {
- int domain;
- int type;
- int protocol;
-};
-
-static int
-linux_socket(struct proc *p, struct linux_socket_args *args)
-{
- struct linux_socket_args linux_args;
- struct socket_args /* {
- int domain;
- int type;
- int protocol;
- } */ bsd_args;
- int error;
- int retval_socket;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.protocol = linux_args.protocol;
- bsd_args.type = linux_args.type;
- bsd_args.domain = linux_to_bsd_domain(linux_args.domain);
- if (bsd_args.domain == -1)
- return (EINVAL);
-
- retval_socket = socket(p, &bsd_args);
- if (bsd_args.type == SOCK_RAW
- && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
- && bsd_args.domain == AF_INET
- && retval_socket >= 0) {
- /* It's a raw IP socket: set the IP_HDRINCL option. */
- struct setsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
- } */ bsd_setsockopt_args;
- caddr_t sg;
- int *hdrincl;
-
- sg = stackgap_init();
- hdrincl = (int *)stackgap_alloc(&sg, sizeof(*hdrincl));
- *hdrincl = 1;
- bsd_setsockopt_args.s = p->p_retval[0];
- bsd_setsockopt_args.level = IPPROTO_IP;
- bsd_setsockopt_args.name = IP_HDRINCL;
- bsd_setsockopt_args.val = (caddr_t)hdrincl;
- bsd_setsockopt_args.valsize = sizeof(*hdrincl);
- /* We ignore any error returned by setsockopt() */
- setsockopt(p, &bsd_setsockopt_args);
- /* Copy back the return value from socket() */
- p->p_retval[0] = bsd_setsockopt_args.s;
- }
-
- return (retval_socket);
-}
-
-struct linux_bind_args {
- int s;
- struct sockaddr *name;
- int namelen;
-};
-
-static int
-linux_bind(struct proc *p, struct linux_bind_args *args)
-{
- struct linux_bind_args linux_args;
- struct bind_args /* {
- int s;
- caddr_t name;
- int namelen;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.name = (caddr_t)linux_args.name;
- bsd_args.namelen = linux_args.namelen;
- return (bind(p, &bsd_args));
-}
-
-struct linux_connect_args {
- int s;
- struct sockaddr * name;
- int namelen;
-};
-
-static int
-linux_connect(struct proc *p, struct linux_connect_args *args)
-{
- struct linux_connect_args linux_args;
- struct connect_args /* {
- int s;
- caddr_t name;
- int namelen;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.name = (caddr_t)linux_args.name;
- bsd_args.namelen = linux_args.namelen;
- error = connect(p, &bsd_args);
- if (error == EISCONN) {
- /*
- * Linux doesn't return EISCONN the first time it occurs,
- * when on a non-blocking socket. Instead it returns the
- * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD.
- */
- struct fcntl_args /* {
- int fd;
- int cmd;
- int arg;
- } */ bsd_fcntl_args;
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int *avalsize;
- } */ bsd_getsockopt_args;
- void *status, *statusl;
- int stat, statl = sizeof stat;
- caddr_t sg;
-
- /* Check for non-blocking */
- bsd_fcntl_args.fd = linux_args.s;
- bsd_fcntl_args.cmd = F_GETFL;
- bsd_fcntl_args.arg = 0;
- error = fcntl(p, &bsd_fcntl_args);
- if (error == 0 && (p->p_retval[0] & O_NONBLOCK)) {
- sg = stackgap_init();
- status = stackgap_alloc(&sg, sizeof stat);
- statusl = stackgap_alloc(&sg, sizeof statusl);
-
- if ((error = copyout(&statl, statusl, sizeof statl)))
- return (error);
-
- bsd_getsockopt_args.s = linux_args.s;
- bsd_getsockopt_args.level = SOL_SOCKET;
- bsd_getsockopt_args.name = SO_ERROR;
- bsd_getsockopt_args.val = status;
- bsd_getsockopt_args.avalsize = statusl;
-
- error = getsockopt(p, &bsd_getsockopt_args);
- if (error)
- return (error);
-
- if ((error = copyin(status, &stat, sizeof stat)))
- return (error);
-
- p->p_retval[0] = stat;
- return (0);
- }
- }
-
- return (error);
-}
-
-struct linux_listen_args {
- int s;
- int backlog;
-};
-
-static int
-linux_listen(struct proc *p, struct linux_listen_args *args)
-{
- struct linux_listen_args linux_args;
- struct listen_args /* {
- int s;
- int backlog;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.backlog = linux_args.backlog;
- return (listen(p, &bsd_args));
-}
-
-struct linux_accept_args {
- int s;
- struct sockaddr *addr;
- int *namelen;
-};
-
-static int
-linux_accept(struct proc *p, struct linux_accept_args *args)
-{
- struct linux_accept_args linux_args;
- struct accept_args /* {
- int s;
- caddr_t name;
- int *anamelen;
- } */ bsd_args;
- struct fcntl_args /* {
- int fd;
- int cmd;
- long arg;
- } */ f_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.name = (caddr_t)linux_args.addr;
- bsd_args.anamelen = linux_args.namelen;
- error = oaccept(p, &bsd_args);
- if (error)
- return (error);
-
- /*
- * linux appears not to copy flags from the parent socket to the
- * accepted one, so we must clear the flags in the new descriptor.
- * Ignore any errors, because we already have an open fd.
- */
- f_args.fd = p->p_retval[0];
- f_args.cmd = F_SETFL;
- f_args.arg = 0;
- (void)fcntl(p, &f_args);
- p->p_retval[0] = f_args.fd;
- return (0);
-}
-
-struct linux_getsockname_args {
- int s;
- struct sockaddr *addr;
- int *namelen;
-};
-
-static int
-linux_getsockname(struct proc *p, struct linux_getsockname_args *args)
-{
- struct linux_getsockname_args linux_args;
- struct getsockname_args /* {
- int fdes;
- caddr_t asa;
- int *alen;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.fdes = linux_args.s;
- bsd_args.asa = (caddr_t) linux_args.addr;
- bsd_args.alen = linux_args.namelen;
- return (ogetsockname(p, &bsd_args));
-}
-
-struct linux_getpeername_args {
- int s;
- struct sockaddr *addr;
- int *namelen;
-};
-
-static int
-linux_getpeername(struct proc *p, struct linux_getpeername_args *args)
-{
- struct linux_getpeername_args linux_args;
- struct ogetpeername_args /* {
- int fdes;
- caddr_t asa;
- int *alen;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.fdes = linux_args.s;
- bsd_args.asa = (caddr_t) linux_args.addr;
- bsd_args.alen = linux_args.namelen;
- return (ogetpeername(p, &bsd_args));
-}
-
-struct linux_socketpair_args {
- int domain;
- int type;
- int protocol;
- int *rsv;
-};
-
-static int
-linux_socketpair(struct proc *p, struct linux_socketpair_args *args)
-{
- struct linux_socketpair_args linux_args;
- struct socketpair_args /* {
- int domain;
- int type;
- int protocol;
- int *rsv;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.domain = linux_to_bsd_domain(linux_args.domain);
- if (bsd_args.domain == -1)
- return (EINVAL);
-
- bsd_args.type = linux_args.type;
- bsd_args.protocol = linux_args.protocol;
- bsd_args.rsv = linux_args.rsv;
- return (socketpair(p, &bsd_args));
-}
-
-struct linux_send_args {
- int s;
- void *msg;
- int len;
- int flags;
-};
-
-static int
-linux_send(struct proc *p, struct linux_send_args *args)
-{
- struct linux_send_args linux_args;
- struct osend_args /* {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.msg;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- return (osend(p, &bsd_args));
-}
-
-struct linux_recv_args {
- int s;
- void *msg;
- int len;
- int flags;
-};
-
-static int
-linux_recv(struct proc *p, struct linux_recv_args *args)
-{
- struct linux_recv_args linux_args;
- struct orecv_args /* {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.msg;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- return (orecv(p, &bsd_args));
-}
-
-struct linux_sendto_args {
- int s;
- void *msg;
- int len;
- int flags;
- caddr_t to;
- int tolen;
-};
-
-static int
-linux_sendto(struct proc *p, struct linux_sendto_args *args)
-{
- struct linux_sendto_args linux_args;
- struct sendto_args /* {
- int s;
- caddr_t buf;
- size_t len;
- int flags;
- caddr_t to;
- int tolen;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.msg;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- bsd_args.to = linux_args.to;
- bsd_args.tolen = linux_args.tolen;
-
- if (linux_check_hdrincl(p, linux_args.s) == 0)
- /* IP_HDRINCL set, tweak the packet before sending */
- return (linux_sendto_hdrincl(p, &bsd_args));
-
- return (sendto(p, &bsd_args));
-}
-
-struct linux_recvfrom_args {
- int s;
- void *buf;
- int len;
- int flags;
- caddr_t from;
- int *fromlen;
-};
-
-static int
-linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args)
-{
- struct linux_recvfrom_args linux_args;
- struct recvfrom_args /* {
- int s;
- caddr_t buf;
- size_t len;
- int flags;
- caddr_t from;
- int *fromlenaddr;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.buf;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- bsd_args.from = linux_args.from;
- bsd_args.fromlenaddr = linux_args.fromlen;
- return (orecvfrom(p, &bsd_args));
-}
-
-struct linux_shutdown_args {
- int s;
- int how;
-};
-
-static int
-linux_shutdown(struct proc *p, struct linux_shutdown_args *args)
-{
- struct linux_shutdown_args linux_args;
- struct shutdown_args /* {
- int s;
- int how;
- } */ bsd_args;
- int error;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.how = linux_args.how;
- return (shutdown(p, &bsd_args));
-}
-
-struct linux_setsockopt_args {
- int s;
- int level;
- int optname;
- void *optval;
- int optlen;
-};
-
-static int
-linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args)
-{
- struct linux_setsockopt_args linux_args;
- struct setsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
- } */ bsd_args;
- int error, name;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.level = linux_to_bsd_sockopt_level(linux_args.level);
- switch (bsd_args.level) {
- case SOL_SOCKET:
- name = linux_to_bsd_so_sockopt(linux_args.optname);
- break;
- case IPPROTO_IP:
- name = linux_to_bsd_ip_sockopt(linux_args.optname);
- break;
- case IPPROTO_TCP:
- /* Linux TCP option values match BSD's */
- name = linux_args.optname;
- break;
- default:
- name = -1;
- break;
- }
- if (name == -1)
- return (EINVAL);
-
- bsd_args.name = name;
- bsd_args.val = linux_args.optval;
- bsd_args.valsize = linux_args.optlen;
- return (setsockopt(p, &bsd_args));
-}
-
-struct linux_getsockopt_args {
- int s;
- int level;
- int optname;
- void *optval;
- int *optlen;
-};
-
-static int
-linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args)
-{
- struct linux_getsockopt_args linux_args;
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int *avalsize;
- } */ bsd_args;
- int error, name;
-
- if ((error = copyin(args, &linux_args, sizeof(linux_args))))
- return (error);
-
- bsd_args.s = linux_args.s;
- bsd_args.level = linux_to_bsd_sockopt_level(linux_args.level);
- switch (bsd_args.level) {
- case SOL_SOCKET:
- name = linux_to_bsd_so_sockopt(linux_args.optname);
- break;
- case IPPROTO_IP:
- name = linux_to_bsd_ip_sockopt(linux_args.optname);
- break;
- case IPPROTO_TCP:
- /* Linux TCP option values match BSD's */
- name = linux_args.optname;
- break;
- default:
- name = -1;
- break;
- }
- if (name == -1)
- return (EINVAL);
-
- bsd_args.name = name;
- bsd_args.val = linux_args.optval;
- bsd_args.avalsize = linux_args.optlen;
- return (getsockopt(p, &bsd_args));
-}
-
-int
-linux_socketcall(struct proc *p, struct linux_socketcall_args *args)
-{
-
- switch (args->what) {
- case LINUX_SOCKET:
- return (linux_socket(p, args->args));
- case LINUX_BIND:
- return (linux_bind(p, args->args));
- case LINUX_CONNECT:
- return (linux_connect(p, args->args));
- case LINUX_LISTEN:
- return (linux_listen(p, args->args));
- case LINUX_ACCEPT:
- return (linux_accept(p, args->args));
- case LINUX_GETSOCKNAME:
- return (linux_getsockname(p, args->args));
- case LINUX_GETPEERNAME:
- return (linux_getpeername(p, args->args));
- case LINUX_SOCKETPAIR:
- return (linux_socketpair(p, args->args));
- case LINUX_SEND:
- return (linux_send(p, args->args));
- case LINUX_RECV:
- return (linux_recv(p, args->args));
- case LINUX_SENDTO:
- return (linux_sendto(p, args->args));
- case LINUX_RECVFROM:
- return (linux_recvfrom(p, args->args));
- case LINUX_SHUTDOWN:
- return (linux_shutdown(p, args->args));
- case LINUX_SETSOCKOPT:
- return (linux_setsockopt(p, args->args));
- case LINUX_GETSOCKOPT:
- return (linux_getsockopt(p, args->args));
- case LINUX_SENDMSG:
- do {
- int error;
- int level;
- caddr_t control;
- struct {
- int s;
- const struct msghdr *msg;
- int flags;
- } *uap = args->args;
-
- error = copyin(&uap->msg->msg_control, &control,
- sizeof(caddr_t));
- if (error)
- return (error);
-
- if (control == NULL)
- goto done;
-
- error = copyin(&((struct cmsghdr*)control)->cmsg_level,
- &level, sizeof(int));
- if (error)
- return (error);
-
- if (level == 1) {
- /*
- * Linux thinks that SOL_SOCKET is 1; we know
- * that it's really 0xffff, of course.
- */
- level = SOL_SOCKET;
- error = copyout(&level,
- &((struct cmsghdr *)control)->cmsg_level,
- sizeof(int));
- if (error)
- return (error);
- }
- done:
- return (sendmsg(p, args->args));
- } while (0);
- case LINUX_RECVMSG:
- return (recvmsg(p, args->args));
- }
-
- uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what);
- return (ENOSYS);
-}
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
deleted file mode 100644
index 573cd74d251d4..0000000000000
--- a/sys/compat/linux/linux_stats.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/conf.h>
-#include <sys/dirent.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/stat.h>
-#include <sys/systm.h>
-#include <sys/vnode.h>
-
-#include <machine/../linux/linux.h>
-#include <machine/../linux/linux_proto.h>
-#include <compat/linux/linux_util.h>
-
-struct linux_newstat {
- u_short stat_dev;
- u_short __pad1;
- u_long stat_ino;
- u_short stat_mode;
- u_short stat_nlink;
- u_short stat_uid;
- u_short stat_gid;
- u_short stat_rdev;
- u_short __pad2;
- u_long stat_size;
- u_long stat_blksize;
- u_long stat_blocks;
- u_long stat_atime;
- u_long __unused1;
- u_long stat_mtime;
- u_long __unused2;
- u_long stat_ctime;
- u_long __unused3;
- u_long __unused4;
- u_long __unused5;
-};
-
-struct linux_ustat
-{
- int f_tfree;
- u_long f_tinode;
- char f_fname[6];
- char f_fpack[6];
-};
-
-static int
-newstat_copyout(struct stat *buf, void *ubuf)
-{
- struct linux_newstat tbuf;
-
- tbuf.stat_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8);
- 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;
- tbuf.stat_blksize = buf->st_blksize;
- tbuf.stat_blocks = buf->st_blocks;
-
- return (copyout(&tbuf, ubuf, sizeof(tbuf)));
-}
-
-int
-linux_newstat(struct proc *p, struct linux_newstat_args *args)
-{
- struct stat buf;
- struct nameidata nd;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newstat(%s, *)\n", (long)p->p_pid,
- args->path);
-#endif
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- args->path, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- error = vn_stat(nd.ni_vp, &buf, p);
- vput(nd.ni_vp);
- if (error)
- return (error);
-
- return (newstat_copyout(&buf, args->buf));
-}
-
-/*
- * Get file status; this version does not follow links.
- */
-int
-linux_newlstat(p, uap)
- struct proc *p;
- struct linux_newlstat_args *uap;
-{
- int error;
- struct vnode *vp;
- struct stat sb;
- struct nameidata nd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, uap->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newlstat(%s, *)\n", (long)p->p_pid,
- uap->path);
-#endif
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- uap->path, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- vp = nd.ni_vp;
- error = vn_stat(vp, &sb, p);
- vput(vp);
- if (error)
- return (error);
-
- return (newstat_copyout(&sb, uap->buf));
-}
-
-int
-linux_newfstat(struct proc *p, struct linux_newfstat_args *args)
-{
- struct filedesc *fdp;
- struct file *fp;
- struct stat buf;
- int error;
-
- fdp = p->p_fd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newfstat(%d, *)\n", (long)p->p_pid, args->fd);
-#endif
-
- if ((unsigned)args->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[args->fd]) == NULL)
- return (EBADF);
-
- error = fo_stat(fp, &buf, p);
- if (!error)
- error = newstat_copyout(&buf, args->buf);
-
- return (error);
-}
-
-struct linux_statfs_buf {
- long ftype;
- long fbsize;
- long fblocks;
- long fbfree;
- long fbavail;
- long ffiles;
- long fffree;
- linux_fsid_t ffsid;
- long fnamelen;
- long fspare[6];
-};
-
-#ifndef VT_NWFS
-#define VT_NWFS VT_TFS /* XXX - bug compatibility with sys/nwfs/nwfs_node.h */
-#endif
-
-#define LINUX_CODA_SUPER_MAGIC 0x73757245L
-#define LINUX_EXT2_SUPER_MAGIC 0xEF53L
-#define LINUX_HPFS_SUPER_MAGIC 0xf995e849L
-#define LINUX_ISOFS_SUPER_MAGIC 0x9660L
-#define LINUX_MSDOS_SUPER_MAGIC 0x4d44L
-#define LINUX_NCP_SUPER_MAGIC 0x564cL
-#define LINUX_NFS_SUPER_MAGIC 0x6969L
-#define LINUX_NTFS_SUPER_MAGIC 0x5346544EL
-#define LINUX_PROC_SUPER_MAGIC 0x9fa0L
-#define LINUX_UFS_SUPER_MAGIC 0x00011954L /* XXX - UFS_MAGIC in Linux */
-
-/*
- * ext2fs uses the VT_UFS tag. A mounted ext2 filesystem will therefore
- * be seen as an ufs/mfs filesystem.
- */
-static long
-bsd_to_linux_ftype(int tag)
-{
-
- switch (tag) {
- case VT_CODA:
- return (LINUX_CODA_SUPER_MAGIC);
- case VT_HPFS:
- return (LINUX_HPFS_SUPER_MAGIC);
- case VT_ISOFS:
- return (LINUX_ISOFS_SUPER_MAGIC);
- case VT_MFS:
- return (LINUX_UFS_SUPER_MAGIC);
- case VT_MSDOSFS:
- return (LINUX_MSDOS_SUPER_MAGIC);
- case VT_NFS:
- return (LINUX_NFS_SUPER_MAGIC);
- case VT_NTFS:
- return (LINUX_NTFS_SUPER_MAGIC);
- case VT_NWFS:
- return (LINUX_NCP_SUPER_MAGIC);
- case VT_PROCFS:
- return (LINUX_PROC_SUPER_MAGIC);
- case VT_UFS:
- return (LINUX_UFS_SUPER_MAGIC);
- }
-
- return (0L);
-}
-
-int
-linux_statfs(struct proc *p, struct linux_statfs_args *args)
-{
- struct mount *mp;
- struct nameidata *ndp;
- struct statfs *bsd_statfs;
- struct nameidata nd;
- struct linux_statfs_buf linux_statfs_buf;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): statfs(%s, *)\n", p->p_pid, args->path);
-#endif
- ndp = &nd;
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc);
- error = namei(ndp);
- if (error)
- return error;
- NDFREE(ndp, NDF_ONLY_PNBUF);
- mp = ndp->ni_vp->v_mount;
- bsd_statfs = &mp->mnt_stat;
- vrele(ndp->ni_vp);
- error = VFS_STATFS(mp, bsd_statfs, p);
- if (error)
- return error;
- bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- linux_statfs_buf.ftype = bsd_to_linux_ftype(bsd_statfs->f_type);
- linux_statfs_buf.fbsize = bsd_statfs->f_bsize;
- linux_statfs_buf.fblocks = bsd_statfs->f_blocks;
- linux_statfs_buf.fbfree = bsd_statfs->f_bfree;
- linux_statfs_buf.fbavail = bsd_statfs->f_bavail;
- linux_statfs_buf.fffree = bsd_statfs->f_ffree;
- linux_statfs_buf.ffiles = bsd_statfs->f_files;
- linux_statfs_buf.ffsid.val[0] = bsd_statfs->f_fsid.val[0];
- linux_statfs_buf.ffsid.val[1] = bsd_statfs->f_fsid.val[1];
- linux_statfs_buf.fnamelen = MAXNAMLEN;
- return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf,
- sizeof(struct linux_statfs_buf));
-}
-
-int
-linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args)
-{
- struct file *fp;
- struct mount *mp;
- struct statfs *bsd_statfs;
- struct linux_statfs_buf linux_statfs_buf;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): fstatfs(%d, *)\n", p->p_pid, args->fd);
-#endif
- error = getvnode(p->p_fd, args->fd, &fp);
- if (error)
- return error;
- mp = ((struct vnode *)fp->f_data)->v_mount;
- bsd_statfs = &mp->mnt_stat;
- error = VFS_STATFS(mp, bsd_statfs, p);
- if (error)
- return error;
- bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- linux_statfs_buf.ftype = bsd_to_linux_ftype(bsd_statfs->f_type);
- linux_statfs_buf.fbsize = bsd_statfs->f_bsize;
- linux_statfs_buf.fblocks = bsd_statfs->f_blocks;
- linux_statfs_buf.fbfree = bsd_statfs->f_bfree;
- linux_statfs_buf.fbavail = bsd_statfs->f_bavail;
- linux_statfs_buf.fffree = bsd_statfs->f_ffree;
- linux_statfs_buf.ffiles = bsd_statfs->f_files;
- linux_statfs_buf.ffsid.val[0] = bsd_statfs->f_fsid.val[0];
- linux_statfs_buf.ffsid.val[1] = bsd_statfs->f_fsid.val[1];
- linux_statfs_buf.fnamelen = MAXNAMLEN;
- return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf,
- sizeof(struct linux_statfs_buf));
-}
-
-int
-linux_ustat(p, uap)
- struct proc *p;
- struct linux_ustat_args *uap;
-{
- struct linux_ustat lu;
- dev_t dev;
- struct vnode *vp;
- struct statfs *stat;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): ustat(%d, *)\n", (long)p->p_pid, uap->dev);
-#endif
-
- /*
- * lu.f_fname and lu.f_fpack are not used. They are always zeroed.
- * lu.f_tinode and lu.f_tfree are set from the device's super block.
- */
- bzero(&lu, sizeof(lu));
-
- /*
- * XXX - Don't return an error if we can't find a vnode for the
- * device. Our dev_t is 32-bits whereas Linux only has a 16-bits
- * dev_t. The dev_t that is used now may as well be a truncated
- * dev_t returned from previous syscalls. Just return a bzeroed
- * ustat in that case.
- */
- dev = makebdev(uap->dev >> 8, uap->dev & 0xFF);
- if (vfinddev(dev, VBLK, &vp)) {
- if (vp->v_mount == NULL)
- return (EINVAL);
- stat = &(vp->v_mount->mnt_stat);
- error = VFS_STATFS(vp->v_mount, stat, p);
- if (error)
- return (error);
-
- lu.f_tfree = stat->f_bfree;
- lu.f_tinode = stat->f_ffree;
- }
-
- return (copyout(&lu, uap->ubuf, sizeof(lu)));
-}
diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
deleted file mode 100644
index 6399805a30371..0000000000000
--- a/sys/compat/linux/linux_util.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 1994 Christos Zoulas
- * Copyright (c) 1995 Frank van der Linden
- * Copyright (c) 1995 Scott Bartram
- * 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.
- *
- * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-
-#include <compat/linux/linux_util.h>
-
-const char linux_emul_path[] = "/compat/linux";
-
-/*
- * Search an alternate path before passing pathname arguments on
- * to system calls. Useful for keeping a seperate 'emulation tree'.
- *
- * If cflag is set, we check if an attempt can be made to create
- * the named file, i.e. we check if the directory it should
- * be in exists.
- */
-int
-linux_emul_find(p, sgp, prefix, path, pbuf, cflag)
- struct proc *p;
- caddr_t *sgp; /* Pointer to stackgap memory */
- const char *prefix;
- char *path;
- char **pbuf;
- int cflag;
-{
- struct nameidata nd;
- struct nameidata ndroot;
- struct vattr vat;
- struct vattr vatroot;
- int error;
- char *ptr, *buf, *cp;
- size_t sz, len;
-
- buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- *pbuf = path;
-
- for (ptr = buf; (*ptr = *prefix) != '\0'; ptr++, prefix++)
- continue;
-
- sz = MAXPATHLEN - (ptr - buf);
-
- /*
- * If sgp is not given then the path is already in kernel space
- */
- if (sgp == NULL)
- error = copystr(path, ptr, sz, &len);
- else
- error = copyinstr(path, ptr, sz, &len);
-
- if (error) {
- free(buf, M_TEMP);
- return error;
- }
-
- if (*ptr != '/') {
- free(buf, M_TEMP);
- return EINVAL;
- }
-
- /*
- * We know that there is a / somewhere in this pathname.
- * Search backwards for it, to find the file's parent dir
- * to see if it exists in the alternate tree. If it does,
- * and we want to create a file (cflag is set). We don't
- * need to worry about the root comparison in this case.
- */
-
- if (cflag) {
- for (cp = &ptr[len] - 1; *cp != '/'; cp--);
- *cp = '\0';
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
-
- if ((error = namei(&nd)) != 0) {
- free(buf, M_TEMP);
- return error;
- }
-
- *cp = '/';
- }
- else {
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
-
- if ((error = namei(&nd)) != 0) {
- free(buf, M_TEMP);
- return error;
- }
-
- /*
- * We now compare the vnode of the linux_root to the one
- * vnode asked. If they resolve to be the same, then we
- * ignore the match so that the real root gets used.
- * This avoids the problem of traversing "../.." to find the
- * root directory and never finding it, because "/" resolves
- * to the emulation root directory. This is expensive :-(
- */
- NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path,
- p);
-
- if ((error = namei(&ndroot)) != 0) {
- /* Cannot happen! */
- free(buf, M_TEMP);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- return error;
- }
-
- if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
- goto bad;
- }
-
- if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
- != 0) {
- goto bad;
- }
-
- if (vat.va_fsid == vatroot.va_fsid &&
- vat.va_fileid == vatroot.va_fileid) {
- error = ENOENT;
- goto bad;
- }
-
- }
- if (sgp == NULL)
- *pbuf = buf;
- else {
- sz = &ptr[len] - buf;
- *pbuf = stackgap_alloc(sgp, sz + 1);
- if (*pbuf != NULL)
- error = copyout(buf, *pbuf, sz);
- else
- error = ENAMETOOLONG;
- free(buf, M_TEMP);
- }
-
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- if (!cflag) {
- NDFREE(&ndroot, NDF_ONLY_PNBUF);
- vrele(ndroot.ni_vp);
- }
- return error;
-
-bad:
- NDFREE(&ndroot, NDF_ONLY_PNBUF);
- vrele(ndroot.ni_vp);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- free(buf, M_TEMP);
- return error;
-}
diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h
deleted file mode 100644
index 444c9a528d16e..0000000000000
--- a/sys/compat/linux/linux_util.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1994 Christos Zoulas
- * Copyright (c) 1995 Frank van der Linden
- * Copyright (c) 1995 Scott Bartram
- * 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.
- *
- * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
- * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp
- * $FreeBSD$
- */
-
-/*
- * This file is pretty much the same as Christos' svr4_util.h
- * (for now).
- */
-
-#ifndef _LINUX_UTIL_H_
-#define _LINUX_UTIL_H_
-
-#include "opt_linux.h"
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <machine/vmparam.h>
-#include <sys/exec.h>
-#include <sys/sysent.h>
-#include <sys/cdefs.h>
-
-static __inline caddr_t stackgap_init(void);
-static __inline void *stackgap_alloc(caddr_t *, size_t);
-
-#define szsigcode (*(curproc->p_sysent->sv_szsigcode))
-
-static __inline caddr_t
-stackgap_init()
-{
- return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE);
-}
-
-static __inline void *
-stackgap_alloc(sgp, sz)
- caddr_t *sgp;
- size_t sz;
-{
- void *p = (void *) *sgp;
-
- sz = ALIGN(sz);
- if (*sgp + sz > (caddr_t)(PS_STRINGS - szsigcode))
- return NULL;
- *sgp += sz;
- return p;
-}
-
-extern const char linux_emul_path[];
-
-int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *,
- char **, int));
-
-#define CHECKALT(p, sgp, path, i) \
- do { \
- int _error; \
- \
- _error = linux_emul_find(p, sgp, linux_emul_path, path, \
- &path, i); \
- if (_error == EFAULT) \
- return (_error); \
- } while (0)
-
-#define CHECKALTEXIST(p, sgp, path) CHECKALT(p, sgp, path, 0)
-#define CHECKALTCREAT(p, sgp, path) CHECKALT(p, sgp, path, 1)
-
-#endif /* !_LINUX_UTIL_H_ */
diff --git a/sys/contrib/ipfilter/netinet/ip_log.c b/sys/contrib/ipfilter/netinet/ip_log.c
deleted file mode 100644
index 082a0a3cf8328..0000000000000
--- a/sys/contrib/ipfilter/netinet/ip_log.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Copyright (C) 1997-2000 by Darren Reed.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and due credit is given
- * to the original author and the contributors.
- *
- * $Id: ip_log.c,v 2.5.2.1 2000/07/19 13:11:47 darrenr Exp $
- * $FreeBSD$
- */
-#include <sys/param.h>
-#if defined(KERNEL) && !defined(_KERNEL)
-# define _KERNEL
-#endif
-#if defined(__NetBSD__) && (NetBSD >= 199905) && !defined(IPFILTER_LKM)
-# include "opt_ipfilter_log.h"
-#endif
-#ifdef __FreeBSD__
-# if defined(IPFILTER_LKM) || defined(_KERNEL)
-# if !defined(__FreeBSD_version)
-# include <sys/osreldate.h>
-# endif
-# if !defined(IPFILTER_LKM)
-# if defined(__FreeBSD_version) && (__FreeBSD_version >= 300000)
-# include "opt_ipfilter.h"
-# endif
-# endif
-# else
-# ifdef KLD_MODULE
-# include <osreldate.h>
-# endif
-# endif
-#endif
-#ifdef IPFILTER_LOG
-# ifndef SOLARIS
-# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
-# endif
-# ifndef _KERNEL
-# include <stdio.h>
-# include <string.h>
-# include <stdlib.h>
-# include <ctype.h>
-# endif
-# include <sys/errno.h>
-# include <sys/types.h>
-# include <sys/file.h>
-# if __FreeBSD_version >= 220000 && defined(_KERNEL)
-# include <sys/fcntl.h>
-# include <sys/filio.h>
-# else
-# include <sys/ioctl.h>
-# endif
-# include <sys/time.h>
-# if defined(_KERNEL) && !defined(linux)
-# include <sys/systm.h>
-# endif
-# include <sys/uio.h>
-# if !SOLARIS
-# if (NetBSD > 199609) || (OpenBSD > 199603) || (__FreeBSD_version >= 300000)
-# include <sys/dirent.h>
-# else
-# include <sys/dir.h>
-# endif
-# ifndef linux
-# include <sys/mbuf.h>
-# endif
-# else
-# include <sys/filio.h>
-# include <sys/cred.h>
-# include <sys/ddi.h>
-# include <sys/sunddi.h>
-# include <sys/ksynch.h>
-# include <sys/kmem.h>
-# include <sys/mkdev.h>
-# include <sys/dditypes.h>
-# include <sys/cmn_err.h>
-# endif
-# ifndef linux
-# include <sys/protosw.h>
-# endif
-# include <sys/socket.h>
-
-# include <net/if.h>
-# ifdef sun
-# include <net/af.h>
-# endif
-# if __FreeBSD_version >= 300000
-# include <net/if_var.h>
-# endif
-# include <net/route.h>
-# include <netinet/in.h>
-# ifdef __sgi
-# include <sys/ddi.h>
-# ifdef IFF_DRVRLOCK /* IRIX6 */
-# include <sys/hashing.h>
-# endif
-# endif
-# if !defined(linux) && !(defined(__sgi) && !defined(IFF_DRVRLOCK)) /*IRIX<6*/
-# include <netinet/in_var.h>
-# endif
-# include <netinet/in_systm.h>
-# include <netinet/ip.h>
-# include <netinet/tcp.h>
-# include <netinet/udp.h>
-# include <netinet/ip_icmp.h>
-# ifndef linux
-# include <netinet/ip_var.h>
-# endif
-# ifndef _KERNEL
-# include <syslog.h>
-# endif
-# include "netinet/ip_compat.h"
-# include <netinet/tcpip.h>
-# include "netinet/ip_fil.h"
-# include "netinet/ip_proxy.h"
-# include "netinet/ip_nat.h"
-# include "netinet/ip_frag.h"
-# include "netinet/ip_state.h"
-# include "netinet/ip_auth.h"
-# if (__FreeBSD_version >= 300000)
-# include <sys/malloc.h>
-# endif
-
-# ifndef MIN
-# define MIN(a,b) (((a)<(b))?(a):(b))
-# endif
-
-
-# if SOLARIS || defined(__sgi)
-extern kmutex_t ipl_mutex;
-# if SOLARIS
-extern kcondvar_t iplwait;
-# endif
-# endif
-
-iplog_t **iplh[IPL_LOGMAX+1], *iplt[IPL_LOGMAX+1], *ipll[IPL_LOGMAX+1];
-size_t iplused[IPL_LOGMAX+1];
-static fr_info_t iplcrc[IPL_LOGMAX+1];
-# ifdef linux
-static struct wait_queue *iplwait[IPL_LOGMAX+1];
-# endif
-
-
-/*
- * Initialise log buffers & pointers. Also iniialised the CRC to a local
- * secret for use in calculating the "last log checksum".
- */
-void ipflog_init()
-{
- int i;
-
- for (i = IPL_LOGMAX; i >= 0; i--) {
- iplt[i] = NULL;
- ipll[i] = NULL;
- iplh[i] = &iplt[i];
- iplused[i] = 0;
- bzero((char *)&iplcrc[i], sizeof(iplcrc[i]));
- }
-}
-
-
-/*
- * ipflog
- * Create a log record for a packet given that it has been triggered by a
- * rule (or the default setting). Calculate the transport protocol header
- * size using predetermined size of a couple of popular protocols and thus
- * how much data to copy into the log, including part of the data body if
- * requested.
- */
-int ipflog(flags, ip, fin, m)
-u_int flags;
-ip_t *ip;
-fr_info_t *fin;
-mb_t *m;
-{
- ipflog_t ipfl;
- register size_t mlen, hlen;
- size_t sizes[2];
- void *ptrs[2];
- int types[2];
- u_char p;
-# if SOLARIS
- ill_t *ifp = fin->fin_ifp;
-# else
- struct ifnet *ifp = fin->fin_ifp;
-# endif
-
- /*
- * calculate header size.
- */
- hlen = fin->fin_hlen;
- if (fin->fin_off == 0) {
- p = fin->fin_fi.fi_p;
- if (p == IPPROTO_TCP)
- hlen += MIN(sizeof(tcphdr_t), fin->fin_dlen);
- else if (p == IPPROTO_UDP)
- hlen += MIN(sizeof(udphdr_t), fin->fin_dlen);
- else if (p == IPPROTO_ICMP) {
- struct icmp *icmp;
-
- icmp = (struct icmp *)fin->fin_dp;
-
- /*
- * For ICMP, if the packet is an error packet, also
- * include the information about the packet which
- * caused the error.
- */
- switch (icmp->icmp_type)
- {
- case ICMP_UNREACH :
- case ICMP_SOURCEQUENCH :
- case ICMP_REDIRECT :
- case ICMP_TIMXCEED :
- case ICMP_PARAMPROB :
- hlen += MIN(sizeof(struct icmp) + 8,
- fin->fin_dlen);
- break;
- default :
- hlen += MIN(sizeof(struct icmp),
- fin->fin_dlen);
- break;
- }
- }
- }
- /*
- * Get the interface number and name to which this packet is
- * currently associated.
- */
-# if SOLARIS
- ipfl.fl_unit = (u_char)ifp->ill_ppa;
- bcopy(ifp->ill_name, ipfl.fl_ifname, MIN(ifp->ill_name_length, 4));
- mlen = (flags & FR_LOGBODY) ? MIN(msgdsize(m) - hlen, 128) : 0;
-# else
-# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
- (defined(OpenBSD) && (OpenBSD >= 199603))
- strncpy(ipfl.fl_ifname, ifp->if_xname, IFNAMSIZ);
-# else
-# ifndef linux
- ipfl.fl_unit = (u_char)ifp->if_unit;
-# endif
- if ((ipfl.fl_ifname[0] = ifp->if_name[0]))
- if ((ipfl.fl_ifname[1] = ifp->if_name[1]))
- if ((ipfl.fl_ifname[2] = ifp->if_name[2]))
- ipfl.fl_ifname[3] = ifp->if_name[3];
-# endif
- mlen = (flags & FR_LOGBODY) ? MIN(fin->fin_plen - hlen, 128) : 0;
-# endif
- ipfl.fl_plen = (u_char)mlen;
- ipfl.fl_hlen = (u_char)hlen;
- ipfl.fl_rule = fin->fin_rule;
- ipfl.fl_group = fin->fin_group;
- if (fin->fin_fr != NULL)
- ipfl.fl_loglevel = fin->fin_fr->fr_loglevel;
- else
- ipfl.fl_loglevel = 0xffff;
- ipfl.fl_flags = flags;
- ptrs[0] = (void *)&ipfl;
- sizes[0] = sizeof(ipfl);
- types[0] = 0;
-# if SOLARIS
- /*
- * Are we copied from the mblk or an aligned array ?
- */
- if (ip == (ip_t *)m->b_rptr) {
- ptrs[1] = m;
- sizes[1] = hlen + mlen;
- types[1] = 1;
- } else {
- ptrs[1] = ip;
- sizes[1] = hlen + mlen;
- types[1] = 0;
- }
-# else
- ptrs[1] = m;
- sizes[1] = hlen + mlen;
- types[1] = 1;
-# endif
- return ipllog(IPL_LOGIPF, fin, ptrs, sizes, types, 2);
-}
-
-
-/*
- * ipllog
- */
-int ipllog(dev, fin, items, itemsz, types, cnt)
-int dev;
-fr_info_t *fin;
-void **items;
-size_t *itemsz;
-int *types, cnt;
-{
- caddr_t buf, s;
- iplog_t *ipl;
- size_t len;
- int i;
-
- /*
- * Check to see if this log record has a CRC which matches the last
- * record logged. If it does, just up the count on the previous one
- * rather than create a new one.
- */
- MUTEX_ENTER(&ipl_mutex);
- if (fin != NULL) {
- if ((ipll[dev] != NULL) &&
- bcmp((char *)fin, (char *)&iplcrc[dev], FI_CSIZE) == 0) {
- ipll[dev]->ipl_count++;
- MUTEX_EXIT(&ipl_mutex);
- return 1;
- }
- bcopy((char *)fin, (char *)&iplcrc[dev], FI_CSIZE);
- } else
- bzero((char *)&iplcrc[dev], FI_CSIZE);
- MUTEX_EXIT(&ipl_mutex);
-
- /*
- * Get the total amount of data to be logged.
- */
- for (i = 0, len = sizeof(iplog_t); i < cnt; i++)
- len += itemsz[i];
-
- /*
- * check that we have space to record this information and can
- * allocate that much.
- */
- KMALLOCS(buf, caddr_t, len);
- if (!buf)
- return 0;
- MUTEX_ENTER(&ipl_mutex);
- if ((iplused[dev] + len) > IPLLOGSIZE) {
- MUTEX_EXIT(&ipl_mutex);
- KFREES(buf, len);
- return 0;
- }
- iplused[dev] += len;
- MUTEX_EXIT(&ipl_mutex);
-
- /*
- * advance the log pointer to the next empty record and deduct the
- * amount of space we're going to use.
- */
- ipl = (iplog_t *)buf;
- ipl->ipl_magic = IPL_MAGIC;
- ipl->ipl_count = 1;
- ipl->ipl_next = NULL;
- ipl->ipl_dsize = len;
-# if SOLARIS || defined(sun) || defined(linux)
- uniqtime((struct timeval *)&ipl->ipl_sec);
-# else
-# if BSD >= 199306 || defined(__FreeBSD__) || defined(__sgi)
- microtime((struct timeval *)&ipl->ipl_sec);
-# endif
-# endif
-
- /*
- * Loop through all the items to be logged, copying each one to the
- * buffer. Use bcopy for normal data or the mb_t copyout routine.
- */
- for (i = 0, s = buf + sizeof(*ipl); i < cnt; i++) {
- if (types[i] == 0)
- bcopy(items[i], s, itemsz[i]);
- else if (types[i] == 1) {
-# if SOLARIS
- copyout_mblk(items[i], 0, itemsz[i], s);
-# else
- m_copydata(items[i], 0, itemsz[i], s);
-# endif
- }
- s += itemsz[i];
- }
- MUTEX_ENTER(&ipl_mutex);
- ipll[dev] = ipl;
- *iplh[dev] = ipl;
- iplh[dev] = &ipl->ipl_next;
-# if SOLARIS
- cv_signal(&iplwait);
- mutex_exit(&ipl_mutex);
-# else
- MUTEX_EXIT(&ipl_mutex);
-# ifdef linux
- wake_up_interruptible(&iplwait[dev]);
-# else
- wakeup(&iplh[dev]);
-# endif
-# endif
- return 1;
-}
-
-
-int ipflog_read(unit, uio)
-minor_t unit;
-struct uio *uio;
-{
- size_t dlen, copied;
- int error = 0;
- iplog_t *ipl;
-# if defined(_KERNEL) && !SOLARIS
- int s;
-# endif
-
- /*
- * Sanity checks. Make sure the minor # is valid and we're copying
- * a valid chunk of data.
- */
- if (IPL_LOGMAX < unit)
- return ENXIO;
- if (!uio->uio_resid)
- return 0;
- if ((uio->uio_resid < sizeof(iplog_t)) ||
- (uio->uio_resid > IPLLOGSIZE))
- return EINVAL;
-
- /*
- * Lock the log so we can snapshot the variables. Wait for a signal
- * if the log is empty.
- */
- SPL_NET(s);
- MUTEX_ENTER(&ipl_mutex);
-
- while (!iplused[unit] || !iplt[unit]) {
-# if SOLARIS && defined(_KERNEL)
- if (!cv_wait_sig(&iplwait, &ipl_mutex)) {
- MUTEX_EXIT(&ipl_mutex);
- return EINTR;
- }
-# else
-# ifdef linux
- interruptible_sleep_on(&iplwait[unit]);
- if (current->signal & ~current->blocked)
- return -EINTR;
-# else
- MUTEX_EXIT(&ipl_mutex);
- SPL_X(s);
- error = SLEEP(&iplh[unit], "ipl sleep");
- if (error)
- return error;
- SPL_NET(s);
- MUTEX_ENTER(&ipl_mutex);
-# endif /* linux */
-# endif /* SOLARIS */
- }
-
-# if BSD >= 199306 || defined(__FreeBSD__)
- uio->uio_rw = UIO_READ;
-# endif
-
- for (copied = 0; (ipl = iplt[unit]); copied += dlen) {
- dlen = ipl->ipl_dsize;
- if (dlen > uio->uio_resid)
- break;
- /*
- * Don't hold the mutex over the uiomove call.
- */
- iplt[unit] = ipl->ipl_next;
- iplused[unit] -= dlen;
- MUTEX_EXIT(&ipl_mutex);
- SPL_X(s);
- error = UIOMOVE((caddr_t)ipl, dlen, UIO_READ, uio);
- if (error) {
- SPL_NET(s);
- MUTEX_ENTER(&ipl_mutex);
- ipl->ipl_next = iplt[unit];
- iplt[unit] = ipl;
- iplused[unit] += dlen;
- break;
- }
- KFREES((caddr_t)ipl, dlen);
- SPL_NET(s);
- MUTEX_ENTER(&ipl_mutex);
- }
- if (!iplt[unit]) {
- iplused[unit] = 0;
- iplh[unit] = &iplt[unit];
- ipll[unit] = NULL;
- }
-
- MUTEX_EXIT(&ipl_mutex);
- SPL_X(s);
-# ifdef linux
- if (!error)
- return (int)copied;
- return -error;
-# else
- return error;
-# endif
-}
-
-
-int ipflog_clear(unit)
-minor_t unit;
-{
- iplog_t *ipl;
- int used;
-
- MUTEX_ENTER(&ipl_mutex);
- while ((ipl = iplt[unit])) {
- iplt[unit] = ipl->ipl_next;
- KFREES((caddr_t)ipl, ipl->ipl_dsize);
- }
- iplh[unit] = &iplt[unit];
- ipll[unit] = NULL;
- used = iplused[unit];
- iplused[unit] = 0;
- bzero((char *)&iplcrc[unit], FI_CSIZE);
- MUTEX_EXIT(&ipl_mutex);
- return used;
-}
-#endif /* IPFILTER_LOG */
diff --git a/sys/contrib/ipfilter/netinet/ip_proxy.c b/sys/contrib/ipfilter/netinet/ip_proxy.c
deleted file mode 100644
index 47d0e5ea0de3b..0000000000000
--- a/sys/contrib/ipfilter/netinet/ip_proxy.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * Copyright (C) 1997-2000 by Darren Reed.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and due credit is given
- * to the original author and the contributors.
- */
-#if !defined(lint)
-/*static const char rcsid[] = "@(#)$Id: ip_proxy.c,v 2.2.2.1 1999/09/19 12:18:19 darrenr Exp $";*/
-static const char rcsid[] = "@(#)$FreeBSD$";
-#endif
-
-#if defined(__FreeBSD__) && defined(KERNEL) && !defined(_KERNEL)
-# define _KERNEL
-#endif
-
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#if !defined(__FreeBSD_version)
-# include <sys/ioctl.h>
-#endif
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#if !defined(_KERNEL) && !defined(KERNEL)
-# include <stdio.h>
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifndef linux
-# include <sys/protosw.h>
-#endif
-#include <sys/socket.h>
-#if defined(_KERNEL)
-# if !defined(linux)
-# include <sys/systm.h>
-# else
-# include <linux/string.h>
-# endif
-#endif
-#if !defined(__SVR4) && !defined(__svr4__)
-# ifndef linux
-# include <sys/mbuf.h>
-# endif
-#else
-# include <sys/byteorder.h>
-# ifdef _KERNEL
-# include <sys/dditypes.h>
-# endif
-# include <sys/stream.h>
-# include <sys/kmem.h>
-#endif
-#if __FreeBSD__ > 2
-# include <sys/queue.h>
-#endif
-#include <net/if.h>
-#ifdef sun
-# include <net/af.h>
-#endif
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#ifndef linux
-# include <netinet/ip_var.h>
-#endif
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
-#include "netinet/ip_compat.h"
-#include <netinet/tcpip.h>
-#include "netinet/ip_fil.h"
-#include "netinet/ip_proxy.h"
-#include "netinet/ip_nat.h"
-#include "netinet/ip_state.h"
-#if (__FreeBSD_version >= 300000)
-# include <sys/malloc.h>
-#endif
-
-
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
-static ap_session_t *appr_new_session __P((aproxy_t *, ip_t *,
- fr_info_t *, nat_t *));
-static int appr_fixseqack __P((fr_info_t *, ip_t *, ap_session_t *, int ));
-
-
-#define AP_SESS_SIZE 53
-
-#if defined(_KERNEL) && !defined(linux)
-#include "netinet/ip_ftp_pxy.c"
-#include "netinet/ip_rcmd_pxy.c"
-#include "netinet/ip_raudio_pxy.c"
-#endif
-
-ap_session_t *ap_sess_tab[AP_SESS_SIZE];
-ap_session_t *ap_sess_list = NULL;
-aproxy_t *ap_proxylist = NULL;
-aproxy_t ap_proxies[] = {
-#ifdef IPF_FTP_PROXY
- { NULL, "ftp", (char)IPPROTO_TCP, 0, 0, ippr_ftp_init, NULL,
- ippr_ftp_new, ippr_ftp_in, ippr_ftp_out },
-#endif
-#ifdef IPF_RCMD_PROXY
- { NULL, "rcmd", (char)IPPROTO_TCP, 0, 0, ippr_rcmd_init, NULL,
- ippr_rcmd_new, NULL, ippr_rcmd_out },
-#endif
-#ifdef IPF_RAUDIO_PROXY
- { NULL, "raudio", (char)IPPROTO_TCP, 0, 0, ippr_raudio_init, NULL,
- ippr_raudio_new, ippr_raudio_in, ippr_raudio_out },
-#endif
- { NULL, "", '\0', 0, 0, NULL, NULL }
-};
-
-
-int appr_add(ap)
-aproxy_t *ap;
-{
- aproxy_t *a;
-
- for (a = ap_proxies; a->apr_p; a++)
- if ((a->apr_p == ap->apr_p) &&
- !strncmp(a->apr_label, ap->apr_label,
- sizeof(ap->apr_label)))
- return -1;
-
- for (a = ap_proxylist; a->apr_p; a = a->apr_next)
- if ((a->apr_p == ap->apr_p) &&
- !strncmp(a->apr_label, ap->apr_label,
- sizeof(ap->apr_label)))
- return -1;
- ap->apr_next = ap_proxylist;
- ap_proxylist = ap;
- return (*ap->apr_init)();
-}
-
-
-int appr_del(ap)
-aproxy_t *ap;
-{
- aproxy_t *a, **app;
-
- for (app = &ap_proxylist; (a = *app); app = &a->apr_next)
- if (a == ap) {
- if (ap->apr_ref != 0)
- return 1;
- *app = a->apr_next;
- return 0;
- }
- return -1;
-}
-
-
-int appr_ok(ip, tcp, nat)
-ip_t *ip;
-tcphdr_t *tcp;
-ipnat_t *nat;
-{
- aproxy_t *apr = nat->in_apr;
- u_short dport = nat->in_dport;
-
- if (!apr || (apr->apr_flags & APR_DELETE) ||
- (ip->ip_p != apr->apr_p))
- return 0;
- if ((tcp && (tcp->th_dport != dport)) || (!tcp && dport))
- return 0;
- return 1;
-}
-
-
-/*
- * Allocate a new application proxy structure and fill it in with the
- * relevant details. call the init function once complete, prior to
- * returning.
- */
-static ap_session_t *appr_new_session(apr, ip, fin, nat)
-aproxy_t *apr;
-ip_t *ip;
-fr_info_t *fin;
-nat_t *nat;
-{
- register ap_session_t *aps;
-
- if (!apr || (apr->apr_flags & APR_DELETE) || (ip->ip_p != apr->apr_p))
- return NULL;
-
- KMALLOC(aps, ap_session_t *);
- if (!aps)
- return NULL;
- bzero((char *)aps, sizeof(*aps));
- aps->aps_p = ip->ip_p;
- aps->aps_data = NULL;
- aps->aps_apr = apr;
- aps->aps_psiz = 0;
- if (apr->apr_new != NULL)
- if ((*apr->apr_new)(fin, ip, aps, nat) == -1) {
- KFREE(aps);
- return NULL;
- }
- aps->aps_nat = nat;
- aps->aps_next = ap_sess_list;
- ap_sess_list = aps;
- return aps;
-}
-
-
-/*
- * check to see if a packet should be passed through an active proxy routine
- * if one has been setup for it.
- */
-int appr_check(ip, fin, nat)
-ip_t *ip;
-fr_info_t *fin;
-nat_t *nat;
-{
- ap_session_t *aps;
- aproxy_t *apr;
- tcphdr_t *tcp = NULL;
- u_32_t sum;
- short rv;
- int err;
-
- if (nat->nat_aps == NULL)
- nat->nat_aps = appr_new_session(nat->nat_ptr->in_apr, ip,
- fin, nat);
- aps = nat->nat_aps;
- if ((aps != NULL) && (aps->aps_p == ip->ip_p)) {
- if (ip->ip_p == IPPROTO_TCP) {
- tcp = (tcphdr_t *)fin->fin_dp;
- /*
- * verify that the checksum is correct. If not, then
- * don't do anything with this packet.
- */
-#if SOLARIS && defined(_KERNEL)
- sum = fr_tcpsum(fin->fin_qfm, ip, tcp);
-#else
- sum = fr_tcpsum(*(mb_t **)fin->fin_mp, ip, tcp);
-#endif
- if (sum != tcp->th_sum) {
- frstats[fin->fin_out].fr_tcpbad++;
- return -1;
- }
- }
-
- apr = aps->aps_apr;
- err = 0;
- if (fin->fin_out != 0) {
- if (apr->apr_outpkt != NULL)
- err = (*apr->apr_outpkt)(fin, ip, aps, nat);
- } else {
- if (apr->apr_inpkt != NULL)
- err = (*apr->apr_inpkt)(fin, ip, aps, nat);
- }
-
- rv = APR_EXIT(err);
- if (rv == -1)
- return rv;
-
- if (tcp != NULL) {
- err = appr_fixseqack(fin, ip, aps, APR_INC(err));
-#if SOLARIS && defined(_KERNEL)
- tcp->th_sum = fr_tcpsum(fin->fin_qfm, ip, tcp);
-#else
- tcp->th_sum = fr_tcpsum(*(mb_t **)fin->fin_mp, ip, tcp);
-#endif
- }
- aps->aps_bytes += ip->ip_len;
- aps->aps_pkts++;
- return 1;
- }
- return 0;
-}
-
-
-aproxy_t *appr_match(pr, name)
-u_int pr;
-char *name;
-{
- aproxy_t *ap;
-
- for (ap = ap_proxies; ap->apr_p; ap++)
- if ((ap->apr_p == pr) &&
- !strncmp(name, ap->apr_label, sizeof(ap->apr_label))) {
- ap->apr_ref++;
- return ap;
- }
-
- for (ap = ap_proxylist; ap; ap = ap->apr_next)
- if ((ap->apr_p == pr) &&
- !strncmp(name, ap->apr_label, sizeof(ap->apr_label))) {
- ap->apr_ref++;
- return ap;
- }
- return NULL;
-}
-
-
-void appr_free(ap)
-aproxy_t *ap;
-{
- ap->apr_ref--;
-}
-
-
-void aps_free(aps)
-ap_session_t *aps;
-{
- ap_session_t *a, **ap;
-
- if (!aps)
- return;
-
- for (ap = &ap_sess_list; (a = *ap); ap = &a->aps_next)
- if (a == aps) {
- *ap = a->aps_next;
- break;
- }
-
- if ((aps->aps_data != NULL) && (aps->aps_psiz != 0))
- KFREES(aps->aps_data, aps->aps_psiz);
- KFREE(aps);
-}
-
-
-static int appr_fixseqack(fin, ip, aps, inc)
-fr_info_t *fin;
-ip_t *ip;
-ap_session_t *aps;
-int inc;
-{
- int sel, ch = 0, out, nlen;
- u_32_t seq1, seq2;
- tcphdr_t *tcp;
-
- tcp = (tcphdr_t *)fin->fin_dp;
- out = fin->fin_out;
- nlen = ip->ip_len;
- nlen -= (ip->ip_hl << 2) + (tcp->th_off << 2);
-
- if (out != 0) {
- seq1 = (u_32_t)ntohl(tcp->th_seq);
- sel = aps->aps_sel[out];
-
- /* switch to other set ? */
- if ((aps->aps_seqmin[!sel] > aps->aps_seqmin[sel]) &&
- (seq1 > aps->aps_seqmin[!sel]))
- sel = aps->aps_sel[out] = !sel;
-
- if (aps->aps_seqoff[sel]) {
- seq2 = aps->aps_seqmin[sel] - aps->aps_seqoff[sel];
- if (seq1 > seq2) {
- seq2 = aps->aps_seqoff[sel];
- seq1 += seq2;
- tcp->th_seq = htonl(seq1);
- ch = 1;
- }
- }
-
- if (inc && (seq1 > aps->aps_seqmin[!sel])) {
- aps->aps_seqmin[!sel] = seq1 + nlen - 1;
- aps->aps_seqoff[!sel] = aps->aps_seqoff[sel] + inc;
- }
-
- /***/
-
- seq1 = ntohl(tcp->th_ack);
- sel = aps->aps_sel[1 - out];
-
- /* switch to other set ? */
- if ((aps->aps_ackmin[!sel] > aps->aps_ackmin[sel]) &&
- (seq1 > aps->aps_ackmin[!sel]))
- sel = aps->aps_sel[1 - out] = !sel;
-
- if (aps->aps_ackoff[sel] && (seq1 > aps->aps_ackmin[sel])) {
- seq2 = aps->aps_ackoff[sel];
- tcp->th_ack = htonl(seq1 - seq2);
- ch = 1;
- }
- } else {
- seq1 = ntohl(tcp->th_seq);
- sel = aps->aps_sel[out];
-
- /* switch to other set ? */
- if ((aps->aps_ackmin[!sel] > aps->aps_ackmin[sel]) &&
- (seq1 > aps->aps_ackmin[!sel]))
- sel = aps->aps_sel[out] = !sel;
-
- if (aps->aps_ackoff[sel]) {
- seq2 = aps->aps_ackmin[sel] -
- aps->aps_ackoff[sel];
- if (seq1 > seq2) {
- seq2 = aps->aps_ackoff[sel];
- seq1 += seq2;
- tcp->th_seq = htonl(seq1);
- ch = 1;
- }
- }
-
- if (inc && (seq1 > aps->aps_ackmin[!sel])) {
- aps->aps_ackmin[!sel] = seq1 + nlen - 1;
- aps->aps_ackoff[!sel] = aps->aps_ackoff[sel] + inc;
- }
-
- /***/
-
- seq1 = ntohl(tcp->th_ack);
- sel = aps->aps_sel[1 - out];
-
- /* switch to other set ? */
- if ((aps->aps_seqmin[!sel] > aps->aps_seqmin[sel]) &&
- (seq1 > aps->aps_seqmin[!sel]))
- sel = aps->aps_sel[1 - out] = !sel;
-
- if (aps->aps_seqoff[sel] && (seq1 > aps->aps_seqmin[sel])) {
- seq2 = aps->aps_seqoff[sel];
- tcp->th_ack = htonl(seq1 - seq2);
- ch = 1;
- }
- }
- return ch ? 2 : 0;
-}
-
-
-int appr_init()
-{
- aproxy_t *ap;
- int err = 0;
-
- for (ap = ap_proxies; ap->apr_p; ap++) {
- err = (*ap->apr_init)();
- if (err != 0)
- break;
- }
- return err;
-}
-
-
-void appr_unload()
-{
- aproxy_t *ap;
-
- for (ap = ap_proxies; ap->apr_p; ap++)
- if (ap->apr_fini)
- (*ap->apr_fini)();
- for (ap = ap_proxylist; ap; ap = ap->apr_next)
- if (ap->apr_fini)
- (*ap->apr_fini)();
-}
diff --git a/sys/dev/aac/aac_tables.h b/sys/dev/aac/aac_tables.h
deleted file mode 100644
index d994ae622181d..0000000000000
--- a/sys/dev/aac/aac_tables.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-/*
- * Status codes for block read/write commands, etc.
- *
- * XXX many of these would not normally be returned, as they are
- * relevant only to FSA operations.
- */
-static struct aac_code_lookup aac_command_status_table[] = {
- {"OK", 0},
- {"operation not permitted", 1},
- {"not found", 2},
- {"I/O error", 5},
- {"device not configured", 6},
- {"too big", 7},
- {"permission denoed", 13},
- {"file exists", 17},
- {"cross-device link", 18},
- {"operation not supported by device", 19},
- {"not a directory", 20},
- {"is a directory", 21},
- {"invalid argument", 22},
- {"file too large", 27},
- {"no space on device", 28},
- {"readonly filesystem", 30},
- {"too many links", 31},
- {"operation would block", 35},
- {"file name too long", 63},
- {"directory not empty", 66},
- {"quota exceeded", 69},
- {"stale file handle", 70},
- {"too many levels of remote in path", 71},
- {"bad file handle", 10001},
- {"not sync", 10002},
- {"bad cookie", 10003},
- {"operation not supported", 10004},
- {"too small", 10005},
- {"server fault", 10006},
- {"bad type", 10007},
- {"jukebox", 10008},
- {"not mounted", 10009},
- {"in maintenace mode", 10010},
- {"stale ACL", 10011},
- {NULL, 0},
- {"unknown command status", 0}
-};
-
-#define AAC_COMMAND_STATUS(x) aac_describe_code(aac_command_status_table, x)
-
-static struct aac_code_lookup aac_cpu_variant[] = {
- {"i960JX", CPUI960_JX},
- {"i960CX", CPUI960_CX},
- {"i960HX", CPUI960_HX},
- {"i960RX", CPUI960_RX},
- {"StrongARM SA110", CPUARM_SA110},
- {"PowerPC 603e", CPUPPC_603e},
- {"Unknown StrongARM", CPUARM_xxx},
- {"Unknown PowerPC", CPUPPC_xxx},
- {NULL, 0},
- {"Unknown processor", 0}
-};
-
-static struct aac_code_lookup aac_battery_platform[] = {
- {"required battery present", PLATFORM_BAT_REQ_PRESENT},
- {"REQUIRED BATTERY NOT PRESENT", PLATFORM_BAT_REQ_NOTPRESENT},
- {"optional battery present", PLATFORM_BAT_OPT_PRESENT},
- {"optional battery not installed", PLATFORM_BAT_OPT_NOTPRESENT},
- {"no battery support", PLATFORM_BAT_NOT_SUPPORTED},
- {NULL, 0},
- {"unknown battery platform", 0}
-};
-
-static struct aac_code_lookup aac_container_types[] = {
- {"Volume", CT_VOLUME},
- {"RAID 1 (Mirror)", CT_MIRROR},
- {"RAID 0 (Stripe)", CT_STRIPE},
- {"RAID 5", CT_RAID5},
- {"SSRW", CT_SSRW},
- {"SSRO", CT_SSRO},
- {"Morph", CT_MORPH},
- {"Passthrough", CT_PASSTHRU},
- {"RAID 4", CT_RAID4},
- {"RAID 10", CT_RAID10},
- {"RAID 00", CT_RAID00},
- {"Volume of Mirrors", CT_VOLUME_OF_MIRRORS},
- {"Pseudo RAID 3", CT_PSEUDO_RAID3},
- {NULL, 0},
- {"unknown", 0}
-};
-
diff --git a/sys/dev/aic7xxx/aic7xxx.c b/sys/dev/aic7xxx/aic7xxx.c
index b5da00ff4655b..5c54b18b3246b 100644
--- a/sys/dev/aic7xxx/aic7xxx.c
+++ b/sys/dev/aic7xxx/aic7xxx.c
@@ -1867,7 +1867,7 @@ ahc_build_transfer_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
period = tinfo->goal.period;
ppr_options = tinfo->goal.ppr_options;
- if (dosync)
+ if (use_ppr == 0)
ppr_options = 0;
rate = ahc_devlimited_syncrate(ahc, &period, &ppr_options);
offset = tinfo->goal.offset;
diff --git a/sys/dev/amr/amr_cam.c b/sys/dev/amr/amr_cam.c
deleted file mode 100644
index 45ecc523c3aad..0000000000000
--- a/sys/dev/amr/amr_cam.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-
-#include <dev/amr/amr_compat.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/devicestat.h>
-#include <sys/disk.h>
-#include <sys/stat.h>
-
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-#include <cam/cam_sim.h>
-#include <cam/cam_xpt.h>
-#include <cam/cam_xpt_sim.h>
-#include <cam/cam_debug.h>
-#include <cam/scsi/scsi_all.h>
-#include <cam/scsi/scsi_message.h>
-
-#include <machine/resource.h>
-#include <machine/bus.h>
-
-#include <dev/amr/amrreg.h>
-#include <dev/amr/amrvar.h>
-
-static void amr_cam_action(struct cam_sim *sim, union ccb *ccb);
-static void amr_cam_poll(struct cam_sim *sim);
-static void amr_cam_complete(struct amr_command *ac);
-
-
-/********************************************************************************
- * Enqueue/dequeue functions
- */
-static __inline void
-amr_enqueue_ccb(struct amr_softc *sc, union ccb *ccb)
-{
- int s;
-
- s = splbio();
- TAILQ_INSERT_TAIL(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
- splx(s);
-}
-
-static __inline void
-amr_requeue_ccb(struct amr_softc *sc, union ccb *ccb)
-{
- int s;
-
- s = splbio();
- TAILQ_INSERT_HEAD(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
- splx(s);
-}
-
-static __inline union ccb *
-amr_dequeue_ccb(struct amr_softc *sc)
-{
- union ccb *ccb;
- int s;
-
- s = splbio();
- if ((ccb = (union ccb *)TAILQ_FIRST(&sc->amr_cam_ccbq)) != NULL)
- TAILQ_REMOVE(&sc->amr_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
- splx(s);
- return(ccb);
-}
-
-/********************************************************************************
- * Attach our 'real' SCSI channels to CAM
- */
-int
-amr_cam_attach(struct amr_softc *sc)
-{
- struct cam_devq *devq;
- int chn;
-
- /* initialise the ccb queue */
- TAILQ_INIT(&sc->amr_cam_ccbq);
-
- /*
- * Allocate a devq for all our channels combined. This should
- * allow for the maximum number of SCSI commands we will accept
- * at one time.
- */
- if ((devq = cam_simq_alloc(AMR_MAX_SCSI_CMDS)) == NULL)
- return(ENOMEM);
-
- /*
- * Iterate over our channels, registering them with CAM
- */
- for (chn = 0; chn < sc->amr_maxchan; chn++) {
-
- /* allocate a sim */
- if ((sc->amr_cam_sim[chn] = cam_sim_alloc(amr_cam_action,
- amr_cam_poll,
- "amr",
- sc,
- device_get_unit(sc->amr_dev),
- 1,
- AMR_MAX_SCSI_CMDS,
- devq)) == NULL) {
- cam_simq_free(devq);
- device_printf(sc->amr_dev, "CAM SIM attach failed\n");
- return(ENOMEM);
- }
-
- /* register the bus ID so we can get it later */
- if (xpt_bus_register(sc->amr_cam_sim[chn], chn)) {
- device_printf(sc->amr_dev, "CAM XPT bus registration failed\n");
- return(ENXIO);
- }
- }
- /*
- * XXX we should scan the config and work out which devices are actually
- * protected.
- */
- return(0);
-}
-
-/********************************************************************************
- * Disconnect ourselves from CAM
- */
-void
-amr_cam_detach(struct amr_softc *sc)
-{
- int chn, first;
-
- for (chn = 0, first = 1; chn < sc->amr_maxchan; chn++) {
-
- /*
- * If a sim was allocated for this channel, free it
- */
- if (sc->amr_cam_sim[chn] != NULL) {
- xpt_bus_deregister(cam_sim_path(sc->amr_cam_sim[chn]));
- cam_sim_free(sc->amr_cam_sim[chn], first ? TRUE : FALSE);
- first = 0;
- }
- }
-}
-
-/********************************************************************************
- ********************************************************************************
- CAM passthrough interface
- ********************************************************************************
- ********************************************************************************/
-
-/********************************************************************************
- * Handle a request for action from CAM
- */
-static void
-amr_cam_action(struct cam_sim *sim, union ccb *ccb)
-{
- struct amr_softc *sc = cam_sim_softc(sim);
-
- switch(ccb->ccb_h.func_code) {
-
- /*
- * Perform SCSI I/O to a physical device.
- */
- case XPT_SCSI_IO:
- {
- struct ccb_hdr *ccbh = &ccb->ccb_h;
- struct ccb_scsiio *csio = &ccb->csio;
-
- /* Validate the CCB */
- ccbh->status = CAM_REQ_INPROG;
-
- /* check the CDB length */
- if (csio->cdb_len > AMR_MAX_CDB_LEN)
- ccbh->status = CAM_REQ_CMP_ERR;
-
- /* check that the CDB pointer is not to a physical address */
- if ((ccbh->flags & CAM_CDB_POINTER) && (ccbh->flags & CAM_CDB_PHYS))
- ccbh->status = CAM_REQ_CMP_ERR;
-
- /* if there is data transfer, it must be to/from a virtual address */
- if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if (ccbh->flags & CAM_DATA_PHYS) /* we can't map it */
- ccbh->status = CAM_REQ_CMP_ERR;
- if (ccbh->flags & CAM_SCATTER_VALID) /* we want to do the s/g setup */
- ccbh->status = CAM_REQ_CMP_ERR;
- }
-
- /*
- * If the command is to a LUN other than 0, fail it.
- * This is probably incorrect, but during testing the firmware did not
- * seem to respect the LUN field, and thus devices appear echoed.
- */
- if (csio->ccb_h.target_lun != 0)
- ccbh->status = CAM_REQ_CMP_ERR;
-
- /* if we're happy with the request, queue it for attention */
- if (ccbh->status == CAM_REQ_INPROG) {
-
- /* save the channel number in the ccb */
- csio->ccb_h.sim_priv.entries[0].field = cam_sim_bus(sim);
-
- amr_enqueue_ccb(sc, ccb);
- amr_startio(sc);
- return;
- }
- break;
- }
-
- case XPT_CALC_GEOMETRY:
- {
- struct ccb_calc_geometry *ccg = &ccb->ccg;
- u_int32_t size_in_mb;
- u_int32_t secs_per_cylinder;
-
- size_in_mb = ccg->volume_size / ((1024L * 1024L) / ccg->block_size);
-
- if (size_in_mb > 1024) {
- ccg->heads = 255;
- ccg->secs_per_track = 63;
- } else {
- ccg->heads = 64;
- ccg->secs_per_track = 32;
- }
- secs_per_cylinder = ccg->heads * ccg->secs_per_track;
- ccg->cylinders = ccg->volume_size / secs_per_cylinder;
- ccb->ccb_h.status = CAM_REQ_CMP;
- break;
- }
-
- /*
- * Return path stats. Some of these should probably be
- * amended.
- */
- case XPT_PATH_INQ:
- {
- struct ccb_pathinq *cpi = & ccb->cpi;
-
- cpi->version_num = 1; /* XXX??? */
- cpi->hba_inquiry = PI_SDTR_ABLE;
- cpi->target_sprt = 0;
- cpi->hba_misc = 0;
- cpi->hba_eng_cnt = 0;
- cpi->max_target = AMR_MAX_TARGETS;
- cpi->max_lun = AMR_MAX_LUNS;
- cpi->initiator_id = 7; /* XXX variable? */
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "BSDi", HBA_IDLEN);
- strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
- cpi->unit_number = cam_sim_unit(sim);
- cpi->bus_id = cam_sim_bus(sim);
- cpi->base_transfer_speed = 132 * 1024; /* XXX get from controller? */
- cpi->ccb_h.status = CAM_REQ_CMP;
-
- break;
- }
-
- /*
- * Reject anything else as unsupported.
- */
- default:
- /* we can't do this */
- ccb->ccb_h.status = CAM_REQ_INVALID;
- break;
- }
- xpt_done(ccb);
-}
-
-/********************************************************************************
- * Convert a CAM CCB off the top of the CCB queue to a passthrough SCSI command.
- */
-int
-amr_cam_command(struct amr_softc *sc, struct amr_command **acp)
-{
- struct amr_command *ac;
- struct amr_passthrough *ap;
- struct ccb_scsiio *csio;
- int bus, target, error;
-
- error = 0;
- ac = NULL;
- ap = NULL;
-
- /* check to see if there is a ccb for us to work with */
- if ((csio = (struct ccb_scsiio *)amr_dequeue_ccb(sc)) == NULL)
- goto out;
-
- /* get bus/target, XXX validate against protected devices? */
- bus = csio->ccb_h.sim_priv.entries[0].field;
- target = csio->ccb_h.target_id;
-
- /*
- * Build a passthrough command.
- */
-
- /* construct passthrough */
- if ((ap = malloc(sizeof(*ap), M_DEVBUF, M_NOWAIT)) == NULL) {
- error = ENOMEM;
- goto out;
- }
- bzero(ap, sizeof(*ap));
- ap->ap_timeout = 0;
- ap->ap_ars = 1;
- ap->ap_request_sense_length = 14;
- ap->ap_islogical = 0;
- ap->ap_channel = bus;
- ap->ap_scsi_id = target;
- ap->ap_logical_drive_no = csio->ccb_h.target_lun;
- ap->ap_cdb_length = csio->cdb_len;
- if (csio->ccb_h.flags & CAM_CDB_POINTER) {
- bcopy(csio->cdb_io.cdb_ptr, ap->ap_cdb, csio->cdb_len);
- } else {
- bcopy(csio->cdb_io.cdb_bytes, ap->ap_cdb, csio->cdb_len);
- }
- /* we leave the data s/g list and s/g count to the map routine later */
-
- debug(2, " COMMAND %x/%d+%d to %d:%d:%d", ap->ap_cdb[0], ap->ap_cdb_length, csio->dxfer_len,
- ap->ap_channel, ap->ap_scsi_id, ap->ap_logical_drive_no);
-
- /* construct command */
- if ((ac = amr_alloccmd(sc)) == NULL) {
- error = ENOMEM;
- goto out;
- }
-
- ac->ac_data = ap;
- ac->ac_length = sizeof(*ap);
- ac->ac_flags |= AMR_CMD_DATAOUT;
-
- ac->ac_ccb_data = csio->data_ptr;
- ac->ac_ccb_length = csio->dxfer_len;
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
- ac->ac_flags |= AMR_CMD_CCB_DATAIN;
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
- ac->ac_flags |= AMR_CMD_CCB_DATAOUT;
-
- ac->ac_complete = amr_cam_complete;
- ac->ac_private = csio;
- ac->ac_mailbox.mb_command = AMR_CMD_PASS;
-
-out:
- if (error != 0) {
- if (ac != NULL)
- amr_releasecmd(ac);
- if (ap != NULL)
- free(ap, M_DEVBUF);
- if (csio != NULL) /* put it back and try again later */
- amr_requeue_ccb(sc, (union ccb *)csio);
- }
- *acp = ac;
- return(error);
-}
-
-/********************************************************************************
- * Check for interrupt status
- */
-static void
-amr_cam_poll(struct cam_sim *sim)
-{
- amr_done(cam_sim_softc(sim));
-}
-
-/********************************************************************************
- * Handle completion of a command submitted via CAM.
- */
-static void
-amr_cam_complete(struct amr_command *ac)
-{
- struct amr_passthrough *ap = (struct amr_passthrough *)ac->ac_data;
- struct ccb_scsiio *csio = (struct ccb_scsiio *)ac->ac_private;
- struct scsi_inquiry_data *inq = (struct scsi_inquiry_data *)csio->data_ptr;
-
- /* XXX note that we're ignoring ac->ac_status - good idea? */
-
- debug(1, "status 0x%x scsi_status 0x%x", ac->ac_status, ap->ap_scsi_status);
-
- /*
- * Hide disks from CAM so that they're not picked up and treated as 'normal' disks.
- *
- * If the configuration provides a mechanism to mark a disk a "not managed", we
- * could add handling for that to allow disks to be selectively visible.
- */
-#if 0
- if ((ap->ap_cdb[0] == INQUIRY) && (SID_TYPE(inq) == T_DIRECT)) {
- bzero(csio->data_ptr, csio->dxfer_len);
- if (ap->ap_scsi_status == 0xf0) {
- csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
- } else {
- csio->ccb_h.status = CAM_DEV_NOT_THERE;
- }
- } else {
-#else
- {
-#endif
-
- /* handle passthrough SCSI status */
- switch(ap->ap_scsi_status) {
- case 0: /* completed OK */
- csio->ccb_h.status = CAM_REQ_CMP;
- break;
-
- case 0x02:
- csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
- csio->scsi_status = SCSI_STATUS_CHECK_COND;
- bcopy(ap->ap_request_sense_area, &csio->sense_data, AMR_MAX_REQ_SENSE_LEN);
- csio->sense_len = AMR_MAX_REQ_SENSE_LEN;
- csio->ccb_h.status |= CAM_AUTOSNS_VALID;
- break;
-
- case 0x08:
- csio->ccb_h.status = CAM_SCSI_BUSY;
- break;
-
- case 0xf0:
- case 0xf4:
- default:
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- break;
- }
- }
- free(ap, M_DEVBUF);
- if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
- debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr, " ");
- xpt_done((union ccb *)csio);
- amr_releasecmd(ac);
-}
-
diff --git a/sys/dev/amr/amr_tables.h b/sys/dev/amr/amr_tables.h
deleted file mode 100644
index d6e9993ad1c66..0000000000000
--- a/sys/dev/amr/amr_tables.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-/*
- * Lookup table for code-to-text translations.
- */
-struct amr_code_lookup {
- char *string;
- u_int32_t code;
-};
-
-extern char *amr_describe_code(struct amr_code_lookup *table, u_int32_t code);
-
-#ifndef AMR_DEFINE_TABLES
-extern struct amr_code_lookup amr_table_qinit[];
-extern struct amr_code_lookup amr_table_sinit[];
-extern struct amr_code_lookup amr_table_drvstate[];
-
-#else /* AMR_DEFINE_TABLES */
-
-/********************************************************************************
- * Look up a text description of a numeric code and return a pointer to same.
- */
-char *
-amr_describe_code(struct amr_code_lookup *table, u_int32_t code)
-{
- int i;
-
- for (i = 0; table[i].string != NULL; i++)
- if (table[i].code == code)
- return(table[i].string);
- return(table[i+1].string);
-}
-
-struct amr_code_lookup amr_table_qinit[] = {
- {"init scanning drives", AMR_QINIT_SCAN},
- {"init scanning initialising", AMR_QINIT_SCANINIT},
- {"init firmware initing", AMR_QINIT_FIRMWARE},
- {"init in progress", AMR_QINIT_INPROG},
- {"init spinning drives", AMR_QINIT_SPINUP},
- {"insufficient memory", AMR_QINIT_NOMEM},
- {"init flushing cache", AMR_QINIT_CACHEFLUSH},
- {"init successfully done", AMR_QINIT_DONE},
- {NULL, 0},
- {"unknown init code", 0}
-};
-
-struct amr_code_lookup amr_table_sinit[] = {
- {"init abnormal terminated", AMR_SINIT_ABEND},
- {"insufficient memory", AMR_SINIT_NOMEM},
- {"firmware flushing cache", AMR_SINIT_CACHEFLUSH},
- {"init in progress", AMR_SINIT_INPROG},
- {"firmware spinning drives", AMR_SINIT_SPINUP},
- {"init successfully done", AMR_SINIT_DONE},
- {NULL, 0},
- {"unknown init code", 0}
-};
-
-struct amr_code_lookup amr_table_drvstate[] = {
- {"offline", AMR_DRV_OFFLINE},
- {"degraded", AMR_DRV_DEGRADED},
- {"optimal", AMR_DRV_OPTIMAL},
- {"online", AMR_DRV_ONLINE},
- {"failed", AMR_DRV_FAILED},
- {"rebuild", AMR_DRV_REBUILD},
- {"hot spare", AMR_DRV_HOTSPARE},
- {NULL, 0},
- {"unknown", 0}
-};
-
-struct amr_code_lookup amr_table_adaptertype[] = {
- {"Series 431", AMR_SIG_431},
- {"Series 438", AMR_SIG_438},
- {"Series 762", AMR_SIG_762},
- {"Integrated HP NetRAID (T5)", AMR_SIG_T5},
- {"Series 466", AMR_SIG_466},
- {"Series 467", AMR_SIG_467},
- {"Integrated HP NetRAID (T7)", AMR_SIG_T7},
- {"Series 490", AMR_SIG_490},
- {NULL, 0},
- {"unknown adapter", 0}
-};
-
-#endif
diff --git a/sys/dev/awi/README b/sys/dev/awi/README
deleted file mode 100644
index 38aaec59de927..0000000000000
--- a/sys/dev/awi/README
+++ /dev/null
@@ -1,60 +0,0 @@
-# $Id: README,v 1.19 2000/03/24 08:13:24 onoe Exp $
-# $FreeBSD$
-
-===== Configuration
- ifconfig awi0 link0
- changes to encapsulation from 802.2 LLC/SNAP (default) to
- ether encapsulation. MELCO access point and PAO's ux driver
- use this.
-
-===== Supported Cards
- Any IEEE 802.11 cards use AMD Am79C930 and Harris (Intersil) Chipset
- with PCnetMobile firmware by AMD.
- BayStack 650 1Mbps Frequency Hopping PCCARD adapter
- BayStack 660 2Mbps Direct Sequence PCCARD adapter
- Icom SL-200 2Mbps Direct Sequence PCCARD adapter
- Melco WLI-PCM 2Mbps Direct Sequence PCCARD adapter
- NEL SSMagic 2Mbps Direct Sequence PCCARD adapter
- Netwave AirSurfer Plus
- 1Mbps Frequency Hopping PCCARD adapter
- Netwave AirSurfer Pro
- 2Mbps Direct Sequence PCCARD adapter
-
-===== Known Problems
- WEP is not supported.
- Does not create IBSS itself.
-
- Cannot configure at all on FreeBSD:
- selection of infrastructure/adhoc mode
- ESSID
- ...
-
-===== How to add
-
-*** NetBSD current
- already merged into current source tree.
-
- pcmcia: update the awi driver, which now supports AMD 79c930-based
- 802.11DS cards as well as 802.11FH cards, and can operate
- in infrastructure mode, adhoc mode, and wi(4) compatible
- adhoc mode. [onoe 20000322]
-
-*** FreeBSD-current
- make directory /sys/dev/awi and put all files there.
- move if_ieee80211.h to /sys/net
- add following lines to /sys/conf/files
- dev/awi/am79c930.c optional awi
- dev/awi/awi.c optional awi
- dev/awi/if_awi_pccard.c optional awi card
- add following line to config file
- device awi0
- config and make kernel
-
- add description of your card to /etc/pccard.conf
- ex.
- card "AMD" "Am79C930"
- config 0x1 "awi0" ?
- card "Icom" "SL-200"
- config 0x1 "awi0" ?
- card "Bay Networks" "BayStack 650 Wireless LAN"
- config 0x1 "awi0" ?
diff --git a/sys/dev/awi/am79c930.c b/sys/dev/awi/am79c930.c
deleted file mode 100644
index aa9c97f5a538a..0000000000000
--- a/sys/dev/awi/am79c930.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/* $NetBSD: am79c930.c,v 1.5 2000/03/23 13:57:58 onoe Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Bill Sommerfeld
- *
- * 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-/*
- * Am79c930 chip driver.
- *
- * This is used by the awi driver to use the shared
- * memory attached to the 79c930 to communicate with the firmware running
- * in the 930's on-board 80188 core.
- *
- * The 79c930 can be mapped into just I/O space, or also have a
- * memory mapping; the mapping must be set up by the bus front-end
- * before am79c930_init is called.
- */
-
-/*
- * operations:
- *
- * read_8, read_16, read_32, read_64, read_bytes
- * write_8, write_16, write_32, write_64, write_bytes
- * (two versions, depending on whether memory-space or i/o space is in use).
- *
- * interrupt E.C.
- * start isr
- * end isr
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#ifndef __FreeBSD__
-#include <sys/device.h>
-#endif
-
-#include <machine/cpu.h>
-#ifdef __FreeBSD__
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#endif
-#include <machine/bus.h>
-#ifdef __NetBSD__
-#include <machine/intr.h>
-#endif
-
-#ifdef __NetBSD__
-#include <dev/ic/am79c930reg.h>
-#include <dev/ic/am79c930var.h>
-#endif
-#ifdef __FreeBSD__
-#include <dev/awi/am79c930reg.h>
-#include <dev/awi/am79c930var.h>
-#endif
-
-#define AM930_DELAY(x) /*nothing*/
-
-void am79c930_regdump __P((struct am79c930_softc *sc));
-
-static void io_write_1 __P((struct am79c930_softc *, u_int32_t, u_int8_t));
-static void io_write_2 __P((struct am79c930_softc *, u_int32_t, u_int16_t));
-static void io_write_4 __P((struct am79c930_softc *, u_int32_t, u_int32_t));
-static void io_write_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t));
-
-static u_int8_t io_read_1 __P((struct am79c930_softc *, u_int32_t));
-static u_int16_t io_read_2 __P((struct am79c930_softc *, u_int32_t));
-static u_int32_t io_read_4 __P((struct am79c930_softc *, u_int32_t));
-static void io_read_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t));
-
-static void mem_write_1 __P((struct am79c930_softc *, u_int32_t, u_int8_t));
-static void mem_write_2 __P((struct am79c930_softc *, u_int32_t, u_int16_t));
-static void mem_write_4 __P((struct am79c930_softc *, u_int32_t, u_int32_t));
-static void mem_write_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t));
-
-static u_int8_t mem_read_1 __P((struct am79c930_softc *, u_int32_t));
-static u_int16_t mem_read_2 __P((struct am79c930_softc *, u_int32_t));
-static u_int32_t mem_read_4 __P((struct am79c930_softc *, u_int32_t));
-static void mem_read_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t));
-
-static struct am79c930_ops iospace_ops = {
- io_write_1,
- io_write_2,
- io_write_4,
- io_write_bytes,
- io_read_1,
- io_read_2,
- io_read_4,
- io_read_bytes
-};
-
-struct am79c930_ops memspace_ops = {
- mem_write_1,
- mem_write_2,
- mem_write_4,
- mem_write_bytes,
- mem_read_1,
- mem_read_2,
- mem_read_4,
- mem_read_bytes
-};
-
-static void io_write_1 (sc, off, val)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int8_t val;
-{
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA, val);
- AM930_DELAY(1);
-}
-
-static void io_write_2 (sc, off, val)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int16_t val;
-{
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, val & 0xff);
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, (val>>8)&0xff);
- AM930_DELAY(1);
-}
-
-static void io_write_4 (sc, off, val)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int32_t val;
-{
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,val & 0xff);
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>8)&0xff);
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>16)&0xff);
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>24)&0xff);
- AM930_DELAY(1);
-}
-
-static void io_write_bytes (sc, off, ptr, len)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int8_t *ptr;
- size_t len;
-{
- int i;
-
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- for (i=0; i<len; i++)
- bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,ptr[i]);
-}
-
-static u_int8_t io_read_1 (sc, off)
- struct am79c930_softc *sc;
- u_int32_t off;
-{
- u_int8_t val;
-
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA);
- AM930_DELAY(1);
- return val;
-}
-
-static u_int16_t io_read_2 (sc, off)
- struct am79c930_softc *sc;
- u_int32_t off;
-{
- u_int16_t val;
-
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA);
- AM930_DELAY(1);
- val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8;
- AM930_DELAY(1);
- return val;
-}
-
-static u_int32_t io_read_4 (sc, off)
- struct am79c930_softc *sc;
- u_int32_t off;
-{
- u_int32_t val;
-
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA);
- AM930_DELAY(1);
- val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8;
- AM930_DELAY(1);
- val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 16;
- AM930_DELAY(1);
- val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 24;
- AM930_DELAY(1);
- return val;
-}
-
-static void io_read_bytes (sc, off, ptr, len)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int8_t *ptr;
- size_t len;
-{
- int i;
-
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
- ((off>>8)& 0x7f));
- AM930_DELAY(1);
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
- AM930_DELAY(1);
- for (i=0; i<len; i++)
- ptr[i] = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
- AM79C930_IODPA);
-}
-
-static void mem_write_1 (sc, off, val)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int8_t val;
-{
- bus_space_write_1(sc->sc_memt, sc->sc_memh, off, val);
-}
-
-static void mem_write_2 (sc, off, val)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int16_t val;
-{
- bus_space_tag_t t = sc->sc_memt;
- bus_space_handle_t h = sc->sc_memh;
-
- /* could be unaligned */
- if ((off & 0x1) == 0)
- bus_space_write_2(t, h, off, val);
- else {
- bus_space_write_1(t, h, off, val & 0xff);
- bus_space_write_1(t, h, off+1, (val >> 8) & 0xff);
- }
-}
-
-static void mem_write_4 (sc, off, val)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int32_t val;
-{
- bus_space_tag_t t = sc->sc_memt;
- bus_space_handle_t h = sc->sc_memh;
-
- /* could be unaligned */
- if ((off & 0x3) == 0)
- bus_space_write_4(t, h, off, val);
- else {
- bus_space_write_1(t, h, off, val & 0xff);
- bus_space_write_1(t, h, off+1, (val >> 8) & 0xff);
- bus_space_write_1(t, h, off+2, (val >> 16) & 0xff);
- bus_space_write_1(t, h, off+3, (val >> 24) & 0xff);
- }
-}
-
-static void mem_write_bytes (sc, off, ptr, len)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int8_t *ptr;
- size_t len;
-{
- bus_space_write_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len);
-}
-
-
-static u_int8_t mem_read_1 (sc, off)
- struct am79c930_softc *sc;
- u_int32_t off;
-{
- return bus_space_read_1(sc->sc_memt, sc->sc_memh, off);
-}
-
-static u_int16_t mem_read_2 (sc, off)
- struct am79c930_softc *sc;
- u_int32_t off;
-{
- /* could be unaligned */
- if ((off & 0x1) == 0)
- return bus_space_read_2(sc->sc_memt, sc->sc_memh, off);
- else
- return
- bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) |
- (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8);
-}
-
-static u_int32_t mem_read_4 (sc, off)
- struct am79c930_softc *sc;
- u_int32_t off;
-{
- /* could be unaligned */
- if ((off & 0x3) == 0)
- return bus_space_read_4(sc->sc_memt, sc->sc_memh, off);
- else
- return
- bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) |
- (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8) |
- (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+2) <<16) |
- (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+3) <<24);
-}
-
-
-
-static void mem_read_bytes (sc, off, ptr, len)
- struct am79c930_softc *sc;
- u_int32_t off;
- u_int8_t *ptr;
- size_t len;
-{
- bus_space_read_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len);
-}
-
-
-
-
-/*
- * Set bits in GCR.
- */
-
-void am79c930_gcr_setbits (sc, bits)
- struct am79c930_softc *sc;
- u_int8_t bits;
-{
- u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR);
-
- gcr |= bits;
-
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr);
-}
-
-/*
- * Clear bits in GCR.
- */
-
-void am79c930_gcr_clearbits (sc, bits)
- struct am79c930_softc *sc;
- u_int8_t bits;
-{
- u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR);
-
- gcr &= ~bits;
-
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr);
-}
-
-u_int8_t am79c930_gcr_read (sc)
- struct am79c930_softc *sc;
-{
- return bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR);
-}
-
-#if 0
-void am79c930_regdump (sc)
- struct am79c930_softc *sc;
-{
- u_int8_t buf[8];
- int i;
-
- AM930_DELAY(5);
- for (i=0; i<8; i++) {
- buf[i] = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, i);
- AM930_DELAY(5);
- }
- printf("am79c930: regdump:");
- for (i=0; i<8; i++) {
- printf(" %02x", buf[i]);
- }
- printf("\n");
-}
-#endif
-
-void am79c930_chip_init (sc, how)
- struct am79c930_softc *sc;
-{
- /* zero the bank select register, and leave it that way.. */
- bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_BSS, 0);
- if (how)
- sc->sc_ops = &memspace_ops;
- else
- sc->sc_ops = &iospace_ops;
-}
-
-
diff --git a/sys/dev/awi/am79c930reg.h b/sys/dev/awi/am79c930reg.h
deleted file mode 100644
index 64b3e239fab1d..0000000000000
--- a/sys/dev/awi/am79c930reg.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* $NetBSD: am79c930reg.h,v 1.3 2000/03/22 11:22:22 onoe Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Bill Sommerfeld
- *
- * 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-/*
- * Device register definitions gleaned from from the AMD "Am79C930
- * PCnet(tm)-Mobile Single Chip Wireless LAN Media Access Controller"
- * data sheet, AMD Pub #20183, Rev B, amendment/0, issue date August 1997.
- *
- * As of 1999/10/23, this was available from AMD's web site in PDF
- * form.
- */
-
-
-/*
- * The 79c930 contains a bus interface unit, a media access
- * controller, and a tranceiver attachment interface.
- * The MAC contains an 80188 CPU core.
- * typical devices built around this chip typically add 32k or 64k of
- * memory for buffers.
- *
- * The 80188 runs firmware which handles most of the 802.11 gorp, and
- * communicates with the host using shared data structures in this
- * memory; the specifics of the shared memory layout are not covered
- * in this source file; see <dev/ic/am80211fw.h> for details of that layer.
- */
-
-/*
- * Device Registers
- */
-
-#define AM79C930_IO_BASE 0
-#define AM79C930_IO_SIZE 16
-#define AM79C930_IO_SIZE_BIG 40
-#define AM79C930_IO_ALIGN 0x40 /* am79c930 decodes lower 6bits */
-
-
-#define AM79C930_GCR 0 /* General Config Register */
-
-#define AM79C930_GCR_SWRESET 0x80 /* software reset */
-#define AM79C930_GCR_CORESET 0x40 /* core reset */
-#define AM79C930_GCR_DISPWDN 0x20 /* disable powerdown */
-#define AM79C930_GCR_ECWAIT 0x10 /* embedded controller wait */
-#define AM79C930_GCR_ECINT 0x08 /* interrupt from embedded ctrlr */
-#define AM79C930_GCR_INT2EC 0x04 /* interrupt to embedded ctrlr */
-#define AM79C930_GCR_ENECINT 0x02 /* enable interrupts from e.c. */
-#define AM79C930_GCR_DAM 0x01 /* direct access mode (read only) */
-
-#define AM79C930_GCR_BITS "\020\1DAM\2ENECINT\3INT2EC\4ECINT\5ECWAIT\6DISPWDN\7CORESET\010SWRESET"
-
-#define AM79C930_BSS 1 /* Bank Switching Select register */
-
-#define AM79C930_BSS_ECATR 0x80 /* E.C. ALE test read */
-#define AM79C930_BSS_FS 0x20 /* Flash Select */
-#define AM79C930_BSS_MBS 0x18 /* Memory Bank Select */
-#define AM79C930_BSS_EIOW 0x04 /* Expand I/O Window */
-#define AM79C930_BSS_TBS 0x03 /* TAI Bank Select */
-
-#define AM79C930_LMA_LO 2 /* Local Memory Address register (low byte) */
-
-#define AM79C930_LMA_HI 3 /* Local Memory Address register (high byte) */
-
- /* set this bit to turn off ISAPnP version */
-#define AM79C930_LMA_HI_ISAPWRDWN 0x80
-
-/*
- * mmm, inconsistancy in chip documentation:
- * According to page 79--80, all four of the following are equivalent
- * and address the single byte pointed at by BSS_{FS,MBS} | LMA_{HI,LO}
- * According to tables on p63 and p67, they're the LSB through MSB
- * of a 32-bit word.
- */
-
-#define AM79C930_IODPA 4 /* I/O Data port A */
-#define AM79C930_IODPB 5 /* I/O Data port B */
-#define AM79C930_IODPC 6 /* I/O Data port C */
-#define AM79C930_IODPD 7 /* I/O Data port D */
-
-
-/*
- * Tranceiver Attachment Interface Registers (TIR space)
- * (omitted for now, since host access to them is for diagnostic
- * purposes only).
- */
-
-/*
- * memory space goo.
- */
-
-#define AM79C930_MEM_SIZE 0x8000 /* 32k */
-#define AM79C930_MEM_BASE 0x0 /* starting at 0 */
diff --git a/sys/dev/awi/am79c930var.h b/sys/dev/awi/am79c930var.h
deleted file mode 100644
index 1e45c6817a9dd..0000000000000
--- a/sys/dev/awi/am79c930var.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* $NetBSD$ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Bill Sommerfeld
- *
- * 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-#define AM79C930_BUS_PCMCIA 1
-#define AM79C930_BUS_ISAPNP 2 /* not implemented */
-
-struct am79c930_softc
-{
- bus_space_tag_t sc_iot;
- bus_space_handle_t sc_ioh;
-
- bus_space_tag_t sc_memt;
- bus_space_handle_t sc_memh;
-
- struct am79c930_ops *sc_ops;
-
- int sc_bustype;
-};
-
-struct am79c930_ops
-{
- void (*write_1) __P((struct am79c930_softc *, u_int32_t, u_int8_t));
- void (*write_2) __P((struct am79c930_softc *, u_int32_t, u_int16_t));
- void (*write_4) __P((struct am79c930_softc *, u_int32_t, u_int32_t));
- void (*write_bytes) __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t));
-
- u_int8_t (*read_1) __P((struct am79c930_softc *, u_int32_t));
- u_int16_t (*read_2) __P((struct am79c930_softc *, u_int32_t));
- u_int32_t (*read_4) __P((struct am79c930_softc *, u_int32_t));
- void (*read_bytes) __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t));
-};
-
-void am79c930_chip_init __P((struct am79c930_softc *sc, int));
-
-void am79c930_gcr_setbits __P((struct am79c930_softc *sc, u_int8_t bits));
-void am79c930_gcr_clearbits __P((struct am79c930_softc *sc, u_int8_t bits));
-
-u_int8_t am79c930_gcr_read __P((struct am79c930_softc *sc));
-
-#define am79c930_hard_reset(sc) am79c930_gcr_setbits(sc, AM79C930_GCR_CORESET)
-#define am79c930_hard_reset_off(sc) am79c930_gcr_clearbits(sc, AM79C930_GCR_CORESET)
-
-
diff --git a/sys/dev/awi/awireg.h b/sys/dev/awi/awireg.h
deleted file mode 100644
index dc936eb730ec3..0000000000000
--- a/sys/dev/awi/awireg.h
+++ /dev/null
@@ -1,460 +0,0 @@
-/* $NetBSD: awireg.h,v 1.3 2000/03/22 11:22:22 onoe Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Bill Sommerfeld
- *
- * 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-/*
- * The firmware typically loaded onto Am79C930-based 802.11 interfaces
- * uses a 32k or larger shared memory buffer to communicate with the
- * host.
- *
- * Depending on the exact configuration of the device, this buffer may
- * either be mapped into PCMCIA memory space, or accessible a byte at
- * a type through PCMCIA I/O space.
- *
- * This header defines offsets into this shared memory.
- */
-
-
-/*
- * LAST_TXD block. 5 32-bit words.
- *
- * There are five different output queues; this defines pointers to
- * the last completed descriptor for each one.
- */
-#define AWI_LAST_TXD 0x3ec /* last completed Tx Descr */
-
-#define AWI_LAST_BCAST_TXD AWI_LAST_TXD+0
-#define AWI_LAST_MGT_TXD AWI_LAST_TXD+4
-#define AWI_LAST_DATA_TXD AWI_LAST_TXD+8
-#define AWI_LAST_PS_POLL_TXD AWI_LAST_TXD+12
-#define AWI_LAST_CF_POLL_TXD AWI_LAST_TXD+16
-
-/*
- * Banner block; null-terminated string.
- *
- * The doc says it contains
- * "PCnetMobile:v2.00 mmddyy APIx.x\0"
- */
-
-#define AWI_BANNER 0x480 /* Version string */
-#define AWI_BANNER_LEN 0x20
-
-/*
- * Command block protocol:
- * write command byte to a zero value.
- * write command status to a zero value.
- * write arguments to AWI_COMMAND_PARAMS
- * write command byte to a non-zero value.
- * wait for command status to be non-zero.
- * write command byte to a zero value.
- * write command status to a zero value.
- */
-
-#define AWI_CMD 0x4a0 /* Command opcode byte */
-
-#define AWI_CMD_IDLE 0x0
-#define AWI_CMD_NOP 0x1
-
-#define AWI_CMD_SET_MIB 0x2
-#define AWI_CMD_GET_MIB 0x9
-
-#define AWI_CA_MIB_TYPE 0x0
-#define AWI_CA_MIB_SIZE 0x1
-#define AWI_CA_MIB_INDEX 0x2
-#define AWI_CA_MIB_DATA 0x4
-
-#define AWI_MIB_LOCAL 0x0
-#define AWI_MIB_ADDR 0x2
-#define AWI_MIB_MAC 0x3
-#define AWI_MIB_STAT 0x4
-#define AWI_MIB_MGT 0x5
-#define AWI_MIB_DRVR 0x6
-#define AWI_MIB_PHY 0x7
-
-
-#define AWI_CMD_INIT_TX 0x3
-
-#define AWI_CA_TX_LEN 0x14
-#define AWI_CA_TX_DATA 0x0
-#define AWI_CA_TX_MGT 0x4
-#define AWI_CA_TX_BCAST 0x8
-#define AWI_CA_TX_PS 0xc
-#define AWI_CA_TX_CF 0x10
-
-#define AWI_CMD_FLUSH_TX 0x4
-
-#define AWI_CA_FTX_LEN 0x5
-#define AWI_CA_FTX_DATA 0x0
-#define AWI_CA_FTX_MGT 0x1
-#define AWI_CA_FTX_BCAST 0x2
-#define AWI_CA_FTX_PS 0x3
-#define AWI_CA_FTX_CF 0x4
-
-#define AWI_CMD_INIT_RX 0x5
-#define AWI_CA_IRX_LEN 0x8
-#define AWI_CA_IRX_DATA_DESC 0x0 /* return */
-#define AWI_CA_IRX_PS_DESC 0x4 /* return */
-
-#define AWI_CMD_KILL_RX 0x6
-
-#define AWI_CMD_SLEEP 0x7
-#define AWI_CA_SLEEP_LEN 0x8
-#define AWI_CA_WAKEUP 0x0 /* uint64 */
-
-#define AWI_CMD_WAKE 0x8
-
-#define AWI_CMD_SCAN 0xa
-#define AWI_CA_SCAN_LEN 0x6
-#define AWI_CA_SCAN_DURATION 0x0
-#define AWI_CA_SCAN_SET 0x2
-#define AWI_CA_SCAN_PATTERN 0x3
-#define AWI_CA_SCAN_IDX 0x4
-#define AWI_CA_SCAN_SUSP 0x5
-
-#define AWI_CMD_SYNC 0xb
-#define AWI_CA_SYNC_LEN 0x14
-#define AWI_CA_SYNC_SET 0x0
-#define AWI_CA_SYNC_PATTERN 0x1
-#define AWI_CA_SYNC_IDX 0x2
-#define AWI_CA_SYNC_STARTBSS 0x3
-#define AWI_CA_SYNC_DWELL 0x4
-#define AWI_CA_SYNC_MBZ 0x6
-#define AWI_CA_SYNC_TIMESTAMP 0x8
-#define AWI_CA_SYNC_REFTIME 0x10
-
-#define AWI_CMD_RESUME 0xc
-
-#define AWI_CMD_STATUS 0x4a1 /* Command status */
-
-#define AWI_STAT_IDLE 0x0
-#define AWI_STAT_OK 0x1
-#define AWI_STAT_BADCMD 0x2
-#define AWI_STAT_BADPARM 0x3
-#define AWI_STAT_NOTIMP 0x4
-#define AWI_STAT_BADRES 0x5
-#define AWI_STAT_BADMODE 0x6
-
-#define AWI_ERROR_OFFSET 0x4a2 /* Offset to erroneous parameter */
-#define AWI_CMD_PARAMS 0x4a4 /* Command parameters */
-
-#define AWI_CSB 0x4f0 /* Control/Status block */
-
-#define AWI_SELFTEST 0x4f0
-
-#define AWI_SELFTEST_INIT 0x00 /* initial */
-#define AWI_SELFTEST_FIRMCKSUM 0x01 /* firmware cksum running */
-#define AWI_SELFTEST_HARDWARE 0x02 /* hardware tests running */
-#define AWI_SELFTEST_MIB 0x03 /* mib initializing */
-
-#define AWI_SELFTEST_MIB_FAIL 0xfa
-#define AWI_SELFTEST_RADIO_FAIL 0xfb
-#define AWI_SELFTEST_MAC_FAIL 0xfc
-#define AWI_SELFTEST_FLASH_FAIL 0xfd
-#define AWI_SELFTEST_RAM_FAIL 0xfe
-#define AWI_SELFTEST_PASSED 0xff
-
-#define AWI_STA_STATE 0x4f1
-
-#define AWI_STA_AP 0x20 /* acting as AP */
-#define AWI_STA_NOPSP 0x10 /* Power Saving disabled */
-#define AWI_STA_DOZE 0x08 /* about to go to sleep */
-#define AWI_STA_PSP 0x04 /* enable PSP */
-#define AWI_STA_RXEN 0x02 /* enable RX */
-#define AWI_STA_TXEN 0x01 /* enable TX */
-
-#define AWI_INTSTAT 0x4f3
-#define AWI_INTMASK 0x4f4
-
-/* Bits in AWI_INTSTAT/AWI_INTMASK */
-
-#define AWI_INT_GROGGY 0x80 /* about to wake up */
-#define AWI_INT_CFP_ENDING 0x40 /* cont. free period ending */
-#define AWI_INT_DTIM 0x20 /* beacon outgoing */
-#define AWI_INT_CFP_START 0x10 /* cont. free period starting */
-#define AWI_INT_SCAN_CMPLT 0x08 /* scan complete */
-#define AWI_INT_TX 0x04 /* tx done */
-#define AWI_INT_RX 0x02 /* rx done */
-#define AWI_INT_CMD 0x01 /* cmd done */
-
-/*
- * The following are used to implement a locking protocol between host
- * and MAC to protect the interrupt status and mask fields.
- *
- * driver: read lockout_host byte; if zero, set lockout_mac to non-zero,
- * then reread lockout_host byte; if still zero, host has lock.
- * if non-zero, clear lockout_mac, loop.
- */
-
-#define AWI_LOCKOUT_MAC 0x4f5
-#define AWI_LOCKOUT_HOST 0x4f6
-
-
-#define AWI_INTSTAT2 0x4f7
-#define AWI_INTMASK2 0x4fd
-
-/* Bits in AWI_INTSTAT2/INTMASK2 */
-#define AWI_INT2_RXMGT 0x80 /* mgt/ps recieved */
-#define AWI_INT2_RXDATA 0x40 /* data received */
-#define AWI_INT2_TXMGT 0x10 /* mgt tx done */
-#define AWI_INT2_TXCF 0x08 /* CF tx done */
-#define AWI_INT2_TXPS 0x04 /* PS tx done */
-#define AWI_INT2_TXBCAST 0x02 /* Broadcast tx done */
-#define AWI_INT2_TXDATA 0x01 /* data tx done */
-
-#define AWI_DIS_PWRDN 0x4fc /* disable powerdown if set */
-
-#define AWI_DRIVERSTATE 0x4fe /* driver state */
-
-#define AWI_DRV_STATEMASK 0x0f
-
-#define AWI_DRV_RESET 0x0
-#define AWI_DRV_INFSY 0x1 /* inf synced */
-#define AWI_DRV_ADHSC 0x2 /* adhoc scan */
-#define AWI_DRV_ADHSY 0x3 /* adhoc synced */
-#define AWI_DRV_INFSC 0x4 /* inf scanning */
-#define AWI_DRV_INFAUTH 0x5 /* inf authed */
-#define AWI_DRV_INFASSOC 0x6 /* inf associated */
-#define AWI_DRV_INFTOSS 0x7 /* inf handoff */
-#define AWI_DRV_APNONE 0x8 /* AP activity: no assoc */
-#define AWI_DRV_APQUIET 0xc /* AP: >=one assoc, no traffic */
-#define AWI_DRV_APLO 0xd /* AP: >=one assoc, light tfc */
-#define AWI_DRV_APMED 0xe /* AP: >=one assoc, mod tfc */
-#define AWI_DRV_APHIGH 0xf /* AP: >=one assoc, heavy tfc */
-
-#define AWI_DRV_AUTORXLED 0x10
-#define AWI_DRV_AUTOTXLED 0x20
-#define AWI_DRV_RXLED 0x40
-#define AWI_DRV_TXLED 0x80
-
-#define AWI_VBM 0x500 /* Virtual Bit Map */
-
-#define AWI_BUFFERS 0x600 /* Buffers */
-#define AWI_BUFFERS_END 0x6000
-
-/*
- * Receive descriptors; there are a linked list of these chained
- * through the "NEXT" fields, starting from XXX
- */
-
-#define AWI_RXD_SIZE 0x18
-
-#define AWI_RXD_NEXT 0x4
-#define AWI_RXD_NEXT_LAST 0x80000000
-
-
-#define AWI_RXD_HOST_DESC_STATE 0x9
-
-#define AWI_RXD_ST_OWN 0x80 /* host owns this */
-#define AWI_RXD_ST_CONSUMED 0x40 /* host is done */
-#define AWI_RXD_ST_LF 0x20 /* last frag */
-#define AWI_RXD_ST_CRC 0x08 /* CRC error */
-#define AWI_RXD_ST_OFLO 0x02 /* possible buffer overrun */
-#define AWI_RXD_ST_RXERROR 0x01 /* this frame is borked; discard me */
-
-#define AWI_RXD_RSSI 0xa /* 1 byte: radio strength indicator */
-#define AWI_RXD_INDEX 0xb /* 1 byte: FH hop index or DS channel */
-#define AWI_RXD_LOCALTIME 0xc /* 4 bytes: local time of RX */
-#define AWI_RXD_START_FRAME 0x10 /* 4 bytes: ptr to first received byte */
-#define AWI_RXD_LEN 0x14 /* 2 bytes: rx len in bytes */
-#define AWI_RXD_RATE 0x16 /* 1 byte: rx rate in 1e5 bps */
-
-/*
- * Transmit descriptors.
- */
-
-#define AWI_TXD_SIZE 0x18
-
-#define AWI_TXD_START 0x00 /* pointer to start of frame */
-#define AWI_TXD_NEXT 0x04 /* pointer to next TXD */
-#define AWI_TXD_LENGTH 0x08 /* length of frame */
-#define AWI_TXD_STATE 0x0a /* state */
-
-#define AWI_TXD_ST_OWN 0x80 /* MAC owns this */
-#define AWI_TXD_ST_DONE 0x40 /* MAC is done */
-#define AWI_TXD_ST_REJ 0x20 /* MAC doesn't like */
-#define AWI_TXD_ST_MSDU 0x10 /* MSDU timeout */
-#define AWI_TXD_ST_ABRT 0x08 /* TX aborted */
-#define AWI_TXD_ST_RETURNED 0x04 /* TX returned */
-#define AWI_TXD_ST_RETRY 0x02 /* TX retries exceeded */
-#define AWI_TXD_ST_ERROR 0x01 /* TX error */
-
-#define AWI_TXD_RATE 0x0b /* rate */
-
-#define AWI_RATE_1MBIT 10
-#define AWI_RATE_2MBIT 20
-
-#define AWI_TXD_NDA 0x0c /* num DIFS attempts */
-#define AWI_TXD_NDF 0x0d /* num DIFS failures */
-#define AWI_TXD_NSA 0x0e /* num SIFS attempts */
-#define AWI_TXD_NSF 0x0f /* num SIFS failures */
-
-#define AWI_TXD_NRA 0x14 /* num RTS attempts */
-#define AWI_TXD_NDTA 0x15 /* num data attempts */
-#define AWI_TXD_CTL 0x16 /* control */
-
-#define AWI_TXD_CTL_PSN 0x80 /* preserve sequence in MAC frame */
-#define AWI_TXD_CTL_BURST 0x02 /* host is doing 802.11 fragmt. */
-#define AWI_TXD_CTL_FRAGS 0x01 /* override normal fragmentation */
-
-/*
- * MIB structures.
- */
-
-#define AWI_ESS_ID_SIZE (IEEE80211_NWID_LEN+2)
-struct awi_mib_local {
- u_int8_t Fragmentation_Dis;
- u_int8_t Add_PLCP_Dis;
- u_int8_t MAC_Hdr_Prsv;
- u_int8_t Rx_Mgmt_Que_En;
- u_int8_t Re_Assembly_Dis;
- u_int8_t Strip_PLCP_Dis;
- u_int8_t Rx_Error_Dis;
- u_int8_t Power_Saving_Mode_Dis;
- u_int8_t Accept_All_Multicast_Dis;
- u_int8_t Check_Seq_Cntl_Dis;
- u_int8_t Flush_CFP_Queue_On_CF_End;
- u_int8_t Network_Mode;
- u_int8_t PWD_Lvl;
- u_int8_t CFP_Mode;
- u_int8_t Tx_Buffer_Offset[4];
- u_int8_t Tx_Buffer_Size[4];
- u_int8_t Rx_Buffer_Offset[4];
- u_int8_t Rx_Buffer_Size[4];
- u_int8_t Acting_as_AP;
- u_int8_t Fill_CFP;
-};
-
-struct awi_mib_mac {
- u_int8_t _Reserved1[2];
- u_int8_t _Reserved2[2];
- u_int8_t aRTS_Threshold[2];
- u_int8_t aCW_max[2];
- u_int8_t aCW_min[2];
- u_int8_t aPromiscuous_Enable;
- u_int8_t _Reserved3;
- u_int8_t _Reserved4[4];
- u_int8_t aShort_Retry_Limit;
- u_int8_t aLong_Retry_Limit;
- u_int8_t aMax_Frame_Length[2];
- u_int8_t aFragmentation_Threshold[2];
- u_int8_t aProbe_Delay[2];
- u_int8_t aMin_Probe_Response_Time[2];
- u_int8_t aMax_Probe_Response_Time[2];
- u_int8_t aMax_Transmit_MSDU_Lifetime[4];
- u_int8_t aMax_Receive_MSDU_Lifetime[4];
- u_int8_t aStation_Basic_Rate[2];
- u_int8_t aDesired_ESS_ID[AWI_ESS_ID_SIZE];
-};
-
-struct awi_mib_stat {
- u_int8_t aTransmitted_MPDU_Count[4];
- u_int8_t aTransmitted_MSDU_Count[4];
- u_int8_t aOctets_Transmitted_Cnt[4];
- u_int8_t aMulticast_Transmitted_Frame_Count[2];
- u_int8_t aBroadcast_Transmitted_Frame_Count[2];
- u_int8_t aFailed_Count[4];
- u_int8_t aRetry_Count[4];
- u_int8_t aMultiple_Retry_Count[4];
- u_int8_t aFrame_Duplicate_Count[4];
- u_int8_t aRTS_Success_Count[4];
- u_int8_t aRTS_Failure_Count[4];
- u_int8_t aACK_Failure_Count[4];
- u_int8_t aReceived_Frame_Count [4];
- u_int8_t aOctets_Received_Count[4];
- u_int8_t aMulticast_Received_Count[2];
- u_int8_t aBroadcast_Received_Count[2];
- u_int8_t aFCS_Error_Count[4];
- u_int8_t aError_Count[4];
- u_int8_t aWEP_Undecryptable_Count[4];
-};
-
-struct awi_mib_mgt {
- u_int8_t aPower_Mgt_Mode;
- u_int8_t aScan_Mode;
-#define AWI_SCAN_PASSIVE 0x00
-#define AWI_SCAN_ACTIVE 0x01
-#define AWI_SCAN_BACKGROUND 0x02
- u_int8_t aScan_State;
- u_int8_t aDTIM_Period;
- u_int8_t aATIM_Window[2];
- u_int8_t Wep_Required;
- u_int8_t _Reserved1;
- u_int8_t aBeacon_Period[2];
- u_int8_t aPassive_Scan_Duration[2];
- u_int8_t aListen_Interval[2];
- u_int8_t aMedium_Occupancy_Limit[2];
- u_int8_t aMax_MPDU_Time[2];
- u_int8_t aCFP_Max_Duration[2];
- u_int8_t aCFP_Rate;
- u_int8_t Do_Not_Receive_DTIMs;
- u_int8_t aStation_ID[2];
- u_int8_t aCurrent_BSS_ID[ETHER_ADDR_LEN];
- u_int8_t aCurrent_ESS_ID[AWI_ESS_ID_SIZE];
-};
-
-#define AWI_GROUP_ADDR_SIZE 4
-struct awi_mib_addr {
- u_int8_t aMAC_Address[ETHER_ADDR_LEN];
- u_int8_t aGroup_Addresses[AWI_GROUP_ADDR_SIZE][ETHER_ADDR_LEN];
- u_int8_t aTransmit_Enable_Status;
- u_int8_t _Reserved1;
-};
-
-#define AWI_PWR_LEVEL_SIZE 4
-struct awi_mib_phy {
- u_int8_t aSlot_Time[2];
- u_int8_t aSIFS[2];
- u_int8_t aMPDU_Maximum[2];
- u_int8_t aHop_Time[2];
- u_int8_t aSuprt_Data_Rates[4];
- u_int8_t aCurrent_Reg_Domain;
-#define AWI_REG_DOMAIN_US 0x10
-#define AWI_REG_DOMAIN_CA 0x20
-#define AWI_REG_DOMAIN_EU 0x30
-#define AWI_REG_DOMAIN_ES 0x31
-#define AWI_REG_DOMAIN_FR 0x32
-#define AWI_REG_DOMAIN_JP 0x40
- u_int8_t aPreamble_Lngth;
- u_int8_t aPLCP_Hdr_Lngth;
- u_int8_t Pwr_Up_Time[AWI_PWR_LEVEL_SIZE][2];
- u_int8_t IEEE_PHY_Type;
-#define AWI_PHY_TYPE_FH 1
-#define AWI_PHY_TYPE_DS 2
-#define AWI_PHY_TYPE_IR 3
- u_int8_t RCR_33A_Bits[8];
-};
diff --git a/sys/dev/awi/awivar.h b/sys/dev/awi/awivar.h
deleted file mode 100644
index 8e86f841a0065..0000000000000
--- a/sys/dev/awi/awivar.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/* $NetBSD: awivar.h,v 1.12 2000/07/21 04:48:56 onoe Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Bill Sommerfeld
- *
- * 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-/* timer values in msec */
-#define AWI_SELFTEST_TIMEOUT 5000
-#define AWI_CMD_TIMEOUT 2000
-#define AWI_LOCKOUT_TIMEOUT 50
-#define AWI_ASCAN_DURATION 100
-#define AWI_ASCAN_WAIT 3000
-#define AWI_PSCAN_DURATION 200
-#define AWI_PSCAN_WAIT 5000
-#define AWI_TRANS_TIMEOUT 2000
-
-#define AWI_NTXBUFS 4
-#define AWI_MAX_KEYLEN 16
-
-enum awi_status {
- AWI_ST_INIT,
- AWI_ST_SCAN,
- AWI_ST_SETSS,
- AWI_ST_SYNC,
- AWI_ST_AUTH,
- AWI_ST_ASSOC,
- AWI_ST_RUNNING
-};
-
-struct awi_bss
-{
- TAILQ_ENTRY(awi_bss) list;
- u_int8_t esrc[ETHER_ADDR_LEN];
- u_int8_t chanset; /* channel set to use */
- u_int8_t pattern; /* hop pattern to use */
- u_int8_t index; /* index to use */
- u_int8_t rssi; /* strength of this beacon */
- u_int16_t dwell_time; /* dwell time */
- u_int8_t timestamp[8]; /* timestamp of this bss */
- u_int8_t bssid[ETHER_ADDR_LEN];
- u_int16_t capinfo;
- u_int32_t rxtime; /* unit's local time */
- u_int16_t interval; /* beacon interval */
- u_int8_t txrate;
- u_int8_t fails;
- u_int8_t essid[IEEE80211_NWID_LEN + 2];
-};
-
-struct awi_wep_algo {
- char *awa_name;
- int (*awa_ctxlen) __P((void));
- void (*awa_setkey) __P((void *, u_char *, int));
- void (*awa_encrypt) __P((void *, u_char *, u_char *, int));
- void (*awa_decrypt) __P((void *, u_char *, u_char *, int));
-};
-
-struct awi_softc
-{
-#ifdef __NetBSD__
- struct device sc_dev;
- struct ethercom sc_ec;
- void *sc_ih; /* interrupt handler */
-#endif
-#ifdef __FreeBSD__
-#if __FreeBSD__ >= 4
- struct {
- char dv_xname[64]; /*XXX*/
- } sc_dev;
-#else
- struct device sc_dev;
-#endif
- struct arpcom sc_ec;
-#endif
- struct am79c930_softc sc_chip;
- struct ifnet *sc_ifp;
- int (*sc_enable) __P((struct awi_softc *));
- void (*sc_disable) __P((struct awi_softc *));
-
- struct ifmedia sc_media;
- enum awi_status sc_status;
- unsigned int sc_enabled:1,
- sc_busy:1,
- sc_cansleep:1,
- sc_invalid:1,
- sc_enab_intr:1,
- sc_format_llc:1,
- sc_start_bss:1,
- sc_rawbpf:1,
- sc_no_bssid:1,
- sc_active_scan:1,
- sc_attached:1; /* attach has succeeded */
- u_int8_t sc_cmd_inprog;
- int sc_sleep_cnt;
-
- int sc_mgt_timer;
-
- TAILQ_HEAD(, awi_bss) sc_scan;
- u_int8_t sc_scan_cur;
- u_int8_t sc_scan_min;
- u_int8_t sc_scan_max;
- u_int8_t sc_scan_set;
- struct awi_bss sc_bss;
- u_int8_t sc_ownssid[IEEE80211_NWID_LEN + 2];
- u_int8_t sc_ownch;
-
- int sc_rx_timer;
- u_int32_t sc_rxdoff;
- u_int32_t sc_rxmoff;
- struct mbuf *sc_rxpend;
-
- int sc_tx_timer;
- u_int8_t sc_tx_rate;
- struct ifqueue sc_mgtq;
- u_int32_t sc_txbase;
- u_int32_t sc_txend;
- u_int32_t sc_txnext;
- u_int32_t sc_txdone;
-
- int sc_wep_keylen[IEEE80211_WEP_NKID]; /* keylen */
- u_int8_t sc_wep_key[IEEE80211_WEP_NKID][AWI_MAX_KEYLEN];
- int sc_wep_defkid;
- void *sc_wep_ctx; /* work area */
- struct awi_wep_algo *sc_wep_algo;
-
- u_char sc_banner[AWI_BANNER_LEN];
- struct awi_mib_local sc_mib_local;
- struct awi_mib_addr sc_mib_addr;
- struct awi_mib_mac sc_mib_mac;
- struct awi_mib_stat sc_mib_stat;
- struct awi_mib_mgt sc_mib_mgt;
- struct awi_mib_phy sc_mib_phy;
-};
-
-#define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
-#define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
-#define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
-#define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
-
-#define awi_write_1(sc, off, val) \
- ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
-#define awi_write_2(sc, off, val) \
- ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
-#define awi_write_4(sc, off, val) \
- ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
-#define awi_write_bytes(sc, off, ptr, len) \
- ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
-
-#define awi_drvstate(sc, state) \
- awi_write_1(sc, AWI_DRIVERSTATE, \
- ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
-
-/* unalligned little endian access */
-#define LE_READ_2(p) \
- (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8))
-#define LE_READ_4(p) \
- (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) | \
- (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))
-#define LE_WRITE_2(p, v) \
- ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
- (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)))
-#define LE_WRITE_4(p, v) \
- ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \
- (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \
- (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \
- (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff)))
-
-#define AWI_80211_RATE(rate) (((rate) & 0x7f) * 5)
-
-int awi_attach __P((struct awi_softc *));
-int awi_intr __P((void *));
-void awi_reset __P((struct awi_softc *));
-#ifdef __NetBSD__
-int awi_activate __P((struct device *, enum devact));
-int awi_detach __P((struct awi_softc *));
-void awi_power __P((struct awi_softc *, int));
-#endif
-
-void awi_stop __P((struct awi_softc *sc));
-int awi_init __P((struct awi_softc *sc));
-int awi_init_region __P((struct awi_softc *));
-int awi_wicfg __P((struct ifnet *, u_long, caddr_t));
-
-int awi_wep_setnwkey __P((struct awi_softc *, struct ieee80211_nwkey *));
-int awi_wep_getnwkey __P((struct awi_softc *, struct ieee80211_nwkey *));
-int awi_wep_getalgo __P((struct awi_softc *));
-int awi_wep_setalgo __P((struct awi_softc *, int));
-int awi_wep_setkey __P((struct awi_softc *, int, unsigned char *, int));
-int awi_wep_getkey __P((struct awi_softc *, int, unsigned char *, int *));
-struct mbuf *awi_wep_encrypt __P((struct awi_softc *, struct mbuf *, int));
diff --git a/sys/dev/cs/if_csreg.h b/sys/dev/cs/if_csreg.h
deleted file mode 100644
index e771156fe1f30..0000000000000
--- a/sys/dev/cs/if_csreg.h
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
- * 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 unmodified, 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.
- *
- */
-
-/*
- * $FreeBSD$
- */
-
-#define CS_89x0_IO_PORTS 0x0020
-
-#define PP_ChipID 0x0000 /* offset 0h -> Corp -ID */
- /* offset 2h -> Model/Product Number */
- /* offset 3h -> Chip Revision Number */
-
-#define PP_ISAIOB 0x0020 /* IO base address */
-#define PP_CS8900_ISAINT 0x0022 /* ISA interrupt select */
-#define PP_CS8900_ISADMA 0x0024 /* ISA Rec DMA channel */
-#define PP_CS8920_ISAINT 0x0370 /* ISA interrupt select */
-#define PP_CS8920_ISADMA 0x0374 /* ISA Rec DMA channel */
-#define PP_ISASOF 0x0026 /* ISA DMA offset */
-#define PP_DmaFrameCnt 0x0028 /* ISA DMA Frame count */
-#define PP_DmaByteCnt 0x002A /* ISA DMA Byte count */
-#define PP_CS8920_ISAMemB 0x0348 /* Memory base */
-
-/* EEPROM data and command registers */
-#define PP_EECMD 0x0040 /* NVR Interface Command register */
-#define PP_EEData 0x0042 /* NVR Interface Data Register */
-#define PP_DebugReg 0x0044 /* Debug Register */
-
-#define PP_RxCFG 0x0102 /* Rx Bus config */
-#define PP_RxCTL 0x0104 /* Receive Control Register */
-#define PP_TxCFG 0x0106 /* Transmit Config Register */
-#define PP_TxCMD 0x0108 /* Transmit Command Register */
-#define PP_BufCFG 0x010A /* Bus configuration Register */
-#define PP_LineCTL 0x0112 /* Line Config Register */
-#define PP_SelfCTL 0x0114 /* Self Command Register */
-#define PP_BusCTL 0x0116 /* ISA bus control Register */
-#define PP_TestCTL 0x0118 /* Test Register */
-#define PP_AutoNegCTL 0x011C /* Auto Negotiation Ctrl */
-
-#define PP_ISQ 0x0120 /* Interrupt Status */
-#define PP_RxEvent 0x0124 /* Rx Event Register */
-#define PP_TxEvent 0x0128 /* Tx Event Register */
-#define PP_BufEvent 0x012C /* Bus Event Register */
-#define PP_RxMiss 0x0130 /* Receive Miss Count */
-#define PP_TxCol 0x0132 /* Transmit Collision Count */
-#define PP_LineST 0x0134 /* Line State Register */
-#define PP_SelfST 0x0136 /* Self State register */
-#define PP_BusST 0x0138 /* Bus Status */
-#define PP_TDR 0x013C /* Time Domain Reflectometry */
-#define PP_AutoNegST 0x013E /* Auto Neg Status */
-#define PP_TxCommand 0x0144 /* Tx Command */
-#define PP_TxLength 0x0146 /* Tx Length */
-#define PP_LAF 0x0150 /* Hash Table */
-#define PP_IA 0x0158 /* Physical Address Register */
-
-#define PP_RxStatus 0x0400 /* Receive start of frame */
-#define PP_RxLength 0x0402 /* Receive Length of frame */
-#define PP_RxFrame 0x0404 /* Receive frame pointer */
-#define PP_TxFrame 0x0A00 /* Transmit frame pointer */
-
-/*
- * Primary I/O Base Address. If no I/O base is supplied by the user, then this
- * can be used as the default I/O base to access the PacketPage Area.
- */
-#define DEFAULTIOBASE 0x0300
-#define FIRST_IO 0x020C /* First I/O port to check */
-#define LAST_IO 0x037C /* Last I/O port to check (+10h) */
-#define ADD_MASK 0x3000 /* Mask it use of the ADD_PORT register */
-#define ADD_SIG 0x3000 /* Expected ID signature */
-
-#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */
-
-#define PRODUCT_ID_ADD 0x0002 /* Address of product ID */
-
-/* Mask to find out the types of registers */
-#define REG_TYPE_MASK 0x001F
-
-/* Eeprom Commands */
-#define ERSE_WR_ENBL 0x00F0
-#define ERSE_WR_DISABLE 0x0000
-
-/* Defines Control/Config register quintuplet numbers */
-#define RX_BUF_CFG 0x0003
-#define RX_CONTROL 0x0005
-#define TX_CFG 0x0007
-#define TX_COMMAND 0x0009
-#define BUF_CFG 0x000B
-#define LINE_CONTROL 0x0013
-#define SELF_CONTROL 0x0015
-#define BUS_CONTROL 0x0017
-#define TEST_CONTROL 0x0019
-
-/* Defines Status/Count registers quintuplet numbers */
-#define RX_EVENT 0x0004
-#define TX_EVENT 0x0008
-#define BUF_EVENT 0x000C
-#define RX_MISS_COUNT 0x0010
-#define TX_COL_COUNT 0x0012
-#define LINE_STATUS 0x0014
-#define SELF_STATUS 0x0016
-#define BUS_STATUS 0x0018
-#define TDR 0x001C
-
-/*
- * PP_RxCFG - Receive Configuration and Interrupt Mask
- * bit definition - Read/write
- */
-#define SKIP_1 0x0040
-#define RX_STREAM_ENBL 0x0080
-#define RX_OK_ENBL 0x0100
-#define RX_DMA_ONLY 0x0200
-#define AUTO_RX_DMA 0x0400
-#define BUFFER_CRC 0x0800
-#define RX_CRC_ERROR_ENBL 0x1000
-#define RX_RUNT_ENBL 0x2000
-#define RX_EXTRA_DATA_ENBL 0x4000
-
-/* PP_RxCTL - Receive Control bit definition - Read/write */
-#define RX_IA_HASH_ACCEPT 0x0040
-#define RX_PROM_ACCEPT 0x0080
-#define RX_OK_ACCEPT 0x0100
-#define RX_MULTCAST_ACCEPT 0x0200
-#define RX_IA_ACCEPT 0x0400
-#define RX_BROADCAST_ACCEPT 0x0800
-#define RX_BAD_CRC_ACCEPT 0x1000
-#define RX_RUNT_ACCEPT 0x2000
-#define RX_EXTRA_DATA_ACCEPT 0x4000
-#define RX_ALL_ACCEPT (RX_PROM_ACCEPT | RX_BAD_CRC_ACCEPT | \
- RX_RUNT_ACCEPT | RX_EXTRA_DATA_ACCEPT)
-/*
- * Default receive mode - individually addressed, broadcast, and error free
- */
-#define RX_DEF_ACCEPT (RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | RX_OK_ACCEPT)
-
-/*
- * PP_TxCFG - Transmit Configuration Interrupt Mask
- * bit definition - Read/write
- */
-#define TX_LOST_CRS_ENBL 0x0040
-#define TX_SQE_ERROR_ENBL 0x0080
-#define TX_OK_ENBL 0x0100
-#define TX_LATE_COL_ENBL 0x0200
-#define TX_JBR_ENBL 0x0400
-#define TX_ANY_COL_ENBL 0x0800
-#define TX_16_COL_ENBL 0x8000
-
-/*
- * PP_TxCMD - Transmit Command bit definition - Read-only
- */
-#define TX_START_4_BYTES 0x0000
-#define TX_START_64_BYTES 0x0040
-#define TX_START_128_BYTES 0x0080
-#define TX_START_ALL_BYTES 0x00C0
-#define TX_FORCE 0x0100
-#define TX_ONE_COL 0x0200
-#define TX_TWO_PART_DEFF_DISABLE 0x0400
-#define TX_NO_CRC 0x1000
-#define TX_RUNT 0x2000
-
-/*
- * PP_BufCFG - Buffer Configuration Interrupt Mask
- * bit definition - Read/write
- */
-#define GENERATE_SW_INTERRUPT 0x0040
-#define RX_DMA_ENBL 0x0080
-#define READY_FOR_TX_ENBL 0x0100
-#define TX_UNDERRUN_ENBL 0x0200
-#define RX_MISS_ENBL 0x0400
-#define RX_128_BYTE_ENBL 0x0800
-#define TX_COL_COUNT_OVRFLOW_ENBL 0x1000
-#define RX_MISS_COUNT_OVRFLOW_ENBL 0x2000
-#define RX_DEST_MATCH_ENBL 0x8000
-
-/*
- * PP_LineCTL - Line Control bit definition - Read/write
- */
-#define SERIAL_RX_ON 0x0040
-#define SERIAL_TX_ON 0x0080
-#define AUI_ONLY 0x0100
-#define AUTO_AUI_10BASET 0x0200
-#define MODIFIED_BACKOFF 0x0800
-#define NO_AUTO_POLARITY 0x1000
-#define TWO_PART_DEFDIS 0x2000
-#define LOW_RX_SQUELCH 0x4000
-
-/*
- * PP_SelfCTL - Software Self Control bit definition - Read/write
- */
-#define POWER_ON_RESET 0x0040
-#define SW_STOP 0x0100
-#define SLEEP_ON 0x0200
-#define AUTO_WAKEUP 0x0400
-#define HCB0_ENBL 0x1000
-#define HCB1_ENBL 0x2000
-#define HCB0 0x4000
-#define HCB1 0x8000
-
-/*
- * PP_BusCTL - ISA Bus Control bit definition - Read/write
- */
-#define RESET_RX_DMA 0x0040
-#define MEMORY_ON 0x0400
-#define DMA_BURST_MODE 0x0800
-#define IO_CHANNEL_READY_ON 0x1000
-#define RX_DMA_SIZE_64Ks 0x2000
-#define ENABLE_IRQ 0x8000
-
-/*
- * PP_TestCTL - Test Control bit definition - Read/write
- */
-#define LINK_OFF 0x0080
-#define ENDEC_LOOPBACK 0x0200
-#define AUI_LOOPBACK 0x0400
-#define BACKOFF_OFF 0x0800
-#define FAST_TEST 0x8000
-
-/*
- * PP_RxEvent - Receive Event Bit definition - Read-only
- */
-#define RX_IA_HASHED 0x0040
-#define RX_DRIBBLE 0x0080
-#define RX_OK 0x0100
-#define RX_HASHED 0x0200
-#define RX_IA 0x0400
-#define RX_BROADCAST 0x0800
-#define RX_CRC_ERROR 0x1000
-#define RX_RUNT 0x2000
-#define RX_EXTRA_DATA 0x4000
-
-#define HASH_INDEX_MASK 0x0FC00
-
-/*
- * PP_TxEvent - Transmit Event Bit definition - Read-only
- */
-#define TX_LOST_CRS 0x0040
-#define TX_SQE_ERROR 0x0080
-#define TX_OK 0x0100
-#define TX_LATE_COL 0x0200
-#define TX_JBR 0x0400
-#define TX_16_COL 0x8000
-#define TX_SEND_OK_BITS (TX_OK | TX_LOST_CRS)
-#define TX_COL_COUNT_MASK 0x7800
-
-/*
- * PP_BufEvent - Buffer Event Bit definition - Read-only
- */
-#define SW_INTERRUPT 0x0040
-#define RX_DMA 0x0080
-#define READY_FOR_TX 0x0100
-#define TX_UNDERRUN 0x0200
-#define RX_MISS 0x0400
-#define RX_128_BYTE 0x0800
-#define TX_COL_OVRFLW 0x1000
-#define RX_MISS_OVRFLW 0x2000
-#define RX_DEST_MATCH 0x8000
-
-/*
- * PP_LineST - Ethernet Line Status bit definition - Read-only
- */
-#define LINK_OK 0x0080
-#define AUI_ON 0x0100
-#define TENBASET_ON 0x0200
-#define POLARITY_OK 0x1000
-#define CRS_OK 0x4000
-
-/*
- * PP_SelfST - Chip Software Status bit definition
- */
-#define ACTIVE_33V 0x0040
-#define INIT_DONE 0x0080
-#define SI_BUSY 0x0100
-#define EEPROM_PRESENT 0x0200
-#define EEPROM_OK 0x0400
-#define EL_PRESENT 0x0800
-#define EE_SIZE_64 0x1000
-
-/*
- * PP_BusST - ISA Bus Status bit definition
- */
-#define TX_BID_ERROR 0x0080
-#define READY_FOR_TX_NOW 0x0100
-
-/*
- * PP_AutoNegCTL - Auto Negotiation Control bit definition
- */
-#define RE_NEG_NOW 0x0040
-#define ALLOW_FDX 0x0080
-#define AUTO_NEG_ENABLE 0x0100
-#define NLP_ENABLE 0x0200
-#define FORCE_FDX 0x8000
-#define AUTO_NEG_BITS (FORCE_FDX | NLP_ENABLE | AUTO_NEG_ENABLE)
-#define AUTO_NEG_MASK (FORCE_FDX | NLP_ENABLE | AUTO_NEG_ENABLE | \
- ALLOW_FDX | RE_NEG_NOW)
-
-/*
- * PP_AutoNegST - Auto Negotiation Status bit definition
- */
-#define AUTO_NEG_BUSY 0x0080
-#define FLP_LINK 0x0100
-#define FLP_LINK_GOOD 0x0800
-#define LINK_FAULT 0x1000
-#define HDX_ACTIVE 0x4000
-#define FDX_ACTIVE 0x8000
-
-/*
- * The following block defines the ISQ event types
- */
-#define ISQ_RECEIVER_EVENT 0x04
-#define ISQ_TRANSMITTER_EVENT 0x08
-#define ISQ_BUFFER_EVENT 0x0c
-#define ISQ_RX_MISS_EVENT 0x10
-#define ISQ_TX_COL_EVENT 0x12
-
-#define ISQ_EVENT_MASK 0x003F /* ISQ mask to find out type of event */
-#define ISQ_HIST 16 /* small history buffer */
-#define AUTOINCREMENT 0x8000 /* Bit mask to set bit-15 for autoincrement */
-
-#define TXRXBUFSIZE 0x0600
-#define RXDMABUFSIZE 0x8000
-#define RXDMASIZE 0x4000
-#define TXRX_LENGTH_MASK 0x07FF
-
-/* rx options bits */
-#define RCV_WITH_RXON 1 /* Set SerRx ON */
-#define RCV_COUNTS 2 /* Use Framecnt1 */
-#define RCV_PONG 4 /* Pong respondent */
-#define RCV_DONG 8 /* Dong operation */
-#define RCV_POLLING 0x10 /* Poll RxEvent */
-#define RCV_ISQ 0x20 /* Use ISQ, int */
-#define RCV_AUTO_DMA 0x100 /* Set AutoRxDMAE */
-#define RCV_DMA 0x200 /* Set RxDMA only */
-#define RCV_DMA_ALL 0x400 /* Copy all DMA'ed */
-#define RCV_FIXED_DATA 0x800 /* Every frame same */
-#define RCV_IO 0x1000 /* Use ISA IO only */
-#define RCV_MEMORY 0x2000 /* Use ISA Memory */
-
-#define RAM_SIZE 0x1000 /* The card has 4k bytes or RAM */
-#define PKT_START PP_TxFrame /* Start of packet RAM */
-
-#define RX_FRAME_PORT 0x0000
-#define TX_FRAME_PORT RX_FRAME_PORT
-#define TX_CMD_PORT 0x0004
-#define TX_CS8900_NOW 0x0000 /* Tx packet after 5 bytes copied */
-#define TX_CS8900_AFTER_381 0x0020 /* Tx packet after 381 bytes copied */
-#define TX_CS8900_AFTER_ALL 0x0060 /* Tx packet after all bytes copied */
-#define TX_CS8920_NOW 0x0000 /* Tx packet after 5 bytes copied */
-#define TX_CS8920_AFTER_381 0x0040 /* Tx packet after 381 bytes copied */
-#define TX_CS8920_AFTER_1021 0x0080 /* Tx packet after1021 bytes copied */
-#define TX_CS8920_AFTER_ALL 0x00C0 /* Tx packet after all bytes copied */
-#define TX_LEN_PORT 0x0006
-#define ISQ_PORT 0x0008
-#define ADD_PORT 0x000A
-#define DATA_PORT 0x000C
-
-#define EEPROM_WRITE_EN 0x00F0
-#define EEPROM_WRITE_DIS 0x0000
-#define EEPROM_WRITE_CMD 0x0100
-#define EEPROM_READ_CMD 0x0200
-
-/* Receive Header
- * Description of header of each packet in receive area of memory
- */
-#define RBUF_EVENT_LOW 0 /* Low byte of RxEvent - status of received frame */
-#define RBUF_EVENT_HIGH 1 /* High byte of RxEvent - status of received frame */
-#define RBUF_LEN_LOW 2 /* Length of received data - low byte */
-#define RBUF_LEN_HI 3 /* Length of received data - high byte */
-#define RBUF_HEAD_LEN 4 /* Length of this header */
-
-#define CHIP_READ 0x1 /* Used to mark state of the repins code (chip or dma) */
-#define DMA_READ 0x2 /* Used to mark state of the repins code (chip or dma) */
-
-/* for bios scan */
-/* */
-#ifdef CSDEBUG
-/* use these values for debugging bios scan */
-#define BIOS_START_SEG 0x00000
-#define BIOS_OFFSET_INC 0x0010
-#else
-#define BIOS_START_SEG 0x0c000
-#define BIOS_OFFSET_INC 0x0200
-#endif
-
-#define BIOS_LAST_OFFSET 0x0fc00
-
-/*
- * Byte offsets into the EEPROM configuration buffer
- */
-#define ISA_CNF_OFFSET 0x6
-#define TX_CTL_OFFSET (ISA_CNF_OFFSET + 8) /* 8900 eeprom */
-#define AUTO_NEG_CNF_OFFSET (ISA_CNF_OFFSET + 8) /* 8920 eeprom */
-
-/*
- * the assumption here is that the bits in the eeprom are generally
- * in the same position as those in the autonegctl register.
- * Of course the IMM bit is not in that register so it must be
- * masked out
- */
-#define EE_FORCE_FDX 0x8000
-#define EE_NLP_ENABLE 0x0200
-#define EE_AUTO_NEG_ENABLE 0x0100
-#define EE_ALLOW_FDX 0x0080
-#define EE_AUTO_NEG_CNF_MASK (EE_FORCE_FDX | EE_NLP_ENABLE | \
- EE_AUTO_NEG_ENABLE | EE_ALLOW_FDX)
-
-#define IMM_BIT 0x0040 /* ignore missing media */
-
-#define ADAPTER_CNF_OFFSET (AUTO_NEG_CNF_OFFSET + 2)
-#define A_CNF_MEDIA 0x0007
-#define A_CNF_10B_T 0x0001
-#define A_CNF_AUI 0x0002
-#define A_CNF_10B_2 0x0004
-#define A_CNF_MEDIA_TYPE 0x0060
-#define A_CNF_MEDIA_AUTO 0x0000
-#define A_CNF_MEDIA_10B_T 0x0020
-#define A_CNF_MEDIA_AUI 0x0040
-#define A_CNF_MEDIA_10B_2 0x0060
-#define A_CNF_DC_DC_POLARITY 0x0080
-#define A_CNF_NO_AUTO_POLARITY 0x2000
-#define A_CNF_LOW_RX_SQUELCH 0x4000
-#define A_CNF_EXTND_10B_2 0x8000
-
-#define PACKET_PAGE_OFFSET 0x8
-
-/*
- * Bit definitions for the ISA configuration word from the EEPROM
- */
-#define INT_NO_MASK 0x000F
-#define DMA_NO_MASK 0x0070
-#define ISA_DMA_SIZE 0x0200
-#define ISA_AUTO_RxDMA 0x0400
-#define ISA_RxDMA 0x0800
-#define DMA_BURST 0x1000
-#define STREAM_TRANSFER 0x2000
-#define ANY_ISA_DMA (ISA_AUTO_RxDMA | ISA_RxDMA)
-
-/* DMA controller registers */
-#define DMA_BASE 0x00 /* DMA controller base */
-#define DMA_BASE_2 0x0C0 /* DMA controller base */
-
-#define DMA_STAT 0x0D0 /* DMA controller status register */
-#define DMA_MASK 0x0D4 /* DMA controller mask register */
-#define DMA_MODE 0x0D6 /* DMA controller mode register */
-#define DMA_RESETFF 0x0D8 /* DMA controller first/last flip flop */
-
-/* DMA data */
-#define DMA_DISABLE 0x04 /* Disable channel n */
-#define DMA_ENABLE 0x00 /* Enable channel n */
-/* Demand transfers, incr. address, auto init, writes, ch. n */
-#define DMA_RX_MODE 0x14
-/* Demand transfers, incr. address, auto init, reads, ch. n */
-#define DMA_TX_MODE 0x18
-
-#define DMA_SIZE (16*1024) /* Size of dma buffer - 16k */
-
-#define CS8900 0x0000
-#define CS8920 0x4000
-#define CS8920M 0x6000
-#define REVISON_BITS 0x1F00
-#define EEVER_NUMBER 0x12
-#define CHKSUM_LEN 0x14
-#define CHKSUM_VAL 0x0000
-#define START_EEPROM_DATA 0x001c /* Offset into eeprom for start of data */
-#define IRQ_MAP_EEPROM_DATA 0x0046 /* Offset into eeprom for the IRQ map */
-#define IRQ_MAP_LEN 0x0004 /* No of bytes to read for the IRQ map */
-#define PNP_IRQ_FRMT 0x0022 /* PNP small item IRQ format */
-#define CS8900_IRQ_MAP 0x1c20 /* This IRQ map is fixed */
-
-#define CS8920_NO_INTS 0x0F /* Max CS8920 interrupt select # */
-
-#define PNP_ADD_PORT 0x0279
-#define PNP_WRITE_PORT 0x0A79
-
-#define GET_PNP_ISA_STRUCT 0x40
-#define PNP_ISA_STRUCT_LEN 0x06
-#define PNP_CSN_CNT_OFF 0x01
-#define PNP_RD_PORT_OFF 0x02
-#define PNP_FUNCTION_OK 0x00
-#define PNP_WAKE 0x03
-#define PNP_RSRC_DATA 0x04
-#define PNP_RSRC_READY 0x01
-#define PNP_STATUS 0x05
-#define PNP_ACTIVATE 0x30
-#define PNP_CNF_IO_H 0x60
-#define PNP_CNF_IO_L 0x61
-#define PNP_CNF_INT 0x70
-#define PNP_CNF_DMA 0x74
-#define PNP_CNF_MEM 0x48
-
-#define BIT0 1
-#define BIT15 0x8000
-
-#define CS_DUPLEX_AUTO 0
-#define CS_DUPLEX_FULL 1
-#define CS_DUPLEX_HALF 2
-
-/* Device name */
-#define CS_NAME "cs"
-
-#define cs_readreg(iobase, portno) \
- (outw((iobase) + ADD_PORT, (portno)), \
- inw((iobase) + DATA_PORT))
-#define cs_writereg(iobase, portno, value) \
- (outw((iobase) + ADD_PORT, (portno)), \
- outw((iobase) + DATA_PORT, (value)))
-#define cs_readword(iobase, portno) \
- (inw((iobase) + (portno)))
-#define cs_writeword(iobase, portno, value) \
- (outw((iobase) + (portno), (value)))
-
-#define reset_chip(nic_addr) \
- cs_writereg(nic_addr, PP_SelfCTL, cs_readreg(ioaddr, PP_SelfCTL) | POWER_ON_RESET), \
- DELAY(30000)
-
-#define cs_duplex_full(sc) \
- (cs_writereg(sc->nic_addr, PP_AutoNegCTL, FORCE_FDX))
-
-#define cs_duplex_half(sc) \
- (cs_writereg(sc->nic_addr, PP_AutoNegCTL, NLP_ENABLE))
-
diff --git a/sys/dev/ic/hd64570.h b/sys/dev/ic/hd64570.h
deleted file mode 100644
index b676e25a9cd5c..0000000000000
--- a/sys/dev/ic/hd64570.h
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 1995 John Hay. 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 [your name]
- * and [any other names deserving credit ]
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY [your name] 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.
- *
- * $FreeBSD$
- */
-#ifndef _HD64570_H_
-#define _HD64570_H_
-
-typedef struct msci_channel
- {
- union
- {
- unsigned short us_trb; /* rw */
- struct
- {
- unsigned char uc_trbl;
- unsigned char uc_trbh;
- }uc_trb;
- }u_trb;
- unsigned char st0; /* ro */
- unsigned char st1; /* rw */
- unsigned char st2; /* rw */
- unsigned char st3; /* ro */
- unsigned char fst; /* rw */
- unsigned char unused0;
- unsigned char ie0; /* rw */
- unsigned char ie1; /* rw */
- unsigned char ie2; /* rw */
- unsigned char fie; /* rw */
- unsigned char cmd; /* wo */
- unsigned char unused1;
- unsigned char md0; /* rw */
- unsigned char md1; /* rw */
- unsigned char md2; /* rw */
- unsigned char ctl; /* rw */
- unsigned char sa0; /* rw */
- unsigned char sa1; /* rw */
- unsigned char idl; /* rw */
- unsigned char tmc; /* rw */
- unsigned char rxs; /* rw */
- unsigned char txs; /* rw */
- unsigned char trc0; /* rw */
- unsigned char trc1; /* rw */
- unsigned char rrc; /* rw */
- unsigned char unused2;
- unsigned char cst0; /* rw */
- unsigned char cst1; /* rw */
- unsigned char unused3[2];
- }msci_channel;
-
-#define trb u_trb.us_trb
-#define trbl u_trb.uc_trb.uc_trbl
-#define trbh u_trb.uc_trb.uc_trbh
-
-typedef struct timer_channel
- {
- unsigned short tcnt; /* rw */
- unsigned short tconr; /* wo */
- unsigned char tcsr; /* rw */
- unsigned char tepr; /* rw */
- unsigned char unused[2];
- }timer_channel;
-
-typedef struct dmac_channel
- {
- unsigned short dar; /* rw */
- unsigned char darb; /* rw */
- unsigned char unused0;
- unsigned short sar; /* rw On odd numbered dmacs (tx) only */
- unsigned char sarb; /* rw */
-#define cpb sarb
- unsigned char unused1;
- unsigned short cda; /* rw */
- unsigned short eda; /* rw */
- unsigned short bfl; /* rw On even numbered dmacs (rx) only */
- unsigned short bcr; /* rw */
- unsigned char dsr; /* rw */
- unsigned char dmr; /* rw */
- unsigned char unused2;
- unsigned char fct; /* rw */
- unsigned char dir; /* rw */
- unsigned char dcr; /* rw */
- unsigned char unused3[10];
- }dmac_channel;
-
-/* x is the channel number. rx channels are even numbered and tx, odd. */
-#define DMAC_RXCH(x) ((x*2) + 0)
-#define DMAC_TXCH(x) ((x*2) + 1)
-
-typedef struct sca_regs
- {
- unsigned char lpr; /* rw */
- unsigned char unused0; /* -- */
- /* Wait system */
- unsigned char pabr0; /* rw */
- unsigned char pabr1; /* rw */
- unsigned char wcrl; /* rw */
- unsigned char wcrm; /* rw */
- unsigned char wcrh; /* rw */
- unsigned char unused1;
- /* DMAC */
- unsigned char pcr; /* rw */
- unsigned char dmer; /* rw */
- unsigned char unused2[6];
- /* Interrupt */
- unsigned char isr0; /* ro */
- unsigned char isr1; /* ro */
- unsigned char isr2; /* ro */
- unsigned char unused3;
- unsigned char ier0; /* rw */
- unsigned char ier1; /* rw */
- unsigned char ier2; /* rw */
- unsigned char unused4;
- unsigned char itcr; /* rw */
- unsigned char unused5;
- unsigned char ivr; /* rw */
- unsigned char unused6;
- unsigned char imvr; /* rw */
- unsigned char unused7[3];
- /* MSCI Channel 0 */
- msci_channel msci[2];
- timer_channel timer[4];
- dmac_channel dmac[4];
- }sca_regs;
-
-#define SCA_CMD_TXRESET 0x01
-#define SCA_CMD_TXENABLE 0x02
-#define SCA_CMD_TXDISABLE 0x03
-#define SCA_CMD_TXCRCINIT 0x04
-#define SCA_CMD_TXCRCEXCL 0x05
-#define SCA_CMS_TXEOM 0x06
-#define SCA_CMD_TXABORT 0x07
-#define SCA_CMD_MPON 0x08
-#define SCA_CMD_TXBCLEAR 0x09
-
-#define SCA_CMD_RXRESET 0x11
-#define SCA_CMD_RXENABLE 0x12
-#define SCA_CMD_RXDISABLE 0x13
-#define SCA_CMD_RXCRCINIT 0x14
-#define SCA_CMD_RXMSGREJ 0x15
-#define SCA_CMD_MPSEARCH 0x16
-#define SCA_CMD_RXCRCEXCL 0x17
-#define SCA_CMD_RXCRCCALC 0x18
-
-#define SCA_CMD_NOP 0x00
-#define SCA_CMD_RESET 0x21
-#define SCA_CMD_SEARCH 0x31
-
-#define SCA_MD0_CRC_1 0x01
-#define SCA_MD0_CRC_CCITT 0x02
-#define SCA_MD0_CRC_ENABLE 0x04
-#define SCA_MD0_AUTO_ENABLE 0x10
-#define SCA_MD0_MODE_ASYNC 0x00
-#define SCA_MD0_MODE_BYTESYNC1 0x20
-#define SCA_MD0_MODE_BISYNC 0x40
-#define SCA_MD0_MODE_BYTESYNC2 0x60
-#define SCA_MD0_MODE_HDLC 0x80
-
-#define SCA_MD1_NOADDRCHK 0x00
-#define SCA_MD1_SNGLADDR1 0x40
-#define SCA_MD1_SNGLADDR2 0x80
-#define SCA_MD1_DUALADDR 0xC0
-
-#define SCA_MD2_DUPLEX 0x00
-#define SCA_MD2_ECHO 0x01
-#define SCA_MD2_LOOPBACK 0x03
-#define SCA_MD2_ADPLLx8 0x00
-#define SCA_MD2_ADPLLx16 0x08
-#define SCA_MD2_ADPLLx32 0x10
-#define SCA_MD2_NRZ 0x00
-#define SCA_MD2_NRZI 0x20
-#define SCA_MD2_MANCHESTER 0x80
-#define SCA_MD2_FM0 0xC0
-#define SCA_MD2_FM1 0xA0
-
-#define SCA_CTL_RTS 0x01
-#define SCA_CTL_IDLPAT 0x10
-#define SCA_CTL_UDRNC 0x20
-
-#define SCA_RXS_DIV_MASK 0x0F
-#define SCA_RXS_DIV1 0x00
-#define SCA_RXS_DIV2 0x01
-#define SCA_RXS_DIV4 0x02
-#define SCA_RXS_DIV8 0x03
-#define SCA_RXS_DIV16 0x04
-#define SCA_RXS_DIV32 0x05
-#define SCA_RXS_DIV64 0x06
-#define SCA_RXS_DIV128 0x07
-#define SCA_RXS_DIV256 0x08
-#define SCA_RXS_DIV512 0x09
-#define SCA_RXS_CLK_RXC0 0x00
-#define SCA_RXS_CLK_RXC1 0x20
-#define SCA_RXS_CLK_INT 0x40
-#define SCA_RXS_CLK_ADPLL_OUT 0x60
-#define SCA_RXS_CLK_ADPLL_IN 0x70
-
-#define SCA_TXS_DIV_MASK 0x0F
-#define SCA_TXS_DIV1 0x00
-#define SCA_TXS_DIV2 0x01
-#define SCA_TXS_DIV4 0x02
-#define SCA_TXS_DIV8 0x03
-#define SCA_TXS_DIV16 0x04
-#define SCA_TXS_DIV32 0x05
-#define SCA_TXS_DIV64 0x06
-#define SCA_TXS_DIV128 0x07
-#define SCA_TXS_DIV256 0x08
-#define SCA_TXS_DIV512 0x09
-#define SCA_TXS_CLK_TXC 0x00
-#define SCA_TXS_CLK_INT 0x40
-#define SCA_TXS_CLK_RX 0x60
-
-#define SCA_ST0_RXRDY 0x01
-#define SCA_ST0_TXRDY 0x02
-#define SCA_ST0_RXINT 0x40
-#define SCA_ST0_TXINT 0x80
-
-#define SCA_ST1_IDLST 0x01
-#define SCA_ST1_ABTST 0x02
-#define SCA_ST1_DCDCHG 0x04
-#define SCA_ST1_CTSCHG 0x08
-#define SCA_ST1_FLAG 0x10
-#define SCA_ST1_TXIDL 0x40
-#define SCA_ST1_UDRN 0x80
-
-/* ST2 and FST look the same */
-#define SCA_FST_CRCERR 0x04
-#define SCA_FST_OVRN 0x08
-#define SCA_FST_RESFRM 0x10
-#define SCA_FST_ABRT 0x20
-#define SCA_FST_SHRT 0x40
-#define SCA_FST_EOM 0x80
-
-#define SCA_ST3_RXENA 0x01
-#define SCA_ST3_TXENA 0x02
-#define SCA_ST3_DCD 0x04
-#define SCA_ST3_CTS 0x08
-#define SCA_ST3_ADPLLSRCH 0x10
-#define SCA_ST3_TXDATA 0x20
-
-#define SCA_FIE_EOMFE 0x80
-
-#define SCA_IE0_RXRDY 0x01
-#define SCA_IE0_TXRDY 0x02
-#define SCA_IE0_RXINT 0x40
-#define SCA_IE0_TXINT 0x80
-
-#define SCA_IE1_IDLDE 0x01
-#define SCA_IE1_ABTDE 0x02
-#define SCA_IE1_DCD 0x04
-#define SCA_IE1_CTS 0x08
-#define SCA_IE1_FLAG 0x10
-#define SCA_IE1_IDL 0x40
-#define SCA_IE1_UDRN 0x80
-
-#define SCA_IE2_CRCERR 0x04
-#define SCA_IE2_OVRN 0x08
-#define SCA_IE2_RESFRM 0x10
-#define SCA_IE2_ABRT 0x20
-#define SCA_IE2_SHRT 0x40
-#define SCA_IE2_EOM 0x80
-
-/* This is for RRC, TRC0 and TRC1. */
-#define SCA_RCR_MASK 0x1F
-
-#define SCA_IE1_
-
-#define SCA_IV_CHAN0 0x00
-#define SCA_IV_CHAN1 0x20
-
-#define SCA_IV_RXRDY 0x04
-#define SCA_IV_TXRDY 0x06
-#define SCA_IV_RXINT 0x08
-#define SCA_IV_TXINT 0x0A
-
-#define SCA_IV_DMACH0 0x00
-#define SCA_IV_DMACH1 0x08
-#define SCA_IV_DMACH2 0x20
-#define SCA_IV_DMACH3 0x28
-
-#define SCA_IV_DMIA 0x14
-#define SCA_IV_DMIB 0x16
-
-#define SCA_IV_TIMER0 0x1C
-#define SCA_IV_TIMER1 0x1E
-#define SCA_IV_TIMER2 0x3C
-#define SCA_IV_TIMER3 0x3E
-
-/*
- * DMA registers
- */
-#define SCA_DSR_EOT 0x80
-#define SCA_DSR_EOM 0x40
-#define SCA_DSR_BOF 0x20
-#define SCA_DSR_COF 0x10
-#define SCA_DSR_DE 0x02
-#define SCA_DSR_DWE 0x01
-
-#define SCA_DMR_TMOD 0x10
-#define SCA_DMR_NF 0x04
-#define SCA_DMR_CNTE 0x02
-
-#define SCA_DMER_EN 0x80
-
-#define SCA_DCR_ABRT 0x01
-#define SCA_DCR_FCCLR 0x02 /* Clear frame end intr counter */
-
-#define SCA_DIR_EOT 0x80
-#define SCA_DIR_EOM 0x40
-#define SCA_DIR_BOF 0x20
-#define SCA_DIR_COF 0x10
-
-#define SCA_PCR_BRC 0x10
-#define SCA_PCR_CCC 0x08
-#define SCA_PCR_PR2 0x04
-#define SCA_PCR_PR1 0x02
-#define SCA_PCR_PR0 0x01
-
-typedef struct sca_descriptor
- {
- unsigned short cp;
- unsigned short bp;
- unsigned char bpb;
- unsigned char unused0;
- unsigned short len;
- unsigned char stat;
- unsigned char unused1;
- }sca_descriptor;
-
-#define SCA_DESC_EOT 0x01
-#define SCA_DESC_CRC 0x04
-#define SCA_DESC_OVRN 0x08
-#define SCA_DESC_RESD 0x10
-#define SCA_DESC_ABORT 0x20
-#define SCA_DESC_SHRTFRM 0x40
-#define SCA_DESC_EOM 0x80
-#define SCA_DESC_ERRORS 0x7C
-
-/*
-***************************************************************************
-** END
-***************************************************************************
-**/
-#endif /* _HD64570_H_ */
-
diff --git a/sys/dev/mii/pnaphy.c b/sys/dev/mii/pnaphy.c
deleted file mode 100644
index 67cf59dde3030..0000000000000
--- a/sys/dev/mii/pnaphy.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (c) 2000 Berkeley Software Design, Inc.
- * Copyright (c) 1997, 1998, 1999, 2000
- * Bill Paul <wpaul@osd.bsdi.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. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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$
- */
-
-/*
- * driver for homePNA PHYs
- * This is really just a stub that allows us to identify homePNA-based
- * transceicers and display the link status. MII-based homePNA PHYs
- * only support one media type and no autonegotiation. If we were
- * really clever, we could tweak some of the vendor-specific registers
- * to optimize the link.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-
-#include <net/if.h>
-#include <net/if_media.h>
-
-#include <machine/clock.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-#include <dev/mii/miidevs.h>
-
-#include "miibus_if.h"
-
-#if !defined(lint)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-static int pnaphy_probe __P((device_t));
-static int pnaphy_attach __P((device_t));
-static int pnaphy_detach __P((device_t));
-
-static device_method_t pnaphy_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, pnaphy_probe),
- DEVMETHOD(device_attach, pnaphy_attach),
- DEVMETHOD(device_detach, pnaphy_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- { 0, 0 }
-};
-
-static devclass_t pnaphy_devclass;
-
-static driver_t pnaphy_driver = {
- "pnaphy",
- pnaphy_methods,
- sizeof(struct mii_softc)
-};
-
-DRIVER_MODULE(pnaphy, miibus, pnaphy_driver, pnaphy_devclass, 0, 0);
-
-int pnaphy_service __P((struct mii_softc *, struct mii_data *, int));
-
-static int
-pnaphy_probe(dev)
- device_t dev;
-{
-
- struct mii_attach_args *ma;
-
- ma = device_get_ivars(dev);
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_AMD &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_AMD_79c978) {
- device_set_desc(dev, MII_STR_AMD_79c978);
- return(0);
- }
-
- return(ENXIO);
-}
-
-static int
-pnaphy_attach(dev)
- device_t dev;
-{
- struct mii_softc *sc;
- struct mii_attach_args *ma;
- struct mii_data *mii;
- const char *sep = "";
-
- sc = device_get_softc(dev);
- ma = device_get_ivars(dev);
- sc->mii_dev = device_get_parent(dev);
- mii = device_get_softc(sc->mii_dev);
- LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
- sc->mii_inst = mii->mii_instance;
- sc->mii_phy = ma->mii_phyno;
- sc->mii_service = pnaphy_service;
- sc->mii_pdata = mii;
-
- mii->mii_instance++;
-
- sc->mii_flags |= MIIF_NOISOLATE;
-
-#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
-#define PRINT(s) printf("%s%s", sep, s); sep = ", "
-
- mii_phy_reset(sc);
-
- sc->mii_capabilities =
- PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
- device_printf(dev, " ");
- if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
- printf("no media present");
- else {
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_homePNA, 0, sc->mii_inst), 0);
- PRINT("HomePNA");
- }
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
- BMCR_ISO);
-
- printf("\n");
-
-#undef ADD
-#undef PRINT
-
- MIIBUS_MEDIAINIT(sc->mii_dev);
-
- return(0);
-}
-
-static int pnaphy_detach(dev)
- device_t dev;
-{
- struct mii_softc *sc;
- struct mii_data *mii;
-
- sc = device_get_softc(dev);
- mii = device_get_softc(device_get_parent(dev));
- sc->mii_dev = NULL;
- LIST_REMOVE(sc, mii_list);
-
- return(0);
-}
-
-int
-pnaphy_service(sc, mii, cmd)
- struct mii_softc *sc;
- struct mii_data *mii;
- int cmd;
-{
- struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
- int reg;
-
- switch (cmd) {
- case MII_POLLSTAT:
- /*
- * If we're not polling our PHY instance, just return.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst)
- return (0);
- break;
-
- case MII_MEDIACHG:
- /*
- * If the media indicates a different PHY instance,
- * isolate ourselves.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
- reg = PHY_READ(sc, MII_BMCR);
- PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
- return (0);
- }
-
- /*
- * If the interface is not up, don't do anything.
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- break;
-
- switch (IFM_SUBTYPE(ife->ifm_media)) {
- case IFM_AUTO:
- case IFM_10_T:
- case IFM_100_TX:
- case IFM_100_T4:
- return (EINVAL);
- default:
- /*
- * BMCR data is stored in the ifmedia entry.
- */
- PHY_WRITE(sc, MII_ANAR,
- mii_anar(ife->ifm_media));
- PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
- }
- break;
-
- case MII_TICK:
- /*
- * If we're not currently selected, just return.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst)
- return (0);
-
- /*
- * Only used for autonegotiation.
- */
- if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
- return (0);
-
- /*
- * Is the interface even up?
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- return (0);
-
- /*
- * Check to see if we have link. If we do, we don't
- * need to restart the autonegotiation process. Read
- * the BMSR twice in case it's latched.
- */
- reg = PHY_READ(sc, MII_BMSR) |
- PHY_READ(sc, MII_BMSR);
- if (reg & BMSR_LINK)
- return (0);
-
- /*
- * Only retry autonegotiation every 5 seconds.
- */
- if (++sc->mii_ticks != 5)
- return (0);
-
- sc->mii_ticks = 0;
- mii_phy_reset(sc);
- if (mii_phy_auto(sc, 0) == EJUSTRETURN)
- return (0);
- break;
- }
-
- /* Update the media status. */
- ukphy_status(sc);
- if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T)
- mii->mii_media_active = IFM_ETHER|IFM_homePNA;
-
- /* Callback if something changed. */
- if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
- MIIBUS_STATCHG(sc->mii_dev);
- sc->mii_active = mii->mii_media_active;
- }
- return (0);
-}
diff --git a/sys/dev/mly/mly_cam.c b/sys/dev/mly/mly_cam.c
deleted file mode 100644
index 9175b276616df..0000000000000
--- a/sys/dev/mly/mly_cam.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-/*
- * CAM interface for FreeBSD
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/devicestat.h>
-
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-#include <cam/cam_periph.h>
-#include <cam/cam_sim.h>
-#include <cam/cam_xpt_sim.h>
-#include <cam/scsi/scsi_all.h>
-
-#include <machine/resource.h>
-#include <machine/bus.h>
-
-#include <dev/mly/mlyreg.h>
-#include <dev/mly/mlyvar.h>
-#include <dev/mly/mly_tables.h>
-
-static void mly_cam_poll(struct cam_sim *sim);
-static void mly_cam_action(struct cam_sim *sim, union ccb *ccb);
-static void mly_cam_complete(struct mly_command *mc);
-static struct cam_periph *mly_find_periph(struct mly_softc *sc, int bus, int target);
-
-/********************************************************************************
- * CAM-specific queue primitives
- */
-static __inline void
-mly_enqueue_ccb(struct mly_softc *sc, union ccb *ccb)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_TAIL(&sc->mly_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
- splx(s);
-}
-
-static __inline void
-mly_requeue_ccb(struct mly_softc *sc, union ccb *ccb)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_HEAD(&sc->mly_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
- splx(s);
-}
-
-static __inline union ccb *
-mly_dequeue_ccb(struct mly_softc *sc)
-{
- union ccb *ccb;
- int s;
-
- s = splcam();
- if ((ccb = (union ccb *)TAILQ_FIRST(&sc->mly_cam_ccbq)) != NULL)
- TAILQ_REMOVE(&sc->mly_cam_ccbq, &ccb->ccb_h, sim_links.tqe);
- splx(s);
- return(ccb);
-}
-
-/********************************************************************************
- * space-fill a character string
- */
-static __inline void
-padstr(char *targ, char *src, int len)
-{
- while (len-- > 0) {
- if (*src != 0) {
- *targ++ = *src++;
- } else {
- *targ++ = ' ';
- }
- }
-}
-
-/********************************************************************************
- * Attach the real and virtual SCSI busses to CAM
- */
-int
-mly_cam_attach(struct mly_softc *sc)
-{
- struct cam_devq *devq;
- int chn, nchn;
-
- debug_called(1);
-
- /* initialise the CCB queue */
- TAILQ_INIT(&sc->mly_cam_ccbq);
-
- /*
- * Allocate a devq for all our channels combined.
- */
- if ((devq = cam_simq_alloc(sc->mly_controllerinfo->maximum_parallel_commands)) == NULL) {
- mly_printf(sc, "can't allocate CAM SIM\n");
- return(ENOMEM);
- }
-
- /*
- * Iterate over channels, registering them with CAM.
- */
- nchn = sc->mly_controllerinfo->physical_channels_present +
- sc->mly_controllerinfo->virtual_channels_present;
- for (chn = 0; chn < nchn; chn++) {
-
- /* allocate a sim */
- if ((sc->mly_cam_sim[chn] = cam_sim_alloc(mly_cam_action,
- mly_cam_poll,
- "mly",
- sc,
- device_get_unit(sc->mly_dev),
- 1,
- sc->mly_controllerinfo->maximum_parallel_commands,
- devq)) == NULL) {
- cam_simq_free(devq);
- mly_printf(sc, "CAM SIM attach failed\n");
- return(ENOMEM);
- }
-
- /* register the bus ID so we can get it later */
- if (xpt_bus_register(sc->mly_cam_sim[chn], chn)) {
- mly_printf(sc, "CAM XPT bus registration failed\n");
- return(ENXIO);
- }
- debug(1, "registered sim %p bus %d", sc->mly_cam_sim[chn], chn);
-
- }
-
- return(0);
-}
-
-/********************************************************************************
- * Detach from CAM
- */
-void
-mly_cam_detach(struct mly_softc *sc)
-{
- int chn, nchn, first;
-
- debug_called(1);
-
- nchn = sc->mly_controllerinfo->physical_channels_present +
- sc->mly_controllerinfo->virtual_channels_present;
-
- /*
- * Iterate over channels, deregistering as we go.
- */
- nchn = sc->mly_controllerinfo->physical_channels_present +
- sc->mly_controllerinfo->virtual_channels_present;
- for (chn = 0, first = 1; chn < nchn; chn++) {
-
- /*
- * If a sim was registered for this channel, free it.
- */
- if (sc->mly_cam_sim[chn] != NULL) {
- debug(1, "deregister bus %d", chn);
- xpt_bus_deregister(cam_sim_path(sc->mly_cam_sim[chn]));
- debug(1, "free sim for channel %d (%sfree queue)", chn, first ? "" : "don't ");
- cam_sim_free(sc->mly_cam_sim[chn], first ? TRUE : FALSE);
- first = 0;
- }
- }
-}
-
-/********************************************************************************
- * Handle an action requested by CAM
- */
-static void
-mly_cam_action(struct cam_sim *sim, union ccb *ccb)
-{
- struct mly_softc *sc = cam_sim_softc(sim);
-
- debug_called(2);
-
- switch (ccb->ccb_h.func_code) {
-
- /* perform SCSI I/O */
- case XPT_SCSI_IO:
- {
- struct ccb_scsiio *csio = &ccb->csio;
- int bus, target;
-
- bus = cam_sim_bus(sim);
- target = csio->ccb_h.target_id;
-
- debug(2, "XPT_SCSI_IO %d:%d:%d", bus, target, ccb->ccb_h.target_lun);
-
- /* check for I/O attempt to a protected device */
- if (sc->mly_btl[bus][target].mb_flags & MLY_BTL_PROTECTED) {
- debug(2, " device protected");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
-
- /* check for I/O attempt to nonexistent device */
- if (!(sc->mly_btl[bus][target].mb_flags & (MLY_BTL_LOGICAL | MLY_BTL_PHYSICAL))) {
- debug(2, " device does not exist");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
-
- /* XXX increase if/when we support large SCSI commands */
- if (csio->cdb_len > MLY_CMD_SCSI_SMALL_CDB) {
- debug(2, " command too large (%d > %d)", csio->cdb_len, MLY_CMD_SCSI_SMALL_CDB);
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
-
- /* check that the CDB pointer is not to a physical address */
- if ((csio->ccb_h.flags & CAM_CDB_POINTER) && (csio->ccb_h.flags & CAM_CDB_PHYS)) {
- debug(2, " CDB pointer is to physical address");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
-
- /* if there is data transfer, it must be to/from a virtual address */
- if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if (csio->ccb_h.flags & CAM_DATA_PHYS) { /* we can't map it */
- debug(2, " data pointer is to physical address");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
- if (csio->ccb_h.flags & CAM_SCATTER_VALID) { /* we want to do the s/g setup */
- debug(2, " data has premature s/g setup");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
- }
-
- /* abandon aborted ccbs or those that have failed validation */
- if ((csio->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
- debug(2, "abandoning CCB due to abort/validation failure");
- break;
- }
-
- /* save the channel number in the ccb */
- csio->ccb_h.sim_priv.entries[0].field = bus;
-
- /* enqueue the ccb and start I/O */
- mly_enqueue_ccb(sc, ccb);
- mly_startio(sc);
- return;
- }
-
- /* perform geometry calculations */
- case XPT_CALC_GEOMETRY:
- {
- struct ccb_calc_geometry *ccg = &ccb->ccg;
- u_int32_t secs_per_cylinder;
-
- debug(2, "XPT_CALC_GEOMETRY %d:%d:%d", cam_sim_bus(sim), ccb->ccb_h.target_id, ccb->ccb_h.target_lun);
-
- if (sc->mly_controllerparam->bios_geometry == MLY_BIOSGEOM_8G) {
- ccg->heads = 255;
- ccg->secs_per_track = 63;
- } else { /* MLY_BIOSGEOM_2G */
- ccg->heads = 128;
- ccg->secs_per_track = 32;
- }
- secs_per_cylinder = ccg->heads * ccg->secs_per_track;
- ccg->cylinders = ccg->volume_size / secs_per_cylinder;
- ccb->ccb_h.status = CAM_REQ_CMP;
- break;
- }
-
- /* handle path attribute inquiry */
- case XPT_PATH_INQ:
- {
- struct ccb_pathinq *cpi = &ccb->cpi;
-
- debug(2, "XPT_PATH_INQ %d:%d:%d", cam_sim_bus(sim), ccb->ccb_h.target_id, ccb->ccb_h.target_lun);
-
- cpi->version_num = 1;
- cpi->hba_inquiry = PI_TAG_ABLE; /* XXX extra flags for physical channels? */
- cpi->target_sprt = 0;
- cpi->hba_misc = 0;
- cpi->max_target = MLY_MAX_TARGETS - 1;
- cpi->max_lun = MLY_MAX_LUNS - 1;
- cpi->initiator_id = sc->mly_controllerparam->initiator_id;
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "BSDi", HBA_IDLEN);
- strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
- cpi->unit_number = cam_sim_unit(sim);
- cpi->bus_id = cam_sim_bus(sim);
- cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */
- ccb->ccb_h.status = CAM_REQ_CMP;
- break;
- }
-
- default: /* we can't do this */
- debug(2, "unspported func_code = 0x%x", ccb->ccb_h.func_code);
- ccb->ccb_h.status = CAM_REQ_INVALID;
- break;
- }
-
- xpt_done(ccb);
-}
-
-/********************************************************************************
- * Check for possibly-completed commands.
- */
-static void
-mly_cam_poll(struct cam_sim *sim)
-{
- struct mly_softc *sc = cam_sim_softc(sim);
-
- debug_called(2);
-
- mly_done(sc);
-}
-
-/********************************************************************************
- * Pull a CCB off the work queue and turn it into a command.
- */
-int
-mly_cam_command(struct mly_softc *sc, struct mly_command **mcp)
-{
- struct mly_command *mc;
- struct mly_command_scsi_small *ss;
- struct ccb_scsiio *csio;
- int error;
-
- debug_called(2);
-
- error = 0;
- mc = NULL;
- csio = NULL;
-
- /* check for a CCB */
- if (!(csio = (struct ccb_scsiio *)mly_dequeue_ccb(sc)))
- goto out;
-
- /* get a command to back it */
- if (mly_alloc_command(sc, &mc)) {
- error = ENOMEM;
- goto out;
- }
-
- /* build the command */
- MLY_CMD_SETSTATE(mc, MLY_CMD_SETUP);
- mc->mc_data = csio->data_ptr;
- mc->mc_length = csio->dxfer_len;
- mc->mc_complete = mly_cam_complete;
- mc->mc_private = csio;
-
- /* build the packet for the controller */
- ss = &mc->mc_packet->scsi_small;
- ss->opcode = MDACMD_SCSI;
- if (csio->ccb_h.flags * CAM_DIS_DISCONNECT)
- ss->command_control.disable_disconnect = 1;
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
- ss->command_control.data_direction = MLY_CCB_WRITE;
- ss->data_size = csio->dxfer_len;
- ss->addr.phys.lun = csio->ccb_h.target_lun;
- ss->addr.phys.target = csio->ccb_h.target_id;
- ss->addr.phys.channel = csio->ccb_h.sim_priv.entries[0].field;
- if (csio->ccb_h.timeout < (60 * 1000)) {
- ss->timeout.value = csio->ccb_h.timeout / 1000;
- ss->timeout.scale = MLY_TIMEOUT_SECONDS;
- } else if (csio->ccb_h.timeout < (60 * 60 * 1000)) {
- ss->timeout.value = csio->ccb_h.timeout / (60 * 1000);
- ss->timeout.scale = MLY_TIMEOUT_MINUTES;
- } else {
- ss->timeout.value = csio->ccb_h.timeout / (60 * 60 * 1000); /* overflow? */
- ss->timeout.scale = MLY_TIMEOUT_HOURS;
- }
- ss->maximum_sense_size = csio->sense_len;
- ss->cdb_length = csio->cdb_len;
- if (csio->ccb_h.flags & CAM_CDB_POINTER) {
- bcopy(csio->cdb_io.cdb_ptr, ss->cdb, csio->cdb_len);
- } else {
- bcopy(csio->cdb_io.cdb_bytes, ss->cdb, csio->cdb_len);
- }
-
-out:
- if (error != 0) {
- if (mc != NULL) {
- mly_release_command(mc);
- mc = NULL;
- }
- if (csio != NULL)
- mly_requeue_ccb(sc, (union ccb *)csio);
- }
- *mcp = mc;
- return(error);
-}
-
-/********************************************************************************
- * Handle completion of a command - pass results back through the CCB
- */
-static void
-mly_cam_complete(struct mly_command *mc)
-{
- struct mly_softc *sc = mc->mc_sc;
- struct ccb_scsiio *csio = (struct ccb_scsiio *)mc->mc_private;
- struct scsi_inquiry_data *inq = (struct scsi_inquiry_data *)csio->data_ptr;
- struct mly_btl *btl;
- u_int8_t cmd;
- int bus, target;
-
- debug_called(2);
-
- csio->scsi_status = mc->mc_status;
- switch(mc->mc_status) {
- case SCSI_STATUS_OK:
- /*
- * In order to report logical device type and status, we overwrite
- * the result of the INQUIRY command to logical devices.
- */
- bus = csio->ccb_h.sim_priv.entries[0].field;
- if (bus >= sc->mly_controllerinfo->physical_channels_present) {
- if (csio->ccb_h.flags & CAM_CDB_POINTER) {
- cmd = *csio->cdb_io.cdb_ptr;
- } else {
- cmd = csio->cdb_io.cdb_bytes[0];
- }
- if (cmd == INQUIRY) {
- target = csio->ccb_h.target_id;
- btl = &sc->mly_btl[bus][target];
- padstr(inq->vendor, mly_describe_code(mly_table_device_type, btl->mb_type), 8);
- padstr(inq->product, mly_describe_code(mly_table_device_state, btl->mb_state), 16);
- padstr(inq->revision, "", 4);
- }
- }
-
- debug(2, "SCSI_STATUS_OK");
- csio->ccb_h.status = CAM_REQ_CMP;
- break;
-
- case SCSI_STATUS_CHECK_COND:
- debug(2, "SCSI_STATUS_CHECK_COND sense %d resid %d", mc->mc_sense, mc->mc_resid);
- csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
- bzero(&csio->sense_data, SSD_FULL_SIZE);
- bcopy(mc->mc_packet, &csio->sense_data, mc->mc_sense);
- csio->sense_len = mc->mc_sense;
- csio->ccb_h.status |= CAM_AUTOSNS_VALID;
- csio->resid = mc->mc_resid; /* XXX this is a signed value... */
- break;
-
- case SCSI_STATUS_BUSY:
- debug(2, "SCSI_STATUS_BUSY");
- csio->ccb_h.status = CAM_SCSI_BUSY;
- break;
-
- default:
- debug(2, "unknown status 0x%x", csio->scsi_status);
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- break;
- }
- xpt_done((union ccb *)csio);
- mly_release_command(mc);
-}
-
-/********************************************************************************
- * Find a peripheral attahed at (bus),(target)
- */
-static struct cam_periph *
-mly_find_periph(struct mly_softc *sc, int bus, int target)
-{
- struct cam_periph *periph;
- struct cam_path *path;
- int status;
-
- status = xpt_create_path(&path, NULL, cam_sim_path(sc->mly_cam_sim[bus]), target, 0);
- if (status == CAM_REQ_CMP) {
- periph = cam_periph_find(path, NULL);
- xpt_free_path(path);
- } else {
- periph = NULL;
- }
- return(periph);
-}
-
-/********************************************************************************
- * Name the device at (bus)(target)
- */
-int
-mly_name_device(struct mly_softc *sc, int bus, int target)
-{
- struct cam_periph *periph;
-
- if ((periph = mly_find_periph(sc, bus, target)) != NULL) {
- sprintf(sc->mly_btl[bus][target].mb_name, "%s%d", periph->periph_name, periph->unit_number);
- return(0);
- }
- sc->mly_btl[bus][target].mb_name[0] = 0;
- return(ENOENT);
-}
diff --git a/sys/dev/mly/mly_pci.c b/sys/dev/mly/mly_pci.c
deleted file mode 100644
index c0dbd457ed887..0000000000000
--- a/sys/dev/mly/mly_pci.c
+++ /dev/null
@@ -1,590 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/devicestat.h>
-#include <sys/disk.h>
-
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#include <dev/mly/mlyreg.h>
-#include <dev/mly/mlyvar.h>
-
-static int mly_pci_probe(device_t dev);
-static int mly_pci_attach(device_t dev);
-static int mly_pci_detach(device_t dev);
-static int mly_pci_shutdown(device_t dev);
-static int mly_pci_suspend(device_t dev);
-static int mly_pci_resume(device_t dev);
-static void mly_pci_intr(void *arg);
-
-static int mly_sg_map(struct mly_softc *sc);
-static void mly_sg_map_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error);
-static int mly_mmbox_map(struct mly_softc *sc);
-static void mly_mmbox_map_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error);
-static void mly_free_command_cluster(struct mly_command_cluster *mcc);
-
-static device_method_t mly_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, mly_pci_probe),
- DEVMETHOD(device_attach, mly_pci_attach),
- DEVMETHOD(device_detach, mly_pci_detach),
- DEVMETHOD(device_shutdown, mly_pci_shutdown),
- DEVMETHOD(device_suspend, mly_pci_suspend),
- DEVMETHOD(device_resume, mly_pci_resume),
- { 0, 0 }
-};
-
-static driver_t mly_pci_driver = {
- "mly",
- mly_methods,
- sizeof(struct mly_softc)
-};
-
-static devclass_t mly_devclass;
-DRIVER_MODULE(mly, pci, mly_pci_driver, mly_devclass, 0, 0);
-
-struct mly_ident
-{
- u_int16_t vendor;
- u_int16_t device;
- u_int16_t subvendor;
- u_int16_t subdevice;
- int hwif;
- char *desc;
-} mly_identifiers[] = {
- {0x1069, 0xba56, 0x1069, 0x0040, MLY_HWIF_STRONGARM, "Mylex eXtremeRAID 2000"},
- {0x1069, 0xba56, 0x1069, 0x0030, MLY_HWIF_STRONGARM, "Mylex eXtremeRAID 3000"},
- {0x1069, 0x0050, 0x1069, 0x0050, MLY_HWIF_I960RX, "Mylex AcceleRAID 352"},
- {0x1069, 0x0050, 0x1069, 0x0052, MLY_HWIF_I960RX, "Mylex AcceleRAID 170"},
- {0x1069, 0x0050, 0x1069, 0x0054, MLY_HWIF_I960RX, "Mylex AcceleRAID 160"},
- {0, 0, 0, 0, 0, 0}
-};
-
-/********************************************************************************
- ********************************************************************************
- Bus Interface
- ********************************************************************************
- ********************************************************************************/
-
-static int
-mly_pci_probe(device_t dev)
-{
- struct mly_ident *m;
-
- debug_called(1);
-
- for (m = mly_identifiers; m->vendor != 0; m++) {
- if ((m->vendor == pci_get_vendor(dev)) &&
- (m->device == pci_get_device(dev)) &&
- ((m->subvendor == 0) || ((m->subvendor == pci_get_subvendor(dev)) &&
- (m->subdevice == pci_get_subdevice(dev))))) {
-
- device_set_desc(dev, m->desc);
- return(-10); /* allow room to be overridden */
- }
- }
- return(ENXIO);
-}
-
-static int
-mly_pci_attach(device_t dev)
-{
- struct mly_softc *sc;
- int i, error;
- u_int32_t command;
-
- debug_called(1);
-
- /*
- * Initialise softc.
- */
- sc = device_get_softc(dev);
- bzero(sc, sizeof(*sc));
- sc->mly_dev = dev;
-
-#ifdef MLY_DEBUG
- if (device_get_unit(sc->mly_dev) == 0)
- mly_softc0 = sc;
-#endif
-
- /* assume failure is 'not configured' */
- error = ENXIO;
-
- /*
- * Verify that the adapter is correctly set up in PCI space.
- */
- command = pci_read_config(sc->mly_dev, PCIR_COMMAND, 2);
- command |= PCIM_CMD_BUSMASTEREN;
- pci_write_config(dev, PCIR_COMMAND, command, 2);
- command = pci_read_config(sc->mly_dev, PCIR_COMMAND, 2);
- if (!(command & PCIM_CMD_BUSMASTEREN)) {
- mly_printf(sc, "can't enable busmaster feature\n");
- goto fail;
- }
- if ((command & PCIM_CMD_MEMEN) == 0) {
- mly_printf(sc, "memory window not available\n");
- goto fail;
- }
-
- /*
- * Allocate the PCI register window.
- */
- sc->mly_regs_rid = PCIR_MAPS; /* first base address register */
- if ((sc->mly_regs_resource = bus_alloc_resource(sc->mly_dev, SYS_RES_MEMORY, &sc->mly_regs_rid,
- 0, ~0, 1, RF_ACTIVE)) == NULL) {
- mly_printf(sc, "can't allocate register window\n");
- goto fail;
- }
- sc->mly_btag = rman_get_bustag(sc->mly_regs_resource);
- sc->mly_bhandle = rman_get_bushandle(sc->mly_regs_resource);
-
- /*
- * Allocate and connect our interrupt.
- */
- sc->mly_irq_rid = 0;
- if ((sc->mly_irq = bus_alloc_resource(sc->mly_dev, SYS_RES_IRQ, &sc->mly_irq_rid,
- 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE)) == NULL) {
- mly_printf(sc, "can't allocate interrupt\n");
- goto fail;
- }
- if (bus_setup_intr(sc->mly_dev, sc->mly_irq, INTR_TYPE_CAM, mly_pci_intr, sc, &sc->mly_intr)) {
- mly_printf(sc, "can't set up interrupt\n");
- goto fail;
- }
-
- /* assume failure is 'out of memory' */
- error = ENOMEM;
-
- /*
- * Allocate the parent bus DMA tag appropriate for our PCI interface.
- *
- * Note that all of these controllers are 64-bit capable.
- */
- if (bus_dma_tag_create(NULL, /* parent */
- 1, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- MAXBSIZE, MLY_MAXSGENTRIES, /* maxsize, nsegments */
- BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
- BUS_DMA_ALLOCNOW, /* flags */
- &sc->mly_parent_dmat)) {
- mly_printf(sc, "can't allocate parent DMA tag\n");
- goto fail;
- }
-
- /*
- * Create DMA tag for mapping buffers into controller-addressable space.
- */
- if (bus_dma_tag_create(sc->mly_parent_dmat, /* parent */
- 1, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- MAXBSIZE, MLY_MAXSGENTRIES, /* maxsize, nsegments */
- BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
- 0, /* flags */
- &sc->mly_buffer_dmat)) {
- mly_printf(sc, "can't allocate buffer DMA tag\n");
- goto fail;
- }
-
- /*
- * Initialise the DMA tag for command packets.
- */
- if (bus_dma_tag_create(sc->mly_parent_dmat, /* parent */
- 1, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- sizeof(union mly_command_packet) * MLY_CMD_CLUSTERCOUNT, 1, /* maxsize, nsegments */
- BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
- 0, /* flags */
- &sc->mly_packet_dmat)) {
- mly_printf(sc, "can't allocate command packet DMA tag\n");
- goto fail;
- }
-
- /*
- * Detect the hardware interface version
- */
- for (i = 0; mly_identifiers[i].vendor != 0; i++) {
- if ((mly_identifiers[i].vendor == pci_get_vendor(dev)) &&
- (mly_identifiers[i].device == pci_get_device(dev))) {
- sc->mly_hwif = mly_identifiers[i].hwif;
- switch(sc->mly_hwif) {
- case MLY_HWIF_I960RX:
- debug(2, "set hardware up for i960RX");
- sc->mly_doorbell_true = 0x00;
- sc->mly_command_mailbox = MLY_I960RX_COMMAND_MAILBOX;
- sc->mly_status_mailbox = MLY_I960RX_STATUS_MAILBOX;
- sc->mly_idbr = MLY_I960RX_IDBR;
- sc->mly_odbr = MLY_I960RX_ODBR;
- sc->mly_error_status = MLY_I960RX_ERROR_STATUS;
- sc->mly_interrupt_status = MLY_I960RX_INTERRUPT_STATUS;
- sc->mly_interrupt_mask = MLY_I960RX_INTERRUPT_MASK;
- break;
- case MLY_HWIF_STRONGARM:
- debug(2, "set hardware up for StrongARM");
- sc->mly_doorbell_true = 0xff; /* doorbell 'true' is 0 */
- sc->mly_command_mailbox = MLY_STRONGARM_COMMAND_MAILBOX;
- sc->mly_status_mailbox = MLY_STRONGARM_STATUS_MAILBOX;
- sc->mly_idbr = MLY_STRONGARM_IDBR;
- sc->mly_odbr = MLY_STRONGARM_ODBR;
- sc->mly_error_status = MLY_STRONGARM_ERROR_STATUS;
- sc->mly_interrupt_status = MLY_STRONGARM_INTERRUPT_STATUS;
- sc->mly_interrupt_mask = MLY_STRONGARM_INTERRUPT_MASK;
- break;
- }
- break;
- }
- }
-
- /*
- * Create the scatter/gather mappings.
- */
- if ((error = mly_sg_map(sc)))
- goto fail;
-
- /*
- * Allocate and map the memory mailbox
- */
- if ((error = mly_mmbox_map(sc)))
- goto fail;
-
- /*
- * Do bus-independent initialisation.
- */
- if ((error = mly_attach(sc)))
- goto fail;
-
- return(0);
-
-fail:
- mly_free(sc);
- return(error);
-}
-
-/********************************************************************************
- * Disconnect from the controller completely, in preparation for unload.
- */
-static int
-mly_pci_detach(device_t dev)
-{
- struct mly_softc *sc = device_get_softc(dev);
- int error;
-
- debug_called(1);
-
- if (sc->mly_state & MLY_STATE_OPEN)
- return(EBUSY);
-
- if ((error = mly_pci_shutdown(dev)))
- return(error);
-
- mly_free(sc);
-
- return(0);
-}
-
-/********************************************************************************
- * Bring the controller down to a dormant state and detach all child devices.
- *
- * This function is called before detach or system shutdown.
- *
- * Note that we can assume that the camq on the controller is empty, as we won't
- * allow shutdown if any device is open.
- */
-static int
-mly_pci_shutdown(device_t dev)
-{
- struct mly_softc *sc = device_get_softc(dev);
-
- debug_called(1);
-
- mly_detach(sc);
- return(0);
-}
-
-/********************************************************************************
- * Bring the controller to a quiescent state, ready for system suspend.
- *
- * We can't assume that the controller is not active at this point, so we need
- * to mask interrupts.
- */
-static int
-mly_pci_suspend(device_t dev)
-{
- struct mly_softc *sc = device_get_softc(dev);
- int s;
-
- debug_called(1);
- s = splcam();
- mly_detach(sc);
- splx(s);
- return(0);
-}
-
-/********************************************************************************
- * Bring the controller back to a state ready for operation.
- */
-static int
-mly_pci_resume(device_t dev)
-{
- struct mly_softc *sc = device_get_softc(dev);
-
- debug_called(1);
- sc->mly_state &= ~MLY_STATE_SUSPEND;
- MLY_UNMASK_INTERRUPTS(sc);
- return(0);
-}
-
-/*******************************************************************************
- * Take an interrupt, or be poked by other code to look for interrupt-worthy
- * status.
- */
-static void
-mly_pci_intr(void *arg)
-{
- struct mly_softc *sc = (struct mly_softc *)arg;
-
- debug_called(3);
-
- /* collect finished commands, queue anything waiting */
- mly_done(sc);
-};
-
-/********************************************************************************
- ********************************************************************************
- Bus-dependant Resource Management
- ********************************************************************************
- ********************************************************************************/
-
-/********************************************************************************
- * Allocate memory for the scatter/gather tables
- */
-static int
-mly_sg_map(struct mly_softc *sc)
-{
- size_t segsize;
-
- debug_called(1);
-
- /*
- * Create a single tag describing a region large enough to hold all of
- * the s/g lists we will need.
- */
- segsize = sizeof(struct mly_sg_entry) * MLY_MAXCOMMANDS * MLY_MAXSGENTRIES;
- if (bus_dma_tag_create(sc->mly_parent_dmat, /* parent */
- 1, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- segsize, 1, /* maxsize, nsegments */
- BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
- 0, /* flags */
- &sc->mly_sg_dmat)) {
- mly_printf(sc, "can't allocate scatter/gather DMA tag\n");
- return(ENOMEM);
- }
-
- /*
- * Allocate enough s/g maps for all commands and permanently map them into
- * controller-visible space.
- *
- * XXX this assumes we can get enough space for all the s/g maps in one
- * contiguous slab.
- */
- if (bus_dmamem_alloc(sc->mly_sg_dmat, (void **)&sc->mly_sg_table, BUS_DMA_NOWAIT, &sc->mly_sg_dmamap)) {
- mly_printf(sc, "can't allocate s/g table\n");
- return(ENOMEM);
- }
- bus_dmamap_load(sc->mly_sg_dmat, sc->mly_sg_dmamap, sc->mly_sg_table, segsize, mly_sg_map_helper, sc, 0);
- return(0);
-}
-
-/********************************************************************************
- * Save the physical address of the base of the s/g table.
- */
-static void
-mly_sg_map_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct mly_softc *sc = (struct mly_softc *)arg;
-
- debug_called(2);
-
- /* save base of s/g table's address in bus space */
- sc->mly_sg_busaddr = segs->ds_addr;
-}
-
-/********************************************************************************
- * Allocate memory for the memory-mailbox interface
- */
-static int
-mly_mmbox_map(struct mly_softc *sc)
-{
-
- /*
- * Create a DMA tag for a single contiguous region large enough for the
- * memory mailbox structure.
- */
- if (bus_dma_tag_create(sc->mly_parent_dmat, /* parent */
- 1, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- sizeof(struct mly_mmbox), 1, /* maxsize, nsegments */
- BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
- 0, /* flags */
- &sc->mly_mmbox_dmat)) {
- mly_printf(sc, "can't allocate memory mailbox DMA tag\n");
- return(ENOMEM);
- }
-
- /*
- * Allocate the buffer
- */
- if (bus_dmamem_alloc(sc->mly_mmbox_dmat, (void **)&sc->mly_mmbox, BUS_DMA_NOWAIT, &sc->mly_mmbox_dmamap)) {
- mly_printf(sc, "can't allocate memory mailbox\n");
- return(ENOMEM);
- }
- bus_dmamap_load(sc->mly_mmbox_dmat, sc->mly_mmbox_dmamap, sc->mly_mmbox, sizeof(struct mly_mmbox),
- mly_mmbox_map_helper, sc, 0);
- bzero(sc->mly_mmbox, sizeof(*sc->mly_mmbox));
- return(0);
-
-}
-
-/********************************************************************************
- * Save the physical address of the memory mailbox
- */
-static void
-mly_mmbox_map_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct mly_softc *sc = (struct mly_softc *)arg;
-
- debug_called(2);
-
- sc->mly_mmbox_busaddr = segs->ds_addr;
-}
-
-/********************************************************************************
- * Free all of the resources associated with (sc)
- *
- * Should not be called if the controller is active.
- */
-void
-mly_free(struct mly_softc *sc)
-{
- struct mly_command_cluster *mcc;
-
- debug_called(1);
-
- /* detach from CAM */
- mly_cam_detach(sc);
-
- /* throw away any command buffers */
- while ((mcc = mly_dequeue_cluster(sc)) != NULL)
- mly_free_command_cluster(mcc);
-
- /* throw away the controllerinfo structure */
- if (sc->mly_controllerinfo != NULL)
- free(sc->mly_controllerinfo, M_DEVBUF);
-
- /* throw away the controllerparam structure */
- if (sc->mly_controllerparam != NULL)
- free(sc->mly_controllerparam, M_DEVBUF);
-
- /* destroy data-transfer DMA tag */
- if (sc->mly_buffer_dmat)
- bus_dma_tag_destroy(sc->mly_buffer_dmat);
-
- /* free and destroy DMA memory and tag for s/g lists */
- if (sc->mly_sg_table) {
- bus_dmamap_unload(sc->mly_sg_dmat, sc->mly_sg_dmamap);
- bus_dmamem_free(sc->mly_sg_dmat, sc->mly_sg_table, sc->mly_sg_dmamap);
- }
- if (sc->mly_sg_dmat)
- bus_dma_tag_destroy(sc->mly_sg_dmat);
-
- /* free and destroy DMA memory and tag for memory mailbox */
- if (sc->mly_mmbox) {
- bus_dmamap_unload(sc->mly_mmbox_dmat, sc->mly_mmbox_dmamap);
- bus_dmamem_free(sc->mly_mmbox_dmat, sc->mly_mmbox, sc->mly_mmbox_dmamap);
- }
- if (sc->mly_mmbox_dmat)
- bus_dma_tag_destroy(sc->mly_mmbox_dmat);
-
- /* disconnect the interrupt handler */
- if (sc->mly_intr)
- bus_teardown_intr(sc->mly_dev, sc->mly_irq, sc->mly_intr);
- if (sc->mly_irq != NULL)
- bus_release_resource(sc->mly_dev, SYS_RES_IRQ, sc->mly_irq_rid, sc->mly_irq);
-
- /* destroy the parent DMA tag */
- if (sc->mly_parent_dmat)
- bus_dma_tag_destroy(sc->mly_parent_dmat);
-
- /* release the register window mapping */
- if (sc->mly_regs_resource != NULL)
- bus_release_resource(sc->mly_dev, SYS_RES_MEMORY, sc->mly_regs_rid, sc->mly_regs_resource);
-}
-
-/********************************************************************************
- * Free a command cluster.
- */
-static void
-mly_free_command_cluster(struct mly_command_cluster *mcc)
-{
- struct mly_softc *sc = mcc->mcc_command[0].mc_sc;
- int i;
-
- debug_called(1);
-
- for (i = 0; i < MLY_CMD_CLUSTERCOUNT; i++)
- bus_dmamap_destroy(sc->mly_buffer_dmat, mcc->mcc_command[i].mc_datamap);
-
- bus_dmamap_unload(sc->mly_packet_dmat, mcc->mcc_packetmap);
- bus_dmamem_free(sc->mly_packet_dmat, mcc->mcc_packet, mcc->mcc_packetmap);
- free(mcc, M_DEVBUF);
-}
-
diff --git a/sys/dev/mly/mly_tables.h b/sys/dev/mly/mly_tables.h
deleted file mode 100644
index 5a83f1767353e..0000000000000
--- a/sys/dev/mly/mly_tables.h
+++ /dev/null
@@ -1,335 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-/*
- * Lookup table for code-to-text translations.
- */
-struct mly_code_lookup {
- char *string;
- u_int32_t code;
-};
-
-extern char *mly_describe_code(struct mly_code_lookup *table, u_int32_t code);
-
-#ifndef MLY_DEFINE_TABLES
-extern struct mly_code_lookup mly_table_bustype[];
-extern struct mly_code_lookup mly_table_controllertype[];
-extern struct mly_code_lookup mly_table_oemname[];
-extern struct mly_code_lookup mly_table_memorytype[];
-extern struct mly_code_lookup mly_table_cputype[];
-extern struct mly_code_lookup mly_table_event[];
-extern struct mly_code_lookup mly_table_device_state[];
-extern struct mly_code_lookup mly_table_device_type[];
-extern struct mly_code_lookup mly_table_stripe_size[];
-extern struct mly_code_lookup mly_table_cacheline_size[];
-
-#else /* MLY_DEFINE_TABLES */
-
-/********************************************************************************
- * Look up a text description of a numeric code and return a pointer to same.
- */
-char *
-mly_describe_code(struct mly_code_lookup *table, u_int32_t code)
-{
- int i;
-
- for (i = 0; table[i].string != NULL; i++)
- if (table[i].code == code)
- return(table[i].string);
- return(table[i+1].string);
-}
-
-struct mly_code_lookup mly_table_bustype[] = {
- {"SCSI", 0x00},
- {"FC-AL", 0x01},
- {"PCI", 0x03},
- {NULL, 0},
- {"unknown bus", 0}
-};
-
-struct mly_code_lookup mly_table_controllertype[] = {
-#if 0 /* not supported by this driver */
- {"DAC960E", 0x01}, /* EISA */
- {"DAC960M", 0x08}, /* MCA */
- {"DAC960PD", 0x10}, /* PCI Dual */
- {"DAC960PL", 0x11}, /* PCU low-cost */
- {"DAC960PDU", 0x12}, /* PD Ultra */
- {"DAC960PE", 0x13}, /* Peregrine low-cost */
- {"DAC960PG", 0x14}, /* Peregrine high-performance */
- {"DAC960PJ", 0x15}, /* Road Runner */
- {"DAC960PTL0", 0x16}, /* Jaguar */
- {"DAC960PR", 0x17}, /* Road Runner (again?) */
- {"DAC960PRL", 0x18}, /* Tomcat */
- {"DAC960PT", 0x19}, /* Road Runner (yet again?) */
- {"DAC1164P", 0x1a}, /* Little Apple */
- {"DAC960PTL1", 0x1b}, /* Jaguar+ */
-#endif
- {"EXR2000P", 0x1c}, /* Big Apple */
- {"EXR3000P", 0x1d}, /* Fibre Apple */
- {"AcceleRAID 352", 0x1e}, /* Leopard */
- {"AcceleRAID 170", 0x1f}, /* Lynx */
- {"AcceleRAID 160", 0x20}, /* Bobcat */
- {NULL, 0},
- {"unknown adapter", 0}
-};
-
-struct mly_code_lookup mly_table_oemname[] = {
- {"Mylex", MLY_OEM_MYLEX},
- {"IBM", MLY_OEM_IBM},
- {"Hewlett-Packard", MLY_OEM_HP},
- {"DEC/Compaq", MLY_OEM_DEC},
- {"Siemens", MLY_OEM_SIEMENS},
- {"Intel", MLY_OEM_INTEL},
- {NULL, 0},
- {"unknown OEM", 0}
-};
-
-struct mly_code_lookup mly_table_memorytype[] = {
- {"DRAM", 0x01},
- {"EDRAM", 0x02},
- {"EDO RAM", 0x03},
- {"SDRAM", 0x04},
- {NULL, 0},
- {"unknown memory", 0}
-};
-
-struct mly_code_lookup mly_table_cputype[] = {
- {"i960CA", 0x01},
- {"i960RD", 0x02},
- {"i960RN", 0x03},
- {"i960RP", 0x04},
- {"NorthBay(?)", 0x05},
- {"StrongArm", 0x06},
- {"i960RM", 0x07},
- {NULL, 0},
- {"unknown CPU", 0}
-};
-
-/*
- * This table is directly derived from the corresponding table in the
- * Linux driver, and uses a derivative encoding for simplicity's sake.
- *
- * The first character of the string determines the format of the message.
- *
- * p "physical device <channel>:<target> <text>" (physical device status)
- * s "physical device <channel>:<target> <text>" (scsi message or error)
- * " sense key <key> asc <asc> ascq <ascq>"
- * " info <info> csi <csi>"
- * l "logical drive <unit>: <text>" (logical device status)
- * m "logical drive <unit>: <text>" (logical device message)
- *
- * Messages which are typically suppressed have the first character capitalised.
- * These messages will only be printed if bootverbose is set.
- *
- * The second character in the string indicates an action to be taken as a
- * result of the event.
- *
- * r rescan the device for possible state change
- *
- */
-struct mly_code_lookup mly_table_event[] = {
- /* physical device events (0x0000 - 0x007f) */
- {"pr online", 0x0001},
- {"pr standby", 0x0002},
- {"p automatic rebuild started", 0x0005},
- {"p manual rebuild started", 0x0006},
- {"pr rebuild completed", 0x0007},
- {"pr rebuild cancelled", 0x0008},
- {"pr rebuild failed for unknown reasons", 0x0009},
- {"pr rebuild failed due to new physical device", 0x000a},
- {"pr rebuild failed due to logical drive failure", 0x000b},
- {"sr offline", 0x000c},
- {"pr found", 0x000d},
- {"pr gone", 0x000e},
- {"p unconfigured", 0x000f},
- {"p expand capacity started", 0x0010},
- {"pr expand capacity completed", 0x0011},
- {"pr expand capacity failed", 0x0012},
- {"p parity error", 0x0016},
- {"p soft error", 0x0017},
- {"p miscellaneous error", 0x0018},
- {"p reset", 0x0019},
- {"p active spare found", 0x001a},
- {"p warm spare found", 0x001b},
- {"s sense data received", 0x001c},
- {"p initialization started", 0x001d},
- {"pr initialization completed", 0x001e},
- {"pr initialization failed", 0x001f},
- {"pr initialization cancelled", 0x0020},
- {"P write recovery failed", 0x0021},
- {"p scsi bus reset failed", 0x0022},
- {"p double check condition", 0x0023},
- {"p device cannot be accessed", 0x0024},
- {"p gross error on scsi processor", 0x0025},
- {"p bad tag from device", 0x0026},
- {"p command timeout", 0x0027},
- {"pr system reset", 0x0028},
- {"p busy status or parity error", 0x0029},
- {"pr host set device to failed state", 0x002a},
- {"pr selection timeout", 0x002b},
- {"p scsi bus phase error", 0x002c},
- {"pr device returned unknown status", 0x002d},
- {"pr device not ready", 0x002e},
- {"p device not found at startup", 0x002f},
- {"p COD write operation failed", 0x0030},
- {"p BDT write operation failed", 0x0031},
- {"p missing at startup", 0x0039},
- {"p start rebuild failed due to physical drive too small", 0x003a},
- /* logical device events (0x0080 - 0x00ff) */
- {"m consistency check started", 0x0080},
- {"mr consistency check completed", 0x0081},
- {"mr consistency check cancelled", 0x0082},
- {"mr consistency check completed with errors", 0x0083},
- {"mr consistency check failed due to logical drive failure", 0x0084},
- {"mr consistency check failed due to physical device failure", 0x0085},
- {"lr offline", 0x0086},
- {"lr critical", 0x0087},
- {"lr online", 0x0088},
- {"m automatic rebuild started", 0x0089},
- {"m manual rebuild started", 0x008a},
- {"mr rebuild completed", 0x008b},
- {"mr rebuild cancelled", 0x008c},
- {"mr rebuild failed for unknown reasons", 0x008d},
- {"mr rebuild failed due to new physical device", 0x008e},
- {"mr rebuild failed due to logical drive failure", 0x008f},
- {"l initialization started", 0x0090},
- {"lr initialization completed", 0x0091},
- {"lr initialization cancelled", 0x0092},
- {"lr initialization failed", 0x0093},
- {"lr found", 0x0094},
- {"lr gone", 0x0095},
- {"l expand capacity started", 0x0096},
- {"lr expand capacity completed", 0x0097},
- {"lr expand capacity failed", 0x0098},
- {"l bad block found", 0x0099},
- {"lr size changed", 0x009a},
- {"lr type changed", 0x009b},
- {"l bad data block found", 0x009c},
- {"l read of data block in bdt", 0x009e},
- {"l write back data for disk block lost", 0x009f},
- /* enclosure management events (0x0100 - 0x017f) */
- {"e enclosure %d fan %d failed", 0x0140},
- {"e enclosure %d fan %d ok", 0x0141},
- {"e enclosure %d fan %d not present", 0x0142},
- {"e enclosure %d power supply %d failed", 0x0143},
- {"e enclosure %d power supply %d ok", 0x0144},
- {"e enclosure %d power supply %d not present", 0x0145},
- {"e enclosure %d temperature sensor %d failed", 0x0146},
- {"e enclosure %d temperature sensor %d critical", 0x0147},
- {"e enclosure %d temperature sensor %d ok", 0x0148},
- {"e enclosure %d temperature sensor %d not present", 0x0149},
- {"e enclosure %d unit %d access critical", 0x014a},
- {"e enclosure %d unit %d access ok", 0x014b},
- {"e enclosure %d unit %d access offline", 0x014c},
- /* controller events (0x0180 - 0x01ff) */
- {"c cache write back error", 0x0181},
- {"c battery backup unit found", 0x0188},
- {"c battery backup unit charge level low", 0x0189},
- {"c battery backup unit charge level ok", 0x018a},
- {"c installation aborted", 0x0193},
- {"c mirror race recovery in progress", 0x0195},
- {"c mirror race on critical drive", 0x0196},
- {"c memory soft ecc error", 0x019e},
- {"c memory hard ecc error", 0x019f},
- {"c battery backup unit failed", 0x01a2},
- {NULL, 0},
- {"? unknown event code", 0}
-};
-
-/*
- * Values here must be 16 characters or less, as they are packed into
- * the 'product' field in the SCSI inquiry data.
- */
-struct mly_code_lookup mly_table_device_state[] = {
- {"offline", MLY_DEVICE_STATE_OFFLINE},
- {"unconfigured", MLY_DEVICE_STATE_UNCONFIGURED},
- {"online", MLY_DEVICE_STATE_ONLINE},
- {"critical", MLY_DEVICE_STATE_CRITICAL},
- {"writeonly", MLY_DEVICE_STATE_WRITEONLY},
- {"standby", MLY_DEVICE_STATE_STANDBY},
- {"missing", MLY_DEVICE_STATE_MISSING},
- {NULL, 0},
- {"unknown state", 0}
-};
-
-/*
- * Values here must be 8 characters or less, as they are packed into
- * the 'vendor' field in the SCSI inquiry data.
- */
-struct mly_code_lookup mly_table_device_type[] = {
- {"RAID 0", MLY_DEVICE_TYPE_RAID0},
- {"RAID 1", MLY_DEVICE_TYPE_RAID1},
- {"RAID 3", MLY_DEVICE_TYPE_RAID3}, /* right asymmetric parity */
- {"RAID 5", MLY_DEVICE_TYPE_RAID5}, /* right asymmetric parity */
- {"RAID 6", MLY_DEVICE_TYPE_RAID6}, /* Mylex RAID 6 */
- {"RAID 7", MLY_DEVICE_TYPE_RAID7}, /* JBOD */
- {"SPAN", MLY_DEVICE_TYPE_NEWSPAN}, /* New Mylex SPAN */
- {"RAID 3", MLY_DEVICE_TYPE_RAID3F}, /* fixed parity */
- {"RAID 3", MLY_DEVICE_TYPE_RAID3L}, /* left symmetric parity */
- {"SPAN", MLY_DEVICE_TYPE_SPAN}, /* current spanning implementation */
- {"RAID 5", MLY_DEVICE_TYPE_RAID5L}, /* left symmetric parity */
- {"RAID E", MLY_DEVICE_TYPE_RAIDE}, /* concatenation */
- {"PHYSICAL", MLY_DEVICE_TYPE_PHYSICAL}, /* physical device */
- {NULL, 0},
- {"UNKNOWN", 0}
-};
-
-struct mly_code_lookup mly_table_stripe_size[] = {
- {"NONE", MLY_STRIPE_ZERO},
- {"512B", MLY_STRIPE_512b},
- {"1k", MLY_STRIPE_1k},
- {"2k", MLY_STRIPE_2k},
- {"4k", MLY_STRIPE_4k},
- {"8k", MLY_STRIPE_8k},
- {"16k", MLY_STRIPE_16k},
- {"32k", MLY_STRIPE_32k},
- {"64k", MLY_STRIPE_64k},
- {"128k", MLY_STRIPE_128k},
- {"256k", MLY_STRIPE_256k},
- {"512k", MLY_STRIPE_512k},
- {"1M", MLY_STRIPE_1m},
- {NULL, 0},
- {"unknown", 0}
-};
-
-struct mly_code_lookup mly_table_cacheline_size[] = {
- {"NONE", MLY_CACHELINE_ZERO},
- {"512B", MLY_CACHELINE_512b},
- {"1k", MLY_CACHELINE_1k},
- {"2k", MLY_CACHELINE_2k},
- {"4k", MLY_CACHELINE_4k},
- {"8k", MLY_CACHELINE_8k},
- {"16k", MLY_CACHELINE_16k},
- {"32k", MLY_CACHELINE_32k},
- {"64k", MLY_CACHELINE_64k},
- {NULL, 0},
- {"unknown", 0}
-};
-
-#endif /* MLY_DEFINE_TABLES */
diff --git a/sys/dev/mly/mlyreg.h b/sys/dev/mly/mlyreg.h
deleted file mode 100644
index 2809eb58714cb..0000000000000
--- a/sys/dev/mly/mlyreg.h
+++ /dev/null
@@ -1,1270 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-/*
- * Section numbers in this document refer to the Mylex "Firmware Software Interface"
- * document ('FSI'), revision 0.11 04/11/00 unless otherwise qualified.
- *
- * Reference is made to the Mylex "Programming Guide for 6.x Controllers" document
- * ('PG6'), document #771242 revision 0.02, 04/11/00
- *
- * Note that fields marked N/A are not supported by the PCI controllers, but are
- * defined here to hold place in datastructures that are shared with the SCSI
- * controllers. Items not relevant to PCI controllers are not described here.
- *
- * Ordering of items in this file is a little odd due to the constraints of
- * nested declarations.
- */
-
-/*
- * 2.1 (Scatter Gather List Format)
- */
-struct mly_sg_entry {
- u_int64_t physaddr;
- u_int64_t length;
-} __attribute__ ((packed));
-
-/*
- * 5.2 System Device Access
- *
- * This is corroborated by the layout of the MDACIOCTL_GETCONTROLLERINFO data
- * in 21.8
- */
-#define MLY_MAX_CHANNELS 6
-#define MLY_MAX_TARGETS 16
-#define MLY_MAX_LUNS 1
-
-/*
- * 8.1 Different Device States
- */
-#define MLY_DEVICE_STATE_OFFLINE 0x08 /* DEAD/OFFLINE */
-#define MLY_DEVICE_STATE_UNCONFIGURED 0x00
-#define MLY_DEVICE_STATE_ONLINE 0x01
-#define MLY_DEVICE_STATE_CRITICAL 0x09
-#define MLY_DEVICE_STATE_WRITEONLY 0x03
-#define MLY_DEVICE_STATE_STANDBY 0x21
-#define MLY_DEVICE_STATE_MISSING 0x04 /* or-ed with (ONLINE or WRITEONLY or STANDBY) */
-
-/*
- * 8.2 Device Type Field definitions
- */
-#define MLY_DEVICE_TYPE_RAID0 0x0 /* RAID 0 */
-#define MLY_DEVICE_TYPE_RAID1 0x1 /* RAID 1 */
-#define MLY_DEVICE_TYPE_RAID3 0x3 /* RAID 3 right asymmetric parity */
-#define MLY_DEVICE_TYPE_RAID5 0x5 /* RAID 5 right asymmetric parity */
-#define MLY_DEVICE_TYPE_RAID6 0x6 /* RAID 6 (Mylex RAID 6) */
-#define MLY_DEVICE_TYPE_RAID7 0x7 /* RAID 7 (JBOD) */
-#define MLY_DEVICE_TYPE_NEWSPAN 0x8 /* New Mylex SPAN */
-#define MLY_DEVICE_TYPE_RAID3F 0x9 /* RAID 3 fixed parity */
-#define MLY_DEVICE_TYPE_RAID3L 0xb /* RAID 3 left symmetric parity */
-#define MLY_DEVICE_TYPE_SPAN 0xc /* current spanning implementation */
-#define MLY_DEVICE_TYPE_RAID5L 0xd /* RAID 5 left symmetric parity */
-#define MLY_DEVICE_TYPE_RAIDE 0xe /* RAID E (concatenation) */
-#define MLY_DEVICE_TYPE_PHYSICAL 0xf /* physical device */
-
-/*
- * 8.3 Stripe Size
- */
-#define MLY_STRIPE_ZERO 0x0 /* no stripe (RAID 1, RAID 7, etc) */
-#define MLY_STRIPE_512b 0x1
-#define MLY_STRIPE_1k 0x2
-#define MLY_STRIPE_2k 0x3
-#define MLY_STRIPE_4k 0x4
-#define MLY_STRIPE_8k 0x5
-#define MLY_STRIPE_16k 0x6
-#define MLY_STRIPE_32k 0x7
-#define MLY_STRIPE_64k 0x8
-#define MLY_STRIPE_128k 0x9
-#define MLY_STRIPE_256k 0xa
-#define MLY_STRIPE_512k 0xb
-#define MLY_STRIPE_1m 0xc
-
-/*
- * 8.4 Cacheline Size
- */
-#define MLY_CACHELINE_ZERO 0x0 /* caching cannot be enabled */
-#define MLY_CACHELINE_512b 0x1
-#define MLY_CACHELINE_1k 0x2
-#define MLY_CACHELINE_2k 0x3
-#define MLY_CACHELINE_4k 0x4
-#define MLY_CACHELINE_8k 0x5
-#define MLY_CACHELINE_16k 0x6
-#define MLY_CACHELINE_32k 0x7
-#define MLY_CACHELINE_64k 0x8
-
-/*
- * 8.5 Read/Write control
- */
-#define MLY_RWCtl_INITTED (1<<7) /* if set, the logical device is initialised */
- /* write control */
-#define MLY_RWCtl_WCD (0) /* write cache disabled */
-#define MLY_RWCtl_WDISABLE (1<<3) /* writing disabled */
-#define MLY_RWCtl_WCE (2<<3) /* write cache enabled */
-#define MLY_RWCtl_IWCE (3<<3) /* intelligent write cache enabled */
- /* read control */
-#define MLY_RWCtl_RCD (0) /* read cache is disabled */
-#define MLY_RWCtl_RCE (1) /* read cache enabled */
-#define MLY_RWCtl_RAHEAD (2) /* readahead enabled */
-#define MLY_RWCtl_IRAHEAD (3) /* intelligent readahead enabled */
-
-/*
- * 9.0 LUN Map Format
- */
-struct mly_lun_map {
- u_int8_t res1:4;
- u_int8_t host_port_mapped:1; /* this system drive visibile to host on this controller/port combination */
- u_int8_t tid_valid:1; /* target ID valid */
- u_int8_t hid_valid:1; /* host ID valid */
- u_int8_t lun_valid:1; /* LUN valid */
- u_int8_t res2;
- u_int8_t lun; /* LUN */
- u_int8_t tid; /* TID */
- u_int8_t hid[32]; /* HID (one bit for each host) */
-} __attribute__ ((packed));
-
-/*
- * 10.1 Controller Parameters
- */
-struct mly_param_controller {
- u_int8_t rdahen:1; /* N/A */
- u_int8_t bilodly:1; /* N/A */
- u_int8_t fua_disable:1;
- u_int8_t reass1s:1; /* N/A */
- u_int8_t truvrfy:1; /* N/A */
- u_int8_t dwtvrfy:1; /* N/A */
- u_int8_t background_initialisation:1;
- u_int8_t clustering:1; /* N/A */
-
- u_int8_t bios_disable:1;
- u_int8_t boot_from_cdrom:1;
- u_int8_t drive_coercion:1;
- u_int8_t write_same_disable:1;
- u_int8_t hba_mode:1; /* N/A */
- u_int8_t bios_geometry:2;
-#define MLY_BIOSGEOM_2G 0x0
-#define MLY_BIOSGEOM_8G 0x1
- u_int8_t res1:1; /* N/A */
-
- u_int8_t res2[2]; /* N/A */
-
- u_int8_t v_dec:1;
- u_int8_t safte:1; /* N/A */
- u_int8_t ses:1; /* N/A */
- u_int8_t res3:2; /* N/A */
- u_int8_t v_arm:1;
- u_int8_t v_ofm:1;
- u_int8_t res4:1; /* N/A */
-
- u_int8_t rebuild_check_rate;
- u_int8_t cache_line_size; /* see 8.4 */
- u_int8_t oem_code;
-#define MLY_OEM_MYLEX 0x00
-#define MLY_OEM_IBM 0x08
-#define MLY_OEM_HP 0x0a
-#define MLY_OEM_DEC 0x0c
-#define MLY_OEM_SIEMENS 0x10
-#define MLY_OEM_INTEL 0x12
- u_int8_t spinup_mode;
-#define MLY_SPIN_AUTO 0
-#define MLY_SPIN_PWRSPIN 1
-#define MLY_SPIN_WSSUSPIN 2
- u_int8_t spinup_devices;
- u_int8_t spinup_interval;
- u_int8_t spinup_wait_time;
-
- u_int8_t res5:3; /* N/A */
- u_int8_t vutursns:1; /* N/A */
- u_int8_t dccfil:1; /* N/A */
- u_int8_t nopause:1; /* N/A */
- u_int8_t disqfull:1; /* N/A */
- u_int8_t disbusy:1; /* N/A */
-
- u_int8_t res6:2; /* N/A */
- u_int8_t failover_node_name; /* N/A */
- u_int8_t res7:1; /* N/A */
- u_int8_t ftopo:3; /* N/A */
- u_int8_t disable_ups:1; /* N/A */
-
- u_int8_t res8:1; /* N/A */
- u_int8_t propagate_reset:1; /* N/A */
- u_int8_t nonstd_mp_reset:1; /* N/A */
- u_int8_t res9:5; /* N/A */
-
- u_int8_t res10; /* N/A */
- u_int8_t serial_port_baud_rate; /* N/A */
- u_int8_t serial_port_control; /* N/A */
- u_int8_t change_stripe_ok_developer_flag_only; /* N/A */
-
- u_int8_t small_large_host_transfers:2; /* N/A */
- u_int8_t frame_control:2; /* N/A */
- u_int8_t pci_latency_control:2; /* N/A */
- u_int8_t treat_lip_as_reset:1; /* N/A */
- u_int8_t res11:1; /* N/A */
-
- u_int8_t ms_autorest:1; /* N/A */
- u_int8_t res12:7; /* N/A */
-
- u_int8_t ms_aa_fsim:1; /* N/A */
- u_int8_t ms_aa_ccach:1; /* N/A */
- u_int8_t ms_aa_fault_signals:1; /* N/A */
- u_int8_t ms_aa_c4_faults:1; /* N/A */
- u_int8_t ms_aa_host_reset_delay_mask:4; /* N/A */
-
- u_int8_t ms_flg_simplex_no_rstcom:1; /* N/A */
- u_int8_t res13:7; /* N/A */
-
- u_int8_t res14; /* N/A */
- u_int8_t hardloopid[2][2]; /* N/A */
- u_int8_t ctrlname[2][16+1]; /* N/A */
- u_int8_t initiator_id;
- u_int8_t startup_option;
-#define MLY_STARTUP_IF_NO_CHANGE 0x0
-#define MLY_STARTUP_IF_NO_LUN_CHANGE 0x1
-#define MLY_STARTUP_IF_NO_LUN_OFFLINE 0x2
-#define MLY_STARTUP_IF_LUN0_NO_CHANGE 0x3
-#define MLY_STARTUP_IF_LUN0_NOT_OFFLINE 0x4
-#define MLY_STARTUP_ALWAYS 0x5
-
- u_int8_t res15[62];
-} __attribute__ ((packed));
-
-/*
- * 10.2 Physical Device Parameters
- */
-struct mly_param_physical_device {
- u_int16_t tags;
- u_int16_t speed;
- u_int8_t width;
- u_int8_t combing:1;
- u_int8_t res1:7;
- u_int8_t res2[3];
-} __attribute__ ((packed));
-
-/*
- * 10.3 Logical Device Parameters
- */
-struct mly_param_logical_device {
- u_int8_t type; /* see 8.2 */
- u_int8_t state; /* see 8.1 */
- u_int16_t raid_device;
- u_int8_t res1;
- u_int8_t bios_geometry; /* BIOS control word? */
- u_int8_t stripe_size; /* see 8.3 */
- u_int8_t read_write_control; /* see 8.5 */
- u_int8_t res2[8];
-} __attribute__ ((packed));
-
-/*
- * 12.3 Health Status Buffer
- *
- * Pad to 128 bytes.
- */
-struct mly_health_status {
- u_int32_t uptime_us; /* N/A */
- u_int32_t uptime_ms; /* N/A */
- u_int32_t realtime; /* N/A */
- u_int32_t res1; /* N/A */
- u_int32_t change_counter;
- u_int32_t res2; /* N/A */
- u_int32_t debug_message_index; /* N/A */
- u_int32_t bios_message_index; /* N/A */
- u_int32_t trace_page; /* N/A */
- u_int32_t profiler_page; /* N/A */
- u_int32_t next_event;
- u_int8_t res3[4 + 16 + 64]; /* N/A */
-} __attribute__ ((packed));
-
-/*
- * 14.2 Timeout Bit Format
- */
-struct mly_timeout {
- u_int8_t value:6;
- u_int8_t scale:2;
-#define MLY_TIMEOUT_SECONDS 0x0
-#define MLY_TIMEOUT_MINUTES 0x1
-#define MLY_TIMEOUT_HOURS 0x2
-} __attribute__ ((packed));
-
-/*
- * 14.3 Operation Device
- */
-#define MLY_OPDEVICE_PHYSICAL_DEVICE 0x0
-#define MLY_OPDEVICE_RAID_DEVICE 0x1
-#define MLY_OPDEVICE_PHYSICAL_CHANNEL 0x2
-#define MLY_OPDEVICE_RAID_CHANNEL 0x3
-#define MLY_OPDEVICE_PHYSICAL_CONTROLLER 0x4
-#define MLY_OPDEVICE_RAID_CONTROLLER 0x5
-#define MLY_OPDEVICE_CONFIGURATION_GROUP 0x10
-
-/*
- * 14.4 Status Bit Format
- *
- * AKA Status Mailbox Format
- *
- * XXX format conflict between FSI and PG6 over the ordering of the
- * status and sense length fields.
- */
-struct mly_status {
- u_int16_t command_id;
- u_int8_t status;
- u_int8_t sense_length;
- int32_t residue;
-} __attribute__ ((packed));
-
-/*
- * 14.5 Command Control Bit (CCB) format
- *
- * This byte is unfortunately named.
- */
-struct mly_command_control {
- u_int8_t force_unit_access:1;
- u_int8_t disable_page_out:1;
- u_int8_t res1:1;
- u_int8_t extended_sg_table:1;
- u_int8_t data_direction:1;
-#define MLY_CCB_WRITE 1
-#define MLY_CCB_READ 0
- u_int8_t res2:1;
- u_int8_t no_auto_sense:1;
- u_int8_t disable_disconnect:1;
-} __attribute__ ((packed));
-
-/*
- * 15.0 Commands
- *
- * We use the command names as given by Mylex
- */
-#define MDACMD_MEMCOPY 0x1 /* memory to memory copy */
-#define MDACMD_SCSIPT 0x2 /* SCSI passthrough (small command) */
-#define MDACMD_SCSILCPT 0x3 /* SCSI passthrough (large command) */
-#define MDACMD_SCSI 0x4 /* SCSI command for logical/phyiscal device (small command) */
-#define MDACMD_SCSILC 0x5 /* SCSI command for logical/phyiscal device (large command) */
-#define MDACMD_IOCTL 0x20 /* Management command */
-#define MDACMD_IOCTLCHECK 0x23 /* Validate management command (not implemented) */
-
-/*
- * 16.0 IOCTL command
- *
- * We use the IOCTL names as given by Mylex
- * Note that only ioctls supported by the PCI controller family are listed
- */
-#define MDACIOCTL_GETCONTROLLERINFO 0x1
-#define MDACIOCTL_GETLOGDEVINFOVALID 0x3
-#define MDACIOCTL_GETPHYSDEVINFOVALID 0x5
-#define MDACIOCTL_GETCONTROLLERSTATISTICS 0xb
-#define MDACIOCTL_GETLOGDEVSTATISTICS 0xd
-#define MDACIOCTL_GETPHYSDEVSTATISTICS 0xf
-#define MDACIOCTL_GETHEALTHSTATUS 0x11
-#define MDACIOCTL_GETEVENT 0x15
-/* flash update */
-#define MDACIOCTL_STOREIMAGE 0x2c
-#define MDACIOCTL_READIMAGE 0x2d
-#define MDACIOCTL_FLASHIMAGES 0x2e
-/* battery backup unit */
-#define MDACIOCTL_GET_SUBSYSTEM_DATA 0x70
-#define MDACIOCTL_SET_SUBSYSTEM_DATA 0x71
-/* non-data commands */
-#define MDACIOCTL_STARTDISOCVERY 0x81
-#define MDACIOCTL_SETRAIDDEVSTATE 0x82
-#define MDACIOCTL_INITPHYSDEVSTART 0x84
-#define MDACIOCTL_INITPHYSDEVSTOP 0x85
-#define MDACIOCTL_INITRAIDDEVSTART 0x86
-#define MDACIOCTL_INITRAIDDEVSTOP 0x87
-#define MDACIOCTL_REBUILDRAIDDEVSTART 0x88
-#define MDACIOCTL_REBUILDRAIDDEVSTOP 0x89
-#define MDACIOCTL_MAKECONSISTENTDATASTART 0x8a
-#define MDACIOCTL_MAKECONSISTENTDATASTOP 0x8b
-#define MDACIOCTL_CONSISTENCYCHECKSTART 0x8c
-#define MDACIOCTL_CONSISTENCYCHECKSTOP 0x8d
-#define MDACIOCTL_SETMEMORYMAILBOX 0x8e
-#define MDACIOCTL_RESETDEVICE 0x90
-#define MDACIOCTL_FLUSHDEVICEDATA 0x91
-#define MDACIOCTL_PAUSEDEVICE 0x92
-#define MDACIOCTL_UNPAUSEDEVICE 0x93
-#define MDACIOCTL_LOCATEDEVICE 0x94
-#define MDACIOCTL_SETMASTERSLAVEMODE 0x95
-#define MDACIOCTL_SETREALTIMECLOCK 0xac
-/* RAID configuration */
-#define MDACIOCTL_CREATENEWCONF 0xc0
-#define MDACIOCTL_DELETERAIDDEV 0xc1
-#define MDACIOCTL_REPLACEINTERNALDEV 0xc2
-#define MDACIOCTL_RENAMERAIDDEV 0xc3
-#define MDACIOCTL_ADDNEWCONF 0xc4
-#define MDACIOCTL_XLATEPHYSDEVTORAIDDEV 0xc5
-#define MDACIOCTL_MORE 0xc6
-#define MDACIOCTL_SETPHYSDEVPARAMETER 0xc8
-#define MDACIOCTL_GETPHYSDEVPARAMETER 0xc9
-#define MDACIOCTL_CLEARCONF 0xca
-#define MDACIOCTL_GETDEVCONFINFO 0xcb
-#define MDACIOCTL_GETGROUPCONFINFO 0xcc
-#define MDACIOCTL_GETFREESPACELIST 0xcd
-#define MDACIOCTL_GETLOGDEVPARAMETER 0xce
-#define MDACIOCTL_SETLOGDEVPARAMETER 0xcf
-#define MDACIOCTL_GETCONTROLLERPARAMETER 0xd0
-#define MDACIOCTL_SETCONTRLLERPARAMETER 0xd1
-#define MDACIOCTL_CLEARCONFSUSPMODE 0xd2
-#define MDACIOCTL_GETBDT_FOR_SYSDRIVE 0xe0
-
-/*
- * 17.1.4 Data Transfer Memory Address Without SG List
- */
-struct mly_short_transfer {
- struct mly_sg_entry sg[2];
-} __attribute__ ((packed));
-
-/*
- * 17.1.5 Data Transfer Memory Address With SG List
- *
- * Note that only the first s/g table is currently used.
- */
-struct mly_sg_transfer {
- u_int16_t entries[3];
- u_int16_t res1;
- u_int64_t table_physaddr[3];
-} __attribute__ ((packed));
-
-/*
- * 17.1.3 Data Transfer Memory Address Format
- */
-union mly_command_transfer {
- struct mly_short_transfer direct;
- struct mly_sg_transfer indirect;
-};
-
-/*
- * 21.1 MDACIOCTL_SETREALTIMECLOCK
- * 21.7 MDACIOCTL_GETHEALTHSTATUS
- * 21.8 MDACIOCTL_GETCONTROLLERINFO
- * 21.9 MDACIOCTL_GETLOGDEVINFOVALID
- * 21.10 MDACIOCTL_GETPHYSDEVINFOVALID
- * 21.11 MDACIOCTL_GETPHYSDEVSTATISTICS
- * 21.12 MDACIOCTL_GETLOGDEVSTATISTICS
- * 21.13 MDACIOCTL_GETCONTROLLERSTATISTICS
- * 21.27 MDACIOCTL_GETBDT_FOR_SYSDRIVE
- * 23.4 MDACIOCTL_CREATENEWCONF
- * 23.5 MDACIOCTL_ADDNEWCONF
- * 23.8 MDACIOCTL_GETDEVCONFINFO
- * 23.9 MDACIOCTL_GETFREESPACELIST
- * 24.1 MDACIOCTL_MORE
- * 25.1 MDACIOCTL_GETPHYSDEVPARAMETER
- * 25.2 MDACIOCTL_SETPHYSDEVPARAMETER
- * 25.3 MDACIOCTL_GETLOGDEVPARAMETER
- * 25.4 MDACIOCTL_SETLOGDEVPARAMETER
- * 25.5 MDACIOCTL_GETCONTROLLERPARAMETER
- * 25.6 MDACIOCTL_SETCONTROLLERPARAMETER
- *
- * These commands just transfer data
- */
-struct mly_ioctl_param_data {
- u_int8_t param[10];
- union mly_command_transfer transfer;
-} __attribute__ ((packed));
-
-/*
- * 21.2 MDACIOCTL_SETMEMORYMAILBOX
- */
-struct mly_ioctl_param_setmemorymailbox {
- u_int8_t health_buffer_size;
- u_int8_t res1;
- u_int64_t health_buffer_physaddr;
- u_int64_t command_mailbox_physaddr;
- u_int64_t status_mailbox_physaddr;
- u_int64_t res2[2];
-} __attribute__ ((packed));
-
-/*
- * 21.8.2 MDACIOCTL_GETCONTROLLERINFO: Data Format
- */
-struct mly_ioctl_getcontrollerinfo {
- u_int8_t res1; /* N/A */
- u_int8_t interface_type;
- u_int8_t controller_type;
- u_int8_t res2; /* N/A */
- u_int16_t interface_speed;
- u_int8_t interface_width;
- u_int8_t res3[9]; /* N/A */
- char interface_name[16];
- char controller_name[16];
- u_int8_t res4[16]; /* N/A */
- /* firmware release information */
- u_int8_t fw_major;
- u_int8_t fw_minor;
- u_int8_t fw_turn;
- u_int8_t fw_build;
- u_int8_t fw_day;
- u_int8_t fw_month;
- u_int8_t fw_century;
- u_int8_t fw_year;
- /* hardware release information */
- u_int8_t hw_revision; /* N/A */
- u_int8_t res5[3]; /* N/A */
- u_int8_t hw_release_day; /* N/A */
- u_int8_t hw_release_month; /* N/A */
- u_int8_t hw_release_century; /* N/A */
- u_int8_t hw_release_year; /* N/A */
- /* hardware manufacturing information */
- u_int8_t batch_number; /* N/A */
- u_int8_t res6; /* N/A */
- u_int8_t plant_number;
- u_int8_t res7;
- u_int8_t hw_manuf_day;
- u_int8_t hw_manuf_month;
- u_int8_t hw_manuf_century;
- u_int8_t hw_manuf_year;
- u_int8_t max_pdd_per_xldd;
- u_int8_t max_ildd_per_xldd;
- u_int16_t nvram_size;
- u_int8_t max_number_of_xld; /* N/A */
- u_int8_t res8[3]; /* N/A */
- /* unique information per controller */
- char serial_number[16];
- u_int8_t res9[16]; /* N/A */
- /* vendor information */
- u_int8_t res10[3]; /* N/A */
- u_int8_t oem_information;
- char vendor_name[16]; /* N/A */
- /* other physical/controller/operation information */
- u_int8_t bbu_present:1;
- u_int8_t active_clustering:1;
- u_int8_t res11:6; /* N/A */
- u_int8_t res12[3]; /* N/A */
- /* physical device scan information */
- u_int8_t physical_scan_active:1;
- u_int8_t res13:7; /* N/A */
- u_int8_t physical_scan_channel;
- u_int8_t physical_scan_target;
- u_int8_t physical_scan_lun;
- /* maximum command data transfer size */
- u_int16_t maximum_block_count;
- u_int16_t maximum_sg_entries;
- /* logical/physical device counts */
- u_int16_t logical_devices_present;
- u_int16_t logical_devices_critical;
- u_int16_t logical_devices_offline;
- u_int16_t physical_devices_present;
- u_int16_t physical_disks_present;
- u_int16_t physical_disks_critical; /* N/A */
- u_int16_t physical_disks_offline;
- u_int16_t maximum_parallel_commands;
- /* channel and target ID information */
- u_int8_t physical_channels_present;
- u_int8_t virtual_channels_present;
- u_int8_t physical_channels_possible;
- u_int8_t virtual_channels_possible;
- u_int8_t maximum_targets_possible[16]; /* N/A (6 and up) */
- u_int8_t res14[12]; /* N/A */
- /* memory/cache information */
- u_int16_t memory_size;
- u_int16_t cache_size;
- u_int32_t valid_cache_size; /* N/A */
- u_int32_t dirty_cache_size; /* N/A */
- u_int16_t memory_speed;
- u_int8_t memory_width;
- u_int8_t memory_type:5;
- u_int8_t res15:1; /* N/A */
- u_int8_t memory_parity:1;
- u_int8_t memory_ecc:1;
- char memory_information[16]; /* N/A */
- /* execution memory information */
- u_int16_t exmemory_size;
- u_int16_t l2cache_size; /* N/A */
- u_int8_t res16[8]; /* N/A */
- u_int16_t exmemory_speed;
- u_int8_t exmemory_width;
- u_int8_t exmemory_type:5;
- u_int8_t res17:1; /* N/A */
- u_int8_t exmemory_parity:1;
- u_int8_t exmemory_ecc:1;
- char exmemory_name[16]; /* N/A */
- /* CPU information */
- struct {
- u_int16_t speed;
- u_int8_t type;
- u_int8_t number;
- u_int8_t res1[12]; /* N/A */
- char name[16]; /* N/A */
- } cpu[2] __attribute__ ((packed));
- /* debugging/profiling/command time tracing information */
- u_int16_t profiling_page; /* N/A */
- u_int16_t profiling_programs; /* N/A */
- u_int16_t time_trace_page; /* N/A */
- u_int16_t time_trace_programs; /* N/A */
- u_int8_t res18[8]; /* N/A */
- /* error counters on physical devices */
- u_int16_t physical_device_bus_resets; /* N/A */
- u_int16_t physical_device_parity_errors; /* N/A */
- u_int16_t physical_device_soft_errors; /* N/A */
- u_int16_t physical_device_commands_failed; /* N/A */
- u_int16_t physical_device_miscellaneous_errors; /* N/A */
- u_int16_t physical_device_command_timeouts; /* N/A */
- u_int16_t physical_device_selection_timeouts; /* N/A */
- u_int16_t physical_device_retries; /* N/A */
- u_int16_t physical_device_aborts; /* N/A */
- u_int16_t physical_device_host_command_aborts; /* N/A */
- u_int16_t physical_device_PFAs_detected; /* N/A */
- u_int16_t physical_device_host_commands_failed; /* N/A */
- u_int8_t res19[8]; /* N/A */
- /* error counters on logical devices */
- u_int16_t logical_device_soft_errors; /* N/A */
- u_int16_t logical_device_commands_failed; /* N/A */
- u_int16_t logical_device_host_command_aborts; /* N/A */
- u_int16_t res20; /* N/A */
- /* error counters on controller */
- u_int16_t controller_parity_ecc_errors;
- u_int16_t controller_host_command_aborts; /* N/A */
- u_int8_t res21[4]; /* N/A */
- /* long duration activity information */
- u_int16_t background_inits_active;
- u_int16_t logical_inits_active;
- u_int16_t physical_inits_active;
- u_int16_t consistency_checks_active;
- u_int16_t rebuilds_active;
- u_int16_t MORE_active;
- u_int16_t patrol_active; /* N/A */
- u_int8_t long_operation_status; /* N/A */
- u_int8_t res22; /* N/A */
- /* flash ROM information */
- u_int8_t flash_type; /* N/A */
- u_int8_t res23; /* N/A */
- u_int16_t flash_size;
- u_int32_t flash_maximum_age;
- u_int32_t flash_age;
- u_int8_t res24[4]; /* N/A */
- char flash_name[16]; /* N/A */
- /* firmware runtime information */
- u_int8_t rebuild_rate;
- u_int8_t background_init_rate;
- u_int8_t init_rate;
- u_int8_t consistency_check_rate;
- u_int8_t res25[4]; /* N/A */
- u_int32_t maximum_dp;
- u_int32_t free_dp;
- u_int32_t maximum_iop;
- u_int32_t free_iop;
- u_int16_t maximum_comb_length;
- u_int16_t maximum_configuration_groups;
- u_int8_t installation_abort:1;
- u_int8_t maintenance:1;
- u_int8_t res26:6; /* N/A */
- u_int8_t res27[3]; /* N/A */
- u_int8_t res28[32 + 512]; /* N/A */
-} __attribute__ ((packed));
-
-/*
- * 21.9.2 MDACIOCTL_GETLOGDEVINFOVALID
- */
-struct mly_ioctl_getlogdevinfovalid {
- u_int8_t res1; /* N/A */
- u_int8_t channel;
- u_int8_t target;
- u_int8_t lun;
- u_int8_t state; /* see 8.1 */
- u_int8_t raid_level; /* see 8.2 */
- u_int8_t stripe_size; /* see 8.3 */
- u_int8_t cache_line_size; /* see 8.4 */
- u_int8_t read_write_control; /* see 8.5 */
- u_int8_t consistency_check:1;
- u_int8_t rebuild:1;
- u_int8_t make_consistent:1;
- u_int8_t initialisation:1;
- u_int8_t migration:1;
- u_int8_t patrol:1;
- u_int8_t res2:2; /* N/A */
- u_int8_t ar5_limit;
- u_int8_t ar5_algo;
- u_int16_t logical_device_number;
- u_int16_t bios_control;
- /* erorr counters */
- u_int16_t soft_errors; /* N/A */
- u_int16_t commands_failed; /* N/A */
- u_int16_t host_command_aborts; /* N/A */
- u_int16_t deferred_write_errors; /* N/A */
- u_int8_t res3[8]; /* N/A */
- /* device size information */
- u_int8_t res4[2]; /* N/A */
- u_int16_t device_block_size;
- u_int32_t original_device_size; /* N/A */
- u_int32_t device_size; /* XXX "blocks or MB" Huh? */
- u_int8_t res5[4]; /* N/A */
- char device_name[32]; /* N/A */
- u_int8_t inquiry[36];
- u_int8_t res6[12]; /* N/A */
- u_int64_t last_read_block; /* N/A */
- u_int64_t last_written_block; /* N/A */
- u_int64_t consistency_check_block;
- u_int64_t rebuild_block;
- u_int64_t make_consistent_block;
- u_int64_t initialisation_block;
- u_int64_t migration_block;
- u_int64_t patrol_block; /* N/A */
- u_int8_t res7[64]; /* N/A */
-} __attribute__ ((packed));
-
-/*
- * 21.10.2 MDACIOCTL_GETPHYSDEVINFOVALID: Data Format
- */
-struct mly_ioctl_getphysdevinfovalid {
- u_int8_t res1;
- u_int8_t channel;
- u_int8_t target;
- u_int8_t lun;
- u_int8_t raid_ft:1; /* configuration status */
- u_int8_t res2:1; /* N/A */
- u_int8_t local:1;
- u_int8_t res3:5;
- u_int8_t host_dead:1; /* multiple host/controller status *//* N/A */
- u_int8_t host_connection_dead:1; /* N/A */
- u_int8_t res4:6; /* N/A */
- u_int8_t state; /* see 8.1 */
- u_int8_t width;
- u_int16_t speed;
- /* multiported physical device information */
- u_int8_t ports_available; /* N/A */
- u_int8_t ports_inuse; /* N/A */
- u_int8_t res5[4];
- u_int8_t ether_address[16]; /* N/A */
- u_int16_t command_tags;
- u_int8_t consistency_check:1; /* N/A */
- u_int8_t rebuild:1; /* N/A */
- u_int8_t make_consistent:1; /* N/A */
- u_int8_t initialisation:1;
- u_int8_t migration:1; /* N/A */
- u_int8_t patrol:1; /* N/A */
- u_int8_t res6:2;
- u_int8_t long_operation_status; /* N/A */
- u_int8_t parity_errors;
- u_int8_t soft_errors;
- u_int8_t hard_errors;
- u_int8_t miscellaneous_errors;
- u_int8_t command_timeouts; /* N/A */
- u_int8_t retries; /* N/A */
- u_int8_t aborts; /* N/A */
- u_int8_t PFAs_detected; /* N/A */
- u_int8_t res7[6];
- u_int16_t block_size;
- u_int32_t original_device_size; /* XXX "blocks or MB" Huh? */
- u_int32_t device_size; /* XXX "blocks or MB" Huh? */
- u_int8_t res8[4];
- char name[16]; /* N/A */
- u_int8_t res9[16 + 32];
- u_int8_t inquiry[36];
- u_int8_t res10[12 + 16];
- u_int64_t last_read_block; /* N/A */
- u_int64_t last_written_block; /* N/A */
- u_int64_t consistency_check_block; /* N/A */
- u_int64_t rebuild_block; /* N/A */
- u_int64_t make_consistent_block; /* N/A */
- u_int64_t initialisation_block; /* N/A */
- u_int64_t migration_block; /* N/A */
- u_int64_t patrol_block; /* N/A */
- u_int8_t res11[256];
-} __attribute__ ((packed));
-
-union mly_devinfo {
- struct mly_ioctl_getlogdevinfovalid logdev;
- struct mly_ioctl_getphysdevinfovalid physdev;
-};
-
-/*
- * 21.11.2 MDACIOCTL_GETPHYSDEVSTATISTICS: Data Format
- * 21.12.2 MDACIOCTL_GETLOGDEVSTATISTICS: Data Format
- */
-struct mly_ioctl_getdevstatistics {
- u_int32_t uptime_ms; /* getphysedevstatistics only */
- u_int8_t res1[5]; /* N/A */
- u_int8_t channel;
- u_int8_t target;
- u_int8_t lun;
- u_int16_t raid_device; /* getlogdevstatistics only */
- u_int8_t res2[2]; /* N/A */
- /* total read/write performance including cache data */
- u_int32_t total_reads;
- u_int32_t total_writes;
- u_int32_t total_read_size;
- u_int32_t total_write_size;
- /* cache read/write performance */
- u_int32_t cache_reads; /* N/A */
- u_int32_t cache_writes; /* N/A */
- u_int32_t cache_read_size; /* N/A */
- u_int32_t cache_write_size; /* N/A */
- /* commands active/wait information */
- u_int32_t command_waits_done; /* N/A */
- u_int16_t active_commands; /* N/A */
- u_int16_t waiting_commands; /* N/A */
- u_int8_t res3[8]; /* N/A */
-} __attribute__ ((packed));
-
-/*
- * 21.13.2 MDACIOCTL_GETCONTROLLERSTATISTICS: Data Format
- */
-struct mly_ioctl_getcontrollerstatistics {
- u_int32_t uptime_ms; /* N/A */
- u_int8_t res1[12]; /* N/A */
- /* target physical device performance data information */
- u_int32_t target_physical_device_interrupts; /* N/A */
- u_int32_t target_physical_device_stray_interrupts; /* N/A */
- u_int8_t res2[8]; /* N/A */
- u_int32_t target_physical_device_reads; /* N/A */
- u_int32_t target_physical_device_writes; /* N/A */
- u_int32_t target_physical_device_read_size; /* N/A */
- u_int32_t target_physical_device_write_size; /* N/A */
- /* host system performance data information */
- u_int32_t host_system_interrupts; /* N/A */
- u_int32_t host_system_stray_interrupts; /* N/A */
- u_int32_t host_system_sent_interrupts; /* N/A */
- u_int8_t res3[4]; /* N/A */
- u_int32_t physical_device_reads; /* N/A */
- u_int32_t physical_device_writes; /* N/A */
- u_int32_t physical_device_read_size; /* N/A */
- u_int32_t physical_device_write_size; /* N/A */
- u_int32_t physical_device_cache_reads; /* N/A */
- u_int32_t physical_device_cache_writes; /* N/A */
- u_int32_t physical_device_cache_read_size; /* N/A */
- u_int32_t physical_device_cache_write_size; /* N/A */
- u_int32_t logical_device_reads; /* N/A */
- u_int32_t logical_device_writes; /* N/A */
- u_int32_t logical_device_read_size; /* N/A */
- u_int32_t logical_device_write_size; /* N/A */
- u_int32_t logical_device_cache_reads; /* N/A */
- u_int32_t logical_device_cache_writes; /* N/A */
- u_int32_t logical_device_cache_read_size; /* N/A */
- u_int32_t logical_device_cache_write_size; /* N/A */
- u_int16_t target_physical_device_commands_active; /* N/A */
- u_int16_t target_physical_device_commands_waiting; /* N/A */
- u_int16_t host_system_commands_active; /* N/A */
- u_int16_t host_system_commands_waiting; /* N/A */
- u_int8_t res4[48 + 64]; /* N/A */
-} __attribute__ ((packed));
-
-/*
- * 21.2 MDACIOCTL_SETRAIDDEVSTATE
- */
-struct mly_ioctl_param_setraiddevstate {
- u_int8_t state;
-} __attribute__ ((packed));
-
-/*
- * 21.27.2 MDACIOCTL_GETBDT_FOR_SYSDRIVE: Data Format
- */
-#define MLY_MAX_BDT_ENTRIES 1022
-struct mly_ioctl_getbdt_for_sysdrive {
- u_int32_t num_of_bdt_entries;
- u_int32_t bad_data_block_address[MLY_MAX_BDT_ENTRIES];
-} __attribute__ ((packed));
-
-/*
- * 22.1 Physical Device Definition (PDD)
- */
-struct mly_pdd {
- u_int8_t type; /* see 8.2 */
- u_int8_t state; /* see 8.1 */
- u_int16_t raid_device;
- u_int32_t device_size; /* XXX "block or MB" Huh? */
- u_int8_t controller;
- u_int8_t channel;
- u_int8_t target;
- u_int8_t lun;
- u_int32_t start_address;
-} __attribute__ ((packed));
-
-/*
- * 22.2 RAID Device Use Definition (UDD)
- */
-struct mly_udd {
- u_int8_t res1;
- u_int8_t state; /* see 8.1 */
- u_int16_t raid_device;
- u_int32_t start_address;
-} __attribute__ ((packed));
-
-/*
- * RAID Device Definition (LDD)
- */
-struct mly_ldd {
- u_int8_t type; /* see 8.2 */
- u_int8_t state; /* see 8.1 */
- u_int16_t raid_device;
- u_int32_t device_size; /* XXX "block or MB" Huh? */
- u_int8_t devices_used_count;
- u_int8_t stripe_size; /* see 8.3 */
- u_int8_t cache_line_size; /* see 8.4 */
- u_int8_t read_write_control; /* see 8.5 */
- u_int32_t devices_used_size; /* XXX "block or MB" Huh? */
- u_int16_t devices_used[32]; /* XXX actual size of this field unknown! */
-} __attribute__ ((packed));
-
-/*
- * Define a datastructure giving the smallest allocation that will hold
- * a PDD, UDD or LDD for MDACIOCTL_GETDEVCONFINFO.
- */
-struct mly_devconf_hdr {
- u_int8_t type; /* see 8.2 */
- u_int8_t state; /* see 8.1 */
- u_int16_t raid_device;
-};
-
-union mly_ioctl_devconfinfo {
- struct mly_pdd pdd;
- struct mly_udd udd;
- struct mly_ldd ldd;
- struct mly_devconf_hdr hdr;
-};
-
-/*
- * 22.3 MDACIOCTL_RENAMERAIDDEV
- *
- * XXX this command is listed as transferring data, but does not define the data.
- */
-struct mly_ioctl_param_renameraiddev {
- u_int8_t new_raid_device;
-} __attribute__ ((packed));
-
-/*
- * 23.6.2 MDACIOCTL_XLATEPHYSDEVTORAIDDEV
- *
- * XXX documentation suggests this format will change
- */
-struct mly_ioctl_param_xlatephysdevtoraiddev {
- u_int16_t raid_device;
- u_int8_t res1[2];
- u_int8_t controller;
- u_int8_t channel;
- u_int8_t target;
- u_int8_t lun;
-} __attribute__ ((packed));
-
-/*
- * 23.7 MDACIOCTL_GETGROUPCONFINFO
- */
-struct mly_ioctl_param_getgroupconfinfo {
- u_int16_t group;
- u_int8_t res1[8];
- union mly_command_transfer transfer;
-} __attribute__ ((packed));
-
-/*
- * 23.9.2 MDACIOCTL_GETFREESPACELIST: Data Format
- *
- * The controller will populate as much of this structure as is provided,
- * or as is required to fully list the free space available.
- */
-struct mly_ioctl_getfreespacelist_entry {
- u_int16_t raid_device;
- u_int8_t res1[6];
- u_int32_t address; /* XXX "blocks or MB" Huh? */
- u_int32_t size; /* XXX "blocks or MB" Huh? */
-} __attribute__ ((packed));
-
-struct mly_ioctl_getfrespacelist {
- u_int16_t returned_entries;
- u_int16_t total_entries;
- u_int8_t res1[12];
- struct mly_ioctl_getfreespacelist_entry space[0]; /* expand to suit */
-} __attribute__ ((packed));
-
-/*
- * 27.1 MDACIOCTL_GETSUBSYSTEMDATA
- * 27.2 MDACIOCTL_SETSUBSYSTEMDATA
- *
- * PCI controller only supports a limited subset of the possible operations.
- *
- * XXX where does the status end up? (the command transfers no data)
- */
-struct mly_ioctl_param_subsystemdata {
- u_int8_t operation:4;
-#define MLY_BBU_GETSTATUS 0x00
-#define MLY_BBU_SET_THRESHOLD 0x00 /* minutes in param[0,1] */
- u_int8_t subsystem:4;
-#define MLY_SUBSYSTEM_BBU 0x01
- u_int parameter[3]; /* only for SETSUBSYSTEMDATA */
-} __attribute__ ((packed));
-
-struct mly_ioctl_getsubsystemdata_bbustatus {
- u_int16_t current_power;
- u_int16_t maximum_power;
- u_int16_t power_threshold;
- u_int8_t charge_level;
- u_int8_t hardware_version;
- u_int8_t battery_type;
-#define MLY_BBU_TYPE_UNKNOWN 0x00
-#define MLY_BBU_TYPE_NICAD 0x01
-#define MLY_BBU_TYPE_MISSING 0xfe
- u_int8_t res1;
- u_int8_t operation_status;
-#define MLY_BBU_STATUS_NO_SYNC 0x01
-#define MLY_BBU_STATUS_OUT_OF_SYNC 0x02
-#define MLY_BBU_STATUS_FIRST_WARNING 0x04
-#define MLY_BBU_STATUS_SECOND_WARNING 0x08
-#define MLY_BBU_STATUS_RECONDITIONING 0x10
-#define MLY_BBU_STATUS_DISCHARGING 0x20
-#define MLY_BBU_STATUS_FASTCHARGING 0x40
- u_int8_t res2;
-} __attribute__ ((packed));
-
-/*
- * 28.9 MDACIOCTL_RESETDEVICE
- * 28.10 MDACIOCTL_FLUSHDEVICEDATA
- * 28.11 MDACIOCTL_PAUSEDEVICE
- * 28.12 MDACIOCTL_UNPAUSEDEVICE
- */
-struct mly_ioctl_param_deviceoperation {
- u_int8_t operation_device; /* see 14.3 */
-} __attribute__ ((packed));
-
-/*
- * 31.1 Event Data Format
- */
-struct mly_event {
- u_int32_t sequence_number;
- u_int32_t timestamp;
- u_int32_t code;
- u_int8_t controller;
- u_int8_t channel;
- u_int8_t target; /* also enclosure */
- u_int8_t lun; /* also enclosure unit */
- u_int8_t res1[4];
- u_int32_t param;
- u_int8_t sense[40];
-} __attribute__ ((packed));
-
-/*
- * 31.2 MDACIOCTL_GETEVENT
- */
-struct mly_ioctl_param_getevent {
- u_int16_t sequence_number_low;
- u_int8_t res1[8];
- union mly_command_transfer transfer;
-} __attribute__ ((packed));
-
-union mly_ioctl_param {
- struct mly_ioctl_param_data data;
- struct mly_ioctl_param_setmemorymailbox setmemorymailbox;
- struct mly_ioctl_param_setraiddevstate setraiddevstate;
- struct mly_ioctl_param_renameraiddev renameraiddev;
- struct mly_ioctl_param_xlatephysdevtoraiddev xlatephysdevtoraiddev;
- struct mly_ioctl_param_getgroupconfinfo getgroupconfinfo;
- struct mly_ioctl_param_subsystemdata subsystemdata;
- struct mly_ioctl_param_deviceoperation deviceoperation;
- struct mly_ioctl_param_getevent getevent;
-};
-
-/*
- * 19 SCSI Command Format
- */
-struct mly_command_address_physical {
- u_int8_t lun;
- u_int8_t target;
- u_int8_t channel:3;
- u_int8_t controller:5;
-} __attribute__ ((packed));
-
-struct mly_command_address_logical {
- u_int16_t logdev;
- u_int8_t res1:3;
- u_int8_t controller:5;
-} __attribute__ ((packed));
-
-union mly_command_address {
- struct mly_command_address_physical phys;
- struct mly_command_address_logical log;
-};
-
-struct mly_command_generic {
- u_int16_t command_id;
- u_int8_t opcode;
- struct mly_command_control command_control;
- u_int32_t data_size;
- u_int64_t sense_buffer_address;
- union mly_command_address addr;
- struct mly_timeout timeout;
- u_int8_t maximum_sense_size;
- u_int8_t res1[11];
- union mly_command_transfer transfer;
-} __attribute__ ((packed));
-
-
-/*
- * 19.1 MDACMD_SCSI & MDACMD_SCSIPT
- */
-#define MLY_CMD_SCSI_SMALL_CDB 10
-struct mly_command_scsi_small {
- u_int16_t command_id;
- u_int8_t opcode;
- struct mly_command_control command_control;
- u_int32_t data_size;
- u_int64_t sense_buffer_address;
- union mly_command_address addr;
- struct mly_timeout timeout;
- u_int8_t maximum_sense_size;
- u_int8_t cdb_length;
- u_int8_t cdb[MLY_CMD_SCSI_SMALL_CDB];
- union mly_command_transfer transfer;
-} __attribute__ ((packed));
-
-/*
- * 19.2 MDACMD_SCSILC & MDACMD_SCSILCPT
- */
-struct mly_command_scsi_large {
- u_int16_t command_id;
- u_int8_t opcode;
- struct mly_command_control command_control;
- u_int32_t data_size;
- u_int64_t sense_buffer_address;
- union mly_command_address addr;
- struct mly_timeout timeout;
- u_int8_t maximum_sense_size;
- u_int8_t cdb_length;
- u_int16_t res1;
- u_int64_t cdb_physaddr;
- union mly_command_transfer transfer;
-} __attribute__ ((packed));
-
-/*
- * 20.1 IOCTL Command Format: Internal Bus
- */
-struct mly_command_ioctl {
- u_int16_t command_id;
- u_int8_t opcode;
- struct mly_command_control command_control;
- u_int32_t data_size;
- u_int64_t sense_buffer_address;
- union mly_command_address addr;
- struct mly_timeout timeout;
- u_int8_t maximum_sense_size;
- u_int8_t sub_ioctl;
- union mly_ioctl_param param;
-} __attribute__ ((packed));
-
-/*
- * PG6: 8.2.2
- */
-struct mly_command_mmbox {
- u_int32_t flag;
- u_int8_t data[60];
-} __attribute__ ((packed));
-
-union mly_command_packet {
- struct mly_command_generic generic;
- struct mly_command_scsi_small scsi_small;
- struct mly_command_scsi_large scsi_large;
- struct mly_command_ioctl ioctl;
- struct mly_command_mmbox mmbox;
-};
-
-/*
- * PG6: 5.3
- */
-#define MLY_I960RX_COMMAND_MAILBOX 0x10
-#define MLY_I960RX_STATUS_MAILBOX 0x18
-#define MLY_I960RX_IDBR 0x20
-#define MLY_I960RX_ODBR 0x2c
-#define MLY_I960RX_ERROR_STATUS 0x2e
-#define MLY_I960RX_INTERRUPT_STATUS 0x30
-#define MLY_I960RX_INTERRUPT_MASK 0x34
-
-#define MLY_STRONGARM_COMMAND_MAILBOX 0x50
-#define MLY_STRONGARM_STATUS_MAILBOX 0x58
-#define MLY_STRONGARM_IDBR 0x60
-#define MLY_STRONGARM_ODBR 0x61
-#define MLY_STRONGARM_ERROR_STATUS 0x63
-#define MLY_STRONGARM_INTERRUPT_STATUS 0x30
-#define MLY_STRONGARM_INTERRUPT_MASK 0x34
-
-/*
- * PG6: 5.4.3 Doorbell 0
- */
-#define MLY_HM_CMDSENT (1<<0)
-#define MLY_HM_STSACK (1<<1)
-#define MLY_SOFT_RST (1<<3)
-#define MLY_AM_CMDSENT (1<<4)
-
-/*
- * PG6: 5.4.4 Doorbell 1
- *
- * Note that the documentation claims that these bits are set when the
- * status queue(s) are empty, wheras the Linux driver and experience
- * suggest they are set when there is status available.
- */
-#define MLY_HM_STSREADY (1<<0)
-#define MLY_AM_STSREADY (1<<1)
-
-/*
- * PG6: 5.4.6 Doorbell 3
- */
-#define MLY_MSG_EMPTY (1<<3)
-#define MLY_MSG_SPINUP 0x08
-#define MLY_MSG_RACE_RECOVERY_FAIL 0x60
-#define MLY_MSG_RACE_IN_PROGRESS 0x70
-#define MLY_MSG_RACE_ON_CRITICAL 0xb0
-#define MLY_MSG_PARITY_ERROR 0xf0
-
-/*
- * PG6: 5.4.8 Outbound Interrupt Mask
- */
-#define MLY_INTERRUPT_MASK_DISABLE 0xff
-#define MLY_INTERRUPT_MASK_ENABLE (0xff & ~(1<<2))
-
-/*
- * PG6: 8.2 Advanced Mailbox Scheme
- *
- * Note that this must be allocated on a 4k boundary, and all internal
- * fields must also reside on a 4k boundary.
- * We could dynamically size this structure, but the extra effort
- * is probably unjustified. Note that these buffers do not need to be
- * adjacent - we just group them to simplify allocation of the bus-visible
- * buffer.
- *
- * XXX Note that for some reason, if MLY_MMBOX_COMMANDS is > 64, the controller
- * fails to respond to the command at (MLY_MMBOX_COMMANDS - 64). It's not
- * wrapping to 0 at this point (determined by experimentation). This is not
- * consistent with the Linux driver's implementation.
- * Whilst it's handy to have lots of room for status returns in case we end up
- * being slow getting back to completed commands, it seems unlikely that we
- * would get 64 commands ahead of the controller on the submissions side, so
- * the current workaround is to simply limit the command ring to 64 entries.
- */
-union mly_status_packet {
- struct mly_status status;
- struct {
- u_int32_t flag;
- u_int8_t data[4];
- } __attribute__ ((packed)) mmbox;
-};
-union mly_health_region {
- struct mly_health_status status;
- u_int8_t pad[1024];
-};
-
-#define MLY_MMBOX_COMMANDS 64
-#define MLY_MMBOX_STATUS 512
-struct mly_mmbox {
- union mly_command_packet mmm_command[MLY_MMBOX_COMMANDS];
- union mly_status_packet mmm_status[MLY_MMBOX_STATUS];
- union mly_health_region mmm_health;
-} __attribute__ ((packed));
diff --git a/sys/dev/mly/mlyvar.h b/sys/dev/mly/mlyvar.h
deleted file mode 100644
index 00a9c9be1d3c1..0000000000000
--- a/sys/dev/mly/mlyvar.h
+++ /dev/null
@@ -1,423 +0,0 @@
-/*-
- * Copyright (c) 2000 Michael Smith
- * Copyright (c) 2000 BSDi
- * 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.
- *
- * 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$
- */
-
-/********************************************************************************
- ********************************************************************************
- Driver Parameter Definitions
- ********************************************************************************
- ********************************************************************************/
-
-/*
- * The firmware interface allows for a 16-bit command identifier. A lookup
- * table this size (256k) would be too expensive, so we cap ourselves at a
- * reasonable limit.
- */
-#define MLY_MAXCOMMANDS 256 /* max outstanding commands per controller, limit 65535 */
-
-/*
- * The firmware interface allows for a 16-bit s/g list length. We limit
- * ourselves to a reasonable maximum and ensure alignment.
- */
-#define MLY_MAXSGENTRIES 64 /* max S/G entries, limit 65535 */
-
-/********************************************************************************
- ********************************************************************************
- Driver Variable Definitions
- ********************************************************************************
- ********************************************************************************/
-
-#if __FreeBSD_version >= 500005
-# include <sys/taskqueue.h>
-#endif
-
-/*
- * Debugging levels:
- * 0 - quiet, only emit warnings
- * 1 - noisy, emit major function points and things done
- * 2 - extremely noisy, emit trace items in loops, etc.
- */
-#ifdef MLY_DEBUG
-# define debug(level, fmt, args...) do { if (level <= MLY_DEBUG) printf("%s: " fmt "\n", __FUNCTION__ , ##args); } while(0)
-# define debug_called(level) do { if (level <= MLY_DEBUG) printf(__FUNCTION__ ": called\n"); } while(0)
-# define debug_struct(s) printf(" SIZE %s: %d\n", #s, sizeof(struct s))
-# define debug_union(s) printf(" SIZE %s: %d\n", #s, sizeof(union s))
-# define debug_field(s, f) printf(" OFFSET %s.%s: %d\n", #s, #f, ((int)&(((struct s *)0)->f)))
-extern void mly_printstate0(void);
-extern struct mly_softc *mly_softc0;
-#else
-# define debug(level, fmt, args...)
-# define debug_called(level)
-# define debug_struct(s)
-#endif
-
-#define mly_printf(sc, fmt, args...) device_printf(sc->mly_dev, fmt , ##args)
-
-/*
- * Per-device structure, used to save persistent state on devices.
- *
- * Note that this isn't really Bus/Target/Lun since we don't support
- * lun != 0 at this time.
- */
-struct mly_btl {
- int mb_flags;
-#define MLY_BTL_PHYSICAL (1<<0) /* physical device */
-#define MLY_BTL_LOGICAL (1<<1) /* logical device */
-#define MLY_BTL_PROTECTED (1<<2) /* device is protected - I/O not allowed */
-#define MLY_BTL_RESCAN (1<<3) /* device needs to be rescanned */
- char mb_name[16]; /* peripheral attached to this device */
- int mb_state; /* see 8.1 */
- int mb_type; /* see 8.2 */
-};
-
-/*
- * Per-command control structure.
- */
-struct mly_command {
- TAILQ_ENTRY(mly_command) mc_link; /* list linkage */
-
- struct mly_softc *mc_sc; /* controller that owns us */
- u_int16_t mc_slot; /* command slot we occupy */
- int mc_flags;
-#define MLY_CMD_STATEMASK ((1<<8)-1)
-#define MLY_CMD_STATE(mc) ((mc)->mc_flags & MLY_CMD_STATEMASK)
-#define MLY_CMD_SETSTATE(mc, s) ((mc)->mc_flags = ((mc)->mc_flags &= ~MLY_CMD_STATEMASK) | (s))
-#define MLY_CMD_FREE 0 /* command is on the free list */
-#define MLY_CMD_SETUP 1 /* command is being built */
-#define MLY_CMD_BUSY 2 /* command is being run, or ready to run, or not completed */
-#define MLY_CMD_COMPLETE 3 /* command has been completed */
-#define MLY_CMD_SLOTTED (1<<8) /* command has a slot number */
-#define MLY_CMD_MAPPED (1<<9) /* command has had its data mapped */
-#define MLY_CMD_PRIORITY (1<<10) /* allow use of "priority" slots */
-#define MLY_CMD_DATAIN (1<<11) /* data moves controller->system */
-#define MLY_CMD_DATAOUT (1<<12) /* data moves system->controller */
- u_int16_t mc_status; /* command completion status */
- u_int8_t mc_sense; /* sense data length */
- int32_t mc_resid; /* I/O residual count */
-
- union mly_command_packet *mc_packet; /* our controller command */
- u_int64_t mc_packetphys; /* physical address of the mapped packet */
-
- void *mc_data; /* data buffer */
- size_t mc_length; /* data length */
- bus_dmamap_t mc_datamap; /* DMA map for data */
-
- void (* mc_complete)(struct mly_command *mc); /* completion handler */
- void *mc_private; /* caller-private data */
-
-};
-
-/*
- * Command slot regulation.
- *
- * We can't use slot 0 due to the memory mailbox implementation.
- */
-#define MLY_SLOT_START 1
-#define MLY_SLOT_MAX (MLY_SLOT_START + MLY_MAXCOMMANDS)
-
-/*
- * Command/command packet cluster.
- *
- * Due to the difficulty of using the zone allocator to create a new
- * zone from within a module, we use our own clustering to reduce
- * memory wastage caused by allocating lots of these small structures.
- *
- * Note that it is possible to require more than MLY_MAXCOMMANDS
- * command structures.
- *
- * Since we may need to allocate extra clusters at any time, and since this
- * process needs to allocate a physically contiguous slab of controller
- * addressible memory in which to place the command packets, do not allow more
- * command packets in a cluster than will fit in a page.
- */
-#define MLY_CMD_CLUSTERCOUNT (PAGE_SIZE / sizeof(union mly_command_packet))
-
-struct mly_command_cluster {
- TAILQ_ENTRY(mly_command_cluster) mcc_link;
- union mly_command_packet *mcc_packet;
- bus_dmamap_t mcc_packetmap;
- u_int64_t mcc_packetphys;
- struct mly_command mcc_command[MLY_CMD_CLUSTERCOUNT];
-};
-
-/*
- * Per-controller structure.
- */
-struct mly_softc {
- /* bus connections */
- device_t mly_dev;
- struct resource *mly_regs_resource; /* register interface window */
- int mly_regs_rid; /* resource ID */
- bus_space_handle_t mly_bhandle; /* bus space handle */
- bus_space_tag_t mly_btag; /* bus space tag */
- bus_dma_tag_t mly_parent_dmat; /* parent DMA tag */
- bus_dma_tag_t mly_buffer_dmat; /* data buffer/command DMA tag */
- struct resource *mly_irq; /* interrupt */
- int mly_irq_rid;
- void *mly_intr; /* interrupt handle */
-
- /* scatter/gather lists and their controller-visible mappings */
- struct mly_sg_entry *mly_sg_table; /* s/g lists */
- u_int32_t mly_sg_busaddr; /* s/g table base address in bus space */
- bus_dma_tag_t mly_sg_dmat; /* s/g buffer DMA tag */
- bus_dmamap_t mly_sg_dmamap; /* map for s/g buffers */
-
- /* controller hardware interface */
- int mly_hwif;
-#define MLY_HWIF_I960RX 0
-#define MLY_HWIF_STRONGARM 1
- u_int8_t mly_doorbell_true; /* xor map to make hardware doorbell 'true' bits into 1s */
- u_int8_t mly_command_mailbox; /* register offsets */
- u_int8_t mly_status_mailbox;
- u_int8_t mly_idbr;
- u_int8_t mly_odbr;
- u_int8_t mly_error_status;
- u_int8_t mly_interrupt_status;
- u_int8_t mly_interrupt_mask;
- struct mly_mmbox *mly_mmbox; /* kernel-space address of memory mailbox */
- u_int64_t mly_mmbox_busaddr; /* bus-space address of memory mailbox */
- bus_dma_tag_t mly_mmbox_dmat; /* memory mailbox DMA tag */
- bus_dmamap_t mly_mmbox_dmamap; /* memory mailbox DMA map */
- u_int32_t mly_mmbox_command_index; /* next slot to use */
- u_int32_t mly_mmbox_status_index; /* slot we next expect status in */
-
- /* controller features, limits and status */
- int mly_state;
-#define MLY_STATE_SUSPEND (1<<0)
-#define MLY_STATE_OPEN (1<<1)
-#define MLY_STATE_INTERRUPTS_ON (1<<2)
-#define MLY_STATE_MMBOX_ACTIVE (1<<3)
- int mly_max_commands; /* max parallel commands we allow */
- struct mly_ioctl_getcontrollerinfo *mly_controllerinfo;
- struct mly_param_controller *mly_controllerparam;
- struct mly_btl mly_btl[MLY_MAX_CHANNELS][MLY_MAX_TARGETS];
-
- /* command management */
- struct mly_command *mly_busycmds[MLY_SLOT_MAX]; /* busy commands */
- int mly_busy_count;
- int mly_last_slot;
- TAILQ_HEAD(,mly_command) mly_freecmds; /* commands available for reuse */
- TAILQ_HEAD(,mly_command) mly_ready; /* commands ready to be submitted */
- TAILQ_HEAD(,mly_command) mly_completed; /* commands which have been returned by the controller */
- TAILQ_HEAD(,mly_command_cluster) mly_clusters; /* command memory blocks */
- bus_dma_tag_t mly_packet_dmat; /* command packet DMA tag */
-
- /* health monitoring */
- u_int32_t mly_event_change; /* event status change indicator */
- u_int32_t mly_event_counter; /* next event for which we anticpiate status */
- u_int32_t mly_event_waiting; /* next event the controller will post status for */
- struct callout_handle mly_periodic; /* periodic event handling */
-
- /* CAM connection */
- TAILQ_HEAD(,ccb_hdr) mly_cam_ccbq; /* outstanding I/O from CAM */
- struct cam_sim *mly_cam_sim[MLY_MAX_CHANNELS];
- int mly_cam_lowbus;
-
-#if __FreeBSD_version >= 500005
- /* command-completion task */
- struct task mly_task_complete; /* deferred-completion task */
-#endif
-};
-
-/*
- * Register access helpers.
- */
-#define MLY_SET_REG(sc, reg, val) bus_space_write_1(sc->mly_btag, sc->mly_bhandle, reg, val)
-#define MLY_GET_REG(sc, reg) bus_space_read_1 (sc->mly_btag, sc->mly_bhandle, reg)
-#define MLY_GET_REG2(sc, reg) bus_space_read_2 (sc->mly_btag, sc->mly_bhandle, reg)
-#define MLY_GET_REG4(sc, reg) bus_space_read_4 (sc->mly_btag, sc->mly_bhandle, reg)
-
-#define MLY_SET_MBOX(sc, mbox, ptr) \
- do { \
- bus_space_write_4(sc->mly_btag, sc->mly_bhandle, mbox, *((u_int32_t *)ptr)); \
- bus_space_write_4(sc->mly_btag, sc->mly_bhandle, mbox + 4, *((u_int32_t *)ptr + 1)); \
- bus_space_write_4(sc->mly_btag, sc->mly_bhandle, mbox + 8, *((u_int32_t *)ptr + 2)); \
- bus_space_write_4(sc->mly_btag, sc->mly_bhandle, mbox + 12, *((u_int32_t *)ptr + 3)); \
- } while(0);
-#define MLY_GET_MBOX(sc, mbox, ptr) \
- do { \
- *((u_int32_t *)ptr) = bus_space_read_4(sc->mly_btag, sc->mly_bhandle, mbox); \
- *((u_int32_t *)ptr + 1) = bus_space_read_4(sc->mly_btag, sc->mly_bhandle, mbox + 4); \
- *((u_int32_t *)ptr + 2) = bus_space_read_4(sc->mly_btag, sc->mly_bhandle, mbox + 8); \
- *((u_int32_t *)ptr + 3) = bus_space_read_4(sc->mly_btag, sc->mly_bhandle, mbox + 12); \
- } while(0);
-
-#define MLY_IDBR_TRUE(sc, mask) \
- ((((MLY_GET_REG((sc), (sc)->mly_idbr)) ^ (sc)->mly_doorbell_true) & (mask)) == (mask))
-#define MLY_ODBR_TRUE(sc, mask) \
- ((MLY_GET_REG((sc), (sc)->mly_odbr) & (mask)) == (mask))
-#define MLY_ERROR_VALID(sc) \
- ((((MLY_GET_REG((sc), (sc)->mly_error_status)) ^ (sc)->mly_doorbell_true) & (MLY_MSG_EMPTY)) == 0)
-
-#define MLY_MASK_INTERRUPTS(sc) \
- do { \
- MLY_SET_REG((sc), (sc)->mly_interrupt_mask, MLY_INTERRUPT_MASK_DISABLE); \
- sc->mly_state &= ~MLY_STATE_INTERRUPTS_ON; \
- } while(0);
-#define MLY_UNMASK_INTERRUPTS(sc) \
- do { \
- MLY_SET_REG((sc), (sc)->mly_interrupt_mask, MLY_INTERRUPT_MASK_ENABLE); \
- sc->mly_state |= MLY_STATE_INTERRUPTS_ON; \
- } while(0);
-
-/*
- * Logical device number -> bus/target translation
- */
-#define MLY_LOGDEV_BUS(sc, x) (((x) / MLY_MAX_TARGETS) + (sc)->mly_controllerinfo->physical_channels_present)
-#define MLY_LOGDEV_TARGET(x) ((x) % MLY_MAX_TARGETS)
-
-/*
- * Public functions/variables
- */
-/* mly.c */
-extern int mly_attach(struct mly_softc *sc);
-extern void mly_detach(struct mly_softc *sc);
-extern void mly_free(struct mly_softc *sc);
-extern void mly_startio(struct mly_softc *sc);
-extern void mly_done(struct mly_softc *sc);
-extern int mly_alloc_command(struct mly_softc *sc, struct mly_command **mcp);
-extern void mly_release_command(struct mly_command *mc);
-
-/* mly_cam.c */
-extern int mly_cam_attach(struct mly_softc *sc);
-extern void mly_cam_detach(struct mly_softc *sc);
-extern int mly_cam_command(struct mly_softc *sc, struct mly_command **mcp);
-extern int mly_name_device(struct mly_softc *sc, int bus, int target);
-
-/********************************************************************************
- * Queue primitives
- *
- * These are broken out individually to make statistics gathering easier.
- */
-
-static __inline void
-mly_enqueue_ready(struct mly_command *mc)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_TAIL(&mc->mc_sc->mly_ready, mc, mc_link);
- MLY_CMD_SETSTATE(mc, MLY_CMD_BUSY);
- splx(s);
-}
-
-static __inline void
-mly_requeue_ready(struct mly_command *mc)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_HEAD(&mc->mc_sc->mly_ready, mc, mc_link);
- splx(s);
-}
-
-static __inline struct mly_command *
-mly_dequeue_ready(struct mly_softc *sc)
-{
- struct mly_command *mc;
- int s;
-
- s = splcam();
- if ((mc = TAILQ_FIRST(&sc->mly_ready)) != NULL)
- TAILQ_REMOVE(&sc->mly_ready, mc, mc_link);
- splx(s);
- return(mc);
-}
-
-static __inline void
-mly_enqueue_completed(struct mly_command *mc)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_TAIL(&mc->mc_sc->mly_completed, mc, mc_link);
- /* don't set MLY_CMD_COMPLETE here to avoid wakeup race */
- splx(s);
-}
-
-static __inline struct mly_command *
-mly_dequeue_completed(struct mly_softc *sc)
-{
- struct mly_command *mc;
- int s;
-
- s = splcam();
- if ((mc = TAILQ_FIRST(&sc->mly_completed)) != NULL)
- TAILQ_REMOVE(&sc->mly_completed, mc, mc_link);
- splx(s);
- return(mc);
-}
-
-static __inline void
-mly_enqueue_free(struct mly_command *mc)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_HEAD(&mc->mc_sc->mly_freecmds, mc, mc_link);
- MLY_CMD_SETSTATE(mc, MLY_CMD_FREE);
- splx(s);
-}
-
-static __inline struct mly_command *
-mly_dequeue_free(struct mly_softc *sc)
-{
- struct mly_command *mc;
- int s;
-
- s = splcam();
- if ((mc = TAILQ_FIRST(&sc->mly_freecmds)) != NULL)
- TAILQ_REMOVE(&sc->mly_freecmds, mc, mc_link);
- splx(s);
- return(mc);
-}
-
-static __inline void
-mly_enqueue_cluster(struct mly_softc *sc, struct mly_command_cluster *mcc)
-{
- int s;
-
- s = splcam();
- TAILQ_INSERT_HEAD(&sc->mly_clusters, mcc, mcc_link);
- splx(s);
-}
-
-static __inline struct mly_command_cluster *
-mly_dequeue_cluster(struct mly_softc *sc)
-{
- struct mly_command_cluster *mcc;
- int s;
-
- s = splcam();
- if ((mcc = TAILQ_FIRST(&sc->mly_clusters)) != NULL)
- TAILQ_REMOVE(&sc->mly_clusters, mcc, mcc_link);
- splx(s);
- return(mcc);
-}
-
-
diff --git a/sys/dev/rp/rpreg.h b/sys/dev/rp/rpreg.h
deleted file mode 100644
index a7cde1b03a257..0000000000000
--- a/sys/dev/rp/rpreg.h
+++ /dev/null
@@ -1,1015 +0,0 @@
-/*
- * Copyright (c) Comtrol Corporation <support@comtrol.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted prodived that the follwoing conditions
- * are met.
- * 1. Redistributions of source code must retain the above copyright
- * notive, this list of conditions and the following disclainer.
- * 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 prodided 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 Comtrol Corporation.
- * 4. The name of Comtrol Corporation may not be used to endorse or
- * promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY COMTROL CORPORATION ``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 COMTROL CORPORATION 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, LIFE 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$
- */
-
-/*
- * Begin OS-specific defines - rpreg.h - for RocketPort FreeBSD
- */
-
-typedef unsigned char Byte_t;
-typedef unsigned int ByteIO_t;
-
-typedef unsigned int Word_t;
-typedef unsigned int WordIO_t;
-
-typedef unsigned long DWord_t;
-typedef unsigned int DWordIO_t;
-
-#define rp_readio(size, ctlp, rid, offset) \
- (bus_space_read_##size(rman_get_bustag(ctlp->io[rid]), rman_get_bushandle(ctlp->io[rid]), offset))
-#define rp_readmultiio(size, ctlp, rid, offset, addr, count) \
- (bus_space_read_multi_##size(rman_get_bustag(ctlp->io[rid]), rman_get_bushandle(ctlp->io[rid]), offset, addr, count))
-#define rp_writeio(size, ctlp, rid, offset, data) \
- (bus_space_write_##size(rman_get_bustag(ctlp->io[rid]), rman_get_bushandle(ctlp->io[rid]), offset, data))
-#define rp_writemultiio(size, ctlp, rid, offset, addr, count) \
- (bus_space_write_multi_##size(rman_get_bustag(ctlp->io[rid]), rman_get_bushandle(ctlp->io[rid]), offset, addr, count))
-
-#define rp_readio1(ctlp, rid, offset) rp_readio(1, ctlp, rid, offset)
-#define rp_readio2(ctlp, rid, offset) rp_readio(2, ctlp, rid, offset)
-#define rp_readio4(ctlp, rid, offset) rp_readio(4, ctlp, rid, offset)
-#define rp_writeio1(ctlp, rid, offset, data) rp_writeio(1, ctlp, rid, offset, data)
-#define rp_writeio2(ctlp, rid, offset, data) rp_writeio(2, ctlp, rid, offset, data)
-#define rp_writeio4(ctlp, rid, offset, data) rp_writeio(4, ctlp, rid, offset, data)
-#define rp_readmultiio1(ctlp, rid, offset, addr, count) rp_readmultiio(1, ctlp, rid, offset, addr, count)
-#define rp_readmultiio2(ctlp, rid, offset, addr, count) rp_readmultiio(2, ctlp, rid, offset, addr, count)
-#define rp_readmultiio4(ctlp, rid, offset, addr, count) rp_readmultiio(4, ctlp, rid, offset, addr, count)
-#define rp_writemultiio1(ctlp, rid, offset, addr, count) rp_writemultiio(1, ctlp, rid, offset, addr, count)
-#define rp_writemultiio2(ctlp, rid, offset, addr, count) rp_writemultiio(2, ctlp, rid, offset, addr, count)
-#define rp_writemultiio4(ctlp, rid, offset, addr, count) rp_writemultiio(4, ctlp, rid, offset, addr, count)
-
-#define rp_readaiop1(ctlp, aiop, offset) \
- (rp_readio1((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset)))
-#define rp_readaiop2(ctlp, aiop, offset) \
- (rp_readio2((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset)))
-#define rp_readaiop4(ctlp, aiop, offset) \
- (rp_readio4((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset)))
-#define rp_readmultiaiop1(ctlp, aiop, offset, addr, count) \
- (rp_readmultiio1((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), addr, count))
-#define rp_readmultiaiop2(ctlp, aiop, offset, addr, count) \
- (rp_readmultiio2((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), addr, count))
-#define rp_readmultiaiop4(ctlp, aiop, offset, addr, count) \
- (rp_readmultiio4((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), addr, count))
-#define rp_writeaiop1(ctlp, aiop, offset, data) \
- (rp_writeio1((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), data))
-#define rp_writeaiop2(ctlp, aiop, offset, data) \
- (rp_writeio2((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), data))
-#define rp_writeaiop4(ctlp, aiop, offset, data) \
- (rp_writeio4((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), data))
-#define rp_writemultiaiop1(ctlp, aiop, offset, addr, count) \
- (rp_writemultiio1((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), addr, count))
-#define rp_writemultiaiop2(ctlp, aiop, offset, addr, count) \
- (rp_writemultiio2((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), addr, count))
-#define rp_writemultiaiop4(ctlp, aiop, offset, addr, count) \
- (rp_writemultiio4((ctlp), (ctlp)->aiop2rid(aiop, offset), (ctlp)->aiop2off(aiop, offset), addr, count))
-
-#define rp_readch1(chp, offset) \
- (rp_readaiop1((chp)->CtlP, (chp)->AiopNum, offset))
-#define rp_readch2(chp, offset) \
- (rp_readaiop2((chp)->CtlP, (chp)->AiopNum, offset))
-#define rp_readch4(chp, offset) \
- (rp_readaiop4((chp)->CtlP, (chp)->AiopNum, offset))
-#define rp_readmultich1(chp, offset, addr, count) \
- (rp_readmultiaiop1((chp)->CtlP, (chp)->AiopNum, offset, addr, count))
-#define rp_readmultich2(chp, offset, addr, count) \
- (rp_readmultiaiop2((chp)->CtlP, (chp)->AiopNum, offset, addr, count))
-#define rp_readmultich4(chp, offset, addr, count) \
- (rp_readmultiaiop4((chp)->CtlP, (chp)->AiopNum, offset, addr, count))
-#define rp_writech1(chp, offset, data) \
- (rp_writeaiop1((chp)->CtlP, (chp)->AiopNum, offset, data))
-#define rp_writech2(chp, offset, data) \
- (rp_writeaiop2((chp)->CtlP, (chp)->AiopNum, offset, data))
-#define rp_writech4(chp, offset, data) \
- (rp_writeaiop4((chp)->CtlP, (chp)->AiopNum, offset, data))
-#define rp_writemultich1(chp, offset, addr, count) \
- (rp_writemultiaiop1((chp)->CtlP, (chp)->AiopNum, offset, addr, count))
-#define rp_writemultich2(chp, offset, addr, count) \
- (rp_writemultiaiop2((chp)->CtlP, (chp)->AiopNum, offset, addr, count))
-#define rp_writemultich4(chp, offset, addr, count) \
- (rp_writemultiaiop4((chp)->CtlP, (chp)->AiopNum, offset, addr, count))
-
-/*
- * End of OS-specific defines
- */
-
-#define ROCKET_H
-
-#define CTL_SIZE 4
-#define AIOP_CTL_SIZE 4
-#define CHAN_AIOP_SIZE 8
-#define MAX_PORTS_PER_AIOP 8
-#define MAX_AIOPS_PER_BOARD 4
-#define MAX_PORTS_PER_BOARD 32
-
-/* Controller ID numbers */
-#define CTLID_NULL -1 /* no controller exists */
-#define CTLID_0001 0x0001 /* controller release 1 */
-
-/* AIOP ID numbers, identifies AIOP type implementing channel */
-#define AIOPID_NULL -1 /* no AIOP or channel exists */
-#define AIOPID_0001 0x0001 /* AIOP release 1 */
-
-#define NULLDEV -1 /* identifies non-existant device */
-#define NULLCTL -1 /* identifies non-existant controller */
-#define NULLCTLPTR (CONTROLLER_T *)0 /* identifies non-existant controller */
-#define NULLAIOP -1 /* identifies non-existant AIOP */
-#define NULLCHAN -1 /* identifies non-existant channel */
-
-/************************************************************************
- Global Register Offsets - Direct Access - Fixed values
-************************************************************************/
-
-#define _CMD_REG 0x38 /* Command Register 8 Write */
-#define _INT_CHAN 0x39 /* Interrupt Channel Register 8 Read */
-#define _INT_MASK 0x3A /* Interrupt Mask Register 8 Read / Write */
-#define _UNUSED 0x3B /* Unused 8 */
-#define _INDX_ADDR 0x3C /* Index Register Address 16 Write */
-#define _INDX_DATA 0x3E /* Index Register Data 8/16 Read / Write */
-
-/************************************************************************
- Channel Register Offsets for 1st channel in AIOP - Direct Access
-************************************************************************/
-#define _TD0 0x00 /* Transmit Data 16 Write */
-#define _RD0 0x00 /* Receive Data 16 Read */
-#define _CHN_STAT0 0x20 /* Channel Status 8/16 Read / Write */
-#define _FIFO_CNT0 0x10 /* Transmit/Receive FIFO Count 16 Read */
-#define _INT_ID0 0x30 /* Interrupt Identification 8 Read */
-
-/************************************************************************
- Tx Control Register Offsets - Indexed - External - Fixed
-************************************************************************/
-#define _TX_ENBLS 0x980 /* Tx Processor Enables Register 8 Read / Write */
-#define _TXCMP1 0x988 /* Transmit Compare Value #1 8 Read / Write */
-#define _TXCMP2 0x989 /* Transmit Compare Value #2 8 Read / Write */
-#define _TXREP1B1 0x98A /* Tx Replace Value #1 - Byte 1 8 Read / Write */
-#define _TXREP1B2 0x98B /* Tx Replace Value #1 - Byte 2 8 Read / Write */
-#define _TXREP2 0x98C /* Transmit Replace Value #2 8 Read / Write */
-
-/************************************************************************
- Receive FIFO
-************************************************************************/
-#define RXFIFO_DATA 0x5f
-#define RXFIFO_OUT 0x5c
-#define RXFIFO_EN 0x08
-#define RXFIFO_DIS 0xa7
-
-/************************************************************************
-Memory Controller Register Offsets - Indexed - External - Fixed
-************************************************************************/
-#define _RX_FIFO 0x000 /* Rx FIFO */
-#define _TX_FIFO 0x800 /* Tx FIFO */
-#define _RXF_OUTP 0x990 /* Rx FIFO OUT pointer 16 Read / Write */
-#define _RXF_INP 0x992 /* Rx FIFO IN pointer 16 Read / Write */
-#define _TXF_OUTP 0x994 /* Tx FIFO OUT pointer 8 Read / Write */
-#define _TXF_INP 0x995 /* Tx FIFO IN pointer 8 Read / Write */
-#define _TXP_CNT 0x996 /* Tx Priority Count 8 Read / Write */
-#define _TXP_PNTR 0x997 /* Tx Priority Pointer 8 Read / Write */
-
-#define PRI_PEND 0x80 /* Priority data pending (bit7, Tx pri cnt) */
-#define TXFIFO_SIZE 255 /* size of Tx FIFO */
-#define RXFIFO_SIZE 1023 /* size of Rx FIFO */
-
-/************************************************************************
-Tx Priority Buffer - Indexed - External - Fixed
-************************************************************************/
-#define _TXP_BUF 0x9C0 /* Tx Priority Buffer 32 Bytes Read / Write */
-#define TXP_SIZE 0x20 /* 32 bytes */
-
-/************************************************************************
-Channel Register Offsets - Indexed - Internal - Fixed
-************************************************************************/
-
-#define _TX_CTRL 0xFF0 /* Transmit Control 16 Write */
-#define _RX_CTRL 0xFF2 /* Receive Control 8 Write */
-#define _BAUD 0xFF4 /* Baud Rate 16 Write */
-#define _CLK_PRE 0xFF6 /* Clock Prescaler 8 Write */
-
-#define CLOCK_PRESC 0x19 /* mod 9 (divide by 10) prescale */
-
-#define BRD50 4607
-#define BRD75 3071
-#define BRD110 2094
-#define BRD134 1712
-#define BRD150 1535
-#define BRD200 1151
-#define BRD300 767
-#define BRD600 383
-#define BRD1200 191
-#define BRD1800 127
-#define BRD2000 114
-#define BRD2400 95
-#define BRD3600 64
-#define BRD4800 47
-#define BRD7200 31
-#define BRD9600 23
-#define BRD14400 15
-#define BRD19200 11
-#define BRD38400 5
-#define BRD57600 3
-#define BRD76800 2
-#define BRD115200 1
-#define BRD230400 0
-
-#define STMBREAK 0x08 /* BREAK */
-#define STMFRAME 0x04 /* framing error */
-#define STMRCVROVR 0x02 /* receiver over run error */
-#define STMPARITY 0x01 /* parity error */
-#define STMERROR (STMBREAK | STMFRAME | STMPARITY)
-#define STMBREAKH 0x800 /* BREAK */
-#define STMFRAMEH 0x400 /* framing error */
-#define STMRCVROVRH 0x200 /* receiver over run error */
-#define STMPARITYH 0x100 /* parity error */
-#define STMERRORH (STMBREAKH | STMFRAMEH | STMPARITYH)
-
-#define CTS_ACT 0x20 /* CTS input asserted */
-#define DSR_ACT 0x10 /* DSR input asserted */
-#define CD_ACT 0x08 /* CD input asserted */
-#define TXFIFOMT 0x04 /* Tx FIFO is empty */
-#define TXSHRMT 0x02 /* Tx shift register is empty */
-#define RDA 0x01 /* Rx data available */
-#define DRAINED (TXFIFOMT | TXSHRMT) /* indicates Tx is drained */
-
-#define STATMODE 0x8000 /* status mode enable bit */
-#define RXFOVERFL 0x2000 /* receive FIFO overflow */
-#define RX2MATCH 0x1000 /* receive compare byte 2 match */
-#define RX1MATCH 0x0800 /* receive compare byte 1 match */
-#define RXBREAK 0x0400 /* received BREAK */
-#define RXFRAME 0x0200 /* received framing error */
-#define RXPARITY 0x0100 /* received parity error */
-#define STATERROR (RXBREAK | RXFRAME | RXPARITY)
-
-#define CTSFC_EN 0x80 /* CTS flow control enable bit */
-#define RTSTOG_EN 0x40 /* RTS toggle enable bit */
-#define TXINT_EN 0x10 /* transmit interrupt enable */
-#define STOP2 0x08 /* enable 2 stop bits (0 = 1 stop) */
-#define PARITY_EN 0x04 /* enable parity (0 = no parity) */
-#define EVEN_PAR 0x02 /* even parity (0 = odd parity) */
-#define DATA8BIT 0x01 /* 8 bit data (0 = 7 bit data) */
-
-#define SETBREAK 0x10 /* send break condition (must clear) */
-#define LOCALLOOP 0x08 /* local loopback set for test */
-#define SET_DTR 0x04 /* assert DTR */
-#define SET_RTS 0x02 /* assert RTS */
-#define TX_ENABLE 0x01 /* enable transmitter */
-
-#define RTSFC_EN 0x40 /* RTS flow control enable */
-#define RXPROC_EN 0x20 /* receive processor enable */
-#define TRIG_NO 0x00 /* Rx FIFO trigger level 0 (no trigger) */
-#define TRIG_1 0x08 /* trigger level 1 char */
-#define TRIG_1_2 0x10 /* trigger level 1/2 */
-#define TRIG_7_8 0x18 /* trigger level 7/8 */
-#define TRIG_MASK 0x18 /* trigger level mask */
-#define SRCINT_EN 0x04 /* special Rx condition interrupt enable */
-#define RXINT_EN 0x02 /* Rx interrupt enable */
-#define MCINT_EN 0x01 /* modem change interrupt enable */
-
-#define RXF_TRIG 0x20 /* Rx FIFO trigger level interrupt */
-#define TXFIFO_MT 0x10 /* Tx FIFO empty interrupt */
-#define SRC_INT 0x08 /* special receive condition interrupt */
-#define DELTA_CD 0x04 /* CD change interrupt */
-#define DELTA_CTS 0x02 /* CTS change interrupt */
-#define DELTA_DSR 0x01 /* DSR change interrupt */
-
-#define REP1W2_EN 0x10 /* replace byte 1 with 2 bytes enable */
-#define IGN2_EN 0x08 /* ignore byte 2 enable */
-#define IGN1_EN 0x04 /* ignore byte 1 enable */
-#define COMP2_EN 0x02 /* compare byte 2 enable */
-#define COMP1_EN 0x01 /* compare byte 1 enable */
-
-#define RESET_ALL 0x80 /* reset AIOP (all channels) */
-#define TXOVERIDE 0x40 /* Transmit software off override */
-#define RESETUART 0x20 /* reset channel's UART */
-#define RESTXFCNT 0x10 /* reset channel's Tx FIFO count register */
-#define RESRXFCNT 0x08 /* reset channel's Rx FIFO count register */
-
-#define INTSTAT0 0x01 /* AIOP 0 interrupt status */
-#define INTSTAT1 0x02 /* AIOP 1 interrupt status */
-#define INTSTAT2 0x04 /* AIOP 2 interrupt status */
-#define INTSTAT3 0x08 /* AIOP 3 interrupt status */
-
-#define INTR_EN 0x08 /* allow interrupts to host */
-#define INT_STROB 0x04 /* strobe and clear interrupt line (EOI) */
-
-#define CHAN3_EN 0x08 /* enable AIOP 3 */
-#define CHAN2_EN 0x04 /* enable AIOP 2 */
-#define CHAN1_EN 0x02 /* enable AIOP 1 */
-#define CHAN0_EN 0x01 /* enable AIOP 0 */
-#define FREQ_DIS 0x00
-#define FREQ_274HZ 0x60
-#define FREQ_137HZ 0x50
-#define FREQ_69HZ 0x40
-#define FREQ_34HZ 0x30
-#define FREQ_17HZ 0x20
-#define FREQ_9HZ 0x10
-#define PERIODIC_ONLY 0x80 /* only PERIODIC interrupt */
-
-#define CHANINT_EN 0x0100 /* flags to enable/disable channel ints */
-
-#define RDATASIZE 72
-#define RREGDATASIZE 52
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-struct CONTROLLER_str;
-struct CHANNEL_str;
-
-/* The types of bus-specific methods */
-typedef int rp_aiop2rid_t(int, int);
-typedef int rp_aiop2off_t(int, int);
-typedef unsigned char rp_ctlmask_t(struct CONTROLLER_str *);
-
-/* Controller level information structure */
-struct CONTROLLER_str
-{
- int CtlID;
- int NumAiop;
- int AiopID[AIOP_CTL_SIZE];
- int AiopNumChan[AIOP_CTL_SIZE];
-
- /* Device and resource management */
- device_t dev; /* device */
- int io_num; /* Number of IO resources */
- int *io_rid; /* IO resource IDs */
- struct resource **io; /* IO resources */
-
- struct rp_port *rp; /* port */
- struct tty *tty; /* tty */
-
- /* Device nodes */
- dev_t *dev_nodes;
-
- /* Bus-specific properties */
- void *bus_ctlp;
-
- /* Bus-specific methods */
- rp_aiop2rid_t *aiop2rid; /* (aiop, offset) -> rid */
- rp_aiop2off_t *aiop2off; /* (aiop, offset) -> off */
- rp_ctlmask_t *ctlmask; /* Int status */
-};
-typedef struct CONTROLLER_str CONTROLLER_T;
-typedef CONTROLLER_T CONTROLLER_t;
-
-/* Channel level information structure */
-struct CHANNEL_str
-{
- CONTROLLER_t *CtlP;
- int AiopNum;
- int ChanID;
- int ChanNum;
-
- Word_t TxFIFO;
- Word_t TxFIFOPtrs;
- Word_t RxFIFO;
- Word_t RxFIFOPtrs;
- Word_t TxPrioCnt;
- Word_t TxPrioPtr;
- Word_t TxPrioBuf;
-
- Byte_t R[RREGDATASIZE];
-
- Byte_t BaudDiv[4];
- Byte_t TxControl[4];
- Byte_t RxControl[4];
- Byte_t TxEnables[4];
- Byte_t TxCompare[4];
- Byte_t TxReplace1[4];
- Byte_t TxReplace2[4];
-};
-
-typedef struct CHANNEL_str CHANNEL_T;
-typedef CHANNEL_T CHANNEL_t;
-typedef CHANNEL_T * CHANPTR_T;
-
-#define CHNOFF_TXRXDATA(chp) ((chp)->ChanNum * 2 + _TD0)
-#define CHNOFF_CHANSTAT(chp) ((chp)->ChanNum * 2 + _CHN_STAT0)
-#define CHNOFF_TXRXCOUNT(chp) ((chp)->ChanNum * 2 + _FIFO_CNT0)
-#define CHNOFF_INTID(chp) ((chp)->ChanNum + _INT_ID0)
-
-/***************************************************************************
-Function: sClrBreak
-Purpose: Stop sending a transmit BREAK signal
-Call: sClrBreak(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrBreak(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~SETBREAK; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sClrDTR
-Purpose: Clr the DTR output
-Call: sClrDTR(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrDTR(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~SET_DTR; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sClrRTS
-Purpose: Clr the RTS output
-Call: sClrRTS(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrRTS(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~SET_RTS; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sClrTxXOFF
-Purpose: Clear any existing transmit software flow control off condition
-Call: sClrTxXOFF(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrTxXOFF(ChP) \
-{ \
- rp_writech1(ChP,_CMD_REG,TXOVERIDE | (Byte_t)(ChP)->ChanNum); \
- rp_writech1(ChP,_CMD_REG,(Byte_t)(ChP)->ChanNum); \
-}
-
-/***************************************************************************
-Function: sDisCTSFlowCtl
-Purpose: Disable output flow control using CTS
-Call: sDisCTSFlowCtl(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sDisCTSFlowCtl(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~CTSFC_EN; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: DisParity
-Purpose: Disable parity
-Call: sDisParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-*/
-#define sDisParity(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~PARITY_EN; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sDisRxFIFO
-Purpose: Disable Rx FIFO
-Call: sDisRxFIFO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sDisRxFIFO(ChP) \
-{ \
- (ChP)->R[0x32] = 0x0a; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->R[0x30]); \
-}
-
-/***************************************************************************
-Function: sDisRxStatusMode
-Purpose: Disable the Rx status mode
-Call: sDisRxStatusMode(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This takes the channel out of the receive status mode. All
- subsequent reads of receive data using sReadRxWord() will return
- two data bytes.
-*/
-#define sDisRxStatusMode(ChP) rp_writech2(ChP,CHNOFF_CHANSTAT(ChP),0)
-
-/***************************************************************************
-Function: sDisTransmit
-Purpose: Disable transmit
-Call: sDisTransmit(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
- This disables movement of Tx data from the Tx FIFO into the 1 byte
- Tx buffer. Therefore there could be up to a 2 byte latency
- between the time sDisTransmit() is called and the transmit buffer
- and transmit shift register going completely empty.
-*/
-#define sDisTransmit(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~TX_ENABLE; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sDisTxSoftFlowCtl
-Purpose: Disable Tx Software Flow Control
-Call: sDisTxSoftFlowCtl(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sDisTxSoftFlowCtl(ChP) \
-{ \
- (ChP)->R[0x06] = 0x8a; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->R[0x04]); \
-}
-
-/***************************************************************************
-Function: sEnCTSFlowCtl
-Purpose: Enable output flow control using CTS
-Call: sEnCTSFlowCtl(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sEnCTSFlowCtl(ChP) \
-{ \
- (ChP)->TxControl[2] |= CTSFC_EN; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: EnParity
-Purpose: Enable parity
-Call: sEnParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-
-Warnings: Before enabling parity odd or even parity should be chosen using
- functions sSetOddParity() or sSetEvenParity().
-*/
-#define sEnParity(ChP) \
-{ \
- (ChP)->TxControl[2] |= PARITY_EN; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sEnRTSFlowCtl
-Return: void
-*/
-#define sEnRTSFlowCtl(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~RTSTOG_EN; \
- (ChP)->TxControl[3] &= ~SET_RTS; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
- (ChP)->RxControl[2] |= RTSFC_EN; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sDisRTSFlowCtl
-Return: void
-*/
-#define sDisRTSFlowCtl(ChP) \
-{ \
- (ChP)->RxControl[2] &= ~RTSFC_EN; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sEnRxFIFO
-Purpose: Enable Rx FIFO
-Call: sEnRxFIFO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sEnRxFIFO(ChP) \
-{ \
- (ChP)->R[0x32] = 0x08; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->R[0x30]); \
-}
-
-/***************************************************************************
-Function: sEnRxProcessor
-Purpose: Enable the receive processor
-Call: sEnRxProcessor(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This function is used to start the receive processor. When
- the channel is in the reset state the receive processor is not
- running. This is done to prevent the receive processor from
- executing invalid microcode instructions prior to the
- downloading of the microcode.
-
-Warnings: This function must be called after valid microcode has been
- downloaded to the AIOP, and it must not be called before the
- microcode has been downloaded.
-*/
-#define sEnRxProcessor(ChP) \
-{ \
- (ChP)->RxControl[2] |= RXPROC_EN; \
- rp_writech2(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sEnRxStatusMode
-Purpose: Enable the Rx status mode
-Call: sEnRxStatusMode(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This places the channel in the receive status mode. All subsequent
- reads of receive data using sReadRxWord() will return a data byte
- in the low word and a status byte in the high word.
-
-*/
-#define sEnRxStatusMode(ChP) rp_writech2(ChP,CHNOFF_CHANSTAT(ChP),STATMODE)
-
-/***************************************************************************
-Function: sEnTransmit
-Purpose: Enable transmit
-Call: sEnTransmit(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sEnTransmit(ChP) \
-{ \
- (ChP)->TxControl[3] |= TX_ENABLE; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sGetAiopIntStatus
-Purpose: Get the AIOP interrupt status
-Call: sGetAiopIntStatus(CtlP,AiopNum)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int AiopNum; AIOP number
-Return: Byte_t: The AIOP interrupt status. Bits 0 through 7
- represent channels 0 through 7 respectively. If a
- bit is set that channel is interrupting.
-*/
-#define sGetAiopIntStatus(CtlP,AIOPNUM) rp_readaiop1(CtlP,AIOPNUM,_INT_CHAN)
-
-/***************************************************************************
-Function: sGetAiopNumChan
-Purpose: Get the number of channels supported by an AIOP
-Call: sGetAiopNumChan(CtlP,AiopNum)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int AiopNum; AIOP number
-Return: int: The number of channels supported by the AIOP
-*/
-#define sGetAiopNumChan(CtlP,AIOPNUM) CtlP->AiopNumChan[AIOPNUM]
-
-/***************************************************************************
-Function: sGetChanIntID
-Purpose: Get a channel's interrupt identification byte
-Call: sGetChanIntID(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Byte_t: The channel interrupt ID. Can be any
- combination of the following flags:
- RXF_TRIG: Rx FIFO trigger level interrupt
- TXFIFO_MT: Tx FIFO empty interrupt
- SRC_INT: Special receive condition interrupt
- DELTA_CD: CD change interrupt
- DELTA_CTS: CTS change interrupt
- DELTA_DSR: DSR change interrupt
-*/
-#define sGetChanIntID(ChP) (rp_readch1(ChP,(ChP)->ChanNum+_INT_ID0) & (RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR))
-
-/***************************************************************************
-Function: sGetChanNum
-Purpose: Get the number of a channel within an AIOP
-Call: sGetChanNum(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: int: Channel number within AIOP, or NULLCHAN if channel does
- not exist.
-*/
-#define sGetChanNum(ChP) (ChP)->ChanNum
-
-/***************************************************************************
-Function: sGetChanStatus
-Purpose: Get the channel status
-Call: sGetChanStatus(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Word_t: The channel status. Can be any combination of
- the following flags:
- LOW BYTE FLAGS
- CTS_ACT: CTS input asserted
- DSR_ACT: DSR input asserted
- CD_ACT: CD input asserted
- TXFIFOMT: Tx FIFO is empty
- TXSHRMT: Tx shift register is empty
- RDA: Rx data available
-
- HIGH BYTE FLAGS
- STATMODE: status mode enable bit
- RXFOVERFL: receive FIFO overflow
- RX2MATCH: receive compare byte 2 match
- RX1MATCH: receive compare byte 1 match
- RXBREAK: received BREAK
- RXFRAME: received framing error
- RXPARITY: received parity error
-Warnings: This function will clear the high byte flags in the Channel
- Status Register.
-*/
-#define sGetChanStatus(ChP) rp_readch2(ChP,CHNOFF_CHANSTAT(ChP))
-
-/***************************************************************************
-Function: sGetChanStatusLo
-Purpose: Get the low byte only of the channel status
-Call: sGetChanStatusLo(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Byte_t: The channel status low byte. Can be any combination
- of the following flags:
- CTS_ACT: CTS input asserted
- DSR_ACT: DSR input asserted
- CD_ACT: CD input asserted
- TXFIFOMT: Tx FIFO is empty
- TXSHRMT: Tx shift register is empty
- RDA: Rx data available
-*/
-#define sGetChanStatusLo(ChP) rp_readch1(ChP,CHNOFF_CHANSTAT(ChP))
-
-/***************************************************************************
-Function: sGetRxCnt
-Purpose: Get the number of data bytes in the Rx FIFO
-Call: sGetRxCnt(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: int: The number of data bytes in the Rx FIFO.
-Comments: Byte read of count register is required to obtain Rx count.
-
-*/
-#define sGetRxCnt(ChP) rp_readch2(ChP,CHNOFF_TXRXCOUNT(ChP))
-
-/***************************************************************************
-Function: sGetTxCnt
-Purpose: Get the number of data bytes in the Tx FIFO
-Call: sGetTxCnt(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Byte_t: The number of data bytes in the Tx FIFO.
-Comments: Byte read of count register is required to obtain Tx count.
-
-*/
-#define sGetTxCnt(ChP) rp_readch1(ChP,CHNOFF_TXRXCOUNT(ChP))
-
-/*****************************************************************************
-Function: sGetTxRxDataIO
-Purpose: Get the offset of a channel's TxRx Data register
-Call: sGetTxRxDataIO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: WordIO_t: offset of a channel's TxRx Data register
-*/
-#define sGetTxRxDataIO(ChP) CHNOFF_TXRXDATA(ChP)
-
-/***************************************************************************
-Function: sInitChanDefaults
-Purpose: Initialize a channel structure to its default state.
-Call: sInitChanDefaults(ChP)
- CHANNEL_T *ChP; Ptr to the channel structure
-Comments: This function must be called once for every channel structure
- that exists before any other SSCI calls can be made.
-
-*/
-#define sInitChanDefaults(ChP) \
-{ \
- (ChP)->CtlP = NULLCTLPTR; \
- (ChP)->AiopNum = NULLAIOP; \
- (ChP)->ChanID = AIOPID_NULL; \
- (ChP)->ChanNum = NULLCHAN; \
-}
-
-/***************************************************************************
-Function: sResetAiopByNum
-Purpose: Reset the AIOP by number
-Call: sResetAiopByNum(CTLP,AIOPNUM)
- CONTROLLER_T CTLP; Ptr to controller structure
- AIOPNUM; AIOP index
-*/
-#define sResetAiopByNum(CTLP,AIOPNUM) \
-{ \
- rp_writeaiop1(CTLP,AIOPNUM,_CMD_REG,RESET_ALL); \
- rp_writeaiop1(CTLP,AIOPNUM,_CMD_REG,0x0); \
-}
-
-/***************************************************************************
-Function: sSendBreak
-Purpose: Send a transmit BREAK signal
-Call: sSendBreak(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSendBreak(ChP) \
-{ \
- (ChP)->TxControl[3] |= SETBREAK; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetBaud
-Purpose: Set baud rate
-Call: sSetBaud(ChP,Divisor)
- CHANNEL_T *ChP; Ptr to channel structure
- Word_t Divisor; 16 bit baud rate divisor for channel
-*/
-#define sSetBaud(ChP,DIVISOR) \
-{ \
- (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \
- (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->BaudDiv[0]); \
-}
-
-/***************************************************************************
-Function: sSetData7
-Purpose: Set data bits to 7
-Call: sSetData7(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetData7(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~DATA8BIT; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetData8
-Purpose: Set data bits to 8
-Call: sSetData8(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetData8(ChP) \
-{ \
- (ChP)->TxControl[2] |= DATA8BIT; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetDTR
-Purpose: Set the DTR output
-Call: sSetDTR(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetDTR(ChP) \
-{ \
- (ChP)->TxControl[3] |= SET_DTR; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetEvenParity
-Purpose: Set even parity
-Call: sSetEvenParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-
-Warnings: This function has no effect unless parity is enabled with function
- sEnParity().
-*/
-#define sSetEvenParity(ChP) \
-{ \
- (ChP)->TxControl[2] |= EVEN_PAR; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetOddParity
-Purpose: Set odd parity
-Call: sSetOddParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-
-Warnings: This function has no effect unless parity is enabled with function
- sEnParity().
-*/
-#define sSetOddParity(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~EVEN_PAR; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetRTS
-Purpose: Set the RTS output
-Call: sSetRTS(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetRTS(ChP) \
-{ \
- (ChP)->TxControl[3] |= SET_RTS; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetRxTrigger
-Purpose: Set the Rx FIFO trigger level
-Call: sSetRxProcessor(ChP,Level)
- CHANNEL_T *ChP; Ptr to channel structure
- Byte_t Level; Number of characters in Rx FIFO at which the
- interrupt will be generated. Can be any of the following flags:
-
- TRIG_NO: no trigger
- TRIG_1: 1 character in FIFO
- TRIG_1_2: FIFO 1/2 full
- TRIG_7_8: FIFO 7/8 full
-Comments: An interrupt will be generated when the trigger level is reached
- only if function sEnInterrupt() has been called with flag
- RXINT_EN set. The RXF_TRIG flag in the Interrupt Idenfification
- register will be set whenever the trigger level is reached
- regardless of the setting of RXINT_EN.
-
-*/
-#define sSetRxTrigger(ChP,LEVEL) \
-{ \
- (ChP)->RxControl[2] &= ~TRIG_MASK; \
- (ChP)->RxControl[2] |= LEVEL; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetStop1
-Purpose: Set stop bits to 1
-Call: sSetStop1(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetStop1(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~STOP2; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetStop2
-Purpose: Set stop bits to 2
-Call: sSetStop2(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetStop2(ChP) \
-{ \
- (ChP)->TxControl[2] |= STOP2; \
- rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sStartRxProcessor
-Purpose: Start a channel's receive processor
-Call: sStartRxProcessor(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This function is used to start a Rx processor after it was
- stopped with sStopRxProcessor() or sStopSWInFlowCtl(). It
- will restart both the Rx processor and software input flow control.
-
-*/
-#define sStartRxProcessor(ChP) rp_writech4(ChP,_INDX_ADDR,*(DWord_t *)&(ChP)->R[0])
-
-/***************************************************************************
-Function: sWriteTxByte
-Purpose: Write a transmit data byte to a channel.
- CHANNEL_T *ChP; Ptr to channel structure
- ByteIO_t io: Channel transmit register I/O address. This can
- be obtained with sGetTxRxDataIO().
- Byte_t Data; The transmit data byte.
-Warnings: This function writes the data byte without checking to see if
- sMaxTxSize is exceeded in the Tx FIFO.
-*/
-#define sWriteTxByte(ChP,IO,DATA) rp_writech1(ChP,IO,DATA)
-
-int sReadAiopID(CONTROLLER_T *CtlP, int aiop);
-int sReadAiopNumChan(CONTROLLER_T *CtlP, int aiop);
-int sInitChan( CONTROLLER_T *CtlP,
- CHANNEL_T *ChP,
- int AiopNum,
- int ChanNum);
-Byte_t sGetRxErrStatus(CHANNEL_T *ChP);
-void sStopRxProcessor(CHANNEL_T *ChP);
-void sStopSWInFlowCtl(CHANNEL_T *ChP);
-void sFlushRxFIFO(CHANNEL_T *ChP);
-void sFlushTxFIFO(CHANNEL_T *ChP);
-int sWriteTxPrioByte(CHANNEL_T *ChP, Byte_t Data);
-void sEnInterrupts(CHANNEL_T *ChP,Word_t Flags);
-void sDisInterrupts(CHANNEL_T *ChP,Word_t Flags);
-int rp_attachcommon(CONTROLLER_T *ctlp, int num_aiops, int num_ports);
-void rp_releaseresource(CONTROLLER_t *ctlp);
-
-#ifndef ROCKET_C
-extern Byte_t R[RDATASIZE];
-extern CONTROLLER_T sController[CTL_SIZE];
-extern Byte_t sIRQMap[16];
-#endif
-extern Byte_t rp_sBitMapClrTbl[8];
-extern Byte_t rp_sBitMapSetTbl[8];
diff --git a/sys/dev/sound/pci/fm801.c b/sys/dev/sound/pci/fm801.c
deleted file mode 100644
index 2173c0a8519f6..0000000000000
--- a/sys/dev/sound/pci/fm801.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * Copyright (c) 2000 Dmitry Dicky diwil@dataart.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. 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.
- *
- * $FreeBSD$
- */
-
-#include <dev/sound/pcm/sound.h>
-#include <dev/sound/pcm/ac97.h>
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#define PCI_VENDOR_FORTEMEDIA 0x1319
-#define PCI_DEVICE_FORTEMEDIA1 0x08011319
-#define PCI_DEVICE_FORTEMEDIA2 0x08021319 /* ??? have no idea what's this... */
-
-#define FM_PCM_VOLUME 0x00
-#define FM_FM_VOLUME 0x02
-#define FM_I2S_VOLUME 0x04
-#define FM_RECORD_SOURCE 0x06
-
-#define FM_PLAY_CTL 0x08
-#define FM_PLAY_RATE_MASK 0x0f00
-#define FM_PLAY_BUF1_LAST 0x0001
-#define FM_PLAY_BUF2_LAST 0x0002
-#define FM_PLAY_START 0x0020
-#define FM_PLAY_PAUSE 0x0040
-#define FM_PLAY_STOPNOW 0x0080
-#define FM_PLAY_16BIT 0x4000
-#define FM_PLAY_STEREO 0x8000
-
-#define FM_PLAY_DMALEN 0x0a
-#define FM_PLAY_DMABUF1 0x0c
-#define FM_PLAY_DMABUF2 0x10
-
-
-#define FM_REC_CTL 0x14
-#define FM_REC_RATE_MASK 0x0f00
-#define FM_REC_BUF1_LAST 0x0001
-#define FM_REC_BUF2_LAST 0x0002
-#define FM_REC_START 0x0020
-#define FM_REC_PAUSE 0x0040
-#define FM_REC_STOPNOW 0x0080
-#define FM_REC_16BIT 0x4000
-#define FM_REC_STEREO 0x8000
-
-
-#define FM_REC_DMALEN 0x16
-#define FM_REC_DMABUF1 0x18
-#define FM_REC_DMABUF2 0x1c
-
-#define FM_CODEC_CTL 0x22
-#define FM_VOLUME 0x26
-#define FM_VOLUME_MUTE 0x8000
-
-#define FM_CODEC_CMD 0x2a
-#define FM_CODEC_CMD_READ 0x0080
-#define FM_CODEC_CMD_VALID 0x0100
-#define FM_CODEC_CMD_BUSY 0x0200
-
-#define FM_CODEC_DATA 0x2c
-
-#define FM_IO_CTL 0x52
-#define FM_CARD_CTL 0x54
-
-#define FM_INTMASK 0x56
-#define FM_INTMASK_PLAY 0x0001
-#define FM_INTMASK_REC 0x0002
-#define FM_INTMASK_VOL 0x0040
-#define FM_INTMASK_MPU 0x0080
-
-#define FM_INTSTATUS 0x5a
-#define FM_INTSTATUS_PLAY 0x0100
-#define FM_INTSTATUS_REC 0x0200
-#define FM_INTSTATUS_VOL 0x4000
-#define FM_INTSTATUS_MPU 0x8000
-
-#define FM801_BUFFSIZE 1024*4 /* Other values do not work!!! */
-
-/* debug purposes */
-#define DPRINT if(0) printf
-
-
-/* channel interface */
-static void *fm801ch_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
-static int fm801ch_setformat(void *data, u_int32_t format);
-static int fm801ch_setspeed(void *data, u_int32_t speed);
-static int fm801ch_setblocksize(void *data, u_int32_t blocksize);
-static int fm801ch_trigger(void *data, int go);
-static int fm801ch_getptr(void *data);
-static pcmchan_caps *fm801ch_getcaps(void *data);
-/*
-static int fm801ch_setup(pcm_channel *c);
-*/
-
-static u_int32_t fmts[] = {
- AFMT_U8,
- AFMT_STEREO | AFMT_U8,
- AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE,
- 0
-};
-
-static pcmchan_caps fm801ch_caps = {
- 4000, 48000,
- fmts, 0
-};
-
-static pcm_channel fm801_chantemplate = {
- fm801ch_init,
- NULL, /* setdir */
- fm801ch_setformat,
- fm801ch_setspeed,
- fm801ch_setblocksize,
- fm801ch_trigger,
- fm801ch_getptr,
- fm801ch_getcaps,
- NULL, /* free */
- NULL, /* nop1 */
- NULL, /* nop2 */
- NULL, /* nop3 */
- NULL, /* nop4 */
- NULL, /* nop5 */
- NULL, /* nop6 */
- NULL, /* nop7 */
-};
-
-struct fm801_info;
-
-struct fm801_chinfo {
- struct fm801_info *parent;
- pcm_channel *channel;
- snd_dbuf *buffer;
- u_int32_t spd, dir, fmt; /* speed, direction, format */
- u_int32_t shift;
-};
-
-struct fm801_info {
- int type;
- bus_space_tag_t st;
- bus_space_handle_t sh;
- bus_dma_tag_t parent_dmat;
-
- device_t dev;
- int num;
- u_int32_t unit;
-
- struct resource *reg, *irq;
- int regtype, regid, irqid;
- void *ih;
-
- u_int32_t play_flip,
- play_nextblk,
- play_start,
- play_blksize,
- play_fmt,
- play_shift,
- play_size;
-
- u_int32_t rec_flip,
- rec_nextblk,
- rec_start,
- rec_blksize,
- rec_fmt,
- rec_shift,
- rec_size;
-
- struct fm801_chinfo pch, rch;
-};
-
-/* Bus Read / Write routines */
-static u_int32_t
-fm801_rd(struct fm801_info *fm801, int regno, int size)
-{
- switch(size) {
- case 1:
- return (bus_space_read_1(fm801->st, fm801->sh, regno));
- case 2:
- return (bus_space_read_2(fm801->st, fm801->sh, regno));
- case 4:
- return (bus_space_read_4(fm801->st, fm801->sh, regno));
- default:
- return 0xffffffff;
- }
-}
-
-static void
-fm801_wr(struct fm801_info *fm801, int regno, u_int32_t data, int size)
-{
- switch(size) {
- case 1:
- return bus_space_write_1(fm801->st, fm801->sh, regno, data);
- case 2:
- return bus_space_write_2(fm801->st, fm801->sh, regno, data);
- case 4:
- return bus_space_write_4(fm801->st, fm801->sh, regno, data);
- default:
- return;
- }
-}
-
-/*
- * ac97 codec routines
- */
-#define TIMO 50
-static u_int32_t
-fm801_rdcd(void *devinfo, int regno)
-{
- struct fm801_info *fm801 = (struct fm801_info *)devinfo;
- int i;
-
- for (i = 0; i < TIMO && fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_BUSY; i++) {
- DELAY(10000);
- DPRINT("fm801 rdcd: 1 - DELAY\n");
- }
- if (i >= TIMO) {
- printf("fm801 rdcd: codec busy\n");
- return 0;
- }
-
- fm801_wr(fm801,FM_CODEC_CMD, regno|FM_CODEC_CMD_READ,2);
-
- for (i = 0; i < TIMO && !(fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_VALID); i++)
- {
- DELAY(10000);
- DPRINT("fm801 rdcd: 2 - DELAY\n");
- }
- if (i >= TIMO) {
- printf("fm801 rdcd: write codec invalid\n");
- return 0;
- }
-
- return fm801_rd(fm801,FM_CODEC_DATA,2);
-}
-
-static void
-fm801_wrcd(void *devinfo, int regno, u_int32_t data)
-{
- struct fm801_info *fm801 = (struct fm801_info *)devinfo;
- int i;
-
- DPRINT("fm801_wrcd reg 0x%x val 0x%x\n",regno, data);
-/*
- if(regno == AC97_REG_RECSEL) return;
-*/
- /* Poll until codec is ready */
- for (i = 0; i < TIMO && fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_BUSY; i++) {
- DELAY(10000);
- DPRINT("fm801 rdcd: 1 - DELAY\n");
- }
- if (i >= TIMO) {
- printf("fm801 wrcd: read codec busy\n");
- return;
- }
-
- fm801_wr(fm801,FM_CODEC_DATA,data, 2);
- fm801_wr(fm801,FM_CODEC_CMD, regno,2);
-
- /* wait until codec is ready */
- for (i = 0; i < TIMO && fm801_rd(fm801,FM_CODEC_CMD,2) & FM_CODEC_CMD_BUSY; i++) {
- DELAY(10000);
- DPRINT("fm801 wrcd: 2 - DELAY\n");
- }
- if (i >= TIMO) {
- printf("fm801 wrcd: read codec busy\n");
- return;
- }
- DPRINT("fm801 wrcd release reg 0x%x val 0x%x\n",regno, data);
- return;
-}
-
-/*
- * The interrupt handler
- */
-static void
-fm801_intr(void *p)
-{
- struct fm801_info *fm801 = (struct fm801_info *)p;
- u_int32_t intsrc = fm801_rd(fm801, FM_INTSTATUS, 2);
- struct fm801_chinfo *ch = &(fm801->pch);
- snd_dbuf *b = ch->buffer;
-
- DPRINT("\nfm801_intr intsrc 0x%x ", intsrc);
- DPRINT("rp %d, rl %d, fp %d fl %d, size=%d\n",
- b->rp,b->rl, b->fp,b->fl, b->blksz);
-
- if(intsrc & FM_INTSTATUS_PLAY) {
- fm801->play_flip++;
- if(fm801->play_flip & 1) {
- fm801_wr(fm801, FM_PLAY_DMABUF1, fm801->play_start,4);
- } else
- fm801_wr(fm801, FM_PLAY_DMABUF2, fm801->play_nextblk,4);
- chn_intr(fm801->pch.channel);
- }
-
- if(intsrc & FM_INTSTATUS_REC) {
- fm801->rec_flip++;
- if(fm801->rec_flip & 1) {
- fm801_wr(fm801, FM_REC_DMABUF1, fm801->rec_start,4);
- } else
- fm801_wr(fm801, FM_REC_DMABUF2, fm801->rec_nextblk,4);
- chn_intr(fm801->rch.channel);
- }
-
- if ( intsrc & FM_INTSTATUS_MPU ) {
- /* This is a TODOish thing... */
- fm801_wr(fm801, FM_INTSTATUS, intsrc & FM_INTSTATUS_MPU,2);
- }
-
- if ( intsrc & FM_INTSTATUS_VOL ) {
- /* This is a TODOish thing... */
- fm801_wr(fm801, FM_INTSTATUS, intsrc & FM_INTSTATUS_VOL,2);
- }
-
- DPRINT("fm801_intr clear\n\n");
- fm801_wr(fm801, FM_INTSTATUS, intsrc & (FM_INTSTATUS_PLAY | FM_INTSTATUS_REC), 2);
-}
-
-/*
- * Init routine is taken from an original NetBSD driver
- */
-static int
-fm801_init(struct fm801_info *fm801)
-{
- u_int32_t k1;
-
- /* reset codec */
- fm801_wr(fm801, FM_CODEC_CTL, 0x0020,2);
- DELAY(100000);
- fm801_wr(fm801, FM_CODEC_CTL, 0x0000,2);
- DELAY(100000);
-
- fm801_wr(fm801, FM_PCM_VOLUME, 0x0808,2);
- fm801_wr(fm801, FM_FM_VOLUME, 0x0808,2);
- fm801_wr(fm801, FM_I2S_VOLUME, 0x0808,2);
- fm801_wr(fm801, 0x40,0x107f,2); /* enable legacy audio */
-
- fm801_wr((void *)fm801, FM_RECORD_SOURCE, 0x0000,2);
-
- /* Unmask playback, record and mpu interrupts, mask the rest */
- k1 = fm801_rd((void *)fm801, FM_INTMASK,2);
- fm801_wr(fm801, FM_INTMASK,
- (k1 & ~(FM_INTMASK_PLAY | FM_INTMASK_REC | FM_INTMASK_MPU)) |
- FM_INTMASK_VOL,2);
- fm801_wr(fm801, FM_INTSTATUS,
- FM_INTSTATUS_PLAY | FM_INTSTATUS_REC | FM_INTSTATUS_MPU |
- FM_INTSTATUS_VOL,2);
-
- DPRINT("FM801 init Ok\n");
- return 0;
-}
-
-static int
-fm801_pci_attach(device_t dev)
-{
- u_int32_t data;
- struct ac97_info *codec = 0;
- struct fm801_info *fm801;
- int i;
- int mapped = 0;
- char status[SND_STATUSLEN];
-
- if ((fm801 = (struct fm801_info *)malloc(sizeof(*fm801),M_DEVBUF, M_NOWAIT)) == NULL) {
- device_printf(dev, "cannot allocate softc\n");
- return ENXIO;
- }
-
- bzero(fm801, sizeof(*fm801));
- fm801->type = pci_get_devid(dev);
-
- data = pci_read_config(dev, PCIR_COMMAND, 2);
- data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCIR_COMMAND, data, 2);
- data = pci_read_config(dev, PCIR_COMMAND, 2);
-
- for (i = 0; (mapped == 0) && (i < PCI_MAXMAPS_0); i++) {
- fm801->regid = PCIR_MAPS + i*4;
- fm801->regtype = SYS_RES_MEMORY;
- fm801->reg = bus_alloc_resource(dev, fm801->regtype, &fm801->regid,
- 0, ~0, 1, RF_ACTIVE);
- if(!fm801->reg)
- {
- fm801->regtype = SYS_RES_IOPORT;
- fm801->reg = bus_alloc_resource(dev, fm801->regtype, &fm801->regid,
- 0, ~0, 1, RF_ACTIVE);
- }
-
- if(fm801->reg) {
- fm801->st = rman_get_bustag(fm801->reg);
- fm801->sh = rman_get_bushandle(fm801->reg);
- mapped++;
- }
- }
-
- if (mapped == 0) {
- device_printf(dev, "unable to map register space\n");
- goto oops;
- }
-
- fm801_init(fm801);
-
- codec = ac97_create(dev, (void *)fm801, NULL, fm801_rdcd, fm801_wrcd);
- if (codec == NULL) goto oops;
-
- if (mixer_init(dev, &ac97_mixer, codec) == -1) goto oops;
-
- fm801->irqid = 0;
- fm801->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &fm801->irqid,
- 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
- if (!fm801->irq ||
- bus_setup_intr(dev, fm801->irq, INTR_TYPE_TTY,
- fm801_intr, fm801, &fm801->ih)) {
- device_printf(dev, "unable to map interrupt\n");
- goto oops;
- }
-
- if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/FM801_BUFFSIZE, /*nsegments*/1, /*maxsegz*/0x3ffff,
- /*flags*/0, &fm801->parent_dmat) != 0) {
- device_printf(dev, "unable to create dma tag\n");
- goto oops;
- }
-
- snprintf(status, 64, "at %s 0x%lx irq %ld",
- (fm801->regtype == SYS_RES_IOPORT)? "io" : "memory",
- rman_get_start(fm801->reg), rman_get_start(fm801->irq));
-
-#define FM801_MAXPLAYCH 1
- if (pcm_register(dev, fm801, FM801_MAXPLAYCH, 1)) goto oops;
- pcm_addchan(dev, PCMDIR_PLAY, &fm801_chantemplate, fm801);
- pcm_addchan(dev, PCMDIR_REC, &fm801_chantemplate, fm801);
- pcm_setstatus(dev, status);
-
- return 0;
-
-oops:
- if (codec) ac97_destroy(codec);
- if (fm801->reg) bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg);
- if (fm801->ih) bus_teardown_intr(dev, fm801->irq, fm801->ih);
- if (fm801->irq) bus_release_resource(dev, SYS_RES_IRQ, fm801->irqid, fm801->irq);
- if (fm801->parent_dmat) bus_dma_tag_destroy(fm801->parent_dmat);
- free(fm801, M_DEVBUF);
- return ENXIO;
-}
-
-static int
-fm801_pci_detach(device_t dev)
-{
- int r;
- struct fm801_info *fm801;
-
- DPRINT("Forte Media FM801 detach\n");
-
- r = pcm_unregister(dev);
- if (r)
- return r;
-
- fm801 = pcm_getdevinfo(dev);
- bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg);
- bus_teardown_intr(dev, fm801->irq, fm801->ih);
- bus_release_resource(dev, SYS_RES_IRQ, fm801->irqid, fm801->irq);
- bus_dma_tag_destroy(fm801->parent_dmat);
- free(fm801, M_DEVBUF);
- return 0;
-}
-
-static int
-fm801_pci_probe( device_t dev )
-{
- int id;
- if ((id = pci_get_devid(dev)) == PCI_DEVICE_FORTEMEDIA1 ) {
- device_set_desc(dev, "Forte Media FM801 Audio Controller");
- return 0;
- }
-/*
- if ((id = pci_get_devid(dev)) == PCI_DEVICE_FORTEMEDIA2 ) {
- device_set_desc(dev, "Forte Media FM801 Joystick (Not Supported)");
- return ENXIO;
- }
-*/
- return ENXIO;
-}
-
-
-
-/* channel interface */
-static void *
-fm801ch_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct fm801_info *fm801 = (struct fm801_info *)devinfo;
- struct fm801_chinfo *ch = (dir == PCMDIR_PLAY)? &fm801->pch : &fm801->rch;
-
- DPRINT("fm801ch_init, direction = %d\n", dir);
- ch->parent = fm801;
- ch->channel = c;
- ch->buffer = b;
- ch->buffer->bufsize = FM801_BUFFSIZE;
- ch->dir = dir;
- if( chn_allocbuf(ch->buffer, fm801->parent_dmat) == -1) return NULL;
- return (void *)ch;
-}
-
-static int
-fm801ch_setformat(void *data, u_int32_t format)
-{
- struct fm801_chinfo *ch = data;
- struct fm801_info *fm801 = ch->parent;
-
- DPRINT("fm801ch_setformat 0x%x : %s, %s, %s, %s\n", format,
- (format & AFMT_STEREO)?"stereo":"mono",
- (format & (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)) ? "16bit":"8bit",
- (format & AFMT_SIGNED)? "signed":"unsigned",
- (format & AFMT_BIGENDIAN)?"bigendiah":"littleendian" );
-
- if(ch->dir == PCMDIR_PLAY) {
- fm801->play_fmt = (format & AFMT_STEREO)? FM_PLAY_STEREO : 0;
- fm801->play_fmt |= (format & AFMT_16BIT) ? FM_PLAY_16BIT : 0;
- return 0;
- }
-
- if(ch->dir == PCMDIR_REC ) {
- fm801->rec_fmt = (format & AFMT_STEREO)? FM_REC_STEREO:0;
- fm801->rec_fmt |= (format & AFMT_16BIT) ? FM_PLAY_16BIT : 0;
- return 0;
- }
-
- return 0;
-}
-
-struct {
- int limit;
- int rate;
-} fm801_rates[11] = {
- { 6600, 5500 },
- { 8750, 8000 },
- { 10250, 9600 },
- { 13200, 11025 },
- { 17500, 16000 },
- { 20500, 19200 },
- { 26500, 22050 },
- { 35000, 32000 },
- { 41000, 38400 },
- { 46000, 44100 },
- { 48000, 48000 },
-/* anything above -> 48000 */
-};
-
-static int
-fm801ch_setspeed(void *data, u_int32_t speed)
-{
- struct fm801_chinfo *ch = data;
- struct fm801_info *fm801 = ch->parent;
- register int i;
-
-
- for (i = 0; i < 10 && fm801_rates[i].limit <= speed; i++) ;
-
- if(ch->dir == PCMDIR_PLAY) {
- fm801->pch.spd = fm801_rates[i].rate;
- fm801->play_shift = (i<<8);
- fm801->play_shift &= FM_PLAY_RATE_MASK;
- }
-
- if(ch->dir == PCMDIR_REC ) {
- fm801->rch.spd = fm801_rates[i].rate;
- fm801->rec_shift = (i<<8);
- fm801->rec_shift &= FM_REC_RATE_MASK;
- }
-
- ch->spd = fm801_rates[i].rate;
-
- return fm801_rates[i].rate;
-}
-
-static int
-fm801ch_setblocksize(void *data, u_int32_t blocksize)
-{
- struct fm801_chinfo *ch = data;
- struct fm801_info *fm801 = ch->parent;
-
- if(ch->dir == PCMDIR_PLAY) {
- if(fm801->play_flip) return fm801->play_blksize;
- fm801->play_blksize = blocksize;
- }
-
- if(ch->dir == PCMDIR_REC) {
- if(fm801->rec_flip) return fm801->rec_blksize;
- fm801->rec_blksize = blocksize;
- }
-
- DPRINT("fm801ch_setblocksize %d (dir %d)\n",blocksize, ch->dir);
-
- return blocksize;
-}
-
-static int
-fm801ch_trigger(void *data, int go)
-{
- struct fm801_chinfo *ch = data;
- struct fm801_info *fm801 = ch->parent;
- u_int32_t baseaddr = vtophys(ch->buffer->buf);
- snd_dbuf *b = ch->buffer;
- u_int32_t k1;
-
- DPRINT("fm801ch_trigger go %d , ", go);
- DPRINT("rp %d, rl %d, fp %d fl %d, dl %d, blksize=%d\n",
- b->rp,b->rl, b->fp,b->fl, b->dl, b->blksz);
-
- if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD) {
- return 0;
- }
-
- if (ch->dir == PCMDIR_PLAY) {
- if (go == PCMTRIG_START) {
-
- fm801->play_start = baseaddr;
- fm801->play_nextblk = fm801->play_start + fm801->play_blksize;
- fm801->play_flip = 0;
- fm801_wr(fm801, FM_PLAY_DMALEN, fm801->play_blksize - 1, 2);
- fm801_wr(fm801, FM_PLAY_DMABUF1,fm801->play_start,4);
- fm801_wr(fm801, FM_PLAY_DMABUF2,fm801->play_nextblk,4);
- fm801_wr(fm801, FM_PLAY_CTL,
- FM_PLAY_START | FM_PLAY_STOPNOW | fm801->play_fmt | fm801->play_shift,
- 2 );
- } else {
- fm801->play_flip = 0;
- k1 = fm801_rd(fm801, FM_PLAY_CTL,2);
- fm801_wr(fm801, FM_PLAY_CTL,
- (k1 & ~(FM_PLAY_STOPNOW | FM_PLAY_START)) |
- FM_PLAY_BUF1_LAST | FM_PLAY_BUF2_LAST, 2 );
- }
- } else if(ch->dir == PCMDIR_REC) {
- if (go == PCMTRIG_START) {
- fm801->rec_start = baseaddr;
- fm801->rec_nextblk = fm801->rec_start + fm801->rec_blksize;
- fm801->rec_flip = 0;
- fm801_wr(fm801, FM_REC_DMALEN, fm801->rec_blksize - 1, 2);
- fm801_wr(fm801, FM_REC_DMABUF1,fm801->rec_start,4);
- fm801_wr(fm801, FM_REC_DMABUF2,fm801->rec_nextblk,4);
- fm801_wr(fm801, FM_REC_CTL,
- FM_REC_START | FM_REC_STOPNOW | fm801->rec_fmt | fm801->rec_shift,
- 2 );
- } else {
- fm801->rec_flip = 0;
- k1 = fm801_rd(fm801, FM_REC_CTL,2);
- fm801_wr(fm801, FM_REC_CTL,
- (k1 & ~(FM_REC_STOPNOW | FM_REC_START)) |
- FM_REC_BUF1_LAST | FM_REC_BUF2_LAST, 2);
- }
- }
-
- return 0;
-}
-
-/* Almost ALSA copy */
-static int
-fm801ch_getptr(void *data)
-{
- struct fm801_chinfo *ch = data;
- struct fm801_info *fm801 = ch->parent;
- int result = 0;
- snd_dbuf *b = ch->buffer;
-
- if (ch->dir == PCMDIR_PLAY) {
- result = fm801_rd(fm801,
- (fm801->play_flip&1) ?
- FM_PLAY_DMABUF2:FM_PLAY_DMABUF1, 4) - fm801->play_start;
- }
-
- if (ch->dir == PCMDIR_REC) {
- result = fm801_rd(fm801,
- (fm801->rec_flip&1) ?
- FM_REC_DMABUF2:FM_REC_DMABUF1, 4) - fm801->rec_start;
- }
-
- DPRINT("fm801ch_getptr:%d, rp %d, rl %d, fp %d fl %d\n",
- result, b->rp,b->rl, b->fp,b->fl);
-
- return result;
-}
-
-static pcmchan_caps *
-fm801ch_getcaps(void *data)
-{
- return &fm801ch_caps;
-}
-
-static device_method_t fm801_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, fm801_pci_probe),
- DEVMETHOD(device_attach, fm801_pci_attach),
- DEVMETHOD(device_detach, fm801_pci_detach),
- { 0, 0}
-};
-
-static driver_t fm801_driver = {
- "pcm",
- fm801_methods,
- sizeof(snddev_info),
-};
-
-static devclass_t pcm_devclass;
-
-DRIVER_MODULE(fm801, pci, fm801_driver, pcm_devclass, 0, 0);
diff --git a/sys/dev/sound/pci/maestro.c b/sys/dev/sound/pci/maestro.c
deleted file mode 100644
index a465d5c33533d..0000000000000
--- a/sys/dev/sound/pci/maestro.c
+++ /dev/null
@@ -1,1188 +0,0 @@
-/*-
- * Copyright (c) 2000 Taku YAMAMOTO <taku@cent.saitama-u.ac.jp>
- * 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.
- *
- * 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: maestro.c,v 1.12 2000/09/06 03:32:34 taku Exp $
- * $FreeBSD$
- */
-
-/*
- * Credits:
- *
- * Part of this code (especially in many magic numbers) was heavily inspired
- * by the Linux driver originally written by
- * Alan Cox <alan.cox@linux.org>, modified heavily by
- * Zach Brown <zab@zabbo.net>.
- *
- * busdma()-ize and buffer size reduction were suggested by
- * Cameron Grant <gandalf@vilnya.demon.co.uk>.
- * Also he showed me the way to use busdma() suite.
- *
- * Internal speaker problems on NEC VersaPro's and Dell Inspiron 7500
- * were looked at by
- * Munehiro Matsuda <haro@tk.kubota.co.jp>,
- * who brought patches based on the Linux driver with some simplification.
- */
-
-#include <dev/sound/pcm/sound.h>
-#include <dev/sound/pcm/ac97.h>
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#include <dev/sound/pci/maestro_reg.h>
-
-#define inline __inline
-
-/*
- * PCI IDs of supported chips:
- *
- * MAESTRO-1 0x01001285
- * MAESTRO-2 0x1968125d
- * MAESTRO-2E 0x1978125d
- */
-
-#define MAESTRO_1_PCI_ID 0x01001285
-#define MAESTRO_2_PCI_ID 0x1968125d
-#define MAESTRO_2E_PCI_ID 0x1978125d
-
-#define NEC_SUBID1 0x80581033 /* Taken from Linux driver */
-#define NEC_SUBID2 0x803c1033 /* NEC VersaProNX VA26D */
-
-#ifndef AGG_MAXPLAYCH
-# define AGG_MAXPLAYCH 4
-#endif
-
-#define AGG_BUFSIZ 4096
-
-
-/* -----------------------------
- * Data structures.
- */
-struct agg_chinfo {
- struct agg_info *parent;
- pcm_channel *channel;
- snd_dbuf *buffer;
- bus_addr_t offset;
- u_int32_t blocksize;
- int dir;
- u_int num;
- u_int16_t aputype;
- u_int16_t wcreg_tpl;
-};
-
-struct agg_info {
- device_t dev;
- struct resource *reg;
- int regid;
-
- bus_space_tag_t st;
- bus_space_handle_t sh;
- bus_dma_tag_t parent_dmat;
-
- struct resource *irq;
- int irqid;
- void *ih;
-
- u_int8_t *stat;
- bus_addr_t baseaddr;
-
- struct ac97_info *codec;
-
- u_int playchns, active;
- struct agg_chinfo pch[AGG_MAXPLAYCH];
- struct agg_chinfo rch;
-};
-
-
-static u_int32_t agg_rdcodec(void *, int);
-static void agg_wrcodec(void *, int, u_int32_t);
-
-static inline void ringbus_setdest(struct agg_info*, int, int);
-
-static inline u_int16_t wp_rdreg(struct agg_info*, u_int16_t);
-static inline void wp_wrreg(struct agg_info*, u_int16_t, u_int16_t);
-static inline u_int16_t wp_rdapu(struct agg_info*, int, u_int16_t);
-static inline void wp_wrapu(struct agg_info*, int, u_int16_t, u_int16_t);
-static inline void wp_settimer(struct agg_info*, u_int);
-static inline void wp_starttimer(struct agg_info*);
-static inline void wp_stoptimer(struct agg_info*);
-
-static inline u_int16_t wc_rdreg(struct agg_info*, u_int16_t);
-static inline void wc_wrreg(struct agg_info*, u_int16_t, u_int16_t);
-static inline u_int16_t wc_rdchctl(struct agg_info*, int);
-static inline void wc_wrchctl(struct agg_info*, int, u_int16_t);
-
-static inline void agg_power(struct agg_info*, int);
-
-static void agg_init(struct agg_info*);
-static u_int32_t agg_ac97_init(void *);
-
-static void aggch_start_dac(struct agg_chinfo*);
-static void aggch_stop_dac(struct agg_chinfo*);
-
-static inline void suppress_jitter(struct agg_chinfo*);
-
-static inline u_int calc_timer_freq(struct agg_chinfo*);
-static void set_timer(struct agg_info*);
-
-static pcmchan_init_t aggch_init;
-static pcmchan_free_t aggch_free;
-static pcmchan_setformat_t aggch_setplayformat;
-static pcmchan_setspeed_t aggch_setspeed;
-static pcmchan_setblocksize_t aggch_setblocksize;
-static pcmchan_trigger_t aggch_trigger;
-static pcmchan_getptr_t aggch_getplayptr;
-static pcmchan_getcaps_t aggch_getcaps;
-
-static void agg_intr(void *);
-static int agg_probe(device_t);
-static int agg_attach(device_t);
-static int agg_detach(device_t);
-static int agg_suspend(device_t);
-static int agg_resume(device_t);
-static int agg_shutdown(device_t);
-
-static void *dma_malloc(struct agg_info*, u_int32_t, bus_addr_t*);
-static void dma_free(struct agg_info*, void *);
-
-/* -----------------------------
- * Subsystems.
- */
-
-/* Codec/Ringbus */
-
-static u_int32_t
-agg_rdcodec(void *sc, int regno)
-{
- struct agg_info *ess = sc;
- unsigned t;
-
- /* We have to wait for a SAFE time to write addr/data */
- for (t = 0; t < 20; t++) {
- if ((bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
- & CODEC_STAT_MASK) != CODEC_STAT_PROGLESS)
- break;
- DELAY(2); /* 20.8us / 13 */
- }
- if (t == 20)
- device_printf(ess->dev, "agg_rdcodec() PROGLESS timed out.\n");
-
- bus_space_write_1(ess->st, ess->sh, PORT_CODEC_CMD,
- CODEC_CMD_READ | regno);
- DELAY(21); /* AC97 cycle = 20.8usec */
-
- /* Wait for data retrieve */
- for (t = 0; t < 20; t++) {
- if ((bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
- & CODEC_STAT_MASK) == CODEC_STAT_RW_DONE)
- break;
- DELAY(2); /* 20.8us / 13 */
- }
- if (t == 20)
- /* Timed out, but perform dummy read. */
- device_printf(ess->dev, "agg_rdcodec() RW_DONE timed out.\n");
-
- return bus_space_read_2(ess->st, ess->sh, PORT_CODEC_REG);
-}
-
-static void
-agg_wrcodec(void *sc, int regno, u_int32_t data)
-{
- unsigned t;
- struct agg_info *ess = sc;
-
- /* We have to wait for a SAFE time to write addr/data */
- for (t = 0; t < 20; t++) {
- if ((bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
- & CODEC_STAT_MASK) != CODEC_STAT_PROGLESS)
- break;
- DELAY(2); /* 20.8us / 13 */
- }
- if (t == 20) {
- /* Timed out. Abort writing. */
- device_printf(ess->dev, "agg_wrcodec() PROGLESS timed out.\n");
- return;
- }
-
- bus_space_write_2(ess->st, ess->sh, PORT_CODEC_REG, data);
- bus_space_write_1(ess->st, ess->sh, PORT_CODEC_CMD,
- CODEC_CMD_WRITE | regno);
-}
-
-static inline void
-ringbus_setdest(struct agg_info *ess, int src, int dest)
-{
- u_int32_t data;
-
- data = bus_space_read_4(ess->st, ess->sh, PORT_RINGBUS_CTRL);
- data &= ~(0xfU << src);
- data |= (0xfU & dest) << src;
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, data);
-}
-
-/* Wave Processor */
-
-static inline u_int16_t
-wp_rdreg(struct agg_info *ess, u_int16_t reg)
-{
- bus_space_write_2(ess->st, ess->sh, PORT_DSP_INDEX, reg);
- return bus_space_read_2(ess->st, ess->sh, PORT_DSP_DATA);
-}
-
-static inline void
-wp_wrreg(struct agg_info *ess, u_int16_t reg, u_int16_t data)
-{
- bus_space_write_2(ess->st, ess->sh, PORT_DSP_INDEX, reg);
- bus_space_write_2(ess->st, ess->sh, PORT_DSP_DATA, data);
-}
-
-static inline void
-apu_setindex(struct agg_info *ess, u_int16_t reg)
-{
- int t;
-
- wp_wrreg(ess, WPREG_CRAM_PTR, reg);
- /* Sometimes WP fails to set apu register index. */
- for (t = 0; t < 1000; t++) {
- if (bus_space_read_2(ess->st, ess->sh, PORT_DSP_DATA) == reg)
- break;
- bus_space_write_2(ess->st, ess->sh, PORT_DSP_DATA, reg);
- }
- if (t == 1000)
- device_printf(ess->dev, "apu_setindex() timed out.\n");
-}
-
-static inline u_int16_t
-wp_rdapu(struct agg_info *ess, int ch, u_int16_t reg)
-{
- u_int16_t ret;
-
- apu_setindex(ess, ((unsigned)ch << 4) + reg);
- ret = wp_rdreg(ess, WPREG_DATA_PORT);
- return ret;
-}
-
-static inline void
-wp_wrapu(struct agg_info *ess, int ch, u_int16_t reg, u_int16_t data)
-{
- int t;
-
- apu_setindex(ess, ((unsigned)ch << 4) + reg);
- wp_wrreg(ess, WPREG_DATA_PORT, data);
- for (t = 0; t < 1000; t++) {
- if (bus_space_read_2(ess->st, ess->sh, PORT_DSP_DATA) == data)
- break;
- bus_space_write_2(ess->st, ess->sh, PORT_DSP_DATA, data);
- }
- if (t == 1000)
- device_printf(ess->dev, "wp_wrapu() timed out.\n");
-}
-
-static inline void
-wp_settimer(struct agg_info *ess, u_int freq)
-{
- u_int clock = 48000 << 2;
- u_int prescale = 0, divide = (freq != 0) ? (clock / freq) : ~0;
-
- RANGE(divide, 4, 32 << 8);
-
- for (; divide > 32 << 1; divide >>= 1)
- prescale++;
- divide = (divide + 1) >> 1;
-
- for (; prescale < 7 && divide > 2 && !(divide & 1); divide >>= 1)
- prescale++;
-
- wp_wrreg(ess, WPREG_TIMER_ENABLE, 0);
- wp_wrreg(ess, WPREG_TIMER_FREQ,
- (prescale << WP_TIMER_FREQ_PRESCALE_SHIFT) | (divide - 1));
- wp_wrreg(ess, WPREG_TIMER_ENABLE, 1);
-}
-
-static inline void
-wp_starttimer(struct agg_info *ess)
-{
- wp_wrreg(ess, WPREG_TIMER_START, 1);
-}
-
-static inline void
-wp_stoptimer(struct agg_info *ess)
-{
- wp_wrreg(ess, WPREG_TIMER_START, 0);
- bus_space_write_2(ess->st, ess->sh, PORT_INT_STAT, 1);
-}
-
-/* WaveCache */
-
-static inline u_int16_t
-wc_rdreg(struct agg_info *ess, u_int16_t reg)
-{
- bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_INDEX, reg);
- return bus_space_read_2(ess->st, ess->sh, PORT_WAVCACHE_DATA);
-}
-
-static inline void
-wc_wrreg(struct agg_info *ess, u_int16_t reg, u_int16_t data)
-{
- bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_INDEX, reg);
- bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_DATA, data);
-}
-
-static inline u_int16_t
-wc_rdchctl(struct agg_info *ess, int ch)
-{
- return wc_rdreg(ess, ch << 3);
-}
-
-static inline void
-wc_wrchctl(struct agg_info *ess, int ch, u_int16_t data)
-{
- wc_wrreg(ess, ch << 3, data);
-}
-
-/* Power management */
-
-static inline void
-agg_power(struct agg_info *ess, int status)
-{
- u_int8_t data;
-
- data = pci_read_config(ess->dev, CONF_PM_PTR, 1);
- if (pci_read_config(ess->dev, data, 1) == PPMI_CID)
- pci_write_config(ess->dev, data + PM_CTRL, status, 1);
-}
-
-
-/* -----------------------------
- * Controller.
- */
-
-static inline void
-agg_initcodec(struct agg_info* ess)
-{
- u_int16_t data;
-
- if (bus_space_read_4(ess->st, ess->sh, PORT_RINGBUS_CTRL)
- & RINGBUS_CTRL_ACLINK_ENABLED) {
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
- DELAY(104); /* 20.8us * (4 + 1) */
- }
- /* XXX - 2nd codec should be looked at. */
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
- RINGBUS_CTRL_AC97_SWRESET);
- DELAY(2);
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
- RINGBUS_CTRL_ACLINK_ENABLED);
- DELAY(21);
-
- agg_rdcodec(ess, 0);
- if (bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT)
- & CODEC_STAT_MASK) {
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
- DELAY(21);
-
- /* Try cold reset. */
- device_printf(ess->dev, "will perform cold reset.\n");
- data = bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR);
- if (pci_read_config(ess->dev, 0x58, 2) & 1)
- data |= 0x10;
- data |= 0x009 &
- ~bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DATA);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK, 0xff6);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR,
- data | 0x009);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x000);
- DELAY(2);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x001);
- DELAY(1);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x009);
- DELAY(500000);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR, data);
- DELAY(84); /* 20.8us * 4 */
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
- RINGBUS_CTRL_ACLINK_ENABLED);
- DELAY(21);
- }
-}
-
-static void
-agg_init(struct agg_info* ess)
-{
- u_int32_t data;
-
- /* Setup PCI config registers. */
-
- /* Disable all legacy emulations. */
- data = pci_read_config(ess->dev, CONF_LEGACY, 2);
- data |= LEGACY_DISABLED;
- pci_write_config(ess->dev, CONF_LEGACY, data, 2);
-
- /* Disconnect from CHI. (Makes Dell inspiron 7500 work?)
- * Enable posted write.
- * Prefer PCI timing rather than that of ISA.
- * Don't swap L/R. */
- data = pci_read_config(ess->dev, CONF_MAESTRO, 4);
- data |= MAESTRO_CHIBUS | MAESTRO_POSTEDWRITE | MAESTRO_DMA_PCITIMING;
- data &= ~MAESTRO_SWAP_LR;
- pci_write_config(ess->dev, CONF_MAESTRO, data, 4);
-
- /* Reset direct sound. */
- bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL,
- HOSTINT_CTRL_DSOUND_RESET);
- DELAY(10000); /* XXX - too long? */
- bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0);
- DELAY(10000);
-
- /* Enable direct sound interruption. */
- bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL,
- HOSTINT_CTRL_DSOUND_INT_ENABLED);
-
- /* Setup Wave Processor. */
-
- /* Enable WaveCache, set DMA base address. */
- wp_wrreg(ess, WPREG_WAVE_ROMRAM,
- WP_WAVE_VIRTUAL_ENABLED | WP_WAVE_DRAM_ENABLED);
- bus_space_write_2(ess->st, ess->sh, PORT_WAVCACHE_CTRL,
- WAVCACHE_ENABLED | WAVCACHE_WTSIZE_4MB);
-
- for (data = WAVCACHE_PCMBAR; data < WAVCACHE_PCMBAR + 4; data++)
- wc_wrreg(ess, data, ess->baseaddr >> WAVCACHE_BASEADDR_SHIFT);
-
- /* Setup Codec/Ringbus. */
- agg_initcodec(ess);
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL,
- RINGBUS_CTRL_RINGBUS_ENABLED | RINGBUS_CTRL_ACLINK_ENABLED);
-
- wp_wrreg(ess, WPREG_BASE, 0x8500); /* Parallel I/O */
- ringbus_setdest(ess, RINGBUS_SRC_ADC,
- RINGBUS_DEST_STEREO | RINGBUS_DEST_DSOUND_IN);
- ringbus_setdest(ess, RINGBUS_SRC_DSOUND,
- RINGBUS_DEST_STEREO | RINGBUS_DEST_DAC);
-
- /* Setup ASSP. Needed for Dell Inspiron 7500? */
- bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CTRL_B, 0x00);
- bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CTRL_A, 0x03);
- bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CTRL_C, 0x00);
-
- /*
- * Setup GPIO.
- * There seems to be speciality with NEC systems.
- */
- switch (pci_get_subvendor(ess->dev)
- | (pci_get_subdevice(ess->dev) << 16)) {
- case NEC_SUBID1:
- case NEC_SUBID2:
- /* Matthew Braithwaite <matt@braithwaite.net> reported that
- * NEC Versa LX doesn't need GPIO operation. */
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK, 0x9ff);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR,
- bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR) | 0x600);
- bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x200);
- break;
- }
-}
-
-/* Channel controller. */
-
-static void
-aggch_start_dac(struct agg_chinfo *ch)
-{
- u_int wpwa = APU_USE_SYSMEM | (ch->offset >> 9);
- u_int size = AGG_BUFSIZ >> 1;
- u_int speed = ch->channel->speed;
- u_int offset = ch->offset >> 1;
- u_int cp = ch->buffer->rp >> 1;
- u_int16_t apuch = ch->num << 1;
- u_int dv;
- int pan = 0;
-
- switch (ch->aputype) {
- case APUTYPE_16BITSTEREO:
- wpwa >>= 1;
- size >>= 1;
- offset >>= 1;
- cp >>= 1;
- /* FALLTHROUGH */
- case APUTYPE_8BITSTEREO:
- pan = 8;
- apuch++;
- break;
- case APUTYPE_8BITLINEAR:
- speed >>= 1;
- break;
- }
-
- dv = (((speed % 48000) << 16) + 24000) / 48000
- + ((speed / 48000) << 16);
-
- do {
- wp_wrapu(ch->parent, apuch, APUREG_WAVESPACE, wpwa & 0xff00);
- wp_wrapu(ch->parent, apuch, APUREG_CURPTR, offset + cp);
- wp_wrapu(ch->parent, apuch, APUREG_ENDPTR, offset + size);
- wp_wrapu(ch->parent, apuch, APUREG_LOOPLEN, size);
- wp_wrapu(ch->parent, apuch, APUREG_AMPLITUDE, 0xe800);
- wp_wrapu(ch->parent, apuch, APUREG_POSITION, 0x8f00
- | (RADIUS_CENTERCIRCLE << APU_RADIUS_SHIFT)
- | ((PAN_FRONT + pan) << APU_PAN_SHIFT));
- wp_wrapu(ch->parent, apuch, APUREG_FREQ_LOBYTE, APU_plus6dB
- | ((dv & 0xff) << APU_FREQ_LOBYTE_SHIFT));
- wp_wrapu(ch->parent, apuch, APUREG_FREQ_HIWORD, dv >> 8);
-
- if (ch->aputype == APUTYPE_16BITSTEREO)
- wpwa |= APU_STEREO >> 1;
- pan = -pan;
- } while (pan < 0 && apuch--);
-
- wc_wrchctl(ch->parent, apuch, ch->wcreg_tpl);
- wc_wrchctl(ch->parent, apuch + 1, ch->wcreg_tpl);
-
- wp_wrapu(ch->parent, apuch, APUREG_APUTYPE,
- (ch->aputype << APU_APUTYPE_SHIFT) | APU_DMA_ENABLED | 0xf);
- if (ch->wcreg_tpl & WAVCACHE_CHCTL_STEREO)
- wp_wrapu(ch->parent, apuch + 1, APUREG_APUTYPE,
- (ch->aputype << APU_APUTYPE_SHIFT) | APU_DMA_ENABLED | 0xf);
-}
-
-static void
-aggch_stop_dac(struct agg_chinfo *ch)
-{
- wp_wrapu(ch->parent, (ch->num << 1), APUREG_APUTYPE,
- APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
- wp_wrapu(ch->parent, (ch->num << 1) + 1, APUREG_APUTYPE,
- APUTYPE_INACTIVE << APU_APUTYPE_SHIFT);
-}
-
-/*
- * Stereo jitter suppressor.
- * Sometimes playback pointers differ in stereo-paired channels.
- * Calling this routine within intr fixes the problem.
- */
-static inline void
-suppress_jitter(struct agg_chinfo *ch)
-{
- if (ch->wcreg_tpl & WAVCACHE_CHCTL_STEREO) {
- int cp, diff, halfsize = AGG_BUFSIZ >> 2;
-
- if (ch->aputype == APUTYPE_16BITSTEREO)
- halfsize >>= 1;
- cp = wp_rdapu(ch->parent, (ch->num << 1), APUREG_CURPTR);
- diff = wp_rdapu(ch->parent, (ch->num << 1) + 1, APUREG_CURPTR);
- diff -= cp;
- if (diff >> 1 && diff > -halfsize && diff < halfsize)
- bus_space_write_2(ch->parent->st, ch->parent->sh,
- PORT_DSP_DATA, cp);
- }
-}
-
-static inline u_int
-calc_timer_freq(struct agg_chinfo *ch)
-{
- u_int ss = 2;
-
- if (ch->aputype == APUTYPE_16BITSTEREO)
- ss <<= 1;
- if (ch->aputype == APUTYPE_8BITLINEAR)
- ss >>= 1;
-
- return (ch->channel->speed * ss + ch->blocksize - 1) / ch->blocksize;
-}
-
-static void
-set_timer(struct agg_info *ess)
-{
- int i;
- u_int freq = 0;
-
- for (i = 0; i < ess->playchns; i++)
- if ((ess->active & (1 << i)) &&
- (freq < calc_timer_freq(ess->pch + i)))
- freq = calc_timer_freq(ess->pch + i);
-
- wp_settimer(ess, freq);
-}
-
-
-/* -----------------------------
- * Newpcm glue.
- */
-
-static u_int32_t
-agg_ac97_init(void *sc)
-{
- struct agg_info *ess = sc;
-
- return (bus_space_read_1(ess->st, ess->sh, PORT_CODEC_STAT) & CODEC_STAT_MASK)? 0 : 1;
-}
-
-static void *
-aggch_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct agg_info *ess = devinfo;
- struct agg_chinfo *ch;
- bus_addr_t physaddr;
-
- ch = (dir == PCMDIR_PLAY)? ess->pch + ess->playchns : &ess->rch;
-
- ch->parent = ess;
- ch->channel = c;
- ch->buffer = b;
- ch->num = ess->playchns;
- ch->dir = dir;
-
- b->buf = dma_malloc(ess, AGG_BUFSIZ, &physaddr);
- if (b->buf == NULL)
- return NULL;
-
- ch->offset = physaddr - ess->baseaddr;
- if (physaddr < ess->baseaddr || ch->offset > WPWA_MAXADDR) {
- device_printf(ess->dev,
- "offset %#x exceeds limit. ", ch->offset);
- dma_free(ess, b->buf);
- b->buf = NULL;
- return NULL;
- }
-
- b->bufsize = AGG_BUFSIZ;
- ch->wcreg_tpl = (physaddr - 16) & WAVCACHE_CHCTL_ADDRTAG_MASK;
-
- if (dir == PCMDIR_PLAY) {
- ess->playchns++;
- if (bootverbose)
- device_printf(ess->dev, "pch[%d].offset = %#x\n", ch->num, ch->offset);
- } else if (bootverbose)
- device_printf(ess->dev, "rch.offset = %#x\n", ch->offset);
-
- return ch;
-}
-
-static int
-aggch_free(void *data)
-{
- struct agg_chinfo *ch = data;
- struct agg_info *ess = ch->parent;
-
- /* free up buffer - called after channel stopped */
- dma_free(ess, ch->buffer->buf);
-
- /* return 0 if ok */
- return 0;
-}
-
-static int
-aggch_setplayformat(void *data, u_int32_t format)
-{
- struct agg_chinfo *ch = data;
- u_int16_t wcreg_tpl;
- u_int16_t aputype = APUTYPE_16BITLINEAR;
-
- wcreg_tpl = ch->wcreg_tpl & WAVCACHE_CHCTL_ADDRTAG_MASK;
-
- if (format & AFMT_STEREO) {
- wcreg_tpl |= WAVCACHE_CHCTL_STEREO;
- aputype += 1;
- }
- if (format & AFMT_U8 || format & AFMT_S8) {
- aputype += 2;
- if (format & AFMT_U8)
- wcreg_tpl |= WAVCACHE_CHCTL_U8;
- }
- if (format & AFMT_BIGENDIAN || format & AFMT_U16_LE) {
- format &= ~AFMT_BIGENDIAN & ~AFMT_U16_LE;
- format |= AFMT_S16_LE;
- }
- ch->wcreg_tpl = wcreg_tpl;
- ch->aputype = aputype;
- return format;
-}
-
-static int
-aggch_setspeed(void *data, u_int32_t speed)
-{
- return speed;
-}
-
-static int
-aggch_setblocksize(void *data, u_int32_t blocksize)
-{
- return ((struct agg_chinfo*)data)->blocksize = blocksize;
-}
-
-static int
-aggch_trigger(void *data, int go)
-{
- struct agg_chinfo *ch = data;
-
- switch (go) {
- case PCMTRIG_EMLDMAWR:
- return 0;
- case PCMTRIG_START:
- ch->parent->active |= (1 << ch->num);
- if (ch->dir == PCMDIR_PLAY)
- aggch_start_dac(ch);
-#if 0 /* XXX - RECORDING */
- else
- aggch_start_adc(ch);
-#endif
- break;
- case PCMTRIG_ABORT:
- case PCMTRIG_STOP:
- ch->parent->active &= ~(1 << ch->num);
- if (ch->dir == PCMDIR_PLAY)
- aggch_stop_dac(ch);
-#if 0 /* XXX - RECORDING */
- else
- aggch_stop_adc(ch);
-#endif
- break;
- }
-
- if (ch->parent->active) {
- set_timer(ch->parent);
- wp_starttimer(ch->parent);
- } else
- wp_stoptimer(ch->parent);
-
- return 0;
-}
-
-static int
-aggch_getplayptr(void *data)
-{
- struct agg_chinfo *ch = data;
- u_int cp;
-
- cp = wp_rdapu(ch->parent, (ch->num << 1), APUREG_CURPTR);
- if (ch->aputype == APUTYPE_16BITSTEREO)
- cp = (0xffff << 2) & ((cp << 2) - ch->offset);
- else
- cp = (0xffff << 1) & ((cp << 1) - ch->offset);
-
- return cp;
-}
-
-static pcmchan_caps *
-aggch_getcaps(void *data)
-{
- static u_int32_t playfmt[] = {
- AFMT_U8,
- AFMT_STEREO | AFMT_U8,
- AFMT_S8,
- AFMT_STEREO | AFMT_S8,
- AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE,
- 0
- };
- static pcmchan_caps playcaps = {2000, 96000, playfmt, 0};
-
- static u_int32_t recfmt[] = {
- AFMT_S8,
- AFMT_STEREO | AFMT_S8,
- AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE,
- 0
- };
- static pcmchan_caps reccaps = {4000, 48000, recfmt, 0};
-
- return (((struct agg_chinfo*)data)->dir == PCMDIR_PLAY)?
- &playcaps : &reccaps;
-}
-
-
-/* -----------------------------
- * Bus space.
- */
-
-static void
-agg_intr(void *sc)
-{
- struct agg_info* ess = sc;
- u_int16_t status;
- int i;
-
- status = bus_space_read_1(ess->st, ess->sh, PORT_HOSTINT_STAT);
- if (!status)
- return;
-
- /* Acknowledge all. */
- bus_space_write_2(ess->st, ess->sh, PORT_INT_STAT, 1);
- bus_space_write_1(ess->st, ess->sh, PORT_HOSTINT_STAT, 0);
-#if 0 /* XXX - HWVOL */
- if (status & HOSTINT_STAT_HWVOL) {
- u_int delta;
- delta = bus_space_read_1(ess->st, ess->sh, PORT_HWVOL_MASTER)
- - 0x88;
- if (delta & 0x11)
- mixer_set(device_get_softc(ess->dev),
- SOUND_MIXER_VOLUME, 0);
- else {
- mixer_set(device_get_softc(ess->dev),
- SOUND_MIXER_VOLUME,
- mixer_get(device_get_softc(ess->dev),
- SOUND_MIXER_VOLUME)
- + ((delta >> 5) & 0x7) - 4
- + ((delta << 7) & 0x700) - 0x400);
- }
- bus_space_write_1(ess->st, ess->sh, PORT_HWVOL_MASTER, 0x88);
- }
-#endif /* XXX - HWVOL */
-
- for (i = 0; i < ess->playchns; i++)
- if (ess->active & (1 << i)) {
- suppress_jitter(ess->pch + i);
- chn_intr(ess->pch[i].channel);
- }
-#if 0 /* XXX - RECORDING */
- if (ess->active & (1 << i))
- chn_intr(ess->rch.channel);
-#endif
-}
-
-static void
-setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- bus_addr_t *phys = arg;
-
- *phys = error? 0 : segs->ds_addr;
-
- if (bootverbose) {
- printf("setmap (%lx, %lx), nseg=%d, error=%d\n",
- (unsigned long)segs->ds_addr, (unsigned long)segs->ds_len,
- nseg, error);
- }
-}
-
-static void *
-dma_malloc(struct agg_info *sc, u_int32_t sz, bus_addr_t *phys)
-{
- void *buf;
- bus_dmamap_t map;
-
- if (bus_dmamem_alloc(sc->parent_dmat, &buf, BUS_DMA_NOWAIT, &map))
- return NULL;
- if (bus_dmamap_load(sc->parent_dmat, map, buf, sz, setmap, phys, 0)
- || !*phys) {
- bus_dmamem_free(sc->parent_dmat, buf, map);
- return NULL;
- }
- return buf;
-}
-
-static void
-dma_free(struct agg_info *sc, void *buf)
-{
- bus_dmamem_free(sc->parent_dmat, buf, NULL);
-}
-
-static int
-agg_probe(device_t dev)
-{
- char *s = NULL;
-
- switch (pci_get_devid(dev)) {
- case MAESTRO_1_PCI_ID:
- s = "ESS Technology Maestro-1";
- break;
-
- case MAESTRO_2_PCI_ID:
- s = "ESS Technology Maestro-2";
- break;
-
- case MAESTRO_2E_PCI_ID:
- s = "ESS Technology Maestro-2E";
- break;
- }
-
- if (s != NULL && pci_get_class(dev) == PCIC_MULTIMEDIA) {
- device_set_desc(dev, s);
- return 0;
- }
- return ENXIO;
-}
-
-static int
-agg_attach(device_t dev)
-{
- struct agg_info *ess = NULL;
- u_int32_t data;
- int mapped = 0;
- int regid = PCIR_MAPS;
- struct resource *reg = NULL;
- struct ac97_info *codec = NULL;
- int irqid = 0;
- struct resource *irq = NULL;
- void *ih = NULL;
- char status[SND_STATUSLEN];
- static pcm_channel agg_pchtpl = {
- aggch_init,
- NULL, /* setdir */
- aggch_setplayformat,
- aggch_setspeed,
- aggch_setblocksize,
- aggch_trigger,
- aggch_getplayptr,
- aggch_getcaps,
- aggch_free, /* free */
- NULL, /* nop1 */
- NULL, /* nop2 */
- NULL, /* nop3 */
- NULL, /* nop4 */
- NULL, /* nop5 */
- NULL, /* nop6 */
- NULL, /* nop7 */
- };
-
- if ((ess = malloc(sizeof *ess, M_DEVBUF, M_NOWAIT)) == NULL) {
- device_printf(dev, "cannot allocate softc\n");
- return ENXIO;
- }
- bzero(ess, sizeof *ess);
- ess->dev = dev;
-
- if (bus_dma_tag_create(/*parent*/NULL,
- /*alignment*/1 << WAVCACHE_BASEADDR_SHIFT,
- /*boundary*/WPWA_MAXADDR + 1,
- /*lowaddr*/MAESTRO_MAXADDR, /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/AGG_BUFSIZ * 2, /*nsegments*/1, /*maxsegz*/0x3ffff,
- /*flags*/0, &ess->parent_dmat) != 0) {
- device_printf(dev, "unable to create dma tag\n");
- goto bad;
- }
-
- ess->stat = dma_malloc(ess, AGG_BUFSIZ, &ess->baseaddr);
- if (ess->stat == NULL) {
- device_printf(dev, "cannot allocate status buffer\n");
- goto bad;
- }
- if (bootverbose)
- device_printf(dev, "Maestro DMA base: %#x\n", ess->baseaddr);
-
- agg_power(ess, PPMI_D0);
- DELAY(100000);
-
- data = pci_read_config(dev, PCIR_COMMAND, 2);
- data |= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCIR_COMMAND, data, 2);
- data = pci_read_config(dev, PCIR_COMMAND, 2);
-
- if (data & PCIM_CMD_PORTEN) {
- reg = bus_alloc_resource(dev, SYS_RES_IOPORT, &regid,
- 0, BUS_SPACE_UNRESTRICTED, 256, RF_ACTIVE);
- if (reg != NULL) {
- ess->reg = reg;
- ess->regid = regid;
- ess->st = rman_get_bustag(reg);
- ess->sh = rman_get_bushandle(reg);
- mapped++;
- }
- }
- if (mapped == 0) {
- device_printf(dev, "unable to map register space\n");
- goto bad;
- }
-
- agg_init(ess);
- if (agg_rdcodec(ess, 0) == 0x80) {
- device_printf(dev, "PT101 codec detected!\n");
- goto bad;
- }
- codec = ac97_create(dev, ess, agg_ac97_init, agg_rdcodec, agg_wrcodec);
- if (codec == NULL)
- goto bad;
- if (mixer_init(dev, &ac97_mixer, codec) == -1)
- goto bad;
- ess->codec = codec;
-
- irq = bus_alloc_resource(dev, SYS_RES_IRQ, &irqid,
- 0, BUS_SPACE_UNRESTRICTED, 1, RF_ACTIVE | RF_SHAREABLE);
- if (irq == NULL
- || bus_setup_intr(dev, irq, INTR_TYPE_TTY, agg_intr, ess, &ih)) {
- device_printf(dev, "unable to map interrupt\n");
- goto bad;
- }
- ess->irq = irq;
- ess->irqid = irqid;
- ess->ih = ih;
-
- snprintf(status, SND_STATUSLEN, "at I/O port 0x%lx irq %ld",
- rman_get_start(reg), rman_get_start(irq));
-
- if (pcm_register(dev, ess, AGG_MAXPLAYCH, 1))
- goto bad;
-
- for (data = 0; data < AGG_MAXPLAYCH; data++)
- pcm_addchan(dev, PCMDIR_PLAY, &agg_pchtpl, ess);
-#if 0 /* XXX - RECORDING */
- pcm_addchan(dev, PCMDIR_REC, &agg_rchtpl, ess);
-#endif
- pcm_setstatus(dev, status);
-
- return 0;
-
- bad:
- if (codec != NULL)
- ac97_destroy(codec);
- if (ih != NULL)
- bus_teardown_intr(dev, irq, ih);
- if (irq != NULL)
- bus_release_resource(dev, SYS_RES_IRQ, irqid, irq);
- if (reg != NULL)
- bus_release_resource(dev, SYS_RES_IOPORT, regid, reg);
- if (ess != NULL) {
- agg_power(ess, PPMI_D3);
- if (ess->stat != NULL)
- dma_free(ess, ess->stat);
- if (ess->parent_dmat != NULL)
- bus_dma_tag_destroy(ess->parent_dmat);
- free(ess, M_DEVBUF);
- }
-
- return ENXIO;
-}
-
-static int
-agg_detach(device_t dev)
-{
- struct agg_info *ess = pcm_getdevinfo(dev);
- int r;
-
- r = pcm_unregister(dev);
- if (r)
- return r;
-
- ess = pcm_getdevinfo(dev);
- dma_free(ess, ess->stat);
-
- /* Power down everything except clock and vref. */
- agg_wrcodec(ess, AC97_REG_POWER, 0xd700);
- DELAY(20);
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
- agg_power(ess, PPMI_D3);
-
- bus_teardown_intr(dev, ess->irq, ess->ih);
- bus_release_resource(dev, SYS_RES_IRQ, ess->irqid, ess->irq);
- bus_release_resource(dev, SYS_RES_IOPORT, ess->regid, ess->reg);
- bus_dma_tag_destroy(ess->parent_dmat);
- free(ess, M_DEVBUF);
- return 0;
-}
-
-static int
-agg_suspend(device_t dev)
-{
- struct agg_info *ess = pcm_getdevinfo(dev);
- int i, x;
-
- x = spltty();
- wp_stoptimer(ess);
- bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0);
-
- for (i = 0; i < ess->playchns; i++)
- aggch_stop_dac(ess->pch + i);
-
-#if 0 /* XXX - RECORDING */
- aggch_stop_adc(&ess->rch);
-#endif
- splx(x);
- /* Power down everything except clock. */
- agg_wrcodec(ess, AC97_REG_POWER, 0xdf00);
- DELAY(20);
- bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
- DELAY(1);
- agg_power(ess, PPMI_D3);
-
- return 0;
-}
-
-static int
-agg_resume(device_t dev)
-{
- int i, x;
- struct agg_info *ess = pcm_getdevinfo(dev);
-
- agg_power(ess, PPMI_D0);
- DELAY(100000);
- agg_init(ess);
- if (mixer_reinit(dev)) {
- device_printf(dev, "unable to reinitialize the mixer\n");
- return ENXIO;
- }
-
- x = spltty();
- for (i = 0; i < ess->playchns; i++)
- if (ess->active & (1 << i))
- aggch_start_dac(ess->pch + i);
-#if 0 /* XXX - RECORDING */
- if (ess->active & (1 << i))
- aggch_start_adc(&ess->rch);
-#endif
- if (ess->active) {
- set_timer(ess);
- wp_starttimer(ess);
- }
- splx(x);
- return 0;
-}
-
-static int
-agg_shutdown(device_t dev)
-{
- struct agg_info *ess = pcm_getdevinfo(dev);
- int i;
-
- wp_stoptimer(ess);
- bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0);
-
- for (i = 0; i < ess->playchns; i++)
- aggch_stop_dac(ess->pch + i);
-
-#if 0 /* XXX - RECORDING */
- aggch_stop_adc(&ess->rch);
-#endif
- return 0;
-}
-
-
-static device_method_t agg_methods[] = {
- DEVMETHOD(device_probe, agg_probe),
- DEVMETHOD(device_attach, agg_attach),
- DEVMETHOD(device_detach, agg_detach),
- DEVMETHOD(device_suspend, agg_suspend),
- DEVMETHOD(device_resume, agg_resume),
- DEVMETHOD(device_shutdown, agg_shutdown),
-
- { 0, 0 }
-};
-
-static driver_t agg_driver = {
- "pcm",
- agg_methods,
- sizeof(snddev_info),
-};
-
-static devclass_t pcm_devclass;
-
-DRIVER_MODULE(snd_maestro, pci, agg_driver, pcm_devclass, 0, 0);
-MODULE_DEPEND(snd_maestro, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
-MODULE_VERSION(snd_maestro, 1);
diff --git a/sys/dev/sound/pci/maestro_reg.h b/sys/dev/sound/pci/maestro_reg.h
deleted file mode 100644
index 579723388d8ed..0000000000000
--- a/sys/dev/sound/pci/maestro_reg.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/*-
- * Copyright (c) 1999-2000 Taku YAMAMOTO <taku@cent.saitama-u.ac.jp>
- * 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.
- *
- * 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: maestro_reg.h,v 1.10 2000/08/29 17:27:29 taku Exp $
- * $FreeBSD$
- */
-
-#ifndef MAESTRO_REG_H_INCLUDED
-#define MAESTRO_REG_H_INCLUDED
-
-/* -----------------------------
- * PCI config registers
- */
-
-/* Legacy emulation */
-#define CONF_LEGACY 0x40
-
-#define LEGACY_DISABLED 0x8000
-
-/* Chip configurations */
-#define CONF_MAESTRO 0x50
-#define MAESTRO_CHIBUS 0x00100000
-#define MAESTRO_POSTEDWRITE 0x00000080
-#define MAESTRO_DMA_PCITIMING 0x00000040
-#define MAESTRO_SWAP_LR 0x00000010
-
-/* ACPI configurations */
-#define CONF_ACPI_STOPCLOCK 0x54
-#define ACPI_PART_2ndC_CLOCK 15
-#define ACPI_PART_CODEC_CLOCK 14
-#define ACPI_PART_978 13 /* Docking station or something */
-#define ACPI_PART_SPDIF 12
-#define ACPI_PART_GLUE 11 /* What? */
-#define ACPI_PART_DAA 10
-#define ACPI_PART_PCI_IF 9
-#define ACPI_PART_HW_VOL 8
-#define ACPI_PART_GPIO 7
-#define ACPI_PART_ASSP 6
-#define ACPI_PART_SB 5
-#define ACPI_PART_FM 4
-#define ACPI_PART_RINGBUS 3
-#define ACPI_PART_MIDI 2
-#define ACPI_PART_GAME_PORT 1
-#define ACPI_PART_WP 0
-
-/* Power management */
-#define CONF_PM_PTR 0x34 /* BYTE R */
-#define PM_CID 0 /* BYTE R */
-#define PPMI_CID 1
-#define PM_CTRL 4 /* BYTE RW */
-#define PPMI_D0 0 /* Full power */
-#define PPMI_D1 1 /* Medium power */
-#define PPMI_D2 2 /* Low power */
-#define PPMI_D3 3 /* Turned off */
-
-
-/* -----------------------------
- * I/O ports
- */
-
-/* Direct Sound Processor (aka WP) */
-#define PORT_DSP_DATA 0x00 /* WORD RW */
-#define PORT_DSP_INDEX 0x02 /* WORD RW */
-#define PORT_INT_STAT 0x04 /* WORD RW */
-#define PORT_SAMPLE_CNT 0x06 /* WORD RO */
-
-/* WaveCache */
-#define PORT_WAVCACHE_INDEX 0x10 /* WORD RW */
-#define PORT_WAVCACHE_DATA 0x12 /* WORD RW */
-#define WAVCACHE_PCMBAR 0x1fc
-#define WAVCACHE_WTBAR 0x1f0
-#define WAVCACHE_BASEADDR_SHIFT 12
-
-#define WAVCACHE_CHCTL_ADDRTAG_MASK 0xfff8
-#define WAVCACHE_CHCTL_U8 0x0004
-#define WAVCACHE_CHCTL_STEREO 0x0002
-#define WAVCACHE_CHCTL_DECREMENTAL 0x0001
-
-#define PORT_WAVCACHE_CTRL 0x14 /* WORD RW */
-#define WAVCACHE_EXTRA_CH_ENABLED 0x0200
-#define WAVCACHE_ENABLED 0x0100
-#define WAVCACHE_CH_60_ENABLED 0x0080
-#define WAVCACHE_WTSIZE_MASK 0x0060
-#define WAVCACHE_WTSIZE_1MB 0x0000
-#define WAVCACHE_WTSIZE_2MB 0x0020
-#define WAVCACHE_WTSIZE_4MB 0x0040
-#define WAVCACHE_WTSIZE_8MB 0x0060
-#define WAVCACHE_SGC_MASK 0x000c
-#define WAVCACHE_SGC_DISABLED 0x0000
-#define WAVCACHE_SGC_40_47 0x0004
-#define WAVCACHE_SGC_32_47 0x0008
-#define WAVCACHE_TESTMODE 0x0001
-
-/* Host Interruption */
-#define PORT_HOSTINT_CTRL 0x18 /* WORD RW */
-#define HOSTINT_CTRL_SOFT_RESET 0x8000
-#define HOSTINT_CTRL_DSOUND_RESET 0x4000
-#define HOSTINT_CTRL_HW_VOL_TO_PME 0x0400
-#define HOSTINT_CTRL_CLKRUN_ENABLED 0x0100
-#define HOSTINT_CTRL_HWVOL_ENABLED 0x0040
-#define HOSTINT_CTRL_ASSP_INT_ENABLED 0x0010
-#define HOSTINT_CTRL_ISDN_INT_ENABLED 0x0008
-#define HOSTINT_CTRL_DSOUND_INT_ENABLED 0x0004
-#define HOSTINT_CTRL_MPU401_INT_ENABLED 0x0002
-#define HOSTINT_CTRL_SB_INT_ENABLED 0x0001
-
-#define PORT_HOSTINT_STAT 0x1a /* BYTE RW */
-#define HOSTINT_STAT_HWVOL 0x40
-#define HOSTINT_STAT_ASSP 0x10
-#define HOSTINT_STAT_ISDN 0x08
-#define HOSTINT_STAT_DSOUND 0x04
-#define HOSTINT_STAT_MPU401 0x02
-#define HOSTINT_STAT_SB 0x01
-
-/* Hardware volume */
-#define PORT_HWVOL_VOICE_SHADOW 0x1c /* BYTE RW */
-#define PORT_HWVOL_VOICE 0x1d /* BYTE RW */
-#define PORT_HWVOL_MASTER_SHADOW 0x1e /* BYTE RW */
-#define PORT_HWVOL_MASTER 0x1f /* BYTE RW */
-
-/* CODEC */
-#define PORT_CODEC_CMD 0x30 /* BYTE W */
-#define CODEC_CMD_READ 0x80
-#define CODEC_CMD_WRITE 0x00
-#define CODEC_CMD_ADDR_MASK 0x7f
-
-#define PORT_CODEC_STAT 0x30 /* BYTE R */
-#define CODEC_STAT_MASK 0x01
-#define CODEC_STAT_RW_DONE 0x00
-#define CODEC_STAT_PROGLESS 0x01
-
-#define PORT_CODEC_REG 0x32 /* WORD RW */
-
-/* Ring bus control */
-#define PORT_RINGBUS_CTRL 0x34 /* DWORD RW */
-#define RINGBUS_CTRL_I2S_ENABLED 0x80000000
-#define RINGBUS_CTRL_RINGBUS_ENABLED 0x20000000
-#define RINGBUS_CTRL_ACLINK_ENABLED 0x10000000
-#define RINGBUS_CTRL_AC97_SWRESET 0x08000000
-#define RINGBUS_CTRL_IODMA_PLAYBACK_ENABLED 0x04000000
-#define RINGBUS_CTRL_IODMA_RECORD_ENABLED 0x02000000
-
-#define RINGBUS_SRC_MIC 20
-#define RINGBUS_SRC_I2S 16
-#define RINGBUS_SRC_ADC 12
-#define RINGBUS_SRC_MODEM 8
-#define RINGBUS_SRC_DSOUND 4
-#define RINGBUS_SRC_ASSP 0
-
-#define RINGBUS_DEST_MONORAL 000
-#define RINGBUS_DEST_STEREO 010
-#define RINGBUS_DEST_NONE 0
-#define RINGBUS_DEST_DAC 1
-#define RINGBUS_DEST_MODEM_IN 2
-#define RINGBUS_DEST_RESERVED3 3
-#define RINGBUS_DEST_DSOUND_IN 4
-#define RINGBUS_DEST_ASSP_IN 5
-
-/* General Purpose I/O */
-#define PORT_GPIO_DATA 0x60 /* WORD RW */
-#define PORT_GPIO_MASK 0x64 /* WORD RW */
-#define PORT_GPIO_DIR 0x68 /* WORD RW */
-
-/* Application Specific Signal Processor */
-#define PORT_ASSP_MEM_INDEX 0x80 /* DWORD RW */
-#define PORT_ASSP_MEM_DATA 0x84 /* WORD RW */
-#define PORT_ASSP_CTRL_A 0xa2 /* BYTE RW */
-#define PORT_ASSP_CTRL_B 0xa4 /* BYTE RW */
-#define PORT_ASSP_CTRL_C 0xa6 /* BYTE RW */
-#define PORT_ASSP_HOST_WR_INDEX 0xa8 /* BYTE W */
-#define PORT_ASSP_HOST_WR_DATA 0xaa /* BYTE RW */
-#define PORT_ASSP_INT_STAT 0xac /* BYTE RW */
-
-
-/* -----------------------------
- * Wave Processor Indexed Data Registers.
- */
-
-#define WPREG_DATA_PORT 0
-#define WPREG_CRAM_PTR 1
-#define WPREG_CRAM_DATA 2
-#define WPREG_WAVE_DATA 3
-#define WPREG_WAVE_PTR_LOW 4
-#define WPREG_WAVE_PTR_HIGH 5
-
-#define WPREG_TIMER_FREQ 6
-#define WP_TIMER_FREQ_PRESCALE_MASK 0x00e0 /* actual - 9 */
-#define WP_TIMER_FREQ_PRESCALE_SHIFT 5
-#define WP_TIMER_FREQ_DIVIDE_MASK 0x001f
-#define WP_TIMER_FREQ_DIVIDE_SHIFT 0
-
-#define WPREG_WAVE_ROMRAM 7
-#define WP_WAVE_VIRTUAL_ENABLED 0x0400
-#define WP_WAVE_8BITRAM_ENABLED 0x0200
-#define WP_WAVE_DRAM_ENABLED 0x0100
-#define WP_WAVE_RAMSPLIT_MASK 0x00ff
-#define WP_WAVE_RAMSPLIT_SHIFT 0
-
-#define WPREG_BASE 12
-#define WP_PARAOUT_BASE_MASK 0xf000
-#define WP_PARAOUT_BASE_SHIFT 12
-#define WP_PARAIN_BASE_MASK 0x0f00
-#define WP_PARAIN_BASE_SHIFT 8
-#define WP_SERIAL0_BASE_MASK 0x00f0
-#define WP_SERIAL0_BASE_SHIFT 4
-#define WP_SERIAL1_BASE_MASK 0x000f
-#define WP_SERIAL1_BASE_SHIFT 0
-
-#define WPREG_TIMER_ENABLE 17
-#define WPREG_TIMER_START 23
-
-
-/* -----------------------------
- * Audio Processing Unit.
- */
-#define APUREG_APUTYPE 0
-#define APU_DMA_ENABLED 0x4000
-#define APU_INT_ON_LOOP 0x2000
-#define APU_ENDCURVE 0x1000
-#define APU_APUTYPE_MASK 0x00f0
-#define APU_FILTERTYPE_MASK 0x000c
-#define APU_FILTERQ_MASK 0x0003
-
-/* APU types */
-#define APU_APUTYPE_SHIFT 4
-
-#define APUTYPE_INACTIVE 0
-#define APUTYPE_16BITLINEAR 1
-#define APUTYPE_16BITSTEREO 2
-#define APUTYPE_8BITLINEAR 3
-#define APUTYPE_8BITSTEREO 4
-#define APUTYPE_8BITDIFF 5
-#define APUTYPE_DIGITALDELAY 6
-#define APUTYPE_DUALTAP_READER 7
-#define APUTYPE_CORRELATOR 8
-#define APUTYPE_INPUTMIXER 9
-#define APUTYPE_WAVETABLE 10
-#define APUTYPE_RATECONV 11
-#define APUTYPE_16BITPINGPONG 12
-/* APU type 13 through 15 are reserved. */
-
-/* Filter types */
-#define APU_FILTERTYPE_SHIFT 2
-
-#define FILTERTYPE_2POLE_LOPASS 0
-#define FILTERTYPE_2POLE_BANDPASS 1
-#define FILTERTYPE_2POLE_HIPASS 2
-#define FILTERTYPE_1POLE_LOPASS 3
-#define FILTERTYPE_1POLE_HIPASS 4
-#define FILTERTYPE_PASSTHROUGH 5
-
-/* Filter Q */
-#define APU_FILTERQ_SHIFT 0
-
-#define FILTERQ_LESSQ 0
-#define FILTERQ_MOREQ 3
-
-/* APU register 2 */
-#define APUREG_FREQ_LOBYTE 2
-#define APU_FREQ_LOBYTE_MASK 0xff00
-#define APU_plus6dB 0x0010
-
-/* APU register 3 */
-#define APUREG_FREQ_HIWORD 3
-#define APU_FREQ_HIWORD_MASK 0x0fff
-
-/* Frequency */
-#define APU_FREQ_LOBYTE_SHIFT 8
-#define APU_FREQ_HIWORD_SHIFT 0
-#define FREQ_Hz2DIV(freq) (((u_int64_t)(freq) << 16) / 48000)
-
-/* APU register 4 */
-#define APUREG_WAVESPACE 4
-#define APU_STEREO 0x8000
-#define APU_USE_SYSMEM 0x4000
-#define APU_PCMBAR_MASK 0x6000
-#define APU_64KPAGE_MASK 0xff00
-
-/* PCM Base Address Register selection */
-#define APU_PCMBAR_SHIFT 13
-
-/* 64KW (==128KB) Page */
-#define APU_64KPAGE_SHIFT 8
-
-/* APU register 5 - 7 */
-#define APUREG_CURPTR 5
-#define APUREG_ENDPTR 6
-#define APUREG_LOOPLEN 7
-
-/* APU register 9 */
-#define APUREG_AMPLITUDE 9
-#define APU_AMPLITUDE_NOW_MASK 0xff00
-#define APU_AMPLITUDE_DEST_MASK 0x00ff
-
-/* Amplitude now? */
-#define APU_AMPLITUDE_NOW_SHIFT 8
-
-/* APU register 10 */
-#define APUREG_POSITION 10
-#define APU_RADIUS_MASK 0x00c0
-#define APU_PAN_MASK 0x003f
-
-/* Radius control. */
-#define APU_RADIUS_SHIFT 6
-#define RADIUS_CENTERCIRCLE 0
-#define RADIUS_MIDDLE 1
-#define RADIUS_OUTSIDE 2
-
-/* Polar pan. */
-#define APU_PAN_SHIFT 0
-#define PAN_RIGHT 0x00
-#define PAN_FRONT 0x08
-#define PAN_LEFT 0x10
-
-
-/* -----------------------------
- * Limits.
- */
-#define WPWA_MAX ((1 << 22) - 1)
-#define WPWA_MAXADDR ((1 << 23) - 1)
-#define MAESTRO_MAXADDR ((1 << 28) - 1)
-
-#endif /* MAESTRO_REG_H_INCLUDED */
diff --git a/sys/dev/sound/pci/via82c686.c b/sys/dev/sound/pci/via82c686.c
deleted file mode 100644
index df721366c3cfa..0000000000000
--- a/sys/dev/sound/pci/via82c686.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/*
- * Copyright (c) 2000 David Jones <dej@ox.org>
- * 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.
- *
- * 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$
- */
-
-#include <dev/sound/pcm/sound.h>
-#include <dev/sound/pcm/ac97.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-#include <sys/sysctl.h>
-
-#include <dev/sound/pci/via82c686.h>
-
-#define VIA_PCI_ID 0x30581106
-#define NSEGS 16 /* Number of segments in SGD table */
-
-#define SEGS_PER_CHAN (NSEGS/2)
-
-#undef DEB
-#define DEB(x)
-
-struct via_info;
-
-struct via_chinfo {
- struct via_info *parent;
- pcm_channel *channel;
- snd_dbuf *buffer;
- int dir;
-};
-
-struct via_info {
- bus_space_tag_t st;
- bus_space_handle_t sh;
- bus_dma_tag_t parent_dmat;
- bus_dma_tag_t sgd_dmat;
-
- struct resource *reg, *irq;
- int regid, irqid;
- void *ih;
-
- struct via_chinfo pch, rch;
- struct via_dma_op *sgd_table;
- u_int16_t codec_caps;
-};
-
-static u_int32_t via_rd(struct via_info *via, int regno, int size);
-static void via_wr(struct via_info *, int regno, u_int32_t data, int size);
-
-int via_waitready_codec(struct via_info *via);
-int via_waitvalid_codec(struct via_info *via);
-u_int32_t via_read_codec(void *addr, int reg);
-void via_write_codec(void *addr, int reg, u_int32_t val);
-
-static void via_intr(void *);
-bus_dmamap_callback_t dma_cb;
-
-
-/* channel interface */
-static void *viachan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
-static int viachan_setdir(void *data, int dir);
-static int viachan_setformat(void *data, u_int32_t format);
-static int viachan_setspeed(void *data, u_int32_t speed);
-static int viachan_setblocksize(void *data, u_int32_t blocksize);
-static int viachan_trigger(void *data, int go);
-static int viachan_getptr(void *data);
-static pcmchan_caps *viachan_getcaps(void *data);
-
-static u_int32_t via_playfmt[] = {
- AFMT_U8,
- AFMT_STEREO | AFMT_U8,
- AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE,
- 0
-};
-static pcmchan_caps via_playcaps = {4000, 48000, via_playfmt, 0};
-
-static u_int32_t via_recfmt[] = {
- AFMT_U8,
- AFMT_STEREO | AFMT_U8,
- AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE,
- 0
-};
-static pcmchan_caps via_reccaps = {4000, 48000, via_recfmt, 0};
-
-static pcm_channel via_chantemplate = {
- viachan_init,
- viachan_setdir,
- viachan_setformat,
- viachan_setspeed,
- viachan_setblocksize,
- viachan_trigger,
- viachan_getptr,
- viachan_getcaps,
- NULL, /* free */
- NULL, /* nop1 */
- NULL, /* nop2 */
- NULL, /* nop3 */
- NULL, /* nop4 */
- NULL, /* nop5 */
- NULL, /* nop6 */
- NULL, /* nop7 */
-};
-
-
-/*
- * Probe and attach the card
- */
-static int
-via_probe(device_t dev)
-{
- if (pci_get_devid(dev) == VIA_PCI_ID) {
- device_set_desc(dev, "VIA VT82C686A AC'97 Audio");
- return 0;
- }
- return ENXIO;
-}
-
-
-void dma_cb(void *p, bus_dma_segment_t *bds, int a, int b)
-{
-}
-
-
-static int
-via_attach(device_t dev)
-{
- struct via_info *via = 0;
- struct ac97_info *codec = 0;
- char status[SND_STATUSLEN];
-
- u_int32_t data;
-
- u_int16_t v;
- bus_dmamap_t sgd_dma_map;
-
- if ((via = malloc(sizeof *via, M_DEVBUF, M_NOWAIT)) == NULL) {
- device_printf(dev, "cannot allocate softc\n");
- return ENXIO;
- }
- bzero(via, sizeof *via);
-
- /* Get resources */
- data = pci_read_config(dev, PCIR_COMMAND, 2);
- data |= (PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCIR_COMMAND, data, 2);
- data = pci_read_config(dev, PCIR_COMMAND, 2);
-
- pci_write_config(dev, VIA_PCICONF_MISC,
- VIA_PCICONF_ACLINKENAB | VIA_PCICONF_ACSGD |
- VIA_PCICONF_ACNOTRST | VIA_PCICONF_ACVSR, 1);
-
- via->regid = PCIR_MAPS;
- via->reg = bus_alloc_resource(dev, SYS_RES_IOPORT, &via->regid,
- 0, ~0, 1, RF_ACTIVE);
- if (!via->reg) {
- device_printf(dev, "via: Cannot allocate bus resource.");
- goto bad;
- }
- via->st = rman_get_bustag(via->reg);
- via->sh = rman_get_bushandle(via->reg);
-
- via->irqid = 0;
- via->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &via->irqid,
- 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
- if (!via->irq
- || bus_setup_intr(dev, via->irq, INTR_TYPE_TTY, via_intr, via, &via->ih)){
- device_printf(dev, "unable to map interrupt\n");
- goto bad;
- }
-
- via_wr(via, VIA_PLAY_MODE,
- VIA_RPMODE_AUTOSTART |
- VIA_RPMODE_INTR_FLAG | VIA_RPMODE_INTR_EOL, 1);
- via_wr(via, VIA_RECORD_MODE,
- VIA_RPMODE_AUTOSTART |
- VIA_RPMODE_INTR_FLAG | VIA_RPMODE_INTR_EOL, 1);
-
- codec = ac97_create(dev, via, NULL,
- via_read_codec, via_write_codec);
- if (!codec) goto bad;
-
- mixer_init(dev, &ac97_mixer, codec);
-
- /*
- * The mixer init resets the codec. So enabling VRA must be done
- * afterwards.
- */
- v = via_read_codec(via, AC97_REG_EXT_AUDIO_ID);
- v &= (AC97_ENAB_VRA | AC97_ENAB_MICVRA);
- via_write_codec(via, AC97_REG_EXT_AUDIO_STAT, v);
- via->codec_caps = v;
- {
- v = via_read_codec(via, AC97_REG_EXT_AUDIO_STAT);
- DEB(printf("init: codec stat: %d\n", v));
- }
-
- if (!(v & AC97_CODEC_DOES_VRA)) {
- /* no VRA => can do only 48 kbps */
- via_playcaps.minspeed = 48000;
- via_reccaps.minspeed = 48000;
- }
-
- /* DMA tag for buffers */
- if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/VIA_BUFFSIZE, /*nsegments*/1, /*maxsegz*/0x3ffff,
- /*flags*/0, &via->parent_dmat) != 0) {
- device_printf(dev, "unable to create dma tag\n");
- goto bad;
- }
-
- /*
- * DMA tag for SGD table. The 686 uses scatter/gather DMA and
- * requires a list in memory of work to do. We need only 16 bytes
- * for this list, and it is wasteful to allocate 16K.
- */
- if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/NSEGS * sizeof(struct via_dma_op),
- /*nsegments*/1, /*maxsegz*/0x3ffff,
- /*flags*/0, &via->sgd_dmat) != 0) {
- device_printf(dev, "unable to create dma tag\n");
- goto bad;
- }
-
- if (bus_dmamem_alloc(via->sgd_dmat, (void **)&via->sgd_table,
- BUS_DMA_NOWAIT, &sgd_dma_map) == -1) goto bad;
- if (bus_dmamap_load(via->sgd_dmat, sgd_dma_map, via->sgd_table,
- NSEGS * sizeof(struct via_dma_op), dma_cb, 0, 0)) goto bad;
-
- snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld",
- rman_get_start(via->reg), rman_get_start(via->irq));
-
- /* Register */
- if (pcm_register(dev, via, 1, 1)) goto bad;
- pcm_addchan(dev, PCMDIR_PLAY, &via_chantemplate, via);
- pcm_addchan(dev, PCMDIR_REC, &via_chantemplate, via);
- pcm_setstatus(dev, status);
- return 0;
-bad:
- if (codec) ac97_destroy(codec);
- if (via->reg) bus_release_resource(dev, SYS_RES_IOPORT, via->regid, via->reg);
- if (via->ih) bus_teardown_intr(dev, via->irq, via->ih);
- if (via->irq) bus_release_resource(dev, SYS_RES_IRQ, via->irqid, via->irq);
- if (via->parent_dmat) bus_dma_tag_destroy(via->parent_dmat);
- if (via->sgd_dmat) bus_dma_tag_destroy(via->sgd_dmat);
- if (via) free(via, M_DEVBUF);
- return ENXIO;
-}
-
-static int
-via_detach(device_t dev)
-{
- int r;
- struct via_info *via = 0;
-
- r = pcm_unregister(dev);
- if (r)
- return r;
-
- via = pcm_getdevinfo(dev);
- bus_release_resource(dev, SYS_RES_IOPORT, via->regid, via->reg);
- bus_teardown_intr(dev, via->irq, via->ih);
- bus_release_resource(dev, SYS_RES_IRQ, via->irqid, via->irq);
- bus_dma_tag_destroy(via->parent_dmat);
- bus_dma_tag_destroy(via->sgd_dmat);
- free(via, M_DEVBUF);
- return 0;
-}
-
-
-static device_method_t via_methods[] = {
- DEVMETHOD(device_probe, via_probe),
- DEVMETHOD(device_attach, via_attach),
- DEVMETHOD(device_detach, via_detach),
- { 0, 0}
-};
-
-static driver_t via_driver = {
- "pcm",
- via_methods,
- sizeof(snddev_info),
-};
-
-static devclass_t pcm_devclass;
-
-DRIVER_MODULE(via, pci, via_driver, pcm_devclass, 0, 0);
-MODULE_DEPEND(via, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
-MODULE_VERSION(via, 1);
-
-
-static u_int32_t
-via_rd(struct via_info *via, int regno, int size)
-{
-
- switch (size) {
- case 1:
- return bus_space_read_1(via->st, via->sh, regno);
- case 2:
- return bus_space_read_2(via->st, via->sh, regno);
- case 4:
- return bus_space_read_4(via->st, via->sh, regno);
- default:
- return 0xFFFFFFFF;
- }
-}
-
-
-static void
-via_wr(struct via_info *via, int regno, u_int32_t data, int size)
-{
-
- switch (size) {
- case 1:
- bus_space_write_1(via->st, via->sh, regno, data);
- break;
- case 2:
- bus_space_write_2(via->st, via->sh, regno, data);
- break;
- case 4:
- bus_space_write_4(via->st, via->sh, regno, data);
- break;
- }
-}
-
-
-/* Codec interface */
-int
-via_waitready_codec(struct via_info *via)
-{
- int i;
-
- /* poll until codec not busy */
- for (i = 0; (i < TIMEOUT) &&
- (via_rd(via, VIA_CODEC_CTL, 4) & VIA_CODEC_BUSY); i++)
- DELAY(1);
- if (i >= TIMEOUT) {
- printf("via: codec busy\n");
- return 1;
- }
-
- return 0;
-}
-
-
-int
-via_waitvalid_codec(struct via_info *via)
-{
- int i;
-
- /* poll until codec valid */
- for (i = 0; (i < TIMEOUT) &&
- !(via_rd(via, VIA_CODEC_CTL, 4) & VIA_CODEC_PRIVALID); i++)
- DELAY(1);
- if (i >= TIMEOUT) {
- printf("via: codec invalid\n");
- return 1;
- }
-
- return 0;
-}
-
-
-void
-via_write_codec(void *addr, int reg, u_int32_t val)
-{
- struct via_info *via = addr;
-
- if (via_waitready_codec(via)) return;
-
- via_wr(via, VIA_CODEC_CTL,
- VIA_CODEC_PRIVALID | VIA_CODEC_INDEX(reg) | val, 4);
-}
-
-
-u_int32_t
-via_read_codec(void *addr, int reg)
-{
- struct via_info *via = addr;
-
- if (via_waitready_codec(via))
- return 1;
-
- via_wr(via, VIA_CODEC_CTL,
- VIA_CODEC_PRIVALID | VIA_CODEC_READ | VIA_CODEC_INDEX(reg),4);
-
- if (via_waitready_codec(via))
- return 1;
-
- if (via_waitvalid_codec(via))
- return 1;
-
- return via_rd(via, VIA_CODEC_CTL, 2);
-}
-
-
-/* channel interface */
-static void *
-viachan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct via_info *via = devinfo;
- struct via_chinfo *ch = (dir == PCMDIR_PLAY) ? &via->pch : &via->rch;
-
- ch->parent = via;
- ch->channel = c;
- ch->buffer = b;
- b->bufsize = VIA_BUFFSIZE;
-
- if (chn_allocbuf(ch->buffer, via->parent_dmat) == -1) return NULL;
- return ch;
-}
-
-static int
-viachan_setdir(void *data, int dir)
-{
- struct via_chinfo *ch = data;
- struct via_info *via = ch->parent;
- struct via_dma_op *ado;
- int i, chunk_size;
- int phys_addr, flag;
-
- ch->dir = dir;
- /*
- * Build the scatter/gather DMA (SGD) table.
- * There are four slots in the table: two for play, two for record.
- * This creates two half-buffers, one of which is playing; the other
- * is feeding.
- */
- ado = via->sgd_table;
- chunk_size = ch->buffer->bufsize / SEGS_PER_CHAN;
-
- if (dir == PCMDIR_REC) {
- ado += SEGS_PER_CHAN;
- }
-
-DEB(printf("SGD table located at va %p\n", ado));
- phys_addr = vtophys(ch->buffer->buf);
- for (i = 0; i < SEGS_PER_CHAN; i++) {
- ado->ptr = phys_addr;
- flag = (i == SEGS_PER_CHAN-1) ?
- VIA_DMAOP_EOL : VIA_DMAOP_FLAG;
- ado->flags = flag | chunk_size;
-DEB(printf("ado->ptr/flags = %x/%x\n", phys_addr, flag));
- phys_addr += chunk_size;
- ado++;
- }
- return 0;
-}
-
-static int
-viachan_setformat(void *data, u_int32_t format)
-{
- struct via_chinfo *ch = data;
- struct via_info *via = ch->parent;
- int mode, mode_set;
-
- mode_set = 0;
- if (format & AFMT_STEREO)
- mode_set |= VIA_RPMODE_STEREO;
- if (format & AFMT_S16_LE)
- mode_set |= VIA_RPMODE_16BIT;
-
- /* Set up for output format */
- if (ch->dir == PCMDIR_PLAY) {
-DEB(printf("set play format: %x\n", format));
- mode = via_rd(via, VIA_PLAY_MODE, 1);
- mode &= ~(VIA_RPMODE_16BIT | VIA_RPMODE_STEREO);
- mode |= mode_set;
- via_wr(via, VIA_PLAY_MODE, mode, 1);
- }
- else {
-DEB(printf("set record format: %x\n", format));
- mode = via_rd(via, VIA_RECORD_MODE, 1);
- mode &= ~(VIA_RPMODE_16BIT | VIA_RPMODE_STEREO);
- mode |= mode_set;
- via_wr(via, VIA_RECORD_MODE, mode, 1);
- }
-
- return 0;
-}
-
-static int
-viachan_setspeed(void *data, u_int32_t speed)
-{
- struct via_chinfo *ch = data;
- struct via_info *via = ch->parent;
-
- /*
- * Basic AC'97 defines a 48 kHz sample rate only. For other rates,
- * upsampling is required.
- *
- * The VT82C686A does not perform upsampling, and neither do we.
- * If the codec supports variable-rate audio (i.e. does the upsampling
- * itself), then negotiate the rate with the codec. Otherwise,
- * return 48 kHz cuz that's all you got.
- */
- if (ch->dir == PCMDIR_PLAY) {
-DEB(printf("requested play speed: %d\n", speed));
- if (via->codec_caps & AC97_CODEC_DOES_VRA) {
- via_write_codec(via, AC97_REG_EXT_DAC_RATE, speed);
- speed = via_read_codec(via, AC97_REG_EXT_DAC_RATE);
- }
- else {
-DEB(printf("VRA not supported!\n"));
- speed = 48000;
- }
-DEB(printf("obtained play speed: %d\n", speed));
- }
- else {
-DEB(printf("requested record speed: %d\n", speed));
- if (via->codec_caps & AC97_CODEC_DOES_VRA) {
- via_write_codec(via, AC97_REG_EXT_ADC_RATE, speed);
- speed = via_read_codec(via, AC97_REG_EXT_ADC_RATE);
- }
- else {
-DEB(printf("VRA not supported!\n"));
- speed = 48000;
- }
-DEB(printf("obtained record speed: %d\n", speed));
- }
- return speed;
-}
-
-static int
-viachan_setblocksize(void *data, u_int32_t blocksize)
-{
- struct via_chinfo *ch = data;
-
- return ch->buffer->bufsize / 2;
-}
-
-static int
-viachan_trigger(void *data, int go)
-{
- struct via_chinfo *ch = data;
- struct via_info *via = ch->parent;
- struct via_dma_op *ado;
-
- if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD) return 0;
- if (ch->dir == PCMDIR_PLAY) {
- if (go == PCMTRIG_START) {
- ado = &via->sgd_table[0];
-DEB(printf("ado located at va=%p pa=%x\n", ado, vtophys(ado)));
- via_wr(via, VIA_PLAY_DMAOPS_BASE, vtophys(ado),4);
- via_wr(via, VIA_PLAY_CONTROL,
- VIA_RPCTRL_START, 1);
- }
- else {
- /* Stop DMA */
- via_wr(via, VIA_PLAY_CONTROL,
- VIA_RPCTRL_TERMINATE, 1);
- }
- } else {
- if (go == PCMTRIG_START) {
- ado = &via->sgd_table[SEGS_PER_CHAN];
-DEB(printf("ado located at va=%p pa=%x\n", ado, vtophys(ado)));
- via_wr(via, VIA_RECORD_DMAOPS_BASE,
- vtophys(ado),4);
- via_wr(via, VIA_RECORD_CONTROL,
- VIA_RPCTRL_START, 1);
- }
- else {
- /* Stop DMA */
- via_wr(via, VIA_RECORD_CONTROL,
- VIA_RPCTRL_TERMINATE, 1);
- }
- }
-
-DEB(printf("viachan_trigger: go=%d\n", go));
- return 0;
-}
-
-static int
-viachan_getptr(void *data)
-{
- struct via_chinfo *ch = data;
- struct via_info *via = ch->parent;
- struct via_dma_op *ado;
- int ptr, base, len, seg;
- int base1;
-
- if (ch->dir == PCMDIR_PLAY) {
- ado = &via->sgd_table[0];
- base1 = via_rd(via, VIA_PLAY_DMAOPS_BASE, 4);
- len = via_rd(via, VIA_PLAY_DMAOPS_COUNT, 4);
- base = via_rd(via, VIA_PLAY_DMAOPS_BASE, 4);
- if (base != base1) { /* Avoid race hazzard */
- len = via_rd(via, VIA_PLAY_DMAOPS_COUNT, 4);
- }
-DEB(printf("viachan_getptr: len / base = %x / %x\n", len, base));
-
- /* Base points to SGD segment to do, one past current */
-
- /* Determine how many segments have been done */
- seg = (base - vtophys(ado)) / sizeof(struct via_dma_op);
- if (seg == 0) seg = SEGS_PER_CHAN;
-
- /* Now work out offset: seg less count */
- ptr = seg * ch->buffer->bufsize / SEGS_PER_CHAN - len;
-DEB(printf("return ptr=%d\n", ptr));
- return ptr;
- }
- else {
- base1 = via_rd(via, VIA_RECORD_DMAOPS_BASE, 4);
- ado = &via->sgd_table[SEGS_PER_CHAN];
- len = via_rd(via, VIA_RECORD_DMAOPS_COUNT, 4);
- base = via_rd(via, VIA_RECORD_DMAOPS_BASE, 4);
- if (base != base1) { /* Avoid race hazzard */
- len = via_rd(via, VIA_RECORD_DMAOPS_COUNT, 4);
- }
-DEB(printf("viachan_getptr: len / base = %x / %x\n", len, base));
-
- /* Base points to next block to do, one past current */
-
- /* Determine how many segments have been done */
- seg = (base - vtophys(ado)) / sizeof(struct via_dma_op);
- if (seg == 0) seg = SEGS_PER_CHAN;
-
- /* Now work out offset: seg less count */
- ptr = seg * ch->buffer->bufsize / SEGS_PER_CHAN - len;
-
- /* DMA appears to operate on memory 'lines' of 32 bytes */
- /* so don't return any part line - it isn't in RAM yet */
- ptr = ptr & ~0x1f;
-DEB(printf("return ptr=%d\n", ptr));
- return ptr;
- }
- return 0;
-}
-
-static pcmchan_caps *
-viachan_getcaps(void *data)
-{
- struct via_chinfo *ch = data;
- return (ch->dir == PCMDIR_PLAY) ? &via_playcaps : &via_reccaps;
-}
-
-static void
-via_intr(void *p)
-{
- struct via_info *via = p;
- int st;
-
-DEB(printf("viachan_intr\n"));
- /* Read channel */
- st = via_rd(via, VIA_PLAY_STAT, 1);
- if (st & VIA_RPSTAT_INTR) {
- via_wr(via, VIA_PLAY_STAT, VIA_RPSTAT_INTR, 1);
- chn_intr(via->pch.channel);
- }
-
- /* Write channel */
- st = via_rd(via, VIA_RECORD_STAT, 1);
- if (st & VIA_RPSTAT_INTR) {
- via_wr(via, VIA_RECORD_STAT, VIA_RPSTAT_INTR, 1);
- chn_intr(via->rch.channel);
- }
-}
-
-
diff --git a/sys/dev/sound/pci/via82c686.h b/sys/dev/sound/pci/via82c686.h
deleted file mode 100644
index 1d85c9b14898b..0000000000000
--- a/sys/dev/sound/pci/via82c686.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Tyler C. Sarna.
- *
- * 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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$
- */
-
-#ifndef _VIA_H
-#define _VIA_H
-
-/*
- * VIA Technologies VT82C686A Southbridge Audio Driver
- *
- * Documentation links:
- *
- * ftp://ftp.alsa-project.org/pub/manuals/via/686a.pdf
- * ftp://ftp.alsa-project.org/pub/manuals/general/ac97r21.pdf
- * ftp://ftp.alsa-project.org/pub/manuals/ad/AD1881_0.pdf (example AC'97 codec)
- */
-
-struct via_dma_op {
- u_int32_t ptr;
- u_int32_t flags;
-#define VIA_DMAOP_EOL 0x80000000
-#define VIA_DMAOP_FLAG 0x40000000
-#define VIA_DMAOP_STOP 0x20000000
-#define VIA_DMAOP_COUNT(x) ((x)&0x00FFFFFF)
-};
-
-#define VIA_PCICONF_MISC 0x41
-#define VIA_PCICONF_ACLINKENAB 0x80 /* ac link enab */
-#define VIA_PCICONF_ACNOTRST 0x40 /* ~(ac reset) */
-#define VIA_PCICONF_ACSYNC 0x20 /* ac sync */
-#define VIA_PCICONF_ACVSR 0x08 /* var. samp. rate */
-#define VIA_PCICONF_ACSGD 0x04 /* SGD enab */
-#define VIA_PCICONF_ACFM 0x02 /* FM enab */
-#define VIA_PCICONF_ACSB 0x01 /* SB enab */
-#define VIA_PCICONF_FUNC_EN 0x42
-
-#define VIA_PLAY_STAT 0x00
-#define VIA_RECORD_STAT 0x10
-#define VIA_RPSTAT_INTR 0x03
-#define VIA_PLAY_CONTROL 0x01
-#define VIA_RECORD_CONTROL 0x11
-#define VIA_RPCTRL_START 0x80
-#define VIA_RPCTRL_TERMINATE 0x40
-#define VIA_PLAY_MODE 0x02
-#define VIA_RECORD_MODE 0x12
-#define VIA_RPMODE_INTR_FLAG 0x01
-#define VIA_RPMODE_INTR_EOL 0x02
-#define VIA_RPMODE_STEREO 0x10
-#define VIA_RPMODE_16BIT 0x20
-#define VIA_RPMODE_AUTOSTART 0x80
-#define VIA_PLAY_DMAOPS_BASE 0x04
-#define VIA_RECORD_DMAOPS_BASE 0x14
-#define VIA_PLAY_DMAOPS_COUNT 0x0C
-#define VIA_RECORD_DMAOPS_COUNT 0x1C
-
-#define VIA_CODEC_CTL 0x80
-#define VIA_CODEC_READ 0x00800000
-#define VIA_CODEC_BUSY 0x01000000
-#define VIA_CODEC_PRIVALID 0x02000000
-#define VIA_CODEC_INDEX(x) ((x)<<16)
-
-#define AC97_REG_EXT_AUDIO_ID 0x28
-#define AC97_CODEC_DOES_VRA 0x0001
-#define AC97_CODEC_DOES_MICVRA 0x0008
-#define AC97_REG_EXT_AUDIO_STAT 0x2A
-#define AC97_ENAB_VRA 0x0001
-#define AC97_ENAB_MICVRA 0x0008
-#define AC97_REG_EXT_DAC_RATE 0x2C
-#define AC97_REG_EXT_ADC_RATE 0x32
-
-#define TIMEOUT 50
-#define VIA_BUFFSIZE 0x4000
-
-#endif /* _VIA_H */
diff --git a/sys/dev/usb/rio500_usb.h b/sys/dev/usb/rio500_usb.h
deleted file mode 100644
index c2da72e91b116..0000000000000
--- a/sys/dev/usb/rio500_usb.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ----------------------------------------------------------------------
-
- Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar)
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted under any licence of your choise which
- meets the open source licence definiton
- http://www.opensource.org/opd.html such as the GNU licence or the
- BSD licence.
-
- 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 or the BSD license for more details.
-
- ----------------------------------------------------------------------
-
- Modified for FreeBSD by Iwasa Kazmi <kzmi@ca2.so-net.ne.jp>
-
- ---------------------------------------------------------------------- */
-
-/* $FreeBSD$ */
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-#include <sys/ioccom.h>
-#ifndef USB_VENDOR_DIAMOND
-#define USB_VENDOR_DIAMOND 0x841
-#endif
-#ifndef USB_PRODUCT_DIAMOND_RIO500USB
-#define USB_PRODUCT_DIAMOND_RIO500USB 0x1
-#endif
-#endif
-
-struct RioCommand
-{
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
- u_int16_t length;
-#else
- short length;
-#endif
- int request;
- int requesttype;
- int value;
- int index;
- void *buffer;
- int timeout;
-};
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-#define RIO_SEND_COMMAND _IOWR('U', 200, struct RioCommand)
-#define RIO_RECV_COMMAND _IOWR('U', 201, struct RioCommand)
-#else
-#define RIO_SEND_COMMAND 0x1
-#define RIO_RECV_COMMAND 0x2
-#endif
-
-#define RIO_DIR_OUT 0x0
-#define RIO_DIR_IN 0x1
diff --git a/sys/modules/ip6fw/Makefile b/sys/modules/ip6fw/Makefile
deleted file mode 100644
index 64fa17ea7f9db..0000000000000
--- a/sys/modules/ip6fw/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../netinet6
-KMOD= ip6fw
-SRCS= ip6_fw.c
-NOMAN=
-CFLAGS+= -DIPV6FIREWALL
-#
-#If you want it verbose
-#CFLAGS+= -DIPV6FIREWALL_VERBOSE
-#CFLAGS+= -DIPV6FIREWALL_VERBOSE_LIMIT=100
-#
-#If you want it to pass all packets by default
-#CFLAGS+= -DIPV6FIREWALL_DEFAULT_TO_ACCEPT
-#
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/mly/Makefile b/sys/modules/mly/Makefile
deleted file mode 100644
index 1f8abe828496d..0000000000000
--- a/sys/modules/mly/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../dev/mly
-KMOD = mly
-SRCS = mly.c mly_pci.c mly_cam.c
-SRCS += opt_scsi.h opt_cam.h
-SRCS += device_if.h bus_if.h pci_if.h
-
-#CFLAGS+= -DMLY_DEBUG=1
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/pcn/Makefile b/sys/modules/pcn/Makefile
deleted file mode 100644
index 0ef6fae5f4120..0000000000000
--- a/sys/modules/pcn/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../pci
-KMOD = if_pcn
-SRCS = if_pcn.c opt_bdg.h device_if.h bus_if.h pci_if.h
-SRCS += miibus_if.h
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/sound/driver/fm801/Makefile b/sys/modules/sound/driver/fm801/Makefile
deleted file mode 100644
index af68e151bf855..0000000000000
--- a/sys/modules/sound/driver/fm801/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../../../dev/sound/pci
-KMOD = snd_fm801
-SRCS = device_if.h bus_if.h isa_if.h pci_if.h
-SRCS += fm801.c
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/sound/driver/maestro/Makefile b/sys/modules/sound/driver/maestro/Makefile
deleted file mode 100644
index 01de2704a9bbe..0000000000000
--- a/sys/modules/sound/driver/maestro/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../../../dev/sound/pci
-KMOD = snd_maestro
-SRCS = device_if.h bus_if.h isa_if.h pci_if.h
-SRCS += maestro.c
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/sound/driver/via82c686/Makefile b/sys/modules/sound/driver/via82c686/Makefile
deleted file mode 100644
index 947eb826304b9..0000000000000
--- a/sys/modules/sound/driver/via82c686/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../../../dev/sound/pci
-KMOD = snd_via82c686
-SRCS = device_if.h bus_if.h isa_if.h pci_if.h
-SRCS += via82c686.c
-
-.include <bsd.kmod.mk>
diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h
deleted file mode 100644
index c2919636419d3..0000000000000
--- a/sys/sys/kobj.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*-
- * Copyright (c) 2000 Doug Rabson
- * 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.
- *
- * 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$
- */
-
-#ifndef _SYS_KOBJ_H_
-#define _SYS_KOBJ_H_
-
-/*
- * Forward declarations
- */
-typedef struct kobj *kobj_t;
-typedef struct kobj_class *kobj_class_t;
-typedef struct kobj_method kobj_method_t;
-typedef int (*kobjop_t)(void);
-typedef struct kobj_ops *kobj_ops_t;
-typedef struct kobjop_desc *kobjop_desc_t;
-struct malloc_type;
-
-struct kobj_method {
- kobjop_desc_t desc;
- kobjop_t func;
-};
-
-/*
- * A class is simply a method table and a sizeof value. When the first
- * instance of the class is created, the method table will be compiled
- * into a form more suited to efficient method dispatch. This compiled
- * method table is always the first field of the object.
- */
-#define KOBJ_CLASS_FIELDS \
- const char *name; /* class name */ \
- kobj_method_t *methods; /* method table */ \
- size_t size; /* object size */ \
- u_int refs; /* reference count */ \
- kobj_ops_t ops /* compiled method table */
-
-struct kobj_class {
- KOBJ_CLASS_FIELDS;
-};
-
-/*
- * Implementation of kobj.
- */
-#define KOBJ_FIELDS \
- kobj_ops_t ops
-
-struct kobj {
- KOBJ_FIELDS;
-};
-
-/*
- * The ops table is used as a cache of results from kobj_lookup_method().
- */
-
-#define KOBJ_CACHE_SIZE 256
-
-struct kobj_ops {
- kobj_method_t cache[KOBJ_CACHE_SIZE];
- kobj_class_t cls;
-};
-
-struct kobjop_desc {
- unsigned int id; /* unique ID */
- kobjop_t deflt; /* default implementation */
-};
-
-/*
- * Shorthand for constructing method tables.
- */
-#define KOBJMETHOD(NAME, FUNC) { &NAME##_desc, (kobjop_t) FUNC }
-
-#define DEFINE_CLASS(name, methods, size) \
- \
-struct kobj_class name ## _class = { \
- #name, methods, size \
-}
-
-/*
- * Compile the method table in a class.
- */
-void kobj_class_compile(kobj_class_t cls);
-
-/*
- * Compile the method table, with the caller providing the space for
- * the ops table.(for use before malloc is initialised).
- */
-void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops);
-
-/*
- * Free the compiled method table in a class.
- */
-void kobj_class_free(kobj_class_t cls);
-
-/*
- * Allocate memory for and initalise a new object.
- */
-kobj_t kobj_create(kobj_class_t cls,
- struct malloc_type *mtype,
- int mflags);
-
-/*
- * Initialise a pre-allocated object.
- */
-void kobj_init(kobj_t obj, kobj_class_t cls);
-
-/*
- * Delete an object. If mtype is non-zero, free the memory.
- */
-void kobj_delete(kobj_t obj, struct malloc_type *mtype);
-
-/*
- * Maintain stats on hits/misses in lookup caches.
- */
-#ifdef KOBJ_STATS
-extern int kobj_lookup_hits;
-extern int kobj_lookup_misses;
-#define KOBJOPHIT do { kobj_lookup_hits++; } while (0)
-#define KOBJOPMISS do { kobj_lookup_misses++; } while (0)
-#else
-#define KOBJOPHIT do { } while (0)
-#define KOBJOPMISS do { } while (0)
-#endif
-
-/*
- * Lookup the method in the cache and if it isn't there look it up the
- * slow way.
- */
-#define KOBJOPLOOKUP(OPS,OP) do { \
- kobjop_desc_t _desc = &OP##_##desc; \
- kobj_method_t *_ce = \
- &OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \
- if (_ce->desc != _desc) { \
- KOBJOPMISS; \
- kobj_lookup_method(OPS->cls->methods, _ce, _desc); \
- } else { \
- KOBJOPHIT; \
- } \
- _m = _ce->func; \
-} while(0)
-
-void kobj_lookup_method(kobj_method_t *methods,
- kobj_method_t *ce,
- kobjop_desc_t desc);
-
-#endif /* !_SYS_KOBJ_H_ */