ReactOS 0.4.15-dev-7934-g1dc8d80
acinterp.h File Reference

Go to the source code of this file.

Classes

struct  acpi_exdump_info
 

Macros

#define ACPI_WALK_OPERANDS   (&(WalkState->Operands [WalkState->NumOperands -1]))
 
#define ACPI_EXD_OFFSET(f)   (UINT8) ACPI_OFFSET (ACPI_OPERAND_OBJECT,f)
 
#define ACPI_EXD_NSOFFSET(f)   (UINT8) ACPI_OFFSET (ACPI_NAMESPACE_NODE,f)
 
#define ACPI_EXD_TABLE_SIZE(name)   (sizeof(name) / sizeof (ACPI_EXDUMP_INFO))
 
#define ACPI_EXD_INIT   0
 
#define ACPI_EXD_TYPE   1
 
#define ACPI_EXD_UINT8   2
 
#define ACPI_EXD_UINT16   3
 
#define ACPI_EXD_UINT32   4
 
#define ACPI_EXD_UINT64   5
 
#define ACPI_EXD_LITERAL   6
 
#define ACPI_EXD_POINTER   7
 
#define ACPI_EXD_ADDRESS   8
 
#define ACPI_EXD_STRING   9
 
#define ACPI_EXD_BUFFER   10
 
#define ACPI_EXD_PACKAGE   11
 
#define ACPI_EXD_FIELD   12
 
#define ACPI_EXD_REFERENCE   13
 
#define ACPI_EXD_LIST   14 /* Operand object list */
 
#define ACPI_EXD_HDLR_LIST   15 /* Address Handler list */
 
#define ACPI_EXD_RGN_LIST   16 /* Region list */
 
#define ACPI_EXD_NODE   17 /* Namespace Node */
 
#define ACPI_EXPLICIT_BYTE_COPY   0x00000000
 
#define ACPI_EXPLICIT_CONVERT_HEX   0x00000001
 
#define ACPI_IMPLICIT_CONVERT_HEX   0x00000002
 
#define ACPI_EXPLICIT_CONVERT_DECIMAL   0x00000003
 

Typedefs

typedef const struct acpi_exdump_info ACPI_EXDUMP_INFO
 

Functions

ACPI_STATUS AcpiExConvertToInteger (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 ImplicitConversion)
 
