From owner-svn-src-all@freebsd.org Fri Dec 16 10:40:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15EE4C805FA; Fri, 16 Dec 2016 10:40:02 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB05CAEC; Fri, 16 Dec 2016 10:40:01 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBGAe1J8034654; Fri, 16 Dec 2016 10:40:01 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBGAe056034652; Fri, 16 Dec 2016 10:40:00 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201612161040.uBGAe056034652@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Fri, 16 Dec 2016 10:40:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310154 - head/sys/dev/acpica X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 10:40:02 -0000 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 #include +#include + #include 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;