1 1.1 jruoho /****************************************************************************** 2 1.1 jruoho * 3 1.1 jruoho * Module Name: aslresource - Resource template/descriptor utilities 4 1.1 jruoho * 5 1.1 jruoho *****************************************************************************/ 6 1.1 jruoho 7 1.1.1.19 christos /****************************************************************************** 8 1.1.1.19 christos * 9 1.1.1.19 christos * 1. Copyright Notice 10 1.1.1.19 christos * 11 1.1.1.20 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 12 1.1 jruoho * All rights reserved. 13 1.1 jruoho * 14 1.1.1.19 christos * 2. License 15 1.1.1.19 christos * 16 1.1.1.19 christos * 2.1. This is your license from Intel Corp. under its intellectual property 17 1.1.1.19 christos * rights. You may have additional license terms from the party that provided 18 1.1.1.19 christos * you this software, covering your right to use that party's intellectual 19 1.1.1.19 christos * property rights. 20 1.1.1.19 christos * 21 1.1.1.19 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 1.1.1.19 christos * copy of the source code appearing in this file ("Covered Code") an 23 1.1.1.19 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 1.1.1.19 christos * base code distributed originally by Intel ("Original Intel Code") to copy, 25 1.1.1.19 christos * make derivatives, distribute, use and display any portion of the Covered 26 1.1.1.19 christos * Code in any form, with the right to sublicense such rights; and 27 1.1.1.19 christos * 28 1.1.1.19 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 1.1.1.19 christos * license (with the right to sublicense), under only those claims of Intel 30 1.1.1.19 christos * patents that are infringed by the Original Intel Code, to make, use, sell, 31 1.1.1.19 christos * offer to sell, and import the Covered Code and derivative works thereof 32 1.1.1.19 christos * solely to the minimum extent necessary to exercise the above copyright 33 1.1.1.19 christos * license, and in no event shall the patent license extend to any additions 34 1.1.1.19 christos * to or modifications of the Original Intel Code. No other license or right 35 1.1.1.19 christos * is granted directly or by implication, estoppel or otherwise; 36 1.1.1.19 christos * 37 1.1.1.19 christos * The above copyright and patent license is granted only if the following 38 1.1.1.19 christos * conditions are met: 39 1.1.1.19 christos * 40 1.1.1.19 christos * 3. Conditions 41 1.1.1.19 christos * 42 1.1.1.19 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 1.1.1.19 christos * Redistribution of source code of any substantial portion of the Covered 44 1.1.1.19 christos * Code or modification with rights to further distribute source must include 45 1.1.1.19 christos * the above Copyright Notice, the above License, this list of Conditions, 46 1.1.1.19 christos * and the following Disclaimer and Export Compliance provision. In addition, 47 1.1.1.19 christos * Licensee must cause all Covered Code to which Licensee contributes to 48 1.1.1.19 christos * contain a file documenting the changes Licensee made to create that Covered 49 1.1.1.19 christos * Code and the date of any change. Licensee must include in that file the 50 1.1.1.19 christos * documentation of any changes made by any predecessor Licensee. Licensee 51 1.1.1.19 christos * must include a prominent statement that the modification is derived, 52 1.1.1.19 christos * directly or indirectly, from Original Intel Code. 53 1.1.1.19 christos * 54 1.1.1.19 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 1.1.1.19 christos * Redistribution of source code of any substantial portion of the Covered 56 1.1.1.19 christos * Code or modification without rights to further distribute source must 57 1.1.1.19 christos * include the following Disclaimer and Export Compliance provision in the 58 1.1.1.19 christos * documentation and/or other materials provided with distribution. In 59 1.1.1.19 christos * addition, Licensee may not authorize further sublicense of source of any 60 1.1.1.19 christos * portion of the Covered Code, and must include terms to the effect that the 61 1.1.1.19 christos * license from Licensee to its licensee is limited to the intellectual 62 1.1.1.19 christos * property embodied in the software Licensee provides to its licensee, and 63 1.1.1.19 christos * not to intellectual property embodied in modifications its licensee may 64 1.1.1.19 christos * make. 65 1.1.1.19 christos * 66 1.1.1.19 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 1.1.1.19 christos * substantial portion of the Covered Code or modification must reproduce the 68 1.1.1.19 christos * above Copyright Notice, and the following Disclaimer and Export Compliance 69 1.1.1.19 christos * provision in the documentation and/or other materials provided with the 70 1.1.1.19 christos * distribution. 71 1.1.1.19 christos * 72 1.1.1.19 christos * 3.4. Intel retains all right, title, and interest in and to the Original 73 1.1.1.19 christos * Intel Code. 74 1.1.1.19 christos * 75 1.1.1.19 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 1.1.1.19 christos * Intel shall be used in advertising or otherwise to promote the sale, use or 77 1.1.1.19 christos * other dealings in products derived from or relating to the Covered Code 78 1.1.1.19 christos * without prior written authorization from Intel. 79 1.1.1.19 christos * 80 1.1.1.19 christos * 4. Disclaimer and Export Compliance 81 1.1.1.19 christos * 82 1.1.1.19 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 1.1.1.19 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 1.1.1.19 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 1.1.1.19 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 1.1.1.19 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 1.1.1.19 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 1.1.1.19 christos * PARTICULAR PURPOSE. 89 1.1.1.19 christos * 90 1.1.1.19 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 1.1.1.19 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 1.1.1.19 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 1.1.1.19 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 1.1.1.19 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 1.1.1.19 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 1.1.1.19 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 1.1.1.19 christos * LIMITED REMEDY. 98 1.1.1.19 christos * 99 1.1.1.19 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 1.1.1.19 christos * software or system incorporating such software without first obtaining any 101 1.1.1.19 christos * required license or other approval from the U. S. Department of Commerce or 102 1.1.1.19 christos * any other agency or department of the United States Government. In the 103 1.1.1.19 christos * event Licensee exports any such software from the United States or 104 1.1.1.19 christos * re-exports any such software from a foreign destination, Licensee shall 105 1.1.1.19 christos * ensure that the distribution and export/re-export of the software is in 106 1.1.1.19 christos * compliance with all laws, regulations, orders, or other restrictions of the 107 1.1.1.19 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 1.1.1.19 christos * any of its subsidiaries will export/re-export any technical data, process, 109 1.1.1.19 christos * software, or service, directly or indirectly, to any country for which the 110 1.1.1.19 christos * United States government or any agency thereof requires an export license, 111 1.1.1.19 christos * other governmental approval, or letter of assurance, without first obtaining 112 1.1.1.19 christos * such license, approval or letter. 113 1.1.1.19 christos * 114 1.1.1.19 christos ***************************************************************************** 115 1.1.1.19 christos * 116 1.1.1.19 christos * Alternatively, you may choose to be licensed under the terms of the 117 1.1.1.19 christos * following license: 118 1.1.1.19 christos * 119 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without 120 1.1.1.2 jruoho * modification, are permitted provided that the following conditions 121 1.1.1.2 jruoho * are met: 122 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright 123 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer, 124 1.1.1.2 jruoho * without modification. 125 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below 127 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon 128 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further 129 1.1.1.2 jruoho * binary redistribution. 130 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names 131 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived 132 1.1.1.2 jruoho * from this software without specific prior written permission. 133 1.1.1.2 jruoho * 134 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 1.1.1.15 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 1.1.1.19 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 1.1.1.19 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 1.1.1.19 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 1.1.1.19 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 1.1.1.19 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 1.1.1.19 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 1.1.1.19 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 1.1.1.19 christos * 146 1.1.1.19 christos * Alternatively, you may choose to be licensed under the terms of the 147 1.1.1.19 christos * GNU General Public License ("GPL") version 2 as published by the Free 148 1.1.1.19 christos * Software Foundation. 149 1.1.1.19 christos * 150 1.1.1.19 christos *****************************************************************************/ 151 1.1 jruoho 152 1.1 jruoho #include "aslcompiler.h" 153 1.1 jruoho #include "aslcompiler.y.h" 154 1.1 jruoho #include "amlcode.h" 155 1.1 jruoho 156 1.1 jruoho 157 1.1 jruoho #define _COMPONENT ACPI_COMPILER 158 1.1 jruoho ACPI_MODULE_NAME ("aslresource") 159 1.1 jruoho 160 1.1 jruoho 161 1.1 jruoho /******************************************************************************* 162 1.1 jruoho * 163 1.1 jruoho * FUNCTION: RsSmallAddressCheck 164 1.1 jruoho * 165 1.1 jruoho * PARAMETERS: Minimum - Address Min value 166 1.1 jruoho * Maximum - Address Max value 167 1.1 jruoho * Length - Address range value 168 1.1 jruoho * Alignment - Address alignment value 169 1.1 jruoho * MinOp - Original Op for Address Min 170 1.1 jruoho * MaxOp - Original Op for Address Max 171 1.1 jruoho * LengthOp - Original Op for address range 172 1.1 jruoho * AlignOp - Original Op for address alignment. If 173 1.1 jruoho * NULL, means "zero value for alignment is 174 1.1 jruoho * OK, and means 64K alignment" (for 175 1.1 jruoho * Memory24 descriptor) 176 1.1.1.2 jruoho * Op - Parent Op for entire construct 177 1.1 jruoho * 178 1.1 jruoho * RETURN: None. Adds error messages to error log if necessary 179 1.1 jruoho * 180 1.1 jruoho * DESCRIPTION: Perform common value checks for "small" address descriptors. 181 1.1 jruoho * Currently: 182 1.1 jruoho * Io, Memory24, Memory32 183 1.1 jruoho * 184 1.1 jruoho ******************************************************************************/ 185 1.1 jruoho 186 1.1 jruoho void 187 1.1 jruoho RsSmallAddressCheck ( 188 1.1 jruoho UINT8 Type, 189 1.1 jruoho UINT32 Minimum, 190 1.1 jruoho UINT32 Maximum, 191 1.1 jruoho UINT32 Length, 192 1.1 jruoho UINT32 Alignment, 193 1.1 jruoho ACPI_PARSE_OBJECT *MinOp, 194 1.1 jruoho ACPI_PARSE_OBJECT *MaxOp, 195 1.1 jruoho ACPI_PARSE_OBJECT *LengthOp, 196 1.1.1.2 jruoho ACPI_PARSE_OBJECT *AlignOp, 197 1.1.1.2 jruoho ACPI_PARSE_OBJECT *Op) 198 1.1 jruoho { 199 1.1 jruoho 200 1.1.1.11 christos if (AslGbl_NoResourceChecking) 201 1.1 jruoho { 202 1.1 jruoho return; 203 1.1 jruoho } 204 1.1 jruoho 205 1.1.1.2 jruoho /* 206 1.1.1.2 jruoho * Check for a so-called "null descriptor". These are descriptors that are 207 1.1.1.2 jruoho * created with most fields set to zero. The intent is that the descriptor 208 1.1.1.2 jruoho * will be updated/completed at runtime via a BufferField. 209 1.1.1.2 jruoho * 210 1.1.1.2 jruoho * If the descriptor does NOT have a resource tag, it cannot be referenced 211 1.1.1.2 jruoho * by a BufferField and we will flag this as an error. Conversely, if 212 1.1.1.2 jruoho * the descriptor has a resource tag, we will assume that a BufferField 213 1.1.1.2 jruoho * will be used to dynamically update it, so no error. 214 1.1.1.2 jruoho * 215 1.1.1.2 jruoho * A possible enhancement to this check would be to verify that in fact 216 1.1.1.2 jruoho * a BufferField is created using the resource tag, and perhaps even 217 1.1.1.2 jruoho * verify that a Store is performed to the BufferField. 218 1.1.1.2 jruoho * 219 1.1.1.2 jruoho * Note: for these descriptors, Alignment is allowed to be zero 220 1.1.1.2 jruoho */ 221 1.1.1.2 jruoho if (!Minimum && !Maximum && !Length) 222 1.1.1.2 jruoho { 223 1.1.1.2 jruoho if (!Op->Asl.ExternalName) 224 1.1.1.2 jruoho { 225 1.1.1.2 jruoho /* No resource tag. Descriptor is fixed and is also illegal */ 226 1.1.1.2 jruoho 227 1.1.1.2 jruoho AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL); 228 1.1.1.2 jruoho } 229 1.1.1.2 jruoho 230 1.1.1.2 jruoho return; 231 1.1.1.2 jruoho } 232 1.1.1.2 jruoho 233 1.1.1.4 christos /* 234 1.1.1.4 christos * Range checks for Memory24 and Memory32. 235 1.1.1.4 christos * IO descriptor has different definition of min/max, don't check. 236 1.1.1.4 christos */ 237 1.1 jruoho if (Type != ACPI_RESOURCE_NAME_IO) 238 1.1 jruoho { 239 1.1 jruoho /* Basic checks on Min/Max/Length */ 240 1.1 jruoho 241 1.1 jruoho if (Minimum > Maximum) 242 1.1 jruoho { 243 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL); 244 1.1 jruoho } 245 1.1 jruoho else if (Length > (Maximum - Minimum + 1)) 246 1.1 jruoho { 247 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); 248 1.1 jruoho } 249 1.1.1.4 christos 250 1.1.1.4 christos /* Special case for Memory24, min/max values are compressed */ 251 1.1.1.4 christos 252 1.1.1.4 christos if (Type == ACPI_RESOURCE_NAME_MEMORY24) 253 1.1.1.4 christos { 254 1.1.1.4 christos if (!Alignment) /* Alignment==0 means 64K alignment */ 255 1.1.1.4 christos { 256 1.1.1.4 christos Alignment = ACPI_UINT16_MAX + 1; 257 1.1.1.4 christos } 258 1.1.1.4 christos 259 1.1.1.4 christos Minimum <<= 8; 260 1.1.1.4 christos Maximum <<= 8; 261 1.1.1.4 christos } 262 1.1 jruoho } 263 1.1 jruoho 264 1.1 jruoho /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */ 265 1.1 jruoho 266 1.1 jruoho if (!Alignment) 267 1.1 jruoho { 268 1.1 jruoho Alignment = 1; 269 1.1 jruoho } 270 1.1 jruoho 271 1.1 jruoho /* Addresses must be an exact multiple of the alignment value */ 272 1.1 jruoho 273 1.1 jruoho if (Minimum % Alignment) 274 1.1 jruoho { 275 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL); 276 1.1 jruoho } 277 1.1 jruoho if (Maximum % Alignment) 278 1.1 jruoho { 279 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, NULL); 280 1.1 jruoho } 281 1.1 jruoho } 282 1.1 jruoho 283 1.1 jruoho 284 1.1 jruoho /******************************************************************************* 285 1.1 jruoho * 286 1.1 jruoho * FUNCTION: RsLargeAddressCheck 287 1.1 jruoho * 288 1.1 jruoho * PARAMETERS: Minimum - Address Min value 289 1.1 jruoho * Maximum - Address Max value 290 1.1 jruoho * Length - Address range value 291 1.1 jruoho * Granularity - Address granularity value 292 1.1 jruoho * Flags - General flags for address descriptors: 293 1.1 jruoho * _MIF, _MAF, _DEC 294 1.1 jruoho * MinOp - Original Op for Address Min 295 1.1 jruoho * MaxOp - Original Op for Address Max 296 1.1 jruoho * LengthOp - Original Op for address range 297 1.1 jruoho * GranOp - Original Op for address granularity 298 1.1.1.2 jruoho * Op - Parent Op for entire construct 299 1.1 jruoho * 300 1.1 jruoho * RETURN: None. Adds error messages to error log if necessary 301 1.1 jruoho * 302 1.1 jruoho * DESCRIPTION: Perform common value checks for "large" address descriptors. 303 1.1 jruoho * Currently: 304 1.1 jruoho * WordIo, WordBusNumber, WordSpace 305 1.1 jruoho * DWordIo, DWordMemory, DWordSpace 306 1.1 jruoho * QWordIo, QWordMemory, QWordSpace 307 1.1 jruoho * ExtendedIo, ExtendedMemory, ExtendedSpace 308 1.1 jruoho * 309 1.1 jruoho * _MIF flag set means that the minimum address is fixed and is not relocatable 310 1.1 jruoho * _MAF flag set means that the maximum address is fixed and is not relocatable 311 1.1 jruoho * Length of zero means that the record size is variable 312 1.1 jruoho * 313 1.1 jruoho * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40 314 1.1 jruoho * of the ACPI 4.0a specification. Added 04/2010. 315 1.1 jruoho * 316 1.1 jruoho ******************************************************************************/ 317 1.1 jruoho 318 1.1 jruoho void 319 1.1 jruoho RsLargeAddressCheck ( 320 1.1 jruoho UINT64 Minimum, 321 1.1 jruoho UINT64 Maximum, 322 1.1 jruoho UINT64 Length, 323 1.1 jruoho UINT64 Granularity, 324 1.1 jruoho UINT8 Flags, 325 1.1 jruoho ACPI_PARSE_OBJECT *MinOp, 326 1.1 jruoho ACPI_PARSE_OBJECT *MaxOp, 327 1.1 jruoho ACPI_PARSE_OBJECT *LengthOp, 328 1.1.1.2 jruoho ACPI_PARSE_OBJECT *GranOp, 329 1.1.1.2 jruoho ACPI_PARSE_OBJECT *Op) 330 1.1 jruoho { 331 1.1 jruoho 332 1.1.1.11 christos if (AslGbl_NoResourceChecking) 333 1.1 jruoho { 334 1.1 jruoho return; 335 1.1 jruoho } 336 1.1 jruoho 337 1.1.1.2 jruoho /* 338 1.1.1.2 jruoho * Check for a so-called "null descriptor". These are descriptors that are 339 1.1.1.2 jruoho * created with most fields set to zero. The intent is that the descriptor 340 1.1.1.2 jruoho * will be updated/completed at runtime via a BufferField. 341 1.1.1.2 jruoho * 342 1.1.1.2 jruoho * If the descriptor does NOT have a resource tag, it cannot be referenced 343 1.1.1.2 jruoho * by a BufferField and we will flag this as an error. Conversely, if 344 1.1.1.2 jruoho * the descriptor has a resource tag, we will assume that a BufferField 345 1.1.1.2 jruoho * will be used to dynamically update it, so no error. 346 1.1.1.2 jruoho * 347 1.1.1.2 jruoho * A possible enhancement to this check would be to verify that in fact 348 1.1.1.2 jruoho * a BufferField is created using the resource tag, and perhaps even 349 1.1.1.2 jruoho * verify that a Store is performed to the BufferField. 350 1.1.1.2 jruoho */ 351 1.1.1.2 jruoho if (!Minimum && !Maximum && !Length && !Granularity) 352 1.1.1.2 jruoho { 353 1.1.1.2 jruoho if (!Op->Asl.ExternalName) 354 1.1.1.2 jruoho { 355 1.1.1.2 jruoho /* No resource tag. Descriptor is fixed and is also illegal */ 356 1.1.1.2 jruoho 357 1.1.1.2 jruoho AslError (ASL_ERROR, ASL_MSG_NULL_DESCRIPTOR, Op, NULL); 358 1.1.1.2 jruoho } 359 1.1.1.2 jruoho 360 1.1.1.2 jruoho return; 361 1.1.1.2 jruoho } 362 1.1.1.2 jruoho 363 1.1 jruoho /* Basic checks on Min/Max/Length */ 364 1.1 jruoho 365 1.1 jruoho if (Minimum > Maximum) 366 1.1 jruoho { 367 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL); 368 1.1 jruoho return; 369 1.1 jruoho } 370 1.1 jruoho else if (Length > (Maximum - Minimum + 1)) 371 1.1 jruoho { 372 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); 373 1.1 jruoho return; 374 1.1 jruoho } 375 1.1 jruoho 376 1.1 jruoho /* If specified (non-zero), ensure granularity is a power-of-two minus one */ 377 1.1 jruoho 378 1.1 jruoho if (Granularity) 379 1.1 jruoho { 380 1.1 jruoho if ((Granularity + 1) & 381 1.1 jruoho Granularity) 382 1.1 jruoho { 383 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_GRANULARITY, GranOp, NULL); 384 1.1 jruoho return; 385 1.1 jruoho } 386 1.1 jruoho } 387 1.1 jruoho 388 1.1 jruoho /* 389 1.1 jruoho * Check the various combinations of Length, MinFixed, and MaxFixed 390 1.1 jruoho */ 391 1.1 jruoho if (Length) 392 1.1 jruoho { 393 1.1 jruoho /* Fixed non-zero length */ 394 1.1 jruoho 395 1.1 jruoho switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF)) 396 1.1 jruoho { 397 1.1 jruoho case 0: 398 1.1 jruoho /* 399 1.1 jruoho * Fixed length, variable locations (both _MIN and _MAX). 400 1.1 jruoho * Length must be a multiple of granularity 401 1.1 jruoho */ 402 1.1 jruoho if (Granularity & Length) 403 1.1 jruoho { 404 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, LengthOp, NULL); 405 1.1 jruoho } 406 1.1 jruoho break; 407 1.1 jruoho 408 1.1 jruoho case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): 409 1.1 jruoho 410 1.1 jruoho /* Fixed length, fixed location. Granularity must be zero */ 411 1.1 jruoho 412 1.1 jruoho if (Granularity != 0) 413 1.1 jruoho { 414 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_GRAN_FIXED, GranOp, NULL); 415 1.1 jruoho } 416 1.1 jruoho 417 1.1 jruoho /* Length must be exactly the size of the min/max window */ 418 1.1 jruoho 419 1.1 jruoho if (Length != (Maximum - Minimum + 1)) 420 1.1 jruoho { 421 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH_FIXED, LengthOp, NULL); 422 1.1 jruoho } 423 1.1 jruoho break; 424 1.1 jruoho 425 1.1 jruoho /* All other combinations are invalid */ 426 1.1 jruoho 427 1.1 jruoho case ACPI_RESOURCE_FLAG_MIF: 428 1.1 jruoho case ACPI_RESOURCE_FLAG_MAF: 429 1.1 jruoho default: 430 1.1.1.3 christos 431 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); 432 1.1 jruoho } 433 1.1 jruoho } 434 1.1 jruoho else 435 1.1 jruoho { 436 1.1 jruoho /* Variable length (length==0) */ 437 1.1 jruoho 438 1.1 jruoho switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF)) 439 1.1 jruoho { 440 1.1 jruoho case 0: 441 1.1 jruoho /* 442 1.1 jruoho * Both _MIN and _MAX are variable. 443 1.1 jruoho * No additional requirements, just exit 444 1.1 jruoho */ 445 1.1 jruoho break; 446 1.1 jruoho 447 1.1 jruoho case ACPI_RESOURCE_FLAG_MIF: 448 1.1 jruoho 449 1.1 jruoho /* _MIN is fixed. _MIN must be multiple of _GRA */ 450 1.1 jruoho 451 1.1 jruoho /* 452 1.1 jruoho * The granularity is defined by the ACPI specification to be a 453 1.1 jruoho * power-of-two minus one, therefore the granularity is a 454 1.1 jruoho * bitmask which can be used to easily validate the addresses. 455 1.1 jruoho */ 456 1.1 jruoho if (Granularity & Minimum) 457 1.1 jruoho { 458 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL); 459 1.1 jruoho } 460 1.1 jruoho break; 461 1.1 jruoho 462 1.1 jruoho case ACPI_RESOURCE_FLAG_MAF: 463 1.1 jruoho 464 1.1 jruoho /* _MAX is fixed. (_MAX + 1) must be multiple of _GRA */ 465 1.1 jruoho 466 1.1 jruoho if (Granularity & (Maximum + 1)) 467 1.1 jruoho { 468 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, "-1"); 469 1.1 jruoho } 470 1.1 jruoho break; 471 1.1 jruoho 472 1.1 jruoho /* Both MIF/MAF set is invalid if length is zero */ 473 1.1 jruoho 474 1.1 jruoho case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): 475 1.1 jruoho default: 476 1.1.1.3 christos 477 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); 478 1.1 jruoho } 479 1.1 jruoho } 480 1.1 jruoho } 481 1.1 jruoho 482 1.1 jruoho 483 1.1 jruoho /******************************************************************************* 484 1.1 jruoho * 485 1.1 jruoho * FUNCTION: RsGetStringDataLength 486 1.1 jruoho * 487 1.1 jruoho * PARAMETERS: InitializerOp - Start of a subtree of init nodes 488 1.1 jruoho * 489 1.1 jruoho * RETURN: Valid string length if a string node is found (otherwise 0) 490 1.1 jruoho * 491 1.1 jruoho * DESCRIPTION: In a list of peer nodes, find the first one that contains a 492 1.1 jruoho * string and return the length of the string. 493 1.1 jruoho * 494 1.1 jruoho ******************************************************************************/ 495 1.1 jruoho 496 1.1 jruoho UINT16 497 1.1 jruoho RsGetStringDataLength ( 498 1.1 jruoho ACPI_PARSE_OBJECT *InitializerOp) 499 1.1 jruoho { 500 1.1 jruoho 501 1.1 jruoho while (InitializerOp) 502 1.1 jruoho { 503 1.1 jruoho if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) 504 1.1 jruoho { 505 1.1 jruoho return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); 506 1.1 jruoho } 507 1.1.1.6 christos 508 1.1 jruoho InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 509 1.1 jruoho } 510 1.1 jruoho 511 1.1.1.3 christos return (0); 512 1.1 jruoho } 513 1.1 jruoho 514 1.1 jruoho 515 1.1 jruoho /******************************************************************************* 516 1.1 jruoho * 517 1.1 jruoho * FUNCTION: RsAllocateResourceNode 518 1.1 jruoho * 519 1.1 jruoho * PARAMETERS: Size - Size of node in bytes 520 1.1 jruoho * 521 1.1 jruoho * RETURN: The allocated node - aborts on allocation failure 522 1.1 jruoho * 523 1.1 jruoho * DESCRIPTION: Allocate a resource description node and the resource 524 1.1 jruoho * descriptor itself (the nodes are used to link descriptors). 525 1.1 jruoho * 526 1.1 jruoho ******************************************************************************/ 527 1.1 jruoho 528 1.1 jruoho ASL_RESOURCE_NODE * 529 1.1 jruoho RsAllocateResourceNode ( 530 1.1 jruoho UINT32 Size) 531 1.1 jruoho { 532 1.1 jruoho ASL_RESOURCE_NODE *Rnode; 533 1.1 jruoho 534 1.1 jruoho 535 1.1 jruoho /* Allocate the node */ 536 1.1 jruoho 537 1.1 jruoho Rnode = UtLocalCalloc (sizeof (ASL_RESOURCE_NODE)); 538 1.1 jruoho 539 1.1 jruoho /* Allocate the resource descriptor itself */ 540 1.1 jruoho 541 1.1 jruoho Rnode->Buffer = UtLocalCalloc (Size); 542 1.1 jruoho Rnode->BufferLength = Size; 543 1.1 jruoho return (Rnode); 544 1.1 jruoho } 545 1.1 jruoho 546 1.1 jruoho 547 1.1 jruoho /******************************************************************************* 548 1.1 jruoho * 549 1.1.1.3 christos * FUNCTION: RsCreateResourceField 550 1.1 jruoho * 551 1.1 jruoho * PARAMETERS: Op - Resource field node 552 1.1 jruoho * Name - Name of the field (Used only to reference 553 1.1 jruoho * the field in the ASL, not in the AML) 554 1.1 jruoho * ByteOffset - Offset from the field start 555 1.1 jruoho * BitOffset - Additional bit offset 556 1.1.1.3 christos * BitLength - Number of bits in the field 557 1.1 jruoho * 558 1.1 jruoho * RETURN: None, sets fields within the input node 559 1.1 jruoho * 560 1.1 jruoho * DESCRIPTION: Utility function to generate a named bit field within a 561 1.1.1.3 christos * resource descriptor. Mark a node as 1) a field in a resource 562 1.1 jruoho * descriptor, and 2) set the value to be a BIT offset 563 1.1 jruoho * 564 1.1 jruoho ******************************************************************************/ 565 1.1 jruoho 566 1.1 jruoho void 567 1.1.1.3 christos RsCreateResourceField ( 568 1.1 jruoho ACPI_PARSE_OBJECT *Op, 569 1.1 jruoho char *Name, 570 1.1 jruoho UINT32 ByteOffset, 571 1.1.1.3 christos UINT32 BitOffset, 572 1.1.1.3 christos UINT32 BitLength) 573 1.1 jruoho { 574 1.1 jruoho 575 1.1.1.3 christos Op->Asl.ExternalName = Name; 576 1.1.1.9 christos Op->Asl.CompileFlags |= OP_IS_RESOURCE_FIELD; 577 1.1 jruoho 578 1.1.1.3 christos Op->Asl.Value.Tag.BitOffset = (ByteOffset * 8) + BitOffset; 579 1.1.1.3 christos Op->Asl.Value.Tag.BitLength = BitLength; 580 1.1 jruoho } 581 1.1 jruoho 582 1.1 jruoho 583 1.1 jruoho /******************************************************************************* 584 1.1 jruoho * 585 1.1 jruoho * FUNCTION: RsSetFlagBits 586 1.1 jruoho * 587 1.1 jruoho * PARAMETERS: *Flags - Pointer to the flag byte 588 1.1 jruoho * Op - Flag initialization node 589 1.1 jruoho * Position - Bit position within the flag byte 590 1.1 jruoho * Default - Used if the node is DEFAULT. 591 1.1 jruoho * 592 1.1 jruoho * RETURN: Sets bits within the *Flags output byte. 593 1.1 jruoho * 594 1.1 jruoho * DESCRIPTION: Set a bit in a cumulative flags word from an initialization 595 1.1.1.3 christos * node. Will use a default value if the node is DEFAULT, meaning 596 1.1.1.3 christos * that no value was specified in the ASL. Used to merge multiple 597 1.1 jruoho * keywords into a single flags byte. 598 1.1 jruoho * 599 1.1 jruoho ******************************************************************************/ 600 1.1 jruoho 601 1.1 jruoho void 602 1.1 jruoho RsSetFlagBits ( 603 1.1 jruoho UINT8 *Flags, 604 1.1 jruoho ACPI_PARSE_OBJECT *Op, 605 1.1 jruoho UINT8 Position, 606 1.1 jruoho UINT8 DefaultBit) 607 1.1 jruoho { 608 1.1 jruoho 609 1.1 jruoho if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 610 1.1 jruoho { 611 1.1 jruoho /* Use the default bit */ 612 1.1 jruoho 613 1.1 jruoho *Flags |= (DefaultBit << Position); 614 1.1 jruoho } 615 1.1 jruoho else 616 1.1 jruoho { 617 1.1 jruoho /* Use the bit specified in the initialization node */ 618 1.1 jruoho 619 1.1 jruoho *Flags |= (((UINT8) Op->Asl.Value.Integer) << Position); 620 1.1 jruoho } 621 1.1 jruoho } 622 1.1 jruoho 623 1.1 jruoho 624 1.1.1.3 christos void 625 1.1.1.3 christos RsSetFlagBits16 ( 626 1.1.1.3 christos UINT16 *Flags, 627 1.1.1.3 christos ACPI_PARSE_OBJECT *Op, 628 1.1.1.3 christos UINT8 Position, 629 1.1.1.3 christos UINT8 DefaultBit) 630 1.1.1.3 christos { 631 1.1.1.3 christos 632 1.1.1.3 christos if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 633 1.1.1.3 christos { 634 1.1.1.3 christos /* Use the default bit */ 635 1.1.1.3 christos 636 1.1.1.3 christos *Flags |= (DefaultBit << Position); 637 1.1.1.3 christos } 638 1.1.1.3 christos else 639 1.1.1.3 christos { 640 1.1.1.3 christos /* Use the bit specified in the initialization node */ 641 1.1.1.3 christos 642 1.1.1.3 christos *Flags |= (((UINT16) Op->Asl.Value.Integer) << Position); 643 1.1.1.3 christos } 644 1.1.1.3 christos } 645 1.1.1.3 christos 646 1.1.1.3 christos 647 1.1 jruoho /******************************************************************************* 648 1.1 jruoho * 649 1.1 jruoho * FUNCTION: RsCompleteNodeAndGetNext 650 1.1 jruoho * 651 1.1 jruoho * PARAMETERS: Op - Resource node to be completed 652 1.1 jruoho * 653 1.1 jruoho * RETURN: The next peer to the input node. 654 1.1 jruoho * 655 1.1 jruoho * DESCRIPTION: Mark the current node completed and return the next peer. 656 1.1 jruoho * The node ParseOpcode is set to DEFAULT_ARG, meaning that 657 1.1 jruoho * this node is to be ignored from now on. 658 1.1 jruoho * 659 1.1 jruoho ******************************************************************************/ 660 1.1 jruoho 661 1.1 jruoho ACPI_PARSE_OBJECT * 662 1.1 jruoho RsCompleteNodeAndGetNext ( 663 1.1 jruoho ACPI_PARSE_OBJECT *Op) 664 1.1 jruoho { 665 1.1 jruoho 666 1.1 jruoho /* Mark this node unused */ 667 1.1 jruoho 668 1.1 jruoho Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 669 1.1 jruoho 670 1.1 jruoho /* Move on to the next peer node in the initializer list */ 671 1.1 jruoho 672 1.1 jruoho return (ASL_GET_PEER_NODE (Op)); 673 1.1 jruoho } 674 1.1 jruoho 675 1.1 jruoho 676 1.1 jruoho /******************************************************************************* 677 1.1 jruoho * 678 1.1 jruoho * FUNCTION: RsCheckListForDuplicates 679 1.1 jruoho * 680 1.1 jruoho * PARAMETERS: Op - First op in the initializer list 681 1.1 jruoho * 682 1.1 jruoho * RETURN: None 683 1.1 jruoho * 684 1.1 jruoho * DESCRIPTION: Check an initializer list for duplicate values. Emits an error 685 1.1 jruoho * if any duplicates are found. 686 1.1 jruoho * 687 1.1 jruoho ******************************************************************************/ 688 1.1 jruoho 689 1.1 jruoho void 690 1.1 jruoho RsCheckListForDuplicates ( 691 1.1 jruoho ACPI_PARSE_OBJECT *Op) 692 1.1 jruoho { 693 1.1 jruoho ACPI_PARSE_OBJECT *NextValueOp = Op; 694 1.1 jruoho ACPI_PARSE_OBJECT *NextOp; 695 1.1 jruoho UINT32 Value; 696 1.1 jruoho 697 1.1 jruoho 698 1.1 jruoho if (!Op) 699 1.1 jruoho { 700 1.1 jruoho return; 701 1.1 jruoho } 702 1.1 jruoho 703 1.1 jruoho /* Search list once for each value in the list */ 704 1.1 jruoho 705 1.1 jruoho while (NextValueOp) 706 1.1 jruoho { 707 1.1 jruoho Value = (UINT32) NextValueOp->Asl.Value.Integer; 708 1.1 jruoho 709 1.1 jruoho /* Compare this value to all remaining values in the list */ 710 1.1 jruoho 711 1.1 jruoho NextOp = ASL_GET_PEER_NODE (NextValueOp); 712 1.1 jruoho while (NextOp) 713 1.1 jruoho { 714 1.1 jruoho if (NextOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 715 1.1 jruoho { 716 1.1 jruoho /* Compare values */ 717 1.1 jruoho 718 1.1 jruoho if (Value == (UINT32) NextOp->Asl.Value.Integer) 719 1.1 jruoho { 720 1.1 jruoho /* Emit error only once per duplicate node */ 721 1.1 jruoho 722 1.1.1.9 christos if (!(NextOp->Asl.CompileFlags & OP_IS_DUPLICATE)) 723 1.1 jruoho { 724 1.1.1.9 christos NextOp->Asl.CompileFlags |= OP_IS_DUPLICATE; 725 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_DUPLICATE_ITEM, 726 1.1 jruoho NextOp, NULL); 727 1.1 jruoho } 728 1.1 jruoho } 729 1.1 jruoho } 730 1.1 jruoho 731 1.1 jruoho NextOp = ASL_GET_PEER_NODE (NextOp); 732 1.1 jruoho } 733 1.1 jruoho 734 1.1 jruoho NextValueOp = ASL_GET_PEER_NODE (NextValueOp); 735 1.1 jruoho } 736 1.1 jruoho } 737 1.1 jruoho 738 1.1 jruoho 739 1.1 jruoho /******************************************************************************* 740 1.1 jruoho * 741 1.1 jruoho * FUNCTION: RsDoOneResourceDescriptor 742 1.1 jruoho * 743 1.1 jruoho * PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor 744 1.1 jruoho * CurrentByteOffset - Offset in the resource descriptor 745 1.1 jruoho * buffer. 746 1.1 jruoho * 747 1.1 jruoho * RETURN: A valid resource node for the descriptor 748 1.1 jruoho * 749 1.1 jruoho * DESCRIPTION: Dispatches the processing of one resource descriptor 750 1.1 jruoho * 751 1.1 jruoho ******************************************************************************/ 752 1.1 jruoho 753 1.1 jruoho ASL_RESOURCE_NODE * 754 1.1 jruoho RsDoOneResourceDescriptor ( 755 1.1.1.4 christos ASL_RESOURCE_INFO *Info, 756 1.1 jruoho UINT8 *State) 757 1.1 jruoho { 758 1.1 jruoho ASL_RESOURCE_NODE *Rnode = NULL; 759 1.1 jruoho 760 1.1 jruoho 761 1.1 jruoho /* Construct the resource */ 762 1.1 jruoho 763 1.1.1.4 christos switch (Info->DescriptorTypeOp->Asl.ParseOpcode) 764 1.1 jruoho { 765 1.1.1.17 christos 766 1.1.1.17 christos case PARSEOP_CLOCKINPUT: 767 1.1.1.17 christos 768 1.1.1.17 christos Rnode = RsDoClockInputDescriptor(Info); 769 1.1.1.17 christos break; 770 1.1.1.17 christos 771 1.1 jruoho case PARSEOP_DMA: 772 1.1.1.3 christos 773 1.1.1.4 christos Rnode = RsDoDmaDescriptor (Info); 774 1.1 jruoho break; 775 1.1 jruoho 776 1.1.1.3 christos case PARSEOP_FIXEDDMA: 777 1.1.1.3 christos 778 1.1.1.4 christos Rnode = RsDoFixedDmaDescriptor (Info); 779 1.1.1.3 christos break; 780 1.1.1.3 christos 781 1.1 jruoho case PARSEOP_DWORDIO: 782 1.1.1.3 christos 783 1.1.1.4 christos Rnode = RsDoDwordIoDescriptor (Info); 784 1.1 jruoho break; 785 1.1 jruoho 786 1.1 jruoho case PARSEOP_DWORDMEMORY: 787 1.1.1.3 christos 788 1.1.1.4 christos Rnode = RsDoDwordMemoryDescriptor (Info); 789 1.1 jruoho break; 790 1.1 jruoho 791 1.1.1.18 christos case PARSEOP_DWORDPCC: 792 1.1.1.18 christos 793 1.1.1.18 christos Rnode = RsDoDwordPccDescriptor (Info); 794 1.1.1.18 christos break; 795 1.1.1.18 christos 796 1.1 jruoho case PARSEOP_DWORDSPACE: 797 1.1.1.3 christos 798 1.1.1.4 christos Rnode = RsDoDwordSpaceDescriptor (Info); 799 1.1 jruoho break; 800 1.1 jruoho 801 1.1 jruoho case PARSEOP_ENDDEPENDENTFN: 802 1.1.1.3 christos 803 1.1 jruoho switch (*State) 804 1.1 jruoho { 805 1.1 jruoho case ACPI_RSTATE_NORMAL: 806 1.1.1.3 christos 807 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, 808 1.1.1.4 christos Info->DescriptorTypeOp, NULL); 809 1.1 jruoho break; 810 1.1 jruoho 811 1.1 jruoho case ACPI_RSTATE_START_DEPENDENT: 812 1.1.1.3 christos 813 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, 814 1.1.1.4 christos Info->DescriptorTypeOp, NULL); 815 1.1 jruoho break; 816 1.1 jruoho 817 1.1 jruoho case ACPI_RSTATE_DEPENDENT_LIST: 818 1.1 jruoho default: 819 1.1.1.3 christos 820 1.1 jruoho break; 821 1.1 jruoho } 822 1.1 jruoho 823 1.1 jruoho *State = ACPI_RSTATE_NORMAL; 824 1.1.1.4 christos Rnode = RsDoEndDependentDescriptor (Info); 825 1.1 jruoho break; 826 1.1 jruoho 827 1.1 jruoho case PARSEOP_ENDTAG: 828 1.1.1.3 christos 829 1.1.1.4 christos Rnode = RsDoEndTagDescriptor (Info); 830 1.1 jruoho break; 831 1.1 jruoho 832 1.1 jruoho case PARSEOP_EXTENDEDIO: 833 1.1.1.3 christos 834 1.1.1.4 christos Rnode = RsDoExtendedIoDescriptor (Info); 835 1.1 jruoho break; 836 1.1 jruoho 837 1.1 jruoho case PARSEOP_EXTENDEDMEMORY: 838 1.1.1.3 christos 839 1.1.1.4 christos Rnode = RsDoExtendedMemoryDescriptor (Info); 840 1.1 jruoho break; 841 1.1 jruoho 842 1.1 jruoho case PARSEOP_EXTENDEDSPACE: 843 1.1.1.3 christos 844 1.1.1.4 christos Rnode = RsDoExtendedSpaceDescriptor (Info); 845 1.1 jruoho break; 846 1.1 jruoho 847 1.1 jruoho case PARSEOP_FIXEDIO: 848 1.1.1.3 christos 849 1.1.1.4 christos Rnode = RsDoFixedIoDescriptor (Info); 850 1.1 jruoho break; 851 1.1 jruoho 852 1.1 jruoho case PARSEOP_INTERRUPT: 853 1.1.1.3 christos 854 1.1.1.4 christos Rnode = RsDoInterruptDescriptor (Info); 855 1.1 jruoho break; 856 1.1 jruoho 857 1.1 jruoho case PARSEOP_IO: 858 1.1.1.3 christos 859 1.1.1.4 christos Rnode = RsDoIoDescriptor (Info); 860 1.1 jruoho break; 861 1.1 jruoho 862 1.1 jruoho case PARSEOP_IRQ: 863 1.1.1.3 christos 864 1.1.1.4 christos Rnode = RsDoIrqDescriptor (Info); 865 1.1 jruoho break; 866 1.1 jruoho 867 1.1 jruoho case PARSEOP_IRQNOFLAGS: 868 1.1.1.3 christos 869 1.1.1.4 christos Rnode = RsDoIrqNoFlagsDescriptor (Info); 870 1.1 jruoho break; 871 1.1 jruoho 872 1.1 jruoho case PARSEOP_MEMORY24: 873 1.1.1.3 christos 874 1.1.1.4 christos Rnode = RsDoMemory24Descriptor (Info); 875 1.1 jruoho break; 876 1.1 jruoho 877 1.1 jruoho case PARSEOP_MEMORY32: 878 1.1.1.3 christos 879 1.1.1.4 christos Rnode = RsDoMemory32Descriptor (Info); 880 1.1 jruoho break; 881 1.1 jruoho 882 1.1 jruoho case PARSEOP_MEMORY32FIXED: 883 1.1.1.3 christos 884 1.1.1.4 christos Rnode = RsDoMemory32FixedDescriptor (Info); 885 1.1 jruoho break; 886 1.1 jruoho 887 1.1 jruoho case PARSEOP_QWORDIO: 888 1.1.1.3 christos 889 1.1.1.4 christos Rnode = RsDoQwordIoDescriptor (Info); 890 1.1 jruoho break; 891 1.1 jruoho 892 1.1 jruoho case PARSEOP_QWORDMEMORY: 893 1.1.1.3 christos 894 1.1.1.4 christos Rnode = RsDoQwordMemoryDescriptor (Info); 895 1.1 jruoho break; 896 1.1 jruoho 897 1.1.1.18 christos case PARSEOP_QWORDPCC: 898 1.1.1.18 christos 899 1.1.1.18 christos Rnode = RsDoQwordPccDescriptor (Info); 900 1.1.1.18 christos break; 901 1.1.1.18 christos 902 1.1 jruoho case PARSEOP_QWORDSPACE: 903 1.1.1.3 christos 904 1.1.1.4 christos Rnode = RsDoQwordSpaceDescriptor (Info); 905 1.1 jruoho break; 906 1.1 jruoho 907 1.1 jruoho case PARSEOP_REGISTER: 908 1.1.1.3 christos 909 1.1.1.4 christos Rnode = RsDoGeneralRegisterDescriptor (Info); 910 1.1 jruoho break; 911 1.1 jruoho 912 1.1 jruoho case PARSEOP_STARTDEPENDENTFN: 913 1.1.1.3 christos 914 1.1 jruoho switch (*State) 915 1.1 jruoho { 916 1.1 jruoho case ACPI_RSTATE_START_DEPENDENT: 917 1.1.1.3 christos 918 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, 919 1.1.1.4 christos Info->DescriptorTypeOp, NULL); 920 1.1 jruoho break; 921 1.1 jruoho 922 1.1 jruoho case ACPI_RSTATE_NORMAL: 923 1.1 jruoho case ACPI_RSTATE_DEPENDENT_LIST: 924 1.1 jruoho default: 925 1.1.1.3 christos 926 1.1 jruoho break; 927 1.1 jruoho } 928 1.1 jruoho 929 1.1 jruoho *State = ACPI_RSTATE_START_DEPENDENT; 930 1.1.1.4 christos Rnode = RsDoStartDependentDescriptor (Info); 931 1.1 jruoho *State = ACPI_RSTATE_DEPENDENT_LIST; 932 1.1 jruoho break; 933 1.1 jruoho 934 1.1 jruoho case PARSEOP_STARTDEPENDENTFN_NOPRI: 935 1.1.1.3 christos 936 1.1 jruoho switch (*State) 937 1.1 jruoho { 938 1.1 jruoho case ACPI_RSTATE_START_DEPENDENT: 939 1.1.1.3 christos 940 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, 941 1.1.1.4 christos Info->DescriptorTypeOp, NULL); 942 1.1 jruoho break; 943 1.1 jruoho 944 1.1 jruoho case ACPI_RSTATE_NORMAL: 945 1.1 jruoho case ACPI_RSTATE_DEPENDENT_LIST: 946 1.1 jruoho default: 947 1.1.1.3 christos 948 1.1 jruoho break; 949 1.1 jruoho } 950 1.1 jruoho 951 1.1 jruoho *State = ACPI_RSTATE_START_DEPENDENT; 952 1.1.1.4 christos Rnode = RsDoStartDependentNoPriDescriptor (Info); 953 1.1 jruoho *State = ACPI_RSTATE_DEPENDENT_LIST; 954 1.1 jruoho break; 955 1.1 jruoho 956 1.1 jruoho case PARSEOP_VENDORLONG: 957 1.1.1.3 christos 958 1.1.1.4 christos Rnode = RsDoVendorLargeDescriptor (Info); 959 1.1 jruoho break; 960 1.1 jruoho 961 1.1 jruoho case PARSEOP_VENDORSHORT: 962 1.1.1.3 christos 963 1.1.1.4 christos Rnode = RsDoVendorSmallDescriptor (Info); 964 1.1 jruoho break; 965 1.1 jruoho 966 1.1 jruoho case PARSEOP_WORDBUSNUMBER: 967 1.1.1.3 christos 968 1.1.1.4 christos Rnode = RsDoWordBusNumberDescriptor (Info); 969 1.1 jruoho break; 970 1.1 jruoho 971 1.1 jruoho case PARSEOP_WORDIO: 972 1.1.1.3 christos 973 1.1.1.4 christos Rnode = RsDoWordIoDescriptor (Info); 974 1.1 jruoho break; 975 1.1 jruoho 976 1.1.1.18 christos case PARSEOP_WORDPCC: 977 1.1.1.18 christos 978 1.1.1.18 christos Rnode = RsDoWordPccDescriptor (Info); 979 1.1.1.18 christos break; 980 1.1.1.18 christos 981 1.1 jruoho case PARSEOP_WORDSPACE: 982 1.1.1.3 christos 983 1.1.1.4 christos Rnode = RsDoWordSpaceDescriptor (Info); 984 1.1 jruoho break; 985 1.1 jruoho 986 1.1.1.3 christos case PARSEOP_GPIO_INT: 987 1.1.1.3 christos 988 1.1.1.4 christos Rnode = RsDoGpioIntDescriptor (Info); 989 1.1.1.3 christos break; 990 1.1.1.3 christos 991 1.1.1.3 christos case PARSEOP_GPIO_IO: 992 1.1.1.3 christos 993 1.1.1.4 christos Rnode = RsDoGpioIoDescriptor (Info); 994 1.1.1.3 christos break; 995 1.1.1.3 christos 996 1.1.1.3 christos case PARSEOP_I2C_SERIALBUS: 997 1.1.1.7 christos case PARSEOP_I2C_SERIALBUS_V2: 998 1.1.1.3 christos 999 1.1.1.4 christos Rnode = RsDoI2cSerialBusDescriptor (Info); 1000 1.1.1.3 christos break; 1001 1.1.1.3 christos 1002 1.1.1.3 christos case PARSEOP_SPI_SERIALBUS: 1003 1.1.1.7 christos case PARSEOP_SPI_SERIALBUS_V2: 1004 1.1.1.3 christos 1005 1.1.1.4 christos Rnode = RsDoSpiSerialBusDescriptor (Info); 1006 1.1.1.3 christos break; 1007 1.1.1.3 christos 1008 1.1.1.3 christos case PARSEOP_UART_SERIALBUS: 1009 1.1.1.7 christos case PARSEOP_UART_SERIALBUS_V2: 1010 1.1.1.3 christos 1011 1.1.1.4 christos Rnode = RsDoUartSerialBusDescriptor (Info); 1012 1.1.1.3 christos break; 1013 1.1.1.3 christos 1014 1.1.1.15 christos case PARSEOP_CSI2_SERIALBUS: 1015 1.1.1.15 christos 1016 1.1.1.15 christos Rnode = RsDoCsi2SerialBusDescriptor (Info); 1017 1.1.1.15 christos break; 1018 1.1.1.15 christos 1019 1.1.1.9 christos case PARSEOP_PINCONFIG: 1020 1.1.1.9 christos 1021 1.1.1.9 christos Rnode = RsDoPinConfigDescriptor (Info); 1022 1.1.1.9 christos break; 1023 1.1.1.9 christos 1024 1.1.1.9 christos case PARSEOP_PINFUNCTION: 1025 1.1.1.9 christos 1026 1.1.1.9 christos Rnode = RsDoPinFunctionDescriptor (Info); 1027 1.1.1.9 christos break; 1028 1.1.1.9 christos 1029 1.1.1.9 christos case PARSEOP_PINGROUP: 1030 1.1.1.9 christos 1031 1.1.1.9 christos Rnode = RsDoPinGroupDescriptor (Info); 1032 1.1.1.9 christos break; 1033 1.1.1.9 christos 1034 1.1.1.9 christos case PARSEOP_PINGROUPFUNCTION: 1035 1.1.1.9 christos 1036 1.1.1.9 christos Rnode = RsDoPinGroupFunctionDescriptor (Info); 1037 1.1.1.9 christos break; 1038 1.1.1.9 christos 1039 1.1.1.9 christos case PARSEOP_PINGROUPCONFIG: 1040 1.1.1.9 christos 1041 1.1.1.9 christos Rnode = RsDoPinGroupConfigDescriptor (Info); 1042 1.1.1.9 christos break; 1043 1.1.1.9 christos 1044 1.1 jruoho case PARSEOP_DEFAULT_ARG: 1045 1.1.1.3 christos 1046 1.1 jruoho /* Just ignore any of these, they are used as fillers/placeholders */ 1047 1.1 jruoho break; 1048 1.1 jruoho 1049 1.1 jruoho default: 1050 1.1.1.3 christos 1051 1.1 jruoho printf ("Unknown resource descriptor type [%s]\n", 1052 1.1.1.6 christos Info->DescriptorTypeOp->Asl.ParseOpName); 1053 1.1 jruoho break; 1054 1.1 jruoho } 1055 1.1 jruoho 1056 1.1 jruoho /* 1057 1.1 jruoho * Mark original node as unused, but head of a resource descriptor. 1058 1.1 jruoho * This allows the resource to be installed in the namespace so that 1059 1.1 jruoho * references to the descriptor can be resolved. 1060 1.1 jruoho */ 1061 1.1.1.4 christos Info->DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 1062 1.1.1.9 christos Info->DescriptorTypeOp->Asl.CompileFlags = OP_IS_RESOURCE_DESC; 1063 1.1.1.4 christos Info->DescriptorTypeOp->Asl.Value.Integer = Info->CurrentByteOffset; 1064 1.1 jruoho 1065 1.1 jruoho if (Rnode) 1066 1.1 jruoho { 1067 1.1.1.4 christos Info->DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; 1068 1.1.1.6 christos Info->DescriptorTypeOp->Asl.Extra = 1069 1.1.1.6 christos ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; 1070 1.1 jruoho } 1071 1.1 jruoho 1072 1.1 jruoho return (Rnode); 1073 1.1 jruoho } 1074 1.1 jruoho 1075 1.1 jruoho 1076 1.1 jruoho /******************************************************************************* 1077 1.1 jruoho * 1078 1.1 jruoho * FUNCTION: RsLinkDescriptorChain 1079 1.1 jruoho * 1080 1.1 jruoho * PARAMETERS: PreviousRnode - Pointer to the node that will be previous 1081 1.1 jruoho * to the linked node, At exit, set to the 1082 1.1 jruoho * last node in the new chain. 1083 1.1 jruoho * Rnode - Resource node to link into the list 1084 1.1 jruoho * 1085 1.1 jruoho * RETURN: Cumulative buffer byte offset of the new segment of chain 1086 1.1 jruoho * 1087 1.1 jruoho * DESCRIPTION: Link a descriptor chain at the end of an existing chain. 1088 1.1 jruoho * 1089 1.1 jruoho ******************************************************************************/ 1090 1.1 jruoho 1091 1.1 jruoho UINT32 1092 1.1 jruoho RsLinkDescriptorChain ( 1093 1.1 jruoho ASL_RESOURCE_NODE **PreviousRnode, 1094 1.1 jruoho ASL_RESOURCE_NODE *Rnode) 1095 1.1 jruoho { 1096 1.1 jruoho ASL_RESOURCE_NODE *LastRnode; 1097 1.1 jruoho UINT32 CurrentByteOffset; 1098 1.1 jruoho 1099 1.1 jruoho 1100 1.1 jruoho /* Anything to do? */ 1101 1.1 jruoho 1102 1.1 jruoho if (!Rnode) 1103 1.1 jruoho { 1104 1.1.1.3 christos return (0); 1105 1.1 jruoho } 1106 1.1 jruoho 1107 1.1 jruoho /* Point the previous node to the new node */ 1108 1.1 jruoho 1109 1.1 jruoho (*PreviousRnode)->Next = Rnode; 1110 1.1 jruoho CurrentByteOffset = Rnode->BufferLength; 1111 1.1 jruoho 1112 1.1 jruoho /* Walk to the end of the chain headed by Rnode */ 1113 1.1 jruoho 1114 1.1 jruoho LastRnode = Rnode; 1115 1.1 jruoho while (LastRnode->Next) 1116 1.1 jruoho { 1117 1.1 jruoho LastRnode = LastRnode->Next; 1118 1.1 jruoho CurrentByteOffset += LastRnode->BufferLength; 1119 1.1 jruoho } 1120 1.1 jruoho 1121 1.1 jruoho /* Previous node becomes the last node in the chain */ 1122 1.1 jruoho 1123 1.1 jruoho *PreviousRnode = LastRnode; 1124 1.1.1.3 christos return (CurrentByteOffset); 1125 1.1 jruoho } 1126 1.1 jruoho 1127 1.1 jruoho 1128 1.1 jruoho /******************************************************************************* 1129 1.1 jruoho * 1130 1.1 jruoho * FUNCTION: RsDoResourceTemplate 1131 1.1 jruoho * 1132 1.1 jruoho * PARAMETERS: Op - Parent of a resource template list 1133 1.1 jruoho * 1134 1.1.1.3 christos * RETURN: None. Sets input node to point to a list of AML code 1135 1.1 jruoho * 1136 1.1 jruoho * DESCRIPTION: Merge a list of resource descriptors into a single AML buffer, 1137 1.1 jruoho * in preparation for output to the AML output file. 1138 1.1 jruoho * 1139 1.1 jruoho ******************************************************************************/ 1140 1.1 jruoho 1141 1.1 jruoho void 1142 1.1 jruoho RsDoResourceTemplate ( 1143 1.1 jruoho ACPI_PARSE_OBJECT *Op) 1144 1.1 jruoho { 1145 1.1 jruoho ACPI_PARSE_OBJECT *BufferLengthOp; 1146 1.1 jruoho ACPI_PARSE_OBJECT *BufferOp; 1147 1.1 jruoho ACPI_PARSE_OBJECT *DescriptorTypeOp; 1148 1.1 jruoho ACPI_PARSE_OBJECT *LastOp = NULL; 1149 1.1 jruoho UINT32 CurrentByteOffset = 0; 1150 1.1 jruoho ASL_RESOURCE_NODE HeadRnode; 1151 1.1 jruoho ASL_RESOURCE_NODE *PreviousRnode; 1152 1.1 jruoho ASL_RESOURCE_NODE *Rnode; 1153 1.1.1.4 christos ASL_RESOURCE_INFO Info; 1154 1.1 jruoho UINT8 State; 1155 1.1 jruoho 1156 1.1 jruoho 1157 1.1 jruoho /* Mark parent as containing a resource template */ 1158 1.1 jruoho 1159 1.1 jruoho if (Op->Asl.Parent) 1160 1.1 jruoho { 1161 1.1.1.9 christos Op->Asl.Parent->Asl.CompileFlags |= OP_IS_RESOURCE_DESC; 1162 1.1 jruoho } 1163 1.1 jruoho 1164 1.1 jruoho /* ResourceTemplate Opcode is first (Op) */ 1165 1.1 jruoho /* Buffer Length node is first child */ 1166 1.1 jruoho 1167 1.1 jruoho BufferLengthOp = ASL_GET_CHILD_NODE (Op); 1168 1.1 jruoho 1169 1.1 jruoho /* Buffer Op is first peer */ 1170 1.1 jruoho 1171 1.1 jruoho BufferOp = ASL_GET_PEER_NODE (BufferLengthOp); 1172 1.1 jruoho 1173 1.1 jruoho /* First Descriptor type is next */ 1174 1.1 jruoho 1175 1.1 jruoho DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp); 1176 1.1 jruoho 1177 1.1.1.9 christos /* DEFAULT_ARG indicates null template - ResourceTemplate(){} */ 1178 1.1.1.9 christos 1179 1.1.1.9 christos if (DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 1180 1.1.1.9 christos { 1181 1.1.1.9 christos AslError (ASL_WARNING, ASL_MSG_NULL_RESOURCE_TEMPLATE, 1182 1.1.1.9 christos DescriptorTypeOp, DescriptorTypeOp->Asl.Value.String); 1183 1.1.1.9 christos } 1184 1.1.1.9 christos 1185 1.1 jruoho /* 1186 1.1 jruoho * Process all resource descriptors in the list 1187 1.1 jruoho * Note: It is assumed that the EndTag node has been automatically 1188 1.1 jruoho * inserted at the end of the template by the parser. 1189 1.1 jruoho */ 1190 1.1 jruoho State = ACPI_RSTATE_NORMAL; 1191 1.1 jruoho PreviousRnode = &HeadRnode; 1192 1.1 jruoho while (DescriptorTypeOp) 1193 1.1 jruoho { 1194 1.1.1.4 christos /* Save information for optional mapfile */ 1195 1.1.1.4 christos 1196 1.1.1.4 christos if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION) 1197 1.1.1.4 christos { 1198 1.1.1.4 christos Info.MappingOp = Op->Asl.Parent; 1199 1.1.1.4 christos } 1200 1.1.1.4 christos else 1201 1.1.1.4 christos { 1202 1.1.1.4 christos Info.MappingOp = DescriptorTypeOp; 1203 1.1.1.4 christos } 1204 1.1.1.4 christos 1205 1.1.1.4 christos Info.DescriptorTypeOp = DescriptorTypeOp; 1206 1.1.1.4 christos Info.CurrentByteOffset = CurrentByteOffset; 1207 1.1.1.4 christos 1208 1.1.1.9 christos DescriptorTypeOp->Asl.CompileFlags |= OP_IS_RESOURCE_DESC; 1209 1.1.1.4 christos Rnode = RsDoOneResourceDescriptor (&Info, &State); 1210 1.1 jruoho 1211 1.1 jruoho /* 1212 1.1 jruoho * Update current byte offset to indicate the number of bytes from the 1213 1.1.1.3 christos * start of the buffer. Buffer can include multiple descriptors, we 1214 1.1 jruoho * must keep track of the offset of not only each descriptor, but each 1215 1.1 jruoho * element (field) within each descriptor as well. 1216 1.1 jruoho */ 1217 1.1 jruoho CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode); 1218 1.1 jruoho 1219 1.1 jruoho /* Get the next descriptor in the list */ 1220 1.1 jruoho 1221 1.1 jruoho LastOp = DescriptorTypeOp; 1222 1.1 jruoho DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp); 1223 1.1 jruoho } 1224 1.1 jruoho 1225 1.1 jruoho if (State == ACPI_RSTATE_DEPENDENT_LIST) 1226 1.1 jruoho { 1227 1.1 jruoho if (LastOp) 1228 1.1 jruoho { 1229 1.1 jruoho LastOp = LastOp->Asl.Parent; 1230 1.1 jruoho } 1231 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL); 1232 1.1 jruoho } 1233 1.1 jruoho 1234 1.1 jruoho /* 1235 1.1 jruoho * Transform the nodes into the following 1236 1.1 jruoho * 1237 1.1 jruoho * Op -> AML_BUFFER_OP 1238 1.1 jruoho * First Child -> BufferLength 1239 1.1 jruoho * Second Child -> Descriptor Buffer (raw byte data) 1240 1.1 jruoho */ 1241 1.1 jruoho Op->Asl.ParseOpcode = PARSEOP_BUFFER; 1242 1.1 jruoho Op->Asl.AmlOpcode = AML_BUFFER_OP; 1243 1.1.1.9 christos Op->Asl.CompileFlags = OP_AML_PACKAGE | OP_IS_RESOURCE_DESC; 1244 1.1.1.3 christos UtSetParseOpName (Op); 1245 1.1 jruoho 1246 1.1 jruoho BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; 1247 1.1 jruoho BufferLengthOp->Asl.Value.Integer = CurrentByteOffset; 1248 1.1 jruoho (void) OpcSetOptimalIntegerSize (BufferLengthOp); 1249 1.1.1.3 christos UtSetParseOpName (BufferLengthOp); 1250 1.1 jruoho 1251 1.1 jruoho BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; 1252 1.1 jruoho BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN; 1253 1.1 jruoho BufferOp->Asl.AmlOpcodeLength = 0; 1254 1.1 jruoho BufferOp->Asl.AmlLength = CurrentByteOffset; 1255 1.1.1.13 christos BufferOp->Asl.Value.Buffer = ACPI_CAST_PTR (UINT8, HeadRnode.Next); 1256 1.1.1.9 christos BufferOp->Asl.CompileFlags |= OP_IS_RESOURCE_DATA; 1257 1.1.1.3 christos UtSetParseOpName (BufferOp); 1258 1.1 jruoho 1259 1.1 jruoho return; 1260 1.1 jruoho } 1261