Rev 1498 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
1 | /****************************************************************************** |
1 | /****************************************************************************** |
2 | * |
2 | * |
3 | * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init |
3 | * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init |
4 | * |
4 | * |
5 | *****************************************************************************/ |
5 | *****************************************************************************/ |
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
17 | * rights. You may have additional license terms from the party that provided |
17 | * rights. You may have additional license terms from the party that provided |
18 | * you this software, covering your right to use that party's intellectual |
18 | * you this software, covering your right to use that party's intellectual |
19 | * property rights. |
19 | * property rights. |
20 | * |
20 | * |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
22 | * copy of the source code appearing in this file ("Covered Code") an |
22 | * copy of the source code appearing in this file ("Covered Code") an |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
25 | * make derivatives, distribute, use and display any portion of the Covered |
25 | * make derivatives, distribute, use and display any portion of the Covered |
26 | * Code in any form, with the right to sublicense such rights; and |
26 | * Code in any form, with the right to sublicense such rights; and |
27 | * |
27 | * |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
29 | * license (with the right to sublicense), under only those claims of Intel |
29 | * license (with the right to sublicense), under only those claims of Intel |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
32 | * solely to the minimum extent necessary to exercise the above copyright |
32 | * solely to the minimum extent necessary to exercise the above copyright |
33 | * license, and in no event shall the patent license extend to any additions |
33 | * license, and in no event shall the patent license extend to any additions |
34 | * to or modifications of the Original Intel Code. No other license or right |
34 | * to or modifications of the Original Intel Code. No other license or right |
35 | * is granted directly or by implication, estoppel or otherwise; |
35 | * is granted directly or by implication, estoppel or otherwise; |
36 | * |
36 | * |
37 | * The above copyright and patent license is granted only if the following |
37 | * The above copyright and patent license is granted only if the following |
38 | * conditions are met: |
38 | * conditions are met: |
39 | * |
39 | * |
40 | * 3. Conditions |
40 | * 3. Conditions |
41 | * |
41 | * |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
43 | * Redistribution of source code of any substantial portion of the Covered |
43 | * Redistribution of source code of any substantial portion of the Covered |
44 | * Code or modification with rights to further distribute source must include |
44 | * Code or modification with rights to further distribute source must include |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
48 | * contain a file documenting the changes Licensee made to create that Covered |
48 | * contain a file documenting the changes Licensee made to create that Covered |
49 | * Code and the date of any change. Licensee must include in that file the |
49 | * Code and the date of any change. Licensee must include in that file the |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
51 | * must include a prominent statement that the modification is derived, |
51 | * must include a prominent statement that the modification is derived, |
52 | * directly or indirectly, from Original Intel Code. |
52 | * directly or indirectly, from Original Intel Code. |
53 | * |
53 | * |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
55 | * Redistribution of source code of any substantial portion of the Covered |
55 | * Redistribution of source code of any substantial portion of the Covered |
56 | * Code or modification without rights to further distribute source must |
56 | * Code or modification without rights to further distribute source must |
57 | * include the following Disclaimer and Export Compliance provision in the |
57 | * include the following Disclaimer and Export Compliance provision in the |
58 | * documentation and/or other materials provided with distribution. In |
58 | * documentation and/or other materials provided with distribution. In |
59 | * addition, Licensee may not authorize further sublicense of source of any |
59 | * addition, Licensee may not authorize further sublicense of source of any |
60 | * portion of the Covered Code, and must include terms to the effect that the |
60 | * portion of the Covered Code, and must include terms to the effect that the |
61 | * license from Licensee to its licensee is limited to the intellectual |
61 | * license from Licensee to its licensee is limited to the intellectual |
62 | * property embodied in the software Licensee provides to its licensee, and |
62 | * property embodied in the software Licensee provides to its licensee, and |
63 | * not to intellectual property embodied in modifications its licensee may |
63 | * not to intellectual property embodied in modifications its licensee may |
64 | * make. |
64 | * make. |
65 | * |
65 | * |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
67 | * substantial portion of the Covered Code or modification must reproduce the |
67 | * substantial portion of the Covered Code or modification must reproduce the |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
69 | * provision in the documentation and/or other materials provided with the |
69 | * provision in the documentation and/or other materials provided with the |
70 | * distribution. |
70 | * distribution. |
71 | * |
71 | * |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
73 | * Intel Code. |
73 | * Intel Code. |
74 | * |
74 | * |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
77 | * other dealings in products derived from or relating to the Covered Code |
77 | * other dealings in products derived from or relating to the Covered Code |
78 | * without prior written authorization from Intel. |
78 | * without prior written authorization from Intel. |
79 | * |
79 | * |
80 | * 4. Disclaimer and Export Compliance |
80 | * 4. Disclaimer and Export Compliance |
81 | * |
81 | * |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
88 | * PARTICULAR PURPOSE. |
88 | * PARTICULAR PURPOSE. |
89 | * |
89 | * |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
97 | * LIMITED REMEDY. |
97 | * LIMITED REMEDY. |
98 | * |
98 | * |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
100 | * software or system incorporating such software without first obtaining any |
100 | * software or system incorporating such software without first obtaining any |
101 | * required license or other approval from the U. S. Department of Commerce or |
101 | * required license or other approval from the U. S. Department of Commerce or |
102 | * any other agency or department of the United States Government. In the |
102 | * any other agency or department of the United States Government. In the |
103 | * event Licensee exports any such software from the United States or |
103 | * event Licensee exports any such software from the United States or |
104 | * re-exports any such software from a foreign destination, Licensee shall |
104 | * re-exports any such software from a foreign destination, Licensee shall |
105 | * ensure that the distribution and export/re-export of the software is in |
105 | * ensure that the distribution and export/re-export of the software is in |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
109 | * software, or service, directly or indirectly, to any country for which the |
109 | * software, or service, directly or indirectly, to any country for which the |
110 | * United States government or any agency thereof requires an export license, |
110 | * United States government or any agency thereof requires an export license, |
111 | * other governmental approval, or letter of assurance, without first obtaining |
111 | * other governmental approval, or letter of assurance, without first obtaining |
112 | * such license, approval or letter. |
112 | * such license, approval or letter. |
113 | * |
113 | * |
114 | *****************************************************************************/ |
114 | *****************************************************************************/ |
115 | 115 | ||
116 | 116 | ||
117 | #define __EVRGNINI_C__ |
117 | #define __EVRGNINI_C__ |
118 | 118 | ||
119 | #include "acpi.h" |
119 | #include "acpi.h" |
120 | #include "accommon.h" |
120 | #include "accommon.h" |
121 | #include "acevents.h" |
121 | #include "acevents.h" |
122 | #include "acnamesp.h" |
122 | #include "acnamesp.h" |
123 | 123 | ||
124 | #define _COMPONENT ACPI_EVENTS |
124 | #define _COMPONENT ACPI_EVENTS |
125 | ACPI_MODULE_NAME ("evrgnini") |
125 | ACPI_MODULE_NAME ("evrgnini") |
126 | 126 | ||
127 | /* Local prototypes */ |
127 | /* Local prototypes */ |
128 | 128 | ||
129 | static BOOLEAN |
129 | static BOOLEAN |
130 | AcpiEvIsPciRootBridge ( |
130 | AcpiEvIsPciRootBridge ( |
131 | ACPI_NAMESPACE_NODE *Node); |
131 | ACPI_NAMESPACE_NODE *Node); |
132 | 132 | ||
133 | 133 | ||
134 | /******************************************************************************* |
134 | /******************************************************************************* |
135 | * |
135 | * |
136 | * FUNCTION: AcpiEvSystemMemoryRegionSetup |
136 | * FUNCTION: AcpiEvSystemMemoryRegionSetup |
137 | * |
137 | * |
138 | * PARAMETERS: Handle - Region we are interested in |
138 | * PARAMETERS: Handle - Region we are interested in |
139 | * Function - Start or stop |
139 | * Function - Start or stop |
140 | * HandlerContext - Address space handler context |
140 | * HandlerContext - Address space handler context |
141 | * RegionContext - Region specific context |
141 | * RegionContext - Region specific context |
142 | * |
142 | * |
143 | * RETURN: Status |
143 | * RETURN: Status |
144 | * |
144 | * |
145 | * DESCRIPTION: Setup a SystemMemory operation region |
145 | * DESCRIPTION: Setup a SystemMemory operation region |
146 | * |
146 | * |
147 | ******************************************************************************/ |
147 | ******************************************************************************/ |
148 | 148 | ||
149 | ACPI_STATUS |
149 | ACPI_STATUS |
150 | AcpiEvSystemMemoryRegionSetup ( |
150 | AcpiEvSystemMemoryRegionSetup ( |
151 | ACPI_HANDLE Handle, |
151 | ACPI_HANDLE Handle, |
152 | UINT32 Function, |
152 | UINT32 Function, |
153 | void *HandlerContext, |
153 | void *HandlerContext, |
154 | void **RegionContext) |
154 | void **RegionContext) |
155 | { |
155 | { |
156 | ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle; |
156 | ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle; |
157 | ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; |
157 | ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; |
158 | 158 | ||
159 | 159 | ||
160 | ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); |
160 | ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); |
161 | 161 | ||
162 | 162 | ||
163 | if (Function == ACPI_REGION_DEACTIVATE) |
163 | if (Function == ACPI_REGION_DEACTIVATE) |
164 | { |
164 | { |
165 | if (*RegionContext) |
165 | if (*RegionContext) |
166 | { |
166 | { |
167 | LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; |
167 | LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; |
168 | 168 | ||
169 | /* Delete a cached mapping if present */ |
169 | /* Delete a cached mapping if present */ |
170 | 170 | ||
171 | if (LocalRegionContext->MappedLength) |
171 | if (LocalRegionContext->MappedLength) |
172 | { |
172 | { |
173 | AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, |
173 | AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, |
174 | LocalRegionContext->MappedLength); |
174 | LocalRegionContext->MappedLength); |
175 | } |
175 | } |
176 | ACPI_FREE (LocalRegionContext); |
176 | ACPI_FREE (LocalRegionContext); |
177 | *RegionContext = NULL; |
177 | *RegionContext = NULL; |
178 | } |
178 | } |
179 | return_ACPI_STATUS (AE_OK); |
179 | return_ACPI_STATUS (AE_OK); |
180 | } |
180 | } |
181 | 181 | ||
182 | /* Create a new context */ |
182 | /* Create a new context */ |
183 | 183 | ||
184 | LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); |
184 | LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); |
185 | if (!(LocalRegionContext)) |
185 | if (!(LocalRegionContext)) |
186 | { |
186 | { |
187 | return_ACPI_STATUS (AE_NO_MEMORY); |
187 | return_ACPI_STATUS (AE_NO_MEMORY); |
188 | } |
188 | } |
189 | 189 | ||
190 | /* Save the region length and address for use in the handler */ |
190 | /* Save the region length and address for use in the handler */ |
191 | 191 | ||
192 | LocalRegionContext->Length = RegionDesc->Region.Length; |
192 | LocalRegionContext->Length = RegionDesc->Region.Length; |
193 | LocalRegionContext->Address = RegionDesc->Region.Address; |
193 | LocalRegionContext->Address = RegionDesc->Region.Address; |
194 | 194 | ||
195 | *RegionContext = LocalRegionContext; |
195 | *RegionContext = LocalRegionContext; |
196 | return_ACPI_STATUS (AE_OK); |
196 | return_ACPI_STATUS (AE_OK); |
197 | } |
197 | } |
198 | 198 | ||
199 | 199 | ||
200 | /******************************************************************************* |
200 | /******************************************************************************* |
201 | * |
201 | * |
202 | * FUNCTION: AcpiEvIoSpaceRegionSetup |
202 | * FUNCTION: AcpiEvIoSpaceRegionSetup |
203 | * |
203 | * |
204 | * PARAMETERS: Handle - Region we are interested in |
204 | * PARAMETERS: Handle - Region we are interested in |
205 | * Function - Start or stop |
205 | * Function - Start or stop |
206 | * HandlerContext - Address space handler context |
206 | * HandlerContext - Address space handler context |
207 | * RegionContext - Region specific context |
207 | * RegionContext - Region specific context |
208 | * |
208 | * |
209 | * RETURN: Status |
209 | * RETURN: Status |
210 | * |
210 | * |
211 | * DESCRIPTION: Setup a IO operation region |
211 | * DESCRIPTION: Setup a IO operation region |
212 | * |
212 | * |
213 | ******************************************************************************/ |
213 | ******************************************************************************/ |
214 | 214 | ||
215 | ACPI_STATUS |
215 | ACPI_STATUS |
216 | AcpiEvIoSpaceRegionSetup ( |
216 | AcpiEvIoSpaceRegionSetup ( |
217 | ACPI_HANDLE Handle, |
217 | ACPI_HANDLE Handle, |
218 | UINT32 Function, |
218 | UINT32 Function, |
219 | void *HandlerContext, |
219 | void *HandlerContext, |
220 | void **RegionContext) |
220 | void **RegionContext) |
221 | { |
221 | { |
222 | ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); |
222 | ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); |
223 | 223 | ||
224 | 224 | ||
225 | if (Function == ACPI_REGION_DEACTIVATE) |
225 | if (Function == ACPI_REGION_DEACTIVATE) |
226 | { |
226 | { |
227 | *RegionContext = NULL; |
227 | *RegionContext = NULL; |
228 | } |
228 | } |
229 | else |
229 | else |
230 | { |
230 | { |
231 | *RegionContext = HandlerContext; |
231 | *RegionContext = HandlerContext; |
232 | } |
232 | } |
233 | 233 | ||
234 | return_ACPI_STATUS (AE_OK); |
234 | return_ACPI_STATUS (AE_OK); |
235 | } |
235 | } |
236 | 236 | ||
237 | 237 | ||
238 | /******************************************************************************* |
238 | /******************************************************************************* |
239 | * |
239 | * |
240 | * FUNCTION: AcpiEvPciConfigRegionSetup |
240 | * FUNCTION: AcpiEvPciConfigRegionSetup |
241 | * |
241 | * |
242 | * PARAMETERS: Handle - Region we are interested in |
242 | * PARAMETERS: Handle - Region we are interested in |
243 | * Function - Start or stop |
243 | * Function - Start or stop |
244 | * HandlerContext - Address space handler context |
244 | * HandlerContext - Address space handler context |
245 | * RegionContext - Region specific context |
245 | * RegionContext - Region specific context |
246 | * |
246 | * |
247 | * RETURN: Status |
247 | * RETURN: Status |
248 | * |
248 | * |
249 | * DESCRIPTION: Setup a PCI_Config operation region |
249 | * DESCRIPTION: Setup a PCI_Config operation region |
250 | * |
250 | * |
251 | * MUTEX: Assumes namespace is not locked |
251 | * MUTEX: Assumes namespace is not locked |
252 | * |
252 | * |
253 | ******************************************************************************/ |
253 | ******************************************************************************/ |
254 | 254 | ||
255 | ACPI_STATUS |
255 | ACPI_STATUS |
256 | AcpiEvPciConfigRegionSetup ( |
256 | AcpiEvPciConfigRegionSetup ( |
257 | ACPI_HANDLE Handle, |
257 | ACPI_HANDLE Handle, |
258 | UINT32 Function, |
258 | UINT32 Function, |
259 | void *HandlerContext, |
259 | void *HandlerContext, |
260 | void **RegionContext) |
260 | void **RegionContext) |
261 | { |
261 | { |
262 | ACPI_STATUS Status = AE_OK; |
262 | ACPI_STATUS Status = AE_OK; |
263 | UINT64 PciValue; |
263 | UINT64 PciValue; |
264 | ACPI_PCI_ID *PciId = *RegionContext; |
264 | ACPI_PCI_ID *PciId = *RegionContext; |
265 | ACPI_OPERAND_OBJECT *HandlerObj; |
265 | ACPI_OPERAND_OBJECT *HandlerObj; |
266 | ACPI_NAMESPACE_NODE *ParentNode; |
266 | ACPI_NAMESPACE_NODE *ParentNode; |
267 | ACPI_NAMESPACE_NODE *PciRootNode; |
267 | ACPI_NAMESPACE_NODE *PciRootNode; |
268 | ACPI_NAMESPACE_NODE *PciDeviceNode; |
268 | ACPI_NAMESPACE_NODE *PciDeviceNode; |
269 | ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; |
269 | ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; |
270 | 270 | ||
271 | 271 | ||
272 | ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); |
272 | ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); |
273 | 273 | ||
274 | 274 | ||
275 | HandlerObj = RegionObj->Region.Handler; |
275 | HandlerObj = RegionObj->Region.Handler; |
276 | if (!HandlerObj) |
276 | if (!HandlerObj) |
277 | { |
277 | { |
278 | /* |
278 | /* |
279 | * No installed handler. This shouldn't happen because the dispatch |
279 | * No installed handler. This shouldn't happen because the dispatch |
280 | * routine checks before we get here, but we check again just in case. |
280 | * routine checks before we get here, but we check again just in case. |
281 | */ |
281 | */ |
282 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, |
282 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, |
283 | "Attempting to init a region %p, with no handler\n", RegionObj)); |
283 | "Attempting to init a region %p, with no handler\n", RegionObj)); |
284 | return_ACPI_STATUS (AE_NOT_EXIST); |
284 | return_ACPI_STATUS (AE_NOT_EXIST); |
285 | } |
285 | } |
286 | 286 | ||
287 | *RegionContext = NULL; |
287 | *RegionContext = NULL; |
288 | if (Function == ACPI_REGION_DEACTIVATE) |
288 | if (Function == ACPI_REGION_DEACTIVATE) |
289 | { |
289 | { |
290 | if (PciId) |
290 | if (PciId) |
291 | { |
291 | { |
292 | ACPI_FREE (PciId); |
292 | ACPI_FREE (PciId); |
293 | } |
293 | } |
294 | return_ACPI_STATUS (Status); |
294 | return_ACPI_STATUS (Status); |
295 | } |
295 | } |
296 | 296 | ||
297 | ParentNode = RegionObj->Region.Node->Parent; |
297 | ParentNode = RegionObj->Region.Node->Parent; |
298 | 298 | ||
299 | /* |
299 | /* |
300 | * Get the _SEG and _BBN values from the device upon which the handler |
300 | * Get the _SEG and _BBN values from the device upon which the handler |
301 | * is installed. |
301 | * is installed. |
302 | * |
302 | * |
303 | * We need to get the _SEG and _BBN objects relative to the PCI BUS device. |
303 | * We need to get the _SEG and _BBN objects relative to the PCI BUS device. |
304 | * This is the device the handler has been registered to handle. |
304 | * This is the device the handler has been registered to handle. |
305 | */ |
305 | */ |
306 | 306 | ||
307 | /* |
307 | /* |
308 | * If the AddressSpace.Node is still pointing to the root, we need |
308 | * If the AddressSpace.Node is still pointing to the root, we need |
309 | * to scan upward for a PCI Root bridge and re-associate the OpRegion |
309 | * to scan upward for a PCI Root bridge and re-associate the OpRegion |
310 | * handlers with that device. |
310 | * handlers with that device. |
311 | */ |
311 | */ |
312 | if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode) |
312 | if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode) |
313 | { |
313 | { |
314 | /* Start search from the parent object */ |
314 | /* Start search from the parent object */ |
315 | 315 | ||
316 | PciRootNode = ParentNode; |
316 | PciRootNode = ParentNode; |
317 | while (PciRootNode != AcpiGbl_RootNode) |
317 | while (PciRootNode != AcpiGbl_RootNode) |
318 | { |
318 | { |
319 | /* Get the _HID/_CID in order to detect a RootBridge */ |
319 | /* Get the _HID/_CID in order to detect a RootBridge */ |
320 | 320 | ||
321 | if (AcpiEvIsPciRootBridge (PciRootNode)) |
321 | if (AcpiEvIsPciRootBridge (PciRootNode)) |
322 | { |
322 | { |
323 | /* Install a handler for this PCI root bridge */ |
323 | /* Install a handler for this PCI root bridge */ |
324 | 324 | ||
325 | Status = AcpiInstallAddressSpaceHandler ( |
325 | Status = AcpiInstallAddressSpaceHandler ( |
326 | (ACPI_HANDLE) PciRootNode, |
326 | (ACPI_HANDLE) PciRootNode, |
327 | ACPI_ADR_SPACE_PCI_CONFIG, |
327 | ACPI_ADR_SPACE_PCI_CONFIG, |
328 | ACPI_DEFAULT_HANDLER, NULL, NULL); |
328 | ACPI_DEFAULT_HANDLER, NULL, NULL); |
329 | if (ACPI_FAILURE (Status)) |
329 | if (ACPI_FAILURE (Status)) |
330 | { |
330 | { |
331 | if (Status == AE_SAME_HANDLER) |
331 | if (Status == AE_SAME_HANDLER) |
332 | { |
332 | { |
333 | /* |
333 | /* |
334 | * It is OK if the handler is already installed on the |
334 | * It is OK if the handler is already installed on the |
335 | * root bridge. Still need to return a context object |
335 | * root bridge. Still need to return a context object |
336 | * for the new PCI_Config operation region, however. |
336 | * for the new PCI_Config operation region, however. |
337 | */ |
337 | */ |
338 | Status = AE_OK; |
338 | Status = AE_OK; |
339 | } |
339 | } |
340 | else |
340 | else |
341 | { |
341 | { |
342 | ACPI_EXCEPTION ((AE_INFO, Status, |
342 | ACPI_EXCEPTION ((AE_INFO, Status, |
343 | "Could not install PciConfig handler " |
343 | "Could not install PciConfig handler " |
344 | "for Root Bridge %4.4s", |
344 | "for Root Bridge %4.4s", |
345 | AcpiUtGetNodeName (PciRootNode))); |
345 | AcpiUtGetNodeName (PciRootNode))); |
346 | } |
346 | } |
347 | } |
347 | } |
348 | break; |
348 | break; |
349 | } |
349 | } |
350 | 350 | ||
351 | PciRootNode = PciRootNode->Parent; |
351 | PciRootNode = PciRootNode->Parent; |
352 | } |
352 | } |
353 | 353 | ||
354 | /* PCI root bridge not found, use namespace root node */ |
354 | /* PCI root bridge not found, use namespace root node */ |
355 | } |
355 | } |
356 | else |
356 | else |
357 | { |
357 | { |
358 | PciRootNode = HandlerObj->AddressSpace.Node; |
358 | PciRootNode = HandlerObj->AddressSpace.Node; |
359 | } |
359 | } |
360 | 360 | ||
361 | /* |
361 | /* |
362 | * If this region is now initialized, we are done. |
362 | * If this region is now initialized, we are done. |
363 | * (InstallAddressSpaceHandler could have initialized it) |
363 | * (InstallAddressSpaceHandler could have initialized it) |
364 | */ |
364 | */ |
365 | if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) |
365 | if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) |
366 | { |
366 | { |
367 | return_ACPI_STATUS (AE_OK); |
367 | return_ACPI_STATUS (AE_OK); |
368 | } |
368 | } |
369 | 369 | ||
370 | /* Region is still not initialized. Create a new context */ |
370 | /* Region is still not initialized. Create a new context */ |
371 | 371 | ||
372 | PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); |
372 | PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); |
373 | if (!PciId) |
373 | if (!PciId) |
374 | { |
374 | { |
375 | return_ACPI_STATUS (AE_NO_MEMORY); |
375 | return_ACPI_STATUS (AE_NO_MEMORY); |
376 | } |
376 | } |
377 | 377 | ||
378 | /* |
378 | /* |
379 | * For PCI_Config space access, we need the segment, bus, device and |
379 | * For PCI_Config space access, we need the segment, bus, device and |
380 | * function numbers. Acquire them here. |
380 | * function numbers. Acquire them here. |
381 | * |
381 | * |
382 | * Find the parent device object. (This allows the operation region to be |
382 | * Find the parent device object. (This allows the operation region to be |
383 | * within a subscope under the device, such as a control method.) |
383 | * within a subscope under the device, such as a control method.) |
384 | */ |
384 | */ |
385 | PciDeviceNode = RegionObj->Region.Node; |
385 | PciDeviceNode = RegionObj->Region.Node; |
386 | while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) |
386 | while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) |
387 | { |
387 | { |
388 | PciDeviceNode = PciDeviceNode->Parent; |
388 | PciDeviceNode = PciDeviceNode->Parent; |
389 | } |
389 | } |
390 | 390 | ||
391 | if (!PciDeviceNode) |
391 | if (!PciDeviceNode) |
392 | { |
392 | { |
393 | ACPI_FREE (PciId); |
393 | ACPI_FREE (PciId); |
394 | return_ACPI_STATUS (AE_AML_OPERAND_TYPE); |
394 | return_ACPI_STATUS (AE_AML_OPERAND_TYPE); |
395 | } |
395 | } |
396 | 396 | ||
397 | /* |
397 | /* |
398 | * Get the PCI device and function numbers from the _ADR object contained |
398 | * Get the PCI device and function numbers from the _ADR object |
399 | * in the parent's scope. |
399 | * contained in the parent's scope. |
400 | */ |
400 | */ |
401 | Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, |
401 | Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, |
402 | PciDeviceNode, &PciValue); |
402 | PciDeviceNode, &PciValue); |
403 | 403 | ||
404 | /* |
404 | /* |
405 | * The default is zero, and since the allocation above zeroed the data, |
405 | * The default is zero, and since the allocation above zeroed the data, |
406 | * just do nothing on failure. |
406 | * just do nothing on failure. |
407 | */ |
407 | */ |
408 | if (ACPI_SUCCESS (Status)) |
408 | if (ACPI_SUCCESS (Status)) |
409 | { |
409 | { |
410 | PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue)); |
410 | PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue)); |
411 | PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue)); |
411 | PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue)); |
412 | } |
412 | } |
413 | 413 | ||
414 | /* The PCI segment number comes from the _SEG method */ |
414 | /* The PCI segment number comes from the _SEG method */ |
415 | 415 | ||
416 | Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, |
416 | Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, |
417 | PciRootNode, &PciValue); |
417 | PciRootNode, &PciValue); |
418 | if (ACPI_SUCCESS (Status)) |
418 | if (ACPI_SUCCESS (Status)) |
419 | { |
419 | { |
420 | PciId->Segment = ACPI_LOWORD (PciValue); |
420 | PciId->Segment = ACPI_LOWORD (PciValue); |
421 | } |
421 | } |
422 | 422 | ||
423 | /* The PCI bus number comes from the _BBN method */ |
423 | /* The PCI bus number comes from the _BBN method */ |
424 | 424 | ||
425 | Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, |
425 | Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, |
426 | PciRootNode, &PciValue); |
426 | PciRootNode, &PciValue); |
427 | if (ACPI_SUCCESS (Status)) |
427 | if (ACPI_SUCCESS (Status)) |
428 | { |
428 | { |
429 | PciId->Bus = ACPI_LOWORD (PciValue); |
429 | PciId->Bus = ACPI_LOWORD (PciValue); |
430 | } |
430 | } |
431 | 431 | ||
432 | /* Complete this device's PciId */ |
432 | /* Complete/update the PCI ID for this device */ |
- | 433 | ||
- | 434 | Status = AcpiHwDerivePciId (PciId, PciRootNode, RegionObj->Region.Node); |
|
- | 435 | if (ACPI_FAILURE (Status)) |
|
- | 436 | { |
|
- | 437 | ACPI_FREE (PciId); |
|
433 | 438 | return_ACPI_STATUS (Status); |
|
434 | AcpiOsDerivePciId (PciRootNode, RegionObj->Region.Node, &PciId); |
439 | } |
435 | 440 | ||
436 | *RegionContext = PciId; |
441 | *RegionContext = PciId; |
437 | return_ACPI_STATUS (AE_OK); |
442 | return_ACPI_STATUS (AE_OK); |
438 | } |
443 | } |
439 | 444 | ||
440 | 445 | ||
441 | /******************************************************************************* |
446 | /******************************************************************************* |
442 | * |
447 | * |
443 | * FUNCTION: AcpiEvIsPciRootBridge |
448 | * FUNCTION: AcpiEvIsPciRootBridge |
444 | * |
449 | * |
445 | * PARAMETERS: Node - Device node being examined |
450 | * PARAMETERS: Node - Device node being examined |
446 | * |
451 | * |
447 | * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge |
452 | * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge |
448 | * |
453 | * |
449 | * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by |
454 | * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by |
450 | * examining the _HID and _CID for the device. |
455 | * examining the _HID and _CID for the device. |
451 | * |
456 | * |
452 | ******************************************************************************/ |
457 | ******************************************************************************/ |
453 | 458 | ||
454 | static BOOLEAN |
459 | static BOOLEAN |
455 | AcpiEvIsPciRootBridge ( |
460 | AcpiEvIsPciRootBridge ( |
456 | ACPI_NAMESPACE_NODE *Node) |
461 | ACPI_NAMESPACE_NODE *Node) |
457 | { |
462 | { |
458 | ACPI_STATUS Status; |
463 | ACPI_STATUS Status; |
459 | ACPI_DEVICE_ID *Hid; |
464 | ACPI_DEVICE_ID *Hid; |
460 | ACPI_DEVICE_ID_LIST *Cid; |
465 | ACPI_DEVICE_ID_LIST *Cid; |
461 | UINT32 i; |
466 | UINT32 i; |
462 | BOOLEAN Match; |
467 | BOOLEAN Match; |
463 | 468 | ||
464 | 469 | ||
465 | /* Get the _HID and check for a PCI Root Bridge */ |
470 | /* Get the _HID and check for a PCI Root Bridge */ |
466 | 471 | ||
467 | Status = AcpiUtExecute_HID (Node, &Hid); |
472 | Status = AcpiUtExecute_HID (Node, &Hid); |
468 | if (ACPI_FAILURE (Status)) |
473 | if (ACPI_FAILURE (Status)) |
469 | { |
474 | { |
470 | return (FALSE); |
475 | return (FALSE); |
471 | } |
476 | } |
472 | 477 | ||
473 | Match = AcpiUtIsPciRootBridge (Hid->String); |
478 | Match = AcpiUtIsPciRootBridge (Hid->String); |
474 | ACPI_FREE (Hid); |
479 | ACPI_FREE (Hid); |
475 | 480 | ||
476 | if (Match) |
481 | if (Match) |
477 | { |
482 | { |
478 | return (TRUE); |
483 | return (TRUE); |
479 | } |
484 | } |
480 | 485 | ||
481 | /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ |
486 | /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ |
482 | 487 | ||
483 | Status = AcpiUtExecute_CID (Node, &Cid); |
488 | Status = AcpiUtExecute_CID (Node, &Cid); |
484 | if (ACPI_FAILURE (Status)) |
489 | if (ACPI_FAILURE (Status)) |
485 | { |
490 | { |
486 | return (FALSE); |
491 | return (FALSE); |
487 | } |
492 | } |
488 | 493 | ||
489 | /* Check all _CIDs in the returned list */ |
494 | /* Check all _CIDs in the returned list */ |
490 | 495 | ||
491 | for (i = 0; i < Cid->Count; i++) |
496 | for (i = 0; i < Cid->Count; i++) |
492 | { |
497 | { |
493 | if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) |
498 | if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) |
494 | { |
499 | { |
495 | ACPI_FREE (Cid); |
500 | ACPI_FREE (Cid); |
496 | return (TRUE); |
501 | return (TRUE); |
497 | } |
502 | } |
498 | } |
503 | } |
499 | 504 | ||
500 | ACPI_FREE (Cid); |
505 | ACPI_FREE (Cid); |
501 | return (FALSE); |
506 | return (FALSE); |
502 | } |
507 | } |
503 | 508 | ||
504 | 509 | ||
505 | /******************************************************************************* |
510 | /******************************************************************************* |
506 | * |
511 | * |
507 | * FUNCTION: AcpiEvPciBarRegionSetup |
512 | * FUNCTION: AcpiEvPciBarRegionSetup |
508 | * |
513 | * |
509 | * PARAMETERS: Handle - Region we are interested in |
514 | * PARAMETERS: Handle - Region we are interested in |
510 | * Function - Start or stop |
515 | * Function - Start or stop |
511 | * HandlerContext - Address space handler context |
516 | * HandlerContext - Address space handler context |
512 | * RegionContext - Region specific context |
517 | * RegionContext - Region specific context |
513 | * |
518 | * |
514 | * RETURN: Status |
519 | * RETURN: Status |
515 | * |
520 | * |
516 | * DESCRIPTION: Setup a PciBAR operation region |
521 | * DESCRIPTION: Setup a PciBAR operation region |
517 | * |
522 | * |
518 | * MUTEX: Assumes namespace is not locked |
523 | * MUTEX: Assumes namespace is not locked |
519 | * |
524 | * |
520 | ******************************************************************************/ |
525 | ******************************************************************************/ |
521 | 526 | ||
522 | ACPI_STATUS |
527 | ACPI_STATUS |
523 | AcpiEvPciBarRegionSetup ( |
528 | AcpiEvPciBarRegionSetup ( |
524 | ACPI_HANDLE Handle, |
529 | ACPI_HANDLE Handle, |
525 | UINT32 Function, |
530 | UINT32 Function, |
526 | void *HandlerContext, |
531 | void *HandlerContext, |
527 | void **RegionContext) |
532 | void **RegionContext) |
528 | { |
533 | { |
529 | ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); |
534 | ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); |
530 | 535 | ||
531 | 536 | ||
532 | return_ACPI_STATUS (AE_OK); |
537 | return_ACPI_STATUS (AE_OK); |
533 | } |
538 | } |
534 | 539 | ||
535 | 540 | ||
536 | /******************************************************************************* |
541 | /******************************************************************************* |
537 | * |
542 | * |
538 | * FUNCTION: AcpiEvCmosRegionSetup |
543 | * FUNCTION: AcpiEvCmosRegionSetup |
539 | * |
544 | * |
540 | * PARAMETERS: Handle - Region we are interested in |
545 | * PARAMETERS: Handle - Region we are interested in |
541 | * Function - Start or stop |
546 | * Function - Start or stop |
542 | * HandlerContext - Address space handler context |
547 | * HandlerContext - Address space handler context |
543 | * RegionContext - Region specific context |
548 | * RegionContext - Region specific context |
544 | * |
549 | * |
545 | * RETURN: Status |
550 | * RETURN: Status |
546 | * |
551 | * |
547 | * DESCRIPTION: Setup a CMOS operation region |
552 | * DESCRIPTION: Setup a CMOS operation region |
548 | * |
553 | * |
549 | * MUTEX: Assumes namespace is not locked |
554 | * MUTEX: Assumes namespace is not locked |
550 | * |
555 | * |
551 | ******************************************************************************/ |
556 | ******************************************************************************/ |
552 | 557 | ||
553 | ACPI_STATUS |
558 | ACPI_STATUS |
554 | AcpiEvCmosRegionSetup ( |
559 | AcpiEvCmosRegionSetup ( |
555 | ACPI_HANDLE Handle, |
560 | ACPI_HANDLE Handle, |
556 | UINT32 Function, |
561 | UINT32 Function, |
557 | void *HandlerContext, |
562 | void *HandlerContext, |
558 | void **RegionContext) |
563 | void **RegionContext) |
559 | { |
564 | { |
560 | ACPI_FUNCTION_TRACE (EvCmosRegionSetup); |
565 | ACPI_FUNCTION_TRACE (EvCmosRegionSetup); |
561 | 566 | ||
562 | 567 | ||
563 | return_ACPI_STATUS (AE_OK); |
568 | return_ACPI_STATUS (AE_OK); |
564 | } |
569 | } |
565 | 570 | ||
566 | 571 | ||
567 | /******************************************************************************* |
572 | /******************************************************************************* |
568 | * |
573 | * |
569 | * FUNCTION: AcpiEvDefaultRegionSetup |
574 | * FUNCTION: AcpiEvDefaultRegionSetup |
570 | * |
575 | * |
571 | * PARAMETERS: Handle - Region we are interested in |
576 | * PARAMETERS: Handle - Region we are interested in |
572 | * Function - Start or stop |
577 | * Function - Start or stop |
573 | * HandlerContext - Address space handler context |
578 | * HandlerContext - Address space handler context |
574 | * RegionContext - Region specific context |
579 | * RegionContext - Region specific context |
575 | * |
580 | * |
576 | * RETURN: Status |
581 | * RETURN: Status |
577 | * |
582 | * |
578 | * DESCRIPTION: Default region initialization |
583 | * DESCRIPTION: Default region initialization |
579 | * |
584 | * |
580 | ******************************************************************************/ |
585 | ******************************************************************************/ |
581 | 586 | ||
582 | ACPI_STATUS |
587 | ACPI_STATUS |
583 | AcpiEvDefaultRegionSetup ( |
588 | AcpiEvDefaultRegionSetup ( |
584 | ACPI_HANDLE Handle, |
589 | ACPI_HANDLE Handle, |
585 | UINT32 Function, |
590 | UINT32 Function, |
586 | void *HandlerContext, |
591 | void *HandlerContext, |
587 | void **RegionContext) |
592 | void **RegionContext) |
588 | { |
593 | { |
589 | ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); |
594 | ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); |
590 | 595 | ||
591 | 596 | ||
592 | if (Function == ACPI_REGION_DEACTIVATE) |
597 | if (Function == ACPI_REGION_DEACTIVATE) |
593 | { |
598 | { |
594 | *RegionContext = NULL; |
599 | *RegionContext = NULL; |
595 | } |
600 | } |
596 | else |
601 | else |
597 | { |
602 | { |
598 | *RegionContext = HandlerContext; |
603 | *RegionContext = HandlerContext; |
599 | } |
604 | } |
600 | 605 | ||
601 | return_ACPI_STATUS (AE_OK); |
606 | return_ACPI_STATUS (AE_OK); |
602 | } |
607 | } |
603 | 608 | ||
604 | 609 | ||
605 | /******************************************************************************* |
610 | /******************************************************************************* |
606 | * |
611 | * |
607 | * FUNCTION: AcpiEvInitializeRegion |
612 | * FUNCTION: AcpiEvInitializeRegion |
608 | * |
613 | * |
609 | * PARAMETERS: RegionObj - Region we are initializing |
614 | * PARAMETERS: RegionObj - Region we are initializing |
610 | * AcpiNsLocked - Is namespace locked? |
615 | * AcpiNsLocked - Is namespace locked? |
611 | * |
616 | * |
612 | * RETURN: Status |
617 | * RETURN: Status |
613 | * |
618 | * |
614 | * DESCRIPTION: Initializes the region, finds any _REG methods and saves them |
619 | * DESCRIPTION: Initializes the region, finds any _REG methods and saves them |
615 | * for execution at a later time |
620 | * for execution at a later time |
616 | * |
621 | * |
617 | * Get the appropriate address space handler for a newly |
622 | * Get the appropriate address space handler for a newly |
618 | * created region. |
623 | * created region. |
619 | * |
624 | * |
620 | * This also performs address space specific initialization. For |
625 | * This also performs address space specific initialization. For |
621 | * example, PCI regions must have an _ADR object that contains |
626 | * example, PCI regions must have an _ADR object that contains |
622 | * a PCI address in the scope of the definition. This address is |
627 | * a PCI address in the scope of the definition. This address is |
623 | * required to perform an access to PCI config space. |
628 | * required to perform an access to PCI config space. |
624 | * |
629 | * |
625 | * MUTEX: Interpreter should be unlocked, because we may run the _REG |
630 | * MUTEX: Interpreter should be unlocked, because we may run the _REG |
626 | * method for this region. |
631 | * method for this region. |
627 | * |
632 | * |
628 | ******************************************************************************/ |
633 | ******************************************************************************/ |
629 | 634 | ||
630 | ACPI_STATUS |
635 | ACPI_STATUS |
631 | AcpiEvInitializeRegion ( |
636 | AcpiEvInitializeRegion ( |
632 | ACPI_OPERAND_OBJECT *RegionObj, |
637 | ACPI_OPERAND_OBJECT *RegionObj, |
633 | BOOLEAN AcpiNsLocked) |
638 | BOOLEAN AcpiNsLocked) |
634 | { |
639 | { |
635 | ACPI_OPERAND_OBJECT *HandlerObj; |
640 | ACPI_OPERAND_OBJECT *HandlerObj; |
636 | ACPI_OPERAND_OBJECT *ObjDesc; |
641 | ACPI_OPERAND_OBJECT *ObjDesc; |
637 | ACPI_ADR_SPACE_TYPE SpaceId; |
642 | ACPI_ADR_SPACE_TYPE SpaceId; |
638 | ACPI_NAMESPACE_NODE *Node; |
643 | ACPI_NAMESPACE_NODE *Node; |
639 | ACPI_STATUS Status; |
644 | ACPI_STATUS Status; |
640 | ACPI_NAMESPACE_NODE *MethodNode; |
645 | ACPI_NAMESPACE_NODE *MethodNode; |
641 | ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; |
646 | ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; |
642 | ACPI_OPERAND_OBJECT *RegionObj2; |
647 | ACPI_OPERAND_OBJECT *RegionObj2; |
643 | 648 | ||
644 | 649 | ||
645 | ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); |
650 | ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); |
646 | 651 | ||
647 | 652 | ||
648 | if (!RegionObj) |
653 | if (!RegionObj) |
649 | { |
654 | { |
650 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
655 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
651 | } |
656 | } |
652 | 657 | ||
653 | if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED) |
658 | if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED) |
654 | { |
659 | { |
655 | return_ACPI_STATUS (AE_OK); |
660 | return_ACPI_STATUS (AE_OK); |
656 | } |
661 | } |
657 | 662 | ||
658 | RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); |
663 | RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); |
659 | if (!RegionObj2) |
664 | if (!RegionObj2) |
660 | { |
665 | { |
661 | return_ACPI_STATUS (AE_NOT_EXIST); |
666 | return_ACPI_STATUS (AE_NOT_EXIST); |
662 | } |
667 | } |
663 | 668 | ||
664 | Node = RegionObj->Region.Node->Parent; |
669 | Node = RegionObj->Region.Node->Parent; |
665 | SpaceId = RegionObj->Region.SpaceId; |
670 | SpaceId = RegionObj->Region.SpaceId; |
666 | 671 | ||
667 | /* Setup defaults */ |
672 | /* Setup defaults */ |
668 | 673 | ||
669 | RegionObj->Region.Handler = NULL; |
674 | RegionObj->Region.Handler = NULL; |
670 | RegionObj2->Extra.Method_REG = NULL; |
675 | RegionObj2->Extra.Method_REG = NULL; |
671 | RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); |
676 | RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); |
672 | RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; |
677 | RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; |
673 | 678 | ||
674 | /* Find any "_REG" method associated with this region definition */ |
679 | /* Find any "_REG" method associated with this region definition */ |
675 | 680 | ||
676 | Status = AcpiNsSearchOneScope ( |
681 | Status = AcpiNsSearchOneScope ( |
677 | *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); |
682 | *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); |
678 | if (ACPI_SUCCESS (Status)) |
683 | if (ACPI_SUCCESS (Status)) |
679 | { |
684 | { |
680 | /* |
685 | /* |
681 | * The _REG method is optional and there can be only one per region |
686 | * The _REG method is optional and there can be only one per region |
682 | * definition. This will be executed when the handler is attached |
687 | * definition. This will be executed when the handler is attached |
683 | * or removed |
688 | * or removed |
684 | */ |
689 | */ |
685 | RegionObj2->Extra.Method_REG = MethodNode; |
690 | RegionObj2->Extra.Method_REG = MethodNode; |
686 | } |
691 | } |
687 | 692 | ||
688 | /* |
693 | /* |
689 | * The following loop depends upon the root Node having no parent |
694 | * The following loop depends upon the root Node having no parent |
690 | * ie: AcpiGbl_RootNode->ParentEntry being set to NULL |
695 | * ie: AcpiGbl_RootNode->ParentEntry being set to NULL |
691 | */ |
696 | */ |
692 | while (Node) |
697 | while (Node) |
693 | { |
698 | { |
694 | /* Check to see if a handler exists */ |
699 | /* Check to see if a handler exists */ |
695 | 700 | ||
696 | HandlerObj = NULL; |
701 | HandlerObj = NULL; |
697 | ObjDesc = AcpiNsGetAttachedObject (Node); |
702 | ObjDesc = AcpiNsGetAttachedObject (Node); |
698 | if (ObjDesc) |
703 | if (ObjDesc) |
699 | { |
704 | { |
700 | /* Can only be a handler if the object exists */ |
705 | /* Can only be a handler if the object exists */ |
701 | 706 | ||
702 | switch (Node->Type) |
707 | switch (Node->Type) |
703 | { |
708 | { |
704 | case ACPI_TYPE_DEVICE: |
709 | case ACPI_TYPE_DEVICE: |
705 | 710 | ||
706 | HandlerObj = ObjDesc->Device.Handler; |
711 | HandlerObj = ObjDesc->Device.Handler; |
707 | break; |
712 | break; |
708 | 713 | ||
709 | case ACPI_TYPE_PROCESSOR: |
714 | case ACPI_TYPE_PROCESSOR: |
710 | 715 | ||
711 | HandlerObj = ObjDesc->Processor.Handler; |
716 | HandlerObj = ObjDesc->Processor.Handler; |
712 | break; |
717 | break; |
713 | 718 | ||
714 | case ACPI_TYPE_THERMAL: |
719 | case ACPI_TYPE_THERMAL: |
715 | 720 | ||
716 | HandlerObj = ObjDesc->ThermalZone.Handler; |
721 | HandlerObj = ObjDesc->ThermalZone.Handler; |
717 | break; |
722 | break; |
718 | 723 | ||
719 | case ACPI_TYPE_METHOD: |
724 | case ACPI_TYPE_METHOD: |
720 | /* |
725 | /* |
721 | * If we are executing module level code, the original |
726 | * If we are executing module level code, the original |
722 | * Node's object was replaced by this Method object and we |
727 | * Node's object was replaced by this Method object and we |
723 | * saved the handler in the method object. |
728 | * saved the handler in the method object. |
724 | * |
729 | * |
725 | * See AcpiNsExecModuleCode |
730 | * See AcpiNsExecModuleCode |
726 | */ |
731 | */ |
727 | if (ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) |
732 | if (ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) |
728 | { |
733 | { |
729 | HandlerObj = ObjDesc->Method.Extra.Handler; |
734 | HandlerObj = ObjDesc->Method.Dispatch.Handler; |
730 | } |
735 | } |
731 | break; |
736 | break; |
732 | 737 | ||
733 | default: |
738 | default: |
734 | /* Ignore other objects */ |
739 | /* Ignore other objects */ |
735 | break; |
740 | break; |
736 | } |
741 | } |
737 | 742 | ||
738 | while (HandlerObj) |
743 | while (HandlerObj) |
739 | { |
744 | { |
740 | /* Is this handler of the correct type? */ |
745 | /* Is this handler of the correct type? */ |
741 | 746 | ||
742 | if (HandlerObj->AddressSpace.SpaceId == SpaceId) |
747 | if (HandlerObj->AddressSpace.SpaceId == SpaceId) |
743 | { |
748 | { |
744 | /* Found correct handler */ |
749 | /* Found correct handler */ |
745 | 750 | ||
746 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, |
751 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, |
747 | "Found handler %p for region %p in obj %p\n", |
752 | "Found handler %p for region %p in obj %p\n", |
748 | HandlerObj, RegionObj, ObjDesc)); |
753 | HandlerObj, RegionObj, ObjDesc)); |
749 | 754 | ||
750 | Status = AcpiEvAttachRegion (HandlerObj, RegionObj, |
755 | Status = AcpiEvAttachRegion (HandlerObj, RegionObj, |
751 | AcpiNsLocked); |
756 | AcpiNsLocked); |
752 | 757 | ||
753 | /* |
758 | /* |
754 | * Tell all users that this region is usable by |
759 | * Tell all users that this region is usable by |
755 | * running the _REG method |
760 | * running the _REG method |
756 | */ |
761 | */ |
757 | if (AcpiNsLocked) |
762 | if (AcpiNsLocked) |
758 | { |
763 | { |
759 | Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); |
764 | Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); |
760 | if (ACPI_FAILURE (Status)) |
765 | if (ACPI_FAILURE (Status)) |
761 | { |
766 | { |
762 | return_ACPI_STATUS (Status); |
767 | return_ACPI_STATUS (Status); |
763 | } |
768 | } |
764 | } |
769 | } |
765 | 770 | ||
766 | Status = AcpiEvExecuteRegMethod (RegionObj, 1); |
771 | Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT); |
767 | 772 | ||
768 | if (AcpiNsLocked) |
773 | if (AcpiNsLocked) |
769 | { |
774 | { |
770 | Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); |
775 | Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); |
771 | if (ACPI_FAILURE (Status)) |
776 | if (ACPI_FAILURE (Status)) |
772 | { |
777 | { |
773 | return_ACPI_STATUS (Status); |
778 | return_ACPI_STATUS (Status); |
774 | } |
779 | } |
775 | } |
780 | } |
776 | 781 | ||
777 | return_ACPI_STATUS (AE_OK); |
782 | return_ACPI_STATUS (AE_OK); |
778 | } |
783 | } |
779 | 784 | ||
780 | /* Try next handler in the list */ |
785 | /* Try next handler in the list */ |
781 | 786 | ||
782 | HandlerObj = HandlerObj->AddressSpace.Next; |
787 | HandlerObj = HandlerObj->AddressSpace.Next; |
783 | } |
788 | } |
784 | } |
789 | } |
785 | 790 | ||
786 | /* This node does not have the handler we need; Pop up one level */ |
791 | /* This node does not have the handler we need; Pop up one level */ |
787 | 792 | ||
788 | Node = Node->Parent; |
793 | Node = Node->Parent; |
789 | } |
794 | } |
790 | 795 | ||
791 | /* If we get here, there is no handler for this region */ |
796 | /* If we get here, there is no handler for this region */ |
792 | 797 | ||
793 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, |
798 | ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, |
794 | "No handler for RegionType %s(%X) (RegionObj %p)\n", |
799 | "No handler for RegionType %s(%X) (RegionObj %p)\n", |
795 | AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); |
800 | AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); |
796 | 801 | ||
797 | return_ACPI_STATUS (AE_NOT_EXIST); |
802 | return_ACPI_STATUS (AE_NOT_EXIST); |
798 | }> |
803 | }> |