This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ev_update_gpes
- acpi_ev_match_gpe_method
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
15 #define _COMPONENT ACPI_EVENTS
16 ACPI_MODULE_NAME("evgpeinit")
17 #if (!ACPI_REDUCED_HARDWARE)
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 acpi_status acpi_ev_gpe_initialize(void)
47 {
48 u32 register_count0 = 0;
49 u32 register_count1 = 0;
50 u32 gpe_number_max = 0;
51 acpi_status status;
52
53 ACPI_FUNCTION_TRACE(ev_gpe_initialize);
54
55 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
56 "Initializing General Purpose Events (GPEs):\n"));
57
58 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
59 if (ACPI_FAILURE(status)) {
60 return_ACPI_STATUS(status);
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 if (acpi_gbl_FADT.gpe0_block_length &&
89 acpi_gbl_FADT.xgpe0_block.address) {
90
91
92
93 register_count0 = (u16)(acpi_gbl_FADT.gpe0_block_length / 2);
94 gpe_number_max =
95 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
96
97
98
99 status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
100 acpi_gbl_FADT.xgpe0_block.
101 address,
102 acpi_gbl_FADT.xgpe0_block.
103 space_id, register_count0, 0,
104 acpi_gbl_FADT.sci_interrupt,
105 &acpi_gbl_gpe_fadt_blocks[0]);
106
107 if (ACPI_FAILURE(status)) {
108 ACPI_EXCEPTION((AE_INFO, status,
109 "Could not create GPE Block 0"));
110 }
111 }
112
113 if (acpi_gbl_FADT.gpe1_block_length &&
114 acpi_gbl_FADT.xgpe1_block.address) {
115
116
117
118 register_count1 = (u16)(acpi_gbl_FADT.gpe1_block_length / 2);
119
120
121
122 if ((register_count0) &&
123 (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) {
124 ACPI_ERROR((AE_INFO,
125 "GPE0 block (GPE 0 to %u) overlaps the GPE1 block "
126 "(GPE %u to %u) - Ignoring GPE1",
127 gpe_number_max, acpi_gbl_FADT.gpe1_base,
128 acpi_gbl_FADT.gpe1_base +
129 ((register_count1 *
130 ACPI_GPE_REGISTER_WIDTH) - 1)));
131
132
133
134 register_count1 = 0;
135 } else {
136
137
138 status =
139 acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
140 acpi_gbl_FADT.xgpe1_block.
141 address,
142 acpi_gbl_FADT.xgpe1_block.
143 space_id, register_count1,
144 acpi_gbl_FADT.gpe1_base,
145 acpi_gbl_FADT.
146 sci_interrupt,
147 &acpi_gbl_gpe_fadt_blocks
148 [1]);
149
150 if (ACPI_FAILURE(status)) {
151 ACPI_EXCEPTION((AE_INFO, status,
152 "Could not create GPE Block 1"));
153 }
154
155
156
157
158
159 gpe_number_max = acpi_gbl_FADT.gpe1_base +
160 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
161 }
162 }
163
164
165
166 if ((register_count0 + register_count1) == 0) {
167
168
169
170 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
171 "There are no GPE blocks defined in the FADT\n"));
172 status = AE_OK;
173 goto cleanup;
174 }
175
176 cleanup:
177 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
178 return_ACPI_STATUS(AE_OK);
179 }
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195 void acpi_ev_update_gpes(acpi_owner_id table_owner_id)
196 {
197 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
198 struct acpi_gpe_block_info *gpe_block;
199 struct acpi_gpe_walk_info walk_info;
200 acpi_status status = AE_OK;
201
202
203
204
205
206
207
208
209
210
211 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
212 if (ACPI_FAILURE(status)) {
213 return;
214 }
215
216 walk_info.count = 0;
217 walk_info.owner_id = table_owner_id;
218 walk_info.execute_by_owner_id = TRUE;
219
220
221
222 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
223 while (gpe_xrupt_info) {
224
225
226
227 gpe_block = gpe_xrupt_info->gpe_block_list_head;
228 while (gpe_block) {
229 walk_info.gpe_block = gpe_block;
230 walk_info.gpe_device = gpe_block->node;
231
232 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD,
233 walk_info.gpe_device,
234 ACPI_UINT32_MAX,
235 ACPI_NS_WALK_NO_UNLOCK,
236 acpi_ev_match_gpe_method,
237 NULL, &walk_info, NULL);
238 if (ACPI_FAILURE(status)) {
239 ACPI_EXCEPTION((AE_INFO, status,
240 "While decoding _Lxx/_Exx methods"));
241 }
242
243 gpe_block = gpe_block->next;
244 }
245
246 gpe_xrupt_info = gpe_xrupt_info->next;
247 }
248
249 if (walk_info.count) {
250 ACPI_INFO(("Enabled %u new GPEs", walk_info.count));
251 }
252
253 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
254 return;
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 acpi_status
284 acpi_ev_match_gpe_method(acpi_handle obj_handle,
285 u32 level, void *context, void **return_value)
286 {
287 struct acpi_namespace_node *method_node =
288 ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
289 struct acpi_gpe_walk_info *walk_info =
290 ACPI_CAST_PTR(struct acpi_gpe_walk_info, context);
291 struct acpi_gpe_event_info *gpe_event_info;
292 acpi_status status;
293 u32 gpe_number;
294 u8 temp_gpe_number;
295 char name[ACPI_NAMESEG_SIZE + 1];
296 u8 type;
297
298 ACPI_FUNCTION_TRACE(ev_match_gpe_method);
299
300
301
302 if ((walk_info->execute_by_owner_id) &&
303 (method_node->owner_id != walk_info->owner_id)) {
304 return_ACPI_STATUS(AE_OK);
305 }
306
307
308
309
310
311
312 ACPI_MOVE_32_TO_32(name, &method_node->name.integer);
313 name[ACPI_NAMESEG_SIZE] = 0;
314
315
316
317 if (name[0] != '_') {
318 return_ACPI_STATUS(AE_OK);
319 }
320
321
322
323
324
325 switch (name[1]) {
326 case 'L':
327
328 type = ACPI_GPE_LEVEL_TRIGGERED;
329 break;
330
331 case 'E':
332
333 type = ACPI_GPE_EDGE_TRIGGERED;
334 break;
335
336 default:
337
338
339
340 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
341 "Ignoring unknown GPE method type: %s "
342 "(name not of form _Lxx or _Exx)", name));
343 return_ACPI_STATUS(AE_OK);
344 }
345
346
347
348 status = acpi_ut_ascii_to_hex_byte(&name[2], &temp_gpe_number);
349 if (ACPI_FAILURE(status)) {
350
351
352
353 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
354 "Could not extract GPE number from name: %s "
355 "(name is not of form _Lxx or _Exx)", name));
356 return_ACPI_STATUS(AE_OK);
357 }
358
359
360
361 gpe_number = (u32)temp_gpe_number;
362 gpe_event_info =
363 acpi_ev_low_get_gpe_info(gpe_number, walk_info->gpe_block);
364 if (!gpe_event_info) {
365
366
367
368
369
370 return_ACPI_STATUS(AE_OK);
371 }
372
373 if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
374 ACPI_GPE_DISPATCH_HANDLER) ||
375 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
376 ACPI_GPE_DISPATCH_RAW_HANDLER)) {
377
378
379
380 return_ACPI_STATUS(AE_OK);
381 }
382
383 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
384 ACPI_GPE_DISPATCH_METHOD) {
385
386
387
388
389 if (type != (gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK)) {
390 ACPI_ERROR((AE_INFO,
391 "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
392 gpe_number, gpe_number, gpe_number));
393 }
394 return_ACPI_STATUS(AE_OK);
395 }
396
397
398
399 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
400
401
402
403
404
405 gpe_event_info->flags &= ~(ACPI_GPE_DISPATCH_MASK);
406 gpe_event_info->flags |= (u8)(type | ACPI_GPE_DISPATCH_METHOD);
407 gpe_event_info->dispatch.method_node = method_node;
408
409 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
410 "Registered GPE method %s as GPE number 0x%.2X\n",
411 name, gpe_number));
412 return_ACPI_STATUS(AE_OK);
413 }
414
415 #endif