noone wrote an equivalent of SunOS format(8) and noone ever will.
-/* $OpenBSD: xd.c,v 1.64 2015/01/13 20:40:11 miod Exp $ */
+/* $OpenBSD: xd.c,v 1.65 2015/01/14 19:01:00 miod Exp $ */
/* $NetBSD: xd.c,v 1.37 1997/07/29 09:58:16 fair Exp $ */
/*
#include <sparc/dev/xdreg.h>
#include <sparc/dev/xdvar.h>
-#include <sparc/dev/xio.h>
#include <sparc/sparc/vaddrs.h>
#include <sparc/sparc/cpuvar.h>
char *xdc_e2str(int);
int xdc_error(struct xdc_softc *, struct xd_iorq *,
struct xd_iopb *, int, int);
-int xdc_ioctlcmd(struct xd_softc *, dev_t dev, struct xd_iocmd *);
void xdc_perror(struct xd_iorq *, struct xd_iopb *, int);
int xdc_piodriver(struct xdc_softc *, int, int);
int xdc_remove_iorq(struct xdc_softc *);
{
struct xd_softc *xd;
- struct xd_iocmd *xio;
int error, s, unit;
unit = DISKUNIT(dev);
}
return error;
- case DIOSXDCMD:
- xio = (struct xd_iocmd *) addr;
- if ((error = suser(p, 0)) != 0)
- return (error);
- return (xdc_ioctlcmd(xd, dev, xio));
-
default:
return ENOTTY;
}
timeout_add(&xdcsc->xdc_tick_tmo, XDC_TICKCNT);
}
-/*
- * xdc_ioctlcmd: this function provides a user level interface to the
- * controller via ioctl. this allows "format" programs to be written
- * in user code, and is also useful for some debugging. we return
- * an error code. called at user priority.
- */
-int
-xdc_ioctlcmd(xd, dev, xio)
- struct xd_softc *xd;
- dev_t dev;
- struct xd_iocmd *xio;
-
-{
- int s, err, rqno, dummy;
- caddr_t dvmabuf = NULL, buf = NULL;
- struct xdc_softc *xdcsc;
-
- /* check sanity of requested command */
-
- switch (xio->cmd) {
-
- case XDCMD_NOP: /* no op: everything should be zero */
- if (xio->subfn || xio->dptr || xio->dlen ||
- xio->block || xio->sectcnt)
- return (EINVAL);
- break;
-
- case XDCMD_RD: /* read / write sectors (up to XD_IOCMD_MAXS) */
- case XDCMD_WR:
- if (xio->subfn || xio->sectcnt > XD_IOCMD_MAXS ||
- xio->sectcnt * XDFM_BPS != xio->dlen || xio->dptr == NULL)
- return (EINVAL);
- break;
-
- case XDCMD_SK: /* seek: doesn't seem useful to export this */
- return (EINVAL);
-
- case XDCMD_WRP: /* write parameters */
- return (EINVAL);/* not useful, except maybe drive
- * parameters... but drive parameters should
- * go via disklabel changes */
-
- case XDCMD_RDP: /* read parameters */
- if (xio->subfn != XDFUN_DRV ||
- xio->dlen || xio->block || xio->dptr)
- return (EINVAL); /* allow read drive params to
- * get hw_spt */
- xio->sectcnt = xd->hw_spt; /* we already know the answer */
- return (0);
- break;
-
- case XDCMD_XRD: /* extended read/write */
- case XDCMD_XWR:
-
- switch (xio->subfn) {
-
- case XDFUN_THD:/* track headers */
- if (xio->sectcnt != xd->hw_spt ||
- (xio->block % xd->nsect) != 0 ||
- xio->dlen != XD_IOCMD_HSZ * xd->hw_spt ||
- xio->dptr == NULL)
- return (EINVAL);
- xio->sectcnt = 0;
- break;
-
- case XDFUN_FMT:/* NOTE: also XDFUN_VFY */
- if (xio->cmd == XDCMD_XRD)
- return (EINVAL); /* no XDFUN_VFY */
- if (xio->sectcnt || xio->dlen ||
- (xio->block % xd->nsect) != 0 || xio->dptr)
- return (EINVAL);
- break;
-
- case XDFUN_HDR:/* header, header verify, data, data ECC */
- return (EINVAL); /* not yet */
-
- case XDFUN_DM: /* defect map */
- case XDFUN_DMX:/* defect map (alternate location) */
- if (xio->sectcnt || xio->dlen != XD_IOCMD_DMSZ ||
- (xio->block % xd->nsect) != 0 || xio->dptr == NULL)
- return (EINVAL);
- break;
-
- default:
- return (EINVAL);
- }
- break;
-
- case XDCMD_TST: /* diagnostics */
- return (EINVAL);
-
- default:
- return (EINVAL);/* ??? */
- }
-
- /* create DVMA buffer for request if needed */
-
- if (xio->dlen) {
- dvmabuf = dvma_malloc(xio->dlen, &buf, M_WAITOK);
- if (xio->cmd == XDCMD_WR || xio->cmd == XDCMD_XWR) {
- if ((err = copyin(xio->dptr, buf, xio->dlen)) != 0) {
- dvma_free(dvmabuf, xio->dlen, &buf);
- return (err);
- }
- }
- }
- /* do it! */
-
- err = 0;
- xdcsc = xd->parent;
- s = splbio();
- rqno = xdc_cmd(xdcsc, xio->cmd, xio->subfn, xd->xd_drive, xio->block,
- xio->sectcnt, dvmabuf, XD_SUB_WAIT);
- if (rqno == XD_ERR_FAIL) {
- err = EIO;
- goto done;
- }
- xio->errno = xdcsc->reqs[rqno].errno;
- xio->tries = xdcsc->reqs[rqno].tries;
- XDC_DONE(xdcsc, rqno, dummy);
-
- if (xio->cmd == XDCMD_RD || xio->cmd == XDCMD_XRD)
- err = copyout(buf, xio->dptr, xio->dlen);
-
-done:
- splx(s);
- if (dvmabuf)
- dvma_free(dvmabuf, xio->dlen, &buf);
- return (err);
-}
-
/*
* xdc_e2str: convert error code number into an error string
*/
+++ /dev/null
-/* $OpenBSD: xio.h,v 1.4 2014/07/11 16:35:40 jsg Exp $ */
-/* $NetBSD: xio.h,v 1.2 1996/03/31 22:38:58 pk Exp $ */
-
-/*
- * Copyright (c) 1995 Charles D. Cranor
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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.
- */
-
-/*
- * x i o . h
- *
- * this file defines the software structure we use to ioctl the
- * 753/7053. this interface isn't set in stone and may (or may not)
- * need adjustment.
- *
- * author: Chuck Cranor <chuck@ccrc.wustl.edu>
- */
-
-/*
- * xylogic ioctl interface
- */
-
-struct xd_iocmd {
- u_char cmd; /* in: command number */
- u_char subfn; /* in: subfunction number */
- u_char errno; /* out: error number */
- u_char tries; /* out: number of tries */
- u_short sectcnt; /* in,out: sector count (hw_spt on read drive param) */
- u_short dlen; /* in: length of data buffer (good sanity check) */
- u_long block; /* in: block number */
- caddr_t dptr; /* in: data buffer to do I/O from */
-};
-
-#ifndef DIOSXDCMD
-#define DIOSXDCMD _IOWR('x', 101, struct xd_iocmd) /* do xd command */
-#endif
-
-#define XD_IOCMD_MAXS 16 /* max number of sectors you can do */
-#define XD_IOCMD_HSZ 4 /* size of one header */
-#define XD_IOCMD_DMSZ 24 /* defect map size */
-/* $OpenBSD: xy.c,v 1.61 2015/01/13 20:40:11 miod Exp $ */
+/* $OpenBSD: xy.c,v 1.62 2015/01/14 19:01:00 miod Exp $ */
/* $NetBSD: xy.c,v 1.26 1997/07/19 21:43:56 pk Exp $ */
/*
#include <sparc/dev/xyreg.h>
#include <sparc/dev/xyvar.h>
-#include <sparc/dev/xio.h>
#include <sparc/sparc/vaddrs.h>
/*
int xyc_entoact(int);
int xyc_error(struct xyc_softc *, struct xy_iorq *,
struct xy_iopb *, int);
-int xyc_ioctlcmd(struct xy_softc *, dev_t dev, struct xd_iocmd *);
void xyc_perror(struct xy_iorq *, struct xy_iopb *, int);
int xyc_piodriver(struct xyc_softc *, struct xy_iorq *);
int xyc_remove_iorq(struct xyc_softc *);
{
struct xy_softc *xy;
- struct xd_iocmd *xio;
int error, s, unit;
unit = DISKUNIT(dev);
}
return error;
- case DIOSXDCMD:
- xio = (struct xd_iocmd *) addr;
- if ((error = suser(p, 0)) != 0)
- return (error);
- return (xyc_ioctlcmd(xy, dev, xio));
-
default:
return ENOTTY;
}
timeout_add(&xycsc->xyc_tick_tmo, XYC_TICKCNT);
}
-/*
- * xyc_ioctlcmd: this function provides a user level interface to the
- * controller via ioctl. this allows "format" programs to be written
- * in user code, and is also useful for some debugging. we return
- * an error code. called at user priority.
- *
- * XXX missing a few commands (see the 7053 driver for ideas)
- */
-int
-xyc_ioctlcmd(xy, dev, xio)
- struct xy_softc *xy;
- dev_t dev;
- struct xd_iocmd *xio;
-
-{
- int s, err, rqno, dummy = 0;
- caddr_t dvmabuf = NULL, buf = NULL;
- struct xyc_softc *xycsc;
-
- /* check sanity of requested command */
-
- switch (xio->cmd) {
-
- case XYCMD_NOP: /* no op: everything should be zero */
- if (xio->subfn || xio->dptr || xio->dlen ||
- xio->block || xio->sectcnt)
- return (EINVAL);
- break;
-
- case XYCMD_RD: /* read / write sectors (up to XD_IOCMD_MAXS) */
- case XYCMD_WR:
- if (xio->subfn || xio->sectcnt > XD_IOCMD_MAXS ||
- xio->sectcnt * XYFM_BPS != xio->dlen || xio->dptr == NULL)
- return (EINVAL);
- break;
-
- case XYCMD_SK: /* seek: doesn't seem useful to export this */
- return (EINVAL);
-
- break;
-
- default:
- return (EINVAL);/* ??? */
- }
-
- /* create DVMA buffer for request if needed */
-
- if (xio->dlen) {
- dvmabuf = dvma_malloc(xio->dlen, &buf, M_WAITOK);
- if (xio->cmd == XYCMD_WR) {
- if ((err = copyin(xio->dptr, buf, xio->dlen)) != 0) {
- dvma_free(dvmabuf, xio->dlen, &buf);
- return (err);
- }
- }
- }
- /* do it! */
-
- err = 0;
- xycsc = xy->parent;
- s = splbio();
- rqno = xyc_cmd(xycsc, xio->cmd, xio->subfn, xy->xy_drive, xio->block,
- xio->sectcnt, dvmabuf, XY_SUB_WAIT);
- if (rqno == XY_ERR_FAIL) {
- err = EIO;
- goto done;
- }
- xio->errno = xycsc->ciorq->errno;
- xio->tries = xycsc->ciorq->tries;
- XYC_DONE(xycsc, dummy);
-
- if (xio->cmd == XYCMD_RD)
- err = copyout(buf, xio->dptr, xio->dlen);
-
-done:
- splx(s);
- if (dvmabuf)
- dvma_free(dvmabuf, xio->dlen, &buf);
- return (err);
-}
-
/*
* xyc_e2str: convert error code number into an error string
*/