static int fdc_acpi_attach(device_t dev) { struct fdc_data *sc; ACPI_BUFFER buf; ACPI_OBJECT *obj; device_t bus; int error; /* Get our softc and use the same accessor as ISA. */ sc = device_get_softc(dev); sc->fdc_dev = dev; /* Initialize variables and get a temporary buffer for _FDE. */ error = ENXIO; buf.Length = ACPI_FDC_BUFLEN; buf.Pointer = malloc(buf.Length, M_TEMP, M_NOWAIT | M_ZERO); if (buf.Pointer == NULL) goto out; /* Allocate resources the same as the ISA attachment. */ error = fdc_isa_alloc_resources(dev, sc); if (error != 0) goto out; /* Call common attach code in fdc(4) first. */ error = fdc_attach(dev); if (error != 0) goto out; /* * Enumerate _FDE, which lists floppy drives that are present. If * this fails, fall back to the ISA hints-based probe method. */ bus = device_get_parent(dev); if (ACPI_FAILURE(ACPI_EVALUATE_OBJECT(bus, dev, "_FDE", NULL, &buf))) { error = fdc_hints_probe(dev); goto out; } /* Add fd child devices as specified. */ obj = buf.Pointer; error = fdc_acpi_probe_children(bus, dev, obj->Buffer.Pointer); out: if (buf.Pointer) free(buf.Pointer, M_TEMP); if (error != 0) fdc_release_resources(sc); return (error); }
static int fdc_cbus_attach(device_t dev) { struct fdc_data *fdc; int error; fdc = device_get_softc(dev); if ((error = fdc_cbus_alloc_resources(dev, fdc)) != 0 || (error = fdc_attach(dev)) != 0 || (error = fdc_hints_probe(dev)) != 0) { fdc_release_resources(fdc); return (error); } return (0); }
static int fdc_isa_attach(device_t dev) { struct fdc_data *fdc; int error; fdc = device_get_softc(dev); fdc->fdc_dev = dev; error = fdc_isa_alloc_resources(dev, fdc); if (error == 0) error = fdc_attach(dev); if (error == 0) error = fdc_hints_probe(dev); if (error) fdc_release_resources(fdc); return (error); }
static int fdc_cbus_probe(device_t dev) { int error; struct fdc_data *fdc; fdc = device_get_softc(dev); /* Check pnp ids */ if (isa_get_vendorid(dev)) return (ENXIO); /* Attempt to allocate our resources for the duration of the probe */ error = fdc_cbus_alloc_resources(dev, fdc); if (!error) error = fdc_initial_reset(fdc); fdc_release_resources(fdc); return (error); }
static int fdc_pccard_attach(device_t dev) { int error; struct fdc_data *fdc; device_t child; fdc = device_get_softc(dev); fdc->flags = FDC_NODMA | FDC_NOFAST; fdc->fdct = FDC_NE765; error = fdc_pccard_alloc_resources(dev, fdc); if (error == 0) error = fdc_attach(dev); if (error == 0) { child = fdc_add_child(dev, "fd", -1); device_set_flags(child, 0x24); error = bus_generic_attach(dev); } if (error) fdc_release_resources(fdc); return (error); }
static int fdc_isa_probe(device_t dev) { int error; struct fdc_data *fdc; fdc = device_get_softc(dev); fdc->fdc_dev = dev; /* Check pnp ids */ error = ISA_PNP_PROBE(device_get_parent(dev), dev, fdc_ids); if (error == ENXIO) return (ENXIO); /* Attempt to allocate our resources for the duration of the probe */ error = fdc_isa_alloc_resources(dev, fdc); if (error == 0) error = fdc_initial_reset(dev, fdc); fdc_release_resources(fdc); return (error); }