Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
Joe Perches | 3c5f9be | 2008-02-03 17:06:17 +0200 | [diff] [blame] | 3 | * Module Name: utresrc - Resource management utilities |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 25f044e | 2013-01-25 05:38:56 +0000 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2013, Intel Corp. |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 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 | |
| 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 46 | #include "acresrc.h" |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 47 | |
| 48 | #define _COMPONENT ACPI_UTILITIES |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("utresrc") |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 50 | #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) |
| 51 | /* |
| 52 | * Strings used to decode resource descriptors. |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 53 | * Used by both the disassembler and the debugger resource dump routines |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 54 | */ |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 55 | const char *acpi_gbl_bm_decode[] = { |
| 56 | "NotBusMaster", |
| 57 | "BusMaster" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 58 | }; |
| 59 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 60 | const char *acpi_gbl_config_decode[] = { |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 61 | "0 - Good Configuration", |
| 62 | "1 - Acceptable Configuration", |
| 63 | "2 - Suboptimal Configuration", |
| 64 | "3 - ***Invalid Configuration***", |
| 65 | }; |
| 66 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 67 | const char *acpi_gbl_consume_decode[] = { |
| 68 | "ResourceProducer", |
| 69 | "ResourceConsumer" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 70 | }; |
| 71 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 72 | const char *acpi_gbl_dec_decode[] = { |
| 73 | "PosDecode", |
| 74 | "SubDecode" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 75 | }; |
| 76 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 77 | const char *acpi_gbl_he_decode[] = { |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 78 | "Level", |
| 79 | "Edge" |
| 80 | }; |
| 81 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 82 | const char *acpi_gbl_io_decode[] = { |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 83 | "Decode10", |
| 84 | "Decode16" |
| 85 | }; |
| 86 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 87 | const char *acpi_gbl_ll_decode[] = { |
| 88 | "ActiveHigh", |
| 89 | "ActiveLow" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 90 | }; |
| 91 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 92 | const char *acpi_gbl_max_decode[] = { |
| 93 | "MaxNotFixed", |
| 94 | "MaxFixed" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 95 | }; |
| 96 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 97 | const char *acpi_gbl_mem_decode[] = { |
| 98 | "NonCacheable", |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 99 | "Cacheable", |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 100 | "WriteCombining", |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 101 | "Prefetchable" |
| 102 | }; |
| 103 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 104 | const char *acpi_gbl_min_decode[] = { |
| 105 | "MinNotFixed", |
| 106 | "MinFixed" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 107 | }; |
| 108 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 109 | const char *acpi_gbl_mtp_decode[] = { |
| 110 | "AddressRangeMemory", |
| 111 | "AddressRangeReserved", |
| 112 | "AddressRangeACPI", |
| 113 | "AddressRangeNVS" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 114 | }; |
| 115 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 116 | const char *acpi_gbl_rng_decode[] = { |
| 117 | "InvalidRanges", |
| 118 | "NonISAOnlyRanges", |
| 119 | "ISAOnlyRanges", |
| 120 | "EntireRange" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 121 | }; |
| 122 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 123 | const char *acpi_gbl_rw_decode[] = { |
| 124 | "ReadOnly", |
| 125 | "ReadWrite" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 126 | }; |
| 127 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 128 | const char *acpi_gbl_shr_decode[] = { |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 129 | "Exclusive", |
Bob Moore | 1f06c92 | 2012-12-19 05:38:12 +0000 | [diff] [blame] | 130 | "Shared", |
| 131 | "ExclusiveAndWake", /* ACPI 5.0 */ |
| 132 | "SharedAndWake" /* ACPI 5.0 */ |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 133 | }; |
| 134 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 135 | const char *acpi_gbl_siz_decode[] = { |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 136 | "Transfer8", |
| 137 | "Transfer8_16", |
| 138 | "Transfer16", |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 139 | "InvalidSize" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 140 | }; |
| 141 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 142 | const char *acpi_gbl_trs_decode[] = { |
| 143 | "DenseTranslation", |
| 144 | "SparseTranslation" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 145 | }; |
| 146 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 147 | const char *acpi_gbl_ttp_decode[] = { |
| 148 | "TypeStatic", |
| 149 | "TypeTranslation" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 150 | }; |
| 151 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 152 | const char *acpi_gbl_typ_decode[] = { |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 153 | "Compatibility", |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 154 | "TypeA", |
| 155 | "TypeB", |
| 156 | "TypeF" |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 157 | }; |
| 158 | |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 159 | const char *acpi_gbl_ppc_decode[] = { |
| 160 | "PullDefault", |
| 161 | "PullUp", |
| 162 | "PullDown", |
| 163 | "PullNone" |
| 164 | }; |
| 165 | |
| 166 | const char *acpi_gbl_ior_decode[] = { |
| 167 | "IoRestrictionNone", |
| 168 | "IoRestrictionInputOnly", |
| 169 | "IoRestrictionOutputOnly", |
| 170 | "IoRestrictionNoneAndPreserve" |
| 171 | }; |
| 172 | |
| 173 | const char *acpi_gbl_dts_decode[] = { |
| 174 | "Width8bit", |
| 175 | "Width16bit", |
| 176 | "Width32bit", |
| 177 | "Width64bit", |
| 178 | "Width128bit", |
| 179 | "Width256bit", |
| 180 | }; |
| 181 | |
| 182 | /* GPIO connection type */ |
| 183 | |
| 184 | const char *acpi_gbl_ct_decode[] = { |
| 185 | "Interrupt", |
| 186 | "I/O" |
| 187 | }; |
| 188 | |
| 189 | /* Serial bus type */ |
| 190 | |
| 191 | const char *acpi_gbl_sbt_decode[] = { |
| 192 | "/* UNKNOWN serial bus type */", |
| 193 | "I2C", |
| 194 | "SPI", |
| 195 | "UART" |
| 196 | }; |
| 197 | |
| 198 | /* I2C serial bus access mode */ |
| 199 | |
| 200 | const char *acpi_gbl_am_decode[] = { |
| 201 | "AddressingMode7Bit", |
| 202 | "AddressingMode10Bit" |
| 203 | }; |
| 204 | |
| 205 | /* I2C serial bus slave mode */ |
| 206 | |
| 207 | const char *acpi_gbl_sm_decode[] = { |
| 208 | "ControllerInitiated", |
| 209 | "DeviceInitiated" |
| 210 | }; |
| 211 | |
| 212 | /* SPI serial bus wire mode */ |
| 213 | |
| 214 | const char *acpi_gbl_wm_decode[] = { |
| 215 | "FourWireMode", |
| 216 | "ThreeWireMode" |
| 217 | }; |
| 218 | |
| 219 | /* SPI serial clock phase */ |
| 220 | |
| 221 | const char *acpi_gbl_cph_decode[] = { |
| 222 | "ClockPhaseFirst", |
| 223 | "ClockPhaseSecond" |
| 224 | }; |
| 225 | |
| 226 | /* SPI serial bus clock polarity */ |
| 227 | |
| 228 | const char *acpi_gbl_cpo_decode[] = { |
| 229 | "ClockPolarityLow", |
| 230 | "ClockPolarityHigh" |
| 231 | }; |
| 232 | |
| 233 | /* SPI serial bus device polarity */ |
| 234 | |
| 235 | const char *acpi_gbl_dp_decode[] = { |
| 236 | "PolarityLow", |
| 237 | "PolarityHigh" |
| 238 | }; |
| 239 | |
| 240 | /* UART serial bus endian */ |
| 241 | |
| 242 | const char *acpi_gbl_ed_decode[] = { |
| 243 | "LittleEndian", |
| 244 | "BigEndian" |
| 245 | }; |
| 246 | |
| 247 | /* UART serial bus bits per byte */ |
| 248 | |
| 249 | const char *acpi_gbl_bpb_decode[] = { |
| 250 | "DataBitsFive", |
| 251 | "DataBitsSix", |
| 252 | "DataBitsSeven", |
| 253 | "DataBitsEight", |
| 254 | "DataBitsNine", |
| 255 | "/* UNKNOWN Bits per byte */", |
| 256 | "/* UNKNOWN Bits per byte */", |
| 257 | "/* UNKNOWN Bits per byte */" |
| 258 | }; |
| 259 | |
| 260 | /* UART serial bus stop bits */ |
| 261 | |
| 262 | const char *acpi_gbl_sb_decode[] = { |
| 263 | "StopBitsNone", |
| 264 | "StopBitsOne", |
| 265 | "StopBitsOnePlusHalf", |
| 266 | "StopBitsTwo" |
| 267 | }; |
| 268 | |
| 269 | /* UART serial bus flow control */ |
| 270 | |
| 271 | const char *acpi_gbl_fc_decode[] = { |
| 272 | "FlowControlNone", |
| 273 | "FlowControlHardware", |
| 274 | "FlowControlXON", |
| 275 | "/* UNKNOWN flow control keyword */" |
| 276 | }; |
| 277 | |
| 278 | /* UART serial bus parity type */ |
| 279 | |
| 280 | const char *acpi_gbl_pt_decode[] = { |
| 281 | "ParityTypeNone", |
| 282 | "ParityTypeEven", |
| 283 | "ParityTypeOdd", |
| 284 | "ParityTypeMark", |
| 285 | "ParityTypeSpace", |
| 286 | "/* UNKNOWN parity keyword */", |
| 287 | "/* UNKNOWN parity keyword */", |
| 288 | "/* UNKNOWN parity keyword */" |
| 289 | }; |
| 290 | |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 291 | #endif |
| 292 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 293 | /* |
| 294 | * Base sizes of the raw AML resource descriptors, indexed by resource type. |
| 295 | * Zero indicates a reserved (and therefore invalid) resource type. |
| 296 | */ |
| 297 | const u8 acpi_gbl_resource_aml_sizes[] = { |
| 298 | /* Small descriptors */ |
| 299 | |
| 300 | 0, |
| 301 | 0, |
| 302 | 0, |
| 303 | 0, |
| 304 | ACPI_AML_SIZE_SMALL(struct aml_resource_irq), |
| 305 | ACPI_AML_SIZE_SMALL(struct aml_resource_dma), |
| 306 | ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent), |
| 307 | ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), |
| 308 | ACPI_AML_SIZE_SMALL(struct aml_resource_io), |
| 309 | ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 310 | ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_dma), |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 311 | 0, |
| 312 | 0, |
| 313 | 0, |
| 314 | ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small), |
| 315 | ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag), |
| 316 | |
| 317 | /* Large descriptors */ |
| 318 | |
| 319 | 0, |
| 320 | ACPI_AML_SIZE_LARGE(struct aml_resource_memory24), |
| 321 | ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register), |
| 322 | 0, |
| 323 | ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large), |
| 324 | ACPI_AML_SIZE_LARGE(struct aml_resource_memory32), |
| 325 | ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32), |
| 326 | ACPI_AML_SIZE_LARGE(struct aml_resource_address32), |
| 327 | ACPI_AML_SIZE_LARGE(struct aml_resource_address16), |
| 328 | ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), |
| 329 | ACPI_AML_SIZE_LARGE(struct aml_resource_address64), |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 330 | ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64), |
| 331 | ACPI_AML_SIZE_LARGE(struct aml_resource_gpio), |
| 332 | 0, |
| 333 | ACPI_AML_SIZE_LARGE(struct aml_resource_common_serialbus), |
| 334 | }; |
| 335 | |
| 336 | const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = { |
| 337 | 0, |
| 338 | ACPI_AML_SIZE_LARGE(struct aml_resource_i2c_serialbus), |
| 339 | ACPI_AML_SIZE_LARGE(struct aml_resource_spi_serialbus), |
| 340 | ACPI_AML_SIZE_LARGE(struct aml_resource_uart_serialbus), |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | /* |
| 344 | * Resource types, used to validate the resource length field. |
| 345 | * The length of fixed-length types must match exactly, variable |
| 346 | * lengths must meet the minimum required length, etc. |
| 347 | * Zero indicates a reserved (and therefore invalid) resource type. |
| 348 | */ |
| 349 | static const u8 acpi_gbl_resource_types[] = { |
| 350 | /* Small descriptors */ |
| 351 | |
| 352 | 0, |
| 353 | 0, |
| 354 | 0, |
| 355 | 0, |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 356 | ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */ |
| 357 | ACPI_FIXED_LENGTH, /* 05 DMA */ |
| 358 | ACPI_SMALL_VARIABLE_LENGTH, /* 06 start_dependent_functions */ |
| 359 | ACPI_FIXED_LENGTH, /* 07 end_dependent_functions */ |
| 360 | ACPI_FIXED_LENGTH, /* 08 IO */ |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 361 | ACPI_FIXED_LENGTH, /* 09 fixed_IO */ |
| 362 | ACPI_FIXED_LENGTH, /* 0A fixed_DMA */ |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 363 | 0, |
| 364 | 0, |
| 365 | 0, |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 366 | ACPI_VARIABLE_LENGTH, /* 0E vendor_short */ |
| 367 | ACPI_FIXED_LENGTH, /* 0F end_tag */ |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 368 | |
| 369 | /* Large descriptors */ |
| 370 | |
| 371 | 0, |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 372 | ACPI_FIXED_LENGTH, /* 01 Memory24 */ |
| 373 | ACPI_FIXED_LENGTH, /* 02 generic_register */ |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 374 | 0, |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 375 | ACPI_VARIABLE_LENGTH, /* 04 vendor_long */ |
| 376 | ACPI_FIXED_LENGTH, /* 05 Memory32 */ |
| 377 | ACPI_FIXED_LENGTH, /* 06 memory32_fixed */ |
| 378 | ACPI_VARIABLE_LENGTH, /* 07 Dword* address */ |
| 379 | ACPI_VARIABLE_LENGTH, /* 08 Word* address */ |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 380 | ACPI_VARIABLE_LENGTH, /* 09 extended_IRQ */ |
| 381 | ACPI_VARIABLE_LENGTH, /* 0A Qword* address */ |
| 382 | ACPI_FIXED_LENGTH, /* 0B Extended* address */ |
| 383 | ACPI_VARIABLE_LENGTH, /* 0C Gpio* */ |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 384 | 0, |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 385 | ACPI_VARIABLE_LENGTH /* 0E *serial_bus */ |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 386 | }; |
| 387 | |
| 388 | /******************************************************************************* |
| 389 | * |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 390 | * FUNCTION: acpi_ut_walk_aml_resources |
| 391 | * |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 392 | * PARAMETERS: walk_state - Current walk info |
| 393 | * PARAMETERS: aml - Pointer to the raw AML resource template |
| 394 | * aml_length - Length of the entire template |
| 395 | * user_function - Called once for each descriptor found. If |
| 396 | * NULL, a pointer to the end_tag is returned |
| 397 | * context - Passed to user_function |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 398 | * |
| 399 | * RETURN: Status |
| 400 | * |
| 401 | * DESCRIPTION: Walk a raw AML resource list(buffer). User function called |
| 402 | * once for each resource found. |
| 403 | * |
| 404 | ******************************************************************************/ |
| 405 | |
| 406 | acpi_status |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 407 | acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, |
| 408 | u8 *aml, |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 409 | acpi_size aml_length, |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 410 | acpi_walk_aml_callback user_function, void **context) |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 411 | { |
| 412 | acpi_status status; |
| 413 | u8 *end_aml; |
| 414 | u8 resource_index; |
| 415 | u32 length; |
| 416 | u32 offset = 0; |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 417 | u8 end_tag[2] = { 0x79, 0x00 }; |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 418 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 419 | ACPI_FUNCTION_TRACE(ut_walk_aml_resources); |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 420 | |
| 421 | /* The absolute minimum resource template is one end_tag descriptor */ |
| 422 | |
| 423 | if (aml_length < sizeof(struct aml_resource_end_tag)) { |
| 424 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
| 425 | } |
| 426 | |
| 427 | /* Point to the end of the resource template buffer */ |
| 428 | |
| 429 | end_aml = aml + aml_length; |
| 430 | |
| 431 | /* Walk the byte list, abort on any invalid descriptor type or length */ |
| 432 | |
| 433 | while (aml < end_aml) { |
| 434 | |
| 435 | /* Validate the Resource Type and Resource Length */ |
| 436 | |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 437 | status = |
| 438 | acpi_ut_validate_resource(walk_state, aml, &resource_index); |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 439 | if (ACPI_FAILURE(status)) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 440 | /* |
| 441 | * Exit on failure. Cannot continue because the descriptor length |
| 442 | * may be bogus also. |
| 443 | */ |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 444 | return_ACPI_STATUS(status); |
| 445 | } |
| 446 | |
| 447 | /* Get the length of this descriptor */ |
| 448 | |
| 449 | length = acpi_ut_get_descriptor_length(aml); |
| 450 | |
| 451 | /* Invoke the user function */ |
| 452 | |
| 453 | if (user_function) { |
| 454 | status = |
| 455 | user_function(aml, length, offset, resource_index, |
| 456 | context); |
| 457 | if (ACPI_FAILURE(status)) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 458 | return_ACPI_STATUS(status); |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | |
| 462 | /* An end_tag descriptor terminates this resource template */ |
| 463 | |
| 464 | if (acpi_ut_get_resource_type(aml) == |
| 465 | ACPI_RESOURCE_NAME_END_TAG) { |
| 466 | /* |
| 467 | * There must be at least one more byte in the buffer for |
| 468 | * the 2nd byte of the end_tag |
| 469 | */ |
| 470 | if ((aml + 1) >= end_aml) { |
| 471 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
| 472 | } |
| 473 | |
| 474 | /* Return the pointer to the end_tag if requested */ |
| 475 | |
| 476 | if (!user_function) { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 477 | *context = aml; |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | /* Normal exit */ |
| 481 | |
| 482 | return_ACPI_STATUS(AE_OK); |
| 483 | } |
| 484 | |
| 485 | aml += length; |
| 486 | offset += length; |
| 487 | } |
| 488 | |
| 489 | /* Did not find an end_tag descriptor */ |
| 490 | |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 491 | if (user_function) { |
| 492 | |
| 493 | /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */ |
| 494 | |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 495 | (void)acpi_ut_validate_resource(walk_state, end_tag, |
| 496 | &resource_index); |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 497 | status = |
| 498 | user_function(end_tag, 2, offset, resource_index, context); |
| 499 | if (ACPI_FAILURE(status)) { |
| 500 | return_ACPI_STATUS(status); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | /******************************************************************************* |
| 508 | * |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 509 | * FUNCTION: acpi_ut_validate_resource |
| 510 | * |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 511 | * PARAMETERS: walk_state - Current walk info |
| 512 | * aml - Pointer to the raw AML resource descriptor |
| 513 | * return_index - Where the resource index is returned. NULL |
| 514 | * if the index is not required. |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 515 | * |
| 516 | * RETURN: Status, and optionally the Index into the global resource tables |
| 517 | * |
| 518 | * DESCRIPTION: Validate an AML resource descriptor by checking the Resource |
| 519 | * Type and Resource Length. Returns an index into the global |
| 520 | * resource information/dispatch tables for later use. |
| 521 | * |
| 522 | ******************************************************************************/ |
| 523 | |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 524 | acpi_status |
| 525 | acpi_ut_validate_resource(struct acpi_walk_state *walk_state, |
| 526 | void *aml, u8 *return_index) |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 527 | { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 528 | union aml_resource *aml_resource; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 529 | u8 resource_type; |
| 530 | u8 resource_index; |
| 531 | acpi_rs_length resource_length; |
| 532 | acpi_rs_length minimum_resource_length; |
| 533 | |
| 534 | ACPI_FUNCTION_ENTRY(); |
| 535 | |
| 536 | /* |
| 537 | * 1) Validate the resource_type field (Byte 0) |
| 538 | */ |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 539 | resource_type = ACPI_GET8(aml); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 540 | |
| 541 | /* |
| 542 | * Byte 0 contains the descriptor name (Resource Type) |
| 543 | * Examine the large/small bit in the resource header |
| 544 | */ |
| 545 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 546 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 547 | /* Verify the large resource type (name) against the max */ |
| 548 | |
| 549 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 550 | goto invalid_resource; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | /* |
| 554 | * Large Resource Type -- bits 6:0 contain the name |
| 555 | * Translate range 0x80-0x8B to index range 0x10-0x1B |
| 556 | */ |
| 557 | resource_index = (u8) (resource_type - 0x70); |
| 558 | } else { |
| 559 | /* |
| 560 | * Small Resource Type -- bits 6:3 contain the name |
| 561 | * Shift range to index range 0x00-0x0F |
| 562 | */ |
| 563 | resource_index = (u8) |
| 564 | ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); |
| 565 | } |
| 566 | |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 567 | /* |
| 568 | * Check validity of the resource type, via acpi_gbl_resource_types. Zero |
| 569 | * indicates an invalid resource. |
| 570 | */ |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 571 | if (!acpi_gbl_resource_types[resource_index]) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 572 | goto invalid_resource; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | /* |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 576 | * Validate the resource_length field. This ensures that the length |
| 577 | * is at least reasonable, and guarantees that it is non-zero. |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 578 | */ |
| 579 | resource_length = acpi_ut_get_resource_length(aml); |
| 580 | minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; |
| 581 | |
| 582 | /* Validate based upon the type of resource - fixed length or variable */ |
| 583 | |
| 584 | switch (acpi_gbl_resource_types[resource_index]) { |
| 585 | case ACPI_FIXED_LENGTH: |
| 586 | |
| 587 | /* Fixed length resource, length must match exactly */ |
| 588 | |
| 589 | if (resource_length != minimum_resource_length) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 590 | goto bad_resource_length; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 591 | } |
| 592 | break; |
| 593 | |
| 594 | case ACPI_VARIABLE_LENGTH: |
| 595 | |
| 596 | /* Variable length resource, length must be at least the minimum */ |
| 597 | |
| 598 | if (resource_length < minimum_resource_length) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 599 | goto bad_resource_length; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 600 | } |
| 601 | break; |
| 602 | |
| 603 | case ACPI_SMALL_VARIABLE_LENGTH: |
| 604 | |
| 605 | /* Small variable length resource, length can be (Min) or (Min-1) */ |
| 606 | |
| 607 | if ((resource_length > minimum_resource_length) || |
| 608 | (resource_length < (minimum_resource_length - 1))) { |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 609 | goto bad_resource_length; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 610 | } |
| 611 | break; |
| 612 | |
| 613 | default: |
| 614 | |
| 615 | /* Shouldn't happen (because of validation earlier), but be sure */ |
| 616 | |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 617 | goto invalid_resource; |
| 618 | } |
| 619 | |
| 620 | aml_resource = ACPI_CAST_PTR(union aml_resource, aml); |
| 621 | if (resource_type == ACPI_RESOURCE_NAME_SERIAL_BUS) { |
| 622 | |
| 623 | /* Validate the bus_type field */ |
| 624 | |
| 625 | if ((aml_resource->common_serial_bus.type == 0) || |
| 626 | (aml_resource->common_serial_bus.type > |
| 627 | AML_RESOURCE_MAX_SERIALBUSTYPE)) { |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 628 | if (walk_state) { |
| 629 | ACPI_ERROR((AE_INFO, |
| 630 | "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", |
| 631 | aml_resource->common_serial_bus. |
| 632 | type)); |
| 633 | } |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 634 | return (AE_AML_INVALID_RESOURCE_TYPE); |
| 635 | } |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | /* Optionally return the resource table index */ |
| 639 | |
| 640 | if (return_index) { |
| 641 | *return_index = resource_index; |
| 642 | } |
| 643 | |
| 644 | return (AE_OK); |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 645 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 646 | invalid_resource: |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 647 | |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 648 | if (walk_state) { |
| 649 | ACPI_ERROR((AE_INFO, |
| 650 | "Invalid/unsupported resource descriptor: Type 0x%2.2X", |
| 651 | resource_type)); |
| 652 | } |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 653 | return (AE_AML_INVALID_RESOURCE_TYPE); |
| 654 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 655 | bad_resource_length: |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 656 | |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 657 | if (walk_state) { |
| 658 | ACPI_ERROR((AE_INFO, |
| 659 | "Invalid resource descriptor length: Type " |
| 660 | "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X", |
| 661 | resource_type, resource_length, |
| 662 | minimum_resource_length)); |
| 663 | } |
Lin Ming | e0fe0a8 | 2011-11-16 14:38:13 +0800 | [diff] [blame] | 664 | return (AE_AML_BAD_RESOURCE_LENGTH); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | /******************************************************************************* |
| 668 | * |
| 669 | * FUNCTION: acpi_ut_get_resource_type |
| 670 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 671 | * PARAMETERS: aml - Pointer to the raw AML resource descriptor |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 672 | * |
| 673 | * RETURN: The Resource Type with no extraneous bits (except the |
| 674 | * Large/Small descriptor bit -- this is left alone) |
| 675 | * |
| 676 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of |
| 677 | * a resource descriptor. |
| 678 | * |
| 679 | ******************************************************************************/ |
| 680 | |
| 681 | u8 acpi_ut_get_resource_type(void *aml) |
| 682 | { |
| 683 | ACPI_FUNCTION_ENTRY(); |
| 684 | |
| 685 | /* |
| 686 | * Byte 0 contains the descriptor name (Resource Type) |
| 687 | * Examine the large/small bit in the resource header |
| 688 | */ |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 689 | if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 690 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 691 | /* Large Resource Type -- bits 6:0 contain the name */ |
| 692 | |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 693 | return (ACPI_GET8(aml)); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 694 | } else { |
| 695 | /* Small Resource Type -- bits 6:3 contain the name */ |
| 696 | |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 697 | return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 698 | } |
| 699 | } |
| 700 | |
| 701 | /******************************************************************************* |
| 702 | * |
| 703 | * FUNCTION: acpi_ut_get_resource_length |
| 704 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 705 | * PARAMETERS: aml - Pointer to the raw AML resource descriptor |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 706 | * |
| 707 | * RETURN: Byte Length |
| 708 | * |
| 709 | * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By |
| 710 | * definition, this does not include the size of the descriptor |
| 711 | * header or the length field itself. |
| 712 | * |
| 713 | ******************************************************************************/ |
| 714 | |
| 715 | u16 acpi_ut_get_resource_length(void *aml) |
| 716 | { |
| 717 | acpi_rs_length resource_length; |
| 718 | |
| 719 | ACPI_FUNCTION_ENTRY(); |
| 720 | |
| 721 | /* |
| 722 | * Byte 0 contains the descriptor name (Resource Type) |
| 723 | * Examine the large/small bit in the resource header |
| 724 | */ |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 725 | if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 726 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 727 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ |
| 728 | |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 729 | ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1)); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 730 | |
| 731 | } else { |
| 732 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ |
| 733 | |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 734 | resource_length = (u16) (ACPI_GET8(aml) & |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 735 | ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); |
| 736 | } |
| 737 | |
| 738 | return (resource_length); |
| 739 | } |
| 740 | |
| 741 | /******************************************************************************* |
| 742 | * |
| 743 | * FUNCTION: acpi_ut_get_resource_header_length |
| 744 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 745 | * PARAMETERS: aml - Pointer to the raw AML resource descriptor |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 746 | * |
| 747 | * RETURN: Length of the AML header (depends on large/small descriptor) |
| 748 | * |
| 749 | * DESCRIPTION: Get the length of the header for this resource. |
| 750 | * |
| 751 | ******************************************************************************/ |
| 752 | |
| 753 | u8 acpi_ut_get_resource_header_length(void *aml) |
| 754 | { |
| 755 | ACPI_FUNCTION_ENTRY(); |
| 756 | |
| 757 | /* Examine the large/small bit in the resource header */ |
| 758 | |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 759 | if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 760 | return (sizeof(struct aml_resource_large_header)); |
| 761 | } else { |
| 762 | return (sizeof(struct aml_resource_small_header)); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | /******************************************************************************* |
| 767 | * |
| 768 | * FUNCTION: acpi_ut_get_descriptor_length |
| 769 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 770 | * PARAMETERS: aml - Pointer to the raw AML resource descriptor |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 771 | * |
| 772 | * RETURN: Byte length |
| 773 | * |
| 774 | * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the |
| 775 | * length of the descriptor header and the length field itself. |
| 776 | * Used to walk descriptor lists. |
| 777 | * |
| 778 | ******************************************************************************/ |
| 779 | |
| 780 | u32 acpi_ut_get_descriptor_length(void *aml) |
| 781 | { |
| 782 | ACPI_FUNCTION_ENTRY(); |
| 783 | |
| 784 | /* |
| 785 | * Get the Resource Length (does not include header length) and add |
| 786 | * the header length (depends on if this is a small or large resource) |
| 787 | */ |
| 788 | return (acpi_ut_get_resource_length(aml) + |
| 789 | acpi_ut_get_resource_header_length(aml)); |
| 790 | } |
| 791 | |
| 792 | /******************************************************************************* |
| 793 | * |
| 794 | * FUNCTION: acpi_ut_get_resource_end_tag |
| 795 | * |
| 796 | * PARAMETERS: obj_desc - The resource template buffer object |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 797 | * end_tag - Where the pointer to the end_tag is returned |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 798 | * |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 799 | * RETURN: Status, pointer to the end tag |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 800 | * |
| 801 | * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 802 | * Note: allows a buffer length of zero. |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 803 | * |
| 804 | ******************************************************************************/ |
| 805 | |
| 806 | acpi_status |
Lv Zheng | 3e8214e | 2012-12-19 05:37:15 +0000 | [diff] [blame] | 807 | acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag) |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 808 | { |
| 809 | acpi_status status; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 810 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 811 | ACPI_FUNCTION_TRACE(ut_get_resource_end_tag); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 812 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 813 | /* Allow a buffer length of zero */ |
| 814 | |
| 815 | if (!obj_desc->buffer.length) { |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 816 | *end_tag = obj_desc->buffer.pointer; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 817 | return_ACPI_STATUS(AE_OK); |
| 818 | } |
| 819 | |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 820 | /* Validate the template and get a pointer to the end_tag */ |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 821 | |
Bob Moore | 886308e | 2012-12-19 05:38:07 +0000 | [diff] [blame] | 822 | status = acpi_ut_walk_aml_resources(NULL, obj_desc->buffer.pointer, |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 823 | obj_desc->buffer.length, NULL, |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 824 | (void **)end_tag); |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 825 | |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 826 | return_ACPI_STATUS(status); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 827 | } |