nsxfname.c revision 7b1019a6d29ccb7999dc76cba3dde1c627e8e609
/******************************************************************************
*
* Module Name: nsxfname - Public interfaces to the ACPI subsystem
* ACPI Namespace oriented interfaces
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define EXPORT_ACPI_INTERFACES
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
#include "acparser.h"
#include "amlcode.h"
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsxfname")
/* Local prototypes */
static char *
char *StringArea);
/******************************************************************************
*
* FUNCTION: AcpiGetHandle
*
* PARAMETERS: Parent - Object to search under (search scope).
* Pathname - Pointer to an asciiz string containing the
* name
* RetHandle - Where the return handle is returned
*
* RETURN: Status
*
* DESCRIPTION: This routine will search for a caller specified name in the
* name space. The caller can restrict the search region by
* specifying a non NULL parent. The parent value is itself a
* namespace handle.
*
******************************************************************************/
{
/* Parameter Validation */
{
return (AE_BAD_PARAMETER);
}
/* Convert a parent handle to a prefix node */
if (Parent)
{
if (!PrefixNode)
{
return (AE_BAD_PARAMETER);
}
}
/*
* Valid cases are:
* 1) Fully qualified pathname
* 2) Parent + Relative pathname
*
* Error for <null Parent + relative path>
*/
if (ACPI_IS_ROOT_PREFIX (Pathname[0]))
{
/* Pathname is fully qualified (starts with '\') */
/* Special case for root-only, since we can't search for it */
{
return (AE_OK);
}
}
else if (!PrefixNode)
{
/* Relative path with null prefix is disallowed */
return (AE_BAD_PARAMETER);
}
/* Find the Node and convert to a handle */
if (ACPI_SUCCESS (Status))
{
}
return (Status);
}
/******************************************************************************
*
* FUNCTION: AcpiGetName
*
* PARAMETERS: Handle - Handle to be converted to a pathname
* NameType - Full pathname or single segment
* Buffer - Buffer for returned path
*
* RETURN: Pointer to a string containing the fully qualified Name.
*
* DESCRIPTION: This routine returns the fully qualified name associated with
* the Handle parameter. This and the AcpiPathnameToHandle are
* complementary functions.
*
******************************************************************************/
{
const char *NodeName;
/* Parameter validation */
if (NameType > ACPI_NAME_TYPE_MAX)
{
return (AE_BAD_PARAMETER);
}
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (NameType == ACPI_FULL_PATHNAME ||
{
/* Get the full pathname (From the namespace root) */
return (Status);
}
/*
* Wants the single segment ACPI name.
* Validate handle and convert to a namespace Node
*/
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (!Node)
{
goto UnlockAndExit;
}
if (ACPI_FAILURE (Status))
{
goto UnlockAndExit;
}
/* Just copy the ACPI name from the Node and zero terminate it */
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
/******************************************************************************
*
* FUNCTION: AcpiNsCopyDeviceId
*
* PARAMETERS: Dest - Pointer to the destination PNP_DEVICE_ID
* Source - Pointer to the source PNP_DEVICE_ID
* StringArea - Pointer to where to copy the dest string
*
* RETURN: Pointer to the next string area
*
* DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data.
*
******************************************************************************/
static char *
char *StringArea)
{
/* Create the destination PNP_DEVICE_ID */
/* Copy actual string and return a pointer to the next string area */
}
/******************************************************************************
*
* FUNCTION: AcpiGetObjectInfo
*
* PARAMETERS: Handle - Object Handle
* ReturnBuffer - Where the info is returned
*
* RETURN: Status
*
* DESCRIPTION: Returns information about an object as gleaned from the
* namespace node and possibly by running several standard
* control methods (Such as in the case of a device.)
*
* For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
* _CLS, _ADR, _SxW, and _SxD methods.
*
* Note: Allocates the return buffer, must be freed by the caller.
*
* Note: This interface is intended to be used during the initial device
* discovery namespace traversal. Therefore, no complex methods can be
* executed, especially those that access operation regions. Therefore, do
* not add any additional methods that could cause problems in this area.
* this was the fate of the _SUB method which was found to cause such
* problems and was removed (11/2015).
*
******************************************************************************/
{
char *NextIdString;
UINT8 ParamCount= 0;
UINT32 i;
/* Parameter validation */
if (!Handle || !ReturnBuffer)
{
return (AE_BAD_PARAMETER);
}
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (!Node)
{
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (AE_BAD_PARAMETER);
}
/* Get the namespace node data while the namespace is locked */
InfoSize = sizeof (ACPI_DEVICE_INFO);
{
}
if (ACPI_FAILURE (Status))
{
return (Status);
}
if ((Type == ACPI_TYPE_DEVICE) ||
(Type == ACPI_TYPE_PROCESSOR))
{
/*
* Run the Device _HID, _UID, _CLS, and _CID methods.
*
* Note: none of these methods are required, so they may or may
* not be present for this device. The Info->Valid bitfield is used
* to indicate which methods were found and run successfully.
*/
/* Execute the Device._HID method */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_HID;
}
/* Execute the Device._UID method */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_UID;
}
/* Execute the Device._CID method */
if (ACPI_SUCCESS (Status))
{
/* Add size of CID strings and CID pointer array */
Valid |= ACPI_VALID_CID;
}
/* Execute the Device._CLS method */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_CLS;
}
}
/*
* Now that we have the variable-length data, we can allocate the
* return buffer
*/
if (!Info)
{
goto Cleanup;
}
/* Get the fixed-length data */
if ((Type == ACPI_TYPE_DEVICE) ||
(Type == ACPI_TYPE_PROCESSOR))
{
/*
* Run the _STA, _ADR and, SxW, and _SxD methods.
*
* Notes: none of these methods are required, so they may or may
* not be present for this device. The Info->Valid bitfield is used
* to indicate which methods were found and run successfully.
*
* For _STA, if the method does not exist, then (as per the ACPI
* specification), the returned CurrentStatus flags will indicate
* that the device is present/functional/enabled. Otherwise, the
* CurrentStatus flags reflect the value returned from _STA.
*/
/* Execute the Device._STA method */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_STA;
}
/* Execute the Device._ADR method */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_ADR;
}
/* Execute the Device._SxW methods */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_SXWS;
}
/* Execute the Device._SxD methods */
if (ACPI_SUCCESS (Status))
{
Valid |= ACPI_VALID_SXDS;
}
}
/*
* Create a pointer to the string area of the return buffer.
* Point to the end of the base ACPI_DEVICE_INFO structure.
*/
if (CidList)
{
/* Point past the CID PNP_DEVICE_ID array */
}
/*
* Copy the HID, UID, and CIDs to the return buffer. The variable-length
* strings are copied to the reserved area at the end of the buffer.
*
* For HID and CID, check if the ID is a PCI Root Bridge.
*/
if (Hid)
{
Hid, NextIdString);
{
}
}
if (Uid)
{
Uid, NextIdString);
}
if (CidList)
{
/* Copy each CID */
{
{
}
}
}
if (Cls)
{
Cls, NextIdString);
}
/* Copy the fixed-length data */
*ReturnBuffer = Info;
if (Hid)
{
}
if (Uid)
{
}
if (CidList)
{
}
if (Cls)
{
}
return (Status);
}
/******************************************************************************
*
* FUNCTION: AcpiInstallMethod
*
* PARAMETERS: Buffer - An ACPI table containing one control method
*
* RETURN: Status
*
* DESCRIPTION: Install a control method into the namespace. If the method
* name already exists in the namespace, it is overwritten. The
* input buffer must contain a valid DSDT or SSDT containing a
* single control method.
*
******************************************************************************/
{
char *Path;
/* Parameter validation */
if (!Buffer)
{
return (AE_BAD_PARAMETER);
}
/* Table must be a DSDT or SSDT */
{
return (AE_BAD_HEADER);
}
/* First AML opcode in the table must be a control method */
if (Opcode != AML_METHOD_OP)
{
return (AE_BAD_PARAMETER);
}
/* Extract method information from the raw AML */
/*
* Allocate resources up-front. We don't want to have to delete a new
* node from the namespace if we cannot allocate memory.
*/
if (!AmlBuffer)
{
return (AE_NO_MEMORY);
}
if (!MethodObj)
{
return (AE_NO_MEMORY);
}
/* Lock namespace for AcpiNsLookup, we may be creating a new node */
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
/* The lookup either returns an existing node or creates a new one */
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
{
if (Status != AE_ALREADY_EXISTS)
{
goto ErrorExit;
}
/* Node existed previously, make sure it is a method node */
{
goto ErrorExit;
}
}
/* Copy the method AML to the local buffer */
/* Initialize the method object with the new method's information */
if (MethodFlags & AML_METHOD_SERIALIZED)
{
}
/*
* Now that it is complete, we can attach the new method object to
*/
/*
* Flag indicates AML buffer is dynamic, must be deleted later.
* Must be set only after attach above.
*/
/* Remove local reference to the method object */
return (Status);
return (Status);
}