blob: 337a0f01cb23c270bc97a90384ed673940f10648 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsmisc - Miscellaneous resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("rsmisc")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/*******************************************************************************
51 *
Bob Moore50eca3e2005-09-30 19:03:00 -040052 * FUNCTION: acpi_rs_get_generic_reg
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
Bob Moore50eca3e2005-09-30 19:03:00 -040054 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * aml_resource_length - Length of the resource from the AML header
56 * Resource - Where the internal resource is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 *
58 * RETURN: Status
59 *
Bob Moore50eca3e2005-09-30 19:03:00 -040060 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
61 * internal resource descriptor, simplifying bitflags and handling
62 * alignment and endian issues if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 *
64 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070065acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -040066acpi_rs_get_generic_reg(union aml_resource *aml,
67 u16 aml_resource_length, struct acpi_resource *resource)
Robert Moorebda663d2005-09-16 16:51:15 -040068{
Bob Moore50eca3e2005-09-30 19:03:00 -040069 ACPI_FUNCTION_TRACE("rs_get_generic_reg");
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71 /*
Bob Moore50eca3e2005-09-30 19:03:00 -040072 * Get the following fields from the AML descriptor:
73 * Address Space ID
74 * Register Bit Width
75 * Register Bit Offset
76 * Access Size
77 * Register Address
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 */
Bob Moore50eca3e2005-09-30 19:03:00 -040079 resource->data.generic_reg.space_id = aml->generic_reg.address_space_id;
80 resource->data.generic_reg.bit_width = aml->generic_reg.bit_width;
81 resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset;
82 resource->data.generic_reg.access_size = aml->generic_reg.access_size;
83 ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address,
84 &aml->generic_reg.address);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Bob Moore50eca3e2005-09-30 19:03:00 -040086 /* Complete the resource header */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Bob Moore50eca3e2005-09-30 19:03:00 -040088 resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER;
89 resource->length =
90 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register);
Len Brown4be44fc2005-08-05 00:44:28 -040091 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092}
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*******************************************************************************
95 *
Bob Moore50eca3e2005-09-30 19:03:00 -040096 * FUNCTION: acpi_rs_set_generic_reg
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 *
Bob Moore50eca3e2005-09-30 19:03:00 -040098 * PARAMETERS: Resource - Pointer to the resource descriptor
99 * Aml - Where the AML descriptor is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 *
101 * RETURN: Status
102 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400103 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
104 * external AML resource descriptor.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 *
106 ******************************************************************************/
107
108acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400109acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Bob Moore50eca3e2005-09-30 19:03:00 -0400111 ACPI_FUNCTION_TRACE("rs_set_generic_reg");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Bob Moore50eca3e2005-09-30 19:03:00 -0400113 /*
114 * Set the following fields in the AML descriptor:
115 * Address Space ID
116 * Register Bit Width
117 * Register Bit Offset
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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Bob Moore50eca3e2005-09-30 19:03:00 -0400131 /* Complete the AML descriptor header */
Robert Moore44f6c012005-04-18 22:49:35 -0400132
Bob Moore50eca3e2005-09-30 19:03:00 -0400133 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER,
134 sizeof(struct
135 aml_resource_generic_register), aml);
136 return_ACPI_STATUS(AE_OK);
137}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Bob Moore50eca3e2005-09-30 19:03:00 -0400139/*******************************************************************************
140 *
141 * FUNCTION: acpi_rs_get_vendor
142 *
143 * PARAMETERS: Aml - Pointer to the AML resource descriptor
144 * aml_resource_length - Length of the resource from the AML header
145 * Resource - Where the internal resource is returned
146 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
150 * internal resource descriptor, simplifying bitflags and handling
151 * alignment and endian issues if necessary.
152 *
153 ******************************************************************************/
Robert Moore44f6c012005-04-18 22:49:35 -0400154
Bob Moore50eca3e2005-09-30 19:03:00 -0400155acpi_status
156acpi_rs_get_vendor(union aml_resource *aml,
157 u16 aml_resource_length, struct acpi_resource *resource)
158{
159 u8 *aml_byte_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Bob Moore50eca3e2005-09-30 19:03:00 -0400161 ACPI_FUNCTION_TRACE("rs_get_vendor");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Bob Moore50eca3e2005-09-30 19:03:00 -0400163 /* Determine if this is a large or small vendor specific item */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
Bob Moore50eca3e2005-09-30 19:03:00 -0400165 if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
166 /* Large item, Point to the first vendor byte */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Bob Moore50eca3e2005-09-30 19:03:00 -0400168 aml_byte_data =
169 ((u8 *) aml) + sizeof(struct aml_resource_large_header);
Len Brown4be44fc2005-08-05 00:44:28 -0400170 } else {
Bob Moore50eca3e2005-09-30 19:03:00 -0400171 /* Small item, Point to the first vendor byte */
Robert Moore44f6c012005-04-18 22:49:35 -0400172
Bob Moore50eca3e2005-09-30 19:03:00 -0400173 aml_byte_data =
174 ((u8 *) aml) + sizeof(struct aml_resource_small_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 }
176
Bob Moore50eca3e2005-09-30 19:03:00 -0400177 /* Copy the vendor-specific bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Bob Moore50eca3e2005-09-30 19:03:00 -0400179 ACPI_MEMCPY(resource->data.vendor.byte_data,
180 aml_byte_data, aml_resource_length);
181 resource->data.vendor.byte_length = aml_resource_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
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 */
Bob Moore50eca3e2005-09-30 19:03:00 -0400188 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);
Len Brown4be44fc2005-08-05 00:44:28 -0400191 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192}
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194/*******************************************************************************
195 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400196 * FUNCTION: acpi_rs_set_vendor
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400198 * PARAMETERS: Resource - Pointer to the resource descriptor
199 * Aml - Where the AML descriptor is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 *
201 * RETURN: Status
202 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400203 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
204 * external AML resource descriptor.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 *
206 ******************************************************************************/
207
208acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400209acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
Bob Moore50eca3e2005-09-30 19:03:00 -0400211 u32 resource_length;
212 u8 *source;
213 u8 *destination;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Bob Moore50eca3e2005-09-30 19:03:00 -0400215 ACPI_FUNCTION_TRACE("rs_set_vendor");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Bob Moore50eca3e2005-09-30 19:03:00 -0400217 resource_length = resource->data.vendor.byte_length;
218 source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data);
Robert Moore44f6c012005-04-18 22:49:35 -0400219
Bob Moore50eca3e2005-09-30 19:03:00 -0400220 /* Length determines if this is a large or small resource */
Robert Moore44f6c012005-04-18 22:49:35 -0400221
Bob Moore50eca3e2005-09-30 19:03:00 -0400222 if (resource_length > 7) {
223 /* Large item, get pointer to the data part of the descriptor */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Bob Moore50eca3e2005-09-30 19:03:00 -0400225 destination =
226 ((u8 *) aml) + sizeof(struct aml_resource_large_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Bob Moore50eca3e2005-09-30 19:03:00 -0400228 /* 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);
Len Brown4be44fc2005-08-05 00:44:28 -0400235 } else {
Bob Moore50eca3e2005-09-30 19:03:00 -0400236 /* Small item, get pointer to the data part of the descriptor */
Robert Moore44f6c012005-04-18 22:49:35 -0400237
Bob Moore50eca3e2005-09-30 19:03:00 -0400238 destination =
239 ((u8 *) aml) + sizeof(struct aml_resource_small_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Bob Moore50eca3e2005-09-30 19:03:00 -0400241 /* Complete the AML descriptor header */
242
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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 }
249
Bob Moore50eca3e2005-09-30 19:03:00 -0400250 /* Copy the vendor-specific bytes */
Robert Moore44f6c012005-04-18 22:49:35 -0400251
Bob Moore50eca3e2005-09-30 19:03:00 -0400252 ACPI_MEMCPY(destination, source, resource_length);
Len Brown4be44fc2005-08-05 00:44:28 -0400253 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254}
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256/*******************************************************************************
257 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400258 * FUNCTION: acpi_rs_get_start_dpf
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400260 * PARAMETERS: Aml - Pointer to the AML resource descriptor
261 * aml_resource_length - Length of the resource from the AML header
262 * Resource - Where the internal resource is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 *
264 * RETURN: Status
265 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400266 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
267 * internal resource descriptor, simplifying bitflags and handling
268 * alignment and endian issues if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 *
270 ******************************************************************************/
271
272acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400273acpi_rs_get_start_dpf(union aml_resource *aml,
274 u16 aml_resource_length, struct acpi_resource *resource)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
Bob Moore50eca3e2005-09-30 19:03:00 -0400276 ACPI_FUNCTION_TRACE("rs_get_start_dpf");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Bob Moore50eca3e2005-09-30 19:03:00 -0400278 /* Get the flags byte if present */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Bob Moore50eca3e2005-09-30 19:03:00 -0400280 if (aml_resource_length == 1) {
281 /* Get the Compatibility priority */
Robert Moore44f6c012005-04-18 22:49:35 -0400282
Bob Moore50eca3e2005-09-30 19:03:00 -0400283 resource->data.start_dpf.compatibility_priority =
284 (aml->start_dpf.flags & 0x03);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Bob Moore50eca3e2005-09-30 19:03:00 -0400286 if (resource->data.start_dpf.compatibility_priority >= 3) {
Len Brown4be44fc2005-08-05 00:44:28 -0400287 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 }
289
Bob Moore50eca3e2005-09-30 19:03:00 -0400290 /* Get the Performance/Robustness preference */
Robert Moore44f6c012005-04-18 22:49:35 -0400291
Bob Moore50eca3e2005-09-30 19:03:00 -0400292 resource->data.start_dpf.performance_robustness =
293 ((aml->start_dpf.flags >> 2) & 0x03);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Bob Moore50eca3e2005-09-30 19:03:00 -0400295 if (resource->data.start_dpf.performance_robustness >= 3) {
Len Brown4be44fc2005-08-05 00:44:28 -0400296 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 }
Len Brown4be44fc2005-08-05 00:44:28 -0400298 } else {
Bob Moore50eca3e2005-09-30 19:03:00 -0400299 /* start_dependent_no_pri(), no flags byte, set defaults */
300
301 resource->data.start_dpf.compatibility_priority =
Len Brown4be44fc2005-08-05 00:44:28 -0400302 ACPI_ACCEPTABLE_CONFIGURATION;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Bob Moore50eca3e2005-09-30 19:03:00 -0400304 resource->data.start_dpf.performance_robustness =
Len Brown4be44fc2005-08-05 00:44:28 -0400305 ACPI_ACCEPTABLE_CONFIGURATION;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 }
307
Bob Moore50eca3e2005-09-30 19:03:00 -0400308 /* Complete the resource header */
Robert Moore44f6c012005-04-18 22:49:35 -0400309
Bob Moore50eca3e2005-09-30 19:03:00 -0400310 resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT;
311 resource->length =
312 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent);
Len Brown4be44fc2005-08-05 00:44:28 -0400313 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314}
315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316/*******************************************************************************
317 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400318 * FUNCTION: acpi_rs_set_start_dpf
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400320 * PARAMETERS: Resource - Pointer to the resource descriptor
321 * Aml - Where the AML descriptor is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 *
323 * RETURN: Status
324 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400325 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
326 * external AML resource descriptor.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 *
328 ******************************************************************************/
329
330acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400331acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
Bob Moore50eca3e2005-09-30 19:03:00 -0400333 ACPI_FUNCTION_TRACE("rs_set_start_dpf");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
335 /*
Robert Moorebda663d2005-09-16 16:51:15 -0400336 * The descriptor type field is set based upon whether a byte is needed
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 * to contain Priority data.
338 */
339 if (ACPI_ACCEPTABLE_CONFIGURATION ==
Robert Moorebda663d2005-09-16 16:51:15 -0400340 resource->data.start_dpf.compatibility_priority &&
Len Brown4be44fc2005-08-05 00:44:28 -0400341 ACPI_ACCEPTABLE_CONFIGURATION ==
Robert Moorebda663d2005-09-16 16:51:15 -0400342 resource->data.start_dpf.performance_robustness) {
Bob Moore50eca3e2005-09-30 19:03:00 -0400343 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
344 sizeof(struct
345 aml_resource_start_dependent_noprio),
346 aml);
Len Brown4be44fc2005-08-05 00:44:28 -0400347 } else {
Bob Moore50eca3e2005-09-30 19:03:00 -0400348 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT,
349 sizeof(struct
350 aml_resource_start_dependent),
351 aml);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
Bob Moore50eca3e2005-09-30 19:03:00 -0400353 /* Set the Flags byte */
Robert Moore44f6c012005-04-18 22:49:35 -0400354
Bob Moore50eca3e2005-09-30 19:03:00 -0400355 aml->start_dpf.flags = (u8)
356 (((resource->data.start_dpf.
357 performance_robustness & 0x03) << 2) | (resource->data.
358 start_dpf.
359 compatibility_priority
360 & 0x03));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 }
Len Brown4be44fc2005-08-05 00:44:28 -0400362 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363}
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365/*******************************************************************************
366 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400367 * FUNCTION: acpi_rs_get_end_dpf
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400369 * PARAMETERS: Aml - Pointer to the AML resource descriptor
370 * aml_resource_length - Length of the resource from the AML header
371 * Resource - Where the internal resource is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 *
373 * RETURN: Status
374 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400375 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
376 * internal resource descriptor, simplifying bitflags and handling
377 * alignment and endian issues if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 *
379 ******************************************************************************/
380
381acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400382acpi_rs_get_end_dpf(union aml_resource *aml,
383 u16 aml_resource_length, struct acpi_resource *resource)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384{
Bob Moore50eca3e2005-09-30 19:03:00 -0400385 ACPI_FUNCTION_TRACE("rs_get_end_dpf");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
Bob Moore50eca3e2005-09-30 19:03:00 -0400387 /* Complete the resource header */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
Bob Moore50eca3e2005-09-30 19:03:00 -0400389 resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT;
390 resource->length = (u32) ACPI_RESOURCE_LENGTH;
391 return_ACPI_STATUS(AE_OK);
392}
Robert Moore44f6c012005-04-18 22:49:35 -0400393
Bob Moore50eca3e2005-09-30 19:03:00 -0400394/*******************************************************************************
395 *
396 * FUNCTION: acpi_rs_set_end_dpf
397 *
398 * PARAMETERS: Resource - Pointer to the resource descriptor
399 * Aml - Where the AML descriptor is returned
400 *
401 * RETURN: Status
402 *
403 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
404 * external AML resource descriptor.
405 *
406 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
Bob Moore50eca3e2005-09-30 19:03:00 -0400408acpi_status
409acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml)
410{
411 ACPI_FUNCTION_TRACE("rs_set_end_dpf");
Robert Moore44f6c012005-04-18 22:49:35 -0400412
Bob Moore50eca3e2005-09-30 19:03:00 -0400413 /* Complete the AML descriptor header */
414
415 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT,
416 sizeof(struct aml_resource_end_dependent),
417 aml);
418 return_ACPI_STATUS(AE_OK);
419}
420
421/*******************************************************************************
422 *
423 * FUNCTION: acpi_rs_get_end_tag
424 *
425 * PARAMETERS: Aml - Pointer to the AML resource descriptor
426 * aml_resource_length - Length of the resource from the AML header
427 * Resource - Where the internal resource is returned
428 *
429 * RETURN: Status
430 *
431 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
432 * internal resource descriptor, simplifying bitflags and handling
433 * alignment and endian issues if necessary.
434 *
435 ******************************************************************************/
436
437acpi_status
438acpi_rs_get_end_tag(union aml_resource *aml,
439 u16 aml_resource_length, struct acpi_resource *resource)
440{
441 ACPI_FUNCTION_TRACE("rs_get_end_tag");
442
443 /* Complete the resource header */
444
445 resource->type = ACPI_RESOURCE_TYPE_END_TAG;
446 resource->length = ACPI_RESOURCE_LENGTH;
447 return_ACPI_STATUS(AE_OK);
448}
449
450/*******************************************************************************
451 *
452 * FUNCTION: acpi_rs_set_end_tag
453 *
454 * PARAMETERS: Resource - Pointer to the resource descriptor
455 * Aml - Where the AML descriptor is returned
456 *
457 * RETURN: Status
458 *
459 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
460 * external AML resource descriptor.
461 *
462 ******************************************************************************/
463
464acpi_status
465acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml)
466{
467 ACPI_FUNCTION_TRACE("rs_set_end_tag");
468
469 /*
470 * Set the Checksum - zero means that the resource data is treated as if
471 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
472 */
473 aml->end_tag.checksum = 0;
474
475 /* Complete the AML descriptor header */
476
477 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG,
478 sizeof(struct aml_resource_end_tag), aml);
Len Brown4be44fc2005-08-05 00:44:28 -0400479 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480}