ReactOS  0.4.15-dev-3453-gff89651
exfield.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acdispat.h"
#include "acinterp.h"
#include "amlcode.h"
Include dependency graph for exfield.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 
#define ACPI_INVALID_PROTOCOL_ID   0x80
 
#define ACPI_MAX_PROTOCOL_ID   0x0F
 
#define PCC_MASTER_SUBSPACE   3
 
#define GENERIC_SUBSPACE_COMMAND(a)   (4 == a || a == 5)
 
#define MASTER_SUBSPACE_COMMAND(a)   (12 <= a && a <= 15)
 

Functions

ACPI_STATUS AcpiExGetProtocolBufferLength (UINT32 ProtocolId, UINT32 *ReturnLength)
 
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)
 

Variables

static const UINT8 AcpiProtocolLengths []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 51 of file exfield.c.

◆ ACPI_INVALID_PROTOCOL_ID

#define ACPI_INVALID_PROTOCOL_ID   0x80

Definition at line 59 of file exfield.c.

◆ ACPI_MAX_PROTOCOL_ID

#define ACPI_MAX_PROTOCOL_ID   0x0F

Definition at line 60 of file exfield.c.

◆ GENERIC_SUBSPACE_COMMAND

#define GENERIC_SUBSPACE_COMMAND (   a)    (4 == a || a == 5)

Definition at line 90 of file exfield.c.

◆ MASTER_SUBSPACE_COMMAND

#define MASTER_SUBSPACE_COMMAND (   a)    (12 <= a && a <= 15)

Definition at line 91 of file exfield.c.

◆ PCC_MASTER_SUBSPACE

#define PCC_MASTER_SUBSPACE   3

Definition at line 82 of file exfield.c.

Function Documentation

◆ 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 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define ACPI_MAX_PROTOCOL_ID
Definition: exfield.c:60
#define ACPI_INVALID_PROTOCOL_ID
Definition: exfield.c:59
#define AE_INFO
Definition: acoutput.h:230
_In_ UINT ProtocolId
Definition: ndis.h:2924
static const UINT8 AcpiProtocolLengths[]
Definition: exfield.c:62
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_AML_PROTOCOL
Definition: acexcep.h:215
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiExReadSerialBus(), and AcpiExWriteSerialBus().

