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.
This commit is contained in:
Nate Lawson 2005-02-05 22:28:36 +00:00
parent ab42aa145d
commit e1c4bf3f42
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141371
3 changed files with 27 additions and 24 deletions

View file

@ -1069,28 +1069,36 @@ acpi_release_resource(device_t bus, device_t child, int type, int rid,
}
/* 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. */

View file

@ -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

View file

@ -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