Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:04

0001 /******************************************************************************
0002  *
0003  * Module Name: utxface - External interfaces, miscellaneous utility functions
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #define EXPORT_ACPI_INTERFACES
0153 
0154 #include "acpi.h"
0155 #include "accommon.h"
0156 #include "acdebug.h"
0157 
0158 #define _COMPONENT          ACPI_UTILITIES
0159         ACPI_MODULE_NAME    ("utxface")
0160 
0161 
0162 /*******************************************************************************
0163  *
0164  * FUNCTION:    AcpiTerminate
0165  *
0166  * PARAMETERS:  None
0167  *
0168  * RETURN:      Status
0169  *
0170  * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
0171  *
0172  ******************************************************************************/
0173 
0174 ACPI_STATUS ACPI_INIT_FUNCTION
0175 AcpiTerminate (
0176     void)
0177 {
0178     ACPI_STATUS         Status;
0179 
0180 
0181     ACPI_FUNCTION_TRACE (AcpiTerminate);
0182 
0183 
0184     /* Shutdown and free all resources */
0185 
0186     AcpiUtSubsystemShutdown ();
0187 
0188     /* Free the mutex objects */
0189 
0190     AcpiUtMutexTerminate ();
0191 
0192     /* Now we can shutdown the OS-dependent layer */
0193 
0194     Status = AcpiOsTerminate ();
0195     return_ACPI_STATUS (Status);
0196 }
0197 
0198 ACPI_EXPORT_SYMBOL_INIT (AcpiTerminate)
0199 
0200 
0201 #ifndef ACPI_ASL_COMPILER
0202 /*******************************************************************************
0203  *
0204  * FUNCTION:    AcpiSubsystemStatus
0205  *
0206  * PARAMETERS:  None
0207  *
0208  * RETURN:      Status of the ACPI subsystem
0209  *
0210  * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
0211  *              before making any other calls, to ensure the subsystem
0212  *              initialized successfully.
0213  *
0214  ******************************************************************************/
0215 
0216 ACPI_STATUS
0217 AcpiSubsystemStatus (
0218     void)
0219 {
0220 
0221     if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
0222     {
0223         return (AE_OK);
0224     }
0225     else
0226     {
0227         return (AE_ERROR);
0228     }
0229 }
0230 
0231 ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus)
0232 
0233 
0234 /*******************************************************************************
0235  *
0236  * FUNCTION:    AcpiGetSystemInfo
0237  *
0238  * PARAMETERS:  OutBuffer       - A buffer to receive the resources for the
0239  *                                device
0240  *
0241  * RETURN:      Status          - the status of the call
0242  *
0243  * DESCRIPTION: This function is called to get information about the current
0244  *              state of the ACPI subsystem. It will return system information
0245  *              in the OutBuffer.
0246  *
0247  *              If the function fails an appropriate status will be returned
0248  *              and the value of OutBuffer is undefined.
0249  *
0250  ******************************************************************************/
0251 
0252 ACPI_STATUS
0253 AcpiGetSystemInfo (
0254     ACPI_BUFFER             *OutBuffer)
0255 {
0256     ACPI_SYSTEM_INFO        *InfoPtr;
0257     ACPI_STATUS             Status;
0258 
0259 
0260     ACPI_FUNCTION_TRACE (AcpiGetSystemInfo);
0261 
0262 
0263     /* Parameter validation */
0264 
0265     Status = AcpiUtValidateBuffer (OutBuffer);
0266     if (ACPI_FAILURE (Status))
0267     {
0268         return_ACPI_STATUS (Status);
0269     }
0270 
0271     /* Validate/Allocate/Clear caller buffer */
0272 
0273     Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
0274     if (ACPI_FAILURE (Status))
0275     {
0276         return_ACPI_STATUS (Status);
0277     }
0278 
0279     /*
0280      * Populate the return buffer
0281      */
0282     InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
0283     InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
0284 
0285     /* System flags (ACPI capabilities) */
0286 
0287     InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
0288 
0289     /* Timer resolution - 24 or 32 bits  */
0290 
0291     if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
0292     {
0293         InfoPtr->TimerResolution = 24;
0294     }
0295     else
0296     {
0297         InfoPtr->TimerResolution = 32;
0298     }
0299 
0300     /* Clear the reserved fields */
0301 
0302     InfoPtr->Reserved1 = 0;
0303     InfoPtr->Reserved2 = 0;
0304 
0305     /* Current debug levels */
0306 
0307     InfoPtr->DebugLayer = AcpiDbgLayer;
0308     InfoPtr->DebugLevel = AcpiDbgLevel;
0309 
0310     return_ACPI_STATUS (AE_OK);
0311 }
0312 
0313 ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo)
0314 
0315 
0316 /*******************************************************************************
0317  *
0318  * FUNCTION:    AcpiGetStatistics
0319  *
0320  * PARAMETERS:  Stats           - Where the statistics are returned
0321  *
0322  * RETURN:      Status          - the status of the call
0323  *
0324  * DESCRIPTION: Get the contents of the various system counters
0325  *
0326  ******************************************************************************/
0327 
0328 ACPI_STATUS
0329 AcpiGetStatistics (
0330     ACPI_STATISTICS         *Stats)
0331 {
0332     ACPI_FUNCTION_TRACE (AcpiGetStatistics);
0333 
0334 
0335     /* Parameter validation */
0336 
0337     if (!Stats)
0338     {
0339         return_ACPI_STATUS (AE_BAD_PARAMETER);
0340     }
0341 
0342     /* Various interrupt-based event counters */
0343 
0344     Stats->SciCount = AcpiSciCount;
0345     Stats->GpeCount = AcpiGpeCount;
0346 
0347     memcpy (Stats->FixedEventCount, AcpiFixedEventCount,
0348         sizeof (AcpiFixedEventCount));
0349 
0350     /* Other counters */
0351 
0352     Stats->MethodCount = AcpiMethodCount;
0353     return_ACPI_STATUS (AE_OK);
0354 }
0355 
0356 ACPI_EXPORT_SYMBOL (AcpiGetStatistics)
0357 
0358 
0359 /*****************************************************************************
0360  *
0361  * FUNCTION:    AcpiInstallInitializationHandler
0362  *
0363  * PARAMETERS:  Handler             - Callback procedure
0364  *              Function            - Not (currently) used, see below
0365  *
0366  * RETURN:      Status
0367  *
0368  * DESCRIPTION: Install an initialization handler
0369  *
0370  * TBD: When a second function is added, must save the Function also.
0371  *
0372  ****************************************************************************/
0373 
0374 ACPI_STATUS
0375 AcpiInstallInitializationHandler (
0376     ACPI_INIT_HANDLER       Handler,
0377     UINT32                  Function)
0378 {
0379 
0380     if (!Handler)
0381     {
0382         return (AE_BAD_PARAMETER);
0383     }
0384 
0385     if (AcpiGbl_InitHandler)
0386     {
0387         return (AE_ALREADY_EXISTS);
0388     }
0389 
0390     AcpiGbl_InitHandler = Handler;
0391     return (AE_OK);
0392 }
0393 
0394 ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler)
0395 
0396 
0397 /*****************************************************************************
0398  *
0399  * FUNCTION:    AcpiPurgeCachedObjects
0400  *
0401  * PARAMETERS:  None
0402  *
0403  * RETURN:      Status
0404  *
0405  * DESCRIPTION: Empty all caches (delete the cached objects)
0406  *
0407  ****************************************************************************/
0408 
0409 ACPI_STATUS
0410 AcpiPurgeCachedObjects (
0411     void)
0412 {
0413     ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects);
0414 
0415 
0416     (void) AcpiOsPurgeCache (AcpiGbl_StateCache);
0417     (void) AcpiOsPurgeCache (AcpiGbl_OperandCache);
0418     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache);
0419     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache);
0420 
0421     return_ACPI_STATUS (AE_OK);
0422 }
0423 
0424 ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects)
0425 
0426 
0427 /*****************************************************************************
0428  *
0429  * FUNCTION:    AcpiInstallInterface
0430  *
0431  * PARAMETERS:  InterfaceName       - The interface to install
0432  *
0433  * RETURN:      Status
0434  *
0435  * DESCRIPTION: Install an _OSI interface to the global list
0436  *
0437  ****************************************************************************/
0438 
0439 ACPI_STATUS
0440 AcpiInstallInterface (
0441     ACPI_STRING             InterfaceName)
0442 {
0443     ACPI_STATUS             Status;
0444     ACPI_INTERFACE_INFO     *InterfaceInfo;
0445 
0446 
0447     /* Parameter validation */
0448 
0449     if (!InterfaceName || (strlen (InterfaceName) == 0))
0450     {
0451         return (AE_BAD_PARAMETER);
0452     }
0453 
0454     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0455     if (ACPI_FAILURE (Status))
0456     {
0457         return (Status);
0458     }
0459 
0460     /* Check if the interface name is already in the global list */
0461 
0462     InterfaceInfo = AcpiUtGetInterface (InterfaceName);
0463     if (InterfaceInfo)
0464     {
0465         /*
0466          * The interface already exists in the list. This is OK if the
0467          * interface has been marked invalid -- just clear the bit.
0468          */
0469         if (InterfaceInfo->Flags & ACPI_OSI_INVALID)
0470         {
0471             InterfaceInfo->Flags &= ~ACPI_OSI_INVALID;
0472             Status = AE_OK;
0473         }
0474         else
0475         {
0476             Status = AE_ALREADY_EXISTS;
0477         }
0478     }
0479     else
0480     {
0481         /* New interface name, install into the global list */
0482 
0483         Status = AcpiUtInstallInterface (InterfaceName);
0484     }
0485 
0486     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0487     return (Status);
0488 }
0489 
0490 ACPI_EXPORT_SYMBOL (AcpiInstallInterface)
0491 
0492 
0493 /*****************************************************************************
0494  *
0495  * FUNCTION:    AcpiRemoveInterface
0496  *
0497  * PARAMETERS:  InterfaceName       - The interface to remove
0498  *
0499  * RETURN:      Status
0500  *
0501  * DESCRIPTION: Remove an _OSI interface from the global list
0502  *
0503  ****************************************************************************/
0504 
0505 ACPI_STATUS
0506 AcpiRemoveInterface (
0507     ACPI_STRING             InterfaceName)
0508 {
0509     ACPI_STATUS             Status;
0510 
0511 
0512     /* Parameter validation */
0513 
0514     if (!InterfaceName || (strlen (InterfaceName) == 0))
0515     {
0516         return (AE_BAD_PARAMETER);
0517     }
0518 
0519     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0520     if (ACPI_FAILURE (Status))
0521     {
0522         return (Status);
0523     }
0524 
0525     Status = AcpiUtRemoveInterface (InterfaceName);
0526 
0527     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0528     return (Status);
0529 }
0530 
0531 ACPI_EXPORT_SYMBOL (AcpiRemoveInterface)
0532 
0533 
0534 /*****************************************************************************
0535  *
0536  * FUNCTION:    AcpiInstallInterfaceHandler
0537  *
0538  * PARAMETERS:  Handler             - The _OSI interface handler to install
0539  *                                    NULL means "remove existing handler"
0540  *
0541  * RETURN:      Status
0542  *
0543  * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
0544  *              invoked during execution of the internal implementation of
0545  *              _OSI. A NULL handler simply removes any existing handler.
0546  *
0547  ****************************************************************************/
0548 
0549 ACPI_STATUS
0550 AcpiInstallInterfaceHandler (
0551     ACPI_INTERFACE_HANDLER  Handler)
0552 {
0553     ACPI_STATUS             Status;
0554 
0555 
0556     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0557     if (ACPI_FAILURE (Status))
0558     {
0559         return (Status);
0560     }
0561 
0562     if (Handler && AcpiGbl_InterfaceHandler)
0563     {
0564         Status = AE_ALREADY_EXISTS;
0565     }
0566     else
0567     {
0568         AcpiGbl_InterfaceHandler = Handler;
0569     }
0570 
0571     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0572     return (Status);
0573 }
0574 
0575 ACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler)
0576 
0577 
0578 /*****************************************************************************
0579  *
0580  * FUNCTION:    AcpiUpdateInterfaces
0581  *
0582  * PARAMETERS:  Action              - Actions to be performed during the
0583  *                                    update
0584  *
0585  * RETURN:      Status
0586  *
0587  * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
0588  *              string or/and feature group strings.
0589  *
0590  ****************************************************************************/
0591 
0592 ACPI_STATUS
0593 AcpiUpdateInterfaces (
0594     UINT8                   Action)
0595 {
0596     ACPI_STATUS             Status;
0597 
0598 
0599     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0600     if (ACPI_FAILURE (Status))
0601     {
0602         return (Status);
0603     }
0604 
0605     Status = AcpiUtUpdateInterfaces (Action);
0606 
0607     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0608     return (Status);
0609 }
0610 
0611 
0612 /*****************************************************************************
0613  *
0614  * FUNCTION:    AcpiCheckAddressRange
0615  *
0616  * PARAMETERS:  SpaceId             - Address space ID
0617  *              Address             - Start address
0618  *              Length              - Length
0619  *              Warn                - TRUE if warning on overlap desired
0620  *
0621  * RETURN:      Count of the number of conflicts detected.
0622  *
0623  * DESCRIPTION: Check if the input address range overlaps any of the
0624  *              ASL operation region address ranges.
0625  *
0626  ****************************************************************************/
0627 
0628 UINT32
0629 AcpiCheckAddressRange (
0630     ACPI_ADR_SPACE_TYPE     SpaceId,
0631     ACPI_PHYSICAL_ADDRESS   Address,
0632     ACPI_SIZE               Length,
0633     BOOLEAN                 Warn)
0634 {
0635     UINT32                  Overlaps;
0636     ACPI_STATUS             Status;
0637 
0638 
0639     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
0640     if (ACPI_FAILURE (Status))
0641     {
0642         return (0);
0643     }
0644 
0645     Overlaps = AcpiUtCheckAddressRange (SpaceId, Address,
0646         (UINT32) Length, Warn);
0647 
0648     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
0649     return (Overlaps);
0650 }
0651 
0652 ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
0653 
0654 #endif /* !ACPI_ASL_COMPILER */
0655 
0656 
0657 /*******************************************************************************
0658  *
0659  * FUNCTION:    AcpiDecodePldBuffer
0660  *
0661  * PARAMETERS:  InBuffer            - Buffer returned by _PLD method
0662  *              Length              - Length of the InBuffer
0663  *              ReturnBuffer        - Where the decode buffer is returned
0664  *
0665  * RETURN:      Status and the decoded _PLD buffer. User must deallocate
0666  *              the buffer via ACPI_FREE.
0667  *
0668  * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
0669  *              a local struct that is much more useful to an ACPI driver.
0670  *
0671  ******************************************************************************/
0672 
0673 ACPI_STATUS
0674 AcpiDecodePldBuffer (
0675     UINT8                   *InBuffer,
0676     ACPI_SIZE               Length,
0677     ACPI_PLD_INFO           **ReturnBuffer)
0678 {
0679     ACPI_PLD_INFO           *PldInfo;
0680     UINT32                  *Buffer = ACPI_CAST_PTR (UINT32, InBuffer);
0681     UINT32                  Dword;
0682 
0683 
0684     /* Parameter validation */
0685 
0686     if (!InBuffer || !ReturnBuffer || (Length < ACPI_PLD_REV1_BUFFER_SIZE))
0687     {
0688         return (AE_BAD_PARAMETER);
0689     }
0690 
0691     PldInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PLD_INFO));
0692     if (!PldInfo)
0693     {
0694         return (AE_NO_MEMORY);
0695     }
0696 
0697     /* First 32-bit DWord */
0698 
0699     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[0]);
0700     PldInfo->Revision =             ACPI_PLD_GET_REVISION (&Dword);
0701     PldInfo->IgnoreColor =          ACPI_PLD_GET_IGNORE_COLOR (&Dword);
0702     PldInfo->Red =                  ACPI_PLD_GET_RED (&Dword);
0703     PldInfo->Green =                ACPI_PLD_GET_GREEN (&Dword);
0704     PldInfo->Blue =                 ACPI_PLD_GET_BLUE (&Dword);
0705 
0706     /* Second 32-bit DWord */
0707 
0708     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[1]);
0709     PldInfo->Width =                ACPI_PLD_GET_WIDTH (&Dword);
0710     PldInfo->Height =               ACPI_PLD_GET_HEIGHT(&Dword);
0711 
0712     /* Third 32-bit DWord */
0713 
0714     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[2]);
0715     PldInfo->UserVisible =          ACPI_PLD_GET_USER_VISIBLE (&Dword);
0716     PldInfo->Dock =                 ACPI_PLD_GET_DOCK (&Dword);
0717     PldInfo->Lid =                  ACPI_PLD_GET_LID (&Dword);
0718     PldInfo->Panel =                ACPI_PLD_GET_PANEL (&Dword);
0719     PldInfo->VerticalPosition =     ACPI_PLD_GET_VERTICAL (&Dword);
0720     PldInfo->HorizontalPosition =   ACPI_PLD_GET_HORIZONTAL (&Dword);
0721     PldInfo->Shape =                ACPI_PLD_GET_SHAPE (&Dword);
0722     PldInfo->GroupOrientation =     ACPI_PLD_GET_ORIENTATION (&Dword);
0723     PldInfo->GroupToken =           ACPI_PLD_GET_TOKEN (&Dword);
0724     PldInfo->GroupPosition =        ACPI_PLD_GET_POSITION (&Dword);
0725     PldInfo->Bay =                  ACPI_PLD_GET_BAY (&Dword);
0726 
0727     /* Fourth 32-bit DWord */
0728 
0729     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[3]);
0730     PldInfo->Ejectable =            ACPI_PLD_GET_EJECTABLE (&Dword);
0731     PldInfo->OspmEjectRequired =    ACPI_PLD_GET_OSPM_EJECT (&Dword);
0732     PldInfo->CabinetNumber =        ACPI_PLD_GET_CABINET (&Dword);
0733     PldInfo->CardCageNumber =       ACPI_PLD_GET_CARD_CAGE (&Dword);
0734     PldInfo->Reference =            ACPI_PLD_GET_REFERENCE (&Dword);
0735     PldInfo->Rotation =             ACPI_PLD_GET_ROTATION (&Dword);
0736     PldInfo->Order =                ACPI_PLD_GET_ORDER (&Dword);
0737 
0738     if (Length >= ACPI_PLD_REV2_BUFFER_SIZE)
0739     {
0740         /* Fifth 32-bit DWord (Revision 2 of _PLD) */
0741 
0742         ACPI_MOVE_32_TO_32 (&Dword, &Buffer[4]);
0743         PldInfo->VerticalOffset =       ACPI_PLD_GET_VERT_OFFSET (&Dword);
0744         PldInfo->HorizontalOffset =     ACPI_PLD_GET_HORIZ_OFFSET (&Dword);
0745     }
0746 
0747     *ReturnBuffer = PldInfo;
0748     return (AE_OK);
0749 }
0750 
0751 ACPI_EXPORT_SYMBOL (AcpiDecodePldBuffer)