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 $
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 */
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;
818 sc->twed_drive->td_sys_unit = device_get_unit(dev);
819
820 disk_create(sc->twed_drive->td_sys_unit, &sc->twed_disk, 0, NULL, NULL);
821#ifdef FREEBSD_4
822 disks_registered++;
823#endif
824
825 /* set the maximum I/O size to the theoretical maximum allowed by the S/G list size */
826
827 return (0);
828}
829
830/********************************************************************************
831 * Disconnect ourselves from the system.
832 */
833static int
834twed_detach(device_t dev)
835{
836 struct twed_softc *sc = (struct twed_softc *)device_get_softc(dev);
837
838 debug_called(4);
839
840 if (sc->twed_disk.d_flags & DISKFLAG_OPEN)
841 return(EBUSY);
842
843 disk_destroy(&sc->twed_disk);
844
845#ifdef FREEBSD_4
846 if (--disks_registered == 0)
847 cdevsw_remove(&tweddisk_cdevsw);
848#endif
849 return(0);
850}
851
--- 286 unchanged lines hidden ---
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 $
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 */
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;
818 sc->twed_drive->td_sys_unit = device_get_unit(dev);
819
820 disk_create(sc->twed_drive->td_sys_unit, &sc->twed_disk, 0, NULL, NULL);
821#ifdef FREEBSD_4
822 disks_registered++;
823#endif
824
825 /* set the maximum I/O size to the theoretical maximum allowed by the S/G list size */
826
827 return (0);
828}
829
830/********************************************************************************
831 * Disconnect ourselves from the system.
832 */
833static int
834twed_detach(device_t dev)
835{
836 struct twed_softc *sc = (struct twed_softc *)device_get_softc(dev);
837
838 debug_called(4);
839
840 if (sc->twed_disk.d_flags & DISKFLAG_OPEN)
841 return(EBUSY);
842
843 disk_destroy(&sc->twed_disk);
844
845#ifdef FREEBSD_4
846 if (--disks_registered == 0)
847 cdevsw_remove(&tweddisk_cdevsw);
848#endif
849 return(0);
850}
851
--- 286 unchanged lines hidden ---