ACPI_STATUS AcpiExConvertToBuffer (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
 
ACPI_STATUS AcpiExConvertToString (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 Type)
 
ACPI_STATUS AcpiExConvertToTargetType (ACPI_OBJECT_TYPE DestinationType, ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState)
 
void AcpiExDoDebugObject (ACPI_OPERAND_OBJECT *SourceDesc, UINT32 Level, UINT32 Index)
 
void AcpiExStartTraceMethod (ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
 
void AcpiExStopTraceMethod (ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
 
void AcpiExStartTraceOpcode (ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
 
void AcpiExStopTraceOpcode (ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
 
void AcpiExTracePoint (ACPI_TRACE_EVENT_TYPE Type, BOOLEAN Begin, UINT8 *Aml, char *Pathname)
 
ACPI_STATUS AcpiExGetProtocolBufferLength (UINT32 ProtocolId, UINT32 *ReturnLength)
 
ACPI_STATUS AcpiExCommonBufferSetup (ACPI_OPERAND_OBJECT *ObjDesc, UINT32 BufferLength, UINT32 *DatumCount)
 
ACPI_STATUS AcpiExWriteWithUpdateRule (ACPI_OPERAND_OBJECT *ObjDesc, UINT64 Mask, UINT64 FieldValue, UINT32 FieldDatumByteOffset)
 
void AcpiExGetBufferDatum (UINT64 *Datum, void *Buffer, UINT32 BufferLength, UINT32 ByteGranularity, UINT32 BufferOffset)
 
void AcpiExSetBufferDatum (UINT64 MergedDatum, void *Buffer, UINT32 BufferLength, UINT32 ByteGranularity, UINT32 BufferOffset)
 
ACPI_STATUS AcpiExReadDataFromField (ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **RetBufferDesc)
 
ACPI_STATUS AcpiExWriteDataToField (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
 
ACPI_STATUS AcpiExExtractFromField (ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer, UINT32 BufferLength)
 
ACPI_STATUS AcpiExInsertIntoField (ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer, UINT32 BufferLength)
 
ACPI_STATUS AcpiExAccessRegion (ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, UINT64 *Value, UINT32 ReadWrite)
 
ACPI_STATUS AcpiExGetObjectReference (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExConcatTemplate (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *ObjDesc2, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExDoConcatenate (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *ObjDesc2, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExDoLogicalNumericOp (UINT16 Opcode, UINT64 Integer0, UINT64 Integer1, BOOLEAN *LogicalResult)
 
ACPI_STATUS AcpiExDoLogicalOp (UINT16 Opcode, ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, BOOLEAN *LogicalResult)
 
UINT64 AcpiExDoMathOp (UINT16 Opcode, UINT64 Operand0, UINT64 Operand1)
 
ACPI_STATUS AcpiExCreateMutex (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateProcessor (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreatePowerResource (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateRegion (UINT8 *AmlStart, UINT32 AmlLength, UINT8 RegionSpace, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateEvent (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateAlias (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateMethod (UINT8 *AmlStart, UINT32 AmlLength, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExLoadOp (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExLoadTableOp (ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **ReturnDesc)
 
ACPI_STATUS AcpiExUnloadTable (ACPI_OPERAND_OBJECT *DdbHandle)
 
ACPI_STATUS AcpiExAcquireMutex (ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExAcquireMutexObject (UINT16 Timeout, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_ID ThreadId)
 
ACPI_STATUS AcpiExReleaseMutex (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExReleaseMutexObject (ACPI_OPERAND_OBJECT *ObjDesc)
 
void AcpiExReleaseAllMutexes (ACPI_THREAD_STATE *Thread)
 
void AcpiExUnlinkMutex (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiExPrepCommonFieldObject (ACPI_OPERAND_OBJECT *ObjDesc, UINT8 FieldFlags, UINT8 FieldAttribute, UINT32 FieldBitPosition, UINT32 FieldBitLength)
 
ACPI_STATUS AcpiExPrepFieldValue (ACPI_CREATE_FIELD_INFO *Info)
 
ACPI_STATUS AcpiExReadSerialBus (ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
 
ACPI_STATUS AcpiExWriteSerialBus (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
 
ACPI_STATUS AcpiExReadGpio (ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer)
 
ACPI_STATUS AcpiExWriteGpio (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
 
ACPI_STATUS AcpiExSystemDoNotifyOp (ACPI_OPERAND_OBJECT *Value, ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiExSystemDoSleep (UINT64 Time)
 
ACPI_STATUS AcpiExSystemDoStall (UINT32 Time)
 
ACPI_STATUS AcpiExSystemSignalEvent (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiExSystemWaitEvent (ACPI_OPERAND_OBJECT *Time, ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiExSystemResetEvent (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiExSystemWaitSemaphore (ACPI_SEMAPHORE Semaphore, UINT16 Timeout)
 
ACPI_STATUS AcpiExSystemWaitMutex (ACPI_MUTEX Mutex, UINT16 Timeout)
 
ACPI_STATUS AcpiExOpcode_0A_0T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_1A_0T_0R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_1A_0T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_1A_1T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_1A_1T_0R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_0T_0R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_0T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_1T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_2A_2T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_3A_0T_0R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_3A_1T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExOpcode_6A_0T_1R (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExResolveToValue (ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExResolveMultiple (ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *Operand, ACPI_OBJECT_TYPE *ReturnType, ACPI_OPERAND_OBJECT **ReturnDesc)
 
ACPI_STATUS AcpiExResolveNodeToValue (ACPI_NAMESPACE_NODE **StackPtr, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExResolveOperands (UINT16 Opcode, ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
 
void AcpiExDumpOperand (ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Depth)
 
void AcpiExDumpOperands (ACPI_OPERAND_OBJECT **Operands, const char *OpcodeName, UINT32 NumOpcodes)
 
void AcpiExDumpObjectDescriptor (ACPI_OPERAND_OBJECT *Object, UINT32 Flags)
 
void AcpiExDumpNamespaceNode (ACPI_NAMESPACE_NODE *Node, UINT32 Flags)
 
ACPI_STATUS AcpiExGetNameString (ACPI_OBJECT_TYPE DataType, UINT8 *InAmlAddress, char **OutNameString, UINT32 *OutNameLength)
 
ACPI_STATUS AcpiExStore (ACPI_OPERAND_OBJECT *ValDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExStoreObjectToNode (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, ACPI_WALK_STATE *WalkState, UINT8 ImplicitConversion)
 
ACPI_STATUS AcpiExResolveObject (ACPI_OPERAND_OBJECT **SourceDescPtr, ACPI_OBJECT_TYPE TargetType, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExStoreObjectToObject (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_OPERAND_OBJECT **NewDesc, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExStoreBufferToBuffer (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 
ACPI_STATUS AcpiExStoreStringToString (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 
ACPI_STATUS AcpiExCopyIntegerToIndexField (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 
ACPI_STATUS AcpiExCopyIntegerToBankField (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 
ACPI_STATUS AcpiExCopyDataToNamedField (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node)
 
ACPI_STATUS AcpiExCopyIntegerToBufferField (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
 
void AcpiExEnterInterpreter (void)
 
void AcpiExExitInterpreter (void)
 
BOOLEAN AcpiExTruncateFor32bitTable (ACPI_OPERAND_OBJECT *ObjDesc)
 
void AcpiExAcquireGlobalLock (UINT32 Rule)
 
void AcpiExReleaseGlobalLock (UINT32 Rule)
 
void AcpiExEisaIdToString (char *Dest, UINT64 CompressedId)
 
void AcpiExIntegerToString (char *Dest, UINT64 Value)
 
void AcpiExPciClsToString (char *Dest, UINT8 ClassCode[3])
 
BOOLEAN AcpiIsValidSpaceId (UINT8 SpaceId)
 
ACPI_STATUS AcpiExSystemMemorySpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExSystemIoSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExPciConfigSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExCmosSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExPciBarSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExEmbeddedControllerSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExSmBusSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExDataTableSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 

Macro Definition Documentation

◆ ACPI_EXD_ADDRESS

#define ACPI_EXD_ADDRESS   8

Definition at line 86 of file acinterp.h.

◆ ACPI_EXD_BUFFER

#define ACPI_EXD_BUFFER   10

Definition at line 88 of file acinterp.h.

◆ ACPI_EXD_FIELD

#define ACPI_EXD_FIELD   12

Definition at line 90 of file acinterp.h.

◆ ACPI_EXD_HDLR_LIST

#define ACPI_EXD_HDLR_LIST   15 /* Address Handler list */

Definition at line 93 of file acinterp.h.

◆ ACPI_EXD_INIT

#define ACPI_EXD_INIT   0

Definition at line 78 of file acinterp.h.

◆ ACPI_EXD_LIST

#define ACPI_EXD_LIST   14 /* Operand object list */

Definition at line 92 of file acinterp.h.

◆ ACPI_EXD_LITERAL

#define ACPI_EXD_LITERAL   6

Definition at line 84 of file acinterp.h.

◆ ACPI_EXD_NODE

#define ACPI_EXD_NODE   17 /* Namespace Node */

Definition at line 95 of file acinterp.h.

◆ ACPI_EXD_NSOFFSET

#define ACPI_EXD_NSOFFSET (   f)    (UINT8) ACPI_OFFSET (ACPI_NAMESPACE_NODE,f)

Definition at line 53 of file acinterp.h.

◆ ACPI_EXD_OFFSET

#define ACPI_EXD_OFFSET (   f)    (UINT8) ACPI_OFFSET (ACPI_OPERAND_OBJECT,f)

Definition at line 52 of file acinterp.h.

◆ ACPI_EXD_PACKAGE

#define ACPI_EXD_PACKAGE   11

Definition at line 89 of file acinterp.h.

◆ ACPI_EXD_POINTER

#define ACPI_EXD_POINTER   7

Definition at line 85 of file acinterp.h.

◆ ACPI_EXD_REFERENCE

#define ACPI_EXD_REFERENCE   13

Definition at line 91 of file acinterp.h.

◆ ACPI_EXD_RGN_LIST

#define ACPI_EXD_RGN_LIST   16 /* Region list */

Definition at line 94 of file acinterp.h.

◆ ACPI_EXD_STRING

#define ACPI_EXD_STRING   9

Definition at line 87 of file acinterp.h.

◆ ACPI_EXD_TABLE_SIZE

#define ACPI_EXD_TABLE_SIZE (   name)    (sizeof(name) / sizeof (ACPI_EXDUMP_INFO))

Definition at line 54 of file acinterp.h.

◆ ACPI_EXD_TYPE

#define ACPI_EXD_TYPE   1

Definition at line 79 of file acinterp.h.

◆ ACPI_EXD_UINT16

#define ACPI_EXD_UINT16   3

Definition at line 81 of file acinterp.h.

◆ ACPI_EXD_UINT32

#define ACPI_EXD_UINT32   4

Definition at line 82 of file acinterp.h.

◆ ACPI_EXD_UINT64

#define ACPI_EXD_UINT64   5

Definition at line 83 of file acinterp.h.

◆ ACPI_EXD_UINT8

#define ACPI_EXD_UINT8   2

Definition at line 80 of file acinterp.h.

◆ ACPI_EXPLICIT_BYTE_COPY

#define ACPI_EXPLICIT_BYTE_COPY   0x00000000

Definition at line 124 of file acinterp.h.

◆ ACPI_EXPLICIT_CONVERT_DECIMAL

#define ACPI_EXPLICIT_CONVERT_DECIMAL   0x00000003

Definition at line 127 of file acinterp.h.

◆ ACPI_EXPLICIT_CONVERT_HEX

#define ACPI_EXPLICIT_CONVERT_HEX   0x00000001

Definition at line 125 of file acinterp.h.

◆ ACPI_IMPLICIT_CONVERT_HEX

#define ACPI_IMPLICIT_CONVERT_HEX   0x00000002

Definition at line 126 of file acinterp.h.

◆ ACPI_WALK_OPERANDS

#define ACPI_WALK_OPERANDS   (&(WalkState->Operands [WalkState->NumOperands -1]))

Definition at line 48 of file acinterp.h.

Typedef Documentation

◆ ACPI_EXDUMP_INFO

Function Documentation

◆ AcpiExAccessRegion()

ACPI_STATUS AcpiExAccessRegion ( ACPI_OPERAND_OBJECT ObjDesc,
UINT32  FieldDatumByteOffset,
UINT64 Value,
UINT32  ReadWrite 
)

Definition at line 249 of file exfldio.c.

254{
256 ACPI_OPERAND_OBJECT *RgnDesc;
257 UINT32 RegionOffset;
258
259
260 ACPI_FUNCTION_TRACE (ExAccessRegion);
261
262
263 /*
264 * Ensure that the region operands are fully evaluated and verify
265 * the validity of the request
266 */
267 Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
268 if (ACPI_FAILURE (Status))
269 {
271 }
272
273 /*
274 * The physical address of this field datum is:
275 *
276 * 1) The base of the region, plus
277 * 2) The base offset of the field, plus
278 * 3) The current offset into the field
279 */
280 RgnDesc = ObjDesc->CommonField.RegionObj;
281 RegionOffset =
282 ObjDesc->CommonField.BaseByteOffset +
283 FieldDatumByteOffset;
284
286 {
287 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
288 }
289 else
290 {
291 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
292 }
293
295 " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %8.8X%8.8X\n",
297 RgnDesc->Region.SpaceId,
298 ObjDesc->CommonField.AccessByteWidth,
299 ObjDesc->CommonField.BaseByteOffset,
300 FieldDatumByteOffset,
301 ACPI_FORMAT_UINT64 (RgnDesc->Region.Address + RegionOffset)));
302
303 /* Invoke the appropriate AddressSpace/OpRegion handler */
304
305 Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc,
306 Function, RegionOffset,
307 ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
308
309 if (ACPI_FAILURE (Status))
310 {
312 {
314 "Region %s (ID=%u) not implemented",
316 RgnDesc->Region.SpaceId));
317 }
318 else if (Status == AE_NOT_EXIST)
319 {
321 "Region %s (ID=%u) has no handler",
323 RgnDesc->Region.SpaceId));
324 }
325 }
326
328}
unsigned int UINT32
#define AE_NOT_IMPLEMENTED
Definition: acexcep.h:122
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_NOT_EXIST
Definition: acexcep.h:114
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_MUL_8(a)
Definition: acmacros.h:215
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_DB_BFIELD
Definition: acoutput.h:168
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_IO_MASK
Definition: actypes.h:753
#define ACPI_READ
Definition: actypes.h:751
UINT32 ACPI_STATUS
Definition: actypes.h:460
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:125
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
ACPI_STATUS AcpiEvAddressSpaceDispatch(ACPI_OPERAND_OBJECT *RegionObj, ACPI_OPERAND_OBJECT *FieldObj, UINT32 Function, UINT32 RegionOffset, UINT32 BitWidth, UINT64 *Value)
Definition: evregion.c:150
static ACPI_STATUS AcpiExSetupRegion(ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset)
Definition: exfldio.c:92
Status
Definition: gdiplustypes.h:25
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object * RegionObj
Definition: acobject.h:336
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
ACPI_PHYSICAL_ADDRESS Address
Definition: acobject.h:206
ACPI_OBJECT_REGION Region
Definition: acobject.h:527
ACPI_OBJECT_FIELD_COMMON CommonField
Definition: acobject.h:533
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

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

◆ AcpiExAcquireGlobalLock()

void AcpiExAcquireGlobalLock ( UINT32  Rule)

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_EXCEPTION(plist)
Definition: acoutput.h:239
#define return_VOID
Definition: acoutput.h:495
ACPI_THREAD_ID AcpiOsGetThreadId(void)
Definition: osl.c:217
#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

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

◆ AcpiExAcquireMutex()

ACPI_STATUS AcpiExAcquireMutex ( ACPI_OPERAND_OBJECT TimeDesc,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 248 of file exmutex.c.

252{
254
255
256 ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc);
257
258
259 if (!ObjDesc)
260 {
262 }
263
264 /* Must have a valid thread state struct */
265
266 if (!WalkState->Thread)
267 {
269 "Cannot acquire Mutex [%4.4s], null thread info",
270 AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
272 }
273
274 /*
275 * Current sync level must be less than or equal to the sync level
276 * of the mutex. This mechanism provides some deadlock prevention.
277 */
278 if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel)
279 {
281 "Cannot acquire Mutex [%4.4s], "
282 "current SyncLevel is too large (%u)",
283 AcpiUtGetNodeName (ObjDesc->Mutex.Node),
284 WalkState->Thread->CurrentSyncLevel));
286 }
287
289 "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, "
290 "Depth %u TID %p\n",
291 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
292 ObjDesc->Mutex.AcquisitionDepth, WalkState->Thread));
293
295 ObjDesc, WalkState->Thread->ThreadId);
296
297 if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1)
298 {
299 /* Save Thread object, original/current sync levels */
300
301 ObjDesc->Mutex.OwnerThread = WalkState->Thread;
302 ObjDesc->Mutex.OriginalSyncLevel =
303 WalkState->Thread->CurrentSyncLevel;
304 WalkState->Thread->CurrentSyncLevel =
305 ObjDesc->Mutex.SyncLevel;
306
307 /* Link the mutex to the current thread for force-unlock at method exit */
308
309 AcpiExLinkMutex (ObjDesc, WalkState->Thread);
310 }
311
313 "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n",
314 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
315 ObjDesc->Mutex.AcquisitionDepth));
316
318}
unsigned short UINT16
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_AML_MUTEX_ORDER
Definition: acexcep.h:200
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
static void AcpiExLinkMutex(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_STATE *Thread)
Definition: exmutex.c:125
ACPI_OBJECT_COMMON_HEADER UINT8 SyncLevel
Definition: acobject.h:186
struct acpi_thread_state * OwnerThread
Definition: acobject.h:190
UINT16 AcquisitionDepth
Definition: acobject.h:187
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:193
UINT8 OriginalSyncLevel
Definition: acobject.h:194
ACPI_STATE_COMMON UINT8 CurrentSyncLevel
Definition: aclocal.h:764
ACPI_THREAD_ID ThreadId
Definition: aclocal.h:767
ACPI_THREAD_STATE * Thread
Definition: acstruct.h:127
ACPI_OBJECT_MUTEX Mutex
Definition: acobject.h:526
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520

Referenced by AcpiExOpcode_2A_0T_1R().

◆ AcpiExAcquireMutexObject()

ACPI_STATUS AcpiExAcquireMutexObject ( UINT16  Timeout,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_THREAD_ID  ThreadId 
)

Definition at line 176 of file exmutex.c.

180{
182
183
184 ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc);
185
186
187 if (!ObjDesc)
188 {
190 }
191
192 /* Support for multiple acquires by the owning thread */
193
194 if (ObjDesc->Mutex.ThreadId == ThreadId)
195 {
196 /*
197 * The mutex is already owned by this thread, just increment the
198 * acquisition depth
199 */
200 ObjDesc->Mutex.AcquisitionDepth++;
202 }
203
204 /* Acquire the mutex, wait if necessary. Special case for Global Lock */
205
206 if (ObjDesc == AcpiGbl_GlobalLockMutex)
207 {
209 }
210 else
211 {
213 }
214
215 if (ACPI_FAILURE (Status))
216 {
217 /* Includes failure from a timeout on TimeDesc */
218
220 }
221
222 /* Acquired the mutex: update mutex object */
223
224 ObjDesc->Mutex.ThreadId = ThreadId;
225 ObjDesc->Mutex.AcquisitionDepth = 1;
226 ObjDesc->Mutex.OriginalSyncLevel = 0;
227 ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */
228
230}
#define AE_OK
Definition: acexcep.h:97
#define NULL
Definition: types.h:112
ACPI_STATUS AcpiEvAcquireGlobalLock(UINT16 Timeout)
Definition: evglock.c:230
ACPI_STATUS AcpiExSystemWaitMutex(ACPI_MUTEX Mutex, UINT16 Timeout)
Definition: exsystem.c:120
static ULONG Timeout
Definition: ping.c:61
ACPI_THREAD_ID ThreadId
Definition: acobject.h:189
ACPI_MUTEX OsMutex
Definition: acobject.h:188

Referenced by AcpiAcquireGlobalLock(), AcpiExAcquireGlobalLock(), and AcpiExAcquireMutex().

◆ AcpiExCmosSpaceHandler()

ACPI_STATUS AcpiExCmosSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 505 of file exregion.c.

512{
514
515
516 ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
517
518
520}

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExCommonBufferSetup()

ACPI_STATUS AcpiExCommonBufferSetup ( ACPI_OPERAND_OBJECT ObjDesc,
UINT32  BufferLength,
UINT32 DatumCount 
)

◆ AcpiExConcatTemplate()

ACPI_STATUS AcpiExConcatTemplate ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT ObjDesc2,
ACPI_OPERAND_OBJECT **  ActualReturnDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 388 of file exconcat.c.

393{
395 ACPI_OPERAND_OBJECT *ReturnDesc;
396 UINT8 *NewBuf;
397 UINT8 *EndTag;
398 ACPI_SIZE Length0;
399 ACPI_SIZE Length1;
400 ACPI_SIZE NewLength;
401
402
403 ACPI_FUNCTION_TRACE (ExConcatTemplate);
404
405
406 /*
407 * Find the EndTag descriptor in each resource template.
408 * Note1: returned pointers point TO the EndTag, not past it.
409 * Note2: zero-length buffers are allowed; treated like one EndTag
410 */
411
412 /* Get the length of the first resource template */
413
414 Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
415 if (ACPI_FAILURE (Status))
416 {
418 }
419
420 Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
421
422 /* Get the length of the second resource template */
423
424 Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
425 if (ACPI_FAILURE (Status))
426 {
428 }
429
430 Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
431
432 /* Combine both lengths, minimum size will be 2 for EndTag */
433
434 NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
435
436 /* Create a new buffer object for the result (with one EndTag) */
437
438 ReturnDesc = AcpiUtCreateBufferObject (NewLength);
439 if (!ReturnDesc)
440 {
442 }
443
444 /*
445 * Copy the templates to the new buffer, 0 first, then 1 follows. One
446 * EndTag descriptor is copied from Operand1.
447 */
448 NewBuf = ReturnDesc->Buffer.Pointer;
449 memcpy (NewBuf, Operand0->Buffer.Pointer, Length0);
450 memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
451
452 /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
453
454 NewBuf[NewLength - 1] = 0;
455 NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
456
457 /* Return the completed resource template */
458
459 *ActualReturnDesc = ReturnDesc;
461}
INT Length1
Definition: FsRtlDissect.c:15
static USHORT USHORT * NewLength
unsigned char UINT8
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_RESOURCE_NAME_END_TAG
Definition: aclocal.h:1323
#define ACPI_PTR_DIFF(a, b)
Definition: actypes.h:548
ACPI_STATUS AcpiUtGetResourceEndTag(ACPI_OPERAND_OBJECT *ObjDesc, UINT8 **EndTag)
Definition: utresrc.c:636
ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject(ACPI_SIZE BufferSize)
Definition: utobject.c:258
struct aml_resource_end_tag AML_RESOURCE_END_TAG
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522

Referenced by AcpiExOpcode_2A_1T_1R().

◆ AcpiExConvertToBuffer()

ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc 
)

Definition at line 224 of file exconvrt.c.

227{
228 ACPI_OPERAND_OBJECT *ReturnDesc;
229 UINT8 *NewBuf;
230
231
232 ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
233
234
235 switch (ObjDesc->Common.Type)
236 {
237 case ACPI_TYPE_BUFFER:
238
239 /* No conversion necessary */
240
241 *ResultDesc = ObjDesc;
243
244
246 /*
247 * Create a new Buffer object.
248 * Need enough space for one integer
249 */
250 ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
251 if (!ReturnDesc)
252 {
254 }
255
256 /* Copy the integer to the buffer, LSB first */
257
258 NewBuf = ReturnDesc->Buffer.Pointer;
259 memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);
260 break;
261
262 case ACPI_TYPE_STRING:
263 /*
264 * Create a new Buffer object
265 * Size will be the string length
266 *
267 * NOTE: Add one to the string length to include the null terminator.
268 * The ACPI spec is unclear on this subject, but there is existing
269 * ASL/AML code that depends on the null being transferred to the new
270 * buffer.
271 */
272 ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
273 ObjDesc->String.Length + 1);
274 if (!ReturnDesc)
275 {
277 }
278
279 /* Copy the string to the buffer */
280
281 NewBuf = ReturnDesc->Buffer.Pointer;
282 strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
283 ObjDesc->String.Length);
284 break;
285
286 default:
287
289 }
290
291 /* Mark buffer initialized */
292
293 ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
294 *ResultDesc = ReturnDesc;
296}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define AE_TYPE
Definition: acexcep.h:116
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_STRING String
Definition: acobject.h:521

Referenced by AcpiExConvertToTargetType(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExOpcode_1A_1T_1R(), AcpiExResolveOperands(), and AcpiNsConvertToBuffer().

◆ AcpiExConvertToInteger()

ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc,
UINT32  ImplicitConversion 
)

Definition at line 79 of file exconvrt.c.

83{
84 ACPI_OPERAND_OBJECT *ReturnDesc;
85 UINT8 *Pointer;
87 UINT32 i;
89
90
91 ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
92
93
94 switch (ObjDesc->Common.Type)
95 {
97
98 /* No conversion necessary */
99
100 *ResultDesc = ObjDesc;
102
103 case ACPI_TYPE_BUFFER:
104 case ACPI_TYPE_STRING:
105
106 /* Note: Takes advantage of common buffer/string fields */
107
108 Pointer = ObjDesc->Buffer.Pointer;
109 Count = ObjDesc->Buffer.Length;
110 break;
111
112 default:
113
115 }
116
117 /*
118 * Convert the buffer/string to an integer. Note that both buffers and
119 * strings are treated as raw data - we don't convert ascii to hex for
120 * strings.
121 *
122 * There are two terminating conditions for the loop:
123 * 1) The size of an integer has been reached, or
124 * 2) The end of the buffer or string has been reached
125 */
126 Result = 0;
127
128 /* String conversion is different than Buffer conversion */
129
130 switch (ObjDesc->Common.Type)
131 {
132 case ACPI_TYPE_STRING:
133 /*
134 * Convert string to an integer - for most cases, the string must be
135 * hexadecimal as per the ACPI specification. The only exception (as
136 * of ACPI 3.0) is that the ToInteger() operator allows both decimal
137 * and hexadecimal strings (hex prefixed with "0x").
138 *
139 * Explicit conversion is used only by ToInteger.
140 * All other string-to-integer conversions are implicit conversions.
141 */
142 if (ImplicitConversion)
143 {
144 Result = AcpiUtImplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));
145 }
146 else
147 {
148 Result = AcpiUtExplicitStrtoul64 (ACPI_CAST_PTR (char, Pointer));
149 }
150 break;
151
152 case ACPI_TYPE_BUFFER:
153
154 /* Check for zero-length buffer */
155
156 if (!Count)
157 {
159 }
160
161 /* Transfer no more than an integer's worth of data */
162
163 if (Count > AcpiGbl_IntegerByteWidth)
164 {
165 Count = AcpiGbl_IntegerByteWidth;
166 }
167
168 /*
169 * Convert buffer to an integer - we simply grab enough raw data
170 * from the buffer to fill an integer
171 */
172 for (i = 0; i < Count; i++)
173 {
174 /*
175 * Get next byte and shift it into the Result.
176 * Little endian is used, meaning that the first byte of the buffer
177 * is the LSB of the integer
178 */
179 Result |= (((UINT64) Pointer[i]) << (i * 8));
180 }
181 break;
182
183 default:
184
185 /* No other types can get here */
186
187 break;
188 }
189
190 /* Create a new integer */
191
192 ReturnDesc = AcpiUtCreateIntegerObject (Result);
193 if (!ReturnDesc)
194 {
196 }
197
198 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
200
201 /* Save the Result */
202
203 (void) AcpiExTruncateFor32bitTable (ReturnDesc);
204 *ResultDesc = ReturnDesc;
206}
unsigned long long UINT64
#define AE_AML_BUFFER_LIMIT
Definition: acexcep.h:189
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
UINT64 AcpiUtExplicitStrtoul64(char *String)
Definition: utstrtoul64.c:347
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
UINT64 AcpiUtImplicitStrtoul64(char *String)
Definition: utstrtoul64.c:259
BOOLEAN AcpiExTruncateFor32bitTable(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exutils.c:177
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
int Count
Definition: noreturn.cpp:7
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by AcpiDsGetPredicateValue(), AcpiExConvertToTargetType(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExOpcode_1A_1T_1R(), and AcpiExResolveOperands().

◆ AcpiExConvertToString()

ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc,
UINT32  Type 
)

Definition at line 440 of file exconvrt.c.

444{
445 ACPI_OPERAND_OBJECT *ReturnDesc;
446 UINT8 *NewBuf;
447 UINT32 i;
448 UINT32 StringLength = 0;
449 UINT16 Base = 16;
450 UINT8 Separator = ',';
451
452
453 ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
454
455
456 switch (ObjDesc->Common.Type)
457 {
458 case ACPI_TYPE_STRING:
459
460 /* No conversion necessary */
461
462 *ResultDesc = ObjDesc;
464
466
467 switch (Type)
468 {
470 /*
471 * From ToDecimalString, integer source.
472 *
473 * Make room for the maximum decimal number size
474 */
475 StringLength = ACPI_MAX_DECIMAL_DIGITS;
476 Base = 10;
477 break;
478
479 default:
480
481 /* Two hex string characters for each integer byte */
482
483 StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
484 break;
485 }
486
487 /*
488 * Create a new String
489 * Need enough space for one ASCII integer (plus null terminator)
490 */
491 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
492 if (!ReturnDesc)
493 {
495 }
496
497 NewBuf = ReturnDesc->Buffer.Pointer;
498
499 /* Convert integer to string */
500
501 StringLength = AcpiExConvertToAscii (
502 ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth);
503
504 /* Null terminate at the correct place */
505
506 ReturnDesc->String.Length = StringLength;
507 NewBuf [StringLength] = 0;
508 break;
509
510 case ACPI_TYPE_BUFFER:
511
512 /* Setup string length, base, and separator */
513
514 switch (Type)
515 {
516 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
517 /*
518 * Explicit conversion from the ToDecimalString ASL operator.
519 *
520 * From ACPI: "If the input is a buffer, it is converted to a
521 * a string of decimal values separated by commas."
522 */
523 Base = 10;
524
525 /*
526 * Calculate the final string length. Individual string values
527 * are variable length (include separator for each)
528 */
529 for (i = 0; i < ObjDesc->Buffer.Length; i++)
530 {
531 if (ObjDesc->Buffer.Pointer[i] >= 100)
532 {
533 StringLength += 4;
534 }
535 else if (ObjDesc->Buffer.Pointer[i] >= 10)
536 {
537 StringLength += 3;
538 }
539 else
540 {
541 StringLength += 2;
542 }
543 }
544 break;
545
547 /*
548 * Implicit buffer-to-string conversion
549 *
550 * From the ACPI spec:
551 * "The entire contents of the buffer are converted to a string of
552 * two-character hexadecimal numbers, each separated by a space."
553 *
554 * Each hex number is prefixed with 0x (11/2018)
555 */
556 Separator = ' ';
557 StringLength = (ObjDesc->Buffer.Length * 5);
558 break;
559
561 /*
562 * Explicit conversion from the ToHexString ASL operator.
563 *
564 * From ACPI: "If Data is a buffer, it is converted to a string of
565 * hexadecimal values separated by commas."
566 *
567 * Each hex number is prefixed with 0x (11/2018)
568 */
569 Separator = ',';
570 StringLength = (ObjDesc->Buffer.Length * 5);
571 break;
572
573 default:
575 }
576
577 /*
578 * Create a new string object and string buffer
579 * (-1 because of extra separator included in StringLength from above)
580 * Allow creation of zero-length strings from zero-length buffers.
581 */
582 if (StringLength)
583 {
584 StringLength--;
585 }
586
587 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
588 if (!ReturnDesc)
589 {
591 }
592
593 NewBuf = ReturnDesc->Buffer.Pointer;
594
595 /*
596 * Convert buffer bytes to hex or decimal values
597 * (separated by commas or spaces)
598 */
599 for (i = 0; i < ObjDesc->Buffer.Length; i++)
600 {
601 if (Base == 16)
602 {
603 /* Emit 0x prefix for explicit/implicit hex conversion */
604
605 *NewBuf++ = '0';
606 *NewBuf++ = 'x';
607 }
608
609 NewBuf += AcpiExConvertToAscii (
610 (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1);
611
612 /* Each digit is separated by either a comma or space */
613
614 *NewBuf++ = Separator;
615 }
616
617 /*
618 * Null terminate the string
619 * (overwrites final comma/space from above)
620 */
621 if (ObjDesc->Buffer.Length)
622 {
623 NewBuf--;
624 }
625 *NewBuf = 0;
626 break;
627
628 default:
629
631 }
632
633 *ResultDesc = ReturnDesc;
635}
Type
Definition: Type.h:7
#define ACPI_EXPLICIT_CONVERT_DECIMAL
Definition: acinterp.h:127
#define ACPI_EXPLICIT_CONVERT_HEX
Definition: acinterp.h:125
#define ACPI_IMPLICIT_CONVERT_HEX
Definition: acinterp.h:126
#define ACPI_MUL_2(a)
Definition: acmacros.h:207
#define ACPI_MAX_DECIMAL_DIGITS
Definition: actypes.h:491
ACPI_OPERAND_OBJECT * AcpiUtCreateStringObject(ACPI_SIZE StringSize)
Definition: utobject.c:320
static UINT32 AcpiExConvertToAscii(UINT64 Integer, UINT16 Base, UINT8 *String, UINT8 MaxLength)
Definition: exconvrt.c:315
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439

Referenced by AcpiExConvertToTargetType(), AcpiExDoConcatenate(), AcpiExDoLogicalOp(), AcpiExOpcode_1A_1T_1R(), AcpiExResolveOperands(), and AcpiNsConvertToString().

◆ AcpiExConvertToTargetType()

ACPI_STATUS AcpiExConvertToTargetType ( ACPI_OBJECT_TYPE  DestinationType,
ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT **  ResultDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 654 of file exconvrt.c.

659{
661
662
663 ACPI_FUNCTION_TRACE (ExConvertToTargetType);
664
665
666 /* Default behavior */
667
668 *ResultDesc = SourceDesc;
669
670 /*
671 * If required by the target,
672 * perform implicit conversion on the source before we store it.
673 */
674 switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
675 {
678 case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
679
680 switch (DestinationType)
681 {
683 /*
684 * Named field can always handle conversions
685 */
686 break;
687
688 default:
689
690 /* No conversion allowed for these types */
691
692 if (DestinationType != SourceDesc->Common.Type)
693 {
695 "Explicit operator, will store (%s) over existing type (%s)\n",
696 AcpiUtGetObjectTypeName (SourceDesc),
697 AcpiUtGetTypeName (DestinationType)));
698 Status = AE_TYPE;
699 }
700 }
701 break;
702
703 case ARGI_TARGETREF:
705
706 switch (DestinationType)
707 {
712 /*
713 * These types require an Integer operand. We can convert
714 * a Buffer or a String to an Integer if necessary.
715 */
716 Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
718 break;
719
720 case ACPI_TYPE_STRING:
721 /*
722 * The operand must be a String. We can convert an
723 * Integer or Buffer if necessary
724 */
725 Status = AcpiExConvertToString (SourceDesc, ResultDesc,
727 break;
728
729 case ACPI_TYPE_BUFFER:
730 /*
731 * The operand must be a Buffer. We can convert an
732 * Integer or String if necessary
733 */
734 Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
735 break;
736
737 default:
738
740 "Bad destination type during conversion: 0x%X",
741 DestinationType));
743 break;
744 }
745 break;
746
747 case ARGI_REFERENCE:
748 /*
749 * CreateXxxxField cases - we are storing the field object into the name
750 */
751 break;
752
753 default:
754
756 "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
758 WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
760 }
761
762 /*
763 * Source-to-Target conversion semantics:
764 *
765 * If conversion to the target type cannot be performed, then simply
766 * overwrite the target with the new object and type.
767 */
768 if (Status == AE_TYPE)
769 {
770 Status = AE_OK;
771 }
772
774}
#define GET_CURRENT_ARG_TYPE(List)
Definition: acmacros.h:450
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:701
#define ACPI_TYPE_LOCAL_BANK_FIELD
Definition: actypes.h:717
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:716
#define ACPI_TYPE_LOCAL_INDEX_FIELD
Definition: actypes.h:718
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:264
#define ACPI_IMPLICIT_CONVERSION
Definition: acutils.h:145
#define ARGI_REFERENCE
Definition: amlcode.h:279
#define ARGI_INTEGER_REF
Definition: amlcode.h:276
#define ARGI_FIXED_TARGET
Definition: amlcode.h:281
#define ARGI_TARGETREF
Definition: amlcode.h:280
#define ARGI_STORE_TARGET
Definition: amlcode.h:283
#define ARGI_SIMPLE_TARGET
Definition: amlcode.h:282
ACPI_STATUS AcpiExConvertToBuffer(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
Definition: exconvrt.c:224
ACPI_STATUS AcpiExConvertToInteger(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 ImplicitConversion)
Definition: exconvrt.c:79
ACPI_STATUS AcpiExConvertToString(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 Type)
Definition: exconvrt.c:440
UINT32 RuntimeArgs
Definition: aclocal.h:872
UINT16 Opcode
Definition: acstruct.h:78
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119

Referenced by AcpiExStoreObjectToObject().

◆ AcpiExCopyDataToNamedField()

ACPI_STATUS AcpiExCopyDataToNamedField ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_NAMESPACE_NODE Node 
)

◆ AcpiExCopyIntegerToBankField()

ACPI_STATUS AcpiExCopyIntegerToBankField ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

◆ AcpiExCopyIntegerToBufferField()

ACPI_STATUS AcpiExCopyIntegerToBufferField ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

◆ AcpiExCopyIntegerToIndexField()

ACPI_STATUS AcpiExCopyIntegerToIndexField ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

◆ AcpiExCreateAlias()

ACPI_STATUS AcpiExCreateAlias ( ACPI_WALK_STATE WalkState)

Definition at line 68 of file excreate.c.

70{
71 ACPI_NAMESPACE_NODE *TargetNode;
72 ACPI_NAMESPACE_NODE *AliasNode;
74
75
76 ACPI_FUNCTION_TRACE (ExCreateAlias);
77
78
79 /* Get the source/alias operands (both namespace nodes) */
80
81 AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
82 TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
83
84 if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
85 (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
86 {
87 /*
88 * Dereference an existing alias so that we don't create a chain
89 * of aliases. With this code, we guarantee that an alias is
90 * always exactly one level of indirection away from the
91 * actual aliased name.
92 */
93 TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
94 }
95
96 /* Ensure that the target node is valid */
97
98 if (!TargetNode)
99 {
101 }
102
103 /* Construct the alias object (a namespace node) */
104
105 switch (TargetNode->Type)
106 {
107 case ACPI_TYPE_METHOD:
108 /*
109 * Control method aliases need to be differentiated with
110 * a special type
111 */
113 break;
114
115 default:
116 /*
117 * All other object types.
118 *
119 * The new alias has the type ALIAS and points to the original
120 * NS node, not the object itself.
121 */
122 AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
123 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
124 break;
125 }
126
127 /* Since both operands are Nodes, we don't need to delete them */
128
129 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
131}
#define AE_NULL_OBJECT
Definition: acexcep.h:117
#define ACPI_TYPE_LOCAL_ALIAS
Definition: actypes.h:720
#define ACPI_TYPE_LOCAL_METHOD_ALIAS
Definition: actypes.h:721
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
union acpi_operand_object * Object
Definition: aclocal.h:187
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateEvent()

ACPI_STATUS AcpiExCreateEvent ( ACPI_WALK_STATE WalkState)

Definition at line 147 of file excreate.c.

149{
151 ACPI_OPERAND_OBJECT *ObjDesc;
152
153
154 ACPI_FUNCTION_TRACE (ExCreateEvent);
155
156
158 if (!ObjDesc)
159 {
161 goto Cleanup;
162 }
163
164 /*
165 * Create the actual OS semaphore, with zero initial units -- meaning
166 * that the event is created in an unsignalled state
167 */
169 &ObjDesc->Event.OsSemaphore);
170 if (ACPI_FAILURE (Status))
171 {
172 goto Cleanup;
173 }
174
175 /* Attach object to the Node */
176
178 (ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
179 ObjDesc, ACPI_TYPE_EVENT);
180
181Cleanup:
182 /*
183 * Remove local reference to the object (on error, will cause deletion
184 * of both object and semaphore if present.)
185 */
186 AcpiUtRemoveReference (ObjDesc);
188}
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle)
Definition: osl.c:352
#define ACPI_NO_UNIT_LIMIT
Definition: acpiosxf.h:67
#define ACPI_TYPE_EVENT
Definition: actypes.h:694
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
static const WCHAR Cleanup[]
Definition: register.c:80
ACPI_OBJECT_COMMON_HEADER ACPI_SEMAPHORE OsSemaphore
Definition: acobject.h:178
ACPI_OBJECT_EVENT Event
Definition: acobject.h:524

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateMethod()

ACPI_STATUS AcpiExCreateMethod ( UINT8 AmlStart,
UINT32  AmlLength,
ACPI_WALK_STATE WalkState 
)

Definition at line 484 of file excreate.c.

488{
489 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
490 ACPI_OPERAND_OBJECT *ObjDesc;
492 UINT8 MethodFlags;
493
494
495 ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
496
497
498 /* Create a new method object */
499
501 if (!ObjDesc)
502 {
504 goto Exit;
505 }
506
507 /* Save the method's AML pointer and length */
508
509 ObjDesc->Method.AmlStart = AmlStart;
510 ObjDesc->Method.AmlLength = AmlLength;
511 ObjDesc->Method.Node = Operand[0];
512
513 /*
514 * Disassemble the method flags. Split off the ArgCount, Serialized
515 * flag, and SyncLevel for efficiency.
516 */
517 MethodFlags = (UINT8) Operand[1]->Integer.Value;
518 ObjDesc->Method.ParamCount = (UINT8)
519 (MethodFlags & AML_METHOD_ARG_COUNT);
520
521 /*
522 * Get the SyncLevel. If method is serialized, a mutex will be
523 * created for this method when it is parsed.
524 */
525 if (MethodFlags & AML_METHOD_SERIALIZED)
526 {
528
529 /*
530 * ACPI 1.0: SyncLevel = 0
531 * ACPI 2.0: SyncLevel = SyncLevel in method declaration
532 */
533 ObjDesc->Method.SyncLevel = (UINT8)
534 ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
535 }
536
537 /* Attach the new object to the method Node */
538
540 ObjDesc, ACPI_TYPE_METHOD);
541
542 /* Remove local reference to the object */
543
544 AcpiUtRemoveReference (ObjDesc);
545
546Exit:
547 /* Remove a reference to the operand */
548
549 AcpiUtRemoveReference (Operand[1]);
551}
#define ACPI_METHOD_SERIALIZED
Definition: acobject.h:238
#define AML_METHOD_ARG_COUNT
Definition: amlcode.h:505
#define AML_METHOD_SERIALIZED
Definition: amlcode.h:506
#define AML_METHOD_SYNC_LEVEL
Definition: amlcode.h:507
static void Exit(void)
Definition: sock.c:1330
UINT8 * AmlStart
Definition: acobject.h:221
ACPI_OBJECT_COMMON_HEADER UINT8 InfoFlags
Definition: acobject.h:216
union acpi_operand_object * Node
Definition: acobject.h:220
ACPI_OBJECT_METHOD Method
Definition: acobject.h:525

Referenced by AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiExCreateMutex()

ACPI_STATUS AcpiExCreateMutex ( ACPI_WALK_STATE WalkState)

Definition at line 206 of file excreate.c.

208{
210 ACPI_OPERAND_OBJECT *ObjDesc;
211
212
214
215
216 /* Create the new mutex object */
217
219 if (!ObjDesc)
220 {
222 goto Cleanup;
223 }
224
225 /* Create the actual OS Mutex */
226
228 if (ACPI_FAILURE (Status))
229 {
230 goto Cleanup;
231 }
232
233 /* Init object and attach to NS node */
234
235 ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
236 ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
237
239 ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
240
241
242Cleanup:
243 /*
244 * Remove local reference to the object (on error, will cause deletion
245 * of both object and semaphore if present.)
246 */
247 AcpiUtRemoveReference (ObjDesc);
249}
#define ACPI_WALK_OPERANDS
Definition: acinterp.h:48
#define ACPI_TYPE_MUTEX
Definition: actypes.h:696
#define AcpiOsCreateMutex(OutHandle)
Definition: actypes.h:274

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreatePowerResource()

ACPI_STATUS AcpiExCreatePowerResource ( ACPI_WALK_STATE WalkState)

Definition at line 433 of file excreate.c.

435{
436 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
438 ACPI_OPERAND_OBJECT *ObjDesc;
439
440
441 ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
442
443
444 /* Create the power resource object */
445
447 if (!ObjDesc)
448 {
450 }
451
452 /* Initialize the power object from the operands */
453
454 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
455 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
456
457 /* Install the power resource object in the parent Node */
458
460 ObjDesc, ACPI_TYPE_POWER);
461
462 /* Remove local reference to the object */
463
464 AcpiUtRemoveReference (ObjDesc);
466}
#define ACPI_TYPE_POWER
Definition: actypes.h:698
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO UINT32 SystemLevel
Definition: acobject.h:280
ACPI_OBJECT_POWER_RESOURCE PowerResource
Definition: acobject.h:530

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateProcessor()

ACPI_STATUS AcpiExCreateProcessor ( ACPI_WALK_STATE WalkState)

Definition at line 381 of file excreate.c.

383{
384 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
385 ACPI_OPERAND_OBJECT *ObjDesc;
387
388
389 ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
390
391
392 /* Create the processor object */
393
395 if (!ObjDesc)
396 {
398 }
399
400 /* Initialize the processor object from the operands */
401
402 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
403 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
404 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
405
406 /* Install the processor object in the parent Node */
407
409 ObjDesc, ACPI_TYPE_PROCESSOR);
410
411 /* Remove local reference to the object */
412
413 AcpiUtRemoveReference (ObjDesc);
415}
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:699
ACPI_COMMON_NOTIFY_INFO ACPI_IO_ADDRESS Address
Definition: acobject.h:295
ACPI_OBJECT_COMMON_HEADER UINT8 ProcId
Definition: acobject.h:292
ACPI_OBJECT_PROCESSOR Processor
Definition: acobject.h:531

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateRegion()

ACPI_STATUS AcpiExCreateRegion ( UINT8 AmlStart,
UINT32  AmlLength,
UINT8  RegionSpace,
ACPI_WALK_STATE WalkState 
)

Definition at line 268 of file excreate.c.

273{
275 ACPI_OPERAND_OBJECT *ObjDesc;
277 ACPI_OPERAND_OBJECT *RegionObj2;
278
279
280 ACPI_FUNCTION_TRACE (ExCreateRegion);
281
282
283 /* Get the Namespace Node */
284
285 Node = WalkState->Op->Common.Node;
286
287 /*
288 * If the region object is already attached to this node,
289 * just return
290 */
292 {
294 }
295
296 /*
297 * Space ID must be one of the predefined IDs, or in the user-defined
298 * range
299 */
301 {
302 /*
303 * Print an error message, but continue. We don't want to abort
304 * a table load for this exception. Instead, if the region is
305 * actually used at runtime, abort the executing method.
306 */
308 "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
309 }
310
311 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
313
314 /* Create the region descriptor */
315
317 if (!ObjDesc)
318 {
320 goto Cleanup;
321 }
322
323 /*
324 * Remember location in AML stream of address & length
325 * operands since they need to be evaluated at run time.
326 */
327 RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
328 RegionObj2->Extra.AmlStart = AmlStart;
329 RegionObj2->Extra.AmlLength = AmlLength;
330 RegionObj2->Extra.Method_REG = NULL;
331 if (WalkState->ScopeInfo)
332 {
333 RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
334 }
335 else
336 {
337 RegionObj2->Extra.ScopeNode = Node;
338 }
339
340 /* Init the region from the operands */
341
342 ObjDesc->Region.SpaceId = SpaceId;
343 ObjDesc->Region.Address = 0;
344 ObjDesc->Region.Length = 0;
345 ObjDesc->Region.Pointer = NULL;
346 ObjDesc->Region.Node = Node;
347 ObjDesc->Region.Handler = NULL;
348 ObjDesc->Common.Flags &=
351
352 /* Install the new region object in the parent Node */
353
355
356
357Cleanup:
358
359 /* Remove local reference to the object */
360
361 AcpiUtRemoveReference (ObjDesc);
363}
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
#define AOPOBJ_REG_CONNECTED
Definition: acobject.h:98
#define AOPOBJ_OBJECT_INITIALIZED
Definition: acobject.h:97
#define AOPOBJ_SETUP_COMPLETE
Definition: acobject.h:99
#define ACPI_DB_LOAD
Definition: acoutput.h:164
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_TYPE_REGION
Definition: actypes.h:697
union node Node
Definition: types.h:1255
BOOLEAN AcpiIsValidSpaceId(UINT8 SpaceId)
Definition: exutils.c:494
ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE * Method_REG
Definition: acobject.h:481
UINT32 AmlLength
Definition: acobject.h:485
ACPI_NAMESPACE_NODE * ScopeNode
Definition: acobject.h:482
UINT8 * AmlStart
Definition: acobject.h:484
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:203
union acpi_operand_object * Handler
Definition: acobject.h:204
ACPI_STATE_COMMON ACPI_NAMESPACE_NODE * Node
Definition: aclocal.h:740
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
ACPI_GENERIC_STATE * ScopeInfo
Definition: acstruct.h:124
ACPI_SCOPE_STATE Scope
Definition: aclocal.h:825
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:541
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
Definition: dlist.c:348

Referenced by AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiExDataTableSpaceHandler()

ACPI_STATUS AcpiExDataTableSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 579 of file exregion.c.

586{
588 char *Pointer;
589
590
591 ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
592
593
594 Mapping = (ACPI_DATA_TABLE_MAPPING *) RegionContext;
595 Pointer = ACPI_CAST_PTR (char, Mapping->Pointer) +
596 (Address - ACPI_PTR_TO_PHYSADDR (Mapping->Pointer));
597
598 /*
599 * Perform the memory read or write. The BitWidth was already
600 * validated.
601 */
602 switch (Function)
603 {
604 case ACPI_READ:
605
606 memcpy (ACPI_CAST_PTR (char, Value), Pointer, ACPI_DIV_8 (BitWidth));
607 break;
608
609 case ACPI_WRITE:
610
611 memcpy (Pointer, ACPI_CAST_PTR (char, Value), ACPI_DIV_8 (BitWidth));
612 break;
613
614 default:
615
617 }
618
620}
#define ACPI_DIV_8(a)
Definition: acmacros.h:214
#define ACPI_WRITE
Definition: actypes.h:752
#define ACPI_PTR_TO_PHYSADDR(i)
Definition: actypes.h:559
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
static WCHAR Address[46]
Definition: ping.c:68

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExDoConcatenate()

ACPI_STATUS AcpiExDoConcatenate ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT ObjDesc2,
ACPI_OPERAND_OBJECT **  ActualReturnDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 85 of file exconcat.c.

90{
91 ACPI_OPERAND_OBJECT *LocalOperand0 = Operand0;
92 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
93 ACPI_OPERAND_OBJECT *TempOperand1 = NULL;
94 ACPI_OPERAND_OBJECT *ReturnDesc;
95 char *Buffer;
96 ACPI_OBJECT_TYPE Operand0Type;
97 ACPI_OBJECT_TYPE Operand1Type;
99
100
101 ACPI_FUNCTION_TRACE (ExDoConcatenate);
102
103
104 /* Operand 0 preprocessing */
105
106 switch (Operand0->Common.Type)
107 {
109 case ACPI_TYPE_STRING:
110 case ACPI_TYPE_BUFFER:
111
112 Operand0Type = Operand0->Common.Type;
113 break;
114
115 default:
116
117 /* For all other types, get the "object type" string */
118
120 Operand0, &LocalOperand0);
121 if (ACPI_FAILURE (Status))
122 {
123 goto Cleanup;
124 }
125
126 Operand0Type = ACPI_TYPE_STRING;
127 break;
128 }
129
130 /* Operand 1 preprocessing */
131
132 switch (Operand1->Common.Type)
133 {
135 case ACPI_TYPE_STRING:
136 case ACPI_TYPE_BUFFER:
137
138 Operand1Type = Operand1->Common.Type;
139 break;
140
141 default:
142
143 /* For all other types, get the "object type" string */
144
146 Operand1, &LocalOperand1);
147 if (ACPI_FAILURE (Status))
148 {
149 goto Cleanup;
150 }
151
152 Operand1Type = ACPI_TYPE_STRING;
153 break;
154 }
155
156 /*
157 * Convert the second operand if necessary. The first operand (0)
158 * determines the type of the second operand (1) (See the Data Types
159 * section of the ACPI specification). Both object types are
160 * guaranteed to be either Integer/String/Buffer by the operand
161 * resolution mechanism.
162 */
163 switch (Operand0Type)
164 {
166
167 Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1,
169 break;
170
171 case ACPI_TYPE_BUFFER:
172
173 Status = AcpiExConvertToBuffer (LocalOperand1, &TempOperand1);
174 break;
175
176 case ACPI_TYPE_STRING:
177
178 switch (Operand1Type)
179 {
181 case ACPI_TYPE_STRING:
182 case ACPI_TYPE_BUFFER:
183
184 /* Other types have already been converted to string */
185
187 LocalOperand1, &TempOperand1, ACPI_IMPLICIT_CONVERT_HEX);
188 break;
189
190 default:
191
192 Status = AE_OK;
193 break;
194 }
195 break;
196
197 default:
198
199 ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
200 Operand0->Common.Type));
202 }
203
204 if (ACPI_FAILURE (Status))
205 {
206 goto Cleanup;
207 }
208
209 /* Take care with any newly created operand objects */
210
211 if ((LocalOperand1 != Operand1) &&
212 (LocalOperand1 != TempOperand1))
213 {
214 AcpiUtRemoveReference (LocalOperand1);
215 }
216
217 LocalOperand1 = TempOperand1;
218
219 /*
220 * Both operands are now known to be the same object type
221 * (Both are Integer, String, or Buffer), and we can now perform
222 * the concatenation.
223 *
224 * There are three cases to handle, as per the ACPI spec:
225 *
226 * 1) Two Integers concatenated to produce a new Buffer
227 * 2) Two Strings concatenated to produce a new String
228 * 3) Two Buffers concatenated to produce a new Buffer
229 */
230 switch (Operand0Type)
231 {
233
234 /* Result of two Integers is a Buffer */
235 /* Need enough buffer space for two integers */
236
237 ReturnDesc = AcpiUtCreateBufferObject (
238 (ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth));
239 if (!ReturnDesc)
240 {
242 goto Cleanup;
243 }
244
245 Buffer = (char *) ReturnDesc->Buffer.Pointer;
246
247 /* Copy the first integer, LSB first */
248
249 memcpy (Buffer, &Operand0->Integer.Value,
250 AcpiGbl_IntegerByteWidth);
251
252 /* Copy the second integer (LSB first) after the first */
253
254 memcpy (Buffer + AcpiGbl_IntegerByteWidth,
255 &LocalOperand1->Integer.Value, AcpiGbl_IntegerByteWidth);
256 break;
257
258 case ACPI_TYPE_STRING:
259
260 /* Result of two Strings is a String */
261
262 ReturnDesc = AcpiUtCreateStringObject (
263 ((ACPI_SIZE) LocalOperand0->String.Length +
264 LocalOperand1->String.Length));
265 if (!ReturnDesc)
266 {
268 goto Cleanup;
269 }
270
271 Buffer = ReturnDesc->String.Pointer;
272
273 /* Concatenate the strings */
274
275 strcpy (Buffer, LocalOperand0->String.Pointer);
276 strcat (Buffer, LocalOperand1->String.Pointer);
277 break;
278
279 case ACPI_TYPE_BUFFER:
280
281 /* Result of two Buffers is a Buffer */
282
283 ReturnDesc = AcpiUtCreateBufferObject (
284 ((ACPI_SIZE) Operand0->Buffer.Length +
285 LocalOperand1->Buffer.Length));
286 if (!ReturnDesc)
287 {
289 goto Cleanup;
290 }
291
292 Buffer = (char *) ReturnDesc->Buffer.Pointer;
293
294 /* Concatenate the buffers */
295
296 memcpy (Buffer, Operand0->Buffer.Pointer,
297 Operand0->Buffer.Length);
298 memcpy (Buffer + Operand0->Buffer.Length,
299 LocalOperand1->Buffer.Pointer,
300 LocalOperand1->Buffer.Length);
301 break;
302
303 default:
304
305 /* Invalid object type, should not happen here */
306
307 ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
308 Operand0->Common.Type));
310 goto Cleanup;
311 }
312
313 *ActualReturnDesc = ReturnDesc;
314
315Cleanup:
316 if (LocalOperand0 != Operand0)
317 {
318 AcpiUtRemoveReference (LocalOperand0);
319 }
320
321 if (LocalOperand1 != Operand1)
322 {
323 AcpiUtRemoveReference (LocalOperand1);
324 }
325
327}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:685
Definition: bufpool.h:45
static ACPI_STATUS AcpiExConvertToObjectTypeString(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
Definition: exconcat.c:346

Referenced by AcpiExOpcode_2A_1T_1R().

◆ AcpiExDoDebugObject()

void AcpiExDoDebugObject ( ACPI_OPERAND_OBJECT SourceDesc,
UINT32  Level,
UINT32  Index 
)

Definition at line 77 of file exdebug.c.

81{
82 UINT32 i;
84 ACPI_OPERAND_OBJECT *ObjectDesc;
86
87
88 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
89
90
91 /* Output must be enabled via the DebugObject global or the DbgLevel */
92
93 if (!AcpiGbl_EnableAmlDebugObject &&
94 !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
95 {
97 }
98
99 /* Newline -- don't emit the line header */
100
101 if (SourceDesc &&
103 (SourceDesc->Common.Type == ACPI_TYPE_STRING))
104 {
105 if ((SourceDesc->String.Length == 1) &&
106 (*SourceDesc->String.Pointer == '\n'))
107 {
108 AcpiOsPrintf ("\n");
110 }
111 }
112
113 /*
114 * Print line header as long as we are not in the middle of an
115 * object display
116 */
117 if (!((Level > 0) && Index == 0))
118 {
119 if (AcpiGbl_DisplayDebugTimer)
120 {
121 /*
122 * We will emit the current timer value (in microseconds) with each
123 * debug output. Only need the lower 26 bits. This allows for 67
124 * million microseconds or 67 seconds before rollover.
125 *
126 * Convert 100 nanosecond units to microseconds
127 */
128 Timer = ((UINT32) AcpiOsGetTimer () / 10);
129 Timer &= 0x03FFFFFF;
130
131 AcpiOsPrintf ("ACPI Debug: T=0x%8.8X %*s", Timer, Level, " ");
132 }
133 else
134 {
135 AcpiOsPrintf ("ACPI Debug: %*s", Level, " ");
136 }
137 }
138
139 /* Display the index for package output only */
140
141 if (Index > 0)
142 {
143 AcpiOsPrintf ("(%.2u) ", Index - 1);
144 }
145
146 if (!SourceDesc)
147 {
148 AcpiOsPrintf ("[Null Object]\n");
150 }
151
153 {
154 /* No object type prefix needed for integers and strings */
155
156 if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
157 (SourceDesc->Common.Type != ACPI_TYPE_STRING))
158 {
159 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
160 }
161
162 if (!AcpiUtValidInternalObject (SourceDesc))
163 {
164 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
166 }
167 }
168 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
169 {
170 AcpiOsPrintf ("%s (Node %p)\n",
171 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
172 SourceDesc);
174 }
175 else
176 {
178 }
179
180 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
181
182 switch (SourceDesc->Common.Type)
183 {
185
186 /* Output correct integer width */
187
188 if (AcpiGbl_IntegerByteWidth == 4)
189 {
190 AcpiOsPrintf ("0x%8.8X\n",
191 (UINT32) SourceDesc->Integer.Value);
192 }
193 else
194 {
195 AcpiOsPrintf ("0x%8.8X%8.8X\n",
196 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
197 }
198 break;
199
200 case ACPI_TYPE_BUFFER:
201
202 AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
203 AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
204 (SourceDesc->Buffer.Length < 256) ?
205 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
206 break;
207
208 case ACPI_TYPE_STRING:
209
210 AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer);
211 break;
212
214
215 AcpiOsPrintf ("(Contains 0x%.2X Elements):\n",
216 SourceDesc->Package.Count);
217
218 /* Output the entire contents of the package */
219
220 for (i = 0; i < SourceDesc->Package.Count; i++)
221 {
223 Level + 4, i + 1);
224 }
225 break;
226
228
229 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
230
231 /* Decode the reference */
232
233 switch (SourceDesc->Reference.Class)
234 {
236
237 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
238 break;
239
241
242 /* Case for DdbHandle */
243
244 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
246
247 default:
248
249 break;
250 }
251
252 AcpiOsPrintf (" ");
253
254 /* Check for valid node first, then valid object */
255
256 if (SourceDesc->Reference.Node)
257 {
258 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
260 {
261 AcpiOsPrintf (" %p - Not a valid namespace node\n",
262 SourceDesc->Reference.Node);
263 }
264 else
265 {
266 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
267 (SourceDesc->Reference.Node)->Name.Ascii);
268
269 switch ((SourceDesc->Reference.Node)->Type)
270 {
271 /* These types have no attached object */
272
273 case ACPI_TYPE_DEVICE:
274 AcpiOsPrintf ("Device\n");
275 break;
276
278 AcpiOsPrintf ("Thermal Zone\n");
279 break;
280
281 default:
282
283 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
284 Level + 4, 0);
285 break;
286 }
287 }
288 }
289 else if (SourceDesc->Reference.Object)
290 {
291 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
293 {
294 /* Reference object is a namespace node */
295
297 SourceDesc->Reference.Object),
298 Level + 4, 0);
299 }
300 else
301 {
302 ObjectDesc = SourceDesc->Reference.Object;
303 Value = SourceDesc->Reference.Value;
304
305 switch (ObjectDesc->Common.Type)
306 {
307 case ACPI_TYPE_BUFFER:
308
309 AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
310 Value, *SourceDesc->Reference.IndexPointer);
311 break;
312
313 case ACPI_TYPE_STRING:
314
315 AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
316 Value, *SourceDesc->Reference.IndexPointer,
317 *SourceDesc->Reference.IndexPointer);
318 break;
319
321
322 AcpiOsPrintf ("Package[%u] = ", Value);
323 if (!(*SourceDesc->Reference.Where))
324 {
325 AcpiOsPrintf ("[Uninitialized Package Element]\n");
326 }
327 else
328 {
329 AcpiExDoDebugObject (*SourceDesc->Reference.Where,
330 Level+4, 0);
331 }
332 break;
333
334 default:
335
336 AcpiOsPrintf ("Unknown Reference object type %X\n",
337 ObjectDesc->Common.Type);
338 break;
339 }
340 }
341 }
342 break;
343
344 default:
345
346 AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc);
347 break;
348 }
349
352}
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
#define ACPI_DESC_TYPE_OPERAND
Definition: acobject.h:576
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:577
@ ACPI_REFCLASS_TABLE
Definition: acobject.h:463
@ ACPI_REFCLASS_INDEX
Definition: acobject.h:462
#define ACPI_LV_DEBUG_OBJECT
Definition: acoutput.h:89
UINT64 AcpiOsGetTimer(void)
Definition: osl.c:884
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_TYPE_DEVICE
Definition: actypes.h:693
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
#define ACPI_TYPE_THERMAL
Definition: actypes.h:700
const char * AcpiUtGetReferenceName(ACPI_OPERAND_OBJECT *Object)
Definition: utdecode.c:426
BOOLEAN AcpiUtValidInternalObject(void *Object)
Definition: utobject.c:376
void AcpiUtDumpBuffer(UINT8 *Buffer, UINT32 Count, UINT32 Display, UINT32 Offset)
Definition: utbuffer.c:71
#define DB_BYTE_DISPLAY
Definition: acutils.h:186
void AcpiExDoDebugObject(ACPI_OPERAND_OBJECT *SourceDesc, UINT32 Level, UINT32 Index)
Definition: exdebug.c:77
ACPI_NAME_UNION Name
Definition: aclocal.h:191
union acpi_operand_object ** Elements
Definition: acobject.h:161
union acpi_operand_object ** Where
Definition: acobject.h:448
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:447
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
char Ascii[4]
Definition: actbl.h:394
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
_In_ WDFCOLLECTION _In_ ULONG Index
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

