1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
/******************************************************************************
*
* Module Name: evrgnini- ACPI Address_space / Op_region init
* $Revision: 22 $
*
*****************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "acpi.h"
#include "acevents.h"
#include "acnamesp.h"
#include "acinterp.h"
#include "amlcode.h"
#define _COMPONENT EVENT_HANDLING
MODULE_NAME ("evrgnini")
/*****************************************************************************
*
* FUNCTION: Acpi_ev_system_memory_region_setup
*
* PARAMETERS: Region_obj - region we are interested in
* Function - start or stop
* Handler_context - Address space handler context
* Region_context - Region specific context
*
* RETURN: Status
*
* DESCRIPTION: Do any prep work for region handling, a nop for now
*
****************************************************************************/
ACPI_STATUS
acpi_ev_system_memory_region_setup (
ACPI_HANDLE handle,
u32 function,
void *handler_context,
void **region_context)
{
ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle;
if (function == ACPI_REGION_DEACTIVATE) {
region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
if (*region_context) {
acpi_cm_free (*region_context);
*region_context = NULL;
}
return (AE_OK);
}
/* Activate. Create a new context */
*region_context = acpi_cm_callocate (sizeof (MEM_HANDLER_CONTEXT));
if (!(*region_context)) {
return (AE_NO_MEMORY);
}
/* Init. (Mapping fields are all set to zeros above) */
region_obj->region.flags |= AOPOBJ_INITIALIZED;
return (AE_OK);
}
/*****************************************************************************
*
* FUNCTION: Acpi_ev_io_space_region_setup
*
* PARAMETERS: Region_obj - region we are interested in
* Function - start or stop
* Handler_context - Address space handler context
* Region_context - Region specific context
*
* RETURN: Status
*
* DESCRIPTION: Do any prep work for region handling
*
****************************************************************************/
ACPI_STATUS
acpi_ev_io_space_region_setup (
ACPI_HANDLE handle,
u32 function,
void *handler_context,
void **region_context)
{
ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle;
if (function == ACPI_REGION_DEACTIVATE) {
*region_context = NULL;
region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
}
else {
*region_context = handler_context;
region_obj->region.flags |= AOPOBJ_INITIALIZED;
}
return (AE_OK);
}
/*****************************************************************************
*
* FUNCTION: Acpi_ev_pci_config_region_setup
*
* PARAMETERS: Region_obj - region we are interested in
* Function - start or stop
* Handler_context - Address space handler context
* Region_context - Region specific context
*
* RETURN: Status
*
* DESCRIPTION: Do any prep work for region handling
*
* MUTEX: Assumes namespace is locked
*
****************************************************************************/
ACPI_STATUS
acpi_ev_pci_config_region_setup (
ACPI_HANDLE handle,
u32 function,
void *handler_context,
void **region_context)
{
ACPI_STATUS status = AE_OK;
u32 temp;
PCI_HANDLER_CONTEXT *pci_context = *region_context;
ACPI_OPERAND_OBJECT *handler_obj;
ACPI_NAMESPACE_NODE *node;
ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle;
handler_obj = region_obj->region.addr_handler;
if (!handler_obj) {
/*
* No installed handler. This shouldn't happen because the dispatch
* routine checks before we get here, but we check again just in case.
*/
return(AE_EXIST);
}
if (function == ACPI_REGION_DEACTIVATE) {
region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
if (pci_context) {
acpi_cm_free (pci_context);
*region_context = NULL;
}
return (status);
}
/* Create a new context */
pci_context = acpi_cm_callocate (sizeof(PCI_HANDLER_CONTEXT));
if (!pci_context) {
return (AE_NO_MEMORY);
}
/*
* For PCI Config space access, we have to pass the segment, bus,
* device and function numbers. This routine must acquire those.
*/
/*
* First get device and function numbers from the _ADR object
* in the parent's scope.
*/
ACPI_ASSERT(region_obj->region.node);
node = acpi_ns_get_parent_object (region_obj->region.node);
acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
/* Acpi_evaluate the _ADR object */
status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR, node, &temp);
/*
* The default is zero, since the allocation above zeroed the data, just
* do nothing on failures.
*/
if (ACPI_SUCCESS (status)) {
/*
* Got it..
*/
pci_context->dev_func = temp;
}
/*
* Get the _SEG and _BBN values from the device upon which the handler
* is installed.
*
* We need to get the _SEG and _BBN objects relative to the PCI BUS device.
* This is the device the handler has been registered to handle.
*/
node = handler_obj->addr_handler.node;
status = acpi_cm_evaluate_numeric_object (METHOD_NAME__SEG, node, &temp);
if (ACPI_SUCCESS (status)) {
/*
* Got it..
*/
pci_context->seg = temp;
}
status = acpi_cm_evaluate_numeric_object (METHOD_NAME__BBN, node, &temp);
if (ACPI_SUCCESS (status)) {
/*
* Got it..
*/
pci_context->bus = temp;
}
*region_context = pci_context;
acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);
region_obj->region.flags |= AOPOBJ_INITIALIZED;
return (AE_OK);
}
/*****************************************************************************
*
* FUNCTION: Acpi_ev_default_region_setup
*
* PARAMETERS: Region_obj - region we are interested in
* Function - start or stop
* Handler_context - Address space handler context
* Region_context - Region specific context
*
* RETURN: Status
*
* DESCRIPTION: Do any prep work for region handling
*
****************************************************************************/
ACPI_STATUS
acpi_ev_default_region_setup (
ACPI_HANDLE handle,
u32 function,
void *handler_context,
void **region_context)
{
ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle;
if (function == ACPI_REGION_DEACTIVATE) {
*region_context = NULL;
region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
}
else {
*region_context = handler_context;
region_obj->region.flags |= AOPOBJ_INITIALIZED;
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: Acpi_ev_initialize_region
*
* PARAMETERS: Region_obj - Region we are initializing
*
* RETURN: Status
*
* DESCRIPTION: Initializes the region, finds any _REG methods and saves them
* for execution at a later time
*
* Get the appropriate address space handler for a newly
* created region.
*
* This also performs address space specific intialization. For
* example, PCI regions must have an _ADR object that contains
* a PCI address in the scope of the defintion. This address is
* required to perform an access to PCI config space.
*
******************************************************************************/
ACPI_STATUS
acpi_ev_initialize_region (
ACPI_OPERAND_OBJECT *region_obj,
u8 acpi_ns_locked)
{
ACPI_OPERAND_OBJECT *handler_obj;
ACPI_OPERAND_OBJECT *obj_desc;
u32 space_id;
ACPI_NAMESPACE_NODE *node;
ACPI_STATUS status;
ACPI_NAMESPACE_NODE *method_node;
ACPI_NAME *reg_name_ptr = (ACPI_NAME *) METHOD_NAME__REG;
if (!region_obj) {
return (AE_BAD_PARAMETER);
}
ACPI_ASSERT(region_obj->region.node);
node = acpi_ns_get_parent_object (region_obj->region.node);
space_id = region_obj->region.space_id;
region_obj->region.addr_handler = NULL;
region_obj->region.REGmethod = NULL;
region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
/*
* Find any "_REG" associated with this region definition
*/
status = acpi_ns_search_node (*reg_name_ptr, node,
ACPI_TYPE_METHOD, &method_node);
if (ACPI_SUCCESS (status)) {
/*
* The _REG method is optional and there can be only one per region
* definition. This will be executed when the handler is attached
* or removed
*/
region_obj->region.REGmethod = method_node;
}
/*
* The following loop depends upon the root Node having no parent
* ie: Acpi_gbl_Root_node->Parent_entry being set to NULL
*/
while (node) {
/*
* Check to see if a handler exists
*/
handler_obj = NULL;
obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node);
if (obj_desc) {
/*
* can only be a handler if the object exists
*/
switch (node->type)
{
case ACPI_TYPE_DEVICE:
handler_obj = obj_desc->device.addr_handler;
break;
case ACPI_TYPE_PROCESSOR:
handler_obj = obj_desc->processor.addr_handler;
break;
case ACPI_TYPE_THERMAL:
handler_obj = obj_desc->thermal_zone.addr_handler;
break;
}
while (handler_obj) {
/*
* This guy has at least one address handler
* see if it has the type we want
*/
if (handler_obj->addr_handler.space_id == space_id) {
/*
* Found it! Now update the region and the handler
*/
acpi_ev_associate_region_and_handler (handler_obj, region_obj, acpi_ns_locked);
return (AE_OK);
}
handler_obj = handler_obj->addr_handler.next;
} /* while handlerobj */
}
/*
* This one does not have the handler we need
* Pop up one level
*/
node = acpi_ns_get_parent_object (node);
} /* while Node != ROOT */
/*
* If we get here, there is no handler for this region
*/
return (AE_NOT_EXIST);
}
|