diff options
author | Bob Moore <robert.moore@intel.com> | 2005-09-30 19:03:00 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-12-10 00:20:25 -0500 |
commit | 50eca3eb89d73d9f0aa070b126c7ee6a616016ab (patch) | |
tree | b2d06d21b34b9bd17eea4c53cff1f3866fa1b21d /drivers/acpi/resources/rsmisc.c | |
parent | 3d5271f9883cba7b54762bc4fe027d4172f06db7 (diff) |
[ACPI] ACPICA 20050930
Completed a major overhaul of the Resource Manager code -
specifically, optimizations in the area of the AML/internal
resource conversion code. The code has been optimized to
simplify and eliminate duplicated code, CPU stack use has
been decreased by optimizing function parameters and local
variables, and naming conventions across the manager have
been standardized for clarity and ease of maintenance (this
includes function, parameter, variable, and struct/typedef
names.)
All Resource Manager dispatch and information tables have
been moved to a single location for clarity and ease of
maintenance. One new file was created, named "rsinfo.c".
The ACPI return macros (return_ACPI_STATUS, etc.) have
been modified to guarantee that the argument is
not evaluated twice, making them less prone to macro
side-effects. However, since there exists the possibility
of additional stack use if a particular compiler cannot
optimize them (such as in the debug generation case),
the original macros are optionally available. Note that
some invocations of the return_VALUE macro may now cause
size mismatch warnings; the return_UINT8 and return_UINT32
macros are provided to eliminate these. (From Randy Dunlap)
Implemented a new mechanism to enable debug tracing for
individual control methods. A new external interface,
acpi_debug_trace(), is provided to enable this mechanism. The
intent is to allow the host OS to easily enable and disable
tracing for problematic control methods. This interface
can be easily exposed to a user or debugger interface if
desired. See the file psxface.c for details.
acpi_ut_callocate() will now return a valid pointer if a
length of zero is specified - a length of one is used
and a warning is issued. This matches the behavior of
acpi_ut_allocate().
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/resources/rsmisc.c')
-rw-r--r-- | drivers/acpi/resources/rsmisc.c | 711 |
1 files changed, 251 insertions, 460 deletions
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index fa7f5a85b61d..337a0f01cb23 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c | |||
@@ -49,641 +49,432 @@ ACPI_MODULE_NAME("rsmisc") | |||
49 | 49 | ||
50 | /******************************************************************************* | 50 | /******************************************************************************* |
51 | * | 51 | * |
52 | * FUNCTION: acpi_rs_generic_register_resource | 52 | * FUNCTION: acpi_rs_get_generic_reg |
53 | * | 53 | * |
54 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 54 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
55 | * stream | 55 | * aml_resource_length - Length of the resource from the AML header |
56 | * bytes_consumed - Pointer to where the number of bytes | 56 | * Resource - Where the internal resource is returned |
57 | * consumed the byte_stream_buffer is | ||
58 | * returned | ||
59 | * output_buffer - Pointer to the return data buffer | ||
60 | * structure_size - Pointer to where the number of bytes | ||
61 | * in the return data struct is returned | ||
62 | * | 57 | * |
63 | * RETURN: Status | 58 | * RETURN: Status |
64 | * | 59 | * |
65 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 60 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
66 | * structure pointed to by the output_buffer. Return the | 61 | * internal resource descriptor, simplifying bitflags and handling |
67 | * number of bytes consumed from the byte stream. | 62 | * alignment and endian issues if necessary. |
68 | * | 63 | * |
69 | ******************************************************************************/ | 64 | ******************************************************************************/ |
70 | acpi_status | 65 | acpi_status |
71 | acpi_rs_generic_register_resource(u8 * byte_stream_buffer, | 66 | acpi_rs_get_generic_reg(union aml_resource *aml, |
72 | acpi_size * bytes_consumed, | 67 | u16 aml_resource_length, struct acpi_resource *resource) |
73 | u8 ** output_buffer, | ||
74 | acpi_size * structure_size) | ||
75 | { | 68 | { |
76 | u8 *buffer = byte_stream_buffer; | 69 | ACPI_FUNCTION_TRACE("rs_get_generic_reg"); |
77 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
78 | u16 temp16; | ||
79 | u8 temp8; | ||
80 | acpi_size struct_size = | ||
81 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg); | ||
82 | 70 | ||
83 | ACPI_FUNCTION_TRACE("rs_generic_register_resource"); | 71 | /* |
84 | 72 | * Get the following fields from the AML descriptor: | |
85 | /* Byte 0 is the Descriptor Type */ | 73 | * Address Space ID |
86 | 74 | * Register Bit Width | |
87 | buffer += 1; | 75 | * Register Bit Offset |
88 | 76 | * Access Size | |
89 | /* Get the Descriptor Length field (Bytes 1-2) */ | 77 | * Register Address |
90 | 78 | */ | |
91 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 79 | resource->data.generic_reg.space_id = aml->generic_reg.address_space_id; |
92 | buffer += 2; | 80 | resource->data.generic_reg.bit_width = aml->generic_reg.bit_width; |
93 | 81 | resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset; | |
94 | /* Validate the descriptor length */ | 82 | resource->data.generic_reg.access_size = aml->generic_reg.access_size; |
95 | 83 | ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address, | |
96 | if (temp16 != 12) { | 84 | &aml->generic_reg.address); |
97 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | 85 | |
98 | } | 86 | /* Complete the resource header */ |
99 | 87 | ||
100 | /* The number of bytes consumed is fixed (12 + 3) */ | 88 | resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER; |
101 | 89 | resource->length = | |
102 | *bytes_consumed = 15; | 90 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register); |
103 | |||
104 | /* Fill out the structure */ | ||
105 | |||
106 | output_struct->type = ACPI_RSTYPE_GENERIC_REG; | ||
107 | |||
108 | /* Get space_id (Byte 3) */ | ||
109 | |||
110 | temp8 = *buffer; | ||
111 | output_struct->data.generic_reg.space_id = temp8; | ||
112 | buffer += 1; | ||
113 | |||
114 | /* Get register_bit_width (Byte 4) */ | ||
115 | |||
116 | temp8 = *buffer; | ||
117 | output_struct->data.generic_reg.bit_width = temp8; | ||
118 | buffer += 1; | ||
119 | |||
120 | /* Get register_bit_offset (Byte 5) */ | ||
121 | |||
122 | temp8 = *buffer; | ||
123 | output_struct->data.generic_reg.bit_offset = temp8; | ||
124 | buffer += 1; | ||
125 | |||
126 | /* Get address_size (Byte 6) */ | ||
127 | |||
128 | temp8 = *buffer; | ||
129 | output_struct->data.generic_reg.address_size = temp8; | ||
130 | buffer += 1; | ||
131 | |||
132 | /* Get register_address (Bytes 7-14) */ | ||
133 | |||
134 | ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer); | ||
135 | |||
136 | /* Set the Length parameter */ | ||
137 | |||
138 | output_struct->length = (u32) struct_size; | ||
139 | |||
140 | /* Return the final size of the structure */ | ||
141 | |||
142 | *structure_size = struct_size; | ||
143 | return_ACPI_STATUS(AE_OK); | 91 | return_ACPI_STATUS(AE_OK); |
144 | } | 92 | } |
145 | 93 | ||
146 | /******************************************************************************* | 94 | /******************************************************************************* |
147 | * | 95 | * |
148 | * FUNCTION: acpi_rs_generic_register_stream | 96 | * FUNCTION: acpi_rs_set_generic_reg |
149 | * | 97 | * |
150 | * PARAMETERS: Resource - Pointer to the resource linked list | 98 | * PARAMETERS: Resource - Pointer to the resource descriptor |
151 | * output_buffer - Pointer to the user's return buffer | 99 | * Aml - Where the AML descriptor is returned |
152 | * bytes_consumed - Pointer to where the number of bytes | ||
153 | * used in the output_buffer is returned | ||
154 | * | 100 | * |
155 | * RETURN: Status | 101 | * RETURN: Status |
156 | * | 102 | * |
157 | * DESCRIPTION: Take the linked list resource structure and fills in the | 103 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
158 | * the appropriate bytes in a byte stream | 104 | * external AML resource descriptor. |
159 | * | 105 | * |
160 | ******************************************************************************/ | 106 | ******************************************************************************/ |
161 | 107 | ||
162 | acpi_status | 108 | acpi_status |
163 | acpi_rs_generic_register_stream(struct acpi_resource *resource, | 109 | acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml) |
164 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
165 | { | 110 | { |
166 | u8 *buffer = *output_buffer; | 111 | ACPI_FUNCTION_TRACE("rs_set_generic_reg"); |
167 | u16 temp16; | ||
168 | |||
169 | ACPI_FUNCTION_TRACE("rs_generic_register_stream"); | ||
170 | |||
171 | /* Set the Descriptor Type (Byte 0) */ | ||
172 | |||
173 | *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER; | ||
174 | buffer += 1; | ||
175 | |||
176 | /* Set the Descriptor Length (Bytes 1-2) */ | ||
177 | |||
178 | temp16 = 12; | ||
179 | ACPI_MOVE_16_TO_16(buffer, &temp16); | ||
180 | buffer += 2; | ||
181 | |||
182 | /* Set space_id (Byte 3) */ | ||
183 | |||
184 | *buffer = (u8) resource->data.generic_reg.space_id; | ||
185 | buffer += 1; | ||
186 | |||
187 | /* Set register_bit_width (Byte 4) */ | ||
188 | |||
189 | *buffer = (u8) resource->data.generic_reg.bit_width; | ||
190 | buffer += 1; | ||
191 | |||
192 | /* Set register_bit_offset (Byte 5) */ | ||
193 | |||
194 | *buffer = (u8) resource->data.generic_reg.bit_offset; | ||
195 | buffer += 1; | ||
196 | |||
197 | /* Set address_size (Byte 6) */ | ||
198 | |||
199 | *buffer = (u8) resource->data.generic_reg.address_size; | ||
200 | buffer += 1; | ||
201 | |||
202 | /* Set register_address (Bytes 7-14) */ | ||
203 | 112 | ||
204 | ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address); | 113 | /* |
205 | buffer += 8; | 114 | * Set the following fields in the AML descriptor: |
206 | 115 | * Address Space ID | |
207 | /* Return the number of bytes consumed in this operation */ | 116 | * Register Bit Width |
208 | 117 | * Register Bit Offset | |
209 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 118 | * Access Size |
119 | * Register Address | ||
120 | */ | ||
121 | aml->generic_reg.address_space_id = | ||
122 | (u8) resource->data.generic_reg.space_id; | ||
123 | aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width; | ||
124 | aml->generic_reg.bit_offset = | ||
125 | (u8) resource->data.generic_reg.bit_offset; | ||
126 | aml->generic_reg.access_size = | ||
127 | (u8) resource->data.generic_reg.access_size; | ||
128 | ACPI_MOVE_64_TO_64(&aml->generic_reg.address, | ||
129 | &resource->data.generic_reg.address); | ||
130 | |||
131 | /* Complete the AML descriptor header */ | ||
132 | |||
133 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER, | ||
134 | sizeof(struct | ||
135 | aml_resource_generic_register), aml); | ||
210 | return_ACPI_STATUS(AE_OK); | 136 | return_ACPI_STATUS(AE_OK); |
211 | } | 137 | } |
212 | 138 | ||
213 | /******************************************************************************* | 139 | /******************************************************************************* |
214 | * | 140 | * |
215 | * FUNCTION: acpi_rs_end_tag_resource | 141 | * FUNCTION: acpi_rs_get_vendor |
216 | * | 142 | * |
217 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 143 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
218 | * stream | 144 | * aml_resource_length - Length of the resource from the AML header |
219 | * bytes_consumed - Pointer to where the number of bytes | 145 | * Resource - Where the internal resource is returned |
220 | * consumed the byte_stream_buffer is | ||
221 | * returned | ||
222 | * output_buffer - Pointer to the return data buffer | ||
223 | * structure_size - Pointer to where the number of bytes | ||
224 | * in the return data struct is returned | ||
225 | * | 146 | * |
226 | * RETURN: Status | 147 | * RETURN: Status |
227 | * | 148 | * |
228 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 149 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
229 | * structure pointed to by the output_buffer. Return the | 150 | * internal resource descriptor, simplifying bitflags and handling |
230 | * number of bytes consumed from the byte stream. | 151 | * alignment and endian issues if necessary. |
231 | * | 152 | * |
232 | ******************************************************************************/ | 153 | ******************************************************************************/ |
233 | 154 | ||
234 | acpi_status | 155 | acpi_status |
235 | acpi_rs_end_tag_resource(u8 * byte_stream_buffer, | 156 | acpi_rs_get_vendor(union aml_resource *aml, |
236 | acpi_size * bytes_consumed, | 157 | u16 aml_resource_length, struct acpi_resource *resource) |
237 | u8 ** output_buffer, acpi_size * structure_size) | ||
238 | { | 158 | { |
239 | struct acpi_resource *output_struct = (void *)*output_buffer; | 159 | u8 *aml_byte_data; |
240 | acpi_size struct_size = ACPI_RESOURCE_LENGTH; | ||
241 | |||
242 | ACPI_FUNCTION_TRACE("rs_end_tag_resource"); | ||
243 | 160 | ||
244 | /* The number of bytes consumed is static */ | 161 | ACPI_FUNCTION_TRACE("rs_get_vendor"); |
245 | 162 | ||
246 | *bytes_consumed = 2; | 163 | /* Determine if this is a large or small vendor specific item */ |
247 | 164 | ||
248 | /* Fill out the structure */ | 165 | if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { |
166 | /* Large item, Point to the first vendor byte */ | ||
249 | 167 | ||
250 | output_struct->type = ACPI_RSTYPE_END_TAG; | 168 | aml_byte_data = |
169 | ((u8 *) aml) + sizeof(struct aml_resource_large_header); | ||
170 | } else { | ||
171 | /* Small item, Point to the first vendor byte */ | ||
251 | 172 | ||
252 | /* Set the Length parameter */ | 173 | aml_byte_data = |
174 | ((u8 *) aml) + sizeof(struct aml_resource_small_header); | ||
175 | } | ||
253 | 176 | ||
254 | output_struct->length = 0; | 177 | /* Copy the vendor-specific bytes */ |
255 | 178 | ||
256 | /* Return the final size of the structure */ | 179 | ACPI_MEMCPY(resource->data.vendor.byte_data, |
180 | aml_byte_data, aml_resource_length); | ||
181 | resource->data.vendor.byte_length = aml_resource_length; | ||
257 | 182 | ||
258 | *structure_size = struct_size; | 183 | /* |
184 | * In order for the struct_size to fall on a 32-bit boundary, | ||
185 | * calculate the length of the vendor string and expand the | ||
186 | * struct_size to the next 32-bit boundary. | ||
187 | */ | ||
188 | resource->type = ACPI_RESOURCE_TYPE_VENDOR; | ||
189 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + | ||
190 | ACPI_ROUND_UP_to_32_bITS(aml_resource_length); | ||
259 | return_ACPI_STATUS(AE_OK); | 191 | return_ACPI_STATUS(AE_OK); |
260 | } | 192 | } |
261 | 193 | ||
262 | /******************************************************************************* | 194 | /******************************************************************************* |
263 | * | 195 | * |
264 | * FUNCTION: acpi_rs_end_tag_stream | 196 | * FUNCTION: acpi_rs_set_vendor |
265 | * | 197 | * |
266 | * PARAMETERS: Resource - Pointer to the resource linked list | 198 | * PARAMETERS: Resource - Pointer to the resource descriptor |
267 | * output_buffer - Pointer to the user's return buffer | 199 | * Aml - Where the AML descriptor is returned |
268 | * bytes_consumed - Pointer to where the number of bytes | ||
269 | * used in the output_buffer is returned | ||
270 | * | 200 | * |
271 | * RETURN: Status | 201 | * RETURN: Status |
272 | * | 202 | * |
273 | * DESCRIPTION: Take the linked list resource structure and fills in the | 203 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
274 | * the appropriate bytes in a byte stream | 204 | * external AML resource descriptor. |
275 | * | 205 | * |
276 | ******************************************************************************/ | 206 | ******************************************************************************/ |
277 | 207 | ||
278 | acpi_status | 208 | acpi_status |
279 | acpi_rs_end_tag_stream(struct acpi_resource *resource, | 209 | acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) |
280 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
281 | { | 210 | { |
282 | u8 *buffer = *output_buffer; | 211 | u32 resource_length; |
283 | u8 temp8 = 0; | 212 | u8 *source; |
213 | u8 *destination; | ||
284 | 214 | ||
285 | ACPI_FUNCTION_TRACE("rs_end_tag_stream"); | 215 | ACPI_FUNCTION_TRACE("rs_set_vendor"); |
286 | 216 | ||
287 | /* The Descriptor Type field is static */ | 217 | resource_length = resource->data.vendor.byte_length; |
218 | source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data); | ||
288 | 219 | ||
289 | *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01; | 220 | /* Length determines if this is a large or small resource */ |
290 | buffer += 1; | ||
291 | 221 | ||
292 | /* | 222 | if (resource_length > 7) { |
293 | * Set the Checksum - zero means that the resource data is treated as if | 223 | /* Large item, get pointer to the data part of the descriptor */ |
294 | * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) | 224 | |
295 | */ | 225 | destination = |
296 | temp8 = 0; | 226 | ((u8 *) aml) + sizeof(struct aml_resource_large_header); |
227 | |||
228 | /* Complete the AML descriptor header */ | ||
229 | |||
230 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, | ||
231 | (u32) (resource_length + | ||
232 | sizeof(struct | ||
233 | aml_resource_large_header)), | ||
234 | aml); | ||
235 | } else { | ||
236 | /* Small item, get pointer to the data part of the descriptor */ | ||
297 | 237 | ||
298 | *buffer = temp8; | 238 | destination = |
299 | buffer += 1; | 239 | ((u8 *) aml) + sizeof(struct aml_resource_small_header); |
300 | 240 | ||
301 | /* Return the number of bytes consumed in this operation */ | 241 | /* Complete the AML descriptor header */ |
302 | 242 | ||
303 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 243 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL, |
244 | (u32) (resource_length + | ||
245 | sizeof(struct | ||
246 | aml_resource_small_header)), | ||
247 | aml); | ||
248 | } | ||
249 | |||
250 | /* Copy the vendor-specific bytes */ | ||
251 | |||
252 | ACPI_MEMCPY(destination, source, resource_length); | ||
304 | return_ACPI_STATUS(AE_OK); | 253 | return_ACPI_STATUS(AE_OK); |
305 | } | 254 | } |
306 | 255 | ||
307 | /******************************************************************************* | 256 | /******************************************************************************* |
308 | * | 257 | * |
309 | * FUNCTION: acpi_rs_vendor_resource | 258 | * FUNCTION: acpi_rs_get_start_dpf |
310 | * | 259 | * |
311 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 260 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
312 | * stream | 261 | * aml_resource_length - Length of the resource from the AML header |
313 | * bytes_consumed - Pointer to where the number of bytes | 262 | * Resource - Where the internal resource is returned |
314 | * consumed the byte_stream_buffer is | ||
315 | * returned | ||
316 | * output_buffer - Pointer to the return data buffer | ||
317 | * structure_size - Pointer to where the number of bytes | ||
318 | * in the return data struct is returned | ||
319 | * | 263 | * |
320 | * RETURN: Status | 264 | * RETURN: Status |
321 | * | 265 | * |
322 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 266 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
323 | * structure pointed to by the output_buffer. Return the | 267 | * internal resource descriptor, simplifying bitflags and handling |
324 | * number of bytes consumed from the byte stream. | 268 | * alignment and endian issues if necessary. |
325 | * | 269 | * |
326 | ******************************************************************************/ | 270 | ******************************************************************************/ |
327 | 271 | ||
328 | acpi_status | 272 | acpi_status |
329 | acpi_rs_vendor_resource(u8 * byte_stream_buffer, | 273 | acpi_rs_get_start_dpf(union aml_resource *aml, |
330 | acpi_size * bytes_consumed, | 274 | u16 aml_resource_length, struct acpi_resource *resource) |
331 | u8 ** output_buffer, acpi_size * structure_size) | ||
332 | { | 275 | { |
333 | u8 *buffer = byte_stream_buffer; | 276 | ACPI_FUNCTION_TRACE("rs_get_start_dpf"); |
334 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
335 | u16 temp16 = 0; | ||
336 | u8 temp8 = 0; | ||
337 | u8 index; | ||
338 | acpi_size struct_size = | ||
339 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor); | ||
340 | |||
341 | ACPI_FUNCTION_TRACE("rs_vendor_resource"); | ||
342 | |||
343 | /* Dereference the Descriptor to find if this is a large or small item. */ | ||
344 | 277 | ||
345 | temp8 = *buffer; | 278 | /* Get the flags byte if present */ |
346 | 279 | ||
347 | if (temp8 & ACPI_RDESC_TYPE_LARGE) { | 280 | if (aml_resource_length == 1) { |
348 | /* Large Item, point to the length field */ | 281 | /* Get the Compatibility priority */ |
349 | 282 | ||
350 | buffer += 1; | 283 | resource->data.start_dpf.compatibility_priority = |
284 | (aml->start_dpf.flags & 0x03); | ||
351 | 285 | ||
352 | /* Dereference */ | 286 | if (resource->data.start_dpf.compatibility_priority >= 3) { |
353 | 287 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | |
354 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 288 | } |
355 | |||
356 | /* Calculate bytes consumed */ | ||
357 | 289 | ||
358 | *bytes_consumed = (acpi_size) temp16 + 3; | 290 | /* Get the Performance/Robustness preference */ |
359 | 291 | ||
360 | /* Point to the first vendor byte */ | 292 | resource->data.start_dpf.performance_robustness = |
293 | ((aml->start_dpf.flags >> 2) & 0x03); | ||
361 | 294 | ||
362 | buffer += 2; | 295 | if (resource->data.start_dpf.performance_robustness >= 3) { |
296 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | ||
297 | } | ||
363 | } else { | 298 | } else { |
364 | /* Small Item, dereference the size */ | 299 | /* start_dependent_no_pri(), no flags byte, set defaults */ |
365 | |||
366 | temp16 = (u8) (*buffer & 0x07); | ||
367 | |||
368 | /* Calculate bytes consumed */ | ||
369 | 300 | ||
370 | *bytes_consumed = (acpi_size) temp16 + 1; | 301 | resource->data.start_dpf.compatibility_priority = |
371 | 302 | ACPI_ACCEPTABLE_CONFIGURATION; | |
372 | /* Point to the first vendor byte */ | ||
373 | 303 | ||
374 | buffer += 1; | 304 | resource->data.start_dpf.performance_robustness = |
305 | ACPI_ACCEPTABLE_CONFIGURATION; | ||
375 | } | 306 | } |
376 | 307 | ||
377 | output_struct->type = ACPI_RSTYPE_VENDOR; | 308 | /* Complete the resource header */ |
378 | output_struct->data.vendor_specific.length = temp16; | ||
379 | |||
380 | for (index = 0; index < temp16; index++) { | ||
381 | output_struct->data.vendor_specific.reserved[index] = *buffer; | ||
382 | buffer += 1; | ||
383 | } | ||
384 | 309 | ||
385 | /* | 310 | resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT; |
386 | * In order for the struct_size to fall on a 32-bit boundary, | 311 | resource->length = |
387 | * calculate the length of the vendor string and expand the | 312 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent); |
388 | * struct_size to the next 32-bit boundary. | ||
389 | */ | ||
390 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); | ||
391 | |||
392 | /* Set the Length parameter */ | ||
393 | |||
394 | output_struct->length = (u32) struct_size; | ||
395 | |||
396 | /* Return the final size of the structure */ | ||
397 | |||
398 | *structure_size = struct_size; | ||
399 | return_ACPI_STATUS(AE_OK); | 313 | return_ACPI_STATUS(AE_OK); |
400 | } | 314 | } |
401 | 315 | ||
402 | /******************************************************************************* | 316 | /******************************************************************************* |
403 | * | 317 | * |
404 | * FUNCTION: acpi_rs_vendor_stream | 318 | * FUNCTION: acpi_rs_set_start_dpf |
405 | * | 319 | * |
406 | * PARAMETERS: Resource - Pointer to the resource linked list | 320 | * PARAMETERS: Resource - Pointer to the resource descriptor |
407 | * output_buffer - Pointer to the user's return buffer | 321 | * Aml - Where the AML descriptor is returned |
408 | * bytes_consumed - Pointer to where the number of bytes | ||
409 | * used in the output_buffer is returned | ||
410 | * | 322 | * |
411 | * RETURN: Status | 323 | * RETURN: Status |
412 | * | 324 | * |
413 | * DESCRIPTION: Take the linked list resource structure and fills in the | 325 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
414 | * the appropriate bytes in a byte stream | 326 | * external AML resource descriptor. |
415 | * | 327 | * |
416 | ******************************************************************************/ | 328 | ******************************************************************************/ |
417 | 329 | ||
418 | acpi_status | 330 | acpi_status |
419 | acpi_rs_vendor_stream(struct acpi_resource *resource, | 331 | acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml) |
420 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
421 | { | 332 | { |
422 | u8 *buffer = *output_buffer; | 333 | ACPI_FUNCTION_TRACE("rs_set_start_dpf"); |
423 | u16 temp16 = 0; | ||
424 | u8 temp8 = 0; | ||
425 | u8 index; | ||
426 | |||
427 | ACPI_FUNCTION_TRACE("rs_vendor_stream"); | ||
428 | |||
429 | /* Dereference the length to find if this is a large or small item. */ | ||
430 | |||
431 | if (resource->data.vendor_specific.length > 7) { | ||
432 | /* Large Item, Set the descriptor field and length bytes */ | ||
433 | 334 | ||
434 | *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR; | 335 | /* |
435 | buffer += 1; | 336 | * The descriptor type field is set based upon whether a byte is needed |
436 | 337 | * to contain Priority data. | |
437 | temp16 = (u16) resource->data.vendor_specific.length; | 338 | */ |
438 | 339 | if (ACPI_ACCEPTABLE_CONFIGURATION == | |
439 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 340 | resource->data.start_dpf.compatibility_priority && |
440 | buffer += 2; | 341 | ACPI_ACCEPTABLE_CONFIGURATION == |
342 | resource->data.start_dpf.performance_robustness) { | ||
343 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, | ||
344 | sizeof(struct | ||
345 | aml_resource_start_dependent_noprio), | ||
346 | aml); | ||
441 | } else { | 347 | } else { |
442 | /* Small Item, Set the descriptor field */ | 348 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, |
443 | 349 | sizeof(struct | |
444 | temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR; | 350 | aml_resource_start_dependent), |
445 | temp8 |= (u8) resource->data.vendor_specific.length; | 351 | aml); |
446 | 352 | ||
447 | *buffer = temp8; | 353 | /* Set the Flags byte */ |
448 | buffer += 1; | 354 | |
449 | } | 355 | aml->start_dpf.flags = (u8) |
450 | 356 | (((resource->data.start_dpf. | |
451 | /* Loop through all of the Vendor Specific fields */ | 357 | performance_robustness & 0x03) << 2) | (resource->data. |
452 | 358 | start_dpf. | |
453 | for (index = 0; index < resource->data.vendor_specific.length; index++) { | 359 | compatibility_priority |
454 | temp8 = resource->data.vendor_specific.reserved[index]; | 360 | & 0x03)); |
455 | |||
456 | *buffer = temp8; | ||
457 | buffer += 1; | ||
458 | } | 361 | } |
459 | |||
460 | /* Return the number of bytes consumed in this operation */ | ||
461 | |||
462 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
463 | return_ACPI_STATUS(AE_OK); | 362 | return_ACPI_STATUS(AE_OK); |
464 | } | 363 | } |
465 | 364 | ||
466 | /******************************************************************************* | 365 | /******************************************************************************* |
467 | * | 366 | * |
468 | * FUNCTION: acpi_rs_start_depend_fns_resource | 367 | * FUNCTION: acpi_rs_get_end_dpf |
469 | * | 368 | * |
470 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 369 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
471 | * stream | 370 | * aml_resource_length - Length of the resource from the AML header |
472 | * bytes_consumed - Pointer to where the number of bytes | 371 | * Resource - Where the internal resource is returned |
473 | * consumed the byte_stream_buffer is | ||
474 | * returned | ||
475 | * output_buffer - Pointer to the return data buffer | ||
476 | * structure_size - Pointer to where the number of bytes | ||
477 | * in the return data struct is returned | ||
478 | * | 372 | * |
479 | * RETURN: Status | 373 | * RETURN: Status |
480 | * | 374 | * |
481 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 375 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
482 | * structure pointed to by the output_buffer. Return the | 376 | * internal resource descriptor, simplifying bitflags and handling |
483 | * number of bytes consumed from the byte stream. | 377 | * alignment and endian issues if necessary. |
484 | * | 378 | * |
485 | ******************************************************************************/ | 379 | ******************************************************************************/ |
486 | 380 | ||
487 | acpi_status | 381 | acpi_status |
488 | acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, | 382 | acpi_rs_get_end_dpf(union aml_resource *aml, |
489 | acpi_size * bytes_consumed, | 383 | u16 aml_resource_length, struct acpi_resource *resource) |
490 | u8 ** output_buffer, | ||
491 | acpi_size * structure_size) | ||
492 | { | 384 | { |
493 | u8 *buffer = byte_stream_buffer; | 385 | ACPI_FUNCTION_TRACE("rs_get_end_dpf"); |
494 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
495 | u8 temp8 = 0; | ||
496 | acpi_size struct_size = | ||
497 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); | ||
498 | |||
499 | ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource"); | ||
500 | |||
501 | /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ | ||
502 | |||
503 | temp8 = *buffer; | ||
504 | |||
505 | *bytes_consumed = (temp8 & 0x01) + 1; | ||
506 | |||
507 | output_struct->type = ACPI_RSTYPE_START_DPF; | ||
508 | |||
509 | /* Point to Byte 1 if it is used */ | ||
510 | |||
511 | if (2 == *bytes_consumed) { | ||
512 | buffer += 1; | ||
513 | temp8 = *buffer; | ||
514 | |||
515 | /* Check Compatibility priority */ | ||
516 | |||
517 | output_struct->data.start_dpf.compatibility_priority = | ||
518 | temp8 & 0x03; | ||
519 | |||
520 | if (3 == output_struct->data.start_dpf.compatibility_priority) { | ||
521 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | ||
522 | } | ||
523 | 386 | ||
524 | /* Check Performance/Robustness preference */ | 387 | /* Complete the resource header */ |
525 | 388 | ||
526 | output_struct->data.start_dpf.performance_robustness = | 389 | resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT; |
527 | (temp8 >> 2) & 0x03; | 390 | resource->length = (u32) ACPI_RESOURCE_LENGTH; |
528 | |||
529 | if (3 == output_struct->data.start_dpf.performance_robustness) { | ||
530 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | ||
531 | } | ||
532 | } else { | ||
533 | output_struct->data.start_dpf.compatibility_priority = | ||
534 | ACPI_ACCEPTABLE_CONFIGURATION; | ||
535 | |||
536 | output_struct->data.start_dpf.performance_robustness = | ||
537 | ACPI_ACCEPTABLE_CONFIGURATION; | ||
538 | } | ||
539 | |||
540 | /* Set the Length parameter */ | ||
541 | |||
542 | output_struct->length = (u32) struct_size; | ||
543 | |||
544 | /* Return the final size of the structure */ | ||
545 | |||
546 | *structure_size = struct_size; | ||
547 | return_ACPI_STATUS(AE_OK); | 391 | return_ACPI_STATUS(AE_OK); |
548 | } | 392 | } |
549 | 393 | ||
550 | /******************************************************************************* | 394 | /******************************************************************************* |
551 | * | 395 | * |
552 | * FUNCTION: acpi_rs_end_depend_fns_resource | 396 | * FUNCTION: acpi_rs_set_end_dpf |
553 | * | 397 | * |
554 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 398 | * PARAMETERS: Resource - Pointer to the resource descriptor |
555 | * stream | 399 | * Aml - Where the AML descriptor is returned |
556 | * bytes_consumed - Pointer to where the number of bytes | ||
557 | * consumed the byte_stream_buffer is | ||
558 | * returned | ||
559 | * output_buffer - Pointer to the return data buffer | ||
560 | * structure_size - Pointer to where the number of bytes | ||
561 | * in the return data struct is returned | ||
562 | * | 400 | * |
563 | * RETURN: Status | 401 | * RETURN: Status |
564 | * | 402 | * |
565 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 403 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
566 | * structure pointed to by the output_buffer. Return the | 404 | * external AML resource descriptor. |
567 | * number of bytes consumed from the byte stream. | ||
568 | * | 405 | * |
569 | ******************************************************************************/ | 406 | ******************************************************************************/ |
570 | 407 | ||
571 | acpi_status | 408 | acpi_status |
572 | acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, | 409 | acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml) |
573 | acpi_size * bytes_consumed, | ||
574 | u8 ** output_buffer, acpi_size * structure_size) | ||
575 | { | 410 | { |
576 | struct acpi_resource *output_struct = (void *)*output_buffer; | 411 | ACPI_FUNCTION_TRACE("rs_set_end_dpf"); |
577 | acpi_size struct_size = ACPI_RESOURCE_LENGTH; | ||
578 | |||
579 | ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource"); | ||
580 | |||
581 | /* The number of bytes consumed is static */ | ||
582 | |||
583 | *bytes_consumed = 1; | ||
584 | 412 | ||
585 | /* Fill out the structure */ | 413 | /* Complete the AML descriptor header */ |
586 | 414 | ||
587 | output_struct->type = ACPI_RSTYPE_END_DPF; | 415 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT, |
588 | 416 | sizeof(struct aml_resource_end_dependent), | |
589 | /* Set the Length parameter */ | 417 | aml); |
590 | |||
591 | output_struct->length = (u32) struct_size; | ||
592 | |||
593 | /* Return the final size of the structure */ | ||
594 | |||
595 | *structure_size = struct_size; | ||
596 | return_ACPI_STATUS(AE_OK); | 418 | return_ACPI_STATUS(AE_OK); |
597 | } | 419 | } |
598 | 420 | ||
599 | /******************************************************************************* | 421 | /******************************************************************************* |
600 | * | 422 | * |
601 | * FUNCTION: acpi_rs_start_depend_fns_stream | 423 | * FUNCTION: acpi_rs_get_end_tag |
602 | * | 424 | * |
603 | * PARAMETERS: Resource - Pointer to the resource linked list | 425 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
604 | * output_buffer - Pointer to the user's return buffer | 426 | * aml_resource_length - Length of the resource from the AML header |
605 | * bytes_consumed - u32 pointer that is filled with | 427 | * Resource - Where the internal resource is returned |
606 | * the number of bytes of the | ||
607 | * output_buffer used | ||
608 | * | 428 | * |
609 | * RETURN: Status | 429 | * RETURN: Status |
610 | * | 430 | * |
611 | * DESCRIPTION: Take the linked list resource structure and fills in the | 431 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
612 | * the appropriate bytes in a byte stream | 432 | * internal resource descriptor, simplifying bitflags and handling |
433 | * alignment and endian issues if necessary. | ||
613 | * | 434 | * |
614 | ******************************************************************************/ | 435 | ******************************************************************************/ |
615 | 436 | ||
616 | acpi_status | 437 | acpi_status |
617 | acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, | 438 | acpi_rs_get_end_tag(union aml_resource *aml, |
618 | u8 ** output_buffer, acpi_size * bytes_consumed) | 439 | u16 aml_resource_length, struct acpi_resource *resource) |
619 | { | 440 | { |
620 | u8 *buffer = *output_buffer; | 441 | ACPI_FUNCTION_TRACE("rs_get_end_tag"); |
621 | u8 temp8 = 0; | ||
622 | |||
623 | ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); | ||
624 | 442 | ||
625 | /* | 443 | /* Complete the resource header */ |
626 | * The descriptor type field is set based upon whether a byte is needed | ||
627 | * to contain Priority data. | ||
628 | */ | ||
629 | if (ACPI_ACCEPTABLE_CONFIGURATION == | ||
630 | resource->data.start_dpf.compatibility_priority && | ||
631 | ACPI_ACCEPTABLE_CONFIGURATION == | ||
632 | resource->data.start_dpf.performance_robustness) { | ||
633 | *buffer = ACPI_RDESC_TYPE_START_DEPENDENT; | ||
634 | } else { | ||
635 | *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01; | ||
636 | buffer += 1; | ||
637 | |||
638 | /* Set the Priority Byte Definition */ | ||
639 | 444 | ||
640 | temp8 = 0; | 445 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
641 | temp8 = (u8) ((resource->data.start_dpf.performance_robustness & | 446 | resource->length = ACPI_RESOURCE_LENGTH; |
642 | 0x03) << 2); | ||
643 | temp8 |= (resource->data.start_dpf.compatibility_priority & | ||
644 | 0x03); | ||
645 | *buffer = temp8; | ||
646 | } | ||
647 | |||
648 | buffer += 1; | ||
649 | |||
650 | /* Return the number of bytes consumed in this operation */ | ||
651 | |||
652 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
653 | return_ACPI_STATUS(AE_OK); | 447 | return_ACPI_STATUS(AE_OK); |
654 | } | 448 | } |
655 | 449 | ||
656 | /******************************************************************************* | 450 | /******************************************************************************* |
657 | * | 451 | * |
658 | * FUNCTION: acpi_rs_end_depend_fns_stream | 452 | * FUNCTION: acpi_rs_set_end_tag |
659 | * | 453 | * |
660 | * PARAMETERS: Resource - Pointer to the resource linked list | 454 | * PARAMETERS: Resource - Pointer to the resource descriptor |
661 | * output_buffer - Pointer to the user's return buffer | 455 | * Aml - Where the AML descriptor is returned |
662 | * bytes_consumed - Pointer to where the number of bytes | ||
663 | * used in the output_buffer is returned | ||
664 | * | 456 | * |
665 | * RETURN: Status | 457 | * RETURN: Status |
666 | * | 458 | * |
667 | * DESCRIPTION: Take the linked list resource structure and fills in the | 459 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
668 | * the appropriate bytes in a byte stream | 460 | * external AML resource descriptor. |
669 | * | 461 | * |
670 | ******************************************************************************/ | 462 | ******************************************************************************/ |
671 | 463 | ||
672 | acpi_status | 464 | acpi_status |
673 | acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, | 465 | acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml) |
674 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
675 | { | 466 | { |
676 | u8 *buffer = *output_buffer; | 467 | ACPI_FUNCTION_TRACE("rs_set_end_tag"); |
677 | |||
678 | ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); | ||
679 | 468 | ||
680 | /* The Descriptor Type field is static */ | 469 | /* |
681 | 470 | * Set the Checksum - zero means that the resource data is treated as if | |
682 | *buffer = ACPI_RDESC_TYPE_END_DEPENDENT; | 471 | * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) |
683 | buffer += 1; | 472 | */ |
473 | aml->end_tag.checksum = 0; | ||
684 | 474 | ||
685 | /* Return the number of bytes consumed in this operation */ | 475 | /* Complete the AML descriptor header */ |
686 | 476 | ||
687 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 477 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG, |
478 | sizeof(struct aml_resource_end_tag), aml); | ||
688 | return_ACPI_STATUS(AE_OK); | 479 | return_ACPI_STATUS(AE_OK); |
689 | } | 480 | } |