1114239Snjl/****************************************************************************** 2114239Snjl * 3114239Snjl * Module Name: dsinit - Object initialization namespace walk 4114239Snjl * 5114239Snjl *****************************************************************************/ 6114239Snjl 7316303Sjkim/****************************************************************************** 8316303Sjkim * 9316303Sjkim * 1. Copyright Notice 10316303Sjkim * 11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 12114239Snjl * All rights reserved. 13114239Snjl * 14316303Sjkim * 2. License 15316303Sjkim * 16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17316303Sjkim * rights. You may have additional license terms from the party that provided 18316303Sjkim * you this software, covering your right to use that party's intellectual 19316303Sjkim * property rights. 20316303Sjkim * 21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 26316303Sjkim * Code in any form, with the right to sublicense such rights; and 27316303Sjkim * 28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29316303Sjkim * license (with the right to sublicense), under only those claims of Intel 30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 33316303Sjkim * license, and in no event shall the patent license extend to any additions 34316303Sjkim * to or modifications of the Original Intel Code. No other license or right 35316303Sjkim * is granted directly or by implication, estoppel or otherwise; 36316303Sjkim * 37316303Sjkim * The above copyright and patent license is granted only if the following 38316303Sjkim * conditions are met: 39316303Sjkim * 40316303Sjkim * 3. Conditions 41316303Sjkim * 42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43316303Sjkim * Redistribution of source code of any substantial portion of the Covered 44316303Sjkim * Code or modification with rights to further distribute source must include 45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 49316303Sjkim * Code and the date of any change. Licensee must include in that file the 50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51316303Sjkim * must include a prominent statement that the modification is derived, 52316303Sjkim * directly or indirectly, from Original Intel Code. 53316303Sjkim * 54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55316303Sjkim * Redistribution of source code of any substantial portion of the Covered 56316303Sjkim * Code or modification without rights to further distribute source must 57316303Sjkim * include the following Disclaimer and Export Compliance provision in the 58316303Sjkim * documentation and/or other materials provided with distribution. In 59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 61316303Sjkim * license from Licensee to its licensee is limited to the intellectual 62316303Sjkim * property embodied in the software Licensee provides to its licensee, and 63316303Sjkim * not to intellectual property embodied in modifications its licensee may 64316303Sjkim * make. 65316303Sjkim * 66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69316303Sjkim * provision in the documentation and/or other materials provided with the 70316303Sjkim * distribution. 71316303Sjkim * 72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73316303Sjkim * Intel Code. 74316303Sjkim * 75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77316303Sjkim * other dealings in products derived from or relating to the Covered Code 78316303Sjkim * without prior written authorization from Intel. 79316303Sjkim * 80316303Sjkim * 4. Disclaimer and Export Compliance 81316303Sjkim * 82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88316303Sjkim * PARTICULAR PURPOSE. 89316303Sjkim * 90316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97316303Sjkim * LIMITED REMEDY. 98316303Sjkim * 99316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100316303Sjkim * software or system incorporating such software without first obtaining any 101316303Sjkim * required license or other approval from the U. S. Department of Commerce or 102316303Sjkim * any other agency or department of the United States Government. In the 103316303Sjkim * event Licensee exports any such software from the United States or 104316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 105316303Sjkim * ensure that the distribution and export/re-export of the software is in 106316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109316303Sjkim * software, or service, directly or indirectly, to any country for which the 110316303Sjkim * United States government or any agency thereof requires an export license, 111316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 112316303Sjkim * such license, approval or letter. 113316303Sjkim * 114316303Sjkim ***************************************************************************** 115316303Sjkim * 116316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 117316303Sjkim * following license: 118316303Sjkim * 119217365Sjkim * Redistribution and use in source and binary forms, with or without 120217365Sjkim * modification, are permitted provided that the following conditions 121217365Sjkim * are met: 122217365Sjkim * 1. Redistributions of source code must retain the above copyright 123217365Sjkim * notice, this list of conditions, and the following disclaimer, 124217365Sjkim * without modification. 125217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 127217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 128217365Sjkim * including a substantially similar Disclaimer requirement for further 129217365Sjkim * binary redistribution. 130217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 131217365Sjkim * of any contributors may be used to endorse or promote products derived 132217365Sjkim * from this software without specific prior written permission. 133114239Snjl * 134316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145316303Sjkim * 146316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 147217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 148217365Sjkim * Software Foundation. 149114239Snjl * 150316303Sjkim *****************************************************************************/ 151114239Snjl 152193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 153193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 154193341Sjkim#include <contrib/dev/acpica/include/acdispat.h> 155193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 156193341Sjkim#include <contrib/dev/acpica/include/actables.h> 157316303Sjkim#include <contrib/dev/acpica/include/acinterp.h> 158114239Snjl 159114239Snjl#define _COMPONENT ACPI_DISPATCHER 160114239Snjl ACPI_MODULE_NAME ("dsinit") 161114239Snjl 162272444Sjkim 163151937Sjkim/* Local prototypes */ 164114239Snjl 165151937Sjkimstatic ACPI_STATUS 166151937SjkimAcpiDsInitOneObject ( 167151937Sjkim ACPI_HANDLE ObjHandle, 168151937Sjkim UINT32 Level, 169151937Sjkim void *Context, 170151937Sjkim void **ReturnValue); 171151937Sjkim 172151937Sjkim 173114239Snjl/******************************************************************************* 174114239Snjl * 175114239Snjl * FUNCTION: AcpiDsInitOneObject 176114239Snjl * 177151937Sjkim * PARAMETERS: ObjHandle - Node for the object 178114239Snjl * Level - Current nesting level 179114239Snjl * Context - Points to a init info struct 180114239Snjl * ReturnValue - Not used 181114239Snjl * 182114239Snjl * RETURN: Status 183114239Snjl * 184241973Sjkim * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object 185114239Snjl * within the namespace. 186114239Snjl * 187114239Snjl * Currently, the only objects that require initialization are: 188114239Snjl * 1) Methods 189114239Snjl * 2) Operation Regions 190114239Snjl * 191114239Snjl ******************************************************************************/ 192114239Snjl 193151937Sjkimstatic ACPI_STATUS 194114239SnjlAcpiDsInitOneObject ( 195114239Snjl ACPI_HANDLE ObjHandle, 196114239Snjl UINT32 Level, 197114239Snjl void *Context, 198114239Snjl void **ReturnValue) 199114239Snjl{ 200151937Sjkim ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; 201151937Sjkim ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 202114239Snjl ACPI_STATUS Status; 203272444Sjkim ACPI_OPERAND_OBJECT *ObjDesc; 204114239Snjl 205114239Snjl 206167802Sjkim ACPI_FUNCTION_ENTRY (); 207114239Snjl 208114239Snjl 209114239Snjl /* 210151937Sjkim * We are only interested in NS nodes owned by the table that 211114239Snjl * was just loaded 212114239Snjl */ 213167802Sjkim if (Node->OwnerId != Info->OwnerId) 214114239Snjl { 215114239Snjl return (AE_OK); 216114239Snjl } 217114239Snjl 218114239Snjl Info->ObjectCount++; 219114239Snjl 220114239Snjl /* And even then, we are only interested in a few object types */ 221114239Snjl 222272444Sjkim switch (AcpiNsGetType (ObjHandle)) 223114239Snjl { 224114239Snjl case ACPI_TYPE_REGION: 225114239Snjl 226114239Snjl Status = AcpiDsInitializeRegion (ObjHandle); 227114239Snjl if (ACPI_FAILURE (Status)) 228114239Snjl { 229167802Sjkim ACPI_EXCEPTION ((AE_INFO, Status, 230167802Sjkim "During Region initialization %p [%4.4s]", 231167802Sjkim ObjHandle, AcpiUtGetNodeName (ObjHandle))); 232114239Snjl } 233114239Snjl 234114239Snjl Info->OpRegionCount++; 235114239Snjl break; 236114239Snjl 237114239Snjl case ACPI_TYPE_METHOD: 238272444Sjkim /* 239272444Sjkim * Auto-serialization support. We will examine each method that is 240272444Sjkim * NotSerialized to determine if it creates any Named objects. If 241272444Sjkim * it does, it will be marked serialized to prevent problems if 242272444Sjkim * the method is entered by two or more threads and an attempt is 243272444Sjkim * made to create the same named object twice -- which results in 244272444Sjkim * an AE_ALREADY_EXISTS exception and method abort. 245272444Sjkim */ 246272444Sjkim Info->MethodCount++; 247272444Sjkim ObjDesc = AcpiNsGetAttachedObject (Node); 248272444Sjkim if (!ObjDesc) 249272444Sjkim { 250272444Sjkim break; 251272444Sjkim } 252114239Snjl 253272444Sjkim /* Ignore if already serialized */ 254272444Sjkim 255272444Sjkim if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED) 256272444Sjkim { 257272444Sjkim Info->SerialMethodCount++; 258272444Sjkim break; 259272444Sjkim } 260272444Sjkim 261272444Sjkim if (AcpiGbl_AutoSerializeMethods) 262272444Sjkim { 263272444Sjkim /* Parse/scan method and serialize it if necessary */ 264272444Sjkim 265272444Sjkim AcpiDsAutoSerializeMethod (Node, ObjDesc); 266272444Sjkim if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED) 267272444Sjkim { 268272444Sjkim /* Method was just converted to Serialized */ 269272444Sjkim 270272444Sjkim Info->SerialMethodCount++; 271272444Sjkim Info->SerializedMethodCount++; 272272444Sjkim break; 273272444Sjkim } 274272444Sjkim } 275272444Sjkim 276272444Sjkim Info->NonSerialMethodCount++; 277114239Snjl break; 278114239Snjl 279114239Snjl case ACPI_TYPE_DEVICE: 280114239Snjl 281114239Snjl Info->DeviceCount++; 282114239Snjl break; 283114239Snjl 284250838Sjkim default: 285114239Snjl 286114239Snjl break; 287114239Snjl } 288114239Snjl 289114239Snjl /* 290114239Snjl * We ignore errors from above, and always return OK, since 291114239Snjl * we don't want to abort the walk on a single error. 292114239Snjl */ 293114239Snjl return (AE_OK); 294114239Snjl} 295114239Snjl 296114239Snjl 297114239Snjl/******************************************************************************* 298114239Snjl * 299114239Snjl * FUNCTION: AcpiDsInitializeObjects 300114239Snjl * 301114239Snjl * PARAMETERS: TableDesc - Descriptor for parent ACPI table 302114239Snjl * StartNode - Root of subtree to be initialized. 303114239Snjl * 304114239Snjl * RETURN: Status 305114239Snjl * 306114239Snjl * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any 307114239Snjl * necessary initialization on the objects found therein 308114239Snjl * 309114239Snjl ******************************************************************************/ 310114239Snjl 311114239SnjlACPI_STATUS 312114239SnjlAcpiDsInitializeObjects ( 313193267Sjkim UINT32 TableIndex, 314114239Snjl ACPI_NAMESPACE_NODE *StartNode) 315114239Snjl{ 316114239Snjl ACPI_STATUS Status; 317114239Snjl ACPI_INIT_WALK_INFO Info; 318167802Sjkim ACPI_TABLE_HEADER *Table; 319167802Sjkim ACPI_OWNER_ID OwnerId; 320114239Snjl 321114239Snjl 322167802Sjkim ACPI_FUNCTION_TRACE (DsInitializeObjects); 323114239Snjl 324114239Snjl 325167802Sjkim Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); 326167802Sjkim if (ACPI_FAILURE (Status)) 327167802Sjkim { 328167802Sjkim return_ACPI_STATUS (Status); 329167802Sjkim } 330167802Sjkim 331114239Snjl ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 332114239Snjl "**** Starting initialization of namespace objects ****\n")); 333114239Snjl 334209746Sjkim /* Set all init info to zero */ 335114239Snjl 336284583Sjkim memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); 337209746Sjkim 338209746Sjkim Info.OwnerId = OwnerId; 339209746Sjkim Info.TableIndex = TableIndex; 340209746Sjkim 341114239Snjl /* Walk entire namespace from the supplied root */ 342114239Snjl 343193267Sjkim /* 344193267Sjkim * We don't use AcpiWalkNamespace since we do not want to acquire 345193267Sjkim * the namespace reader lock. 346193267Sjkim */ 347193267Sjkim Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, 348316303Sjkim ACPI_NS_WALK_NO_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); 349193267Sjkim if (ACPI_FAILURE (Status)) 350193267Sjkim { 351167802Sjkim ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); 352114239Snjl } 353114239Snjl 354167802Sjkim Status = AcpiGetTableByIndex (TableIndex, &Table); 355167802Sjkim if (ACPI_FAILURE (Status)) 356167802Sjkim { 357167802Sjkim return_ACPI_STATUS (Status); 358167802Sjkim } 359167802Sjkim 360287168Sjkim /* DSDT is always the first AML table */ 361287168Sjkim 362287168Sjkim if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT)) 363287168Sjkim { 364298714Sjkim ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 365298714Sjkim "\nInitializing Namespace objects:\n")); 366287168Sjkim } 367287168Sjkim 368287168Sjkim /* Summary of objects initialized */ 369287168Sjkim 370114239Snjl ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 371298714Sjkim "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, " 372287168Sjkim "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n", 373298714Sjkim Table->Signature, Table->OemTableId, OwnerId, Info.ObjectCount, 374298714Sjkim Info.DeviceCount,Info.OpRegionCount, Info.MethodCount, 375298714Sjkim Info.SerialMethodCount, Info.NonSerialMethodCount, 376298714Sjkim Info.SerializedMethodCount)); 377114239Snjl 378272444Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n", 379272444Sjkim Info.MethodCount, Info.OpRegionCount)); 380114239Snjl 381114239Snjl return_ACPI_STATUS (AE_OK); 382114239Snjl} 383