Referenced by AcpiExDoDebugObject().

◆ AcpiExDoLogicalNumericOp()

ACPI_STATUS AcpiExDoLogicalNumericOp ( UINT16  Opcode,
UINT64  Integer0,
UINT64  Integer1,
BOOLEAN LogicalResult 
)

Definition at line 262 of file exmisc.c.

267{
269 BOOLEAN LocalResult = FALSE;
270
271
272 ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
273
274
275 switch (Opcode)
276 {
277 case AML_LOGICAL_AND_OP: /* LAnd (Integer0, Integer1) */
278
279 if (Integer0 && Integer1)
280 {
281 LocalResult = TRUE;
282 }
283 break;
284
285 case AML_LOGICAL_OR_OP: /* LOr (Integer0, Integer1) */
286
287 if (Integer0 || Integer1)
288 {
289 LocalResult = TRUE;
290 }
291 break;
292
293 default:
294
296 "Invalid numeric logical opcode: %X", Opcode));
298 break;
299 }
300
301 /* Return the logical result and status */
302
303 *LogicalResult = LocalResult;
305}
unsigned char BOOLEAN
#define AML_LOGICAL_OR_OP
Definition: amlcode.h:121
#define AML_LOGICAL_AND_OP
Definition: amlcode.h:120
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:331

Referenced by AcpiExOpcode_2A_0T_1R().

◆ AcpiExDoLogicalOp()

ACPI_STATUS AcpiExDoLogicalOp ( UINT16  Opcode,
ACPI_OPERAND_OBJECT Operand0,
ACPI_OPERAND_OBJECT Operand1,
BOOLEAN LogicalResult 
)

Definition at line 335 of file exmisc.c.

340{
341 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
342 UINT64 Integer0;
343 UINT64 Integer1;
344 UINT32 Length0;
347 BOOLEAN LocalResult = FALSE;
348 int Compare;
349
350
351 ACPI_FUNCTION_TRACE (ExDoLogicalOp);
352
353
354 /*
355 * Convert the second operand if necessary. The first operand
356 * determines the type of the second operand, (See the Data Types
357 * section of the ACPI 3.0+ specification.) Both object types are
358 * guaranteed to be either Integer/String/Buffer by the operand
359 * resolution mechanism.
360 */
361 switch (Operand0->Common.Type)
362 {
364
365 Status = AcpiExConvertToInteger (Operand1, &LocalOperand1,
367 break;
368
369 case ACPI_TYPE_STRING:
370
372 Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
373 break;
374
375 case ACPI_TYPE_BUFFER:
376
377 Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
378 break;
379
380 default:
381
383 "Invalid object type for logical operator: %X",
384 Operand0->Common.Type));
386 break;
387 }
388
389 if (ACPI_FAILURE (Status))
390 {
391 goto Cleanup;
392 }
393
394 /*
395 * Two cases: 1) Both Integers, 2) Both Strings or Buffers
396 */
397 if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
398 {
399 /*
400 * 1) Both operands are of type integer
401 * Note: LocalOperand1 may have changed above
402 */
403 Integer0 = Operand0->Integer.Value;
404 Integer1 = LocalOperand1->Integer.Value;
405
406 switch (Opcode)
407 {
408 case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */
409
410 if (Integer0 == Integer1)
411 {
412 LocalResult = TRUE;
413 }
414 break;
415
416 case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */
417
418 if (Integer0 > Integer1)
419 {
420 LocalResult = TRUE;
421 }
422 break;
423
424 case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */
425
426 if (Integer0 < Integer1)
427 {
428 LocalResult = TRUE;
429 }
430 break;
431
432 default:
433
435 "Invalid comparison opcode: %X", Opcode));
437 break;
438 }
439 }
440 else
441 {
442 /*
443 * 2) Both operands are Strings or both are Buffers
444 * Note: Code below takes advantage of common Buffer/String
445 * object fields. LocalOperand1 may have changed above. Use
446 * memcmp to handle nulls in buffers.
447 */
448 Length0 = Operand0->Buffer.Length;
449 Length1 = LocalOperand1->Buffer.Length;
450
451 /* Lexicographic compare: compare the data bytes */
452
453 Compare = memcmp (Operand0->Buffer.Pointer,
454 LocalOperand1->Buffer.Pointer,
455 (Length0 > Length1) ? Length1 : Length0);
456
457 switch (Opcode)
458 {
459 case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */
460
461 /* Length and all bytes must be equal */
462
463 if ((Length0 == Length1) &&
464 (Compare == 0))
465 {
466 /* Length and all bytes match ==> TRUE */
467
468 LocalResult = TRUE;
469 }
470 break;
471
472 case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */
473
474 if (Compare > 0)
475 {
476 LocalResult = TRUE;
477 goto Cleanup; /* TRUE */
478 }
479 if (Compare < 0)
480 {
481 goto Cleanup; /* FALSE */
482 }
483
484 /* Bytes match (to shortest length), compare lengths */
485
486 if (Length0 > Length1)
487 {
488 LocalResult = TRUE;
489 }
490 break;
491
492 case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */
493
494 if (Compare > 0)
495 {
496 goto Cleanup; /* FALSE */
497 }
498 if (Compare < 0)
499 {
500 LocalResult = TRUE;
501 goto Cleanup; /* TRUE */
502 }
503
504 /* Bytes match (to shortest length), compare lengths */
505
506 if (Length0 < Length1)
507 {
508 LocalResult = TRUE;
509 }
510 break;
511
512 default:
513
515 "Invalid comparison opcode: %X", Opcode));
517 break;
518 }
519 }
520
521Cleanup:
522
523 /* New object was created if implicit conversion performed - delete */
524
525 if (LocalOperand1 != Operand1)
526 {
527 AcpiUtRemoveReference (LocalOperand1);
528 }
529
530 /* Return the logical result and status */
531
532 *LogicalResult = LocalResult;
534}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define AML_LOGICAL_GREATER_OP
Definition: amlcode.h:124
#define AML_LOGICAL_LESS_OP
Definition: amlcode.h:125
#define AML_LOGICAL_EQUAL_OP
Definition: amlcode.h:123

Referenced by AcpiExDoMatch(), and AcpiExOpcode_2A_0T_1R().

◆ AcpiExDoMathOp()

UINT64 AcpiExDoMathOp ( UINT16  Opcode,
UINT64  Operand0,
UINT64  Operand1 
)

Definition at line 167 of file exmisc.c.

171{
172
174
175
176 switch (Opcode)
177 {
178 case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
179
180 return (Integer0 + Integer1);
181
182 case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
183
184 return (Integer0 & Integer1);
185
186 case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
187
188 return (~(Integer0 & Integer1));
189
190 case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
191
192 return (Integer0 | Integer1);
193
194 case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
195
196 return (~(Integer0 | Integer1));
197
198 case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
199
200 return (Integer0 ^ Integer1);
201
202 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
203
204 return (Integer0 * Integer1);
205
206 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
207
208 /*
209 * We need to check if the shiftcount is larger than the integer bit
210 * width since the behavior of this is not well-defined in the C language.
211 */
212 if (Integer1 >= AcpiGbl_IntegerBitWidth)
213 {
214 return (0);
215 }
216 return (Integer0 << Integer1);
217
218 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
219
220 /*
221 * We need to check if the shiftcount is larger than the integer bit
222 * width since the behavior of this is not well-defined in the C language.
223 */
224 if (Integer1 >= AcpiGbl_IntegerBitWidth)
225 {
226 return (0);
227 }
228 return (Integer0 >> Integer1);
229
230 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
231
232 return (Integer0 - Integer1);
233
234 default:
235
236 return (0);
237 }
238}
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define AML_SHIFT_RIGHT_OP
Definition: amlcode.h:98
#define AML_BIT_XOR_OP
Definition: amlcode.h:103
#define AML_BIT_NOR_OP
Definition: amlcode.h:102
#define AML_SHIFT_LEFT_OP
Definition: amlcode.h:97
#define AML_SUBTRACT_OP
Definition: amlcode.h:92
#define AML_BIT_AND_OP
Definition: amlcode.h:99
#define AML_BIT_NAND_OP
Definition: amlcode.h:100
#define AML_BIT_OR_OP
Definition: amlcode.h:101
#define AML_ADD_OP
Definition: amlcode.h:90
#define AML_MULTIPLY_OP
Definition: amlcode.h:95

Referenced by AcpiExOpcode_2A_1T_1R().

◆ AcpiExDumpNamespaceNode()

void AcpiExDumpNamespaceNode ( ACPI_NAMESPACE_NODE Node,
UINT32  Flags 
)

◆ AcpiExDumpObjectDescriptor()

void AcpiExDumpObjectDescriptor ( ACPI_OPERAND_OBJECT Object,
UINT32  Flags 
)

◆ AcpiExDumpOperand()

void AcpiExDumpOperand ( ACPI_OPERAND_OBJECT ObjDesc,
UINT32  Depth 
)

◆ AcpiExDumpOperands()

void AcpiExDumpOperands ( ACPI_OPERAND_OBJECT **  Operands,
const char OpcodeName,
UINT32  NumOpcodes 
)

◆ AcpiExEisaIdToString()

void AcpiExEisaIdToString ( char Dest,
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_WARNING(plist)
Definition: acoutput.h:238
#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().

◆ AcpiExEmbeddedControllerSpaceHandler()

ACPI_STATUS AcpiExEmbeddedControllerSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

◆ 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
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  )

◆ AcpiExExtractFromField()

ACPI_STATUS AcpiExExtractFromField ( ACPI_OPERAND_OBJECT ObjDesc,
void Buffer,
UINT32  BufferLength 
)

Definition at line 723 of file exfldio.c.

727{
729 UINT64 RawDatum;
730 UINT64 MergedDatum;
731 UINT32 FieldOffset = 0;
732 UINT32 BufferOffset = 0;
733 UINT32 BufferTailBits;
734 UINT32 DatumCount;
735 UINT32 FieldDatumCount;
736 UINT32 AccessBitWidth;
737 UINT32 i;
738
739
740 ACPI_FUNCTION_TRACE (ExExtractFromField);
741
742
743 /* Validate target buffer and clear it */
744
745 if (BufferLength <
746 ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength))
747 {
749 "Field size %u (bits) is too large for buffer (%u)",
750 ObjDesc->CommonField.BitLength, BufferLength));
751
753 }
754
756 AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
757
758 /* Handle the simple case here */
759
760 if ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
761 (ObjDesc->CommonField.BitLength == AccessBitWidth))
762 {
763 if (BufferLength >= sizeof (UINT64))
764 {
765 Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ);
766 }
767 else
768 {
769 /* Use RawDatum (UINT64) to handle buffers < 64 bits */
770
771 Status = AcpiExFieldDatumIo (ObjDesc, 0, &RawDatum, ACPI_READ);
772 memcpy (Buffer, &RawDatum, BufferLength);
773 }
774
776 }
777
778/* TBD: Move to common setup code */
779
780 /* Field algorithm is limited to sizeof(UINT64), truncate if needed */
781
782 if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
783 {
784 ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
785 AccessBitWidth = sizeof (UINT64) * 8;
786 }
787
788 /* Compute the number of datums (access width data items) */
789
790 DatumCount = ACPI_ROUND_UP_TO (
791 ObjDesc->CommonField.BitLength, AccessBitWidth);
792
793 FieldDatumCount = ACPI_ROUND_UP_TO (
794 ObjDesc->CommonField.BitLength +
795 ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth);
796
797 /* Priming read from the field */
798
799 Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
800 if (ACPI_FAILURE (Status))
801 {
803 }
804 MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
805
806 /* Read the rest of the field */
807
808 for (i = 1; i < FieldDatumCount; i++)
809 {
810 /* Get next input datum from the field */
811
812 FieldOffset += ObjDesc->CommonField.AccessByteWidth;
814 ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
815 if (ACPI_FAILURE (Status))
816 {
818 }
819
820 /*
821 * Merge with previous datum if necessary.
822 *
823 * Note: Before the shift, check if the shift value will be larger than
824 * the integer size. If so, there is no need to perform the operation.
825 * This avoids the differences in behavior between different compilers
826 * concerning shift values larger than the target data width.
827 */
828 if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset <
830 {
831 MergedDatum |= RawDatum <<
832 (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
833 }
834
835 if (i == DatumCount)
836 {
837 break;
838 }
839
840 /* Write merged datum to target buffer */
841
842 memcpy (((char *) Buffer) + BufferOffset, &MergedDatum,
843 ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
844 BufferLength - BufferOffset));
845
846 BufferOffset += ObjDesc->CommonField.AccessByteWidth;
847 MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
848 }
849
850 /* Mask off any extra bits in the last datum */
851
852 BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth;
853 if (BufferTailBits)
854 {
855 MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
856 }
857
858 /* Write the last datum to the buffer */
859
860 memcpy (((char *) Buffer) + BufferOffset, &MergedDatum,
861 ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
862 BufferLength - BufferOffset));
863
865}
#define AE_BUFFER_OVERFLOW
Definition: acexcep.h:119
#define ACPI_MASK_BITS_ABOVE(position)
Definition: acmacros.h:344
#define ACPI_ROUND_UP_TO(value, boundary)
Definition: acmacros.h:263
#define ACPI_ROUND_BITS_UP_TO_BYTES(a)
Definition: acmacros.h:256
#define ACPI_MIN(a, b)
Definition: actypes.h:535
#define ACPI_INTEGER_BIT_SIZE
Definition: actypes.h:490
static ACPI_STATUS AcpiExFieldDatumIo(ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, UINT64 *Value, UINT32 ReadWrite)
Definition: exfldio.c:402
#define memset(x, y, z)
Definition: compat.h:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by AcpiExFieldDatumIo(), and AcpiExReadDataFromField().

◆ AcpiExGetBufferDatum()

void AcpiExGetBufferDatum ( UINT64 Datum,
void Buffer,
UINT32  BufferLength,
UINT32  ByteGranularity,
UINT32  BufferOffset 
)

◆ AcpiExGetNameString()

ACPI_STATUS AcpiExGetNameString ( ACPI_OBJECT_TYPE  DataType,
UINT8 InAmlAddress,
char **  OutNameString,
UINT32 OutNameLength 
)

Definition at line 278 of file exnames.c.

283{
285 UINT8 *AmlAddress = InAmlAddress;
286 char *NameString = NULL;
287 UINT32 NumSegments;
288 UINT32 PrefixCount = 0;
290
291
292 ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress);
293
294
298 {
299 /* Disallow prefixes for types associated with FieldUnit names */
300
301 NameString = AcpiExAllocateNameString (0, 1);
302 if (!NameString)
303 {
305 }
306 else
307 {
308 Status = AcpiExNameSegment (&AmlAddress, NameString);
309 }
310 }
311 else
312 {
313 /*
314 * DataType is not a field name.
315 * Examine first character of name for root or parent prefix operators
316 */
317 switch (*AmlAddress)
318 {
319 case AML_ROOT_PREFIX:
320
321 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
322 AmlAddress));
323
324 /*
325 * Remember that we have a RootPrefix --
326 * see comment in AcpiExAllocateNameString()
327 */
328 AmlAddress++;
329 PrefixCount = ACPI_UINT32_MAX;
330 HasPrefix = TRUE;
331 break;
332
334
335 /* Increment past possibly multiple parent prefixes */
336
337 do
338 {
339 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
340 AmlAddress));
341
342 AmlAddress++;
343 PrefixCount++;
344
345 } while (*AmlAddress == AML_PARENT_PREFIX);
346
347 HasPrefix = TRUE;
348 break;
349
350 default:
351
352 /* Not a prefix character */
353
354 break;
355 }
356
357 /* Examine first character of name for name segment prefix operator */
358
359 switch (*AmlAddress)
360 {
362
363 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
364 AmlAddress));
365
366 AmlAddress++;
367 NameString = AcpiExAllocateNameString (PrefixCount, 2);
368 if (!NameString)
369 {
371 break;
372 }
373
374 /* Indicate that we processed a prefix */
375
376 HasPrefix = TRUE;
377
378 Status = AcpiExNameSegment (&AmlAddress, NameString);
379 if (ACPI_SUCCESS (Status))
380 {
381 Status = AcpiExNameSegment (&AmlAddress, NameString);
382 }
383 break;
384
386
387 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
388 AmlAddress));
389
390 /* Fetch count of segments remaining in name path */
391
392 AmlAddress++;
393 NumSegments = *AmlAddress;
394
395 NameString = AcpiExAllocateNameString (
396 PrefixCount, NumSegments);
397 if (!NameString)
398 {
400 break;
401 }
402
403 /* Indicate that we processed a prefix */
404
405 AmlAddress++;
406 HasPrefix = TRUE;
407
408 while (NumSegments &&
409 (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
410 AE_OK)
411 {
412 NumSegments--;
413 }
414
415 break;
416
417 case 0:
418
419 /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
420
421 if (PrefixCount == ACPI_UINT32_MAX)
422 {
424 "NameSeg is \"\\\" followed by NULL\n"));
425 }
426
427 /* Consume the NULL byte */
428
429 AmlAddress++;
430 NameString = AcpiExAllocateNameString (PrefixCount, 0);
431 if (!NameString)
432 {
434 break;
435 }
436
437 break;
438
439 default:
440
441 /* Name segment string */
442
443 NameString = AcpiExAllocateNameString (PrefixCount, 1);
444 if (!NameString)
445 {
447 break;
448 }
449
450 Status = AcpiExNameSegment (&AmlAddress, NameString);
451 break;
452 }
453 }
454
456 {
457 /* Ran out of segments after processing a prefix */
458
460 "Malformed Name at %p", NameString));
462 }
463
464 if (ACPI_FAILURE (Status))
465 {
466 if (NameString)
467 {
468 ACPI_FREE (NameString);
469 }
471 }
472
473 *OutNameString = NameString;
474 *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
475
477}
#define AE_AML_BAD_NAME
Definition: acexcep.h:192
#define AE_CTRL_PENDING
Definition: acexcep.h:225
#define ACPI_FREE(a)
Definition: actypes.h:386
#define AML_PARENT_PREFIX
Definition: amlcode.h:70
#define AML_DUAL_NAME_PREFIX
Definition: amlcode.h:66
#define AML_MULTI_NAME_PREFIX
Definition: amlcode.h:67
#define AML_ROOT_PREFIX
Definition: amlcode.h:69
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
static ACPI_STATUS AcpiExNameSegment(UINT8 **InAmlAddress, char *NameString)
Definition: exnames.c:179
static char * AcpiExAllocateNameString(UINT32 PrefixCount, UINT32 NumNameSegs)
Definition: exnames.c:82
DataType
Definition: simd.h:252

Referenced by AcpiDsCreateOperand().

◆ AcpiExGetObjectReference()

ACPI_STATUS AcpiExGetObjectReference ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ReturnDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 70 of file exmisc.c.

74{
75 ACPI_OPERAND_OBJECT *ReferenceObj;
76 ACPI_OPERAND_OBJECT *ReferencedObj;
77
78
79 ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
80
81
82 *ReturnDesc = NULL;
83
84 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
85 {
87
88 if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
89 {
91 }
92
93 /*
94 * Must be a reference to a Local or Arg
95 */
96 switch (ObjDesc->Reference.Class)
97 {
101
102 /* The referenced object is the pseudo-node for the local/arg */
103
104 ReferencedObj = ObjDesc->Reference.Object;
105 break;
106
107 default:
108
109 ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X",
110 ObjDesc->Reference.Class));
112 }
113 break;
114
116 /*
117 * A named reference that has already been resolved to a Node
118 */
119 ReferencedObj = ObjDesc;
120 break;
121
122 default:
123
124 ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
125 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
127 }
128
129
130 /* Create a new reference object */
131
133 if (!ReferenceObj)
134 {
136 }
137
138 ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
139 ReferenceObj->Reference.Object = ReferencedObj;
140 *ReturnDesc = ReferenceObj;
141
143 "Object %p Type [%s], returning Reference %p\n",
144 ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
145
147}
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
@ ACPI_REFCLASS_ARG
Definition: acobject.h:460
@ ACPI_REFCLASS_LOCAL
Definition: acobject.h:459
@ ACPI_REFCLASS_REFOF
Definition: acobject.h:461
@ ACPI_REFCLASS_DEBUG
Definition: acobject.h:465

Referenced by AcpiExOpcode_1A_0T_1R(), and AcpiExOpcode_1A_1T_1R().

◆ AcpiExGetProtocolBufferLength()

ACPI_STATUS AcpiExGetProtocolBufferLength ( UINT32  ProtocolId,
UINT32 ReturnLength 
)

Definition at line 111 of file exfield.c.

114{
115
118 {
120 "Invalid Field/AccessAs protocol ID: 0x%4.4X", ProtocolId));
121
122 return (AE_AML_PROTOCOL);
123 }
124
126 return (AE_OK);
127}
#define AE_AML_PROTOCOL
Definition: acexcep.h:215
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
#define ACPI_INVALID_PROTOCOL_ID
Definition: exfield.c:59
static const UINT8 AcpiProtocolLengths[]
Definition: exfield.c:62
#define ACPI_MAX_PROTOCOL_ID
Definition: exfield.c:60
_In_ UINT ProtocolId
Definition: ndis.h:2924

Referenced by AcpiExReadSerialBus(), and AcpiExWriteSerialBus().

◆ AcpiExInsertIntoField()

ACPI_STATUS AcpiExInsertIntoField ( ACPI_OPERAND_OBJECT ObjDesc,
void Buffer,
UINT32  BufferLength 
)

Definition at line 883 of file exfldio.c.

887{
888 void *NewBuffer;
890 UINT64 Mask;
891 UINT64 WidthMask;
892 UINT64 MergedDatum;
893 UINT64 RawDatum = 0;
894 UINT32 FieldOffset = 0;
895 UINT32 BufferOffset = 0;
896 UINT32 BufferTailBits;
897 UINT32 DatumCount;
898 UINT32 FieldDatumCount;
899 UINT32 AccessBitWidth;
901 UINT32 i;
902
903
904 ACPI_FUNCTION_TRACE (ExInsertIntoField);
905
906
907 /* Validate input buffer */
908
909 NewBuffer = NULL;
911 ObjDesc->CommonField.BitLength);
912
913 /*
914 * We must have a buffer that is at least as long as the field
915 * we are writing to. This is because individual fields are
916 * indivisible and partial writes are not supported -- as per
917 * the ACPI specification.
918 */
920 {
921 /* We need to create a new buffer */
922
924 if (!NewBuffer)
925 {
927 }
928
929 /*
930 * Copy the original data to the new buffer, starting
931 * at Byte zero. All unused (upper) bytes of the
932 * buffer will be 0.
933 */
934 memcpy ((char *) NewBuffer, (char *) Buffer, BufferLength);
935 Buffer = NewBuffer;
937 }
938
939/* TBD: Move to common setup code */
940
941 /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */
942 if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
943 {
944 ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
945 }
946
947 AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
948
949 /* Create the bitmasks used for bit insertion */
950
951 WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth);
952 Mask = WidthMask &
953 ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
954
955 /* Compute the number of datums (access width data items) */
956
957 DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
958 AccessBitWidth);
959
960 FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
961 ObjDesc->CommonField.StartFieldBitOffset,
962 AccessBitWidth);
963
964 /* Get initial Datum from the input buffer */
965
966 memcpy (&RawDatum, Buffer,
967 ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
968 BufferLength - BufferOffset));
969
970 MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
971
972 /* Write the entire field */
973
974 for (i = 1; i < FieldDatumCount; i++)
975 {
976 /* Write merged datum to the target field */
977
978 MergedDatum &= Mask;
980 ObjDesc, Mask, MergedDatum, FieldOffset);
981 if (ACPI_FAILURE (Status))
982 {
983 goto Exit;
984 }
985
986 FieldOffset += ObjDesc->CommonField.AccessByteWidth;
987
988 /*
989 * Start new output datum by merging with previous input datum
990 * if necessary.
991 *
992 * Note: Before the shift, check if the shift value will be larger than
993 * the integer size. If so, there is no need to perform the operation.
994 * This avoids the differences in behavior between different compilers
995 * concerning shift values larger than the target data width.
996 */
997 if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) <
999 {
1000 MergedDatum = RawDatum >>
1001 (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
1002 }
1003 else
1004 {
1005 MergedDatum = 0;
1006 }
1007
1008 Mask = WidthMask;
1009
1010 if (i == DatumCount)
1011 {
1012 break;
1013 }
1014
1015 /* Get the next input datum from the buffer */
1016
1017 BufferOffset += ObjDesc->CommonField.AccessByteWidth;
1018 memcpy (&RawDatum, ((char *) Buffer) + BufferOffset,
1019 ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
1020 BufferLength - BufferOffset));
1021
1022 MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
1023 }
1024
1025 /* Mask off any extra bits in the last datum */
1026
1027 BufferTailBits = (ObjDesc->CommonField.BitLength +
1028 ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth;
1029 if (BufferTailBits)
1030 {
1031 Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
1032 }
1033
1034 /* Write the last datum to the field */
1035
1036 MergedDatum &= Mask;
1038 ObjDesc, Mask, MergedDatum, FieldOffset);
1039
1040Exit:
1041 /* Free temporary buffer if we used one */
1042
1043 if (NewBuffer)
1044 {
1045 ACPI_FREE (NewBuffer);
1046 }
1048}
#define ACPI_MASK_BITS_ABOVE_64(width)
Definition: acmacros.h:348
#define ACPI_MASK_BITS_BELOW(position)
Definition: acmacros.h:345
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
ACPI_STATUS AcpiExWriteWithUpdateRule(ACPI_OPERAND_OBJECT *ObjDesc, UINT64 Mask, UINT64 FieldValue, UINT32 FieldDatumByteOffset)
Definition: exfldio.c:617
unsigned int Mask
Definition: fpcontrol.c:82
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30

Referenced by AcpiExFieldDatumIo(), and AcpiExWriteDataToField().

◆ AcpiExIntegerToString()

void AcpiExIntegerToString ( char Dest,
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}
ACPI_STATUS AcpiUtShortDivide(UINT64 InDividend, UINT32 Divisor, UINT64 *OutQuotient, UINT32 *OutRemainder)
Definition: utmath.c:337
static UINT32 AcpiExDigitsNeeded(UINT64 Value, UINT32 Base)
Definition: exutils.c:316
_In_ LARGE_INTEGER _Out_opt_ PLARGE_INTEGER Remainder
Definition: rtlfuncs.h:3045

Referenced by AcpiUtExecute_UID().

◆ AcpiExLoadOp()

ACPI_STATUS AcpiExLoadOp ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT Target,
ACPI_WALK_STATE WalkState 
)

Definition at line 343 of file exconfig.c.

347{
348 ACPI_OPERAND_OBJECT *DdbHandle;
349 ACPI_TABLE_HEADER *TableHeader;
351 UINT32 TableIndex;
354
355
356 ACPI_FUNCTION_TRACE (ExLoadOp);
357
358
359 if (Target->Common.DescriptorType == ACPI_DESC_TYPE_NAMED)
360 {
362 }
363 if (Target->Common.Type != ACPI_TYPE_INTEGER)
364 {
365 ACPI_ERROR ((AE_INFO, "Type not integer: %X", Target->Common.Type));
367 }
368
369 Target->Integer.Value = 0;
370
371 /* Source Object can be either an OpRegion or a Buffer/Field */
372
373 switch (ObjDesc->Common.Type)
374 {
375 case ACPI_TYPE_REGION:
376
378 "Load table from Region %p\n", ObjDesc));
379
380 /* Region must be SystemMemory (from ACPI spec) */
381
383 {
385 }
386
387 /*
388 * If the Region Address and Length have not been previously
389 * evaluated, evaluate them now and save the results.
390 */
391 if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
392 {
394 if (ACPI_FAILURE (Status))
395 {
397 }
398 }
399
400 /* Get the table header first so we can get the table length */
401
402 TableHeader = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
403 if (!TableHeader)
404 {
406 }
407
408 Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER),
409 ACPI_CAST_PTR (UINT8, TableHeader));
410 Length = TableHeader->Length;
411 ACPI_FREE (TableHeader);
412
413 if (ACPI_FAILURE (Status))
414 {
416 }
417
418 /* Must have at least an ACPI table header */
419
420 if (Length < sizeof (ACPI_TABLE_HEADER))
421 {
423 }
424
425 /*
426 * The original implementation simply mapped the table, with no copy.
427 * However, the memory region is not guaranteed to remain stable and
428 * we must copy the table to a local buffer. For example, the memory
429 * region is corrupted after suspend on some machines. Dynamically
430 * loaded tables are usually small, so this overhead is minimal.
431 *
432 * The latest implementation (5/2009) does not use a mapping at all.
433 * We use the low-level operation region interface to read the table
434 * instead of the obvious optimization of using a direct mapping.
435 * This maintains a consistent use of operation regions across the
436 * entire subsystem. This is important if additional processing must
437 * be performed in the (possibly user-installed) operation region
438 * handler. For example, AcpiExec and ASLTS depend on this.
439 */
440
441 /* Allocate a buffer for the table */
442
444 if (!Table)
445 {
447 }
448
449 /* Read the entire table */
450
451 Status = AcpiExRegionRead (ObjDesc, Length,
453 if (ACPI_FAILURE (Status))
454 {
457 }
458 break;
459
460 case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */
461
463 "Load table from Buffer or Field %p\n", ObjDesc));
464
465 /* Must have at least an ACPI table header */
466
467 if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER))
468 {
470 }
471
472 /* Get the actual table length from the table header */
473
474 TableHeader = ACPI_CAST_PTR (
475 ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer);
476 Length = TableHeader->Length;
477
478 /* Table cannot extend beyond the buffer */
479
480 if (Length > ObjDesc->Buffer.Length)
481 {
483 }
484 if (Length < sizeof (ACPI_TABLE_HEADER))
485 {
487 }
488
489 /*
490 * Copy the table from the buffer because the buffer could be
491 * modified or even deleted in the future
492 */
494 if (!Table)
495 {
497 }
498
499 memcpy (Table, TableHeader, Length);
500 break;
501
502 default:
503
505 }
506
507 /* Install the new table into the local data structures */
508
509 ACPI_INFO (("Dynamic OEM Table Load:"));
514 if (ACPI_FAILURE (Status))
515 {
516 /* Delete allocated table buffer */
517
520 }
521
522 /*
523 * Add the table to the namespace.
524 *
525 * Note: Load the table objects relative to the root of the namespace.
526 * This appears to go against the ACPI specification, but we do it for
527 * compatibility with other ACPI implementations.
528 */
529 Status = AcpiExAddTable (TableIndex, &DdbHandle);
530 if (ACPI_FAILURE (Status))
531 {
533 }
534
535 /* Complete the initialization/resolution of new objects */
536
540
541 /* Remove the reference to DdbHandle created by AcpiExAddTable above */
542
543 AcpiUtRemoveReference (DdbHandle);
544
545 /* Return -1 (non-zero) indicates success */
546
547 Target->Integer.Value = 0xFFFFFFFFFFFFFFFF;
549}
#define AE_INVALID_TABLE_LENGTH
Definition: acexcep.h:171
ACPI_STATUS AcpiNsInitializeObjects(void)
Definition: nsinit.c:92
#define ACPI_INFO(plist)
Definition: acoutput.h:237
ACPI_STATUS AcpiTbInstallAndLoadTable(ACPI_PHYSICAL_ADDRESS Address, UINT8 Flags, ACPI_TABLE_HEADER *Table, BOOLEAN Override, UINT32 *TableIndex)
Definition: tbdata.c:1162
#define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
Definition: actbl.h:431
#define ACPI_ADR_SPACE_SYSTEM_MEMORY
Definition: actypes.h:861
#define ACPI_ALLOCATE(a)
Definition: actypes.h:384
ACPI_STATUS AcpiDsGetRegionArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:395
static ACPI_STATUS AcpiExRegionRead(ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Length, UINT8 *Buffer)
Definition: exconfig.c:290
static ACPI_STATUS AcpiExAddTable(UINT32 TableIndex, ACPI_OPERAND_OBJECT **DdbHandle)
Definition: exconfig.c:87
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91
ASMGENDATA Table[]
Definition: genincdata.c:61
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
UINT32 Length
Definition: actbl.h:109
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by AcpiExOpcode_1A_1T_1R().

