summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2003-11-15 19:18:29 +0000
committernjl <njl@FreeBSD.org>2003-11-15 19:18:29 +0000
commit0fd0be9b4cadc547ffbe21338f36ab49fbd66d7a (patch)
tree1dc93b462e08d59fd2bf3eff046703d61966befe
parent1f1358c8e0b607c2fdaf5da2deda6bbfb118ef8c (diff)
downloadFreeBSD-src-0fd0be9b4cadc547ffbe21338f36ab49fbd66d7a.zip
FreeBSD-src-0fd0be9b4cadc547ffbe21338f36ab49fbd66d7a.tar.gz
Add acpi_bus_alloc_gas() for allocating a memory or IO resource from its
Generic Address Structure.
-rw-r--r--sys/dev/acpica/acpi.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 33cb20c..3500205 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -46,6 +46,8 @@
#include <machine/clock.h>
#include <machine/resource.h>
+#include <machine/bus.h>
+#include <sys/rman.h>
#include <isa/isavar.h>
#include "acpi.h"
@@ -755,7 +757,32 @@ acpi_release_resource(device_t bus, device_t child, int type, int rid, struct re
struct acpi_device *ad = device_get_ivars(child);
struct resource_list *rl = &ad->ad_rl;
- return(resource_list_release(rl, bus, child, type, rid, r));
+ return (resource_list_release(rl, bus, child, type, rid, r));
+}
+
+/* Allocate an IO port or memory resource, given its GAS. */
+struct resource *
+acpi_bus_alloc_gas(device_t dev, int *rid, ACPI_GENERIC_ADDRESS *gas)
+{
+ int type;
+
+ if (gas == NULL || !ACPI_VALID_ADDRESS(gas->Address) ||
+ gas->RegisterBitWidth < 8)
+ return (NULL);
+
+ switch (gas->AddressSpaceId) {
+ case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+ type = SYS_RES_MEMORY;
+ break;
+ case ACPI_ADR_SPACE_SYSTEM_IO:
+ type = SYS_RES_IOPORT;
+ break;
+ default:
+ return (NULL);
+ }
+
+ bus_set_resource(dev, type, *rid, gas->Address, gas->RegisterBitWidth / 8);
+ return (bus_alloc_resource(dev, type, rid, 0, ~0, 1, RF_ACTIVE));
}
/*
OpenPOWER on IntegriCloud