aslresource.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind
2 1.1.1.2.4.2 rmind /******************************************************************************
3 1.1.1.2.4.2 rmind *
4 1.1.1.2.4.2 rmind * Module Name: aslresource - Resource template/descriptor utilities
5 1.1.1.2.4.2 rmind *
6 1.1.1.2.4.2 rmind *****************************************************************************/
7 1.1.1.2.4.2 rmind
8 1.1.1.2.4.2 rmind /*
9 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
10 1.1.1.2.4.2 rmind * All rights reserved.
11 1.1.1.2.4.2 rmind *
12 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
13 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
14 1.1.1.2.4.2 rmind * are met:
15 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
16 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
17 1.1.1.2.4.2 rmind * without modification.
18 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
20 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
21 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
22 1.1.1.2.4.2 rmind * binary redistribution.
23 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
24 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
25 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
26 1.1.1.2.4.2 rmind *
27 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
28 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
29 1.1.1.2.4.2 rmind * Software Foundation.
30 1.1.1.2.4.2 rmind *
31 1.1.1.2.4.2 rmind * NO WARRANTY
32 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
43 1.1.1.2.4.2 rmind */
44 1.1.1.2.4.2 rmind
45 1.1.1.2.4.2 rmind
46 1.1.1.2.4.2 rmind #include "aslcompiler.h"
47 1.1.1.2.4.2 rmind #include "aslcompiler.y.h"
48 1.1.1.2.4.2 rmind #include "amlcode.h"
49 1.1.1.2.4.2 rmind
50 1.1.1.2.4.2 rmind
51 1.1.1.2.4.2 rmind #define _COMPONENT ACPI_COMPILER
52 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("aslresource")
53 1.1.1.2.4.2 rmind
54 1.1.1.2.4.2 rmind
55 1.1.1.2.4.2 rmind /*******************************************************************************
56 1.1.1.2.4.2 rmind *
57 1.1.1.2.4.2 rmind * FUNCTION: RsSmallAddressCheck
58 1.1.1.2.4.2 rmind *
59 1.1.1.2.4.2 rmind * PARAMETERS: Minimum - Address Min value
60 1.1.1.2.4.2 rmind * Maximum - Address Max value
61 1.1.1.2.4.2 rmind * Length - Address range value
62 1.1.1.2.4.2 rmind * Alignment - Address alignment value
63 1.1.1.2.4.2 rmind * MinOp - Original Op for Address Min
64 1.1.1.2.4.2 rmind * MaxOp - Original Op for Address Max
65 1.1.1.2.4.2 rmind * LengthOp - Original Op for address range
66 1.1.1.2.4.2 rmind * AlignOp - Original Op for address alignment. If
67 1.1.1.2.4.2 rmind * NULL, means "zero value for alignment is
68 1.1.1.2.4.2 rmind * OK, and means 64K alignment" (for
69 1.1.1.2.4.2 rmind * Memory24 descriptor)
70 1.1.1.2.4.2 rmind * Op - Parent Op for entire construct
71 1.1.1.2.4.2 rmind *
72 1.1.1.2.4.2 rmind * RETURN: None. Adds error messages to error log if necessary
73 1.1.1.2.4.2 rmind *
74 1.1.1.2.4.2 rmind * DESCRIPTION: Perform common value checks for "small" address descriptors.
75 1.1.1.2.4.2 rmind * Currently:
76 1.1.1.2.4.2 rmind * Io, Memory24, Memory32
77 1.1.1.2.4.2 rmind *
78 1.1.1.2.4.2 rmind ******************************************************************************/
79 1.1.1.2.4.2 rmind
80 1.1.1.2.4.2 rmind void
81 1.1.1.2.4.2 rmind RsSmallAddressCheck (
82 1.1.1.2.4.2 rmind UINT8 Type,
83 1.1.1.2.4.2 rmind UINT32 Minimum,
84 1.1.1.2.4.2 rmind UINT32 Maximum,
85 1.1.1.2.4.2 rmind UINT32 Length,
86 1.1.1.2.4.2 rmind UINT32 Alignment,
87 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *MinOp,
88 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *MaxOp,
89 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *LengthOp,
90 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *AlignOp,
91 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
92 1.1.1.2.4.2 rmind {
93 1.1.1.2.4.2 rmind
94 1.1.1.2.4.2 rmind if (Gbl_NoResourceChecking)
95 1.1.1.2.4.2 rmind {
96 1.1.1.2.4.2 rmind return;
97 1.1.1.2.4.2 rmind }
98 1.1.1.2.4.2 rmind
99 1.1.1.2.4.2 rmind /*
100 1.1.1.2.4.2 rmind * Check for a so-called "null descriptor". These are descriptors that are
101 1.1.1.2.4.2 rmind * created with most fields set to zero. The intent is that the descriptor
102 1.1.1.2.4.2 rmind * will be updated/completed at runtime via a BufferField.
103 1.1.1.2.4.2 rmind *
104 1.1.1.2.4.2 rmind * If the descriptor does NOT have a resource tag, it cannot be referenced
105 1.1.1.2.4.2 rmind * by a BufferField and we will flag this as an error. Conversely, if
106 1.1.1.2.4.2 rmind * the descriptor has a resource tag, we will assume that a BufferField
107 1.1.1.2.4.2 rmind * will be used to dynamically update it, so no error.
108 1.1.1.2.4.2 rmind *
109 1.1.1.2.4.2 rmind * A possible enhancement to this check would be to verify that in fact
110 1.1.1.2.4.2 rmind * a BufferField is created using the resource tag, and perhaps even
111 1.1.1.2.4.2 rmind * verify that a Store is performed to the BufferField.
112 1.1.1.2.4.2 rmind *
113 1.1.1.2.4.2 rmind * Note: for these descriptors, Alignment is allowed to be zero
114 1.1.1.2.4.2 rmind */
115 1.1.1.2.4.2 rmind if (!Minimum && !Maximum && !Length)
116 1.1.1.2.4.2 rmind {
117 1.1.1.2.4.2 rmind if (!Op->Asl.ExternalName)
118 1.1.1.2.4.2 rmind {
119 1.1.1.2.4.2 rmind /* No resource tag. Descriptor is fixed and is also illegal */
120 1.1.1.2.4.2 rmind
121 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL);
122 1.1.1.2.4.2 rmind }
123 1.1.1.2.4.2 rmind
124 1.1.1.2.4.2 rmind return;
125 1.1.1.2.4.2 rmind }
126 1.1.1.2.4.2 rmind
127 1.1.1.2.4.2 rmind /* Special case for Memory24, values are compressed */
128 1.1.1.2.4.2 rmind
129 1.1.1.2.4.2 rmind if (Type == ACPI_RESOURCE_NAME_MEMORY24)
130 1.1.1.2.4.2 rmind {
131 1.1.1.2.4.2 rmind if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */
132 1.1.1.2.4.2 rmind {
133 1.1.1.2.4.2 rmind Alignment = ACPI_UINT16_MAX + 1;
134 1.1.1.2.4.2 rmind }
135 1.1.1.2.4.2 rmind
136 1.1.1.2.4.2 rmind Minimum <<= 8;
137 1.1.1.2.4.2 rmind Maximum <<= 8;
138 1.1.1.2.4.2 rmind Length *= 256;
139 1.1.1.2.4.2 rmind }
140 1.1.1.2.4.2 rmind
141 1.1.1.2.4.2 rmind /* IO descriptor has different definition of min/max, don't check */
142 1.1.1.2.4.2 rmind
143 1.1.1.2.4.2 rmind if (Type != ACPI_RESOURCE_NAME_IO)
144 1.1.1.2.4.2 rmind {
145 1.1.1.2.4.2 rmind /* Basic checks on Min/Max/Length */
146 1.1.1.2.4.2 rmind
147 1.1.1.2.4.2 rmind if (Minimum > Maximum)
148 1.1.1.2.4.2 rmind {
149 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL);
150 1.1.1.2.4.2 rmind }
151 1.1.1.2.4.2 rmind else if (Length > (Maximum - Minimum + 1))
152 1.1.1.2.4.2 rmind {
153 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL);
154 1.1.1.2.4.2 rmind }
155 1.1.1.2.4.2 rmind }
156 1.1.1.2.4.2 rmind
157 1.1.1.2.4.2 rmind /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */
158 1.1.1.2.4.2 rmind
159 1.1.1.2.4.2 rmind if (!Alignment)
160 1.1.1.2.4.2 rmind {
161 1.1.1.2.4.2 rmind Alignment = 1;
162 1.1.1.2.4.2 rmind }
163 1.1.1.2.4.2 rmind
164 1.1.1.2.4.2 rmind /* Addresses must be an exact multiple of the alignment value */
165 1.1.1.2.4.2 rmind
166 1.1.1.2.4.2 rmind if (Minimum % Alignment)
167 1.1.1.2.4.2 rmind {
168 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL);
169 1.1.1.2.4.2 rmind }
170 1.1.1.2.4.2 rmind if (Maximum % Alignment)
171 1.1.1.2.4.2 rmind {
172 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, NULL);
173 1.1.1.2.4.2 rmind }
174 1.1.1.2.4.2 rmind }
175 1.1.1.2.4.2 rmind
176 1.1.1.2.4.2 rmind
177 1.1.1.2.4.2 rmind /*******************************************************************************
178 1.1.1.2.4.2 rmind *
179 1.1.1.2.4.2 rmind * FUNCTION: RsLargeAddressCheck
180 1.1.1.2.4.2 rmind *
181 1.1.1.2.4.2 rmind * PARAMETERS: Minimum - Address Min value
182 1.1.1.2.4.2 rmind * Maximum - Address Max value
183 1.1.1.2.4.2 rmind * Length - Address range value
184 1.1.1.2.4.2 rmind * Granularity - Address granularity value
185 1.1.1.2.4.2 rmind * Flags - General flags for address descriptors:
186 1.1.1.2.4.2 rmind * _MIF, _MAF, _DEC
187 1.1.1.2.4.2 rmind * MinOp - Original Op for Address Min
188 1.1.1.2.4.2 rmind * MaxOp - Original Op for Address Max
189 1.1.1.2.4.2 rmind * LengthOp - Original Op for address range
190 1.1.1.2.4.2 rmind * GranOp - Original Op for address granularity
191 1.1.1.2.4.2 rmind * Op - Parent Op for entire construct
192 1.1.1.2.4.2 rmind *
193 1.1.1.2.4.2 rmind * RETURN: None. Adds error messages to error log if necessary
194 1.1.1.2.4.2 rmind *
195 1.1.1.2.4.2 rmind * DESCRIPTION: Perform common value checks for "large" address descriptors.
196 1.1.1.2.4.2 rmind * Currently:
197 1.1.1.2.4.2 rmind * WordIo, WordBusNumber, WordSpace
198 1.1.1.2.4.2 rmind * DWordIo, DWordMemory, DWordSpace
199 1.1.1.2.4.2 rmind * QWordIo, QWordMemory, QWordSpace
200 1.1.1.2.4.2 rmind * ExtendedIo, ExtendedMemory, ExtendedSpace
201 1.1.1.2.4.2 rmind *
202 1.1.1.2.4.2 rmind * _MIF flag set means that the minimum address is fixed and is not relocatable
203 1.1.1.2.4.2 rmind * _MAF flag set means that the maximum address is fixed and is not relocatable
204 1.1.1.2.4.2 rmind * Length of zero means that the record size is variable
205 1.1.1.2.4.2 rmind *
206 1.1.1.2.4.2 rmind * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40
207 1.1.1.2.4.2 rmind * of the ACPI 4.0a specification. Added 04/2010.
208 1.1.1.2.4.2 rmind *
209 1.1.1.2.4.2 rmind ******************************************************************************/
210 1.1.1.2.4.2 rmind
211 1.1.1.2.4.2 rmind void
212 1.1.1.2.4.2 rmind RsLargeAddressCheck (
213 1.1.1.2.4.2 rmind UINT64 Minimum,
214 1.1.1.2.4.2 rmind UINT64 Maximum,
215 1.1.1.2.4.2 rmind UINT64 Length,
216 1.1.1.2.4.2 rmind UINT64 Granularity,
217 1.1.1.2.4.2 rmind UINT8 Flags,
218 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *MinOp,
219 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *MaxOp,
220 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *LengthOp,
221 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *GranOp,
222 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
223 1.1.1.2.4.2 rmind {
224 1.1.1.2.4.2 rmind
225 1.1.1.2.4.2 rmind if (Gbl_NoResourceChecking)
226 1.1.1.2.4.2 rmind {
227 1.1.1.2.4.2 rmind return;
228 1.1.1.2.4.2 rmind }
229 1.1.1.2.4.2 rmind
230 1.1.1.2.4.2 rmind /*
231 1.1.1.2.4.2 rmind * Check for a so-called "null descriptor". These are descriptors that are
232 1.1.1.2.4.2 rmind * created with most fields set to zero. The intent is that the descriptor
233 1.1.1.2.4.2 rmind * will be updated/completed at runtime via a BufferField.
234 1.1.1.2.4.2 rmind *
235 1.1.1.2.4.2 rmind * If the descriptor does NOT have a resource tag, it cannot be referenced
236 1.1.1.2.4.2 rmind * by a BufferField and we will flag this as an error. Conversely, if
237 1.1.1.2.4.2 rmind * the descriptor has a resource tag, we will assume that a BufferField
238 1.1.1.2.4.2 rmind * will be used to dynamically update it, so no error.
239 1.1.1.2.4.2 rmind *
240 1.1.1.2.4.2 rmind * A possible enhancement to this check would be to verify that in fact
241 1.1.1.2.4.2 rmind * a BufferField is created using the resource tag, and perhaps even
242 1.1.1.2.4.2 rmind * verify that a Store is performed to the BufferField.
243 1.1.1.2.4.2 rmind */
244 1.1.1.2.4.2 rmind if (!Minimum && !Maximum && !Length && !Granularity)
245 1.1.1.2.4.2 rmind {
246 1.1.1.2.4.2 rmind if (!Op->Asl.ExternalName)
247 1.1.1.2.4.2 rmind {
248 1.1.1.2.4.2 rmind /* No resource tag. Descriptor is fixed and is also illegal */
249 1.1.1.2.4.2 rmind
250 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL);
251 1.1.1.2.4.2 rmind }
252 1.1.1.2.4.2 rmind
253 1.1.1.2.4.2 rmind return;
254 1.1.1.2.4.2 rmind }
255 1.1.1.2.4.2 rmind
256 1.1.1.2.4.2 rmind /* Basic checks on Min/Max/Length */
257 1.1.1.2.4.2 rmind
258 1.1.1.2.4.2 rmind if (Minimum > Maximum)
259 1.1.1.2.4.2 rmind {
260 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL);
261 1.1.1.2.4.2 rmind return;
262 1.1.1.2.4.2 rmind }
263 1.1.1.2.4.2 rmind else if (Length > (Maximum - Minimum + 1))
264 1.1.1.2.4.2 rmind {
265 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL);
266 1.1.1.2.4.2 rmind return;
267 1.1.1.2.4.2 rmind }
268 1.1.1.2.4.2 rmind
269 1.1.1.2.4.2 rmind /* If specified (non-zero), ensure granularity is a power-of-two minus one */
270 1.1.1.2.4.2 rmind
271 1.1.1.2.4.2 rmind if (Granularity)
272 1.1.1.2.4.2 rmind {
273 1.1.1.2.4.2 rmind if ((Granularity + 1) &
274 1.1.1.2.4.2 rmind Granularity)
275 1.1.1.2.4.2 rmind {
276 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_GRANULARITY, GranOp, NULL);
277 1.1.1.2.4.2 rmind return;
278 1.1.1.2.4.2 rmind }
279 1.1.1.2.4.2 rmind }
280 1.1.1.2.4.2 rmind
281 1.1.1.2.4.2 rmind /*
282 1.1.1.2.4.2 rmind * Check the various combinations of Length, MinFixed, and MaxFixed
283 1.1.1.2.4.2 rmind */
284 1.1.1.2.4.2 rmind if (Length)
285 1.1.1.2.4.2 rmind {
286 1.1.1.2.4.2 rmind /* Fixed non-zero length */
287 1.1.1.2.4.2 rmind
288 1.1.1.2.4.2 rmind switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF))
289 1.1.1.2.4.2 rmind {
290 1.1.1.2.4.2 rmind case 0:
291 1.1.1.2.4.2 rmind /*
292 1.1.1.2.4.2 rmind * Fixed length, variable locations (both _MIN and _MAX).
293 1.1.1.2.4.2 rmind * Length must be a multiple of granularity
294 1.1.1.2.4.2 rmind */
295 1.1.1.2.4.2 rmind if (Granularity & Length)
296 1.1.1.2.4.2 rmind {
297 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, LengthOp, NULL);
298 1.1.1.2.4.2 rmind }
299 1.1.1.2.4.2 rmind break;
300 1.1.1.2.4.2 rmind
301 1.1.1.2.4.2 rmind case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF):
302 1.1.1.2.4.2 rmind
303 1.1.1.2.4.2 rmind /* Fixed length, fixed location. Granularity must be zero */
304 1.1.1.2.4.2 rmind
305 1.1.1.2.4.2 rmind if (Granularity != 0)
306 1.1.1.2.4.2 rmind {
307 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_GRAN_FIXED, GranOp, NULL);
308 1.1.1.2.4.2 rmind }
309 1.1.1.2.4.2 rmind
310 1.1.1.2.4.2 rmind /* Length must be exactly the size of the min/max window */
311 1.1.1.2.4.2 rmind
312 1.1.1.2.4.2 rmind if (Length != (Maximum - Minimum + 1))
313 1.1.1.2.4.2 rmind {
314 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH_FIXED, LengthOp, NULL);
315 1.1.1.2.4.2 rmind }
316 1.1.1.2.4.2 rmind break;
317 1.1.1.2.4.2 rmind
318 1.1.1.2.4.2 rmind /* All other combinations are invalid */
319 1.1.1.2.4.2 rmind
320 1.1.1.2.4.2 rmind case ACPI_RESOURCE_FLAG_MIF:
321 1.1.1.2.4.2 rmind case ACPI_RESOURCE_FLAG_MAF:
322 1.1.1.2.4.2 rmind default:
323 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL);
324 1.1.1.2.4.2 rmind }
325 1.1.1.2.4.2 rmind }
326 1.1.1.2.4.2 rmind else
327 1.1.1.2.4.2 rmind {
328 1.1.1.2.4.2 rmind /* Variable length (length==0) */
329 1.1.1.2.4.2 rmind
330 1.1.1.2.4.2 rmind switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF))
331 1.1.1.2.4.2 rmind {
332 1.1.1.2.4.2 rmind case 0:
333 1.1.1.2.4.2 rmind /*
334 1.1.1.2.4.2 rmind * Both _MIN and _MAX are variable.
335 1.1.1.2.4.2 rmind * No additional requirements, just exit
336 1.1.1.2.4.2 rmind */
337 1.1.1.2.4.2 rmind break;
338 1.1.1.2.4.2 rmind
339 1.1.1.2.4.2 rmind case ACPI_RESOURCE_FLAG_MIF:
340 1.1.1.2.4.2 rmind
341 1.1.1.2.4.2 rmind /* _MIN is fixed. _MIN must be multiple of _GRA */
342 1.1.1.2.4.2 rmind
343 1.1.1.2.4.2 rmind /*
344 1.1.1.2.4.2 rmind * The granularity is defined by the ACPI specification to be a
345 1.1.1.2.4.2 rmind * power-of-two minus one, therefore the granularity is a
346 1.1.1.2.4.2 rmind * bitmask which can be used to easily validate the addresses.
347 1.1.1.2.4.2 rmind */
348 1.1.1.2.4.2 rmind if (Granularity & Minimum)
349 1.1.1.2.4.2 rmind {
350 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL);
351 1.1.1.2.4.2 rmind }
352 1.1.1.2.4.2 rmind break;
353 1.1.1.2.4.2 rmind
354 1.1.1.2.4.2 rmind case ACPI_RESOURCE_FLAG_MAF:
355 1.1.1.2.4.2 rmind
356 1.1.1.2.4.2 rmind /* _MAX is fixed. (_MAX + 1) must be multiple of _GRA */
357 1.1.1.2.4.2 rmind
358 1.1.1.2.4.2 rmind if (Granularity & (Maximum + 1))
359 1.1.1.2.4.2 rmind {
360 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, "-1");
361 1.1.1.2.4.2 rmind }
362 1.1.1.2.4.2 rmind break;
363 1.1.1.2.4.2 rmind
364 1.1.1.2.4.2 rmind /* Both MIF/MAF set is invalid if length is zero */
365 1.1.1.2.4.2 rmind
366 1.1.1.2.4.2 rmind case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF):
367 1.1.1.2.4.2 rmind default:
368 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL);
369 1.1.1.2.4.2 rmind }
370 1.1.1.2.4.2 rmind }
371 1.1.1.2.4.2 rmind }
372 1.1.1.2.4.2 rmind
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind /*******************************************************************************
375 1.1.1.2.4.2 rmind *
376 1.1.1.2.4.2 rmind * FUNCTION: RsGetStringDataLength
377 1.1.1.2.4.2 rmind *
378 1.1.1.2.4.2 rmind * PARAMETERS: InitializerOp - Start of a subtree of init nodes
379 1.1.1.2.4.2 rmind *
380 1.1.1.2.4.2 rmind * RETURN: Valid string length if a string node is found (otherwise 0)
381 1.1.1.2.4.2 rmind *
382 1.1.1.2.4.2 rmind * DESCRIPTION: In a list of peer nodes, find the first one that contains a
383 1.1.1.2.4.2 rmind * string and return the length of the string.
384 1.1.1.2.4.2 rmind *
385 1.1.1.2.4.2 rmind ******************************************************************************/
386 1.1.1.2.4.2 rmind
387 1.1.1.2.4.2 rmind UINT16
388 1.1.1.2.4.2 rmind RsGetStringDataLength (
389 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *InitializerOp)
390 1.1.1.2.4.2 rmind {
391 1.1.1.2.4.2 rmind
392 1.1.1.2.4.2 rmind while (InitializerOp)
393 1.1.1.2.4.2 rmind {
394 1.1.1.2.4.2 rmind if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
395 1.1.1.2.4.2 rmind {
396 1.1.1.2.4.2 rmind return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1));
397 1.1.1.2.4.2 rmind }
398 1.1.1.2.4.2 rmind InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
399 1.1.1.2.4.2 rmind }
400 1.1.1.2.4.2 rmind
401 1.1.1.2.4.2 rmind return 0;
402 1.1.1.2.4.2 rmind }
403 1.1.1.2.4.2 rmind
404 1.1.1.2.4.2 rmind
405 1.1.1.2.4.2 rmind /*******************************************************************************
406 1.1.1.2.4.2 rmind *
407 1.1.1.2.4.2 rmind * FUNCTION: RsAllocateResourceNode
408 1.1.1.2.4.2 rmind *
409 1.1.1.2.4.2 rmind * PARAMETERS: Size - Size of node in bytes
410 1.1.1.2.4.2 rmind *
411 1.1.1.2.4.2 rmind * RETURN: The allocated node - aborts on allocation failure
412 1.1.1.2.4.2 rmind *
413 1.1.1.2.4.2 rmind * DESCRIPTION: Allocate a resource description node and the resource
414 1.1.1.2.4.2 rmind * descriptor itself (the nodes are used to link descriptors).
415 1.1.1.2.4.2 rmind *
416 1.1.1.2.4.2 rmind ******************************************************************************/
417 1.1.1.2.4.2 rmind
418 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *
419 1.1.1.2.4.2 rmind RsAllocateResourceNode (
420 1.1.1.2.4.2 rmind UINT32 Size)
421 1.1.1.2.4.2 rmind {
422 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *Rnode;
423 1.1.1.2.4.2 rmind
424 1.1.1.2.4.2 rmind
425 1.1.1.2.4.2 rmind /* Allocate the node */
426 1.1.1.2.4.2 rmind
427 1.1.1.2.4.2 rmind Rnode = UtLocalCalloc (sizeof (ASL_RESOURCE_NODE));
428 1.1.1.2.4.2 rmind
429 1.1.1.2.4.2 rmind /* Allocate the resource descriptor itself */
430 1.1.1.2.4.2 rmind
431 1.1.1.2.4.2 rmind Rnode->Buffer = UtLocalCalloc (Size);
432 1.1.1.2.4.2 rmind Rnode->BufferLength = Size;
433 1.1.1.2.4.2 rmind
434 1.1.1.2.4.2 rmind return (Rnode);
435 1.1.1.2.4.2 rmind }
436 1.1.1.2.4.2 rmind
437 1.1.1.2.4.2 rmind
438 1.1.1.2.4.2 rmind /*******************************************************************************
439 1.1.1.2.4.2 rmind *
440 1.1.1.2.4.2 rmind * FUNCTION: RsCreateBitField
441 1.1.1.2.4.2 rmind *
442 1.1.1.2.4.2 rmind * PARAMETERS: Op - Resource field node
443 1.1.1.2.4.2 rmind * Name - Name of the field (Used only to reference
444 1.1.1.2.4.2 rmind * the field in the ASL, not in the AML)
445 1.1.1.2.4.2 rmind * ByteOffset - Offset from the field start
446 1.1.1.2.4.2 rmind * BitOffset - Additional bit offset
447 1.1.1.2.4.2 rmind *
448 1.1.1.2.4.2 rmind * RETURN: None, sets fields within the input node
449 1.1.1.2.4.2 rmind *
450 1.1.1.2.4.2 rmind * DESCRIPTION: Utility function to generate a named bit field within a
451 1.1.1.2.4.2 rmind * resource descriptor. Mark a node as 1) a field in a resource
452 1.1.1.2.4.2 rmind * descriptor, and 2) set the value to be a BIT offset
453 1.1.1.2.4.2 rmind *
454 1.1.1.2.4.2 rmind ******************************************************************************/
455 1.1.1.2.4.2 rmind
456 1.1.1.2.4.2 rmind void
457 1.1.1.2.4.2 rmind RsCreateBitField (
458 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
459 1.1.1.2.4.2 rmind char *Name,
460 1.1.1.2.4.2 rmind UINT32 ByteOffset,
461 1.1.1.2.4.2 rmind UINT32 BitOffset)
462 1.1.1.2.4.2 rmind {
463 1.1.1.2.4.2 rmind
464 1.1.1.2.4.2 rmind Op->Asl.ExternalName = Name;
465 1.1.1.2.4.2 rmind Op->Asl.Value.Integer = ((UINT64) ByteOffset * 8) + BitOffset;
466 1.1.1.2.4.2 rmind Op->Asl.CompileFlags |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET);
467 1.1.1.2.4.2 rmind }
468 1.1.1.2.4.2 rmind
469 1.1.1.2.4.2 rmind
470 1.1.1.2.4.2 rmind /*******************************************************************************
471 1.1.1.2.4.2 rmind *
472 1.1.1.2.4.2 rmind * FUNCTION: RsCreateByteField
473 1.1.1.2.4.2 rmind *
474 1.1.1.2.4.2 rmind * PARAMETERS: Op - Resource field node
475 1.1.1.2.4.2 rmind * Name - Name of the field (Used only to reference
476 1.1.1.2.4.2 rmind * the field in the ASL, not in the AML)
477 1.1.1.2.4.2 rmind * ByteOffset - Offset from the field start
478 1.1.1.2.4.2 rmind *
479 1.1.1.2.4.2 rmind * RETURN: None, sets fields within the input node
480 1.1.1.2.4.2 rmind *
481 1.1.1.2.4.2 rmind * DESCRIPTION: Utility function to generate a named byte field within a
482 1.1.1.2.4.2 rmind * resource descriptor. Mark a node as 1) a field in a resource
483 1.1.1.2.4.2 rmind * descriptor, and 2) set the value to be a BYTE offset
484 1.1.1.2.4.2 rmind *
485 1.1.1.2.4.2 rmind ******************************************************************************/
486 1.1.1.2.4.2 rmind
487 1.1.1.2.4.2 rmind void
488 1.1.1.2.4.2 rmind RsCreateByteField (
489 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
490 1.1.1.2.4.2 rmind char *Name,
491 1.1.1.2.4.2 rmind UINT32 ByteOffset)
492 1.1.1.2.4.2 rmind {
493 1.1.1.2.4.2 rmind
494 1.1.1.2.4.2 rmind Op->Asl.ExternalName = Name;
495 1.1.1.2.4.2 rmind Op->Asl.Value.Integer = ByteOffset;
496 1.1.1.2.4.2 rmind Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
497 1.1.1.2.4.2 rmind }
498 1.1.1.2.4.2 rmind
499 1.1.1.2.4.2 rmind
500 1.1.1.2.4.2 rmind /*******************************************************************************
501 1.1.1.2.4.2 rmind *
502 1.1.1.2.4.2 rmind * FUNCTION: RsSetFlagBits
503 1.1.1.2.4.2 rmind *
504 1.1.1.2.4.2 rmind * PARAMETERS: *Flags - Pointer to the flag byte
505 1.1.1.2.4.2 rmind * Op - Flag initialization node
506 1.1.1.2.4.2 rmind * Position - Bit position within the flag byte
507 1.1.1.2.4.2 rmind * Default - Used if the node is DEFAULT.
508 1.1.1.2.4.2 rmind *
509 1.1.1.2.4.2 rmind * RETURN: Sets bits within the *Flags output byte.
510 1.1.1.2.4.2 rmind *
511 1.1.1.2.4.2 rmind * DESCRIPTION: Set a bit in a cumulative flags word from an initialization
512 1.1.1.2.4.2 rmind * node. Will use a default value if the node is DEFAULT, meaning
513 1.1.1.2.4.2 rmind * that no value was specified in the ASL. Used to merge multiple
514 1.1.1.2.4.2 rmind * keywords into a single flags byte.
515 1.1.1.2.4.2 rmind *
516 1.1.1.2.4.2 rmind ******************************************************************************/
517 1.1.1.2.4.2 rmind
518 1.1.1.2.4.2 rmind void
519 1.1.1.2.4.2 rmind RsSetFlagBits (
520 1.1.1.2.4.2 rmind UINT8 *Flags,
521 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
522 1.1.1.2.4.2 rmind UINT8 Position,
523 1.1.1.2.4.2 rmind UINT8 DefaultBit)
524 1.1.1.2.4.2 rmind {
525 1.1.1.2.4.2 rmind
526 1.1.1.2.4.2 rmind if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
527 1.1.1.2.4.2 rmind {
528 1.1.1.2.4.2 rmind /* Use the default bit */
529 1.1.1.2.4.2 rmind
530 1.1.1.2.4.2 rmind *Flags |= (DefaultBit << Position);
531 1.1.1.2.4.2 rmind }
532 1.1.1.2.4.2 rmind else
533 1.1.1.2.4.2 rmind {
534 1.1.1.2.4.2 rmind /* Use the bit specified in the initialization node */
535 1.1.1.2.4.2 rmind
536 1.1.1.2.4.2 rmind *Flags |= (((UINT8) Op->Asl.Value.Integer) << Position);
537 1.1.1.2.4.2 rmind }
538 1.1.1.2.4.2 rmind }
539 1.1.1.2.4.2 rmind
540 1.1.1.2.4.2 rmind
541 1.1.1.2.4.2 rmind /*******************************************************************************
542 1.1.1.2.4.2 rmind *
543 1.1.1.2.4.2 rmind * FUNCTION: RsCompleteNodeAndGetNext
544 1.1.1.2.4.2 rmind *
545 1.1.1.2.4.2 rmind * PARAMETERS: Op - Resource node to be completed
546 1.1.1.2.4.2 rmind *
547 1.1.1.2.4.2 rmind * RETURN: The next peer to the input node.
548 1.1.1.2.4.2 rmind *
549 1.1.1.2.4.2 rmind * DESCRIPTION: Mark the current node completed and return the next peer.
550 1.1.1.2.4.2 rmind * The node ParseOpcode is set to DEFAULT_ARG, meaning that
551 1.1.1.2.4.2 rmind * this node is to be ignored from now on.
552 1.1.1.2.4.2 rmind *
553 1.1.1.2.4.2 rmind ******************************************************************************/
554 1.1.1.2.4.2 rmind
555 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *
556 1.1.1.2.4.2 rmind RsCompleteNodeAndGetNext (
557 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
558 1.1.1.2.4.2 rmind {
559 1.1.1.2.4.2 rmind
560 1.1.1.2.4.2 rmind /* Mark this node unused */
561 1.1.1.2.4.2 rmind
562 1.1.1.2.4.2 rmind Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
563 1.1.1.2.4.2 rmind
564 1.1.1.2.4.2 rmind /* Move on to the next peer node in the initializer list */
565 1.1.1.2.4.2 rmind
566 1.1.1.2.4.2 rmind return (ASL_GET_PEER_NODE (Op));
567 1.1.1.2.4.2 rmind }
568 1.1.1.2.4.2 rmind
569 1.1.1.2.4.2 rmind
570 1.1.1.2.4.2 rmind /*******************************************************************************
571 1.1.1.2.4.2 rmind *
572 1.1.1.2.4.2 rmind * FUNCTION: RsCheckListForDuplicates
573 1.1.1.2.4.2 rmind *
574 1.1.1.2.4.2 rmind * PARAMETERS: Op - First op in the initializer list
575 1.1.1.2.4.2 rmind *
576 1.1.1.2.4.2 rmind * RETURN: None
577 1.1.1.2.4.2 rmind *
578 1.1.1.2.4.2 rmind * DESCRIPTION: Check an initializer list for duplicate values. Emits an error
579 1.1.1.2.4.2 rmind * if any duplicates are found.
580 1.1.1.2.4.2 rmind *
581 1.1.1.2.4.2 rmind ******************************************************************************/
582 1.1.1.2.4.2 rmind
583 1.1.1.2.4.2 rmind void
584 1.1.1.2.4.2 rmind RsCheckListForDuplicates (
585 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
586 1.1.1.2.4.2 rmind {
587 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *NextValueOp = Op;
588 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *NextOp;
589 1.1.1.2.4.2 rmind UINT32 Value;
590 1.1.1.2.4.2 rmind
591 1.1.1.2.4.2 rmind
592 1.1.1.2.4.2 rmind if (!Op)
593 1.1.1.2.4.2 rmind {
594 1.1.1.2.4.2 rmind return;
595 1.1.1.2.4.2 rmind }
596 1.1.1.2.4.2 rmind
597 1.1.1.2.4.2 rmind /* Search list once for each value in the list */
598 1.1.1.2.4.2 rmind
599 1.1.1.2.4.2 rmind while (NextValueOp)
600 1.1.1.2.4.2 rmind {
601 1.1.1.2.4.2 rmind Value = (UINT32) NextValueOp->Asl.Value.Integer;
602 1.1.1.2.4.2 rmind
603 1.1.1.2.4.2 rmind /* Compare this value to all remaining values in the list */
604 1.1.1.2.4.2 rmind
605 1.1.1.2.4.2 rmind NextOp = ASL_GET_PEER_NODE (NextValueOp);
606 1.1.1.2.4.2 rmind while (NextOp)
607 1.1.1.2.4.2 rmind {
608 1.1.1.2.4.2 rmind if (NextOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
609 1.1.1.2.4.2 rmind {
610 1.1.1.2.4.2 rmind /* Compare values */
611 1.1.1.2.4.2 rmind
612 1.1.1.2.4.2 rmind if (Value == (UINT32) NextOp->Asl.Value.Integer)
613 1.1.1.2.4.2 rmind {
614 1.1.1.2.4.2 rmind /* Emit error only once per duplicate node */
615 1.1.1.2.4.2 rmind
616 1.1.1.2.4.2 rmind if (!(NextOp->Asl.CompileFlags & NODE_IS_DUPLICATE))
617 1.1.1.2.4.2 rmind {
618 1.1.1.2.4.2 rmind NextOp->Asl.CompileFlags |= NODE_IS_DUPLICATE;
619 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_DUPLICATE_ITEM,
620 1.1.1.2.4.2 rmind NextOp, NULL);
621 1.1.1.2.4.2 rmind }
622 1.1.1.2.4.2 rmind }
623 1.1.1.2.4.2 rmind }
624 1.1.1.2.4.2 rmind
625 1.1.1.2.4.2 rmind NextOp = ASL_GET_PEER_NODE (NextOp);
626 1.1.1.2.4.2 rmind }
627 1.1.1.2.4.2 rmind
628 1.1.1.2.4.2 rmind NextValueOp = ASL_GET_PEER_NODE (NextValueOp);
629 1.1.1.2.4.2 rmind }
630 1.1.1.2.4.2 rmind }
631 1.1.1.2.4.2 rmind
632 1.1.1.2.4.2 rmind
633 1.1.1.2.4.2 rmind /*******************************************************************************
634 1.1.1.2.4.2 rmind *
635 1.1.1.2.4.2 rmind * FUNCTION: RsDoOneResourceDescriptor
636 1.1.1.2.4.2 rmind *
637 1.1.1.2.4.2 rmind * PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor
638 1.1.1.2.4.2 rmind * CurrentByteOffset - Offset in the resource descriptor
639 1.1.1.2.4.2 rmind * buffer.
640 1.1.1.2.4.2 rmind *
641 1.1.1.2.4.2 rmind * RETURN: A valid resource node for the descriptor
642 1.1.1.2.4.2 rmind *
643 1.1.1.2.4.2 rmind * DESCRIPTION: Dispatches the processing of one resource descriptor
644 1.1.1.2.4.2 rmind *
645 1.1.1.2.4.2 rmind ******************************************************************************/
646 1.1.1.2.4.2 rmind
647 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *
648 1.1.1.2.4.2 rmind RsDoOneResourceDescriptor (
649 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *DescriptorTypeOp,
650 1.1.1.2.4.2 rmind UINT32 CurrentByteOffset,
651 1.1.1.2.4.2 rmind UINT8 *State)
652 1.1.1.2.4.2 rmind {
653 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *Rnode = NULL;
654 1.1.1.2.4.2 rmind
655 1.1.1.2.4.2 rmind
656 1.1.1.2.4.2 rmind /* Construct the resource */
657 1.1.1.2.4.2 rmind
658 1.1.1.2.4.2 rmind switch (DescriptorTypeOp->Asl.ParseOpcode)
659 1.1.1.2.4.2 rmind {
660 1.1.1.2.4.2 rmind case PARSEOP_DMA:
661 1.1.1.2.4.2 rmind Rnode = RsDoDmaDescriptor (DescriptorTypeOp,
662 1.1.1.2.4.2 rmind CurrentByteOffset);
663 1.1.1.2.4.2 rmind break;
664 1.1.1.2.4.2 rmind
665 1.1.1.2.4.2 rmind case PARSEOP_DWORDIO:
666 1.1.1.2.4.2 rmind Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp,
667 1.1.1.2.4.2 rmind CurrentByteOffset);
668 1.1.1.2.4.2 rmind break;
669 1.1.1.2.4.2 rmind
670 1.1.1.2.4.2 rmind case PARSEOP_DWORDMEMORY:
671 1.1.1.2.4.2 rmind Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp,
672 1.1.1.2.4.2 rmind CurrentByteOffset);
673 1.1.1.2.4.2 rmind break;
674 1.1.1.2.4.2 rmind
675 1.1.1.2.4.2 rmind case PARSEOP_DWORDSPACE:
676 1.1.1.2.4.2 rmind Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp,
677 1.1.1.2.4.2 rmind CurrentByteOffset);
678 1.1.1.2.4.2 rmind break;
679 1.1.1.2.4.2 rmind
680 1.1.1.2.4.2 rmind case PARSEOP_ENDDEPENDENTFN:
681 1.1.1.2.4.2 rmind switch (*State)
682 1.1.1.2.4.2 rmind {
683 1.1.1.2.4.2 rmind case ACPI_RSTATE_NORMAL:
684 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT,
685 1.1.1.2.4.2 rmind DescriptorTypeOp, NULL);
686 1.1.1.2.4.2 rmind break;
687 1.1.1.2.4.2 rmind
688 1.1.1.2.4.2 rmind case ACPI_RSTATE_START_DEPENDENT:
689 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
690 1.1.1.2.4.2 rmind DescriptorTypeOp, NULL);
691 1.1.1.2.4.2 rmind break;
692 1.1.1.2.4.2 rmind
693 1.1.1.2.4.2 rmind case ACPI_RSTATE_DEPENDENT_LIST:
694 1.1.1.2.4.2 rmind default:
695 1.1.1.2.4.2 rmind break;
696 1.1.1.2.4.2 rmind }
697 1.1.1.2.4.2 rmind
698 1.1.1.2.4.2 rmind *State = ACPI_RSTATE_NORMAL;
699 1.1.1.2.4.2 rmind Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp,
700 1.1.1.2.4.2 rmind CurrentByteOffset);
701 1.1.1.2.4.2 rmind break;
702 1.1.1.2.4.2 rmind
703 1.1.1.2.4.2 rmind case PARSEOP_ENDTAG:
704 1.1.1.2.4.2 rmind Rnode = RsDoEndTagDescriptor (DescriptorTypeOp,
705 1.1.1.2.4.2 rmind CurrentByteOffset);
706 1.1.1.2.4.2 rmind break;
707 1.1.1.2.4.2 rmind
708 1.1.1.2.4.2 rmind case PARSEOP_EXTENDEDIO:
709 1.1.1.2.4.2 rmind Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp,
710 1.1.1.2.4.2 rmind CurrentByteOffset);
711 1.1.1.2.4.2 rmind break;
712 1.1.1.2.4.2 rmind
713 1.1.1.2.4.2 rmind case PARSEOP_EXTENDEDMEMORY:
714 1.1.1.2.4.2 rmind Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp,
715 1.1.1.2.4.2 rmind CurrentByteOffset);
716 1.1.1.2.4.2 rmind break;
717 1.1.1.2.4.2 rmind
718 1.1.1.2.4.2 rmind case PARSEOP_EXTENDEDSPACE:
719 1.1.1.2.4.2 rmind Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp,
720 1.1.1.2.4.2 rmind CurrentByteOffset);
721 1.1.1.2.4.2 rmind break;
722 1.1.1.2.4.2 rmind
723 1.1.1.2.4.2 rmind case PARSEOP_FIXEDIO:
724 1.1.1.2.4.2 rmind Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp,
725 1.1.1.2.4.2 rmind CurrentByteOffset);
726 1.1.1.2.4.2 rmind break;
727 1.1.1.2.4.2 rmind
728 1.1.1.2.4.2 rmind case PARSEOP_INTERRUPT:
729 1.1.1.2.4.2 rmind Rnode = RsDoInterruptDescriptor (DescriptorTypeOp,
730 1.1.1.2.4.2 rmind CurrentByteOffset);
731 1.1.1.2.4.2 rmind break;
732 1.1.1.2.4.2 rmind
733 1.1.1.2.4.2 rmind case PARSEOP_IO:
734 1.1.1.2.4.2 rmind Rnode = RsDoIoDescriptor (DescriptorTypeOp,
735 1.1.1.2.4.2 rmind CurrentByteOffset);
736 1.1.1.2.4.2 rmind break;
737 1.1.1.2.4.2 rmind
738 1.1.1.2.4.2 rmind case PARSEOP_IRQ:
739 1.1.1.2.4.2 rmind Rnode = RsDoIrqDescriptor (DescriptorTypeOp,
740 1.1.1.2.4.2 rmind CurrentByteOffset);
741 1.1.1.2.4.2 rmind break;
742 1.1.1.2.4.2 rmind
743 1.1.1.2.4.2 rmind case PARSEOP_IRQNOFLAGS:
744 1.1.1.2.4.2 rmind Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp,
745 1.1.1.2.4.2 rmind CurrentByteOffset);
746 1.1.1.2.4.2 rmind break;
747 1.1.1.2.4.2 rmind
748 1.1.1.2.4.2 rmind case PARSEOP_MEMORY24:
749 1.1.1.2.4.2 rmind Rnode = RsDoMemory24Descriptor (DescriptorTypeOp,
750 1.1.1.2.4.2 rmind CurrentByteOffset);
751 1.1.1.2.4.2 rmind break;
752 1.1.1.2.4.2 rmind
753 1.1.1.2.4.2 rmind case PARSEOP_MEMORY32:
754 1.1.1.2.4.2 rmind Rnode = RsDoMemory32Descriptor (DescriptorTypeOp,
755 1.1.1.2.4.2 rmind CurrentByteOffset);
756 1.1.1.2.4.2 rmind break;
757 1.1.1.2.4.2 rmind
758 1.1.1.2.4.2 rmind case PARSEOP_MEMORY32FIXED:
759 1.1.1.2.4.2 rmind Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp,
760 1.1.1.2.4.2 rmind CurrentByteOffset);
761 1.1.1.2.4.2 rmind break;
762 1.1.1.2.4.2 rmind
763 1.1.1.2.4.2 rmind case PARSEOP_QWORDIO:
764 1.1.1.2.4.2 rmind Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp,
765 1.1.1.2.4.2 rmind CurrentByteOffset);
766 1.1.1.2.4.2 rmind break;
767 1.1.1.2.4.2 rmind
768 1.1.1.2.4.2 rmind case PARSEOP_QWORDMEMORY:
769 1.1.1.2.4.2 rmind Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp,
770 1.1.1.2.4.2 rmind CurrentByteOffset);
771 1.1.1.2.4.2 rmind break;
772 1.1.1.2.4.2 rmind
773 1.1.1.2.4.2 rmind case PARSEOP_QWORDSPACE:
774 1.1.1.2.4.2 rmind Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp,
775 1.1.1.2.4.2 rmind CurrentByteOffset);
776 1.1.1.2.4.2 rmind break;
777 1.1.1.2.4.2 rmind
778 1.1.1.2.4.2 rmind case PARSEOP_REGISTER:
779 1.1.1.2.4.2 rmind Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp,
780 1.1.1.2.4.2 rmind CurrentByteOffset);
781 1.1.1.2.4.2 rmind break;
782 1.1.1.2.4.2 rmind
783 1.1.1.2.4.2 rmind case PARSEOP_STARTDEPENDENTFN:
784 1.1.1.2.4.2 rmind switch (*State)
785 1.1.1.2.4.2 rmind {
786 1.1.1.2.4.2 rmind case ACPI_RSTATE_START_DEPENDENT:
787 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
788 1.1.1.2.4.2 rmind DescriptorTypeOp, NULL);
789 1.1.1.2.4.2 rmind break;
790 1.1.1.2.4.2 rmind
791 1.1.1.2.4.2 rmind case ACPI_RSTATE_NORMAL:
792 1.1.1.2.4.2 rmind case ACPI_RSTATE_DEPENDENT_LIST:
793 1.1.1.2.4.2 rmind default:
794 1.1.1.2.4.2 rmind break;
795 1.1.1.2.4.2 rmind }
796 1.1.1.2.4.2 rmind
797 1.1.1.2.4.2 rmind *State = ACPI_RSTATE_START_DEPENDENT;
798 1.1.1.2.4.2 rmind Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp,
799 1.1.1.2.4.2 rmind CurrentByteOffset);
800 1.1.1.2.4.2 rmind *State = ACPI_RSTATE_DEPENDENT_LIST;
801 1.1.1.2.4.2 rmind break;
802 1.1.1.2.4.2 rmind
803 1.1.1.2.4.2 rmind case PARSEOP_STARTDEPENDENTFN_NOPRI:
804 1.1.1.2.4.2 rmind switch (*State)
805 1.1.1.2.4.2 rmind {
806 1.1.1.2.4.2 rmind case ACPI_RSTATE_START_DEPENDENT:
807 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
808 1.1.1.2.4.2 rmind DescriptorTypeOp, NULL);
809 1.1.1.2.4.2 rmind break;
810 1.1.1.2.4.2 rmind
811 1.1.1.2.4.2 rmind case ACPI_RSTATE_NORMAL:
812 1.1.1.2.4.2 rmind case ACPI_RSTATE_DEPENDENT_LIST:
813 1.1.1.2.4.2 rmind default:
814 1.1.1.2.4.2 rmind break;
815 1.1.1.2.4.2 rmind }
816 1.1.1.2.4.2 rmind
817 1.1.1.2.4.2 rmind *State = ACPI_RSTATE_START_DEPENDENT;
818 1.1.1.2.4.2 rmind Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp,
819 1.1.1.2.4.2 rmind CurrentByteOffset);
820 1.1.1.2.4.2 rmind *State = ACPI_RSTATE_DEPENDENT_LIST;
821 1.1.1.2.4.2 rmind break;
822 1.1.1.2.4.2 rmind
823 1.1.1.2.4.2 rmind case PARSEOP_VENDORLONG:
824 1.1.1.2.4.2 rmind Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp,
825 1.1.1.2.4.2 rmind CurrentByteOffset);
826 1.1.1.2.4.2 rmind break;
827 1.1.1.2.4.2 rmind
828 1.1.1.2.4.2 rmind case PARSEOP_VENDORSHORT:
829 1.1.1.2.4.2 rmind Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp,
830 1.1.1.2.4.2 rmind CurrentByteOffset);
831 1.1.1.2.4.2 rmind break;
832 1.1.1.2.4.2 rmind
833 1.1.1.2.4.2 rmind case PARSEOP_WORDBUSNUMBER:
834 1.1.1.2.4.2 rmind Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp,
835 1.1.1.2.4.2 rmind CurrentByteOffset);
836 1.1.1.2.4.2 rmind break;
837 1.1.1.2.4.2 rmind
838 1.1.1.2.4.2 rmind case PARSEOP_WORDIO:
839 1.1.1.2.4.2 rmind Rnode = RsDoWordIoDescriptor (DescriptorTypeOp,
840 1.1.1.2.4.2 rmind CurrentByteOffset);
841 1.1.1.2.4.2 rmind break;
842 1.1.1.2.4.2 rmind
843 1.1.1.2.4.2 rmind case PARSEOP_WORDSPACE:
844 1.1.1.2.4.2 rmind Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp,
845 1.1.1.2.4.2 rmind CurrentByteOffset);
846 1.1.1.2.4.2 rmind break;
847 1.1.1.2.4.2 rmind
848 1.1.1.2.4.2 rmind case PARSEOP_DEFAULT_ARG:
849 1.1.1.2.4.2 rmind /* Just ignore any of these, they are used as fillers/placeholders */
850 1.1.1.2.4.2 rmind break;
851 1.1.1.2.4.2 rmind
852 1.1.1.2.4.2 rmind default:
853 1.1.1.2.4.2 rmind printf ("Unknown resource descriptor type [%s]\n",
854 1.1.1.2.4.2 rmind DescriptorTypeOp->Asl.ParseOpName);
855 1.1.1.2.4.2 rmind break;
856 1.1.1.2.4.2 rmind }
857 1.1.1.2.4.2 rmind
858 1.1.1.2.4.2 rmind /*
859 1.1.1.2.4.2 rmind * Mark original node as unused, but head of a resource descriptor.
860 1.1.1.2.4.2 rmind * This allows the resource to be installed in the namespace so that
861 1.1.1.2.4.2 rmind * references to the descriptor can be resolved.
862 1.1.1.2.4.2 rmind */
863 1.1.1.2.4.2 rmind DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
864 1.1.1.2.4.2 rmind DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC;
865 1.1.1.2.4.2 rmind DescriptorTypeOp->Asl.Value.Integer = CurrentByteOffset;
866 1.1.1.2.4.2 rmind
867 1.1.1.2.4.2 rmind if (Rnode)
868 1.1.1.2.4.2 rmind {
869 1.1.1.2.4.2 rmind DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength;
870 1.1.1.2.4.2 rmind }
871 1.1.1.2.4.2 rmind
872 1.1.1.2.4.2 rmind return (Rnode);
873 1.1.1.2.4.2 rmind }
874 1.1.1.2.4.2 rmind
875 1.1.1.2.4.2 rmind
876 1.1.1.2.4.2 rmind /*******************************************************************************
877 1.1.1.2.4.2 rmind *
878 1.1.1.2.4.2 rmind * FUNCTION: RsLinkDescriptorChain
879 1.1.1.2.4.2 rmind *
880 1.1.1.2.4.2 rmind * PARAMETERS: PreviousRnode - Pointer to the node that will be previous
881 1.1.1.2.4.2 rmind * to the linked node, At exit, set to the
882 1.1.1.2.4.2 rmind * last node in the new chain.
883 1.1.1.2.4.2 rmind * Rnode - Resource node to link into the list
884 1.1.1.2.4.2 rmind *
885 1.1.1.2.4.2 rmind * RETURN: Cumulative buffer byte offset of the new segment of chain
886 1.1.1.2.4.2 rmind *
887 1.1.1.2.4.2 rmind * DESCRIPTION: Link a descriptor chain at the end of an existing chain.
888 1.1.1.2.4.2 rmind *
889 1.1.1.2.4.2 rmind ******************************************************************************/
890 1.1.1.2.4.2 rmind
891 1.1.1.2.4.2 rmind UINT32
892 1.1.1.2.4.2 rmind RsLinkDescriptorChain (
893 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE **PreviousRnode,
894 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *Rnode)
895 1.1.1.2.4.2 rmind {
896 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *LastRnode;
897 1.1.1.2.4.2 rmind UINT32 CurrentByteOffset;
898 1.1.1.2.4.2 rmind
899 1.1.1.2.4.2 rmind
900 1.1.1.2.4.2 rmind /* Anything to do? */
901 1.1.1.2.4.2 rmind
902 1.1.1.2.4.2 rmind if (!Rnode)
903 1.1.1.2.4.2 rmind {
904 1.1.1.2.4.2 rmind return 0;
905 1.1.1.2.4.2 rmind }
906 1.1.1.2.4.2 rmind
907 1.1.1.2.4.2 rmind /* Point the previous node to the new node */
908 1.1.1.2.4.2 rmind
909 1.1.1.2.4.2 rmind (*PreviousRnode)->Next = Rnode;
910 1.1.1.2.4.2 rmind CurrentByteOffset = Rnode->BufferLength;
911 1.1.1.2.4.2 rmind
912 1.1.1.2.4.2 rmind /* Walk to the end of the chain headed by Rnode */
913 1.1.1.2.4.2 rmind
914 1.1.1.2.4.2 rmind LastRnode = Rnode;
915 1.1.1.2.4.2 rmind while (LastRnode->Next)
916 1.1.1.2.4.2 rmind {
917 1.1.1.2.4.2 rmind LastRnode = LastRnode->Next;
918 1.1.1.2.4.2 rmind CurrentByteOffset += LastRnode->BufferLength;
919 1.1.1.2.4.2 rmind }
920 1.1.1.2.4.2 rmind
921 1.1.1.2.4.2 rmind /* Previous node becomes the last node in the chain */
922 1.1.1.2.4.2 rmind
923 1.1.1.2.4.2 rmind *PreviousRnode = LastRnode;
924 1.1.1.2.4.2 rmind return CurrentByteOffset;
925 1.1.1.2.4.2 rmind }
926 1.1.1.2.4.2 rmind
927 1.1.1.2.4.2 rmind
928 1.1.1.2.4.2 rmind /*******************************************************************************
929 1.1.1.2.4.2 rmind *
930 1.1.1.2.4.2 rmind * FUNCTION: RsDoResourceTemplate
931 1.1.1.2.4.2 rmind *
932 1.1.1.2.4.2 rmind * PARAMETERS: Op - Parent of a resource template list
933 1.1.1.2.4.2 rmind *
934 1.1.1.2.4.2 rmind * RETURN: None. Sets input node to point to a list of AML code
935 1.1.1.2.4.2 rmind *
936 1.1.1.2.4.2 rmind * DESCRIPTION: Merge a list of resource descriptors into a single AML buffer,
937 1.1.1.2.4.2 rmind * in preparation for output to the AML output file.
938 1.1.1.2.4.2 rmind *
939 1.1.1.2.4.2 rmind ******************************************************************************/
940 1.1.1.2.4.2 rmind
941 1.1.1.2.4.2 rmind void
942 1.1.1.2.4.2 rmind RsDoResourceTemplate (
943 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
944 1.1.1.2.4.2 rmind {
945 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *BufferLengthOp;
946 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *BufferOp;
947 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *DescriptorTypeOp;
948 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *LastOp = NULL;
949 1.1.1.2.4.2 rmind UINT32 CurrentByteOffset = 0;
950 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE HeadRnode;
951 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *PreviousRnode;
952 1.1.1.2.4.2 rmind ASL_RESOURCE_NODE *Rnode;
953 1.1.1.2.4.2 rmind UINT8 State;
954 1.1.1.2.4.2 rmind
955 1.1.1.2.4.2 rmind
956 1.1.1.2.4.2 rmind /* Mark parent as containing a resource template */
957 1.1.1.2.4.2 rmind
958 1.1.1.2.4.2 rmind if (Op->Asl.Parent)
959 1.1.1.2.4.2 rmind {
960 1.1.1.2.4.2 rmind Op->Asl.Parent->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC;
961 1.1.1.2.4.2 rmind }
962 1.1.1.2.4.2 rmind
963 1.1.1.2.4.2 rmind /* ResourceTemplate Opcode is first (Op) */
964 1.1.1.2.4.2 rmind /* Buffer Length node is first child */
965 1.1.1.2.4.2 rmind
966 1.1.1.2.4.2 rmind BufferLengthOp = ASL_GET_CHILD_NODE (Op);
967 1.1.1.2.4.2 rmind
968 1.1.1.2.4.2 rmind /* Buffer Op is first peer */
969 1.1.1.2.4.2 rmind
970 1.1.1.2.4.2 rmind BufferOp = ASL_GET_PEER_NODE (BufferLengthOp);
971 1.1.1.2.4.2 rmind
972 1.1.1.2.4.2 rmind /* First Descriptor type is next */
973 1.1.1.2.4.2 rmind
974 1.1.1.2.4.2 rmind DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp);
975 1.1.1.2.4.2 rmind
976 1.1.1.2.4.2 rmind /*
977 1.1.1.2.4.2 rmind * Process all resource descriptors in the list
978 1.1.1.2.4.2 rmind * Note: It is assumed that the EndTag node has been automatically
979 1.1.1.2.4.2 rmind * inserted at the end of the template by the parser.
980 1.1.1.2.4.2 rmind */
981 1.1.1.2.4.2 rmind State = ACPI_RSTATE_NORMAL;
982 1.1.1.2.4.2 rmind PreviousRnode = &HeadRnode;
983 1.1.1.2.4.2 rmind while (DescriptorTypeOp)
984 1.1.1.2.4.2 rmind {
985 1.1.1.2.4.2 rmind DescriptorTypeOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC;
986 1.1.1.2.4.2 rmind Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset,
987 1.1.1.2.4.2 rmind &State);
988 1.1.1.2.4.2 rmind
989 1.1.1.2.4.2 rmind /*
990 1.1.1.2.4.2 rmind * Update current byte offset to indicate the number of bytes from the
991 1.1.1.2.4.2 rmind * start of the buffer. Buffer can include multiple descriptors, we
992 1.1.1.2.4.2 rmind * must keep track of the offset of not only each descriptor, but each
993 1.1.1.2.4.2 rmind * element (field) within each descriptor as well.
994 1.1.1.2.4.2 rmind */
995 1.1.1.2.4.2 rmind CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
996 1.1.1.2.4.2 rmind
997 1.1.1.2.4.2 rmind /* Get the next descriptor in the list */
998 1.1.1.2.4.2 rmind
999 1.1.1.2.4.2 rmind LastOp = DescriptorTypeOp;
1000 1.1.1.2.4.2 rmind DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp);
1001 1.1.1.2.4.2 rmind }
1002 1.1.1.2.4.2 rmind
1003 1.1.1.2.4.2 rmind if (State == ACPI_RSTATE_DEPENDENT_LIST)
1004 1.1.1.2.4.2 rmind {
1005 1.1.1.2.4.2 rmind if (LastOp)
1006 1.1.1.2.4.2 rmind {
1007 1.1.1.2.4.2 rmind LastOp = LastOp->Asl.Parent;
1008 1.1.1.2.4.2 rmind }
1009 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL);
1010 1.1.1.2.4.2 rmind }
1011 1.1.1.2.4.2 rmind
1012 1.1.1.2.4.2 rmind /*
1013 1.1.1.2.4.2 rmind * Transform the nodes into the following
1014 1.1.1.2.4.2 rmind *
1015 1.1.1.2.4.2 rmind * Op -> AML_BUFFER_OP
1016 1.1.1.2.4.2 rmind * First Child -> BufferLength
1017 1.1.1.2.4.2 rmind * Second Child -> Descriptor Buffer (raw byte data)
1018 1.1.1.2.4.2 rmind */
1019 1.1.1.2.4.2 rmind Op->Asl.ParseOpcode = PARSEOP_BUFFER;
1020 1.1.1.2.4.2 rmind Op->Asl.AmlOpcode = AML_BUFFER_OP;
1021 1.1.1.2.4.2 rmind Op->Asl.CompileFlags = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC;
1022 1.1.1.2.4.2 rmind
1023 1.1.1.2.4.2 rmind BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
1024 1.1.1.2.4.2 rmind BufferLengthOp->Asl.Value.Integer = CurrentByteOffset;
1025 1.1.1.2.4.2 rmind (void) OpcSetOptimalIntegerSize (BufferLengthOp);
1026 1.1.1.2.4.2 rmind
1027 1.1.1.2.4.2 rmind BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
1028 1.1.1.2.4.2 rmind BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
1029 1.1.1.2.4.2 rmind BufferOp->Asl.AmlOpcodeLength = 0;
1030 1.1.1.2.4.2 rmind BufferOp->Asl.AmlLength = CurrentByteOffset;
1031 1.1.1.2.4.2 rmind BufferOp->Asl.Value.Buffer = (UINT8 *) HeadRnode.Next;
1032 1.1.1.2.4.2 rmind BufferOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DATA;
1033 1.1.1.2.4.2 rmind
1034 1.1.1.2.4.2 rmind return;
1035 1.1.1.2.4.2 rmind }
1036 1.1.1.2.4.2 rmind
1037 1.1.1.2.4.2 rmind
1038