Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
/* $NetBSD: ed_mca.c,v 1.10 2001/11/23 22:53:10 jdolecek Exp $ */
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jaromir Dolecek.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
* Disk drive goo for MCA ESDI controller driver.
|
2001-04-19 11:30:24 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 10:38:28 +03:00
|
|
|
#include <sys/cdefs.h>
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.10 2001/11/23 22:53:10 jdolecek Exp $");
|
2001-11-13 10:38:28 +03:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
#include "rnd.h"
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
#include "locators.h"
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/disk.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#if NRND > 0
|
|
|
|
#include <sys/rnd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
2001-04-22 15:52:18 +04:00
|
|
|
#include <dev/mca/mcavar.h>
|
|
|
|
|
2001-04-19 21:17:28 +04:00
|
|
|
#include <dev/mca/edcreg.h>
|
2001-04-19 11:30:24 +04:00
|
|
|
#include <dev/mca/edvar.h>
|
2001-04-19 21:17:28 +04:00
|
|
|
#include <dev/mca/edcvar.h>
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/* #define WDCDEBUG */
|
|
|
|
|
|
|
|
#ifdef WDCDEBUG
|
|
|
|
#define WDCDEBUG_PRINT(args, level) printf args
|
|
|
|
#else
|
|
|
|
#define WDCDEBUG_PRINT(args, level)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define EDLABELDEV(dev) (MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART))
|
|
|
|
|
|
|
|
/* XXX: these should go elsewhere */
|
|
|
|
cdev_decl(edmca);
|
|
|
|
bdev_decl(edmca);
|
|
|
|
|
|
|
|
static int ed_mca_probe __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void ed_mca_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach ed_mca_ca = {
|
|
|
|
sizeof(struct ed_softc), ed_mca_probe, ed_mca_attach
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct cfdriver ed_cd;
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
static int ed_get_params __P((struct ed_softc *, int *));
|
2001-04-19 11:30:24 +04:00
|
|
|
static int ed_lock __P((struct ed_softc *));
|
|
|
|
static void ed_unlock __P((struct ed_softc *));
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
static void edgetdisklabel __P((dev_t, struct ed_softc *));
|
2001-04-19 11:30:24 +04:00
|
|
|
static void edgetdefaultlabel __P((struct ed_softc *, struct disklabel *));
|
|
|
|
|
|
|
|
static struct dkdriver eddkdriver = { edmcastrategy };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just check if it's possible to identify the disk.
|
|
|
|
*/
|
|
|
|
static int
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed_mca_probe(parent, cf, aux)
|
2001-04-19 11:30:24 +04:00
|
|
|
struct device *parent;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
struct cfdata *cf;
|
2001-04-19 11:30:24 +04:00
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
u_int16_t cmd_args[2];
|
2001-04-19 21:17:28 +04:00
|
|
|
struct edc_mca_softc *sc = (void *) parent;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
struct ed_attach_args *eda = (struct ed_attach_args *) aux;
|
2001-05-04 16:58:34 +04:00
|
|
|
int found = 1;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
/*
|
|
|
|
* Check we match hardwired config.
|
|
|
|
*/
|
|
|
|
if (cf->edccf_unit != EDCCF_DRIVE_DEFAULT &&
|
|
|
|
cf->edccf_unit != eda->edc_drive)
|
|
|
|
return (0);
|
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
/*
|
|
|
|
* Get Device Configuration (09).
|
|
|
|
*/
|
2001-05-04 16:58:34 +04:00
|
|
|
cmd_args[0] = 14; /* Options: 00s110, s: 0=Physical 1=Pseudo */
|
2001-04-19 11:30:24 +04:00
|
|
|
cmd_args[1] = 0;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
if (edc_run_cmd(sc, CMD_GET_DEV_CONF, eda->edc_drive, cmd_args, 2, 1))
|
2001-05-04 16:58:34 +04:00
|
|
|
found = 0;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
2001-05-04 16:58:34 +04:00
|
|
|
return (found);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ed_mca_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct ed_softc *ed = (void *) self;
|
2001-04-19 21:17:28 +04:00
|
|
|
struct edc_mca_softc *sc = (void *) parent;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
struct ed_attach_args *eda = (struct ed_attach_args *) aux;
|
|
|
|
char pbuf[8], lckname[10];
|
|
|
|
int drv_flags;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
2001-04-19 21:17:28 +04:00
|
|
|
ed->edc_softc = sc;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_devno = eda->edc_drive;
|
|
|
|
edc_add_disk(sc, ed);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
BUFQ_INIT(&ed->sc_q);
|
2001-09-03 22:13:13 +04:00
|
|
|
simple_lock_init(&ed->sc_q_lock);
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
snprintf(lckname, sizeof(lckname), "%slck", ed->sc_dev.dv_xname);
|
|
|
|
lockinit(&ed->sc_lock, PRIBIO | PCATCH, lckname, 0, 0);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
if (ed_get_params(ed, &drv_flags)) {
|
2001-04-19 11:30:24 +04:00
|
|
|
printf(": IDENTIFY failed, no disk found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
format_bytes(pbuf, sizeof(pbuf),
|
|
|
|
(u_int64_t) ed->sc_capacity * DEV_BSIZE);
|
|
|
|
printf(": %s, %u cyl, %u head, %u sec, 512 bytes/sect x %u sectors\n",
|
|
|
|
pbuf,
|
|
|
|
ed->cyl, ed->heads, ed->sectors,
|
|
|
|
ed->sc_capacity);
|
|
|
|
|
2001-05-04 16:58:34 +04:00
|
|
|
printf("%s: %u spares/cyl, %s, %s, %s, %s, %s\n",
|
2001-04-19 11:30:24 +04:00
|
|
|
ed->sc_dev.dv_xname, ed->spares,
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
(drv_flags & (1 << 0)) ? "NoRetries" : "Retries",
|
|
|
|
(drv_flags & (1 << 1)) ? "Removable" : "Fixed",
|
|
|
|
(drv_flags & (1 << 2)) ? "SkewedFormat" : "NoSkew",
|
|
|
|
(drv_flags & (1 << 3)) ? "ZeroDefect" : "Defects",
|
|
|
|
(drv_flags & (1 << 4)) ? "InvalidSecondary" : "SecondaryOK"
|
2001-04-19 11:30:24 +04:00
|
|
|
);
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
/*
|
|
|
|
* Initialize and attach the disk structure.
|
|
|
|
*/
|
|
|
|
ed->sc_dk.dk_driver = &eddkdriver;
|
|
|
|
ed->sc_dk.dk_name = ed->sc_dev.dv_xname;
|
|
|
|
disk_attach(&ed->sc_dk);
|
|
|
|
#if NRND > 0
|
|
|
|
rnd_attach_source(&ed->rnd_source, ed->sc_dev.dv_xname,
|
|
|
|
RND_TYPE_DISK, 0);
|
|
|
|
#endif
|
|
|
|
|
2001-05-04 16:58:34 +04:00
|
|
|
ed->sc_flags |= EDF_INIT;
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read/write routine for a buffer. Validates the arguments and schedules the
|
|
|
|
* transfer. Does not wait for the transfer to complete.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
edmcastrategy(bp)
|
|
|
|
struct buf *bp;
|
|
|
|
{
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
struct ed_softc *ed = device_lookup(&ed_cd, DISKUNIT(bp->b_dev));
|
|
|
|
struct disklabel *lp = ed->sc_dk.dk_label;
|
2001-04-19 11:30:24 +04:00
|
|
|
daddr_t blkno;
|
|
|
|
int s;
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
WDCDEBUG_PRINT(("edmcastrategy (%s)\n", ed->sc_dev.dv_xname),
|
2001-04-19 11:30:24 +04:00
|
|
|
DEBUG_XFERS);
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
/* Valid request? */
|
|
|
|
if (bp->b_blkno < 0 ||
|
|
|
|
(bp->b_bcount % lp->d_secsize) != 0 ||
|
|
|
|
(bp->b_bcount / lp->d_secsize) >= (1 << NBBY)) {
|
|
|
|
bp->b_error = EINVAL;
|
|
|
|
goto bad;
|
|
|
|
}
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
/* If device invalidated (e.g. media change, door open), error. */
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
if ((ed->sc_flags & WDF_LOADED) == 0) {
|
2001-04-19 11:30:24 +04:00
|
|
|
bp->b_error = EIO;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If it's a null transfer, return immediately. */
|
|
|
|
if (bp->b_bcount == 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do bounds checking, adjust transfer. if error, process.
|
|
|
|
* If end of partition, just return.
|
|
|
|
*/
|
|
|
|
if (DISKPART(bp->b_dev) != RAW_PART &&
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
bounds_check_with_label(bp, ed->sc_dk.dk_label,
|
|
|
|
(ed->sc_flags & (WDF_WLABEL|WDF_LABELLING)) != 0) <= 0)
|
2001-04-19 11:30:24 +04:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now convert the block number to absolute and put it in
|
|
|
|
* terms of the device's logical block size.
|
|
|
|
*/
|
|
|
|
if (lp->d_secsize >= DEV_BSIZE)
|
|
|
|
blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
|
|
|
|
else
|
|
|
|
blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
|
|
|
|
|
|
|
|
if (DISKPART(bp->b_dev) != RAW_PART)
|
|
|
|
blkno += lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
|
|
|
|
|
|
|
|
bp->b_rawblkno = blkno;
|
|
|
|
|
|
|
|
/* Queue transfer on drive, activate drive and controller if idle. */
|
|
|
|
s = splbio();
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
simple_lock(&ed->sc_q_lock);
|
|
|
|
disksort_blkno(&ed->sc_q, bp);
|
|
|
|
simple_unlock(&ed->sc_q_lock);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/* Ring the worker thread */
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
wakeup_one(ed->edc_softc);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
bad:
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
done:
|
|
|
|
/* Toss transfer; we're done early. */
|
|
|
|
bp->b_resid = bp->b_bcount;
|
|
|
|
biodone(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edmcaread(dev, uio, flags)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
WDCDEBUG_PRINT(("edread\n"), DEBUG_XFERS);
|
|
|
|
return (physio(edmcastrategy, NULL, dev, B_READ, minphys, uio));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edmcawrite(dev, uio, flags)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
WDCDEBUG_PRINT(("edwrite\n"), DEBUG_XFERS);
|
|
|
|
return (physio(edmcastrategy, NULL, dev, B_WRITE, minphys, uio));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait interruptibly for an exclusive lock.
|
|
|
|
*/
|
|
|
|
static int
|
2001-04-22 15:32:49 +04:00
|
|
|
ed_lock(ed)
|
|
|
|
struct ed_softc *ed;
|
2001-04-19 11:30:24 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
WDCDEBUG_PRINT(("ed_lock\n"), DEBUG_FUNCS);
|
|
|
|
|
|
|
|
s = splbio();
|
2001-04-22 15:32:49 +04:00
|
|
|
error = lockmgr(&ed->sc_lock, LK_EXCLUSIVE, NULL);
|
2001-04-19 11:30:24 +04:00
|
|
|
splx(s);
|
2001-04-22 15:32:49 +04:00
|
|
|
|
|
|
|
return (error);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unlock and wake up any waiters.
|
|
|
|
*/
|
|
|
|
static void
|
2001-04-22 15:32:49 +04:00
|
|
|
ed_unlock(ed)
|
|
|
|
struct ed_softc *ed;
|
2001-04-19 11:30:24 +04:00
|
|
|
{
|
|
|
|
WDCDEBUG_PRINT(("ed_unlock\n"), DEBUG_FUNCS);
|
|
|
|
|
2001-04-22 15:32:49 +04:00
|
|
|
(void) lockmgr(&ed->sc_lock, LK_RELEASE, NULL);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edmcaopen(dev, flag, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, fmt;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct ed_softc *wd;
|
|
|
|
int part, error;
|
|
|
|
|
|
|
|
WDCDEBUG_PRINT(("edopen\n"), DEBUG_FUNCS);
|
|
|
|
wd = device_lookup(&ed_cd, DISKUNIT(dev));
|
2001-05-04 16:58:34 +04:00
|
|
|
if (wd == NULL || (wd->sc_flags & EDF_INIT) == 0)
|
2001-04-19 11:30:24 +04:00
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if ((error = ed_lock(wd)) != 0)
|
|
|
|
goto bad4;
|
|
|
|
|
|
|
|
if (wd->sc_dk.dk_openmask != 0) {
|
|
|
|
/*
|
|
|
|
* If any partition is open, but the disk has been invalidated,
|
|
|
|
* disallow further opens.
|
|
|
|
*/
|
|
|
|
if ((wd->sc_flags & WDF_LOADED) == 0) {
|
|
|
|
error = EIO;
|
|
|
|
goto bad3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((wd->sc_flags & WDF_LOADED) == 0) {
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
int s;
|
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
wd->sc_flags |= WDF_LOADED;
|
|
|
|
|
|
|
|
/* Load the physical device parameters. */
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
s = splbio();
|
|
|
|
ed_get_params(wd, NULL);
|
|
|
|
splx(s);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/* Load the partition info if not already loaded. */
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
edgetdisklabel(dev, wd);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
part = DISKPART(dev);
|
|
|
|
|
|
|
|
/* Check that the partition exists. */
|
|
|
|
if (part != RAW_PART &&
|
|
|
|
(part >= wd->sc_dk.dk_label->d_npartitions ||
|
|
|
|
wd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
|
|
|
|
error = ENXIO;
|
|
|
|
goto bad;
|
|
|
|
}
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
/* Insure only one open at a time. */
|
|
|
|
switch (fmt) {
|
|
|
|
case S_IFCHR:
|
|
|
|
wd->sc_dk.dk_copenmask |= (1 << part);
|
|
|
|
break;
|
|
|
|
case S_IFBLK:
|
|
|
|
wd->sc_dk.dk_bopenmask |= (1 << part);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wd->sc_dk.dk_openmask =
|
|
|
|
wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
|
|
|
|
|
|
|
|
ed_unlock(wd);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
if (wd->sc_dk.dk_openmask == 0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bad3:
|
|
|
|
ed_unlock(wd);
|
|
|
|
bad4:
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edmcaclose(dev, flag, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, fmt;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct ed_softc *wd = device_lookup(&ed_cd, DISKUNIT(dev));
|
|
|
|
int part = DISKPART(dev);
|
|
|
|
int error;
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
WDCDEBUG_PRINT(("edmcaclose\n"), DEBUG_FUNCS);
|
|
|
|
if ((error = ed_lock(wd)) != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
switch (fmt) {
|
|
|
|
case S_IFCHR:
|
|
|
|
wd->sc_dk.dk_copenmask &= ~(1 << part);
|
|
|
|
break;
|
|
|
|
case S_IFBLK:
|
|
|
|
wd->sc_dk.dk_bopenmask &= ~(1 << part);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wd->sc_dk.dk_openmask =
|
|
|
|
wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
|
|
|
|
|
|
|
|
if (wd->sc_dk.dk_openmask == 0) {
|
|
|
|
#if 0
|
|
|
|
wd_flushcache(wd, AT_WAIT);
|
|
|
|
#endif
|
|
|
|
/* XXXX Must wait for I/O to complete! */
|
|
|
|
|
|
|
|
if (! (wd->sc_flags & WDF_KLABEL))
|
|
|
|
wd->sc_flags &= ~WDF_LOADED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ed_unlock(wd);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
edgetdefaultlabel(ed, lp)
|
|
|
|
struct ed_softc *ed;
|
2001-04-19 11:30:24 +04:00
|
|
|
struct disklabel *lp;
|
|
|
|
{
|
|
|
|
WDCDEBUG_PRINT(("edgetdefaultlabel\n"), DEBUG_FUNCS);
|
|
|
|
memset(lp, 0, sizeof(struct disklabel));
|
|
|
|
|
|
|
|
lp->d_secsize = DEV_BSIZE;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
lp->d_ntracks = ed->heads;
|
|
|
|
lp->d_nsectors = ed->sectors;
|
|
|
|
lp->d_ncylinders = ed->cyl;
|
2001-04-19 11:30:24 +04:00
|
|
|
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
|
|
|
|
|
|
|
|
lp->d_type = DTYPE_ESDI;
|
|
|
|
|
|
|
|
strncpy(lp->d_typename, "ESDI", 16);
|
|
|
|
strncpy(lp->d_packname, "fictitious", 16);
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
lp->d_secperunit = ed->sc_capacity;
|
2001-04-19 11:30:24 +04:00
|
|
|
lp->d_rpm = 3600;
|
|
|
|
lp->d_interleave = 1;
|
|
|
|
lp->d_flags = 0;
|
|
|
|
|
|
|
|
lp->d_partitions[RAW_PART].p_offset = 0;
|
|
|
|
lp->d_partitions[RAW_PART].p_size =
|
|
|
|
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
|
|
|
|
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
|
|
|
|
lp->d_npartitions = RAW_PART + 1;
|
|
|
|
|
|
|
|
lp->d_magic = DISKMAGIC;
|
|
|
|
lp->d_magic2 = DISKMAGIC;
|
|
|
|
lp->d_checksum = dkcksum(lp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fabricate a default disk label, and try to read the correct one.
|
|
|
|
*/
|
|
|
|
static void
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
edgetdisklabel(dev, ed)
|
|
|
|
dev_t dev;
|
|
|
|
struct ed_softc *ed;
|
2001-04-19 11:30:24 +04:00
|
|
|
{
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
struct disklabel *lp = ed->sc_dk.dk_label;
|
2001-04-19 11:30:24 +04:00
|
|
|
char *errstring;
|
|
|
|
|
|
|
|
WDCDEBUG_PRINT(("edgetdisklabel\n"), DEBUG_FUNCS);
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
memset(ed->sc_dk.dk_cpulabel, 0, sizeof(struct cpu_disklabel));
|
2001-04-19 11:30:24 +04:00
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
edgetdefaultlabel(ed, lp);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
errstring = readdisklabel(
|
|
|
|
EDLABELDEV(dev), edmcastrategy, lp, ed->sc_dk.dk_cpulabel);
|
2001-04-19 11:30:24 +04:00
|
|
|
if (errstring) {
|
|
|
|
/*
|
|
|
|
* This probably happened because the drive's default
|
|
|
|
* geometry doesn't match the DOS geometry. We
|
|
|
|
* assume the DOS geometry is now in the label and try
|
|
|
|
* again. XXX This is a kluge.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
if (wd->drvp->state > RECAL)
|
|
|
|
wd->drvp->drive_flags |= DRIVE_RESET;
|
|
|
|
#endif
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
errstring = readdisklabel(EDLABELDEV(dev),
|
|
|
|
edmcastrategy, lp, ed->sc_dk.dk_cpulabel);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
if (errstring) {
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
printf("%s: %s\n", ed->sc_dev.dv_xname, errstring);
|
2001-04-19 11:30:24 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edmcaioctl(dev, xfer, addr, flag, p)
|
|
|
|
dev_t dev;
|
|
|
|
u_long xfer;
|
|
|
|
caddr_t addr;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
struct ed_softc *ed = device_lookup(&ed_cd, DISKUNIT(dev));
|
2001-04-19 11:30:24 +04:00
|
|
|
int error;
|
|
|
|
|
2001-04-22 15:32:49 +04:00
|
|
|
WDCDEBUG_PRINT(("edioctl\n"), DEBUG_FUNCS);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
if ((ed->sc_flags & WDF_LOADED) == 0)
|
2001-04-19 11:30:24 +04:00
|
|
|
return EIO;
|
|
|
|
|
|
|
|
switch (xfer) {
|
|
|
|
case DIOCGDINFO:
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
*(struct disklabel *)addr = *(ed->sc_dk.dk_label);
|
2001-04-19 11:30:24 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case DIOCGPART:
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
((struct partinfo *)addr)->disklab = ed->sc_dk.dk_label;
|
2001-04-19 11:30:24 +04:00
|
|
|
((struct partinfo *)addr)->part =
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
&ed->sc_dk.dk_label->d_partitions[DISKPART(dev)];
|
2001-04-19 11:30:24 +04:00
|
|
|
return 0;
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
case DIOCWDINFO:
|
|
|
|
case DIOCSDINFO:
|
|
|
|
{
|
|
|
|
struct disklabel *lp;
|
|
|
|
|
|
|
|
lp = (struct disklabel *)addr;
|
|
|
|
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return EBADF;
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
if ((error = ed_lock(ed)) != 0)
|
2001-04-19 11:30:24 +04:00
|
|
|
return error;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_flags |= WDF_LABELLING;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
error = setdisklabel(ed->sc_dk.dk_label,
|
2001-04-19 11:30:24 +04:00
|
|
|
lp, /*wd->sc_dk.dk_openmask : */0,
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_dk.dk_cpulabel);
|
2001-04-19 11:30:24 +04:00
|
|
|
if (error == 0) {
|
|
|
|
#if 0
|
|
|
|
if (wd->drvp->state > RECAL)
|
|
|
|
wd->drvp->drive_flags |= DRIVE_RESET;
|
|
|
|
#endif
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
if (xfer == DIOCWDINFO)
|
2001-04-19 11:30:24 +04:00
|
|
|
error = writedisklabel(EDLABELDEV(dev),
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
edmcastrategy, ed->sc_dk.dk_label,
|
|
|
|
ed->sc_dk.dk_cpulabel);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_flags &= ~WDF_LABELLING;
|
|
|
|
ed_unlock(ed);
|
|
|
|
return (error);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case DIOCKLABEL:
|
|
|
|
if (*(int *)addr)
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_flags |= WDF_KLABEL;
|
2001-04-19 11:30:24 +04:00
|
|
|
else
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_flags &= ~WDF_KLABEL;
|
2001-04-19 11:30:24 +04:00
|
|
|
return 0;
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
case DIOCWLABEL:
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return EBADF;
|
|
|
|
if (*(int *)addr)
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_flags |= WDF_WLABEL;
|
2001-04-19 11:30:24 +04:00
|
|
|
else
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->sc_flags &= ~WDF_WLABEL;
|
2001-04-19 11:30:24 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case DIOCGDEFLABEL:
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
edgetdefaultlabel(ed, (struct disklabel *)addr);
|
2001-04-19 11:30:24 +04:00
|
|
|
return 0;
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
#if 0
|
2001-04-19 11:30:24 +04:00
|
|
|
case DIOCWFORMAT:
|
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return EBADF;
|
|
|
|
{
|
|
|
|
register struct format_op *fop;
|
|
|
|
struct iovec aiov;
|
|
|
|
struct uio auio;
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
fop = (struct format_op *)addr;
|
|
|
|
aiov.iov_base = fop->df_buf;
|
|
|
|
aiov.iov_len = fop->df_count;
|
|
|
|
auio.uio_iov = &aiov;
|
|
|
|
auio.uio_iovcnt = 1;
|
|
|
|
auio.uio_resid = fop->df_count;
|
|
|
|
auio.uio_segflg = 0;
|
|
|
|
auio.uio_offset =
|
|
|
|
fop->df_startblk * wd->sc_dk.dk_label->d_secsize;
|
|
|
|
auio.uio_procp = p;
|
|
|
|
error = physio(wdformat, NULL, dev, B_WRITE, minphys,
|
|
|
|
&auio);
|
|
|
|
fop->df_count -= auio.uio_resid;
|
|
|
|
fop->df_reg[0] = wdc->sc_status;
|
|
|
|
fop->df_reg[1] = wdc->sc_error;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
2001-04-22 15:32:49 +04:00
|
|
|
panic("edioctl: impossible");
|
2001-04-19 11:30:24 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edmcasize(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
|
|
|
struct ed_softc *wd;
|
|
|
|
int part, omask;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
WDCDEBUG_PRINT(("edsize\n"), DEBUG_FUNCS);
|
|
|
|
|
|
|
|
wd = device_lookup(&ed_cd, DISKUNIT(dev));
|
|
|
|
if (wd == NULL)
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
part = DISKPART(dev);
|
|
|
|
omask = wd->sc_dk.dk_openmask & (1 << part);
|
|
|
|
|
|
|
|
if (omask == 0 && edmcaopen(dev, 0, S_IFBLK, NULL) != 0)
|
|
|
|
return (-1);
|
|
|
|
if (wd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
|
|
|
|
size = -1;
|
|
|
|
else
|
|
|
|
size = wd->sc_dk.dk_label->d_partitions[part].p_size *
|
|
|
|
(wd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
|
|
|
|
if (omask == 0 && edmcaclose(dev, 0, S_IFBLK, NULL) != 0)
|
|
|
|
return (-1);
|
|
|
|
return (size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* #define WD_DUMP_NOT_TRUSTED if you just want to watch */
|
2001-05-04 16:58:34 +04:00
|
|
|
static int eddoingadump = 0;
|
|
|
|
static int eddumprecalibrated = 0;
|
|
|
|
static int eddumpmulti = 1;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump core after a system crash.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
edmcadump(dev, blkno, va, size)
|
|
|
|
dev_t dev;
|
|
|
|
daddr_t blkno;
|
|
|
|
caddr_t va;
|
|
|
|
size_t size;
|
|
|
|
{
|
2001-05-04 16:58:34 +04:00
|
|
|
struct ed_softc *ed; /* disk unit to do the I/O */
|
2001-04-19 11:30:24 +04:00
|
|
|
struct disklabel *lp; /* disk's disklabel */
|
2001-05-14 11:35:33 +04:00
|
|
|
int part;
|
2001-04-19 11:30:24 +04:00
|
|
|
int nblks; /* total number of sectors left to write */
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
int error;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/* Check if recursive dump; if so, punt. */
|
2001-05-04 16:58:34 +04:00
|
|
|
if (eddoingadump)
|
2001-04-19 11:30:24 +04:00
|
|
|
return EFAULT;
|
2001-05-04 16:58:34 +04:00
|
|
|
eddoingadump = 1;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
2001-05-04 16:58:34 +04:00
|
|
|
ed = device_lookup(&ed_cd, DISKUNIT(dev));
|
|
|
|
if (ed == NULL)
|
2001-04-19 11:30:24 +04:00
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
part = DISKPART(dev);
|
|
|
|
|
|
|
|
/* Make sure it was initialized. */
|
2001-05-04 16:58:34 +04:00
|
|
|
if ((ed->sc_flags & EDF_INIT) == 0)
|
2001-04-19 11:30:24 +04:00
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
/* Convert to disk sectors. Request must be a multiple of size. */
|
2001-05-04 16:58:34 +04:00
|
|
|
lp = ed->sc_dk.dk_label;
|
2001-04-19 11:30:24 +04:00
|
|
|
if ((size % lp->d_secsize) != 0)
|
|
|
|
return EFAULT;
|
|
|
|
nblks = size / lp->d_secsize;
|
|
|
|
blkno = blkno / (lp->d_secsize / DEV_BSIZE);
|
|
|
|
|
|
|
|
/* Check transfer bounds against partition size. */
|
|
|
|
if ((blkno < 0) || ((blkno + nblks) > lp->d_partitions[part].p_size))
|
2001-09-03 22:13:13 +04:00
|
|
|
return EINVAL;
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/* Offset block number to start of partition. */
|
|
|
|
blkno += lp->d_partitions[part].p_offset;
|
|
|
|
|
|
|
|
/* Recalibrate, if first dump transfer. */
|
2001-05-04 16:58:34 +04:00
|
|
|
if (eddumprecalibrated == 0) {
|
|
|
|
eddumprecalibrated = 1;
|
|
|
|
eddumpmulti = 8;
|
2001-04-19 11:30:24 +04:00
|
|
|
#if 0
|
|
|
|
wd->drvp->state = RESET;
|
|
|
|
#endif
|
|
|
|
}
|
2001-09-03 22:13:13 +04:00
|
|
|
|
2001-04-19 11:30:24 +04:00
|
|
|
while (nblks > 0) {
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
error = edc_bio(ed->edc_softc, ed, va, blkno,
|
|
|
|
min(nblks, eddumpmulti) * lp->d_secsize, 0, 1);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2001-04-19 11:30:24 +04:00
|
|
|
|
|
|
|
/* update block count */
|
2001-05-04 16:58:34 +04:00
|
|
|
nblks -= min(nblks, eddumpmulti);
|
|
|
|
blkno += min(nblks, eddumpmulti);
|
|
|
|
va += min(nblks, eddumpmulti) * lp->d_secsize;
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
2001-05-04 16:58:34 +04:00
|
|
|
eddoingadump = 0;
|
|
|
|
return (0);
|
2001-04-19 11:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed_get_params(ed, drv_flags)
|
2001-04-19 11:30:24 +04:00
|
|
|
struct ed_softc *ed;
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
int *drv_flags;
|
2001-04-19 11:30:24 +04:00
|
|
|
{
|
|
|
|
u_int16_t cmd_args[2];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get Device Configuration (09).
|
|
|
|
*/
|
2001-04-23 10:10:08 +04:00
|
|
|
cmd_args[0] = 14; /* Options: 00s110, s: 0=Physical 1=Pseudo */
|
2001-04-19 11:30:24 +04:00
|
|
|
cmd_args[1] = 0;
|
2001-05-04 16:58:34 +04:00
|
|
|
if (edc_run_cmd(ed->edc_softc, CMD_GET_DEV_CONF, ed->sc_devno,
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
cmd_args, 2, 1))
|
2001-04-19 11:30:24 +04:00
|
|
|
return (1);
|
|
|
|
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->spares = ed->sense_data[1] >> 8;
|
|
|
|
if (drv_flags)
|
|
|
|
*drv_flags = ed->sense_data[1] & 0x1f;
|
|
|
|
ed->rba = ed->sense_data[2] | (ed->sense_data[3] << 16);
|
2001-04-19 11:30:24 +04:00
|
|
|
/* Instead of using:
|
Convert over to use the new MCA DMA facilities, which encapsulate
the MCA DMA controller access. This also means we gain >16MB RAM support.
While here, overhaul the driver to saner state, especially:
* simplify and clean the attach code a lot, and support the 'drive'
locator
* pass proper dev_t to readdisklabel() - formerly, the passed value was
completely broken (used incorrect major and wrong minor), but worked
by accident
* worker thread is now spawned per controller, rather than per-drive;
i/o cannot be done concurrently by different drivers, only one
i/o can be pending at any time
* simplify the command queue code, just sleep appropriately when
!poll case, g/c 'async' code formerly needed, move the bio code
from ed_mca.c to edc_mca.c:edc_bio()
* put all string arrays used by edc_dump_status_block() within #ifdef EDC_DEBUG,
and use numbers instead if it's not defined; this cuts object size by 5KB
* other misc cleanups
2001-11-24 01:53:09 +03:00
|
|
|
ed->cyl = ed->sense_data[4];
|
|
|
|
ed->heads = ed->sense_data[5] & 0xff;
|
|
|
|
ed->sectors = ed->sense_data[5] >> 8;
|
2001-04-19 11:30:24 +04:00
|
|
|
* we fabricate the numbers from RBA count, so that
|
|
|
|
* number of sectors is 32 and heads 64. This seems
|
|
|
|
* to be necessary for integrated ESDI controller.
|
|
|
|
*/
|
|
|
|
ed->sectors = 32;
|
|
|
|
ed->heads = 64;
|
|
|
|
ed->cyl = ed->rba / (ed->heads * ed->sectors);
|
|
|
|
ed->sc_capacity = ed->rba;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|