-/* $OpenBSD: adlookup.c,v 1.3 1996/02/26 14:18:17 niklas Exp $ */
-/* $NetBSD: adlookup.c,v 1.12 1996/02/13 17:05:47 christos Exp $ */
+/* $OpenBSD: adlookup.c,v 1.4 1996/04/21 22:14:33 deraadt Exp $ */
+/* $NetBSD: adlookup.c,v 1.13 1996/04/05 05:06:07 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
+ * Copyright (c) 1996 Matthias Scheler
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
struct anode *adp; /* anode of search dir */
struct ucred *ucp; /* lookup credentials */
u_long bn, plen, hval;
- char *pelt;
+ u_char *pelt;
#ifdef ADOSFS_DIAGNOSTIC
advopprint(sp);
last = flags & ISLASTCN;
lockp = flags & LOCKPARENT;
wantp = flags & (LOCKPARENT | WANTPARENT);
- pelt = cnp->cn_nameptr;
+ pelt = (u_char *)cnp->cn_nameptr;
plen = cnp->cn_namelen;
nocache = 0;
* then walk the chain. if chain has not been fully
* walked before, track the count in `tabi'
*/
- hval = adoshash(pelt, plen, adp->ntabent);
+ hval = adoshash(pelt, plen, adp->ntabent, IS_INTER(adp->amp));
bn = adp->tab[hval];
i = min(adp->tabi[hval], 0);
while (bn != 0) {
-/* $OpenBSD: adosfs.h,v 1.3 1996/02/26 14:18:18 niklas Exp $ */
-/* $NetBSD: adosfs.h,v 1.9 1996/02/09 19:06:39 christos Exp $ */
+/* $OpenBSD: adosfs.h,v 1.4 1996/04/21 22:14:36 deraadt Exp $ */
+/* $NetBSD: adosfs.h,v 1.10 1996/04/05 05:06:08 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
+ * Copyright (c) 1996 Matthias Scheler
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
int flags; /* misc flags */
char *slinkto; /* name of file or dir */
};
-#define VTOA(vp) ((struct anode *)(vp)->v_data)
-#define ATOV(ap) ((ap)->vp)
-#define ANODETABSZ(ap) (((ap)->nwords - 56) * sizeof(long))
-#define ANODETABENT(ap) ((ap)->nwords - 56)
+#define VTOA(vp) ((struct anode *)(vp)->v_data)
+#define ATOV(ap) ((ap)->vp)
+#define ANODETABSZ(ap) (((ap)->nwords - 56) * sizeof(long))
+#define ANODETABENT(ap) ((ap)->nwords - 56)
#define ANODENDATBLKENT(ap) ((ap)->nwords - 56)
/*
struct adosfsmount {
LIST_HEAD(anodechain, anode) anodetab[ANODEHASHSZ];
struct mount *mp; /* owner mount */
+ u_long dostype; /* type of volume */
u_long rootb; /* root block number */
- u_long startb; /* start block */
- u_long endb; /* one block past last */
+ u_long secsperblk; /* sectors per block */
u_long bsize; /* size of blocks */
u_long nwords; /* size of blocks in long words */
+ u_long dbsize; /* data bytes per block */
uid_t uid; /* uid of mounting user */
gid_t gid; /* gid of mounting user */
u_long mask; /* mode mask */
struct vnode *devvp; /* blk device mounted on */
struct vnode *rootvp; /* out root vnode */
struct netexport export;
+ u_long *bitmap; /* allocation bitmap */
+ u_long numblks; /* number of usable blocks */
+ u_long freeblks; /* number of free blocks */
};
#define VFSTOADOSFS(mp) ((struct adosfsmount *)(mp)->mnt_data)
+#define IS_FFS(amp) ((amp)->dostype & 1)
+#define IS_INTER(amp) (((amp)->dostype & 7) > 1)
+
/*
* AmigaDOS block stuff.
*/
+#define BBOFF (0)
+
#define BPT_SHORT (2)
+#define BPT_DATA (8)
#define BPT_LIST (16)
#define BST_RDIR (1)
#define BST_FILE (-3L)
#define BST_LFILE (-4L)
+#define OFS_DATA_OFFSET (24)
+
/*
* utility protos
*/
+#ifndef m68k
long adoswordn __P((struct buf *, int));
+#else
+#define adoswordn(bp,wn) (*((long *)(bp)->b_data + (wn)))
+#endif
+
long adoscksum __P((struct buf *, long));
-int adoshash __P((const char *, int, int));
+int adoshash __P((const u_char *, int, int, int));
int adunixprot __P((int));
int adosfs_getblktype __P((struct adosfsmount *, struct buf *));
-/* $OpenBSD: adutil.c,v 1.3 1996/02/26 14:18:19 niklas Exp $ */
-/* $NetBSD: adutil.c,v 1.8 1996/02/09 19:06:41 christos Exp $ */
+/* $OpenBSD: adutil.c,v 1.4 1996/04/21 22:14:38 deraadt Exp $ */
+/* $NetBSD: adutil.c,v 1.9 1996/04/05 05:06:10 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
+ * Copyright (c) 1996 Matthias Scheler
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* look for anode in the mount's hash table, return locked.
*/
#define AHASH(an) ((an) & (ANODEHASHSZ - 1))
-static int toupper __P((int));
+static int CapitalChar __P((int, int));
struct vnode *
adosfs_ahashget(mp, an)
{
if (adoscksum(bp, amp->nwords)) {
#ifdef DIAGNOSTIC
- printf("adosfs: aget: cksum of blk %d failed\n", bp->b_blkno);
+ printf("adosfs: aget: cksum of blk %d failed\n",
+ bp->b_blkno / amp->secsperblk);
#endif
return (-1);
}
*/
if (adoswordn(bp, 0) != BPT_SHORT) {
#ifdef DIAGNOSTIC
- printf("adosfs: aget: bad primary type blk %d\n", bp->b_blkno);
+ printf("adosfs: aget: bad primary type blk %d\n",
+ bp->b_blkno / amp->secsperblk);
#endif
return (-1);
}
int adprot;
{
if (adprot & 0xc000ee00) {
- adprot = ((adprot & 0xee00) | (~adprot & 0x000e)) >> 1;
- return (((adprot & 0x7) << 6) | ((adprot & 0x700) >> 5) |
- (adprot >> 12));
+ adprot = (adprot & 0xee0e) >> 1;
+ return (((adprot & 0x7) << 6) |
+ ((adprot & 0x700) >> 5) |
+ ((adprot & 0x7000) >> 12));
}
else {
- adprot = (~adprot >> 1) & 0x7;
+ adprot = (adprot >> 1) & 0x7;
return((adprot << 6) | (adprot << 3) | adprot);
}
}
static int
-toupper(ch)
- int ch;
+CapitalChar(ch, inter)
+ int ch, inter;
{
- if (ch >= 'a' && ch <= 'z')
- return(ch & ~(0x20));
+ if ((ch >= 'a' && ch <= 'z') ||
+ (inter && ch >= 0xe0 && ch <= 0xfe && ch != 0xf7))
+ return(ch - ('a' - 'A'));
return(ch);
}
}
int
-adoshash(nam, namlen, nelt)
- const char *nam;
- int namlen, nelt;
+adoshash(nam, namlen, nelt, inter)
+ const u_char *nam;
+ int namlen, nelt, inter;
{
int val;
val = namlen;
while (namlen--)
- val = ((val * 13) + toupper(*nam++)) & 0x7ff;
+ val = ((val * 13) + CapitalChar(*nam++, inter)) & 0x7ff;
return(val % nelt);
}
}
#endif
+#ifndef m68k
long
adoswordn(bp, wn)
struct buf *bp;
*/
return(ntohl(*((long *)bp->b_data + wn)));
}
+#endif
-/* $OpenBSD: advfsops.c,v 1.4 1996/02/26 14:18:20 niklas Exp $ */
+/* $OpenBSD: advfsops.c,v 1.5 1996/04/21 22:14:39 deraadt Exp $ */
/* $NetBSD: advfsops.c,v 1.14.2.1 1995/11/10 16:05:16 chopps Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
+ * Copyright (c) 1996 Matthias Scheler
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
int adosfs_vptofh __P((struct vnode *, struct fid *));
int adosfs_mountfs __P((struct vnode *, struct mount *, struct proc *));
+int adosfs_loadbitmap __P((struct adosfsmount *));
int
adosfs_mount(mp, path, data, ndp, p)
struct disklabel dl;
struct partition *parp;
struct adosfsmount *amp;
+ struct buf *bp;
struct vnode *rvp;
int error, part, i;
amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK);
bzero((char *)amp, (u_long)sizeof(struct adosfsmount));
amp->mp = mp;
- amp->startb = parp->p_offset;
- amp->endb = parp->p_offset + parp->p_size;
- amp->bsize = dl.d_secsize;
+ if (dl.d_type == DTYPE_FLOPPY) {
+ amp->bsize = dl.d_secsize;
+ amp->secsperblk = 1;
+ }
+ else {
+ amp->bsize = parp->p_fsize * parp->p_frag;
+ amp->secsperblk = parp->p_frag;
+ }
+ amp->rootb = (parp->p_size / amp->secsperblk - 1 + parp->p_cpg) >> 1;
+ amp->numblks = parp->p_size / amp->secsperblk - parp->p_cpg;
+
+ bp = NULL;
+ if ((error = bread(devvp, (daddr_t)BBOFF,
+ amp->bsize, NOCRED, &bp)) != 0)
+ goto fail;
+
+ amp->dostype = adoswordn(bp, 0);
+ brelse(bp);
+
+ if (amp->dostype < 0x444f5300 || amp->dostype > 0x444f5305) {
+ error = EINVAL;
+ goto fail;
+ }
+
amp->nwords = amp->bsize >> 2;
+ amp->dbsize = amp->bsize - (IS_FFS(amp) ? 0 : OFS_DATA_OFFSET);
amp->devvp = devvp;
-/* amp->rootb = (parp->p_size - 1 + 2) >> 1;*/
- amp->rootb = (parp->p_size - 1 + parp->p_cpg) >> 1;
mp->mnt_data = (qaddr_t)amp;
mp->mnt_stat.f_fsid.val[0] = (long)devvp->v_rdev;
*/
if ((error = VFS_ROOT(mp, &rvp)) != 0)
goto fail;
+ /* allocate and load bitmap, set free space */
+ amp->bitmap = malloc(((amp->numblks + 31) / 32) * sizeof(*amp->bitmap),
+ M_ADOSFSBITMAP, M_WAITOK);
+ if (amp->bitmap)
+ adosfs_loadbitmap(amp);
+ if (mp->mnt_flag & MNT_RDONLY && amp->bitmap) {
+ /*
+ * Don't need the bitmap any more if it's read-only.
+ */
+ free(amp->bitmap, M_ADOSFSBITMAP);
+ amp->bitmap = NULL;
+ }
vput(rvp);
return(0);
fail:
(void) VOP_CLOSE(devvp, FREAD, NOCRED, p);
+ if (amp && amp->bitmap)
+ free(amp->bitmap, M_ADOSFSBITMAP);
if (amp)
free(amp, M_ADOSFSMNT);
return (error);
amp->devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(amp->devvp, FREAD, NOCRED, p);
vrele(amp->devvp);
+ if (amp->bitmap)
+ free(amp->bitmap, M_ADOSFSBITMAP);
free(amp, M_ADOSFSMNT);
mp->mnt_data = (qaddr_t)0;
mp->mnt_flag &= ~MNT_LOCAL;
if ((error = VFS_VGET(mp, (ino_t)VFSTOADOSFS(mp)->rootb, &nvp)) != 0)
return (error);
+ /* XXX verify it's a root block? */
*vpp = nvp;
return (0);
}
amp = VFSTOADOSFS(mp);
sbp->f_type = 0;
sbp->f_bsize = amp->bsize;
- sbp->f_iosize = amp->bsize;
- sbp->f_blocks = 2; /* XXX */
- sbp->f_bfree = 0; /* none */
- sbp->f_bavail = 0; /* none */
+ sbp->f_iosize = amp->dbsize;
+ sbp->f_blocks = amp->numblks;
+ sbp->f_bfree = amp->freeblks;
+ sbp->f_bavail = amp->freeblks;
sbp->f_files = 0; /* who knows */
sbp->f_ffree = 0; /* " " */
if (sbp != &mp->mnt_stat) {
struct anode *ap;
struct buf *bp;
char *nam, *tmp;
- int namlen, error, tmplen;
+ int namlen, error;
error = 0;
amp = VFSTOADOSFS(mp);
ap->nwords = amp->nwords;
adosfs_ainshash(amp, ap);
- if ((error = bread(amp->devvp, an, amp->bsize, NOCRED, &bp)) != 0) {
+ if ((error = bread(amp->devvp, an * amp->secsperblk,
+ amp->bsize, NOCRED, &bp)) != 0) {
vput(vp);
return (error);
}
ap->created.ticks = adoswordn(bp, ap->nwords - 5);
break;
case ALDIR:
- vp->v_type = VDIR;
- break;
case ADIR:
vp->v_type = VDIR;
break;
case ALFILE:
- vp->v_type = VREG;
- ap->fsize = adoswordn(bp, ap->nwords - 47);
- break;
case AFILE:
vp->v_type = VREG;
ap->fsize = adoswordn(bp, ap->nwords - 47);
* from: "part:dir/file" to: "/part/dir/file"
*/
nam = bp->b_data + (6 * sizeof(long));
- tmplen = namlen = *(u_char *)nam++;
+ namlen = strlen(nam);
tmp = nam;
- while (tmplen-- && *tmp != ':')
+ while (*tmp && *tmp != ':')
tmp++;
if (*tmp == 0) {
ap->slinkto = malloc(namlen + 1, M_ANODE, M_WAITOK);
vput(vp);
return (EINVAL);
}
+
+ /*
+ * Get appropriate data from this block; hard link needs
+ * to get other data from the "real" block.
+ */
+
+ /*
+ * copy in name (from original block)
+ */
+ nam = bp->b_data + (ap->nwords - 20) * sizeof(long);
+ namlen = *(u_char *)nam++;
+ if (namlen > 30) {
+#ifdef DIAGNOSTIC
+ printf("adosfs: aget: name length too long blk %d\n", an);
+#endif
+ brelse(bp);
+ vput(vp);
+ return (EINVAL);
+ }
+ bcopy(nam, ap->name, namlen);
+ ap->name[namlen] = 0;
+
/*
* if dir alloc hash table and copy it in
*/
* setup last indirect block cache.
*/
ap->lastlindblk = 0;
- if (ap->type == AFILE)
+ if (ap->type == AFILE) {
ap->lastindblk = ap->block;
- else if (ap->type == ALFILE)
+ if (adoswordn(bp, ap->nwords - 10))
+ ap->linkto = ap->block;
+ } else if (ap->type == ALFILE) {
ap->lastindblk = ap->linkto;
+ brelse(bp);
+ bp = NULL;
+ error = bread(amp->devvp, ap->linkto * amp->secsperblk,
+ amp->bsize, NOCRED, &bp);
+ ap->fsize = adoswordn(bp, ap->nwords - 47);
+ /*
+ * Should ap->block be set to the real file header block?
+ */
+ ap->block = ap->linkto;
+ }
if (ap->type == AROOT) {
- ap->adprot = 0;
+ ap->adprot = 15;
ap->uid = amp->uid;
ap->gid = amp->gid;
} else {
- ap->adprot = adoswordn(bp, ap->nwords - 48);
+ ap->adprot = adoswordn(bp, ap->nwords - 48) ^ 15;
/*
* Get uid/gid from extensions in file header
* (really need to know if this is a muFS partition)
ap->mtime.mins = adoswordn(bp, ap->nwords - 22);
ap->mtime.ticks = adoswordn(bp, ap->nwords - 21);
- /*
- * copy in name
- */
- nam = bp->b_data + (ap->nwords - 20) * sizeof(long);
- namlen = *(u_char *)nam++;
- if (namlen > 30) {
-#ifdef DIAGNOSTIC
- printf("adosfs: aget: name length too long blk %d\n", an);
-#endif
- brelse(bp);
- vput(vp);
- return (EINVAL);
- }
- bcopy(nam, ap->name, namlen);
- ap->name[namlen] = 0;
-
*vpp = vp; /* return vp */
brelse(bp); /* release buffer */
return (0);
}
+/*
+ * Load the bitmap into memory, and count the number of available
+ * blocks.
+ * The bitmap will be released if the filesystem is read-only; it's
+ * only needed to find the free space.
+ */
+int
+adosfs_loadbitmap(amp)
+ struct adosfsmount *amp;
+{
+ struct buf *bp, *mapbp;
+ u_long bn;
+ int blkix, endix, mapix;
+ int bmsize;
+ int error;
+
+ bp = mapbp = NULL;
+ bn = amp->rootb;
+ if ((error = bread(amp->devvp, bn * amp->secsperblk, amp->bsize,
+ NOCRED, &bp)) != 0)
+ return (error);
+ blkix = amp->nwords - 49;
+ endix = amp->nwords - 24;
+ mapix = 0;
+ bmsize = (amp->numblks + 31) / 32;
+ while (mapix < bmsize) {
+ int n;
+ u_long bits;
+
+ if (adoswordn(bp, blkix) == 0)
+ break;
+ if (mapbp != NULL)
+ brelse(mapbp);
+ if ((error = bread(amp->devvp,
+ adoswordn(bp, blkix) * amp->secsperblk, amp->bsize,
+ NOCRED, &mapbp)) != 0)
+ break;
+ if (adoscksum(mapbp, amp->nwords)) {
+#ifdef DIAGNOSTIC
+ printf("adosfs: loadbitmap - cksum of blk %d failed\n",
+ adoswordn(bp, blkix));
+#endif
+ /* XXX Force read-only? Set free space 0? */
+ break;
+ }
+ n = 1;
+ while (n < amp->nwords && mapix < bmsize) {
+ amp->bitmap[mapix++] = bits = adoswordn(mapbp, n);
+ ++n;
+ if (mapix == bmsize && amp->numblks & 31)
+ bits &= ~(0xffffffff << (amp->numblks & 31));
+ while (bits) {
+ if (bits & 1)
+ ++amp->freeblks;
+ bits >>= 1;
+ }
+ }
+ ++blkix;
+ if (mapix < bmsize && blkix == endix) {
+ bn = adoswordn(bp, blkix);
+ brelse(bp);
+ if ((error = bread(amp->devvp, bn * amp->secsperblk,
+ amp->bsize, NOCRED, &bp)) != 0)
+ break;
+ /*
+ * Why is there no checksum on these blocks?
+ */
+ blkix = 0;
+ endix = amp->nwords - 1;
+ }
+ }
+ if (bp)
+ brelse(bp);
+ if (mapbp)
+ brelse(mapbp);
+ return (error);
+}
+
/*
* File handle to vnode
-/* $OpenBSD: advnops.c,v 1.3 1996/02/26 14:18:21 niklas Exp $ */
+/* $OpenBSD: advnops.c,v 1.4 1996/04/21 22:14:40 deraadt Exp $ */
/* $NetBSD: advnops.c,v 1.22 1995/08/18 15:14:38 chopps Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
+ * Copyright (c) 1996 Matthias Scheler
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
* XXX actually we can track this if we were to walk the list
* of links if it exists.
+ * XXX for now, just set nlink to 2 if this is a hard link
+ * to a file, or a file with a hard link.
*/
- vap->va_nlink = 1;
+ vap->va_nlink = 1 + (ap->linkto != 0);
/*
* round up to nearest blocks add number of file list
* blocks needed and mutiply by number of bytes per block.
*/
- fblks = howmany(ap->fsize, amp->bsize);
+ fblks = howmany(ap->fsize, amp->dbsize);
fblks += howmany(fblks, ANODENDATBLKENT(ap));
- vap->va_bytes = fblks * amp->bsize;
+ vap->va_bytes = fblks * amp->dbsize;
vap->va_size = ap->fsize;
- vap->va_blocksize = amp->bsize;
+ vap->va_blocksize = amp->dbsize;
}
#ifdef ADOSFS_DIAGNOSTIC
printf(" 0)");
do {
/*
* we are only supporting ADosFFS currently
- * (which have data blocks of 512 bytes)
+ * (which have data blocks without headers)
*/
- size = amp->bsize;
+ size = amp->dbsize;
lbn = uio->uio_offset / size;
on = uio->uio_offset % size;
n = min((u_int)(size - on), uio->uio_resid);
* but not much as ados makes little attempt to
* make things contigous
*/
- error = bread(sp->a_vp, lbn, size, NOCRED, &bp);
+ error = bread(sp->a_vp, lbn * amp->secsperblk,
+ amp->bsize, NOCRED, &bp);
sp->a_vp->v_lastr = lbn;
- n = min(n, (u_int)size - bp->b_resid);
+
+ if (!IS_FFS(amp)) {
+ if (bp->b_resid > 0)
+ error = EIO; /* OFS needs the complete block */
+ else if (adoswordn(bp, 0) != BPT_DATA) {
+#ifdef DIAGNOSTIC
+ printf("adosfs: bad primary type blk %d\n",
+ bp->b_blkno / amp->secsperblk);
+#endif
+ error=EINVAL;
+ }
+ else if ( adoscksum(bp, ap->nwords)) {
+#ifdef DIAGNOSTIC
+ printf("adosfs: blk %d failed cksum.\n",
+ bp->b_blkno / amp->secsperblk);
+#endif
+ error=EINVAL;
+ }
+ }
+
if (error) {
brelse(bp);
goto reterr;
#ifdef ADOSFS_DIAGNOSTIC
printf(" %d+%d-%d+%d", lbn, on, lbn, n);
#endif
- error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
+ n = min(n, (u_int)size - bp->b_resid);
+ error = uiomove(bp->b_un.b_addr + on +
+ amp->bsize - amp->dbsize, (int)n, uio);
brelse(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
reterr:
#ifdef ADOSFS_DIAGNOSTIC
advopprint(sp);
#endif
- bn = sp->a_bn;
+ ap = VTOA(sp->a_vp);
+ bn = sp->a_bn / ap->amp->secsperblk;
bnp = sp->a_bnp;
error = 0;
- ap = VTOA(sp->a_vp);
if (sp->a_vpp != NULL)
*sp->a_vpp = ap->amp->devvp;
error = EINVAL;
goto reterr;
}
- error = bread(ap->amp->devvp, nb, ap->amp->bsize,
- NOCRED, &flbp);
+ error = bread(ap->amp->devvp, nb * ap->amp->secsperblk,
+ ap->amp->bsize, NOCRED, &flbp);
if (error)
goto reterr;
if (adoscksum(flbp, ap->nwords)) {
flblkoff = bn % ANODENDATBLKENT(ap);
if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) {
flblkoff = (ap->nwords - 51) - flblkoff;
- *bnp = adoswordn(flbp, flblkoff);
+ *bnp = adoswordn(flbp, flblkoff) * ap->amp->secsperblk;
} else {
#ifdef DIAGNOSTIC
printf("flblk offset %d too large in lblk %d blk %d\n",
- flblkoff, bn, flbp->b_blkno);
+ flblkoff, bn / ap->amp->secsperblk , flbp->b_blkno);
#endif
error = EINVAL;
}
-/* $OpenBSD: amiga_init.c,v 1.6 1996/03/24 15:59:41 niklas Exp $ */
-/* $NetBSD: amiga_init.c,v 1.35 1996/02/24 07:43:14 chopps Exp $ */
+/* $OpenBSD: amiga_init.c,v 1.7 1996/04/21 22:14:47 deraadt Exp $ */
+/* $NetBSD: amiga_init.c,v 1.36 1996/03/19 11:12:10 is Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
-/* $NetBSD: autoconf.c,v 1.29 1995/10/05 12:40:54 chopps Exp $ */
+/* $OpenBSD: autoconf.c,v 1.2 1996/04/21 22:14:49 deraadt Exp $ */
+/* $NetBSD: autoconf.c,v 1.31 1996/04/04 06:25:07 cgd Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
void swapconf __P((void));
void mbattach __P((struct device *, struct device *, void *));
int mbprint __P((void *, char *));
-int mbmatch __P((struct device *, struct cfdata *, void *));
+int mbmatch __P((struct device *, void *, void *));
int cold; /* 1 if still booting */
#include <sys/kernel.h>
amiga_realconfig = 1;
custom.intena = INTF_INTEN;
- if (config_rootfound("mainbus", "mainbus") == 0)
+ if (config_rootfound("mainbus", "mainbus") == NULL)
panic("no mainbus found");
custom.intena = INTF_SETCLR | INTF_INTEN;
struct cfdata *cf;
if (amiga_realconfig)
- return(config_found(pdp, auxp, pfn));
+ return(config_found(pdp, auxp, pfn) != NULL);
if (pdp == NULL)
pdp = &temp;
pdp->dv_cfdata = pcfp;
if ((cf = config_search((cfmatch_t)NULL, pdp, auxp)) != NULL) {
- cf->cf_driver->cd_attach(pdp, NULL, auxp);
+ cf->cf_attach->ca_attach(pdp, NULL, auxp);
pdp->dv_cfdata = NULL;
return(1);
}
/*
* mainbus driver
*/
-struct cfdriver mainbuscd = {
- NULL, "mainbus", (cfmatch_t)mbmatch, mbattach,
- DV_DULL, sizeof(struct device), NULL, 0
+struct cfattach mainbus_ca = {
+ sizeof(struct device), mbmatch, mbattach
+};
+
+struct cfdriver mainbus_cd = {
+ NULL, "mainbus", DV_DULL, NULL, 0
};
int
-mbmatch(pdp, cfp, auxp)
+mbmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (cfp->cf_unit > 0)
return(0);
/*
-/* $NetBSD: disksubr.c,v 1.21 1996/01/07 22:01:44 thorpej Exp $ */
+/* $OpenBSD: disksubr.c,v 1.3 1996/04/21 22:14:50 deraadt Exp $ */
+/* $NetBSD: disksubr.c,v 1.22 1996/04/05 04:50:26 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
pp = &lp->d_partitions[lp->d_npartitions];
break;
}
+ if (lp->d_npartitions <= (pp - lp->d_partitions))
+ lp->d_npartitions = (pp - lp->d_partitions) + 1;
+
+#ifdef DIAGNOSTIC
+ if (lp->d_secpercyl != (pbp->e.secpertrk * pbp->e.numheads)) {
+ if (pbp->partname[0] < sizeof(pbp->partname))
+ pbp->partname[pbp->partname[0] + 1] = 0;
+ else
+ pbp->partname[sizeof(pbp->partname) - 1] = 0;
+ printf("Partition '%s' geometry %d/%d differs",
+ pbp->partname + 1, pbp->e.numheads,
+ pbp->e.secpertrk);
+ printf(" from RDB %d/%d\n", lp->d_ntracks,
+ lp->d_nsectors);
+ }
+#endif
/*
* insert sort in increasing offset order
*/
while ((pp - lp->d_partitions) > RAW_PART + 1) {
daddr_t boff;
- boff = pbp->e.lowcyl * lp->d_secpercyl;
+ boff = pbp->e.lowcyl * pbp->e.secpertrk
+ * pbp->e.numheads;
if (boff > (pp - 1)->p_offset)
break;
*pp = *(pp - 1); /* struct copy */
nopname = 0;
}
- if (lp->d_npartitions <= i)
- lp->d_npartitions = i + 1;
-
pp->p_size = (pbp->e.highcyl - pbp->e.lowcyl + 1)
- * lp->d_secpercyl;
- pp->p_offset = pbp->e.lowcyl * lp->d_secpercyl;
+ * pbp->e.secpertrk * pbp->e.numheads;
+ pp->p_offset = pbp->e.lowcyl * pbp->e.secpertrk
+ * pbp->e.numheads;
pp->p_fstype = adt.fstype;
- if (pbp->e.tabsize > 22 && ISFSARCH_NETBSD(adt)) {
- pp->p_fsize = pbp->e.fsize;
- pp->p_frag = pbp->e.frag;
- pp->p_cpg = pbp->e.cpg;
- } else {
- pp->p_fsize = 1024;
- pp->p_frag = 8;
- pp->p_cpg = 0;
- }
if (adt.archtype == ADT_AMIGADOS) {
/*
* Save reserved blocks at begin in cpg and
* adjust size by reserved blocks at end
*/
+ pp->p_fsize = 512;
+ pp->p_frag = pbp->e.secperblk;
pp->p_cpg = pbp->e.resvblocks;
pp->p_size -= pbp->e.prefac;
+ } else if (pbp->e.tabsize > 22 && ISFSARCH_NETBSD(adt)) {
+ pp->p_fsize = pbp->e.fsize;
+ pp->p_frag = pbp->e.frag;
+ pp->p_cpg = pbp->e.cpg;
+ } else {
+ pp->p_fsize = 1024;
+ pp->p_frag = 8;
+ pp->p_cpg = 0;
}
/*
return(adt);
case DOST_MUFS:
/* check for 'muFS'? */
- case DOST_DOS:
adt.archtype = ADT_AMIGADOS;
adt.fstype = FS_ADOS;
return(adt);
+ case DOST_DOS:
+ adt.archtype = ADT_AMIGADOS;
+ if (b1 > 5)
+ adt.fstype = FS_UNUSED;
+ else
+ adt.fstype = FS_ADOS;
+ return(adt);
case DOST_AMIX:
adt.archtype = ADT_AMIX;
if (b1 == 2)
-/* $NetBSD: swapgeneric.c,v 1.20 1996/01/07 22:01:46 thorpej Exp $ */
+/* $OpenBSD: swapgeneric.c,v 1.3 1996/04/21 22:14:51 deraadt Exp $ */
+/* $NetBSD: swapgeneric.c,v 1.21 1996/03/17 05:54:41 mhitch Exp $ */
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
};
#if NFD > 0
-extern struct cfdriver fdcd;
+extern struct cfdriver fd_cd;
#endif
#if NSD > 0
-extern struct cfdriver sdcd;
+extern struct cfdriver sd_cd;
#endif
#if NCD > 0
-extern struct cfdriver cdcd;
+extern struct cfdriver cd_cd;
#endif
struct genericconf {
*/
struct genericconf genericconf[] = {
#if NFD > 0
- {&fdcd, makedev(2, 0)},
+ {&fd_cd, makedev(2, 0)},
#endif
#if NSD > 0
- {&sdcd, makedev(4, 0)},
+ {&sd_cd, makedev(4, 0)},
#endif
#if NCD > 0
- {&cdcd, makedev(7, 0)},
+ {&cd_cd, makedev(7, 0)},
#endif
{ 0 },
};
-# $OpenBSD: files.amiga,v 1.8 1996/03/30 22:18:10 niklas Exp $
-# $NetBSD: files.amiga,v 1.36 1996/03/02 14:00:32 veego Exp $
+# $OpenBSD: files.amiga,v 1.9 1996/04/21 22:14:53 deraadt Exp $
+# $NetBSD: files.amiga,v 1.41 1996/03/28 18:41:55 is Exp $
# maxpartitions must be first item in files.${ARCH}
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
maxusers 2 8 64
-device mainbus at root {}
+device mainbus {}
+attach mainbus at root
-device cpu at mainbus
+device cpu
+attach cpu at mainbus
# zorro II expansion bus.
-device zbus at mainbus {}
+device zbus {}
+attach zbus at mainbus
file arch/amiga/dev/zbus.c zbus
define event {}
file arch/amiga/dev/event.c event
-device clock at mainbus
+device clock
+attach clock at mainbus
file arch/amiga/dev/clock.c
# keyboard
-device kbd at mainbus: event
+device kbd: event
+attach kbd at mainbus
file arch/amiga/dev/kbd.c kbd needs-flag
# serial port
-device ser at mainbus: tty
+device ser: tty
+attach ser at mainbus
file arch/amiga/dev/ser.c ser needs-count
# parellel port
-device par at mainbus
+device par
+attach par at mainbus
file arch/amiga/dev/par.c par needs-count
# mouse
pseudo-device mouse
file arch/amiga/dev/ms.c mouse needs-count
-device fdc at mainbus { unit = -1 }
+device fdc { unit = -1 }
+attach fdc at mainbus
-device fd at fdc
+device fd
+attach fd at fdc
file arch/amiga/dev/fd.c fd needs-flag
major {fd = 2}
# graphic devices
define grfbus {}
-device grf at grfbus {}
+device grf {}
+attach grf at grfbus
file arch/amiga/dev/grf.c grf needs-count
-device ite at grf
+device ite
+attach ite at grf
file arch/amiga/dev/ite.c ite needs-flag
file arch/amiga/dev/kbdmap.c ite
file arch/amiga/dev/kf_8x8.c ite
file arch/amiga/dev/kf_custom.c kfont_custom
# custom chips grf
-device grfcc at mainbus: grfbus
+device grfcc: grfbus
+attach grfcc at mainbus
file arch/amiga/dev/grf_cc.c grfcc needs-flag
-file arch/amiga/dev/ite_cc.c grfcc ite
+file arch/amiga/dev/ite_cc.c grfcc & ite
pseudo-device view
-file arch/amiga/dev/view.c view grfcc needs-count
-file arch/amiga/dev/grfabs.c grfcc view
-file arch/amiga/dev/grfabs_cc.c grfcc view
-file arch/amiga/dev/grfabs_ccglb.c grfcc view
+file arch/amiga/dev/view.c view | grfcc needs-count
+file arch/amiga/dev/grfabs.c grfcc | view
+file arch/amiga/dev/grfabs_cc.c grfcc | view
+file arch/amiga/dev/grfabs_ccglb.c grfcc | view
# retina grf
-device grfrt at zbus: grfbus
+device grfrt: grfbus
+attach grfrt at zbus
file arch/amiga/dev/grf_rt.c grfrt needs-flag
-file arch/amiga/dev/ite_rt.c grfrt ite
+file arch/amiga/dev/ite_rt.c grfrt & ite
# cirrus grf
-device grfcl at zbus: grfbus
+device grfcl: grfbus
+attach grfcl at zbus
file arch/amiga/dev/grf_cl.c grfcl needs-flag
-file arch/amiga/dev/ite_cl.c grfcl ite
+file arch/amiga/dev/ite_cl.c grfcl & ite
# CyberVison 64 grf
-device grfcv at zbus: grfbus
+device grfcv: grfbus
+attach grfcv at zbus
file arch/amiga/dev/grf_cv.c grfcv needs-flag
-file arch/amiga/dev/ite_cv.c grfcv ite
+file arch/amiga/dev/ite_cv.c grfcv & ite
# A2410 grf
-device grful at zbus: grfbus
+device grful: grfbus
+attach grful at zbus
file arch/amiga/dev/grf_ul.c grful needs-flag
-file arch/amiga/dev/ite_ul.c grful ite
-file arch/amiga/dev/grf_ultms.g grful
+file arch/amiga/dev/ite_ul.c grful & ite
+file arch/amiga/dev/grf_ultms.g grful
# retina ZIII grf
-device grfrh at zbus: grfbus
+device grfrh: grfbus
+attach grfrh at zbus
file arch/amiga/dev/grf_rh.c grfrh needs-flag
-file arch/amiga/dev/ite_rh.c grfrh ite
+file arch/amiga/dev/ite_rh.c grfrh & ite
# handle gvp's odd autoconf info..
-device gvpbus at zbus {}
+device gvpbus {}
+attach gvpbus at zbus
file arch/amiga/dev/gvpbus.c gvpbus
-device le at zbus: ifnet, ether
-file arch/amiga/dev/if_le.c le needs-flag
+device le: ifnet, ether
+attach le at zbus with le_zbus
+file arch/amiga/dev/if_le.c le_zbus needs-flag
-device ed at zbus: ifnet, ether
-file arch/amiga/dev/if_ed.c ed needs-flag
+device ed: ifnet, ether
+attach ed at zbus with ed_zbus
+file arch/amiga/dev/if_ed.c ed_zbus needs-flag
# C=/Ameristar A2060 / 560
-device bah at zbus: ifnet, arc
-file arch/amiga/dev/if_bah.c bah needs-flag
+device bah: ifnet, arc
+attach bah at zbus with bah_zbus
+file arch/amiga/dev/if_bah.c bah_zbus needs-flag
-device es at zbus: ifnet, ether
+device es: ifnet, ether
+attach es at zbus
file arch/amiga/dev/if_es.c es needs-flag
-device qn at zbus: ifnet, ether
+device qn: ifnet, ether
+attach qn at zbus
file arch/amiga/dev/if_qn.c qn needs-flag
-device ae at zbus: ifnet, ether
+device ae: ifnet, ether
+attach ae at zbus
file arch/amiga/dev/if_ae.c ae needs-count
# A2232 msc serial ports
-device msc at zbus: tty
+device msc: tty
+attach msc at zbus
file arch/amiga/dev/msc.c msc needs-count
# bsc/Alf Data MultiFaceCard
-device mfc at zbus { unit = -1 }
+device mfc { unit = -1 }
+attach mfc at zbus
-device mfcs at mfc
-device mfcp at mfc
-file arch/amiga/dev/mfc.c mfcs mfcp needs-count
+device mfcs
+attach mfcs at mfc
+device mfcp
+attach mfcp at mfc
+file arch/amiga/dev/mfc.c mfcs | mfcp needs-count
include "../../../scsi/files.scsi"
file arch/amiga/dev/sbic.c sbic
# C= A2091
-device atzsc at zbus: scsi, sbic
+device atzsc: scsi, sbic
+attach atzsc at zbus
file arch/amiga/dev/atzsc.c atzsc needs-flag
# GVP series II
-device gtsc at gvpbus: scsi, sbic
+device gtsc: scsi, sbic
+attach gtsc at gvpbus
file arch/amiga/dev/gtsc.c gtsc needs-flag
# Amiga 3000 internal
-device ahsc at mainbus: scsi, sbic
+device ahsc: scsi, sbic
+attach ahsc at mainbus
file arch/amiga/dev/ahsc.c ahsc needs-flag
# ncr 57c710 controllers
file arch/amiga/dev/siop.c siop
# PPI Zeus
-device zssc at zbus: scsi, siop
+device zssc: scsi, siop
+attach zssc at zbus
file arch/amiga/dev/zssc.c zssc needs-flag
# CSA Magnum
-device mgnsc at zbus: scsi, siop
+device mgnsc: scsi, siop
+attach mgnsc at zbus
file arch/amiga/dev/mgnsc.c mgnsc needs-flag
# MacroSystems Warp Engine
-device wesc at zbus: scsi, siop
+device wesc: scsi, siop
+attach wesc at zbus
file arch/amiga/dev/wesc.c wesc needs-flag
# C= A4091
-device afsc at zbus: scsi, siop
-device aftsc at mainbus: scsi, siop
-file arch/amiga/dev/afsc.c afsc aftsc needs-flag
+device afsc: scsi, siop
+attach afsc at zbus
+device aftsc: scsi, siop
+attach aftsc at mainbus
+file arch/amiga/dev/afsc.c afsc | aftsc needs-flag
# ncr 5380 controllers
define sci
file arch/amiga/dev/sci.c sci
# Supra Wordsync II
-device wstsc at zbus: scsi, sci
+device wstsc: scsi, sci
+attach wstsc at zbus
file arch/amiga/dev/wstsc.c wstsc needs-flag
# IVS
-device ivsc at zbus: scsi, sci
+device ivsc: scsi, sci
+attach ivsc at zbus
file arch/amiga/dev/ivsc.c ivsc needs-flag
# CSA twelve gauge.
-device otgsc at zbus: scsi, sci
+device otgsc: scsi, sci
+attach otgsc at zbus
file arch/amiga/dev/otgsc.c otgsc needs-flag
# MLH
-device mlhsc at zbus: scsi, sci
+device mlhsc: scsi, sci
+attach mlhsc at zbus
file arch/amiga/dev/mlhsc.c mlhsc needs-flag
+# Emplant
+device empsc: scsi, sci
+attach empsc at zbus
+file arch/amiga/dev/empsc.c empsc needs-flag
+
# Emulex ESP216 & FAS216 controllers
define sfas
file arch/amiga/dev/sfas.c sfas
# FastlaneZ3
-device flsc at zbus: scsi, sfas
+device flsc: scsi, sfas
+attach flsc at zbus
file arch/amiga/dev/flsc.c flsc needs-flag
# Blizzard1230
-device bzsc at zbus: scsi, sfas
+device bzsc: scsi, sfas
+attach bzsc at zbus
file arch/amiga/dev/bzsc.c bzsc needs-flag
# Amiga 4000/1200 IDE masquerading as SCSI
-device idesc at mainbus: scsi
+device idesc: scsi
+attach idesc at mainbus
file arch/amiga/dev/idesc.c idesc needs-flag
#
file arch/amiga/isa/if_isaed.c isaed
# list of standard files...
-file dev/cons.c ite ser
-file dev/cninit.c ite ser
+file dev/cons.c ite | ser
+file dev/cninit.c ite | ser
file arch/amiga/amiga/amiga_init.c
file arch/amiga/amiga/autoconf.c
file arch/amiga/amiga/cia.c
-/* $OpenBSD: afsc.c,v 1.3 1996/03/30 22:18:12 niklas Exp $ */
-/* $NetBSD: afsc.c,v 1.11 1996/03/15 22:11:09 mhitch Exp $ */
+/* $OpenBSD: afsc.c,v 1.4 1996/04/21 22:14:56 deraadt Exp $ */
+/* $NetBSD: afsc.c,v 1.13 1996/03/18 04:58:36 mhitch Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int afscprint __P((void *auxp, char *));
void afscattach __P((struct device *, struct device *, void *));
-int afscmatch __P((struct device *, struct cfdata *, void *));
+int afscmatch __P((struct device *, void *, void *));
int siopintr __P((struct siop_softc *));
int afsc_dmaintr __P((struct siop_softc *));
#ifdef DEBUG
#endif
-struct cfdriver afsccd = {
- NULL, "afsc", (cfmatch_t)afscmatch, afscattach,
- DV_DULL, sizeof(struct siop_softc), NULL, 0 };
-struct cfdriver aftsccd = {
- NULL, "aftsc", (cfmatch_t)afscmatch, afscattach,
- DV_DULL, sizeof(struct siop_softc), NULL, 0 };
+struct cfattach afsc_ca = {
+ sizeof(struct siop_softc), afscmatch, afscattach
+};
+
+struct cfdriver afsc_cd = {
+ NULL, "afsc", DV_DULL, NULL, 0
+};
+
+struct cfattach aftsc_ca = {
+ sizeof(struct siop_softc), afscmatch, afscattach
+};
+
+struct cfdriver aftsc_cd = {
+ NULL, "aftsc", DV_DULL, NULL, 0
+};
/*
* if we are a Commodore Amiga A4091 or possibly an A4000T
*/
int
-afscmatch(pdp, cdp, auxp)
+afscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
siop_regmap_p rp;
u_long temp, scratch;
{
int i;
- for (i = 0; i < afsccd.cd_ndevs; ++i)
- if (afsccd.cd_devs[i])
- siop_dump(afsccd.cd_devs[i]);
+ for (i = 0; i < afsc_cd.cd_ndevs; ++i)
+ if (afsc_cd.cd_devs[i])
+ siop_dump(afsc_cd.cd_devs[i]);
}
#endif
-/* $NetBSD: ahsc.c,v 1.10 1995/09/04 13:04:40 chopps Exp $ */
+/* $OpenBSD: ahsc.c,v 1.2 1996/04/21 22:14:57 deraadt Exp $ */
+/* $NetBSD: ahsc.c,v 1.11 1996/03/17 01:17:00 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
int ahscprint __P((void *auxp, char *));
void ahscattach __P((struct device *, struct device *, void *));
-int ahscmatch __P((struct device *, struct cfdata *, void *));
+int ahscmatch __P((struct device *, void *, void *));
void ahsc_enintr __P((struct sbic_softc *));
void ahsc_dmastop __P((struct sbic_softc *));
int ahsc_dmadebug = 0;
#endif
-struct cfdriver ahsccd = {
- NULL, "ahsc", (cfmatch_t)ahscmatch, ahscattach,
- DV_DULL, sizeof(struct sbic_softc), NULL, 0 };
+struct cfattach ahsc_ca = {
+ sizeof(struct sbic_softc), ahscmatch, ahscattach
+};
+
+struct cfdriver ahsc_cd = {
+ NULL, "ahsc", DV_DULL, NULL, 0
+};
/*
* if we are an A3000 we are here.
*/
int
-ahscmatch(pdp, cdp, auxp)
+ahscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
char *mbusstr;
mbusstr = auxp;
{
int i;
- for (i = 0; i < ahsccd.cd_ndevs; ++i)
- if (ahsccd.cd_devs[i])
- sbic_dump(ahsccd.cd_devs[i]);
+ for (i = 0; i < ahsc_cd.cd_ndevs; ++i)
+ if (ahsc_cd.cd_devs[i])
+ sbic_dump(ahsc_cd.cd_devs[i]);
}
#endif
-/* $NetBSD: atzsc.c,v 1.13 1995/09/04 13:04:42 chopps Exp $ */
+/* $OpenBSD: atzsc.c,v 1.2 1996/04/21 22:14:59 deraadt Exp $ */
+/* $NetBSD: atzsc.c,v 1.15 1996/03/18 04:58:37 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
int atzscprint __P((void *auxp, char *));
void atzscattach __P((struct device *, struct device *, void *));
-int atzscmatch __P((struct device *, struct cfdata *, void *));
+int atzscmatch __P((struct device *, void *, void *));
void atzsc_enintr __P((struct sbic_softc *));
void atzsc_dmastop __P((struct sbic_softc *));
int atzsc_dmadebug = 0;
#endif
-struct cfdriver atzsccd = {
- NULL, "atzsc", (cfmatch_t)atzscmatch, atzscattach,
- DV_DULL, sizeof(struct sbic_softc), NULL, 0 };
+struct cfattach atzsc_ca = {
+ sizeof(struct sbic_softc), atzscmatch, atzscattach
+};
+
+struct cfdriver atzsc_cd = {
+ NULL, "atzsc", DV_DULL, NULL, 0
+};
/*
* if we are an A3000 we are here.
*/
int
-atzscmatch(pdp, cdp, auxp)
+atzscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
{
int i;
- for (i = 0; i < atzsccd.cd_ndevs; ++i)
- if (atzsccd.cd_devs[i])
- sbic_dump(atzsccd.cd_devs[i]);
+ for (i = 0; i < atzsc_cd.cd_ndevs; ++i)
+ if (atzsc_cd.cd_devs[i])
+ sbic_dump(atzsc_cd.cd_devs[i]);
}
#endif
+/* $OpenBSD: bzsc.c,v 1.2 1996/04/21 22:15:00 deraadt Exp $ */
+
/*
* Copyright (c) 1995 Daniel Widenfalk
* Copyright (c) 1994 Christian E. Hopps
int bzscprint __P((void *auxp, char *));
void bzscattach __P((struct device *, struct device *, void *));
-int bzscmatch __P((struct device *, struct cfdata *, void *));
+int bzscmatch __P((struct device *, void *, void *));
struct scsi_adapter bzsc_scsiswitch = {
sfas_scsicmd,
NULL, /* Use default done routine */
};
+struct cfattach bzsc_ca = {
+ sizeof(struct bzsc_softc), bzscmatch, bzscattach
+};
-struct cfdriver bzsccd = {
- NULL, "bzsc", (cfmatch_t)bzscmatch, bzscattach,
- DV_DULL, sizeof(struct bzsc_softc), NULL, 0 };
+struct cfdriver bzsc_cd = {
+ NULL, "bzsc", DV_DULL, NULL, 0
+};
int bzsc_intr __P((struct sfas_softc *dev));
int bzsc_setup_dma __P((struct sfas_softc *sc, void *ptr, int len,
/*
* if we are an Advanced Systems & Software FastlaneZ3
*/
-int bzscmatch(struct device *pdp, struct cfdata *cdp, void *auxp)
+int bzscmatch(struct device *pdp, void *match, void *auxp)
{
struct zbus_args *zap;
-/* $NetBSD: clock.c,v 1.10 1995/02/20 00:53:42 chopps Exp $ */
+/* $OpenBSD: clock.c,v 1.4 1996/04/21 22:15:01 deraadt Exp $ */
+/* $NetBSD: clock.c,v 1.12 1996/03/17 05:58:30 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* periods where N is the value loaded into the counter.
*/
-int clockmatch __P((struct device *, struct cfdata *, void *));
+int clockmatch __P((struct device *, void *, void *));
void clockattach __P((struct device *, struct device *, void *));
-struct cfdriver clockcd = {
- NULL, "clock", (cfmatch_t)clockmatch, clockattach,
- DV_DULL, sizeof(struct device), NULL, 0 };
+struct cfattach clock_ca = {
+ sizeof(struct device), clockmatch, clockattach
+};
+
+struct cfdriver clock_cd = {
+ NULL, "clock", DV_DULL, NULL, 0 };
int
-clockmatch(pdp, cfp, auxp)
+clockmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (matchname("clock", auxp))
return(1);
return(0);
--- /dev/null
+/* $OpenBSD: empsc.c,v 1.1 1996/04/21 22:15:02 deraadt Exp $ */
+/* $NetBSD: empsc.c,v 1.4 1996/04/05 15:53:41 is Exp $ */
+
+/*
+
+ * Copyright (c) 1995 Sean Riddle, Bo Najdrovsky
+ * Copyright (c) 1994 Michael L. Hitch
+ * Copyright (c) 1982, 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <scsi/scsi_all.h>
+#include <scsi/scsiconf.h>
+#include <amiga/amiga/custom.h>
+#include <amiga/amiga/device.h>
+#include <amiga/amiga/isr.h>
+#include <amiga/dev/scireg.h>
+#include <amiga/dev/scivar.h>
+#include <amiga/dev/zbusvar.h>
+
+int empscprint __P((void *auxp, char *));
+void empscattach __P((struct device *, struct device *, void *));
+int empscmatch __P((struct device *, struct cfdata *, void *));
+int empsc_intr __P((struct sci_softc *));
+
+struct scsi_adapter empsc_scsiswitch = {
+ sci_scsicmd,
+ sci_minphys,
+ 0, /* no lun support */
+ 0, /* no lun support */
+};
+
+struct scsi_device empsc_scsidev = {
+ NULL, /* use default error handler */
+ NULL, /* do not have a start functio */
+ NULL, /* have no async handler */
+ NULL, /* Use default done routine */
+};
+
+#define QPRINTF
+
+#ifdef DEBUG
+extern int sci_debug;
+#endif
+
+extern int sci_data_wait;
+
+struct cfattach empsc_ca = {
+ sizeof(struct sci_softc), empscmatch, empscattach
+};
+
+struct cfdriver empsc_cd = {
+ NULL, "empsc", DV_DULL, NULL, 0
+};
+
+/*
+ * if this is an EMPLANT board
+ */
+int
+empscmatch(pdp, match, auxp)
+ struct device *pdp;
+ void *match, *auxp;
+{
+ struct zbus_args *zap;
+
+ zap = auxp;
+
+ /*
+ * Check manufacturer and product id.
+ */
+ if (zap->manid == 2171 && ((zap->prodid == 21)||(zap->prodid==32)))
+ return(1);
+ else
+ return(0);
+}
+
+void
+empscattach(pdp, dp, auxp)
+ struct device *pdp, *dp;
+ void *auxp;
+{
+ volatile u_char *rp;
+ struct sci_softc *sc;
+ struct zbus_args *zap;
+
+ printf("\n");
+
+ zap = auxp;
+
+ sc = (struct sci_softc *)dp;
+ rp = zap->va + 0x5000;
+
+ sc->sci_data = rp;
+ sc->sci_odata = rp;
+ sc->sci_icmd = rp + 0x10;
+ sc->sci_mode = rp + 0x20;
+ sc->sci_tcmd = rp + 0x30;
+ sc->sci_bus_csr = rp + 0x40;
+ sc->sci_sel_enb = rp + 0x40;
+ sc->sci_csr = rp + 0x50;
+ sc->sci_dma_send = rp + 0x50;
+ sc->sci_idata = rp + 0x60;
+ sc->sci_trecv = rp + 0x60;
+ sc->sci_iack = rp + 0x70;
+ sc->sci_irecv = rp + 0x70;
+ sc->sc_isr.isr_intr = empsc_intr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = 2;
+ add_isr(&sc->sc_isr);
+
+ scireset(sc);
+
+ sc->sc_link.adapter_softc = sc;
+ sc->sc_link.adapter_target = 7;
+ sc->sc_link.adapter = &empsc_scsiswitch;
+ sc->sc_link.device = &empsc_scsidev;
+ sc->sc_link.openings = 1;
+ TAILQ_INIT(&sc->sc_xslist);
+
+ /*
+ * attach all scsi units on us
+ */
+ config_found(dp, &sc->sc_link, empscprint);
+}
+
+/*
+ * print diag if pnp is NULL else just extra
+ */
+int
+empscprint(auxp, pnp)
+ void *auxp;
+ char *pnp;
+{
+ if (pnp == NULL)
+ return(UNCONF);
+ return(QUIET);
+}
+
+int
+empsc_intr(dev)
+ struct sci_softc *dev;
+{
+ u_char stat;
+
+ if ((*dev->sci_csr & SCI_CSR_INT) == 0)
+ return(0);
+ stat = *dev->sci_iack;
+ /* XXXX is: something is missing here, at least a: */
+ return(1);
+}
-/* $NetBSD: fd.c,v 1.25 1996/01/28 19:48:39 chopps Exp $ */
+/* $OpenBSD: fd.c,v 1.5 1996/04/21 22:15:04 deraadt Exp $ */
+/* $NetBSD: fd.c,v 1.28 1996/04/05 05:08:07 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
int unit;
};
-int fdmatch __P((struct device *, struct cfdata *, void *));
-int fdcmatch __P((struct device *, struct cfdata *, void *));
+int fdmatch __P((struct device *, void *, void *));
+int fdcmatch __P((struct device *, void *, void *));
int fdcprint __P((void *, char *));
void fdcattach __P((struct device *, struct device *, void *));
void fdattach __P((struct device *, struct device *, void *));
};
int nfdtype = sizeof(fdtype) / sizeof(*fdtype);
-struct cfdriver fdcd = {
- NULL, "fd", (cfmatch_t)fdmatch, fdattach, DV_DISK,
- sizeof(struct fd_softc), NULL, 0 };
+struct cfattach fd_ca = {
+ sizeof(struct fd_softc), fdmatch, fdattach
+};
+
+struct cfdriver fd_cd = {
+ NULL, "fd", DV_DISK, NULL, 0
+};
+
+struct cfattach fdc_ca = {
+ sizeof(struct device), fdcmatch, fdcattach
+};
-struct cfdriver fdccd = {
- NULL, "fdc", (cfmatch_t)fdcmatch, fdcattach, DV_DULL,
- sizeof(struct device), NULL, 0 };
+struct cfdriver fdc_cd = {
+ NULL, "fdc", DV_DULL, NULL, 0
+};
/*
* all hw access through macros, this helps to hide the active low
int
-fdcmatch(pdp, cfp, auxp)
+fdcmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (matchname("fdc", auxp) == 0 || cfp->cf_unit != 0)
return(0);
if ((fdc_dmap = alloc_chipmem(DMABUFSZ)) == NULL) {
/*ARGSUSED*/
int
-fdmatch(pdp, cfp, auxp)
+fdmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
#define cf_unit cf_loc[0]
struct fdcargs *fdap;
if (FDPART(dev) >= FDMAXPARTS)
return(ENXIO);
- if ((sc = getsoftc(fdcd, FDUNIT(dev))) == NULL)
+ if ((sc = getsoftc(fd_cd, FDUNIT(dev))) == NULL)
return(ENXIO);
if (sc->flags & FDF_NOTRACK0)
return(ENXIO);
#ifdef FDDEBUG
printf("fdclose()\n");
#endif
- sc = getsoftc(fdcd, FDUNIT(dev));
+ sc = getsoftc(fd_cd, FDUNIT(dev));
s = splbio();
if (sc->flags & FDF_MOTORON) {
sc->flags |= FDF_WMOTOROFF;
void *data;
int error, wlab;
- sc = getsoftc(fdcd, FDUNIT(dev));
+ sc = getsoftc(fd_cd, FDUNIT(dev));
if ((sc->flags & FDF_HAVELABEL) == 0)
return(EBADF);
unit = FDUNIT(bp->b_dev);
part = FDPART(bp->b_dev);
- sc = getsoftc(fdcd, unit);
+ sc = getsoftc(fd_cd, unit);
#ifdef FDDEBUG
printf("fdstrategy: 0x%x\n", bp);
lp->d_partitions[part].p_fstype = FS_UNUSED;
lp->d_partitions[part].p_fsize = 1024;
lp->d_partitions[part].p_frag = 8;
+ lp->d_partitions[part].p_cpg = 2; /* for adosfs: reserved blks */
sc->flags |= FDF_HAVELABEL;
lp->d_partitions[part].p_fstype = FS_UNUSED;
lp->d_partitions[part].p_fsize = 1024;
lp->d_partitions[part].p_frag = 8;
+ lp->d_partitions[part].p_cpg = 2; /* adosfs: reserved blocks */
lp->d_npartitions = part + 1;
lp->d_magic = lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
for (i = unit + 1; last == 0; i++) {
if (i == unit)
last = 1;
- if (i >= fdcd.cd_ndevs) {
+ if (i >= fd_cd.cd_ndevs) {
i = -1;
continue;
}
- if ((sc = fdcd.cd_devs[i]) == NULL)
+ if ((sc = fd_cd.cd_devs[i]) == NULL)
continue;
/*
struct fd_softc *sc;
int trk, sec, toff, tsz;
- if ((sc = getsoftc(fdcd, FDUNIT(bp->b_dev))) == NULL)
+ if ((sc = getsoftc(fd_cd, FDUNIT(bp->b_dev))) == NULL)
panic("fdminphys: couldn't get softc");
trk = bp->b_blkno / sc->nsectors;
+/* $OpenBSD: flsc.c,v 1.2 1996/04/21 22:15:05 deraadt Exp $ */
+
/*
* Copyright (c) 1995 Daniel Widenfalk
* Copyright (c) 1994 Christian E. Hopps
int flscprint __P((void *auxp, char *));
void flscattach __P((struct device *, struct device *, void *));
-int flscmatch __P((struct device *, struct cfdata *, void *));
+int flscmatch __P((struct device *, void *, void *));
struct scsi_adapter flsc_scsiswitch = {
sfas_scsicmd,
NULL, /* Use default done routine */
};
+struct cfattach flsc_ca = {
+ sizeof(struct flsc_softc), flscmatch, flscattach
+};
-struct cfdriver flsccd = {
- NULL, "flsc", (cfmatch_t)flscmatch, flscattach,
- DV_DULL, sizeof(struct flsc_softc), NULL, 0 };
+struct cfdriver flsc_cd = {
+ NULL, "flsc", DV_DULL, NULL, 0
+};
int flsc_intr __P((struct sfas_softc *dev));
int flsc_setup_dma __P((struct sfas_softc *sc, void *ptr, int len,
* if we are an Advanced Systems & Software FastlaneZ3
*/
int
-flscmatch(pdp, cdp, auxp)
+flscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
struct zbus_args *zap;
-/* $NetBSD: grf.c,v 1.23.2.1 1995/10/20 11:01:06 chopps Exp $ */
+/* $OpenBSD: grf.c,v 1.3 1996/04/21 22:15:08 deraadt Exp $ */
+/* $NetBSD: grf.c,v 1.25 1996/03/17 01:17:09 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#endif
void grfattach __P((struct device *, struct device *, void *));
-int grfmatch __P((struct device *, struct cfdata *, void *));
+int grfmatch __P((struct device *, void *, void *));
int grfprint __P((void *, char *));
/*
* pointers to grf drivers device structs
*/
struct grf_softc *grfsp[NGRF];
+struct cfattach grf_ca = {
+ sizeof(struct device), grfmatch, grfattach
+};
-struct cfdriver grfcd = {
- NULL, "grf", (cfmatch_t)grfmatch, grfattach, DV_DULL,
- sizeof(struct device), NULL, 0 };
+struct cfdriver grf_cd = {
+ NULL, "grf", DV_DULL, NULL, 0
+};
/*
* only used in console init.
* low level board driver.
*/
int
-grfmatch(pdp, cfp, auxp)
+grfmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (cfp->cf_unit != ((struct grf_softc *)pdp)->g_unit)
return(0);
cfdata = cfp;
-/* $NetBSD: grf_cc.c,v 1.17 1995/02/16 21:57:34 chopps Exp $ */
+/* $OpenBSD: grf_cc.c,v 1.2 1996/04/21 22:15:09 deraadt Exp $ */
+/* $NetBSD: grf_cc.c,v 1.18 1996/03/17 01:17:10 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
#include <amiga/dev/viewioctl.h>
-int grfccmatch __P((struct device *, struct cfdata *, void *));
+int grfccmatch __P((struct device *, void *, void *));
int grfccprint __P((void *, char *));
void grfccattach __P((struct device *, struct device *, void *));
void grf_cc_on __P((struct grf_softc *));
-struct cfdriver grfcccd = {
- NULL, "grfcc", (cfmatch_t)grfccmatch, grfccattach,
- DV_DULL, sizeof(struct grf_softc), NULL, 0 };
+struct cfattach grfcc_ca = {
+ sizeof(struct grf_softc), grfccmatch, grfccattach
+};
+
+struct cfdriver grfcc_cd = {
+ NULL, "grfcc", DV_DULL, NULL, 0
+};
/*
* only used in console init
* tricky regarding the console.
*/
int
-grfccmatch(pdp, cfp, auxp)
+grfccmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
static int ccconunit = -1;
char *mainbus_name = auxp;
-/* $OpenBSD: grf_cl.c,v 1.2 1996/03/30 22:18:13 niklas Exp $ */
-/* $NetBSD: grf_cl.c,v 1.6 1996/03/05 18:08:33 is Exp $ */
+/* $OpenBSD: grf_cl.c,v 1.3 1996/04/21 22:15:10 deraadt Exp $ */
+/* $NetBSD: grf_cl.c,v 1.8 1996/03/17 05:58:35 mhitch Exp $ */
/*
* Copyright (c) 1995 Ezra Story
void grfclattach __P((struct device *, struct device *, void *));
int grfclprint __P((void *, char *));
-int grfclmatch __P((struct device *, struct cfdata *, void *));
+int grfclmatch __P((struct device *, void *, void *));
void cl_memset __P((unsigned char *d, unsigned char c, int l));
/* Graphics display definitions.
static unsigned char cl_sprred[2], cl_sprgreen[2], cl_sprblue[2];
/* standard driver stuff */
-struct cfdriver grfclcd = {
- NULL, "grfcl", (cfmatch_t) grfclmatch, grfclattach,
- DV_DULL, sizeof(struct grf_softc), NULL, 0
+struct cfattach grfcl_ca = {
+ sizeof(struct grf_softc), grfclmatch, grfclattach
+};
+
+struct cfdriver grfcl_cd = {
+ NULL, "grfcl", DV_DULL, NULL, 0
};
static struct cfdata *cfdata;
int
-grfclmatch(pdp, cfp, auxp)
+grfclmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
struct zbus_args *zap;
static int regprod, fbprod;
-/* $OpenBSD: grf_cv.c,v 1.6 1996/03/30 22:18:15 niklas Exp $ */
-/* $NetBSD: grf_cv.c,v 1.9 1996/03/06 16:40:16 is Exp $ */
+/* $OpenBSD: grf_cv.c,v 1.7 1996/04/21 22:15:11 deraadt Exp $ */
+/* $NetBSD: grf_cv.c,v 1.11 1996/03/17 05:58:36 mhitch Exp $ */
/*
* Copyright (c) 1995 Michael Teske
#include <amiga/dev/grf_cvreg.h>
#include <amiga/dev/zbusvar.h>
-int grfcvmatch __P((struct device *, struct cfdata *, void *));
+int grfcvmatch __P((struct device *, void *, void *));
void grfcvattach __P((struct device *, struct device *, void *));
int grfcvprint __P((void *, char *));
#endif
/* standard driver stuff */
-struct cfdriver grfcvcd = {
- NULL, "grfcv", (cfmatch_t)grfcvmatch, grfcvattach,
- DV_DULL, sizeof(struct grf_softc), NULL, 0
+struct cfattach grfcv_ca = {
+ sizeof(struct grf_softc), grfcvmatch, grfcvattach
+};
+
+struct cfdriver grfcv_cd = {
+ NULL, "grfcv", DV_DULL, NULL, 0
};
static struct cfdata *cfdata;
}
int
-grfcvmatch(pdp, cfp, auxp)
+grfcvmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
struct zbus_args *zap;
static int cvcons_unit = -1;
-/* $OpenBSD: grf_rh.c,v 1.3 1996/03/30 22:18:18 niklas Exp $ */
-/* $NetBSD: grf_rh.c,v 1.11 1996/03/06 20:13:28 is Exp $ */
+/* $OpenBSD: grf_rh.c,v 1.4 1996/04/21 22:15:13 deraadt Exp $ */
+/* $NetBSD: grf_rh.c,v 1.13 1996/03/17 05:58:39 mhitch Exp $ */
/*
* Copyright (c) 1994 Markus Wild
int rh_mode __P((struct grf_softc *, int, void *, int, int));
void grfrhattach __P((struct device *, struct device *, void *));
int grfrhprint __P((void *, char *));
-int grfrhmatch __P((struct device *, struct cfdata *, void *));
+int grfrhmatch __P((struct device *, void *, void *));
-struct cfdriver grfrhcd = {
- NULL, "grfrh", (cfmatch_t)grfrhmatch, grfrhattach,
- DV_DULL, sizeof(struct grf_softc), NULL, 0
+struct cfattach grfrh_ca = {
+ sizeof(struct grf_softc), grfrhmatch, grfrhattach
+};
+
+struct cfdriver grfrh_cd = {
+ NULL, "grfrh", DV_DULL, NULL, 0
};
static struct cfdata *cfdata;
int
-grfrhmatch(pdp, cfp, auxp)
+grfrhmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
#ifdef RETINACONSOLE
static int rhconunit = -1;
#endif
-/* $NetBSD: grf_rt.c,v 1.23 1996/01/28 19:19:12 chopps Exp $ */
+/* $OpenBSD: grf_rt.c,v 1.3 1996/04/21 22:15:15 deraadt Exp $ */
+/* $NetBSD: grf_rt.c,v 1.24 1996/03/17 01:17:18 thorpej Exp $ */
/*
* Copyright (c) 1993 Markus Wild
void grfrtattach __P((struct device *, struct device *, void *));
int grfrtprint __P((void *, char *));
-int grfrtmatch __P((struct device *, struct cfdata *, void *));
+int grfrtmatch __P((struct device *, void *, void *));
+
+struct cfattach grfrt_ca = {
+ sizeof(struct grf_softc), grfrtmatch, grfrtattach
+};
-struct cfdriver grfrtcd = {
- NULL, "grfrt", (cfmatch_t)grfrtmatch, grfrtattach,
- DV_DULL, sizeof(struct grf_softc), NULL, 0 };
+struct cfdriver grfrt_cd = {
+ NULL, "grfrt", DV_DULL, NULL, 0
+};
/*
* only used in console init
* tricky regarding the console.
*/
int
-grfrtmatch(pdp, cfp, auxp)
+grfrtmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
#ifdef RETINACONSOLE
static int rtconunit = -1;
#endif
-/* $OpenBSD: grf_ul.c,v 1.5 1996/03/30 22:18:19 niklas Exp $ */
-/* $NetBSD: grf_ul.c,v 1.12 1996/03/04 19:49:11 is Exp $ */
+/* $OpenBSD: grf_ul.c,v 1.6 1996/04/21 22:15:16 deraadt Exp $ */
+/* $NetBSD: grf_ul.c,v 1.14 1996/03/17 05:58:41 mhitch Exp $ */
#define UL_DEBUG
void grfulattach __P((struct device *, struct device *, void *));
int grfulprint __P((void *, char *));
-int grfulmatch __P((struct device *, struct cfdata *, void *));
+int grfulmatch __P((struct device *, void *, void *));
-struct cfdriver grfulcd = {
- NULL, "grful", (cfmatch_t)grfulmatch, grfulattach,
- DV_DULL, sizeof(struct grf_ul_softc), NULL, 0 };
+struct cfattach grful_ca = {
+ sizeof(struct grf_ul_softc), grfulmatch, grfulattach
+};
+
+struct cfdriver grful_cd = {
+ NULL, "grful", DV_DULL, NULL, 0
+};
/*
* only used in console init
* tricky regarding the console.
*/
int
-grfulmatch(pdp, cfp, auxp)
+grfulmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
#ifdef ULOWELLCONSOLE
static int ulconunit = -1;
#endif
-/* $NetBSD: gtsc.c,v 1.13 1995/09/04 13:04:43 chopps Exp $ */
+/* $OpenBSD: gtsc.c,v 1.2 1996/04/21 22:15:17 deraadt Exp $ */
+/* $NetBSD: gtsc.c,v 1.14 1996/03/17 01:17:22 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
#include <amiga/dev/gvpbusvar.h>
void gtscattach __P((struct device *, struct device *, void *));
-int gtscmatch __P((struct device *, struct cfdata *, void *));
+int gtscmatch __P((struct device *, void *, void *));
int gtscprint __P((void *auxp, char *));
void gtsc_enintr __P((struct sbic_softc *));
int gtsc_debug = 0;
#endif
-struct cfdriver gtsccd = {
- NULL, "gtsc", (cfmatch_t)gtscmatch, gtscattach,
- DV_DULL, sizeof(struct sbic_softc), NULL, 0 };
+struct cfattach gtsc_ca = {
+ sizeof(struct sbic_softc), gtscmatch, gtscattach
+};
+
+struct cfdriver gtsc_cd = {
+ NULL, "gtsc", DV_DULL, NULL, 0
+};
int
-gtscmatch(pdp, cdp, auxp)
+gtscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct gvpbus_args *gap;
gap = auxp;
{
int i;
- for (i = 0; i < gtsccd.cd_ndevs; ++i)
- if (gtsccd.cd_devs[i])
- sbic_dump(gtsccd.cd_devs[i]);
+ for (i = 0; i < gtsc_cd.cd_ndevs; ++i)
+ if (gtsc_cd.cd_devs[i])
+ sbic_dump(gtsc_cd.cd_devs[i]);
}
#endif
-/* $NetBSD: gvpbus.c,v 1.9 1995/08/18 15:27:54 chopps Exp $ */
+/* $OpenBSD: gvpbus.c,v 1.2 1996/04/21 22:15:18 deraadt Exp $ */
+/* $NetBSD: gvpbus.c,v 1.10 1996/03/17 01:17:23 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
#include <amiga/dev/gvpbusvar.h>
void gvpbusattach __P((struct device *, struct device *, void *));
-int gvpbusmatch __P((struct device *, struct cfdata *, void *));
+int gvpbusmatch __P((struct device *, void *, void *));
int gvpbusprint __P((void *auxp, char *));
extern int sbic_no_dma; /* Kludge for A1291 - mlh */
-struct cfdriver gvpbuscd = {
- NULL, "gvpbus", (cfmatch_t)gvpbusmatch, gvpbusattach,
- DV_DULL, sizeof(struct device), NULL, 0 };
+struct cfattach gvpbus_ca = {
+ sizeof(struct device), gvpbusmatch, gvpbusattach
+};
+
+struct cfdriver gvpbus_cd = {
+ NULL, "gvpbus", DV_DULL, NULL, 0
+};
int
-gvpbusmatch(pdp, cdp, auxp)
+gvpbusmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
-/* $NetBSD: idesc.c,v 1.15 1996/01/07 22:01:53 thorpej Exp $ */
+/* $OpenBSD: idesc.c,v 1.3 1996/04/21 22:15:20 deraadt Exp $ */
+/* $NetBSD: idesc.c,v 1.18 1996/03/24 04:12:27 mhitch Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int idescprint __P((void *auxp, char *));
void idescattach __P((struct device *, struct device *, void *));
-int idescmatch __P((struct device *, struct cfdata *, void *));
+int idescmatch __P((struct device *, void *, void *));
int ideicmd __P((struct idec_softc *, int, void *, int, void *, int));
int idego __P((struct idec_softc *, struct scsi_xfer *));
NULL, /* Use default done routine */
};
-struct cfdriver idesccd = {
- NULL, "idesc", (cfmatch_t)idescmatch, idescattach,
- DV_DULL, sizeof(struct idec_softc), NULL, 0 };
+struct cfattach idesc_ca = {
+ sizeof(struct idec_softc), idescmatch, idescattach
+};
+
+struct cfdriver idesc_cd = {
+ NULL, "idesc", DV_DULL, NULL, 0
+};
struct {
short ide_err;
* if we are an A4000 we are here.
*/
int
-idescmatch(pdp, cdp, auxp)
+idescmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
char *mbusstr;
mdsnbuf->blk_desc.blklen[1] = 512 >> 8;
mdsnbuf->pages.rigid_geometry.pg_code = 4;
mdsnbuf->pages.rigid_geometry.pg_length = 16;
- mdsnbuf->pages.rigid_geometry.ncyl_2 =
- ide->sc_params.idep_fixedcyl >> 16;
- mdsnbuf->pages.rigid_geometry.ncyl_1 =
- ide->sc_params.idep_fixedcyl >> 8;
- mdsnbuf->pages.rigid_geometry.ncyl_0 =
- ide->sc_params.idep_fixedcyl;
+ _lto3b(ide->sc_params.idep_fixedcyl,
+ mdsnbuf->pages.rigid_geometry.ncyl);
mdsnbuf->pages.rigid_geometry.nheads =
ide->sc_params.idep_heads;
dev->sc_stat[0] = 0;
int i;
#if 0
- if (idesccd.cd_ndevs == 0 || (dev = idesccd.cd_devs[0]) == NULL)
+ if (idesc_cd.cd_ndevs == 0 || (dev = idesc_cd.cd_devs[0]) == NULL)
return (0);
#endif
regs = dev->sc_cregs;
-/* $OpenBSD: if_ae.c,v 1.3 1996/02/26 21:11:40 niklas Exp $ */
-/* $NetBSD: if_ae.c,v 1.5 1996/02/24 07:47:36 chopps Exp $ */
+/* $OpenBSD: if_ae.c,v 1.4 1996/04/21 22:15:21 deraadt Exp $ */
+/* $NetBSD: if_ae.c,v 1.6 1996/03/17 01:17:28 thorpej Exp $ */
/*
* Copyright (c) 1995 Bernd Ernesti and Klaus Burkert. All rights reserved.
int aeioctl __P((struct ifnet *, u_long, caddr_t));
void aesetladrf __P((struct arpcom *, u_int16_t *));
-struct cfdriver aecd = {
- NULL, "ae", aematch, aeattach, DV_IFNET, sizeof(struct ae_softc)
+struct cfattach ae_ca = {
+ sizeof(struct ae_softc), aematch, aeattach
+};
+
+struct cfdriver ae_cd = {
+ NULL, "ae", DV_IFNET
};
int
splx (s);
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = aecd.cd_name;
+ ifp->if_name = ae_cd.cd_name;
ifp->if_ioctl = aeioctl;
ifp->if_watchdog = aewatchdog;
ifp->if_output = ether_output;
aewatchdog(unit)
short unit;
{
- struct ae_softc *sc = aecd.cd_devs[unit];
+ struct ae_softc *sc = ae_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
aestart(ifp)
struct ifnet *ifp;
{
- register struct ae_softc *sc = aecd.cd_devs[ifp->if_unit];
+ register struct ae_softc *sc = ae_cd.cd_devs[ifp->if_unit];
register int bix;
register struct aetmd *tmd;
register struct mbuf *m;
u_long cmd;
caddr_t data;
{
- struct ae_softc *sc = aecd.cd_devs[ifp->if_unit];
+ struct ae_softc *sc = ae_cd.cd_devs[ifp->if_unit];
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
-/* $NetBSD: if_bah.c,v 1.14 1995/12/27 07:51:40 chopps Exp $ */
+/* $OpenBSD: if_bah.c,v 1.4 1996/04/21 22:15:23 deraadt Exp $ */
+/* $NetBSD: if_bah.c,v 1.16 1996/03/20 13:28:50 is Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
/* #define BAHTIMINGS */
/* #define BAH_DEBUG 3 */
+/* zeroth version of M68060 support */
+
+#if defined(M68060) && defined(BAHASMCOPY)
+#undef BAHASMCOPY
+#endif
+
#include "bpfilter.h"
#include <sys/param.h>
#endif
};
-int bahmatch __P((struct device *, void *, void *));
-void bahattach __P((struct device *, struct device *, void *));
+int bah_zbus_match __P((struct device *, void *, void *));
+void bah_zbus_attach __P((struct device *, struct device *, void *));
void bah_init __P((struct bah_softc *));
void bah_reset __P((struct bah_softc *));
void bah_stop __P((struct bah_softc *));
int clkread();
#endif
-struct cfdriver bahcd = {
- NULL, "bah", bahmatch, bahattach, DV_IFNET, sizeof(struct bah_softc)
+struct cfattach bah_zbus_ca = {
+ sizeof(struct bah_softc), bah_zbus_match, bah_zbus_attach
+};
+
+struct cfdriver bah_cd = {
+ NULL, "bah", DV_IFNET
};
int
-bahmatch(parent, match, aux)
+bah_zbus_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
}
void
-bahattach(parent, self, aux)
+bah_zbus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
bah_stop(sc);
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = bahcd.cd_name;
+ ifp->if_name = bah_cd.cd_name;
ifp->if_output = arc_output;
ifp->if_start = bah_start;
ifp->if_ioctl = bah_ioctl;
u_long copystart, lencopy, perbyte;
#endif
- sc = bahcd.cd_devs[ifp->if_unit];
+ sc = bah_cd.cd_devs[ifp->if_unit];
#if defined(BAH_DEBUG) && (BAH_DEBUG > 3)
printf("%s: start(0x%x)\n", sc->sc_dev.dv_xname, ifp);
if (head != NULL)
m_freem(head);
+ /* mark buffer as invalid by source id 0 */
+ sc->sc_base->buffers[buffer*512*2] = 0;
s = splnet();
if (--sc->sc_rx_fillcount == 2 - 1) {
if (maskedisr & ARC_RI) {
#if defined(BAH_DEBUG) && (BAH_DEBUG > 1)
- printf("%s: intr: hard rint, act %ld 2:%ld 3:%ld\n",
- sc->sc_dev.dv_xname,
- sc->sc_rx_act, sc->sc_bufstat[2], sc->sc_bufstat[3]);
+ printf("%s: intr: hard rint, act %ld\n",
+ sc->sc_dev.dv_xname, sc->sc_rx_act);
#endif
buffer = sc->sc_rx_act;
- if (++sc->sc_rx_fillcount > 1) {
+ /* look if buffer is marked invalid: */
+ if (sc->sc_base->buffers[buffer*512*2] == 0) {
+ /* invalid marked buffer (or illegally configured sender) */
+ log(LOG_WARNING,
+ "%s: spurious RX interrupt or sender 0 (ignored)\n",
+ sc->sc_dev.dv_xname);
+ /*
+ * restart receiver on same buffer.
+ */
+ sc->sc_base->command = ARC_RXBC(buffer);
+
+ } else if (++sc->sc_rx_fillcount > 1) {
sc->sc_intmask &= ~ARC_RI;
sc->sc_base->status = sc->sc_intmask;
} else {
int s, error;
error = 0;
- sc = bahcd.cd_devs[ifp->if_unit];
+ sc = bah_cd.cd_devs[ifp->if_unit];
ifa = (struct ifaddr *)data;
s = splnet();
* and the int handler will have to decide not to retransmit (in case
* retransmission is implemented).
*
- * This one assumes being called inside splnet(), and that imp >= ipl2
+ * This one assumes being called inside splnet(), and that net >= ipl2
*/
void
struct bah_softc *sc;
struct ifnet *ifp;
- sc = bahcd.cd_devs[unit];
+ sc = bah_cd.cd_devs[unit];
ifp = &(sc->sc_arccom.ac_if);
sc->sc_base->command = ARC_TXDIS;
-/* $NetBSD: if_ed.c,v 1.17 1995/12/24 02:29:57 mycroft Exp $ */
+/* $OpenBSD: if_ed.c,v 1.3 1996/04/21 22:15:25 deraadt Exp $ */
+/* $NetBSD: if_ed.c,v 1.19 1996/03/21 21:00:21 is Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
u_char next_packet; /* pointer to next unread RX packet */
};
-int edmatch __P((struct device *, void *, void *));
-void edattach __P((struct device *, struct device *, void *));
+int ed_zbus_match __P((struct device *, void *, void *));
+void ed_zbus_attach __P((struct device *, struct device *, void *));
int edintr __P((struct ed_softc *));
int ed_ioctl __P((struct ifnet *, u_long, caddr_t));
void ed_start __P((struct ifnet *));
static inline caddr_t ed_ring_copy __P((/* struct ed_softc *, caddr_t, caddr_t,
u_short */));
-struct cfdriver edcd = {
- NULL, "ed", edmatch, edattach, DV_IFNET, sizeof(struct ed_softc)
+struct cfattach ed_zbus_ca = {
+ sizeof(struct ed_softc), ed_zbus_match, ed_zbus_attach
+};
+
+struct cfdriver ed_cd = {
+ NULL, "ed", DV_IFNET
};
#define ETHER_MIN_LEN 64
}
int
-edmatch(parent, match, aux)
+ed_zbus_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
}
void
-edattach(parent, self, aux)
+ed_zbus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
sc->mem_ring =
sc->mem_start + ((sc->txb_cnt * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
+ /*
+ * Interupts must be inactive when reading the prom, as the interupt
+ * line is shared with one of its address lines.
+ */
+
+ NIC_PUT(sc, ED_P0_IMR, 0x00); /* disable ints */
+ NIC_PUT(sc, ED_P0_ISR, 0xff); /* clear ints */
+
/*
* read the ethernet address from the board
*/
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = edcd.cd_name;
+ ifp->if_name = ed_cd.cd_name;
ifp->if_start = ed_start;
ifp->if_ioctl = ed_ioctl;
ifp->if_watchdog = ed_watchdog;
ed_watchdog(unit)
short unit;
{
- struct ed_softc *sc = edcd.cd_devs[unit];
+ struct ed_softc *sc = ed_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
ed_start(ifp)
struct ifnet *ifp;
{
- struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
+ struct ed_softc *sc = ed_cd.cd_devs[ifp->if_unit];
struct mbuf *m0, *m;
caddr_t buffer;
int len;
u_long command;
caddr_t data;
{
- struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
+ struct ed_softc *sc = ed_cd.cd_devs[ifp->if_unit];
register struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
-/* $NetBSD: if_es.c,v 1.8 1995/12/24 02:29:59 mycroft Exp $ */
+/* $OpenBSD: if_es.c,v 1.3 1996/04/21 22:15:26 deraadt Exp $ */
+/* $NetBSD: if_es.c,v 1.10 1996/03/17 05:58:45 mhitch Exp $ */
/*
* Copyright (c) 1995 Michael L. Hitch
int esmatch __P((struct device *, void *, void *));
void esattach __P((struct device *, struct device *, void *));
-struct cfdriver escd = {
- NULL, "es", esmatch, esattach, DV_IFNET, sizeof(struct es_softc)
+struct cfattach es_ca = {
+ sizeof(struct es_softc), esmatch, esattach
+};
+
+struct cfdriver es_cd = {
+ NULL, "es", DV_IFNET
};
int
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = escd.cd_name;
+ ifp->if_name = es_cd.cd_name;
ifp->if_output = ether_output;
ifp->if_ioctl = esioctl;
ifp->if_start = esstart;
esstart(ifp)
struct ifnet *ifp;
{
- struct es_softc *sc = escd.cd_devs[ifp->if_unit];
+ struct es_softc *sc = es_cd.cd_devs[ifp->if_unit];
union smcregs *smc = sc->sc_base;
struct mbuf *m0, *m;
#ifdef USEPKTBUF
u_long command;
caddr_t data;
{
- struct es_softc *sc = escd.cd_devs[ifp->if_unit];
+ struct es_softc *sc = es_cd.cd_devs[ifp->if_unit];
register struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
eswatchdog(unit)
int unit;
{
- struct es_softc *sc = escd.cd_devs[unit];
+ struct es_softc *sc = es_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
-/* $NetBSD: if_le.c,v 1.16 1995/12/27 07:09:37 chopps Exp $ */
+/* $OpenBSD: if_le.c,v 1.3 1996/04/21 22:15:28 deraadt Exp $ */
+/* $NetBSD: if_le.c,v 1.17 1996/03/17 01:17:35 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
/* offsets for: ID, REGS, MEM */
int lestd[] = { 0, 0x4000, 0x8000 };
-#define LE_SOFTC(unit) lecd.cd_devs[unit]
+#define LE_SOFTC(unit) le_cd.cd_devs[unit]
#define LE_DELAY(x) DELAY(x)
-int lematch __P((struct device *, void *, void *));
-void leattach __P((struct device *, struct device *, void *));
+int le_zbus_match __P((struct device *, void *, void *));
+void le_zbus_attach __P((struct device *, struct device *, void *));
int leintr __P((void *));
-struct cfdriver lecd = {
- NULL, "le", lematch, leattach, DV_IFNET, sizeof(struct le_softc)
+struct cfattach le_zbus_ca = {
+ sizeof(struct le_softc), le_zbus_match, le_zbus_attach
+};
+
+struct cfdriver le_cd = {
+ NULL, "le", DV_IFNET
};
integrate void
}
int
-lematch(parent, match, aux)
+le_zbus_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
}
void
-leattach(parent, self, aux)
+le_zbus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
sc->sc_arpcom.ac_enaddr[4] = (ser >> 8) & 0xff;
sc->sc_arpcom.ac_enaddr[5] = (ser ) & 0xff;
- sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
+ sc->sc_arpcom.ac_if.if_name = le_cd.cd_name;
leconfig(sc);
sc->sc_isr.isr_intr = leintr;
-/* $NetBSD: if_le.c,v 1.16 1995/12/27 07:09:37 chopps Exp $ */
+/* $OpenBSD: if_le_zbus.c,v 1.3 1996/04/21 22:15:28 deraadt Exp $ */
+/* $NetBSD: if_le.c,v 1.17 1996/03/17 01:17:35 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
/* offsets for: ID, REGS, MEM */
int lestd[] = { 0, 0x4000, 0x8000 };
-#define LE_SOFTC(unit) lecd.cd_devs[unit]
+#define LE_SOFTC(unit) le_cd.cd_devs[unit]
#define LE_DELAY(x) DELAY(x)
-int lematch __P((struct device *, void *, void *));
-void leattach __P((struct device *, struct device *, void *));
+int le_zbus_match __P((struct device *, void *, void *));
+void le_zbus_attach __P((struct device *, struct device *, void *));
int leintr __P((void *));
-struct cfdriver lecd = {
- NULL, "le", lematch, leattach, DV_IFNET, sizeof(struct le_softc)
+struct cfattach le_zbus_ca = {
+ sizeof(struct le_softc), le_zbus_match, le_zbus_attach
+};
+
+struct cfdriver le_cd = {
+ NULL, "le", DV_IFNET
};
integrate void
}
int
-lematch(parent, match, aux)
+le_zbus_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
}
void
-leattach(parent, self, aux)
+le_zbus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
sc->sc_arpcom.ac_enaddr[4] = (ser >> 8) & 0xff;
sc->sc_arpcom.ac_enaddr[5] = (ser ) & 0xff;
- sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
+ sc->sc_arpcom.ac_if.if_name = le_cd.cd_name;
leconfig(sc);
sc->sc_isr.isr_intr = leintr;
-/* $NetBSD: if_qn.c,v 1.3 1995/12/24 02:30:02 mycroft Exp $ */
+/* $OpenBSD: if_qn.c,v 1.4 1996/04/21 22:15:29 deraadt Exp $ */
+/* $NetBSD: if_qn.c,v 1.4 1996/03/17 01:17:37 thorpej Exp $ */
/*
* Copyright (c) 1995 Mika Kortelainen
static void qn_dump __P((struct qn_softc *));
#endif
-struct cfdriver qncd = {
- NULL, "qn", qnmatch, qnattach, DV_IFNET, sizeof(struct qn_softc)
+struct cfattach qn_ca = {
+ sizeof(struct qn_softc), qnmatch, qnattach
+};
+
+struct cfdriver qn_cd = {
+ NULL, "qn", DV_IFNET
};
qnstop(sc);
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = qncd.cd_name;
+ ifp->if_name = qn_cd.cd_name;
ifp->if_ioctl = qnioctl;
ifp->if_watchdog = qnwatchdog;
ifp->if_output = ether_output;
qnwatchdog(unit)
int unit;
{
- struct qn_softc *sc = qncd.cd_devs[unit];
+ struct qn_softc *sc = qn_cd.cd_devs[unit];
log(LOG_INFO, "qn: device timeout (watchdog)\n");
++sc->sc_arpcom.ac_if.if_oerrors;
qnstart(ifp)
struct ifnet *ifp;
{
- struct qn_softc *sc = qncd.cd_devs[ifp->if_unit];
+ struct qn_softc *sc = qn_cd.cd_devs[ifp->if_unit];
struct mbuf *m;
u_short len;
int timout = 60000;
u_long command;
caddr_t data;
{
- struct qn_softc *sc = qncd.cd_devs[ifp->if_unit];
+ struct qn_softc *sc = qn_cd.cd_devs[ifp->if_unit];
register struct ifaddr *ifa = (struct ifaddr *)data;
#if 0
struct ifreg *ifr = (struct ifreg *)data;
-/* $OpenBSD: ite.c,v 1.4 1996/03/30 22:18:20 niklas Exp $ */
-/* $NetBSD: ite.c,v 1.36 1996/03/16 08:19:43 mhitch Exp $ */
+/* $OpenBSD: ite.c,v 1.5 1996/04/21 22:15:30 deraadt Exp $ */
+/* $NetBSD: ite.c,v 1.38 1996/03/17 05:58:48 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
void iteputchar __P((int c, struct ite_softc *ip));
void ite_putstr __P((const char * s, int len, dev_t dev));
void iteattach __P((struct device *, struct device *, void *));
-int itematch __P((struct device *, struct cfdata *, void *));
+int itematch __P((struct device *, void *, void *));
static void iteprecheckwrap __P((struct ite_softc *));
static void itecheckwrap __P((struct ite_softc *));
+struct cfattach ite_ca = {
+ sizeof(struct ite_softc), itematch, iteattach
+};
-struct cfdriver itecd = {
- NULL, "ite", (cfmatch_t)itematch, iteattach, DV_DULL,
- sizeof(struct ite_softc), NULL, 0 };
+struct cfdriver ite_cd = {
+ NULL, "ite", DV_DULL, NULL, 0
+};
int
-itematch(pdp, cdp, auxp)
+itematch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct grf_softc *gp;
int maj;
dev_t dev;
{
if (amiga_realconfig && con_itesoftc.grf == NULL)
- return(itecd.cd_devs[ITEUNIT(dev)]);
+ return(ite_cd.cd_devs[ITEUNIT(dev)]);
if (con_itesoftc.grf == NULL)
panic("no ite_softc for console");
-/* $NetBSD: ivsc.c,v 1.12 1995/08/18 15:28:00 chopps Exp $ */
+/* $OpenBSD: ivsc.c,v 1.2 1996/04/21 22:15:32 deraadt Exp $ */
+/* $NetBSD: ivsc.c,v 1.14 1996/03/28 19:23:34 is Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int ivscprint __P((void *auxp, char *));
void ivscattach __P((struct device *, struct device *, void *));
-int ivscmatch __P((struct device *, struct cfdata *, void *));
+int ivscmatch __P((struct device *, void *, void *));
int ivsc_intr __P((struct sci_softc *));
int ivsc_dma_xfer_in __P((struct sci_softc *dev, int len,
int ivsdma_pseudo = 1; /* 0=off, 1=on */
-struct cfdriver ivsccd = {
- NULL, "ivsc", (cfmatch_t)ivscmatch, ivscattach,
- DV_DULL, sizeof(struct sci_softc), NULL, 0 };
+struct cfattach ivsc_ca = {
+ sizeof(struct sci_softc), ivscmatch, ivscattach
+};
+
+struct cfdriver ivsc_cd = {
+ NULL, "ivsc", DV_DULL, NULL, 0
+};
/*
* if this is an IVS board
*/
int
-ivscmatch(pdp, cdp, auxp)
+ivscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
struct zbus_args *zap;
if ((*dev->sci_csr & SCI_CSR_INT) == 0)
return(0);
stat = *dev->sci_iack;
+ /* XXXX is: something is missing here, at least a: */
+ return(1);
}
-/* $NetBSD: kbd.c,v 1.15 1995/05/07 15:37:11 chopps Exp $ */
+/* $OpenBSD: kbd.c,v 1.2 1996/04/21 22:15:33 deraadt Exp $ */
+/* $NetBSD: kbd.c,v 1.17 1996/03/17 05:58:50 mhitch Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
};
struct kbd_softc kbd_softc;
+int kbdmatch __P((struct device *, void *, void *));
void kbdattach __P((struct device *, struct device *, void *));
-int kbdmatch __P((struct device *, struct cfdata *, void *));
-struct cfdriver kbdcd = {
- NULL, "kbd", (cfmatch_t)kbdmatch, kbdattach, DV_DULL,
- sizeof(struct device), NULL, 0 };
+struct cfattach kbd_ca = {
+ sizeof(struct device), kbdmatch, kbdattach
+};
+
+struct cfdriver kbd_cd = {
+ NULL, "kbd", DV_DULL, NULL, 0
+};
/*ARGSUSED*/
int
-kbdmatch(pdp, cfp, auxp)
+kbdmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (matchname((char *)auxp, "kbd"))
return(1);
return(0);
-/* $NetBSD: mfc.c,v 1.8.2.1 1995/10/20 11:01:12 chopps Exp $ */
+/* $OpenBSD: mfc.c,v 1.5 1996/04/21 22:15:34 deraadt Exp $ */
+/* $NetBSD: mfc.c,v 1.11 1996/03/17 05:58:52 mhitch Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int mfcprint __P((void *auxp, char *));
void mfcattach __P((struct device *, struct device *, void *));
-int mfcmatch __P((struct device *, struct cfdata *, void *));
+int mfcmatch __P((struct device *, void *, void *));
#if NMFCS > 0
void mfcsattach __P((struct device *, struct device *, void *));
-int mfcsmatch __P((struct device *, struct cfdata *, void *));
+int mfcsmatch __P((struct device *, void *, void *));
#endif
#if NMFCP > 0
void mfcpattach __P((struct device *, struct device *, void *));
-int mfcpmatch __P((struct device *, struct cfdata *, void *));
+int mfcpmatch __P((struct device *, void *, void *));
#endif
int mfcintr __P((struct mfc_softc *));
void mfcsmint __P((register int unit));
-struct cfdriver mfccd = {
- NULL, "mfc", (cfmatch_t) mfcmatch, mfcattach,
- DV_DULL, sizeof(struct mfc_softc), NULL, 0 };
+struct cfattach mfc_ca = {
+ sizeof(struct mfc_softc), mfcmatch, mfcattach
+};
+
+struct cfdriver mfc_cd = {
+ NULL, "mfc", DV_DULL, NULL, 0
+};
#if NMFCS > 0
-struct cfdriver mfcscd = {
- NULL, "mfcs", (cfmatch_t) mfcsmatch, mfcsattach,
- DV_TTY, sizeof(struct mfcs_softc), NULL, 0 };
+struct cfattach mfcs_ca = {
+ sizeof(struct mfcs_softc), mfcsmatch, mfcsattach
+};
+
+struct cfdriver mfcs_cd = {
+ NULL, "mfcs", DV_TTY, NULL, 0
+};
#endif
#if NMFCP > 0
-struct cfdriver mfcpcd = {
- NULL, "mfcp", (cfmatch_t) mfcpmatch, mfcpattach,
- DV_DULL, sizeof(struct mfcp_softc), NULL, 0 };
+struct cfattach mfcp_ca = {
+ sizeof(struct mfcp_softc, mfcpmatch, mfcpattach
+};
+
+struct cfdriver mfcp_cd = {
+ NULL, "mfcp", DV_DULL, NULL, 0
+};
#endif
int mfcsstart(), mfcsparam(), mfcshwiflow();
* if we are an bsc/Alf Data MultFaceCard (I, II, and III)
*/
int
-mfcmatch(pdp, cdp, auxp)
+mfcmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
*
*/
int
-mfcsmatch(pdp, cdp, auxp)
+mfcsmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct mfc_args *ma;
ma = auxp;
error = 0;
unit = dev & 0x1f;
- if (unit >= mfcscd.cd_ndevs || (mfcs_active & (1 << unit)) == 0)
+ if (unit >= mfcs_cd.cd_ndevs || (mfcs_active & (1 << unit)) == 0)
return (ENXIO);
- sc = mfcscd.cd_devs[unit];
+ sc = mfcs_cd.cd_devs[unit];
s = spltty();
{
struct tty *tp;
int unit;
- struct mfcs_softc *sc = mfcscd.cd_devs[dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31];
struct mfc_softc *scc= sc->sc_mfc;
unit = dev & 31;
struct uio *uio;
int flag;
{
- struct mfcs_softc *sc = mfcscd.cd_devs[dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31];
struct tty *tp = sc->sc_tty;
if (tp == NULL)
return(ENXIO);
struct uio *uio;
int flag;
{
- struct mfcs_softc *sc = mfcscd.cd_devs[dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31];
struct tty *tp = sc->sc_tty;
if (tp == NULL)
mfcstty(dev)
dev_t dev;
{
- struct mfcs_softc *sc = mfcscd.cd_devs[dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31];
return (sc->sc_tty);
}
register struct tty *tp;
register int unit = dev & 31;
register int error;
- struct mfcs_softc *sc = mfcscd.cd_devs[dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31];
tp = sc->sc_tty;
if (!tp)
struct termios *t;
{
int cfcr, cflag, unit, ospeed;
- struct mfcs_softc *sc = mfcscd.cd_devs[tp->t_dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[tp->t_dev & 31];
struct mfc_softc *scc= sc->sc_mfc;
cflag = t->c_cflag;
struct tty *tp;
int flag;
{
- struct mfcs_softc *sc = mfcscd.cd_devs[tp->t_dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[tp->t_dev & 31];
int unit = tp->t_dev & 1;
if (flag)
struct tty *tp;
{
int cc, s, unit;
- struct mfcs_softc *sc = mfcscd.cd_devs[tp->t_dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[tp->t_dev & 31];
struct mfc_softc *scc= sc->sc_mfc;
if ((tp->t_state & TS_ISOPEN) == 0)
{
int unit, s;
u_char ub;
- struct mfcs_softc *sc = mfcscd.cd_devs[dev & 31];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31];
unit = dev & 1;
return (0);
unit = scc->sc_dev.dv_unit * 2;
if (istat & 0x02) { /* channel A receive interrupt */
- sc = mfcscd.cd_devs[unit];
+ sc = mfcs_cd.cd_devs[unit];
while (1) {
c = regs->du_sra << 8;
if ((c & 0x0100) == 0)
}
}
if (istat & 0x20) { /* channel B receive interrupt */
- sc = mfcscd.cd_devs[unit + 1];
+ sc = mfcs_cd.cd_devs[unit + 1];
while (1) {
c = regs->du_srb << 8;
if ((c & 0x0100) == 0)
}
}
if (istat & 0x01) { /* channel A transmit interrupt */
- sc = mfcscd.cd_devs[unit];
+ sc = mfcs_cd.cd_devs[unit];
tp = sc->sc_tty;
if (sc->ptr == sc->end) {
tp->t_state &= ~(TS_BUSY | TS_FLUSH);
regs->du_tba = *sc->ptr++;
}
if (istat & 0x10) { /* channel B transmit interrupt */
- sc = mfcscd.cd_devs[unit + 1];
+ sc = mfcs_cd.cd_devs[unit + 1];
tp = sc->sc_tty;
if (sc->ptr == sc->end) {
tp->t_state &= ~(TS_BUSY | TS_FLUSH);
int unit;
{
int s1, s2, ovfl;
- struct mfcs_softc *sc = mfcscd.cd_devs[unit];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
/*
mfcseint(unit, stat)
int unit, stat;
{
- struct mfcs_softc *sc = mfcscd.cd_devs[unit];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[unit];
struct tty *tp;
u_char ch;
int c;
if (stat & 0x1000)
log(LOG_WARNING, "%s: fifo overflow\n",
- ((struct mfcs_softc *)mfcscd.cd_devs[unit])->sc_dev.dv_xname);
+ ((struct mfcs_softc *)mfcs_cd.cd_devs[unit])->sc_dev.dv_xname);
(*linesw[tp->t_line].l_rint)(c, tp);
}
int unit;
{
struct tty *tp;
- struct mfcs_softc *sc = mfcscd.cd_devs[unit];
+ struct mfcs_softc *sc = mfcs_cd.cd_devs[unit];
u_char stat, last, istat;
tp = sc->sc_tty;
-/* $OpenBSD: mgnsc.c,v 1.4 1996/03/30 22:18:22 niklas Exp $ */
-/* $NetBSD: mgnsc.c,v 1.16 1996/03/15 22:11:12 mhitch Exp $ */
+/* $OpenBSD: mgnsc.c,v 1.5 1996/04/21 22:15:36 deraadt Exp $ */
+/* $NetBSD: mgnsc.c,v 1.17 1996/03/17 01:17:45 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int mgnscprint __P((void *auxp, char *));
void mgnscattach __P((struct device *, struct device *, void *));
-int mgnscmatch __P((struct device *, struct cfdata *, void *));
+int mgnscmatch __P((struct device *, void *, void *));
int siopintr __P((struct siop_softc *));
int mgnsc_dmaintr __P((struct siop_softc *));
#ifdef DEBUG
#endif
-struct cfdriver mgnsccd = {
- NULL, "mgnsc", (cfmatch_t)mgnscmatch, mgnscattach,
- DV_DULL, sizeof(struct siop_softc), NULL, 0 };
+struct cfattach mgnsc_ca = {
+ sizeof(struct siop_softc), mgnscmatch, mgnscattach
+};
+
+struct cfdriver mgnsc_cd = {
+ NULL, "mgnsc", DV_DULL, NULL, 0
+};
/*
* if we are a CSA Magnum 40 SCSI
*/
int
-mgnscmatch(pdp, cdp, auxp)
+mgnscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
{
int i;
- for (i = 0; i < mgnsccd.cd_ndevs; ++i)
- if (mgnsccd.cd_devs[i])
- siop_dump(mgnsccd.cd_devs[i]);
+ for (i = 0; i < mgnsc_cd.cd_ndevs; ++i)
+ if (mgnsc_cd.cd_devs[i])
+ siop_dump(mgnsc_cd.cd_devs[i]);
}
#endif
-/* $NetBSD: mlhsc.c,v 1.8 1995/02/12 19:19:18 chopps Exp $ */
+/* $OpenBSD: mlhsc.c,v 1.2 1996/04/21 22:15:38 deraadt Exp $ */
+/* $NetBSD: mlhsc.c,v 1.9 1996/03/17 01:17:46 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int mlhscprint __P((void *auxp, char *));
void mlhscattach __P((struct device *, struct device *, void *));
-int mlhscmatch __P((struct device *, struct cfdata *, void *));
+int mlhscmatch __P((struct device *, void *, void *));
int mlhsc_dma_xfer_in __P((struct sci_softc *dev, int len,
register u_char *buf, int phase));
extern int sci_data_wait;
-struct cfdriver mlhsccd = {
- NULL, "mlhsc", (cfmatch_t)mlhscmatch, mlhscattach,
- DV_DULL, sizeof(struct sci_softc), NULL, 0 };
+struct cfattach mlhsc_ca = {
+ sizeof(struct sci_softc), mlhscmatch, mlhscattach
+};
+
+struct cfdriver mlhsc_cd = {
+ NULL, "mlhsc", DV_DULL, NULL, 0
+};
/*
* if we are my Hacker's SCSI board we are here.
*/
int
-mlhscmatch(pdp, cdp, auxp)
+mlhscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
struct zbus_args *zap;
-/* $NetBSD: msc.c,v 1.3 1996/02/02 18:05:44 mycroft Exp $ */
+/* $OpenBSD: msc.c,v 1.3 1996/04/21 22:15:39 deraadt Exp $ */
+/* $NetBSD: msc.c,v 1.5 1996/03/17 05:58:54 mhitch Exp $ */
/*
* Copyright (c) 1993 Zik.
int mscmctl __P((dev_t dev, int bits, int howto));
void mscmint __P((register void *data));
-int mscmatch __P((struct device *, struct cfdata *, void *));
+int mscmatch __P((struct device *, void *, void *));
void mscattach __P((struct device *, struct device *, void *));
#define SWFLAGS(dev) (msc->openflags | (MSCDIALIN(dev) ? 0 : TIOCFLAG_SOFTCAR))
#define DEBUG_MSC 0
#define DEBUG_CD 0
-struct cfdriver msccd = {
- NULL, "msc", (cfmatch_t) mscmatch, mscattach, DV_TTY,
- sizeof(struct device), NULL, 0
+struct cfattach msc_ca = {
+ sizeof(struct device), mscmatch, mscattach
+};
+
+struct cfdriver msc_cd = {
+ NULL, "msc",DV_TTY, NULL, 0
};
#if DEBUG_MSC
#endif
int
-mscmatch(pdp, cdp, auxp)
+mscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
-/* $NetBSD: otgsc.c,v 1.9 1995/09/16 16:11:24 chopps Exp $ */
+/* $OpenBSD: otgsc.c,v 1.2 1996/04/21 22:15:40 deraadt Exp $ */
+/* $NetBSD: otgsc.c,v 1.10 1996/03/17 01:17:50 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int otgscprint __P((void *auxp, char *));
void otgscattach __P((struct device *, struct device *, void *));
-int otgscmatch __P((struct device *, struct cfdata *, void *));
+int otgscmatch __P((struct device *, void *, void *));
int otgsc_dma_xfer_in __P((struct sci_softc *dev, int len,
register u_char *buf, int phase));
extern int sci_data_wait;
-struct cfdriver otgsccd = {
- NULL, "otgsc", (cfmatch_t)otgscmatch, otgscattach,
- DV_DULL, sizeof(struct sci_softc), NULL, 0 };
+struct cfattach otgsc_ca = {
+ sizeof(struct sci_softc), otgscmatch, otgscattach
+};
+
+struct cfdriver otgsc_cd = {
+ NULL, "otgsc", DV_DULL, NULL, 0
+};
/*
* if we are my Hacker's SCSI board we are here.
*/
int
-otgscmatch(pdp, cdp, auxp)
+otgscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
struct zbus_args *zap;
-/* $NetBSD: par.c,v 1.11 1994/12/01 17:25:33 chopps Exp $ */
+/* $OpenBSD: par.c,v 1.2 1996/04/21 22:15:41 deraadt Exp $ */
+/* $NetBSD: par.c,v 1.12 1996/03/17 01:17:51 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990 The Regents of the University of California.
void parintr __P((void *));
void parattach __P((struct device *, struct device *, void *));
-int parmatch __P((struct device *, struct cfdata *, void *));
+int parmatch __P((struct device *, void *, void *));
-struct cfdriver parcd = {
- NULL, "par", (cfmatch_t)parmatch, parattach, DV_DULL,
- sizeof(struct device), NULL, 0 };
+struct cfattach par_ca = {
+ sizeof(struct device), parmatch, parattach
+};
+
+struct cfdriver par_cd = {
+ NULL, "par", DV_DULL, NULL, 0
+};
/*ARGSUSED*/
int
-parmatch(pdp, cfp, auxp)
+parmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (matchname((char *)auxp, "par") && cfp->cf_unit == 0)
return(1);
return(0);
-/* $NetBSD: sbic.c,v 1.21 1996/01/07 22:01:54 thorpej Exp $ */
+/* $OpenBSD: sbic.c,v 1.4 1996/04/21 22:15:43 deraadt Exp $ */
+/* $NetBSD: sbic.c,v 1.22 1996/03/23 15:09:54 is Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
xs->error = XS_SENSE;
#ifdef DEBUG
if (report_sense)
- printf(" => %02x %02x\n", xs->sense.extended_flags,
- xs->sense.extended_extra_bytes[3]);
+ printf(" => %02x %02x\n", xs->sense.flags,
+ xs->sense.extra_bytes[3]);
#endif
} else {
xs->resid = 0; /* XXXX */
-/* $NetBSD: ser.c,v 1.27.2.1 1995/10/20 11:01:14 chopps Exp $ */
+/* $OpenBSD: ser.c,v 1.3 1996/04/21 22:15:45 deraadt Exp $ */
+/* $NetBSD: ser.c,v 1.30 1996/03/17 05:58:58 mhitch Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
#if NSER > 0
void serattach __P((struct device *, struct device *, void *));
-int sermatch __P((struct device *, struct cfdata *, void *));
+int sermatch __P((struct device *, void *, void *));
struct ser_softc {
struct device dev;
struct tty *ser_tty;
};
-struct cfdriver sercd = {
- NULL, "ser", (cfmatch_t)sermatch, serattach, DV_TTY,
- sizeof(struct ser_softc), NULL, 0 };
+struct cfattach ser_ca = {
+ sizeof(struct ser_softc), sermatch, serattach
+};
+
+struct cfdriver ser_cd = {
+ NULL, "ser", DV_TTY, NULL, 0
+};
#ifndef SEROBUF_SIZE
#define SEROBUF_SIZE 32
void sermint __P((register int unit));
int
-sermatch(pdp, cfp, auxp)
+sermatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (matchname("ser", (char *)auxp) == 0 || cfp->cf_unit != 0)
return(0);
if (serconsole != 0 && amiga_realconfig == 0)
if (ser_tty[unit])
tp = ser_tty[unit];
else
- tp = ((struct ser_softc *)sercd.cd_devs[unit])->ser_tty =
+ tp = ((struct ser_softc *)ser_cd.cd_devs[unit])->ser_tty =
ser_tty[unit] = ttymalloc();
tp->t_oproc = (void (*) (struct tty *)) serstart;
-/* $OpenBSD: wesc.c,v 1.2 1996/03/30 22:18:24 niklas Exp $ */
-/* $NetBSD: wesc.c,v 1.11 1996/03/15 22:11:19 mhitch Exp $ */
+/* $OpenBSD: wesc.c,v 1.3 1996/04/21 22:15:47 deraadt Exp $ */
+/* $NetBSD: wesc.c,v 1.12 1996/03/17 01:17:55 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int wescprint __P((void *auxp, char *));
void wescattach __P((struct device *, struct device *, void *));
-int wescmatch __P((struct device *, struct cfdata *, void *));
+int wescmatch __P((struct device *, void *, void *));
int wesc_dmaintr __P((struct siop_softc *));
struct scsi_adapter wesc_scsiswitch = {
#ifdef DEBUG
#endif
-struct cfdriver wesccd = {
- NULL, "wesc", (cfmatch_t)wescmatch, wescattach,
- DV_DULL, sizeof(struct siop_softc), NULL, 0 };
+struct cfattach wesc_ca = {
+ sizeof(struct siop_softc), wescmatch, wescattach
+};
+
+struct cfdriver wesc_cd = {
+ NULL, "wesc", DV_DULL, NULL, 0
+};
/*
* if we are an MacroSystemsUS Warp Engine
*/
int
-wescmatch(pdp, cdp, auxp)
+wescmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
{
int i;
- for (i = 0; i < wesccd.cd_ndevs; ++i)
- if (wesccd.cd_devs[i])
- siop_dump(wesccd.cd_devs[i]);
+ for (i = 0; i < wesc_cd.cd_ndevs; ++i)
+ if (wesc_cd.cd_devs[i])
+ siop_dump(wesc_cd.cd_devs[i]);
}
#endif
-/* $NetBSD: wstsc.c,v 1.9 1995/08/18 15:28:17 chopps Exp $ */
+/* $OpenBSD: wstsc.c,v 1.2 1996/04/21 22:15:48 deraadt Exp $ */
+/* $NetBSD: wstsc.c,v 1.10 1996/03/17 01:17:56 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int wstscprint __P((void *auxp, char *));
void wstscattach __P((struct device *, struct device *, void *));
-int wstscmatch __P((struct device *, struct cfdata *, void *));
+int wstscmatch __P((struct device *, void *, void *));
int wstsc_dma_xfer_in __P((struct sci_softc *dev, int len,
register u_char *buf, int phase));
int supradma_pseudo = 0; /* 0=none, 1=byte, 2=word */
-struct cfdriver wstsccd = {
- NULL, "wstsc", (cfmatch_t)wstscmatch, wstscattach,
- DV_DULL, sizeof(struct sci_softc), NULL, 0 };
+struct cfattach wstsc_ca = {
+ sizeof(struct sci_softc), wstscmatch, wstscattach
+};
+
+struct cfdriver wstsc_cd = {
+ NULL, "wstsc", DV_DULL, NULL, 0
+};
/*
* if this a Supra WordSync board
*/
int
-wstscmatch(pdp, cdp, auxp)
+wstscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
-/* $OpenBSD: zbus.c,v 1.3 1996/03/30 22:18:25 niklas Exp $ */
-/* $NetBSD: zbus.c,v 1.15 1996/03/06 20:13:32 is Exp $ */
+/* $OpenBSD: zbus.c,v 1.4 1996/04/21 22:15:50 deraadt Exp $ */
+/* $NetBSD: zbus.c,v 1.17 1996/03/28 18:41:49 is Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
/* Hacker Inc. */
{ "mlhsc", 2011, 1 },
/* Resource Management Force */
- { "qn", 2011, 2 } /* QuickNet Ethernet */
+ { "qn", 2011, 2 }, /* QuickNet Ethernet */
+ /* ??? */
+ { "empsc", 2171, 21 } /* Emplant SCSI */
};
static int naconfent = sizeof(aconftab) / sizeof(struct aconfdata);
void zbusattach __P((struct device *, struct device *, void *));
int zbusprint __P((void *, char *));
-int zbusmatch __P((struct device *, struct cfdata *,void *));
+int zbusmatch __P((struct device *, void *, void *));
caddr_t zbusmap __P((caddr_t, u_int));
static char *aconflookup __P((int, int));
/*
* mainbus driver
*/
-struct cfdriver zbuscd = {
- NULL, "zbus", (cfmatch_t)zbusmatch, zbusattach,
- DV_DULL, sizeof(struct device), NULL, 0
+
+struct cfattach zbus_ca = {
+ sizeof(struct device), zbusmatch, zbusattach
+};
+
+struct cfdriver zbus_cd = {
+ NULL, "zbus", DV_DULL, NULL, 0
};
static struct cfdata *early_cfdata;
/*ARGSUSED*/
int
-zbusmatch(pdp, cfp, auxp)
+zbusmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cfp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cfp = match;
+
if (matchname(auxp, "zbus") == 0)
return(0);
if (amiga_realconfig == 0)
}
/*
- * this function is used to map Zorro physical I/O addresses into kernel virtual
- * addresses. We don't keep track which address we map where, we don't NEED
- * to know this. We made sure in amiga_init.c (by scanning all available Zorro
- * devices) to have enough kva-space available, so there is no extra range
- * check done here.
+ * this function is used to map Zorro physical I/O addresses into kernel
+ * virtual addresses. We don't keep track which address we map where, we don't
+ * NEED to know this. We made sure in amiga_init.c (by scanning all available
+ * Zorro devices) to have enough kva-space available, so there is no extra
+ * range check done here.
*/
caddr_t
zbusmap (pa, size)
-/* $OpenBSD: zssc.c,v 1.4 1996/03/30 22:18:25 niklas Exp $ */
-/* $NetBSD: zssc.c,v 1.14 1996/03/15 22:11:22 mhitch Exp $ */
+/* $OpenBSD: zssc.c,v 1.5 1996/04/21 22:15:51 deraadt Exp $ */
+/* $NetBSD: zssc.c,v 1.15 1996/03/17 01:18:00 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
int zsscprint __P((void *auxp, char *));
void zsscattach __P((struct device *, struct device *, void *));
-int zsscmatch __P((struct device *, struct cfdata *, void *));
+int zsscmatch __P((struct device *, void *, void *));
int siopintr __P((struct siop_softc *));
int zssc_dmaintr __P((struct siop_softc *));
#ifdef DEBUG
#endif
-struct cfdriver zssccd = {
- NULL, "zssc", (cfmatch_t)zsscmatch, zsscattach,
- DV_DULL, sizeof(struct siop_softc), NULL, 0 };
+struct cfattach zssc_ca = {
+ sizeof(struct siop_softc), zsscmatch, zsscattach
+};
+
+struct cfdriver zssc_cd = {
+ NULL, "zssc", DV_DULL, NULL, 0
+};
/*
* if we are a PPI Zeus
*/
int
-zsscmatch(pdp, cdp, auxp)
+zsscmatch(pdp, match, auxp)
struct device *pdp;
- struct cfdata *cdp;
- void *auxp;
+ void *match, *auxp;
{
+ struct cfdata *cdp = match;
struct zbus_args *zap;
zap = auxp;
{
int i;
- for (i = 0; i < zssccd.cd_ndevs; ++i)
- if (zssccd.cd_devs[i])
- siop_dump(zssccd.cd_devs[i]);
+ for (i = 0; i < zssc_cd.cd_ndevs; ++i)
+ if (zssc_cd.cd_devs[i])
+ siop_dump(zssc_cd.cd_devs[i]);
}
#endif
-/* $OpenBSD: cpu.h,v 1.4 1996/03/30 22:18:27 niklas Exp $ */
-/* $NetBSD: cpu.h,v 1.26 1996/03/15 19:47:48 is Exp $ */
+/* $OpenBSD: cpu.h,v 1.5 1996/04/21 22:15:55 deraadt Exp $ */
+/* $NetBSD: cpu.h,v 1.28 1996/03/30 16:22:55 is Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#define IC40_ENABLE 0x00008000 /* enable instruction cache */
#define DC40_ENABLE 0x80000000 /* enable data cache */
+/* additional fields in the 68060 cache control register */
+
+#define DC60_NAD 0x40000000 /* no allocate mode, data cache */
+#define DC60_ESB 0x20000000 /* enable store buffer */
+#define DC60_DPI 0x10000000 /* disable CPUSH invalidation */
+#define DC60_FOC 0x08000000 /* four kB data cache mode (else 8) */
+
+#define IC60_EBC 0x00800000 /* enable branch cache */
+#define IC60_CABC 0x00400000 /* clear all branch cache entries */
+#define IC60_CUBC 0x00200000 /* clear user branch cache entries */
+
+#define IC60_NAI 0x00004000 /* no allocate mode, instr. cache */
+#define IC60_FIC 0x00002000 /* four kB instr. cache (else 8) */
+
+
#define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
#define CACHE_OFF (DC_CLR|IC_CLR)
#define CACHE_CLR (CACHE_ON)
#define CACHE40_ON (IC40_ENABLE|DC40_ENABLE)
#define CACHE40_OFF 0x00000000
+#define CACHE60_ON (CACHE40_ON |IC60_CABC|IC60_EBC|DC60_ESB)
+#define CACHE60_OFF (CACHE40_OFF|IC60_CABC)
+
/*
* CTL_MACHDEP definitions.
*/
-# $OpenBSD: DISKLESS,v 1.3 1996/04/18 18:55:32 niklas Exp $
-# $NetBSD: DISKLESS,v 1.21 1996/03/16 06:09:02 thorpej Exp $
+# $OpenBSD: DISKLESS,v 1.4 1996/04/21 22:16:04 deraadt Exp $
+# $NetBSD: DISKLESS,v 1.23 1996/03/25 05:45:14 perry Exp $
#
# DISKLESS -- Generic machine setup for diskless boot.
# This kernel can be loaded from a bootable floppy (i.e. kernel-copy)
options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8,
options COMPAT_09 # NetBSD 0.9,
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options COMPAT_43 # and 4.3BSD
options TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD
#le0 at isa? port 0x320 irq 10 drq 7 # IsoLan, NE2100, and DEPCA
sb0 at isa? port 0x220 irq 7 drq 1 # SoundBlaster
-#spkr0 at isa? port 0x61
+#spkr0 at pckbd? port 0x61
pseudo-device loop 1 # network loopback
pseudo-device bpfilter 8 # packet filter
-# $OpenBSD: GENERIC,v 1.7 1996/04/18 18:55:33 niklas Exp $
-# $NetBSD: GENERIC,v 1.36 1996/03/16 06:09:03 thorpej Exp $
+# $OpenBSD: GENERIC,v 1.8 1996/04/21 22:16:06 deraadt Exp $
+# $NetBSD: GENERIC,v 1.40 1996/03/30 23:57:09 perry Exp $
#
# GENERIC -- everything that's currently supported
#
options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8,
options COMPAT_09 # NetBSD 0.9,
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options COMPAT_43 # and 4.3BSD
options TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD
uha1 at isa? port 0x334 irq ? drq ? # UltraStor [13]4f SCSI controllers
uha2 at isa? port ? irq ? # UltraStor 24f SCSI controllers
scsibus* at uha?
+wds0 at isa? port 0x350 irq 15 drq 6 # WD7000 and TMC-7000 controllers
+wds1 at isa? port 0x358 irq 11 drq 5
+scsibus* at wds?
sd* at scsibus? target ? lun ? # SCSI disk drives
st* at scsibus? target ? lun ? # SCSI tape drives
wss0 at isa? port 0x530 irq 10 drq 0 # Windows Sound System
pas0 at isa? port 0x220 irq 7 drq 1 # ProAudio Spectrum
gus0 at isa? port 0x220 irq 7 drq 1 flags 6 # Gravis Ultra Sound (flags is record drq for full-duplex)
-#spkr0 at isa? port 0x61
+#spkr0 at pckbd? port 0x61
+
+# Joystick driver. Probe is a little strange; add only if you have one.
+#joy0 at isa? port 0x201
pseudo-device loop 1 # network loopback
pseudo-device bpfilter 8 # packet filter
-# $OpenBSD: GENERICADP,v 1.6 1996/04/18 18:55:34 niklas Exp $
-# $NetBSD: GENERICADP,v 1.3 1995/12/14 01:10:08 tls Exp $
+# $OpenBSD: GENERICADP,v 1.7 1996/04/21 22:16:09 deraadt Exp $
+# $NetBSD: GENERICADP,v 1.16 1996/03/30 23:57:16 perry Exp $
#
# GENERICADP -- everything that's currently supported, except non-
# Adaptec SCSI controllers.
options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8,
options COMPAT_09 # NetBSD 0.9,
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options COMPAT_43 # and 4.3BSD
options TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD
wss0 at isa? port 0x530 irq 10 drq 0 # Windows Sound System
pas0 at isa? port 0x220 irq 7 drq 1 # ProAudio Spectrum
gus0 at isa? port 0x220 irq 7 drq 1 flags 6 # Gravis Ultra Sound (flags is record drq for full-duplex)
-#spkr0 at isa? port 0x61
+#spkr0 at pckbd? port 0x61
+
+# Joystick driver. Probe is a little strange; add only if you have one.
+#joy0 at isa? port 0x201
pseudo-device loop 1 # network loopback
pseudo-device bpfilter 8 # packet filter
-# $OpenBSD: GENERICOTHER,v 1.5 1996/04/18 18:55:34 niklas Exp $
-# $NetBSD: GENERICOTHER,v 1.3 1995/12/14 01:10:10 tls Exp $
+# $OpenBSD: GENERICOTHER,v 1.6 1996/04/21 22:16:11 deraadt Exp $
+# $NetBSD: GENERICOTHER,v 1.16 1996/03/30 23:57:19 perry Exp $
#
# GENERICOTHER -- everything that's currently supported, except
# Adaptec SCSI controllers.
options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8,
options COMPAT_09 # NetBSD 0.9,
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options COMPAT_43 # and 4.3BSD
options TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD
uha1 at isa? port 0x334 irq ? drq ? # UltraStor [13]4f SCSI controllers
uha2 at isa? port ? irq ? # UltraStor 24f SCSI controllers
scsibus* at uha?
+wds0 at isa? port 0x350 irq 15 drq 6 # WD7000 and TMC-7000 controllers
+wds1 at isa? port 0x358 irq 11 drq 5
+scsibus* at wds?
sd* at scsibus? target ? lun ? # SCSI disk drives
st* at scsibus? target ? lun ? # SCSI tape drives
wss0 at isa? port 0x530 irq 10 drq 0 # Windows Sound System
pas0 at isa? port 0x220 irq 7 drq 1 # ProAudio Spectrum
gus0 at isa? port 0x220 irq 7 drq 1 flags 6 # Gravis Ultra Sound (flags is record drq for full-duplex)
-#spkr0 at isa? port 0x61
+#spkr0 at pckbd? port 0x61
+
+# Joystick driver. Probe is a little strange; add only if you have one.
+#joy0 at isa? port 0x201
pseudo-device loop 1 # network loopback
pseudo-device bpfilter 8 # packet filter
-# $OpenBSD: INSTADP,v 1.5 1996/04/18 18:55:36 niklas Exp $
-# $NetBSD: INSTADP,v 1.3 1995/12/14 01:10:12 tls Exp $
+# $OpenBSD: INSTADP,v 1.6 1996/04/21 22:16:12 deraadt Exp $
+# $NetBSD: INSTADP,v 1.11 1996/03/25 05:45:28 perry Exp $
#
# INSTADP -- like GENERICADP. This supports only Adaptec SCSI
# adapters. This kernel is GENERICADP with lines
#makeoptions DEBUG="-g" # compile full symbol table
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options LKM # loadable kernel modules
-# $NetBSD: INSTOTHER,v 1.3 1995/12/14 01:10:15 tls Exp $
+# $OpenBSD: INSTOTHER,v 1.4 1996/04/21 22:16:14 deraadt Exp $
+# $NetBSD: INSTOTHER,v 1.11 1996/03/30 05:42:59 mycroft Exp $
#
# INSTOTHER -- like GENERICOTHER. This supports only non-Adaptec SCSI
# adapters. This kernel is GENERICOTHER with lines
options KTRACE # system call tracing, a la ktrace(1)
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options LKM # loadable kernel modules
uha1 at isa? port 0x334 irq ? drq ? # UltraStor [13]4f SCSI controllers
uha2 at isa? port ? irq ? # UltraStor 24f SCSI controllers
scsibus* at uha?
+wds0 at isa? port 0x350 irq 15 drq 6 # WD7000 and TMC-7000 controllers
+wds1 at isa? port 0x358 irq 11 drq 5
+scsibus* at wds?
sd* at scsibus? target ? lun ? # SCSI disk drives
st* at scsibus? target ? lun ? # SCSI tape drives
-# $OpenBSD: TDR,v 1.5 1996/04/18 18:55:37 niklas Exp $
-# $NetBSD: TDR,v 1.62 1996/03/16 06:09:12 thorpej Exp $
+# $OpenBSD: TDR,v 1.6 1996/04/21 22:16:14 deraadt Exp $
+# $NetBSD: TDR,v 1.64 1996/03/25 05:45:49 perry Exp $
#
# TDR -- Theo Deraadt's 486
#
options COMPAT_NOMID # compatibility with 386BSD, BSDI, NetBSD 0.8,
options COMPAT_09 # NetBSD 0.9,
options COMPAT_10 # NetBSD 1.0,
+options COMPAT_11 # NetBSD 1.1,
options COMPAT_43 # and 4.3BSD
options TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD
#le0 at isa? port 0x320 irq 10 drq 7 # IsoLan, NE2100, and DEPCA
#sb0 at isa? port 0x220 irq 7 drq 1 # SoundBlaster
-#spkr0 at isa? port 0x61
+#spkr0 at pckbd? port 0x61
pseudo-device loop 1 # network loopback
pseudo-device bpfilter 16 # packet filter
-# $OpenBSD: files.i386,v 1.10 1996/04/19 07:33:39 mickey Exp $
-# $NetBSD: files.i386,v 1.66 1996/03/16 06:09:16 thorpej Exp $
+# $OpenBSD: files.i386,v 1.11 1996/04/21 22:16:15 deraadt Exp $
+# $NetBSD: files.i386,v 1.72 1996/04/09 22:59:03 cgd Exp $
#
# new style config file for i386 architecture
#
major {st = 5}
major {cd = 6}
+# RAM Disk for install floppy
+pseudo-device rd
+file dev/ramdisk.c rd needs-flag
+file arch/i386/i386/rd_root.c ramdisk_hooks
+major {rd = 17}
+
#
# System bus types
#
-device mainbus at root: isabus, eisabus, pcibus
+device mainbus: isabus, eisabus, pcibus
+attach mainbus at root
file arch/i386/i386/mainbus.c mainbus
#device mca at root {...}
include "../../../dev/pci/files.pci"
file arch/i386/pci/pci_machdep.c pci
+file arch/i386/pci/pci_compat.c pci # XXX compatibility
#
# ISA and mixed ISA+EISA or ISA+PCI or ISA+PCMCIA drivers
file arch/i386/isa/clock.c isabus
# Numeric Processing Extension; Math Co-processor
-device npx at isa
+device npx
+attach npx at isa
file arch/i386/isa/npx.c npx needs-flag
# attribute used to represent the "keyboard controller"
# XXX should be a real device
-define pckbd { [irq = -1], [port = -1] }
+define pckbd { [irq = -1], [port = -1] }
# PC console support a la "pccons"
-device pc at isa: tty, pckbd
+device pc: tty, pckbd
+attach pc at isa
file arch/i386/isa/pccons.c pc needs-flag
# PC console support a la "pcvt"
-device vt at isa: tty, pckbd
+device vt: tty, pckbd
+attach vt at isa
file arch/i386/isa/pcvt/pcvt_drv.c vt needs-flag
file arch/i386/isa/pcvt/pcvt_ext.c vt needs-flag
file arch/i386/isa/pcvt/pcvt_kbd.c vt needs-flag
file arch/i386/isa/pcvt/pcvt_vtf.c vt needs-flag
# PC Mice; Logitech-style, Microsoft-style, and PS/2-style
-device lms at isa
+device lms
+attach lms at isa
file arch/i386/isa/lms.c lms needs-flag
-device mms at isa
+device mms
+attach mms at isa
file arch/i386/isa/mms.c mms needs-flag
-device pms at pckbd
+device pms
+attach pms at pckbd
file arch/i386/isa/pms.c pms needs-flag
# Floppy disk controller
-device fdc at isa {drive = -1}
-device fd at fdc: disk, isadma
+device fdc {drive = -1}
+attach fdc at isa
+device fd: disk, isadma
+attach fd at fdc
file arch/i386/isa/fd.c fdc needs-flag
major {fd = 2}
# PC speaker
-device spkr at pckbd: tty
+device spkr: tty
+attach spkr at pckbd
file arch/i386/isa/spkr.c spkr needs-flag
# AMD am7990 (Lance) -based boards
# (BICC Isolan, NE2100, DEPCA)
# XXX conflicts with other ports; can't be in files.isa
-device le at isa, pci: ether, ifnet, isadma
+device le: ether, ifnet
+attach le at isa with le_isa: isadma
+attach le at pci with le_pci
file dev/isa/if_le.c le
-# National Semiconductor DS8390/WD83C690-based boards
-# (WD/SMC 80x3 family, SMC Ultra [8216], 3Com 3C503, NE[12]000, and clones)
-# XXX conflicts with other ports; can't be in files.isa
-device ed at isa: ether, ifnet
-file dev/isa/if_ed.c ed needs-flag
-
# Game adapter (joystick)
-device joy at isa
-file arch/i386/isa/joy.c joy needs-flag
+device joy
+attach joy at isa
+file arch/i386/isa/joy.c joy needs-flag
#
# EISA-only drivers
#
include "../../../dev/eisa/files.eisa"
+file arch/i386/eisa/eisa_machdep.c eisa
#
# Compatibility modules
--- /dev/null
+/* $NetBSD: eisa_machdep.c,v 1.2 1996/04/11 22:15:08 cgd Exp $ */
+
+/*
+ * Copyright (c) 1996 Christopher G. Demetriou. 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Machine-specific functions for EISA autoconfiguration.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+
+#include <i386/isa/icu.h>
+#include <dev/isa/isavar.h>
+#include <dev/eisa/eisavar.h>
+
+void
+eisa_attach_hook(parent, self, eba)
+ struct device *parent, *self;
+ struct eisabus_attach_args *eba;
+{
+
+ /* Nothing to do */
+}
+
+int
+eisa_maxslots(ec)
+ eisa_chipset_tag_t ec;
+{
+
+ /*
+ * Always try 16 slots.
+ */
+ return (16);
+}
+
+int
+eisa_intr_map(ec, irq, ihp)
+ eisa_chipset_tag_t ec;
+ u_int irq;
+ eisa_intr_handle_t *ihp;
+{
+
+ if (irq >= ICU_LEN) {
+ printf("eisa_intr_map: bad IRQ %d\n", irq);
+ *ihp = -1;
+ return 1;
+ }
+ if (irq == 2) {
+ printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
+ irq = 9;
+ }
+
+ *ihp = irq;
+ return 0;
+}
+
+const char *
+eisa_intr_string(ec, ih)
+ eisa_chipset_tag_t ec;
+ eisa_intr_handle_t ih;
+{
+ static char irqstr[8]; /* 4 + 2 + NULL + sanity */
+
+ if (ih == 0 || ih >= ICU_LEN || ih == 2)
+ panic("eisa_intr_string: bogus handle 0x%x\n", ih);
+
+ sprintf(irqstr, "irq %d", ih);
+ return (irqstr);
+
+}
+
+void *
+eisa_intr_establish(ec, ih, type, level, func, arg, what)
+ eisa_chipset_tag_t ec;
+ eisa_intr_handle_t ih;
+ int type, level, (*func) __P((void *));
+ void *arg;
+ char *what;
+{
+
+ if (ih == 0 || ih >= ICU_LEN || ih == 2)
+ panic("eisa_intr_establish: bogus handle 0x%x\n", ih);
+
+ return isa_intr_establish(NULL, ih, type, level, func, arg, what);
+}
+
+void
+eisa_intr_disestablish(ec, cookie)
+ eisa_chipset_tag_t ec;
+ void *cookie;
+{
+
+ return isa_intr_disestablish(NULL, cookie);
+}
-/* $OpenBSD: eisa_machdep.h,v 1.1 1996/04/18 18:56:27 niklas Exp $ */
-/* $NetBSD: eisa_machdep.h,v 1.1 1996/03/04 03:26:14 cgd Exp $ */
+/* $OpenBSD: eisa_machdep.h,v 1.2 1996/04/21 22:16:19 deraadt Exp $ */
+/* $NetBSD: eisa_machdep.h,v 1.2 1996/04/09 23:00:27 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
*/
/*
- * The "EISA" signature is in the BIOS of EISA systems. We use it
- * to determine whether or not we have an EISA bus.
+ * Machine-specific definitions for EISA autoconfiguration.
+ */
+
+/*
+ * i386-specific EISA definitions.
+ * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
*/
#define EISA_ID "EISA"
#define EISA_ID_LEN (sizeof(EISA_ID) - 1)
#define EISA_ID_PADDR 0xfffd9
+
+/*
+ * Types provided to machine-independent EISA code.
+ */
+typedef void *eisa_chipset_tag_t;
+typedef int eisa_intr_handle_t;
+
+/*
+ * Functions provided to machine-independent EISA code.
+ */
+void eisa_attach_hook __P((struct device *, struct device *,
+ struct eisabus_attach_args *));
+int eisa_maxslots __P((eisa_chipset_tag_t));
+int eisa_intr_map __P((eisa_chipset_tag_t, u_int,
+ eisa_intr_handle_t *));
+const char *eisa_intr_string __P((eisa_chipset_tag_t, eisa_intr_handle_t));
+void *eisa_intr_establish __P((eisa_chipset_tag_t,
+ eisa_intr_handle_t, int, int, int (*)(void *), void *,
+ char *));
+void eisa_intr_disestablish __P((eisa_chipset_tag_t, void *));
-/* $OpenBSD: autoconf.c,v 1.7 1996/04/18 19:18:05 niklas Exp $ */
-/* $NetBSD: autoconf.c,v 1.18 1996/03/04 03:26:18 cgd Exp $ */
+/* $OpenBSD: autoconf.c,v 1.8 1996/04/21 22:16:22 deraadt Exp $ */
+/* $NetBSD: autoconf.c,v 1.19 1996/03/29 01:15:04 mycroft Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
void swapconf __P((void));
void setroot __P((void));
+void setroot __P((void));
+void swapconf __P((void));
+void dumpconf __P((void));
+
/*
* The following several variables are related to
* the configuration process, and are used in initializing
-/* $OpenBSD: conf.c,v 1.11 1996/04/18 19:18:06 niklas Exp $ */
-/* $NetBSD: conf.c,v 1.71 1996/03/14 21:27:33 christos Exp $ */
+/* $OpenBSD: conf.c,v 1.12 1996/04/21 22:16:23 deraadt Exp $ */
+/* $NetBSD: conf.c,v 1.74 1996/03/30 07:30:33 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
bdev_decl(scd);
#include "ccd.h"
bdev_decl(ccd);
+#include "rd.h"
+bdev_decl(rd);
+/* no cdev for rd */
struct bdevsw bdevsw[] =
{
bdev_disk_init(NVND,vnd), /* 14: vnode disk driver */
bdev_disk_init(NSCD,scd), /* 15: Sony CD-ROM */
bdev_disk_init(NCCD,ccd), /* 16: concatenated disk driver */
+ bdev_disk_init(NRD,rd), /* 17: ram disk driver */
};
int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
0, seltrue, (dev_type_mmap((*))) enodev }
-/* open, close, ioctl, select -- XXX should be a generic device */
-#define cdev_ocis_init(c,n) { \
- dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
- (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
- (dev_type_stop((*))) enodev, 0, dev_init(c,n,select), \
- (dev_type_mmap((*))) enodev, 0 }
-
-/* open, close, read, ioctl */
-#define cdev_joy_init(c,n) { \
- dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
- (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
- (dev_type_stop((*))) enodev, 0, seltrue, (dev_type_mmap((*))) enodev }
-
/* open, close, read, ioctl */
#define cdev_ss_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
(dev_type_stop((*))) enodev, 0, seltrue, \
(dev_type_mmap((*))) enodev }
+#define cdev_joy_init cdev_ss_init
cdev_decl(cn);
cdev_decl(ctty);
dev_decl(filedesc,open);
#include "bpfilter.h"
cdev_decl(bpf);
-#include "pcmciabus.h"
-cdev_decl(pcmciabus);
#include "spkr.h"
cdev_decl(spkr);
#ifdef LKM
cdev_fd_init(1,filedesc), /* 22: file descriptor pseudo-device */
cdev_bpftun_init(NBPFILTER,bpf),/* 23: Berkeley packet filter */
cdev_notdef(), /* 24 */
- cdev_joy_init(NJOY,joy), /* 25: Game adapter */
- cdev_ocis_init(NPCMCIABUS,pcmciabus), /* 26: PCMCIA Bus */
+ cdev_notdef(), /* 25 */
+ cdev_joy_init(NJOY,joy), /* 26: joystick */
cdev_spkr_init(NSPKR,spkr), /* 27: PC speaker */
cdev_lkm_init(NLKM,lkm), /* 28: loadable module driver */
cdev_lkm_dummy(), /* 29 */
/*
* Returns true if dev is /dev/mem or /dev/kmem.
*/
+int
iskmemdev(dev)
dev_t dev;
{
/*
* Returns true if dev is /dev/zero.
*/
+int
iszerodev(dev)
dev_t dev;
{
/*
* Convert a character device number to a block device number.
*/
+dev_t
chrtoblk(dev)
dev_t dev;
{
-/* $OpenBSD: db_interface.c,v 1.4 1996/04/18 19:18:06 niklas Exp $ */
-/* $NetBSD: db_interface.c,v 1.20 1996/03/15 00:07:18 chuck Exp $ */
+/* $OpenBSD: db_interface.c,v 1.5 1996/04/21 22:16:24 deraadt Exp $ */
+/* $NetBSD: db_interface.c,v 1.21 1996/03/30 07:57:16 mycroft Exp $ */
/*
* Mach Operating System
#include <machine/db_machdep.h>
extern label_t *db_recover;
+extern char *trap_type[];
+extern int trap_types;
int db_active = 0;
+/*
+ * Print trap reason.
+ */
+void
+kdbprinttrap(type, code)
+ int type, code;
+{
+ db_printf("kernel: ");
+ if (type >= trap_types || type < 0)
+ db_printf("type %d", type);
+ else
+ db_printf("%s", trap_type[type]);
+ db_printf(" trap, code=%x\n", code);
+}
+
/*
* kdb_trap - field a TRACE or BPT trap
*/
+int
kdb_trap(type, code, regs)
int type, code;
register db_regs_t *regs;
return (1);
}
-extern char *trap_type[];
-extern int trap_types;
-
-/*
- * Print trap reason.
- */
-kdbprinttrap(type, code)
- int type, code;
-{
- db_printf("kernel: ");
- if (type >= trap_types || type < 0)
- db_printf("type %d", type);
- else
- db_printf("%s", trap_type[type]);
- db_printf(" trap, code=%x\n", code);
-}
-
/*
* Read bytes from kernel address space for debugger.
*/
-/* $OpenBSD: disksubr.c,v 1.2 1996/04/18 19:18:07 niklas Exp $ */
-/* $NetBSD: disksubr.c,v 1.19 1996/03/09 20:52:59 ghudson Exp $ */
+/* $OpenBSD: disksubr.c,v 1.3 1996/04/21 22:16:25 deraadt Exp $ */
+/* $NetBSD: disksubr.c,v 1.20 1996/04/03 08:18:27 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
* Check new disk label for sensibility
* before setting it.
*/
+int
setdisklabel(olp, nlp, openmask, osdep)
register struct disklabel *olp, *nlp;
u_long openmask;
/*
* Write disk label back to device after modification.
*/
+int
writedisklabel(dev, strat, lp, osdep)
dev_t dev;
void (*strat)();
-/* $OpenBSD: freebsd_machdep.c,v 1.3 1996/04/17 05:18:51 mickey Exp $ */
-/* $NetBSD: freebsd_machdep.c,v 1.7 1996/04/11 07:47:44 mycroft Exp $ */
+/* $OpenBSD: freebsd_machdep.c,v 1.4 1996/04/21 22:16:26 deraadt Exp $ */
+/* $NetBSD: freebsd_machdep.c,v 1.8 1996/04/12 08:44:35 mycroft Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996 Charles M. Hannum. All rights reserved.
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
frame.sf_sc.sc_eflags = get_vflags(p);
- tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
tf->tf_eip = (int)(((char *)PS_STRINGS) -
(freebsd_esigcode - freebsd_sigcode));
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+ tf->tf_eflags &= ~(PSL_T|PSL_VM);
tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
-/* $NetBSD: genassym.c,v 1.46 1996/02/02 19:42:43 mycroft Exp $ */
+/* $NetBSD: genassym.c,v 1.48 1996/03/28 23:44:04 mycroft Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
#include <i386/isa/isa_machdep.h>
#endif
+#include <stdio.h>
+#include <stddef.h>
+
+int
main()
{
- struct proc *p = 0;
- struct vmmeter *vm = 0;
- struct pcb *pcb = 0;
- struct trapframe *tf = 0;
- struct sigframe *sigf = 0;
- struct sigcontext *sc = 0;
- struct uprof *uprof = 0;
-#if NISA > 0
- struct intrhand *ih = 0;
-#endif
-#ifdef COMPAT_SVR4
- struct svr4_sigframe *svr4_sigf = 0;
- struct svr4_ucontext *svr4_uc = 0;
-#endif
-#ifdef COMPAT_LINUX
- struct linux_sigframe *linux_sigf = 0;
- struct linux_sigcontext *linux_sc = 0;
-#endif
-#ifdef COMPAT_FREEBSD
- struct freebsd_sigframe *freebsd_sigf = 0;
- struct freebsd_sigcontext *freebsd_sc = 0;
-#endif
#define def(N,V) printf("#define\t%s %d\n", N, V)
+#define off(N,S,M) def(N, (int)offsetof(S, M))
def("SRUN", SRUN);
def("NKPDE", NKPDE);
def("APTDPTDI", APTDPTDI);
- def("VM_MAXUSER_ADDRESS", VM_MAXUSER_ADDRESS);
+ def("VM_MAXUSER_ADDRESS", (int)VM_MAXUSER_ADDRESS);
- def("P_ADDR", &p->p_addr);
- def("P_BACK", &p->p_back);
- def("P_FORW", &p->p_forw);
- def("P_PRIORITY", &p->p_priority);
- def("P_STAT", &p->p_stat);
- def("P_WCHAN", &p->p_wchan);
- def("P_VMSPACE", &p->p_vmspace);
- def("P_FLAG", &p->p_flag);
+ off("P_ADDR", struct proc, p_addr);
+ off("P_BACK", struct proc, p_back);
+ off("P_FORW", struct proc, p_forw);
+ off("P_PRIORITY", struct proc, p_priority);
+ off("P_STAT", struct proc, p_stat);
+ off("P_WCHAN", struct proc, p_wchan);
+ off("P_VMSPACE", struct proc, p_vmspace);
+ off("P_FLAG", struct proc, p_flag);
def("P_SYSTEM", P_SYSTEM);
- def("V_TRAP", &vm->v_trap);
- def("V_INTR", &vm->v_intr);
+ off("V_TRAP", struct vmmeter, v_trap);
+ off("V_INTR", struct vmmeter, v_intr);
- def("PCB_CR3", &pcb->pcb_cr3);
- def("PCB_EBP", &pcb->pcb_ebp);
- def("PCB_ESP", &pcb->pcb_esp);
- def("PCB_FS", &pcb->pcb_fs);
- def("PCB_GS", &pcb->pcb_gs);
- def("PCB_CR0", &pcb->pcb_cr0);
- def("PCB_LDT_SEL", &pcb->pcb_ldt_sel);
- def("PCB_TSS_SEL", &pcb->pcb_tss_sel);
- def("PCB_ONFAULT", &pcb->pcb_onfault);
+ off("PCB_CR3", struct pcb, pcb_cr3);
+ off("PCB_EBP", struct pcb, pcb_ebp);
+ off("PCB_ESP", struct pcb, pcb_esp);
+ off("PCB_FS", struct pcb, pcb_fs);
+ off("PCB_GS", struct pcb, pcb_gs);
+ off("PCB_CR0", struct pcb, pcb_cr0);
+ off("PCB_LDT_SEL", struct pcb, pcb_ldt_sel);
+ off("PCB_TSS_SEL", struct pcb, pcb_tss_sel);
+ off("PCB_ONFAULT", struct pcb, pcb_onfault);
- def("TF_CS", &tf->tf_cs);
- def("TF_TRAPNO", &tf->tf_trapno);
- def("TF_EFLAGS", &tf->tf_eflags);
+ off("TF_CS", struct trapframe, tf_cs);
+ off("TF_TRAPNO", struct trapframe, tf_trapno);
+ off("TF_EFLAGS", struct trapframe, tf_eflags);
def("FRAMESIZE", sizeof(struct trapframe));
- def("SIGF_HANDLER", &sigf->sf_handler);
- def("SIGF_SC", &sigf->sf_sc);
- def("SC_FS", &sc->sc_fs);
- def("SC_GS", &sc->sc_gs);
- def("SC_EFLAGS", &sc->sc_eflags);
+ off("SIGF_HANDLER", struct sigframe, sf_handler);
+ off("SIGF_SC", struct sigframe, sf_sc);
+ off("SC_FS", struct sigcontext, sc_fs);
+ off("SC_GS", struct sigcontext, sc_gs);
+ off("SC_EFLAGS", struct sigcontext, sc_eflags);
#ifdef COMPAT_SVR4
- def("SVR4_SIGF_HANDLER", &svr4_sigf->sf_handler);
- def("SVR4_SIGF_UC", &svr4_sigf->sf_uc);
- def("SVR4_UC_FS", &svr4_uc->uc_mcontext.greg[SVR4_X86_FS]);
- def("SVR4_UC_GS", &svr4_uc->uc_mcontext.greg[SVR4_X86_GS]);
- def("SVR4_UC_EFLAGS", &svr4_uc->uc_mcontext.greg[SVR4_X86_EFL]);
+ off("SVR4_SIGF_HANDLER", struct svr4_sigframe, sf_handler);
+ off("SVR4_SIGF_UC", struct svr4_sigframe, sf_uc);
+ off("SVR4_UC_FS", struct svr4_ucontext, uc_mcontext.greg[SVR4_X86_FS]);
+ off("SVR4_UC_GS", struct svr4_ucontext, uc_mcontext.greg[SVR4_X86_GS]);
+ off("SVR4_UC_EFLAGS", struct svr4_ucontext, uc_mcontext.greg[SVR4_X86_EFL]);
#endif
#ifdef COMPAT_LINUX
- def("LINUX_SIGF_HANDLER", &linux_sigf->sf_handler);
- def("LINUX_SIGF_SC", &linux_sigf->sf_sc);
- def("LINUX_SC_FS", &linux_sc->sc_fs);
- def("LINUX_SC_GS", &linux_sc->sc_gs);
- def("LINUX_SC_EFLAGS", &linux_sc->sc_eflags);
+ off("LINUX_SIGF_HANDLER", struct linux_sigframe, sf_handler);
+ off("LINUX_SIGF_SC", struct linux_sigframe, sf_sc);
+ off("LINUX_SC_FS", struct linux_sigcontext, sc_fs);
+ off("LINUX_SC_GS", struct linux_sigcontext, sc_gs);
+ off("LINUX_SC_EFLAGS", struct linux_sigcontext, sc_eflags);
#endif
#ifdef COMPAT_FREEBSD
- def("FREEBSD_SIGF_HANDLER", &freebsd_sigf->sf_handler);
- def("FREEBSD_SIGF_SC", &freebsd_sigf->sf_sc);
+ off("FREEBSD_SIGF_HANDLER", struct freebsd_sigframe, sf_handler);
+ off("FREEBSD_SIGF_SC", struct freebsd_sigframe, sf_sc);
#endif
#if NISA > 0
- def("IH_FUN", &ih->ih_fun);
- def("IH_ARG", &ih->ih_arg);
- def("IH_COUNT", &ih->ih_count);
- def("IH_NEXT", &ih->ih_next);
+ off("IH_FUN", struct intrhand, ih_fun);
+ off("IH_ARG", struct intrhand, ih_arg);
+ off("IH_COUNT", struct intrhand, ih_count);
+ off("IH_NEXT", struct intrhand, ih_next);
#endif
exit(0);
-/* $OpenBSD: linux_machdep.c,v 1.5 1996/04/18 19:18:09 niklas Exp $ */
-/* $NetBSD: linux_machdep.c,v 1.26 1996/04/11 07:47:45 mycroft Exp $ */
+/* $OpenBSD: linux_machdep.c,v 1.6 1996/04/21 22:16:28 deraadt Exp $ */
+/* $NetBSD: linux_machdep.c,v 1.27 1996/04/12 08:44:37 mycroft Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
frame.sf_sc.sc_eflags = get_vflags(p);
- tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
tf->tf_eip = (int)(((char *)PS_STRINGS) -
(linux_esigcode - linux_sigcode));
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+ tf->tf_eflags &= ~(PSL_T|PSL_VM);
tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
-/* $NetBSD: locore.s,v 1.143 1996/02/02 02:36:40 mycroft Exp $ */
+/* $NetBSD: locore.s,v 1.144 1996/04/03 05:48:35 mycroft Exp $ */
-#undef DIAGNOSTIC
-#define DIAGNOSTIC
/*-
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
* Copyright (c) 1990 The Regents of the University of California.
-/* $OpenBSD: machdep.c,v 1.12 1996/04/18 19:18:11 niklas Exp $ */
-/* $NetBSD: machdep.c,v 1.194 1996/03/08 20:19:48 cgd Exp $ */
+/* $OpenBSD: machdep.c,v 1.13 1996/04/21 22:16:31 deraadt Exp $ */
+/* $NetBSD: machdep.c,v 1.197 1996/04/12 08:44:40 mycroft Exp $ */
/*-
- * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1993, 1994, 1995, 1996 Charles M. Hannum. All rights reserved.
* Copyright (c) 1992 Terrence R. Lambert.
* Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
* All rights reserved.
static vm_offset_t hole_start, hole_end;
static vm_offset_t avail_next;
+void identifycpu __P((void));
caddr_t allocsys __P((caddr_t));
void dumpsys __P((void));
void cpu_reset __P((void));
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
frame.sf_sc.sc_eflags = get_vflags(p);
- tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_eip = (int)(((char *)PS_STRINGS) - (esigcode - sigcode));
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+ tf->tf_eflags &= ~(PSL_T|PSL_VM);
tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = context.sc_mask & ~sigcantmask;
+ if (context.sc_onstack & 01)
+ p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ else
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigmask = context.sc_mask & ~sigcantmask;
+
return (EJUSTRETURN);
}
-/* $OpenBSD: mainbus.c,v 1.1 1996/04/18 19:18:11 niklas Exp $ */
-/* $NetBSD: mainbus.c,v 1.4 1996/03/14 02:37:28 cgd Exp $ */
+/* $OpenBSD: mainbus.c,v 1.2 1996/04/21 22:16:32 deraadt Exp $ */
+/* $NetBSD: mainbus.c,v 1.8 1996/04/11 22:13:37 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
#include <machine/bus.h>
-#if 0 /* XXX eisavar.h includes isavar.h, which is not idempotent */
#include <dev/isa/isavar.h>
-#endif
#include <dev/eisa/eisavar.h>
#include <dev/pci/pcivar.h>
-#include <dev/isa/isareg.h>
+#include <dev/isa/isareg.h> /* for ISA_HOLE_VADDR */
#include <i386/isa/isa_machdep.h>
-#include <i386/eisa/eisa_machdep.h>
#include "pci.h"
int mainbus_match __P((struct device *, void *, void *));
void mainbus_attach __P((struct device *, struct device *, void *));
-struct cfdriver mainbuscd =
- { NULL, "mainbus", mainbus_match, mainbus_attach,
- DV_DULL, sizeof(struct device) };
+struct cfattach mainbus_ca = {
+ sizeof(struct device), mainbus_match, mainbus_attach
+};
+
+struct cfdriver mainbus_cd = {
+ NULL, "mainbus", DV_DULL
+};
int mainbus_print __P((void *, char *));
printf("\n");
+ if (1 /* XXX ISA NOT YET SEEN */) {
+ mba.mba_iba.iba_busname = "isa";
+ mba.mba_iba.iba_bc = NULL;
+ mba.mba_iba.iba_ic = NULL;
+ config_found(self, &mba.mba_iba, mainbus_print);
+ }
+
+ if (!bcmp(ISA_HOLE_VADDR(EISA_ID_PADDR), EISA_ID, EISA_ID_LEN)) {
+ mba.mba_eba.eba_busname = "eisa";
+ mba.mba_eba.eba_bc = NULL;
+ mba.mba_eba.eba_ec = NULL;
+ config_found(self, &mba.mba_eba, mainbus_print);
+ }
+
/*
* XXX Note also that the presence of a PCI bus should
* XXX _always_ be checked, and if present the bus should be
}
#endif
- if (!bcmp(ISA_HOLE_VADDR(EISA_ID_PADDR), EISA_ID, EISA_ID_LEN)) {
- mba.mba_eba.eba_busname = "eisa";
- mba.mba_eba.eba_bc = NULL;
- config_found(self, &mba.mba_eba, mainbus_print);
- }
-
- if (1 /* XXX ISA NOT YET SEEN */) {
- mba.mba_iba.iba_busname = "isa";
- mba.mba_iba.iba_bc = NULL;
- config_found(self, &mba.mba_iba, mainbus_print);
- }
}
int
-/* $OpenBSD: pmap.c,v 1.7 1996/04/18 04:04:54 mickey Exp $ */
-/* $NetBSD: pmap.c,v 1.34 1995/12/09 07:39:02 mycroft Exp $ */
+/* $OpenBSD: pmap.c,v 1.8 1996/04/21 22:16:33 deraadt Exp $ */
+/* $NetBSD: pmap.c,v 1.35 1996/04/03 08:21:05 mycroft Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
void i386_protection_init __P((void));
pt_entry_t *pmap_pte __P((pmap_t, vm_offset_t));
+void i386_protection_init __P((void));
#if BSDVM_COMPAT
#include <sys/msgbuf.h>
-/* $OpenBSD: pmap.old.c,v 1.7 1996/04/18 04:04:54 mickey Exp $ */
-/* $NetBSD: pmap.c,v 1.34 1995/12/09 07:39:02 mycroft Exp $ */
+/* $OpenBSD: pmap.old.c,v 1.8 1996/04/21 22:16:33 deraadt Exp $ */
+/* $NetBSD: pmap.c,v 1.35 1996/04/03 08:21:05 mycroft Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
void i386_protection_init __P((void));
pt_entry_t *pmap_pte __P((pmap_t, vm_offset_t));
+void i386_protection_init __P((void));
#if BSDVM_COMPAT
#include <sys/msgbuf.h>
-/* $OpenBSD: process_machdep.c,v 1.3 1996/04/17 05:18:56 mickey Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.4 1996/04/21 22:16:34 deraadt Exp $ */
/* $NetBSD: process_machdep.c,v 1.21 1996/04/11 07:47:48 mycroft Exp $ */
/*
#define valid_sel(sel) (ISPL(sel) == SEL_UPL && verr(sel))
#define null_sel(sel) (!ISLDT(sel) && IDXSEL(sel) == 0)
- /*
- * Check for security violations.
- */
- if (((regs->r_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(regs->r_cs, regs->r_eflags))
- return (EINVAL);
-
if ((regs->r_gs != pcb->pcb_gs && \
!valid_sel(regs->r_gs) && !null_sel(regs->r_gs)) ||
(regs->r_fs != pcb->pcb_fs && \
--- /dev/null
+/* $NetBSD: rd_root.c,v 1.2 1996/03/27 16:38:33 perry Exp $ */
+
+/*
+ * Copyright (c) 1995 Gordon W. Ross
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+
+#include <dev/ramdisk.h>
+
+extern int boothowto;
+
+#ifndef MINIROOTSIZE
+#define MINIROOTSIZE 512
+#endif
+
+#define ROOTBYTES (MINIROOTSIZE << DEV_BSHIFT)
+
+/*
+ * This array will be patched to contain a file-system image.
+ * See the program: src/distrib/sun3/common/rdsetroot.c
+ */
+int rd_root_size = ROOTBYTES;
+char rd_root_image[ROOTBYTES] = "|This is the root ramdisk!\n";
+
+/*
+ * This is called during autoconfig.
+ */
+void
+rd_attach_hook(unit, rd)
+ int unit;
+ struct rd_conf *rd;
+{
+ if (unit == 0) {
+ /* Setup root ramdisk */
+ rd->rd_addr = (caddr_t) rd_root_image;
+ rd->rd_size = (size_t) rd_root_size;
+ rd->rd_type = RD_KMEM_FIXED;
+ printf(" fixed, %d blocks", MINIROOTSIZE);
+ }
+}
+
+/*
+ * This is called during open (i.e. mountroot)
+ */
+void
+rd_open_hook(unit, rd)
+ int unit;
+ struct rd_conf *rd;
+{
+ if (unit == 0) {
+ /* The root ramdisk only works single-user. */
+ boothowto |= RB_SINGLE;
+ }
+}
-/* $OpenBSD: svr4_machdep.c,v 1.3 1996/04/17 05:18:57 mickey Exp $ */
-/* $NetBSD: svr4_machdep.c,v 1.21 1996/04/11 07:47:50 mycroft Exp $ */
+/* $OpenBSD: svr4_machdep.c,v 1.4 1996/04/21 22:16:38 deraadt Exp $ */
+/* $NetBSD: svr4_machdep.c,v 1.22 1996/04/12 08:44:42 mycroft Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
r[SVR4_X86_ES] = tf->tf_vm86_es;
r[SVR4_X86_DS] = tf->tf_vm86_ds;
r[SVR4_X86_EFL] = get_vflags(p);
- tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
/*
* Build context to run handler in.
*/
- tf->tf_esp = (int)fp;
+ tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_eip = (int)(((char *)PS_STRINGS) -
- (svr4_esigcode - svr4_sigcode));
-#ifdef VM86
- tf->tf_eflags &= ~PSL_VM;
-#endif
+ (svr4_esigcode - svr4_sigcode));
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
- tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
- tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_eflags &= ~(PSL_T|PSL_VM);
+ tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
-/* $OpenBSD: swapgeneric.c,v 1.3 1996/04/18 19:18:12 niklas Exp $ */
-/* $NetBSD: swapgeneric.c,v 1.9 1994/11/04 09:57:52 mycroft Exp $ */
+/* $OpenBSD: swapgeneric.c,v 1.4 1996/04/21 22:16:39 deraadt Exp $ */
+/* $NetBSD: swapgeneric.c,v 1.11 1996/04/03 09:15:26 mycroft Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
#include "cd.h"
#include "mcd.h"
-void gets __P((char *));
-
/*
* Generic configuration; all in one
*/
int dmmin, dmmax, dmtext;
#if NWDC > 0
-extern struct cfdriver wdcd;
+extern struct cfdriver wd_cd;
#endif
#if NFDC > 0
-extern struct cfdriver fdcd;
+extern struct cfdriver fd_cd;
#endif
#if NSD > 0
-extern struct cfdriver sdcd;
+extern struct cfdriver sd_cd;
#endif
#if NCD > 0
-extern struct cfdriver cdcd;
+extern struct cfdriver cd_cd;
#endif
#if NMCD > 0
-extern struct cfdriver mcdcd;
+extern struct cfdriver mcd_cd;
#endif
struct genericconf {
dev_t gc_major;
} genericconf[] = {
#if NWDC > 0
- { &wdcd, "wd", 0 },
+ { &wd_cd, "wd", 0 },
#endif
#if NSD > 0
- { &sdcd, "sd", 4 },
+ { &sd_cd, "sd", 4 },
#endif
#if NCD > 0
- { &cdcd, "cd", 6 },
+ { &cd_cd, "cd", 6 },
#endif
#if NMCD > 0
- { &mcdcd, "mcd", 7 },
+ { &mcd_cd, "mcd", 7 },
#endif
#if NFDC > 0
- { &fdcd, "fd", 2 },
+ { &fd_cd, "fd", 2 },
#endif
{ 0 }
};
extern int ffs_mountroot();
int (*mountroot)() = ffs_mountroot;
+void gets __P((char *));
+
void
setconf()
{
-/* $OpenBSD: trap.c,v 1.6 1996/03/19 21:09:23 mickey Exp $ */
-/* $NetBSD: trap.c,v 1.92 1996/01/08 13:51:38 mycroft Exp $ */
+/* $OpenBSD: trap.c,v 1.7 1996/04/21 22:16:40 deraadt Exp $ */
+/* $NetBSD: trap.c,v 1.93 1996/04/15 00:20:32 mycroft Exp $ */
#undef DEBUG
#define DEBUG
map, va, ftype, rv);
goto we_re_toast;
}
- trapsignal(p, (rv == KERN_PROTECTION_FAILURE)
- ? SIGBUS : SIGSEGV, T_PAGEFLT);
+ trapsignal(p, (rv == KERN_PROTECTION_FAILURE
+#ifdef COMPAT_LINUX
+ && p->p_emul != &emul_linux_aout && p->p_emul != &emul_linux_elf
+#endif
+ ) ? SIGBUS : SIGSEGV, T_PAGEFLT);
break;
}
case T_BPTFLT|T_USER: /* bpt instruction fault */
case T_TRCTRAP|T_USER: /* trace trap */
trace:
- frame.tf_eflags &= ~PSL_T;
trapsignal(p, SIGTRAP, type &~ T_USER);
break;
-/* $OpenBSD: vm86.c,v 1.3 1996/04/18 19:18:13 niklas Exp $ */
-/* $NetBSD: vm86.c,v 1.8 1996/04/11 10:07:17 mycroft Exp $ */
+/* $OpenBSD: vm86.c,v 1.4 1996/04/21 22:16:42 deraadt Exp $ */
+/* $NetBSD: vm86.c,v 1.9 1996/04/12 05:57:43 mycroft Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
static void fast_intxx __P((struct proc *, int));
-#define CS(tf) (*(u_short *)&tf->tf_cs)
+#define SETDIRECT ((~(PSL_USERSTATIC|PSL_NT)) & 0xffff)
+#define GETDIRECT (SETDIRECT|0x02a) /* add in two MBZ bits */
+
#define IP(tf) (*(u_short *)&tf->tf_eip)
-#define SS(tf) (*(u_short *)&tf->tf_ss)
#define SP(tf) (*(u_short *)&tf->tf_esp)
struct trapframe *tf = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
struct vm86_kern vm86s;
- int err;
+ int error;
- if (err = copyin(args, &vm86s, sizeof(vm86s)))
- return err;
+ error = copyin(args, &vm86s, sizeof(vm86s));
+ if (error)
+ return (error);
pcb->vm86_userp = (void *)args;
case VCPU_086:
case VCPU_186:
case VCPU_286:
- pcb->vm86_flagmask = 0;
+ pcb->vm86_flagmask = PSL_ID|PSL_AC|PSL_NT|PSL_IOPL;
break;
case VCPU_386:
- pcb->vm86_flagmask = PSL_NT|PSL_IOPL;
+ pcb->vm86_flagmask = PSL_ID|PSL_AC;
break;
case VCPU_486:
- pcb->vm86_flagmask = PSL_AC|PSL_NT|PSL_IOPL;
+ pcb->vm86_flagmask = PSL_ID;
break;
case VCPU_586:
- default:
- pcb->vm86_flagmask = PSL_ID|PSL_AC|PSL_NT|PSL_IOPL;
+ pcb->vm86_flagmask = 0;
break;
+ default:
+ return (EINVAL);
}
#define DOVREG(reg) tf->tf_vm86_##reg = (u_short) vm86s.regs.vmsc.sc_##reg
-/* $OpenBSD: vm_machdep.c,v 1.8 1996/04/17 05:19:00 mickey Exp $ */
-/* $NetBSD: vm_machdep.c,v 1.58 1996/02/05 02:00:35 christos Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.9 1996/04/21 22:16:43 deraadt Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.59 1996/04/03 08:24:17 mycroft Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
return 0;
}
+#if 0
/*
* Set a red zone in the kernel stack after the u. area.
*/
used by sched (that has physical memory mapped 1:1 at bottom)
and take the dump while still in mapped mode */
}
+#endif
/*
* Move pages from one kernel virtual address to another.
-/* $OpenBSD: bus.h,v 1.1 1996/04/18 19:21:33 niklas Exp $ */
-/* $NetBSD: bus.h,v 1.1 1996/03/08 20:11:23 cgd Exp $ */
+/* $OpenBSD: bus.h,v 1.2 1996/04/21 22:16:46 deraadt Exp $ */
+/* $NetBSD: bus.h,v 1.2 1996/04/05 23:59:37 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
#define bus_io_read_8(t, h, o) !!! bus_io_read_8 unimplemented !!!
#endif
+#define bus_io_read_multi_1(t, h, o, a, c) \
+ insb((h) + (o), (a), (c))
+#define bus_io_read_multi_2(t, h, o, a, c) \
+ insw((h) + (o), (a), (c))
+#define bus_io_read_multi_4(t, h, o, a, c) \
+ insl((h) + (o), (a), (c))
+#if 0 /* Cause a link error for bus_io_read_multi_8 */
+#define bus_io_read_multi_8(t, h, o, a, c) \
+ !!! bus_io_read_multi_8 unimplemented !!!
+#endif
+
#define bus_io_write_1(t, h, o, v) outb((h) + (o), (v))
#define bus_io_write_2(t, h, o, v) outw((h) + (o), (v))
#define bus_io_write_4(t, h, o, v) outl((h) + (o), (v))
#define bus_io_write_8(t, h, o, v) !!! bus_io_write_8 unimplemented !!!
#endif
+#define bus_io_write_multi_1(t, h, o, a, c) \
+ outsb((h) + (o), (a), (c))
+#define bus_io_write_multi_2(t, h, o, a, c) \
+ outsw((h) + (o), (a), (c))
+#define bus_io_write_multi_4(t, h, o, a, c) \
+ outsl((h) + (o), (a), (c))
+#if 0 /* Cause a link error for bus_io_write_multi_8 */
+#define bus_io_write_multi_8(t, h, o, a, c) \
+ !!! bus_io_write_multi_8 unimplimented !!!
+#endif
+
int bus_mem_map __P((bus_chipset_tag_t t, bus_mem_addr_t bpa,
bus_mem_size_t size, int cacheable, bus_mem_handle_t *mhp));
void bus_mem_unmap __P((bus_chipset_tag_t t, bus_mem_handle_t memh,
-/* $NetBSD: cpu.h,v 1.32 1995/12/24 01:08:02 mycroft Exp $ */
+/* $NetBSD: cpu.h,v 1.33 1996/03/29 00:23:28 mycroft Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* We need a machine-independent name for this.
*/
#define DELAY(x) delay(x)
+void delay __P((int));
#ifdef I586_CPU
/*
+/* $NetBSD: joystick.h,v 1.1 1996/03/27 19:18:56 perry Exp $ */
+
+#ifndef _JOY_IOCTL_H_
+#define _JOY_IOCTL_H_
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+struct joystick {
+ int x;
+ int y;
+ int b1;
+ int b2;
+};
+
+#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */
+#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */
+#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */
+#define JOY_SET_Y_OFFSET _IOW('J', 4, int) /* set offset on X-axis */
+#define JOY_GET_X_OFFSET _IOR('J', 5, int) /* get offset on X-axis */
+#define JOY_GET_Y_OFFSET _IOR('J', 6, int) /* get offset on Y-axis */
+
+#endif /* _JOY_IOCTL_H_ */
#ifndef _JOY_IOCTL_H_
#define _JOY_IOCTL_H_
-/* $OpenBSD: vm86.h,v 1.3 1996/04/18 19:21:42 niklas Exp $ */
-/* $NetBSD: vm86.h,v 1.4 1996/04/11 10:07:25 mycroft Exp $ */
+/* $OpenBSD: vm86.h,v 1.4 1996/04/21 22:16:48 deraadt Exp $ */
+/* $NetBSD: vm86.h,v 1.5 1996/04/12 05:57:45 mycroft Exp $ */
#define VM86_USE_VIF
#define VM86_SETDIRECT (~PSL_USERSTATIC)
#define VM86_GETDIRECT (VM86_SETDIRECT|PSL_MBO|PSL_MBZ)
+#define VM86_SETDIRECT (~PSL_USERSTATIC)
+#define VM86_GETDIRECT (VM86_SETDIRECT|PSL_MBO|PSL_MBZ)
+
struct vm86_regs {
struct sigcontext vmsc;
};
struct trapframe *tf = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
- SETFLAGS(pcb->vm86_eflags, flags, pcb->vm86_flagmask | ~VM86_GETDIRECT);
+ flags &= ~pcb->vm86_flagmask;
+ SETFLAGS(pcb->vm86_eflags, flags, ~VM86_GETDIRECT);
SETFLAGS(tf->tf_eflags, flags, VM86_SETDIRECT);
#ifndef VM86_USE_VIF
if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
struct pcb *pcb = &p->p_addr->u_pcb;
int flags = 0;
- SETFLAGS(flags, pcb->vm86_eflags, pcb->vm86_flagmask | ~VM86_GETDIRECT);
+ SETFLAGS(flags, pcb->vm86_eflags, ~VM86_GETDIRECT);
SETFLAGS(flags, tf->tf_eflags, VM86_GETDIRECT);
return (flags);
}
struct trapframe *tf = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
- SETFLAGS(pcb->vm86_eflags, flags, (pcb->vm86_flagmask | ~VM86_GETDIRECT) & 0xffff);
+ flags &= ~pcb->vm86_flagmask;
+ SETFLAGS(pcb->vm86_eflags, flags, ~VM86_GETDIRECT & 0xffff);
SETFLAGS(tf->tf_eflags, flags, VM86_SETDIRECT & 0xffff);
#ifndef VM86_USE_VIF
if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
struct pcb *pcb = &p->p_addr->u_pcb;
int flags = 0;
- SETFLAGS(flags, pcb->vm86_eflags, (pcb->vm86_flagmask | ~VM86_GETDIRECT) & 0xffff);
+ SETFLAGS(flags, pcb->vm86_eflags, ~VM86_GETDIRECT & 0xffff);
SETFLAGS(flags, tf->tf_eflags, VM86_GETDIRECT & 0xffff);
return (flags);
}
-/* $NetBSD: clock.c,v 1.35 1995/12/24 02:30:07 mycroft Exp $ */
+/* $NetBSD: clock.c,v 1.37 1996/04/11 22:15:13 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles Hannum.
#include <i386/isa/spkrreg.h>
void spinwait __P((int));
+void findcpuspeed __P((void));
#ifdef I586_CPU
int pentium_mhz;
unsigned int delaycount; /* calibrated loop variable (1 millisecond) */
#define FIRST_GUESS 0x2000
+
+void
findcpuspeed()
{
int i;
* XXX If you're doing strange things with multiple clocks, you might
* want to keep track of clock handlers.
*/
- (void)isa_intr_establish(0, IST_PULSE, IPL_CLOCK, clockintr, 0, "clock");
+ (void)isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK, clockintr,
+ 0, "clock");
}
void
-/* $OpenBSD: fd.c,v 1.12 1996/04/18 17:12:13 niklas Exp $ */
-/* $NetBSD: fd.c,v 1.85 1996/03/04 04:01:03 mycroft Exp $ */
+/* $OpenBSD: fd.c,v 1.13 1996/04/21 22:16:52 deraadt Exp $ */
+/* $NetBSD: fd.c,v 1.87 1996/04/11 22:15:16 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
#endif
void fdcattach __P((struct device *, struct device *, void *));
-struct cfdriver fdccd = {
- NULL, "fdc", fdcprobe, fdcattach, DV_DULL, sizeof(struct fdc_softc)
+struct cfattach fdc_ca = {
+ sizeof(struct fdc_softc), fdcprobe, fdcattach
+};
+
+struct cfdriver fdc_cd = {
+ NULL, "fdc", DV_DULL
};
/*
int fdprobe __P((struct device *, void *, void *));
void fdattach __P((struct device *, struct device *, void *));
-struct cfdriver fdcd = {
- NULL, "fd", fdprobe, fdattach, DV_DISK, sizeof(struct fd_softc)
+struct cfattach fd_ca = {
+ sizeof(struct fd_softc), fdprobe, fdattach
+};
+
+struct cfdriver fd_cd = {
+ NULL, "fd", DV_DISK
};
void fdgetdisklabel __P((struct fd_softc *));
at_setup_dmachan(fdc->sc_drq, FDC_MAXIOSIZE);
isa_establish(&fdc->sc_id, &fdc->sc_dev);
#endif
- fdc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, fdcintr,
- fdc, fdc->sc_dev.dv_xname);
+ fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, fdcintr, fdc, fdc->sc_dev.dv_xname);
/*
* The NVRAM info only tells us about the first two disks on the
int s;
/* Valid unit, controller, and request? */
- if (unit >= fdcd.cd_ndevs ||
- (fd = fdcd.cd_devs[unit]) == 0 ||
+ if (unit >= fd_cd.cd_ndevs ||
+ (fd = fd_cd.cd_devs[unit]) == 0 ||
bp->b_blkno < 0 ||
(bp->b_bcount % FDC_BSIZE) != 0) {
bp->b_error = EINVAL;
struct fd_type *type;
unit = FDUNIT(dev);
- if (unit >= fdcd.cd_ndevs)
+ if (unit >= fd_cd.cd_ndevs)
return ENXIO;
- fd = fdcd.cd_devs[unit];
+ fd = fd_cd.cd_devs[unit];
if (fd == 0)
return ENXIO;
type = fd_dev_to_type(fd, dev);
dev_t dev;
int flags;
{
- struct fd_softc *fd = fdcd.cd_devs[FDUNIT(dev)];
+ struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
fd->sc_flags &= ~FD_OPEN;
return 0;
caddr_t addr;
int flag;
{
- struct fd_softc *fd = fdcd.cd_devs[FDUNIT(dev)];
+ struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
struct disklabel buffer;
int error;
-/* $OpenBSD: isa_machdep.c,v 1.11 1996/04/19 05:41:52 mickey Exp $ */
-/* $NetBSD: isa_machdep.c,v 1.11 1996/02/28 01:49:35 cgd Exp $ */
+/* $OpenBSD: isa_machdep.c,v 1.12 1996/04/21 22:16:54 deraadt Exp $ */
+/* $NetBSD: isa_machdep.c,v 1.12 1996/04/11 22:11:32 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles Hannum.
* XXX PRONE TO RACE CONDITIONS, UGLY, 'INTERESTING' INSERTION ALGORITHM.
*/
void *
-isa_intr_establish(irq, type, level, ih_fun, ih_arg, ih_what)
+isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg, ih_what)
+ isa_chipset_tag_t ic;
int irq;
int type;
int level;
* Deregister an interrupt handler.
*/
void
-isa_intr_disestablish(arg)
+isa_intr_disestablish(ic, arg)
+ isa_chipset_tag_t ic;
void *arg;
{
struct intrhand *ih = arg;
intrtype[irq] = IST_NONE;
}
+void
+isa_attach_hook(parent, self, iba)
+ struct device *parent, *self;
+ struct isabus_attach_args *iba;
+{
+
+ /* Nothing to do. */
+}
+
/*
* ISA DMA and bounce buffer management
*/
-/* $NetBSD: isa_machdep.h,v 1.4 1995/05/04 19:39:46 cgd Exp $ */
+/* $NetBSD: isa_machdep.h,v 1.5 1996/04/11 22:10:11 cgd Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* @(#)isa.h 5.7 (Berkeley) 5/9/91
*/
+/*
+ * Various pieces of the i386 port want to include this file without
+ * or in spite of using isavar.h, and should be fixed.
+ */
+
+#ifndef _I386_ISA_MACHDEP_H_ /* XXX */
+#define _I386_ISA_MACHDEP_H_ /* XXX */
+
/*
* XXX THIS FILE IS A MESS. copyright: berkeley's probably.
* contents from isavar.h and isareg.h, mostly the latter.
* copyright from berkeley's isa.h which is now dev/isa/isareg.h.
*/
+/*
+ * Types provided to machine-independent ISA code.
+ */
+typedef void *isa_chipset_tag_t;
+
+struct device; /* XXX */
+struct isabus_attach_args; /* XXX */
+/*
+ * Functions provided to machine-independent ISA code.
+ */
+void isa_attach_hook __P((struct device *, struct device *,
+ struct isabus_attach_args *));
+void *isa_intr_establish __P((isa_chipset_tag_t ic, int irq, int type,
+ int level, int (*ih_fun)(void *), void *ih_arg, char *ih_what));
+void isa_intr_disestablish __P((isa_chipset_tag_t ic, void *handler));
+
+/*
+ * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
+ * BY PORTABLE CODE.
+ */
/*
* XXX Various seemingly PC-specific constants, some of which may be
* unnecessary anyway.
* Miscellanous functions.
*/
void sysbeep __P((int, int)); /* beep with the system speaker */
+
+#endif /* _I386_ISA_MACHDEP_H_ XXX */
+/* $NetBSD: joy.c,v 1.2 1996/04/01 06:39:17 scottr Exp $ */
+
+/*-
+ * Copyright (c) 1995 Jean-Marc Zucconi
+ * All rights reserved.
+ *
+ * Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>
+ *
+ * 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.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+
+#include <machine/cpu.h>
+#include <machine/pio.h>
+#include <machine/cpufunc.h>
+#include <machine/joystick.h>
+
+#include <dev/isa/isavar.h>
+#include <dev/isa/isareg.h>
+#include <i386/isa/timerreg.h>
+
+
+/*
+ * The game port can manage 4 buttons and 4 variable resistors (usually 2
+ * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201.
+ * Getting the state of the buttons is done by reading the game port;
+ * buttons 1-4 correspond to bits 4-7 and resistors 1-4 (X1, Y1, X2, Y2)
+ * to bits 0-3. If button 1 (resp 2, 3, 4) is pressed, the bit 4 (resp 5,
+ * 6, 7) is set to 0 to get the value of a resistor, write the value 0xff
+ * at port and wait until the corresponding bit returns to 0.
+ */
+
+/*
+ * The formulae below only work if u is ``not too large''. See also
+ * the discussion in microtime.s
+ */
+#define USEC2TICKS(u) (((u) * 19549) >> 14)
+#define TICKS2USEC(u) (((u) * 3433) >> 12)
+
+
+#define JOYPART(d) minor(d) & 1
+#define JOYUNIT(d) minor(d) >> 1 & 3
+
+#ifndef JOY_TIMEOUT
+#define JOY_TIMEOUT 2000 /* 2 milliseconds */
+#endif
+
+#define JOY_NPORTS 1
+
+struct joy_softc {
+ struct device sc_dev;
+ int port;
+ int x_off[2], y_off[2];
+ int timeout[2];
+};
+
+int joyprobe __P((struct device *, void *, void *));
+void joyattach __P((struct device *, struct device *, void *));
+int joyopen __P((dev_t, int, int, struct proc *));
+int joyclose __P((dev_t, int, int, struct proc *));
+static int get_tick __P((void));
+
+struct cfattach joy_ca = {
+ sizeof(struct joy_softc), joyprobe, joyattach
+};
+
+struct cfdriver joy_cd = {
+ NULL, "joy", DV_DULL
+};
+
+
+int
+joyprobe(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct isa_attach_args *ia = aux;
+ int iobase = ia->ia_iobase;
+
+#ifdef WANT_JOYSTICK_CONNECTED
+ outb(iobase, 0xff);
+ DELAY(10000); /* 10 ms delay */
+ return (inb(iobase) & 0x0f) != 0x0f;
+#else
+ ia->ia_iosize = JOY_NPORTS;
+ ia->ia_msize = 0;
+ return 1;
+#endif
+}
+
+void
+joyattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct joy_softc *sc = (void *) self;
+ struct isa_attach_args *ia = aux;
+ int unit = sc->sc_dev.dv_unit;
+ int iobase = ia->ia_iobase;
+
+ sc->port = iobase;
+ sc->timeout[0] = sc->timeout[1] = 0;
+ outb(iobase, 0xff);
+ DELAY(10000); /* 10 ms delay */
+ printf(": joystick%sconnected\n",
+ (inb(iobase) & 0x0f) == 0x0f ? " not " : " ");
+}
+
+int
+joyopen(dev, flag, mode, p)
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
+{
+ int unit = JOYUNIT(dev);
+ int i = JOYPART(dev);
+ struct joy_softc *sc;
+
+ if (unit >= joy_cd.cd_ndevs)
+ return (ENXIO);
+
+ sc = joy_cd.cd_devs[unit];
+
+ if (sc->timeout[i])
+ return EBUSY;
+
+ sc->x_off[i] = sc->y_off[i] = 0;
+ sc->timeout[i] = JOY_TIMEOUT;
+ return 0;
+}
+
+int
+joyclose(dev, flag, mode, p)
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
+{
+ int unit = JOYUNIT(dev);
+ int i = JOYPART(dev);
+ struct joy_softc *sc = joy_cd.cd_devs[unit];
+
+ sc->timeout[i] = 0;
+ return 0;
+}
+
+int
+joyread(dev, uio, flag)
+ dev_t dev;
+ struct uio *uio;
+ int flag;
+{
+ int unit = JOYUNIT(dev);
+ struct joy_softc *sc = joy_cd.cd_devs[unit];
+ struct joystick c;
+ int port = sc->port;
+ int i, t0, t1;
+ int state = 0, x = 0, y = 0;
+
+ disable_intr();
+ outb(port, 0xff);
+ t0 = get_tick();
+ t1 = t0;
+ i = USEC2TICKS(sc->timeout[JOYPART(dev)]);
+ while (t0 - t1 < i) {
+ state = inb(port);
+ if (JOYPART(dev) == 1)
+ state >>= 2;
+ t1 = get_tick();
+ if (t1 > t0)
+ t1 -= TIMER_FREQ / hz;
+ if (!x && !(state & 0x01))
+ x = t1;
+ if (!y && !(state & 0x02))
+ y = t1;
+ if (x && y)
+ break;
+ }
+ enable_intr();
+ c.x = x ? sc->x_off[JOYPART(dev)] + TICKS2USEC(t0 - x) : 0x80000000;
+ c.y = y ? sc->y_off[JOYPART(dev)] + TICKS2USEC(t0 - y) : 0x80000000;
+ state >>= 4;
+ c.b1 = ~state & 1;
+ c.b2 = ~(state >> 1) & 1;
+ return uiomove((caddr_t) & c, sizeof(struct joystick), uio);
+}
+
+int
+joyioctl(dev, cmd, data, flag, p)
+ dev_t dev;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+ int unit = JOYUNIT(dev);
+ struct joy_softc *sc = joy_cd.cd_devs[unit];
+ int i = JOYPART(dev);
+ int x;
+
+ switch (cmd) {
+ case JOY_SETTIMEOUT:
+ x = *(int *) data;
+ if (x < 1 || x > 10000) /* 10ms maximum! */
+ return EINVAL;
+ sc->timeout[i] = x;
+ break;
+ case JOY_GETTIMEOUT:
+ *(int *) data = sc->timeout[i];
+ break;
+ case JOY_SET_X_OFFSET:
+ sc->x_off[i] = *(int *) data;
+ break;
+ case JOY_SET_Y_OFFSET:
+ sc->y_off[i] = *(int *) data;
+ break;
+ case JOY_GET_X_OFFSET:
+ *(int *) data = sc->x_off[i];
+ break;
+ case JOY_GET_Y_OFFSET:
+ *(int *) data = sc->y_off[i];
+ break;
+ default:
+ return ENXIO;
+ }
+ return 0;
+}
+
+static int
+get_tick()
+{
+ int low, high;
+
+ outb(TIMER_MODE, TIMER_SEL0);
+ low = inb(TIMER_CNTR0);
+ high = inb(TIMER_CNTR0);
+
+ return (high << 8) | low;
+}
/*-
* Copyright (c) 1995 Jean-Marc Zucconi
* All rights reserved.
-/* $NetBSD: lms.c,v 1.21 1995/12/24 02:30:17 mycroft Exp $ */
+/* $NetBSD: lms.c,v 1.24 1996/04/11 22:15:18 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles Hannum.
#include <sys/device.h>
#include <machine/cpu.h>
-#include <machine/pio.h>
+#include <machine/bus.h>
#include <machine/mouse.h>
#include <dev/isa/isavar.h>
struct device sc_dev;
void *sc_ih;
+ bus_chipset_tag_t sc_bc; /* bus chipset identifier */
+ bus_io_handle_t sc_ioh; /* bus i/o handle */
+
struct clist sc_q;
struct selinfo sc_rsel;
- int sc_iobase; /* I/O port base */
u_char sc_state; /* mouse driver state */
#define LMS_OPEN 0x01 /* device is open */
#define LMS_ASLP 0x02 /* waiting for mouse data */
void lmsattach __P((struct device *, struct device *, void *));
int lmsintr __P((void *));
-struct cfdriver lmscd = {
- NULL, "lms", lmsprobe, lmsattach, DV_TTY, sizeof(struct lms_softc)
+struct cfattach lms_ca = {
+ sizeof(struct lms_softc), lmsprobe, lmsattach
+};
+
+struct cfdriver lms_cd = {
+ NULL, "lms", DV_TTY
};
#define LMSUNIT(dev) (minor(dev))
void *match, *aux;
{
struct isa_attach_args *ia = aux;
- int iobase = ia->ia_iobase;
+ bus_chipset_tag_t bc = ia->ia_bc;
+ bus_io_handle_t ioh;
+ int rv;
+
+ /* Map the i/o space. */
+ if (bus_io_map(bc, ia->ia_iobase, LMS_NPORTS, &ioh))
+ return 0;
+
+ rv = 0;
/* Configure and check for port present. */
- outb(iobase + LMS_CONFIG, 0x91);
+ bus_io_write_1(bc, ioh, LMS_CONFIG, 0x91);
delay(10);
- outb(iobase + LMS_SIGN, 0x0c);
+ bus_io_write_1(bc, ioh, LMS_SIGN, 0x0c);
delay(10);
- if (inb(iobase + LMS_SIGN) != 0x0c)
- return 0;
- outb(iobase + LMS_SIGN, 0x50);
+ if (bus_io_read_1(bc, ioh, LMS_SIGN) != 0x0c)
+ goto out;
+ bus_io_write_1(bc, ioh, LMS_SIGN, 0x50);
delay(10);
- if (inb(iobase + LMS_SIGN) != 0x50)
- return 0;
+ if (bus_io_read_1(bc, ioh, LMS_SIGN) != 0x50)
+ goto out;
/* Disable interrupts. */
- outb(iobase + LMS_CNTRL, 0x10);
+ bus_io_write_1(bc, ioh, LMS_CNTRL, 0x10);
+ rv = 1;
ia->ia_iosize = LMS_NPORTS;
ia->ia_msize = 0;
- return 1;
+
+out:
+ bus_io_unmap(bc, ioh, LMS_NPORTS);
+ return rv;
}
void
printf("\n");
/* Other initialization was done by lmsprobe. */
- sc->sc_iobase = iobase;
- sc->sc_state = 0;
+ sc->sc_bc = ia->ia_bc;
+ if (bus_io_map(sc->sc_bc, ia->ia_iobase, LMS_NPORTS, &sc->sc_ioh))
+ panic("lmsattach: couldn't map I/O ports");
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_PULSE, IPL_TTY, lmsintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
+ IPL_TTY, lmsintr, sc, sc->sc_dev.dv_xname);
}
int
int unit = LMSUNIT(dev);
struct lms_softc *sc;
- if (unit >= lmscd.cd_ndevs)
+ if (unit >= lms_cd.cd_ndevs)
return ENXIO;
- sc = lmscd.cd_devs[unit];
+ sc = lms_cd.cd_devs[unit];
if (!sc)
return ENXIO;
sc->sc_x = sc->sc_y = 0;
/* Enable interrupts. */
- outb(sc->sc_iobase + LMS_CNTRL, 0);
+ bus_io_write_1(sc->sc_bc, sc->sc_ioh, LMS_CNTRL, 0);
return 0;
}
dev_t dev;
int flag;
{
- struct lms_softc *sc = lmscd.cd_devs[LMSUNIT(dev)];
+ struct lms_softc *sc = lms_cd.cd_devs[LMSUNIT(dev)];
/* Disable interrupts. */
- outb(sc->sc_iobase + LMS_CNTRL, 0x10);
+ bus_io_write_1(sc->sc_bc, sc->sc_ioh, LMS_CNTRL, 0x10);
sc->sc_state &= ~LMS_OPEN;
struct uio *uio;
int flag;
{
- struct lms_softc *sc = lmscd.cd_devs[LMSUNIT(dev)];
+ struct lms_softc *sc = lms_cd.cd_devs[LMSUNIT(dev)];
int s;
int error;
size_t length;
caddr_t addr;
int flag;
{
- struct lms_softc *sc = lmscd.cd_devs[LMSUNIT(dev)];
+ struct lms_softc *sc = lms_cd.cd_devs[LMSUNIT(dev)];
struct mouseinfo info;
int s;
int error;
void *arg;
{
struct lms_softc *sc = arg;
- int iobase = sc->sc_iobase;
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
u_char hi, lo, buttons, changed;
char dx, dy;
u_char buffer[5];
/* Interrupts are not expected. */
return 0;
- outb(iobase + LMS_CNTRL, 0xab);
- hi = inb(iobase + LMS_DATA);
- outb(iobase + LMS_CNTRL, 0x90);
- lo = inb(iobase + LMS_DATA);
+ bus_io_write_1(bc, ioh, LMS_CNTRL, 0xab);
+ hi = bus_io_read_1(bc, ioh, LMS_DATA);
+ bus_io_write_1(bc, ioh, LMS_CNTRL, 0x90);
+ lo = bus_io_read_1(bc, ioh, LMS_DATA);
dx = ((hi & 0x0f) << 4) | (lo & 0x0f);
/* Bounding at -127 avoids a bug in XFree86. */
dx = (dx == -128) ? -127 : dx;
- outb(iobase + LMS_CNTRL, 0xf0);
- hi = inb(iobase + LMS_DATA);
- outb(iobase + LMS_CNTRL, 0xd0);
- lo = inb(iobase + LMS_DATA);
+ bus_io_write_1(bc, ioh, LMS_CNTRL, 0xf0);
+ hi = bus_io_read_1(bc, ioh, LMS_DATA);
+ bus_io_write_1(bc, ioh, LMS_CNTRL, 0xd0);
+ lo = bus_io_read_1(bc, ioh, LMS_DATA);
dy = ((hi & 0x0f) << 4) | (lo & 0x0f);
dy = (dy == -128) ? 127 : -dy;
- outb(iobase + LMS_CNTRL, 0);
+ bus_io_write_1(bc, ioh, LMS_CNTRL, 0);
buttons = (~hi >> 5) & 0x07;
changed = ((buttons ^ sc->sc_status) & 0x07) << 3;
int rw;
struct proc *p;
{
- struct lms_softc *sc = lmscd.cd_devs[LMSUNIT(dev)];
+ struct lms_softc *sc = lms_cd.cd_devs[LMSUNIT(dev)];
int s;
int ret;
-/* $NetBSD: mms.c,v 1.20 1995/12/24 02:30:19 mycroft Exp $ */
+/* $NetBSD: mms.c,v 1.22 1996/04/11 22:15:20 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles Hannum.
void mmsattach __P((struct device *, struct device *, void *));
int mmsintr __P((void *));
-struct cfdriver mmscd = {
- NULL, "mms", mmsprobe, mmsattach, DV_TTY, sizeof(struct mms_softc)
+struct cfattach mms_ca = {
+ sizeof(struct mms_softc), mmsprobe, mmsattach
+};
+
+struct cfdriver mms_cd = {
+ NULL, "mms", DV_TTY
};
#define MMSUNIT(dev) (minor(dev))
sc->sc_iobase = iobase;
sc->sc_state = 0;
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_PULSE, IPL_TTY, mmsintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
+ IPL_TTY, mmsintr, sc, sc->sc_dev.dv_xname);
}
int
int unit = MMSUNIT(dev);
struct mms_softc *sc;
- if (unit >= mmscd.cd_ndevs)
+ if (unit >= mms_cd.cd_ndevs)
return ENXIO;
- sc = mmscd.cd_devs[unit];
+ sc = mms_cd.cd_devs[unit];
if (!sc)
return ENXIO;
dev_t dev;
int flag;
{
- struct mms_softc *sc = mmscd.cd_devs[MMSUNIT(dev)];
+ struct mms_softc *sc = mms_cd.cd_devs[MMSUNIT(dev)];
/* Disable interrupts. */
outb(sc->sc_iobase + MMS_ADDR, 0x87);
struct uio *uio;
int flag;
{
- struct mms_softc *sc = mmscd.cd_devs[MMSUNIT(dev)];
+ struct mms_softc *sc = mms_cd.cd_devs[MMSUNIT(dev)];
int s;
int error;
size_t length;
caddr_t addr;
int flag;
{
- struct mms_softc *sc = mmscd.cd_devs[MMSUNIT(dev)];
+ struct mms_softc *sc = mms_cd.cd_devs[MMSUNIT(dev)];
struct mouseinfo info;
int s;
int error;
int rw;
struct proc *p;
{
- struct mms_softc *sc = mmscd.cd_devs[MMSUNIT(dev)];
+ struct mms_softc *sc = mms_cd.cd_devs[MMSUNIT(dev)];
int s;
int ret;
-/* $NetBSD: npx.c,v 1.53 1996/01/07 02:00:31 mycroft Exp $ */
+/* $NetBSD: npx.c,v 1.55 1996/04/11 22:15:22 cgd Exp $ */
#if 0
#define iprintf(x) printf x
int npxprobe __P((struct device *, void *, void *));
void npxattach __P((struct device *, struct device *, void *));
-struct cfdriver npxcd = {
- NULL, "npx", npxprobe, npxattach, DV_DULL, sizeof(struct npx_softc)
+struct cfattach npx_ca = {
+ sizeof(struct npx_softc), npxprobe, npxattach
+};
+
+struct cfdriver npx_cd = {
+ NULL, "npx", DV_DULL
};
enum npx_type {
case NPX_INTERRUPT:
printf("\n");
lcr0(rcr0() & ~CR0_NE);
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NONE,
- npxintr, 0, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
+ IST_EDGE, IPL_NONE, npxintr, 0, sc->sc_dev.dv_xname);
break;
case NPX_EXCEPTION:
printf(": using exception 16\n");
-/* $OpenBSD: pccons.c,v 1.7 1996/04/18 17:12:18 niklas Exp $ */
-/* $NetBSD: pccons.c,v 1.92 1996/03/16 06:08:46 thorpej Exp $ */
+/* $OpenBSD: pccons.c,v 1.8 1996/04/21 22:17:01 deraadt Exp $ */
+/* $NetBSD: pccons.c,v 1.96 1996/04/11 22:15:25 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
void pcattach __P((struct device *, struct device *, void *));
int pcintr __P((void *));
-struct cfdriver pccd = {
- NULL, "pc", pcprobe, pcattach, DV_TTY, sizeof(struct pc_softc)
+struct cfattach pc_ca = {
+ sizeof(struct pc_softc), pcprobe, pcattach
+};
+
+struct cfdriver pc_cd = {
+ NULL, "pc", DV_TTY
};
#define COL 80
char *sget __P((void));
void sput __P((u_char *, int));
+void pc_xmode_on __P((void));
+void pc_xmode_off __P((void));
void pcstart();
int pcparam();
printf(": %s\n", vs.color ? "color" : "mono");
do_async_update(1);
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_TTY, pcintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_TTY, pcintr, sc, sc->sc_dev.dv_xname);
/*
* Look for children of the keyboard controller.
* XXX Really should decouple keyboard controller
* from the console code.
*/
- while (config_found(self, NULL, NULL))
+ while (config_found(self, ia->ia_ic, NULL) != NULL) /* XXX */
/* will break when no more children */ ;
}
int unit = PCUNIT(dev);
struct tty *tp;
- if (unit >= pccd.cd_ndevs)
+ if (unit >= pc_cd.cd_ndevs)
return ENXIO;
- sc = pccd.cd_devs[unit];
+ sc = pc_cd.cd_devs[unit];
if (sc == 0)
return ENXIO;
int flag, mode;
struct proc *p;
{
- struct pc_softc *sc = pccd.cd_devs[PCUNIT(dev)];
+ struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
struct tty *tp = sc->sc_tty;
(*linesw[tp->t_line].l_close)(tp, flag);
struct uio *uio;
int flag;
{
- struct pc_softc *sc = pccd.cd_devs[PCUNIT(dev)];
+ struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
struct uio *uio;
int flag;
{
- struct pc_softc *sc = pccd.cd_devs[PCUNIT(dev)];
+ struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
pctty(dev)
dev_t dev;
{
- struct pc_softc *sc = pccd.cd_devs[PCUNIT(dev)];
+ struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
struct tty *tp = sc->sc_tty;
return (tp);
int flag;
struct proc *p;
{
- struct pc_softc *sc = pccd.cd_devs[PCUNIT(dev)];
+ struct pc_softc *sc = pc_cd.cd_devs[PCUNIT(dev)];
struct tty *tp = sc->sc_tty;
int error;
}
/* ARGSUSED */
+int
pccngetc(dev)
dev_t dev;
{
* interrupts.
*/
unit = PCUNIT(dev);
- if (pccd.cd_ndevs > unit) {
- sc = pccd.cd_devs[unit];
+ if (pc_cd.cd_ndevs > unit) {
+ sc = pc_cd.cd_devs[unit];
if (sc != 0) {
s = spltty();
pcintr(sc);
return i386_btop(0xa0000 + offset);
}
+void
pc_xmode_on()
{
struct trapframe *fp;
#endif
}
+void
pc_xmode_off()
{
struct trapframe *fp;
#---------------------------------------------------------------------------
#
-# sample /etc/ttys file for pcvt driver and pcvt25h terminal emulation
+# sample /etc/ttys file for pcvt driver and pcvt25 terminal emulation
#
# last edit-date: [Sun Feb 26 12:30:09 1995]
#
#
# name getty type status comments
#
-console "/usr/libexec/getty Pcvt" pcvt25h off secure
+console "/usr/libexec/getty Pcvt" pcvt25 off secure
#
# the following lines are for the pcvt driver
#
-ttyv0 "/usr/libexec/getty Pcvt" pcvt25h on secure
-ttyv1 "/usr/libexec/getty Pcvt" pcvt25h on secure
-ttyv2 "/usr/libexec/getty Pcvt" pcvt25h on secure
-ttyv3 "/usr/libexec/getty Pcvt" pcvt25h on secure
-ttyv4 "/usr/libexec/getty Pcvt" pcvt25h on secure
-ttyv5 "/usr/libexec/getty Pcvt" pcvt25h on secure
-ttyv6 "/usr/libexec/getty Pcvt" pcvt25h off secure # X11 :1
-ttyv7 "/usr/libexec/getty Pcvt" pcvt25h off secure # X11 :0
+ttyv0 "/usr/libexec/getty Pcvt" pcvt25 on secure
+ttyv1 "/usr/libexec/getty Pcvt" pcvt25 on secure
+ttyv2 "/usr/libexec/getty Pcvt" pcvt25 on secure
+ttyv3 "/usr/libexec/getty Pcvt" pcvt25 on secure
+ttyv4 "/usr/libexec/getty Pcvt" pcvt25 on secure
+ttyv5 "/usr/libexec/getty Pcvt" pcvt25 on secure
+ttyv6 "/usr/libexec/getty Pcvt" pcvt25 off secure # X11 :1
+ttyv7 "/usr/libexec/getty Pcvt" pcvt25 off secure # X11 :0
#
# Hardwired lines are marked off, by default, so getty(8)
# is quiet when they don't exist.
fprintf(stderr,"Operating System = %s\t", p);
fprintf(stderr,"OS Release Id = %u\n", pcvtinfo.opsysrel);
fprintf(stderr,"PCVT_NSCREENS = %u\t\t", pcvtinfo.nscreens);
- fprintf(stderr,"PCVT_UPDATEFAST = %u\n", pcvtinfo.updatefast);
- fprintf(stderr,"PCVT_UPDATESLOW = %u\t\t", pcvtinfo.updateslow);
fprintf(stderr,"PCVT_SYSBEEPF = %u\n", pcvtinfo.sysbeepf);
fprintf(stderr,"PCVT_PCBURST = %u\t\t", pcvtinfo.pcburst);
fprintf(stderr,"PCVT_KBD_FIFO_SZ = %u\n\n", pcvtinfo.kbd_fifo_sz);
{
fprintf(stderr,"BSD Version = %u\n", pcvtinfo.opsys);
fprintf(stderr,"PCVT_NSCREENS = %u\n", pcvtinfo.nscreens);
- fprintf(stderr,"PCVT_UPDATEFAST = %u\n", pcvtinfo.updatefast);
- fprintf(stderr,"PCVT_UPDATESLOW = %u\n", pcvtinfo.updateslow);
fprintf(stderr,"PCVT_SYSBEEPF = %u\n", pcvtinfo.sysbeepf);
fprintf(stderr,"Compile options = 0x%08X\n", pcvtinfo.compile_opts);
}
LFLAGS+= -I
LDADD= -lm -ly -ll
+DPADD= ${LIBM} ${LIBY} ${LIBL}
NOMAN=
NOSHARED= no shared linkage
u_int opsysrel; /* Release for NetBSD/FreeBSD */
u_int nscreens; /* PCVT_NSCREENS */
u_int scanset; /* PCVT_SCANSET */
- u_int updatefast; /* PCVT_UPDATEFAST */
- u_int updateslow; /* PCVT_UPDATESLOW */
u_int sysbeepf; /* PCVT_SYSBEEPF */
/* config booleans */
LFLAGS+= -I
LDADD= -lm -ly -ll
+DPADD= ${LIBM} ${LIBY} ${LIBL}
CFLAGS+= -I ${.CURDIR}/obj -I ${.CURDIR} -g
-/* $OpenBSD: pcvt_drv.c,v 1.9 1996/04/18 17:48:28 niklas Exp $ */
+/* $OpenBSD: pcvt_drv.c,v 1.10 1996/04/21 22:17:07 deraadt Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
#if PCVT_NETBSD > 9
#if PCVT_NETBSD > 101
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_TTY, pcintr,
- (void *)0, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_TTY, pcintr, (void *)0, sc->sc_dev.dv_xname);
#if PCVT_NETBSD > 110
/*
* XXX Really should decouple keyboard controller
* from the console code.
*/
- while (config_found(self, NULL, NULL))
+ while (config_found(self, ia->ia_ic, NULL) != NULL)
/* will break when no more children */ ;
-#endif /* PVCT_NETBSD > 110 */
+#endif /* PCVT_NETBSD > 110 */
#else /* PCVT_NETBSD > 100 */
vthand.ih_fun = pcrint;
vthand.ih_arg = 0;
void
pccnpollc(Dev_t dev, int on)
{
+#if PCVT_NETBSD > 110
+ struct vt_softc *sc = NULL; /* XXX not used */
+#else
#if PCVT_NETBSD > 101
struct vt_softc *sc = vtcd.cd_devs[0]; /* XXX */
+#endif
#endif
kbd_polling = on;
-/* $OpenBSD: pcvt_hdr.h,v 1.6 1996/04/18 17:48:31 niklas Exp $ */
+/* $OpenBSD: pcvt_hdr.h,v 1.7 1996/04/21 22:17:09 deraadt Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
int pcprobe ();
void pcattach ();
+#if PCVT_NETBSD > 110
+struct cfattach vt_ca = {
+ sizeof(struct vt_softc), pcprobe, pcattach
+};
+
+struct cfdriver vt_cd = {
+ NULL, "vt", DV_TTY
+};
+#else /* !PCVT_NETBSD > 110 */
#if PCVT_NETBSD > 101
struct cfdriver vtcd = {
NULL, "vt", pcprobe, pcattach, DV_TTY, sizeof(struct vt_softc)
NULL, "vt", pcprobe, pcattach, DV_TTY, sizeof(struct device)
};
#endif /* PCVT_NETBSD > 101 */
+#endif /* PCVT_NETBSD > 110 */
#else /* !PCVT_NETBSD > 9 */
-/* $OpenBSD: pms.c,v 1.6 1996/04/18 17:12:20 niklas Exp $ */
-/* $NetBSD: pms.c,v 1.25 1996/03/16 06:08:50 thorpej Exp $ */
+/* $OpenBSD: pms.c,v 1.7 1996/04/21 22:17:02 deraadt Exp $ */
+/* $NetBSD: pms.c,v 1.27 1996/04/11 22:15:27 cgd Exp $ */
/*-
* Copyright (c) 1994 Charles Hannum.
void pmsattach __P((struct device *, struct device *, void *));
int pmsintr __P((void *));
-struct cfdriver pmscd = {
- NULL, "pms", pmsprobe, pmsattach, DV_TTY, sizeof(struct pms_softc)
+struct cfattach pms_ca = {
+ sizeof(struct pms_softc), pmsprobe, pmsattach,
+};
+
+struct cfdriver pms_cd = {
+ NULL, "pms", DV_TTY
};
#define PMSUNIT(dev) (minor(dev))
{
struct pms_softc *sc = (void *)self;
int irq = self->dv_cfdata->cf_loc[0];
+ isa_chipset_tag_t ic = aux; /* XXX */
printf(" irq %d\n", irq);
/* Other initialization was done by pmsprobe. */
sc->sc_state = 0;
- sc->sc_ih = isa_intr_establish(irq, IST_EDGE, IPL_TTY, pmsintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ic, irq, IST_EDGE, IPL_TTY,
+ pmsintr, sc, sc->sc_dev.dv_xname);
}
int
int unit = PMSUNIT(dev);
struct pms_softc *sc;
- if (unit >= pmscd.cd_ndevs)
+ if (unit >= pms_cd.cd_ndevs)
return ENXIO;
- sc = pmscd.cd_devs[unit];
+ sc = pms_cd.cd_devs[unit];
if (!sc)
return ENXIO;
dev_t dev;
int flag;
{
- struct pms_softc *sc = pmscd.cd_devs[PMSUNIT(dev)];
+ struct pms_softc *sc = pms_cd.cd_devs[PMSUNIT(dev)];
/* Disable interrupts. */
pms_dev_cmd(PMS_DEV_DISABLE);
struct uio *uio;
int flag;
{
- struct pms_softc *sc = pmscd.cd_devs[PMSUNIT(dev)];
+ struct pms_softc *sc = pms_cd.cd_devs[PMSUNIT(dev)];
int s;
int error;
size_t length;
caddr_t addr;
int flag;
{
- struct pms_softc *sc = pmscd.cd_devs[PMSUNIT(dev)];
+ struct pms_softc *sc = pms_cd.cd_devs[PMSUNIT(dev)];
struct mouseinfo info;
int s;
int error;
int rw;
struct proc *p;
{
- struct pms_softc *sc = pmscd.cd_devs[PMSUNIT(dev)];
+ struct pms_softc *sc = pms_cd.cd_devs[PMSUNIT(dev)];
int s;
int ret;
+/* $OpenBSD: spkr.c,v 1.6 1996/04/21 22:17:04 deraadt Exp $ */
/* $NetBSD: spkr.c,v 1.22 1996/03/18 01:26:12 jtk Exp $ */
/*
struct device sc_dev;
};
-struct cfdriver spkrcd = {
- NULL, "spkr", spkrprobe, spkrattach, DV_TTY, sizeof(struct spkr_softc)
+struct cfattach spkr_ca = {
+ sizeof(struct spkr_softc), spkrprobe, spkrattach
+};
+
+struct cfdriver spkr_cd = {
+ NULL, "spkr", DV_TTY
};
/**************** MACHINE DEPENDENT PART STARTS HERE *************************
if (cf->cf_loc[1] != PITAUX_PORT)
return (0);
+ ia->ia_iosize = 1;
return (1);
}
dev, uio->uio_resid);
#endif /* DEBUG */
- if (minor(dev) != 0)
+ if (minor(dev) != 0 || !spkr_attached)
return(ENXIO);
else
{
--- /dev/null
+/* $NetBSD: pci_compat.c,v 1.1 1996/03/27 04:01:13 cgd Exp $ */
+
+/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
+ * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Charles Hannum.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Compatibility functions, for use with old NetBSD/i386 PCI code.
+ *
+ * These should go away when all drivers are converted to the new
+ * interfaces.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <vm/vm.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+
+__warn_references(pci_map_int,
+ "uses pci_map_int() compatibility interface");
+
+void *
+pci_map_int(tag, level, func, arg)
+ pcitag_t tag;
+ int level;
+ int (*func) __P((void *));
+ void *arg;
+{
+ pci_intr_handle_t ih;
+ pcireg_t data;
+ int pin, line;
+ const char *intrstr;
+ void *rv;
+
+ data = pci_conf_read(NULL, tag, PCI_INTERRUPT_REG);
+
+ pin = PCI_INTERRUPT_PIN(data);
+ line = PCI_INTERRUPT_LINE(data);
+
+ if (pci_intr_map(NULL, tag, pin, line, &ih))
+ return NULL;
+ intrstr = pci_intr_string(NULL, ih);
+ rv = pci_intr_establish(NULL, ih, level, func, arg, NULL);
+ if (rv == NULL)
+ printf("pci_map_int: failed to map interrupt\n");
+ else if (intrstr != NULL)
+ printf("pci_map_int: interrupting at %s\n", intrstr);
+ return (rv);
+}
+
+__warn_references(pci_map_io,
+ "uses pci_map_io() compatibility interface");
+
+int
+pci_map_io(tag, reg, iobasep)
+ pcitag_t tag;
+ int reg;
+ int *iobasep;
+{
+ bus_io_addr_t ioaddr;
+ bus_io_size_t iosize;
+ bus_io_handle_t ioh;
+
+ if (pci_io_find(NULL, tag, reg, &ioaddr, &iosize))
+ return (1);
+ if (bus_io_map(NULL, ioaddr, iosize, &ioh))
+ return (1);
+
+ *iobasep = ioh;
+
+ return 0;
+}
+
+__warn_references(pci_map_mem,
+ "uses pci_map_mem() compatibility interface");
+
+int
+pci_map_mem(tag, reg, vap, pap)
+ pcitag_t tag;
+ int reg;
+ vm_offset_t *vap, *pap;
+{
+ bus_mem_addr_t memaddr;
+ bus_mem_size_t memsize;
+ bus_mem_handle_t memh;
+ int cacheable;
+
+ if (pci_mem_find(NULL, tag, reg, &memaddr, &memsize, &cacheable))
+ return (1);
+ if (bus_mem_map(NULL, memaddr, memsize, cacheable, &memh))
+ return (1);
+
+ *vap = (vm_offset_t)memh;
+ *pap = memaddr;
+
+ return 0;
+}
-/* $NetBSD: pci_machdep.c,v 1.20 1996/03/04 19:39:31 cgd Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.23 1996/04/11 22:15:33 cgd Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
* Copyright (c) 1994 Charles Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#define PCI_MODE2_ENABLE_REG 0x0cf8
#define PCI_MODE2_FORWARD_REG 0x0cfa
+void
+pci_attach_hook(parent, self, pba)
+ struct device *parent, *self;
+ struct pcibus_attach_args *pba;
+{
+
+ if (pba->pba_bus == 0)
+ printf(": configuration mode %d", pci_mode);
+}
+
+int
+pci_bus_maxdevs(pc, busno)
+ pci_chipset_tag_t pc;
+ int busno;
+{
+
+ /*
+ * Bus number is irrelevant. If Configuration Mechanism 2 is in
+ * use, can only have devices 0-15 on any bus. If Configuration
+ * Mechanism 1 is in use, can have devices 0-32 (i.e. the `normal'
+ * range).
+ */
+ if (pci_mode == 2)
+ return (16);
+ else
+ return (32);
+}
+
pcitag_t
-pci_make_tag(bus, device, function)
+pci_make_tag(pc, bus, device, function)
+ pci_chipset_tag_t pc;
int bus, device, function;
{
pcitag_t tag;
}
pcireg_t
-pci_conf_read(tag, reg)
+pci_conf_read(pc, tag, reg)
+ pci_chipset_tag_t pc;
pcitag_t tag;
int reg;
{
}
void
-pci_conf_write(tag, reg, data)
+pci_conf_write(pc, tag, reg, data)
+ pci_chipset_tag_t pc;
pcitag_t tag;
int reg;
pcireg_t data;
}
int
-pci_map_io(tag, reg, iobasep)
- pcitag_t tag;
- int reg;
- int *iobasep;
-{
- pcireg_t address;
- int iobase;
-
- if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
- panic("pci_map_io: bad request");
-
- address = pci_conf_read(tag, reg);
-
- if (PCI_MAPREG_TYPE(address) != PCI_MAPREG_TYPE_IO)
- panic("pci_map_io: not an I/O mapping register");
-
- iobase = PCI_MAPREG_IO_ADDR(address);
- *iobasep = iobase;
-
- return 0;
-}
-
-int
-pci_map_mem(tag, reg, vap, pap)
- pcitag_t tag;
- int reg;
- vm_offset_t *vap, *pap;
-{
- pcireg_t address, mask;
- int cachable;
- vm_size_t size;
- vm_offset_t va, pa;
-
- if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
- panic("pci_map_mem: bad request");
-
- /*
- * Section 6.2.5.1, `Address Maps', tells us that:
- *
- * 1) The builtin software should have already mapped the device in a
- * reasonable way.
- *
- * 2) A device which wants 2^n bytes of memory will hardwire the bottom
- * n bits of the address to 0. As recommended, we write all 1s and see
- * what we get back.
- */
- address = pci_conf_read(tag, reg);
- pci_conf_write(tag, reg, 0xffffffff);
- mask = pci_conf_read(tag, reg);
- pci_conf_write(tag, reg, address);
-
- if (PCI_MAPREG_TYPE(address) == PCI_MAPREG_TYPE_IO)
- panic("pci_map_mem: I/O mapping register");
-
- switch (address & PCI_MAPREG_MEM_TYPE_MASK) {
- case PCI_MAPREG_MEM_TYPE_32BIT:
- case PCI_MAPREG_MEM_TYPE_32BIT_1M:
- break;
- case PCI_MAPREG_MEM_TYPE_64BIT:
- printf("pci_map_mem: 64-bit memory mapping register\n");
- return EOPNOTSUPP;
- default:
- printf("pci_map_mem: reserved mapping register type\n");
- return EINVAL;
- }
-
- pa = PCI_MAPREG_MEM_ADDR(address);
- size = ~PCI_MAPREG_MEM_ADDR(mask) + 1;
- if (size < NBPG)
- size = NBPG;
-
- va = kmem_alloc_pageable(kernel_map, size);
- if (va == 0) {
- printf("pci_map_mem: not enough memory\n");
- return ENOMEM;
- }
-
- /*
- * Tell the driver where we mapped it.
- *
- * If the region is smaller than one page, adjust the virtual address
- * to the same page offset as the physical address.
- */
- *vap = va + (pa & PGOFSET);
- *pap = pa;
-
-#if 1
- printf("pci_map_mem: mapping memory at virtual %08x, physical %08x\n", *vap, *pap);
-#endif
-
- /* Map the space into the kernel page table. */
- cachable = PCI_MAPREG_MEM_CACHEABLE(address);
- pa &= ~PGOFSET;
- while (size) {
- pmap_enter(pmap_kernel(), va, pa, VM_PROT_READ | VM_PROT_WRITE,
- TRUE);
- if (!cachable)
- pmap_changebit(pa, PG_N, ~0);
- else
- pmap_changebit(pa, 0, ~PG_N);
- va += NBPG;
- pa += NBPG;
- size -= NBPG;
- }
-
- return 0;
-}
-
-void *
-pci_map_int(tag, level, func, arg, what)
- pcitag_t tag;
- int level;
- int (*func) __P((void *));
- void *arg;
- char *what;
-{
- pcireg_t data;
+pci_intr_map(pc, intrtag, pin, line, ihp)
+ pci_chipset_tag_t pc;
+ pcitag_t intrtag;
int pin, line;
-
- data = pci_conf_read(tag, PCI_INTERRUPT_REG);
-
- pin = PCI_INTERRUPT_PIN(data);
- line = PCI_INTERRUPT_LINE(data);
+ pci_intr_handle_t *ihp;
+{
if (pin == 0) {
/* No IRQ used. */
- return 0;
+ goto bad;
}
if (pin > 4) {
- printf("pci_map_int: bad interrupt pin %d\n", pin);
- return NULL;
+ printf("pci_intr_map: bad interrupt pin %d\n", pin);
+ goto bad;
}
/*
* the BIOS has not configured the device.
*/
if (line == 0 || line == 255) {
- printf("pci_map_int: no mapping for pin %c\n", '@' + pin);
- return NULL;
+ printf("pci_intr_map: no mapping for pin %c\n", '@' + pin);
+ goto bad;
} else {
if (line >= ICU_LEN) {
- printf("pci_map_int: bad interrupt line %d\n", line);
- return NULL;
+ printf("pci_intr_map: bad interrupt line %d\n", line);
+ goto bad;
}
if (line == 2) {
- printf("pci_map_int: changed line 2 to line 9\n");
+ printf("pci_intr_map: changed line 2 to line 9\n");
line = 9;
}
}
-#if 1
- printf("pci_map_int: pin %c mapped to line %d\n", '@' + pin, line);
-#endif
+ *ihp = line;
+ return 0;
+
+bad:
+ *ihp = -1;
+ return 1;
+}
+
+const char *
+pci_intr_string(pc, ih)
+ pci_chipset_tag_t pc;
+ pci_intr_handle_t ih;
+{
+ static char irqstr[8]; /* 4 + 2 + NULL + sanity */
+
+ if (ih == 0 || ih >= ICU_LEN || ih == 2)
+ panic("pci_intr_string: bogus handle 0x%x\n", ih);
+
+ sprintf(irqstr, "irq %d", ih);
+ return (irqstr);
+
+}
+
+void *
+pci_intr_establish(pc, ih, level, func, arg, what)
+ pci_chipset_tag_t pc;
+ pci_intr_handle_t ih;
+ int level, (*func) __P((void *));
+ void *arg;
+ char *what;
+{
+
+ if (ih == 0 || ih >= ICU_LEN || ih == 2)
+ panic("pci_intr_establish: bogus handle 0x%x\n", ih);
+
+ return isa_intr_establish(NULL, ih, IST_LEVEL, level, func, arg, what);
+}
+
+void
+pci_intr_disestablish(pc, cookie)
+ pci_chipset_tag_t pc;
+ void *cookie;
+{
- return isa_intr_establish(line, IST_LEVEL, level, func, arg, what);
+ return isa_intr_disestablish(NULL, cookie);
}
-/* $OpenBSD: pci_machdep.h,v 1.2 1996/04/18 19:22:23 niklas Exp $ */
-/* $NetBSD: pci_machdep.h,v 1.4 1996/03/14 02:37:59 cgd Exp $ */
+/* $OpenBSD: pci_machdep.h,v 1.3 1996/04/21 22:17:34 deraadt Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.5 1996/03/27 04:01:16 cgd Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
* Copyright (c) 1994 Charles Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
* Machine-specific definitions for PCI autoconfiguration.
- *
- * See the comments in pci_machdep.c for more explanation.
*/
/*
+ * i386-specific PCI structure and type definitions.
+ * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
+ *
* Configuration tag; created from a {bus,device,function} triplet by
* pci_make_tag(), and passed to pci_conf_read() and pci_conf_write().
* We could instead always pass the {bus,device,function} triplet to
* the read and write routines, but this would cause extra overhead.
*
- * Machines other than PCs are likely to use the equivalent of mode 1
- * tags always. Mode 2 is historical and deprecated by the Revision
- * 2.0 specification.
+ * Mode 2 is historical and deprecated by the Revision 2.0 specification.
*/
-typedef union {
- u_long mode1;
+union i386_pci_tag_u {
+ u_int32_t mode1;
struct {
- u_short port;
- u_char enable;
- u_char forward;
+ u_int16_t port;
+ u_int8_t enable;
+ u_int8_t forward;
} mode2;
-} pcitag_t;
+};
/*
- * Type of a value read from or written to a configuration register.
- * Always 32 bits.
+ * Types provided to machine-independent PCI code
*/
-typedef u_int32_t pcireg_t;
+typedef void *pci_chipset_tag_t;
+typedef union i386_pci_tag_u pcitag_t;
+typedef int pci_intr_handle_t;
/*
- * PCs which use Configuration Mechanism #2 are limited to 16
- * devices per bus.
+ * i386-specific PCI variables and functions.
+ * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
*/
-#define PCI_MAX_DEVICE_NUMBER (pci_mode == 2 ? 16 : 32)
+extern int pci_mode;
+int pci_mode_detect __P((void));
/*
- * Hook for PCI bus attach function to do any necessary machine-specific
- * operations.
+ * Functions provided to machine-independent PCI code.
*/
-
-#define pci_md_attach_hook(parent, sc, pba) \
- do { \
- if (pba->pba_bus == 0) \
- printf(": configuration mode %d", pci_mode); \
- } while (0);
+void pci_attach_hook __P((struct device *, struct device *,
+ struct pcibus_attach_args *));
+int pci_bus_maxdevs __P((pci_chipset_tag_t, int));
+pcitag_t pci_make_tag __P((pci_chipset_tag_t, int, int, int));
+pcireg_t pci_conf_read __P((pci_chipset_tag_t, pcitag_t, int));
+void pci_conf_write __P((pci_chipset_tag_t, pcitag_t, int,
+ pcireg_t));
+int pci_intr_map __P((pci_chipset_tag_t, pcitag_t, int, int,
+ pci_intr_handle_t *));
+const char *pci_intr_string __P((pci_chipset_tag_t, pci_intr_handle_t));
+void *pci_intr_establish __P((pci_chipset_tag_t, pci_intr_handle_t,
+ int, int (*)(void *), void *, char *));
+void pci_intr_disestablish __P((pci_chipset_tag_t, void *));
/*
- * Miscellaneous variables and functions.
+ * Compatibility functions, to map the old i386 PCI functions to the new ones.
+ * NOT TO BE USED BY NEW CODE.
*/
-extern int pci_mode;
-extern int pci_mode_detect __P((void));
+void *pci_map_int __P((pcitag_t, int, int (*)(void *), void *));
+int pci_map_io __P((pcitag_t, int, int *));
+int pci_map_mem __P((pcitag_t, int, vm_offset_t *, vm_offset_t *));
-/* $NetBSD: endian.h,v 1.6 1994/10/26 07:50:45 cgd Exp $ */
+/* $OpenBSD: endian.h,v 1.2 1996/04/21 22:17:40 deraadt Exp $ */
+/* $NetBSD: endian.h,v 1.7 1996/03/29 01:40:31 briggs Exp $ */
/*
* Copyright (c) 1987, 1991 Regents of the University of California.
#define htonl(x) (x)
#define htons(x) (x)
-#define NTOHL(x) (x)
-#define NTOHS(x) (x)
-#define HTONL(x) (x)
-#define HTONS(x) (x)
+#define NTOHL(x) (void) (x)
+#define NTOHS(x) (void) (x)
+#define HTONL(x) (void) (x)
+#define HTONS(x) (void) (x)
#else
-/* $NetBSD: db_disasm.c,v 1.12 1994/11/14 20:53:52 gwr Exp $ */
+/* $OpenBSD: db_disasm.c,v 1.2 1996/04/21 22:17:44 deraadt Exp $ */
+/* $NetBSD: db_disasm.c,v 1.13 1996/04/01 01:38:01 briggs Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
#include <machine/db_machdep.h>
#include <ddb/db_sym.h>
+#include <ddb/db_output.h>
#include <m68k/m68k/db_disasm.h>
void get_modregstr __P((dis_buffer_t *, int, int, int, int));
u_short opc;
dis_func_t *func;
dis_buffer_t dbuf;
- char *symname = NULL;
- db_expr_t diff;
- db_sym_t sym;
- struct nlist *nl;
dbuf.casm = dbuf.dasm = asm_buffer;
dbuf.cinfo = dbuf.info = info_buffer;
{
char *tmp;
int sz;
- u_short ext;
tmp = NULL;
u_short opc;
{
u_short ext;
- int sz, type, opmode;
+ int type, opmode;
type = BITFIELD(opc,8,6);
switch (type) {
u_short opc, ext;
{
int sz;
-
+
if (BITFIELD(ext,15,13) == 3) {
/* fmove r ==> m */
addstr(dbuf, "fmov");
u_short opc;
{
u_short ext;
- int sz, type, opmode;
+ int type;
type = BITFIELD(opc,8,6);
switch (type) {
dis_buffer_t *dbuf;
u_short opc;
{
- u_short ext;
- int sz, type;
-
if (ISBITSET(opc, 6)) {
addstr(dbuf, "ptest");
if (ISBITSET(opc, 5))
dis_buffer_t *dbuf;
const char *s;
{
- while (*dbuf->casm++ = *s++)
+ while ((*dbuf->casm++ = *s++))
;
dbuf->casm--;
}
dis_buffer_t *dbuf;
const char *s;
{
- while (*dbuf->cinfo++ = *s++)
+ while ((*dbuf->cinfo++ = *s++))
;
dbuf->cinfo--;
}
*++p = "0123456789abcdef"[val % base];
} while (val /= base);
- while (ch = *p--)
+ while ((ch = *p--))
addchar(ch);
*dbuf->casm = 0;
*++p = "0123456789abcdef"[val % base];
} while (val /= base);
- while (ch = *p--)
+ while ((ch = *p--))
iaddchar(ch);
*dbuf->cinfo = 0;
-/* $NetBSD: db_disasm.h,v 1.3 1994/10/26 07:51:05 cgd Exp $ */
+/* $OpenBSD: db_disasm.h,v 1.2 1996/04/21 22:17:47 deraadt Exp $ */
+/* $NetBSD: db_disasm.h,v 1.4 1996/04/01 01:38:12 briggs Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
#define PRINT_DREG(dbuf, reg) addstr(dbuf, dregs[reg])
#define PRINT_AREG(dbuf, reg) addstr(dbuf, aregs[reg])
+vm_offset_t db_disasm __P((vm_offset_t loc, boolean_t moto_syntax));
+void get_modregstr_moto __P((dis_buffer_t *dbuf, int bit, int mod, int sz, int dd));
+void get_modregstr_mit __P((dis_buffer_t *dbuf, int bit, int mod, int sz, int dd));
+u_long get_areg_val __P((int reg));
-/* $OpenBSD: db_interface.c,v 1.3 1996/04/19 06:18:15 niklas Exp $ */
-/* $NetBSD: db_interface.c,v 1.18 1996/02/22 23:23:23 gwr Exp $ */
+/* $OpenBSD: db_interface.c,v 1.4 1996/04/21 22:17:49 deraadt Exp $ */
+/* $NetBSD: db_interface.c,v 1.19 1996/03/16 18:45:44 mhitch Exp $ */
/*
* Mach Operating System
printf(" trap\n");
}
-int
+void
Debugger()
{
asm ("trap #15");
-/* $NetBSD: ns_cksum.c,v 1.4 1994/10/26 07:51:12 cgd Exp $ */
+/* $OpenBSD: ns_cksum.c,v 1.2 1996/04/21 22:17:51 deraadt Exp $ */
+/* $NetBSD: ns_cksum.c,v 1.5 1996/04/01 01:38:15 briggs Exp $ */
/*
* Copyright (c) 1982, 1988 Regents of the University of California.
#include <sys/param.h>
#include <sys/mbuf.h>
+#include <netns/ns_var.h>
/*
* Checksum routine for Network Systems Protocol Packets (Big-Endian).
-# $NetBSD: files.svr4,v 1.5 1995/10/14 20:24:17 christos Exp $
+# $OpenBSD: files.svr4,v 1.3 1996/04/21 22:18:17 deraadt Exp $
+# $NetBSD: files.svr4,v 1.6 1996/04/11 12:43:29 christos Exp $
#
# Config.new file description for machine-independent SVR4 compat code.
# Included by ports that need it.
file compat/svr4/svr4_net.c compat_svr4
file compat/svr4/svr4_termios.c compat_svr4
file compat/svr4/svr4_stream.c compat_svr4
+file compat/svr4/svr4_socket.c compat_svr4
file compat/svr4/svr4_ttold.c compat_svr4
file compat/svr4/svr4_filio.c compat_svr4
file compat/svr4/svr4_sockio.c compat_svr4
-/* $OpenBSD: svr4_conf.h,v 1.1 1996/04/18 21:21:26 niklas Exp $ */
-/* $NetBSD: svr4_conf.h,v 1.1 1996/03/14 19:29:11 christos Exp $ */
-
-/*
- * Copyright (c) 1995 Christos Zoulas. 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 Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/conf.h>
-
-#ifdef COMPAT_SVR4
-# define NSVR4_NET 1
-#else
-# define NSVR4_NET 0
-#endif
-
-cdev_decl(svr4_net);
-/* $NetBSD: svr4_filio.c,v 1.4 1996/03/30 22:37:52 christos Exp $ */
+/* $OpenBSD: svr4_filio.c,v 1.3 1996/04/21 22:18:19 deraadt Exp $ */
+/* $NetBSD: svr4_filio.c,v 1.5 1996/04/11 12:54:40 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
int
-svr4_filioctl(fp, cmd, data, p, retval)
+svr4_fil_ioctl(fp, p, retval, fd, cmd, data)
struct file *fp;
- u_long cmd;
- caddr_t data;
struct proc *p;
register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t data;
{
- struct filedesc *fdp = p->p_fd;
int error;
- int fd;
int num;
+ struct filedesc *fdp = p->p_fd;
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
fp->f_ops->fo_ioctl;
switch (cmd) {
case SVR4_FIOCLEX:
- fd = fp - fdp->fd_ofiles[0];
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
return 0;
case SVR4_FIONCLEX:
- fd = fp - fdp->fd_ofiles[0];
fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
return 0;
-/* $OpenBSD: svr4_ioctl.c,v 1.4 1996/04/17 05:24:17 mickey Exp $ */
-/* $NetBSD: svr4_ioctl.c,v 1.15 1996/03/30 22:37:57 christos Exp $ */
+/* $OpenBSD: svr4_ioctl.c,v 1.5 1996/04/21 22:18:20 deraadt Exp $ */
+/* $NetBSD: svr4_ioctl.c,v 1.16 1996/04/11 12:54:41 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
struct file *fp;
struct filedesc *fdp;
u_long cmd;
+ int (*fun) __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
#ifdef DEBUG_SVR4
char dir[4];
char c;
return EBADF;
switch (cmd & 0xff00) {
- case SVR4_tIOC:
- return svr4_ttoldioctl(fp, cmd, SCARG(uap, data), p, retval);
+ case SVR4_tIOC:
+ fun = svr4_ttold_ioctl;
+ break;
case SVR4_TIOC:
- return svr4_termioctl(fp, cmd, SCARG(uap, data), p, retval);
+ fun = svr4_term_ioctl;
+ break;
case SVR4_STR:
- return svr4_streamioctl(fp, cmd, SCARG(uap, data), p, retval);
+ fun = svr4_stream_ioctl;
+ break;
case SVR4_FIOC:
- return svr4_filioctl(fp, cmd, SCARG(uap, data), p, retval);
+ fun = svr4_fil_ioctl;
+ break;
case SVR4_SIOC:
- return svr4_sockioctl(fp, cmd, SCARG(uap, data), p, retval);
+ fun = svr4_sock_ioctl;
+ break;
default:
DPRINTF(("Unimplemented ioctl %lx\n", cmd));
return 0; /* XXX: really ENOSYS */
}
+ return (*fun)(fp, p, retval, SCARG(uap, fd), cmd, SCARG(uap, data));
}
-/* $NetBSD: svr4_ioctl.h,v 1.4 1995/10/07 06:27:42 mycroft Exp $ */
+/* $OpenBSD: svr4_ioctl.h,v 1.2 1996/04/21 22:18:22 deraadt Exp $ */
+/* $NetBSD: svr4_ioctl.h,v 1.5 1996/04/11 12:54:43 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t))
#define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t))
-int svr4_streamioctl __P((struct file *fp, u_long cmd, caddr_t data,
- struct proc *p, register_t *retval));
-int svr4_termioctl __P((struct file *fp, u_long cmd, caddr_t data,
- struct proc *p, register_t *retval));
-int svr4_ttoldioctl __P((struct file *fp, u_long cmd, caddr_t data,
- struct proc *p, register_t *retval));
-int svr4_filioctl __P((struct file *fp, u_long cmd, caddr_t data,
- struct proc *p, register_t *retval));
-int svr4_sockioctl __P((struct file *fp, u_long cmd, caddr_t data,
- struct proc *p, register_t *retval));
+int svr4_stream_ti_ioctl __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
+int svr4_stream_ioctl __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
+int svr4_term_ioctl __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
+int svr4_ttold_ioctl __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
+int svr4_fil_ioctl __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
+int svr4_sock_ioctl __P((struct file *, struct proc *, register_t *,
+ int, u_long, caddr_t));
#endif /* !_SVR4_IOCTL_H_ */
-/* $OpenBSD: svr4_net.c,v 1.5 1996/04/18 21:21:28 niklas Exp $ */
-/* $NetBSD: svr4_net.c,v 1.8 1996/03/30 22:41:02 christos Exp $ */
+/* $OpenBSD: svr4_net.c,v 1.6 1996/04/21 22:18:23 deraadt Exp $ */
+/* $NetBSD: svr4_net.c,v 1.9 1996/04/11 12:52:41 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#include <compat/svr4/svr4_syscallargs.h>
#include <compat/svr4/svr4_ioctl.h>
#include <compat/svr4/svr4_stropts.h>
-#include <compat/svr4/svr4_conf.h>
+#include <compat/svr4/svr4_socket.h>
/*
* Device minor numbers
*/
enum {
- dev_arp = 26,
- dev_icmp = 27,
- dev_ip = 28,
- dev_tcp = 35,
- dev_udp = 36
+ dev_arp = 26,
+ dev_icmp = 27,
+ dev_ip = 28,
+ dev_tcp = 35,
+ dev_udp = 36,
+ dev_rawip = 37,
+ dev_unix_dgram = 38,
+ dev_unix_stream = 39,
+ dev_unix_ord_stream = 40
};
int svr4_netattach __P((int));
struct file *fp;
struct socket *so;
int error;
+ int family;
struct svr4_strm *st;
DPRINTF(("netopen("));
switch (minor(dev)) {
case dev_udp:
+ family = AF_INET;
type = SOCK_DGRAM;
protocol = IPPROTO_UDP;
DPRINTF(("udp, "));
break;
case dev_tcp:
+ family = AF_INET;
type = SOCK_STREAM;
protocol = IPPROTO_TCP;
DPRINTF(("tcp, "));
break;
case dev_ip:
+ case dev_rawip:
+ family = AF_INET;
type = SOCK_RAW;
protocol = IPPROTO_IP;
DPRINTF(("ip, "));
break;
case dev_icmp:
+ family = AF_INET;
type = SOCK_RAW;
protocol = IPPROTO_ICMP;
DPRINTF(("icmp, "));
break;
+ case dev_unix_dgram:
+ family = AF_UNIX;
+ type = SOCK_DGRAM;
+ protocol = 0;
+ DPRINTF(("unix-dgram, "));
+ break;
+
+ case dev_unix_stream:
+ case dev_unix_ord_stream:
+ family = AF_UNIX;
+ type = SOCK_STREAM;
+ protocol = 0;
+ DPRINTF(("unix-stream, "));
+ break;
+
default:
DPRINTF(("%d);\n", minor(dev)));
return EOPNOTSUPP;
if ((error = falloc(p, &fp, &fd)) != 0)
return (error);
- if ((error = socreate(AF_INET, &so, type, protocol)) != 0) {
+ if ((error = socreate(family, &so, type, protocol)) != 0) {
DPRINTF(("socreate error %d\n", error));
p->p_fd->fd_ofiles[fd] = 0;
ffree(fp);
st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK);
/* XXX: This is unused; ask for a field and make this legal */
+ st->s_family = family;
so->so_internal = st;
st->s_cmd = ~0;
fp->f_data = (caddr_t)so;
struct proc *p;
{
struct socket *so = (struct socket *) fp->f_data;
+ svr4_delete_socket(p, fp);
free(so->so_internal, M_NETADDR);
return soo_close(fp, p);
}
--- /dev/null
+/* $OpenBSD: svr4_socket.c,v 1.1 1996/04/21 22:18:24 deraadt Exp $ */
+/* $NetBSD: svr4_socket.c,v 1.1 1996/04/11 12:43:30 christos Exp $ */
+
+/*
+ * Copyright (c) 1996 Christos Zoulas. 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 Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * In SVR4 unix domain sockets are referenced sometimes
+ * (in putmsg(2) for example) as a [device, inode] pair instead of a pathname.
+ * Since there is no iname() routine in the kernel, and we need access to
+ * a mapping from inode to pathname, we keep our own table. This is a simple
+ * linked list that contains the pathname, the [device, inode] pair, the
+ * file corresponding to that socket and the process. When the
+ * socket gets closed we remove the item from the list. The list gets loaded
+ * every time a stat(2) call finds a socket.
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/queue.h>
+#include <sys/mbuf.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_socket.h>
+
+struct svr4_sockcache_entry {
+ struct proc *p; /* Process for the socket */
+ void *cookie; /* Internal cookie used for matching */
+ struct sockaddr_un sock;/* Pathname for the socket */
+ dev_t dev; /* Device where the socket lives on */
+ ino_t ino; /* Inode where the socket lives on */
+ TAILQ_ENTRY(svr4_sockcache_entry) entries;
+};
+
+static TAILQ_HEAD(svr4_sockcache_head, svr4_sockcache_entry) svr4_head;
+static int initialized = 0;
+
+struct sockaddr_un *
+svr4_find_socket(p, fp, dev, ino)
+ struct proc *p;
+ struct file *fp;
+ dev_t dev;
+ ino_t ino;
+{
+ struct svr4_sockcache_entry *e;
+ void *cookie = ((struct socket *) fp->f_data)->so_internal;
+
+ if (!initialized) {
+ TAILQ_INIT(&svr4_head);
+ initialized = 1;
+ return NULL;
+ }
+
+
+ DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino));
+ for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
+ if (e->p == p && e->dev == dev && e->ino == ino) {
+#ifdef DIAGNOSTIC
+ if (e->cookie != NULL && e->cookie != cookie)
+ panic("svr4 socket cookie mismatch");
+#endif
+ e->cookie = cookie;
+ DPRINTF(("%s\n", e->sock.sun_path));
+ return &e->sock;
+ }
+
+ DPRINTF(("not found\n"));
+ return NULL;
+}
+
+
+void
+svr4_delete_socket(p, fp)
+ struct proc *p;
+ struct file *fp;
+{
+ struct svr4_sockcache_entry *e;
+ void *cookie = ((struct socket *) fp->f_data)->so_internal;
+
+ if (!initialized) {
+ TAILQ_INIT(&svr4_head);
+ initialized = 1;
+ return;
+ }
+
+ for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
+ if (e->p == p && e->cookie == cookie) {
+ TAILQ_REMOVE(&svr4_head, e, entries);
+ DPRINTF(("svr4_delete_socket: %s [%p,%d,%d]\n",
+ e->sock.sun_path, p, e->dev, e->ino));
+ free(e, M_TEMP);
+ return;
+ }
+}
+
+
+int
+svr4_add_socket(p, path, st)
+ struct proc *p;
+ const char *path;
+ struct stat *st;
+{
+ struct svr4_sockcache_entry *e;
+ int len, error;
+
+ if (!initialized) {
+ TAILQ_INIT(&svr4_head);
+ initialized = 1;
+ }
+
+ e = malloc(sizeof(*e), M_TEMP, M_WAITOK);
+ e->cookie = NULL;
+ e->dev = st->st_dev;
+ e->ino = st->st_ino;
+ e->p = p;
+
+ if ((error = copyinstr((char *) path, e->sock.sun_path,
+ sizeof(e->sock.sun_path), &len)) != 0) {
+ DPRINTF(("svr4_add_socket: copyinstr failed %d\n", error));
+ free(e, M_TEMP);
+ return error;
+ }
+
+ e->sock.sun_family = AF_UNIX;
+ e->sock.sun_len = len;
+
+ TAILQ_INSERT_HEAD(&svr4_head, e, entries);
+ DPRINTF(("svr4_add_socket: %s [%p,%d,%d]\n", e->sock.sun_path,
+ p, e->dev, e->ino));
+ return 0;
+}
--- /dev/null
+/* $OpenBSD: svr4_socket.h,v 1.1 1996/04/21 22:18:25 deraadt Exp $ */
+/* $NetBSD: svr4_socket.h,v 1.1 1996/04/11 12:43:31 christos Exp $ */
+
+/*
+ * Copyright (c) 1996 Christos Zoulas. 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 Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SVR4_SOCKET_H_
+#define _SVR4_SOCKET_H_
+
+struct sockaddr_un;
+struct proc;
+struct file;
+
+struct sockaddr_un *svr4_find_socket __P((struct proc *, struct file *,
+ dev_t, ino_t));
+void svr4_delete_socket __P((struct proc *, struct file *));
+int svr4_add_socket __P((struct proc *, const char *, struct stat *));
+
+#endif /* _SVR4_SOCKET_H_ */
-/* $OpenBSD: svr4_sockio.c,v 1.3 1996/04/17 05:24:21 mickey Exp $ */
-/* $NetBSD: svr4_sockio.c,v 1.7 1996/03/30 22:38:14 christos Exp $ */
+/* $OpenBSD: svr4_sockio.c,v 1.4 1996/04/21 22:18:26 deraadt Exp $ */
+/* $NetBSD: svr4_sockio.c,v 1.8 1996/04/11 12:54:44 christos Exp $ */
/*
* Copyright (c) 1995 Christos Zoulas
}
int
-svr4_sockioctl(fp, cmd, data, p, retval)
+svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
struct file *fp;
- u_long cmd;
- caddr_t data;
struct proc *p;
register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t data;
{
int error;
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
-/* $OpenBSD: svr4_stat.c,v 1.6 1996/02/26 23:32:01 niklas Exp $ */
-/* $NetBSD: svr4_stat.c,v 1.19 1996/02/10 17:12:36 christos Exp $ */
+/* $OpenBSD: svr4_stat.c,v 1.7 1996/04/21 22:18:27 deraadt Exp $ */
+/* $NetBSD: svr4_stat.c,v 1.20 1996/04/11 12:46:41 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#include <compat/svr4/svr4_utsname.h>
#include <compat/svr4/svr4_systeminfo.h>
#include <compat/svr4/svr4_time.h>
+#include <compat/svr4/svr4_socket.h>
#ifdef sparc
/*
int svr4_ustat __P((struct proc *, void *, register_t *));
static int svr4_to_bsd_pathconf __P((int));
+/*
+ * SVR4 uses named pipes as named sockets, so we tell programs
+ * that sockets are named pipes with mode 0
+ */
+#define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
+
#ifndef SVR4_NO_OSTAT
static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
bzero(st4, sizeof(*st4));
st4->st_dev = st->st_dev;
st4->st_ino = st->st_ino;
- st4->st_mode = st->st_mode;
+ st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
st4->st_nlink = st->st_nlink;
st4->st_uid = st->st_uid;
st4->st_gid = st->st_gid;
bzero(st4, sizeof(*st4));
st4->st_dev = st->st_dev;
st4->st_ino = st->st_ino;
- st4->st_mode = st->st_mode;
+ st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
st4->st_nlink = st->st_nlink;
st4->st_uid = st->st_uid;
st4->st_gid = st->st_gid;
bsd_to_svr4_stat(&st, &svr4_st);
+ if (S_ISSOCK(st.st_mode))
+ (void) svr4_add_socket(p, SCARG(uap, path), &st);
+
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
return error;
bsd_to_svr4_stat(&st, &svr4_st);
+ if (S_ISSOCK(st.st_mode))
+ (void) svr4_add_socket(p, SCARG(uap, path), &st);
+
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
return error;
bsd_to_svr4_xstat(&st, &svr4_st);
+ if (S_ISSOCK(st.st_mode))
+ (void) svr4_add_socket(p, SCARG(uap, path), &st);
+
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
return error;
bsd_to_svr4_xstat(&st, &svr4_st);
+ if (S_ISSOCK(st.st_mode))
+ (void) svr4_add_socket(p, SCARG(uap, path), &st);
+
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
return error;
-/* $OpenBSD: svr4_stream.c,v 1.3 1996/04/17 05:24:22 mickey Exp $ */
-/* $NetBSD: svr4_stream.c,v 1.12 1996/03/30 22:38:19 christos Exp $ */
-
+/* $OpenBSD: svr4_stream.c,v 1.4 1996/04/21 22:18:29 deraadt Exp $ */
+/* $NetBSD: svr4_stream.c,v 1.13 1996/04/11 12:49:13 christos Exp $ */
/*
- * Copyright (c) 1994 Christos Zoulas
- * All rights reserved.
+ * Copyright (c) 1994, 1996 Christos Zoulas. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/*
* Pretend that we have streams...
+ * Yes, this is gross.
+ *
+ * ToDo: The state machine for getmsg needs re-thinking
+ * We really need I_FDINSERT and it is going to be a pain.
*/
#include <sys/param.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/un.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/device.h>
+#include <sys/stat.h>
#include <sys/syscallargs.h>
#include <compat/svr4/svr4_timod.h>
#include <compat/svr4/svr4_sockmod.h>
#include <compat/svr4/svr4_ioctl.h>
+#include <compat/svr4/svr4_socket.h>
+
+/* Utils */
+static int clean_pipe __P((struct proc *, const char *));
+static void getparm __P((struct socket *, struct svr4_si_sockparms *));
+
+/* Address Conversions */
+static void sockaddr_to_netaddr_in __P((struct svr4_strmcmd *,
+ const struct sockaddr_in *));
+static void sockaddr_to_netaddr_un __P((struct svr4_strmcmd *,
+ const struct sockaddr_un *));
+static void netaddr_to_sockaddr_in __P((struct sockaddr_in *,
+ const struct svr4_strmcmd *));
+static void netaddr_to_sockaddr_un __P((struct sockaddr_un *,
+ const struct svr4_strmcmd *));
+
+/* stream ioctls */
+static int i_nread __P((struct file *, struct proc *, register_t *, int,
+ u_long, caddr_t));
+static int i_str __P((struct file *, struct proc *, register_t *, int,
+ u_long, caddr_t));
+
+/* i_str sockmod calls */
+static int sockmod __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+static int si_listen __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+static int si_ogetudata __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+static int si_sockparams __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+static int si_getudata __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+
+/* i_str timod calls */
+static int timod __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+static int ti_getinfo __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
+static int ti_bind __P((struct file *, int, struct svr4_strioctl *,
+ struct proc *));
-static void svr4_getparm __P((struct socket *, struct svr4_si_sockparms *));
-static int svr4_sockmod __P((struct file *, struct svr4_strioctl *,
- struct proc *));
-static int svr4_timod __P((struct file *, struct svr4_strioctl *,
- struct proc *));
#ifdef DEBUG_SVR4
-static int svr4_showioc __P((const char *, struct svr4_strioctl *));
-static int svr4_getstrbuf __P((struct svr4_strbuf *));
-static void svr4_showmsg __P((const char *, int, struct svr4_strbuf *,
- struct svr4_strbuf *, int));
+static int show_ioc __P((const char *, struct svr4_strioctl *));
+static int show_strbuf __P((struct svr4_strbuf *));
+static void show_msg __P((const char *, int, struct svr4_strbuf *,
+ struct svr4_strbuf *, int));
+static void show_strmcmd __P((const char *, struct svr4_strmcmd *));
+
+static int
+show_ioc(str, ioc)
+ const char *str;
+ struct svr4_strioctl *ioc;
+{
+ char *ptr = (char *) malloc(ioc->len, M_TEMP, M_WAITOK);
+ int error;
+ int i;
+
+ printf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ",
+ str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
+
+ if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) {
+ free((char *) ptr, M_TEMP);
+ return error;
+ }
+
+ for (i = 0; i < ioc->len; i++)
+ printf("%x ", (unsigned char) ptr[i]);
+
+ printf("}\n");
+
+ free((char *) ptr, M_TEMP);
+ return 0;
+}
+
+
+static int
+show_strbuf(str)
+ struct svr4_strbuf *str;
+{
+ int error;
+ int i;
+ char *ptr = NULL;
+ int maxlen = str->maxlen;
+ int len = str->len;
+
+ if (maxlen < 0)
+ maxlen = 0;
+
+ if (len >= maxlen || len <= 0)
+ len = maxlen;
+
+ if (len != 0) {
+ ptr = malloc(len, M_TEMP, M_WAITOK);
+
+ if ((error = copyin(str->buf, ptr, len)) != 0) {
+ free((char *) ptr, M_TEMP);
+ return error;
+ }
+ }
+
+ printf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf);
+
+ for (i = 0; i < len; i++)
+ printf("%x ", (unsigned char) ptr[i]);
+
+ printf("]}");
+
+ if (ptr)
+ free((char *) ptr, M_TEMP);
+
+ return 0;
+}
+
+
+static void
+show_msg(str, fd, ctl, dat, flags)
+ const char *str;
+ int fd;
+ struct svr4_strbuf *ctl;
+ struct svr4_strbuf *dat;
+ int flags;
+{
+ struct svr4_strbuf buf;
+ int error;
+
+ printf("%s(%d", str, fd);
+ if (ctl != NULL) {
+ if ((error = copyin(ctl, &buf, sizeof(buf))) != 0)
+ return;
+ show_strbuf(&buf);
+ }
+ else
+ printf(", NULL");
+
+ if (dat != NULL) {
+ if ((error = copyin(dat, &buf, sizeof(buf))) != 0)
+ return;
+ show_strbuf(&buf);
+ }
+ else
+ printf(", NULL");
+
+ printf(", %x);\n", flags);
+}
+
+
+static void
+show_strmcmd(str, cmd)
+ const char *str;
+ struct svr4_strmcmd *cmd;
+{
+ int i;
+
+ printf("%s cmd = %ld, len = %ld, offs = %ld { ",
+ str, cmd->cmd, cmd->len, cmd->offs);
+
+ for (i = 0; i < sizeof(cmd->pad) / sizeof(cmd->pad[0]); i++)
+ printf("%lx ", cmd->pad[i]);
+
+ printf("}\n");
+}
#endif /* DEBUG_SVR4 */
+/*
+ * We are faced with an interesting situation. On svr4 unix sockets
+ * are really pipes. But we really have sockets, and we might as
+ * well use them. At the point where svr4 calls TI_BIND, it has
+ * already created a named pipe for the socket using mknod(2).
+ * We need to create a socket with the same name when we bind,
+ * so we need to remove the pipe before, otherwise we'll get address
+ * already in use. So we *carefully* remove the pipe, to avoid
+ * using this as a random file removal tool. We use system calls
+ * to avoid code duplication.
+ */
+static int
+clean_pipe(p, path)
+ struct proc *p;
+ const char *path;
+{
+ struct sys_lstat_args la;
+ struct sys_unlink_args ua;
+ register_t retval;
+ struct stat st;
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+ size_t l = strlen(path) + 1;
+
+ SCARG(&la, path) = stackgap_alloc(&sg, l);
+ SCARG(&la, ub) = stackgap_alloc(&sg, sizeof(struct stat));
+
+ if ((error = copyout((char *) path, SCARG(&la, path), l)) != 0)
+ return error;
+
+ if ((error = sys_lstat(p, &la, &retval)) != 0)
+ return 0;
+
+ if ((error = copyin(SCARG(&la, ub), &st, sizeof(st))) != 0)
+ return 0;
+
+ /*
+ * Make sure we are dealing with a mode 0 named pipe.
+ */
+ if ((st.st_mode & S_IFMT) != S_IFIFO)
+ return 0;
+
+ if ((st.st_mode & ALLPERMS) != 0)
+ return 0;
+
+ SCARG(&ua, path) = SCARG(&la, path);
+
+ if ((error = sys_unlink(p, &ua, &retval)) != 0) {
+ DPRINTF(("clean_pipe: unlink failed %d\n", error));
+ return error;
+ }
+
+ return 0;
+}
+
+
+static void
+sockaddr_to_netaddr_in(sc, sain)
+ struct svr4_strmcmd *sc;
+ const struct sockaddr_in *sain;
+{
+ struct svr4_netaddr_in *na;
+ na = SVR4_ADDROF(sc);
+
+ na->family = sain->sin_family;
+ na->port = sain->sin_port;
+ na->addr = sain->sin_addr.s_addr;
+ DPRINTF(("sockaddr_in -> netaddr %d %d %lx\n", na->family, na->port,
+ na->addr));
+}
+
+
+static void
+sockaddr_to_netaddr_un(sc, saun)
+ struct svr4_strmcmd *sc;
+ const struct sockaddr_un *saun;
+{
+ struct svr4_netaddr_un *na;
+ char *dst, *edst = ((char *) sc) + sc->offs + sizeof(na->family) + 1 -
+ sizeof(*sc);
+ const char *src;
+
+ na = SVR4_ADDROF(sc);
+ na->family = saun->sun_family;
+ for (src = saun->sun_path, dst = na->path; (*dst++ = *src++) != '\0'; )
+ if (dst == edst)
+ break;
+ DPRINTF(("sockaddr_un -> netaddr %d %s\n", na->family, na->path));
+}
+
+
static void
-svr4_getparm(so, pa)
+netaddr_to_sockaddr_in(sain, sc)
+ struct sockaddr_in *sain;
+ const struct svr4_strmcmd *sc;
+{
+ const struct svr4_netaddr_in *na;
+
+
+ na = SVR4_ADDROF(sc);
+ bzero(sain, sizeof(*sain));
+ sain->sin_len = sizeof(*sain);
+ sain->sin_family = na->family;
+ sain->sin_port = na->port;
+ sain->sin_addr.s_addr = na->addr;
+ DPRINTF(("netaddr -> sockaddr_in %d %d %x\n", sain->sin_family,
+ sain->sin_port, sain->sin_addr.s_addr));
+}
+
+
+static void
+netaddr_to_sockaddr_un(saun, sc)
+ struct sockaddr_un *saun;
+ const struct svr4_strmcmd *sc;
+{
+ const struct svr4_netaddr_un *na;
+ char *dst, *edst = &saun->sun_path[sizeof(saun->sun_path) - 1];
+ const char *src;
+
+ na = SVR4_ADDROF(sc);
+ bzero(saun, sizeof(*saun));
+ saun->sun_family = na->family;
+ for (src = na->path, dst = saun->sun_path; (*dst++ = *src++) != '\0'; )
+ if (dst == edst)
+ break;
+ saun->sun_len = dst - saun->sun_path;
+ DPRINTF(("netaddr -> sockaddr_un %d %s\n", saun->sun_family,
+ saun->sun_path));
+}
+
+
+static void
+getparm(so, pa)
struct socket *so;
struct svr4_si_sockparms *pa;
{
- pa->family = AF_INET;
+ struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ pa->family = st->s_family;
switch (so->so_type) {
case SOCK_DGRAM:
static int
-svr4_sockmod(fp, ioc, p)
+si_ogetudata(fp, fd, ioc, p)
struct file *fp;
+ int fd;
struct svr4_strioctl *ioc;
struct proc *p;
{
int error;
+ struct svr4_si_oudata ud;
+ struct svr4_si_sockparms pa;
+ struct socket *so = (struct socket *) fp->f_data;
- switch (ioc->cmd) {
- case SVR4_SI_OGETUDATA:
- DPRINTF(("SI_OGETUDATA\n"));
- {
- struct svr4_si_oudata ud;
- struct svr4_si_sockparms pa;
- struct socket *so = (struct socket *) fp->f_data;
-
- if (sizeof(ud) != ioc->len) {
- DPRINTF(("Wrong size %d != %d\n",
- sizeof(ud), ioc->len));
- return EINVAL;
- }
+ if (sizeof(ud) != ioc->len) {
+ DPRINTF(("SI_OGETUDATA: Wrong size %d != %d\n",
+ sizeof(ud), ioc->len));
+ return EINVAL;
+ }
- if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
- return error;
+ if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
+ return error;
- /* I have no idea what these should be! */
- ud.tidusize = 16384;
- ud.addrsize = sizeof(struct sockaddr_in);
- ud.optsize = 128;
+ getparm(so, &pa);
- svr4_getparm(so, &pa);
+ switch (pa.family) {
+ case AF_INET:
+ ud.addrsize = sizeof(struct sockaddr_in);
+ break;
- if (pa.type == SVR4_SOCK_STREAM)
- ud.etsdusize = 1;
- else
- ud.etsdusize = 0;
+ case AF_UNIX:
+ ud.addrsize = sizeof(struct sockaddr_un);
+ break;
- ud.servtype = pa.type;
+ default:
+ DPRINTF(("SI_OGETUDATA: Unsupported address family %d\n",
+ pa.family));
+ return ENOSYS;
+ }
- /* XXX: Fixme */
- ud.so_state = 0;
- ud.so_options = 0;
- return copyout(&ud, ioc->buf, sizeof(ud));
- }
+ /* I have no idea what these should be! */
+ ud.tidusize = 16384;
+ ud.optsize = 128;
+
+
+ if (pa.type == SVR4_SOCK_STREAM)
+ ud.etsdusize = 1;
+ else
+ ud.etsdusize = 0;
+
+ ud.servtype = pa.type;
+
+ /* XXX: Fixme */
+ ud.so_state = 0;
+ ud.so_options = 0;
+ return copyout(&ud, ioc->buf, sizeof(ud));
+}
+
+
+static int
+si_sockparams(fp, fd, ioc, p)
+ struct file *fp;
+ int fd;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ struct socket *so = (struct socket *) fp->f_data;
+ struct svr4_si_sockparms pa;
+
+ getparm(so, &pa);
+ return copyout(&pa, ioc->buf, sizeof(pa));
+}
+
+
+static int
+si_listen(fp, fd, ioc, p)
+ struct file *fp;
+ int fd;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ int error;
+ struct socket *so = (struct socket *) fp->f_data;
+ struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ register_t retval;
+#if 0
+ struct sockaddr_in sain;
+ struct sockaddr_un saun;
+ caddr_t sg;
+ void *skp, *sup;
+ int sasize;
+#endif
+ struct svr4_strmcmd lst;
+ struct sys_listen_args la;
+
+ if ((error = copyin(ioc->buf, &lst, ioc->len)) != 0)
+ return error;
+
+#ifdef DEBUG_SVR4
+ show_strmcmd(">si_listen", &lst);
+#endif
+
+#if 0
+ switch (st->s_family) {
+ case AF_INET:
+ skp = &sain;
+ sasize = sizeof(sain);
+
+ if (lst.offs == 0)
+ goto reply;
+
+ netaddr_to_sockaddr_in(&sain, &lst);
+
+ DPRINTF(("SI_LISTEN: fam %d, port %d, addr %x\n",
+ sain.sin_family, sain.sin_port,
+ sain.sin_addr.s_addr));
+ break;
+
+ case AF_UNIX:
+ skp = &saun;
+ sasize = sizeof(saun);
+ if (lst.offs == 0)
+ goto reply;
+
+ netaddr_to_sockaddr_un(&saun, &lst);
+
+ if (saun.sun_path[0] == '\0')
+ goto reply;
+
+ DPRINTF(("SI_LISTEN: fam %d, path %s\n",
+ saun.sun_family, saun.sun_path));
+
+ if ((error = clean_pipe(p, saun.sun_path)) != 0)
+ return error;
+ break;
+
+ default:
+ DPRINTF(("SI_LISTEN: Unsupported address family %d\n",
+ st->s_family));
+ return ENOSYS;
+ }
+
+ sg = stackgap_init(p->p_emul);
+ sup = stackgap_alloc(&sg, sasize);
+
+ if ((error = copyout(skp, sup, sasize)) != 0)
+ return error;
+#endif
+
+ SCARG(&la, s) = fd;
+ DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5));
+ SCARG(&la, backlog) = 5;
+
+ if ((error = sys_listen(p, &la, &retval)) != 0) {
+ DPRINTF(("SI_LISTEN: listen failed %d\n", error));
+ return error;
+ }
+
+ st->s_cmd = SVR4_TI_ACCEPT_REPLY;
+
+ return 0;
+
+#if 0
+reply:
+ bzero(&lst, sizeof(lst));
+ lst.cmd = SVR4_TI_BIND_REPLY;
+ lst.len = sasize;
+ lst.offs = 0x10; /* XXX */
+
+ ioc->len = 32;
+ if ((error = copyout(&lst, ioc->buf, ioc->len)) != 0)
+ return error;
+
+ return 0;
+#endif
+}
+
+
+static int
+si_getudata(fp, fd, ioc, p)
+ struct file *fp;
+ int fd;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ int error;
+ struct svr4_si_udata ud;
+ struct socket *so = (struct socket *) fp->f_data;
+
+ if (sizeof(ud) != ioc->len) {
+ DPRINTF(("SI_GETUDATA: Wrong size %d != %d\n",
+ sizeof(ud), ioc->len));
+ return EINVAL;
+ }
+
+ if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
+ return error;
+
+ getparm(so, &ud.sockparms);
+
+ switch (ud.sockparms.family) {
+ case AF_INET:
+ ud.addrsize = sizeof(struct sockaddr_in);
+ break;
+
+ case AF_UNIX:
+ ud.addrsize = sizeof(struct sockaddr_un);
+ break;
+
+ default:
+ DPRINTF(("SI_GETUDATA: Unsupported address family %d\n",
+ ud.sockparms.family));
+ return ENOSYS;
+ }
+
+ /* I have no idea what these should be! */
+ ud.tidusize = 16384;
+ ud.optsize = 128;
+ ud.tsdusize = 16384;
+
+
+ if (ud.sockparms.type == SVR4_SOCK_STREAM)
+ ud.etsdusize = 1;
+ else
+ ud.etsdusize = 0;
+
+ ud.servtype = ud.sockparms.type;
+
+ /* XXX: Fixme */
+ ud.so_state = 0;
+ ud.so_options = 0;
+ return copyout(&ud, ioc->buf, sizeof(ud));
+}
+
+
+static int
+sockmod(fp, fd, ioc, p)
+ struct file *fp;
+ int fd;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ switch (ioc->cmd) {
+ case SVR4_SI_OGETUDATA:
+ DPRINTF(("SI_OGETUDATA\n"));
+ return si_ogetudata(fp, fd, ioc, p);
case SVR4_SI_SHUTDOWN:
DPRINTF(("SI_SHUTDOWN\n"));
case SVR4_SI_LISTEN:
DPRINTF(("SI_LISTEN\n"));
- return 0;
+ return si_listen(fp, fd, ioc, p);
case SVR4_SI_SETMYNAME:
DPRINTF(("SI_SETMYNAME\n"));
case SVR4_SI_SOCKPARAMS:
DPRINTF(("SI_SOCKPARAMS\n"));
- {
- struct socket *so = (struct socket *) fp->f_data;
- struct svr4_si_sockparms pa;
-
- svr4_getparm(so, &pa);
- return copyout(&pa, ioc->buf, sizeof(pa));
- }
- return 0;
+ return si_sockparams(fp, fd, ioc, p);
case SVR4_SI_GETUDATA:
DPRINTF(("SI_GETUDATA\n"));
- {
- struct svr4_si_udata ud;
- struct socket *so = (struct socket *) fp->f_data;
+ return si_getudata(fp, fd, ioc, p);
- if (sizeof(ud) != ioc->len) {
- DPRINTF(("Wrong size %d != %d\n",
- sizeof(ud), ioc->len));
- return EINVAL;
- }
+ default:
+ DPRINTF(("Unknown sockmod ioctl %lx\n", ioc->cmd));
+ return 0;
- if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
- return error;
+ }
+}
- /* I have no idea what these should be! */
- ud.tidusize = 16384;
- ud.addrsize = sizeof(struct sockaddr_in);
- ud.optsize = 128;
- ud.tsdusize = 16384;
- svr4_getparm(so, &ud.sockparms);
+static int
+ti_getinfo(fp, fd, ioc, p)
+ struct file *fp;
+ int fd;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ int error;
+ struct svr4_infocmd info;
- if (ud.sockparms.type == SVR4_SOCK_STREAM)
- ud.etsdusize = 1;
- else
- ud.etsdusize = 0;
+ bzero(&info, sizeof(info));
- ud.servtype = ud.sockparms.type;
+ if ((error = copyin(ioc->buf, &info, ioc->len)) != 0)
+ return error;
- /* XXX: Fixme */
- ud.so_state = 0;
- ud.so_options = 0;
- return copyout(&ud, ioc->buf, sizeof(ud));
- }
- return 0;
+ if (info.cmd != SVR4_TI_INFO_REQUEST)
+ return EINVAL;
- default:
- DPRINTF(("Unknown sockmod ioctl %lx\n", ioc->cmd));
- return 0;
+ info.cmd = SVR4_TI_INFO_REPLY;
+ info.tsdu = 0;
+ info.etsdu = 1;
+ info.cdata = -2;
+ info.ddata = -2;
+ info.addr = 16;
+ info.opt = -1;
+ info.tidu = 16384;
+ info.serv = 2;
+ info.current = 0;
+ info.provider = 2;
+
+ ioc->len = sizeof(info);
+ if ((error = copyout(&info, ioc->buf, ioc->len)) != 0)
+ return error;
- }
+ return 0;
}
+
static int
-svr4_timod(fp, ioc, p)
+ti_bind(fp, fd, ioc, p)
struct file *fp;
+ int fd;
struct svr4_strioctl *ioc;
struct proc *p;
{
int error;
+ struct socket *so = (struct socket *) fp->f_data;
+ struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ struct sockaddr_in sain;
+ struct sockaddr_un saun;
+ register_t retval;
+ caddr_t sg;
+ void *skp, *sup = NULL;
+ int sasize;
+ struct svr4_strmcmd bnd;
+ struct sys_bind_args ba;
- switch (ioc->cmd) {
- case SVR4_TI_GETINFO:
- DPRINTF(("TI_GETINFO\n"));
- {
- struct svr4_infocmd info;
+ if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0)
+ return error;
- bzero(&info, sizeof(info));
+ if (bnd.cmd != SVR4_TI_BIND_REQUEST)
+ return EINVAL;
- if ((error = copyin(ioc->buf, &info, ioc->len)) != 0)
- return error;
+ switch (st->s_family) {
+ case AF_INET:
+ skp = &sain;
+ sasize = sizeof(sain);
- if (info.cmd != SVR4_TI_INFO_REQUEST)
- return EINVAL;
-
- info.cmd = SVR4_TI_INFO_REPLY;
- info.tsdu = 0;
- info.etsdu = 1;
- info.cdata = -2;
- info.ddata = -2;
- info.addr = 16;
- info.opt = -1;
- info.tidu = 16384;
- info.serv = 2;
- info.current = 0;
- info.provider = 2;
-
- ioc->len = sizeof(info);
- if ((error = copyout(&info, ioc->buf, ioc->len)) != 0)
- return error;
- }
- return 0;
+ if (bnd.offs == 0)
+ goto reply;
+
+ netaddr_to_sockaddr_in(&sain, &bnd);
+
+ DPRINTF(("TI_BIND: fam %d, port %d, addr %x\n",
+ sain.sin_family, sain.sin_port,
+ sain.sin_addr.s_addr));
+ break;
+
+ case AF_UNIX:
+ skp = &saun;
+ sasize = sizeof(saun);
+ if (bnd.offs == 0)
+ goto reply;
+
+ netaddr_to_sockaddr_un(&saun, &bnd);
+
+ if (saun.sun_path[0] == '\0')
+ goto reply;
+
+ DPRINTF(("TI_BIND: fam %d, path %s\n",
+ saun.sun_family, saun.sun_path));
+
+ if ((error = clean_pipe(p, saun.sun_path)) != 0)
+ return error;
+ break;
+
+ default:
+ DPRINTF(("TI_BIND: Unsupported address family %d\n",
+ st->s_family));
+ return ENOSYS;
+ }
+
+ sg = stackgap_init(p->p_emul);
+ sup = stackgap_alloc(&sg, sasize);
+
+ if ((error = copyout(skp, sup, sasize)) != 0)
+ return error;
+
+ SCARG(&ba, s) = fd;
+ DPRINTF(("TI_BIND: fileno %d\n", fd));
+ SCARG(&ba, name) = (caddr_t) sup;
+ SCARG(&ba, namelen) = sasize;
+
+ if ((error = sys_bind(p, &ba, &retval)) != 0) {
+ DPRINTF(("TI_BIND: bind failed %d\n", error));
+ return error;
+ }
+
+reply:
+ if (sup == NULL) {
+ bzero(&bnd, sizeof(bnd));
+ bnd.len = sasize;
+ bnd.offs = 0x10; /* XXX */
+ }
+
+ bnd.cmd = SVR4_TI_BIND_REPLY;
+
+ if ((error = copyout(&bnd, ioc->buf, ioc->len)) != 0)
+ return error;
+
+ return 0;
+}
+
+
+static int
+timod(fp, fd, ioc, p)
+ struct file *fp;
+ int fd;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ switch (ioc->cmd) {
+ case SVR4_TI_GETINFO:
+ DPRINTF(("TI_GETINFO\n"));
+ return ti_getinfo(fp, fd, ioc, p);
case SVR4_TI_OPTMGMT:
DPRINTF(("TI_OPTMGMT\n"));
case SVR4_TI_BIND:
DPRINTF(("TI_BIND\n"));
- {
- struct svr4_strmcmd bnd;
- bzero(&bnd, sizeof(bnd));
+ return ti_bind(fp, fd, ioc, p);
- if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0)
- return error;
+ case SVR4_TI_UNBIND:
+ DPRINTF(("TI_UNBIND\n"));
+ return 0;
- if (bnd.cmd != SVR4_TI_BIND_REQUEST)
- return EINVAL;
+ default:
+ DPRINTF(("Unknown timod ioctl %lx\n", ioc->cmd));
+ return 0;
+ }
+}
- ioc->len = 32;
- bzero(&bnd, sizeof(bnd));
+int
+svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat)
+ struct file *fp;
+ struct proc *p;
+ register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t dat;
+{
+ struct svr4_strbuf skb, *sub = (struct svr4_strbuf *) dat;
+ struct socket *so = (struct socket *) fp->f_data;
+ struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ int error;
+ void *skp, *sup;
+ struct sockaddr_in sain;
+ struct sockaddr_un saun;
+ struct svr4_strmcmd sc;
+ int sasize;
+ caddr_t sg;
+ int *lenp;
- bnd.cmd = SVR4_TI_BIND_REPLY;
- bnd.len = sizeof(struct sockaddr_in);
- bnd.offs = 0x10;
+ sc.offs = 0x10;
+
+ if ((error = copyin(sub, &skb, sizeof(skb))) != 0) {
+ DPRINTF(("ti_ioctl: error copying in strbuf\n"));
+ return error;
+ }
- if ((error = copyout(&bnd, ioc->buf, ioc->len)) != 0)
- return error;
- }
- return 0;
+ switch (st->s_family) {
+ case AF_INET:
+ skp = &sain;
+ sasize = sizeof(sain);
+ break;
+
+ case AF_UNIX:
+ skp = &saun;
+ sasize = sizeof(saun);
+ break;
+
+ default:
+ DPRINTF(("ti_ioctl: Unsupported address family %d\n",
+ st->s_family));
+ return ENOSYS;
+ }
+
+ sg = stackgap_init(p->p_emul);
+ sup = stackgap_alloc(&sg, sasize);
+ lenp = stackgap_alloc(&sg, sizeof(*lenp));
- case SVR4_TI_UNBIND:
- DPRINTF(("TI_UNBIND\n"));
- return 0;
+ if ((error = copyout(&sasize, lenp, sizeof(*lenp))) != 0) {
+ DPRINTF(("ti_ioctl: error copying out lenp\n"));
+ return error;
+ }
+ switch (cmd) {
case SVR4_TI_GETMYNAME:
DPRINTF(("TI_GETMYNAME\n"));
- return 0;
+ {
+ struct sys_getsockname_args ap;
+ SCARG(&ap, fdes) = fd;
+ SCARG(&ap, asa) = sup;
+ SCARG(&ap, alen) = lenp;
+ if ((error = sys_getsockname(p, &ap, retval)) != 0) {
+ DPRINTF(("ti_ioctl: getsockname error\n"));
+ return error;
+ }
+ }
+ break;
case SVR4_TI_GETPEERNAME:
DPRINTF(("TI_GETPEERNAME\n"));
- return 0;
+ {
+ struct sys_getpeername_args ap;
+ SCARG(&ap, fdes) = fd;
+ SCARG(&ap, asa) = sup;
+ SCARG(&ap, alen) = lenp;
+ if ((error = sys_getpeername(p, &ap, retval)) != 0) {
+ DPRINTF(("ti_ioctl: getpeername error\n"));
+ return error;
+ }
+ }
+ break;
case SVR4_TI_SETMYNAME:
DPRINTF(("TI_SETMYNAME\n"));
case SVR4_TI_SETPEERNAME:
DPRINTF(("TI_SETPEERNAME\n"));
return 0;
+ default:
+ DPRINTF(("ti_ioctl: Unknown ioctl %lx\n", cmd));
+ return ENOSYS;
+ }
+
+ if ((error = copyin(sup, skp, sasize)) != 0) {
+ DPRINTF(("ti_ioctl: error copying in socket data\n"));
+ return error;
+ }
+
+ if ((error = copyin(lenp, &sasize, sizeof(*lenp))) != 0) {
+ DPRINTF(("ti_ioctl: error copying in socket size\n"));
+ return error;
+ }
+
+ switch (st->s_family) {
+ case AF_INET:
+ sockaddr_to_netaddr_in(&sc, &sain);
+ break;
+
+ case AF_UNIX:
+ sockaddr_to_netaddr_un(&sc, &saun);
+ break;
default:
- DPRINTF(("Unknown timod ioctl %lx\n", ioc->cmd));
- return 0;
+ return ENOSYS;
+ }
+
+ skb.len = sasize;
+
+ if ((error = copyout(SVR4_ADDROF(&sc), skb.buf, sasize)) != 0) {
+ DPRINTF(("ti_ioctl: error copying out socket data\n"));
+ return error;
+ }
+
+ if ((error = copyout(&skb, sub, sizeof(skb))) != 0) {
+ DPRINTF(("ti_ioctl: error copying out strbuf\n"));
+ return error;
}
+
+ return error;
}
-#ifdef DEBUG_SVR4
+
+
static int
-svr4_showioc(str, ioc)
- const char *str;
- struct svr4_strioctl *ioc;
+i_nread(fp, p, retval, fd, cmd, dat)
+ struct file *fp;
+ struct proc *p;
+ register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t dat;
{
- char *ptr = (char *) malloc(ioc->len, M_TEMP, M_WAITOK);
int error;
- int i;
+ int nread = 0;
- printf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ",
- str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
+ /*
+ * We are supposed to return the message length in nread, and the
+ * number of messages in retval. We don't have the notion of number
+ * of stream messages, so we just find out if we have any bytes waiting
+ * for us, and if we do, then we assume that we have at least one
+ * message waiting for us.
+ */
+ if ((error = (*fp->f_ops->fo_ioctl)(fp, FIONREAD,
+ (caddr_t) &nread, p)) != 0)
+ return error;
- if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) {
- free((char *) ptr, M_TEMP);
+ if (nread != 0)
+ *retval = 1;
+ else
+ *retval = 0;
+
+ return copyout(&nread, dat, sizeof(nread));
+}
+
+
+static int
+i_str(fp, p, retval, fd, cmd, dat)
+ struct file *fp;
+ struct proc *p;
+ register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t dat;
+{
+ int error;
+ struct svr4_strioctl ioc;
+
+ if ((error = copyin(dat, &ioc, sizeof(ioc))) != 0)
return error;
- }
- for (i = 0; i < ioc->len; i++)
- printf("%x ", (unsigned char) ptr[i]);
+#ifdef DEBUG_SVR4
+ if ((error = show_ioc(">", &ioc)) != 0)
+ return error;
+#endif /* DEBUG_SVR4 */
- printf("}\n");
+ switch (ioc.cmd & 0xff00) {
+ case SVR4_SIMOD:
+ if ((error = sockmod(fp, fd, &ioc, p)) != 0)
+ return error;
+ break;
- free((char *) ptr, M_TEMP);
- return 0;
-}
+ case SVR4_TIMOD:
+ if ((error = timod(fp, fd, &ioc, p)) != 0)
+ return error;
+ break;
+
+ default:
+ DPRINTF(("Unimplemented module %c %ld\n",
+ (char) (cmd >> 8), cmd & 0xff));
+ return 0;
+ }
+
+#ifdef DEBUG_SVR4
+ if ((error = show_ioc("<", &ioc)) != 0)
+ return error;
#endif /* DEBUG_SVR4 */
+ return copyout(&ioc, dat, sizeof(ioc));
+}
int
-svr4_streamioctl(fp, cmd, dat, p, retval)
+svr4_stream_ioctl(fp, p, retval, fd, cmd, dat)
struct file *fp;
- u_long cmd;
- caddr_t dat;
struct proc *p;
register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t dat;
{
- struct svr4_strioctl ioc;
- int error;
-
*retval = 0;
/*
switch (cmd) {
case SVR4_I_NREAD:
DPRINTF(("I_NREAD\n"));
- {
- int nread = 0; /* XXX: is that FIONREAD? */
- if ((error = copyout(&nread, dat, sizeof(nread))) != 0)
- return error;
- }
- return 0;
+ return i_nread(fp, p, retval, fd, cmd, dat);
case SVR4_I_PUSH:
DPRINTF(("I_PUSH\n"));
case SVR4_I_STR:
DPRINTF(("I_STR\n"));
- if ((error = copyin(dat, &ioc, sizeof(ioc))) != 0)
- return error;
-
-#ifdef DEBUG_SVR4
- if ((error = svr4_showioc(">", &ioc)) != 0)
- return error;
-#endif /* DEBUG_SVR4 */
- switch (ioc.cmd & 0xff00) {
- case SVR4_SIMOD:
- if ((error = svr4_sockmod(fp, &ioc, p)) != 0)
- return error;
- break;
-
- case SVR4_TIMOD:
- if ((error = svr4_timod(fp, &ioc, p)) != 0)
- return error;
- break;
-
- default:
- DPRINTF(("Unimplemented module %c %ld\n",
- (char) (cmd >> 8), cmd & 0xff));
- return 0;
- }
-
-#ifdef DEBUG_SVR4
- if ((error = svr4_showioc("<", &ioc)) != 0)
- return error;
-#endif /* DEBUG_SVR4 */
- return copyout(&ioc, dat, sizeof(ioc));
+ return i_str(fp, p, retval, fd, cmd, dat);
case SVR4_I_SETSIG:
DPRINTF(("I_SETSIG\n"));
}
-#ifdef DEBUG_SVR4
-static int
-svr4_getstrbuf(str)
- struct svr4_strbuf *str;
-{
- int error;
- int i;
- char *ptr = NULL;
- int maxlen = str->maxlen;
- int len = str->len;
-
- if (maxlen < 0)
- maxlen = 0;
-
- if (len >= maxlen || len <= 0)
- len = maxlen;
-
- if (len != 0) {
- ptr = malloc(len, M_TEMP, M_WAITOK);
-
- if ((error = copyin(str->buf, ptr, len)) != 0) {
- free((char *) ptr, M_TEMP);
- return error;
- }
- }
-
- printf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf);
- for (i = 0; i < len; i++) {
- printf("%x ", (unsigned char) ptr[i]);
- if (i > 20) {
- printf("...");
- break;
- }
- }
- printf("]}");
-
- if (ptr)
- free((char *) ptr, M_TEMP);
-
- return 0;
-}
-
-
-static void
-svr4_showmsg(str, fd, ctl, dat, flags)
- const char *str;
- int fd;
- struct svr4_strbuf *ctl;
- struct svr4_strbuf *dat;
- int flags;
-{
- struct svr4_strbuf buf;
- int error;
-
- printf("%s(%d", str, fd);
- if (ctl != NULL) {
- if ((error = copyin(ctl, &buf, sizeof(buf))) != 0)
- return;
- svr4_getstrbuf(&buf);
- }
- else
- printf(", NULL");
-
- if (dat != NULL) {
- if ((error = copyin(dat, &buf, sizeof(buf))) != 0)
- return;
- svr4_getstrbuf(&buf);
- }
- else
- printf(", NULL");
-
- printf(", %x);\n", flags);
-}
-#endif /* DEBUG_SVR4 */
int
struct file *fp;
struct svr4_strbuf dat, ctl;
struct svr4_strmcmd sc;
- struct svr4_netaddr *na;
+ struct sockaddr_in sain;
+ struct sockaddr_un saun;
+ void *skp, *sup;
+ int sasize;
struct socket *so;
struct svr4_strm *st;
int error;
- struct sockaddr_in sa, *sap;
caddr_t sg;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
return EBADF;
#ifdef DEBUG_SVR4
- svr4_showmsg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl),
- SCARG(uap, dat), SCARG(uap, flags));
+ show_msg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl),
+ SCARG(uap, dat), SCARG(uap, flags));
#endif /* DEBUG_SVR4 */
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
return error;
- if (sc.len != sizeof(sa)) {
- DPRINTF(("putmsg: Cannot handle variable address lengths\n"));
+ switch (st->s_family) {
+ case AF_INET:
+ if (sc.len != sizeof(sain)) {
+ DPRINTF(("putmsg: Invalid inet length %ld\n", sc.len));
+ return ENOSYS;
+ }
+ netaddr_to_sockaddr_in(&sain, &sc);
+ skp = &sain;
+ sasize = sizeof(sain);
+ error = sain.sin_family != st->s_family;
+ break;
+
+ case AF_UNIX:
+ {
+ /* We've been given a device/inode pair */
+ dev_t *dev = SVR4_ADDROF(&sc);
+ ino_t *ino = (ino_t *) &dev[1];
+ if ((skp = svr4_find_socket(p, fp, *dev, *ino)) == NULL)
+ return ENOENT;
+ sasize = sizeof(saun);
+ }
+ break;
+
+ default:
+ DPRINTF(("putmsg: Unsupported address family %d\n",
+ st->s_family));
return ENOSYS;
}
- na = SVR4_ADDROF(&sc);
- bzero(&sa, sizeof(sa));
- sa.sin_family = na->family;
- sa.sin_port = na->port;
- sa.sin_addr.s_addr = na->addr;
-
sg = stackgap_init(p->p_emul);
- sap = (struct sockaddr_in *) stackgap_alloc(&sg,
- sizeof(struct sockaddr_in));
+ sup = stackgap_alloc(&sg, sasize);
- if ((error = copyout(&sa, sap, sizeof(sa))) != 0)
+ if ((error = copyout(skp, sup, sasize)) != 0)
return error;
switch (st->s_cmd = sc.cmd) {
struct sys_connect_args co;
co.s = SCARG(uap, fd);
- co.name = (caddr_t) sap;
- co.namelen = (int) sizeof(sa);
+ co.name = (caddr_t) sup;
+ co.namelen = (int) sasize;
return sys_connect(p, &co, retval);
}
{
struct msghdr msg;
struct iovec aiov;
- msg.msg_name = (caddr_t) sap;
- msg.msg_namelen = sizeof(sa);
+ msg.msg_name = (caddr_t) sup;
+ msg.msg_namelen = sasize;
msg.msg_iov = &aiov;
msg.msg_iovlen = 1;
msg.msg_control = 0;
-#ifdef COMPAT_OLDSOCK
msg.msg_flags = 0;
-#endif /* COMPAT_OLDSOCK */
aiov.iov_base = dat.buf;
aiov.iov_len = dat.len;
error = sendit(p, SCARG(uap, fd), &msg,
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct sys_getpeername_args ga;
+ struct sys_accept_args aa;
struct svr4_strbuf dat, ctl;
struct svr4_strmcmd sc;
- struct svr4_netaddr *na;
int error;
struct msghdr msg;
struct iovec aiov;
- struct sockaddr_in sa, *sap;
+ struct sockaddr_in sain;
+ struct sockaddr_un saun;
+ void *skp, *sup;
+ int sasize;
struct socket *so;
struct svr4_strm *st;
int *flen;
bzero(&sc, sizeof(sc));
#ifdef DEBUG_SVR4
- svr4_showmsg(">getmsg", SCARG(uap, fd), SCARG(uap, ctl),
- SCARG(uap, dat), 0);
+ show_msg(">getmsg", SCARG(uap, fd), SCARG(uap, ctl),
+ SCARG(uap, dat), 0);
#endif /* DEBUG_SVR4 */
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
return ENOSYS;
}
+ switch (st->s_family) {
+ case AF_INET:
+ skp = &sain;
+ sasize = sizeof(sain);
+ break;
+
+ case AF_UNIX:
+ skp = &saun;
+ sasize = sizeof(saun);
+ break;
+
+ default:
+ DPRINTF(("getmsg: Unsupported address family %d\n",
+ st->s_family));
+ return ENOSYS;
+ }
+
sg = stackgap_init(p->p_emul);
- sap = (struct sockaddr_in *) stackgap_alloc(&sg,
- sizeof(struct sockaddr_in));
+ sup = stackgap_alloc(&sg, sasize);
flen = (int *) stackgap_alloc(&sg, sizeof(*flen));
- fl = sizeof(sa);
+ fl = sasize;
if ((error = copyout(&fl, flen, sizeof(fl))) != 0)
return error;
-
switch (st->s_cmd) {
case SVR4_TI_CONNECT_REQUEST:
/*
* an connect verification.
*/
SCARG(&ga, fdes) = SCARG(uap, fd);
- SCARG(&ga, asa) = (caddr_t) sap;
+ SCARG(&ga, asa) = (caddr_t) sup;
SCARG(&ga, alen) = flen;
if ((error = sys_getpeername(p, &ga, retval)) != 0) {
return error;
}
- if ((error = copyin(sap, &sa, sizeof(sa))) != 0)
+ if ((error = copyin(sup, skp, sasize)) != 0)
return error;
sc.cmd = SVR4_TI_CONNECT_REPLY;
- sc.len = sizeof(struct sockaddr_in);
+ sc.len = sasize;
sc.offs = 0x18;
sc.pad[0] = 0x4;
sc.pad[1] = 0x14;
sc.pad[2] = 0x04000402;
- na = SVR4_ADDROF(&sc);
- na->family = sa.sin_family;
- na->port = sa.sin_port;
- na->addr = sa.sin_addr.s_addr;
+ switch (st->s_family) {
+ case AF_INET:
+ sockaddr_to_netaddr_in(&sc, &sain);
+ break;
+
+ case AF_UNIX:
+ sockaddr_to_netaddr_un(&sc, &saun);
+ break;
+
+ default:
+ return ENOSYS;
+ }
+
+ ctl.len = 40;
+ dat.len = -1;
+ fl = 0;
+ break;
+
+ case SVR4_TI_ACCEPT_REPLY:
+ /*
+ * We are after a listen, so we try to accept...
+ */
+ SCARG(&aa, s) = SCARG(uap, fd);
+ SCARG(&aa, name) = (caddr_t) sup;
+ SCARG(&aa, anamelen) = flen;
+
+ if ((error = sys_accept(p, &aa, retval)) != 0) {
+ DPRINTF(("getmsg: getpeername failed %d\n", error));
+ return error;
+ }
+
+ if ((error = copyin(sup, skp, sasize)) != 0)
+ return error;
+
+ sc.cmd = SVR4_TI_ACCEPT_REPLY;
+ sc.len = sasize;
+ sc.offs = 0x18;
+ sc.pad[0] = 0x0;
+ sc.pad[1] = 0x28;
+ sc.pad[2] = 0x3;
+
+ switch (st->s_family) {
+ case AF_INET:
+ sockaddr_to_netaddr_in(&sc, &sain);
+ break;
+
+ case AF_UNIX:
+ sockaddr_to_netaddr_un(&sc, &saun);
+ break;
+
+ default:
+ return ENOSYS;
+ }
ctl.len = 40;
dat.len = -1;
if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
return error;
+ switch (st->s_family) {
+ case AF_INET:
+ sockaddr_to_netaddr_in(&sc, &sain);
+ break;
- na = SVR4_ADDROF(&sc);
-
- bzero(&sa, sizeof(sa));
- sa.sin_family = na->family;
- sa.sin_port = na->port;
- sa.sin_addr.s_addr = na->addr;
+ case AF_UNIX:
+ sockaddr_to_netaddr_un(&sc, &saun);
+ break;
- if ((error = copyout(&sa, sap, sizeof(sa))) != 0)
- return error;
+ default:
+ return ENOSYS;
+ }
- msg.msg_name = (caddr_t) sap;
- msg.msg_namelen = sizeof(sa);
+ msg.msg_name = (caddr_t) sup;
+ msg.msg_namelen = sasize;
msg.msg_iov = &aiov;
msg.msg_iovlen = 1;
msg.msg_control = 0;
error = recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen, retval);
if (error) {
- DPRINTF(("getmsg: recvit failed %d\n", error))
+ DPRINTF(("getmsg: recvit failed %d\n", error));
return error;
}
-
- if ((error = copyin(msg.msg_name, &sa, sizeof(sa))) != 0)
+ if ((error = copyin(msg.msg_name, skp, sasize)) != 0)
return error;
sc.cmd = SVR4_TI_RECVFROM_REPLY;
- sc.len = sizeof(sa);
+ sc.len = sasize;
+
+ switch (st->s_family) {
+ case AF_INET:
+ sockaddr_to_netaddr_in(&sc, &sain);
+ break;
+
+ case AF_UNIX:
+ sockaddr_to_netaddr_un(&sc, &saun);
+ break;
- na->family = sa.sin_family;
- na->port = sa.sin_port;
- na->addr = sa.sin_addr.s_addr;
+ default:
+ return ENOSYS;
+ }
dat.len = *retval;
fl = 0;
return EINVAL;
}
-
st->s_cmd = sc.cmd;
if (SCARG(uap, ctl)) {
if (ctl.len != -1)
*retval = 0;
#ifdef DEBUG_SVR4
- svr4_showmsg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl),
- SCARG(uap, dat), fl);
+ show_msg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl),
+ SCARG(uap, dat), fl);
#endif /* DEBUG_SVR4 */
return error;
}
-/* $NetBSD: svr4_stropts.h,v 1.5 1995/10/07 06:27:53 mycroft Exp $ */
+/* $OpenBSD: svr4_stropts.h,v 1.2 1996/04/21 22:18:31 deraadt Exp $ */
+/* $NetBSD: svr4_stropts.h,v 1.6 1996/04/11 12:50:31 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
* streams state.
*/
struct svr4_strm {
- int s_cmd; /* last getmsg reply or putmsg request */
+ int s_family; /* socket family */
+ int s_cmd; /* last getmsg reply or putmsg request */
};
/*
long provider;
};
-struct svr4_netaddr {
+struct svr4_netaddr_in {
u_short family;
u_short port;
u_long addr;
};
-#define SVR4_ADDROF(sc) (struct svr4_netaddr *) (((char *) (sc)) + (sc)->offs)
+struct svr4_netaddr_un {
+ u_short family;
+ char path[1];
+};
+
+#define SVR4_ADDROF(sc) (void *) (((char *) (sc)) + (sc)->offs)
#endif /* !_SVR4_STROPTS */
* System call numbers.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp
+ * created from OpenBSD: syscalls.master,v 1.4 1996/02/26 23:32:08 niklas Exp
*/
#define SVR4_SYS_syscall 0
* System call argument lists.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp
+ * created from OpenBSD: syscalls.master,v 1.4 1996/02/26 23:32:08 niklas Exp
*/
#define syscallarg(x) union { x datum; register_t pad; }
* System call names.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp
+ * created from OpenBSD: syscalls.master,v 1.4 1996/02/26 23:32:08 niklas Exp
*/
char *svr4_syscallnames[] = {
* System call switch table.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp
+ * created from OpenBSD: syscalls.master,v 1.4 1996/02/26 23:32:08 niklas Exp
*/
#include <sys/param.h>
-/* $OpenBSD: svr4_termios.c,v 1.5 1996/04/19 09:38:59 niklas Exp $ */
-/* $NetBSD: svr4_termios.c,v 1.8 1996/03/30 22:38:23 christos Exp $ */
+/* $OpenBSD: svr4_termios.c,v 1.6 1996/04/21 22:18:38 deraadt Exp $ */
+/* $NetBSD: svr4_termios.c,v 1.9 1996/04/11 12:53:48 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
}
int
-svr4_termioctl(fp, cmd, data, p, retval)
+svr4_term_ioctl(fp, p, retval, fd, cmd, data)
struct file *fp;
- u_long cmd;
- caddr_t data;
struct proc *p;
register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t data;
{
struct termios bt;
struct svr4_termios st;
}
default:
- DPRINTF(("Unknown svr4 termios %lx\n", cmd));
- return ENOSYS;
+ return svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, data);
}
}
-/* $NetBSD: svr4_timod.h,v 1.3 1995/01/10 00:04:11 christos Exp $ */
+/* $OpenBSD: svr4_timod.h,v 1.2 1996/04/21 22:18:39 deraadt Exp $ */
+/* $NetBSD: svr4_timod.h,v 1.4 1996/04/11 12:52:03 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#define SVR4_TI_BIND_REQUEST 0x06
#define SVR4_TI_SENDTO_REQUEST 0x08
+#define SVR4_TI_ACCEPT_REPLY 0x0b
#define SVR4_TI_CONNECT_REPLY 0x0c
#define SVR4_TI_INFO_REPLY 0x10
#define SVR4_TI_BIND_REPLY 0x11
-/* $NetBSD: svr4_ttold.c,v 1.8 1996/03/30 22:38:27 christos Exp $ */
+/* $OpenBSD: svr4_ttold.c,v 1.4 1996/04/21 22:18:40 deraadt Exp $ */
+/* $NetBSD: svr4_ttold.c,v 1.9 1996/04/11 12:54:45 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
int
-svr4_ttoldioctl(fp, cmd, data, p, retval)
+svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
struct file *fp;
- u_long cmd;
- caddr_t data;
struct proc *p;
register_t *retval;
+ int fd;
+ u_long cmd;
+ caddr_t data;
{
int error;
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
-/* $NetBSD: svr4_util.h,v 1.7 1995/06/24 20:29:31 christos Exp $ */
+/* $OpenBSD: svr4_util.h,v 1.2 1996/04/21 22:18:41 deraadt Exp $ */
+/* $NetBSD: svr4_util.h,v 1.8 1996/04/11 12:41:25 christos Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#include <compat/common/compat_util.h>
#ifdef DEBUG_SVR4
-#define DPRINTF(a) printf a;
+#define DPRINTF(a) uprintf a;
#else
#define DPRINTF(a)
#endif
- $OpenBSD: syscalls.master,v 1.4 1996/02/26 23:32:08 niklas Exp $
- $NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp $
+ $OpenBSD: syscalls.master,v 1.5 1996/04/21 22:18:42 deraadt Exp $
+; $NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
-/* $OpenBSD: ultrix_fs.c,v 1.2 1996/04/18 21:21:49 niklas Exp $ */
-/* $NetBSD: ultrix_fs.c,v 1.3 1996/02/19 15:41:39 pk Exp $ */
+/* $OpenBSD: ultrix_fs.c,v 1.3 1996/04/21 22:18:45 deraadt Exp $ */
+/* $NetBSD: ultrix_fs.c,v 1.4 1996/04/07 17:23:06 jonathan Exp $ */
/*
* Copyright (c) 1995
tem->ufsd_fstype = ULTRIX_FSTYPE_ULTRIX;
tem->ufsd_gtot = sp->f_files; /* total "gnodes" */
- tem->ufsd_gfree = sp->f_ffree; /* free "gnodes"/
+ tem->ufsd_gfree = sp->f_ffree; /* free "gnodes" */
tem->ufsd_btot = sp->f_blocks; /* total 1k blocks */
- /*tem->ufsd_bfree = sp->f_bfree; /* free 1k blocks */
- /*tem->ufsd_bfree = sp->f_bavail; /* free 1k blocks */
+#ifdef needsmorethought /* XXX */
+ /* tem->ufsd_bfree = sp->f_bfree; */ /* free 1k blocks */
+ /* tem->ufsd_bfree = sp->f_bavail; */ /* free 1k blocks */
+#endif
+
tem->ufsd_bfreen = sp->f_bavail; /* blocks available to users */
tem->ufsd_pgthresh = 0; /* not relevant */
tem->ufsd_uid = 0; /* XXX kept where ?*/
* provided.
*/
MALLOC(path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
- if (error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL))
+ if ((error = copyinstr(SCARG(uap, path), path,
+ MAXPATHLEN, NULL)) != 0)
goto bad;
maxcount = 1;
} else {
* Find out how many mount list entries to skip, and skip
* them.
*/
- if (error =
- copyin((caddr_t)SCARG(uap, start), &start,
- sizeof(*SCARG(uap, start))))
+ if ((error = copyin((caddr_t)SCARG(uap, start), &start,
+ sizeof(*SCARG(uap, start)))) != 0)
goto bad;
for (skip = start, mp = mountlist.cqh_first;
mp != (void*)&mountlist && skip-- > 0; mp = nmp)
if (path == NULL ||
strcmp(path, sp->f_mntonname) == 0) {
make_ultrix_mntent(sp, &tem);
- if (error =
- copyout((caddr_t)&tem, sfsp, sizeof(tem)))
+ if ((error = copyout((caddr_t)&tem, sfsp,
+ sizeof(tem))) != 0)
goto bad;
sfsp++;
count++;
/* Copy string-ified version of mount type back out to user space */
SCARG(&nuap, type) = (char *)usp;
- if (error = copyout(fstype, SCARG(&nuap, type), strlen(fstype)+1)) {
+ if ((error = copyout(fstype, SCARG(&nuap, type),
+ strlen(fstype)+1)) != 0) {
return (error);
}
usp += strlen(fstype)+1;
if (otype == ULTRIX_FSTYPE_ULTRIX) {
/* attempt to mount a native, rather than 4.2bsd, ffs */
struct ufs_args ua;
- struct nameidata nd;
ua.fspec = SCARG(uap, special);
bzero(&ua.export, sizeof(ua.export));
SCARG(&nuap, data) = usp;
- if (error = copyout(&ua, SCARG(&nuap, data), sizeof ua)) {
+ if ((error = copyout(&ua, SCARG(&nuap, data),
+ sizeof ua)) !=0) {
return(error);
}
/*
* and if so, set MNT_UPDATE so we can mount / read-write.
*/
fsname[0] = 0;
- if (error = copyinstr((caddr_t)SCARG(&nuap, path), fsname,
- sizeof fsname, (u_int*)0))
+ if ((error = copyinstr((caddr_t)SCARG(&nuap, path), fsname,
+ sizeof fsname, (u_int*)0)) != 0)
return(error);
if (strcmp(fsname, "/") == 0) {
SCARG(&nuap, flags) |= MNT_UPDATE;
bzero(&osa, sizeof(osa));
bzero(&una, sizeof(una));
- if (error = copyin(SCARG(uap, data), &una, sizeof una)) {
+ if ((error = copyin(SCARG(uap, data), &una, sizeof una)) !=0) {
return (error);
}
/*
* address of the server passes, so do backwards
* compatibility on 4.3style sockaddrs here.
*/
- if (error = copyin(una.addr, &osa, sizeof osa)) {
+ if ((error = copyin(una.addr, &osa, sizeof osa)) != 0) {
printf("ultrix_mount: nfs copyin osa\n");
return (error);
}
na.timeo = una.timeo;
na.retrans = una.retrans;
na.hostname = una.hostname;
- if (error = copyout(sap, na.addr, sizeof (*sap) ))
+ if ((error = copyout(sap, na.addr, sizeof (*sap) )) != 0)
return (error);
- if (error = copyout(&na, SCARG(&nuap, data), sizeof na))
+ if ((error = copyout(&na, SCARG(&nuap, data), sizeof na)) != 0)
return (error);
}
return (sys_mount(p, &nuap, retval));
-/* $NetBSD: ultrix_ioctl.c,v 1.2 1996/01/04 19:03:32 jonathan Exp $ */
+/* $NetBSD: ultrix_ioctl.c,v 1.3 1996/04/07 17:23:08 jonathan Exp $ */
/* from : NetBSD: sunos_ioctl.c,v 1.21 1995/10/07 06:27:31 mycroft Exp */
/*
#else
result= (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA,
(caddr_t)&bts, p);
- printf("ultrix TCSETA %x returns %d\n",
+ printf("ultrix TCSETA %lx returns %d\n",
ULTRIX_TCSETA - SCARG(uap, com), result);
return result;
#endif
{
struct termios bts;
struct ultrix_termios sts;
- int result;
if ((error = copyin (SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0)
case _IOW('t', 32, int): { /* TIOCTCNTL */
int error, on;
- if (error = copyin (SCARG(uap, data), (caddr_t)&on, sizeof (on)))
+ error = copyin (SCARG(uap, data), (caddr_t)&on, sizeof (on));
+ if (error != 0)
return error;
return (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p);
}
case _IOW('t', 33, int): { /* TIOCSIGNAL */
int error, sig;
- if (error = copyin (SCARG(uap, data), (caddr_t)&sig, sizeof (sig)))
+ error = copyin (SCARG(uap, data), (caddr_t)&sig, sizeof (sig));
+ if (error != 0)
return error;
return (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p);
}
/*
* Socket ioctl translations.
*/
+#define IN_TYPE(a, type_t) { \
+ type_t localbuf; \
+ if ((error = copyin (SCARG(uap, data), \
+ (caddr_t)&localbuf, sizeof (type_t))) != 0) \
+ return error; \
+ return (*ctl)(fp, a, (caddr_t)&localbuf, p); \
+}
+
+#define INOUT_TYPE(a, type_t) { \
+ type_t localbuf; \
+ if ((error = copyin (SCARG(uap, data), (caddr_t)&localbuf, \
+ sizeof (type_t))) != 0) \
+ return error; \
+ if ((error = (*ctl)(fp, a, (caddr_t)&localbuf, p)) != 0) \
+ return error; \
+ return copyout ((caddr_t)&localbuf, SCARG(uap, data), sizeof (type_t)); \
+}
+
+
#define IFREQ_IN(a) { \
struct ifreq ifreq; \
- if (error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) \
+ if ((error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) != 0) \
return error; \
return (*ctl)(fp, a, (caddr_t)&ifreq, p); \
}
+
#define IFREQ_INOUT(a) { \
struct ifreq ifreq; \
- if (error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) \
+ if ((error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) != 0) \
return error; \
- if (error = (*ctl)(fp, a, (caddr_t)&ifreq, p)) \
+ if ((error = (*ctl)(fp, a, (caddr_t)&ifreq, p)) != 0) \
return error; \
return copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
}
* 1. our sockaddr's are variable length, not always sizeof(sockaddr)
* 2. this returns a name per protocol, ie. it returns two "lo0"'s
*/
- if (error = copyin (SCARG(uap, data), (caddr_t)&ifconf,
- sizeof (ifconf)))
+ if ((error = copyin (SCARG(uap, data), (caddr_t)&ifconf,
+ sizeof (ifconf))) != 0)
return error;
- if (error = (*ctl)(fp, OSIOCGIFCONF, (caddr_t)&ifconf, p))
+ if ((error = (*ctl)(fp, OSIOCGIFCONF,
+ * (caddr_t)&ifconf, p)) !=0 )
return error;
return copyout ((caddr_t)&ifconf, SCARG(uap, data),
sizeof (ifconf));
-/* $OpenBSD: ultrix_misc.c,v 1.6 1996/04/18 21:21:50 niklas Exp $ */
-/* $NetBSD: ultrix_misc.c,v 1.21 1996/02/19 15:41:38 pk Exp $ */
+/* $OpenBSD: ultrix_misc.c,v 1.7 1996/04/21 22:18:48 deraadt Exp $ */
+/* $NetBSD: ultrix_misc.c,v 1.23 1996/04/07 17:23:04 jonathan Exp $ */
+
+/*
+ * Copyright (c) 1995
+ * Jonathan Stone (hereinafter referred to as the author)
+ *
+ * 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.
+ */
/*
* Copyright (c) 1992, 1993
#include <vm/vm.h>
+#include <sys/conf.h> /* iszerodev() */
+#include <sys/socketvar.h> /* sosetopt() */
+
extern struct sysent ultrix_sysent[];
extern char *ultrix_syscallnames[];
-extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
+
+/*
+ * Select the appropriate setregs callback for the target architecture.
+ */
+#ifdef mips
+#define ULTRIX_EXEC_SETREGS cpu_exec_ecoff_setregs
+#endif /* mips */
+
+#ifdef vax
+#define ULTRIX_EXEC_SETREGS setregs
+#endif /* mips */
+
+
+extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *,
u_long, register_t *));
extern char sigcode[], esigcode[];
ultrix_syscallnames,
0,
copyargs,
- cpu_exec_ecoff_setregs,
+ ULTRIX_EXEC_SETREGS,
sigcode,
esigcode,
};
#define GSI_PROG_ENV 1
+int
ultrix_sys_getsysinfo(p, v, retval)
struct proc *p;
void *v;
}
}
+int
ultrix_sys_setsysinfo(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
+
+#ifdef notyet
struct ultrix_sys_setsysinfo_args *uap = v;
+#endif
+
*retval = 0;
return 0;
}
+int
ultrix_sys_waitpid(p, v, retval)
struct proc *p;
void *v;
return (sys_wait4(p, &ua, retval));
}
+int
ultrix_sys_wait3(p, v, retval)
struct proc *p;
void *v;
/*
* Ultrix binaries pass in FD_MAX as the first arg to select().
- * On Ultrix, that is 4096, which is more than the NetBSD sys_select()
+ * On Ultrix, FD_MAX is 4096, which is more than the NetBSD sys_select()
* can handle.
+ * Since we can't have more than the (native) FD_MAX descriptors open,
+ * limit nfds to at most FD_MAX.
*/
+int
ultrix_sys_select(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct sys_select_args *uap = v;
- struct timeval atv, *tvp;
+ struct timeval atv;
int error;
/* Limit number of FDs selected on to the native maximum */
#ifdef DEBUG
/* Ultrix clients sometimes give negative timeouts? */
if (atv.tv_sec < 0 || atv.tv_usec < 0)
- printf("ultrix select( %d, %d)\n",
+ printf("ultrix select( %ld, %ld): negative timeout\n",
atv.tv_sec, atv.tv_usec);
/*tvp = (timeval *)STACKGAPBASE;*/
#endif
}
#if defined(NFSCLIENT)
+int
async_daemon(p, v, retval)
struct proc *p;
void *v;
}
#endif /* NFSCLIENT */
-#if 0
-/* XXX: Temporary until sys/dir.h, include/dirent.h and sys/dirent.h are fixed */
-struct dirent {
- u_long d_fileno; /* file number of entry */
- u_short d_reclen; /* length of this record */
- u_short d_namlen; /* length of string in d_name */
- char d_name[255 + 1]; /* name must be no longer than this */
-};
-#endif
#define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
return (sys_mmap(p, &ouap, retval));
}
+int
ultrix_sys_setsockopt(p, v, retval)
struct proc *p;
void *v;
struct mbuf *m = NULL;
int error;
- if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
#define SO_DONTLINGER (~SO_LINGER)
if (SCARG(uap, name) == SO_DONTLINGER) {
m = m_get(M_WAIT, MT_SOOPTS);
if (m == NULL)
return (ENOBUFS);
- if (error = copyin(SCARG(uap, val), mtod(m, caddr_t),
- (u_int)SCARG(uap, valsize))) {
+ if ((error = copyin(SCARG(uap, val), mtod(m, caddr_t),
+ (u_int)SCARG(uap, valsize))) != 0) {
(void) m_free(m);
return (error);
}
void *v;
register_t *retval;
{
+
+#if 0 /* XXX */
struct ultrix_sys_nfssvc_args *uap = v;
struct emul *e = p->p_emul;
struct sys_nfssvc_args outuap;
struct sockaddr sa;
int error;
-#if 0
bzero(&outuap, sizeof outuap);
SCARG(&outuap, fd) = SCARG(uap, fd);
SCARG(&outuap, mskval) = STACKGAPBASE;
* How do we translate dev -> fstat? (and then to ultrix_ustat)
*/
- if (error = copyout(&us, SCARG(uap, buf), sizeof us))
+ if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0)
return (error);
return 0;
}
void *v;
register_t *retval;
{
+
+#ifdef notyet
struct ultrix_sys_quotactl_args *uap = v;
+#endif
return EINVAL;
}
void *v;
register_t *retval;
{
+#ifdef notyet
struct ultrix_sys_exportfs_args *uap = v;
+#endif
/*
* XXX: should perhaps translate into a mount(2)
-/* $NetBSD: ultrix_pathname.c,v 1.1 1996/01/07 13:38:52 jonathan Exp $ */
+/* $NetBSD: ultrix_pathname.c,v 1.2 1996/04/07 17:23:07 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
ULTRIX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
+
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
- if (error = VFS_STATFS(mp, sp, p))
+ if ((error = VFS_STATFS(mp, sp, p)) != 0)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return ultrixstatfs(sp, (caddr_t)SCARG(uap, buf));
register struct statfs *sp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if (error = VFS_STATFS(mp, sp, p))
+ if ((error = VFS_STATFS(mp, sp, p)) != 0)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return ultrixstatfs(sp, (caddr_t)SCARG(uap, buf));
-# $OpenBSD: files,v 1.14 1996/04/19 16:08:25 niklas Exp $
+# $OpenBSD: files,v 1.15 1996/04/21 22:18:51 deraadt Exp $
# $NetBSD: files,v 1.82 1996/03/19 01:02:35 paulus Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
file isofs/cd9660/cd9660_vnops.c cd9660
file kern/exec_aout.c
file kern/exec_conf.c
-file kern/exec_ecoff.c compat_ultrix compat_osf1 exec_ecoff
-file kern/exec_elf.c compat_svr4 compat_linux
+file kern/exec_ecoff.c compat_ultrix | compat_osf1 | exec_ecoff
+file kern/exec_elf.c compat_svr4 | compat_linux
file kern/exec_script.c
file kern/exec_subr.c
file kern/init_main.c
file kern/sys_process.c
file kern/sys_socket.c
file kern/syscalls.c syscall_debug
-file kern/sysv_ipc.c sysvshm sysvsem sysvmsg
+file kern/sysv_ipc.c sysvshm | sysvsem | sysvmsg
file kern/sysv_msg.c sysvmsg
file kern/sysv_sem.c sysvsem
file kern/sysv_shm.c sysvshm
file msdosfs/msdosfs_vfsops.c msdosfs
file msdosfs/msdosfs_vnops.c msdosfs
file net/bpf.c bpfilter needs-count
-file net/bpf_filter.c bpfilter ppp
+file net/bpf_filter.c bpfilter | ppp
file net/if.c
file net/if_arcsubr.c arc needs-flag
-file net/if_ethersubr.c ether fddi needs-flag
+file net/if_ethersubr.c ether | fddi needs-flag
file net/if_fddisubr.c fddi
file net/if_loop.c loop needs-count
file net/if_sl.c sl needs-count
file net/raw_usrreq.c
file net/route.c
file net/rtsock.c
-file net/slcompress.c sl ppp
+file net/slcompress.c sl | ppp
file netccitt/ccitt_proto.c ccitt
file netccitt/hd_debug.c hdlc
file netccitt/hd_input.c hdlc
file netccitt/pk_acct.c ccitt
file netccitt/pk_debug.c ccitt
file netccitt/pk_input.c ccitt
-file netccitt/pk_llcsubr.c llc hdlc
+file netccitt/pk_llcsubr.c llc | hdlc
file netccitt/pk_output.c ccitt
file netccitt/pk_subr.c ccitt
file netccitt/pk_timer.c ccitt
file netiso/iso_pcb.c iso
file netiso/iso_proto.c iso
file netiso/iso_snpac.c iso
-file netiso/tp_astring.c iso tpip
+file netiso/tp_astring.c iso | tpip
file netiso/tp_cons.c iso
-file netiso/tp_driver.c iso tpip
-file netiso/tp_emit.c iso tpip
-file netiso/tp_inet.c iso tpip
-file netiso/tp_input.c iso tpip
+file netiso/tp_driver.c iso | tpip
+file netiso/tp_emit.c iso | tpip
+file netiso/tp_inet.c iso | tpip
+file netiso/tp_input.c iso | tpip
file netiso/tp_iso.c iso
-file netiso/tp_meas.c iso tpip
-file netiso/tp_output.c iso tpip
-file netiso/tp_pcb.c iso tpip
-file netiso/tp_subr.c iso tpip
-file netiso/tp_subr2.c iso tpip
-file netiso/tp_timer.c iso tpip
-file netiso/tp_trace.c iso tpip
-file netiso/tp_usrreq.c iso tpip
-file netiso/tuba_subr.c iso tuba
-file netiso/tuba_table.c iso tuba
-file netiso/tuba_usrreq.c iso tuba
+file netiso/tp_meas.c iso | tpip
+file netiso/tp_output.c iso | tpip
+file netiso/tp_pcb.c iso | tpip
+file netiso/tp_subr.c iso | tpip
+file netiso/tp_subr2.c iso | tpip
+file netiso/tp_timer.c iso | tpip
+file netiso/tp_trace.c iso | tpip
+file netiso/tp_usrreq.c iso | tpip
+file netiso/tuba_subr.c iso | tuba
+file netiso/tuba_table.c iso | tuba
+file netiso/tuba_usrreq.c iso | tuba
file netns/idp_usrreq.c ns
file netns/ns.c ns
file netns/ns_error.c ns
file nfs/nfs_bio.c nfsclient
file nfs/nfs_boot.c nfsclient
file nfs/nfs_node.c nfsclient
-file nfs/nfs_nqlease.c nfsserver nfsclient
+file nfs/nfs_nqlease.c nfsserver | nfsclient
file nfs/nfs_serv.c nfsserver
-file nfs/nfs_socket.c nfsserver nfsclient
+file nfs/nfs_socket.c nfsserver | nfsclient
file nfs/nfs_srvcache.c nfsserver
-file nfs/nfs_subs.c nfsserver nfsclient
-file nfs/nfs_syscalls.c nfsserver nfsclient
+file nfs/nfs_subs.c nfsserver | nfsclient
+file nfs/nfs_syscalls.c nfsserver | nfsclient
file nfs/nfs_vfsops.c nfsclient
file nfs/nfs_vnops.c nfsclient
-file ufs/ffs/ffs_alloc.c ffs mfs
-file ufs/ffs/ffs_balloc.c ffs mfs
-file ufs/ffs/ffs_inode.c ffs mfs
-file ufs/ffs/ffs_subr.c ffs mfs
-file ufs/ffs/ffs_tables.c ffs mfs
-file ufs/ffs/ffs_vfsops.c ffs mfs
-file ufs/ffs/ffs_vnops.c ffs mfs
+file ufs/ffs/ffs_alloc.c ffs | mfs
+file ufs/ffs/ffs_balloc.c ffs | mfs
+file ufs/ffs/ffs_inode.c ffs | mfs
+file ufs/ffs/ffs_subr.c ffs | mfs
+file ufs/ffs/ffs_tables.c ffs | mfs
+file ufs/ffs/ffs_vfsops.c ffs | mfs
+file ufs/ffs/ffs_vnops.c ffs | mfs
file ufs/lfs/lfs_alloc.c lfs
file ufs/lfs/lfs_bio.c lfs
file ufs/lfs/lfs_balloc.c lfs
file ufs/lfs/lfs_vnops.c lfs
file ufs/mfs/mfs_vfsops.c mfs
file ufs/mfs/mfs_vnops.c mfs
-file ufs/ufs/ufs_bmap.c ffs lfs mfs
-file ufs/ufs/ufs_ihash.c ffs lfs mfs
-file ufs/ufs/ufs_inode.c ffs lfs mfs
-file ufs/ufs/ufs_lookup.c ffs lfs mfs
-file ufs/ufs/ufs_quota.c ffs lfs mfs
-file ufs/ufs/ufs_vfsops.c ffs lfs mfs
-file ufs/ufs/ufs_vnops.c ffs lfs mfs
+file ufs/ufs/ufs_bmap.c ffs | lfs | mfs
+file ufs/ufs/ufs_ihash.c ffs | lfs | mfs
+file ufs/ufs/ufs_inode.c ffs | lfs | mfs
+file ufs/ufs/ufs_lookup.c ffs | lfs | mfs
+file ufs/ufs/ufs_quota.c ffs | lfs | mfs
+file ufs/ufs/ufs_vfsops.c ffs | lfs | mfs
+file ufs/ufs/ufs_vnops.c ffs | lfs | mfs
file vm/device_pager.c devpager
file vm/kern_lock.c
file vm/swap_pager.c swappager
-/* $OpenBSD: db_access.c,v 1.4 1996/04/17 05:29:35 mickey Exp $ */
+/* $OpenBSD: db_access.c,v 1.5 1996/04/21 22:18:53 deraadt Exp $ */
+/* $NetBSD: db_access.c,v 1.8 1994/10/09 08:37:35 mycroft Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_access.h,v 1.3 1996/03/11 11:15:55 mickey Exp $ */
+/* $OpenBSD: db_access.h,v 1.4 1996/04/21 22:18:54 deraadt Exp $ */
+/* $NetBSD: db_access.h,v 1.6 1994/10/09 08:29:57 mycroft Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_break.c,v 1.3 1996/03/11 11:15:58 mickey Exp $ */
+/* $OpenBSD: db_break.c,v 1.4 1996/04/21 22:18:55 deraadt Exp $ */
+/* $NetBSD: db_break.c,v 1.7 1996/03/30 22:30:03 christos Exp $ */
/*
* Mach Operating System
bkpt != 0;
bkpt = bkpt->link)
{
- db_printf("%s%8x %5d ",
+ db_printf("%s%p %5d ",
db_map_current(bkpt->map) ? "*" : " ",
bkpt->map, bkpt->init_count);
db_printsym(bkpt->address, DB_STGY_PROC);
-/* $OpenBSD: db_break.h,v 1.3 1996/03/11 11:16:00 mickey Exp $ */
+/* $OpenBSD: db_break.h,v 1.4 1996/04/21 22:18:56 deraadt Exp $ */
+/* $NetBSD: db_break.h,v 1.8 1996/02/05 01:56:52 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_command.c,v 1.6 1996/04/19 16:08:30 niklas Exp $ */
-/* $NetBSD: db_command.c,v 1.19 1996/03/13 21:06:38 christos Exp $ */
+/* $OpenBSD: db_command.c,v 1.7 1996/04/21 22:18:57 deraadt Exp $ */
+/* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */
/*
* Mach Operating System
}
retval = (*func)(args[0], args[1], args[2], args[3], args[4],
- args[5], args[6], args[7], args[8], args[9] );
+ args[5], args[6], args[7], args[8], args[9]);
db_printf("%#n\n", retval);
}
-/* $OpenBSD: db_command.h,v 1.3 1996/03/11 11:16:03 mickey Exp $ */
+/* $OpenBSD: db_command.h,v 1.4 1996/04/21 22:18:58 deraadt Exp $ */
+/* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_examine.c,v 1.3 1996/03/11 11:16:05 mickey Exp $ */
+/* $OpenBSD: db_examine.c,v 1.4 1996/04/21 22:18:59 deraadt Exp $ */
+/* $NetBSD: db_examine.c,v 1.11 1996/03/30 22:30:07 christos Exp $ */
/*
* Mach Operating System
width = 12;
break;
case 'a': /* address */
- db_printf("= 0x%x\n", addr);
+ db_printf("= 0x%lx\n", addr);
break;
case 'r': /* signed, current radix */
value = db_get_value(addr, size, TRUE);
-/* $OpenBSD: db_expr.c,v 1.3 1996/03/11 11:16:06 mickey Exp $ */
+/* $OpenBSD: db_expr.c,v 1.4 1996/04/21 22:19:00 deraadt Exp $ */
+/* $NetBSD: db_expr.c,v 1.5 1996/02/05 01:56:58 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_input.c,v 1.3 1996/03/11 11:16:09 mickey Exp $ */
+/* $OpenBSD: db_input.c,v 1.4 1996/04/21 22:19:01 deraadt Exp $ */
+/* $NetBSD: db_input.c,v 1.7 1996/02/05 01:57:02 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_interface.h,v 1.2 1996/03/11 11:16:10 mickey Exp $ */
-/* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp & */
+/* $OpenBSD: db_interface.h,v 1.3 1996/04/21 22:19:02 deraadt Exp $ */
+/* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp $ */
/*
* Copyright (c) 1995 Christos Zoulas. All rights reserved.
-/* $OpenBSD: db_lex.c,v 1.3 1996/03/11 11:16:12 mickey Exp $ */
+/* $OpenBSD: db_lex.c,v 1.4 1996/04/21 22:19:03 deraadt Exp $ */
+/* $NetBSD: db_lex.c,v 1.8 1996/02/05 01:57:05 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_lex.h,v 1.3 1996/03/11 11:16:13 mickey Exp $ */
+/* $OpenBSD: db_lex.h,v 1.4 1996/04/21 22:19:04 deraadt Exp $ */
+/* $NetBSD: db_lex.h,v 1.7 1996/02/05 01:57:07 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_output.c,v 1.4 1996/03/11 11:16:15 mickey Exp $ */
+/* $OpenBSD: db_output.c,v 1.5 1996/04/21 22:19:05 deraadt Exp $ */
+/* $NetBSD: db_output.c,v 1.13 1996/04/01 17:27:14 christos Exp $ */
/*
* Mach Operating System
db_printf(const char *fmt, ...)
#else
db_printf(fmt, va_alist)
-/*###207 [cc] warning: type of `va_alist' defaults to `int'%%%*/
const char *fmt;
-/*###208 [cc] parse error before `va_dcl'%%%*/
va_dcl
#endif
{
width = -width;
}
goto reswitch;
+ case ':':
+ p = va_arg(ap, char *);
+ db_printf_guts (p, va_arg(ap, va_list));
+ break;
case 'c':
db_putchar(va_arg(ap, int));
break;
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
base = 8;
goto number;
+ case 'p':
+ db_putchar ('0');
+ db_putchar ('x');
+ ul = (u_long) va_arg(ap, void *);
+ base = 16;
+ goto number;
case 'u':
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
base = 10;
}
}
}
-
-/* $OpenBSD: db_output.h,v 1.4 1996/03/11 11:16:17 mickey Exp $ */
+/* $OpenBSD: db_output.h,v 1.5 1996/04/21 22:19:07 deraadt Exp $ */
+/* $NetBSD: db_output.h,v 1.9 1996/04/04 05:13:50 cgd Exp $ */
/*
* Mach Operating System
void db_force_whitespace __P((void));
void db_putchar __P((int));
int db_print_position __P((void));
-void db_printf __P((const char *, ...));
-void kdbprintf __P((const char *, ...));
+void db_printf __P((const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,1,2)));
+void kdbprintf __P((const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,1,2)));
void db_end_line __P((void));
-/* $OpenBSD: db_print.c,v 1.3 1996/03/11 11:16:18 mickey Exp $ */
+/* $OpenBSD: db_print.c,v 1.4 1996/04/21 22:19:08 deraadt Exp $ */
+/* $NetBSD: db_print.c,v 1.5 1996/02/05 01:57:11 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_run.c,v 1.3 1996/03/11 11:16:20 mickey Exp $ */
+/* $OpenBSD: db_run.c,v 1.4 1996/04/21 22:19:10 deraadt Exp $ */
+/* $NetBSD: db_run.c,v 1.8 1996/02/05 01:57:12 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_run.h,v 1.3 1996/03/11 11:16:21 mickey Exp $ */
+/* $OpenBSD: db_run.h,v 1.4 1996/04/21 22:19:12 deraadt Exp $ */
+/* $NetBSD: db_run.h,v 1.3 1996/02/05 01:57:14 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_sym.c,v 1.6 1996/03/30 04:51:28 mickey Exp $ */
+/* $OpenBSD: db_sym.c,v 1.7 1996/04/21 22:19:13 deraadt Exp $ */
+/* $NetBSD: db_sym.c,v 1.12 1996/02/05 01:57:15 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_sym.h,v 1.3 1996/03/11 11:16:25 mickey Exp $ */
+/* $OpenBSD: db_sym.h,v 1.4 1996/04/21 22:19:15 deraadt Exp $ */
+/* $NetBSD: db_sym.h,v 1.7 1996/02/05 01:57:16 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_trap.c,v 1.3 1996/03/11 11:16:26 mickey Exp $ */
+/* $OpenBSD: db_trap.c,v 1.4 1996/04/21 22:19:16 deraadt Exp $ */
+/* $NetBSD: db_trap.c,v 1.9 1996/02/05 01:57:18 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_variables.c,v 1.4 1996/03/30 04:51:30 mickey Exp $ */
+/* $OpenBSD: db_variables.c,v 1.5 1996/04/21 22:19:18 deraadt Exp $ */
+/* $NetBSD: db_variables.c,v 1.8 1996/02/05 01:57:19 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_variables.h,v 1.3 1996/03/11 11:16:30 mickey Exp $ */
+/* $OpenBSD: db_variables.h,v 1.4 1996/04/21 22:19:19 deraadt Exp $ */
+/* $NetBSD: db_variables.h,v 1.5 1996/02/05 01:57:21 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_watch.c,v 1.3 1996/03/11 11:16:31 mickey Exp $ */
+/* $OpenBSD: db_watch.c,v 1.4 1996/04/21 22:19:21 deraadt Exp $ */
+/* $NetBSD: db_watch.c,v 1.9 1996/03/30 22:30:12 christos Exp $ */
/*
* Mach Operating System
for (watch = db_watchpoint_list;
watch != 0;
watch = watch->link)
- db_printf("%s%8x %8x %x\n",
+ db_printf("%s%p %8lx %lx\n",
db_map_current(watch->map) ? "*" : " ",
watch->map, watch->loaddr,
watch->hiaddr - watch->loaddr);
-/* $OpenBSD: db_watch.h,v 1.3 1996/03/11 11:16:32 mickey Exp $ */
+/* $OpenBSD: db_watch.h,v 1.4 1996/04/21 22:19:22 deraadt Exp $ */
+/* $NetBSD: db_watch.h,v 1.9 1996/02/05 01:57:24 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: db_write_cmd.c,v 1.3 1996/03/11 11:16:33 mickey Exp $ */
+/* $OpenBSD: db_write_cmd.c,v 1.4 1996/04/21 22:19:27 deraadt Exp $ */
+/* $NetBSD: db_write_cmd.c,v 1.6 1996/02/05 01:57:25 christos Exp $ */
/*
* Mach Operating System
-/* $OpenBSD: audio.c,v 1.6 1996/04/18 23:46:55 niklas Exp $ */
-/* $NetBSD: audio.c,v 1.22 1996/03/14 19:08:32 christos Exp $ */
+/* $OpenBSD: audio.c,v 1.7 1996/04/21 22:19:38 deraadt Exp $ */
+/* $NetBSD: audio.c,v 1.24 1996/03/30 22:51:23 christos Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
#include <sys/syslog.h>
#include <sys/kernel.h>
#include <sys/signalvar.h>
+#include <sys/conf.h>
#include <sys/audioio.h>
#include <dev/audiovar.h>
#ifdef AUDIO_DEBUG
#include <machine/stdarg.h>
-#ifndef TOLOG
-#define TOLOG 0x04
-#endif
-void kprintf __P((const char *fmt, int flags, struct tty *tp, va_list ap));
void
#ifdef __STDC__
va_list ap;
va_start(ap, fmt);
- kprintf(fmt, TOLOG, NULL, ap);
+ log(LOG_DEBUG, "%:", fmt, ap);
va_end(ap);
}
void audio_printsc __P((struct audio_softc *));
void audioattach __P((int));
int audio_hardware_attach __P((struct audio_hw_if *, void *));
-int audioopen __P((dev_t, int, int, struct proc *));
-int audioclose __P((dev_t, int, int, struct proc *));
-int audioread __P((dev_t, struct uio *, int));
-int audiowrite __P((dev_t, struct uio *, int));
-int audioioctl __P((dev_t, int, caddr_t, int, struct proc *));
-int audioselect __P((dev_t, int, struct proc *));
void audio_init_ring __P((struct audio_buffer *, int));
void audio_initbufs __P((struct audio_softc *));
static __inline int audio_sleep_timo __P((int *, char *, int));
audio_printsc(sc)
struct audio_softc *sc;
{
- printf("hwhandle %x hw_if %x ", sc->hw_hdl, sc->hw_if);
+ printf("hwhandle %p hw_if %p ", sc->hw_hdl, sc->hw_if);
printf("open %x mode %x\n", sc->sc_open, sc->sc_mode);
printf("rchan %x wchan %x ", sc->sc_rchan, sc->sc_wchan);
printf("rring blk %x pring nblk %x\n", sc->rr.nblk, sc->pr.nblk);
int
audioioctl(dev, cmd, addr, flag, p)
dev_t dev;
- int cmd;
+ u_long cmd;
caddr_t addr;
int flag;
struct proc *p;
#ifdef AUDIO_DEBUG
if (audiodebug > 1) {
int left = cb->ep - tp;
- Dprintf("audio_write: cc=%d tp=0x%x bs=%d nblk=%d left=%d\n", cc, tp, blocksize, cb->nblk, left);
+ Dprintf("audio_write: cc=%d tp=%p bs=%d nblk=%d left=%d\n", cc, tp, blocksize, cb->nblk, left);
}
#endif
#ifdef DIAGNOSTIC
/* check for an overwrite. Should never happen */
if ((tp + towrite) > cb->ep) {
- DPRINTF(("audio_write: overwrite tp=0x%x towrite=%d ep=0x%x bs=%d\n",
+ DPRINTF(("audio_write: overwrite tp=%p towrite=%d ep=0x%x bs=%d\n",
tp, towrite, cb->ep, blocksize));
printf("audio_write: overwrite tp=%p towrite=%d ep=%p\n",
tp, towrite, cb->ep);
}
if (error) {
#ifdef AUDIO_DEBUG
- printf("audio_write:(1) uiomove failed %d; cc=%d tp=0x%x bs=%d\n", error, cc, tp, blocksize);
+ printf("audio_write:(1) uiomove failed %d; cc=%d tp=%p bs=%d\n", error, cc, tp, blocksize);
#endif
break;
}
{
int error;
- DPRINTF(("audiostartr: tp=0x%x\n", sc->rr.tp));
+ DPRINTF(("audiostartr: tp=%p\n", sc->rr.tp));
error = sc->hw_if->start_input(sc->hw_hdl, sc->rr.tp, sc->sc_blksize,
audio_rint, (void *)sc);
if (++cb->nblk < cb->maxblk) {
#ifdef AUDIO_DEBUG
if (audiodebug > 1)
- Dprintf("audio_rint: tp=0x%x cc=%d\n", tp, cc);
+ Dprintf("audio_rint: tp=%p cc=%d\n", tp, cc);
#endif
error = hw->start_input(sc->hw_hdl, tp, cc,
audio_rint, (void *)sc);
-/* $OpenBSD: ccd.c,v 1.9 1996/04/19 07:43:47 mickey Exp $ */
-/* $NetBSD: ccd.c,v 1.29 1996/03/07 15:00:11 christos Exp $ */
+/* $OpenBSD: ccd.c,v 1.10 1996/04/21 22:19:44 deraadt Exp $ */
+/* $NetBSD: ccd.c,v 1.31 1996/03/30 23:05:54 christos Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/cpu.h>
+#include <sys/conf.h>
#include <dev/ccdvar.h>
#ifdef DEBUG
if (ccddebug & CCDB_IO)
- printf("ccdbuffer(%p, %p, %d, %p, %d)\n",
+ printf("ccdbuffer(%p, %p, %d, %p, %ld)\n",
cs, bp, bn, addr, bcount);
#endif
/*
#ifdef DEBUG
if (ccddebug & CCDB_IO)
- printf(" dev %x(u%d): cbp %p bn %d addr %p bcnt %d\n",
+ printf(" dev %x(u%d): cbp %p bn %d addr %p bcnt %ld\n",
ci->ci_dev, ci-cs->sc_cinfo, cbp, cbp->cb_buf.b_blkno,
cbp->cb_buf.b_data, cbp->cb_buf.b_bcount);
#endif
if (cbp->cb_flags & CBF_MIRROR)
printf("ccdiodone: mirror component\n");
else
- printf("ccdiodone: bp %p bcount %d resid %d\n",
+ printf("ccdiodone: bp %p bcount %ld resid %ld\n",
bp, bp->b_bcount, bp->b_resid);
- printf(" dev %x(u%d), cbp %p bn %d addr %p bcnt %d\n",
+ printf(" dev %x(u%d), cbp %p bn %d addr %p bcnt %ld\n",
cbp->cb_buf.b_dev, cbp->cb_comp, cbp,
cbp->cb_buf.b_blkno, cbp->cb_buf.b_data,
cbp->cb_buf.b_bcount);
-/* $OpenBSD: cons.c,v 1.6 1996/04/18 04:05:39 mickey Exp $ */
-/* $NetBSD: cons.c,v 1.29 1996/02/04 02:04:08 christos Exp $ */
+/* $OpenBSD: cons.c,v 1.7 1996/04/21 22:19:48 deraadt Exp $ */
+/* $NetBSD: cons.c,v 1.30 1996/04/08 19:57:30 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
struct tty *tp;
int flag;
{
-
+ return (0);
}
int
+++ /dev/null
-/* $OpenBSD: dev_conf.h,v 1.1 1996/04/18 23:47:02 niklas Exp $ */
-/* $NetBSD: dev_conf.h,v 1.1 1996/03/07 15:00:13 christos Exp $ */
-
-/*
- * Copyright (c) 1995 Christos Zoulas. 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 Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/conf.h>
-
-#include "audio.h"
-cdev_decl(audio);
-
-cdev_decl(cn);
-
-#include "vnd.h"
-bdev_decl(vnd);
-cdev_decl(vnd);
-
-#include "ccd.h"
-bdev_decl(ccd);
-cdev_decl(ccd);
-/* $OpenBSD: aha1742.c,v 1.4 1996/04/18 23:47:09 niklas Exp $ */
-/* $NetBSD: aha1742.c,v 1.57 1996/03/08 22:03:26 cgd Exp $ */
+/* $OpenBSD: aha1742.c,v 1.5 1996/04/21 22:20:12 deraadt Exp $ */
+/* $NetBSD: aha1742.c,v 1.59 1996/04/09 22:47:00 cgd Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
struct ahb_softc {
struct device sc_dev;
- struct isadev sc_id;
- void *sc_ih;
bus_chipset_tag_t sc_bc;
- bus_io_handle_t sc_ioh;
+ eisa_chipset_tag_t sc_ec;
+ bus_io_handle_t sc_ioh;
int sc_irq;
+ void *sc_ih;
struct ahb_ecb *immed_ecb; /* an outstanding immediete command */
struct ahb_ecb *ecbhash[ECB_HASH_SIZE];
int ahbmatch __P((struct device *, void *, void *));
void ahbattach __P((struct device *, struct device *, void *));
-struct cfdriver ahbcd = {
- NULL, "ahb", ahbmatch, ahbattach, DV_DULL, sizeof(struct ahb_softc)
+struct cfattach ahb_ca = {
+ sizeof(struct ahb_softc), ahbmatch, ahbattach
+};
+
+struct cfdriver ahb_cd = {
+ NULL, "ahb", DV_DULL
};
/*
struct ahb_softc *ahb = (void *)self;
bus_chipset_tag_t bc = ea->ea_bc;
bus_io_handle_t ioh;
- char *model;
+ eisa_chipset_tag_t ec = ea->ea_ec;
+ eisa_intr_handle_t ih;
+ const char *model, *intrstr;
ahb->sc_bc = bc;
+ ahb->sc_ec = ec;
+
if (bus_io_map(bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE, &ioh))
panic("ahbattach: could not map I/O addresses");
ahb->sc_ioh = ioh;
#! /usr/bin/awk -f
-# $OpenBSD: devlist2h.awk,v 1.1 1996/04/18 23:47:10 niklas Exp $
-# $NetBSD: devlist2h.awk,v 1.1 1996/02/26 23:46:20 cgd Exp $
+# $OpenBSD: devlist2h.awk,v 1.2 1996/04/21 22:20:18 deraadt Exp $
+# $NetBSD: devlist2h.awk,v 1.2 1996/04/09 20:07:16 cgd Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
products[nproducts, 1] = $2; # vendor name
products[nproducts, 2] = $3; # product id
printf("#define\tEISA_PRODUCT_%s%s\t\"", products[nproducts, 1],
- products[nproducts, 2]) > hfile
+ products[nproducts, 2]) > hfile
i = vendorindex[products[nproducts, 1]]; j = 2;
needspace = 0;
-/* $OpenBSD: eisa.c,v 1.1 1996/04/18 23:47:10 niklas Exp $ */
-/* $NetBSD: eisa.c,v 1.7 1996/03/14 04:02:58 cgd Exp $ */
+/* $OpenBSD: eisa.c,v 1.2 1996/04/21 22:20:23 deraadt Exp $ */
+/* $NetBSD: eisa.c,v 1.11 1996/04/09 22:46:11 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou
int eisamatch __P((struct device *, void *, void *));
void eisaattach __P((struct device *, struct device *, void *));
-struct cfdriver eisacd = {
- NULL, "eisa", eisamatch, eisaattach, DV_DULL, sizeof(struct device)
+struct cfattach eisa_ca = {
+ sizeof(struct device), eisamatch, eisaattach
+};
+
+struct cfdriver eisa_cd = {
+ NULL, "eisa", DV_DULL
};
int eisasubmatch __P((struct device *, void *, void *));
int
eisamatch(parent, match, aux)
- struct device *parent;
- void *match, *aux;
+ struct device *parent;
+ void *match, *aux;
{
struct cfdata *cf = match;
struct eisabus_attach_args *eba = aux;
/* XXX check other indicators */
- return (1);
+ return (1);
}
int
if (cf->eisacf_slot != EISA_UNKNOWN_SLOT &&
cf->eisacf_slot != ea->ea_slot)
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
void
eisaattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+ struct device *parent, *self;
+ void *aux;
{
struct eisabus_attach_args *eba = aux;
bus_chipset_tag_t bc;
- int slot;
+ eisa_chipset_tag_t ec;
+ int slot, maxnslots;
+ eisa_attach_hook(parent, self, eba);
printf("\n");
bc = eba->eba_bc;
+ ec = eba->eba_ec;
/*
* Search for and attach subdevices.
* Slot 0 is the "motherboard" slot, and the code attaching
* the EISA bus should have already attached an ISA bus there.
*/
- for (slot = 1; slot < EISA_MAX_SLOT; slot++) {
+ maxnslots = eisa_maxslots(ec);
+ for (slot = 1; slot < maxnslots; slot++) {
struct eisa_attach_args ea;
- struct cfdata *cf;
u_int slotaddr;
bus_io_handle_t slotioh;
int i;
ea.ea_bc = bc;
+ ea.ea_ec = ec;
ea.ea_slot = slot;
slotaddr = EISA_SLOT_ADDR(slot);
* about it.
*/
if (bus_io_map(bc, slotaddr, EISA_SLOT_SIZE, &slotioh)) {
- printf("%s: can't map I/O space for slot %d\n", slot);
+ printf("%s: can't map I/O space for slot %d\n",
+ self->dv_xname, slot);
continue;
}
}
#ifdef EISAVERBOSE
-/*
+/*
* Descriptions of of known vendors and devices ("products").
- */
+ */
struct eisa_knowndev {
int flags;
const char *id, *name;
-};
-#define EISA_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
+};
+#define EISA_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
#include <dev/eisa/eisadevs_data.h>
#endif /* EISAVERBOSE */
-$OpenBSD: eisadevs,v 1.1 1996/04/18 23:47:11 niklas Exp $
+$OpenBSD: eisadevs,v 1.2 1996/04/21 22:20:29 deraadt Exp $
/* $NetBSD: eisadevs,v 1.1 1996/02/26 23:46:22 cgd Exp $ */
/*
*/
vendor ADP Adaptec
+vendor AMI AMI
vendor BUS BusLogic
vendor DEC Digital Equipment
vendor TCM 3Com
*/
/* Adaptec products */
-product ADP 0000 AHA-1740
-product ADP 0001 AHA-1740A
-product ADP 0002 AHA-1742A
-product ADP 0400 AHA-1744
-product ADP 7770 AIC-7770 (on motherboard)
-product ADP 7771 AHA-274x
-product ADP 7756 AHA-284x (BIOS enabled)
-product ADP 7757 AHA-284x (BIOS disabled)
+product ADP 0000 AHA-1740 SCSI
+product ADP 0001 AHA-1740A SCSI
+product ADP 0002 AHA-1742A SCSI
+product ADP 0400 AHA-1744 SCSI
+product ADP 7770 AIC-7770 SCSI (on motherboard)
+product ADP 7771 AHA-274x SCSI
+product ADP 7756 AHA-284x SCSI (BIOS enabled)
+product ADP 7757 AHA-284x SCSI (BIOS disabled)
+
+/* AMI products */
+product AMI 4801 Series 48 SCSI
/* BusLogic products */
-/* XXX */
+product BUS 4201 Bt74xB SCSI
+product BUS 4202 Bt74xC SCSI
/* Digital Equipment products */
-product DEC 4250 DE425
+product DEC 4250 DE425 Ethernet
/* ??? DEC DEFEA */
/* 3Com products */
-product TCM 5092 3C579-TP
-product TCM 5093 3C579
+product TCM 5092 3C579-TP Ethernet
+product TCM 5093 3C579 Ethernet
*/
/* Adaptec products */
-#define EISA_PRODUCT_ADP0000 "Adaptec AHA-1740"
-#define EISA_PRODUCT_ADP0001 "Adaptec AHA-1740A"
-#define EISA_PRODUCT_ADP0002 "Adaptec AHA-1742A"
-#define EISA_PRODUCT_ADP0400 "Adaptec AHA-1744"
-#define EISA_PRODUCT_ADP7770 "Adaptec AIC-7770 (on motherboard)"
-#define EISA_PRODUCT_ADP7771 "Adaptec AHA-274x"
-#define EISA_PRODUCT_ADP7756 "Adaptec AHA-284x (BIOS enabled)"
-#define EISA_PRODUCT_ADP7757 "Adaptec AHA-284x (BIOS disabled)"
+#define EISA_PRODUCT_ADP0000 "Adaptec AHA-1740 SCSI"
+#define EISA_PRODUCT_ADP0001 "Adaptec AHA-1740A SCSI"
+#define EISA_PRODUCT_ADP0002 "Adaptec AHA-1742A SCSI"
+#define EISA_PRODUCT_ADP0400 "Adaptec AHA-1744 SCSI"
+#define EISA_PRODUCT_ADP7770 "Adaptec AIC-7770 SCSI (on motherboard)"
+#define EISA_PRODUCT_ADP7771 "Adaptec AHA-274x SCSI"
+#define EISA_PRODUCT_ADP7756 "Adaptec AHA-284x SCSI (BIOS enabled)"
+#define EISA_PRODUCT_ADP7757 "Adaptec AHA-284x SCSI (BIOS disabled)"
+
+/* AMI products */
+#define EISA_PRODUCT_AMI4801 "AMI Series 48 SCSI"
/* BusLogic products */
-/* XXX */
+#define EISA_PRODUCT_BUS4201 "BusLogic Bt74xB SCSI"
+#define EISA_PRODUCT_BUS4202 "BusLogic Bt74xC SCSI"
/* Digital Equipment products */
-#define EISA_PRODUCT_DEC4250 "Digital Equipment DE425"
+#define EISA_PRODUCT_DEC4250 "Digital Equipment DE425 Ethernet"
/* ??? DEC DEFEA */
/* 3Com products */
-#define EISA_PRODUCT_TCM5092 "3Com 3C579-TP"
-#define EISA_PRODUCT_TCM5093 "3Com 3C579"
+#define EISA_PRODUCT_TCM5092 "3Com 3C579-TP Ethernet"
+#define EISA_PRODUCT_TCM5093 "3Com 3C579 Ethernet"
"ADP7757",
EISA_PRODUCT_ADP7757,
},
+ {
+ 0,
+ "AMI4801",
+ EISA_PRODUCT_AMI4801,
+ },
+ {
+ 0,
+ "BUS4201",
+ EISA_PRODUCT_BUS4201,
+ },
+ {
+ 0,
+ "BUS4202",
+ EISA_PRODUCT_BUS4202,
+ },
{
0,
"DEC4250",
"ADP",
"Adaptec",
},
+ {
+ EISA_KNOWNDEV_NOPROD,
+ "AMI",
+ "AMI",
+ },
{
EISA_KNOWNDEV_NOPROD,
"BUS",
-/* $OpenBSD: eisareg.h,v 1.2 1996/04/18 23:47:12 niklas Exp $ */
-/* $NetBSD: eisareg.h,v 1.2 1996/02/27 00:21:02 cgd Exp $ */
+/* $OpenBSD: eisareg.h,v 1.3 1996/04/21 22:20:42 deraadt Exp $ */
+/* $NetBSD: eisareg.h,v 1.3 1996/04/09 22:46:13 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou
* Intel Peripheral Components Databook (1992)
*/
-/*
- * Max number of EISA slots in a machine. 64K I/O space total.
- */
-#define EISA_MAX_SLOT 16 /* number of slots. 0 -> 0xf */
-
/*
* Slot I/O space size, and I/O address of a given slot.
*/
-/* $OpenBSD: eisavar.h,v 1.3 1996/04/18 23:47:13 niklas Exp $ */
-/* $NetBSD: eisavar.h,v 1.4 1996/03/08 20:25:22 cgd Exp $ */
+/* $OpenBSD: eisavar.h,v 1.4 1996/04/21 22:20:45 deraadt Exp $ */
+/* $NetBSD: eisavar.h,v 1.9 1996/04/12 06:34:36 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __DEV_EISA_EISAVAR_H__
-#define __DEV_EISA_EISAVAR_H__
+#ifndef _DEV_EISA_EISAVAR_H_
+#define _DEV_EISA_EISAVAR_H_
/*
* Definitions for EISA autoconfiguration.
*
- * This file describes types, constants, and functions which are used
- * for EISA autoconfiguration.
+ * This file describes types and functions which are used for EISA
+ * configuration. Some of this information is machine-specific, and is
+ * separated into eisa_machdep.h.
*/
#include <machine/bus.h>
#include <dev/eisa/eisareg.h> /* For ID register & string info. */
+/*
+ * Structures and definitions needed by the machine-dependent header.
+ */
+struct eisabus_attach_args;
-typedef int eisa_slot_t; /* really only needs to be 4 bits */
+/*
+ * Machine-dependent definitions.
+ */
+#if (alpha + i386 != 1)
+ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
+#endif
+#if alpha
+#include <alpha/eisa/eisa_machdep.h>
+#endif
+#if i386
+#include <i386/eisa/eisa_machdep.h>
+#endif
+typedef int eisa_slot_t; /* really only needs to be 4 bits */
/*
* EISA bus attach arguments.
struct eisabus_attach_args {
char *eba_busname; /* XXX should be common */
bus_chipset_tag_t eba_bc; /* XXX should be common */
+ eisa_chipset_tag_t eba_ec;
};
-
/*
* EISA device attach arguments.
*/
struct eisa_attach_args {
bus_chipset_tag_t ea_bc;
+ eisa_chipset_tag_t ea_ec;
eisa_slot_t ea_slot;
u_int8_t ea_vid[EISA_NVIDREGS];
char ea_idstring[EISA_IDSTRINGLEN];
};
-
-/*
- * Easy to remember names for EISA device locators.
- */
-
-#define eisacf_slot cf_loc[0] /* slot */
-
-
-/*
- * EISA device locator values that mean "unknown" or "unspecified."
- * Note that not all are supplied by 'config' and should be filled
- * in by the device if appropriate.
- */
-
-#define EISA_UNKNOWN_SLOT ((eisa_slot_t)-1)
-
/*
- * The EISA bus cfdriver, so that subdevices can more easily tell
- * what bus they're on.
+ * Locators for EISA devices, as specified to config.
*/
+#define eisacf_slot cf_loc[0]
+#define EISA_UNKNOWN_SLOT -1 /* wildcarded 'slot' */
-extern struct cfdriver eisacd;
-
-/*
- * XXX interrupt attachment, etc., is done by using the ISA interfaces.
- * XXX THIS SHOULD CHANGE.
- */
-
-#include <dev/isa/isavar.h>
-
-#define eisa_intr_establish isa_intr_establish /* XXX */
-#define eisa_intr_disestablish isa_intr_disestablish /* XXX */
-
-#endif /* !__DEV_EISA_EISAVAR_H__ */
+#endif /* _DEV_EISA_EISAVAR_H_ */
-# $OpenBSD: files.eisa,v 1.2 1996/04/18 23:47:14 niklas Exp $
-# $NetBSD: files.eisa,v 1.6 1996/03/04 03:29:12 cgd Exp $
+# $OpenBSD: files.eisa,v 1.3 1996/04/21 22:20:50 deraadt Exp $
+# $NetBSD: files.eisa,v 1.7 1996/03/17 00:47:21 thorpej Exp $
#
# Config.new file and device description for machine-independent EISA code.
# Included by ports that need it. Requires that the SCSI files be
# defined first.
-device eisa at eisabus {[slot = -1]}
+device eisa {[slot = -1]}
+attach eisa at eisabus
file dev/eisa/eisa.c eisa needs-flag
# Adaptec AHA-174x EISA SCSI Host Adapter family
-device ahb at eisa: scsi
+device ahb: scsi
+attach ahb at eisa
file dev/eisa/aha1742.c ahb
-/* $OpenBSD: aic7xxx.c,v 1.3 1996/04/18 23:47:15 niklas Exp $ */
-/* $NetBSD: aic7xxx.c,v 1.3 1996/02/25 22:56:30 cgd Exp $ */
+/* $OpenBSD: aic7xxx.c,v 1.4 1996/04/21 22:21:03 deraadt Exp $ */
+/* $NetBSD: aic7xxx.c,v 1.5 1996/03/29 00:24:58 mycroft Exp $ */
/*
* Generic driver for the aic7xxx based adaptec SCSI controllers
int ahc_poll __P((struct ahc_softc *, struct scsi_xfer *, int));
/* Different debugging levels */
+#ifdef AHC_DEBUG
#define AHC_SHOWMISC 0x0001
#define AHC_SHOWCMDS 0x0002
#define AHC_SHOWSCBS 0x0004
-/*#define AHC_DEBUG /**/
int ahc_debug = AHC_SHOWMISC;
-
-/*#define AHC_MORE_DEBUG /**/
+#endif
#ifdef AHC_MORE_DEBUG
#define DEBUGLEVEL -1
struct ahc_softc *ahc;
int target;
{
- u_char scsirate;
int i;
for (i = 0; i < ahc_num_syncrates; i++) {
#endif /* AHC_DEBUG */
}
-ahcprint()
+int
+ahcprint(aux, name)
+ void *aux;
+ char *name;
{
+ if (name != NULL)
+ printf("%s: scsibus ", name);
+ return UNCONF;
}
/*
break;
case NO_IDENT:
panic("%s: No IDENTIFY message from reconnecting "
- "target %d at seqaddr = 0x%lx "
+ "target %d at seqaddr = 0x%x "
"SAVED_TCL == 0x%x\n",
ahc->sc_dev.dv_xname,
(inb(SELID + iobase) >> 4) & 0xf,
*/
#ifdef AHC_DEBUG
if (ahc_debug & AHC_SHOWMISC)
- printf("Sending SDTR!!\n");
+ printf("Sending SDTR!!\n");
#endif
outb(HA_RETURN_1 + iobase, SEND_SDTR);
}
if (xs->error == XS_NOERROR &&
scb->flags != SCB_CHKSENSE) {
- u_char flags;
u_char head;
u_char tail;
struct ahc_dma_seg *sg = scb->ahc_dma;
ahc->sc_dev.dv_xname, sizeof(struct ahc_scb), SCB_DOWN_SIZE,
sizeof(struct ahc_dma_seg));
#endif /* AHC_DEBUG */
- /*printf("%s: reading board settings\n", ahc->sc_dev.dv_xname);/**/
/* Save the IRQ type before we do a chip reset */
-/* $OpenBSD: aic7xxxvar.h,v 1.2 1996/04/18 23:47:16 niklas Exp $ */
-/* $NetBSD: aic7xxxvar.h,v 1.2 1996/03/14 02:30:30 cgd Exp $ */
+/* $OpenBSD: aic7xxxvar.h,v 1.3 1996/04/21 22:21:12 deraadt Exp $ */
+/* $NetBSD: aic7xxxvar.h,v 1.3 1996/03/29 00:25:02 mycroft Exp $ */
/*
* Interface to the generic driver for the aic7xxx based adaptec
#ifndef _AIC7XXX_H_
#define _AIC7XXX_H_
-/*#include "ahc.h" /* for NAHC from config */
-
#define AHC_NSEG 256 /* number of dma segments supported */
#define AHC_SCB_MAX 16 /*
-/* $OpenBSD: am7990.c,v 1.4 1996/04/18 23:47:17 niklas Exp $ */
-/* $NetBSD: am7990.c,v 1.11 1996/03/14 19:05:07 christos Exp $ */
+/* $OpenBSD: am7990.c,v 1.5 1996/04/21 22:21:15 deraadt Exp $ */
+/* $NetBSD: am7990.c,v 1.16 1996/04/09 15:21:59 pk Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
#define ifp (&sc->sc_arpcom.ac_if)
+#ifndef ETHER_CMP
+#define ETHER_CMP(a, b) bcmp((a), (b), ETHER_ADDR_LEN)
+#endif
+
void
leconfig(sc)
struct le_softc *sc;
panic("leconfig: weird memory size");
}
- printf(": address %s\n%s: %d receive buffers, %d transmit buffers\n",
- ether_sprintf(sc->sc_arpcom.ac_enaddr),
+ printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
+ printf("%s: %d receive buffers, %d transmit buffers\n",
sc->sc_dev.dv_xname, sc->sc_nrbuf, sc->sc_ntbuf);
mem = 0;
*/
if ((ifp->if_flags & IFF_PROMISC) != 0 &&
(eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
- bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
- sizeof(eh->ether_dhost)) != 0) {
+ ETHER_CMP(eh->ether_dhost, sc->sc_arpcom.ac_enaddr)) {
m_freem(m);
return;
}
#endif
#ifdef LANCE_REVC_BUG
- if (bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
- sizeof(eh->ether_dhost)) != 0 &&
- bcmp(eh->ether_dhost, etherbroadcastaddr,
- sizeof(eh->ether_dhost)) != 0) {
+ /*
+ * The old LANCE (Rev. C) chips have a bug which causes
+ * garbage to be inserted in front of the received packet.
+ * The work-around is to ignore packets with an invalid
+ * destination address (garbage will usually not match).
+ * Of course, this precludes multicast support...
+ */
+ if (ETHER_CMP(eh->ether_dhost, sc->sc_arpcom.ac_enaddr) &&
+ ETHER_CMP(eh->ether_dhost, etherbroadcastaddr)) {
m_freem(m);
return;
}
printf("%s: receive buffer error\n",
sc->sc_dev.dv_xname);
ifp->if_ierrors++;
- } else if (rmd.rmd1_bits & (LE_R1_STP | LE_R1_ENP) !=
+ } else if ((rmd.rmd1_bits & (LE_R1_STP | LE_R1_ENP)) !=
(LE_R1_STP | LE_R1_ENP)) {
printf("%s: dropping chained buffer\n",
sc->sc_dev.dv_xname);
#ifdef LEDEBUG
if (sc->sc_debug)
- printf("sc->sc_last_rd = %x, rmd = %x\n",
- sc->sc_last_rd, rmd);
+ printf("sc->sc_last_rd = %x, rmd: "
+ "ladr %04x, hadr %02x, flags %02x, "
+ "bcnt %04x, mcnt %04x\n",
+ sc->sc_last_rd,
+ rmd.rmd0, rmd.rmd1_hadr, rmd.rmd1_bits,
+ rmd.rmd2, rmd.rmd3);
#endif
if (++bix == sc->sc_nrbuf)
#ifdef LEDEBUG
if (sc->sc_debug)
- printf("trans tmd = %x\n", tmd);
+ printf("trans tmd: "
+ "ladr %04x, hadr %02x, flags %02x, "
+ "bcnt %04x, mcnt %04x\n",
+ tmd.tmd0, tmd.tmd1_hadr, tmd.tmd1_bits,
+ tmd.tmd2, tmd.tmd3);
#endif
(*sc->sc_copyfromdesc)(sc, &tmd, LE_TMDADDR(sc, bix),
rmd.rmd0, rmd.rmd1_hadr, rmd.rmd1_bits, rmd.rmd2, rmd.rmd3);
if (len >= sizeof(eh)) {
(*sc->sc_copyfrombuf)(sc, &eh, LE_RBUFADDR(sc, no), sizeof(eh));
- printf("%s: dst %s", ether_sprintf(eh.ether_dhost));
+ printf("%s: dst %s", sc->sc_dev.dv_xname,
+ ether_sprintf(eh.ether_dhost));
printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
- ntohs(eh.ether_type));
+ ntohs(eh.ether_type));
}
}
tmd.tmd0, tmd.tmd1_hadr, tmd.tmd1_bits, tmd.tmd2, tmd.tmd3);
if (len >= sizeof(eh)) {
(*sc->sc_copyfrombuf)(sc, &eh, LE_TBUFADDR(sc, no), sizeof(eh));
- printf("%s: dst %s", ether_sprintf(eh.ether_dhost));
+ printf("%s: dst %s", sc->sc_dev.dv_xname,
+ ether_sprintf(eh.ether_dhost));
printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
ntohs(eh.ether_type));
}
af[0] = af[1] = af[2] = af[3] = 0x0000;
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
- if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
- sizeof(enm->enm_addrlo)) != 0) {
+ if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) {
/*
* We must listen to a range of multicast addresses.
* For now, just accept all multicasts, rather than
volatile caddr_t buf = sc->sc_mem;
register caddr_t from = fromv;
register volatile u_int16_t *bptr;
- register int xfer;
if (boff & 0x1) {
/* handle unaligned first byte */
register caddr_t to = tov;
register volatile u_int16_t *bptr;
register u_int16_t tmp;
- register int xfer;
if (boff & 0x1) {
/* handle unaligned first byte */
-/* $OpenBSD: com.c,v 1.10 1996/04/18 23:47:32 niklas Exp $ */
-/* $NetBSD: com.c,v 1.75 1996/03/10 09:01:24 cgd Exp $ */
+/* $OpenBSD: com.c,v 1.11 1996/04/21 22:23:15 deraadt Exp $ */
+/* $NetBSD: com.c,v 1.79 1996/04/15 18:54:31 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996
#include <sys/types.h>
#include <sys/device.h>
-#include <machine/cpu.h>
+#ifdef i386 /* XXX */
+#include <machine/cpu.h> /* XXX */
+#else /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <machine/bus.h>
#include <dev/isa/isavar.h>
#endif
#define com_lcr com_cfcr
+#include "com.h"
+
#define COM_IBUFSIZE (2 * 512)
#define COM_IHIGHWATER ((3 * COM_IBUFSIZE) / 4)
u_char sc_ibufs[2][COM_IBUFSIZE];
};
-int comprobe __P((struct device *, void *, void *));
#ifdef COM_HAYESP
int comprobeHAYESP __P((bus_io_handle_t hayespioh, struct com_softc *sc));
#endif
-void comattach __P((struct device *, struct device *, void *));
int comopen __P((dev_t, int, int, struct proc *));
int comclose __P((dev_t, int, int, struct proc *));
void comdiag __P((void *));
int comparam __P((struct tty *, struct termios *));
void comstart __P((struct tty *));
-int cominit __P((bus_chipset_tag_t, bus_io_handle_t, int));
+/*
+ * XXX the following two cfattach structs should be different, and possibly
+ * XXX elsewhere.
+ */
+int comprobe __P((struct device *, void *, void *));
+void comattach __P((struct device *, struct device *, void *));
+
+#if NCOM_ISA
+struct cfattach com_isa_ca = {
+ sizeof(struct com_softc), comprobe, comattach
+};
+#endif
-struct cfdriver comcd = {
- NULL, "com", comprobe, comattach, DV_TTY, sizeof(struct com_softc)
+#if NCOM_COMMULTI
+struct cfattach com_commulti_ca = {
+ sizeof(struct com_softc), comprobe, comattach
};
+#endif
+
+struct cfdriver com_cd = {
+ NULL, "com", DV_TTY
+};
+
+int cominit __P((bus_chipset_tag_t, bus_io_handle_t, int));
#ifdef COMCONSOLE
int comdefaultrate = CONSPEED; /* XXX why set default? */
int comconsattached;
bus_chipset_tag_t comconsbc;
bus_io_handle_t comconsioh;
+tcflag_t comconscflag = TTYDEF_CFLAG;
int commajor;
int comsopen = 0;
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
-#include "pcmciabus.h"
+/*#include "pcmciabus.h"*/
#if NPCMCIABUS >0
/* additional setup needed for pcmcia devices */
#include <dev/pcmcia/pcmciabus.h>
int iobase, needioh;
int rv = 1;
+ /*
+ * XXX should be broken out into functions for isa probe and
+ * XXX for commulti probe, with a helper function that contains
+ * XXX most of the interesting stuff.
+ */
+#if NCOM_ISA
if (!strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
struct isa_attach_args *ia = aux;
bc = ia->ia_bc;
iobase = ia->ia_iobase;
needioh = 1;
- } else {
+ } else
+#endif
+#if NCOM_COMMULTI
+ if (1) {
struct commulti_attach_args *ca = aux;
if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave)
iobase = ca->ca_iobase;
ioh = ca->ca_ioh;
needioh = 0;
- }
+ } else
+#endif
+ return(0); /* This cannot happen */
/* if it's in use as console, it's there. */
if (iobase == comconsaddr && !comconsattached)
bus_io_unmap(bc, ioh, COM_NPORTS);
out:
+#if NCOM_ISA
if (rv && !strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
struct isa_attach_args *ia = aux;
ia->ia_iosize = COM_NPORTS;
ia->ia_msize = 0;
}
+#endif
return (rv);
}
int *hayespp;
#endif
+ /*
+ * XXX should be broken out into functions for isa attach and
+ * XXX for commulti attach, with a helper function that contains
+ * XXX most of the interesting stuff.
+ */
sc->sc_hwflags = 0;
sc->sc_swflags = 0;
+#if NCOM_ISA
if (!strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
struct isa_attach_args *ia = aux;
} else
ioh = comconsioh;
irq = ia->ia_irq;
- } else {
+ } else
+#endif
+#if NCOM_COMMULTI
+ if (1) {
struct commulti_attach_args *ca = aux;
/*
if (ca->ca_noien)
sc->sc_hwflags |= COM_HW_NOIEN;
- }
+ } else
+#endif
+ panic("comattach: impossible");
sc->sc_bc = bc;
sc->sc_ioh = ioh;
bus_io_write_1(bc, ioh, com_ier, 0);
bus_io_write_1(bc, ioh, com_mcr, 0);
- if (irq != IRQUNK)
- sc->sc_ih = isa_intr_establish(irq, IST_EDGE, IPL_TTY,
- comintr, sc, sc->sc_dev.dv_xname);
+ if (irq != IRQUNK) {
+#if NCOM_ISA
+ if (!strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
+ struct isa_attach_args *ia = aux;
+
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
+ IST_EDGE, IPL_TTY, comintr, sc,
+ sc->sc_dev.dv_xname);
+ } else
+#endif
+ panic("comattach: IRQ but can't have one");
+ }
#ifdef KGDB
if (kgdb_dev == makedev(commajor, unit)) {
int s;
int error = 0;
- if (unit >= comcd.cd_ndevs)
+ if (unit >= com_cd.cd_ndevs)
return ENXIO;
- sc = comcd.cd_devs[unit];
+ sc = com_cd.cd_devs[unit];
if (!sc)
return ENXIO;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
- tp->t_cflag = TTYDEF_CFLAG;
+ if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
+ tp->t_cflag = comconscflag;
+ else
+ tp->t_cflag = TTYDEF_CFLAG;
if (ISSET(sc->sc_swflags, COM_SW_CLOCAL))
SET(tp->t_cflag, CLOCAL);
if (ISSET(sc->sc_swflags, COM_SW_CRTSCTS))
struct proc *p;
{
int unit = COMUNIT(dev);
- struct com_softc *sc = comcd.cd_devs[unit];
+ struct com_softc *sc = com_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
struct uio *uio;
int flag;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
struct uio *uio;
int flag;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
comtty(dev)
dev_t dev;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
struct tty *tp = sc->sc_tty;
return (tp);
struct proc *p;
{
int unit = COMUNIT(dev);
- struct com_softc *sc = comcd.cd_devs[unit];
+ struct com_softc *sc = com_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
struct tty *tp;
struct termios *t;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(tp->t_dev)];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
int ospeed = comspeed(t->c_ospeed);
comstart(tp)
struct tty *tp;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(tp->t_dev)];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
int s;
comevents = 0;
splx(s);
- for (unit = 0; unit < comcd.cd_ndevs; unit++) {
- sc = comcd.cd_devs[unit];
+ for (unit = 0; unit < com_cd.cd_ndevs; unit++) {
+ sc = com_cd.cd_devs[unit];
if (sc == 0 || sc->sc_ibufp == sc->sc_ibuf)
continue;
-/* $OpenBSD: comvar.h,v 1.1 1996/04/19 16:08:34 niklas Exp $ */
-/* $NetBSD: comvar.h,v 1.3 1996/03/10 09:01:26 cgd Exp $ */
+/* $OpenBSD: comvar.h,v 1.2 1996/04/21 22:23:20 deraadt Exp $ */
+/* $NetBSD: comvar.h,v 1.4 1996/04/15 18:54:35 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
extern int comconsattached;
extern bus_chipset_tag_t comconsbc;
extern bus_io_handle_t comconsioh;
+extern tcflag_t comconscflag;
-/* $OpenBSD: ncr5380sbc.c,v 1.4 1996/04/18 23:47:19 niklas Exp $ */
-/* $NetBSD: ncr5380sbc.c,v 1.8 1996/03/07 15:00:17 christos Exp $ */
+/* $OpenBSD: ncr5380sbc.c,v 1.5 1996/04/21 22:21:21 deraadt Exp $ */
+/* $NetBSD: ncr5380sbc.c,v 1.9 1996/03/18 23:09:02 gwr Exp $ */
/*
* Copyright (c) 1995 David Jones, Gordon W. Ross
if (act_flags & ACT_DISCONNECT) {
/*
* The device has dropped BSY (or will soon).
- * Return and let ncr5380_sched() do its thing.
+ * We have to wait here for BSY to drop, otherwise
+ * the next command may decide we need a bus reset.
*/
+ timo = ncr5380_wait_nrq_timo; /* XXX */
+ for (;;) {
+ if (!SCI_BUSY(sc))
+ goto busfree;
+ if (--timo <= 0)
+ break;
+ delay(2);
+ }
+ /* Device is sitting on the bus! */
+ printf("%s: SCSI job did not finish, resetting...\n",
+ sc->sc_dev.dv_xname);
+ ncr5380_reset_scsibus(sc);
+ busfree:
+ NCR_TRACE("machine: discon, waited %d\n",
+ ncr5380_wait_nrq_timo - timo);
+
*sc->sci_icmd = 0;
*sc->sci_mode = 0;
*sc->sci_tcmd = PHASE_INVALID;
--- /dev/null
+/* $NetBSD: smc90cx6.c,v 1.16 1996/03/20 13:28:50 is Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Ignatios Souvatzis
+ * 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 Ignatios Souvatzis
+ * for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Driver for the Commodore Busines Machines ARCnet card.
+ */
+
+#define BAHASMCOPY /**/
+#define BAHSOFTCOPY /**/
+#define BAHRETRANSMIT /**/
+/* #define BAHTIMINGS */
+/* #define BAH_DEBUG 3 */
+
+/* zeroth version of M68060 support */
+
+#if defined(M68060) && defined(BAHASMCOPY)
+#undef BAHASMCOPY
+#endif
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/buf.h>
+#include <sys/device.h>
+#include <sys/protosw.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#include <net/netisr.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+#include <netinet/if_arc.h>
+#endif
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#include <net/bpfdesc.h>
+#endif
+
+#include <sys/kernel.h>
+#include <machine/cpu.h>
+#include <machine/mtpr.h>
+
+#include <amiga/amiga/device.h>
+#include <amiga/amiga/isr.h>
+#include <amiga/dev/zbusvar.h>
+#include <amiga/dev/if_bahreg.h>
+
+/* these should be elsewhere */
+
+#define ARC_MIN_LEN 1
+#define ARC_MIN_FORBID_LEN 254
+#define ARC_MAX_FORBID_LEN 256
+#define ARC_MAX_LEN 508
+#define ARC_ADDR_LEN 1
+
+/* for watchdog timer. This should be more than enough. */
+#define ARCTIMEOUT (5*IFNET_SLOWHZ)
+
+/*
+ * This currently uses 2 bufs for tx, 2 for rx
+ *
+ * New rx protocol:
+ *
+ * rx has a fillcount variable. If fillcount > (NRXBUF-1),
+ * rx can be switched off from rx hard int.
+ * Else rx is restarted on the other receiver.
+ * rx soft int counts down. if it is == (NRXBUF-1), it restarts
+ * the receiver.
+ * To ensure packet ordering (we need that for 1201 later), we have a counter
+ * which is incremented modulo 256 on each receive and a per buffer
+ * variable, which is set to the counter on filling. The soft int can
+ * compare both values to determine the older packet.
+ *
+ * Transmit direction:
+ *
+ * bah_start checks tx_fillcount
+ * case 2: return
+ *
+ * else fill tx_act ^ 1 && inc tx_fillcount
+ *
+ * check tx_fillcount again.
+ * case 2: set IFF_OACTIVE to stop arc_output from filling us.
+ * case 1: start tx
+ *
+ * tint clears IFF_OCATIVE, decrements and checks tx_fillcount
+ * case 1: start tx on tx_act ^ 1, softcall bah_start
+ * case 0: softcall bah_start
+ *
+ * #define fill(i) get mbuf && copy mbuf to chip(i)
+ */
+
+#ifdef BAHTIMINGS
+/*
+ * ARCnet stats; per interface.
+ */
+struct bah_stats {
+ u_long mincopyin;
+ u_long maxcopyin; /* divided by byte count */
+ u_long mincopyout;
+ u_long maxcopyout;
+ u_long minsend;
+ u_long maxsend;
+ u_long lasttxstart_mics;
+ struct timeval lasttxstart_tv;
+};
+
+#error BAHTIMINGS CODE IS BROKEN; use of clkread() is bogus
+#endif
+
+/*
+ * Arcnet software status per interface
+ */
+struct bah_softc {
+ struct device sc_dev;
+ struct arccom sc_arccom; /* Common arcnet structures */
+ struct isr sc_isr;
+ struct a2060 *sc_base;
+ u_long sc_recontime; /* seconds only, I'm lazy */
+ u_long sc_reconcount; /* for the above */
+ u_long sc_reconcount_excessive; /* for the above */
+#define ARC_EXCESSIVE_RECONS 20
+#define ARC_EXCESSIVE_RECONS_REWARN 400
+ u_char sc_intmask;
+ u_char sc_rx_act; /* 2..3 */
+ u_char sc_tx_act; /* 0..1 */
+ u_char sc_rx_fillcount;
+ u_char sc_tx_fillcount;
+ u_char sc_broadcast[2]; /* is it a broadcast packet? */
+ u_char sc_retransmits[2]; /* unused at the moment */
+#ifdef BAHTIMINGS
+ struct bah_stats sc_stats;
+#endif
+};
+
+int bah_zbus_match __P((struct device *, void *, void *));
+void bah_zbus_attach __P((struct device *, struct device *, void *));
+void bah_init __P((struct bah_softc *));
+void bah_reset __P((struct bah_softc *));
+void bah_stop __P((struct bah_softc *));
+void bah_start __P((struct ifnet *));
+int bahintr __P((struct bah_softc *sc));
+int bah_ioctl __P((struct ifnet *, unsigned long, caddr_t));
+void bah_watchdog __P((int));
+void movepout __P((u_char *from, u_char __volatile *to, int len));
+void movepin __P((u_char __volatile *from, u_char *to, int len));
+void bah_srint __P((void *vsc, void *dummy));
+void callstart __P((void *vsc, void *dummy));
+
+#ifdef BAHTIMINGS
+int clkread();
+#endif
+
+struct cfattach bah_zbus_ca = {
+ sizeof(struct bah_softc), bah_zbus_match, bah_zbus_attach
+};
+
+struct cfdriver bah_cd = {
+ NULL, "bah", DV_IFNET
+};
+
+int
+bah_zbus_match(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct zbus_args *zap = aux;
+
+ if ((zap->manid == 514 || zap->manid == 1053) && zap->prodid == 9)
+ return (1);
+
+ return (0);
+}
+
+void
+bah_zbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct bah_softc *sc = (void *)self;
+ struct zbus_args *zap = aux;
+ struct ifnet *ifp = &sc->sc_arccom.ac_if;
+ int s, linkaddress;
+
+#if (defined(BAH_DEBUG) && (BAH_DEBUG > 2))
+ printf("\n%s: attach(0x%x, 0x%x, 0x%x)\n",
+ sc->sc_dev.dv_xname, parent, self, aux);
+#endif
+ s = splhigh();
+ sc->sc_base = zap->va;
+
+ /*
+ * read the arcnet address from the board
+ */
+
+ sc->sc_base->kick1 = 0x0;
+ sc->sc_base->kick2 = 0x0;
+ DELAY(200);
+
+ sc->sc_base->kick1 = 0xFF;
+ sc->sc_base->kick2 = 0xFF;
+ do {
+ DELAY(200);
+ } while (!(sc->sc_base->status & ARC_POR));
+
+ linkaddress = sc->sc_base->dipswitches;
+
+#ifdef BAHTIMINGS
+ printf(": link addr 0x%02x(%ld), with timer\n",
+ linkaddress, linkaddress);
+#else
+ printf(": link addr 0x%02x(%ld)\n", linkaddress, linkaddress);
+#endif
+
+ sc->sc_arccom.ac_anaddr = linkaddress;
+
+ /* clear the int mask... */
+
+ sc->sc_base->status = sc->sc_intmask = 0;
+
+ sc->sc_base->command = ARC_CONF(CONF_LONG);
+ sc->sc_base->command = ARC_CLR(CLR_POR|CLR_RECONFIG);
+ sc->sc_recontime = sc->sc_reconcount = 0;
+
+ /* and reenable kernel int level */
+ splx(s);
+
+ /*
+ * set interface to stopped condition (reset)
+ */
+ bah_stop(sc);
+
+ ifp->if_unit = sc->sc_dev.dv_unit;
+ ifp->if_name = bah_cd.cd_name;
+ ifp->if_output = arc_output;
+ ifp->if_start = bah_start;
+ ifp->if_ioctl = bah_ioctl;
+ ifp->if_timer = 0;
+ ifp->if_watchdog = bah_watchdog;
+
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX |
+ IFF_NOTRAILERS | IFF_NOARP;
+
+ ifp->if_mtu = ARCMTU;
+
+ if_attach(ifp);
+ arc_ifattach(ifp);
+
+#if NBPFILTER > 0
+ bpfattach(&ifp->if_bpf, ifp, DLT_ARCNET, ARC_HDRLEN);
+#endif
+ /* under heavy load we need four of them: */
+ alloc_sicallback();
+ alloc_sicallback();
+ alloc_sicallback();
+ alloc_sicallback();
+
+ sc->sc_isr.isr_intr = bahintr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = 2;
+ add_isr(&sc->sc_isr);
+}
+
+/*
+ * Initialize device
+ *
+ */
+void
+bah_init(sc)
+ struct bah_softc *sc;
+{
+ struct ifnet *ifp;
+ int s;
+
+ ifp = &sc->sc_arccom.ac_if;
+
+ if ((ifp->if_flags & IFF_RUNNING) == 0) {
+ s = splnet();
+ ifp->if_flags |= IFF_RUNNING;
+ bah_reset(sc);
+ bah_start(ifp);
+ splx(s);
+ }
+}
+
+/*
+ * Reset the interface...
+ *
+ * this assumes that it is called inside a critical section...
+ *
+ */
+void
+bah_reset(sc)
+ struct bah_softc *sc;
+{
+ struct ifnet *ifp;
+ int linkaddress;
+
+ ifp = &sc->sc_arccom.ac_if;
+
+#ifdef BAH_DEBUG
+ printf("%s: reset\n", sc->sc_dev.dv_xname);
+#endif
+ /* stop hardware in case it still runs */
+
+ sc->sc_base->kick1 = 0;
+ sc->sc_base->kick2 = 0;
+ DELAY(200);
+
+ /* and restart it */
+ sc->sc_base->kick1 = 0xFF;
+ sc->sc_base->kick2 = 0xFF;
+
+ do {
+ DELAY(200);
+ } while (!(sc->sc_base->status & ARC_POR));
+
+ linkaddress = sc->sc_base->dipswitches;
+
+#if defined(BAH_DEBUG) && (BAH_DEBUG > 2)
+ printf("bah%ld: reset: card reset, link addr = 0x%02x (%ld)\n",
+ ifp->if_unit, linkaddress, linkaddress);
+#endif
+ sc->sc_arccom.ac_anaddr = linkaddress;
+
+ /* tell the routing level about the (possibly changed) link address */
+ arc_ifattach(ifp);
+
+ /* POR is NMI, but we need it below: */
+ sc->sc_intmask = ARC_RECON|ARC_POR;
+ sc->sc_base->status = sc->sc_intmask;
+ sc->sc_base->command = ARC_CONF(CONF_LONG);
+
+#ifdef BAH_DEBUG
+ printf("%s: reset: chip configured, status=0x%02x\n",
+ sc->sc_dev.dv_xname, sc->sc_base->status);
+#endif
+
+ sc->sc_base->command = ARC_CLR(CLR_POR|CLR_RECONFIG);
+
+#ifdef BAH_DEBUG
+ printf("%s: reset: bits cleared, status=0x%02x\n",
+ sc->sc_dev.dv_xname, sc->sc_base->status);
+#endif
+
+ sc->sc_reconcount_excessive = ARC_EXCESSIVE_RECONS;
+
+ /* start receiver */
+
+ sc->sc_intmask |= ARC_RI;
+ sc->sc_rx_fillcount = 0;
+ sc->sc_rx_act = 2;
+
+ sc->sc_base->command = ARC_RXBC(2);
+ sc->sc_base->status = sc->sc_intmask;
+
+#ifdef BAH_DEBUG
+ printf("%s: reset: started receiver, status=0x%02x\n",
+ sc->sc_dev.dv_xname, sc->sc_base->status);
+#endif
+
+ /* and init transmitter status */
+ sc->sc_tx_act = 0;
+ sc->sc_tx_fillcount = 0;
+
+ ifp->if_flags |= IFF_RUNNING;
+ ifp->if_flags &= ~IFF_OACTIVE;
+
+#ifdef BAHTIMINGS
+ bzero((caddr_t)&(sc->sc_stats), sizeof(sc->sc_stats));
+ sc->sc_stats.mincopyin =
+ sc->sc_stats.mincopyout =
+ sc->sc_stats.minsend = ULONG_MAX;
+#endif
+
+ bah_start(ifp);
+}
+
+/*
+ * Take interface offline
+ */
+void
+bah_stop(sc)
+ struct bah_softc *sc;
+{
+ /* Stop the interrupts */
+ sc->sc_base->status = 0;
+
+ /* Stop the interface */
+ sc->sc_base->kick1 = 0;
+ sc->sc_base->kick2 = 0;
+
+ /* Stop watchdog timer */
+ sc->sc_arccom.ac_if.if_timer = 0;
+
+#ifdef BAHTIMINGS
+ log(LOG_DEBUG,"%s: to board: %6lu .. %6lu ns/byte\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_stats.mincopyout, sc->sc_stats.maxcopyout);
+
+ log(LOG_DEBUG,"%s: from board: %6lu .. %6lu ns/byte\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_stats.mincopyin, sc->sc_stats.maxcopyin);
+
+ log(LOG_DEBUG,"%s: send time: %6lu .. %6lu mics/byte\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_stats.minsend, sc->sc_stats.maxsend);
+
+ sc->sc_stats.minsend =
+ sc->sc_stats.mincopyout =
+ sc->sc_stats.mincopyin = ULONG_MAX;
+ sc->sc_stats.maxsend =
+ sc->sc_stats.maxcopyout =
+ sc->sc_stats.maxcopyin = 0;
+#endif
+}
+
+__inline void
+movepout(from, to, len)
+ u_char *from;
+ __volatile u_char *to;
+ int len;
+{
+#ifdef BAHASMCOPY
+ u_short shortd;
+ u_long longd, longd1, longd2, longd3, longd4;
+
+ if ((len > 3) && ((long)from) & 3) {
+ switch (((long)from) & 3) {
+ case 3:
+ *to = *from++;
+ to += 2; --len;
+ break;
+ case 1:
+ *to = *from++;
+ to += 2; --len;
+ case 2:
+ shortd = *((u_short *)from)++;
+ asm("movepw %0,%1@(0)" : : "d"(shortd), "a"(to));
+ to += 4; len -= 2;
+ break;
+ default:
+ }
+
+ while (len >= 32) {
+ longd1 = *((u_long *)from)++;
+ longd2 = *((u_long *)from)++;
+ longd3 = *((u_long *)from)++;
+ longd4 = *((u_long *)from)++;
+ asm("movepl %0,%1@(0)" : : "d"(longd1), "a"(to));
+ asm("movepl %0,%1@(8)" : : "d"(longd2), "a"(to));
+ asm("movepl %0,%1@(16)" : : "d"(longd3), "a"(to));
+ asm("movepl %0,%1@(24)" : : "d"(longd4), "a"(to));
+
+ longd1 = *((u_long *)from)++;
+ longd2 = *((u_long *)from)++;
+ longd3 = *((u_long *)from)++;
+ longd4 = *((u_long *)from)++;
+ asm("movepl %0,%1@(32)" : : "d"(longd1), "a"(to));
+ asm("movepl %0,%1@(40)" : : "d"(longd2), "a"(to));
+ asm("movepl %0,%1@(48)" : : "d"(longd3), "a"(to));
+ asm("movepl %0,%1@(56)" : : "d"(longd4), "a"(to));
+
+ to += 64; len -= 32;
+ }
+ while (len > 0) {
+ longd = *((u_long *)from)++;
+ asm("movepl %0,%1@(0)" : : "d"(longd), "a"(to));
+ to += 8; len -= 4;
+ }
+ }
+#endif
+ while (len > 0) {
+ *to = *from++;
+ to += 2;
+ --len;
+ }
+}
+
+/*
+ * Start output on interface. Get another datagram to send
+ * off the interface queue, and copy it to the
+ * interface becore starting the output
+ *
+ * this assumes that it is called inside a critical section...
+ * XXX hm... does it still?
+ *
+ */
+void
+bah_start(ifp)
+ struct ifnet *ifp;
+{
+ struct bah_softc *sc;
+ struct mbuf *m,*mp;
+ __volatile u_char *bah_ram_ptr;
+ int len, tlen, offset, s, buffer;
+#ifdef BAHTIMINGS
+ u_long copystart, lencopy, perbyte;
+#endif
+
+ sc = bah_cd.cd_devs[ifp->if_unit];
+
+#if defined(BAH_DEBUG) && (BAH_DEBUG > 3)
+ printf("%s: start(0x%x)\n", sc->sc_dev.dv_xname, ifp);
+#endif
+
+ if ((ifp->if_flags & IFF_RUNNING) == 0)
+ return;
+
+ s = splnet();
+
+ if (sc->sc_tx_fillcount >= 2) {
+ splx(s);
+ return;
+ }
+
+ IF_DEQUEUE(&ifp->if_snd, m);
+ buffer = sc->sc_tx_act ^ 1;
+
+ splx(s);
+
+ if (m == 0)
+ return;
+
+#if NBPFILTER > 0
+ /*
+ * If bpf is listening on this interface, let it
+ * see the packet before we commit it to the wire
+ *
+ * (can't give the copy in A2060 card RAM to bpf, because
+ * that RAM is just accessed as on every other byte)
+ */
+ if (ifp->if_bpf)
+ bpf_mtap(ifp->if_bpf, m);
+#endif
+
+#ifdef BAH_DEBUG
+ m = m_pullup(m,3); /* gcc does structure padding */
+ printf("%s: start: filling %ld from %ld to %ld type %ld\n",
+ sc->sc_dev.dv_xname, buffer, mtod(m, u_char *)[0],
+ mtod(m, u_char *)[1], mtod(m, u_char *)[2]);
+#else
+ m = m_pullup(m, 2);
+#endif
+ bah_ram_ptr = sc->sc_base->buffers + buffer*512*2;
+
+ /* write the addresses to RAM and throw them away */
+
+ /*
+ * Hardware does this: Yet Another Microsecond Saved.
+ * (btw, timing code says usually 2 microseconds)
+ * bah_ram_ptr[0*2] = mtod(m, u_char *)[0];
+ */
+ bah_ram_ptr[1 * 2] = mtod(m, u_char *)[1];
+ m_adj(m, 2);
+
+ /* get total length left at this point */
+ tlen = m->m_pkthdr.len;
+ if (tlen < ARC_MIN_FORBID_LEN) {
+ offset = 256 - tlen;
+ bah_ram_ptr[2 * 2] = offset;
+ } else {
+ bah_ram_ptr[2 * 2] = 0;
+ if (tlen <= ARC_MAX_FORBID_LEN)
+ offset = 255; /* !!! */
+ else {
+ if (tlen > ARC_MAX_LEN)
+ tlen = ARC_MAX_LEN;
+ offset = 512 - tlen;
+ }
+ bah_ram_ptr[3 * 2] = offset;
+
+ }
+ bah_ram_ptr += offset * 2;
+
+ /* lets loop through the mbuf chain */
+
+ for (mp = m; mp; mp = mp->m_next) {
+ if ((len = mp->m_len)) { /* YAMS */
+#ifdef BAHTIMINGS
+ lencopy = len;
+ copystart = clkread();
+#endif
+ movepout(mtod(mp, caddr_t), bah_ram_ptr, len);
+
+#ifdef BAHTIMINGS
+ perbyte = 1000 * (clkread() - copystart) / lencopy;
+ sc->sc_stats.mincopyout =
+ ulmin(sc->sc_stats.mincopyout, perbyte);
+ sc->sc_stats.maxcopyout =
+ ulmax(sc->sc_stats.maxcopyout, perbyte);
+#endif
+ bah_ram_ptr += len*2;
+ }
+ }
+
+ sc->sc_broadcast[buffer] = (m->m_flags & M_BCAST) != 0;
+ sc->sc_retransmits[buffer] = (m->m_flags & M_BCAST) ? 1 : 5;
+
+ /* actually transmit the packet */
+ s = splnet();
+
+ if (++sc->sc_tx_fillcount > 1) {
+ /*
+ * We are filled up to the rim. No more bufs for the moment,
+ * please.
+ */
+ ifp->if_flags |= IFF_OACTIVE;
+ } else {
+#ifdef BAH_DEBUG
+ printf("%s: start: starting transmitter on buffer %d\n",
+ sc->sc_dev.dv_xname, buffer);
+#endif
+ /* Transmitter was off, start it */
+ sc->sc_tx_act = buffer;
+
+ /*
+ * We still can accept another buf, so don't:
+ * ifp->if_flags |= IFF_OACTIVE;
+ */
+ sc->sc_intmask |= ARC_TA;
+ sc->sc_base->command = ARC_TX(buffer);
+ sc->sc_base->status = sc->sc_intmask;
+
+ sc->sc_arccom.ac_if.if_timer = ARCTIMEOUT;
+#ifdef BAHTIMINGS
+ bcopy((caddr_t)&time,
+ (caddr_t)&(sc->sc_stats.lasttxstart_tv),
+ sizeof(struct timeval));
+
+ sc->sc_stats.lasttxstart_mics = clkread();
+#endif
+ }
+ splx(s);
+ m_freem(m);
+
+ /*
+ * After 10 times reading the docs, I realized
+ * that in the case the receiver NAKs the buffer request,
+ * the hardware retries till shutdown.
+ * This is integrated now in the code above.
+ */
+
+ return;
+}
+
+void
+callstart(vsc, dummy)
+ void *vsc, *dummy;
+{
+ struct bah_softc *sc;
+
+ sc = (struct bah_softc *)vsc;
+ bah_start(&sc->sc_arccom.ac_if);
+}
+
+__inline void
+movepin(from, to, len)
+ __volatile u_char *from;
+ u_char *to;
+ int len;
+{
+#ifdef BAHASMCOPY
+ unsigned long longd, longd1, longd2, longd3, longd4;
+ ushort shortd;
+
+ if ((len > 3) && (((long)to) & 3)) {
+ switch (((long)to) & 3) {
+ case 3: *to++ = *from;
+ from += 2; --len;
+ break;
+ case 1: *to++ = *from;
+ from += 2; --len;
+ case 2: asm ("movepw %1@(0),%0": "=d" (shortd) : "a" (from));
+ *((ushort *)to)++ = shortd;
+ from += 4; len -= 2;
+ break;
+ default:
+ }
+
+ while (len >= 32) {
+ asm("movepl %1@(0),%0" : "=d"(longd1) : "a" (from));
+ asm("movepl %1@(8),%0" : "=d"(longd2) : "a" (from));
+ asm("movepl %1@(16),%0" : "=d"(longd3) : "a" (from));
+ asm("movepl %1@(24),%0" : "=d"(longd4) : "a" (from));
+ *((unsigned long *)to)++ = longd1;
+ *((unsigned long *)to)++ = longd2;
+ *((unsigned long *)to)++ = longd3;
+ *((unsigned long *)to)++ = longd4;
+
+ asm("movepl %1@(32),%0" : "=d"(longd1) : "a" (from));
+ asm("movepl %1@(40),%0" : "=d"(longd2) : "a" (from));
+ asm("movepl %1@(48),%0" : "=d"(longd3) : "a" (from));
+ asm("movepl %1@(56),%0" : "=d"(longd4) : "a" (from));
+ *((unsigned long *)to)++ = longd1;
+ *((unsigned long *)to)++ = longd2;
+ *((unsigned long *)to)++ = longd3;
+ *((unsigned long *)to)++ = longd4;
+
+ from += 64; len -= 32;
+ }
+ while (len > 0) {
+ asm("movepl %1@(0),%0" : "=d"(longd) : "a" (from));
+ *((unsigned long *)to)++ = longd;
+ from += 8; len -= 4;
+ }
+
+ }
+#endif /* BAHASMCOPY */
+ while (len > 0) {
+ *to++ = *from;
+ from += 2;
+ --len;
+ }
+
+}
+
+/*
+ * Arcnet interface receiver soft interrupt:
+ * get the stuff out of any filled buffer we find.
+ */
+void
+bah_srint(vsc, dummy)
+ void *vsc, *dummy;
+{
+ struct bah_softc *sc;
+ int buffer, len, len1, amount, offset, s, i, type;
+ u_char __volatile *bah_ram_ptr;
+ struct mbuf *m, *dst, *head;
+ struct arc_header *ah;
+ struct ifnet *ifp;
+#ifdef BAHTIMINGS
+ u_long copystart, lencopy, perbyte;
+#endif
+ sc = (struct bah_softc *)vsc;
+ ifp = &sc->sc_arccom.ac_if;
+ head = 0;
+
+ s = splnet();
+ buffer = sc->sc_rx_act ^ 1;
+ splx(s);
+
+ /* Allocate header mbuf */
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+
+ if (m == 0) {
+ /*
+ * in case s.th. goes wrong with mem, drop it
+ * to make sure the receiver can be started again
+ * count it as input error (we dont have any other
+ * detectable)
+ */
+ ifp->if_ierrors++;
+ goto cleanup;
+ }
+
+ m->m_pkthdr.rcvif = ifp;
+
+ /*
+ * Align so that IP packet will be longword aligned. Here we
+ * assume that m_data of new packet is longword aligned.
+ * When implementing PHDS, we might have to change it to 2,
+ * (2*sizeof(ulong) - ARC_HDRNEWLEN)), packet type dependent.
+ */
+
+ bah_ram_ptr = sc->sc_base->buffers + buffer*512*2;
+ offset = bah_ram_ptr[2*2];
+ if (offset)
+ len = 256 - offset;
+ else {
+ offset = bah_ram_ptr[3*2];
+ len = 512 - offset;
+ }
+ type = bah_ram_ptr[offset*2];
+ m->m_data += 1 + arc_isphds(type);
+
+ head = m;
+ ah = mtod(head, struct arc_header *);
+
+ ah->arc_shost = bah_ram_ptr[0*2];
+ ah->arc_dhost = bah_ram_ptr[1*2];
+
+ m->m_pkthdr.len = len+2; /* whole packet length */
+ m->m_len = 2; /* mbuf filled with ARCnet addresses */
+ bah_ram_ptr += offset*2; /* ram buffer continues there */
+
+ while (len > 0) {
+
+ len1 = len;
+ amount = M_TRAILINGSPACE(m);
+
+ if (amount == 0) {
+ dst = m;
+ MGET(m, M_DONTWAIT, MT_DATA);
+
+ if (m == 0) {
+ ifp->if_ierrors++;
+ goto cleanup;
+ }
+
+ if (len1 >= MINCLSIZE)
+ MCLGET(m, M_DONTWAIT);
+
+ m->m_len = 0;
+ dst->m_next = m;
+ amount = M_TRAILINGSPACE(m);
+ }
+
+ if (amount < len1)
+ len1 = amount;
+
+#ifdef BAHTIMINGS
+ lencopy = len;
+ copystart = clkread();
+#endif
+
+ movepin(bah_ram_ptr, mtod(m, u_char *) + m->m_len, len1);
+
+#ifdef BAHTIMINGS
+ perbyte = 1000 * (clkread() - copystart) / lencopy;
+ sc->sc_stats.mincopyin =
+ ulmin(sc->sc_stats.mincopyin, perbyte);
+ sc->sc_stats.maxcopyin =
+ ulmax(sc->sc_stats.maxcopyin, perbyte);
+#endif
+
+ m->m_len += len1;
+ bah_ram_ptr += len1*2;
+ len -= len1;
+ }
+
+#if NBPFILTER > 0
+ if (ifp->if_bpf)
+ bpf_mtap(ifp->if_bpf, head);
+#endif
+
+ arc_input(&sc->sc_arccom.ac_if, head);
+
+ /* arc_input has freed it, we dont need to... */
+
+ head = NULL;
+ ifp->if_ipackets++;
+
+cleanup:
+
+ if (head != NULL)
+ m_freem(head);
+
+ /* mark buffer as invalid by source id 0 */
+ sc->sc_base->buffers[buffer*512*2] = 0;
+ s = splnet();
+
+ if (--sc->sc_rx_fillcount == 2 - 1) {
+
+ /* was off, restart it on buffer just emptied */
+ sc->sc_rx_act = buffer;
+ sc->sc_intmask |= ARC_RI;
+
+ /* this also clears the RI flag interupt: */
+ sc->sc_base->command = ARC_RXBC(buffer);
+ sc->sc_base->status = sc->sc_intmask;
+
+#ifdef BAH_DEBUG
+ printf("%s: srint: restarted rx on buf %ld\n",
+ sc->sc_dev.dv_xname, buffer);
+#endif
+ }
+ splx(s);
+}
+
+__inline static void
+bah_tint(sc, isr)
+ struct bah_softc *sc;
+ int isr;
+{
+ struct ifnet *ifp;
+
+ int buffer;
+#ifdef BAHTIMINGS
+ int clknow;
+#endif
+
+ ifp = &(sc->sc_arccom.ac_if);
+ buffer = sc->sc_tx_act;
+
+ /*
+ * retransmit code:
+ * Normal situtations first for fast path:
+ * If acknowledgement received ok or broadcast, we're ok.
+ * else if
+ */
+
+ if (isr & ARC_TMA || sc->sc_broadcast[buffer])
+ sc->sc_arccom.ac_if.if_opackets++;
+#ifdef BAHRETRANSMIT
+ else if (ifp->if_flags & IFF_LINK2 && ifp->if_timer > 0
+ && --sc->sc_retransmits[buffer] > 0) {
+ /* retransmit same buffer */
+ sc->sc_base->command = ARC_TX(buffer);
+ return;
+ }
+#endif
+ else
+ ifp->if_oerrors++;
+
+
+#ifdef BAHTIMINGS
+ clknow = clkread();
+
+ sc->sc_stats.minsend = ulmin(sc->sc_stats.minsend,
+ clknow - sc->sc_stats.lasttxstart_mics);
+
+ sc->sc_stats.maxsend = ulmax(sc->sc_stats.maxsend,
+ clknow - sc->sc_stats.lasttxstart_mics);
+#endif
+
+ /* We know we can accept another buffer at this point. */
+ ifp->if_flags &= ~IFF_OACTIVE;
+
+ if (--sc->sc_tx_fillcount > 0) {
+
+ /*
+ * start tx on other buffer.
+ * This also clears the int flag
+ */
+ buffer ^= 1;
+ sc->sc_tx_act = buffer;
+
+ /*
+ * already given:
+ * sc->sc_intmask |= ARC_TA;
+ * sc->sc_base->status = sc->sc_intmask;
+ */
+ sc->sc_base->command = ARC_TX(buffer);
+ /* init watchdog timer */
+ ifp->if_timer = ARCTIMEOUT;
+
+#ifdef BAHTIMINGS
+ bcopy((caddr_t)&time,
+ (caddr_t)&(sc->sc_stats.lasttxstart_tv),
+ sizeof(struct timeval));
+
+ sc->sc_stats.lasttxstart_mics = clkread();
+#endif
+
+#if defined(BAH_DEBUG) && (BAH_DEBUG > 1)
+ printf("%s: tint: starting tx on buffer %d, status 0x%02x\n",
+ sc->sc_dev.dv_xname, buffer, sc->sc_base->status);
+#endif
+ } else {
+ /* have to disable TX interrupt */
+ sc->sc_intmask &= ~ARC_TA;
+ sc->sc_base->status = sc->sc_intmask;
+ /* ... and watchdog timer */
+ ifp->if_timer = 0;
+
+#ifdef BAH_DEBUG
+ printf("%s: tint: no more buffers to send, status 0x%02x\n",
+ sc->sc_dev.dv_xname, sc->sc_base->status);
+#endif
+ }
+
+#ifdef BAHSOFTCOPY
+ /* schedule soft int to fill a new buffer for us */
+ add_sicallback((sifunc_t)callstart, sc, NULL);
+#else
+ /* call it directly */
+ callstart(sc, NULL);
+#endif
+}
+
+/*
+ * Our interrupt routine
+ */
+int
+bahintr(sc)
+ struct bah_softc *sc;
+{
+ u_char isr, maskedisr;
+ int buffer;
+ u_long newsec;
+
+ isr = sc->sc_base->status;
+ maskedisr = isr & sc->sc_intmask;
+ if (!maskedisr)
+ return (0);
+
+#if defined(BAH_DEBUG) && (BAH_DEBUG>1)
+ printf("%s: intr: status 0x%02x, intmask 0x%02x\n",
+ sc->sc_dev.dv_xname, isr, sc->sc_intmask);
+#endif
+
+ if (maskedisr & ARC_POR) {
+ sc->sc_arccom.ac_anaddr = sc->sc_base->dipswitches;
+ sc->sc_base->command = ARC_CLR(CLR_POR);
+ log(LOG_WARNING, "%s: intr: got spurious power on reset int\n",
+ sc->sc_dev.dv_xname);
+ }
+
+ if (maskedisr & ARC_RECON) {
+ /*
+ * we dont need to:
+ * sc->sc_base->command = ARC_CONF(CONF_LONG);
+ */
+ sc->sc_base->command = ARC_CLR(CLR_RECONFIG);
+ sc->sc_arccom.ac_if.if_collisions++;
+
+ /*
+ * If more than 2 seconds per reconfig:
+ * Reset time and counter.
+ * else:
+ * If more than ARC_EXCESSIVE_RECONFIGS reconfigs
+ * since last burst, complain and set treshold for
+ * warnings to ARC_EXCESSIVE_RECONS_REWARN.
+ *
+ * This allows for, e.g., new stations on the cable, or
+ * cable switching as long as it is over after (normally)
+ * 16 seconds.
+ *
+ * XXX TODO: check timeout bits in status word and double
+ * time if necessary.
+ */
+
+ newsec = time.tv_sec;
+ if (newsec - sc->sc_recontime > 2 * sc->sc_reconcount) {
+ sc->sc_recontime = newsec;
+ sc->sc_reconcount = 0;
+ sc->sc_reconcount_excessive = ARC_EXCESSIVE_RECONS;
+ } else if (++sc->sc_reconcount > sc->sc_reconcount_excessive) {
+ sc->sc_reconcount_excessive =
+ ARC_EXCESSIVE_RECONS_REWARN;
+ log(LOG_WARNING,
+ "%s: excessive token losses, cable problem?\n",
+ sc->sc_dev.dv_xname);
+ sc->sc_recontime = newsec;
+ sc->sc_reconcount = 0;
+ }
+ }
+
+ if (maskedisr & ARC_RI) {
+
+#if defined(BAH_DEBUG) && (BAH_DEBUG > 1)
+ printf("%s: intr: hard rint, act %ld\n",
+ sc->sc_dev.dv_xname, sc->sc_rx_act);
+#endif
+
+ buffer = sc->sc_rx_act;
+ /* look if buffer is marked invalid: */
+ if (sc->sc_base->buffers[buffer*512*2] == 0) {
+ /* invalid marked buffer (or illegally configured sender) */
+ log(LOG_WARNING,
+ "%s: spurious RX interrupt or sender 0 (ignored)\n",
+ sc->sc_dev.dv_xname);
+ /*
+ * restart receiver on same buffer.
+ */
+ sc->sc_base->command = ARC_RXBC(buffer);
+
+ } else if (++sc->sc_rx_fillcount > 1) {
+ sc->sc_intmask &= ~ARC_RI;
+ sc->sc_base->status = sc->sc_intmask;
+ } else {
+
+ buffer ^= 1;
+ sc->sc_rx_act = buffer;
+
+ /*
+ * Start receiver on other receive buffer.
+ * This also clears the RI interupt flag.
+ */
+ sc->sc_base->command = ARC_RXBC(buffer);
+ /* we are in the RX intr, so mask is ok for RX */
+
+#ifdef BAH_DEBUG
+ printf("%s: started rx for buffer %ld, status 0x%02x\n",
+ sc->sc_dev.dv_xname, sc->sc_rx_act,
+ sc->sc_base->status);
+#endif
+ }
+
+#ifdef BAHSOFTCOPY
+ /* this one starts a soft int to copy out of the hw */
+ add_sicallback((sifunc_t)bah_srint, sc,NULL);
+#else
+ /* this one does the copy here */
+ bah_srint(sc,NULL);
+#endif
+ }
+
+ if (maskedisr & ARC_TA)
+ bah_tint(sc, isr);
+
+ return (1);
+}
+
+/*
+ * Process an ioctl request.
+ * This code needs some work - it looks pretty ugly.
+ */
+int
+bah_ioctl(ifp, command, data)
+ register struct ifnet *ifp;
+ u_long command;
+ caddr_t data;
+{
+ struct bah_softc *sc;
+ register struct ifaddr *ifa;
+ int s, error;
+
+ error = 0;
+ sc = bah_cd.cd_devs[ifp->if_unit];
+ ifa = (struct ifaddr *)data;
+ s = splnet();
+
+#if defined(BAH_DEBUG) && (BAH_DEBUG > 2)
+ printf("%s: ioctl() called, cmd = 0x%x\n",
+ sc->sc_dev.dv_xname, command);
+#endif
+
+ switch (command) {
+ case SIOCSIFADDR:
+ ifp->if_flags |= IFF_UP;
+ switch (ifa->ifa_addr->sa_family) {
+#ifdef INET
+ case AF_INET:
+ bah_init(sc);
+ break;
+#endif
+ default:
+ bah_init(sc);
+ break;
+ }
+
+ case SIOCSIFFLAGS:
+ if ((ifp->if_flags & IFF_UP) == 0 &&
+ (ifp->if_flags & IFF_RUNNING) != 0) {
+ /*
+ * If interface is marked down and it is running,
+ * then stop it.
+ */
+ bah_stop(sc);
+ ifp->if_flags &= ~IFF_RUNNING;
+ } else if ((ifp->if_flags & IFF_UP) != 0 &&
+ (ifp->if_flags & IFF_RUNNING) == 0) {
+ /*
+ * If interface is marked up and it is stopped, then
+ * start it.
+ */
+ bah_init(sc);
+ }
+ break;
+
+ /* Multicast not supported */
+
+ default:
+ error = EINVAL;
+ }
+
+ splx(s);
+ return (error);
+}
+
+/*
+ * watchdog routine for transmitter.
+ *
+ * We need this, because else a receiver whose hardware is alive, but whose
+ * software has not enabled the Receiver, would make our hardware wait forever
+ * Discovered this after 20 times reading the docs.
+ *
+ * Only thing we do is disable transmitter. We'll get an transmit timeout,
+ * and the int handler will have to decide not to retransmit (in case
+ * retransmission is implemented).
+ *
+ * This one assumes being called inside splnet(), and that net >= ipl2
+ */
+
+void
+bah_watchdog(unit)
+int unit;
+{
+ struct bah_softc *sc;
+ struct ifnet *ifp;
+
+ sc = bah_cd.cd_devs[unit];
+ ifp = &(sc->sc_arccom.ac_if);
+
+ sc->sc_base->command = ARC_TXDIS;
+ return;
+}
--- /dev/null
+/* $NetBSD: smc90cx6reg.h,v 1.4 1995/06/07 00:16:59 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Ignatios Souvatzis
+ * 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 Ignatios Souvatzis
+ * for the NetBSD project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * The A2060/A560 card use the SMC COM90C26 Arcnet chipset.
+ * First or last 16k segment, resp., write a fifo which drives the reset line.
+ * 2nd 16k segment contains the registers.
+ * 3rd 16k segment contains the buffer RAM.
+ * All are only accessible at even addresses.
+ */
+
+/* CBM Arcnet board */
+#define MANUFACTURER_1 514
+#define PRODUCT_1 9
+
+/* Ameristar board */
+#define MANUFACTURER_2 1053
+#define PRODUCT_2 9
+
+struct a2060 {
+ volatile u_int8_t kick1;
+ u_int8_t pad1[16383];
+ volatile u_int8_t status; /* also intmask */
+ u_int8_t pad2;
+ volatile u_int8_t command;
+ u_int8_t pad3[16381];
+ volatile u_int8_t buffers[4096]; /* even bytes only */
+ u_int8_t pad4[12228];
+ volatile u_int8_t kick2;
+ u_int8_t pad5[16383];
+};
+
+#define checkbyte buffers[0]
+#define dipswitches buffers[2]
+
+/* calculate address for board b, buffer no n and offset o */
+#define BUFPTR(b,n,o) (&(b)->buffers[(n)*512+(o)*2])
+
+#define ARC_TXDIS 0x01
+#define ARC_RXDIS 0x02
+#define ARC_TX(x) (0x03 | ((x)<<3))
+#define ARC_RX(x) (0x04 | ((x)<<3))
+#define ARC_RXBC(x) (0x84 | ((x)<<3))
+
+#define ARC_CONF(x) (0x05 | (x))
+#define CLR_POR 0x08
+#define CLR_RECONFIG 0x10
+
+#define ARC_CLR(x) (0x06 | (x))
+#define CONF_LONG 0x08
+#define CONF_SHORT 0x00
+
+/*
+ * These are not in the COM90C65 docs. Derived from the arcnet.asm
+ * packet driver by Philippe Prindeville and Russel Nelson.
+ */
+
+#define ARC_LDTST(x) (0x07 | (x))
+#define TEST_ON 0x08
+#define TEST_OFF 0x00
+
+#define ARC_TA 1 /* int mask also */
+#define ARC_TMA 2
+#define ARC_RECON 4 /* int mask also */
+#define ARC_TEST 8 /* not in the COM90C65 docs (see above) */
+#define ARC_POR 0x10 /* non maskable interrupt */
+#define ARC_ET1 0x20 /* timeout value bits, normally 1 */
+#define ARC_ET2 0x40 /* timeout value bits, normally 1 */
+#define ARC_RI 0x80 /* int mask also */
-/* $NetBSD: z8530sc.c,v 1.1 1996/01/24 01:07:23 gwr Exp $ */
+/* $OpenBSD: z8530sc.c,v 1.2 1996/04/21 22:21:35 deraadt Exp $ */
+/* $NetBSD: z8530sc.c,v 1.3 1996/04/10 21:44:35 gwr Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
cs->cs_preg[5] &= ~ZSWR5_BREAK;
cs->cs_creg[5] &= ~ZSWR5_BREAK;
}
- ZS_WRITE(cs, 5, cs->cs_creg[5]);
+ zs_write_reg(cs, 5, cs->cs_creg[5]);
splx(s);
}
{
int tconst;
- tconst = ZS_READ(cs, 12);
- tconst |= ZS_READ(cs, 13) << 8;
+ tconst = zs_read_reg(cs, 12);
+ tconst |= zs_read_reg(cs, 13) << 8;
return (TCONST_TO_BPS(cs->cs_pclk_div16, tconst));
}
for (;;) {
/* Is there input available? */
- rr0 = *(cs->cs_reg_csr);
- ZS_DELAY();
+ rr0 = zs_read_csr(cs);
if ((rr0 & ZSRR0_RX_READY) == 0)
break;
- /* Read the data. */
- c = *(cs->cs_reg_data);
- ZS_DELAY();
+ /*
+ * First read the status, because reading the data
+ * destroys the status of this char.
+ */
+ rr1 = zs_read_reg(cs, 1);
+ c = zs_read_data(cs);
- /* Need to read status register too? */
- rr1 = ZS_READ(cs, 1);
if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
/* Clear the receive error. */
- *(cs->cs_reg_csr) = ZSWR0_RESET_ERRORS;
- ZS_DELAY();
+ zs_write_csr(cs, ZSWR0_RESET_ERRORS);
}
}
}
bcopy((caddr_t)cs->cs_preg, (caddr_t)cs->cs_creg, 16);
reg = cs->cs_creg; /* current regs */
- *(cs->cs_reg_csr) = ZSM_RESET_ERR; /* XXX: reset error condition */
- ZS_DELAY();
+ zs_write_csr(cs, ZSM_RESET_ERR); /* XXX: reset error condition */
#if 1
/*
#endif
/* baud clock divisor, stop bits, parity */
- ZS_WRITE(cs, 4, reg[4]);
+ zs_write_reg(cs, 4, reg[4]);
/* misc. TX/RX control bits */
- ZS_WRITE(cs, 10, reg[10]);
+ zs_write_reg(cs, 10, reg[10]);
/* char size, enable (RX/TX) */
- ZS_WRITE(cs, 3, reg[3] & ~ZSWR3_RX_ENABLE);
- ZS_WRITE(cs, 5, reg[5] & ~ZSWR5_TX_ENABLE);
+ zs_write_reg(cs, 3, reg[3] & ~ZSWR3_RX_ENABLE);
+ zs_write_reg(cs, 5, reg[5] & ~ZSWR5_TX_ENABLE);
/* interrupt enables: TX, TX, STATUS */
- ZS_WRITE(cs, 1, reg[1]);
+ zs_write_reg(cs, 1, reg[1]);
#if 0
/*
* and they should not be touched thereafter.
*/
/* interrupt vector */
- ZS_WRITE(cs, 2, reg[2]);
+ zs_write_reg(cs, 2, reg[2]);
/* master interrupt control */
- ZS_WRITE(cs, 9, reg[9]);
+ zs_write_reg(cs, 9, reg[9]);
#endif
/* clock mode control */
- ZS_WRITE(cs, 11, reg[11]);
+ zs_write_reg(cs, 11, reg[11]);
/* baud rate (lo/hi) */
- ZS_WRITE(cs, 12, reg[12]);
- ZS_WRITE(cs, 13, reg[13]);
+ zs_write_reg(cs, 12, reg[12]);
+ zs_write_reg(cs, 13, reg[13]);
/* Misc. control bits */
- ZS_WRITE(cs, 14, reg[14]);
+ zs_write_reg(cs, 14, reg[14]);
/* which lines cause status interrupts */
- ZS_WRITE(cs, 15, reg[15]);
+ zs_write_reg(cs, 15, reg[15]);
/* char size, enable (RX/TX)*/
- ZS_WRITE(cs, 3, reg[3]);
- ZS_WRITE(cs, 5, reg[5]);
+ zs_write_reg(cs, 3, reg[3]);
+ zs_write_reg(cs, 5, reg[5]);
}
register struct zsc_softc *zsc = arg;
register struct zs_chanstate *cs_a;
register struct zs_chanstate *cs_b;
- register int rval, soft;
+ register int rval;
register u_char rr3;
cs_a = &zsc->zsc_cs[0];
cs_b = &zsc->zsc_cs[1];
rval = 0;
- soft = 0;
/* Note: only channel A has an RR3 */
- rr3 = ZS_READ(cs_a, 3);
+ rr3 = zs_read_reg(cs_a, 3);
/* Handle receive interrupts first. */
if (rr3 & ZSRR3_IP_A_RX)
if (rr3 & ZSRR3_IP_B_RX)
(*cs_b->cs_ops->zsop_rxint)(cs_b);
+ /* Handle status interrupts (i.e. flow control). */
+ if (rr3 & ZSRR3_IP_A_STAT)
+ (*cs_a->cs_ops->zsop_stint)(cs_a);
+ if (rr3 & ZSRR3_IP_B_STAT)
+ (*cs_b->cs_ops->zsop_stint)(cs_b);
+
/* Handle transmit done interrupts. */
if (rr3 & ZSRR3_IP_A_TX)
(*cs_a->cs_ops->zsop_txint)(cs_a);
if (rr3 & ZSRR3_IP_B_TX)
(*cs_b->cs_ops->zsop_txint)(cs_b);
- /* Handle status interrupts. */
- if (rr3 & ZSRR3_IP_A_STAT)
- (*cs_a->cs_ops->zsop_stint)(cs_a);
- if (rr3 & ZSRR3_IP_B_STAT)
- (*cs_b->cs_ops->zsop_stint)(cs_b);
-
/* Clear interrupt. */
if (rr3 & (ZSRR3_IP_A_RX | ZSRR3_IP_A_TX | ZSRR3_IP_A_STAT)) {
- *(cs_a->cs_reg_csr) = ZSWR0_CLR_INTR;
- ZS_DELAY();
+ zs_write_csr(cs_a, ZSWR0_CLR_INTR);
rval |= 1;
}
if (rr3 & (ZSRR3_IP_B_RX | ZSRR3_IP_B_TX | ZSRR3_IP_B_STAT)) {
- *(cs_b->cs_reg_csr) = ZSWR0_CLR_INTR;
- ZS_DELAY();
+ zs_write_csr(cs_b, ZSWR0_CLR_INTR);
rval |= 2;
}
- if ((cs_a->cs_softreq) || (cs_b->cs_softreq))
- {
- /* This is a machine-dependent function. */
+ if ((cs_a->cs_softreq) || (cs_b->cs_softreq)) {
+ /* This is a machine-dependent function (or macro). */
zsc_req_softint(zsc);
}
{
register struct zsc_softc *zsc = arg;
register struct zs_chanstate *cs;
- register int req, rval, s, unit;
+ register int rval, unit;
rval = 0;
for (unit = 0; unit < 2; unit++) {
cs = &zsc->zsc_cs[unit];
- s = splzs();
- req = cs->cs_softreq;
- cs->cs_softreq = 0;
- splx(s);
-
- if (req) {
+ /*
+ * The softint flag can be safely cleared once
+ * we have decided to call the softint routine.
+ * (No need to do splzs() first.)
+ */
+ if (cs->cs_softreq) {
+ cs->cs_softreq = 0;
(*cs->cs_ops->zsop_softint)(cs);
rval = 1;
}
}
-static int
+static void
zsnull_intr(cs)
struct zs_chanstate *cs;
{
- ZS_WRITE(cs, 1, 0);
- ZS_WRITE(cs, 15, 0);
+ zs_write_reg(cs, 1, 0);
+ zs_write_reg(cs, 15, 0);
}
-static int
+static void
zsnull_softint(cs)
struct zs_chanstate *cs;
{
-/* $NetBSD: z8530sc.h,v 1.1 1996/01/24 01:07:24 gwr Exp $ */
+/* $NetBSD: z8530sc.h,v 1.2 1996/04/10 21:44:44 gwr Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
* Function vector - per channel
*/
struct zsops {
- int (*zsop_rxint)(); /* receive char available */
- int (*zsop_stint)(); /* external/status */
- int (*zsop_txint)(); /* xmit buffer empty */
- int (*zsop_softint)(); /* process software interrupt */
+ void (*zsop_rxint)(); /* receive char available */
+ void (*zsop_stint)(); /* external/status */
+ void (*zsop_txint)(); /* xmit buffer empty */
+ void (*zsop_softint)(); /* process software interrupt */
};
extern struct zsops zsops_null;
u_char cs_heldchange; /* change pending (creg != preg) */
u_char cs_rr0; /* last rr0 processed */
+ u_char cs_rr0_new; /* rr0 saved in status interrupt. */
char cs_softreq; /* need soft interrupt call */
- char cs__spare;
};
struct zsc_softc {
-/* $OpenBSD: z8530tty.c,v 1.2 1996/04/18 23:47:26 niklas Exp $ */
-/* $NetBSD: z8530tty.c,v 1.1 1996/01/24 01:07:25 gwr Exp $ */
+/* $OpenBSD: z8530tty.c,v 1.3 1996/04/21 22:21:46 deraadt Exp $ */
+/* $NetBSD: z8530tty.c,v 1.6 1996/04/10 21:44:47 gwr Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/ioctl.h>
+#include <sys/malloc.h>
#include <sys/tty.h>
#include <sys/time.h>
#include <sys/kernel.h>
* Note: must be a power of two!
*/
#ifndef ZSTTY_RING_SIZE
-#define ZSTTY_RING_SIZE 1024
+#define ZSTTY_RING_SIZE 2048
#endif
-#define ZSTTY_RING_MASK (ZSTTY_RING_SIZE-1)
+
+/*
+ * Make this an option variable one can patch.
+ * But be warned: this must be a power of 2!
+ */
+int zstty_rbuf_size = ZSTTY_RING_SIZE;
struct zstty_softc {
struct device zst_dev; /* required first: base device */
*/
u_int zst_rbget; /* ring buffer `get' index */
volatile u_int zst_rbput; /* ring buffer `put' index */
- u_short zst_rbuf[ZSTTY_RING_SIZE]; /* rr1, data pairs */
+ u_int zst_ringmask;
+ u_short *zst_rbuf; /* rr1, data pairs */
};
static int zstty_match(struct device *, void *, void *);
static void zstty_attach(struct device *, struct device *, void *);
-struct cfdriver zsttycd = {
- NULL, "zstty", zstty_match, zstty_attach,
- DV_TTY, sizeof(struct zstty_softc), NULL,
+struct cfattach zstty_ca = {
+ sizeof(struct zstty_softc), zstty_match, zstty_attach
+};
+
+struct cfdriver zstty_cd = {
+ NULL, "zstty", DV_TTY
};
struct zsops zsops_tty;
}
printf("\n");
- tp = zst->zst_tty = ttymalloc();
+ tp = ttymalloc();
tp->t_dev = dev;
tp->t_oproc = zsstart;
tp->t_param = zsparam;
+ zst->zst_tty = tp;
+ zst->zst_ringmask = zstty_rbuf_size - 1;
+ zst->zst_rbuf = malloc(zstty_rbuf_size * sizeof(zst->zst_rbuf[0]),
+ M_DEVBUF, M_WAITOK);
+
/*
* Hardware init
*/
reset = (channel == 0) ?
ZSWR9_A_RESET : ZSWR9_B_RESET;
s = splzs();
- ZS_WRITE(cs, 9, reset);
+ zs_write_reg(cs, 9, reset);
splx(s);
}
int unit = minor(dev);
#ifdef DIAGNOSTIC
- if (unit >= zsttycd.cd_ndevs)
+ if (unit >= zstty_cd.cd_ndevs)
panic("zstty");
#endif
- zst = zsttycd.cd_devs[unit];
+ zst = zstty_cd.cd_devs[unit];
return (zst->zst_tty);
}
int error, s, unit;
unit = minor(dev);
- if (unit >= zsttycd.cd_ndevs)
+ if (unit >= zstty_cd.cd_ndevs)
return (ENXIO);
- zst = zsttycd.cd_devs[unit];
+ zst = zstty_cd.cd_devs[unit];
if (zst == NULL)
return (ENXIO);
tp = zst->zst_tty;
/* Wait for carrier. */
for (;;) {
- register int rr0;
/* Might never get status intr if carrier already on. */
- rr0 = *(cs->cs_reg_csr);
- ZS_DELAY();
- if (rr0 & ZSRR0_DCD) {
+ cs->cs_rr0 = zs_read_csr(cs);
+ if (cs->cs_rr0 & ZSRR0_DCD) {
tp->t_state |= TS_CARR_ON;
break;
}
struct zsinfo *zi;
int hup, s;
- zst = zsttycd.cd_devs[minor(dev)];
+ zst = zstty_cd.cd_devs[minor(dev)];
cs = zst->zst_cs;
tp = zst->zst_tty;
register struct zstty_softc *zst;
register struct tty *tp;
- zst = zsttycd.cd_devs[minor(dev)];
+ zst = zstty_cd.cd_devs[minor(dev)];
tp = zst->zst_tty;
return (linesw[tp->t_line].l_read(tp, uio, flags));
}
register struct zstty_softc *zst;
register struct tty *tp;
- zst = zsttycd.cd_devs[minor(dev)];
+ zst = zstty_cd.cd_devs[minor(dev)];
tp = zst->zst_tty;
return (linesw[tp->t_line].l_write(tp, uio, flags));
}
register struct tty *tp;
register int error, tmp;
- zst = zsttycd.cd_devs[minor(dev)];
+ zst = zstty_cd.cd_devs[minor(dev)];
cs = zst->zst_cs;
tp = zst->zst_tty;
register struct zs_chanstate *cs;
register int s, nch;
- zst = zsttycd.cd_devs[minor(tp->t_dev)];
+ zst = zstty_cd.cd_devs[minor(tp->t_dev)];
cs = zst->zst_cs;
s = spltty();
cs->cs_preg[1] |= ZSWR1_TIE;
cs->cs_creg[1] |= ZSWR1_TIE;
- ZS_WRITE(cs, 1, cs->cs_creg[1]);
- *(cs->cs_reg_data) = *p;
- ZS_DELAY();
+ zs_write_reg(cs, 1, cs->cs_creg[1]);
+ zs_write_data(cs, *p);
zst->zst_tba = p + 1;
zst->zst_tbc = nch - 1;
} else {
(void) splzs();
cs->cs_preg[1] &= ~ZSWR1_TIE;
cs->cs_creg[1] &= ~ZSWR1_TIE;
- ZS_WRITE(cs, 1, cs->cs_creg[1]);
+ zs_write_reg(cs, 1, cs->cs_creg[1]);
}
out:
splx(s);
register struct zs_chanstate *cs;
register int s;
- zst = zsttycd.cd_devs[minor(tp->t_dev)];
+ zst = zstty_cd.cd_devs[minor(tp->t_dev)];
cs = zst->zst_cs;
s = splzs();
register int s, bps, cflag, tconst;
u_char tmp3, tmp4, tmp5, reset;
- zst = zsttycd.cd_devs[minor(tp->t_dev)];
+ zst = zstty_cd.cd_devs[minor(tp->t_dev)];
cs = zst->zst_cs;
/*
*/
tmp3 |= ZSWR3_RX_ENABLE;
if (cflag & CCTS_OFLOW) {
- if (*(cs->cs_reg_csr) & ZSRR0_DCD)
+ if (zs_read_csr(cs) & ZSRR0_DCD)
tmp3 |= ZSWR3_HFC;
- ZS_DELAY();
}
cs->cs_preg[3] = tmp3;
cs->cs_heldchange = 1;
} else {
cs->cs_creg[5] = (cs->cs_creg[5] | bis) & and;
- ZS_WRITE(cs, 5, cs->cs_creg[5]);
+ zs_write_reg(cs, 5, cs->cs_creg[5]);
}
}
splx(s);
* XXX: need to do input flow-control to avoid ring overrun.
*/
-static int
+/*
+ * receiver ready interrupt. (splzs)
+ */
+static void
zstty_rxint(cs)
register struct zs_chanstate *cs;
{
register struct zstty_softc *zst;
- register put, put_next;
+ register put, put_next, ringmask;
register u_char c, rr0, rr1;
zst = cs->cs_private;
put = zst->zst_rbput;
+ ringmask = zst->zst_ringmask;
nextchar:
- /* Read the input data ASAP. */
- c = *(cs->cs_reg_data);
- ZS_DELAY();
- /* Save the status register too. */
- rr1 = ZS_READ(cs, 1);
+ /*
+ * First read the status, because reading the received char
+ * destroys the status of this char.
+ */
+ rr1 = zs_read_reg(cs, 1);
+ c = zs_read_data(cs);
if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
/* Clear the receive error. */
- *(cs->cs_reg_csr) = ZSWR0_RESET_ERRORS;
- ZS_DELAY();
+ zs_write_csr(cs, ZSWR0_RESET_ERRORS);
}
zst->zst_rbuf[put] = (c << 8) | rr1;
- put_next = (put + 1) & ZSTTY_RING_MASK;
+ put_next = (put + 1) & ringmask;
/* Would overrun if increment makes (put==get). */
if (put_next == zst->zst_rbget) {
}
/* Keep reading until the FIFO is empty. */
- rr0 = *(cs->cs_reg_csr);
- ZS_DELAY();
+ rr0 = zs_read_csr(cs);
if (rr0 & ZSRR0_RX_READY)
goto nextchar;
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return(1);
}
-static int
+/*
+ * transmitter ready interrupt. (splzs)
+ */
+static void
zstty_txint(cs)
register struct zs_chanstate *cs;
{
register struct zstty_softc *zst;
- register int count, rval;
+ register int count;
zst = cs->cs_private;
count = zst->zst_tbc;
+ /*
+ * If our transmit buffer still has data,
+ * just send the next character.
+ */
if (count > 0) {
/* Send the next char. */
- *(cs->cs_reg_data) = *zst->zst_tba++;
- ZS_DELAY();
zst->zst_tbc = --count;
- rval = 0;
- } else {
- /* Nothing more to send. */
- *(cs->cs_reg_csr) = ZSWR0_RESET_TXINT;
- ZS_DELAY();
- zst->zst_intr_flags |= INTR_TX_EMPTY;
- rval = 1; /* want softcall */
+ zs_write_data(cs, *zst->zst_tba);
+ zst->zst_tba++;
+ return;
}
- cs->cs_softreq = rval;
- return (rval);
+ zs_write_csr(cs, ZSWR0_RESET_TXINT);
+
+ /* Ask the softint routine for more output. */
+ zst->zst_intr_flags |= INTR_TX_EMPTY;
+ cs->cs_softreq = 1;
}
-static int
+/*
+ * status change interrupt. (splzs)
+ */
+static void
zstty_stint(cs)
register struct zs_chanstate *cs;
{
register struct zstty_softc *zst;
- register int rr0;
+ register struct tty *tp;
+ register u_char rr0;
zst = cs->cs_private;
+ tp = zst->zst_tty;
- rr0 = *(cs->cs_reg_csr);
- ZS_DELAY();
+ rr0 = zs_read_csr(cs);
+ zs_write_csr(cs, ZSWR0_RESET_STATUS);
- *(cs->cs_reg_csr) = ZSWR0_RESET_STATUS;
- ZS_DELAY();
+ /*
+ * The chip's hardware flow control is, as noted in zsreg.h,
+ * busted---if the DCD line goes low the chip shuts off the
+ * receiver (!). If we want hardware CTS flow control but do
+ * not have it, and carrier is now on, turn HFC on; if we have
+ * HFC now but carrier has gone low, turn it off.
+ */
+ if (rr0 & ZSRR0_DCD) {
+ if (tp->t_cflag & CCTS_OFLOW &&
+ (cs->cs_creg[3] & ZSWR3_HFC) == 0) {
+ cs->cs_creg[3] |= ZSWR3_HFC;
+ zs_write_reg(cs, 3, cs->cs_creg[3]);
+ }
+ } else {
+ if (cs->cs_creg[3] & ZSWR3_HFC) {
+ cs->cs_creg[3] &= ~ZSWR3_HFC;
+ zs_write_reg(cs, 3, cs->cs_creg[3]);
+ }
+ }
- if ((rr0 & ZSRR0_BREAK) &&
+ /*
+ * Check here for console break, so that we can abort
+ * even when interrupts are locking up the machine.
+ */
+ if ((rr0 & ZSRR0_BREAK) &&
(zst->zst_hwflags & ZS_HWFLAG_CONSOLE))
{
zs_abort();
- return (0);
+ return;
}
+ cs->cs_rr0_new = rr0;
zst->zst_intr_flags |= INTR_ST_CHECK;
+
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return (1);
}
/*
}
}
-static int
+/*
+ * Software interrupt. Called at zssoft
+ */
+static void
zstty_softint(cs)
struct zs_chanstate *cs;
{
register struct linesw *line;
register struct tty *tp;
register int get, c, s;
- int intr_flags;
+ int intr_flags, ringmask;
register u_short ring_data;
register u_char rr0, rr1;
zst = cs->cs_private;
tp = zst->zst_tty;
line = &linesw[tp->t_line];
+ ringmask = zst->zst_ringmask;
/* Atomically get and clear flags. */
s = splzs();
intr_flags = zst->zst_intr_flags;
zst->zst_intr_flags = 0;
- splx(s);
+
+ /*
+ * Lower to tty priority while servicing the ring.
+ */
+ (void) spltty();
if (intr_flags & INTR_RX_OVERRUN) {
/* May turn this on again below. */
intr_flags &= ~INTR_RX_OVERRUN;
- zsoverrun(zst, "ring");
+ zsoverrun(zst, &zst->zst_rotime, "ring");
}
/*
get = zst->zst_rbget;
while (get != zst->zst_rbput) {
ring_data = zst->zst_rbuf[get];
- get = (get + 1) & ZSTTY_RING_MASK;
+ get = (get + 1) & ringmask;
if (ring_data & ZSRR1_DO)
intr_flags |= INTR_RX_OVERRUN;
}
zst->zst_rbget = get;
- /* If set, it is from the loop above. */
+ /*
+ * If the overrun flag is set now, it was set while
+ * copying char/status pairs from the ring, which
+ * means this was a hardware (fifo) overrun.
+ */
if (intr_flags & INTR_RX_OVERRUN) {
- zsoverrun(zst, "fifo");
+ zsoverrun(zst, &zst->zst_fotime, "fifo");
}
if (intr_flags & INTR_TX_EMPTY) {
/*
- * Transmit done. Change registers and resume,
- * or just clear BUSY.
+ * The transmitter output buffer count is zero.
+ * If we suspended output for a "held" change,
+ * then handle that now and resume. Otherwise,
+ * try to start a new output chunk.
*/
if (cs->cs_heldchange) {
- s = splzs();
- rr0 = *(cs->cs_reg_csr);
- ZS_DELAY();
+ (void) splzs();
+ rr0 = zs_read_csr(cs);
if ((rr0 & ZSRR0_DCD) == 0)
cs->cs_preg[3] &= ~ZSWR3_HFC;
zs_loadchannelregs(cs);
- splx(s);
+ (void) spltty();
cs->cs_heldchange = 0;
-
if (zst->zst_heldtbc &&
(tp->t_state & TS_TTSTOP) == 0)
{
zst->zst_tbc = zst->zst_heldtbc - 1;
- *(cs->cs_reg_data) = *zst->zst_tba++;
- ZS_DELAY();
+ zs_write_data(cs, *zst->zst_tba);
+ zst->zst_tba++;
goto tx_resumed;
}
}
if (intr_flags & INTR_ST_CHECK) {
/*
- * Status line change.
- *
- * The chip's hardware flow control is, as noted in zsreg.h,
- * busted---if the DCD line goes low the chip shuts off the
- * receiver (!). If we want hardware CTS flow control but do
- * not have it, and carrier is now on, turn HFC on; if we have
- * HFC now but carrier has gone low, turn it off.
+ * Status line change. HFC bit is run in
+ * hardware interrupt, to avoid locking
+ * at splzs here.
*/
- s = splzs();
- rr0 = *(cs->cs_reg_csr);
- if (rr0 & ZSRR0_DCD) {
- if (tp->t_cflag & CCTS_OFLOW &&
- (cs->cs_creg[3] & ZSWR3_HFC) == 0) {
- cs->cs_creg[3] |= ZSWR3_HFC;
- ZS_WRITE(cs, 3, cs->cs_creg[3]);
- }
- } else {
- if (cs->cs_creg[3] & ZSWR3_HFC) {
- cs->cs_creg[3] &= ~ZSWR3_HFC;
- ZS_WRITE(cs, 3, cs->cs_creg[3]);
- }
- }
- splx(s);
-
- /* Was there a change on DCD? */
+ rr0 = cs->cs_rr0_new;
if ((rr0 ^ cs->cs_rr0) & ZSRR0_DCD) {
c = ((rr0 & ZSRR0_DCD) != 0);
if (line->l_modem(tp, c) == 0)
cs->cs_rr0 = rr0;
}
- return (1);
+ splx(s);
}
struct zsops zsops_tty = {
zstty_txint, /* xmit buffer empty */
zstty_softint, /* process software interrupt */
};
+
-/* $OpenBSD: aha.c,v 1.13 1996/03/20 01:00:35 mickey Exp $ */
-/* $NetBSD: aha1542.c,v 1.55 1995/12/24 02:31:06 mycroft Exp $ */
+/* $NetBSD: aha.c,v 1.7 1996/04/11 22:27:59 cgd Exp $ */
+
+#define AHADIAG
+#define integrate
/*
- * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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 Charles Hannum.
+ * This product includes software developed by Charles M. Hannum.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* functioning of this software in any circumstances.
*/
-/*
- * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
- */
-
#include <sys/types.h>
#include <sys/param.h>
-#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <machine/pio.h>
-#include <dev/isa/isavar.h>
-#include <dev/isa/isadmavar.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
+#include <dev/isa/isavar.h>
+#include <dev/isa/isadmavar.h>
+#include <dev/isa/ahareg.h>
+
#ifndef DDB
#define Debugger() panic("should call debugger here (aha1542.c)")
#endif /* ! DDB */
-/* XXX fixme:
- * on i386 at least, xfers to/from user memory
- * cannot be serviced at interrupt time.
- */
-#ifdef i386
-#define VOLATILE_XS(xs) \
- ((xs)->datalen > 0 && (xs)->bp == NULL && \
- ((xs)->flags & SCSI_POLL) == 0)
-#else
-#define VOLATILE_XS(xs) 0
-#endif
-
-#undef TUNE_1542 /* if bus speed check breaks the machine, undefine it */
-
-/************************** board definitions *******************************/
-
-/*
- * I/O Port Interface
- */
-#define AHA_BASE aha->sc_iobase
-#define AHA_CTRL_STAT_PORT (AHA_BASE + 0x0) /* control & status */
-#define AHA_CMD_DATA_PORT (AHA_BASE + 0x1) /* cmds and datas */
-#define AHA_INTR_PORT (AHA_BASE + 0x2) /* Intr. stat */
-
-/*
- * AHA_CTRL_STAT bits (write)
- */
-#define AHA_HRST 0x80 /* Hardware reset */
-#define AHA_SRST 0x40 /* Software reset */
-#define AHA_IRST 0x20 /* Interrupt reset */
-#define AHA_SCRST 0x10 /* SCSI bus reset */
-
-/*
- * AHA_CTRL_STAT bits (read)
- */
-#define AHA_STST 0x80 /* Self test in Progress */
-#define AHA_DIAGF 0x40 /* Diagnostic Failure */
-#define AHA_INIT 0x20 /* Mbx Init required */
-#define AHA_IDLE 0x10 /* Host Adapter Idle */
-#define AHA_CDF 0x08 /* cmd/data out port full */
-#define AHA_DF 0x04 /* Data in port full */
-#define AHA_INVDCMD 0x01 /* Invalid command */
-
/*
- * AHA_CMD_DATA bits (write)
- */
-#define AHA_NOP 0x00 /* No operation */
-#define AHA_MBX_INIT 0x01 /* Mbx initialization */
-#define AHA_START_SCSI 0x02 /* start scsi command */
-#define AHA_START_BIOS 0x03 /* start bios command */
-#define AHA_INQUIRE 0x04 /* Adapter Inquiry */
-#define AHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
-#define AHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
-#define AHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */
-#define AHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
-#define AHA_SPEED_SET 0x09 /* set transfer speed */
-#define AHA_DEV_GET 0x0a /* return installed devices */
-#define AHA_CONF_GET 0x0b /* return configuration data */
-#define AHA_TARGET_EN 0x0c /* enable target mode */
-#define AHA_SETUP_GET 0x0d /* return setup data */
-#define AHA_WRITE_CH2 0x1a /* write channel 2 buffer */
-#define AHA_READ_CH2 0x1b /* read channel 2 buffer */
-#define AHA_WRITE_FIFO 0x1c /* write fifo buffer */
-#define AHA_READ_FIFO 0x1d /* read fifo buffer */
-#define AHA_ECHO 0x1e /* Echo command data */
-#define AHA_EXT_BIOS 0x28 /* return extended bios info */
-#define AHA_MBX_ENABLE 0x29 /* enable mail box interface */
-
-/*
- * AHA_INTR_PORT bits (read)
- */
-#define AHA_ANY_INTR 0x80 /* Any interrupt */
-#define AHA_SCRD 0x08 /* SCSI reset detected */
-#define AHA_HACC 0x04 /* Command complete */
-#define AHA_MBOA 0x02 /* MBX out empty */
-#define AHA_MBIF 0x01 /* MBX in full */
-
-/*
- * Mail box defs
+ * Mail box defs etc.
+ * these could be bigger but we need the aha_softc to fit on a single page..
*/
#define AHA_MBX_SIZE 16 /* mail box size */
-#define AHA_CCB_MAX 32 /* store up to 32 CCBs at one time */
-#define CCB_HASH_SIZE 32 /* hash table size for phystokv */
+#define AHA_CCB_MAX 16 /* store up to 32 CCBs at one time */
+#define CCB_HASH_SIZE 16 /* hash table size for phystokv */
#define CCB_HASH_SHIFT 9
#define CCB_HASH(x) ((((long)(x))>>CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
else \
(wmb)++;
-struct aha_mbx_out {
- u_char cmd;
- u_char ccb_addr[3];
-};
-
-struct aha_mbx_in {
- u_char stat;
- u_char ccb_addr[3];
-};
-
struct aha_mbx {
struct aha_mbx_out mbo[AHA_MBX_SIZE];
struct aha_mbx_in mbi[AHA_MBX_SIZE];
+ struct aha_mbx_out *cmbo; /* Collection Mail Box out */
struct aha_mbx_out *tmbo; /* Target Mail Box out */
struct aha_mbx_in *tmbi; /* Target Mail Box in */
};
-/*
- * mbo.cmd values
- */
-#define AHA_MBO_FREE 0x0 /* MBO entry is free */
-#define AHA_MBO_START 0x1 /* MBO activate entry */
-#define AHA_MBO_ABORT 0x2 /* MBO abort entry */
-
-/*
- * mbi.stat values
- */
-#define AHA_MBI_FREE 0x0 /* MBI entry is free */
-#define AHA_MBI_OK 0x1 /* completed without error */
-#define AHA_MBI_ABORT 0x2 /* aborted ccb */
-#define AHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
-#define AHA_MBI_ERROR 0x4 /* Completed with error */
-
-/* FOR OLD VERSIONS OF THE !%$@ this may have to be 16 (yuk) */
-#define AHA_NSEG 17 /* Number of scatter gather segments <= 16 */
- /* allow 60 K i/o (min) */
-
-struct aha_ccb {
- u_char opcode;
- u_char lun:3;
- u_char data_in:1; /* must be 0 */
- u_char data_out:1; /* must be 0 */
- u_char target:3;
- u_char scsi_cmd_length;
- u_char req_sense_length;
- u_char data_length[3];
- u_char data_addr[3];
- u_char link_addr[3];
- u_char link_id;
- u_char host_stat;
- u_char target_stat;
- u_char reserved[2];
- struct scsi_generic scsi_cmd;
- struct scsi_sense_data scsi_sense;
- struct aha_scat_gath {
- u_char seg_len[3];
- u_char seg_addr[3];
- } scat_gath[AHA_NSEG];
- /*----------------------------------------------------------------*/
-#define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
- TAILQ_ENTRY(aha_ccb) chain;
- struct aha_ccb *nexthash;
- struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
- int flags;
-#define CCB_FREE 0
-#define CCB_ACTIVE 1
-#define CCB_ABORTED 2
- struct aha_mbx_out *mbx; /* pointer to mail box */
- struct isadma_seg ccb_phys[1]; /* phys segment of this ccb */
- struct isadma_seg data_phys[AHA_NSEG]; /* phys segments of data */
- int data_nseg; /* number of phys segments of data */
-};
-
-/*
- * opcode fields
- */
-#define AHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
-#define AHA_TARGET_CCB 0x01 /* SCSI Target CCB */
-#define AHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scatter gather */
-#define AHA_RESET_CCB 0x81 /* SCSI Bus reset */
-
-/*
- * aha_ccb.host_stat values
- */
-#define AHA_OK 0x00 /* cmd ok */
-#define AHA_LINK_OK 0x0a /* Link cmd ok */
-#define AHA_LINK_IT 0x0b /* Link cmd ok + int */
-#define AHA_SEL_TIMEOUT 0x11 /* Selection time out */
-#define AHA_OVER_UNDER 0x12 /* Data over/under run */
-#define AHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */
-#define AHA_INV_BUS 0x14 /* Invalid bus phase/sequence */
-#define AHA_BAD_MBO 0x15 /* Incorrect MBO cmd */
-#define AHA_BAD_CCB 0x16 /* Incorrect ccb opcode */
-#define AHA_BAD_LINK 0x17 /* Not same values of LUN for links */
-#define AHA_INV_TARGET 0x18 /* Invalid target direction */
-#define AHA_CCB_DUP 0x19 /* Duplicate CCB received */
-#define AHA_INV_CCB 0x1a /* Invalid CCB or segment list */
-#define AHA_ABORTED 42
-
-struct aha_setup {
- u_char sync_neg:1;
- u_char parity:1;
- u_char:6;
- u_char speed;
- u_char bus_on;
- u_char bus_off;
- u_char num_mbx;
- u_char mbx[3];
- struct {
- u_char offset:4;
- u_char period:3;
- u_char valid:1;
- } sync[8];
- u_char disc_sts;
-};
-
-struct aha_config {
- u_char chan;
- u_char intr;
- u_char scsi_dev:3;
- u_char:5;
-};
-
-struct aha_inquire {
- u_char boardid; /* type of board */
- /* 0x31 = AHA-1540 */
- /* 0x41 = AHA-1540A/1542A/1542B */
- /* 0x42 = AHA-1640 */
- /* 0x43 = AHA-1542C */
- /* 0x44 = AHA-1542CF */
- /* 0x45 = AHA-1542CF, BIOS v2.01 */
- u_char spec_opts; /* special options ID */
- /* 0x41 = Board is standard model */
- u_char revision_1; /* firmware revision [0-9A-Z] */
- u_char revision_2; /* firmware revision [0-9A-Z] */
-};
-
-struct aha_extbios {
- u_char flags; /* Bit 3 == 1 extended bios enabled */
- u_char mailboxlock; /* mail box lock code to unlock it */
-};
-
-#define INT9 0x01
-#define INT10 0x02
-#define INT11 0x04
-#define INT12 0x08
-#define INT14 0x20
-#define INT15 0x40
-
-#define CHAN0 0x01
-#define CHAN5 0x20
-#define CHAN6 0x40
-#define CHAN7 0x80
-
-/*********************************** end of board definitions***************/
-
-#ifdef AHADEBUG
-int aha_debug = 1;
-#endif /*AHADEBUG */
+#define KVTOPHYS(x) vtophys(x)
struct aha_softc {
struct device sc_dev;
int sc_iobase;
int sc_irq, sc_drq;
- struct aha_mbx aha_mbx; /* all the mailboxes */
- struct aha_ccb *ccbhash[CCB_HASH_SIZE];
- TAILQ_HEAD(, aha_ccb) free_ccb;
- int numccbs;
- int aha_scsi_dev; /* our scsi id */
+ char sc_model[18],
+ sc_firmware[4];
+
+ struct aha_mbx sc_mbx; /* all the mailboxes */
+#define wmbx (&sc->sc_mbx)
+ struct aha_ccb *sc_ccbhash[CCB_HASH_SIZE];
+ TAILQ_HEAD(, aha_ccb) sc_free_ccb, sc_waiting_ccb;
+ int sc_numccbs, sc_mbofull;
+ int sc_scsi_dev; /* our scsi id */
struct scsi_link sc_link;
};
-int aha_cmd(); /* XXX must be varargs to prototype */
+#ifdef AHADEBUG
+int aha_debug = 1;
+#endif /* AHADEBUG */
+
+int aha_cmd __P((int, struct aha_softc *, int, u_char *, int, u_char *));
+integrate void aha_finish_ccbs __P((struct aha_softc *));
int ahaintr __P((void *));
-void aha_free_ccb __P((struct aha_softc *, struct aha_ccb *, int));
+integrate void aha_reset_ccb __P((struct aha_softc *, struct aha_ccb *));
+void aha_free_ccb __P((struct aha_softc *, struct aha_ccb *));
+integrate void aha_init_ccb __P((struct aha_softc *, struct aha_ccb *));
struct aha_ccb *aha_get_ccb __P((struct aha_softc *, int));
struct aha_ccb *aha_ccb_phys_kv __P((struct aha_softc *, u_long));
-struct aha_mbx_out *aha_send_mbo __P((struct aha_softc *, int, struct aha_ccb *));
+void aha_queue_ccb __P((struct aha_softc *, struct aha_ccb *));
+void aha_collect_mbo __P((struct aha_softc *));
+void aha_start_ccbs __P((struct aha_softc *));
void aha_done __P((struct aha_softc *, struct aha_ccb *));
-int aha_find __P((struct aha_softc *));
+int aha_find __P((struct isa_attach_args *, struct aha_softc *));
void aha_init __P((struct aha_softc *));
+void aha_inquire_setup_information __P((struct aha_softc *));
void ahaminphys __P((struct buf *));
int aha_scsi_cmd __P((struct scsi_xfer *));
int aha_poll __P((struct aha_softc *, struct scsi_xfer *, int));
-int aha_set_bus_speed __P((struct aha_softc *));
-int aha_bus_speed_check __P((struct aha_softc *, int));
void aha_timeout __P((void *arg));
struct scsi_adapter aha_switch = {
void ahaattach __P((struct device *, struct device *, void *));
int ahaprint __P((void *, char *));
-struct cfdriver ahacd = {
- NULL, "aha", ahaprobe, ahaattach, DV_DULL, sizeof(struct aha_softc)
+struct cfattach aha_ca = {
+ sizeof(struct aha_softc), ahaprobe, ahaattach
+};
+
+struct cfdriver aha_cd = {
+ NULL, "aha", DV_DULL
};
#define AHA_RESET_TIMEOUT 2000 /* time to wait for reset (mSec) */
+#define AHA_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */
/*
- * aha_cmd(aha,icnt, ocnt,wait, retval, opcode, args)
+ * aha_cmd(iobase, sc, icnt, ibuf, ocnt, obuf)
+ *
* Activate Adapter command
- * icnt: number of args (outbound bytes written after opcode)
+ * icnt: number of args (outbound bytes including opcode)
+ * ibuf: argument buffer
* ocnt: number of expected returned bytes
+ * obuf: result buffer
* wait: number of seconds to wait for response
- * retval: buffer where to place returned bytes
- * opcode: opcode AHA_NOP, AHA_MBX_INIT, AHA_START_SCSI ...
- * args: parameters
*
- * Performs an adapter command through the ports. Not to be confused
- * with a scsi command, which is read in via the dma. One of the adapter
- * commands tells it to read in a scsi command but that one is done
- * separately. This is only called during set-up.
+ * Performs an adapter command through the ports. Not to be confused with a
+ * scsi command, which is read in via the dma; one of the adapter commands
+ * tells it to read in a scsi command.
*/
int
-aha_cmd(aha, icnt, ocnt, wait, retval, opcode, args)
- struct aha_softc *aha;
- int icnt, ocnt, wait;
- u_char *retval;
- unsigned opcode;
- u_char args;
+aha_cmd(iobase, sc, icnt, ibuf, ocnt, obuf)
+ int iobase;
+ struct aha_softc *sc;
+ int icnt, ocnt;
+ u_char *ibuf, *obuf;
{
- unsigned *ic = &opcode;
- u_char oc;
- register i;
- int sts;
+ const char *name;
+ register int i;
+ int wait;
+ u_char sts;
+ u_char opcode = ibuf[0];
+
+ if (sc == NULL)
+ name = sc->sc_dev.dv_xname;
+ else
+ name = "(probe)";
/*
- * multiply the wait argument by a big constant
- * zero defaults to 1 sec..
- * all wait loops are in 50uSec cycles
+ * Calculate a reasonable timeout for the command.
*/
- if (wait)
- wait *= 20000;
- else
- wait = 20000;
+ switch (opcode) {
+ case AHA_INQUIRE_DEVICES:
+ wait = 15 * 20000;
+ break;
+ default:
+ wait = 1 * 20000;
+ break;
+ }
+
/*
* Wait for the adapter to go idle, unless it's one of
* the commands which don't need this
*/
- if (opcode != AHA_MBX_INIT && opcode != AHA_START_SCSI) {
- i = 20000; /*do this for upto about a second */
- while (--i) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts & AHA_IDLE)
+ if (opcode != AHA_MBO_INTR_EN) {
+ for (i = 20000; i; i--) { /* 1 sec? */
+ sts = inb(iobase + AHA_STAT_PORT);
+ if (sts & AHA_STAT_IDLE)
break;
delay(50);
}
if (!i) {
printf("%s: aha_cmd, host not idle(0x%x)\n",
- aha->sc_dev.dv_xname, sts);
+ name, sts);
return ENXIO;
}
}
* queue feeding to us.
*/
if (ocnt) {
- while ((inb(AHA_CTRL_STAT_PORT)) & AHA_DF)
- inb(AHA_CMD_DATA_PORT);
+ while ((inb(iobase + AHA_STAT_PORT)) & AHA_STAT_DF)
+ inb(iobase + AHA_DATA_PORT);
}
/*
* Output the command and the number of arguments given
* for each byte, first check the port is empty.
*/
- icnt++;
- /* include the command */
while (icnt--) {
- sts = inb(AHA_CTRL_STAT_PORT);
for (i = wait; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (!(sts & AHA_CDF))
+ sts = inb(iobase + AHA_STAT_PORT);
+ if (!(sts & AHA_STAT_CDF))
break;
delay(50);
}
if (!i) {
- if (opcode != AHA_INQUIRE)
- printf("%s: aha_cmd, cmd/data port full\n",
- aha->sc_dev.dv_xname);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
+ if (opcode != AHA_INQUIRE_REVISION)
+ printf("%s: aha_cmd, cmd/data port full\n", name);
+ outb(iobase + AHA_CTRL_PORT, AHA_CTRL_SRST);
return ENXIO;
}
- outb(AHA_CMD_DATA_PORT, (u_char) (*ic++));
+ outb(iobase + AHA_CMD_PORT, *ibuf++);
}
/*
* If we expect input, loop that many times, each time,
* looking for the data register to have valid data
*/
while (ocnt--) {
- sts = inb(AHA_CTRL_STAT_PORT);
for (i = wait; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts & AHA_DF)
+ sts = inb(iobase + AHA_STAT_PORT);
+ if (sts & AHA_STAT_DF)
break;
delay(50);
}
if (!i) {
- if (opcode != AHA_INQUIRE)
+ if (opcode != AHA_INQUIRE_REVISION)
printf("%s: aha_cmd, cmd/data port empty %d\n",
- aha->sc_dev.dv_xname, ocnt);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
+ name, ocnt);
+ outb(iobase + AHA_CTRL_PORT, AHA_CTRL_SRST);
return ENXIO;
}
- oc = inb(AHA_CMD_DATA_PORT);
- if (retval)
- *retval++ = oc;
+ *obuf++ = inb(iobase + AHA_DATA_PORT);
}
/*
- * Wait for the board to report a finised instruction
+ * Wait for the board to report a finished instruction.
+ * We may get an extra interrupt for the HACC signal, but this is
+ * unimportant.
*/
- i = 20000;
- while (--i) {
- sts = inb(AHA_INTR_PORT);
- if (sts & AHA_HACC)
- break;
- delay(50);
- }
- if (!i) {
- printf("%s: aha_cmd, host not finished(0x%x)\n",
- aha->sc_dev.dv_xname, sts);
- return ENXIO;
+ if (opcode != AHA_MBO_INTR_EN) {
+ for (i = 20000; i; i--) { /* 1 sec? */
+ sts = inb(iobase + AHA_INTR_PORT);
+ /* XXX Need to save this in the interrupt handler? */
+ if (sts & AHA_INTR_HACC)
+ break;
+ delay(50);
+ }
+ if (!i) {
+ printf("%s: aha_cmd, host not finished(0x%x)\n",
+ name, sts);
+ return ENXIO;
+ }
}
- outb(AHA_CTRL_STAT_PORT, AHA_IRST);
+ outb(iobase + AHA_CTRL_PORT, AHA_CTRL_IRST);
return 0;
}
struct device *parent;
void *match, *aux;
{
- struct aha_softc *aha = match;
- struct isa_attach_args *ia = aux;
+ register struct isa_attach_args *ia = aux;
#ifdef NEWCONFIG
if (ia->ia_iobase == IOBASEUNK)
return 0;
#endif
- aha->sc_iobase = ia->ia_iobase;
-
- /*
- * Try initialise a unit at this location
- * sets up dma and bus speed, loads aha->sc_irq
- */
- if (aha_find(aha) != 0)
+ /* See if there is a unit at this location. */
+ if (aha_find(ia, NULL) != 0)
return 0;
- if (ia->ia_irq != IRQUNK) {
- if (ia->ia_irq != aha->sc_irq) {
- printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
- aha->sc_dev.dv_xname, ia->ia_irq, aha->sc_irq);
- return 0;
- }
- } else
- ia->ia_irq = aha->sc_irq;
-
- if (ia->ia_drq != DRQUNK) {
- if (ia->ia_drq != aha->sc_drq) {
- printf("%s: drq mismatch; kernel configured %d != board configured %d\n",
- aha->sc_dev.dv_xname, ia->ia_drq, aha->sc_drq);
- return 0;
- }
- } else
- ia->ia_drq = aha->sc_drq;
-
ia->ia_msize = 0;
ia->ia_iosize = 4;
+ /* IRQ and DRQ set by aha_find(). */
return 1;
}
void *aux;
char *name;
{
+
if (name != NULL)
printf("%s: scsibus ", name);
return UNCONF;
void *aux;
{
struct isa_attach_args *ia = aux;
- struct aha_softc *aha = (void *)self;
+ struct aha_softc *sc = (void *)self;
- if (ia->ia_drq != DRQUNK)
- isadma_cascade(ia->ia_drq);
+ if (aha_find(ia, sc) != 0)
+ panic("ahaattach: aha_find of %s failed", self->dv_xname);
+ sc->sc_iobase = ia->ia_iobase;
- aha_init(aha);
- TAILQ_INIT(&aha->free_ccb);
+ if (sc->sc_drq != DRQUNK)
+ isa_dmacascade(sc->sc_drq);
+
+ aha_inquire_setup_information(sc);
+ aha_init(sc);
+ TAILQ_INIT(&sc->sc_free_ccb);
+ TAILQ_INIT(&sc->sc_waiting_ccb);
/*
* fill in the prototype scsi_link.
*/
- aha->sc_link.adapter_softc = aha;
- aha->sc_link.adapter_target = aha->aha_scsi_dev;
- aha->sc_link.adapter = &aha_switch;
- aha->sc_link.device = &aha_dev;
- aha->sc_link.openings = 2;
-
- printf("\n");
+ sc->sc_link.adapter_softc = sc;
+ sc->sc_link.adapter_target = sc->sc_scsi_dev;
+ sc->sc_link.adapter = &aha_switch;
+ sc->sc_link.device = &aha_dev;
+ sc->sc_link.openings = 2;
#ifdef NEWCONFIG
- isa_establish(&aha->sc_id, &aha->sc_dev);
+ isa_establish(&sc->sc_id, &sc->sc_dev);
#endif
- aha->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, ahaintr,
- aha, aha->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, sc->sc_irq, IST_EDGE,
+ IPL_BIO, ahaintr, sc);
/*
* ask the adapter what subunits are present
*/
- config_found(self, &aha->sc_link, ahaprint);
+ config_found(self, &sc->sc_link, ahaprint);
}
-/*
- * Catch an interrupt from the adaptor
- */
-int
-ahaintr(arg)
- void *arg;
+integrate void
+aha_finish_ccbs(sc)
+ struct aha_softc *sc;
{
- struct aha_softc *aha = arg;
struct aha_mbx_in *wmbi;
- struct aha_mbx *wmbx;
struct aha_ccb *ccb;
- u_char stat;
int i;
- int found = 0;
-#ifdef AHADEBUG
- printf("%s: ahaintr ", aha->sc_dev.dv_xname);
-#endif /*AHADEBUG */
-
- /*
- * First acknowlege the interrupt, Then if it's not telling about
- * a completed operation just return.
- */
- stat = inb(AHA_INTR_PORT);
- if ((stat & (AHA_MBOA | AHA_MBIF)) == 0) {
- outb(AHA_CTRL_STAT_PORT, AHA_IRST);
- return -1; /* XXX */
- }
+ wmbi = wmbx->tmbi;
- /* Mail box out empty? */
- if (stat & AHA_MBOA) {
- /* Disable MBO available interrupt. */
- outb(AHA_CMD_DATA_PORT, AHA_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(AHA_CTRL_STAT_PORT) & AHA_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: ahaintr, cmd/data port full\n",
- aha->sc_dev.dv_xname);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
- return 1;
+ if (wmbi->stat == AHA_MBI_FREE) {
+ for (i = 0; i < AHA_MBX_SIZE; i++) {
+ if (wmbi->stat != AHA_MBI_FREE) {
+ printf("%s: mbi not in round-robin order\n",
+ sc->sc_dev.dv_xname);
+ goto AGAIN;
+ }
+ aha_nextmbx(wmbi, wmbx, mbi);
}
- outb(AHA_CMD_DATA_PORT, 0x00); /* Disable */
- wakeup(&aha->aha_mbx);
+#ifdef AHADIAGnot
+ printf("%s: mbi interrupt with no full mailboxes\n",
+ sc->sc_dev.dv_xname);
+#endif
+ return;
}
- /* Mail box in full? */
- if ((stat & AHA_MBIF) == 0)
- return 1;
- wmbx = &aha->aha_mbx;
- wmbi = wmbx->tmbi;
AGAIN:
- while (wmbi->stat != AHA_MBI_FREE) {
- ccb = aha_ccb_phys_kv(aha, _3btol(wmbi->ccb_addr));
+ do {
+ ccb = aha_ccb_phys_kv(sc, phystol(wmbi->ccb_addr));
if (!ccb) {
- wmbi->stat = AHA_MBI_FREE;
- printf("%s: BAD CCB ADDR!\n", aha->sc_dev.dv_xname);
- continue;
+ printf("%s: bad mbi ccb pointer; skipping\n",
+ sc->sc_dev.dv_xname);
+ goto next;
}
- found++;
+
+#ifdef AHADEBUG
+ if (aha_debug) {
+ u_char *cp = &ccb->scsi_cmd;
+ printf("op=%x %x %x %x %x %x\n",
+ cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
+ printf("stat %x for mbi addr = 0x%08x, ",
+ wmbi->stat, wmbi);
+ printf("ccb addr = 0x%x\n", ccb);
+ }
+#endif /* AHADEBUG */
+
switch (wmbi->stat) {
case AHA_MBI_OK:
case AHA_MBI_ERROR:
+ if ((ccb->flags & CCB_ABORT) != 0) {
+ /*
+ * If we already started an abort, wait for it
+ * to complete before clearing the CCB. We
+ * could instead just clear CCB_SENDING, but
+ * what if the mailbox was already received?
+ * The worst that happens here is that we clear
+ * the CCB a bit later than we need to. BFD.
+ */
+ goto next;
+ }
break;
case AHA_MBI_ABORT:
- ccb->host_stat = AHA_ABORTED;
- break;
-
case AHA_MBI_UNKNOWN:
- ccb = 0;
+ /*
+ * Even if the CCB wasn't found, we clear it anyway.
+ * See preceeding comment.
+ */
break;
default:
- panic("Impossible mbxi status");
- }
-#ifdef AHADEBUG
- if (aha_debug && ccb) {
- u_char *cp = &ccb->scsi_cmd;
- printf("op=%x %x %x %x %x %x\n",
- cp[0], cp[1], cp[2],
- cp[3], cp[4], cp[5]);
- printf("stat %x for mbi addr = 0x%08x, ",
- wmbi->stat, wmbi);
- printf("ccb addr = 0x%x\n", ccb);
+ printf("%s: bad mbi status %02x; skipping\n",
+ sc->sc_dev.dv_xname, wmbi->stat);
+ goto next;
}
-#endif /* AHADEBUG */
+
+ untimeout(aha_timeout, ccb);
+ aha_done(sc, ccb);
+
+ next:
wmbi->stat = AHA_MBI_FREE;
- if (ccb) {
- untimeout(aha_timeout, ccb);
- aha_done(aha, ccb);
- }
aha_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
- for (i = 0; i < AHA_MBX_SIZE; i++) {
- if (wmbi->stat != AHA_MBI_FREE) {
- found++;
- break;
- }
- aha_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
-#if 0
- printf("%s: mbi interrupt with no full mailboxes\n",
- aha->sc_dev.dv_xname);
+ } while (wmbi->stat != AHA_MBI_FREE);
+
+ wmbx->tmbi = wmbi;
+}
+
+/*
+ * Catch an interrupt from the adaptor
+ */
+int
+ahaintr(arg)
+ void *arg;
+{
+ struct aha_softc *sc = arg;
+ int iobase = sc->sc_iobase;
+ u_char sts;
+
+#ifdef AHADEBUG
+ printf("%s: ahaintr ", sc->sc_dev.dv_xname);
+#endif /*AHADEBUG */
+
+ /*
+ * First acknowlege the interrupt, Then if it's not telling about
+ * a completed operation just return.
+ */
+ sts = inb(iobase + AHA_INTR_PORT);
+ if ((sts & AHA_INTR_ANYINTR) == 0)
+ return 0;
+ outb(iobase + AHA_CTRL_PORT, AHA_CTRL_IRST);
+
+#ifdef AHADIAG
+ /* Make sure we clear CCB_SENDING before finishing a CCB. */
+ aha_collect_mbo(sc);
#endif
- } else {
- found = 0;
- goto AGAIN;
- }
+
+ /* Mail box out empty? */
+ if (sts & AHA_INTR_MBOA) {
+ struct aha_toggle toggle;
+
+ toggle.cmd.opcode = AHA_MBO_INTR_EN;
+ toggle.cmd.enable = 0;
+ aha_cmd(iobase, sc, sizeof(toggle.cmd), (u_char *)&toggle.cmd, 0,
+ (u_char *)0);
+ aha_start_ccbs(sc);
}
- wmbx->tmbi = wmbi;
- outb(AHA_CTRL_STAT_PORT, AHA_IRST);
+
+ /* Mail box in full? */
+ if (sts & AHA_INTR_MBIF)
+ aha_finish_ccbs(sc);
+
return 1;
}
+integrate void
+aha_reset_ccb(sc, ccb)
+ struct aha_softc *sc;
+ struct aha_ccb *ccb;
+{
+
+ ccb->flags = 0;
+}
+
/*
- * A ccb (and hence a mbx-out is put onto the
- * free list.
+ * A ccb is put onto the free list.
*/
void
-aha_free_ccb(aha, ccb, flags)
- struct aha_softc *aha;
+aha_free_ccb(sc, ccb)
+ struct aha_softc *sc;
struct aha_ccb *ccb;
- int flags;
{
- int s, hashnum;
- struct aha_ccb **hashccb;
+ int s;
s = splbio();
- if (ccb->ccb_phys[0].addr)
- isadma_unmap((caddr_t)ccb, CCB_PHYS_SIZE, 1, ccb->ccb_phys);
-
- /* remove from hash table */
-
- hashnum = CCB_HASH(ccb->ccb_phys[0].addr);
- hashccb = &aha->ccbhash[hashnum];
-
- while (*hashccb) {
- if ((*hashccb)->ccb_phys[0].addr == ccb->ccb_phys[0].addr) {
- *hashccb = (*hashccb)->nexthash;
- break;
- }
- hashccb = &(*hashccb)->nexthash;
- }
-
- ccb->flags = CCB_FREE;
- TAILQ_INSERT_HEAD(&aha->free_ccb, ccb, chain);
+ aha_reset_ccb(sc, ccb);
+ TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
/*
* If there were none, wake anybody waiting for one to come free,
* starting with queued entries.
*/
if (ccb->chain.tqe_next == 0)
- wakeup(&aha->free_ccb);
+ wakeup(&sc->sc_free_ccb);
splx(s);
}
-static inline void
-aha_init_ccb(aha, ccb)
- struct aha_softc *aha;
- struct aha_ccb *ccb;
-{
- bzero(ccb, sizeof(struct aha_ccb));
-}
-
-static inline void
-aha_reset_ccb(aha, ccb)
- struct aha_softc *aha;
+integrate void
+aha_init_ccb(sc, ccb)
+ struct aha_softc *sc;
struct aha_ccb *ccb;
{
+ int hashnum;
+ bzero(ccb, sizeof(struct aha_ccb));
+ /*
+ * put in the phystokv hash table
+ * Never gets taken out.
+ */
+ ccb->hashkey = KVTOPHYS(ccb);
+ hashnum = CCB_HASH(ccb->hashkey);
+ ccb->nexthash = sc->sc_ccbhash[hashnum];
+ sc->sc_ccbhash[hashnum] = ccb;
+ aha_reset_ccb(sc, ccb);
}
/*
* Get a free ccb
+ *
+ * If there are none, see if we can allocate a new one. If so, put it in
+ * the hash table too otherwise either return an error or sleep.
*/
struct aha_ccb *
-aha_get_ccb(aha, flags)
- struct aha_softc *aha;
+aha_get_ccb(sc, flags)
+ struct aha_softc *sc;
int flags;
{
struct aha_ccb *ccb;
- int hashnum, mflags, s;
+ int s;
s = splbio();
- if (flags & SCSI_NOSLEEP)
- mflags = ISADMA_MAP_BOUNCE;
- else
- mflags = ISADMA_MAP_BOUNCE | ISADMA_MAP_WAITOK;
-
/*
- * If we can and have to, sleep waiting for one
- * to come free
+ * If we can and have to, sleep waiting for one to come free
+ * but only if we can't allocate a new one.
*/
for (;;) {
- ccb = aha->free_ccb.tqh_first;
+ ccb = sc->sc_free_ccb.tqh_first;
if (ccb) {
- TAILQ_REMOVE(&aha->free_ccb, ccb, chain);
+ TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain);
break;
}
- if (aha->numccbs < AHA_CCB_MAX) {
- if (ccb = (struct aha_ccb *) malloc(sizeof(struct aha_ccb),
- M_TEMP, M_NOWAIT)) {
- aha_init_ccb(aha, ccb);
- aha->numccbs++;
- } else {
+ if (sc->sc_numccbs < AHA_CCB_MAX) {
+ ccb = (struct aha_ccb *) malloc(sizeof(struct aha_ccb),
+ M_TEMP, M_NOWAIT);
+ if (!ccb) {
printf("%s: can't malloc ccb\n",
- aha->sc_dev.dv_xname);
+ sc->sc_dev.dv_xname);
goto out;
}
+ aha_init_ccb(sc, ccb);
+ sc->sc_numccbs++;
break;
}
if ((flags & SCSI_NOSLEEP) != 0)
goto out;
- tsleep(&aha->free_ccb, PRIBIO, "ahaccb", 0);
+ tsleep(&sc->sc_free_ccb, PRIBIO, "ahaccb", 0);
}
- aha_reset_ccb(aha, ccb);
- ccb->flags = CCB_ACTIVE;
-
- if (isadma_map((caddr_t)ccb, CCB_PHYS_SIZE, ccb->ccb_phys,
- mflags | ISADMA_MAP_CONTIG) == 1) {
- hashnum = CCB_HASH(ccb->ccb_phys[0].addr);
- ccb->nexthash = aha->ccbhash[hashnum];
- aha->ccbhash[hashnum] = ccb;
- } else {
- ccb->ccb_phys[0].addr = 0;
- aha_free_ccb(aha, ccb, flags);
- ccb = 0;
- }
+ ccb->flags |= CCB_ALLOC;
out:
splx(s);
}
/*
- * given a physical address, find the ccb that it corresponds to.
+ * Given a physical address, find the ccb that it corresponds to.
*/
struct aha_ccb *
-aha_ccb_phys_kv(aha, ccb_phys)
- struct aha_softc *aha;
+aha_ccb_phys_kv(sc, ccb_phys)
+ struct aha_softc *sc;
u_long ccb_phys;
{
int hashnum = CCB_HASH(ccb_phys);
- struct aha_ccb *res = aha->ccbhash[hashnum];
+ struct aha_ccb *ccb = sc->sc_ccbhash[hashnum];
- while (res) {
- if (res->ccb_phys[0].addr == ccb_phys)
+ while (ccb) {
+ if (ccb->hashkey == ccb_phys)
break;
- res = res->nexthash;
+ ccb = ccb->nexthash;
}
+ return ccb;
+}
- return res;
+/*
+ * Queue a CCB to be sent to the controller, and send it if possible.
+ */
+void
+aha_queue_ccb(sc, ccb)
+ struct aha_softc *sc;
+ struct aha_ccb *ccb;
+{
+
+ TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
+ aha_start_ccbs(sc);
}
/*
- * Get a mbo and send the ccb.
+ * Garbage collect mailboxes that are no longer in use.
*/
-struct aha_mbx_out *
-aha_send_mbo(aha, cmd, ccb)
- struct aha_softc *aha;
- int cmd;
+void
+aha_collect_mbo(sc)
+ struct aha_softc *sc;
+{
+ struct aha_mbx_out *wmbo; /* Mail Box Out pointer */
struct aha_ccb *ccb;
+
+ wmbo = wmbx->cmbo;
+
+ while (sc->sc_mbofull > 0) {
+ if (wmbo->cmd != AHA_MBO_FREE)
+ break;
+
+#ifdef AHADIAG
+ ccb = aha_ccb_phys_kv(sc, phystol(wmbo->ccb_addr));
+ ccb->flags &= ~CCB_SENDING;
+#endif
+
+ --sc->sc_mbofull;
+ aha_nextmbx(wmbo, wmbx, mbo);
+ }
+
+ wmbx->cmbo = wmbo;
+}
+
+/*
+ * Send as many CCBs as we have empty mailboxes for.
+ */
+void
+aha_start_ccbs(sc)
+ struct aha_softc *sc;
{
+ int iobase = sc->sc_iobase;
struct aha_mbx_out *wmbo; /* Mail Box Out pointer */
- struct aha_mbx *wmbx; /* Mail Box pointer specified unit */
+ struct aha_ccb *ccb;
int i;
- /* Get the target out mail box pointer and increment. */
- wmbx = &aha->aha_mbx;
wmbo = wmbx->tmbo;
- aha_nextmbx(wmbx->tmbo, wmbx, mbo);
- /*
- * Check the outmail box is free or not.
- * Note: Under the normal operation, it shuld NOT happen to wait.
- */
- while (wmbo->cmd != AHA_MBO_FREE) {
- /* Enable mbo available interrupt. */
- outb(AHA_CMD_DATA_PORT, AHA_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(AHA_CTRL_STAT_PORT) & AHA_CDF))
+ while (ccb = sc->sc_waiting_ccb.tqh_first) {
+ if (sc->sc_mbofull >= AHA_MBX_SIZE) {
+ aha_collect_mbo(sc);
+ if (sc->sc_mbofull >= AHA_MBX_SIZE) {
+ struct aha_toggle toggle;
+
+ toggle.cmd.opcode = AHA_MBO_INTR_EN;
+ toggle.cmd.enable = 1;
+ aha_cmd(iobase, sc, sizeof(toggle.cmd),
+ (u_char *)&toggle.cmd, 0, (u_char *)0);
break;
- delay(10);
- }
- if (!i) {
- printf("%s: aha_send_mbo, cmd/data port full\n",
- aha->sc_dev.dv_xname);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
- return NULL;
+ }
}
- outb(AHA_CMD_DATA_PORT, 0x01); /* Enable */
- tsleep(wmbx, PRIBIO, "ahasnd", 0);/*XXX can't do this */
- }
- /* Link ccb to mbo. */
- lto3b(ccb->ccb_phys[0].addr, wmbo->ccb_addr);
- ccb->mbx = wmbo;
- wmbo->cmd = cmd;
+ TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
+#ifdef AHADIAG
+ ccb->flags |= CCB_SENDING;
+#endif
+
+ /* Link ccb to mbo. */
+ ltophys(KVTOPHYS(ccb), wmbo->ccb_addr);
+ if (ccb->flags & CCB_ABORT)
+ wmbo->cmd = AHA_MBO_ABORT;
+ else
+ wmbo->cmd = AHA_MBO_START;
- /* Sent it! */
- outb(AHA_CMD_DATA_PORT, AHA_START_SCSI);
+ /* Tell the card to poll immediately. */
+ outb(iobase + AHA_CMD_PORT, AHA_START_SCSI);
- return wmbo;
+ if ((ccb->xs->flags & SCSI_POLL) == 0)
+ timeout(aha_timeout, ccb, (ccb->timeout * hz) / 1000);
+
+ ++sc->sc_mbofull;
+ aha_nextmbx(wmbo, wmbx, mbo);
+ }
+
+ wmbx->tmbo = wmbo;
}
/*
* went. Wake up the owner if waiting
*/
void
-aha_done(aha, ccb)
- struct aha_softc *aha;
+aha_done(sc, ccb)
+ struct aha_softc *sc;
struct aha_ccb *ccb;
{
struct scsi_sense_data *s1, *s2;
* Otherwise, put the results of the operation
* into the xfer and call whoever started it
*/
- if ((xs->flags & INUSE) == 0) {
- printf("%s: exiting but not in use!\n", aha->sc_dev.dv_xname);
+#ifdef AHADIAG
+ if (ccb->flags & CCB_SENDING) {
+ printf("%s: exiting ccb still in transit!\n", sc->sc_dev.dv_xname);
+ Debugger();
+ return;
+ }
+#endif
+ if ((ccb->flags & CCB_ALLOC) == 0) {
+ printf("%s: exiting ccb not allocated!\n", sc->sc_dev.dv_xname);
Debugger();
+ return;
}
if (xs->error == XS_NOERROR) {
if (ccb->host_stat != AHA_OK) {
switch (ccb->host_stat) {
- case AHA_ABORTED:
- xs->error = XS_DRIVER_STUFFUP;
- break;
case AHA_SEL_TIMEOUT: /* No response */
xs->error = XS_SELTIMEOUT;
break;
default: /* Other scsi protocol messes */
printf("%s: host_stat %x\n",
- aha->sc_dev.dv_xname, ccb->host_stat);
+ sc->sc_dev.dv_xname, ccb->host_stat);
xs->error = XS_DRIVER_STUFFUP;
+ break;
}
} else if (ccb->target_stat != SCSI_OK) {
switch (ccb->target_stat) {
break;
default:
printf("%s: target_stat %x\n",
- aha->sc_dev.dv_xname, ccb->target_stat);
+ sc->sc_dev.dv_xname, ccb->target_stat);
xs->error = XS_DRIVER_STUFFUP;
+ break;
}
} else
xs->resid = 0;
}
+ aha_free_ccb(sc, ccb);
xs->flags |= ITSDONE;
-
- if (VOLATILE_XS(xs)) {
- wakeup(ccb);
- return;
- }
-
- if (ccb->data_nseg) {
- if (xs->flags & SCSI_DATA_IN)
- isadma_copyfrombuf(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- isadma_unmap(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- }
- aha_free_ccb(aha, ccb, xs->flags);
scsi_done(xs);
}
* Find the board and find its irq/drq
*/
int
-aha_find(aha)
- struct aha_softc *aha;
+aha_find(ia, sc)
+ struct isa_attach_args *ia;
+ struct aha_softc *sc;
{
- volatile int i, sts;
- struct aha_config conf;
- struct aha_inquire inquire;
- struct aha_extbios extbios;
+ int iobase = ia->ia_iobase;
+ int i;
+ u_char sts;
+ struct aha_config config;
+ int irq, drq;
/*
* reset board, If it doesn't respond, assume
* that it's not there.. good for the probe
*/
- outb(AHA_CTRL_STAT_PORT, AHA_HRST | AHA_SRST);
+ outb(iobase + AHA_CTRL_PORT, AHA_CTRL_HRST | AHA_CTRL_SRST);
+ delay(100);
for (i = AHA_RESET_TIMEOUT; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts == (AHA_IDLE | AHA_INIT))
+ sts = inb(iobase + AHA_STAT_PORT);
+ if (sts == (AHA_STAT_IDLE | AHA_STAT_INIT))
break;
delay(1000); /* calibrated in msec */
}
if (!i) {
-#ifdef AHADEBUG
+#ifdef AHADEBUG
if (aha_debug)
printf("aha_find: No answer from adaptec board\n");
-#endif /*AHADEBUG */
- return ENXIO;
- }
-
- /*
- * Assume we have a board at this stage, do an adapter inquire
- * to find out what type of controller it is. If the command
- * fails, we assume it's either a crusty board or an old 1542
- * clone, and skip the board-specific stuff.
- */
- if (aha_cmd(aha, 0, sizeof(inquire), 1, &inquire, AHA_INQUIRE)) {
- /*
- * aha_cmd() already started the reset. It's not clear we
- * even need to bother here.
- */
- for (i = AHA_RESET_TIMEOUT; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts == (AHA_IDLE | AHA_INIT))
- break;
- delay(1000);
- }
- if (!i) {
-#ifdef AHADEBUG
- printf("aha_init: soft reset failed\n");
-#endif /* AHADEBUG */
- return ENXIO;
- }
-#ifdef AHADEBUG
- printf("aha_init: inquire command failed\n");
#endif /* AHADEBUG */
- goto noinquire;
- }
-#ifdef AHADEBUG
- printf("%s: inquire %x, %x, %x, %x\n",
- aha->sc_dev.dv_xname,
- inquire.boardid, inquire.spec_opts,
- inquire.revision_1, inquire.revision_2);
-#endif /* AHADEBUG */
- /*
- * If we are a 1542C or 1542CF disable the extended bios so that the
- * mailbox interface is unlocked.
- * No need to check the extended bios flags as some of the
- * extensions that cause us problems are not flagged in that byte.
- */
- if (inquire.boardid == 0x43 || inquire.boardid == 0x44 ||
- inquire.boardid == 0x45) {
- aha_cmd(aha, 0, sizeof(extbios), 0, &extbios, AHA_EXT_BIOS);
-#ifdef AHADEBUG
- printf("%s: extended bios flags %x\n", aha->sc_dev.dv_xname,
- extbios.flags);
-#endif /* AHADEBUG */
- printf("%s: 1542C/CF detected, unlocking mailbox\n",
- aha->sc_dev.dv_xname);
- aha_cmd(aha, 2, 0, 0, 0, AHA_MBX_ENABLE,
- 0, extbios.mailboxlock);
+ return 1;
}
-noinquire:
/*
* setup dma channel from jumpers and save int
* level
*/
delay(1000); /* for Bustek 545 */
- aha_cmd(aha, 0, sizeof(conf), 0, &conf, AHA_CONF_GET);
- switch (conf.chan) {
+ config.cmd.opcode = AHA_INQUIRE_CONFIG;
+ aha_cmd(iobase, sc, sizeof(config.cmd), (u_char *)&config.cmd,
+ sizeof(config.reply), (u_char *)&config.reply);
+ switch (config.reply.chan) {
+ case EISADMA:
+ drq = DRQUNK; /* for EISA/VLB/PCI clones */
+ break;
case CHAN0:
- aha->sc_drq = 0;
+ drq = 0;
break;
case CHAN5:
- aha->sc_drq = 5;
+ drq = 5;
break;
case CHAN6:
- aha->sc_drq = 6;
+ drq = 6;
break;
case CHAN7:
- aha->sc_drq = 7;
+ drq = 7;
break;
default:
- printf("%s: illegal drq setting %x\n", aha->sc_dev.dv_xname,
- conf.chan);
- return EIO;
+ printf("aha_find: illegal drq setting %x\n", config.reply.chan);
+ return 1;
}
- switch (conf.intr) {
+ switch (config.reply.intr) {
case INT9:
- aha->sc_irq = 9;
+ irq = 9;
break;
case INT10:
- aha->sc_irq = 10;
+ irq = 10;
break;
case INT11:
- aha->sc_irq = 11;
+ irq = 11;
break;
case INT12:
- aha->sc_irq = 12;
+ irq = 12;
break;
case INT14:
- aha->sc_irq = 14;
+ irq = 14;
break;
case INT15:
- aha->sc_irq = 15;
+ irq = 15;
break;
default:
- printf("%s: illegal irq setting %x\n", aha->sc_dev.dv_xname,
- conf.intr);
+ printf("aha_find: illegal irq setting %x\n", config.reply.intr);
return EIO;
}
- /* who are we on the scsi bus? */
- aha->aha_scsi_dev = conf.scsi_dev;
+ if (sc != NULL) {
+ /* who are we on the scsi bus? */
+ sc->sc_scsi_dev = config.reply.scsi_dev;
- /*
- * Change the bus on/off times to not clash with other dma users.
- */
- aha_cmd(aha, 1, 0, 0, 0, AHA_BUS_ON_TIME_SET, 7);
- aha_cmd(aha, 1, 0, 0, 0, AHA_BUS_OFF_TIME_SET, 4);
+ sc->sc_iobase = iobase;
+ sc->sc_irq = irq;
+ sc->sc_drq = drq;
+ } else {
+ if (ia->ia_irq == IRQUNK)
+ ia->ia_irq = irq;
+ else if (ia->ia_irq != irq)
+ return 1;
+ if (ia->ia_drq == DRQUNK)
+ ia->ia_drq = drq;
+ else if (ia->ia_drq != drq)
+ return 1;
+ }
return 0;
}
* Start the board, ready for normal operation
*/
void
-aha_init(aha)
- struct aha_softc *aha;
+aha_init(sc)
+ struct aha_softc *sc;
{
- u_char ad[3];
- struct isadma_seg mbx_phys[1];
+ int iobase = sc->sc_iobase;
+ struct aha_devices devices;
+ struct aha_setup setup;
+ struct aha_mailbox mailbox;
int i;
-#ifdef TUNE_1542
/*
- * Initialize memory transfer speed
- * Not compiled in by default because it breaks some machines
+ * XXX
+ * If we are a 1542C or later, disable the extended BIOS so that the
+ * mailbox interface is unlocked.
+ * No need to check the extended BIOS flags as some of the
+ * extensions that cause us problems are not flagged in that byte.
*/
- if (!aha_set_bus_speed(aha))
- panic("aha_init: cannot set bus speed");
-#endif /* TUNE_1542 */
+ if (!strncmp(sc->sc_model, "1542C", 5)) {
+ struct aha_extbios extbios;
+ struct aha_unlock unlock;
+
+ printf("%s: unlocking mailbox interface\n", sc->sc_dev.dv_xname);
+ extbios.cmd.opcode = AHA_EXT_BIOS;
+ aha_cmd(iobase, sc, sizeof(extbios.cmd), (u_char *)&extbios.cmd,
+ sizeof(extbios.reply), (u_char *)&extbios.reply);
+
+#ifdef AHADEBUG
+ printf("%s: flags=%02x, mailboxlock=%02x\n",
+ sc->sc_dev.dv_xname,
+ extbios.reply.flags, extbios.reply.mailboxlock);
+#endif /* AHADEBUG */
+ unlock.cmd.opcode = AHA_MBX_ENABLE;
+ unlock.cmd.junk = 0;
+ unlock.cmd.magic = extbios.reply.mailboxlock;
+ aha_cmd(iobase, sc, sizeof(unlock.cmd), (u_char *)&unlock.cmd,
+ 0, (u_char *)0);
+ }
+
+#if 0
/*
- * Initialize mail box. This mapping will never be undone.
+ * Change the bus on/off times to not clash with other dma users.
*/
- if (isadma_map((caddr_t)(&aha->aha_mbx), sizeof(struct aha_mbx),
- mbx_phys, ISADMA_MAP_CONTIG) != 1)
- panic("aha_init: cannot map mail box");
- lto3b(mbx_phys[0].addr, ad);
+ aha_cmd(sc, 1, 0, 0, 0, AHA_BUS_ON_TIME_SET, 7);
+ aha_cmd(sc, 1, 0, 0, 0, AHA_BUS_OFF_TIME_SET, 4);
+#endif
- aha_cmd(aha, 4, 0, 0, 0, AHA_MBX_INIT, AHA_MBX_SIZE,
- ad[0], ad[1], ad[2]);
+ /* Inquire Installed Devices (to force synchronous negotiation). */
+ devices.cmd.opcode = AHA_INQUIRE_DEVICES;
+ aha_cmd(iobase, sc, sizeof(devices.cmd), (u_char *)&devices.cmd,
+ sizeof(devices.reply), (u_char *)&devices.reply);
+
+ /* Obtain setup information from. */
+ setup.cmd.opcode = AHA_INQUIRE_SETUP;
+ setup.cmd.len = sizeof(setup.reply);
+ aha_cmd(iobase, sc, sizeof(setup.cmd), (u_char *)&setup.cmd,
+ sizeof(setup.reply), (u_char *)&setup.reply);
+
+ printf("%s: %s, %s\n",
+ sc->sc_dev.dv_xname,
+ setup.reply.sync_neg ? "sync" : "async",
+ setup.reply.parity ? "parity" : "no parity");
+
+ for (i = 0; i < 8; i++) {
+ if (!setup.reply.sync[i].valid ||
+ (!setup.reply.sync[i].offset && !setup.reply.sync[i].period))
+ continue;
+ printf("%s targ %d: sync, offset %d, period %dnsec\n",
+ sc->sc_dev.dv_xname, i,
+ setup.reply.sync[i].offset, setup.reply.sync[i].period * 50 + 200);
+ }
+ /*
+ * Set up initial mail box for round-robin operation.
+ */
for (i = 0; i < AHA_MBX_SIZE; i++) {
- aha->aha_mbx.mbo[i].cmd = AHA_MBO_FREE;
- aha->aha_mbx.mbi[i].stat = AHA_MBO_FREE;
+ wmbx->mbo[i].cmd = AHA_MBO_FREE;
+ wmbx->mbi[i].stat = AHA_MBO_FREE;
}
+ wmbx->cmbo = wmbx->tmbo = &wmbx->mbo[0];
+ wmbx->tmbi = &wmbx->mbi[0];
+ sc->sc_mbofull = 0;
+
+ /* Initialize mail box. */
+ mailbox.cmd.opcode = AHA_MBX_INIT;
+ mailbox.cmd.nmbx = AHA_MBX_SIZE;
+ ltophys(KVTOPHYS(wmbx), mailbox.cmd.addr);
+ aha_cmd(iobase, sc, sizeof(mailbox.cmd), (u_char *)&mailbox.cmd,
+ 0, (u_char *)0);
+}
+
+void
+aha_inquire_setup_information(sc)
+ struct aha_softc *sc;
+{
+ int iobase = sc->sc_iobase;
+ struct aha_revision revision;
+ u_char sts;
+ int i;
+ char *p;
+
+ strcpy(sc->sc_model, "unknown");
/*
- * Set up initial mail box for round-robin operation.
+ * Assume we have a board at this stage, do an adapter inquire
+ * to find out what type of controller it is. If the command
+ * fails, we assume it's either a crusty board or an old 1542
+ * clone, and skip the board-specific stuff.
*/
- aha->aha_mbx.tmbo = &aha->aha_mbx.mbo[0];
- aha->aha_mbx.tmbi = &aha->aha_mbx.mbi[0];
+ revision.cmd.opcode = AHA_INQUIRE_REVISION;
+ if (aha_cmd(iobase, sc, sizeof(revision.cmd), (u_char *)&revision.cmd,
+ sizeof(revision.reply), (u_char *)&revision.reply)) {
+ /*
+ * aha_cmd() already started the reset. It's not clear we
+ * even need to bother here.
+ */
+ for (i = AHA_RESET_TIMEOUT; i; i--) {
+ sts = inb(iobase + AHA_STAT_PORT);
+ if (sts == (AHA_STAT_IDLE | AHA_STAT_INIT))
+ break;
+ delay(1000);
+ }
+ if (!i) {
+#ifdef AHADEBUG
+ printf("aha_init: soft reset failed\n");
+#endif /* AHADEBUG */
+ return;
+ }
+#ifdef AHADEBUG
+ printf("aha_init: inquire command failed\n");
+#endif /* AHADEBUG */
+ goto noinquire;
+ }
+
+#ifdef AHADEBUG
+ printf("%s: inquire %x, %x, %x, %x\n",
+ sc->sc_dev.dv_xname,
+ revision.reply.boardid, revision.reply.spec_opts,
+ revision.reply.revision_1, revision.reply.revision_2);
+#endif /* AHADEBUG */
+
+ switch (revision.reply.boardid) {
+ case 0x31:
+ strcpy(sc->sc_model, "1540");
+ break;
+ case 0x41:
+ strcpy(sc->sc_model, "1540A/1542A/1542B");
+ break;
+ case 0x42:
+ strcpy(sc->sc_model, "1640");
+ break;
+ case 0x43:
+ strcpy(sc->sc_model, "1542C");
+ break;
+ case 0x44:
+ case 0x45:
+ strcpy(sc->sc_model, "1542CF");
+ break;
+ case 0x46:
+ strcpy(sc->sc_model, "1542CP");
+ break;
+ }
+
+ p = sc->sc_firmware;
+ *p++ = revision.reply.revision_1;
+ *p++ = '.';
+ *p++ = revision.reply.revision_2;
+ *p = '\0';
+
+noinquire:
+ printf(": model AHA-%s, firmware %s\n", sc->sc_model, sc->sc_firmware);
}
void
struct scsi_xfer *xs;
{
struct scsi_link *sc_link = xs->sc_link;
- struct aha_softc *aha = sc_link->adapter_softc;
+ struct aha_softc *sc = sc_link->adapter_softc;
struct aha_ccb *ccb;
struct aha_scat_gath *sg;
- int seg, datalen, flags, mflags;
+ int seg; /* scatter gather seg being worked on */
+ u_long thiskv, thisphys, nextphys;
+ int bytes_this_seg, bytes_this_page, datalen, flags;
struct iovec *iovp;
- struct aha_mbx_out *mbo;
int s;
SC_DEBUG(sc_link, SDEV_DB2, ("aha_scsi_cmd\n"));
* then we can't allow it to sleep
*/
flags = xs->flags;
- if (flags & SCSI_NOSLEEP)
- mflags = ISADMA_MAP_BOUNCE;
- else
- mflags = ISADMA_MAP_BOUNCE | ISADMA_MAP_WAITOK;
- if ((flags & (ITSDONE|INUSE)) != INUSE) {
- printf("%s: done or not in use?\n", aha->sc_dev.dv_xname);
- xs->flags &= ~ITSDONE;
- xs->flags |= INUSE;
- }
- if ((ccb = aha_get_ccb(aha, flags)) == NULL) {
+ if ((ccb = aha_get_ccb(sc, flags)) == NULL) {
xs->error = XS_DRIVER_STUFFUP;
return TRY_AGAIN_LATER;
}
ccb->xs = xs;
+ ccb->timeout = xs->timeout;
/*
* Put all the arguments for the xfer in the ccb
*/
if (flags & SCSI_RESET) {
ccb->opcode = AHA_RESET_CCB;
+ ccb->scsi_cmd_length = 0;
} else {
/* can't use S/G if zero length */
ccb->opcode = (xs->datalen ? AHA_INIT_SCAT_GATH_CCB
: AHA_INITIATOR_CCB);
+ bcopy(xs->cmd, &ccb->scsi_cmd,
+ ccb->scsi_cmd_length = xs->cmdlen);
}
- ccb->data_out = 0;
- ccb->data_in = 0;
- ccb->target = sc_link->target;
- ccb->lun = sc_link->lun;
- ccb->scsi_cmd_length = xs->cmdlen;
- ccb->req_sense_length = sizeof(ccb->scsi_sense);
- ccb->host_stat = 0x00;
- ccb->target_stat = 0x00;
- ccb->data_nseg = 0;
- if (xs->datalen && (flags & SCSI_RESET) == 0) {
- sg = ((struct aha_ccb *)(ccb->ccb_phys[0].addr))->scat_gath;
- lto3b((vm_offset_t)sg, ccb->data_addr);
+ if (xs->datalen) {
sg = ccb->scat_gath;
seg = 0;
#ifdef TFS
datalen = ((struct uio *)xs->data)->uio_iovcnt;
xs->datalen = 0;
while (datalen && seg < AHA_NSEG) {
- lto3b(iovp->iov_base, sg->seg_addr);
- lto3b(iovp->iov_len, sg->seg_len);
+ ltophys(iovp->iov_base, sg->seg_addr);
+ ltophys(iovp->iov_len, sg->seg_len);
xs->datalen += iovp->iov_len;
SC_DEBUGN(sc_link, SDEV_DB4, ("UIO(0x%x@0x%x)",
iovp->iov_len, iovp->iov_base));
datalen--;
}
} else
-#endif /*TFS_ONLY */
+#endif /* TFS */
{
/*
- * Set up the scatter gather block
+ * Set up the scatter-gather block.
*/
+ SC_DEBUG(sc_link, SDEV_DB4,
+ ("%d @0x%x:- ", xs->datalen, xs->data));
+
+ datalen = xs->datalen;
+ thiskv = (int)xs->data;
+ thisphys = KVTOPHYS(thiskv);
- ccb->data_nseg = isadma_map(xs->data, xs->datalen,
- ccb->data_phys, mflags);
- for (seg = 0; seg < ccb->data_nseg; seg++) {
- lto3b(ccb->data_phys[seg].addr,
- sg[seg].seg_addr);
- lto3b(ccb->data_phys[seg].length,
- sg[seg].seg_len);
+ while (datalen && seg < AHA_NSEG) {
+ bytes_this_seg = 0;
+
+ /* put in the base address */
+ ltophys(thisphys, sg->seg_addr);
+
+ SC_DEBUGN(sc_link, SDEV_DB4, ("0x%x", thisphys));
+
+ /* do it at least once */
+ nextphys = thisphys;
+ while (datalen && thisphys == nextphys) {
+ /*
+ * This page is contiguous (physically)
+ * with the the last, just extend the
+ * length
+ */
+ /* check it fits on the ISA bus */
+ if (thisphys > 0xFFFFFF) {
+ printf("%s: DMA beyond"
+ " end of ISA\n",
+ sc->sc_dev.dv_xname);
+ goto bad;
+ }
+ /* how far to the end of the page */
+ nextphys = (thisphys & ~PGOFSET) + NBPG;
+ bytes_this_page = nextphys - thisphys;
+ /**** or the data ****/
+ bytes_this_page = min(bytes_this_page,
+ datalen);
+ bytes_this_seg += bytes_this_page;
+ datalen -= bytes_this_page;
+
+ /* get more ready for the next page */
+ thiskv = (thiskv & ~PGOFSET) + NBPG;
+ if (datalen)
+ thisphys = KVTOPHYS(thiskv);
+ }
+ /*
+ * next page isn't contiguous, finish the seg
+ */
+ SC_DEBUGN(sc_link, SDEV_DB4,
+ ("(0x%x)", bytes_this_seg));
+ ltophys(bytes_this_seg, sg->seg_len);
+ sg++;
+ seg++;
}
}
- lto3b(ccb->data_nseg * sizeof(struct aha_scat_gath), ccb->data_length);
- if (ccb->data_nseg == 0) {
- printf("%s: aha_scsi_cmd, cannot map\n",
- aha->sc_dev.dv_xname);
- xs->error = XS_DRIVER_STUFFUP;
- aha_free_ccb(aha, ccb, flags);
- return COMPLETE;
- } else if (flags & SCSI_DATA_OUT)
- isadma_copytobuf(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
+ /* end of iov/kv decision */
+ SC_DEBUGN(sc_link, SDEV_DB4, ("\n"));
+ if (datalen) {
+ /*
+ * there's still data, must have run out of segs!
+ */
+ printf("%s: aha_scsi_cmd, more than %d dma segs\n",
+ sc->sc_dev.dv_xname, AHA_NSEG);
+ goto bad;
+ }
+ ltophys(KVTOPHYS(ccb->scat_gath), ccb->data_addr);
+ ltophys(seg * sizeof(struct aha_scat_gath), ccb->data_length);
} else { /* No data xfer, use non S/G values */
- lto3b(0, ccb->data_addr);
- lto3b(0, ccb->data_length);
+ ltophys(0, ccb->data_addr);
+ ltophys(0, ccb->data_length);
}
- ccb->link_id = 0;
- lto3b(0, ccb->link_addr);
- /*
- * Put the scsi command in the ccb and start it
- */
- if ((flags & SCSI_RESET) == 0)
- bcopy(xs->cmd, &ccb->scsi_cmd, ccb->scsi_cmd_length);
+ ccb->data_out = 0;
+ ccb->data_in = 0;
+ ccb->target = sc_link->target;
+ ccb->lun = sc_link->lun;
+ ccb->req_sense_length = sizeof(ccb->scsi_sense);
+ ccb->host_stat = 0x00;
+ ccb->target_stat = 0x00;
+ ccb->link_id = 0;
+ ltophys(0, ccb->link_addr);
s = splbio();
-
- isadma_copytobuf((caddr_t)ccb, CCB_PHYS_SIZE, 1, ccb->ccb_phys);
-
- if (aha_send_mbo(aha, AHA_MBO_START, ccb) == NULL) {
- splx(s);
- xs->error = XS_DRIVER_STUFFUP;
- if (ccb->data_nseg)
- isadma_unmap(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- aha_free_ccb(aha, ccb, flags);
- return TRY_AGAIN_LATER;
- }
+ aha_queue_ccb(sc, ccb);
+ splx(s);
/*
* Usually return SUCCESSFULLY QUEUED
*/
SC_DEBUG(sc_link, SDEV_DB3, ("cmd_sent\n"));
-
- if (VOLATILE_XS(xs)) {
- timeout(aha_timeout, ccb, (xs->timeout * hz) / 1000);
- while ((ccb->xs->flags & ITSDONE) == 0) {
- tsleep(ccb, PRIBIO, "ahawait", 0);
- }
- splx(s);
- if (ccb->data_nseg) {
- if (flags & SCSI_DATA_IN)
- isadma_copyfrombuf(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- isadma_unmap(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- }
- aha_free_ccb(aha, ccb, xs->flags);
- scsi_done(xs);
- return COMPLETE;
- }
-
- if ((flags & SCSI_POLL) == 0) {
- timeout(aha_timeout, ccb, (xs->timeout * hz) / 1000);
- splx(s);
+ if ((flags & SCSI_POLL) == 0)
return SUCCESSFULLY_QUEUED;
- }
-
- splx(s);
/*
* If we can't use interrupts, poll on completion
*/
- if (aha_poll(aha, xs, xs->timeout)) {
+ if (aha_poll(sc, xs, ccb->timeout)) {
aha_timeout(ccb);
- if (aha_poll(aha, xs, 2000))
+ if (aha_poll(sc, xs, ccb->timeout))
aha_timeout(ccb);
}
return COMPLETE;
+
+bad:
+ xs->error = XS_DRIVER_STUFFUP;
+ aha_free_ccb(sc, ccb);
+ return COMPLETE;
}
/*
* Poll a particular unit, looking for a particular xs
*/
int
-aha_poll(aha, xs, count)
- struct aha_softc *aha;
+aha_poll(sc, xs, count)
+ struct aha_softc *sc;
struct scsi_xfer *xs;
int count;
{
+ int iobase = sc->sc_iobase;
/* timeouts are in msec, so we loop in 1000 usec cycles */
while (count) {
* If we had interrupts enabled, would we
* have got an interrupt?
*/
- if (inb(AHA_INTR_PORT) & AHA_ANY_INTR)
- ahaintr(aha);
+ if (inb(iobase + AHA_INTR_PORT) & AHA_INTR_ANYINTR)
+ ahaintr(sc);
if (xs->flags & ITSDONE)
return 0;
delay(1000); /* only happens in boot so ok */
return 1;
}
-#ifdef TUNE_1542
-/*
- * Try all the speeds from slowest to fastest.. if it finds a
- * speed that fails, back off one notch from the last working
- * speed (unless there is no other notch).
- * Returns the nSEC value of the time used
- * or 0 if it could get a working speed (or the NEXT speed
- * failed)
- */
-static struct bus_speed {
- u_char arg;
- int nsecs;
-} aha_bus_speeds[] = {
- {0x88, 100},
- {0x99, 150},
- {0xaa, 200},
- {0xbb, 250},
- {0xcc, 300},
- {0xdd, 350},
- {0xee, 400},
- {0xff, 450}
-};
-
-int
-aha_set_bus_speed(aha)
- struct aha_softc *aha;
-{
- int speed;
- int lastworking;
-
- lastworking = -1;
- for (speed = 7; speed >= 0; speed--) {
- if (!aha_bus_speed_check(aha, speed))
- break;
- lastworking = speed;
- }
- if (lastworking == -1) {
- printf(" no working bus speed");
- return 0;
- }
- printf(", %d nsec ", aha_bus_speeds[lastworking].nsecs);
- if (lastworking == 7) /* is slowest already */
- printf("marginal");
- else {
- lastworking++;
- printf("ok, using %d nsec", aha_bus_speeds[lastworking].nsecs);
- }
- if (!aha_bus_speed_check(aha, lastworking)) {
- printf("test retry failed.. aborting.");
- return 0;
- }
- return 1;
-}
-
-/*
- * Set the DMA speed to the Nth speed and try an xfer. If it
- * fails return 0, if it succeeds return the nSec value selected
- * If there is no such speed return COMPLETE.
- */
-char aha_scratch_buf[256];
-char aha_test_string[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@";
-
-int
-aha_bus_speed_check(aha, speed)
- struct aha_softc *aha;
- int speed;
-{
- int numspeeds = sizeof(aha_bus_speeds) / sizeof(struct bus_speed);
- int result, loopcount;
- struct isadma_seg test_phys[1], scratch_phys[1];
- u_char ad[3];
-
- result = 1;
-
- if (isadma_map(aha_scratch_buf, sizeof(aha_scratch_buf),
- scratch_phys, ISADMA_MAP_CONTIG) != 1)
- return 0;
- if (isadma_map(aha_test_string, sizeof(aha_test_string),
- test_phys, ISADMA_MAP_CONTIG) != 1) {
- isadma_unmap(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
- return 0;
- }
- isadma_copytobuf(aha_test_string, sizeof(aha_test_string),
- 1, test_phys);
-
- /*
- * Set the dma-speed
- */
- aha_cmd(aha, 1, 0, 0, 0, AHA_SPEED_SET, aha_bus_speeds[speed].arg);
-
- /*
- * put the test data into the buffer and calculate
- * it's address. Read it onto the board
- */
- for (loopcount = 100; loopcount; loopcount--) {
- lto3b(test_phys[0].addr, ad);
- aha_cmd(aha, 3, 0, 0, 0, AHA_WRITE_FIFO, ad[0], ad[1], ad[2]);
-
- /*
- * Clear the buffer then copy the contents back from the
- * board.
- */
- bzero(aha_scratch_buf, 54);
- isadma_copytobuf(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
-
- lto3b(scratch_phys[0].addr, ad);
- aha_cmd(aha, 3, 0, 0, 0, AHA_READ_FIFO, ad[0], ad[1], ad[2]);
- isadma_copyfrombuf(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
-
- /*
- * Compare the original data and the final data and return the
- * correct value depending upon the result. We only check the
- * first 54 bytes, because that's all the board copies during
- * WRITE_FIFO and READ_FIFO.
- */
- if (bcmp(aha_test_string, aha_scratch_buf, 54)) {
- result = 0; /* failed test */
- break;
- }
- }
-
- isadma_unmap(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
- isadma_unmap(aha_test_string, sizeof(aha_test_string),
- 1, test_phys);
-
- /* copy succeeded; assume speed ok */
- return result;
-}
-#endif /* TUNE_1542 */
-
void
aha_timeout(arg)
void *arg;
struct aha_ccb *ccb = arg;
struct scsi_xfer *xs = ccb->xs;
struct scsi_link *sc_link = xs->sc_link;
- struct aha_softc *aha = sc_link->adapter_softc;
+ struct aha_softc *sc = sc_link->adapter_softc;
int s;
sc_print_addr(sc_link);
s = splbio();
+#ifdef AHADIAG
/*
* If The ccb's mbx is not free, then the board has gone south?
*/
- if (aha_ccb_phys_kv(aha, _3btol(ccb->mbx->ccb_addr)) == ccb &&
- ccb->mbx->cmd != AHA_MBO_FREE) {
- printf("%s: not taking commands!\n", aha->sc_dev.dv_xname);
+ aha_collect_mbo(sc);
+ if (ccb->flags & CCB_SENDING) {
+ printf("%s: not taking commands!\n", sc->sc_dev.dv_xname);
Debugger();
}
+#endif
/*
* If it has been through before, then
* a previous abort has failed, don't
* try abort again
*/
- if (ccb->flags == CCB_ABORTED) {
+ if (ccb->flags & CCB_ABORT) {
/* abort timed out */
printf(" AGAIN\n");
- ccb->xs->retries = 0;
- aha_done(aha, ccb);
+ /* XXX Must reset! */
} else {
/* abort the operation that has timed out */
printf("\n");
ccb->xs->error = XS_TIMEOUT;
- ccb->flags = CCB_ABORTED;
- aha_send_mbo(aha, AHA_MBO_ABORT, ccb);
- /* 2 secs for the abort */
- if ((xs->flags & SCSI_POLL) == 0)
- timeout(aha_timeout, ccb, 2 * hz);
+ ccb->timeout = AHA_ABORT_TIMEOUT;
+ ccb->flags |= CCB_ABORT;
+ aha_queue_ccb(sc, ccb);
}
splx(s);
+++ /dev/null
-/* $OpenBSD: aha1542.c,v 1.13 1996/03/20 01:00:35 mickey Exp $ */
-/* $NetBSD: aha1542.c,v 1.55 1995/12/24 02:31:06 mycroft Exp $ */
-
-/*
- * Copyright (c) 1994 Charles Hannum. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Charles Hannum.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Originally written by Julian Elischer (julian@tfs.com)
- * for TRW Financial Systems for use under the MACH(2.5) operating system.
- *
- * TRW Financial Systems, in accordance with their agreement with Carnegie
- * Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
- * the software. For this reason TFS also grants any other persons or
- * organisations permission to use or modify this software.
- *
- * TFS supplies this software to be publicly redistributed
- * on the understanding that TFS is not responsible for the correct
- * functioning of this software in any circumstances.
- */
-
-/*
- * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-
-#include <machine/pio.h>
-
-#include <dev/isa/isavar.h>
-#include <dev/isa/isadmavar.h>
-#include <scsi/scsi_all.h>
-#include <scsi/scsiconf.h>
-
-#ifndef DDB
-#define Debugger() panic("should call debugger here (aha1542.c)")
-#endif /* ! DDB */
-
-/* XXX fixme:
- * on i386 at least, xfers to/from user memory
- * cannot be serviced at interrupt time.
- */
-#ifdef i386
-#define VOLATILE_XS(xs) \
- ((xs)->datalen > 0 && (xs)->bp == NULL && \
- ((xs)->flags & SCSI_POLL) == 0)
-#else
-#define VOLATILE_XS(xs) 0
-#endif
-
-#undef TUNE_1542 /* if bus speed check breaks the machine, undefine it */
-
-/************************** board definitions *******************************/
-
-/*
- * I/O Port Interface
- */
-#define AHA_BASE aha->sc_iobase
-#define AHA_CTRL_STAT_PORT (AHA_BASE + 0x0) /* control & status */
-#define AHA_CMD_DATA_PORT (AHA_BASE + 0x1) /* cmds and datas */
-#define AHA_INTR_PORT (AHA_BASE + 0x2) /* Intr. stat */
-
-/*
- * AHA_CTRL_STAT bits (write)
- */
-#define AHA_HRST 0x80 /* Hardware reset */
-#define AHA_SRST 0x40 /* Software reset */
-#define AHA_IRST 0x20 /* Interrupt reset */
-#define AHA_SCRST 0x10 /* SCSI bus reset */
-
-/*
- * AHA_CTRL_STAT bits (read)
- */
-#define AHA_STST 0x80 /* Self test in Progress */
-#define AHA_DIAGF 0x40 /* Diagnostic Failure */
-#define AHA_INIT 0x20 /* Mbx Init required */
-#define AHA_IDLE 0x10 /* Host Adapter Idle */
-#define AHA_CDF 0x08 /* cmd/data out port full */
-#define AHA_DF 0x04 /* Data in port full */
-#define AHA_INVDCMD 0x01 /* Invalid command */
-
-/*
- * AHA_CMD_DATA bits (write)
- */
-#define AHA_NOP 0x00 /* No operation */
-#define AHA_MBX_INIT 0x01 /* Mbx initialization */
-#define AHA_START_SCSI 0x02 /* start scsi command */
-#define AHA_START_BIOS 0x03 /* start bios command */
-#define AHA_INQUIRE 0x04 /* Adapter Inquiry */
-#define AHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
-#define AHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
-#define AHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */
-#define AHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
-#define AHA_SPEED_SET 0x09 /* set transfer speed */
-#define AHA_DEV_GET 0x0a /* return installed devices */
-#define AHA_CONF_GET 0x0b /* return configuration data */
-#define AHA_TARGET_EN 0x0c /* enable target mode */
-#define AHA_SETUP_GET 0x0d /* return setup data */
-#define AHA_WRITE_CH2 0x1a /* write channel 2 buffer */
-#define AHA_READ_CH2 0x1b /* read channel 2 buffer */
-#define AHA_WRITE_FIFO 0x1c /* write fifo buffer */
-#define AHA_READ_FIFO 0x1d /* read fifo buffer */
-#define AHA_ECHO 0x1e /* Echo command data */
-#define AHA_EXT_BIOS 0x28 /* return extended bios info */
-#define AHA_MBX_ENABLE 0x29 /* enable mail box interface */
-
-/*
- * AHA_INTR_PORT bits (read)
- */
-#define AHA_ANY_INTR 0x80 /* Any interrupt */
-#define AHA_SCRD 0x08 /* SCSI reset detected */
-#define AHA_HACC 0x04 /* Command complete */
-#define AHA_MBOA 0x02 /* MBX out empty */
-#define AHA_MBIF 0x01 /* MBX in full */
-
-/*
- * Mail box defs
- */
-#define AHA_MBX_SIZE 16 /* mail box size */
-
-#define AHA_CCB_MAX 32 /* store up to 32 CCBs at one time */
-#define CCB_HASH_SIZE 32 /* hash table size for phystokv */
-#define CCB_HASH_SHIFT 9
-#define CCB_HASH(x) ((((long)(x))>>CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
-
-#define aha_nextmbx(wmb, mbx, mbio) \
- if ((wmb) == &(mbx)->mbio[AHA_MBX_SIZE - 1]) \
- (wmb) = &(mbx)->mbio[0]; \
- else \
- (wmb)++;
-
-struct aha_mbx_out {
- u_char cmd;
- u_char ccb_addr[3];
-};
-
-struct aha_mbx_in {
- u_char stat;
- u_char ccb_addr[3];
-};
-
-struct aha_mbx {
- struct aha_mbx_out mbo[AHA_MBX_SIZE];
- struct aha_mbx_in mbi[AHA_MBX_SIZE];
- struct aha_mbx_out *tmbo; /* Target Mail Box out */
- struct aha_mbx_in *tmbi; /* Target Mail Box in */
-};
-
-/*
- * mbo.cmd values
- */
-#define AHA_MBO_FREE 0x0 /* MBO entry is free */
-#define AHA_MBO_START 0x1 /* MBO activate entry */
-#define AHA_MBO_ABORT 0x2 /* MBO abort entry */
-
-/*
- * mbi.stat values
- */
-#define AHA_MBI_FREE 0x0 /* MBI entry is free */
-#define AHA_MBI_OK 0x1 /* completed without error */
-#define AHA_MBI_ABORT 0x2 /* aborted ccb */
-#define AHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
-#define AHA_MBI_ERROR 0x4 /* Completed with error */
-
-/* FOR OLD VERSIONS OF THE !%$@ this may have to be 16 (yuk) */
-#define AHA_NSEG 17 /* Number of scatter gather segments <= 16 */
- /* allow 60 K i/o (min) */
-
-struct aha_ccb {
- u_char opcode;
- u_char lun:3;
- u_char data_in:1; /* must be 0 */
- u_char data_out:1; /* must be 0 */
- u_char target:3;
- u_char scsi_cmd_length;
- u_char req_sense_length;
- u_char data_length[3];
- u_char data_addr[3];
- u_char link_addr[3];
- u_char link_id;
- u_char host_stat;
- u_char target_stat;
- u_char reserved[2];
- struct scsi_generic scsi_cmd;
- struct scsi_sense_data scsi_sense;
- struct aha_scat_gath {
- u_char seg_len[3];
- u_char seg_addr[3];
- } scat_gath[AHA_NSEG];
- /*----------------------------------------------------------------*/
-#define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
- TAILQ_ENTRY(aha_ccb) chain;
- struct aha_ccb *nexthash;
- struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
- int flags;
-#define CCB_FREE 0
-#define CCB_ACTIVE 1
-#define CCB_ABORTED 2
- struct aha_mbx_out *mbx; /* pointer to mail box */
- struct isadma_seg ccb_phys[1]; /* phys segment of this ccb */
- struct isadma_seg data_phys[AHA_NSEG]; /* phys segments of data */
- int data_nseg; /* number of phys segments of data */
-};
-
-/*
- * opcode fields
- */
-#define AHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
-#define AHA_TARGET_CCB 0x01 /* SCSI Target CCB */
-#define AHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scatter gather */
-#define AHA_RESET_CCB 0x81 /* SCSI Bus reset */
-
-/*
- * aha_ccb.host_stat values
- */
-#define AHA_OK 0x00 /* cmd ok */
-#define AHA_LINK_OK 0x0a /* Link cmd ok */
-#define AHA_LINK_IT 0x0b /* Link cmd ok + int */
-#define AHA_SEL_TIMEOUT 0x11 /* Selection time out */
-#define AHA_OVER_UNDER 0x12 /* Data over/under run */
-#define AHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */
-#define AHA_INV_BUS 0x14 /* Invalid bus phase/sequence */
-#define AHA_BAD_MBO 0x15 /* Incorrect MBO cmd */
-#define AHA_BAD_CCB 0x16 /* Incorrect ccb opcode */
-#define AHA_BAD_LINK 0x17 /* Not same values of LUN for links */
-#define AHA_INV_TARGET 0x18 /* Invalid target direction */
-#define AHA_CCB_DUP 0x19 /* Duplicate CCB received */
-#define AHA_INV_CCB 0x1a /* Invalid CCB or segment list */
-#define AHA_ABORTED 42
-
-struct aha_setup {
- u_char sync_neg:1;
- u_char parity:1;
- u_char:6;
- u_char speed;
- u_char bus_on;
- u_char bus_off;
- u_char num_mbx;
- u_char mbx[3];
- struct {
- u_char offset:4;
- u_char period:3;
- u_char valid:1;
- } sync[8];
- u_char disc_sts;
-};
-
-struct aha_config {
- u_char chan;
- u_char intr;
- u_char scsi_dev:3;
- u_char:5;
-};
-
-struct aha_inquire {
- u_char boardid; /* type of board */
- /* 0x31 = AHA-1540 */
- /* 0x41 = AHA-1540A/1542A/1542B */
- /* 0x42 = AHA-1640 */
- /* 0x43 = AHA-1542C */
- /* 0x44 = AHA-1542CF */
- /* 0x45 = AHA-1542CF, BIOS v2.01 */
- u_char spec_opts; /* special options ID */
- /* 0x41 = Board is standard model */
- u_char revision_1; /* firmware revision [0-9A-Z] */
- u_char revision_2; /* firmware revision [0-9A-Z] */
-};
-
-struct aha_extbios {
- u_char flags; /* Bit 3 == 1 extended bios enabled */
- u_char mailboxlock; /* mail box lock code to unlock it */
-};
-
-#define INT9 0x01
-#define INT10 0x02
-#define INT11 0x04
-#define INT12 0x08
-#define INT14 0x20
-#define INT15 0x40
-
-#define CHAN0 0x01
-#define CHAN5 0x20
-#define CHAN6 0x40
-#define CHAN7 0x80
-
-/*********************************** end of board definitions***************/
-
-#ifdef AHADEBUG
-int aha_debug = 1;
-#endif /*AHADEBUG */
-
-struct aha_softc {
- struct device sc_dev;
- struct isadev sc_id;
- void *sc_ih;
-
- int sc_iobase;
- int sc_irq, sc_drq;
-
- struct aha_mbx aha_mbx; /* all the mailboxes */
- struct aha_ccb *ccbhash[CCB_HASH_SIZE];
- TAILQ_HEAD(, aha_ccb) free_ccb;
- int numccbs;
- int aha_scsi_dev; /* our scsi id */
- struct scsi_link sc_link;
-};
-
-int aha_cmd(); /* XXX must be varargs to prototype */
-int ahaintr __P((void *));
-void aha_free_ccb __P((struct aha_softc *, struct aha_ccb *, int));
-struct aha_ccb *aha_get_ccb __P((struct aha_softc *, int));
-struct aha_ccb *aha_ccb_phys_kv __P((struct aha_softc *, u_long));
-struct aha_mbx_out *aha_send_mbo __P((struct aha_softc *, int, struct aha_ccb *));
-void aha_done __P((struct aha_softc *, struct aha_ccb *));
-int aha_find __P((struct aha_softc *));
-void aha_init __P((struct aha_softc *));
-void ahaminphys __P((struct buf *));
-int aha_scsi_cmd __P((struct scsi_xfer *));
-int aha_poll __P((struct aha_softc *, struct scsi_xfer *, int));
-int aha_set_bus_speed __P((struct aha_softc *));
-int aha_bus_speed_check __P((struct aha_softc *, int));
-void aha_timeout __P((void *arg));
-
-struct scsi_adapter aha_switch = {
- aha_scsi_cmd,
- ahaminphys,
- 0,
- 0,
-};
-
-/* the below structure is so we have a default dev struct for out link struct */
-struct scsi_device aha_dev = {
- NULL, /* Use default error handler */
- NULL, /* have a queue, served by this */
- NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
-};
-
-int ahaprobe __P((struct device *, void *, void *));
-void ahaattach __P((struct device *, struct device *, void *));
-int ahaprint __P((void *, char *));
-
-struct cfdriver ahacd = {
- NULL, "aha", ahaprobe, ahaattach, DV_DULL, sizeof(struct aha_softc)
-};
-
-#define AHA_RESET_TIMEOUT 2000 /* time to wait for reset (mSec) */
-
-/*
- * aha_cmd(aha,icnt, ocnt,wait, retval, opcode, args)
- * Activate Adapter command
- * icnt: number of args (outbound bytes written after opcode)
- * ocnt: number of expected returned bytes
- * wait: number of seconds to wait for response
- * retval: buffer where to place returned bytes
- * opcode: opcode AHA_NOP, AHA_MBX_INIT, AHA_START_SCSI ...
- * args: parameters
- *
- * Performs an adapter command through the ports. Not to be confused
- * with a scsi command, which is read in via the dma. One of the adapter
- * commands tells it to read in a scsi command but that one is done
- * separately. This is only called during set-up.
- */
-int
-aha_cmd(aha, icnt, ocnt, wait, retval, opcode, args)
- struct aha_softc *aha;
- int icnt, ocnt, wait;
- u_char *retval;
- unsigned opcode;
- u_char args;
-{
- unsigned *ic = &opcode;
- u_char oc;
- register i;
- int sts;
-
- /*
- * multiply the wait argument by a big constant
- * zero defaults to 1 sec..
- * all wait loops are in 50uSec cycles
- */
- if (wait)
- wait *= 20000;
- else
- wait = 20000;
- /*
- * Wait for the adapter to go idle, unless it's one of
- * the commands which don't need this
- */
- if (opcode != AHA_MBX_INIT && opcode != AHA_START_SCSI) {
- i = 20000; /*do this for upto about a second */
- while (--i) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts & AHA_IDLE)
- break;
- delay(50);
- }
- if (!i) {
- printf("%s: aha_cmd, host not idle(0x%x)\n",
- aha->sc_dev.dv_xname, sts);
- return ENXIO;
- }
- }
- /*
- * Now that it is idle, if we expect output, preflush the
- * queue feeding to us.
- */
- if (ocnt) {
- while ((inb(AHA_CTRL_STAT_PORT)) & AHA_DF)
- inb(AHA_CMD_DATA_PORT);
- }
- /*
- * Output the command and the number of arguments given
- * for each byte, first check the port is empty.
- */
- icnt++;
- /* include the command */
- while (icnt--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- for (i = wait; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (!(sts & AHA_CDF))
- break;
- delay(50);
- }
- if (!i) {
- if (opcode != AHA_INQUIRE)
- printf("%s: aha_cmd, cmd/data port full\n",
- aha->sc_dev.dv_xname);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
- return ENXIO;
- }
- outb(AHA_CMD_DATA_PORT, (u_char) (*ic++));
- }
- /*
- * If we expect input, loop that many times, each time,
- * looking for the data register to have valid data
- */
- while (ocnt--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- for (i = wait; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts & AHA_DF)
- break;
- delay(50);
- }
- if (!i) {
- if (opcode != AHA_INQUIRE)
- printf("%s: aha_cmd, cmd/data port empty %d\n",
- aha->sc_dev.dv_xname, ocnt);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
- return ENXIO;
- }
- oc = inb(AHA_CMD_DATA_PORT);
- if (retval)
- *retval++ = oc;
- }
- /*
- * Wait for the board to report a finised instruction
- */
- i = 20000;
- while (--i) {
- sts = inb(AHA_INTR_PORT);
- if (sts & AHA_HACC)
- break;
- delay(50);
- }
- if (!i) {
- printf("%s: aha_cmd, host not finished(0x%x)\n",
- aha->sc_dev.dv_xname, sts);
- return ENXIO;
- }
- outb(AHA_CTRL_STAT_PORT, AHA_IRST);
- return 0;
-}
-
-/*
- * Check if the device can be found at the port given
- * and if so, set it up ready for further work
- * as an argument, takes the isa_device structure from
- * autoconf.c
- */
-int
-ahaprobe(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- struct aha_softc *aha = match;
- struct isa_attach_args *ia = aux;
-
-#ifdef NEWCONFIG
- if (ia->ia_iobase == IOBASEUNK)
- return 0;
-#endif
-
- aha->sc_iobase = ia->ia_iobase;
-
- /*
- * Try initialise a unit at this location
- * sets up dma and bus speed, loads aha->sc_irq
- */
- if (aha_find(aha) != 0)
- return 0;
-
- if (ia->ia_irq != IRQUNK) {
- if (ia->ia_irq != aha->sc_irq) {
- printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
- aha->sc_dev.dv_xname, ia->ia_irq, aha->sc_irq);
- return 0;
- }
- } else
- ia->ia_irq = aha->sc_irq;
-
- if (ia->ia_drq != DRQUNK) {
- if (ia->ia_drq != aha->sc_drq) {
- printf("%s: drq mismatch; kernel configured %d != board configured %d\n",
- aha->sc_dev.dv_xname, ia->ia_drq, aha->sc_drq);
- return 0;
- }
- } else
- ia->ia_drq = aha->sc_drq;
-
- ia->ia_msize = 0;
- ia->ia_iosize = 4;
- return 1;
-}
-
-int
-ahaprint(aux, name)
- void *aux;
- char *name;
-{
- if (name != NULL)
- printf("%s: scsibus ", name);
- return UNCONF;
-}
-
-/*
- * Attach all the sub-devices we can find
- */
-void
-ahaattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct isa_attach_args *ia = aux;
- struct aha_softc *aha = (void *)self;
-
- if (ia->ia_drq != DRQUNK)
- isadma_cascade(ia->ia_drq);
-
- aha_init(aha);
- TAILQ_INIT(&aha->free_ccb);
-
- /*
- * fill in the prototype scsi_link.
- */
- aha->sc_link.adapter_softc = aha;
- aha->sc_link.adapter_target = aha->aha_scsi_dev;
- aha->sc_link.adapter = &aha_switch;
- aha->sc_link.device = &aha_dev;
- aha->sc_link.openings = 2;
-
- printf("\n");
-
-#ifdef NEWCONFIG
- isa_establish(&aha->sc_id, &aha->sc_dev);
-#endif
- aha->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, ahaintr,
- aha, aha->sc_dev.dv_xname);
-
- /*
- * ask the adapter what subunits are present
- */
- config_found(self, &aha->sc_link, ahaprint);
-}
-
-/*
- * Catch an interrupt from the adaptor
- */
-int
-ahaintr(arg)
- void *arg;
-{
- struct aha_softc *aha = arg;
- struct aha_mbx_in *wmbi;
- struct aha_mbx *wmbx;
- struct aha_ccb *ccb;
- u_char stat;
- int i;
- int found = 0;
-
-#ifdef AHADEBUG
- printf("%s: ahaintr ", aha->sc_dev.dv_xname);
-#endif /*AHADEBUG */
-
- /*
- * First acknowlege the interrupt, Then if it's not telling about
- * a completed operation just return.
- */
- stat = inb(AHA_INTR_PORT);
- if ((stat & (AHA_MBOA | AHA_MBIF)) == 0) {
- outb(AHA_CTRL_STAT_PORT, AHA_IRST);
- return -1; /* XXX */
- }
-
- /* Mail box out empty? */
- if (stat & AHA_MBOA) {
- /* Disable MBO available interrupt. */
- outb(AHA_CMD_DATA_PORT, AHA_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(AHA_CTRL_STAT_PORT) & AHA_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: ahaintr, cmd/data port full\n",
- aha->sc_dev.dv_xname);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
- return 1;
- }
- outb(AHA_CMD_DATA_PORT, 0x00); /* Disable */
- wakeup(&aha->aha_mbx);
- }
-
- /* Mail box in full? */
- if ((stat & AHA_MBIF) == 0)
- return 1;
- wmbx = &aha->aha_mbx;
- wmbi = wmbx->tmbi;
-AGAIN:
- while (wmbi->stat != AHA_MBI_FREE) {
- ccb = aha_ccb_phys_kv(aha, _3btol(wmbi->ccb_addr));
- if (!ccb) {
- wmbi->stat = AHA_MBI_FREE;
- printf("%s: BAD CCB ADDR!\n", aha->sc_dev.dv_xname);
- continue;
- }
- found++;
- switch (wmbi->stat) {
- case AHA_MBI_OK:
- case AHA_MBI_ERROR:
- break;
-
- case AHA_MBI_ABORT:
- ccb->host_stat = AHA_ABORTED;
- break;
-
- case AHA_MBI_UNKNOWN:
- ccb = 0;
- break;
-
- default:
- panic("Impossible mbxi status");
- }
-#ifdef AHADEBUG
- if (aha_debug && ccb) {
- u_char *cp = &ccb->scsi_cmd;
- printf("op=%x %x %x %x %x %x\n",
- cp[0], cp[1], cp[2],
- cp[3], cp[4], cp[5]);
- printf("stat %x for mbi addr = 0x%08x, ",
- wmbi->stat, wmbi);
- printf("ccb addr = 0x%x\n", ccb);
- }
-#endif /* AHADEBUG */
- wmbi->stat = AHA_MBI_FREE;
- if (ccb) {
- untimeout(aha_timeout, ccb);
- aha_done(aha, ccb);
- }
- aha_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
- for (i = 0; i < AHA_MBX_SIZE; i++) {
- if (wmbi->stat != AHA_MBI_FREE) {
- found++;
- break;
- }
- aha_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
-#if 0
- printf("%s: mbi interrupt with no full mailboxes\n",
- aha->sc_dev.dv_xname);
-#endif
- } else {
- found = 0;
- goto AGAIN;
- }
- }
- wmbx->tmbi = wmbi;
- outb(AHA_CTRL_STAT_PORT, AHA_IRST);
- return 1;
-}
-
-/*
- * A ccb (and hence a mbx-out is put onto the
- * free list.
- */
-void
-aha_free_ccb(aha, ccb, flags)
- struct aha_softc *aha;
- struct aha_ccb *ccb;
- int flags;
-{
- int s, hashnum;
- struct aha_ccb **hashccb;
-
- s = splbio();
-
- if (ccb->ccb_phys[0].addr)
- isadma_unmap((caddr_t)ccb, CCB_PHYS_SIZE, 1, ccb->ccb_phys);
-
- /* remove from hash table */
-
- hashnum = CCB_HASH(ccb->ccb_phys[0].addr);
- hashccb = &aha->ccbhash[hashnum];
-
- while (*hashccb) {
- if ((*hashccb)->ccb_phys[0].addr == ccb->ccb_phys[0].addr) {
- *hashccb = (*hashccb)->nexthash;
- break;
- }
- hashccb = &(*hashccb)->nexthash;
- }
-
- ccb->flags = CCB_FREE;
- TAILQ_INSERT_HEAD(&aha->free_ccb, ccb, chain);
-
- /*
- * If there were none, wake anybody waiting for one to come free,
- * starting with queued entries.
- */
- if (ccb->chain.tqe_next == 0)
- wakeup(&aha->free_ccb);
-
- splx(s);
-}
-
-static inline void
-aha_init_ccb(aha, ccb)
- struct aha_softc *aha;
- struct aha_ccb *ccb;
-{
- bzero(ccb, sizeof(struct aha_ccb));
-}
-
-static inline void
-aha_reset_ccb(aha, ccb)
- struct aha_softc *aha;
- struct aha_ccb *ccb;
-{
-
-}
-
-/*
- * Get a free ccb
- */
-struct aha_ccb *
-aha_get_ccb(aha, flags)
- struct aha_softc *aha;
- int flags;
-{
- struct aha_ccb *ccb;
- int hashnum, mflags, s;
-
- s = splbio();
-
- if (flags & SCSI_NOSLEEP)
- mflags = ISADMA_MAP_BOUNCE;
- else
- mflags = ISADMA_MAP_BOUNCE | ISADMA_MAP_WAITOK;
-
- /*
- * If we can and have to, sleep waiting for one
- * to come free
- */
- for (;;) {
- ccb = aha->free_ccb.tqh_first;
- if (ccb) {
- TAILQ_REMOVE(&aha->free_ccb, ccb, chain);
- break;
- }
- if (aha->numccbs < AHA_CCB_MAX) {
- if (ccb = (struct aha_ccb *) malloc(sizeof(struct aha_ccb),
- M_TEMP, M_NOWAIT)) {
- aha_init_ccb(aha, ccb);
- aha->numccbs++;
- } else {
- printf("%s: can't malloc ccb\n",
- aha->sc_dev.dv_xname);
- goto out;
- }
- break;
- }
- if ((flags & SCSI_NOSLEEP) != 0)
- goto out;
- tsleep(&aha->free_ccb, PRIBIO, "ahaccb", 0);
- }
-
- aha_reset_ccb(aha, ccb);
- ccb->flags = CCB_ACTIVE;
-
- if (isadma_map((caddr_t)ccb, CCB_PHYS_SIZE, ccb->ccb_phys,
- mflags | ISADMA_MAP_CONTIG) == 1) {
- hashnum = CCB_HASH(ccb->ccb_phys[0].addr);
- ccb->nexthash = aha->ccbhash[hashnum];
- aha->ccbhash[hashnum] = ccb;
- } else {
- ccb->ccb_phys[0].addr = 0;
- aha_free_ccb(aha, ccb, flags);
- ccb = 0;
- }
-
-out:
- splx(s);
- return (ccb);
-}
-
-/*
- * given a physical address, find the ccb that it corresponds to.
- */
-struct aha_ccb *
-aha_ccb_phys_kv(aha, ccb_phys)
- struct aha_softc *aha;
- u_long ccb_phys;
-{
- int hashnum = CCB_HASH(ccb_phys);
- struct aha_ccb *res = aha->ccbhash[hashnum];
-
- while (res) {
- if (res->ccb_phys[0].addr == ccb_phys)
- break;
- res = res->nexthash;
- }
-
- return res;
-}
-
-/*
- * Get a mbo and send the ccb.
- */
-struct aha_mbx_out *
-aha_send_mbo(aha, cmd, ccb)
- struct aha_softc *aha;
- int cmd;
- struct aha_ccb *ccb;
-{
- struct aha_mbx_out *wmbo; /* Mail Box Out pointer */
- struct aha_mbx *wmbx; /* Mail Box pointer specified unit */
- int i;
-
- /* Get the target out mail box pointer and increment. */
- wmbx = &aha->aha_mbx;
- wmbo = wmbx->tmbo;
- aha_nextmbx(wmbx->tmbo, wmbx, mbo);
-
- /*
- * Check the outmail box is free or not.
- * Note: Under the normal operation, it shuld NOT happen to wait.
- */
- while (wmbo->cmd != AHA_MBO_FREE) {
- /* Enable mbo available interrupt. */
- outb(AHA_CMD_DATA_PORT, AHA_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(AHA_CTRL_STAT_PORT) & AHA_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: aha_send_mbo, cmd/data port full\n",
- aha->sc_dev.dv_xname);
- outb(AHA_CTRL_STAT_PORT, AHA_SRST);
- return NULL;
- }
- outb(AHA_CMD_DATA_PORT, 0x01); /* Enable */
- tsleep(wmbx, PRIBIO, "ahasnd", 0);/*XXX can't do this */
- }
-
- /* Link ccb to mbo. */
- lto3b(ccb->ccb_phys[0].addr, wmbo->ccb_addr);
- ccb->mbx = wmbo;
- wmbo->cmd = cmd;
-
- /* Sent it! */
- outb(AHA_CMD_DATA_PORT, AHA_START_SCSI);
-
- return wmbo;
-}
-
-/*
- * We have a ccb which has been processed by the
- * adaptor, now we look to see how the operation
- * went. Wake up the owner if waiting
- */
-void
-aha_done(aha, ccb)
- struct aha_softc *aha;
- struct aha_ccb *ccb;
-{
- struct scsi_sense_data *s1, *s2;
- struct scsi_xfer *xs = ccb->xs;
-
- SC_DEBUG(xs->sc_link, SDEV_DB2, ("aha_done\n"));
- /*
- * Otherwise, put the results of the operation
- * into the xfer and call whoever started it
- */
- if ((xs->flags & INUSE) == 0) {
- printf("%s: exiting but not in use!\n", aha->sc_dev.dv_xname);
- Debugger();
- }
- if (xs->error == XS_NOERROR) {
- if (ccb->host_stat != AHA_OK) {
- switch (ccb->host_stat) {
- case AHA_ABORTED:
- xs->error = XS_DRIVER_STUFFUP;
- break;
- case AHA_SEL_TIMEOUT: /* No response */
- xs->error = XS_SELTIMEOUT;
- break;
- default: /* Other scsi protocol messes */
- printf("%s: host_stat %x\n",
- aha->sc_dev.dv_xname, ccb->host_stat);
- xs->error = XS_DRIVER_STUFFUP;
- }
- } else if (ccb->target_stat != SCSI_OK) {
- switch (ccb->target_stat) {
- case SCSI_CHECK:
- s1 = (struct scsi_sense_data *) (((char *) (&ccb->scsi_cmd)) +
- ccb->scsi_cmd_length);
- s2 = &xs->sense;
- *s2 = *s1;
- xs->error = XS_SENSE;
- break;
- case SCSI_BUSY:
- xs->error = XS_BUSY;
- break;
- default:
- printf("%s: target_stat %x\n",
- aha->sc_dev.dv_xname, ccb->target_stat);
- xs->error = XS_DRIVER_STUFFUP;
- }
- } else
- xs->resid = 0;
- }
- xs->flags |= ITSDONE;
-
- if (VOLATILE_XS(xs)) {
- wakeup(ccb);
- return;
- }
-
- if (ccb->data_nseg) {
- if (xs->flags & SCSI_DATA_IN)
- isadma_copyfrombuf(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- isadma_unmap(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- }
- aha_free_ccb(aha, ccb, xs->flags);
- scsi_done(xs);
-}
-
-/*
- * Find the board and find its irq/drq
- */
-int
-aha_find(aha)
- struct aha_softc *aha;
-{
- volatile int i, sts;
- struct aha_config conf;
- struct aha_inquire inquire;
- struct aha_extbios extbios;
-
- /*
- * reset board, If it doesn't respond, assume
- * that it's not there.. good for the probe
- */
-
- outb(AHA_CTRL_STAT_PORT, AHA_HRST | AHA_SRST);
-
- for (i = AHA_RESET_TIMEOUT; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts == (AHA_IDLE | AHA_INIT))
- break;
- delay(1000); /* calibrated in msec */
- }
- if (!i) {
-#ifdef AHADEBUG
- if (aha_debug)
- printf("aha_find: No answer from adaptec board\n");
-#endif /*AHADEBUG */
- return ENXIO;
- }
-
- /*
- * Assume we have a board at this stage, do an adapter inquire
- * to find out what type of controller it is. If the command
- * fails, we assume it's either a crusty board or an old 1542
- * clone, and skip the board-specific stuff.
- */
- if (aha_cmd(aha, 0, sizeof(inquire), 1, &inquire, AHA_INQUIRE)) {
- /*
- * aha_cmd() already started the reset. It's not clear we
- * even need to bother here.
- */
- for (i = AHA_RESET_TIMEOUT; i; i--) {
- sts = inb(AHA_CTRL_STAT_PORT);
- if (sts == (AHA_IDLE | AHA_INIT))
- break;
- delay(1000);
- }
- if (!i) {
-#ifdef AHADEBUG
- printf("aha_init: soft reset failed\n");
-#endif /* AHADEBUG */
- return ENXIO;
- }
-#ifdef AHADEBUG
- printf("aha_init: inquire command failed\n");
-#endif /* AHADEBUG */
- goto noinquire;
- }
-#ifdef AHADEBUG
- printf("%s: inquire %x, %x, %x, %x\n",
- aha->sc_dev.dv_xname,
- inquire.boardid, inquire.spec_opts,
- inquire.revision_1, inquire.revision_2);
-#endif /* AHADEBUG */
- /*
- * If we are a 1542C or 1542CF disable the extended bios so that the
- * mailbox interface is unlocked.
- * No need to check the extended bios flags as some of the
- * extensions that cause us problems are not flagged in that byte.
- */
- if (inquire.boardid == 0x43 || inquire.boardid == 0x44 ||
- inquire.boardid == 0x45) {
- aha_cmd(aha, 0, sizeof(extbios), 0, &extbios, AHA_EXT_BIOS);
-#ifdef AHADEBUG
- printf("%s: extended bios flags %x\n", aha->sc_dev.dv_xname,
- extbios.flags);
-#endif /* AHADEBUG */
- printf("%s: 1542C/CF detected, unlocking mailbox\n",
- aha->sc_dev.dv_xname);
- aha_cmd(aha, 2, 0, 0, 0, AHA_MBX_ENABLE,
- 0, extbios.mailboxlock);
- }
-noinquire:
-
- /*
- * setup dma channel from jumpers and save int
- * level
- */
- delay(1000); /* for Bustek 545 */
- aha_cmd(aha, 0, sizeof(conf), 0, &conf, AHA_CONF_GET);
- switch (conf.chan) {
- case CHAN0:
- aha->sc_drq = 0;
- break;
- case CHAN5:
- aha->sc_drq = 5;
- break;
- case CHAN6:
- aha->sc_drq = 6;
- break;
- case CHAN7:
- aha->sc_drq = 7;
- break;
- default:
- printf("%s: illegal drq setting %x\n", aha->sc_dev.dv_xname,
- conf.chan);
- return EIO;
- }
-
- switch (conf.intr) {
- case INT9:
- aha->sc_irq = 9;
- break;
- case INT10:
- aha->sc_irq = 10;
- break;
- case INT11:
- aha->sc_irq = 11;
- break;
- case INT12:
- aha->sc_irq = 12;
- break;
- case INT14:
- aha->sc_irq = 14;
- break;
- case INT15:
- aha->sc_irq = 15;
- break;
- default:
- printf("%s: illegal irq setting %x\n", aha->sc_dev.dv_xname,
- conf.intr);
- return EIO;
- }
-
- /* who are we on the scsi bus? */
- aha->aha_scsi_dev = conf.scsi_dev;
-
- /*
- * Change the bus on/off times to not clash with other dma users.
- */
- aha_cmd(aha, 1, 0, 0, 0, AHA_BUS_ON_TIME_SET, 7);
- aha_cmd(aha, 1, 0, 0, 0, AHA_BUS_OFF_TIME_SET, 4);
-
- return 0;
-}
-
-/*
- * Start the board, ready for normal operation
- */
-void
-aha_init(aha)
- struct aha_softc *aha;
-{
- u_char ad[3];
- struct isadma_seg mbx_phys[1];
- int i;
-
-#ifdef TUNE_1542
- /*
- * Initialize memory transfer speed
- * Not compiled in by default because it breaks some machines
- */
- if (!aha_set_bus_speed(aha))
- panic("aha_init: cannot set bus speed");
-#endif /* TUNE_1542 */
-
- /*
- * Initialize mail box. This mapping will never be undone.
- */
- if (isadma_map((caddr_t)(&aha->aha_mbx), sizeof(struct aha_mbx),
- mbx_phys, ISADMA_MAP_CONTIG) != 1)
- panic("aha_init: cannot map mail box");
- lto3b(mbx_phys[0].addr, ad);
-
- aha_cmd(aha, 4, 0, 0, 0, AHA_MBX_INIT, AHA_MBX_SIZE,
- ad[0], ad[1], ad[2]);
-
- for (i = 0; i < AHA_MBX_SIZE; i++) {
- aha->aha_mbx.mbo[i].cmd = AHA_MBO_FREE;
- aha->aha_mbx.mbi[i].stat = AHA_MBO_FREE;
- }
-
- /*
- * Set up initial mail box for round-robin operation.
- */
- aha->aha_mbx.tmbo = &aha->aha_mbx.mbo[0];
- aha->aha_mbx.tmbi = &aha->aha_mbx.mbi[0];
-}
-
-void
-ahaminphys(bp)
- struct buf *bp;
-{
-
- if (bp->b_bcount > ((AHA_NSEG - 1) << PGSHIFT))
- bp->b_bcount = ((AHA_NSEG - 1) << PGSHIFT);
- minphys(bp);
-}
-
-/*
- * start a scsi operation given the command and the data address. Also needs
- * the unit, target and lu.
- */
-int
-aha_scsi_cmd(xs)
- struct scsi_xfer *xs;
-{
- struct scsi_link *sc_link = xs->sc_link;
- struct aha_softc *aha = sc_link->adapter_softc;
- struct aha_ccb *ccb;
- struct aha_scat_gath *sg;
- int seg, datalen, flags, mflags;
- struct iovec *iovp;
- struct aha_mbx_out *mbo;
- int s;
-
- SC_DEBUG(sc_link, SDEV_DB2, ("aha_scsi_cmd\n"));
- /*
- * get a ccb to use. If the transfer
- * is from a buf (possibly from interrupt time)
- * then we can't allow it to sleep
- */
- flags = xs->flags;
- if (flags & SCSI_NOSLEEP)
- mflags = ISADMA_MAP_BOUNCE;
- else
- mflags = ISADMA_MAP_BOUNCE | ISADMA_MAP_WAITOK;
- if ((flags & (ITSDONE|INUSE)) != INUSE) {
- printf("%s: done or not in use?\n", aha->sc_dev.dv_xname);
- xs->flags &= ~ITSDONE;
- xs->flags |= INUSE;
- }
- if ((ccb = aha_get_ccb(aha, flags)) == NULL) {
- xs->error = XS_DRIVER_STUFFUP;
- return TRY_AGAIN_LATER;
- }
- ccb->xs = xs;
-
- /*
- * Put all the arguments for the xfer in the ccb
- */
- if (flags & SCSI_RESET) {
- ccb->opcode = AHA_RESET_CCB;
- } else {
- /* can't use S/G if zero length */
- ccb->opcode = (xs->datalen ? AHA_INIT_SCAT_GATH_CCB
- : AHA_INITIATOR_CCB);
- }
- ccb->data_out = 0;
- ccb->data_in = 0;
- ccb->target = sc_link->target;
- ccb->lun = sc_link->lun;
- ccb->scsi_cmd_length = xs->cmdlen;
- ccb->req_sense_length = sizeof(ccb->scsi_sense);
- ccb->host_stat = 0x00;
- ccb->target_stat = 0x00;
- ccb->data_nseg = 0;
-
- if (xs->datalen && (flags & SCSI_RESET) == 0) {
- sg = ((struct aha_ccb *)(ccb->ccb_phys[0].addr))->scat_gath;
- lto3b((vm_offset_t)sg, ccb->data_addr);
- sg = ccb->scat_gath;
- seg = 0;
-#ifdef TFS
- if (flags & SCSI_DATA_UIO) {
- iovp = ((struct uio *)xs->data)->uio_iov;
- datalen = ((struct uio *)xs->data)->uio_iovcnt;
- xs->datalen = 0;
- while (datalen && seg < AHA_NSEG) {
- lto3b(iovp->iov_base, sg->seg_addr);
- lto3b(iovp->iov_len, sg->seg_len);
- xs->datalen += iovp->iov_len;
- SC_DEBUGN(sc_link, SDEV_DB4, ("UIO(0x%x@0x%x)",
- iovp->iov_len, iovp->iov_base));
- sg++;
- iovp++;
- seg++;
- datalen--;
- }
- } else
-#endif /*TFS_ONLY */
- {
- /*
- * Set up the scatter gather block
- */
-
- ccb->data_nseg = isadma_map(xs->data, xs->datalen,
- ccb->data_phys, mflags);
- for (seg = 0; seg < ccb->data_nseg; seg++) {
- lto3b(ccb->data_phys[seg].addr,
- sg[seg].seg_addr);
- lto3b(ccb->data_phys[seg].length,
- sg[seg].seg_len);
- }
- }
- lto3b(ccb->data_nseg * sizeof(struct aha_scat_gath), ccb->data_length);
- if (ccb->data_nseg == 0) {
- printf("%s: aha_scsi_cmd, cannot map\n",
- aha->sc_dev.dv_xname);
- xs->error = XS_DRIVER_STUFFUP;
- aha_free_ccb(aha, ccb, flags);
- return COMPLETE;
- } else if (flags & SCSI_DATA_OUT)
- isadma_copytobuf(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- } else { /* No data xfer, use non S/G values */
- lto3b(0, ccb->data_addr);
- lto3b(0, ccb->data_length);
- }
- ccb->link_id = 0;
- lto3b(0, ccb->link_addr);
-
- /*
- * Put the scsi command in the ccb and start it
- */
- if ((flags & SCSI_RESET) == 0)
- bcopy(xs->cmd, &ccb->scsi_cmd, ccb->scsi_cmd_length);
-
- s = splbio();
-
- isadma_copytobuf((caddr_t)ccb, CCB_PHYS_SIZE, 1, ccb->ccb_phys);
-
- if (aha_send_mbo(aha, AHA_MBO_START, ccb) == NULL) {
- splx(s);
- xs->error = XS_DRIVER_STUFFUP;
- if (ccb->data_nseg)
- isadma_unmap(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- aha_free_ccb(aha, ccb, flags);
- return TRY_AGAIN_LATER;
- }
-
- /*
- * Usually return SUCCESSFULLY QUEUED
- */
- SC_DEBUG(sc_link, SDEV_DB3, ("cmd_sent\n"));
-
- if (VOLATILE_XS(xs)) {
- timeout(aha_timeout, ccb, (xs->timeout * hz) / 1000);
- while ((ccb->xs->flags & ITSDONE) == 0) {
- tsleep(ccb, PRIBIO, "ahawait", 0);
- }
- splx(s);
- if (ccb->data_nseg) {
- if (flags & SCSI_DATA_IN)
- isadma_copyfrombuf(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- isadma_unmap(xs->data, xs->datalen,
- ccb->data_nseg, ccb->data_phys);
- }
- aha_free_ccb(aha, ccb, xs->flags);
- scsi_done(xs);
- return COMPLETE;
- }
-
- if ((flags & SCSI_POLL) == 0) {
- timeout(aha_timeout, ccb, (xs->timeout * hz) / 1000);
- splx(s);
- return SUCCESSFULLY_QUEUED;
- }
-
- splx(s);
-
- /*
- * If we can't use interrupts, poll on completion
- */
- if (aha_poll(aha, xs, xs->timeout)) {
- aha_timeout(ccb);
- if (aha_poll(aha, xs, 2000))
- aha_timeout(ccb);
- }
- return COMPLETE;
-}
-
-/*
- * Poll a particular unit, looking for a particular xs
- */
-int
-aha_poll(aha, xs, count)
- struct aha_softc *aha;
- struct scsi_xfer *xs;
- int count;
-{
-
- /* timeouts are in msec, so we loop in 1000 usec cycles */
- while (count) {
- /*
- * If we had interrupts enabled, would we
- * have got an interrupt?
- */
- if (inb(AHA_INTR_PORT) & AHA_ANY_INTR)
- ahaintr(aha);
- if (xs->flags & ITSDONE)
- return 0;
- delay(1000); /* only happens in boot so ok */
- count--;
- }
- return 1;
-}
-
-#ifdef TUNE_1542
-/*
- * Try all the speeds from slowest to fastest.. if it finds a
- * speed that fails, back off one notch from the last working
- * speed (unless there is no other notch).
- * Returns the nSEC value of the time used
- * or 0 if it could get a working speed (or the NEXT speed
- * failed)
- */
-static struct bus_speed {
- u_char arg;
- int nsecs;
-} aha_bus_speeds[] = {
- {0x88, 100},
- {0x99, 150},
- {0xaa, 200},
- {0xbb, 250},
- {0xcc, 300},
- {0xdd, 350},
- {0xee, 400},
- {0xff, 450}
-};
-
-int
-aha_set_bus_speed(aha)
- struct aha_softc *aha;
-{
- int speed;
- int lastworking;
-
- lastworking = -1;
- for (speed = 7; speed >= 0; speed--) {
- if (!aha_bus_speed_check(aha, speed))
- break;
- lastworking = speed;
- }
- if (lastworking == -1) {
- printf(" no working bus speed");
- return 0;
- }
- printf(", %d nsec ", aha_bus_speeds[lastworking].nsecs);
- if (lastworking == 7) /* is slowest already */
- printf("marginal");
- else {
- lastworking++;
- printf("ok, using %d nsec", aha_bus_speeds[lastworking].nsecs);
- }
- if (!aha_bus_speed_check(aha, lastworking)) {
- printf("test retry failed.. aborting.");
- return 0;
- }
- return 1;
-}
-
-/*
- * Set the DMA speed to the Nth speed and try an xfer. If it
- * fails return 0, if it succeeds return the nSec value selected
- * If there is no such speed return COMPLETE.
- */
-char aha_scratch_buf[256];
-char aha_test_string[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@";
-
-int
-aha_bus_speed_check(aha, speed)
- struct aha_softc *aha;
- int speed;
-{
- int numspeeds = sizeof(aha_bus_speeds) / sizeof(struct bus_speed);
- int result, loopcount;
- struct isadma_seg test_phys[1], scratch_phys[1];
- u_char ad[3];
-
- result = 1;
-
- if (isadma_map(aha_scratch_buf, sizeof(aha_scratch_buf),
- scratch_phys, ISADMA_MAP_CONTIG) != 1)
- return 0;
- if (isadma_map(aha_test_string, sizeof(aha_test_string),
- test_phys, ISADMA_MAP_CONTIG) != 1) {
- isadma_unmap(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
- return 0;
- }
- isadma_copytobuf(aha_test_string, sizeof(aha_test_string),
- 1, test_phys);
-
- /*
- * Set the dma-speed
- */
- aha_cmd(aha, 1, 0, 0, 0, AHA_SPEED_SET, aha_bus_speeds[speed].arg);
-
- /*
- * put the test data into the buffer and calculate
- * it's address. Read it onto the board
- */
- for (loopcount = 100; loopcount; loopcount--) {
- lto3b(test_phys[0].addr, ad);
- aha_cmd(aha, 3, 0, 0, 0, AHA_WRITE_FIFO, ad[0], ad[1], ad[2]);
-
- /*
- * Clear the buffer then copy the contents back from the
- * board.
- */
- bzero(aha_scratch_buf, 54);
- isadma_copytobuf(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
-
- lto3b(scratch_phys[0].addr, ad);
- aha_cmd(aha, 3, 0, 0, 0, AHA_READ_FIFO, ad[0], ad[1], ad[2]);
- isadma_copyfrombuf(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
-
- /*
- * Compare the original data and the final data and return the
- * correct value depending upon the result. We only check the
- * first 54 bytes, because that's all the board copies during
- * WRITE_FIFO and READ_FIFO.
- */
- if (bcmp(aha_test_string, aha_scratch_buf, 54)) {
- result = 0; /* failed test */
- break;
- }
- }
-
- isadma_unmap(aha_scratch_buf, sizeof(aha_scratch_buf),
- 1, scratch_phys);
- isadma_unmap(aha_test_string, sizeof(aha_test_string),
- 1, test_phys);
-
- /* copy succeeded; assume speed ok */
- return result;
-}
-#endif /* TUNE_1542 */
-
-void
-aha_timeout(arg)
- void *arg;
-{
- struct aha_ccb *ccb = arg;
- struct scsi_xfer *xs = ccb->xs;
- struct scsi_link *sc_link = xs->sc_link;
- struct aha_softc *aha = sc_link->adapter_softc;
- int s;
-
- sc_print_addr(sc_link);
- printf("timed out");
-
- s = splbio();
-
- /*
- * If The ccb's mbx is not free, then the board has gone south?
- */
- if (aha_ccb_phys_kv(aha, _3btol(ccb->mbx->ccb_addr)) == ccb &&
- ccb->mbx->cmd != AHA_MBO_FREE) {
- printf("%s: not taking commands!\n", aha->sc_dev.dv_xname);
- Debugger();
- }
-
- /*
- * If it has been through before, then
- * a previous abort has failed, don't
- * try abort again
- */
- if (ccb->flags == CCB_ABORTED) {
- /* abort timed out */
- printf(" AGAIN\n");
- ccb->xs->retries = 0;
- aha_done(aha, ccb);
- } else {
- /* abort the operation that has timed out */
- printf("\n");
- ccb->xs->error = XS_TIMEOUT;
- ccb->flags = CCB_ABORTED;
- aha_send_mbo(aha, AHA_MBO_ABORT, ccb);
- /* 2 secs for the abort */
- if ((xs->flags & SCSI_POLL) == 0)
- timeout(aha_timeout, ccb, 2 * hz);
- }
-
- splx(s);
-}
-/* $NetBSD: aha284x.c,v 1.2 1996/01/13 02:06:30 thorpej Exp $ */
+/* $NetBSD: aha284x.c,v 1.4 1996/04/11 22:28:04 cgd Exp $ */
/*
* Copyright (c) 1996 Michael Graff. All rights reserved.
static int ahe_probe __P((struct device *, void *, void *));
static void ahe_attach __P((struct device *, struct device *, void *));
-struct cfdriver ahecd = {
- NULL, /* devices found */
- "ahe", /* device name */
- ahe_probe, /* match routine */
- ahe_attach, /* attach routine */
- DV_DULL, /* device class */
- sizeof(struct ahc_softc), /* size of private dev data */
+struct cfattach ahe_ca = {
+ sizeof(struct ahc_softc), ahe_probe, ahe_attach
+};
+
+struct cfdriver ahe_cd = {
+ NULL, "ahe", DV_DULL
};
/*
#ifdef NEWCONFIG
isa_establish(&ahc->sc_id, &ahc->sc_dev);
#endif
- ahc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO,
- ahcintr, ahc, ahc->sc_dev.dv_xname);
+ ahc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, ahcintr, ahc, ahc->sc_dev.dv_xname);
/*
* attach the devices on the bus
--- /dev/null
+typedef u_int8_t physaddr[3];
+typedef u_int8_t physlen[3];
+#define ltophys _lto3b
+#define phystol _3btol
+
+/*
+ * I/O port offsets
+ */
+#define AHA_CTRL_PORT 0 /* control (wo) */
+#define AHA_STAT_PORT 0 /* status (ro) */
+#define AHA_CMD_PORT 1 /* command (wo) */
+#define AHA_DATA_PORT 1 /* data (ro) */
+#define AHA_INTR_PORT 2 /* interrupt status (ro) */
+
+/*
+ * AHA_CTRL bits
+ */
+#define AHA_CTRL_HRST 0x80 /* Hardware reset */
+#define AHA_CTRL_SRST 0x40 /* Software reset */
+#define AHA_CTRL_IRST 0x20 /* Interrupt reset */
+#define AHA_CTRL_SCRST 0x10 /* SCSI bus reset */
+
+/*
+ * AHA_STAT bits
+ */
+#define AHA_STAT_STST 0x80 /* Self test in Progress */
+#define AHA_STAT_DIAGF 0x40 /* Diagnostic Failure */
+#define AHA_STAT_INIT 0x20 /* Mbx Init required */
+#define AHA_STAT_IDLE 0x10 /* Host Adapter Idle */
+#define AHA_STAT_CDF 0x08 /* cmd/data out port full */
+#define AHA_STAT_DF 0x04 /* Data in port full */
+#define AHA_STAT_INVDCMD 0x01 /* Invalid command */
+
+/*
+ * AHA_CMD opcodes
+ */
+#define AHA_NOP 0x00 /* No operation */
+#define AHA_MBX_INIT 0x01 /* Mbx initialization */
+#define AHA_START_SCSI 0x02 /* start scsi command */
+#define AHA_INQUIRE_REVISION 0x04 /* Adapter Inquiry */
+#define AHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
+/*#define AHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
+/*#define AHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */
+/*#define AHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
+/*#define AHA_SPEED_SET 0x09 /* set transfer speed */
+#define AHA_INQUIRE_DEVICES 0x0a /* return installed devices 0-7 */
+#define AHA_INQUIRE_CONFIG 0x0b /* return configuration data */
+#define AHA_TARGET_EN 0x0c /* enable target mode */
+#define AHA_INQUIRE_SETUP 0x0d /* return setup data */
+#define AHA_ECHO 0x1e /* Echo command data */
+#define AHA_INQUIRE_DEVICES_2 0x23 /* return installed devices 8-15 */
+#define AHA_EXT_BIOS 0x28 /* return extended bios info */
+#define AHA_MBX_ENABLE 0x29 /* enable mail box interface */
+
+/*
+ * AHA_INTR bits
+ */
+#define AHA_INTR_ANYINTR 0x80 /* Any interrupt */
+#define AHA_INTR_SCRD 0x08 /* SCSI reset detected */
+#define AHA_INTR_HACC 0x04 /* Command complete */
+#define AHA_INTR_MBOA 0x02 /* MBX out empty */
+#define AHA_INTR_MBIF 0x01 /* MBX in full */
+
+struct aha_mbx_out {
+ u_char cmd;
+ physaddr ccb_addr;
+};
+
+struct aha_mbx_in {
+ u_char stat;
+ physaddr ccb_addr;
+};
+
+/*
+ * mbo.cmd values
+ */
+#define AHA_MBO_FREE 0x0 /* MBO entry is free */
+#define AHA_MBO_START 0x1 /* MBO activate entry */
+#define AHA_MBO_ABORT 0x2 /* MBO abort entry */
+
+/*
+ * mbi.stat values
+ */
+#define AHA_MBI_FREE 0x0 /* MBI entry is free */
+#define AHA_MBI_OK 0x1 /* completed without error */
+#define AHA_MBI_ABORT 0x2 /* aborted ccb */
+#define AHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
+#define AHA_MBI_ERROR 0x4 /* Completed with error */
+
+/* FOR OLD VERSIONS OF THE !%$@ this may have to be 16 (yuk) */
+#define AHA_NSEG 17 /* Number of scatter gather segments <= 16 */
+ /* allow 64 K i/o (min) */
+
+struct aha_scat_gath {
+ physlen seg_len;
+ physaddr seg_addr;
+};
+
+struct aha_ccb {
+ u_char opcode;
+ u_char lun:3;
+ u_char data_in:1; /* must be 0 */
+ u_char data_out:1; /* must be 0 */
+ u_char target:3;
+ u_char scsi_cmd_length;
+ u_char req_sense_length;
+ physlen data_length;
+ physaddr data_addr;
+ physaddr link_addr;
+ u_char link_id;
+ u_char host_stat;
+ u_char target_stat;
+ u_char reserved[2];
+ struct scsi_generic scsi_cmd;
+ struct scsi_sense_data scsi_sense;
+ struct aha_scat_gath scat_gath[AHA_NSEG];
+ /*----------------------------------------------------------------*/
+ TAILQ_ENTRY(aha_ccb) chain;
+ struct aha_ccb *nexthash;
+ long hashkey;
+ struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
+ int flags;
+#define CCB_ALLOC 0x01
+#define CCB_ABORT 0x02
+#ifdef AHADIAG
+#define CCB_SENDING 0x04
+#endif
+ int timeout;
+};
+
+/*
+ * opcode fields
+ */
+#define AHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
+#define AHA_TARGET_CCB 0x01 /* SCSI Target CCB */
+#define AHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scatter gather */
+#define AHA_RESET_CCB 0x81 /* SCSI Bus reset */
+
+/*
+ * aha_ccb.host_stat values
+ */
+#define AHA_OK 0x00 /* cmd ok */
+#define AHA_LINK_OK 0x0a /* Link cmd ok */
+#define AHA_LINK_IT 0x0b /* Link cmd ok + int */
+#define AHA_SEL_TIMEOUT 0x11 /* Selection time out */
+#define AHA_OVER_UNDER 0x12 /* Data over/under run */
+#define AHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */
+#define AHA_INV_BUS 0x14 /* Invalid bus phase/sequence */
+#define AHA_BAD_MBO 0x15 /* Incorrect MBO cmd */
+#define AHA_BAD_CCB 0x16 /* Incorrect ccb opcode */
+#define AHA_BAD_LINK 0x17 /* Not same values of LUN for links */
+#define AHA_INV_TARGET 0x18 /* Invalid target direction */
+#define AHA_CCB_DUP 0x19 /* Duplicate CCB received */
+#define AHA_INV_CCB 0x1a /* Invalid CCB or segment list */
+
+struct aha_revision {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char boardid; /* type of board */
+ /* 0x31 = AHA-1540 */
+ /* 0x41 = AHA-1540A/1542A/1542B */
+ /* 0x42 = AHA-1640 */
+ /* 0x43 = AHA-1542C */
+ /* 0x44 = AHA-1542CF */
+ /* 0x45 = AHA-1542CF, BIOS v2.01 */
+ /* 0x46 = AHA-1542CP */
+ u_char spec_opts; /* special options ID */
+ /* 0x41 = Board is standard model */
+ u_char revision_1; /* firmware revision [0-9A-Z] */
+ u_char revision_2; /* firmware revision [0-9A-Z] */
+ } reply;
+};
+
+struct aha_extbios {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char flags; /* Bit 3 == 1 extended bios enabled */
+ u_char mailboxlock; /* mail box lock code to unlock it */
+ } reply;
+};
+
+struct aha_toggle {
+ struct {
+ u_char opcode;
+ u_char enable;
+ } cmd;
+};
+
+struct aha_config {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char chan;
+ u_char intr;
+ u_char scsi_dev:3;
+ u_char :5;
+ } reply;
+};
+
+struct aha_mailbox {
+ struct {
+ u_char opcode;
+ u_char nmbx;
+ physaddr addr;
+ } cmd;
+};
+
+struct aha_unlock {
+ struct {
+ u_char opcode;
+ u_char junk;
+ u_char magic;
+ } cmd;
+};
+
+struct aha_devices {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char junk[8];
+ } reply;
+};
+
+struct aha_setup {
+ struct {
+ u_char opcode;
+ u_char len;
+ } cmd;
+ struct {
+ u_char sync_neg:1;
+ u_char parity:1;
+ u_char :6;
+ u_char speed;
+ u_char bus_on;
+ u_char bus_off;
+ u_char num_mbx;
+ u_char mbx[3];
+ struct {
+ u_char offset:4;
+ u_char period:3;
+ u_char valid:1;
+ } sync[8];
+ u_char disc_sts;
+ } reply;
+};
+
+#define INT9 0x01
+#define INT10 0x02
+#define INT11 0x04
+#define INT12 0x08
+#define INT14 0x20
+#define INT15 0x40
+
+#define EISADMA 0x00
+#define CHAN0 0x01
+#define CHAN5 0x20
+#define CHAN6 0x40
+#define CHAN7 0x80
-/* $NetBSD: aic6360.c,v 1.36.2.1 1995/10/18 21:40:12 pk Exp $ */
+/* $OpenBSD: aic6360.c,v 1.7 1996/04/21 22:22:39 deraadt Exp $ */
+/* $NetBSD: aic6360.c,v 1.44 1996/04/11 22:28:08 cgd Exp $ */
+
+#define integrate static inline
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
* 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 Charles Hannum.
+ * This product includes software developed by Charles M. Hannum.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*/
#define AIC_DEBUG 1
+#define AIC_ABORT_TIMEOUT 2000 /* time to wait for abort */
+
/* End of customizable parameters */
#if AIC_USE_EISA_DMA || AIC_USE_ISA_DMA
*/
/* AIC6360 definitions */
-#define IOBASE sc->sc_iobase
-#define SCSISEQ (IOBASE + 0x00) /* SCSI sequence control */
-#define SXFRCTL0 (IOBASE + 0x01) /* SCSI transfer control 0 */
-#define SXFRCTL1 (IOBASE + 0x02) /* SCSI transfer control 1 */
-#define SCSISIG (IOBASE + 0x03) /* SCSI signal in/out */
-#define SCSIRATE (IOBASE + 0x04) /* SCSI rate control */
-#define SCSIID (IOBASE + 0x05) /* SCSI ID */
-#define SELID (IOBASE + 0x05) /* Selection/Reselection ID */
-#define SCSIDAT (IOBASE + 0x06) /* SCSI Latched Data */
-#define SCSIBUS (IOBASE + 0x07) /* SCSI Data Bus*/
-#define STCNT0 (IOBASE + 0x08) /* SCSI transfer count */
-#define STCNT1 (IOBASE + 0x09)
-#define STCNT2 (IOBASE + 0x0a)
-#define CLRSINT0 (IOBASE + 0x0b) /* Clear SCSI interrupts 0 */
-#define SSTAT0 (IOBASE + 0x0b) /* SCSI interrupt status 0 */
-#define CLRSINT1 (IOBASE + 0x0c) /* Clear SCSI interrupts 1 */
-#define SSTAT1 (IOBASE + 0x0c) /* SCSI status 1 */
-#define SSTAT2 (IOBASE + 0x0d) /* SCSI status 2 */
-#define SCSITEST (IOBASE + 0x0e) /* SCSI test control */
-#define SSTAT3 (IOBASE + 0x0e) /* SCSI status 3 */
-#define CLRSERR (IOBASE + 0x0f) /* Clear SCSI errors */
-#define SSTAT4 (IOBASE + 0x0f) /* SCSI status 4 */
-#define SIMODE0 (IOBASE + 0x10) /* SCSI interrupt mode 0 */
-#define SIMODE1 (IOBASE + 0x11) /* SCSI interrupt mode 1 */
-#define DMACNTRL0 (IOBASE + 0x12) /* DMA control 0 */
-#define DMACNTRL1 (IOBASE + 0x13) /* DMA control 1 */
-#define DMASTAT (IOBASE + 0x14) /* DMA status */
-#define FIFOSTAT (IOBASE + 0x15) /* FIFO status */
-#define DMADATA (IOBASE + 0x16) /* DMA data */
-#define DMADATAL (IOBASE + 0x16) /* DMA data low byte */
-#define DMADATAH (IOBASE + 0x17) /* DMA data high byte */
-#define BRSTCNTRL (IOBASE + 0x18) /* Burst Control */
-#define DMADATALONG (IOBASE + 0x18)
-#define PORTA (IOBASE + 0x1a) /* Port A */
-#define PORTB (IOBASE + 0x1b) /* Port B */
-#define REV (IOBASE + 0x1c) /* Revision (001 for 6360) */
-#define STACK (IOBASE + 0x1d) /* Stack */
-#define TEST (IOBASE + 0x1e) /* Test register */
-#define ID (IOBASE + 0x1f) /* ID register */
+#define SCSISEQ 0x00 /* SCSI sequence control */
+#define SXFRCTL0 0x01 /* SCSI transfer control 0 */
+#define SXFRCTL1 0x02 /* SCSI transfer control 1 */
+#define SCSISIG 0x03 /* SCSI signal in/out */
+#define SCSIRATE 0x04 /* SCSI rate control */
+#define SCSIID 0x05 /* SCSI ID */
+#define SELID 0x05 /* Selection/Reselection ID */
+#define SCSIDAT 0x06 /* SCSI Latched Data */
+#define SCSIBUS 0x07 /* SCSI Data Bus*/
+#define STCNT0 0x08 /* SCSI transfer count */
+#define STCNT1 0x09
+#define STCNT2 0x0a
+#define CLRSINT0 0x0b /* Clear SCSI interrupts 0 */
+#define SSTAT0 0x0b /* SCSI interrupt status 0 */
+#define CLRSINT1 0x0c /* Clear SCSI interrupts 1 */
+#define SSTAT1 0x0c /* SCSI status 1 */
+#define SSTAT2 0x0d /* SCSI status 2 */
+#define SCSITEST 0x0e /* SCSI test control */
+#define SSTAT3 0x0e /* SCSI status 3 */
+#define CLRSERR 0x0f /* Clear SCSI errors */
+#define SSTAT4 0x0f /* SCSI status 4 */
+#define SIMODE0 0x10 /* SCSI interrupt mode 0 */
+#define SIMODE1 0x11 /* SCSI interrupt mode 1 */
+#define DMACNTRL0 0x12 /* DMA control 0 */
+#define DMACNTRL1 0x13 /* DMA control 1 */
+#define DMASTAT 0x14 /* DMA status */
+#define FIFOSTAT 0x15 /* FIFO status */
+#define DMADATA 0x16 /* DMA data */
+#define DMADATAL 0x16 /* DMA data low byte */
+#define DMADATAH 0x17 /* DMA data high byte */
+#define BRSTCNTRL 0x18 /* Burst Control */
+#define DMADATALONG 0x18
+#define PORTA 0x1a /* Port A */
+#define PORTB 0x1b /* Port B */
+#define REV 0x1c /* Revision (001 for 6360) */
+#define STACK 0x1d /* Stack */
+#define TEST 0x1e /* Test register */
+#define ID 0x1f /* ID register */
#define IDSTRING "(C)1991ADAPTECAIC6360 "
TAILQ_ENTRY(aic_acb) chain;
struct scsi_xfer *xs; /* SCSI xfer ctrl block from above */
int flags;
-#define ACB_FREE 0
-#define ACB_ACTIVE 1
-#define ACB_CHKSENSE 2
-#define ACB_ABORTED 3
+#define ACB_ALLOC 0x01
+#define ACB_NEXUS 0x02
+#define ACB_SENSE 0x04
+#define ACB_ABORT 0x40
+#define ACB_RESET 0x80
+ int timeout;
};
/*
u_char sc_phase; /* Current bus phase */
u_char sc_prevphase; /* Previous bus phase */
u_char sc_state; /* State applicable to the adapter */
-#define AIC_IDLE 0x01
-#define AIC_SELECTING 0x02 /* SCSI command is arbiting */
-#define AIC_RESELECTED 0x04 /* Has been reselected */
-#define AIC_CONNECTED 0x08 /* Actively using the SCSI bus */
-#define AIC_DISCONNECT 0x10 /* MSG_DISCONNECT received */
-#define AIC_CMDCOMPLETE 0x20 /* MSG_CMDCOMPLETE received */
-#define AIC_CLEANING 0x40
+#define AIC_INIT 0
+#define AIC_IDLE 1
+#define AIC_SELECTING 2 /* SCSI command is arbiting */
+#define AIC_RESELECTED 3 /* Has been reselected */
+#define AIC_CONNECTED 4 /* Actively using the SCSI bus */
+#define AIC_DISCONNECT 5 /* MSG_DISCONNECT received */
+#define AIC_CMDCOMPLETE 6 /* MSG_CMDCOMPLETE received */
+#define AIC_CLEANING 7
u_char sc_flags;
#define AIC_DROP_MSGIN 0x01 /* Discard all msgs (parity err detected) */
#define AIC_ABORTING 0x02 /* Bailing out */
u_char sc_currmsg; /* Message currently ready to transmit */
#define SEND_DEV_RESET 0x01
#define SEND_PARITY_ERROR 0x02
-#define SEND_ABORT 0x04
+#define SEND_INIT_DET_ERR 0x04
#define SEND_REJECT 0x08
-#define SEND_INIT_DET_ERR 0x10
-#define SEND_IDENTIFY 0x20
+#define SEND_IDENTIFY 0x10
+#define SEND_ABORT 0x20
#define SEND_SDTR 0x40
#define SEND_WDTR 0x80
#define AIC_MAX_MSG_LEN 8
void aic_dequeue __P((struct aic_softc *, struct aic_acb *));
int aic_scsi_cmd __P((struct scsi_xfer *));
int aic_poll __P((struct aic_softc *, struct scsi_xfer *, int));
+integrate void aic_sched_msgout __P((struct aic_softc *, u_char));
+integrate void aic_setsync __P((struct aic_softc *, struct aic_tinfo *));
void aic_select __P((struct aic_softc *, struct aic_acb *));
void aic_timeout __P((void *));
int aic_find __P((struct aic_softc *));
void aic_dump6360();
#endif
-struct cfdriver aiccd = {
- NULL, "aic", aicprobe, aicattach, DV_DULL, sizeof(struct aic_softc)
+struct cfattach aic_ca = {
+ sizeof(struct aic_softc), aicprobe, aicattach
+};
+
+struct cfdriver aic_cd = {
+ NULL, "aic", DV_DULL
};
struct scsi_adapter aic_switch = {
aic_find(sc)
struct aic_softc *sc;
{
+ int iobase = sc->sc_iobase;
char chip_id[sizeof(IDSTRING)]; /* For chips that support it */
char *start;
int i;
/* Remove aic6360 from possible powerdown mode */
- outb(DMACNTRL0, 0);
+ outb(iobase + DMACNTRL0, 0);
/* Thanks to mark@aggregate.com for the new method for detecting
* whether the chip is present or not. Bonus: may also work for
*/
/* Push the sequence 0,1,..,15 on the stack */
#define STSIZE 16
- outb(DMACNTRL1, 0); /* Reset stack pointer */
+ outb(iobase + DMACNTRL1, 0); /* Reset stack pointer */
for (i = 0; i < STSIZE; i++)
- outb(STACK, i);
+ outb(iobase + STACK, i);
/* See if we can pull out the same sequence */
- outb(DMACNTRL1, 0);
- for (i = 0; i < STSIZE && inb(STACK) == i; i++)
+ outb(iobase + DMACNTRL1, 0);
+ for (i = 0; i < STSIZE && inb(iobase + STACK) == i; i++)
;
if (i != STSIZE) {
AIC_START(("STACK futzed at %d.\n", i));
* now only used for informational purposes.
*/
bzero(chip_id, sizeof(chip_id));
- insb(ID, chip_id, sizeof(IDSTRING)-1);
+ insb(iobase + ID, chip_id, sizeof(IDSTRING)-1);
AIC_START(("AIC found at 0x%x ", sc->sc_iobase));
AIC_START(("ID: %s ",chip_id));
- AIC_START(("chip revision %d\n",(int)inb(REV)));
+ AIC_START(("chip revision %d\n",(int)inb(iobase + REV)));
sc->sc_initiator = 7;
sc->sc_freq = 20; /* XXXX Assume 20 MHz. */
struct aic_softc *sc = (void *)self;
AIC_TRACE(("aicattach "));
- sc->sc_state = 0;
+ sc->sc_state = AIC_INIT;
aic_init(sc); /* Init chip and driver */
/*
#ifdef NEWCONFIG
isa_establish(&sc->sc_id, &sc->sc_dev);
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, aicintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, aicintr, sc, sc->sc_dev.dv_xname);
config_found(self, &sc->sc_link, aicprint);
}
aic_reset(sc)
struct aic_softc *sc;
{
+ int iobase = sc->sc_iobase;
- outb(SCSITEST, 0); /* Doc. recommends to clear these two */
- outb(TEST, 0); /* registers before operations commence */
+ outb(iobase + SCSITEST, 0); /* Doc. recommends to clear these two */
+ outb(iobase + TEST, 0); /* registers before operations commence */
/* Reset SCSI-FIFO and abort any transfers */
- outb(SXFRCTL0, CHEN|CLRCH|CLRSTCNT);
+ outb(iobase + SXFRCTL0, CHEN | CLRCH | CLRSTCNT);
/* Reset DMA-FIFO */
- outb(DMACNTRL0, RSTFIFO);
- outb(DMACNTRL1, 0);
+ outb(iobase + DMACNTRL0, RSTFIFO);
+ outb(iobase + DMACNTRL1, 0);
- outb(SCSISEQ, 0); /* Disable all selection features */
- outb(SXFRCTL1, 0);
+ outb(iobase + SCSISEQ, 0); /* Disable all selection features */
+ outb(iobase + SXFRCTL1, 0);
- outb(SIMODE0, 0x00); /* Disable some interrupts */
- outb(CLRSINT0, 0x7f); /* Clear a slew of interrupts */
+ outb(iobase + SIMODE0, 0x00); /* Disable some interrupts */
+ outb(iobase + CLRSINT0, 0x7f); /* Clear a slew of interrupts */
- outb(SIMODE1, 0x00); /* Disable some more interrupts */
- outb(CLRSINT1, 0xef); /* Clear another slew of interrupts */
+ outb(iobase + SIMODE1, 0x00); /* Disable some more interrupts */
+ outb(iobase + CLRSINT1, 0xef); /* Clear another slew of interrupts */
- outb(SCSIRATE, 0); /* Disable synchronous transfers */
+ outb(iobase + SCSIRATE, 0); /* Disable synchronous transfers */
- outb(CLRSERR, 0x07); /* Haven't seen ant errors (yet) */
+ outb(iobase + CLRSERR, 0x07); /* Haven't seen ant errors (yet) */
- outb(SCSIID, sc->sc_initiator << OID_S); /* Set our SCSI-ID */
- outb(BRSTCNTRL, EISA_BRST_TIM);
+ outb(iobase + SCSIID, sc->sc_initiator << OID_S); /* Set our SCSI-ID */
+ outb(iobase + BRSTCNTRL, EISA_BRST_TIM);
}
/* Pull the SCSI RST line for 500 us */
aic_scsi_reset(sc)
struct aic_softc *sc;
{
+ int iobase = sc->sc_iobase;
- outb(SCSISEQ, SCSIRSTO);
+ outb(iobase + SCSISEQ, SCSIRSTO);
delay(500);
- outb(SCSISEQ, 0);
+ outb(iobase + SCSISEQ, 0);
delay(50);
}
aic_init(sc)
struct aic_softc *sc;
{
+ int iobase = sc->sc_iobase;
struct aic_acb *acb;
int r;
aic_scsi_reset(sc);
aic_reset(sc);
- if (sc->sc_state == 0) {
+ if (sc->sc_state == AIC_INIT) {
/* First time through; initialize. */
TAILQ_INIT(&sc->ready_list);
TAILQ_INIT(&sc->nexus_list);
}
sc->sc_state = AIC_IDLE;
- outb(DMACNTRL0, INTEN);
+ outb(iobase + DMACNTRL0, INTEN);
}
void
s = splbio();
- acb->flags = ACB_FREE;
+ acb->flags = 0;
TAILQ_INSERT_HEAD(&sc->free_list, acb, chain);
/*
tsleep(&sc->free_list, PRIBIO, "aicacb", 0);
if (acb) {
TAILQ_REMOVE(&sc->free_list, acb, chain);
- acb->flags = ACB_ACTIVE;
+ acb->flags |= ACB_ALLOC;
}
splx(s);
sc_link->target));
flags = xs->flags;
- if ((flags & (ITSDONE|INUSE)) != INUSE) {
- printf("%s: done or not in use?\n", sc->sc_dev.dv_xname);
- xs->flags &= ~ITSDONE;
- xs->flags |= INUSE;
- }
-
if ((acb = aic_get_acb(sc, flags)) == NULL) {
xs->error = XS_DRIVER_STUFFUP;
return TRY_AGAIN_LATER;
/* Initialize acb */
acb->xs = xs;
- bcopy(xs->cmd, &acb->scsi_cmd, xs->cmdlen);
- acb->scsi_cmd_length = xs->cmdlen;
- acb->data_addr = xs->data;
- acb->data_length = xs->datalen;
+ acb->timeout = xs->timeout;
+
+ if (xs->flags & SCSI_RESET) {
+ acb->flags |= ACB_RESET;
+ acb->scsi_cmd_length = 0;
+ acb->data_length = 0;
+ } else {
+ bcopy(xs->cmd, &acb->scsi_cmd, xs->cmdlen);
+ acb->scsi_cmd_length = xs->cmdlen;
+ acb->data_addr = xs->data;
+ acb->data_length = xs->datalen;
+ }
acb->target_stat = 0;
s = splbio();
if (sc->sc_state == AIC_IDLE)
aic_sched(sc);
- if ((flags & SCSI_POLL) == 0) { /* Almost done. Wait outside */
- timeout(aic_timeout, acb, (xs->timeout * hz) / 1000);
- splx(s);
- return SUCCESSFULLY_QUEUED;
- }
-
splx(s);
+ if ((flags & SCSI_POLL) == 0)
+ return SUCCESSFULLY_QUEUED;
+
/* Not allowed to use interrupts, use polling instead */
- if (aic_poll(sc, xs, xs->timeout)) {
+ if (aic_poll(sc, xs, acb->timeout)) {
aic_timeout(acb);
- if (aic_poll(sc, xs, 2000))
+ if (aic_poll(sc, xs, acb->timeout))
aic_timeout(acb);
}
return COMPLETE;
struct scsi_xfer *xs;
int count;
{
+ int iobase = sc->sc_iobase;
AIC_TRACE(("aic_poll "));
while (count) {
* If we had interrupts enabled, would we
* have got an interrupt?
*/
- if ((inb(DMASTAT) & INTSTAT) != 0)
+ if ((inb(iobase + DMASTAT) & INTSTAT) != 0)
aicintr(sc);
if ((xs->flags & ITSDONE) != 0)
return 0;
* LOW LEVEL SCSI UTILITIES
*/
-#define aic_sched_msgout(m) \
- do { \
- if (sc->sc_msgpriq == 0) \
- outb(SCSISIG, sc->sc_phase|ATNO); \
- sc->sc_msgpriq |= (m); \
- } while (0)
+integrate void
+aic_sched_msgout(sc, m)
+ struct aic_softc *sc;
+ u_char m;
+{
+ int iobase = sc->sc_iobase;
+
+ if (sc->sc_msgpriq == 0)
+ outb(iobase + SCSISIG, sc->sc_phase | ATNO);
+ sc->sc_msgpriq |= m;
+}
-#if AIC_USE_SYNCHRONOUS
/*
* Set synchronous transfer offset and period.
*/
-static inline void
+integrate void
aic_setsync(sc, ti)
struct aic_softc *sc;
struct aic_tinfo *ti;
{
+#if AIC_USE_SYNCHRONOUS
+ int iobase = sc->sc_iobase;
if (ti->offset != 0)
- outb(SCSIRATE,
+ outb(iobase + SCSIRATE,
((ti->period * sc->sc_freq) / 250 - 2) << 4 | ti->offset);
else
- outb(SCSIRATE, 0);
-}
-#else
-#define aic_setsync(sc, ti)
+ outb(iobase + SCSIRATE, 0);
#endif
+}
/*
* Start a selection. This is used by aic_sched() to select an idle target,
struct scsi_link *sc_link = acb->xs->sc_link;
int target = sc_link->target;
struct aic_tinfo *ti = &sc->sc_tinfo[target];
+ int iobase = sc->sc_iobase;
- outb(SCSIID, sc->sc_initiator << OID_S | target);
+ outb(iobase + SCSIID, sc->sc_initiator << OID_S | target);
aic_setsync(sc, ti);
- outb(SXFRCTL1, STIMO_256ms|ENSTIMER);
+ outb(iobase + SXFRCTL1, STIMO_256ms | ENSTIMER);
/* Always enable reselections. */
- outb(SIMODE0, ENSELDI|ENSELDO);
- outb(SIMODE1, ENSCSIRST|ENSELTIMO);
- outb(SCSISEQ, ENRESELI|ENSELO|ENAUTOATNO);
+ outb(iobase + SIMODE0, ENSELDI | ENSELDO);
+ outb(iobase + SIMODE1, ENSCSIRST | ENSELTIMO);
+ outb(iobase + SCSISEQ, ENRESELI | ENSELO | ENAUTOATNO);
sc->sc_state = AIC_SELECTING;
}
ti->lubusy |= (1 << lun);
aic_setsync(sc, ti);
+ if (acb->flags & ACB_RESET)
+ aic_sched_msgout(sc, SEND_DEV_RESET);
+ else if (acb->flags & ACB_ABORT)
+ aic_sched_msgout(sc, SEND_ABORT);
+
/* Do an implicit RESTORE POINTERS. */
sc->sc_dp = acb->data_addr;
sc->sc_dleft = acb->data_length;
return (0);
reset:
- sc->sc_flags |= AIC_ABORTING;
- aic_sched_msgout(SEND_DEV_RESET);
+ aic_sched_msgout(sc, SEND_DEV_RESET);
return (1);
abort:
- sc->sc_flags |= AIC_ABORTING;
- aic_sched_msgout(SEND_ABORT);
+ aic_sched_msgout(sc, SEND_ABORT);
return (1);
}
\f
struct aic_acb *acb;
struct scsi_link *sc_link;
struct aic_tinfo *ti;
+ int iobase = sc->sc_iobase;
/*
* Find first acb in ready queue that is for a target/lunit pair that
* is not busy.
*/
- outb(CLRSINT1, CLRSELTIMO|CLRBUSFREE|CLRSCSIPERR);
+ outb(iobase + CLRSINT1, CLRSELTIMO | CLRBUSFREE | CLRSCSIPERR);
for (acb = sc->ready_list.tqh_first; acb != NULL;
acb = acb->chain.tqe_next) {
sc_link = acb->xs->sc_link;
}
AIC_MISC(("idle "));
/* Nothing to start; just enable reselections and wait. */
- outb(SIMODE0, ENSELDI);
- outb(SIMODE1, ENSCSIRST);
- outb(SCSISEQ, ENRESELI);
+ outb(iobase + SIMODE0, ENSELDI);
+ outb(iobase + SIMODE1, ENSCSIRST);
+ outb(iobase + SCSISEQ, ENRESELI);
}
\f
+void
+aic_sense(sc, acb)
+ struct aic_softc *sc;
+ struct aic_acb *acb;
+{
+ struct scsi_xfer *xs = acb->xs;
+ struct scsi_link *sc_link = xs->sc_link;
+ struct aic_tinfo *ti = &sc->sc_tinfo[sc_link->target];
+ struct scsi_sense *ss = (void *)&acb->scsi_cmd;
+
+ AIC_MISC(("requesting sense "));
+ /* Next, setup a request sense command block */
+ bzero(ss, sizeof(*ss));
+ ss->opcode = REQUEST_SENSE;
+ ss->byte2 = sc_link->lun << 5;
+ ss->length = sizeof(struct scsi_sense_data);
+ acb->scsi_cmd_length = sizeof(*ss);
+ acb->data_addr = (char *)&xs->sense;
+ acb->data_length = sizeof(struct scsi_sense_data);
+ acb->flags |= ACB_SENSE;
+ ti->senses++;
+ if (acb->flags & ACB_NEXUS)
+ ti->lubusy &= ~(1 << sc_link->lun);
+ if (acb == sc->sc_nexus) {
+ aic_select(sc, acb);
+ } else {
+ aic_dequeue(sc, acb);
+ TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
+ if (sc->sc_state == AIC_IDLE)
+ aic_sched(sc);
+ }
+}
+
/*
* POST PROCESSING OF SCSI_CMD (usually current)
*/
* We don't support chk sense conditions for the request sense cmd.
*/
if (xs->error == XS_NOERROR) {
- if (acb->flags == ACB_ABORTED) {
+ if (acb->flags & ACB_ABORT) {
xs->error = XS_DRIVER_STUFFUP;
- } else if (acb->flags == ACB_CHKSENSE) {
+ } else if (acb->flags & ACB_SENSE) {
xs->error = XS_SENSE;
} else if (acb->target_stat == SCSI_CHECK) {
- struct scsi_sense *ss = (void *)&acb->scsi_cmd;
-
- AIC_MISC(("requesting sense "));
/* First, save the return values */
xs->resid = acb->data_length;
xs->status = acb->target_stat;
- /* Next, setup a request sense command block */
- bzero(ss, sizeof(*ss));
- ss->opcode = REQUEST_SENSE;
- ss->byte2 = sc_link->lun << 5;
- ss->length = sizeof(struct scsi_sense_data);
- acb->scsi_cmd_length = sizeof(*ss);
- acb->data_addr = (char *)&xs->sense;
- acb->data_length = sizeof(struct scsi_sense_data);
- acb->flags = ACB_CHKSENSE;
- ti->senses++;
- ti->lubusy &= ~(1<<sc_link->lun);
- if (acb == sc->sc_nexus) {
- aic_select(sc, acb);
- } else {
- TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
- }
+ aic_sense(sc, acb);
return;
} else {
xs->resid = acb->data_length;
#endif
/*
- * Remove the ACB from whatever queue it's on. We have to do a bit of
- * a hack to figure out which queue it's on. Note that it is *not*
- * necessary to cdr down the ready queue, but we must cdr down the
- * nexus queue and see if it's there, so we can mark the unit as no
- * longer busy. This code is sickening, but it works.
+ * Remove the ACB from whatever queue it happens to be on.
*/
- if (acb == sc->sc_nexus) {
+ if (acb->flags & ACB_NEXUS)
ti->lubusy &= ~(1 << sc_link->lun);
- sc->sc_state = AIC_IDLE;
+ if (acb == sc->sc_nexus) {
sc->sc_nexus = NULL;
+ sc->sc_state = AIC_IDLE;
aic_sched(sc);
} else
aic_dequeue(sc, acb);
struct aic_softc *sc;
struct aic_acb *acb;
{
- struct scsi_link *sc_link = acb->xs->sc_link;
- struct aic_tinfo *ti = &sc->sc_tinfo[sc_link->target];
- if (sc->ready_list.tqh_last == &acb->chain.tqe_next) {
- TAILQ_REMOVE(&sc->ready_list, acb, chain);
+ if (acb->flags & ACB_NEXUS) {
+ TAILQ_REMOVE(&sc->nexus_list, acb, chain);
} else {
- register struct aic_acb *acb2;
- for (acb2 = sc->nexus_list.tqh_first; acb2 != NULL;
- acb2 = acb2->chain.tqe_next) {
- if (acb2 == acb)
- break;
- }
- if (acb2 != NULL) {
- TAILQ_REMOVE(&sc->nexus_list, acb, chain);
- ti->lubusy &= ~(1 << sc_link->lun);
- } else if (acb->chain.tqe_next) {
- TAILQ_REMOVE(&sc->ready_list, acb, chain);
- } else {
- printf("%s: can't find matching acb\n",
- sc->sc_dev.dv_xname);
- Debugger();
- }
+ TAILQ_REMOVE(&sc->ready_list, acb, chain);
}
}
\f
* The SCSI bus is already in the MSGI phase and there is a message byte
* on the bus, along with an asserted REQ signal.
*/
-int
+void
aic_msgin(sc)
register struct aic_softc *sc;
{
+ int iobase = sc->sc_iobase;
u_char sstat1;
int n;
*/
for (;;) {
for (;;) {
- sstat1 = inb(SSTAT1);
- if ((sstat1 & (REQINIT|BUSFREE)) != 0)
+ sstat1 = inb(iobase + SSTAT1);
+ if ((sstat1 & (REQINIT | PHASECHG | BUSFREE)) != 0)
break;
/* Wait for REQINIT. XXX Need timeout. */
}
- if ((sstat1 & (PHASECHG|BUSFREE)) != 0) {
+ if ((sstat1 & (PHASECHG | BUSFREE)) != 0) {
/*
* Target left MESSAGE IN, probably because it
* a) noticed our ATN signal, or
* b) ran out of messages.
*/
- return (1);
+ goto out;
}
/* If parity error, just dump everything on the floor. */
if ((sstat1 & SCSIPERR) != 0) {
- aic_sched_msgout(SEND_PARITY_ERROR);
sc->sc_flags |= AIC_DROP_MSGIN;
+ aic_sched_msgout(sc, SEND_PARITY_ERROR);
}
/* Gather incoming message bytes if needed. */
if ((sc->sc_flags & AIC_DROP_MSGIN) == 0) {
if (n >= AIC_MAX_MSG_LEN) {
- (void) inb(SCSIDAT);
- aic_sched_msgout(SEND_REJECT);
+ (void) inb(iobase + SCSIDAT);
sc->sc_flags |= AIC_DROP_MSGIN;
+ aic_sched_msgout(sc, SEND_REJECT);
} else {
- *sc->sc_imp++ = inb(SCSIDAT);
+ *sc->sc_imp++ = inb(iobase + SCSIDAT);
n++;
/*
* This testing is suboptimal, but most
break;
}
} else
- (void) inb(SCSIDAT);
+ (void) inb(iobase + SCSIDAT);
/*
* If we reach this spot we're either:
* a) in the middle of a multi-byte message, or
* b) dropping bytes.
*/
- outb(SXFRCTL0, CHEN|SPIOEN);
+ outb(iobase + SXFRCTL0, CHEN | SPIOEN);
/* Ack the last byte read. */
- (void) inb(SCSIDAT);
- outb(SXFRCTL0, CHEN);
- while ((inb(SCSISIG) & ACKI) != 0)
+ (void) inb(iobase + SCSIDAT);
+ outb(iobase + SXFRCTL0, CHEN);
+ while ((inb(iobase + SCSISIG) & ACKI) != 0)
;
}
case MSG_PARITY_ERROR:
/* Resend the last message. */
- aic_sched_msgout(sc->sc_lastmsg);
+ aic_sched_msgout(sc, sc->sc_lastmsg);
break;
case MSG_MESSAGE_REJECT:
switch (sc->sc_lastmsg) {
#if AIC_USE_SYNCHRONOUS + AIC_USE_WIDE
case SEND_IDENTIFY:
- ti->flags &= ~(DO_SYNC|DO_WIDE);
+ ti->flags &= ~(DO_SYNC | DO_WIDE);
ti->period = ti->offset = 0;
aic_setsync(sc, ti);
ti->width = 0;
break;
#endif
case SEND_INIT_DET_ERR:
- sc->sc_flags |= AIC_ABORTING;
- aic_sched_msgout(SEND_ABORT);
+ aic_sched_msgout(sc, SEND_ABORT);
break;
}
break;
ti->period > sc->sc_maxsync ||
ti->offset > 8) {
ti->period = ti->offset = 0;
- aic_sched_msgout(SEND_SDTR);
+ aic_sched_msgout(sc, SEND_SDTR);
} else {
sc_print_addr(acb->xs->sc_link);
printf("sync, offset %d, period %dnsec\n",
if (ti->width == 0) {
} else if (ti->width > AIC_MAX_WIDTH) {
ti->width = 0;
- aic_sched_msgout(SEND_WDTR);
+ aic_sched_msgout(sc, SEND_WDTR);
} else {
sc_print_addr(acb->xs->sc_link);
printf("wide, width %d\n",
sc->sc_dev.dv_xname);
AIC_BREAK();
reject:
- aic_sched_msgout(SEND_REJECT);
+ aic_sched_msgout(sc, SEND_REJECT);
break;
}
break;
sc->sc_dev.dv_xname);
AIC_BREAK();
reset:
- sc->sc_flags |= AIC_ABORTING;
- aic_sched_msgout(SEND_DEV_RESET);
+ aic_sched_msgout(sc, SEND_DEV_RESET);
break;
abort:
- sc->sc_flags |= AIC_ABORTING;
- aic_sched_msgout(SEND_ABORT);
+ aic_sched_msgout(sc, SEND_ABORT);
break;
}
- outb(SXFRCTL0, CHEN|SPIOEN);
+ outb(iobase + SXFRCTL0, CHEN | SPIOEN);
/* Ack the last message byte. */
- (void) inb(SCSIDAT);
- outb(SXFRCTL0, CHEN);
- while ((inb(SCSISIG) & ACKI) != 0)
+ (void) inb(iobase + SCSIDAT);
+ outb(iobase + SXFRCTL0, CHEN);
+ while ((inb(iobase + SCSISIG) & ACKI) != 0)
;
/* Go get the next message, if any. */
out:
AIC_MISC(("n=%d imess=0x%02x ", n, sc->sc_imess[0]));
- return (0);
}
/*
aic_msgout(sc)
register struct aic_softc *sc;
{
- struct aic_acb *acb;
+ int iobase = sc->sc_iobase;
struct aic_tinfo *ti;
u_char sstat1;
int n;
AIC_TRACE(("aic_msgout "));
- /*
- * Set ATN. If we're just sending a trivial 1-byte message, we'll
- * clear ATN later on anyway.
- */
- outb(SCSISIG, PH_MSGOUT|ATNO);
/* Reset the FIFO. */
- outb(DMACNTRL0, RSTFIFO);
+ outb(iobase + DMACNTRL0, RSTFIFO);
/* Enable REQ/ACK protocol. */
- outb(SXFRCTL0, CHEN|SPIOEN);
+ outb(iobase + SXFRCTL0, CHEN | SPIOEN);
if (sc->sc_prevphase == PH_MSGOUT) {
if (sc->sc_omp == sc->sc_omess) {
*/
AIC_MISC(("retransmitting "));
sc->sc_msgpriq |= sc->sc_msgoutq;
+ /*
+ * Set ATN. If we're just sending a trivial 1-byte
+ * message, we'll clear ATN later on anyway.
+ */
+ outb(iobase + SCSISIG, PH_MSGOUT | ATNO);
} else {
/* This is a continuation of the previous message. */
n = sc->sc_omp - sc->sc_omess;
/* Build the outgoing message data. */
switch (sc->sc_currmsg) {
case SEND_IDENTIFY:
- if (sc->sc_state != AIC_CONNECTED) {
- printf("%s: SEND_IDENTIFY while not connected; sending NOOP\n",
- sc->sc_dev.dv_xname);
- AIC_BREAK();
- goto noop;
- }
AIC_ASSERT(sc->sc_nexus != NULL);
- acb = sc->sc_nexus;
- sc->sc_omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun, 1);
+ sc->sc_omess[0] =
+ MSG_IDENTIFY(sc->sc_nexus->xs->sc_link->lun, 1);
n = 1;
break;
#if AIC_USE_SYNCHRONOUS
case SEND_SDTR:
- if (sc->sc_state != AIC_CONNECTED) {
- printf("%s: SEND_SDTR while not connected; sending NOOP\n",
- sc->sc_dev.dv_xname);
- AIC_BREAK();
- goto noop;
- }
AIC_ASSERT(sc->sc_nexus != NULL);
ti = &sc->sc_tinfo[sc->sc_nexus->xs->sc_link->target];
sc->sc_omess[4] = MSG_EXTENDED;
#if AIC_USE_WIDE
case SEND_WDTR:
- if (sc->sc_state != AIC_CONNECTED) {
- printf("%s: SEND_WDTR while not connected; sending NOOP\n",
- sc->sc_dev.dv_xname);
- AIC_BREAK();
- goto noop;
- }
AIC_ASSERT(sc->sc_nexus != NULL);
ti = &sc->sc_tinfo[sc->sc_nexus->xs->sc_link->target];
sc->sc_omess[3] = MSG_EXTENDED;
#endif
case SEND_DEV_RESET:
+ sc->sc_flags |= AIC_ABORTING;
sc->sc_omess[0] = MSG_BUS_DEV_RESET;
n = 1;
break;
break;
case SEND_ABORT:
+ sc->sc_flags |= AIC_ABORTING;
sc->sc_omess[0] = MSG_ABORT;
n = 1;
break;
- case 0:
-#ifdef AIC_PICKY
+ default:
printf("%s: unexpected MESSAGE OUT; sending NOOP\n",
sc->sc_dev.dv_xname);
AIC_BREAK();
-#endif
- noop:
sc->sc_omess[0] = MSG_NOOP;
n = 1;
break;
-
- default:
- printf("%s: weird MESSAGE OUT; sending NOOP\n",
- sc->sc_dev.dv_xname);
- AIC_BREAK();
- goto noop;
}
sc->sc_omp = &sc->sc_omess[n];
/* Send message bytes. */
for (;;) {
for (;;) {
- sstat1 = inb(SSTAT1);
- if ((sstat1 & (REQINIT|BUSFREE)) != 0)
+ sstat1 = inb(iobase + SSTAT1);
+ if ((sstat1 & (REQINIT | PHASECHG | BUSFREE)) != 0)
break;
/* Wait for REQINIT. XXX Need timeout. */
}
- if ((sstat1 & (PHASECHG|BUSFREE)) != 0) {
+ if ((sstat1 & (PHASECHG | BUSFREE)) != 0) {
/*
* Target left MESSAGE OUT, possibly to reject
* our message.
+ *
+ * If this is the last message being sent, then we
+ * deassert ATN, since either the target is going to
+ * ignore this message, or it's going to ask for a
+ * retransmission via MESSAGE PARITY ERROR (in which
+ * case we reassert ATN anyway).
*/
+ if (sc->sc_msgpriq == 0)
+ outb(iobase + CLRSINT1, CLRATNO);
goto out;
}
/* Clear ATN before last byte if this is the last message. */
if (n == 1 && sc->sc_msgpriq == 0)
- outb(CLRSINT1, CLRATNO);
+ outb(iobase + CLRSINT1, CLRATNO);
/* Send message byte. */
- outb(SCSIDAT, *--sc->sc_omp);
+ outb(iobase + SCSIDAT, *--sc->sc_omp);
--n;
/* Keep track of the last message we've sent any bytes of. */
sc->sc_lastmsg = sc->sc_currmsg;
/* Wait for ACK to be negated. XXX Need timeout. */
- while ((inb(SCSISIG) & ACKI) != 0)
+ while ((inb(iobase + SCSISIG) & ACKI) != 0)
;
if (n == 0)
out:
/* Disable REQ/ACK protocol. */
- outb(SXFRCTL0, CHEN);
+ outb(iobase + SXFRCTL0, CHEN);
}
\f
/* aic_dataout_pio: perform a data transfer using the FIFO datapath in the aic6360
u_char *p;
int n;
{
+ int iobase = sc->sc_iobase;
register u_char dmastat;
int out = 0;
#define DOUTAMOUNT 128 /* Full FIFO */
/* Clear host FIFO and counter. */
- outb(DMACNTRL0, RSTFIFO|WRITE);
+ outb(iobase + DMACNTRL0, RSTFIFO | WRITE);
/* Enable FIFOs. */
- outb(SXFRCTL0, SCSIEN|DMAEN|CHEN);
- outb(DMACNTRL0, ENDMA|DWORDPIO|WRITE);
+ outb(iobase + SXFRCTL0, SCSIEN | DMAEN | CHEN);
+ outb(iobase + DMACNTRL0, ENDMA | DWORDPIO | WRITE);
/* Turn off ENREQINIT for now. */
- outb(SIMODE1, ENSCSIRST|ENSCSIPERR|ENBUSFREE|ENPHASECHG);
+ outb(iobase + SIMODE1,
+ ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENPHASECHG);
/* I have tried to make the main loop as tight as possible. This
* means that some of the code following the loop is a bit more
* complex than otherwise.
*/
while (n > 0) {
- int xfer;
-
for (;;) {
- dmastat = inb(DMASTAT);
- if ((dmastat & DFIFOEMP) != 0)
+ dmastat = inb(iobase + DMASTAT);
+ if ((dmastat & (DFIFOEMP | INTSTAT)) != 0)
break;
- if ((dmastat & INTSTAT) != 0)
- goto phasechange;
}
- xfer = min(DOUTAMOUNT, n);
+ if ((dmastat & INTSTAT) != 0)
+ goto phasechange;
+
+ if (n >= DOUTAMOUNT) {
+ n -= DOUTAMOUNT;
+ out += DOUTAMOUNT;
+
+#if AIC_USE_DWORDS
+ outsl(iobase + DMADATALONG, p, DOUTAMOUNT >> 2);
+#else
+ outsw(iobase + DMADATA, p, DOUTAMOUNT >> 1);
+#endif
+
+ p += DOUTAMOUNT;
+ } else {
+ register int xfer;
- AIC_MISC(("%d> ", xfer));
+ xfer = n;
+ AIC_MISC(("%d> ", xfer));
- n -= xfer;
- out += xfer;
+ n -= xfer;
+ out += xfer;
#if AIC_USE_DWORDS
- if (xfer >= 12) {
- outsl(DMADATALONG, p, xfer>>2);
- p += xfer & ~3;
- xfer &= 3;
- }
+ if (xfer >= 12) {
+ outsl(iobase + DMADATALONG, p, xfer >> 2);
+ p += xfer & ~3;
+ xfer &= 3;
+ }
#else
- if (xfer >= 8) {
- outsw(DMADATA, p, xfer>>1);
- p += xfer & ~1;
- xfer &= 1;
- }
+ if (xfer >= 8) {
+ outsw(iobase + DMADATA, p, xfer >> 1);
+ p += xfer & ~1;
+ xfer &= 1;
+ }
#endif
- if (xfer > 0) {
- outb(DMACNTRL0, ENDMA|B8MODE|WRITE);
- outsb(DMADATA, p, xfer);
- p += xfer;
- outb(DMACNTRL0, ENDMA|DWORDPIO|WRITE);
+ if (xfer > 0) {
+ outb(iobase + DMACNTRL0, ENDMA | B8MODE | WRITE);
+ outsb(iobase + DMADATA, p, xfer);
+ p += xfer;
+ outb(iobase + DMACNTRL0, ENDMA | DWORDPIO | WRITE);
+ }
}
}
if (out == 0) {
- outb(SXFRCTL1, BITBUCKET);
+ outb(iobase + SXFRCTL1, BITBUCKET);
for (;;) {
- if ((inb(DMASTAT) & INTSTAT) != 0)
+ if ((inb(iobase + DMASTAT) & INTSTAT) != 0)
break;
}
- outb(SXFRCTL1, 0);
+ outb(iobase + SXFRCTL1, 0);
AIC_MISC(("extra data "));
} else {
/* See the bytes off chip */
for (;;) {
- dmastat = inb(DMASTAT);
- if ((dmastat & DFIFOEMP) != 0 &&
- (inb(SSTAT2) & SEMPTY) != 0)
- break;
+ dmastat = inb(iobase + DMASTAT);
if ((dmastat & INTSTAT) != 0)
goto phasechange;
+ if ((dmastat & DFIFOEMP) != 0 &&
+ (inb(iobase + SSTAT2) & SEMPTY) != 0)
+ break;
}
}
phasechange:
/* Stop the FIFO data path. */
- outb(SXFRCTL0, CHEN);
- while ((inb(SXFRCTL0) & SCSIEN) != 0)
+ outb(iobase + SXFRCTL0, CHEN);
+ while ((inb(iobase + SXFRCTL0) & SCSIEN) != 0)
;
if ((dmastat & INTSTAT) != 0) {
int amount;
/* Stop transfers, do some accounting */
- amount = inb(FIFOSTAT) + (inb(SSTAT2) & 15);
+ amount = inb(iobase + FIFOSTAT) + (inb(iobase + SSTAT2) & 15);
if (amount > 0) {
out -= amount;
- outb(SXFRCTL0, CHEN|CLRSTCNT|CLRCH);
+ outb(iobase + SXFRCTL0, CHEN | CLRSTCNT | CLRCH);
AIC_MISC(("+%d ", amount));
}
}
/* Turn on ENREQINIT again. */
- outb(SIMODE1, ENSCSIRST|ENSCSIPERR|ENBUSFREE|ENREQINIT|ENPHASECHG);
+ outb(iobase + SIMODE1,
+ ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENREQINIT | ENPHASECHG);
return out;
}
u_char *p;
int n;
{
+ int iobase = sc->sc_iobase;
register u_char dmastat;
int in = 0;
#define DINAMOUNT 128 /* Full FIFO */
/* Clear host FIFO and counter. */
- outb(DMACNTRL0, RSTFIFO);
- /* Enable FIFOs */
- outb(SXFRCTL0, SCSIEN|DMAEN|CHEN);
- outb(DMACNTRL0, ENDMA|DWORDPIO);
+ outb(iobase + DMACNTRL0, RSTFIFO);
+ /* Enable FIFOs. */
+ outb(iobase + SXFRCTL0, SCSIEN | DMAEN | CHEN);
+ outb(iobase + DMACNTRL0, ENDMA | DWORDPIO);
/* Turn off ENREQINIT for now. */
- outb(SIMODE1, ENSCSIRST|ENSCSIPERR|ENBUSFREE|ENPHASECHG);
+ outb(iobase + SIMODE1,
+ ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENPHASECHG);
/* We leave this loop if one or more of the following is true:
* a) phase != PH_DATAIN && FIFOs are empty
* b) SCSIRSTI is set (a reset has occurred) or busfree is detected.
*/
while (n > 0) {
- int xfer;
-
/* Wait for fifo half full or phase mismatch */
for (;;) {
- dmastat = inb(DMASTAT);
- if ((dmastat & (DFIFOFULL|INTSTAT)) != 0)
+ dmastat = inb(iobase + DMASTAT);
+ if ((dmastat & (DFIFOFULL | INTSTAT)) != 0)
break;
}
- if ((dmastat & DFIFOFULL) != 0)
- xfer = min(DINAMOUNT, n);
- else
- xfer = min(inb(FIFOSTAT), n);
+ if ((dmastat & DFIFOFULL) != 0) {
+ n -= DINAMOUNT;
+ in += DINAMOUNT;
+
+#if AIC_USE_DWORDS
+ insl(iobase + DMADATALONG, p, DINAMOUNT >> 2);
+#else
+ insw(iobase + DMADATA, p, DINAMOUNT >> 1);
+#endif
- AIC_MISC((">%d ", xfer));
+ p += DINAMOUNT;
+ } else {
+ register int xfer;
- n -= xfer;
- in += xfer;
+ xfer = min(inb(iobase + FIFOSTAT), n);
+ AIC_MISC((">%d ", xfer));
+
+ n -= xfer;
+ in += xfer;
#if AIC_USE_DWORDS
- if (xfer >= 12) {
- insl(DMADATALONG, p, xfer>>2);
- p += xfer & ~3;
- xfer &= 3;
- }
+ if (xfer >= 12) {
+ insl(iobase + DMADATALONG, p, xfer >> 2);
+ p += xfer & ~3;
+ xfer &= 3;
+ }
#else
- if (xfer >= 8) {
- insw(DMADATA, p, xfer>>1);
- p += xfer & ~1;
- xfer &= 1;
- }
+ if (xfer >= 8) {
+ insw(iobase + DMADATA, p, xfer >> 1);
+ p += xfer & ~1;
+ xfer &= 1;
+ }
#endif
- if (xfer > 0) {
- outb(DMACNTRL0, ENDMA|B8MODE);
- insb(DMADATA, p, xfer);
- p += xfer;
- outb(DMACNTRL0, ENDMA|DWORDPIO);
+ if (xfer > 0) {
+ outb(iobase + DMACNTRL0, ENDMA | B8MODE);
+ insb(iobase + DMADATA, p, xfer);
+ p += xfer;
+ outb(iobase + DMACNTRL0, ENDMA | DWORDPIO);
+ }
}
if ((dmastat & INTSTAT) != 0)
* FIFO is not empty, waste some bytes....
*/
if (in == 0) {
- outb(SXFRCTL1, BITBUCKET);
+ outb(iobase + SXFRCTL1, BITBUCKET);
for (;;) {
- if ((inb(DMASTAT) & INTSTAT) != 0)
+ if ((inb(iobase + DMASTAT) & INTSTAT) != 0)
break;
}
- outb(SXFRCTL1, 0);
+ outb(iobase + SXFRCTL1, 0);
AIC_MISC(("extra data "));
}
phasechange:
/* Stop the FIFO data path. */
- outb(SXFRCTL0, CHEN);
- while ((inb(SXFRCTL0) & SCSIEN) != 0)
+ outb(iobase + SXFRCTL0, CHEN);
+ while ((inb(iobase + SXFRCTL0) & SCSIEN) != 0)
;
/* Turn on ENREQINIT again. */
- outb(SIMODE1, ENSCSIRST|ENSCSIPERR|ENBUSFREE|ENREQINIT|ENPHASECHG);
+ outb(iobase + SIMODE1,
+ ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENREQINIT | ENPHASECHG);
return in;
}
void *arg;
{
register struct aic_softc *sc = arg;
+ int iobase = sc->sc_iobase;
u_char sstat0, sstat1;
register struct aic_acb *acb;
register struct scsi_link *sc_link;
* Clear INTEN. We enable it again before returning. This makes the
* interrupt esssentially level-triggered.
*/
- outb(DMACNTRL0, 0);
+ outb(iobase + DMACNTRL0, 0);
AIC_TRACE(("aicintr "));
loop:
-gotintr:
/*
* First check for abnormal conditions, such as reset.
*/
- sstat1 = inb(SSTAT1);
+ sstat1 = inb(iobase + SSTAT1);
AIC_MISC(("sstat1:0x%02x ", sstat1));
if ((sstat1 & SCSIRSTI) != 0) {
*/
if ((sstat1 & SCSIPERR) != 0) {
printf("%s: SCSI bus parity error\n", sc->sc_dev.dv_xname);
- outb(CLRSINT1, CLRSCSIPERR);
+ outb(iobase + CLRSINT1, CLRSCSIPERR);
if (sc->sc_prevphase == PH_MSGIN) {
- aic_sched_msgout(SEND_PARITY_ERROR);
sc->sc_flags |= AIC_DROP_MSGIN;
+ aic_sched_msgout(sc, SEND_PARITY_ERROR);
} else
- aic_sched_msgout(SEND_INIT_DET_ERR);
+ aic_sched_msgout(sc, SEND_INIT_DET_ERR);
}
/*
switch (sc->sc_state) {
case AIC_IDLE:
case AIC_SELECTING:
- sstat0 = inb(SSTAT0);
+ sstat0 = inb(iobase + SSTAT0);
AIC_MISC(("sstat0:0x%02x ", sstat0));
if ((sstat0 & TARGET) != 0) {
/*
* We don't currently support target mode.
*/
- printf("%s: target mode selected; going to bus free\n",
+ printf("%s: target mode selected; going to BUS FREE\n",
sc->sc_dev.dv_xname);
- outb(SCSISIG, 0);
+ outb(iobase + SCSISIG, 0);
- sc->sc_state = AIC_IDLE;
- aic_sched(sc);
- goto out;
+ goto sched;
} else if ((sstat0 & SELDI) != 0) {
AIC_MISC(("reselected "));
}
/* Save reselection ID. */
- sc->sc_selid = inb(SELID);
+ sc->sc_selid = inb(iobase + SELID);
sc->sc_state = AIC_RESELECTED;
} else if ((sstat0 & SELDO) != 0) {
}
AIC_ASSERT(sc->sc_nexus != NULL);
acb = sc->sc_nexus;
-
sc_link = acb->xs->sc_link;
ti = &sc->sc_tinfo[sc_link->target];
- if ((acb->xs->flags & SCSI_RESET) == 0) {
- sc->sc_msgpriq = SEND_IDENTIFY;
- if (acb->flags != ACB_ABORTED) {
+
+ sc->sc_msgpriq = SEND_IDENTIFY;
+ if (acb->flags & ACB_RESET)
+ sc->sc_msgpriq |= SEND_DEV_RESET;
+ else if (acb->flags & ACB_ABORT)
+ sc->sc_msgpriq |= SEND_ABORT;
+ else {
#if AIC_USE_SYNCHRONOUS
- if ((ti->flags & DO_SYNC) != 0)
- sc->sc_msgpriq |= SEND_SDTR;
+ if ((ti->flags & DO_SYNC) != 0)
+ sc->sc_msgpriq |= SEND_SDTR;
#endif
#if AIC_USE_WIDE
- if ((ti->flags & DO_WIDE) != 0)
- sc->sc_msgpriq |= SEND_WDTR;
+ if ((ti->flags & DO_WIDE) != 0)
+ sc->sc_msgpriq |= SEND_WDTR;
#endif
- } else {
- sc->sc_flags |= AIC_ABORTING;
- sc->sc_msgpriq |= SEND_ABORT;
- }
- } else
- sc->sc_msgpriq = SEND_DEV_RESET;
+ }
+ acb->flags |= ACB_NEXUS;
ti->lubusy |= (1 << sc_link->lun);
/* Do an implicit RESTORE POINTERS. */
sc->sc_cp = (u_char *)&acb->scsi_cmd;
sc->sc_cleft = acb->scsi_cmd_length;
+ /* On our first connection, schedule a timeout. */
+ if ((acb->xs->flags & SCSI_POLL) == 0)
+ timeout(aic_timeout, acb, (acb->timeout * hz) / 1000);
+
sc->sc_state = AIC_CONNECTED;
} else if ((sstat1 & SELTO) != 0) {
AIC_MISC(("selection timeout "));
AIC_ASSERT(sc->sc_nexus != NULL);
acb = sc->sc_nexus;
- outb(SXFRCTL1, 0);
- outb(SCSISEQ, ENRESELI);
- outb(CLRSINT1, CLRSELTIMO);
+ outb(iobase + SXFRCTL1, 0);
+ outb(iobase + SCSISEQ, ENRESELI);
+ outb(iobase + CLRSINT1, CLRSELTIMO);
+ delay(250);
acb->xs->error = XS_SELTIMEOUT;
- untimeout(aic_timeout, acb);
- delay(250);
- aic_done(sc, acb);
- goto out;
+ goto finish;
} else {
-#ifdef AIC_PICKY
if (sc->sc_state != AIC_IDLE) {
printf("%s: BUS FREE while not idle; state=%d\n",
sc->sc_dev.dv_xname, sc->sc_state);
AIC_BREAK();
goto out;
}
-#endif
- aic_sched(sc);
- goto out;
+ goto sched;
}
/*
* Turn off selection stuff, and prepare to catch bus free
* interrupts, parity errors, and phase changes.
*/
- outb(SXFRCTL1, 0);
- outb(SCSISEQ, ENAUTOATNP);
- outb(CLRSINT0, CLRSELDI|CLRSELDO);
- outb(CLRSINT1, CLRBUSFREE|CLRPHASECHG);
- outb(SIMODE0, 0);
- outb(SIMODE1, ENSCSIRST|ENSCSIPERR|ENBUSFREE|ENREQINIT|ENPHASECHG);
+ outb(iobase + SXFRCTL0, CHEN | CLRSTCNT | CLRCH);
+ outb(iobase + SXFRCTL1, 0);
+ outb(iobase + SCSISEQ, ENAUTOATNP);
+ outb(iobase + CLRSINT0, CLRSELDI | CLRSELDO);
+ outb(iobase + CLRSINT1, CLRBUSFREE | CLRPHASECHG);
+ outb(iobase + SIMODE0, 0);
+ outb(iobase + SIMODE1,
+ ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENREQINIT | ENPHASECHG);
sc->sc_flags = 0;
sc->sc_prevphase = PH_INVALID;
goto dophase;
}
- outb(CLRSINT1, CLRPHASECHG);
-
if ((sstat1 & BUSFREE) != 0) {
/* We've gone to BUS FREE phase. */
- outb(CLRSINT1, CLRBUSFREE);
+ outb(iobase + CLRSINT1, CLRBUSFREE | CLRPHASECHG);
switch (sc->sc_state) {
case AIC_RESELECTED:
- sc->sc_state = AIC_IDLE;
- aic_sched(sc);
- break;
+ goto sched;
case AIC_CONNECTED:
+ AIC_ASSERT(sc->sc_nexus != NULL);
+ acb = sc->sc_nexus;
+
+#if AIC_USE_SYNCHRONOUS + AIC_USE_WIDE
+ if (sc->sc_prevphase == PH_MSGOUT) {
+ /*
+ * If the target went to BUS FREE phase during
+ * or immediately after sending a SDTR or WDTR
+ * message, disable negotiation.
+ */
+ sc_link = acb->xs->sc_link;
+ ti = &sc->sc_tinfo[sc_link->target];
+ switch (sc->sc_lastmsg) {
+#if AIC_USE_SYNCHRONOUS
+ case SEND_SDTR:
+ ti->flags &= ~DO_SYNC;
+ ti->period = ti->offset = 0;
+ break;
+#endif
+#if AIC_USE_WIDE
+ case SEND_WDTR:
+ ti->flags &= ~DO_WIDE;
+ ti->width = 0;
+ break;
+#endif
+ }
+ }
+#endif
+
if ((sc->sc_flags & AIC_ABORTING) == 0) {
- printf("%s: unexpected BUS FREE; aborting\n",
+ /*
+ * Section 5.1.1 of the SCSI 2 spec suggests
+ * issuing a REQUEST SENSE following an
+ * unexpected disconnect. Some devices go into
+ * a contingent allegiance condition when
+ * disconnecting, and this is necessary to
+ * clean up their state.
+ */
+ printf("%s: unexpected disconnect; sending REQUEST SENSE\n",
sc->sc_dev.dv_xname);
AIC_BREAK();
+ aic_sense(sc, acb);
+ goto out;
}
- AIC_ASSERT(sc->sc_nexus != NULL);
- acb = sc->sc_nexus;
+
acb->xs->error = XS_DRIVER_STUFFUP;
goto finish;
case AIC_DISCONNECT:
AIC_ASSERT(sc->sc_nexus != NULL);
acb = sc->sc_nexus;
- sc->sc_state = AIC_IDLE;
- sc->sc_nexus = NULL;
TAILQ_INSERT_HEAD(&sc->nexus_list, acb, chain);
- aic_sched(sc);
- break;
+ sc->sc_nexus = NULL;
+ goto sched;
case AIC_CMDCOMPLETE:
AIC_ASSERT(sc->sc_nexus != NULL);
acb = sc->sc_nexus;
- finish:
- untimeout(aic_timeout, acb);
- aic_done(sc, acb);
- break;
+ goto finish;
}
- goto out;
}
+ outb(iobase + CLRSINT1, CLRPHASECHG);
+
dophase:
if ((sstat1 & REQINIT) == 0) {
/* Wait for REQINIT. */
goto out;
}
- sc->sc_phase = inb(SCSISIG) & PH_MASK;
- outb(SCSISIG, sc->sc_phase);
+ sc->sc_phase = inb(iobase + SCSISIG) & PH_MASK;
+ outb(iobase + SCSISIG, sc->sc_phase);
switch (sc->sc_phase) {
case PH_MSGOUT:
- /* If aborting, always handle MESSAGE OUT. */
- if ((sc->sc_state & AIC_CONNECTED) == 0 &&
- (sc->sc_flags & AIC_ABORTING) == 0)
+ if (sc->sc_state != AIC_CONNECTED &&
+ sc->sc_state != AIC_RESELECTED)
break;
aic_msgout(sc);
sc->sc_prevphase = PH_MSGOUT;
goto loop;
case PH_MSGIN:
- if ((sc->sc_state & (AIC_CONNECTED|AIC_RESELECTED)) == 0)
+ if (sc->sc_state != AIC_CONNECTED &&
+ sc->sc_state != AIC_RESELECTED)
break;
- if (aic_msgin(sc)) {
- sc->sc_prevphase = PH_MSGIN;
- goto gotintr;
- }
+ aic_msgin(sc);
sc->sc_prevphase = PH_MSGIN;
goto loop;
case PH_CMD:
- if ((sc->sc_state & AIC_CONNECTED) == 0)
+ if (sc->sc_state != AIC_CONNECTED)
break;
#if AIC_DEBUG
if ((aic_debug & AIC_SHOWMISC) != 0) {
goto loop;
case PH_DATAOUT:
- if ((sc->sc_state & AIC_CONNECTED) == 0)
+ if (sc->sc_state != AIC_CONNECTED)
break;
AIC_MISC(("dataout dleft=%d ", sc->sc_dleft));
n = aic_dataout_pio(sc, sc->sc_dp, sc->sc_dleft);
goto loop;
case PH_DATAIN:
- if ((sc->sc_state & AIC_CONNECTED) == 0)
+ if (sc->sc_state != AIC_CONNECTED)
break;
AIC_MISC(("datain "));
n = aic_datain_pio(sc, sc->sc_dp, sc->sc_dleft);
goto loop;
case PH_STAT:
- if ((sc->sc_state & AIC_CONNECTED) == 0)
+ if (sc->sc_state != AIC_CONNECTED)
break;
AIC_ASSERT(sc->sc_nexus != NULL);
acb = sc->sc_nexus;
/* XXXX Don't clear FIFO. Wait for byte to come in. */
- outb(SXFRCTL0, CHEN|SPIOEN);
- outb(DMACNTRL0, RSTFIFO);
- acb->target_stat = inb(SCSIDAT);
- outb(SXFRCTL0, CHEN);
- outb(DMACNTRL0, RSTFIFO);
- while ((inb(SXFRCTL0) & SCSIEN) != 0)
+ outb(iobase + SXFRCTL0, CHEN | SPIOEN);
+ outb(iobase + DMACNTRL0, RSTFIFO);
+ acb->target_stat = inb(iobase + SCSIDAT);
+ outb(iobase + SXFRCTL0, CHEN);
+ outb(iobase + DMACNTRL0, RSTFIFO);
+ while ((inb(iobase + SXFRCTL0) & SCSIEN) != 0)
;
AIC_MISC(("target_stat=0x%02x ", acb->target_stat));
sc->sc_prevphase = PH_STAT;
aic_init(sc);
return 1;
+finish:
+ untimeout(aic_timeout, acb);
+ aic_done(sc, acb);
+ goto out;
+
+sched:
+ sc->sc_state = AIC_IDLE;
+ aic_sched(sc);
+ goto out;
+
out:
- outb(DMACNTRL0, INTEN);
+ outb(iobase + DMACNTRL0, INTEN);
return 1;
}
struct aic_acb *acb;
{
- if (sc->sc_nexus == acb) {
- if (sc->sc_state == AIC_CONNECTED) {
- sc->sc_flags |= AIC_ABORTING;
- aic_sched_msgout(SEND_ABORT);
- }
+ /* 2 secs for the abort */
+ acb->timeout = AIC_ABORT_TIMEOUT;
+ acb->flags |= ACB_ABORT;
+
+ if (acb == sc->sc_nexus) {
+ /*
+ * If we're still selecting, the message will be scheduled
+ * after selection is complete.
+ */
+ if (sc->sc_state == AIC_CONNECTED)
+ aic_sched_msgout(sc, SEND_ABORT);
} else {
aic_dequeue(sc, acb);
TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
s = splbio();
- if (acb->flags == ACB_ABORTED) {
+ if (acb->flags & ACB_ABORT) {
/* abort timed out */
printf(" AGAIN\n");
- acb->xs->retries = 0;
- aic_done(sc, acb);
+ /* XXX Must reset! */
} else {
/* abort the operation that has timed out */
printf("\n");
acb->xs->error = XS_TIMEOUT;
- acb->flags = ACB_ABORTED;
aic_abort(sc, acb);
- /* 2 secs for the abort */
- if ((xs->flags & SCSI_POLL) == 0)
- timeout(aic_timeout, acb, 2 * hz);
}
splx(s);
aic_print_active_acb()
{
struct aic_acb *acb;
- struct aic_softc *sc = aiccd.cd_devs[0];
+ struct aic_softc *sc = aic_cd.cd_devs[0];
printf("ready list:\n");
for (acb = sc->ready_list.tqh_first; acb != NULL;
aic_dump6360(sc)
struct aic_softc *sc;
{
+ int iobase = sc->sc_iobase;
printf("aic6360: SCSISEQ=%x SXFRCTL0=%x SXFRCTL1=%x SCSISIG=%x\n",
- inb(SCSISEQ), inb(SXFRCTL0), inb(SXFRCTL1), inb(SCSISIG));
+ inb(iobase + SCSISEQ), inb(iobase + SXFRCTL0),
+ inb(iobase + SXFRCTL1), inb(iobase + SCSISIG));
printf(" SSTAT0=%x SSTAT1=%x SSTAT2=%x SSTAT3=%x SSTAT4=%x\n",
- inb(SSTAT0), inb(SSTAT1), inb(SSTAT2), inb(SSTAT3), inb(SSTAT4));
+ inb(iobase + SSTAT0), inb(iobase + SSTAT1), inb(iobase + SSTAT2),
+ inb(iobase + SSTAT3), inb(iobase + SSTAT4));
printf(" SIMODE0=%x SIMODE1=%x DMACNTRL0=%x DMACNTRL1=%x DMASTAT=%x\n",
- inb(SIMODE0), inb(SIMODE1), inb(DMACNTRL0), inb(DMACNTRL1),
- inb(DMASTAT));
+ inb(iobase + SIMODE0), inb(iobase + SIMODE1),
+ inb(iobase + DMACNTRL0), inb(iobase + DMACNTRL1),
+ inb(iobase + DMASTAT));
printf(" FIFOSTAT=%d SCSIBUS=0x%x\n",
- inb(FIFOSTAT), inb(SCSIBUS));
+ inb(iobase + FIFOSTAT), inb(iobase + SCSIBUS));
}
void
-/* $OpenBSD: ast.c,v 1.7 1996/04/18 23:47:29 niklas Exp $ */
-/* $NetBSD: ast.c,v 1.22 1996/03/10 09:01:20 cgd Exp $ */
+/* $OpenBSD: ast.c,v 1.8 1996/04/21 22:22:48 deraadt Exp $ */
+/* $NetBSD: ast.c,v 1.26 1996/04/15 18:55:23 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/termios.h>
+#ifdef i386 /* XXX */
+#include <machine/cpu.h> /* XXX */
+#else /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <machine/bus.h>
#include <dev/isa/isavar.h>
void astattach();
int astintr __P((void *));
-struct cfdriver astcd = {
- NULL, "ast", astprobe, astattach, DV_TTY, sizeof(struct ast_softc)
+struct cfattach ast_ca = {
+ sizeof(struct ast_softc), astprobe, astattach
+};
+
+struct cfdriver ast_cd = {
+ NULL, "ast", DV_TTY
};
int
ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
ca.ca_noien = 1;
- /* mimic config_found(), but with special functionality */
- if ((match = config_search(NULL, self, &ca)) != NULL) {
- subunit = match->cf_unit; /* can change if unit == * */
- config_attach(self, match, &ca, astprint);
- sc->sc_slaves[i] = match->cf_driver->cd_devs[subunit];
+ sc->sc_slaves[i] = config_found(self, &ca, astprint);
+ if (sc->sc_slaves[i] != NULL)
sc->sc_alive |= 1 << i;
- } else {
- astprint(&ca, self->dv_xname);
- printf(" not configured\n");
- }
}
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_TTY, astintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_TTY, astintr, sc, sc->sc_dev.dv_xname);
}
int
-/* $OpenBSD: boca.c,v 1.7 1996/04/18 23:47:30 niklas Exp $ */
-/* $NetBSD: boca.c,v 1.9 1996/03/10 09:01:22 cgd Exp $ */
+/* $OpenBSD: boca.c,v 1.8 1996/04/21 22:22:52 deraadt Exp $ */
+/* $NetBSD: boca.c,v 1.13 1996/04/15 18:55:28 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/termios.h>
+#ifdef i386 /* XXX */
+#include <machine/cpu.h> /* XXX */
+#else /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <machine/bus.h>
#include <dev/isa/isavar.h>
void bocaattach();
int bocaintr __P((void *));
-struct cfdriver bocacd = {
- NULL, "boca", bocaprobe, bocaattach, DV_TTY, sizeof(struct boca_softc)
+struct cfattach boca_ca = {
+ sizeof(struct boca_softc), bocaprobe, bocaattach,
+};
+
+struct cfdriver boca_cd = {
+ NULL, "boca", DV_TTY
};
int
ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
ca.ca_noien = 0;
- /* mimic config_found(), but with special functionality */
- if ((match = config_search(NULL, self, &ca)) != NULL) {
- subunit = match->cf_unit; /* can change if unit == * */
- config_attach(self, match, &ca, bocaprint);
- sc->sc_slaves[i] = match->cf_driver->cd_devs[subunit];
+ sc->sc_slaves[i] = config_found(self, &ca, bocaprint);
+ if (sc->sc_slaves[i] != NULL)
sc->sc_alive |= 1 << i;
- } else {
- bocaprint(&ca, self->dv_xname);
- printf(" not configured\n");
- }
}
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_TTY, bocaintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_TTY, bocaintr, sc, sc->sc_dev.dv_xname);
}
int
-/* $OpenBSD: bt.c,v 1.7 1996/04/18 23:47:31 niklas Exp $ */
-/* $NetBSD: bt742a.c,v 1.55 1996/03/16 05:33:28 cgd Exp $ */
+/* $NetBSD: bt.c,v 1.7 1996/04/11 22:28:25 cgd Exp $ */
+
+#define BTDIAG
+#define integrate
/*
- * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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 Charles Hannum.
+ * This product includes software developed by Charles M. Hannum.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* functioning of this software in any circumstances.
*/
-/*
- * bt742a SCSI driver
- */
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/pio.h>
-#include <dev/isa/isavar.h>
-#include <dev/isa/isadmavar.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
-/*
- * Note that stdarg.h and the ANSI style va_start macro is used for both
- * ANSI and traditional C compilers.
- */
-#include <machine/stdarg.h>
+#include <dev/isa/isavar.h>
+#include <dev/isa/isadmavar.h>
+#include <dev/isa/btreg.h>
#ifndef DDB
#define Debugger() panic("should call debugger here (bt742a.c)")
#endif /* ! DDB */
-typedef u_long physaddr;
-typedef u_long physlen;
-
-/*
- * I/O Port Interface
- */
-#define BT_CTRL_STAT_PORT 0x0 /* control & status */
-#define BT_CMD_DATA_PORT 0x1 /* cmds and datas */
-#define BT_INTR_PORT 0x2 /* Intr. stat */
-
-/*
- * BT_CTRL_STAT bits (write)
- */
-#define BT_HRST 0x80 /* Hardware reset */
-#define BT_SRST 0x40 /* Software reset */
-#define BT_IRST 0x20 /* Interrupt reset */
-#define BT_SCRST 0x10 /* SCSI bus reset */
-
-/*
- * BT_CTRL_STAT bits (read)
- */
-#define BT_STST 0x80 /* Self test in Progress */
-#define BT_DIAGF 0x40 /* Diagnostic Failure */
-#define BT_INIT 0x20 /* Mbx Init required */
-#define BT_IDLE 0x10 /* Host Adapter Idle */
-#define BT_CDF 0x08 /* cmd/data out port full */
-#define BT_DF 0x04 /* Data in port full */
-#define BT_INVDCMD 0x01 /* Invalid command */
-
-/*
- * BT_CMD_DATA bits (write)
- */
-#define BT_NOP 0x00 /* No operation */
-#define BT_MBX_INIT 0x01 /* Mbx initialization */
-#define BT_START_SCSI 0x02 /* start scsi command */
-#define BT_START_BIOS 0x03 /* start bios command */
-#define BT_INQUIRE 0x04 /* Adapter Inquiry */
-#define BT_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
-#define BT_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
-#define BT_BUS_ON_TIME_SET 0x07 /* set bus-on time */
-#define BT_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
-#define BT_SPEED_SET 0x09 /* set transfer speed */
-#define BT_DEV_GET 0x0a /* return installed devices */
-#define BT_CONF_GET 0x0b /* return configuration data */
-#define BT_TARGET_EN 0x0c /* enable target mode */
-#define BT_SETUP_GET 0x0d /* return setup data */
-#define BT_WRITE_CH2 0x1a /* write channel 2 buffer */
-#define BT_READ_CH2 0x1b /* read channel 2 buffer */
-#define BT_WRITE_FIFO 0x1c /* write fifo buffer */
-#define BT_READ_FIFO 0x1d /* read fifo buffer */
-#define BT_ECHO 0x1e /* Echo command data */
-#define BT_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */
-#define BT_INQUIRE_REV_THIRD 0x84 /* Get 3rd firmware version byte */
-#define BT_INQUIRE_REV_FOURTH 0x85 /* Get 4th firmware version byte */
-#define BT_GET_BOARD_INFO 0x8b /* Get hardware ID and revision */
-#define BT_INQUIRE_EXTENDED 0x8d /* Adapter Setup Inquiry */
-
-/* Follows command appeared at firmware 3.31 */
-#define BT_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */
-#define BT_DISABLE 0x00 /* Parameter value for Disable */
-#define BT_ENABLE 0x01 /* Parameter value for Enable */
-
-/*
- * BT_INTR_PORT bits (read)
- */
-#define BT_ANY_INTR 0x80 /* Any interrupt */
-#define BT_SCRD 0x08 /* SCSI reset detected */
-#define BT_HACC 0x04 /* Command complete */
-#define BT_MBOA 0x02 /* MBX out empty */
-#define BT_MBIF 0x01 /* MBX in full */
-
/*
* Mail box defs etc.
* these could be bigger but we need the bt_softc to fit on a single page..
else \
(wmb)++;
-struct bt_mbx_out {
- physaddr ccb_addr;
- u_char dummy[3];
- u_char cmd;
-};
-
-struct bt_mbx_in {
- physaddr ccb_addr;
- u_char btstat;
- u_char sdstat;
- u_char dummy;
- u_char stat;
-};
-
struct bt_mbx {
struct bt_mbx_out mbo[BT_MBX_SIZE];
struct bt_mbx_in mbi[BT_MBX_SIZE];
+ struct bt_mbx_out *cmbo; /* Collection Mail Box out */
struct bt_mbx_out *tmbo; /* Target Mail Box out */
struct bt_mbx_in *tmbi; /* Target Mail Box in */
};
-/*
- * mbo.cmd values
- */
-#define BT_MBO_FREE 0x0 /* MBO entry is free */
-#define BT_MBO_START 0x1 /* MBO activate entry */
-#define BT_MBO_ABORT 0x2 /* MBO abort entry */
-
-/*
- * mbi.stat values
- */
-#define BT_MBI_FREE 0x0 /* MBI entry is free */
-#define BT_MBI_OK 0x1 /* completed without error */
-#define BT_MBI_ABORT 0x2 /* aborted ccb */
-#define BT_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
-#define BT_MBI_ERROR 0x4 /* Completed with error */
-
-#if defined(BIG_DMA)
-WARNING...THIS WON'T WORK(won't fit on 1 page)
-/* #define BT_NSEG 2048 /* Number of scatter gather segments - to much vm */
-#define BT_NSEG 128
-#else
-#define BT_NSEG 33
-#endif /* BIG_DMA */
-
-struct bt_scat_gath {
- physlen seg_len;
- physaddr seg_addr;
-};
-
-struct bt_ccb {
- u_char opcode;
- u_char:3, data_in:1, data_out:1,:3;
- u_char scsi_cmd_length;
- u_char req_sense_length;
- /*------------------------------------longword boundary */
- physlen data_length;
- /*------------------------------------longword boundary */
- physaddr data_addr;
- /*------------------------------------longword boundary */
- u_char dummy1[2];
- u_char host_stat;
- u_char target_stat;
- /*------------------------------------longword boundary */
- u_char target;
- u_char lun;
- struct scsi_generic scsi_cmd;
- u_char dummy2[1];
- u_char link_id;
- /*------------------------------------longword boundary */
- physaddr link_addr;
- /*------------------------------------longword boundary */
- physaddr sense_ptr;
-/*-----end of HW fields-----------------------longword boundary */
- struct scsi_sense_data scsi_sense;
- /*------------------------------------longword boundary */
- struct bt_scat_gath scat_gath[BT_NSEG];
- /*------------------------------------longword boundary */
- TAILQ_ENTRY(bt_ccb) chain;
- struct bt_ccb *nexthash;
- long hashkey;
- struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
- int flags;
-#define CCB_FREE 0
-#define CCB_ACTIVE 1
-#define CCB_ABORTED 2
- struct bt_mbx_out *mbx; /* pointer to mail box */
-};
-
-/*
- * opcode fields
- */
-#define BT_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
-#define BT_TARGET_CCB 0x01 /* SCSI Target CCB */
-#define BT_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */
-#define BT_RESET_CCB 0x81 /* SCSI Bus reset */
-
-/*
- * bt_ccb.host_stat values
- */
-#define BT_OK 0x00 /* cmd ok */
-#define BT_LINK_OK 0x0a /* Link cmd ok */
-#define BT_LINK_IT 0x0b /* Link cmd ok + int */
-#define BT_SEL_TIMEOUT 0x11 /* Selection time out */
-#define BT_OVER_UNDER 0x12 /* Data over/under run */
-#define BT_BUS_FREE 0x13 /* Bus dropped at unexpected time */
-#define BT_INV_BUS 0x14 /* Invalid bus phase/sequence */
-#define BT_BAD_MBO 0x15 /* Incorrect MBO cmd */
-#define BT_BAD_CCB 0x16 /* Incorrect ccb opcode */
-#define BT_BAD_LINK 0x17 /* Not same values of LUN for links */
-#define BT_INV_TARGET 0x18 /* Invalid target direction */
-#define BT_CCB_DUP 0x19 /* Duplicate CCB received */
-#define BT_INV_CCB 0x1a /* Invalid CCB or segment list */
-#define BT_ABORTED 42 /* pseudo value from driver */
-
-struct bt_extended_inquire {
- u_char bus_type; /* Type of bus connected to */
-#define BT_BUS_TYPE_24BIT 'A' /* ISA bus */
-#define BT_BUS_TYPE_32BIT 'E' /* EISA/VLB/PCI bus */
-#define BT_BUS_TYPE_MCA 'M' /* MicroChannel bus */
- u_char bios_address; /* Address of adapter BIOS */
- u_short max_segment; /* ? */
-};
-
-struct bt_boardID {
- u_char board_type;
- u_char custom_feture;
- char firm_revision;
- u_char firm_version;
-};
-
-struct bt_board_info {
- u_char id[4]; /* i.e bt742a -> '7','4','2','A' */
- u_char version[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */
-};
-
-struct bt_setup {
- u_char sync_neg:1;
- u_char parity:1;
- u_char :6;
- u_char speed;
- u_char bus_on;
- u_char bus_off;
- u_char num_mbx;
- u_char mbx[3]; /*XXX */
- /* doesn't make sense with 32bit addresses */
- struct {
- u_char offset:4;
- u_char period:3;
- u_char valid:1;
- } sync[8];
- u_char disc_sts;
-};
-
-struct bt_config {
- u_char chan;
- u_char intr;
- u_char scsi_dev:3;
- u_char :5;
-};
-
-#define INT9 0x01
-#define INT10 0x02
-#define INT11 0x04
-#define INT12 0x08
-#define INT14 0x20
-#define INT15 0x40
-
-#define EISADMA 0x00
-#define CHAN0 0x01
-#define CHAN5 0x20
-#define CHAN6 0x40
-#define CHAN7 0x80
-
#define KVTOPHYS(x) vtophys(x)
struct bt_softc {
int sc_iobase;
int sc_irq, sc_drq;
+ char sc_model[7],
+ sc_firmware[6];
+
struct bt_mbx sc_mbx; /* all our mailboxes */
+#define wmbx (&sc->sc_mbx)
struct bt_ccb *sc_ccbhash[CCB_HASH_SIZE];
- TAILQ_HEAD(, bt_ccb) sc_free_ccb;
- int sc_numccbs;
+ TAILQ_HEAD(, bt_ccb) sc_free_ccb, sc_waiting_ccb;
+ int sc_numccbs, sc_mbofull;
int sc_scsi_dev; /* adapters scsi id */
struct scsi_link sc_link; /* prototype for devs */
};
-/***********debug values *************/
-#define BT_SHOWCCBS 0x01
-#define BT_SHOWINTS 0x02
-#define BT_SHOWCMDS 0x04
-#define BT_SHOWMISC 0x08
+#ifdef BTDEBUG
int bt_debug = 0;
+#endif /* BTDEBUG */
-int bt_cmd __P((int, struct bt_softc *, int, int, int, u_char *,
- unsigned, ...));
+int bt_cmd __P((int, struct bt_softc *, int, u_char *, int, u_char *));
+integrate void bt_finish_ccbs __P((struct bt_softc *));
int btintr __P((void *));
-void bt_free_ccb __P((struct bt_softc *, struct bt_ccb *, int));
+integrate void bt_reset_ccb __P((struct bt_softc *, struct bt_ccb *));
+void bt_free_ccb __P((struct bt_softc *, struct bt_ccb *));
+integrate void bt_init_ccb __P((struct bt_softc *, struct bt_ccb *));
struct bt_ccb *bt_get_ccb __P((struct bt_softc *, int));
struct bt_ccb *bt_ccb_phys_kv __P((struct bt_softc *, u_long));
-struct bt_mbx_out *bt_send_mbo __P((struct bt_softc *, int, struct bt_ccb *));
+void bt_queue_ccb __P((struct bt_softc *, struct bt_ccb *));
+void bt_collect_mbo __P((struct bt_softc *));
+void bt_start_ccbs __P((struct bt_softc *));
void bt_done __P((struct bt_softc *, struct bt_ccb *));
int bt_find __P((struct isa_attach_args *, struct bt_softc *));
void bt_init __P((struct bt_softc *));
int bt_scsi_cmd __P((struct scsi_xfer *));
int bt_poll __P((struct bt_softc *, struct scsi_xfer *, int));
void bt_timeout __P((void *arg));
-#ifdef UTEST
-void bt_print_ccb __P((struct bt_ccb *));
-void bt_print_active_ccbs __P((struct bt_softc *));
-#endif
struct scsi_adapter bt_switch = {
bt_scsi_cmd,
void btattach __P((struct device *, struct device *, void *));
int btprint __P((void *, char *));
-struct cfdriver btcd = {
- NULL, "bt", btprobe, btattach, DV_DULL, sizeof(struct bt_softc)
+struct cfattach bt_ca = {
+ sizeof(struct bt_softc), btprobe, btattach
+};
+
+struct cfdriver bt_cd = {
+ NULL, "bt", DV_DULL
};
-#define BT_RESET_TIMEOUT 1000
+#define BT_RESET_TIMEOUT 2000 /* time to wait for reset (mSec) */
+#define BT_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */
/*
- * bt_cmd(iobase, sc, icnt, ocnt, wait, retval, opcode, ... args ...)
+ * bt_cmd(iobase, sc, icnt, ibuf, ocnt, obuf)
*
* Activate Adapter command
- * icnt: number of args (outbound bytes written after opcode)
+ * icnt: number of args (outbound bytes including opcode)
+ * ibuf: argument buffer
* ocnt: number of expected returned bytes
+ * obuf: result buffer
* wait: number of seconds to wait for response
- * retval: buffer where to place returned bytes
- * opcode: opcode BT_NOP, BT_MBX_INIT, BT_START_SCSI ...
- * args: variable number of parameters
*
* Performs an adapter command through the ports. Not to be confused with a
* scsi command, which is read in via the dma; one of the adapter commands
* tells it to read in a scsi command.
*/
int
-#ifdef __STDC__
-bt_cmd(int iobase, struct bt_softc *sc, int icnt, int ocnt, int wait,
- u_char *retval, unsigned opcode, ...)
-#else
-bt_cmd(iobase, sc, icnt, ocnt, wait, retval, opcode, va_alist)
+bt_cmd(iobase, sc, icnt, ibuf, ocnt, obuf)
int iobase;
struct bt_softc *sc;
- int icnt, ocnt, wait;
- u_char *retval;
- unsigned opcode;
- va_dcl
-#endif
+ int icnt, ocnt;
+ u_char *ibuf, *obuf;
{
- va_list ap;
- unsigned data;
const char *name;
- u_char oc;
- register i;
- int sts;
+ register int i;
+ int wait;
+ u_char sts;
+ u_char opcode = ibuf[0];
if (sc == NULL)
name = sc->sc_dev.dv_xname;
name = "(probe)";
/*
- * multiply the wait argument by a big constant
- * zero defaults to 1
+ * Calculate a reasonable timeout for the command.
*/
- if (wait)
- wait *= 100000;
- else
- wait = 100000;
+ switch (opcode) {
+ case BT_INQUIRE_DEVICES:
+ wait = 15 * 20000;
+ break;
+ default:
+ wait = 1 * 20000;
+ break;
+ }
+
/*
* Wait for the adapter to go idle, unless it's one of
* the commands which don't need this
*/
- if (opcode != BT_MBX_INIT && opcode != BT_START_SCSI) {
- i = 100000; /* 1 sec? */
- while (--i) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (sts & BT_IDLE) {
+ if (opcode != BT_MBO_INTR_EN) {
+ for (i = 20000; i; i--) { /* 1 sec? */
+ sts = inb(iobase + BT_STAT_PORT);
+ if (sts & BT_STAT_IDLE)
break;
- }
- delay(10);
+ delay(50);
}
if (!i) {
printf("%s: bt_cmd, host not idle(0x%x)\n",
- name, sts);
+ name, sts);
return ENXIO;
}
}
* queue feeding to us.
*/
if (ocnt) {
- while ((inb(iobase + BT_CTRL_STAT_PORT)) & BT_DF)
- inb(iobase + BT_CMD_DATA_PORT);
+ while ((inb(iobase + BT_STAT_PORT)) & BT_STAT_DF)
+ inb(iobase + BT_DATA_PORT);
}
/*
* Output the command and the number of arguments given
* for each byte, first check the port is empty.
*/
- va_start(ap, opcode);
- /* test icnt >= 0, to include the command in data sent */
- for (data = opcode; icnt >= 0; icnt--, data = va_arg(ap, u_char)) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
+ while (icnt--) {
for (i = wait; i; i--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (!(sts & BT_CDF))
+ sts = inb(iobase + BT_STAT_PORT);
+ if (!(sts & BT_STAT_CDF))
break;
- delay(10);
+ delay(50);
}
if (!i) {
- printf("%s: bt_cmd, cmd/data port full\n", name);
- outb(iobase + BT_CTRL_STAT_PORT, BT_SRST);
- va_end(ap);
+ if (opcode != BT_INQUIRE_REVISION)
+ printf("%s: bt_cmd, cmd/data port full\n", name);
+ outb(iobase + BT_CTRL_PORT, BT_CTRL_SRST);
return ENXIO;
}
- outb(iobase + BT_CMD_DATA_PORT, data);
+ outb(iobase + BT_CMD_PORT, *ibuf++);
}
- va_end(ap);
/*
* If we expect input, loop that many times, each time,
* looking for the data register to have valid data
*/
while (ocnt--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
for (i = wait; i; i--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (sts & BT_DF)
+ sts = inb(iobase + BT_STAT_PORT);
+ if (sts & BT_STAT_DF)
break;
- delay(10);
+ delay(50);
}
if (!i) {
- printf("bt%d: bt_cmd, cmd/data port empty %d\n",
- name, ocnt);
+ if (opcode != BT_INQUIRE_REVISION)
+ printf("%s: bt_cmd, cmd/data port empty %d\n",
+ name, ocnt);
+ outb(iobase + BT_CTRL_PORT, BT_CTRL_SRST);
return ENXIO;
}
- oc = inb(iobase + BT_CMD_DATA_PORT);
- if (retval)
- *retval++ = oc;
+ *obuf++ = inb(iobase + BT_DATA_PORT);
}
/*
- * Wait for the board to report a finised instruction
+ * Wait for the board to report a finished instruction.
+ * We may get an extra interrupt for the HACC signal, but this is
+ * unimportant.
*/
- i = 100000; /* 1 sec? */
- while (--i) {
- sts = inb(iobase + BT_INTR_PORT);
- if (sts & BT_HACC)
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: bt_cmd, host not finished(0x%x)\n",
- name, sts);
- return ENXIO;
+ if (opcode != BT_MBO_INTR_EN) {
+ for (i = 20000; i; i--) { /* 1 sec? */
+ sts = inb(iobase + BT_INTR_PORT);
+ /* XXX Need to save this in the interrupt handler? */
+ if (sts & BT_INTR_HACC)
+ break;
+ delay(50);
+ }
+ if (!i) {
+ printf("%s: bt_cmd, host not finished(0x%x)\n",
+ name, sts);
+ return ENXIO;
+ }
}
- outb(iobase + BT_CTRL_STAT_PORT, BT_IRST);
+ outb(iobase + BT_CTRL_PORT, BT_CTRL_IRST);
return 0;
}
struct device *parent;
void *match, *aux;
{
- struct bt_softc *sc = match;
register struct isa_attach_args *ia = aux;
#ifdef NEWCONFIG
return 0;
#endif
- /*
- * Try initialise a unit at this location
- * sets up dma and bus speed, loads sc->sc_irq
- */
+ /* See if there is a unit at this location. */
if (bt_find(ia, NULL) != 0)
return 0;
ia->ia_msize = 0;
ia->ia_iosize = 4;
- /* IRQ and DRQ set by bt_find() */
+ /* IRQ and DRQ set by bt_find(). */
return 1;
}
void *aux;
char *name;
{
+
if (name != NULL)
printf("%s: scsibus ", name);
return UNCONF;
void *aux;
{
struct isa_attach_args *ia = aux;
- struct bt_softc *sc = (struct bt_softc *)self;
+ struct bt_softc *sc = (void *)self;
if (bt_find(ia, sc) != 0)
panic("btattach: bt_find of %s failed", self->dv_xname);
if (sc->sc_drq != DRQUNK)
isa_dmacascade(sc->sc_drq);
+ bt_inquire_setup_information(sc);
bt_init(sc);
TAILQ_INIT(&sc->sc_free_ccb);
+ TAILQ_INIT(&sc->sc_waiting_ccb);
/*
* fill in the prototype scsi_link.
sc->sc_link.adapter_target = sc->sc_scsi_dev;
sc->sc_link.adapter = &bt_switch;
sc->sc_link.device = &bt_dev;
- sc->sc_link.openings = 2;
-
- printf("\n");
+ sc->sc_link.openings = 4;
#ifdef NEWCONFIG
isa_establish(&sc->sc_id, &sc->sc_dev);
#endif
- sc->sc_ih = isa_intr_establish(sc->sc_irq, IST_EDGE, IPL_BIO, btintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, sc->sc_irq, IST_EDGE,
+ IPL_BIO, btintr, sc, sc->sc_dev.dv_xname);
/*
* ask the adapter what subunits are present
config_found(self, &sc->sc_link, btprint);
}
-/*
- * Catch an interrupt from the adaptor
- */
-int
-btintr(arg)
- void *arg;
+integrate void
+bt_finish_ccbs(sc)
+ struct bt_softc *sc;
{
- struct bt_softc *sc = arg;
- int iobase = sc->sc_iobase;
struct bt_mbx_in *wmbi;
- struct bt_mbx *wmbx;
struct bt_ccb *ccb;
- u_char stat;
int i;
- int found = 0;
-#ifdef BTDEBUG
- printf("%s: btintr ", sc->sc_dev.dv_xname);
-#endif /* BTDEBUG */
-
- /*
- * First acknowlege the interrupt, Then if it's
- * not telling about a completed operation
- * just return.
- */
- stat = inb(iobase + BT_INTR_PORT);
- if ((stat & (BT_MBOA | BT_MBIF)) == 0) {
- outb(iobase + BT_CTRL_STAT_PORT, BT_IRST);
- return -1; /* XXX */
- }
+ wmbi = wmbx->tmbi;
- /* Mail box out empty? */
- if (stat & BT_MBOA) {
- /* Disable MBO available interrupt. */
- outb(iobase + BT_CMD_DATA_PORT, BT_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(iobase + BT_CTRL_STAT_PORT) & BT_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: btintr, cmd/data port full\n",
- sc->sc_dev.dv_xname);
- outb(iobase + BT_CTRL_STAT_PORT, BT_SRST);
- return 1;
+ if (wmbi->stat == BT_MBI_FREE) {
+ for (i = 0; i < BT_MBX_SIZE; i++) {
+ if (wmbi->stat != BT_MBI_FREE) {
+ printf("%s: mbi not in round-robin order\n",
+ sc->sc_dev.dv_xname);
+ goto AGAIN;
+ }
+ bt_nextmbx(wmbi, wmbx, mbi);
}
- outb(iobase + BT_CMD_DATA_PORT, 0x00); /* Disable */
- wakeup(&sc->sc_mbx);
+#ifdef BTDIAGnot
+ printf("%s: mbi interrupt with no full mailboxes\n",
+ sc->sc_dev.dv_xname);
+#endif
+ return;
}
- /* Mail box in full? */
- if ((stat & BT_MBIF) == 0)
- return 1;
- wmbx = &sc->sc_mbx;
- wmbi = wmbx->tmbi;
AGAIN:
- while (wmbi->stat != BT_MBI_FREE) {
- ccb = bt_ccb_phys_kv(sc, wmbi->ccb_addr);
+ do {
+ ccb = bt_ccb_phys_kv(sc, phystol(wmbi->ccb_addr));
if (!ccb) {
- wmbi->stat = BT_MBI_FREE;
- printf("%s: BAD CCB ADDR!\n", sc->sc_dev.dv_xname);
- continue;
+ printf("%s: bad mbi ccb pointer; skipping\n",
+ sc->sc_dev.dv_xname);
+ goto next;
+ }
+
+#ifdef BTDEBUG
+ if (bt_debug) {
+ u_char *cp = &ccb->scsi_cmd;
+ printf("op=%x %x %x %x %x %x\n",
+ cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
+ printf("stat %x for mbi addr = 0x%08x, ",
+ wmbi->stat, wmbi);
+ printf("ccb addr = 0x%x\n", ccb);
}
- found++;
+#endif /* BTDEBUG */
+
switch (wmbi->stat) {
case BT_MBI_OK:
case BT_MBI_ERROR:
+ if ((ccb->flags & CCB_ABORT) != 0) {
+ /*
+ * If we already started an abort, wait for it
+ * to complete before clearing the CCB. We
+ * could instead just clear CCB_SENDING, but
+ * what if the mailbox was already received?
+ * The worst that happens here is that we clear
+ * the CCB a bit later than we need to. BFD.
+ */
+ goto next;
+ }
break;
case BT_MBI_ABORT:
- ccb->host_stat = BT_ABORTED;
- break;
-
case BT_MBI_UNKNOWN:
- ccb = 0;
+ /*
+ * Even if the CCB wasn't found, we clear it anyway.
+ * See preceeding comment.
+ */
break;
default:
- panic("Impossible mbxi status");
+ printf("%s: bad mbi status %02x; skipping\n",
+ sc->sc_dev.dv_xname, wmbi->stat);
+ goto next;
}
-#ifdef BTDEBUG
- if (bt_debug && ccb) {
- u_char *cp = &ccb->scsi_cmd;
- printf("op=%x %x %x %x %x %x\n",
- cp[0], cp[1], cp[2],
- cp[3], cp[4], cp[5]);
- printf("stat %x for mbi addr = 0x%08x, ",
- wmbi->stat, wmbi);
- printf("ccb addr = 0x%x\n", ccb);
- }
-#endif /* BTDEBUG */
+
+ untimeout(bt_timeout, ccb);
+ bt_done(sc, ccb);
+
+ next:
wmbi->stat = BT_MBI_FREE;
- if (ccb) {
- untimeout(bt_timeout, ccb);
- bt_done(sc, ccb);
- }
bt_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
- for (i = 0; i < BT_MBX_SIZE; i++) {
- if (wmbi->stat != BT_MBI_FREE) {
- found++;
- break;
- }
- bt_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
-#if 0
- printf("%s: mbi interrupt with no full mailboxes\n",
- sc->sc_dev.dv_xname);
+ } while (wmbi->stat != BT_MBI_FREE);
+
+ wmbx->tmbi = wmbi;
+}
+
+/*
+ * Catch an interrupt from the adaptor
+ */
+int
+btintr(arg)
+ void *arg;
+{
+ struct bt_softc *sc = arg;
+ int iobase = sc->sc_iobase;
+ u_char sts;
+
+#ifdef BTDEBUG
+ printf("%s: btintr ", sc->sc_dev.dv_xname);
+#endif /* BTDEBUG */
+
+ /*
+ * First acknowlege the interrupt, Then if it's not telling about
+ * a completed operation just return.
+ */
+ sts = inb(iobase + BT_INTR_PORT);
+ if ((sts & BT_INTR_ANYINTR) == 0)
+ return 0;
+ outb(iobase + BT_CTRL_PORT, BT_CTRL_IRST);
+
+#ifdef BTDIAG
+ /* Make sure we clear CCB_SENDING before finishing a CCB. */
+ bt_collect_mbo(sc);
#endif
- } else {
- found = 0;
- goto AGAIN;
- }
+
+ /* Mail box out empty? */
+ if (sts & BT_INTR_MBOA) {
+ struct bt_toggle toggle;
+
+ toggle.cmd.opcode = BT_MBO_INTR_EN;
+ toggle.cmd.enable = 0;
+ bt_cmd(iobase, sc, sizeof(toggle.cmd), (u_char *)&toggle.cmd, 0,
+ (u_char *)0);
+ bt_start_ccbs(sc);
}
- wmbx->tmbi = wmbi;
- outb(iobase + BT_CTRL_STAT_PORT, BT_IRST);
+
+ /* Mail box in full? */
+ if (sts & BT_INTR_MBIF)
+ bt_finish_ccbs(sc);
+
return 1;
}
+integrate void
+bt_reset_ccb(sc, ccb)
+ struct bt_softc *sc;
+ struct bt_ccb *ccb;
+{
+
+ ccb->flags = 0;
+}
+
/*
* A ccb is put onto the free list.
*/
void
-bt_free_ccb(sc, ccb, flags)
+bt_free_ccb(sc, ccb)
struct bt_softc *sc;
struct bt_ccb *ccb;
- int flags;
{
int s;
s = splbio();
- ccb->flags = CCB_FREE;
+ bt_reset_ccb(sc, ccb);
TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
/*
splx(s);
}
-static inline void
+integrate void
bt_init_ccb(sc, ccb)
struct bt_softc *sc;
struct bt_ccb *ccb;
hashnum = CCB_HASH(ccb->hashkey);
ccb->nexthash = sc->sc_ccbhash[hashnum];
sc->sc_ccbhash[hashnum] = ccb;
-}
-
-static inline void
-bt_reset_ccb(sc, ccb)
- struct bt_softc *sc;
- struct bt_ccb *ccb;
-{
-
+ bt_reset_ccb(sc, ccb);
}
/*
break;
}
if (sc->sc_numccbs < BT_CCB_MAX) {
- if (ccb = (struct bt_ccb *) malloc(sizeof(struct bt_ccb),
- M_TEMP, M_NOWAIT)) {
- bt_init_ccb(sc, ccb);
- sc->sc_numccbs++;
- } else {
+ ccb = (struct bt_ccb *) malloc(sizeof(struct bt_ccb),
+ M_TEMP, M_NOWAIT);
+ if (!ccb) {
printf("%s: can't malloc ccb\n",
sc->sc_dev.dv_xname);
goto out;
}
+ bt_init_ccb(sc, ccb);
+ sc->sc_numccbs++;
break;
}
if ((flags & SCSI_NOSLEEP) != 0)
tsleep(&sc->sc_free_ccb, PRIBIO, "btccb", 0);
}
- bt_reset_ccb(sc, ccb);
- ccb->flags = CCB_ACTIVE;
+ ccb->flags |= CCB_ALLOC;
out:
splx(s);
}
/*
- * given a physical address, find the ccb that
- * it corresponds to:
+ * Given a physical address, find the ccb that it corresponds to.
*/
struct bt_ccb *
bt_ccb_phys_kv(sc, ccb_phys)
}
/*
- * Get a mbo and send the ccb.
+ * Queue a CCB to be sent to the controller, and send it if possible.
+ */
+void
+bt_queue_ccb(sc, ccb)
+ struct bt_softc *sc;
+ struct bt_ccb *ccb;
+{
+
+ TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain);
+ bt_start_ccbs(sc);
+}
+
+/*
+ * Garbage collect mailboxes that are no longer in use.
*/
-struct bt_mbx_out *
-bt_send_mbo(sc, cmd, ccb)
+void
+bt_collect_mbo(sc)
struct bt_softc *sc;
- int cmd;
+{
+ struct bt_mbx_out *wmbo; /* Mail Box Out pointer */
struct bt_ccb *ccb;
+
+ wmbo = wmbx->cmbo;
+
+ while (sc->sc_mbofull > 0) {
+ if (wmbo->cmd != BT_MBO_FREE)
+ break;
+
+#ifdef BTDIAG
+ ccb = bt_ccb_phys_kv(sc, phystol(wmbo->ccb_addr));
+ ccb->flags &= ~CCB_SENDING;
+#endif
+
+ --sc->sc_mbofull;
+ bt_nextmbx(wmbo, wmbx, mbo);
+ }
+
+ wmbx->cmbo = wmbo;
+}
+
+/*
+ * Send as many CCBs as we have empty mailboxes for.
+ */
+void
+bt_start_ccbs(sc)
+ struct bt_softc *sc;
{
int iobase = sc->sc_iobase;
struct bt_mbx_out *wmbo; /* Mail Box Out pointer */
- struct bt_mbx *wmbx; /* Mail Box pointer specified unit */
+ struct bt_ccb *ccb;
int i;
- /* Get the target out mail box pointer and increment. */
- wmbx = &sc->sc_mbx;
wmbo = wmbx->tmbo;
- bt_nextmbx(wmbx->tmbo, wmbx, mbo);
- /*
- * Check the outmail box is free or not.
- * Note: Under the normal operation, it shuld NOT happen to wait.
- */
- while (wmbo->cmd != BT_MBO_FREE) {
- /* Enable mbo available interrupt. */
- outb(iobase + BT_CMD_DATA_PORT, BT_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(iobase + BT_CTRL_STAT_PORT) & BT_CDF))
+ while (ccb = sc->sc_waiting_ccb.tqh_first) {
+ if (sc->sc_mbofull >= BT_MBX_SIZE) {
+ bt_collect_mbo(sc);
+ if (sc->sc_mbofull >= BT_MBX_SIZE) {
+ struct bt_toggle toggle;
+
+ toggle.cmd.opcode = BT_MBO_INTR_EN;
+ toggle.cmd.enable = 1;
+ bt_cmd(iobase, sc, sizeof(toggle.cmd),
+ (u_char *)&toggle.cmd, 0, (u_char *)0);
break;
- delay(10);
- }
- if (!i) {
- printf("%s: bt_send_mbo, cmd/data port full\n",
- sc->sc_dev.dv_xname);
- outb(iobase + BT_CTRL_STAT_PORT, BT_SRST);
- return NULL;
+ }
}
- outb(iobase + BT_CMD_DATA_PORT, 0x01); /* Enable */
- tsleep(wmbx, PRIBIO, "btsnd", 0);/*XXX can't do this */
- }
- /* Link ccb to mbo. */
- wmbo->ccb_addr = KVTOPHYS(ccb);
- ccb->mbx = wmbo;
- wmbo->cmd = cmd;
+ TAILQ_REMOVE(&sc->sc_waiting_ccb, ccb, chain);
+#ifdef BTDIAG
+ ccb->flags |= CCB_SENDING;
+#endif
+
+ /* Link ccb to mbo. */
+ ltophys(KVTOPHYS(ccb), wmbo->ccb_addr);
+ if (ccb->flags & CCB_ABORT)
+ wmbo->cmd = BT_MBO_ABORT;
+ else
+ wmbo->cmd = BT_MBO_START;
+
+ /* Tell the card to poll immediately. */
+ outb(iobase + BT_CMD_PORT, BT_START_SCSI);
+
+ if ((ccb->xs->flags & SCSI_POLL) == 0)
+ timeout(bt_timeout, ccb, (ccb->timeout * hz) / 1000);
- /* Send it! */
- outb(iobase + BT_CMD_DATA_PORT, BT_START_SCSI);
+ ++sc->sc_mbofull;
+ bt_nextmbx(wmbo, wmbx, mbo);
+ }
- return wmbo;
+ wmbx->tmbo = wmbo;
}
/*
* Otherwise, put the results of the operation
* into the xfer and call whoever started it
*/
- if ((xs->flags & INUSE) == 0) {
- printf("%s: exiting but not in use!\n", sc->sc_dev.dv_xname);
+#ifdef BTDIAG
+ if (ccb->flags & CCB_SENDING) {
+ printf("%s: exiting ccb still in transit!\n", sc->sc_dev.dv_xname);
Debugger();
+ return;
+ }
+#endif
+ if ((ccb->flags & CCB_ALLOC) == 0) {
+ printf("%s: exiting ccb not allocated!\n", sc->sc_dev.dv_xname);
+ Debugger();
+ return;
}
if (xs->error == XS_NOERROR) {
if (ccb->host_stat != BT_OK) {
switch (ccb->host_stat) {
- case BT_ABORTED:
- xs->error = XS_DRIVER_STUFFUP;
- break;
case BT_SEL_TIMEOUT: /* No response */
xs->error = XS_SELTIMEOUT;
break;
printf("%s: host_stat %x\n",
sc->sc_dev.dv_xname, ccb->host_stat);
xs->error = XS_DRIVER_STUFFUP;
+ break;
}
} else if (ccb->target_stat != SCSI_OK) {
switch (ccb->target_stat) {
printf("%s: target_stat %x\n",
sc->sc_dev.dv_xname, ccb->target_stat);
xs->error = XS_DRIVER_STUFFUP;
+ break;
}
} else
xs->resid = 0;
}
+ bt_free_ccb(sc, ccb);
xs->flags |= ITSDONE;
- bt_free_ccb(sc, ccb, xs->flags);
scsi_done(xs);
}
struct bt_softc *sc;
{
int iobase = ia->ia_iobase;
- u_char ad[4];
- volatile int i, sts;
- struct bt_extended_inquire info;
- struct bt_config conf;
+ int i;
+ u_char sts;
+ struct bt_extended_inquire inquire;
+ struct bt_config config;
int irq, drq;
/*
* that it's not there.. good for the probe
*/
- outb(iobase + BT_CTRL_STAT_PORT, BT_HRST | BT_SRST);
+ outb(iobase + BT_CTRL_PORT, BT_CTRL_HRST | BT_CTRL_SRST);
+ delay(100);
for (i = BT_RESET_TIMEOUT; i; i--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (sts == (BT_IDLE | BT_INIT))
+ sts = inb(iobase + BT_STAT_PORT);
+ if (sts == (BT_STAT_IDLE | BT_STAT_INIT))
break;
delay(1000);
}
if (!i) {
-#ifdef UTEST
- printf("bt_find: No answer from bt742a board\n");
-#endif
+#ifdef BTDEBUG
+ if (bt_debug)
+ printf("bt_find: No answer from buslogic board\n");
+#endif /* BTDEBUG */
return 1;
}
* Check that we actually know how to use this board.
*/
delay(1000);
- bt_cmd(iobase, sc, 1, sizeof(info), 0, (u_char *)&info,
- BT_INQUIRE_EXTENDED, sizeof(info));
- switch (info.bus_type) {
+ inquire.cmd.opcode = BT_INQUIRE_EXTENDED;
+ inquire.cmd.len = sizeof(inquire.reply);
+ bt_cmd(iobase, sc, sizeof(inquire.cmd), (u_char *)&inquire.cmd,
+ sizeof(inquire.reply), (u_char *)&inquire.reply);
+ switch (inquire.reply.bus_type) {
case BT_BUS_TYPE_24BIT:
/* XXXX How do we avoid conflicting with the aha1542 probe? */
case BT_BUS_TYPE_32BIT:
/* We don't grok MicroChannel (yet). */
return 1;
default:
- printf("bt_find: illegal bus type %c\n", info.bus_type);
+ printf("bt_find: illegal bus type %c\n", inquire.reply.bus_type);
return 1;
}
* jumpers and save int level
*/
delay(1000);
- bt_cmd(iobase, sc, 0, sizeof(conf), 0, (u_char *)&conf, BT_CONF_GET);
- switch (conf.chan) {
+ config.cmd.opcode = BT_INQUIRE_CONFIG;
+ bt_cmd(iobase, sc, sizeof(config.cmd), (u_char *)&config.cmd,
+ sizeof(config.reply), (u_char *)&config.reply);
+ switch (config.reply.chan) {
case EISADMA:
drq = DRQUNK;
break;
drq = 7;
break;
default:
- printf("bt_find: illegal dma setting %x\n", conf.chan);
+ printf("bt_find: illegal drq setting %x\n", config.reply.chan);
return 1;
}
- switch (conf.intr) {
+ switch (config.reply.intr) {
case INT9:
irq = 9;
break;
irq = 15;
break;
default:
- printf("bt_find: illegal int setting %x\n", conf.intr);
+ printf("bt_find: illegal irq setting %x\n", config.reply.intr);
return 1;
}
if (sc != NULL) {
/* who are we on the scsi bus? */
- sc->sc_scsi_dev = conf.scsi_dev;
+ sc->sc_scsi_dev = config.reply.scsi_dev;
sc->sc_iobase = iobase;
sc->sc_irq = irq;
struct bt_softc *sc;
{
int iobase = sc->sc_iobase;
- u_char ad[4];
+ struct bt_devices devices;
+ struct bt_setup setup;
+ struct bt_mailbox mailbox;
+ struct bt_period period;
int i;
- /*
- * Initialize mail box
- */
- *((physaddr *)ad) = KVTOPHYS(&sc->sc_mbx);
+ /* Enable round-robin scheme - appeared at firmware rev. 3.31. */
+ if (strcmp(sc->sc_firmware, "3.31") >= 0) {
+ struct bt_toggle toggle;
- bt_cmd(iobase, sc, 5, 0, 0, 0, BT_MBX_INIT_EXTENDED, BT_MBX_SIZE,
- ad[0], ad[1], ad[2], ad[3]);
+ toggle.cmd.opcode = BT_ROUND_ROBIN;
+ toggle.cmd.enable = 1;
+ bt_cmd(iobase, sc, sizeof(toggle.cmd), (u_char *)&toggle.cmd,
+ 0, (u_char *)0);
+ }
- for (i = 0; i < BT_MBX_SIZE; i++) {
- sc->sc_mbx.mbo[i].cmd = BT_MBO_FREE;
- sc->sc_mbx.mbi[i].stat = BT_MBI_FREE;
+ /* Inquire Installed Devices (to force synchronous negotiation). */
+ devices.cmd.opcode = BT_INQUIRE_DEVICES;
+ bt_cmd(iobase, sc, sizeof(devices.cmd), (u_char *)&devices.cmd,
+ sizeof(devices.reply), (u_char *)&devices.reply);
+
+ /* Obtain setup information from. */
+ setup.cmd.opcode = BT_INQUIRE_SETUP;
+ setup.cmd.len = sizeof(setup.reply);
+ bt_cmd(iobase, sc, sizeof(setup.cmd), (u_char *)&setup.cmd,
+ sizeof(setup.reply), (u_char *)&setup.reply);
+
+ printf("%s: %s, %s\n",
+ sc->sc_dev.dv_xname,
+ setup.reply.sync_neg ? "sync" : "async",
+ setup.reply.parity ? "parity" : "no parity");
+
+ for (i = 0; i < 8; i++)
+ period.reply.period[i] = setup.reply.sync[i].period * 5 + 20;
+
+ if (sc->sc_firmware[0] >= '3') {
+ period.cmd.opcode = BT_INQUIRE_PERIOD;
+ period.cmd.len = sizeof(period.reply);
+ bt_cmd(iobase, sc, sizeof(period.cmd), (u_char *)&period.cmd,
+ sizeof(period.reply), (u_char *)&period.reply);
+ }
+
+ for (i = 0; i < 8; i++) {
+ if (!setup.reply.sync[i].valid ||
+ (!setup.reply.sync[i].offset && !setup.reply.sync[i].period))
+ continue;
+ printf("%s targ %d: sync, offset %d, period %dnsec\n",
+ sc->sc_dev.dv_xname, i,
+ setup.reply.sync[i].offset, period.reply.period[i] * 10);
}
/*
* Set up initial mail box for round-robin operation.
*/
- sc->sc_mbx.tmbo = &sc->sc_mbx.mbo[0];
- sc->sc_mbx.tmbi = &sc->sc_mbx.mbi[0];
-
- bt_inquire_setup_information(sc);
+ for (i = 0; i < BT_MBX_SIZE; i++) {
+ wmbx->mbo[i].cmd = BT_MBO_FREE;
+ wmbx->mbi[i].stat = BT_MBI_FREE;
+ }
+ wmbx->cmbo = wmbx->tmbo = &wmbx->mbo[0];
+ wmbx->tmbi = &wmbx->mbi[0];
+ sc->sc_mbofull = 0;
+
+ /* Initialize mail box. */
+ mailbox.cmd.opcode = BT_MBX_INIT_EXTENDED;
+ mailbox.cmd.nmbx = BT_MBX_SIZE;
+ ltophys(KVTOPHYS(wmbx), mailbox.cmd.addr);
+ bt_cmd(iobase, sc, sizeof(mailbox.cmd), (u_char *)&mailbox.cmd,
+ 0, (u_char *)0);
}
void
struct bt_softc *sc;
{
int iobase = sc->sc_iobase;
- struct bt_boardID bID;
- struct bt_board_info binfo;
- char dummy[8], sub_ver[3];
- struct bt_setup setup;
- int i, ver;
+ struct bt_model model;
+ struct bt_revision revision;
+ struct bt_digit digit;
+ char dummy[8];
+ char *p;
/*
- * Get and print board hardware information.
+ * Get the firmware revision.
*/
- bt_cmd(iobase, sc, 1, sizeof(binfo), 0, (u_char *)&binfo,
- BT_GET_BOARD_INFO, sizeof(binfo));
- printf(": Bt%c%c%c", binfo.id[0], binfo.id[1], binfo.id[2]);
- if (binfo.id[3] != ' ')
- printf("%c", binfo.id[3]);
- if (binfo.version[0] != ' ')
- printf("%c%s", binfo.version[0], binfo.version[1]);
- printf("\n");
-
- /*
- * Inquire Board ID to Bt742 for board type and firmware version.
- */
- bt_cmd(iobase, sc, 0, sizeof(bID), 0, (u_char *)&bID, BT_INQUIRE);
- ver = (bID.firm_revision - '0') * 10 + (bID.firm_version - '0');
+ p = sc->sc_firmware;
+ revision.cmd.opcode = BT_INQUIRE_REVISION;
+ bt_cmd(iobase, sc, sizeof(revision.cmd), (u_char *)&revision.cmd,
+ sizeof(revision.reply), (u_char *)&revision.reply);
+ *p++ = revision.reply.firm_revision;
+ *p++ = '.';
+ *p++ = revision.reply.firm_version;
+ digit.cmd.opcode = BT_INQUIRE_REVISION_3;
+ bt_cmd(iobase, sc, sizeof(digit.cmd), (u_char *)&digit.cmd,
+ sizeof(digit.reply), (u_char *)&digit.reply);
+ *p++ = digit.reply.digit;
+ if (revision.reply.firm_revision >= '3' ||
+ (revision.reply.firm_revision == '3' && revision.reply.firm_version >= '3')) {
+ digit.cmd.opcode = BT_INQUIRE_REVISION_4;
+ bt_cmd(iobase, sc, sizeof(digit.cmd), (u_char *)&digit.cmd,
+ sizeof(digit.reply), (u_char *)&digit.reply);
+ *p++ = digit.reply.digit;
+ }
+ while (p > sc->sc_firmware && (p[-1] == ' ' || p[-1] == '\0'))
+ p--;
+ *p = '\0';
/*
- * Get the rest of the firmware version. Firmware revisions
- * before 3.3 apparently don't accept the BT_INQUIRE_REV_FOURTH
- * command.
+ * Get the model number.
*/
- i = 0;
- bt_cmd(iobase, sc, 0, 1, 0, &sub_ver[i++], BT_INQUIRE_REV_THIRD);
- if (ver >= 33)
- bt_cmd(iobase, sc, 0, 1, 0, &sub_ver[i++],
- BT_INQUIRE_REV_FOURTH);
- if (sub_ver[i - 1] == ' ')
- i--;
- sub_ver[i] = '\0';
-
- printf("%s: firmware version %c.%c%s, ", sc->sc_dev.dv_xname,
- bID.firm_revision, bID.firm_version, sub_ver);
-
- /* Enable round-robin scheme - appeared at firmware rev. 3.31 */
- if (ver > 33 || (ver == 33 && sub_ver[0] >= 1)) {
- bt_cmd(iobase, sc, 1, 0, 0, 0, BT_ROUND_ROBIN, BT_ENABLE);
- }
-
- /* Inquire Installed Devices (to force synchronous negotiation) */
- bt_cmd(iobase, sc, 0, sizeof(dummy), 10, dummy, BT_DEV_GET);
-
- /* Obtain setup information from Bt742. */
- bt_cmd(iobase, sc, 1, sizeof(setup), 0, (u_char *)&setup, BT_SETUP_GET,
- sizeof(setup));
-
- printf("%s, %s, %d mailboxes",
- setup.sync_neg ? "sync" : "async",
- setup.parity ? "parity" : "no parity",
- setup.num_mbx);
-
- for (i = 0; i < 8; i++) {
- if (!setup.sync[i].valid ||
- (!setup.sync[i].offset && !setup.sync[i].period))
- continue;
- printf("\n%s targ %d: sync, offset %d, period %dnsec",
- sc->sc_dev.dv_xname, i,
- setup.sync[i].offset, setup.sync[i].period * 50 + 200);
- }
+ if (revision.reply.firm_revision >= '3') {
+ p = sc->sc_model;
+ model.cmd.opcode = BT_INQUIRE_MODEL;
+ model.cmd.len = sizeof(model.reply);
+ bt_cmd(iobase, sc, sizeof(model.cmd), (u_char *)&model.cmd,
+ sizeof(model.reply), (u_char *)&model.reply);
+ *p++ = model.reply.id[0];
+ *p++ = model.reply.id[1];
+ *p++ = model.reply.id[2];
+ *p++ = model.reply.id[3];
+ while (p > sc->sc_model && (p[-1] == ' ' || p[-1] == '\0'))
+ p--;
+ *p++ = model.reply.version[0];
+ *p++ = model.reply.version[1];
+ while (p > sc->sc_model && (p[-1] == ' ' || p[-1] == '\0'))
+ p--;
+ *p = '\0';
+ } else
+ strcpy(sc->sc_model, "542B");
+
+ printf(": model BT-%s, firmware %s\n", sc->sc_model, sc->sc_firmware);
}
void
struct bt_ccb *ccb;
struct bt_scat_gath *sg;
int seg; /* scatter gather seg being worked on */
- int thiskv;
- physaddr thisphys, nextphys;
+ u_long thiskv, thisphys, nextphys;
int bytes_this_seg, bytes_this_page, datalen, flags;
struct iovec *iovp;
- struct bt_mbx_out *mbo;
int s;
SC_DEBUG(sc_link, SDEV_DB2, ("bt_scsi_cmd\n"));
* then we can't allow it to sleep
*/
flags = xs->flags;
- if ((flags & (ITSDONE|INUSE)) != INUSE) {
- printf("%s: done or not in use?\n", sc->sc_dev.dv_xname);
- xs->flags &= ~ITSDONE;
- xs->flags |= INUSE;
- }
if ((ccb = bt_get_ccb(sc, flags)) == NULL) {
xs->error = XS_DRIVER_STUFFUP;
return TRY_AGAIN_LATER;
}
ccb->xs = xs;
+ ccb->timeout = xs->timeout;
/*
* Put all the arguments for the xfer in the ccb
*/
if (flags & SCSI_RESET) {
ccb->opcode = BT_RESET_CCB;
+ ccb->scsi_cmd_length = 0;
} else {
/* can't use S/G if zero length */
ccb->opcode = (xs->datalen ? BT_INIT_SCAT_GATH_CCB
: BT_INITIATOR_CCB);
+ bcopy(xs->cmd, &ccb->scsi_cmd,
+ ccb->scsi_cmd_length = xs->cmdlen);
}
- ccb->data_out = 0;
- ccb->data_in = 0;
- ccb->target = sc_link->target;
- ccb->lun = sc_link->lun;
- ccb->scsi_cmd_length = xs->cmdlen;
- ccb->sense_ptr = KVTOPHYS(&ccb->scsi_sense);
- ccb->req_sense_length = sizeof(ccb->scsi_sense);
- ccb->host_stat = 0x00;
- ccb->target_stat = 0x00;
- if (xs->datalen && (flags & SCSI_RESET) == 0) {
- ccb->data_addr = KVTOPHYS(ccb->scat_gath);
+ if (xs->datalen) {
sg = ccb->scat_gath;
seg = 0;
#ifdef TFS
datalen = ((struct uio *)xs->data)->uio_iovcnt;
xs->datalen = 0;
while (datalen && seg < BT_NSEG) {
- sg->seg_addr = (physaddr)iovp->iov_base;
- sg->seg_len = iovp->iov_len;
+ ltophys(iovp->iov_base, sg->seg_addr);
+ ltophys(iovp->iov_len, sg->seg_len);
xs->datalen += iovp->iov_len;
SC_DEBUGN(sc_link, SDEV_DB4, ("(0x%x@0x%x)",
iovp->iov_len, iovp->iov_base));
#endif /* TFS */
{
/*
- * Set up the scatter gather block
+ * Set up the scatter-gather block.
*/
SC_DEBUG(sc_link, SDEV_DB4,
("%d @0x%x:- ", xs->datalen, xs->data));
+
datalen = xs->datalen;
- thiskv = (int) xs->data;
+ thiskv = (int)xs->data;
thisphys = KVTOPHYS(thiskv);
while (datalen && seg < BT_NSEG) {
bytes_this_seg = 0;
/* put in the base address */
- sg->seg_addr = thisphys;
+ ltophys(thisphys, sg->seg_addr);
SC_DEBUGN(sc_link, SDEV_DB4, ("0x%x", thisphys));
*/
SC_DEBUGN(sc_link, SDEV_DB4,
("(0x%x)", bytes_this_seg));
- sg->seg_len = bytes_this_seg;
+ ltophys(bytes_this_seg, sg->seg_len);
sg++;
seg++;
}
}
/* end of iov/kv decision */
- ccb->data_length = seg * sizeof(struct bt_scat_gath);
SC_DEBUGN(sc_link, SDEV_DB4, ("\n"));
if (datalen) {
/*
*/
printf("%s: bt_scsi_cmd, more than %d dma segs\n",
sc->sc_dev.dv_xname, BT_NSEG);
- xs->error = XS_DRIVER_STUFFUP;
- bt_free_ccb(sc, ccb, flags);
- return COMPLETE;
+ goto bad;
}
+ ltophys(KVTOPHYS(ccb->scat_gath), ccb->data_addr);
+ ltophys(seg * sizeof(struct bt_scat_gath), ccb->data_length);
} else { /* No data xfer, use non S/G values */
- ccb->data_addr = (physaddr)0;
- ccb->data_length = 0;
+ ltophys(0, ccb->data_addr);
+ ltophys(0, ccb->data_length);
}
- ccb->link_id = 0;
- ccb->link_addr = (physaddr)0;
- /*
- * Put the scsi command in the ccb and start it
- */
- if ((flags & SCSI_RESET) == 0)
- bcopy(xs->cmd, &ccb->scsi_cmd, ccb->scsi_cmd_length);
+ ccb->data_out = 0;
+ ccb->data_in = 0;
+ ccb->target = sc_link->target;
+ ccb->lun = sc_link->lun;
+ ltophys(KVTOPHYS(&ccb->scsi_sense), ccb->sense_ptr);
+ ccb->req_sense_length = sizeof(ccb->scsi_sense);
+ ccb->host_stat = 0x00;
+ ccb->target_stat = 0x00;
+ ccb->link_id = 0;
+ ltophys(0, ccb->link_addr);
s = splbio();
-
- if (bt_send_mbo(sc, BT_MBO_START, ccb) == NULL) {
- splx(s);
- xs->error = XS_DRIVER_STUFFUP;
- bt_free_ccb(sc, ccb, flags);
- return TRY_AGAIN_LATER;
- }
+ bt_queue_ccb(sc, ccb);
+ splx(s);
/*
* Usually return SUCCESSFULLY QUEUED
*/
SC_DEBUG(sc_link, SDEV_DB3, ("cmd_sent\n"));
- if ((flags & SCSI_POLL) == 0) {
- timeout(bt_timeout, ccb, (xs->timeout * hz) / 1000);
- splx(s);
+ if ((flags & SCSI_POLL) == 0)
return SUCCESSFULLY_QUEUED;
- }
-
- splx(s);
/*
* If we can't use interrupts, poll on completion
*/
- if (bt_poll(sc, xs, xs->timeout)) {
+ if (bt_poll(sc, xs, ccb->timeout)) {
bt_timeout(ccb);
- if (bt_poll(sc, xs, 2000))
+ if (bt_poll(sc, xs, ccb->timeout))
bt_timeout(ccb);
}
return COMPLETE;
+
+bad:
+ xs->error = XS_DRIVER_STUFFUP;
+ bt_free_ccb(sc, ccb);
+ return COMPLETE;
}
/*
* If we had interrupts enabled, would we
* have got an interrupt?
*/
- if (inb(iobase + BT_INTR_PORT) & BT_ANY_INTR)
+ if (inb(iobase + BT_INTR_PORT) & BT_INTR_ANYINTR)
btintr(sc);
if (xs->flags & ITSDONE)
return 0;
s = splbio();
+#ifdef BTDIAG
/*
* If the ccb's mbx is not free, then the board has gone Far East?
*/
- if (bt_ccb_phys_kv(sc, ccb->mbx->ccb_addr) == ccb &&
- ccb->mbx->cmd != BT_MBO_FREE) {
+ bt_collect_mbo(sc);
+ if (ccb->flags & CCB_SENDING) {
printf("%s: not taking commands!\n", sc->sc_dev.dv_xname);
Debugger();
}
+#endif
/*
* If it has been through before, then
* a previous abort has failed, don't
* try abort again
*/
- if (ccb->flags == CCB_ABORTED) {
+ if (ccb->flags & CCB_ABORT) {
/* abort timed out */
printf(" AGAIN\n");
- ccb->xs->retries = 0;
- bt_done(sc, ccb);
+ /* XXX Must reset! */
} else {
/* abort the operation that has timed out */
printf("\n");
ccb->xs->error = XS_TIMEOUT;
- ccb->flags = CCB_ABORTED;
- bt_send_mbo(sc, BT_MBO_ABORT, ccb);
- /* 2 secs for the abort */
- if ((xs->flags & SCSI_POLL) == 0)
- timeout(bt_timeout, ccb, 2 * hz);
+ ccb->timeout = BT_ABORT_TIMEOUT;
+ ccb->flags |= CCB_ABORT;
+ bt_queue_ccb(sc, ccb);
}
splx(s);
}
-
-#ifdef UTEST
-void
-bt_print_ccb(ccb)
- struct bt_ccb *ccb;
-{
-
- printf("ccb:%x op:%x cmdlen:%d senlen:%d\n",
- ccb, ccb->opcode, ccb->scsi_cmd_length, ccb->req_sense_length);
- printf(" datlen:%d hstat:%x tstat:%x flags:%x\n",
- ccb->data_length, ccb->host_stat, ccb->target_stat, ccb->flags);
-}
-
-void
-bt_print_active_ccbs(sc)
- struct bt_softc *sc;
-{
- struct bt_ccb *ccb;
- int i = 0;
-
- while (i < CCB_HASH_SIZE) {
- ccb = sc->sc_ccbhash[i];
- while (ccb) {
- if (ccb->flags != CCB_FREE)
- bt_print_ccb(ccb);
- ccb = ccb->nexthash;
- }
- i++;
- }
-}
-#endif /*UTEST */
+++ /dev/null
-/* $OpenBSD: bt742a.c,v 1.7 1996/04/18 23:47:31 niklas Exp $ */
-/* $NetBSD: bt742a.c,v 1.55 1996/03/16 05:33:28 cgd Exp $ */
-
-/*
- * Copyright (c) 1994 Charles Hannum. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Charles Hannum.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Originally written by Julian Elischer (julian@tfs.com)
- * for TRW Financial Systems for use under the MACH(2.5) operating system.
- *
- * TRW Financial Systems, in accordance with their agreement with Carnegie
- * Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
- * the software. For this reason TFS also grants any other persons or
- * organisations permission to use or modify this software.
- *
- * TFS supplies this software to be publicly redistributed
- * on the understanding that TFS is not responsible for the correct
- * functioning of this software in any circumstances.
- */
-
-/*
- * bt742a SCSI driver
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-
-#include <machine/pio.h>
-
-#include <dev/isa/isavar.h>
-#include <dev/isa/isadmavar.h>
-#include <scsi/scsi_all.h>
-#include <scsi/scsiconf.h>
-
-/*
- * Note that stdarg.h and the ANSI style va_start macro is used for both
- * ANSI and traditional C compilers.
- */
-#include <machine/stdarg.h>
-
-#ifndef DDB
-#define Debugger() panic("should call debugger here (bt742a.c)")
-#endif /* ! DDB */
-
-typedef u_long physaddr;
-typedef u_long physlen;
-
-/*
- * I/O Port Interface
- */
-#define BT_CTRL_STAT_PORT 0x0 /* control & status */
-#define BT_CMD_DATA_PORT 0x1 /* cmds and datas */
-#define BT_INTR_PORT 0x2 /* Intr. stat */
-
-/*
- * BT_CTRL_STAT bits (write)
- */
-#define BT_HRST 0x80 /* Hardware reset */
-#define BT_SRST 0x40 /* Software reset */
-#define BT_IRST 0x20 /* Interrupt reset */
-#define BT_SCRST 0x10 /* SCSI bus reset */
-
-/*
- * BT_CTRL_STAT bits (read)
- */
-#define BT_STST 0x80 /* Self test in Progress */
-#define BT_DIAGF 0x40 /* Diagnostic Failure */
-#define BT_INIT 0x20 /* Mbx Init required */
-#define BT_IDLE 0x10 /* Host Adapter Idle */
-#define BT_CDF 0x08 /* cmd/data out port full */
-#define BT_DF 0x04 /* Data in port full */
-#define BT_INVDCMD 0x01 /* Invalid command */
-
-/*
- * BT_CMD_DATA bits (write)
- */
-#define BT_NOP 0x00 /* No operation */
-#define BT_MBX_INIT 0x01 /* Mbx initialization */
-#define BT_START_SCSI 0x02 /* start scsi command */
-#define BT_START_BIOS 0x03 /* start bios command */
-#define BT_INQUIRE 0x04 /* Adapter Inquiry */
-#define BT_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
-#define BT_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
-#define BT_BUS_ON_TIME_SET 0x07 /* set bus-on time */
-#define BT_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
-#define BT_SPEED_SET 0x09 /* set transfer speed */
-#define BT_DEV_GET 0x0a /* return installed devices */
-#define BT_CONF_GET 0x0b /* return configuration data */
-#define BT_TARGET_EN 0x0c /* enable target mode */
-#define BT_SETUP_GET 0x0d /* return setup data */
-#define BT_WRITE_CH2 0x1a /* write channel 2 buffer */
-#define BT_READ_CH2 0x1b /* read channel 2 buffer */
-#define BT_WRITE_FIFO 0x1c /* write fifo buffer */
-#define BT_READ_FIFO 0x1d /* read fifo buffer */
-#define BT_ECHO 0x1e /* Echo command data */
-#define BT_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */
-#define BT_INQUIRE_REV_THIRD 0x84 /* Get 3rd firmware version byte */
-#define BT_INQUIRE_REV_FOURTH 0x85 /* Get 4th firmware version byte */
-#define BT_GET_BOARD_INFO 0x8b /* Get hardware ID and revision */
-#define BT_INQUIRE_EXTENDED 0x8d /* Adapter Setup Inquiry */
-
-/* Follows command appeared at firmware 3.31 */
-#define BT_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */
-#define BT_DISABLE 0x00 /* Parameter value for Disable */
-#define BT_ENABLE 0x01 /* Parameter value for Enable */
-
-/*
- * BT_INTR_PORT bits (read)
- */
-#define BT_ANY_INTR 0x80 /* Any interrupt */
-#define BT_SCRD 0x08 /* SCSI reset detected */
-#define BT_HACC 0x04 /* Command complete */
-#define BT_MBOA 0x02 /* MBX out empty */
-#define BT_MBIF 0x01 /* MBX in full */
-
-/*
- * Mail box defs etc.
- * these could be bigger but we need the bt_softc to fit on a single page..
- */
-#define BT_MBX_SIZE 32 /* mail box size (MAX 255 MBxs) */
- /* don't need that many really */
-#define BT_CCB_MAX 32 /* store up to 32 CCBs at one time */
-#define CCB_HASH_SIZE 32 /* hash table size for phystokv */
-#define CCB_HASH_SHIFT 9
-#define CCB_HASH(x) ((((long)(x))>>CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
-
-#define bt_nextmbx(wmb, mbx, mbio) \
- if ((wmb) == &(mbx)->mbio[BT_MBX_SIZE - 1]) \
- (wmb) = &(mbx)->mbio[0]; \
- else \
- (wmb)++;
-
-struct bt_mbx_out {
- physaddr ccb_addr;
- u_char dummy[3];
- u_char cmd;
-};
-
-struct bt_mbx_in {
- physaddr ccb_addr;
- u_char btstat;
- u_char sdstat;
- u_char dummy;
- u_char stat;
-};
-
-struct bt_mbx {
- struct bt_mbx_out mbo[BT_MBX_SIZE];
- struct bt_mbx_in mbi[BT_MBX_SIZE];
- struct bt_mbx_out *tmbo; /* Target Mail Box out */
- struct bt_mbx_in *tmbi; /* Target Mail Box in */
-};
-
-/*
- * mbo.cmd values
- */
-#define BT_MBO_FREE 0x0 /* MBO entry is free */
-#define BT_MBO_START 0x1 /* MBO activate entry */
-#define BT_MBO_ABORT 0x2 /* MBO abort entry */
-
-/*
- * mbi.stat values
- */
-#define BT_MBI_FREE 0x0 /* MBI entry is free */
-#define BT_MBI_OK 0x1 /* completed without error */
-#define BT_MBI_ABORT 0x2 /* aborted ccb */
-#define BT_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
-#define BT_MBI_ERROR 0x4 /* Completed with error */
-
-#if defined(BIG_DMA)
-WARNING...THIS WON'T WORK(won't fit on 1 page)
-/* #define BT_NSEG 2048 /* Number of scatter gather segments - to much vm */
-#define BT_NSEG 128
-#else
-#define BT_NSEG 33
-#endif /* BIG_DMA */
-
-struct bt_scat_gath {
- physlen seg_len;
- physaddr seg_addr;
-};
-
-struct bt_ccb {
- u_char opcode;
- u_char:3, data_in:1, data_out:1,:3;
- u_char scsi_cmd_length;
- u_char req_sense_length;
- /*------------------------------------longword boundary */
- physlen data_length;
- /*------------------------------------longword boundary */
- physaddr data_addr;
- /*------------------------------------longword boundary */
- u_char dummy1[2];
- u_char host_stat;
- u_char target_stat;
- /*------------------------------------longword boundary */
- u_char target;
- u_char lun;
- struct scsi_generic scsi_cmd;
- u_char dummy2[1];
- u_char link_id;
- /*------------------------------------longword boundary */
- physaddr link_addr;
- /*------------------------------------longword boundary */
- physaddr sense_ptr;
-/*-----end of HW fields-----------------------longword boundary */
- struct scsi_sense_data scsi_sense;
- /*------------------------------------longword boundary */
- struct bt_scat_gath scat_gath[BT_NSEG];
- /*------------------------------------longword boundary */
- TAILQ_ENTRY(bt_ccb) chain;
- struct bt_ccb *nexthash;
- long hashkey;
- struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
- int flags;
-#define CCB_FREE 0
-#define CCB_ACTIVE 1
-#define CCB_ABORTED 2
- struct bt_mbx_out *mbx; /* pointer to mail box */
-};
-
-/*
- * opcode fields
- */
-#define BT_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
-#define BT_TARGET_CCB 0x01 /* SCSI Target CCB */
-#define BT_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */
-#define BT_RESET_CCB 0x81 /* SCSI Bus reset */
-
-/*
- * bt_ccb.host_stat values
- */
-#define BT_OK 0x00 /* cmd ok */
-#define BT_LINK_OK 0x0a /* Link cmd ok */
-#define BT_LINK_IT 0x0b /* Link cmd ok + int */
-#define BT_SEL_TIMEOUT 0x11 /* Selection time out */
-#define BT_OVER_UNDER 0x12 /* Data over/under run */
-#define BT_BUS_FREE 0x13 /* Bus dropped at unexpected time */
-#define BT_INV_BUS 0x14 /* Invalid bus phase/sequence */
-#define BT_BAD_MBO 0x15 /* Incorrect MBO cmd */
-#define BT_BAD_CCB 0x16 /* Incorrect ccb opcode */
-#define BT_BAD_LINK 0x17 /* Not same values of LUN for links */
-#define BT_INV_TARGET 0x18 /* Invalid target direction */
-#define BT_CCB_DUP 0x19 /* Duplicate CCB received */
-#define BT_INV_CCB 0x1a /* Invalid CCB or segment list */
-#define BT_ABORTED 42 /* pseudo value from driver */
-
-struct bt_extended_inquire {
- u_char bus_type; /* Type of bus connected to */
-#define BT_BUS_TYPE_24BIT 'A' /* ISA bus */
-#define BT_BUS_TYPE_32BIT 'E' /* EISA/VLB/PCI bus */
-#define BT_BUS_TYPE_MCA 'M' /* MicroChannel bus */
- u_char bios_address; /* Address of adapter BIOS */
- u_short max_segment; /* ? */
-};
-
-struct bt_boardID {
- u_char board_type;
- u_char custom_feture;
- char firm_revision;
- u_char firm_version;
-};
-
-struct bt_board_info {
- u_char id[4]; /* i.e bt742a -> '7','4','2','A' */
- u_char version[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */
-};
-
-struct bt_setup {
- u_char sync_neg:1;
- u_char parity:1;
- u_char :6;
- u_char speed;
- u_char bus_on;
- u_char bus_off;
- u_char num_mbx;
- u_char mbx[3]; /*XXX */
- /* doesn't make sense with 32bit addresses */
- struct {
- u_char offset:4;
- u_char period:3;
- u_char valid:1;
- } sync[8];
- u_char disc_sts;
-};
-
-struct bt_config {
- u_char chan;
- u_char intr;
- u_char scsi_dev:3;
- u_char :5;
-};
-
-#define INT9 0x01
-#define INT10 0x02
-#define INT11 0x04
-#define INT12 0x08
-#define INT14 0x20
-#define INT15 0x40
-
-#define EISADMA 0x00
-#define CHAN0 0x01
-#define CHAN5 0x20
-#define CHAN6 0x40
-#define CHAN7 0x80
-
-#define KVTOPHYS(x) vtophys(x)
-
-struct bt_softc {
- struct device sc_dev;
- struct isadev sc_id;
- void *sc_ih;
-
- int sc_iobase;
- int sc_irq, sc_drq;
-
- struct bt_mbx sc_mbx; /* all our mailboxes */
- struct bt_ccb *sc_ccbhash[CCB_HASH_SIZE];
- TAILQ_HEAD(, bt_ccb) sc_free_ccb;
- int sc_numccbs;
- int sc_scsi_dev; /* adapters scsi id */
- struct scsi_link sc_link; /* prototype for devs */
-};
-
-/***********debug values *************/
-#define BT_SHOWCCBS 0x01
-#define BT_SHOWINTS 0x02
-#define BT_SHOWCMDS 0x04
-#define BT_SHOWMISC 0x08
-int bt_debug = 0;
-
-int bt_cmd __P((int, struct bt_softc *, int, int, int, u_char *,
- unsigned, ...));
-int btintr __P((void *));
-void bt_free_ccb __P((struct bt_softc *, struct bt_ccb *, int));
-struct bt_ccb *bt_get_ccb __P((struct bt_softc *, int));
-struct bt_ccb *bt_ccb_phys_kv __P((struct bt_softc *, u_long));
-struct bt_mbx_out *bt_send_mbo __P((struct bt_softc *, int, struct bt_ccb *));
-void bt_done __P((struct bt_softc *, struct bt_ccb *));
-int bt_find __P((struct isa_attach_args *, struct bt_softc *));
-void bt_init __P((struct bt_softc *));
-void bt_inquire_setup_information __P((struct bt_softc *));
-void btminphys __P((struct buf *));
-int bt_scsi_cmd __P((struct scsi_xfer *));
-int bt_poll __P((struct bt_softc *, struct scsi_xfer *, int));
-void bt_timeout __P((void *arg));
-#ifdef UTEST
-void bt_print_ccb __P((struct bt_ccb *));
-void bt_print_active_ccbs __P((struct bt_softc *));
-#endif
-
-struct scsi_adapter bt_switch = {
- bt_scsi_cmd,
- btminphys,
- 0,
- 0,
-};
-
-/* the below structure is so we have a default dev struct for out link struct */
-struct scsi_device bt_dev = {
- NULL, /* Use default error handler */
- NULL, /* have a queue, served by this */
- NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
-};
-
-int btprobe __P((struct device *, void *, void *));
-void btattach __P((struct device *, struct device *, void *));
-int btprint __P((void *, char *));
-
-struct cfdriver btcd = {
- NULL, "bt", btprobe, btattach, DV_DULL, sizeof(struct bt_softc)
-};
-
-#define BT_RESET_TIMEOUT 1000
-
-/*
- * bt_cmd(iobase, sc, icnt, ocnt, wait, retval, opcode, ... args ...)
- *
- * Activate Adapter command
- * icnt: number of args (outbound bytes written after opcode)
- * ocnt: number of expected returned bytes
- * wait: number of seconds to wait for response
- * retval: buffer where to place returned bytes
- * opcode: opcode BT_NOP, BT_MBX_INIT, BT_START_SCSI ...
- * args: variable number of parameters
- *
- * Performs an adapter command through the ports. Not to be confused with a
- * scsi command, which is read in via the dma; one of the adapter commands
- * tells it to read in a scsi command.
- */
-int
-#ifdef __STDC__
-bt_cmd(int iobase, struct bt_softc *sc, int icnt, int ocnt, int wait,
- u_char *retval, unsigned opcode, ...)
-#else
-bt_cmd(iobase, sc, icnt, ocnt, wait, retval, opcode, va_alist)
- int iobase;
- struct bt_softc *sc;
- int icnt, ocnt, wait;
- u_char *retval;
- unsigned opcode;
- va_dcl
-#endif
-{
- va_list ap;
- unsigned data;
- const char *name;
- u_char oc;
- register i;
- int sts;
-
- if (sc == NULL)
- name = sc->sc_dev.dv_xname;
- else
- name = "(probe)";
-
- /*
- * multiply the wait argument by a big constant
- * zero defaults to 1
- */
- if (wait)
- wait *= 100000;
- else
- wait = 100000;
- /*
- * Wait for the adapter to go idle, unless it's one of
- * the commands which don't need this
- */
- if (opcode != BT_MBX_INIT && opcode != BT_START_SCSI) {
- i = 100000; /* 1 sec? */
- while (--i) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (sts & BT_IDLE) {
- break;
- }
- delay(10);
- }
- if (!i) {
- printf("%s: bt_cmd, host not idle(0x%x)\n",
- name, sts);
- return ENXIO;
- }
- }
- /*
- * Now that it is idle, if we expect output, preflush the
- * queue feeding to us.
- */
- if (ocnt) {
- while ((inb(iobase + BT_CTRL_STAT_PORT)) & BT_DF)
- inb(iobase + BT_CMD_DATA_PORT);
- }
- /*
- * Output the command and the number of arguments given
- * for each byte, first check the port is empty.
- */
- va_start(ap, opcode);
- /* test icnt >= 0, to include the command in data sent */
- for (data = opcode; icnt >= 0; icnt--, data = va_arg(ap, u_char)) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- for (i = wait; i; i--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (!(sts & BT_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: bt_cmd, cmd/data port full\n", name);
- outb(iobase + BT_CTRL_STAT_PORT, BT_SRST);
- va_end(ap);
- return ENXIO;
- }
- outb(iobase + BT_CMD_DATA_PORT, data);
- }
- va_end(ap);
- /*
- * If we expect input, loop that many times, each time,
- * looking for the data register to have valid data
- */
- while (ocnt--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- for (i = wait; i; i--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (sts & BT_DF)
- break;
- delay(10);
- }
- if (!i) {
- printf("bt%d: bt_cmd, cmd/data port empty %d\n",
- name, ocnt);
- return ENXIO;
- }
- oc = inb(iobase + BT_CMD_DATA_PORT);
- if (retval)
- *retval++ = oc;
- }
- /*
- * Wait for the board to report a finised instruction
- */
- i = 100000; /* 1 sec? */
- while (--i) {
- sts = inb(iobase + BT_INTR_PORT);
- if (sts & BT_HACC)
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: bt_cmd, host not finished(0x%x)\n",
- name, sts);
- return ENXIO;
- }
- outb(iobase + BT_CTRL_STAT_PORT, BT_IRST);
- return 0;
-}
-
-/*
- * Check if the device can be found at the port given
- * and if so, set it up ready for further work
- * as an argument, takes the isa_device structure from
- * autoconf.c
- */
-int
-btprobe(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- struct bt_softc *sc = match;
- register struct isa_attach_args *ia = aux;
-
-#ifdef NEWCONFIG
- if (ia->ia_iobase == IOBASEUNK)
- return 0;
-#endif
-
- /*
- * Try initialise a unit at this location
- * sets up dma and bus speed, loads sc->sc_irq
- */
- if (bt_find(ia, NULL) != 0)
- return 0;
-
- ia->ia_msize = 0;
- ia->ia_iosize = 4;
- /* IRQ and DRQ set by bt_find() */
- return 1;
-}
-
-int
-btprint(aux, name)
- void *aux;
- char *name;
-{
- if (name != NULL)
- printf("%s: scsibus ", name);
- return UNCONF;
-}
-
-/*
- * Attach all the sub-devices we can find
- */
-void
-btattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct isa_attach_args *ia = aux;
- struct bt_softc *sc = (struct bt_softc *)self;
-
- if (bt_find(ia, sc) != 0)
- panic("btattach: bt_find of %s failed", self->dv_xname);
- sc->sc_iobase = ia->ia_iobase;
-
- if (sc->sc_drq != DRQUNK)
- isa_dmacascade(sc->sc_drq);
-
- bt_init(sc);
- TAILQ_INIT(&sc->sc_free_ccb);
-
- /*
- * fill in the prototype scsi_link.
- */
- sc->sc_link.adapter_softc = sc;
- sc->sc_link.adapter_target = sc->sc_scsi_dev;
- sc->sc_link.adapter = &bt_switch;
- sc->sc_link.device = &bt_dev;
- sc->sc_link.openings = 2;
-
- printf("\n");
-
-#ifdef NEWCONFIG
- isa_establish(&sc->sc_id, &sc->sc_dev);
-#endif
- sc->sc_ih = isa_intr_establish(sc->sc_irq, IST_EDGE, IPL_BIO, btintr,
- sc, sc->sc_dev.dv_xname);
-
- /*
- * ask the adapter what subunits are present
- */
- config_found(self, &sc->sc_link, btprint);
-}
-
-/*
- * Catch an interrupt from the adaptor
- */
-int
-btintr(arg)
- void *arg;
-{
- struct bt_softc *sc = arg;
- int iobase = sc->sc_iobase;
- struct bt_mbx_in *wmbi;
- struct bt_mbx *wmbx;
- struct bt_ccb *ccb;
- u_char stat;
- int i;
- int found = 0;
-
-#ifdef BTDEBUG
- printf("%s: btintr ", sc->sc_dev.dv_xname);
-#endif /* BTDEBUG */
-
- /*
- * First acknowlege the interrupt, Then if it's
- * not telling about a completed operation
- * just return.
- */
- stat = inb(iobase + BT_INTR_PORT);
- if ((stat & (BT_MBOA | BT_MBIF)) == 0) {
- outb(iobase + BT_CTRL_STAT_PORT, BT_IRST);
- return -1; /* XXX */
- }
-
- /* Mail box out empty? */
- if (stat & BT_MBOA) {
- /* Disable MBO available interrupt. */
- outb(iobase + BT_CMD_DATA_PORT, BT_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(iobase + BT_CTRL_STAT_PORT) & BT_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: btintr, cmd/data port full\n",
- sc->sc_dev.dv_xname);
- outb(iobase + BT_CTRL_STAT_PORT, BT_SRST);
- return 1;
- }
- outb(iobase + BT_CMD_DATA_PORT, 0x00); /* Disable */
- wakeup(&sc->sc_mbx);
- }
-
- /* Mail box in full? */
- if ((stat & BT_MBIF) == 0)
- return 1;
- wmbx = &sc->sc_mbx;
- wmbi = wmbx->tmbi;
-AGAIN:
- while (wmbi->stat != BT_MBI_FREE) {
- ccb = bt_ccb_phys_kv(sc, wmbi->ccb_addr);
- if (!ccb) {
- wmbi->stat = BT_MBI_FREE;
- printf("%s: BAD CCB ADDR!\n", sc->sc_dev.dv_xname);
- continue;
- }
- found++;
- switch (wmbi->stat) {
- case BT_MBI_OK:
- case BT_MBI_ERROR:
- break;
-
- case BT_MBI_ABORT:
- ccb->host_stat = BT_ABORTED;
- break;
-
- case BT_MBI_UNKNOWN:
- ccb = 0;
- break;
-
- default:
- panic("Impossible mbxi status");
- }
-#ifdef BTDEBUG
- if (bt_debug && ccb) {
- u_char *cp = &ccb->scsi_cmd;
- printf("op=%x %x %x %x %x %x\n",
- cp[0], cp[1], cp[2],
- cp[3], cp[4], cp[5]);
- printf("stat %x for mbi addr = 0x%08x, ",
- wmbi->stat, wmbi);
- printf("ccb addr = 0x%x\n", ccb);
- }
-#endif /* BTDEBUG */
- wmbi->stat = BT_MBI_FREE;
- if (ccb) {
- untimeout(bt_timeout, ccb);
- bt_done(sc, ccb);
- }
- bt_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
- for (i = 0; i < BT_MBX_SIZE; i++) {
- if (wmbi->stat != BT_MBI_FREE) {
- found++;
- break;
- }
- bt_nextmbx(wmbi, wmbx, mbi);
- }
- if (!found) {
-#if 0
- printf("%s: mbi interrupt with no full mailboxes\n",
- sc->sc_dev.dv_xname);
-#endif
- } else {
- found = 0;
- goto AGAIN;
- }
- }
- wmbx->tmbi = wmbi;
- outb(iobase + BT_CTRL_STAT_PORT, BT_IRST);
- return 1;
-}
-
-/*
- * A ccb is put onto the free list.
- */
-void
-bt_free_ccb(sc, ccb, flags)
- struct bt_softc *sc;
- struct bt_ccb *ccb;
- int flags;
-{
- int s;
-
- s = splbio();
-
- ccb->flags = CCB_FREE;
- TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, chain);
-
- /*
- * If there were none, wake anybody waiting for one to come free,
- * starting with queued entries.
- */
- if (ccb->chain.tqe_next == 0)
- wakeup(&sc->sc_free_ccb);
-
- splx(s);
-}
-
-static inline void
-bt_init_ccb(sc, ccb)
- struct bt_softc *sc;
- struct bt_ccb *ccb;
-{
- int hashnum;
-
- bzero(ccb, sizeof(struct bt_ccb));
- /*
- * put in the phystokv hash table
- * Never gets taken out.
- */
- ccb->hashkey = KVTOPHYS(ccb);
- hashnum = CCB_HASH(ccb->hashkey);
- ccb->nexthash = sc->sc_ccbhash[hashnum];
- sc->sc_ccbhash[hashnum] = ccb;
-}
-
-static inline void
-bt_reset_ccb(sc, ccb)
- struct bt_softc *sc;
- struct bt_ccb *ccb;
-{
-
-}
-
-/*
- * Get a free ccb
- *
- * If there are none, see if we can allocate a new one. If so, put it in
- * the hash table too otherwise either return an error or sleep.
- */
-struct bt_ccb *
-bt_get_ccb(sc, flags)
- struct bt_softc *sc;
- int flags;
-{
- struct bt_ccb *ccb;
- int s;
-
- s = splbio();
-
- /*
- * If we can and have to, sleep waiting for one to come free
- * but only if we can't allocate a new one.
- */
- for (;;) {
- ccb = sc->sc_free_ccb.tqh_first;
- if (ccb) {
- TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain);
- break;
- }
- if (sc->sc_numccbs < BT_CCB_MAX) {
- if (ccb = (struct bt_ccb *) malloc(sizeof(struct bt_ccb),
- M_TEMP, M_NOWAIT)) {
- bt_init_ccb(sc, ccb);
- sc->sc_numccbs++;
- } else {
- printf("%s: can't malloc ccb\n",
- sc->sc_dev.dv_xname);
- goto out;
- }
- break;
- }
- if ((flags & SCSI_NOSLEEP) != 0)
- goto out;
- tsleep(&sc->sc_free_ccb, PRIBIO, "btccb", 0);
- }
-
- bt_reset_ccb(sc, ccb);
- ccb->flags = CCB_ACTIVE;
-
-out:
- splx(s);
- return ccb;
-}
-
-/*
- * given a physical address, find the ccb that
- * it corresponds to:
- */
-struct bt_ccb *
-bt_ccb_phys_kv(sc, ccb_phys)
- struct bt_softc *sc;
- u_long ccb_phys;
-{
- int hashnum = CCB_HASH(ccb_phys);
- struct bt_ccb *ccb = sc->sc_ccbhash[hashnum];
-
- while (ccb) {
- if (ccb->hashkey == ccb_phys)
- break;
- ccb = ccb->nexthash;
- }
- return ccb;
-}
-
-/*
- * Get a mbo and send the ccb.
- */
-struct bt_mbx_out *
-bt_send_mbo(sc, cmd, ccb)
- struct bt_softc *sc;
- int cmd;
- struct bt_ccb *ccb;
-{
- int iobase = sc->sc_iobase;
- struct bt_mbx_out *wmbo; /* Mail Box Out pointer */
- struct bt_mbx *wmbx; /* Mail Box pointer specified unit */
- int i;
-
- /* Get the target out mail box pointer and increment. */
- wmbx = &sc->sc_mbx;
- wmbo = wmbx->tmbo;
- bt_nextmbx(wmbx->tmbo, wmbx, mbo);
-
- /*
- * Check the outmail box is free or not.
- * Note: Under the normal operation, it shuld NOT happen to wait.
- */
- while (wmbo->cmd != BT_MBO_FREE) {
- /* Enable mbo available interrupt. */
- outb(iobase + BT_CMD_DATA_PORT, BT_MBO_INTR_EN);
- for (i = 100000; i; i--) {
- if (!(inb(iobase + BT_CTRL_STAT_PORT) & BT_CDF))
- break;
- delay(10);
- }
- if (!i) {
- printf("%s: bt_send_mbo, cmd/data port full\n",
- sc->sc_dev.dv_xname);
- outb(iobase + BT_CTRL_STAT_PORT, BT_SRST);
- return NULL;
- }
- outb(iobase + BT_CMD_DATA_PORT, 0x01); /* Enable */
- tsleep(wmbx, PRIBIO, "btsnd", 0);/*XXX can't do this */
- }
-
- /* Link ccb to mbo. */
- wmbo->ccb_addr = KVTOPHYS(ccb);
- ccb->mbx = wmbo;
- wmbo->cmd = cmd;
-
- /* Send it! */
- outb(iobase + BT_CMD_DATA_PORT, BT_START_SCSI);
-
- return wmbo;
-}
-
-/*
- * We have a ccb which has been processed by the
- * adaptor, now we look to see how the operation
- * went. Wake up the owner if waiting
- */
-void
-bt_done(sc, ccb)
- struct bt_softc *sc;
- struct bt_ccb *ccb;
-{
- struct scsi_sense_data *s1, *s2;
- struct scsi_xfer *xs = ccb->xs;
-
- SC_DEBUG(xs->sc_link, SDEV_DB2, ("bt_done\n"));
- /*
- * Otherwise, put the results of the operation
- * into the xfer and call whoever started it
- */
- if ((xs->flags & INUSE) == 0) {
- printf("%s: exiting but not in use!\n", sc->sc_dev.dv_xname);
- Debugger();
- }
- if (xs->error == XS_NOERROR) {
- if (ccb->host_stat != BT_OK) {
- switch (ccb->host_stat) {
- case BT_ABORTED:
- xs->error = XS_DRIVER_STUFFUP;
- break;
- case BT_SEL_TIMEOUT: /* No response */
- xs->error = XS_SELTIMEOUT;
- break;
- default: /* Other scsi protocol messes */
- printf("%s: host_stat %x\n",
- sc->sc_dev.dv_xname, ccb->host_stat);
- xs->error = XS_DRIVER_STUFFUP;
- }
- } else if (ccb->target_stat != SCSI_OK) {
- switch (ccb->target_stat) {
- case SCSI_CHECK:
- s1 = &ccb->scsi_sense;
- s2 = &xs->sense;
- *s2 = *s1;
- xs->error = XS_SENSE;
- break;
- case SCSI_BUSY:
- xs->error = XS_BUSY;
- break;
- default:
- printf("%s: target_stat %x\n",
- sc->sc_dev.dv_xname, ccb->target_stat);
- xs->error = XS_DRIVER_STUFFUP;
- }
- } else
- xs->resid = 0;
- }
- xs->flags |= ITSDONE;
- bt_free_ccb(sc, ccb, xs->flags);
- scsi_done(xs);
-}
-
-/*
- * Find the board and find it's irq/drq
- */
-int
-bt_find(ia, sc)
- struct isa_attach_args *ia;
- struct bt_softc *sc;
-{
- int iobase = ia->ia_iobase;
- u_char ad[4];
- volatile int i, sts;
- struct bt_extended_inquire info;
- struct bt_config conf;
- int irq, drq;
-
- /*
- * reset board, If it doesn't respond, assume
- * that it's not there.. good for the probe
- */
-
- outb(iobase + BT_CTRL_STAT_PORT, BT_HRST | BT_SRST);
-
- for (i = BT_RESET_TIMEOUT; i; i--) {
- sts = inb(iobase + BT_CTRL_STAT_PORT);
- if (sts == (BT_IDLE | BT_INIT))
- break;
- delay(1000);
- }
- if (!i) {
-#ifdef UTEST
- printf("bt_find: No answer from bt742a board\n");
-#endif
- return 1;
- }
-
- /*
- * Check that we actually know how to use this board.
- */
- delay(1000);
- bt_cmd(iobase, sc, 1, sizeof(info), 0, (u_char *)&info,
- BT_INQUIRE_EXTENDED, sizeof(info));
- switch (info.bus_type) {
- case BT_BUS_TYPE_24BIT:
- /* XXXX How do we avoid conflicting with the aha1542 probe? */
- case BT_BUS_TYPE_32BIT:
- break;
- case BT_BUS_TYPE_MCA:
- /* We don't grok MicroChannel (yet). */
- return 1;
- default:
- printf("bt_find: illegal bus type %c\n", info.bus_type);
- return 1;
- }
-
- /*
- * Assume we have a board at this stage setup dma channel from
- * jumpers and save int level
- */
- delay(1000);
- bt_cmd(iobase, sc, 0, sizeof(conf), 0, (u_char *)&conf, BT_CONF_GET);
- switch (conf.chan) {
- case EISADMA:
- drq = DRQUNK;
- break;
- case CHAN0:
- drq = 0;
- break;
- case CHAN5:
- drq = 5;
- break;
- case CHAN6:
- drq = 6;
- break;
- case CHAN7:
- drq = 7;
- break;
- default:
- printf("bt_find: illegal dma setting %x\n", conf.chan);
- return 1;
- }
-
- switch (conf.intr) {
- case INT9:
- irq = 9;
- break;
- case INT10:
- irq = 10;
- break;
- case INT11:
- irq = 11;
- break;
- case INT12:
- irq = 12;
- break;
- case INT14:
- irq = 14;
- break;
- case INT15:
- irq = 15;
- break;
- default:
- printf("bt_find: illegal int setting %x\n", conf.intr);
- return 1;
- }
-
- if (sc != NULL) {
- /* who are we on the scsi bus? */
- sc->sc_scsi_dev = conf.scsi_dev;
-
- sc->sc_iobase = iobase;
- sc->sc_irq = irq;
- sc->sc_drq = drq;
- } else {
- if (ia->ia_irq == IRQUNK)
- ia->ia_irq = irq;
- else if (ia->ia_irq != irq)
- return 1;
- if (ia->ia_drq == DRQUNK)
- ia->ia_drq = drq;
- else if (ia->ia_drq != drq)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Start the board, ready for normal operation
- */
-void
-bt_init(sc)
- struct bt_softc *sc;
-{
- int iobase = sc->sc_iobase;
- u_char ad[4];
- int i;
-
- /*
- * Initialize mail box
- */
- *((physaddr *)ad) = KVTOPHYS(&sc->sc_mbx);
-
- bt_cmd(iobase, sc, 5, 0, 0, 0, BT_MBX_INIT_EXTENDED, BT_MBX_SIZE,
- ad[0], ad[1], ad[2], ad[3]);
-
- for (i = 0; i < BT_MBX_SIZE; i++) {
- sc->sc_mbx.mbo[i].cmd = BT_MBO_FREE;
- sc->sc_mbx.mbi[i].stat = BT_MBI_FREE;
- }
-
- /*
- * Set up initial mail box for round-robin operation.
- */
- sc->sc_mbx.tmbo = &sc->sc_mbx.mbo[0];
- sc->sc_mbx.tmbi = &sc->sc_mbx.mbi[0];
-
- bt_inquire_setup_information(sc);
-}
-
-void
-bt_inquire_setup_information(sc)
- struct bt_softc *sc;
-{
- int iobase = sc->sc_iobase;
- struct bt_boardID bID;
- struct bt_board_info binfo;
- char dummy[8], sub_ver[3];
- struct bt_setup setup;
- int i, ver;
-
- /*
- * Get and print board hardware information.
- */
- bt_cmd(iobase, sc, 1, sizeof(binfo), 0, (u_char *)&binfo,
- BT_GET_BOARD_INFO, sizeof(binfo));
- printf(": Bt%c%c%c", binfo.id[0], binfo.id[1], binfo.id[2]);
- if (binfo.id[3] != ' ')
- printf("%c", binfo.id[3]);
- if (binfo.version[0] != ' ')
- printf("%c%s", binfo.version[0], binfo.version[1]);
- printf("\n");
-
- /*
- * Inquire Board ID to Bt742 for board type and firmware version.
- */
- bt_cmd(iobase, sc, 0, sizeof(bID), 0, (u_char *)&bID, BT_INQUIRE);
- ver = (bID.firm_revision - '0') * 10 + (bID.firm_version - '0');
-
- /*
- * Get the rest of the firmware version. Firmware revisions
- * before 3.3 apparently don't accept the BT_INQUIRE_REV_FOURTH
- * command.
- */
- i = 0;
- bt_cmd(iobase, sc, 0, 1, 0, &sub_ver[i++], BT_INQUIRE_REV_THIRD);
- if (ver >= 33)
- bt_cmd(iobase, sc, 0, 1, 0, &sub_ver[i++],
- BT_INQUIRE_REV_FOURTH);
- if (sub_ver[i - 1] == ' ')
- i--;
- sub_ver[i] = '\0';
-
- printf("%s: firmware version %c.%c%s, ", sc->sc_dev.dv_xname,
- bID.firm_revision, bID.firm_version, sub_ver);
-
- /* Enable round-robin scheme - appeared at firmware rev. 3.31 */
- if (ver > 33 || (ver == 33 && sub_ver[0] >= 1)) {
- bt_cmd(iobase, sc, 1, 0, 0, 0, BT_ROUND_ROBIN, BT_ENABLE);
- }
-
- /* Inquire Installed Devices (to force synchronous negotiation) */
- bt_cmd(iobase, sc, 0, sizeof(dummy), 10, dummy, BT_DEV_GET);
-
- /* Obtain setup information from Bt742. */
- bt_cmd(iobase, sc, 1, sizeof(setup), 0, (u_char *)&setup, BT_SETUP_GET,
- sizeof(setup));
-
- printf("%s, %s, %d mailboxes",
- setup.sync_neg ? "sync" : "async",
- setup.parity ? "parity" : "no parity",
- setup.num_mbx);
-
- for (i = 0; i < 8; i++) {
- if (!setup.sync[i].valid ||
- (!setup.sync[i].offset && !setup.sync[i].period))
- continue;
- printf("\n%s targ %d: sync, offset %d, period %dnsec",
- sc->sc_dev.dv_xname, i,
- setup.sync[i].offset, setup.sync[i].period * 50 + 200);
- }
-}
-
-void
-btminphys(bp)
- struct buf *bp;
-{
-
- if (bp->b_bcount > ((BT_NSEG - 1) << PGSHIFT))
- bp->b_bcount = ((BT_NSEG - 1) << PGSHIFT);
- minphys(bp);
-}
-
-/*
- * start a scsi operation given the command and the data address. Also needs
- * the unit, target and lu.
- */
-int
-bt_scsi_cmd(xs)
- struct scsi_xfer *xs;
-{
- struct scsi_link *sc_link = xs->sc_link;
- struct bt_softc *sc = sc_link->adapter_softc;
- struct bt_ccb *ccb;
- struct bt_scat_gath *sg;
- int seg; /* scatter gather seg being worked on */
- int thiskv;
- physaddr thisphys, nextphys;
- int bytes_this_seg, bytes_this_page, datalen, flags;
- struct iovec *iovp;
- struct bt_mbx_out *mbo;
- int s;
-
- SC_DEBUG(sc_link, SDEV_DB2, ("bt_scsi_cmd\n"));
- /*
- * get a ccb to use. If the transfer
- * is from a buf (possibly from interrupt time)
- * then we can't allow it to sleep
- */
- flags = xs->flags;
- if ((flags & (ITSDONE|INUSE)) != INUSE) {
- printf("%s: done or not in use?\n", sc->sc_dev.dv_xname);
- xs->flags &= ~ITSDONE;
- xs->flags |= INUSE;
- }
- if ((ccb = bt_get_ccb(sc, flags)) == NULL) {
- xs->error = XS_DRIVER_STUFFUP;
- return TRY_AGAIN_LATER;
- }
- ccb->xs = xs;
-
- /*
- * Put all the arguments for the xfer in the ccb
- */
- if (flags & SCSI_RESET) {
- ccb->opcode = BT_RESET_CCB;
- } else {
- /* can't use S/G if zero length */
- ccb->opcode = (xs->datalen ? BT_INIT_SCAT_GATH_CCB
- : BT_INITIATOR_CCB);
- }
- ccb->data_out = 0;
- ccb->data_in = 0;
- ccb->target = sc_link->target;
- ccb->lun = sc_link->lun;
- ccb->scsi_cmd_length = xs->cmdlen;
- ccb->sense_ptr = KVTOPHYS(&ccb->scsi_sense);
- ccb->req_sense_length = sizeof(ccb->scsi_sense);
- ccb->host_stat = 0x00;
- ccb->target_stat = 0x00;
-
- if (xs->datalen && (flags & SCSI_RESET) == 0) {
- ccb->data_addr = KVTOPHYS(ccb->scat_gath);
- sg = ccb->scat_gath;
- seg = 0;
-#ifdef TFS
- if (flags & SCSI_DATA_UIO) {
- iovp = ((struct uio *)xs->data)->uio_iov;
- datalen = ((struct uio *)xs->data)->uio_iovcnt;
- xs->datalen = 0;
- while (datalen && seg < BT_NSEG) {
- sg->seg_addr = (physaddr)iovp->iov_base;
- sg->seg_len = iovp->iov_len;
- xs->datalen += iovp->iov_len;
- SC_DEBUGN(sc_link, SDEV_DB4, ("(0x%x@0x%x)",
- iovp->iov_len, iovp->iov_base));
- sg++;
- iovp++;
- seg++;
- datalen--;
- }
- } else
-#endif /* TFS */
- {
- /*
- * Set up the scatter gather block
- */
- SC_DEBUG(sc_link, SDEV_DB4,
- ("%d @0x%x:- ", xs->datalen, xs->data));
- datalen = xs->datalen;
- thiskv = (int) xs->data;
- thisphys = KVTOPHYS(thiskv);
-
- while (datalen && seg < BT_NSEG) {
- bytes_this_seg = 0;
-
- /* put in the base address */
- sg->seg_addr = thisphys;
-
- SC_DEBUGN(sc_link, SDEV_DB4, ("0x%x", thisphys));
-
- /* do it at least once */
- nextphys = thisphys;
- while (datalen && thisphys == nextphys) {
- /*
- * This page is contiguous (physically)
- * with the the last, just extend the
- * length
- */
- /* how far to the end of the page */
- nextphys = (thisphys & ~PGOFSET) + NBPG;
- bytes_this_page = nextphys - thisphys;
- /**** or the data ****/
- bytes_this_page = min(bytes_this_page,
- datalen);
- bytes_this_seg += bytes_this_page;
- datalen -= bytes_this_page;
-
- /* get more ready for the next page */
- thiskv = (thiskv & ~PGOFSET) + NBPG;
- if (datalen)
- thisphys = KVTOPHYS(thiskv);
- }
- /*
- * next page isn't contiguous, finish the seg
- */
- SC_DEBUGN(sc_link, SDEV_DB4,
- ("(0x%x)", bytes_this_seg));
- sg->seg_len = bytes_this_seg;
- sg++;
- seg++;
- }
- }
- /* end of iov/kv decision */
- ccb->data_length = seg * sizeof(struct bt_scat_gath);
- SC_DEBUGN(sc_link, SDEV_DB4, ("\n"));
- if (datalen) {
- /*
- * there's still data, must have run out of segs!
- */
- printf("%s: bt_scsi_cmd, more than %d dma segs\n",
- sc->sc_dev.dv_xname, BT_NSEG);
- xs->error = XS_DRIVER_STUFFUP;
- bt_free_ccb(sc, ccb, flags);
- return COMPLETE;
- }
- } else { /* No data xfer, use non S/G values */
- ccb->data_addr = (physaddr)0;
- ccb->data_length = 0;
- }
- ccb->link_id = 0;
- ccb->link_addr = (physaddr)0;
-
- /*
- * Put the scsi command in the ccb and start it
- */
- if ((flags & SCSI_RESET) == 0)
- bcopy(xs->cmd, &ccb->scsi_cmd, ccb->scsi_cmd_length);
-
- s = splbio();
-
- if (bt_send_mbo(sc, BT_MBO_START, ccb) == NULL) {
- splx(s);
- xs->error = XS_DRIVER_STUFFUP;
- bt_free_ccb(sc, ccb, flags);
- return TRY_AGAIN_LATER;
- }
-
- /*
- * Usually return SUCCESSFULLY QUEUED
- */
- SC_DEBUG(sc_link, SDEV_DB3, ("cmd_sent\n"));
- if ((flags & SCSI_POLL) == 0) {
- timeout(bt_timeout, ccb, (xs->timeout * hz) / 1000);
- splx(s);
- return SUCCESSFULLY_QUEUED;
- }
-
- splx(s);
-
- /*
- * If we can't use interrupts, poll on completion
- */
- if (bt_poll(sc, xs, xs->timeout)) {
- bt_timeout(ccb);
- if (bt_poll(sc, xs, 2000))
- bt_timeout(ccb);
- }
- return COMPLETE;
-}
-
-/*
- * Poll a particular unit, looking for a particular xs
- */
-int
-bt_poll(sc, xs, count)
- struct bt_softc *sc;
- struct scsi_xfer *xs;
- int count;
-{
- int iobase = sc->sc_iobase;
-
- /* timeouts are in msec, so we loop in 1000 usec cycles */
- while (count) {
- /*
- * If we had interrupts enabled, would we
- * have got an interrupt?
- */
- if (inb(iobase + BT_INTR_PORT) & BT_ANY_INTR)
- btintr(sc);
- if (xs->flags & ITSDONE)
- return 0;
- delay(1000); /* only happens in boot so ok */
- count--;
- }
- return 1;
-}
-
-void
-bt_timeout(arg)
- void *arg;
-{
- struct bt_ccb *ccb = arg;
- struct scsi_xfer *xs = ccb->xs;
- struct scsi_link *sc_link = xs->sc_link;
- struct bt_softc *sc = sc_link->adapter_softc;
- int s;
-
- sc_print_addr(sc_link);
- printf("timed out");
-
- s = splbio();
-
- /*
- * If the ccb's mbx is not free, then the board has gone Far East?
- */
- if (bt_ccb_phys_kv(sc, ccb->mbx->ccb_addr) == ccb &&
- ccb->mbx->cmd != BT_MBO_FREE) {
- printf("%s: not taking commands!\n", sc->sc_dev.dv_xname);
- Debugger();
- }
-
- /*
- * If it has been through before, then
- * a previous abort has failed, don't
- * try abort again
- */
- if (ccb->flags == CCB_ABORTED) {
- /* abort timed out */
- printf(" AGAIN\n");
- ccb->xs->retries = 0;
- bt_done(sc, ccb);
- } else {
- /* abort the operation that has timed out */
- printf("\n");
- ccb->xs->error = XS_TIMEOUT;
- ccb->flags = CCB_ABORTED;
- bt_send_mbo(sc, BT_MBO_ABORT, ccb);
- /* 2 secs for the abort */
- if ((xs->flags & SCSI_POLL) == 0)
- timeout(bt_timeout, ccb, 2 * hz);
- }
-
- splx(s);
-}
-
-#ifdef UTEST
-void
-bt_print_ccb(ccb)
- struct bt_ccb *ccb;
-{
-
- printf("ccb:%x op:%x cmdlen:%d senlen:%d\n",
- ccb, ccb->opcode, ccb->scsi_cmd_length, ccb->req_sense_length);
- printf(" datlen:%d hstat:%x tstat:%x flags:%x\n",
- ccb->data_length, ccb->host_stat, ccb->target_stat, ccb->flags);
-}
-
-void
-bt_print_active_ccbs(sc)
- struct bt_softc *sc;
-{
- struct bt_ccb *ccb;
- int i = 0;
-
- while (i < CCB_HASH_SIZE) {
- ccb = sc->sc_ccbhash[i];
- while (ccb) {
- if (ccb->flags != CCB_FREE)
- bt_print_ccb(ccb);
- ccb = ccb->nexthash;
- }
- i++;
- }
-}
-#endif /*UTEST */
--- /dev/null
+typedef u_int8_t physaddr[4];
+typedef u_int8_t physlen[4];
+#define ltophys _lto4l
+#define phystol _4ltol
+
+/*
+ * I/O port offsets
+ */
+#define BT_CTRL_PORT 0 /* control (wo) */
+#define BT_STAT_PORT 0 /* status (ro) */
+#define BT_CMD_PORT 1 /* command (wo) */
+#define BT_DATA_PORT 1 /* data (ro) */
+#define BT_INTR_PORT 2 /* interrupt status (ro) */
+
+/*
+ * BT_CTRL bits
+ */
+#define BT_CTRL_HRST 0x80 /* Hardware reset */
+#define BT_CTRL_SRST 0x40 /* Software reset */
+#define BT_CTRL_IRST 0x20 /* Interrupt reset */
+#define BT_CTRL_SCRST 0x10 /* SCSI bus reset */
+
+/*
+ * BT_STAT bits
+ */
+#define BT_STAT_STST 0x80 /* Self test in Progress */
+#define BT_STAT_DIAGF 0x40 /* Diagnostic Failure */
+#define BT_STAT_INIT 0x20 /* Mbx Init required */
+#define BT_STAT_IDLE 0x10 /* Host Adapter Idle */
+#define BT_STAT_CDF 0x08 /* cmd/data out port full */
+#define BT_STAT_DF 0x04 /* Data in port full */
+#define BT_STAT_INVDCMD 0x01 /* Invalid command */
+
+/*
+ * BT_CMD opcodes
+ */
+#define BT_NOP 0x00 /* No operation */
+#define BT_MBX_INIT 0x01 /* Mbx initialization */
+#define BT_START_SCSI 0x02 /* start scsi command */
+#define BT_INQUIRE_REVISION 0x04 /* Adapter Inquiry */
+#define BT_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
+/*#define BT_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
+/*#define BT_BUS_ON_TIME_SET 0x07 /* set bus-on time */
+/*#define BT_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
+/*#define BT_SPEED_SET 0x09 /* set transfer speed */
+#define BT_INQUIRE_DEVICES 0x0a /* return installed devices 0-7 */
+#define BT_INQUIRE_CONFIG 0x0b /* return configuration data */
+#define BT_TARGET_EN 0x0c /* enable target mode */
+#define BT_INQUIRE_SETUP 0x0d /* return setup data */
+#define BT_ECHO 0x1e /* Echo command data */
+#define BT_INQUIRE_DEVICES_2 0x23 /* return installed devices 8-15 */
+#define BT_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */
+#define BT_INQUIRE_REVISION_3 0x84 /* Get 3rd firmware version byte */
+#define BT_INQUIRE_REVISION_4 0x85 /* Get 4th firmware version byte */
+#define BT_INQUIRE_MODEL 0x8b /* Get hardware ID and revision */
+#define BT_INQUIRE_PERIOD 0x8c /* Get synchronous period */
+#define BT_INQUIRE_EXTENDED 0x8d /* Adapter Setup Inquiry */
+#define BT_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */
+
+/*
+ * BT_INTR bits
+ */
+#define BT_INTR_ANYINTR 0x80 /* Any interrupt */
+#define BT_INTR_SCRD 0x08 /* SCSI reset detected */
+#define BT_INTR_HACC 0x04 /* Command complete */
+#define BT_INTR_MBOA 0x02 /* MBX out empty */
+#define BT_INTR_MBIF 0x01 /* MBX in full */
+
+struct bt_mbx_out {
+ physaddr ccb_addr;
+ u_char dummy[3];
+ u_char cmd;
+};
+
+struct bt_mbx_in {
+ physaddr ccb_addr;
+ u_char dummy[3];
+ u_char stat;
+};
+
+/*
+ * mbo.cmd values
+ */
+#define BT_MBO_FREE 0x0 /* MBO entry is free */
+#define BT_MBO_START 0x1 /* MBO activate entry */
+#define BT_MBO_ABORT 0x2 /* MBO abort entry */
+
+/*
+ * mbi.stat values
+ */
+#define BT_MBI_FREE 0x0 /* MBI entry is free */
+#define BT_MBI_OK 0x1 /* completed without error */
+#define BT_MBI_ABORT 0x2 /* aborted ccb */
+#define BT_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
+#define BT_MBI_ERROR 0x4 /* Completed with error */
+
+#if defined(BIG_DMA)
+WARNING...THIS WON'T WORK(won't fit on 1 page)
+/* #define BT_NSEG 2048 /* Number of scatter gather segments - to much vm */
+#define BT_NSEG 128
+#else
+#define BT_NSEG 33
+#endif /* BIG_DMA */
+
+struct bt_scat_gath {
+ physlen seg_len;
+ physaddr seg_addr;
+};
+
+struct bt_ccb {
+ u_char opcode;
+ u_char:3, data_in:1, data_out:1,:3;
+ u_char scsi_cmd_length;
+ u_char req_sense_length;
+ /*------------------------------------longword boundary */
+ physlen data_length;
+ /*------------------------------------longword boundary */
+ physaddr data_addr;
+ /*------------------------------------longword boundary */
+ u_char dummy1[2];
+ u_char host_stat;
+ u_char target_stat;
+ /*------------------------------------longword boundary */
+ u_char target;
+ u_char lun;
+ struct scsi_generic scsi_cmd;
+ u_char dummy2[1];
+ u_char link_id;
+ /*------------------------------------longword boundary */
+ physaddr link_addr;
+ /*------------------------------------longword boundary */
+ physaddr sense_ptr;
+/*-----end of HW fields-----------------------longword boundary */
+ struct scsi_sense_data scsi_sense;
+ /*------------------------------------longword boundary */
+ struct bt_scat_gath scat_gath[BT_NSEG];
+ /*------------------------------------longword boundary */
+ TAILQ_ENTRY(bt_ccb) chain;
+ struct bt_ccb *nexthash;
+ long hashkey;
+ struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
+ int flags;
+#define CCB_ALLOC 0x01
+#define CCB_ABORT 0x02
+#ifdef BTDIAG
+#define CCB_SENDING 0x04
+#endif
+ int timeout;
+};
+
+/*
+ * opcode fields
+ */
+#define BT_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
+#define BT_TARGET_CCB 0x01 /* SCSI Target CCB */
+#define BT_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */
+#define BT_RESET_CCB 0x81 /* SCSI Bus reset */
+
+/*
+ * bt_ccb.host_stat values
+ */
+#define BT_OK 0x00 /* cmd ok */
+#define BT_LINK_OK 0x0a /* Link cmd ok */
+#define BT_LINK_IT 0x0b /* Link cmd ok + int */
+#define BT_SEL_TIMEOUT 0x11 /* Selection time out */
+#define BT_OVER_UNDER 0x12 /* Data over/under run */
+#define BT_BUS_FREE 0x13 /* Bus dropped at unexpected time */
+#define BT_INV_BUS 0x14 /* Invalid bus phase/sequence */
+#define BT_BAD_MBO 0x15 /* Incorrect MBO cmd */
+#define BT_BAD_CCB 0x16 /* Incorrect ccb opcode */
+#define BT_BAD_LINK 0x17 /* Not same values of LUN for links */
+#define BT_INV_TARGET 0x18 /* Invalid target direction */
+#define BT_CCB_DUP 0x19 /* Duplicate CCB received */
+#define BT_INV_CCB 0x1a /* Invalid CCB or segment list */
+
+struct bt_extended_inquire {
+ struct {
+ u_char opcode;
+ u_char len;
+ } cmd;
+ struct {
+ u_char bus_type; /* Type of bus connected to */
+#define BT_BUS_TYPE_24BIT 'A' /* ISA bus */
+#define BT_BUS_TYPE_32BIT 'E' /* EISA/VLB/PCI bus */
+#define BT_BUS_TYPE_MCA 'M' /* MicroChannel bus */
+ u_char bios_address; /* Address of adapter BIOS */
+ u_short max_segment; /* ? */
+ } reply;
+};
+
+struct bt_config {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char chan;
+ u_char intr;
+ u_char scsi_dev:3;
+ u_char :5;
+ } reply;
+};
+
+struct bt_toggle {
+ struct {
+ u_char opcode;
+ u_char enable;
+ } cmd;
+};
+
+struct bt_mailbox {
+ struct {
+ u_char opcode;
+ u_char nmbx;
+ physaddr addr;
+ } cmd;
+};
+
+struct bt_model {
+ struct {
+ u_char opcode;
+ u_char len;
+ } cmd;
+ struct {
+ u_char id[4]; /* i.e bt742a -> '7','4','2','A' */
+ u_char version[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */
+ } reply;
+};
+
+struct bt_revision {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char board_type;
+ u_char custom_feature;
+ char firm_revision;
+ u_char firm_version;
+ } reply;
+};
+
+struct bt_digit {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char digit;
+ } reply;
+};
+
+struct bt_devices {
+ struct {
+ u_char opcode;
+ } cmd;
+ struct {
+ u_char junk[8];
+ } reply;
+};
+
+struct bt_setup {
+ struct {
+ u_char opcode;
+ u_char len;
+ } cmd;
+ struct {
+ u_char sync_neg:1;
+ u_char parity:1;
+ u_char :6;
+ u_char speed;
+ u_char bus_on;
+ u_char bus_off;
+ u_char num_mbx;
+ u_char mbx[3]; /*XXX */
+ /* doesn't make sense with 32bit addresses */
+ struct {
+ u_char offset:4;
+ u_char period:3;
+ u_char valid:1;
+ } sync[8];
+ u_char disc_sts;
+ } reply;
+};
+
+struct bt_period {
+ struct {
+ u_char opcode;
+ u_char len;
+ } cmd;
+ struct {
+ u_char period[8];
+ } reply;
+};
+
+#define INT9 0x01
+#define INT10 0x02
+#define INT11 0x04
+#define INT12 0x08
+#define INT14 0x20
+#define INT15 0x40
+
+#define EISADMA 0x00
+#define CHAN0 0x01
+#define CHAN5 0x20
+#define CHAN6 0x40
+#define CHAN7 0x80
-/* $OpenBSD: com.c,v 1.10 1996/04/18 23:47:32 niklas Exp $ */
-/* $NetBSD: com.c,v 1.75 1996/03/10 09:01:24 cgd Exp $ */
+/* $OpenBSD: com.c,v 1.11 1996/04/21 22:23:15 deraadt Exp $ */
+/* $NetBSD: com.c,v 1.79 1996/04/15 18:54:31 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996
#include <sys/types.h>
#include <sys/device.h>
-#include <machine/cpu.h>
+#ifdef i386 /* XXX */
+#include <machine/cpu.h> /* XXX */
+#else /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <machine/bus.h>
#include <dev/isa/isavar.h>
#endif
#define com_lcr com_cfcr
+#include "com.h"
+
#define COM_IBUFSIZE (2 * 512)
#define COM_IHIGHWATER ((3 * COM_IBUFSIZE) / 4)
u_char sc_ibufs[2][COM_IBUFSIZE];
};
-int comprobe __P((struct device *, void *, void *));
#ifdef COM_HAYESP
int comprobeHAYESP __P((bus_io_handle_t hayespioh, struct com_softc *sc));
#endif
-void comattach __P((struct device *, struct device *, void *));
int comopen __P((dev_t, int, int, struct proc *));
int comclose __P((dev_t, int, int, struct proc *));
void comdiag __P((void *));
int comparam __P((struct tty *, struct termios *));
void comstart __P((struct tty *));
-int cominit __P((bus_chipset_tag_t, bus_io_handle_t, int));
+/*
+ * XXX the following two cfattach structs should be different, and possibly
+ * XXX elsewhere.
+ */
+int comprobe __P((struct device *, void *, void *));
+void comattach __P((struct device *, struct device *, void *));
+
+#if NCOM_ISA
+struct cfattach com_isa_ca = {
+ sizeof(struct com_softc), comprobe, comattach
+};
+#endif
-struct cfdriver comcd = {
- NULL, "com", comprobe, comattach, DV_TTY, sizeof(struct com_softc)
+#if NCOM_COMMULTI
+struct cfattach com_commulti_ca = {
+ sizeof(struct com_softc), comprobe, comattach
};
+#endif
+
+struct cfdriver com_cd = {
+ NULL, "com", DV_TTY
+};
+
+int cominit __P((bus_chipset_tag_t, bus_io_handle_t, int));
#ifdef COMCONSOLE
int comdefaultrate = CONSPEED; /* XXX why set default? */
int comconsattached;
bus_chipset_tag_t comconsbc;
bus_io_handle_t comconsioh;
+tcflag_t comconscflag = TTYDEF_CFLAG;
int commajor;
int comsopen = 0;
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
-#include "pcmciabus.h"
+/*#include "pcmciabus.h"*/
#if NPCMCIABUS >0
/* additional setup needed for pcmcia devices */
#include <dev/pcmcia/pcmciabus.h>
int iobase, needioh;
int rv = 1;
+ /*
+ * XXX should be broken out into functions for isa probe and
+ * XXX for commulti probe, with a helper function that contains
+ * XXX most of the interesting stuff.
+ */
+#if NCOM_ISA
if (!strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
struct isa_attach_args *ia = aux;
bc = ia->ia_bc;
iobase = ia->ia_iobase;
needioh = 1;
- } else {
+ } else
+#endif
+#if NCOM_COMMULTI
+ if (1) {
struct commulti_attach_args *ca = aux;
if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave)
iobase = ca->ca_iobase;
ioh = ca->ca_ioh;
needioh = 0;
- }
+ } else
+#endif
+ return(0); /* This cannot happen */
/* if it's in use as console, it's there. */
if (iobase == comconsaddr && !comconsattached)
bus_io_unmap(bc, ioh, COM_NPORTS);
out:
+#if NCOM_ISA
if (rv && !strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
struct isa_attach_args *ia = aux;
ia->ia_iosize = COM_NPORTS;
ia->ia_msize = 0;
}
+#endif
return (rv);
}
int *hayespp;
#endif
+ /*
+ * XXX should be broken out into functions for isa attach and
+ * XXX for commulti attach, with a helper function that contains
+ * XXX most of the interesting stuff.
+ */
sc->sc_hwflags = 0;
sc->sc_swflags = 0;
+#if NCOM_ISA
if (!strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
struct isa_attach_args *ia = aux;
} else
ioh = comconsioh;
irq = ia->ia_irq;
- } else {
+ } else
+#endif
+#if NCOM_COMMULTI
+ if (1) {
struct commulti_attach_args *ca = aux;
/*
if (ca->ca_noien)
sc->sc_hwflags |= COM_HW_NOIEN;
- }
+ } else
+#endif
+ panic("comattach: impossible");
sc->sc_bc = bc;
sc->sc_ioh = ioh;
bus_io_write_1(bc, ioh, com_ier, 0);
bus_io_write_1(bc, ioh, com_mcr, 0);
- if (irq != IRQUNK)
- sc->sc_ih = isa_intr_establish(irq, IST_EDGE, IPL_TTY,
- comintr, sc, sc->sc_dev.dv_xname);
+ if (irq != IRQUNK) {
+#if NCOM_ISA
+ if (!strcmp(parent->dv_cfdata->cf_driver->cd_name, "isa")) {
+ struct isa_attach_args *ia = aux;
+
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
+ IST_EDGE, IPL_TTY, comintr, sc,
+ sc->sc_dev.dv_xname);
+ } else
+#endif
+ panic("comattach: IRQ but can't have one");
+ }
#ifdef KGDB
if (kgdb_dev == makedev(commajor, unit)) {
int s;
int error = 0;
- if (unit >= comcd.cd_ndevs)
+ if (unit >= com_cd.cd_ndevs)
return ENXIO;
- sc = comcd.cd_devs[unit];
+ sc = com_cd.cd_devs[unit];
if (!sc)
return ENXIO;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
- tp->t_cflag = TTYDEF_CFLAG;
+ if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
+ tp->t_cflag = comconscflag;
+ else
+ tp->t_cflag = TTYDEF_CFLAG;
if (ISSET(sc->sc_swflags, COM_SW_CLOCAL))
SET(tp->t_cflag, CLOCAL);
if (ISSET(sc->sc_swflags, COM_SW_CRTSCTS))
struct proc *p;
{
int unit = COMUNIT(dev);
- struct com_softc *sc = comcd.cd_devs[unit];
+ struct com_softc *sc = com_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
struct uio *uio;
int flag;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
struct uio *uio;
int flag;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
struct tty *tp = sc->sc_tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
comtty(dev)
dev_t dev;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
struct tty *tp = sc->sc_tty;
return (tp);
struct proc *p;
{
int unit = COMUNIT(dev);
- struct com_softc *sc = comcd.cd_devs[unit];
+ struct com_softc *sc = com_cd.cd_devs[unit];
struct tty *tp = sc->sc_tty;
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
struct tty *tp;
struct termios *t;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(tp->t_dev)];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
int ospeed = comspeed(t->c_ospeed);
comstart(tp)
struct tty *tp;
{
- struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
+ struct com_softc *sc = com_cd.cd_devs[COMUNIT(tp->t_dev)];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
int s;
comevents = 0;
splx(s);
- for (unit = 0; unit < comcd.cd_ndevs; unit++) {
- sc = comcd.cd_devs[unit];
+ for (unit = 0; unit < com_cd.cd_ndevs; unit++) {
+ sc = com_cd.cd_devs[unit];
if (sc == 0 || sc->sc_ibufp == sc->sc_ibuf)
continue;
-/* $OpenBSD: comvar.h,v 1.1 1996/04/19 16:08:34 niklas Exp $ */
-/* $NetBSD: comvar.h,v 1.3 1996/03/10 09:01:26 cgd Exp $ */
+/* $OpenBSD: comvar.h,v 1.2 1996/04/21 22:23:20 deraadt Exp $ */
+/* $NetBSD: comvar.h,v 1.4 1996/04/15 18:54:35 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
extern int comconsattached;
extern bus_chipset_tag_t comconsbc;
extern bus_io_handle_t comconsioh;
+extern tcflag_t comconscflag;
-/* $OpenBSD: fd.c,v 1.12 1996/04/18 17:12:13 niklas Exp $ */
-/* $NetBSD: fd.c,v 1.85 1996/03/04 04:01:03 mycroft Exp $ */
+/* $OpenBSD: fd.c,v 1.13 1996/04/21 22:16:52 deraadt Exp $ */
+/* $NetBSD: fd.c,v 1.87 1996/04/11 22:15:16 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
#endif
void fdcattach __P((struct device *, struct device *, void *));
-struct cfdriver fdccd = {
- NULL, "fdc", fdcprobe, fdcattach, DV_DULL, sizeof(struct fdc_softc)
+struct cfattach fdc_ca = {
+ sizeof(struct fdc_softc), fdcprobe, fdcattach
+};
+
+struct cfdriver fdc_cd = {
+ NULL, "fdc", DV_DULL
};
/*
int fdprobe __P((struct device *, void *, void *));
void fdattach __P((struct device *, struct device *, void *));
-struct cfdriver fdcd = {
- NULL, "fd", fdprobe, fdattach, DV_DISK, sizeof(struct fd_softc)
+struct cfattach fd_ca = {
+ sizeof(struct fd_softc), fdprobe, fdattach
+};
+
+struct cfdriver fd_cd = {
+ NULL, "fd", DV_DISK
};
void fdgetdisklabel __P((struct fd_softc *));
at_setup_dmachan(fdc->sc_drq, FDC_MAXIOSIZE);
isa_establish(&fdc->sc_id, &fdc->sc_dev);
#endif
- fdc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, fdcintr,
- fdc, fdc->sc_dev.dv_xname);
+ fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, fdcintr, fdc, fdc->sc_dev.dv_xname);
/*
* The NVRAM info only tells us about the first two disks on the
int s;
/* Valid unit, controller, and request? */
- if (unit >= fdcd.cd_ndevs ||
- (fd = fdcd.cd_devs[unit]) == 0 ||
+ if (unit >= fd_cd.cd_ndevs ||
+ (fd = fd_cd.cd_devs[unit]) == 0 ||
bp->b_blkno < 0 ||
(bp->b_bcount % FDC_BSIZE) != 0) {
bp->b_error = EINVAL;
struct fd_type *type;
unit = FDUNIT(dev);
- if (unit >= fdcd.cd_ndevs)
+ if (unit >= fd_cd.cd_ndevs)
return ENXIO;
- fd = fdcd.cd_devs[unit];
+ fd = fd_cd.cd_devs[unit];
if (fd == 0)
return ENXIO;
type = fd_dev_to_type(fd, dev);
dev_t dev;
int flags;
{
- struct fd_softc *fd = fdcd.cd_devs[FDUNIT(dev)];
+ struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
fd->sc_flags &= ~FD_OPEN;
return 0;
caddr_t addr;
int flag;
{
- struct fd_softc *fd = fdcd.cd_devs[FDUNIT(dev)];
+ struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
struct disklabel buffer;
int error;
-# $OpenBSD: files.isa,v 1.7 1996/04/18 23:47:33 niklas Exp $
-# $NetBSD: files.isa,v 1.12 1996/03/04 03:29:16 cgd Exp $
+# $OpenBSD: files.isa,v 1.8 1996/04/21 22:23:23 deraadt Exp $
+# $NetBSD: files.isa,v 1.17 1996/03/29 20:53:30 mycroft Exp $
#
# Config.new file and device description for machine-independent ISA code.
# Included by ports that need it. Requires that the SCSI files be
# devices:
# mcd, scd, wd, wt
-define isa {[port = -1], [size = 0],
- [iomem = -1], [iosiz = 0],
- [irq = -1], [drq = -1]}
-
-device isa at isabus: isa
+device isa {[port = -1], [size = 0],
+ [iomem = -1], [iosiz = 0],
+ [irq = -1], [drq = -1]}
+attach isa at isabus
file dev/isa/isa.c isa needs-flag
# ISA DMA controller
define pcicbus {[iomem = -1], [iosiz = 0]}
-device pcic at isa: pcicbus
+device pcic: pcicbus
+attach pcic at isa
file dev/isa/pcmcia_pcic.c pcic
file dev/isa/pcmcia_isa.c pcmcia
define commulti {[slave = -1]}
# AST 4-port board
-device ast at isa: commulti
+device ast: commulti
+attach ast at isa
file dev/isa/ast.c ast
# BOCA 8-port board
-device boca at isa: commulti
+device boca: commulti
+attach boca at isa
file dev/isa/boca.c boca
# IBM RT PC 4-port board
-device rtfps at isa: commulti
+device rtfps: commulti
+attach rtfps at isa
file dev/isa/rtfps.c rtfps
#
#
# 8250/16[45]50-based "com" ports
-device com at isa, commulti: tty
-file dev/isa/com.c com needs-flag
+device com: tty
+attach com at isa with com_isa
+attach com at commulti with com_commulti
+file dev/isa/com.c com & (com_isa | com_commulti) needs-flag
# Cyclades Cyclom multiport serial cards
# XXX currently broken
-device cy at isa: tty
+device cy: tty
+attach cy at isa
file dev/isa/cy.c cy needs-count
# PC parallel ports (XXX what chip?)
-device lpt at isa
+device lpt
+attach lpt at isa
file dev/isa/lpt.c lpt needs-flag
#
#
# Adaptec AHA-154x family
-device aha at isa: scsi, isadma
-file dev/isa/aha1542.c aha
+device aha: scsi, isadma
+attach aha at isa
+file dev/isa/aha.c aha
# Adapctec AIC-6[32]60 ICs
-device aic at isa: scsi, isadma
+device aic: scsi, isadma
+attach aic at isa
file dev/isa/aic6360.c aic
# Adaptec 7770-based EISA, VLB, etc. controllers
-device ahe at isa: scsi, aic7xxx
+device ahe: scsi, aic7xxx
+attach ahe at isa
file dev/isa/aha284x.c ahe
# BusLogic BT-74x EISA family (XXX; should be EISA. it's special)
-device bt at isa: scsi, isadma
-file dev/isa/bt742a.c bt
+device bt: scsi, isadma
+attach bt at isa
+file dev/isa/bt.c bt
# Seagate ST0[12] ICs
-device sea at isa: scsi, isadma
+device sea: scsi, isadma
+attach sea at isa
file dev/isa/seagate.c sea
# UltraStor UHA-[13]4f boards
-device uha at isa: scsi, isadma
+device uha: scsi, isadma
+attach uha at isa
file dev/isa/ultra14f.c uha
-# Western Digital WD7000 boards (XXX incomplete description)
-# XXX not yet working
-device wds at isa: scsi, isadma
-file dev/isa/wd7000.c wds
+# Western Digital WD7000 and Future Domain TMC-7000 boards
+device wds: scsi, isadma
+attach wds at isa
+file dev/isa/wds.c wds
#
# Other ISA disk controllers
#
# Mitsumi CD-ROM controllers
-device mcd at isa: disk
+device mcd: disk
+attach mcd at isa
file dev/isa/mcd.c mcd needs-flag
# Sony CDU-3[13]A CD-ROM drives
-device scd at isa: disk
+device scd: disk
+attach scd at isa
file dev/isa/scd.c scd needs-flag
# ISA "wd" (ESDI/IDE/etc.) controllers
-device wdc at isa {drive = -1}
-device wd at wdc: disk, isadma
+device wdc {drive = -1}
+attach wdc at isa
+device wd: disk, isadma
+attach wd at wdc
file dev/isa/wd.c wdc needs-flag
# Wangtek- and Archive-compatible tape controller boards
-device wt at isa: tape, isadma
+device wt: tape, isadma
+attach wt at isa
file dev/isa/wt.c wt needs-flag
#
# National Semiconductor DS8390/WD83C690-based boards
# (WD/SMC 80x3 family, SMC Ultra [8216], 3Com 3C503, NE[12]000, and clones)
# XXX conflicts with amiga if_ed.c
-#device ed at isa, pcmcia: ether, ifnet
-#file dev/isa/if_ed.c ed needs-flag
+device ed: ether, ifnet
+attach ed at isa
+file dev/isa/if_ed.c ed needs-flag
# 3Com 3C505
-device eg at isa: ether, ifnet
+device eg: ether, ifnet
+attach eg at isa
file dev/isa/if_eg.c eg
# 3Com 3C501
-device el at isa: ether, ifnet
+device el: ether, ifnet
+attach el at isa
file dev/isa/if_el.c el
# 3Com 3C5x9, 3c59x (EtherLink III) family
-device ep at isa, pci: ether, ifnet, elink
+device ep: ether, ifnet, elink
+attach ep at isa with ep_isa
+attach ep at pci with ep_pci
file dev/isa/if_ep.c ep needs-flag
# Fujitsu MB8696[05]-based boards
# (Allied Telesis AT1700)
-device fe at isa: ether, ifnet
+device fe: ether, ifnet
+attach fe at isa
file dev/isa/if_fe.c fe
# HP Lan Ethernet controllers
# XXX currently broken
-#device hp at isa: ether, ifnet
+#device hp: ether, ifnet
+#attach hp at isa
#file dev/isa/if_hp.c hp
# Intel i82586-based boards
# (AT&T StarLAN 10, AT&T EN100, AT&T StarLAN Fiber, 3Com 3C507)
-device ie at isa: ether, ifnet, elink
+device ie: ether, ifnet, elink
+attach ie at isa
file dev/isa/if_ie.c ie
# XXX ???
# XXX NOT IN TREE?
-#device ix at isa: ether, ifnet
+#device ix: ether, ifnet
+#attach ix at isa
#file dev/isa/if_ix.c ix
# AMD am7990 (Lance) -based boards
# (BICC Isolan, NE2100, DEPCA)
# XXX conflicts with alpha if_le.c
-#device le at isa: ether, ifnet, isadma
+#device le: ether, ifnet, isadma
+#attach le at isa with le_isa
#file dev/isa/if_le.c le
#
file dev/isa/sbdsp.c sbdsp
# SoundBlaster family
-device sb at isa: audio, isadma, sbdsp, mulaw
+device sb: audio, isadma, sbdsp, mulaw
+attach sb at isa
file dev/isa/sb.c sb needs-flag
# ProAudio Spectrum
-device pas at isa: audio, isadma, sbdsp, mulaw
+device pas: audio, isadma, sbdsp, mulaw
+attach pas at isa
file dev/isa/pas.c pas needs-flag
# AD1848 (CS4248, CS4231, AD1845) audio codec support; used by other drivers
# Audio systems based on Echo Speech Corp. ESC61[45] ASICs
-device pss at isa {[port = -1], [size = 0],
- [iomem = -1], [iosiz = 0],
- [irq = -1], [drq = -1]}
-device sp at pss: audio, isadma, ad1848
+device pss {[port = -1], [size = 0],
+ [iomem = -1], [iosiz = 0],
+ [irq = -1], [drq = -1]}
+attach pss at isa
+device sp: audio, isadma, ad1848
+attach sp at pss
file dev/isa/pss.c pss needs-flag
# Microsoft Windows Sound System
-device wss at isa: audio, isadma, ad1848
+device wss: audio, isadma, ad1848
+attach wss at isa
file dev/isa/wss.c wss needs-flag
# Gravis UltraSound & UltraSound MAX.
# Use the "flags" keyword in a config file to specify an extra DMA
# channel for full-duplex operation.
-device gus at isa: audio, isadma, ics2101, ad1848, mulaw
+device gus: audio, isadma, ics2101, ad1848, mulaw
+attach gus at isa
file dev/isa/gus.c gus needs-flag
-/* $OpenBSD: gus.c,v 1.8 1996/04/18 23:47:34 niklas Exp $ */
-/* $NetBSD: gus.c,v 1.10 1996/03/01 04:08:31 mycroft Exp $ */
+/* $OpenBSD: gus.c,v 1.9 1996/04/21 22:23:28 deraadt Exp $ */
+/* $NetBSD: gus.c,v 1.13 1996/04/11 22:28:42 cgd Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
#include <dev/ic/ad1848reg.h>
#include <dev/isa/ics2101var.h>
#include <dev/isa/ad1848var.h>
+#include <dev/isa/cs4231var.h>
#include "gusreg.h"
#ifdef AUDIO_DEBUG
int gusprobe __P((struct device *, void *, void *));
void gusattach __P((struct device *, struct device *, void *));
-struct cfdriver guscd = {
- NULL, "gus", gusprobe, gusattach, DV_DULL, sizeof(struct gus_softc)
+struct cfattach gus_ca = {
+ sizeof(struct gus_softc), gusprobe, gusattach,
+};
+
+struct cfdriver gus_cd = {
+ NULL, "gus", DV_DULL
};
/* XXX we shouldn't have to use splgus == splclock, nor should
* we use IPL_CLOCK.
*/
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_AUDIO, gusintr,
- sc /* sc->sc_gusdsp */, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_AUDIO, gusintr, sc /* sc->sc_gusdsp */, sc->sc_dev.dv_xname);
/*
* Set some default values
DPRINTF(("gusopen() called\n"));
- if (unit >= guscd.cd_ndevs)
+ if (unit >= gus_cd.cd_ndevs)
return ENXIO;
- sc = guscd.cd_devs[unit];
+ sc = gus_cd.cd_devs[unit];
if (!sc)
return ENXIO;
-/* $OpenBSD: if_ed.c,v 1.9 1996/04/18 23:47:37 niklas Exp $ */
-/* $NetBSD: if_ed.c,v 1.90 1996/03/16 07:24:15 cgd Exp $ */
+/* $OpenBSD: if_ed.c,v 1.10 1996/04/21 22:23:41 deraadt Exp $ */
+/* $NetBSD: if_ed.c,v 1.93 1996/04/11 22:28:55 cgd Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
* similar clones.
*/
-#include "pcmciabus.h"
#include "bpfilter.h"
#include <sys/param.h>
#endif
#include <machine/cpu.h>
-#include <machine/pio.h>
+#include <machine/bus.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
-#include <i386/isa/isa_machdep.h> /* XXX USES ISA HOLE DIRECTLY */
#define ED_BYTE_ORDER LITTLE_ENDIAN
#include <dev/ic/dp8390reg.h>
#include <dev/isa/if_edreg.h>
#define ED_NOTPRESENT 0x0002 /* card not present; do not allow
reconfiguration */
- int asic_base; /* Base ASIC I/O port */
- int nic_base; /* Base NIC (DS8390) I/O port */
+ bus_chipset_tag_t sc_bc; /* bus identifier */
+ bus_io_handle_t sc_ioh; /* io handle */
+ bus_mem_handle_t sc_memh; /* bus memory handle */
+
+ bus_io_size_t asic_base; /* offset of ASIC I/O port */
+ bus_io_size_t nic_base; /* offset of NIC (DS8390) I/O port */
/*
* The following 'proto' variable is part of a work-around for 8013EBT asics
u_char isa16bit; /* width of access to card 0=8 or 1=16 */
u_char is790; /* set by probe if NIC is a 790 */
- caddr_t mem_start; /* NIC memory start address */
- caddr_t mem_end; /* NIC memory end address */
- u_long mem_size; /* total NIC memory size */
- caddr_t mem_ring; /* start of RX ring-buffer (in NIC mem) */
+ int mem_start; /* offset of NIC memory */
+ int mem_end; /* offset of NIC memory end */
+ int mem_size; /* total NIC memory size */
+ int mem_ring; /* offset of RX ring-buffer (in NIC mem) */
u_char mem_shared; /* NIC memory is shared with host */
u_char txb_cnt; /* number of transmit buffers */
void edattach __P((struct device *, struct device *, void *));
int ed_find __P((struct ed_softc *, struct cfdata *,
struct isa_attach_args *ia));
-int ed_probe_generic8390 __P((int));
+int ed_probe_generic8390 __P((bus_chipset_tag_t, bus_io_handle_t, int));
int ed_find_WD80x3 __P((struct ed_softc *, struct cfdata *,
struct isa_attach_args *ia));
int ed_find_3Com __P((struct ed_softc *, struct cfdata *,
void edinit __P((struct ed_softc *));
void edstop __P((struct ed_softc *));
+void ed_shared_writemem __P((struct ed_softc *, caddr_t, int, int));
+void ed_shared_readmem __P((struct ed_softc *, int, caddr_t, int));
+
#define inline /* XXX for debugging porpoises */
void ed_getmcaf __P((struct arpcom *, u_long *));
-void edread __P((struct ed_softc *, caddr_t, int));
-struct mbuf *edget __P((struct ed_softc *, caddr_t, int));
+void edread __P((struct ed_softc *, int, int));
+struct mbuf *edget __P((struct ed_softc *, int, int));
static inline void ed_rint __P((struct ed_softc *));
static inline void ed_xmit __P((struct ed_softc *));
-static inline caddr_t ed_ring_copy __P((struct ed_softc *, caddr_t, caddr_t,
+static inline int ed_ring_copy __P((struct ed_softc *, int, caddr_t,
u_short));
void ed_pio_readmem __P((struct ed_softc *, u_short, caddr_t, u_short));
void ed_pio_writemem __P((struct ed_softc *, caddr_t, u_short, u_short));
u_short ed_pio_write_mbufs __P((struct ed_softc *, struct mbuf *, u_short));
-struct cfdriver edcd = {
- NULL, "ed", edprobe, edattach, DV_IFNET, sizeof(struct ed_softc)
+struct cfattach ed_ca = {
+ sizeof(struct ed_softc), edprobe, edattach
+};
+
+struct cfdriver ed_cd = {
+ NULL, "ed", DV_IFNET
};
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
-#define NIC_PUT(base, off, val) outb((base) + (off), (val))
-#define NIC_GET(base, off) inb((base) + (off))
+#define NIC_PUT(bc, ioh, nic, reg, val) \
+ bus_io_write_1((bc), (ioh), ((nic) + (reg)), (val))
+#define NIC_GET(bc, ioh, nic, reg) \
+ bus_io_read_1((bc), (ioh), ((nic) + (reg)))
+/*#include "pcmciabus.h"*/
#if NPCMCIABUS > 0
#include <dev/pcmcia/pcmciabus.h>
* Return 1 if 8390 was found, 0 if not.
*/
int
-ed_probe_generic8390(nicbase)
+ed_probe_generic8390(bc, ioh, nicbase)
+ bus_chipset_tag_t bc;
+ bus_io_handle_t ioh;
int nicbase;
{
- if ((NIC_GET(nicbase, ED_P0_CR) &
+ if ((NIC_GET(bc, ioh, nicbase, ED_P0_CR) &
(ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) !=
(ED_CR_RD2 | ED_CR_STP))
return (0);
- if ((NIC_GET(nicbase, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
+ if ((NIC_GET(bc, ioh, nicbase, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
return (0);
return (1);
struct cfdata *cf;
struct isa_attach_args *ia;
{
- int i;
+ bus_chipset_tag_t bc;
+ bus_io_handle_t ioh;
+ bus_mem_handle_t memh;
u_int memsize;
u_char iptr, isa16bit, sum;
+ int i, rv, mapped_mem = 0;
int asicbase, nicbase;
- sc->asic_base = asicbase = ia->ia_iobase;
+ bc = ia->ia_bc;
+ rv = 0;
+
+ if (bus_io_map(bc, ia->ia_iobase, ED_WD_IO_PORTS, &ioh))
+ return (0);
+
+ sc->asic_base = asicbase = 0;
sc->nic_base = nicbase = asicbase + ED_WD_NIC_OFFSET;
sc->is790 = 0;
#ifdef TOSH_ETHER
- outb(asicbase + ED_WD_MSR, ED_WD_MSR_POW);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, ED_WD_MSR_POW);
delay(10000);
#endif
* Danpex boards for one.
*/
for (sum = 0, i = 0; i < 8; ++i)
- sum += inb(asicbase + ED_WD_PROM + i);
+ sum += bus_io_read_1(bc, ioh, asicbase + ED_WD_PROM + i);
if (sum != ED_WD_ROM_CHECKSUM_TOTAL) {
/*
* clones. In this case, the checksum byte (the eighth byte)
* seems to always be zero.
*/
- if (inb(asicbase + ED_WD_CARD_ID) != ED_TYPE_WD8003E ||
- inb(asicbase + ED_WD_PROM + 7) != 0)
- return (0);
+ if (bus_io_read_1(bc, ioh, asicbase + ED_WD_CARD_ID) !=
+ ED_TYPE_WD8003E ||
+ bus_io_read_1(bc, ioh, asicbase + ED_WD_PROM + 7) != 0)
+ goto out;
}
/* Reset card to force it into a known state. */
#ifdef TOSH_ETHER
- outb(asicbase + ED_WD_MSR, ED_WD_MSR_RST | ED_WD_MSR_POW);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
+ ED_WD_MSR_RST | ED_WD_MSR_POW);
#else
- outb(asicbase + ED_WD_MSR, ED_WD_MSR_RST);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, ED_WD_MSR_RST);
#endif
delay(100);
- outb(asicbase + ED_WD_MSR,
- inb(asicbase + ED_WD_MSR) & ~ED_WD_MSR_RST);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
+ bus_io_read_1(bc, ioh, asicbase + ED_WD_MSR) & ~ED_WD_MSR_RST);
/* Wait in the case this card is reading it's EEROM. */
delay(5000);
sc->vendor = ED_VENDOR_WD_SMC;
- sc->type = inb(asicbase + ED_WD_CARD_ID);
+ sc->type = bus_io_read_1(bc, ioh, asicbase + ED_WD_CARD_ID);
/* Set initial values for width/size. */
memsize = 8192;
case ED_TYPE_SMC8216T:
sc->type_str = (sc->type == ED_TYPE_SMC8216C) ?
"SMC8216/SMC8216C" : "SMC8216T";
- outb(asicbase + ED_WD790_HWR,
- inb(asicbase + ED_WD790_HWR) | ED_WD790_HWR_SWH);
- switch (inb(asicbase + ED_WD790_RAR) & ED_WD790_RAR_SZ64) {
+ bus_io_write_1(bc, ioh, asicbase + ED_WD790_HWR,
+ bus_io_read_1(bc, ioh, asicbase + ED_WD790_HWR)
+ | ED_WD790_HWR_SWH);
+ switch (bus_io_read_1(bc, ioh, asicbase + ED_WD790_RAR) &
+ ED_WD790_RAR_SZ64) {
case ED_WD790_RAR_SZ64:
memsize = 65536;
break;
memsize = 8192;
break;
}
- outb(asicbase + ED_WD790_HWR,
- inb(asicbase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD790_HWR,
+ bus_io_read_1(bc, ioh,
+ asicbase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
isa16bit = 1;
sc->is790 = 1;
#ifdef TOSH_ETHER
(sc->type != ED_TYPE_TOSHIBA1) && (sc->type != ED_TYPE_TOSHIBA4) &&
#endif
- ((inb(asicbase + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
+ ((bus_io_read_1(bc, ioh,
+ asicbase + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
isa16bit = 0;
memsize = 8192;
}
if (sc->is790) {
u_char x;
/* Assemble together the encoded interrupt number. */
- outb(ia->ia_iobase + ED_WD790_HWR,
- inb(ia->ia_iobase + ED_WD790_HWR) | ED_WD790_HWR_SWH);
- x = inb(ia->ia_iobase + ED_WD790_GCR);
+ bus_io_write_1(bc, ioh, ED_WD790_HWR,
+ bus_io_read_1(bc, ioh, ED_WD790_HWR) | ED_WD790_HWR_SWH);
+ x = bus_io_read_1(bc, ioh, ED_WD790_GCR);
iptr = ((x & ED_WD790_GCR_IR2) >> 4) |
((x & (ED_WD790_GCR_IR1|ED_WD790_GCR_IR0)) >> 2);
- outb(ia->ia_iobase + ED_WD790_HWR,
- inb(ia->ia_iobase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
+ bus_io_write_1(bc, ioh, ED_WD790_HWR,
+ bus_io_read_1(bc, ioh, ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
/*
* Translate it using translation table, and check for
* correctness.
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
sc->sc_dev.dv_xname, ia->ia_irq,
ed_wd790_irq[iptr]);
- return (0);
+ goto out;
}
} else
ia->ia_irq = ed_wd790_irq[iptr];
/* Enable the interrupt. */
- outb(ia->ia_iobase + ED_WD790_ICR,
- inb(ia->ia_iobase + ED_WD790_ICR) | ED_WD790_ICR_EIL);
+ bus_io_write_1(bc, ioh, ED_WD790_ICR,
+ bus_io_read_1(bc, ioh, ED_WD790_ICR) | ED_WD790_ICR_EIL);
} else if (sc->type & ED_WD_SOFTCONFIG) {
/* Assemble together the encoded interrupt number. */
- iptr = (inb(ia->ia_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) |
- ((inb(ia->ia_iobase + ED_WD_IRR) &
+ iptr = (bus_io_read_1(bc, ioh, ED_WD_ICR) & ED_WD_ICR_IR2) |
+ ((bus_io_read_1(bc, ioh, ED_WD_IRR) &
(ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5);
/*
* Translate it using translation table, and check for
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
sc->sc_dev.dv_xname, ia->ia_irq,
ed_wd584_irq[iptr]);
- return (0);
+ goto out;
}
} else
ia->ia_irq = ed_wd584_irq[iptr];
/* Enable the interrupt. */
- outb(ia->ia_iobase + ED_WD_IRR,
- inb(ia->ia_iobase + ED_WD_IRR) | ED_WD_IRR_IEN);
+ bus_io_write_1(bc, ioh, ED_WD_IRR,
+ bus_io_read_1(bc, ioh, ED_WD_IRR) | ED_WD_IRR_IEN);
} else {
if (ia->ia_irq == IRQUNK) {
printf("%s: %s does not have soft configuration\n",
sc->sc_dev.dv_xname, sc->type_str);
- return (0);
+ goto out;
}
}
sc->isa16bit = isa16bit;
sc->mem_shared = 1;
ia->ia_msize = memsize;
- sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
+ if (bus_mem_map(bc, ia->ia_maddr, memsize, 0, &memh))
+ goto out;
+ mapped_mem = 1;
+ sc->mem_start = 0; /* offset */
/* Allocate one xmit buffer if < 16k, two buffers otherwise. */
if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
/* Get station address from on-board ROM. */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
sc->sc_arpcom.ac_enaddr[i] =
- inb(asicbase + ED_WD_PROM + i);
+ bus_io_read_1(bc, ioh, asicbase + ED_WD_PROM + i);
/*
* Set upper address bits and 8/16 bit access to shared memory.
if (isa16bit) {
if (sc->is790) {
sc->wd_laar_proto =
- inb(asicbase + ED_WD_LAAR) &
+ bus_io_read_1(bc, ioh, asicbase + ED_WD_LAAR) &
~ED_WD_LAAR_M16EN;
} else {
sc->wd_laar_proto =
ED_WD_LAAR_L16EN |
- ((kvtop(sc->mem_start) >> 19) &
+ ((ia->ia_maddr >> 19) &
ED_WD_LAAR_ADDRHI);
}
- outb(asicbase + ED_WD_LAAR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
} else {
if ((sc->type & ED_WD_SOFTCONFIG) ||
#endif
(sc->type == ED_TYPE_WD8013EBT) && !sc->is790) {
sc->wd_laar_proto =
- ((kvtop(sc->mem_start) >> 19) &
+ ((ia->ia_maddr >> 19) &
ED_WD_LAAR_ADDRHI);
- outb(asicbase + ED_WD_LAAR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
sc->wd_laar_proto);
}
}
*/
if (!sc->is790) {
#ifdef TOSH_ETHER
- outb(asicbase + ED_WD_MSR + 1,
- ((kvtop(sc->mem_start) >> 8) & 0xe0) | 4);
- outb(asicbase + ED_WD_MSR + 2,
- ((kvtop(sc->mem_start) >> 16) & 0x0f));
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR + 1,
+ ((ia->ia_maddr >> 8) & 0xe0) | 4);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR + 2,
+ ((ia->ia_maddr >> 16) & 0x0f));
sc->wd_msr_proto = ED_WD_MSR_POW;
#else
sc->wd_msr_proto =
- (kvtop(sc->mem_start) >> 13) & ED_WD_MSR_ADDR;
+ (ia->ia_maddr >> 13) & ED_WD_MSR_ADDR;
#endif
sc->cr_proto = ED_CR_RD2;
} else {
- outb(asicbase + 0x04,
- inb(asicbase + 0x04) | 0x80);
- outb(asicbase + 0x0b,
- ((kvtop(sc->mem_start) >> 13) & 0x0f) |
- ((kvtop(sc->mem_start) >> 11) & 0x40) |
- (inb(asicbase + 0x0b) & 0xb0));
- outb(asicbase + 0x04,
- inb(asicbase + 0x04) & ~0x80);
+ bus_io_write_1(bc, ioh, asicbase + 0x04,
+ bus_io_read_1(bc, ioh, asicbase + 0x04) | 0x80);
+ bus_io_write_1(bc, ioh, asicbase + 0x0b,
+ ((ia->ia_maddr >> 13) & 0x0f) |
+ ((ia->ia_maddr >> 11) & 0x40) |
+ (bus_io_read_1(bc, ioh, asicbase + 0x0b) & 0xb0));
+ bus_io_write_1(bc, ioh, asicbase + 0x04,
+ bus_io_read_1(bc, ioh, asicbase + 0x04) & ~0x80);
sc->wd_msr_proto = 0x00;
sc->cr_proto = 0;
}
- outb(asicbase + ED_WD_MSR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
sc->wd_msr_proto | ED_WD_MSR_MENB);
- (void) inb(0x84);
- (void) inb(0x84);
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
/* Now zero memory and verify that it is clear. */
- bzero(sc->mem_start, memsize);
+ for (i = 0; i < memsize; ++i)
+ bus_mem_write_1(bc, memh, sc->mem_start + i, 0);
for (i = 0; i < memsize; ++i)
- if (sc->mem_start[i]) {
+ if (bus_mem_read_1(bc, memh, sc->mem_start + i)) {
printf("%s: failed to clear shared memory at %x - check configuration\n",
sc->sc_dev.dv_xname,
- kvtop(sc->mem_start + i));
+ (ia->ia_maddr + sc->mem_start + i));
/* Disable 16 bit access to shared memory. */
- outb(asicbase + ED_WD_MSR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
sc->wd_msr_proto);
if (isa16bit)
- outb(asicbase + ED_WD_LAAR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
sc->wd_laar_proto);
- (void) inb(0x84);
- (void) inb(0x84);
- return (0);
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
+ goto out;
}
/*
* and 2) so that other 8 bit devices with shared memory can be
* used in this 128k region, too.
*/
- outb(asicbase + ED_WD_MSR, sc->wd_msr_proto);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, sc->wd_msr_proto);
if (isa16bit)
- outb(asicbase + ED_WD_LAAR, sc->wd_laar_proto);
- (void) inb(0x84);
- (void) inb(0x84);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
+ sc->wd_laar_proto);
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
ia->ia_iosize = ED_WD_IO_PORTS;
- return (1);
+ rv = 1;
+
+ out:
+ /*
+ * XXX Sould always unmap, but we can't yet.
+ * XXX Need to squish "indirect" first.
+ */
+ if (rv == 0) {
+ bus_io_unmap(bc, ioh, ED_WD_IO_PORTS);
+ if (mapped_mem)
+ bus_mem_unmap(bc, memh, memsize);
+ } else {
+ /* XXX this is all "indirect" brokenness */
+ sc->sc_bc = bc;
+ sc->sc_ioh = ioh;
+ sc->sc_memh = memh;
+ }
+ return (rv);
}
int ed_3com_iobase[] = {0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300};
struct cfdata *cf;
struct isa_attach_args *ia;
{
- int i;
+ bus_chipset_tag_t bc;
+ bus_io_handle_t ioh;
+ bus_mem_handle_t memh;
+ int i, rv, mapped_mem = 0;
u_int memsize;
u_char isa16bit, sum, x;
int ptr, asicbase, nicbase;
- sc->asic_base = asicbase = ia->ia_iobase + ED_3COM_ASIC_OFFSET;
- sc->nic_base = nicbase = ia->ia_iobase + ED_3COM_NIC_OFFSET;
+ bc = ia->ia_bc;
+ rv = 0;
+
+ if (bus_io_map(bc, ia->ia_iobase, ED_WD_IO_PORTS, &ioh))
+ return (0);
+
+ sc->asic_base = asicbase = ED_3COM_ASIC_OFFSET;
+ sc->nic_base = nicbase = ED_3COM_NIC_OFFSET;
/*
* Verify that the kernel configured I/O address matches the board
* board is there; after all, we are already talking it at that
* address.
*/
- x = inb(asicbase + ED_3COM_BCFR);
+ x = bus_io_read_1(bc, ioh, asicbase + ED_3COM_BCFR);
if (x == 0 || (x & (x - 1)) != 0)
- return (0);
+ goto out;
ptr = ffs(x) - 1;
if (ia->ia_iobase != IOBASEUNK) {
if (ia->ia_iobase != ed_3com_iobase[ptr]) {
printf("%s: %s mismatch; kernel configured %x != board configured %x\n",
"iobase", sc->sc_dev.dv_xname, ia->ia_iobase,
ed_3com_iobase[ptr]);
- return (0);
+ goto out;
}
} else
- ia->ia_iobase = ed_3com_iobase[ptr];
+ ia->ia_iobase = ed_3com_iobase[ptr]; /* XXX --thorpej */
- x = inb(asicbase + ED_3COM_PCFR);
+ x = bus_io_read_1(bc, ioh, asicbase + ED_3COM_PCFR);
if (x == 0 || (x & (x - 1)) != 0)
- return (0);
+ goto out;
ptr = ffs(x) - 1;
if (ia->ia_maddr != MADDRUNK) {
if (ia->ia_maddr != ed_3com_maddr[ptr]) {
printf("%s: %s mismatch; kernel configured %x != board configured %x\n",
"maddr", sc->sc_dev.dv_xname, ia->ia_maddr,
ed_3com_maddr[ptr]);
- return (0);
+ goto out;
}
} else
ia->ia_maddr = ed_3com_maddr[ptr];
#if 0
- x = inb(asicbase + ED_3COM_IDCFR) & ED_3COM_IDCFR_IRQ;
+ x = bus_io_read_1(bc, ioh, asicbase + ED_3COM_IDCFR) &
+ ED_3COM_IDCFR_IRQ;
if (x == 0 || (x & (x - 1)) != 0)
- return (0);
+ goto out;
ptr = ffs(x) - 1;
if (ia->ia_irq != IRQUNK) {
if (ia->ia_irq != ed_3com_irq[ptr]) {
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
sc->sc_dev.dv_xname, ia->ia_irq,
ed_3com_irq[ptr]);
- return (0);
+ goto out;
}
} else
ia->ia_irq = ed_3com_irq[ptr];
* sequence because it'll lock up if the cable isn't connected if we
* don't.
*/
- outb(asicbase + ED_3COM_CR, ED_3COM_CR_RST | ED_3COM_CR_XSEL);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_CR,
+ ED_3COM_CR_RST | ED_3COM_CR_XSEL);
/* Wait for a while, then un-reset it. */
delay(50);
* reset - it's important to set it again after the following outb
* (this is done when we map the PROM below).
*/
- outb(asicbase + ED_3COM_CR, ED_3COM_CR_XSEL);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_CR, ED_3COM_CR_XSEL);
/* Wait a bit for the NIC to recover from the reset. */
delay(5000);
* First, map ethernet address PROM over the top of where the NIC
* registers normally appear.
*/
- outb(asicbase + ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_CR,
+ ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] = NIC_GET(nicbase, i);
+ sc->sc_arpcom.ac_enaddr[i] = NIC_GET(bc, ioh, nicbase, i);
/*
* Unmap PROM - select NIC registers. The proper setting of the
* tranceiver is set in edinit so that the attach code is given a
* chance to set the default based on a compile-time config option.
*/
- outb(asicbase + ED_3COM_CR, ED_3COM_CR_XSEL);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_CR, ED_3COM_CR_XSEL);
/* Determine if this is an 8bit or 16bit board. */
/* Select page 0 registers. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
/*
* Attempt to clear WTS bit. If it doesn't clear, then this is a
* 16-bit board.
*/
- NIC_PUT(nicbase, ED_P0_DCR, 0);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_DCR, 0);
/* Select page 2 registers. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase,
+ ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
/* The 3c503 forces the WTS bit to a one if this is a 16bit board. */
- if (NIC_GET(nicbase, ED_P2_DCR) & ED_DCR_WTS)
+ if (NIC_GET(bc, ioh, nicbase, ED_P2_DCR) & ED_DCR_WTS)
isa16bit = 1;
else
isa16bit = 0;
/* Select page 0 registers. */
- NIC_PUT(nicbase, ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P2_CR,
+ ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
- sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
+ if (bus_mem_map(bc, ia->ia_maddr, memsize, 0, &memh))
+ goto out;
+ mapped_mem = 1;
+ sc->mem_start = 0; /* offset */
sc->mem_size = memsize;
sc->mem_end = sc->mem_start + memsize;
* Initialize GA page start/stop registers. Probably only needed if
* doing DMA, but what the Hell.
*/
- outb(asicbase + ED_3COM_PSTR, sc->rec_page_start);
- outb(asicbase + ED_3COM_PSPR, sc->rec_page_stop);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_PSTR, sc->rec_page_start);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_PSPR, sc->rec_page_stop);
/* Set IRQ. 3c503 only allows a choice of irq 3-5 or 9. */
switch (ia->ia_irq) {
case 9:
- outb(asicbase + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_IDCFR,
+ ED_3COM_IDCFR_IRQ2);
break;
case 3:
- outb(asicbase + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_IDCFR,
+ ED_3COM_IDCFR_IRQ3);
break;
case 4:
- outb(asicbase + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_IDCFR,
+ ED_3COM_IDCFR_IRQ4);
break;
case 5:
- outb(asicbase + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_IDCFR,
+ ED_3COM_IDCFR_IRQ5);
break;
default:
printf("%s: invalid irq configuration (%d) must be 3-5 or 9 for 3c503\n",
sc->sc_dev.dv_xname, ia->ia_irq);
- return (0);
+ goto out;
}
/*
* Initialize GA configuration register. Set bank and enable shared
* mem.
*/
- outb(asicbase + ED_3COM_GACFR,
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_GACFR,
ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
/*
* shared memory is disabled. We set them to 0xffff0...allegedly the
* reset vector.
*/
- outb(asicbase + ED_3COM_VPTR2, 0xff);
- outb(asicbase + ED_3COM_VPTR1, 0xff);
- outb(asicbase + ED_3COM_VPTR0, 0x00);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR2, 0xff);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR1, 0xff);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR0, 0x00);
/* Zero memory and verify that it is clear. */
- bzero(sc->mem_start, memsize);
+ for (i = 0; i < memsize; ++i)
+ bus_mem_write_1(bc, memh, sc->mem_start + i, 0);
for (i = 0; i < memsize; ++i)
- if (sc->mem_start[i]) {
+ if (bus_mem_read_1(bc, memh, sc->mem_start + i)) {
printf("%s: failed to clear shared memory at %x - check configuration\n",
- sc->sc_dev.dv_xname, kvtop(sc->mem_start + i));
- return (0);
+ sc->sc_dev.dv_xname,
+ (ia->ia_maddr + sc->mem_start + i));
+ goto out;
}
ia->ia_msize = memsize;
ia->ia_iosize = ED_3COM_IO_PORTS;
- return (1);
+ rv = 1;
+
+ out:
+ /*
+ * XXX Sould always unmap, but we can't yet.
+ * XXX Need to squish "indirect" first.
+ */
+ if (rv == 0) {
+ bus_io_unmap(bc, ioh, ED_3COM_IO_PORTS);
+ if (mapped_mem)
+ bus_mem_unmap(bc, memh, memsize);
+ } else {
+ /* XXX this is all "indirect" brokenness */
+ sc->sc_bc = bc;
+ sc->sc_ioh = ioh;
+ sc->sc_memh = memh;
+ }
+ return (rv);
}
/*
struct cfdata *cf;
struct isa_attach_args *ia;
{
+ bus_chipset_tag_t bc;
+ bus_io_handle_t ioh;
+ bus_mem_handle_t memh;
u_int memsize, n;
u_char romdata[16], isa16bit = 0, tmp;
static u_char test_pattern[32] = "THIS is A memory TEST pattern";
u_char test_buffer[32];
- int asicbase, nicbase;
+ int rv, asicbase, nicbase;
- sc->asic_base = asicbase = ia->ia_iobase + ED_NOVELL_ASIC_OFFSET;
- sc->nic_base = nicbase = ia->ia_iobase + ED_NOVELL_NIC_OFFSET;
+ bc = ia->ia_bc;
+ rv = 0;
+
+ if (bus_io_map(bc, ia->ia_iobase, ED_NOVELL_IO_PORTS, &ioh))
+ return (0);
+
+ sc->asic_base = asicbase = ED_NOVELL_ASIC_OFFSET;
+ sc->nic_base = nicbase = ED_NOVELL_NIC_OFFSET;
/* XXX - do Novell-specific probe here */
/* Reset the board. */
#ifdef GWETHER
- outb(asicbase + ED_NOVELL_RESET, 0);
+ bus_io_write_1(bc, ioh, asicbase + ED_NOVELL_RESET, 0);
delay(200);
#endif /* GWETHER */
- tmp = inb(asicbase + ED_NOVELL_RESET);
+ tmp = bus_io_read_1(bc, ioh, asicbase + ED_NOVELL_RESET);
/*
* I don't know if this is necessary; probably cruft leftover from
* complete documentation on what the 'right' thing to do is...so we do
* the invasive thing for now. Yuck.]
*/
- outb(asicbase + ED_NOVELL_RESET, tmp);
+ bus_io_write_1(bc, ioh, asicbase + ED_NOVELL_RESET, tmp);
delay(5000);
/*
* XXX - this makes the probe invasive! ...Done against my better
* judgement. -DLG
*/
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
delay(5000);
/* Make sure that we really have an 8390 based board. */
- if (!ed_probe_generic8390(nicbase))
- return (0);
+ if (!ed_probe_generic8390(bc, ioh, nicbase))
+ goto out;
sc->vendor = ED_VENDOR_NOVELL;
sc->mem_shared = 0;
* This prevents packets from being stored in the NIC memory when the
* readmem routine turns on the start bit in the CR.
*/
- NIC_PUT(nicbase, ED_P0_RCR, ED_RCR_MON);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RCR, ED_RCR_MON);
/* Temporarily initialize DCR for byte operations. */
- NIC_PUT(nicbase, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
- NIC_PUT(nicbase, ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT);
- NIC_PUT(nicbase, ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT);
sc->isa16bit = 0;
+ /*
+ * XXX indirect brokenness, used by ed_pio{read,write}mem()
+ */
+ sc->sc_bc = bc;
+ sc->sc_ioh = ioh;
+
/*
* Write a test pattern in byte mode. If this fails, then there
* probably isn't any memory at 8k - which likely means that the board
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
/* not an NE1000 - try NE2000 */
- NIC_PUT(nicbase, ED_P0_DCR,
+ NIC_PUT(bc, ioh, nicbase, ED_P0_DCR,
ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
- NIC_PUT(nicbase, ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT);
- NIC_PUT(nicbase, ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT);
sc->isa16bit = 1;
ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)))
- return (0); /* not an NE2000 either */
+ goto out; /* not an NE2000 either */
sc->type = ED_TYPE_NE2000;
sc->type_str = "NE2000";
if (ia->ia_irq == IRQUNK) {
printf("%s: %s does not have soft configuration\n",
sc->sc_dev.dv_xname, sc->type_str);
- return (0);
+ goto out;
}
/* 8k of memory plus an additional 8k if 16-bit. */
/* NIC memory doesn't start at zero on an NE board. */
/* The start address is tied to the bus width. */
- sc->mem_start = (caddr_t)(8192 + sc->isa16bit * 8192);
+ sc->mem_start = (8192 + sc->isa16bit * 8192);
sc->tx_page_start = memsize >> ED_PAGE_SHIFT;
#ifdef GWETHER
if (mstart == 0) {
printf("%s: cannot find start of RAM\n",
sc->sc_dev.dv_xname);
- return (0);
+ goto out;
}
/* Search for the end of RAM. */
#endif /* GWETHER */
/* Clear any pending interrupts that might have occurred above. */
- NIC_PUT(nicbase, ED_P0_ISR, 0xff);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_ISR, 0xff);
ia->ia_iosize = ED_NOVELL_IO_PORTS;
- return (1);
+ rv = 1;
+
+ out:
+ /*
+ * XXX Sould always unmap, but we can't yet.
+ * XXX Need to squish "indirect" first.
+ */
+ if (rv == 0)
+ bus_io_unmap(bc, ioh, ED_NOVELL_IO_PORTS);
+ else {
+ /* XXX this is all "indirect" brokenness */
+ sc->sc_bc = bc;
+ sc->sc_ioh = ioh;
+ sc->sc_memh = memh;
+ }
+ return (rv);
}
/*
struct device *parent, *self;
void *aux;
{
+ bus_chipset_tag_t bc;
+ bus_io_handle_t ioh;
struct ed_softc *sc = (void *)self;
struct isa_attach_args *ia = aux;
struct cfdata *cf = sc->sc_dev.dv_cfdata;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
int asicbase;
+ /*
+ * XXX Should re-map io and mem, but can't
+ * XXX until we squish "indirect" brokenness.
+ */
+ bc = sc->sc_bc; /* XXX */
+ ioh = sc->sc_ioh; /* XXX */
asicbase = sc->asic_base;
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = edcd.cd_name;
+ ifp->if_name = ed_cd.cd_name;
ifp->if_start = edstart;
ifp->if_ioctl = edioctl;
ifp->if_watchdog = edwatchdog;
case ED_VENDOR_WD_SMC:
if ((sc->type & ED_WD_SOFTCONFIG) == 0)
break;
- if ((inb(asicbase + ED_WD_IRR) & ED_WD_IRR_OUT2) == 0)
+ if ((bus_io_read_1(bc, ioh, asicbase + ED_WD_IRR) &
+ ED_WD_IRR_OUT2) == 0)
ifp->if_flags |= IFF_LINK0;
break;
}
ether_ifattach(ifp);
/* Print additional info when attached. */
- printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
+ printf("\n%s: address %s, ", sc->sc_dev.dv_xname,
+ ether_sprintf(sc->sc_arpcom.ac_enaddr));
if (sc->type_str)
printf("type %s ", sc->type_str);
sizeof(struct ether_header));
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET, edintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_NET, edintr, sc, sc->sc_dev.dv_xname);
sc->sc_sh = shutdownhook_establish((void (*)(void *))edstop, sc);
}
edstop(sc)
struct ed_softc *sc;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
int nicbase = sc->nic_base;
int n = 5000;
/* Stop everything on the interface, and select page 0 registers. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
/*
* Wait for interface to enter stopped state, but limit # of checks to
* 'n' (about 5ms). It shouldn't even take 5us on modern DS8390's, but
* just in case it's an old one.
*/
- while (((NIC_GET(nicbase, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
+ while (((NIC_GET(bc, ioh, nicbase,
+ ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
}
/*
edwatchdog(unit)
int unit;
{
- struct ed_softc *sc = edcd.cd_devs[unit];
+ struct ed_softc *sc = ed_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
edinit(sc)
struct ed_softc *sc;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
int nicbase = sc->nic_base, asicbase = sc->asic_base;
int i;
sc->txb_next_tx = 0;
/* Set interface for page 0, remote DMA complete, stopped. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
if (sc->isa16bit) {
/*
* Set FIFO threshold to 8, No auto-init Remote DMA, byte
* order=80x86, word-wide DMA xfers,
*/
- NIC_PUT(nicbase, ED_P0_DCR,
+ NIC_PUT(bc, ioh, nicbase, ED_P0_DCR,
ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
} else {
/* Same as above, but byte-wide DMA xfers. */
- NIC_PUT(nicbase, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
}
/* Clear remote byte count registers. */
- NIC_PUT(nicbase, ED_P0_RBCR0, 0);
- NIC_PUT(nicbase, ED_P0_RBCR1, 0);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR0, 0);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR1, 0);
/* Tell RCR to do nothing for now. */
- NIC_PUT(nicbase, ED_P0_RCR, ED_RCR_MON);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RCR, ED_RCR_MON);
/* Place NIC in internal loopback mode. */
- NIC_PUT(nicbase, ED_P0_TCR, ED_TCR_LB0);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_TCR, ED_TCR_LB0);
/* Set lower bits of byte addressable framing to 0. */
if (sc->is790)
- NIC_PUT(nicbase, 0x09, 0);
+ NIC_PUT(bc, ioh, nicbase, 0x09, 0);
/* Initialize receive buffer ring. */
- NIC_PUT(nicbase, ED_P0_BNRY, sc->rec_page_start);
- NIC_PUT(nicbase, ED_P0_PSTART, sc->rec_page_start);
- NIC_PUT(nicbase, ED_P0_PSTOP, sc->rec_page_stop);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_BNRY, sc->rec_page_start);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_PSTART, sc->rec_page_start);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_PSTOP, sc->rec_page_stop);
/*
* Clear all interrupts. A '1' in each bit position clears the
* corresponding flag.
*/
- NIC_PUT(nicbase, ED_P0_ISR, 0xff);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_ISR, 0xff);
/*
* Enable the following interrupts: receive/transmit complete,
*
* Counter overflow and Remote DMA complete are *not* enabled.
*/
- NIC_PUT(nicbase, ED_P0_IMR,
+ NIC_PUT(bc, ioh, nicbase, ED_P0_IMR,
ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE |
ED_IMR_OVWE);
/* Program command register for page 1. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
/* Copy out our station address. */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- NIC_PUT(nicbase, ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
+ NIC_PUT(bc, ioh, nicbase, ED_P1_PAR0 + i,
+ sc->sc_arpcom.ac_enaddr[i]);
/* Set multicast filter on chip. */
ed_getmcaf(&sc->sc_arpcom, mcaf);
for (i = 0; i < 8; i++)
- NIC_PUT(nicbase, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
+ NIC_PUT(bc, ioh, nicbase, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
/*
* Set current page pointer to one page after the boundary pointer, as
* recommended in the National manual.
*/
sc->next_packet = sc->rec_page_start + 1;
- NIC_PUT(nicbase, ED_P1_CURR, sc->next_packet);
+ NIC_PUT(bc, ioh, nicbase, ED_P1_CURR, sc->next_packet);
/* Program command register for page 0. */
- NIC_PUT(nicbase, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(bc, ioh, nicbase, ED_P1_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
i = ED_RCR_AB | ED_RCR_AM;
if (ifp->if_flags & IFF_PROMISC) {
*/
i |= ED_RCR_PRO | ED_RCR_AR | ED_RCR_SEP;
}
- NIC_PUT(nicbase, ED_P0_RCR, i);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RCR, i);
/* Take interface out of loopback. */
- NIC_PUT(nicbase, ED_P0_TCR, 0);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_TCR, 0);
/*
* If this is a 3Com board, the tranceiver must be software enabled
u_char x;
case ED_VENDOR_3COM:
if (ifp->if_flags & IFF_LINK0)
- outb(asicbase + ED_3COM_CR, 0);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_CR, 0);
else
- outb(asicbase + ED_3COM_CR, ED_3COM_CR_XSEL);
+ bus_io_write_1(bc, ioh, asicbase + ED_3COM_CR,
+ ED_3COM_CR_XSEL);
break;
case ED_VENDOR_WD_SMC:
if ((sc->type & ED_WD_SOFTCONFIG) == 0)
break;
- x = inb(asicbase + ED_WD_IRR);
+ x = bus_io_read_1(bc, ioh, asicbase + ED_WD_IRR);
if (ifp->if_flags & IFF_LINK0)
x &= ~ED_WD_IRR_OUT2;
else
x |= ED_WD_IRR_OUT2;
- outb(asicbase + ED_WD_IRR, x);
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_IRR, x);
break;
}
/* Fire up the interface. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
/* Set 'running' flag, and clear output active flag. */
ifp->if_flags |= IFF_RUNNING;
ed_xmit(sc)
struct ed_softc *sc;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
int nicbase = sc->nic_base;
u_short len;
len = sc->txb_len[sc->txb_next_tx];
/* Set NIC for page 0 register access. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
/* Set TX buffer start page. */
- NIC_PUT(nicbase, ED_P0_TPSR, sc->tx_page_start +
+ NIC_PUT(bc, ioh, nicbase, ED_P0_TPSR, sc->tx_page_start +
sc->txb_next_tx * ED_TXBUF_SIZE);
/* Set TX length. */
- NIC_PUT(nicbase, ED_P0_TBCR0, len);
- NIC_PUT(nicbase, ED_P0_TBCR1, len >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_TBCR0, len);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_TBCR1, len >> 8);
/* Set page 0, remote DMA complete, transmit packet, and *start*. */
- NIC_PUT(nicbase, ED_P0_CR,
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA);
/* Point to next transmit buffer slot and wrap if necessary. */
edstart(ifp)
struct ifnet *ifp;
{
- struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
+ struct ed_softc *sc = ed_cd.cd_devs[ifp->if_unit];
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
struct mbuf *m0, *m;
- caddr_t buffer;
+ int buffer;
int asicbase = sc->asic_base;
- int len;
+ int len, i;
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
return;
#endif
/* txb_new points to next open buffer slot. */
- buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
+ buffer = sc->mem_start +
+ ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
if (sc->mem_shared) {
/* Special case setup for 16 bit boards... */
*/
case ED_VENDOR_3COM:
if (sc->isa16bit)
- outb(asicbase + ED_3COM_GACFR,
+ bus_io_write_1(bc, ioh,
+ asicbase + ED_3COM_GACFR,
ED_3COM_GACFR_RSEL);
break;
/*
*/
case ED_VENDOR_WD_SMC:
if (sc->isa16bit)
- outb(asicbase + ED_WD_LAAR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
- outb(asicbase + ED_WD_MSR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
sc->wd_msr_proto | ED_WD_MSR_MENB);
- (void) inb(0x84);
- (void) inb(0x84);
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
break;
}
for (m = m0; m != 0; m = m->m_next) {
- bcopy(mtod(m, caddr_t), buffer, m->m_len);
+ ed_shared_writemem(sc, mtod(m, caddr_t), buffer,
+ m->m_len);
buffer += m->m_len;
}
len = m0->m_pkthdr.len;
switch (sc->vendor) {
case ED_VENDOR_3COM:
if (sc->isa16bit)
- outb(asicbase + ED_3COM_GACFR,
+ bus_io_write_1(bc, ioh,
+ asicbase + ED_3COM_GACFR,
ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
break;
case ED_VENDOR_WD_SMC:
- outb(asicbase + ED_WD_MSR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR,
sc->wd_msr_proto);
if (sc->isa16bit)
- outb(asicbase + ED_WD_LAAR,
+ bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR,
sc->wd_laar_proto);
- (void) inb(0x84);
- (void) inb(0x84);
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */
break;
}
} else
ed_rint(sc)
struct ed_softc *sc;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
int nicbase = sc->nic_base;
u_char boundary, current;
u_short len;
u_char nlen;
struct ed_ring packet_hdr;
- caddr_t packet_ptr;
+ int packet_ptr;
loop:
/* Set NIC to page 1 registers to get 'current' pointer. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
/*
* 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
* until the logical beginning equals the logical end (or in other
* words, until the ring-buffer is empty).
*/
- current = NIC_GET(nicbase, ED_P1_CURR);
+ current = NIC_GET(bc, ioh, nicbase, ED_P1_CURR);
if (sc->next_packet == current)
return;
/* Set NIC to page 0 registers to update boundary register. */
- NIC_PUT(nicbase, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P1_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
do {
/* Get pointer to this buffer's header structure. */
* the NIC.
*/
if (sc->mem_shared)
- packet_hdr = *(struct ed_ring *)packet_ptr;
+ ed_shared_readmem(sc, packet_ptr, (caddr_t)&packet_hdr,
+ sizeof(packet_hdr));
else
ed_pio_readmem(sc, (long)packet_ptr,
(caddr_t) &packet_hdr, sizeof(packet_hdr));
boundary = sc->next_packet - 1;
if (boundary < sc->rec_page_start)
boundary = sc->rec_page_stop - 1;
- NIC_PUT(nicbase, ED_P0_BNRY, boundary);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_BNRY, boundary);
} while (sc->next_packet != current);
goto loop;
void *arg;
{
struct ed_softc *sc = arg;
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
int nicbase = sc->nic_base, asicbase = sc->asic_base;
u_char isr;
/* Set NIC to page 0 registers. */
- NIC_PUT(nicbase, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
- isr = NIC_GET(nicbase, ED_P0_ISR);
+ isr = NIC_GET(bc, ioh, nicbase, ED_P0_ISR);
if (!isr)
return (0);
* '1' to each bit position that was set.
* (Writing a '1' *clears* the bit.)
*/
- NIC_PUT(nicbase, ED_P0_ISR, isr);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_ISR, isr);
/*
* Handle transmitter interrupts. Handle these first because
* the receiver will reset the board under some conditions.
*/
if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
- u_char collisions = NIC_GET(nicbase, ED_P0_NCR) & 0x0f;
+ u_char collisions = NIC_GET(bc, ioh, nicbase,
+ ED_P0_NCR) & 0x0f;
/*
* Check for transmit error. If a TX completed with an
* course, with UDP we're screwed, but this is expected
* when a network is heavily loaded.
*/
- (void) NIC_GET(nicbase, ED_P0_TSR);
+ (void) NIC_GET(bc, ioh, nicbase, ED_P0_TSR);
if (isr & ED_ISR_TXE) {
/*
* Excessive collisions (16).
*/
- if ((NIC_GET(nicbase, ED_P0_TSR) & ED_TSR_ABT)
- && (collisions == 0)) {
+ if ((NIC_GET(bc, ioh, nicbase, ED_P0_TSR) &
+ ED_TSR_ABT) && (collisions == 0)) {
/*
* When collisions total 16, the P0_NCR
* will indicate 0, and the TSR_ABT is
*/
if (sc->vendor == ED_VENDOR_WD_SMC) {
if (sc->isa16bit)
- outb(asicbase + ED_WD_LAAR,
- sc->wd_laar_proto | ED_WD_LAAR_M16EN);
- outb(asicbase + ED_WD_MSR,
+ bus_io_write_1(bc, ioh,
+ asicbase + ED_WD_LAAR,
+ sc->wd_laar_proto |
+ ED_WD_LAAR_M16EN);
+ bus_io_write_1(bc, ioh,
+ asicbase + ED_WD_MSR,
sc->wd_msr_proto | ED_WD_MSR_MENB);
- (void) inb(0x84);
- (void) inb(0x84);
+ /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84);
+ (void) bus_io_read_1(bc, ioh, 0x84);
}
ed_rint(sc);
/* Disable 16-bit access. */
if (sc->vendor == ED_VENDOR_WD_SMC) {
- outb(asicbase + ED_WD_MSR,
+ bus_io_write_1(bc, ioh,
+ asicbase + ED_WD_MSR,
sc->wd_msr_proto);
if (sc->isa16bit)
- outb(asicbase + ED_WD_LAAR,
+ bus_io_write_1(bc, ioh,
+ asicbase + ED_WD_LAAR,
sc->wd_laar_proto);
- (void) inb(0x84);
- (void) inb(0x84);
+ /* XXX */
+ (void) bus_io_read_1(bc, ioh, 0x84);
+ (void) bus_io_read_1(bc, ioh, 0x84);
}
}
}
* set in the transmit routine, is *okay* - it is 'edge'
* triggered from low to high).
*/
- NIC_PUT(nicbase, ED_P0_CR,
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
/*
* otherwise - resulting in an infinite loop.
*/
if (isr & ED_ISR_CNT) {
- (void) NIC_GET(nicbase, ED_P0_CNTR0);
- (void) NIC_GET(nicbase, ED_P0_CNTR1);
- (void) NIC_GET(nicbase, ED_P0_CNTR2);
+ (void) NIC_GET(bc, ioh, nicbase, ED_P0_CNTR0);
+ (void) NIC_GET(bc, ioh, nicbase, ED_P0_CNTR1);
+ (void) NIC_GET(bc, ioh, nicbase, ED_P0_CNTR2);
}
- isr = NIC_GET(nicbase, ED_P0_ISR);
+ isr = NIC_GET(bc, ioh, nicbase, ED_P0_ISR);
if (!isr)
return (1);
}
u_long cmd;
caddr_t data;
{
- struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
+ struct ed_softc *sc = ed_cd.cd_devs[ifp->if_unit];
register struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
void
edread(sc, buf, len)
struct ed_softc *sc;
- caddr_t buf;
- int len;
+ int buf, len;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *m;
caddr_t dst;
u_short amount;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
int nicbase = sc->nic_base;
/* Select page 0 registers. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
/* Round up to a word. */
if (amount & 1)
++amount;
/* Set up DMA byte count. */
- NIC_PUT(nicbase, ED_P0_RBCR0, amount);
- NIC_PUT(nicbase, ED_P0_RBCR1, amount >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR0, amount);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR1, amount >> 8);
/* Set up source address in NIC mem. */
- NIC_PUT(nicbase, ED_P0_RSAR0, src);
- NIC_PUT(nicbase, ED_P0_RSAR1, src >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RSAR0, src);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RSAR1, src >> 8);
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA);
if (sc->isa16bit)
- insw(sc->asic_base + ED_NOVELL_DATA, dst, amount / 2);
+ bus_io_read_multi_2(bc, ioh, sc->asic_base + ED_NOVELL_DATA,
+ dst, amount / 2);
else
- insb(sc->asic_base + ED_NOVELL_DATA, dst, amount);
+ bus_io_read_multi_1(bc, ioh, sc->asic_base + ED_NOVELL_DATA,
+ dst, amount);
}
/*
u_short dst;
u_short len;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
int nicbase = sc->nic_base;
int maxwait = 100; /* about 120us */
/* Select page 0 registers. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
/* Reset remote DMA complete flag. */
- NIC_PUT(nicbase, ED_P0_ISR, ED_ISR_RDC);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_ISR, ED_ISR_RDC);
/* Set up DMA byte count. */
- NIC_PUT(nicbase, ED_P0_RBCR0, len);
- NIC_PUT(nicbase, ED_P0_RBCR1, len >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR0, len);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR1, len >> 8);
/* Set up destination address in NIC mem. */
- NIC_PUT(nicbase, ED_P0_RSAR0, dst);
- NIC_PUT(nicbase, ED_P0_RSAR1, dst >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RSAR0, dst);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RSAR1, dst >> 8);
/* Set remote DMA write. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
if (sc->isa16bit)
- outsw(sc->asic_base + ED_NOVELL_DATA, src, len / 2);
+ bus_io_write_multi_2(bc, ioh, sc->asic_base + ED_NOVELL_DATA,
+ src, len / 2);
else
- outsb(sc->asic_base + ED_NOVELL_DATA, src, len);
+ bus_io_write_multi_1(bc, ioh, sc->asic_base + ED_NOVELL_DATA,
+ src, len);
/*
* Wait for remote DMA complete. This is necessary because on the
* waiting causes really bad things to happen - like the NIC
* irrecoverably jamming the ISA bus.
*/
- while (((NIC_GET(nicbase, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) &&
- --maxwait);
+ while (((NIC_GET(bc, ioh, nicbase, ED_P0_ISR) & ED_ISR_RDC) !=
+ ED_ISR_RDC) && --maxwait);
}
/*
struct mbuf *m;
u_short dst;
{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_io_handle_t ioh = sc->sc_ioh;
int nicbase = sc->nic_base, asicbase = sc->asic_base;
u_short len;
struct mbuf *mp;
len = m->m_pkthdr.len;
/* Select page 0 registers. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
/* Reset remote DMA complete flag. */
- NIC_PUT(nicbase, ED_P0_ISR, ED_ISR_RDC);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_ISR, ED_ISR_RDC);
/* Set up DMA byte count. */
- NIC_PUT(nicbase, ED_P0_RBCR0, len);
- NIC_PUT(nicbase, ED_P0_RBCR1, len >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR0, len);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RBCR1, len >> 8);
/* Set up destination address in NIC mem. */
- NIC_PUT(nicbase, ED_P0_RSAR0, dst);
- NIC_PUT(nicbase, ED_P0_RSAR1, dst >> 8);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RSAR0, dst);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_RSAR1, dst >> 8);
/* Set remote DMA write. */
- NIC_PUT(nicbase, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(bc, ioh, nicbase, ED_P0_CR,
+ ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
/*
* Transfer the mbuf chain to the NIC memory.
/* NE1000s are easy. */
for (; m != 0; m = m->m_next) {
if (m->m_len) {
- outsb(asicbase + ED_NOVELL_DATA,
+ bus_io_write_multi_1(bc, ioh,
+ asicbase + ED_NOVELL_DATA,
mtod(m, u_char *), m->m_len);
}
}
} else {
/* NE2000s are a bit trickier. */
- u_char *data, savebyte[2];
+ u_int8_t *data, savebyte[2];
int len, wantbyte;
wantbyte = 0;
len = m->m_len;
if (len == 0)
continue;
- data = mtod(m, u_char *);
+ data = mtod(m, u_int8_t *);
/* Finish the last word. */
if (wantbyte) {
savebyte[1] = *data;
- outw(asicbase + ED_NOVELL_DATA,
- *(u_short *)savebyte);
+ bus_io_write_2(bc, ioh,
+ asicbase + ED_NOVELL_DATA,
+ *(u_int16_t *)savebyte);
data++;
len--;
wantbyte = 0;
}
/* Output contiguous words. */
- if (len > 1)
- outsw(asicbase + ED_NOVELL_DATA,
+ if (len > 1) {
+ bus_io_write_multi_2(bc, ioh,
+ asicbase + ED_NOVELL_DATA,
data, len >> 1);
+ }
/* Save last byte, if necessary. */
if (len & 1) {
data += len & ~1;
if (wantbyte) {
savebyte[1] = 0;
- outw(asicbase + ED_NOVELL_DATA, *(u_short *)savebyte);
+ bus_io_write_2(bc, ioh, asicbase + ED_NOVELL_DATA,
+ *(u_int16_t *)savebyte);
}
}
* waiting causes really bad things to happen - like the NIC
* irrecoverably jamming the ISA bus.
*/
- while (((NIC_GET(nicbase, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) &&
- --maxwait);
+ while (((NIC_GET(bc, ioh, nicbase, ED_P0_ISR) & ED_ISR_RDC) !=
+ ED_ISR_RDC) && --maxwait);
if (!maxwait) {
log(LOG_WARNING,
* Given a source and destination address, copy 'amount' of a packet from the
* ring buffer into a linear destination buffer. Takes into account ring-wrap.
*/
-static inline caddr_t
+static inline int
ed_ring_copy(sc, src, dst, amount)
struct ed_softc *sc;
- caddr_t src, dst;
+ int src;
+ caddr_t dst;
u_short amount;
{
u_short tmp_amount;
/* Copy amount up to end of NIC memory. */
if (sc->mem_shared)
- bcopy(src, dst, tmp_amount);
+ ed_shared_readmem(sc, src, dst, tmp_amount);
else
ed_pio_readmem(sc, (long)src, dst, tmp_amount);
}
if (sc->mem_shared)
- bcopy(src, dst, amount);
+ ed_shared_readmem(sc, src, dst, amount);
else
ed_pio_readmem(sc, (long)src, dst, amount);
struct mbuf *
edget(sc, src, total_len)
struct ed_softc *sc;
- caddr_t src;
+ int src;
u_short total_len;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
}
ifp->if_flags &= ~IFF_ALLMULTI;
}
+
+void
+ed_shared_writemem(sc, buf, card, len)
+ struct ed_softc *sc;
+ caddr_t buf;
+ int card, len;
+{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_mem_handle_t memh = sc->sc_memh;
+ u_int8_t *ptr = (u_int8_t *)buf;
+ int i;
+
+ /* XXX should have bus_mem_copyout_{1,2,4,8}() */
+
+ for (i = 0; i < len; ++i)
+ bus_mem_write_1(bc, memh, card + i, ptr[i]);
+}
+
+void
+ed_shared_readmem(sc, card, buf, len)
+ struct ed_softc *sc;
+ caddr_t buf;
+ int card, len;
+{
+ bus_chipset_tag_t bc = sc->sc_bc;
+ bus_mem_handle_t memh = sc->sc_memh;
+ u_int8_t *ptr = (u_int8_t *)buf;
+ int i;
+
+ /* XXX should have bus_mem_copyin_{1,2,4,8}() */
+
+ for (i = 0; i < len; ++i)
+ ptr[i] = bus_mem_read_1(bc, memh, card + i);
+}
-/* $NetBSD: if_eg.c,v 1.22 1996/01/10 18:21:52 hpeyerl Exp $ */
+/* $NetBSD: if_eg.c,v 1.24 1996/04/11 22:29:03 cgd Exp $ */
/*
* Copyright (c) 1993 Dean Huxley <dean@fsa.ca>
int egprobe __P((struct device *, void *, void *));
void egattach __P((struct device *, struct device *, void *));
-struct cfdriver egcd = {
- NULL, "eg", egprobe, egattach, DV_IFNET, sizeof(struct eg_softc)
+struct cfattach eg_ca = {
+ sizeof(struct eg_softc), egprobe, egattach
+};
+
+struct cfdriver eg_cd = {
+ NULL, "eg", DV_IFNET
};
int egintr __P((void *));
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = egcd.cd_name;
+ ifp->if_name = eg_cd.cd_name;
ifp->if_start = egstart;
ifp->if_ioctl = egioctl;
ifp->if_watchdog = egwatchdog;
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET, egintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_NET, egintr, sc, sc->sc_dev.dv_xname);
}
void
egstart(ifp)
struct ifnet *ifp;
{
- register struct eg_softc *sc = egcd.cd_devs[ifp->if_unit];
+ register struct eg_softc *sc = eg_cd.cd_devs[ifp->if_unit];
struct mbuf *m0, *m;
caddr_t buffer;
int len;
u_long cmd;
caddr_t data;
{
- struct eg_softc *sc = egcd.cd_devs[ifp->if_unit];
+ struct eg_softc *sc = eg_cd.cd_devs[ifp->if_unit];
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
egwatchdog(unit)
int unit;
{
- struct eg_softc *sc = egcd.cd_devs[unit];
+ struct eg_softc *sc = eg_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
sc->sc_arpcom.ac_if.if_oerrors++;
-/* $OpenBSD: if_el.c,v 1.6 1996/03/20 01:00:48 mickey Exp $ */
-/* $NetBSD: if_el.c,v 1.34 1995/12/24 02:31:25 mycroft Exp $ */
+/* $OpenBSD: if_el.c,v 1.7 1996/04/21 22:23:48 deraadt Exp $ */
+/* $NetBSD: if_el.c,v 1.36 1996/04/11 22:29:07 cgd Exp $ */
/*
* Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted
int elprobe __P((struct device *, void *, void *));
void elattach __P((struct device *, struct device *, void *));
-/* isa_driver structure for autoconf */
-struct cfdriver elcd = {
- NULL, "el", elprobe, elattach, DV_IFNET, sizeof(struct el_softc)
+struct cfattach el_ca = {
+ sizeof(struct el_softc), elprobe, elattach
+};
+
+struct cfdriver el_cd = {
+ NULL, "el", DV_IFNET
};
/*
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = elcd.cd_name;
+ ifp->if_name = el_cd.cd_name;
ifp->if_start = elstart;
ifp->if_ioctl = elioctl;
ifp->if_watchdog = elwatchdog;
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET, elintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_NET, elintr, sc, sc->sc_dev.dv_xname);
dprintf(("elattach() finished.\n"));
}
elstart(ifp)
struct ifnet *ifp;
{
- struct el_softc *sc = elcd.cd_devs[ifp->if_unit];
+ struct el_softc *sc = el_cd.cd_devs[ifp->if_unit];
int iobase = sc->sc_iobase;
struct mbuf *m, *m0;
int s, i, off, retries;
u_long cmd;
caddr_t data;
{
- struct el_softc *sc = elcd.cd_devs[ifp->if_unit];
+ struct el_softc *sc = el_cd.cd_devs[ifp->if_unit];
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
elwatchdog(unit)
int unit;
{
- struct el_softc *sc = elcd.cd_devs[unit];
+ struct el_softc *sc = el_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
sc->sc_arpcom.ac_if.if_oerrors++;
-/* $OpenBSD: if_ep.c,v 1.10 1996/04/18 23:47:40 niklas Exp $ */
-/* $NetBSD: if_ep.c,v 1.87 1996/02/19 20:18:40 christos Exp $ */
+/* $OpenBSD: if_ep.c,v 1.11 1996/04/21 22:23:52 deraadt Exp $ */
+/* $NetBSD: if_ep.c,v 1.90 1996/04/11 22:29:15 cgd Exp $ */
/*
* Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "pcmciabus.h"
+/*#include "pcmciabus.h"*/
#include "bpfilter.h"
#include <sys/param.h>
static int epprobe __P((struct device *, void *, void *));
static void epattach __P((struct device *, struct device *, void *));
-struct cfdriver epcd = {
- NULL, "ep", epprobe, epattach, DV_IFNET, sizeof(struct ep_softc)
+/* XXX the following two structs should be different. */
+struct cfattach ep_isa_ca = {
+ sizeof(struct ep_softc), epprobe, epattach
+};
+
+struct cfattach ep_pci_ca = {
+ sizeof(struct ep_softc), epprobe, epattach
+};
+
+struct cfdriver ep_cd = {
+ NULL, "ep", DV_IFNET
};
int epintr __P((void *));
int k, k2;
#if NPCI > 0
- extern struct cfdriver pcicd;
+ extern struct cfdriver pci_cd;
- if (parent->dv_cfdata->cf_driver == &pcicd) {
+ if (parent->dv_cfdata->cf_driver == &pci_cd) {
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
if (PCI_VENDORID(pa->pa_id) != PCI_VENDOR_3COM)
printf(" address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = epcd.cd_name;
+ ifp->if_name = ep_cd.cd_name;
ifp->if_start = epstart;
ifp->if_ioctl = epioctl;
ifp->if_watchdog = epwatchdog;
struct ep_softc *sc = (void *)self;
u_short conn = 0;
#if NPCI > 0
- extern struct cfdriver pcicd;
+ extern struct cfdriver pci_cd;
- if (parent->dv_cfdata->cf_driver == &pcicd) {
+ if (parent->dv_cfdata->cf_driver == &pci_cd) {
struct pci_attach_args *pa = aux;
int iobase;
u_short i;
}
sc->bustype = EP_BUS_PCI;
sc->ep_iobase = iobase; /* & 0xfffffff0 */
- i = pci_conf_read(pa->pa_tag, PCI_CONN);
+ i = pci_conf_read(pa->pa_bc, pa->pa_tag, PCI_CONN);
/*
* Bits 13,12,9 of the isa adapter are the same as bits
#if NPCI > 0
- if (parent->dv_cfdata->cf_driver == &pcicd) {
+ if (parent->dv_cfdata->cf_driver == &pci_cd) {
struct pci_attach_args *pa = aux;
- pci_conf_write(pa->pa_tag, PCI_COMMAND_STATUS_REG,
- pci_conf_read(pa->pa_tag,
+ pci_conf_write(pa->pa_bc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+ pci_conf_read(pa->pa_bc, pa->pa_tag,
PCI_COMMAND_STATUS_REG) |
PCI_COMMAND_MASTER_ENABLE);
- sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, epintr, sc,
- sc->sc_dev.dv_xname);
+ sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, epintr, sc);
if (sc->sc_ih == NULL) {
printf("%s: couldn't map interrupt\n",
sc->sc_dev.dv_xname);
#endif
{
struct isa_attach_args *ia = aux;
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET,
- epintr, sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
+ IST_EDGE, IPL_NET, epintr, sc, sc->sc_dev.dv_xname);
}
}
epstart(ifp)
struct ifnet *ifp;
{
- register struct ep_softc *sc = epcd.cd_devs[ifp->if_unit];
+ register struct ep_softc *sc = ep_cd.cd_devs[ifp->if_unit];
struct mbuf *m, *m0;
int sh, len, pad;
u_long cmd;
caddr_t data;
{
- struct ep_softc *sc = epcd.cd_devs[ifp->if_unit];
+ struct ep_softc *sc = ep_cd.cd_devs[ifp->if_unit];
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
epwatchdog(unit)
int unit;
{
- struct ep_softc *sc = epcd.cd_devs[unit];
+ struct ep_softc *sc = ep_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
void fe_dump __P((int, struct fe_softc *));
#endif
-struct cfdriver fecd = {
- NULL, "fe", feprobe, feattach, DV_IFNET, sizeof(struct fe_softc)
+struct cfattach fe_ca = {
+ sizeof(struct fe_softc), feprobe, feattach
+};
+
+struct cfdriver fe_cd = {
+ NULL, "fe", DV_IFNET
};
/* Ethernet constants. To be defined in if_ehter.h? FIXME. */
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = fecd.cd_name;
+ ifp->if_name = fe_cd.cd_name;
ifp->if_start = fe_start;
ifp->if_ioctl = fe_ioctl;
ifp->if_watchdog = fe_watchdog;
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET, feintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_NET, feintr, sc, sc->sc_dev.dv_xname);
}
/*
fe_watchdog(unit)
int unit;
{
- struct fe_softc *sc = fecd.cd_devs[unit];
+ struct fe_softc *sc = fe_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
#if FE_DEBUG >= 3
fe_start(ifp)
struct ifnet *ifp;
{
- struct fe_softc *sc = fecd.cd_devs[ifp->if_unit];
+ struct fe_softc *sc = fe_cd.cd_devs[ifp->if_unit];
struct mbuf *m;
#if FE_DEBUG >= 1
*/
ifp->if_opackets += sc->txb_sched;
sc->txb_sched = 0;
+ }
+ if (sc->txb_sched == 0) {
/*
* The transmitter is no more active.
* Reset output active flag and watchdog timer.
u_long command;
caddr_t data;
{
- struct fe_softc *sc = fecd.cd_devs[ifp->if_unit];
+ struct fe_softc *sc = fe_cd.cd_devs[ifp->if_unit];
register struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
-/* $OpenBSD: if_ie.c,v 1.6 1996/03/20 01:00:52 mickey Exp $ */
-/* $NetBSD: if_ie.c,v 1.45 1995/12/24 02:31:33 mycroft Exp $ */
+/* $OpenBSD: if_ie.c,v 1.7 1996/04/21 22:24:03 deraadt Exp $ */
+/* $NetBSD: if_ie.c,v 1.47 1996/04/11 22:29:27 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
int ieprobe __P((struct device *, void *, void *));
void ieattach __P((struct device *, struct device *, void *));
-struct cfdriver iecd = {
- NULL, "ie", ieprobe, ieattach, DV_IFNET, sizeof(struct ie_softc)
+struct cfattach ie_ca = {
+ sizeof(struct ie_softc), ieprobe, ieattach
+};
+
+struct cfdriver ie_cd = {
+ NULL, "ie", DV_IFNET
};
#define MK_24(base, ptr) ((caddr_t)((u_long)ptr - (u_long)base))
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
ifp->if_unit = sc->sc_dev.dv_unit;
- ifp->if_name = iecd.cd_name;
+ ifp->if_name = ie_cd.cd_name;
ifp->if_start = iestart;
ifp->if_ioctl = ieioctl;
ifp->if_watchdog = iewatchdog;
sizeof(struct ether_header));
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET, ieintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_NET, ieintr, sc, sc->sc_dev.dv_xname);
}
/*
iewatchdog(unit)
int unit;
{
- struct ie_softc *sc = iecd.cd_devs[unit];
+ struct ie_softc *sc = ie_cd.cd_devs[unit];
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
iestart(ifp)
struct ifnet *ifp;
{
- struct ie_softc *sc = iecd.cd_devs[ifp->if_unit];
+ struct ie_softc *sc = ie_cd.cd_devs[ifp->if_unit];
struct mbuf *m0, *m;
u_char *buffer;
u_short len;
u_long cmd;
caddr_t data;
{
- struct ie_softc *sc = iecd.cd_devs[ifp->if_unit];
+ struct ie_softc *sc = ie_cd.cd_devs[ifp->if_unit];
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
-/* $OpenBSD: if_le.c,v 1.7 1996/03/20 01:00:54 mickey Exp $ */
-/* $NetBSD: if_le.c,v 1.38 1995/12/24 02:31:35 mycroft Exp $ */
+/* $OpenBSD: if_le.c,v 1.8 1996/04/21 22:24:09 deraadt Exp $ */
+/* $NetBSD: if_le.c,v 1.41 1996/04/11 22:29:34 cgd Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
char *card_type[] = {"unknown", "BICC Isolan", "NE2100", "DEPCA", "PCnet-ISA", "PCnet-PCI"};
-#define LE_SOFTC(unit) lecd.cd_devs[unit]
+#define LE_SOFTC(unit) le_cd.cd_devs[unit]
#define LE_DELAY(x) delay(x)
int leprobe __P((struct device *, void *, void *));
int leintredge __P((void *));
void leshutdown __P((void *));
-struct cfdriver lecd = {
- NULL, "le", leprobe, leattach, DV_IFNET, sizeof(struct le_softc)
+/* XXX the following two structs should be different. */
+struct cfattach le_isa_ca = {
+ sizeof(struct le_softc), leprobe, leattach
+};
+
+struct cfattach le_pci_ca = {
+ sizeof(struct le_softc), leprobe, leattach
+};
+
+struct cfdriver le_cd = {
+ NULL, "le", DV_IFNET
};
integrate void
void *match, *aux;
{
struct le_softc *sc = match;
- extern struct cfdriver isacd, pcicd;
+ extern struct cfdriver isa_cd, pci_cd;
#if NISA > 0
- if (parent->dv_cfdata->cf_driver == &isacd) {
+ if (parent->dv_cfdata->cf_driver == &isa_cd) {
struct isa_attach_args *ia = aux;
if (bicc_probe(sc, ia))
#endif
#if NPCI > 0
- if (parent->dv_cfdata->cf_driver == &pcicd) {
+ if (parent->dv_cfdata->cf_driver == &pci_cd) {
struct pci_attach_args *pa = aux;
if (pa->pa_id == 0x20001022)
void *aux;
{
struct le_softc *sc = (void *)self;
- extern struct cfdriver isacd, pcicd;
+ extern struct cfdriver isa_cd, pci_cd;
#if NPCI > 0
- if (parent->dv_cfdata->cf_driver == &pcicd) {
+ if (parent->dv_cfdata->cf_driver == &pci_cd) {
struct pci_attach_args *pa = aux;
int iobase;
sc->sc_copyfrombuf = copyfrombuf_contig;
sc->sc_zerobuf = zerobuf_contig;
- sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
+ sc->sc_arpcom.ac_if.if_name = le_cd.cd_name;
leconfig(sc);
printf("%s: type %s\n", sc->sc_dev.dv_xname, card_type[sc->sc_card]);
#if NISA > 0
- if (parent->dv_cfdata->cf_driver == &isacd) {
+ if (parent->dv_cfdata->cf_driver == &isa_cd) {
struct isa_attach_args *ia = aux;
if (ia->ia_drq != DRQUNK)
isa_dmacascade(ia->ia_drq);
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NET,
- leintredge, sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_NET, leintredge, sc, sc->sc_dev.dv_xname);
}
#endif
#if NPCI > 0
- if (parent->dv_cfdata->cf_driver == &pcicd) {
+ if (parent->dv_cfdata->cf_driver == &pci_cd) {
struct pci_attach_args *pa = aux;
+ pcireg_t csr;
- pci_conf_write(pa->pa_tag, PCI_COMMAND_STATUS_REG,
- pci_conf_read(pa->pa_tag, PCI_COMMAND_STATUS_REG) |
- PCI_COMMAND_MASTER_ENABLE);
+ csr = pci_conf_read(pa->pa_bc, pa->pa_tag,
+ PCI_COMMAND_STATUS_REG);
+ pci_conf_write(pa->pa_bc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+ csr | PCI_COMMAND_MASTER_ENABLE);
- sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, leintr, sc,
- sc->sc_dev.dv_xname);
+ sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, leintr, sc);
}
#endif
-/* $OpenBSD: isa.c,v 1.5 1996/04/18 23:47:41 niklas Exp $ */
-/* $NetBSD: isa.c,v 1.78 1996/03/08 20:36:21 cgd Exp $ */
+/* $OpenBSD: isa.c,v 1.6 1996/04/21 22:24:12 deraadt Exp $ */
+/* $NetBSD: isa.c,v 1.80 1996/04/11 22:25:44 cgd Exp $ */
/*-
* Copyright (c) 1993, 1994 Charles Hannum. All rights reserved.
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/device.h>
+#ifndef i386 /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
int isamatch __P((struct device *, void *, void *));
void isaattach __P((struct device *, struct device *, void *));
-struct cfdriver isacd = {
- NULL, "isa", isamatch, isaattach, DV_DULL, sizeof(struct isa_softc), 1
+struct cfattach isa_ca = {
+ sizeof(struct isa_softc), isamatch, isaattach
+};
+
+struct cfdriver isa_cd = {
+ NULL, "isa", DV_DULL, 1
};
int
struct isa_softc *sc = (struct isa_softc *)self;
struct isabus_attach_args *iba = aux;
+ isa_attach_hook(parent, self, iba);
printf("\n");
sc->sc_bc = iba->iba_bc;
+ sc->sc_ic = iba->iba_ic;
TAILQ_INIT(&sc->sc_subdevs);
config_scan(isascan, self);
panic("clone devices not supported on ISA bus");
ia.ia_bc = sc->sc_bc;
+ ia.ia_ic = sc->sc_ic;
ia.ia_iobase = cf->cf_loc[0];
ia.ia_iosize = 0x666;
ia.ia_maddr = cf->cf_loc[2];
ia.ia_irq = cf->cf_loc[4] == 2 ? 9 : cf->cf_loc[4];
ia.ia_drq = cf->cf_loc[5];
- if ((*cf->cf_driver->cd_match)(parent, dev, &ia) > 0)
+ if ((*cf->cf_attach->ca_match)(parent, dev, &ia) > 0)
config_attach(parent, dev, &ia, isaprint);
else
free(dev, M_DEVBUF);
-/* $OpenBSD: isadma.c,v 1.3 1996/04/18 23:47:41 niklas Exp $ */
-/* $NetBSD: isadma.c,v 1.17 1996/03/01 04:35:27 mycroft Exp $ */
+/* $OpenBSD: isadma.c,v 1.4 1996/04/21 22:24:14 deraadt Exp $ */
+/* $NetBSD: isadma.c,v 1.18 1996/03/31 20:51:43 mycroft Exp $ */
#include <sys/param.h>
#include <sys/systm.h>
static u_int8_t dma_finished;
/* high byte of address is stored in this port for i-th dma channel */
-static int dmapageport[8] = {
- 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a
+static int dmapageport[2][4] = {
+ {0x87, 0x83, 0x81, 0x82},
+ {0x8f, 0x8b, 0x89, 0x8a}
};
static u_int8_t dmamode[4] = {
/* send start address */
waport = DMA1_CHN(chan);
- outb(dmapageport[chan], di->phys[0].addr>>16);
+ outb(dmapageport[0][chan], di->phys[0].addr>>16);
outb(waport, di->phys[0].addr);
outb(waport, di->phys[0].addr>>8);
/* send start address */
waport = DMA2_CHN(chan & 3);
- outb(dmapageport[chan], di->phys[0].addr>>16);
+ outb(dmapageport[1][chan], di->phys[0].addr>>16);
outb(waport, di->phys[0].addr>>1);
outb(waport, di->phys[0].addr>>9);
-/* $OpenBSD: isavar.h,v 1.7 1996/04/18 23:47:43 niklas Exp $ */
-/* $NetBSD: isavar.h,v 1.20 1996/03/16 02:00:43 cgd Exp $ */
+/* $OpenBSD: isavar.h,v 1.8 1996/04/21 22:24:16 deraadt Exp $ */
+/* $NetBSD: isavar.h,v 1.21 1996/04/11 22:20:50 cgd Exp $ */
/*
* Copyright (c) 1995 Chris G. Demetriou
#include <sys/queue.h>
#include <machine/bus.h>
+/*
+ * Structures and definitions needed by the machine-dependent header.
+ */
+struct isabus_attach_args;
+
+#if (alpha + i386 != 1)
+ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
+#endif
+#if alpha
+#include <alpha/isa/isa_machdep.h>
+#endif
+#if i386
+#include <i386/isa/isa_machdep.h>
+#endif
+
/*
* ISA bus attach arguments
*/
struct isabus_attach_args {
char *iba_busname; /* XXX should be common */
bus_chipset_tag_t iba_bc; /* XXX should be common */
+ isa_chipset_tag_t iba_ic;
};
/*
* ISA driver attach arguments
*/
struct isa_attach_args {
- bus_chipset_tag_t ia_bc; /* bus chipset tag */
+ bus_chipset_tag_t ia_bc;
+ isa_chipset_tag_t ia_ic;
int ia_iobase; /* base i/o address */
int ia_iosize; /* span of ports used */
TAILQ_HEAD(, isadev)
sc_subdevs; /* list of all children */
- bus_chipset_tag_t sc_bc; /* bus chipset tag */
+ bus_chipset_tag_t sc_bc;
+ isa_chipset_tag_t sc_ic;
};
#define cf_iobase cf_loc[0]
/* ISA interrupt sharing types */
void isascan __P((struct device *parent, void *match));
-void *isa_intr_establish __P((int intr, int type, int level,
- int (*ih_fun)(void *), void *ih_arg, char *));
-void isa_intr_disestablish __P((void *handler));
char *isa_intr_typename __P((int type));
#ifdef NEWCONFIG
-/* $OpenBSD: lpt.c,v 1.8 1996/04/18 23:47:43 niklas Exp $ */
-/* $NetBSD: lpt.c,v 1.32 1996/03/08 22:17:58 cgd Exp $ */
+/* $OpenBSD: lpt.c,v 1.9 1996/04/21 22:24:18 deraadt Exp $ */
+/* $NetBSD: lpt.c,v 1.37 1996/04/11 22:29:37 cgd Exp $ */
/*
* Copyright (c) 1993, 1994 Charles Hannum.
#include <sys/device.h>
#include <sys/syslog.h>
-#include <machine/cpu.h>
+#ifdef i386 /* XXX */
+#include <machine/cpu.h> /* XXX */
+#else /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <machine/bus.h>
#include <dev/isa/isavar.h>
void lptattach __P((struct device *, struct device *, void *));
int lptintr __P((void *));
-struct cfdriver lptcd = {
- NULL, "lpt", lptprobe, lptattach, DV_TTY, sizeof(struct lpt_softc)
+struct cfattach lpt_ca = {
+ sizeof(struct lpt_softc), lptprobe, lptattach
+};
+
+struct cfdriver lpt_cd = {
+ NULL, "lpt", DV_TTY
};
#define LPTUNIT(s) (minor(s) & 0x1f)
static void lptwakeup __P((void *arg));
static int pushbytes __P((struct lpt_softc *));
+int lpt_port_test __P((bus_chipset_tag_t, bus_io_handle_t, bus_io_addr_t,
+ bus_io_size_t, u_char, u_char));
+
/*
* Internal routine to lptprobe to do port tests of one byte value.
*/
int
-lpt_port_test(ioh, off, data, mask, base)
+lpt_port_test(bc, ioh, base, off, data, mask)
+ bus_chipset_tag_t bc;
bus_io_handle_t ioh;
- size_t off;
+ bus_io_addr_t base;
+ bus_io_size_t off;
u_char data, mask;
- u_long base;
{
int timeout;
u_char temp;
mask = 0xff;
data = 0x55; /* Alternating zeros */
- if (!lpt_port_test(ioh, lpt_data, data, mask, base))
+ if (!lpt_port_test(bc, ioh, base, lpt_data, data, mask))
ABORT;
data = 0xaa; /* Alternating ones */
- if (!lpt_port_test(ioh, lpt_data, data, mask, base))
+ if (!lpt_port_test(bc, ioh, base, lpt_data, data, mask))
ABORT;
for (i = 0; i < CHAR_BIT; i++) { /* Walking zero */
data = ~(1 << i);
- if (!lpt_port_test(ioh, lpt_data, data, mask, base))
+ if (!lpt_port_test(bc, ioh, base, lpt_data, data, mask))
ABORT;
}
for (i = 0; i < CHAR_BIT; i++) { /* Walking one */
data = (1 << i);
- if (!lpt_port_test(ioh, lpt_data, data, mask, base))
+ if (!lpt_port_test(bc, ioh, base, lpt_data, data, mask))
ABORT;
}
bus_io_write_1(bc, ioh, lpt_control, LPC_NINIT);
if (ia->ia_irq != IRQUNK)
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_NONE,
- lptintr, sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_TTY, lptintr, sc, sc->sc_dev.dv_xname);
}
/*
int error;
int spin;
- if (unit >= lptcd.cd_ndevs)
+ if (unit >= lpt_cd.cd_ndevs)
return ENXIO;
- sc = lptcd.cd_devs[unit];
+ sc = lpt_cd.cd_devs[unit];
if (!sc)
return ENXIO;
/*
* Close the device, and free the local line buffer.
*/
+int
lptclose(dev, flag)
dev_t dev;
int flag;
{
int unit = LPTUNIT(dev);
- struct lpt_softc *sc = lptcd.cd_devs[unit];
+ struct lpt_softc *sc = lpt_cd.cd_devs[unit];
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
* Copy a line from user space to a local buffer, then call putc to get the
* chars moved to the output queue.
*/
+int
lptwrite(dev, uio)
dev_t dev;
struct uio *uio;
{
- struct lpt_softc *sc = lptcd.cd_devs[LPTUNIT(dev)];
+ struct lpt_softc *sc = lpt_cd.cd_devs[LPTUNIT(dev)];
size_t n;
int error = 0;
-/* $OpenBSD: mcd.c,v 1.8 1996/03/20 01:00:56 mickey Exp $ */
-/* $NetBSD: mcd.c,v 1.45 1996/01/30 18:28:05 thorpej Exp $ */
+/* $OpenBSD: mcd.c,v 1.9 1996/04/21 22:24:21 deraadt Exp $ */
+/* $NetBSD: mcd.c,v 1.47 1996/04/11 22:29:43 cgd Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
int mcdprobe __P((struct device *, void *, void *));
void mcdattach __P((struct device *, struct device *, void *));
-struct cfdriver mcdcd = {
- NULL, "mcd", mcdprobe, mcdattach, DV_DISK, sizeof(struct mcd_softc)
+struct cfattach mcd_ca = {
+ sizeof(struct mcd_softc), mcdprobe, mcdattach
+};
+
+struct cfdriver mcd_cd = {
+ NULL, "mcd", DV_DISK
};
void mcdgetdisklabel __P((struct mcd_softc *));
mcd_soft_reset(sc);
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, mcdintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, mcdintr, sc, sc->sc_dev.dv_xname);
}
/*
struct mcd_softc *sc;
unit = MCDUNIT(dev);
- if (unit >= mcdcd.cd_ndevs)
+ if (unit >= mcd_cd.cd_ndevs)
return ENXIO;
- sc = mcdcd.cd_devs[unit];
+ sc = mcd_cd.cd_devs[unit];
if (!sc)
return ENXIO;
dev_t dev;
int flag, fmt;
{
- struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(dev)];
+ struct mcd_softc *sc = mcd_cd.cd_devs[MCDUNIT(dev)];
int part = MCDPART(dev);
int error;
mcdstrategy(bp)
struct buf *bp;
{
- struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(bp->b_dev)];
+ struct mcd_softc *sc = mcd_cd.cd_devs[MCDUNIT(bp->b_dev)];
int s;
/* Test validity. */
int flag;
struct proc *p;
{
- struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(dev)];
+ struct mcd_softc *sc = mcd_cd.cd_devs[MCDUNIT(dev)];
int error;
MCD_TRACE("ioctl: cmd=0x%x\n", cmd, 0, 0, 0);
-/* $OpenBSD: pas.c,v 1.8 1996/04/18 23:47:44 niklas Exp $ */
-/* $NetBSD: pas.c,v 1.13 1996/03/01 04:08:43 mycroft Exp $ */
+/* $OpenBSD: pas.c,v 1.9 1996/04/21 22:24:23 deraadt Exp $ */
+/* $NetBSD: pas.c,v 1.15 1996/04/11 22:29:48 cgd Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
int pasprobe __P((struct device *, void *, void *));
void pasattach __P((struct device *, struct device *, void *));
-struct cfdriver pascd = {
- NULL, "pas", pasprobe, pasattach, DV_DULL, sizeof(struct pas_softc)
+struct cfattach pas_ca = {
+ sizeof(struct pas_softc), pasprobe, pasattach
+};
+
+struct cfdriver pas_cd = {
+ NULL, "pas", DV_DULL
};
/*
int err;
sc->sc_iobase = iobase;
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_AUDIO,
- sbdsp_intr, &sc->sc_sbdsp, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_AUDIO, sbdsp_intr, &sc->sc_sbdsp, sc->sc_dev.dv_xname);
printf(" ProAudio Spectrum %s [rev %d] ", pasnames[sc->model], sc->rev);
struct pas_softc *sc;
int unit = AUDIOUNIT(dev);
- if (unit >= pascd.cd_ndevs)
+ if (unit >= pas_cd.cd_ndevs)
return ENODEV;
- sc = pascd.cd_devs[unit];
+ sc = pas_cd.cd_devs[unit];
if (!sc)
return ENXIO;
-/* $OpenBSD: pss.c,v 1.7 1996/03/20 01:00:59 mickey Exp $ */
-/* $NetBSD: pss.c,v 1.11 1995/12/24 02:31:45 mycroft Exp $ */
+/* $OpenBSD: pss.c,v 1.8 1996/04/21 22:24:26 deraadt Exp $ */
+/* $NetBSD: pss.c,v 1.13 1996/04/11 22:29:52 cgd Exp $ */
/*
* Copyright (c) 1994 John Brezak
#define at_dma(flags, ptr, cc, chan) isa_dmastart(flags, ptr, cc, chan)
#endif
-struct cfdriver psscd = {
- NULL, "pss", pssprobe, pssattach, DV_DULL, sizeof(struct pss_softc), 1
+struct cfattach pss_ca = {
+ sizeof(struct pss_softc), pssprobe, pssattach
};
-struct cfdriver spcd = {
- NULL, "sp", spprobe, spattach, DV_DULL, sizeof(struct ad1848_softc)
+struct cfdriver pss_cd = {
+ NULL, "pss", DV_DULL, 1
};
-struct cfdriver mpucd = {
- NULL, "mpu", mpuprobe, mpuattach, DV_DULL, sizeof(struct mpu_softc)
+struct cfattach sp_ca = {
+ sizeof(struct ad1848_softc), spprobe, spattach
};
-struct cfdriver pcdcd = {
- NULL, "pcd", pcdprobe, pcdattach, DV_DULL, sizeof(struct cd_softc)
+struct cfdriver sp_cd = {
+ NULL, "sp", DV_DULL
+};
+
+struct cfattach mpu_ca = {
+ sizeof(struct mpu_softc), mpuprobe, mpuattach
+};
+
+struct cfdriver mpu_cd = {
+ NULL, "mpu", DV_DULL
+};
+
+struct cfattach pcd_ca = {
+ sizeof(struct cd_softc), pcdprobe, pcdattach
+};
+
+struct cfdriver pcd_cd = {
+ NULL, "pcd", DV_DULL
};
struct audio_device pss_device = {
#endif
/* Setup interrupt handler for PSS */
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_AUDIO, pssintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, IPL_AUDIO,
+ pssintr, sc, sc->sc_dev.dv_xname);
vers = (inw(sc->sc_iobase+PSS_ID_VERS)&0xff) - 1;
printf(": ESC614%c\n", (vers > 0)?'A'+vers:' ');
- (void)config_found(self, NULL, NULL);
+ (void)config_found(self, ia->ia_ic, NULL); /* XXX */
sc->out_port = PSS_MASTER_VOL;
{
struct ad1848_softc *sc = (struct ad1848_softc *)self;
struct cfdata *cf = (void *)sc->sc_dev.dv_cfdata;
+ isa_chipset_tag_t ic = aux; /* XXX */
int iobase = cf->cf_iobase;
sc->sc_iobase = iobase;
isa_establish(&sc->sc_id, &sc->sc_dev);
#endif
- sc->sc_ih = isa_intr_establish(cf->cf_irq, IST_EDGE, IPL_AUDIO, ad1848_intr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ic, cf->cf_irq, IST_EDGE, IPL_AUDIO,
+ ad1848_intr, sc, sc->sc_dev.dv_xname);
/* XXX might use pssprint func ?? */
printf(" port 0x%x-0x%x irq %d drq %d",
{
struct mpu_softc *sc = (struct mpu_softc *)self;
struct cfdata *cf = (void *)sc->sc_dev.dv_cfdata;
+ isa_chipset_tag_t ic = aux; /* XXX */
int iobase = cf->cf_iobase;
sc->sc_iobase = iobase;
isa_establish(&sc->sc_id, &sc->sc_dev);
#endif
- sc->sc_ih = isa_intr_establish(cf->cf_irq, IST_EDGE, IPL_AUDIO, mpuintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ic, cf->cf_irq, IST_EDGE, IPL_AUDIO,
+ mpuintr, sc, sc->sc_dev.dv_xname);
/* XXX might use pssprint func ?? */
printf(" port 0x%x-0x%x irq %d\n",
struct ad1848_softc *sc;
int unit = AUDIOUNIT(dev);
- if (unit >= spcd.cd_ndevs)
+ if (unit >= sp_cd.cd_ndevs)
return ENODEV;
- sc = spcd.cd_devs[unit];
+ sc = sp_cd.cd_devs[unit];
if (!sc)
return ENXIO;
-/* $OpenBSD: rtfps.c,v 1.7 1996/04/18 23:47:45 niklas Exp $ */
-/* $NetBSD: rtfps.c,v 1.17 1996/03/10 09:01:28 cgd Exp $ */
+/* $OpenBSD: rtfps.c,v 1.8 1996/04/21 22:24:28 deraadt Exp $ */
+/* $NetBSD: rtfps.c,v 1.21 1996/04/15 18:55:31 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/termios.h>
+#ifdef i386 /* XXX */
+#include <machine/cpu.h> /* XXX */
+#else /* XXX */
+#include <machine/intr.h>
+#endif /* XXX */
#include <machine/bus.h>
#include <dev/isa/isavar.h>
void rtfpsattach();
int rtfpsintr __P((void *));
-struct cfdriver rtfpscd = {
- NULL, "rtfps", rtfpsprobe, rtfpsattach, DV_TTY, sizeof(struct rtfps_softc)
+struct cfattach rtfps_ca = {
+ sizeof(struct rtfps_softc), rtfpsprobe, rtfpsattach
+};
+
+struct cfdriver rtfps_cd = {
+ NULL, "rtfps", DV_TTY
};
int
ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
ca.ca_noien = 0;
- /* mimic config_found(), but with special functionality */
- if ((match = config_search(NULL, self, &ca)) != NULL) {
- subunit = match->cf_unit; /* can change if unit == * */
- config_attach(self, match, &ca, rtfpsprint);
- sc->sc_slaves[i] = match->cf_driver->cd_devs[subunit];
+ sc->sc_slaves[i] = config_found(self, &ca, rtfpsprint);
+ if (sc->sc_slaves[i] != NULL)
sc->sc_alive |= 1 << i;
- } else {
- rtfpsprint(&ca, self->dv_xname);
- printf(" not configured\n");
- }
}
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_TTY,
- rtfpsintr, sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_TTY, rtfpsintr, sc, sc->sc_dev.dv_xname);
}
int
-/* $OpenBSD: sb.c,v 1.8 1996/04/18 23:47:46 niklas Exp $ */
-/* $NetBSD: sb.c,v 1.32 1996/03/16 04:00:09 jtk Exp $ */
+/* $OpenBSD: sb.c,v 1.9 1996/04/21 22:24:30 deraadt Exp $ */
+/* $NetBSD: sb.c,v 1.34 1996/04/11 22:30:01 cgd Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
int sbprobe __P((struct device *, void *, void *));
void sbattach __P((struct device *, struct device *, void *));
-struct cfdriver sbcd = {
- NULL, "sb", sbprobe, sbattach, DV_DULL, sizeof(struct sbdsp_softc)
+struct cfattach sb_ca = {
+ sizeof(struct sbdsp_softc), sbprobe, sbattach
+};
+
+struct cfdriver sb_cd = {
+ NULL, "sb", DV_DULL
+};
+
+struct audio_device sb_device = {
+ "SoundBlaster",
+ "x",
+ "sb"
};
int sbopen __P((dev_t, int));
register int iobase = ia->ia_iobase;
int err;
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_AUDIO,
- sbdsp_intr, sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_AUDIO, sbdsp_intr, sc, sc->sc_dev.dv_xname);
sbdsp_attach(sc);
struct sbdsp_softc *sc;
int unit = AUDIOUNIT(dev);
- if (unit >= sbcd.cd_ndevs)
+ if (unit >= sb_cd.cd_ndevs)
return ENODEV;
- sc = sbcd.cd_devs[unit];
+ sc = sb_cd.cd_devs[unit];
if (!sc)
return ENXIO;
void seaattach __P((struct device *, struct device *, void *));
int seaprint __P((void *, char *));
-struct cfdriver seacd = {
- NULL, "sea", seaprobe, seaattach, DV_DULL, sizeof(struct sea_softc)
+struct cfattach sea_ca = {
+ sizeof(struct sea_softc), seaprobe, seaattach
+};
+
+struct cfdriver sea_cd = {
+ NULL, "sea", DV_DULL
};
#ifdef SEA_DEBUGQUEUE
#ifdef NEWCONFIG
isa_establish(&sea->sc_id, &sea->sc_deV);
#endif
- sea->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, seaintr,
- sea, sc->sc_dev.dv_xname);
+ sea->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, seaintr, sea, sea->sc_dev.dv_xname);
/*
* ask the adapter what subunits are present
*/
loop:
done = 1;
- for (unit = 0; unit < seacd.cd_ndevs; unit++) {
- sea = seacd.cd_devs[unit];
+ for (unit = 0; unit < sea_cd.cd_ndevs; unit++) {
+ sea = sea_cd.cd_devs[unit];
if (!sea)
continue;
s = splbio();
-/* $OpenBSD: ultra14f.c,v 1.12 1996/04/18 23:47:50 niklas Exp $ */
-/* $NetBSD: ultra14f.c,v 1.62 1996/02/24 05:27:49 mycroft Exp $ */
+/* $OpenBSD: ultra14f.c,v 1.13 1996/04/21 22:24:36 deraadt Exp $ */
+/* $NetBSD: ultra14f.c,v 1.64 1996/04/11 22:30:20 cgd Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
void uhaattach __P((struct device *, struct device *, void *));
int uhaprint __P((void *, char *));
-struct cfdriver uhacd = {
- NULL, "uha", uhaprobe, uhaattach, DV_DULL, sizeof(struct uha_softc)
+struct cfattach uha_ca = {
+ sizeof(struct uha_softc), uhaprobe, uhaattach
+};
+
+struct cfdriver uha_cd = {
+ NULL, "uha", DV_DULL
};
/*
#ifdef NEWCONFIG
isa_establish(&uha->sc_id, &uha->sc_dev);
#endif
- uha->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO,
- uha->intr, uha, uha->sc_dev.dv_xname);
+ uha->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, uha->intr, uha, uha->sc_dev.dv_xname);
/*
* ask the adapter what subunits are present
-/* $OpenBSD: wd.c,v 1.9 1996/04/18 23:47:51 niklas Exp $ */
-/* $NetBSD: wd.c,v 1.146 1996/03/01 04:08:51 mycroft Exp $ */
+/* $OpenBSD: wd.c,v 1.10 1996/04/21 22:24:40 deraadt Exp $ */
+/* $NetBSD: wd.c,v 1.148 1996/04/11 22:30:31 cgd Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
int wdcprobe __P((struct device *, void *, void *));
void wdcattach __P((struct device *, struct device *, void *));
-struct cfdriver wdccd = {
- NULL, "wdc", wdcprobe, wdcattach, DV_DULL, sizeof(struct wdc_softc)
+struct cfattach wdc_ca = {
+ sizeof(struct wdc_softc), wdcprobe, wdcattach
+};
+
+struct cfdriver wdc_cd = {
+ NULL, "wdc", DV_DULL
};
int wdprobe __P((struct device *, void *, void *));
void wdattach __P((struct device *, struct device *, void *));
-struct cfdriver wdcd = {
- NULL, "wd", wdprobe, wdattach, DV_DISK, sizeof(struct wd_softc)
+struct cfattach wd_ca = {
+ sizeof(struct wd_softc), wdprobe, wdattach
+};
+
+struct cfdriver wd_cd = {
+ NULL, "wd", DV_DISK
};
void wdgetdisklabel __P((struct wd_softc *));
printf("\n");
- wdc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, wdcintr,
- wdc, wdc->sc_dev.dv_xname);
+ wdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, wdcintr, wdc, wdc->sc_dev.dv_xname);
for (wa.wa_drive = 0; wa.wa_drive < 2; wa.wa_drive++)
(void)config_found(self, (void *)&wa, wdprint);
wdstrategy(bp)
struct buf *bp;
{
- struct wd_softc *wd = wdcd.cd_devs[WDUNIT(bp->b_dev)];
+ struct wd_softc *wd = wd_cd.cd_devs[WDUNIT(bp->b_dev)];
int s;
/* Valid request? */
int error;
unit = WDUNIT(dev);
- if (unit >= wdcd.cd_ndevs)
+ if (unit >= wd_cd.cd_ndevs)
return ENXIO;
- wd = wdcd.cd_devs[unit];
+ wd = wd_cd.cd_devs[unit];
if (wd == 0)
return ENXIO;
dev_t dev;
int flag, fmt;
{
- struct wd_softc *wd = wdcd.cd_devs[WDUNIT(dev)];
+ struct wd_softc *wd = wd_cd.cd_devs[WDUNIT(dev)];
int part = WDPART(dev);
int error;
int flag;
struct proc *p;
{
- struct wd_softc *wd = wdcd.cd_devs[WDUNIT(dev)];
+ struct wd_softc *wd = wd_cd.cd_devs[WDUNIT(dev)];
int error;
if ((wd->sc_flags & WDF_LOADED) == 0)
if (wdopen(dev, 0, S_IFBLK) != 0)
return -1;
- wd = wdcd.cd_devs[WDUNIT(dev)];
+ wd = wd_cd.cd_devs[WDUNIT(dev)];
part = WDPART(dev);
if (wd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
wddoingadump = 1;
unit = WDUNIT(dev);
- if (unit >= wdcd.cd_ndevs)
+ if (unit >= wd_cd.cd_ndevs)
return ENXIO;
- wd = wdcd.cd_devs[unit];
+ wd = wd_cd.cd_devs[unit];
if (wd == 0)
return ENXIO;
(void) wdcreset(wdc);
/* Schedule recalibrate for all drives on this controller. */
- for (unit = 0; unit < wdcd.cd_ndevs; unit++) {
- struct wd_softc *wd = wdcd.cd_devs[unit];
+ for (unit = 0; unit < wd_cd.cd_ndevs; unit++) {
+ struct wd_softc *wd = wd_cd.cd_devs[unit];
if (!wd || (void *)wd->sc_dev.dv_parent != wdc)
continue;
if (wd->sc_state > RECAL)
+++ /dev/null
-/* $NetBSD: wd7000.c,v 1.22 1995/08/12 20:31:32 mycroft Exp $ */
-
-/* XXX THIS DRIVER IS BROKEN. IT WILL NOT EVEN COMPILE. */
-
-/*
- * UNFINISHED! UNFINISHED! UNFINISHED! UNFINISHED! UNFINISHED! UNFINISHED!
- *
- * deraadt@fsa.ca 93/04/02
- *
- * I was writing this driver for a wd7000-ASC. Yeah, the "-ASC" not the
- * "-FASST2". The difference is that the "-ASC" is missing scatter gather
- * support.
- *
- * In any case, the real reason why I never finished it is because the
- * motherboard I have has broken DMA. This card wants 8MHz 1 wait state
- * operation, and my board munges about 30% of the words transferred.
- *
- * Hopefully someone can finish this for the wd7000-FASST2. It should be
- * quite easy to do. Look at the Linux wd7000 device driver to see how
- * scatter gather is done by the board, then look at one of the Adaptec
- * drivers to finish off the job..
- */
-#include "wds.h"
-#if NWDS > 0
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/dkbad.h>
-#include <sys/disklabel.h>
-
-#include <scsi/scsi_all.h>
-#include <scsi/scsiconf.h>
-
-#include <machine/cpu.h>
-#include <machine/pio.h>
-
-#include <dev/isa/isadmavar.h>
-#include <i386/isa/isa_device.h> /* XXX BROKEN */
-
-extern int delaycount; /* from clock setup code */
-
-#define PHYSTOKV(x) ((x) + KERNBASE)
-#define KVTOPHYS(x) vtophys(x)
-#define PAGESIZ 4096
-
-
-/* WD7000 registers */
-#define WDS_STAT 0 /* read */
-#define WDS_IRQSTAT 1 /* read */
-
-#define WDS_CMD 0 /* write */
-#define WDS_IRQACK 1 /* write */
-#define WDS_HCR 2 /* write */
-
-/* WDS_STAT (read) defs */
-#define WDS_IRQ 0x80
-#define WDS_RDY 0x40
-#define WDS_REJ 0x20
-#define WDS_INIT 0x10
-
-/* WDS_IRQSTAT (read) defs */
-#define WDSI_MASK 0xc0
-#define WDSI_ERR 0x00
-#define WDSI_MFREE 0x80
-#define WDSI_MSVC 0xc0
-
-/* WDS_CMD (write) defs */
-#define WDSC_NOOP 0x00
-#define WDSC_INIT 0x01
-#define WDSC_DISUNSOL 0x02
-#define WDSC_ENAUNSOL 0x03
-#define WDSC_IRQMFREE 0x04
-#define WDSC_SCSIRESETSOFT 0x05
-#define WDSC_SCSIRESETHARD 0x06
-#define WDSC_MSTART(m) (0x80 + (m))
-#define WDSC_MMSTART(m) (0xc0 + (m))
-
-/* WDS_HCR (write) defs */
-#define WDSH_IRQEN 0x08
-#define WDSH_DRQEN 0x04
-#define WDSH_SCSIRESET 0x02
-#define WDSH_ASCRESET 0x01
-
-struct wds_cmd {
- u_char cmd;
- u_char targ;
- struct scsi_generic scb; /*u_char scb[12];*/
- u_char stat;
- u_char venderr;
- u_char len[3];
- u_char data[3];
- u_char next[3];
- u_char write;
- u_char xx[6];
-};
-
-struct wds_req {
- struct wds_cmd cmd;
- struct wds_cmd sense;
- struct scsi_xfer *sxp;
- int busy, polled;
- int done, ret, ombn;
-};
-
-#define WDSX_SCSICMD 0x00
-#define WDSX_OPEN_RCVBUF 0x80
-#define WDSX_RCV_CMD 0x81
-#define WDSX_RCV_DATA 0x82
-#define WDSX_RCV_DATASTAT 0x83
-#define WDSX_SND_DATA 0x84
-#define WDSX_SND_DATASTAT 0x85
-#define WDSX_SND_CMDSTAT 0x86
-#define WDSX_READINIT 0x88
-#define WDSX_READSCSIID 0x89
-#define WDSX_SETUNSOLIRQMASK 0x8a
-#define WDSX_GETUNSOLIRQMASK 0x8b
-#define WDSX_GETFIRMREV 0x8c
-#define WDSX_EXECDIAG 0x8d
-#define WDSX_SETEXECPARM 0x8e
-#define WDSX_GETEXECPARM 0x8f
-
-struct wds_mb {
- u_char stat;
- u_char addr[3];
-};
-/* ICMB status value */
-#define ICMB_OK 0x01
-#define ICMB_OKERR 0x02
-#define ICMB_ETIME 0x04
-#define ICMB_ERESET 0x05
-#define ICMB_ETARCMD 0x06
-#define ICMB_ERESEL 0x80
-#define ICMB_ESEL 0x81
-#define ICMB_EABORT 0x82
-#define ICMB_ESRESET 0x83
-#define ICMB_EHRESET 0x84
-
-struct wds_setup {
- u_char cmd;
- u_char scsi_id;
- u_char buson_t;
- u_char busoff_t;
- u_char xx;
- u_char mbaddr[3];
- u_char nomb;
- u_char nimb;
-};
-
-#define WDS_NOMB 16
-#define WDS_NIMB 8
-#define MAXSIMUL 8
-struct wds {
- int addr;
- struct wds_req wdsr[MAXSIMUL];
- struct wds_mb ombs[WDS_NOMB], imbs[WDS_NIMB];
-} wds[NWDS];
-
-static int wdsunit = 0;
-int wds_debug = 0;
-
-void p2x(u_char *, u_long);
-u_char *x2p(u_char *);
-int wdsprobe(struct isa_device *);
-void wds_minphys(struct buf *);
-struct wds_req *wdsr_alloc(int);
-int wds_scsi_cmd(struct scsi_xfer *);
-long wds_adapter_info(int);
-int wdsintr(int);
-int wds_done(int, struct wds_cmd *, u_char);
-int wdsattach(struct isa_device *);
-int wds_init(struct isa_device *);
-int wds_cmd(int, u_char *, int);
-void wds_wait(int, int, int);
-
-
-struct scsi_switch wds_switch[NWDS];
-
-struct isa_driver wdsdriver = {
- wdsprobe,
- wdsattach,
- "wds",
-};
-
-
-void
-flushcache(void)
-{
- extern main();
- volatile char *p, c;
- int i;
-
- for(p=(char *)main, i=0; i<256*1024; i++)
- c = *p++;
-}
-
-void
-p2x(u_char *p, u_long x)
-{
- p[0] = (x & 0x00ff0000) >> 16;
- p[1] = (x & 0x0000ff00) >> 8;
- p[2] = (x & 0x000000ff);
-}
-
-u_char *
-x2p(u_char *x)
-{
- u_long q;
-
- q = ((x[0]<<16) & 0x00ff0000) + ((x[1]<<8) & 0x0000ff00) + (x[2] & 0x000000ff);
- return (u_char *)q;
-}
-
-int
-wdsprobe(struct isa_device *dev)
-{
- /*scsi_debug = PRINTROUTINES | TRACEOPENS | TRACEINTERRUPTS |
- SHOWREQUESTS | SHOWSCATGATH | SHOWINQUIRY | SHOWCOMMANDS;*/
-
- if (dev->id_parent)
- return 1;
-
- if(wdsunit > NWDS)
- return 0;
-
- dev->id_unit = wdsunit;
- wds[wdsunit].addr = dev->id_iobase;
-
- if(wds_init(dev) != 0)
- return 0;
- wdsunit++;
- return 8;
-}
-
-void
-wds_minphys(struct buf *bp)
-{
- int base = (int)bp->b_data & (PAGESIZ-1);
-
- if (base + bp->b_bcount > PAGESIZ)
- bp->b_bcount = PAGESIZ - base;
- minphys(bp);
-}
-
-struct wds_req *
-wdsr_alloc(int unit)
-{
- struct wds_req *r;
- int x;
- int i;
-
- r = NULL;
- x = splbio();
- for(i=0; i<MAXSIMUL; i++)
- if(wds[unit].wdsr[i].busy == 0) {
- r = &wds[unit].wdsr[i];
- r->busy = 1;
- break;
- }
- if(r == NULL) {
- splx(x);
- return NULL;
- }
-
- r->ombn = -1;
- for(i=0; i<WDS_NOMB; i++)
- if(wds[unit].ombs[i].stat==0) {
- wds[unit].ombs[i].stat = 1;
- r->ombn = i;
- break;
- }
- if(r->ombn == -1 ) {
- r->busy = 0;
- splx(x);
- return NULL;
- }
- splx(x);
- return r;
-}
-
-int
-wds_scsi_cmd(struct scsi_xfer *sxp)
-{
- struct wds_req *r;
- int unit = sxp->adapter;
- int base;
- u_char c, *p;
- int i;
-
- base = wds[unit].addr;
-
- /*printf("scsi_cmd\n");*/
-
- if( sxp->flags & SCSI_RESET) {
- printf("reset!\n");
- return COMPLETE;
- }
-
- r = wdsr_alloc(unit);
- if(r==NULL) {
- printf("no request slot available!\n");
- sxp->error = XS_DRIVER_STUFFUP;
- return TRY_AGAIN_LATER;
- }
- r->done = 0;
- r->sxp = sxp;
-
- printf("wds%d: target %d/%d req %8x flags %08x len %d: ", unit,
- sxp->targ, sxp->lu, r, sxp->flags, sxp->cmdlen);
- for(i=0, p=(u_char *)sxp->cmd; i<sxp->cmdlen; i++)
- printf("%02x ", p[i]);
- printf("\n");
- printf(" data %08x datalen %08x\n", sxp->data, sxp->datalen);
-
- if(sxp->flags & SCSI_DATA_UIO) {
- printf("UIO!\n");
- sxp->error = XS_DRIVER_STUFFUP;
- return TRY_AGAIN_LATER;
- }
-
- p2x(&wds[unit].ombs[r->ombn].addr[0], KVTOPHYS(&r->cmd));
- printf("%08x/%08x mbox@%08x: %02x %02x %02x %02x\n",
- &r->cmd, KVTOPHYS(&r->cmd), &wds[unit].ombs[0],
- wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0],
- wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]);
-
- bzero(&r->cmd, sizeof r->cmd);
- r->cmd.cmd = WDSX_SCSICMD;
- r->cmd.targ = (sxp->targ << 5) | sxp->lu;
- bcopy(sxp->cmd, &r->cmd.scb, sxp->cmdlen<12 ? sxp->cmdlen : 12);
- p2x(&r->cmd.len[0], sxp->datalen);
- p2x(&r->cmd.data[0], sxp->datalen ? KVTOPHYS(sxp->data) : 0);
- r->cmd.write = (sxp->flags&SCSI_DATA_IN)? 0x80 : 0x00;
- p2x(&r->cmd.next[0], KVTOPHYS(&r->sense));
-
- bzero(&r->sense, sizeof r->sense);
- r->sense.cmd = r->cmd.cmd;
- r->sense.targ = r->cmd.targ;
- r->sense.scb.opcode = REQUEST_SENSE;
- p2x(&r->sense.data[0], KVTOPHYS(&sxp->sense));
- p2x(&r->sense.len[0], sizeof sxp->sense);
- r->sense.write = 0x80;
-
- /*printf("wdscmd: ");
- for(i=0, p=(u_char *)&r->cmd; i<sizeof r->cmd; i++)
- printf("%02x ", p[i]);
- printf("\n");*/
-
- if(sxp->flags & SCSI_NOMASK) {
- outb(base+WDS_HCR, WDSH_DRQEN);
- r->polled = 1;
- } else
- r->polled = 0;
-
- c = WDSC_MSTART(r->ombn);
- flushcache();
- if( wds_cmd(base, &c, sizeof c) != 0) {
- printf("wds%d: unable to start outgoing mbox\n", unit);
- r->busy = 0;
- /* XXX need to free mailbox */
- return TRY_AGAIN_LATER;
- }
-
- delay(10000);
- /*printf("%08x/%08x mbox: %02x %02x %02x %02x\n", &r->cmd, KVTOPHYS(&r->cmd),
- wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0],
- wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]);*/
-
- if(sxp->flags & SCSI_NOMASK) {
-repoll: printf("wds%d: polling.", unit);
- i = 0;
- while( (inb(base+WDS_STAT) & WDS_IRQ) == 0) {
- printf(".");
- delay(10000);
- if(++i == 10) {
- printf("failed %02x\n", inb(base+WDS_IRQSTAT));
- /*r->busy = 0;*/
- sxp->error = XS_TIMEOUT;
- return HAD_ERROR;
- }
- }
- flushcache();
- printf("got one!\n");
- wdsintr(unit);
- if(r->done) {
- r->sxp->flags |= ITSDONE;
- if(r->sxp->when_done)
- (*r->sxp->when_done)(r->sxp->done_arg,
- r->sxp->done_arg2);
- r->busy = 0;
- return r->ret;
- }
- goto repoll;
- }
-
- outb(base+WDS_HCR, WDSH_IRQEN|WDSH_DRQEN);
- printf("wds%d: successfully queued\n", unit);
- return SUCCESSFULLY_QUEUED;
-}
-
-long
-wds_adapter_info(int unit)
-{
- return 1;
-}
-
-int
-wdsintr(int unit)
-{
- struct wds_cmd *pc, *vc;
- struct wds_mb *in;
- u_char stat;
- u_char c;
-
- /*printf("stat=%02x\n", inb(wds[unit].addr + WDS_STAT));*/
- delay(1000);
- c = inb(wds[unit].addr + WDS_IRQSTAT);
- printf("wdsintr: %02x\n", c);
- if( (c&WDSI_MASK) == WDSI_MSVC) {
- delay(1000);
- c = c & ~WDSI_MASK;
- flushcache();
- in = &wds[unit].imbs[c];
-
- printf("incoming mailbox %02x@%08x: ", c, in);
- printf("%02x %02x %02x %02x\n",
- in->stat, in->addr[0], in->addr[1], in->addr[2]);
- pc = (struct wds_cmd *)x2p(&in->addr[0]);
- vc = (struct wds_cmd *)PHYSTOKV(pc);
- stat = in->stat;
- printf("p=%08x v=%08x stat %02x\n", pc, vc, stat);
- wds_done(unit, vc, stat);
- in->stat = 0;
-
- outb(wds[unit].addr + WDS_IRQACK, 0xff);
- }
- return 1;
-}
-
-int
-wds_done(int unit, struct wds_cmd *c, u_char stat)
-{
- struct wds_req *r;
- int i;
-
- r = (struct wds_req *)NULL;
- for(i=0; i<MAXSIMUL; i++)
- if( c == &wds[unit].wdsr[i].cmd ) {
- /*printf("found at req slot %d\n", i);*/
- r = &wds[unit].wdsr[i];
- break;
- }
- if(r == (struct wds_req *)NULL) {
- printf("failed to find request!\n");
- return 1;
- }
-
- printf("wds%d: cmd %8x stat %2x/%2x %2x/%2x\n", unit, c,
- r->cmd.stat, r->cmd.venderr, r->sense.stat, r->sense.venderr);
-
- r->done = 1;
- /* XXX need to free mailbox */
- r->ret = HAD_ERROR;
- switch(r->cmd.stat) {
- case ICMB_OK:
- /*XXX r->sxp->sense.valid = 0;
- r->sxp->error = 0;*/
- r->ret = COMPLETE;
- break;
- case ICMB_OKERR:
- printf("scsi err %02x\n", c->venderr);
- /*XXX r->sxp->sense.error_code = c->venderr;
- r->sxp->sense.valid = 1;*/
- r->ret = COMPLETE;
- break;
- case ICMB_ETIME:
- r->sxp->error = XS_TIMEOUT;
- r->ret = HAD_ERROR;
- break;
- case ICMB_ERESET:
- case ICMB_ETARCMD:
- case ICMB_ERESEL:
- case ICMB_ESEL:
- case ICMB_EABORT:
- case ICMB_ESRESET:
- case ICMB_EHRESET:
- r->sxp->error = XS_DRIVER_STUFFUP;
- r->ret = HAD_ERROR;
- break;
- }
- if(r->polled==0) {
- r->sxp->flags |= ITSDONE;
- if(r->sxp->when_done)
- (*r->sxp->when_done)(r->sxp->done_arg, r->sxp->done_arg2);
- r->busy = 0;
- }
- return 0;
-}
-
-int
-wds_getvers(int unit)
-{
- struct wds_req *r;
- int base;
- u_char c, *p;
- int i;
-
- base = wds[unit].addr;
-
- /*printf("scsi_cmd\n");*/
-
- r = wdsr_alloc(unit);
- if(r==NULL) {
- printf("wds%d: no request slot available!\n", unit);
- return -1;
- }
- r->done = 0;
- r->sxp = NULL;
-
- printf("wds%d: getvers req %8x\n", unit, r);
-
- p2x(&wds[unit].ombs[r->ombn].addr[0], KVTOPHYS(&r->cmd));
- printf("%08x/%08x mbox@%08x: %02x %02x %02x %02x\n",
- &r->cmd, KVTOPHYS(&r->cmd), &wds[unit].ombs[0],
- wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0],
- wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]);
-
- bzero(&r->cmd, sizeof r->cmd);
- r->cmd.cmd = WDSX_GETFIRMREV;
- r->cmd.write = 0x80;
-
- printf("wdscmd: ");
- for(i=0, p=(u_char *)&r->cmd; i<sizeof r->cmd; i++)
- printf("%02x ", p[i]);
- printf("\n");
-
- outb(base+WDS_HCR, WDSH_DRQEN);
- r->polled = 1;
-
- c = WDSC_MSTART(r->ombn);
- flushcache();
- if( wds_cmd(base, &c, sizeof c) != 0) {
- printf("wds%d: unable to start outgoing mbox\n", unit);
- r->busy = 0;
- /* XXX need to free mailbox */
- return -1;
- }
-
- delay(10000);
- /*printf("%08x/%08x mbox: %02x %02x %02x %02x\n", &r->cmd, KVTOPHYS(&r->cmd),
- wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0],
- wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]);*/
-
- while(1) {
- printf("wds%d: polling.", unit);
- i = 0;
- while( (inb(base+WDS_STAT) & WDS_IRQ) == 0) {
- printf(".");
- delay(10000);
- if(++i == 10) {
- printf("failed %02x\n", inb(base+WDS_IRQSTAT));
- /*r->busy = 0;*/
- return -1;
- }
- }
- flushcache();
- printf("got one!\n");
- wdsintr(unit);
- if(r->done) {
- printf("wds%d: version %02x %02x\n", unit,
- r->cmd.targ, r->cmd.scb.opcode);
- r->busy = 0;
- return 0;
- }
- }
-}
-
-int
-wdsattach(struct isa_device *dev)
-{
- int masunit;
- static int firstswitch[NWDS];
- static u_long versprobe /* max 32 controllers */
- int r;
-
- if (!dev->id_parent)
- return 1;
- masunit = dev->id_parent->id_unit;
-
- if( !(versprobe & (1<<masunit))) {
- versprobe |= (1<<masunit);
- if(wds_getvers(masunit)==-1)
- printf("wds%d: getvers failed\n", masunit);
- }
-
- if (!firstswitch[masunit]) {
- firstswitch[masunit] = 1;
- wds_switch[masunit].name = "wds";
- wds_switch[masunit].scsi_cmd = wds_scsi_cmd;
- wds_switch[masunit].scsi_minphys = wdsminphys;
- wds_switch[masunit].open_target_lu = 0;
- wds_switch[masunit].close_target_lu = 0;
- wds_switch[masunit].adapter_info = wds_adapter_info;
- for (r = 0; r < 8; r++) {
- wds_switch[masunit].empty[r] = 0;
- wds_switch[masunit].used[r] = 0;
- wds_switch[masunit].printed[r] = 0;
- }
- }
- r = scsi_attach(masunit, &wds_switch[masunit], &dev->id_physid,
- &dev->id_unit, dev->id_flags);
- return r;
-}
-
-int
-wds_init(struct isa_device *dev)
-{
- struct wds_setup init;
- int base;
- u_char *p, c;
- int unit, i;
-
- unit = dev->id_unit;
- base = wds[unit].addr;
-
- /*
- * Sending a command causes the CMDRDY bit to clear.
- */
- c = inb(base+WDS_STAT);
- for(i=0; i<4; i++)
- if( (inb(base+WDS_STAT) & WDS_RDY) != 0) {
- goto ready;
- delay(10);
- }
- return 1;
-
-ready:
- outb(base+WDS_CMD, WDSC_NOOP);
- if( inb(base+WDS_STAT) & WDS_RDY)
- return 1;
-
- /*
- * the controller exists. reset and init.
- */
- outb(base+WDS_HCR, WDSH_SCSIRESET|WDSH_ASCRESET);
- delay(3);
- outb(base+WDS_HCR, WDSH_DRQEN);
- delay(20000);
-
-#if 1
- outb(0xd6, 0xc3);
- outb(0xd4, 0x03);
-#else
- isa_dmacascade(dev->id_drq);
-#endif
-
- if( (inb(base+WDS_STAT) & (WDS_RDY)) != WDS_RDY) {
- printf("wds%d: waiting for controller to become ready", unit);
- for(i=0; i<6; i++) {
- if( (inb(base+WDS_STAT) & (WDS_RDY)) == WDS_RDY)
- break;
- printf(".");
- delay(10000);
- }
- if( (inb(base+WDS_STAT) & (WDS_RDY)) != WDS_RDY) {
- printf("failed\n");
- return 1;
- }
- }
-
- bzero(&init, sizeof init);
- init.cmd = WDSC_INIT;
- init.scsi_id = 0;
- init.buson_t = 24;
- init.busoff_t = 48;
- p2x(&init.mbaddr[0], KVTOPHYS(&wds[unit].ombs[0]));
- init.xx = 0;
- init.nomb = WDS_NOMB;
- init.nimb = WDS_NIMB;
-
- /*p = (u_char *)&init;
- printf("wds%d: %08x %08x init: ", unit,
- &wds[unit].ombs[0], KVTOPHYS(&wds[unit].ombs[0]));
- for(i=0; i<sizeof init; i++)
- printf("%02x ", p[i]);
- printf("\n");*/
-
- wds_wait(base+WDS_STAT, WDS_RDY, WDS_RDY);
- flushcache();
- if( wds_cmd(base, (u_char *)&init, sizeof init) != 0) {
- printf("wds%d: wds_cmd failed\n", unit);
- return 1;
- }
- wds_wait(base+WDS_STAT, WDS_INIT, WDS_INIT);
-
- wds_wait(base+WDS_STAT, WDS_RDY, WDS_RDY);
- c = WDSC_DISUNSOL;
- if( wds_cmd(base, &c, sizeof c) != 0) {
- printf("wds%d: wds_cmd failed\n", unit);
- return 1;
- }
-
- return 0;
-}
-
-int
-wds_cmd(int base, u_char *p, int l)
-{
- int i;
- u_char c;
-
- i = 0;
- while(i < l) {
- while( ((c=inb(base+WDS_STAT)) & WDS_RDY) == 0)
- ;
-
- outb(base+WDS_CMD, *p);
-
- while( ((c=inb(base+WDS_STAT)) & WDS_RDY) == 0)
- ;
-
- if(c & WDS_REJ)
- return 1;
- p++;
- i++;
- }
- while( ((c=inb(base+WDS_STAT)) & WDS_RDY) == 0)
- ;
- if(c & WDS_REJ)
- return 1;
- /*printf("wds_cmd: %02x\n", inb(base+WDS_STAT));*/
- return 0;
-}
-
-void
-wds_wait(int reg, int mask, int val)
-{
- while( (inb(reg) & mask) != val)
- ;
-}
-
-#endif
--- /dev/null
+/* $NetBSD: wds.c,v 1.4 1996/04/11 22:30:38 cgd Exp $ */
+
+#define WDSDIAG
+#define integrate
+
+/*
+ * XXX
+ * sense data
+ * aborts
+ * resets
+ */
+
+/*
+ * Copyright (c) 1994, 1995 Julian Highfield. All rights reserved.
+ * Portions copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Julian Highfield.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This driver is for the WD7000 family of SCSI controllers:
+ * the WD7000-ASC, a bus-mastering DMA controller,
+ * the WD7000-FASST2, an -ASC with new firmware and scatter-gather,
+ * and the WD7000-ASE, which was custom manufactured for Apollo
+ * workstations and seems to include an -ASC as well as floppy
+ * and ESDI interfaces.
+ *
+ * Loosely based on Theo Deraadt's unfinished attempt.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/buf.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+
+#include <machine/pio.h>
+
+#include <scsi/scsi_all.h>
+#include <scsi/scsiconf.h>
+
+#include <dev/isa/isavar.h>
+#include <dev/isa/isadmavar.h>
+#include <dev/isa/wdsreg.h>
+
+#ifndef DDB
+#define Debugger() panic("should call debugger here (wds.c)")
+#endif /* ! DDB */
+
+#define WDS_MBX_SIZE 16
+
+#define WDS_SCB_MAX 32
+#define SCB_HASH_SIZE 32 /* hash table size for phystokv */
+#define SCB_HASH_SHIFT 9
+#define SCB_HASH(x) ((((long)(x))>>SCB_HASH_SHIFT) & (SCB_HASH_SIZE - 1))
+
+#define wds_nextmbx(wmb, mbx, mbio) \
+ if ((wmb) == &(mbx)->mbio[WDS_MBX_SIZE - 1]) \
+ (wmb) = &(mbx)->mbio[0]; \
+ else \
+ (wmb)++;
+
+struct wds_mbx {
+ struct wds_mbx_out mbo[WDS_MBX_SIZE];
+ struct wds_mbx_in mbi[WDS_MBX_SIZE];
+ struct wds_mbx_out *cmbo; /* Collection Mail Box out */
+ struct wds_mbx_out *tmbo; /* Target Mail Box out */
+ struct wds_mbx_in *tmbi; /* Target Mail Box in */
+};
+
+#define KVTOPHYS(x) vtophys(x)
+
+struct wds_softc {
+ struct device sc_dev;
+ struct isadev sc_id;
+ void *sc_ih;
+
+ int sc_iobase;
+ int sc_irq, sc_drq;
+
+ int sc_revision;
+
+ struct wds_mbx sc_mbx;
+#define wmbx (&sc->sc_mbx)
+ struct wds_scb *sc_scbhash[SCB_HASH_SIZE];
+ TAILQ_HEAD(, wds_scb) sc_free_scb, sc_waiting_scb;
+ int sc_numscbs, sc_mbofull;
+ int sc_scsi_dev;
+ struct scsi_link sc_link; /* prototype for subdevs */
+};
+
+/* Define the bounce buffer length... */
+#define BUFLEN (64*1024)
+/* ..and how many there are. One per device! Non-FASST boards need these. */
+#define BUFCNT 8
+/* The macro for deciding whether the board needs a buffer. */
+#define NEEDBUFFER(sc) (sc->sc_revision < 0x800)
+
+struct wds_buf {
+ u_char data[BUFLEN];
+ int busy;
+ TAILQ_ENTRY(wds_buf) chain;
+} wds_buffer[BUFCNT];
+
+TAILQ_HEAD(, wds_buf) wds_free_buffer;
+
+integrate void wds_wait __P((int, int, int));
+int wds_cmd __P((int, u_char *, int));
+integrate void wds_finish_scbs __P((struct wds_softc *));
+int wdsintr __P((void *));
+integrate void wds_reset_scb __P((struct wds_softc *, struct wds_scb *));
+void wds_free_scb __P((struct wds_softc *, struct wds_scb *));
+void wds_free_buf __P((struct wds_softc *, struct wds_buf *));
+integrate void wds_init_scb __P((struct wds_softc *, struct wds_scb *));
+struct wds_scb *wds_get_scb __P((struct wds_softc *, int, int));
+struct wds_buf *wds_get_buf __P((struct wds_softc *, int));
+struct wds_scb *wds_scb_phys_kv __P((struct wds_softc *, u_long));
+void wds_queue_scb __P((struct wds_softc *, struct wds_scb *));
+void wds_collect_mbo __P((struct wds_softc *));
+void wds_start_scbs __P((struct wds_softc *));
+void wds_done __P((struct wds_softc *, struct wds_scb *, u_char));
+int wds_find __P((struct isa_attach_args *, struct wds_softc *));
+void wds_init __P((struct wds_softc *));
+void wds_inquire_setup_information __P((struct wds_softc *));
+void wdsminphys __P((struct buf *));
+int wds_scsi_cmd __P((struct scsi_xfer *));
+void wds_sense __P((struct wds_softc *, struct wds_scb *));
+int wds_poll __P((struct wds_softc *, struct scsi_xfer *, int));
+int wds_ipoll __P((struct wds_softc *, struct wds_scb *, int));
+void wds_timeout __P((void *));
+
+struct scsi_adapter wds_switch = {
+ wds_scsi_cmd,
+ wdsminphys,
+ 0,
+ 0,
+};
+
+/* the below structure is so we have a default dev struct for our link struct */
+struct scsi_device wds_dev = {
+ NULL, /* Use default error handler */
+ NULL, /* have a queue, served by this */
+ NULL, /* have no async handler */
+ NULL, /* Use default 'done' routine */
+};
+
+int wdsprobe __P((struct device *, void *, void *));
+void wdsattach __P((struct device *, struct device *, void *));
+int wdsprint __P((void *, char *));
+
+struct cfattach wds_ca = {
+ sizeof(struct wds_softc), wdsprobe, wdsattach
+};
+
+struct cfdriver wds_cd = {
+ NULL, "wds", DV_DULL
+};
+
+#define WDS_ABORT_TIMEOUT 2000 /* time to wait for abort (mSec) */
+
+integrate void
+wds_wait(port, mask, val)
+ int port;
+ int mask;
+ int val;
+{
+
+ while ((inb(port) & mask) != val)
+ ;
+}
+
+/*
+ * Write a command to the board's I/O ports.
+ */
+int
+wds_cmd(iobase, ibuf, icnt)
+ int iobase;
+ u_char *ibuf;
+ int icnt;
+{
+ u_char c;
+
+ wds_wait(iobase + WDS_STAT, WDSS_RDY, WDSS_RDY);
+
+ while (icnt--) {
+ outb(iobase + WDS_CMD, *ibuf++);
+ wds_wait(iobase + WDS_STAT, WDSS_RDY, WDSS_RDY);
+ c = inb(iobase + WDS_STAT);
+ if (c & WDSS_REJ)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Check for the presence of a WD7000 SCSI controller.
+ */
+int
+wdsprobe(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ register struct isa_attach_args *ia = aux;
+
+#ifdef NEWCONFIG
+ if (ia->ia_iobase == IOBASEUNK)
+ return 0;
+#endif
+
+ /* See if there is a unit at this location. */
+ if (wds_find(ia, NULL) != 0)
+ return 0;
+
+ ia->ia_msize = 0;
+ ia->ia_iosize = 8;
+ return 1;
+}
+
+int
+wdsprint(aux, name)
+ void *aux;
+ char *name;
+{
+
+ if (name != NULL)
+ printf("%s: scsibus ", name);
+ return UNCONF;
+}
+
+/*
+ * Attach all available units.
+ */
+void
+wdsattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct isa_attach_args *ia = aux;
+ struct wds_softc *sc = (void *)self;
+
+ if (wds_find(ia, sc) != 0)
+ panic("wdsattach: wds_find of %s failed", self->dv_xname);
+ sc->sc_iobase = ia->ia_iobase;
+
+ if (sc->sc_drq != DRQUNK)
+ isa_dmacascade(sc->sc_drq);
+
+ wds_init(sc);
+ TAILQ_INIT(&sc->sc_free_scb);
+ TAILQ_INIT(&sc->sc_waiting_scb);
+ wds_inquire_setup_information(sc);
+
+ /*
+ * fill in the prototype scsi_link.
+ */
+ sc->sc_link.adapter_softc = sc;
+ sc->sc_link.adapter_target = sc->sc_scsi_dev;
+ sc->sc_link.adapter = &wds_switch;
+ sc->sc_link.device = &wds_dev;
+ /* XXX */
+ /* I don't think the -ASE can handle openings > 1. */
+ /* It gives Vendor Error 26 whenever I try it. */
+ sc->sc_link.openings = 1;
+
+#ifdef NEWCONFIG
+ isa_establish(&sc->sc_id, &sc->sc_dev);
+#endif
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, sc->sc_irq, IST_EDGE,
+ IPL_BIO, wdsintr, sc, sc->sc_dev.dv_xname);
+
+ /*
+ * ask the adapter what subunits are present
+ */
+ config_found(self, &sc->sc_link, wdsprint);
+}
+
+integrate void
+wds_finish_scbs(sc)
+ struct wds_softc *sc;
+{
+ struct wds_mbx_in *wmbi;
+ struct wds_scb *scb;
+ int i;
+
+ wmbi = wmbx->tmbi;
+
+ if (wmbi->stat == WDS_MBI_FREE) {
+ for (i = 0; i < WDS_MBX_SIZE; i++) {
+ if (wmbi->stat != WDS_MBI_FREE) {
+ printf("%s: mbi not in round-robin order\n",
+ sc->sc_dev.dv_xname);
+ goto AGAIN;
+ }
+ wds_nextmbx(wmbi, wmbx, mbi);
+ }
+#ifdef WDSDIAGnot
+ printf("%s: mbi interrupt with no full mailboxes\n",
+ sc->sc_dev.dv_xname);
+#endif
+ return;
+ }
+
+AGAIN:
+ do {
+ scb = wds_scb_phys_kv(sc, phystol(wmbi->scb_addr));
+ if (!scb) {
+ printf("%s: bad mbi scb pointer; skipping\n",
+ sc->sc_dev.dv_xname);
+ goto next;
+ }
+
+#ifdef WDSDEBUG
+ if (wds_debug) {
+ u_char *cp = &scb->scsi_cmd;
+ printf("op=%x %x %x %x %x %x\n",
+ cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
+ printf("stat %x for mbi addr = 0x%08x, ",
+ wmbi->stat, wmbi);
+ printf("scb addr = 0x%x\n", scb);
+ }
+#endif /* WDSDEBUG */
+
+ untimeout(wds_timeout, scb);
+ wds_done(sc, scb, wmbi->stat);
+
+ next:
+ wmbi->stat = WDS_MBI_FREE;
+ wds_nextmbx(wmbi, wmbx, mbi);
+ } while (wmbi->stat != WDS_MBI_FREE);
+
+ wmbx->tmbi = wmbi;
+}
+
+/*
+ * Process an interrupt.
+ */
+int
+wdsintr(arg)
+ void *arg;
+{
+ struct wds_softc *sc = arg;
+ int iobase = sc->sc_iobase;
+ u_char sts;
+
+ struct wds_mbx_in *in;
+ struct wds_scb *scb;
+ u_char stat, c;
+
+ /* Was it really an interrupt from the board? */
+ if ((inb(iobase + WDS_STAT) & WDSS_IRQ) == 0)
+ return 0;
+
+ /* Get the interrupt status byte. */
+ c = inb(iobase + WDS_IRQSTAT) & WDSI_MASK;
+
+ /* Acknowledge (which resets) the interrupt. */
+ outb(iobase + WDS_IRQACK, 0x00);
+
+ switch (c) {
+ case WDSI_MSVC:
+ wds_finish_scbs(sc);
+ break;
+
+ case WDSI_MFREE:
+ wds_start_scbs(sc);
+ break;
+
+ default:
+ printf("%s: unrecognized interrupt type %02x", c);
+ break;
+ }
+
+ return 1;
+}
+
+integrate void
+wds_reset_scb(sc, scb)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+{
+
+ scb->flags = 0;
+}
+
+/*
+ * Free the command structure, the outgoing mailbox and the data buffer.
+ */
+void
+wds_free_scb(sc, scb)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+{
+ int s;
+
+ if (scb->buf != 0) {
+ wds_free_buf(sc, scb->buf);
+ scb->buf = 0;
+ }
+
+ s = splbio();
+
+ wds_reset_scb(sc, scb);
+ TAILQ_INSERT_HEAD(&sc->sc_free_scb, scb, chain);
+
+ /*
+ * If there were none, wake anybody waiting for one to come free,
+ * starting with queued entries.
+ */
+ if (scb->chain.tqe_next == 0)
+ wakeup(&sc->sc_free_scb);
+
+ splx(s);
+}
+
+void
+wds_free_buf(sc, buf)
+ struct wds_softc *sc;
+ struct wds_buf *buf;
+{
+ int s;
+
+ s = splbio();
+
+ buf->busy = 0;
+ TAILQ_INSERT_HEAD(&wds_free_buffer, buf, chain);
+
+ /*
+ * If there were none, wake anybody waiting for one to come free,
+ * starting with queued entries.
+ */
+ if (buf->chain.tqe_next == 0)
+ wakeup(&wds_free_buffer);
+
+ splx(s);
+}
+
+integrate void
+wds_init_scb(sc, scb)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+{
+ int hashnum;
+
+ bzero(scb, sizeof(struct wds_scb));
+ /*
+ * put in the phystokv hash table
+ * Never gets taken out.
+ */
+ scb->hashkey = KVTOPHYS(scb);
+ hashnum = SCB_HASH(scb->hashkey);
+ scb->nexthash = sc->sc_scbhash[hashnum];
+ sc->sc_scbhash[hashnum] = scb;
+ wds_reset_scb(sc, scb);
+}
+
+/*
+ * Get a free scb
+ *
+ * If there are none, see if we can allocate a new one. If so, put it in
+ * the hash table too otherwise either return an error or sleep.
+ */
+struct wds_scb *
+wds_get_scb(sc, flags, needbuffer)
+ struct wds_softc *sc;
+ int flags;
+ int needbuffer;
+{
+ struct wds_scb *scb;
+ int s;
+
+ s = splbio();
+
+ /*
+ * If we can and have to, sleep waiting for one to come free
+ * but only if we can't allocate a new one.
+ */
+ for (;;) {
+ scb = sc->sc_free_scb.tqh_first;
+ if (scb) {
+ TAILQ_REMOVE(&sc->sc_free_scb, scb, chain);
+ break;
+ }
+ if (sc->sc_numscbs < WDS_SCB_MAX) {
+ scb = (struct wds_scb *) malloc(sizeof(struct wds_scb),
+ M_TEMP, M_NOWAIT);
+ if (!scb) {
+ printf("%s: can't malloc scb\n",
+ sc->sc_dev.dv_xname);
+ goto out;
+ }
+ wds_init_scb(sc, scb);
+ sc->sc_numscbs++;
+ break;
+ }
+ if ((flags & SCSI_NOSLEEP) != 0)
+ goto out;
+ tsleep(&sc->sc_free_scb, PRIBIO, "wdsscb", 0);
+ }
+
+ scb->flags |= SCB_ALLOC;
+
+ if (needbuffer) {
+ scb->buf = wds_get_buf(sc, flags);
+ if (scb->buf == 0)
+ wds_free_scb(sc, scb);
+ scb = 0;
+ }
+
+out:
+ splx(s);
+ return (scb);
+}
+
+struct wds_buf *
+wds_get_buf(sc, flags)
+ struct wds_softc *sc;
+ int flags;
+{
+ struct wds_buf *buf;
+ int s;
+
+ s = splbio();
+
+ for (;;) {
+ buf = wds_free_buffer.tqh_first;
+ if (buf) {
+ TAILQ_REMOVE(&wds_free_buffer, buf, chain);
+ break;
+ }
+ if ((flags & SCSI_NOSLEEP) != 0)
+ goto out;
+ tsleep(&wds_free_buffer, PRIBIO, "wdsbuf", 0);
+ }
+
+ buf->busy = 1;
+
+out:
+ splx(s);
+ return (buf);
+}
+
+struct wds_scb *
+wds_scb_phys_kv(sc, scb_phys)
+ struct wds_softc *sc;
+ u_long scb_phys;
+{
+ int hashnum = SCB_HASH(scb_phys);
+ struct wds_scb *scb = sc->sc_scbhash[hashnum];
+
+ while (scb) {
+ if (scb->hashkey == scb_phys)
+ break;
+ /* XXX Check to see if it matches the sense command block. */
+ if (scb->hashkey == (scb_phys - sizeof(struct wds_cmd)))
+ break;
+ scb = scb->nexthash;
+ }
+ return scb;
+}
+
+/*
+ * Queue a SCB to be sent to the controller, and send it if possible.
+ */
+void
+wds_queue_scb(sc, scb)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+{
+
+ TAILQ_INSERT_TAIL(&sc->sc_waiting_scb, scb, chain);
+ wds_start_scbs(sc);
+}
+
+/*
+ * Garbage collect mailboxes that are no longer in use.
+ */
+void
+wds_collect_mbo(sc)
+ struct wds_softc *sc;
+{
+ struct wds_mbx_out *wmbo; /* Mail Box Out pointer */
+ struct wds_scb *scb;
+
+ wmbo = wmbx->cmbo;
+
+ while (sc->sc_mbofull > 0) {
+ if (wmbo->cmd != WDS_MBO_FREE)
+ break;
+
+#ifdef WDSDIAG
+ scb = wds_scb_phys_kv(sc, phystol(wmbo->scb_addr));
+ scb->flags &= ~SCB_SENDING;
+#endif
+
+ --sc->sc_mbofull;
+ wds_nextmbx(wmbo, wmbx, mbo);
+ }
+
+ wmbx->cmbo = wmbo;
+}
+
+/*
+ * Send as many SCBs as we have empty mailboxes for.
+ */
+void
+wds_start_scbs(sc)
+ struct wds_softc *sc;
+{
+ int iobase = sc->sc_iobase;
+ struct wds_mbx_out *wmbo; /* Mail Box Out pointer */
+ struct wds_scb *scb;
+ int i;
+ u_char c;
+
+ wmbo = wmbx->tmbo;
+
+ while (scb = sc->sc_waiting_scb.tqh_first) {
+ if (sc->sc_mbofull >= WDS_MBX_SIZE) {
+ wds_collect_mbo(sc);
+ if (sc->sc_mbofull >= WDS_MBX_SIZE) {
+ c = WDSC_IRQMFREE;
+ wds_cmd(iobase, &c, sizeof c);
+ break;
+ }
+ }
+
+ TAILQ_REMOVE(&sc->sc_waiting_scb, scb, chain);
+#ifdef WDSDIAG
+ scb->flags |= SCB_SENDING;
+#endif
+
+ /* Link scb to mbo. */
+ if (scb->flags & SCB_SENSE)
+ ltophys(KVTOPHYS(&scb->sense), wmbo->scb_addr);
+ else
+ ltophys(KVTOPHYS(&scb->cmd), wmbo->scb_addr);
+ /* XXX What about aborts? */
+ wmbo->cmd = WDS_MBO_START;
+
+ /* Tell the card to poll immediately. */
+ c = WDSC_MSTART(wmbo - wmbx->mbo);
+ wds_cmd(sc->sc_iobase, &c, sizeof c);
+
+ if ((scb->flags & SCB_POLLED) == 0)
+ timeout(wds_timeout, scb, (scb->timeout * hz) / 1000);
+
+ next:
+ ++sc->sc_mbofull;
+ wds_nextmbx(wmbo, wmbx, mbo);
+ }
+
+ wmbx->tmbo = wmbo;
+}
+
+/*
+ * Process the result of a SCSI command.
+ */
+void
+wds_done(sc, scb, stat)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+ u_char stat;
+{
+ struct scsi_xfer *xs = scb->xs;
+ int i, x;
+
+ /* XXXXX */
+
+ /* Don't release the SCB if it was an internal command. */
+ if (xs == 0) {
+ scb->flags |= SCB_DONE;
+ return;
+ }
+
+ /* Sense handling. */
+ if (xs->error == XS_SENSE) {
+ bcopy(&scb->sense_data, &xs->sense, sizeof (struct scsi_sense_data));
+ } else {
+ if (xs->error == XS_NOERROR) {
+ /* If all went well, or an error is acceptable. */
+ if (stat == WDS_MBI_OK) {
+ /* OK, set the result */
+ xs->resid = 0;
+ } else {
+ /* Check the mailbox status. */
+ switch (stat) {
+ case WDS_MBI_OKERR:
+ /* SCSI error recorded in scb, counts as WDS_MBI_OK */
+ switch (scb->cmd.venderr) {
+ case 0x00:
+ printf("%s: Is this an error?\n", sc->sc_dev.dv_xname);
+ xs->error = XS_DRIVER_STUFFUP; /* Experiment */
+ break;
+ case 0x01:
+ /*printf("%s: OK, see SCSI error field.\n", sc->sc_dev.dv_xname);*/
+ if (scb->cmd.stat == SCSI_CHECK) {
+ /* Do sense. */
+ wds_sense (sc, scb);
+ return;
+ } else if (scb->cmd.stat == SCSI_BUSY) {
+ xs->error = XS_BUSY;
+ }
+ break;
+ case 0x40:
+ /*printf("%s: DMA underrun!\n", sc->sc_dev.dv_xname);*/
+ /* Hits this if the target returns fewer that datalen bytes (eg my CD-ROM,
+ which returns a short version string, or if DMA is turned off etc. */
+ xs->resid = 0;
+ break;
+ default:
+ printf("%s: VENDOR ERROR %02x, scsi %02x\n", sc->sc_dev.dv_xname, scb->cmd.venderr, scb->cmd.stat);
+ xs->error = XS_DRIVER_STUFFUP; /* Experiment */
+ break;
+ }
+ break;
+ case WDS_MBI_ETIME:
+ /*
+ * The documentation isn't clear on
+ * what conditions might generate this,
+ * but selection timeouts are the only
+ * one I can think of.
+ */
+ xs->error = XS_SELTIMEOUT;
+ break;
+ case WDS_MBI_ERESET:
+ case WDS_MBI_ETARCMD:
+ case WDS_MBI_ERESEL:
+ case WDS_MBI_ESEL:
+ case WDS_MBI_EABORT:
+ case WDS_MBI_ESRESET:
+ case WDS_MBI_EHRESET:
+ xs->error = XS_DRIVER_STUFFUP;
+ break;
+ }
+ }
+ } /* else sense */
+
+ if (NEEDBUFFER(sc) && xs->datalen) {
+ if (xs->flags & SCSI_DATA_IN)
+ bcopy(scb->buf->data, xs->data, xs->datalen);
+ }
+ } /* XS_NOERROR */
+
+ wds_free_scb(sc, scb);
+ xs->flags |= ITSDONE;
+ scsi_done(xs);
+}
+
+int
+wds_find(ia, sc)
+ struct isa_attach_args *ia;
+ struct wds_softc *sc;
+{
+ int iobase = ia->ia_iobase;
+ u_char c;
+ int i;
+
+ /* XXXXX */
+
+ /*
+ * Sending a command causes the CMDRDY bit to clear.
+ */
+ c = inb(iobase + WDS_STAT);
+ for (i = 0; i < 4; i++)
+ if ((inb(iobase+WDS_STAT) & WDSS_RDY) != 0) {
+ goto ready;
+ delay(10);
+ }
+ return 1;
+
+ready:
+ outb(iobase + WDS_CMD, WDSC_NOOP);
+ if (inb(iobase + WDS_STAT) & WDSS_RDY)
+ return 1;
+
+ outb(iobase + WDS_HCR, WDSH_SCSIRESET|WDSH_ASCRESET);
+ delay(10000);
+ outb(iobase + WDS_HCR, 0x00);
+ delay(500000);
+ wds_wait(iobase + WDS_STAT, WDSS_RDY, WDSS_RDY);
+ if (inb(iobase + WDS_IRQSTAT) != 1)
+ if (inb(iobase + WDS_IRQSTAT) != 7)
+ printf("%s: failed reset!!! %2x\n", sc->sc_dev.dv_xname, inb(iobase + WDS_IRQSTAT));
+
+ if ((inb(iobase + WDS_STAT) & (WDSS_RDY)) != WDSS_RDY) {
+ printf("%s: waiting for controller to become ready.", sc->sc_dev.dv_xname);
+ for (i = 0; i < 20; i++) {
+ if ((inb(iobase + WDS_STAT) & (WDSS_RDY)) == WDSS_RDY)
+ break;
+ printf(".");
+ delay(10000);
+ }
+ if ((inb(iobase + WDS_STAT) & (WDSS_RDY)) != WDSS_RDY) {
+ printf(" failed\n");
+ return 1;
+ }
+ printf("\n");
+ }
+
+ if (sc != NULL) {
+ /* XXX Can we do this better? */
+ /* who are we on the scsi bus? */
+ sc->sc_scsi_dev = 7;
+
+ sc->sc_iobase = iobase;
+ sc->sc_irq = ia->ia_irq;
+ sc->sc_drq = ia->ia_drq;
+ }
+
+ return 0;
+}
+
+/*
+ * Initialise the board and driver.
+ */
+void
+wds_init(sc)
+ struct wds_softc *sc;
+{
+ int iobase = sc->sc_iobase;
+ struct wds_setup init;
+ u_char c;
+ int i;
+
+ /*
+ * Set up initial mail box for round-robin operation.
+ */
+ for (i = 0; i < WDS_MBX_SIZE; i++) {
+ wmbx->mbo[i].cmd = WDS_MBO_FREE;
+ wmbx->mbi[i].stat = WDS_MBO_FREE;
+ }
+ wmbx->cmbo = wmbx->tmbo = &wmbx->mbo[0];
+ wmbx->tmbi = &wmbx->mbi[0];
+ sc->sc_mbofull = 0;
+
+ /* Clear the buffers. */
+ TAILQ_INIT(&wds_free_buffer);
+ for (i = 0; i < BUFCNT; i++) {
+ wds_buffer[i].busy = 0;
+ TAILQ_INSERT_HEAD(&wds_free_buffer, &wds_buffer[i], chain);
+ }
+
+ init.opcode = WDSC_INIT;
+ init.scsi_id = sc->sc_scsi_dev;
+ /* Record scsi id of controller for use in scsi_attach */
+ sc->sc_scsi_dev = init.scsi_id;
+ init.buson_t = 48;
+ init.busoff_t = 24;
+ init.xx = 0;
+ ltophys(KVTOPHYS(wmbx), init.mbaddr);
+ init.nomb = init.nimb = WDS_MBX_SIZE;
+ wds_cmd(iobase, (u_char *)&init, sizeof init);
+
+ wds_wait(iobase + WDS_STAT, WDSS_INIT, WDSS_INIT);
+
+ c = WDSC_DISUNSOL;
+ wds_cmd(iobase, &c, sizeof c);
+
+ outb(iobase + WDS_HCR, WDSH_DRQEN);
+}
+
+/*
+ * Read the board's firmware revision information.
+ */
+void
+wds_inquire_setup_information(sc)
+ struct wds_softc *sc;
+{
+ struct wds_scb *scb;
+ int iobase;
+ u_char *j;
+ int s;
+
+ iobase = sc->sc_iobase;
+
+ if ((scb = wds_get_scb(sc, SCSI_NOSLEEP, 0)) == NULL) {
+ printf("%s: no request slot available in getvers()!\n", sc->sc_dev.dv_xname);
+ return;
+ }
+ scb->xs = NULL;
+ scb->timeout = 40;
+
+ bzero(&scb->cmd, sizeof scb->cmd);
+ scb->cmd.write = 0x80;
+ scb->cmd.opcode = WDSX_GETFIRMREV;
+
+ /* Will poll card, await result. */
+ outb(iobase + WDS_HCR, WDSH_DRQEN);
+ scb->flags |= SCB_POLLED;
+
+ s = splbio();
+ wds_queue_scb(sc, scb);
+ splx(s);
+
+ if (wds_ipoll(sc, scb, scb->timeout))
+ goto out;
+
+ /* Print the version number. */
+ printf(": version %x.%02x ", scb->cmd.targ, scb->cmd.scb.opcode);
+ sc->sc_revision = (scb->cmd.targ << 8) | scb->cmd.scb.opcode;
+ /* Print out the version string. */
+ j = 2 + &(scb->cmd.targ);
+ while ((*j >= 32) && (*j < 128)) {
+ printf("%c", *j);
+ j++;
+ }
+
+out:
+ printf("\n");
+ wds_free_scb(sc, scb);
+}
+
+void
+wdsminphys(bp)
+ struct buf *bp;
+{
+
+ if (bp->b_bcount > ((WDS_NSEG - 1) << PGSHIFT))
+ bp->b_bcount = ((WDS_NSEG - 1) << PGSHIFT);
+ minphys(bp);
+}
+
+/*
+ * Send a SCSI command.
+ */
+int
+wds_scsi_cmd(xs)
+ struct scsi_xfer *xs;
+{
+ struct scsi_link *sc_link = xs->sc_link;
+ struct wds_softc *sc = sc_link->adapter_softc;
+ struct wds_scb *scb;
+ struct wds_scat_gath *sg;
+ int seg;
+ u_long thiskv, thisphys, nextphys;
+ int bytes_this_seg, bytes_this_page, datalen, flags;
+ struct iovec *iovp;
+ int s;
+
+ int iobase;
+
+ iobase = sc->sc_iobase;
+
+ if (xs->flags & SCSI_RESET) {
+ /* XXX Fix me! */
+ printf("%s: reset!\n", sc->sc_dev.dv_xname);
+ wds_init(sc);
+ return COMPLETE;
+ }
+
+ flags = xs->flags;
+ if ((scb = wds_get_scb(sc, flags, NEEDBUFFER(sc))) == NULL) {
+ xs->error = XS_DRIVER_STUFFUP;
+ return TRY_AGAIN_LATER;
+ }
+ scb->xs = xs;
+ scb->timeout = xs->timeout;
+
+ if (xs->flags & SCSI_DATA_UIO) {
+ /* XXX Fix me! */
+ /* Let's not worry about UIO. There isn't any code for the *
+ * non-SG boards anyway! */
+ printf("%s: UIO is untested and disabled!\n", sc->sc_dev.dv_xname);
+ goto bad;
+ }
+
+ /* Zero out the command structure. */
+ bzero(&scb->cmd, sizeof scb->cmd);
+ bcopy(xs->cmd, &scb->cmd.scb, xs->cmdlen < 12 ? xs->cmdlen : 12);
+
+ /* Set up some of the command fields. */
+ scb->cmd.targ = (xs->sc_link->target << 5) | xs->sc_link->lun;
+
+ /* NOTE: cmd.write may be OK as 0x40 (disable direction checking)
+ * on boards other than the WD-7000V-ASE. Need this for the ASE:
+ */
+ scb->cmd.write = (xs->flags & SCSI_DATA_IN) ? 0x80 : 0x00;
+
+ if (!NEEDBUFFER(sc) && xs->datalen) {
+ sg = scb->scat_gath;
+ seg = 0;
+#ifdef TFS
+ if (flags & SCSI_DATA_UIO) {
+ iovp = ((struct uio *)xs->data)->uio_iov;
+ datalen = ((struct uio *)xs->data)->uio_iovcnt;
+ xs->datalen = 0;
+ while (datalen && seg < WDS_NSEG) {
+ ltophys(iovp->iov_base, sg->seg_addr);
+ ltophys(iovp->iov_len, sg->seg_len);
+ xs->datalen += iovp->iov_len;
+ SC_DEBUGN(sc_link, SDEV_DB4, ("UIO(0x%x@0x%x)",
+ iovp->iov_len, iovp->iov_base));
+ sg++;
+ iovp++;
+ seg++;
+ datalen--;
+ }
+ } else
+#endif /* TFS */
+ {
+ /*
+ * Set up the scatter-gather block.
+ */
+ SC_DEBUG(sc_link, SDEV_DB4,
+ ("%d @0x%x:- ", xs->datalen, xs->data));
+
+ datalen = xs->datalen;
+ thiskv = (int)xs->data;
+ thisphys = KVTOPHYS(xs->data);
+
+ while (datalen && seg < WDS_NSEG) {
+ bytes_this_seg = 0;
+
+ /* put in the base address */
+ ltophys(thisphys, sg->seg_addr);
+
+ SC_DEBUGN(sc_link, SDEV_DB4, ("0x%x", thisphys));
+
+ /* do it at least once */
+ nextphys = thisphys;
+ while (datalen && thisphys == nextphys) {
+ /*
+ * This page is contiguous (physically)
+ * with the the last, just extend the
+ * length
+ */
+ /* check it fits on the ISA bus */
+ if (thisphys > 0xFFFFFF) {
+ printf("%s: DMA beyond"
+ " end of ISA\n",
+ sc->sc_dev.dv_xname);
+ goto bad;
+ }
+ /* how far to the end of the page */
+ nextphys = (thisphys & ~PGOFSET) + NBPG;
+ bytes_this_page = nextphys - thisphys;
+ /**** or the data ****/
+ bytes_this_page = min(bytes_this_page,
+ datalen);
+ bytes_this_seg += bytes_this_page;
+ datalen -= bytes_this_page;
+
+ /* get more ready for the next page */
+ thiskv = (thiskv & ~PGOFSET) + NBPG;
+ if (datalen)
+ thisphys = KVTOPHYS(thiskv);
+ }
+ /*
+ * next page isn't contiguous, finish the seg
+ */
+ SC_DEBUGN(sc_link, SDEV_DB4,
+ ("(0x%x)", bytes_this_seg));
+ ltophys(bytes_this_seg, sg->seg_len);
+ sg++;
+ seg++;
+ }
+ }
+ /* end of iov/kv decision */
+ SC_DEBUGN(sc_link, SDEV_DB4, ("\n"));
+ if (datalen) {
+ /*
+ * there's still data, must have run out of segs!
+ */
+ printf("%s: wds_scsi_cmd, more than %d dma segs\n",
+ sc->sc_dev.dv_xname, WDS_NSEG);
+ goto bad;
+ }
+ scb->cmd.opcode = WDSX_SCSISG;
+ ltophys(KVTOPHYS(scb->scat_gath), scb->cmd.data);
+ ltophys(seg * sizeof(struct wds_scat_gath), scb->cmd.len);
+ } else if (xs->datalen > 0) {
+ /* The board is an ASC or ASE. Do not use scatter/gather. */
+ if (xs->datalen > BUFLEN) {
+ printf("%s: wds_scsi_cmd, I/O too large for bounce buffer\n",
+ sc->sc_dev.dv_xname);
+ goto bad;
+ }
+ if (xs->flags & SCSI_DATA_OUT)
+ bcopy(xs->data, scb->buf->data, xs->datalen);
+ else
+ bzero(scb->buf->data, xs->datalen);
+ scb->cmd.opcode = WDSX_SCSICMD;
+ ltophys(KVTOPHYS(scb->buf->data), scb->cmd.data);
+ ltophys(xs->datalen, scb->cmd.len);
+ } else {
+ scb->cmd.opcode = WDSX_SCSICMD;
+ ltophys(0, scb->cmd.data);
+ ltophys(0, scb->cmd.len);
+ }
+
+ scb->cmd.stat = 0x00;
+ scb->cmd.venderr = 0x00;
+ ltophys(0, scb->cmd.link);
+
+ /* XXX Do we really want to do this? */
+ if (flags & SCSI_POLL) {
+ /* Will poll card, await result. */
+ outb(iobase + WDS_HCR, WDSH_DRQEN);
+ scb->flags |= SCB_POLLED;
+ } else {
+ /* Will send command, let interrupt routine handle result. */
+ outb(iobase + WDS_HCR, WDSH_IRQEN | WDSH_DRQEN);
+ }
+
+ s = splbio();
+ wds_queue_scb(sc, scb);
+ splx(s);
+
+ if ((flags & SCSI_POLL) == 0)
+ return SUCCESSFULLY_QUEUED;
+
+ if (wds_poll(sc, xs, scb->timeout)) {
+ wds_timeout(scb);
+ if (wds_poll(sc, xs, scb->timeout))
+ wds_timeout(scb);
+ }
+ return COMPLETE;
+
+bad:
+ xs->error = XS_DRIVER_STUFFUP;
+ wds_free_scb(sc, scb);
+ return COMPLETE;
+}
+
+/*
+ * Send a sense request.
+ */
+void
+wds_sense(sc, scb)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+{
+ struct scsi_xfer *xs = scb->xs;
+ struct scsi_sense *ss = (void *)&scb->sense.scb;
+ int s;
+ u_char c;
+ int i;
+
+ /* XXXXX */
+
+ /* Send sense request SCSI command. */
+ xs->error = XS_SENSE;
+ scb->flags |= SCB_SENSE;
+
+ /* First, save the return values */
+ if (NEEDBUFFER(sc) && xs->datalen) {
+ if (xs->flags & SCSI_DATA_IN)
+ bcopy(scb->buf->data, xs->data, xs->datalen);
+ }
+
+ /* Next, setup a request sense command block */
+ bzero(ss, sizeof(*ss));
+ ss->opcode = REQUEST_SENSE;
+ ss->byte2 = xs->sc_link->lun << 5;
+ ss->length = sizeof(struct scsi_sense_data);
+
+ /* Set up some of the command fields. */
+ scb->sense.targ = scb->cmd.targ;
+ scb->sense.write = 0x80;
+ scb->sense.opcode = WDSX_SCSICMD;
+ ltophys(KVTOPHYS(&scb->sense_data), scb->sense.data);
+ ltophys(sizeof(struct scsi_sense_data), scb->sense.len);
+
+ s = splbio();
+ wds_queue_scb(sc, scb);
+ splx(s);
+
+ /*
+ * There's no reason for us to poll here. There are two cases:
+ * 1) If it's a polling operation, then we're called from the interrupt
+ * handler, and we return and continue polling.
+ * 2) If it's an interrupt-driven operation, then it gets completed
+ * later on when the REQUEST SENSE finishes.
+ */
+}
+
+/*
+ * Poll a particular unit, looking for a particular scb
+ */
+int
+wds_poll(sc, xs, count)
+ struct wds_softc *sc;
+ struct scsi_xfer *xs;
+ int count;
+{
+ int iobase = sc->sc_iobase;
+
+ /* timeouts are in msec, so we loop in 1000 usec cycles */
+ while (count) {
+ /*
+ * If we had interrupts enabled, would we
+ * have got an interrupt?
+ */
+ if (inb(iobase + WDS_STAT) & WDSS_IRQ)
+ wdsintr(sc);
+ if (xs->flags & ITSDONE)
+ return 0;
+ delay(1000); /* only happens in boot so ok */
+ count--;
+ }
+ return 1;
+}
+
+/*
+ * Poll a particular unit, looking for a particular scb
+ */
+int
+wds_ipoll(sc, scb, count)
+ struct wds_softc *sc;
+ struct wds_scb *scb;
+ int count;
+{
+ int iobase = sc->sc_iobase;
+
+ /* timeouts are in msec, so we loop in 1000 usec cycles */
+ while (count) {
+ /*
+ * If we had interrupts enabled, would we
+ * have got an interrupt?
+ */
+ if (inb(iobase + WDS_STAT) & WDSS_IRQ)
+ wdsintr(sc);
+ if (scb->flags & SCB_DONE)
+ return 0;
+ delay(1000); /* only happens in boot so ok */
+ count--;
+ }
+ return 1;
+}
+
+void
+wds_timeout(arg)
+ void *arg;
+{
+ struct wds_scb *scb = arg;
+ struct scsi_xfer *xs = scb->xs;
+ struct scsi_link *sc_link = xs->sc_link;
+ struct wds_softc *sc = sc_link->adapter_softc;
+ int s;
+
+ sc_print_addr(sc_link);
+ printf("timed out");
+
+ s = splbio();
+
+#ifdef WDSDIAG
+ /*
+ * If The scb's mbx is not free, then the board has gone south?
+ */
+ wds_collect_mbo(sc);
+ if (scb->flags & SCB_SENDING) {
+ printf("%s: not taking commands!\n", sc->sc_dev.dv_xname);
+ Debugger();
+ }
+#endif
+
+ /*
+ * If it has been through before, then
+ * a previous abort has failed, don't
+ * try abort again
+ */
+ if (scb->flags & SCB_ABORT) {
+ /* abort timed out */
+ printf(" AGAIN\n");
+ /* XXX Must reset! */
+ } else {
+ /* abort the operation that has timed out */
+ printf("\n");
+ scb->xs->error = XS_TIMEOUT;
+ scb->timeout = WDS_ABORT_TIMEOUT;
+ scb->flags |= SCB_ABORT;
+ wds_queue_scb(sc, scb);
+ }
+
+ splx(s);
+}
--- /dev/null
+typedef u_char physaddr[3];
+typedef u_char physlen[3];
+#define ltophys _lto3b
+#define phystol _3btol
+
+/* WD7000 registers */
+#define WDS_STAT 0 /* read */
+#define WDS_IRQSTAT 1 /* read */
+
+#define WDS_CMD 0 /* write */
+#define WDS_IRQACK 1 /* write */
+#define WDS_HCR 2 /* write */
+
+/* WDS_STAT (read) defs */
+#define WDSS_IRQ 0x80
+#define WDSS_RDY 0x40
+#define WDSS_REJ 0x20
+#define WDSS_INIT 0x10
+
+/* WDS_IRQSTAT (read) defs */
+#define WDSI_MASK 0xc0
+#define WDSI_ERR 0x00
+#define WDSI_MFREE 0x80
+#define WDSI_MSVC 0xc0
+
+/* WDS_CMD (write) defs */
+#define WDSC_NOOP 0x00
+#define WDSC_INIT 0x01
+#define WDSC_DISUNSOL 0x02
+#define WDSC_ENAUNSOL 0x03
+#define WDSC_IRQMFREE 0x04
+#define WDSC_SCSIRESETSOFT 0x05
+#define WDSC_SCSIRESETHARD 0x06
+#define WDSC_MSTART(m) (0x80 + (m))
+#define WDSC_MMSTART(m) (0xc0 + (m))
+
+/* WDS_HCR (write) defs */
+#define WDSH_IRQEN 0x08
+#define WDSH_DRQEN 0x04
+#define WDSH_SCSIRESET 0x02
+#define WDSH_ASCRESET 0x01
+
+#define WDS_NSEG 17
+
+struct wds_scat_gath {
+ physlen seg_len;
+ physaddr seg_addr;
+};
+
+struct wds_cmd {
+ u_char opcode;
+ u_char targ;
+ struct scsi_generic scb;
+ u_char stat;
+ u_char venderr;
+ physlen len;
+ physaddr data;
+ physaddr link;
+ u_char write;
+ u_char xx[6];
+};
+
+struct wds_scb {
+ struct wds_cmd cmd;
+ struct wds_cmd sense;
+
+ struct wds_scat_gath scat_gath[WDS_NSEG];
+ struct scsi_sense_data sense_data;
+
+ TAILQ_ENTRY(wds_scb) chain;
+ struct wds_scb *nexthash;
+ long hashkey;
+ struct scsi_xfer *xs;
+ int flags;
+#define SCB_ALLOC 0x01
+#define SCB_ABORT 0x02
+#ifdef WDSDIAG
+#define SCB_SENDING 0x04
+#endif
+#define SCB_POLLED 0x08
+#define SCB_SENSE 0x10
+#define SCB_DONE 0x20 /* for internal commands only */
+#define SCB_BUFFER 0x40
+ int timeout;
+
+ struct wds_buf *buf;
+};
+
+#define WDSX_SCSICMD 0x00
+#define WDSX_SCSISG 0x01
+#define WDSX_OPEN_RCVBUF 0x80
+#define WDSX_RCV_CMD 0x81
+#define WDSX_RCV_DATA 0x82
+#define WDSX_RCV_DATASTAT 0x83
+#define WDSX_SND_DATA 0x84
+#define WDSX_SND_DATASTAT 0x85
+#define WDSX_SND_CMDSTAT 0x86
+#define WDSX_READINIT 0x88
+#define WDSX_READSCSIID 0x89
+#define WDSX_SETUNSOLIRQMASK 0x8a
+#define WDSX_GETUNSOLIRQMASK 0x8b
+#define WDSX_GETFIRMREV 0x8c
+#define WDSX_EXECDIAG 0x8d
+#define WDSX_SETEXECPARM 0x8e
+#define WDSX_GETEXECPARM 0x8f
+
+struct wds_mbx_out {
+ u_char cmd;
+ physaddr scb_addr;
+};
+
+struct wds_mbx_in {
+ u_char stat;
+ physaddr scb_addr;
+};
+
+/*
+ * mbo.cmd values
+ */
+#define WDS_MBO_FREE 0x0 /* MBO entry is free */
+#define WDS_MBO_START 0x1 /* MBO activate entry */
+
+/*
+ * mbi.stat values
+ */
+#define WDS_MBI_FREE 0x00 /* MBI entry is free */
+#define WDS_MBI_OK 0x01 /* completed without error */
+#define WDS_MBI_OKERR 0x02 /* completed with error */
+#define WDS_MBI_ETIME 0x04
+#define WDS_MBI_ERESET 0x05
+#define WDS_MBI_ETARCMD 0x06
+#define WDS_MBI_ERESEL 0x80
+#define WDS_MBI_ESEL 0x81
+#define WDS_MBI_EABORT 0x82
+#define WDS_MBI_ESRESET 0x83
+#define WDS_MBI_EHRESET 0x84
+
+struct wds_setup {
+ u_char opcode;
+ u_char scsi_id;
+ u_char buson_t;
+ u_char busoff_t;
+ u_char xx;
+ physaddr mbaddr;
+ u_char nomb;
+ u_char nimb;
+};
-/* $OpenBSD: wss.c,v 1.7 1996/03/20 01:01:06 mickey Exp $ */
-/* $NetBSD: wss.c,v 1.9 1996/02/16 08:18:36 mycroft Exp $ */
+/* $OpenBSD: wss.c,v 1.8 1996/04/21 22:24:49 deraadt Exp $ */
+/* $NetBSD: wss.c,v 1.11 1996/04/11 22:30:46 cgd Exp $ */
/*
* Copyright (c) 1994 John Brezak
int wssprobe __P((struct device *, void *, void *));
void wssattach __P((struct device *, struct device *, void *));
-struct cfdriver wsscd = {
- NULL, "wss", wssprobe, wssattach, DV_DULL, sizeof(struct wss_softc)
+struct cfattach wss_ca = {
+ sizeof(struct wss_softc), wssprobe, wssattach
+};
+
+struct cfdriver wss_cd = {
+ NULL, "wss", DV_DULL
};
/*
#ifdef NEWCONFIG
isa_establish(&sc->sc_id, &sc->sc_dev);
#endif
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_AUDIO, ad1848_intr,
- &sc->sc_ad1848, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, IPL_AUDIO,
+ ad1848_intr, &sc->sc_ad1848, sc->sc_dev.dv_xname);
ad1848_attach(&sc->sc_ad1848);
struct wss_softc *sc;
int unit = AUDIOUNIT(dev);
- if (unit >= wsscd.cd_ndevs)
+ if (unit >= wss_cd.cd_ndevs)
return ENODEV;
- sc = wsscd.cd_devs[unit];
+ sc = wss_cd.cd_devs[unit];
if (!sc)
return ENXIO;
-/* $OpenBSD: wt.c,v 1.7 1996/04/18 23:47:52 niklas Exp $ */
-/* $NetBSD: wt.c,v 1.29 1996/03/01 04:08:40 mycroft Exp $ */
+/* $OpenBSD: wt.c,v 1.8 1996/04/21 22:24:52 deraadt Exp $ */
+/* $NetBSD: wt.c,v 1.31 1996/04/11 22:30:49 cgd Exp $ */
/*
* Streamer tape driver.
void wtattach __P((struct device *, struct device *, void *));
int wtintr __P((void *sc));
-struct cfdriver wtcd = {
- NULL, "wt", wtprobe, wtattach, DV_TAPE, sizeof(struct wt_softc)
+struct cfattach wt_ca = {
+ sizeof(struct wt_softc), wtprobe, wtattach
+};
+
+struct cfdriver wt_cd = {
+ NULL, "wt", DV_TAPE
};
/*
sc->flags = TPSTART; /* tape is rewound */
sc->dens = -1; /* unknown density */
- sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, wtintr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
+ IPL_BIO, wtintr, sc, sc->sc_dev.dv_xname);
}
int
struct wt_softc *sc;
int error;
- if (unit >= wtcd.cd_ndevs)
+ if (unit >= wt_cd.cd_ndevs)
return ENXIO;
- sc = wtcd.cd_devs[unit];
+ sc = wt_cd.cd_devs[unit];
if (!sc)
return ENXIO;
dev_t dev;
{
int unit = minor(dev) & T_UNIT;
- struct wt_softc *sc = wtcd.cd_devs[unit];
+ struct wt_softc *sc = wt_cd.cd_devs[unit];
/* If rewind is pending, do nothing */
if (sc->flags & TPREW)
int flag;
{
int unit = minor(dev) & T_UNIT;
- struct wt_softc *sc = wtcd.cd_devs[unit];
+ struct wt_softc *sc = wt_cd.cd_devs[unit];
int error, count, op;
switch (cmd) {
struct buf *bp;
{
int unit = minor(bp->b_dev) & T_UNIT;
- struct wt_softc *sc = wtcd.cd_devs[unit];
+ struct wt_softc *sc = wt_cd.cd_devs[unit];
int s;
bp->b_resid = bp->b_bcount;
-/* $NetBSD: aic7870.c,v 1.7 1996/03/04 19:30:50 cgd Exp $ */
+/* $NetBSD: aic7870.c,v 1.8 1996/03/17 00:55:23 thorpej Exp $ */
/*
* Product specific probe and attach routines for:
static int aic7870_probe __P((struct device *, void *, void *));
static void aic7870_attach __P((struct device *, struct device *, void *));
-struct cfdriver ahccd = {
- NULL, "ahc", aic7870_probe, aic7870_attach, DV_DULL,
- sizeof(struct ahc_softc)
+struct cfattach ahc_ca = {
+ sizeof(struct ahc_softc), aic7870_probe, aic7870_attach
+};
+
+struct cfdriver ahc_cd = {
+ NULL, "ahc", DV_DULL
};
int ahcintr __P((void *));
ahcattach(ahc);
- ahc->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ahcintr, ahc,
- ahc->sc_dev.dv_xname);
+ ahc->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ahcintr, ahc);
}
-# $OpenBSD: files.pci,v 1.3 1996/04/18 23:47:55 niklas Exp $
-# $NetBSD: files.pci,v 1.12 1996/03/04 03:29:19 cgd Exp $
+# $OpenBSD: files.pci,v 1.4 1996/04/21 22:25:06 deraadt Exp $
+# $NetBSD: files.pci,v 1.13 1996/03/17 00:55:24 thorpej Exp $
#
-# Config file and device description for machine-independent PCI code.
+# Config.new file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
# defined first.
-device pci at pcibus {[dev = -1], [function = -1]}
+device pci {[dev = -1], [function = -1]}
+attach pci at pcibus
file dev/pci/pci.c pci needs-flag
file dev/pci/pci_subr.c pci
# Adaptec 7870 chips
-device ahc at pci: scsi, aic7xxx
+device ahc: scsi, aic7xxx
+attach ahc at pci
file dev/pci/aic7870.c ahc
# Ethernet driver for DC21040-based boards
-device de at pci: ether, ifnet
+device de: ether, ifnet
+attach de at pci
file dev/pci/if_de.c de
# Digital DEFPA PCI FDDI Controller
-device fpa at pci: pdq, fddi, ifnet
+device fpa: pdq, fddi, ifnet
+attach fpa at pci
file dev/pci/if_fpa.c fpa
# NCR 53c8xx SCSI chips
-device ncr at pci: scsi
+device ncr: scsi
+attach ncr at pci
file dev/pci/ncr.c ncr
# PCI-PCI bridge chips
-device ppb at pci: pcibus
+device ppb: pcibus
+attach ppb at pci
file dev/pci/ppb.c ppb
-/* $OpenBSD: if_de.c,v 1.5 1996/04/18 23:47:56 niklas Exp $ */
-/* $NetBSD: if_de.c,v 1.13 1996/03/14 03:04:17 cgd Exp $ */
+/* $OpenBSD: if_de.c,v 1.6 1996/04/21 22:25:13 deraadt Exp $ */
+/* $NetBSD: if_de.c,v 1.17 1996/04/01 19:37:54 cgd Exp $ */
/*-
* Copyright (c) 1994, 1995 Matt Thomas (matt@lkg.dec.com)
#if defined(__NetBSD__)
#include <machine/bus.h>
+#ifdef __alpha__
+#include <machine/intr.h>
+#endif
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/ic/dc21040reg.h>
-#ifdef __i386__ /* XXX -- fix later -- cgd */
-#include <i386/isa/isa_machdep.h>
-#endif
#endif /* __NetBSD__ */
/*
} tulip_ringinfo_t;
#ifdef TULIP_IOMAPPED
-#ifndef __NetBSD__
-#else
-#endif
#define TULIP_EISA_CSRSIZE 16
#define TULIP_PCI_CSRSIZE 8
struct device tulip_dev; /* base device */
void *tulip_ih; /* intrrupt vectoring */
void *tulip_ats; /* shutdown hook */
- bus_chipset_tag_t tulip_bc; /* bus chipset tag */
+ bus_chipset_tag_t tulip_bc;
+ pci_chipset_tag_t tulip_pc;
#ifdef TULIP_IOMAPPED
bus_io_handle_t tulip_ioh; /* I/O region handle */
#else
#if defined(__NetBSD__)
typedef void ifnet_ret_t;
typedef u_long ioctl_cmd_t;
-extern struct cfdriver decd;
-#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit])
+extern struct cfattach de_ca;
+extern struct cfdriver de_cd;
+#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) de_cd.cd_devs[unit])
#endif
#ifndef TULIP_BURSTSIZE
static void tulip_rx_intr(tulip_softc_t *sc);
static void tulip_addr_filter(tulip_softc_t *sc);
+#if defined(__NetBSD__) && defined(__alpha__)
+/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
+#define vtophys(va) (vtophys(va) | 0x40000000)
+#endif
\f
static int
tulip_dc21040_media_probe(
if ((TULIP_READ_CSR(sc, csr_gp) &
(TULIP_GP_DE500_NOTOK_100|TULIP_GP_DE500_NOTOK_10)) !=
(TULIP_GP_DE500_NOTOK_100|TULIP_GP_DE500_NOTOK_10))
- return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) != 0;
+ return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) == 0;
TULIP_WRITE_CSR(sc, csr_gp,
TULIP_GP_DE500_HALFDUPLEX|TULIP_GP_DE500_FORCE_100);
TULIP_WRITE_CSR(sc, csr_command,
TULIP_WRITE_CSR(sc, csr_command,
TULIP_READ_CSR(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
DELAY(1000000);
- return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) != 0;
+ return (TULIP_READ_CSR(sc, csr_gp) & TULIP_GP_DE500_NOTOK_100) == 0;
}
static void
#error BIG_PACKET is incompatible with TULIP_COPY_RXDATA
#endif
if (ms == me)
- bcopy(mtod(m, caddr_t) + sizeof(struct ether_header),
+/*XXX?*/ bcopy(mtod(ms, caddr_t) + sizeof(struct ether_header),
mtod(m0, caddr_t), total_len);
else
- m_copydata(m, 0, total_len, mtod(m0, caddr_t));
+/*XXX?*/ m_copydata(ms, 0, total_len, mtod(m0, caddr_t));
m0->m_len = m0->m_pkthdr.len = total_len;
m0->m_pkthdr.rcvif = ifp;
ether_input(ifp, &eh, m0);
static void tulip_pci_attach(TULIP_PCI_ATTACH_ARGS);
-struct cfdriver decd = {
- 0, "de", tulip_pci_probe, tulip_pci_attach, DV_IFNET, sizeof(tulip_softc_t)
+struct cfattach de_ca = {
+ sizeof(tulip_softc_t), tulip_pci_probe, tulip_pci_attach
+};
+
+struct cfdriver de_cd = {
+ 0, "de", DV_IFNET
};
#endif /* __NetBSD__ */
#if defined(__NetBSD__)
tulip_softc_t * const sc = (tulip_softc_t *) self;
struct pci_attach_args * const pa = (struct pci_attach_args *) aux;
+ bus_chipset_tag_t bc = pa->pa_bc;
+ pci_chipset_tag_t pc = pa->pa_pc;
+#if defined(TULIP_IOMAPPED)
+ bus_io_addr_t iobase;
+ bus_io_size_t iosize;
+#else
+ bus_mem_addr_t membase;
+ bus_mem_size_t memsize;
+#endif
int unit = sc->tulip_dev.dv_unit;
+ const char *intrstr = NULL;
#endif
int retval, idx, revinfo, id;
-#if !defined(TULIP_IOMAPPED) && !defined(__bsdi__)
+#if !defined(TULIP_IOMAPPED) && !defined(__bsdi__) && !defined(__NetBSD__)
vm_offset_t pa_csrs;
#endif
unsigned csrsize = TULIP_PCI_CSRSIZE;
}
#endif
#if defined(__NetBSD__)
- revinfo = pci_conf_read(pa->pa_tag, PCI_CFRV) & 0xFF;
+ revinfo = pci_conf_read(pc, pa->pa_tag, PCI_CFRV) & 0xFF;
id = pa->pa_id;
#endif
#endif /* __bsdi__ */
#if defined(__NetBSD__)
- sc->tulip_bc = pa->pa_bc;
+ sc->tulip_bc = bc;
+ sc->tulip_pc = pc;
#if defined(TULIP_IOMAPPED)
- retval = pci_map_io(pa->pa_tag, PCI_CBIO, &sc->tulip_ioh);
+ retval = pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize);
+ if (!retval)
+ retval = bus_io_map(bc, iobase, iosize, &sc->tulip_ioh);
#else
- retval = pci_map_mem(pa->pa_tag, PCI_CBMA, &sc->tulip_memh, &pa_csrs);
+ retval = pci_mem_find(pc, pa->pa_tag, PCI_CBMA, &membase, &memsize,
+ NULL);
+ if (!retval)
+ retval = bus_mem_map(bc, membase, memsize, 0, &sc->tulip_memh);
#endif
csr_base = 0;
if (retval) {
bit longer anyways) */
#if defined(__NetBSD__)
if (sc->tulip_boardsw->bd_type != TULIP_DC21040_ZX314_SLAVE) {
- sc->tulip_ih = pci_map_int(pa->pa_tag, IPL_NET, tulip_intr, sc,
- sc->tulip_dev.dv_xname);
+ pci_intr_handle_t intrhandle;
+
+ if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
+ pa->pa_intrline, &intrhandle)) {
+ printf(": couldn't map interrupt\n", self->dv_xname);
+ return;
+ }
+ intrstr = pci_intr_string(pc, intrhandle);
+ sc->tulip_ih = pci_intr_establish(pc, intrhandle, IPL_NET,
+ tulip_intr, sc, self->dv_xname);
if (sc->tulip_ih == NULL) {
- printf("%s%d: couldn't map interrupt\n",
- sc->tulip_name, sc->tulip_unit);
+ printf(": couldn't establish interrupt", self->dv_xname);
+ if (intrstr != NULL)
+ printf(" at %s", intrstr);
+ printf("\n");
return;
}
-#if defined(__i386__)
- /* gross but netbsd won't print the irq otherwise */
- printf(" irq %d", ((struct intrhand *) sc->tulip_ih)->ih_irq);
-#endif
}
sc->tulip_ats = shutdownhook_establish(tulip_pci_shutdown, sc);
if (sc->tulip_ats == NULL)
- printf("%s%d: warning: couldn't establish shutdown hook\n",
+ printf("\n%s%d: warning: couldn't establish shutdown hook",
sc->tulip_name, sc->tulip_unit);
#endif
#if defined(__FreeBSD__)
#endif
tulip_reset(sc);
tulip_attach(sc);
+#if defined(__NetBSD__)
+ if (intrstr != NULL)
+ printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
+#endif
}
}
#endif /* NDE > 0 */
-/* $OpenBSD: if_fpa.c,v 1.4 1996/04/18 23:47:58 niklas Exp $ */
+/* $OpenBSD: if_fpa.c,v 1.5 1996/04/21 22:25:19 deraadt Exp $ */
/* $NetBSD: if_fpa.c,v 1.7 1996/03/17 00:55:30 thorpej Exp $ */
/*-
sc->sc_ih.ih_fun = pdq_pci_ifintr;
sc->sc_ih.ih_arg = (void *)sc;
- intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET);
+ intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET, sc->sc_dv.dv_xname);
sc->sc_ats.func = (void (*)(void *)) pdq_hwreset;
sc->sc_ats.arg = (void *) sc->sc_pdq;
-/* $OpenBSD: ncr.c,v 1.6 1996/04/18 23:47:59 niklas Exp $ */
-/* $NetBSD: ncr.c,v 1.29 1996/03/14 05:21:20 cgd Exp $ */
+/* $OpenBSD: ncr.c,v 1.7 1996/04/21 22:25:22 deraadt Exp $ */
+/* $NetBSD: ncr.c,v 1.33 1996/04/03 08:44:15 mycroft Exp $ */
/**************************************************************************
**
#else
#include <sys/device.h>
#include <machine/bus.h>
+#ifdef __alpha__
+#include <machine/intr.h>
+#endif
#include <dev/pci/ncr_reg.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#ifndef __alpha__
#define DELAY(x) delay(x)
+#endif
#endif /* __NetBSD__ */
#include <scsi/scsi_all.h>
#include <machine/clock.h>
#endif /* __NetBSD__ */
+#if defined(__NetBSD__) && defined(__alpha__)
+/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
+#define vtophys(va) (vtophys(va) | 0x40000000)
+#endif
/*==========================================================
**
struct device sc_dev;
void *sc_ih;
bus_chipset_tag_t sc_bc;
+ pci_chipset_tag_t sc_pc;
#ifdef NCR_IOMAPPED
bus_io_handle_t sc_ioh;
#else /* !NCR_IOMAPPED */
static char ident[] =
- "\n$NetBSD: ncr.c,v 1.29 1996/03/14 05:21:20 cgd Exp $\n";
+ "\n$NetBSD: ncr.c,v 1.33 1996/04/03 08:44:15 mycroft Exp $\n";
u_long ncr_version = NCR_VERSION * 11
+ (u_long) sizeof (struct ncb) * 7
#ifdef __NetBSD__
-struct cfdriver ncrcd = {
- NULL, "ncr", ncr_probe, ncr_attach, DV_DULL, sizeof(struct ncb)
+struct cfattach ncr_ca = {
+ sizeof(struct ncb), ncr_probe, ncr_attach
+};
+
+struct cfdriver ncr_cd = {
+ NULL, "ncr", DV_DULL
};
#else /* !__NetBSD__ */
#ifdef __NetBSD__
int
-ncr_print()
+ncr_print(aux, name)
+ void *aux;
+ char *name;
{
+
+ if (name != NULL)
+ printf("%s: scsibus ", name);
+ return UNCONF;
}
void
void *aux;
{
struct pci_attach_args *pa = aux;
- int retval;
+ bus_chipset_tag_t bc = pa->pa_bc;
+ pci_chipset_tag_t pc = pa->pa_pc;
+ bus_mem_size_t memsize;
+ int retval, cacheable;
+ pci_intr_handle_t intrhandle;
+ const char *intrstr;
ncb_p np = (void *)self;
printf(": NCR ");
}
printf(" SCSI\n");
+ np->sc_bc = bc;
+ np->sc_pc = pc;
+
/*
** Try to map the controller chip to
** virtual and physical memory.
*/
- retval = pci_map_mem(pa->pa_tag, 0x14, (vm_offset_t *)&np->sc_memh,
- &np->paddr);
- if (retval)
+ retval = pci_mem_find(pc, pa->pa_tag, 0x14, &np->paddr,
+ &memsize, &cacheable);
+ if (retval) {
+ printf("%s: couldn't find memory region\n", self->dv_xname);
return;
+ }
- np->sc_ih = pci_map_int(pa->pa_tag, IPL_BIO, ncr_intr, np,
- np->sc_dev.dv_xname);
- if (np->sc_ih == NULL)
+ /* Map the memory. Note that we never want it to be cacheable. */
+ retval = bus_mem_map(pa->pa_bc, np->paddr, memsize, 0, &np->sc_memh);
+ if (retval) {
+ printf("%s: couldn't map memory region\n", self->dv_xname);
return;
+ }
+ /*
+ ** Set up the controller chip's interrupt.
+ */
+ retval = pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
+ pa->pa_intrline, &intrhandle);
+ if (retval) {
+ printf("%s: couldn't map interrupt\n", self->dv_xname);
+ return;
+ }
+ intrstr = pci_intr_string(pc, intrhandle);
+ np->sc_ih = pci_intr_establish(pc, intrhandle, IPL_BIO,
+ ncr_intr, np, self->dv_xname);
+ if (np->sc_ih == NULL) {
+ printf("%s: couldn't establish interrupt", self->dv_xname);
+ if (intrstr != NULL)
+ printf(" at %s", intrstr);
+ printf("\n");
+ return;
+ }
+ if (intrstr != NULL)
+ printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
#else /* !__NetBSD__ */
-/* $NetBSD: ncrstat.c,v 1.6 1995/01/27 05:44:31 cgd Exp $ */
+/* $NetBSD: ncrstat.c,v 1.7 1996/03/17 00:55:36 thorpej Exp $ */
/**************************************************************************
**
{ "_ncr_version" },
#ifdef __NetBSD__
#define N_NCRCD 1
- { "_ncrcd" },
+ { "_ncr_cd" },
#else
#define N_NCRP 1
{ "_ncrp" },
u_long ncr_unit;
#ifdef __NetBSD__
-struct cfdriver ncrcd;
+struct cfdriver ncr_cd;
#else
u_long ncr_units;
#endif
if (!KVM_READ (
nl[N_NCRCD].n_value,
- &ncrcd,
- sizeof (ncrcd))) {
+ &ncr_cd,
+ sizeof (ncr_cd))) {
fprintf (stderr, "%s: bad kvm read.\n", prog);
exit (1);
};
- if (ncr_unit >= ncrcd.cd_ndevs){
+ if (ncr_unit >= ncr_cd.cd_ndevs){
fprintf (stderr, "%s: bad unit number (valid range: 0-%d).\n",
- prog, ncrcd.cd_ndevs-1);
+ prog, ncr_cd.cd_ndevs-1);
exit (1);
};
if (!KVM_READ (
- ncrcd.cd_devs+4*ncr_unit,
+ ncr_cd.cd_devs+4*ncr_unit,
&ncr_base,
sizeof (ncr_base))) {
fprintf (stderr, "%s: bad kvm read.\n", prog);
-/* $OpenBSD: pci.c,v 1.1 1996/04/18 23:48:02 niklas Exp $ */
-/* $NetBSD: pci.c,v 1.15 1996/03/14 04:03:01 cgd Exp $ */
+/* $OpenBSD: pci.c,v 1.2 1996/04/21 22:25:34 deraadt Exp $ */
+/* $NetBSD: pci.c,v 1.18 1996/03/27 04:08:24 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
int pcimatch __P((struct device *, void *, void *));
void pciattach __P((struct device *, struct device *, void *));
-struct cfdriver pcicd = {
- NULL, "pci", pcimatch, pciattach, DV_DULL, sizeof(struct device)
+struct cfattach pci_ca = {
+ sizeof(struct device), pcimatch, pciattach
+};
+
+struct cfdriver pci_cd = {
+ NULL, "pci", DV_DULL
};
int pciprint __P((void *, char *));
{
struct pcibus_attach_args *pba = aux;
bus_chipset_tag_t bc;
- int device, function, nfunctions;
+ pci_chipset_tag_t pc;
+ int bus, device, maxndevs, function, nfunctions;
- pci_md_attach_hook(parent, self, pba);
+ pci_attach_hook(parent, self, pba);
printf("\n");
- for (device = 0; device < PCI_MAX_DEVICE_NUMBER; device++) {
+ bc = pba->pba_bc;
+ pc = pba->pba_pc;
+ bus = pba->pba_bus;
+ maxndevs = pci_bus_maxdevs(pc, bus);
+
+ for (device = 0; device < maxndevs; device++) {
pcitag_t tag;
- pcireg_t id, class;
+ pcireg_t id, class, intr, bhlcr;
struct pci_attach_args pa;
struct cfdata *cf;
- int supported;
+ int supported, pin;
- tag = pci_make_tag(pba->pba_bus, device, 0);
- id = pci_conf_read(tag, PCI_ID_REG);
+ tag = pci_make_tag(pc, bus, device, 0);
+ id = pci_conf_read(pc, tag, PCI_ID_REG);
if (id == 0 || id == 0xffffffff)
continue;
- nfunctions = 1; /* XXX */
+ bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
+ nfunctions = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1;
for (function = 0; function < nfunctions; function++) {
- tag = pci_make_tag(pba->pba_bus, device, function);
- id = pci_conf_read(tag, PCI_ID_REG);
+ tag = pci_make_tag(pc, bus, device, function);
+ id = pci_conf_read(pc, tag, PCI_ID_REG);
if (id == 0 || id == 0xffffffff)
continue;
- class = pci_conf_read(tag, PCI_CLASS_REG);
+ class = pci_conf_read(pc, tag, PCI_CLASS_REG);
+ intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
- pa.pa_bc = pba->pba_bc;
+ pa.pa_bc = bc;
+ pa.pa_pc = pc;
pa.pa_device = device;
pa.pa_function = function;
pa.pa_tag = tag;
pa.pa_id = id;
pa.pa_class = class;
+ if (bus == 0) {
+ pa.pa_intrswiz = 0;
+ pa.pa_intrtag = tag;
+ } else {
+ pa.pa_intrswiz = pba->pba_intrswiz + device;
+ pa.pa_intrtag = pba->pba_intrtag;
+ }
+ pin = PCI_INTERRUPT_PIN(intr);
+ if (pin == PCI_INTERRUPT_PIN_NONE) {
+ /* no interrupt */
+ pa.pa_intrpin = 0;
+ } else {
+ /*
+ * swizzle it based on the number of
+ * busses we're behind and our device
+ * number.
+ */
+ pa.pa_intrpin = /* XXX */
+ ((pin + pa.pa_intrswiz - 1) % 4) + 1;
+ }
+ pa.pa_intrline = PCI_INTERRUPT_LINE(intr);
+
config_found_sm(self, &pa, pciprint, pcisubmatch);
}
}
if (cf->pcicf_function != PCI_UNK_FUNCTION &&
cf->pcicf_function != pa->pa_function)
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
+}
+
+int
+pci_io_find(pc, pcitag, reg, iobasep, iosizep)
+ pci_chipset_tag_t pc;
+ pcitag_t pcitag;
+ int reg;
+ bus_io_addr_t *iobasep;
+ bus_io_size_t *iosizep;
+{
+ pcireg_t addrdata, sizedata;
+ int s;
+
+ if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
+ panic("pci_io_find: bad request");
+
+ /* XXX?
+ * Section 6.2.5.1, `Address Maps', tells us that:
+ *
+ * 1) The builtin software should have already mapped the device in a
+ * reasonable way.
+ *
+ * 2) A device which wants 2^n bytes of memory will hardwire the bottom
+ * n bits of the address to 0. As recommended, we write all 1s and see
+ * what we get back.
+ */
+ addrdata = pci_conf_read(pc, pcitag, reg);
+
+ s = splhigh();
+ pci_conf_write(pc, pcitag, reg, 0xffffffff);
+ sizedata = pci_conf_read(pc, pcitag, reg);
+ pci_conf_write(pc, pcitag, reg, addrdata);
+ splx(s);
+
+ if (PCI_MAPREG_TYPE(addrdata) != PCI_MAPREG_TYPE_IO)
+ panic("pci_io_find: not an I/O region");
+
+ if (iobasep != NULL)
+ *iobasep = PCI_MAPREG_IO_ADDR(addrdata);
+ if (iosizep != NULL)
+ *iosizep = ~PCI_MAPREG_IO_ADDR(sizedata) + 1;
+
+ return (0);
+}
+
+int
+pci_mem_find(pc, pcitag, reg, membasep, memsizep, cacheablep)
+ pci_chipset_tag_t pc;
+ pcitag_t pcitag;
+ int reg;
+ bus_mem_addr_t *membasep;
+ bus_mem_size_t *memsizep;
+ int *cacheablep;
+{
+ pcireg_t addrdata, sizedata;
+ int s;
+
+ if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
+ panic("pci_find_mem: bad request");
+
+ /*
+ * Section 6.2.5.1, `Address Maps', tells us that:
+ *
+ * 1) The builtin software should have already mapped the device in a
+ * reasonable way.
+ *
+ * 2) A device which wants 2^n bytes of memory will hardwire the bottom
+ * n bits of the address to 0. As recommended, we write all 1s and see
+ * what we get back.
+ */
+ addrdata = pci_conf_read(pc, pcitag, reg);
+
+ s = splhigh();
+ pci_conf_write(pc, pcitag, reg, 0xffffffff);
+ sizedata = pci_conf_read(pc, pcitag, reg);
+ pci_conf_write(pc, pcitag, reg, addrdata);
+ splx(s);
+
+ if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_IO)
+ panic("pci_find_mem: I/O region");
+
+ switch (PCI_MAPREG_MEM_TYPE(addrdata)) {
+ case PCI_MAPREG_MEM_TYPE_32BIT:
+ case PCI_MAPREG_MEM_TYPE_32BIT_1M:
+ break;
+ case PCI_MAPREG_MEM_TYPE_64BIT:
+/* XXX */ printf("pci_find_mem: 64-bit region\n");
+/* XXX */ return (1);
+ default:
+ printf("pci_find_mem: reserved region type\n");
+ return (1);
+ }
+
+ if (membasep != NULL)
+ *membasep = PCI_MAPREG_MEM_ADDR(addrdata); /* PCI addr */
+ if (memsizep != NULL)
+ *memsizep = ~PCI_MAPREG_MEM_ADDR(sizedata) + 1;
+ if (cacheablep != NULL)
+ *cacheablep = PCI_MAPREG_MEM_CACHEABLE(addrdata);
+
+ return 0;
}
-$OpenBSD: pcidevs,v 1.6 1996/04/18 23:48:04 niklas Exp $
-/* $NetBSD: pcidevs,v 1.6 1996/02/19 20:08:25 christos Exp $ */
+$OpenBSD: pcidevs,v 1.7 1996/04/21 22:25:38 deraadt Exp $
+/* $NetBSD: pcidevs,v 1.7 1996/04/04 21:46:33 mycroft Exp $ */
+
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou
product OLDNCR 820 0x0002 53c820
product OLDNCR 825 0x0003 53c825
product OLDNCR 815 0x0004 53c815
+product OLDNCR 810AP 0x0005 53c810AP
+product OLDNCR 860 0x0006 53c860
+product OLDNCR 875 0x000f 53c875
/* do the NCR chips use the new ID, as well? */
/* Number Nine products */
#define PCI_PRODUCT_OLDNCR_820 0x0002 /* 53c820 */
#define PCI_PRODUCT_OLDNCR_825 0x0003 /* 53c825 */
#define PCI_PRODUCT_OLDNCR_815 0x0004 /* 53c815 */
+#define PCI_PRODUCT_OLDNCR_810AP 0x0005 /* 53c810AP */
+#define PCI_PRODUCT_OLDNCR_860 0x0006 /* 53c860 */
+#define PCI_PRODUCT_OLDNCR_875 0x000f /* 53c875 */
/* do the NCR chips use the new ID, as well? */
/* Number Nine products */
"NCR",
"53c815",
},
+ {
+ PCI_VENDOR_OLDNCR, PCI_PRODUCT_OLDNCR_810AP,
+ 0,
+ "NCR",
+ "53c810AP",
+ },
+ {
+ PCI_VENDOR_OLDNCR, PCI_PRODUCT_OLDNCR_860,
+ 0,
+ "NCR",
+ "53c860",
+ },
+ {
+ PCI_VENDOR_OLDNCR, PCI_PRODUCT_OLDNCR_875,
+ 0,
+ "NCR",
+ "53c875",
+ },
{
PCI_VENDOR_NUMBER9, PCI_PRODUCT_NUMBER9_IMAG128,
0,
-/* $OpenBSD: pcireg.h,v 1.2 1996/04/18 23:48:07 niklas Exp $ */
-/* $NetBSD: pcireg.h,v 1.5 1996/03/04 19:30:51 cgd Exp $ */
+/* $OpenBSD: pcireg.h,v 1.3 1996/04/21 22:25:49 deraadt Exp $ */
+/* $NetBSD: pcireg.h,v 1.7 1996/03/27 04:08:27 cgd Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _DEV_PCI_PCIREG_H_
+#define _DEV_PCI_PCIREG_H_
+
/*
* Standardized PCI configuration information
*
#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05
#define PCI_SUBCLASS_BRIDGE_MISC 0x80
+/*
+ * PCI BIST/Header Type/Latency Timer/Cache Line Size Register.
+ */
+#define PCI_BHLC_REG 0x0c
+
+#define PCI_BIST_SHIFT 24
+#define PCI_BIST_MASK 0xff
+#define PCI_BIST(bhlcr) \
+ (((bhlcr) >> PCI_BIST_SHIFT) & PCI_BIST_MASK)
+
+#define PCI_HDRTYPE_SHIFT 24
+#define PCI_HDRTYPE_MASK 0xff
+#define PCI_HDRTYPE(bhlcr) \
+ (((bhlcr) >> PCI_HDRTYPE_SHIFT) & PCI_HDRTYPE_MASK)
+
+#define PCI_HDRTYPE_MULTIFN(bhlcr) \
+ ((PCI_HDRTYPE(bhlcr) & 0x80) != 0)
+
+#define PCI_LATTIMER_SHIFT 24
+#define PCI_LATTIMER_MASK 0xff
+#define PCI_LATTIMER(bhlcr) \
+ (((bhlcr) >> PCI_LATTIMER_SHIFT) & PCI_LATTIMER_MASK)
+
+#define PCI_CACHELINE_SHIFT 24
+#define PCI_CACHELINE_MASK 0xff
+#define PCI_CACHELINE(bhlcr) \
+ (((bhlcr) >> PCI_CACHELINE_SHIFT) & PCI_CACHELINE_MASK)
+
/*
* Mapping registers
*/
#define PCI_INTERRUPT_PIN_B 0x02
#define PCI_INTERRUPT_PIN_C 0x03
#define PCI_INTERRUPT_PIN_D 0x04
+
+#endif /* _DEV_PCI_PCIREG_H_ */
-/* $OpenBSD: pcivar.h,v 1.6 1996/04/18 23:48:08 niklas Exp $ */
-/* $NetBSD: pcivar.h,v 1.8 1995/06/18 01:26:50 cgd Exp $ */
+/* $OpenBSD: pcivar.h,v 1.7 1996/04/21 22:25:51 deraadt Exp $ */
+/* $NetBSD: pcivar.h,v 1.15 1996/03/28 02:16:23 cgd Exp $ */
/*
+ * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
* Copyright (c) 1994 Charles Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*
* This file describes types and functions which are used for PCI
* configuration. Some of this information is machine-specific, and is
- * separated into pci_machdep.h.
+ * provided by pci_machdep.h.
*/
#include <machine/bus.h>
+#include <dev/pci/pcireg.h>
+/*
+ * Structures and definitions needed by the machine-dependent header.
+ */
+typedef u_int32_t pcireg_t; /* configuration space register XXX */
+struct pcibus_attach_args;
+
+/*
+ * Machine-dependent definitions.
+ */
#if (alpha + i386 != 1)
ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
#endif
-
#if alpha
#include <alpha/pci/pci_machdep.h>
#endif
-
#if i386
#include <i386/pci/pci_machdep.h>
#endif
-/*
- * The maximum number of devices on a PCI bus is 32. However, some
- * PCI chipsets (e.g. chipsets that implement 'Configuration Mechanism #2'
- * on the i386) can't deal with that many, so let pci_machdep.h override it.
- */
-#ifndef PCI_MAX_DEVICE_NUMBER
-#define PCI_MAX_DEVICE_NUMBER 32
-#endif
-
/*
* PCI bus attach arguments.
*/
struct pcibus_attach_args {
char *pba_busname; /* XXX should be common */
bus_chipset_tag_t pba_bc; /* XXX should be common */
+ pci_chipset_tag_t pba_pc;
int pba_bus; /* PCI bus number */
+
+ /*
+ * Interrupt swizzling information. These fields
+ * are only used by secondary busses.
+ */
+ u_int pba_intrswiz; /* how to swizzle pins */
+ pcitag_t pba_intrtag; /* intr. appears to come from here */
};
/*
* PCI device attach arguments.
*/
struct pci_attach_args {
- bus_chipset_tag_t pa_bc; /* bus chipset tag */
+ bus_chipset_tag_t pa_bc;
+ pci_chipset_tag_t pa_pc;
- int pa_device;
- int pa_function;
+ u_int pa_device;
+ u_int pa_function;
pcitag_t pa_tag;
pcireg_t pa_id, pa_class;
+
+ /*
+ * Interrupt information.
+ *
+ * "Intrline" is used on systems whose firmware puts
+ * the right routing data into the line register in
+ * configuration space. The rest are used on systems
+ * that do not.
+ */
+ u_int pa_intrswiz; /* how to swizzle pins if ppb */
+ pcitag_t pa_intrtag; /* intr. appears to come from here */
+ pci_intr_pin_t pa_intrpin; /* intr. appears on this pin */
+ pci_intr_line_t pa_intrline; /* intr. routing information */
};
/*
#define pcicf_function cf_loc[1]
#define PCI_UNK_FUNCTION -1 /* wildcarded 'function' */
-pcireg_t pci_conf_read __P((pcitag_t, int));
-void pci_conf_write __P((pcitag_t, int, pcireg_t));
-void pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
-pcitag_t pci_make_tag __P((int, int, int));
-void *pci_map_int __P((pcitag_t, int, int (*)(void *), void *, char *));
-int pci_map_mem __P((pcitag_t, int, vm_offset_t *, vm_offset_t *));
+/*
+ * Configuration space access and utility functions. (Note that most,
+ * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
+ */
+int pci_io_find __P((pci_chipset_tag_t, pcitag_t, int, bus_io_addr_t *,
+ bus_io_size_t *));
+int pci_mem_find __P((pci_chipset_tag_t, pcitag_t, int, bus_mem_addr_t *,
+ bus_mem_size_t *, int *));
+
+/*
+ * Helper functions for autoconfiguration.
+ */
+void pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
#endif /* _DEV_PCI_PCIVAR_H_ */
-/* $OpenBSD: ppb.c,v 1.1 1996/04/18 23:48:09 niklas Exp $ */
-/* $NetBSD: ppb.c,v 1.4 1996/03/14 04:03:03 cgd Exp $ */
+/* $OpenBSD: ppb.c,v 1.2 1996/04/21 22:25:53 deraadt Exp $ */
+/* $NetBSD: ppb.c,v 1.7 1996/03/27 04:08:34 cgd Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
int ppbmatch __P((struct device *, void *, void *));
void ppbattach __P((struct device *, struct device *, void *));
-struct cfdriver ppbcd = {
- NULL, "ppb", ppbmatch, ppbattach, DV_DULL, sizeof(struct device)
+struct cfattach ppb_ca = {
+ sizeof(struct device), ppbmatch, ppbattach
};
-static int ppbprint __P((void *, char *pnp));
+struct cfdriver ppb_cd = {
+ NULL, "ppb", DV_DULL
+};
+
+int ppbprint __P((void *, char *pnp));
int
ppbmatch(parent, match, aux)
void *aux;
{
struct pci_attach_args *pa = aux;
+ pci_chipset_tag_t pc = pa->pa_pc;
struct pcibus_attach_args pba;
- pcireg_t data;
+ pcireg_t busdata;
char devinfo[256];
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
- data = pci_conf_read(pa->pa_tag, PPB_REG_BUSINFO);
+ busdata = pci_conf_read(pc, pa->pa_tag, PPB_REG_BUSINFO);
- if (PPB_BUSINFO_SECONDARY(data) == 0) {
+ if (PPB_BUSINFO_SECONDARY(busdata) == 0) {
printf("%s: not configured by system firmware\n",
self->dv_xname);
return;
#if 0
/*
* XXX can't do this, because we're not given our bus number
- * (we shouldn't need it) and we can't decompose our tag.
+ * (we shouldn't need it), and because we've no way to
+ * decompose our tag.
*/
-
/* sanity check. */
- if (pa->pa_bus != PPB_BUSINFO_PRIMARY(data))
+ if (pa->pa_bus != PPB_BUSINFO_PRIMARY(busdata))
panic("ppbattach: bus in tag (%d) != bus in reg (%d)",
- pa->pa_bus, PPB_BUSINFO_PRIMARY(data));
+ pa->pa_bus, PPB_BUSINFO_PRIMARY(busdata));
#endif
/*
* Attach the PCI bus than hangs off of it.
*/
pba.pba_busname = "pci";
- pba.pba_bus = PPB_BUSINFO_SECONDARY(data);
+ pba.pba_bc = pa->pa_bc;
+ pba.pba_pc = pc;
+ pba.pba_bus = PPB_BUSINFO_SECONDARY(busdata);
+ pba.pba_intrswiz = pa->pa_intrswiz;
+ pba.pba_intrtag = pa->pa_intrtag;
config_found(self, &pba, ppbprint);
}
-static int
+int
ppbprint(aux, pnp)
void *aux;
char *pnp;
if (pnp)
printf("pci at %s", pnp);
printf(" bus %d", pba->pba_bus);
- return (UNCONF);
+ return (UNCONF);
}
-# $OpenBSD: files.pcmcia,v 1.2 1996/04/18 23:48:11 niklas Exp $
+# $OpenBSD: files.pcmcia,v 1.3 1996/04/21 22:25:58 deraadt Exp $
#
# Config file and device description for machine-independent PCMCIA code.
# Included by ports that need it.
# ports should define their own "device pcmcia" line (like the one below,
# but with the correct bus attachment).
-device pcmcia at pcicbus: isa
+device pcmcia: isa
+attach pcmcia at pcicbus
file dev/pcmcia/pcmcia.c pcmcia needs-count
file dev/pcmcia/pcmcia_conf.c pcmcia
-/* $OpenBSD: ramdisk.c,v 1.4 1996/04/18 23:47:04 niklas Exp $ */
-/* $NetBSD: ramdisk.c,v 1.5 1996/03/07 10:26:29 leo Exp $ */
+/* $OpenBSD: ramdisk.c,v 1.5 1996/04/21 22:19:53 deraadt Exp $ */
+/* $NetBSD: ramdisk.c,v 1.8 1996/04/12 08:30:09 leo Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
*/
#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/device.h>
#include <sys/disk.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
*
* XXX Assumption: 16 RAM-disks are enough!
*/
+#define RD_MAX_UNITS 0x10
#define RD_IS_CTRL(unit) (unit & 0x10)
#define RD_UNIT(unit) (unit & 0xF)
-/*
- * XXX - This is just for a sanity check. Only
- * applies to kernel-space RAM disk allocations.
- */
-#define RD_KMEM_MAX_SIZE 0x100000 /* 1MB */
-
/* autoconfig stuff... */
struct rd_softc {
#define RD_ISOPEN 0x01
#define RD_SERVED 0x02
-static int rd_match (struct device *, void *self, void *);
-static void rd_attach(struct device *, struct device *self, void *);
+void rdattach __P((int));
+static void rd_attach __P((struct device *, struct device *, void *));
-struct cfdriver rdcd = {
- NULL, "rd", rd_match, rd_attach,
- DV_DULL, sizeof(struct rd_softc), NULL, 0 };
+/*
+ * Some ports (like i386) use a swapgeneric that wants to
+ * snoop around in this rd_cd structure. It is preserved
+ * (for now) to remain compatible with such practice.
+ * XXX - that practice is questionable...
+ */
+struct cfdriver rd_cd = {
+ NULL, "rd", DV_DULL, NULL, 0
+};
void rdstrategy __P((struct buf *bp));
-
struct dkdriver rddkdriver = { rdstrategy };
-static int
-rd_match(parent, self, aux)
- struct device *parent;
- void *self;
- void *aux;
+static int ramdisk_ndevs;
+static void *ramdisk_devs[RD_MAX_UNITS];
+
+/*
+ * This is called if we are configured as a pseudo-device
+ */
+void
+rdattach(n)
+ int n;
{
-#ifdef RAMDISK_HOOKS
- /*
- * This external function allows for a machine dependent
- * match function.
- */
- return (rd_match_hook(parent, self, aux));
-#else
- return(1);
+ struct rd_softc *sc;
+ int i;
+
+#ifdef DIAGNOSTIC
+ if (ramdisk_ndevs) {
+ printf("ramdisk: multiple attach calls?\n");
+ return;
+ }
#endif
+
+ /* XXX: Are we supposed to provide a default? */
+ if (n <= 1)
+ n = 1;
+ if (n > RD_MAX_UNITS)
+ n = RD_MAX_UNITS;
+ ramdisk_ndevs = n;
+
+ /* XXX: Fake-up rd_cd (see above) */
+ rd_cd.cd_ndevs = ramdisk_ndevs;
+ rd_cd.cd_devs = ramdisk_devs;
+
+ /* Attach as if by autoconfig. */
+ for (i = 0; i < n; i++) {
+
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK);
+ if (!sc) {
+ printf("ramdisk: malloc for attach failed!\n");
+ return;
+ }
+ bzero((caddr_t)sc, sizeof(*sc));
+ ramdisk_devs[i] = sc;
+ sc->sc_dev.dv_unit = i;
+ sprintf(sc->sc_dev.dv_xname, "rd%d", i);
+ rd_attach(NULL, &sc->sc_dev, NULL);
+ }
}
static void
*/
rd_attach_hook(sc->sc_dev.dv_unit, &sc->sc_rd);
#endif
- printf("\n");
/*
* Initialize and attach the disk structure.
*/
- bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
sc->sc_dkdev.dk_driver = &rddkdriver;
sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
disk_attach(&sc->sc_dkdev);
static int rd_ioctl_server __P((struct rd_softc *sc,
struct rd_conf *urd, struct proc *proc));
#endif
+static int rd_ioctl_kalloc __P((struct rd_softc *sc,
+ struct rd_conf *urd, struct proc *proc));
+
+dev_type_open(rdopen);
+dev_type_close(rdclose);
+dev_type_read(rdread);
+dev_type_write(rdwrite);
+dev_type_ioctl(rdioctl);
+dev_type_size(rdsize);
+dev_type_dump(rddump);
int rddump(dev, blkno, va, size)
dev_t dev;
/* Disallow control units. */
unit = minor(dev);
- if (unit >= rdcd.cd_ndevs)
+ if (unit >= ramdisk_ndevs)
return 0;
- sc = rdcd.cd_devs[unit];
+ sc = ramdisk_devs[unit];
if (sc == NULL)
return 0;
return (sc->sc_size >> DEV_BSHIFT);
}
-int rdopen(dev, flag, fmt, proc)
+int
+rdopen(dev, flag, fmt, proc)
dev_t dev;
int flag, fmt;
struct proc *proc;
md = minor(dev);
unit = RD_UNIT(md);
- if (unit >= rdcd.cd_ndevs)
+ if (unit >= ramdisk_ndevs)
return ENXIO;
- sc = rdcd.cd_devs[unit];
+ sc = ramdisk_devs[unit];
if (sc == NULL)
return ENXIO;
return 0;
}
-int rdclose(dev, flag, fmt, proc)
+int
+rdclose(dev, flag, fmt, proc)
dev_t dev;
int flag, fmt;
struct proc *proc;
md = minor(dev);
unit = RD_UNIT(md);
- sc = rdcd.cd_devs[unit];
+ sc = ramdisk_devs[unit];
if (RD_IS_CTRL(md))
return 0;
}
int
-rdread(dev, uio)
+rdread(dev, uio, flags)
dev_t dev;
struct uio *uio;
+ int flags;
{
return (physio(rdstrategy, NULL, dev, B_READ, minphys, uio));
}
int
-rdwrite(dev, uio)
+rdwrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
+ int flags;
{
return (physio(rdstrategy, NULL, dev, B_WRITE, minphys, uio));
}
md = minor(bp->b_dev);
unit = RD_UNIT(md);
- sc = rdcd.cd_devs[unit];
+ sc = ramdisk_devs[unit];
switch (sc->sc_type) {
#if RAMDISK_SERVER
md = minor(dev);
unit = RD_UNIT(md);
- sc = rdcd.cd_devs[unit];
+ sc = ramdisk_devs[unit];
/* If this is not the control device, punt! */
if (RD_IS_CTRL(md) == 0)
* Handle ioctl RD_SETCONF for (sc_type == RD_KMEM_ALLOCATED)
* Just allocate some kernel memory and return.
*/
-int
+static int
rd_ioctl_kalloc(sc, urd, proc)
struct rd_softc *sc;
struct rd_conf *urd;
/* Sanity check the size. */
size = urd->rd_size;
- if (size > RD_KMEM_MAX_SIZE)
- return EINVAL;
addr = kmem_alloc(kernel_map, size);
if (!addr)
return ENOMEM;
* Handle ioctl RD_SETCONF for (sc_type == RD_UMEM_SERVER)
* Set config, then become the I/O server for this unit.
*/
-int
+static int
rd_ioctl_server(sc, urd, proc)
struct rd_softc *sc;
struct rd_conf *urd;
-/* $OpenBSD: ramdisk.h,v 1.3 1996/04/18 23:47:04 niklas Exp $ */
-/* $NetBSD: ramdisk.h,v 1.3 1996/03/07 10:26:31 leo Exp $ */
+/* $OpenBSD: ramdisk.h,v 1.4 1996/04/21 22:19:56 deraadt Exp $ */
+/* $NetBSD: ramdisk.h,v 1.4 1996/03/22 23:02:04 gwr Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross
* called by the ramdisk driver to allow machine-dependent to
* match/configure and/or load each ramdisk unit.
*/
-extern int rd_match_hook __P((struct device *, void *, void *));
extern void rd_attach_hook __P((int unit, struct rd_conf *));
extern void rd_open_hook __P((int unit, struct rd_conf *));
#endif
-# $NetBSD: files.rcons,v 1.1 1995/10/04 23:35:31 pk Exp $
+# $NetBSD: files.rcons,v 1.2 1996/04/11 21:54:38 cgd Exp $
#
# Configuration file for RASTER Console.
#
-file dev/rcons/raster_op.c rasterconsole
-file dev/rcons/raster_text.c rasterconsole
+file dev/rcons/raster_op.c rasterconsole | raster
+file dev/rcons/raster_text.c rasterconsole | raster
file dev/rcons/rcons_kern.c rasterconsole
file dev/rcons/rcons_subr.c rasterconsole
-/* $OpenBSD: kbd.c,v 1.2 1996/04/18 23:48:15 niklas Exp $ */
-/* $NetBSD: kbd.c,v 1.4 1996/02/29 19:32:14 gwr Exp $ */
+/* $OpenBSD: kbd.c,v 1.3 1996/04/21 22:26:10 deraadt Exp $ */
+/* $NetBSD: kbd.c,v 1.7 1996/04/10 21:44:58 gwr Exp $ */
/*
* Copyright (c) 1992, 1993
static int kbd_match(struct device *, void *, void *);
static void kbd_attach(struct device *, struct device *, void *);
-struct cfdriver kbdcd = {
- NULL, "kbd", kbd_match, kbd_attach,
- DV_DULL, sizeof(struct kbd_softc), NULL,
+struct cfattach kbd_ca = {
+ sizeof(struct kbd_softc), kbd_match, kbd_attach
+};
+
+struct cfdriver kbd_cd = {
+ NULL, "kbd", DV_DULL
};
int error, s, unit;
unit = minor(dev);
- if (unit >= kbdcd.cd_ndevs)
+ if (unit >= kbd_cd.cd_ndevs)
return (ENXIO);
- k = kbdcd.cd_devs[unit];
+ k = kbd_cd.cd_devs[unit];
if (k == NULL)
return (ENXIO);
{
struct kbd_softc *k;
- k = kbdcd.cd_devs[minor(dev)];
+ k = kbd_cd.cd_devs[minor(dev)];
k->k_evmode = 0;
ev_fini(&k->k_events);
k->k_events.ev_io = NULL;
{
struct kbd_softc *k;
- k = kbdcd.cd_devs[minor(dev)];
+ k = kbd_cd.cd_devs[minor(dev)];
return (ev_read(&k->k_events, uio, flags));
}
{
struct kbd_softc *k;
- k = kbdcd.cd_devs[minor(dev)];
+ k = kbd_cd.cd_devs[minor(dev)];
return (ev_select(&k->k_events, rw, p));
}
-static int kbd_oldkeymap __P((struct kbd_state *ks,
- u_long cmd, struct okiockey *okio));
+static int kbd_ioccmd(struct kbd_softc *k, int *data);
static int kbd_iockeymap __P((struct kbd_state *ks,
u_long cmd, struct kiockeymap *kio));
+static int kbd_iocsled(struct kbd_softc *k, int *data);
+
+#ifdef KIOCGETKEY
+static int kbd_oldkeymap __P((struct kbd_state *ks,
+ u_long cmd, struct okiockey *okio));
+#endif
+
int
kbdioctl(dev, cmd, data, flag, p)
dev_t dev;
int *ip;
int error = 0;
- k = kbdcd.cd_devs[minor(dev)];
+ k = kbd_cd.cd_devs[minor(dev)];
ks = &k->k_state;
switch (cmd) {
break;
case KIOCCMD: /* Send a command to the keyboard */
- /*
- * ``unimplemented commands are ignored'' (blech)
- * so cannot check return value from kbd_docmd
- */
- error = kbd_drain_tx(k);
- if (error == 0) {
- (void) kbd_docmd(k, *(int *)data);
- }
+ error = kbd_ioccmd(k, (int *)data);
break;
case KIOCTYPE: /* Get keyboard type */
break;
case KIOCSLED:
- error = kbd_drain_tx(k);
- kbd_set_leds(k, *(int *)data);
+ error = kbd_iocsled(k, (int *)data);
break;
case KIOCGLED:
/*
* Get/Set keymap entry
*/
-int
+static int
kbd_iockeymap(ks, cmd, kio)
struct kbd_state *ks;
u_long cmd;
}
#endif /* KIOCGETKEY */
+
+/*
+ * keyboard command ioctl
+ * ``unimplemented commands are ignored'' (blech)
+ */
+static int
+kbd_ioccmd(k, data)
+ struct kbd_softc *k;
+ int *data;
+{
+ struct kbd_state *ks = &k->k_state;
+ int cmd, error, s;
+
+ cmd = *data;
+ switch (cmd) {
+
+ case KBD_CMD_BELL:
+ case KBD_CMD_NOBELL:
+ /* Supported by type 2, 3, and 4 keyboards */
+ break;
+
+ case KBD_CMD_CLICK:
+ case KBD_CMD_NOCLICK:
+ /* Unsupported by type 2 keyboards */
+ if (ks->kbd_id <= KB_SUN2)
+ return (0);
+ ks->kbd_click = (cmd == KBD_CMD_CLICK);
+ break;
+
+ default:
+ return (0);
+ }
+
+ s = spltty();
+
+ error = kbd_drain_tx(k);
+ if (error == 0) {
+ kbd_output(k, cmd);
+ kbd_start_tx(k);
+ }
+
+ splx(s);
+
+ return (error);
+}
+
+/*
+ * Set LEDs ioctl.
+ */
+static int
+kbd_iocsled(k, data)
+ struct kbd_softc *k;
+ int *data;
+{
+ struct kbd_state *ks = &k->k_state;
+ int leds, error, s;
+
+ leds = *data;
+
+ s = spltty();
+ error = kbd_drain_tx(k);
+ if (error == 0) {
+ kbd_set_leds(k, leds);
+ }
+ splx(s);
+
+ return (error);
+}
+
+
/****************************************************************
* middle layers:
* - keysym to ASCII sequence
/*
* This is called by kbd_input_raw() or by kb_repeat()
- * to deliver ASCII input. Called at splsoftclock()
- * XXX: Raise to spltty before calling kd_input() ?
+ * to deliver ASCII input. Called at spltty().
*/
void
kbd_input_keysym(k, keysym)
/*
* This is the autorepeat timeout function.
- * (called at splsoftclock)
+ * Called at splsoftclock().
*/
void
kbd_repeat(void *arg)
{
struct kbd_softc *k = (struct kbd_softc *)arg;
+ int s = spltty();
if (k->k_repeating && k->k_repeatsym >= 0) {
kbd_input_keysym(k, k->k_repeatsym);
timeout(kbd_repeat, k, k->k_repeat_step);
}
+ splx(s);
}
/*
* Called by our kbd_softint() routine on input,
* which passes the raw hardware scan codes.
- * Note: this is called at splsoftclock()
+ * Called at spltty()
*/
void
kbd_input_raw(k, c)
* Interface to the lower layer (zscc)
****************************************************************/
-static int
+static void
kbd_rxint(cs)
register struct zs_chanstate *cs;
{
k = cs->cs_private;
put = k->k_rbput;
- /* Read the input data ASAP. */
- c = zs_read_data(cs);
-
- /* Save the status register too. */
+ /*
+ * First read the status, because reading the received char
+ * destroys the status of this char.
+ */
rr1 = zs_read_reg(cs, 1);
+ c = zs_read_data(cs);
if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
/* Clear the receive error. */
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return(1);
}
-static int
+static void
kbd_txint(cs)
register struct zs_chanstate *cs;
{
register struct kbd_softc *k;
- register int count, rval;
k = cs->cs_private;
-
zs_write_csr(cs, ZSWR0_RESET_TXINT);
-
k->k_intr_flags |= INTR_TX_EMPTY;
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return (1);
}
-static int
+static void
kbd_stint(cs)
register struct zs_chanstate *cs;
{
k = cs->cs_private;
- rr0 = zs_read_csr(cs);
+ cs->cs_rr0_new = zs_read_csr(cs);
zs_write_csr(cs, ZSWR0_RESET_STATUS);
#if 0
k->k_intr_flags |= INTR_ST_CHECK;
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return (1);
}
/*
* Get input from the recieve ring and pass it on.
* Note: this is called at splsoftclock()
*/
-static int
+static void
kbd_softint(cs)
struct zs_chanstate *cs;
{
s = splzs();
intr_flags = k->k_intr_flags;
k->k_intr_flags = 0;
- splx(s);
+
+ /* Now lower to spltty for the rest. */
+ (void) spltty();
/*
* Copy data from the receive ring to the event layer.
*/
log(LOG_ERR, "%s: status interrupt?\n",
k->k_dev.dv_xname);
+ cs->cs_rr0 = cs->cs_rr0_new;
}
- return (1);
+ splx(s);
}
struct zsops zsops_kbd = {
/*
* Initialization to be done at first open.
* This is called from kbdopen or kdopen (in kd.c)
+ * Called with user context.
*/
int
kbd_iopen(unit)
struct kbd_state *ks;
int error, s;
- if (unit >= kbdcd.cd_ndevs)
+ if (unit >= kbd_cd.cd_ndevs)
return (ENXIO);
- k = kbdcd.cd_devs[unit];
+ k = kbd_cd.cd_devs[unit];
if (k == NULL)
return (ENXIO);
ks = &k->k_state;
return error;
}
+/*
+ * Called by kbd_input_raw, at spltty()
+ */
void
kbd_was_reset(k)
struct kbd_softc *k;
case KB_SUN3:
/* Type 3 keyboards come up with keyclick on */
- if (!ks->kbd_click)
- (void) kbd_docmd(k, KBD_CMD_NOCLICK);
+ if (!ks->kbd_click) {
+ /* turn off the click */
+ kbd_output(k, KBD_CMD_NOCLICK);
+ kbd_start_tx(k);
+ }
break;
case KB_SUN4:
/* Type 4 keyboards come up with keyclick off */
- if (ks->kbd_click)
- (void) kbd_docmd(k, KBD_CMD_CLICK);
+ if (ks->kbd_click) {
+ /* turn on the click */
+ kbd_output(k, KBD_CMD_CLICK);
+ kbd_start_tx(k);
+ }
break;
}
ks->kbd_leds = 0;
}
+/*
+ * Called by kbd_input_raw, at spltty()
+ */
void
kbd_new_layout(k)
struct kbd_softc *k;
/*
* Wait for output to finish.
- * Called with user context.
+ * Called at spltty(). Has user context.
*/
int
kbd_drain_tx(k)
struct kbd_softc *k;
{
- int error, s;
+ int error;
error = 0;
- s = spltty();
+
while (k->k_txflags & K_TXBUSY) {
k->k_txflags |= K_TXWANT;
error = tsleep((caddr_t)&k->k_txflags,
PZERO | PCATCH, "kbdout", 0);
}
- splx(s);
+
return (error);
}
/*
- * Send out a byte to the keyboard (i.e. reset)
- * Called with user context.
+ * Enqueue some output for the keyboard
+ * Called at spltty().
*/
void
kbd_output(k, c)
int c; /* the data */
{
struct zs_chanstate *cs = k->k_cs;
- int put, s;
+ int put;
- s = spltty();
put = k->k_tbput;
k->k_tbuf[put] = (u_char)c;
put = (put + 1) & KBD_TX_RING_MASK;
/* OK, really increment. */
k->k_tbput = put;
}
-
- splx(s);
}
+/*
+ * Start the sending data from the output queue
+ * Called at spltty().
+ */
void
kbd_start_tx(k)
struct kbd_softc *k;
int get, s;
u_char c;
- s = spltty();
if (k->k_txflags & K_TXBUSY)
- goto out;
+ return;
/* Is there anything to send? */
get = k->k_tbget;
k->k_txflags &= ~K_TXWANT;
wakeup((caddr_t)&k->k_txflags);
}
- goto out;
+ return;
}
/* Have something to send. */
k->k_txflags |= K_TXBUSY;
/* Need splzs to avoid interruption of the delay. */
- (void) splzs();
+ s = splzs();
zs_write_data(cs, c);
-
-out:
splx(s);
}
-
+/*
+ * Called at spltty by:
+ * kbd_update_leds, kbd_iocsled
+ */
void
kbd_set_leds(k, new_leds)
struct kbd_softc *k;
int new_leds;
{
struct kbd_state *ks = &k->k_state;
- int s;
-
- s = spltty();
/* Don't send unless state changes. */
if (ks->kbd_leds == new_leds)
- goto out;
+ return;
+
ks->kbd_leds = new_leds;
/* Only type 4 and later has LEDs anyway. */
if (ks->kbd_id < 4)
- goto out;
+ return;
kbd_output(k, KBD_CMD_SETLED);
kbd_output(k, new_leds);
kbd_start_tx(k);
-
-out:
- splx(s);
}
+/*
+ * Called at spltty by:
+ * kbd_input_keysym
+ */
void
kbd_update_leds(k)
struct kbd_softc *k;
kbd_set_leds(k, leds);
}
-
-
-/*
- * Execute a keyboard command; return 0 on success.
- */
-int
-kbd_docmd(k, cmd)
- struct kbd_softc *k;
- int cmd;
-{
- struct kbd_state *ks = &k->k_state;
- int error, s;
-
- switch (cmd) {
-
- case KBD_CMD_BELL:
- case KBD_CMD_NOBELL:
- /* Supported by type 2, 3, and 4 keyboards */
- break;
-
- case KBD_CMD_CLICK:
- /* Unsupported by type 2 keyboards */
- if (ks->kbd_id != KB_SUN2) {
- ks->kbd_click = 1;
- break;
- }
- return (EINVAL);
-
- case KBD_CMD_NOCLICK:
- /* Unsupported by type 2 keyboards */
- if (ks->kbd_id != KB_SUN2) {
- ks->kbd_click = 0;
- break;
- }
- return (EINVAL);
-
- default:
- return (EINVAL); /* ENOTTY? EOPNOTSUPP? */
- }
-
- kbd_output(k, cmd);
- kbd_start_tx(k);
- return (0);
-}
-/* $OpenBSD: ms.c,v 1.2 1996/04/18 23:48:18 niklas Exp $ */
-/* $NetBSD: ms.c,v 1.3 1996/02/19 04:36:15 gwr Exp $ */
+/* $OpenBSD: ms.c,v 1.3 1996/04/21 22:26:13 deraadt Exp $ */
+/* $NetBSD: ms.c,v 1.5 1996/04/10 21:45:01 gwr Exp $ */
/*
* Copyright (c) 1992, 1993
static int ms_match(struct device *, void *, void *);
static void ms_attach(struct device *, struct device *, void *);
-struct cfdriver mscd = {
- NULL, "ms", ms_match, ms_attach,
- DV_DULL, sizeof(struct ms_softc), NULL,
+struct cfattach ms_ca = {
+ sizeof(struct ms_softc), ms_match, ms_attach
+};
+
+struct cfdriver ms_cd = {
+ NULL, "ms", DV_DULL
};
int error, s, unit;
unit = minor(dev);
- if (unit >= mscd.cd_ndevs)
+ if (unit >= ms_cd.cd_ndevs)
return (ENXIO);
- ms = mscd.cd_devs[unit];
+ ms = ms_cd.cd_devs[unit];
if (ms == NULL)
return (ENXIO);
{
struct ms_softc *ms;
- ms = mscd.cd_devs[minor(dev)];
+ ms = ms_cd.cd_devs[minor(dev)];
ms->ms_ready = 0; /* stop accepting events */
ev_fini(&ms->ms_events);
{
struct ms_softc *ms;
- ms = mscd.cd_devs[minor(dev)];
+ ms = ms_cd.cd_devs[minor(dev)];
return (ev_read(&ms->ms_events, uio, flags));
}
{
struct ms_softc *ms;
- ms = mscd.cd_devs[minor(dev)];
+ ms = ms_cd.cd_devs[minor(dev)];
switch (cmd) {
{
struct ms_softc *ms;
- ms = mscd.cd_devs[minor(dev)];
+ ms = ms_cd.cd_devs[minor(dev)];
return (ev_select(&ms->ms_events, rw, p));
}
* Interface to the lower layer (zscc)
****************************************************************/
-static int
+static void
ms_rxint(cs)
register struct zs_chanstate *cs;
{
ms = cs->cs_private;
put = ms->ms_rbput;
- /* Read the input data ASAP. */
- c = zs_read_data(cs);
-
- /* Save the status register too. */
+ /*
+ * First read the status, because reading the received char
+ * destroys the status of this char.
+ */
rr1 = zs_read_reg(cs, 1);
+ c = zs_read_data(cs);
if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) {
/* Clear the receive error. */
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return(1);
}
-static int
+static void
ms_txint(cs)
register struct zs_chanstate *cs;
{
register struct ms_softc *ms;
- register int count, rval;
ms = cs->cs_private;
-
zs_write_csr(cs, ZSWR0_RESET_TXINT);
-
ms->ms_intr_flags |= INTR_TX_EMPTY;
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return (1);
}
-static int
+static void
ms_stint(cs)
register struct zs_chanstate *cs;
{
ms = cs->cs_private;
- rr0 = zs_read_csr(cs);
+ cs->cs_rr0_new = zs_read_csr(cs);
zs_write_csr(cs, ZSWR0_RESET_STATUS);
ms->ms_intr_flags |= INTR_ST_CHECK;
/* Ask for softint() call. */
cs->cs_softreq = 1;
- return (1);
}
-static int
+static void
ms_softint(cs)
struct zs_chanstate *cs;
{
s = splzs();
intr_flags = ms->ms_intr_flags;
ms->ms_intr_flags = 0;
- splx(s);
+
+ /* Now lower to spltty for the rest. */
+ (void) spltty();
/*
* Copy data from the receive ring to the event layer.
*/
log(LOG_ERR, "%s: status interrupt?\n",
ms->ms_dev.dv_xname);
+ cs->cs_rr0 = cs->cs_rr0_new;
}
- return (1);
+ splx(s);
}
struct zsops zsops_ms = {
-/* $NetBSD: asc.c,v 1.16 1996/01/04 17:43:23 jonathan Exp $ */
+/* $NetBSD: asc.c,v 1.18 1996/03/18 01:39:47 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
#include <sys/conf.h>
#include <sys/errno.h>
#include <sys/device.h>
+#include <dev/tc/tcvar.h>
+#include <dev/tc/ioasicvar.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <pmax/pmax/pmaxtype.h>
-#define readback(a) { register int foo; foo = (a); }
+/*#define readback(a) { register int foo; wbflush(); foo = (a); }*/
+#define readback(a) { register int foo; foo = (a); }
extern int pmax_boardtype;
/*
*/
script_t asc_scripts[] = {
/* start data in */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_DATAI), /* 0 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_DATAI), /* 0 */
asc_dma_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_STATUS), /* 1 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_STATUS), /* 1 */
asc_last_dma_in, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
/* continue data in after a chunk is finished */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAI), /* 2 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAI), /* 2 */
asc_dma_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
/* start data out */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_DATAO), /* 3 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_DATAO), /* 3 */
asc_dma_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_STATUS), /* 4 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_STATUS), /* 4 */
asc_last_dma_out, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
/* continue data out after a chunk is finished */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAO), /* 5 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAO), /* 5 */
asc_dma_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
/* simple command with no data transfer */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_STATUS), /* 6 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_STATUS), /* 6 */
script_nop, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
/* get status and finish command */
- {SCRIPT_MATCH(ASC_INT_FC, ASC_PHASE_MSG_IN), /* 7 */
+ {SCRIPT_MATCH(ASC_INT_FC, SCSI_PHASE_MSG_IN), /* 7 */
asc_get_status, ASC_CMD_MSG_ACPT,
&asc_scripts[SCRIPT_DONE]},
{SCRIPT_MATCH(ASC_INT_DISC, 0), /* 8 */
&asc_scripts[SCRIPT_DONE]},
/* message in */
- {SCRIPT_MATCH(ASC_INT_FC, ASC_PHASE_MSG_IN), /* 9 */
+ {SCRIPT_MATCH(ASC_INT_FC, SCSI_PHASE_MSG_IN), /* 9 */
asc_msg_in, ASC_CMD_MSG_ACPT,
&asc_scripts[SCRIPT_MSG_IN + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_MSG_IN), /* 10 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_MSG_IN), /* 10 */
script_nop, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_MSG_IN]},
/* send synchonous negotiation reply */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_MSG_OUT), /* 11 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_MSG_OUT), /* 11 */
asc_replysync, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_REPLY_SYNC]},
/* try to negotiate synchonous transfer parameters */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_MSG_OUT), /* 12 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_MSG_OUT), /* 12 */
asc_sendsync, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_TRY_SYNC + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_MSG_IN), /* 13 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_MSG_IN), /* 13 */
script_nop, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_MSG_IN]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_COMMAND), /* 14 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_COMMAND), /* 14 */
script_nop, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_RESUME_NO_DATA]},
/* handle a disconnect */
- {SCRIPT_MATCH(ASC_INT_DISC, ASC_PHASE_DATAO), /* 15 */
+ {SCRIPT_MATCH(ASC_INT_DISC, SCSI_PHASE_DATAO), /* 15 */
asc_disconnect, ASC_CMD_ENABLE_SEL,
&asc_scripts[SCRIPT_RESEL]},
/* reselect sequence: this is just a placeholder so match fails */
- {SCRIPT_MATCH(0, ASC_PHASE_MSG_IN), /* 16 */
+ {SCRIPT_MATCH(0, SCSI_PHASE_MSG_IN), /* 16 */
script_nop, ASC_CMD_MSG_ACPT,
&asc_scripts[SCRIPT_RESEL]},
/* resume data in after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAI), /* 17 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAI), /* 17 */
asc_resume_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
/* resume partial DMA data in after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAI), /* 18 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAI), /* 18 */
asc_resume_dma_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
/* resume data out after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAO), /* 19 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAO), /* 19 */
asc_resume_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
/* resume partial DMA data out after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAO), /* 20 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAO), /* 20 */
asc_resume_dma_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
/* resume after a message when there is no more data */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_STATUS), /* 21 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_STATUS), /* 21 */
script_nop, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
};
#define ASCDMA_WRITE 2
static void tb_dma_start(), tb_dma_end(), asic_dma_start(), asic_dma_end();
extern u_long asc_iomem;
-extern u_long asic_base;
+
/*
* Autoconfiguration data for config.
void ascattach __P((struct device *parent, struct device *self, void *aux));
int ascprint(void*, char*);
-extern struct cfdriver asccd;
-struct cfdriver asccd = {
- NULL, "asc", ascmatch, ascattach, DV_DULL, sizeof(struct asc_softc)
+struct cfattach asc_ca = {
+ sizeof(struct asc_softc), ascmatch, ascattach
+};
+
+extern struct cfdriver asc_cd;
+struct cfdriver asc_cd = {
+ NULL, "as", DV_DULL
};
+
#ifdef USE_NEW_SCSI
/* Glue to the machine-independent scsi */
struct scsi_adapter asc_switch = {
{
struct cfdata *cf = match;
struct confargs *ca = aux;
- void *sccaddr;
+ void *ascaddr;
- if (!BUS_MATCHNAME(ca, "asc") && !BUS_MATCHNAME(ca, "PMAZ-AA "))
+ /*if (parent->dv_cfdata->cf_driver == &ioasic_cd) */
+ if (!TC_BUS_MATCHNAME(ca, "asc") && !TC_BUS_MATCHNAME(ca, "PMAZ-AA "))
return (0);
- sccaddr = BUS_CVTADDR(ca);
+ ascaddr = (void*)ca->ca_addr;
- if (badaddr(sccaddr + ASC_OFFSET_53C94, 4))
+ if (badaddr(ascaddr + ASC_OFFSET_53C94, 4))
return (0);
return (1);
}
+extern struct cfdriver ioasic_cd; /* XXX */
+
void
ascattach(parent, self, aux)
struct device *parent;
void *ascaddr;
int unit;
- ascaddr = (void *)MACH_PHYS_TO_UNCACHED(BUS_CVTADDR(ca));
+ ascaddr = (void*)MACH_PHYS_TO_UNCACHED(ca->ca_addr);
unit = asc->sc_dev.dv_unit;
/*
* (1) how to do dma
* (2) timing based on turbochannel frequency
*/
- switch (pmax_boardtype) {
- case DS_3MIN:
- case DS_MAXINE:
- case DS_3MAXPLUS:
- if (unit == 0) {
+
+ if (asc->sc_dev.dv_parent->dv_cfdata->cf_driver == &ioasic_cd) {
asc->buff = (u_char *)MACH_PHYS_TO_UNCACHED(asc_iomem);
bufsiz = 8192;
- *((volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base)) = -1;
- *((volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base)) = -1;
- *((volatile int *)ASIC_REG_SCSI_SCR(asic_base)) = 0;
+ *((volatile int *)IOASIC_REG_SCSI_DMAPTR(ioasic_base)) = -1;
+ *((volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base)) = -1;
+ *((volatile int *)IOASIC_REG_SCSI_SCR(ioasic_base)) = 0;
asc->dma_start = asic_dma_start;
asc->dma_end = asic_dma_end;
- break;
- }
+ } else
+ {
/*
* Fall through for turbochannel option.
*/
- case DS_3MAX:
- default:
asc->dmar = (volatile int *)(ascaddr + ASC_OFFSET_DMAR);
asc->buff = (u_char *)(ascaddr + ASC_OFFSET_RAM);
bufsiz = PER_TGT_DMA_SIZE;
/* tie pseudo-slot to device */
BUS_INTR_ESTABLISH(ca, asc_intr, asc);
+
printf(": target %d\n", id);
register ScsiCmd *scsicmd; /* command to start */
{
register struct pmax_scsi_device *sdp = scsicmd->sd;
- register asc_softc_t asc = asccd.cd_devs[sdp->sd_ctlr];
+ register asc_softc_t asc = asc_cd.cd_devs[sdp->sd_ctlr];
int s;
s = splbio();
state = &asc->st[asc->target];
switch (ASC_PHASE(status)) {
- case ASC_PHASE_DATAI:
- case ASC_PHASE_DATAO:
+ case SCSI_PHASE_DATAI:
+ case SCSI_PHASE_DATAO:
ASC_TC_GET(regs, len);
fifo = regs->asc_flags & ASC_FLAGS_FIFO_CNT;
printf("asc_intr: data overrun: buflen %d dmalen %d tc %d fifo %d\n",
state->buflen, state->dmalen, len, fifo);
goto abort;
- case ASC_PHASE_MSG_IN:
+ case SCSI_PHASE_MSG_IN:
break;
- case ASC_PHASE_MSG_OUT:
+ case SCSI_PHASE_MSG_OUT:
/*
* Check for parity error.
* Hardware will automatically set ATN
readback(regs->asc_cmd);
goto done;
- case ASC_PHASE_STATUS:
+ case SCSI_PHASE_STATUS:
/* probably an error in the SCSI command */
asc->script = &asc_scripts[SCRIPT_GET_STATUS];
regs->asc_cmd = ASC_CMD_I_COMPLETE;
/*
* Disconnects can happen normally when the
* command is complete with the phase being
- * either ASC_PHASE_DATAO or ASC_PHASE_MSG_IN.
+ * either SCSI_PHASE_DATAO or SCSI_PHASE_MSG_IN.
* The SCRIPT_MATCH() only checks for one phase
* so we can wind up here.
* Perform the appropriate operation, then proceed.
status = asc_wait(regs, ASC_CSR_INT);
ir = regs->asc_intr;
/* some just break out here, some dont */
- if (ASC_PHASE(status) == ASC_PHASE_MSG_OUT) {
+ if (ASC_PHASE(status) == SCSI_PHASE_MSG_OUT) {
regs->asc_fifo = SCSI_ABORT;
regs->asc_cmd = ASC_CMD_XFER_INFO;
readback(regs->asc_cmd);
int flag;
{
register volatile u_int *ssr = (volatile u_int *)
- ASIC_REG_CSR(asic_base);
+ IOASIC_REG_CSR(ioasic_base);
u_int phys, nphys;
/* stop DMA engine first */
- *ssr &= ~ASIC_CSR_DMAEN_SCSI;
- *((volatile int *)ASIC_REG_SCSI_SCR(asic_base)) = 0;
+ *ssr &= ~IOASIC_CSR_DMAEN_SCSI;
+ *((volatile int *)IOASIC_REG_SCSI_SCR(ioasic_base)) = 0;
phys = MACH_CACHED_TO_PHYS(cp);
cp = (caddr_t)pmax_trunc_page(cp + NBPG);
asc->dma_next = cp;
asc->dma_xfer = state->dmalen - (nphys - phys);
- *(volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base) =
- ASIC_DMA_ADDR(phys);
- *(volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base) =
- ASIC_DMA_ADDR(nphys);
+ *(volatile int *)IOASIC_REG_SCSI_DMAPTR(ioasic_base) =
+ IOASIC_DMA_ADDR(phys);
+ *(volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base) =
+ IOASIC_DMA_ADDR(nphys);
if (flag == ASCDMA_READ)
- *ssr |= ASIC_CSR_SCSI_DIR | ASIC_CSR_DMAEN_SCSI;
+ *ssr |= IOASIC_CSR_SCSI_DIR | IOASIC_CSR_DMAEN_SCSI;
else
- *ssr = (*ssr & ~ASIC_CSR_SCSI_DIR) | ASIC_CSR_DMAEN_SCSI;
+ *ssr = (*ssr & ~IOASIC_CSR_SCSI_DIR) | IOASIC_CSR_DMAEN_SCSI;
MachEmptyWriteBuffer();
}
int flag;
{
register volatile u_int *ssr = (volatile u_int *)
- ASIC_REG_CSR(asic_base);
+ IOASIC_REG_CSR(ioasic_base);
register volatile u_int *dmap = (volatile u_int *)
- ASIC_REG_SCSI_DMAPTR(asic_base);
+ IOASIC_REG_SCSI_DMAPTR(ioasic_base);
register u_short *to;
register int w;
int nb;
- *ssr &= ~ASIC_CSR_DMAEN_SCSI;
+ *ssr &= ~IOASIC_CSR_DMAEN_SCSI;
to = (u_short *)MACH_PHYS_TO_CACHED(*dmap >> 3);
*dmap = -1;
- *((volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base)) = -1;
+ *((volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base)) = -1;
MachEmptyWriteBuffer();
if (flag == ASCDMA_READ) {
MachFlushDCache(MACH_PHYS_TO_CACHED(
MACH_UNCACHED_TO_PHYS(state->dmaBufAddr)), state->dmalen);
- if (nb = *((int *)ASIC_REG_SCSI_SCR(asic_base))) {
+ if (nb = *((int *)IOASIC_REG_SCSI_SCR(ioasic_base))) {
/* pick up last upto6 bytes, sigh. */
/* Last byte really xferred is.. */
- w = *(int *)ASIC_REG_SCSI_SDR0(asic_base);
+ w = *(int *)IOASIC_REG_SCSI_SDR0(ioasic_base);
*to++ = w;
if (--nb > 0) {
w >>= 16;
*to++ = w;
}
if (--nb > 0) {
- w = *(int *)ASIC_REG_SCSI_SDR1(asic_base);
+ w = *(int *)IOASIC_REG_SCSI_SDR1(ioasic_base);
*to++ = w;
}
}
void
asc_dma_intr()
{
- asc_softc_t asc = &asccd.cd_devs[0]; /*XXX*/
+ asc_softc_t asc = &asc_cd.cd_devs[0]; /*XXX*/
u_int next_phys;
asc->dma_xfer -= NBPG;
if (asc->dma_xfer <= -NBPG) {
volatile u_int *ssr = (volatile u_int *)
- ASIC_REG_CSR(asic_base);
- *ssr &= ~ASIC_CSR_DMAEN_SCSI;
+ IOASIC_REG_CSR(ioasic_base);
+ *ssr &= ~IOASIC_CSR_DMAEN_SCSI;
} else {
asc->dma_next += NBPG;
next_phys = MACH_CACHED_TO_PHYS(asc->dma_next);
}
- *(volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base) =
- ASIC_DMA_ADDR(next_phys);
+ *(volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base) =
+ IOASIC_DMA_ADDR(next_phys);
MachEmptyWriteBuffer();
}
#endif /*notdef*/
-# $OpenBSD: files.tc,v 1.2 1996/04/18 23:48:21 niklas Exp $
-# $NetBSD: files.tc,v 1.2 1996/02/27 22:00:04 cgd Exp $
+# $OpenBSD: files.tc,v 1.3 1996/04/21 22:26:22 deraadt Exp $
+# $NetBSD: files.tc,v 1.3 1996/03/17 00:58:33 thorpej Exp $
#
# Config.new file and device description for machine-independent
# TurboChannel code. Included by ports that need it.
-device tc at tcbus {[slot = -1], [offset = -1]}
+device tc {[slot = -1], [offset = -1]}
+attach tc at tcbus
file dev/tc/tc.c tc needs-flag
# XXX conflicts with ISA if_le.c
-#device le at ioasic, tc: ether, ifnet # XXX PMAX BASEBOARD OPTIONS
+#device le: ether, ifnet # XXX PMAX BASEBOARD OPTIONS
+#attach le at ioasic, tc with le_tc
#file dev/tc/if_le.c le needs-flag # for le_iomem
-/* $OpenBSD: if_le.c,v 1.2 1996/04/18 23:48:21 niklas Exp $ */
-/* $NetBSD: if_le.c,v 1.3 1996/02/26 23:38:38 cgd Exp $ */
+/* $OpenBSD: if_le.c,v 1.3 1996/04/21 22:26:24 deraadt Exp $ */
+/* $NetBSD: if_le.c,v 1.6 1996/04/08 20:09:56 jonathan Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
* @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
+
+/*
+ * Supported busses: DEC IOCTL asic baseboard device, TurboChannel option,
+ * plus baseboard device on "busless" DECstations.
+ */
#ifdef alpha
#define CAN_HAVE_IOASIC 1
#define CAN_HAVE_TC 1
#define CAN_HAVE_IOASIC 1
#define CAN_HAVE_TC 1
#define CAN_HAVE_MAINBUS 1
-#endif
+#endif /* pmax */
+
+
+/*
+ * For each bus on which a LANCE device might appear, determine
+ * if that bus was configured into the current kernel.
+ */
-#include "bpfilter.h"
#ifdef CAN_HAVE_MAINBUS
/*XXX TEST FOR KN01 OR MIPSFAIR? */
#endif
#include "ioasic.h"
#endif
+#include "bpfilter.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#endif
#if CAN_HAVE_MAINBUS
#include <pmax/pmax/kn01.h>
-extern struct cfdriver mainbuscd; /* XXX */
+#include <pmax/pmax/kn01var.h>
+extern struct cfdriver mainbus_cd; /* XXX */
#endif
#include <dev/tc/if_levar.h>
#include <dev/ic/am7990var.h>
/* access LANCE registers */
-void lewritereg();
+void lewritereg __P((volatile u_short *regptr, u_short val));
#define LERDWR(cntl, src, dst) { (dst) = (src); tc_mb(); }
#define LEWREG(src, dst) lewritereg(&(dst), (src))
extern caddr_t le_iomem;
-#define LE_SOFTC(unit) lecd.cd_devs[unit]
+#define LE_SOFTC(unit) le_cd.cd_devs[unit]
#define LE_DELAY(x) DELAY(x)
-int lematch __P((struct device *, void *, void *));
-void leattach __P((struct device *, struct device *, void *));
+int le_tc_match __P((struct device *, void *, void *));
+void le_tc_attach __P((struct device *, struct device *, void *));
int leintr __P((void *));
-struct cfdriver lecd = {
- NULL, "le", lematch, leattach, DV_IFNET, sizeof (struct le_softc)
+struct cfattach le_tc_ca = {
+ sizeof(struct le_softc), le_tc_match, le_tc_attach
+};
+
+struct cfdriver le_cd = {
+ NULL, "le", DV_IFNET
};
integrate void
}
int
-lematch(parent, match, aux)
+le_tc_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
#if CAN_HAVE_IOASIC && (NIOASIC > 0)
- if (parent->dv_cfdata->cf_driver == &ioasiccd) {
+ if (parent->dv_cfdata->cf_driver == &ioasic_cd) {
struct ioasicdev_attach_args *d = aux;
- if (!ioasic_submatch(match, aux))
+ if (!ioasic_submatch(match, aux)) {
return (0);
- if (strncmp("lance ", d->iada_modname, TC_ROM_LLEN))
+ }
+ if (strncmp("lance", d->iada_modname, TC_ROM_LLEN)) {
return (0);
+ }
} else
#endif /* IOASIC */
+
#if CAN_HAVE_TC && (NTC > 0)
- if (parent->dv_cfdata->cf_driver == &tccd) {
- struct tcdev_attach_args *d = aux;
+ if (parent->dv_cfdata->cf_driver == &tc_cd) {
+ struct tc_attach_args *d = aux;
- if (strncmp("PMAD-AA ", d->tcda_modname, TC_ROM_LLEN) &&
- strncmp("PMAD-BA ", d->tcda_modname, TC_ROM_LLEN))
+ if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) &&
+ strncmp("PMAD-BA ", d->ta_modname, TC_ROM_LLEN))
return (0);
} else
#endif /* TC */
-#if CAN_HAVE_MAINBUS /* XXX TEST FOR KN01 OR MIPSFAIR? */
- if (parent->dv_cfdata->cf_driver == &mainbuscd) {
- /* XXX VARIOUS PMAX BASEBOARD CASES? */
+
+#if CAN_HAVE_MAINBUS && defined(DS3100)
+ if (parent->dv_cfdata->cf_driver == &mainbus_cd) {
+ struct confargs *d = aux;
+ if (strcmp("lance", d->ca_name) != 0)
+ return (0);
} else
#endif /* MAINBUS */
return (0);
return (1);
}
+typedef void (*ie_fn_t) __P((struct device *, void *,
+ tc_intrlevel_t, int (*)(void *), void *));
+
void
-leattach(parent, self, aux)
+le_tc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
register struct le_softc *sc = (void *)self;
- void (*ie_fn) __P((struct device *, void *, tc_intrlevel_t,
- int (*)(void *), void *));
+ ie_fn_t ie_fn;
u_char *cp; /* pointer to MAC address */
int i;
#if CAN_HAVE_IOASIC && (NIOASIC > 0)
- if (parent->dv_cfdata->cf_driver == &ioasiccd) {
+ if (parent->dv_cfdata->cf_driver == &ioasic_cd) {
struct ioasicdev_attach_args *d = aux;
/* It's on the system IOCTL ASIC */
} else
#endif /* IOASIC */
#if CAN_HAVE_TC && (NTC > 0)
- if (parent->dv_cfdata->cf_driver == &tccd) {
- struct tcdev_attach_args *d = aux;
+ if (parent->dv_cfdata->cf_driver == &tc_cd) {
+ struct tc_attach_args *d = aux;
/*
* It's on the turbochannel proper, or a kn02
* baseboard implementation of a TC option card.
*/
- sc->sc_r1 = (struct lereg1 *)(d->tcda_addr + LE_OFFSET_LANCE);
- sc->sc_mem = (void *)(d->tcda_addr + LE_OFFSET_RAM);
- cp = (u_char *)(d->tcda_addr + LE_OFFSET_ROM + 2);
+ sc->sc_r1 = (struct lereg1 *)(d->ta_addr + LE_OFFSET_LANCE);
+ sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
+ cp = (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2);
sc->sc_copytodesc = copytobuf_contig;
sc->sc_copyfromdesc = copyfrombuf_contig;
sc->sc_copyfrombuf = copyfrombuf_contig;
sc->sc_zerobuf = zerobuf_contig;
- sc->sc_cookie = d->tcda_cookie;
+ sc->sc_cookie = d->ta_cookie;
/*
* TC lance boards have onboard SRAM buffers. DMA
* between the onbard RAM and main memory is not possible,
ie_fn = tc_intr_establish;
} else
#endif /* TC */
-#if CAN_HAVE_MAINBUS /* XXX TEST FOR KN01 OR MIPSFAIR? */
- if (parent->dv_cfdata->cf_driver == &mainbuscd) {
+#if CAN_HAVE_MAINBUS && defined(DS3100)
+ if (parent->dv_cfdata->cf_driver == &mainbus_cd) {
struct confargs *ca = aux;
/*
sc->sc_zerobuf = zerobuf_gap2;
sc->sc_cookie = (void *)ca->ca_slotpri; /*XXX more thought */
- /* XXX BASEBOARD INTERRUPT ESTABLISH FUNCTION? */
+ ie_fn = (ie_fn_t) kn01_intr_establish;
} else
#endif /* MAINBUS */
- panic("leattach: can't be here");
+ panic("le_tc_attach: can't be here");
sc->sc_conf3 = 0;
sc->sc_addr = 0;
cp += 4;
}
- sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
+ sc->sc_arpcom.ac_if.if_name = le_cd.cd_name;
leconfig(sc);
(*ie_fn)(parent, sc->sc_cookie, TC_IPL_NET, leintr, sc);
-/* $NetBSD: ioasicvar.h,v 1.1 1995/12/20 00:50:42 cgd Exp $ */
+/* $NetBSD: ioasicvar.h,v 1.2 1996/03/17 21:37:45 jonathan Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* The IOASIC (bus) cfdriver, so that subdevices can more
* easily tell what bus they're on.
*/
-extern struct cfdriver ioasiccd;
+extern struct cfdriver ioasic_cd;
/*
-/* $OpenBSD: tc.c,v 1.2 1996/04/18 23:48:22 niklas Exp $ */
-/* $NetBSD: tc.c,v 1.10 1996/03/05 23:15:07 cgd Exp $ */
+/* $OpenBSD: tc.c,v 1.3 1996/04/21 22:26:28 deraadt Exp $ */
+/* $NetBSD: tc.c,v 1.13 1996/04/09 20:50:06 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/device.h>
#include <dev/tc/tcreg.h>
#include <dev/tc/tcvar.h>
#include <dev/tc/tcdevs.h>
+#include <machine/autoconf.h>
+
struct tc_softc {
struct device sc_dv;
/* Definition of the driver for autoconfig. */
int tcmatch __P((struct device *, void *, void *));
void tcattach __P((struct device *, struct device *, void *));
-struct cfdriver tccd =
- { NULL, "tc", tcmatch, tcattach, DV_DULL, sizeof (struct tc_softc) };
+
+struct cfattach tc_ca = {
+ sizeof(struct tc_softc), tcmatch, tcattach
+};
+
+struct cfdriver tc_cd = {
+ NULL, "tc", DV_DULL
+};
int tcprint __P((void *, char *));
int tcsubmatch __P((struct device *, void *, void *));
const struct tc_builtin *builtin;
struct tc_slotdesc *slot;
tc_addr_t tcaddr;
- void *match;
int i;
printf("%s MHz clock\n",
(cf->tccf_offset != d->ta_offset))
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
-/* $OpenBSD: tcvar.h,v 1.2 1996/04/18 23:48:24 niklas Exp $ */
-/* $NetBSD: tcvar.h,v 1.3 1996/02/27 01:37:33 cgd Exp $ */
+/* $OpenBSD: tcvar.h,v 1.3 1996/04/21 22:26:30 deraadt Exp $ */
+/* $NetBSD: tcvar.h,v 1.4 1996/03/17 21:37:47 jonathan Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* The TurboChannel bus cfdriver, so that subdevices can more
* easily tell what bus they're on.
*/
-extern struct cfdriver tccd;
+extern struct cfdriver tc_cd;
#endif /* __DEV_TC_TCVAR_H__ */
-/* $OpenBSD: vnd.c,v 1.5 1996/03/02 00:29:25 niklas Exp $ */
-/* $NetBSD: vnd.c,v 1.24 1996/02/10 00:11:44 christos Exp $ */
+/* $OpenBSD: vnd.c,v 1.6 1996/04/21 22:19:59 deraadt Exp $ */
+/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#include <sys/device.h>
#include <sys/disk.h>
#include <sys/stat.h>
-#include <sys/conf.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/uio.h>
+#include <sys/conf.h>
#include <miscfs/specfs/specdev.h>
struct vnd_softc *vnd_softc;
int numvnd = 0;
-/* {b,c}devsw[] function prototypes XXX: move them to dev_conf.h */
-bdev_decl(vnd);
-cdev_decl(vnd);
-
/* called by main() at boot time */
void vndattach __P((int));
vnd->sc_tab.b_actf = bp->b_actf;
#ifdef DEBUG
if (vnddebug & VDB_IO)
- printf("vndstart(%d): bp %p vp %p blkno %x addr %p cnt %x\n",
+ printf("vndstart(%d): bp %p vp %p blkno %x addr %p cnt %lx\n",
vnd-vnd_softc, bp, bp->b_vp, bp->b_blkno, bp->b_data,
bp->b_bcount);
#endif
s = splbio();
#ifdef DEBUG
if (vnddebug & VDB_IO)
- printf("vndiodone(%d): vbp %p vp %p blkno %x addr %p cnt %x\n",
+ printf("vndiodone(%d): vbp %p vp %p blkno %x addr %p cnt %lx\n",
vnd-vnd_softc, vbp, vbp->vb_buf.b_vp, vbp->vb_buf.b_blkno,
vbp->vb_buf.b_data, vbp->vb_buf.b_bcount);
#endif
-/* $OpenBSD: cd9660_vnops.c,v 1.4 1996/04/19 16:08:43 niklas Exp $ */
-/* $NetBSD: cd9660_vnops.c,v 1.31 1996/03/08 18:13:07 scottr Exp $ */
+/* $OpenBSD: cd9660_vnops.c,v 1.5 1996/04/21 22:26:38 deraadt Exp $ */
+/* $NetBSD: cd9660_vnops.c,v 1.32 1996/03/16 20:25:40 ws Exp $ */
/*-
* Copyright (c) 1994
--idp->ncookies;
}
- if ((error = uiomove((caddr_t) dp,dp->d_reclen,idp->uio)) != 0)
+ if ((error = uiomove((caddr_t)dp, dp->d_reclen, idp->uio)) != 0)
return (error);
idp->uio_off = off;
return (0);
cl = idp->current.d_namlen;
cname = idp->current.d_name;
- if ((assoc = (cl > 1)) && *cname == ASSOCCHAR) {
+ if ((assoc = cl > 1 && *cname == ASSOCCHAR)) {
cl--;
cname++;
}
struct vop_link_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
- struct componentname *a_cnp;
+ struct componentname *a_cnp;
} */ *ap = v;
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
}
/*
- * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually
+ * cd9660 abort op, called after namei() when a CREATE/DELETE isn't actually
* done. If a buffer has been saved in anticipation of a CREATE, delete it.
*/
int
struct proc *p = curproc; /* XXX */
if ((ip->i_flag & IN_LOCKED) == 0) {
- vprint("ufs_unlock: unlocked inode", ap->a_vp);
- panic("ufs_unlock NOT LOCKED");
+ vprint("cd9660_unlock: unlocked inode", ap->a_vp);
+ panic("cd9660_unlock NOT LOCKED");
}
if (p && p->p_pid != ip->i_lockholder && p->p_pid > -1 &&
ip->i_lockholder > -1/* && lockcount++ < 100*/)
-/* $OpenBSD: iso.h,v 1.2 1996/02/29 10:12:30 niklas Exp $ */
-/* $NetBSD: iso.h,v 1.10 1996/02/09 21:32:11 christos Exp $ */
+/* $OpenBSD: iso.h,v 1.3 1996/04/21 22:26:41 deraadt Exp $ */
+/* $NetBSD: iso.h,v 1.11 1996/03/16 20:25:42 ws Exp $ */
/*-
* Copyright (c) 1994
isonum_723(u_char *p)
#else
isonum_723(p)
- u_char *p
+ u_char *p;
#endif
{
return *(u_int16t *)p;
isonum_723(u_char *p)
#else
isonum_723(p)
- u_char *p
+ u_char *p;
#endif
{
return *(u_int16t *)(p + 2);
-/* $OpenBSD: init_main.c,v 1.4 1996/03/03 17:19:39 niklas Exp $ */
-/* $NetBSD: init_main.c,v 1.82 1996/02/09 18:59:21 christos Exp $ */
+/* $OpenBSD: init_main.c,v 1.5 1996/04/21 22:26:50 deraadt Exp $ */
+/* $NetBSD: init_main.c,v 1.83 1996/04/04 00:26:28 cgd Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
vm_mem_init();
kmeminit();
disk_init(); /* must come before autoconfiguration */
+ config_init(); /* init autoconfiguration data structures */
cpu_startup();
/*
-/* $OpenBSD: kern_clock.c,v 1.8 1996/04/19 16:08:50 niklas Exp $ */
+/* $OpenBSD: kern_clock.c,v 1.9 1996/04/21 22:26:53 deraadt Exp $ */
/* $NetBSD: kern_clock.c,v 1.31 1996/03/15 07:56:00 mycroft Exp $ */
/*-
extern long timedelta;
#ifdef NTP
register int time_update;
+ struct timeval newtime;
register int ltemp;
#endif
tickfixcnt = 0;
}
}
+#else
+ newtime = time;
#endif /* !NTP */
/* Imprecise 4bsd adjtime() handling */
if (timedelta != 0) {
clock_offset.tv_sec--;
clock_offset.tv_usec += 1000000;
}
- time.tv_usec += clock_cpu;
+ newtime.tv_usec += clock_cpu;
clock_cpu = 0;
#else
- time.tv_usec += time_update;
+ newtime.tv_usec += time_update;
#endif /* HIGHBALL */
/*
* maximum frequency offset is a tad less than) +-512 ppm. On a
* 64-bit machine, you shouldn't need to ask.
*/
- if (time.tv_usec >= 1000000) {
- time.tv_usec -= 1000000;
- time.tv_sec++;
+ if (newtime.tv_usec >= 1000000) {
+ newtime.tv_usec -= 1000000;
+ newtime.tv_sec++;
time_maxerror += time_tolerance >> SHIFT_USEC;
/*
break;
case TIME_INS:
- if (time.tv_sec % 86400 == 0) {
- time.tv_sec--;
+ if (newtime.tv_sec % 86400 == 0) {
+ newtime.tv_sec--;
time_state = TIME_OOP;
}
break;
case TIME_DEL:
- if ((time.tv_sec + 1) % 86400 == 0) {
- time.tv_sec++;
+ if ((newtime.tv_sec + 1) % 86400 == 0) {
+ newtime.tv_sec++;
time_state = TIME_WAIT;
}
break;
if (clock_count > CLOCK_INTERVAL) {
clock_count = 0;
microtime(&clock_ext);
- delta.tv_sec = clock_ext.tv_sec - time.tv_sec;
+ delta.tv_sec = clock_ext.tv_sec - newtime.tv_sec;
delta.tv_usec = clock_ext.tv_usec -
- time.tv_usec;
+ newtime.tv_usec;
if (delta.tv_usec < 0)
delta.tv_sec--;
if (delta.tv_usec >= 500000) {
delta.tv_usec > MAXPHASE) ||
delta.tv_sec < -1 || (delta.tv_sec == -1 &&
delta.tv_usec < -MAXPHASE)) {
- time = clock_ext;
+ newtime = clock_ext;
delta.tv_sec = 0;
delta.tv_usec = 0;
}
#endif /* EXT_CLOCK */
}
+#ifdef CPU_CLOCKUPDATE
+ CPU_CLOCKUPDATE(&time, &newtime);
+#else
+ time = newtime;
+#endif
+
#endif /* NTP */
/*
+++ /dev/null
-/* $OpenBSD: kern_conf.h,v 1.2 1996/04/19 16:08:52 niklas Exp $ */
-/* $NetBSD: kern_conf.h,v 1.2 1996/03/14 19:01:08 christos Exp $ */
-
-/*
- * Copyright (c) 1995 Christos Zoulas. 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 Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/conf.h>
-
-cdev_decl(filedesc);
-
-cdev_decl(log);
-
-#ifndef LKM
-# define NLKM 0
-# define lkmenodev enodev
-#else
-# define NLKM 1
-#endif
-cdev_decl(lkm);
-
-#include "pty.h"
-#define ptstty ptytty
-#define ptsioctl ptyioctl
-cdev_decl(pts);
-#define ptctty ptytty
-#define ptcioctl ptyioctl
-cdev_decl(ptc);
-
-cdev_decl(ctty);
-/* $OpenBSD: kern_descrip.c,v 1.4 1996/04/19 16:08:53 niklas Exp $ */
-/* $NetBSD: kern_descrip.c,v 1.40 1996/03/14 19:01:10 christos Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.5 1996/04/21 22:26:59 deraadt Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
#include <sys/syslog.h>
#include <sys/unistd.h>
#include <sys/resourcevar.h>
+#include <sys/conf.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <vm/vm.h>
-#include <kern/kern_conf.h>
-
/*
* Descriptor management.
*/
return (0);
}
error = (*fp->f_ops->fo_ioctl)
- (fp, (int)TIOCGPGRP, (caddr_t)retval, p);
+ (fp, TIOCGPGRP, (caddr_t)retval, p);
*retval = -*retval;
return (error);
SCARG(uap, arg) = (void *)(long)p1->p_pgrp->pg_id;
}
return ((*fp->f_ops->fo_ioctl)
- (fp, (int)TIOCSPGRP, (caddr_t)&SCARG(uap, arg), p));
+ (fp, TIOCSPGRP, (caddr_t)&SCARG(uap, arg), p));
case F_SETLKW:
flg |= F_WAIT;
-/* $OpenBSD: kern_lkm.c,v 1.2 1996/03/03 17:19:47 niklas Exp $ */
-/* $NetBSD: kern_lkm.c,v 1.28 1996/02/09 18:59:38 christos Exp $ */
+/* $OpenBSD: kern_lkm.c,v 1.3 1996/04/21 22:27:01 deraadt Exp $ */
+/* $NetBSD: kern_lkm.c,v 1.31 1996/03/31 21:40:27 christos Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
#include <sys/mount.h>
#include <sys/exec.h>
#include <sys/syscallargs.h>
-
-#include <kern/kern_conf.h>
+#include <sys/conf.h>
#include <sys/lkm.h>
#include <sys/syscall.h>
resrvp->addr = curp->area; /* ret kernel addr */
#ifdef DEBUG
- printf("LKM: LMRESERV (actual = 0x%08x)\n", curp->area);
- printf("LKM: LMRESERV (adjusted = 0x%08x)\n",
+ printf("LKM: LMRESERV (actual = 0x%08lx)\n", curp->area);
+ printf("LKM: LMRESERV (adjusted = 0x%08lx)\n",
trunc_page(curp->area));
#endif /* DEBUG */
lkm_state = LKMS_RESERVED;
if ((curp->offset + i) < curp->size) {
lkm_state = LKMS_LOADING;
#ifdef DEBUG
- printf("LKM: LMLOADBUF (loading @ %d of %d, i = %d)\n",
+ printf("LKM: LMLOADBUF (loading @ %ld of %ld, i = %d)\n",
curp->offset, curp->size, i);
#endif /* DEBUG */
} else {
* Place holder for device switch slots reserved for loadable modules.
*/
int
-lkmenodev(dev, oflags, devtype, p)
- dev_t dev;
- int oflags, devtype;
- struct proc *p;
+lkmenodev()
{
return (enodev());
* Search the table looking for a slot...
*/
for (i = 0; i < nblkdev; i++)
- if (bdevsw[i].d_open == lkmenodev)
+ if (bdevsw[i].d_open ==
+ (dev_type_open((*))) lkmenodev)
break; /* found it! */
/* out of allocable slots? */
if (i == nblkdev) {
* Search the table looking for a slot...
*/
for (i = 0; i < nchrdev; i++)
- if (cdevsw[i].d_open == lkmenodev)
+ if (cdevsw[i].d_open ==
+ (dev_type_open((*))) lkmenodev)
break; /* found it! */
/* out of allocable slots? */
if (i == nchrdev) {
-/* $OpenBSD: kern_malloc.c,v 1.3 1996/04/19 16:08:55 niklas Exp $ */
-/* $NetBSD: kern_malloc.c,v 1.14 1996/02/20 23:56:16 cgd Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.4 1996/04/21 22:27:03 deraadt Exp $ */
+/* $NetBSD: kern_malloc.c,v 1.15 1996/03/16 23:17:06 christos Exp $ */
/*
* Copyright (c) 1987, 1991, 1993
memname[freep->type] : "???";
if (kbp->kb_next &&
!kernacc(kbp->kb_next, sizeof(struct freelist), 0)) {
- printf("%s %d of object %p size %d %s %s (invalid addr %p)\n",
+ printf("%s %d of object %p size %ld %s %s (invalid addr %p)\n",
"Data modified on freelist: word",
(int32_t *)&kbp->kb_next - (int32_t *)kbp, va, size,
"previous type", savedtype, kbp->kb_next);
for (lp = (int32_t *)va; lp < end; lp++) {
if (*lp == WEIRD_ADDR)
continue;
- printf("%s %d of object %p size %d %s %s (0x%x != 0x%x)\n",
+ printf("%s %d of object %p size %ld %s %s (0x%x != 0x%x)\n",
"Data modified on freelist: word", lp - (int32_t *)va,
va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
break;
else
alloc = addrmask[kup->ku_indx];
if (((u_long)addr & alloc) != 0)
- panic("free: unaligned addr 0x%x, size %d, type %s, mask %d\n",
+ panic("free: unaligned addr %p, size %ld, type %s, mask %ld\n",
addr, size, memname[type], alloc);
#endif /* DIAGNOSTIC */
if (size > MAXALLOCSAVE) {
-/* $NetBSD: kern_subr.c,v 1.14 1995/05/31 20:41:44 cgd Exp $ */
+/* $NetBSD: kern_subr.c,v 1.15 1996/04/09 17:21:56 ragge Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
-/* $OpenBSD: kern_synch.c,v 1.2 1996/03/03 17:19:55 niklas Exp $ */
-/* $NetBSD: kern_synch.c,v 1.35 1996/02/09 18:59:50 christos Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.3 1996/04/21 22:27:08 deraadt Exp $ */
+/* $NetBSD: kern_synch.c,v 1.36 1996/03/30 22:23:25 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
while (p != 0) {
pp = p->p_pptr;
if (p->p_stat) {
- db_printf("%5d %06x %06x ",
+ db_printf("%5d %p %p ",
p->p_pid, p, p->p_addr);
if (map)
- db_printf("%06x %s ",
+ db_printf("%p %s ",
p->p_vmspace, p->p_comm);
else
db_printf("%3d %5d %5d %06x %d %s %s ",
if (p->p_wchan) {
if (p->p_wmesg)
db_printf("%s ", p->p_wmesg);
- db_printf("%x", p->p_wchan);
+ db_printf("%p", p->p_wchan);
}
db_printf("\n");
}
-/* $OpenBSD: kern_sysctl.c,v 1.4 1996/04/19 16:08:59 niklas Exp $ */
-/* $NetBSD: kern_sysctl.c,v 1.15 1996/02/27 04:20:40 jonathan Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.5 1996/04/21 22:27:10 deraadt Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.16 1996/04/12 23:21:37 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
return (error);
if (SCARG(uap, oldlenp))
error = copyout(&oldlen, SCARG(uap, oldlenp), sizeof(oldlen));
- *retval = oldlen;
- return (0);
+ return (error);
}
/*
-/* $OpenBSD: subr_autoconf.c,v 1.3 1996/04/19 16:09:01 niklas Exp $ */
-/* $NetBSD: subr_autoconf.c,v 1.18 1996/02/27 21:45:46 cgd Exp $ */
+/* $OpenBSD: subr_autoconf.c,v 1.4 1996/04/21 22:27:13 deraadt Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
static char *number __P((char *, int));
static void mapply __P((struct matchinfo *, struct cfdata *));
+struct devicelist alldevs; /* list of all devices */
+struct evcntlist allevents; /* list of all event counters */
+
+/*
+ * Initialize autoconfiguration data structures.
+ */
+void
+config_init()
+{
+
+ TAILQ_INIT(&alldevs);
+ TAILQ_INIT(&allevents);
+}
+
/*
* Apply the matching function and choose the best. This is used
* a few times and we want to keep the code small.
if (m->fn != NULL)
pri = (*m->fn)(m->parent, match, m->aux);
else {
- if (cf->cf_driver->cd_match == NULL) {
+ if (cf->cf_attach->ca_match == NULL) {
panic("mapply: no match function for '%s' device\n",
cf->cf_driver->cd_name);
}
- pri = (*cf->cf_driver->cd_match)(m->parent, match, m->aux);
+ pri = (*cf->cf_attach->ca_match)(m->parent, match, m->aux);
}
if (pri > m->pri) {
* functions) and attach it, and return true. If the device was
* not configured, call the given `print' function and return 0.
*/
-int
+struct device *
config_found_sm(parent, aux, print, submatch)
struct device *parent;
void *aux;
{
void *match;
- if ((match = config_search(submatch, parent, aux)) != NULL) {
- config_attach(parent, match, aux, print);
- return (1);
- }
+ if ((match = config_search(submatch, parent, aux)) != NULL)
+ return (config_attach(parent, match, aux, print));
if (print)
printf(msgs[(*print)(aux, parent->dv_xname)]);
- return (0);
+ return (NULL);
}
/*
* As above, but for root devices.
*/
-int
+struct device *
config_rootfound(rootname, aux)
char *rootname;
void *aux;
{
void *match;
- if ((match = config_rootsearch((cfmatch_t)NULL, rootname, aux))
- != NULL) {
- config_attach(ROOT, match, aux, (cfprint_t)NULL);
- return (1);
- }
+ if ((match = config_rootsearch((cfmatch_t)NULL, rootname, aux)) != NULL)
+ return (config_attach(ROOT, match, aux, (cfprint_t)NULL));
printf("root device %s not configured\n", rootname);
- return (0);
+ return (NULL);
}
/* just like sprintf(buf, "%d") except that it works from the end */
/*
* Attach a found device. Allocates memory for device variables.
*/
-void
+struct device *
config_attach(parent, match, aux, print)
register struct device *parent;
void *match;
register struct cfdata *cf;
register struct device *dev;
register struct cfdriver *cd;
- static struct device **nextp = &alldevs;
+ register struct cfattach *ca;
if (parent && parent->dv_cfdata->cf_driver->cd_indirect) {
dev = match;
}
cd = cf->cf_driver;
+ ca = cf->cf_attach;
cd->cd_devs[cf->cf_unit] = dev;
if (cf->cf_fstate == FSTATE_STAR)
else
cf->cf_fstate = FSTATE_FOUND;
- *nextp = dev; /* link up */
- nextp = &dev->dv_next;
+ TAILQ_INSERT_TAIL(&alldevs, dev, dv_list);
if (parent == ROOT)
printf("%s (root)", dev->dv_xname);
/*
* Before attaching, clobber any unfound devices that are
- * otherwise identical.
+ * otherwise identical, or bump the unit number on all starred
+ * cfdata for this device.
*/
for (cf = cfdata; cf->cf_driver; cf++)
- if (cf->cf_driver == cd && cf->cf_unit == dev->dv_unit &&
- cf->cf_fstate == FSTATE_NOTFOUND)
- cf->cf_fstate = FSTATE_FOUND;
- (*cd->cd_attach)(parent, dev, aux);
+ if (cf->cf_driver == cd && cf->cf_unit == dev->dv_unit) {
+ if (cf->cf_fstate == FSTATE_NOTFOUND)
+ cf->cf_fstate = FSTATE_FOUND;
+ if (cf->cf_fstate == FSTATE_STAR)
+ cf->cf_unit++;
+ }
+ (*ca->ca_attach)(parent, dev, aux);
+ return (dev);
}
struct device *
{
register struct device *dev;
register struct cfdriver *cd;
+ register struct cfattach *ca;
register size_t lname, lunit;
register char *xunit;
char num[10];
cd = cf->cf_driver;
- if (cd->cd_devsize < sizeof(struct device))
+ ca = cf->cf_attach;
+ if (ca->ca_devsize < sizeof(struct device))
panic("config_make_softc");
/* compute length of name and decimal expansion of unit number */
panic("config_attach: device name too long");
/* get memory for all device vars */
- dev = (struct device *)malloc(cd->cd_devsize, M_DEVBUF, M_NOWAIT);
+ dev = (struct device *)malloc(ca->ca_devsize, M_DEVBUF, M_NOWAIT);
if (!dev)
panic("config_attach: memory allocation for device softc failed");
- bzero(dev, cd->cd_devsize);
+ bzero(dev, ca->ca_devsize);
dev->dv_class = cd->cd_class;
dev->dv_cfdata = cf;
dev->dv_unit = cf->cf_unit;
const char *name;
struct evcnt *ev;
{
- static struct evcnt **nextp = &allevents;
#ifdef DIAGNOSTIC
if (strlen(name) >= sizeof(ev->ev_name))
ev->ev_dev = dev;
/* ev->ev_count = 0; */
strcpy(ev->ev_name, name);
- *nextp = ev;
- nextp = &ev->ev_next;
+ TAILQ_INSERT_TAIL(&allevents, ev, ev_list);
}
-/* $NetBSD: subr_disk.c,v 1.16 1996/02/09 18:59:56 christos Exp $ */
+/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
* Copyright (c) 1995 Jason R. Thorpe. All rights reserved.
int sn;
if (pri != LOG_PRINTF) {
- log(pri, "");
+ static const char fmt[] = "";
+ log(pri, fmt);
pr = addlog;
} else
pr = printf;
-/* $OpenBSD: subr_log.c,v 1.2 1996/03/03 17:20:00 niklas Exp $ */
-/* $NetBSD: subr_log.c,v 1.10 1996/02/09 18:59:58 christos Exp $ */
+/* $OpenBSD: subr_log.c,v 1.3 1996/04/21 22:27:17 deraadt Exp $ */
+/* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
#include <sys/file.h>
#include <sys/signalvar.h>
#include <sys/syslog.h>
-
-#include <kern/kern_conf.h>
+#include <sys/conf.h>
#define LOG_RDPRI (PZERO + 1)
-/* $OpenBSD: subr_prf.c,v 1.3 1996/04/19 16:09:03 niklas Exp $ */
-/* $NetBSD: subr_prf.c,v 1.22 1996/03/14 19:01:11 christos Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.4 1996/04/21 22:27:19 deraadt Exp $ */
+/* $NetBSD: subr_prf.c,v 1.24 1996/03/30 22:25:18 christos Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
#include <sys/tprintf.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
+#include <sys/cpu.h>
#include <dev/cons.h>
* and then reboots. If we are called twice, then we avoid trying to sync
* the disks as this often leads to recursive panics.
*/
-#ifdef __GNUC__
-volatile void boot(int flags); /* boot() does not return */
-volatile /* panic() does not return */
-#endif
void
#ifdef __STDC__
panic(const char *fmt, ...)
{
int bootopt;
va_list ap;
- static const char fm[] = "panic: %r\n";
bootopt = RB_AUTOBOOT | RB_DUMP;
if (panicstr)
panicstr = fmt;
va_start(ap, fmt);
- printf(fm, fmt, ap);
+ printf("panic: %:\n", fmt, ap);
va_end(ap);
#ifdef KGDB
*
* reg=3<BITTWO,BITONE>
*
- * The format %r passes an additional format string and argument list
+ * The format %: passes an additional format string and argument list
* recursively. Its usage is:
*
* fn(char *fmt, ...)
* {
* va_list ap;
* va_start(ap, fmt);
- * printf("prefix: %r: suffix\n", fmt, ap);
+ * printf("prefix: %: suffix\n", fmt, ap);
* va_end(ap);
* }
*
case 'c':
putchar(va_arg(ap, int), flags, tp);
break;
- case 'r':
+ case ':':
p = va_arg(ap, char *);
kprintf(p, flags, tp, va_arg(ap, va_list));
break;
-/* $OpenBSD: subr_prof.c,v 1.3 1996/03/03 17:20:01 niklas Exp $ */
-/* $NetBSD: subr_prof.c,v 1.10 1996/02/09 19:00:06 christos Exp $ */
+/* $OpenBSD: subr_prof.c,v 1.4 1996/04/21 22:27:21 deraadt Exp $ */
+/* $NetBSD: subr_prof.c,v 1.11 1996/03/17 02:44:40 pk Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
p->lowpc = ROUNDDOWN(KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER));
p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER));
p->textsize = p->highpc - p->lowpc;
- printf("Profiling kernel, textsize=%d [%p..%p]\n",
+ printf("Profiling kernel, textsize=%ld [%lx..%lx]\n",
p->textsize, p->lowpc, p->highpc);
p->kcountsize = p->textsize / HISTFRACTION;
p->hashfraction = HASHFRACTION;
/*
* Return kernel profiling information.
*/
-sysctl_doprof(name, namelen, oldp, oldlenp, newp, newlen, p)
+int
+sysctl_doprof(name, namelen, oldp, oldlenp, newp, newlen)
int *name;
u_int namelen;
void *oldp;
-/* $OpenBSD: subr_rmap.c,v 1.2 1996/03/03 17:20:02 niklas Exp $ */
-/* $NetBSD: subr_rmap.c,v 1.10 1996/02/04 02:16:49 christos Exp $ */
+/* $OpenBSD: subr_rmap.c,v 1.3 1996/04/21 22:27:23 deraadt Exp $ */
+/* $NetBSD: subr_rmap.c,v 1.11 1996/03/16 23:17:11 christos Exp $ */
/*
* Copyright (C) 1992, 1994 Wolfgang Solfrank.
*/
if (fp->m_size > size) {
/* range to free is smaller, so drop that */
- printf("rmfree: map '%s' loses space (%d)\n",
+ printf("rmfree: map '%s' loses space (%ld)\n",
mp->m_name, size);
return;
} else {
/* drop the smallest slot in the list */
- printf("rmfree: map '%s' loses space (%d)\n",
+ printf("rmfree: map '%s' loses space (%ld)\n",
mp->m_name, fp->m_size);
ovbcopy(fp + 1, fp,
(char *)(mp->m_limit - 1) - (char *)fp);
-/* $OpenBSD: sys_generic.c,v 1.2 1996/03/03 17:20:03 niklas Exp $ */
-/* $NetBSD: sys_generic.c,v 1.23 1996/02/09 19:00:09 christos Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.3 1996/04/21 22:27:24 deraadt Exp $ */
+/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
tmp = p1->p_pgrp->pg_id;
}
error = (*fp->f_ops->fo_ioctl)
- (fp, (int)TIOCSPGRP, (caddr_t)&tmp, p);
+ (fp, TIOCSPGRP, (caddr_t)&tmp, p);
break;
case FIOGETOWN:
-/* $OpenBSD: sysv_shm.c,v 1.3 1996/03/03 17:20:08 niklas Exp $ */
-/* $NetBSD: sysv_shm.c,v 1.36 1996/02/09 19:00:29 christos Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.4 1996/04/21 22:27:26 deraadt Exp $ */
+/* $NetBSD: sysv_shm.c,v 1.37 1996/03/16 23:17:13 christos Exp $ */
/*
* Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
return error;
if (SCARG(uap, size) && SCARG(uap, size) > shmseg->shm_segsz)
return EINVAL;
- if (SCARG(uap, shmflg) & (IPC_CREAT | IPC_EXCL) ==
+ if ((SCARG(uap, shmflg) & (IPC_CREAT | IPC_EXCL)) ==
(IPC_CREAT | IPC_EXCL))
return EEXIST;
*retval = IXSEQ_TO_IPCID(segnum, shmseg->shm_perm);
-/* $OpenBSD: tty.c,v 1.3 1996/03/03 17:20:09 niklas Exp $ */
-/* $NetBSD: tty.c,v 1.66 1996/02/09 19:00:38 christos Exp $ */
+/* $OpenBSD: tty.c,v 1.4 1996/04/21 22:27:28 deraadt Exp $ */
+/* $NetBSD: tty.c,v 1.68 1996/03/29 01:55:12 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
utime.tv_sec += 1;
utime.tv_usec -= 1000000;
}
- ttyprintf(tp, "%d.%02du ", utime.tv_sec,
+ ttyprintf(tp, "%ld.%02ldu ", utime.tv_sec,
utime.tv_usec / 10000);
/* Round up and print system time. */
stime.tv_sec += 1;
stime.tv_usec -= 1000000;
}
- ttyprintf(tp, "%d.%02ds ", stime.tv_sec,
+ ttyprintf(tp, "%ld.%02lds ", stime.tv_sec,
stime.tv_usec / 10000);
-#define pgtok(a) (((a) * NBPG) / 1024)
+#define pgtok(a) (((u_long) ((a) * NBPG) / 1024))
/* Print percentage cpu, resident set size. */
tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
- ttyprintf(tp, "%d%% %dk\n",
+ ttyprintf(tp, "%d%% %ldk\n",
tmp / 100,
pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
#ifdef pmap_resident_count
-/* $NetBSD: tty_pty.c,v 1.32 1996/02/09 19:00:41 christos Exp $ */
+/* $NetBSD: tty_pty.c,v 1.33 1996/03/30 22:24:45 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
#include <sys/vnode.h>
#include <sys/signalvar.h>
#include <sys/uio.h>
+#include <sys/conf.h>
-#undef NPTY /* XXX */
-#include <kern/kern_conf.h>
#if NPTY == 1
-/* $OpenBSD: tty_tty.c,v 1.2 1996/03/03 17:20:15 niklas Exp $ */
-/* $NetBSD: tty_tty.c,v 1.12 1996/02/04 02:17:39 christos Exp $ */
+/* $OpenBSD: tty_tty.c,v 1.3 1996/04/21 22:27:32 deraadt Exp $ */
+/* $NetBSD: tty_tty.c,v 1.13 1996/03/30 22:24:46 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
#include <sys/tty.h>
#include <sys/vnode.h>
#include <sys/file.h>
+#include <sys/conf.h>
-#include <kern/kern_conf.h>
#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
-/* $OpenBSD: vfs_cluster.c,v 1.2 1996/03/03 17:20:25 niklas Exp $ */
-/* $NetBSD: vfs_cluster.c,v 1.10 1996/02/09 19:00:56 christos Exp $ */
+/* $OpenBSD: vfs_cluster.c,v 1.3 1996/04/21 22:27:34 deraadt Exp $ */
+/* $NetBSD: vfs_cluster.c,v 1.11 1996/03/16 23:17:18 christos Exp $ */
/*-
* Copyright (c) 1993
#ifdef DIAGNOSTIC
if (size != vp->v_mount->mnt_stat.f_iosize)
- panic("cluster_rbuild: size %d != filesize %d\n",
+ panic("cluster_rbuild: size %ld != filesize %ld\n",
size, vp->v_mount->mnt_stat.f_iosize);
#endif
if (size * (lbn + run + 1) > filesize)
#ifdef DIAGNOSTIC
if (size != vp->v_mount->mnt_stat.f_iosize)
- panic("cluster_wbuild: size %d != filesize %d\n",
+ panic("cluster_wbuild: size %ld != filesize %ld\n",
size, vp->v_mount->mnt_stat.f_iosize);
#endif
redo:
/* Move memory from children to parent */
if (tbp->b_blkno != (bp->b_blkno + btodb(bp->b_bufsize))) {
- printf("Clustered Block: %d addr %x bufsize: %d\n",
+ printf("Clustered Block: %d addr %x bufsize: %ld\n",
bp->b_lblkno, bp->b_blkno, bp->b_bufsize);
printf("Child Block: %d addr: %x\n", tbp->b_lblkno,
tbp->b_blkno);
-/* $NetBSD: vfs_subr.c,v 1.51 1996/02/09 19:01:01 christos Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.52 1996/03/16 23:17:20 christos Exp $ */
/*
* Copyright (c) 1989, 1993
if (label != NULL)
printf("%s: ", label);
- printf("type %s, usecount %d, writecount %d, refcount %d,",
+ printf("type %s, usecount %d, writecount %d, refcount %ld,",
typename[vp->v_type], vp->v_usecount, vp->v_writecount,
vp->v_holdcnt);
buf[0] = '\0';
-/* $OpenBSD: vfs_syscalls.c,v 1.5 1996/04/17 05:09:14 mickey Exp $ */
-/* $NetBSD: vfs_syscalls.c,v 1.68 1996/02/09 19:01:05 christos Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.6 1996/04/21 22:27:39 deraadt Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.70 1996/03/22 06:51:04 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
void *v;
register_t *retval;
{
+#ifndef FIFO
+ return (EOPNOTSUPP);
+#else
register struct sys_mkfifo_args /* {
syscallarg(char *) path;
syscallarg(int) mode;
int error;
struct nameidata nd;
-#ifndef FIFO
- return (EOPNOTSUPP);
-#else
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
if ((error = namei(&nd)) != 0)
return (error);
goto out;
}
- if (vp->v_flag & VTEXT)
- (void)vnode_pager_uncache(vp);
+ (void)vnode_pager_uncache(vp);
+
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
-# $NetBSD: Makefile.inc,v 1.3 1995/10/20 01:15:37 cgd Exp $
+# $OpenBSD: Makefile.inc,v 1.3 1996/04/21 22:27:45 deraadt Exp $
+# $NetBSD: Makefile.inc,v 1.4 1996/04/13 01:17:27 cgd Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
bcmp.c bzero.S ffs.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c \
strncpy.c scanc.c skpc.c locc.c htonl.c htons.c ntohl.c ntohs.c \
- random.c
+ random.c strncasecmp.c
# `source' files built from m4 source
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
--- /dev/null
+# $Id: Makefile.inc,v 1.1 1996/04/21 22:27:47 deraadt Exp $
+
+SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
+ bcmp.c bzero.c ffs.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c \
+ strncpy.c scanc.c skpc.c locc.c htonl.c htons.c ntohl.c ntohs.c \
+ div.S random.c strncasecmp.c
--- /dev/null
+fp .req r11
+ip .req r12
+sp .req r13
+lr .req r14
+pc .req r15
+
+.text
+ .align 0
+
+ .global mcount
+mcount:
+ stmfd sp!, {lr}
+ mov r1, lr
+ mov r0, ip
+ bl __mcount
+ ldmfd sp!, {lr}
+ add pc, lr, #0x00000004
--- /dev/null
+a1 .req r0
+a2 .req r1
+a3 .req r2
+a4 .req r3
+v1 .req r4
+v2 .req r5
+v3 .req r6
+v4 .req r7
+v5 .req r8
+v6 .req r9
+v7 .req r10
+fp .req r11
+ip .req r12
+sp .req r13
+lr .req r14
+pc .req r15
+
+.text
+
+ .global __rt_sdiv
+__rt_sdiv:
+ b x_divide
+
+ .global __rt_udiv
+__rt_udiv:
+ b x_udivide
+
+ .global ___umodsi3
+___umodsi3:
+ mov a3, a1
+ mov a1, a2
+ mov a2, a3
+ b x_uremainder
+
+ .global ___udivsi3
+___udivsi3:
+ mov a3, a1
+ mov a1, a2
+ mov a2, a3
+ b x_udivide
+
+ .global ___modsi3
+___modsi3:
+ mov a3, a1
+ mov a1, a2
+ mov a2, a3
+ b x_remainder
+
+ .global ___divsi3
+___divsi3:
+ mov a3, a1
+ mov a1, a2
+ mov a2, a3
+ b x_divide
+
+ .global x_divtest
+x_divtest:
+ mov pc,lr
+
+ .global x_remainder
+x_remainder:
+ stmfd sp!,{lr}
+ bl x_divide
+ mov a1,a2
+ ldmfd sp!,{pc}
+
+ .global x_uremainder
+x_uremainder:
+ stmfd sp!,{lr}
+ bl x_udivide
+ mov a1,a2
+ ldmfd sp!,{pc}
+
+x_overflow:
+ mvn a1,#0
+ mov pc,lr
+
+ .global x_udivide /* a1 = a2 / a1; a2 = a2 % a1 */
+x_udivide:
+ cmp a1,#1
+ bcc x_overflow
+ beq x_divide_l0
+ mov ip,#0
+ movs a2,a2
+ bpl x_divide_l1
+ orr ip,ip,#0x20000000 /* ip bit 0x20000000 = -ve a2 */
+ movs a2,a2,lsr #1
+ orrcs ip,ip,#0x10000000 /* ip bit 0x10000000 = bit 0 of a2 */
+ b x_divide_l1
+
+x_divide_l0: /* a1 == 1 */
+ mov a1,a2
+ mov a2,#0
+ mov pc,lr
+
+ .global x_divide /* a1 = a2 / a1; a2 = a2 % a1 */
+x_divide:
+ cmp a1,#1
+ bcc x_overflow
+ beq x_divide_l0
+ ands ip,a1,#0x80000000
+ rsbmi a1,a1,#0
+ ands a3,a2,#0x80000000
+ eor ip,ip,a3
+ rsbmi a2,a2,#0
+ orr ip,a3,ip,lsr #1 /* ip bit 0x40000000 = -ve division */
+ /* ip bit 0x80000000 = -ve remainder */
+
+x_divide_l1:
+ mov a3,#1
+ mov a4,#0
+
+ cmp a2,a1
+ bcc x_divide_b0
+ cmp a2,a1,lsl #1
+ bcc x_divide_b1
+ cmp a2,a1,lsl #2
+ bcc x_divide_b2
+ cmp a2,a1,lsl #3
+ bcc x_divide_b3
+ cmp a2,a1,lsl #4
+ bcc x_divide_b4
+ cmp a2,a1,lsl #5
+ bcc x_divide_b5
+ cmp a2,a1,lsl #6
+ bcc x_divide_b6
+ cmp a2,a1,lsl #7
+ bcc x_divide_b7
+ cmp a2,a1,lsl #8
+ bcc x_divide_b8
+ cmp a2,a1,lsl #9
+ bcc x_divide_b9
+ cmp a2,a1,lsl #10
+ bcc x_divide_b10
+ cmp a2,a1,lsl #11
+ bcc x_divide_b11
+ cmp a2,a1,lsl #12
+ bcc x_divide_b12
+ cmp a2,a1,lsl #13
+ bcc x_divide_b13
+ cmp a2,a1,lsl #14
+ bcc x_divide_b14
+ cmp a2,a1,lsl #15
+ bcc x_divide_b15
+ cmp a2,a1,lsl #16
+ bcc x_divide_b16
+ cmp a2,a1,lsl #17
+ bcc x_divide_b17
+ cmp a2,a1,lsl #18
+ bcc x_divide_b18
+ cmp a2,a1,lsl #19
+ bcc x_divide_b19
+ cmp a2,a1,lsl #20
+ bcc x_divide_b20
+ cmp a2,a1,lsl #21
+ bcc x_divide_b21
+ cmp a2,a1,lsl #22
+ bcc x_divide_b22
+ cmp a2,a1,lsl #23
+ bcc x_divide_b23
+ cmp a2,a1,lsl #24
+ bcc x_divide_b24
+ cmp a2,a1,lsl #25
+ bcc x_divide_b25
+ cmp a2,a1,lsl #26
+ bcc x_divide_b26
+ cmp a2,a1,lsl #27
+ bcc x_divide_b27
+ cmp a2,a1,lsl #28
+ bcc x_divide_b28
+ cmp a2,a1,lsl #29
+ bcc x_divide_b29
+ cmp a2,a1,lsl #30
+ bcc x_divide_b30
+ cmp a2,a1,lsl #31
+ subhs a2,a2,a1,lsl #31
+ addhs a4,a4,a3,lsl #31
+ cmp a2,a1,lsl #30
+ subhs a2,a2,a1,lsl #30
+ addhs a4,a4,a3,lsl #30
+x_divide_b30:
+ cmp a2,a1,lsl #29
+ subhs a2,a2,a1,lsl #29
+ addhs a4,a4,a3,lsl #29
+x_divide_b29:
+ cmp a2,a1,lsl #28
+ subhs a2,a2,a1,lsl #28
+ addhs a4,a4,a3,lsl #28
+x_divide_b28:
+ cmp a2,a1,lsl #27
+ subhsS a2,a2,a1,lsl #27
+ addhs a4,a4,a3,lsl #27
+x_divide_b27:
+ cmp a2,a1,lsl #26
+ subhs a2,a2,a1,lsl #26
+ addhs a4,a4,a3,lsl #26
+x_divide_b26:
+ cmp a2,a1,lsl #25
+ subhs a2,a2,a1,lsl #25
+ addhs a4,a4,a3,lsl #25
+x_divide_b25:
+ cmp a2,a1,lsl #24
+ subhs a2,a2,a1,lsl #24
+ addhs a4,a4,a3,lsl #24
+x_divide_b24:
+ cmp a2,a1,lsl #23
+ subhs a2,a2,a1,lsl #23
+ addhs a4,a4,a3,lsl #23
+x_divide_b23:
+ cmp a2,a1,lsl #22
+ subhs a2,a2,a1,lsl #22
+ addhs a4,a4,a3,lsl #22
+x_divide_b22:
+ cmp a2,a1,lsl #21
+ subhs a2,a2,a1,lsl #21
+ addhs a4,a4,a3,lsl #21
+x_divide_b21:
+ cmp a2,a1,lsl #20
+ subhs a2,a2,a1,lsl #20
+ addhs a4,a4,a3,lsl #20
+x_divide_b20:
+ cmp a2,a1,lsl #19
+ subhs a2,a2,a1,lsl #19
+ addhs a4,a4,a3,lsl #19
+x_divide_b19:
+ cmp a2,a1,lsl #18
+ subhs a2,a2,a1,lsl #18
+ addhs a4,a4,a3,lsl #18
+x_divide_b18:
+ cmp a2,a1,lsl #17
+ subhs a2,a2,a1,lsl #17
+ addhs a4,a4,a3,lsl #17
+x_divide_b17:
+ cmp a2,a1,lsl #16
+ subhs a2,a2,a1,lsl #16
+ addhs a4,a4,a3,lsl #16
+x_divide_b16:
+ cmp a2,a1,lsl #15
+ subhs a2,a2,a1,lsl #15
+ addhs a4,a4,a3,lsl #15
+x_divide_b15:
+ cmp a2,a1,lsl #14
+ subhs a2,a2,a1,lsl #14
+ addhs a4,a4,a3,lsl #14
+x_divide_b14:
+ cmp a2,a1,lsl #13
+ subhs a2,a2,a1,lsl #13
+ addhs a4,a4,a3,lsl #13
+x_divide_b13:
+ cmp a2,a1,lsl #12
+ subhs a2,a2,a1,lsl #12
+ addhs a4,a4,a3,lsl #12
+x_divide_b12:
+ cmp a2,a1,lsl #11
+ subhs a2,a2,a1,lsl #11
+ addhs a4,a4,a3,lsl #11
+x_divide_b11:
+ cmp a2,a1,lsl #10
+ subhs a2,a2,a1,lsl #10
+ addhs a4,a4,a3,lsl #10
+x_divide_b10:
+ cmp a2,a1,lsl #9
+ subhs a2,a2,a1,lsl #9
+ addhs a4,a4,a3,lsl #9
+x_divide_b9:
+ cmp a2,a1,lsl #8
+ subhs a2,a2,a1,lsl #8
+ addhs a4,a4,a3,lsl #8
+x_divide_b8:
+ cmp a2,a1,lsl #7
+ subhs a2,a2,a1,lsl #7
+ addhs a4,a4,a3,lsl #7
+x_divide_b7:
+ cmp a2,a1,lsl #6
+ subhs a2,a2,a1,lsl #6
+ addhs a4,a4,a3,lsl #6
+x_divide_b6:
+ cmp a2,a1,lsl #5
+ subhs a2,a2,a1,lsl #5
+ addhs a4,a4,a3,lsl #5
+x_divide_b5:
+ cmp a2,a1,lsl #4
+ subhs a2,a2,a1,lsl #4
+ addhs a4,a4,a3,lsl #4
+x_divide_b4:
+ cmp a2,a1,lsl #3
+ subhs a2,a2,a1,lsl #3
+ addhs a4,a4,a3,lsl #3
+x_divide_b3:
+ cmp a2,a1,lsl #2
+ subhs a2,a2,a1,lsl #2
+ addhs a4,a4,a3,lsl #2
+x_divide_b2:
+ cmp a2,a1,lsl #1
+ subhs a2,a2,a1,lsl #1
+ addhs a4,a4,a3,lsl #1
+x_divide_b1:
+ cmp a2,a1
+ subhs a2,a2,a1
+ addhs a4,a4,a3
+x_divide_b0:
+
+ tst ip,#0x20000000
+ bne x_udivide_l1
+ mov a1,a4
+ cmp ip,#0
+ rsbmi a2,a2,#0
+ movs ip,ip,lsl #1
+ rsbmi a1,a1,#0
+ mov pc,lr
+
+x_udivide_l1:
+ tst ip,#0x10000000
+ mov a2,a2,lsl #1
+ orrne a2,a2,#1
+ mov a4,a4,lsl #1
+ cmp a2,a1
+ subhs a2,a2,a1
+ addhs a4,a4,a3
+ mov a1,a4
+ mov pc,lr
+
-# $OpenBSD: Makefile.inc,v 1.3 1996/04/19 16:09:44 niklas Exp $
-# $NetBSD: Makefile.inc,v 1.9 1996/03/11 05:32:00 scottr Exp $
+# $OpenBSD: Makefile.inc,v 1.4 1996/04/21 22:27:52 deraadt Exp $
+# $NetBSD: Makefile.inc,v 1.10 1996/04/13 01:17:41 cgd Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
bcmp.S ffs.S memset.S strcat.S strcmp.S strcpy.S strlen.S strncmp.c \
- strncpy.c scanc.S skpc.S locc.S htonl.S htons.S ntohl.S ntohs.S
+ strncpy.c scanc.S skpc.S locc.S htonl.S htons.S ntohl.S ntohs.S \
+ strncasecmp.c
-# $NetBSD: Makefile.inc,v 1.3 1994/10/26 06:39:40 cgd Exp $
+# $OpenBSD: Makefile.inc,v 1.3 1996/04/21 22:27:55 deraadt Exp $
+# $NetBSD: Makefile.inc,v 1.4 1996/04/13 01:17:46 cgd Exp $
#
# There are likely more that we will notice when we go native
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
bcmp.S bzero.S strcat.c strcmp.c strcpy.c ffs.S strlen.S strncmp.c \
- random.c scanc.c skpc.c strcat.c strcpy.c strncmp.c strncpy.c
+ random.c scanc.c skpc.c strcat.c strcpy.c strncmp.c strncpy.c \
+ strncasecmp.c
-# $NetBSD: Makefile.inc,v 1.6 1995/11/30 01:00:10 jtc Exp $
+# $OpenBSD: Makefile.inc,v 1.3 1996/04/21 22:27:58 deraadt Exp $
+# $NetBSD: Makefile.inc,v 1.7 1996/04/13 01:17:50 cgd Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
bcmp.c ffs.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c strncpy.c \
- scanc.c skpc.c locc.c \
+ scanc.c skpc.c locc.c strncasecmp.c \
htonl.S htons.S ntohl.S ntohs.S
-# $NetBSD: Makefile.inc,v 1.10 1995/10/07 22:26:53 mycroft Exp $
+# $OpenBSD: Makefile.inc,v 1.2 1996/04/21 22:28:01 deraadt Exp $
+# $NetBSD: Makefile.inc,v 1.11 1996/04/13 01:17:53 cgd Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
bcmp.c bzero.S strcat.c strcmp.c strcpy.c strlen.S strncmp.c \
- strncpy.c htonl.S htons.S ntohl.S ntohs.S scanc.c skpc.c memset.c
+ strncpy.c htonl.S htons.S ntohl.S ntohs.S scanc.c skpc.c memset.c \
+ strncasecmp.c
SRCS+= umul.S mul.S rem.S sdiv.S udiv.S umul.S urem.S
SRCS+= mul.S saveregs.S umul.S
-# $NetBSD: Makefile.inc,v 1.1 1995/04/18 21:59:46 ragge Exp $
+# $OpenBSD: Makefile.inc,v 1.2 1996/04/21 22:28:04 deraadt Exp $
+# $NetBSD: Makefile.inc,v 1.2 1996/04/13 01:17:58 cgd Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
strcat.c strcmp.c strcpy.c strlen.c strncmp.c \
- strncpy.c scanc.c skpc.c locc.c
+ strncpy.c scanc.c skpc.c locc.c strncasecmp.c
-/* $OpenBSD: fifo_vnops.c,v 1.2 1996/02/27 07:53:43 niklas Exp $ */
-/* $NetBSD: fifo_vnops.c,v 1.17 1996/02/09 22:40:16 christos Exp $ */
+/* $OpenBSD: fifo_vnops.c,v 1.3 1996/04/21 22:28:10 deraadt Exp $ */
+/* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */
/*
* Copyright (c) 1990, 1993
{
register struct fifoinfo *fip = vp->v_fifoinfo;
- printf(", fifo with %d readers and %d writers",
+ printf(", fifo with %ld readers and %ld writers",
fip->fi_readers, fip->fi_writers);
}
-/* $OpenBSD: kernfs_vnops.c,v 1.2 1996/02/27 07:55:19 niklas Exp $ */
-/* $NetBSD: kernfs_vnops.c,v 1.42 1996/02/13 13:12:55 mycroft Exp $ */
+/* $OpenBSD: kernfs_vnops.c,v 1.3 1996/04/21 22:28:14 deraadt Exp $ */
+/* $NetBSD: kernfs_vnops.c,v 1.43 1996/03/16 23:52:47 christos Exp $ */
/*
* Copyright (c) 1992, 1993
struct timeval tv;
microtime(&tv);
- sprintf(*bufp, "%d %d\n", tv.tv_sec, tv.tv_usec);
+ sprintf(*bufp, "%ld %ld\n", tv.tv_sec, tv.tv_usec);
break;
}
case KTT_AVENRUN:
averunnable.fscale = FSCALE;
- sprintf(*bufp, "%ld %ld %ld %ld\n",
+ sprintf(*bufp, "%d %d %d %ld\n",
averunnable.ldavg[0], averunnable.ldavg[1],
averunnable.ldavg[2], averunnable.fscale);
break;
-/* $OpenBSD: null_vnops.c,v 1.2 1996/02/27 07:58:04 niklas Exp $ */
-/* $NetBSD: null_vnops.c,v 1.5 1996/02/09 22:40:34 christos Exp $ */
+/* $OpenBSD: null_vnops.c,v 1.3 1996/04/21 22:28:16 deraadt Exp $ */
+/* $NetBSD: null_vnops.c,v 1.6 1996/04/13 01:34:06 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
struct vnode *a_vp;
} */ *ap = v;
register struct vnode *vp = ap->a_vp;
- printf ("\ttag VT_NULLFS, vp=%x, lowervp=%x\n", (unsigned int) vp,
- (unsigned int) NULLVPTOLOWERVP(vp));
+ printf ("\ttag VT_NULLFS, vp=%p, lowervp=%p\n", vp,
+ NULLVPTOLOWERVP(vp));
return (0);
}
-/* $NetBSD: procfs_status.c,v 1.10 1995/06/01 22:44:28 jtc Exp $ */
+/* $OpenBSD: procfs_status.c,v 1.2 1996/04/21 22:28:18 deraadt Exp $ */
+/* $NetBSD: procfs_status.c,v 1.11 1996/03/16 23:52:50 christos Exp $ */
/*
* Copyright (c) 1993 Jan-Simon Pendry
ps += sprintf(ps, "noflags");
if (p->p_flag & P_INMEM)
- ps += sprintf(ps, " %d,%d",
+ ps += sprintf(ps, " %ld,%ld",
p->p_stats->p_start.tv_sec,
p->p_stats->p_start.tv_usec);
else
struct timeval ut, st;
calcru(p, &ut, &st, (void *) 0);
- ps += sprintf(ps, " %d,%d %d,%d",
+ ps += sprintf(ps, " %ld,%ld %ld,%ld",
ut.tv_sec,
ut.tv_usec,
st.tv_sec,
-/* $OpenBSD: procfs_vnops.c,v 1.2 1996/02/27 08:03:39 niklas Exp $ */
-/* $NetBSD: procfs_vnops.c,v 1.39 1996/02/13 13:12:59 mycroft Exp $ */
+/* $OpenBSD: procfs_vnops.c,v 1.3 1996/04/21 22:28:19 deraadt Exp $ */
+/* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */
/*
* Copyright (c) 1993 Jan-Simon Pendry
} */ *ap = v;
struct pfsnode *pfs = VTOPFS(ap->a_vp);
- printf("tag VT_PROCFS, type %d, pid %d, mode %x, flags %x\n",
+ printf("tag VT_PROCFS, type %d, pid %d, mode %x, flags %lx\n",
pfs->pfs_type, pfs->pfs_pid, pfs->pfs_mode, pfs->pfs_flags);
return 0;
}
-/* $OpenBSD: msdosfs_vfsops.c,v 1.4 1996/02/29 10:46:57 niklas Exp $ */
-/* $NetBSD: msdosfs_vfsops.c,v 1.40 1996/02/11 22:48:16 ws Exp $ */
+/* $OpenBSD: msdosfs_vfsops.c,v 1.5 1996/04/21 22:28:22 deraadt Exp $ */
+/* $NetBSD: msdosfs_vfsops.c,v 1.41 1996/03/20 00:45:40 thorpej Exp $ */
/*-
* Copyright (C) 1994, 1995 Wolfgang Solfrank.
if (VOP_ISLOCKED(vp))
continue;
dep = VTODE(vp);
- if (dep->de_flag
- & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED) == 0
- && vp->v_dirtyblkhd.lh_first == NULL)
+ if (((dep->de_flag
+ & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0)
+ && (vp->v_dirtyblkhd.lh_first == NULL))
continue;
if (vget(vp, 1))
goto loop;
-/* $OpenBSD: msdosfs_vnops.c,v 1.4 1996/04/19 16:10:03 niklas Exp $ */
-/* $NetBSD: msdosfs_vnops.c,v 1.47 1996/03/08 18:13:10 scottr Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.5 1996/04/21 22:28:24 deraadt Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.48 1996/03/20 00:45:43 thorpej Exp $ */
/*-
* Copyright (C) 1994, 1995 Wolfgang Solfrank.
} */ *ap = v;
register struct vnode *vp = ap->a_vp;
register struct denode *dep;
+#ifdef DIAGNOSTIC
struct proc *p = curproc; /* XXX */
+#endif
start:
while (vp->v_flag & VXLOCK) {
struct vnode *vp;
} */ *ap = v;
register struct denode *dep = VTODE(ap->a_vp);
+#ifdef DIAGNOSTIC
struct proc *p = curproc; /* XXX */
+#endif
#ifdef DIAGNOSTIC
if ((dep->de_flag & DE_LOCKED) == 0) {
} */ *ap = v;
struct denode *dep = VTODE(ap->a_vp);
- printf("tag VT_MSDOSFS, startcluster %d, dircluster %d, diroffset %d ",
- dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
+ printf(
+ "tag VT_MSDOSFS, startcluster %d, dircluster %ld, diroffset %ld ",
+ dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
printf(" dev %d, %d, %s\n",
- major(dep->de_dev), minor(dep->de_dev),
- dep->de_flag & DE_LOCKED ? "(LOCKED)" : "");
+ major(dep->de_dev), minor(dep->de_dev),
+ dep->de_flag & DE_LOCKED ? "(LOCKED)" : "");
#ifdef DIAGNOSTIC
if (dep->de_lockholder) {
printf(" owner pid %d", dep->de_lockholder);
-/* $OpenBSD: bpf.c,v 1.2 1996/03/03 21:07:00 niklas Exp $ */
-/* $NetBSD: bpf.c,v 1.24 1996/02/13 21:59:53 christos Exp $ */
+/* $OpenBSD: bpf.c,v 1.3 1996/04/21 22:28:27 deraadt Exp $ */
+/* $NetBSD: bpf.c,v 1.25 1996/03/30 21:57:30 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
#include <sys/user.h>
#include <sys/ioctl.h>
#include <sys/map.h>
+#include <sys/conf.h>
#include <sys/file.h>
#if defined(sparc) && BSD < 199103
#include <net/bpf.h>
#include <net/bpfdesc.h>
-#include <net/net_conf.h>
#include <sys/errno.h>
-/* $OpenBSD: bsd-comp.c,v 1.2 1996/03/03 21:07:03 niklas Exp $ */
-/* $NetBSD: bsd-comp.c,v 1.2 1996/02/13 22:00:03 christos Exp $ */
+/* $OpenBSD: bsd-comp.c,v 1.3 1996/04/21 22:28:28 deraadt Exp $ */
+/* $NetBSD: bsd-comp.c,v 1.4 1996/03/15 02:28:00 paulus Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
*
/*
* This version is for use with mbufs on BSD-derived systems.
*
- * $Id: bsd-comp.c,v 1.2 1996/03/03 21:07:03 niklas Exp $
+ * $Id: bsd-comp.c,v 1.3 1996/04/21 22:28:28 deraadt Exp $
*/
#include <sys/param.h>
u_int newlen, hsize, hshift, maxmaxcode;
struct bsd_db *db;
- if (opt_len != CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
+ if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
|| options[1] != CILEN_BSD_COMPRESS
|| BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
return NULL;
{
int i;
- if (opt_len != CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
+ if (opt_len < CILEN_BSD_COMPRESS || options[0] != CI_BSD_COMPRESS
|| options[1] != CILEN_BSD_COMPRESS
|| BSD_VERSION(options[2]) != BSD_CURRENT_VERSION
|| BSD_NBITS(options[2]) != db->maxbits
-/* $OpenBSD: if.c,v 1.6 1996/03/14 08:35:35 tholo Exp $ */
+/* $OpenBSD: if.c,v 1.7 1996/04/21 22:28:29 deraadt Exp $ */
/* $NetBSD: if.c,v 1.24 1996/02/13 22:00:09 christos Exp $ */
/*
ifa->ifa_netmask->sa_len;
while (cp3 < cplim)
if ((*cp++ ^ *cp2++) & *cp3++)
+ /* want to continue for() loop */
goto next;
if (ifa_maybe == 0 ||
rn_refines((caddr_t)ifa->ifa_netmask,
-/* $NetBSD: if_arcsubr.c,v 1.6 1995/12/24 03:03:55 mycroft Exp $ */
+/* $NetBSD: if_arcsubr.c,v 1.7 1996/04/15 14:01:25 is Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
int tfrags, sflag, fsflag, rsflag;
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
- senderr(ENETDOWN);
+ return(ENETDOWN); /* m, m1 aren't initialized yet */
error = newencoding = 0;
ac = (struct arccom *)ifp;
-/* $OpenBSD: if_ppp.c,v 1.5 1996/04/19 18:12:29 mickey Exp $ */
-/* $NetBSD: if_ppp.c,v 1.28 1996/02/13 22:00:18 christos Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.6 1996/04/21 22:28:32 deraadt Exp $ */
+/* $NetBSD: if_ppp.c,v 1.30 1996/03/19 01:00:49 paulus Exp $ */
/*
* if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
#include <sys/ioctl.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/time.h>
+#include <sys/malloc.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/route.h>
+#include <net/bpf.h>
#if INET
#include <netinet/in.h>
*/
extern struct compressor ppp_bsd_compress;
+extern struct compressor ppp_deflate;
struct compressor *ppp_compressors[8] = {
-#ifdef PPP_BSDCOMP
+#if DO_BSD_COMPRESS && defined(PPP_BSD_COMP)
&ppp_bsd_compress,
+#endif
+#if DO_DEFLATE && defined(PPP_DEFLATE)
+ &ppp_deflate,
#endif
NULL
};
sc->sc_flags = 0;
sc->sc_mru = PPP_MRU;
sc->sc_relinq = NULL;
+ bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
#ifdef VJC
- sl_compress_init(&sc->sc_comp, -1);
+ MALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress),
+ M_DEVBUF, M_NOWAIT);
+ if (sc->sc_comp)
+ sl_compress_init(sc->sc_comp, -1);
#endif
#ifdef PPP_COMPRESS
sc->sc_xc_state = NULL;
sc->sc_xc_state = NULL;
sc->sc_rc_state = NULL;
#endif /* PPP_COMPRESS */
+ if (sc->sc_pass_filt.bf_insns != 0) {
+ FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF);
+ sc->sc_pass_filt.bf_insns = 0;
+ sc->sc_pass_filt.bf_len = 0;
+ }
+ if (sc->sc_active_filt.bf_insns != 0) {
+ FREE(sc->sc_active_filt.bf_insns, M_DEVBUF);
+ sc->sc_active_filt.bf_insns = 0;
+ sc->sc_active_filt.bf_len = 0;
+ }
+#ifdef VJC
+ if (sc->sc_comp != 0) {
+ FREE(sc->sc_comp, M_DEVBUF);
+ sc->sc_comp = 0;
+ }
+#endif
}
/*
struct compressor **cp;
struct npioctl *npi;
time_t t;
+ struct bpf_program *bp, *nbp;
+ struct bpf_insn *newcode, *oldcode;
+ int newcodelen;
#ifdef PPP_COMPRESS
u_char ccp_option[CCP_MAX_OPTION_LENGTH];
#endif
case PPPIOCSMAXCID:
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
+ if (sc->sc_comp) {
s = splsoftnet();
- sl_compress_init(&sc->sc_comp, *(int *)data);
+ sl_compress_init(sc->sc_comp, *(int *)data);
splx(s);
+ }
break;
#endif
splx(s);
break;
+ case PPPIOCSPASS:
+ case PPPIOCSACTIVE:
+ nbp = (struct bpf_program *) data;
+ if ((unsigned) nbp->bf_len > BPF_MAXINSNS)
+ return EINVAL;
+ newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
+ if (newcodelen != 0) {
+ MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK);
+ if (newcode == 0) {
+ return EINVAL; /* or sumpin */
+ }
+ if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode,
+ newcodelen)) != 0) {
+ FREE(newcode, M_DEVBUF);
+ return error;
+ }
+ if (!bpf_validate(newcode, nbp->bf_len)) {
+ FREE(newcode, M_DEVBUF);
+ return EINVAL;
+ }
+ } else
+ newcode = 0;
+ bp = (cmd == PPPIOCSPASS)? &sc->sc_pass_filt: &sc->sc_active_filt;
+ oldcode = bp->bf_insns;
+ s = splimp();
+ bp->bf_len = nbp->bf_len;
+ bp->bf_insns = newcode;
+ splx(s);
+ if (oldcode != 0)
+ FREE(oldcode, M_DEVBUF);
+ break;
+
default:
return (-1);
}
case SIOCADDMULTI:
case SIOCDELMULTI:
- switch (ifr->ifr_addr.sa_family) {
+ if (ifr == 0) {
+ error = EAFNOSUPPORT;
+ break;
+ }
+ switch(ifr->ifr_addr.sa_family) {
#ifdef INET
case AF_INET:
break;
case SIOCGPPPSTATS:
psp = &((struct ifpppstatsreq *) data)->stats;
bzero(psp, sizeof(*psp));
- psp->p.ppp_ibytes = sc->sc_bytesrcvd;
- psp->p.ppp_ipackets = ifp->if_ipackets;
- psp->p.ppp_ierrors = ifp->if_ierrors;
- psp->p.ppp_obytes = sc->sc_bytessent;
- psp->p.ppp_opackets = ifp->if_opackets;
- psp->p.ppp_oerrors = ifp->if_oerrors;
-#ifdef VJC
- psp->vj.vjs_packets = sc->sc_comp.sls_packets;
- psp->vj.vjs_compressed = sc->sc_comp.sls_compressed;
- psp->vj.vjs_searches = sc->sc_comp.sls_searches;
- psp->vj.vjs_misses = sc->sc_comp.sls_misses;
- psp->vj.vjs_uncompressedin = sc->sc_comp.sls_uncompressedin;
- psp->vj.vjs_compressedin = sc->sc_comp.sls_compressedin;
- psp->vj.vjs_errorin = sc->sc_comp.sls_errorin;
- psp->vj.vjs_tossed = sc->sc_comp.sls_tossed;
+ psp->p = sc->sc_stats;
+#if defined(VJC) && !defined(SL_NO_STATS)
+ if (sc->sc_comp) {
+ psp->vj.vjs_packets = sc->sc_comp->sls_packets;
+ psp->vj.vjs_compressed = sc->sc_comp->sls_compressed;
+ psp->vj.vjs_searches = sc->sc_comp->sls_searches;
+ psp->vj.vjs_misses = sc->sc_comp->sls_misses;
+ psp->vj.vjs_uncompressedin = sc->sc_comp->sls_uncompressedin;
+ psp->vj.vjs_compressedin = sc->sc_comp->sls_compressedin;
+ psp->vj.vjs_errorin = sc->sc_comp->sls_errorin;
+ psp->vj.vjs_tossed = sc->sc_comp->sls_tossed;
+ }
#endif /* VJC */
break;
struct ip *ip;
struct ifqueue *ifq;
enum NPmode mode;
+ int active, len;
+ struct mbuf *m;
if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
|| ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
*cp++ = protocol & 0xff;
m0->m_len += PPP_HDRLEN;
+ len = 0;
+ for (m = m0; m != 0; m = m->m_next)
+ len += m->m_len;
+
if (sc->sc_flags & SC_LOG_OUTPKT) {
printf("ppp%d output: ", ifp->if_unit);
pppdumpm(m0);
}
+ /*
+ * Apply the pass and active filters to the packet,
+ * but only if it is a data packet.
+ */
+ active = 0;
+ if ((protocol & 0x8000) == 0) {
+ *mtod(m0, u_char *) = 1; /* indicates outbound */
+ if (sc->sc_pass_filt.bf_insns != 0
+ && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m0,
+ len, 0) == 0) {
+ error = 0; /* drop this packet */
+ goto bad;
+ }
+
+ /*
+ * Update the time we sent the most recent packet.
+ */
+ if (sc->sc_active_filt.bf_insns == 0
+ || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
+ sc->sc_last_sent = time.tv_sec;
+
+ *mtod(m0, u_char *) = address;
+ }
+
#if NBPFILTER > 0
/*
* See if bpf wants to look at the packet.
sc->sc_npqtail = &m0->m_nextpkt;
} else {
ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
- if (IF_QFULL(ifq)) {
+ if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
IF_DROP(ifq);
splx(s);
sc->sc_if.if_oerrors++;
+ sc->sc_stats.ppp_oerrors++;
error = ENOBUFS;
goto bad;
}
(*sc->sc_start)(sc);
}
ifp->if_lastchange = time;
+ ifp->if_opackets++;
+ ifp->if_obytes += len;
splx(s);
return (0);
if (IF_QFULL(ifq)) {
IF_DROP(ifq);
sc->sc_if.if_oerrors++;
+ sc->sc_stats.ppp_oerrors++;
} else
IF_ENQUEUE(ifq, m);
break;
if (m == NULL)
return;
+ ++sc->sc_stats.ppp_opackets;
+
/*
* Extract the ppp header of the new packet.
* The ppp header will be in one mbuf.
switch (protocol) {
case PPP_IP:
- /*
- * Update the time we sent the most recent packet.
- */
- sc->sc_last_sent = time.tv_sec;
-
#ifdef VJC
/*
* If the packet is a TCP/IP packet, see if we can compress it.
*/
- if (sc->sc_flags & SC_COMP_TCP) {
+ if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) {
struct ip *ip;
int type;
}
/* this code assumes the IP/TCP header is in one non-shared mbuf */
if (ip->ip_p == IPPROTO_TCP) {
- type = sl_compress_tcp(mp, ip, &sc->sc_comp,
+ type = sl_compress_tcp(mp, ip, sc->sc_comp,
!(sc->sc_flags & SC_NO_TCP_CCID));
switch (type) {
case TYPE_UNCOMPRESSED_TCP:
#ifdef PPP_COMPRESS
if (protocol != PPP_LCP && protocol != PPP_CCP
&& sc->sc_xc_state && (sc->sc_flags & SC_COMP_RUN)) {
- struct mbuf *mcomp;
+ struct mbuf *mcomp = NULL;
int slen, clen;
slen = 0;
{
struct ifnet *ifp = &sc->sc_if;
struct ifqueue *inq;
- int s, ilen = 0, xlen, proto, rv;
+ int s, ilen, xlen, proto, rv;
u_char *cp, adrs, ctrl;
- struct mbuf *mp, *dmp;
+ struct mbuf *mp, *dmp = NULL;
u_char *iphdr;
u_int hlen;
- ifp->if_ipackets++;
- ifp->if_lastchange = time;
+ sc->sc_stats.ppp_ipackets++;
if (sc->sc_flags & SC_LOG_INPKT) {
- register int len = 0;
+ ilen = 0;
for (mp = m; mp != NULL; mp = mp->m_next)
- len += mp->m_len;
- printf("ppp%d: got %d bytes\n", ifp->if_unit, len);
+ ilen += mp->m_len;
+ printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen);
pppdumpm(m);
}
* If we've missed a packet, we must toss subsequent compressed
* packets which don't have an explicit connection ID.
*/
- sl_uncompress_tcp(NULL, 0, TYPE_ERROR, &sc->sc_comp);
+ if (sc->sc_comp)
+ sl_uncompress_tcp(NULL, 0, TYPE_ERROR, sc->sc_comp);
s = splhigh();
sc->sc_flags &= ~SC_VJ_RESET;
splx(s);
* See if we have a VJ-compressed packet to uncompress.
*/
if (proto == PPP_VJC_COMP) {
- if (sc->sc_flags & SC_REJ_COMP_TCP)
+ if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
goto bad;
xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
ilen - PPP_HDRLEN, TYPE_COMPRESSED_TCP,
- &sc->sc_comp, &iphdr, &hlen);
+ sc->sc_comp, &iphdr, &hlen);
if (xlen <= 0) {
if (sc->sc_flags & SC_DEBUG)
ilen += hlen - xlen;
} else if (proto == PPP_VJC_UNCOMP) {
- if (sc->sc_flags & SC_REJ_COMP_TCP)
+ if ((sc->sc_flags & SC_REJ_COMP_TCP) || sc->sc_comp == 0)
goto bad;
xlen = sl_uncompress_tcp_core(cp + PPP_HDRLEN, m->m_len - PPP_HDRLEN,
ilen - PPP_HDRLEN, TYPE_UNCOMPRESSED_TCP,
- &sc->sc_comp, &iphdr, &hlen);
+ sc->sc_comp, &iphdr, &hlen);
if (xlen < 0) {
if (sc->sc_flags & SC_DEBUG)
m->m_pkthdr.len = ilen;
m->m_pkthdr.rcvif = ifp;
+ /*
+ * See whether we want to pass this packet, and
+ * if it counts as link activity.
+ */
+ if ((proto & 0x8000) == 0) {
+ adrs = *mtod(m, u_char *); /* save address field */
+ *mtod(m, u_char *) = 0; /* indicate inbound */
+ if (sc->sc_pass_filt.bf_insns != 0
+ && bpf_filter(sc->sc_pass_filt.bf_insns, (u_char *) m,
+ ilen, 0) == 0) {
+ /* drop this packet */
+ m_freem(m);
+ return;
+ }
+ if (sc->sc_active_filt.bf_insns == 0
+ || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
+ sc->sc_last_recv = time.tv_sec;
+
+ *mtod(m, u_char *) = adrs;
+ }
+
#if NBPFILTER > 0
/* See if bpf wants to look at the packet. */
if (sc->sc_bpf)
m->m_len -= PPP_HDRLEN;
schednetisr(NETISR_IP);
inq = &ipintrq;
- sc->sc_last_recv = time.tv_sec; /* update time of last pkt rcvd */
break;
#endif
}
IF_ENQUEUE(inq, m);
splx(s);
+ ifp->if_ipackets++;
+ ifp->if_ibytes += ilen;
+ ifp->if_lastchange = time;
if (rv)
(*sc->sc_ctlp)(sc);
bad:
m_freem(m);
sc->sc_if.if_ierrors++;
+ sc->sc_stats.ppp_ierrors++;
}
#define MAX_DUMP_BYTES 128
-/* $OpenBSD: if_ppp.h,v 1.2 1996/03/03 21:07:09 niklas Exp $ */
-/* $NetBSD: if_ppp.h,v 1.10 1996/02/13 22:00:21 christos Exp $ */
+/* $OpenBSD: if_ppp.h,v 1.3 1996/04/21 22:28:33 deraadt Exp $ */
+/* $NetBSD: if_ppp.h,v 1.11 1996/03/15 02:28:05 paulus Exp $ */
/*
* if_ppp.h - Point-to-Point Protocol definitions.
#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */
#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
#define PPPIOCGIDLE _IOR('t', 74, struct ppp_idle) /* get idle time */
+#define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */
+#define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */
/* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */
#define PPPIOCGMTU _IOR('t', 73, int) /* get interface MTU */
#if !defined(ifr_mtu)
#define ifr_mtu ifr_ifru.ifru_metric
#endif
+
#ifdef _KERNEL
void pppattach __P((void));
-struct ppp_softc *pppalloc __P((pid_t));
-void pppdealloc __P((struct ppp_softc *));
-int pppioctl __P((struct ppp_softc *, u_long, caddr_t, int, struct proc *));
int pppsioctl __P((struct ifnet *, u_long, caddr_t));
int pppoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *));
-struct mbuf *ppp_dequeue __P((struct ppp_softc *));
void pppintr __P((void));
-void ppppktin __P((struct ppp_softc *, struct mbuf *, int));
#endif
#endif /* _IF_PPP_H_ */
-/* $NetBSD: if_pppvar.h,v 1.2 1995/07/04 15:30:39 briggs Exp $ */
+/* $NetBSD: if_pppvar.h,v 1.3 1996/03/15 02:28:06 paulus Exp $ */
/*
* if_pppvar.h - private structures and declarations for PPP.
*
struct mbuf *sc_togo; /* output packet ready to go */
struct mbuf *sc_npqueue; /* output packets not to be sent yet */
struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */
-#ifdef VJC
- struct slcompress sc_comp; /* vjc control buffer */
-#endif
- u_int sc_bytessent; /* count of octets sent */
- u_int sc_bytesrcvd; /* count of octets received */
+ struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */
caddr_t sc_bpf; /* hook for BPF */
enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
struct compressor *sc_xcomp; /* transmit compressor */
void *sc_rc_state; /* receive decompressor state */
time_t sc_last_sent; /* time (secs) last NP pkt sent */
time_t sc_last_recv; /* time (secs) last NP pkt rcvd */
+ struct bpf_program sc_pass_filt; /* filter for packets to pass */
+ struct bpf_program sc_active_filt; /* filter for "non-idle" packets */
+#ifdef VJC
+ struct slcompress *sc_comp; /* vjc control buffer */
+#endif
/* Device-dependent part for async lines. */
ext_accm sc_asyncmap; /* async control character map */
-/* $OpenBSD: if_tun.c,v 1.5 1996/03/03 21:07:11 niklas Exp $ */
+/* $OpenBSD: if_tun.c,v 1.6 1996/04/21 22:28:35 deraadt Exp $ */
/* $NetBSD: if_tun.c,v 1.22 1996/02/13 22:00:26 christos Exp $ */
/*
#include <sys/device.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
+#include <sys/conf.h>
#include <machine/cpu.h>
#endif
#include <net/if_tun.h>
-#include <net/net_conf.h>
#ifdef TUN_DEBUG
int tundebug = TUN_DEBUG;
-/* $OpenBSD: if_tun.h,v 1.2 1996/02/20 14:34:01 mickey Exp $ */
+/* $OpenBSD: if_tun.h,v 1.3 1996/04/21 22:28:36 deraadt Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
+++ /dev/null
-/* $OpenBSD: net_conf.h,v 1.1 1996/03/03 21:07:11 niklas Exp $ */
-/* $NetBSD: net_conf.h,v 1.1 1996/02/13 22:00:28 christos Exp $ */
-
-/*
- * Copyright (c) 1995 Christos Zoulas. 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 Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/conf.h>
-
-#include "bpfilter.h"
-cdev_decl(bpf);
-
-#include "tun.h"
-cdev_decl(tun);
-/* $NetBSD: ppp-comp.h,v 1.1 1995/07/04 06:28:24 paulus Exp $ */
+/* $NetBSD: ppp-comp.h,v 1.2 1996/03/15 02:28:07 paulus Exp $ */
/*
* ppp-comp.h - Definitions for doing PPP packet compression.
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
*
- * $Id: ppp-comp.h,v 1.1.1.1 1995/10/18 08:53:07 deraadt Exp $
+ * $Id: ppp-comp.h,v 1.2 1996/04/21 22:28:40 deraadt Exp $
*/
#ifndef _NET_PPP_COMP_H
#ifndef DO_BSD_COMPRESS
#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
#endif
+#ifndef DO_DEFLATE
+#define DO_DEFLATE 1 /* by default, include Deflate */
+#endif
+#define DO_PREDICTOR_1 0
+#define DO_PREDICTOR_2 0
/*
* Structure giving methods for compression/decompression.
#define BSD_MIN_BITS 9 /* smallest code size supported */
#define BSD_MAX_BITS 15 /* largest code size supported */
+/*
+ * Definitions for other, as yet unsupported, compression methods.
+ */
+#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
+#define CILEN_PREDICTOR_1 2 /* length of its config option */
+#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
+#define CILEN_PREDICTOR_2 2 /* length of its config option */
+
+#define CI_DEFLATE 24 /* config option for Deflate */
+#define CILEN_DEFLATE 4 /* length of its config option */
+
+#define DEFLATE_MIN_SIZE 8
+#define DEFLATE_MAX_SIZE 15
+#define DEFLATE_METHOD_VAL 8
+#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
+#define DEFLATE_METHOD(x) ((x) & 0x0F)
+#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
+ + DEFLATE_METHOD_VAL)
+#define DEFLATE_CHK_SEQUENCE 0
+
#endif /* _NET_PPP_COMP_H */
--- /dev/null
+/* $NetBSD: ppp-deflate.c,v 1.1 1996/03/15 02:28:09 paulus Exp $ */
+
+/*
+ * ppp_deflate.c - interface the zlib procedures for Deflate compression
+ * and decompression (as used by gzip) to the PPP code.
+ * This version is for use with mbufs on BSD-derived systems.
+ *
+ * Copyright (c) 1994 The Australian National University.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation is hereby granted, provided that the above copyright
+ * notice appears in all copies. This software is provided without any
+ * warranty, express or implied. The Australian National University
+ * makes no representations about the suitability of this software for
+ * any purpose.
+ *
+ * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+ * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
+ * OR MODIFICATIONS.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <net/ppp_defs.h>
+#include <net/zlib.h>
+
+#define PACKETPTR struct mbuf *
+#include <net/ppp-comp.h>
+
+#if DO_DEFLATE
+
+/*
+ * State for a Deflate (de)compressor.
+ */
+struct deflate_state {
+ int seqno;
+ int w_size;
+ int unit;
+ int hdrlen;
+ int mru;
+ int debug;
+ z_stream strm;
+ struct compstat stats;
+};
+
+#define DEFLATE_OVHD 2 /* Deflate overhead/packet */
+
+static void *zalloc __P((void *, u_int items, u_int size));
+static void zfree __P((void *, void *ptr, u_int nb));
+static void *z_comp_alloc __P((u_char *options, int opt_len));
+static void *z_decomp_alloc __P((u_char *options, int opt_len));
+static void z_comp_free __P((void *state));
+static void z_decomp_free __P((void *state));
+static int z_comp_init __P((void *state, u_char *options, int opt_len,
+ int unit, int hdrlen, int debug));
+static int z_decomp_init __P((void *state, u_char *options, int opt_len,
+ int unit, int hdrlen, int mru, int debug));
+static int z_compress __P((void *state, struct mbuf **mret,
+ struct mbuf *mp, int slen, int maxolen));
+static void z_incomp __P((void *state, struct mbuf *dmsg));
+static int z_decompress __P((void *state, struct mbuf *cmp,
+ struct mbuf **dmpp));
+static void z_comp_reset __P((void *state));
+static void z_decomp_reset __P((void *state));
+static void z_comp_stats __P((void *state, struct compstat *stats));
+
+/*
+ * Procedures exported to if_ppp.c.
+ */
+struct compressor ppp_deflate = {
+ CI_DEFLATE, /* compress_proto */
+ z_comp_alloc, /* comp_alloc */
+ z_comp_free, /* comp_free */
+ z_comp_init, /* comp_init */
+ z_comp_reset, /* comp_reset */
+ z_compress, /* compress */
+ z_comp_stats, /* comp_stat */
+ z_decomp_alloc, /* decomp_alloc */
+ z_decomp_free, /* decomp_free */
+ z_decomp_init, /* decomp_init */
+ z_decomp_reset, /* decomp_reset */
+ z_decompress, /* decompress */
+ z_incomp, /* incomp */
+ z_comp_stats, /* decomp_stat */
+};
+
+/*
+ * Space allocation and freeing routines for use by zlib routines.
+ */
+void *
+zalloc(notused, items, size)
+ void *notused;
+ u_int items, size;
+{
+ void *ptr;
+
+ MALLOC(ptr, void *, items * size, M_DEVBUF, M_NOWAIT);
+ return ptr;
+}
+
+void
+zfree(notused, ptr, nbytes)
+ void *notused;
+ void *ptr;
+ u_int nbytes;
+{
+ FREE(ptr, M_DEVBUF);
+}
+
+/*
+ * Allocate space for a compressor.
+ */
+static void *
+z_comp_alloc(options, opt_len)
+ u_char *options;
+ int opt_len;
+{
+ struct deflate_state *state;
+ int w_size;
+
+ if (opt_len != CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return NULL;
+ w_size = DEFLATE_SIZE(options[2]);
+ if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
+ return NULL;
+
+ MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
+ M_DEVBUF, M_NOWAIT);
+ if (state == NULL)
+ return NULL;
+
+ state->strm.next_in = NULL;
+ state->strm.zalloc = zalloc;
+ state->strm.zfree = zfree;
+ if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
+ -w_size, 8, Z_DEFAULT_STRATEGY, DEFLATE_OVHD+2) != Z_OK) {
+ FREE(state, M_DEVBUF);
+ return NULL;
+ }
+
+ state->w_size = w_size;
+ bzero(&state->stats, sizeof(state->stats));
+ return (void *) state;
+}
+
+static void
+z_comp_free(arg)
+ void *arg;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+
+ deflateEnd(&state->strm);
+ FREE(state, M_DEVBUF);
+}
+
+static int
+z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
+ void *arg;
+ u_char *options;
+ int opt_len, unit, hdrlen, debug;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+
+ if (opt_len < CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || DEFLATE_SIZE(options[2]) != state->w_size
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return 0;
+
+ state->seqno = 0;
+ state->unit = unit;
+ state->hdrlen = hdrlen;
+ state->debug = debug;
+
+ deflateReset(&state->strm);
+
+ return 1;
+}
+
+static void
+z_comp_reset(arg)
+ void *arg;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+
+ state->seqno = 0;
+ deflateReset(&state->strm);
+}
+
+int
+z_compress(arg, mret, mp, orig_len, maxolen)
+ void *arg;
+ struct mbuf **mret; /* compressed packet (out) */
+ struct mbuf *mp; /* uncompressed packet (in) */
+ int orig_len, maxolen;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+ u_char *rptr, *wptr;
+ int proto, olen, wspace, r, flush;
+ struct mbuf *m;
+
+ /*
+ * Check that the protocol is in the range we handle.
+ */
+ rptr = mtod(mp, u_char *);
+ proto = PPP_PROTOCOL(rptr);
+ if (proto > 0x3fff || proto == 0xfd || proto == 0xfb) {
+ *mret = NULL;
+ return orig_len;
+ }
+
+ /* Allocate one mbuf initially. */
+ if (maxolen > orig_len)
+ maxolen = orig_len;
+ MGET(m, M_DONTWAIT, MT_DATA);
+ *mret = m;
+ if (m != NULL) {
+ m->m_len = 0;
+ if (maxolen + state->hdrlen > MLEN)
+ MCLGET(m, M_DONTWAIT);
+ wspace = M_TRAILINGSPACE(m);
+ if (state->hdrlen + PPP_HDRLEN + 2 < wspace) {
+ m->m_data += state->hdrlen;
+ wspace -= state->hdrlen;
+ }
+ wptr = mtod(m, u_char *);
+
+ /*
+ * Copy over the PPP header and store the 2-byte sequence number.
+ */
+ wptr[0] = PPP_ADDRESS(rptr);
+ wptr[1] = PPP_CONTROL(rptr);
+ wptr[2] = PPP_COMP >> 8;
+ wptr[3] = PPP_COMP;
+ wptr += PPP_HDRLEN;
+ wptr[0] = state->seqno >> 8;
+ wptr[1] = state->seqno;
+ wptr += 2;
+ state->strm.next_out = wptr;
+ state->strm.avail_out = wspace - (PPP_HDRLEN + 2);
+ } else {
+ state->strm.next_out = NULL;
+ state->strm.avail_out = 1000000;
+ wptr = NULL;
+ wspace = 0;
+ }
+ ++state->seqno;
+
+ rptr += (proto > 0xff)? 2: 3; /* skip 1st proto byte if 0 */
+ state->strm.next_in = rptr;
+ state->strm.avail_in = mtod(mp, u_char *) + mp->m_len - rptr;
+ mp = mp->m_next;
+ flush = (mp == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
+ olen = 0;
+ for (;;) {
+ r = deflate(&state->strm, flush);
+ if (r != Z_OK) {
+ printf("z_compress: deflate returned %d (%s)\n",
+ r, (state->strm.msg? state->strm.msg: ""));
+ break;
+ }
+ if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
+ break; /* all done */
+ if (state->strm.avail_in == 0 && mp != NULL) {
+ state->strm.next_in = mtod(mp, u_char *);
+ state->strm.avail_in = mp->m_len;
+ mp = mp->m_next;
+ if (mp == NULL)
+ flush = Z_PACKET_FLUSH;
+ }
+ if (state->strm.avail_out == 0) {
+ if (m != NULL) {
+ m->m_len = wspace;
+ olen += wspace;
+ MGET(m->m_next, M_DONTWAIT, MT_DATA);
+ m = m->m_next;
+ if (m != NULL) {
+ m->m_len = 0;
+ if (maxolen - olen > MLEN)
+ MCLGET(m, M_DONTWAIT);
+ state->strm.next_out = mtod(m, u_char *);
+ state->strm.avail_out = wspace = M_TRAILINGSPACE(m);
+ }
+ }
+ if (m == NULL) {
+ state->strm.next_out = NULL;
+ state->strm.avail_out = 1000000;
+ }
+ }
+ }
+ if (m != NULL)
+ olen += (m->m_len = wspace - state->strm.avail_out);
+
+ /*
+ * See if we managed to reduce the size of the packet.
+ * If the compressor just gave us a single zero byte, it means
+ * the packet was incompressible.
+ */
+ if (m != NULL && olen < orig_len
+ && !(olen == PPP_HDRLEN + 3 && *wptr == 0)) {
+ state->stats.comp_bytes += olen;
+ state->stats.comp_packets++;
+ } else {
+ if (*mret != NULL) {
+ m_freem(*mret);
+ *mret = NULL;
+ }
+ state->stats.inc_bytes += orig_len;
+ state->stats.inc_packets++;
+ olen = orig_len;
+ }
+ state->stats.unc_bytes += orig_len;
+ state->stats.unc_packets++;
+
+ return olen;
+}
+
+static void
+z_comp_stats(arg, stats)
+ void *arg;
+ struct compstat *stats;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+ u_int out;
+
+ *stats = state->stats;
+ stats->ratio = stats->unc_bytes;
+ out = stats->comp_bytes + stats->inc_bytes;
+ if (stats->ratio <= 0x7ffffff)
+ stats->ratio <<= 8;
+ else
+ out >>= 8;
+ if (out != 0)
+ stats->ratio /= out;
+}
+
+/*
+ * Allocate space for a decompressor.
+ */
+static void *
+z_decomp_alloc(options, opt_len)
+ u_char *options;
+ int opt_len;
+{
+ struct deflate_state *state;
+ int w_size;
+
+ if (opt_len != CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return NULL;
+ w_size = DEFLATE_SIZE(options[2]);
+ if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
+ return NULL;
+
+ MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
+ M_DEVBUF, M_NOWAIT);
+ if (state == NULL)
+ return NULL;
+
+ state->strm.next_out = NULL;
+ state->strm.zalloc = zalloc;
+ state->strm.zfree = zfree;
+ if (inflateInit2(&state->strm, -w_size) != Z_OK) {
+ FREE(state, M_DEVBUF);
+ return NULL;
+ }
+
+ state->w_size = w_size;
+ bzero(&state->stats, sizeof(state->stats));
+ return (void *) state;
+}
+
+static void
+z_decomp_free(arg)
+ void *arg;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+
+ inflateEnd(&state->strm);
+ FREE(state, M_DEVBUF);
+}
+
+static int
+z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
+ void *arg;
+ u_char *options;
+ int opt_len, unit, hdrlen, mru, debug;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+
+ if (opt_len < CILEN_DEFLATE || options[0] != CI_DEFLATE
+ || options[1] != CILEN_DEFLATE
+ || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
+ || DEFLATE_SIZE(options[2]) != state->w_size
+ || options[3] != DEFLATE_CHK_SEQUENCE)
+ return 0;
+
+ state->seqno = 0;
+ state->unit = unit;
+ state->hdrlen = hdrlen;
+ state->debug = debug;
+ state->mru = mru;
+
+ inflateReset(&state->strm);
+
+ return 1;
+}
+
+static void
+z_decomp_reset(arg)
+ void *arg;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+
+ state->seqno = 0;
+ inflateReset(&state->strm);
+}
+
+/*
+ * Decompress a Deflate-compressed packet.
+ *
+ * Because of patent problems, we return DECOMP_ERROR for errors
+ * found by inspecting the input data and for system problems, but
+ * DECOMP_FATALERROR for any errors which could possibly be said to
+ * be being detected "after" decompression. For DECOMP_ERROR,
+ * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
+ * infringing a patent of Motorola's if we do, so we take CCP down
+ * instead.
+ *
+ * Given that the frame has the correct sequence number and a good FCS,
+ * errors such as invalid codes in the input most likely indicate a
+ * bug, so we return DECOMP_FATALERROR for them in order to turn off
+ * compression, even though they are detected by inspecting the input.
+ */
+int
+z_decompress(arg, mi, mop)
+ void *arg;
+ struct mbuf *mi, **mop;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+ struct mbuf *mo, *mo_head;
+ u_char *rptr, *wptr;
+ int rlen, olen, ospace;
+ int seq, i, flush, r, decode_proto;
+ u_char hdr[PPP_HDRLEN + DEFLATE_OVHD];
+
+ *mop = NULL;
+ rptr = mtod(mi, u_char *);
+ rlen = mi->m_len;
+ for (i = 0; i < PPP_HDRLEN + DEFLATE_OVHD; ++i) {
+ while (rlen <= 0) {
+ mi = mi->m_next;
+ if (mi == NULL)
+ return DECOMP_ERROR;
+ rptr = mtod(mi, u_char *);
+ rlen = mi->m_len;
+ }
+ hdr[i] = *rptr++;
+ --rlen;
+ }
+
+ /* Check the sequence number. */
+ seq = (hdr[PPP_HDRLEN] << 8) + hdr[PPP_HDRLEN+1];
+ if (seq != state->seqno) {
+ if (state->debug)
+ printf("z_decompress%d: bad seq # %d, expected %d\n",
+ state->unit, seq, state->seqno);
+ return DECOMP_ERROR;
+ }
+ ++state->seqno;
+
+ /* Allocate an output mbuf. */
+ MGETHDR(mo, M_DONTWAIT, MT_DATA);
+ if (mo == NULL)
+ return DECOMP_ERROR;
+ mo_head = mo;
+ mo->m_len = 0;
+ mo->m_next = NULL;
+ MCLGET(mo, M_DONTWAIT);
+ ospace = M_TRAILINGSPACE(mo);
+ if (state->hdrlen + PPP_HDRLEN < ospace) {
+ mo->m_data += state->hdrlen;
+ ospace -= state->hdrlen;
+ }
+
+ /*
+ * Fill in the first part of the PPP header. The protocol field
+ * comes from the decompressed data.
+ */
+ wptr = mtod(mo, u_char *);
+ wptr[0] = PPP_ADDRESS(hdr);
+ wptr[1] = PPP_CONTROL(hdr);
+ wptr[2] = 0;
+
+ /*
+ * Set up to call inflate. We set avail_out to 1 initially so we can
+ * look at the first byte of the output and decide whether we have
+ * a 1-byte or 2-byte protocol field.
+ */
+ state->strm.next_in = rptr;
+ state->strm.avail_in = rlen;
+ mi = mi->m_next;
+ flush = (mi == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
+ rlen += PPP_HDRLEN + DEFLATE_OVHD;
+ state->strm.next_out = wptr + 3;
+ state->strm.avail_out = 1;
+ decode_proto = 1;
+ olen = PPP_HDRLEN;
+
+ /*
+ * Call inflate, supplying more input or output as needed.
+ */
+ for (;;) {
+ r = inflate(&state->strm, flush);
+ if (r != Z_OK) {
+ if (state->debug)
+ printf("z_decompress%d: inflate returned %d (%s)\n",
+ state->unit, r, (state->strm.msg? state->strm.msg: ""));
+ m_freem(mo_head);
+ return DECOMP_FATALERROR;
+ }
+ if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
+ break; /* all done */
+ if (state->strm.avail_in == 0 && mi != NULL) {
+ state->strm.next_in = mtod(mi, u_char *);
+ state->strm.avail_in = mi->m_len;
+ rlen += mi->m_len;
+ mi = mi->m_next;
+ if (mi == NULL)
+ flush = Z_PACKET_FLUSH;
+ }
+ if (state->strm.avail_out == 0) {
+ if (decode_proto) {
+ state->strm.avail_out = ospace - PPP_HDRLEN;
+ if ((wptr[3] & 1) == 0) {
+ /* 2-byte protocol field */
+ wptr[2] = wptr[3];
+ --state->strm.next_out;
+ ++state->strm.avail_out;
+ --olen;
+ }
+ decode_proto = 0;
+ } else {
+ mo->m_len = ospace;
+ olen += ospace;
+ MGET(mo->m_next, M_DONTWAIT, MT_DATA);
+ mo = mo->m_next;
+ if (mo == NULL) {
+ m_freem(mo_head);
+ return DECOMP_ERROR;
+ }
+ MCLGET(mo, M_DONTWAIT);
+ state->strm.next_out = mtod(mo, u_char *);
+ state->strm.avail_out = ospace = M_TRAILINGSPACE(mo);
+ }
+ }
+ }
+ if (decode_proto) {
+ m_freem(mo_head);
+ return DECOMP_ERROR;
+ }
+ olen += (mo->m_len = ospace - state->strm.avail_out);
+
+ state->stats.unc_bytes += olen;
+ state->stats.unc_packets++;
+ state->stats.comp_bytes += rlen;
+ state->stats.comp_packets++;
+
+ *mop = mo_head;
+ return DECOMP_OK;
+}
+
+/*
+ * Incompressible data has arrived - add it to the history.
+ */
+static void
+z_incomp(arg, mi)
+ void *arg;
+ struct mbuf *mi;
+{
+ struct deflate_state *state = (struct deflate_state *) arg;
+ u_char *rptr;
+ int rlen, proto, r;
+
+ /*
+ * Check that the protocol is one we handle.
+ */
+ rptr = mtod(mi, u_char *);
+ proto = PPP_PROTOCOL(rptr);
+ if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
+ return;
+
+ ++state->seqno;
+
+ /*
+ * Iterate through the mbufs, adding the characters in them
+ * to the decompressor's history. For the first mbuf, we start
+ * at the either the 1st or 2nd byte of the protocol field,
+ * depending on whether the protocol value is compressible.
+ */
+ rlen = mi->m_len;
+ state->strm.next_in = rptr + 3;
+ state->strm.avail_in = rlen - 3;
+ if (proto > 0xff) {
+ --state->strm.next_in;
+ ++state->strm.avail_in;
+ }
+ for (;;) {
+ r = inflateIncomp(&state->strm);
+ if (r != Z_OK) {
+ /* gak! */
+ if (state->debug) {
+ printf("z_incomp%d: inflateIncomp returned %d (%s)\n",
+ state->unit, r, (state->strm.msg? state->strm.msg: ""));
+ }
+ return;
+ }
+ mi = mi->m_next;
+ if (mi == NULL)
+ break;
+ state->strm.next_in = mtod(mi, u_char *);
+ state->strm.avail_in = mi->m_len;
+ rlen += mi->m_len;
+ }
+
+ /*
+ * Update stats.
+ */
+ state->stats.inc_bytes += rlen;
+ state->stats.inc_packets++;
+ state->stats.unc_bytes += rlen;
+ state->stats.unc_packets++;
+}
+
+#endif /* DO_DEFLATE */
-/* $OpenBSD: ppp_tty.c,v 1.2 1996/03/03 21:07:12 niklas Exp $ */
-/* $NetBSD: ppp_tty.c,v 1.4 1996/02/13 22:00:30 christos Exp $ */
+/* $OpenBSD: ppp_tty.c,v 1.3 1996/04/21 22:28:42 deraadt Exp $ */
+/* $NetBSD: ppp_tty.c,v 1.5 1996/03/15 02:28:10 paulus Exp $ */
/*
* ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
#include <net/slcompress.h>
#endif
+#include <net/bpf.h>
#include <net/ppp_defs.h>
#include <net/if_ppp.h>
#include <net/if_pppvar.h>
int s;
s = spltty();
- ttywflush(tp);
+ ttyflush(tp, FREAD|FWRITE);
tp->t_line = 0;
sc = (struct ppp_softc *) tp->t_sc;
if (sc != NULL) {
* the line may have been idle for some time.
*/
if (CCOUNT(&tp->t_outq) == 0) {
- ++sc->sc_bytessent;
+ ++sc->sc_stats.ppp_obytes;
(void) putc(PPP_FLAG, &tp->t_outq);
}
ndone = n - b_to_q(start, n, &tp->t_outq);
len -= ndone;
start += ndone;
- sc->sc_bytessent += ndone;
+ sc->sc_stats.ppp_obytes += ndone;
if (ndone < n)
break; /* packet doesn't fit */
(void) unputc(&tp->t_outq);
break;
}
- sc->sc_bytessent += 2;
+ sc->sc_stats.ppp_obytes += 2;
start++;
len--;
}
unputc(&tp->t_outq);
break;
}
- sc->sc_bytessent += q - endseq;
+ sc->sc_stats.ppp_obytes += q - endseq;
}
if (!done) {
m = m2;
if (m == NULL) {
/* Finished a packet */
- sc->sc_if.if_opackets++;
- sc->sc_if.if_obytes = sc->sc_bytessent;
break;
}
sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len);
s = spltty(); /* should be unnecessary */
++tk_nin;
- ++sc->sc_bytesrcvd;
+ ++sc->sc_stats.ppp_ibytes;
if (c & TTY_FE) {
/* framing error or overrun on this char - abort packet */
c &= 0xff;
+ /*
+ * Handle software flow control of output.
+ */
+ if (tp->t_iflag & IXON) {
+ if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
+ if ((tp->t_state & TS_TTSTOP) == 0) {
+ tp->t_state |= TS_TTSTOP;
+ (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
+ }
+ return 0;
+ }
+ if (c == tp->t_cc[VSTART] && tp->t_cc[VSTART] != _POSIX_VDISABLE) {
+ tp->t_state &= ~TS_TTSTOP;
+ if (tp->t_oproc != NULL)
+ (*tp->t_oproc)(tp);
+ return 0;
+ }
+ }
+
if (c & 0x80)
sc->sc_flags |= SC_RCV_B7_1;
else
if (c == PPP_FLAG) {
ilen = sc->sc_ilen;
sc->sc_ilen = 0;
- sc->sc_if.if_ibytes = sc->sc_bytesrcvd;
if (sc->sc_rawin_count > 0)
ppplogchar(sc, -1);
printf("ppp%d: bad fcs %x\n", sc->sc_if.if_unit,
sc->sc_fcs);
sc->sc_if.if_ierrors++;
+ sc->sc_stats.ppp_ierrors++;
} else
sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
splx(s);
if (sc->sc_flags & SC_DEBUG)
printf("ppp%d: too short (%d)\n", sc->sc_if.if_unit, ilen);
sc->sc_if.if_ierrors++;
+ sc->sc_stats.ppp_ierrors++;
sc->sc_flags |= SC_PKTLOST;
}
splx(s);
flush:
if (!(sc->sc_flags & SC_FLUSH)) {
sc->sc_if.if_ierrors++;
+ sc->sc_stats.ppp_ierrors++;
sc->sc_flags |= SC_FLUSH;
if (sc->sc_flags & SC_LOG_FLUSH)
ppplogchar(sc, c);
-/* $OpenBSD: radix.c,v 1.2 1996/03/03 21:07:14 niklas Exp $ */
-/* $NetBSD: radix.c,v 1.10 1996/02/13 22:00:32 christos Exp $ */
+/* $OpenBSD: radix.c,v 1.3 1996/04/21 22:28:43 deraadt Exp $ */
+/* $NetBSD: radix.c,v 1.11 1996/03/16 23:55:36 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1993
m = mm;
}
if (m)
- log(LOG_ERR, "%s %x at %x\n",
+ log(LOG_ERR, "%s %p at %p\n",
"rn_delete: Orphaned Mask", m, x);
}
}
-/* $OpenBSD: rtsock.c,v 1.2 1996/03/03 21:07:21 niklas Exp $ */
-/* $NetBSD: rtsock.c,v 1.17 1996/02/13 22:00:52 christos Exp $ */
+/* $OpenBSD: rtsock.c,v 1.3 1996/04/21 22:28:44 deraadt Exp $ */
+/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
* Copyright (c) 1988, 1991, 1993
}
#define ROUNDUP(a) \
- ((a) > 0 ? (1 + (((a) - 1) | (sizeof(int32_t) - 1))) : sizeof(int32_t))
+ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
static void
-/* $OpenBSD: slcompress.c,v 1.3 1996/03/03 21:07:22 niklas Exp $ */
-/* $NetBSD: slcompress.c,v 1.14 1996/02/13 22:00:55 christos Exp $ */
+/* $OpenBSD: slcompress.c,v 1.4 1996/04/21 22:28:46 deraadt Exp $ */
+/* $NetBSD: slcompress.c,v 1.15 1996/03/15 02:28:12 paulus Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
register u_int i;
register struct cstate *tstate = comp->tstate;
- if (max_state == -1)
+ if (max_state == -1) {
max_state = MAX_STATES - 1;
bzero((char *)comp, sizeof(*comp));
+ } else {
+ /* Don't reset statistics */
+ bzero((char *)comp->tstate, sizeof(comp->tstate));
+ bzero((char *)comp->rstate, sizeof(comp->rstate));
+ }
for (i = max_state; i > 0; --i) {
tstate[i].cs_id = i;
tstate[i].cs_next = &tstate[i - 1];
--- /dev/null
+/* $NetBSD: zlib.c,v 1.2 1996/03/16 23:55:40 christos Exp $ */
+
+/*
+ * This file is derived from various .h and .c files from the zlib-0.95
+ * distribution by Jean-loup Gailly and Mark Adler, with some additions
+ * by Paul Mackerras to aid in implementing Deflate compression and
+ * decompression for PPP packets. See zlib.h for conditions of
+ * distribution and use.
+ *
+ * Changes that have been made include:
+ * - changed functions not used outside this file to "local"
+ * - added minCompression parameter to deflateInit2
+ * - added Z_PACKET_FLUSH (see zlib.h for details)
+ * - added inflateIncomp
+ */
+
+
+/*+++++*/
+/* zutil.h -- internal interface and configuration of the compression library
+ * Copyright (C) 1995 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* From: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp */
+
+#define _Z_UTIL_H
+
+#include "zlib.h"
+
+#ifdef STDC
+# include <string.h>
+#endif
+
+#ifndef local
+# define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+#define FAR
+
+typedef unsigned char uch;
+typedef uch FAR uchf;
+typedef unsigned short ush;
+typedef ush FAR ushf;
+typedef unsigned long ulg;
+
+extern char *z_errmsg[]; /* indexed by 1-zlib_error */
+
+#define ERR_RETURN(strm,err) return (strm->msg=z_errmsg[1-err], err)
+/* To be used only when the state is known to be valid */
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+ /* common constants */
+
+#define DEFLATED 8
+
+#ifndef DEF_WBITS
+# define DEF_WBITS MAX_WBITS
+#endif
+/* default windowBits for decompression. MAX_WBITS is for compression only */
+
+#if MAX_MEM_LEVEL >= 8
+# define DEF_MEM_LEVEL 8
+#else
+# define DEF_MEM_LEVEL MAX_MEM_LEVEL
+#endif
+/* default memLevel */
+
+#define STORED_BLOCK 0
+#define STATIC_TREES 1
+#define DYN_TREES 2
+/* The three kinds of block type */
+
+#define MIN_MATCH 3
+#define MAX_MATCH 258
+/* The minimum and maximum match lengths */
+
+ /* functions */
+
+#if defined(KERNEL) || defined(_KERNEL)
+# define zmemcpy(d, s, n) bcopy((s), (d), (n))
+# define zmemzero bzero
+#else
+#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
+# define HAVE_MEMCPY
+#endif
+#ifdef HAVE_MEMCPY
+# define zmemcpy memcpy
+# define zmemzero(dest, len) memset(dest, 0, len)
+#else
+ extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
+ extern void zmemzero OF((Bytef* dest, uInt len));
+#endif
+#endif
+
+/* Diagnostic functions */
+#ifdef DEBUG_ZLIB
+# include <stdio.h>
+# ifndef verbose
+# define verbose 0
+# endif
+# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
+# define Trace(x) fprintf x
+# define Tracev(x) {if (verbose) fprintf x ;}
+# define Tracevv(x) {if (verbose>1) fprintf x ;}
+# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
+# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
+#else
+# define Assert(cond,msg)
+# define Trace(x)
+# define Tracev(x)
+# define Tracevv(x)
+# define Tracec(c,x)
+# define Tracecv(c,x)
+#endif
+
+
+typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len));
+
+/* voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); */
+/* void zcfree OF((voidpf opaque, voidpf ptr)); */
+
+#define ZALLOC(strm, items, size) \
+ (*((strm)->zalloc))((strm)->opaque, (items), (size))
+#define ZFREE(strm, addr, size) \
+ (*((strm)->zfree))((strm)->opaque, (voidpf)(addr), (size))
+#define TRY_FREE(s, p, n) {if (p) ZFREE(s, p, n);}
+
+/* deflate.h -- internal compression state
+ * Copyright (C) 1995 Jean-loup Gailly
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+
+/*+++++*/
+/* From: deflate.h,v 1.5 1995/05/03 17:27:09 jloup Exp */
+
+/* ===========================================================================
+ * Internal compression state.
+ */
+
+/* Data type */
+#define BINARY 0
+#define ASCII 1
+#define UNKNOWN 2
+
+#define LENGTH_CODES 29
+/* number of length codes, not counting the special END_BLOCK code */
+
+#define LITERALS 256
+/* number of literal bytes 0..255 */
+
+#define L_CODES (LITERALS+1+LENGTH_CODES)
+/* number of Literal or Length codes, including the END_BLOCK code */
+
+#define D_CODES 30
+/* number of distance codes */
+
+#define BL_CODES 19
+/* number of codes used to transfer the bit lengths */
+
+#define HEAP_SIZE (2*L_CODES+1)
+/* maximum heap size */
+
+#define MAX_BITS 15
+/* All codes must not exceed MAX_BITS bits */
+
+#define INIT_STATE 42
+#define BUSY_STATE 113
+#define FLUSH_STATE 124
+#define FINISH_STATE 666
+/* Stream status */
+
+
+/* Data structure describing a single value and its code string. */
+typedef struct ct_data_s {
+ union {
+ ush freq; /* frequency count */
+ ush code; /* bit string */
+ } fc;
+ union {
+ ush dad; /* father node in Huffman tree */
+ ush len; /* length of bit string */
+ } dl;
+} FAR ct_data;
+
+#define Freq fc.freq
+#define Code fc.code
+#define Dad dl.dad
+#define Len dl.len
+
+typedef struct static_tree_desc_s static_tree_desc;
+
+typedef struct tree_desc_s {
+ ct_data *dyn_tree; /* the dynamic tree */
+ int max_code; /* largest code with non zero frequency */
+ static_tree_desc *stat_desc; /* the corresponding static tree */
+} FAR tree_desc;
+
+typedef ush Pos;
+typedef Pos FAR Posf;
+typedef unsigned IPos;
+
+/* A Pos is an index in the character window. We use short instead of int to
+ * save space in the various tables. IPos is used only for parameter passing.
+ */
+
+typedef struct deflate_state {
+ z_stream *strm; /* pointer back to this zlib stream */
+ int status; /* as the name implies */
+ Bytef *pending_buf; /* output still pending */
+ Bytef *pending_out; /* next pending byte to output to the stream */
+ int pending; /* nb of bytes in the pending buffer */
+ uLong adler; /* adler32 of uncompressed data */
+ int noheader; /* suppress zlib header and adler32 */
+ Byte data_type; /* UNKNOWN, BINARY or ASCII */
+ Byte method; /* STORED (for zip only) or DEFLATED */
+ int minCompr; /* min size decrease for Z_FLUSH_NOSTORE */
+
+ /* used by deflate.c: */
+
+ uInt w_size; /* LZ77 window size (32K by default) */
+ uInt w_bits; /* log2(w_size) (8..16) */
+ uInt w_mask; /* w_size - 1 */
+
+ Bytef *window;
+ /* Sliding window. Input bytes are read into the second half of the window,
+ * and move to the first half later to keep a dictionary of at least wSize
+ * bytes. With this organization, matches are limited to a distance of
+ * wSize-MAX_MATCH bytes, but this ensures that IO is always
+ * performed with a length multiple of the block size. Also, it limits
+ * the window size to 64K, which is quite useful on MSDOS.
+ * To do: use the user input buffer as sliding window.
+ */
+
+ ulg window_size;
+ /* Actual size of window: 2*wSize, except when the user input buffer
+ * is directly used as sliding window.
+ */
+
+ Posf *prev;
+ /* Link to older string with same hash index. To limit the size of this
+ * array to 64K, this link is maintained only for the last 32K strings.
+ * An index in this array is thus a window index modulo 32K.
+ */
+
+ Posf *head; /* Heads of the hash chains or NIL. */
+
+ uInt ins_h; /* hash index of string to be inserted */
+ uInt hash_size; /* number of elements in hash table */
+ uInt hash_bits; /* log2(hash_size) */
+ uInt hash_mask; /* hash_size-1 */
+
+ uInt hash_shift;
+ /* Number of bits by which ins_h must be shifted at each input
+ * step. It must be such that after MIN_MATCH steps, the oldest
+ * byte no longer takes part in the hash key, that is:
+ * hash_shift * MIN_MATCH >= hash_bits
+ */
+
+ long block_start;
+ /* Window position at the beginning of the current output block. Gets
+ * negative when the window is moved backwards.
+ */
+
+ uInt match_length; /* length of best match */
+ IPos prev_match; /* previous match */
+ int match_available; /* set if previous match exists */
+ uInt strstart; /* start of string to insert */
+ uInt match_start; /* start of matching string */
+ uInt lookahead; /* number of valid bytes ahead in window */
+
+ uInt prev_length;
+ /* Length of the best match at previous step. Matches not greater than this
+ * are discarded. This is used in the lazy match evaluation.
+ */
+
+ uInt max_chain_length;
+ /* To speed up deflation, hash chains are never searched beyond this
+ * length. A higher limit improves compression ratio but degrades the
+ * speed.
+ */
+
+ uInt max_lazy_match;
+ /* Attempt to find a better match only when the current match is strictly
+ * smaller than this value. This mechanism is used only for compression
+ * levels >= 4.
+ */
+# define max_insert_length max_lazy_match
+ /* Insert new strings in the hash table only if the match length is not
+ * greater than this length. This saves time but degrades compression.
+ * max_insert_length is used only for compression levels <= 3.
+ */
+
+ int level; /* compression level (1..9) */
+ int strategy; /* favor or force Huffman coding*/
+
+ uInt good_match;
+ /* Use a faster search when the previous match is longer than this */
+
+ int nice_match; /* Stop searching when current match exceeds this */
+
+ /* used by trees.c: */
+ /* Didn't use ct_data typedef below to supress compiler warning */
+ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
+ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
+ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
+
+ struct tree_desc_s l_desc; /* desc. for literal tree */
+ struct tree_desc_s d_desc; /* desc. for distance tree */
+ struct tree_desc_s bl_desc; /* desc. for bit length tree */
+
+ ush bl_count[MAX_BITS+1];
+ /* number of codes at each bit length for an optimal tree */
+
+ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
+ int heap_len; /* number of elements in the heap */
+ int heap_max; /* element of largest frequency */
+ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
+ * The same heap array is used to build all trees.
+ */
+
+ uch depth[2*L_CODES+1];
+ /* Depth of each subtree used as tie breaker for trees of equal frequency
+ */
+
+ uchf *l_buf; /* buffer for literals or lengths */
+
+ uInt lit_bufsize;
+ /* Size of match buffer for literals/lengths. There are 4 reasons for
+ * limiting lit_bufsize to 64K:
+ * - frequencies can be kept in 16 bit counters
+ * - if compression is not successful for the first block, all input
+ * data is still in the window so we can still emit a stored block even
+ * when input comes from standard input. (This can also be done for
+ * all blocks if lit_bufsize is not greater than 32K.)
+ * - if compression is not successful for a file smaller than 64K, we can
+ * even emit a stored file instead of a stored block (saving 5 bytes).
+ * This is applicable only for zip (not gzip or zlib).
+ * - creating new Huffman trees less frequently may not provide fast
+ * adaptation to changes in the input data statistics. (Take for
+ * example a binary file with poorly compressible code followed by
+ * a highly compressible string table.) Smaller buffer sizes give
+ * fast adaptation but have of course the overhead of transmitting
+ * trees more frequently.
+ * - I can't count above 4
+ */
+
+ uInt last_lit; /* running index in l_buf */
+
+ ushf *d_buf;
+ /* Buffer for distances. To simplify the code, d_buf and l_buf have
+ * the same number of elements. To use different lengths, an extra flag
+ * array would be necessary.
+ */
+
+ ulg opt_len; /* bit length of current block with optimal trees */
+ ulg static_len; /* bit length of current block with static trees */
+ ulg compressed_len; /* total bit length of compressed file */
+ uInt matches; /* number of string matches in current block */
+ int last_eob_len; /* bit length of EOB code for last block */
+
+#ifdef DEBUG_ZLIB
+ ulg bits_sent; /* bit length of the compressed data */
+#endif
+
+ ush bi_buf;
+ /* Output buffer. bits are inserted starting at the bottom (least
+ * significant bits).
+ */
+ int bi_valid;
+ /* Number of valid bits in bi_buf. All bits above the last valid bit
+ * are always zero.
+ */
+
+ uInt blocks_in_packet;
+ /* Number of blocks produced since the last time Z_PACKET_FLUSH
+ * was used.
+ */
+
+} FAR deflate_state;
+
+/* Output a byte on the stream.
+ * IN assertion: there is enough room in pending_buf.
+ */
+#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
+
+
+#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
+/* Minimum amount of lookahead, except at the end of the input file.
+ * See deflate.c for comments about the MIN_MATCH+1.
+ */
+
+#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
+/* In order to simplify the code, particularly on 16 bit machines, match
+ * distances are limited to MAX_DIST instead of WSIZE.
+ */
+
+ /* in trees.c */
+local void ct_init OF((deflate_state *s));
+local int ct_tally OF((deflate_state *s, int dist, int lc));
+local ulg ct_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
+ int flush));
+local void ct_align OF((deflate_state *s));
+local void ct_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
+ int eof));
+local void ct_stored_type_only OF((deflate_state *s));
+
+
+/*+++++*/
+/* deflate.c -- compress data using the deflation algorithm
+ * Copyright (C) 1995 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/*
+ * ALGORITHM
+ *
+ * The "deflation" process depends on being able to identify portions
+ * of the input text which are identical to earlier input (within a
+ * sliding window trailing behind the input currently being processed).
+ *
+ * The most straightforward technique turns out to be the fastest for
+ * most input files: try all possible matches and select the longest.
+ * The key feature of this algorithm is that insertions into the string
+ * dictionary are very simple and thus fast, and deletions are avoided
+ * completely. Insertions are performed at each input character, whereas
+ * string matches are performed only when the previous match ends. So it
+ * is preferable to spend more time in matches to allow very fast string
+ * insertions and avoid deletions. The matching algorithm for small
+ * strings is inspired from that of Rabin & Karp. A brute force approach
+ * is used to find longer strings when a small match has been found.
+ * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
+ * (by Leonid Broukhis).
+ * A previous version of this file used a more sophisticated algorithm
+ * (by Fiala and Greene) which is guaranteed to run in linear amortized
+ * time, but has a larger average cost, uses more memory and is patented.
+ * However the F&G algorithm may be faster for some highly redundant
+ * files if the parameter max_chain_length (described below) is too large.
+ *
+ * ACKNOWLEDGEMENTS
+ *
+ * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
+ * I found it in 'freeze' written by Leonid Broukhis.
+ * Thanks to many people for bug reports and testing.
+ *
+ * REFERENCES
+ *
+ * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
+ * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
+ *
+ * A description of the Rabin and Karp algorithm is given in the book
+ * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
+ *
+ * Fiala,E.R., and Greene,D.H.
+ * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
+ *
+ */
+
+/* From: deflate.c,v 1.8 1995/05/03 17:27:08 jloup Exp */
+
+#if 0
+local char zlib_copyright[] = " deflate Copyright 1995 Jean-loup Gailly ";
+#endif
+/*
+ If you use the zlib library in a product, an acknowledgment is welcome
+ in the documentation of your product. If for some reason you cannot
+ include such an acknowledgment, I would appreciate that you keep this
+ copyright string in the executable of your product.
+ */
+
+#define NIL 0
+/* Tail of hash chains */
+
+#ifndef TOO_FAR
+# define TOO_FAR 4096
+#endif
+/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
+
+#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
+/* Minimum amount of lookahead, except at the end of the input file.
+ * See deflate.c for comments about the MIN_MATCH+1.
+ */
+
+/* Values for max_lazy_match, good_match and max_chain_length, depending on
+ * the desired pack level (0..9). The values given below have been tuned to
+ * exclude worst case performance for pathological files. Better values may be
+ * found for specific files.
+ */
+
+typedef struct config_s {
+ ush good_length; /* reduce lazy search above this match length */
+ ush max_lazy; /* do not perform lazy search above this match length */
+ ush nice_length; /* quit search above this match length */
+ ush max_chain;
+} config;
+
+local config configuration_table[10] = {
+/* good lazy nice chain */
+/* 0 */ {0, 0, 0, 0}, /* store only */
+/* 1 */ {4, 4, 8, 4}, /* maximum speed, no lazy matches */
+/* 2 */ {4, 5, 16, 8},
+/* 3 */ {4, 6, 32, 32},
+
+/* 4 */ {4, 4, 16, 16}, /* lazy matches */
+/* 5 */ {8, 16, 32, 32},
+/* 6 */ {8, 16, 128, 128},
+/* 7 */ {8, 32, 128, 256},
+/* 8 */ {32, 128, 258, 1024},
+/* 9 */ {32, 258, 258, 4096}}; /* maximum compression */
+
+/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
+ * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
+ * meaning.
+ */
+
+#define EQUAL 0
+/* result of memcmp for equal strings */
+
+/* ===========================================================================
+ * Prototypes for local functions.
+ */
+
+local void fill_window OF((deflate_state *s));
+local int deflate_fast OF((deflate_state *s, int flush));
+local int deflate_slow OF((deflate_state *s, int flush));
+local void lm_init OF((deflate_state *s));
+local int longest_match OF((deflate_state *s, IPos cur_match));
+local void putShortMSB OF((deflate_state *s, uInt b));
+local void flush_pending OF((z_stream *strm));
+local int read_buf OF((z_stream *strm, charf *buf, unsigned size));
+#ifdef ASMV
+ void match_init OF((void)); /* asm code initialization */
+#endif
+
+#ifdef DEBUG_ZLIB
+local void check_match OF((deflate_state *s, IPos start, IPos match,
+ int length));
+#endif
+
+
+/* ===========================================================================
+ * Update a hash value with the given input byte
+ * IN assertion: all calls to to UPDATE_HASH are made with consecutive
+ * input characters, so that a running hash key can be computed from the
+ * previous key instead of complete recalculation each time.
+ */
+#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
+
+
+/* ===========================================================================
+ * Insert string str in the dictionary and set match_head to the previous head
+ * of the hash chain (the most recent string with same hash key). Return
+ * the previous length of the hash chain.
+ * IN assertion: all calls to to INSERT_STRING are made with consecutive
+ * input characters and the first MIN_MATCH bytes of str are valid
+ * (except for the last MIN_MATCH-1 bytes of the input file).
+ */
+#define INSERT_STRING(s, str, match_head) \
+ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
+ s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \
+ s->head[s->ins_h] = (str))
+
+/* ===========================================================================
+ * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
+ * prev[] will be initialized on the fly.
+ */
+#define CLEAR_HASH(s) \
+ s->head[s->hash_size-1] = NIL; \
+ zmemzero((charf *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+
+/* ========================================================================= */
+int deflateInit (strm, level)
+ z_stream *strm;
+ int level;
+{
+ return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
+ 0, 0);
+ /* To do: ignore strm->next_in if we use it as window */
+}
+
+/* ========================================================================= */
+int deflateInit2 (strm, level, method, windowBits, memLevel,
+ strategy, minCompression)
+ z_stream *strm;
+ int level;
+ int method;
+ int windowBits;
+ int memLevel;
+ int strategy;
+ int minCompression;
+{
+ deflate_state *s;
+ int noheader = 0;
+
+ if (strm == Z_NULL) return Z_STREAM_ERROR;
+
+ strm->msg = Z_NULL;
+/* if (strm->zalloc == Z_NULL) strm->zalloc = zcalloc; */
+/* if (strm->zfree == Z_NULL) strm->zfree = zcfree; */
+
+ if (level == Z_DEFAULT_COMPRESSION) level = 6;
+
+ if (windowBits < 0) { /* undocumented feature: suppress zlib header */
+ noheader = 1;
+ windowBits = -windowBits;
+ }
+ if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != DEFLATED ||
+ windowBits < 8 || windowBits > 15 || level < 1 || level > 9) {
+ return Z_STREAM_ERROR;
+ }
+ s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
+ if (s == Z_NULL) return Z_MEM_ERROR;
+ strm->state = (struct internal_state FAR *)s;
+ s->strm = strm;
+
+ s->noheader = noheader;
+ s->w_bits = windowBits;
+ s->w_size = 1 << s->w_bits;
+ s->w_mask = s->w_size - 1;
+
+ s->hash_bits = memLevel + 7;
+ s->hash_size = 1 << s->hash_bits;
+ s->hash_mask = s->hash_size - 1;
+ s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
+
+ s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
+ s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
+ s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
+
+ s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
+
+ s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 2*sizeof(ush));
+
+ if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
+ s->pending_buf == Z_NULL) {
+ strm->msg = z_errmsg[1-Z_MEM_ERROR];
+ deflateEnd (strm);
+ return Z_MEM_ERROR;
+ }
+ s->d_buf = (ushf *) &(s->pending_buf[s->lit_bufsize]);
+ s->l_buf = (uchf *) &(s->pending_buf[3*s->lit_bufsize]);
+ /* We overlay pending_buf and d_buf+l_buf. This works since the average
+ * output size for (length,distance) codes is <= 32 bits (worst case
+ * is 15+15+13=33).
+ */
+
+ s->level = level;
+ s->strategy = strategy;
+ s->method = (Byte)method;
+ s->minCompr = minCompression;
+ s->blocks_in_packet = 0;
+
+ return deflateReset(strm);
+}
+
+/* ========================================================================= */
+int deflateReset (strm)
+ z_stream *strm;
+{
+ deflate_state *s;
+
+ if (strm == Z_NULL || strm->state == Z_NULL ||
+ strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR;
+
+ strm->total_in = strm->total_out = 0;
+ strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
+ strm->data_type = Z_UNKNOWN;
+
+ s = (deflate_state *)strm->state;
+ s->pending = 0;
+ s->pending_out = s->pending_buf;
+
+ if (s->noheader < 0) {
+ s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */
+ }
+ s->status = s->noheader ? BUSY_STATE : INIT_STATE;
+ s->adler = 1;
+
+ ct_init(s);
+ lm_init(s);
+
+ return Z_OK;
+}
+
+/* =========================================================================
+ * Put a short in the pending buffer. The 16-bit value is put in MSB order.
+ * IN assertion: the stream state is correct and there is enough room in
+ * pending_buf.
+ */
+local void putShortMSB (s, b)
+ deflate_state *s;
+ uInt b;
+{
+ put_byte(s, (Byte)(b >> 8));
+ put_byte(s, (Byte)(b & 0xff));
+}
+
+/* =========================================================================
+ * Flush as much pending output as possible.
+ */
+local void flush_pending(strm)
+ z_stream *strm;
+{
+ deflate_state *state = (deflate_state *) strm->state;
+ unsigned len = state->pending;
+
+ if (len > strm->avail_out) len = strm->avail_out;
+ if (len == 0) return;
+
+ if (strm->next_out != NULL) {
+ zmemcpy(strm->next_out, state->pending_out, len);
+ strm->next_out += len;
+ }
+ state->pending_out += len;
+ strm->total_out += len;
+ strm->avail_out -= len;
+ state->pending -= len;
+ if (state->pending == 0) {
+ state->pending_out = state->pending_buf;
+ }
+}
+
+/* ========================================================================= */
+int deflate (strm, flush)
+ z_stream *strm;
+ int flush;
+{
+ deflate_state *state = (deflate_state *) strm->state;
+
+ if (strm == Z_NULL || state == Z_NULL) return Z_STREAM_ERROR;
+
+ if (strm->next_in == Z_NULL && strm->avail_in != 0) {
+ ERR_RETURN(strm, Z_STREAM_ERROR);
+ }
+ if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
+
+ state->strm = strm; /* just in case */
+
+ /* Write the zlib header */
+ if (state->status == INIT_STATE) {
+
+ uInt header = (DEFLATED + ((state->w_bits-8)<<4)) << 8;
+ uInt level_flags = (state->level-1) >> 1;
+
+ if (level_flags > 3) level_flags = 3;
+ header |= (level_flags << 6);
+ header += 31 - (header % 31);
+
+ state->status = BUSY_STATE;
+ putShortMSB(state, header);
+ }
+
+ /* Flush as much pending output as possible */
+ if (state->pending != 0) {
+ flush_pending(strm);
+ if (strm->avail_out == 0) return Z_OK;
+ }
+
+ /* If we came back in here to get the last output from
+ * a previous flush, we're done for now.
+ */
+ if (state->status == FLUSH_STATE) {
+ state->status = BUSY_STATE;
+ if (flush != Z_NO_FLUSH && flush != Z_FINISH)
+ return Z_OK;
+ }
+
+ /* User must not provide more input after the first FINISH: */
+ if (state->status == FINISH_STATE && strm->avail_in != 0) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
+ /* Start a new block or continue the current one.
+ */
+ if (strm->avail_in != 0 || state->lookahead != 0 ||
+ (flush == Z_FINISH && state->status != FINISH_STATE)) {
+ int quit;
+
+ if (flush == Z_FINISH) {
+ state->status = FINISH_STATE;
+ }
+ if (state->level <= 3) {
+ quit = deflate_fast(state, flush);
+ } else {
+ quit = deflate_slow(state, flush);
+ }
+ if (quit || strm->avail_out == 0)
+ return Z_OK;
+ /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
+ * of deflate should use the same flush parameter to make sure
+ * that the flush is complete. So we don't have to output an
+ * empty block here, this will be done at next call. This also
+ * ensures that for a very small output buffer, we emit at most
+ * one empty block.
+ */
+ }
+
+ /* If a flush was requested, we have a little more to output now. */
+ if (flush != Z_NO_FLUSH && flush != Z_FINISH
+ && state->status != FINISH_STATE) {
+ switch (flush) {
+ case Z_PARTIAL_FLUSH:
+ ct_align(state);
+ break;
+ case Z_PACKET_FLUSH:
+ /* Output just the 3-bit `stored' block type value,
+ but not a zero length. */
+ ct_stored_type_only(state);
+ break;
+ default:
+ ct_stored_block(state, (char*)0, 0L, 0);
+ /* For a full flush, this empty block will be recognized
+ * as a special marker by inflate_sync().
+ */
+ if (flush == Z_FULL_FLUSH) {
+ CLEAR_HASH(state); /* forget history */
+ }
+ }
+ flush_pending(strm);
+ if (strm->avail_out == 0) {
+ /* We'll have to come back to get the rest of the output;
+ * this ensures we don't output a second zero-length stored
+ * block (or whatever).
+ */
+ state->status = FLUSH_STATE;
+ return Z_OK;
+ }
+ }
+
+ Assert(strm->avail_out > 0, "bug2");
+
+ if (flush != Z_FINISH) return Z_OK;
+ if (state->noheader) return Z_STREAM_END;
+
+ /* Write the zlib trailer (adler32) */
+ putShortMSB(state, (uInt)(state->adler >> 16));
+ putShortMSB(state, (uInt)(state->adler & 0xffff));
+ flush_pending(strm);
+ /* If avail_out is zero, the application will call deflate again
+ * to flush the rest.
+ */
+ state->noheader = -1; /* write the trailer only once! */
+ return state->pending != 0 ? Z_OK : Z_STREAM_END;
+}
+
+/* ========================================================================= */
+int deflateEnd (strm)
+ z_stream *strm;
+{
+ deflate_state *state = (deflate_state *) strm->state;
+
+ if (strm == Z_NULL || state == Z_NULL) return Z_STREAM_ERROR;
+
+ TRY_FREE(strm, state->window, state->w_size * 2 * sizeof(Byte));
+ TRY_FREE(strm, state->prev, state->w_size * sizeof(Pos));
+ TRY_FREE(strm, state->head, state->hash_size * sizeof(Pos));
+ TRY_FREE(strm, state->pending_buf, state->lit_bufsize * 2 * sizeof(ush));
+
+ ZFREE(strm, state, sizeof(deflate_state));
+ strm->state = Z_NULL;
+
+ return Z_OK;
+}
+
+/* ===========================================================================
+ * Read a new buffer from the current input stream, update the adler32
+ * and total number of bytes read.
+ */
+local int read_buf(strm, buf, size)
+ z_stream *strm;
+ charf *buf;
+ unsigned size;
+{
+ unsigned len = strm->avail_in;
+ deflate_state *state = (deflate_state *) strm->state;
+
+ if (len > size) len = size;
+ if (len == 0) return 0;
+
+ strm->avail_in -= len;
+
+ if (!state->noheader) {
+ state->adler = adler32(state->adler, strm->next_in, len);
+ }
+ zmemcpy(buf, strm->next_in, len);
+ strm->next_in += len;
+ strm->total_in += len;
+
+ return (int)len;
+}
+
+/* ===========================================================================
+ * Initialize the "longest match" routines for a new zlib stream
+ */
+local void lm_init (s)
+ deflate_state *s;
+{
+ s->window_size = (ulg)2L*s->w_size;
+
+ CLEAR_HASH(s);
+
+ /* Set the default configuration parameters:
+ */
+ s->max_lazy_match = configuration_table[s->level].max_lazy;
+ s->good_match = configuration_table[s->level].good_length;
+ s->nice_match = configuration_table[s->level].nice_length;
+ s->max_chain_length = configuration_table[s->level].max_chain;
+
+ s->strstart = 0;
+ s->block_start = 0L;
+ s->lookahead = 0;
+ s->match_length = MIN_MATCH-1;
+ s->match_available = 0;
+ s->ins_h = 0;
+#ifdef ASMV
+ match_init(); /* initialize the asm code */
+#endif
+}
+
+/* ===========================================================================
+ * Set match_start to the longest match starting at the given string and
+ * return its length. Matches shorter or equal to prev_length are discarded,
+ * in which case the result is equal to prev_length and match_start is
+ * garbage.
+ * IN assertions: cur_match is the head of the hash chain for the current
+ * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
+ */
+#ifndef ASMV
+/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
+ * match.S. The code will be functionally equivalent.
+ */
+local int longest_match(s, cur_match)
+ deflate_state *s;
+ IPos cur_match; /* current match */
+{
+ unsigned chain_length = s->max_chain_length;/* max hash chain length */
+ register Bytef *scan = s->window + s->strstart; /* current string */
+ register Bytef *match; /* matched string */
+ register int len; /* length of current match */
+ int best_len = s->prev_length; /* best match length so far */
+ IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
+ s->strstart - (IPos)MAX_DIST(s) : NIL;
+ /* Stop when cur_match becomes <= limit. To simplify the code,
+ * we prevent matches with the string of window index 0.
+ */
+ Posf *prev = s->prev;
+ uInt wmask = s->w_mask;
+
+#ifdef UNALIGNED_OK
+ /* Compare two bytes at a time. Note: this is not always beneficial.
+ * Try with and without -DUNALIGNED_OK to check.
+ */
+ register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
+ register ush scan_start = *(ushf*)scan;
+ register ush scan_end = *(ushf*)(scan+best_len-1);
+#else
+ register Bytef *strend = s->window + s->strstart + MAX_MATCH;
+ register Byte scan_end1 = scan[best_len-1];
+ register Byte scan_end = scan[best_len];
+#endif
+
+ /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
+ * It is easy to get rid of this optimization if necessary.
+ */
+ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
+
+ /* Do not waste too much time if we already have a good match: */
+ if (s->prev_length >= s->good_match) {
+ chain_length >>= 2;
+ }
+ Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
+
+ do {
+ Assert(cur_match < s->strstart, "no future");
+ match = s->window + cur_match;
+
+ /* Skip to next match if the match length cannot increase
+ * or if the match length is less than 2:
+ */
+#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
+ /* This code assumes sizeof(unsigned short) == 2. Do not use
+ * UNALIGNED_OK if your compiler uses a different size.
+ */
+ if (*(ushf*)(match+best_len-1) != scan_end ||
+ *(ushf*)match != scan_start) continue;
+
+ /* It is not necessary to compare scan[2] and match[2] since they are
+ * always equal when the other bytes match, given that the hash keys
+ * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
+ * strstart+3, +5, ... up to strstart+257. We check for insufficient
+ * lookahead only every 4th comparison; the 128th check will be made
+ * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
+ * necessary to put more guard bytes at the end of the window, or
+ * to check more often for insufficient lookahead.
+ */
+ Assert(scan[2] == match[2], "scan[2]?");
+ scan++, match++;
+ do {
+ } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ scan < strend);
+ /* The funny "do {}" generates better code on most compilers */
+
+ /* Here, scan <= window+strstart+257 */
+ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+ if (*scan == *match) scan++;
+
+ len = (MAX_MATCH - 1) - (int)(strend-scan);
+ scan = strend - (MAX_MATCH-1);
+
+#else /* UNALIGNED_OK */
+
+ if (match[best_len] != scan_end ||
+ match[best_len-1] != scan_end1 ||
+ *match != *scan ||
+ *++match != scan[1]) continue;
+
+ /* The check at best_len-1 can be removed because it will be made
+ * again later. (This heuristic is not always a win.)
+ * It is not necessary to compare scan[2] and match[2] since they
+ * are always equal when the other bytes match, given that
+ * the hash keys are equal and that HASH_BITS >= 8.
+ */
+ scan += 2, match++;
+ Assert(*scan == *match, "match[2]?");
+
+ /* We check for insufficient lookahead only every 8th comparison;
+ * the 256th check will be made at strstart+258.
+ */
+ do {
+ } while (*++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ scan < strend);
+
+ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+
+ len = MAX_MATCH - (int)(strend - scan);
+ scan = strend - MAX_MATCH;
+
+#endif /* UNALIGNED_OK */
+
+ if (len > best_len) {
+ s->match_start = cur_match;
+ best_len = len;
+ if (len >= s->nice_match) break;
+#ifdef UNALIGNED_OK
+ scan_end = *(ushf*)(scan+best_len-1);
+#else
+ scan_end1 = scan[best_len-1];
+ scan_end = scan[best_len];
+#endif
+ }
+ } while ((cur_match = prev[cur_match & wmask]) > limit
+ && --chain_length != 0);
+
+ return best_len;
+}
+#endif /* ASMV */
+
+#ifdef DEBUG_ZLIB
+/* ===========================================================================
+ * Check that the match at match_start is indeed a match.
+ */
+local void check_match(s, start, match, length)
+ deflate_state *s;
+ IPos start, match;
+ int length;
+{
+ /* check that the match is indeed a match */
+ if (memcmp((charf *)s->window + match,
+ (charf *)s->window + start, length) != EQUAL) {
+ fprintf(stderr,
+ " start %u, match %u, length %d\n",
+ start, match, length);
+ do { fprintf(stderr, "%c%c", s->window[match++],
+ s->window[start++]); } while (--length != 0);
+ z_error("invalid match");
+ }
+ if (verbose > 1) {
+ fprintf(stderr,"\\[%d,%d]", start-match, length);
+ do { putc(s->window[start++], stderr); } while (--length != 0);
+ }
+}
+#else
+# define check_match(s, start, match, length)
+#endif
+
+/* ===========================================================================
+ * Fill the window when the lookahead becomes insufficient.
+ * Updates strstart and lookahead.
+ *
+ * IN assertion: lookahead < MIN_LOOKAHEAD
+ * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
+ * At least one byte has been read, or avail_in == 0; reads are
+ * performed for at least two bytes (required for the zip translate_eol
+ * option -- not supported here).
+ */
+local void fill_window(s)
+ deflate_state *s;
+{
+ register unsigned n, m;
+ register Posf *p;
+ unsigned more; /* Amount of free space at the end of the window. */
+ uInt wsize = s->w_size;
+
+ do {
+ more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
+
+ /* Deal with !@#$% 64K limit: */
+ if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
+ more = wsize;
+ } else if (more == (unsigned)(-1)) {
+ /* Very unlikely, but possible on 16 bit machine if strstart == 0
+ * and lookahead == 1 (input done one byte at time)
+ */
+ more--;
+
+ /* If the window is almost full and there is insufficient lookahead,
+ * move the upper half to the lower one to make room in the upper half.
+ */
+ } else if (s->strstart >= wsize+MAX_DIST(s)) {
+
+ /* By the IN assertion, the window is not empty so we can't confuse
+ * more == 0 with more == 64K on a 16 bit machine.
+ */
+ zmemcpy((charf *)s->window, (charf *)s->window+wsize,
+ (unsigned)wsize);
+ s->match_start -= wsize;
+ s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
+
+ s->block_start -= (long) wsize;
+
+ /* Slide the hash table (could be avoided with 32 bit values
+ at the expense of memory usage):
+ */
+ n = s->hash_size;
+ p = &s->head[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m-wsize : NIL);
+ } while (--n);
+
+ n = wsize;
+ p = &s->prev[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m-wsize : NIL);
+ /* If n is not on any hash chain, prev[n] is garbage but
+ * its value will never be used.
+ */
+ } while (--n);
+
+ more += wsize;
+ }
+ if (s->strm->avail_in == 0) return;
+
+ /* If there was no sliding:
+ * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
+ * more == window_size - lookahead - strstart
+ * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
+ * => more >= window_size - 2*WSIZE + 2
+ * In the BIG_MEM or MMAP case (not yet supported),
+ * window_size == input_size + MIN_LOOKAHEAD &&
+ * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
+ * Otherwise, window_size == 2*WSIZE so more >= 2.
+ * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
+ */
+ Assert(more >= 2, "more < 2");
+
+ n = read_buf(s->strm, (charf *)s->window + s->strstart + s->lookahead,
+ more);
+ s->lookahead += n;
+
+ /* Initialize the hash value now that we have some input: */
+ if (s->lookahead >= MIN_MATCH) {
+ s->ins_h = s->window[s->strstart];
+ UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
+#if MIN_MATCH != 3
+ Call UPDATE_HASH() MIN_MATCH-3 more times
+#endif
+ }
+ /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
+ * but this is not important since only literal bytes will be emitted.
+ */
+
+ } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
+}
+
+/* ===========================================================================
+ * Flush the current block, with given end-of-file flag.
+ * IN assertion: strstart is set to the end of the current match.
+ */
+#define FLUSH_BLOCK_ONLY(s, flush) { \
+ ct_flush_block(s, (s->block_start >= 0L ? \
+ (charf *)&s->window[(unsigned)s->block_start] : \
+ (charf *)Z_NULL), (long)s->strstart - s->block_start, (flush)); \
+ s->block_start = s->strstart; \
+ flush_pending(s->strm); \
+ Tracev((stderr,"[FLUSH]")); \
+}
+
+/* Same but force premature exit if necessary. */
+#define FLUSH_BLOCK(s, flush) { \
+ FLUSH_BLOCK_ONLY(s, flush); \
+ if (s->strm->avail_out == 0) return 1; \
+}
+
+/* ===========================================================================
+ * Compress as much as possible from the input stream, return true if
+ * processing was terminated prematurely (no more input or output space).
+ * This function does not perform lazy evaluationof matches and inserts
+ * new strings in the dictionary only for unmatched strings or for short
+ * matches. It is used only for the fast compression options.
+ */
+local int deflate_fast(s, flush)
+ deflate_state *s;
+ int flush;
+{
+ IPos hash_head = NIL; /* head of the hash chain */
+ int bflush; /* set if current block must be flushed */
+
+ s->prev_length = MIN_MATCH-1;
+
+ for (;;) {
+ /* Make sure that we always have enough lookahead, except
+ * at the end of the input file. We need MAX_MATCH bytes
+ * for the next match, plus MIN_MATCH bytes to insert the
+ * string following the next match.
+ */
+ if (s->lookahead < MIN_LOOKAHEAD) {
+ fill_window(s);
+ if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1;
+
+ if (s->lookahead == 0) break; /* flush the current block */
+ }
+
+ /* Insert the string window[strstart .. strstart+2] in the
+ * dictionary, and set hash_head to the head of the hash chain:
+ */
+ if (s->lookahead >= MIN_MATCH) {
+ INSERT_STRING(s, s->strstart, hash_head);
+ }
+
+ /* Find the longest match, discarding those <= prev_length.
+ * At this point we have always match_length < MIN_MATCH
+ */
+ if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
+ /* To simplify the code, we prevent matches with the string
+ * of window index 0 (in particular we have to avoid a match
+ * of the string with itself at the start of the input file).
+ */
+ if (s->strategy != Z_HUFFMAN_ONLY) {
+ s->match_length = longest_match (s, hash_head);
+ }
+ /* longest_match() sets match_start */
+
+ if (s->match_length > s->lookahead) s->match_length = s->lookahead;
+ }
+ if (s->match_length >= MIN_MATCH) {
+ check_match(s, s->strstart, s->match_start, s->match_length);
+
+ bflush = ct_tally(s, s->strstart - s->match_start,
+ s->match_length - MIN_MATCH);
+
+ s->lookahead -= s->match_length;
+
+ /* Insert new strings in the hash table only if the match length
+ * is not too large. This saves time but degrades compression.
+ */
+ if (s->match_length <= s->max_insert_length &&
+ s->lookahead >= MIN_MATCH) {
+ s->match_length--; /* string at strstart already in hash table */
+ do {
+ s->strstart++;
+ INSERT_STRING(s, s->strstart, hash_head);
+ /* strstart never exceeds WSIZE-MAX_MATCH, so there are
+ * always MIN_MATCH bytes ahead.
+ */
+ } while (--s->match_length != 0);
+ s->strstart++;
+ } else {
+ s->strstart += s->match_length;
+ s->match_length = 0;
+ s->ins_h = s->window[s->strstart];
+ UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
+#if MIN_MATCH != 3
+ Call UPDATE_HASH() MIN_MATCH-3 more times
+#endif
+ /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
+ * matter since it will be recomputed at next deflate call.
+ */
+ }
+ } else {
+ /* No match, output a literal byte */
+ Tracevv((stderr,"%c", s->window[s->strstart]));
+ bflush = ct_tally (s, 0, s->window[s->strstart]);
+ s->lookahead--;
+ s->strstart++;
+ }
+ if (bflush) FLUSH_BLOCK(s, Z_NO_FLUSH);
+ }
+ FLUSH_BLOCK(s, flush);
+ return 0; /* normal exit */
+}
+
+/* ===========================================================================
+ * Same as above, but achieves better compression. We use a lazy
+ * evaluation for matches: a match is finally adopted only if there is
+ * no better match at the next window position.
+ */
+local int deflate_slow(s, flush)
+ deflate_state *s;
+ int flush;
+{
+ IPos hash_head = NIL; /* head of hash chain */
+ int bflush; /* set if current block must be flushed */
+
+ /* Process the input block. */
+ for (;;) {
+ /* Make sure that we always have enough lookahead, except
+ * at the end of the input file. We need MAX_MATCH bytes
+ * for the next match, plus MIN_MATCH bytes to insert the
+ * string following the next match.
+ */
+ if (s->lookahead < MIN_LOOKAHEAD) {
+ fill_window(s);
+ if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1;
+
+ if (s->lookahead == 0) break; /* flush the current block */
+ }
+
+ /* Insert the string window[strstart .. strstart+2] in the
+ * dictionary, and set hash_head to the head of the hash chain:
+ */
+ if (s->lookahead >= MIN_MATCH) {
+ INSERT_STRING(s, s->strstart, hash_head);
+ }
+
+ /* Find the longest match, discarding those <= prev_length.
+ */
+ s->prev_length = s->match_length, s->prev_match = s->match_start;
+ s->match_length = MIN_MATCH-1;
+
+ if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
+ s->strstart - hash_head <= MAX_DIST(s)) {
+ /* To simplify the code, we prevent matches with the string
+ * of window index 0 (in particular we have to avoid a match
+ * of the string with itself at the start of the input file).
+ */
+ if (s->strategy != Z_HUFFMAN_ONLY) {
+ s->match_length = longest_match (s, hash_head);
+ }
+ /* longest_match() sets match_start */
+ if (s->match_length > s->lookahead) s->match_length = s->lookahead;
+
+ if (s->match_length <= 5 && (s->strategy == Z_FILTERED ||
+ (s->match_length == MIN_MATCH &&
+ s->strstart - s->match_start > TOO_FAR))) {
+
+ /* If prev_match is also MIN_MATCH, match_start is garbage
+ * but we will ignore the current match anyway.
+ */
+ s->match_length = MIN_MATCH-1;
+ }
+ }
+ /* If there was a match at the previous step and the current
+ * match is not better, output the previous match:
+ */
+ if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
+ uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
+ /* Do not insert strings in hash table beyond this. */
+
+ check_match(s, s->strstart-1, s->prev_match, s->prev_length);
+
+ bflush = ct_tally(s, s->strstart -1 - s->prev_match,
+ s->prev_length - MIN_MATCH);
+
+ /* Insert in hash table all strings up to the end of the match.
+ * strstart-1 and strstart are already inserted. If there is not
+ * enough lookahead, the last two strings are not inserted in
+ * the hash table.
+ */
+ s->lookahead -= s->prev_length-1;
+ s->prev_length -= 2;
+ do {
+ if (++s->strstart <= max_insert) {
+ INSERT_STRING(s, s->strstart, hash_head);
+ }
+ } while (--s->prev_length != 0);
+ s->match_available = 0;
+ s->match_length = MIN_MATCH-1;
+ s->strstart++;
+
+ if (bflush) FLUSH_BLOCK(s, Z_NO_FLUSH);
+
+ } else if (s->match_available) {
+ /* If there was no match at the previous position, output a
+ * single literal. If there was a match but the current match
+ * is longer, truncate the previous match to a single literal.
+ */
+ Tracevv((stderr,"%c", s->window[s->strstart-1]));
+ if (ct_tally (s, 0, s->window[s->strstart-1])) {
+ FLUSH_BLOCK_ONLY(s, Z_NO_FLUSH);
+ }
+ s->strstart++;
+ s->lookahead--;
+ if (s->strm->avail_out == 0) return 1;
+ } else {
+ /* There is no previous match to compare with, wait for
+ * the next step to decide.
+ */
+ s->match_available = 1;
+ s->strstart++;
+ s->lookahead--;
+ }
+ }
+ Assert (flush != Z_NO_FLUSH, "no flush?");
+ if (s->match_available) {
+ Tracevv((stderr,"%c", s->window[s->strstart-1]));
+ ct_tally (s, 0, s->window[s->strstart-1]);
+ s->match_available = 0;
+ }
+ FLUSH_BLOCK(s, flush);
+ return 0;
+}
+
+
+/*+++++*/
+/* trees.c -- output deflated data using Huffman coding
+ * Copyright (C) 1995 Jean-loup Gailly
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/*
+ * ALGORITHM
+ *
+ * The "deflation" process uses several Huffman trees. The more
+ * common source values are represented by shorter bit sequences.
+ *
+ * Each code tree is stored in a compressed form which is itself
+ * a Huffman encoding of the lengths of all the code strings (in
+ * ascending order by source values). The actual code strings are
+ * reconstructed from the lengths in the inflate process, as described
+ * in the deflate specification.
+ *
+ * REFERENCES
+ *
+ * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
+ * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
+ *
+ * Storer, James A.
+ * Data Compression: Methods and Theory, pp. 49-50.
+ * Computer Science Press, 1988. ISBN 0-7167-8156-5.
+ *
+ * Sedgewick, R.
+ * Algorithms, p290.
+ * Addison-Wesley, 1983. ISBN 0-201-06672-6.
+ */
+
+/* From: trees.c,v 1.5 1995/05/03 17:27:12 jloup Exp */
+
+#ifdef DEBUG_ZLIB
+# include <ctype.h>
+#endif
+
+/* ===========================================================================
+ * Constants
+ */
+
+#define MAX_BL_BITS 7
+/* Bit length codes must not exceed MAX_BL_BITS bits */
+
+#define END_BLOCK 256
+/* end of block literal code */
+
+#define REP_3_6 16
+/* repeat previous bit length 3-6 times (2 bits of repeat count) */
+
+#define REPZ_3_10 17
+/* repeat a zero length 3-10 times (3 bits of repeat count) */
+
+#define REPZ_11_138 18
+/* repeat a zero length 11-138 times (7 bits of repeat count) */
+
+local int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
+ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
+
+local int extra_dbits[D_CODES] /* extra bits for each distance code */
+ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
+
+local int extra_blbits[BL_CODES]/* extra bits for each bit length code */
+ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+
+local uch bl_order[BL_CODES]
+ = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
+/* The lengths of the bit length codes are sent in order of decreasing
+ * probability, to avoid transmitting the lengths for unused bit length codes.
+ */
+
+#define Buf_size (8 * 2*sizeof(char))
+/* Number of bits used within bi_buf. (bi_buf might be implemented on
+ * more than 16 bits on some systems.)
+ */
+
+/* ===========================================================================
+ * Local data. These are initialized only once.
+ * To do: initialize at compile time to be completely reentrant. ???
+ */
+
+local ct_data static_ltree[L_CODES+2];
+/* The static literal tree. Since the bit lengths are imposed, there is no
+ * need for the L_CODES extra codes used during heap construction. However
+ * The codes 286 and 287 are needed to build a canonical tree (see ct_init
+ * below).
+ */
+
+local ct_data static_dtree[D_CODES];
+/* The static distance tree. (Actually a trivial tree since all codes use
+ * 5 bits.)
+ */
+
+local uch dist_code[512];
+/* distance codes. The first 256 values correspond to the distances
+ * 3 .. 258, the last 256 values correspond to the top 8 bits of
+ * the 15 bit distances.
+ */
+
+local uch length_code[MAX_MATCH-MIN_MATCH+1];
+/* length code for each normalized match length (0 == MIN_MATCH) */
+
+local int base_length[LENGTH_CODES];
+/* First normalized length for each code (0 = MIN_MATCH) */
+
+local int base_dist[D_CODES];
+/* First normalized distance for each code (0 = distance of 1) */
+
+struct static_tree_desc_s {
+ ct_data *static_tree; /* static tree or NULL */
+ intf *extra_bits; /* extra bits for each code or NULL */
+ int extra_base; /* base index for extra_bits */
+ int elems; /* max number of elements in the tree */
+ int max_length; /* max bit length for the codes */
+};
+
+local static_tree_desc static_l_desc =
+{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
+
+local static_tree_desc static_d_desc =
+{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
+
+local static_tree_desc static_bl_desc =
+{(ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
+
+/* ===========================================================================
+ * Local (static) routines in this file.
+ */
+
+local void ct_static_init OF((void));
+local void init_block OF((deflate_state *s));
+local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
+local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
+local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
+local void build_tree OF((deflate_state *s, tree_desc *desc));
+local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
+local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
+local int build_bl_tree OF((deflate_state *s));
+local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
+ int blcodes));
+local void compress_block OF((deflate_state *s, ct_data *ltree,
+ ct_data *dtree));
+local void set_data_type OF((deflate_state *s));
+local unsigned bi_reverse OF((unsigned value, int length));
+local void bi_windup OF((deflate_state *s));
+local void bi_flush OF((deflate_state *s));
+local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
+ int header));
+
+#ifndef DEBUG_ZLIB
+# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
+ /* Send a code of the given tree. c and tree must not have side effects */
+
+#else /* DEBUG_ZLIB */
+# define send_code(s, c, tree) \
+ { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \
+ send_bits(s, tree[c].Code, tree[c].Len); }
+#endif
+
+#define d_code(dist) \
+ ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
+/* Mapping from a distance to a distance code. dist is the distance - 1 and
+ * must not have side effects. dist_code[256] and dist_code[257] are never
+ * used.
+ */
+
+/* ===========================================================================
+ * Output a short LSB first on the stream.
+ * IN assertion: there is enough room in pendingBuf.
+ */
+#define put_short(s, w) { \
+ put_byte(s, (uch)((w) & 0xff)); \
+ put_byte(s, (uch)((ush)(w) >> 8)); \
+}
+
+/* ===========================================================================
+ * Send a value on a given number of bits.
+ * IN assertion: length <= 16 and value fits in length bits.
+ */
+#ifdef DEBUG_ZLIB
+local void send_bits OF((deflate_state *s, int value, int length));
+
+local void send_bits(s, value, length)
+ deflate_state *s;
+ int value; /* value to send */
+ int length; /* number of bits */
+{
+ Tracev((stderr," l %2d v %4x ", length, value));
+ Assert(length > 0 && length <= 15, "invalid length");
+ s->bits_sent += (ulg)length;
+
+ /* If not enough room in bi_buf, use (valid) bits from bi_buf and
+ * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
+ * unused bits in value.
+ */
+ if (s->bi_valid > (int)Buf_size - length) {
+ s->bi_buf |= (value << s->bi_valid);
+ put_short(s, s->bi_buf);
+ s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
+ s->bi_valid += length - Buf_size;
+ } else {
+ s->bi_buf |= value << s->bi_valid;
+ s->bi_valid += length;
+ }
+}
+#else /* !DEBUG_ZLIB */
+
+#define send_bits(s, value, length) \
+{ int len = length;\
+ if (s->bi_valid > (int)Buf_size - len) {\
+ int val = value;\
+ s->bi_buf |= (val << s->bi_valid);\
+ put_short(s, s->bi_buf);\
+ s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
+ s->bi_valid += len - Buf_size;\
+ } else {\
+ s->bi_buf |= (value) << s->bi_valid;\
+ s->bi_valid += len;\
+ }\
+}
+#endif /* DEBUG_ZLIB */
+
+
+#define MAX(a,b) (a >= b ? a : b)
+/* the arguments must not have side effects */
+
+/* ===========================================================================
+ * Initialize the various 'constant' tables.
+ * To do: do this at compile time.
+ */
+local void ct_static_init()
+{
+ int n; /* iterates over tree elements */
+ int bits; /* bit counter */
+ int length; /* length value */
+ int code; /* code value */
+ int dist; /* distance index */
+ ush bl_count[MAX_BITS+1];
+ /* number of codes at each bit length for an optimal tree */
+
+ /* Initialize the mapping length (0..255) -> length code (0..28) */
+ length = 0;
+ for (code = 0; code < LENGTH_CODES-1; code++) {
+ base_length[code] = length;
+ for (n = 0; n < (1<<extra_lbits[code]); n++) {
+ length_code[length++] = (uch)code;
+ }
+ }
+ Assert (length == 256, "ct_static_init: length != 256");
+ /* Note that the length 255 (match length 258) can be represented
+ * in two different ways: code 284 + 5 bits or code 285, so we
+ * overwrite length_code[255] to use the best encoding:
+ */
+ length_code[length-1] = (uch)code;
+
+ /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
+ dist = 0;
+ for (code = 0 ; code < 16; code++) {
+ base_dist[code] = dist;
+ for (n = 0; n < (1<<extra_dbits[code]); n++) {
+ dist_code[dist++] = (uch)code;
+ }
+ }
+ Assert (dist == 256, "ct_static_init: dist != 256");
+ dist >>= 7; /* from now on, all distances are divided by 128 */
+ for ( ; code < D_CODES; code++) {
+ base_dist[code] = dist << 7;
+ for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
+ dist_code[256 + dist++] = (uch)code;
+ }
+ }
+ Assert (dist == 256, "ct_static_init: 256+dist != 512");
+
+ /* Construct the codes of the static literal tree */
+ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
+ n = 0;
+ while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
+ while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
+ while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
+ while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
+ /* Codes 286 and 287 do not exist, but we must include them in the
+ * tree construction to get a canonical Huffman tree (longest code
+ * all ones)
+ */
+ gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
+
+ /* The static distance tree is trivial: */
+ for (n = 0; n < D_CODES; n++) {
+ static_dtree[n].Len = 5;
+ static_dtree[n].Code = bi_reverse(n, 5);
+ }
+}
+
+/* ===========================================================================
+ * Initialize the tree data structures for a new zlib stream.
+ */
+local void ct_init(s)
+ deflate_state *s;
+{
+ if (static_dtree[0].Len == 0) {
+ ct_static_init(); /* To do: at compile time */
+ }
+
+ s->compressed_len = 0L;
+
+ s->l_desc.dyn_tree = s->dyn_ltree;
+ s->l_desc.stat_desc = &static_l_desc;
+
+ s->d_desc.dyn_tree = s->dyn_dtree;
+ s->d_desc.stat_desc = &static_d_desc;
+
+ s->bl_desc.dyn_tree = s->bl_tree;
+ s->bl_desc.stat_desc = &static_bl_desc;
+
+ s->bi_buf = 0;
+ s->bi_valid = 0;
+ s->last_eob_len = 8; /* enough lookahead for inflate */
+#ifdef DEBUG_ZLIB
+ s->bits_sent = 0L;
+#endif
+ s->blocks_in_packet = 0;
+
+ /* Initialize the first block of the first file: */
+ init_block(s);
+}
+
+/* ===========================================================================
+ * Initialize a new block.
+ */
+local void init_block(s)
+ deflate_state *s;
+{
+ int n; /* iterates over tree elements */
+
+ /* Initialize the trees. */
+ for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
+ for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
+ for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
+
+ s->dyn_ltree[END_BLOCK].Freq = 1;
+ s->opt_len = s->static_len = 0L;
+ s->last_lit = s->matches = 0;
+}
+
+#define SMALLEST 1
+/* Index within the heap array of least frequent node in the Huffman tree */
+
+
+/* ===========================================================================
+ * Remove the smallest element from the heap and recreate the heap with
+ * one less element. Updates heap and heap_len.
+ */
+#define pqremove(s, tree, top) \
+{\
+ top = s->heap[SMALLEST]; \
+ s->heap[SMALLEST] = s->heap[s->heap_len--]; \
+ pqdownheap(s, tree, SMALLEST); \
+}
+
+/* ===========================================================================
+ * Compares to subtrees, using the tree depth as tie breaker when
+ * the subtrees have equal frequency. This minimizes the worst case length.
+ */
+#define smaller(tree, n, m, depth) \
+ (tree[n].Freq < tree[m].Freq || \
+ (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
+
+/* ===========================================================================
+ * Restore the heap property by moving down the tree starting at node k,
+ * exchanging a node with the smallest of its two sons if necessary, stopping
+ * when the heap property is re-established (each father smaller than its
+ * two sons).
+ */
+local void pqdownheap(s, tree, k)
+ deflate_state *s;
+ ct_data *tree; /* the tree to restore */
+ int k; /* node to move down */
+{
+ int v = s->heap[k];
+ int j = k << 1; /* left son of k */
+ while (j <= s->heap_len) {
+ /* Set j to the smallest of the two sons: */
+ if (j < s->heap_len &&
+ smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
+ j++;
+ }
+ /* Exit if v is smaller than both sons */
+ if (smaller(tree, v, s->heap[j], s->depth)) break;
+
+ /* Exchange v with the smallest son */
+ s->heap[k] = s->heap[j]; k = j;
+
+ /* And continue down the tree, setting j to the left son of k */
+ j <<= 1;
+ }
+ s->heap[k] = v;
+}
+
+/* ===========================================================================
+ * Compute the optimal bit lengths for a tree and update the total bit length
+ * for the current block.
+ * IN assertion: the fields freq and dad are set, heap[heap_max] and
+ * above are the tree nodes sorted by increasing frequency.
+ * OUT assertions: the field len is set to the optimal bit length, the
+ * array bl_count contains the frequencies for each bit length.
+ * The length opt_len is updated; static_len is also updated if stree is
+ * not null.
+ */
+local void gen_bitlen(s, desc)
+ deflate_state *s;
+ tree_desc *desc; /* the tree descriptor */
+{
+ ct_data *tree = desc->dyn_tree;
+ int max_code = desc->max_code;
+ ct_data *stree = desc->stat_desc->static_tree;
+ intf *extra = desc->stat_desc->extra_bits;
+ int base = desc->stat_desc->extra_base;
+ int max_length = desc->stat_desc->max_length;
+ int h; /* heap index */
+ int n, m; /* iterate over the tree elements */
+ int bits; /* bit length */
+ int xbits; /* extra bits */
+ ush f; /* frequency */
+ int overflow = 0; /* number of elements with bit length too large */
+
+ for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
+
+ /* In a first pass, compute the optimal bit lengths (which may
+ * overflow in the case of the bit length tree).
+ */
+ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
+
+ for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
+ n = s->heap[h];
+ bits = tree[tree[n].Dad].Len + 1;
+ if (bits > max_length) bits = max_length, overflow++;
+ tree[n].Len = (ush)bits;
+ /* We overwrite tree[n].Dad which is no longer needed */
+
+ if (n > max_code) continue; /* not a leaf node */
+
+ s->bl_count[bits]++;
+ xbits = 0;
+ if (n >= base) xbits = extra[n-base];
+ f = tree[n].Freq;
+ s->opt_len += (ulg)f * (bits + xbits);
+ if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
+ }
+ if (overflow == 0) return;
+
+ Trace((stderr,"\nbit length overflow\n"));
+ /* This happens for example on obj2 and pic of the Calgary corpus */
+
+ /* Find the first bit length which could increase: */
+ do {
+ bits = max_length-1;
+ while (s->bl_count[bits] == 0) bits--;
+ s->bl_count[bits]--; /* move one leaf down the tree */
+ s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
+ s->bl_count[max_length]--;
+ /* The brother of the overflow item also moves one step up,
+ * but this does not affect bl_count[max_length]
+ */
+ overflow -= 2;
+ } while (overflow > 0);
+
+ /* Now recompute all bit lengths, scanning in increasing frequency.
+ * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
+ * lengths instead of fixing only the wrong ones. This idea is taken
+ * from 'ar' written by Haruhiko Okumura.)
+ */
+ for (bits = max_length; bits != 0; bits--) {
+ n = s->bl_count[bits];
+ while (n != 0) {
+ m = s->heap[--h];
+ if (m > max_code) continue;
+ if (tree[m].Len != (unsigned) bits) {
+ Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
+ s->opt_len += ((long)bits - (long)tree[m].Len)
+ *(long)tree[m].Freq;
+ tree[m].Len = (ush)bits;
+ }
+ n--;
+ }
+ }
+}
+
+/* ===========================================================================
+ * Generate the codes for a given tree and bit counts (which need not be
+ * optimal).
+ * IN assertion: the array bl_count contains the bit length statistics for
+ * the given tree and the field len is set for all tree elements.
+ * OUT assertion: the field code is set for all tree elements of non
+ * zero code length.
+ */
+local void gen_codes (tree, max_code, bl_count)
+ ct_data *tree; /* the tree to decorate */
+ int max_code; /* largest code with non zero frequency */
+ ushf *bl_count; /* number of codes at each bit length */
+{
+ ush next_code[MAX_BITS+1]; /* next code value for each bit length */
+ ush code = 0; /* running code value */
+ int bits; /* bit index */
+ int n; /* code index */
+
+ /* The distribution counts are first used to generate the code values
+ * without bit reversal.
+ */
+ for (bits = 1; bits <= MAX_BITS; bits++) {
+ next_code[bits] = code = (code + bl_count[bits-1]) << 1;
+ }
+ /* Check that the bit counts in bl_count are consistent. The last code
+ * must be all ones.
+ */
+ Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
+ "inconsistent bit counts");
+ Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
+
+ for (n = 0; n <= max_code; n++) {
+ int len = tree[n].Len;
+ if (len == 0) continue;
+ /* Now reverse the bits */
+ tree[n].Code = bi_reverse(next_code[len]++, len);
+
+ Tracec(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
+ n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
+ }
+}
+
+/* ===========================================================================
+ * Construct one Huffman tree and assigns the code bit strings and lengths.
+ * Update the total bit length for the current block.
+ * IN assertion: the field freq is set for all tree elements.
+ * OUT assertions: the fields len and code are set to the optimal bit length
+ * and corresponding code. The length opt_len is updated; static_len is
+ * also updated if stree is not null. The field max_code is set.
+ */
+local void build_tree(s, desc)
+ deflate_state *s;
+ tree_desc *desc; /* the tree descriptor */
+{
+ ct_data *tree = desc->dyn_tree;
+ ct_data *stree = desc->stat_desc->static_tree;
+ int elems = desc->stat_desc->elems;
+ int n, m; /* iterate over heap elements */
+ int max_code = -1; /* largest code with non zero frequency */
+ int node; /* new node being created */
+
+ /* Construct the initial heap, with least frequent element in
+ * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
+ * heap[0] is not used.
+ */
+ s->heap_len = 0, s->heap_max = HEAP_SIZE;
+
+ for (n = 0; n < elems; n++) {
+ if (tree[n].Freq != 0) {
+ s->heap[++(s->heap_len)] = max_code = n;
+ s->depth[n] = 0;
+ } else {
+ tree[n].Len = 0;
+ }
+ }
+
+ /* The pkzip format requires that at least one distance code exists,
+ * and that at least one bit should be sent even if there is only one
+ * possible code. So to avoid special checks later on we force at least
+ * two codes of non zero frequency.
+ */
+ while (s->heap_len < 2) {
+ node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
+ tree[node].Freq = 1;
+ s->depth[node] = 0;
+ s->opt_len--; if (stree) s->static_len -= stree[node].Len;
+ /* node is 0 or 1 so it does not have extra bits */
+ }
+ desc->max_code = max_code;
+
+ /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
+ * establish sub-heaps of increasing lengths:
+ */
+ for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
+
+ /* Construct the Huffman tree by repeatedly combining the least two
+ * frequent nodes.
+ */
+ node = elems; /* next internal node of the tree */
+ do {
+ pqremove(s, tree, n); /* n = node of least frequency */
+ m = s->heap[SMALLEST]; /* m = node of next least frequency */
+
+ s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
+ s->heap[--(s->heap_max)] = m;
+
+ /* Create a new node father of n and m */
+ tree[node].Freq = tree[n].Freq + tree[m].Freq;
+ s->depth[node] = (uch) (MAX(s->depth[n], s->depth[m]) + 1);
+ tree[n].Dad = tree[m].Dad = (ush)node;
+#ifdef DUMP_BL_TREE
+ if (tree == s->bl_tree) {
+ fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
+ node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
+ }
+#endif
+ /* and insert the new node in the heap */
+ s->heap[SMALLEST] = node++;
+ pqdownheap(s, tree, SMALLEST);
+
+ } while (s->heap_len >= 2);
+
+ s->heap[--(s->heap_max)] = s->heap[SMALLEST];
+
+ /* At this point, the fields freq and dad are set. We can now
+ * generate the bit lengths.
+ */
+ gen_bitlen(s, (tree_desc *)desc);
+
+ /* The field len is now set, we can generate the bit codes */
+ gen_codes ((ct_data *)tree, max_code, s->bl_count);
+}
+
+/* ===========================================================================
+ * Scan a literal or distance tree to determine the frequencies of the codes
+ * in the bit length tree.
+ */
+local void scan_tree (s, tree, max_code)
+ deflate_state *s;
+ ct_data *tree; /* the tree to be scanned */
+ int max_code; /* and its largest code of non zero frequency */
+{
+ int n; /* iterates over all tree elements */
+ int prevlen = -1; /* last emitted length */
+ int curlen; /* length of current code */
+ int nextlen = tree[0].Len; /* length of next code */
+ int count = 0; /* repeat count of the current code */
+ int max_count = 7; /* max repeat count */
+ int min_count = 4; /* min repeat count */
+
+ if (nextlen == 0) max_count = 138, min_count = 3;
+ tree[max_code+1].Len = (ush)0xffff; /* guard */
+
+ for (n = 0; n <= max_code; n++) {
+ curlen = nextlen; nextlen = tree[n+1].Len;
+ if (++count < max_count && curlen == nextlen) {
+ continue;
+ } else if (count < min_count) {
+ s->bl_tree[curlen].Freq += count;
+ } else if (curlen != 0) {
+ if (curlen != prevlen) s->bl_tree[curlen].Freq++;
+ s->bl_tree[REP_3_6].Freq++;
+ } else if (count <= 10) {
+ s->bl_tree[REPZ_3_10].Freq++;
+ } else {
+ s->bl_tree[REPZ_11_138].Freq++;
+ }
+ count = 0; prevlen = curlen;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ } else if (curlen == nextlen) {
+ max_count = 6, min_count = 3;
+ } else {
+ max_count = 7, min_count = 4;
+ }
+ }
+}
+
+/* ===========================================================================
+ * Send a literal or distance tree in compressed form, using the codes in
+ * bl_tree.
+ */
+local void send_tree (s, tree, max_code)
+ deflate_state *s;
+ ct_data *tree; /* the tree to be scanned */
+ int max_code; /* and its largest code of non zero frequency */
+{
+ int n; /* iterates over all tree elements */
+ int prevlen = -1; /* last emitted length */
+ int curlen; /* length of current code */
+ int nextlen = tree[0].Len; /* length of next code */
+ int count = 0; /* repeat count of the current code */
+ int max_count = 7; /* max repeat count */
+ int min_count = 4; /* min repeat count */
+
+ /* tree[max_code+1].Len = -1; */ /* guard already set */
+ if (nextlen == 0) max_count = 138, min_count = 3;
+
+ for (n = 0; n <= max_code; n++) {
+ curlen = nextlen; nextlen = tree[n+1].Len;
+ if (++count < max_count && curlen == nextlen) {
+ continue;
+ } else if (count < min_count) {
+ do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
+
+ } else if (curlen != 0) {
+ if (curlen != prevlen) {
+ send_code(s, curlen, s->bl_tree); count--;
+ }
+ Assert(count >= 3 && count <= 6, " 3_6?");
+ send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
+
+ } else if (count <= 10) {
+ send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
+
+ } else {
+ send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
+ }
+ count = 0; prevlen = curlen;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ } else if (curlen == nextlen) {
+ max_count = 6, min_count = 3;
+ } else {
+ max_count = 7, min_count = 4;
+ }
+ }
+}
+
+/* ===========================================================================
+ * Construct the Huffman tree for the bit lengths and return the index in
+ * bl_order of the last bit length code to send.
+ */
+local int build_bl_tree(s)
+ deflate_state *s;
+{
+ int max_blindex; /* index of last bit length code of non zero freq */
+
+ /* Determine the bit length frequencies for literal and distance trees */
+ scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
+ scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
+
+ /* Build the bit length tree: */
+ build_tree(s, (tree_desc *)(&(s->bl_desc)));
+ /* opt_len now includes the length of the tree representations, except
+ * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
+ */
+
+ /* Determine the number of bit length codes to send. The pkzip format
+ * requires that at least 4 bit length codes be sent. (appnote.txt says
+ * 3 but the actual value used is 4.)
+ */
+ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
+ if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
+ }
+ /* Update opt_len to include the bit length tree and counts */
+ s->opt_len += 3*(max_blindex+1) + 5+5+4;
+ Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
+ s->opt_len, s->static_len));
+
+ return max_blindex;
+}
+
+/* ===========================================================================
+ * Send the header for a block using dynamic Huffman trees: the counts, the
+ * lengths of the bit length codes, the literal tree and the distance tree.
+ * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
+ */
+local void send_all_trees(s, lcodes, dcodes, blcodes)
+ deflate_state *s;
+ int lcodes, dcodes, blcodes; /* number of codes for each tree */
+{
+ int rank; /* index in bl_order */
+
+ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
+ Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
+ "too many codes");
+ Tracev((stderr, "\nbl counts: "));
+ send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
+ send_bits(s, dcodes-1, 5);
+ send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
+ for (rank = 0; rank < blcodes; rank++) {
+ Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
+ send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
+ }
+ Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
+
+ send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
+ Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
+
+ send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
+ Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
+}
+
+/* ===========================================================================
+ * Send a stored block
+ */
+local void ct_stored_block(s, buf, stored_len, eof)
+ deflate_state *s;
+ charf *buf; /* input block */
+ ulg stored_len; /* length of input block */
+ int eof; /* true if this is the last block for a file */
+{
+ send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
+ s->compressed_len = (s->compressed_len + 3 + 7) & ~7L;
+ s->compressed_len += (stored_len + 4) << 3;
+
+ copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
+}
+
+/* Send just the `stored block' type code without any length bytes or data.
+ */
+local void ct_stored_type_only(s)
+ deflate_state *s;
+{
+ send_bits(s, (STORED_BLOCK << 1), 3);
+ bi_windup(s);
+ s->compressed_len = (s->compressed_len + 3) & ~7L;
+}
+
+
+/* ===========================================================================
+ * Send one empty static block to give enough lookahead for inflate.
+ * This takes 10 bits, of which 7 may remain in the bit buffer.
+ * The current inflate code requires 9 bits of lookahead. If the EOB
+ * code for the previous block was coded on 5 bits or less, inflate
+ * may have only 5+3 bits of lookahead to decode this EOB.
+ * (There are no problems if the previous block is stored or fixed.)
+ */
+local void ct_align(s)
+ deflate_state *s;
+{
+ send_bits(s, STATIC_TREES<<1, 3);
+ send_code(s, END_BLOCK, static_ltree);
+ s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
+ bi_flush(s);
+ /* Of the 10 bits for the empty block, we have already sent
+ * (10 - bi_valid) bits. The lookahead for the EOB of the previous
+ * block was thus its length plus what we have just sent.
+ */
+ if (s->last_eob_len + 10 - s->bi_valid < 9) {
+ send_bits(s, STATIC_TREES<<1, 3);
+ send_code(s, END_BLOCK, static_ltree);
+ s->compressed_len += 10L;
+ bi_flush(s);
+ }
+ s->last_eob_len = 7;
+}
+
+/* ===========================================================================
+ * Determine the best encoding for the current block: dynamic trees, static
+ * trees or store, and output the encoded block to the zip file. This function
+ * returns the total compressed length for the file so far.
+ */
+local ulg ct_flush_block(s, buf, stored_len, flush)
+ deflate_state *s;
+ charf *buf; /* input block, or NULL if too old */
+ ulg stored_len; /* length of input block */
+ int flush; /* Z_FINISH if this is the last block for a file */
+{
+ ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
+ int max_blindex; /* index of last bit length code of non zero freq */
+ int eof = flush == Z_FINISH;
+
+ ++s->blocks_in_packet;
+
+ /* Check if the file is ascii or binary */
+ if (s->data_type == UNKNOWN) set_data_type(s);
+
+ /* Construct the literal and distance trees */
+ build_tree(s, (tree_desc *)(&(s->l_desc)));
+ Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
+ s->static_len));
+
+ build_tree(s, (tree_desc *)(&(s->d_desc)));
+ Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
+ s->static_len));
+ /* At this point, opt_len and static_len are the total bit lengths of
+ * the compressed block data, excluding the tree representations.
+ */
+
+ /* Build the bit length tree for the above two trees, and get the index
+ * in bl_order of the last bit length code to send.
+ */
+ max_blindex = build_bl_tree(s);
+
+ /* Determine the best encoding. Compute first the block length in bytes */
+ opt_lenb = (s->opt_len+3+7)>>3;
+ static_lenb = (s->static_len+3+7)>>3;
+
+ Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
+ opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
+ s->last_lit));
+
+ if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
+
+ /* If compression failed and this is the first and last block,
+ * and if the .zip file can be seeked (to rewrite the local header),
+ * the whole file is transformed into a stored file:
+ */
+#ifdef STORED_FILE_OK
+# ifdef FORCE_STORED_FILE
+ if (eof && compressed_len == 0L) /* force stored file */
+# else
+ if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable())
+# endif
+ {
+ /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
+ if (buf == (charf*)0) error ("block vanished");
+
+ copy_block(buf, (unsigned)stored_len, 0); /* without header */
+ s->compressed_len = stored_len << 3;
+ s->method = STORED;
+ } else
+#endif /* STORED_FILE_OK */
+
+ /* For Z_PACKET_FLUSH, if we don't achieve the required minimum
+ * compression, and this block contains all the data since the last
+ * time we used Z_PACKET_FLUSH, then just omit this block completely
+ * from the output.
+ */
+ if (flush == Z_PACKET_FLUSH && s->blocks_in_packet == 1
+ && opt_lenb > stored_len - s->minCompr) {
+ s->blocks_in_packet = 0;
+ /* output nothing */
+ } else
+
+#ifdef FORCE_STORED
+ if (buf != (char*)0) /* force stored block */
+#else
+ if (stored_len+4 <= opt_lenb && buf != (char*)0)
+ /* 4: two words for the lengths */
+#endif
+ {
+ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
+ * Otherwise we can't have processed more than WSIZE input bytes since
+ * the last block flush, because compression would have been
+ * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
+ * transform a block into a stored block.
+ */
+ ct_stored_block(s, buf, stored_len, eof);
+ } else
+
+#ifdef FORCE_STATIC
+ if (static_lenb >= 0) /* force static trees */
+#else
+ if (static_lenb == opt_lenb)
+#endif
+ {
+ send_bits(s, (STATIC_TREES<<1)+eof, 3);
+ compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
+ s->compressed_len += 3 + s->static_len;
+ } else {
+ send_bits(s, (DYN_TREES<<1)+eof, 3);
+ send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
+ max_blindex+1);
+ compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
+ s->compressed_len += 3 + s->opt_len;
+ }
+ Assert (s->compressed_len == s->bits_sent, "bad compressed size");
+ init_block(s);
+
+ if (eof) {
+ bi_windup(s);
+ s->compressed_len += 7; /* align on byte boundary */
+ }
+ Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
+ s->compressed_len-7*eof));
+
+ return s->compressed_len >> 3;
+}
+
+/* ===========================================================================
+ * Save the match info and tally the frequency counts. Return true if
+ * the current block must be flushed.
+ */
+local int ct_tally (s, dist, lc)
+ deflate_state *s;
+ int dist; /* distance of matched string */
+ int lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
+{
+ s->d_buf[s->last_lit] = (ush)dist;
+ s->l_buf[s->last_lit++] = (uch)lc;
+ if (dist == 0) {
+ /* lc is the unmatched char */
+ s->dyn_ltree[lc].Freq++;
+ } else {
+ s->matches++;
+ /* Here, lc is the match length - MIN_MATCH */
+ dist--; /* dist = match distance - 1 */
+ Assert((ush)dist < (ush)MAX_DIST(s) &&
+ (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
+ (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match");
+
+ s->dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
+ s->dyn_dtree[d_code(dist)].Freq++;
+ }
+
+ /* Try to guess if it is profitable to stop the current block here */
+ if (s->level > 2 && (s->last_lit & 0xfff) == 0) {
+ /* Compute an upper bound for the compressed length */
+ ulg out_length = (ulg)s->last_lit*8L;
+ ulg in_length = (ulg)s->strstart - s->block_start;
+ int dcode;
+ for (dcode = 0; dcode < D_CODES; dcode++) {
+ out_length += (ulg)s->dyn_dtree[dcode].Freq *
+ (5L+extra_dbits[dcode]);
+ }
+ out_length >>= 3;
+ Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
+ s->last_lit, in_length, out_length,
+ 100L - out_length*100L/in_length));
+ if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
+ }
+ return (s->last_lit == s->lit_bufsize-1);
+ /* We avoid equality with lit_bufsize because of wraparound at 64K
+ * on 16 bit machines and because stored blocks are restricted to
+ * 64K-1 bytes.
+ */
+}
+
+/* ===========================================================================
+ * Send the block data compressed using the given Huffman trees
+ */
+local void compress_block(s, ltree, dtree)
+ deflate_state *s;
+ ct_data *ltree; /* literal tree */
+ ct_data *dtree; /* distance tree */
+{
+ unsigned dist; /* distance of matched string */
+ int lc; /* match length or unmatched char (if dist == 0) */
+ unsigned lx = 0; /* running index in l_buf */
+ unsigned code; /* the code to send */
+ int extra; /* number of extra bits to send */
+
+ if (s->last_lit != 0) do {
+ dist = s->d_buf[lx];
+ lc = s->l_buf[lx++];
+ if (dist == 0) {
+ send_code(s, lc, ltree); /* send a literal byte */
+ Tracecv(isgraph(lc), (stderr," '%c' ", lc));
+ } else {
+ /* Here, lc is the match length - MIN_MATCH */
+ code = length_code[lc];
+ send_code(s, code+LITERALS+1, ltree); /* send the length code */
+ extra = extra_lbits[code];
+ if (extra != 0) {
+ lc -= base_length[code];
+ send_bits(s, lc, extra); /* send the extra length bits */
+ }
+ dist--; /* dist is now the match distance - 1 */
+ code = d_code(dist);
+ Assert (code < D_CODES, "bad d_code");
+
+ send_code(s, code, dtree); /* send the distance code */
+ extra = extra_dbits[code];
+ if (extra != 0) {
+ dist -= base_dist[code];
+ send_bits(s, dist, extra); /* send the extra distance bits */
+ }
+ } /* literal or match pair ? */
+
+ /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
+ Assert(s->pending < s->lit_bufsize + 2*lx, "pendingBuf overflow");
+
+ } while (lx < s->last_lit);
+
+ send_code(s, END_BLOCK, ltree);
+ s->last_eob_len = ltree[END_BLOCK].Len;
+}
+
+/* ===========================================================================
+ * Set the data type to ASCII or BINARY, using a crude approximation:
+ * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
+ * IN assertion: the fields freq of dyn_ltree are set and the total of all
+ * frequencies does not exceed 64K (to fit in an int on 16 bit machines).
+ */
+local void set_data_type(s)
+ deflate_state *s;
+{
+ int n = 0;
+ unsigned ascii_freq = 0;
+ unsigned bin_freq = 0;
+ while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
+ while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
+ while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
+ s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? BINARY : ASCII);
+}
+
+/* ===========================================================================
+ * Reverse the first len bits of a code, using straightforward code (a faster
+ * method would use a table)
+ * IN assertion: 1 <= len <= 15
+ */
+local unsigned bi_reverse(code, len)
+ unsigned code; /* the value to invert */
+ int len; /* its bit length */
+{
+ register unsigned res = 0;
+ do {
+ res |= code & 1;
+ code >>= 1, res <<= 1;
+ } while (--len > 0);
+ return res >> 1;
+}
+
+/* ===========================================================================
+ * Flush the bit buffer, keeping at most 7 bits in it.
+ */
+local void bi_flush(s)
+ deflate_state *s;
+{
+ if (s->bi_valid == 16) {
+ put_short(s, s->bi_buf);
+ s->bi_buf = 0;
+ s->bi_valid = 0;
+ } else if (s->bi_valid >= 8) {
+ put_byte(s, (Byte)s->bi_buf);
+ s->bi_buf >>= 8;
+ s->bi_valid -= 8;
+ }
+}
+
+/* ===========================================================================
+ * Flush the bit buffer and align the output on a byte boundary
+ */
+local void bi_windup(s)
+ deflate_state *s;
+{
+ if (s->bi_valid > 8) {
+ put_short(s, s->bi_buf);
+ } else if (s->bi_valid > 0) {
+ put_byte(s, (Byte)s->bi_buf);
+ }
+ s->bi_buf = 0;
+ s->bi_valid = 0;
+#ifdef DEBUG_ZLIB
+ s->bits_sent = (s->bits_sent+7) & ~7;
+#endif
+}
+
+/* ===========================================================================
+ * Copy a stored block, storing first the length and its
+ * one's complement if requested.
+ */
+local void copy_block(s, buf, len, header)
+ deflate_state *s;
+ charf *buf; /* the input data */
+ unsigned len; /* its length */
+ int header; /* true if block header must be written */
+{
+ bi_windup(s); /* align on byte boundary */
+ s->last_eob_len = 8; /* enough lookahead for inflate */
+
+ if (header) {
+ put_short(s, (ush)len);
+ put_short(s, (ush)~len);
+#ifdef DEBUG_ZLIB
+ s->bits_sent += 2*16;
+#endif
+ }
+#ifdef DEBUG_ZLIB
+ s->bits_sent += (ulg)len<<3;
+#endif
+ while (len--) {
+ put_byte(s, *buf++);
+ }
+}
+
+
+/*+++++*/
+/* infblock.h -- header to use infblock.c
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+struct inflate_blocks_state;
+typedef struct inflate_blocks_state FAR inflate_blocks_statef;
+
+local inflate_blocks_statef * inflate_blocks_new OF((
+ z_stream *z,
+ check_func c, /* check function */
+ uInt w)); /* window size */
+
+local int inflate_blocks OF((
+ inflate_blocks_statef *,
+ z_stream *,
+ int)); /* initial return code */
+
+local void inflate_blocks_reset OF((
+ inflate_blocks_statef *,
+ z_stream *,
+ uLongf *)); /* check value on output */
+
+local int inflate_blocks_free OF((
+ inflate_blocks_statef *,
+ z_stream *,
+ uLongf *)); /* check value on output */
+
+local int inflate_addhistory OF((
+ inflate_blocks_statef *,
+ z_stream *));
+
+local int inflate_packet_flush OF((
+ inflate_blocks_statef *));
+
+/*+++++*/
+/* inftrees.h -- header to use inftrees.c
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* Huffman code lookup table entry--this entry is four bytes for machines
+ that have 16-bit pointers (e.g. PC's in the small or medium model). */
+
+typedef struct inflate_huft_s FAR inflate_huft;
+
+struct inflate_huft_s {
+ union {
+ struct {
+ Byte Exop; /* number of extra bits or operation */
+ Byte Bits; /* number of bits in this code or subcode */
+ } what;
+ uInt Nalloc; /* number of these allocated here */
+ Bytef *pad; /* pad structure to a power of 2 (4 bytes for */
+ } word; /* 16-bit, 8 bytes for 32-bit machines) */
+ union {
+ uInt Base; /* literal, length base, or distance base */
+ inflate_huft *Next; /* pointer to next level of table */
+ } more;
+};
+
+#ifdef DEBUG_ZLIB
+ local uInt inflate_hufts;
+#endif
+
+local int inflate_trees_bits OF((
+ uIntf *, /* 19 code lengths */
+ uIntf *, /* bits tree desired/actual depth */
+ inflate_huft * FAR *, /* bits tree result */
+ z_stream *)); /* for zalloc, zfree functions */
+
+local int inflate_trees_dynamic OF((
+ uInt, /* number of literal/length codes */
+ uInt, /* number of distance codes */
+ uIntf *, /* that many (total) code lengths */
+ uIntf *, /* literal desired/actual bit depth */
+ uIntf *, /* distance desired/actual bit depth */
+ inflate_huft * FAR *, /* literal/length tree result */
+ inflate_huft * FAR *, /* distance tree result */
+ z_stream *)); /* for zalloc, zfree functions */
+
+local int inflate_trees_fixed OF((
+ uIntf *, /* literal desired/actual bit depth */
+ uIntf *, /* distance desired/actual bit depth */
+ inflate_huft * FAR *, /* literal/length tree result */
+ inflate_huft * FAR *)); /* distance tree result */
+
+local int inflate_trees_free OF((
+ inflate_huft *, /* tables to free */
+ z_stream *)); /* for zfree function */
+
+
+/*+++++*/
+/* infcodes.h -- header to use infcodes.c
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+struct inflate_codes_state;
+typedef struct inflate_codes_state FAR inflate_codes_statef;
+
+local inflate_codes_statef *inflate_codes_new OF((
+ uInt, uInt,
+ inflate_huft *, inflate_huft *,
+ z_stream *));
+
+local int inflate_codes OF((
+ inflate_blocks_statef *,
+ z_stream *,
+ int));
+
+local void inflate_codes_free OF((
+ inflate_codes_statef *,
+ z_stream *));
+
+
+/*+++++*/
+/* inflate.c -- zlib interface to inflate modules
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* inflate private state */
+struct internal_state {
+
+ /* mode */
+ enum {
+ METHOD, /* waiting for method byte */
+ FLAG, /* waiting for flag byte */
+ BLOCKS, /* decompressing blocks */
+ CHECK4, /* four check bytes to go */
+ CHECK3, /* three check bytes to go */
+ CHECK2, /* two check bytes to go */
+ CHECK1, /* one check byte to go */
+ DONE, /* finished check, done */
+ BAD} /* got an error--stay here */
+ mode; /* current inflate mode */
+
+ /* mode dependent information */
+ union {
+ uInt method; /* if FLAGS, method byte */
+ struct {
+ uLong was; /* computed check value */
+ uLong need; /* stream check value */
+ } check; /* if CHECK, check values to compare */
+ uInt marker; /* if BAD, inflateSync's marker bytes count */
+ } sub; /* submode */
+
+ /* mode independent information */
+ int nowrap; /* flag for no wrapper */
+ uInt wbits; /* log2(window size) (8..15, defaults to 15) */
+ inflate_blocks_statef
+ *blocks; /* current inflate_blocks state */
+
+};
+
+
+int inflateReset(z)
+z_stream *z;
+{
+ uLong c;
+
+ if (z == Z_NULL || z->state == Z_NULL)
+ return Z_STREAM_ERROR;
+ z->total_in = z->total_out = 0;
+ z->msg = Z_NULL;
+ z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
+ inflate_blocks_reset(z->state->blocks, z, &c);
+ Trace((stderr, "inflate: reset\n"));
+ return Z_OK;
+}
+
+
+int inflateEnd(z)
+z_stream *z;
+{
+ uLong c;
+
+ if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
+ return Z_STREAM_ERROR;
+ if (z->state->blocks != Z_NULL)
+ inflate_blocks_free(z->state->blocks, z, &c);
+ ZFREE(z, z->state, sizeof(struct internal_state));
+ z->state = Z_NULL;
+ Trace((stderr, "inflate: end\n"));
+ return Z_OK;
+}
+
+
+int inflateInit2(z, w)
+z_stream *z;
+int w;
+{
+ /* initialize state */
+ if (z == Z_NULL)
+ return Z_STREAM_ERROR;
+/* if (z->zalloc == Z_NULL) z->zalloc = zcalloc; */
+/* if (z->zfree == Z_NULL) z->zfree = zcfree; */
+ if ((z->state = (struct internal_state FAR *)
+ ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
+ return Z_MEM_ERROR;
+ z->state->blocks = Z_NULL;
+
+ /* handle undocumented nowrap option (no zlib header or check) */
+ z->state->nowrap = 0;
+ if (w < 0)
+ {
+ w = - w;
+ z->state->nowrap = 1;
+ }
+
+ /* set window size */
+ if (w < 8 || w > 15)
+ {
+ inflateEnd(z);
+ return Z_STREAM_ERROR;
+ }
+ z->state->wbits = (uInt)w;
+
+ /* create inflate_blocks state */
+ if ((z->state->blocks =
+ inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, 1 << w))
+ == Z_NULL)
+ {
+ inflateEnd(z);
+ return Z_MEM_ERROR;
+ }
+ Trace((stderr, "inflate: allocated\n"));
+
+ /* reset state */
+ inflateReset(z);
+ return Z_OK;
+}
+
+
+int inflateInit(z)
+z_stream *z;
+{
+ return inflateInit2(z, DEF_WBITS);
+}
+
+
+#define NEEDBYTE {if(z->avail_in==0)goto empty;r=Z_OK;}
+#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
+
+int inflate(z, f)
+z_stream *z;
+int f;
+{
+ int r;
+ uInt b;
+
+ if (z == Z_NULL || z->next_in == Z_NULL)
+ return Z_STREAM_ERROR;
+ r = Z_BUF_ERROR;
+ while (1) switch (z->state->mode)
+ {
+ case METHOD:
+ NEEDBYTE
+ if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED)
+ {
+ z->state->mode = BAD;
+ z->msg = "unknown compression method";
+ z->state->sub.marker = 5; /* can't try inflateSync */
+ break;
+ }
+ if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
+ {
+ z->state->mode = BAD;
+ z->msg = "invalid window size";
+ z->state->sub.marker = 5; /* can't try inflateSync */
+ break;
+ }
+ z->state->mode = FLAG;
+ case FLAG:
+ NEEDBYTE
+ if ((b = NEXTBYTE) & 0x20)
+ {
+ z->state->mode = BAD;
+ z->msg = "invalid reserved bit";
+ z->state->sub.marker = 5; /* can't try inflateSync */
+ break;
+ }
+ if (((z->state->sub.method << 8) + b) % 31)
+ {
+ z->state->mode = BAD;
+ z->msg = "incorrect header check";
+ z->state->sub.marker = 5; /* can't try inflateSync */
+ break;
+ }
+ Trace((stderr, "inflate: zlib header ok\n"));
+ z->state->mode = BLOCKS;
+ case BLOCKS:
+ r = inflate_blocks(z->state->blocks, z, r);
+ if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0)
+ r = inflate_packet_flush(z->state->blocks);
+ if (r == Z_DATA_ERROR)
+ {
+ z->state->mode = BAD;
+ z->state->sub.marker = 0; /* can try inflateSync */
+ break;
+ }
+ if (r != Z_STREAM_END)
+ return r;
+ r = Z_OK;
+ inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
+ if (z->state->nowrap)
+ {
+ z->state->mode = DONE;
+ break;
+ }
+ z->state->mode = CHECK4;
+ case CHECK4:
+ NEEDBYTE
+ z->state->sub.check.need = (uLong)NEXTBYTE << 24;
+ z->state->mode = CHECK3;
+ case CHECK3:
+ NEEDBYTE
+ z->state->sub.check.need += (uLong)NEXTBYTE << 16;
+ z->state->mode = CHECK2;
+ case CHECK2:
+ NEEDBYTE
+ z->state->sub.check.need += (uLong)NEXTBYTE << 8;
+ z->state->mode = CHECK1;
+ case CHECK1:
+ NEEDBYTE
+ z->state->sub.check.need += (uLong)NEXTBYTE;
+
+ if (z->state->sub.check.was != z->state->sub.check.need)
+ {
+ z->state->mode = BAD;
+ z->msg = "incorrect data check";
+ z->state->sub.marker = 5; /* can't try inflateSync */
+ break;
+ }
+ Trace((stderr, "inflate: zlib check ok\n"));
+ z->state->mode = DONE;
+ case DONE:
+ return Z_STREAM_END;
+ case BAD:
+ return Z_DATA_ERROR;
+ default:
+ return Z_STREAM_ERROR;
+ }
+
+ empty:
+ if (f != Z_PACKET_FLUSH)
+ return r;
+ z->state->mode = BAD;
+ z->state->sub.marker = 0; /* can try inflateSync */
+ return Z_DATA_ERROR;
+}
+
+/*
+ * This subroutine adds the data at next_in/avail_in to the output history
+ * without performing any output. The output buffer must be "caught up";
+ * i.e. no pending output (hence s->read equals s->write), and the state must
+ * be BLOCKS (i.e. we should be willing to see the start of a series of
+ * BLOCKS). On exit, the output will also be caught up, and the checksum
+ * will have been updated if need be.
+ */
+
+int inflateIncomp(z)
+z_stream *z;
+{
+ if (z->state->mode != BLOCKS)
+ return Z_DATA_ERROR;
+ return inflate_addhistory(z->state->blocks, z);
+}
+
+
+int inflateSync(z)
+z_stream *z;
+{
+ uInt n; /* number of bytes to look at */
+ Bytef *p; /* pointer to bytes */
+ uInt m; /* number of marker bytes found in a row */
+ uLong r, w; /* temporaries to save total_in and total_out */
+
+ /* set up */
+ if (z == Z_NULL || z->state == Z_NULL)
+ return Z_STREAM_ERROR;
+ if (z->state->mode != BAD)
+ {
+ z->state->mode = BAD;
+ z->state->sub.marker = 0;
+ }
+ if ((n = z->avail_in) == 0)
+ return Z_BUF_ERROR;
+ p = z->next_in;
+ m = z->state->sub.marker;
+
+ /* search */
+ while (n && m < 4)
+ {
+ if (*p == (Byte)(m < 2 ? 0 : 0xff))
+ m++;
+ else if (*p)
+ m = 0;
+ else
+ m = 4 - m;
+ p++, n--;
+ }
+
+ /* restore */
+ z->total_in += p - z->next_in;
+ z->next_in = p;
+ z->avail_in = n;
+ z->state->sub.marker = m;
+
+ /* return no joy or set up to restart on a new block */
+ if (m != 4)
+ return Z_DATA_ERROR;
+ r = z->total_in; w = z->total_out;
+ inflateReset(z);
+ z->total_in = r; z->total_out = w;
+ z->state->mode = BLOCKS;
+ return Z_OK;
+}
+
+#undef NEEDBYTE
+#undef NEXTBYTE
+
+/*+++++*/
+/* infutil.h -- types and macros common to blocks and codes
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* inflate blocks semi-private state */
+struct inflate_blocks_state {
+
+ /* mode */
+ enum {
+ TYPE, /* get type bits (3, including end bit) */
+ LENS, /* get lengths for stored */
+ STORED, /* processing stored block */
+ TABLE, /* get table lengths */
+ BTREE, /* get bit lengths tree for a dynamic block */
+ DTREE, /* get length, distance trees for a dynamic block */
+ CODES, /* processing fixed or dynamic block */
+ DRY, /* output remaining window bytes */
+ DONEB, /* finished last block, done */
+ BADB} /* got a data error--stuck here */
+ mode; /* current inflate_block mode */
+
+ /* mode dependent information */
+ union {
+ uInt left; /* if STORED, bytes left to copy */
+ struct {
+ uInt table; /* table lengths (14 bits) */
+ uInt index; /* index into blens (or border) */
+ uIntf *blens; /* bit lengths of codes */
+ uInt bb; /* bit length tree depth */
+ inflate_huft *tb; /* bit length decoding tree */
+ int nblens; /* # elements allocated at blens */
+ } trees; /* if DTREE, decoding info for trees */
+ struct {
+ inflate_huft *tl, *td; /* trees to free */
+ inflate_codes_statef
+ *codes;
+ } decode; /* if CODES, current state */
+ } sub; /* submode */
+ uInt last; /* true if this block is the last block */
+
+ /* mode independent information */
+ uInt bitk; /* bits in bit buffer */
+ uLong bitb; /* bit buffer */
+ Bytef *window; /* sliding window */
+ Bytef *end; /* one byte after sliding window */
+ Bytef *read; /* window read pointer */
+ Bytef *write; /* window write pointer */
+ check_func checkfn; /* check function */
+ uLong check; /* check on output */
+
+};
+
+
+/* defines for inflate input/output */
+/* update pointers and return */
+#define UPDBITS {s->bitb=b;s->bitk=k;}
+#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
+#define UPDOUT {s->write=q;}
+#define UPDATE {UPDBITS UPDIN UPDOUT}
+#define LEAVE {UPDATE return inflate_flush(s,z,r);}
+/* get bytes and bits */
+#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
+#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
+#define NEXTBYTE (n--,*p++)
+#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
+#define DUMPBITS(j) {b>>=(j);k-=(j);}
+/* output bytes */
+#define WAVAIL (q<s->read?s->read-q-1:s->end-q)
+#define LOADOUT {q=s->write;m=WAVAIL;}
+#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=WAVAIL;}}
+#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
+#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
+#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
+/* load local pointers */
+#define LOAD {LOADIN LOADOUT}
+
+/* And'ing with mask[n] masks the lower n bits */
+local uInt inflate_mask[] = {
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
+};
+
+/* copy as much as possible from the sliding window to the output area */
+local int inflate_flush OF((
+ inflate_blocks_statef *,
+ z_stream *,
+ int));
+
+/*+++++*/
+/* inffast.h -- header to use inffast.c
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+local int inflate_fast OF((
+ uInt,
+ uInt,
+ inflate_huft *,
+ inflate_huft *,
+ inflate_blocks_statef *,
+ z_stream *));
+
+
+/*+++++*/
+/* infblock.c -- interpret and process block types to last block
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* Table for deflate from PKZIP's appnote.txt. */
+local uInt border[] = { /* Order of the bit length code lengths */
+ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+
+/*
+ Notes beyond the 1.93a appnote.txt:
+
+ 1. Distance pointers never point before the beginning of the output
+ stream.
+ 2. Distance pointers can point back across blocks, up to 32k away.
+ 3. There is an implied maximum of 7 bits for the bit length table and
+ 15 bits for the actual data.
+ 4. If only one code exists, then it is encoded using one bit. (Zero
+ would be more efficient, but perhaps a little confusing.) If two
+ codes exist, they are coded using one bit each (0 and 1).
+ 5. There is no way of sending zero distance codes--a dummy must be
+ sent if there are none. (History: a pre 2.0 version of PKZIP would
+ store blocks with no distance codes, but this was discovered to be
+ too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
+ zero distance codes, which is sent as one code of zero bits in
+ length.
+ 6. There are up to 286 literal/length codes. Code 256 represents the
+ end-of-block. Note however that the static length tree defines
+ 288 codes just to fill out the Huffman codes. Codes 286 and 287
+ cannot be used though, since there is no length base or extra bits
+ defined for them. Similarily, there are up to 30 distance codes.
+ However, static trees define 32 codes (all 5 bits) to fill out the
+ Huffman codes, but the last two had better not show up in the data.
+ 7. Unzip can check dynamic Huffman blocks for complete code sets.
+ The exception is that a single code would not be complete (see #4).
+ 8. The five bits following the block type is really the number of
+ literal codes sent minus 257.
+ 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
+ (1+6+6). Therefore, to output three times the length, you output
+ three codes (1+1+1), whereas to output four times the same length,
+ you only need two codes (1+3). Hmm.
+ 10. In the tree reconstruction algorithm, Code = Code + Increment
+ only if BitLength(i) is not zero. (Pretty obvious.)
+ 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
+ 12. Note: length code 284 can represent 227-258, but length code 285
+ really is 258. The last length deserves its own, short code
+ since it gets used a lot in very redundant files. The length
+ 258 is special since 258 - 3 (the min match length) is 255.
+ 13. The literal/length and distance code bit lengths are read as a
+ single stream of lengths. It is possible (and advantageous) for
+ a repeat code (16, 17, or 18) to go across the boundary between
+ the two sets of lengths.
+ */
+
+
+local void inflate_blocks_reset(s, z, c)
+inflate_blocks_statef *s;
+z_stream *z;
+uLongf *c;
+{
+ if (s->checkfn != Z_NULL)
+ *c = s->check;
+ if (s->mode == BTREE || s->mode == DTREE)
+ ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
+ if (s->mode == CODES)
+ {
+ inflate_codes_free(s->sub.decode.codes, z);
+ inflate_trees_free(s->sub.decode.td, z);
+ inflate_trees_free(s->sub.decode.tl, z);
+ }
+ s->mode = TYPE;
+ s->bitk = 0;
+ s->bitb = 0;
+ s->read = s->write = s->window;
+ if (s->checkfn != Z_NULL)
+ s->check = (*s->checkfn)(0L, Z_NULL, 0);
+ Trace((stderr, "inflate: blocks reset\n"));
+}
+
+
+local inflate_blocks_statef *inflate_blocks_new(z, c, w)
+z_stream *z;
+check_func c;
+uInt w;
+{
+ inflate_blocks_statef *s;
+
+ if ((s = (inflate_blocks_statef *)ZALLOC
+ (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
+ return s;
+ if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
+ {
+ ZFREE(z, s, sizeof(struct inflate_blocks_state));
+ return Z_NULL;
+ }
+ s->end = s->window + w;
+ s->checkfn = c;
+ s->mode = TYPE;
+ Trace((stderr, "inflate: blocks allocated\n"));
+ inflate_blocks_reset(s, z, &s->check);
+ return s;
+}
+
+
+local int inflate_blocks(s, z, r)
+inflate_blocks_statef *s;
+z_stream *z;
+int r;
+{
+ uInt t; /* temporary storage */
+ uLong b; /* bit buffer */
+ uInt k; /* bits in bit buffer */
+ Bytef *p; /* input data pointer */
+ uInt n; /* bytes available there */
+ Bytef *q; /* output window write pointer */
+ uInt m; /* bytes to end of window or read pointer */
+
+ /* copy input/output information to locals (UPDATE macro restores) */
+ LOAD
+
+ /* process input based on current state */
+ while (1) switch (s->mode)
+ {
+ case TYPE:
+ NEEDBITS(3)
+ t = (uInt)b & 7;
+ s->last = t & 1;
+ switch (t >> 1)
+ {
+ case 0: /* stored */
+ Trace((stderr, "inflate: stored block%s\n",
+ s->last ? " (last)" : ""));
+ DUMPBITS(3)
+ t = k & 7; /* go to byte boundary */
+ DUMPBITS(t)
+ s->mode = LENS; /* get length of stored block */
+ break;
+ case 1: /* fixed */
+ Trace((stderr, "inflate: fixed codes block%s\n",
+ s->last ? " (last)" : ""));
+ {
+ uInt bl, bd;
+ inflate_huft *tl, *td;
+
+ inflate_trees_fixed(&bl, &bd, &tl, &td);
+ s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
+ if (s->sub.decode.codes == Z_NULL)
+ {
+ r = Z_MEM_ERROR;
+ LEAVE
+ }
+ s->sub.decode.tl = Z_NULL; /* don't try to free these */
+ s->sub.decode.td = Z_NULL;
+ }
+ DUMPBITS(3)
+ s->mode = CODES;
+ break;
+ case 2: /* dynamic */
+ Trace((stderr, "inflate: dynamic codes block%s\n",
+ s->last ? " (last)" : ""));
+ DUMPBITS(3)
+ s->mode = TABLE;
+ break;
+ case 3: /* illegal */
+ DUMPBITS(3)
+ s->mode = BADB;
+ z->msg = "invalid block type";
+ r = Z_DATA_ERROR;
+ LEAVE
+ }
+ break;
+ case LENS:
+ NEEDBITS(32)
+ if (((~b) >> 16) != (b & 0xffff))
+ {
+ s->mode = BADB;
+ z->msg = "invalid stored block lengths";
+ r = Z_DATA_ERROR;
+ LEAVE
+ }
+ s->sub.left = (uInt)b & 0xffff;
+ b = k = 0; /* dump bits */
+ Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
+ s->mode = s->sub.left ? STORED : TYPE;
+ break;
+ case STORED:
+ if (n == 0)
+ LEAVE
+ NEEDOUT
+ t = s->sub.left;
+ if (t > n) t = n;
+ if (t > m) t = m;
+ zmemcpy(q, p, t);
+ p += t; n -= t;
+ q += t; m -= t;
+ if ((s->sub.left -= t) != 0)
+ break;
+ Tracev((stderr, "inflate: stored end, %lu total out\n",
+ z->total_out + (q >= s->read ? q - s->read :
+ (s->end - s->read) + (q - s->window))));
+ s->mode = s->last ? DRY : TYPE;
+ break;
+ case TABLE:
+ NEEDBITS(14)
+ s->sub.trees.table = t = (uInt)b & 0x3fff;
+#ifndef PKZIP_BUG_WORKAROUND
+ if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
+ {
+ s->mode = BADB;
+ z->msg = "too many length or distance symbols";
+ r = Z_DATA_ERROR;
+ LEAVE
+ }
+#endif
+ t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
+ if (t < 19)
+ t = 19;
+ if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
+ {
+ r = Z_MEM_ERROR;
+ LEAVE
+ }
+ s->sub.trees.nblens = t;
+ DUMPBITS(14)
+ s->sub.trees.index = 0;
+ Tracev((stderr, "inflate: table sizes ok\n"));
+ s->mode = BTREE;
+ case BTREE:
+ while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
+ {
+ NEEDBITS(3)
+ s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
+ DUMPBITS(3)
+ }
+ while (s->sub.trees.index < 19)
+ s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
+ s->sub.trees.bb = 7;
+ t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
+ &s->sub.trees.tb, z);
+ if (t != Z_OK)
+ {
+ r = t;
+ if (r == Z_DATA_ERROR)
+ s->mode = BADB;
+ LEAVE
+ }
+ s->sub.trees.index = 0;
+ Tracev((stderr, "inflate: bits tree ok\n"));
+ s->mode = DTREE;
+ case DTREE:
+ while (t = s->sub.trees.table,
+ s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
+ {
+ inflate_huft *h;
+ uInt i, j, c;
+
+ t = s->sub.trees.bb;
+ NEEDBITS(t)
+ h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
+ t = h->word.what.Bits;
+ c = h->more.Base;
+ if (c < 16)
+ {
+ DUMPBITS(t)
+ s->sub.trees.blens[s->sub.trees.index++] = c;
+ }
+ else /* c == 16..18 */
+ {
+ i = c == 18 ? 7 : c - 14;
+ j = c == 18 ? 11 : 3;
+ NEEDBITS(t + i)
+ DUMPBITS(t)
+ j += (uInt)b & inflate_mask[i];
+ DUMPBITS(i)
+ i = s->sub.trees.index;
+ t = s->sub.trees.table;
+ if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
+ (c == 16 && i < 1))
+ {
+ s->mode = BADB;
+ z->msg = "invalid bit length repeat";
+ r = Z_DATA_ERROR;
+ LEAVE
+ }
+ c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
+ do {
+ s->sub.trees.blens[i++] = c;
+ } while (--j);
+ s->sub.trees.index = i;
+ }
+ }
+ inflate_trees_free(s->sub.trees.tb, z);
+ s->sub.trees.tb = Z_NULL;
+ {
+ uInt bl, bd;
+ inflate_huft *tl, *td;
+ inflate_codes_statef *c;
+
+ bl = 9; /* must be <= 9 for lookahead assumptions */
+ bd = 6; /* must be <= 9 for lookahead assumptions */
+ t = s->sub.trees.table;
+ t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
+ s->sub.trees.blens, &bl, &bd, &tl, &td, z);
+ if (t != Z_OK)
+ {
+ if (t == (uInt)Z_DATA_ERROR)
+ s->mode = BADB;
+ r = t;
+ LEAVE
+ }
+ Tracev((stderr, "inflate: trees ok\n"));
+ if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
+ {
+ inflate_trees_free(td, z);
+ inflate_trees_free(tl, z);
+ r = Z_MEM_ERROR;
+ LEAVE
+ }
+ ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
+ s->sub.decode.codes = c;
+ s->sub.decode.tl = tl;
+ s->sub.decode.td = td;
+ }
+ s->mode = CODES;
+ case CODES:
+ UPDATE
+ if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
+ return inflate_flush(s, z, r);
+ r = Z_OK;
+ inflate_codes_free(s->sub.decode.codes, z);
+ inflate_trees_free(s->sub.decode.td, z);
+ inflate_trees_free(s->sub.decode.tl, z);
+ LOAD
+ Tracev((stderr, "inflate: codes end, %lu total out\n",
+ z->total_out + (q >= s->read ? q - s->read :
+ (s->end - s->read) + (q - s->window))));
+ if (!s->last)
+ {
+ s->mode = TYPE;
+ break;
+ }
+ if (k > 7) /* return unused byte, if any */
+ {
+ Assert(k < 16, "inflate_codes grabbed too many bytes")
+ k -= 8;
+ n++;
+ p--; /* can always return one */
+ }
+ s->mode = DRY;
+ case DRY:
+ FLUSH
+ if (s->read != s->write)
+ LEAVE
+ s->mode = DONEB;
+ case DONEB:
+ r = Z_STREAM_END;
+ LEAVE
+ case BADB:
+ r = Z_DATA_ERROR;
+ LEAVE
+ default:
+ r = Z_STREAM_ERROR;
+ LEAVE
+ }
+}
+
+
+local int inflate_blocks_free(s, z, c)
+inflate_blocks_statef *s;
+z_stream *z;
+uLongf *c;
+{
+ inflate_blocks_reset(s, z, c);
+ ZFREE(z, s->window, s->end - s->window);
+ ZFREE(z, s, sizeof(struct inflate_blocks_state));
+ Trace((stderr, "inflate: blocks freed\n"));
+ return Z_OK;
+}
+
+/*
+ * This subroutine adds the data at next_in/avail_in to the output history
+ * without performing any output. The output buffer must be "caught up";
+ * i.e. no pending output (hence s->read equals s->write), and the state must
+ * be BLOCKS (i.e. we should be willing to see the start of a series of
+ * BLOCKS). On exit, the output will also be caught up, and the checksum
+ * will have been updated if need be.
+ */
+local int inflate_addhistory(s, z)
+inflate_blocks_statef *s;
+z_stream *z;
+{
+ uLong b; /* bit buffer */ /* NOT USED HERE */
+ uInt k; /* bits in bit buffer */ /* NOT USED HERE */
+ uInt t; /* temporary storage */
+ Bytef *p; /* input data pointer */
+ uInt n; /* bytes available there */
+ Bytef *q; /* output window write pointer */
+ uInt m; /* bytes to end of window or read pointer */
+
+ if (s->read != s->write)
+ return Z_STREAM_ERROR;
+ if (s->mode != TYPE)
+ return Z_DATA_ERROR;
+
+ /* we're ready to rock */
+ LOAD
+ /* while there is input ready, copy to output buffer, moving
+ * pointers as needed.
+ */
+ while (n) {
+ t = n; /* how many to do */
+ /* is there room until end of buffer? */
+ if (t > m) t = m;
+ /* update check information */
+ if (s->checkfn != Z_NULL)
+ s->check = (*s->checkfn)(s->check, q, t);
+ zmemcpy(q, p, t);
+ q += t;
+ p += t;
+ n -= t;
+ z->total_out += t;
+ s->read = q; /* drag read pointer forward */
+/* WRAP */ /* expand WRAP macro by hand to handle s->read */
+ if (q == s->end) {
+ s->read = q = s->window;
+ m = WAVAIL;
+ }
+ }
+ UPDATE
+ return Z_OK;
+}
+
+
+/*
+ * At the end of a Deflate-compressed PPP packet, we expect to have seen
+ * a `stored' block type value but not the (zero) length bytes.
+ */
+local int inflate_packet_flush(s)
+ inflate_blocks_statef *s;
+{
+ if (s->mode != LENS)
+ return Z_DATA_ERROR;
+ s->mode = TYPE;
+ return Z_OK;
+}
+
+
+/*+++++*/
+/* inftrees.c -- generate Huffman trees for efficient decoding
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* simplify the use of the inflate_huft type with some defines */
+#define base more.Base
+#define next more.Next
+#define exop word.what.Exop
+#define bits word.what.Bits
+
+
+local int huft_build OF((
+ uIntf *, /* code lengths in bits */
+ uInt, /* number of codes */
+ uInt, /* number of "simple" codes */
+ uIntf *, /* list of base values for non-simple codes */
+ uIntf *, /* list of extra bits for non-simple codes */
+ inflate_huft * FAR*,/* result: starting table */
+ uIntf *, /* maximum lookup bits (returns actual) */
+ z_stream *)); /* for zalloc function */
+
+local voidpf falloc OF((
+ voidpf, /* opaque pointer (not used) */
+ uInt, /* number of items */
+ uInt)); /* size of item */
+
+local void ffree OF((
+ voidpf q, /* opaque pointer (not used) */
+ voidpf p, /* what to free (not used) */
+ uInt n)); /* number of bytes (not used) */
+
+/* Tables for deflate from PKZIP's appnote.txt. */
+local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
+ /* actually lengths - 2; also see note #13 above about 258 */
+local uInt cplext[] = { /* Extra bits for literal codes 257..285 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */
+local uInt cpdist[] = { /* Copy offsets for distance codes 0..29 */
+ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+ 8193, 12289, 16385, 24577};
+local uInt cpdext[] = { /* Extra bits for distance codes */
+ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+ 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
+ 12, 12, 13, 13};
+
+/*
+ Huffman code decoding is performed using a multi-level table lookup.
+ The fastest way to decode is to simply build a lookup table whose
+ size is determined by the longest code. However, the time it takes
+ to build this table can also be a factor if the data being decoded
+ is not very long. The most common codes are necessarily the
+ shortest codes, so those codes dominate the decoding time, and hence
+ the speed. The idea is you can have a shorter table that decodes the
+ shorter, more probable codes, and then point to subsidiary tables for
+ the longer codes. The time it costs to decode the longer codes is
+ then traded against the time it takes to make longer tables.
+
+ This results of this trade are in the variables lbits and dbits
+ below. lbits is the number of bits the first level table for literal/
+ length codes can decode in one step, and dbits is the same thing for
+ the distance codes. Subsequent tables are also less than or equal to
+ those sizes. These values may be adjusted either when all of the
+ codes are shorter than that, in which case the longest code length in
+ bits is used, or when the shortest code is *longer* than the requested
+ table size, in which case the length of the shortest code in bits is
+ used.
+
+ There are two different values for the two tables, since they code a
+ different number of possibilities each. The literal/length table
+ codes 286 possible values, or in a flat code, a little over eight
+ bits. The distance table codes 30 possible values, or a little less
+ than five bits, flat. The optimum values for speed end up being
+ about one bit more than those, so lbits is 8+1 and dbits is 5+1.
+ The optimum values may differ though from machine to machine, and
+ possibly even between compilers. Your mileage may vary.
+ */
+
+
+/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
+#define BMAX 15 /* maximum bit length of any code */
+#define N_MAX 288 /* maximum number of codes in any set */
+
+#ifdef DEBUG_ZLIB
+ uInt inflate_hufts;
+#endif
+
+local int huft_build(b, n, s, d, e, t, m, zs)
+uIntf *b; /* code lengths in bits (all assumed <= BMAX) */
+uInt n; /* number of codes (assumed <= N_MAX) */
+uInt s; /* number of simple-valued codes (0..s-1) */
+uIntf *d; /* list of base values for non-simple codes */
+uIntf *e; /* list of extra bits for non-simple codes */
+inflate_huft * FAR *t; /* result: starting table */
+uIntf *m; /* maximum lookup bits, returns actual */
+z_stream *zs; /* for zalloc function */
+/* Given a list of code lengths and a maximum table size, make a set of
+ tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
+ if the given code set is incomplete (the tables are still built in this
+ case), Z_DATA_ERROR if the input is invalid (all zero length codes or an
+ over-subscribed set of lengths), or Z_MEM_ERROR if not enough memory. */
+{
+
+ uInt a; /* counter for codes of length k */
+ uInt c[BMAX+1]; /* bit length count table */
+ uInt f; /* i repeats in table every f entries */
+ int g; /* maximum code length */
+ int h; /* table level */
+ register uInt i; /* counter, current code */
+ register uInt j; /* counter */
+ register int k; /* number of bits in current code */
+ int l; /* bits per table (returned in m) */
+ register uIntf *p; /* pointer into c[], b[], or v[] */
+ inflate_huft *q; /* points to current table */
+ struct inflate_huft_s r; /* table entry for structure assignment */
+ inflate_huft *u[BMAX]; /* table stack */
+ uInt v[N_MAX]; /* values in order of bit length */
+ register int w; /* bits before this table == (l * h) */
+ uInt x[BMAX+1]; /* bit offsets, then code stack */
+ uIntf *xp; /* pointer into x */
+ int y; /* number of dummy codes added */
+ uInt z; /* number of entries in current table */
+
+
+ /* Generate counts for each bit length */
+ p = c;
+#define C0 *p++ = 0;
+#define C2 C0 C0 C0 C0
+#define C4 C2 C2 C2 C2
+ C4 /* clear c[]--assume BMAX+1 is 16 */
+ p = b; i = n;
+ do {
+ c[*p++]++; /* assume all entries <= BMAX */
+ } while (--i);
+ if (c[0] == n) /* null input--all zero length codes */
+ {
+ *t = (inflate_huft *)Z_NULL;
+ *m = 0;
+ return Z_OK;
+ }
+
+
+ /* Find minimum and maximum length, bound *m by those */
+ l = *m;
+ for (j = 1; j <= BMAX; j++)
+ if (c[j])
+ break;
+ k = j; /* minimum code length */
+ if ((uInt)l < j)
+ l = j;
+ for (i = BMAX; i; i--)
+ if (c[i])
+ break;
+ g = i; /* maximum code length */
+ if ((uInt)l > i)
+ l = i;
+ *m = l;
+
+
+ /* Adjust last length count to fill out codes, if needed */
+ for (y = 1 << j; j < i; j++, y <<= 1)
+ if ((y -= c[j]) < 0)
+ return Z_DATA_ERROR;
+ if ((y -= c[i]) < 0)
+ return Z_DATA_ERROR;
+ c[i] += y;
+
+
+ /* Generate starting offsets into the value table for each length */
+ x[1] = j = 0;
+ p = c + 1; xp = x + 2;
+ while (--i) { /* note that i == g from above */
+ *xp++ = (j += *p++);
+ }
+
+
+ /* Make a table of values in order of bit lengths */
+ p = b; i = 0;
+ do {
+ if ((j = *p++) != 0)
+ v[x[j]++] = i;
+ } while (++i < n);
+
+
+ /* Generate the Huffman codes and for each, make the table entries */
+ x[0] = i = 0; /* first Huffman code is zero */
+ p = v; /* grab values in bit order */
+ h = -1; /* no tables yet--level -1 */
+ w = -l; /* bits decoded == (l * h) */
+ u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
+ q = (inflate_huft *)Z_NULL; /* ditto */
+ z = 0; /* ditto */
+
+ /* go through the bit lengths (k already is bits in shortest code) */
+ for (; k <= g; k++)
+ {
+ a = c[k];
+ while (a--)
+ {
+ /* here i is the Huffman code of length k bits for value *p */
+ /* make tables up to required level */
+ while (k > w + l)
+ {
+ h++;
+ w += l; /* previous table always l bits */
+
+ /* compute minimum size table less than or equal to l bits */
+ z = (z = g - w) > (uInt)l ? l : z; /* table size upper limit */
+ if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
+ { /* too few codes for k-w bit table */
+ f -= a + 1; /* deduct codes from patterns left */
+ xp = c + k;
+ if (j < z)
+ while (++j < z) /* try smaller tables up to z bits */
+ {
+ if ((f <<= 1) <= *++xp)
+ break; /* enough codes to use up j bits */
+ f -= *xp; /* else deduct codes from patterns */
+ }
+ }
+ z = 1 << j; /* table entries for j-bit table */
+
+ /* allocate and link in new table */
+ if ((q = (inflate_huft *)ZALLOC
+ (zs,z + 1,sizeof(inflate_huft))) == Z_NULL)
+ {
+ if (h)
+ inflate_trees_free(u[0], zs);
+ return Z_MEM_ERROR; /* not enough memory */
+ }
+ q->word.Nalloc = z + 1;
+#ifdef DEBUG_ZLIB
+ inflate_hufts += z + 1;
+#endif
+ *t = q + 1; /* link to list for huft_free() */
+ *(t = &(q->next)) = Z_NULL;
+ u[h] = ++q; /* table starts after link */
+
+ /* connect to last table, if there is one */
+ if (h)
+ {
+ x[h] = i; /* save pattern for backing up */
+ r.bits = (Byte)l; /* bits to dump before this table */
+ r.exop = (Byte)j; /* bits in this table */
+ r.next = q; /* pointer to this table */
+ j = i >> (w - l); /* (get around Turbo C bug) */
+ u[h-1][j] = r; /* connect to last table */
+ }
+ }
+
+ /* set up table entry in r */
+ r.bits = (Byte)(k - w);
+ if (p >= v + n)
+ r.exop = 128 + 64; /* out of values--invalid code */
+ else if (*p < s)
+ {
+ r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
+ r.base = *p++; /* simple code is just the value */
+ }
+ else
+ {
+ r.exop = (Byte)e[*p - s] + 16 + 64; /* non-simple--look up in lists */
+ r.base = d[*p++ - s];
+ }
+
+ /* fill code-like entries with r */
+ f = 1 << (k - w);
+ for (j = i >> w; j < z; j += f)
+ q[j] = r;
+
+ /* backwards increment the k-bit code i */
+ for (j = 1 << (k - 1); i & j; j >>= 1)
+ i ^= j;
+ i ^= j;
+
+ /* backup over finished tables */
+ while ((i & ((1 << w) - 1)) != x[h])
+ {
+ h--; /* don't need to update q */
+ w -= l;
+ }
+ }
+ }
+
+
+ /* Return Z_BUF_ERROR if we were given an incomplete table */
+ return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
+}
+
+
+local int inflate_trees_bits(c, bb, tb, z)
+uIntf *c; /* 19 code lengths */
+uIntf *bb; /* bits tree desired/actual depth */
+inflate_huft * FAR *tb; /* bits tree result */
+z_stream *z; /* for zfree function */
+{
+ int r;
+
+ r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z);
+ if (r == Z_DATA_ERROR)
+ z->msg = "oversubscribed dynamic bit lengths tree";
+ else if (r == Z_BUF_ERROR)
+ {
+ inflate_trees_free(*tb, z);
+ z->msg = "incomplete dynamic bit lengths tree";
+ r = Z_DATA_ERROR;
+ }
+ return r;
+}
+
+
+local int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z)
+uInt nl; /* number of literal/length codes */
+uInt nd; /* number of distance codes */
+uIntf *c; /* that many (total) code lengths */
+uIntf *bl; /* literal desired/actual bit depth */
+uIntf *bd; /* distance desired/actual bit depth */
+inflate_huft * FAR *tl; /* literal/length tree result */
+inflate_huft * FAR *td; /* distance tree result */
+z_stream *z; /* for zfree function */
+{
+ int r;
+
+ /* build literal/length tree */
+ if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK)
+ {
+ if (r == Z_DATA_ERROR)
+ z->msg = "oversubscribed literal/length tree";
+ else if (r == Z_BUF_ERROR)
+ {
+ inflate_trees_free(*tl, z);
+ z->msg = "incomplete literal/length tree";
+ r = Z_DATA_ERROR;
+ }
+ return r;
+ }
+
+ /* build distance tree */
+ if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK)
+ {
+ if (r == Z_DATA_ERROR)
+ z->msg = "oversubscribed literal/length tree";
+ else if (r == Z_BUF_ERROR) {
+#ifdef PKZIP_BUG_WORKAROUND
+ r = Z_OK;
+ }
+#else
+ inflate_trees_free(*td, z);
+ z->msg = "incomplete literal/length tree";
+ r = Z_DATA_ERROR;
+ }
+ inflate_trees_free(*tl, z);
+ return r;
+#endif
+ }
+
+ /* done */
+ return Z_OK;
+}
+
+
+/* build fixed tables only once--keep them here */
+local int fixed_lock = 0;
+local int fixed_built = 0;
+#define FIXEDH 530 /* number of hufts used by fixed tables */
+local uInt fixed_left = FIXEDH;
+local inflate_huft fixed_mem[FIXEDH];
+local uInt fixed_bl;
+local uInt fixed_bd;
+local inflate_huft *fixed_tl;
+local inflate_huft *fixed_td;
+
+
+local voidpf falloc(q, n, s)
+voidpf q; /* opaque pointer (not used) */
+uInt n; /* number of items */
+uInt s; /* size of item */
+{
+ Assert(s == sizeof(inflate_huft) && n <= fixed_left,
+ "inflate_trees falloc overflow");
+ if (q) s++; /* to make some compilers happy */
+ fixed_left -= n;
+ return (voidpf)(fixed_mem + fixed_left);
+}
+
+
+local void ffree(q, p, n)
+voidpf q;
+voidpf p;
+uInt n;
+{
+ Assert(0, "inflate_trees ffree called!");
+ if (q) q = p; /* to make some compilers happy */
+}
+
+
+local int inflate_trees_fixed(bl, bd, tl, td)
+uIntf *bl; /* literal desired/actual bit depth */
+uIntf *bd; /* distance desired/actual bit depth */
+inflate_huft * FAR *tl; /* literal/length tree result */
+inflate_huft * FAR *td; /* distance tree result */
+{
+ /* build fixed tables if not built already--lock out other instances */
+ while (++fixed_lock > 1)
+ fixed_lock--;
+ if (!fixed_built)
+ {
+ int k; /* temporary variable */
+ unsigned c[288]; /* length list for huft_build */
+ z_stream z; /* for falloc function */
+
+ /* set up fake z_stream for memory routines */
+ z.zalloc = falloc;
+ z.zfree = ffree;
+ z.opaque = Z_NULL;
+
+ /* literal table */
+ for (k = 0; k < 144; k++)
+ c[k] = 8;
+ for (; k < 256; k++)
+ c[k] = 9;
+ for (; k < 280; k++)
+ c[k] = 7;
+ for (; k < 288; k++)
+ c[k] = 8;
+ fixed_bl = 7;
+ huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, &z);
+
+ /* distance table */
+ for (k = 0; k < 30; k++)
+ c[k] = 5;
+ fixed_bd = 5;
+ huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, &z);
+
+ /* done */
+ fixed_built = 1;
+ }
+ fixed_lock--;
+ *bl = fixed_bl;
+ *bd = fixed_bd;
+ *tl = fixed_tl;
+ *td = fixed_td;
+ return Z_OK;
+}
+
+
+local int inflate_trees_free(t, z)
+inflate_huft *t; /* table to free */
+z_stream *z; /* for zfree function */
+/* Free the malloc'ed tables built by huft_build(), which makes a linked
+ list of the tables it made, with the links in a dummy first entry of
+ each table. */
+{
+ register inflate_huft *p, *q;
+
+ /* Go through linked list, freeing from the malloced (t[-1]) address. */
+ p = t;
+ while (p != Z_NULL)
+ {
+ q = (--p)->next;
+ ZFREE(z, p, p->word.Nalloc * sizeof(inflate_huft));
+ p = q;
+ }
+ return Z_OK;
+}
+
+/*+++++*/
+/* infcodes.c -- process literals and length/distance pairs
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* simplify the use of the inflate_huft type with some defines */
+#define base more.Base
+#define next more.Next
+#define exop word.what.Exop
+#define bits word.what.Bits
+
+/* inflate codes private state */
+struct inflate_codes_state {
+
+ /* mode */
+ enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
+ START, /* x: set up for LEN */
+ LEN, /* i: get length/literal/eob next */
+ LENEXT, /* i: getting length extra (have base) */
+ DIST, /* i: get distance next */
+ DISTEXT, /* i: getting distance extra */
+ COPY, /* o: copying bytes in window, waiting for space */
+ LIT, /* o: got literal, waiting for output space */
+ WASH, /* o: got eob, possibly still output waiting */
+ END, /* x: got eob and all data flushed */
+ BADCODE} /* x: got error */
+ mode; /* current inflate_codes mode */
+
+ /* mode dependent information */
+ uInt len;
+ union {
+ struct {
+ inflate_huft *tree; /* pointer into tree */
+ uInt need; /* bits needed */
+ } code; /* if LEN or DIST, where in tree */
+ uInt lit; /* if LIT, literal */
+ struct {
+ uInt get; /* bits to get for extra */
+ uInt dist; /* distance back to copy from */
+ } copy; /* if EXT or COPY, where and how much */
+ } sub; /* submode */
+
+ /* mode independent information */
+ Byte lbits; /* ltree bits decoded per branch */
+ Byte dbits; /* dtree bits decoder per branch */
+ inflate_huft *ltree; /* literal/length/eob tree */
+ inflate_huft *dtree; /* distance tree */
+
+};
+
+
+local inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
+uInt bl, bd;
+inflate_huft *tl, *td;
+z_stream *z;
+{
+ inflate_codes_statef *c;
+
+ if ((c = (inflate_codes_statef *)
+ ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
+ {
+ c->mode = START;
+ c->lbits = (Byte)bl;
+ c->dbits = (Byte)bd;
+ c->ltree = tl;
+ c->dtree = td;
+ Tracev((stderr, "inflate: codes new\n"));
+ }
+ return c;
+}
+
+
+local int inflate_codes(s, z, r)
+inflate_blocks_statef *s;
+z_stream *z;
+int r;
+{
+ uInt j; /* temporary storage */
+ inflate_huft *t; /* temporary pointer */
+ uInt e; /* extra bits or operation */
+ uLong b; /* bit buffer */
+ uInt k; /* bits in bit buffer */
+ Bytef *p; /* input data pointer */
+ uInt n; /* bytes available there */
+ Bytef *q; /* output window write pointer */
+ uInt m; /* bytes to end of window or read pointer */
+ Bytef *f; /* pointer to copy strings from */
+ inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
+
+ /* copy input/output information to locals (UPDATE macro restores) */
+ LOAD
+
+ /* process input and output based on current state */
+ while (1) switch (c->mode)
+ { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
+ case START: /* x: set up for LEN */
+#ifndef SLOW
+ if (m >= 258 && n >= 10)
+ {
+ UPDATE
+ r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
+ LOAD
+ if (r != Z_OK)
+ {
+ c->mode = r == Z_STREAM_END ? WASH : BADCODE;
+ break;
+ }
+ }
+#endif /* !SLOW */
+ c->sub.code.need = c->lbits;
+ c->sub.code.tree = c->ltree;
+ c->mode = LEN;
+ case LEN: /* i: get length/literal/eob next */
+ j = c->sub.code.need;
+ NEEDBITS(j)
+ t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
+ DUMPBITS(t->bits)
+ e = (uInt)(t->exop);
+ if (e == 0) /* literal */
+ {
+ c->sub.lit = t->base;
+ Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
+ "inflate: literal '%c'\n" :
+ "inflate: literal 0x%02x\n", t->base));
+ c->mode = LIT;
+ break;
+ }
+ if (e & 16) /* length */
+ {
+ c->sub.copy.get = e & 15;
+ c->len = t->base;
+ c->mode = LENEXT;
+ break;
+ }
+ if ((e & 64) == 0) /* next table */
+ {
+ c->sub.code.need = e;
+ c->sub.code.tree = t->next;
+ break;
+ }
+ if (e & 32) /* end of block */
+ {
+ Tracevv((stderr, "inflate: end of block\n"));
+ c->mode = WASH;
+ break;
+ }
+ c->mode = BADCODE; /* invalid code */
+ z->msg = "invalid literal/length code";
+ r = Z_DATA_ERROR;
+ LEAVE
+ case LENEXT: /* i: getting length extra (have base) */
+ j = c->sub.copy.get;
+ NEEDBITS(j)
+ c->len += (uInt)b & inflate_mask[j];
+ DUMPBITS(j)
+ c->sub.code.need = c->dbits;
+ c->sub.code.tree = c->dtree;
+ Tracevv((stderr, "inflate: length %u\n", c->len));
+ c->mode = DIST;
+ case DIST: /* i: get distance next */
+ j = c->sub.code.need;
+ NEEDBITS(j)
+ t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
+ DUMPBITS(t->bits)
+ e = (uInt)(t->exop);
+ if (e & 16) /* distance */
+ {
+ c->sub.copy.get = e & 15;
+ c->sub.copy.dist = t->base;
+ c->mode = DISTEXT;
+ break;
+ }
+ if ((e & 64) == 0) /* next table */
+ {
+ c->sub.code.need = e;
+ c->sub.code.tree = t->next;
+ break;
+ }
+ c->mode = BADCODE; /* invalid code */
+ z->msg = "invalid distance code";
+ r = Z_DATA_ERROR;
+ LEAVE
+ case DISTEXT: /* i: getting distance extra */
+ j = c->sub.copy.get;
+ NEEDBITS(j)
+ c->sub.copy.dist += (uInt)b & inflate_mask[j];
+ DUMPBITS(j)
+ Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
+ c->mode = COPY;
+ case COPY: /* o: copying bytes in window, waiting for space */
+#ifndef __TURBOC__ /* Turbo C bug for following expression */
+ f = (uInt)(q - s->window) < c->sub.copy.dist ?
+ s->end - (c->sub.copy.dist - (q - s->window)) :
+ q - c->sub.copy.dist;
+#else
+ f = q - c->sub.copy.dist;
+ if ((uInt)(q - s->window) < c->sub.copy.dist)
+ f = s->end - (c->sub.copy.dist - (q - s->window));
+#endif
+ while (c->len)
+ {
+ NEEDOUT
+ OUTBYTE(*f++)
+ if (f == s->end)
+ f = s->window;
+ c->len--;
+ }
+ c->mode = START;
+ break;
+ case LIT: /* o: got literal, waiting for output space */
+ NEEDOUT
+ OUTBYTE(c->sub.lit)
+ c->mode = START;
+ break;
+ case WASH: /* o: got eob, possibly more output */
+ FLUSH
+ if (s->read != s->write)
+ LEAVE
+ c->mode = END;
+ case END:
+ r = Z_STREAM_END;
+ LEAVE
+ case BADCODE: /* x: got error */
+ r = Z_DATA_ERROR;
+ LEAVE
+ default:
+ r = Z_STREAM_ERROR;
+ LEAVE
+ }
+}
+
+
+local void inflate_codes_free(c, z)
+inflate_codes_statef *c;
+z_stream *z;
+{
+ ZFREE(z, c, sizeof(struct inflate_codes_state));
+ Tracev((stderr, "inflate: codes free\n"));
+}
+
+/*+++++*/
+/* inflate_util.c -- data and routines common to blocks and codes
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* copy as much as possible from the sliding window to the output area */
+local int inflate_flush(s, z, r)
+inflate_blocks_statef *s;
+z_stream *z;
+int r;
+{
+ uInt n;
+ Bytef *p, *q;
+
+ /* local copies of source and destination pointers */
+ p = z->next_out;
+ q = s->read;
+
+ /* compute number of bytes to copy as far as end of window */
+ n = (uInt)((q <= s->write ? s->write : s->end) - q);
+ if (n > z->avail_out) n = z->avail_out;
+ if (n && r == Z_BUF_ERROR) r = Z_OK;
+
+ /* update counters */
+ z->avail_out -= n;
+ z->total_out += n;
+
+ /* update check information */
+ if (s->checkfn != Z_NULL)
+ s->check = (*s->checkfn)(s->check, q, n);
+
+ /* copy as far as end of window */
+ if (p != NULL) {
+ zmemcpy(p, q, n);
+ p += n;
+ }
+ q += n;
+
+ /* see if more to copy at beginning of window */
+ if (q == s->end)
+ {
+ /* wrap pointers */
+ q = s->window;
+ if (s->write == s->end)
+ s->write = s->window;
+
+ /* compute bytes to copy */
+ n = (uInt)(s->write - q);
+ if (n > z->avail_out) n = z->avail_out;
+ if (n && r == Z_BUF_ERROR) r = Z_OK;
+
+ /* update counters */
+ z->avail_out -= n;
+ z->total_out += n;
+
+ /* update check information */
+ if (s->checkfn != Z_NULL)
+ s->check = (*s->checkfn)(s->check, q, n);
+
+ /* copy */
+ if (p != NULL) {
+ zmemcpy(p, q, n);
+ p += n;
+ }
+ q += n;
+ }
+
+ /* update pointers */
+ z->next_out = p;
+ s->read = q;
+
+ /* done */
+ return r;
+}
+
+
+/*+++++*/
+/* inffast.c -- process literals and length/distance pairs fast
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* simplify the use of the inflate_huft type with some defines */
+#define base more.Base
+#define next more.Next
+#define exop word.what.Exop
+#define bits word.what.Bits
+
+/* macros for bit input with no checking and for returning unused bytes */
+#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
+#define UNGRAB {n+=(c=k>>3);p-=c;k&=7;}
+
+/* Called with number of bytes left to write in window at least 258
+ (the maximum string length) and number of input bytes available
+ at least ten. The ten bytes are six bytes for the longest length/
+ distance pair plus four bytes for overloading the bit buffer. */
+
+local int inflate_fast(bl, bd, tl, td, s, z)
+uInt bl, bd;
+inflate_huft *tl, *td;
+inflate_blocks_statef *s;
+z_stream *z;
+{
+ inflate_huft *t; /* temporary pointer */
+ uInt e; /* extra bits or operation */
+ uLong b; /* bit buffer */
+ uInt k; /* bits in bit buffer */
+ Bytef *p; /* input data pointer */
+ uInt n; /* bytes available there */
+ Bytef *q; /* output window write pointer */
+ uInt m; /* bytes to end of window or read pointer */
+ uInt ml; /* mask for literal/length tree */
+ uInt md; /* mask for distance tree */
+ uInt c; /* bytes to copy */
+ uInt d; /* distance back to copy from */
+ Bytef *r; /* copy source pointer */
+
+ /* load input, output, bit values */
+ LOAD
+
+ /* initialize masks */
+ ml = inflate_mask[bl];
+ md = inflate_mask[bd];
+
+ /* do until not enough input or output space for fast loop */
+ do { /* assume called with m >= 258 && n >= 10 */
+ /* get literal/length code */
+ GRABBITS(20) /* max bits for literal/length code */
+ if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
+ {
+ DUMPBITS(t->bits)
+ Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
+ "inflate: * literal '%c'\n" :
+ "inflate: * literal 0x%02x\n", t->base));
+ *q++ = (Byte)t->base;
+ m--;
+ continue;
+ }
+ do {
+ DUMPBITS(t->bits)
+ if (e & 16)
+ {
+ /* get extra bits for length */
+ e &= 15;
+ c = t->base + ((uInt)b & inflate_mask[e]);
+ DUMPBITS(e)
+ Tracevv((stderr, "inflate: * length %u\n", c));
+
+ /* decode distance base of block to copy */
+ GRABBITS(15); /* max bits for distance code */
+ e = (t = td + ((uInt)b & md))->exop;
+ do {
+ DUMPBITS(t->bits)
+ if (e & 16)
+ {
+ /* get extra bits to add to distance base */
+ e &= 15;
+ GRABBITS(e) /* get extra bits (up to 13) */
+ d = t->base + ((uInt)b & inflate_mask[e]);
+ DUMPBITS(e)
+ Tracevv((stderr, "inflate: * distance %u\n", d));
+
+ /* do the copy */
+ m -= c;
+ if ((uInt)(q - s->window) >= d) /* offset before dest */
+ { /* just copy */
+ r = q - d;
+ *q++ = *r++; c--; /* minimum count is three, */
+ *q++ = *r++; c--; /* so unroll loop a little */
+ }
+ else /* else offset after destination */
+ {
+ e = d - (q - s->window); /* bytes from offset to end */
+ r = s->end - e; /* pointer to offset */
+ if (c > e) /* if source crosses, */
+ {
+ c -= e; /* copy to end of window */
+ do {
+ *q++ = *r++;
+ } while (--e);
+ r = s->window; /* copy rest from start of window */
+ }
+ }
+ do { /* copy all or what's left */
+ *q++ = *r++;
+ } while (--c);
+ break;
+ }
+ else if ((e & 64) == 0)
+ e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop;
+ else
+ {
+ z->msg = "invalid distance code";
+ UNGRAB
+ UPDATE
+ return Z_DATA_ERROR;
+ }
+ } while (1);
+ break;
+ }
+ if ((e & 64) == 0)
+ {
+ if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0)
+ {
+ DUMPBITS(t->bits)
+ Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
+ "inflate: * literal '%c'\n" :
+ "inflate: * literal 0x%02x\n", t->base));
+ *q++ = (Byte)t->base;
+ m--;
+ break;
+ }
+ }
+ else if (e & 32)
+ {
+ Tracevv((stderr, "inflate: * end of block\n"));
+ UNGRAB
+ UPDATE
+ return Z_STREAM_END;
+ }
+ else
+ {
+ z->msg = "invalid literal/length code";
+ UNGRAB
+ UPDATE
+ return Z_DATA_ERROR;
+ }
+ } while (1);
+ } while (m >= 258 && n >= 10);
+
+ /* not enough input or output--restore pointers and return */
+ UNGRAB
+ UPDATE
+ return Z_OK;
+}
+
+
+/*+++++*/
+/* zutil.c -- target dependent utility functions for the compression library
+ * Copyright (C) 1995 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* From: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp */
+
+char *zlib_version = ZLIB_VERSION;
+
+char *z_errmsg[] = {
+"stream end", /* Z_STREAM_END 1 */
+"", /* Z_OK 0 */
+"file error", /* Z_ERRNO (-1) */
+"stream error", /* Z_STREAM_ERROR (-2) */
+"data error", /* Z_DATA_ERROR (-3) */
+"insufficient memory", /* Z_MEM_ERROR (-4) */
+"buffer error", /* Z_BUF_ERROR (-5) */
+""};
+
+
+/*+++++*/
+/* adler32.c -- compute the Adler-32 checksum of a data stream
+ * Copyright (C) 1995 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* From: adler32.c,v 1.6 1995/05/03 17:27:08 jloup Exp */
+
+#define BASE 65521L /* largest prime smaller than 65536 */
+#define NMAX 5552
+/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
+
+#define DO1(buf) {s1 += *buf++; s2 += s1;}
+#define DO2(buf) DO1(buf); DO1(buf);
+#define DO4(buf) DO2(buf); DO2(buf);
+#define DO8(buf) DO4(buf); DO4(buf);
+#define DO16(buf) DO8(buf); DO8(buf);
+
+/* ========================================================================= */
+uLong adler32(adler, buf, len)
+ uLong adler;
+ Bytef *buf;
+ uInt len;
+{
+ unsigned long s1 = adler & 0xffff;
+ unsigned long s2 = (adler >> 16) & 0xffff;
+ int k;
+
+ if (buf == Z_NULL) return 1L;
+
+ while (len > 0) {
+ k = len < NMAX ? len : NMAX;
+ len -= k;
+ while (k >= 16) {
+ DO16(buf);
+ k -= 16;
+ }
+ if (k != 0) do {
+ DO1(buf);
+ } while (--k);
+ s1 %= BASE;
+ s2 %= BASE;
+ }
+ return (s2 << 16) | s1;
+}
--- /dev/null
+/* $NetBSD: zlib.h,v 1.1 1996/03/15 02:28:17 paulus Exp $ */
+
+/*
+ * This file is derived from zlib.h and zconf.h from the zlib-0.95
+ * distribution by Jean-loup Gailly and Mark Adler, with some additions
+ * by Paul Mackerras to aid in implementing Deflate compression and
+ * decompression for PPP packets.
+ */
+
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+ version 0.95, Aug 16th, 1995.
+
+ Copyright (C) 1995 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ gzip@prep.ai.mit.edu madler@alumni.caltech.edu
+ */
+
+#ifndef _ZLIB_H
+#define _ZLIB_H
+
+/* #include "zconf.h" */ /* included directly here */
+
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* From: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp */
+
+/*
+ The library does not install any signal handler. It is recommended to
+ add at least a handler for SIGSEGV when decompressing; the library checks
+ the consistency of the input data whenever possible but may go nuts
+ for some forms of corrupted input.
+ */
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ * Compile with -DUNALIGNED_OK if it is OK to access shorts or ints
+ * at addresses which are not a multiple of their size.
+ * Under DOS, -DFAR=far or -DFAR=__far may be needed.
+ */
+
+#ifndef STDC
+# if defined(MSDOS) || defined(__STDC__) || defined(__cplusplus)
+# define STDC
+# endif
+#endif
+
+#ifdef __MWERKS__ /* Metrowerks CodeWarrior declares fileno() in unix.h */
+# include <unix.h>
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+# ifdef MAXSEG_64K
+# define MAX_MEM_LEVEL 8
+# else
+# define MAX_MEM_LEVEL 9
+# endif
+#endif
+
+#ifndef FAR
+# define FAR
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
+#ifndef MAX_WBITS
+# define MAX_WBITS 15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+ 1 << (windowBits+2) + 1 << (memLevel+9)
+ that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+ make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+ The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
+ /* Type declarations */
+
+#ifndef OF /* function prototypes */
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
+
+typedef unsigned char Byte; /* 8 bits */
+typedef unsigned int uInt; /* 16 bits or more */
+typedef unsigned long uLong; /* 32 bits or more */
+
+typedef Byte FAR Bytef;
+typedef char FAR charf;
+typedef int FAR intf;
+typedef uInt FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+ typedef void FAR *voidpf;
+ typedef void *voidp;
+#else
+ typedef Byte FAR *voidpf;
+ typedef Byte *voidp;
+#endif
+
+/* end of original zconf.h */
+
+#define ZLIB_VERSION "0.95P"
+
+/*
+ The 'zlib' compression library provides in-memory compression and
+ decompression functions, including integrity checks of the uncompressed
+ data. This version of the library supports only one compression method
+ (deflation) but other algorithms may be added later and will have the same
+ stream interface.
+
+ For compression the application must provide the output buffer and
+ may optionally provide the input buffer for optimization. For decompression,
+ the application must provide the input buffer and may optionally provide
+ the output buffer for optimization.
+
+ Compression can be done in a single step if the buffers are large
+ enough (for example if an input file is mmap'ed), or can be done by
+ repeated calls of the compression function. In the latter case, the
+ application must provide more input and/or consume the output
+ (providing more output space) before each call.
+*/
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt nbytes));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+ Bytef *next_in; /* next input byte */
+ uInt avail_in; /* number of bytes available at next_in */
+ uLong total_in; /* total nb of input bytes read so far */
+
+ Bytef *next_out; /* next output byte should be put there */
+ uInt avail_out; /* remaining free space at next_out */
+ uLong total_out; /* total nb of bytes output so far */
+
+ char *msg; /* last error message, NULL if no error */
+ struct internal_state FAR *state; /* not visible by applications */
+
+ alloc_func zalloc; /* used to allocate the internal state */
+ free_func zfree; /* used to free the internal state */
+ voidp opaque; /* private data object passed to zalloc and zfree */
+
+ Byte data_type; /* best guess about the data type: ascii or binary */
+
+} z_stream;
+
+/*
+ The application must update next_in and avail_in when avail_in has
+ dropped to zero. It must update next_out and avail_out when avail_out
+ has dropped to zero. The application must initialize zalloc, zfree and
+ opaque before calling the init function. All other fields are set by the
+ compression library and must not be updated by the application.
+
+ The opaque value provided by the application will be passed as the first
+ parameter for calls of zalloc and zfree. This can be useful for custom
+ memory management. The compression library attaches no meaning to the
+ opaque value.
+
+ zalloc must return Z_NULL if there is not enough memory for the object.
+ On 16-bit systems, the functions zalloc and zfree must be able to allocate
+ exactly 65536 bytes, but will not be required to allocate more than this
+ if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
+ pointers returned by zalloc for objects of exactly 65536 bytes *must*
+ have their offset normalized to zero. The default allocation function
+ provided by this library ensures this (see zutil.c). To reduce memory
+ requirements and avoid any allocation of 64K objects, at the expense of
+ compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
+
+ The fields total_in and total_out can be used for statistics or
+ progress reports. After compression, total_in holds the total size of
+ the uncompressed data and may be saved for use in the decompressor
+ (particularly if the decompressor wants to decompress everything in
+ a single step).
+*/
+
+ /* constants */
+
+#define Z_NO_FLUSH 0
+#define Z_PARTIAL_FLUSH 1
+#define Z_FULL_FLUSH 2
+#define Z_SYNC_FLUSH 3 /* experimental: partial_flush + byte align */
+#define Z_FINISH 4
+#define Z_PACKET_FLUSH 5
+/* See deflate() below for the usage of these constants */
+
+#define Z_OK 0
+#define Z_STREAM_END 1
+#define Z_ERRNO (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR (-3)
+#define Z_MEM_ERROR (-4)
+#define Z_BUF_ERROR (-5)
+/* error codes for the compression/decompression functions */
+
+#define Z_BEST_SPEED 1
+#define Z_BEST_COMPRESSION 9
+#define Z_DEFAULT_COMPRESSION (-1)
+/* compression levels */
+
+#define Z_FILTERED 1
+#define Z_HUFFMAN_ONLY 2
+#define Z_DEFAULT_STRATEGY 0
+
+#define Z_BINARY 0
+#define Z_ASCII 1
+#define Z_UNKNOWN 2
+/* Used to set the data_type field */
+
+#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
+
+extern char *zlib_version;
+/* The application can compare zlib_version and ZLIB_VERSION for consistency.
+ If the first character differs, the library code actually used is
+ not compatible with the zlib.h header file used by the application.
+ */
+
+ /* basic functions */
+
+extern int deflateInit OF((z_stream *strm, int level));
+/*
+ Initializes the internal stream state for compression. The fields
+ zalloc, zfree and opaque must be initialized before by the caller.
+ If zalloc and zfree are set to Z_NULL, deflateInit updates them to
+ use default allocation functions.
+
+ The compression level must be Z_DEFAULT_COMPRESSION, or between 1 and 9:
+ 1 gives best speed, 9 gives best compression. Z_DEFAULT_COMPRESSION requests
+ a default compromise between speed and compression (currently equivalent
+ to level 6).
+
+ deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if level is not a valid compression level.
+ msg is set to null if there is no error message. deflateInit does not
+ perform any compression: this will be done by deflate().
+*/
+
+
+extern int deflate OF((z_stream *strm, int flush));
+/*
+ Performs one or both of the following actions:
+
+ - Compress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in and avail_in are updated and
+ processing will resume at this point for the next call of deflate().
+
+ - Provide more output starting at next_out and update next_out and avail_out
+ accordingly. This action is forced if the parameter flush is non zero.
+ Forcing flush frequently degrades the compression ratio, so this parameter
+ should be set only when necessary (in interactive applications).
+ Some output may be provided even if flush is not set.
+
+ Before the call of deflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming
+ more output, and updating avail_in or avail_out accordingly; avail_out
+ should never be zero before the call. The application can consume the
+ compressed output when it wants, for example when the output buffer is full
+ (avail_out == 0), or after each call of deflate().
+
+ If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression
+ block is terminated and flushed to the output buffer so that the
+ decompressor can get all input data available so far. For method 9, a future
+ variant on method 8, the current block will be flushed but not terminated.
+ If flush is set to Z_FULL_FLUSH, the compression block is terminated, a
+ special marker is output and the compression dictionary is discarded; this
+ is useful to allow the decompressor to synchronize if one compressed block
+ has been damaged (see inflateSync below). Flushing degrades compression and
+ so should be used only when necessary. Using Z_FULL_FLUSH too often can
+ seriously degrade the compression. If deflate returns with avail_out == 0,
+ this function must be called again with the same value of the flush
+ parameter and more output space (updated avail_out), until the flush is
+ complete (deflate returns with non-zero avail_out).
+
+ If the parameter flush is set to Z_PACKET_FLUSH, the compression
+ block is terminated, and a zero-length stored block is output,
+ omitting the length bytes (the effect of this is that the 3-bit type
+ code 000 for a stored block is output, and the output is then
+ byte-aligned). This is designed for use at the end of a PPP packet.
+ In addition, if the current compression block contains all the data
+ since the last Z_PACKET_FLUSH, it is never output as a stored block.
+ If the current compression block output as a static or dynamic block
+ would not be at least `minCompression' bytes smaller than the
+ original data, then nothing is output for that block. (The type
+ code for the zero-length stored block is still output, resulting in
+ a single zero byte being output for the whole packet.)
+ `MinCompression' is a parameter to deflateInit2, or 0 if deflateInit
+ is used.
+
+ If the parameter flush is set to Z_FINISH, all pending input is processed,
+ all pending output is flushed and deflate returns with Z_STREAM_END if there
+ was enough output space; if deflate returns with Z_OK, this function must be
+ called again with Z_FINISH and more output space (updated avail_out) but no
+ more input data, until it returns with Z_STREAM_END or an error. After
+ deflate has returned Z_STREAM_END, the only possible operations on the
+ stream are deflateReset or deflateEnd.
+
+ Z_FINISH can be used immediately after deflateInit if all the compression
+ is to be done in a single step. In this case, avail_out must be at least
+ 0.1% larger than avail_in plus 12 bytes. If deflate does not return
+ Z_STREAM_END, then it must be called again as described above.
+
+ deflate() may update data_type if it can make a good guess about
+ the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
+ binary. This field is only for information purposes and does not affect
+ the compression algorithm in any manner.
+
+ deflate() returns Z_OK if some progress has been made (more input
+ processed or more output produced), Z_STREAM_END if all input has been
+ consumed and all output has been produced (only when flush is set to
+ Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+ if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible.
+*/
+
+
+extern int deflateEnd OF((z_stream *strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any
+ pending output.
+
+ deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+ stream state was inconsistent. In the error case, msg may be set
+ but then points to a static string (which must not be deallocated).
+*/
+
+
+extern int inflateInit OF((z_stream *strm));
+/*
+ Initializes the internal stream state for decompression. The fields
+ zalloc and zfree must be initialized before by the caller. If zalloc and
+ zfree are set to Z_NULL, inflateInit updates them to use default allocation
+ functions.
+
+ inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory. msg is set to null if there is no error message.
+ inflateInit does not perform any decompression: this will be done by
+ inflate().
+*/
+
+
+extern int inflate OF((z_stream *strm, int flush));
+/*
+ Performs one or both of the following actions:
+
+ - Decompress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in is updated and processing
+ will resume at this point for the next call of inflate().
+
+ - Provide more output starting at next_out and update next_out and avail_out
+ accordingly. inflate() always provides as much output as possible
+ (until there is no more input data or no more space in the output buffer).
+
+ Before the call of inflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming
+ more output, and updating the next_* and avail_* values accordingly.
+ The application can consume the uncompressed output when it wants, for
+ example when the output buffer is full (avail_out == 0), or after each
+ call of inflate().
+
+ If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH,
+ inflate flushes as much output as possible to the output buffer. The
+ flushing behavior of inflate is not specified for values of the flush
+ parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
+ current implementation actually flushes as much output as possible
+ anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data
+ has been consumed, it is expecting to see the length field of a stored
+ block; if not, it returns Z_DATA_ERROR.
+
+ inflate() should normally be called until it returns Z_STREAM_END or an
+ error. However if all decompression is to be performed in a single step
+ (a single call of inflate), the parameter flush should be set to
+ Z_FINISH. In this case all pending input is processed and all pending
+ output is flushed; avail_out must be large enough to hold all the
+ uncompressed data. (The size of the uncompressed data may have been saved
+ by the compressor for this purpose.) The next operation on this stream must
+ be inflateEnd to deallocate the decompression state. The use of Z_FINISH
+ is never required, but can be used to inform inflate that a faster routine
+ may be used for the single inflate() call.
+
+ inflate() returns Z_OK if some progress has been made (more input
+ processed or more output produced), Z_STREAM_END if the end of the
+ compressed data has been reached and all uncompressed output has been
+ produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if
+ the stream structure was inconsistent (for example if next_in or next_out
+ was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no
+ progress is possible or if there was not enough room in the output buffer
+ when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then
+ call inflateSync to look for a good compression block. */
+
+
+extern int inflateEnd OF((z_stream *strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any
+ pending output.
+
+ inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
+ was inconsistent. In the error case, msg may be set but then points to a
+ static string (which must not be deallocated).
+*/
+
+ /* advanced functions */
+
+/*
+ The following functions are needed only in some special applications.
+*/
+
+extern int deflateInit2 OF((z_stream *strm,
+ int level,
+ int method,
+ int windowBits,
+ int memLevel,
+ int strategy,
+ int minCompression));
+/*
+ This is another version of deflateInit with more compression options. The
+ fields next_in, zalloc and zfree must be initialized before by the caller.
+
+ The method parameter is the compression method. It must be 8 in this
+ version of the library. (Method 9 will allow a 64K history buffer and
+ partial block flushes.)
+
+ The windowBits parameter is the base two logarithm of the window size
+ (the size of the history buffer). It should be in the range 8..15 for this
+ version of the library (the value 16 will be allowed for method 9). Larger
+ values of this parameter result in better compression at the expense of
+ memory usage. The default value is 15 if deflateInit is used instead.
+
+ The memLevel parameter specifies how much memory should be allocated
+ for the internal compression state. memLevel=1 uses minimum memory but
+ is slow and reduces compression ratio; memLevel=9 uses maximum memory
+ for optimal speed. The default value is 8. See zconf.h for total memory
+ usage as a function of windowBits and memLevel.
+
+ The strategy parameter is used to tune the compression algorithm. Use
+ the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data
+ produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman
+ encoding only (no string match). Filtered data consists mostly of small
+ values with a somewhat random distribution. In this case, the
+ compression algorithm is tuned to compress them better. The strategy
+ parameter only affects the compression ratio but not the correctness of
+ the compressed output even if it is not set appropriately.
+
+ The minCompression parameter specifies the minimum reduction in size
+ required for a compressed block to be output when Z_PACKET_FLUSH is
+ used (see the description of deflate above).
+
+ If next_in is not null, the library will use this buffer to hold also
+ some history information; the buffer must either hold the entire input
+ data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in
+ is null, the library will allocate its own history buffer (and leave next_in
+ null). next_out need not be provided here but must be provided by the
+ application for the next call of deflate().
+
+ If the history buffer is provided by the application, next_in must
+ must never be changed by the application since the compressor maintains
+ information inside this buffer from call to call; the application
+ must provide more input only by increasing avail_in. next_in is always
+ reset by the library in this case.
+
+ deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
+ not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
+ an invalid method). msg is set to null if there is no error message.
+ deflateInit2 does not perform any compression: this will be done by
+ deflate().
+*/
+
+extern int deflateCopy OF((z_stream *dest,
+ z_stream *source));
+/*
+ Sets the destination stream as a complete copy of the source stream. If
+ the source stream is using an application-supplied history buffer, a new
+ buffer is allocated for the destination stream. The compressed output
+ buffer is always application-supplied. It's the responsibility of the
+ application to provide the correct values of next_out and avail_out for the
+ next call of deflate.
+
+ This function is useful when several compression strategies will be
+ tried, for example when there are several ways of pre-processing the input
+ data with a filter. The streams that will be discarded should then be freed
+ by calling deflateEnd. Note that deflateCopy duplicates the internal
+ compression state which can be quite large, so this strategy is slow and
+ can consume lots of memory.
+
+ deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+extern int deflateReset OF((z_stream *strm));
+/*
+ This function is equivalent to deflateEnd followed by deflateInit,
+ but does not free and reallocate all the internal compression state.
+ The stream will keep the same compression level and any other attributes
+ that may have been set by deflateInit2.
+
+ deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being NULL).
+*/
+
+extern int inflateInit2 OF((z_stream *strm,
+ int windowBits));
+/*
+ This is another version of inflateInit with more compression options. The
+ fields next_out, zalloc and zfree must be initialized before by the caller.
+
+ The windowBits parameter is the base two logarithm of the maximum window
+ size (the size of the history buffer). It should be in the range 8..15 for
+ this version of the library (the value 16 will be allowed soon). The
+ default value is 15 if inflateInit is used instead. If a compressed stream
+ with a larger window size is given as input, inflate() will return with
+ the error code Z_DATA_ERROR instead of trying to allocate a larger window.
+
+ If next_out is not null, the library will use this buffer for the history
+ buffer; the buffer must either be large enough to hold the entire output
+ data, or have at least 1<<windowBits bytes. If next_out is null, the
+ library will allocate its own buffer (and leave next_out null). next_in
+ need not be provided here but must be provided by the application for the
+ next call of inflate().
+
+ If the history buffer is provided by the application, next_out must
+ never be changed by the application since the decompressor maintains
+ history information inside this buffer from call to call; the application
+ can only reset next_out to the beginning of the history buffer when
+ avail_out is zero and all output has been consumed.
+
+ inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
+ not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
+ windowBits < 8). msg is set to null if there is no error message.
+ inflateInit2 does not perform any decompression: this will be done by
+ inflate().
+*/
+
+extern int inflateSync OF((z_stream *strm));
+/*
+ Skips invalid compressed data until the special marker (see deflate()
+ above) can be found, or until all available input is skipped. No output
+ is provided.
+
+ inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR
+ if no more input was provided, Z_DATA_ERROR if no marker has been found,
+ or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
+ case, the application may save the current current value of total_in which
+ indicates where valid compressed data was found. In the error case, the
+ application may repeatedly call inflateSync, providing more input each time,
+ until success or end of the input data.
+*/
+
+extern int inflateReset OF((z_stream *strm));
+/*
+ This function is equivalent to inflateEnd followed by inflateInit,
+ but does not free and reallocate all the internal decompression state.
+ The stream will keep attributes that may have been set by inflateInit2.
+
+ inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being NULL).
+*/
+
+extern int inflateIncomp OF((z_stream *strm));
+/*
+ This function adds the data at next_in (avail_in bytes) to the output
+ history without performing any output. There must be no pending output,
+ and the decompressor must be expecting to see the start of a block.
+ Calling this function is equivalent to decompressing a stored block
+ containing the data at next_in (except that the data is not output).
+*/
+
+ /* checksum functions */
+
+/*
+ This function is not related to compression but is exported
+ anyway because it might be useful in applications using the
+ compression library.
+*/
+
+extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len));
+
+/*
+ Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+ return the updated checksum. If buf is NULL, this function returns
+ the required initial value for the checksum.
+ An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ much faster. Usage example:
+
+ uLong adler = adler32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ adler = adler32(adler, buffer, length);
+ }
+ if (adler != original_adler) error();
+*/
+
+#ifndef _Z_UTIL_H
+ struct internal_state {int dummy;}; /* hack for buggy compilers */
+#endif
+
+#endif /* _ZLIB_H */
-/* $OpenBSD: hd_input.c,v 1.2 1996/03/04 07:36:22 niklas Exp $ */
-/* $NetBSD: hd_input.c,v 1.8 1996/02/13 22:04:27 christos Exp $ */
+/* $OpenBSD: hd_input.c,v 1.3 1996/04/21 22:28:52 deraadt Exp $ */
+/* $NetBSD: hd_input.c,v 1.9 1996/04/13 01:34:16 cgd Exp $ */
/*
* Copyright (c) University of British Columbia, 1984
if (hdp->hd_ifp == ifp)
break;
if (hdp == 0) {
- printf("hdintr: unknown interface %x\n",
- (unsigned int) ifp);
+ printf("hdintr: unknown interface %p\n", ifp);
m_freem(m);
continue;
}
-/* $OpenBSD: pk_subr.c,v 1.2 1996/03/04 07:36:44 niklas Exp $ */
-/* $NetBSD: pk_subr.c,v 1.11 1996/02/13 22:05:34 christos Exp $ */
+/* $OpenBSD: pk_subr.c,v 1.3 1996/04/21 22:28:53 deraadt Exp $ */
+/* $NetBSD: pk_subr.c,v 1.12 1996/03/30 21:54:33 christos Exp $ */
/*
* Copyright (c) University of British Columbia, 1984
#endif
{
va_list ap;
- static const char *rec = "%r\n";
if (lcn)
if (!PQEMPTY)
printf("X.25: ");
va_start(ap, fmt);
- printf(rec, fmt, ap);
+ printf("%:\n", fmt, ap);
va_end(ap);
}
if (m == 0)
return 0;
- if (m->m_flags & M_PKTHDR == 0)
+ if ((m->m_flags & M_PKTHDR) == 0)
panic("pk_fragment");
totlen = m->m_pkthdr.len;
m->m_act = 0;
--- /dev/null
+/* $NetBSD: if_arp.c,v 1.29 1996/03/30 21:53:19 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)if_ether.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Ethernet address resolution protocol.
+ * TODO:
+ * add "inuse/lock" bit (or ref. count) along with valid bit
+ */
+
+#ifdef INET
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/syslog.h>
+#include <sys/proc.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/route.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+
+#define SIN(s) ((struct sockaddr_in *)s)
+#define SDL(s) ((struct sockaddr_dl *)s)
+#define SRP(s) ((struct sockaddr_inarp *)s)
+
+/*
+ * ARP trailer negotiation. Trailer protocol is not IP specific,
+ * but ARP request/response use IP addresses.
+ */
+#define ETHERTYPE_IPTRAILERS ETHERTYPE_TRAIL
+
+/* timer values */
+int arpt_prune = (5*60*1); /* walk list every 5 minutes */
+int arpt_keep = (20*60); /* once resolved, good for 20 more minutes */
+int arpt_down = 20; /* once declared down, don't send for 20 secs */
+#define rt_expire rt_rmx.rmx_expire
+
+static void arprequest
+ __P((struct arpcom *, u_int32_t *, u_int32_t *, u_int8_t *));
+static void arptfree __P((struct llinfo_arp *));
+static void arptimer __P((void *));
+static struct llinfo_arp *arplookup __P((u_int32_t, int, int));
+static void in_arpinput __P((struct mbuf *));
+
+extern struct ifnet loif;
+LIST_HEAD(, llinfo_arp) llinfo_arp;
+struct ifqueue arpintrq = {0, 0, 0, 50};
+int arp_inuse, arp_allocated, arp_intimer;
+int arp_maxtries = 5;
+int useloopback = 1; /* use loopback interface for local traffic */
+int arpinit_done = 0;
+
+/* revarp state */
+static struct in_addr myip, srv_ip;
+static int myip_initialized = 0;
+static int revarp_in_progress = 0;
+static struct ifnet *myip_ifp = NULL;
+
+static void arptimer __P((void *));
+static void arprequest __P((struct arpcom *, u_int32_t *, u_int32_t *,
+ u_int8_t *));
+static void in_arpinput __P((struct mbuf *));
+static void arptfree __P((struct llinfo_arp *));
+static struct llinfo_arp *arplookup __P((u_int32_t, int, int ));
+#ifdef DDB
+static void db_print_sa __P((struct sockaddr *));
+static void db_print_ifa __P((struct ifaddr *));
+static void db_print_llinfo __P((caddr_t));
+static int db_show_radix_node __P((struct radix_node *, void *));
+#endif
+
+/*
+ * Timeout routine. Age arp_tab entries periodically.
+ */
+/* ARGSUSED */
+static void
+arptimer(arg)
+ void *arg;
+{
+ int s;
+ register struct llinfo_arp *la, *nla;
+
+ s = splsoftnet();
+ timeout(arptimer, NULL, arpt_prune * hz);
+ for (la = llinfo_arp.lh_first; la != 0; la = nla) {
+ register struct rtentry *rt = la->la_rt;
+
+ nla = la->la_list.le_next;
+ if (rt->rt_expire && rt->rt_expire <= time.tv_sec)
+ arptfree(la); /* timer has expired; clear */
+ }
+ splx(s);
+}
+
+/*
+ * Parallel to llc_rtrequest.
+ */
+void
+arp_rtrequest(req, rt, sa)
+ int req;
+ register struct rtentry *rt;
+ struct sockaddr *sa;
+{
+ register struct sockaddr *gate = rt->rt_gateway;
+ register struct llinfo_arp *la = (struct llinfo_arp *)rt->rt_llinfo;
+ static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
+
+ if (!arpinit_done) {
+ arpinit_done = 1;
+ /*
+ * We generate expiration times from time.tv_sec
+ * so avoid accidently creating permanent routes.
+ */
+ if (time.tv_sec == 0) {
+ time.tv_sec++;
+ }
+ timeout(arptimer, (caddr_t)0, hz);
+ }
+ if (rt->rt_flags & RTF_GATEWAY)
+ return;
+ switch (req) {
+
+ case RTM_ADD:
+ /*
+ * XXX: If this is a manually added route to interface
+ * such as older version of routed or gated might provide,
+ * restore cloning bit.
+ */
+ if ((rt->rt_flags & RTF_HOST) == 0 &&
+ SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
+ rt->rt_flags |= RTF_CLONING;
+ if (rt->rt_flags & RTF_CLONING) {
+ /*
+ * Case 1: This route should come from a route to iface.
+ */
+ rt_setgate(rt, rt_key(rt),
+ (struct sockaddr *)&null_sdl);
+ gate = rt->rt_gateway;
+ SDL(gate)->sdl_type = rt->rt_ifp->if_type;
+ SDL(gate)->sdl_index = rt->rt_ifp->if_index;
+ /*
+ * Give this route an expiration time, even though
+ * it's a "permanent" route, so that routes cloned
+ * from it do not need their expiration time set.
+ */
+ rt->rt_expire = time.tv_sec;
+ break;
+ }
+ /* Announce a new entry if requested. */
+ if (rt->rt_flags & RTF_ANNOUNCE)
+ arprequest((struct arpcom *)rt->rt_ifp,
+ &SIN(rt_key(rt))->sin_addr.s_addr,
+ &SIN(rt_key(rt))->sin_addr.s_addr,
+ (u_char *)LLADDR(SDL(gate)));
+ /*FALLTHROUGH*/
+ case RTM_RESOLVE:
+ if (gate->sa_family != AF_LINK ||
+ gate->sa_len < sizeof(null_sdl)) {
+ log(LOG_DEBUG, "arp_rtrequest: bad gateway value");
+ break;
+ }
+ SDL(gate)->sdl_type = rt->rt_ifp->if_type;
+ SDL(gate)->sdl_index = rt->rt_ifp->if_index;
+ if (la != 0)
+ break; /* This happens on a route change */
+ /*
+ * Case 2: This route may come from cloning, or a manual route
+ * add with a LL address.
+ */
+ R_Malloc(la, struct llinfo_arp *, sizeof(*la));
+ rt->rt_llinfo = (caddr_t)la;
+ if (la == 0) {
+ log(LOG_DEBUG, "arp_rtrequest: malloc failed\n");
+ break;
+ }
+ arp_inuse++, arp_allocated++;
+ Bzero(la, sizeof(*la));
+ la->la_rt = rt;
+ rt->rt_flags |= RTF_LLINFO;
+ LIST_INSERT_HEAD(&llinfo_arp, la, la_list);
+ if (SIN(rt_key(rt))->sin_addr.s_addr ==
+ (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) {
+ /*
+ * This test used to be
+ * if (loif.if_flags & IFF_UP)
+ * It allowed local traffic to be forced through
+ * the hardware by configuring the loopback down.
+ * However, it causes problems during network
+ * configuration for boards that can't receive
+ * packets they send. It is now necessary to clear
+ * "useloopback" and remove the route to force
+ * traffic out to the hardware.
+ */
+ rt->rt_expire = 0;
+ Bcopy(((struct arpcom *)rt->rt_ifp)->ac_enaddr,
+ LLADDR(SDL(gate)),
+ SDL(gate)->sdl_alen = ETHER_ADDR_LEN);
+ if (useloopback)
+ rt->rt_ifp = &loif;
+ }
+ break;
+
+ case RTM_DELETE:
+ if (la == 0)
+ break;
+ arp_inuse--;
+ LIST_REMOVE(la, la_list);
+ rt->rt_llinfo = 0;
+ rt->rt_flags &= ~RTF_LLINFO;
+ if (la->la_hold)
+ m_freem(la->la_hold);
+ Free((caddr_t)la);
+ }
+}
+
+/*
+ * Broadcast an ARP packet, asking who has addr on interface ac.
+ */
+void
+arpwhohas(ac, addr)
+ register struct arpcom *ac;
+ register struct in_addr *addr;
+{
+ arprequest(ac, &ac->ac_ipaddr.s_addr, &addr->s_addr, ac->ac_enaddr);
+}
+
+/*
+ * Broadcast an ARP request. Caller specifies:
+ * - arp header source ip address
+ * - arp header target ip address
+ * - arp header source ethernet address
+ */
+static void
+arprequest(ac, sip, tip, enaddr)
+ register struct arpcom *ac;
+ register u_int32_t *sip, *tip;
+ register u_int8_t *enaddr;
+{
+ register struct mbuf *m;
+ register struct ether_header *eh;
+ register struct ether_arp *ea;
+ struct sockaddr sa;
+
+ if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL)
+ return;
+ m->m_len = sizeof(*ea);
+ m->m_pkthdr.len = sizeof(*ea);
+ MH_ALIGN(m, sizeof(*ea));
+ ea = mtod(m, struct ether_arp *);
+ eh = (struct ether_header *)sa.sa_data;
+ bzero((caddr_t)ea, sizeof (*ea));
+ bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
+ sizeof(eh->ether_dhost));
+ eh->ether_type = htons(ETHERTYPE_ARP); /* if_output will not swap */
+ ea->arp_hrd = htons(ARPHRD_ETHER);
+ ea->arp_pro = htons(ETHERTYPE_IP);
+ ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
+ ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */
+ ea->arp_op = htons(ARPOP_REQUEST);
+ bcopy((caddr_t)enaddr, (caddr_t)ea->arp_sha, sizeof(ea->arp_sha));
+ bcopy((caddr_t)sip, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
+ bcopy((caddr_t)tip, (caddr_t)ea->arp_tpa, sizeof(ea->arp_tpa));
+ sa.sa_family = AF_UNSPEC;
+ sa.sa_len = sizeof(sa);
+ (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
+}
+
+/*
+ * Resolve an IP address into an ethernet address. If success,
+ * desten is filled in. If there is no entry in arptab,
+ * set one up and broadcast a request for the IP address.
+ * Hold onto this mbuf and resend it once the address
+ * is finally resolved. A return value of 1 indicates
+ * that desten has been filled in and the packet should be sent
+ * normally; a 0 return indicates that the packet has been
+ * taken over here, either now or for later transmission.
+ */
+int
+arpresolve(ac, rt, m, dst, desten)
+ register struct arpcom *ac;
+ register struct rtentry *rt;
+ struct mbuf *m;
+ register struct sockaddr *dst;
+ register u_char *desten;
+{
+ register struct llinfo_arp *la;
+ struct sockaddr_dl *sdl;
+
+ if (m->m_flags & M_BCAST) { /* broadcast */
+ bcopy((caddr_t)etherbroadcastaddr, (caddr_t)desten,
+ sizeof(etherbroadcastaddr));
+ return (1);
+ }
+ if (m->m_flags & M_MCAST) { /* multicast */
+ ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten);
+ return (1);
+ }
+ if (rt)
+ la = (struct llinfo_arp *)rt->rt_llinfo;
+ else {
+ if ((la = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0)) != NULL)
+ rt = la->la_rt;
+ }
+ if (la == 0 || rt == 0) {
+ log(LOG_DEBUG, "arpresolve: can't allocate llinfo");
+ m_freem(m);
+ return (0);
+ }
+ sdl = SDL(rt->rt_gateway);
+ /*
+ * Check the address family and length is valid, the address
+ * is resolved; otherwise, try to resolve.
+ */
+ if ((rt->rt_expire == 0 || rt->rt_expire > time.tv_sec) &&
+ sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
+ bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
+ return 1;
+ }
+ /*
+ * There is an arptab entry, but no ethernet address
+ * response yet. Replace the held mbuf with this
+ * latest one.
+ */
+ if (la->la_hold)
+ m_freem(la->la_hold);
+ la->la_hold = m;
+ /*
+ * Re-send the ARP request when appropriate.
+ */
+#ifdef DIAGNOSTIC
+ if (rt->rt_expire == 0) {
+ /* This should never happen. (Should it? -gwr) */
+ printf("arpresolve: unresolved and rt_expire == 0\n");
+ /* Set expiration time to now (expired). */
+ rt->rt_expire = time.tv_sec;
+ }
+#endif
+ if (rt->rt_expire) {
+ rt->rt_flags &= ~RTF_REJECT;
+ if (la->la_asked == 0 || rt->rt_expire != time.tv_sec) {
+ rt->rt_expire = time.tv_sec;
+ if (la->la_asked++ < arp_maxtries)
+ arpwhohas(ac, &(SIN(dst)->sin_addr));
+ else {
+ rt->rt_flags |= RTF_REJECT;
+ rt->rt_expire += arpt_down;
+ la->la_asked = 0;
+ }
+ }
+ }
+ return (0);
+}
+
+/*
+ * Common length and type checks are done here,
+ * then the protocol-specific routine is called.
+ */
+void
+arpintr()
+{
+ register struct mbuf *m;
+ register struct arphdr *ar;
+ int s;
+
+ while (arpintrq.ifq_head) {
+ s = splimp();
+ IF_DEQUEUE(&arpintrq, m);
+ splx(s);
+ if (m == 0 || (m->m_flags & M_PKTHDR) == 0)
+ panic("arpintr");
+ if (m->m_len >= sizeof(struct arphdr) &&
+ (ar = mtod(m, struct arphdr *)) &&
+ ntohs(ar->ar_hrd) == ARPHRD_ETHER &&
+ m->m_len >=
+ sizeof(struct arphdr) + 2 * (ar->ar_hln + ar->ar_pln))
+ switch (ntohs(ar->ar_pro)) {
+
+ case ETHERTYPE_IP:
+ case ETHERTYPE_IPTRAILERS:
+ in_arpinput(m);
+ continue;
+ }
+ m_freem(m);
+ }
+}
+
+/*
+ * ARP for Internet protocols on 10 Mb/s Ethernet.
+ * Algorithm is that given in RFC 826.
+ * In addition, a sanity check is performed on the sender
+ * protocol address, to catch impersonators.
+ * We no longer handle negotiations for use of trailer protocol:
+ * Formerly, ARP replied for protocol type ETHERTYPE_TRAIL sent
+ * along with IP replies if we wanted trailers sent to us,
+ * and also sent them in response to IP replies.
+ * This allowed either end to announce the desire to receive
+ * trailer packets.
+ * We no longer reply to requests for ETHERTYPE_TRAIL protocol either,
+ * but formerly didn't normally send requests.
+ */
+static void
+in_arpinput(m)
+ struct mbuf *m;
+{
+ register struct ether_arp *ea;
+ register struct arpcom *ac = (struct arpcom *)m->m_pkthdr.rcvif;
+ struct ether_header *eh;
+ register struct llinfo_arp *la = 0;
+ register struct rtentry *rt;
+ struct in_ifaddr *ia, *maybe_ia = 0;
+ struct sockaddr_dl *sdl;
+ struct sockaddr sa;
+ struct in_addr isaddr, itaddr, myaddr;
+ int op;
+
+ ea = mtod(m, struct ether_arp *);
+ op = ntohs(ea->arp_op);
+ bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof (isaddr));
+ bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof (itaddr));
+ for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
+ if (ia->ia_ifp == &ac->ac_if) {
+ maybe_ia = ia;
+ if (itaddr.s_addr == ia->ia_addr.sin_addr.s_addr ||
+ isaddr.s_addr == ia->ia_addr.sin_addr.s_addr)
+ break;
+ }
+ if (maybe_ia == 0)
+ goto out;
+ myaddr = ia ? ia->ia_addr.sin_addr : maybe_ia->ia_addr.sin_addr;
+ if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)ac->ac_enaddr,
+ sizeof (ea->arp_sha)))
+ goto out; /* it's from me, ignore it. */
+ if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr,
+ sizeof (ea->arp_sha))) {
+ log(LOG_ERR,
+ "arp: ether address is broadcast for IP address %x!\n",
+ ntohl(isaddr.s_addr));
+ goto out;
+ }
+ if (isaddr.s_addr == myaddr.s_addr) {
+ log(LOG_ERR,
+ "duplicate IP address %08x sent from ethernet address %s\n",
+ ntohl(isaddr.s_addr), ether_sprintf(ea->arp_sha));
+ itaddr = myaddr;
+ goto reply;
+ }
+ la = arplookup(isaddr.s_addr, itaddr.s_addr == myaddr.s_addr, 0);
+ if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) {
+ if (sdl->sdl_alen &&
+ bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen))
+ log(LOG_INFO, "arp info overwritten for %08x by %s\n",
+ ntohl(isaddr.s_addr), ether_sprintf(ea->arp_sha));
+ bcopy((caddr_t)ea->arp_sha, LLADDR(sdl),
+ sdl->sdl_alen = sizeof(ea->arp_sha));
+ if (rt->rt_expire)
+ rt->rt_expire = time.tv_sec + arpt_keep;
+ rt->rt_flags &= ~RTF_REJECT;
+ la->la_asked = 0;
+ if (la->la_hold) {
+ (*ac->ac_if.if_output)(&ac->ac_if, la->la_hold,
+ rt_key(rt), rt);
+ la->la_hold = 0;
+ }
+ }
+reply:
+ if (op != ARPOP_REQUEST) {
+ out:
+ m_freem(m);
+ return;
+ }
+ if (itaddr.s_addr == myaddr.s_addr) {
+ /* I am the target */
+ bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
+ sizeof(ea->arp_sha));
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
+ sizeof(ea->arp_sha));
+ } else {
+ la = arplookup(itaddr.s_addr, 0, SIN_PROXY);
+ if (la == 0)
+ goto out;
+ rt = la->la_rt;
+ bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
+ sizeof(ea->arp_sha));
+ sdl = SDL(rt->rt_gateway);
+ bcopy(LLADDR(sdl), (caddr_t)ea->arp_sha, sizeof(ea->arp_sha));
+ }
+
+ bcopy((caddr_t)ea->arp_spa, (caddr_t)ea->arp_tpa, sizeof(ea->arp_spa));
+ bcopy((caddr_t)&itaddr, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
+ ea->arp_op = htons(ARPOP_REPLY);
+ ea->arp_pro = htons(ETHERTYPE_IP); /* let's be sure! */
+ eh = (struct ether_header *)sa.sa_data;
+ bcopy((caddr_t)ea->arp_tha, (caddr_t)eh->ether_dhost,
+ sizeof(eh->ether_dhost));
+ eh->ether_type = htons(ETHERTYPE_ARP);
+ sa.sa_family = AF_UNSPEC;
+ sa.sa_len = sizeof(sa);
+ (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
+ return;
+}
+
+/*
+ * Free an arp entry.
+ */
+static void
+arptfree(la)
+ register struct llinfo_arp *la;
+{
+ register struct rtentry *rt = la->la_rt;
+ register struct sockaddr_dl *sdl;
+
+ if (rt == 0)
+ panic("arptfree");
+ if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) &&
+ sdl->sdl_family == AF_LINK) {
+ sdl->sdl_alen = 0;
+ la->la_asked = 0;
+ rt->rt_flags &= ~RTF_REJECT;
+ return;
+ }
+ rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt),
+ 0, (struct rtentry **)0);
+}
+
+/*
+ * Lookup or enter a new address in arptab.
+ */
+static struct llinfo_arp *
+arplookup(addr, create, proxy)
+ u_int32_t addr;
+ int create, proxy;
+{
+ register struct rtentry *rt;
+ static struct sockaddr_inarp sin;
+
+ sin.sin_len = sizeof(sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = addr;
+ sin.sin_other = proxy ? SIN_PROXY : 0;
+ rt = rtalloc1(sintosa(&sin), create);
+ if (rt == 0)
+ return (0);
+ rt->rt_refcnt--;
+ if ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 ||
+ rt->rt_gateway->sa_family != AF_LINK) {
+ if (create)
+ log(LOG_DEBUG, "arplookup: unable to enter address for %x\n", ntohl(addr));
+ return (0);
+ }
+ return ((struct llinfo_arp *)rt->rt_llinfo);
+}
+
+int
+arpioctl(cmd, data)
+ u_long cmd;
+ caddr_t data;
+{
+
+ return (EOPNOTSUPP);
+}
+
+void
+arp_ifinit(ac, ifa)
+ struct arpcom *ac;
+ struct ifaddr *ifa;
+{
+
+ ac->ac_ipaddr = IA_SIN(ifa)->sin_addr;
+ /* Warn the user if another station has this IP address. */
+ arpwhohas(ac, &ac->ac_ipaddr);
+ ifa->ifa_rtrequest = arp_rtrequest;
+ ifa->ifa_flags |= RTF_CLONING;
+}
+
+/*
+ * Called from 10 Mb/s Ethernet interrupt handlers
+ * when ether packet type ETHERTYPE_REVARP
+ * is received. Common length and type checks are done here,
+ * then the protocol-specific routine is called.
+ */
+void
+revarpinput(m)
+ struct mbuf *m;
+{
+ struct arphdr *ar;
+
+ if (m->m_len < sizeof(struct arphdr))
+ goto out;
+ ar = mtod(m, struct arphdr *);
+ if (ntohs(ar->ar_hrd) != ARPHRD_ETHER)
+ goto out;
+ if (m->m_len < sizeof(struct arphdr) + 2 * (ar->ar_hln + ar->ar_pln))
+ goto out;
+ switch (ntohs(ar->ar_pro)) {
+
+ case ETHERTYPE_IP:
+ case ETHERTYPE_IPTRAILERS:
+ in_revarpinput(m);
+ return;
+
+ default:
+ break;
+ }
+out:
+ m_freem(m);
+}
+
+/*
+ * RARP for Internet protocols on 10 Mb/s Ethernet.
+ * Algorithm is that given in RFC 903.
+ * We are only using for bootstrap purposes to get an ip address for one of
+ * our interfaces. Thus we support no user-interface.
+ *
+ * Since the contents of the RARP reply are specific to the interface that
+ * sent the request, this code must ensure that they are properly associated.
+ *
+ * Note: also supports ARP via RARP packets, per the RFC.
+ */
+void
+in_revarpinput(m)
+ struct mbuf *m;
+{
+ struct ifnet *ifp;
+ struct ether_arp *ar;
+ int op;
+
+ ar = mtod(m, struct ether_arp *);
+ op = ntohs(ar->arp_op);
+ switch (op) {
+ case ARPOP_REQUEST:
+ case ARPOP_REPLY: /* per RFC */
+ in_arpinput(m);
+ return;
+ case ARPOP_REVREPLY:
+ break;
+ case ARPOP_REVREQUEST: /* handled by rarpd(8) */
+ default:
+ goto out;
+ }
+ if (!revarp_in_progress)
+ goto out;
+ ifp = m->m_pkthdr.rcvif;
+ if (ifp != myip_ifp) /* !same interface */
+ goto out;
+ if (myip_initialized)
+ goto wake;
+ if (bcmp(ar->arp_tha, ((struct arpcom *)ifp)->ac_enaddr,
+ sizeof(ar->arp_tha)))
+ goto out;
+ bcopy((caddr_t)ar->arp_spa, (caddr_t)&srv_ip, sizeof(srv_ip));
+ bcopy((caddr_t)ar->arp_tpa, (caddr_t)&myip, sizeof(myip));
+ myip_initialized = 1;
+wake: /* Do wakeup every time in case it was missed. */
+ wakeup((caddr_t)&myip);
+
+out:
+ m_freem(m);
+}
+
+/*
+ * Send a RARP request for the ip address of the specified interface.
+ * The request should be RFC 903-compliant.
+ */
+void
+revarprequest(ifp)
+ struct ifnet *ifp;
+{
+ struct sockaddr sa;
+ struct mbuf *m;
+ struct ether_header *eh;
+ struct ether_arp *ea;
+ struct arpcom *ac = (struct arpcom *)ifp;
+
+ if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL)
+ return;
+ m->m_len = sizeof(*ea);
+ m->m_pkthdr.len = sizeof(*ea);
+ MH_ALIGN(m, sizeof(*ea));
+ ea = mtod(m, struct ether_arp *);
+ eh = (struct ether_header *)sa.sa_data;
+ bzero((caddr_t)ea, sizeof(*ea));
+ bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
+ sizeof(eh->ether_dhost));
+ eh->ether_type = htons(ETHERTYPE_REVARP);
+ ea->arp_hrd = htons(ARPHRD_ETHER);
+ ea->arp_pro = htons(ETHERTYPE_IP);
+ ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
+ ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */
+ ea->arp_op = htons(ARPOP_REVREQUEST);
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
+ sizeof(ea->arp_sha));
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_tha,
+ sizeof(ea->arp_tha));
+ sa.sa_family = AF_UNSPEC;
+ sa.sa_len = sizeof(sa);
+ ifp->if_output(ifp, m, &sa, (struct rtentry *)0);
+}
+
+/*
+ * RARP for the ip address of the specified interface, but also
+ * save the ip address of the server that sent the answer.
+ * Timeout if no response is received.
+ */
+int
+revarpwhoarewe(ifp, serv_in, clnt_in)
+ struct ifnet *ifp;
+ struct in_addr *serv_in;
+ struct in_addr *clnt_in;
+{
+ int result, count = 20;
+
+ if (myip_initialized)
+ return EIO;
+
+ myip_ifp = ifp;
+ revarp_in_progress = 1;
+ while (count--) {
+ revarprequest(ifp);
+ result = tsleep((caddr_t)&myip, PSOCK, "revarp", hz/2);
+ if (result != EWOULDBLOCK)
+ break;
+ }
+ revarp_in_progress = 0;
+ if (!myip_initialized)
+ return ENETUNREACH;
+
+ bcopy((caddr_t)&srv_ip, serv_in, sizeof(*serv_in));
+ bcopy((caddr_t)&myip, clnt_in, sizeof(*clnt_in));
+ return 0;
+}
+
+/* For compatibility: only saves interface address. */
+int
+revarpwhoami(in, ifp)
+ struct in_addr *in;
+ struct ifnet *ifp;
+{
+ struct in_addr server;
+ return (revarpwhoarewe(ifp, &server, in));
+}
+\f
+
+#ifdef DDB
+
+#include <machine/db_machdep.h>
+#include <ddb/db_interface.h>
+#include <ddb/db_output.h>
+static void
+db_print_sa(sa)
+ struct sockaddr *sa;
+{
+ int len;
+ u_char *p;
+
+ if (sa == 0) {
+ db_printf("[NULL]");
+ return;
+ }
+
+ p = (u_char*)sa;
+ len = sa->sa_len;
+ db_printf("[");
+ while (len > 0) {
+ db_printf("%d", *p);
+ p++; len--;
+ if (len) db_printf(",");
+ }
+ db_printf("]\n");
+}
+static void
+db_print_ifa(ifa)
+ struct ifaddr *ifa;
+{
+ if (ifa == 0)
+ return;
+ db_printf(" ifa_addr=");
+ db_print_sa(ifa->ifa_addr);
+ db_printf(" ifa_dsta=");
+ db_print_sa(ifa->ifa_dstaddr);
+ db_printf(" ifa_mask=");
+ db_print_sa(ifa->ifa_netmask);
+ db_printf(" flags=0x%x,refcnt=%d,metric=%d\n",
+ ifa->ifa_flags,
+ ifa->ifa_refcnt,
+ ifa->ifa_metric);
+}
+static void
+db_print_llinfo(li)
+ caddr_t li;
+{
+ struct llinfo_arp *la;
+
+ if (li == 0)
+ return;
+ la = (struct llinfo_arp *)li;
+ db_printf(" la_rt=%p la_hold=%p, la_asked=0x%lx\n",
+ la->la_rt, la->la_hold, la->la_asked);
+}
+/*
+ * Function to pass to rn_walktree().
+ * Return non-zero error to abort walk.
+ */
+static int
+db_show_radix_node(rn, w)
+ struct radix_node *rn;
+ void *w;
+{
+ struct rtentry *rt = (struct rtentry *)rn;
+
+ db_printf("rtentry=%p", rt);
+
+ db_printf(" flags=0x%x refcnt=%d use=%ld expire=%ld\n",
+ rt->rt_flags, rt->rt_refcnt,
+ rt->rt_use, rt->rt_expire);
+
+ db_printf(" key="); db_print_sa(rt_key(rt));
+ db_printf(" mask="); db_print_sa(rt_mask(rt));
+ db_printf(" gw="); db_print_sa(rt->rt_gateway);
+
+ db_printf(" ifp=%p ", rt->rt_ifp);
+ if (rt->rt_ifp)
+ db_printf("(%s%d)",
+ rt->rt_ifp->if_name,
+ rt->rt_ifp->if_unit);
+ else
+ db_printf("(NULL)");
+
+ db_printf(" ifa=%p\n", rt->rt_ifa);
+ db_print_ifa(rt->rt_ifa);
+
+ db_printf(" genmask="); db_print_sa(rt->rt_genmask);
+
+ db_printf(" gwroute=%p llinfo=%p\n",
+ rt->rt_gwroute, rt->rt_llinfo);
+ db_print_llinfo(rt->rt_llinfo);
+
+ return (0);
+}
+/*
+ * Function to print all the route trees.
+ * Use this from ddb: "call db_show_arptab"
+ */
+int
+db_show_arptab()
+{
+ struct radix_node_head *rnh;
+ rnh = rt_tables[AF_INET];
+ db_printf("Route tree for AF_INET\n");
+ if (rnh == NULL) {
+ db_printf(" (not initialized)\n");
+ return (0);
+ }
+ rn_walktree(rnh, db_show_radix_node, NULL);
+ return (0);
+}
+#endif
+#endif /* INET */
--- /dev/null
+/* $NetBSD: if_arp.h,v 1.21 1996/02/13 23:41:17 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)if_ether.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Ethernet address - 6 octets
+ * this is only used by the ethers(3) functions.
+ */
+struct ether_addr {
+ u_int8_t ether_addr_octet[6];
+};
+
+/*
+ * Structure of a 10Mb/s Ethernet header.
+ */
+#define ETHER_ADDR_LEN 6
+
+struct ether_header {
+ u_int8_t ether_dhost[ETHER_ADDR_LEN];
+ u_int8_t ether_shost[ETHER_ADDR_LEN];
+ u_int16_t ether_type;
+};
+
+#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
+#define ETHERTYPE_IP 0x0800 /* IP protocol */
+#define ETHERTYPE_ARP 0x0806 /* address resolution protocol */
+#define ETHERTYPE_REVARP 0x8035 /* reverse addr resolution protocol */
+
+/*
+ * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
+ * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
+ * by an ETHER type (as given above) and then the (variable-length) header.
+ */
+#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
+#define ETHERTYPE_NTRAILER 16
+
+#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
+
+#define ETHERMTU 1500
+#define ETHERMIN (60-14)
+
+#ifdef _KERNEL
+/*
+ * Macro to map an IP multicast address to an Ethernet multicast address.
+ * The high-order 25 bits of the Ethernet address are statically assigned,
+ * and the low-order 23 bits are taken from the low end of the IP address.
+ */
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
+ /* struct in_addr *ipaddr; */ \
+ /* u_int8_t enaddr[ETHER_ADDR_LEN]; */ \
+{ \
+ (enaddr)[0] = 0x01; \
+ (enaddr)[1] = 0x00; \
+ (enaddr)[2] = 0x5e; \
+ (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \
+ (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \
+ (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \
+}
+#endif
+
+/*
+ * Ethernet Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. Structure below is adapted
+ * to resolving internet addresses. Field names used correspond to
+ * RFC 826.
+ */
+struct ether_arp {
+ struct arphdr ea_hdr; /* fixed-size header */
+ u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
+ u_int8_t arp_spa[4]; /* sender protocol address */
+ u_int8_t arp_tha[ETHER_ADDR_LEN]; /* target hardware address */
+ u_int8_t arp_tpa[4]; /* target protocol address */
+};
+#define arp_hrd ea_hdr.ar_hrd
+#define arp_pro ea_hdr.ar_pro
+#define arp_hln ea_hdr.ar_hln
+#define arp_pln ea_hdr.ar_pln
+#define arp_op ea_hdr.ar_op
+
+/*
+ * Structure shared between the ethernet driver modules and
+ * the address resolution code. For example, each ec_softc or il_softc
+ * begins with this structure.
+ */
+struct arpcom {
+ struct ifnet ac_if; /* network-visible interface */
+ u_int8_t ac_enaddr[ETHER_ADDR_LEN]; /* ethernet hardware address */
+ struct in_addr ac_ipaddr; /* copy of ip address- XXX */
+ LIST_HEAD(, ether_multi) ac_multiaddrs; /* list of ether multicast addrs */
+ int ac_multicnt; /* length of ac_multiaddrs list */
+};
+
+struct llinfo_arp {
+ LIST_ENTRY(llinfo_arp) la_list;
+ struct rtentry *la_rt;
+ struct mbuf *la_hold; /* last packet until resolved/timeout */
+ long la_asked; /* last time we QUERIED for this addr */
+#define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */
+};
+
+struct sockaddr_inarp {
+ u_int8_t sin_len;
+ u_int8_t sin_family;
+ u_int16_t sin_port;
+ struct in_addr sin_addr;
+ struct in_addr sin_srcaddr;
+ u_int16_t sin_tos;
+ u_int16_t sin_other;
+#define SIN_PROXY 1
+};
+
+/*
+ * IP and ethernet specific routing flags
+ */
+#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */
+#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */
+
+#ifdef _KERNEL
+u_int8_t etherbroadcastaddr[ETHER_ADDR_LEN];
+u_int8_t ether_ipmulticast_min[ETHER_ADDR_LEN];
+u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
+struct ifqueue arpintrq;
+
+void arpwhohas __P((struct arpcom *, struct in_addr *));
+void arpintr __P((void));
+int arpresolve __P((struct arpcom *,
+ struct rtentry *, struct mbuf *, struct sockaddr *, u_char *));
+void arp_ifinit __P((struct arpcom *, struct ifaddr *));
+void arp_rtrequest __P((int, struct rtentry *, struct sockaddr *));
+
+int ether_addmulti __P((struct ifreq *, struct arpcom *));
+int ether_delmulti __P((struct ifreq *, struct arpcom *));
+#endif /* _KERNEL */
+
+/*
+ * Ethernet multicast address structure. There is one of these for each
+ * multicast address or range of multicast addresses that we are supposed
+ * to listen to on a particular interface. They are kept in a linked list,
+ * rooted in the interface's arpcom structure. (This really has nothing to
+ * do with ARP, or with the Internet address family, but this appears to be
+ * the minimally-disrupting place to put it.)
+ */
+struct ether_multi {
+ u_int8_t enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */
+ u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
+ struct arpcom *enm_ac; /* back pointer to arpcom */
+ u_int enm_refcount; /* no. claims to this addr/range */
+ LIST_ENTRY(ether_multi) enm_list;
+};
+
+/*
+ * Structure used by macros below to remember position when stepping through
+ * all of the ether_multi records.
+ */
+struct ether_multistep {
+ struct ether_multi *e_enm;
+};
+
+/*
+ * Macro for looking up the ether_multi record for a given range of Ethernet
+ * multicast addresses connected to a given arpcom structure. If no matching
+ * record is found, "enm" returns NULL.
+ */
+#define ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm) \
+ /* u_int8_t addrlo[ETHER_ADDR_LEN]; */ \
+ /* u_int8_t addrhi[ETHER_ADDR_LEN]; */ \
+ /* struct arpcom *ac; */ \
+ /* struct ether_multi *enm; */ \
+{ \
+ for ((enm) = (ac)->ac_multiaddrs.lh_first; \
+ (enm) != NULL && \
+ (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \
+ bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
+ (enm) = (enm)->enm_list.le_next); \
+}
+
+/*
+ * Macro to step through all of the ether_multi records, one at a time.
+ * The current position is remembered in "step", which the caller must
+ * provide. ETHER_FIRST_MULTI(), below, must be called to initialize "step"
+ * and get the first record. Both macros return a NULL "enm" when there
+ * are no remaining records.
+ */
+#define ETHER_NEXT_MULTI(step, enm) \
+ /* struct ether_multistep step; */ \
+ /* struct ether_multi *enm; */ \
+{ \
+ if (((enm) = (step).e_enm) != NULL) \
+ (step).e_enm = (enm)->enm_list.le_next; \
+}
+
+#define ETHER_FIRST_MULTI(step, ac, enm) \
+ /* struct ether_multistep step; */ \
+ /* struct arpcom *ac; */ \
+ /* struct ether_multi *enm; */ \
+{ \
+ (step).e_enm = (ac)->ac_multiaddrs.lh_first; \
+ ETHER_NEXT_MULTI((step), (enm)); \
+}
+
+#ifdef _KERNEL
+
+void arp_rtrequest __P((int, struct rtentry *, struct sockaddr *));
+void arpwhohas __P((struct arpcom *, struct in_addr *));
+int arpresolve __P((struct arpcom *, struct rtentry *, struct mbuf *,
+ struct sockaddr *, u_char *));
+void arpintr __P((void));
+int arpioctl __P((u_long, caddr_t));
+void arp_ifinit __P((struct arpcom *, struct ifaddr *));
+void revarpinput __P((struct mbuf *));
+void in_revarpinput __P((struct mbuf *));
+void revarprequest __P((struct ifnet *));
+int revarpwhoarewe __P((struct ifnet *, struct in_addr *, struct in_addr *));
+int revarpwhoami __P((struct in_addr *, struct ifnet *));
+int db_show_arptab __P((void));
+
+#endif
-/* $OpenBSD: if_ether.c,v 1.4 1996/03/03 22:30:24 niklas Exp $ */
-/* $NetBSD: if_ether.c,v 1.28 1996/02/13 23:40:59 christos Exp $ */
+/* $OpenBSD: if_ether.c,v 1.5 1996/04/21 22:28:58 deraadt Exp $ */
+/* $NetBSD: if_ether.c,v 1.29 1996/03/30 21:53:19 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
if (li == 0)
return;
la = (struct llinfo_arp *)li;
- db_printf(" la_rt=0x%x la_hold=0x%x, la_asked=0x%x\n",
+ db_printf(" la_rt=%p la_hold=%p, la_asked=0x%lx\n",
la->la_rt, la->la_hold, la->la_asked);
}
/*
{
struct rtentry *rt = (struct rtentry *)rn;
- db_printf("rtentry=0x%x", rt);
+ db_printf("rtentry=%p", rt);
- db_printf(" flags=0x%x refcnt=%d use=%d expire=%d\n",
+ db_printf(" flags=0x%x refcnt=%d use=%ld expire=%ld\n",
rt->rt_flags, rt->rt_refcnt,
rt->rt_use, rt->rt_expire);
db_printf(" mask="); db_print_sa(rt_mask(rt));
db_printf(" gw="); db_print_sa(rt->rt_gateway);
- db_printf(" ifp=0x%lx ", rt->rt_ifp);
+ db_printf(" ifp=%p ", rt->rt_ifp);
if (rt->rt_ifp)
db_printf("(%s%d)",
rt->rt_ifp->if_name,
else
db_printf("(NULL)");
- db_printf(" ifa=0x%lx\n", rt->rt_ifa);
+ db_printf(" ifa=%p\n", rt->rt_ifa);
db_print_ifa(rt->rt_ifa);
db_printf(" genmask="); db_print_sa(rt->rt_genmask);
- db_printf(" gwroute=0x%x llinfo=0x%x\n",
+ db_printf(" gwroute=%p llinfo=%p\n",
rt->rt_gwroute, rt->rt_llinfo);
db_print_llinfo(rt->rt_llinfo);
-/* $NetBSD: in_cksum.c,v 1.10 1995/04/13 06:27:51 cgd Exp $ */
+/* $NetBSD: in_cksum.c,v 1.11 1996/04/08 19:55:37 jonathan Exp $ */
/*
* Copyright (c) 1988, 1992, 1993
#include <sys/param.h>
#include <sys/mbuf.h>
+#include <sys/systm.h>
+#include <netinet/in.h>
/*
* Checksum routine for Internet Protocol family headers (Portable Version).
-/* $OpenBSD: ip_input.c,v 1.10 1996/03/09 21:30:22 dm Exp $ */
-/* $NetBSD: ip_input.c,v 1.28 1996/02/13 23:42:37 christos Exp $ */
+/* $OpenBSD: ip_input.c,v 1.11 1996/04/21 22:29:00 deraadt Exp $ */
+/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
*(mtod(m, struct in_addr *)) = *p--;
#ifdef DIAGNOSTIC
if (ipprintfs)
- printf(" hops %lx", ntohl(mtod(m, struct in_addr *)->s_addr));
+ printf(" hops %x", ntohl(mtod(m, struct in_addr *)->s_addr));
#endif
/*
while (p >= ip_srcrt.route) {
#ifdef DIAGNOSTIC
if (ipprintfs)
- printf(" %lx", ntohl(q->s_addr));
+ printf(" %x", ntohl(q->s_addr));
#endif
*q++ = *p--;
}
*q = ip_srcrt.dst;
#ifdef DIAGNOSTIC
if (ipprintfs)
- printf(" %lx\n", ntohl(q->s_addr));
+ printf(" %x\n", ntohl(q->s_addr));
#endif
return (m);
}
-/* $OpenBSD: ip_mroute.c,v 1.2 1996/03/03 22:30:39 niklas Exp $ */
-/* $NetBSD: ip_mroute.c,v 1.25 1996/02/13 23:42:46 christos Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.3 1996/04/21 22:29:02 deraadt Exp $ */
+/* $NetBSD: ip_mroute.c,v 1.26 1996/03/16 23:54:00 christos Exp $ */
/*
* IP multicast forwarding procedures
rt->mfc_mcastgrp.s_addr == mfccp->mfcc_mcastgrp.s_addr &&
rt->mfc_stall != NULL) {
if (nstl++)
- log(LOG_ERR, "add_mfc %s o %x g %x p %x dbx %x",
+ log(LOG_ERR, "add_mfc %s o %x g %x p %x dbx %p",
"multiple kernel entries",
ntohl(mfccp->mfcc_origin.s_addr),
ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent, rt->mfc_stall);
if (mrtdebug & DEBUG_MFC)
- log(LOG_DEBUG,"add_mfc o %x g %x p %x dbg %x",
+ log(LOG_DEBUG,"add_mfc o %x g %x p %x dbg %p",
ntohl(mfccp->mfcc_origin.s_addr),
ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent, rt->mfc_stall);
#endif /* RSVP_ISI */
if (mrtdebug & DEBUG_FORWARD)
- log(LOG_DEBUG, "ip_mforward: src %x, dst %x, ifp %x",
+ log(LOG_DEBUG, "ip_mforward: src %x, dst %x, ifp %p",
ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr), ifp);
if (ip->ip_hl < (IP_HDR_LEN + TUNNEL_LEN) >> 2 ||
if ((vifi >= numvifs) || (viftable[vifi].v_ifp != ifp)) {
/* came in the wrong interface */
if (mrtdebug & DEBUG_FORWARD)
- log(LOG_DEBUG, "wrong if: ifp %x vifi %d vififp %x",
+ log(LOG_DEBUG, "wrong if: ifp %p vifi %d vififp %p",
ifp, vifi, viftable[vifi].v_ifp);
++mrtstat.mrts_wrong_if;
++rt->mfc_wrong_if;
-/* $OpenBSD: udp_usrreq.c,v 1.3 1996/03/03 22:30:51 niklas Exp $ */
-/* $NetBSD: udp_usrreq.c,v 1.27 1996/02/13 23:44:32 christos Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.4 1996/04/21 22:29:03 deraadt Exp $ */
+/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
* port. It * assumes that an application will never
* clear these options after setting them.
*/
- if ((last->so_options&(SO_REUSEPORT|SO_REUSEADDR) == 0))
+ if ((last->so_options&(SO_REUSEPORT|SO_REUSEADDR)) == 0)
break;
}
-/* $OpenBSD: clnp_er.c,v 1.2 1996/03/04 10:34:48 mickey Exp $ */
-/* $NetBSD: clnp_er.c,v 1.7 1996/02/13 22:08:17 christos Exp $ */
+/* $OpenBSD: clnp_er.c,v 1.3 1996/04/21 22:29:08 deraadt Exp $ */
+/* $NetBSD: clnp_er.c,v 1.8 1996/04/13 01:34:20 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_CTLINPUT]) {
- printf("clnp_er_input: m x%x, src %s, reason x%x\n",
- (unsigned int) m, clnp_iso_addrp(src), reason);
+ printf("clnp_er_input: m %p, src %s, reason x%x\n",
+ m, clnp_iso_addrp(src), reason);
}
#endif
{
#ifdef ARGO_DEBUG
if (argo_debug[D_DISCARD]) {
- printf("clnp_discard: m x%x, reason x%x\n",
- (unsigned int) m, reason);
+ printf("clnp_discard: m %p, reason x%x\n", m, reason);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_DISCARD]) {
- printf("clnp_emit_er: m x%x, hdr len %d\n",
- (unsigned int) m, clnp->cnf_hdr_len);
+ printf("clnp_emit_er: m %p, hdr len %d\n",
+ m, clnp->cnf_hdr_len);
}
#endif
-/* $OpenBSD: clnp_frag.c,v 1.2 1996/03/04 10:34:50 mickey Exp $ */
-/* $NetBSD: clnp_frag.c,v 1.7 1996/02/13 22:08:21 christos Exp $ */
+/* $OpenBSD: clnp_frag.c,v 1.3 1996/04/21 22:29:11 deraadt Exp $ */
+/* $NetBSD: clnp_frag.c,v 1.8 1996/04/13 01:34:23 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
printf("clnp_fragment: total_len %d:\n",
total_len);
while (mdump != NULL) {
- printf("\tmbuf x%x, m_len %d\n",
- (unsigned int) mdump,
- mdump->m_len);
+ printf("\tmbuf %p, m_len %d\n",
+ mdump, mdump->m_len);
tot_mlen += mdump->m_len;
mdump = mdump->m_next;
}
struct mbuf *mdump = frag_hdr;
printf("clnp_fragment: sending dg:\n");
while (mdump != NULL) {
- printf("\tmbuf x%x, m_len %d\n",
- (unsigned int) mdump,
- mdump->m_len);
+ printf("\tmbuf %p, m_len %d\n",
+ mdump, mdump->m_len);
mdump = mdump->m_next;
}
}
first, last, fraglen);
printf("clnp_insert_frag: current fragments:\n");
for (cf = cfh->cfl_frags; cf != NULL; cf = cf->cfr_next) {
- printf("\tcf x%x: [%d-%d]\n",
- (unsigned int) cf, cf->cfr_first, cf->cfr_last);
+ printf("\tcf %p: [%d-%d]\n",
+ cf, cf->cfr_first, cf->cfr_last);
}
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_REASS]) {
printf(
- "clnp_insert_frag: clnp x%x requires %d alignment\n",
- (unsigned int) clnp, pad);
+ "clnp_insert_frag: clnp %p requires %d alignment\n",
+ clnp, pad);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_REASS]) {
- printf("clnp_insert_frag: cf now x%x, cfr_bytes %d\n",
- (unsigned int) cf, cf->cfr_bytes);
+ printf("clnp_insert_frag: cf now %p, cfr_bytes %d\n",
+ cf, cf->cfr_bytes);
}
#endif
}
mdump = cf->cfr_data;
l = 0;
while (mdump != NULL) {
- printf("\tmbuf x%x, m_len %d\n",
- (unsigned int) mdump,
- mdump->m_len);
+ printf("\tmbuf %p, m_len %d\n",
+ mdump, mdump->m_len);
l += mdump->m_len;
mdump = mdump->m_next;
}
mdump = cf_next->cfr_data;
l = 0;
while (mdump != NULL) {
- printf("\tmbuf x%x, m_len %d\n",
- (unsigned int) mdump,
- mdump->m_len);
+ printf("\tmbuf %p, m_len %d\n",
+ mdump, mdump->m_len);
l += mdump->m_len;
mdump = mdump->m_next;
}
cf->cfr_first, cf->cfr_last);
printf("clnp_comp_pdu: data for frag:\n");
while (mdump != NULL) {
- printf("mbuf x%x, m_len %d\n", (unsigned int) mdump,
- mdump->m_len);
+ printf("mbuf %p, m_len %d\n", mdump, mdump->m_len);
/* dump_buf(mtod(mdump, caddr_t), mdump->m_len); */
mdump = mdump->m_next;
}
struct mbuf *mdump = hdr;
printf("clnp_comp_pdu: pdu is:\n");
while (mdump != NULL) {
- printf("mbuf x%x, m_len %d\n",
- (unsigned int) mdump,
- mdump->m_len);
+ printf("mbuf %p, m_len %d\n",
+ mdump, mdump->m_len);
#if 0
dump_buf(mtod(mdump, caddr_t), mdump->m_len);
#endif
-/* $OpenBSD: clnp_input.c,v 1.2 1996/03/04 10:34:53 mickey Exp $ */
-/* $NetBSD: clnp_input.c,v 1.11 1996/02/13 22:08:26 christos Exp $ */
+/* $OpenBSD: clnp_input.c,v 1.3 1996/04/21 22:29:13 deraadt Exp $ */
+/* $NetBSD: clnp_input.c,v 1.12 1996/04/13 01:34:26 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
dump_buf(mtod(m, caddr_t), clnp->cnf_hdr_len);
printf("clnp_input: mbuf chain:\n");
for (mhead = m; mhead != NULL; mhead = mhead->m_next) {
- printf("m x%x, len %d\n", (unsigned int) mhead,
- mhead->m_len);
+ printf("m %p, len %d\n", mhead, mhead->m_len);
total_len += mhead->m_len;
}
printf("clnp_input: total length of mbuf chain %d:\n",
-/* $OpenBSD: clnp_options.c,v 1.2 1996/03/04 10:34:55 mickey Exp $ */
-/* $NetBSD: clnp_options.c,v 1.6 1996/02/13 22:08:32 christos Exp $ */
+/* $OpenBSD: clnp_options.c,v 1.3 1996/04/21 22:29:15 deraadt Exp $ */
+/* $NetBSD: clnp_options.c,v 1.7 1996/04/13 01:34:29 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_OPTIONS]) {
- printf("clnp_dooptions: record route: option x%x for %d bytes\n",
- (unsigned int) opt, oidx->cni_recrt_len);
+ printf("clnp_dooptions: record route: option %p for %d bytes\n",
+ opt, oidx->cni_recrt_len);
printf("\tfree slot offset x%x\n", off);
printf("clnp_dooptions: recording %s\n", clnp_iso_addrp(isoa));
printf("clnp_dooptions: option dump:\n");
} else {
#ifdef ARGO_DEBUG
if (argo_debug[D_OPTIONS]) {
- printf("clnp_dooptions: new addr at x%x for %d\n",
- (unsigned int) rec_start,
- new_addrlen);
+ printf("clnp_dooptions: new addr at %p for %d\n",
+ rec_start, new_addrlen);
}
#endif
-/* $OpenBSD: clnp_output.c,v 1.2 1996/03/04 10:34:57 mickey Exp $ */
-/* $NetBSD: clnp_output.c,v 1.8 1996/02/13 22:08:39 christos Exp $ */
+/* $OpenBSD: clnp_output.c,v 1.3 1996/04/21 22:29:16 deraadt Exp $ */
+/* $NetBSD: clnp_output.c,v 1.9 1996/04/13 01:34:32 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
if (argo_debug[D_OUTPUT]) {
printf("clnp_output: to %s", clnp_iso_addrp(dst));
printf(" from %s of %d bytes\n", clnp_iso_addrp(src), datalen);
- printf("\toptions x%x, flags x%x, isop_clnpcache x%x\n",
- (unsigned int) isop->isop_options, flags,
- (unsigned int) isop->isop_clnpcache);
+ printf("\toptions %p, flags x%x, isop_clnpcache %p\n",
+ isop->isop_options, flags, isop->isop_clnpcache);
}
#endif
*/
#ifdef ARGO_DEBUG
if (argo_debug[D_OUTPUT]) {
- printf("clnp_output: ck cache: clcp %x\n", (unsigned int) clcp);
+ printf("clnp_output: ck cache: clcp %p\n", clcp);
if (clcp != NULL) {
printf("\tclc_dst %s\n", clnp_iso_addrp(&clcp->clc_dst));
- printf("\tisop_opts x%x, clc_opts x%x\n",
- (unsigned int) isop->isop_options,
- (unsigned int) clcp->clc_options);
+ printf("\tisop_opts %p, clc_opts %p\n",
+ isop->isop_options, clcp->clc_options);
if (isop->isop_route.ro_rt)
- printf("\tro_rt x%x, rt_flags x%x\n",
- (unsigned int) isop->isop_route.ro_rt,
+ printf("\tro_rt %p, rt_flags x%x\n",
+ isop->isop_route.ro_rt,
isop->isop_route.ro_rt->rt_flags);
printf("\tflags x%x, clc_flags x%x\n", flags,
clcp->clc_flags);
- printf("\tclc_hdr x%x\n", (unsigned int) clcp->clc_hdr);
+ printf("\tclc_hdr %p\n", clcp->clc_hdr);
}
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_OUTPUT]) {
printf(
- "clnp_output: freeing old clc_hdr 0x%x\n",
- (unsigned int) clcp->clc_hdr);
+ "clnp_output: freeing old clc_hdr %p\n",
+ clcp->clc_hdr);
}
#endif
m_free(clcp->clc_hdr);
}
#ifdef ARGO_DEBUG
if (argo_debug[D_OUTPUT]) {
- printf("clnp_output: NEW clcp x%x\n",
- (unsigned int) clcp);
+ printf("clnp_output: NEW clcp %p\n", clcp);
}
#endif
bzero((caddr_t) clcp, sizeof(struct clnp_cache));
-/* $OpenBSD: clnp_subr.c,v 1.2 1996/03/04 10:35:02 mickey Exp $ */
-/* $NetBSD: clnp_subr.c,v 1.7 1996/02/13 22:08:49 christos Exp $ */
+/* $OpenBSD: clnp_subr.c,v 1.3 1996/04/21 22:29:18 deraadt Exp $ */
+/* $NetBSD: clnp_subr.c,v 1.8 1996/04/13 01:34:35 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) {
#ifdef ARGO_DEBUG
if (argo_debug[D_ROUTE]) {
- printf("clnp_ours: ia_sis x%x, dst x%x\n",
- (unsigned int) &ia->ia_addr,
- (unsigned int) dst);
+ printf("clnp_ours: ia_sis %p, dst %p\n",
+ &ia->ia_addr, dst);
}
#endif
/*
}
#ifdef ARGO_DEBUG
if (argo_debug[D_FORWARD]) {
- printf("clnp_forward: %d bytes, to %s, options x%x\n", len,
- clnp_iso_addrp(dst), (unsigned int) oidx);
+ printf("clnp_forward: %d bytes, to %s, options %p\n", len,
+ clnp_iso_addrp(dst), oidx);
}
#endif
(Bcmp(ro->ro_dst.siso_data, dst->isoa_genaddr, dst->isoa_len)))) {
#ifdef ARGO_DEBUG
if (argo_debug[D_ROUTE]) {
- printf("clnp_route: freeing old route: ro->ro_rt 0x%x\n",
- (unsigned int) ro->ro_rt);
+ printf("clnp_route: freeing old route: ro->ro_rt %p\n",
+ ro->ro_rt);
printf("clnp_route: old route refcnt: 0x%x\n",
ro->ro_rt->rt_refcnt);
}
int line; /* where the dirty deed occured */
char *file; /* where the dirty deed occured */
{
- printf("sending on route 0x%x with no mtu, line %d of file %s\n",
- (unsigned int) rt, line, file);
+ printf("sending on route %p with no mtu, line %d of file %s\n",
+ rt, line, file);
#ifdef ARGO_DEBUG
printf("route dst is ");
dump_isoaddr((struct sockaddr_iso *) rt_key(rt));
-/* $OpenBSD: esis.c,v 1.2 1996/03/04 10:35:15 mickey Exp $ */
-/* $NetBSD: esis.c,v 1.12 1996/02/13 22:09:23 christos Exp $ */
+/* $OpenBSD: esis.c,v 1.3 1996/04/21 22:29:21 deraadt Exp $ */
+/* $NetBSD: esis.c,v 1.13 1996/04/13 01:34:39 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_ESISOUTPUT]) {
printf(
- "esis_rdoutput: ifp x%x (%s%d), ht %d, m x%x, oidx x%x\n",
- (unsigned int) ifp, ifp->if_name, ifp->if_unit,
- esis_holding_time,
- (unsigned int) inbound_m, (unsigned int) inbound_oidx);
+ "esis_rdoutput: ifp %p (%s%d), ht %d, m %p, oidx %p\n",
+ ifp, ifp->if_name, ifp->if_unit, esis_holding_time,
+ inbound_m, inbound_oidx);
printf("\tdestination: %s\n", clnp_iso_addrp(rd_dstnsap));
printf("\tredirected toward:%s\n", clnp_iso_addrp(rd_gwnsap));
}
#ifdef ARGO_DEBUG
if (argo_debug[D_ESISOUTPUT]) {
int i;
- printf("esis_shoutput: ifp x%x (%s%d), %s, ht %d, to: [%d] ",
- (unsigned int) ifp, ifp->if_name, ifp->if_unit,
+ printf("esis_shoutput: ifp %p (%s%d), %s, ht %d, to: [%d] ",
+ ifp, ifp->if_name, ifp->if_unit,
type == ESIS_ESH ? "esh" : "ish",
ht, sn_len);
for (i = 0; i < sn_len; i++)
m->m_len += 4;
#ifdef ARGO_DEBUG
if (argo_debug[D_ESISOUTPUT]) {
- printf("m0 0x%x, m 0x%x, data 0x%x, len %d, cp 0x%x\n",
- (unsigned int) m0, (unsigned int) m,
- (unsigned int) m->m_data, m->m_len,
- (unsigned int) cp);
+ printf("m0 %p, m %p, data %p, len %d, cp %p\n",
+ m0, m, m->m_data, m->m_len, cp);
}
#endif
}
if (argo_debug[D_ISISINPUT]) {
int i;
- printf("isis_input: pkt on ifp x%x (%s%d): from:",
- (unsigned int) ifp,
- ifp->if_name, ifp->if_unit);
+ printf("isis_input: pkt on ifp %p (%s%d): from:",
+ ifp, ifp->if_name, ifp->if_unit);
for (i = 0; i < 6; i++)
printf("%x%c", shp->snh_shost[i] & 0xff,
(i < 5) ? ':' : ' ');
#ifdef ARGO_DEBUG
if (argo_debug[D_ISISINPUT]) {
printf(
- "Error in sbappenaddr, mm = 0x%x\n",
- (unsigned int) mm);
+ "Error in sbappenaddr, mm = %p\n", mm);
}
#endif
m_freem(mm);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISISOUTPUT]) {
u_char *cp = (u_char *) LLADDR(sdl), *cplim = cp + sn_len;
- printf("isis_output: ifp 0x%x (%s%d), to: ",
- (unsigned int) ifp, ifp->if_name, ifp->if_unit);
+ printf("isis_output: ifp %p (%s%d), to: ",
+ ifp, ifp->if_name, ifp->if_unit);
while (cp < cplim) {
printf("%x", *cp++);
printf("%c", (cp < cplim) ? ':' : ' ');
-/* $OpenBSD: if_eon.c,v 1.2 1996/03/04 10:35:24 mickey Exp $ */
-/* $NetBSD: if_eon.c,v 1.12 1996/02/13 22:09:50 christos Exp $ */
+/* $OpenBSD: if_eon.c,v 1.3 1996/04/21 22:29:23 deraadt Exp $ */
+/* $NetBSD: if_eon.c,v 1.13 1996/04/13 01:34:44 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
mhead.m_next = 0;
#ifdef ARGO_DEBUG
if (argo_debug[D_EON]) {
- printf("eonoutput : gen csum (0x%x, offset %d, datalen %d)\n",
- (unsigned int) &mhead,
- _offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr));
+ printf("eonoutput : gen csum (%p, offset %d, datalen %d)\n",
+ &mhead, _offsetof(struct eon_hdr, eonh_csum),
+ sizeof(struct eon_hdr));
}
#endif
iso_gen_csum(&mhead,
#ifdef ARGO_DEBUG
if (argo_debug[D_EON]) {
- printf("eoninput() 0x%x m_data 0x%x m_len 0x%x dequeued\n",
- (unsigned int) m,
- (unsigned int) (m ? m->m_data : 0), m ? m->m_len : 0);
+ printf("eoninput() %p m_data %p m_len 0x%x dequeued\n",
+ m, (m ? m->m_data : 0), m ? m->m_len : 0);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_EON]) {
printf(
- "0x%x enqueued on clnp Q: m_len 0x%x m_type 0x%x m_data 0x%x\n",
- (unsigned int) m, m->m_len, m->m_type,
- (unsigned int) m->m_data);
+ "%p enqueued on clnp Q: m_len 0x%x m_type 0x%x m_data %p\n",
+ m, m->m_len, m->m_type, m->m_data);
dump_buf(mtod(m, caddr_t), m->m_len);
}
#endif
-/* $OpenBSD: iso.c,v 1.2 1996/03/04 10:35:26 mickey Exp $ */
-/* $NetBSD: iso.c,v 1.13 1996/02/13 22:09:54 christos Exp $ */
+/* $OpenBSD: iso.c,v 1.3 1996/04/21 22:29:25 deraadt Exp $ */
+/* $NetBSD: iso.c,v 1.14 1996/04/13 01:34:48 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_nlctloutput: cmd %x, opt %x, pcb %x, m %x\n",
- cmd, optname, (unsigned int) pcb, (unsigned int) m);
+ printf("iso_nlctloutput: cmd %x, opt %x, pcb %p, m %p\n",
+ cmd, optname, pcb, m);
}
#endif
-/* $OpenBSD: iso_chksum.c,v 1.2 1996/03/04 10:35:30 mickey Exp $ */
-/* $NetBSD: iso_chksum.c,v 1.6 1996/02/13 22:10:01 christos Exp $ */
+/* $OpenBSD: iso_chksum.c,v 1.3 1996/04/21 22:29:27 deraadt Exp $ */
+/* $NetBSD: iso_chksum.c,v 1.7 1996/04/13 01:34:52 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_CHKSUM]) {
- printf("iso_check_csum: m x%x, l x%x, m->m_len x%x\n",
- (unsigned int) m, l, m->m_len);
+ printf("iso_check_csum: m %p, l x%x, m->m_len x%x\n",
+ m, l, m->m_len);
}
#endif
printf("iso_check_csum: new mbuf\n");
if (l - i < m->m_len)
printf(
- "bad mbuf chain in check csum l 0x%x i 0x%x m_data 0x%x",
- l, i, (unsigned int) m->m_data);
+ "bad mbuf chain in check csum l 0x%x i 0x%x m_data %p",
+ l, i, m->m_data);
}
#endif
ASSERT(m != NULL);
#ifdef ARGO_DEBUG
if (argo_debug[D_CHKSUM]) {
- printf("enter gen csum m 0x%x n 0x%x l 0x%x\n",
- (unsigned int) m, n - 1, l);
+ printf("enter gen csum m %p n 0x%x l 0x%x\n",
+ m, n - 1, l);
}
#endif
xloc = loc + mtod(m, u_char *);
#ifdef ARGO_DEBUG
if (argo_debug[D_CHKSUM]) {
- printf(
- "1: zeroing xloc 0x%x loc 0x%x\n",
- (unsigned int) xloc,
- (unsigned int) loc);
+ printf("1: zeroing xloc %p loc %p\n",
+ xloc, loc);
}
#endif
*xloc = (u_char) 0;
#ifdef ARGO_DEBUG
if (argo_debug[D_CHKSUM]) {
printf(
- "2: zeroing yloc 0x%x loc 0x%x\n",
- (unsigned int) yloc, loc);
+ "2: zeroing yloc %p loc 0x%x\n",
+ yloc, loc);
}
#endif
*yloc = (u_char) 0;
#ifdef ARGO_DEBUG
if (argo_debug[D_CHKSUM]) {
printf(
- "3: zeroing yloc 0x%x \n",
- (unsigned int) yloc);
+ "3: zeroing yloc %p \n", yloc);
}
#endif
*yloc = (u_char) 0;
}
#ifdef ARGO_DEBUG
if (argo_debug[D_CHKSUM]) {
- printf("gen csum final xloc 0x%x yloc 0x%x\n",
- (unsigned int) xloc, (unsigned int) yloc);
+ printf("gen csum final xloc %p yloc %p\n", xloc, yloc);
}
#endif
while (in) {
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
- printf("m_compress in 0x%x *out 0x%x\n",
- (unsigned int) in, (unsigned int) *out);
- printf("m_compress in: len 0x%x, off 0x%x\n",
- in->m_len, (unsigned int) in->m_data);
- printf("m_compress *out: len 0x%x, off 0x%x\n",
- (*out)->m_len, (unsigned int) (*out)->m_data);
+ printf("m_compress in %p *out %p\n", in, *out);
+ printf("m_compress in: len 0x%x, off %p\n",
+ in->m_len, in->m_data);
+ printf("m_compress *out: len 0x%x, off %p\n",
+ (*out)->m_len, (*out)->m_data);
}
#endif
if (in->m_flags & M_EXT) {
-/* $OpenBSD: iso_pcb.c,v 1.2 1996/03/04 10:35:34 mickey Exp $ */
-/* $NetBSD: iso_pcb.c,v 1.9 1996/02/13 22:10:13 christos Exp $ */
+/* $OpenBSD: iso_pcb.c,v 1.3 1996/04/21 22:29:29 deraadt Exp $ */
+/* $NetBSD: iso_pcb.c,v 1.10 1996/04/13 01:34:56 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcballoc(so 0x%x)\n", (unsigned int) so);
+ printf("iso_pcballoc(so %p)\n", so);
}
#endif
MALLOC(isop, struct isopcb *, sizeof(*isop), M_PCB, M_NOWAIT);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbbind(isop 0x%x, nam 0x%x)\n",
- (unsigned int) isop, (unsigned int) nam);
+ printf("iso_pcbbind(isop %p, nam %p)\n", isop, nam);
}
#endif
suf.s = 0;
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbconnect(isop 0x%x sock 0x%x nam 0x%x",
- (unsigned int) isop, (unsigned int) isop->isop_socket,
- (unsigned int) nam);
+ printf("iso_pcbconnect(isop %p sock %p nam %p",
+ isop, isop->isop_socket, nam);
printf("nam->m_len 0x%x), addr:\n", nam->m_len);
dump_isoaddr(siso);
}
return error;
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbconnect localzero 2, ro->ro_rt 0x%x",
- (unsigned int) isop->isop_route.ro_rt);
- printf(" ia 0x%x\n", (unsigned int) ia);
+ printf("iso_pcbconnect localzero 2, ro->ro_rt %p",
+ isop->isop_route.ro_rt);
+ printf(" ia %p\n", ia);
}
#endif
}
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("in iso_pcbconnect before lookup isop 0x%x isop->sock 0x%x\n",
- (unsigned int) isop, (unsigned int) isop->isop_socket);
+ printf("in iso_pcbconnect before lookup isop %p isop->sock %p\n",
+ isop, isop->isop_socket);
}
#endif
if (local_zero) {
}
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("in iso_pcbconnect before bcopy isop 0x%x isop->sock 0x%x\n",
- (unsigned int) isop, (unsigned int) isop->isop_socket);
+ printf("in iso_pcbconnect before bcopy isop %p isop->sock %p\n",
+ isop, isop->isop_socket);
}
#endif
/*
bcopy((caddr_t) siso, (caddr_t) isop->isop_faddr, siso->siso_len);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("in iso_pcbconnect after bcopy isop 0x%x isop->sock 0x%x\n",
- (unsigned int) isop, (unsigned int) isop->isop_socket);
+ printf("in iso_pcbconnect after bcopy isop %p isop->sock %p\n",
+ isop, isop->isop_socket);
printf("iso_pcbconnect connected to addr:\n");
dump_isoaddr(isop->isop_faddr);
printf("iso_pcbconnect end: src addr:\n");
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbdisconnect(isop 0x%x)\n", (unsigned int) isop);
+ printf("iso_pcbdisconnect(isop %p)\n", isop);
}
#endif
/*
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbdetach(isop 0x%x socket 0x%x so 0x%x)\n",
- (unsigned int) isop, (unsigned int) isop->isop_socket,
- (unsigned int) so);
+ printf("iso_pcbdetach(isop %p socket %p so %p)\n",
+ isop, isop->isop_socket, so);
}
#endif
#ifdef TPCONS
mtod(isop->isop_clnpcache, struct clnp_cache *);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbdetach 3.2: clcp 0x%x freeing clc_hdr x%x\n",
- (unsigned int) clcp,
- (unsigned int) clcp->clc_hdr);
+ printf("iso_pcbdetach 3.2: clcp %p freeing clc_hdr %p\n",
+ clcp, clcp->clc_hdr);
}
#endif
if (clcp->clc_hdr != NULL)
m_free(clcp->clc_hdr);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbdetach 3.3: freeing cache x%x\n",
- (unsigned int) isop->isop_clnpcache);
+ printf("iso_pcbdetach 3.3: freeing cache %p\n",
+ isop->isop_clnpcache);
}
#endif
m_free(isop->isop_clnpcache);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbnotify(head 0x%x, notify 0x%x) dst:\n",
- (unsigned int) head, (unsigned int) notify);
+ printf("iso_pcbnotify(head %p, notify %p) dst:\n",
+ head, notify);
}
#endif
for (isop = head->isop_next; isop != head; isop = isop->isop_next) {
!SAME_ISOADDR(siso, isop->isop_faddr)) {
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcbnotify: CONTINUE isop 0x%x, sock 0x%x\n",
- (unsigned int) isop,
- (unsigned int) isop->isop_socket);
- printf("addrmatch cmp'd with (0x%x):\n",
- (unsigned int) isop->isop_faddr);
+ printf("iso_pcbnotify: CONTINUE isop %p, sock %p\n",
+ isop, isop->isop_socket);
+ printf("addrmatch cmp'd with (%p):\n",
+ isop->isop_faddr);
dump_isoaddr(isop->isop_faddr);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
- printf("iso_pcblookup(head 0x%x laddr 0x%x fport 0x%x)\n",
- (unsigned int) head, (unsigned int) laddr,
- (unsigned int) fport);
+ printf("iso_pcblookup(head %p laddr %p fport %p)\n",
+ head, laddr, fport);
}
#endif
for (isop = head->isop_next; isop != head; isop = isop->isop_next) {
-/* $OpenBSD: iso_snpac.c,v 1.2 1996/03/04 10:35:39 mickey Exp $ */
-/* $NetBSD: iso_snpac.c,v 1.11 1996/02/13 22:10:25 christos Exp $ */
+/* $OpenBSD: iso_snpac.c,v 1.3 1996/04/21 22:29:32 deraadt Exp $ */
+/* $NetBSD: iso_snpac.c,v 1.12 1996/04/13 01:35:00 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_SNPA]) {
- printf("llc_rtrequest(%d, %x, %x)\n", req,
- (unsigned int) rt, (unsigned int) sa);
+ printf("llc_rtrequest(%d, %p, %p)\n", req, rt, sa);
}
#endif
if (rt->rt_flags & RTF_GATEWAY)
#ifdef ARGO_DEBUG
if (argo_debug[D_SNPA]) {
- printf("snpac_add(%x, %x, %x, %x, %x, %x)\n",
- (unsigned int) ifp,
- (unsigned int) nsap,
- (unsigned int) snpa, type, ht, nsellength);
+ printf("snpac_add(%p, %p, %p, %x, %x, %x)\n",
+ ifp, nsap, snpa, type, ht, nsellength);
}
#endif
zap_isoaddr(dst, nsap);
rt = rtalloc1(sisotosa(&dst), 0);
#ifdef ARGO_DEBUG
if (argo_debug[D_SNPA]) {
- printf("snpac_add: rtalloc1 returns %x\n", (unsigned int) rt);
+ printf("snpac_add: rtalloc1 returns %p\n", rt);
}
#endif
if (rt == 0) {
-/* $OpenBSD: tp_driver.c,v 1.2 1996/03/04 10:35:53 mickey Exp $ */
-/* $NetBSD: tp_driver.c,v 1.7 1996/02/13 22:10:49 christos Exp $ */
+/* $OpenBSD: tp_driver.c,v 1.3 1996/04/21 22:29:40 deraadt Exp $ */
+/* $NetBSD: tp_driver.c,v 1.8 1996/03/16 23:13:45 christos Exp $ */
#include "tp_states.h"
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("CR datalen 0x%x data 0x%x",
+ printf("CR datalen 0x%x data %p",
e->ev_union.EV_CR_TPDU.e_datalen,
e->ev_union.EV_CR_TPDU.e_data);
}
if (data) {
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("T_CONN_req.trans m_copy cc 0x%x\n",
+ printf("T_CONN_req.trans m_copy cc %p\n",
p->tp_ucddata);
dump_mbuf(data, "sosnd @ T_CONN_req");
}
if (p->tp_ucddata) {
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("TM_retrans.trans m_copy cc 0x%x\n",
+ printf("TM_retrans.trans m_copy cc %p\n",
data);
dump_mbuf(p->tp_ucddata, "sosnd @ TM_retrans");
}
if (data) {
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("T_DISC_req.trans tp_ucddata 0x%x\n",
+ printf("T_DISC_req.trans tp_ucddata %p\n",
p->tp_ucddata);
dump_mbuf(data, "ucddata @ T_DISC_req");
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_XPD]) {
- printf("T_XPD_req: sb_cc 0x%x\n", p->tp_Xsnd.sb_cc);
+ printf("T_XPD_req: sb_cc 0x%lx\n", p->tp_Xsnd.sb_cc);
dump_mbuf(m, "XPD req emitting M");
}
#endif
-/* $OpenBSD: tp_emit.c,v 1.2 1996/03/04 10:35:56 mickey Exp $ */
-/* $NetBSD: tp_emit.c,v 1.7 1996/02/13 22:10:54 christos Exp $ */
+/* $OpenBSD: tp_emit.c,v 1.3 1996/04/21 22:29:43 deraadt Exp $ */
+/* $NetBSD: tp_emit.c,v 1.8 1996/03/16 23:13:48 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_EMIT]) {
printf(
- "tp_emit dutype 0x%x, tpcb 0x%x, eot 0x%x, seq 0x%x, data 0x%x",
+ "tp_emit dutype 0x%x, tpcb %p, eot 0x%x, seq 0x%x, data %p",
dutype, tpcb, eot, seq, data);
}
#endif
} else if (tpcb->tp_class == TP_CLASS_0) {
#ifdef ARGO_DEBUG
if (argo_debug[D_EMIT]) {
- printf("DT tpdu: class 0 m 0x%x hdr 0x%x\n", m, hdr);
+ printf("DT tpdu: class 0 m %p hdr %p\n", m, hdr);
dump_buf(hdr, hdr->tpdu_li + 1);
}
#endif
((struct tp0du *) hdr)->tp0du_mbz = 0;
#ifdef ARGO_DEBUG
if (argo_debug[D_EMIT]) {
- printf("DT 2 tpdu: class 0 m 0x%x hdr 0x%x\n", m, hdr);
+ printf("DT 2 tpdu: class 0 m %p hdr %p\n", m, hdr);
dump_buf(hdr, hdr->tpdu_li + 1);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKSEND]) {
- printf("Calling ADDOPTION 0x%x, 0x%x, 0x%x,0x%x\n",
+ printf("Calling ADDOPTION 0x%x, %p, 0x%x,0x%x\n",
TPP_flow_cntl_conf,
hdr, sizeof(bogus), bogus[0]);
}
ADDOPTION(TPP_flow_cntl_conf, hdr, sizeof(bogus), bogus[0]);
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKSEND]) {
- printf("after ADDOPTION hdr 0x%x hdr->tpdu_li 0x%x\n",
+ printf("after ADDOPTION hdr %p hdr->tpdu_li 0x%x\n",
hdr, hdr->tpdu_li);
printf(
"after ADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n",
}
#ifdef ARGO_DEBUG
if (argo_debug[D_EMIT]) {
- printf("tp_emit before tpxxx_output tpcb 0x%x, dutype 0x%x, datalen 0x%x\n",
+ printf("tp_emit before tpxxx_output tpcb %p, dutype 0x%x, datalen 0x%x\n",
tpcb, dutype, datalen);
dump_buf(mtod(m, caddr_t), datalen);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_EMIT]) {
- printf("OUTPUT: tpcb 0x%x, isop 0x%x, so 0x%x\n",
+ printf("OUTPUT: tpcb %p, isop %p, so %p\n",
tpcb, tpcb->tp_npcb, tpcb->tp_sock);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_ERROR_EMIT]) {
printf(
- "tp_error_emit error 0x%x sref 0x%x tpcb 0x%x erlen 0x%x chan 0x%x\n",
+ "tp_error_emit error 0x%x sref %lx tpcb %p erlen 0x%x chan %p\n",
error, sref, tpcb, erlen, cons_channel);
}
#endif
} else {
#ifdef ARGO_DEBUG
if (argo_debug[D_ERROR_EMIT]) {
- printf("error_emit DR error tpduli 0x%x\n", error, hdr->tpdu_li);
+ printf("error_emit DR error %d tpduli %x\n", error, hdr->tpdu_li);
dump_buf((char *) hdr, hdr->tpdu_li);
}
#endif
}
#ifdef ARGO_DEBUG
if (argo_debug[D_ERROR_EMIT]) {
- printf("OUTPUT: tpcb 0x%x, isop 0x%x, so 0x%x\n",
+ printf("OUTPUT: tpcb %p, isop %p, so %p\n",
tpcb, tpcb->tp_npcb, tpcb->tp_sock);
}
#endif
}
#endif
#else
- printf("TP panic! cons channel 0x%x but not cons configured\n",
+ printf("TP panic! cons channel %p but not cons configured\n",
cons_channel);
#endif
return 0;
} else {
#ifdef ARGO_DEBUG
if (argo_debug[D_ERROR_EMIT]) {
- printf("tp_error_emit DROPPING \n", m);
+ printf("tp_error_emit DROPPING %p\n", m);
}
#endif
IncStat(ts_send_drop);
-/* $OpenBSD: tp_inet.c,v 1.2 1996/03/04 10:36:00 mickey Exp $ */
-/* $NetBSD: tp_inet.c,v 1.10 1996/02/13 22:11:02 christos Exp $ */
+/* $OpenBSD: tp_inet.c,v 1.3 1996/04/21 22:29:45 deraadt Exp $ */
+/* $NetBSD: tp_inet.c,v 1.11 1996/03/16 23:13:49 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tpip_mtu(tpcb)\n", tpcb);
+ printf("tpip_mtu(tpcb %p)\n", tpcb);
printf("tpip_mtu routing to addr 0x%x\n", inp->inp_faddr.s_addr);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_EMIT]) {
- printf("tpip_output_dg datalen 0x%x m0 0x%x\n", datalen, m0);
+ printf("tpip_output_dg datalen 0x%x m0 %p\n", datalen, m0);
}
#endif
dump_inaddr(addr)
register struct sockaddr_in *addr;
{
- printf("INET: port 0x%x; addr 0x%x\n", addr->sin_port, addr->sin_addr);
+ printf("INET: port 0x%x; addr 0x%x\n", addr->sin_port, addr->sin_addr.s_addr);
}
#endif /* ARGO_DEBUG */
#endif /* INET */
-/* $OpenBSD: tp_input.c,v 1.2 1996/03/04 10:36:02 mickey Exp $ */
-/* $NetBSD: tp_input.c,v 1.8 1996/02/13 22:11:08 christos Exp $ */
+/* $OpenBSD: tp_input.c,v 1.3 1996/04/21 22:29:47 deraadt Exp $ */
+/* $NetBSD: tp_input.c,v 1.9 1996/03/16 23:13:51 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tp_inputprep: m 0x%x\n", m);
+ printf("tp_inputprep: m %p\n", m);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_INPUT]) {
printf(
- " at end: m 0x%x hdr->tpdu_li 0x%x m_len 0x%x\n", m,
+ " at end: m %p hdr->tpdu_li 0x%x m_len 0x%x\n", m,
hdrlen, m->m_len);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_NEWSOCK]) {
- printf("tp_newsocket(channel 0x%x) after sonewconn so 0x%x \n",
+ printf("tp_newsocket(channel %p) after sonewconn so %p \n",
cons_channel, so);
dump_addr(fname);
{
head = so->so_head;
t = so;
- printf("so 0x%x so_head 0x%x so_q0 0x%x, q0len %d\n",
+ printf("so %p so_head %p so_q0 %p, q0len %d\n",
t, t->so_head, t->so_q0, t->so_q0len);
while ((t = t->so_q0) && t != so && t != head)
- printf("so 0x%x so_head 0x%x so_q0 0x%x, q0len %d\n",
+ printf("so %p so_head %p so_q0 %p, q0len %d\n",
t, t->so_head, t->so_q0, t->so_q0len);
}
}
}
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tp_route_to FAILED! detaching tpcb 0x%x, so 0x%x\n",
+ printf("tp_route_to FAILED! detaching tpcb %p, so %p\n",
tpcb, so);
}
#endif
ok:
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tp_newsocket returning so 0x%x, sototpcb(so) 0x%x\n",
+ printf("tp_newsocket returning so %p, sototpcb(so) %p\n",
so, sototpcb(so));
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tp_input(0x%x, ... 0x%x)\n", m, cons_channel);
+ printf("tp_input(%p, ... %p)\n", m, cons_channel);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("input: dutype 0x%x cons_channel 0x%x dref 0x%x\n", dutype,
- cons_channel, dref);
+ printf("input: dutype 0x%x cons_channel %p dref 0x%x\n",
+ dutype, cons_channel, dref);
printf("input: dref 0x%x sref 0x%x\n", dref, sref);
}
#endif
#ifdef ARGO_DEBUG
if ((dutype < TP_MIN_TPDUTYPE) || (dutype > TP_MAX_TPDUTYPE)) {
- printf("BAD dutype! 0x%x, channel 0x%x dref 0x%x\n",
+ printf("BAD dutype! 0x%x, channel %p dref 0x%x\n",
dutype, cons_channel, dref);
dump_buf(m, sizeof(struct mbuf));
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("HAVE A TPCB 1: 0x%x\n", tpcb);
+ printf("HAVE A TPCB 1: %p\n", tpcb);
}
#endif
#ifdef ARGO_DEBUG
)
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("CR: after CRCCCHECKS: tpcb 0x%x, flags 0x%x\n",
+ printf("CR: after CRCCCHECKS: tpcb %p, flags 0x%x\n",
tpcb, tpcb->tp_flags);
}
#endif
*/
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("abt to call tp_newsocket(0x%x, 0x%x, 0x%x, 0x%x)\n",
+ printf("abt to call tp_newsocket(%p, %p, %p, %p)\n",
so, laddr, faddr, cons_channel);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("HAVE A TPCB 2: 0x%x\n", tpcb);
+ printf("HAVE A TPCB 2: %p\n", tpcb);
}
#endif
ts_inv_dref, respond,
(1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr))
#ifdef ARGO_DEBUG
- if (argo_debug[D_TPINPUT]) {
- printf("state of dref %d ok, tpcb 0x%x\n", dref, tpcb);
+ if (argo_debug[D_TPINPUT]) {
+ printf("state of dref %d ok, tpcb %p\n", dref, tpcb);
}
#endif
/*
default:
printf(
- "ERROR in tp_input! hdr->tpdu_type 0x%x takes_data 0x%x m 0x%x\n",
+ "ERROR in tp_input! hdr->tpdu_type 0x%x takes_data 0x%x m %p\n",
hdr->tpdu_type, takes_data, m);
break;
}
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tp_input: before driver, state 0x%x event 0x%x m 0x%x",
+ printf("tp_input: before driver, state 0x%x event 0x%x m %p",
tpcb->tp_state, e.ev_number, m);
- printf(" e.e_data 0x%x\n", e.TPDU_ATTR(DT).e_data);
+ printf(" e.e_data %p\n", e.TPDU_ATTR(DT).e_data);
printf("takes_data 0x%x m_len 0x%x, tpdu_len 0x%x\n",
takes_data, (m == MNULL) ? 0 : m->m_len, tpdu_len);
}
* dutypes */
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("after driver, restoring m to 0x%x, takes_data 0x%x\n",
+ printf("after driver, restoring m to %p, takes_data 0x%x\n",
m, takes_data);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
hdr = mtod(m, struct tpdu *);
- printf("tp_input @ separate: hdr 0x%x size %d m 0x%x\n",
+ printf("tp_input @ separate: hdr %p size %d m %p\n",
hdr, (int) hdr->tpdu_li + 1, m);
dump_mbuf(m, "tp_input after driver, at separate");
}
if (m != MNULL) {
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tp_input : m_freem(0x%x)\n", m);
+ printf("tp_input : m_freem(%p)\n", m);
}
#endif
m_freem(m);
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tp_input : after m_freem 0x%x\n", m);
+ printf("tp_input : after m_freem %p\n", m);
}
#endif
}
-/* $OpenBSD: tp_iso.c,v 1.2 1996/03/04 10:36:07 mickey Exp $ */
-/* $NetBSD: tp_iso.c,v 1.7 1996/02/13 22:11:15 christos Exp $ */
+/* $OpenBSD: tp_iso.c,v 1.3 1996/04/21 22:29:50 deraadt Exp $ */
+/* $NetBSD: tp_iso.c,v 1.8 1996/03/16 23:13:54 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tpclnp_mtu(tpcb)\n", tpcb);
+ printf("tpclnp_mtu(tpcb %p)\n", tpcb);
}
#endif
tpcb->tp_routep = &(isop->isop_route.ro_rt);
#ifdef ARGO_DEBUG
if (argo_debug[D_TPISO]) {
- printf("tpclnp_output_dg datalen 0x%x m0 0x%x\n", datalen, m0);
+ printf("tpclnp_output_dg datalen 0x%x m0 %p\n", datalen, m0);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_TPINPUT]) {
- printf("tpclnp_input: m 0x%x clnp_len 0x%x\n", m, clnp_len);
+ printf("tpclnp_input: m %p clnp_len 0x%x\n", m, clnp_len);
dump_mbuf(m, "at tpclnp_input");
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_TPISO]) {
- printf("calling %sinput : src 0x%x, dst 0x%x, src addr:\n",
+ printf("calling %sinput : src %p, dst %p, src addr:\n",
(input == tp_input ? "tp_" : "clts_"), src, dst);
dump_isoaddr(src);
printf(" dst addr:\n");
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tpiso_abort 0x%x\n", isop);
+ printf("tpiso_abort %p\n", isop);
}
#endif
e.ev_number = ER_TPDU;
-/* $OpenBSD: tp_output.c,v 1.2 1996/03/04 10:36:13 mickey Exp $ */
-/* $NetBSD: tp_output.c,v 1.11 1996/02/13 22:11:25 christos Exp $ */
+/* $OpenBSD: tp_output.c,v 1.3 1996/04/21 22:29:52 deraadt Exp $ */
+/* $NetBSD: tp_output.c,v 1.12 1996/03/16 23:13:56 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
printf(
- "tp_ctloutput so 0x%x cmd 0x%x optname 0x%x, mp 0x%x *mp 0x%x tpcb 0x%x\n",
+ "tp_ctloutput so %p cmd 0x%x optname 0x%x, mp %p *mp %p tpcb %p\n",
so, cmd, optname, mp, mp ? *mp : 0, tpcb);
}
#endif
(*mp)->m_len = tpcb->tp_lsuffixlen;
} else { /* cmd == PRCO_SETOPT */
if ((val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0)) {
- printf("val_len 0x%x (*mp)->m_len 0x%x\n", val_len, (*mp));
+ printf("val_len 0x%x (*mp)->m_len %p\n",
+ val_len, (*mp));
error = EINVAL;
} else {
bcopy(value, (caddr_t) tpcb->tp_lsuffix, val_len);
(*mp)->m_len = tpcb->tp_fsuffixlen;
} else { /* cmd == PRCO_SETOPT */
if ((val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0)) {
- printf("val_len 0x%x (*mp)->m_len 0x%x\n", val_len, (*mp));
+ printf("val_len 0x%x (*mp)->m_len %p\n",
+ val_len, (*mp));
error = EINVAL;
} else {
bcopy(value, (caddr_t) tpcb->tp_fsuffix, val_len);
case TPOPT_FLAGS:
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
- printf("%s TPOPT_FLAGS value 0x%x *value 0x%x, flags 0x%x \n",
+ printf("%s TPOPT_FLAGS value %p *value 0x%x, flags 0x%x \n",
cmd == PRCO_GETOPT ? "GET" : "SET",
value,
*value,
*/
#ifdef ARGO_DEBUG
if (argo_debug[D_SETPARAMS]) {
- printf("TPOPT_PARAMS value 0x%x, cmd %s \n", value,
+ printf("TPOPT_PARAMS value %p, cmd %s \n", value,
cmd == PRCO_GETOPT ? "GET" : "SET");
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
- printf("TPOPT_PARAMS value 0x%x, cmd %s \n", value,
+ printf("TPOPT_PARAMS value %p, cmd %s \n", value,
cmd == PRCO_GETOPT ? "GET" : "SET");
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
printf("%s\n", optname == TPOPT_DISC_DATA ? "DISC data" : "CONN data");
- printf("m_len 0x%x, vallen 0x%x so_snd.cc 0x%x\n",
+ printf("m_len 0x%x, vallen 0x%x so_snd.cc 0x%lx\n",
(*mp)->m_len, val_len, so->so_snd.sb_cc);
dump_mbuf(so->so_snd.sb_mb, "tp_ctloutput: sosnd ");
}
-/* $OpenBSD: tp_pcb.c,v 1.2 1996/03/04 10:36:18 mickey Exp $ */
-/* $NetBSD: tp_pcb.c,v 1.12 1996/02/13 22:11:39 christos Exp $ */
+/* $OpenBSD: tp_pcb.c,v 1.3 1996/04/21 22:29:55 deraadt Exp $ */
+/* $NetBSD: tp_pcb.c,v 1.13 1996/03/16 23:13:58 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
tpcb = r->tpr_pcb;
#ifdef ARGO_DEBUG
if (argo_debug[D_TIMER]) {
- printf("tp_freeref called for ref %d pcb %x maxrefopen %d\n",
+ printf("tp_freeref called for ref %d pcb %p maxrefopen %d\n",
n, tpcb, tp_refinfo.tpr_maxopen);
}
#endif
return;
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tp_freeref: CLEARING tpr_pcb 0x%x\n", tpcb);
+ printf("tp_freeref: CLEARING tpr_pcb %p\n", tpcb);
}
#endif
r->tpr_pcb = (struct tp_pcb *) 0;
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tp_attach:dom 0x%x so 0x%x ", dom, so);
+ printf("tp_attach:dom 0x%x so %p ", dom, so);
}
#endif
#ifdef TPPT
bad4:
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("BAD4 in tp_attach, so 0x%x\n", so);
+ printf("BAD4 in tp_attach, so %p\n", so);
}
#endif
tp_freeref(tpcb->tp_lref);
bad3:
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("BAD3 in tp_attach, so 0x%x\n", so);
+ printf("BAD3 in tp_attach, so %p\n", so);
}
#endif
bad2:
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("BAD2 in tp_attach, so 0x%x\n", so);
+ printf("BAD2 in tp_attach, so %p\n", so);
}
#endif
so->so_pcb = 0;
/* bad: */
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("BAD in tp_attach, so 0x%x\n", so);
+ printf("BAD in tp_attach, so %p\n", so);
}
#endif
return error;
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tp_detach(tpcb 0x%x, so 0x%x)\n",
+ printf("tp_detach(tpcb %p, so %p)\n",
tpcb, so);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("so_snd at 0x%x so_rcv at 0x%x\n", &so->so_snd, &so->so_rcv);
+ printf("so_snd at %p so_rcv at %p\n", &so->so_snd, &so->so_rcv);
dump_mbuf(so->so_snd.sb_mb, "so_snd at detach ");
- printf("about to call LL detach, nlproto 0x%x, nl_detach 0x%x\n",
+ printf("about to call LL detach, nlproto %p, nl_detach %p\n",
tpcb->tp_nlproto, tpcb->tp_nlproto->nlp_pcbdetach);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("reassembly info cnt %d rsyq 0x%x\n",
+ printf("reassembly info cnt %d rsyq %p\n",
tpcb->tp_rsycnt, tpcb->tp_rsyq);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("calling (...nlproto->...)(0x%x, so 0x%x)\n",
+ printf("calling (...nlproto->...)(%p, so %p)\n",
tpcb->tp_npcb, so);
- printf("so 0x%x so_head 0x%x, qlen %d q0len %d qlimit %d\n",
+ printf("so %p so_head %p, qlen %d q0len %d qlimit %d\n",
so, so->so_head,
so->so_q0len, so->so_qlen, so->so_qlimit);
}
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("end of detach, NOT single, tpcb 0x%x\n", tpcb);
+ printf("end of detach, NOT single, tpcb %p\n", tpcb);
}
#endif
/* free((caddr_t)tpcb, M_PCB); WHere to put this ? */
-/* $OpenBSD: tp_subr.c,v 1.2 1996/03/04 10:36:29 mickey Exp $ */
-/* $NetBSD: tp_subr.c,v 1.7 1996/02/13 22:11:59 christos Exp $ */
+/* $OpenBSD: tp_subr.c,v 1.3 1996/04/21 22:29:57 deraadt Exp $ */
+/* $NetBSD: tp_subr.c,v 1.8 1996/03/16 23:14:00 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
tpcb->tp_peer_acktime, 128 /* XXX */ );
#ifdef ARGO_DEBUG
if (argo_debug[D_RTT]) {
- printf("%s tpcb 0x%x, elapsed %d, delta %d, rtt %d, rtv %d, old %d\n",
+ printf("%s tpcb %p, elapsed %d, delta %d, rtt %d, rtv %d, old %d\n",
"tp_rtt_rtv:", tpcb, elapsed, delta, tpcb->tp_rtt, tpcb->tp_rtv, old);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKRECV]) {
- printf("goodack tpcb 0x%x seq 0x%x cdt %d una 0x%x new 0x%x nxt 0x%x\n",
+ printf("goodack tpcb %p seq 0x%x cdt %d una 0x%x new 0x%x nxt 0x%x\n",
tpcb, seq, cdt, tpcb->tp_snduna, tpcb->tp_sndnew, tpcb->tp_sndnxt);
}
#endif
discard_the_ack:
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKRECV]) {
- printf("goodack discard : tpcb 0x%x subseq %d r_subseq %d\n",
+ printf("goodack discard : tpcb %p subseq %d r_subseq %d\n",
tpcb, subseq, tpcb->tp_r_subseq);
}
#endif
tpcb->tp_cong_win / tpcb->tp_l_tpdusize) / 2;
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKRECV]) {
- printf("%s tpcb 0x%x seq 0x%x rttseq 0x%x onxt 0x%x\n",
+ printf("%s tpcb %p seq 0x%x rttseq 0x%x onxt 0x%x\n",
"goodack dupacks:", tpcb, seq, tpcb->tp_rttseq, onxt);
}
#endif
done:
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKRECV]) {
- printf("goodack returns 0x%x, cdt 0x%x ocdt 0x%x cwin 0x%x\n",
+ printf("goodack returns 0x%x, cdt 0x%x ocdt 0x%x cwin 0x%lx\n",
bang, cdt, old_fcredit, tpcb->tp_cong_win);
}
#endif
sbdroprecord(sb);
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKRECV]) {
- printf("tp_sbdroping %d pkts %d bytes on %x at 0x%x\n",
+ printf("tp_sbdroping %d pkts %ld bytes on %p at 0x%x\n",
oldi, oldcc - sb->sb_cc, tpcb, seq);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_DATA]) {
- printf("tp_send enter tpcb 0x%x nxt 0x%x win %d high 0x%x\n",
+ printf("tp_send enter tpcb %p nxt 0x%x win %d high 0x%x\n",
tpcb, tpcb->tp_sndnxt, cong_win, highseq);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_DATA]) {
- printf("tp_sending tpcb 0x%x nxt 0x%x\n",
+ printf("tp_sending tpcb %p nxt 0x%x\n",
tpcb, tpcb->tp_sndnxt);
}
#endif
m_freem(*mp);
}
if (tpcb->tp_rsycnt) {
- printf("tp_rsyflush %x\n", tpcb);
+ printf("tp_rsyflush %p\n", tpcb);
tpcb->tp_rsycnt = 0;
}
}
mbcnt += m->m_ext.ext_size;
}
if (len != pktlen) {
- printf("test %d; len %d != pktlen %d on mbuf 0x%x\n",
+ printf("test %d; len %d != pktlen %d on mbuf %p\n",
i, len, pktlen, n);
panic("tpsbcheck short");
}
}
if (len != sb->sb_cc || mbcnt != sb->sb_mbcnt) {
- printf("test %d: cc %d != %d || mbcnt %d != %d\n", i, len, sb->sb_cc,
+ printf("test %d: cc %d != %ld || mbcnt %d != %ld\n", i, len, sb->sb_cc,
mbcnt, sb->sb_mbcnt);
panic("tpsbcheck");
}
-/* $OpenBSD: tp_subr2.c,v 1.2 1996/03/04 10:36:32 mickey Exp $ */
-/* $NetBSD: tp_subr2.c,v 1.9 1996/02/13 22:12:04 christos Exp $ */
+/* $OpenBSD: tp_subr2.c,v 1.3 1996/04/21 22:29:59 deraadt Exp $ */
+/* $NetBSD: tp_subr2.c,v 1.11 1996/03/26 22:27:01 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static void copyQOSparms __P((struct tp_conn_param *, struct tp_conn_param *));
#endif
-#if 0
-static void pk_flowcontrol __P((struct pklcd *, int, int));
-#endif
/*
* NAME: tp_local_credit()
LOCAL_CREDIT(tpcb);
#ifdef ARGO_DEBUG
if (argo_debug[D_CREDIT]) {
- printf("ref 0x%x lcdt 0x%x l_tpdusize 0x%x decbit 0x%x\n",
+ printf("ref 0x%x lcdt 0x%x l_tpdusize 0x%x decbit 0x%x cong_win 0x%lx\n",
tpcb->tp_lref,
tpcb->tp_lcredit,
tpcb->tp_l_tpdusize,
struct tp_event *e;
struct tp_pcb *tpcb;
{
- printf("TP PROTOCOL ERROR! tpcb 0x%x event 0x%x, state 0x%x\n",
+ printf("TP PROTOCOL ERROR! tpcb %p event 0x%x, state 0x%x\n",
tpcb, e->ev_number, tpcb->tp_state);
#ifdef TPPT
if (tp_traceflags[D_DRIVER]) {
struct tp_pcb *tpcb = (struct tp_pcb *) ipcb;
#ifdef ARGO_DEBUG
if (argo_debug[D_QUENCH]) {
- printf("tp_quench tpcb 0x%x ref 0x%x sufx 0x%x\n",
+ printf("tp_quench tpcb %p ref 0x%x sufx 0x%x\n",
tpcb, tpcb->tp_lref, *(u_short *) (tpcb->tp_lsuffix));
- printf("cong_win 0x%x decbit 0x%x \n",
+ printf("cong_win 0x%lx decbit 0x%x \n",
tpcb->tp_cong_win, tpcb->tp_decbit);
}
#endif
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("tp_route_to( m x%x, channel 0x%x, tpcb 0x%x netserv 0x%x)\n",
+ printf("tp_route_to( m %p, channel %p, tpcb %p netserv 0x%x)\n",
m, channel, tpcb, tpcb->tp_netservice);
printf("m->mlen x%x, m->m_data:\n", m->m_len);
dump_buf(mtod(m, caddr_t), m->m_len);
return error;
}
-#if 0
-static
+#ifndef CCITT
void
pk_flowcontrol(lcp, foo, bar)
struct pklcd *lcp;
{
int i, j;
#define Buf ((u_char *)buf)
- printf("Dump buf 0x%x len 0x%x\n", buf, len);
+ printf("Dump buf %p len 0x%x\n", buf, len);
for (i = 0; i < len; i += MAX_COLUMNS) {
printf("+%d:\t", i);
for (j = 0; j < MAX_COLUMNS; j++) {
-/* $OpenBSD: tp_timer.c,v 1.2 1996/03/04 10:36:34 mickey Exp $ */
-/* $NetBSD: tp_timer.c,v 1.7 1996/02/13 22:12:10 christos Exp $ */
+/* $OpenBSD: tp_timer.c,v 1.3 1996/04/21 22:30:02 deraadt Exp $ */
+/* $NetBSD: tp_timer.c,v 1.8 1996/03/16 23:14:04 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
register u_int *callp;
#ifdef ARGO_DEBUG
if (argo_debug[D_TIMER]) {
- printf("etimeout pcb 0x%x state 0x%x\n", tpcb, tpcb->tp_state);
+ printf("etimeout pcb %p state 0x%x\n", tpcb, tpcb->tp_state);
}
#endif
#ifdef TPPT
E.ev_number = t;
#ifdef ARGO_DEBUG
if (argo_debug[D_TIMER]) {
- printf("tp_slowtimo: pcb 0x%x t %d\n",
+ printf("tp_slowtimo: pcb %p t %d\n",
tpcb, t);
}
#endif
*/
#ifdef ARGO_DEBUG
if (argo_debug[D_ACKRECV]) {
- printf("tp_data_retrans: 0 window tpcb 0x%x una 0x%x\n",
+ printf("tp_data_retrans: 0 window tpcb %p una 0x%x\n",
tpcb, tpcb->tp_snduna);
}
#endif
{
#ifdef ARGO_DEBUG
if (argo_debug[D_TIMER]) {
- printf("tp_cuntimeout(0x%x, %d) active %d\n",
+ printf("tp_cuntimeout(%p, %d) active %d\n",
tpcb, which, tpcb->tp_timer[which]);
}
#endif
-/* $OpenBSD: tp_usrreq.c,v 1.2 1996/03/04 10:36:45 mickey Exp $ */
-/* $NetBSD: tp_usrreq.c,v 1.8 1996/02/13 22:12:27 christos Exp $ */
+/* $OpenBSD: tp_usrreq.c,v 1.3 1996/04/21 22:30:04 deraadt Exp $ */
+/* $NetBSD: tp_usrreq.c,v 1.9 1996/03/16 23:14:06 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
nextrecord = n->m_act;
printf("RECORD:\n");
while (n) {
- printf("%x : Len %x Data %x A %x Nx %x Tp %x\n",
+ printf("%p : Len %x Data %p A %p Nx %p Tp %x\n",
n, n->m_len, n->m_data, n->m_act, n->m_next, n->m_type);
#ifdef notdef
{
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
- printf("usrreq(0x%x,%d,0x%x,0x%x,0x%x)\n", so, req, m, nam, outflags);
+ printf("usrreq(%p,%d,%p,%p,%p)\n", so, req, m, nam, outflags);
if (so->so_error)
printf("WARNING!!! so->so_error is 0x%x\n", so->so_error);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("PRU_CONNECT: so *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x",
+ printf("PRU_CONNECT: so %p *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x",
tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen,
tpcb->tp_class);
}
}
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
- printf("isop 0x%x isop->isop_socket offset 12 :\n", tpcb->tp_npcb);
+ printf("isop %p isop->isop_socket offset 12 :\n", tpcb->tp_npcb);
dump_buf(tpcb->tp_npcb, 16);
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_CONN]) {
printf(
- "PRU_CONNECT after tpcb 0x%x so 0x%x npcb 0x%x flags 0x%x\n",
+ "PRU_CONNECT after tpcb %p so %p npcb %p flags 0x%x\n",
tpcb, so, tpcb->tp_npcb, tpcb->tp_flags);
- printf("isop 0x%x isop->isop_socket offset 12 :\n", tpcb->tp_npcb);
+ printf("isop %p isop->isop_socket offset 12 :\n", tpcb->tp_npcb);
dump_buf(tpcb->tp_npcb, 16);
}
#endif
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
- printf("RCVD: cc %d space %d hiwat %d\n",
+ printf("RCVD: cc %ld space %ld hiwat %ld\n",
so->so_rcv.sb_cc, sbspace(&so->so_rcv),
so->so_rcv.sb_hiwat);
}
#ifdef ARGO_DEBUG
if (argo_debug[D_SYSCALL]) {
printf(
- "PRU_SEND: eot %d before sbappend 0x%x len 0x%x to sb @ 0x%x\n",
+ "PRU_SEND: eot %ld before sbappend %p len 0x%x to sb @ %p\n",
eotsdu, m, totlen, sb);
dump_mbuf(sb->sb_mb, "so_snd.sb_mb");
dump_mbuf(m, "m : to be added");
tp_packetize(tpcb, m, eotsdu);
#ifdef ARGO_DEBUG
if (argo_debug[D_SYSCALL]) {
- printf("PRU_SEND: eot %d after sbappend 0x%x\n", eotsdu, m);
+ printf("PRU_SEND: eot %ld after sbappend %p\n", eotsdu, m);
dump_mbuf(sb->sb_mb, "so_snd.sb_mb");
}
#endif
#ifdef ARGO_DEBUG
if (argo_debug[D_SYSCALL]) {
printf("PRU_SEND: after driver error 0x%x \n", error);
- printf("so_snd 0x%x cc 0t%d mbcnt 0t%d\n",
+ printf("so_snd %p cc 0t%ld mbcnt 0t%ld\n",
sb, sb->sb_cc, sb->sb_mbcnt);
dump_mbuf(sb->sb_mb, "so_snd.sb_mb after driver");
}
#ifdef ARGO_DEBUG
if (argo_debug[D_REQUEST]) {
- printf("%s, so 0x%x, tpcb 0x%x, error %d, state %d\n",
+ printf("%s, so %p, tpcb %p, error %d, state %d\n",
"returning from tp_usrreq", so, tpcb, error,
tpcb ? tpcb->tp_state : 0);
}
struct tp_event E;
if (tpcb->tp_state == TP_CONFIRMING)
return DoEvent(T_ACPT_req);
- printf("Tp confirm called when not confirming; tpcb 0x%x, state 0x%x\n",
+ printf("Tp confirm called when not confirming; tpcb %p, state 0x%x\n",
tpcb, tpcb->tp_state);
return 0;
}
-/* $OpenBSD: ns_pcb.c,v 1.2 1996/03/04 08:20:29 niklas Exp $ */
-/* $NetBSD: ns_pcb.c,v 1.9 1996/02/13 22:14:02 christos Exp $ */
+/* $OpenBSD: ns_pcb.c,v 1.3 1996/04/21 22:30:11 deraadt Exp $ */
+/* $NetBSD: ns_pcb.c,v 1.10 1996/03/27 14:44:14 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
splx(s);
}
-#ifdef notdef
/*
* After a routing change, flush old routing
* and allocate a (hopefully) better one.
}
/* SHOULD NOTIFY HIGHER-LEVEL PROTOCOLS */
}
-#endif
struct nspcb *
ns_pcblookup(faddr, lport, wildp)
-/* $OpenBSD: ns_var.h,v 1.1 1996/03/04 08:20:32 niklas Exp $ */
+/* $OpenBSD: ns_var.h,v 1.2 1996/04/21 22:30:13 deraadt Exp $ */
#ifdef _KERNEL
struct socket;
void ns_setsockaddr __P((struct nspcb *, struct mbuf *));
void ns_setpeeraddr __P((struct nspcb *, struct mbuf *));
void ns_pcbnotify __P((struct ns_addr *, int, void (*)(struct nspcb *), long));
-int ns_rtchange __P((struct nspcb *));
+void ns_rtchange __P((struct nspcb *));
struct nspcb *ns_pcblookup __P((struct ns_addr *, u_short, int));
#endif
-/* $OpenBSD: spp_usrreq.c,v 1.2 1996/03/04 08:20:34 niklas Exp $ */
+/* $OpenBSD: spp_usrreq.c,v 1.3 1996/04/21 22:30:14 deraadt Exp $ */
/* $NetBSD: spp_usrreq.c,v 1.9 1996/02/13 22:14:13 christos Exp $ */
/*
return NULL;
type = NS_ERR_UNREACH_HOST;
+
switch (cmd) {
case PRC_ROUTEDEAD:
na = &sns->sns_addr;
break;
+ case PRC_REDIRECT_NET:
+ case PRC_REDIRECT_HOST:
+ case PRC_REDIRECT_TOSNET:
+ case PRC_REDIRECT_TOSHOST:
+ /*
+ * PRC_IS_REDIRECT: Call ns_rtchange to flush the route, so
+ * that the next time we attempt output we try a new one
+ * XXX: Is this the right way? ns_rtchange has a comment
+ * that needs to be fixed.
+ */
+ sns = (struct sockaddr_ns *) sa;
+ if (sns->sns_family != AF_NS)
+ return NULL;
+ na = &sns->sns_addr;
+ ns_pcbnotify(na, (int)nsctlerrmap[cmd], ns_rtchange, (long) 0);
+ return NULL;
+
default:
errp = arg;
na = &errp->ns_err_idp.idp_dna;
type = errp->ns_err_num;
type = ntohs((u_short)type);
+ break;
}
+
switch (type) {
case NS_ERR_UNREACH_HOST:
-/* $OpenBSD: krpc_subr.c,v 1.3 1996/04/17 04:50:22 mickey Exp $ */
-/* $NetBSD: krpc_subr.c,v 1.11 1995/12/19 23:07:19 cgd Exp $ */
+/* $OpenBSD: krpc_subr.c,v 1.4 1996/04/21 22:30:16 deraadt Exp $ */
+/* $NetBSD: krpc_subr.c,v 1.12 1996/02/18 11:53:36 fvdl Exp $ */
/*
* Copyright (c) 1995 Gordon Ross, Adam Glass
-/* $OpenBSD: nfs_bio.c,v 1.5 1996/04/17 04:50:24 mickey Exp $ */
+/* $OpenBSD: nfs_bio.c,v 1.6 1996/04/21 22:30:18 deraadt Exp $ */
/* $NetBSD: nfs_bio.c,v 1.25 1996/02/29 20:26:16 fvdl Exp $ */
/*
|| ((vp->v_flag & VROOT) && vp->v_type == VLNK)) {
switch (vp->v_type) {
case VREG:
- return nfs_readrpc(vp, uio, cred);
+ return (nfs_readrpc(vp, uio, cred));
case VLNK:
- return nfs_readlinkrpc(vp, uio, cred);
+ return (nfs_readlinkrpc(vp, uio, cred));
case VDIR:
break;
default:
vp->v_type);
};
}
- baddr = NULL;
+ baddr = (caddr_t)0;
switch (vp->v_type) {
case VREG:
nfsstats.biocache_reads++;
}
} else if ((n + on) == biosize &&
(nmp->nm_flag & NFSMNT_NQNFS) == 0) {
- bp->b_proc = (struct proc *)NULL;
+ bp->b_proc = (struct proc *)0;
bp->b_flags |= B_ASYNC;
(void)nfs_writebp(bp, 0);
} else {
if (nmp->nm_flag & NFSMNT_INT) {
bp = getblk(vp, bn, size, PCATCH, 0);
- while (bp == NULL) {
- if (nfs_sigintr(nmp, (struct nfsreq *)NULL, p))
- return ((struct buf *)NULL);
+ while (bp == (struct buf *)0) {
+ if (nfs_sigintr(nmp, (struct nfsreq *)0, p))
+ return ((struct buf *)0);
bp = getblk(vp, bn, size, 0, 2 * hz);
}
} else
np->n_flag |= NFLUSHWANT;
error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "nfsvinval",
slptimeo);
- if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)NULL, p))
+ if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p))
return (EINTR);
}
np->n_flag |= NFLUSHINPROG;
error = vinvalbuf(vp, flags, cred, p, slpflag, 0);
while (error) {
- if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)NULL, p)) {
+ if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p)) {
np->n_flag &= ~NFLUSHINPROG;
if (np->n_flag & NFLUSHWANT) {
np->n_flag &= ~NFLUSHWANT;
}
TAILQ_INSERT_TAIL(&nfs_bufq, bp, b_freelist);
- nfs_iodwant[i] = (struct proc *)NULL;
+ nfs_iodwant[i] = (struct proc *)0;
wakeup((caddr_t)&nfs_iodwant[i]);
return (0);
}
}
break;
case VLNK:
- uiop->uio_offset = (off_t)NULL;
+ uiop->uio_offset = (off_t)0;
nfsstats.readlink_bios++;
error = nfs_readlinkrpc(vp, uiop, cr);
break;
-/* $OpenBSD: nfs_node.c,v 1.5 1996/04/17 04:50:25 mickey Exp $ */
+/* $OpenBSD: nfs_node.c,v 1.6 1996/04/21 22:30:19 deraadt Exp $ */
/* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */
/*
if (ap->a_vp->v_type != VDIR)
sp = np->n_sillyrename;
else
- sp = NULL;
- np->n_sillyrename = NULL;
+ sp = (struct sillyrename *)0;
+ np->n_sillyrename = (struct sillyrename *)0;
if (sp) {
/*
* Remove the silly file that was rename'd earlier
cache_purge(vp);
FREE(vp->v_data, M_NFSNODE);
- vp->v_data = NULL;
+ vp->v_data = (void *)0;
return (0);
}
-/* $OpenBSD: nfs_nqlease.c,v 1.5 1996/04/17 04:50:26 mickey Exp $ */
+/* $OpenBSD: nfs_nqlease.c,v 1.6 1996/04/21 22:30:20 deraadt Exp $ */
/* $NetBSD: nfs_nqlease.c,v 1.14 1996/02/18 14:06:50 fvdl Exp $ */
/*
tlp = vp->v_lease;
if ((flags & ND_CHECK) == 0)
nfsstats.srvnqnfs_getleases++;
- if (tlp == NULL) {
+ if (tlp == 0) {
/*
* Find the lease by searching the hash list.
*/
}
} else
lp = tlp;
- if (lp != NULL) {
+ if (lp != 0) {
if ((lp->lc_flag & LC_NONCACHABLE) ||
- (lp->lc_morehosts == NULL &&
+ (lp->lc_morehosts == (struct nqm *)0 &&
nqsrv_cmpnam(slp, nam, &lp->lc_host)))
goto doreply;
if ((flags & ND_READ) && (lp->lc_flag & LC_WRITE) == 0) {
u_quad_t frev;
(void) nqsrv_getlease(ap->a_vp, &duration, ND_CHECK | ap->a_flag,
- NQLOCALSLP, ap->a_p, (struct mbuf *)NULL, &cache, &frev, ap->a_cred);
+ NQLOCALSLP, ap->a_p, (struct mbuf *)0, &cache, &frev, ap->a_cred);
return (0);
}
newexpiry = time.tv_sec + duration + nqsrv_clockskew;
if (lp->lc_expiry == newexpiry)
return;
- if (lp->lc_timer.cqe_next != NULL)
+ if (lp->lc_timer.cqe_next != 0)
CIRCLEQ_REMOVE(&nqtimerhead, lp, lc_timer);
lp->lc_expiry = newexpiry;
nam2 = lph->lph_nam;
so = nfs_cltpsock->ns_so;
} else if (lph->lph_slp->ns_flag & SLP_VALID) {
- nam2 = (struct mbuf *)NULL;
+ nam2 = (struct mbuf *)0;
so = lph->lph_slp->ns_so;
} else
goto nextone;
if (so->so_proto->pr_flags & PR_CONNREQUIRED)
solockp = &lph->lph_slp->ns_solock;
else
- solockp = (int *)NULL;
- nfsm_reqhead((struct vnode *)NULL, NQNFSPROC_EVICTED,
+ solockp = (int *)0;
+ nfsm_reqhead((struct vnode *)0, NQNFSPROC_EVICTED,
NFSX_V3FH);
nfsm_build(cp, caddr_t, NFSX_V3FH);
bzero(cp, NFSX_V3FH);
}
m = nfsm_rpchead(cred, (NFSMNT_NFSV3 | NFSMNT_NQNFS),
NQNFSPROC_EVICTED,
- RPCAUTH_UNIX, 5 * NFSX_UNSIGNED, NULL,
- 0, NULL, mreq, siz, &mheadend, &xid);
+ RPCAUTH_UNIX, 5 * NFSX_UNSIGNED, (char *)0,
+ 0, (char *)0, mreq, siz, &mheadend, &xid);
/*
* For stream protocols, prepend a Sun RPC
* Record Mark.
if (solockp)
*solockp |= NFSMNT_SNDLOCK;
(void) nfs_send(so, nam2, m,
- (struct nfsreq *)NULL);
+ (struct nfsreq *)0);
if (solockp)
nfs_sndunlock(solockp);
}
* recycled and has another valid lease reference,
* which is dereferenced prematurely.
*/
- lp->lc_vp->v_lease = (struct nqlease *)NULL;
+ lp->lc_vp->v_lease = (struct nqlease *)0;
lph = &lp->lc_host;
lphnext = lp->lc_morehosts;
- olphnext = (struct nqm *)NULL;
+ olphnext = (struct nqm *)0;
len = 1;
i = 0;
ok = 1;
if (++i == len) {
if (olphnext) {
free((caddr_t)olphnext, M_NQMHOST);
- olphnext = (struct nqm *)NULL;
+ olphnext = (struct nqm *)0;
}
if (lphnext) {
olphnext = lphnext;
caddr_t dpos = nfsd->nd_dpos;
register struct nqlease *lp;
register struct nqhost *lph;
- struct nqlease *tlp = NULL;
+ struct nqlease *tlp = (struct nqlease *)0;
nfsfh_t nfh;
fhandle_t *fhp;
register u_int32_t *tl;
tlp = lp;
break;
}
- if (tlp != NULL) {
+ if (tlp != 0) {
lp = tlp;
len = 1;
i = 0;
if (reqtime > time.tv_sec) {
fxdr_hyper(tl, &frev);
nqnfs_clientlease(nmp, np, rwflag, cachable, reqtime, frev);
- nfsm_loadattr(vp, (struct vattr *)NULL);
+ nfsm_loadattr(vp, (struct vattr *)0);
} else
error = NQNFS_EXPIRED;
nfsm_reqdone;
m = m->m_next;
}
m = nfsm_rpchead(cred, nmp->nm_flag, NQNFSPROC_VACATED,
- RPCAUTH_UNIX, 5 * NFSX_UNSIGNED, NULL,
- 0, NULL, mreq, i, &mheadend, &xid);
+ RPCAUTH_UNIX, 5 * NFSX_UNSIGNED, (char *)0,
+ 0, (char *)0, mreq, i, &mheadend, &xid);
if (nmp->nm_sotype == SOCK_STREAM) {
M_PREPEND(m, NFSX_UNSIGNED, M_WAIT);
*mtod(m, u_int32_t *) = htonl(0x80000000 | (m->m_pkthdr.len -
myrep.r_flags = 0;
myrep.r_nmp = nmp;
if (nmp->nm_soflags & PR_CONNREQUIRED)
- (void) nfs_sndlock(&nmp->nm_flag, (struct nfsreq *)NULL);
+ (void) nfs_sndlock(&nmp->nm_flag, (struct nfsreq *)0);
(void) nfs_send(nmp->nm_so, nmp->nm_nam, m, &myrep);
if (nmp->nm_soflags & PR_CONNREQUIRED)
nfs_sndunlock(&nmp->nm_flag);
struct nfssvc_sock *slp;
struct nfsrv_descript ndesc;
register struct nfsrv_descript *nfsd = &ndesc;
- struct mbuf **mrq = NULL, *mb, *mreq;
+ struct mbuf **mrq = (struct mbuf **)0, *mb, *mreq;
int error = 0, cache = 0;
char *cp2, *bpos;
u_quad_t frev;
nmp->nm_so->so_rcv.sb_cc > 0) {
myrep.r_flags = R_GETONEREP;
myrep.r_nmp = nmp;
- myrep.r_mrep = (struct mbuf *)NULL;
- myrep.r_procp = (struct proc *)NULL;
+ myrep.r_mrep = (struct mbuf *)0;
+ myrep.r_procp = (struct proc *)0;
(void) nfs_reply(&myrep);
}
-/* $OpenBSD: nfs_serv.c,v 1.5 1996/04/17 04:50:27 mickey Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.6 1996/04/21 22:30:23 deraadt Exp $ */
/* $NetBSD: nfs_serv.c,v 1.25 1996/03/02 15:55:52 jtk Exp $ */
/*
(nfsd->nd_flag & ND_KERBAUTH));
if (error) {
nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(1, (struct vattr *)NULL);
+ nfsm_srvpostop_attr(1, (struct vattr *)0);
return (0);
}
nfsmode = fxdr_unsigned(u_int32_t, *tl);
uiop->uio_resid = len;
uiop->uio_rw = UIO_READ;
uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = (struct proc *)NULL;
+ uiop->uio_procp = (struct proc *)0;
error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
&rdonly, (nfsd->nd_flag & ND_KERBAUTH));
if (error) {
m_freem(mp3);
nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvpostop_attr(1, (struct vattr *)NULL);
+ nfsm_srvpostop_attr(1, (struct vattr *)0);
return (0);
}
if (vp->v_type != VLNK) {
&rdonly, (nfsd->nd_flag & ND_KERBAUTH));
if (error) {
nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvpostop_attr(1, (struct vattr *)NULL);
+ nfsm_srvpostop_attr(1, (struct vattr *)0);
return (0);
}
if (vp->v_type != VREG) {
uiop->uio_resid = len;
uiop->uio_rw = UIO_WRITE;
uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = (struct proc *)NULL;
+ uiop->uio_procp = (struct proc *)0;
uiop->uio_offset = off;
error = VOP_WRITE(vp, uiop, ioflags, cred);
nfsstats.srvvop_writes++;
ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED);
uiop->uio_rw = UIO_WRITE;
uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = (struct proc *)NULL;
+ uiop->uio_procp = (struct proc *)0;
uiop->uio_offset = nfsd->nd_off;
uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off;
if (uiop->uio_resid > 0) {
procp);
else {
vrele(dirp);
- dirp = (struct vnode *)NULL;
+ dirp = (struct vnode *)0;
}
}
if (error) {
va.va_type == VFIFO) {
if (va.va_type == VCHR && rdev == 0xffffffff)
va.va_type = VFIFO;
- if ((error = suser(cred, NULL)) != 0) {
+ error = suser(cred, (u_short *)0);
+ if (error) {
vrele(nd.ni_startdir);
free(nd.ni_cnd.cn_pnbuf, M_NAMEI);
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
enum vtype vtyp;
char *cp2;
struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp, *dirp = NULL;
+ struct vnode *vp, *dirp = (struct vnode *)0;
nfsfh_t nfh;
fhandle_t *fhp;
u_quad_t frev;
if (!error)
FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI);
} else {
- if ((error = suser(cred, NULL)) != 0) {
+ error = suser(cred, (u_short *)0);
+ if (error) {
vrele(nd.ni_startdir);
free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI);
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
int v3 = (nfsd->nd_flag & ND_NFSV3);
char *cp2;
struct mbuf *mb, *mreq;
- struct vnode *vp = NULL, *dirp;
+ struct vnode *vp, *dirp;
struct vattr dirfor, diraft;
nfsfh_t nfh;
fhandle_t *fhp;
u_quad_t frev;
+#ifndef nolint
+ vp = (struct vnode *)0;
+#endif
fhp = &nfh.fh_generic;
nfsm_srvmtofh(fhp);
nfsm_srvnamesiz(len);
if (!error) {
vp = nd.ni_vp;
if (vp->v_type == VDIR &&
- (error = suser(cred, NULL)) != 0)
+ (error = suser(cred, (u_short *)0)) != 0)
goto out;
/*
* The root of a mounted filesystem cannot be deleted.
procp);
else {
vrele(fdirp);
- fdirp = (struct vnode *)NULL;
+ fdirp = (struct vnode *)0;
}
}
if (error) {
procp);
else {
vrele(tdirp);
- tdirp = (struct vnode *)NULL;
+ tdirp = (struct vnode *)0;
}
}
if (error) {
int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3);
char *cp2;
struct mbuf *mb, *mreq;
- struct vnode *vp, *xp, *dirp = NULL;
+ struct vnode *vp, *xp, *dirp = (struct vnode *)0;
struct vattr dirfor, diraft, at;
nfsfh_t nfh, dnfh;
fhandle_t *fhp, *dfhp;
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
return (0);
}
- if (vp->v_type == VDIR && (error = suser(cred, NULL)) != 0)
+ if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0)) != 0)
goto out1;
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameiop = CREATE;
procp);
else {
vrele(dirp);
- dirp = (struct vnode *)NULL;
+ dirp = (struct vnode *)0;
}
}
if (error)
int error = 0, cache, len, len2, dirfor_ret = 1, diraft_ret = 1;
int v3 = (nfsd->nd_flag & ND_NFSV3);
struct mbuf *mb, *mreq, *mb2;
- struct vnode *dirp = NULL;
+ struct vnode *dirp = (struct vnode *)0;
nfsfh_t nfh;
fhandle_t *fhp;
u_quad_t frev;
procp);
else {
vrele(dirp);
- dirp = (struct vnode *)NULL;
+ dirp = (struct vnode *)0;
}
}
if (error)
io.uio_iovcnt = 1;
io.uio_segflg = UIO_SYSSPACE;
io.uio_rw = UIO_READ;
- io.uio_procp = (struct proc *)NULL;
+ io.uio_procp = (struct proc *)0;
nfsm_mtouio(&io, len2);
if (!v3) {
nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
int v3 = (nfsd->nd_flag & ND_NFSV3);
char *cp2;
struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp, *dirp = NULL;
+ struct vnode *vp, *dirp = (struct vnode *)0;
nfsfh_t nfh;
fhandle_t *fhp;
u_quad_t frev;
procp);
else {
vrele(dirp);
- dirp = (struct vnode *)NULL;
+ dirp = (struct vnode *)0;
}
}
if (error) {
int v3 = (nfsd->nd_flag & ND_NFSV3);
char *cp2;
struct mbuf *mb, *mreq;
- struct vnode *vp, *dirp = (struct vnode *)NULL;
+ struct vnode *vp, *dirp = (struct vnode *)0;
struct vattr dirfor, diraft;
nfsfh_t nfh;
fhandle_t *fhp;
procp);
else {
vrele(dirp);
- dirp = (struct vnode *)NULL;
+ dirp = (struct vnode *)0;
}
}
if (error) {
io.uio_resid = fullsiz;
io.uio_segflg = UIO_SYSSPACE;
io.uio_rw = UIO_READ;
- io.uio_procp = (struct proc *)NULL;
+ io.uio_procp = (struct proc *)0;
eofflag = 0;
#ifdef Lite2_integrated
VOP_LOCK(vp, 0, procp);
io.uio_resid = fullsiz;
io.uio_segflg = UIO_SYSSPACE;
io.uio_rw = UIO_READ;
- io.uio_procp = (struct proc *)NULL;
+ io.uio_procp = (struct proc *)0;
eofflag = 0;
#ifdef Lite2_integrated
-/* $OpenBSD: nfs_socket.c,v 1.5 1996/04/17 04:50:29 mickey Exp $ */
-/* $NetBSD: nfs_socket.c,v 1.26 1996/02/25 17:47:26 fvdl Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.6 1996/04/21 22:30:26 deraadt Exp $ */
+/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
struct mbuf *m;
u_int16_t tport;
- nmp->nm_so = (struct socket *)NULL;
+ nmp->nm_so = (struct socket *)0;
saddr = mtod(nmp->nm_nam, struct sockaddr *);
error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype,
nmp->nm_soproto);
if (nmp->nm_so) {
so = nmp->nm_so;
- nmp->nm_so = (struct socket *)NULL;
+ nmp->nm_so = (struct socket *)0;
soshutdown(so, 2);
soclose(so);
}
} else
soflags = so->so_proto->pr_flags;
if ((soflags & PR_CONNREQUIRED) || (so->so_state & SS_ISCONNECTED))
- sendnam = (struct mbuf *)NULL;
+ sendnam = (struct mbuf *)0;
else
sendnam = nam;
if (so->so_type == SOCK_SEQPACKET)
else
flags = 0;
- error = sosend(so, sendnam, (struct uio *)NULL, top,
- (struct mbuf *)NULL, flags);
+ error = sosend(so, sendnam, (struct uio *)0, top,
+ (struct mbuf *)0, flags);
if (error) {
if (rep) {
log(LOG_INFO, "nfs send error %d for server %s\n",error,
/*
* Set up arguments for soreceive()
*/
- *mp = (struct mbuf *)NULL;
- *aname = (struct mbuf *)NULL;
+ *mp = (struct mbuf *)0;
+ *aname = (struct mbuf *)0;
sotype = rep->r_nmp->nm_sotype;
/*
auio.uio_procp = p;
do {
rcvflg = MSG_WAITALL;
- error = soreceive(so, (struct mbuf **)NULL, &auio,
- (struct mbuf **)NULL, (struct mbuf **)NULL, &rcvflg);
+ error = soreceive(so, (struct mbuf **)0, &auio,
+ (struct mbuf **)0, (struct mbuf **)0, &rcvflg);
if (error == EWOULDBLOCK && rep) {
if (rep->r_flags & R_SOFTTERM)
return (EINTR);
auio.uio_resid = len;
do {
rcvflg = MSG_WAITALL;
- error = soreceive(so, (struct mbuf **)NULL,
- &auio, mp, (struct mbuf **)NULL, &rcvflg);
+ error = soreceive(so, (struct mbuf **)0,
+ &auio, mp, (struct mbuf **)0, &rcvflg);
} while (error == EWOULDBLOCK || error == EINTR ||
error == ERESTART);
if (!error && auio.uio_resid > 0) {
auio.uio_procp = p;
do {
rcvflg = 0;
- error = soreceive(so, (struct mbuf **)NULL,
+ error = soreceive(so, (struct mbuf **)0,
&auio, mp, &control, &rcvflg);
if (control)
m_freem(control);
errout:
if (error && error != EINTR && error != ERESTART) {
m_freem(*mp);
- *mp = (struct mbuf *)NULL;
+ *mp = (struct mbuf *)0;
if (error != EPIPE)
log(LOG_INFO,
"receive error %d from nfs server %s\n",
if ((so = rep->r_nmp->nm_so) == NULL)
return (EACCES);
if (so->so_state & SS_ISCONNECTED)
- getnam = (struct mbuf **)NULL;
+ getnam = (struct mbuf **)0;
else
getnam = aname;
auio.uio_resid = len = 1000000;
do {
rcvflg = 0;
error = soreceive(so, getnam, &auio, mp,
- (struct mbuf **)NULL, &rcvflg);
+ (struct mbuf **)0, &rcvflg);
if (error == EWOULDBLOCK &&
(rep->r_flags & R_SOFTTERM))
return (EINTR);
}
if (error) {
m_freem(*mp);
- *mp = (struct mbuf *)NULL;
+ *mp = (struct mbuf *)0;
}
/*
* Search for any mbufs that are not a multiple of 4 bytes long
* Get the RPC header with authorization.
*/
kerbauth:
- verf_str = auth_str = (char *)NULL;
+ verf_str = auth_str = (char *)0;
if (nmp->nm_flag & NFSMNT_KERB) {
verf_str = nickv;
verf_len = sizeof (nickv);
else if ((nmp->nm_flag & NFSMNT_KERB) && *tl++ == rpc_autherr) {
if (!failed_auth) {
failed_auth++;
- mheadend->m_next = (struct mbuf *)NULL;
+ mheadend->m_next = (struct mbuf *)0;
m_freem(mrep);
m_freem(rep->r_mreq);
goto kerbauth;
register struct socket *so;
register struct nfsmount *nmp;
register int timeo;
- register struct nfssvc_sock *slp;
+ int s, error;
#ifdef NFSSERVER
+ register struct nfssvc_sock *slp;
static long lasttime = 0;
-#endif
- int s, error;
u_quad_t cur_usec;
+#endif
s = splsoftnet();
for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) {
(m = m_copym(rep->r_mreq, 0, M_COPYALL, M_DONTWAIT))){
if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
- (struct mbuf *)NULL, (struct mbuf *)NULL);
+ (struct mbuf *)0, (struct mbuf *)0);
else
error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
- nmp->nm_nam, (struct mbuf *)NULL);
+ nmp->nm_nam, (struct mbuf *)0);
if (error) {
if (NFSIGNORE_SOERROR(nmp->nm_soflags, error))
so->so_error = 0;
}
#endif /* NFSSERVER */
splx(s);
- timeout(nfs_timer, NULL, nfs_ticks);
+ timeout(nfs_timer, (void *)0, nfs_ticks);
}
/*
if (rep->r_nmp->nm_flag & NFSMNT_INT)
slpflag = PCATCH;
} else
- p = (struct proc *)NULL;
+ p = (struct proc *)0;
while (*flagp & NFSMNT_SNDLOCK) {
if (nfs_sigintr(rep->r_nmp, rep, p))
return (EINTR);
*/
auio.uio_resid = 1000000000;
flags = MSG_DONTWAIT;
- error = soreceive(so, &nam, &auio, &mp,
- (struct mbuf **)NULL, &flags);
- if (error || mp == NULL) {
+ error = soreceive(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
+ if (error || mp == (struct mbuf *)0) {
if (error == EWOULDBLOCK)
slp->ns_flag |= SLP_NEEDQ;
else
auio.uio_resid = 1000000000;
flags = MSG_DONTWAIT;
error = soreceive(so, &nam, &auio, &mp,
- (struct mbuf **)NULL, &flags);
+ (struct mbuf **)0, &flags);
if (mp) {
nfs_realign(mp, 10 * NFSX_UNSIGNED);
if (nam) {
else
slp->ns_rec = m;
slp->ns_recend = m;
- m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)0;
}
if (error) {
if ((so->so_proto->pr_flags & PR_CONNREQUIRED)
*/
if (slp->ns_cc == slp->ns_reclen) {
recm = slp->ns_raw;
- slp->ns_raw = slp->ns_rawend = (struct mbuf *)NULL;
+ slp->ns_raw = slp->ns_rawend = (struct mbuf *)0;
slp->ns_cc = slp->ns_reclen = 0;
} else if (slp->ns_cc > slp->ns_reclen) {
len = 0;
m = slp->ns_raw;
- om = (struct mbuf *)NULL;
+ om = (struct mbuf *)0;
while (len < slp->ns_reclen) {
if ((len + m->m_len) > slp->ns_reclen) {
m2 = m_copym(m, 0, slp->ns_reclen - len,
len += m->m_len;
m = m->m_next;
recm = slp->ns_raw;
- om->m_next = (struct mbuf *)NULL;
+ om->m_next = (struct mbuf *)0;
} else {
om = m;
len += m->m_len;
else
slp->ns_rec = slp->ns_frag;
slp->ns_recend = slp->ns_frag;
- slp->ns_frag = (struct mbuf *)NULL;
+ slp->ns_frag = (struct mbuf *)0;
}
}
}
*ndp = NULL;
if ((slp->ns_flag & SLP_VALID) == 0 ||
- (m = slp->ns_rec) == NULL)
+ (m = slp->ns_rec) == (struct mbuf *)0)
return (ENOBUFS);
slp->ns_rec = m->m_nextpkt;
if (slp->ns_rec)
- m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)0;
else
- slp->ns_recend = (struct mbuf *)NULL;
+ slp->ns_recend = (struct mbuf *)0;
if (m->m_type == MT_SONAME) {
nam = m;
m = m->m_next;
-/* $OpenBSD: nfs_srvcache.c,v 1.4 1996/04/17 04:50:30 mickey Exp $ */
+/* $OpenBSD: nfs_srvcache.c,v 1.5 1996/04/21 22:30:28 deraadt Exp $ */
/* $NetBSD: nfs_srvcache.c,v 1.12 1996/02/18 11:53:49 fvdl Exp $ */
/*
} else if (rp->rc_flag & RC_REPSTATUS) {
nfsstats.srvcache_nonidemdonehits++;
nfs_rephead(0, nd, slp, rp->rc_status,
- 0, (u_quad_t *)NULL, repp, &mb, &bpos);
+ 0, (u_quad_t *)0, repp, &mb, &bpos);
ret = RC_REPLY;
} else if (rp->rc_flag & RC_REPMBUF) {
nfsstats.srvcache_nonidemdonehits++;
-/* $OpenBSD: nfs_subs.c,v 1.6 1996/04/17 04:50:31 mickey Exp $ */
-/* $NetBSD: nfs_subs.c,v 1.26 1996/03/13 00:44:17 fvdl Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.7 1996/04/21 22:30:30 deraadt Exp $ */
+/* $NetBSD: nfs_subs.c,v 1.27 1996/04/03 23:25:36 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
}
mb->m_next = mrest;
mreq->m_pkthdr.len = authsiz + 10 * NFSX_UNSIGNED + mrest_len;
- mreq->m_pkthdr.rcvif = (struct ifnet *)NULL;
+ mreq->m_pkthdr.rcvif = (struct ifnet *)0;
*mbp = mb;
return (mreq);
}
#ifdef NFSCLIENT
/* Ensure async daemons disabled */
for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
- nfs_iodwant[i] = (struct proc *)NULL;
+ nfs_iodwant[i] = (struct proc *)0;
TAILQ_INIT(&nfs_bufq);
nfs_nhinit(); /* Init the nfsnode table */
#endif /* NFSCLIENT */
if (vp->v_type != vtyp) {
vp->v_type = vtyp;
if (vp->v_type == VFIFO) {
+#ifndef FIFO
+ return (EOPNOTSUPP);
+#else
extern int (**fifo_nfsv2nodeop_p) __P((void *));
vp->v_op = fifo_nfsv2nodeop_p;
+#endif /* FIFO */
}
if (vp->v_type == VCHR || vp->v_type == VBLK) {
vp->v_op = spec_nfsv2nodeop_p;
int error, rdonly;
struct componentname *cnp = &ndp->ni_cnd;
- *retdirp = (struct vnode *)NULL;
+ *retdirp = (struct vnode *)0;
MALLOC(cnp->cn_pnbuf, char *, len + 1, M_NAMEI, M_WAITOK);
/*
* Copy the name from the mbuf list to ndp->ni_pnbuf
* And call lookup() to do the real work
*/
cnp->cn_proc = p;
- if ((error = lookup(ndp)) != 0)
+ error = lookup(ndp);
+ if (error)
goto out;
/*
* Check for encountering a symbolic link
m = mp;
for (;;) {
count += m->m_len;
- if (m->m_next == (struct mbuf *)NULL)
+ if (m->m_next == (struct mbuf *)0)
break;
m = m->m_next;
}
struct ucred *credanon;
int error, exflags;
- *vpp = (struct vnode *)NULL;
+ *vpp = (struct vnode *)0;
#ifdef Lite2_integrated
mp = vfs_getvfs(&fhp->fh_fsid);
#else
dp->ndm_eocookie = 0;
LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list);
} else
- return ((nfsuint64 *)NULL);
+ return ((nfsuint64 *)0);
}
while (pos >= NFSNUMCOOKIES) {
pos -= NFSNUMCOOKIES;
if (dp->ndm_list.le_next) {
if (!add && dp->ndm_eocookie < NFSNUMCOOKIES &&
pos >= dp->ndm_eocookie)
- return ((nfsuint64 *)NULL);
+ return ((nfsuint64 *)0);
dp = dp->ndm_list.le_next;
} else if (add) {
MALLOC(dp2, struct nfsdmap *, sizeof (struct nfsdmap),
LIST_INSERT_AFTER(dp, dp2, ndm_list);
dp = dp2;
} else
- return ((nfsuint64 *)NULL);
+ return ((nfsuint64 *)0);
}
if (pos >= dp->ndm_eocookie) {
if (add)
dp->ndm_eocookie = pos + 1;
else
- return ((nfsuint64 *)NULL);
+ return ((nfsuint64 *)0);
}
return (&dp->ndm_cookies[pos]);
}
-/* $OpenBSD: nfs_syscalls.c,v 1.5 1996/04/17 04:50:33 mickey Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.6 1996/04/21 22:30:33 deraadt Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
* Get the client address for connected sockets.
*/
if (nfsdarg.name == NULL || nfsdarg.namelen == 0)
- nam = (struct mbuf *)NULL;
+ nam = (struct mbuf *)0;
else {
error = sockargs(&nam, nfsdarg.name, nfsdarg.namelen,
MT_SONAME);
malloc(sizeof (struct nfsuid), M_NFSUID,
M_WAITOK);
} else
- nuidp = (struct nfsuid *)NULL;
+ nuidp = (struct nfsuid *)0;
if ((slp->ns_flag & SLP_VALID) == 0) {
if (nuidp)
free((caddr_t)nuidp, M_NFSUID);
} else {
- if (nuidp == NULL) {
+ if (nuidp == (struct nfsuid *)0) {
nuidp = slp->ns_uidlruhead.tqh_first;
LIST_REMOVE(nuidp, nu_hash);
TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp,
int error, s;
so = (struct socket *)fp->f_data;
- tslp = (struct nfssvc_sock *)NULL;
+ tslp = (struct nfssvc_sock *)0;
/*
* Add it to the list, as required.
*/
writes_todo = 0;
#endif
s = splsoftnet();
- if (nfsd == NULL) {
+ if (nfsd == (struct nfsd *)0) {
nsd->nsd_nfsd = nfsd = (struct nfsd *)
malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK);
bzero((caddr_t)nfsd, sizeof (struct nfsd));
*/
for (;;) {
if ((nfsd->nfsd_flag & NFSD_REQINPROG) == 0) {
- while (nfsd->nfsd_slp == NULL &&
+ while (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
(nfsd_head_flag & NFSD_CHECKSLP) == 0) {
nfsd->nfsd_flag |= NFSD_WAITING;
nfsd_waiting++;
if (error)
goto done;
}
- if (nfsd->nfsd_slp == NULL &&
+ if (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
(nfsd_head_flag & NFSD_CHECKSLP) != 0) {
for (slp = nfssvc_sockhead.tqh_first; slp != 0;
slp = slp->ns_chain.tqe_next) {
if (slp == 0)
nfsd_head_flag &= ~NFSD_CHECKSLP;
}
- if ((slp = nfsd->nfsd_slp) == NULL)
+ if ((slp = nfsd->nfsd_slp) == (struct nfssvc_sock *)0)
continue;
if (slp->ns_flag & SLP_VALID) {
if (slp->ns_flag & SLP_DISCONN)
else if (slp->ns_flag & SLP_NEEDQ) {
slp->ns_flag &= ~SLP_NEEDQ;
(void) nfs_sndlock(&slp->ns_solock,
- NULL);
+ (struct nfsreq *)0);
nfsrv_rcv(slp->ns_so, (caddr_t)slp,
M_WAIT);
nfs_sndunlock(&slp->ns_solock);
free((caddr_t)nd, M_NFSRVDESC);
nd = NULL;
}
- nfsd->nfsd_slp = (struct nfssvc_sock *)NULL;
+ nfsd->nfsd_slp = (struct nfssvc_sock *)0;
nfsd->nfsd_flag &= ~NFSD_REQINPROG;
nfsrv_slpderef(slp);
continue;
if (so->so_proto->pr_flags & PR_CONNREQUIRED)
solockp = &slp->ns_solock;
else
- solockp = (int *)NULL;
+ solockp = (int *)0;
if (nd) {
nd->nd_starttime = time;
if (nd->nd_nam2)
}
nfsstats.srvrpccnt[nd->nd_procnum]++;
nfsrv_updatecache(nd, TRUE, mreq);
- nd->nd_mrep = (struct mbuf *)NULL;
+ nd->nd_mrep = (struct mbuf *)0;
case RC_REPLY:
m = mreq;
siz = 0;
}
m = mreq;
m->m_pkthdr.len = siz;
- m->m_pkthdr.rcvif = (struct ifnet *)NULL;
+ m->m_pkthdr.rcvif = (struct ifnet *)0;
/*
* For stream protocols, prepend a Sun RPC
* Record Mark.
*mtod(m, u_int32_t *) = htonl(0x80000000 | siz);
}
if (solockp)
- (void) nfs_sndlock(solockp, (struct nfsreq *)NULL);
+ (void) nfs_sndlock(solockp, (struct nfsreq *)0);
if (slp->ns_flag & SLP_VALID)
error = nfs_send(so, nd->nd_nam2, m, NULL);
else {
TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain);
splx(s);
free((caddr_t)nfsd, M_NFSD);
- nsd->nsd_nfsd = (struct nfsd *)NULL;
+ nsd->nsd_nfsd = (struct nfsd *)0;
if (--nfs_numnfsd == 0)
nfsrv_init(TRUE); /* Reinitialize everything */
return (error);
slp->ns_flag &= ~SLP_ALLFLAGS;
fp = slp->ns_fp;
if (fp) {
- slp->ns_fp = (struct file *)NULL;
+ slp->ns_fp = (struct file *)0;
so = slp->ns_so;
so->so_upcall = NULL;
soshutdown(so, 2);
- closef(fp, (struct proc *)NULL);
+ closef(fp, (struct proc *)0);
if (slp->ns_nam)
MFREE(slp->ns_nam, m);
m_freem(slp->ns_raw);
/* Take one off the front of the list */
TAILQ_REMOVE(&nfs_bufq, bp, b_freelist);
if (bp->b_flags & B_READ)
- (void) nfs_doio(bp, bp->b_rcred, (struct proc *)NULL);
+ (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
else do {
/*
* Look for a delayed write for the same vnode, so I can do
reassignbuf(nbp, nbp->b_vp);
nbp->b_vp->v_numoutput++;
}
- (void) nfs_doio(bp, bp->b_wcred, (struct proc *)NULL);
+ (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);
} while ((bp = nbp) != NULL);
}
if (error) {
-/* $OpenBSD: nfs_vfsops.c,v 1.7 1996/04/17 04:50:34 mickey Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.8 1996/04/21 22:30:34 deraadt Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46 1996/03/24 23:58:10 fvdl Exp $ */
/*
if (nmp->nm_so && adjsock) {
nfs_disconnect(nmp);
if (nmp->nm_sotype == SOCK_DGRAM)
- while (nfs_connect(nmp, (struct nfsreq *)NULL)) {
+ while (nfs_connect(nmp, (struct nfsreq *)0)) {
printf("nfs_args: retrying connect\n");
(void) tsleep((caddr_t)&lbolt,
PSOCK, "nfscon", 0);
* the first request, in case the server is not responding.
*/
if (nmp->nm_sotype == SOCK_DGRAM &&
- (error = nfs_connect(nmp, (struct nfsreq *)NULL)))
+ (error = nfs_connect(nmp, (struct nfsreq *)0)))
goto bad;
/*
-/* $OpenBSD: nfs_vnops.c,v 1.6 1996/04/17 04:50:35 mickey Exp $ */
-/* $NetBSD: nfs_vnops.c,v 1.60 1996/03/05 05:30:09 jtk Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.7 1996/04/21 22:30:36 deraadt Exp $ */
+/* $NetBSD: nfs_vnops.c,v 1.61 1996/04/03 23:25:42 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
struct vnodeopv_desc spec_nfsv2nodeop_opv_desc =
{ &spec_nfsv2nodeop_p, spec_nfsv2nodeop_entries };
+#ifdef FIFO
int (**fifo_nfsv2nodeop_p) __P((void *));
struct vnodeopv_entry_desc fifo_nfsv2nodeop_entries[] = {
{ &vop_default_desc, vn_default_error },
};
struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc =
{ &fifo_nfsv2nodeop_p, fifo_nfsv2nodeop_entries };
+#endif /* FIFO */
/*
* Global variables
vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) &&
(vp->v_mount->mnt_flag & MNT_RDONLY))
return (EROFS);
-
if (vap->va_size != VNOVAL) {
switch (vp->v_type) {
case VDIR:
*/
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (EROFS);
- error = nfs_vinvalbuf(vp,
- ((vap->va_size == 0)? 0 : V_SAVE),
+ if (vap->va_size == 0)
+ error = nfs_vinvalbuf(vp, 0,
+ ap->a_cred, ap->a_p, 1);
+ else
+ error = nfs_vinvalbuf(vp, V_SAVE,
ap->a_cred, ap->a_p, 1);
if (error)
return (error);
(error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred,
ap->a_p, 1)) == EINTR)
return (error);
-
error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_p);
if (error && vap->va_size != VNOVAL) {
np->n_size = np->n_vattr.va_size = tsize;
if (v3) {
nfsm_wcc_data(vp, wccflag);
} else
- nfsm_loadattr(vp, (struct vattr *)NULL);
+ nfsm_loadattr(vp, (struct vattr *)0);
nfsm_reqdone;
return (error);
}
nfsm_postop_attr(newvp, attrflag);
nfsm_postop_attr(dvp, attrflag);
} else
- nfsm_loadattr(newvp, (struct vattr *)NULL);
+ nfsm_loadattr(newvp, (struct vattr *)0);
*vpp = newvp;
m_freem(mrep);
cnp->cn_flags |= SAVENAME;
nfsm_postop_attr(newvp, attrflag);
nfsm_postop_attr(dvp, attrflag);
} else
- nfsm_loadattr(newvp, (struct vattr *)NULL);
+ nfsm_loadattr(newvp, (struct vattr *)0);
if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
cnp->cn_flags |= SAVENAME;
if ((cnp->cn_flags & MAKEENTRY) &&
nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
eof = fxdr_unsigned(int, *(tl + 1));
} else
- nfsm_loadattr(vp, (struct vattr *)NULL);
+ nfsm_loadattr(vp, (struct vattr *)0);
nfsm_strsiz(retlen, nmp->nm_rsize);
nfsm_mtouio(uiop, retlen);
m_freem(mrep);
}
}
} else
- nfsm_loadattr(vp, (struct vattr *)NULL);
+ nfsm_loadattr(vp, (struct vattr *)0);
if (wccflag)
VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime.tv_sec;
m_freem(mrep);
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
- struct vnode *newvp = NULL;
+ struct vnode *newvp = (struct vnode *)0;
struct nfsnode *np;
char *cp2;
caddr_t bpos, dpos;
if (!gotvp) {
if (newvp) {
vrele(newvp);
- newvp = (struct vnode *)NULL;
+ newvp = (struct vnode *)0;
}
error = nfs_lookitup(dvp, cnp->cn_nameptr,
cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np);
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
- struct nfsnode *np = NULL;
- struct vnode *newvp = NULL;
+ struct nfsnode *np = (struct nfsnode *)0;
+ struct vnode *newvp = (struct vnode *)0;
caddr_t bpos, dpos, cp2;
int error = 0, wccflag = NFSV3_WCCRATTR, gotvp = 0, fmode = 0;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
if (!gotvp) {
if (newvp) {
vrele(newvp);
- newvp = (struct vnode *)NULL;
+ newvp = (struct vnode *)0;
}
error = nfs_lookitup(dvp, cnp->cn_nameptr,
cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np);
{
return (nfs_removerpc(sp->s_dvp, sp->s_name, sp->s_namlen, sp->s_cred,
- (struct proc *)NULL));
+ (struct proc *)0));
}
/*
caddr_t bpos, dpos, cp2;
int slen, error = 0, wccflag = NFSV3_WCCRATTR, gotvp;
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct vnode *newvp = NULL;
+ struct vnode *newvp = (struct vnode *)0;
int v3 = NFS_ISV3(dvp);
nfsstats.rpccnt[NFSPROC_SYMLINK]++;
register caddr_t cp;
register int32_t t1, t2;
register int len;
- struct nfsnode *np = NULL;
- struct vnode *newvp = NULL;
+ struct nfsnode *np = (struct nfsnode *)0;
+ struct vnode *newvp = (struct vnode *)0;
caddr_t bpos, dpos, cp2;
int error = 0, wccflag = NFSV3_WCCRATTR;
int gotvp = 0;
if (error == EEXIST || (!error && !gotvp)) {
if (newvp) {
vrele(newvp);
- newvp = (struct vnode *)NULL;
+ newvp = (struct vnode *)0;
}
error = nfs_lookitup(dvp, cnp->cn_nameptr, len, cnp->cn_cred,
cnp->cn_proc, &np);
dpos = dpossav1;
mdsav2 = md;
md = mdsav1;
- nfsm_loadattr(newvp, (struct vattr *)NULL);
+ nfsm_loadattr(newvp, (struct vattr *)0);
dpos = dpossav2;
md = mdsav2;
dp->d_type =
/* Try lookitups until we get one that isn't there */
while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred,
- cnp->cn_proc, (struct nfsnode **)NULL) == 0) {
+ cnp->cn_proc, (struct nfsnode **)0) == 0) {
sp->s_name[4]++;
if (sp->s_name[4] > 'z') {
error = EINVAL;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
- struct vnode *newvp = NULL;
+ struct vnode *newvp = (struct vnode *)0;
struct nfsnode *np, *dnp = VTONFS(dvp);
caddr_t bpos, dpos, cp2;
int error = 0, fhlen, attrflag;
return (ENOENT);
}
} else
- nfsm_loadattr(newvp, (struct vattr *)NULL);
+ nfsm_loadattr(newvp, (struct vattr *)0);
}
nfsm_reqdone;
if (npp && *npp == NULL) {
if ((bp->b_flags & (B_PHYS|B_ASYNC)) == (B_PHYS|B_ASYNC))
panic("nfs physio/async");
if (bp->b_flags & B_ASYNC)
- p = (struct proc *)NULL;
+ p = (struct proc *)0;
else
p = curproc; /* XXX */
if (bp->b_flags & B_READ)
"nfsfsync", slptimeo);
splx(s);
if (error) {
- if (nfs_sigintr(nmp, (struct nfsreq *)NULL, p))
+ if (nfs_sigintr(nmp, (struct nfsreq *)0, p))
return (EINTR);
if (slpflag == PCATCH) {
slpflag = 0;
error = tsleep((caddr_t)&vp->v_numoutput,
slpflag | (PRIBIO + 1), "nfsfsync", slptimeo);
if (error) {
- if (nfs_sigintr(nmp, (struct nfsreq *)NULL, p))
+ if (nfs_sigintr(nmp, (struct nfsreq *)0, p))
return (EINTR);
if (slpflag == PCATCH) {
slpflag = 0;
printf("tag VT_NFS, fileid %ld fsid 0x%lx",
np->n_vattr.va_fileid, np->n_vattr.va_fsid);
+#ifdef FIFO
if (vp->v_type == VFIFO)
fifo_printinfo(vp);
+#endif
printf("\n");
return (0);
}
return (VOCALL(spec_vnodeop_p, VOFFSET(vop_close), ap));
}
+#ifdef FIFO
/*
* Read wrapper for fifos.
*/
}
return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap));
}
+#endif /* ! FIFO */
-/* $OpenBSD: nfsm_subs.h,v 1.5 1996/04/17 04:50:38 mickey Exp $ */
/* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */
/*
nfsm_adv(NFSX_V3FATTR); \
} \
if (f) \
- nfsm_loadattr((v), (struct vattr *)NULL); \
+ nfsm_loadattr((v), (struct vattr *)0); \
}
#define nfsm_getfh(f, s, v3) \
nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
- (struct vattr *)NULL)) != 0) { \
+ (struct vattr *)0)) != 0) { \
error = t1; \
(f) = 0; \
m_freem(mrep); \
-/* $NetBSD: cd.c,v 1.82 1996/02/14 21:46:52 christos Exp $ */
+/* $NetBSD: cd.c,v 1.90 1996/03/30 21:44:50 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
#include <sys/cdio.h>
#include <sys/proc.h>
#include <sys/cpu.h>
+#include <sys/conf.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_cd.h>
#include <scsi/scsi_disk.h> /* rw_big and start_stop come from there */
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
-#define CDOUTSTANDING 2
+#define CDOUTSTANDING 4
#define CDRETRIES 1
#define CDUNIT(z) DISKUNIT(z)
#define CDF_WANTED 0x02
#define CDF_WLABEL 0x04 /* label is writable */
#define CDF_LABELLING 0x08 /* writing label */
+#define CDF_ANCIENT 0x10 /* disk is ancient; for minphys */
struct scsi_link *sc_link; /* contains our targ, lun, etc. */
struct cd_parms {
int blksize;
int ));
int cd_get_parms __P((struct cd_softc *, int));
-struct cfdriver cdcd = {
- NULL, "cd", cdmatch, cdattach, DV_DISK, sizeof(struct cd_softc)
+struct cfattach cd_ca = {
+ sizeof(struct cd_softc), cdmatch, cdattach
+};
+
+struct cfdriver cd_cd = {
+ NULL, "cd", DV_DISK
};
struct dkdriver cddkdriver = { cdstrategy };
cd->sc_dk.dk_name = cd->sc_dev.dv_xname;
disk_attach(&cd->sc_dk);
-#if !defined(i386) || defined(NEWCONFIG)
+#if !defined(i386)
dk_establish(&cd->sc_dk, &cd->sc_dev); /* XXX */
#endif
+ /*
+ * Note if this device is ancient. This is used in cdminphys().
+ */
+ if ((sa->sa_inqbuf->version & SID_ANSII) == 0)
+ cd->flags |= CDF_ANCIENT;
+
printf("\n");
}
int error;
unit = CDUNIT(dev);
- if (unit >= cdcd.cd_ndevs)
+ if (unit >= cd_cd.cd_ndevs)
return ENXIO;
- cd = cdcd.cd_devs[unit];
+ cd = cd_cd.cd_devs[unit];
if (!cd)
return ENXIO;
SC_DEBUG(sc_link, SDEV_DB1,
("cdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
- cdcd.cd_ndevs, part));
+ cd_cd.cd_ndevs, part));
if ((error = cdlock(cd)) != 0)
return error;
int flag, fmt;
struct proc *p;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
int part = CDPART(dev);
int error;
cdstrategy(bp)
struct buf *bp;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(bp->b_dev)];
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(bp->b_dev)];
int opri;
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cdstrategy "));
bzero(&cmd_small, sizeof(cmd_small));
cmd_small.opcode = (bp->b_flags & B_READ) ?
READ_COMMAND : WRITE_COMMAND;
- cmd_small.addr_2 = (blkno >> 16) & 0x1f;
- cmd_small.addr_1 = (blkno >> 8) & 0xff;
- cmd_small.addr_0 = blkno & 0xff;
+ _lto3b(blkno, cmd_small.addr);
cmd_small.length = nblks & 0xff;
cmdlen = sizeof(cmd_small);
cmdp = (struct scsi_generic *)&cmd_small;
bzero(&cmd_big, sizeof(cmd_big));
cmd_big.opcode = (bp->b_flags & B_READ) ?
READ_BIG : WRITE_BIG;
- cmd_big.addr_3 = (blkno >> 24) & 0xff;
- cmd_big.addr_2 = (blkno >> 16) & 0xff;
- cmd_big.addr_1 = (blkno >> 8) & 0xff;
- cmd_big.addr_0 = blkno & 0xff;
- cmd_big.length2 = (nblks >> 8) & 0xff;
- cmd_big.length1 = nblks & 0xff;
+ _lto4b(blkno, cmd_big.addr);
+ _lto2b(nblks, cmd_big.length);
cmdlen = sizeof(cmd_big);
cmdp = (struct scsi_generic *)&cmd_big;
}
return (0);
}
+void
+cdminphys(bp)
+ struct buf *bp;
+{
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(bp->b_dev)];
+ long max;
+
+ /*
+ * If the device is ancient, we want to make sure that
+ * the transfer fits into a 6-byte cdb.
+ *
+ * XXX Note that the SCSI-I spec says that 256-block transfers
+ * are allowed in a 6-byte read/write, and are specified
+ * by settng the "length" to 0. However, we're conservative
+ * here, allowing only 255-block transfers in case an
+ * ancient device gets confused by length == 0. A length of 0
+ * in a 10-byte read/write actually means 0 blocks.
+ */
+ if (cd->flags & CDF_ANCIENT) {
+ max = cd->sc_dk.dk_label->d_secsize * 0xff;
+
+ if (bp->b_bcount > max)
+ bp->b_bcount = max;
+ }
+
+ (*cd->sc_link->adapter->scsi_minphys)(bp);
+}
+
int
cdread(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
int ioflag;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
- return (physio(cdstrategy, NULL, dev, B_READ,
- cd->sc_link->adapter->scsi_minphys, uio));
+ return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
}
int
struct uio *uio;
int ioflag;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
- return (physio(cdstrategy, NULL, dev, B_WRITE,
- cd->sc_link->adapter->scsi_minphys, uio));
+ return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
}
/*
int flag;
struct proc *p;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
int error;
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cdioctl 0x%lx ", cmd));
&data, len);
if (error)
return error;
- len = min(len, ((data.header.data_len[0] << 8) +
- data.header.data_len[1] +
- sizeof(struct cd_sub_channel_header)));
+ len = min(len, _2btol(data.header.data_len) +
+ sizeof(struct cd_sub_channel_header));
return copyout(&data, args->data, len);
}
case CDIOREADTOCHEADER: {
2000, NULL, flags | SCSI_DATA_IN) != 0)
return 0;
- blksize = (rdcap.length_3 << 24) + (rdcap.length_2 << 16) +
- (rdcap.length_1 << 8) + rdcap.length_0;
+ blksize = _4btol(rdcap.length);
if (blksize < 512)
blksize = 2048; /* some drives lie ! */
cd->params.blksize = blksize;
- size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) +
- (rdcap.addr_1 << 8) + rdcap.addr_0 + 1;
+ size = _4btol(rdcap.addr) + 1;
if (size < 100)
size = 400000; /* ditto */
cd->params.disksize = size;
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = PLAY;
- scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff;
- scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff;
- scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff;
- scsi_cmd.blk_addr[3] = blkno & 0xff;
- scsi_cmd.xfer_len[0] = (nblks >> 8) & 0xff;
- scsi_cmd.xfer_len[1] = nblks & 0xff;
+ _lto4b(blkno, scsi_cmd.blk_addr);
+ _lto2b(nblks, scsi_cmd.xfer_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), 0, 0, CDRETRIES, 200000, NULL, 0);
}
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = PLAY_BIG;
- scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff;
- scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff;
- scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff;
- scsi_cmd.blk_addr[3] = blkno & 0xff;
- scsi_cmd.xfer_len[0] = (nblks >> 24) & 0xff;
- scsi_cmd.xfer_len[1] = (nblks >> 16) & 0xff;
- scsi_cmd.xfer_len[2] = (nblks >> 8) & 0xff;
- scsi_cmd.xfer_len[3] = nblks & 0xff;
+ _lto4b(blkno, scsi_cmd.blk_addr);
+ _lto4b(nblks, scsi_cmd.xfer_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), 0, 0, CDRETRIES, 20000, NULL, 0);
}
scsi_cmd.byte3 = SRS_SUBQ;
scsi_cmd.subchan_format = format;
scsi_cmd.track = track;
- scsi_cmd.data_len[0] = (len >> 8) & 0xff;
- scsi_cmd.data_len[1] = len & 0xff;
+ _lto2b(len, scsi_cmd.data_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_subchannel), (u_char *)data, len,
CDRETRIES, 5000, NULL, SCSI_DATA_IN);
if (mode == CD_MSF_FORMAT)
scsi_cmd.byte2 |= CD_MSF;
scsi_cmd.from_track = start;
- scsi_cmd.data_len[0] = (ntoc >> 8) & 0xff;
- scsi_cmd.data_len[1] = ntoc & 0xff;
+ _lto2b(ntoc, scsi_cmd.data_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_toc), (u_char *)data, len, CDRETRIES,
5000, NULL, SCSI_DATA_IN);
-/* $OpenBSD: ch.c,v 1.3 1996/04/19 16:10:12 niklas Exp $ */
-/* $NetBSD: ch.c,v 1.16 1996/03/05 00:15:09 thorpej Exp $ */
+/* $OpenBSD: ch.c,v 1.4 1996/04/21 22:30:45 deraadt Exp $ */
+/* $NetBSD: ch.c,v 1.20 1996/04/03 00:25:39 thorpej Exp $ */
/*
- * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
+ * All rights reserved.
+ *
+ * Partially based on an autochanger driver written by Stefan Grefen
+ * and on an autochanger driver written by the Systems Programming Group
+ * at the University of Utah Computer Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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 Charles Hannum.
+ * must display the following acknowledgements:
+ * This product includes software developed by Jason R. Thorpe
+ * for And Communications, http://www.and.com/
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* 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.
- */
-
-/*
- * Originally written by grefen@?????
- * Based on scsi drivers by Julian Elischer (julian@tfs.com)
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/user.h>
-#include <sys/chio.h>
+#include <sys/chio.h>
#include <sys/device.h>
+#include <sys/malloc.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_changer.h>
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
-#define CHRETRIES 2
-
-#define CHMODE(z) (minor(z) & 0x0f)
-#define CHUNIT(z) (minor(z) >> 4)
+#define CHRETRIES 2
+#define CHUNIT(x) (minor((x)))
struct ch_softc {
- struct device sc_dev;
-
- struct scsi_link *sc_link; /* all the inter level info */
- u_int16_t chmo; /* Offset of first CHM */
- u_int16_t chms; /* No. of CHM */
- u_int16_t slots; /* No. of Storage Elements */
- u_int16_t sloto; /* Offset of first SE */
- u_int16_t imexs; /* No. of Import/Export Slots */
- u_int16_t imexo; /* Offset of first IM/EX */
- u_int16_t drives; /* No. of CTS */
- u_int16_t driveo; /* Offset of first CTS */
- u_int16_t rot; /* CHM can rotate */
- u_long op_matrix; /* possible operations */
- u_int16_t lsterr; /* details of lasterror */
- u_char stor; /* posible Storage locations */
+ struct device sc_dev; /* generic device info */
+ struct scsi_link *sc_link; /* link in the SCSI bus */
+
+ int sc_picker; /* current picker */
+
+ /*
+ * The following information is obtained from the
+ * element address assignment page.
+ */
+ int sc_firsts[4]; /* firsts, indexed by CHET_* */
+ int sc_counts[4]; /* counts, indexed by CHET_* */
+
+ /*
+ * The following mask defines the legal combinations
+ * of elements for the MOVE MEDIUM command.
+ */
+ u_int8_t sc_movemask[4];
+
+ /*
+ * As above, but for EXCHANGE MEDIUM.
+ */
+ u_int8_t sc_exchangemask[4];
+
+ int flags; /* misc. info */
};
+/* sc_flags */
+#define CHF_ROTATE 0x01 /* picker can rotate */
+
+/* Autoconfiguration glue */
int chmatch __P((struct device *, void *, void *));
void chattach __P((struct device *, struct device *, void *));
-int ch_getelem __P((struct ch_softc *, short *, int, int , char *, int));
-int ch_move __P((struct ch_softc *, short *, int, int , int , int ));
-int ch_position __P((struct ch_softc *, short *, int, int , int ));
-int ch_mode_sense __P((struct ch_softc *, int));
-struct cfdriver chcd = {
- NULL, "ch", chmatch, chattach, DV_DULL, sizeof(struct ch_softc)
+struct cfattach ch_ca = {
+ sizeof(struct ch_softc), chmatch, chattach
};
-/*
- * This driver is so simple it uses all the default services
- */
-struct scsi_device ch_switch = {
- NULL,
- NULL,
- NULL,
- NULL,
+struct cfdriver ch_cd = {
+ NULL, "ch", DV_DULL
};
struct scsi_inquiry_pattern ch_patterns[] = {
{T_CHANGER, T_REMOV,
- "", "", ""},
+ "", "", ""},
};
+/* SCSI glue */
+struct scsi_device ch_switch = {
+ NULL, NULL, NULL, NULL
+};
+
+int ch_move __P((struct ch_softc *, struct changer_move *));
+int ch_exchange __P((struct ch_softc *, struct changer_exchange *));
+int ch_position __P((struct ch_softc *, struct changer_position *));
+int ch_usergetelemstatus __P((struct ch_softc *, int, u_int8_t *));
+int ch_getelemstatus __P((struct ch_softc *, int, int, caddr_t, size_t));
+int ch_get_params __P((struct ch_softc *, int));
+
int
chmatch(parent, match, aux)
struct device *parent;
(void)scsi_inqmatch(sa->sa_inqbuf,
(caddr_t)ch_patterns, sizeof(ch_patterns)/sizeof(ch_patterns[0]),
sizeof(ch_patterns[0]), &priority);
+
return (priority);
}
-/*
- * The routine called by the low level scsi routine when it discovers
- * a device suitable for this driver.
- */
-void
+void
chattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
- struct ch_softc *ch = (void *)self;
+ struct ch_softc *sc = (struct ch_softc *)self;
struct scsibus_attach_args *sa = aux;
- struct scsi_link *sc_link = sa->sa_sc_link;
+ struct scsi_link *link = sa->sa_sc_link;
- SC_DEBUG(sc_link, SDEV_DB2, ("chattach: "));
+ /* Glue into the SCSI bus */
+ sc->sc_link = link;
+ link->device = &ch_switch;
+ link->device_softc = sc;
+ link->openings = 1;
- /*
- * Store information needed to contact our base driver
- */
- ch->sc_link = sc_link;
- sc_link->device = &ch_switch;
- sc_link->device_softc = ch;
- sc_link->openings = 1;
+ printf("\n");
/*
- * Use the subdriver to request information regarding
- * the drive. We cannot use interrupts yet, so the
- * request must specify this.
+ * Get information about the device. Note we can't use
+ * interrupts yet.
*/
- printf("\n");
- printf("%s: ", ch->sc_dev.dv_xname);
- if (ch_mode_sense(ch, SCSI_AUTOCONF) != 0)
- printf("offline\n");
- else
- printf("%d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
- ch->slots, ch->drives, ch->chms, ch->imexs);
+ if (ch_get_params(sc, SCSI_AUTOCONF))
+ printf("%s: offline\n", sc->sc_dev.dv_xname);
+ else {
+ printf("%s: %d slot%s, %d drive%s, %d picker%s",
+ sc->sc_dev.dv_xname,
+ sc->sc_counts[CHET_ST], (sc->sc_counts[CHET_ST] > 1) ?
+ "s" : "",
+ sc->sc_counts[CHET_DT], (sc->sc_counts[CHET_DT] > 1) ?
+ "s" : "",
+ sc->sc_counts[CHET_MT], (sc->sc_counts[CHET_MT] > 1) ?
+ "s" : "");
+ if (sc->sc_counts[CHET_IE])
+ printf(", %d portal%s", sc->sc_counts[CHET_IE],
+ (sc->sc_counts[CHET_IE] > 1) ? "s" : "");
+ printf("\n");
+#ifdef CHANGER_DEBUG
+ printf("%s: move mask: 0x%x 0x%x 0x%x 0x%x\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_movemask[CHET_MT], sc->sc_movemask[CHET_ST],
+ sc->sc_movemask[CHET_IE], sc->sc_movemask[CHET_DT]);
+ printf("%s: exchange mask: 0x%x 0x%x 0x%x 0x%x\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_exchangemask[CHET_MT], sc->sc_exchangemask[CHET_ST],
+ sc->sc_exchangemask[CHET_IE], sc->sc_exchangemask[CHET_DT]);
+#endif /* CHANGER_DEBUG */
+ }
+
+ /* Default the current picker. */
+ sc->sc_picker = sc->sc_firsts[CHET_MT];
}
-/*
- * open the device.
- */
-int
-chopen(dev, flags, mode, p)
+int
+chopen(dev, flags, fmt, p)
dev_t dev;
- int flags;
- int mode;
+ int flags, fmt;
struct proc *p;
{
- int error = 0;
- int unit;
- struct ch_softc *ch;
- struct scsi_link *sc_link;
+ struct ch_softc *sc;
+ int unit, error = 0;
unit = CHUNIT(dev);
- if (unit >= chcd.cd_ndevs)
- return ENXIO;
- ch = chcd.cd_devs[unit];
- if (!ch)
- return ENXIO;
-
- sc_link = ch->sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB1,
- ("chopen: dev=0x%x (unit %d (of %d))\n", dev, unit, chcd.cd_ndevs));
+ if ((unit >= ch_cd.cd_ndevs) ||
+ ((sc = ch_cd.cd_devs[unit]) == NULL))
+ return (ENXIO);
/*
- * Only allow one at a time
+ * Only allow one open at a time.
*/
- if (sc_link->flags & SDEV_OPEN) {
- printf("%s: already open\n", ch->sc_dev.dv_xname);
- return EBUSY;
- }
+ if (sc->sc_link->flags & SDEV_OPEN)
+ return (EBUSY);
+
+ sc->sc_link->flags |= SDEV_OPEN;
/*
- * Catch any unit attention errors.
+ * Absorb any unit attention errors. Ignore "not ready"
+ * since this might occur if e.g. a tape isn't actually
+ * loaded in the drive.
*/
- error = scsi_test_unit_ready(sc_link, SCSI_IGNORE_MEDIA_CHANGE);
- if (error)
+ if (error = scsi_test_unit_ready(sc->sc_link,
+ SCSI_IGNORE_NOT_READY|SCSI_IGNORE_MEDIA_CHANGE))
goto bad;
- sc_link->flags |= SDEV_OPEN; /* unit attn are now errors */
-
/*
- * Make sure data is loaded
+ * Make sure our parameters are up to date.
*/
- if ((error = ch_mode_sense(ch, 0)) != 0) {
- printf("%s: offline\n", ch->sc_dev.dv_xname);
+ if (error = ch_get_params(sc, 0))
goto bad;
- }
- SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
- return 0;
+ return (0);
-bad:
- sc_link->flags &= ~SDEV_OPEN;
- return error;
+ bad:
+ sc->sc_link->flags &= ~SDEV_OPEN;
+ return (error);
}
-/*
- * close the device.. only called if we are the LAST
- * occurence of an open device
- */
-int
-chclose(dev, flags, mode, p)
+int
+chclose(dev, flags, fmt, p)
dev_t dev;
- int flags;
- int mode;
+ int flags, fmt;
struct proc *p;
{
- struct ch_softc *ch = chcd.cd_devs[CHUNIT(dev)];
-
- SC_DEBUG(ch->sc_link, SDEV_DB1, ("closing\n"));
- ch->sc_link->flags &= ~SDEV_OPEN;
+ struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
- return 0;
+ sc->sc_link->flags &= ~SDEV_OPEN;
+ return (0);
}
-/*
- * Perform special action on behalf of the user
- * Knows about the internals of this device
- */
-int
-chioctl(dev, cmd, arg, mode, p)
+int
+chioctl(dev, cmd, data, flags, p)
dev_t dev;
u_long cmd;
- caddr_t arg;
- int mode;
+ caddr_t data;
+ int flags;
struct proc *p;
{
- struct ch_softc *ch = chcd.cd_devs[CHUNIT(dev)];
- struct scsi_link *sc_link = ch->sc_link;
- int flags;
-
- /*
- * Find the device that the user is talking about
- */
- flags = 0; /* give error messages, act on errors etc. */
+ struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ caddr_t elemdata;
+ int error = 0;
switch (cmd) {
- case CHIOOP: {
- struct chop *chop = (struct chop *) arg;
- SC_DEBUG(sc_link, SDEV_DB2, ("[chtape_chop: %x]\n",
- chop->ch_op));
-
- switch (chop->ch_op) {
- case CHGETPARAM:
- chop->u.getparam.chmo = ch->chmo;
- chop->u.getparam.chms = ch->chms;
- chop->u.getparam.sloto = ch->sloto;
- chop->u.getparam.slots = ch->slots;
- chop->u.getparam.imexo = ch->imexo;
- chop->u.getparam.imexs = ch->imexs;
- chop->u.getparam.driveo = ch->driveo;
- chop->u.getparam.drives = ch->drives;
- chop->u.getparam.rot = ch->rot;
- chop->result = 0;
- return 0;
- break;
- case CHPOSITION:
- return ch_position(ch, &chop->result,
- chop->u.position.chm, chop->u.position.to, flags);
- case CHMOVE:
- return ch_move(ch, &chop->result, chop->u.position.chm,
- chop->u.move.from, chop->u.move.to, flags);
- case CHGETELEM:
- return ch_getelem(ch, &chop->result,
- chop->u.get_elem_stat.type,
- chop->u.get_elem_stat.from,
- (char *) &chop->u.get_elem_stat.elem_data, flags);
- default:
- return EINVAL;
- }
- }
+ case CHIOMOVE:
+ error = ch_move(sc, (struct changer_move *)data);
+ break;
+
+ case CHIOEXCHANGE:
+ error = ch_exchange(sc, (struct changer_exchange *)data);
+ break;
+
+ case CHIOPOSITION:
+ error = ch_position(sc, (struct changer_position *)data);
+ break;
+
+ case CHIOGPICKER:
+ *(int *)data = sc->sc_picker - sc->sc_firsts[CHET_MT];
+ break;
+
+ case CHIOSPICKER: {
+ int new_picker = *(int *)data;
+
+ if (new_picker > (sc->sc_counts[CHET_MT] - 1))
+ return (EINVAL);
+ sc->sc_picker = sc->sc_firsts[CHET_MT] + new_picker;
+ break; }
+
+ case CHIOGPARAMS: {
+ struct changer_params *cp = (struct changer_params *)data;
+
+ cp->cp_curpicker = sc->sc_picker - sc->sc_firsts[CHET_MT];
+ cp->cp_npickers = sc->sc_counts[CHET_MT];
+ cp->cp_nslots = sc->sc_counts[CHET_ST];
+ cp->cp_nportals = sc->sc_counts[CHET_IE];
+ cp->cp_ndrives = sc->sc_counts[CHET_DT];
+ break; }
+
+ case CHIOGSTATUS: {
+ struct changer_element_status *ces =
+ (struct changer_element_status *)data;
+
+ error = ch_usergetelemstatus(sc, ces->ces_type, ces->ces_data);
+ break; }
+
+ /* Implement prevent/allow? */
+
default:
- return scsi_do_ioctl(sc_link, dev, cmd, arg, mode, p);
+ error = scsi_do_ioctl(sc->sc_link, dev, cmd, data, flags, p);
+ break;
}
-#ifdef DIAGNOSTIC
- panic("chioctl: impossible");
-#endif
+
+ return (error);
}
-int
-ch_getelem(ch, stat, type, from, data, flags)
- struct ch_softc *ch;
- short *stat;
- int type, from;
- char *data;
- int flags;
+int
+ch_move(sc, cm)
+ struct ch_softc *sc;
+ struct changer_move *cm;
{
- struct scsi_read_element_status scsi_cmd;
- char elbuf[32];
- int error;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = READ_ELEMENT_STATUS;
- scsi_cmd.byte2 = type;
- scsi_cmd.starting_element_addr[0] = (from >> 8) & 0xff;
- scsi_cmd.starting_element_addr[1] = from & 0xff;
- scsi_cmd.number_of_elements[1] = 1;
- scsi_cmd.allocation_length[2] = 32;
-
- error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), (u_char *) elbuf, 32, CHRETRIES, 100000, NULL,
- SCSI_DATA_IN | flags);
- if (error)
- *stat = ch->lsterr;
- else
- *stat = 0;
- bcopy(elbuf + 16, data, 16);
- return error;
+ struct scsi_move_medium cmd;
+ u_int16_t fromelem, toelem;
+
+ /*
+ * Check arguments.
+ */
+ if ((cm->cm_fromtype > CHET_DT) || (cm->cm_totype > CHET_DT))
+ return (EINVAL);
+ if ((cm->cm_fromunit > (sc->sc_counts[cm->cm_fromtype] - 1)) ||
+ (cm->cm_tounit > (sc->sc_counts[cm->cm_totype] - 1)))
+ return (ENODEV);
+
+ /*
+ * Check the request against the changer's capabilities.
+ */
+ if ((sc->sc_movemask[cm->cm_fromtype] & (1 << cm->cm_totype)) == 0)
+ return (EINVAL);
+
+ /*
+ * Calculate the source and destination elements.
+ */
+ fromelem = sc->sc_firsts[cm->cm_fromtype] + cm->cm_fromunit;
+ toelem = sc->sc_firsts[cm->cm_totype] + cm->cm_tounit;
+
+ /*
+ * Build the SCSI command.
+ */
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = MOVE_MEDIUM;
+ _lto2b(sc->sc_picker, cmd.tea);
+ _lto2b(fromelem, cmd.src);
+ _lto2b(toelem, cmd.dst);
+ if (cm->cm_flags & CM_INVERT)
+ cmd.flags |= MOVE_MEDIUM_INVERT;
+
+ /*
+ * Send command to changer.
+ */
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
}
-int
-ch_move(ch, stat, chm, from, to, flags)
- struct ch_softc *ch;
- short *stat;
- int chm, from, to, flags;
+int
+ch_exchange(sc, ce)
+ struct ch_softc *sc;
+ struct changer_exchange *ce;
{
- struct scsi_move_medium scsi_cmd;
- int error;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = MOVE_MEDIUM;
- scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff;
- scsi_cmd.transport_element_address[1] = chm & 0xff;
- scsi_cmd.source_address[0] = (from >> 8) & 0xff;
- scsi_cmd.source_address[1] = from & 0xff;
- scsi_cmd.destination_address[0] = (to >> 8) & 0xff;
- scsi_cmd.destination_address[1] = to & 0xff;
- scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0;
- error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags);
- if (error)
- *stat = ch->lsterr;
- else
- *stat = 0;
- return error;
+ struct scsi_exchange_medium cmd;
+ u_int16_t src, dst1, dst2;
+
+ /*
+ * Check arguments.
+ */
+ if ((ce->ce_srctype > CHET_DT) || (ce->ce_fdsttype > CHET_DT) ||
+ (ce->ce_sdsttype > CHET_DT))
+ return (EINVAL);
+ if ((ce->ce_srcunit > (sc->sc_counts[ce->ce_srctype] - 1)) ||
+ (ce->ce_fdstunit > (sc->sc_counts[ce->ce_fdsttype] - 1)) ||
+ (ce->ce_sdstunit > (sc->sc_counts[ce->ce_sdsttype] - 1)))
+ return (ENODEV);
+
+ /*
+ * Check the request against the changer's capabilities.
+ */
+ if (((sc->sc_exchangemask[ce->ce_srctype] &
+ (1 << ce->ce_fdsttype)) == 0) ||
+ ((sc->sc_exchangemask[ce->ce_fdsttype] &
+ (1 << ce->ce_sdsttype)) == 0))
+ return (EINVAL);
+
+ /*
+ * Calculate the source and destination elements.
+ */
+ src = sc->sc_firsts[ce->ce_srctype] + ce->ce_srcunit;
+ dst1 = sc->sc_firsts[ce->ce_fdsttype] + ce->ce_fdstunit;
+ dst2 = sc->sc_firsts[ce->ce_sdsttype] + ce->ce_sdstunit;
+
+ /*
+ * Build the SCSI command.
+ */
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = EXCHANGE_MEDIUM;
+ _lto2b(sc->sc_picker, cmd.tea);
+ _lto2b(src, cmd.src);
+ _lto2b(dst1, cmd.fdst);
+ _lto2b(dst2, cmd.sdst);
+ if (ce->ce_flags & CE_INVERT1)
+ cmd.flags |= EXCHANGE_MEDIUM_INV1;
+ if (ce->ce_flags & CE_INVERT2)
+ cmd.flags |= EXCHANGE_MEDIUM_INV2;
+
+ /*
+ * Send command to changer.
+ */
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
}
-int
-ch_position(ch, stat, chm, to, flags)
- struct ch_softc *ch;
- short *stat;
- int chm, to, flags;
+int
+ch_position(sc, cp)
+ struct ch_softc *sc;
+ struct changer_position *cp;
{
- struct scsi_position_to_element scsi_cmd;
- int error;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = POSITION_TO_ELEMENT;
- scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff;
- scsi_cmd.transport_element_address[1] = chm & 0xff;
- scsi_cmd.source_address[0] = (to >> 8) & 0xff;
- scsi_cmd.source_address[1] = to & 0xff;
- scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0;
- error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags);
- if (error)
- *stat = ch->lsterr;
- else
- *stat = 0;
- return error;
+ struct scsi_position_to_element cmd;
+ u_int16_t dst;
+
+ /*
+ * Check arguments.
+ */
+ if (cp->cp_type > CHET_DT)
+ return (EINVAL);
+ if (cp->cp_unit > (sc->sc_counts[cp->cp_type] - 1))
+ return (ENODEV);
+
+ /*
+ * Calculate the destination element.
+ */
+ dst = sc->sc_firsts[cp->cp_type] + cp->cp_unit;
+
+ /*
+ * Build the SCSI command.
+ */
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = POSITION_TO_ELEMENT;
+ _lto2b(sc->sc_picker, cmd.tea);
+ _lto2b(dst, cmd.dst);
+ if (cp->cp_flags & CP_INVERT)
+ cmd.flags |= POSITION_TO_ELEMENT_INVERT;
+
+ /*
+ * Send command to changer.
+ */
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
}
/*
- * Get the scsi driver to send a full inquiry to the
- * device and use the results to fill out the global
- * parameter structure.
+ * Perform a READ ELEMENT STATUS on behalf of the user, and return to
+ * the user only the data the user is interested in (i.e. an array of
+ * flags bytes).
*/
-int
-ch_mode_sense(ch, flags)
- struct ch_softc *ch;
- int flags;
+int
+ch_usergetelemstatus(sc, chet, uptr)
+ struct ch_softc *sc;
+ int chet;
+ u_int8_t *uptr;
+{
+ struct read_element_status_header *st_hdr;
+ struct read_element_status_page_header *pg_hdr;
+ struct read_element_status_descriptor *desc;
+ caddr_t data = NULL;
+ size_t size, desclen;
+ int avail, i, error = 0;
+ u_int8_t *user_data = NULL;
+
+ /*
+ * If there are no elements of the requested type in the changer,
+ * the request is invalid.
+ */
+ if (sc->sc_counts[chet] == 0)
+ return (EINVAL);
+
+ /*
+ * Request one descriptor for the given element type. This
+ * is used to determine the size of the descriptor so that
+ * we can allocate enough storage for all of them. We assume
+ * that the first one can fit into 1k.
+ */
+ data = (caddr_t)malloc(1024, M_DEVBUF, M_WAITOK);
+ if (error = ch_getelemstatus(sc, sc->sc_firsts[chet], 1, data, 1024))
+ goto done;
+
+ st_hdr = (struct read_element_status_header *)data;
+ pg_hdr = (struct read_element_status_page_header *)((u_long)st_hdr +
+ sizeof(struct read_element_status_header));
+ desclen = _2btol(pg_hdr->edl);
+
+ size = sizeof(struct read_element_status_header) +
+ sizeof(struct read_element_status_page_header) +
+ (desclen * sc->sc_counts[chet]);
+
+ /*
+ * Reallocate storage for descriptors and get them from the
+ * device.
+ */
+ free(data, M_DEVBUF);
+ data = (caddr_t)malloc(size, M_DEVBUF, M_WAITOK);
+ if (error = ch_getelemstatus(sc, sc->sc_firsts[chet],
+ sc->sc_counts[chet], data, size))
+ goto done;
+
+ /*
+ * Fill in the user status array.
+ */
+ st_hdr = (struct read_element_status_header *)data;
+ avail = _2btol(st_hdr->count);
+ if (avail != sc->sc_counts[chet])
+ printf("%s: warning, READ ELEMENT STATUS avail != count\n",
+ sc->sc_dev.dv_xname);
+
+ user_data = (u_int8_t *)malloc(avail, M_DEVBUF, M_WAITOK);
+
+ desc = (struct read_element_status_descriptor *)((u_long)data +
+ sizeof(struct read_element_status_header) +
+ sizeof(struct read_element_status_page_header));
+ for (i = 0; i < avail; ++i) {
+ user_data[i] = desc->flags1;
+ (u_long)desc += desclen;
+ }
+
+ /* Copy flags array out to userspace. */
+ error = copyout(user_data, uptr, avail);
+
+ done:
+ if (data != NULL)
+ free(data, M_DEVBUF);
+ if (user_data != NULL)
+ free(user_data, M_DEVBUF);
+ return (error);
+}
+
+int
+ch_getelemstatus(sc, first, count, data, datalen)
+ struct ch_softc *sc;
+ int first, count;
+ caddr_t data;
+ size_t datalen;
{
- struct scsi_mode_sense scsi_cmd;
- u_char scsi_sense[128]; /* Can't use scsi_mode_sense_data because of
- * missing block descriptor.
- */
- u_char *b;
- int i, l;
- int error;
- struct scsi_link *sc_link = ch->sc_link;
+ struct scsi_read_element_status cmd;
/*
- * First check if we have it all loaded
+ * Build SCSI command.
*/
- if (sc_link->flags & SDEV_MEDIA_LOADED)
- return 0;
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = READ_ELEMENT_STATUS;
+ _lto2b(first, cmd.sea);
+ _lto2b(count, cmd.count);
+ _lto3b(datalen, cmd.len);
/*
- * First do a mode sense
+ * Send command to changer.
*/
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = MODE_SENSE;
- scsi_cmd.byte2 = SMS_DBD;
- scsi_cmd.page = 0x3f; /* All Pages */
- scsi_cmd.length = sizeof(scsi_sense);
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), (u_char *)data, datalen, CHRETRIES, 100000, NULL, 0));
+}
+
+
+/*
+ * Ask the device about itself and fill in the parameters in our
+ * softc.
+ */
+int
+ch_get_params(sc, scsiflags)
+ struct ch_softc *sc;
+ int scsiflags;
+{
+ struct scsi_mode_sense cmd;
+ struct scsi_mode_sense_data {
+ struct scsi_mode_header header;
+ union {
+ struct page_element_address_assignment ea;
+ struct page_transport_geometry_parameters tg;
+ struct page_device_capabilities cap;
+ } pages;
+ } sense_data;
+ int error, from;
+ u_int8_t *moves, *exchanges;
/*
- * Read in the pages
+ * Grab info from the element address assignment page.
*/
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), (u_char *) &scsi_sense,
- sizeof(scsi_sense), CHRETRIES, 5000, NULL,
- flags | SCSI_DATA_IN);
+ bzero(&cmd, sizeof(cmd));
+ bzero(&sense_data, sizeof(sense_data));
+ cmd.opcode = MODE_SENSE;
+ cmd.byte2 |= 0x08; /* disable block descriptors */
+ cmd.page = 0x1d;
+ cmd.length = (sizeof(sense_data) & 0xff);
+ error = scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&sense_data, sizeof(sense_data), CHRETRIES,
+ 6000, NULL, scsiflags | SCSI_DATA_IN);
if (error) {
- printf("%s: could not mode sense\n", ch->sc_dev.dv_xname);
- return error;
+ printf("%s: could not sense element address page\n");
+ return (error);
}
- sc_link->flags |= SDEV_MEDIA_LOADED;
- l = scsi_sense[0] - 3;
- b = &scsi_sense[4];
+ sc->sc_firsts[CHET_MT] = _2btol(sense_data.pages.ea.mtea);
+ sc->sc_counts[CHET_MT] = _2btol(sense_data.pages.ea.nmte);
+ sc->sc_firsts[CHET_ST] = _2btol(sense_data.pages.ea.fsea);
+ sc->sc_counts[CHET_ST] = _2btol(sense_data.pages.ea.nse);
+ sc->sc_firsts[CHET_IE] = _2btol(sense_data.pages.ea.fieea);
+ sc->sc_counts[CHET_IE] = _2btol(sense_data.pages.ea.niee);
+ sc->sc_firsts[CHET_DT] = _2btol(sense_data.pages.ea.fdtea);
+ sc->sc_counts[CHET_DT] = _2btol(sense_data.pages.ea.ndte);
+
+ /* XXX ask for page trasport geom */
/*
- * To avoid alignment problems
+ * Grab info from the capabilities page.
*/
-/* XXXX - FIX THIS FOR MSB */
-#define p2copy(valp) (valp[1] | (valp[0]<<8)); valp+=2
-#define p4copy(valp) (valp[3] | (valp[2]<<8) | (valp[1]<<16) | (valp[0]<<24)); valp+=4
-#if 0
- printf("\nmode_sense %d\n", l);
- for (i = 0; i < l + 4; i++)
- printf("%x%c", scsi_sense[i], i % 8 == 7 ? '\n' : ':');
- printf("\n");
-#endif
- for (i = 0; i < l;) {
- u_char pc = (*b++) & 0x3f;
- u_char pl = *b++;
- u_char *bb = b;
- switch (pc) {
- case 0x1d:
- ch->chmo = p2copy(bb);
- ch->chms = p2copy(bb);
- ch->sloto = p2copy(bb);
- ch->slots = p2copy(bb);
- ch->imexo = p2copy(bb);
- ch->imexs = p2copy(bb);
- ch->driveo = p2copy(bb);
- ch->drives = p2copy(bb);
- break;
- case 0x1e:
- ch->rot = *b & 0x1;
- break;
- case 0x1f:
- ch->stor = *b & 0xf;
- bb += 2;
- ch->stor = p4copy(bb);
- break;
- default:
- break;
- }
- b += pl;
- i += pl + 2;
+ bzero(&cmd, sizeof(cmd));
+ bzero(&sense_data, sizeof(sense_data));
+ cmd.opcode = MODE_SENSE;
+ cmd.byte2 |= 0x08; /* disable block descriptors */
+ cmd.page = 0x1f;
+ cmd.length = (sizeof(sense_data) & 0xff);
+ error = scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&sense_data, sizeof(sense_data), CHRETRIES,
+ 6000, NULL, scsiflags | SCSI_DATA_IN);
+ if (error) {
+ printf("%s: could not sense capabilities page\n");
+ return (error);
+ }
+
+ bzero(sc->sc_movemask, sizeof(sc->sc_movemask));
+ bzero(sc->sc_exchangemask, sizeof(sc->sc_exchangemask));
+ moves = &sense_data.pages.cap.move_from_mt;
+ exchanges = &sense_data.pages.cap.exchange_with_mt;
+ for (from = CHET_MT; from <= CHET_DT; ++from) {
+ sc->sc_movemask[from] = moves[from];
+ sc->sc_exchangemask[from] = exchanges[from];
}
- SC_DEBUG(sc_link, SDEV_DB2,
- (" cht(%d-%d)slot(%d-%d)imex(%d-%d)cts(%d-%d) %s rotate\n",
- ch->chmo, ch->chms, ch->sloto, ch->slots, ch->imexo, ch->imexs,
- ch->driveo, ch->drives, ch->rot ? "can" : "can't"));
- return 0;
+
+ sc->sc_link->flags |= SDEV_MEDIA_LOADED;
+ return (0);
}
-# $NetBSD: files.scsi,v 1.2 1996/02/18 20:32:40 mycroft Exp $
+# $NetBSD: files.scsi,v 1.3 1996/03/17 00:59:45 thorpej Exp $
#
# Config.new file and device description for machine-independent SCSI code.
# Included by ports that need it. Ports that usee it must provide
file scsi/scsi_ioctl.c scsi
file scsi/scsiconf.c scsi
-device scsibus at scsi {target = -1, lun = -1}
+device scsibus {target = -1, lun = -1}
+attach scsibus at scsi
-device cd at scsibus: disk
+device cd: disk
+attach cd at scsibus
file scsi/cd.c cd needs-flag
-device ch at scsibus: disk
+
+device ch: disk
+attach ch at scsibus
file scsi/ch.c ch needs-flag
-device sd at scsibus: disk
+
+device sd: disk
+attach sd at scsibus
file scsi/sd.c sd needs-flag
-device st at scsibus: tape
+
+device st: tape
+attach st at scsibus
file scsi/st.c st needs-flag
-device ss at scsibus: tape
+
+device ss: tape
+attach ss at scsibus
file scsi/ss.c ss needs-flag
file scsi/ss_mustek.c ss
file scsi/ss_scanjet.c ss
-device su at scsibus: disk
+
+device su: disk
+attach su at scsibus
file scsi/su.c su needs-flag
-device uk at scsibus: disk
-file scsi/uk.c uk needs-flag
+device uk: disk
+attach uk at scsibus
+file scsi/uk.c uk needs-flag
-/* $NetBSD: scsi_all.h,v 1.6 1994/12/28 19:42:54 mycroft Exp $ */
+/* $NetBSD: scsi_all.h,v 1.7 1996/03/19 03:06:10 mycroft Exp $ */
/*
* SCSI general interface description
u_int8_t extra[8];
};
-/*
- * This looks bad, and it is. However it fixes padding problems
- * caused by using unions. This *needs* to be an array, if this code
- * is to work on any architecture.
- */
-struct scsi_sense_data {
-/* 1*/ u_int8_t error_code; /* same bits as new version */
-#define XXX_unextended_blockhi extended_segment
-#define XXX_unextended_blockmed extended_flags
-#define XXX_unextended_blocklow extended_info[0]
-/* 2*/ u_int8_t extended_segment;
-/* 3*/ u_int8_t extended_flags; /* same bits as new version */
-/* 7*/ u_int8_t extended_info[4];
-/* 8*/ u_int8_t extended_extra_len;
- /*
- * allocate enough room to hold new stuff
- * (by increasing 16 to 24 below)
- */
-/*32*/ u_int8_t extended_extra_bytes[24];
-}; /* total of 32 bytes */
-
-struct scsi_sense_data_new {
+struct scsi_sense_data_unextended {
+/* 1*/ u_int8_t error_code;
+/* 4*/ u_int8_t block[3];
+};
+
+struct scsi_sense_data {
/* 1*/ u_int8_t error_code;
#define SSD_ERRCODE 0x7F
#define SSD_ERRCODE_VALID 0x80
- union {
- struct { /* this is deprecated, the standard says "DON'T"*/
-/* 2*/ u_int8_t blockhi;
-/* 3*/ u_int8_t blockmed;
-/* 4*/ u_int8_t blocklow;
- } unextended;
- struct {
-/* 2*/ u_int8_t segment;
-/* 3*/ u_int8_t flags;
+/* 2*/ u_int8_t segment;
+/* 3*/ u_int8_t flags;
#define SSD_KEY 0x0F
#define SSD_ILI 0x20
#define SSD_EOM 0x40
#define SSD_FILEMARK 0x80
-/* 7*/ u_int8_t info[4];
-/* 8*/ u_int8_t extra_len;
-/*12*/ u_int8_t cmd_spec_info[4];
-/*13*/ u_int8_t add_sense_code;
-/*14*/ u_int8_t add_sense_code_qual;
-/*15*/ u_int8_t fru;
-/*16*/ u_int8_t sense_key_spec_1;
-#define SSD_SCS_VALID 0x80
-/*17*/ u_int8_t sense_key_spec_2;
-/*18*/ u_int8_t sense_key_spec_3;
-/*32*/ u_int8_t extra_bytes[14];
- } extended;
- } ext;
-}; /* total of 32 bytes */
+/* 7*/ u_int8_t info[4];
+/* 8*/ u_int8_t extra_len;
+/*12*/ u_int8_t cmd_spec_info[4];
+/*13*/ u_int8_t add_sense_code;
+/*14*/ u_int8_t add_sense_code_qual;
+/*15*/ u_int8_t fru;
+/*16*/ u_int8_t sense_key_spec_1;
+#define SSD_SCS_VALID 0x80
+/*17*/ u_int8_t sense_key_spec_2;
+/*18*/ u_int8_t sense_key_spec_3;
+/*32*/ u_int8_t extra_bytes[14];
+};
struct scsi_blk_desc {
u_int8_t density;
-/* $OpenBSD: scsi_base.c,v 1.6 1996/02/29 13:12:22 niklas Exp $ */
-/* $NetBSD: scsi_base.c,v 1.33 1996/02/14 21:47:14 christos Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.7 1996/04/21 22:30:50 deraadt Exp $ */
+/* $NetBSD: scsi_base.c,v 1.34 1996/03/19 03:06:28 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
{
struct scsi_read_cap_data rdcap;
struct scsi_read_capacity scsi_cmd;
- u_long size;
/*
* make up a scsi command and ask the scsi driver to do
sc_print_addr(sc_link);
printf("could not get size\n");
return 0;
- } else {
- size = rdcap.addr_0 + 1;
- size += rdcap.addr_1 << 8;
- size += rdcap.addr_2 << 16;
- size += rdcap.addr_3 << 24;
}
- return size;
+
+ return _4btol(rdcap.addr) + 1;
}
/*
sense->error_code & SSD_ERRCODE,
sense->error_code & SSD_ERRCODE_VALID ? 1 : 0);
printf("seg%x key%x ili%x eom%x fmark%x\n",
- sense->extended_segment,
- sense->extended_flags & SSD_KEY,
- sense->extended_flags & SSD_ILI ? 1 : 0,
- sense->extended_flags & SSD_EOM ? 1 : 0,
- sense->extended_flags & SSD_FILEMARK ? 1 : 0);
+ sense->segment,
+ sense->flags & SSD_KEY,
+ sense->flags & SSD_ILI ? 1 : 0,
+ sense->flags & SSD_EOM ? 1 : 0,
+ sense->flags & SSD_FILEMARK ? 1 : 0);
printf("info: %x %x %x %x followed by %d extra bytes\n",
- sense->extended_info[0],
- sense->extended_info[1],
- sense->extended_info[2],
- sense->extended_info[3],
- sense->extended_extra_len);
+ sense->info[0],
+ sense->info[1],
+ sense->info[2],
+ sense->info[3],
+ sense->extra_len);
printf("extra: ");
- for (count = 0; count < sense->extended_extra_len; count++)
- printf("%x ", sense->extended_extra_bytes[count]);
+ for (count = 0; count < sense->extra_len; count++)
+ printf("%x ", sense->extra_bytes[count]);
printf("\n");
}
#endif /*SCSIDEBUG */
*/
case 0x71: /* delayed error */
sc_print_addr(sc_link);
- key = sense->extended_flags & SSD_KEY;
+ key = sense->flags & SSD_KEY;
printf(" DELAYED ERROR, key = 0x%x\n", key);
case 0x70:
- if ((sense->error_code & SSD_ERRCODE_VALID) != 0) {
- bcopy(sense->extended_info, &info, sizeof info);
- info = ntohl(info);
- } else
+ if ((sense->error_code & SSD_ERRCODE_VALID) != 0)
+ info = _4btol(sense->info);
+ else
info = 0;
- key = sense->extended_flags & SSD_KEY;
+ key = sense->flags & SSD_KEY;
switch (key) {
case 0x0: /* NO SENSE */
printf(", info = %d (decimal)", info);
}
}
- if (sense->extended_extra_len != 0) {
+ if (sense->extra_len != 0) {
int n;
printf(", data =");
- for (n = 0; n < sense->extended_extra_len; n++)
- printf(" %02x", sense->extended_extra_bytes[n]);
+ for (n = 0; n < sense->extra_len; n++)
+ printf(" %02x", sense->extra_bytes[n]);
}
printf("\n");
}
printf("error code %d",
sense->error_code & SSD_ERRCODE);
if ((sense->error_code & SSD_ERRCODE_VALID) != 0) {
+ struct scsi_sense_data_unextended *usense =
+ (struct scsi_sense_data_unextended *)sense;
printf(" at block no. %d (decimal)",
- (sense->XXX_unextended_blockhi << 16) +
- (sense->XXX_unextended_blockmed << 8) +
- (sense->XXX_unextended_blocklow));
+ _3btol(usense->block));
}
printf("\n");
return EIO;
* Utility routines often used in SCSI stuff
*/
-/*
- * convert a physical address to 3 bytes,
- * MSB at the lowest address,
- * LSB at the highest.
- */
-void
-lto3b(val, bytes)
- u_int32_t val;
- u_int8_t *bytes;
-{
-
- *bytes++ = (val >> 16) & 0xff;
- *bytes++ = (val >> 8) & 0xff;
- *bytes = val & 0xff;
-}
-
-/*
- * The reverse of lto3b
- */
-u_int32_t
-_3btol(bytes)
- u_int8_t *bytes;
-{
- u_int32_t rc;
-
- rc = (*bytes++ << 16);
- rc += (*bytes++ << 8);
- rc += *bytes;
- return (rc);
-}
/*
* Print out the scsi_link structure's address info.
-/* $NetBSD: scsi_cd.h,v 1.5 1994/12/28 19:42:58 mycroft Exp $ */
+/* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:06:39 mycroft Exp $ */
/*
* Written by Julian Elischer (julian@tfs.com)
struct scsi_read_capacity_cd {
u_int8_t opcode;
- u_char byte2;
- u_char addr_3; /* Most Significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least Significant */
- u_char unused[3];
- u_char control;
+ u_int8_t byte2;
+ u_int8_t addr[4];
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_pause {
- u_char opcode;
- u_char byte2;
- u_char unused[6];
- u_char resume;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[6];
+ u_int8_t resume;
+ u_int8_t control;
};
#define PA_PAUSE 1
#define PA_RESUME 0
struct scsi_play_msf {
- u_char opcode;
- u_char byte2;
- u_char unused;
- u_char start_m;
- u_char start_s;
- u_char start_f;
- u_char end_m;
- u_char end_s;
- u_char end_f;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused;
+ u_int8_t start_m;
+ u_int8_t start_s;
+ u_int8_t start_f;
+ u_int8_t end_m;
+ u_int8_t end_s;
+ u_int8_t end_f;
+ u_int8_t control;
};
struct scsi_play_track {
- u_char opcode;
- u_char byte2;
- u_char unused[2];
- u_char start_track;
- u_char start_index;
- u_char unused1;
- u_char end_track;
- u_char end_index;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[2];
+ u_int8_t start_track;
+ u_int8_t start_index;
+ u_int8_t unused1;
+ u_int8_t end_track;
+ u_int8_t end_index;
+ u_int8_t control;
};
struct scsi_play {
- u_char opcode;
- u_char byte2;
- u_char blk_addr[4];
- u_char unused;
- u_char xfer_len[2];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t blk_addr[4];
+ u_int8_t unused;
+ u_int8_t xfer_len[2];
+ u_int8_t control;
};
struct scsi_play_big {
- u_char opcode;
- u_char byte2; /* same as above */
- u_char blk_addr[4];
- u_char xfer_len[4];
- u_char unused;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2; /* same as above */
+ u_int8_t blk_addr[4];
+ u_int8_t xfer_len[4];
+ u_int8_t unused;
+ u_int8_t control;
};
struct scsi_play_rel_big {
- u_char opcode;
- u_char byte2; /* same as above */
- u_char blk_addr[4];
- u_char xfer_len[4];
- u_char track;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2; /* same as above */
+ u_int8_t blk_addr[4];
+ u_int8_t xfer_len[4];
+ u_int8_t track;
+ u_int8_t control;
};
struct scsi_read_header {
- u_char opcode;
- u_char byte2;
- u_char blk_addr[4];
- u_char unused;
- u_char data_len[2];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t blk_addr[4];
+ u_int8_t unused;
+ u_int8_t data_len[2];
+ u_int8_t control;
};
struct scsi_read_subchannel {
- u_char opcode;
- u_char byte2;
- u_char byte3;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t byte3;
#define SRS_SUBQ 0x40
- u_char subchan_format;
- u_char unused[2];
- u_char track;
- u_char data_len[2];
- u_char control;
+ u_int8_t subchan_format;
+ u_int8_t unused[2];
+ u_int8_t track;
+ u_int8_t data_len[2];
+ u_int8_t control;
};
struct scsi_read_toc {
- u_char opcode;
- u_char byte2;
- u_char unused[4];
- u_char from_track;
- u_char data_len[2];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[4];
+ u_int8_t from_track;
+ u_int8_t data_len[2];
+ u_int8_t control;
};
;
struct scsi_read_cd_capacity {
- u_char opcode;
- u_char byte2;
- u_char addr_3; /* Most Significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least Significant */
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t addr[4];
+ u_int8_t unused[3];
+ u_int8_t control;
};
/*
struct scsi_read_cd_cap_data {
- u_char addr_3; /* Most significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least significant */
- u_char length_3; /* Most significant */
- u_char length_2;
- u_char length_1;
- u_char length_0; /* Least significant */
+ u_int8_t addr[4];
+ u_int8_t length[4];
};
union cd_pages {
struct audio_page {
- u_char page_code;
+ u_int8_t page_code;
#define CD_PAGE_CODE 0x3F
#define AUDIO_PAGE 0x0e
#define CD_PAGE_PS 0x80
- u_char param_len;
- u_char flags;
+ u_int8_t param_len;
+ u_int8_t flags;
#define CD_PA_SOTC 0x02
#define CD_PA_IMMED 0x04
- u_char unused[2];
- u_char format_lba;
+ u_int8_t unused[2];
+ u_int8_t format_lba;
#define CD_PA_FORMAT_LBA 0x0F
#define CD_PA_APR_VALID 0x80
- u_char lb_per_sec[2];
+ u_int8_t lb_per_sec[2];
struct port_control {
- u_char channels;
+ u_int8_t channels;
#define CHANNEL 0x0F
#define CHANNEL_0 1
#define CHANNEL_1 2
#define CHANNEL_3 8
#define LEFT_CHANNEL CHANNEL_0
#define RIGHT_CHANNEL CHANNEL_1
- u_char volume;
+ u_int8_t volume;
} port[4];
#define LEFT_PORT 0
#define RIGHT_PORT 1
-/* $NetBSD: scsi_changer.h,v 1.5 1994/12/28 19:42:59 mycroft Exp $ */
+/* $NetBSD: scsi_changer.h,v 1.7 1996/04/03 00:25:48 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
+ * All rights reserved.
+ *
+ * Partially based on an autochanger driver written by Stefan Grefen
+ * and on an autochanger driver written by the Systems Programming Group
+ * at the University of Utah Computer Science Department.
+ *
+ * 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 acknowledgements:
+ * This product includes software developed by Jason R. Thorpe
+ * for And Communications, http://www.and.com/
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
/*
* SCSI changer interface description
*/
/*
- * Written by Stefan Grefen (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
+ * Partially derived from software written by Stefan Grefen
+ * (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
* based on the SCSI System by written Julian Elischer (julian@tfs.com)
* for TRW Financial Systems.
*
*
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
*/
+
#ifndef _SCSI_SCSI_CHANGER_H
#define _SCSI_SCSI_CHANGER_H 1
/*
* SCSI command format
*/
-struct scsi_read_element_status {
- u_char opcode;
- u_char byte2;
-#define SRES_ELEM_TYPE_CODE 0x0F
-#define SRES_ELEM_VOLTAG 0x10
- u_char starting_element_addr[2];
- u_char number_of_elements[2];
- u_char resv1;
- u_char allocation_length[3];
- u_char resv2;
- u_char control;
+
+/*
+ * Exchange the medium in the source element with the medium
+ * located at the destination element.
+ */
+struct scsi_exchange_medium {
+ u_int8_t opcode;
+#define EXCHANGE_MEDIUM 0xa6
+ u_int8_t byte2;
+ u_int8_t tea[2]; /* transport element address */
+ u_int8_t src[2]; /* source address */
+ u_int8_t fdst[2]; /* first destination address */
+ u_int8_t sdst[2]; /* second destination address */
+ u_int8_t flags;
+#define EXCHANGE_MEDIUM_INV1 0x01
+#define EXCHANGE_MEDIUM_INV2 0x02
+ u_int8_t control;
};
-#define RE_ALL_ELEMENTS 0
-#define RE_MEDIUM_TRANSPORT_ELEMENT 1
-#define RE_STORAGE_ELEMENT 2
-#define RE_IMPORT_EXPORT 3
-#define RE_DATA_TRANSFER_ELEMENT 4
+/*
+ * Cause the medium changer to check all elements for medium and any
+ * other status relevant to the element.
+ */
+struct scsi_initialize_elememt_status {
+ u_int8_t opcode;
+#define INITIALIZE_ELEMENT_STATUS 0x07
+ u_int8_t byte2;
+ u_int8_t reserved[3];
+ u_int8_t control;
+};
+
+/*
+ * Request the changer to move a unit of media from the source element
+ * to the destination element.
+ */
struct scsi_move_medium {
- u_char opcode;
- u_char byte2;
- u_char transport_element_address[2];
- u_char source_address[2];
- u_char destination_address[2];
- u_char rsvd[2];
- u_char invert;
- u_char control;
+ u_int8_t opcode;
+#define MOVE_MEDIUM 0xa5
+ u_int8_t byte2;
+ u_int8_t tea[2]; /* transport element address */
+ u_int8_t src[2]; /* source element address */
+ u_int8_t dst[2]; /* destination element address */
+ u_int8_t reserved[2];
+ u_int8_t flags;
+#define MOVE_MEDIUM_INVERT 0x01
+ u_int8_t control;
};
+/*
+ * Position the specified transport element (picker) in front of
+ * the destination element specified.
+ */
struct scsi_position_to_element {
- u_char opcode;
- u_char byte2;
- u_char transport_element_address[2];
- u_char source_address[2];
- u_char rsvd[2];
- u_char invert;
- u_char control;
+ u_int8_t opcode;
+#define POSITION_TO_ELEMENT 0x2b
+ u_int8_t byte2;
+ u_int8_t tea[2]; /* transport element address */
+ u_int8_t dst[2]; /* destination element address */
+ u_int8_t reserved[2];
+ u_int8_t flags;
+#define POSITION_TO_ELEMENT_INVERT 0x01
+ u_int8_t control;
+};
+
+/*
+ * Request that the changer report the status of its internal elements.
+ */
+struct scsi_read_element_status {
+ u_int8_t opcode;
+#define READ_ELEMENT_STATUS 0xb8
+ u_int8_t byte2;
+#define READ_ELEMENT_STATUS_VOLTAG 0x10 /* report volume tag info */
+ /* ...next 4 bits are an element type code... */
+ u_int8_t sea[2]; /* starting element address */
+ u_int8_t count[2]; /* number of elements */
+ u_int8_t reserved0;
+ u_int8_t len[3]; /* length of data buffer */
+ u_int8_t reserved1;
+ u_int8_t control;
};
-
+
+struct scsi_request_volume_element_address {
+ u_int8_t opcode;
+#define REQUEST_VOLUME_ELEMENT_ADDRESS 0xb5
+ u_int8_t byte2;
+#define REQUEST_VOLUME_ELEMENT_ADDRESS_VOLTAG 0x10
+ /* ...next 4 bits are an element type code... */
+ u_int8_t eaddr[2]; /* element address */
+ u_int8_t count[2]; /* number of elements */
+ u_int8_t reserved0;
+ u_int8_t len[3]; /* length of data buffer */
+ u_int8_t reserved1;
+ u_int8_t control;
+};
+
+/* XXX scsi_release */
+
/*
- * Opcodes
+ * Data returned by READ ELEMENT STATUS consists of an 8-byte header
+ * followed by one or more read_element_status_pages.
*/
-#define POSITION_TO_ELEMENT 0x2b
-#define MOVE_MEDIUM 0xa5
-#define READ_ELEMENT_STATUS 0xb8
-
-struct scsi_element_status_data {
- u_char first_element_reported[2];
- u_char number_of_elements_reported[2];
- u_char rsvd;
- u_char byte_count_of_report[3];
+struct read_element_status_header {
+ u_int8_t fear[2]; /* first element address reported */
+ u_int8_t count[2]; /* number of elements available */
+ u_int8_t reserved;
+ u_int8_t nbytes[3]; /* byte count of all pages */
};
-struct element_status_page {
- u_char element_type_code;
- u_char flags;
-#define ESP_AVOLTAG 0x40
-#define ESP_PVOLTAG 0x80
- u_char element_descriptor_length[2];
- u_char rsvd;
- u_char byte_count_of_descriptor_data[3];
+struct read_element_status_page_header {
+ u_int8_t type; /* element type code; see type codes below */
+ u_int8_t flags;
+#define READ_ELEMENT_STATUS_AVOLTAG 0x40
+#define READ_ELEMENT_STATUS_PVOLTAG 0x80
+ u_int8_t edl[2]; /* element descriptor length */
+ u_int8_t reserved;
+ u_int8_t nbytes[3]; /* byte count of all descriptors */
};
-#endif /* _SCSI_SCSI_CHANGER_H */
+struct read_element_status_descriptor {
+ u_int8_t eaddr[2]; /* element address */
+ u_int8_t flags1;
+
+#define READ_ELEMENT_STATUS_FULL 0x01
+#define READ_ELEMENT_STATUS_IMPEXP 0x02
+#define READ_ELEMENT_STATUS_EXCEPT 0x04
+#define READ_ELEMENT_STATUS_ACCESS 0x08
+#define READ_ELEMENT_STATUS_EXENAB 0x10
+#define READ_ELEMENT_STATUS_INENAB 0x20
+
+#define READ_ELEMENT_STATUS_MT_MASK1 0x05
+#define READ_ELEMENT_STATUS_ST_MASK1 0x0c
+#define READ_ELEMENT_STATUS_IE_MASK1 0x3f
+#define READ_ELEMENT_STATUS_DT_MASK1 0x0c
+
+ u_int8_t reserved0;
+ u_int8_t sense_code;
+ u_int8_t sense_qual;
+ /*
+ * dt_scsi_flags and dt_scsi_addr are valid only on data transport
+ * elements. These bytes are undefined for all other element types.
+ */
+ u_int8_t dt_scsi_flags;
+
+#define READ_ELEMENT_STATUS_DT_LUNMASK 0x07
+#define READ_ELEMENT_STATUS_DT_LUVALID 0x10
+#define READ_ELEMENT_STATUS_DT_IDVALID 0x20
+#define READ_ELEMENT_STATUS_DT_NOTBUS 0x80
+
+ u_int8_t dt_scsi_addr;
+
+ u_int8_t reserved1;
+
+ u_int8_t flags2;
+#define READ_ELEMENT_STATUS_INVERT 0x40
+#define READ_ELEMENT_STATUS_SVALID 0x80
+ u_int8_t ssea[2]; /* source storage element address */
+
+ /*
+ * bytes 12-47: Primary volume tag information.
+ * (field omitted if PVOLTAG = 0)
+ *
+ * bytes 48-83: Alternate volume tag information.
+ * (field omitted if AVOLTAG = 0)
+ *
+ * bytes 84-87: Reserved (moved up if either of the above fields
+ * are omitted)
+ *
+ * bytes 88-end: Vendor-specific: (moved up if either of the
+ * above fields are missing)
+ */
+};
+
+/* XXX add data returned by REQUEST VOLUME ELEMENT ADDRESS */
+
+/* Element type codes */
+#define ELEMENT_TYPE_MASK 0x0f /* Note: these aren't bits */
+#define ELEMENT_TYPE_ALL 0x00
+#define ELEMENT_TYPE_MT 0x01
+#define ELEMENT_TYPE_ST 0x02
+#define ELEMENT_TYPE_IE 0x03
+#define ELEMENT_TYPE_DT 0x04
+
+/*
+ * XXX The following definitions should be common to all SCSI device types.
+ */
+#define PGCODE_MASK 0x3f /* valid page number bits in pg_code */
+#define PGCODE_PS 0x80 /* indicates page is savable */
+
+/*
+ * Device capabilities page.
+ *
+ * This page defines characteristics of the elemenet types in the
+ * medium changer device.
+ *
+ * Note in the definitions below, the following abbreviations are
+ * used:
+ * MT Medium transport element (picker)
+ * ST Storage transport element (slot)
+ * IE Import/export element (portal)
+ * DT Data tranfer element (tape/disk drive)
+ */
+struct page_device_capabilities {
+ u_int8_t pg_code; /* page code (0x1f) */
+ u_int8_t pg_length; /* page length (0x12) */
+
+ /*
+ * The STOR_xx bits indicate that an element of a given
+ * type may provide independent storage for a unit of
+ * media. The top four bits of this value are reserved.
+ */
+ u_int8_t stor;
+#define STOR_MT 0x01
+#define STOR_ST 0x02
+#define STOR_IE 0x04
+#define STOR_DT 0x08
+
+ u_int8_t reserved0;
+
+ /*
+ * The MOVE_TO_yy bits indicate the changer supports
+ * moving a unit of medium from an element of a given type to an
+ * element of type yy. This is used to determine if a given
+ * MOVE MEDIUM command is legal. The top four bits of each
+ * of these values are reserved.
+ */
+ u_int8_t move_from_mt;
+ u_int8_t move_from_st;
+ u_int8_t move_from_ie;
+ u_int8_t move_from_dt;
+#define MOVE_TO_MT 0x01
+#define MOVE_TO_ST 0x02
+#define MOVE_TO_IE 0x04
+#define MOVE_TO_DT 0x08
+
+ u_int8_t reserved1[2];
+
+ /*
+ * Similar to above, but for EXCHANGE MEDIUM.
+ */
+ u_int8_t exchange_with_mt;
+ u_int8_t exchange_with_st;
+ u_int8_t exchange_with_ie;
+ u_int8_t exchange_with_dt;
+#define EXCHANGE_WITH_MT 0x01
+#define EXCHANGE_WITH_ST 0x02
+#define EXCHANGE_WITH_IE 0x04
+#define EXCHANGE_WITH_DT 0x08
+};
+
+/*
+ * Medium changer elemement address assignment page.
+ *
+ * Some of these fields can be a little confusing, so an explanation
+ * is in order.
+ *
+ * Each component within a a medium changer apparatus is called an
+ * "element".
+ *
+ * The "medium transport element address" is the address of the first
+ * picker (robotic arm). "Number of medium transport elements" tells
+ * us how many pickers exist in the changer.
+ *
+ * The "first storage element address" is the address of the first
+ * slot in the tape or disk magazine. "Number of storage elements" tells
+ * us how many slots exist in the changer.
+ *
+ * The "first import/export element address" is the address of the first
+ * medium portal accessible both by the medium changer and an outside
+ * human operator. This is where the changer might deposit tapes destined
+ * for some vault. The "number of import/export elements" tells us
+ * not many of these portals exist in the changer. NOTE: this number may
+ * be 0.
+ *
+ * The "first data transfer element address" is the address of the first
+ * tape or disk drive in the changer. "Number of data transfer elements"
+ * tells us how many drives exist in the changer.
+ */
+struct page_element_address_assignment {
+ u_int8_t pg_code; /* page code (0x1d) */
+ u_int8_t pg_length; /* page length (0x12) */
+
+ /* Medium transport element address */
+ u_int8_t mtea[2];
+
+ /* Number of medium transport elements */
+ u_int8_t nmte[2];
+
+ /* First storage element address */
+ u_int8_t fsea[2];
+
+ /* Number of storage elements */
+ u_int8_t nse[2];
+
+ /* First import/export element address */
+ u_int8_t fieea[2];
+
+ /* Number of import/export elements */
+ u_int8_t niee[2];
+
+ /* First data transfer element address */
+ u_int8_t fdtea[2];
+
+ /* Number of data trafer elements */
+ u_int8_t ndte[2];
+
+ u_int8_t reserved[2];
+};
+
+/*
+ * Transport geometry parameters page.
+ *
+ * Defines whether each medium transport element is a member of a set of
+ * elements that share a common robotics subsystem and whether the element
+ * is capable of media rotation. One transport geometry descriptor is
+ * transferred for each medium transport element, beginning with the first
+ * medium transport element (other than the default transport element address
+ * of 0).
+ */
+struct page_transport_geometry_parameters {
+ u_int8_t pg_code; /* page code (0x1e) */
+ u_int8_t pg_length; /* page length; variable */
+
+ /* Transport geometry descriptor(s) are here. */
+
+ u_int8_t misc;
+#define CAN_ROTATE 0x01
+
+ /* Member number in transport element set. */
+ u_int8_t member;
+};
+
+#endif /* _SCSI_SCSI_CHANGER_H */
+++ /dev/null
-/* $NetBSD: scsi_conf.h,v 1.2 1996/02/18 20:32:41 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Christos Zoulas. 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 Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/conf.h>
-
-#include "ch.h"
-cdev_decl(ch);
-
-#include "ss.h"
-cdev_decl(ss);
-
-#include "sd.h"
-bdev_decl(sd);
-cdev_decl(sd);
-
-#include "st.h"
-bdev_decl(st);
-cdev_decl(st);
-
-#include "cd.h"
-bdev_decl(cd);
-cdev_decl(cd);
-/* $NetBSD: scsi_disk.h,v 1.8 1995/10/15 23:32:02 thorpej Exp $ */
+/* $NetBSD: scsi_disk.h,v 1.9 1996/03/19 03:07:02 mycroft Exp $ */
/*
* SCSI interface description
#define _SCSI_SCSI_DISK_H 1
struct scsi_reassign_blocks {
- u_char opcode;
- u_char byte2;
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_rw {
- u_char opcode;
- u_char addr_2; /* Most significant */
+ u_int8_t opcode;
+ u_int8_t addr[3];
#define SRW_TOPADDR 0x1F /* only 5 bits here */
- u_char addr_1;
- u_char addr_0; /* least significant */
- u_char length;
- u_char control;
+ u_int8_t length;
+ u_int8_t control;
};
struct scsi_rw_big {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SRWB_RELADDR 0x01
- u_char addr_3; /* Most significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* least significant */
- u_char reserved;
- u_char length2;
- u_char length1;
- u_char control;
+ u_int8_t addr[4];
+ u_int8_t reserved;
+ u_int8_t length[2];
+ u_int8_t control;
};
struct scsi_read_capacity {
- u_char opcode;
- u_char byte2;
- u_char addr_3; /* Most Significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least Significant */
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t addr[4];
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_start_stop {
- u_char opcode;
- u_char byte2;
- u_char unused[2];
- u_char how;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[2];
+ u_int8_t how;
#define SSS_STOP 0x00
#define SSS_START 0x01
#define SSS_LOEJ 0x02
- u_char control;
+ u_int8_t control;
};
struct scsi_read_cap_data {
- u_char addr_3; /* Most significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least significant */
- u_char length_3; /* Most significant */
- u_char length_2;
- u_char length_1;
- u_char length_0; /* Least significant */
+ u_int8_t addr[4];
+ u_int8_t length[4];
};
struct scsi_reassign_blocks_data {
- u_char reserved[2];
- u_char length_msb;
- u_char length_lsb;
+ u_int8_t reserved[2];
+ u_int8_t length[2];
struct {
- u_char dlbaddr_3; /* defect logical block address (MSB) */
- u_char dlbaddr_2;
- u_char dlbaddr_1;
- u_char dlbaddr_0; /* defect logical block address (LSB) */
+ u_int8_t dlbaddr[4];
} defect_descriptor[1];
};
-union disk_pages { /* this is the structure copied from osf */
- struct page_disk_format {
- u_char pg_code; /* page code (should be 3) */
+union disk_pages {
#define DISK_PGCODE 0x3F /* only 6 bits valid */
- u_char pg_length; /* page length (should be 0x16) */
- u_char trk_z_1; /* tracks per zone (MSB) */
- u_char trk_z_0; /* tracks per zone (LSB) */
- u_char alt_sec_1; /* alternate sectors per zone (MSB) */
- u_char alt_sec_0; /* alternate sectors per zone (LSB) */
- u_char alt_trk_z_1; /* alternate tracks per zone (MSB) */
- u_char alt_trk_z_0; /* alternate tracks per zone (LSB) */
- u_char alt_trk_v_1; /* alternate tracks per volume (MSB) */
- u_char alt_trk_v_0; /* alternate tracks per volume (LSB) */
- u_char ph_sec_t_1; /* physical sectors per track (MSB) */
- u_char ph_sec_t_0; /* physical sectors per track (LSB) */
- u_char bytes_s_1; /* bytes per sector (MSB) */
- u_char bytes_s_0; /* bytes per sector (LSB) */
- u_char interleave_1;/* interleave (MSB) */
- u_char interleave_0;/* interleave (LSB) */
- u_char trk_skew_1; /* track skew factor (MSB) */
- u_char trk_skew_0; /* track skew factor (LSB) */
- u_char cyl_skew_1; /* cylinder skew (MSB) */
- u_char cyl_skew_0; /* cylinder skew (LSB) */
- u_char flags; /* various */
-#define DISK_FMT_SURF 0x10
-#define DISK_FMT_RMB 0x20
-#define DISK_FMT_HSEC 0x40
-#define DISK_FMT_SSEC 0x80
- u_char reserved2;
- u_char reserved3;
+ struct page_disk_format {
+ u_int8_t pg_code; /* page code (should be 3) */
+ u_int8_t pg_length; /* page length (should be 0x16) */
+ u_int8_t trk_z[2]; /* tracks per zone */
+ u_int8_t alt_sec[2]; /* alternate sectors per zone */
+ u_int8_t alt_trk_z[2]; /* alternate tracks per zone */
+ u_int8_t alt_trk_v[2]; /* alternate tracks per volume */
+ u_int8_t ph_sec_t[2]; /* physical sectors per track */
+ u_int8_t bytes_s[2]; /* bytes per sector */
+ u_int8_t interleave[2]; /* interleave */
+ u_int8_t trk_skew[2]; /* track skew factor */
+ u_int8_t cyl_skew[2]; /* cylinder skew */
+ u_int8_t flags; /* various */
+#define DISK_FMT_SURF 0x10
+#define DISK_FMT_RMB 0x20
+#define DISK_FMT_HSEC 0x40
+#define DISK_FMT_SSEC 0x80
+ u_int8_t reserved2;
+ u_int8_t reserved3;
} disk_format;
struct page_rigid_geometry {
- u_char pg_code; /* page code (should be 4) */
- u_char pg_length; /* page length (should be 0x16) */
- u_char ncyl_2; /* number of cylinders (MSB) */
- u_char ncyl_1; /* number of cylinders */
- u_char ncyl_0; /* number of cylinders (LSB) */
- u_char nheads; /* number of heads */
- u_char st_cyl_wp_2; /* starting cyl., write precomp (MSB) */
- u_char st_cyl_wp_1; /* starting cyl., write precomp */
- u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */
- u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/
- u_char st_cyl_rwc_1;/* starting cyl., red. write cur */
- u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/
- u_char driv_step_1; /* drive step rate (MSB) */
- u_char driv_step_0; /* drive step rate (LSB) */
- u_char land_zone_2; /* landing zone cylinder (MSB) */
- u_char land_zone_1; /* landing zone cylinder */
- u_char land_zone_0; /* landing zone cylinder (LSB) */
- u_char sp_sync_ctl; /* spindle synch control */
+ u_int8_t pg_code; /* page code (should be 4) */
+ u_int8_t pg_length; /* page length (should be 0x16) */
+ u_int8_t ncyl[3]; /* number of cylinders */
+ u_int8_t nheads; /* number of heads */
+ u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */
+ u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */
+ u_int8_t driv_step[2]; /* drive step rate */
+ u_int8_t land_zone[3]; /* landing zone cylinder */
+ u_int8_t sp_sync_ctl; /* spindle synch control */
#define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */
#define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */
#define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */
#define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */
#define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */
- u_char rot_offset; /* rotational offset (for spindle synch) */
- u_char reserved1;
- u_char rpm_1; /* media rotation speed (MSB) */
- u_char rpm_0; /* media rotation speed (LSB) */
- u_char reserved2;
- u_char reserved3;
+ u_int8_t rot_offset; /* rotational offset (for spindle synch) */
+ u_int8_t reserved1;
+ u_int8_t rpm[2]; /* media rotation speed */
+ u_int8_t reserved2;
+ u_int8_t reserved3;
} rigid_geometry;
};
-/* $OpenBSD: scsi_scanner.h,v 1.2 1996/04/19 16:10:13 niklas Exp $ */
+/* $OpenBSD: scsi_scanner.h,v 1.3 1996/04/21 22:31:00 deraadt Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
struct scsi_rw_scanner {
#define READ 0x08
#define WRITE 0x0a
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SRW_FIXED 0x01
- u_char len[3];
- u_char control;
+ u_int8_t len[3];
+ u_int8_t control;
};
struct scsi_start_stop {
- u_char opcode;
- u_char byte2;
- u_char unused[2];
- u_char how;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[2];
+ u_int8_t how;
#define SSS_STOP 0x00
#define SSS_START 0x01
#define SSS_LOEJ 0x02
- u_char control;
+ u_int8_t control;
};
struct scsi_set_window {
#define SET_WINDOW 0x24 /* set params of image area and windows */
#define GET_WINDOW 0x25
- u_char opcode;
- u_char byte2;
- u_char reserved[4];
- u_char len[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t reserved[4];
+ u_int8_t len[3];
+ u_int8_t control;
};
struct scsi_window_header {
- u_char reserved[6];
- u_char len[2]; /* MSB-LSB */
+ u_int8_t reserved[6];
+ u_int8_t len[2];
};
struct scsi_window_data {
- u_char window_id; /* must be zero */
- u_char res1:7;
- u_char auto_bit:1;
- u_char x_res[2];
- u_char y_res[2];
- u_char x_org[4];
- u_char y_org[4];
- u_char width[4];
- u_char length[4];
- u_char brightness;
- u_char threshold;
- u_char contrast;
- u_char image_comp; /* image composition (data type) */
- u_char bits_per_pixel;
- u_char halftone_pattern[2];
- u_char rif:1; /* reverse image format (mono negative) */
- u_char res2:4;
- u_char pad_type:3;
- u_char bit_ordering[2];
- u_char compression_type;
- u_char compression_arg;
- u_char res3[6];
+ u_int8_t window_id; /* must be zero */
+ u_int8_t res1:7;
+ u_int8_t auto_bit:1;
+ u_int8_t x_res[2];
+ u_int8_t y_res[2];
+ u_int8_t x_org[4];
+ u_int8_t y_org[4];
+ u_int8_t width[4];
+ u_int8_t length[4];
+ u_int8_t brightness;
+ u_int8_t threshold;
+ u_int8_t contrast;
+ u_int8_t image_comp; /* image composition (data type) */
+ u_int8_t bits_per_pixel;
+ u_int8_t halftone_pattern[2];
+ u_int8_t rif:1; /* reverse image format (mono negative) */
+ u_int8_t res2:4;
+ u_int8_t pad_type:3;
+ u_int8_t bit_ordering[2];
+ u_int8_t compression_type;
+ u_int8_t compression_arg;
+ u_int8_t res3[6];
};
/* mustek scsi commands */
-/* $NetBSD: scsi_tape.h,v 1.6 1994/12/28 19:43:08 mycroft Exp $ */
+/* $NetBSD: scsi_tape.h,v 1.8 1996/03/19 03:07:36 mycroft Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
#define READ 0x08
#define WRITE 0x0a
struct scsi_rw_tape {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SRW_FIXED 0x01
- u_char len[3];
- u_char control;
+ u_int8_t len[3];
+ u_int8_t control;
};
#define SPACE 0x11
struct scsi_space {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SS_CODE 0x03
#define SP_BLKS 0x00
#define SP_FILEMARKS 0x01
#define SP_SEQ_FILEMARKS 0x02
#define SP_EOM 0x03
- u_char number[3];
- u_char control;
+ u_int8_t number[3];
+ u_int8_t control;
};
#define WRITE_FILEMARKS 0x10
struct scsi_write_filemarks {
- u_char opcode;
- u_char byte2;
- u_char number[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t number[3];
+ u_int8_t control;
};
#define REWIND 0x01
struct scsi_rewind {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SR_IMMED 0x01
- u_char unused[3];
- u_char control;
+ u_int8_t unused[3];
+ u_int8_t control;
};
-#define ERASE 0x19
-struct scsi_erase {
- u_char opcode;
- u_char byte2;
-#define SE_LONG 0x01 /* some units do not allow short erase */
-#define SE_IMMED 0x02
- u_char unused[3];
- u_char control;
-} erase;
-
#define LOAD 0x1b
struct scsi_load {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SL_IMMED 0x01
- u_char unused[2];
- u_char how;
+ u_int8_t unused[2];
+ u_int8_t how;
#define LD_UNLOAD 0x00
#define LD_LOAD 0x01
#define LD_RETENSION 0x02
- u_char control;
+ u_int8_t control;
+};
+
+#define ERASE 0x19
+struct scsi_erase {
+ u_int8_t opcode;
+ u_int8_t byte2;
+#define SE_LONG 0x01
+#define SE_IMMED 0x02
+ u_int8_t unused[3];
+ u_int8_t control;
};
#define READ_BLOCK_LIMITS 0x05
struct scsi_block_limits {
- u_char opcode;
- u_char byte2;
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_block_limits_data {
- u_char reserved;
- u_char max_length_2; /* Most significant */
- u_char max_length_1;
- u_char max_length_0; /* Least significant */
- u_char min_length_1; /* Most significant */
- u_char min_length_0; /* Least significant */
+ u_int8_t reserved;
+ u_int8_t max_length[3]; /* Most significant */
+ u_int8_t min_length[2]; /* Most significant */
};
/* See SCSI-II spec 9.3.3.1 */
struct scsi_tape_dev_conf_page {
- u_char pagecode; /* 0x10 */
- u_char pagelength; /* 0x0e */
- u_char byte2;
+ u_int8_t pagecode; /* 0x10 */
+ u_int8_t pagelength; /* 0x0e */
+ u_int8_t byte2;
#define SMT_CAP 0x40 /* change active partition */
#define SMT_CAF 0x20 /* change active format */
#define SMT_AFMASK 0x1f /* active format mask */
- u_char active_partition;
- u_char wb_full_ratio;
- u_char rb_empty_ratio;
- u_char wrdelay_time_1; /* MSB */
- u_char wrdelay_time_0; /* LSB */
- u_char byte8;
+ u_int8_t active_partition;
+ u_int8_t wb_full_ratio;
+ u_int8_t rb_empty_ratio;
+ u_int8_t wrdelay_time[2];
+ u_int8_t byte8;
#define SMT_DBR 0x80 /* data buffer recovery */
#define SMT_BIS 0x40 /* block identifiers supported */
#define SMT_RSMK 0x20 /* report setmarks */
#define SMT_SOCF_MASK 0xc0 /* stop on consecutive formats */
#define SMT_RBO 0x20 /* recover buffer order */
#define SMT_REW 0x10 /* report early warning */
- u_char gap_size;
- u_char byte10;
+ u_int8_t gap_size;
+ u_int8_t byte10;
#define SMT_EODDEFINED 0xe0 /* EOD defined */
#define SMT_EEG 0x10 /* enable EOD generation */
#define SMT_SEW 0x80 /* synchronize at early warning */
- u_char ew_bufsize_2; /* MSB */
- u_char ew_bufsize_1; /* ... */
- u_char ew_bufsize_0; /* LSB */
- u_char sel_comp_alg;
+ u_int8_t ew_bufsize[3];
+ u_int8_t sel_comp_alg;
#define SMT_COMP_NONE 0x00
#define SMT_COMP_DEFAULT 0x01
- u_char reserved;
+ u_int8_t reserved;
};
/* defines for the device specific byte in the mode select/sense header */
/* A special for the CIPHER ST150S(old drive) */
struct block_desc_cipher {
- u_char density;
- u_char nblocks[3];
- u_char reserved;
- u_char blklen[3];
- u_char other;
+ u_int8_t density;
+ u_int8_t nblocks[3];
+ u_int8_t reserved;
+ u_int8_t blklen[3];
+ u_int8_t other;
#define ST150_SEC 0x01 /* soft error count */
#define SR150_AUI 0x02 /* autoload inhibit */
};
-/* $OpenBSD: scsiconf.c,v 1.7 1996/04/19 16:10:15 niklas Exp $ */
-/* $NetBSD: scsiconf.c,v 1.52 1996/03/05 01:45:42 thorpej Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.8 1996/04/21 22:31:04 deraadt Exp $ */
+/* $NetBSD: scsiconf.c,v 1.55 1996/03/21 03:29:40 scottr Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
void scsibusattach __P((struct device *, struct device *, void *));
int scsibussubmatch __P((struct device *, void *, void *));
-struct cfdriver scsibuscd = {
- NULL, "scsibus", scsibusmatch, scsibusattach, DV_DULL,
- sizeof(struct scsibus_softc)
+struct cfattach scsibus_ca = {
+ sizeof(struct scsibus_softc), scsibusmatch, scsibusattach
+};
+
+struct cfdriver scsibus_cd = {
+ NULL, "scsibus", DV_DULL
};
int scsibusprint __P((void *, char *));
return 0;
if (cf->cf_loc[1] != -1 && cf->cf_loc[1] != sc_link->lun)
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
/*
{
if (bus == -1) {
- for (bus = 0; bus < scsibuscd.cd_ndevs; bus++)
- if (scsibuscd.cd_devs[bus])
+ for (bus = 0; bus < scsibus_cd.cd_ndevs; bus++)
+ if (scsibus_cd.cd_devs[bus])
scsi_probe_bus(bus, target, lun);
return 0;
} else {
int maxtarget, mintarget, maxlun, minlun;
u_int8_t scsi_addr;
- if (bus < 0 || bus >= scsibuscd.cd_ndevs)
+ if (bus < 0 || bus >= scsibus_cd.cd_ndevs)
return ENXIO;
- scsi = scsibuscd.cd_devs[bus];
+ scsi = scsibus_cd.cd_devs[bus];
if (!scsi)
return ENXIO;
{{T_CDROM, T_REMOV,
"TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS},
+ {{T_OPTICAL, T_REMOV,
+ "EPSON ", "OMD-5010 ", "3.08"}, SDEV_NOLUNS},
+
{{T_DIRECT, T_FIXED,
"DEC ", "RZ55 (C) DEC", ""}, SDEV_AUTOSAVE},
{{T_DIRECT, T_FIXED,
"MAXTOR ", "LXT-200S ", ""}, SDEV_NOLUNS},
{{T_DIRECT, T_FIXED,
"MST ", "SnapLink ", ""}, SDEV_NOLUNS},
+ {{T_DIRECT, T_FIXED,
+ "NEC ", "D3847 ", "0307"}, SDEV_NOLUNS},
{{T_DIRECT, T_FIXED,
"QUANTUM ", "LPS525S ", ""}, SDEV_NOLUNS},
{{T_DIRECT, T_FIXED,
{{T_DIRECT, T_FIXED,
"TOSHIBA ", "MK538FB ", "6027"}, SDEV_NOLUNS},
+
/* XXX: QIC-36 tape behind Emulex adapter. Very broken. */
{{T_SEQUENTIAL, T_REMOV,
" ", " ", " "}, SDEV_NOLUNS},
-/* $NetBSD: scsiconf.h,v 1.28 1996/02/18 20:32:45 mycroft Exp $ */
+/* $NetBSD: scsiconf.h,v 1.29 1996/03/19 03:07:50 mycroft Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
int scsi_probe_busses __P((int, int, int));
void scsi_strvis __P((u_char *, u_char *, int));
+static __inline void _lto2b __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto3b __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto4b __P((u_int32_t val, u_int8_t *bytes));
+static __inline u_int32_t _2btol __P((u_int8_t *bytes));
+static __inline u_int32_t _3btol __P((u_int8_t *bytes));
+static __inline u_int32_t _4btol __P((u_int8_t *bytes));
-void lto3b __P((u_int32_t val, u_int8_t *bytes));
-u_int32_t _3btol __P((u_int8_t *bytes));
+static __inline void _lto2l __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto3l __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto4l __P((u_int32_t val, u_int8_t *bytes));
+static __inline u_int32_t _2ltol __P((u_int8_t *bytes));
+static __inline u_int32_t _3ltol __P((u_int8_t *bytes));
+static __inline u_int32_t _4ltol __P((u_int8_t *bytes));
+
+static __inline void
+_lto2b(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 8) & 0xff;
+ bytes[1] = val & 0xff;
+}
+
+static __inline void
+_lto3b(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 16) & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+ bytes[2] = val & 0xff;
+}
+
+static __inline void
+_lto4b(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 24) & 0xff;
+ bytes[1] = (val >> 16) & 0xff;
+ bytes[2] = (val >> 8) & 0xff;
+ bytes[3] = val & 0xff;
+}
+
+static __inline u_int32_t
+_2btol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = (bytes[0] << 8) |
+ bytes[1];
+ return (rv);
+}
+
+static __inline u_int32_t
+_3btol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = (bytes[0] << 16) |
+ (bytes[1] << 8) |
+ bytes[2];
+ return (rv);
+}
+
+static __inline u_int32_t
+_4btol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = (bytes[0] << 24) |
+ (bytes[1] << 16) |
+ (bytes[2] << 8) |
+ bytes[3];
+ return (rv);
+}
+
+static __inline void
+_lto2l(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = val & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+}
+
+static __inline void
+_lto3l(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = val & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+ bytes[2] = (val >> 16) & 0xff;
+}
+
+static __inline void
+_lto4l(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = val & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+ bytes[2] = (val >> 16) & 0xff;
+ bytes[3] = (val >> 24) & 0xff;
+}
+
+static __inline u_int32_t
+_2ltol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = bytes[0] |
+ (bytes[1] << 8);
+ return (rv);
+}
+
+static __inline u_int32_t
+_3ltol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = bytes[0] |
+ (bytes[1] << 8) |
+ (bytes[2] << 16);
+ return (rv);
+}
+
+static __inline u_int32_t
+_4ltol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = bytes[0] |
+ (bytes[1] << 8) |
+ (bytes[2] << 16) |
+ (bytes[3] << 24);
+ return (rv);
+}
#endif /* SCSI_SCSICONF_H */
-/* $OpenBSD: sd.c,v 1.6 1996/04/19 16:10:17 niklas Exp $ */
-/* $NetBSD: sd.c,v 1.88 1996/03/05 00:15:15 thorpej Exp $ */
+/* $OpenBSD: sd.c,v 1.7 1996/04/21 22:31:10 deraadt Exp $ */
+/* $NetBSD: sd.c,v 1.95 1996/03/30 21:45:14 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
#include <sys/disk.h>
#include <sys/proc.h>
#include <sys/cpu.h>
+#include <sys/conf.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_disk.h>
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
-#define SDOUTSTANDING 2
+#define SDOUTSTANDING 4
#define SDRETRIES 4
#define SDUNIT(dev) DISKUNIT(dev)
void sdgetdisklabel __P((struct sd_softc *));
void sdstart __P((void *));
int sddone __P((struct scsi_xfer *, int));
-u_long sd_size __P((struct sd_softc *, int));
int sd_reassign_blocks __P((struct sd_softc *, u_long));
int sd_get_parms __P((struct sd_softc *, int));
-struct cfdriver sdcd = {
- NULL, "sd", sdmatch, sdattach, DV_DISK, sizeof(struct sd_softc)
+struct cfattach sd_ca = {
+ sizeof(struct sd_softc), sdmatch, sdattach
+};
+
+struct cfdriver sd_cd = {
+ NULL, "sd", DV_DISK
};
struct dkdriver sddkdriver = { sdstrategy };
sd->sc_dk.dk_name = sd->sc_dev.dv_xname;
disk_attach(&sd->sc_dk);
- sd->sc_dk.dk_driver = &sddkdriver;
-#if !defined(i386) || defined(NEWCONFIG)
+#if !defined(i386)
dk_establish(&sd->sc_dk, &sd->sc_dev); /* XXX */
#endif
sd_get_parms(sd, SCSI_AUTOCONF) != 0)
printf("drive offline\n");
else
- printf("%dMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
+ printf("%ldMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
dp->disksize / (1048576 / dp->blksize), dp->cyls,
dp->heads, dp->sectors, dp->blksize);
}
int error;
unit = SDUNIT(dev);
- if (unit >= sdcd.cd_ndevs)
+ if (unit >= sd_cd.cd_ndevs)
return ENXIO;
- sd = sdcd.cd_devs[unit];
+ sd = sd_cd.cd_devs[unit];
if (!sd)
return ENXIO;
SC_DEBUG(sc_link, SDEV_DB1,
("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
- sdcd.cd_ndevs, part));
+ sd_cd.cd_ndevs, part));
if ((error = sdlock(sd)) != 0)
return error;
int flag, fmt;
struct proc *p;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
int part = SDPART(dev);
int error;
sdstrategy(bp)
struct buf *bp;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(bp->b_dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
int s;
SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdstrategy "));
bzero(&cmd_small, sizeof(cmd_small));
cmd_small.opcode = (bp->b_flags & B_READ) ?
READ_COMMAND : WRITE_COMMAND;
- cmd_small.addr_2 = (blkno >> 16) & 0x1f;
- cmd_small.addr_1 = (blkno >> 8) & 0xff;
- cmd_small.addr_0 = blkno & 0xff;
+ _lto3b(blkno, cmd_small.addr);
cmd_small.length = nblks & 0xff;
cmdlen = sizeof(cmd_small);
cmdp = (struct scsi_generic *)&cmd_small;
bzero(&cmd_big, sizeof(cmd_big));
cmd_big.opcode = (bp->b_flags & B_READ) ?
READ_BIG : WRITE_BIG;
- cmd_big.addr_3 = (blkno >> 24) & 0xff;
- cmd_big.addr_2 = (blkno >> 16) & 0xff;
- cmd_big.addr_1 = (blkno >> 8) & 0xff;
- cmd_big.addr_0 = blkno & 0xff;
- cmd_big.length2 = (nblks >> 8) & 0xff;
- cmd_big.length1 = nblks & 0xff;
+ _lto4b(blkno, cmd_big.addr);
+ _lto2b(nblks, cmd_big.length);
cmdlen = sizeof(cmd_big);
cmdp = (struct scsi_generic *)&cmd_big;
}
sdminphys(bp)
struct buf *bp;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(bp->b_dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
long max;
/*
int flag;
struct proc *p;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
int error;
SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdioctl 0x%lx ", cmd));
(*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0);
case DIOCEJECT:
- return ((sd->sc_link->flags & SDEV_REMOVABLE == 0) ? ENOTTY :
+ return ((sd->sc_link->flags & SDEV_REMOVABLE) == 0 ? ENOTTY :
scsi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0));
default:
}
}
-/*
- * Find out from the device what it's capacity is
- */
-u_long
-sd_size(sd, flags)
- struct sd_softc *sd;
- int flags;
-{
- struct scsi_read_cap_data rdcap;
- struct scsi_read_capacity scsi_cmd;
- u_long size;
-
- /*
- * make up a scsi command and ask the scsi driver to do
- * it for you.
- */
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = READ_CAPACITY;
-
- /*
- * If the command works, interpret the result as a 4 byte
- * number of blocks
- */
- if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
- sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), SDRETRIES,
- 2000, NULL, flags | SCSI_DATA_IN) != 0)
- return 0;
-
- size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) +
- (rdcap.addr_1 << 8) + rdcap.addr_0 + 1;
-
- return size;
-}
-
/*
* Tell the device to map out a defective block
*/
int
-sd_reassign_blocks(sd, block)
+sd_reassign_blocks(sd, blkno)
struct sd_softc *sd;
- u_long block;
+ u_long blkno;
{
struct scsi_reassign_blocks scsi_cmd;
struct scsi_reassign_blocks_data rbdata;
bzero(&rbdata, sizeof(rbdata));
scsi_cmd.opcode = REASSIGN_BLOCKS;
- rbdata.length_msb = 0;
- rbdata.length_lsb = sizeof(rbdata.defect_descriptor[0]);
- rbdata.defect_descriptor[0].dlbaddr_3 = (block >> 24) & 0xff;
- rbdata.defect_descriptor[0].dlbaddr_2 = (block >> 16) & 0xff;
- rbdata.defect_descriptor[0].dlbaddr_1 = (block >> 8) & 0xff;
- rbdata.defect_descriptor[0].dlbaddr_0 = block & 0xff;
+ _lto2b(sizeof(rbdata.defect_descriptor[0]), rbdata.length);
+ _lto4b(blkno, rbdata.defect_descriptor[0].dlbaddr);
return scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), SDRETRIES,
5000, NULL, SCSI_DATA_OUT);
}
-#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 )
-
/*
* Get the scsi driver to send a full inquiry to the * device and use the
* results to fill out the disk parameter structure.
* this depends on which controller (e.g. 1542C is
* different. but we have to put SOMETHING here..)
*/
- sectors = sd_size(sd, flags);
+ sectors = scsi_size(sd->sc_link, flags);
dp->heads = 64;
dp->sectors = 32;
dp->cyls = sectors / (64 * 32);
} else {
SC_DEBUG(sd->sc_link, SDEV_DB3,
("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n",
- _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2),
+ _3btol(scsi_sense.pages.rigid_geometry.ncyl),
scsi_sense.pages.rigid_geometry.nheads,
- b2tol(scsi_sense.pages.rigid_geometry.st_cyl_wp),
- b2tol(scsi_sense.pages.rigid_geometry.st_cyl_rwc),
- b2tol(scsi_sense.pages.rigid_geometry.land_zone)));
+ _2btol(scsi_sense.pages.rigid_geometry.st_cyl_wp),
+ _2btol(scsi_sense.pages.rigid_geometry.st_cyl_rwc),
+ _2btol(scsi_sense.pages.rigid_geometry.land_zone)));
/*
* KLUDGE!! (for zone recorded disks)
* can lead to wasted space! THINK ABOUT THIS !
*/
dp->heads = scsi_sense.pages.rigid_geometry.nheads;
- dp->cyls =
- _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2);
+ dp->cyls = _3btol(scsi_sense.pages.rigid_geometry.ncyl);
dp->blksize = _3btol(scsi_sense.blk_desc.blklen);
if (dp->heads == 0 || dp->cyls == 0) {
if (dp->blksize == 0)
dp->blksize = 512;
- sectors = sd_size(sd, flags);
+ sectors = scsi_size(sd->sc_link, flags);
dp->disksize = sectors;
sectors /= (dp->heads * dp->cyls);
dp->sectors = sectors; /* XXX dubious on SCSI */
if (sdopen(dev, 0, S_IFBLK, NULL) != 0)
return -1;
- sd = sdcd.cd_devs[SDUNIT(dev)];
+ sd = sd_cd.cd_devs[SDUNIT(dev)];
part = SDPART(dev);
if (sd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
part = SDPART(dev);
/* Check for acceptable drive number. */
- if (unit >= sdcd.cd_ndevs || (sd = sdcd.cd_devs[unit]) == NULL)
+ if (unit >= sd_cd.cd_ndevs || (sd = sd_cd.cd_devs[unit]) == NULL)
return ENXIO;
/* Make sure it was initialized. */
- if (sd->sc_link->flags & SDEV_MEDIA_LOADED != SDEV_MEDIA_LOADED)
+ if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) != SDEV_MEDIA_LOADED)
return ENXIO;
/* Convert to disk sectors. Request must be a multiple of size. */
*/
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE_BIG;
- cmd.addr_3 = (blkno >> 24) & 0xff;
- cmd.addr_2 = (blkno >> 16) & 0xff;
- cmd.addr_1 = (blkno >> 8) & 0xff;
- cmd.addr_0 = blkno & 0xff;
- cmd.length2 = (nwrt >> 8) & 0xff;
- cmd.length1 = nwrt & 0xff;
+ _lto4b(blkno, cmd.addr);
+ _lto2b(nwrt, cmd.length);
/*
* Fill out the scsi_xfer structure
* Note: we cannot sleep as we may be an interrupt
-/* $OpenBSD: ss.c,v 1.2 1996/04/19 16:10:19 niklas Exp $ */
-/* $NetBSD: ss.c,v 1.7 1996/03/05 00:15:18 thorpej Exp $ */
+/* $OpenBSD: ss.c,v 1.3 1996/04/21 22:31:12 deraadt Exp $ */
+/* $NetBSD: ss.c,v 1.9 1996/03/30 21:47:00 christos Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/device.h>
-#include <sys/conf.h> /* for cdevsw */
+#include <sys/conf.h>
#include <sys/scanio.h>
#include <scsi/scsi_all.h>
int ssmatch __P((struct device *, void *, void *));
void ssattach __P((struct device *, struct device *, void *));
-struct cfdriver sscd = {
- NULL, "ss", ssmatch, ssattach, DV_DULL, sizeof(struct ss_softc)
+struct cfattach ss_ca = {
+ sizeof(struct ss_softc), ssmatch, ssattach
+};
+
+struct cfdriver ss_cd = {
+ NULL, "ss", DV_DULL
};
void ssstrategy __P((struct buf *));
void ssstart __P((void *));
+void ssminphys __P((struct buf *));
struct scsi_device ss_switch = {
NULL,
ss->buf_queue.b_active = 0;
ss->buf_queue.b_actf = 0;
ss->buf_queue.b_actb = &ss->buf_queue.b_actf;
-
- printf("\n");
}
/*
struct scsi_link *sc_link;
unit = SSUNIT(dev);
- if (unit >= sscd.cd_ndevs)
+ if (unit >= ss_cd.cd_ndevs)
return (ENXIO);
- ss = sscd.cd_devs[unit];
+ ss = ss_cd.cd_devs[unit];
if (!ss)
return (ENXIO);
sc_link = ss->sc_link;
SC_DEBUG(sc_link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", dev,
- unit, sscd.cd_ndevs));
+ unit, ss_cd.cd_ndevs));
if (sc_link->flags & SDEV_OPEN) {
printf("%s: already open\n", ss->sc_dev.dv_xname);
* occurence of an open device
*/
int
-ssclose(dev)
+ssclose(dev, flag, mode, p)
dev_t dev;
+ int flag;
+ int mode;
+ struct proc *p;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
int error;
SC_DEBUG(ss->sc_link, SDEV_DB1, ("closing\n"));
ssminphys(bp)
struct buf *bp;
{
- register struct ss_softc *ss = sscd.cd_devs[SSUNIT(bp->b_dev)];
+ register struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
(ss->sc_link->adapter->scsi_minphys)(bp);
struct uio *uio;
int flag;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
int error;
/* if the scanner has not yet been started, do it now */
ssstrategy(bp)
struct buf *bp;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(bp->b_dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
struct buf *dp;
int s;
splx(s);
return;
-bad:
bp->b_flags |= B_ERROR;
done:
/*
int flag;
struct proc *p;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
int error = 0;
- int unit;
struct scan_io *sio;
switch (cmd) {
-/* $OpenBSD: ss_mustek.c,v 1.2 1996/04/19 16:10:21 niklas Exp $ */
-/* $NetBSD: ss_mustek.c,v 1.1 1996/02/18 20:32:47 mycroft Exp $ */
+/* $OpenBSD: ss_mustek.c,v 1.3 1996/04/21 22:31:13 deraadt Exp $ */
+/* $NetBSD: ss_mustek.c,v 1.3 1996/03/30 21:47:04 christos Exp $ */
/*
* Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved.
struct ss_softc *ss;
struct scsibus_attach_args *sa;
{
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = sa->sa_sc_link;
+#endif
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: start\n"));
ss->sio.scan_scanner_type = 0;
+ printf("\n%s: ", ss->sc_dev.dv_xname);
+
/* first, check the model which determines resolutions */
if (!bcmp(sa->sa_inqbuf->product, "MFS-06000CX", 11)) {
ss->sio.scan_scanner_type = MUSTEK_06000CX;
- printf(": Mustek 6000CX Flatbed 3-pass color scanner, 3 - 600 dpi\n");
+ printf("Mustek 6000CX Flatbed 3-pass color scanner, 3 - 600 dpi\n");
}
if (!bcmp(sa->sa_inqbuf->product, "MFS-12000CX", 11)) {
ss->sio.scan_scanner_type = MUSTEK_12000CX;
- printf(": Mustek 12000CX Flatbed 3-pass color scanner, 6 - 1200 dpi\n");
+ printf("Mustek 12000CX Flatbed 3-pass color scanner, 6 - 1200 dpi\n");
}
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: scanner_type = %d\n",
struct ss_softc *ss;
struct buf *bp;
{
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = ss->sc_link;
+#endif
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_minphys: before: %d\n",
bp->b_bcount));
struct mustek_set_window_data window_data;
struct mustek_start_scan_cmd start_scan_cmd;
struct scsi_link *sc_link = ss->sc_link;
-#ifndef MUSTEK_INCH_SPEC
int pixel_tlx, pixel_tly, pixel_brx, pixel_bry, paperlength;
-#endif
int error;
mustek_compute_sizes(ss);
window_cmd.length = sizeof(window_data);
bzero(&window_data, sizeof(window_data));
- window_data.frame_header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC;
+ window_data.frame.header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC;
#ifdef MUSTEK_INCH_SPEC
/* the positional values are all 1 byte because 256 / 8 = 32" */
- window_data.frame_tl_x_0 = ss->sio.scan_x_origin / 150;
- window_data.frame_tl_x_1 = 0;
- window_data.frame_tl_y_0 = ss->sio.scan_y_origin / 150;
- window_data.frame_tl_y_1 = 0;
- window_data.frame_br_x_0 = (ss->sio.scan_x_origin +
- ss->sio.scan_width) / 150;
- window_data.frame_br_x_1 = 0;
- window_data.frame_br_y_0 = (ss->sio.scan_y_origin +
- ss->sio.scan_height) / 150;
- window_data.frame_br_y_1 = 0;
+ pixel_tlx = ss->sio.scan_x_origin / 150;
+ pixel_tly = ss->sio.scan_y_origin / 150;
+ pixel_brx = pixel_tlx + ss->sio.scan_width / 150;
+ pixel_bry = pixel_tly + ss->sio.scan_height / 150;
#else
pixel_tlx = (ss->sio.scan_x_origin * ss->sio.scan_x_resolution) / 1200;
- window_data.frame_tl_x_0 = pixel_tlx & 0xff;
- window_data.frame_tl_x_1 = (pixel_tlx >> 8) & 0xff;
pixel_tly = (ss->sio.scan_y_origin * ss->sio.scan_y_resolution) / 1200;
- window_data.frame_tl_y_0 = pixel_tly & 0xff;
- window_data.frame_tl_y_1 = (pixel_tly >> 8) & 0xff;
pixel_brx = pixel_tlx +
(ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
- window_data.frame_br_x_0 = pixel_brx & 0xff;
- window_data.frame_br_x_1 = (pixel_brx >> 8) & 0xff;
pixel_bry = pixel_tly +
(ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
- window_data.frame_br_y_0 = pixel_bry & 0xff;
- window_data.frame_br_y_1 = (pixel_bry >> 8) & 0xff;
#endif
+ _lto2l(pixel_tlx, window_data.frame.tl_x);
+ _lto2l(pixel_tly, window_data.frame.tl_y);
+ _lto2l(pixel_brx, window_data.frame.br_x);
+ _lto2l(pixel_bry, window_data.frame.br_y);
#if MUSTEK_WINDOWS >= 1
- window_data.window1_header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC;
- window_data.window1_tl_x_0 = window_data.frame_tl_x_0;
- window_data.window1_tl_x_1 = window_data.frame_tl_x_1;
- window_data.window1_tl_y_0 = window_data.frame_tl_y_0;
- window_data.window1_tl_y_1 = window_data.frame_tl_y_1;
- window_data.window1_br_x_0 = window_data.frame_br_x_0;
- window_data.window1_br_x_1 = window_data.frame_br_x_1;
- window_data.window1_br_y_0 = window_data.frame_br_y_0;
- window_data.window1_br_y_1 = window_data.frame_br_y_1;
+ window_data.window1 = window_data.frame;
+ window_data.window1.header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC;
#endif
/* send the set window command to the scanner */
*/
bzero(&mode_cmd, sizeof(mode_cmd));
mode_cmd.opcode = MUSTEK_MODE_SELECT;
- mode_cmd.length_0 = sizeof(mode_data);
+ _lto2b(sizeof(mode_data), mode_cmd.length);
bzero(&mode_data, sizeof(mode_data));
mode_data.mode =
mode_data.grain = 0;
mode_data.velocity = ss->sio.scan_quality / 20 - 1;
#ifdef MUSTEK_INCH_SPEC
- mode_data.paperlength_0 = 14 * 8; /* 14" */
- mode_data.paperlength_1 = 0;
+ paperlength = 14 * 8; /* 14" */
#else
- paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */
- mode_data.paperlength_0 = paperlength & 0xff;
- mode_data.paperlength_1 = (paperlength >> 8) & 0xff;
+ paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */
#endif
+ _lto2l(paperlength, mode_data.paperlength);
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n"));
/* send the command to the scanner */
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_read: read %d lines\n",
lines_to_read));
- cmd.length_0 = lines_to_read & 0xff;
- cmd.length_1 = (lines_to_read >> 8) & 0xff;
- cmd.length_2 = (lines_to_read >> 16) & 0xff;
+ _lto3b(lines_to_read, cmd.length);
/*
* go ask the adapter to do all this for us
}
if (update) {
- bytes_per_line =
- (data.bytes_per_line_1 << 8) |
- data.bytes_per_line_0;
- lines =
- (data.lines_2 << 16) |
- (data.lines_1 << 8) |
- data.lines_0;
+ bytes_per_line = _2ltol(data.bytes_per_line);
+ lines = _3ltol(data.lines);
if (lines != ss->sio.scan_lines) {
- printf("mustek: lines actual(%d) != computed(%d)\n",
+ printf("mustek: lines actual(%d) != computed(%ld)\n",
lines, ss->sio.scan_lines);
return (EIO);
}
if (bytes_per_line * lines != ss->sio.scan_window_size) {
- printf("mustek: win-size actual(%d) != computed(%d)\n",
+ printf("mustek: win-size actual(%d) != computed(%ld)\n",
bytes_per_line * lines, ss->sio.scan_window_size);
return (EIO);
}
SC_DEBUG(sc_link, SDEV_DB1,
- ("mustek_get_size: bpl=%d, lines=%d\n",
+ ("mustek_get_size: bpl=%ld, lines=%ld\n",
(ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8,
ss->sio.scan_lines));
SC_DEBUG(sc_link, SDEV_DB1, ("window size = %d\n",
-/* $OpenBSD: ss_mustek.h,v 1.2 1996/04/19 16:10:22 niklas Exp $ */
-/* $NetBSD: ss_mustek.h,v 1.1 1996/02/18 20:32:48 mycroft Exp $ */
+/* $OpenBSD: ss_mustek.h,v 1.3 1996/04/21 22:31:15 deraadt Exp $ */
+/* $NetBSD: ss_mustek.h,v 1.2 1996/03/19 03:08:37 mycroft Exp $ */
/*
* Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved.
*/
struct mustek_set_window_cmd {
- u_char opcode; /* 0x04 */
- u_char reserved[3];
- u_char length; /* in bytes */
- u_char control;
+ u_int8_t opcode; /* 0x04 */
+ u_int8_t reserved[3];
+ u_int8_t length; /* in bytes */
+ u_int8_t control;
+};
+
+struct mustek_window {
+ u_int8_t header; /* unit-defines also apply */
+ u_int8_t tl_x[2]; /* LSB */
+ u_int8_t tl_y[2];
+ u_int8_t br_x[2];
+ u_int8_t br_y[2];
};
struct mustek_set_window_data {
#define MUSTEK_LINEART_BACKGROUND 0x00
#define MUSTEK_HALFTONE_BACKGROUND 0x01
- u_char frame_header; /* unit-defines also apply */
- u_char frame_tl_x_0;
- u_char frame_tl_x_1;
- u_char frame_tl_y_0;
- u_char frame_tl_y_1;
- u_char frame_br_x_0;
- u_char frame_br_x_1;
- u_char frame_br_y_0;
- u_char frame_br_y_1;
+ struct mustek_window frame;
#if MUSTEK_WINDOWS >= 1
#define MUSTEK_WINDOW_MASK 0x80
- u_char window1_header; /* unit-defines also apply */
- u_char window1_tl_x_0;
- u_char window1_tl_x_1;
- u_char window1_tl_y_0;
- u_char window1_tl_y_1;
- u_char window1_br_x_0;
- u_char window1_br_x_1;
- u_char window1_br_y_0;
- u_char window1_br_y_1;
+ struct mustek_window window1;
#endif
#if MUSTEK_WINDOWS >= 2
- u_char window2_header;
- u_char window2_tl_x_0;
- u_char window2_tl_x_1;
- u_char window2_tl_y_0;
- u_char window2_tl_y_1;
- u_char window2_br_x_0;
- u_char window2_br_x_1;
- u_char window2_br_y_0;
- u_char window2_br_y_1;
+ struct mustek_window window2;
#endif
#if MUSTEK_WINDOWS >= 3
- u_char window3_header;
- u_char window3_tl_x_0;
- u_char window3_tl_x_1;
- u_char window3_tl_y_0;
- u_char window3_tl_y_1;
- u_char window3_br_x_0;
- u_char window3_br_x_1;
- u_char window3_br_y_0;
- u_char window3_br_y_1;
+ struct mustek_window window3;
#endif
-#if MUSTEK_WINDOWS == 4
- u_char window4_header;
- u_char window4_tl_x_0;
- u_char window4_tl_x_1;
- u_char window4_tl_y_0;
- u_char window4_tl_y_1;
- u_char window4_br_x_0;
- u_char window4_br_x_1;
- u_char window4_br_y_0;
- u_char window4_br_y_1;
+#if MUSTEK_WINDOWS >= 4
+ struct mustek_window window4;
#endif
};
struct mustek_read_cmd {
- u_char opcode; /* 0x08 */
- u_char reserved;
- u_char length_2; /* number of LINES to be read (MSB) */
- u_char length_1; /* number of LINES to be read */
- u_char length_0; /* number of LINES to be read (LSB) */
- u_char control;
+ u_int8_t opcode; /* 0x08 */
+ u_int8_t reserved;
+ u_int8_t length[3];
+ u_int8_t control;
};
struct mustek_get_status_cmd {
- u_char opcode; /* 0x0f */
- u_char reserved[3];
- u_char length; /* 0x06 */
- u_char control;
+ u_int8_t opcode; /* 0x0f */
+ u_int8_t reserved[3];
+ u_int8_t length; /* 0x06 */
+ u_int8_t control;
};
struct mustek_get_status_data {
#define MUSTEK_READY 0
#define MUSTEK_BUSY -1
- u_char ready_busy; /* 0 = ready */
- u_char bytes_per_line_0; /* LSB */
- u_char bytes_per_line_1; /* MSB */
- u_char lines_0; /* LSB */
- u_char lines_1;
- u_char lines_2; /* MSB */
+ u_int8_t ready_busy; /* 0 = ready */
+ u_int8_t bytes_per_line[2]; /* LSB */
+ u_int8_t lines[3]; /* LSB */
};
struct mustek_mode_select_cmd {
- u_char opcode; /* 0x15 */
- u_char reserved[2];
- u_char length_1; /* MSB */
- u_char length_0; /* LSB */
- u_char control;
+ u_int8_t opcode; /* 0x15 */
+ u_int8_t reserved[2];
+ u_int8_t length[2];
+ u_int8_t control;
};
/*
#define MUSTEK_MODE_MASK 0x83
#define MUSTEK_HT_PATTERN_BUILTIN 0x00
#define MUSTEK_HT_PATTERN_DOWNLOADED 0x10
- u_char mode;
- u_char resolution;
- u_char brightness;
- u_char contrast;
- u_char grain; /* 0 = 8x8, ..... 5 = 2x2 */
- u_char velocity; /* 0 = fast, ...., 4 = slow */
- u_char reserved[2];
- u_char paperlength_0; /* LSB */
- u_char paperlength_1; /* MSB */
+ u_int8_t mode;
+ u_int8_t resolution;
+ u_int8_t brightness;
+ u_int8_t contrast;
+ u_int8_t grain; /* 0 = 8x8, ..... 5 = 2x2 */
+ u_int8_t velocity; /* 0 = fast, ...., 4 = slow */
+ u_int8_t reserved[2];
+ u_int8_t paperlength[2]; /* LSB */
};
struct mustek_start_scan_cmd {
- u_char opcode; /* 0x1b */
- u_char reserved[3];
+ u_int8_t opcode; /* 0x1b */
+ u_int8_t reserved[3];
#define MUSTEK_SCAN_STOP 0x00
#define MUSTEK_SCAN_START 0x01
#define MUSTEK_GRAY_FILTER 0x00
#define MUSTEK_BIT_MODE 0x00
#define MUSTEK_RES_STEP_1 0x00
#define MUSTEK_RES_STEP_10 0x80
- u_char mode;
- u_char control;
+ u_int8_t mode;
+ u_int8_t control;
};
#endif /* _SS_MUSTEK_H_ */
-/* $OpenBSD: ss_scanjet.c,v 1.2 1996/04/19 16:10:24 niklas Exp $ */
-/* $NetBSD: ss_scanjet.c,v 1.1 1996/02/18 20:32:49 mycroft Exp $ */
+/* $OpenBSD: ss_scanjet.c,v 1.3 1996/04/21 22:31:17 deraadt Exp $ */
+/* $NetBSD: ss_scanjet.c,v 1.3 1996/03/30 21:47:07 christos Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
struct ss_softc *ss;
struct scsibus_attach_args *sa;
{
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = sa->sa_sc_link;
+#endif
SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: start\n"));
ss->sio.scan_scanner_type = 0;
+ printf("\n%s: ", ss->sc_dev.dv_xname);
+
/* first, check the model (which determines nothing yet) */
if (!bcmp(sa->sa_inqbuf->product, "C1750A", 6)) {
ss->sio.scan_scanner_type = HP_SCANJET_IIC;
- printf(": HP ScanJet IIc\n");
+ printf("HP ScanJet IIc\n");
}
if (!bcmp(sa->sa_inqbuf->product, "C2500A", 6)) {
ss->sio.scan_scanner_type = HP_SCANJET_IIC;
- printf(": HP ScanJet IIcx\n");
+ printf("HP ScanJet IIcx\n");
}
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: scanner_type = %d\n",
+ SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: scanner_type = %d\n",
ss->sio.scan_scanner_type));
/* now install special handlers */
ss->sio.scan_y_resolution = 100;
ss->sio.scan_x_origin = 0;
ss->sio.scan_y_origin = 0;
- ss->sio.scan_brightness = 100;
- ss->sio.scan_contrast = 100;
+ ss->sio.scan_brightness = 128;
+ ss->sio.scan_contrast = 128;
ss->sio.scan_quality = 100;
ss->sio.scan_image_mode = SIM_GRAYSCALE;
struct ss_softc *ss;
struct scan_io *sio;
{
+#if 0
int error;
-#if 0
/*
* if the scanner is triggered, then rewind it
*/
struct ss_softc *ss;
{
char escape_codes[20];
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = ss->sc_link;
+#endif
int error;
scanjet_compute_sizes(ss);
* Handle "fixed-block-mode" tape drives by using the
* block count instead of the length.
*/
- lto3b(bp->b_bcount, cmd.len);
+ _lto3b(bp->b_bcount, cmd.len);
/*
* go ask the adapter to do all this for us
return (0);
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE;
- lto3b(size, cmd.len);
+ _lto3b(size, cmd.len);
return (scsi_scsi_cmd(ss->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
flags | SCSI_DATA_OUT));
p = escape_codes;
- sprintf(p, "\033*f%dP", ss->sio.scan_width / 4);
+ sprintf(p, "\033*f%ldP", ss->sio.scan_width / 4);
p += strlen(p);
- sprintf(p, "\033*f%dQ", ss->sio.scan_height / 4);
+ sprintf(p, "\033*f%ldQ", ss->sio.scan_height / 4);
p += strlen(p);
- sprintf(p, "\033*f%dX", ss->sio.scan_x_origin / 4);
+ sprintf(p, "\033*f%ldX", ss->sio.scan_x_origin / 4);
p += strlen(p);
- sprintf(p, "\033*f%dY", ss->sio.scan_y_origin / 4);
+ sprintf(p, "\033*f%ldY", ss->sio.scan_y_origin / 4);
p += strlen(p);
sprintf(p, "\033*a%dR", ss->sio.scan_x_resolution);
p += strlen(p);
scanjet_compute_sizes(ss)
struct ss_softc *ss;
{
+ int r = 0; /* round up by r 1/1200" */
/*
* Deal with the fact that the HP ScanJet IIc uses 1/300" not 1/1200"
ss->sio.scan_bits_per_pixel = 1;
break;
case SIM_GRAYSCALE:
+ r = 600;
ss->sio.scan_bits_per_pixel = 8;
break;
case SIM_COLOR:
+ r = 600;
ss->sio.scan_bits_per_pixel = 24;
break;
}
ss->sio.scan_pixels_per_line =
- (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
+ (ss->sio.scan_width * ss->sio.scan_x_resolution + r) / 1200;
if (ss->sio.scan_bits_per_pixel == 1)
/* pad to byte boundary: */
ss->sio.scan_pixels_per_line =
(ss->sio.scan_pixels_per_line + 7) & 0xfffffff8;
ss->sio.scan_lines =
- (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
+ (ss->sio.scan_height * ss->sio.scan_y_resolution + r) / 1200;
ss->sio.scan_window_size = ss->sio.scan_lines *
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
}
-/* $OpenBSD: ssvar.h,v 1.2 1996/04/19 16:10:26 niklas Exp $ */
-/* $NetBSD: ssvar.h,v 1.1 1996/02/18 20:32:50 mycroft Exp $ */
+/* $OpenBSD: ssvar.h,v 1.3 1996/04/21 22:31:18 deraadt Exp $ */
+/* $NetBSD: ssvar.h,v 1.2 1996/03/30 21:47:11 christos Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
* Register NULL for a function if you want to try the real SCSI code
* (with quirks table)
*/
+struct ss_softc;
+struct scan_io;
+
struct ss_special {
- int (*set_params)();
- int (*trigger_scanner)();
- int (*get_params)();
- void (*minphys)(); /* some scanners only send line-multiples */
- int (*read)();
- int (*rewind_scanner)();
- int (*load_adf)();
- int (*unload_adf)();
+ int (*set_params) __P((struct ss_softc *, struct scan_io *));
+ int (*trigger_scanner) __P((struct ss_softc *));
+ int (*get_params) __P((struct ss_softc *));
+ /* some scanners only send line-multiples */
+ void (*minphys) __P((struct ss_softc *, struct buf *));
+ int (*read) __P((struct ss_softc *, struct buf *));
+ int (*rewind_scanner) __P((struct ss_softc *));
+ int (*load_adf) __P((struct ss_softc *));
+ int (*unload_adf) __P((struct ss_softc *));
};
/*
-/* $OpenBSD: st.c,v 1.9 1996/04/19 16:10:28 niklas Exp $ */
-/* $NetBSD: st.c,v 1.62 1996/03/05 00:15:23 thorpej Exp $ */
+/* $OpenBSD: st.c,v 1.10 1996/04/21 22:31:20 deraadt Exp $ */
+/* $NetBSD: st.c,v 1.65 1996/03/30 21:45:04 christos Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
#include <sys/user.h>
#include <sys/mtio.h>
#include <sys/device.h>
+#include <sys/conf.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_tape.h>
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
/* Defines for device specific stuff */
#define DEF_FIXED_BSIZE 512
int st_touch_tape __P((struct st_softc *));
int st_erase __P((struct st_softc *, int full, int flags));
-struct cfdriver stcd = {
- NULL, "st", stmatch, stattach, DV_TAPE, sizeof(struct st_softc)
+struct cfattach st_ca = {
+ sizeof(struct st_softc), stmatch, stattach
+};
+
+struct cfdriver st_cd = {
+ NULL, "st", DV_TAPE
};
struct scsi_device st_switch = {
struct scsi_link *sc_link;
unit = STUNIT(dev);
- if (unit >= stcd.cd_ndevs)
+ if (unit >= st_cd.cd_ndevs)
return ENXIO;
- st = stcd.cd_devs[unit];
+ st = st_cd.cd_devs[unit];
if (!st)
return ENXIO;
sc_link = st->sc_link;
SC_DEBUG(sc_link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", dev,
- unit, stcd.cd_ndevs));
+ unit, st_cd.cd_ndevs));
/*
* Only allow one at a time
int mode;
struct proc *p;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
SC_DEBUG(st->sc_link, SDEV_DB1, ("closing\n"));
if ((st->flags & (ST_WRITTEN | ST_FM_WRITTEN)) == ST_WRITTEN)
unit = STUNIT(dev);
mode = STMODE(dev);
dsty = STDSTY(dev);
- st = stcd.cd_devs[unit];
+ st = st_cd.cd_devs[unit];
sc_link = st->sc_link;
if (st->flags & ST_MOUNTED)
ststrategy(bp)
struct buf *bp;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(bp->b_dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(bp->b_dev)];
struct buf *dp;
int s;
*/
if (st->flags & ST_FIXEDBLOCKS) {
cmd.byte2 |= SRW_FIXED;
- lto3b(bp->b_bcount / st->blksize, cmd.len);
+ _lto3b(bp->b_bcount / st->blksize, cmd.len);
} else
- lto3b(bp->b_bcount, cmd.len);
+ _lto3b(bp->b_bcount, cmd.len);
/*
* go ask the adapter to do all this for us
struct uio *uio;
int iomode;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
return (physio(ststrategy, NULL, dev, B_READ,
st->sc_link->adapter->scsi_minphys, uio));
struct uio *uio;
int iomode;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
return (physio(ststrategy, NULL, dev, B_WRITE,
st->sc_link->adapter->scsi_minphys, uio));
flags = 0; /* give error messages, act on errors etc. */
unit = STUNIT(dev);
dsty = STDSTY(dev);
- st = stcd.cd_devs[unit];
+ st = st_cd.cd_devs[unit];
hold_blksize = st->blksize;
hold_density = st->density;
cmd.opcode = READ;
if (st->flags & ST_FIXEDBLOCKS) {
cmd.byte2 |= SRW_FIXED;
- lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE),
+ _lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE),
cmd.len);
} else
- lto3b(size, cmd.len);
+ _lto3b(size, cmd.len);
return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
flags | SCSI_DATA_IN);
}
-#ifdef __STDC__
-#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0)
-#else
-#define b2tol(a) (((unsigned)(a/**/_1) << 8) + (unsigned)a/**/_0)
-#endif
-
/*
* Ask the drive what it's min and max blk sizes are.
*/
if (error)
return error;
- st->blkmin = b2tol(block_limits.min_length);
- st->blkmax = _3btol(&block_limits.max_length_2);
+ st->blkmin = _2btol(block_limits.min_length);
+ st->blkmax = _3btol(block_limits.max_length);
SC_DEBUG(sc_link, SDEV_DB3,
("(%d <= blksize <= %d)\n", st->blkmin, st->blkmax));
else
scsi_select.header.dev_spec |= SMH_DSP_BUFF_MODE_ON;
if (st->flags & ST_FIXEDBLOCKS)
- lto3b(st->blksize, scsi_select.blk_desc.blklen);
+ _lto3b(st->blksize, scsi_select.blk_desc.blklen);
if (st->page_0_size)
bcopy(st->sense_data, scsi_select.sense_data, st->page_0_size);
bzero(&cmd, sizeof(cmd));
cmd.opcode = SPACE;
cmd.byte2 = what;
- lto3b(number, cmd.number);
+ _lto3b(number, cmd.number);
return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), 0, 0, 0, 900000, NULL, flags);
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE_FILEMARKS;
- lto3b(number, cmd.number);
+ _lto3b(number, cmd.number);
return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), 0, 0, 0, 100000, NULL, flags);
/*
* Get the sense fields and work out what code
*/
- if (sense->error_code & SSD_ERRCODE_VALID) {
- bcopy(sense->extended_info, &info, sizeof info);
- info = ntohl(info);
- } else
+ if (sense->error_code & SSD_ERRCODE_VALID)
+ info = _4btol(sense->info);
+ else
info = xs->datalen; /* bad choice if fixed blocks */
if ((sense->error_code & SSD_ERRCODE) != 0x70)
return -1; /* let the generic code handle it */
if (st->flags & ST_FIXEDBLOCKS) {
xs->resid = info * st->blksize;
- if (sense->extended_flags & SSD_EOM) {
+ if (sense->flags & SSD_EOM) {
st->flags |= ST_EIO_PENDING;
if (bp)
bp->b_resid = xs->resid;
}
- if (sense->extended_flags & SSD_FILEMARK) {
+ if (sense->flags & SSD_FILEMARK) {
st->flags |= ST_AT_FILEMARK;
if (bp)
bp->b_resid = xs->resid;
}
- if (sense->extended_flags & SSD_ILI) {
+ if (sense->flags & SSD_ILI) {
st->flags |= ST_EIO_PENDING;
if (bp)
bp->b_resid = xs->resid;
}
} else { /* must be variable mode */
xs->resid = xs->datalen; /* to be sure */
- if (sense->extended_flags & SSD_EOM)
+ if (sense->flags & SSD_EOM)
return EIO;
- if (sense->extended_flags & SSD_FILEMARK) {
+ if (sense->flags & SSD_FILEMARK) {
if (bp)
bp->b_resid = bp->b_bcount;
return 0;
}
- if (sense->extended_flags & SSD_ILI) {
+ if (sense->flags & SSD_ILI) {
if (info < 0) {
/*
* the record was bigger than the read
bp->b_resid = info;
}
}
- key = sense->extended_flags & SSD_KEY;
+ key = sense->flags & SSD_KEY;
if (key == 0x8) {
/*
-/* $OpenBSD: uk.c,v 1.2 1996/04/19 16:10:30 niklas Exp $ */
-/* $NetBSD: uk.c,v 1.14 1996/03/05 00:15:33 thorpej Exp $ */
+/* $OpenBSD: uk.c,v 1.3 1996/04/21 22:31:23 deraadt Exp $ */
+/* $NetBSD: uk.c,v 1.15 1996/03/17 00:59:57 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
int ukmatch __P((struct device *, void *, void *));
void ukattach __P((struct device *, struct device *, void *));
-struct cfdriver ukcd = {
- NULL, "uk", ukmatch, ukattach, DV_DULL, sizeof(struct uk_softc)
+struct cfattach uk_ca = {
+ sizeof(struct uk_softc), ukmatch, ukattach
+};
+
+struct cfdriver uk_cd = {
+ NULL, "uk", DV_DULL
};
/*
struct scsi_link *sc_link;
unit = UKUNIT(dev);
- if (unit >= ukcd.cd_ndevs)
+ if (unit >= uk_cd.cd_ndevs)
return ENXIO;
- uk = ukcd.cd_devs[unit];
+ uk = uk_cd.cd_devs[unit];
if (!uk)
return ENXIO;
sc_link = uk->sc_link;
SC_DEBUG(sc_link, SDEV_DB1,
- ("ukopen: dev=0x%x (unit %d (of %d))\n", dev, unit, ukcd.cd_ndevs));
+ ("ukopen: dev=0x%x (unit %d (of %d))\n", dev, unit, uk_cd.cd_ndevs));
/*
* Only allow one at a time
ukclose(dev)
dev_t dev;
{
- struct uk_softc *uk = ukcd.cd_devs[UKUNIT(dev)];
+ struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
SC_DEBUG(uk->sc_link, SDEV_DB1, ("closing\n"));
uk->sc_link->flags &= ~SDEV_OPEN;
int flag;
struct proc *p;
{
- register struct uk_softc *uk = ukcd.cd_devs[UKUNIT(dev)];
+ register struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
return scsi_do_ioctl(uk->sc_link, dev, cmd, addr, flag, p);
}
-/* $OpenBSD: audioio.h,v 1.4 1996/04/18 21:40:43 niklas Exp $ */
-/* $NetBSD: audioio.h,v 1.5 1996/03/11 05:12:28 scottr Exp $ */
+/* $OpenBSD: audioio.h,v 1.5 1996/04/21 22:31:28 deraadt Exp $ */
+/* $NetBSD: audioio.h,v 1.6 1996/04/09 20:55:22 cgd Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
#define AUDIO_SETFD _IOWR('A', 30, int)
#define AUDIO_PERROR _IOR('A', 31, int)
-/*
+/*
* Mixer device
*/
#define AUDIO_MIN_GAIN 0
-/* $OpenBSD: cdefs.h,v 1.3 1996/03/24 17:00:37 tholo Exp $ */
-/* $NetBSD: cdefs.h,v 1.15 1995/01/19 01:54:52 jtc Exp $ */
+/* $OpenBSD: cdefs.h,v 1.4 1996/04/21 22:31:30 deraadt Exp $ */
+/* $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ */
/*
* Copyright (c) 1991, 1993
#endif
#endif
+#ifdef __KPRINTF_ATTRIBUTE__
+#define __kprintf_attribute__(a) __attribute__(a)
+#else
+#define __kprintf_attribute__(a)
+#endif
+
/* Delete pseudo-keywords wherever they are not available or needed. */
#ifndef __dead
#define __dead
-/* $OpenBSD: chio.h,v 1.3 1996/03/03 12:11:25 niklas Exp $ */
-/* $NetBSD: chio.h,v 1.7 1996/02/19 18:29:06 scottr Exp $ */
+/* $OpenBSD: chio.h,v 1.4 1996/04/21 22:31:32 deraadt Exp $ */
+/* $NetBSD: chio.h,v 1.8 1996/04/03 00:25:21 thorpej Exp $ */
/*
- * Copyright (c) 1982, 1986 The Regents of the University of California.
+ * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * must display the following acknowledgements:
+ * This product includes software developed by Jason R. Thorpe
+ * for And Communications, http://www.and.com/
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CHIO_H_
+#define _SYS_CHIO_H_
+
+/*
+ * Element types. Used as "to" and "from" type indicators in move
+ * and exchange operations.
*
- * @(#)mtio.h 7.6 (Berkeley) 2/5/91
+ * Note that code in sys/scsi/ch.c relies on these values (uses them
+ * as offsets in an array, and other evil), so don't muck with them
+ * unless you know what you're doing.
*/
+#define CHET_MT 0 /* medium transport (picker) */
+#define CHET_ST 1 /* storage transport (slot) */
+#define CHET_IE 2 /* import/export (portal) */
+#define CHET_DT 3 /* data transfer (drive) */
-/* This is a "converted" mtio.h from 386BSD
- Stefan Grefen grefen@goofy.zdv.uni-mainz.de
+/*
+ * Structure used to execute a MOVE MEDIUM command.
*/
+struct changer_move {
+ int cm_fromtype; /* element type to move from */
+ int cm_fromunit; /* logical unit of from element */
+ int cm_totype; /* element type to move to */
+ int cm_tounit; /* logical unit of to element */
+ int cm_flags; /* misc. flags */
+};
-#ifndef _SYS_CHIO_H_
-#define _SYS_CHIO_H_
+/* cm_flags */
+#define CM_INVERT 0x01 /* invert media */
/*
- * Structures and definitions for changer io control commands
+ * Structure used to execute an EXCHANGE MEDIUM command. In an
+ * exchange operation, the following steps occur:
+ *
+ * - media from source is moved to first destination.
+ *
+ * - media previously occupying first destination is moved
+ * to the second destination.
+ *
+ * The second destination may or may not be the same as the source.
+ * In the case of a simple exchange, the source and second destination
+ * are the same.
*/
+struct changer_exchange {
+ int ce_srctype; /* element type of source */
+ int ce_srcunit; /* logical unit of source */
+ int ce_fdsttype; /* element type of first destination */
+ int ce_fdstunit; /* logical unit of first destination */
+ int ce_sdsttype; /* element type of second destination */
+ int ce_sdstunit; /* logical unit of second destination */
+ int ce_flags; /* misc. flags */
+};
+
+/* ce_flags */
+#define CE_INVERT1 0x01 /* invert media 1 */
+#define CE_INVERT2 0x02 /* invert media 2 */
-#define CH_INVERT 0x10000
-#define CH_ADDR_MASK 0xffff
-struct chop {
- short ch_op; /* operations defined below */
- short result; /* the result */
- union {
- struct {
- int chm; /* Transport element */
- int from;
- int to;
- } move;
- struct {
- int chm; /* Transport element */
- int to;
- } position;
- struct {
- short chmo; /* Offset of first CHM */
- short chms; /* No. of CHM */
- short slots; /* No. of Storage Elements */
- short sloto; /* Offset of first SE */
- short imexs; /* No. of Import/Export Slots */
- short imexo; /* Offset of first IM/EX */
- short drives; /* No. of CTS */
- short driveo; /* Offset of first CTS */
- short rot; /* CHM can rotate */
- } getparam;
- struct {
- int type;
-#define CH_CHM 1
-#define CH_STOR 2
-#define CH_IMEX 3
-#define CH_CTS 4
- int from;
- struct {
- u_char elema_1;
- u_char elema_0;
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char full:1;
- u_char rsvd:1;
- u_char except:1;
- u_char :5;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_char :5;
- u_char except:1;
- u_char rsvd:1;
- u_char full:1;
-#endif
- u_char rsvd2;
- union {
- struct {
- u_char add_sense_code;
- u_char add_sense_code_qualifier;
- } specs;
- short add_sense;
-/* WARINING LSB only */
-#define CH_CHOLDER 0x0290 /* Cartridge holder is missing */
-#define CH_STATUSQ 0x0390 /* Status is questionable */
-#define CH_CTS_CLOSED 0x0490 /* CTS door is closed */
- } ch_add_sense;
- u_char rsvd3[3];
-#if BYTE_ORDER == BIG_ENDIAN
- u_char :6;
- u_char invert:1;
- u_char svalid:1;
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char svalid:1;
- u_char invert:1;
- u_char :6;
-#endif
- u_char source_1;
- u_char source_0;
- u_char rsvd4[4];
- } elem_data;
- } get_elem_stat;
- } u;
+/*
+ * Structure used to execute a POSITION TO ELEMENT command. This
+ * moves the current picker in front of the specified element.
+ */
+struct changer_position {
+ int cp_type; /* element type */
+ int cp_unit; /* logical unit of element */
+ int cp_flags; /* misc. flags */
+};
+
+/* cp_flags */
+#define CP_INVERT 0x01 /* invert picker */
+
+/*
+ * Data returned by CHIOGPARAMS.
+ */
+struct changer_params {
+ int cp_curpicker; /* current picker */
+ int cp_npickers; /* number of pickers */
+ int cp_nslots; /* number of slots */
+ int cp_nportals; /* number of import/export portals */
+ int cp_ndrives; /* number of drives */
};
-/* operations */
-#define CHMOVE 1
-#define CHPOSITION 2
-#define CHGETPARAM 3
-#define CHGETELEM 4
+/*
+ * Command used to get element status.
+ */
+struct changer_element_status {
+ int ces_type; /* element type */
+ u_int8_t *ces_data; /* pre-allocated data storage */
+};
+
+/*
+ * Data returned by CHIOGSTATUS is an array of flags bytes.
+ * Not all flags have meaning for all element types.
+ */
+#define CESTATUS_FULL 0x01 /* element is full */
+#define CESTATUS_IMPEXP 0x02 /* media deposited by operator */
+#define CESTATUS_EXCEPT 0x04 /* element in abnormal state */
+#define CESTATUS_ACCESS 0x08 /* media accessible by picker */
+#define CESTATUS_EXENAB 0x10 /* element supports exporting */
+#define CESTATUS_INENAB 0x20 /* element supports importing */
+
+#define CESTATUS_PICKER_MASK 0x05 /* flags valid for pickers */
+#define CESTATUS_SLOT_MASK 0x0c /* flags valid for slots */
+#define CESTATUS_PORTAL_MASK 0x3f /* flags valid for portals */
+#define CESTATUS_DRIVE_MASK 0x0c /* flags valid for drives */
+#define CESTATUS_BITS \
+ "\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
-/* Changer IO control command */
-#define CHIOOP _IOWR('c', 1, struct chop) /* do a mag tape op */
+#define CHIOMOVE _IOW('c', 0x01, struct changer_move)
+#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange)
+#define CHIOPOSITION _IOW('c', 0x03, struct changer_position)
+#define CHIOGPICKER _IOR('c', 0x04, int)
+#define CHIOSPICKER _IOW('c', 0x05, int)
+#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params)
+#define CHIOGSTATUS _IOW('c', 0x08, struct changer_element_status)
-#endif /* !_SYS_CHIO_H_ */
+#endif /* _SYS_CHIO_H_ */
-/* $OpenBSD: conf.h,v 1.6 1996/04/18 21:40:47 niklas Exp $ */
-/* $NetBSD: conf.h,v 1.31 1996/03/14 18:59:07 christos Exp $ */
+/* $OpenBSD: conf.h,v 1.7 1996/04/21 22:31:34 deraadt Exp $ */
+/* $NetBSD: conf.h,v 1.32 1996/03/30 21:52:04 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
* @(#)conf.h 8.3 (Berkeley) 1/21/94
*/
-#ifndef _SYS_CONF_H_
-#define _SYS_CONF_H_
/*
* Definitions of device driver entry switches
*/
int chrtoblk __P((dev_t));
int iskmemdev __P((dev_t));
int iszerodev __P((dev_t));
+
+cdev_decl(filedesc);
+
+cdev_decl(log);
+
+#ifndef LKM
+# define NLKM 0
+# define lkmenodev enodev
+#else
+# define NLKM 1
+#endif
+cdev_decl(lkm);
+
+#define ptstty ptytty
+#define ptsioctl ptyioctl
+cdev_decl(pts);
+
+#define ptctty ptytty
+#define ptcioctl ptyioctl
+cdev_decl(ptc);
+
+cdev_decl(ctty);
+
+cdev_decl(audio);
+
+cdev_decl(cn);
+
+bdev_decl(vnd);
+cdev_decl(vnd);
+
+bdev_decl(ccd);
+cdev_decl(ccd);
+
+cdev_decl(ch);
+
+bdev_decl(ss);
+cdev_decl(ss);
+
+bdev_decl(sd);
+cdev_decl(sd);
+
+bdev_decl(st);
+cdev_decl(st);
+
+bdev_decl(cd);
+cdev_decl(cd);
+
+cdev_decl(bpf);
+
+cdev_decl(tun);
+
+#ifdef COMPAT_SVR4
+# define NSVR4_NET 1
+#else
+# define NSVR4_NET 0
#endif
+cdev_decl(svr4_net);
-#endif /* _SYS_CONF_ */
+#endif
-/* $OpenBSD: cpu.h,v 1.4 1996/04/18 21:40:49 niklas Exp $ */
-/* $NetBSD: cpu.h,v 1.4 1996/02/16 17:25:46 gwr Exp $ */
+/* $OpenBSD: cpu.h,v 1.5 1996/04/21 22:31:35 deraadt Exp $ */
+/* $NetBSD: cpu.h,v 1.5 1996/03/16 23:12:11 christos Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
__BEGIN_DECLS
void consinit __P((void));
-void boot __P((int));
+void boot __P((int))
+ __attribute__((__noreturn__));
void pagemove __P((caddr_t, caddr_t, size_t));
/* delay() is declared in <machine/param.h> */
int bounds_check_with_label __P((struct buf *, struct disklabel *, int));
-/* $OpenBSD: device.h,v 1.3 1996/04/18 21:40:51 niklas Exp $ */
-/* $NetBSD: device.h,v 1.11 1996/03/05 22:14:58 thorpej Exp $ */
+/* $OpenBSD: device.h,v 1.4 1996/04/21 22:31:38 deraadt Exp $ */
+/* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
#ifndef _SYS_DEVICE_H_
#define _SYS_DEVICE_H_
+#include <sys/queue.h>
+
/*
* Minimal device structures.
* Note that all ``system'' device types are listed here.
struct device {
enum devclass dv_class; /* this device's classification */
- struct device *dv_next; /* next in list of all */
+ TAILQ_ENTRY(device) dv_list; /* entry on list of all devices */
struct cfdata *dv_cfdata; /* config data that found us */
int dv_unit; /* device unit number */
char dv_xname[16]; /* external name (name + unit) */
struct device *dv_parent; /* pointer to parent device */
};
+TAILQ_HEAD(devicelist, device);
/* `event' counters (use zero or more per device instance, as needed) */
struct evcnt {
- struct evcnt *ev_next; /* linked list */
+ TAILQ_ENTRY(evcnt) ev_list; /* entry on list of all counters */
struct device *ev_dev; /* associated device */
int ev_count; /* how many have occurred */
char ev_name[8]; /* what to call them (systat display) */
};
+TAILQ_HEAD(evcntlist, evcnt);
/*
* Configuration data (i.e., data placed in ioconf.c).
*/
struct cfdata {
+ struct cfattach *cf_attach; /* config attachment */
struct cfdriver *cf_driver; /* config driver */
short cf_unit; /* unit number */
short cf_fstate; /* finding state (below) */
typedef void (*cfscan_t) __P((struct device *, void *));
/*
- * `configuration' driver (what the machine-independent autoconf uses).
- * As devices are found, they are applied against all the potential matches.
- * The one with the best match is taken, and a device structure (plus any
- * other data desired) is allocated. Pointers to these are placed into
- * an array of pointers. The array itself must be dynamic since devices
- * can be found long after the machine is up and running.
+ * `configuration' attachment and driver (what the machine-independent
+ * autoconf uses). As devices are found, they are applied against all
+ * the potential matches. The one with the best match is taken, and a
+ * device structure (plus any other data desired) is allocated. Pointers
+ * to these are placed into an array of pointers. The array itself must
+ * be dynamic since devices can be found long after the machine is up
+ * and running.
+ *
+ * Devices can have multiple configuration attachments if they attach
+ * to different attributes (busses, or whatever), to allow specification
+ * of multiple match and attach functions. There is only one configuration
+ * driver per driver, so that things like unit numbers and the device
+ * structure array will be shared.
*/
+struct cfattach {
+ size_t ca_devsize; /* size of dev data (for malloc) */
+ cfmatch_t ca_match; /* returns a match level */
+ void (*ca_attach) __P((struct device *, struct device *, void *));
+ /* XXX should have detach */
+};
+
struct cfdriver {
void **cd_devs; /* devices found */
char *cd_name; /* device name */
- cfmatch_t cd_match; /* returns a match level */
- void (*cd_attach) __P((struct device *, struct device *, void *));
enum devclass cd_class; /* device classification */
- size_t cd_devsize; /* size of dev data (for malloc) */
int cd_indirect; /* indirectly configure subdevices */
int cd_ndevs; /* size of cd_devs array */
};
};
#ifdef _KERNEL
-struct device *alldevs; /* head of list of all devices */
-struct evcnt *allevents; /* head of list of all events */
+extern struct devicelist alldevs; /* list of all devices */
+extern struct evcntlist allevents; /* list of all event counters */
+
+void config_init __P((void));
void *config_search __P((cfmatch_t, struct device *, void *));
void *config_rootsearch __P((cfmatch_t, char *, void *));
-int config_found_sm __P((struct device *, void *, cfprint_t, cfmatch_t));
-int config_rootfound __P((char *, void *));
+struct device *config_found_sm __P((struct device *, void *, cfprint_t,
+ cfmatch_t));
+struct device *config_rootfound __P((char *, void *));
void config_scan __P((cfscan_t, struct device *));
-void config_attach __P((struct device *, void *, void *, cfprint_t));
+struct device *config_attach __P((struct device *, void *, void *, cfprint_t));
void evcnt_attach __P((struct device *, const char *, struct evcnt *));
/* compatibility definitions */
-/* $OpenBSD: dirent.h,v 1.3 1996/04/18 21:40:52 niklas Exp $ */
-/* $NetBSD: dirent.h,v 1.11 1996/03/08 18:13:05 scottr Exp $ */
+/* $OpenBSD: dirent.h,v 1.4 1996/04/21 22:31:40 deraadt Exp $ */
+/* $NetBSD: dirent.h,v 1.12 1996/04/09 20:55:25 cgd Exp $ */
/*-
* Copyright (c) 1989, 1993
*/
/*
- * The dirent structure defines the format of directory entries returned by
+ * The dirent structure defines the format of directory entries returned by
* the getdirentries(2) system call.
*
* A directory entry has a struct dirent at the front of it, containing its
-/* $OpenBSD: disklabel.h,v 1.5 1996/03/19 21:10:47 mickey Exp $ */
-/* $NetBSD: disklabel.h,v 1.38 1996/02/09 18:25:05 christos Exp $ */
+/* $OpenBSD: disklabel.h,v 1.6 1996/04/21 22:31:42 deraadt Exp $ */
+/* $NetBSD: disklabel.h,v 1.39 1996/04/09 20:55:26 cgd Exp $ */
/*
* Copyright (c) 1987, 1988, 1993
u_int16_t d_subtype; /* controller/d_type specific */
char d_typename[16]; /* type name, e.g. "eagle" */
- /*
+ /*
* d_packname contains the pack identifier and is returned when
* the disklabel is read off the disk or in-core copy.
* d_boot0 and d_boot1 are the (optional) names of the
* getdiskbyname(3) to retrieve the values from /etc/disktab.
*/
union {
- char un_d_packname[16]; /* pack identifier */
+ char un_d_packname[16]; /* pack identifier */
struct {
char *un_d_boot0; /* primary bootstrap name */
char *un_d_boot1; /* secondary bootstrap name */
- } un_b;
- } d_un;
+ } un_b;
+ } d_un;
#define d_packname d_un.un_d_packname
#define d_boot0 d_un.un_b.un_d_boot0
#define d_boot1 d_un.un_b.un_d_boot1
-/* $OpenBSD: filedesc.h,v 1.4 1996/04/18 21:40:55 niklas Exp $ */
-/* $NetBSD: filedesc.h,v 1.13 1996/03/14 18:59:09 christos Exp $ */
+/* $OpenBSD: filedesc.h,v 1.5 1996/04/21 22:31:44 deraadt Exp $ */
+/* $NetBSD: filedesc.h,v 1.14 1996/04/09 20:55:28 cgd Exp $ */
/*
* Copyright (c) 1990, 1993
* that will fit in a power-of-two sized piece of memory.
*/
#define NDFILE 20
-#define NDEXTENT 50 /* 250 bytes in 256-byte alloc. */
+#define NDEXTENT 50 /* 250 bytes in 256-byte alloc. */
struct filedesc {
struct file **fd_ofiles; /* file structures for open files */
-/* $OpenBSD: gmon.h,v 1.2 1996/03/03 12:11:48 niklas Exp $ */
-/* $NetBSD: gmon.h,v 1.4 1994/06/29 06:44:17 cgd Exp $ */
+/* $OpenBSD: gmon.h,v 1.3 1996/04/21 22:31:46 deraadt Exp $ */
+/* $NetBSD: gmon.h,v 1.5 1996/04/09 20:55:30 cgd Exp $ */
/*-
* Copyright (c) 1982, 1986, 1992, 1993
* calls $0,(r0)
* calls $0,(r0)
*
- * which is separated by only three bytes, thus HASHFRACTION is
+ * which is separated by only three bytes, thus HASHFRACTION is
* calculated as:
*
* HASHFRACTION = 3 / (2 * 2 - 1) = 1
* Note that the division above rounds down, thus if MIN_SUBR_FRACTION
* is less than three, this algorithm will not work!
*
- * In practice, however, call instructions are rarely at a minimal
+ * In practice, however, call instructions are rarely at a minimal
* distance. Hence, we will define HASHFRACTION to be 2 across all
- * architectures. This saves a reasonable amount of space for
+ * architectures. This saves a reasonable amount of space for
* profiling data structures without (in practice) sacrificing
* any granularity.
*/
};
/*
- * a raw arc, with pointers to the calling site and
+ * a raw arc, with pointers to the calling site and
* the called site and a count.
*/
struct rawarc {
-/* $OpenBSD: localedef.h,v 1.2 1996/03/03 12:11:56 niklas Exp $ */
-/* $NetBSD: localedef.h,v 1.3 1994/11/30 22:15:58 jtc Exp $ */
+/* $OpenBSD: localedef.h,v 1.3 1996/04/21 22:31:47 deraadt Exp $ */
+/* $NetBSD: localedef.h,v 1.4 1996/04/09 20:55:31 cgd Exp $ */
/*
* Copyright (c) 1994 Winning Strategies, Inc.
extern const _MonetaryLocale *_CurrentMonetaryLocale;
extern const _MonetaryLocale _DefaultMonetaryLocale;
-
+
typedef struct
{
const char *decimal_point;
-/* $OpenBSD: malloc.h,v 1.5 1996/04/18 21:40:59 niklas Exp $ */
-/* $NetBSD: malloc.h,v 1.22 1996/02/22 12:47:33 jtk Exp $ */
+/* $OpenBSD: malloc.h,v 1.6 1996/04/21 22:31:49 deraadt Exp $ */
+/* $NetBSD: malloc.h,v 1.23 1996/04/05 04:52:52 mhitch Exp $ */
/*
* Copyright (c) 1987, 1993
#define M_ANODE 68 /* adosfs anode structures and tables. */
#define M_IPQ 69 /* IP packet queue entry */
#define M_AFS 70 /* Andrew File System */
+#define M_ADOSFSBITMAP 71 /* adosfs bitmap */
#define M_TEMP 84 /* misc temporary data buffers */
#define M_LAST 85 /* Must be last type + 1 */
"adosfs anode", /* 68 M_ANODE */ \
"IP queue ent", /* 69 M_IPQ */ \
"afs", /* 70 M_AFS */ \
- NULL, NULL, NULL, NULL, NULL, \
+ "adosfs bitmap", /* 71 M_ADOSFSBITMAP */ \
+ NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, \
"temp", /* 84 M_TEMP */ \
-/* $OpenBSD: param.h,v 1.7 1996/04/18 21:41:03 niklas Exp $ */
-/* $NetBSD: param.h,v 1.21 1996/03/16 05:35:45 thorpej Exp $ */
+/* $OpenBSD: param.h,v 1.8 1996/04/21 22:31:51 deraadt Exp $ */
+/* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
#define BSD4_4 1
#define NetBSD 199603 /* NetBSD version (year & month). */
-#define NetBSD1_1 2 /* NetBSD 1.1A */
+#define NetBSD1_1 3 /* NetBSD 1.1B */
#ifndef NULL
#define NULL 0
-/* $OpenBSD: protosw.h,v 1.2 1996/03/03 12:12:08 niklas Exp $ */
-/* $NetBSD: protosw.h,v 1.9 1996/02/13 21:08:55 christos Exp $ */
+/* $OpenBSD: protosw.h,v 1.3 1996/04/21 22:31:54 deraadt Exp $ */
+/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
/* utility hooks */
void (*pr_init) /* initialization hook */
__P((void));
-
+
void (*pr_fasttimo) /* fast timeout (200ms) */
__P((void));
void (*pr_slowtimo) /* slow timeout (500ms) */
-/* $OpenBSD: queue.h,v 1.2 1996/03/03 12:12:10 niklas Exp $ */
-/* $NetBSD: queue.h,v 1.9 1994/12/13 15:04:28 mycroft Exp $ */
+/* $OpenBSD: queue.h,v 1.3 1996/04/21 22:31:56 deraadt Exp $ */
+/* $NetBSD: queue.h,v 1.10 1996/04/09 20:55:34 cgd Exp $ */
-/*
+/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
-/* $OpenBSD: shm.h,v 1.2 1996/03/03 12:12:18 niklas Exp $ */
-/* $NetBSD: shm.h,v 1.19 1996/02/09 18:25:30 christos Exp $ */
+/* $OpenBSD: shm.h,v 1.3 1996/04/21 22:31:57 deraadt Exp $ */
+/* $NetBSD: shm.h,v 1.20 1996/04/09 20:55:35 cgd Exp $ */
/*
* Copyright (c) 1994 Adam Glass
struct shminfo shminfo;
struct shmid_ds *shmsegs;
-void shminit __P((void));
+void shminit __P((void));
void shmfork __P((struct proc *, struct proc *));
void shmexit __P((struct proc *));
-/* $OpenBSD: sysctl.h,v 1.4 1996/04/18 21:41:13 niklas Exp $ */
-/* $NetBSD: sysctl.h,v 1.14 1996/03/12 00:22:43 jonathan Exp $ */
+/* $OpenBSD: sysctl.h,v 1.5 1996/04/21 22:31:59 deraadt Exp $ */
+/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
* Copyright (c) 1989, 1993
/*
* Each subsystem defined by sysctl defines a list of variables
- * for that subsystem. Each name is either a node with further
+ * for that subsystem. Each name is either a node with further
* levels defined below it, or it is a leaf of some particular
* type given below. Each sysctl level defines a set of name/type
* pairs to be used by sysctl(1) in manipulating the subsystem.
{ "timex", CTLTYPE_STRUCT }, \
}
-/*
+/*
* KERN_PROC subtypes
*/
#define KERN_PROC_ALL 0 /* everything */
#define KERN_PROC_UID 5 /* by effective uid */
#define KERN_PROC_RUID 6 /* by real uid */
-/*
+/*
* KERN_PROC subtype ops return arrays of augmented proc structures:
*/
struct kinfo_proc {
int sysctl_rdstruct __P((void *, size_t *, void *, void *, int));
int sysctl_vnode __P((char *, size_t *));
int sysctl_ntptime __P((char *, size_t *));
+#ifdef GPROF
+int sysctl_doprof __P((int *, u_int, void *, size_t *, void *, size_t));
+#endif
void fill_eproc __P((struct proc *, struct eproc *));
struct proc *));
int cpu_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
-
#else /* !_KERNEL */
#include <sys/cdefs.h>
-/* $OpenBSD: syslog.h,v 1.2 1996/03/03 12:12:24 niklas Exp $ */
-/* $NetBSD: syslog.h,v 1.10 1996/02/09 18:25:40 christos Exp $ */
+/* $OpenBSD: syslog.h,v 1.3 1996/04/21 22:32:01 deraadt Exp $ */
+/* $NetBSD: syslog.h,v 1.14 1996/04/03 20:46:44 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
void closelog __P((void));
void openlog __P((const char *, int, int));
int setlogmask __P((int));
-void syslog __P((int, const char *, ...));
+void syslog __P((int, const char *, ...))
+ __attribute__((__format__(__printf__,2,3)));
void vsyslog __P((int, const char *, _BSD_VA_LIST_));
__END_DECLS
#else /* !_KERNEL */
void logpri __P((int));
-void log __P((int, const char *, ...));
-void addlog __P((const char *, ...));
+void log __P((int, const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,2,3)));
+void addlog __P((const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,1,2)));
void logwakeup __P((void));
#endif /* !_KERNEL */
-/* $OpenBSD: systm.h,v 1.3 1996/04/18 21:41:14 niklas Exp $ */
-/* $NetBSD: systm.h,v 1.43 1996/03/14 18:59:12 christos Exp $ */
+/* $OpenBSD: systm.h,v 1.4 1996/04/21 22:32:04 deraadt Exp $ */
+/* $NetBSD: systm.h,v 1.48 1996/04/09 20:55:38 cgd Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
* raw disks of mounted filesystems, /dev/mem, and /dev/kmem are
* read-only.
* 2 highly secure mode - same as (1) plus raw disks are always
- * read-only whether mounted or not. This level precludes tampering
+ * read-only whether mounted or not. This level precludes tampering
* with filesystems by unmounting them, but also inhibits running
* newfs while the system is secured.
*
int nullop __P((void *));
int enodev __P((void));
int enosys __P((void));
-int lkmenodev __P((dev_t, int, int, struct proc *));
int enoioctl __P((void));
int enxio __P((void));
int eopnotsupp __P((void));
+
+int lkmenodev __P((void));
+
int seltrue __P((dev_t dev, int which, struct proc *p));
void *hashinit __P((int count, int type, u_long *hashmask));
int sys_nosys __P((struct proc *, void *, register_t *));
-#ifdef __GNUC__
-volatile void panic __P((const char *, ...));
+void panic __P((const char *, ...))
+#ifdef __KPRINTF_ATTRIBUTE__
+ __kprintf_attribute__((__noreturn__,__format__(__kprintf__,1,2)));
#else
-void panic __P((const char *, ...));
+ __attribute__((__noreturn__));
#endif
+void printf __P((const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,1,2)));
+void uprintf __P((const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,1,2)));
+int sprintf __P((char *buf, const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,2,3)));
+void ttyprintf __P((struct tty *, const char *, ...))
+ __kprintf_attribute__((__format__(__kprintf__,2,3)));
+
void tablefull __P((const char *));
-void printf __P((const char *, ...));
-void uprintf __P((const char *, ...));
-int sprintf __P((char *buf, const char *, ...));
-void ttyprintf __P((struct tty *, const char *, ...));
void bcopy __P((const void *from, void *to, size_t len));
void ovbcopy __P((const void *from, void *to, size_t len));
int setjmp __P((label_t *));
void longjmp __P((label_t *));
+#ifdef GPROF
+void kmstartup __P((void));
+#endif
+
#include <lib/libkern/libkern.h>
#ifdef DDB
-/* $OpenBSD: termios.h,v 1.2 1996/03/03 12:12:26 niklas Exp $ */
-/* $NetBSD: termios.h,v 1.13 1995/04/22 13:03:10 cgd Exp $ */
+/* $OpenBSD: termios.h,v 1.3 1996/04/21 22:32:05 deraadt Exp $ */
+/* $NetBSD: termios.h,v 1.14 1996/04/09 20:55:41 cgd Exp $ */
/*
* Copyright (c) 1988, 1989, 1993, 1994
#ifndef _SYS_TERMIOS_H_
#define _SYS_TERMIOS_H_
-/*
- * Special Control Characters
+/*
+ * Special Control Characters
*
* Index into c_cc[] character array.
*
- * Name Subscript Enabled by
+ * Name Subscript Enabled by
*/
#define VEOF 0 /* ICANON */
#define VEOL 1 /* ICANON */
#define VERASE 3 /* ICANON */
#ifndef _POSIX_SOURCE
#define VWERASE 4 /* ICANON */
-#endif
+#endif
#define VKILL 5 /* ICANON */
#ifndef _POSIX_SOURCE
#define VREPRINT 6 /* ICANON */
#endif
-/*
+/*
* "Local" flags - dumping ground for other state
*
* Warning: some flags in this structure begin with
int c_ospeed; /* output speed */
};
-/*
+/*
* Commands passed to tcsetattr() for setting the termios structure.
*/
#define TCSANOW 0 /* make change immediate */
-/* $OpenBSD: timex.h,v 1.3 1996/04/18 21:41:16 niklas Exp $ */
+/* $OpenBSD: timex.h,v 1.4 1996/04/21 22:32:08 deraadt Exp $ */
/* $NetBSD: timex.h,v 1.2 1996/02/27 04:20:34 jonathan Exp $ */
/******************************************************************************
#endif /* __FreeBSD__ || __NetBSD__ */
#endif /* _SYS_TIMEX_H_ */
-/* $OpenBSD: timex.h,v 1.3 1996/04/18 21:41:16 niklas Exp $ */
-
-/******************************************************************************
- * *
- * Copyright (c) David L. Mills 1993, 1994 *
- * *
- * Permission to use, copy, modify, and distribute this software and its *
- * documentation for any purpose and without fee is hereby granted, provided *
- * that the above copyright notice appears in all copies and that both the *
- * copyright notice and this permission notice appear in supporting *
- * documentation, and that the name University of Delaware not be used in *
- * advertising or publicity pertaining to distribution of the software *
- * without specific, written prior permission. The University of Delaware *
- * makes no representations about the suitability this software for any *
- * purpose. It is provided "as is" without express or implied warranty. *
- * *
- ******************************************************************************/
-
-/*
- * Modification history timex.h
- *
- * 26 Sep 94 David L. Mills
- * Added defines for hybrid phase/frequency-lock loop.
- *
- * 19 Mar 94 David L. Mills
- * Moved defines from kernel routines to header file and added new
- * defines for PPS phase-lock loop.
- *
- * 20 Feb 94 David L. Mills
- * Revised status codes and structures for external clock and PPS
- * signal discipline.
- *
- * 28 Nov 93 David L. Mills
- * Adjusted parameters to improve stability and increase poll
- * interval.
- *
- * 17 Sep 93 David L. Mills
- * Created file
- */
-/*
- * This header file defines the Network Time Protocol (NTP) interfaces
- * for user and daemon application programs. These are implemented using
- * private syscalls and data structures and require specific kernel
- * support.
- *
- * NAME
- * ntp_gettime - NTP user application interface
- *
- * SYNOPSIS
- * #include <sys/timex.h>
- *
- * int syscall(SYS_ntp_gettime, tptr)
- *
- * int SYS_ntp_gettime defined in syscall.h header file
- * struct ntptimeval *tptr pointer to ntptimeval structure
- *
- * NAME
- * ntp_adjtime - NTP daemon application interface
- *
- * SYNOPSIS
- * #include <sys/timex.h>
- *
- * int syscall(SYS_ntp_adjtime, mode, tptr)
- *
- * int SYS_ntp_adjtime defined in syscall.h header file
- * struct timex *tptr pointer to timex structure
- *
- */
-#ifndef _SYS_TIMEX_H_
-#define _SYS_TIMEX_H_ 1
-
-#include <sys/syscall.h>
-
-/*
- * The following defines establish the engineering parameters of the
- * phase-lock loop (PLL) model used in the kernel implementation. These
- * parameters have been carefully chosen by analysis for good stability
- * and wide dynamic range.
- *
- * The hz variable is defined in the kernel build environment. It
- * establishes the timer interrupt frequency, 100 Hz for the SunOS
- * kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1
- * kernel. SHIFT_HZ expresses the same value as the nearest power of two
- * in order to avoid hardware multiply operations.
- *
- * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
- * for a slightly underdamped convergence characteristic. SHIFT_KH
- * establishes the damping of the FLL and is chosen by wisdom and black
- * art.
- *
- * MAXTC establishes the maximum time constant of the PLL. With the
- * SHIFT_KG and SHIFT_KF values given and a time constant range from
- * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
- * respectively.
- */
-#define SHIFT_HZ 7 /* log2(hz) */
-#define SHIFT_KG 6 /* phase factor (shift) */
-#define SHIFT_KF 16 /* PLL frequency factor (shift) */
-#define SHIFT_KH 2 /* FLL frequency factor (shift) */
-#define MAXTC 6 /* maximum time constant (shift) */
-
-/*
- * The following defines establish the scaling of the various variables
- * used by the PLL. They are chosen to allow the greatest precision
- * possible without overflow of a 32-bit word.
- *
- * SHIFT_SCALE defines the scaling (shift) of the time_phase variable,
- * which serves as a an extension to the low-order bits of the system
- * clock variable time.tv_usec.
- *
- * SHIFT_UPDATE defines the scaling (shift) of the time_offset variable,
- * which represents the current time offset with respect to standard
- * time.
- *
- * SHIFT_USEC defines the scaling (shift) of the time_freq and
- * time_tolerance variables, which represent the current frequency
- * offset and maximum frequency tolerance.
- *
- * FINEUSEC is 1 us in SHIFT_UPDATE units of the time_phase variable.
- */
-#define SHIFT_SCALE 22 /* phase scale (shift) */
-#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
-#define SHIFT_USEC 16 /* frequency offset scale (shift) */
-#define FINEUSEC (1L << SHIFT_SCALE) /* 1 us in phase units */
-
-/*
- * The following defines establish the performance envelope of the PLL.
- * They insure it operates within predefined limits, in order to satisfy
- * correctness assertions. An excursion which exceeds these bounds is
- * clamped to the bound and operation proceeds accordingly. In practice,
- * this can occur only if something has failed or is operating out of
- * tolerance, but otherwise the PLL continues to operate in a stable
- * mode.
- *
- * MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as
- * defined in the NTP specification. CLOCK.MAX establishes the maximum
- * time offset allowed before the system time is reset, rather than
- * incrementally adjusted. Here, the maximum offset is clamped to
- * MAXPHASE only in order to prevent overflow errors due to defective
- * protocol implementations.
- *
- * MAXFREQ is the maximum frequency tolerance of the CPU clock
- * oscillator plus the maximum slew rate allowed by the protocol. It
- * should be set to at least the frequency tolerance of the oscillator
- * plus 100 ppm for vernier frequency adjustments. If the kernel
- * PPS discipline code is configured (PPS_SYNC), the oscillator time and
- * frequency are disciplined to an external source, presumably with
- * negligible time and frequency error relative to UTC, and MAXFREQ can
- * be reduced.
- *
- * MAXTIME is the maximum jitter tolerance of the PPS signal if the
- * kernel PPS discipline code is configured (PPS_SYNC).
- *
- * MINSEC and MAXSEC define the lower and upper bounds on the interval
- * between protocol updates.
- */
-#define MAXPHASE 512000L /* max phase error (us) */
-#ifdef PPS_SYNC
-#define MAXFREQ (512L << SHIFT_USEC) /* max freq error (100 ppm) */
-#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
-#else
-#define MAXFREQ (512L << SHIFT_USEC) /* max freq error (200 ppm) */
-#endif /* PPS_SYNC */
-#define MINSEC 16L /* min interval between updates (s) */
-#define MAXSEC 1200L /* max interval between updates (s) */
-
-#ifdef PPS_SYNC
-/*
- * The following defines are used only if a pulse-per-second (PPS)
- * signal is available and connected via a modem control lead, such as
- * produced by the optional ppsclock feature incorporated in the Sun
- * asynch driver. They establish the design parameters of the frequency-
- * lock loop used to discipline the CPU clock oscillator to the PPS
- * signal.
- *
- * PPS_AVG is the averaging factor for the frequency loop, as well as
- * the time and frequency dispersion.
- *
- * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
- * calibration intervals, respectively, in seconds as a power of two.
- *
- * PPS_VALID is the maximum interval before the PPS signal is considered
- * invalid and protocol updates used directly instead.
- *
- * MAXGLITCH is the maximum interval before a time offset of more than
- * MAXTIME is believed.
- */
-#define PPS_AVG 2 /* pps averaging constant (shift) */
-#define PPS_SHIFT 2 /* min interval duration (s) (shift) */
-#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */
-#define PPS_VALID 120 /* pps signal watchdog max (s) */
-#define MAXGLITCH 30 /* pps signal glitch max (s) */
-#endif /* PPS_SYNC */
-
-/*
- * The following defines and structures define the user interface for
- * the ntp_gettime() and ntp_adjtime() system calls.
- *
- * Control mode codes (timex.modes)
- */
-#define MOD_OFFSET 0x0001 /* set time offset */
-#define MOD_FREQUENCY 0x0002 /* set frequency offset */
-#define MOD_MAXERROR 0x0004 /* set maximum time error */
-#define MOD_ESTERROR 0x0008 /* set estimated time error */
-#define MOD_STATUS 0x0010 /* set clock status bits */
-#define MOD_TIMECONST 0x0020 /* set pll time constant */
-#define MOD_CLKB 0x4000 /* set clock B */
-#define MOD_CLKA 0x8000 /* set clock A */
-
-/*
- * Status codes (timex.status)
- */
-#define STA_PLL 0x0001 /* enable PLL updates (rw) */
-#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
-#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
-#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
-
-#define STA_INS 0x0010 /* insert leap (rw) */
-#define STA_DEL 0x0020 /* delete leap (rw) */
-#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
-#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
-
-#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
-#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
-#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
-#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
-
-#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
-
-#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
- STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
-
-/*
- * Clock states (time_state)
- */
-#define TIME_OK 0 /* no leap second warning */
-#define TIME_INS 1 /* insert leap second warning */
-#define TIME_DEL 2 /* delete leap second warning */
-#define TIME_OOP 3 /* leap second in progress */
-#define TIME_WAIT 4 /* leap second has occured */
-#define TIME_ERROR 5 /* clock not synchronized */
-
-/*
- * NTP user interface (ntp_gettime()) - used to read kernel clock values
- *
- * Note: maximum error = NTP synch distance = dispersion + delay / 2;
- * estimated error = NTP dispersion.
- */
-struct ntptimeval {
- struct timeval time; /* current time (ro) */
- long maxerror; /* maximum error (us) (ro) */
- long esterror; /* estimated error (us) (ro) */
-};
-
-/*
- * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock
- * oscillator
- */
-struct timex {
- unsigned int modes; /* clock mode bits (wo) */
- long offset; /* time offset (us) (rw) */
- long freq; /* frequency offset (scaled ppm) (rw) */
- long maxerror; /* maximum error (us) (rw) */
- long esterror; /* estimated error (us) (rw) */
- int status; /* clock status bits (rw) */
- long constant; /* pll time constant (rw) */
- long precision; /* clock precision (us) (ro) */
- long tolerance; /* clock frequency tolerance (scaled
- * ppm) (ro) */
- /*
- * The following read-only structure members are implemented
- * only if the PPS signal discipline is configured in the
- * kernel.
- */
- long ppsfreq; /* pps frequency (scaled ppm) (ro) */
- long jitter; /* pps jitter (us) (ro) */
- int shift; /* interval duration (s) (shift) (ro) */
- long stabil; /* pps stability (scaled ppm) (ro) */
- long jitcnt; /* jitter limit exceeded (ro) */
- long calcnt; /* calibration intervals (ro) */
- long errcnt; /* calibration errors (ro) */
- long stbcnt; /* stability limit exceeded (ro) */
-
-};
-
-#ifndef _KERNEL
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-extern int ntp_gettime __P((struct ntptimeval *));
-extern int ntp_adjtime __P((struct timex *));
-__END_DECLS
-
-#endif /* not _KERNEL */
-#endif /* _SYS_TIMEX_H_ */
-/* $OpenBSD: tprintf.h,v 1.2 1996/03/03 12:12:30 niklas Exp $ */
-/* $NetBSD: tprintf.h,v 1.6 1994/06/29 06:45:49 cgd Exp $ */
+/* $OpenBSD: tprintf.h,v 1.3 1996/04/21 22:32:10 deraadt Exp $ */
+/* $NetBSD: tprintf.h,v 1.10 1996/04/09 20:55:43 cgd Exp $ */
/*-
* Copyright (c) 1990, 1993
tpr_t tprintf_open __P((struct proc *));
void tprintf_close __P((tpr_t));
-void tprintf __P((tpr_t, const char *fmt, ...));
+void tprintf __P((tpr_t, const char *fmt, ...))
+ __kprintf_attribute__((__format__(__kprintf__,2,3)));
-/* $OpenBSD: tty.h,v 1.2 1996/03/03 12:12:32 niklas Exp $ */
-/* $NetBSD: tty.h,v 1.29 1996/02/09 18:25:44 christos Exp $ */
+/* $OpenBSD: tty.h,v 1.3 1996/04/21 22:32:12 deraadt Exp $ */
+/* $NetBSD: tty.h,v 1.30 1996/04/09 20:55:44 cgd Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
* exactly the same behaviour as in true clists.
* if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
* (but, saves memory and cpu time)
- *
+ *
* *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside tty_subr.c!!!
*/
struct clist {
-/* $OpenBSD: ttydefaults.h,v 1.3 1996/03/03 12:12:35 niklas Exp $ */
-/* $NetBSD: ttydefaults.h,v 1.7 1994/06/29 06:45:57 cgd Exp $ */
+/* $OpenBSD: ttydefaults.h,v 1.4 1996/04/21 22:32:13 deraadt Exp $ */
+/* $NetBSD: ttydefaults.h,v 1.8 1996/04/09 20:55:45 cgd Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
*/
#ifdef TTYDEFCHARS
cc_t ttydefchars[NCCS] = {
- CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
+ CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
_POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE
};
-/* $OpenBSD: types.h,v 1.7 1996/04/18 21:41:17 niklas Exp $ */
-/* $NetBSD: types.h,v 1.25 1996/03/15 19:54:53 jtc Exp $ */
+/* $OpenBSD: types.h,v 1.8 1996/04/21 22:32:15 deraadt Exp $ */
+/* $NetBSD: types.h,v 1.26 1996/04/09 20:55:47 cgd Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
/*
* These belong in unistd.h, but are placed here too to ensure that
- * long arguments will be promoted to off_t if the program fails to
+ * long arguments will be promoted to off_t if the program fails to
* include that header or explicitly cast them to off_t.
*/
#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-/* $OpenBSD: user.h,v 1.2 1996/03/03 12:12:42 niklas Exp $ */
-/* $NetBSD: user.h,v 1.9 1995/03/26 20:25:03 jtc Exp $ */
+/* $OpenBSD: user.h,v 1.3 1996/04/21 22:32:17 deraadt Exp $ */
+/* $NetBSD: user.h,v 1.10 1996/04/09 20:55:49 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* This structure may or may not be at the same kernel address
* in all processes.
*/
-
+
struct user {
struct pcb u_pcb;
-/* $OpenBSD: vsio.h,v 1.2 1996/03/03 12:12:48 niklas Exp $ */
-/* $NetBSD: vsio.h,v 1.6 1994/06/29 06:46:20 cgd Exp $ */
+/* $OpenBSD: vsio.h,v 1.3 1996/04/21 22:32:19 deraadt Exp $ */
+/* $NetBSD: vsio.h,v 1.7 1996/04/09 20:55:50 cgd Exp $ */
/*-
* Copyright (c) 1987, 1993
* *
* *
****************************************************************************/
-/*
+/*
* vsio.h - VS100 I/O command definitions
- *
+ *
* Author: Christopher A. Kent
* Digital Equipment Corporation
* Western Research Lab
* Date: Tue Jun 21 1983
*/
-/*
+/*
* Possible ioctl calls
*/
#define VS_FIB_FINITE 1 /* finite retries */
#define VS_FIB_INFINITE 2 /* infinite retries */
-/*
+/*
* Event queue entries
*/
-/* $OpenBSD: wait.h,v 1.3 1996/03/03 12:12:49 niklas Exp $ */
-/* $NetBSD: wait.h,v 1.10 1995/10/19 08:14:18 jtc Exp $ */
+/* $OpenBSD: wait.h,v 1.4 1996/04/21 22:32:21 deraadt Exp $ */
+/* $NetBSD: wait.h,v 1.11 1996/04/09 20:55:51 cgd Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993, 1994
* Terminated process status.
*/
struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
unsigned int w_Termsig:7, /* termination signal */
w_Coredump:1, /* core dump indicator */
w_Retcode:8, /* exit code if w_termsig==0 */
w_Filler:16; /* upper bits filler */
#endif
-#if BYTE_ORDER == BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
unsigned int w_Filler:16, /* upper bits filler */
w_Retcode:8, /* exit code if w_termsig==0 */
w_Coredump:1, /* core dump indicator */
* with the WUNTRACED option bit.
*/
struct {
-#if BYTE_ORDER == LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
w_Stopsig:8, /* signal that stopped us */
w_Filler:16; /* upper bits filler */
#endif
-#if BYTE_ORDER == BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
unsigned int w_Filler:16, /* upper bits filler */
w_Stopsig:8, /* signal that stopped us */
w_Stopval:8; /* == W_STOPPED if stopped */
-/* $OpenBSD: ffs_alloc.c,v 1.2 1996/02/27 07:27:34 niklas Exp $ */
-/* $NetBSD: ffs_alloc.c,v 1.9 1996/02/09 22:22:18 christos Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.3 1996/04/21 22:32:28 deraadt Exp $ */
+/* $NetBSD: ffs_alloc.c,v 1.10 1996/03/17 02:16:18 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
fs = ip->i_fs;
if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) {
- printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n",
+ printf("dev = 0x%x, bsize = %d, size = %ld, fs = %s\n",
ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
panic("blkfree: bad size");
}
-/* $OpenBSD: ffs_subr.c,v 1.2 1996/02/27 07:27:39 niklas Exp $ */
-/* $NetBSD: ffs_subr.c,v 1.5 1996/02/09 22:22:24 christos Exp $ */
+/* $OpenBSD: ffs_subr.c,v 1.3 1996/04/21 22:32:33 deraadt Exp $ */
+/* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
ep->b_blkno + btodb(ep->b_bcount) <= start)
continue;
vprint("Disk overlap", vp);
- (void)printf("\tstart %d, end %d overlap start %d, end %d\n",
+ (void)printf("\tstart %d, end %d overlap start %d, end %ld\n",
start, last, ep->b_blkno,
ep->b_blkno + btodb(ep->b_bcount) - 1);
panic("Disk buffer overlap");
-/* $OpenBSD: lfs_alloc.c,v 1.3 1996/03/19 21:10:51 mickey Exp $ */
-/* $NetBSD: lfs_alloc.c,v 1.3 1996/02/09 22:28:47 christos Exp $ */
+/* $OpenBSD: lfs_alloc.c,v 1.4 1996/04/21 22:32:39 deraadt Exp $ */
+/* $NetBSD: lfs_alloc.c,v 1.4 1996/03/25 12:53:37 pk Exp $ */
/*
* Copyright (c) 1991, 1993
extern int (**lfs_vnodeop_p) __P((void *));
struct inode *ip;
struct ufsmount *ump;
- int error, i;
+ int error;
+#ifdef QUOTA
+ int i;
+#endif
/* Create the vnode. */
if ((error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, vpp)) != 0) {
-/* $OpenBSD: lfs_debug.c,v 1.2 1996/02/27 07:13:23 niklas Exp $ */
-/* $NetBSD: lfs_debug.c,v 1.3 1996/02/12 22:08:47 christos Exp $ */
+/* $OpenBSD: lfs_debug.c,v 1.3 1996/04/21 22:32:42 deraadt Exp $ */
+/* $NetBSD: lfs_debug.c,v 1.4 1996/03/17 02:16:28 christos Exp $ */
/*
* Copyright (c) 1991, 1993
{
int i;
- (void)printf("%s%lx\t%s%lx\t%s%d\t%s%d\n",
+ (void)printf("%s%x\t%s%x\t%s%d\t%s%d\n",
"magic ", lfsp->lfs_magic,
"version ", lfsp->lfs_version,
"size ", lfsp->lfs_size,
"cleansz ", lfsp->lfs_cleansz,
"segtabsz ", lfsp->lfs_segtabsz);
- (void)printf("%s%lx\t%s%d\t%s%lx\t%s%d\n",
+ (void)printf("%s%x\t%s%d\t%s%x\t%s%d\n",
"segmask ", lfsp->lfs_segmask,
"segshift ", lfsp->lfs_segshift,
"bmask ", lfsp->lfs_bmask,
"bshift ", lfsp->lfs_bshift);
- (void)printf("%s%lx\t%s%d\t%s%lx\t%s%d\n",
+ (void)printf("%s%x\t%s%d\t%s%x\t%s%d\n",
"ffmask ", lfsp->lfs_ffmask,
"ffshift ", lfsp->lfs_ffshift,
"fbmask ", lfsp->lfs_fbmask,
"fbshift ", lfsp->lfs_fbshift);
- (void)printf("%s%d\t%s%d\t%s%lx\t%s%qx\n",
+ (void)printf("%s%d\t%s%d\t%s%x\t%s%qx\n",
"sushift ", lfsp->lfs_sushift,
"fsbtodb ", lfsp->lfs_fsbtodb,
"cksum ", lfsp->lfs_cksum,
(void)printf("Superblock disk addresses:");
for (i = 0; i < LFS_MAXNUMSB; i++)
- (void)printf(" %lx", lfsp->lfs_sboffs[i]);
+ (void)printf(" %x", lfsp->lfs_sboffs[i]);
(void)printf("\n");
(void)printf("Checkpoint Info\n");
- (void)printf("%s%d\t%s%lx\t%s%d\n",
+ (void)printf("%s%d\t%s%x\t%s%d\n",
"free ", lfsp->lfs_free,
"idaddr ", lfsp->lfs_idaddr,
"ifile ", lfsp->lfs_ifile);
- (void)printf("%s%lx\t%s%d\t%s%lx\t%s%lx\t%s%lx\t%s%lx\n",
+ (void)printf("%s%x\t%s%d\t%s%x\t%s%x\t%s%x\t%s%x\n",
"bfree ", lfsp->lfs_bfree,
"nfiles ", lfsp->lfs_nfiles,
"lastseg ", lfsp->lfs_lastseg,
"nextseg ", lfsp->lfs_nextseg,
"curseg ", lfsp->lfs_curseg,
"offset ", lfsp->lfs_offset);
- (void)printf("tstamp %lx\n", lfsp->lfs_tstamp);
+ (void)printf("tstamp %x\n", lfsp->lfs_tstamp);
}
void
"uid ", dip->di_uid,
"gid ", dip->di_gid,
"size ", dip->di_size);
- (void)printf("inum %ld\n", dip->di_inumber);
+ (void)printf("inum %d\n", dip->di_inumber);
(void)printf("Direct Addresses\n");
for (i = 0; i < NDADDR; i++) {
- (void)printf("\t%lx", dip->di_db[i]);
+ (void)printf("\t%x", dip->di_db[i]);
if ((i % 6) == 5)
(void)printf("\n");
}
for (i = 0; i < NIADDR; i++)
- (void)printf("\t%lx", dip->di_ib[i]);
+ (void)printf("\t%x", dip->di_ib[i]);
(void)printf("\n");
}
#endif /* DEBUG */
-/* $OpenBSD: lfs_vfsops.c,v 1.2 1996/02/27 07:13:29 niklas Exp $ */
-/* $NetBSD: lfs_vfsops.c,v 1.10 1996/02/09 22:28:58 christos Exp $ */
+/* $OpenBSD: lfs_vfsops.c,v 1.3 1996/04/21 22:32:45 deraadt Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.11 1996/03/25 12:53:35 pk Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
{
register struct ufsmount *ump;
register struct lfs *fs;
- int i, error, flags, ronly;
+ int error, flags, ronly;
flags = 0;
if (mntflags & MNT_FORCE)
fs = ump->um_lfs;
#ifdef QUOTA
if (mp->mnt_flag & MNT_QUOTA) {
+ int i;
error = vflush(mp, fs->lfs_ivnode, SKIPSYSTEM|flags);
if (error)
return (error);
-/* $OpenBSD: mfs_vnops.c,v 1.3 1996/04/19 16:10:41 niklas Exp $ */
-/* $NetBSD: mfs_vnops.c,v 1.7 1996/02/21 00:06:45 cgd Exp $ */
+/* $OpenBSD: mfs_vnops.c,v 1.4 1996/04/21 22:32:49 deraadt Exp $ */
+/* $NetBSD: mfs_vnops.c,v 1.8 1996/03/17 02:16:32 christos Exp $ */
/*
* Copyright (c) 1989, 1993
register struct mfsnode *mfsp = VTOMFS(ap->a_vp);
if (mfsp->mfs_buflist && mfsp->mfs_buflist != (struct buf *)(-1))
- panic("mfs_inactive: not inactive (mfs_buflist %x)",
+ panic("mfs_inactive: not inactive (mfs_buflist %p)",
mfsp->mfs_buflist);
return (0);
}
} */ *ap = v;
register struct mfsnode *mfsp = VTOMFS(ap->a_vp);
- printf("tag VT_MFS, pid %d, base %p, size %d\n", mfsp->mfs_pid,
- mfsp->mfs_baseoff, mfsp->mfs_size);
+ printf("tag VT_MFS, pid %d, base %p, size %ld\n", mfsp->mfs_pid,
+ mfsp->mfs_baseoff, mfsp->mfs_size);
return (0);
}
-/* $NetBSD: device_pager.c,v 1.18 1994/10/29 07:35:04 cgd Exp $ */
+/* $NetBSD: device_pager.c,v 1.21 1996/03/16 23:15:18 christos Exp $ */
/*
* Copyright (c) 1990 University of Utah.
#ifdef DEBUG
if (dpagerdebug & DDB_FOLLOW)
- printf("dev_pager_alloc(%x, %x, %x, %x)\n",
+ printf("dev_pager_alloc(%p, %lx, %x, %lx)\n",
handle, size, prot, foff);
#endif
#ifdef DIAGNOSTIC
{
#ifdef DEBUG
if (dpagerdebug & DDB_FOLLOW)
- printf("dev_pager_haspage(%x, %x)\n", pager, offset);
+ printf("dev_pager_haspage(%p, %lx)\n", pager, offset);
#endif
return(TRUE);
}
-/* $NetBSD: pmap.h,v 1.10 1995/03/26 20:39:07 jtc Exp $ */
+/* $NetBSD: pmap.h,v 1.16 1996/03/31 22:15:32 pk Exp $ */
/*
* Copyright (c) 1991, 1993
#include <machine/pmap.h>
+#ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */
#ifdef _KERNEL
__BEGIN_DECLS
void *pmap_bootstrap_alloc __P((int));
void pmap_virtual_space __P(());
#endif
__END_DECLS
-#endif
+#endif /* kernel*/
+#endif /* PMAP_EXCLUDE_DECLS */
#endif /* _PMAP_VM_ */
-/* $NetBSD: swap_pager.c,v 1.24 1994/10/18 06:42:28 cgd Exp $ */
+/* $NetBSD: swap_pager.c,v 1.27 1996/03/16 23:15:20 christos Exp $ */
/*
* Copyright (c) 1990 University of Utah.
swap_pager_maxcluster = dbtob(bsize);
#ifdef DEBUG
if (swpagerdebug & SDB_INIT)
- printf("swpg_init: ix %d, size %x, bsize %x\n",
+ printf("swpg_init: ix %d, size %lx, bsize %x\n",
i, swtab[i].st_osize, swtab[i].st_bsize);
#endif
if (bsize >= maxbsize)
#ifdef DEBUG
if (swpagerdebug & (SDB_FOLLOW|SDB_ALLOC))
- printf("swpg_alloc(%x, %x, %x)\n", handle, size, prot);
+ printf("swpg_alloc(%p, %lx, %x)\n", handle, size, prot);
#endif
/*
* If this is a "named" anonymous region, look it up and
#ifdef DEBUG
if (swpagerdebug & (SDB_FOLLOW|SDB_ALLOCBLK))
- printf("swpg_haspage(%x, %x) ", pager, offset);
+ printf("swpg_haspage(%p, %x) ", pager, offset);
#endif
swp = (sw_pager_t) pager->pg_data;
ix = offset / dbtob(swp->sw_bsize);
if (swp->sw_blocks == NULL || ix >= swp->sw_nblocks) {
#ifdef DEBUG
if (swpagerdebug & (SDB_FAIL|SDB_FOLLOW|SDB_ALLOCBLK))
- printf("swpg_haspage: %x bad offset %x, ix %x\n",
+ printf("swpg_haspage: %p bad offset %lx, ix %x\n",
swp->sw_blocks, offset, ix);
#endif
return(FALSE);
#ifdef DEBUG
if (swpagerdebug & (SDB_FOLLOW|SDB_CLUSTER))
- printf("swpg_cluster(%x, %x) ", pager, offset);
+ printf("swpg_cluster(%p, %lx) ", pager, offset);
#endif
swp = (sw_pager_t) pager->pg_data;
bsize = dbtob(swp->sw_bsize);
*hoffset = hoff;
#ifdef DEBUG
if (swpagerdebug & (SDB_FOLLOW|SDB_CLUSTER))
- printf("returns [%x-%x]\n", loff, hoff);
+ printf("returns [%lx-%lx]\n", loff, hoff);
#endif
}
bp, swp, swp->sw_poip);
if ((swpagerdebug & SDB_ALLOCBLK) &&
(swb->swb_mask & mask) != mask)
- printf("swpg_io: %x write %d pages at %x+%x\n",
+ printf("swpg_io: %p write %d pages at %x+%lx\n",
swp->sw_blocks, npages, swb->swb_block,
atop(off));
if (swpagerdebug & SDB_CLUSTER)
- printf("swpg_io: off=%x, npg=%x, mask=%x, bmask=%x\n",
+ printf("swpg_io: off=%lx, npg=%x, mask=%x, bmask=%x\n",
off, npages, mask, swb->swb_mask);
#endif
swb->swb_mask |= mask;
*/
#ifdef DEBUG
if (swpagerdebug & SDB_IO)
- printf("swpg_io: IO start: bp %x, db %x, va %x, pa %x\n",
+ printf("swpg_io: IO start: bp %p, db %lx, va %lx, pa %lx\n",
bp, swb->swb_block+btodb(off), kva, VM_PAGE_TO_PHYS(m));
#endif
VOP_STRATEGY(bp);
* after awhile.
*/
if (spc->spc_flags & SPC_ERROR) {
- printf("%s: clean of page %x failed\n",
+ printf("%s: clean of page %lx failed\n",
"swap_pager_clean",
VM_PAGE_TO_PHYS(m));
m->flags |= PG_LAUNDRY;
-/* $OpenBSD: vm_glue.c,v 1.13 1996/04/19 16:10:47 niklas Exp $ */
-/* $NetBSD: vm_glue.c,v 1.53 1996/02/18 22:53:43 mycroft Exp $ */
+/* $OpenBSD: vm_glue.c,v 1.14 1996/04/21 22:33:11 deraadt Exp $ */
+/* $NetBSD: vm_glue.c,v 1.54 1996/03/30 21:50:45 christos Exp $ */
/*
* Copyright (c) 1991, 1993
while (--i >= 0)
(*pr)(" ");
va_start(ap, fmt);
- (*pr)("%r", fmt, ap);
+ (*pr)("%:", fmt, ap);
va_end(ap);
}
-/* $OpenBSD: vm_mmap.c,v 1.5 1996/04/19 16:10:48 niklas Exp $ */
-/* $NetBSD: vm_mmap.c,v 1.46 1996/02/28 22:39:13 gwr Exp $ */
+/* $OpenBSD: vm_mmap.c,v 1.6 1996/04/21 22:33:13 deraadt Exp $ */
+/* $NetBSD: vm_mmap.c,v 1.47 1996/03/16 23:15:23 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#ifdef DEBUG
if (mmapdebug & MDB_FOLLOW)
- printf("mmap(%d): addr %x len %x pro %x flg %x fd %d pos %x\n",
+ printf("mmap(%d): addr %lx len %lx pro %x flg %x fd %d pos %lx\n",
p->p_pid, addr, size, prot, flags, fd, pos);
#endif
size = (vm_size_t)SCARG(uap, len);
#ifdef DEBUG
if (mmapdebug & (MDB_FOLLOW|MDB_SYNC))
- printf("msync(%d): addr %x len %x\n",
+ printf("msync(%d): addr %lx len %lx\n",
p->p_pid, addr, size);
#endif
}
#ifdef DEBUG
if (mmapdebug & MDB_SYNC)
- printf("msync: cleaning/flushing address range [%x-%x)\n",
+ printf("msync: cleaning/flushing address range [%lx-%lx)\n",
addr, addr+size);
#endif
/*
size = (vm_size_t) SCARG(uap, len);
#ifdef DEBUG
if (mmapdebug & MDB_FOLLOW)
- printf("munmap(%d): addr %x len %x\n",
+ printf("munmap(%d): addr %lx len %lx\n",
p->p_pid, addr, size);
#endif
prot = SCARG(uap, prot) & VM_PROT_ALL;
#ifdef DEBUG
if (mmapdebug & MDB_FOLLOW)
- printf("mprotect(%d): addr %x len %x prot %d\n", p->p_pid,
+ printf("mprotect(%d): addr %lx len %lx prot %d\n", p->p_pid,
addr, size, prot);
#endif
/*
size = (vm_size_t)SCARG(uap, len);
#ifdef DEBUG
if (mmapdebug & MDB_FOLLOW)
- printf("mlock(%d): addr %x len %x\n",
+ printf("mlock(%d): addr %lx len %lx\n",
p->p_pid, addr, size);
#endif
/*
size = (vm_size_t)SCARG(uap, len);
#ifdef DEBUG
if (mmapdebug & MDB_FOLLOW)
- printf("munlock(%d): addr %x len %x\n",
+ printf("munlock(%d): addr %lx len %lx\n",
p->p_pid, addr, size);
#endif
/*
(void) pager_cache(object, FALSE);
#ifdef DEBUG
if (mmapdebug & MDB_MAPIT)
- printf("vm_mmap(%d): ANON *addr %x size %x pager %p\n",
+ printf("vm_mmap(%d): ANON *addr %lx size %lx pager %p\n",
curproc->p_pid, *addr, size, pager);
#endif
}
if (paddr != *addr)
printf(
"vm_mmap: pmap botch! "
- "[foff %x, addr %x, paddr %x]\n",
+ "[foff %lx, addr %lx, paddr %lx]\n",
foff, *addr, paddr);
}
#endif
}
#ifdef DEBUG
if (mmapdebug & MDB_MAPIT)
- printf("vm_mmap(%d): FILE *addr %x size %x pager %p\n",
+ printf("vm_mmap(%d): FILE *addr %lx size %lx pager %p\n",
curproc->p_pid, *addr, size, pager);
#endif
}
-/* $OpenBSD: vm_pager.c,v 1.2 1996/03/03 17:45:37 niklas Exp $ */
-/* $NetBSD: vm_pager.c,v 1.20 1996/02/10 00:08:13 christos Exp $ */
+/* $OpenBSD: vm_pager.c,v 1.3 1996/04/21 22:33:16 deraadt Exp $ */
+/* $NetBSD: vm_pager.c,v 1.21 1996/03/16 23:15:25 christos Exp $ */
/*
* Copyright (c) 1991, 1993
if (m->flags & PG_PAGEROWNED)
m->flags &= ~PG_PAGEROWNED;
else
- printf("vm_pager_unmap_pages: %p(%x/%x) not owned\n",
+ printf("vm_pager_unmap_pages: %p(%lx/%lx) not owned\n",
m, va, VM_PAGE_TO_PHYS(m));
}
#endif
-/* $OpenBSD: vnode_pager.c,v 1.2 1996/03/03 17:45:40 niklas Exp $ */
-/* $NetBSD: vnode_pager.c,v 1.18 1996/02/10 00:08:15 christos Exp $ */
+/* $OpenBSD: vnode_pager.c,v 1.3 1996/04/21 22:33:18 deraadt Exp $ */
+/* $NetBSD: vnode_pager.c,v 1.19 1996/03/16 23:15:27 christos Exp $ */
/*
* Copyright (c) 1990 University of Utah.
#ifdef DEBUG
if (vpagerdebug & (VDB_FOLLOW|VDB_ALLOC))
- printf("vnode_pager_alloc(%p, %x, %x)\n", handle, size, prot);
+ printf("vnode_pager_alloc(%p, %lx, %x)\n", handle, size, prot);
#endif
/*
* Pageout to vnode, no can do yet.
}
#ifdef DEBUG
if (vpagerdebug & VDB_ALLOC)
- printf("vnode_pager_setup: vp %p sz %x pager %p object %p\n",
+ printf("vnode_pager_setup: vp %p sz %lx pager %p object %p\n",
vp, vnp->vnp_size, pager, object);
#endif
return(pager);
#ifdef DEBUG
if (vpagerdebug & VDB_FOLLOW)
- printf("vnode_pager_haspage(%p, %x)\n", pager, offset);
+ printf("vnode_pager_haspage(%p, %lx)\n", pager, offset);
#endif
/*
VOP_UNLOCK(vnp->vnp_vp);
#ifdef DEBUG
if (vpagerdebug & (VDB_FAIL|VDB_SIZE))
- printf("vnode_pager_haspage: pg %p, off %x, size %x\n",
+ printf("vnode_pager_haspage: pg %p, off %lx, size %lx\n",
pager, offset, vnp->vnp_size);
#endif
return(FALSE);
if (err) {
#ifdef DEBUG
if (vpagerdebug & VDB_FAIL)
- printf("vnode_pager_haspage: BMAP err %d, pg %p, off %x\n",
+ printf("vnode_pager_haspage: BMAP err %d, pg %p, off %lx\n",
err, pager, offset);
#endif
return(TRUE);
#ifdef DEBUG
if (vpagerdebug & VDB_FOLLOW)
- printf("vnode_pager_cluster(%p, %x) ", pager, offset);
+ printf("vnode_pager_cluster(%p, %lx) ", pager, offset);
#endif
loff = offset;
if (loff >= vnp->vnp_size)
*hoffset = hoff;
#ifdef DEBUG
if (vpagerdebug & VDB_FOLLOW)
- printf("returns [%x-%x]\n", loff, hoff);
+ printf("returns [%lx-%lx]\n", loff, hoff);
#endif
}
#ifdef DEBUG
if (vpagerdebug & (VDB_FOLLOW|VDB_SIZE))
- printf("vnode_pager_setsize: vp %p obj %p osz %d nsz %d\n",
+ printf("vnode_pager_setsize: vp %p obj %p osz %ld nsz %ld\n",
vp, object, vnp->vnp_size, nsize);
#endif
/*
vm_pager_unmap_pages(kva, npages);
#ifdef DEBUG
if (vpagerdebug & VDB_SIZE)
- printf("vnode_pager_io: vp %p, off %d size %d\n",
+ printf("vnode_pager_io: vp %p, off %ld size %ld\n",
vnp->vnp_vp, foff, vnp->vnp_size);
#endif
return(VM_PAGER_BAD);
auio.uio_procp = (struct proc *)0;
#ifdef DEBUG
if (vpagerdebug & VDB_IO)
- printf("vnode_pager_io: vp %p kva %x foff %x size %x",
+ printf("vnode_pager_io: vp %p kva %lx foff %lx size %x",
vnp->vnp_vp, kva, foff, size);
#endif
if (rw == UIO_READ)