Exemple #1
0
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);
}
Exemple #2
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);
}
Exemple #3
0
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);
}