◆ AcpiExLoadTableOp()

ACPI_STATUS AcpiExLoadTableOp ( ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT **  ReturnDesc 
)

Definition at line 129 of file exconfig.c.

132{
134 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
135 ACPI_NAMESPACE_NODE *ParentNode;
136 ACPI_NAMESPACE_NODE *StartNode;
137 ACPI_NAMESPACE_NODE *ParameterNode = NULL;
138 ACPI_OPERAND_OBJECT *ReturnObj;
139 ACPI_OPERAND_OBJECT *DdbHandle;
140 UINT32 TableIndex;
141
142
143 ACPI_FUNCTION_TRACE (ExLoadTableOp);
144
145
146 /* Create the return object */
147
148 ReturnObj = AcpiUtCreateIntegerObject ((UINT64) 0);
149 if (!ReturnObj)
150 {
152 }
153
154 *ReturnDesc = ReturnObj;
155
156 /* Find the ACPI table in the RSDT/XSDT */
157
160 Operand[0]->String.Pointer,
161 Operand[1]->String.Pointer,
162 Operand[2]->String.Pointer, &TableIndex);
164 if (ACPI_FAILURE (Status))
165 {
166 if (Status != AE_NOT_FOUND)
167 {
169 }
170
171 /* Table not found, return an Integer=0 and AE_OK */
172
174 }
175
176 /* Default nodes */
177
178 StartNode = WalkState->ScopeInfo->Scope.Node;
179 ParentNode = AcpiGbl_RootNode;
180
181 /* RootPath (optional parameter) */
182
183 if (Operand[3]->String.Length > 0)
184 {
185 /*
186 * Find the node referenced by the RootPathString. This is the
187 * location within the namespace where the table will be loaded.
188 */
189 Status = AcpiNsGetNodeUnlocked (StartNode,
190 Operand[3]->String.Pointer, ACPI_NS_SEARCH_PARENT,
191 &ParentNode);
192 if (ACPI_FAILURE (Status))
193 {
195 }
196 }
197
198 /* ParameterPath (optional parameter) */
199
200 if (Operand[4]->String.Length > 0)
201 {
202 if ((Operand[4]->String.Pointer[0] != AML_ROOT_PREFIX) &&
203 (Operand[4]->String.Pointer[0] != AML_PARENT_PREFIX))
204 {
205 /*
206 * Path is not absolute, so it will be relative to the node
207 * referenced by the RootPathString (or the NS root if omitted)
208 */
209 StartNode = ParentNode;
210 }
211
212 /* Find the node referenced by the ParameterPathString */
213
214 Status = AcpiNsGetNodeUnlocked (StartNode,
215 Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT,
216 &ParameterNode);
217 if (ACPI_FAILURE (Status))
218 {
220 }
221 }
222
223 /* Load the table into the namespace */
224
225 ACPI_INFO (("Dynamic OEM Table Load:"));
227 Status = AcpiTbLoadTable (TableIndex, ParentNode);
229 if (ACPI_FAILURE (Status))
230 {
232 }
233
234 Status = AcpiExAddTable (TableIndex, &DdbHandle);
235 if (ACPI_FAILURE (Status))
236 {
238 }
239
240 /* Complete the initialization/resolution of new objects */
241
245
246 /* Parameter Data (optional) */
247
248 if (ParameterNode)
249 {
250 /* Store the parameter data into the optional parameter object */
251
252 Status = AcpiExStore (Operand[5],
253 ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), WalkState);
254 if (ACPI_FAILURE (Status))
255 {
256 (void) AcpiExUnloadTable (DdbHandle);
257
258 AcpiUtRemoveReference (DdbHandle);
260 }
261 }
262
263 /* Remove the reference to DdbHandle created by AcpiExAddTable above */
264
265 AcpiUtRemoveReference (DdbHandle);
266
267 /* Return -1 (non-zero) indicates success */
268
269 ReturnObj->Integer.Value = 0xFFFFFFFFFFFFFFFF;
271}
#define AE_NOT_FOUND
Definition: acexcep.h:113
ACPI_STATUS AcpiNsGetNodeUnlocked(ACPI_NAMESPACE_NODE *PrefixNode, const char *ExternalPathname, UINT32 Flags, ACPI_NAMESPACE_NODE **OutNode)
Definition: nsutils.c:777
#define ACPI_NS_SEARCH_PARENT
Definition: acnamesp.h:63
ACPI_STATUS AcpiTbLoadTable(UINT32 TableIndex, ACPI_NAMESPACE_NODE *ParentNode)
Definition: tbdata.c:1097
ACPI_STATUS AcpiTbFindTable(char *Signature, char *OemId, char *OemTableId, UINT32 *TableIndex)
Definition: tbfind.c:70
ACPI_STATUS AcpiExUnloadTable(ACPI_OPERAND_OBJECT *DdbHandle)
Definition: exconfig.c:565
ACPI_STATUS AcpiExStore(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState)
Definition: exstore.c:91
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by AcpiExOpcode_6A_0T_1R().

◆ AcpiExOpcode_0A_0T_1R()

ACPI_STATUS AcpiExOpcode_0A_0T_1R ( ACPI_WALK_STATE WalkState)

Naming convention for AML interpreter execution routines.

The routines that begin execution of AML opcodes are named with a common convention based upon the number of arguments, the number of target operands, and whether or not a value is returned:

 AcpiExOpcode_xA_yT_zR

Where:

xA - ARGUMENTS: The number of arguments (input operands) that are required for this opcode type (0 through 6 args). yT - TARGETS: The number of targets (output operands) that are required for this opcode type (0, 1, or 2 targets). zR - RETURN VALUE: Indicates whether this opcode type returns a value as the function return (0 or 1).

The AcpiExOpcode* functions are called via the Dispatcher component with fully resolved operands. !

Definition at line 92 of file exoparg1.c.

94{
96 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
97
98
99 ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
100 AcpiPsGetOpcodeName (WalkState->Opcode));
101
102
103 /* Examine the AML opcode */
104
105 switch (WalkState->Opcode)
106 {
107 case AML_TIMER_OP: /* Timer () */
108
109 /* Create a return object of type Integer */
110
112 if (!ReturnDesc)
113 {
115 goto Cleanup;
116 }
117 break;
118
119 default: /* Unknown opcode */
120
121 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
122 WalkState->Opcode));
124 break;
125 }
126
127Cleanup:
128
129 /* Delete return object on error */
130
131 if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
132 {
133 AcpiUtRemoveReference (ReturnDesc);
134 WalkState->ResultObj = NULL;
135 }
136 else
137 {
138 /* Save the return value */
139
140 WalkState->ResultObj = ReturnDesc;
141 }
142
144}
#define AE_AML_BAD_OPCODE
Definition: acexcep.h:180
#define ACPI_FUNCTION_TRACE_STR(a, b)
Definition: acoutput.h:483
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
#define AML_TIMER_OP
Definition: amlcode.h:179
union acpi_operand_object * ResultObj
Definition: acstruct.h:121

◆ AcpiExOpcode_1A_0T_0R()

ACPI_STATUS AcpiExOpcode_1A_0T_0R ( ACPI_WALK_STATE WalkState)

Definition at line 161 of file exoparg1.c.

163{
164 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
166
167
168 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
169 AcpiPsGetOpcodeName (WalkState->Opcode));
170
171
172 /* Examine the AML opcode */
173
174 switch (WalkState->Opcode)
175 {
176 case AML_RELEASE_OP: /* Release (MutexObject) */
177
178 Status = AcpiExReleaseMutex (Operand[0], WalkState);
179 break;
180
181 case AML_RESET_OP: /* Reset (EventObject) */
182
183 Status = AcpiExSystemResetEvent (Operand[0]);
184 break;
185
186 case AML_SIGNAL_OP: /* Signal (EventObject) */
187
188 Status = AcpiExSystemSignalEvent (Operand[0]);
189 break;
190
191 case AML_SLEEP_OP: /* Sleep (MsecTime) */
192
193 Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
194 break;
195
196 case AML_STALL_OP: /* Stall (UsecTime) */
197
198 Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
199 break;
200
201 case AML_UNLOAD_OP: /* Unload (Handle) */
202
203 Status = AcpiExUnloadTable (Operand[0]);
204 break;
205
206 default: /* Unknown opcode */
207
208 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
209 WalkState->Opcode));
211 break;
212 }
213
215}
#define AML_RELEASE_OP
Definition: amlcode.h:172
#define AML_STALL_OP
Definition: amlcode.h:166
#define AML_SIGNAL_OP
Definition: amlcode.h:169
#define AML_RESET_OP
Definition: amlcode.h:171
#define AML_UNLOAD_OP
Definition: amlcode.h:175
#define AML_SLEEP_OP
Definition: amlcode.h:167
ACPI_STATUS AcpiExReleaseMutex(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: exmutex.c:408
ACPI_STATUS AcpiExSystemDoStall(UINT32 HowLongUs)
Definition: exsystem.c:174
ACPI_STATUS AcpiExSystemDoSleep(UINT64 HowLongMs)
Definition: exsystem.c:223
ACPI_STATUS AcpiExSystemSignalEvent(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exsystem.c:265
ACPI_STATUS AcpiExSystemResetEvent(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exsystem.c:332

◆ AcpiExOpcode_1A_0T_1R()

ACPI_STATUS AcpiExOpcode_1A_0T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 642 of file exoparg1.c.

644{
645 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
646 ACPI_OPERAND_OBJECT *TempDesc;
647 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
649 UINT32 Type;
651
652
653 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
654 AcpiPsGetOpcodeName (WalkState->Opcode));
655
656
657 /* Examine the AML opcode */
658
659 switch (WalkState->Opcode)
660 {
661 case AML_LOGICAL_NOT_OP: /* LNot (Operand) */
662
663 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
664 if (!ReturnDesc)
665 {
667 goto Cleanup;
668 }
669
670 /*
671 * Set result to ONES (TRUE) if Value == 0. Note:
672 * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
673 */
674 if (!Operand[0]->Integer.Value)
675 {
676 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
677 }
678 break;
679
680 case AML_DECREMENT_OP: /* Decrement (Operand) */
681 case AML_INCREMENT_OP: /* Increment (Operand) */
682 /*
683 * Create a new integer. Can't just get the base integer and
684 * increment it because it may be an Arg or Field.
685 */
687 if (!ReturnDesc)
688 {
690 goto Cleanup;
691 }
692
693 /*
694 * Since we are expecting a Reference operand, it can be either a
695 * NS Node or an internal object.
696 */
697 TempDesc = Operand[0];
699 {
700 /* Internal reference object - prevent deletion */
701
702 AcpiUtAddReference (TempDesc);
703 }
704
705 /*
706 * Convert the Reference operand to an Integer (This removes a
707 * reference on the Operand[0] object)
708 *
709 * NOTE: We use LNOT_OP here in order to force resolution of the
710 * reference operand to an actual integer.
711 */
713 &TempDesc, WalkState);
714 if (ACPI_FAILURE (Status))
715 {
717 "While resolving operands for [%s]",
718 AcpiPsGetOpcodeName (WalkState->Opcode)));
719
720 goto Cleanup;
721 }
722
723 /*
724 * TempDesc is now guaranteed to be an Integer object --
725 * Perform the actual increment or decrement
726 */
727 if (WalkState->Opcode == AML_INCREMENT_OP)
728 {
729 ReturnDesc->Integer.Value = TempDesc->Integer.Value + 1;
730 }
731 else
732 {
733 ReturnDesc->Integer.Value = TempDesc->Integer.Value - 1;
734 }
735
736 /* Finished with this Integer object */
737
738 AcpiUtRemoveReference (TempDesc);
739
740 /*
741 * Store the result back (indirectly) through the original
742 * Reference object
743 */
744 Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
745 break;
746
747 case AML_OBJECT_TYPE_OP: /* ObjectType (SourceObject) */
748 /*
749 * Note: The operand is not resolved at this point because we want to
750 * get the associated object, not its value. For example, we don't
751 * want to resolve a FieldUnit to its value, we want the actual
752 * FieldUnit object.
753 */
754
755 /* Get the type of the base object */
756
757 Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
758 if (ACPI_FAILURE (Status))
759 {
760 goto Cleanup;
761 }
762
763 /* Allocate a descriptor to hold the type. */
764
765 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
766 if (!ReturnDesc)
767 {
769 goto Cleanup;
770 }
771 break;
772
773 case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
774 /*
775 * Note: The operand is not resolved at this point because we want to
776 * get the associated object, not its value.
777 */
778
779 /* Get the base object */
780
782 WalkState, Operand[0], &Type, &TempDesc);
783 if (ACPI_FAILURE (Status))
784 {
785 goto Cleanup;
786 }
787
788 /*
789 * The type of the base object must be integer, buffer, string, or
790 * package. All others are not supported.
791 *
792 * NOTE: Integer is not specifically supported by the ACPI spec,
793 * but is supported implicitly via implicit operand conversion.
794 * rather than bother with conversion, we just use the byte width
795 * global (4 or 8 bytes).
796 */
797 switch (Type)
798 {
800
801 Value = AcpiGbl_IntegerByteWidth;
802 break;
803
804 case ACPI_TYPE_STRING:
805
806 Value = TempDesc->String.Length;
807 break;
808
809 case ACPI_TYPE_BUFFER:
810
811 /* Buffer arguments may not be evaluated at this point */
812
813 Status = AcpiDsGetBufferArguments (TempDesc);
814 Value = TempDesc->Buffer.Length;
815 break;
816
818
819 /* Package arguments may not be evaluated at this point */
820
822 Value = TempDesc->Package.Count;
823 break;
824
825 default:
826
828 "Operand must be Buffer/Integer/String/Package"
829 " - found type %s",
831
833 goto Cleanup;
834 }
835
836 if (ACPI_FAILURE (Status))
837 {
838 goto Cleanup;
839 }
840
841 /*
842 * Now that we have the size of the object, create a result
843 * object to hold the value
844 */
845 ReturnDesc = AcpiUtCreateIntegerObject (Value);
846 if (!ReturnDesc)
847 {
849 goto Cleanup;
850 }
851 break;
852
853
854 case AML_REF_OF_OP: /* RefOf (SourceObject) */
855
857 Operand[0], &ReturnDesc, WalkState);
858 if (ACPI_FAILURE (Status))
859 {
860 goto Cleanup;
861 }
862 break;
863
864
865 case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
866
867 /* Check for a method local or argument, or standalone String */
868
870 {
871 TempDesc = AcpiNsGetAttachedObject (
872 (ACPI_NAMESPACE_NODE *) Operand[0]);
873 if (TempDesc &&
874 ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
875 (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
876 {
877 Operand[0] = TempDesc;
878 AcpiUtAddReference (TempDesc);
879 }
880 else
881 {
883 goto Cleanup;
884 }
885 }
886 else
887 {
888 switch ((Operand[0])->Common.Type)
889 {
891 /*
892 * This is a DerefOf (LocalX | ArgX)
893 *
894 * Must resolve/dereference the local/arg reference first
895 */
896 switch (Operand[0]->Reference.Class)
897 {
900
901 /* Set Operand[0] to the value of the local/arg */
902
904 Operand[0]->Reference.Class,
905 Operand[0]->Reference.Value,
906 WalkState, &TempDesc);
907 if (ACPI_FAILURE (Status))
908 {
909 goto Cleanup;
910 }
911
912 /*
913 * Delete our reference to the input object and
914 * point to the object just retrieved
915 */
916 AcpiUtRemoveReference (Operand[0]);
917 Operand[0] = TempDesc;
918 break;
919
921
922 /* Get the object to which the reference refers */
923
924 TempDesc = Operand[0]->Reference.Object;
925 AcpiUtRemoveReference (Operand[0]);
926 Operand[0] = TempDesc;
927 break;
928
929 default:
930
931 /* Must be an Index op - handled below */
932 break;
933 }
934 break;
935
936 case ACPI_TYPE_STRING:
937
938 break;
939
940 default:
941
943 goto Cleanup;
944 }
945 }
946
948 {
949 if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
950 {
951 /*
952 * This is a DerefOf (String). The string is a reference
953 * to a named ACPI object.
954 *
955 * 1) Find the owning Node
956 * 2) Dereference the node to an actual object. Could be a
957 * Field, so we need to resolve the node to a value.
958 */
960 Operand[0]->String.Pointer,
963 ACPI_NAMESPACE_NODE, &ReturnDesc));
964 if (ACPI_FAILURE (Status))
965 {
966 goto Cleanup;
967 }
968
971 ACPI_NAMESPACE_NODE, &ReturnDesc),
972 WalkState);
973 goto Cleanup;
974 }
975 }
976
977 /* Operand[0] may have changed from the code above */
978
980 {
981 /*
982 * This is a DerefOf (ObjectReference)
983 * Get the actual object from the Node (This is the dereference).
984 * This case may only happen when a LocalX or ArgX is
985 * dereferenced above, or for references to device and
986 * thermal objects.
987 */
988 switch (((ACPI_NAMESPACE_NODE *) Operand[0])->Type)
989 {
990 case ACPI_TYPE_DEVICE:
992
993 /* These types have no node subobject, return the NS node */
994
995 ReturnDesc = Operand[0];
996 break;
997
998 default:
999 /* For most types, get the object attached to the node */
1000
1001 ReturnDesc = AcpiNsGetAttachedObject (
1002 (ACPI_NAMESPACE_NODE *) Operand[0]);
1003 AcpiUtAddReference (ReturnDesc);
1004 break;
1005 }
1006 }
1007 else
1008 {
1009 /*
1010 * This must be a reference object produced by either the
1011 * Index() or RefOf() operator
1012 */
1013 switch (Operand[0]->Reference.Class)
1014 {
1016 /*
1017 * The target type for the Index operator must be
1018 * either a Buffer or a Package
1019 */
1020 switch (Operand[0]->Reference.TargetType)
1021 {
1023
1024 TempDesc = Operand[0]->Reference.Object;
1025
1026 /*
1027 * Create a new object that contains one element of the
1028 * buffer -- the element pointed to by the index.
1029 *
1030 * NOTE: index into a buffer is NOT a pointer to a
1031 * sub-buffer of the main buffer, it is only a pointer to a
1032 * single element (byte) of the buffer!
1033 *
1034 * Since we are returning the value of the buffer at the
1035 * indexed location, we don't need to add an additional
1036 * reference to the buffer itself.
1037 */
1038 ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
1039 TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
1040 if (!ReturnDesc)
1041 {
1043 goto Cleanup;
1044 }
1045 break;
1046
1047 case ACPI_TYPE_PACKAGE:
1048 /*
1049 * Return the referenced element of the package. We must
1050 * add another reference to the referenced object, however.
1051 */
1052 ReturnDesc = *(Operand[0]->Reference.Where);
1053 if (!ReturnDesc)
1054 {
1055 /*
1056 * Element is NULL, do not allow the dereference.
1057 * This provides compatibility with other ACPI
1058 * implementations.
1059 */
1061 }
1062
1063 AcpiUtAddReference (ReturnDesc);
1064 break;
1065
1066 default:
1067
1069 "Unknown Index TargetType 0x%X in reference object %p",
1070 Operand[0]->Reference.TargetType, Operand[0]));
1071
1073 goto Cleanup;
1074 }
1075 break;
1076
1078
1079 ReturnDesc = Operand[0]->Reference.Object;
1080
1081 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1083 {
1084 ReturnDesc = AcpiNsGetAttachedObject (
1085 (ACPI_NAMESPACE_NODE *) ReturnDesc);
1086 if (!ReturnDesc)
1087 {
1088 break;
1089 }
1090
1091 /*
1092 * June 2013:
1093 * BufferFields/FieldUnits require additional resolution
1094 */
1095 switch (ReturnDesc->Common.Type)
1096 {
1101
1103 WalkState, ReturnDesc, &TempDesc);
1104 if (ACPI_FAILURE (Status))
1105 {
1107 }
1108
1109 ReturnDesc = TempDesc;
1110 break;
1111
1112 default:
1113
1114 /* Add another reference to the object */
1115
1116 AcpiUtAddReference (ReturnDesc);
1117 break;
1118 }
1119 }
1120 break;
1121
1122 default:
1123
1125 "Unknown class in reference(%p) - 0x%2.2X",
1126 Operand[0], Operand[0]->Reference.Class));
1127
1128 Status = AE_TYPE;
1129 goto Cleanup;
1130 }
1131 }
1132 break;
1133
1134 default:
1135
1136 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
1137 WalkState->Opcode));
1138
1140 goto Cleanup;
1141 }
1142
1143
1144Cleanup:
1145
1146 /* Delete return object on error */
1147
1148 if (ACPI_FAILURE (Status))
1149 {
1150 AcpiUtRemoveReference (ReturnDesc);
1151 }
1152
1153 /* Save return object on success */
1154
1155 else
1156 {
1157 WalkState->ResultObj = ReturnDesc;
1158 }
1159
1161}
#define AE_AML_UNINITIALIZED_ELEMENT
Definition: acexcep.h:186
#define ACPI_UINT64_MAX
Definition: actypes.h:67
#define ACPI_CAST_INDIRECT_PTR(t, p)
Definition: actypes.h:545
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752
#define AML_OBJECT_TYPE_OP
Definition: amlcode.h:118
#define AML_DECREMENT_OP
Definition: amlcode.h:94
#define AML_REF_OF_OP
Definition: amlcode.h:89
#define AML_LOGICAL_NOT_OP
Definition: amlcode.h:122
#define AML_INCREMENT_OP
Definition: amlcode.h:93
#define AML_SIZE_OF_OP
Definition: amlcode.h:111
#define AML_DEREF_OF_OP
Definition: amlcode.h:107
ACPI_STATUS AcpiDsGetPackageArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:344
ACPI_STATUS AcpiDsGetBufferArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:294
ACPI_STATUS AcpiDsMethodDataGetValue(UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc)
Definition: dsmthdat.c:406
ACPI_STATUS AcpiExReadDataFromField(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **RetBufferDesc)
Definition: exfield.c:147
ACPI_STATUS AcpiExGetObjectReference(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnDesc, ACPI_WALK_STATE *WalkState)
Definition: exmisc.c:70
ACPI_STATUS AcpiExResolveNodeToValue(ACPI_NAMESPACE_NODE **ObjectPtr, ACPI_WALK_STATE *WalkState)
Definition: exresnte.c:82
ACPI_STATUS AcpiExResolveMultiple(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *Operand, ACPI_OBJECT_TYPE *ReturnType, ACPI_OPERAND_OBJECT **ReturnDesc)
Definition: exresolv.c:350
ACPI_STATUS AcpiExResolveOperands(UINT16 Opcode, ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
Definition: exresop.c:145

◆ AcpiExOpcode_1A_1T_0R()

ACPI_STATUS AcpiExOpcode_1A_1T_0R ( ACPI_WALK_STATE WalkState)

◆ AcpiExOpcode_1A_1T_1R()

ACPI_STATUS AcpiExOpcode_1A_1T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 286 of file exoparg1.c.

288{
290 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
291 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
292 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
293 UINT32 Temp32;
294 UINT32 i;
295 UINT64 PowerOfTen;
296 UINT64 Digit;
297
298
299 ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
300 AcpiPsGetOpcodeName (WalkState->Opcode));
301
302
303 /* Examine the AML opcode */
304
305 switch (WalkState->Opcode)
306 {
307 case AML_BIT_NOT_OP:
310 case AML_FROM_BCD_OP:
311 case AML_LOAD_OP:
312 case AML_TO_BCD_OP:
314
315 /* Create a return object of type Integer for these opcodes */
316
318 if (!ReturnDesc)
319 {
321 goto Cleanup;
322 }
323
324 switch (WalkState->Opcode)
325 {
326 case AML_BIT_NOT_OP: /* Not (Operand, Result) */
327
328 ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
329 break;
330
331 case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
332
333 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
334
335 /*
336 * Acpi specification describes Integer type as a little
337 * endian unsigned value, so this boundary condition is valid.
338 */
339 for (Temp32 = 0; ReturnDesc->Integer.Value &&
340 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
341 {
342 ReturnDesc->Integer.Value >>= 1;
343 }
344
345 ReturnDesc->Integer.Value = Temp32;
346 break;
347
348 case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
349
350 ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
351
352 /*
353 * The Acpi specification describes Integer type as a little
354 * endian unsigned value, so this boundary condition is valid.
355 */
356 for (Temp32 = 0; ReturnDesc->Integer.Value &&
357 Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
358 {
359 ReturnDesc->Integer.Value <<= 1;
360 }
361
362 /* Since the bit position is one-based, subtract from 33 (65) */
363
364 ReturnDesc->Integer.Value =
365 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
366 break;
367
368 case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
369 /*
370 * The 64-bit ACPI integer can hold 16 4-bit BCD characters
371 * (if table is 32-bit, integer can hold 8 BCD characters)
372 * Convert each 4-bit BCD value
373 */
374 PowerOfTen = 1;
375 ReturnDesc->Integer.Value = 0;
376 Digit = Operand[0]->Integer.Value;
377
378 /* Convert each BCD digit (each is one nybble wide) */
379
380 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
381 {
382 /* Get the least significant 4-bit BCD digit */
383
384 Temp32 = ((UINT32) Digit) & 0xF;
385
386 /* Check the range of the digit */
387
388 if (Temp32 > 9)
389 {
391 "BCD digit too large (not decimal): 0x%X",
392 Temp32));
393
395 goto Cleanup;
396 }
397
398 /* Sum the digit into the result with the current power of 10 */
399
400 ReturnDesc->Integer.Value +=
401 (((UINT64) Temp32) * PowerOfTen);
402
403 /* Shift to next BCD digit */
404
405 Digit >>= 4;
406
407 /* Next power of 10 */
408
409 PowerOfTen *= 10;
410 }
411 break;
412
413 case AML_LOAD_OP: /* Result1 = Load (Operand[0], Result1) */
414
415 ReturnDesc->Integer.Value = 0;
416 Status = AcpiExLoadOp (Operand[0], ReturnDesc, WalkState);
417 if (ACPI_SUCCESS (Status))
418 {
419 /* Return -1 (non-zero) indicates success */
420
421 ReturnDesc->Integer.Value = 0xFFFFFFFFFFFFFFFF;
422 }
423 break;
424
425 case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
426
427 ReturnDesc->Integer.Value = 0;
428 Digit = Operand[0]->Integer.Value;
429
430 /* Each BCD digit is one nybble wide */
431
432 for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
433 {
434 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
435
436 /*
437 * Insert the BCD digit that resides in the
438 * remainder from above
439 */
440 ReturnDesc->Integer.Value |=
441 (((UINT64) Temp32) << ACPI_MUL_4 (i));
442 }
443
444 /* Overflow if there is any data left in Digit */
445
446 if (Digit > 0)
447 {
449 "Integer too large to convert to BCD: 0x%8.8X%8.8X",
450 ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
452 goto Cleanup;
453 }
454 break;
455
456 case AML_CONDITIONAL_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
457 /*
458 * This op is a little strange because the internal return value is
459 * different than the return value stored in the result descriptor
460 * (There are really two return values)
461 */
462 if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
463 {
464 /*
465 * This means that the object does not exist in the namespace,
466 * return FALSE
467 */
468 ReturnDesc->Integer.Value = 0;
469 goto Cleanup;
470 }
471
472 /* Get the object reference, store it, and remove our reference */
473
474 Status = AcpiExGetObjectReference (Operand[0],
475 &ReturnDesc2, WalkState);
476 if (ACPI_FAILURE (Status))
477 {
478 goto Cleanup;
479 }
480
481 Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
482 AcpiUtRemoveReference (ReturnDesc2);
483
484 /* The object exists in the namespace, return TRUE */
485
486 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
487 goto Cleanup;
488
489
490 default:
491
492 /* No other opcodes get here */
493
494 break;
495 }
496 break;
497
498 case AML_STORE_OP: /* Store (Source, Target) */
499 /*
500 * A store operand is typically a number, string, buffer or lvalue
501 * Be careful about deleting the source object,
502 * since the object itself may have been stored.
503 */
504 Status = AcpiExStore (Operand[0], Operand[1], WalkState);
505 if (ACPI_FAILURE (Status))
506 {
508 }
509
510 /* It is possible that the Store already produced a return object */
511
512 if (!WalkState->ResultObj)
513 {
514 /*
515 * Normally, we would remove a reference on the Operand[0]
516 * parameter; But since it is being used as the internal return
517 * object (meaning we would normally increment it), the two
518 * cancel out, and we simply don't do anything.
519 */
520 WalkState->ResultObj = Operand[0];
521 WalkState->Operands[0] = NULL; /* Prevent deletion */
522 }
524
525 /*
526 * ACPI 2.0 Opcodes
527 */
528 case AML_COPY_OBJECT_OP: /* CopyObject (Source, Target) */
529
531 Operand[0], &ReturnDesc, WalkState);
532 break;
533
534 case AML_TO_DECIMAL_STRING_OP: /* ToDecimalString (Data, Result) */
535
537 Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL);
538 if (ReturnDesc == Operand[0])
539 {
540 /* No conversion performed, add ref to handle return value */
541
542 AcpiUtAddReference (ReturnDesc);
543 }
544 break;
545
546 case AML_TO_HEX_STRING_OP: /* ToHexString (Data, Result) */
547
549 Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX);
550 if (ReturnDesc == Operand[0])
551 {
552 /* No conversion performed, add ref to handle return value */
553
554 AcpiUtAddReference (ReturnDesc);
555 }
556 break;
557
558 case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
559
560 Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
561 if (ReturnDesc == Operand[0])
562 {
563 /* No conversion performed, add ref to handle return value */
564
565 AcpiUtAddReference (ReturnDesc);
566 }
567 break;
568
569 case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
570
571 /* Perform "explicit" conversion */
572
573 Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, 0);
574 if (ReturnDesc == Operand[0])
575 {
576 /* No conversion performed, add ref to handle return value */
577
578 AcpiUtAddReference (ReturnDesc);
579 }
580 break;
581
582 case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
583 case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
584
585 /* These are two obsolete opcodes */
586
588 "%s is obsolete and not implemented",
589 AcpiPsGetOpcodeName (WalkState->Opcode)));
591 goto Cleanup;
592
593 default: /* Unknown opcode */
594
595 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
596 WalkState->Opcode));
598 goto Cleanup;
599 }
600
601 if (ACPI_SUCCESS (Status))
602 {
603 /* Store the return value computed above into the target object */
604
605 Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
606 }
607
608
609Cleanup:
610
611 /* Delete return object on error */
612
613 if (ACPI_FAILURE (Status))
614 {
615 AcpiUtRemoveReference (ReturnDesc);
616 }
617
618 /* Save return object on success */
619
620 else if (!WalkState->ResultObj)
621 {
622 WalkState->ResultObj = ReturnDesc;
623 }
624
626}
#define AE_SUPPORT
Definition: acexcep.h:123
#define AE_AML_NUMERIC_OVERFLOW
Definition: acexcep.h:187
#define ACPI_MUL_4(a)
Definition: acmacros.h:211
ACPI_STATUS AcpiUtCopyIobjectToIobject(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, ACPI_WALK_STATE *WalkState)
Definition: utcopy.c:1037
#define AML_TO_DECIMAL_STRING_OP
Definition: amlcode.h:127
#define AML_TO_HEX_STRING_OP
Definition: amlcode.h:128
#define AML_FIND_SET_RIGHT_BIT_OP
Definition: amlcode.h:106
#define AML_FROM_BCD_OP
Definition: amlcode.h:173
#define AML_COPY_OBJECT_OP
Definition: amlcode.h:131
#define AML_SHIFT_LEFT_BIT_OP
Definition: amlcode.h:161
#define AML_TO_BCD_OP
Definition: amlcode.h:174
#define AML_STORE_OP
Definition: amlcode.h:88
#define AML_CONDITIONAL_REF_OF_OP
Definition: amlcode.h:162
#define AML_TO_BUFFER_OP
Definition: amlcode.h:126
#define AML_LOAD_OP
Definition: amlcode.h:165
#define AML_TO_INTEGER_OP
Definition: amlcode.h:129
#define AML_FIND_SET_LEFT_BIT_OP
Definition: amlcode.h:105
#define AML_BIT_NOT_OP
Definition: amlcode.h:104
#define AML_SHIFT_RIGHT_BIT_OP
Definition: amlcode.h:160
ACPI_STATUS AcpiExLoadOp(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState)
Definition: exconfig.c:343

