ReactOS 0.4.16-dev-117-g38f21f9
utownerid.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
Include dependency graph for utownerid.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_UTILITIES
 

Functions

ACPI_STATUS AcpiUtAllocateOwnerId (ACPI_OWNER_ID *OwnerId)
 
void AcpiUtReleaseOwnerId (ACPI_OWNER_ID *OwnerIdPtr)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_UTILITIES

Definition at line 49 of file utownerid.c.

Function Documentation

◆ AcpiUtAllocateOwnerId()

ACPI_STATUS AcpiUtAllocateOwnerId ( ACPI_OWNER_ID OwnerId)

Definition at line 68 of file utownerid.c.

70{
71 UINT32 i;
72 UINT32 j;
73 UINT32 k;
75
76
77 ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
78
79
80 /* Guard against multiple allocations of ID to the same location */
81
82 if (*OwnerId)
83 {
85 "Owner ID [0x%3.3X] already exists", *OwnerId));
87 }
88
89 /* Mutex for the global ID mask */
90
92 if (ACPI_FAILURE (Status))
93 {
95 }
96
97 /*
98 * Find a free owner ID, cycle through all possible IDs on repeated
99 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index
100 * may have to be scanned twice.
101 */
102 for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
104 i++, j++)
105 {
107 {
108 j = 0; /* Wraparound to start of mask array */
109 }
110
111 for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
112 {
113 if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
114 {
115 /* There are no free IDs in this mask */
116
117 break;
118 }
119
120 /*
121 * Note: the UINT32 cast ensures that 1 is stored as a unsigned
122 * integer. Omitting the cast may result in 1 being stored as an
123 * int. Some compilers or runtime error detection may flag this as
124 * an error.
125 */
126 if (!(AcpiGbl_OwnerIdMask[j] & ((UINT32) 1 << k)))
127 {
128 /*
129 * Found a free ID. The actual ID is the bit index plus one,
130 * making zero an invalid Owner ID. Save this as the last ID
131 * allocated and update the global ID mask.
132 */
133 AcpiGbl_OwnerIdMask[j] |= ((UINT32) 1 << k);
134
135 AcpiGbl_LastOwnerIdIndex = (UINT8) j;
136 AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
137
138 /*
139 * Construct encoded ID from the index and bit position
140 *
141 * Note: Last [j].k (bit 4095) is never used and is marked
142 * permanently allocated (prevents +1 overflow)
143 */
144 *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
145
147 "Allocated OwnerId: 0x%3.3X\n", (unsigned int) *OwnerId));
148 goto Exit;
149 }
150 }
151
152 AcpiGbl_NextOwnerIdOffset = 0;
153 }
154
155 /*
156 * All OwnerIds have been allocated. This typically should
157 * not happen since the IDs are reused after deallocation. The IDs are
158 * allocated upon table load (one per table) and method execution, and
159 * they are released when a table is unloaded or a method completes
160 * execution.
161 *
162 * If this error happens, there may be very deep nesting of invoked
163 * control methods, or there may be a bug where the IDs are not released.
164 */
167 "Could not allocate new OwnerId (4095 max), AE_OWNER_ID_LIMIT"));
168
169Exit:
172}
unsigned char UINT8
unsigned int UINT32
#define AE_OWNER_ID_LIMIT
Definition: acexcep.h:135
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
#define ACPI_MTX_CACHES
Definition: aclocal.h:88
#define ACPI_MUL_32(a)
Definition: acmacros.h:223
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_VALUES
Definition: acoutput.h:173
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_UINT32_MAX
Definition: actypes.h:66
UINT16 ACPI_OWNER_ID
Definition: actypes.h:486
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
#define ACPI_NUM_OWNERID_MASKS
Definition: acconfig.h:136
_Must_inspect_result_ _In_opt_ PVOID OwnerId
Definition: fsrtlfuncs.h:907
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
int k
Definition: mpi.c:3369
static void Exit(void)
Definition: sock.c:1330

Referenced by AcpiDsBeginMethodExecution(), and AcpiTbAllocateOwnerId().

◆ AcpiUtReleaseOwnerId()

void AcpiUtReleaseOwnerId ( ACPI_OWNER_ID OwnerIdPtr)

Definition at line 190 of file utownerid.c.

192{
193 ACPI_OWNER_ID OwnerId = *OwnerIdPtr;
196 UINT32 Bit;
197
198
199 ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
200
201
202 /* Always clear the input OwnerId (zero is an invalid ID) */
203
204 *OwnerIdPtr = 0;
205
206 /* Zero is not a valid OwnerID */
207
208 if (OwnerId == 0)
209 {
210 ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%3.3X", OwnerId));
212 }
213
214 /* Mutex for the global ID mask */
215
217 if (ACPI_FAILURE (Status))
218 {
220 }
221
222 /* Normalize the ID to zero */
223
224 OwnerId--;
225
226 /* Decode ID to index/offset pair */
227
229 Bit = (UINT32) 1 << ACPI_MOD_32 (OwnerId);
230
231 /* Free the owner ID only if it is valid */
232
233 if (AcpiGbl_OwnerIdMask[Index] & Bit)
234 {
235 AcpiGbl_OwnerIdMask[Index] ^= Bit;
236 }
237 else
238 {
240 "Attempted release of non-allocated OwnerId: 0x%3.3X", OwnerId + 1));
241 }
242
245}
#define ACPI_DIV_32(a)
Definition: acmacros.h:222
#define ACPI_MOD_32(a)
Definition: acmacros.h:224
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
#define return_VOID
Definition: acoutput.h:495
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by AcpiDsTerminateControlMethod(), and AcpiTbReleaseOwnerId().