diff options
author | njl <njl@FreeBSD.org> | 2005-02-05 22:28:36 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2005-02-05 22:28:36 +0000 |
commit | 91da9ee9862682a904c81cb681b35c97f57c2f5d (patch) | |
tree | 10024df0268cec88bc7178a3ca893917f7750e99 | |
parent | 847a21ef1075a69823ce60cd0c0061637aea4b96 (diff) | |
download | FreeBSD-src-91da9ee9862682a904c81cb681b35c97f57c2f5d.zip FreeBSD-src-91da9ee9862682a904c81cb681b35c97f57c2f5d.tar.gz |
Convert the acpi_bus_alloc_gas() and acpi_PkgGas() APIs to output the memory
type. This is needed if the resource is to be released later. The RID is
still also present, though less necessary since rman_get_rid() can be used
to obtain it from the resource.
-rw-r--r-- | sys/dev/acpica/acpi.c | 30 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_package.c | 13 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 8 |
3 files changed, 27 insertions, 24 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 63b705f..c1dbbe5 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1069,28 +1069,36 @@ out: } /* 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 +acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas, + struct resource **res) { - int type; + int error, res_type; - if (gas == NULL || !ACPI_VALID_ADDRESS(gas->Address) || - gas->RegisterBitWidth < 8) - return (NULL); + error = ENOMEM; + if (type == NULL || rid == NULL || gas == NULL || res == NULL || + !ACPI_VALID_ADDRESS(gas->Address) || gas->RegisterBitWidth < 8) + return (EINVAL); switch (gas->AddressSpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: - type = SYS_RES_MEMORY; + res_type = SYS_RES_MEMORY; break; case ACPI_ADR_SPACE_SYSTEM_IO: - type = SYS_RES_IOPORT; + res_type = SYS_RES_IOPORT; break; default: - return (NULL); + return (EOPNOTSUPP); } - bus_set_resource(dev, type, *rid, gas->Address, gas->RegisterBitWidth / 8); - return (bus_alloc_resource_any(dev, type, rid, RF_ACTIVE)); + bus_set_resource(dev, res_type, *rid, gas->Address, + gas->RegisterBitWidth / 8); + *res = bus_alloc_resource_any(dev, res_type, rid, RF_ACTIVE); + if (*res != NULL) { + *type = res_type; + error = 0; + } + return (error); } /* Probe _HID and _CID for compatible ISA PNP ids. */ diff --git a/sys/dev/acpica/acpi_package.c b/sys/dev/acpica/acpi_package.c index 1ed55e4..0cad9a0 100644 --- a/sys/dev/acpica/acpi_package.c +++ b/sys/dev/acpica/acpi_package.c @@ -103,11 +103,11 @@ acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size) } int -acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid, - struct resource **dst) +acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *type, int *rid, + struct resource **dst) { ACPI_GENERIC_ADDRESS gas; - ACPI_OBJECT *obj; + ACPI_OBJECT *obj; obj = &res->Package.Elements[idx]; if (obj == NULL || obj->Type != ACPI_TYPE_BUFFER || @@ -115,13 +115,8 @@ acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid, return (EINVAL); memcpy(&gas, obj->Buffer.Pointer + 3, sizeof(gas)); - if (gas.AddressSpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE) - return (EOPNOTSUPP); - *dst = acpi_bus_alloc_gas(dev, rid, &gas); - if (*dst == NULL) - return (ENXIO); - return (0); + return (acpi_bus_alloc_gas(dev, type, rid, &gas, dst)); } ACPI_HANDLE diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index a06717e..4478252 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -282,8 +282,8 @@ int acpi_parse_prw(ACPI_HANDLE h, struct acpi_prw_data *prw); ACPI_STATUS acpi_Startup(void); void acpi_UserNotify(const char *subsystem, ACPI_HANDLE h, uint8_t notify); -struct resource *acpi_bus_alloc_gas(device_t dev, int *rid, - ACPI_GENERIC_ADDRESS *gas); +int acpi_bus_alloc_gas(device_t dev, int *type, int *rid, + ACPI_GENERIC_ADDRESS *gas, struct resource **res); struct acpi_parse_resource_set { void (*set_init)(device_t dev, void *arg, void **context); @@ -387,8 +387,8 @@ int acpi_acad_get_acline(int *); int acpi_PkgInt(ACPI_OBJECT *res, int idx, ACPI_INTEGER *dst); int acpi_PkgInt32(ACPI_OBJECT *res, int idx, uint32_t *dst); int acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size); -int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid, - struct resource **dst); +int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *type, + int *rid, struct resource **dst); ACPI_HANDLE acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj); #ifndef ACPI_MAX_THREADS |