◆ AcpiExOpcode_2A_0T_0R()

ACPI_STATUS AcpiExOpcode_2A_0T_0R ( ACPI_WALK_STATE WalkState)

Naming convention for AML interpreter execution routines.

The routines that begin execution of AML opcodes are named with a common convention based upon the number of arguments, the number of target operands, and whether or not a value is returned:

 AcpiExOpcode_xA_yT_zR

Where:

xA - ARGUMENTS: The number of arguments (input operands) that are required for this opcode type (1 through 6 args). yT - TARGETS: The number of targets (output operands) that are required for this opcode type (0, 1, or 2 targets). zR - RETURN VALUE: Indicates whether this opcode type returns a value as the function return (0 or 1).

The AcpiExOpcode* functions are called via the Dispatcher component with fully resolved operands. !

Definition at line 95 of file exoparg2.c.

97{
98 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
102
103
104 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
105 AcpiPsGetOpcodeName (WalkState->Opcode));
106
107
108 /* Examine the opcode */
109
110 switch (WalkState->Opcode)
111 {
112 case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */
113
114 /* The first operand is a namespace node */
115
116 Node = (ACPI_NAMESPACE_NODE *) Operand[0];
117
118 /* Second value is the notify value */
119
120 Value = (UINT32) Operand[1]->Integer.Value;
121
122 /* Are notifies allowed on this object? */
123
125 {
127 "Unexpected notify object type [%s]",
128 AcpiUtGetTypeName (Node->Type)));
129
131 break;
132 }
133
134 /*
135 * Dispatch the notify to the appropriate handler
136 * NOTE: the request is queued for execution after this method
137 * completes. The notify handlers are NOT invoked synchronously
138 * from this thread -- because handlers may in turn run other
139 * control methods.
140 */
142 break;
143
144 default:
145
146 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
147 WalkState->Opcode));
149 }
150
152}
#define AML_NOTIFY_OP
Definition: amlcode.h:110
ACPI_STATUS AcpiEvQueueNotifyRequest(ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue)
Definition: evmisc.c:111
BOOLEAN AcpiEvIsNotifyObject(ACPI_NAMESPACE_NODE *Node)
Definition: evmisc.c:75
if(dx< 0)
Definition: linetemp.h:194

◆ AcpiExOpcode_2A_0T_1R()

ACPI_STATUS AcpiExOpcode_2A_0T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 540 of file exoparg2.c.

542{
543 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
544 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
546 BOOLEAN LogicalResult = FALSE;
547
548
549 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
550 AcpiPsGetOpcodeName (WalkState->Opcode));
551
552
553 /* Create the internal return object */
554
556 if (!ReturnDesc)
557 {
559 goto Cleanup;
560 }
561
562 /* Execute the Opcode */
563
564 if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
565 {
566 /* LogicalOp (Operand0, Operand1) */
567
569 Operand[0]->Integer.Value, Operand[1]->Integer.Value,
570 &LogicalResult);
571 goto StoreLogicalResult;
572 }
573 else if (WalkState->OpInfo->Flags & AML_LOGICAL)
574 {
575 /* LogicalOp (Operand0, Operand1) */
576
577 Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
578 Operand[1], &LogicalResult);
579 goto StoreLogicalResult;
580 }
581
582 switch (WalkState->Opcode)
583 {
584 case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
585
586 Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
587 if (Status == AE_TIME)
588 {
589 LogicalResult = TRUE; /* TRUE = Acquire timed out */
590 Status = AE_OK;
591 }
592 break;
593
594
595 case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
596
597 Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
598 if (Status == AE_TIME)
599 {
600 LogicalResult = TRUE; /* TRUE, Wait timed out */
601 Status = AE_OK;
602 }
603 break;
604
605 default:
606
607 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
608 WalkState->Opcode));
609
611 goto Cleanup;
612 }
613
614
615StoreLogicalResult:
616 /*
617 * Set return value to according to LogicalResult. logical TRUE (all ones)
618 * Default is FALSE (zero)
619 */
620 if (LogicalResult)
621 {
622 ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
623 }
624
625Cleanup:
626
627 /* Delete return object on error */
628
629 if (ACPI_FAILURE (Status))
630 {
631 AcpiUtRemoveReference (ReturnDesc);
632 }
633
634 /* Save return object on success */
635
636 else
637 {
638 WalkState->ResultObj = ReturnDesc;
639 }
640
642}
#define AE_TIME
Definition: acexcep.h:125
#define AML_WAIT_OP
Definition: amlcode.h:170
#define AML_ACQUIRE_OP
Definition: amlcode.h:168
#define AML_LOGICAL
Definition: amlcode.h:317
#define AML_LOGICAL_NUMERIC
Definition: amlcode.h:318
ACPI_STATUS AcpiExDoLogicalOp(UINT16 Opcode, ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, BOOLEAN *LogicalResult)
Definition: exmisc.c:335
ACPI_STATUS AcpiExDoLogicalNumericOp(UINT16 Opcode, UINT64 Integer0, UINT64 Integer1, BOOLEAN *LogicalResult)
Definition: exmisc.c:262
ACPI_STATUS AcpiExAcquireMutex(ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: exmutex.c:248
ACPI_STATUS AcpiExSystemWaitEvent(ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exsystem.c:299
UINT16 Flags
Definition: aclocal.h:873

◆ AcpiExOpcode_2A_1T_1R()

ACPI_STATUS AcpiExOpcode_2A_1T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 279 of file exoparg2.c.

281{
282 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
283 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
286 ACPI_SIZE Length = 0;
287
288
289 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
290 AcpiPsGetOpcodeName (WalkState->Opcode));
291
292
293 /* Execute the opcode */
294
295 if (WalkState->OpInfo->Flags & AML_MATH)
296 {
297 /* All simple math opcodes (add, etc.) */
298
300 if (!ReturnDesc)
301 {
303 goto Cleanup;
304 }
305
306 ReturnDesc->Integer.Value = AcpiExDoMathOp (
307 WalkState->Opcode,
308 Operand[0]->Integer.Value,
309 Operand[1]->Integer.Value);
310 goto StoreResultToTarget;
311 }
312
313 switch (WalkState->Opcode)
314 {
315 case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
316
318 if (!ReturnDesc)
319 {
321 goto Cleanup;
322 }
323
324 /* ReturnDesc will contain the remainder */
325
327 Operand[0]->Integer.Value,
328 Operand[1]->Integer.Value,
329 NULL,
330 &ReturnDesc->Integer.Value);
331 break;
332
333 case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */
334
336 Operand[0], Operand[1], &ReturnDesc, WalkState);
337 break;
338
339 case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
340 /*
341 * Input object is guaranteed to be a buffer at this point (it may have
342 * been converted.) Copy the raw buffer data to a new object of
343 * type String.
344 */
345
346 /*
347 * Get the length of the new string. It is the smallest of:
348 * 1) Length of the input buffer
349 * 2) Max length as specified in the ToString operator
350 * 3) Length of input buffer up to a zero byte (null terminator)
351 *
352 * NOTE: A length of zero is ok, and will create a zero-length, null
353 * terminated string.
354 */
355 while ((Length < Operand[0]->Buffer.Length) && /* Length of input buffer */
356 (Length < Operand[1]->Integer.Value) && /* Length operand */
357 (Operand[0]->Buffer.Pointer[Length])) /* Null terminator */
358 {
359 Length++;
360 }
361
362 /* Allocate a new string object */
363
364 ReturnDesc = AcpiUtCreateStringObject (Length);
365 if (!ReturnDesc)
366 {
368 goto Cleanup;
369 }
370
371 /*
372 * Copy the raw buffer data with no transform.
373 * (NULL terminated already)
374 */
375 memcpy (ReturnDesc->String.Pointer,
376 Operand[0]->Buffer.Pointer, Length);
377 break;
378
380
381 /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
382
384 Operand[0], Operand[1], &ReturnDesc, WalkState);
385 break;
386
387 case AML_INDEX_OP: /* Index (Source Index Result) */
388
389 /* Create the internal return object */
390
392 if (!ReturnDesc)
393 {
395 goto Cleanup;
396 }
397
398 /* Initialize the Index reference object */
399
400 Index = Operand[1]->Integer.Value;
401 ReturnDesc->Reference.Value = (UINT32) Index;
402 ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
403
404 /*
405 * At this point, the Source operand is a String, Buffer, or Package.
406 * Verify that the index is within range.
407 */
408 switch ((Operand[0])->Common.Type)
409 {
410 case ACPI_TYPE_STRING:
411
412 if (Index >= Operand[0]->String.Length)
413 {
414 Length = Operand[0]->String.Length;
416 }
417
419 ReturnDesc->Reference.IndexPointer =
420 &(Operand[0]->Buffer.Pointer [Index]);
421 break;
422
423 case ACPI_TYPE_BUFFER:
424
425 if (Index >= Operand[0]->Buffer.Length)
426 {
427 Length = Operand[0]->Buffer.Length;
429 }
430
432 ReturnDesc->Reference.IndexPointer =
433 &(Operand[0]->Buffer.Pointer [Index]);
434 break;
435
437
438 if (Index >= Operand[0]->Package.Count)
439 {
440 Length = Operand[0]->Package.Count;
442 }
443
445 ReturnDesc->Reference.Where =
446 &Operand[0]->Package.Elements [Index];
447 break;
448
449 default:
450
452 "Invalid object type: %X", (Operand[0])->Common.Type));
454 goto Cleanup;
455 }
456
457 /* Failure means that the Index was beyond the end of the object */
458
459 if (ACPI_FAILURE (Status))
460 {
462 "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
464 goto Cleanup;
465 }
466
467 /*
468 * Save the target object and add a reference to it for the life
469 * of the index
470 */
471 ReturnDesc->Reference.Object = Operand[0];
472 AcpiUtAddReference (Operand[0]);
473
474 /* Store the reference to the Target */
475
476 Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
477
478 /* Return the reference */
479
480 WalkState->ResultObj = ReturnDesc;
481 goto Cleanup;
482
483 default:
484
485 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
486 WalkState->Opcode));
488 break;
489 }
490
491
492StoreResultToTarget:
493
494 if (ACPI_SUCCESS (Status))
495 {
496 /*
497 * Store the result of the operation (which is now in ReturnDesc) into
498 * the Target descriptor.
499 */
500 Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
501 if (ACPI_FAILURE (Status))
502 {
503 goto Cleanup;
504 }
505
506 if (!WalkState->ResultObj)
507 {
508 WalkState->ResultObj = ReturnDesc;
509 }
510 }
511
512
513Cleanup:
514
515 /* Delete return object on error */
516
517 if (ACPI_FAILURE (Status))
518 {
519 AcpiUtRemoveReference (ReturnDesc);
520 WalkState->ResultObj = NULL;
521 }
522
524}
#define AE_AML_PACKAGE_LIMIT
Definition: acexcep.h:190
#define AE_AML_STRING_LIMIT
Definition: acexcep.h:196
#define ACPI_BIOS_EXCEPTION(plist)
Definition: acoutput.h:242
ACPI_STATUS AcpiUtDivide(UINT64 InDividend, UINT64 InDivisor, UINT64 *OutQuotient, UINT64 *OutRemainder)
Definition: utmath.c:402
#define AML_MOD_OP
Definition: amlcode.h:109
#define AML_CONCATENATE_TEMPLATE_OP
Definition: amlcode.h:108
#define AML_MATH
Definition: amlcode.h:319
#define AML_CONCATENATE_OP
Definition: amlcode.h:91
#define AML_INDEX_OP
Definition: amlcode.h:112
#define AML_TO_STRING_OP
Definition: amlcode.h:130
ACPI_STATUS AcpiExConcatTemplate(ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState)
Definition: exconcat.c:388
ACPI_STATUS AcpiExDoConcatenate(ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState)
Definition: exconcat.c:85
UINT64 AcpiExDoMathOp(UINT16 Opcode, UINT64 Integer0, UINT64 Integer1)
Definition: exmisc.c:167

◆ AcpiExOpcode_2A_2T_1R()

ACPI_STATUS AcpiExOpcode_2A_2T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 169 of file exoparg2.c.

171{
172 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
173 ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL;
174 ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
176
177
178 ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
179 AcpiPsGetOpcodeName (WalkState->Opcode));
180
181
182 /* Execute the opcode */
183
184 switch (WalkState->Opcode)
185 {
186 case AML_DIVIDE_OP:
187
188 /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
189
191 if (!ReturnDesc1)
192 {
194 goto Cleanup;
195 }
196
198 if (!ReturnDesc2)
199 {
201 goto Cleanup;
202 }
203
204 /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
205
207 Operand[0]->Integer.Value,
208 Operand[1]->Integer.Value,
209 &ReturnDesc1->Integer.Value,
210 &ReturnDesc2->Integer.Value);
211 if (ACPI_FAILURE (Status))
212 {
213 goto Cleanup;
214 }
215 break;
216
217 default:
218
219 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
220 WalkState->Opcode));
221
223 goto Cleanup;
224 }
225
226 /* Store the results to the target reference operands */
227
228 Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
229 if (ACPI_FAILURE (Status))
230 {
231 goto Cleanup;
232 }
233
234 Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
235 if (ACPI_FAILURE (Status))
236 {
237 goto Cleanup;
238 }
239
240Cleanup:
241 /*
242 * Since the remainder is not returned indirectly, remove a reference to
243 * it. Only the quotient is returned indirectly.
244 */
245 AcpiUtRemoveReference (ReturnDesc2);
246
247 if (ACPI_FAILURE (Status))
248 {
249 /* Delete the return object */
250
251 AcpiUtRemoveReference (ReturnDesc1);
252 }
253
254 /* Save return object (the remainder) on success */
255
256 else
257 {
258 WalkState->ResultObj = ReturnDesc1;
259 }
260
262}
#define AML_DIVIDE_OP
Definition: amlcode.h:96

◆ AcpiExOpcode_3A_0T_0R()

ACPI_STATUS AcpiExOpcode_3A_0T_0R ( ACPI_WALK_STATE WalkState)

Naming convention for AML interpreter execution routines.

The routines that begin execution of AML opcodes are named with a common convention based upon the number of arguments, the number of target operands, and whether or not a value is returned:

 AcpiExOpcode_xA_yT_zR

Where:

xA - ARGUMENTS: The number of arguments (input operands) that are required for this opcode type (1 through 6 args). yT - TARGETS: The number of targets (output operands) that are required for this opcode type (0, 1, or 2 targets). zR - RETURN VALUE: Indicates whether this opcode type returns a value as the function return (0 or 1).

The AcpiExOpcode* functions are called via the Dispatcher component with fully resolved operands. !

Definition at line 91 of file exoparg3.c.

93{
94 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
97
98
99 ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R,
100 AcpiPsGetOpcodeName (WalkState->Opcode));
101
102
103 switch (WalkState->Opcode)
104 {
105 case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */
106
108 "FatalOp: Type %X Code %X Arg %X "
109 "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
110 (UINT32) Operand[0]->Integer.Value,
111 (UINT32) Operand[1]->Integer.Value,
112 (UINT32) Operand[2]->Integer.Value));
113
115 if (Fatal)
116 {
117 Fatal->Type = (UINT32) Operand[0]->Integer.Value;
118 Fatal->Code = (UINT32) Operand[1]->Integer.Value;
119 Fatal->Argument = (UINT32) Operand[2]->Integer.Value;
120 }
121
122 /* Always signal the OS! */
123
125
126 /* Might return while OS is shutting down, just continue */
127
129 goto Cleanup;
130
131 case AML_EXTERNAL_OP:
132 /*
133 * If the interpreter sees this opcode, just ignore it. The External
134 * op is intended for use by disassemblers in order to properly
135 * disassemble control method invocations. The opcode or group of
136 * opcodes should be surrounded by an "if (0)" clause to ensure that
137 * AML interpreters never see the opcode. Thus, something is
138 * wrong if an external opcode ever gets here.
139 */
140 ACPI_ERROR ((AE_INFO, "Executed External Op"));
141 Status = AE_OK;
142 goto Cleanup;
143
144 default:
145
146 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
147 WalkState->Opcode));
148
150 goto Cleanup;
151 }
152
153
154Cleanup:
155
157}
ACPI_STATUS AcpiOsSignal(UINT32 Function, void *Info)
Definition: osl.c:904
#define ACPI_SIGNAL_FATAL
Definition: acpiosxf.h:73
#define AML_EXTERNAL_OP
Definition: amlcode.h:65
#define AML_FATAL_OP
Definition: amlcode.h:178
void Fatal(const char *filename, unsigned nLine, const char *pcLine, const char *pc, size_t errorlen, const char *format,...)
Definition: spec2def.c:844

◆ AcpiExOpcode_3A_1T_1R()

ACPI_STATUS AcpiExOpcode_3A_1T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 173 of file exoparg3.c.

175{
176 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
177 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
178 char *Buffer = NULL;
181 ACPI_SIZE Length;
182
183
184 ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R,
185 AcpiPsGetOpcodeName (WalkState->Opcode));
186
187
188 switch (WalkState->Opcode)
189 {
190 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
191 /*
192 * Create the return object. The Source operand is guaranteed to be
193 * either a String or a Buffer, so just use its type.
194 */
195 ReturnDesc = AcpiUtCreateInternalObject (
196 (Operand[0])->Common.Type);
197 if (!ReturnDesc)
198 {
200 goto Cleanup;
201 }
202
203 /* Get the Integer values from the objects */
204
205 Index = Operand[1]->Integer.Value;
206 Length = (ACPI_SIZE) Operand[2]->Integer.Value;
207
208 /*
209 * If the index is beyond the length of the String/Buffer, or if the
210 * requested length is zero, return a zero-length String/Buffer
211 */
212 if (Index >= Operand[0]->String.Length)
213 {
214 Length = 0;
215 }
216
217 /* Truncate request if larger than the actual String/Buffer */
218
219 else if ((Index + Length) > Operand[0]->String.Length)
220 {
221 Length =
222 (ACPI_SIZE) Operand[0]->String.Length - (ACPI_SIZE) Index;
223 }
224
225 /* Strings always have a sub-pointer, not so for buffers */
226
227 switch ((Operand[0])->Common.Type)
228 {
229 case ACPI_TYPE_STRING:
230
231 /* Always allocate a new buffer for the String */
232
233 Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
234 if (!Buffer)
235 {
237 goto Cleanup;
238 }
239 break;
240
241 case ACPI_TYPE_BUFFER:
242
243 /* If the requested length is zero, don't allocate a buffer */
244
245 if (Length > 0)
246 {
247 /* Allocate a new buffer for the Buffer */
248
250 if (!Buffer)
251 {
253 goto Cleanup;
254 }
255 }
256 break;
257
258 default: /* Should not happen */
259
261 goto Cleanup;
262 }
263
264 if (Buffer)
265 {
266 /* We have a buffer, copy the portion requested */
267
268 memcpy (Buffer,
269 Operand[0]->String.Pointer + Index, Length);
270 }
271
272 /* Set the length of the new String/Buffer */
273
274 ReturnDesc->String.Pointer = Buffer;
275 ReturnDesc->String.Length = (UINT32) Length;
276
277 /* Mark buffer initialized */
278
279 ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
280 break;
281
282 default:
283
284 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
285 WalkState->Opcode));
286
288 goto Cleanup;
289 }
290
291 /* Store the result in the target */
292
293 Status = AcpiExStore (ReturnDesc, Operand[3], WalkState);
294
295Cleanup:
296
297 /* Delete return object on error */
298
299 if (ACPI_FAILURE (Status) || WalkState->ResultObj)
300 {
301 AcpiUtRemoveReference (ReturnDesc);
302 WalkState->ResultObj = NULL;
303 }
304 else
305 {
306 /* Set the return object and exit */
307
308 WalkState->ResultObj = ReturnDesc;
309 }
310
312}
#define AML_MID_OP
Definition: amlcode.h:132

◆ AcpiExOpcode_6A_0T_1R()

ACPI_STATUS AcpiExOpcode_6A_0T_1R ( ACPI_WALK_STATE WalkState)

Definition at line 221 of file exoparg6.c.

223{
224 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
225 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
228 ACPI_OPERAND_OBJECT *ThisElement;
229
230
231 ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R,
232 AcpiPsGetOpcodeName (WalkState->Opcode));
233
234
235 switch (WalkState->Opcode)
236 {
237 case AML_MATCH_OP:
238 /*
239 * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2],
240 * MatchOp2[3], MatchObj2[4], StartIndex[5])
241 */
242
243 /* Validate both Match Term Operators (MTR, MEQ, etc.) */
244
245 if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
246 (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
247 {
248 ACPI_ERROR ((AE_INFO, "Match operator out of range"));
250 goto Cleanup;
251 }
252
253 /* Get the package StartIndex, validate against the package length */
254
255 Index = Operand[5]->Integer.Value;
256 if (Index >= Operand[0]->Package.Count)
257 {
259 "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
260 ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count));
262 goto Cleanup;
263 }
264
265 /* Create an integer for the return value */
266 /* Default return value is ACPI_UINT64_MAX if no match found */
267
269 if (!ReturnDesc)
270 {
272 goto Cleanup;
273
274 }
275
276 /*
277 * Examine each element until a match is found. Both match conditions
278 * must be satisfied for a match to occur. Within the loop,
279 * "continue" signifies that the current element does not match
280 * and the next should be examined.
281 *
282 * Upon finding a match, the loop will terminate via "break" at
283 * the bottom. If it terminates "normally", MatchValue will be
284 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
285 * match was found.
286 */
287 for ( ; Index < Operand[0]->Package.Count; Index++)
288 {
289 /* Get the current package element */
290
291 ThisElement = Operand[0]->Package.Elements[Index];
292
293 /* Treat any uninitialized (NULL) elements as non-matching */
294
295 if (!ThisElement)
296 {
297 continue;
298 }
299
300 /*
301 * Both match conditions must be satisfied. Execution of a continue
302 * (proceed to next iteration of enclosing for loop) signifies a
303 * non-match.
304 */
305 if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
306 ThisElement, Operand[2]))
307 {
308 continue;
309 }
310
311 if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
312 ThisElement, Operand[4]))
313 {
314 continue;
315 }
316
317 /* Match found: Index is the return value */
318
319 ReturnDesc->Integer.Value = Index;
320 break;
321 }
322 break;
323
325
326 Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
327 break;
328
329 default:
330
331 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
332 WalkState->Opcode));
333
335 goto Cleanup;
336 }
337
338
339Cleanup:
340
341 /* Delete return object on error */
342
343 if (ACPI_FAILURE (Status))
344 {
345 AcpiUtRemoveReference (ReturnDesc);
346 }
347
348 /* Save return object on success */
349
350 else
351 {
352 WalkState->ResultObj = ReturnDesc;
353 }
354
356}
#define AE_AML_OPERAND_VALUE
Definition: acexcep.h:183
#define MAX_MATCH_OPERATOR
Definition: amlcode.h:426
#define AML_LOAD_TABLE_OP
Definition: amlcode.h:164
#define AML_MATCH_OP
Definition: amlcode.h:113
ACPI_STATUS AcpiExLoadTableOp(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **ReturnDesc)
Definition: exconfig.c:129
static BOOLEAN AcpiExDoMatch(UINT32 MatchOp, ACPI_OPERAND_OBJECT *PackageObj, ACPI_OPERAND_OBJECT *MatchObj)
Definition: exoparg6.c:103

◆ AcpiExPciBarSpaceHandler()

ACPI_STATUS AcpiExPciBarSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 542 of file exregion.c.

549{
551
552
553 ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
554
555
557}

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExPciClsToString()

void AcpiExPciClsToString ( char Dest,
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().

◆ AcpiExPciConfigSpaceHandler()

ACPI_STATUS AcpiExPciConfigSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 424 of file exregion.c.

431{
433 ACPI_PCI_ID *PciId;
434 UINT16 PciRegister;
435
436
437 ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
438
439
440 /*
441 * The arguments to AcpiOs(Read|Write)PciConfiguration are:
442 *
443 * PciSegment is the PCI bus segment range 0-31
444 * PciBus is the PCI bus number range 0-255
445 * PciDevice is the PCI device number range 0-31
446 * PciFunction is the PCI device function number
447 * PciRegister is the Config space register range 0-255 bytes
448 *
449 * Value - input value for write, output address for read
450 *
451 */
452 PciId = (ACPI_PCI_ID *) RegionContext;
453 PciRegister = (UINT16) (UINT32) Address;
454
456 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) "
457 "Dev(%04x) Func(%04x) Reg(%04x)\n",
458 Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
459 PciId->Function, PciRegister));
460
461 switch (Function)
462 {
463 case ACPI_READ:
464
465 *Value = 0;
467 PciId, PciRegister, Value, BitWidth);
468 break;
469
470 case ACPI_WRITE:
471
473 PciId, PciRegister, *Value, BitWidth);
474 break;
475
476 default:
477
479 break;
480 }
481
483}
ACPI_STATUS AcpiOsWritePciConfiguration(ACPI_PCI_ID *PciId, UINT32 Reg, UINT64 Value, UINT32 Width)
Definition: osl.c:822
ACPI_STATUS AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Reg, UINT64 *Value, UINT32 Width)
Definition: osl.c:793
UINT16 Device
Definition: actypes.h:1353
UINT16 Function
Definition: actypes.h:1354
UINT16 Segment
Definition: actypes.h:1351
UINT16 Bus
Definition: actypes.h:1352

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExPrepCommonFieldObject()

ACPI_STATUS AcpiExPrepCommonFieldObject ( ACPI_OPERAND_OBJECT ObjDesc,
UINT8  FieldFlags,
UINT8  FieldAttribute,
UINT32  FieldBitPosition,
UINT32  FieldBitLength 
)

Definition at line 347 of file exprep.c.

353{
354 UINT32 AccessBitWidth;
355 UINT32 ByteAlignment;
356 UINT32 NearestByteAddress;
357
358
359 ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject);
360
361
362 /*
363 * Note: the structure being initialized is the
364 * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common
365 * area are initialized by this procedure.
366 */
367 ObjDesc->CommonField.FieldFlags = FieldFlags;
368 ObjDesc->CommonField.Attribute = FieldAttribute;
369 ObjDesc->CommonField.BitLength = FieldBitLength;
370
371 /*
372 * Decode the access type so we can compute offsets. The access type gives
373 * two pieces of information - the width of each field access and the
374 * necessary ByteAlignment (address granularity) of the access.
375 *
376 * For AnyAcc, the AccessBitWidth is the largest width that is both
377 * necessary and possible in an attempt to access the whole field in one
378 * I/O operation. However, for AnyAcc, the ByteAlignment is always one
379 * byte.
380 *
381 * For all Buffer Fields, the ByteAlignment is always one byte.
382 *
383 * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
384 * the same (equivalent) as the ByteAlignment.
385 */
386 AccessBitWidth = AcpiExDecodeFieldAccess (
387 ObjDesc, FieldFlags, &ByteAlignment);
388 if (!AccessBitWidth)
389 {
391 }
392
393 /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */
394
395 ObjDesc->CommonField.AccessByteWidth = (UINT8)
396 ACPI_DIV_8 (AccessBitWidth);
397
398 /*
399 * BaseByteOffset is the address of the start of the field within the
400 * region. It is the byte address of the first *datum* (field-width data
401 * unit) of the field. (i.e., the first datum that contains at least the
402 * first *bit* of the field.)
403 *
404 * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
405 * (Byte access), and it defines the addressing granularity of the parent
406 * region or buffer.
407 */
408 NearestByteAddress =
409 ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
410 ObjDesc->CommonField.BaseByteOffset = (UINT32)
411 ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
412
413 /*
414 * StartFieldBitOffset is the offset of the first bit of the field within
415 * a field datum.
416 */
417 ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
418 (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
419
421}
#define ACPI_ROUND_DOWN(value, boundary)
Definition: acmacros.h:239
#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a)
Definition: acmacros.h:257
static UINT32 AcpiExDecodeFieldAccess(ACPI_OPERAND_OBJECT *ObjDesc, UINT8 FieldFlags, UINT32 *ReturnByteAlignment)
Definition: exprep.c:243

Referenced by AcpiDsInitBufferField(), and AcpiExPrepFieldValue().

◆ AcpiExPrepFieldValue()

ACPI_STATUS AcpiExPrepFieldValue ( ACPI_CREATE_FIELD_INFO Info)

Definition at line 438 of file exprep.c.

