diff options
author | jkim <jkim@FreeBSD.org> | 2011-04-18 23:12:41 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2011-04-18 23:12:41 +0000 |
commit | f5b28424de5145cf84073390684865dc604cef24 (patch) | |
tree | 26dc6b07d05470b594b5e9a5106bd01547eb6cb0 /sys/dev/acpica | |
parent | 54ea1a10a5370fdc4fe35392a981779de4c01e5e (diff) | |
download | FreeBSD-src-f5b28424de5145cf84073390684865dc604cef24.zip FreeBSD-src-f5b28424de5145cf84073390684865dc604cef24.tar.gz |
Do not assume PM timer GAS type is I/O or memory. It may be an unsupported
type, i. e., a broken table. Also, do not hardcode ACPI timer frequency in
device description.
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r-- | sys/dev/acpica/acpi_timer.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index 11c0e24..f456206 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -130,9 +130,17 @@ acpi_timer_identify(driver_t *driver, device_t parent) } acpi_timer_dev = dev; + switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + rtype = SYS_RES_MEMORY; + break; + case ACPI_ADR_SPACE_SYSTEM_IO: + rtype = SYS_RES_IOPORT; + break; + default: + return_VOID; + } rid = 0; - rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? - SYS_RES_IOPORT : SYS_RES_MEMORY; rlen = AcpiGbl_FADT.PmTimerLength; rstart = AcpiGbl_FADT.XPmTimerBlock.Address; if (bus_set_resource(dev, rtype, rid, rstart, rlen)) @@ -152,9 +160,17 @@ acpi_timer_probe(device_t dev) if (dev != acpi_timer_dev) return (ENXIO); + switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + rtype = SYS_RES_MEMORY; + break; + case ACPI_ADR_SPACE_SYSTEM_IO: + rtype = SYS_RES_IOPORT; + break; + default: + return (ENXIO); + } rid = 0; - rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? - SYS_RES_IOPORT : SYS_RES_MEMORY; acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); if (acpi_timer_reg == NULL) { device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n", @@ -195,8 +211,9 @@ acpi_timer_probe(device_t dev) } tc_init(&acpi_timer_timecounter); - sprintf(desc, "%d-bit timer at 3.579545MHz", - (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) ? 32 : 24); + sprintf(desc, "%d-bit timer at %u.%06uMHz", + (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24, + acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000); device_set_desc_copy(dev, desc); /* Release the resource, we'll allocate it again during attach. */ @@ -211,9 +228,17 @@ acpi_timer_attach(device_t dev) ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + rtype = SYS_RES_MEMORY; + break; + case ACPI_ADR_SPACE_SYSTEM_IO: + rtype = SYS_RES_IOPORT; + break; + default: + return (ENXIO); + } rid = 0; - rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? - SYS_RES_IOPORT : SYS_RES_MEMORY; acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); if (acpi_timer_reg == NULL) return (ENXIO); |