1a88e22b7SJung-uk Kim /****************************************************************************** 2a88e22b7SJung-uk Kim * 3a88e22b7SJung-uk Kim * Module Name: dtsubtable.c - handling of subtables within ACPI tables 4a88e22b7SJung-uk Kim * 5a88e22b7SJung-uk Kim *****************************************************************************/ 6a88e22b7SJung-uk Kim 70d84335fSJung-uk Kim /****************************************************************************** 80d84335fSJung-uk Kim * 90d84335fSJung-uk Kim * 1. Copyright Notice 100d84335fSJung-uk Kim * 110d84335fSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 12a88e22b7SJung-uk Kim * All rights reserved. 13a88e22b7SJung-uk Kim * 140d84335fSJung-uk Kim * 2. License 150d84335fSJung-uk Kim * 160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 190d84335fSJung-uk Kim * property rights. 200d84335fSJung-uk Kim * 210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 270d84335fSJung-uk Kim * 280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 360d84335fSJung-uk Kim * 370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 380d84335fSJung-uk Kim * conditions are met: 390d84335fSJung-uk Kim * 400d84335fSJung-uk Kim * 3. Conditions 410d84335fSJung-uk Kim * 420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 530d84335fSJung-uk Kim * 540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 640d84335fSJung-uk Kim * make. 650d84335fSJung-uk Kim * 660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 700d84335fSJung-uk Kim * distribution. 710d84335fSJung-uk Kim * 720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 730d84335fSJung-uk Kim * Intel Code. 740d84335fSJung-uk Kim * 750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 780d84335fSJung-uk Kim * without prior written authorization from Intel. 790d84335fSJung-uk Kim * 800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 810d84335fSJung-uk Kim * 820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 880d84335fSJung-uk Kim * PARTICULAR PURPOSE. 890d84335fSJung-uk Kim * 900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 970d84335fSJung-uk Kim * LIMITED REMEDY. 980d84335fSJung-uk Kim * 990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 1120d84335fSJung-uk Kim * such license, approval or letter. 1130d84335fSJung-uk Kim * 1140d84335fSJung-uk Kim ***************************************************************************** 1150d84335fSJung-uk Kim * 1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 1170d84335fSJung-uk Kim * following license: 1180d84335fSJung-uk Kim * 119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions 121d244b227SJung-uk Kim * are met: 122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124d244b227SJung-uk Kim * without modification. 125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129d244b227SJung-uk Kim * binary redistribution. 130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132d244b227SJung-uk Kim * from this software without specific prior written permission. 133a88e22b7SJung-uk Kim * 1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1450d84335fSJung-uk Kim * 1460d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148d244b227SJung-uk Kim * Software Foundation. 149a88e22b7SJung-uk Kim * 1500d84335fSJung-uk Kim *****************************************************************************/ 151a88e22b7SJung-uk Kim 152a88e22b7SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 153a88e22b7SJung-uk Kim 154a88e22b7SJung-uk Kim #define _COMPONENT DT_COMPILER 155a88e22b7SJung-uk Kim ACPI_MODULE_NAME ("dtsubtable") 156a88e22b7SJung-uk Kim 157a88e22b7SJung-uk Kim 158a88e22b7SJung-uk Kim /****************************************************************************** 159a88e22b7SJung-uk Kim * 160a88e22b7SJung-uk Kim * FUNCTION: DtCreateSubtable 161a88e22b7SJung-uk Kim * 162a88e22b7SJung-uk Kim * PARAMETERS: Buffer - Input buffer 163a88e22b7SJung-uk Kim * Length - Buffer length 164a88e22b7SJung-uk Kim * RetSubtable - Returned newly created subtable 165a88e22b7SJung-uk Kim * 166a88e22b7SJung-uk Kim * RETURN: None 167a88e22b7SJung-uk Kim * 168a88e22b7SJung-uk Kim * DESCRIPTION: Create a subtable that is not listed with ACPI_DMTABLE_INFO 169a88e22b7SJung-uk Kim * For example, FACS has 24 bytes reserved at the end 170a88e22b7SJung-uk Kim * and it's not listed at AcpiDmTableInfoFacs 171a88e22b7SJung-uk Kim * 172a88e22b7SJung-uk Kim *****************************************************************************/ 173a88e22b7SJung-uk Kim 174a88e22b7SJung-uk Kim void 175a88e22b7SJung-uk Kim DtCreateSubtable ( 176a88e22b7SJung-uk Kim UINT8 *Buffer, 177a88e22b7SJung-uk Kim UINT32 Length, 178a88e22b7SJung-uk Kim DT_SUBTABLE **RetSubtable) 179a88e22b7SJung-uk Kim { 180a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable; 181313a0c13SJung-uk Kim char *String; 182a88e22b7SJung-uk Kim 183a88e22b7SJung-uk Kim 184313a0c13SJung-uk Kim Subtable = UtSubtableCacheCalloc (); 185a88e22b7SJung-uk Kim 186a88e22b7SJung-uk Kim /* Create a new buffer for the subtable data */ 187a88e22b7SJung-uk Kim 188*67d9aa44SJung-uk Kim String = UtLocalCacheCalloc (Length); 189313a0c13SJung-uk Kim Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); 1905ef50723SJung-uk Kim memcpy (Subtable->Buffer, Buffer, Length); 191a88e22b7SJung-uk Kim 192a88e22b7SJung-uk Kim Subtable->Length = Length; 193a88e22b7SJung-uk Kim Subtable->TotalLength = Length; 194a88e22b7SJung-uk Kim 195a88e22b7SJung-uk Kim *RetSubtable = Subtable; 196a88e22b7SJung-uk Kim } 197a88e22b7SJung-uk Kim 198a88e22b7SJung-uk Kim 199a88e22b7SJung-uk Kim /****************************************************************************** 200a88e22b7SJung-uk Kim * 201a88e22b7SJung-uk Kim * FUNCTION: DtInsertSubtable 202a88e22b7SJung-uk Kim * 203a88e22b7SJung-uk Kim * PARAMETERS: ParentTable - The Parent of the new subtable 204a88e22b7SJung-uk Kim * Subtable - The new subtable to insert 205a88e22b7SJung-uk Kim * 206a88e22b7SJung-uk Kim * RETURN: None 207a88e22b7SJung-uk Kim * 208a88e22b7SJung-uk Kim * DESCRIPTION: Insert the new subtable to the parent table 209a88e22b7SJung-uk Kim * 210a88e22b7SJung-uk Kim *****************************************************************************/ 211a88e22b7SJung-uk Kim 212a88e22b7SJung-uk Kim void 213a88e22b7SJung-uk Kim DtInsertSubtable ( 214a88e22b7SJung-uk Kim DT_SUBTABLE *ParentTable, 215a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable) 216a88e22b7SJung-uk Kim { 217a88e22b7SJung-uk Kim DT_SUBTABLE *ChildTable; 218a88e22b7SJung-uk Kim 219a88e22b7SJung-uk Kim 220a88e22b7SJung-uk Kim Subtable->Peer = NULL; 221a88e22b7SJung-uk Kim Subtable->Parent = ParentTable; 222efcc2a30SJung-uk Kim Subtable->Depth = ParentTable->Depth + 1; 223a88e22b7SJung-uk Kim 224a88e22b7SJung-uk Kim /* Link the new entry into the child list */ 225a88e22b7SJung-uk Kim 226a88e22b7SJung-uk Kim if (!ParentTable->Child) 227a88e22b7SJung-uk Kim { 228a88e22b7SJung-uk Kim ParentTable->Child = Subtable; 229a88e22b7SJung-uk Kim } 230a88e22b7SJung-uk Kim else 231a88e22b7SJung-uk Kim { 232a88e22b7SJung-uk Kim /* Walk to the end of the child list */ 233a88e22b7SJung-uk Kim 234a88e22b7SJung-uk Kim ChildTable = ParentTable->Child; 235a88e22b7SJung-uk Kim while (ChildTable->Peer) 236a88e22b7SJung-uk Kim { 237a88e22b7SJung-uk Kim ChildTable = ChildTable->Peer; 238a88e22b7SJung-uk Kim } 239a88e22b7SJung-uk Kim 240a88e22b7SJung-uk Kim /* Add new subtable at the end of the child list */ 241a88e22b7SJung-uk Kim 242a88e22b7SJung-uk Kim ChildTable->Peer = Subtable; 243a88e22b7SJung-uk Kim } 244a88e22b7SJung-uk Kim } 245a88e22b7SJung-uk Kim 246a88e22b7SJung-uk Kim 247a88e22b7SJung-uk Kim /****************************************************************************** 248a88e22b7SJung-uk Kim * 249a88e22b7SJung-uk Kim * FUNCTION: DtPushSubtable 250a88e22b7SJung-uk Kim * 251a88e22b7SJung-uk Kim * PARAMETERS: Subtable - Subtable to push 252a88e22b7SJung-uk Kim * 253a88e22b7SJung-uk Kim * RETURN: None 254a88e22b7SJung-uk Kim * 255a88e22b7SJung-uk Kim * DESCRIPTION: Push a subtable onto a subtable stack 256a88e22b7SJung-uk Kim * 257a88e22b7SJung-uk Kim *****************************************************************************/ 258a88e22b7SJung-uk Kim 259a88e22b7SJung-uk Kim void 260a88e22b7SJung-uk Kim DtPushSubtable ( 261a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable) 262a88e22b7SJung-uk Kim { 263a88e22b7SJung-uk Kim 264a88e22b7SJung-uk Kim Subtable->StackTop = Gbl_SubtableStack; 265a88e22b7SJung-uk Kim Gbl_SubtableStack = Subtable; 266a88e22b7SJung-uk Kim } 267a88e22b7SJung-uk Kim 268a88e22b7SJung-uk Kim 269a88e22b7SJung-uk Kim /****************************************************************************** 270a88e22b7SJung-uk Kim * 271a88e22b7SJung-uk Kim * FUNCTION: DtPopSubtable 272a88e22b7SJung-uk Kim * 273a88e22b7SJung-uk Kim * PARAMETERS: None 274a88e22b7SJung-uk Kim * 275a88e22b7SJung-uk Kim * RETURN: None 276a88e22b7SJung-uk Kim * 277a88e22b7SJung-uk Kim * DESCRIPTION: Pop a subtable from a subtable stack. Uses global SubtableStack 278a88e22b7SJung-uk Kim * 279a88e22b7SJung-uk Kim *****************************************************************************/ 280a88e22b7SJung-uk Kim 281a88e22b7SJung-uk Kim void 282a88e22b7SJung-uk Kim DtPopSubtable ( 283a88e22b7SJung-uk Kim void) 284a88e22b7SJung-uk Kim { 285a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable; 286a88e22b7SJung-uk Kim 287a88e22b7SJung-uk Kim 288a88e22b7SJung-uk Kim Subtable = Gbl_SubtableStack; 289a88e22b7SJung-uk Kim 290a88e22b7SJung-uk Kim if (Subtable) 291a88e22b7SJung-uk Kim { 292a88e22b7SJung-uk Kim Gbl_SubtableStack = Subtable->StackTop; 293a88e22b7SJung-uk Kim } 294a88e22b7SJung-uk Kim } 295a88e22b7SJung-uk Kim 296a88e22b7SJung-uk Kim 297a88e22b7SJung-uk Kim /****************************************************************************** 298a88e22b7SJung-uk Kim * 299a88e22b7SJung-uk Kim * FUNCTION: DtPeekSubtable 300a88e22b7SJung-uk Kim * 301a88e22b7SJung-uk Kim * PARAMETERS: None 302a88e22b7SJung-uk Kim * 303a88e22b7SJung-uk Kim * RETURN: The subtable on top of stack 304a88e22b7SJung-uk Kim * 305a88e22b7SJung-uk Kim * DESCRIPTION: Get the subtable on top of stack 306a88e22b7SJung-uk Kim * 307a88e22b7SJung-uk Kim *****************************************************************************/ 308a88e22b7SJung-uk Kim 309a88e22b7SJung-uk Kim DT_SUBTABLE * 310a88e22b7SJung-uk Kim DtPeekSubtable ( 311a88e22b7SJung-uk Kim void) 312a88e22b7SJung-uk Kim { 313a88e22b7SJung-uk Kim 314a88e22b7SJung-uk Kim return (Gbl_SubtableStack); 315a88e22b7SJung-uk Kim } 316a88e22b7SJung-uk Kim 317a88e22b7SJung-uk Kim 318a88e22b7SJung-uk Kim /****************************************************************************** 319a88e22b7SJung-uk Kim * 320a88e22b7SJung-uk Kim * FUNCTION: DtGetNextSubtable 321a88e22b7SJung-uk Kim * 322a88e22b7SJung-uk Kim * PARAMETERS: ParentTable - Parent table whose children we are 323a88e22b7SJung-uk Kim * getting 324a88e22b7SJung-uk Kim * ChildTable - Previous child that was found. 325a88e22b7SJung-uk Kim * The NEXT child will be returned 326a88e22b7SJung-uk Kim * 327a88e22b7SJung-uk Kim * RETURN: Pointer to the NEXT child or NULL if none is found. 328a88e22b7SJung-uk Kim * 329a88e22b7SJung-uk Kim * DESCRIPTION: Return the next peer subtable within the tree. 330a88e22b7SJung-uk Kim * 331a88e22b7SJung-uk Kim *****************************************************************************/ 332a88e22b7SJung-uk Kim 333a88e22b7SJung-uk Kim DT_SUBTABLE * 334a88e22b7SJung-uk Kim DtGetNextSubtable ( 335a88e22b7SJung-uk Kim DT_SUBTABLE *ParentTable, 336a88e22b7SJung-uk Kim DT_SUBTABLE *ChildTable) 337a88e22b7SJung-uk Kim { 338a88e22b7SJung-uk Kim ACPI_FUNCTION_ENTRY (); 339a88e22b7SJung-uk Kim 340a88e22b7SJung-uk Kim 341a88e22b7SJung-uk Kim if (!ChildTable) 342a88e22b7SJung-uk Kim { 343a88e22b7SJung-uk Kim /* It's really the parent's _scope_ that we want */ 344a88e22b7SJung-uk Kim 345a88e22b7SJung-uk Kim return (ParentTable->Child); 346a88e22b7SJung-uk Kim } 347a88e22b7SJung-uk Kim 348a88e22b7SJung-uk Kim /* Otherwise just return the next peer (NULL if at end-of-list) */ 349a88e22b7SJung-uk Kim 350a88e22b7SJung-uk Kim return (ChildTable->Peer); 351a88e22b7SJung-uk Kim } 352a88e22b7SJung-uk Kim 353a88e22b7SJung-uk Kim 354a88e22b7SJung-uk Kim /****************************************************************************** 355a88e22b7SJung-uk Kim * 356a88e22b7SJung-uk Kim * FUNCTION: DtGetParentSubtable 357a88e22b7SJung-uk Kim * 358a88e22b7SJung-uk Kim * PARAMETERS: Subtable - Current subtable 359a88e22b7SJung-uk Kim * 360a88e22b7SJung-uk Kim * RETURN: Parent of the given subtable 361a88e22b7SJung-uk Kim * 362a88e22b7SJung-uk Kim * DESCRIPTION: Get the parent of the given subtable in the tree 363a88e22b7SJung-uk Kim * 364a88e22b7SJung-uk Kim *****************************************************************************/ 365a88e22b7SJung-uk Kim 366a88e22b7SJung-uk Kim DT_SUBTABLE * 367a88e22b7SJung-uk Kim DtGetParentSubtable ( 368a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable) 369a88e22b7SJung-uk Kim { 370a88e22b7SJung-uk Kim 371a88e22b7SJung-uk Kim if (!Subtable) 372a88e22b7SJung-uk Kim { 373a88e22b7SJung-uk Kim return (NULL); 374a88e22b7SJung-uk Kim } 375a88e22b7SJung-uk Kim 376a88e22b7SJung-uk Kim return (Subtable->Parent); 377a88e22b7SJung-uk Kim } 378a88e22b7SJung-uk Kim 379a88e22b7SJung-uk Kim 380a88e22b7SJung-uk Kim /****************************************************************************** 381a88e22b7SJung-uk Kim * 382a88e22b7SJung-uk Kim * FUNCTION: DtGetSubtableLength 383a88e22b7SJung-uk Kim * 384a88e22b7SJung-uk Kim * PARAMETERS: Field - Current field list pointer 385a88e22b7SJung-uk Kim * Info - Data table info 386a88e22b7SJung-uk Kim * 387a88e22b7SJung-uk Kim * RETURN: Subtable length 388a88e22b7SJung-uk Kim * 389a88e22b7SJung-uk Kim * DESCRIPTION: Get length of bytes needed to compile the subtable 390a88e22b7SJung-uk Kim * 391a88e22b7SJung-uk Kim *****************************************************************************/ 392a88e22b7SJung-uk Kim 393a88e22b7SJung-uk Kim UINT32 394a88e22b7SJung-uk Kim DtGetSubtableLength ( 395a88e22b7SJung-uk Kim DT_FIELD *Field, 396a88e22b7SJung-uk Kim ACPI_DMTABLE_INFO *Info) 397a88e22b7SJung-uk Kim { 398a88e22b7SJung-uk Kim UINT32 ByteLength = 0; 399d052a1ccSJung-uk Kim UINT8 Step; 400d052a1ccSJung-uk Kim UINT8 i; 401a88e22b7SJung-uk Kim 402a88e22b7SJung-uk Kim 403a88e22b7SJung-uk Kim /* Walk entire Info table; Null name terminates */ 404a88e22b7SJung-uk Kim 405a88e22b7SJung-uk Kim for (; Info->Name; Info++) 406a88e22b7SJung-uk Kim { 4073f0275a0SJung-uk Kim if (Info->Opcode == ACPI_DMT_EXTRA_TEXT) 4083f0275a0SJung-uk Kim { 4093f0275a0SJung-uk Kim continue; 4103f0275a0SJung-uk Kim } 4113f0275a0SJung-uk Kim 412d052a1ccSJung-uk Kim if (!Field) 413d052a1ccSJung-uk Kim { 414d052a1ccSJung-uk Kim goto Error; 415d052a1ccSJung-uk Kim } 416d052a1ccSJung-uk Kim 417a88e22b7SJung-uk Kim ByteLength += DtGetFieldLength (Field, Info); 418d052a1ccSJung-uk Kim 419d052a1ccSJung-uk Kim switch (Info->Opcode) 420d052a1ccSJung-uk Kim { 421d052a1ccSJung-uk Kim case ACPI_DMT_GAS: 422a9d8d09cSJung-uk Kim 423d052a1ccSJung-uk Kim Step = 5; 424d052a1ccSJung-uk Kim break; 425d052a1ccSJung-uk Kim 426d052a1ccSJung-uk Kim case ACPI_DMT_HESTNTFY: 427a9d8d09cSJung-uk Kim 428d052a1ccSJung-uk Kim Step = 9; 429d052a1ccSJung-uk Kim break; 430d052a1ccSJung-uk Kim 431a371a5fdSJung-uk Kim case ACPI_DMT_IORTMEM: 432a371a5fdSJung-uk Kim 433a371a5fdSJung-uk Kim Step = 10; 434a371a5fdSJung-uk Kim break; 435a371a5fdSJung-uk Kim 436d052a1ccSJung-uk Kim default: 437a9d8d09cSJung-uk Kim 438d052a1ccSJung-uk Kim Step = 1; 439d052a1ccSJung-uk Kim break; 440d052a1ccSJung-uk Kim } 441d052a1ccSJung-uk Kim 442d052a1ccSJung-uk Kim for (i = 0; i < Step; i++) 443d052a1ccSJung-uk Kim { 444d052a1ccSJung-uk Kim if (!Field) 445d052a1ccSJung-uk Kim { 446d052a1ccSJung-uk Kim goto Error; 447d052a1ccSJung-uk Kim } 448d052a1ccSJung-uk Kim 449d052a1ccSJung-uk Kim Field = Field->Next; 450d052a1ccSJung-uk Kim } 451a88e22b7SJung-uk Kim } 452a88e22b7SJung-uk Kim 453a88e22b7SJung-uk Kim return (ByteLength); 454d052a1ccSJung-uk Kim 455d052a1ccSJung-uk Kim Error: 456d052a1ccSJung-uk Kim if (!Field) 457d052a1ccSJung-uk Kim { 458d052a1ccSJung-uk Kim sprintf (MsgBuffer, "Found NULL field - Field name \"%s\" needed", 459d052a1ccSJung-uk Kim Info->Name); 460d052a1ccSJung-uk Kim DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); 461d052a1ccSJung-uk Kim } 462d052a1ccSJung-uk Kim 463d052a1ccSJung-uk Kim return (ASL_EOF); 464a88e22b7SJung-uk Kim } 465a88e22b7SJung-uk Kim 466a88e22b7SJung-uk Kim 467a88e22b7SJung-uk Kim /****************************************************************************** 468a88e22b7SJung-uk Kim * 469a88e22b7SJung-uk Kim * FUNCTION: DtSetSubtableLength 470a88e22b7SJung-uk Kim * 471a88e22b7SJung-uk Kim * PARAMETERS: Subtable - Subtable 472a88e22b7SJung-uk Kim * 473a88e22b7SJung-uk Kim * RETURN: None 474a88e22b7SJung-uk Kim * 475a88e22b7SJung-uk Kim * DESCRIPTION: Set length of the subtable into its length field 476a88e22b7SJung-uk Kim * 477a88e22b7SJung-uk Kim *****************************************************************************/ 478a88e22b7SJung-uk Kim 479a88e22b7SJung-uk Kim void 480a88e22b7SJung-uk Kim DtSetSubtableLength ( 481a88e22b7SJung-uk Kim DT_SUBTABLE *Subtable) 482a88e22b7SJung-uk Kim { 483a88e22b7SJung-uk Kim 484a88e22b7SJung-uk Kim if (!Subtable->LengthField) 485a88e22b7SJung-uk Kim { 486a88e22b7SJung-uk Kim return; 487a88e22b7SJung-uk Kim } 488a88e22b7SJung-uk Kim 4895ef50723SJung-uk Kim memcpy (Subtable->LengthField, &Subtable->TotalLength, 490a88e22b7SJung-uk Kim Subtable->SizeOfLengthField); 491a88e22b7SJung-uk Kim } 492