440{
441 ACPI_OPERAND_OBJECT *ObjDesc;
442 ACPI_OPERAND_OBJECT *SecondDesc = NULL;
444 UINT32 AccessByteWidth;
445 UINT32 Type;
446
447
448 ACPI_FUNCTION_TRACE (ExPrepFieldValue);
449
450
451 /* Parameter validation */
452
453 if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
454 {
455 if (!Info->RegionNode)
456 {
457 ACPI_ERROR ((AE_INFO, "Null RegionNode"));
459 }
460
461 Type = AcpiNsGetType (Info->RegionNode);
462 if (Type != ACPI_TYPE_REGION)
463 {
464 ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
466
468 }
469 }
470
471 /* Allocate a new field object */
472
473 ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
474 if (!ObjDesc)
475 {
477 }
478
479 /* Initialize areas of the object that are common to all fields */
480
481 ObjDesc->CommonField.Node = Info->FieldNode;
483 Info->FieldFlags, Info->Attribute,
484 Info->FieldBitPosition, Info->FieldBitLength);
485 if (ACPI_FAILURE (Status))
486 {
487 AcpiUtDeleteObjectDesc (ObjDesc);
489 }
490
491 /* Initialize areas of the object that are specific to the field type */
492
493 switch (Info->FieldType)
494 {
496
497 ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
498
499 /* Fields specific to GenericSerialBus fields */
500
501 ObjDesc->Field.AccessLength = Info->AccessLength;
502
503 if (Info->ConnectionNode)
504 {
505 SecondDesc = Info->ConnectionNode->Object;
506 if (!(SecondDesc->Common.Flags & AOPOBJ_DATA_VALID))
507 {
508 Status = AcpiDsGetBufferArguments (SecondDesc);
509 if (ACPI_FAILURE (Status))
510 {
511 AcpiUtDeleteObjectDesc (ObjDesc);
513 }
514 }
515
516 ObjDesc->Field.ResourceBuffer =
517 SecondDesc->Buffer.Pointer;
518 ObjDesc->Field.ResourceLength =
519 (UINT16) SecondDesc->Buffer.Length;
520 }
521 else if (Info->ResourceBuffer)
522 {
523 ObjDesc->Field.ResourceBuffer = Info->ResourceBuffer;
524 ObjDesc->Field.ResourceLength = Info->ResourceLength;
525 }
526
527 ObjDesc->Field.PinNumberIndex = Info->PinNumberIndex;
528
529 /* Allow full data read from EC address space */
530
531 if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
532 (ObjDesc->CommonField.BitLength > 8))
533 {
534 AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES (
535 ObjDesc->CommonField.BitLength);
536
537 /* Maximum byte width supported is 255 */
538
539 if (AccessByteWidth < 256)
540 {
541 ObjDesc->CommonField.AccessByteWidth =
542 (UINT8) AccessByteWidth;
543 }
544 }
545
547 "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
548 ObjDesc->Field.StartFieldBitOffset,
549 ObjDesc->Field.BaseByteOffset,
550 ObjDesc->Field.AccessByteWidth,
551 ObjDesc->Field.RegionObj));
552 break;
553
555
556 ObjDesc->BankField.Value = Info->BankValue;
557 ObjDesc->BankField.RegionObj =
558 AcpiNsGetAttachedObject (Info->RegionNode);
559 ObjDesc->BankField.BankObj =
560 AcpiNsGetAttachedObject (Info->RegisterNode);
561
562 /* An additional reference for the attached objects */
563
566
568 "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
569 ObjDesc->BankField.StartFieldBitOffset,
570 ObjDesc->BankField.BaseByteOffset,
571 ObjDesc->Field.AccessByteWidth,
572 ObjDesc->BankField.RegionObj,
573 ObjDesc->BankField.BankObj));
574
575 /*
576 * Remember location in AML stream of the field unit
577 * opcode and operands -- since the BankValue
578 * operands must be evaluated.
579 */
580 SecondDesc = ObjDesc->Common.NextObject;
582 Info->DataRegisterNode)->Named.Data;
584 Info->DataRegisterNode)->Named.Length;
585
586 break;
587
589
590 /* Get the Index and Data registers */
591
592 ObjDesc->IndexField.IndexObj =
593 AcpiNsGetAttachedObject (Info->RegisterNode);
594 ObjDesc->IndexField.DataObj =
595 AcpiNsGetAttachedObject (Info->DataRegisterNode);
596
597 if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
598 {
599 ACPI_ERROR ((AE_INFO, "Null Index Object during field prep"));
600 AcpiUtDeleteObjectDesc (ObjDesc);
602 }
603
604 /* An additional reference for the attached objects */
605
608
609 /*
610 * April 2006: Changed to match MS behavior
611 *
612 * The value written to the Index register is the byte offset of the
613 * target field in units of the granularity of the IndexField
614 *
615 * Previously, the value was calculated as an index in terms of the
616 * width of the Data register, as below:
617 *
618 * ObjDesc->IndexField.Value = (UINT32)
619 * (Info->FieldBitPosition / ACPI_MUL_8 (
620 * ObjDesc->Field.AccessByteWidth));
621 *
622 * February 2006: Tried value as a byte offset:
623 * ObjDesc->IndexField.Value = (UINT32)
624 * ACPI_DIV_8 (Info->FieldBitPosition);
625 */
626 ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN (
627 ACPI_DIV_8 (Info->FieldBitPosition),
628 ObjDesc->IndexField.AccessByteWidth);
629
631 "IndexField: BitOff %X, Off %X, Value %X, "
632 "Gran %X, Index %p, Data %p\n",
633 ObjDesc->IndexField.StartFieldBitOffset,
634 ObjDesc->IndexField.BaseByteOffset,
635 ObjDesc->IndexField.Value,
636 ObjDesc->Field.AccessByteWidth,
637 ObjDesc->IndexField.IndexObj,
638 ObjDesc->IndexField.DataObj));
639 break;
640
641 default:
642
643 /* No other types should get here */
644
645 break;
646 }
647
648 /*
649 * Store the constructed descriptor (ObjDesc) into the parent Node,
650 * preserving the current type of that NamedObj.
651 */
653 Info->FieldNode, ObjDesc, AcpiNsGetType (Info->FieldNode));
654
656 "Set NamedObj %p [%4.4s], ObjDesc %p\n",
657 Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
658
659 /* Remove local reference to the object */
660
661 AcpiUtRemoveReference (ObjDesc);
663}
#define AE_AML_NO_OPERAND
Definition: acexcep.h:181
ACPI_OBJECT_TYPE AcpiNsGetType(ACPI_NAMESPACE_NODE *Node)
Definition: nsutils.c:120
#define ACPI_ADR_SPACE_EC
Definition: actypes.h:864
void AcpiUtDeleteObjectDesc(ACPI_OPERAND_OBJECT *Object)
Definition: utobject.c:473
ACPI_STATUS AcpiExPrepCommonFieldObject(ACPI_OPERAND_OBJECT *ObjDesc, UINT8 FieldFlags, UINT8 FieldAttribute, UINT32 FieldBitPosition, UINT32 FieldBitLength)
Definition: exprep.c:347
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object * RegionObj
Definition: acobject.h:358
union acpi_operand_object * BankObj
Definition: acobject.h:359
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object * IndexObj
Definition: acobject.h:373
union acpi_operand_object * DataObj
Definition: acobject.h:374
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO UINT16 ResourceLength
Definition: acobject.h:345
union acpi_operand_object * RegionObj
Definition: acobject.h:346
ACPI_OBJECT_REGION_FIELD Field
Definition: acobject.h:534
ACPI_OBJECT_BANK_FIELD BankField
Definition: acobject.h:536
ACPI_OBJECT_INDEX_FIELD IndexField
Definition: acobject.h:537
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by AcpiDsGetFieldNames().

◆ AcpiExReadDataFromField()

ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  RetBufferDesc 
)

Definition at line 147 of file exfield.c.

151{
153 ACPI_OPERAND_OBJECT *BufferDesc;
154 void *Buffer;
156
157
158 ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc);
159
160
161 /* Parameter validation */
162
163 if (!ObjDesc)
164 {
166 }
167 if (!RetBufferDesc)
168 {
170 }
171
172 if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
173 {
174 /*
175 * If the BufferField arguments have not been previously evaluated,
176 * evaluate them now and save the results.
177 */
178 if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
179 {
181 if (ACPI_FAILURE (Status))
182 {
184 }
185 }
186 }
187 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
193 {
194 /* SMBus, GSBus, IPMI serial */
195
196 Status = AcpiExReadSerialBus (ObjDesc, RetBufferDesc);
198 }
199
200 /*
201 * Allocate a buffer for the contents of the field.
202 *
203 * If the field is larger than the current integer width, create
204 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
205 * the use of arithmetic operators on the returned value if the
206 * field size is equal or smaller than an Integer.
207 *
208 * However, all buffer fields created by CreateField operator needs to
209 * remain as a buffer to match other AML interpreter implementations.
210 *
211 * Note: Field.length is in bits.
212 */
214 ObjDesc->Field.BitLength);
215
216 if (BufferLength > AcpiGbl_IntegerByteWidth ||
217 (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD &&
218 ObjDesc->BufferField.IsCreateField))
219 {
220 /* Field is too large for an Integer, create a Buffer instead */
221
223 if (!BufferDesc)
224 {
226 }
227 Buffer = BufferDesc->Buffer.Pointer;
228 }
229 else
230 {
231 /* Field will fit within an Integer (normal case) */
232
233 BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
234 if (!BufferDesc)
235 {
237 }
238
239 BufferLength = AcpiGbl_IntegerByteWidth;
240 Buffer = &BufferDesc->Integer.Value;
241 }
242
243 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
245 {
246 /* General Purpose I/O */
247
248 Status = AcpiExReadGpio (ObjDesc, Buffer);
249 goto Exit;
250 }
251 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
253 {
254 /*
255 * Reading from a PCC field unit does not require the handler because
256 * it only requires reading from the InternalPccBuffer.
257 */
259 "PCC FieldRead bits %u\n", ObjDesc->Field.BitLength));
260
262 ObjDesc->Field.BaseByteOffset, (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (
263 ObjDesc->Field.BitLength));
264
265 *RetBufferDesc = BufferDesc;
266 return AE_OK;
267 }
268
270 "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
271 ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength));
273 "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
274 ObjDesc->CommonField.BitLength,
275 ObjDesc->CommonField.StartFieldBitOffset,
276 ObjDesc->CommonField.BaseByteOffset));
277
278 /* Lock entire transaction if requested */
279
280 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
281
282 /* Read from the field */
283
285 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
286
287
288Exit:
289 if (ACPI_FAILURE (Status))
290 {
291 AcpiUtRemoveReference (BufferDesc);
292 }
293 else
294 {
295 *RetBufferDesc = BufferDesc;
296 }
297
299}
#define ACPI_ADR_SPACE_IPMI
Definition: actypes.h:868
#define ACPI_ADR_SPACE_PLATFORM_RT
Definition: actypes.h:872
#define ACPI_ADR_SPACE_PLATFORM_COMM
Definition: actypes.h:871
#define ACPI_ADR_SPACE_GSBUS
Definition: actypes.h:870
#define ACPI_ADR_SPACE_SMBUS
Definition: actypes.h:865
#define ACPI_ADR_SPACE_FIXED_HARDWARE
Definition: actypes.h:885
#define ACPI_ADR_SPACE_GPIO
Definition: actypes.h:869
ACPI_STATUS AcpiDsGetBufferFieldArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:196
ACPI_STATUS AcpiExExtractFromField(ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer, UINT32 BufferLength)
Definition: exfldio.c:723
ACPI_STATUS AcpiExReadSerialBus(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
Definition: exserial.c:182
ACPI_STATUS AcpiExReadGpio(ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer)
Definition: exserial.c:70
void AcpiExAcquireGlobalLock(UINT32 FieldFlags)
Definition: exutils.c:225
void AcpiExReleaseGlobalLock(UINT32 FieldFlags)
Definition: exutils.c:270
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO BOOLEAN IsCreateField
Definition: acobject.h:385
ACPI_OBJECT_BUFFER_FIELD BufferField
Definition: acobject.h:535

Referenced by AcpiExOpcode_1A_0T_1R(), AcpiExResolveNodeToValue(), and AcpiExResolveObjectToValue().

◆ AcpiExReadGpio()

ACPI_STATUS AcpiExReadGpio ( ACPI_OPERAND_OBJECT ObjDesc,
void Buffer 
)

Definition at line 70 of file exserial.c.

73{
75
76
77 ACPI_FUNCTION_TRACE_PTR (ExReadGpio, ObjDesc);
78
79
80 /*
81 * For GPIO (GeneralPurposeIo), the Address will be the bit offset
82 * from the previous Connection() operator, making it effectively a
83 * pin number index. The BitLength is the length of the field, which
84 * is thus the number of pins.
85 */
87 "GPIO FieldRead [FROM]: Pin %u Bits %u\n",
88 ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength));
89
90 /* Lock entire transaction if requested */
91
92 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
93
94 /* Perform the read */
95
97 ObjDesc, 0, (UINT64 *) Buffer, ACPI_READ);
98
99 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
101}
ACPI_STATUS AcpiExAccessRegion(ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, UINT64 *Value, UINT32 Function)
Definition: exfldio.c:249

Referenced by AcpiExReadDataFromField().

◆ AcpiExReadSerialBus()

ACPI_STATUS AcpiExReadSerialBus ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ReturnBuffer 
)

Definition at line 182 of file exserial.c.

185{
188 ACPI_OPERAND_OBJECT *BufferDesc;
190 UINT16 AccessorType;
191
192
193 ACPI_FUNCTION_TRACE_PTR (ExReadSerialBus, ObjDesc);
194
195
196 /*
197 * This is an SMBus, GSBus or IPMI read. We must create a buffer to
198 * hold the data and then directly access the region handler.
199 *
200 * Note: SMBus and GSBus protocol value is passed in upper 16-bits
201 * of Function
202 *
203 * Common buffer format:
204 * Status; (Byte 0 of the data buffer)
205 * Length; (Byte 1 of the data buffer)
206 * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer)
207 */
208 switch (ObjDesc->Field.RegionObj->Region.SpaceId)
209 {
211
213 Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
214 break;
215
217
220 break;
221
223
224 AccessorType = ObjDesc->Field.Attribute;
225 if (AccessorType == AML_FIELD_ATTRIB_RAW_PROCESS_BYTES)
226 {
228 "Invalid direct read using bidirectional write-then-read protocol"));
229
231 }
232
234 if (ACPI_FAILURE (Status))
235 {
237 "Invalid protocol ID for GSBus: 0x%4.4X", AccessorType));
238
240 }
241
242 /* Add header length to get the full size of the buffer */
243
245 Function = ACPI_READ | (AccessorType << 16);
246 break;
247
249
252 break;
253
254 default:
256 }
257
258 /* Create the local transfer buffer that is returned to the caller */
259
261 if (!BufferDesc)
262 {
264 }
265
266 /* Lock entire transaction if requested */
267
268 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
269
270 /* Call the region handler for the write-then-read */
271
272 Status = AcpiExAccessRegion (ObjDesc, 0,
273 ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer), Function);
274 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
275
276 *ReturnBuffer = BufferDesc;
278}
#define AE_AML_INVALID_SPACE_ID
Definition: acexcep.h:195
@ AML_FIELD_ATTRIB_RAW_PROCESS_BYTES
Definition: amlcode.h:498
#define ACPI_IPMI_BUFFER_SIZE
Definition: acconfig.h:223
#define ACPI_SMBUS_BUFFER_SIZE
Definition: acconfig.h:220
#define ACPI_SERIAL_HEADER_SIZE
Definition: acconfig.h:217
#define ACPI_PRM_INPUT_BUFFER_SIZE
Definition: acconfig.h:228
ACPI_STATUS AcpiExGetProtocolBufferLength(UINT32 ProtocolId, UINT32 *ReturnLength)
Definition: exfield.c:111

Referenced by AcpiExReadDataFromField().

◆ AcpiExReleaseAllMutexes()

void AcpiExReleaseAllMutexes ( ACPI_THREAD_STATE Thread)

Definition at line 536 of file exmutex.c.

538{
539 ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList;
540 ACPI_OPERAND_OBJECT *ObjDesc;
541
542
543 ACPI_FUNCTION_TRACE (ExReleaseAllMutexes);
544
545
546 /* Traverse the list of owned mutexes, releasing each one */
547
548 while (Next)
549 {
550 ObjDesc = Next;
552 "Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n",
553 ObjDesc->Mutex.Node->Name.Ascii, ObjDesc->Mutex.SyncLevel,
554 ObjDesc->Mutex.AcquisitionDepth));
555
556 /* Release the mutex, special case for Global Lock */
557
558 if (ObjDesc == AcpiGbl_GlobalLockMutex)
559 {
560 /* Ignore errors */
561
563 }
564 else
565 {
567 }
568
569 /* Update Thread SyncLevel (Last mutex is the important one) */
570
571 Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;
572
573 /* Mark mutex unowned */
574
575 Next = ObjDesc->Mutex.Next;
576
577 ObjDesc->Mutex.Prev = NULL;
578 ObjDesc->Mutex.Next = NULL;
579 ObjDesc->Mutex.AcquisitionDepth = 0;
580 ObjDesc->Mutex.OwnerThread = NULL;
581 ObjDesc->Mutex.ThreadId = 0;
582 }
583
585}
#define AcpiOsReleaseMutex(Handle)
Definition: actypes.h:277
ACPI_STATUS AcpiEvReleaseGlobalLock(void)
Definition: evglock.c:333
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
union acpi_operand_object * Next
Definition: acobject.h:192
union acpi_operand_object * Prev
Definition: acobject.h:191

Referenced by AcpiPsParseAml().

◆ AcpiExReleaseGlobalLock()

void AcpiExReleaseGlobalLock ( UINT32  Rule)

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().

◆ AcpiExReleaseMutex()

ACPI_STATUS AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT ObjDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 408 of file exmutex.c.

411{
412 UINT8 PreviousSyncLevel;
413 ACPI_THREAD_STATE *OwnerThread;
415
416
417 ACPI_FUNCTION_TRACE (ExReleaseMutex);
418
419
420 if (!ObjDesc)
421 {
423 }
424
425 OwnerThread = ObjDesc->Mutex.OwnerThread;
426
427 /* The mutex must have been previously acquired in order to release it */
428
429 if (!OwnerThread)
430 {
432 "Cannot release Mutex [%4.4s], not acquired",
433 AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
435 }
436
437 /* Must have a valid thread ID */
438
439 if (!WalkState->Thread)
440 {
442 "Cannot release Mutex [%4.4s], null thread info",
443 AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
445 }
446
447 /*
448 * The Mutex is owned, but this thread must be the owner.
449 * Special case for Global Lock, any thread can release
450 */
451 if ((OwnerThread->ThreadId != WalkState->Thread->ThreadId) &&
452 (ObjDesc != AcpiGbl_GlobalLockMutex))
453 {
455 "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
456 (UINT32) WalkState->Thread->ThreadId,
457 AcpiUtGetNodeName (ObjDesc->Mutex.Node),
458 (UINT32) OwnerThread->ThreadId));
460 }
461
462 /*
463 * The sync level of the mutex must be equal to the current sync level. In
464 * other words, the current level means that at least one mutex at that
465 * level is currently being held. Attempting to release a mutex of a
466 * different level can only mean that the mutex ordering rule is being
467 * violated. This behavior is clarified in ACPI 4.0 specification.
468 */
469 if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel)
470 {
472 "Cannot release Mutex [%4.4s], SyncLevel mismatch: "
473 "mutex %u current %u",
474 AcpiUtGetNodeName (ObjDesc->Mutex.Node),
475 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel));
477 }
478
479 /*
480 * Get the previous SyncLevel from the head of the acquired mutex list.
481 * This handles the case where several mutexes at the same level have been
482 * acquired, but are not released in reverse order.
483 */
484 PreviousSyncLevel =
486
488 "Releasing: Object SyncLevel %u, Thread SyncLevel %u, "
489 "Prev SyncLevel %u, Depth %u TID %p\n",
490 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
491 PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth,
492 WalkState->Thread));
493
495 if (ACPI_FAILURE (Status))
496 {
498 }
499
500 if (ObjDesc->Mutex.AcquisitionDepth == 0)
501 {
502 /* Restore the previous SyncLevel */
503
504 OwnerThread->CurrentSyncLevel = PreviousSyncLevel;
505 }
506
508 "Released: Object SyncLevel %u, Thread SyncLevel, %u, "
509 "Prev SyncLevel %u, Depth %u\n",
510 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
511 PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth));
512
514}
#define AE_AML_NOT_OWNER
Definition: acexcep.h:199
#define AE_AML_MUTEX_NOT_ACQUIRED
Definition: acexcep.h:201
union acpi_operand_object * AcquiredMutexList
Definition: aclocal.h:766

Referenced by AcpiExOpcode_1A_0T_0R().

◆ AcpiExReleaseMutexObject()

ACPI_STATUS AcpiExReleaseMutexObject ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 344 of file exmutex.c.

346{
348
349
350 ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
351
352
353 if (ObjDesc->Mutex.AcquisitionDepth == 0)
354 {
356 }
357
358 /* Match multiple Acquires with multiple Releases */
359
360 ObjDesc->Mutex.AcquisitionDepth--;
361 if (ObjDesc->Mutex.AcquisitionDepth != 0)
362 {
363 /* Just decrement the depth and return */
364
366 }
367
368 if (ObjDesc->Mutex.OwnerThread)
369 {
370 /* Unlink the mutex from the owner's list */
371
372 AcpiExUnlinkMutex (ObjDesc);
373 ObjDesc->Mutex.OwnerThread = NULL;
374 }
375
376 /* Release the mutex, special case for Global Lock */
377
378 if (ObjDesc == AcpiGbl_GlobalLockMutex)
379 {
381 }
382 else
383 {
385 }
386
387 /* Clear mutex info */
388
389 ObjDesc->Mutex.ThreadId = 0;
391}
#define AE_NOT_ACQUIRED
Definition: acexcep.h:128
void AcpiExUnlinkMutex(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exmutex.c:73

Referenced by AcpiExReleaseGlobalLock(), AcpiExReleaseMutex(), and AcpiReleaseGlobalLock().

◆ AcpiExResolveMultiple()

ACPI_STATUS AcpiExResolveMultiple ( ACPI_WALK_STATE WalkState,
ACPI_OPERAND_OBJECT Operand,
ACPI_OBJECT_TYPE ReturnType,
ACPI_OPERAND_OBJECT **  ReturnDesc 
)

Definition at line 350 of file exresolv.c.

355{
356 ACPI_OPERAND_OBJECT *ObjDesc = ACPI_CAST_PTR (void, Operand);
360
361
363
364
365 /* Operand can be either a namespace node or an operand descriptor */
366
367 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
368 {
370
371 Type = ObjDesc->Common.Type;
372 break;
373
375
376 Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
377 ObjDesc = AcpiNsGetAttachedObject (Node);
378
379 /* If we had an Alias node, use the attached object for type info */
380
382 {
383 Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
384 ObjDesc = AcpiNsGetAttachedObject (
385 (ACPI_NAMESPACE_NODE *) ObjDesc);
386 }
387
388 switch (Type)
389 {
390 case ACPI_TYPE_DEVICE:
392
393 /* These types have no attached subobject */
394 break;
395
396 default:
397
398 /* All other types require a subobject */
399
400 if (!ObjDesc)
401 {
403 "[%4.4s] Node is unresolved or uninitialized",
406 }
407 break;
408 }
409 break;
410
411 default:
413 }
414
415 /* If type is anything other than a reference, we are done */
416
418 {
419 goto Exit;
420 }
421
422 /*
423 * For reference objects created via the RefOf, Index, or Load/LoadTable
424 * operators, we need to get to the base object (as per the ACPI
425 * specification of the ObjectType and SizeOf operators). This means
426 * traversing the list of possibly many nested references.
427 */
428 while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
429 {
430 switch (ObjDesc->Reference.Class)
431 {
434
435 /* Dereference the reference pointer */
436
437 if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
438 {
439 Node = ObjDesc->Reference.Object;
440 }
441 else /* AML_INT_NAMEPATH_OP */
442 {
443 Node = ObjDesc->Reference.Node;
444 }
445
446 /* All "References" point to a NS node */
447
449 {
451 "Not a namespace node %p [%s]",
454 }
455
456 /* Get the attached object */
457
458 ObjDesc = AcpiNsGetAttachedObject (Node);
459 if (!ObjDesc)
460 {
461 /* No object, use the NS node type */
462
464 goto Exit;
465 }
466
467 /* Check for circular references */
468
469 if (ObjDesc == Operand)
470 {
472 }
473 break;
474
476
477 /* Get the type of this reference (index into another object) */
478
479 Type = ObjDesc->Reference.TargetType;
480 if (Type != ACPI_TYPE_PACKAGE)
481 {
482 goto Exit;
483 }
484
485 /*
486 * The main object is a package, we want to get the type
487 * of the individual package element that is referenced by
488 * the index.
489 *
490 * This could of course in turn be another reference object.
491 */
492 ObjDesc = *(ObjDesc->Reference.Where);
493 if (!ObjDesc)
494 {
495 /* NULL package elements are allowed */
496
497 Type = 0; /* Uninitialized */
498 goto Exit;
499 }
500 break;
501
503
505 goto Exit;
506
509
510 if (ReturnDesc)
511 {
513 ObjDesc->Reference.Value, WalkState, &ObjDesc);
514 if (ACPI_FAILURE (Status))
515 {
517 }
518 AcpiUtRemoveReference (ObjDesc);
519 }
520 else
521 {
523 ObjDesc->Reference.Value, WalkState, &Node);
524 if (ACPI_FAILURE (Status))
525 {
527 }
528
529 ObjDesc = AcpiNsGetAttachedObject (Node);
530 if (!ObjDesc)
531 {
533 goto Exit;
534 }
535 }
536 break;
537
539
540 /* The Debug Object is of type "DebugObject" */
541
543 goto Exit;
544
545 default:
546
548 "Unknown Reference Class 0x%2.2X",
549 ObjDesc->Reference.Class));
551 }
552 }
553
554 /*
555 * Now we are guaranteed to have an object that has not been created
556 * via the RefOf or Index operators.
557 */
558 Type = ObjDesc->Common.Type;
559
560
561Exit:
562 /* Convert internal types to external types */
563
564 switch (Type)
565 {
569
571 break;
572
574
575 /* Per ACPI Specification, Scope is untyped */
576
578 break;
579
580 default:
581
582 /* No change to Type required */
583
584 break;
585 }
586
587 *ReturnType = Type;
588 if (ReturnDesc)
589 {
590 *ReturnDesc = ObjDesc;
591 }
593}
#define AE_AML_CIRCULAR_REFERENCE
Definition: acexcep.h:209
#define AE_AML_UNINITIALIZED_NODE
Definition: acexcep.h:213
@ ACPI_REFCLASS_NAME
Definition: acobject.h:464
#define ACPI_TYPE_FIELD_UNIT
Definition: actypes.h:692
#define ACPI_TYPE_ANY
Definition: actypes.h:687
#define ACPI_TYPE_DEBUG_OBJECT
Definition: actypes.h:703
#define ACPI_TYPE_DDB_HANDLE
Definition: actypes.h:702
#define ACPI_TYPE_LOCAL_SCOPE
Definition: actypes.h:726
const char * AcpiUtGetDescriptorName(void *Object)
Definition: utdecode.c:382
ACPI_STATUS AcpiDsMethodDataGetNode(UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node)
Definition: dsmthdat.c:275

Referenced by AcpiExOpcode_1A_0T_1R(), and AcpiExResolveMultiple().

◆ AcpiExResolveNodeToValue()

ACPI_STATUS AcpiExResolveNodeToValue ( ACPI_NAMESPACE_NODE **  StackPtr,
ACPI_WALK_STATE WalkState 
)

Definition at line 82 of file exresnte.c.

86{
88 ACPI_OPERAND_OBJECT *SourceDesc;
89 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
91 ACPI_OBJECT_TYPE EntryType;
92
93
94 ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
95
96
97 /*
98 * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
99 * object that is attached to the Node.
100 */
101 Node = *ObjectPtr;
102 SourceDesc = AcpiNsGetAttachedObject (Node);
103 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
104
105 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
106 Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
107
108 if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
109 (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
110 {
111 /* There is always exactly one level of indirection */
112
114 SourceDesc = AcpiNsGetAttachedObject (Node);
115 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
116 *ObjectPtr = Node;
117 }
118
119 /*
120 * Several object types require no further processing:
121 * 1) Device/Thermal objects don't have a "real" subobject, return Node
122 * 2) Method locals and arguments have a pseudo-Node
123 * 3) 10/2007: Added method type to assist with Package construction.
124 */
125 if ((EntryType == ACPI_TYPE_DEVICE) ||
126 (EntryType == ACPI_TYPE_THERMAL) ||
127 (EntryType == ACPI_TYPE_METHOD) ||
129 {
131 }
132
133 if (!SourceDesc)
134 {
135 ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p",
136 Node->Name.Ascii, Node));
138 }
139
140 /*
141 * Action is based on the type of the Node, which indicates the type
142 * of the attached object or pointer
143 */
144 switch (EntryType)
145 {
147
148 if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
149 {
150 ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
151 AcpiUtGetObjectTypeName (SourceDesc)));
153 }
154
155 Status = AcpiDsGetPackageArguments (SourceDesc);
156 if (ACPI_SUCCESS (Status))
157 {
158 /* Return an additional reference to the object */
159
160 ObjDesc = SourceDesc;
161 AcpiUtAddReference (ObjDesc);
162 }
163 break;
164
165 case ACPI_TYPE_BUFFER:
166
167 if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
168 {
169 ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
170 AcpiUtGetObjectTypeName (SourceDesc)));
172 }
173
174 Status = AcpiDsGetBufferArguments (SourceDesc);
175 if (ACPI_SUCCESS (Status))
176 {
177 /* Return an additional reference to the object */
178
179 ObjDesc = SourceDesc;
180 AcpiUtAddReference (ObjDesc);
181 }
182 break;
183
184 case ACPI_TYPE_STRING:
185
186 if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
187 {
188 ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
189 AcpiUtGetObjectTypeName (SourceDesc)));
191 }
192
193 /* Return an additional reference to the object */
194
195 ObjDesc = SourceDesc;
196 AcpiUtAddReference (ObjDesc);
197 break;
198
200
201 if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
202 {
203 ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
204 AcpiUtGetObjectTypeName (SourceDesc)));
206 }
207
208 /* Return an additional reference to the object */
209
210 ObjDesc = SourceDesc;
211 AcpiUtAddReference (ObjDesc);
212 break;
213
218
220 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
221 Node, SourceDesc, EntryType));
222
223 Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
224 break;
225
226 /* For these objects, just return the object attached to the Node */
227
228 case ACPI_TYPE_MUTEX:
229 case ACPI_TYPE_POWER:
231 case ACPI_TYPE_EVENT:
232 case ACPI_TYPE_REGION:
233
234 /* Return an additional reference to the object */
235
236 ObjDesc = SourceDesc;
237 AcpiUtAddReference (ObjDesc);
238 break;
239
240 /* TYPE_ANY is untyped, and thus there is no object associated with it */
241
242 case ACPI_TYPE_ANY:
243
245 "Untyped entry %p, no attached object!", Node));
246
247 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
248
250
251 switch (SourceDesc->Reference.Class)
252 {
253 case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
256
257 /* Return an additional reference to the object */
258
259 ObjDesc = SourceDesc;
260 AcpiUtAddReference (ObjDesc);
261 break;
262
263 default:
264
265 /* No named references are allowed here */
266
268 "Unsupported Reference type 0x%X",
269 SourceDesc->Reference.Class));
270
272 }
273 break;
274
275 default:
276
277 /* Default case is for unknown types */
278
280 "Node %p - Unknown object type 0x%X",
281 Node, EntryType));
282
284
285 } /* switch (EntryType) */
286
287
288 /* Return the object descriptor */
289
290 *ObjectPtr = (void *) ObjDesc;
292}
#define ANOBJ_METHOD_ARG
Definition: aclocal.h:217
#define ANOBJ_METHOD_LOCAL
Definition: aclocal.h:218

Referenced by AcpiDsResolvePackageElement(), AcpiExOpcode_1A_0T_1R(), AcpiExResolveToValue(), and AcpiNsEvaluate().

◆ AcpiExResolveObject()

ACPI_STATUS AcpiExResolveObject ( ACPI_OPERAND_OBJECT **  SourceDescPtr,
ACPI_OBJECT_TYPE  TargetType,
ACPI_WALK_STATE WalkState 
)

Definition at line 71 of file exstoren.c.

