Deleted Added
full compact
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2003 Paul Saab
4 * Copyright (c) 2003 Vinod Kashyap
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/sys/dev/twe/twe_freebsd.c 123103 2003-12-02 07:57:20Z ps $
29 * $FreeBSD: head/sys/dev/twe/twe_freebsd.c 125975 2004-02-18 21:36:53Z phk $
30 */
31
32/*
33 * FreeBSD-specific code.
34 */
35
36#include <dev/twe/twe_compat.h>
37#include <dev/twe/twereg.h>

--- 597 unchanged lines hidden (view full) ---

635/*
636 * Disk device softc
637 */
638struct twed_softc
639{
640 device_t twed_dev;
641 struct twe_softc *twed_controller; /* parent device softc */
642 struct twe_drive *twed_drive; /* drive data in parent softc */
643 struct disk twed_disk; /* generic disk handle */
643 struct disk *twed_disk; /* generic disk handle */
644};
645
646/*
647 * Disk device bus interface
648 */
649static int twed_probe(device_t dev);
650static int twed_attach(device_t dev);
651static int twed_detach(device_t dev);

--- 148 unchanged lines hidden (view full) ---

800
801 /* report the drive */
802 twed_printf(sc, "%uMB (%u sectors)\n",
803 sc->twed_drive->td_size / ((1024 * 1024) / TWE_BLOCK_SIZE),
804 sc->twed_drive->td_size);
805
806 /* attach a generic disk device to ourselves */
807
808 sc->twed_disk.d_open = twed_open;
809 sc->twed_disk.d_strategy = twed_strategy;
810 sc->twed_disk.d_dump = (dumper_t *)twed_dump;
811 sc->twed_disk.d_name = "twed";
812 sc->twed_disk.d_drv1 = sc;
813 sc->twed_disk.d_maxsize = (TWE_MAX_SGL_LENGTH - 1) * PAGE_SIZE;
814 sc->twed_disk.d_sectorsize = TWE_BLOCK_SIZE;
815 sc->twed_disk.d_mediasize = TWE_BLOCK_SIZE * (off_t)sc->twed_drive->td_size;
816 sc->twed_disk.d_fwsectors = sc->twed_drive->td_sectors;
817 sc->twed_disk.d_fwheads = sc->twed_drive->td_heads;
808 sc->twed_drive->td_sys_unit = device_get_unit(dev);
809
820 disk_create(sc->twed_drive->td_sys_unit, &sc->twed_disk, 0, NULL, NULL);
810 sc->twed_disk = disk_alloc();
811 sc->twed_disk->d_open = twed_open;
812 sc->twed_disk->d_strategy = twed_strategy;
813 sc->twed_disk->d_dump = (dumper_t *)twed_dump;
814 sc->twed_disk->d_name = "twed";
815 sc->twed_disk->d_drv1 = sc;
816 sc->twed_disk->d_maxsize = (TWE_MAX_SGL_LENGTH - 1) * PAGE_SIZE;
817 sc->twed_disk->d_sectorsize = TWE_BLOCK_SIZE;
818 sc->twed_disk->d_mediasize = TWE_BLOCK_SIZE * (off_t)sc->twed_drive->td_size;
819 sc->twed_disk->d_fwsectors = sc->twed_drive->td_sectors;
820 sc->twed_disk->d_fwheads = sc->twed_drive->td_heads;
821 sc->twed_disk->d_unit = sc->twed_drive->td_sys_unit;
822 sc->twed_disk->d_flags = DISKFLAG_NEEDSGIANT;
823
824 disk_create(sc->twed_disk, DISK_VERSION);
825
826#ifdef FREEBSD_4
827 disks_registered++;
828#endif
829
830 /* set the maximum I/O size to the theoretical maximum allowed by the S/G list size */
831
832 return (0);
833}
834
835/********************************************************************************
836 * Disconnect ourselves from the system.
837 */
838static int
839twed_detach(device_t dev)
840{
841 struct twed_softc *sc = (struct twed_softc *)device_get_softc(dev);
842
843 debug_called(4);
844
840 if (sc->twed_disk.d_flags & DISKFLAG_OPEN)
845 if (sc->twed_disk->d_flags & DISKFLAG_OPEN)
846 return(EBUSY);
847
843 disk_destroy(&sc->twed_disk);
848 disk_destroy(sc->twed_disk);
849
850#ifdef FREEBSD_4
851 if (--disks_registered == 0)
852 cdevsw_remove(&tweddisk_cdevsw);
853#endif
854 return(0);
855}
856

--- 286 unchanged lines hidden ---