◆ 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) &&
192  {
193  /* SMBus, GSBus, IPMI serial */
194 
195  Status = AcpiExReadSerialBus (ObjDesc, RetBufferDesc);
197  }
198 
199  /*
200  * Allocate a buffer for the contents of the field.
201  *
202  * If the field is larger than the current integer width, create
203  * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
204  * the use of arithmetic operators on the returned value if the
205  * field size is equal or smaller than an Integer.
206  *
207  * However, all buffer fields created by CreateField operator needs to
208  * remain as a buffer to match other AML interpreter implementations.
209  *
210  * Note: Field.length is in bits.
211  */
213  ObjDesc->Field.BitLength);
214 
215  if (BufferLength > AcpiGbl_IntegerByteWidth ||
216  (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD &&
217  ObjDesc->BufferField.IsCreateField))
218  {
219  /* Field is too large for an Integer, create a Buffer instead */
220 
221  BufferDesc = AcpiUtCreateBufferObject (BufferLength);
222  if (!BufferDesc)
223  {
225  }
226  Buffer = BufferDesc->Buffer.Pointer;
227  }
228  else
229  {
230  /* Field will fit within an Integer (normal case) */
231 
232  BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
233  if (!BufferDesc)
234  {
236  }
237 
238  BufferLength = AcpiGbl_IntegerByteWidth;
239  Buffer = &BufferDesc->Integer.Value;
240  }
241 
242  if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
244  {
245  /* General Purpose I/O */
246 
247  Status = AcpiExReadGpio (ObjDesc, Buffer);
248  goto Exit;
249  }
250  else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
252  {
253  /*
254  * Reading from a PCC field unit does not require the handler because
255  * it only requires reading from the InternalPccBuffer.
256  */
258  "PCC FieldRead bits %u\n", ObjDesc->Field.BitLength));
259 
261  ObjDesc->Field.BaseByteOffset, (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (
262  ObjDesc->Field.BitLength));
263 
264  *RetBufferDesc = BufferDesc;
265  return AE_OK;
266  }
267 
269  "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
270  ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength));
272  "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
273  ObjDesc->CommonField.BitLength,
274  ObjDesc->CommonField.StartFieldBitOffset,
275  ObjDesc->CommonField.BaseByteOffset));
276 
277  /* Lock entire transaction if requested */
278 
279  AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
280 
281  /* Read from the field */
282 
284  AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
285 
286 
287 Exit:
288  if (ACPI_FAILURE (Status))
289  {
290  AcpiUtRemoveReference (BufferDesc);
291  }
292  else
293  {
294  *RetBufferDesc = BufferDesc;
295  }
296 
298 }
#define ACPI_DB_BFIELD
Definition: acoutput.h:168
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
ACPI_STATUS AcpiDsGetBufferFieldArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:196
void AcpiExReleaseGlobalLock(UINT32 FieldFlags)
Definition: exutils.c:270
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
ACPI_OBJECT_FIELD_COMMON CommonField
Definition: acobject.h:532
ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject(ACPI_SIZE BufferSize)
Definition: utobject.c:258
#define ACPI_ADR_SPACE_GPIO
Definition: actypes.h:860
#define AE_AML_NO_OPERAND
Definition: acexcep.h:181
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO BOOLEAN IsCreateField
Definition: acobject.h:384
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
ACPI_STATUS AcpiExReadSerialBus(ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
Definition: exserial.c:182
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define ACPI_ADR_SPACE_PLATFORM_COMM
Definition: actypes.h:862
void AcpiExAcquireGlobalLock(UINT32 FieldFlags)
Definition: exutils.c:225
Definition: bufpool.h:45
ACPI_OBJECT_REGION Region
Definition: acobject.h:526
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_STATUS AcpiExExtractFromField(ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer, UINT32 BufferLength)
Definition: exfldio.c:723
Status
Definition: gdiplustypes.h:24
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:521
static void Exit(void)
Definition: sock.c:1331
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_ADR_SPACE_IPMI
Definition: actypes.h:859
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:708
#define ACPI_ADR_SPACE_GSBUS
Definition: actypes.h:861
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:519
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
union acpi_operand_object * RegionObj
Definition: acobject.h:345
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:693
ACPI_OBJECT_COMMON Common
Definition: acobject.h:518
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:789
ACPI_STATUS AcpiExReadGpio(ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer)
Definition: exserial.c:70
#define ACPI_ADR_SPACE_PLATFORM_RT
Definition: actypes.h:863
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
ACPI_OBJECT_REGION_FIELD Field
Definition: acobject.h:533
#define ACPI_ADR_SPACE_SMBUS
Definition: actypes.h:856
#define ACPI_ROUND_BITS_UP_TO_BYTES(a)
Definition: acmacros.h:256
ACPI_OBJECT_BUFFER_FIELD BufferField
Definition: acobject.h:534
unsigned long long UINT64
#define AE_OK
Definition: acexcep.h:97

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

◆ AcpiExWriteDataToField()

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

Definition at line 316 of file exfield.c.

320 {
324  void *Buffer;
325 
326 
327  ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc);
328 
329 
330  /* Parameter validation */
331 
332  if (!SourceDesc || !ObjDesc)
333  {
335  }
336 
337  if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
338  {
339  /*
340  * If the BufferField arguments have not been previously evaluated,
341  * evaluate them now and save the results.
342  */
343  if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
344  {
346  if (ACPI_FAILURE (Status))
347  {
349  }
350  }
351  }
352  else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
354  {
355  /* General Purpose I/O */
356 
357  Status = AcpiExWriteGpio (SourceDesc, ObjDesc, ResultDesc);
359  }
360  else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
365  {
366  /* SMBus, GSBus, IPMI serial */
367 
368  Status = AcpiExWriteSerialBus (SourceDesc, ObjDesc, ResultDesc);
370  }
371  else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
373  {
374  /*
375  * According to the spec a write to the COMD field will invoke the
376  * region handler. Otherwise, write to the PccInternal buffer. This
377  * implementation will use the offsets specified rather than the name
378  * of the field. This is considered safer because some firmware tools
379  * are known to obfiscate named objects.
380  */
382  ObjDesc->Field.BitLength);
384  ObjDesc->Field.BaseByteOffset,
385  SourceDesc->Buffer.Pointer, DataLength);
386 
387  if ((ObjDesc->Field.RegionObj->Region.Address == PCC_MASTER_SUBSPACE &&
388  MASTER_SUBSPACE_COMMAND (ObjDesc->Field.BaseByteOffset)) ||
389  GENERIC_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  {
409  case ACPI_TYPE_INTEGER:
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 }
#define ACPI_DB_BFIELD
Definition: acoutput.h:168
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
ACPI_STATUS AcpiDsGetBufferFieldArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:196
void AcpiExReleaseGlobalLock(UINT32 FieldFlags)
Definition: exutils.c:270
#define GENERIC_SUBSPACE_COMMAND(a)
Definition: exfield.c:90
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define ACPI_TYPE_BUFFER
Definition: actypes.h:682
#define ACPI_TYPE_INTEGER
Definition: actypes.h:680
ACPI_OBJECT_FIELD_COMMON CommonField
Definition: acobject.h:532
#define ACPI_ADR_SPACE_GPIO
Definition: actypes.h:860
#define AE_AML_NO_OPERAND
Definition: acexcep.h:181
#define PCC_MASTER_SUBSPACE
Definition: exfield.c:82
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiExWriteGpio(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
Definition: exserial.c:121
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define ACPI_ADR_SPACE_PLATFORM_COMM
Definition: actypes.h:862
void AcpiExAcquireGlobalLock(UINT32 FieldFlags)
Definition: exutils.c:225
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
Definition: bufpool.h:45
ACPI_OBJECT_REGION Region
Definition: acobject.h:526
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define MASTER_SUBSPACE_COMMAND(a)
Definition: exfield.c:91
Status
Definition: gdiplustypes.h:24
ACPI_STATUS AcpiExWriteSerialBus(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnBuffer)
Definition: exserial.c:297
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:521
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_ADR_SPACE_IPMI
Definition: actypes.h:859
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:708
#define ACPI_ADR_SPACE_GSBUS
Definition: actypes.h:861
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:519
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ACPI_OBJECT_STRING String
Definition: acobject.h:520
union acpi_operand_object * RegionObj
Definition: acobject.h:345
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:693
ACPI_OBJECT_COMMON Common
Definition: acobject.h:518
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
#define ACPI_ADR_SPACE_PLATFORM_RT
Definition: actypes.h:863
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
ACPI_OBJECT_REGION_FIELD Field
Definition: acobject.h:533
ACPI_PHYSICAL_ADDRESS Address
Definition: acobject.h:206
#define ACPI_ADR_SPACE_SMBUS
Definition: actypes.h:856
#define ACPI_TYPE_STRING
Definition: actypes.h:681
#define ACPI_ROUND_BITS_UP_TO_BYTES(a)
Definition: acmacros.h:256
ACPI_STATUS AcpiExInsertIntoField(ACPI_OPERAND_OBJECT *ObjDesc, void *Buffer, UINT32 BufferLength)
Definition: exfldio.c:883
unsigned long long UINT64
ACPI_STATUS AcpiExAccessRegion(ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, UINT64 *Value, UINT32 Function)
Definition: exfldio.c:249
#define AE_OK
Definition: acexcep.h:97
#define ACPI_WRITE
Definition: actypes.h:744

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

Variable Documentation

◆ AcpiProtocolLengths

const UINT8 AcpiProtocolLengths[]
static
Initial value:
=
{
0x00,
0x01,
0x01,
0x02,
0xFF,
0xFF,
0x02,
0xFF,
0xFF,
0xFF
}
#define ACPI_INVALID_PROTOCOL_ID
Definition: exfield.c:59

Definition at line 62 of file exfield.c.

Referenced by AcpiExGetProtocolBufferLength().