evgpeinit.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: evgpeinit - System GPE initialization and update
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer
45 1.1.1.2.2.2 bouyer #include "acpi.h"
46 1.1.1.2.2.2 bouyer #include "accommon.h"
47 1.1.1.2.2.2 bouyer #include "acevents.h"
48 1.1.1.2.2.2 bouyer #include "acnamesp.h"
49 1.1.1.2.2.2 bouyer
50 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_EVENTS
51 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("evgpeinit")
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer /*
55 1.1.1.2.2.2 bouyer * Note: History of _PRW support in ACPICA
56 1.1.1.2.2.2 bouyer *
57 1.1.1.2.2.2 bouyer * Originally (2000 - 2010), the GPE initialization code performed a walk of
58 1.1.1.2.2.2 bouyer * the entire namespace to execute the _PRW methods and detect all GPEs
59 1.1.1.2.2.2 bouyer * capable of waking the system.
60 1.1.1.2.2.2 bouyer *
61 1.1.1.2.2.2 bouyer * As of 10/2010, the _PRW method execution has been removed since it is
62 1.1.1.2.2.2 bouyer * actually unnecessary. The host OS must in fact execute all _PRW methods
63 1.1.1.2.2.2 bouyer * in order to identify the device/power-resource dependencies. We now put
64 1.1.1.2.2.2 bouyer * the onus on the host OS to identify the wake GPEs as part of this process
65 1.1.1.2.2.2 bouyer * and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This
66 1.1.1.2.2.2 bouyer * not only reduces the complexity of the ACPICA initialization code, but in
67 1.1.1.2.2.2 bouyer * some cases (on systems with very large namespaces) it should reduce the
68 1.1.1.2.2.2 bouyer * kernel boot time as well.
69 1.1.1.2.2.2 bouyer */
70 1.1.1.2.2.2 bouyer
71 1.1.1.2.2.2 bouyer /*******************************************************************************
72 1.1.1.2.2.2 bouyer *
73 1.1.1.2.2.2 bouyer * FUNCTION: AcpiEvGpeInitialize
74 1.1.1.2.2.2 bouyer *
75 1.1.1.2.2.2 bouyer * PARAMETERS: None
76 1.1.1.2.2.2 bouyer *
77 1.1.1.2.2.2 bouyer * RETURN: Status
78 1.1.1.2.2.2 bouyer *
79 1.1.1.2.2.2 bouyer * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks
80 1.1.1.2.2.2 bouyer *
81 1.1.1.2.2.2 bouyer ******************************************************************************/
82 1.1.1.2.2.2 bouyer
83 1.1.1.2.2.2 bouyer ACPI_STATUS
84 1.1.1.2.2.2 bouyer AcpiEvGpeInitialize (
85 1.1.1.2.2.2 bouyer void)
86 1.1.1.2.2.2 bouyer {
87 1.1.1.2.2.2 bouyer UINT32 RegisterCount0 = 0;
88 1.1.1.2.2.2 bouyer UINT32 RegisterCount1 = 0;
89 1.1.1.2.2.2 bouyer UINT32 GpeNumberMax = 0;
90 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
91 1.1.1.2.2.2 bouyer
92 1.1.1.2.2.2 bouyer
93 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (EvGpeInitialize);
94 1.1.1.2.2.2 bouyer
95 1.1.1.2.2.2 bouyer
96 1.1.1.2.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
97 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
98 1.1.1.2.2.2 bouyer {
99 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
100 1.1.1.2.2.2 bouyer }
101 1.1.1.2.2.2 bouyer
102 1.1.1.2.2.2 bouyer /*
103 1.1.1.2.2.2 bouyer * Initialize the GPE Block(s) defined in the FADT
104 1.1.1.2.2.2 bouyer *
105 1.1.1.2.2.2 bouyer * Why the GPE register block lengths are divided by 2: From the ACPI
106 1.1.1.2.2.2 bouyer * Spec, section "General-Purpose Event Registers", we have:
107 1.1.1.2.2.2 bouyer *
108 1.1.1.2.2.2 bouyer * "Each register block contains two registers of equal length
109 1.1.1.2.2.2 bouyer * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
110 1.1.1.2.2.2 bouyer * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
111 1.1.1.2.2.2 bouyer * The length of the GPE1_STS and GPE1_EN registers is equal to
112 1.1.1.2.2.2 bouyer * half the GPE1_LEN. If a generic register block is not supported
113 1.1.1.2.2.2 bouyer * then its respective block pointer and block length values in the
114 1.1.1.2.2.2 bouyer * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
115 1.1.1.2.2.2 bouyer * to be the same size."
116 1.1.1.2.2.2 bouyer */
117 1.1.1.2.2.2 bouyer
118 1.1.1.2.2.2 bouyer /*
119 1.1.1.2.2.2 bouyer * Determine the maximum GPE number for this machine.
120 1.1.1.2.2.2 bouyer *
121 1.1.1.2.2.2 bouyer * Note: both GPE0 and GPE1 are optional, and either can exist without
122 1.1.1.2.2.2 bouyer * the other.
123 1.1.1.2.2.2 bouyer *
124 1.1.1.2.2.2 bouyer * If EITHER the register length OR the block address are zero, then that
125 1.1.1.2.2.2 bouyer * particular block is not supported.
126 1.1.1.2.2.2 bouyer */
127 1.1.1.2.2.2 bouyer if (AcpiGbl_FADT.Gpe0BlockLength &&
128 1.1.1.2.2.2 bouyer AcpiGbl_FADT.XGpe0Block.Address)
129 1.1.1.2.2.2 bouyer {
130 1.1.1.2.2.2 bouyer /* GPE block 0 exists (has both length and address > 0) */
131 1.1.1.2.2.2 bouyer
132 1.1.1.2.2.2 bouyer RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2);
133 1.1.1.2.2.2 bouyer
134 1.1.1.2.2.2 bouyer GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1;
135 1.1.1.2.2.2 bouyer
136 1.1.1.2.2.2 bouyer /* Install GPE Block 0 */
137 1.1.1.2.2.2 bouyer
138 1.1.1.2.2.2 bouyer Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
139 1.1.1.2.2.2 bouyer &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0,
140 1.1.1.2.2.2 bouyer AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]);
141 1.1.1.2.2.2 bouyer
142 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
143 1.1.1.2.2.2 bouyer {
144 1.1.1.2.2.2 bouyer ACPI_EXCEPTION ((AE_INFO, Status,
145 1.1.1.2.2.2 bouyer "Could not create GPE Block 0"));
146 1.1.1.2.2.2 bouyer }
147 1.1.1.2.2.2 bouyer }
148 1.1.1.2.2.2 bouyer
149 1.1.1.2.2.2 bouyer if (AcpiGbl_FADT.Gpe1BlockLength &&
150 1.1.1.2.2.2 bouyer AcpiGbl_FADT.XGpe1Block.Address)
151 1.1.1.2.2.2 bouyer {
152 1.1.1.2.2.2 bouyer /* GPE block 1 exists (has both length and address > 0) */
153 1.1.1.2.2.2 bouyer
154 1.1.1.2.2.2 bouyer RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2);
155 1.1.1.2.2.2 bouyer
156 1.1.1.2.2.2 bouyer /* Check for GPE0/GPE1 overlap (if both banks exist) */
157 1.1.1.2.2.2 bouyer
158 1.1.1.2.2.2 bouyer if ((RegisterCount0) &&
159 1.1.1.2.2.2 bouyer (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base))
160 1.1.1.2.2.2 bouyer {
161 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
162 1.1.1.2.2.2 bouyer "GPE0 block (GPE 0 to %u) overlaps the GPE1 block "
163 1.1.1.2.2.2 bouyer "(GPE %u to %u) - Ignoring GPE1",
164 1.1.1.2.2.2 bouyer GpeNumberMax, AcpiGbl_FADT.Gpe1Base,
165 1.1.1.2.2.2 bouyer AcpiGbl_FADT.Gpe1Base +
166 1.1.1.2.2.2 bouyer ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
167 1.1.1.2.2.2 bouyer
168 1.1.1.2.2.2 bouyer /* Ignore GPE1 block by setting the register count to zero */
169 1.1.1.2.2.2 bouyer
170 1.1.1.2.2.2 bouyer RegisterCount1 = 0;
171 1.1.1.2.2.2 bouyer }
172 1.1.1.2.2.2 bouyer else
173 1.1.1.2.2.2 bouyer {
174 1.1.1.2.2.2 bouyer /* Install GPE Block 1 */
175 1.1.1.2.2.2 bouyer
176 1.1.1.2.2.2 bouyer Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
177 1.1.1.2.2.2 bouyer &AcpiGbl_FADT.XGpe1Block, RegisterCount1,
178 1.1.1.2.2.2 bouyer AcpiGbl_FADT.Gpe1Base,
179 1.1.1.2.2.2 bouyer AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]);
180 1.1.1.2.2.2 bouyer
181 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
182 1.1.1.2.2.2 bouyer {
183 1.1.1.2.2.2 bouyer ACPI_EXCEPTION ((AE_INFO, Status,
184 1.1.1.2.2.2 bouyer "Could not create GPE Block 1"));
185 1.1.1.2.2.2 bouyer }
186 1.1.1.2.2.2 bouyer
187 1.1.1.2.2.2 bouyer /*
188 1.1.1.2.2.2 bouyer * GPE0 and GPE1 do not have to be contiguous in the GPE number
189 1.1.1.2.2.2 bouyer * space. However, GPE0 always starts at GPE number zero.
190 1.1.1.2.2.2 bouyer */
191 1.1.1.2.2.2 bouyer GpeNumberMax = AcpiGbl_FADT.Gpe1Base +
192 1.1.1.2.2.2 bouyer ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1);
193 1.1.1.2.2.2 bouyer }
194 1.1.1.2.2.2 bouyer }
195 1.1.1.2.2.2 bouyer
196 1.1.1.2.2.2 bouyer /* Exit if there are no GPE registers */
197 1.1.1.2.2.2 bouyer
198 1.1.1.2.2.2 bouyer if ((RegisterCount0 + RegisterCount1) == 0)
199 1.1.1.2.2.2 bouyer {
200 1.1.1.2.2.2 bouyer /* GPEs are not required by ACPI, this is OK */
201 1.1.1.2.2.2 bouyer
202 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
203 1.1.1.2.2.2 bouyer "There are no GPE blocks defined in the FADT\n"));
204 1.1.1.2.2.2 bouyer Status = AE_OK;
205 1.1.1.2.2.2 bouyer goto Cleanup;
206 1.1.1.2.2.2 bouyer }
207 1.1.1.2.2.2 bouyer
208 1.1.1.2.2.2 bouyer /* Check for Max GPE number out-of-range */
209 1.1.1.2.2.2 bouyer
210 1.1.1.2.2.2 bouyer if (GpeNumberMax > ACPI_GPE_MAX)
211 1.1.1.2.2.2 bouyer {
212 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
213 1.1.1.2.2.2 bouyer "Maximum GPE number from FADT is too large: 0x%X",
214 1.1.1.2.2.2 bouyer GpeNumberMax));
215 1.1.1.2.2.2 bouyer Status = AE_BAD_VALUE;
216 1.1.1.2.2.2 bouyer goto Cleanup;
217 1.1.1.2.2.2 bouyer }
218 1.1.1.2.2.2 bouyer
219 1.1.1.2.2.2 bouyer Cleanup:
220 1.1.1.2.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
221 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
222 1.1.1.2.2.2 bouyer }
223 1.1.1.2.2.2 bouyer
224 1.1.1.2.2.2 bouyer
225 1.1.1.2.2.2 bouyer /*******************************************************************************
226 1.1.1.2.2.2 bouyer *
227 1.1.1.2.2.2 bouyer * FUNCTION: AcpiEvUpdateGpes
228 1.1.1.2.2.2 bouyer *
229 1.1.1.2.2.2 bouyer * PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table
230 1.1.1.2.2.2 bouyer *
231 1.1.1.2.2.2 bouyer * RETURN: None
232 1.1.1.2.2.2 bouyer *
233 1.1.1.2.2.2 bouyer * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
234 1.1.1.2.2.2 bouyer * result of a Load() or LoadTable() operation. If new GPE
235 1.1.1.2.2.2 bouyer * methods have been installed, register the new methods.
236 1.1.1.2.2.2 bouyer *
237 1.1.1.2.2.2 bouyer ******************************************************************************/
238 1.1.1.2.2.2 bouyer
239 1.1.1.2.2.2 bouyer void
240 1.1.1.2.2.2 bouyer AcpiEvUpdateGpes (
241 1.1.1.2.2.2 bouyer ACPI_OWNER_ID TableOwnerId)
242 1.1.1.2.2.2 bouyer {
243 1.1.1.2.2.2 bouyer ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
244 1.1.1.2.2.2 bouyer ACPI_GPE_BLOCK_INFO *GpeBlock;
245 1.1.1.2.2.2 bouyer ACPI_GPE_WALK_INFO WalkInfo;
246 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
247 1.1.1.2.2.2 bouyer
248 1.1.1.2.2.2 bouyer
249 1.1.1.2.2.2 bouyer /*
250 1.1.1.2.2.2 bouyer * Find any _Lxx/_Exx GPE methods that have just been loaded.
251 1.1.1.2.2.2 bouyer *
252 1.1.1.2.2.2 bouyer * Any GPEs that correspond to new _Lxx/_Exx methods are immediately
253 1.1.1.2.2.2 bouyer * enabled.
254 1.1.1.2.2.2 bouyer *
255 1.1.1.2.2.2 bouyer * Examine the namespace underneath each GpeDevice within the
256 1.1.1.2.2.2 bouyer * GpeBlock lists.
257 1.1.1.2.2.2 bouyer */
258 1.1.1.2.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
259 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
260 1.1.1.2.2.2 bouyer {
261 1.1.1.2.2.2 bouyer return;
262 1.1.1.2.2.2 bouyer }
263 1.1.1.2.2.2 bouyer
264 1.1.1.2.2.2 bouyer WalkInfo.Count = 0;
265 1.1.1.2.2.2 bouyer WalkInfo.OwnerId = TableOwnerId;
266 1.1.1.2.2.2 bouyer WalkInfo.ExecuteByOwnerId = TRUE;
267 1.1.1.2.2.2 bouyer
268 1.1.1.2.2.2 bouyer /* Walk the interrupt level descriptor list */
269 1.1.1.2.2.2 bouyer
270 1.1.1.2.2.2 bouyer GpeXruptInfo = AcpiGbl_GpeXruptListHead;
271 1.1.1.2.2.2 bouyer while (GpeXruptInfo)
272 1.1.1.2.2.2 bouyer {
273 1.1.1.2.2.2 bouyer /* Walk all Gpe Blocks attached to this interrupt level */
274 1.1.1.2.2.2 bouyer
275 1.1.1.2.2.2 bouyer GpeBlock = GpeXruptInfo->GpeBlockListHead;
276 1.1.1.2.2.2 bouyer while (GpeBlock)
277 1.1.1.2.2.2 bouyer {
278 1.1.1.2.2.2 bouyer WalkInfo.GpeBlock = GpeBlock;
279 1.1.1.2.2.2 bouyer WalkInfo.GpeDevice = GpeBlock->Node;
280 1.1.1.2.2.2 bouyer
281 1.1.1.2.2.2 bouyer Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD,
282 1.1.1.2.2.2 bouyer WalkInfo.GpeDevice, ACPI_UINT32_MAX,
283 1.1.1.2.2.2 bouyer ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod,
284 1.1.1.2.2.2 bouyer NULL, &WalkInfo, NULL);
285 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
286 1.1.1.2.2.2 bouyer {
287 1.1.1.2.2.2 bouyer ACPI_EXCEPTION ((AE_INFO, Status,
288 1.1.1.2.2.2 bouyer "While decoding _Lxx/_Exx methods"));
289 1.1.1.2.2.2 bouyer }
290 1.1.1.2.2.2 bouyer
291 1.1.1.2.2.2 bouyer GpeBlock = GpeBlock->Next;
292 1.1.1.2.2.2 bouyer }
293 1.1.1.2.2.2 bouyer
294 1.1.1.2.2.2 bouyer GpeXruptInfo = GpeXruptInfo->Next;
295 1.1.1.2.2.2 bouyer }
296 1.1.1.2.2.2 bouyer
297 1.1.1.2.2.2 bouyer if (WalkInfo.Count)
298 1.1.1.2.2.2 bouyer {
299 1.1.1.2.2.2 bouyer ACPI_INFO ((AE_INFO, "Enabled %u new GPEs", WalkInfo.Count));
300 1.1.1.2.2.2 bouyer }
301 1.1.1.2.2.2 bouyer
302 1.1.1.2.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
303 1.1.1.2.2.2 bouyer return;
304 1.1.1.2.2.2 bouyer }
305 1.1.1.2.2.2 bouyer
306 1.1.1.2.2.2 bouyer
307 1.1.1.2.2.2 bouyer /*******************************************************************************
308 1.1.1.2.2.2 bouyer *
309 1.1.1.2.2.2 bouyer * FUNCTION: AcpiEvMatchGpeMethod
310 1.1.1.2.2.2 bouyer *
311 1.1.1.2.2.2 bouyer * PARAMETERS: Callback from WalkNamespace
312 1.1.1.2.2.2 bouyer *
313 1.1.1.2.2.2 bouyer * RETURN: Status
314 1.1.1.2.2.2 bouyer *
315 1.1.1.2.2.2 bouyer * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a
316 1.1.1.2.2.2 bouyer * control method under the _GPE portion of the namespace.
317 1.1.1.2.2.2 bouyer * Extract the name and GPE type from the object, saving this
318 1.1.1.2.2.2 bouyer * information for quick lookup during GPE dispatch. Allows a
319 1.1.1.2.2.2 bouyer * per-OwnerId evaluation if ExecuteByOwnerId is TRUE in the
320 1.1.1.2.2.2 bouyer * WalkInfo parameter block.
321 1.1.1.2.2.2 bouyer *
322 1.1.1.2.2.2 bouyer * The name of each GPE control method is of the form:
323 1.1.1.2.2.2 bouyer * "_Lxx" or "_Exx", where:
324 1.1.1.2.2.2 bouyer * L - means that the GPE is level triggered
325 1.1.1.2.2.2 bouyer * E - means that the GPE is edge triggered
326 1.1.1.2.2.2 bouyer * xx - is the GPE number [in HEX]
327 1.1.1.2.2.2 bouyer *
328 1.1.1.2.2.2 bouyer * If WalkInfo->ExecuteByOwnerId is TRUE, we only execute examine GPE methods
329 1.1.1.2.2.2 bouyer * with that owner.
330 1.1.1.2.2.2 bouyer *
331 1.1.1.2.2.2 bouyer ******************************************************************************/
332 1.1.1.2.2.2 bouyer
333 1.1.1.2.2.2 bouyer ACPI_STATUS
334 1.1.1.2.2.2 bouyer AcpiEvMatchGpeMethod (
335 1.1.1.2.2.2 bouyer ACPI_HANDLE ObjHandle,
336 1.1.1.2.2.2 bouyer UINT32 Level,
337 1.1.1.2.2.2 bouyer void *Context,
338 1.1.1.2.2.2 bouyer void **ReturnValue)
339 1.1.1.2.2.2 bouyer {
340 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
341 1.1.1.2.2.2 bouyer ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context);
342 1.1.1.2.2.2 bouyer ACPI_GPE_EVENT_INFO *GpeEventInfo;
343 1.1.1.2.2.2 bouyer UINT32 GpeNumber;
344 1.1.1.2.2.2 bouyer char Name[ACPI_NAME_SIZE + 1];
345 1.1.1.2.2.2 bouyer UINT8 Type;
346 1.1.1.2.2.2 bouyer
347 1.1.1.2.2.2 bouyer
348 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (EvMatchGpeMethod);
349 1.1.1.2.2.2 bouyer
350 1.1.1.2.2.2 bouyer
351 1.1.1.2.2.2 bouyer /* Check if requested OwnerId matches this OwnerId */
352 1.1.1.2.2.2 bouyer
353 1.1.1.2.2.2 bouyer if ((WalkInfo->ExecuteByOwnerId) &&
354 1.1.1.2.2.2 bouyer (MethodNode->OwnerId != WalkInfo->OwnerId))
355 1.1.1.2.2.2 bouyer {
356 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
357 1.1.1.2.2.2 bouyer }
358 1.1.1.2.2.2 bouyer
359 1.1.1.2.2.2 bouyer /*
360 1.1.1.2.2.2 bouyer * Match and decode the _Lxx and _Exx GPE method names
361 1.1.1.2.2.2 bouyer *
362 1.1.1.2.2.2 bouyer * 1) Extract the method name and null terminate it
363 1.1.1.2.2.2 bouyer */
364 1.1.1.2.2.2 bouyer ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer);
365 1.1.1.2.2.2 bouyer Name[ACPI_NAME_SIZE] = 0;
366 1.1.1.2.2.2 bouyer
367 1.1.1.2.2.2 bouyer /* 2) Name must begin with an underscore */
368 1.1.1.2.2.2 bouyer
369 1.1.1.2.2.2 bouyer if (Name[0] != '_')
370 1.1.1.2.2.2 bouyer {
371 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK); /* Ignore this method */
372 1.1.1.2.2.2 bouyer }
373 1.1.1.2.2.2 bouyer
374 1.1.1.2.2.2 bouyer /*
375 1.1.1.2.2.2 bouyer * 3) Edge/Level determination is based on the 2nd character
376 1.1.1.2.2.2 bouyer * of the method name
377 1.1.1.2.2.2 bouyer */
378 1.1.1.2.2.2 bouyer switch (Name[1])
379 1.1.1.2.2.2 bouyer {
380 1.1.1.2.2.2 bouyer case 'L':
381 1.1.1.2.2.2 bouyer Type = ACPI_GPE_LEVEL_TRIGGERED;
382 1.1.1.2.2.2 bouyer break;
383 1.1.1.2.2.2 bouyer
384 1.1.1.2.2.2 bouyer case 'E':
385 1.1.1.2.2.2 bouyer Type = ACPI_GPE_EDGE_TRIGGERED;
386 1.1.1.2.2.2 bouyer break;
387 1.1.1.2.2.2 bouyer
388 1.1.1.2.2.2 bouyer default:
389 1.1.1.2.2.2 bouyer /* Unknown method type, just ignore it */
390 1.1.1.2.2.2 bouyer
391 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
392 1.1.1.2.2.2 bouyer "Ignoring unknown GPE method type: %s "
393 1.1.1.2.2.2 bouyer "(name not of form _Lxx or _Exx)", Name));
394 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
395 1.1.1.2.2.2 bouyer }
396 1.1.1.2.2.2 bouyer
397 1.1.1.2.2.2 bouyer /* 4) The last two characters of the name are the hex GPE Number */
398 1.1.1.2.2.2 bouyer
399 1.1.1.2.2.2 bouyer GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
400 1.1.1.2.2.2 bouyer if (GpeNumber == ACPI_UINT32_MAX)
401 1.1.1.2.2.2 bouyer {
402 1.1.1.2.2.2 bouyer /* Conversion failed; invalid method, just ignore it */
403 1.1.1.2.2.2 bouyer
404 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
405 1.1.1.2.2.2 bouyer "Could not extract GPE number from name: %s "
406 1.1.1.2.2.2 bouyer "(name is not of form _Lxx or _Exx)", Name));
407 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
408 1.1.1.2.2.2 bouyer }
409 1.1.1.2.2.2 bouyer
410 1.1.1.2.2.2 bouyer /* Ensure that we have a valid GPE number for this GPE block */
411 1.1.1.2.2.2 bouyer
412 1.1.1.2.2.2 bouyer GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock);
413 1.1.1.2.2.2 bouyer if (!GpeEventInfo)
414 1.1.1.2.2.2 bouyer {
415 1.1.1.2.2.2 bouyer /*
416 1.1.1.2.2.2 bouyer * This GpeNumber is not valid for this GPE block, just ignore it.
417 1.1.1.2.2.2 bouyer * However, it may be valid for a different GPE block, since GPE0
418 1.1.1.2.2.2 bouyer * and GPE1 methods both appear under \_GPE.
419 1.1.1.2.2.2 bouyer */
420 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
421 1.1.1.2.2.2 bouyer }
422 1.1.1.2.2.2 bouyer
423 1.1.1.2.2.2 bouyer if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
424 1.1.1.2.2.2 bouyer ACPI_GPE_DISPATCH_HANDLER)
425 1.1.1.2.2.2 bouyer {
426 1.1.1.2.2.2 bouyer /* If there is already a handler, ignore this GPE method */
427 1.1.1.2.2.2 bouyer
428 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
429 1.1.1.2.2.2 bouyer }
430 1.1.1.2.2.2 bouyer
431 1.1.1.2.2.2 bouyer if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
432 1.1.1.2.2.2 bouyer ACPI_GPE_DISPATCH_METHOD)
433 1.1.1.2.2.2 bouyer {
434 1.1.1.2.2.2 bouyer /*
435 1.1.1.2.2.2 bouyer * If there is already a method, ignore this method. But check
436 1.1.1.2.2.2 bouyer * for a type mismatch (if both the _Lxx AND _Exx exist)
437 1.1.1.2.2.2 bouyer */
438 1.1.1.2.2.2 bouyer if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK))
439 1.1.1.2.2.2 bouyer {
440 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
441 1.1.1.2.2.2 bouyer "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
442 1.1.1.2.2.2 bouyer GpeNumber, GpeNumber, GpeNumber));
443 1.1.1.2.2.2 bouyer }
444 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
445 1.1.1.2.2.2 bouyer }
446 1.1.1.2.2.2 bouyer
447 1.1.1.2.2.2 bouyer /*
448 1.1.1.2.2.2 bouyer * Add the GPE information from above to the GpeEventInfo block for
449 1.1.1.2.2.2 bouyer * use during dispatch of this GPE.
450 1.1.1.2.2.2 bouyer */
451 1.1.1.2.2.2 bouyer GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK);
452 1.1.1.2.2.2 bouyer GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD);
453 1.1.1.2.2.2 bouyer GpeEventInfo->Dispatch.MethodNode = MethodNode;
454 1.1.1.2.2.2 bouyer
455 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
456 1.1.1.2.2.2 bouyer "Registered GPE method %s as GPE number 0x%.2X\n",
457 1.1.1.2.2.2 bouyer Name, GpeNumber));
458 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
459 1.1.1.2.2.2 bouyer }
460