ReactOS 0.4.16-dev-91-g764881a
exutils.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "amlcode.h"
Include dependency graph for exutils.c:

Go to the source code of this file.

Macros

#define DEFINE_AML_GLOBALS
 
#define _COMPONENT   ACPI_EXECUTER
 

Functions

static UINT32 AcpiExDigitsNeeded (UINT64 Value, UINT32 Base)
 
void AcpiExEnterInterpreter (void)
 
void AcpiExExitInterpreter (void)
 
BOOLEAN AcpiExTruncateFor32bitTable (ACPI_OPERAND_OBJECT *ObjDesc)
 
void AcpiExAcquireGlobalLock (UINT32 FieldFlags)
 
void AcpiExReleaseGlobalLock (UINT32 FieldFlags)
 
void AcpiExEisaIdToString (char *OutString, UINT64 CompressedId)
 
void AcpiExIntegerToString (char *OutString, UINT64 Value)
 
void AcpiExPciClsToString (char *OutString, UINT8 ClassCode[3])
 
BOOLEAN AcpiIsValidSpaceId (UINT8 SpaceId)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 65 of file exutils.c.

◆ DEFINE_AML_GLOBALS

#define DEFINE_AML_GLOBALS

Definition at line 58 of file exutils.c.

Function Documentation

◆ AcpiExAcquireGlobalLock()

void AcpiExAcquireGlobalLock ( UINT32  FieldFlags)

Definition at line 225 of file exutils.c.

227{
229
230
231 ACPI_FUNCTION_TRACE (ExAcquireGlobalLock);
232
233
234 /* Only use the lock if the AlwaysLock bit is set */
235
236 if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
237 {
239 }
240
241 /* Attempt to get the global lock, wait forever */
242
244 AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
245
246 if (ACPI_FAILURE (Status))
247 {
249 "Could not acquire Global Lock"));
250 }
251
253}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_INFO
Definition: acoutput.h:230
#define return_VOID
Definition: acoutput.h:495
ACPI_THREAD_ID AcpiOsGetThreadId(void)
Definition: osl.c:217
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_WAIT_FOREVER
Definition: actypes.h:501
#define AML_FIELD_LOCK_RULE_MASK
Definition: amlcode.h:443
ACPI_STATUS AcpiExAcquireMutexObject(UINT16 Timeout, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_ID ThreadId)
Definition: exmutex.c:176
Status
Definition: gdiplustypes.h:25

Referenced by AcpiExReadDataFromField(), AcpiExReadGpio(), AcpiExReadSerialBus(), AcpiExWriteDataToField(), AcpiExWriteGpio(), and AcpiExWriteSerialBus().

◆ AcpiExDigitsNeeded()

static UINT32 AcpiExDigitsNeeded ( UINT64  Value,
UINT32  Base 
)
static

Definition at line 316 of file exutils.c.

319{
320 UINT32 NumDigits;
321 UINT64 CurrentValue;
322
323
324 ACPI_FUNCTION_TRACE (ExDigitsNeeded);
325
326
327 /* UINT64 is unsigned, so we don't worry about a '-' prefix */
328
329 if (Value == 0)
330 {
331 return_UINT32 (1);
332 }
333
334 CurrentValue = Value;
335 NumDigits = 0;
336
337 /* Count the digits in the requested base */
338
339 while (CurrentValue)
340 {
341 (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL);
342 NumDigits++;
343 }
344
345 return_UINT32 (NumDigits);
346}
unsigned long long UINT64
unsigned int UINT32
#define return_UINT32(s)
Definition: acoutput.h:501
ACPI_STATUS AcpiUtShortDivide(UINT64 InDividend, UINT32 Divisor, UINT64 *OutQuotient, UINT32 *OutRemainder)
Definition: utmath.c:337
#define NULL
Definition: types.h:112
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2451
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by AcpiExIntegerToString().

◆ AcpiExEisaIdToString()

void AcpiExEisaIdToString ( char OutString,
UINT64  CompressedId 
)

Definition at line 366 of file exutils.c.

369{
370 UINT32 SwappedId;
371
372
374
375
376 /* The EISAID should be a 32-bit integer */
377
378 if (CompressedId > ACPI_UINT32_MAX)
379 {
381 "Expected EISAID is larger than 32 bits: "
382 "0x%8.8X%8.8X, truncating",
383 ACPI_FORMAT_UINT64 (CompressedId)));
384 }
385
386 /* Swap ID to big-endian to get contiguous bits */
387
388 SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId);
389
390 /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
391
392 OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F));
393 OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F));
394 OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F));
395 OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12);
396 OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8);
397 OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4);
398 OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0);
399 OutString[7] = 0;
400}
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_UINT32_MAX
Definition: actypes.h:66
UINT32 AcpiUtDwordByteSwap(UINT32 Value)
Definition: utmisc.c:136
char AcpiUtHexToAsciiChar(UINT64 Integer, UINT32 Position)
Definition: uthex.c:74
unsigned char
Definition: typeof.h:29

Referenced by AcpiUtExecute_CID(), and AcpiUtExecute_HID().

◆ AcpiExEnterInterpreter()

void AcpiExEnterInterpreter ( void  )

Definition at line 91 of file exutils.c.

