Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/acresrc.h> |
| 46 | |
| 47 | #define _COMPONENT ACPI_RESOURCES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 48 | ACPI_MODULE_NAME("rsmisc") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /******************************************************************************* |
| 51 | * |
| 52 | * FUNCTION: acpi_rs_end_tag_resource |
| 53 | * |
| 54 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 55 | * stream |
| 56 | * bytes_consumed - Pointer to where the number of bytes |
| 57 | * consumed the byte_stream_buffer is |
| 58 | * returned |
| 59 | * output_buffer - Pointer to the return data buffer |
| 60 | * structure_size - Pointer to where the number of bytes |
| 61 | * in the return data struct is returned |
| 62 | * |
| 63 | * RETURN: Status |
| 64 | * |
| 65 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 66 | * structure pointed to by the output_buffer. Return the |
| 67 | * number of bytes consumed from the byte stream. |
| 68 | * |
| 69 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 71 | acpi_rs_end_tag_resource(u8 * byte_stream_buffer, |
| 72 | acpi_size * bytes_consumed, |
| 73 | u8 ** output_buffer, acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 75 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 76 | acpi_size struct_size = ACPI_RESOURCE_LENGTH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 78 | ACPI_FUNCTION_TRACE("rs_end_tag_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 80 | /* The number of bytes consumed is static */ |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | *bytes_consumed = 2; |
| 83 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 84 | /* Fill out the structure */ |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | output_struct->id = ACPI_RSTYPE_END_TAG; |
| 87 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 88 | /* Set the Length parameter */ |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | output_struct->length = 0; |
| 91 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 92 | /* Return the final size of the structure */ |
| 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 95 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | /******************************************************************************* |
| 99 | * |
| 100 | * FUNCTION: acpi_rs_end_tag_stream |
| 101 | * |
| 102 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 103 | * output_buffer - Pointer to the user's return buffer |
| 104 | * bytes_consumed - Pointer to where the number of bytes |
| 105 | * used in the output_buffer is returned |
| 106 | * |
| 107 | * RETURN: Status |
| 108 | * |
| 109 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 110 | * the appropriate bytes in a byte stream |
| 111 | * |
| 112 | ******************************************************************************/ |
| 113 | |
| 114 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 115 | acpi_rs_end_tag_stream(struct acpi_resource *linked_list, |
| 116 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 118 | u8 *buffer = *output_buffer; |
| 119 | u8 temp8 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 121 | ACPI_FUNCTION_TRACE("rs_end_tag_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 123 | /* The descriptor field is static */ |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | *buffer = 0x79; |
| 126 | buffer += 1; |
| 127 | |
| 128 | /* |
| 129 | * Set the Checksum - zero means that the resource data is treated as if |
| 130 | * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) |
| 131 | */ |
| 132 | temp8 = 0; |
| 133 | |
| 134 | *buffer = temp8; |
| 135 | buffer += 1; |
| 136 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 137 | /* Return the number of bytes consumed in this operation */ |
| 138 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 139 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 140 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | /******************************************************************************* |
| 144 | * |
| 145 | * FUNCTION: acpi_rs_vendor_resource |
| 146 | * |
| 147 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 148 | * stream |
| 149 | * bytes_consumed - Pointer to where the number of bytes |
| 150 | * consumed the byte_stream_buffer is |
| 151 | * returned |
| 152 | * output_buffer - Pointer to the return data buffer |
| 153 | * structure_size - Pointer to where the number of bytes |
| 154 | * in the return data struct is returned |
| 155 | * |
| 156 | * RETURN: Status |
| 157 | * |
| 158 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 159 | * structure pointed to by the output_buffer. Return the |
| 160 | * number of bytes consumed from the byte stream. |
| 161 | * |
| 162 | ******************************************************************************/ |
| 163 | |
| 164 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 165 | acpi_rs_vendor_resource(u8 * byte_stream_buffer, |
| 166 | acpi_size * bytes_consumed, |
| 167 | u8 ** output_buffer, acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 169 | u8 *buffer = byte_stream_buffer; |
| 170 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 171 | u16 temp16 = 0; |
| 172 | u8 temp8 = 0; |
| 173 | u8 index; |
| 174 | acpi_size struct_size = |
| 175 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 177 | ACPI_FUNCTION_TRACE("rs_vendor_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 179 | /* Dereference the Descriptor to find if this is a large or small item. */ |
| 180 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | temp8 = *buffer; |
| 182 | |
| 183 | if (temp8 & 0x80) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 184 | /* Large Item, point to the length field */ |
| 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | buffer += 1; |
| 187 | |
| 188 | /* Dereference */ |
| 189 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 190 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
| 192 | /* Calculate bytes consumed */ |
| 193 | |
| 194 | *bytes_consumed = (acpi_size) temp16 + 3; |
| 195 | |
| 196 | /* Point to the first vendor byte */ |
| 197 | |
| 198 | buffer += 2; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 199 | } else { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 200 | /* Small Item, dereference the size */ |
| 201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 202 | temp16 = (u8) (*buffer & 0x07); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
| 204 | /* Calculate bytes consumed */ |
| 205 | |
| 206 | *bytes_consumed = (acpi_size) temp16 + 1; |
| 207 | |
| 208 | /* Point to the first vendor byte */ |
| 209 | |
| 210 | buffer += 1; |
| 211 | } |
| 212 | |
| 213 | output_struct->id = ACPI_RSTYPE_VENDOR; |
| 214 | output_struct->data.vendor_specific.length = temp16; |
| 215 | |
| 216 | for (index = 0; index < temp16; index++) { |
| 217 | output_struct->data.vendor_specific.reserved[index] = *buffer; |
| 218 | buffer += 1; |
| 219 | } |
| 220 | |
| 221 | /* |
| 222 | * In order for the struct_size to fall on a 32-bit boundary, |
| 223 | * calculate the length of the vendor string and expand the |
| 224 | * struct_size to the next 32-bit boundary. |
| 225 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 226 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 228 | /* Set the Length parameter */ |
| 229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | output_struct->length = (u32) struct_size; |
| 231 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 232 | /* Return the final size of the structure */ |
| 233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 235 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | /******************************************************************************* |
| 239 | * |
| 240 | * FUNCTION: acpi_rs_vendor_stream |
| 241 | * |
| 242 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 243 | * output_buffer - Pointer to the user's return buffer |
| 244 | * bytes_consumed - Pointer to where the number of bytes |
| 245 | * used in the output_buffer is returned |
| 246 | * |
| 247 | * RETURN: Status |
| 248 | * |
| 249 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 250 | * the appropriate bytes in a byte stream |
| 251 | * |
| 252 | ******************************************************************************/ |
| 253 | |
| 254 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 255 | acpi_rs_vendor_stream(struct acpi_resource *linked_list, |
| 256 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 258 | u8 *buffer = *output_buffer; |
| 259 | u16 temp16 = 0; |
| 260 | u8 temp8 = 0; |
| 261 | u8 index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 263 | ACPI_FUNCTION_TRACE("rs_vendor_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 265 | /* Dereference the length to find if this is a large or small item. */ |
| 266 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 267 | if (linked_list->data.vendor_specific.length > 7) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 268 | /* Large Item, Set the descriptor field and length bytes */ |
| 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | *buffer = 0x84; |
| 271 | buffer += 1; |
| 272 | |
| 273 | temp16 = (u16) linked_list->data.vendor_specific.length; |
| 274 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 275 | ACPI_MOVE_16_TO_16(buffer, &temp16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | buffer += 2; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 277 | } else { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 278 | /* Small Item, Set the descriptor field */ |
| 279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | temp8 = 0x70; |
| 281 | temp8 |= (u8) linked_list->data.vendor_specific.length; |
| 282 | |
| 283 | *buffer = temp8; |
| 284 | buffer += 1; |
| 285 | } |
| 286 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 287 | /* Loop through all of the Vendor Specific fields */ |
| 288 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 289 | for (index = 0; index < linked_list->data.vendor_specific.length; |
| 290 | index++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | temp8 = linked_list->data.vendor_specific.reserved[index]; |
| 292 | |
| 293 | *buffer = temp8; |
| 294 | buffer += 1; |
| 295 | } |
| 296 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 297 | /* Return the number of bytes consumed in this operation */ |
| 298 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 299 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 300 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | /******************************************************************************* |
| 304 | * |
| 305 | * FUNCTION: acpi_rs_start_depend_fns_resource |
| 306 | * |
| 307 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 308 | * stream |
| 309 | * bytes_consumed - Pointer to where the number of bytes |
| 310 | * consumed the byte_stream_buffer is |
| 311 | * returned |
| 312 | * output_buffer - Pointer to the return data buffer |
| 313 | * structure_size - Pointer to where the number of bytes |
| 314 | * in the return data struct is returned |
| 315 | * |
| 316 | * RETURN: Status |
| 317 | * |
| 318 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 319 | * structure pointed to by the output_buffer. Return the |
| 320 | * number of bytes consumed from the byte stream. |
| 321 | * |
| 322 | ******************************************************************************/ |
| 323 | |
| 324 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 325 | acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, |
| 326 | acpi_size * bytes_consumed, |
| 327 | u8 ** output_buffer, |
| 328 | acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 330 | u8 *buffer = byte_stream_buffer; |
| 331 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 332 | u8 temp8 = 0; |
| 333 | acpi_size struct_size = |
| 334 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 336 | ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 338 | /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ |
| 339 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | temp8 = *buffer; |
| 341 | |
| 342 | *bytes_consumed = (temp8 & 0x01) + 1; |
| 343 | |
| 344 | output_struct->id = ACPI_RSTYPE_START_DPF; |
| 345 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 346 | /* Point to Byte 1 if it is used */ |
| 347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | if (2 == *bytes_consumed) { |
| 349 | buffer += 1; |
| 350 | temp8 = *buffer; |
| 351 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 352 | /* Check Compatibility priority */ |
| 353 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 354 | output_struct->data.start_dpf.compatibility_priority = |
| 355 | temp8 & 0x03; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
| 357 | if (3 == output_struct->data.start_dpf.compatibility_priority) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 358 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 361 | /* Check Performance/Robustness preference */ |
| 362 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 363 | output_struct->data.start_dpf.performance_robustness = |
| 364 | (temp8 >> 2) & 0x03; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
| 366 | if (3 == output_struct->data.start_dpf.performance_robustness) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 367 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 369 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | output_struct->data.start_dpf.compatibility_priority = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 371 | ACPI_ACCEPTABLE_CONFIGURATION; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | |
| 373 | output_struct->data.start_dpf.performance_robustness = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 374 | ACPI_ACCEPTABLE_CONFIGURATION; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 377 | /* Set the Length parameter */ |
| 378 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | output_struct->length = (u32) struct_size; |
| 380 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 381 | /* Return the final size of the structure */ |
| 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 384 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | /******************************************************************************* |
| 388 | * |
| 389 | * FUNCTION: acpi_rs_end_depend_fns_resource |
| 390 | * |
| 391 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte |
| 392 | * stream |
| 393 | * bytes_consumed - Pointer to where the number of bytes |
| 394 | * consumed the byte_stream_buffer is |
| 395 | * returned |
| 396 | * output_buffer - Pointer to the return data buffer |
| 397 | * structure_size - Pointer to where the number of bytes |
| 398 | * in the return data struct is returned |
| 399 | * |
| 400 | * RETURN: Status |
| 401 | * |
| 402 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate |
| 403 | * structure pointed to by the output_buffer. Return the |
| 404 | * number of bytes consumed from the byte stream. |
| 405 | * |
| 406 | ******************************************************************************/ |
| 407 | |
| 408 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 409 | acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, |
| 410 | acpi_size * bytes_consumed, |
| 411 | u8 ** output_buffer, acpi_size * structure_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 413 | struct acpi_resource *output_struct = (void *)*output_buffer; |
| 414 | acpi_size struct_size = ACPI_RESOURCE_LENGTH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 416 | ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 418 | /* The number of bytes consumed is static */ |
| 419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | *bytes_consumed = 1; |
| 421 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 422 | /* Fill out the structure */ |
| 423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | output_struct->id = ACPI_RSTYPE_END_DPF; |
| 425 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 426 | /* Set the Length parameter */ |
| 427 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | output_struct->length = (u32) struct_size; |
| 429 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 430 | /* Return the final size of the structure */ |
| 431 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | *structure_size = struct_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 433 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | /******************************************************************************* |
| 437 | * |
| 438 | * FUNCTION: acpi_rs_start_depend_fns_stream |
| 439 | * |
| 440 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 441 | * output_buffer - Pointer to the user's return buffer |
| 442 | * bytes_consumed - u32 pointer that is filled with |
| 443 | * the number of bytes of the |
| 444 | * output_buffer used |
| 445 | * |
| 446 | * RETURN: Status |
| 447 | * |
| 448 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 449 | * the appropriate bytes in a byte stream |
| 450 | * |
| 451 | ******************************************************************************/ |
| 452 | |
| 453 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 454 | acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list, |
| 455 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 457 | u8 *buffer = *output_buffer; |
| 458 | u8 temp8 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 460 | ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | /* |
| 463 | * The descriptor field is set based upon whether a byte is needed |
| 464 | * to contain Priority data. |
| 465 | */ |
| 466 | if (ACPI_ACCEPTABLE_CONFIGURATION == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 467 | linked_list->data.start_dpf.compatibility_priority && |
| 468 | ACPI_ACCEPTABLE_CONFIGURATION == |
| 469 | linked_list->data.start_dpf.performance_robustness) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | *buffer = 0x30; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 471 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | *buffer = 0x31; |
| 473 | buffer += 1; |
| 474 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 475 | /* Set the Priority Byte Definition */ |
| 476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | temp8 = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 478 | temp8 = |
| 479 | (u8) ((linked_list->data.start_dpf. |
| 480 | performance_robustness & 0x03) << 2); |
| 481 | temp8 |= |
| 482 | (linked_list->data.start_dpf.compatibility_priority & 0x03); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | *buffer = temp8; |
| 484 | } |
| 485 | |
| 486 | buffer += 1; |
| 487 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 488 | /* Return the number of bytes consumed in this operation */ |
| 489 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 490 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 491 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | /******************************************************************************* |
| 495 | * |
| 496 | * FUNCTION: acpi_rs_end_depend_fns_stream |
| 497 | * |
| 498 | * PARAMETERS: linked_list - Pointer to the resource linked list |
| 499 | * output_buffer - Pointer to the user's return buffer |
| 500 | * bytes_consumed - Pointer to where the number of bytes |
| 501 | * used in the output_buffer is returned |
| 502 | * |
| 503 | * RETURN: Status |
| 504 | * |
| 505 | * DESCRIPTION: Take the linked list resource structure and fills in the |
| 506 | * the appropriate bytes in a byte stream |
| 507 | * |
| 508 | ******************************************************************************/ |
| 509 | |
| 510 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 511 | acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list, |
| 512 | u8 ** output_buffer, acpi_size * bytes_consumed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 514 | u8 *buffer = *output_buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 516 | ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 518 | /* The descriptor field is static */ |
| 519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | *buffer = 0x38; |
| 521 | buffer += 1; |
| 522 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 523 | /* Return the number of bytes consumed in this operation */ |
| 524 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 525 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); |
| 526 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | } |