acpidev_cpu.c revision e2af1b53c69207cf8b36451b3a8c8f800ee9855e
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2016 Nexenta Systems, Inc.
*/
/*
* Copyright (c) 2009-2010, Intel Corporation.
* All rights reserved.
*/
/*
* [Support of X2APIC]
* According to the ACPI Spec, when using the X2APIC interrupt model, logical
* processors with APIC ID values of 255 and greater are required to have a
* Processor Device object and must convey the Processor's APIC information to
* OSPM using the Processor Local X2APIC structure. Logical Processors with APIC
* ID values less than 255 must use the Processor Local XAPIC structure to
* convey their APIC information to OSPM.
*
* Some systems ignore that requirement of ACPI Spec and use Processor Local
* X2APIC structures even for Logical Processors with APIC ID values less than
* 255.
*/
#include <sys/bootconf.h>
#include <sys/machsystm.h>
#include <sys/psm_types.h>
#include <sys/x86_archext.h>
#include <sys/acpidev_impl.h>
struct acpidev_cpu_map_item {
};
struct acpidev_cpu_MAT_arg {
};
/*
*/
0, /* adc_refcnt */
ACPIDEV_CLASS_REV1, /* adc_version */
ACPIDEV_CLASS_ID_CPU, /* adc_class_id */
"ACPI CPU", /* adc_class_name */
ACPIDEV_TYPE_CPU, /* adc_dev_type */
NULL, /* adc_private */
acpidev_cpu_pre_probe, /* adc_pre_probe */
acpidev_cpu_post_probe, /* adc_post_probe */
acpidev_cpu_probe, /* adc_probe */
acpidev_cpu_filter, /* adc_filter */
acpidev_cpu_init, /* adc_init */
acpidev_cpu_fini, /* adc_fini */
};
/*
* List of class drivers which will be called in order when handling
*/
/* Filter rule table for the first probe at boot time. */
static acpidev_filter_rule_t acpidev_cpu_filters[] = {
{ /* Skip all processors under root node, should be there. */
NULL,
0,
NULL,
1,
1,
NULL,
NULL,
},
{ /* Create and scan other processor objects */
0,
2,
NULL,
}
};
static char *acpidev_processor_device_ids[] = {
};
static char *acpidev_cpu_uid_formats[] = {
"SCK%x-CPU%x",
};
static ACPI_HANDLE acpidev_cpu_map_hdl;
static uint32_t acpidev_cpu_map_count;
static struct acpidev_cpu_map_item *acpidev_cpu_map;
/* Count how many enabled CPUs are in the MADT table. */
static ACPI_STATUS
{
(*cntp)++;
}
break;
(*cntp)++;
}
break;
default:
break;
}
return (AE_OK);
}
/* Extract information from the enabled CPUs using the MADT table. */
static ACPI_STATUS
{
(*cntp)++;
}
break;
/* See comment at beginning about 255 limitation. */
"!acpidev: encountered CPU with X2APIC Id < 255.");
}
(*cntp)++;
}
break;
default:
break;
}
return (AE_OK);
}
static ACPI_STATUS
{
uint32_t i;
for (i = 0; i < acpidev_cpu_map_count; i++) {
return (AE_OK);
}
}
return (AE_NOT_FOUND);
}
/*
* Extract information for enabled CPUs from the buffer returned
* by the _MAT method.
*/
static ACPI_STATUS
{
struct acpidev_cpu_MAT_arg *rp;
} else {
}
return (AE_CTRL_TERMINATE);
"with X2APIC Id < 255 in _MAT.");
}
} else {
}
return (AE_CTRL_TERMINATE);
/* UNIMPLEMENTED */
break;
/* UNIMPLEMENTED */
break;
default:
/*
* According to the ACPI Spec, the buffer returned by _MAT
* for a processor object should only contain Local APIC,
* Local SAPIC, and local APIC NMI entries.
* x2APIC Specification extends it to support Processor
* x2APIC and x2APIC NMI Structure.
*/
break;
}
return (AE_OK);
}
/*
* Query ACPI processor ID by evaluating ACPI _MAT, _UID, and PROCESSOR
* objects.
*/
static ACPI_STATUS
{
int id;
struct acpidev_cpu_MAT_arg mat;
"!acpidev: object %s is not PROCESSOR or DEVICE.",
return (AE_BAD_PARAMETER);
}
/*
* First try to evaluate _MAT.
* According to the ACPI Spec3.0b, it's legal for ACPI PROCESSOR objects
* to have ACPI method objects.
*/
return (AE_OK);
}
/* Then evalute PROCESSOR object. */
ACPI_TYPE_PROCESSOR))) {
return (AE_OK);
} else {
"!acpidev: failed to evaluate ACPI object %s.",
}
}
/*
* Finally, try to evalute the _UID method.
* According to the ACPI Spec3.0b, it's legal for ACPI PROCESSOR objects
* to have ACPI method objects.
* The CPU _UID method should return Processor Id as an integer on x86.
*/
return (AE_OK);
}
return (AE_NOT_FOUND);
}
static ACPI_STATUS
{
*pxmidp = UINT32_MAX;
return (AE_OK);
}
if (acpidev_srat_tbl_ptr == NULL) {
return (AE_NOT_FOUND);
}
/* Search the static ACPI SRAT table for proximity domain id. */
off = sizeof (*acpidev_srat_tbl_ptr);
return (AE_OK);
}
break;
return (AE_OK);
}
break;
}
}
return (AE_NOT_FOUND);
}
static ACPI_STATUS
{
/* Parse and cache APIC info in MADT on the first probe at boot time. */
acpidev_cpu_map_hdl == NULL) {
/* Parse CPU relative information in the ACPI MADT table. */
/* Cache pointer to the ACPI SRAT table. */
(ACPI_TABLE_HEADER **)&acpidev_srat_tbl_ptr))) {
}
}
return (AE_OK);
}
static ACPI_STATUS
{
/* Free cached APIC info on the second probe at boot time. */
acpidev_cpu_map_hdl != NULL &&
}
/* replace psm_cpu_create_devinfo with local implementation. */
}
return (AE_OK);
}
static ACPI_STATUS
{
int flags;
ACPIDEV_ARRAY_PARAM(acpidev_processor_device_ids)) == 0)) {
return (AE_OK);
}
switch (infop->awi_op_type) {
case ACPIDEV_OP_BOOT_PROBE:
/*
* Mark device as offline. It will be changed to online state
* when the corresponding CPU starts up.
*/
}
break;
case ACPIDEV_OP_BOOT_REPROBE:
break;
case ACPIDEV_OP_HOTPLUG_PROBE:
}
break;
default:
break;
}
}
"!acpidev: failed to process processor object %s.",
} else {
}
return (rc);
}
static acpidev_filter_result_t
{
"!acpidev: failed to query processor id for %s.",
return (ACPIDEV_FILTER_SKIP);
"!acpidev: failed to query apic id for %s.",
return (ACPIDEV_FILTER_SKIP);
}
struct acpidev_cpu_MAT_arg mat;
"!acpidev: failed to walk apic resource for %s.",
return (ACPIDEV_FILTER_SKIP);
"!acpidev: CPU %s has been disabled.",
return (ACPIDEV_FILTER_SKIP);
}
/* Save processor id and APIC id in scratchpad memory. */
}
return (res);
}
static acpidev_filter_result_t
{
} else {
}
return (res);
}
static ACPI_STATUS
{
int count;
char unitaddr[64];
char **compatpp;
static char *compatible[] = {
"cpu"
};
/* Create "apic_id", "processor_id" and "proximity_id" properties. */
NDI_SUCCESS) {
"!acpidev: failed to set processor_id property for %s.",
return (AE_ERROR);
}
NDI_SUCCESS) {
"!acpidev: failed to set apic_id property for %s.",
return (AE_ERROR);
}
return (AE_ERROR);
}
}
/* Set "compatible" property for CPU dip */
/*
* skip first item for pseudo processor HID.
*/
count--;
} else {
return (AE_BAD_PARAMETER);
}
return (AE_ERROR);
}
/*
* Set device unit-address property.
* First try to generate meaningful unit address from _UID,
* then use Processor Id if that fails.
*/
}
return (AE_ERROR);
}
/*
* Build binding information for CPUs.
*/
return (AE_ERROR);
}
} else {
"!acpidev: unknown operation type %u in acpidev_cpu_init.",
infop->awi_op_type);
return (AE_BAD_PARAMETER);
}
return (AE_OK);
}
static void
{
int rc;
if (ACPI_SUCCESS(rc)) {
if (ACPI_FAILURE(rc)) {
"processor from ACPICA.");
}
}
}
/*
* Lookup the dip for a CPU if ACPI CPU autoconfig is enabled.
*/
static int
{
(apicid != UINT32_MAX &&
return (PSM_SUCCESS);
}
}
"!acpidev: failed to lookup dip for cpu %d(%p).",
}
return (PSM_FAILURE);
}
static int
{
return (PSM_SUCCESS);
}
if (psm_cpu_create_devinfo_old != NULL) {
} else {
return (PSM_FAILURE);
}
}
static int
{
return (PSM_SUCCESS);
}
if (psm_cpu_get_devinfo_old != NULL) {
} else {
return (PSM_FAILURE);
}
}