93{
95
96
97 ACPI_FUNCTION_TRACE (ExEnterInterpreter);
98
99
101 if (ACPI_FAILURE (Status))
102 {
103 ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
104 }
106 if (ACPI_FAILURE (Status))
107 {
108 ACPI_ERROR ((AE_INFO, "Could not acquire AML Namespace mutex"));
109 }
110
112}
#define ACPI_MTX_INTERPRETER
Definition: aclocal.h:84
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256

Referenced by AcpiAcquireGlobalLock(), AcpiDsMethodError(), AcpiDsTerminateControlMethod(), AcpiEvAddressSpaceDispatch(), AcpiEvaluateObject(), AcpiEvInitializeRegion(), AcpiExLoadOp(), AcpiExLoadTableOp(), AcpiExSystemDoSleep(), AcpiExSystemWaitMutex(), AcpiExSystemWaitSemaphore(), AcpiExUnloadTable(), AcpiNsEvaluate(), AcpiNsInitOneObject(), AcpiNsLoadTable(), AcpiNsOneCompleteParse(), AcpiPsExecuteTable(), and AcpiPsParseAml().

◆ AcpiExExitInterpreter()

void AcpiExExitInterpreter ( void  )

◆ AcpiExIntegerToString()

void AcpiExIntegerToString ( char OutString,
UINT64  Value 
)

Definition at line 421 of file exutils.c.

424{
426 UINT32 DigitsNeeded;
428
429
431
432
433 DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
434 OutString[DigitsNeeded] = 0;
435
436 for (Count = DigitsNeeded; Count > 0; Count--)
437 {
439 OutString[Count-1] = (char) ('0' + Remainder);\
440 }
441}
static UINT32 AcpiExDigitsNeeded(UINT64 Value, UINT32 Base)
Definition: exutils.c:316
int Count
Definition: noreturn.cpp:7
_In_ LARGE_INTEGER _Out_opt_ PLARGE_INTEGER Remainder
Definition: rtlfuncs.h:3059

Referenced by AcpiUtExecute_UID().

◆ AcpiExPciClsToString()

void AcpiExPciClsToString ( char OutString,
UINT8  ClassCode[3] 
)

Definition at line 461 of file exutils.c.

464{
465
467
468
469 /* All 3 bytes are hexadecimal */
470
471 OutString[0] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 4);
472 OutString[1] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 0);
473 OutString[2] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 4);
474 OutString[3] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 0);
475 OutString[4] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 4);
476 OutString[5] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 0);
477 OutString[6] = 0;
478}

Referenced by AcpiUtExecute_CLS().

◆ AcpiExReleaseGlobalLock()

void AcpiExReleaseGlobalLock ( UINT32  FieldFlags)

Definition at line 270 of file exutils.c.

272{
274
275
276 ACPI_FUNCTION_TRACE (ExReleaseGlobalLock);
277
278
279 /* Only use the lock if the AlwaysLock bit is set */
280
281 if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
282 {
284 }
285
286 /* Release the global lock */
287
288 Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
289 if (ACPI_FAILURE (Status))
290 {
291 /* Report the error, but there isn't much else we can do */
292
294 "Could not release Global Lock"));
295 }
296
298}
ACPI_STATUS AcpiExReleaseMutexObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exmutex.c:344

Referenced by AcpiExReadDataFromField(), AcpiExReadGpio(), AcpiExReadSerialBus(), AcpiExWriteDataToField(), AcpiExWriteGpio(), and AcpiExWriteSerialBus().

◆ AcpiExTruncateFor32bitTable()

BOOLEAN AcpiExTruncateFor32bitTable ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 177 of file exutils.c.

179{
180
182
183
184 /*
185 * Object must be a valid number and we must be executing
186 * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
187 */
188 if ((!ObjDesc) ||
190 (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
191 {
192 return (FALSE);
193 }
194
195 if ((AcpiGbl_IntegerByteWidth == 4) &&
196 (ObjDesc->Integer.Value > (UINT64) ACPI_UINT32_MAX))
197 {
198 /*
199 * We are executing in a 32-bit ACPI table. Truncate
200 * the value to 32 bits by zeroing out the upper 32-bit field
201 */
202 ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
203 return (TRUE);
204 }
205
206 return (FALSE);
207}
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
#define ACPI_DESC_TYPE_OPERAND
Definition: acobject.h:576
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519

Referenced by AcpiDsExecEndOp(), AcpiDsGetPredicateValue(), AcpiDsInitObjectFromOp(), AcpiExConvertToInteger(), and AcpiExStoreObjectToObject().

◆ AcpiIsValidSpaceId()

BOOLEAN AcpiIsValidSpaceId ( UINT8  SpaceId)

Definition at line 494 of file exutils.c.

496{
497
502 {
503 return (FALSE);
504 }
505
506 return (TRUE);
507}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE SpaceId
Definition: acpixf.h:832
#define ACPI_NUM_PREDEFINED_REGIONS
Definition: actypes.h:874
#define ACPI_ADR_SPACE_FIXED_HARDWARE
Definition: actypes.h:885
#define ACPI_ADR_SPACE_DATA_TABLE
Definition: actypes.h:884
#define ACPI_USER_REGION_BEGIN
Definition: acconfig.h:197

Referenced by AcpiExCreateRegion(), and AcpiExSetupRegion().