FreeBSD/sys/dev/twe/twe_freebsd.c
/********************************************************************************
 * Attach a unit to the controller.
 */
Attach a unit to the controller.
Attach a unit to the controller .
static int
twed_attach(device_t dev)
{
    struct twed_softc	*sc;
    device_t		parent;
    debug_called(4);
    sc = device_get_softc(dev);
    parent = device_get_parent(dev);
    sc->twed_controller = (struct twe_softc *)device_get_softc(parent);
    sc->twed_drive = device_get_ivars(dev);
    sc->twed_dev = dev;
    twed_printf(sc, "%uMB (%u sectors)\n",
		sc->twed_drive->td_size / ((1024 * 1024) / TWE_BLOCK_SIZE),
		sc->twed_drive->td_size);
    sc->twed_drive->td_sys_unit = device_get_unit(dev);
    sc->twed_disk = disk_alloc();
    sc->twed_disk->d_open = twed_open;
    sc->twed_disk->d_strategy = twed_strategy;
    sc->twed_disk->d_dump = (dumper_t *)twed_dump;
    sc->twed_disk->d_name = "twed";
    sc->twed_disk->d_drv1 = sc;
    sc->twed_disk->d_maxsize = (TWE_MAX_SGL_LENGTH - 1) * PAGE_SIZE;
    sc->twed_disk->d_sectorsize = TWE_BLOCK_SIZE;
    sc->twed_disk->d_mediasize = TWE_BLOCK_SIZE * (off_t)sc->twed_drive->td_size;
    if (sc->twed_drive->td_type == TWE_UD_CONFIG_RAID0 ||
	sc->twed_drive->td_type == TWE_UD_CONFIG_RAID5 ||
	sc->twed_drive->td_type == TWE_UD_CONFIG_RAID10) {
	    sc->twed_disk->d_stripesize =
		TWE_BLOCK_SIZE << sc->twed_drive->td_stripe;
	    sc->twed_disk->d_stripeoffset = 0;
    }
    sc->twed_disk->d_fwsectors = sc->twed_drive->td_sectors;
    sc->twed_disk->d_fwheads = sc->twed_drive->td_heads;
    sc->twed_disk->d_unit = sc->twed_drive->td_sys_unit;
    disk_create(sc->twed_disk, DISK_VERSION);
    return (0);
}
static int twed_attach ( device_t dev ) { struct twed_softc * sc ; device_t parent ; debug_called ( 4 ) ; sc = device_get_softc ( dev ) ; parent = device_get_parent ( dev ) ; sc -> twed_controller = ( struct twe_softc * ) device_get_softc ( parent ) ; sc -> twed_drive = device_get_ivars ( dev ) ; sc -> twed_dev = dev ; twed_printf ( sc , " \n " , sc -> twed_drive -> td_size / ( ( 1024 * 1024 ) / TWE_BLOCK_SIZE ) , sc -> twed_drive -> td_size ) ; sc -> twed_drive -> td_sys_unit = device_get_unit ( dev ) ; sc -> twed_disk = disk_alloc ( ) ; sc -> twed_disk -> d_open = twed_open ; sc -> twed_disk -> d_strategy = twed_strategy ; sc -> twed_disk -> d_dump = ( dumper_t * ) twed_dump ; sc -> twed_disk -> d_name = " " ; sc -> twed_disk -> d_drv1 = sc ; sc -> twed_disk -> d_maxsize = ( TWE_MAX_SGL_LENGTH - 1 ) * PAGE_SIZE ; sc -> twed_disk -> d_sectorsize = TWE_BLOCK_SIZE ; sc -> twed_disk -> d_mediasize = TWE_BLOCK_SIZE * ( off_t ) sc -> twed_drive -> td_size ; if ( sc -> twed_drive -> td_type == TWE_UD_CONFIG_RAID0 || sc -> twed_drive -> td_type == TWE_UD_CONFIG_RAID5 || sc -> twed_drive -> td_type == TWE_UD_CONFIG_RAID10 ) { sc -> twed_disk -> d_stripesize = TWE_BLOCK_SIZE << sc -> twed_drive -> td_stripe ; sc -> twed_disk -> d_stripeoffset = 0 ; } sc -> twed_disk -> d_fwsectors = sc -> twed_drive -> td_sectors ; sc -> twed_disk -> d_fwheads = sc -> twed_drive -> td_heads ; sc -> twed_disk -> d_unit = sc -> twed_drive -> td_sys_unit ; disk_create ( sc -> twed_disk , DISK_VERSION ) ; return ( 0 ) ; }
Attach a unit to the controller.
Attach a unit to the controller .
/* initialise our softc */ /* report the drive */ /* attach a generic disk device to ourselves */ /* set the maximum I/O size to the theoretical maximum allowed by the S/G list size */