Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 1 | /****************************************************************************** |
2 | * |
||
3 | * Module Name: evgpeblk - GPE block creation and initialization. |
||
4 | * |
||
5 | *****************************************************************************/ |
||
6 | |||
7 | /****************************************************************************** |
||
8 | * |
||
9 | * 1. Copyright Notice |
||
10 | * |
||
2216 | Serge | 11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
1498 | serge | 12 | * All rights reserved. |
13 | * |
||
14 | * 2. License |
||
15 | * |
||
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 |
||
18 | * you this software, covering your right to use that party's intellectual |
||
19 | * property rights. |
||
20 | * |
||
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 |
||
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
||
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
||
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 |
||
27 | * |
||
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 |
||
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 |
||
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 |
||
34 | * to or modifications of the Original Intel Code. No other license or right |
||
35 | * is granted directly or by implication, estoppel or otherwise; |
||
36 | * |
||
37 | * The above copyright and patent license is granted only if the following |
||
38 | * conditions are met: |
||
39 | * |
||
40 | * 3. Conditions |
||
41 | * |
||
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
||
43 | * Redistribution of source code of any substantial portion of the Covered |
||
44 | * Code or modification with rights to further distribute source must include |
||
45 | * the above Copyright Notice, the above License, this list of Conditions, |
||
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
||
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 |
||
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 |
||
51 | * must include a prominent statement that the modification is derived, |
||
52 | * directly or indirectly, from Original Intel Code. |
||
53 | * |
||
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 |
||
56 | * Code or modification without rights to further distribute source must |
||
57 | * include the following Disclaimer and Export Compliance provision in the |
||
58 | * documentation and/or other materials provided with distribution. In |
||
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 |
||
61 | * license from Licensee to its licensee is limited to the intellectual |
||
62 | * property embodied in the software Licensee provides to its licensee, and |
||
63 | * not to intellectual property embodied in modifications its licensee may |
||
64 | * make. |
||
65 | * |
||
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
||
67 | * substantial portion of the Covered Code or modification must reproduce the |
||
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
||
69 | * provision in the documentation and/or other materials provided with the |
||
70 | * distribution. |
||
71 | * |
||
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
||
73 | * Intel Code. |
||
74 | * |
||
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 |
||
77 | * other dealings in products derived from or relating to the Covered Code |
||
78 | * without prior written authorization from Intel. |
||
79 | * |
||
80 | * 4. Disclaimer and Export Compliance |
||
81 | * |
||
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 |
||
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
||
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
||
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
||
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
||
88 | * PARTICULAR PURPOSE. |
||
89 | * |
||
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 |
||
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 |
||
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 |
||
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
||
97 | * LIMITED REMEDY. |
||
98 | * |
||
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 |
||
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 |
||
103 | * event Licensee exports any such software from the United States or |
||
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 |
||
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
||
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, |
||
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, |
||
111 | * other governmental approval, or letter of assurance, without first obtaining |
||
112 | * such license, approval or letter. |
||
113 | * |
||
114 | *****************************************************************************/ |
||
115 | |||
116 | #include "acpi.h" |
||
117 | #include "accommon.h" |
||
118 | #include "acevents.h" |
||
119 | #include "acnamesp.h" |
||
120 | |||
121 | #define _COMPONENT ACPI_EVENTS |
||
122 | ACPI_MODULE_NAME ("evgpeblk") |
||
123 | |||
124 | /* Local prototypes */ |
||
125 | |||
126 | static ACPI_STATUS |
||
127 | AcpiEvInstallGpeBlock ( |
||
128 | ACPI_GPE_BLOCK_INFO *GpeBlock, |
||
129 | UINT32 InterruptNumber); |
||
130 | |||
131 | static ACPI_STATUS |
||
132 | AcpiEvCreateGpeInfoBlocks ( |
||
133 | ACPI_GPE_BLOCK_INFO *GpeBlock); |
||
134 | |||
135 | |||
136 | /******************************************************************************* |
||
137 | * |
||
138 | * FUNCTION: AcpiEvInstallGpeBlock |
||
139 | * |
||
140 | * PARAMETERS: GpeBlock - New GPE block |
||
141 | * InterruptNumber - Xrupt to be associated with this |
||
142 | * GPE block |
||
143 | * |
||
144 | * RETURN: Status |
||
145 | * |
||
146 | * DESCRIPTION: Install new GPE block with mutex support |
||
147 | * |
||
148 | ******************************************************************************/ |
||
149 | |||
150 | static ACPI_STATUS |
||
151 | AcpiEvInstallGpeBlock ( |
||
152 | ACPI_GPE_BLOCK_INFO *GpeBlock, |
||
153 | UINT32 InterruptNumber) |
||
154 | { |
||
155 | ACPI_GPE_BLOCK_INFO *NextGpeBlock; |
||
156 | ACPI_GPE_XRUPT_INFO *GpeXruptBlock; |
||
157 | ACPI_STATUS Status; |
||
158 | ACPI_CPU_FLAGS Flags; |
||
159 | |||
160 | |||
161 | ACPI_FUNCTION_TRACE (EvInstallGpeBlock); |
||
162 | |||
163 | |||
164 | Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); |
||
165 | if (ACPI_FAILURE (Status)) |
||
166 | { |
||
167 | return_ACPI_STATUS (Status); |
||
168 | } |
||
169 | |||
170 | GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); |
||
171 | if (!GpeXruptBlock) |
||
172 | { |
||
173 | Status = AE_NO_MEMORY; |
||
174 | goto UnlockAndExit; |
||
175 | } |
||
176 | |||
177 | /* Install the new block at the end of the list with lock */ |
||
178 | |||
179 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
||
180 | if (GpeXruptBlock->GpeBlockListHead) |
||
181 | { |
||
182 | NextGpeBlock = GpeXruptBlock->GpeBlockListHead; |
||
183 | while (NextGpeBlock->Next) |
||
184 | { |
||
185 | NextGpeBlock = NextGpeBlock->Next; |
||
186 | } |
||
187 | |||
188 | NextGpeBlock->Next = GpeBlock; |
||
189 | GpeBlock->Previous = NextGpeBlock; |
||
190 | } |
||
191 | else |
||
192 | { |
||
193 | GpeXruptBlock->GpeBlockListHead = GpeBlock; |
||
194 | } |
||
195 | |||
196 | GpeBlock->XruptBlock = GpeXruptBlock; |
||
197 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
||
198 | |||
199 | |||
200 | UnlockAndExit: |
||
201 | Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); |
||
202 | return_ACPI_STATUS (Status); |
||
203 | } |
||
204 | |||
205 | |||
206 | /******************************************************************************* |
||
207 | * |
||
208 | * FUNCTION: AcpiEvDeleteGpeBlock |
||
209 | * |
||
210 | * PARAMETERS: GpeBlock - Existing GPE block |
||
211 | * |
||
212 | * RETURN: Status |
||
213 | * |
||
214 | * DESCRIPTION: Remove a GPE block |
||
215 | * |
||
216 | ******************************************************************************/ |
||
217 | |||
218 | ACPI_STATUS |
||
219 | AcpiEvDeleteGpeBlock ( |
||
220 | ACPI_GPE_BLOCK_INFO *GpeBlock) |
||
221 | { |
||
222 | ACPI_STATUS Status; |
||
223 | ACPI_CPU_FLAGS Flags; |
||
224 | |||
225 | |||
226 | ACPI_FUNCTION_TRACE (EvInstallGpeBlock); |
||
227 | |||
228 | |||
229 | Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); |
||
230 | if (ACPI_FAILURE (Status)) |
||
231 | { |
||
232 | return_ACPI_STATUS (Status); |
||
233 | } |
||
234 | |||
235 | /* Disable all GPEs in this block */ |
||
236 | |||
237 | Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock, NULL); |
||
238 | |||
239 | if (!GpeBlock->Previous && !GpeBlock->Next) |
||
240 | { |
||
241 | /* This is the last GpeBlock on this interrupt */ |
||
242 | |||
243 | Status = AcpiEvDeleteGpeXrupt (GpeBlock->XruptBlock); |
||
244 | if (ACPI_FAILURE (Status)) |
||
245 | { |
||
246 | goto UnlockAndExit; |
||
247 | } |
||
248 | } |
||
249 | else |
||
250 | { |
||
251 | /* Remove the block on this interrupt with lock */ |
||
252 | |||
253 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
||
254 | if (GpeBlock->Previous) |
||
255 | { |
||
256 | GpeBlock->Previous->Next = GpeBlock->Next; |
||
257 | } |
||
258 | else |
||
259 | { |
||
260 | GpeBlock->XruptBlock->GpeBlockListHead = GpeBlock->Next; |
||
261 | } |
||
262 | |||
263 | if (GpeBlock->Next) |
||
264 | { |
||
265 | GpeBlock->Next->Previous = GpeBlock->Previous; |
||
266 | } |
||
267 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
||
268 | } |
||
269 | |||
270 | AcpiCurrentGpeCount -= GpeBlock->GpeCount; |
||
271 | |||
272 | /* Free the GpeBlock */ |
||
273 | |||
274 | ACPI_FREE (GpeBlock->RegisterInfo); |
||
275 | ACPI_FREE (GpeBlock->EventInfo); |
||
276 | ACPI_FREE (GpeBlock); |
||
277 | |||
278 | UnlockAndExit: |
||
279 | Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); |
||
280 | return_ACPI_STATUS (Status); |
||
281 | } |
||
282 | |||
283 | |||
284 | /******************************************************************************* |
||
285 | * |
||
286 | * FUNCTION: AcpiEvCreateGpeInfoBlocks |
||
287 | * |
||
288 | * PARAMETERS: GpeBlock - New GPE block |
||
289 | * |
||
290 | * RETURN: Status |
||
291 | * |
||
292 | * DESCRIPTION: Create the RegisterInfo and EventInfo blocks for this GPE block |
||
293 | * |
||
294 | ******************************************************************************/ |
||
295 | |||
296 | static ACPI_STATUS |
||
297 | AcpiEvCreateGpeInfoBlocks ( |
||
298 | ACPI_GPE_BLOCK_INFO *GpeBlock) |
||
299 | { |
||
300 | ACPI_GPE_REGISTER_INFO *GpeRegisterInfo = NULL; |
||
301 | ACPI_GPE_EVENT_INFO *GpeEventInfo = NULL; |
||
302 | ACPI_GPE_EVENT_INFO *ThisEvent; |
||
303 | ACPI_GPE_REGISTER_INFO *ThisRegister; |
||
304 | UINT32 i; |
||
305 | UINT32 j; |
||
306 | ACPI_STATUS Status; |
||
307 | |||
308 | |||
309 | ACPI_FUNCTION_TRACE (EvCreateGpeInfoBlocks); |
||
310 | |||
311 | |||
312 | /* Allocate the GPE register information block */ |
||
313 | |||
314 | GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( |
||
315 | (ACPI_SIZE) GpeBlock->RegisterCount * |
||
316 | sizeof (ACPI_GPE_REGISTER_INFO)); |
||
317 | if (!GpeRegisterInfo) |
||
318 | { |
||
319 | ACPI_ERROR ((AE_INFO, |
||
320 | "Could not allocate the GpeRegisterInfo table")); |
||
321 | return_ACPI_STATUS (AE_NO_MEMORY); |
||
322 | } |
||
323 | |||
324 | /* |
||
325 | * Allocate the GPE EventInfo block. There are eight distinct GPEs |
||
326 | * per register. Initialization to zeros is sufficient. |
||
327 | */ |
||
328 | GpeEventInfo = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) GpeBlock->GpeCount * |
||
329 | sizeof (ACPI_GPE_EVENT_INFO)); |
||
330 | if (!GpeEventInfo) |
||
331 | { |
||
332 | ACPI_ERROR ((AE_INFO, |
||
333 | "Could not allocate the GpeEventInfo table")); |
||
334 | Status = AE_NO_MEMORY; |
||
335 | goto ErrorExit; |
||
336 | } |
||
337 | |||
338 | /* Save the new Info arrays in the GPE block */ |
||
339 | |||
340 | GpeBlock->RegisterInfo = GpeRegisterInfo; |
||
341 | GpeBlock->EventInfo = GpeEventInfo; |
||
342 | |||
343 | /* |
||
344 | * Initialize the GPE Register and Event structures. A goal of these |
||
345 | * tables is to hide the fact that there are two separate GPE register |
||
346 | * sets in a given GPE hardware block, the status registers occupy the |
||
347 | * first half, and the enable registers occupy the second half. |
||
348 | */ |
||
349 | ThisRegister = GpeRegisterInfo; |
||
350 | ThisEvent = GpeEventInfo; |
||
351 | |||
352 | for (i = 0; i < GpeBlock->RegisterCount; i++) |
||
353 | { |
||
354 | /* Init the RegisterInfo for this GPE register (8 GPEs) */ |
||
355 | |||
356 | ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber + |
||
357 | (i * ACPI_GPE_REGISTER_WIDTH)); |
||
358 | |||
359 | ThisRegister->StatusAddress.Address = |
||
360 | GpeBlock->BlockAddress.Address + i; |
||
361 | |||
362 | ThisRegister->EnableAddress.Address = |
||
363 | GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount; |
||
364 | |||
365 | ThisRegister->StatusAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; |
||
366 | ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; |
||
367 | ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; |
||
368 | ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; |
||
369 | ThisRegister->StatusAddress.BitOffset = 0; |
||
370 | ThisRegister->EnableAddress.BitOffset = 0; |
||
371 | |||
372 | /* Init the EventInfo for each GPE within this register */ |
||
373 | |||
374 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) |
||
375 | { |
||
376 | ThisEvent->GpeNumber = (UINT8) (ThisRegister->BaseGpeNumber + j); |
||
377 | ThisEvent->RegisterInfo = ThisRegister; |
||
378 | ThisEvent++; |
||
379 | } |
||
380 | |||
381 | /* Disable all GPEs within this register */ |
||
382 | |||
383 | Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress); |
||
384 | if (ACPI_FAILURE (Status)) |
||
385 | { |
||
386 | goto ErrorExit; |
||
387 | } |
||
388 | |||
389 | /* Clear any pending GPE events within this register */ |
||
390 | |||
391 | Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress); |
||
392 | if (ACPI_FAILURE (Status)) |
||
393 | { |
||
394 | goto ErrorExit; |
||
395 | } |
||
396 | |||
397 | ThisRegister++; |
||
398 | } |
||
399 | |||
400 | return_ACPI_STATUS (AE_OK); |
||
401 | |||
402 | |||
403 | ErrorExit: |
||
404 | if (GpeRegisterInfo) |
||
405 | { |
||
406 | ACPI_FREE (GpeRegisterInfo); |
||
407 | } |
||
408 | if (GpeEventInfo) |
||
409 | { |
||
410 | ACPI_FREE (GpeEventInfo); |
||
411 | } |
||
412 | |||
413 | return_ACPI_STATUS (Status); |
||
414 | } |
||
415 | |||
416 | |||
417 | /******************************************************************************* |
||
418 | * |
||
419 | * FUNCTION: AcpiEvCreateGpeBlock |
||
420 | * |
||
421 | * PARAMETERS: GpeDevice - Handle to the parent GPE block |
||
422 | * GpeBlockAddress - Address and SpaceID |
||
423 | * RegisterCount - Number of GPE register pairs in the block |
||
424 | * GpeBlockBaseNumber - Starting GPE number for the block |
||
425 | * InterruptNumber - H/W interrupt for the block |
||
426 | * ReturnGpeBlock - Where the new block descriptor is returned |
||
427 | * |
||
428 | * RETURN: Status |
||
429 | * |
||
430 | * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within |
||
431 | * the block are disabled at exit. |
||
432 | * Note: Assumes namespace is locked. |
||
433 | * |
||
434 | ******************************************************************************/ |
||
435 | |||
436 | ACPI_STATUS |
||
437 | AcpiEvCreateGpeBlock ( |
||
438 | ACPI_NAMESPACE_NODE *GpeDevice, |
||
439 | ACPI_GENERIC_ADDRESS *GpeBlockAddress, |
||
440 | UINT32 RegisterCount, |
||
441 | UINT8 GpeBlockBaseNumber, |
||
442 | UINT32 InterruptNumber, |
||
443 | ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) |
||
444 | { |
||
445 | ACPI_STATUS Status; |
||
446 | ACPI_GPE_BLOCK_INFO *GpeBlock; |
||
447 | ACPI_GPE_WALK_INFO WalkInfo; |
||
448 | |||
449 | |||
450 | ACPI_FUNCTION_TRACE (EvCreateGpeBlock); |
||
451 | |||
452 | |||
453 | if (!RegisterCount) |
||
454 | { |
||
455 | return_ACPI_STATUS (AE_OK); |
||
456 | } |
||
457 | |||
458 | /* Allocate a new GPE block */ |
||
459 | |||
460 | GpeBlock = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_BLOCK_INFO)); |
||
461 | if (!GpeBlock) |
||
462 | { |
||
463 | return_ACPI_STATUS (AE_NO_MEMORY); |
||
464 | } |
||
465 | |||
466 | /* Initialize the new GPE block */ |
||
467 | |||
468 | GpeBlock->Node = GpeDevice; |
||
469 | GpeBlock->GpeCount = (UINT16) (RegisterCount * ACPI_GPE_REGISTER_WIDTH); |
||
2216 | Serge | 470 | GpeBlock->Initialized = FALSE; |
1498 | serge | 471 | GpeBlock->RegisterCount = RegisterCount; |
472 | GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; |
||
473 | |||
474 | ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, |
||
475 | sizeof (ACPI_GENERIC_ADDRESS)); |
||
476 | |||
477 | /* |
||
478 | * Create the RegisterInfo and EventInfo sub-structures |
||
479 | * Note: disables and clears all GPEs in the block |
||
480 | */ |
||
481 | Status = AcpiEvCreateGpeInfoBlocks (GpeBlock); |
||
482 | if (ACPI_FAILURE (Status)) |
||
483 | { |
||
484 | ACPI_FREE (GpeBlock); |
||
485 | return_ACPI_STATUS (Status); |
||
486 | } |
||
487 | |||
488 | /* Install the new block in the global lists */ |
||
489 | |||
490 | Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber); |
||
491 | if (ACPI_FAILURE (Status)) |
||
492 | { |
||
493 | ACPI_FREE (GpeBlock); |
||
494 | return_ACPI_STATUS (Status); |
||
495 | } |
||
496 | |||
2216 | Serge | 497 | AcpiGbl_AllGpesInitialized = FALSE; |
498 | |||
1498 | serge | 499 | /* Find all GPE methods (_Lxx or_Exx) for this block */ |
500 | |||
501 | WalkInfo.GpeBlock = GpeBlock; |
||
502 | WalkInfo.GpeDevice = GpeDevice; |
||
503 | WalkInfo.ExecuteByOwnerId = FALSE; |
||
504 | |||
505 | Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, |
||
506 | ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, |
||
507 | AcpiEvMatchGpeMethod, NULL, &WalkInfo, NULL); |
||
508 | |||
509 | /* Return the new block */ |
||
510 | |||
511 | if (ReturnGpeBlock) |
||
512 | { |
||
513 | (*ReturnGpeBlock) = GpeBlock; |
||
514 | } |
||
515 | |||
516 | ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
||
517 | "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", |
||
518 | (UINT32) GpeBlock->BlockBaseNumber, |
||
519 | (UINT32) (GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1)), |
||
520 | GpeDevice->Name.Ascii, GpeBlock->RegisterCount, |
||
521 | InterruptNumber)); |
||
522 | |||
523 | /* Update global count of currently available GPEs */ |
||
524 | |||
525 | AcpiCurrentGpeCount += GpeBlock->GpeCount; |
||
526 | return_ACPI_STATUS (AE_OK); |
||
527 | } |
||
528 | |||
529 | |||
530 | /******************************************************************************* |
||
531 | * |
||
532 | * FUNCTION: AcpiEvInitializeGpeBlock |
||
533 | * |
||
2216 | Serge | 534 | * PARAMETERS: ACPI_GPE_CALLBACK |
1498 | serge | 535 | * |
536 | * RETURN: Status |
||
537 | * |
||
2216 | Serge | 538 | * DESCRIPTION: Initialize and enable a GPE block. Enable GPEs that have |
539 | * associated methods. |
||
1498 | serge | 540 | * Note: Assumes namespace is locked. |
541 | * |
||
542 | ******************************************************************************/ |
||
543 | |||
544 | ACPI_STATUS |
||
545 | AcpiEvInitializeGpeBlock ( |
||
2216 | Serge | 546 | ACPI_GPE_XRUPT_INFO *GpeXruptInfo, |
547 | ACPI_GPE_BLOCK_INFO *GpeBlock, |
||
548 | void *Ignored) |
||
1498 | serge | 549 | { |
550 | ACPI_STATUS Status; |
||
551 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
||
552 | UINT32 GpeEnabledCount; |
||
553 | UINT32 GpeIndex; |
||
554 | UINT32 i; |
||
555 | UINT32 j; |
||
556 | |||
557 | |||
558 | ACPI_FUNCTION_TRACE (EvInitializeGpeBlock); |
||
559 | |||
560 | |||
561 | /* |
||
2216 | Serge | 562 | * Ignore a null GPE block (e.g., if no GPE block 1 exists), and |
563 | * any GPE blocks that have been initialized already. |
||
1498 | serge | 564 | */ |
2216 | Serge | 565 | if (!GpeBlock || GpeBlock->Initialized) |
1498 | serge | 566 | { |
2216 | Serge | 567 | return_ACPI_STATUS (AE_OK); |
1498 | serge | 568 | } |
569 | |||
570 | /* |
||
2216 | Serge | 571 | * Enable all GPEs that have a corresponding method and have the |
572 | * ACPI_GPE_CAN_WAKE flag unset. Any other GPEs within this block |
||
573 | * must be enabled via the acpi_enable_gpe() interface. |
||
1498 | serge | 574 | */ |
575 | GpeEnabledCount = 0; |
||
576 | |||
577 | for (i = 0; i < GpeBlock->RegisterCount; i++) |
||
578 | { |
||
579 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) |
||
580 | { |
||
581 | /* Get the info block for this particular GPE */ |
||
582 | |||
583 | GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; |
||
584 | GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; |
||
585 | |||
2216 | Serge | 586 | /* |
587 | * Ignore GPEs that have no corresponding _Lxx/_Exx method |
||
588 | * and GPEs that are used to wake the system |
||
589 | */ |
||
590 | if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_NONE) || |
||
591 | ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) || |
||
592 | (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)) |
||
1498 | serge | 593 | { |
594 | continue; |
||
595 | } |
||
596 | |||
2216 | Serge | 597 | Status = AcpiEvAddGpeReference (GpeEventInfo); |
1498 | serge | 598 | if (ACPI_FAILURE (Status)) |
599 | { |
||
600 | ACPI_EXCEPTION ((AE_INFO, Status, |
||
2216 | Serge | 601 | "Could not enable GPE 0x%02X", |
602 | GpeIndex + GpeBlock->BlockBaseNumber)); |
||
1498 | serge | 603 | continue; |
604 | } |
||
605 | |||
606 | GpeEnabledCount++; |
||
607 | } |
||
608 | } |
||
609 | |||
2216 | Serge | 610 | if (GpeEnabledCount) |
1498 | serge | 611 | { |
612 | ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
||
2216 | Serge | 613 | "Enabled %u GPEs in this block\n", GpeEnabledCount)); |
1498 | serge | 614 | } |
615 | |||
2216 | Serge | 616 | GpeBlock->Initialized = TRUE; |
1498 | serge | 617 | return_ACPI_STATUS (AE_OK); |
618 | }>>>> |
||
619 |