1 /******************************************************************************
2 *
3 * Module Name: evgpeinit - System GPE initialization and update
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45 #include "acpi.h"
46 #include "accommon.h"
47 #include "acevents.h"
48 #include "acnamesp.h"
49
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evgpeinit")
52
53
54 /*
55 * Note: History of _PRW support in ACPICA
56 *
57 * Originally (2000 - 2010), the GPE initialization code performed a walk of
58 * the entire namespace to execute the _PRW methods and detect all GPEs
59 * capable of waking the system.
60 *
61 * As of 10/2010, the _PRW method execution has been removed since it is
62 * actually unnecessary. The host OS must in fact execute all _PRW methods
63 * in order to identify the device/power-resource dependencies. We now put
64 * the onus on the host OS to identify the wake GPEs as part of this process
65 * and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This
66 * not only reduces the complexity of the ACPICA initialization code, but in
67 * some cases (on systems with very large namespaces) it should reduce the
68 * kernel boot time as well.
69 */
70
71 /*******************************************************************************
72 *
76 *
77 * RETURN: Status
78 *
79 * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks
80 *
81 ******************************************************************************/
82
83 ACPI_STATUS
84 AcpiEvGpeInitialize (
85 void)
86 {
87 UINT32 RegisterCount0 = 0;
88 UINT32 RegisterCount1 = 0;
89 UINT32 GpeNumberMax = 0;
90 ACPI_STATUS Status;
91
92
93 ACPI_FUNCTION_TRACE (EvGpeInitialize);
94
95
96 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
97 if (ACPI_FAILURE (Status))
98 {
99 return_ACPI_STATUS (Status);
100 }
101
102 /*
103 * Initialize the GPE Block(s) defined in the FADT
104 *
105 * Why the GPE register block lengths are divided by 2: From the ACPI
106 * Spec, section "General-Purpose Event Registers", we have:
107 *
108 * "Each register block contains two registers of equal length
109 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
110 * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
111 * The length of the GPE1_STS and GPE1_EN registers is equal to
112 * half the GPE1_LEN. If a generic register block is not supported
113 * then its respective block pointer and block length values in the
114 * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
115 * to be the same size."
116 */
117
118 /*
119 * Determine the maximum GPE number for this machine.
120 *
121 * Note: both GPE0 and GPE1 are optional, and either can exist without
122 * the other.
123 *
124 * If EITHER the register length OR the block address are zero, then that
125 * particular block is not supported.
126 */
127 if (AcpiGbl_FADT.Gpe0BlockLength &&
128 AcpiGbl_FADT.XGpe0Block.Address)
129 {
130 /* GPE block 0 exists (has both length and address > 0) */
131
132 RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2);
133
134 GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1;
135
136 /* Install GPE Block 0 */
137
138 Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
139 &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0,
140 AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]);
141
142 if (ACPI_FAILURE (Status))
143 {
144 ACPI_EXCEPTION ((AE_INFO, Status,
145 "Could not create GPE Block 0"));
146 }
147 }
148
149 if (AcpiGbl_FADT.Gpe1BlockLength &&
150 AcpiGbl_FADT.XGpe1Block.Address)
151 {
152 /* GPE block 1 exists (has both length and address > 0) */
153
188 * GPE0 and GPE1 do not have to be contiguous in the GPE number
189 * space. However, GPE0 always starts at GPE number zero.
190 */
191 GpeNumberMax = AcpiGbl_FADT.Gpe1Base +
192 ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1);
193 }
194 }
195
196 /* Exit if there are no GPE registers */
197
198 if ((RegisterCount0 + RegisterCount1) == 0)
199 {
200 /* GPEs are not required by ACPI, this is OK */
201
202 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
203 "There are no GPE blocks defined in the FADT\n"));
204 Status = AE_OK;
205 goto Cleanup;
206 }
207
208 /* Check for Max GPE number out-of-range */
209
210 if (GpeNumberMax > ACPI_GPE_MAX)
211 {
212 ACPI_ERROR ((AE_INFO,
213 "Maximum GPE number from FADT is too large: 0x%X",
214 GpeNumberMax));
215 Status = AE_BAD_VALUE;
216 goto Cleanup;
217 }
218
219 Cleanup:
220 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
221 return_ACPI_STATUS (AE_OK);
222 }
223
224
225 /*******************************************************************************
226 *
227 * FUNCTION: AcpiEvUpdateGpes
228 *
229 * PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table
230 *
231 * RETURN: None
232 *
233 * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
234 * result of a Load() or LoadTable() operation. If new GPE
235 * methods have been installed, register the new methods.
236 *
237 ******************************************************************************/
238
361 *
362 * 1) Extract the method name and null terminate it
363 */
364 ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer);
365 Name[ACPI_NAME_SIZE] = 0;
366
367 /* 2) Name must begin with an underscore */
368
369 if (Name[0] != '_')
370 {
371 return_ACPI_STATUS (AE_OK); /* Ignore this method */
372 }
373
374 /*
375 * 3) Edge/Level determination is based on the 2nd character
376 * of the method name
377 */
378 switch (Name[1])
379 {
380 case 'L':
381 Type = ACPI_GPE_LEVEL_TRIGGERED;
382 break;
383
384 case 'E':
385 Type = ACPI_GPE_EDGE_TRIGGERED;
386 break;
387
388 default:
389 /* Unknown method type, just ignore it */
390
391 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
392 "Ignoring unknown GPE method type: %s "
393 "(name not of form _Lxx or _Exx)", Name));
394 return_ACPI_STATUS (AE_OK);
395 }
396
397 /* 4) The last two characters of the name are the hex GPE Number */
398
399 GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
400 if (GpeNumber == ACPI_UINT32_MAX)
401 {
402 /* Conversion failed; invalid method, just ignore it */
403
404 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
405 "Could not extract GPE number from name: %s "
406 "(name is not of form _Lxx or _Exx)", Name));
407 return_ACPI_STATUS (AE_OK);
408 }
440 ACPI_ERROR ((AE_INFO,
441 "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
442 GpeNumber, GpeNumber, GpeNumber));
443 }
444 return_ACPI_STATUS (AE_OK);
445 }
446
447 /*
448 * Add the GPE information from above to the GpeEventInfo block for
449 * use during dispatch of this GPE.
450 */
451 GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK);
452 GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD);
453 GpeEventInfo->Dispatch.MethodNode = MethodNode;
454
455 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
456 "Registered GPE method %s as GPE number 0x%.2X\n",
457 Name, GpeNumber));
458 return_ACPI_STATUS (AE_OK);
459 }
|
1 /******************************************************************************
2 *
3 * Module Name: evgpeinit - System GPE initialization and update
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45 #include "acpi.h"
46 #include "accommon.h"
47 #include "acevents.h"
48 #include "acnamesp.h"
49
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME ("evgpeinit")
52
53 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54
55 /*
56 * Note: History of _PRW support in ACPICA
57 *
58 * Originally (2000 - 2010), the GPE initialization code performed a walk of
59 * the entire namespace to execute the _PRW methods and detect all GPEs
60 * capable of waking the system.
61 *
62 * As of 10/2010, the _PRW method execution has been removed since it is
63 * actually unnecessary. The host OS must in fact execute all _PRW methods
64 * in order to identify the device/power-resource dependencies. We now put
65 * the onus on the host OS to identify the wake GPEs as part of this process
66 * and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This
67 * not only reduces the complexity of the ACPICA initialization code, but in
68 * some cases (on systems with very large namespaces) it should reduce the
69 * kernel boot time as well.
70 */
71
72 /*******************************************************************************
73 *
77 *
78 * RETURN: Status
79 *
80 * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks
81 *
82 ******************************************************************************/
83
84 ACPI_STATUS
85 AcpiEvGpeInitialize (
86 void)
87 {
88 UINT32 RegisterCount0 = 0;
89 UINT32 RegisterCount1 = 0;
90 UINT32 GpeNumberMax = 0;
91 ACPI_STATUS Status;
92
93
94 ACPI_FUNCTION_TRACE (EvGpeInitialize);
95
96
97 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
98 "Initializing General Purpose Events (GPEs):\n"));
99
100 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
101 if (ACPI_FAILURE (Status))
102 {
103 return_ACPI_STATUS (Status);
104 }
105
106 /*
107 * Initialize the GPE Block(s) defined in the FADT
108 *
109 * Why the GPE register block lengths are divided by 2: From the ACPI
110 * Spec, section "General-Purpose Event Registers", we have:
111 *
112 * "Each register block contains two registers of equal length
113 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
114 * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
115 * The length of the GPE1_STS and GPE1_EN registers is equal to
116 * half the GPE1_LEN. If a generic register block is not supported
117 * then its respective block pointer and block length values in the
118 * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
119 * to be the same size."
120 */
121
122 /*
123 * Determine the maximum GPE number for this machine.
124 *
125 * Note: both GPE0 and GPE1 are optional, and either can exist without
126 * the other.
127 *
128 * If EITHER the register length OR the block address are zero, then that
129 * particular block is not supported.
130 */
131 if (AcpiGbl_FADT.Gpe0BlockLength &&
132 AcpiGbl_FADT.XGpe0Block.Address)
133 {
134 /* GPE block 0 exists (has both length and address > 0) */
135
136 RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2);
137 GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1;
138
139 /* Install GPE Block 0 */
140
141 Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
142 &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0,
143 AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]);
144
145 if (ACPI_FAILURE (Status))
146 {
147 ACPI_EXCEPTION ((AE_INFO, Status,
148 "Could not create GPE Block 0"));
149 }
150 }
151
152 if (AcpiGbl_FADT.Gpe1BlockLength &&
153 AcpiGbl_FADT.XGpe1Block.Address)
154 {
155 /* GPE block 1 exists (has both length and address > 0) */
156
191 * GPE0 and GPE1 do not have to be contiguous in the GPE number
192 * space. However, GPE0 always starts at GPE number zero.
193 */
194 GpeNumberMax = AcpiGbl_FADT.Gpe1Base +
195 ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1);
196 }
197 }
198
199 /* Exit if there are no GPE registers */
200
201 if ((RegisterCount0 + RegisterCount1) == 0)
202 {
203 /* GPEs are not required by ACPI, this is OK */
204
205 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
206 "There are no GPE blocks defined in the FADT\n"));
207 Status = AE_OK;
208 goto Cleanup;
209 }
210
211
212 Cleanup:
213 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
214 return_ACPI_STATUS (AE_OK);
215 }
216
217
218 /*******************************************************************************
219 *
220 * FUNCTION: AcpiEvUpdateGpes
221 *
222 * PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table
223 *
224 * RETURN: None
225 *
226 * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
227 * result of a Load() or LoadTable() operation. If new GPE
228 * methods have been installed, register the new methods.
229 *
230 ******************************************************************************/
231
354 *
355 * 1) Extract the method name and null terminate it
356 */
357 ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer);
358 Name[ACPI_NAME_SIZE] = 0;
359
360 /* 2) Name must begin with an underscore */
361
362 if (Name[0] != '_')
363 {
364 return_ACPI_STATUS (AE_OK); /* Ignore this method */
365 }
366
367 /*
368 * 3) Edge/Level determination is based on the 2nd character
369 * of the method name
370 */
371 switch (Name[1])
372 {
373 case 'L':
374
375 Type = ACPI_GPE_LEVEL_TRIGGERED;
376 break;
377
378 case 'E':
379
380 Type = ACPI_GPE_EDGE_TRIGGERED;
381 break;
382
383 default:
384
385 /* Unknown method type, just ignore it */
386
387 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
388 "Ignoring unknown GPE method type: %s "
389 "(name not of form _Lxx or _Exx)", Name));
390 return_ACPI_STATUS (AE_OK);
391 }
392
393 /* 4) The last two characters of the name are the hex GPE Number */
394
395 GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
396 if (GpeNumber == ACPI_UINT32_MAX)
397 {
398 /* Conversion failed; invalid method, just ignore it */
399
400 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
401 "Could not extract GPE number from name: %s "
402 "(name is not of form _Lxx or _Exx)", Name));
403 return_ACPI_STATUS (AE_OK);
404 }
436 ACPI_ERROR ((AE_INFO,
437 "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
438 GpeNumber, GpeNumber, GpeNumber));
439 }
440 return_ACPI_STATUS (AE_OK);
441 }
442
443 /*
444 * Add the GPE information from above to the GpeEventInfo block for
445 * use during dispatch of this GPE.
446 */
447 GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK);
448 GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD);
449 GpeEventInfo->Dispatch.MethodNode = MethodNode;
450
451 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
452 "Registered GPE method %s as GPE number 0x%.2X\n",
453 Name, GpeNumber));
454 return_ACPI_STATUS (AE_OK);
455 }
456
457 #endif /* !ACPI_REDUCED_HARDWARE */
|