Add support to read the _CLS entry if it's present. It is used by

memory-mapped devices that are normally PCIe drives. Devices can then use
the existing pci_get_class, etc. accessors to query this data.

The ivar values are different enough from the existing ACPI and ISA values
to not conflict.

Reviewed by:	jhb
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8721
This commit is contained in:
Andrew Turner
2016-12-16 10:40:00 +00:00
parent 6c925b9c81
commit 0e68afe553
2 changed files with 25 additions and 0 deletions
+24
View File
@@ -68,6 +68,8 @@ __FBSDID("$FreeBSD$");
#include <dev/acpica/acpivar.h>
#include <dev/acpica/acpiio.h>
#include <dev/pci/pcivar.h>
#include <vm/vm_param.h>
static MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices");
@@ -923,6 +925,15 @@ acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
case ISA_IVAR_LOGICALID:
*(int *)result = acpi_isa_get_logicalid(child);
break;
case PCI_IVAR_CLASS:
*(uint8_t*)result = (ad->ad_cls_class >> 16) & 0xff;
break;
case PCI_IVAR_SUBCLASS:
*(uint8_t*)result = (ad->ad_cls_class >> 8) & 0xff;
break;
case PCI_IVAR_PROGIF:
*(uint8_t*)result = (ad->ad_cls_class >> 0) & 0xff;
break;
default:
return (ENOENT);
}
@@ -1961,6 +1972,8 @@ acpi_probe_order(ACPI_HANDLE handle, int *order)
static ACPI_STATUS
acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
{
ACPI_DEVICE_INFO *devinfo;
struct acpi_device *ad;
struct acpi_prw_data prw;
ACPI_OBJECT_TYPE type;
ACPI_HANDLE h;
@@ -2054,6 +2067,17 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
* device not to have any resources.
*/
acpi_parse_resources(child, handle, &acpi_res_parse_set, NULL);
ad = device_get_ivars(child);
ad->ad_cls_class = 0xffffff;
if (ACPI_SUCCESS(AcpiGetObjectInfo(handle, &devinfo))) {
if ((devinfo->Valid & ACPI_VALID_CLS) != 0 &&
devinfo->ClassCode.Length >= ACPI_PCICLS_STRING_SIZE) {
ad->ad_cls_class = strtoul(devinfo->ClassCode.String,
NULL, 16);
}
AcpiOsFree(devinfo);
}
break;
}
}
+1
View File
@@ -85,6 +85,7 @@ struct acpi_device {
ACPI_HANDLE ad_handle;
void *ad_private;
int ad_flags;
int ad_cls_class;
/* Resources */
struct resource_list ad_rl;