xref: /linux/drivers/acpi/acpica/rsmisc.c (revision 4fa4616e279df89baeb36287bbee83ab272edaed)
195b482a8SLen Brown /*******************************************************************************
295b482a8SLen Brown  *
395b482a8SLen Brown  * Module Name: rsmisc - Miscellaneous resource descriptors
495b482a8SLen Brown  *
595b482a8SLen Brown  ******************************************************************************/
695b482a8SLen Brown 
795b482a8SLen Brown /*
882a80941SDavid E. Box  * Copyright (C) 2000 - 2015, Intel Corp.
995b482a8SLen Brown  * All rights reserved.
1095b482a8SLen Brown  *
1195b482a8SLen Brown  * Redistribution and use in source and binary forms, with or without
1295b482a8SLen Brown  * modification, are permitted provided that the following conditions
1395b482a8SLen Brown  * are met:
1495b482a8SLen Brown  * 1. Redistributions of source code must retain the above copyright
1595b482a8SLen Brown  *    notice, this list of conditions, and the following disclaimer,
1695b482a8SLen Brown  *    without modification.
1795b482a8SLen Brown  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1895b482a8SLen Brown  *    substantially similar to the "NO WARRANTY" disclaimer below
1995b482a8SLen Brown  *    ("Disclaimer") and any redistribution must be conditioned upon
2095b482a8SLen Brown  *    including a substantially similar Disclaimer requirement for further
2195b482a8SLen Brown  *    binary redistribution.
2295b482a8SLen Brown  * 3. Neither the names of the above-listed copyright holders nor the names
2395b482a8SLen Brown  *    of any contributors may be used to endorse or promote products derived
2495b482a8SLen Brown  *    from this software without specific prior written permission.
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * Alternatively, this software may be distributed under the terms of the
2795b482a8SLen Brown  * GNU General Public License ("GPL") version 2 as published by the Free
2895b482a8SLen Brown  * Software Foundation.
2995b482a8SLen Brown  *
3095b482a8SLen Brown  * NO WARRANTY
3195b482a8SLen Brown  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3295b482a8SLen Brown  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3395b482a8SLen Brown  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3495b482a8SLen Brown  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3595b482a8SLen Brown  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3695b482a8SLen Brown  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3795b482a8SLen Brown  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3895b482a8SLen Brown  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3995b482a8SLen Brown  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4095b482a8SLen Brown  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4195b482a8SLen Brown  * POSSIBILITY OF SUCH DAMAGES.
4295b482a8SLen Brown  */
4395b482a8SLen Brown 
4495b482a8SLen Brown #include <acpi/acpi.h>
45e2f7a777SLen Brown #include "accommon.h"
46e2f7a777SLen Brown #include "acresrc.h"
4795b482a8SLen Brown 
4895b482a8SLen Brown #define _COMPONENT          ACPI_RESOURCES
4995b482a8SLen Brown ACPI_MODULE_NAME("rsmisc")
5095b482a8SLen Brown #define INIT_RESOURCE_TYPE(i)       i->resource_offset
5195b482a8SLen Brown #define INIT_RESOURCE_LENGTH(i)     i->aml_offset
5295b482a8SLen Brown #define INIT_TABLE_LENGTH(i)        i->value
5395b482a8SLen Brown #define COMPARE_OPCODE(i)           i->resource_offset
5495b482a8SLen Brown #define COMPARE_TARGET(i)           i->aml_offset
5595b482a8SLen Brown #define COMPARE_VALUE(i)            i->value
5695b482a8SLen Brown /*******************************************************************************
5795b482a8SLen Brown  *
5895b482a8SLen Brown  * FUNCTION:    acpi_rs_convert_aml_to_resource
5995b482a8SLen Brown  *
60ba494beeSBob Moore  * PARAMETERS:  resource            - Pointer to the resource descriptor
61ba494beeSBob Moore  *              aml                 - Where the AML descriptor is returned
62ba494beeSBob Moore  *              info                - Pointer to appropriate conversion table
6395b482a8SLen Brown  *
6495b482a8SLen Brown  * RETURN:      Status
6595b482a8SLen Brown  *
6695b482a8SLen Brown  * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
6795b482a8SLen Brown  *              internal resource descriptor
6895b482a8SLen Brown  *
6995b482a8SLen Brown  ******************************************************************************/
7095b482a8SLen Brown acpi_status
7195b482a8SLen Brown acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
7295b482a8SLen Brown 				union aml_resource *aml,
7395b482a8SLen Brown 				struct acpi_rsconvert_info *info)
7495b482a8SLen Brown {
7595b482a8SLen Brown 	acpi_rs_length aml_resource_length;
7695b482a8SLen Brown 	void *source;
7795b482a8SLen Brown 	void *destination;
7895b482a8SLen Brown 	char *target;
7995b482a8SLen Brown 	u8 count;
8095b482a8SLen Brown 	u8 flags_mode = FALSE;
8195b482a8SLen Brown 	u16 item_count = 0;
8295b482a8SLen Brown 	u16 temp16 = 0;
8395b482a8SLen Brown 
8495b482a8SLen Brown 	ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource);
8595b482a8SLen Brown 
86e0fe0a8dSLin Ming 	if (!info) {
87e0fe0a8dSLin Ming 		return_ACPI_STATUS(AE_BAD_PARAMETER);
88e0fe0a8dSLin Ming 	}
89e0fe0a8dSLin Ming 
9095b482a8SLen Brown 	if (((acpi_size) resource) & 0x3) {
9195b482a8SLen Brown 
9295b482a8SLen Brown 		/* Each internal resource struct is expected to be 32-bit aligned */
9395b482a8SLen Brown 
9495b482a8SLen Brown 		ACPI_WARNING((AE_INFO,
95f6a22b0bSBob Moore 			      "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
9695b482a8SLen Brown 			      resource, resource->type, resource->length));
9795b482a8SLen Brown 	}
9895b482a8SLen Brown 
9995b482a8SLen Brown 	/* Extract the resource Length field (does not include header length) */
10095b482a8SLen Brown 
10195b482a8SLen Brown 	aml_resource_length = acpi_ut_get_resource_length(aml);
10295b482a8SLen Brown 
10395b482a8SLen Brown 	/*
10495b482a8SLen Brown 	 * First table entry must be ACPI_RSC_INITxxx and must contain the
10595b482a8SLen Brown 	 * table length (# of table entries)
10695b482a8SLen Brown 	 */
10795b482a8SLen Brown 	count = INIT_TABLE_LENGTH(info);
10895b482a8SLen Brown 	while (count) {
10995b482a8SLen Brown 		/*
11095b482a8SLen Brown 		 * Source is the external AML byte stream buffer,
11195b482a8SLen Brown 		 * destination is the internal resource descriptor
11295b482a8SLen Brown 		 */
11395b482a8SLen Brown 		source = ACPI_ADD_PTR(void, aml, info->aml_offset);
11495b482a8SLen Brown 		destination =
11595b482a8SLen Brown 		    ACPI_ADD_PTR(void, resource, info->resource_offset);
11695b482a8SLen Brown 
11795b482a8SLen Brown 		switch (info->opcode) {
11895b482a8SLen Brown 		case ACPI_RSC_INITGET:
11995b482a8SLen Brown 			/*
12095b482a8SLen Brown 			 * Get the resource type and the initial (minimum) length
12195b482a8SLen Brown 			 */
122*4fa4616eSBob Moore 			memset(resource, 0, INIT_RESOURCE_LENGTH(info));
12395b482a8SLen Brown 			resource->type = INIT_RESOURCE_TYPE(info);
12495b482a8SLen Brown 			resource->length = INIT_RESOURCE_LENGTH(info);
12595b482a8SLen Brown 			break;
12695b482a8SLen Brown 
12795b482a8SLen Brown 		case ACPI_RSC_INITSET:
12895b482a8SLen Brown 			break;
12995b482a8SLen Brown 
13095b482a8SLen Brown 		case ACPI_RSC_FLAGINIT:
13195b482a8SLen Brown 
13295b482a8SLen Brown 			flags_mode = TRUE;
13395b482a8SLen Brown 			break;
13495b482a8SLen Brown 
13595b482a8SLen Brown 		case ACPI_RSC_1BITFLAG:
13695b482a8SLen Brown 			/*
13795b482a8SLen Brown 			 * Mask and shift the flag bit
13895b482a8SLen Brown 			 */
13957bf6aefSLv Zheng 			ACPI_SET8(destination,
14057bf6aefSLv Zheng 				  ((ACPI_GET8(source) >> info->value) & 0x01));
14195b482a8SLen Brown 			break;
14295b482a8SLen Brown 
14395b482a8SLen Brown 		case ACPI_RSC_2BITFLAG:
14495b482a8SLen Brown 			/*
14595b482a8SLen Brown 			 * Mask and shift the flag bits
14695b482a8SLen Brown 			 */
14757bf6aefSLv Zheng 			ACPI_SET8(destination,
14857bf6aefSLv Zheng 				  ((ACPI_GET8(source) >> info->value) & 0x03));
14995b482a8SLen Brown 			break;
15095b482a8SLen Brown 
151e0fe0a8dSLin Ming 		case ACPI_RSC_3BITFLAG:
152e0fe0a8dSLin Ming 			/*
153e0fe0a8dSLin Ming 			 * Mask and shift the flag bits
154e0fe0a8dSLin Ming 			 */
15557bf6aefSLv Zheng 			ACPI_SET8(destination,
15657bf6aefSLv Zheng 				  ((ACPI_GET8(source) >> info->value) & 0x07));
157e0fe0a8dSLin Ming 			break;
158e0fe0a8dSLin Ming 
15995b482a8SLen Brown 		case ACPI_RSC_COUNT:
16095b482a8SLen Brown 
16195b482a8SLen Brown 			item_count = ACPI_GET8(source);
16257bf6aefSLv Zheng 			ACPI_SET8(destination, item_count);
16395b482a8SLen Brown 
16495b482a8SLen Brown 			resource->length = resource->length +
16595b482a8SLen Brown 			    (info->value * (item_count - 1));
16695b482a8SLen Brown 			break;
16795b482a8SLen Brown 
16895b482a8SLen Brown 		case ACPI_RSC_COUNT16:
16995b482a8SLen Brown 
17095b482a8SLen Brown 			item_count = aml_resource_length;
17157bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
17295b482a8SLen Brown 
17395b482a8SLen Brown 			resource->length = resource->length +
17495b482a8SLen Brown 			    (info->value * (item_count - 1));
17595b482a8SLen Brown 			break;
17695b482a8SLen Brown 
177e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_PIN:
178e0fe0a8dSLin Ming 
179e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, info->value);
180e0fe0a8dSLin Ming 			item_count = ACPI_GET16(target) - ACPI_GET16(source);
181e0fe0a8dSLin Ming 
182e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
183e0fe0a8dSLin Ming 			item_count = item_count / 2;
18457bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
185e0fe0a8dSLin Ming 			break;
186e0fe0a8dSLin Ming 
187e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_VEN:
188e0fe0a8dSLin Ming 
189e0fe0a8dSLin Ming 			item_count = ACPI_GET8(source);
19057bf6aefSLv Zheng 			ACPI_SET8(destination, item_count);
191e0fe0a8dSLin Ming 
192e0fe0a8dSLin Ming 			resource->length = resource->length +
193e0fe0a8dSLin Ming 			    (info->value * item_count);
194e0fe0a8dSLin Ming 			break;
195e0fe0a8dSLin Ming 
196e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_RES:
197e0fe0a8dSLin Ming 			/*
198e0fe0a8dSLin Ming 			 * Vendor data is optional (length/offset may both be zero)
199e0fe0a8dSLin Ming 			 * Examine vendor data length field first
200e0fe0a8dSLin Ming 			 */
201e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, (info->value + 2));
202e0fe0a8dSLin Ming 			if (ACPI_GET16(target)) {
203e0fe0a8dSLin Ming 
204e0fe0a8dSLin Ming 				/* Use vendor offset to get resource source length */
205e0fe0a8dSLin Ming 
206e0fe0a8dSLin Ming 				target = ACPI_ADD_PTR(void, aml, info->value);
207e0fe0a8dSLin Ming 				item_count =
208e0fe0a8dSLin Ming 				    ACPI_GET16(target) - ACPI_GET16(source);
209e0fe0a8dSLin Ming 			} else {
210e0fe0a8dSLin Ming 				/* No vendor data to worry about */
211e0fe0a8dSLin Ming 
212e0fe0a8dSLin Ming 				item_count = aml->large_header.resource_length +
213e0fe0a8dSLin Ming 				    sizeof(struct aml_resource_large_header) -
214e0fe0a8dSLin Ming 				    ACPI_GET16(source);
215e0fe0a8dSLin Ming 			}
216e0fe0a8dSLin Ming 
217e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
21857bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
219e0fe0a8dSLin Ming 			break;
220e0fe0a8dSLin Ming 
221e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_VEN:
222e0fe0a8dSLin Ming 
223e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source) - info->value;
224e0fe0a8dSLin Ming 
225e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
22657bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
227e0fe0a8dSLin Ming 			break;
228e0fe0a8dSLin Ming 
229e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_RES:
230e0fe0a8dSLin Ming 
231e0fe0a8dSLin Ming 			item_count = (aml_resource_length +
232e0fe0a8dSLin Ming 				      sizeof(struct aml_resource_large_header))
233e0fe0a8dSLin Ming 			    - ACPI_GET16(source) - info->value;
234e0fe0a8dSLin Ming 
235e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
23657bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
237e0fe0a8dSLin Ming 			break;
238e0fe0a8dSLin Ming 
23995b482a8SLen Brown 		case ACPI_RSC_LENGTH:
24095b482a8SLen Brown 
24195b482a8SLen Brown 			resource->length = resource->length + info->value;
24295b482a8SLen Brown 			break;
24395b482a8SLen Brown 
24495b482a8SLen Brown 		case ACPI_RSC_MOVE8:
24595b482a8SLen Brown 		case ACPI_RSC_MOVE16:
24695b482a8SLen Brown 		case ACPI_RSC_MOVE32:
24795b482a8SLen Brown 		case ACPI_RSC_MOVE64:
24895b482a8SLen Brown 			/*
24995b482a8SLen Brown 			 * Raw data move. Use the Info value field unless item_count has
25095b482a8SLen Brown 			 * been previously initialized via a COUNT opcode
25195b482a8SLen Brown 			 */
25295b482a8SLen Brown 			if (info->value) {
25395b482a8SLen Brown 				item_count = info->value;
25495b482a8SLen Brown 			}
25595b482a8SLen Brown 			acpi_rs_move_data(destination, source, item_count,
25695b482a8SLen Brown 					  info->opcode);
25795b482a8SLen Brown 			break;
25895b482a8SLen Brown 
259e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_PIN:
260e0fe0a8dSLin Ming 
261e0fe0a8dSLin Ming 			/* Generate and set the PIN data pointer */
262e0fe0a8dSLin Ming 
263e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
264e0fe0a8dSLin Ming 						      (resource->length -
265e0fe0a8dSLin Ming 						       item_count * 2));
266e0fe0a8dSLin Ming 			*(u16 **)destination = ACPI_CAST_PTR(u16, target);
267e0fe0a8dSLin Ming 
268e0fe0a8dSLin Ming 			/* Copy the PIN data */
269e0fe0a8dSLin Ming 
270e0fe0a8dSLin Ming 			source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
271e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
272e0fe0a8dSLin Ming 					  info->opcode);
273e0fe0a8dSLin Ming 			break;
274e0fe0a8dSLin Ming 
275e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_RES:
276e0fe0a8dSLin Ming 
277e0fe0a8dSLin Ming 			/* Generate and set the resource_source string pointer */
278e0fe0a8dSLin Ming 
279e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
280e0fe0a8dSLin Ming 						      (resource->length -
281e0fe0a8dSLin Ming 						       item_count));
282e0fe0a8dSLin Ming 			*(u8 **)destination = ACPI_CAST_PTR(u8, target);
283e0fe0a8dSLin Ming 
284e0fe0a8dSLin Ming 			/* Copy the resource_source string */
285e0fe0a8dSLin Ming 
286e0fe0a8dSLin Ming 			source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
287e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
288e0fe0a8dSLin Ming 					  info->opcode);
289e0fe0a8dSLin Ming 			break;
290e0fe0a8dSLin Ming 
291e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_VEN:
292e0fe0a8dSLin Ming 
293e0fe0a8dSLin Ming 			/* Generate and set the Vendor Data pointer */
294e0fe0a8dSLin Ming 
295e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
296e0fe0a8dSLin Ming 						      (resource->length -
297e0fe0a8dSLin Ming 						       item_count));
298e0fe0a8dSLin Ming 			*(u8 **)destination = ACPI_CAST_PTR(u8, target);
299e0fe0a8dSLin Ming 
300e0fe0a8dSLin Ming 			/* Copy the Vendor Data */
301e0fe0a8dSLin Ming 
302e0fe0a8dSLin Ming 			source = ACPI_ADD_PTR(void, aml, info->value);
303e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
304e0fe0a8dSLin Ming 					  info->opcode);
305e0fe0a8dSLin Ming 			break;
306e0fe0a8dSLin Ming 
307e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_RES:
308e0fe0a8dSLin Ming 
309e0fe0a8dSLin Ming 			/* Generate and set the resource_source string pointer */
310e0fe0a8dSLin Ming 
311e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
312e0fe0a8dSLin Ming 						      (resource->length -
313e0fe0a8dSLin Ming 						       item_count));
314e0fe0a8dSLin Ming 			*(u8 **)destination = ACPI_CAST_PTR(u8, target);
315e0fe0a8dSLin Ming 
316e0fe0a8dSLin Ming 			/* Copy the resource_source string */
317e0fe0a8dSLin Ming 
318e0fe0a8dSLin Ming 			source =
319e0fe0a8dSLin Ming 			    ACPI_ADD_PTR(void, aml,
320e0fe0a8dSLin Ming 					 (ACPI_GET16(source) + info->value));
321e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
322e0fe0a8dSLin Ming 					  info->opcode);
323e0fe0a8dSLin Ming 			break;
324e0fe0a8dSLin Ming 
32595b482a8SLen Brown 		case ACPI_RSC_SET8:
32695b482a8SLen Brown 
327*4fa4616eSBob Moore 			memset(destination, info->aml_offset, info->value);
32895b482a8SLen Brown 			break;
32995b482a8SLen Brown 
33095b482a8SLen Brown 		case ACPI_RSC_DATA8:
33195b482a8SLen Brown 
33295b482a8SLen Brown 			target = ACPI_ADD_PTR(char, resource, info->value);
333*4fa4616eSBob Moore 			memcpy(destination, source, ACPI_GET16(target));
33495b482a8SLen Brown 			break;
33595b482a8SLen Brown 
33695b482a8SLen Brown 		case ACPI_RSC_ADDRESS:
33795b482a8SLen Brown 			/*
33895b482a8SLen Brown 			 * Common handler for address descriptor flags
33995b482a8SLen Brown 			 */
34095b482a8SLen Brown 			if (!acpi_rs_get_address_common(resource, aml)) {
34195b482a8SLen Brown 				return_ACPI_STATUS
34295b482a8SLen Brown 				    (AE_AML_INVALID_RESOURCE_TYPE);
34395b482a8SLen Brown 			}
34495b482a8SLen Brown 			break;
34595b482a8SLen Brown 
34695b482a8SLen Brown 		case ACPI_RSC_SOURCE:
34795b482a8SLen Brown 			/*
34895b482a8SLen Brown 			 * Optional resource_source (Index and String)
34995b482a8SLen Brown 			 */
35095b482a8SLen Brown 			resource->length +=
35195b482a8SLen Brown 			    acpi_rs_get_resource_source(aml_resource_length,
35295b482a8SLen Brown 							info->value,
35395b482a8SLen Brown 							destination, aml, NULL);
35495b482a8SLen Brown 			break;
35595b482a8SLen Brown 
35695b482a8SLen Brown 		case ACPI_RSC_SOURCEX:
35795b482a8SLen Brown 			/*
35895b482a8SLen Brown 			 * Optional resource_source (Index and String). This is the more
35995b482a8SLen Brown 			 * complicated case used by the Interrupt() macro
36095b482a8SLen Brown 			 */
361e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(char, resource,
362e0fe0a8dSLin Ming 					      info->aml_offset +
363e0fe0a8dSLin Ming 					      (item_count * 4));
36495b482a8SLen Brown 
36595b482a8SLen Brown 			resource->length +=
36695b482a8SLen Brown 			    acpi_rs_get_resource_source(aml_resource_length,
367e0fe0a8dSLin Ming 							(acpi_rs_length)
368e0fe0a8dSLin Ming 							(((item_count -
369e0fe0a8dSLin Ming 							   1) * sizeof(u32)) +
370e0fe0a8dSLin Ming 							 info->value),
371e0fe0a8dSLin Ming 							destination, aml,
372e0fe0a8dSLin Ming 							target);
37395b482a8SLen Brown 			break;
37495b482a8SLen Brown 
37595b482a8SLen Brown 		case ACPI_RSC_BITMASK:
37695b482a8SLen Brown 			/*
37795b482a8SLen Brown 			 * 8-bit encoded bitmask (DMA macro)
37895b482a8SLen Brown 			 */
37995b482a8SLen Brown 			item_count =
38095b482a8SLen Brown 			    acpi_rs_decode_bitmask(ACPI_GET8(source),
38195b482a8SLen Brown 						   destination);
38295b482a8SLen Brown 			if (item_count) {
38395b482a8SLen Brown 				resource->length += (item_count - 1);
38495b482a8SLen Brown 			}
38595b482a8SLen Brown 
38695b482a8SLen Brown 			target = ACPI_ADD_PTR(char, resource, info->value);
38757bf6aefSLv Zheng 			ACPI_SET8(target, item_count);
38895b482a8SLen Brown 			break;
38995b482a8SLen Brown 
39095b482a8SLen Brown 		case ACPI_RSC_BITMASK16:
39195b482a8SLen Brown 			/*
39295b482a8SLen Brown 			 * 16-bit encoded bitmask (IRQ macro)
39395b482a8SLen Brown 			 */
39495b482a8SLen Brown 			ACPI_MOVE_16_TO_16(&temp16, source);
39595b482a8SLen Brown 
39695b482a8SLen Brown 			item_count =
39795b482a8SLen Brown 			    acpi_rs_decode_bitmask(temp16, destination);
39895b482a8SLen Brown 			if (item_count) {
39995b482a8SLen Brown 				resource->length += (item_count - 1);
40095b482a8SLen Brown 			}
40195b482a8SLen Brown 
40295b482a8SLen Brown 			target = ACPI_ADD_PTR(char, resource, info->value);
40357bf6aefSLv Zheng 			ACPI_SET8(target, item_count);
40495b482a8SLen Brown 			break;
40595b482a8SLen Brown 
40695b482a8SLen Brown 		case ACPI_RSC_EXIT_NE:
40795b482a8SLen Brown 			/*
408ba494beeSBob Moore 			 * control - Exit conversion if not equal
40995b482a8SLen Brown 			 */
41095b482a8SLen Brown 			switch (info->resource_offset) {
41195b482a8SLen Brown 			case ACPI_RSC_COMPARE_AML_LENGTH:
4121d1ea1b7SChao Guan 
41395b482a8SLen Brown 				if (aml_resource_length != info->value) {
41495b482a8SLen Brown 					goto exit;
41595b482a8SLen Brown 				}
41695b482a8SLen Brown 				break;
41795b482a8SLen Brown 
41895b482a8SLen Brown 			case ACPI_RSC_COMPARE_VALUE:
4191d1ea1b7SChao Guan 
42095b482a8SLen Brown 				if (ACPI_GET8(source) != info->value) {
42195b482a8SLen Brown 					goto exit;
42295b482a8SLen Brown 				}
42395b482a8SLen Brown 				break;
42495b482a8SLen Brown 
42595b482a8SLen Brown 			default:
42695b482a8SLen Brown 
42795b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
42895b482a8SLen Brown 					    "Invalid conversion sub-opcode"));
42995b482a8SLen Brown 				return_ACPI_STATUS(AE_BAD_PARAMETER);
43095b482a8SLen Brown 			}
43195b482a8SLen Brown 			break;
43295b482a8SLen Brown 
43395b482a8SLen Brown 		default:
43495b482a8SLen Brown 
43595b482a8SLen Brown 			ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
43695b482a8SLen Brown 			return_ACPI_STATUS(AE_BAD_PARAMETER);
43795b482a8SLen Brown 		}
43895b482a8SLen Brown 
43995b482a8SLen Brown 		count--;
44095b482a8SLen Brown 		info++;
44195b482a8SLen Brown 	}
44295b482a8SLen Brown 
44395b482a8SLen Brown exit:
44495b482a8SLen Brown 	if (!flags_mode) {
44595b482a8SLen Brown 
44695b482a8SLen Brown 		/* Round the resource struct length up to the next boundary (32 or 64) */
44795b482a8SLen Brown 
44895b482a8SLen Brown 		resource->length =
44995b482a8SLen Brown 		    (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(resource->length);
45095b482a8SLen Brown 	}
45195b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
45295b482a8SLen Brown }
45395b482a8SLen Brown 
45495b482a8SLen Brown /*******************************************************************************
45595b482a8SLen Brown  *
45695b482a8SLen Brown  * FUNCTION:    acpi_rs_convert_resource_to_aml
45795b482a8SLen Brown  *
458ba494beeSBob Moore  * PARAMETERS:  resource            - Pointer to the resource descriptor
459ba494beeSBob Moore  *              aml                 - Where the AML descriptor is returned
460ba494beeSBob Moore  *              info                - Pointer to appropriate conversion table
46195b482a8SLen Brown  *
46295b482a8SLen Brown  * RETURN:      Status
46395b482a8SLen Brown  *
46495b482a8SLen Brown  * DESCRIPTION: Convert an internal resource descriptor to the corresponding
46595b482a8SLen Brown  *              external AML resource descriptor.
46695b482a8SLen Brown  *
46795b482a8SLen Brown  ******************************************************************************/
46895b482a8SLen Brown 
46995b482a8SLen Brown acpi_status
47095b482a8SLen Brown acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
47195b482a8SLen Brown 				union aml_resource *aml,
47295b482a8SLen Brown 				struct acpi_rsconvert_info *info)
47395b482a8SLen Brown {
47495b482a8SLen Brown 	void *source = NULL;
47595b482a8SLen Brown 	void *destination;
476e0fe0a8dSLin Ming 	char *target;
47795b482a8SLen Brown 	acpi_rsdesc_size aml_length = 0;
47895b482a8SLen Brown 	u8 count;
47995b482a8SLen Brown 	u16 temp16 = 0;
48095b482a8SLen Brown 	u16 item_count = 0;
48195b482a8SLen Brown 
48295b482a8SLen Brown 	ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);
48395b482a8SLen Brown 
484e0fe0a8dSLin Ming 	if (!info) {
485e0fe0a8dSLin Ming 		return_ACPI_STATUS(AE_BAD_PARAMETER);
486e0fe0a8dSLin Ming 	}
487e0fe0a8dSLin Ming 
48895b482a8SLen Brown 	/*
48995b482a8SLen Brown 	 * First table entry must be ACPI_RSC_INITxxx and must contain the
49095b482a8SLen Brown 	 * table length (# of table entries)
49195b482a8SLen Brown 	 */
49295b482a8SLen Brown 	count = INIT_TABLE_LENGTH(info);
49395b482a8SLen Brown 
49495b482a8SLen Brown 	while (count) {
49595b482a8SLen Brown 		/*
49695b482a8SLen Brown 		 * Source is the internal resource descriptor,
49795b482a8SLen Brown 		 * destination is the external AML byte stream buffer
49895b482a8SLen Brown 		 */
49995b482a8SLen Brown 		source = ACPI_ADD_PTR(void, resource, info->resource_offset);
50095b482a8SLen Brown 		destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
50195b482a8SLen Brown 
50295b482a8SLen Brown 		switch (info->opcode) {
50395b482a8SLen Brown 		case ACPI_RSC_INITSET:
50495b482a8SLen Brown 
505*4fa4616eSBob Moore 			memset(aml, 0, INIT_RESOURCE_LENGTH(info));
50695b482a8SLen Brown 			aml_length = INIT_RESOURCE_LENGTH(info);
50795b482a8SLen Brown 			acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
50895b482a8SLen Brown 						    aml_length, aml);
50995b482a8SLen Brown 			break;
51095b482a8SLen Brown 
51195b482a8SLen Brown 		case ACPI_RSC_INITGET:
51295b482a8SLen Brown 			break;
51395b482a8SLen Brown 
51495b482a8SLen Brown 		case ACPI_RSC_FLAGINIT:
51595b482a8SLen Brown 			/*
51695b482a8SLen Brown 			 * Clear the flag byte
51795b482a8SLen Brown 			 */
51857bf6aefSLv Zheng 			ACPI_SET8(destination, 0);
51995b482a8SLen Brown 			break;
52095b482a8SLen Brown 
52195b482a8SLen Brown 		case ACPI_RSC_1BITFLAG:
52295b482a8SLen Brown 			/*
52395b482a8SLen Brown 			 * Mask and shift the flag bit
52495b482a8SLen Brown 			 */
52557bf6aefSLv Zheng 			ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
52657bf6aefSLv Zheng 				     ((ACPI_GET8(source) & 0x01) << info->
52757bf6aefSLv Zheng 				      value));
52895b482a8SLen Brown 			break;
52995b482a8SLen Brown 
53095b482a8SLen Brown 		case ACPI_RSC_2BITFLAG:
53195b482a8SLen Brown 			/*
53295b482a8SLen Brown 			 * Mask and shift the flag bits
53395b482a8SLen Brown 			 */
53457bf6aefSLv Zheng 			ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
53557bf6aefSLv Zheng 				     ((ACPI_GET8(source) & 0x03) << info->
53657bf6aefSLv Zheng 				      value));
53795b482a8SLen Brown 			break;
53895b482a8SLen Brown 
539e0fe0a8dSLin Ming 		case ACPI_RSC_3BITFLAG:
540e0fe0a8dSLin Ming 			/*
541e0fe0a8dSLin Ming 			 * Mask and shift the flag bits
542e0fe0a8dSLin Ming 			 */
54357bf6aefSLv Zheng 			ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
54457bf6aefSLv Zheng 				     ((ACPI_GET8(source) & 0x07) << info->
54557bf6aefSLv Zheng 				      value));
546e0fe0a8dSLin Ming 			break;
547e0fe0a8dSLin Ming 
54895b482a8SLen Brown 		case ACPI_RSC_COUNT:
54995b482a8SLen Brown 
55095b482a8SLen Brown 			item_count = ACPI_GET8(source);
55157bf6aefSLv Zheng 			ACPI_SET8(destination, item_count);
55295b482a8SLen Brown 
55395b482a8SLen Brown 			aml_length =
55495b482a8SLen Brown 			    (u16) (aml_length +
55595b482a8SLen Brown 				   (info->value * (item_count - 1)));
55695b482a8SLen Brown 			break;
55795b482a8SLen Brown 
55895b482a8SLen Brown 		case ACPI_RSC_COUNT16:
55995b482a8SLen Brown 
56095b482a8SLen Brown 			item_count = ACPI_GET16(source);
56195b482a8SLen Brown 			aml_length = (u16) (aml_length + item_count);
56295b482a8SLen Brown 			acpi_rs_set_resource_length(aml_length, aml);
56395b482a8SLen Brown 			break;
56495b482a8SLen Brown 
565e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_PIN:
566e0fe0a8dSLin Ming 
567e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
56857bf6aefSLv Zheng 			ACPI_SET16(destination, aml_length);
569e0fe0a8dSLin Ming 
570e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count * 2);
571e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, info->value);
57257bf6aefSLv Zheng 			ACPI_SET16(target, aml_length);
573e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
574e0fe0a8dSLin Ming 			break;
575e0fe0a8dSLin Ming 
576e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_VEN:
577e0fe0a8dSLin Ming 
578e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
57957bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
580e0fe0a8dSLin Ming 
581e0fe0a8dSLin Ming 			aml_length =
582e0fe0a8dSLin Ming 			    (u16)(aml_length + (info->value * item_count));
583e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
584e0fe0a8dSLin Ming 			break;
585e0fe0a8dSLin Ming 
586e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_RES:
587e0fe0a8dSLin Ming 
588e0fe0a8dSLin Ming 			/* Set resource source string length */
589e0fe0a8dSLin Ming 
590e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
59157bf6aefSLv Zheng 			ACPI_SET16(destination, aml_length);
592e0fe0a8dSLin Ming 
593e0fe0a8dSLin Ming 			/* Compute offset for the Vendor Data */
594e0fe0a8dSLin Ming 
595e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count);
596e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, info->value);
597e0fe0a8dSLin Ming 
598e0fe0a8dSLin Ming 			/* Set vendor offset only if there is vendor data */
599e0fe0a8dSLin Ming 
600e0fe0a8dSLin Ming 			if (resource->data.gpio.vendor_length) {
60157bf6aefSLv Zheng 				ACPI_SET16(target, aml_length);
602e0fe0a8dSLin Ming 			}
603e0fe0a8dSLin Ming 
604e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
605e0fe0a8dSLin Ming 			break;
606e0fe0a8dSLin Ming 
607e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_VEN:
608e0fe0a8dSLin Ming 
609e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
61057bf6aefSLv Zheng 			ACPI_SET16(destination, item_count + info->value);
611e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count);
612e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
613e0fe0a8dSLin Ming 			break;
614e0fe0a8dSLin Ming 
615e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_RES:
616e0fe0a8dSLin Ming 
617e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
618e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count);
619e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
620e0fe0a8dSLin Ming 			break;
621e0fe0a8dSLin Ming 
62295b482a8SLen Brown 		case ACPI_RSC_LENGTH:
62395b482a8SLen Brown 
62495b482a8SLen Brown 			acpi_rs_set_resource_length(info->value, aml);
62595b482a8SLen Brown 			break;
62695b482a8SLen Brown 
62795b482a8SLen Brown 		case ACPI_RSC_MOVE8:
62895b482a8SLen Brown 		case ACPI_RSC_MOVE16:
62995b482a8SLen Brown 		case ACPI_RSC_MOVE32:
63095b482a8SLen Brown 		case ACPI_RSC_MOVE64:
63195b482a8SLen Brown 
63295b482a8SLen Brown 			if (info->value) {
63395b482a8SLen Brown 				item_count = info->value;
63495b482a8SLen Brown 			}
63595b482a8SLen Brown 			acpi_rs_move_data(destination, source, item_count,
63695b482a8SLen Brown 					  info->opcode);
63795b482a8SLen Brown 			break;
63895b482a8SLen Brown 
639e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_PIN:
640e0fe0a8dSLin Ming 
641e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
642e0fe0a8dSLin Ming 							   ACPI_GET16
643e0fe0a8dSLin Ming 							   (destination));
644e0fe0a8dSLin Ming 			source = *(u16 **)source;
645e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
646e0fe0a8dSLin Ming 					  info->opcode);
647e0fe0a8dSLin Ming 			break;
648e0fe0a8dSLin Ming 
649e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_RES:
650e0fe0a8dSLin Ming 
651e0fe0a8dSLin Ming 			/* Used for both resource_source string and vendor_data */
652e0fe0a8dSLin Ming 
653e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
654e0fe0a8dSLin Ming 							   ACPI_GET16
655e0fe0a8dSLin Ming 							   (destination));
656e0fe0a8dSLin Ming 			source = *(u8 **)source;
657e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
658e0fe0a8dSLin Ming 					  info->opcode);
659e0fe0a8dSLin Ming 			break;
660e0fe0a8dSLin Ming 
661e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_VEN:
662e0fe0a8dSLin Ming 
663e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
664e0fe0a8dSLin Ming 							   (aml_length -
665e0fe0a8dSLin Ming 							    item_count));
666e0fe0a8dSLin Ming 			source = *(u8 **)source;
667e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
668e0fe0a8dSLin Ming 					  info->opcode);
669e0fe0a8dSLin Ming 			break;
670e0fe0a8dSLin Ming 
671e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_RES:
672e0fe0a8dSLin Ming 
673e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
674e0fe0a8dSLin Ming 							   (aml_length -
675e0fe0a8dSLin Ming 							    item_count));
676e0fe0a8dSLin Ming 			source = *(u8 **)source;
677e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
678e0fe0a8dSLin Ming 					  info->opcode);
679e0fe0a8dSLin Ming 			break;
680e0fe0a8dSLin Ming 
68195b482a8SLen Brown 		case ACPI_RSC_ADDRESS:
68295b482a8SLen Brown 
68395b482a8SLen Brown 			/* Set the Resource Type, General Flags, and Type-Specific Flags */
68495b482a8SLen Brown 
68595b482a8SLen Brown 			acpi_rs_set_address_common(aml, resource);
68695b482a8SLen Brown 			break;
68795b482a8SLen Brown 
68895b482a8SLen Brown 		case ACPI_RSC_SOURCEX:
68995b482a8SLen Brown 			/*
69095b482a8SLen Brown 			 * Optional resource_source (Index and String)
69195b482a8SLen Brown 			 */
69295b482a8SLen Brown 			aml_length =
6933e8214e5SLv Zheng 			    acpi_rs_set_resource_source(aml,
6943e8214e5SLv Zheng 							(acpi_rs_length)
69595b482a8SLen Brown 							aml_length, source);
69695b482a8SLen Brown 			acpi_rs_set_resource_length(aml_length, aml);
69795b482a8SLen Brown 			break;
69895b482a8SLen Brown 
69995b482a8SLen Brown 		case ACPI_RSC_SOURCE:
70095b482a8SLen Brown 			/*
70195b482a8SLen Brown 			 * Optional resource_source (Index and String). This is the more
70295b482a8SLen Brown 			 * complicated case used by the Interrupt() macro
70395b482a8SLen Brown 			 */
70495b482a8SLen Brown 			aml_length =
70595b482a8SLen Brown 			    acpi_rs_set_resource_source(aml, info->value,
70695b482a8SLen Brown 							source);
70795b482a8SLen Brown 			acpi_rs_set_resource_length(aml_length, aml);
70895b482a8SLen Brown 			break;
70995b482a8SLen Brown 
71095b482a8SLen Brown 		case ACPI_RSC_BITMASK:
71195b482a8SLen Brown 			/*
71295b482a8SLen Brown 			 * 8-bit encoded bitmask (DMA macro)
71395b482a8SLen Brown 			 */
71457bf6aefSLv Zheng 			ACPI_SET8(destination,
71595b482a8SLen Brown 				  acpi_rs_encode_bitmask(source,
71657bf6aefSLv Zheng 							 *ACPI_ADD_PTR(u8,
71757bf6aefSLv Zheng 								       resource,
71857bf6aefSLv Zheng 								       info->
71957bf6aefSLv Zheng 								       value)));
72095b482a8SLen Brown 			break;
72195b482a8SLen Brown 
72295b482a8SLen Brown 		case ACPI_RSC_BITMASK16:
72395b482a8SLen Brown 			/*
72495b482a8SLen Brown 			 * 16-bit encoded bitmask (IRQ macro)
72595b482a8SLen Brown 			 */
72695b482a8SLen Brown 			temp16 = acpi_rs_encode_bitmask(source,
72795b482a8SLen Brown 							*ACPI_ADD_PTR(u8,
72895b482a8SLen Brown 								      resource,
72995b482a8SLen Brown 								      info->
73095b482a8SLen Brown 								      value));
73195b482a8SLen Brown 			ACPI_MOVE_16_TO_16(destination, &temp16);
73295b482a8SLen Brown 			break;
73395b482a8SLen Brown 
73495b482a8SLen Brown 		case ACPI_RSC_EXIT_LE:
73595b482a8SLen Brown 			/*
736ba494beeSBob Moore 			 * control - Exit conversion if less than or equal
73795b482a8SLen Brown 			 */
73895b482a8SLen Brown 			if (item_count <= info->value) {
73995b482a8SLen Brown 				goto exit;
74095b482a8SLen Brown 			}
74195b482a8SLen Brown 			break;
74295b482a8SLen Brown 
74395b482a8SLen Brown 		case ACPI_RSC_EXIT_NE:
74495b482a8SLen Brown 			/*
745ba494beeSBob Moore 			 * control - Exit conversion if not equal
74695b482a8SLen Brown 			 */
74795b482a8SLen Brown 			switch (COMPARE_OPCODE(info)) {
74895b482a8SLen Brown 			case ACPI_RSC_COMPARE_VALUE:
74995b482a8SLen Brown 
75095b482a8SLen Brown 				if (*ACPI_ADD_PTR(u8, resource,
75195b482a8SLen Brown 						  COMPARE_TARGET(info)) !=
75295b482a8SLen Brown 				    COMPARE_VALUE(info)) {
75395b482a8SLen Brown 					goto exit;
75495b482a8SLen Brown 				}
75595b482a8SLen Brown 				break;
75695b482a8SLen Brown 
75795b482a8SLen Brown 			default:
75895b482a8SLen Brown 
75995b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
76095b482a8SLen Brown 					    "Invalid conversion sub-opcode"));
76195b482a8SLen Brown 				return_ACPI_STATUS(AE_BAD_PARAMETER);
76295b482a8SLen Brown 			}
76395b482a8SLen Brown 			break;
76495b482a8SLen Brown 
76595b482a8SLen Brown 		case ACPI_RSC_EXIT_EQ:
76695b482a8SLen Brown 			/*
767ba494beeSBob Moore 			 * control - Exit conversion if equal
76895b482a8SLen Brown 			 */
76995b482a8SLen Brown 			if (*ACPI_ADD_PTR(u8, resource,
77095b482a8SLen Brown 					  COMPARE_TARGET(info)) ==
77195b482a8SLen Brown 			    COMPARE_VALUE(info)) {
77295b482a8SLen Brown 				goto exit;
77395b482a8SLen Brown 			}
77495b482a8SLen Brown 			break;
77595b482a8SLen Brown 
77695b482a8SLen Brown 		default:
77795b482a8SLen Brown 
77895b482a8SLen Brown 			ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
77995b482a8SLen Brown 			return_ACPI_STATUS(AE_BAD_PARAMETER);
78095b482a8SLen Brown 		}
78195b482a8SLen Brown 
78295b482a8SLen Brown 		count--;
78395b482a8SLen Brown 		info++;
78495b482a8SLen Brown 	}
78595b482a8SLen Brown 
78695b482a8SLen Brown exit:
78795b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
78895b482a8SLen Brown }
78995b482a8SLen Brown 
79095b482a8SLen Brown #if 0
79195b482a8SLen Brown /* Previous resource validations */
79295b482a8SLen Brown 
793ba494beeSBob Moore if (aml->ext_address64.revision_ID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
79495b482a8SLen Brown 	return_ACPI_STATUS(AE_SUPPORT);
79595b482a8SLen Brown }
79695b482a8SLen Brown 
79795b482a8SLen Brown if (resource->data.start_dpf.performance_robustness >= 3) {
79895b482a8SLen Brown 	return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
79995b482a8SLen Brown }
80095b482a8SLen Brown 
80195b482a8SLen Brown if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
80295b482a8SLen Brown 	/*
80395b482a8SLen Brown 	 * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
80495b482a8SLen Brown 	 * polarity/trigger interrupts are allowed (ACPI spec, section
80595b482a8SLen Brown 	 * "IRQ Format"), so 0x00 and 0x09 are illegal.
80695b482a8SLen Brown 	 */
80795b482a8SLen Brown 	ACPI_ERROR((AE_INFO,
808f6a22b0bSBob Moore 		    "Invalid interrupt polarity/trigger in resource list, 0x%X",
80995b482a8SLen Brown 		    aml->irq.flags));
81095b482a8SLen Brown 	return_ACPI_STATUS(AE_BAD_DATA);
81195b482a8SLen Brown }
81295b482a8SLen Brown 
81395b482a8SLen Brown resource->data.extended_irq.interrupt_count = temp8;
81495b482a8SLen Brown if (temp8 < 1) {
81595b482a8SLen Brown 
81695b482a8SLen Brown 	/* Must have at least one IRQ */
81795b482a8SLen Brown 
81895b482a8SLen Brown 	return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
81995b482a8SLen Brown }
82095b482a8SLen Brown 
82195b482a8SLen Brown if (resource->data.dma.transfer == 0x03) {
82295b482a8SLen Brown 	ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
82395b482a8SLen Brown 	return_ACPI_STATUS(AE_BAD_DATA);
82495b482a8SLen Brown }
82595b482a8SLen Brown #endif
826