Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Update for lsu; untested.
details: https://anonhg.NetBSD.org/src/rev/de788bbea231
branches: trunk
changeset: 498313:de788bbea231
user: ad <ad%NetBSD.org@localhost>
date: Thu Oct 19 14:28:46 2000 +0000
description:
Update for lsu; untested.
diffstat:
sys/dev/ic/ca.c | 684 ----------------------------------------------------
sys/dev/ic/cac.c | 40 +-
sys/dev/ic/cacvar.h | 9 +-
3 files changed, 17 insertions(+), 716 deletions(-)
diffs (truncated from 833 to 300 lines):
diff -r 3b9a6df4afb4 -r de788bbea231 sys/dev/ic/ca.c
--- a/sys/dev/ic/ca.c Thu Oct 19 14:27:53 2000 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,684 +0,0 @@
-/* $NetBSD: ca.c,v 1.10 2000/09/01 12:23:57 ad Exp $ */
-
-/*-
- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and Andrew Doran.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Originally written by Julian Elischer (julian%dialix.oz.au@localhost)
- * for TRW Financial Systems for use under the MACH(2.5) operating system.
- *
- * TRW Financial Systems, in accordance with their agreement with Carnegie
- * Mellon University, makes this software available to CMU to distribute
- * or use in any manner that they see fit as long as this message is kept with
- * the software. For this reason TFS also grants any other persons or
- * organisations permission to use or modify this software.
- *
- * TFS supplies this software to be publicly redistributed
- * on the understanding that TFS is not responsible for the correct
- * functioning of this software in any circumstances.
- *
- * Ported to run under 386BSD by Julian Elischer (julian%dialix.oz.au@localhost) Sept 1992
- */
-
-/*
- * Disk driver for Compaq arrays, based on sd.c (revision 1.157).
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.10 2000/09/01 12:23:57 ad Exp $");
-
-#include "rnd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-#include <sys/queue.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/endian.h>
-#include <sys/disklabel.h>
-#include <sys/disk.h>
-#include <sys/dkio.h>
-#include <sys/stat.h>
-#include <sys/lock.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#if NRND > 0
-#include <sys/rnd.h>
-#endif
-
-#include <machine/bswap.h>
-#include <machine/bus.h>
-
-#include <dev/ic/cacreg.h>
-#include <dev/ic/cacvar.h>
-
-#define CAUNIT(dev) DISKUNIT(dev)
-#define CAPART(dev) DISKPART(dev)
-#define CAMINOR(unit, part) DISKMINOR(unit, part)
-#define CAMAKEDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part)
-
-#define CALABELDEV(dev) (CAMAKEDEV(major(dev), CAUNIT(dev), RAW_PART))
-
-/* #define CA_ENABLE_SYNC_XFER */
-
-struct ca_softc {
- struct device sc_dv;
- int sc_unit;
- int sc_flags;
- struct cac_softc *sc_cac;
- struct disk sc_dk;
-#if NRND > 0
- rndsource_element_t sc_rnd_source;
-#endif
-
- /* Parameters from controller. */
- int sc_ncylinders;
- int sc_nheads;
- int sc_nsectors;
- int sc_secsize;
- int sc_secperunit;
- int sc_mirror;
-};
-
-#define CAF_ENABLED 0x01 /* device enabled */
-#define CAF_LOCKED 0x02 /* lock held */
-#define CAF_WANTED 0x04 /* lock wanted */
-#define CAF_WLABEL 0x08 /* label is writable */
-#define CAF_LABELLING 0x10 /* writing label */
-
-static int calock __P((struct ca_softc *));
-static void caunlock __P((struct ca_softc *));
-static int camatch __P((struct device *, struct cfdata *, void *));
-static void caattach __P((struct device *, struct device *, void *));
-static void cadone __P((struct cac_ccb *, int));
-static void cagetdisklabel __P((struct ca_softc *));
-static void cagetdefaultlabel __P((struct ca_softc *, struct disklabel *));
-
-struct cfattach ca_ca = {
- sizeof(struct ca_softc), camatch, caattach
-};
-
-extern struct cfdriver ca_cd;
-
-struct dkdriver cadkdriver = { castrategy };
-
-static int
-camatch(parent, match, aux)
- struct device *parent;
- struct cfdata *match;
- void *aux;
-{
-
- return (1);
-}
-
-static void
-caattach(parent, self, aux)
- struct device *parent;
- struct device *self;
- void *aux;
-{
- struct cac_drive_info dinfo;
- struct cac_attach_args *caca;
- struct ca_softc *sc;
- char *type;
- int mb;
-
- sc = (struct ca_softc *)self;
- caca = (struct cac_attach_args *)aux;
- sc->sc_cac = (struct cac_softc *)parent;
- sc->sc_unit = caca->caca_unit;
-
- if (cac_cmd(sc->sc_cac, CAC_CMD_GET_LOG_DRV_INFO, &dinfo, sizeof(dinfo),
- sc->sc_unit, 0, CAC_CCB_DATA_IN, NULL)) {
- printf("%s: CMD_GET_LOG_DRV_INFO failed\n",
- sc->sc_dv.dv_xname);
- return;
- }
-
- sc->sc_ncylinders = CAC_GET2(dinfo.ncylinders);
- sc->sc_nheads = CAC_GET1(dinfo.nheads);
- sc->sc_nsectors = CAC_GET1(dinfo.nsectors);
- sc->sc_secsize = CAC_GET2(dinfo.secsize);
- sc->sc_mirror = CAC_GET1(dinfo.mirror);
- sc->sc_secperunit = sc->sc_ncylinders * sc->sc_nheads * sc->sc_nsectors;
-
- switch (sc->sc_mirror) {
- case 0:
- type = "standalone disk or RAID0";
- break;
- case 1:
- type = "RAID4";
- break;
- case 2:
- type = "RAID1";
- break;
- case 3:
- type = "RAID5";
- break;
- default:
- type = "unknown type of";
- break;
- }
-
- printf(": %s array\n", type);
-
- mb = sc->sc_secperunit / (1048576 / sc->sc_secsize);
- printf("%s: %uMB, %u cyl, %u head, %u sec, %d bytes/sect "
- "x %d sectors\n", sc->sc_dv.dv_xname, mb, sc->sc_ncylinders,
- sc->sc_nheads, sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit);
-
- /* Initialize and attach the disk structure */
- sc->sc_dk.dk_driver = &cadkdriver;
- sc->sc_dk.dk_name = sc->sc_dv.dv_xname;
- disk_attach(&sc->sc_dk);
- sc->sc_flags |= CAF_ENABLED;
-
-#if NRND > 0
- /* Attach the device into the rnd source list. */
- rnd_attach_source(&sc->sc_rnd_source, sc->sc_dv.dv_xname,
- RND_TYPE_DISK, 0);
-#endif
-}
-
-int
-caopen(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- struct ca_softc *sc;
- int part;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- if (sc == NULL)
- return (ENXIO);
- if ((sc->sc_flags & CAF_ENABLED) == 0)
- return (ENODEV);
- part = CAPART(dev);
- calock(sc);
-
- if (sc->sc_dk.dk_openmask == 0)
- cagetdisklabel(sc);
-
- /* Check that the partition exists. */
- if (part != RAW_PART && (part >= sc->sc_dk.dk_label->d_npartitions ||
- sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
- caunlock(sc);
- return (ENXIO);
- }
-
- /* Insure only one open at a time. */
- switch (fmt) {
- case S_IFCHR:
- sc->sc_dk.dk_copenmask |= (1 << part);
- break;
- case S_IFBLK:
- sc->sc_dk.dk_bopenmask |= (1 << part);
- break;
- }
- sc->sc_dk.dk_openmask =
- sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
-
- caunlock(sc);
- return (0);
-}
-
-int
-caclose(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- struct ca_softc *sc;
- int part;
-
- sc = device_lookup(&ca_cd, CAUNIT(dev));
- part = CAPART(dev);
- calock(sc);
-
- switch (fmt) {
- case S_IFCHR:
- sc->sc_dk.dk_copenmask &= ~(1 << part);
- break;
- case S_IFBLK:
- sc->sc_dk.dk_bopenmask &= ~(1 << part);
- break;
- }
- sc->sc_dk.dk_openmask =
- sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
-
- caunlock(sc);
- return (0);
-}
-
-int
-caread(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
Home |
Main Index |
Thread Index |
Old Index