xref: /linux/drivers/acpi/acpica/rsmisc.c (revision 25f044e64568dd83de34c16c837a96bbb2b0cecb)
195b482a8SLen Brown /*******************************************************************************
295b482a8SLen Brown  *
395b482a8SLen Brown  * Module Name: rsmisc - Miscellaneous resource descriptors
495b482a8SLen Brown  *
595b482a8SLen Brown  ******************************************************************************/
695b482a8SLen Brown 
795b482a8SLen Brown /*
8*25f044e6SBob Moore  * Copyright (C) 2000 - 2013, 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 			 */
12295b482a8SLen Brown 			ACPI_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 			/*
199e0fe0a8dSLin Ming 			 * Vendor data is optional (length/offset may both be zero)
200e0fe0a8dSLin Ming 			 * Examine vendor data length field first
201e0fe0a8dSLin Ming 			 */
202e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, (info->value + 2));
203e0fe0a8dSLin Ming 			if (ACPI_GET16(target)) {
204e0fe0a8dSLin Ming 
205e0fe0a8dSLin Ming 				/* Use vendor offset to get resource source length */
206e0fe0a8dSLin Ming 
207e0fe0a8dSLin Ming 				target = ACPI_ADD_PTR(void, aml, info->value);
208e0fe0a8dSLin Ming 				item_count =
209e0fe0a8dSLin Ming 				    ACPI_GET16(target) - ACPI_GET16(source);
210e0fe0a8dSLin Ming 			} else {
211e0fe0a8dSLin Ming 				/* No vendor data to worry about */
212e0fe0a8dSLin Ming 
213e0fe0a8dSLin Ming 				item_count = aml->large_header.resource_length +
214e0fe0a8dSLin Ming 				    sizeof(struct aml_resource_large_header) -
215e0fe0a8dSLin Ming 				    ACPI_GET16(source);
216e0fe0a8dSLin Ming 			}
217e0fe0a8dSLin Ming 
218e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
21957bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
220e0fe0a8dSLin Ming 			break;
221e0fe0a8dSLin Ming 
222e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_VEN:
223e0fe0a8dSLin Ming 
224e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source) - info->value;
225e0fe0a8dSLin Ming 
226e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
22757bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
228e0fe0a8dSLin Ming 			break;
229e0fe0a8dSLin Ming 
230e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_RES:
231e0fe0a8dSLin Ming 
232e0fe0a8dSLin Ming 			item_count = (aml_resource_length +
233e0fe0a8dSLin Ming 				      sizeof(struct aml_resource_large_header))
234e0fe0a8dSLin Ming 			    - ACPI_GET16(source) - info->value;
235e0fe0a8dSLin Ming 
236e0fe0a8dSLin Ming 			resource->length = resource->length + item_count;
23757bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
238e0fe0a8dSLin Ming 			break;
239e0fe0a8dSLin Ming 
24095b482a8SLen Brown 		case ACPI_RSC_LENGTH:
24195b482a8SLen Brown 
24295b482a8SLen Brown 			resource->length = resource->length + info->value;
24395b482a8SLen Brown 			break;
24495b482a8SLen Brown 
24595b482a8SLen Brown 		case ACPI_RSC_MOVE8:
24695b482a8SLen Brown 		case ACPI_RSC_MOVE16:
24795b482a8SLen Brown 		case ACPI_RSC_MOVE32:
24895b482a8SLen Brown 		case ACPI_RSC_MOVE64:
24995b482a8SLen Brown 			/*
25095b482a8SLen Brown 			 * Raw data move. Use the Info value field unless item_count has
25195b482a8SLen Brown 			 * been previously initialized via a COUNT opcode
25295b482a8SLen Brown 			 */
25395b482a8SLen Brown 			if (info->value) {
25495b482a8SLen Brown 				item_count = info->value;
25595b482a8SLen Brown 			}
25695b482a8SLen Brown 			acpi_rs_move_data(destination, source, item_count,
25795b482a8SLen Brown 					  info->opcode);
25895b482a8SLen Brown 			break;
25995b482a8SLen Brown 
260e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_PIN:
261e0fe0a8dSLin Ming 
262e0fe0a8dSLin Ming 			/* Generate and set the PIN data pointer */
263e0fe0a8dSLin Ming 
264e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
265e0fe0a8dSLin Ming 						      (resource->length -
266e0fe0a8dSLin Ming 						       item_count * 2));
267e0fe0a8dSLin Ming 			*(u16 **)destination = ACPI_CAST_PTR(u16, target);
268e0fe0a8dSLin Ming 
269e0fe0a8dSLin Ming 			/* Copy the PIN data */
270e0fe0a8dSLin Ming 
271e0fe0a8dSLin Ming 			source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
272e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
273e0fe0a8dSLin Ming 					  info->opcode);
274e0fe0a8dSLin Ming 			break;
275e0fe0a8dSLin Ming 
276e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_RES:
277e0fe0a8dSLin Ming 
278e0fe0a8dSLin Ming 			/* Generate and set the resource_source string pointer */
279e0fe0a8dSLin Ming 
280e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
281e0fe0a8dSLin Ming 						      (resource->length -
282e0fe0a8dSLin Ming 						       item_count));
283e0fe0a8dSLin Ming 			*(u8 **)destination = ACPI_CAST_PTR(u8, target);
284e0fe0a8dSLin Ming 
285e0fe0a8dSLin Ming 			/* Copy the resource_source string */
286e0fe0a8dSLin Ming 
287e0fe0a8dSLin Ming 			source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
288e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
289e0fe0a8dSLin Ming 					  info->opcode);
290e0fe0a8dSLin Ming 			break;
291e0fe0a8dSLin Ming 
292e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_VEN:
293e0fe0a8dSLin Ming 
294e0fe0a8dSLin Ming 			/* Generate and set the Vendor Data pointer */
295e0fe0a8dSLin Ming 
296e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
297e0fe0a8dSLin Ming 						      (resource->length -
298e0fe0a8dSLin Ming 						       item_count));
299e0fe0a8dSLin Ming 			*(u8 **)destination = ACPI_CAST_PTR(u8, target);
300e0fe0a8dSLin Ming 
301e0fe0a8dSLin Ming 			/* Copy the Vendor Data */
302e0fe0a8dSLin Ming 
303e0fe0a8dSLin Ming 			source = ACPI_ADD_PTR(void, aml, info->value);
304e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
305e0fe0a8dSLin Ming 					  info->opcode);
306e0fe0a8dSLin Ming 			break;
307e0fe0a8dSLin Ming 
308e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_RES:
309e0fe0a8dSLin Ming 
310e0fe0a8dSLin Ming 			/* Generate and set the resource_source string pointer */
311e0fe0a8dSLin Ming 
312e0fe0a8dSLin Ming 			target = (char *)ACPI_ADD_PTR(void, resource,
313e0fe0a8dSLin Ming 						      (resource->length -
314e0fe0a8dSLin Ming 						       item_count));
315e0fe0a8dSLin Ming 			*(u8 **)destination = ACPI_CAST_PTR(u8, target);
316e0fe0a8dSLin Ming 
317e0fe0a8dSLin Ming 			/* Copy the resource_source string */
318e0fe0a8dSLin Ming 
319e0fe0a8dSLin Ming 			source =
320e0fe0a8dSLin Ming 			    ACPI_ADD_PTR(void, aml,
321e0fe0a8dSLin Ming 					 (ACPI_GET16(source) + info->value));
322e0fe0a8dSLin Ming 			acpi_rs_move_data(target, source, item_count,
323e0fe0a8dSLin Ming 					  info->opcode);
324e0fe0a8dSLin Ming 			break;
325e0fe0a8dSLin Ming 
32695b482a8SLen Brown 		case ACPI_RSC_SET8:
32795b482a8SLen Brown 
32895b482a8SLen Brown 			ACPI_MEMSET(destination, info->aml_offset, info->value);
32995b482a8SLen Brown 			break;
33095b482a8SLen Brown 
33195b482a8SLen Brown 		case ACPI_RSC_DATA8:
33295b482a8SLen Brown 
33395b482a8SLen Brown 			target = ACPI_ADD_PTR(char, resource, info->value);
33495b482a8SLen Brown 			ACPI_MEMCPY(destination, source, ACPI_GET16(target));
33595b482a8SLen Brown 			break;
33695b482a8SLen Brown 
33795b482a8SLen Brown 		case ACPI_RSC_ADDRESS:
33895b482a8SLen Brown 			/*
33995b482a8SLen Brown 			 * Common handler for address descriptor flags
34095b482a8SLen Brown 			 */
34195b482a8SLen Brown 			if (!acpi_rs_get_address_common(resource, aml)) {
34295b482a8SLen Brown 				return_ACPI_STATUS
34395b482a8SLen Brown 				    (AE_AML_INVALID_RESOURCE_TYPE);
34495b482a8SLen Brown 			}
34595b482a8SLen Brown 			break;
34695b482a8SLen Brown 
34795b482a8SLen Brown 		case ACPI_RSC_SOURCE:
34895b482a8SLen Brown 			/*
34995b482a8SLen Brown 			 * Optional resource_source (Index and String)
35095b482a8SLen Brown 			 */
35195b482a8SLen Brown 			resource->length +=
35295b482a8SLen Brown 			    acpi_rs_get_resource_source(aml_resource_length,
35395b482a8SLen Brown 							info->value,
35495b482a8SLen Brown 							destination, aml, NULL);
35595b482a8SLen Brown 			break;
35695b482a8SLen Brown 
35795b482a8SLen Brown 		case ACPI_RSC_SOURCEX:
35895b482a8SLen Brown 			/*
35995b482a8SLen Brown 			 * Optional resource_source (Index and String). This is the more
36095b482a8SLen Brown 			 * complicated case used by the Interrupt() macro
36195b482a8SLen Brown 			 */
362e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(char, resource,
363e0fe0a8dSLin Ming 					      info->aml_offset +
364e0fe0a8dSLin Ming 					      (item_count * 4));
36595b482a8SLen Brown 
36695b482a8SLen Brown 			resource->length +=
36795b482a8SLen Brown 			    acpi_rs_get_resource_source(aml_resource_length,
368e0fe0a8dSLin Ming 							(acpi_rs_length)
369e0fe0a8dSLin Ming 							(((item_count -
370e0fe0a8dSLin Ming 							   1) * sizeof(u32)) +
371e0fe0a8dSLin Ming 							 info->value),
372e0fe0a8dSLin Ming 							destination, aml,
373e0fe0a8dSLin Ming 							target);
37495b482a8SLen Brown 			break;
37595b482a8SLen Brown 
37695b482a8SLen Brown 		case ACPI_RSC_BITMASK:
37795b482a8SLen Brown 			/*
37895b482a8SLen Brown 			 * 8-bit encoded bitmask (DMA macro)
37995b482a8SLen Brown 			 */
38095b482a8SLen Brown 			item_count =
38195b482a8SLen Brown 			    acpi_rs_decode_bitmask(ACPI_GET8(source),
38295b482a8SLen Brown 						   destination);
38395b482a8SLen Brown 			if (item_count) {
38495b482a8SLen Brown 				resource->length += (item_count - 1);
38595b482a8SLen Brown 			}
38695b482a8SLen Brown 
38795b482a8SLen Brown 			target = ACPI_ADD_PTR(char, resource, info->value);
38857bf6aefSLv Zheng 			ACPI_SET8(target, item_count);
38995b482a8SLen Brown 			break;
39095b482a8SLen Brown 
39195b482a8SLen Brown 		case ACPI_RSC_BITMASK16:
39295b482a8SLen Brown 			/*
39395b482a8SLen Brown 			 * 16-bit encoded bitmask (IRQ macro)
39495b482a8SLen Brown 			 */
39595b482a8SLen Brown 			ACPI_MOVE_16_TO_16(&temp16, source);
39695b482a8SLen Brown 
39795b482a8SLen Brown 			item_count =
39895b482a8SLen Brown 			    acpi_rs_decode_bitmask(temp16, destination);
39995b482a8SLen Brown 			if (item_count) {
40095b482a8SLen Brown 				resource->length += (item_count - 1);
40195b482a8SLen Brown 			}
40295b482a8SLen Brown 
40395b482a8SLen Brown 			target = ACPI_ADD_PTR(char, resource, info->value);
40457bf6aefSLv Zheng 			ACPI_SET8(target, item_count);
40595b482a8SLen Brown 			break;
40695b482a8SLen Brown 
40795b482a8SLen Brown 		case ACPI_RSC_EXIT_NE:
40895b482a8SLen Brown 			/*
409ba494beeSBob Moore 			 * control - Exit conversion if not equal
41095b482a8SLen Brown 			 */
41195b482a8SLen Brown 			switch (info->resource_offset) {
41295b482a8SLen Brown 			case ACPI_RSC_COMPARE_AML_LENGTH:
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:
41995b482a8SLen Brown 				if (ACPI_GET8(source) != info->value) {
42095b482a8SLen Brown 					goto exit;
42195b482a8SLen Brown 				}
42295b482a8SLen Brown 				break;
42395b482a8SLen Brown 
42495b482a8SLen Brown 			default:
42595b482a8SLen Brown 
42695b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
42795b482a8SLen Brown 					    "Invalid conversion sub-opcode"));
42895b482a8SLen Brown 				return_ACPI_STATUS(AE_BAD_PARAMETER);
42995b482a8SLen Brown 			}
43095b482a8SLen Brown 			break;
43195b482a8SLen Brown 
43295b482a8SLen Brown 		default:
43395b482a8SLen Brown 
43495b482a8SLen Brown 			ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
43595b482a8SLen Brown 			return_ACPI_STATUS(AE_BAD_PARAMETER);
43695b482a8SLen Brown 		}
43795b482a8SLen Brown 
43895b482a8SLen Brown 		count--;
43995b482a8SLen Brown 		info++;
44095b482a8SLen Brown 	}
44195b482a8SLen Brown 
44295b482a8SLen Brown       exit:
44395b482a8SLen Brown 	if (!flags_mode) {
44495b482a8SLen Brown 
44595b482a8SLen Brown 		/* Round the resource struct length up to the next boundary (32 or 64) */
44695b482a8SLen Brown 
44795b482a8SLen Brown 		resource->length =
44895b482a8SLen Brown 		    (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(resource->length);
44995b482a8SLen Brown 	}
45095b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
45195b482a8SLen Brown }
45295b482a8SLen Brown 
45395b482a8SLen Brown /*******************************************************************************
45495b482a8SLen Brown  *
45595b482a8SLen Brown  * FUNCTION:    acpi_rs_convert_resource_to_aml
45695b482a8SLen Brown  *
457ba494beeSBob Moore  * PARAMETERS:  resource            - Pointer to the resource descriptor
458ba494beeSBob Moore  *              aml                 - Where the AML descriptor is returned
459ba494beeSBob Moore  *              info                - Pointer to appropriate conversion table
46095b482a8SLen Brown  *
46195b482a8SLen Brown  * RETURN:      Status
46295b482a8SLen Brown  *
46395b482a8SLen Brown  * DESCRIPTION: Convert an internal resource descriptor to the corresponding
46495b482a8SLen Brown  *              external AML resource descriptor.
46595b482a8SLen Brown  *
46695b482a8SLen Brown  ******************************************************************************/
46795b482a8SLen Brown 
46895b482a8SLen Brown acpi_status
46995b482a8SLen Brown acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
47095b482a8SLen Brown 				union aml_resource *aml,
47195b482a8SLen Brown 				struct acpi_rsconvert_info *info)
47295b482a8SLen Brown {
47395b482a8SLen Brown 	void *source = NULL;
47495b482a8SLen Brown 	void *destination;
475e0fe0a8dSLin Ming 	char *target;
47695b482a8SLen Brown 	acpi_rsdesc_size aml_length = 0;
47795b482a8SLen Brown 	u8 count;
47895b482a8SLen Brown 	u16 temp16 = 0;
47995b482a8SLen Brown 	u16 item_count = 0;
48095b482a8SLen Brown 
48195b482a8SLen Brown 	ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);
48295b482a8SLen Brown 
483e0fe0a8dSLin Ming 	if (!info) {
484e0fe0a8dSLin Ming 		return_ACPI_STATUS(AE_BAD_PARAMETER);
485e0fe0a8dSLin Ming 	}
486e0fe0a8dSLin Ming 
48795b482a8SLen Brown 	/*
48895b482a8SLen Brown 	 * First table entry must be ACPI_RSC_INITxxx and must contain the
48995b482a8SLen Brown 	 * table length (# of table entries)
49095b482a8SLen Brown 	 */
49195b482a8SLen Brown 	count = INIT_TABLE_LENGTH(info);
49295b482a8SLen Brown 
49395b482a8SLen Brown 	while (count) {
49495b482a8SLen Brown 		/*
49595b482a8SLen Brown 		 * Source is the internal resource descriptor,
49695b482a8SLen Brown 		 * destination is the external AML byte stream buffer
49795b482a8SLen Brown 		 */
49895b482a8SLen Brown 		source = ACPI_ADD_PTR(void, resource, info->resource_offset);
49995b482a8SLen Brown 		destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
50095b482a8SLen Brown 
50195b482a8SLen Brown 		switch (info->opcode) {
50295b482a8SLen Brown 		case ACPI_RSC_INITSET:
50395b482a8SLen Brown 
50495b482a8SLen Brown 			ACPI_MEMSET(aml, 0, INIT_RESOURCE_LENGTH(info));
50595b482a8SLen Brown 			aml_length = INIT_RESOURCE_LENGTH(info);
50695b482a8SLen Brown 			acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
50795b482a8SLen Brown 						    aml_length, aml);
50895b482a8SLen Brown 			break;
50995b482a8SLen Brown 
51095b482a8SLen Brown 		case ACPI_RSC_INITGET:
51195b482a8SLen Brown 			break;
51295b482a8SLen Brown 
51395b482a8SLen Brown 		case ACPI_RSC_FLAGINIT:
51495b482a8SLen Brown 			/*
51595b482a8SLen Brown 			 * Clear the flag byte
51695b482a8SLen Brown 			 */
51757bf6aefSLv Zheng 			ACPI_SET8(destination, 0);
51895b482a8SLen Brown 			break;
51995b482a8SLen Brown 
52095b482a8SLen Brown 		case ACPI_RSC_1BITFLAG:
52195b482a8SLen Brown 			/*
52295b482a8SLen Brown 			 * Mask and shift the flag bit
52395b482a8SLen Brown 			 */
52457bf6aefSLv Zheng 			ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
52557bf6aefSLv Zheng 				     ((ACPI_GET8(source) & 0x01) << info->
52657bf6aefSLv Zheng 				      value));
52795b482a8SLen Brown 			break;
52895b482a8SLen Brown 
52995b482a8SLen Brown 		case ACPI_RSC_2BITFLAG:
53095b482a8SLen Brown 			/*
53195b482a8SLen Brown 			 * Mask and shift the flag bits
53295b482a8SLen Brown 			 */
53357bf6aefSLv Zheng 			ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
53457bf6aefSLv Zheng 				     ((ACPI_GET8(source) & 0x03) << info->
53557bf6aefSLv Zheng 				      value));
53695b482a8SLen Brown 			break;
53795b482a8SLen Brown 
538e0fe0a8dSLin Ming 		case ACPI_RSC_3BITFLAG:
539e0fe0a8dSLin Ming 			/*
540e0fe0a8dSLin Ming 			 * Mask and shift the flag bits
541e0fe0a8dSLin Ming 			 */
54257bf6aefSLv Zheng 			ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
54357bf6aefSLv Zheng 				     ((ACPI_GET8(source) & 0x07) << info->
54457bf6aefSLv Zheng 				      value));
545e0fe0a8dSLin Ming 			break;
546e0fe0a8dSLin Ming 
54795b482a8SLen Brown 		case ACPI_RSC_COUNT:
54895b482a8SLen Brown 
54995b482a8SLen Brown 			item_count = ACPI_GET8(source);
55057bf6aefSLv Zheng 			ACPI_SET8(destination, item_count);
55195b482a8SLen Brown 
55295b482a8SLen Brown 			aml_length =
55395b482a8SLen Brown 			    (u16) (aml_length +
55495b482a8SLen Brown 				   (info->value * (item_count - 1)));
55595b482a8SLen Brown 			break;
55695b482a8SLen Brown 
55795b482a8SLen Brown 		case ACPI_RSC_COUNT16:
55895b482a8SLen Brown 
55995b482a8SLen Brown 			item_count = ACPI_GET16(source);
56095b482a8SLen Brown 			aml_length = (u16) (aml_length + item_count);
56195b482a8SLen Brown 			acpi_rs_set_resource_length(aml_length, aml);
56295b482a8SLen Brown 			break;
56395b482a8SLen Brown 
564e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_PIN:
565e0fe0a8dSLin Ming 
566e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
56757bf6aefSLv Zheng 			ACPI_SET16(destination, aml_length);
568e0fe0a8dSLin Ming 
569e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count * 2);
570e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, info->value);
57157bf6aefSLv Zheng 			ACPI_SET16(target, aml_length);
572e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
573e0fe0a8dSLin Ming 			break;
574e0fe0a8dSLin Ming 
575e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_VEN:
576e0fe0a8dSLin Ming 
577e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
57857bf6aefSLv Zheng 			ACPI_SET16(destination, item_count);
579e0fe0a8dSLin Ming 
580e0fe0a8dSLin Ming 			aml_length =
581e0fe0a8dSLin Ming 			    (u16)(aml_length + (info->value * item_count));
582e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
583e0fe0a8dSLin Ming 			break;
584e0fe0a8dSLin Ming 
585e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_GPIO_RES:
586e0fe0a8dSLin Ming 
587e0fe0a8dSLin Ming 			/* Set resource source string length */
588e0fe0a8dSLin Ming 
589e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
59057bf6aefSLv Zheng 			ACPI_SET16(destination, aml_length);
591e0fe0a8dSLin Ming 
592e0fe0a8dSLin Ming 			/* Compute offset for the Vendor Data */
593e0fe0a8dSLin Ming 
594e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count);
595e0fe0a8dSLin Ming 			target = ACPI_ADD_PTR(void, aml, info->value);
596e0fe0a8dSLin Ming 
597e0fe0a8dSLin Ming 			/* Set vendor offset only if there is vendor data */
598e0fe0a8dSLin Ming 
599e0fe0a8dSLin Ming 			if (resource->data.gpio.vendor_length) {
60057bf6aefSLv Zheng 				ACPI_SET16(target, aml_length);
601e0fe0a8dSLin Ming 			}
602e0fe0a8dSLin Ming 
603e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
604e0fe0a8dSLin Ming 			break;
605e0fe0a8dSLin Ming 
606e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_VEN:
607e0fe0a8dSLin Ming 
608e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
60957bf6aefSLv Zheng 			ACPI_SET16(destination, item_count + info->value);
610e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count);
611e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
612e0fe0a8dSLin Ming 			break;
613e0fe0a8dSLin Ming 
614e0fe0a8dSLin Ming 		case ACPI_RSC_COUNT_SERIAL_RES:
615e0fe0a8dSLin Ming 
616e0fe0a8dSLin Ming 			item_count = ACPI_GET16(source);
617e0fe0a8dSLin Ming 			aml_length = (u16)(aml_length + item_count);
618e0fe0a8dSLin Ming 			acpi_rs_set_resource_length(aml_length, aml);
619e0fe0a8dSLin Ming 			break;
620e0fe0a8dSLin Ming 
62195b482a8SLen Brown 		case ACPI_RSC_LENGTH:
62295b482a8SLen Brown 
62395b482a8SLen Brown 			acpi_rs_set_resource_length(info->value, aml);
62495b482a8SLen Brown 			break;
62595b482a8SLen Brown 
62695b482a8SLen Brown 		case ACPI_RSC_MOVE8:
62795b482a8SLen Brown 		case ACPI_RSC_MOVE16:
62895b482a8SLen Brown 		case ACPI_RSC_MOVE32:
62995b482a8SLen Brown 		case ACPI_RSC_MOVE64:
63095b482a8SLen Brown 
63195b482a8SLen Brown 			if (info->value) {
63295b482a8SLen Brown 				item_count = info->value;
63395b482a8SLen Brown 			}
63495b482a8SLen Brown 			acpi_rs_move_data(destination, source, item_count,
63595b482a8SLen Brown 					  info->opcode);
63695b482a8SLen Brown 			break;
63795b482a8SLen Brown 
638e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_PIN:
639e0fe0a8dSLin Ming 
640e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
641e0fe0a8dSLin Ming 							   ACPI_GET16
642e0fe0a8dSLin Ming 							   (destination));
643e0fe0a8dSLin Ming 			source = *(u16 **)source;
644e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
645e0fe0a8dSLin Ming 					  info->opcode);
646e0fe0a8dSLin Ming 			break;
647e0fe0a8dSLin Ming 
648e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_GPIO_RES:
649e0fe0a8dSLin Ming 
650e0fe0a8dSLin Ming 			/* Used for both resource_source string and vendor_data */
651e0fe0a8dSLin Ming 
652e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
653e0fe0a8dSLin Ming 							   ACPI_GET16
654e0fe0a8dSLin Ming 							   (destination));
655e0fe0a8dSLin Ming 			source = *(u8 **)source;
656e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
657e0fe0a8dSLin Ming 					  info->opcode);
658e0fe0a8dSLin Ming 			break;
659e0fe0a8dSLin Ming 
660e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_VEN:
661e0fe0a8dSLin Ming 
662e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
663e0fe0a8dSLin Ming 							   (aml_length -
664e0fe0a8dSLin Ming 							    item_count));
665e0fe0a8dSLin Ming 			source = *(u8 **)source;
666e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
667e0fe0a8dSLin Ming 					  info->opcode);
668e0fe0a8dSLin Ming 			break;
669e0fe0a8dSLin Ming 
670e0fe0a8dSLin Ming 		case ACPI_RSC_MOVE_SERIAL_RES:
671e0fe0a8dSLin Ming 
672e0fe0a8dSLin Ming 			destination = (char *)ACPI_ADD_PTR(void, aml,
673e0fe0a8dSLin Ming 							   (aml_length -
674e0fe0a8dSLin Ming 							    item_count));
675e0fe0a8dSLin Ming 			source = *(u8 **)source;
676e0fe0a8dSLin Ming 			acpi_rs_move_data(destination, source, item_count,
677e0fe0a8dSLin Ming 					  info->opcode);
678e0fe0a8dSLin Ming 			break;
679e0fe0a8dSLin Ming 
68095b482a8SLen Brown 		case ACPI_RSC_ADDRESS:
68195b482a8SLen Brown 
68295b482a8SLen Brown 			/* Set the Resource Type, General Flags, and Type-Specific Flags */
68395b482a8SLen Brown 
68495b482a8SLen Brown 			acpi_rs_set_address_common(aml, resource);
68595b482a8SLen Brown 			break;
68695b482a8SLen Brown 
68795b482a8SLen Brown 		case ACPI_RSC_SOURCEX:
68895b482a8SLen Brown 			/*
68995b482a8SLen Brown 			 * Optional resource_source (Index and String)
69095b482a8SLen Brown 			 */
69195b482a8SLen Brown 			aml_length =
6923e8214e5SLv Zheng 			    acpi_rs_set_resource_source(aml,
6933e8214e5SLv Zheng 							(acpi_rs_length)
69495b482a8SLen Brown 							aml_length, source);
69595b482a8SLen Brown 			acpi_rs_set_resource_length(aml_length, aml);
69695b482a8SLen Brown 			break;
69795b482a8SLen Brown 
69895b482a8SLen Brown 		case ACPI_RSC_SOURCE:
69995b482a8SLen Brown 			/*
70095b482a8SLen Brown 			 * Optional resource_source (Index and String). This is the more
70195b482a8SLen Brown 			 * complicated case used by the Interrupt() macro
70295b482a8SLen Brown 			 */
70395b482a8SLen Brown 			aml_length =
70495b482a8SLen Brown 			    acpi_rs_set_resource_source(aml, info->value,
70595b482a8SLen Brown 							source);
70695b482a8SLen Brown 			acpi_rs_set_resource_length(aml_length, aml);
70795b482a8SLen Brown 			break;
70895b482a8SLen Brown 
70995b482a8SLen Brown 		case ACPI_RSC_BITMASK:
71095b482a8SLen Brown 			/*
71195b482a8SLen Brown 			 * 8-bit encoded bitmask (DMA macro)
71295b482a8SLen Brown 			 */
71357bf6aefSLv Zheng 			ACPI_SET8(destination,
71495b482a8SLen Brown 				  acpi_rs_encode_bitmask(source,
71557bf6aefSLv Zheng 							 *ACPI_ADD_PTR(u8,
71657bf6aefSLv Zheng 								       resource,
71757bf6aefSLv Zheng 								       info->
71857bf6aefSLv Zheng 								       value)));
71995b482a8SLen Brown 			break;
72095b482a8SLen Brown 
72195b482a8SLen Brown 		case ACPI_RSC_BITMASK16:
72295b482a8SLen Brown 			/*
72395b482a8SLen Brown 			 * 16-bit encoded bitmask (IRQ macro)
72495b482a8SLen Brown 			 */
72595b482a8SLen Brown 			temp16 = acpi_rs_encode_bitmask(source,
72695b482a8SLen Brown 							*ACPI_ADD_PTR(u8,
72795b482a8SLen Brown 								      resource,
72895b482a8SLen Brown 								      info->
72995b482a8SLen Brown 								      value));
73095b482a8SLen Brown 			ACPI_MOVE_16_TO_16(destination, &temp16);
73195b482a8SLen Brown 			break;
73295b482a8SLen Brown 
73395b482a8SLen Brown 		case ACPI_RSC_EXIT_LE:
73495b482a8SLen Brown 			/*
735ba494beeSBob Moore 			 * control - Exit conversion if less than or equal
73695b482a8SLen Brown 			 */
73795b482a8SLen Brown 			if (item_count <= info->value) {
73895b482a8SLen Brown 				goto exit;
73995b482a8SLen Brown 			}
74095b482a8SLen Brown 			break;
74195b482a8SLen Brown 
74295b482a8SLen Brown 		case ACPI_RSC_EXIT_NE:
74395b482a8SLen Brown 			/*
744ba494beeSBob Moore 			 * control - Exit conversion if not equal
74595b482a8SLen Brown 			 */
74695b482a8SLen Brown 			switch (COMPARE_OPCODE(info)) {
74795b482a8SLen Brown 			case ACPI_RSC_COMPARE_VALUE:
74895b482a8SLen Brown 
74995b482a8SLen Brown 				if (*ACPI_ADD_PTR(u8, resource,
75095b482a8SLen Brown 						  COMPARE_TARGET(info)) !=
75195b482a8SLen Brown 				    COMPARE_VALUE(info)) {
75295b482a8SLen Brown 					goto exit;
75395b482a8SLen Brown 				}
75495b482a8SLen Brown 				break;
75595b482a8SLen Brown 
75695b482a8SLen Brown 			default:
75795b482a8SLen Brown 
75895b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
75995b482a8SLen Brown 					    "Invalid conversion sub-opcode"));
76095b482a8SLen Brown 				return_ACPI_STATUS(AE_BAD_PARAMETER);
76195b482a8SLen Brown 			}
76295b482a8SLen Brown 			break;
76395b482a8SLen Brown 
76495b482a8SLen Brown 		case ACPI_RSC_EXIT_EQ:
76595b482a8SLen Brown 			/*
766ba494beeSBob Moore 			 * control - Exit conversion if equal
76795b482a8SLen Brown 			 */
76895b482a8SLen Brown 			if (*ACPI_ADD_PTR(u8, resource,
76995b482a8SLen Brown 					  COMPARE_TARGET(info)) ==
77095b482a8SLen Brown 			    COMPARE_VALUE(info)) {
77195b482a8SLen Brown 				goto exit;
77295b482a8SLen Brown 			}
77395b482a8SLen Brown 			break;
77495b482a8SLen Brown 
77595b482a8SLen Brown 		default:
77695b482a8SLen Brown 
77795b482a8SLen Brown 			ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
77895b482a8SLen Brown 			return_ACPI_STATUS(AE_BAD_PARAMETER);
77995b482a8SLen Brown 		}
78095b482a8SLen Brown 
78195b482a8SLen Brown 		count--;
78295b482a8SLen Brown 		info++;
78395b482a8SLen Brown 	}
78495b482a8SLen Brown 
78595b482a8SLen Brown       exit:
78695b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
78795b482a8SLen Brown }
78895b482a8SLen Brown 
78995b482a8SLen Brown #if 0
79095b482a8SLen Brown /* Previous resource validations */
79195b482a8SLen Brown 
792ba494beeSBob Moore if (aml->ext_address64.revision_ID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
79395b482a8SLen Brown 	return_ACPI_STATUS(AE_SUPPORT);
79495b482a8SLen Brown }
79595b482a8SLen Brown 
79695b482a8SLen Brown if (resource->data.start_dpf.performance_robustness >= 3) {
79795b482a8SLen Brown 	return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
79895b482a8SLen Brown }
79995b482a8SLen Brown 
80095b482a8SLen Brown if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
80195b482a8SLen Brown 	/*
80295b482a8SLen Brown 	 * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
80395b482a8SLen Brown 	 * polarity/trigger interrupts are allowed (ACPI spec, section
80495b482a8SLen Brown 	 * "IRQ Format"), so 0x00 and 0x09 are illegal.
80595b482a8SLen Brown 	 */
80695b482a8SLen Brown 	ACPI_ERROR((AE_INFO,
807f6a22b0bSBob Moore 		    "Invalid interrupt polarity/trigger in resource list, 0x%X",
80895b482a8SLen Brown 		    aml->irq.flags));
80995b482a8SLen Brown 	return_ACPI_STATUS(AE_BAD_DATA);
81095b482a8SLen Brown }
81195b482a8SLen Brown 
81295b482a8SLen Brown resource->data.extended_irq.interrupt_count = temp8;
81395b482a8SLen Brown if (temp8 < 1) {
81495b482a8SLen Brown 
81595b482a8SLen Brown 	/* Must have at least one IRQ */
81695b482a8SLen Brown 
81795b482a8SLen Brown 	return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
81895b482a8SLen Brown }
81995b482a8SLen Brown 
82095b482a8SLen Brown if (resource->data.dma.transfer == 0x03) {
82195b482a8SLen Brown 	ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
82295b482a8SLen Brown 	return_ACPI_STATUS(AE_BAD_DATA);
82395b482a8SLen Brown }
82495b482a8SLen Brown #endif
825