diff options
author | jhb <jhb@FreeBSD.org> | 2009-08-24 21:51:46 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-08-24 21:51:46 +0000 |
commit | de920e4e3fb4815142222ca80f8c56e7e375c438 (patch) | |
tree | 363015e7c14d8976f39256022c32c0d78080eae6 | |
parent | 91fcf01735145ebd2496ff073dcf063d8b912862 (diff) | |
download | FreeBSD-src-de920e4e3fb4815142222ca80f8c56e7e375c438.zip FreeBSD-src-de920e4e3fb4815142222ca80f8c56e7e375c438.tar.gz |
Tweak the way that the ACPI and ISA bus drivers match hint devices to
BIOS-enumerated devices:
- Assume a device is a match if the memory and I/O ports match even if the
IRQ or DRQ is wrong or missing. Some BIOSes don't include an IRQ for
the atrtc device for example.
- Add a hack to better match floppy controller devices. Many BIOSes do not
include the starting port of the floppy controller listed in the hints
(0x3f0) in the resources for the device. So far, however, all the BIOS
variations encountered do include the 'port + 2' resource (0x3f2), so
adjust the matching for "fdc" devices to look for 'port + 2'.
Reviewed by: imp
MFC after: 3 days
-rw-r--r-- | sys/dev/acpica/acpi.c | 20 | ||||
-rw-r--r-- | sys/isa/isahint.c | 27 |
2 files changed, 41 insertions, 6 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 63f95d3..a2e5883 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1014,14 +1014,27 @@ acpi_hint_device_unit(device_t acdev, device_t child, const char *name, continue; /* - * Check for matching resources. We must have at least one, - * and all resources specified have to match. + * Check for matching resources. We must have at least one match. + * Since I/O and memory resources cannot be shared, if we get a + * match on either of those, ignore any mismatches in IRQs or DRQs. * * XXX: We may want to revisit this to be more lenient and wire * as long as it gets one match. */ matches = 0; if (resource_long_value(name, unit, "port", &value) == 0) { + /* + * Floppy drive controllers are notorious for having a + * wide variety of resources not all of which include the + * first port that is specified by the hint (typically + * 0x3f0) (see the comment above fdc_isa_alloc_resources() + * in fdc_isa.c). However, they do all seem to include + * port + 2 (e.g. 0x3f2) so for a floppy device, look for + * 'value + 2' in the port resources instead of the hint + * value. + */ + if (strcmp(name, "fdc") == 0) + value += 2; if (acpi_match_resource_hint(child, SYS_RES_IOPORT, value)) matches++; else @@ -1033,6 +1046,8 @@ acpi_hint_device_unit(device_t acdev, device_t child, const char *name, else continue; } + if (matches > 0) + goto matched; if (resource_long_value(name, unit, "irq", &value) == 0) { if (acpi_match_resource_hint(child, SYS_RES_IRQ, value)) matches++; @@ -1046,6 +1061,7 @@ acpi_hint_device_unit(device_t acdev, device_t child, const char *name, continue; } + matched: if (matches > 0) { /* We have a winner! */ *unitp = unit; diff --git a/sys/isa/isahint.c b/sys/isa/isahint.c index e2ce6a4..5eccef8 100644 --- a/sys/isa/isahint.c +++ b/sys/isa/isahint.c @@ -118,14 +118,30 @@ isa_hint_device_unit(device_t bus, device_t child, const char *name, int *unitp) continue; /* - * Check for matching resources. We must have at least one, - * and all resources specified have to match. + * Check for matching resources. We must have at + * least one match. Since I/O and memory resources + * cannot be shared, if we get a match on either of + * those, ignore any mismatches in IRQs or DRQs. * - * XXX: We may want to revisit this to be more lenient and wire - * as long as it gets one match. + * XXX: We may want to revisit this to be more lenient + * and wire as long as it gets one match. */ matches = 0; if (resource_long_value(name, unit, "port", &value) == 0) { + /* + * Floppy drive controllers are notorious for + * having a wide variety of resources not all + * of which include the first port that is + * specified by the hint (typically 0x3f0) + * (see the comment above + * fdc_isa_alloc_resources() in fdc_isa.c). + * However, they do all seem to include port + + * 2 (e.g. 0x3f2) so for a floppy device, look + * for 'value + 2' in the port resources + * instead of the hint value. + */ + if (strcmp(name, "fdc") == 0) + value += 2; if (isa_match_resource_hint(child, SYS_RES_IOPORT, value)) matches++; @@ -139,6 +155,8 @@ isa_hint_device_unit(device_t bus, device_t child, const char *name, int *unitp) else continue; } + if (matches > 0) + goto matched; if (resource_long_value(name, unit, "irq", &value) == 0) { if (isa_match_resource_hint(child, SYS_RES_IRQ, value)) matches++; @@ -152,6 +170,7 @@ isa_hint_device_unit(device_t bus, device_t child, const char *name, int *unitp) continue; } + matched: if (matches > 0) { /* We have a winner! */ *unitp = unit; |