75{
76 ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr;
78
79
80 ACPI_FUNCTION_TRACE (ExResolveObject);
81
82
83 /* Ensure we have a Target that can be stored to */
84
85 switch (TargetType)
86 {
91 /*
92 * These cases all require only Integers or values that
93 * can be converted to Integers (Strings or Buffers)
94 */
98 /*
99 * Stores into a Field/Region or into a Integer/Buffer/String
100 * are all essentially the same. This case handles the
101 * "interchangeable" types Integer, String, and Buffer.
102 */
103 if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
104 {
105 /* Resolve a reference object first */
106
107 Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
108 if (ACPI_FAILURE (Status))
109 {
110 break;
111 }
112 }
113
114 /* For CopyObject, no further validation necessary */
115
116 if (WalkState->Opcode == AML_COPY_OBJECT_OP)
117 {
118 break;
119 }
120
121 /* Must have a Integer, Buffer, or String */
122
123 if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
124 (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) &&
125 (SourceDesc->Common.Type != ACPI_TYPE_STRING) &&
126 !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
127 (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
128 {
129 /* Conversion successful but still not a valid type */
130
132 "Cannot assign type [%s] to [%s] (must be type Int/Str/Buf)",
133 AcpiUtGetObjectTypeName (SourceDesc),
134 AcpiUtGetTypeName (TargetType)));
135
137 }
138 break;
139
142 /*
143 * All aliases should have been resolved earlier, during the
144 * operand resolution phase.
145 */
146 ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
148 break;
149
151 default:
152 /*
153 * All other types than Alias and the various Fields come here,
154 * including the untyped case - ACPI_TYPE_ANY.
155 */
156 break;
157 }
158
160}
ACPI_STATUS AcpiExResolveToValue(ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
Definition: exresolv.c:79

Referenced by AcpiExStoreObjectToNode().

◆ AcpiExResolveOperands()

ACPI_STATUS AcpiExResolveOperands ( UINT16  Opcode,
ACPI_OPERAND_OBJECT **  StackPtr,
ACPI_WALK_STATE WalkState 
)

Definition at line 145 of file exresop.c.

149{
150 ACPI_OPERAND_OBJECT *ObjDesc;
153 UINT32 ArgTypes;
154 const ACPI_OPCODE_INFO *OpInfo;
155 UINT32 ThisArgType;
156 ACPI_OBJECT_TYPE TypeNeeded;
157 UINT16 TargetOp = 0;
158
159
160 ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode);
161
162
163 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
164 if (OpInfo->Class == AML_CLASS_UNKNOWN)
165 {
167 }
168
169 ArgTypes = OpInfo->RuntimeArgs;
170 if (ArgTypes == ARGI_INVALID_OPCODE)
171 {
172 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
173 Opcode));
174
176 }
177
179 "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
180 Opcode, OpInfo->Name, ArgTypes));
181
182 /*
183 * Normal exit is with (ArgTypes == 0) at end of argument list.
184 * Function will return an exception from within the loop upon
185 * finding an entry which is not (or cannot be converted
186 * to) the required type; if stack underflows; or upon
187 * finding a NULL stack entry (which should not happen).
188 */
189 while (GET_CURRENT_ARG_TYPE (ArgTypes))
190 {
191 if (!StackPtr || !*StackPtr)
192 {
193 ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
194 StackPtr));
195
197 }
198
199 /* Extract useful items */
200
201 ObjDesc = *StackPtr;
202
203 /* Decode the descriptor type */
204
205 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
206 {
208
209 /* Namespace Node */
210
211 ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
212
213 /*
214 * Resolve an alias object. The construction of these objects
215 * guarantees that there is only one level of alias indirection;
216 * thus, the attached object is always the aliased namespace node
217 */
219 {
220 ObjDesc = AcpiNsGetAttachedObject (
221 (ACPI_NAMESPACE_NODE *) ObjDesc);
222 *StackPtr = ObjDesc;
223 ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
224 }
225 break;
226
228
229 /* ACPI internal object */
230
231 ObjectType = ObjDesc->Common.Type;
232
233 /* Check for bad ACPI_OBJECT_TYPE */
234
236 {
238 "Bad operand object type [0x%X]", ObjectType));
239
241 }
242
244 {
245 /* Validate the Reference */
246
247 switch (ObjDesc->Reference.Class)
248 {
250
251 TargetOp = AML_DEBUG_OP;
252
254
259 case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
260 case ACPI_REFCLASS_NAME: /* Reference to a named object */
261
263 "Operand is a Reference, Class [%s] %2.2X\n",
264 AcpiUtGetReferenceName (ObjDesc),
265 ObjDesc->Reference.Class));
266 break;
267
268 default:
269
271 "Unknown Reference Class 0x%2.2X in %p",
272 ObjDesc->Reference.Class, ObjDesc));
273
275 }
276 }
277 break;
278
279 default:
280
281 /* Invalid descriptor */
282
283 ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]",
284 ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
285
287 }
288
289 /* Get one argument type, point to the next */
290
291 ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
292 INCREMENT_ARG_LIST (ArgTypes);
293
294 /*
295 * Handle cases where the object does not need to be
296 * resolved to a value
297 */
298 switch (ThisArgType)
299 {
300 case ARGI_REF_OR_STRING: /* Can be a String or Reference */
301
302 if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) ==
304 (ObjDesc->Common.Type == ACPI_TYPE_STRING))
305 {
306 /*
307 * String found - the string references a named object and
308 * must be resolved to a node
309 */
310 goto NextOperand;
311 }
312
313 /*
314 * Else not a string - fall through to the normal Reference
315 * case below
316 */
318
319 case ARGI_REFERENCE: /* References: */
320 case ARGI_INTEGER_REF:
321 case ARGI_OBJECT_REF:
322 case ARGI_DEVICE_REF:
323 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
324 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
325 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
327
328 /*
329 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
330 * A Namespace Node is OK as-is
331 */
333 {
334 goto NextOperand;
335 }
336
339 if (ACPI_FAILURE (Status))
340 {
342 }
343 goto NextOperand;
344
345 case ARGI_DATAREFOBJ: /* Store operator only */
346 /*
347 * We don't want to resolve IndexOp reference objects during
348 * a store because this would be an implicit DeRefOf operation.
349 * Instead, we just want to store the reference object.
350 * -- All others must be resolved below.
351 */
352 if ((Opcode == AML_STORE_OP) &&
353 ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
354 ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
355 {
356 goto NextOperand;
357 }
358 break;
359
360 default:
361
362 /* All cases covered above */
363
364 break;
365 }
366
367 /*
368 * Resolve this object to a value
369 */
370 Status = AcpiExResolveToValue (StackPtr, WalkState);
371 if (ACPI_FAILURE (Status))
372 {
374 }
375
376 /* Get the resolved object */
377
378 ObjDesc = *StackPtr;
379
380 /*
381 * Check the resulting object (value) type
382 */
383 switch (ThisArgType)
384 {
385 /*
386 * For the simple cases, only one type of resolved object
387 * is allowed
388 */
389 case ARGI_MUTEX:
390
391 /* Need an operand of type ACPI_TYPE_MUTEX */
392
393 TypeNeeded = ACPI_TYPE_MUTEX;
394 break;
395
396 case ARGI_EVENT:
397
398 /* Need an operand of type ACPI_TYPE_EVENT */
399
400 TypeNeeded = ACPI_TYPE_EVENT;
401 break;
402
403 case ARGI_PACKAGE: /* Package */
404
405 /* Need an operand of type ACPI_TYPE_PACKAGE */
406
407 TypeNeeded = ACPI_TYPE_PACKAGE;
408 break;
409
410 case ARGI_ANYTYPE:
411
412 /* Any operand type will do */
413
414 TypeNeeded = ACPI_TYPE_ANY;
415 break;
416
417 case ARGI_DDBHANDLE:
418
419 /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
420
421 TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
422 break;
423
424
425 /*
426 * The more complex cases allow multiple resolved object types
427 */
428 case ARGI_INTEGER:
429
430 /*
431 * Need an operand of type ACPI_TYPE_INTEGER, but we can
432 * implicitly convert from a STRING or BUFFER.
433 *
434 * Known as "Implicit Source Operand Conversion"
435 */
436 Status = AcpiExConvertToInteger (ObjDesc, StackPtr,
438 if (ACPI_FAILURE (Status))
439 {
440 if (Status == AE_TYPE)
441 {
443 "Needed [Integer/String/Buffer], found [%s] %p",
444 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
445
447 }
448
450 }
451
452 if (ObjDesc != *StackPtr)
453 {
454 AcpiUtRemoveReference (ObjDesc);
455 }
456 goto NextOperand;
457
458 case ARGI_BUFFER:
459 /*
460 * Need an operand of type ACPI_TYPE_BUFFER,
461 * But we can implicitly convert from a STRING or INTEGER
462 * Aka - "Implicit Source Operand Conversion"
463 */
464 Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
465 if (ACPI_FAILURE (Status))
466 {
467 if (Status == AE_TYPE)
468 {
470 "Needed [Integer/String/Buffer], found [%s] %p",
471 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
472
474 }
475
477 }
478
479 if (ObjDesc != *StackPtr)
480 {
481 AcpiUtRemoveReference (ObjDesc);
482 }
483 goto NextOperand;
484
485 case ARGI_STRING:
486 /*
487 * Need an operand of type ACPI_TYPE_STRING,
488 * But we can implicitly convert from a BUFFER or INTEGER
489 * Aka - "Implicit Source Operand Conversion"
490 */
492 ObjDesc, StackPtr, ACPI_IMPLICIT_CONVERT_HEX);
493 if (ACPI_FAILURE (Status))
494 {
495 if (Status == AE_TYPE)
496 {
498 "Needed [Integer/String/Buffer], found [%s] %p",
499 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
500
502 }
503
505 }
506
507 if (ObjDesc != *StackPtr)
508 {
509 AcpiUtRemoveReference (ObjDesc);
510 }
511 goto NextOperand;
512
513 case ARGI_COMPUTEDATA:
514
515 /* Need an operand of type INTEGER, STRING or BUFFER */
516
517 switch (ObjDesc->Common.Type)
518 {
520 case ACPI_TYPE_STRING:
521 case ACPI_TYPE_BUFFER:
522
523 /* Valid operand */
524 break;
525
526 default:
528 "Needed [Integer/String/Buffer], found [%s] %p",
529 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
530
532 }
533 goto NextOperand;
534
536
537 /* Need an operand of type STRING or BUFFER */
538
539 switch (ObjDesc->Common.Type)
540 {
541 case ACPI_TYPE_STRING:
542 case ACPI_TYPE_BUFFER:
543
544 /* Valid operand */
545 break;
546
548
549 /* Highest priority conversion is to type Buffer */
550
551 Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
552 if (ACPI_FAILURE (Status))
553 {
555 }
556
557 if (ObjDesc != *StackPtr)
558 {
559 AcpiUtRemoveReference (ObjDesc);
560 }
561 break;
562
563 default:
565 "Needed [Integer/String/Buffer], found [%s] %p",
566 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
567
569 }
570 goto NextOperand;
571
572 case ARGI_DATAOBJECT:
573 /*
574 * ARGI_DATAOBJECT is only used by the SizeOf operator.
575 * Need a buffer, string, package, or RefOf reference.
576 *
577 * The only reference allowed here is a direct reference to
578 * a namespace node.
579 */
580 switch (ObjDesc->Common.Type)
581 {
583 case ACPI_TYPE_STRING:
584 case ACPI_TYPE_BUFFER:
586
587 /* Valid operand */
588 break;
589
590 default:
591
593 "Needed [Buffer/String/Package/Reference], found [%s] %p",
594 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
595
597 }
598 goto NextOperand;
599
600 case ARGI_COMPLEXOBJ:
601
602 /* Need a buffer or package or (ACPI 2.0) String */
603
604 switch (ObjDesc->Common.Type)
605 {
607 case ACPI_TYPE_STRING:
608 case ACPI_TYPE_BUFFER:
609
610 /* Valid operand */
611 break;
612
613 default:
614
616 "Needed [Buffer/String/Package], found [%s] %p",
617 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
618
620 }
621 goto NextOperand;
622
623 case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
624
625 /*
626 * Need an operand of type REGION or a BUFFER
627 * (which could be a resolved region field)
628 */
629 switch (ObjDesc->Common.Type)
630 {
631 case ACPI_TYPE_BUFFER:
632 case ACPI_TYPE_REGION:
633
634 /* Valid operand */
635 break;
636
637 default:
638
640 "Needed [Region/Buffer], found [%s] %p",
641 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
642
644 }
645 goto NextOperand;
646
647 case ARGI_DATAREFOBJ:
648
649 /* Used by the Store() operator only */
650
651 switch (ObjDesc->Common.Type)
652 {
655 case ACPI_TYPE_STRING:
656 case ACPI_TYPE_BUFFER:
663
664 /* Valid operand */
665 break;
666
667 default:
668
669 if (AcpiGbl_EnableInterpreterSlack)
670 {
671 /*
672 * Enable original behavior of Store(), allowing any
673 * and all objects as the source operand. The ACPI
674 * spec does not allow this, however.
675 */
676 break;
677 }
678
679 if (TargetOp == AML_DEBUG_OP)
680 {
681 /* Allow store of any object to the Debug object */
682
683 break;
684 }
685
687 "Needed Integer/Buffer/String/Package/Ref/Ddb]"
688 ", found [%s] %p",
689 AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
690
692 }
693 goto NextOperand;
694
695 default:
696
697 /* Unknown type */
698
700 "Internal - Unknown ARGI (required operand) type 0x%X",
701 ThisArgType));
702
704 }
705
706 /*
707 * Make sure that the original object was resolved to the
708 * required object type (Simple cases only).
709 */
711 TypeNeeded, (*StackPtr)->Common.Type, *StackPtr);
712 if (ACPI_FAILURE (Status))
713 {
715 }
716
717NextOperand:
718 /*
719 * If more operands needed, decrement StackPtr to point
720 * to next operand on stack
721 */
722 if (GET_CURRENT_ARG_TYPE (ArgTypes))
723 {
724 StackPtr--;
725 }
726 }
727
728 ACPI_DUMP_OPERANDS (WalkState->Operands,
730
732}
#define INCREMENT_ARG_LIST(List)
Definition: acmacros.h:451
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
#define ACPI_DUMP_OPERANDS(a, b, c)
Definition: acoutput.h:486
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define ACPI_FALLTHROUGH
Definition: actypes.h:1466
BOOLEAN AcpiUtValidObjectType(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:681
#define ARGI_BUFFER
Definition: amlcode.h:270
#define ARGI_BUFFER_OR_STRING
Definition: amlcode.h:271
#define ARGI_COMPUTEDATA
Definition: amlcode.h:272
#define ARGI_COMPLEXOBJ
Definition: amlcode.h:288
#define ARGI_STRING
Definition: amlcode.h:269
#define ARGI_DDBHANDLE
Definition: amlcode.h:264
#define ARGI_OBJECT_REF
Definition: amlcode.h:277
#define ARGI_DEVICE_REF
Definition: amlcode.h:278
#define ARGI_INVALID_OPCODE
Definition: amlcode.h:295
#define ARGI_DATAREFOBJ
Definition: amlcode.h:291
#define ARGI_MUTEX
Definition: amlcode.h:263
#define AML_DEBUG_OP
Definition: amlcode.h:177
#define ARGI_ANYTYPE
Definition: amlcode.h:260
#define ARGI_REF_OR_STRING
Definition: amlcode.h:289
#define ARGI_EVENT
Definition: amlcode.h:262
#define ARGI_REGION_OR_BUFFER
Definition: amlcode.h:290
#define ARGI_INTEGER
Definition: amlcode.h:268
#define AML_CLASS_UNKNOWN
Definition: amlcode.h:410
#define ARGI_DATAOBJECT
Definition: amlcode.h:287
#define ARGI_PACKAGE
Definition: amlcode.h:261
static ACPI_STATUS AcpiExCheckObjectType(ACPI_OBJECT_TYPE TypeNeeded, ACPI_OBJECT_TYPE ThisType, void *Object)
Definition: exresop.c:79
ObjectType
Definition: metafile.c:81
UINT8 NumOperands
Definition: acstruct.h:80

Referenced by AcpiDsEvalBufferFieldOperands(), AcpiDsEvalDataObjectOperands(), AcpiDsEvalRegionOperands(), AcpiDsEvalTableRegionOperands(), AcpiDsExecEndOp(), and AcpiExOpcode_1A_0T_1R().

◆ AcpiExResolveToValue()

ACPI_STATUS AcpiExResolveToValue ( ACPI_OPERAND_OBJECT **  StackPtr,
ACPI_WALK_STATE WalkState 
)

Definition at line 79 of file exresolv.c.

82{
84
85
86 ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
87
88
89 if (!StackPtr || !*StackPtr)
90 {
91 ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
93 }
94
95 /*
96 * The entity pointed to by the StackPtr can be either
97 * 1) A valid ACPI_OPERAND_OBJECT, or
98 * 2) A ACPI_NAMESPACE_NODE (NamedObj)
99 */
101 {
102 Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
103 if (ACPI_FAILURE (Status))
104 {
106 }
107
108 if (!*StackPtr)
109 {
110 ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
112 }
113 }
114
115 /*
116 * Object on the stack may have changed if AcpiExResolveObjectToValue()
117 * was called (i.e., we can't use an _else_ here.)
118 */
120 {
123 WalkState);
124 if (ACPI_FAILURE (Status))
125 {
127 }
128 }
129
130 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
132}
static ACPI_STATUS AcpiExResolveObjectToValue(ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState)
Definition: exresolv.c:150

Referenced by AcpiDsEvalBankFieldOperands(), AcpiDsEvaluateNamePath(), AcpiDsExecEndControlOp(), AcpiDsGetPredicateValue(), AcpiDsResolveOperands(), AcpiExResolveObject(), and AcpiExResolveOperands().

◆ AcpiExSetBufferDatum()

void AcpiExSetBufferDatum ( UINT64  MergedDatum,
void Buffer,
UINT32  BufferLength,
UINT32  ByteGranularity,
UINT32  BufferOffset 
)

◆ AcpiExSmBusSpaceHandler()

ACPI_STATUS AcpiExSmBusSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

◆ AcpiExStartTraceMethod()

void AcpiExStartTraceMethod ( ACPI_NAMESPACE_NODE MethodNode,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 224 of file extrace.c.

228{
229 char *Pathname = NULL;
231
232
233 ACPI_FUNCTION_NAME (ExStartTraceMethod);
234
235
236 if (MethodNode)
237 {
239 }
240
243 {
245 AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
246 AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
247 AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL;
248 AcpiDbgLayer = ACPI_TRACE_LAYER_ALL;
249
250 if (AcpiGbl_TraceDbgLevel)
251 {
252 AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
253 }
254
255 if (AcpiGbl_TraceDbgLayer)
256 {
257 AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
258 }
259 }
260
261 if (Enabled)
262 {
264 ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
265 }
266
267 if (Pathname)
268 {
270 }
271}
char * AcpiNsGetNormalizedPathname(ACPI_NAMESPACE_NODE *Node, BOOLEAN NoTrailing)
Definition: nsnames.c:367
#define ACPI_TRACE_LEVEL_ALL
Definition: acoutput.h:203
#define ACPI_TRACE_POINT(a, b, c, d)
Definition: acoutput.h:491
#define ACPI_TRACE_LAYER_ALL
Definition: acoutput.h:204
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
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 Pathname
Definition: acpixf.h:704
@ ACPI_TRACE_AML_METHOD
Definition: actypes.h:1414
static BOOLEAN AcpiExInterpreterTraceEnabled(char *Name)
Definition: extrace.c:80
static ACPI_OPERAND_OBJECT * AcpiGbl_TraceMethodObject
Definition: extrace.c:54
@ Enabled
Definition: mountmgr.h:159

Referenced by AcpiDsBeginMethodExecution().

◆ AcpiExStartTraceOpcode()

void AcpiExStartTraceOpcode ( ACPI_PARSE_OBJECT Op,
ACPI_WALK_STATE WalkState 
)

Definition at line 353 of file extrace.c.

356{
357
358 ACPI_FUNCTION_NAME (ExStartTraceOpcode);
359
360
362 (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
363 {
365 Op->Common.Aml, Op->Common.AmlOpName);
366 }
367}
#define ACPI_TRACE_OPCODE
Definition: acoutput.h:199
@ ACPI_TRACE_AML_OPCODE
Definition: actypes.h:1415

Referenced by AcpiPsParseLoop().

◆ AcpiExStopTraceMethod()

void AcpiExStopTraceMethod ( ACPI_NAMESPACE_NODE MethodNode,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 290 of file extrace.c.

294{
295 char *Pathname = NULL;
297
298
299 ACPI_FUNCTION_NAME (ExStopTraceMethod);
300
301
302 if (MethodNode)
303 {
305 }
306
308
309 if (Enabled)
310 {
312 ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
313 }
314
315 /* Check whether the tracer should be stopped */
316
317 if (AcpiGbl_TraceMethodObject == ObjDesc)
318 {
319 /* Disable further tracing if type is one-shot */
320
321 if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT)
322 {
323 AcpiGbl_TraceMethodName = NULL;
324 }
325
326 AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
327 AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
329 }
330
331 if (Pathname)
332 {
334 }
335}
#define ACPI_TRACE_ONESHOT
Definition: acoutput.h:198

Referenced by AcpiDsTerminateControlMethod().

◆ AcpiExStopTraceOpcode()

void AcpiExStopTraceOpcode ( ACPI_PARSE_OBJECT Op,
ACPI_WALK_STATE WalkState 
)

Definition at line 385 of file extrace.c.

388{
389
390 ACPI_FUNCTION_NAME (ExStopTraceOpcode);
391
392
394 (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
395 {
397 Op->Common.Aml, Op->Common.AmlOpName);
398 }
399}

Referenced by AcpiPsCompleteThisOp().

◆ AcpiExStore()

ACPI_STATUS AcpiExStore ( ACPI_OPERAND_OBJECT ValDesc,
ACPI_OPERAND_OBJECT DestDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 91 of file exstore.c.

95{
97 ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
98
99
100 ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
101
102
103 /* Validate parameters */
104
105 if (!SourceDesc || !DestDesc)
106 {
107 ACPI_ERROR ((AE_INFO, "Null parameter"));
109 }
110
111 /* DestDesc can be either a namespace node or an ACPI object */
112
114 {
115 /*
116 * Dest is a namespace node,
117 * Storing an object into a Named node.
118 */
119 Status = AcpiExStoreObjectToNode (SourceDesc,
120 (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
122
124 }
125
126 /* Destination object must be a Reference or a Constant object */
127
128 switch (DestDesc->Common.Type)
129 {
131
132 break;
133
135
136 /* Allow stores to Constants -- a Noop as per ACPI spec */
137
138 if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
139 {
141 }
142
144
145 default:
146
147 /* Destination is not a Reference object */
148
150 "Target is not a Reference or Constant object - [%s] %p",
151 AcpiUtGetObjectTypeName (DestDesc), DestDesc));
152
154 }
155
156 /*
157 * Examine the Reference class. These cases are handled:
158 *
159 * 1) Store to Name (Change the object associated with a name)
160 * 2) Store to an indexed area of a Buffer or Package
161 * 3) Store to a Method Local or Arg
162 * 4) Store to the debug object
163 */
164 switch (RefDesc->Reference.Class)
165 {
167
168 /* Storing an object into a Name "container" */
169
170 Status = AcpiExStoreObjectToNode (SourceDesc,
171 RefDesc->Reference.Object,
172 WalkState, ACPI_IMPLICIT_CONVERSION);
173 break;
174
176
177 /* Storing to an Index (pointer into a packager or buffer) */
178
179 Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
180 break;
181
184
185 /* Store to a method local/arg */
186
188 RefDesc->Reference.Value, SourceDesc, WalkState);
189 break;
190
192 /*
193 * Storing to the Debug object causes the value stored to be
194 * displayed and otherwise has no effect -- see ACPI Specification
195 */
197 "**** Write to Debug Object: Object %p [%s] ****:\n\n",
198 SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
199
200 ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
201 break;
202
203 default:
204
205 ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
206 RefDesc->Reference.Class));
207 ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
208
210 break;
211 }
212
214}
#define AOPOBJ_AML_CONSTANT
Definition: acobject.h:94
#define ACPI_LV_INFO
Definition: acoutput.h:90
#define ACPI_DEBUG_OBJECT(obj, l, i)
Definition: acoutput.h:244
#define ACPI_DUMP_ENTRY(a, b)
Definition: acoutput.h:487
ACPI_STATUS AcpiDsStoreObjectToLocal(UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: dsmthdat.c:585
ACPI_STATUS AcpiExStoreObjectToNode(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, ACPI_WALK_STATE *WalkState, UINT8 ImplicitConversion)
Definition: exstore.c:412
static ACPI_STATUS AcpiExStoreObjectToIndex(ACPI_OPERAND_OBJECT *ValDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState)
Definition: exstore.c:232

Referenced by AcpiExLoadTableOp(), AcpiExOpcode_1A_0T_1R(), AcpiExOpcode_1A_1T_1R(), AcpiExOpcode_2A_1T_1R(), AcpiExOpcode_2A_2T_1R(), and AcpiExOpcode_3A_1T_1R().

◆ AcpiExStoreBufferToBuffer()

ACPI_STATUS AcpiExStoreBufferToBuffer ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

Definition at line 67 of file exstorob.c.

70{
73
74
75 ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc);
76
77
78 /* If Source and Target are the same, just return */
79
80 if (SourceDesc == TargetDesc)
81 {
83 }
84
85 /* We know that SourceDesc is a buffer by now */
86
87 Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer);
88 Length = SourceDesc->Buffer.Length;
89
90 /*
91 * If target is a buffer of length zero or is a static buffer,
92 * allocate a new buffer of the proper length
93 */
94 if ((TargetDesc->Buffer.Length == 0) ||
95 (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
96 {
97 TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length);
98 if (!TargetDesc->Buffer.Pointer)
99 {
101 }
102
103 TargetDesc->Buffer.Length = Length;
104 }
105
106 /* Copy source buffer to target buffer */
107
108 if (Length <= TargetDesc->Buffer.Length)
109 {
110 /* Clear existing buffer and copy in the new one */
111
112 memset (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
113 memcpy (TargetDesc->Buffer.Pointer, Buffer, Length);
114
115#ifdef ACPI_OBSOLETE_BEHAVIOR
116 /*
117 * NOTE: ACPI versions up to 3.0 specified that the buffer must be
118 * truncated if the string is smaller than the buffer. However, "other"
119 * implementations of ACPI never did this and thus became the defacto
120 * standard. ACPI 3.0A changes this behavior such that the buffer
121 * is no longer truncated.
122 */
123
124 /*
125 * OBSOLETE BEHAVIOR:
126 * If the original source was a string, we must truncate the buffer,
127 * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
128 * copy must not truncate the original buffer.
129 */
130 if (OriginalSrcType == ACPI_TYPE_STRING)
131 {
132 /* Set the new length of the target */
133
134 TargetDesc->Buffer.Length = Length;
135 }
136#endif
137 }
138 else
139 {
140 /* Truncate the source, copy only what will fit */
141
142 memcpy (TargetDesc->Buffer.Pointer, Buffer,
143 TargetDesc->Buffer.Length);
144
146 "Truncating source buffer from %X to %X\n",
147 Length, TargetDesc->Buffer.Length));
148 }
149
150 /* Copy flags */
151
152 TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags;
153 TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
155}
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95

Referenced by AcpiExStoreObjectToObject().

◆ AcpiExStoreObjectToNode()

ACPI_STATUS AcpiExStoreObjectToNode ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_NAMESPACE_NODE Node,
ACPI_WALK_STATE WalkState,
UINT8  ImplicitConversion 
)

Definition at line 412 of file exstore.c.

417{
419 ACPI_OPERAND_OBJECT *TargetDesc;
420 ACPI_OPERAND_OBJECT *NewDesc;
421 ACPI_OBJECT_TYPE TargetType;
422
423
424 ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
425
426
427 /* Get current type of the node, and object attached to Node */
428
429 TargetType = AcpiNsGetType (Node);
430 TargetDesc = AcpiNsGetAttachedObject (Node);
431
432 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p [%s] to node %p [%s]\n",
433 SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
434 Node, AcpiUtGetTypeName (TargetType)));
435
436 /* Only limited target types possible for everything except CopyObject */
437
438 if (WalkState->Opcode != AML_COPY_OBJECT_OP)
439 {
440 /*
441 * Only CopyObject allows all object types to be overwritten. For
442 * TargetRef(s), there are restrictions on the object types that
443 * are allowed.
444 *
445 * Allowable operations/typing for Store:
446 *
447 * 1) Simple Store
448 * Integer --> Integer (Named/Local/Arg)
449 * String --> String (Named/Local/Arg)
450 * Buffer --> Buffer (Named/Local/Arg)
451 * Package --> Package (Named/Local/Arg)
452 *
453 * 2) Store with implicit conversion
454 * Integer --> String or Buffer (Named)
455 * String --> Integer or Buffer (Named)
456 * Buffer --> Integer or String (Named)
457 */
458 switch (TargetType)
459 {
461 /*
462 * Here, can only store a package to an existing package.
463 * Storing a package to a Local/Arg is OK, and handled
464 * elsewhere.
465 */
466 if (WalkState->Opcode == AML_STORE_OP)
467 {
468 if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
469 {
471 "Cannot assign type [%s] to [Package] "
472 "(source must be type Pkg)",
473 AcpiUtGetObjectTypeName (SourceDesc)));
474
476 }
477 break;
478 }
479
481
482 case ACPI_TYPE_DEVICE:
483 case ACPI_TYPE_EVENT:
484 case ACPI_TYPE_MUTEX:
485 case ACPI_TYPE_REGION:
486 case ACPI_TYPE_POWER:
489
491 "Target must be [Buffer/Integer/String/Reference]"
492 ", found [%s] (%4.4s)",
493 AcpiUtGetTypeName (Node->Type), Node->Name.Ascii));
494
496
497 default:
498 break;
499 }
500 }
501
502 /*
503 * Resolve the source object to an actual value
504 * (If it is a reference object)
505 */
506 Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
507 if (ACPI_FAILURE (Status))
508 {
510 }
511
512 /* Do the actual store operation */
513
514 switch (TargetType)
515 {
516 /*
517 * The simple data types all support implicit source operand
518 * conversion before the store.
519 */
521 case ACPI_TYPE_STRING:
522 case ACPI_TYPE_BUFFER:
523
524 if ((WalkState->Opcode == AML_COPY_OBJECT_OP) ||
525 !ImplicitConversion)
526 {
527 /*
528 * However, CopyObject and Stores to ArgX do not perform
529 * an implicit conversion, as per the ACPI specification.
530 * A direct store is performed instead.
531 */
532 Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState);
533 break;
534 }
535
536 /* Store with implicit source operand conversion support */
537
538 Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
539 &NewDesc, WalkState);
540 if (ACPI_FAILURE (Status))
541 {
543 }
544
545 if (NewDesc != TargetDesc)
546 {
547 /*
548 * Store the new NewDesc as the new value of the Name, and set
549 * the Name's type to that of the value being stored in it.
550 * SourceDesc reference count is incremented by AttachObject.
551 *
552 * Note: This may change the type of the node if an explicit
553 * store has been performed such that the node/object type
554 * has been changed.
555 */
557 Node, NewDesc, NewDesc->Common.Type);
558
560 "Store type [%s] into [%s] via Convert/Attach\n",
561 AcpiUtGetObjectTypeName (SourceDesc),
562 AcpiUtGetObjectTypeName (NewDesc)));
563 }
564 break;
565
570 /*
571 * For all fields, always write the source data to the target
572 * field. Any required implicit source operand conversion is
573 * performed in the function below as necessary. Note, field
574 * objects must retain their original type permanently.
575 */
576 Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
577 &WalkState->ResultObj);
578 break;
579
580 default:
581 /*
582 * CopyObject operator: No conversions for all other types.
583 * Instead, directly store a copy of the source object.
584 *
585 * This is the ACPI spec-defined behavior for the CopyObject
586 * operator. (Note, for this default case, all normal
587 * Store/Target operations exited above with an error).
588 */
589 Status = AcpiExStoreDirectToNode (SourceDesc, Node, WalkState);
590 break;
591 }
592
594}
#define AE_AML_TARGET_TYPE
Definition: acexcep.h:214
ACPI_STATUS AcpiExWriteDataToField(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc)
Definition: exfield.c:317
static ACPI_STATUS AcpiExStoreDirectToNode(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, ACPI_WALK_STATE *WalkState)
Definition: exstore.c:613
ACPI_STATUS AcpiExStoreObjectToObject(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_OPERAND_OBJECT **NewDesc, ACPI_WALK_STATE *WalkState)
Definition: exstoren.c:199
ACPI_STATUS AcpiExResolveObject(ACPI_OPERAND_OBJECT **SourceDescPtr, ACPI_OBJECT_TYPE TargetType, ACPI_WALK_STATE *WalkState)
Definition: exstoren.c:71

Referenced by AcpiDsStoreObjectToLocal(), and AcpiExStore().

◆ AcpiExStoreObjectToObject()

ACPI_STATUS AcpiExStoreObjectToObject ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT DestDesc,
ACPI_OPERAND_OBJECT **  NewDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 199 of file exstoren.c.

