Beispiel #1
0
static int
afd_reinit(device_t dev)
{
    struct ata_channel *ch = device_get_softc(device_get_parent(dev));
    struct ata_device *atadev = device_get_softc(dev);

    /* if detach pending, return error */
    if (!(ch->devices & (ATA_ATAPI_MASTER << atadev->unit)))
	return 1;

    ata_setmode(dev);
    return 0;
}
Beispiel #2
0
static int
acd_attach(device_t dev)
{
    struct acd_softc *cdp;

    if (!(cdp = malloc(sizeof(struct acd_softc), M_ACD, M_NOWAIT | M_ZERO))) {
	device_printf(dev, "out of memory\n");
	return ENOMEM;
    }
    cdp->block_size = 2048;
    device_set_ivars(dev, cdp);
    ata_setmode(dev);
    ata_controlcmd(dev, ATA_DEVICE_RESET, 0, 0, 0);
    acd_get_cap(dev);
    g_post_event(acd_geom_attach, dev, M_WAITOK, NULL);

    /* announce we are here */
    acd_describe(dev);
    return 0;
}
Beispiel #3
0
static int 
afd_attach(device_t dev)
{
    struct ata_channel *ch = device_get_softc(device_get_parent(dev));
    struct ata_device *atadev = device_get_softc(dev);
    struct afd_softc *fdp;

    if (!(fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT | M_ZERO))) {
	device_printf(dev, "out of memory\n");
	return ENOMEM;
    }
    device_set_ivars(dev, fdp);
    ata_setmode(dev);

    if (afd_sense(dev)) {
	device_set_ivars(dev, NULL);
	free(fdp, M_AFD);
	return ENXIO;
    }
    atadev->flags |= ATA_D_MEDIA_CHANGED;

    /* announce we are here */
    afd_describe(dev);

    /* create the disk device */
    fdp->disk = disk_alloc();
    fdp->disk->d_open = afd_open;
    fdp->disk->d_close = afd_close;
    fdp->disk->d_strategy = afd_strategy;
    fdp->disk->d_ioctl = afd_ioctl;
    fdp->disk->d_name = "afd";
    fdp->disk->d_drv1 = dev;
    fdp->disk->d_maxsize = ch->dma.max_iosize ? ch->dma.max_iosize : DFLTPHYS;
    fdp->disk->d_unit = device_get_unit(dev);
    disk_create(fdp->disk, DISK_VERSION);
    return 0;
}