4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2009-2010, Intel Corporation.
23 * All rights reserved.
26 #include <sys/types.h>
27 #include <sys/atomic.h>
28 #include <sys/sunddi.h>
29 #include <sys/sunndi.h>
30 #include <sys/acpi/acpi.h>
31 #include <sys/acpica.h>
32 #include <sys/acpidev.h>
33 #include <sys/acpidev_impl.h>
35 static ACPI_STATUS
acpidev_scope_probe(acpidev_walk_info_t
*infop
);
36 static acpidev_filter_result_t
acpidev_scope_filter(acpidev_walk_info_t
*infop
,
37 char *devname
, int maxlen
);
38 static ACPI_STATUS
acpidev_scope_init(acpidev_walk_info_t
*infop
);
41 * Default class driver for ACPI scope objects.
42 * This class driver is used to handle predefined ACPI SCOPE objects
43 * under the ACPI root object, such as _PR_, _SB_ and _TZ_ etc.
44 * The default policy for ACPI SCOPE objects is SKIP.
46 acpidev_class_t acpidev_class_scope
= {
48 ACPIDEV_CLASS_REV1
, /* adc_version */
49 ACPIDEV_CLASS_ID_SCOPE
, /* adc_class_id */
50 "ACPI Scope", /* adc_class_name */
51 ACPIDEV_TYPE_SCOPE
, /* adc_dev_type */
52 NULL
, /* adc_private */
53 NULL
, /* adc_pre_probe */
54 NULL
, /* adc_post_probe */
55 acpidev_scope_probe
, /* adc_probe */
56 acpidev_scope_filter
, /* adc_filter */
57 acpidev_scope_init
, /* adc_init */
61 acpidev_class_list_t
*acpidev_class_list_scope
= NULL
;
64 * All SCOPE objects share a global pseudo unit address space across the system.
66 static uint32_t acpidev_scope_unitaddr
= 0;
68 /* Filter rule table for ACPI SCOPE objects. */
69 static acpidev_filter_rule_t acpidev_scope_filters
[] = {
70 { /* For safety, _SB_ is hardcoded as DEVICE by acpica */
73 ACPIDEV_FILTER_DEFAULT
,
74 &acpidev_class_list_device
,
77 ACPIDEV_OBJECT_NAME_SB
,
78 ACPIDEV_NODE_NAME_MODULE_SBD
,
80 { /* Handle _PR_ object. */
84 &acpidev_class_list_scope
,
87 ACPIDEV_OBJECT_NAME_PR
,
88 ACPIDEV_NODE_NAME_PROCESSOR
,
90 { /* Ignore all other scope objects. */
103 acpidev_scope_probe(acpidev_walk_info_t
*infop
)
105 ACPI_STATUS rc
= AE_OK
;
108 ASSERT(infop
!= NULL
);
109 ASSERT(infop
->awi_hdl
!= NULL
);
110 ASSERT(infop
->awi_info
!= NULL
);
111 if (infop
->awi_info
->Type
!= ACPI_TYPE_LOCAL_SCOPE
) {
115 flags
= ACPIDEV_PROCESS_FLAG_SCAN
;
116 switch (infop
->awi_op_type
) {
117 case ACPIDEV_OP_BOOT_PROBE
:
118 flags
|= ACPIDEV_PROCESS_FLAG_CREATE
;
121 case ACPIDEV_OP_BOOT_REPROBE
:
124 case ACPIDEV_OP_HOTPLUG_PROBE
:
125 flags
|= ACPIDEV_PROCESS_FLAG_SYNCSTATUS
|
126 ACPIDEV_PROCESS_FLAG_HOLDBRANCH
;
130 ACPIDEV_DEBUG(CE_WARN
, "!acpidev: unknown operation type %u "
131 "in acpidev_scope_probe().", infop
->awi_op_type
);
132 rc
= AE_BAD_PARAMETER
;
137 rc
= acpidev_process_object(infop
, flags
);
139 if (ACPI_FAILURE(rc
) && rc
!= AE_NOT_EXIST
&& rc
!= AE_ALREADY_EXISTS
) {
141 "!acpidev: failed to process scope object %s.",
150 static acpidev_filter_result_t
151 acpidev_scope_filter(acpidev_walk_info_t
*infop
, char *devname
, int maxlen
)
153 acpidev_filter_result_t res
;
155 ASSERT(infop
!= NULL
);
156 if (infop
->awi_op_type
== ACPIDEV_OP_BOOT_PROBE
||
157 infop
->awi_op_type
== ACPIDEV_OP_BOOT_REPROBE
||
158 infop
->awi_op_type
== ACPIDEV_OP_HOTPLUG_PROBE
) {
159 res
= acpidev_filter_device(infop
, infop
->awi_hdl
,
160 ACPIDEV_ARRAY_PARAM(acpidev_scope_filters
),
163 ACPIDEV_DEBUG(CE_WARN
, "!acpidev: unknown operation type %u "
164 "in acpidev_scope_filter().", infop
->awi_op_type
);
165 res
= ACPIDEV_FILTER_FAILED
;
172 acpidev_scope_init(acpidev_walk_info_t
*infop
)
175 char *compatible
[] = {
179 ACPIDEV_TYPE_VIRTNEX
,
182 ASSERT(infop
!= NULL
);
183 ASSERT(infop
->awi_hdl
!= NULL
);
184 ASSERT(infop
->awi_dip
!= NULL
);
185 if (ACPI_FAILURE(acpidev_set_compatible(infop
,
186 ACPIDEV_ARRAY_PARAM(compatible
)))) {
189 (void) snprintf(unitaddr
, sizeof (unitaddr
), "%u",
190 atomic_inc_32_nv(&acpidev_scope_unitaddr
) - 1);
191 if (ACPI_FAILURE(acpidev_set_unitaddr(infop
, NULL
, 0, unitaddr
))) {