xref: /titanic_53/usr/src/uts/intel/io/acpica/utilities/utxface.c (revision 385cc6b4ad1792caef3f84eb61eed3f27085801f)
1ae115bc7Smrj /******************************************************************************
2ae115bc7Smrj  *
3*385cc6b4SJerry Jelinek  * Module Name: utxface - External interfaces, miscellaneous utility functions
4ae115bc7Smrj  *
5ae115bc7Smrj  *****************************************************************************/
6ae115bc7Smrj 
726f3cdf0SGordon Ross /*
8*385cc6b4SJerry Jelinek  * Copyright (C) 2000 - 2016, Intel Corp.
9ae115bc7Smrj  * All rights reserved.
10ae115bc7Smrj  *
1126f3cdf0SGordon Ross  * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross  * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross  * are met:
1426f3cdf0SGordon Ross  * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross  *    notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross  *    without modification.
1726f3cdf0SGordon Ross  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross  *    substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross  *    ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross  *    including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross  *    binary redistribution.
2226f3cdf0SGordon Ross  * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross  *    of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross  *    from this software without specific prior written permission.
25ae115bc7Smrj  *
2626f3cdf0SGordon Ross  * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross  * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross  * Software Foundation.
29ae115bc7Smrj  *
3026f3cdf0SGordon Ross  * NO WARRANTY
3126f3cdf0SGordon Ross  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross  * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross  */
43ae115bc7Smrj 
44*385cc6b4SJerry Jelinek #define EXPORT_ACPI_INTERFACES
45ae115bc7Smrj 
46ae115bc7Smrj #include "acpi.h"
47aa2aa9a6SDana Myers #include "accommon.h"
48ae115bc7Smrj #include "acdebug.h"
49ae115bc7Smrj 
50ae115bc7Smrj #define _COMPONENT          ACPI_UTILITIES
51ae115bc7Smrj         ACPI_MODULE_NAME    ("utxface")
52ae115bc7Smrj 
53ae115bc7Smrj 
54ae115bc7Smrj /*******************************************************************************
55ae115bc7Smrj  *
56ae115bc7Smrj  * FUNCTION:    AcpiTerminate
57ae115bc7Smrj  *
58ae115bc7Smrj  * PARAMETERS:  None
59ae115bc7Smrj  *
60ae115bc7Smrj  * RETURN:      Status
61ae115bc7Smrj  *
6257190917SDana Myers  * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
63ae115bc7Smrj  *
64ae115bc7Smrj  ******************************************************************************/
65ae115bc7Smrj 
66ae115bc7Smrj ACPI_STATUS
AcpiTerminate(void)67ae115bc7Smrj AcpiTerminate (
68ae115bc7Smrj     void)
69ae115bc7Smrj {
70ae115bc7Smrj     ACPI_STATUS         Status;
71ae115bc7Smrj 
72ae115bc7Smrj 
73ae115bc7Smrj     ACPI_FUNCTION_TRACE (AcpiTerminate);
74ae115bc7Smrj 
75ae115bc7Smrj 
76ae115bc7Smrj     /* Shutdown and free all resources */
77ae115bc7Smrj 
78ae115bc7Smrj     AcpiUtSubsystemShutdown ();
79ae115bc7Smrj 
80ae115bc7Smrj     /* Free the mutex objects */
81ae115bc7Smrj 
82ae115bc7Smrj     AcpiUtMutexTerminate ();
83ae115bc7Smrj 
84ae115bc7Smrj     /* Now we can shutdown the OS-dependent layer */
85ae115bc7Smrj 
86ae115bc7Smrj     Status = AcpiOsTerminate ();
87ae115bc7Smrj     return_ACPI_STATUS (Status);
88ae115bc7Smrj }
89ae115bc7Smrj 
ACPI_EXPORT_SYMBOL_INIT(AcpiTerminate)90*385cc6b4SJerry Jelinek ACPI_EXPORT_SYMBOL_INIT (AcpiTerminate)
91ae115bc7Smrj 
92ae115bc7Smrj 
9357190917SDana Myers #ifndef ACPI_ASL_COMPILER
94ae115bc7Smrj /*******************************************************************************
95ae115bc7Smrj  *
96ae115bc7Smrj  * FUNCTION:    AcpiSubsystemStatus
97ae115bc7Smrj  *
98ae115bc7Smrj  * PARAMETERS:  None
99ae115bc7Smrj  *
100ae115bc7Smrj  * RETURN:      Status of the ACPI subsystem
101ae115bc7Smrj  *
102ae115bc7Smrj  * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
103ae115bc7Smrj  *              before making any other calls, to ensure the subsystem
104ae115bc7Smrj  *              initialized successfully.
105ae115bc7Smrj  *
106ae115bc7Smrj  ******************************************************************************/
107ae115bc7Smrj 
108ae115bc7Smrj ACPI_STATUS
109ae115bc7Smrj AcpiSubsystemStatus (
110ae115bc7Smrj     void)
111ae115bc7Smrj {
112ae115bc7Smrj 
113ae115bc7Smrj     if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
114ae115bc7Smrj     {
115ae115bc7Smrj         return (AE_OK);
116ae115bc7Smrj     }
117ae115bc7Smrj     else
118ae115bc7Smrj     {
119ae115bc7Smrj         return (AE_ERROR);
120ae115bc7Smrj     }
121ae115bc7Smrj }
122ae115bc7Smrj 
ACPI_EXPORT_SYMBOL(AcpiSubsystemStatus)123ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus)
124ae115bc7Smrj 
125ae115bc7Smrj 
126ae115bc7Smrj /*******************************************************************************
127ae115bc7Smrj  *
128ae115bc7Smrj  * FUNCTION:    AcpiGetSystemInfo
129ae115bc7Smrj  *
130ae115bc7Smrj  * PARAMETERS:  OutBuffer       - A buffer to receive the resources for the
131ae115bc7Smrj  *                                device
132ae115bc7Smrj  *
133ae115bc7Smrj  * RETURN:      Status          - the status of the call
134ae115bc7Smrj  *
135ae115bc7Smrj  * DESCRIPTION: This function is called to get information about the current
136ae115bc7Smrj  *              state of the ACPI subsystem. It will return system information
137ae115bc7Smrj  *              in the OutBuffer.
138ae115bc7Smrj  *
139ae115bc7Smrj  *              If the function fails an appropriate status will be returned
140ae115bc7Smrj  *              and the value of OutBuffer is undefined.
141ae115bc7Smrj  *
142ae115bc7Smrj  ******************************************************************************/
143ae115bc7Smrj 
144ae115bc7Smrj ACPI_STATUS
145ae115bc7Smrj AcpiGetSystemInfo (
146ae115bc7Smrj     ACPI_BUFFER             *OutBuffer)
147ae115bc7Smrj {
148ae115bc7Smrj     ACPI_SYSTEM_INFO        *InfoPtr;
149ae115bc7Smrj     ACPI_STATUS             Status;
150ae115bc7Smrj 
151ae115bc7Smrj 
152ae115bc7Smrj     ACPI_FUNCTION_TRACE (AcpiGetSystemInfo);
153ae115bc7Smrj 
154ae115bc7Smrj 
155ae115bc7Smrj     /* Parameter validation */
156ae115bc7Smrj 
157ae115bc7Smrj     Status = AcpiUtValidateBuffer (OutBuffer);
158ae115bc7Smrj     if (ACPI_FAILURE (Status))
159ae115bc7Smrj     {
160ae115bc7Smrj         return_ACPI_STATUS (Status);
161ae115bc7Smrj     }
162ae115bc7Smrj 
163ae115bc7Smrj     /* Validate/Allocate/Clear caller buffer */
164ae115bc7Smrj 
165ae115bc7Smrj     Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
166ae115bc7Smrj     if (ACPI_FAILURE (Status))
167ae115bc7Smrj     {
168ae115bc7Smrj         return_ACPI_STATUS (Status);
169ae115bc7Smrj     }
170ae115bc7Smrj 
171ae115bc7Smrj     /*
172ae115bc7Smrj      * Populate the return buffer
173ae115bc7Smrj      */
174ae115bc7Smrj     InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
175ae115bc7Smrj     InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
176ae115bc7Smrj 
177ae115bc7Smrj     /* System flags (ACPI capabilities) */
178ae115bc7Smrj 
179ae115bc7Smrj     InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
180ae115bc7Smrj 
181ae115bc7Smrj     /* Timer resolution - 24 or 32 bits  */
182ae115bc7Smrj 
183db2bae30SDana Myers     if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
184ae115bc7Smrj     {
185ae115bc7Smrj         InfoPtr->TimerResolution = 24;
186ae115bc7Smrj     }
187ae115bc7Smrj     else
188ae115bc7Smrj     {
189ae115bc7Smrj         InfoPtr->TimerResolution = 32;
190ae115bc7Smrj     }
191ae115bc7Smrj 
192ae115bc7Smrj     /* Clear the reserved fields */
193ae115bc7Smrj 
194ae115bc7Smrj     InfoPtr->Reserved1 = 0;
195ae115bc7Smrj     InfoPtr->Reserved2 = 0;
196ae115bc7Smrj 
197ae115bc7Smrj     /* Current debug levels */
198ae115bc7Smrj 
199ae115bc7Smrj     InfoPtr->DebugLayer = AcpiDbgLayer;
200ae115bc7Smrj     InfoPtr->DebugLevel = AcpiDbgLevel;
201ae115bc7Smrj 
202ae115bc7Smrj     return_ACPI_STATUS (AE_OK);
203ae115bc7Smrj }
204ae115bc7Smrj 
ACPI_EXPORT_SYMBOL(AcpiGetSystemInfo)205ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo)
206ae115bc7Smrj 
207ae115bc7Smrj 
208db2bae30SDana Myers /*******************************************************************************
209db2bae30SDana Myers  *
210db2bae30SDana Myers  * FUNCTION:    AcpiGetStatistics
211db2bae30SDana Myers  *
212db2bae30SDana Myers  * PARAMETERS:  Stats           - Where the statistics are returned
213db2bae30SDana Myers  *
214db2bae30SDana Myers  * RETURN:      Status          - the status of the call
215db2bae30SDana Myers  *
216db2bae30SDana Myers  * DESCRIPTION: Get the contents of the various system counters
217db2bae30SDana Myers  *
218db2bae30SDana Myers  ******************************************************************************/
219db2bae30SDana Myers 
220db2bae30SDana Myers ACPI_STATUS
221db2bae30SDana Myers AcpiGetStatistics (
222db2bae30SDana Myers     ACPI_STATISTICS         *Stats)
223db2bae30SDana Myers {
224db2bae30SDana Myers     ACPI_FUNCTION_TRACE (AcpiGetStatistics);
225db2bae30SDana Myers 
226db2bae30SDana Myers 
227db2bae30SDana Myers     /* Parameter validation */
228db2bae30SDana Myers 
229db2bae30SDana Myers     if (!Stats)
230db2bae30SDana Myers     {
231db2bae30SDana Myers         return_ACPI_STATUS (AE_BAD_PARAMETER);
232db2bae30SDana Myers     }
233db2bae30SDana Myers 
234db2bae30SDana Myers     /* Various interrupt-based event counters */
235db2bae30SDana Myers 
236db2bae30SDana Myers     Stats->SciCount = AcpiSciCount;
237db2bae30SDana Myers     Stats->GpeCount = AcpiGpeCount;
238db2bae30SDana Myers 
239*385cc6b4SJerry Jelinek     memcpy (Stats->FixedEventCount, AcpiFixedEventCount,
240db2bae30SDana Myers         sizeof (AcpiFixedEventCount));
241db2bae30SDana Myers 
242db2bae30SDana Myers     /* Other counters */
243db2bae30SDana Myers 
244db2bae30SDana Myers     Stats->MethodCount = AcpiMethodCount;
245db2bae30SDana Myers     return_ACPI_STATUS (AE_OK);
246db2bae30SDana Myers }
247db2bae30SDana Myers 
ACPI_EXPORT_SYMBOL(AcpiGetStatistics)248db2bae30SDana Myers ACPI_EXPORT_SYMBOL (AcpiGetStatistics)
249db2bae30SDana Myers 
250db2bae30SDana Myers 
251ae115bc7Smrj /*****************************************************************************
252ae115bc7Smrj  *
253ae115bc7Smrj  * FUNCTION:    AcpiInstallInitializationHandler
254ae115bc7Smrj  *
255ae115bc7Smrj  * PARAMETERS:  Handler             - Callback procedure
256ae115bc7Smrj  *              Function            - Not (currently) used, see below
257ae115bc7Smrj  *
258ae115bc7Smrj  * RETURN:      Status
259ae115bc7Smrj  *
260ae115bc7Smrj  * DESCRIPTION: Install an initialization handler
261ae115bc7Smrj  *
262ae115bc7Smrj  * TBD: When a second function is added, must save the Function also.
263ae115bc7Smrj  *
264ae115bc7Smrj  ****************************************************************************/
265ae115bc7Smrj 
266ae115bc7Smrj ACPI_STATUS
267ae115bc7Smrj AcpiInstallInitializationHandler (
268ae115bc7Smrj     ACPI_INIT_HANDLER       Handler,
269ae115bc7Smrj     UINT32                  Function)
270ae115bc7Smrj {
271ae115bc7Smrj 
272ae115bc7Smrj     if (!Handler)
273ae115bc7Smrj     {
274ae115bc7Smrj         return (AE_BAD_PARAMETER);
275ae115bc7Smrj     }
276ae115bc7Smrj 
277ae115bc7Smrj     if (AcpiGbl_InitHandler)
278ae115bc7Smrj     {
279ae115bc7Smrj         return (AE_ALREADY_EXISTS);
280ae115bc7Smrj     }
281ae115bc7Smrj 
282ae115bc7Smrj     AcpiGbl_InitHandler = Handler;
283*385cc6b4SJerry Jelinek     return (AE_OK);
284ae115bc7Smrj }
285ae115bc7Smrj 
ACPI_EXPORT_SYMBOL(AcpiInstallInitializationHandler)286ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler)
287ae115bc7Smrj 
288ae115bc7Smrj 
289ae115bc7Smrj /*****************************************************************************
290ae115bc7Smrj  *
291ae115bc7Smrj  * FUNCTION:    AcpiPurgeCachedObjects
292ae115bc7Smrj  *
293ae115bc7Smrj  * PARAMETERS:  None
294ae115bc7Smrj  *
295ae115bc7Smrj  * RETURN:      Status
296ae115bc7Smrj  *
297ae115bc7Smrj  * DESCRIPTION: Empty all caches (delete the cached objects)
298ae115bc7Smrj  *
299ae115bc7Smrj  ****************************************************************************/
300ae115bc7Smrj 
301ae115bc7Smrj ACPI_STATUS
302ae115bc7Smrj AcpiPurgeCachedObjects (
303ae115bc7Smrj     void)
304ae115bc7Smrj {
305ae115bc7Smrj     ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects);
306ae115bc7Smrj 
307*385cc6b4SJerry Jelinek 
308ae115bc7Smrj     (void) AcpiOsPurgeCache (AcpiGbl_StateCache);
309ae115bc7Smrj     (void) AcpiOsPurgeCache (AcpiGbl_OperandCache);
310ae115bc7Smrj     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache);
311ae115bc7Smrj     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache);
312*385cc6b4SJerry Jelinek 
313ae115bc7Smrj     return_ACPI_STATUS (AE_OK);
314ae115bc7Smrj }
315ae115bc7Smrj 
ACPI_EXPORT_SYMBOL(AcpiPurgeCachedObjects)316ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects)
317db2bae30SDana Myers 
31826f3cdf0SGordon Ross 
31926f3cdf0SGordon Ross /*****************************************************************************
32026f3cdf0SGordon Ross  *
32126f3cdf0SGordon Ross  * FUNCTION:    AcpiInstallInterface
32226f3cdf0SGordon Ross  *
32326f3cdf0SGordon Ross  * PARAMETERS:  InterfaceName       - The interface to install
32426f3cdf0SGordon Ross  *
32526f3cdf0SGordon Ross  * RETURN:      Status
32626f3cdf0SGordon Ross  *
32726f3cdf0SGordon Ross  * DESCRIPTION: Install an _OSI interface to the global list
32826f3cdf0SGordon Ross  *
32926f3cdf0SGordon Ross  ****************************************************************************/
33026f3cdf0SGordon Ross 
33126f3cdf0SGordon Ross ACPI_STATUS
33226f3cdf0SGordon Ross AcpiInstallInterface (
33326f3cdf0SGordon Ross     ACPI_STRING             InterfaceName)
33426f3cdf0SGordon Ross {
33526f3cdf0SGordon Ross     ACPI_STATUS             Status;
33626f3cdf0SGordon Ross     ACPI_INTERFACE_INFO     *InterfaceInfo;
33726f3cdf0SGordon Ross 
33826f3cdf0SGordon Ross 
33926f3cdf0SGordon Ross     /* Parameter validation */
34026f3cdf0SGordon Ross 
341*385cc6b4SJerry Jelinek     if (!InterfaceName || (strlen (InterfaceName) == 0))
34226f3cdf0SGordon Ross     {
34326f3cdf0SGordon Ross         return (AE_BAD_PARAMETER);
34426f3cdf0SGordon Ross     }
34526f3cdf0SGordon Ross 
346*385cc6b4SJerry Jelinek     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
347*385cc6b4SJerry Jelinek     if (ACPI_FAILURE (Status))
348*385cc6b4SJerry Jelinek     {
349*385cc6b4SJerry Jelinek         return (Status);
350*385cc6b4SJerry Jelinek     }
35126f3cdf0SGordon Ross 
35226f3cdf0SGordon Ross     /* Check if the interface name is already in the global list */
35326f3cdf0SGordon Ross 
35426f3cdf0SGordon Ross     InterfaceInfo = AcpiUtGetInterface (InterfaceName);
35526f3cdf0SGordon Ross     if (InterfaceInfo)
35626f3cdf0SGordon Ross     {
35726f3cdf0SGordon Ross         /*
35826f3cdf0SGordon Ross          * The interface already exists in the list. This is OK if the
35926f3cdf0SGordon Ross          * interface has been marked invalid -- just clear the bit.
36026f3cdf0SGordon Ross          */
36126f3cdf0SGordon Ross         if (InterfaceInfo->Flags & ACPI_OSI_INVALID)
36226f3cdf0SGordon Ross         {
36326f3cdf0SGordon Ross             InterfaceInfo->Flags &= ~ACPI_OSI_INVALID;
36426f3cdf0SGordon Ross             Status = AE_OK;
36526f3cdf0SGordon Ross         }
36626f3cdf0SGordon Ross         else
36726f3cdf0SGordon Ross         {
36826f3cdf0SGordon Ross             Status = AE_ALREADY_EXISTS;
36926f3cdf0SGordon Ross         }
37026f3cdf0SGordon Ross     }
37126f3cdf0SGordon Ross     else
37226f3cdf0SGordon Ross     {
37326f3cdf0SGordon Ross         /* New interface name, install into the global list */
37426f3cdf0SGordon Ross 
37526f3cdf0SGordon Ross         Status = AcpiUtInstallInterface (InterfaceName);
37626f3cdf0SGordon Ross     }
37726f3cdf0SGordon Ross 
37826f3cdf0SGordon Ross     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
37926f3cdf0SGordon Ross     return (Status);
38026f3cdf0SGordon Ross }
38126f3cdf0SGordon Ross 
ACPI_EXPORT_SYMBOL(AcpiInstallInterface)38226f3cdf0SGordon Ross ACPI_EXPORT_SYMBOL (AcpiInstallInterface)
38326f3cdf0SGordon Ross 
38426f3cdf0SGordon Ross 
38526f3cdf0SGordon Ross /*****************************************************************************
38626f3cdf0SGordon Ross  *
38726f3cdf0SGordon Ross  * FUNCTION:    AcpiRemoveInterface
38826f3cdf0SGordon Ross  *
38926f3cdf0SGordon Ross  * PARAMETERS:  InterfaceName       - The interface to remove
39026f3cdf0SGordon Ross  *
39126f3cdf0SGordon Ross  * RETURN:      Status
39226f3cdf0SGordon Ross  *
39326f3cdf0SGordon Ross  * DESCRIPTION: Remove an _OSI interface from the global list
39426f3cdf0SGordon Ross  *
39526f3cdf0SGordon Ross  ****************************************************************************/
39626f3cdf0SGordon Ross 
39726f3cdf0SGordon Ross ACPI_STATUS
39826f3cdf0SGordon Ross AcpiRemoveInterface (
39926f3cdf0SGordon Ross     ACPI_STRING             InterfaceName)
40026f3cdf0SGordon Ross {
40126f3cdf0SGordon Ross     ACPI_STATUS             Status;
40226f3cdf0SGordon Ross 
40326f3cdf0SGordon Ross 
40426f3cdf0SGordon Ross     /* Parameter validation */
40526f3cdf0SGordon Ross 
406*385cc6b4SJerry Jelinek     if (!InterfaceName || (strlen (InterfaceName) == 0))
40726f3cdf0SGordon Ross     {
40826f3cdf0SGordon Ross         return (AE_BAD_PARAMETER);
40926f3cdf0SGordon Ross     }
41026f3cdf0SGordon Ross 
411*385cc6b4SJerry Jelinek     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
412*385cc6b4SJerry Jelinek     if (ACPI_FAILURE (Status))
413*385cc6b4SJerry Jelinek     {
414*385cc6b4SJerry Jelinek         return (Status);
415*385cc6b4SJerry Jelinek     }
41626f3cdf0SGordon Ross 
41726f3cdf0SGordon Ross     Status = AcpiUtRemoveInterface (InterfaceName);
41826f3cdf0SGordon Ross 
41926f3cdf0SGordon Ross     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
42026f3cdf0SGordon Ross     return (Status);
42126f3cdf0SGordon Ross }
42226f3cdf0SGordon Ross 
ACPI_EXPORT_SYMBOL(AcpiRemoveInterface)42326f3cdf0SGordon Ross ACPI_EXPORT_SYMBOL (AcpiRemoveInterface)
42426f3cdf0SGordon Ross 
42526f3cdf0SGordon Ross 
42626f3cdf0SGordon Ross /*****************************************************************************
42726f3cdf0SGordon Ross  *
42826f3cdf0SGordon Ross  * FUNCTION:    AcpiInstallInterfaceHandler
42926f3cdf0SGordon Ross  *
43026f3cdf0SGordon Ross  * PARAMETERS:  Handler             - The _OSI interface handler to install
43126f3cdf0SGordon Ross  *                                    NULL means "remove existing handler"
43226f3cdf0SGordon Ross  *
43326f3cdf0SGordon Ross  * RETURN:      Status
43426f3cdf0SGordon Ross  *
43526f3cdf0SGordon Ross  * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
43626f3cdf0SGordon Ross  *              invoked during execution of the internal implementation of
43726f3cdf0SGordon Ross  *              _OSI. A NULL handler simply removes any existing handler.
43826f3cdf0SGordon Ross  *
43926f3cdf0SGordon Ross  ****************************************************************************/
44026f3cdf0SGordon Ross 
44126f3cdf0SGordon Ross ACPI_STATUS
44226f3cdf0SGordon Ross AcpiInstallInterfaceHandler (
44326f3cdf0SGordon Ross     ACPI_INTERFACE_HANDLER  Handler)
44426f3cdf0SGordon Ross {
445*385cc6b4SJerry Jelinek     ACPI_STATUS             Status;
44626f3cdf0SGordon Ross 
44726f3cdf0SGordon Ross 
448*385cc6b4SJerry Jelinek     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
449*385cc6b4SJerry Jelinek     if (ACPI_FAILURE (Status))
450*385cc6b4SJerry Jelinek     {
451*385cc6b4SJerry Jelinek         return (Status);
452*385cc6b4SJerry Jelinek     }
45326f3cdf0SGordon Ross 
45426f3cdf0SGordon Ross     if (Handler && AcpiGbl_InterfaceHandler)
45526f3cdf0SGordon Ross     {
45626f3cdf0SGordon Ross         Status = AE_ALREADY_EXISTS;
45726f3cdf0SGordon Ross     }
45826f3cdf0SGordon Ross     else
45926f3cdf0SGordon Ross     {
46026f3cdf0SGordon Ross         AcpiGbl_InterfaceHandler = Handler;
46126f3cdf0SGordon Ross     }
46226f3cdf0SGordon Ross 
46326f3cdf0SGordon Ross     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
46426f3cdf0SGordon Ross     return (Status);
46526f3cdf0SGordon Ross }
46626f3cdf0SGordon Ross 
ACPI_EXPORT_SYMBOL(AcpiInstallInterfaceHandler)46726f3cdf0SGordon Ross ACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler)
46826f3cdf0SGordon Ross 
469*385cc6b4SJerry Jelinek 
470*385cc6b4SJerry Jelinek /*****************************************************************************
471*385cc6b4SJerry Jelinek  *
472*385cc6b4SJerry Jelinek  * FUNCTION:    AcpiUpdateInterfaces
473*385cc6b4SJerry Jelinek  *
474*385cc6b4SJerry Jelinek  * PARAMETERS:  Action              - Actions to be performed during the
475*385cc6b4SJerry Jelinek  *                                    update
476*385cc6b4SJerry Jelinek  *
477*385cc6b4SJerry Jelinek  * RETURN:      Status
478*385cc6b4SJerry Jelinek  *
479*385cc6b4SJerry Jelinek  * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
480*385cc6b4SJerry Jelinek  *              string or/and feature group strings.
481*385cc6b4SJerry Jelinek  *
482*385cc6b4SJerry Jelinek  ****************************************************************************/
483*385cc6b4SJerry Jelinek 
484*385cc6b4SJerry Jelinek ACPI_STATUS
485*385cc6b4SJerry Jelinek AcpiUpdateInterfaces (
486*385cc6b4SJerry Jelinek     UINT8                   Action)
487*385cc6b4SJerry Jelinek {
488*385cc6b4SJerry Jelinek     ACPI_STATUS             Status;
489*385cc6b4SJerry Jelinek 
490*385cc6b4SJerry Jelinek 
491*385cc6b4SJerry Jelinek     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
492*385cc6b4SJerry Jelinek     if (ACPI_FAILURE (Status))
493*385cc6b4SJerry Jelinek     {
494*385cc6b4SJerry Jelinek         return (Status);
495*385cc6b4SJerry Jelinek     }
496*385cc6b4SJerry Jelinek 
497*385cc6b4SJerry Jelinek     Status = AcpiUtUpdateInterfaces (Action);
498*385cc6b4SJerry Jelinek 
499*385cc6b4SJerry Jelinek     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
500*385cc6b4SJerry Jelinek     return (Status);
501*385cc6b4SJerry Jelinek }
502*385cc6b4SJerry Jelinek 
503*385cc6b4SJerry Jelinek 
504*385cc6b4SJerry Jelinek /*****************************************************************************
505*385cc6b4SJerry Jelinek  *
506*385cc6b4SJerry Jelinek  * FUNCTION:    AcpiCheckAddressRange
507*385cc6b4SJerry Jelinek  *
508*385cc6b4SJerry Jelinek  * PARAMETERS:  SpaceId             - Address space ID
509*385cc6b4SJerry Jelinek  *              Address             - Start address
510*385cc6b4SJerry Jelinek  *              Length              - Length
511*385cc6b4SJerry Jelinek  *              Warn                - TRUE if warning on overlap desired
512*385cc6b4SJerry Jelinek  *
513*385cc6b4SJerry Jelinek  * RETURN:      Count of the number of conflicts detected.
514*385cc6b4SJerry Jelinek  *
515*385cc6b4SJerry Jelinek  * DESCRIPTION: Check if the input address range overlaps any of the
516*385cc6b4SJerry Jelinek  *              ASL operation region address ranges.
517*385cc6b4SJerry Jelinek  *
518*385cc6b4SJerry Jelinek  ****************************************************************************/
519*385cc6b4SJerry Jelinek 
520*385cc6b4SJerry Jelinek UINT32
AcpiCheckAddressRange(ACPI_ADR_SPACE_TYPE SpaceId,ACPI_PHYSICAL_ADDRESS Address,ACPI_SIZE Length,BOOLEAN Warn)521*385cc6b4SJerry Jelinek AcpiCheckAddressRange (
522*385cc6b4SJerry Jelinek     ACPI_ADR_SPACE_TYPE     SpaceId,
523*385cc6b4SJerry Jelinek     ACPI_PHYSICAL_ADDRESS   Address,
524*385cc6b4SJerry Jelinek     ACPI_SIZE               Length,
525*385cc6b4SJerry Jelinek     BOOLEAN                 Warn)
526*385cc6b4SJerry Jelinek {
527*385cc6b4SJerry Jelinek     UINT32                  Overlaps;
528*385cc6b4SJerry Jelinek     ACPI_STATUS             Status;
529*385cc6b4SJerry Jelinek 
530*385cc6b4SJerry Jelinek 
531*385cc6b4SJerry Jelinek     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
532*385cc6b4SJerry Jelinek     if (ACPI_FAILURE (Status))
533*385cc6b4SJerry Jelinek     {
534*385cc6b4SJerry Jelinek         return (0);
535*385cc6b4SJerry Jelinek     }
536*385cc6b4SJerry Jelinek 
537*385cc6b4SJerry Jelinek     Overlaps = AcpiUtCheckAddressRange (SpaceId, Address,
538*385cc6b4SJerry Jelinek         (UINT32) Length, Warn);
539*385cc6b4SJerry Jelinek 
540*385cc6b4SJerry Jelinek     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
541*385cc6b4SJerry Jelinek     return (Overlaps);
542*385cc6b4SJerry Jelinek }
543*385cc6b4SJerry Jelinek 
ACPI_EXPORT_SYMBOL(AcpiCheckAddressRange)544*385cc6b4SJerry Jelinek ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
545*385cc6b4SJerry Jelinek 
54626f3cdf0SGordon Ross #endif /* !ACPI_ASL_COMPILER */
547aa2aa9a6SDana Myers 
548*385cc6b4SJerry Jelinek 
549*385cc6b4SJerry Jelinek /*******************************************************************************
550*385cc6b4SJerry Jelinek  *
551*385cc6b4SJerry Jelinek  * FUNCTION:    AcpiDecodePldBuffer
552*385cc6b4SJerry Jelinek  *
553*385cc6b4SJerry Jelinek  * PARAMETERS:  InBuffer            - Buffer returned by _PLD method
554*385cc6b4SJerry Jelinek  *              Length              - Length of the InBuffer
555*385cc6b4SJerry Jelinek  *              ReturnBuffer        - Where the decode buffer is returned
556*385cc6b4SJerry Jelinek  *
557*385cc6b4SJerry Jelinek  * RETURN:      Status and the decoded _PLD buffer. User must deallocate
558*385cc6b4SJerry Jelinek  *              the buffer via ACPI_FREE.
559*385cc6b4SJerry Jelinek  *
560*385cc6b4SJerry Jelinek  * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
561*385cc6b4SJerry Jelinek  *              a local struct that is much more useful to an ACPI driver.
562*385cc6b4SJerry Jelinek  *
563*385cc6b4SJerry Jelinek  ******************************************************************************/
564*385cc6b4SJerry Jelinek 
565*385cc6b4SJerry Jelinek ACPI_STATUS
566*385cc6b4SJerry Jelinek AcpiDecodePldBuffer (
567*385cc6b4SJerry Jelinek     UINT8                   *InBuffer,
568*385cc6b4SJerry Jelinek     ACPI_SIZE               Length,
569*385cc6b4SJerry Jelinek     ACPI_PLD_INFO           **ReturnBuffer)
570*385cc6b4SJerry Jelinek {
571*385cc6b4SJerry Jelinek     ACPI_PLD_INFO           *PldInfo;
572*385cc6b4SJerry Jelinek     UINT32                  *Buffer = ACPI_CAST_PTR (UINT32, InBuffer);
573*385cc6b4SJerry Jelinek     UINT32                  Dword;
574*385cc6b4SJerry Jelinek 
575*385cc6b4SJerry Jelinek 
576*385cc6b4SJerry Jelinek     /* Parameter validation */
577*385cc6b4SJerry Jelinek 
578*385cc6b4SJerry Jelinek     if (!InBuffer || !ReturnBuffer || (Length < ACPI_PLD_REV1_BUFFER_SIZE))
579*385cc6b4SJerry Jelinek     {
580*385cc6b4SJerry Jelinek         return (AE_BAD_PARAMETER);
581*385cc6b4SJerry Jelinek     }
582*385cc6b4SJerry Jelinek 
583*385cc6b4SJerry Jelinek     PldInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PLD_INFO));
584*385cc6b4SJerry Jelinek     if (!PldInfo)
585*385cc6b4SJerry Jelinek     {
586*385cc6b4SJerry Jelinek         return (AE_NO_MEMORY);
587*385cc6b4SJerry Jelinek     }
588*385cc6b4SJerry Jelinek 
589*385cc6b4SJerry Jelinek     /* First 32-bit DWord */
590*385cc6b4SJerry Jelinek 
591*385cc6b4SJerry Jelinek     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[0]);
592*385cc6b4SJerry Jelinek     PldInfo->Revision =             ACPI_PLD_GET_REVISION (&Dword);
593*385cc6b4SJerry Jelinek     PldInfo->IgnoreColor =          ACPI_PLD_GET_IGNORE_COLOR (&Dword);
594*385cc6b4SJerry Jelinek     PldInfo->Red =                  ACPI_PLD_GET_RED (&Dword);
595*385cc6b4SJerry Jelinek     PldInfo->Green =                ACPI_PLD_GET_GREEN (&Dword);
596*385cc6b4SJerry Jelinek     PldInfo->Blue =                 ACPI_PLD_GET_BLUE (&Dword);
597*385cc6b4SJerry Jelinek 
598*385cc6b4SJerry Jelinek     /* Second 32-bit DWord */
599*385cc6b4SJerry Jelinek 
600*385cc6b4SJerry Jelinek     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[1]);
601*385cc6b4SJerry Jelinek     PldInfo->Width =                ACPI_PLD_GET_WIDTH (&Dword);
602*385cc6b4SJerry Jelinek     PldInfo->Height =               ACPI_PLD_GET_HEIGHT(&Dword);
603*385cc6b4SJerry Jelinek 
604*385cc6b4SJerry Jelinek     /* Third 32-bit DWord */
605*385cc6b4SJerry Jelinek 
606*385cc6b4SJerry Jelinek     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[2]);
607*385cc6b4SJerry Jelinek     PldInfo->UserVisible =          ACPI_PLD_GET_USER_VISIBLE (&Dword);
608*385cc6b4SJerry Jelinek     PldInfo->Dock =                 ACPI_PLD_GET_DOCK (&Dword);
609*385cc6b4SJerry Jelinek     PldInfo->Lid =                  ACPI_PLD_GET_LID (&Dword);
610*385cc6b4SJerry Jelinek     PldInfo->Panel =                ACPI_PLD_GET_PANEL (&Dword);
611*385cc6b4SJerry Jelinek     PldInfo->VerticalPosition =     ACPI_PLD_GET_VERTICAL (&Dword);
612*385cc6b4SJerry Jelinek     PldInfo->HorizontalPosition =   ACPI_PLD_GET_HORIZONTAL (&Dword);
613*385cc6b4SJerry Jelinek     PldInfo->Shape =                ACPI_PLD_GET_SHAPE (&Dword);
614*385cc6b4SJerry Jelinek     PldInfo->GroupOrientation =     ACPI_PLD_GET_ORIENTATION (&Dword);
615*385cc6b4SJerry Jelinek     PldInfo->GroupToken =           ACPI_PLD_GET_TOKEN (&Dword);
616*385cc6b4SJerry Jelinek     PldInfo->GroupPosition =        ACPI_PLD_GET_POSITION (&Dword);
617*385cc6b4SJerry Jelinek     PldInfo->Bay =                  ACPI_PLD_GET_BAY (&Dword);
618*385cc6b4SJerry Jelinek 
619*385cc6b4SJerry Jelinek     /* Fourth 32-bit DWord */
620*385cc6b4SJerry Jelinek 
621*385cc6b4SJerry Jelinek     ACPI_MOVE_32_TO_32 (&Dword, &Buffer[3]);
622*385cc6b4SJerry Jelinek     PldInfo->Ejectable =            ACPI_PLD_GET_EJECTABLE (&Dword);
623*385cc6b4SJerry Jelinek     PldInfo->OspmEjectRequired =    ACPI_PLD_GET_OSPM_EJECT (&Dword);
624*385cc6b4SJerry Jelinek     PldInfo->CabinetNumber =        ACPI_PLD_GET_CABINET (&Dword);
625*385cc6b4SJerry Jelinek     PldInfo->CardCageNumber =       ACPI_PLD_GET_CARD_CAGE (&Dword);
626*385cc6b4SJerry Jelinek     PldInfo->Reference =            ACPI_PLD_GET_REFERENCE (&Dword);
627*385cc6b4SJerry Jelinek     PldInfo->Rotation =             ACPI_PLD_GET_ROTATION (&Dword);
628*385cc6b4SJerry Jelinek     PldInfo->Order =                ACPI_PLD_GET_ORDER (&Dword);
629*385cc6b4SJerry Jelinek 
630*385cc6b4SJerry Jelinek     if (Length >= ACPI_PLD_REV2_BUFFER_SIZE)
631*385cc6b4SJerry Jelinek     {
632*385cc6b4SJerry Jelinek         /* Fifth 32-bit DWord (Revision 2 of _PLD) */
633*385cc6b4SJerry Jelinek 
634*385cc6b4SJerry Jelinek         ACPI_MOVE_32_TO_32 (&Dword, &Buffer[4]);
635*385cc6b4SJerry Jelinek         PldInfo->VerticalOffset =       ACPI_PLD_GET_VERT_OFFSET (&Dword);
636*385cc6b4SJerry Jelinek         PldInfo->HorizontalOffset =     ACPI_PLD_GET_HORIZ_OFFSET (&Dword);
637*385cc6b4SJerry Jelinek     }
638*385cc6b4SJerry Jelinek 
639*385cc6b4SJerry Jelinek     *ReturnBuffer = PldInfo;
640*385cc6b4SJerry Jelinek     return (AE_OK);
641*385cc6b4SJerry Jelinek }
642*385cc6b4SJerry Jelinek 
643*385cc6b4SJerry Jelinek ACPI_EXPORT_SYMBOL (AcpiDecodePldBuffer)
644