204{
205 ACPI_OPERAND_OBJECT *ActualSrcDesc;
207
208
209 ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc);
210
211
212 ActualSrcDesc = SourceDesc;
213 if (!DestDesc)
214 {
215 /*
216 * There is no destination object (An uninitialized node or
217 * package element), so we can simply copy the source object
218 * creating a new destination object
219 */
220 Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState);
222 }
223
224 if (SourceDesc->Common.Type != DestDesc->Common.Type)
225 {
226 /*
227 * The source type does not match the type of the destination.
228 * Perform the "implicit conversion" of the source to the current type
229 * of the target as per the ACPI specification.
230 *
231 * If no conversion performed, ActualSrcDesc = SourceDesc.
232 * Otherwise, ActualSrcDesc is a temporary object to hold the
233 * converted object.
234 */
235 Status = AcpiExConvertToTargetType (DestDesc->Common.Type,
236 SourceDesc, &ActualSrcDesc, WalkState);
237 if (ACPI_FAILURE (Status))
238 {
240 }
241
242 if (SourceDesc == ActualSrcDesc)
243 {
244 /*
245 * No conversion was performed. Return the SourceDesc as the
246 * new object.
247 */
248 *NewDesc = SourceDesc;
250 }
251 }
252
253 /*
254 * We now have two objects of identical types, and we can perform a
255 * copy of the *value* of the source object.
256 */
257 switch (DestDesc->Common.Type)
258 {
260
261 DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
262
263 /* Truncate value if we are executing from a 32-bit ACPI table */
264
266 break;
267
268 case ACPI_TYPE_STRING:
269
270 Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
271 break;
272
273 case ACPI_TYPE_BUFFER:
274
275 Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
276 break;
277
279
280 Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
281 WalkState);
282 break;
283
284 default:
285 /*
286 * All other types come here.
287 */
288 ACPI_WARNING ((AE_INFO, "Store into type [%s] not implemented",
289 AcpiUtGetObjectTypeName (DestDesc)));
290
292 break;
293 }
294
295 if (ActualSrcDesc != SourceDesc)
296 {
297 /* Delete the intermediate (temporary) source object */
298
299 AcpiUtRemoveReference (ActualSrcDesc);
300 }
301
302 *NewDesc = DestDesc;
304}
ACPI_STATUS AcpiExConvertToTargetType(ACPI_OBJECT_TYPE DestinationType, ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState)
Definition: exconvrt.c:654
ACPI_STATUS AcpiExStoreBufferToBuffer(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
Definition: exstorob.c:67
ACPI_STATUS AcpiExStoreStringToString(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc)
Definition: exstorob.c:172

Referenced by AcpiExStoreObjectToNode().

◆ AcpiExStoreStringToString()

ACPI_STATUS AcpiExStoreStringToString ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT TargetDesc 
)

Definition at line 172 of file exstorob.c.

175{
177 UINT8 *Buffer;
178
179
180 ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc);
181
182
183 /* If Source and Target are the same, just return */
184
185 if (SourceDesc == TargetDesc)
186 {
188 }
189
190 /* We know that SourceDesc is a string by now */
191
192 Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer);
193 Length = SourceDesc->String.Length;
194
195 /*
196 * Replace existing string value if it will fit and the string
197 * pointer is not a static pointer (part of an ACPI table)
198 */
199 if ((Length < TargetDesc->String.Length) &&
200 (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
201 {
202 /*
203 * String will fit in existing non-static buffer.
204 * Clear old string and copy in the new one
205 */
206 memset (TargetDesc->String.Pointer, 0,
207 (ACPI_SIZE) TargetDesc->String.Length + 1);
208 memcpy (TargetDesc->String.Pointer, Buffer, Length);
209 }
210 else
211 {
212 /*
213 * Free the current buffer, then allocate a new buffer
214 * large enough to hold the value
215 */
216 if (TargetDesc->String.Pointer &&
217 (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
218 {
219 /* Only free if not a pointer into the DSDT */
220
221 ACPI_FREE (TargetDesc->String.Pointer);
222 }
223
224 TargetDesc->String.Pointer =
225 ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
226
227 if (!TargetDesc->String.Pointer)
228 {
230 }
231
232 TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
233 memcpy (TargetDesc->String.Pointer, Buffer, Length);
234 }
235
236 /* Set the new target length */
237
238 TargetDesc->String.Length = Length;
240}

Referenced by AcpiExStoreObjectToObject().

◆ AcpiExSystemDoNotifyOp()

ACPI_STATUS AcpiExSystemDoNotifyOp ( ACPI_OPERAND_OBJECT Value,
ACPI_OPERAND_OBJECT ObjDesc 
)

◆ AcpiExSystemDoSleep()

ACPI_STATUS AcpiExSystemDoSleep ( UINT64  Time)

Definition at line 223 of file exsystem.c.

225{
227
228
229 /* Since this thread will sleep, we must release the interpreter */
230
232
233 /*
234 * For compatibility with other ACPI implementations and to prevent
235 * accidental deep sleeps, limit the sleep time to something reasonable.
236 */
237 if (HowLongMs > ACPI_MAX_SLEEP)
238 {
239 HowLongMs = ACPI_MAX_SLEEP;
240 }
241
242 AcpiOsSleep (HowLongMs);
243
244 /* And now we must get the interpreter again */
245
247 return (AE_OK);
248}
void AcpiOsSleep(UINT64 Milliseconds)
Definition: osl.c:257
#define ACPI_MAX_SLEEP
Definition: acconfig.h:144

Referenced by AcpiExOpcode_1A_0T_0R().

◆ AcpiExSystemDoStall()

ACPI_STATUS AcpiExSystemDoStall ( UINT32  Time)

Definition at line 174 of file exsystem.c.

176{
178
179
181
182
183 if (HowLongUs > 255)
184 {
185 /*
186 * Longer than 255 microseconds, this is an error
187 *
188 * (ACPI specifies 100 usec as max, but this gives some slack in
189 * order to support existing BIOSs)
190 */
192 "Time parameter is too large (%u)", HowLongUs));
194 }
195 else
196 {
197 if (HowLongUs > 100)
198 {
200 "Time parameter %u us > 100 us violating ACPI spec, please fix the firmware.", HowLongUs));
201 }
202 AcpiOsStall (HowLongUs);
203 }
204
205 return (Status);
206}
void AcpiOsStall(UINT32 Microseconds)
Definition: osl.c:264

Referenced by AcpiExOpcode_1A_0T_0R().

◆ AcpiExSystemIoSpaceHandler()

ACPI_STATUS AcpiExSystemIoSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 359 of file exregion.c.

366{
368 UINT32 Value32;
369
370
371 ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
372
373
375 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
376 BitWidth, Function, ACPI_FORMAT_UINT64 (Address)));
377
378 /* Decode the function parameter */
379
380 switch (Function)
381 {
382 case ACPI_READ:
383
384 Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
385 &Value32, BitWidth);
386 *Value = Value32;
387 break;
388
389 case ACPI_WRITE:
390
391 Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
392 (UINT32) *Value, BitWidth);
393 break;
394
395 default:
396
398 break;
399 }
400
402}
ACPI_STATUS AcpiHwWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: hwvalid.c:312
ACPI_STATUS AcpiHwReadPort(ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
Definition: hwvalid.c:237

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExSystemMemorySpaceHandler()

ACPI_STATUS AcpiExSystemMemorySpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 72 of file exregion.c.

79{
81 void *LogicalAddrPtr = NULL;
82 ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
83 ACPI_MEM_MAPPING *Mm = MemInfo->CurMm;
85 ACPI_SIZE MapLength;
86 ACPI_SIZE PageBoundaryMapLength;
87#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
89#endif
90
91
92 ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
93
94
95 /* Validate and translate the bit width */
96
97 switch (BitWidth)
98 {
99 case 8:
100
101 Length = 1;
102 break;
103
104 case 16:
105
106 Length = 2;
107 break;
108
109 case 32:
110
111 Length = 4;
112 break;
113
114 case 64:
115
116 Length = 8;
117 break;
118
119 default:
120
121 ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
122 BitWidth));
124 }
125
126#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
127 /*
128 * Hardware does not support non-aligned data transfers, we must verify
129 * the request.
130 */
132 if (Remainder != 0)
133 {
135 }
136#endif
137
138 /*
139 * Does the request fit into the cached memory mapping?
140 * Is 1) Address below the current mapping? OR
141 * 2) Address beyond the current mapping?
142 */
143 if (!Mm || (Address < Mm->PhysicalAddress) ||
144 ((UINT64) Address + Length > (UINT64) Mm->PhysicalAddress + Mm->Length))
145 {
146 /*
147 * The request cannot be resolved by the current memory mapping.
148 *
149 * Look for an existing saved mapping covering the address range
150 * at hand. If found, save it as the current one and carry out
151 * the access.
152 */
153 for (Mm = MemInfo->FirstMm; Mm; Mm = Mm->NextMm)
154 {
155 if (Mm == MemInfo->CurMm)
156 {
157 continue;
158 }
159
160 if (Address < Mm->PhysicalAddress)
161 {
162 continue;
163 }
164
165 if ((UINT64) Address + Length > (UINT64) Mm->PhysicalAddress + Mm->Length)
166 {
167 continue;
168 }
169
170 MemInfo->CurMm = Mm;
171 goto access;
172 }
173
174 /* Create a new mappings list entry */
175
176 Mm = ACPI_ALLOCATE_ZEROED(sizeof(*Mm));
177 if (!Mm)
178 {
180 "Unable to save memory mapping at 0x%8.8X%8.8X, size %u",
183 }
184
185 /*
186 * October 2009: Attempt to map from the requested address to the
187 * end of the region. However, we will never map more than one
188 * page, nor will we cross a page boundary.
189 */
190 MapLength = (ACPI_SIZE)
191 ((MemInfo->Address + MemInfo->Length) - Address);
192
193 /*
194 * If mapping the entire remaining portion of the region will cross
195 * a page boundary, just map up to the page boundary, do not cross.
196 * On some systems, crossing a page boundary while mapping regions
197 * can cause warnings if the pages have different attributes
198 * due to resource management.
199 *
200 * This has the added benefit of constraining a single mapping to
201 * one page, which is similar to the original code that used a 4k
202 * maximum window.
203 */
204 PageBoundaryMapLength = (ACPI_SIZE)
206 if (PageBoundaryMapLength == 0)
207 {
208 PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
209 }
210
211 if (MapLength > PageBoundaryMapLength)
212 {
213 MapLength = PageBoundaryMapLength;
214 }
215
216 /* Create a new mapping starting at the address given */
217
218 LogicalAddrPtr = AcpiOsMapMemory(Address, MapLength);
219 if (!LogicalAddrPtr)
220 {
222 "Could not map memory at 0x%8.8X%8.8X, size %u",
223 ACPI_FORMAT_UINT64 (Address), (UINT32) MapLength));
224 ACPI_FREE(Mm);
226 }
227
228 /* Save the physical address and mapping size */
229
230 Mm->LogicalAddress = LogicalAddrPtr;
232 Mm->Length = MapLength;
233
234 /*
235 * Add the new entry to the mappigs list and save it as the
236 * current mapping.
237 */
238 Mm->NextMm = MemInfo->FirstMm;
239 MemInfo->FirstMm = Mm;
240 MemInfo->CurMm = Mm;
241 }
242
243access:
244 /*
245 * Generate a logical pointer corresponding to the address we want to
246 * access
247 */
248 LogicalAddrPtr = Mm->LogicalAddress +
250
252 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
253 BitWidth, Function, ACPI_FORMAT_UINT64 (Address)));
254
255 /*
256 * Perform the memory read or write
257 *
258 * Note: For machines that do not support non-aligned transfers, the target
259 * address was checked for alignment above. We do not attempt to break the
260 * transfer up into smaller (byte-size) chunks because the AML specifically
261 * asked for a transfer width that the hardware may require.
262 */
263 switch (Function)
264 {
265 case ACPI_READ:
266
267 *Value = 0;
268 switch (BitWidth)
269 {
270 case 8:
271
272 *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
273 break;
274
275 case 16:
276
277 *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
278 break;
279
280 case 32:
281
282 *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
283 break;
284
285 case 64:
286
287 *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
288 break;
289
290 default:
291
292 /* BitWidth was already validated */
293
294 break;
295 }
296 break;
297
298 case ACPI_WRITE:
299
300 switch (BitWidth)
301 {
302 case 8:
303
304 ACPI_SET8 (LogicalAddrPtr, *Value);
305 break;
306
307 case 16:
308
309 ACPI_SET16 (LogicalAddrPtr, *Value);
310 break;
311
312 case 32:
313
314 ACPI_SET32 (LogicalAddrPtr, *Value);
315 break;
316
317 case 64:
318
319 ACPI_SET64 (LogicalAddrPtr, *Value);
320 break;
321
322 default:
323
324 /* BitWidth was already validated */
325
326 break;
327 }
328 break;
329
330 default:
331
333 break;
334 }
335
337}
#define AE_AML_ALIGNMENT
Definition: acexcep.h:206
#define ACPI_GET16(ptr)
Definition: acmacros.h:58
#define ACPI_SET8(ptr, val)
Definition: acmacros.h:61
#define ACPI_GET32(ptr)
Definition: acmacros.h:59
#define ACPI_SET64(ptr, val)
Definition: acmacros.h:64
#define ACPI_GET8(ptr)
Definition: acmacros.h:57
#define ACPI_ROUND_UP(value, boundary)
Definition: acmacros.h:242
#define ACPI_SET32(ptr, val)
Definition: acmacros.h:63
#define ACPI_SET16(ptr, val)
Definition: acmacros.h:62
#define ACPI_GET64(ptr)
Definition: acmacros.h:60
void * AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
Definition: osl.c:108
#define ACPI_DEFAULT_PAGE_SIZE
Definition: acconfig.h:132
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
ACPI_SIZE Length
Definition: actypes.h:1362
struct acpi_mem_mapping * NextMm
Definition: actypes.h:1363
UINT8 * LogicalAddress
Definition: actypes.h:1361
ACPI_PHYSICAL_ADDRESS PhysicalAddress
Definition: actypes.h:1360
ACPI_PHYSICAL_ADDRESS Address
Definition: actypes.h:1370
ACPI_MEM_MAPPING * CurMm
Definition: actypes.h:1371
ACPI_MEM_MAPPING * FirstMm
Definition: actypes.h:1372
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExSystemResetEvent()

ACPI_STATUS AcpiExSystemResetEvent ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 332 of file exsystem.c.

334{
336 ACPI_SEMAPHORE TempSemaphore;
337
338
340
341
342 /*
343 * We are going to simply delete the existing semaphore and
344 * create a new one!
345 */
346 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
347 if (ACPI_SUCCESS (Status))
348 {
350 ObjDesc->Event.OsSemaphore = TempSemaphore;
351 }
352
353 return (Status);
354}
ACPI_STATUS AcpiOsDeleteSemaphore(ACPI_SEMAPHORE Handle)
Definition: osl.c:378
#define ACPI_SEMAPHORE
Definition: actypes.h:287

Referenced by AcpiExOpcode_1A_0T_0R().

◆ AcpiExSystemSignalEvent()

ACPI_STATUS AcpiExSystemSignalEvent ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 265 of file exsystem.c.

267{
269
270
271 ACPI_FUNCTION_TRACE (ExSystemSignalEvent);
272
273
274 if (ObjDesc)
275 {
277 }
278
280}
ACPI_STATUS AcpiOsSignalSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units)
Definition: osl.c:439

Referenced by AcpiExOpcode_1A_0T_0R().

◆ AcpiExSystemWaitEvent()

ACPI_STATUS AcpiExSystemWaitEvent ( ACPI_OPERAND_OBJECT Time,
ACPI_OPERAND_OBJECT ObjDesc 
)

Definition at line 299 of file exsystem.c.

302{
304
305
306 ACPI_FUNCTION_TRACE (ExSystemWaitEvent);
307
308
309 if (ObjDesc)
310 {
312 (UINT16) TimeDesc->Integer.Value);
313 }
314
316}
ACPI_STATUS AcpiExSystemWaitSemaphore(ACPI_SEMAPHORE Semaphore, UINT16 Timeout)
Definition: exsystem.c:68

Referenced by AcpiExOpcode_2A_0T_1R().

◆ AcpiExSystemWaitMutex()

ACPI_STATUS AcpiExSystemWaitMutex ( ACPI_MUTEX  Mutex,
UINT16  Timeout 
)

Definition at line 120 of file exsystem.c.

123{
125
126
127 ACPI_FUNCTION_TRACE (ExSystemWaitMutex);
128
129
131 if (ACPI_SUCCESS (Status))
132 {
134 }
135
136 if (Status == AE_TIME)
137 {
138 /* We must wait, so unlock the interpreter */
139
142
144 "*** Thread awake after blocking, %s\n",
146
147 /* Reacquire the interpreter */
148
150 }
151
153}
#define AcpiOsAcquireMutex(Handle, Time)
Definition: actypes.h:276
#define ACPI_DO_NOT_WAIT
Definition: actypes.h:502
Definition: Mutex.h:16
const char * AcpiFormatException(ACPI_STATUS Status)
Definition: utexcep.c:70

Referenced by AcpiDsBeginMethodExecution(), AcpiEvAcquireGlobalLock(), and AcpiExAcquireMutexObject().

◆ AcpiExSystemWaitSemaphore()

ACPI_STATUS AcpiExSystemWaitSemaphore ( ACPI_SEMAPHORE  Semaphore,
UINT16  Timeout 
)

Definition at line 68 of file exsystem.c.

71{
73
74
75 ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore);
76
77
79 if (ACPI_SUCCESS (Status))
80 {
82 }
83
84 if (Status == AE_TIME)
85 {
86 /* We must wait, so unlock the interpreter */
87
89 Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
90
92 "*** Thread awake after blocking, %s\n",
94
95 /* Reacquire the interpreter */
96
98 }
99
101}
ACPI_STATUS AcpiOsWaitSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units, UINT16 Timeout)
Definition: osl.c:393

Referenced by AcpiEvAcquireGlobalLock(), and AcpiExSystemWaitEvent().

◆ AcpiExTracePoint()

void AcpiExTracePoint ( ACPI_TRACE_EVENT_TYPE  Type,
BOOLEAN  Begin,
UINT8 Aml,
char Pathname 
)

Definition at line 181 of file extrace.c.

186{
187
188 ACPI_FUNCTION_NAME (ExTracePoint);
189
190
191 if (Pathname)
192 {
194 "%s %s [0x%p:%s] execution.\n",
195 AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
196 Aml, Pathname));
197 }
198 else
199 {
201 "%s %s [0x%p] execution.\n",
202 AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
203 Aml));
204 }
205}
#define ACPI_DB_TRACE_POINT
Definition: acoutput.h:155
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN Begin
Definition: acpixf.h:1301
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN UINT8 * Aml
Definition: acpixf.h:1302

◆ 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}

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

◆ AcpiExUnlinkMutex()

void AcpiExUnlinkMutex ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 73 of file exmutex.c.

75{
77
78
79 if (!Thread)
80 {
81 return;
82 }
83
84 /* Doubly linked list */
85
86 if (ObjDesc->Mutex.Next)
87 {
88 (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
89 }
90
91 if (ObjDesc->Mutex.Prev)
92 {
93 (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next;
94
95 /*
96 * Migrate the previous sync level associated with this mutex to
97 * the previous mutex on the list so that it may be preserved.
98 * This handles the case where several mutexes have been acquired
99 * at the same level, but are not released in opposite order.
100 */
101 (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel =
102 ObjDesc->Mutex.OriginalSyncLevel;
103 }
104 else
105 {
106 Thread->AcquiredMutexList = ObjDesc->Mutex.Next;
107 }
108}

Referenced by AcpiExReleaseMutexObject(), and AcpiUtDeleteInternalObj().

◆ AcpiExUnloadTable()

ACPI_STATUS AcpiExUnloadTable ( ACPI_OPERAND_OBJECT DdbHandle)

Definition at line 565 of file exconfig.c.

567{
569 ACPI_OPERAND_OBJECT *TableDesc = DdbHandle;
570 UINT32 TableIndex;
571
572
573 ACPI_FUNCTION_TRACE (ExUnloadTable);
574
575
576 /*
577 * Temporarily emit a warning so that the ASL for the machine can be
578 * hopefully obtained. This is to say that the Unload() operator is
579 * extremely rare if not completely unused.
580 */
582 "Received request to unload an ACPI table"));
583
584 /*
585 * May 2018: Unload is no longer supported for the following reasons:
586 * 1) A correct implementation on some hosts may not be possible.
587 * 2) Other ACPI implementations do not correctly/fully support it.
588 * 3) It requires host device driver support which does not exist.
589 * (To properly support namespace unload out from underneath.)
590 * 4) This AML operator has never been seen in the field.
591 */
593 "AML Unload operator is not supported"));
594
595 /*
596 * Validate the handle
597 * Although the handle is partially validated in AcpiExReconfiguration()
598 * when it calls AcpiExResolveOperands(), the handle is more completely
599 * validated here.
600 *
601 * Handle must be a valid operand object of type reference. Also, the
602 * DdbHandle must still be marked valid (table has not been previously
603 * unloaded)
604 */
605 if ((!DdbHandle) ||
607 (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) ||
608 (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID)))
609 {
611 }
612
613 /* Get the table index from the DdbHandle */
614
615 TableIndex = TableDesc->Reference.Value;
616
617 /*
618 * Release the interpreter lock so that the table lock won't have
619 * strict order requirement against it.
620 */
622 Status = AcpiTbUnloadTable (TableIndex);
624
625 /*
626 * Invalidate the handle. We do this because the handle may be stored
627 * in a named object and may not be actually deleted until much later.
628 */
629 if (ACPI_SUCCESS (Status))
630 {
631 DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
632 }
634}
ACPI_STATUS AcpiTbUnloadTable(UINT32 TableIndex)
Definition: tbdata.c:1206

Referenced by AcpiExLoadTableOp(), and AcpiExOpcode_1A_0T_0R().

◆ AcpiExWriteDataToField()

ACPI_STATUS AcpiExWriteDataToField ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ResultDesc 
)

Definition at line 317 of file exfield.c.

321{
325 void *Buffer;
326
327
328 ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc);
329
330
331 /* Parameter validation */
332
333 if (!SourceDesc || !ObjDesc)
334 {
336 }
337
338 if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
339 {
340 /*
341 * If the BufferField arguments have not been previously evaluated,
342 * evaluate them now and save the results.
343 */
344 if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
345 {
347 if (ACPI_FAILURE (Status))
348 {
350 }
351 }
352 }
353 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
355 {
356 /* General Purpose I/O */
357
358 Status = AcpiExWriteGpio (SourceDesc, ObjDesc, ResultDesc);
360 }
361 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
367 {
368 /* SMBus, GSBus, IPMI serial */
369
370 Status = AcpiExWriteSerialBus (SourceDesc, ObjDesc, ResultDesc);
372 }
373 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
375 {
376 /*
377 * According to the spec a write to the COMD field will invoke the
378 * region handler. Otherwise, write to the PccInternal buffer. This
379 * implementation will use the offsets specified rather than the name
380 * of the field. This is considered safer because some firmware tools
381 * are known to obfiscate named objects.
382 */
384 ObjDesc->Field.BitLength);
386 ObjDesc->Field.BaseByteOffset,
387 SourceDesc->Buffer.Pointer, DataLength);
388
389 if (MASTER_SUBSPACE_COMMAND (ObjDesc->Field.BaseByteOffset))
390 {
391 /* Perform the write */
392
394 "PCC COMD field has been written. Invoking PCC handler now.\n"));
395
397 ObjDesc, 0, (UINT64 *) ObjDesc->Field.RegionObj->Field.InternalPccBuffer,
398 ACPI_WRITE);
400 }
401 return (AE_OK);
402 }
403
404
405 /* Get a pointer to the data to be written */
406
407 switch (SourceDesc->Common.Type)
408 {
410
411 Buffer = &SourceDesc->Integer.Value;
412 BufferLength = sizeof (SourceDesc->Integer.Value);
413 break;
414
415 case ACPI_TYPE_BUFFER:
416
417 Buffer = SourceDesc->Buffer.Pointer;
418 BufferLength = SourceDesc->Buffer.Length;
419 break;
420
421 case ACPI_TYPE_STRING:
422
423 Buffer = SourceDesc->String.Pointer;
424 BufferLength = SourceDesc->String.Length;
425 break;
426
427 default:
429 }
430
432 "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
433 SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
434 SourceDesc->Common.Type, Buffer, BufferLength));
435
437 "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
438 ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type),
439 ObjDesc->Common.Type,
440 ObjDesc->CommonField.BitLength,
441 ObjDesc->CommonField.StartFieldBitOffset,
442 ObjDesc->CommonField.BaseByteOffset));
443
444 /* Lock entire transaction if requested */
445
446 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
447
448 /* Write to the field */
449
451 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
453}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define MASTER_SUBSPACE_COMMAND(a)
Definition: exfield.c:91
ACPI_STATUS AcpiExInsertIntoField(ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer, UINT32 BufferLength)
Definition: exfldio.c:883
ACPI_STATUS AcpiExWriteGpio(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
Definition: exserial.c:121
ACPI_STATUS AcpiExWriteSerialBus(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
Definition: exserial.c:297

Referenced by AcpiDsExecEndOp(), AcpiDsGetFieldNames(), and AcpiExStoreObjectToNode().

◆ AcpiExWriteGpio()

ACPI_STATUS AcpiExWriteGpio ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ReturnBuffer 
)

Definition at line 121 of file exserial.c.

125{
127 void *Buffer;
128
129
130 ACPI_FUNCTION_TRACE_PTR (ExWriteGpio, ObjDesc);
131
132
133 /*
134 * For GPIO (GeneralPurposeIo), we will bypass the entire field
135 * mechanism and handoff the bit address and bit width directly to
136 * the handler. The Address will be the bit offset
137 * from the previous Connection() operator, making it effectively a
138 * pin number index. The BitLength is the length of the field, which
139 * is thus the number of pins.
140 */
141 if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
142 {
144 }
145
147 "GPIO FieldWrite [FROM]: (%s:%X), Value %.8X [TO]: Pin %u Bits %u\n",
148 AcpiUtGetTypeName (SourceDesc->Common.Type),
149 SourceDesc->Common.Type, (UINT32) SourceDesc->Integer.Value,
150 ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength));
151
152 Buffer = &SourceDesc->Integer.Value;
153
154 /* Lock entire transaction if requested */
155
156 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
157
158 /* Perform the write */
159
161 ObjDesc, 0, (UINT64 *) Buffer, ACPI_WRITE);
162 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
164}

Referenced by AcpiExWriteDataToField().

◆ AcpiExWriteSerialBus()

ACPI_STATUS AcpiExWriteSerialBus ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT ObjDesc,
ACPI_OPERAND_OBJECT **  ReturnBuffer 
)

Definition at line 297 of file exserial.c.

301{
305 void *Buffer;
306 ACPI_OPERAND_OBJECT *BufferDesc;
308 UINT16 AccessorType;
309
310
311 ACPI_FUNCTION_TRACE_PTR (ExWriteSerialBus, ObjDesc);
312
313
314 /*
315 * This is an SMBus, GSBus or IPMI write. We will bypass the entire
316 * field mechanism and handoff the buffer directly to the handler.
317 * For these address spaces, the buffer is bidirectional; on a
318 * write, return data is returned in the same buffer.
319 *
320 * Source must be a buffer of sufficient size, these are fixed size:
321 * ACPI_SMBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE.
322 *
323 * Note: SMBus and GSBus protocol type is passed in upper 16-bits
324 * of Function
325 *
326 * Common buffer format:
327 * Status; (Byte 0 of the data buffer)
328 * Length; (Byte 1 of the data buffer)
329 * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer)
330 */
331 if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
332 {
334 "SMBus/IPMI/GenericSerialBus write requires "
335 "Buffer, found type %s",
336 AcpiUtGetObjectTypeName (SourceDesc)));
337
339 }
340
341 switch (ObjDesc->Field.RegionObj->Region.SpaceId)
342 {
344
346 Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
347 break;
348
350
353 break;
354
356
357 AccessorType = ObjDesc->Field.Attribute;
359 if (ACPI_FAILURE (Status))
360 {
362 "Invalid protocol ID for GSBus: 0x%4.4X", AccessorType));
363
365 }
366
367 /* Add header length to get the full size of the buffer */
368
370 Function = ACPI_WRITE | (AccessorType << 16);
371 break;
372
374
377 break;
378
380
383 break;
384
385 default:
387 }
388
389 /* Create the transfer/bidirectional/return buffer */
390
392 if (!BufferDesc)
393 {
395 }
396
397 /* Copy the input buffer data to the transfer buffer */
398
399 Buffer = BufferDesc->Buffer.Pointer;
400 DataLength = (BufferLength < SourceDesc->Buffer.Length ?
401 BufferLength : SourceDesc->Buffer.Length);
402 memcpy (Buffer, SourceDesc->Buffer.Pointer, DataLength);
403
404 /* Lock entire transaction if requested */
405
406 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
407
408 /*
409 * Perform the write (returns status and perhaps data in the
410 * same buffer)
411 */
413 ObjDesc, 0, (UINT64 *) Buffer, Function);
414 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
415
416 *ReturnBuffer = BufferDesc;
418}
#define ACPI_FFH_INPUT_BUFFER_SIZE
Definition: acconfig.h:230

Referenced by AcpiExWriteDataToField().

◆ AcpiExWriteWithUpdateRule()

ACPI_STATUS AcpiExWriteWithUpdateRule ( ACPI_OPERAND_OBJECT ObjDesc,
UINT64  Mask,
UINT64  FieldValue,
UINT32  FieldDatumByteOffset 
)

Definition at line 617 of file exfldio.c.

622{
624 UINT64 MergedValue;
625 UINT64 CurrentValue;
626
627
628 ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask);
629
630
631 /* Start with the new bits */
632
633 MergedValue = FieldValue;
634
635 /* If the mask is all ones, we don't need to worry about the update rule */
636
637 if (Mask != ACPI_UINT64_MAX)
638 {
639 /* Decode the update rule */
640
641 switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
642 {
644 /*
645 * Check if update rule needs to be applied (not if mask is all
646 * ones) The left shift drops the bits we want to ignore.
647 */
648 if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
649 ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
650 {
651 /*
652 * Read the current contents of the byte/word/dword containing
653 * the field, and merge with the new field value.
654 */
656 ObjDesc, FieldDatumByteOffset, &CurrentValue, ACPI_READ);
657 if (ACPI_FAILURE (Status))
658 {
660 }
661
662 MergedValue |= (CurrentValue & ~Mask);
663 }
664 break;
665
667
668 /* Set positions outside the field to all ones */
669
670 MergedValue |= ~Mask;
671 break;
672
674
675 /* Set positions outside the field to all zeros */
676
677 MergedValue &= Mask;
678 break;
679
680 default:
681
683 "Unknown UpdateRule value: 0x%X",
684 (ObjDesc->CommonField.FieldFlags &
687 }
688 }
689
691 "Mask %8.8X%8.8X, DatumOffset %X, Width %X, "
692 "Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
694 FieldDatumByteOffset,
695 ObjDesc->CommonField.AccessByteWidth,
696 ACPI_FORMAT_UINT64 (FieldValue),
697 ACPI_FORMAT_UINT64 (MergedValue)));
698
699 /* Write the merged value */
700
702 ObjDesc, FieldDatumByteOffset, &MergedValue, ACPI_WRITE);
703
705}
#define AML_FIELD_UPDATE_RULE_MASK
Definition: amlcode.h:444
@ AML_FIELD_UPDATE_WRITE_AS_ONES
Definition: amlcode.h:476
@ AML_FIELD_UPDATE_WRITE_AS_ZEROS
Definition: amlcode.h:477
@ AML_FIELD_UPDATE_PRESERVE
Definition: amlcode.h:475

Referenced by AcpiExInsertIntoField().

◆ 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}
#define ACPI_NUM_PREDEFINED_REGIONS
Definition: actypes.h:874
#define ACPI_ADR_SPACE_DATA_TABLE
Definition: actypes.h:884
#define ACPI_USER_REGION_BEGIN
Definition: acconfig.h:197

Referenced by AcpiExCreateRegion(), and AcpiExSetupRegion().