This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ev_io_space_region_setup
- acpi_ev_pci_config_region_setup
- acpi_ev_is_pci_root_bridge
- acpi_ev_pci_bar_region_setup
- acpi_ev_cmos_region_setup
- acpi_ev_default_region_setup
- acpi_ev_initialize_region
1
2
3
4
5
6
7
8
9
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acevents.h"
13 #include "acnamesp.h"
14 #include "acinterp.h"
15
16 #define _COMPONENT ACPI_EVENTS
17 ACPI_MODULE_NAME("evrgnini")
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 acpi_status
34 acpi_ev_system_memory_region_setup(acpi_handle handle,
35 u32 function,
36 void *handler_context, void **region_context)
37 {
38 union acpi_operand_object *region_desc =
39 (union acpi_operand_object *)handle;
40 struct acpi_mem_space_context *local_region_context;
41
42 ACPI_FUNCTION_TRACE(ev_system_memory_region_setup);
43
44 if (function == ACPI_REGION_DEACTIVATE) {
45 if (*region_context) {
46 local_region_context =
47 (struct acpi_mem_space_context *)*region_context;
48
49
50
51 if (local_region_context->mapped_length) {
52 acpi_os_unmap_memory(local_region_context->
53 mapped_logical_address,
54 local_region_context->
55 mapped_length);
56 }
57 ACPI_FREE(local_region_context);
58 *region_context = NULL;
59 }
60 return_ACPI_STATUS(AE_OK);
61 }
62
63
64
65 local_region_context =
66 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_mem_space_context));
67 if (!(local_region_context)) {
68 return_ACPI_STATUS(AE_NO_MEMORY);
69 }
70
71
72
73 local_region_context->length = region_desc->region.length;
74 local_region_context->address = region_desc->region.address;
75
76 *region_context = local_region_context;
77 return_ACPI_STATUS(AE_OK);
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 acpi_status
96 acpi_ev_io_space_region_setup(acpi_handle handle,
97 u32 function,
98 void *handler_context, void **region_context)
99 {
100 ACPI_FUNCTION_TRACE(ev_io_space_region_setup);
101
102 if (function == ACPI_REGION_DEACTIVATE) {
103 *region_context = NULL;
104 } else {
105 *region_context = handler_context;
106 }
107
108 return_ACPI_STATUS(AE_OK);
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 acpi_status
129 acpi_ev_pci_config_region_setup(acpi_handle handle,
130 u32 function,
131 void *handler_context, void **region_context)
132 {
133 acpi_status status = AE_OK;
134 u64 pci_value;
135 struct acpi_pci_id *pci_id = *region_context;
136 union acpi_operand_object *handler_obj;
137 struct acpi_namespace_node *parent_node;
138 struct acpi_namespace_node *pci_root_node;
139 struct acpi_namespace_node *pci_device_node;
140 union acpi_operand_object *region_obj =
141 (union acpi_operand_object *)handle;
142
143 ACPI_FUNCTION_TRACE(ev_pci_config_region_setup);
144
145 handler_obj = region_obj->region.handler;
146 if (!handler_obj) {
147
148
149
150
151 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
152 "Attempting to init a region %p, with no handler\n",
153 region_obj));
154 return_ACPI_STATUS(AE_NOT_EXIST);
155 }
156
157 *region_context = NULL;
158 if (function == ACPI_REGION_DEACTIVATE) {
159 if (pci_id) {
160 ACPI_FREE(pci_id);
161 }
162 return_ACPI_STATUS(status);
163 }
164
165 parent_node = region_obj->region.node->parent;
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180 if (handler_obj->address_space.node == acpi_gbl_root_node) {
181
182
183
184 pci_root_node = parent_node;
185 while (pci_root_node != acpi_gbl_root_node) {
186
187
188
189 if (acpi_ev_is_pci_root_bridge(pci_root_node)) {
190
191
192
193 status = acpi_install_address_space_handler((acpi_handle)pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
194 if (ACPI_FAILURE(status)) {
195 if (status == AE_SAME_HANDLER) {
196
197
198
199
200
201 status = AE_OK;
202 } else {
203 ACPI_EXCEPTION((AE_INFO, status,
204 "Could not install PciConfig handler "
205 "for Root Bridge %4.4s",
206 acpi_ut_get_node_name
207 (pci_root_node)));
208 }
209 }
210 break;
211 }
212
213 pci_root_node = pci_root_node->parent;
214 }
215
216
217 } else {
218 pci_root_node = handler_obj->address_space.node;
219 }
220
221
222
223
224
225 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
226 return_ACPI_STATUS(AE_OK);
227 }
228
229
230
231 pci_id = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pci_id));
232 if (!pci_id) {
233 return_ACPI_STATUS(AE_NO_MEMORY);
234 }
235
236
237
238
239
240
241
242
243 pci_device_node = region_obj->region.node;
244 while (pci_device_node && (pci_device_node->type != ACPI_TYPE_DEVICE)) {
245 pci_device_node = pci_device_node->parent;
246 }
247
248 if (!pci_device_node) {
249 ACPI_FREE(pci_id);
250 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
251 }
252
253
254
255
256
257 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR,
258 pci_device_node, &pci_value);
259
260
261
262
263
264 if (ACPI_SUCCESS(status)) {
265 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
266 pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value));
267 }
268
269
270
271 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG,
272 pci_root_node, &pci_value);
273 if (ACPI_SUCCESS(status)) {
274 pci_id->segment = ACPI_LOWORD(pci_value);
275 }
276
277
278
279 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN,
280 pci_root_node, &pci_value);
281 if (ACPI_SUCCESS(status)) {
282 pci_id->bus = ACPI_LOWORD(pci_value);
283 }
284
285
286
287 status =
288 acpi_hw_derive_pci_id(pci_id, pci_root_node,
289 region_obj->region.node);
290 if (ACPI_FAILURE(status)) {
291 ACPI_FREE(pci_id);
292 return_ACPI_STATUS(status);
293 }
294
295 *region_context = pci_id;
296 return_ACPI_STATUS(AE_OK);
297 }
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312 u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
313 {
314 acpi_status status;
315 struct acpi_pnp_device_id *hid;
316 struct acpi_pnp_device_id_list *cid;
317 u32 i;
318 u8 match;
319
320
321
322 status = acpi_ut_execute_HID(node, &hid);
323 if (ACPI_FAILURE(status)) {
324 return (FALSE);
325 }
326
327 match = acpi_ut_is_pci_root_bridge(hid->string);
328 ACPI_FREE(hid);
329
330 if (match) {
331 return (TRUE);
332 }
333
334
335
336 status = acpi_ut_execute_CID(node, &cid);
337 if (ACPI_FAILURE(status)) {
338 return (FALSE);
339 }
340
341
342
343 for (i = 0; i < cid->count; i++) {
344 if (acpi_ut_is_pci_root_bridge(cid->ids[i].string)) {
345 ACPI_FREE(cid);
346 return (TRUE);
347 }
348 }
349
350 ACPI_FREE(cid);
351 return (FALSE);
352 }
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371 acpi_status
372 acpi_ev_pci_bar_region_setup(acpi_handle handle,
373 u32 function,
374 void *handler_context, void **region_context)
375 {
376 ACPI_FUNCTION_TRACE(ev_pci_bar_region_setup);
377
378 return_ACPI_STATUS(AE_OK);
379 }
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398 acpi_status
399 acpi_ev_cmos_region_setup(acpi_handle handle,
400 u32 function,
401 void *handler_context, void **region_context)
402 {
403 ACPI_FUNCTION_TRACE(ev_cmos_region_setup);
404
405 return_ACPI_STATUS(AE_OK);
406 }
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423 acpi_status
424 acpi_ev_default_region_setup(acpi_handle handle,
425 u32 function,
426 void *handler_context, void **region_context)
427 {
428 ACPI_FUNCTION_TRACE(ev_default_region_setup);
429
430 if (function == ACPI_REGION_DEACTIVATE) {
431 *region_context = NULL;
432 } else {
433 *region_context = handler_context;
434 }
435
436 return_ACPI_STATUS(AE_OK);
437 }
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475 acpi_status acpi_ev_initialize_region(union acpi_operand_object *region_obj)
476 {
477 union acpi_operand_object *handler_obj;
478 union acpi_operand_object *obj_desc;
479 acpi_adr_space_type space_id;
480 struct acpi_namespace_node *node;
481
482 ACPI_FUNCTION_TRACE(ev_initialize_region);
483
484 if (!region_obj) {
485 return_ACPI_STATUS(AE_BAD_PARAMETER);
486 }
487
488 if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
489 return_ACPI_STATUS(AE_OK);
490 }
491
492 region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED;
493
494 node = region_obj->region.node->parent;
495 space_id = region_obj->region.space_id;
496
497
498
499
500
501 while (node) {
502
503
504
505 handler_obj = NULL;
506 obj_desc = acpi_ns_get_attached_object(node);
507 if (obj_desc) {
508
509
510
511 switch (node->type) {
512 case ACPI_TYPE_DEVICE:
513 case ACPI_TYPE_PROCESSOR:
514 case ACPI_TYPE_THERMAL:
515
516 handler_obj = obj_desc->common_notify.handler;
517 break;
518
519 default:
520
521
522
523 break;
524 }
525
526 handler_obj =
527 acpi_ev_find_region_handler(space_id, handler_obj);
528 if (handler_obj) {
529
530
531
532 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
533 "Found handler %p for region %p in obj %p\n",
534 handler_obj, region_obj,
535 obj_desc));
536
537 (void)acpi_ev_attach_region(handler_obj,
538 region_obj, FALSE);
539
540
541
542
543
544 acpi_ex_exit_interpreter();
545 (void)acpi_ev_execute_reg_method(region_obj,
546 ACPI_REG_CONNECT);
547 acpi_ex_enter_interpreter();
548 return_ACPI_STATUS(AE_OK);
549 }
550 }
551
552
553
554 node = node->parent;
555 }
556
557
558
559
560
561
562 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
563 "No handler for RegionType %s(%X) (RegionObj %p)\n",
564 acpi_ut_get_region_name(space_id), space_id,
565 region_obj));
566
567 return_ACPI_STATUS(AE_OK);
568 }