3e8d6d858d29b9b60a861bbf3460b0ebba648171
1 /*******************************************************************************
3 * Module Name: utxfmutex - external AML mutex access functions
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utxfmutex")
53 /* Local prototypes */
56 AcpiUtGetMutexObject (
59 ACPI_OPERAND_OBJECT
**RetObj
);
62 /*******************************************************************************
64 * FUNCTION: AcpiUtGetMutexObject
66 * PARAMETERS: Handle - Mutex or prefix handle (optional)
67 * Pathname - Mutex pathname (optional)
68 * RetObj - Where the mutex object is returned
72 * DESCRIPTION: Get an AML mutex object. The mutex node is pointed to by
73 * Handle:Pathname. Either Handle or Pathname can be NULL, but
76 ******************************************************************************/
79 AcpiUtGetMutexObject (
82 ACPI_OPERAND_OBJECT
**RetObj
)
84 ACPI_NAMESPACE_NODE
*MutexNode
;
85 ACPI_OPERAND_OBJECT
*MutexObj
;
89 /* Parameter validation */
91 if (!RetObj
|| (!Handle
&& !Pathname
))
93 return (AE_BAD_PARAMETER
);
96 /* Get a the namespace node for the mutex */
101 Status
= AcpiGetHandle (
102 Handle
, Pathname
, ACPI_CAST_PTR (ACPI_HANDLE
, &MutexNode
));
103 if (ACPI_FAILURE (Status
))
109 /* Ensure that we actually have a Mutex object */
112 (MutexNode
->Type
!= ACPI_TYPE_MUTEX
))
117 /* Get the low-level mutex object */
119 MutexObj
= AcpiNsGetAttachedObject (MutexNode
);
122 return (AE_NULL_OBJECT
);
130 /*******************************************************************************
132 * FUNCTION: AcpiAcquireMutex
134 * PARAMETERS: Handle - Mutex or prefix handle (optional)
135 * Pathname - Mutex pathname (optional)
136 * Timeout - Max time to wait for the lock (millisec)
140 * DESCRIPTION: Acquire an AML mutex. This is a device driver interface to
141 * AML mutex objects, and allows for transaction locking between
142 * drivers and AML code. The mutex node is pointed to by
143 * Handle:Pathname. Either Handle or Pathname can be NULL, but
146 ******************************************************************************/
151 ACPI_STRING Pathname
,
155 ACPI_OPERAND_OBJECT
*MutexObj
;
158 /* Get the low-level mutex associated with Handle:Pathname */
160 Status
= AcpiUtGetMutexObject (Handle
, Pathname
, &MutexObj
);
161 if (ACPI_FAILURE (Status
))
166 /* Acquire the OS mutex */
168 Status
= AcpiOsAcquireMutex (MutexObj
->Mutex
.OsMutex
, Timeout
);
173 /*******************************************************************************
175 * FUNCTION: AcpiReleaseMutex
177 * PARAMETERS: Handle - Mutex or prefix handle (optional)
178 * Pathname - Mutex pathname (optional)
182 * DESCRIPTION: Release an AML mutex. This is a device driver interface to
183 * AML mutex objects, and allows for transaction locking between
184 * drivers and AML code. The mutex node is pointed to by
185 * Handle:Pathname. Either Handle or Pathname can be NULL, but
188 ******************************************************************************/
193 ACPI_STRING Pathname
)
196 ACPI_OPERAND_OBJECT
*MutexObj
;
199 /* Get the low-level mutex associated with Handle:Pathname */
201 Status
= AcpiUtGetMutexObject (Handle
, Pathname
, &MutexObj
);
202 if (ACPI_FAILURE (Status
))
207 /* Release the OS mutex */
209 AcpiOsReleaseMutex (MutexObj
->Mutex
.OsMutex
);