Author: andrew
Date: Fri Dec 16 10:40:00 2016
New Revision: 310154
URL: https://svnweb.freebsd.org/changeset/base/310154

Log:
  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

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/dev/acpica/acpivar.h

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c  Fri Dec 16 10:31:13 2016        (r310153)
+++ head/sys/dev/acpica/acpi.c  Fri Dec 16 10:40:00 2016        (r310154)
@@ -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 ch
     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
 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, UIN
             * 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;
        }
     }

Modified: head/sys/dev/acpica/acpivar.h
==============================================================================
--- head/sys/dev/acpica/acpivar.h       Fri Dec 16 10:31:13 2016        
(r310153)
+++ head/sys/dev/acpica/acpivar.h       Fri Dec 16 10:40:00 2016        
(r310154)
@@ -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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to