summaryrefslogtreecommitdiffstats
path: root/sys/contrib
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>2001-11-28 04:34:52 +0000
committermsmith <msmith@FreeBSD.org>2001-11-28 04:34:52 +0000
commit02c92eb332c4d56cd990b07b9cecc1ada735ed68 (patch)
treee6f6c1568b015bf309e2b21a79a3529655d3f173 /sys/contrib
parentf06e6295c8dce22b1649c23d59705ab3fefdc9ce (diff)
downloadFreeBSD-src-02c92eb332c4d56cd990b07b9cecc1ada735ed68.zip
FreeBSD-src-02c92eb332c4d56cd990b07b9cecc1ada735ed68.tar.gz
Merge local changes.
Add a fix for a minor error in the PCI routing table creation handler where the correct size for the buffer is not returned.
Diffstat (limited to 'sys/contrib')
-rw-r--r--sys/contrib/dev/acpica/acconfig.h28
-rw-r--r--sys/contrib/dev/acpica/acgcc.h18
-rw-r--r--sys/contrib/dev/acpica/acpiosxf.h6
-rw-r--r--sys/contrib/dev/acpica/acpixf.h26
-rw-r--r--sys/contrib/dev/acpica/exfldio.c729
-rw-r--r--sys/contrib/dev/acpica/hwsleep.c86
-rw-r--r--sys/contrib/dev/acpica/psparse.c111
-rw-r--r--sys/contrib/dev/acpica/rscreate.c2
-rw-r--r--sys/contrib/dev/acpica/tbget.c9
9 files changed, 575 insertions, 440 deletions
diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h
index fb97fc2..9a48eaa 100644
--- a/sys/contrib/dev/acpica/acconfig.h
+++ b/sys/contrib/dev/acpica/acconfig.h
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Name: acconfig.h - Global configuration constants
- * $Revision: 74 $
+ * $Revision: 78 $
*
*****************************************************************************/
@@ -125,12 +125,13 @@
*****************************************************************************/
/*
- * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI
- * subsystem. This includes the DEBUG_PRINT output statements
- * When disabled, all DEBUG_PRINT statements are compiled out.
+ * ACPI_DEBUG - This switch enables all the debug facilities of the
+ * ACPI subsystem. This includes the DEBUG_PRINT output
+ * statements. When disabled, all DEBUG_PRINT
+ * statements are compiled out.
*
* ACPI_APPLICATION - Use this switch if the subsystem is going to be run
- * at the application level.
+ * at the application level.
*
*/
@@ -144,7 +145,7 @@
/* Version string */
-#define ACPI_CA_VERSION 0x20011018
+#define ACPI_CA_VERSION 0x20011120
/* Version of ACPI supported */
@@ -153,17 +154,17 @@
/* Maximum objects in the various object caches */
-#define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */
+#define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */
#define MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
#define MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */
#define MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */
-#define MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks (method execution) */
+#define MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */
/* String size constants */
#define MAX_STRING_LENGTH 512
-#define PATHNAME_MAX 256 /* A full namespace pathname */
+#define PATHNAME_MAX 256 /* A full namespace pathname */
/* Maximum count for a semaphore object */
@@ -232,7 +233,7 @@
/* Names within the namespace are 4 bytes long */
#define ACPI_NAME_SIZE 4
-#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 INT8 for separator */
+#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
#define PATH_SEPARATOR '.'
@@ -244,10 +245,15 @@
#define HI_RSDP_WINDOW_SIZE 0x20000
#define RSDP_SCAN_STEP 16
+
+/* Operation regions */
+
+#define ACPI_NUM_PREDEFINED_REGIONS 7
+#define ACPI_USER_REGION_BEGIN 0x80
+
/* Maximum SpaceIds for Operation Regions */
#define ACPI_MAX_ADDRESS_SPACE 255
-#define ACPI_NUM_ADDRESS_SPACES 256
#endif /* _ACCONFIG_H */
diff --git a/sys/contrib/dev/acpica/acgcc.h b/sys/contrib/dev/acpica/acgcc.h
index 9ca66f1..5581e48 100644
--- a/sys/contrib/dev/acpica/acgcc.h
+++ b/sys/contrib/dev/acpica/acgcc.h
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Name: acgcc.h - GCC specific defines, etc.
- * $Revision: 14 $
+ * $Revision: 15 $
*
*****************************************************************************/
@@ -235,17 +235,17 @@
* Math helper asm macros
*/
#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
- asm("divl %2;" \
- :"=a"(q32), "=d"(r32) \
- :"r"(d32), \
- "0"(n_lo), "1"(n_hi))
+ asm("divl %2;" \
+ :"=a"(q32), "=d"(r32) \
+ :"r"(d32), \
+ "0"(n_lo), "1"(n_hi))
#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
- asm("shrl $1,%2;" \
- "rcrl $1,%3;" \
- :"=r"(n_hi), "=r"(n_lo) \
- :"0"(n_hi), "1"(n_lo))
+ asm("shrl $1,%2;" \
+ "rcrl $1,%3;" \
+ :"=r"(n_hi), "=r"(n_lo) \
+ :"0"(n_hi), "1"(n_lo))
/*! [End] no source code translation !*/
diff --git a/sys/contrib/dev/acpica/acpiosxf.h b/sys/contrib/dev/acpica/acpiosxf.h
index 57c9f97..e7a8637 100644
--- a/sys/contrib/dev/acpica/acpiosxf.h
+++ b/sys/contrib/dev/acpica/acpiosxf.h
@@ -294,7 +294,7 @@ AcpiOsReadPort (
ACPI_STATUS
AcpiOsWritePort (
ACPI_IO_ADDRESS Address,
- NATIVE_UINT Value,
+ ACPI_INTEGER Value,
UINT32 Width);
@@ -312,7 +312,7 @@ AcpiOsReadMemory (
ACPI_STATUS
AcpiOsWriteMemory (
ACPI_PHYSICAL_ADDRESS Address,
- NATIVE_UINT Value,
+ ACPI_INTEGER Value,
UINT32 Width);
@@ -332,7 +332,7 @@ ACPI_STATUS
AcpiOsWritePciConfiguration (
ACPI_PCI_ID *PciId,
UINT32 Register,
- NATIVE_UINT Value,
+ ACPI_INTEGER Value,
UINT32 Width);
diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h
index 2c25e15..ec03fb4 100644
--- a/sys/contrib/dev/acpica/acpixf.h
+++ b/sys/contrib/dev/acpica/acpixf.h
@@ -158,6 +158,10 @@ const char *
AcpiFormatException (
ACPI_STATUS Exception);
+ACPI_STATUS
+AcpiPurgeCachedObjects (
+ void);
+
/*
* ACPI Memory manager
@@ -249,6 +253,23 @@ AcpiGetHandle (
ACPI_STRING Pathname,
ACPI_HANDLE *RetHandle);
+ACPI_STATUS
+AcpiAttachData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler,
+ void *Data);
+
+ACPI_STATUS
+AcpiDetachData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler);
+
+ACPI_STATUS
+AcpiGetData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler,
+ void **Data);
+
/*
* Object manipulation and enumeration
@@ -406,6 +427,11 @@ ACPI_STATUS
AcpiGetFirmwareWakingVector (
ACPI_PHYSICAL_ADDRESS *PhysicalAddress);
+
+ACPI_STATUS
+AcpiEnterSleepStatePrep (
+ UINT8 SleepState);
+
ACPI_STATUS
AcpiEnterSleepState (
UINT8 SleepState);
diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c
index c10b336..7e60ea8 100644
--- a/sys/contrib/dev/acpica/exfldio.c
+++ b/sys/contrib/dev/acpica/exfldio.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: exfldio - Aml Field I/O
- * $Revision: 66 $
+ * $Revision: 75 $
*
*****************************************************************************/
@@ -132,20 +132,21 @@
/*******************************************************************************
*
- * FUNCTION: AcpiExSetupField
+ * FUNCTION: AcpiExSetupRegion
*
- * PARAMETERS: *ObjDesc - Field to be read or written
- * FieldDatumByteOffset - Current offset into the field
+ * PARAMETERS: *ObjDesc - Field to be read or written
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
*
* RETURN: Status
*
* DESCRIPTION: Common processing for AcpiExExtractFromField and
- * AcpiExInsertIntoField
+ * AcpiExInsertIntoField. Initialize the
*
******************************************************************************/
ACPI_STATUS
-AcpiExSetupField (
+AcpiExSetupRegion (
ACPI_OPERAND_OBJECT *ObjDesc,
UINT32 FieldDatumByteOffset)
{
@@ -153,7 +154,7 @@ AcpiExSetupField (
ACPI_OPERAND_OBJECT *RgnDesc;
- FUNCTION_TRACE_U32 ("ExSetupField", FieldDatumByteOffset);
+ FUNCTION_TRACE_U32 ("ExSetupRegion", FieldDatumByteOffset);
RgnDesc = ObjDesc->CommonField.RegionObj;
@@ -171,7 +172,6 @@ AcpiExSetupField (
*/
if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID))
{
-
Status = AcpiDsGetRegionArguments (RgnDesc);
if (ACPI_FAILURE (Status))
{
@@ -184,9 +184,9 @@ AcpiExSetupField (
* length of one field datum (access width) must fit within the region.
* (Region length is specified in bytes)
*/
- if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset +
- FieldDatumByteOffset +
- ObjDesc->CommonField.AccessByteWidth))
+ if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset
+ + FieldDatumByteOffset
+ + ObjDesc->CommonField.AccessByteWidth))
{
if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
{
@@ -205,7 +205,7 @@ AcpiExSetupField (
* exceeds region length, indicate an error
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Field base+offset+width %X+%X+%X exceeds region size (%X bytes) field=%p region=%p\n",
+ "Field Base+Offset+Width %X+%X+%X exceeds region size (%X bytes) field=%p region=%p\n",
ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset,
ObjDesc->CommonField.AccessByteWidth,
RgnDesc->Region.Length, ObjDesc, RgnDesc));
@@ -219,121 +219,427 @@ AcpiExSetupField (
/*******************************************************************************
*
- * FUNCTION: AcpiExReadFieldDatum
+ * FUNCTION: AcpiExAccessRegion
*
- * PARAMETERS: *ObjDesc - Field to be read
- * *Value - Where to store value (must be 32 bits)
+ * PARAMETERS: *ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * *Value - Where to store value (must be 32 bits)
+ * ReadWrite - Read or Write flag
*
* RETURN: Status
*
- * DESCRIPTION: Retrieve the value of the given field
+ * DESCRIPTION: Read or Write a single field datum to an Operation Region.
*
******************************************************************************/
ACPI_STATUS
-AcpiExReadFieldDatum (
+AcpiExAccessRegion (
ACPI_OPERAND_OBJECT *ObjDesc,
UINT32 FieldDatumByteOffset,
- UINT32 *Value)
+ ACPI_INTEGER *Value,
+ UINT32 ReadWrite)
{
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT *RgnDesc;
ACPI_PHYSICAL_ADDRESS Address;
- UINT32 LocalValue;
- FUNCTION_TRACE_U32 ("ExReadFieldDatum", FieldDatumByteOffset);
+ FUNCTION_TRACE ("AcpiExAccessRegion");
- if (!Value)
+ /*
+ * The physical address of this field datum is:
+ *
+ * 1) The base of the region, plus
+ * 2) The base offset of the field, plus
+ * 3) The current offset into the field
+ */
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+ Address = RgnDesc->Region.Address
+ + ObjDesc->CommonField.BaseByteOffset
+ + FieldDatumByteOffset;
+
+ if (ReadWrite == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
+ }
+ else
{
- LocalValue = 0;
- Value = &LocalValue; /* support reads without saving value */
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
}
- /* Clear the entire return buffer first, [Very Important!] */
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
+ " Region[%s-%X] Width %X Base:Off %X:%X at %8.8X%8.8X\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId,
+ ObjDesc->CommonField.AccessBitWidth,
+ ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset,
+ HIDWORD (Address), LODWORD (Address)));
- *Value = 0;
+ /* Invoke the appropriate AddressSpace/OpRegion handler */
+
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ReadWrite,
+ Address, ObjDesc->CommonField.AccessBitWidth, Value);
+
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_IMPLEMENTED)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Region %s(%X) not implemented\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+
+ else if (Status == AE_NOT_EXIST)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Region %s(%X) has no handler\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRegisterOverflow
+ *
+ * PARAMETERS: *ObjDesc - Register(Field) to be written
+ * Value - Value to be stored
+ *
+ * RETURN: TRUE if value overflows the field, FALSE otherwise
+ *
+ * DESCRIPTION: Check if a value is out of range of the field being written.
+ * Used to check if the values written to Index and Bank registers
+ * are out of range. Normally, the value is simply truncated
+ * to fit the field, but this case is most likely a serious
+ * coding error in the ASL.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiExRegisterOverflow (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_INTEGER Value)
+{
/*
- * BufferFields - Read from a Buffer
- * Other Fields - Read from a Operation Region.
+ * Is the Value larger than the maximum value that can fit into
+ * the field?
+ */
+ if (Value >= (ACPI_INTEGER) (1 << ObjDesc->CommonField.BitLength))
+ {
+ return (TRUE);
+ }
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExFieldDatumIo
+ *
+ * PARAMETERS: *ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * *Value - Where to store value (must be 64 bits)
+ * ReadWrite - Read or Write flag
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single datum of a field. The FieldType is
+ * demultiplexed here to handle the different types of fields
+ * (BufferField, RegionField, IndexField, BankField)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExFieldDatumIo (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ ACPI_INTEGER *Value,
+ UINT32 ReadWrite)
+{
+ ACPI_STATUS Status;
+ ACPI_INTEGER LocalValue;
+
+
+ FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset);
+
+
+ if (ReadWrite == ACPI_READ)
+ {
+ if (!Value)
+ {
+ LocalValue = 0;
+ Value = &LocalValue; /* To support reads without saving return value */
+ }
+
+ /* Clear the entire return buffer first, [Very Important!] */
+
+ *Value = 0;
+ }
+
+ /*
+ * The four types of fields are:
+ *
+ * BufferFields - Read/write from/to a Buffer
+ * RegionFields - Read/write from/to a Operation Region.
+ * BankFields - Write to a Bank Register, then read/write from/to an OpRegion
+ * IndexFields - Write to an Index Register, then read/write from/to a Data Register
*/
switch (ObjDesc->Common.Type)
{
case ACPI_TYPE_BUFFER_FIELD:
-
/*
- * For BufferFields, we only need to copy the data from the
- * source buffer. Length is the field width in bytes.
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
*/
- MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer
- + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset,
- ObjDesc->CommonField.AccessByteWidth);
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /*
+ * Copy the data from the source buffer.
+ * Length is the field width in bytes.
+ */
+ MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer
+ + ObjDesc->BufferField.BaseByteOffset
+ + FieldDatumByteOffset,
+ ObjDesc->CommonField.AccessByteWidth);
+ }
+ else
+ {
+ /*
+ * Copy the data to the target buffer.
+ * Length is the field width in bytes.
+ */
+ MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer
+ + ObjDesc->BufferField.BaseByteOffset
+ + FieldDatumByteOffset,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+
Status = AE_OK;
break;
- case INTERNAL_TYPE_REGION_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
+ /* Ensure that the BankValue is not beyond the capacity of the register */
+
+ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
+ ObjDesc->BankField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
/*
- * For other fields, we need to go through an Operation Region
- * (Only types that will get here are RegionFields and BankFields)
+ * For BankFields, we must write the BankValue to the BankRegister
+ * (itself a RegionField) before we can access the data.
*/
- Status = AcpiExSetupField (ObjDesc, FieldDatumByteOffset);
+ Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
+ &ObjDesc->BankField.Value,
+ sizeof (ObjDesc->BankField.Value));
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
- * The physical address of this field datum is:
- *
- * 1) The base of the region, plus
- * 2) The base offset of the field, plus
- * 3) The current offset into the field
+ * Now that the Bank has been selected, fall through to the
+ * RegionField case and write the datum to the Operation Region
*/
- RgnDesc = ObjDesc->CommonField.RegionObj;
- Address = RgnDesc->Region.Address + ObjDesc->CommonField.BaseByteOffset +
- FieldDatumByteOffset;
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Region %s(%X) width %X base:off %X:%X at %8.8X%8.8X\n",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId, ObjDesc->CommonField.AccessBitWidth,
- ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset,
- HIDWORD(Address), LODWORD(Address)));
+ /* No break; ! */
- /* Invoke the appropriate AddressSpace/OpRegion handler */
- Status = AcpiEvAddressSpaceDispatch (RgnDesc, ACPI_READ_ADR_SPACE,
- Address, ObjDesc->CommonField.AccessBitWidth, Value);
- if (Status == AE_NOT_IMPLEMENTED)
+ case INTERNAL_TYPE_REGION_FIELD:
+ /*
+ * For simple RegionFields, we just directly access the owning
+ * Operation Region.
+ */
+ Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
+ if (ACPI_FAILURE (Status))
{
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %s(%X) not implemented\n",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId));
+ return_ACPI_STATUS (Status);
}
- else if (Status == AE_NOT_EXIST)
+ Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
+ ReadWrite);
+ break;
+
+
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+
+ /* Ensure that the IndexValue is not beyond the capacity of the register */
+
+ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
+ ObjDesc->IndexField.Value))
{
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %s(%X) has no handler\n",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId));
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /* Write the index value to the IndexRegister (itself a RegionField) */
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
+ &ObjDesc->IndexField.Value,
+ sizeof (ObjDesc->IndexField.Value));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /* Read the datum from the DataRegister */
+
+ Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+ else
+ {
+ /* Write the datum to the Data register */
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
+ Value, ObjDesc->CommonField.AccessByteWidth);
}
break;
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, wrong source type - %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, Wrong object type - %s\n",
ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type)));
Status = AE_AML_INTERNAL;
break;
}
+ if (ACPI_SUCCESS (Status))
+ {
+ if (ReadWrite == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read=%8.8X%8.8X\n",
+ HIDWORD(*Value), LODWORD(*Value)));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written=%8.8X%8.8X\n",
+ HIDWORD(*Value), LODWORD(*Value)));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExWriteWithUpdateRule
+ *
+ * PARAMETERS: *ObjDesc - Field to be set
+ * Value - Value to store
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExWriteWithUpdateRule (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_INTEGER Mask,
+ ACPI_INTEGER FieldValue,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_INTEGER MergedValue;
+ ACPI_INTEGER CurrentValue;
+
+
+ FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask);
+
+
+ /* Start with the new bits */
+
+ MergedValue = FieldValue;
+
+ /* If the mask is all ones, we don't need to worry about the update rule */
+
+ if (Mask != ACPI_UINT32_MAX)
+ {
+ /* Decode the update rule */
+
+ switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
+ {
+ case AML_FIELD_UPDATE_PRESERVE:
+ /*
+ * Check if update rule needs to be applied (not if mask is all
+ * ones) The left shift drops the bits we want to ignore.
+ */
+ if ((~Mask << (sizeof (Mask) * 8 -
+ ObjDesc->CommonField.AccessBitWidth)) != 0)
+ {
+ /*
+ * Read the current contents of the byte/word/dword containing
+ * the field, and merge with the new field value.
+ */
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &CurrentValue, ACPI_READ);
+ MergedValue |= (CurrentValue & ~Mask);
+ }
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ONES:
+
+ /* Set positions outside the field to all ones */
+
+ MergedValue |= ~Mask;
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
+
+ /* Set positions outside the field to all zeros */
+
+ MergedValue &= Mask;
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "WriteWithUpdateRule: Unknown UpdateRule setting: %x\n",
+ (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ break;
+ }
+ }
+
+ /* Write the merged value */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &MergedValue, ACPI_WRITE);
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Returned value=%08X \n", *Value));
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Mask %8.8X%8.8X DatumOffset %X Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
+ HIDWORD(Mask), LODWORD(Mask),
+ FieldDatumByteOffset,
+ HIDWORD(FieldValue), LODWORD(FieldValue),
+ HIDWORD(MergedValue),LODWORD(MergedValue)));
return_ACPI_STATUS (Status);
}
@@ -343,22 +649,22 @@ AcpiExReadFieldDatum (
*
* FUNCTION: AcpiExGetBufferDatum
*
- * PARAMETERS: MergedDatum - Value to store
- * Buffer - Receiving buffer
- * ByteGranularity - 1/2/4 Granularity of the field
+ * PARAMETERS: Datum - Where the Datum is returned
+ * Buffer - Raw field buffer
+ * ByteGranularity - 1/2/4/8 Granularity of the field
* (aka Datum Size)
* Offset - Datum offset into the buffer
*
* RETURN: none
*
- * DESCRIPTION: Store the merged datum to the buffer according to the
+ * DESCRIPTION: Get a datum from the buffer according to the buffer field
* byte granularity
*
******************************************************************************/
-static void
+void
AcpiExGetBufferDatum(
- UINT32 *Datum,
+ ACPI_INTEGER *Datum,
void *Buffer,
UINT32 ByteGranularity,
UINT32 Offset)
@@ -380,6 +686,10 @@ AcpiExGetBufferDatum(
case ACPI_FIELD_DWORD_GRANULARITY:
MOVE_UNALIGNED32_TO_32 (Datum, &(((UINT32 *) Buffer) [Offset]));
break;
+
+ case ACPI_FIELD_QWORD_GRANULARITY:
+ MOVE_UNALIGNED64_TO_64 (Datum, &(((UINT64 *) Buffer) [Offset]));
+ break;
}
}
@@ -390,7 +700,7 @@ AcpiExGetBufferDatum(
*
* PARAMETERS: MergedDatum - Value to store
* Buffer - Receiving buffer
- * ByteGranularity - 1/2/4 Granularity of the field
+ * ByteGranularity - 1/2/4/8 Granularity of the field
* (aka Datum Size)
* Offset - Datum offset into the buffer
*
@@ -401,9 +711,9 @@ AcpiExGetBufferDatum(
*
******************************************************************************/
-static void
+void
AcpiExSetBufferDatum (
- UINT32 MergedDatum,
+ ACPI_INTEGER MergedDatum,
void *Buffer,
UINT32 ByteGranularity,
UINT32 Offset)
@@ -425,6 +735,10 @@ AcpiExSetBufferDatum (
case ACPI_FIELD_DWORD_GRANULARITY:
MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[Offset]), &MergedDatum);
break;
+
+ case ACPI_FIELD_QWORD_GRANULARITY:
+ MOVE_UNALIGNED64_TO_64 (&(((UINT64 *) Buffer)[Offset]), &MergedDatum);
+ break;
}
}
@@ -451,9 +765,9 @@ AcpiExExtractFromField (
ACPI_STATUS Status;
UINT32 FieldDatumByteOffset;
UINT32 DatumOffset;
- UINT32 PreviousRawDatum;
- UINT32 ThisRawDatum = 0;
- UINT32 MergedDatum = 0;
+ ACPI_INTEGER PreviousRawDatum;
+ ACPI_INTEGER ThisRawDatum = 0;
+ ACPI_INTEGER MergedDatum = 0;
UINT32 ByteFieldLength;
UINT32 DatumCount;
@@ -467,7 +781,8 @@ AcpiExExtractFromField (
ByteFieldLength = ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
if (ByteFieldLength > BufferLength)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Field size %X (bytes) too large for buffer (%X)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Field size %X (bytes) too large for buffer (%X)\n",
ByteFieldLength, BufferLength));
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
@@ -475,7 +790,8 @@ AcpiExExtractFromField (
/* Convert field byte count to datum count, round up if necessary */
- DatumCount = ROUND_UP_TO (ByteFieldLength, ObjDesc->CommonField.AccessByteWidth);
+ DatumCount = ROUND_UP_TO (ByteFieldLength,
+ ObjDesc->CommonField.AccessByteWidth);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n",
@@ -494,7 +810,8 @@ AcpiExExtractFromField (
FieldDatumByteOffset = 0;
DatumOffset= 0;
- Status = AcpiExReadFieldDatum (ObjDesc, FieldDatumByteOffset, &PreviousRawDatum);
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &PreviousRawDatum, ACPI_READ);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@@ -504,7 +821,7 @@ AcpiExExtractFromField (
/* We might actually be done if the request fits in one datum */
if ((DatumCount == 1) &&
- (ObjDesc->CommonField.AccessFlags & AFIELD_SINGLE_DATUM))
+ (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM))
{
/* 1) Shift the valid data bits down to start at bit 0 */
@@ -537,18 +854,19 @@ AcpiExExtractFromField (
* to perform a final read, since this would potentially read
* past the end of the region.
*
- * TBD: [Investigate] It may make more sense to just split the aligned
- * and non-aligned cases since the aligned case is so very simple,
+ * We could just split the aligned and non-aligned cases since the
+ * aligned case is so very simple, but this would require more code.
*/
- if ((ObjDesc->CommonField.StartFieldBitOffset != 0) ||
- ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
+ if ((ObjDesc->CommonField.StartFieldBitOffset != 0) ||
+ ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
(DatumOffset < (DatumCount -1))))
{
/*
* Get the next raw datum, it contains some or all bits
* of the current field datum
*/
- Status = AcpiExReadFieldDatum (ObjDesc, FieldDatumByteOffset, &ThisRawDatum);
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &ThisRawDatum, ACPI_READ);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@@ -564,7 +882,6 @@ AcpiExExtractFromField (
MergedDatum = PreviousRawDatum;
}
-
else
{
/*
@@ -599,8 +916,8 @@ AcpiExExtractFromField (
* Store the merged field datum in the caller's buffer, according to
* the granularity of the field (size of each datum).
*/
- AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth,
- DatumOffset);
+ AcpiExSetBufferDatum (MergedDatum, Buffer,
+ ObjDesc->CommonField.AccessByteWidth, DatumOffset);
/*
* Save the raw datum that was just acquired since it may contain bits
@@ -616,218 +933,6 @@ AcpiExExtractFromField (
/*******************************************************************************
*
- * FUNCTION: AcpiExWriteFieldDatum
- *
- * PARAMETERS: *ObjDesc - Field to be set
- * Value - Value to store
- *
- * RETURN: Status
- *
- * DESCRIPTION: Store the value into the given field
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExWriteFieldDatum (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 FieldDatumByteOffset,
- UINT32 Value)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *RgnDesc = NULL;
- ACPI_PHYSICAL_ADDRESS Address;
-
-
- FUNCTION_TRACE_U32 ("ExWriteFieldDatum", FieldDatumByteOffset);
-
-
- /*
- * BufferFields - Read from a Buffer
- * Other Fields - Read from a Operation Region.
- */
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_BUFFER_FIELD:
-
- /*
- * For BufferFields, we only need to copy the data to the
- * target buffer. Length is the field width in bytes.
- */
- MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer
- + ObjDesc->BufferField.BaseByteOffset + FieldDatumByteOffset,
- &Value, ObjDesc->CommonField.AccessByteWidth);
- Status = AE_OK;
- break;
-
-
- case INTERNAL_TYPE_REGION_FIELD:
- case INTERNAL_TYPE_BANK_FIELD:
-
- /*
- * For other fields, we need to go through an Operation Region
- * (Only types that will get here are RegionFields and BankFields)
- */
- Status = AcpiExSetupField (ObjDesc, FieldDatumByteOffset);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * The physical address of this field datum is:
- *
- * 1) The base of the region, plus
- * 2) The base offset of the field, plus
- * 3) The current offset into the field
- */
- RgnDesc = ObjDesc->CommonField.RegionObj;
- Address = RgnDesc->Region.Address +
- ObjDesc->CommonField.BaseByteOffset +
- FieldDatumByteOffset;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Store %X in Region %s(%X) at %8.8X%8.8X width %X\n",
- Value, AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId, HIDWORD(Address), LODWORD(Address),
- ObjDesc->CommonField.AccessBitWidth));
-
- /* Invoke the appropriate AddressSpace/OpRegion handler */
-
- Status = AcpiEvAddressSpaceDispatch (RgnDesc, ACPI_WRITE_ADR_SPACE,
- Address, ObjDesc->CommonField.AccessBitWidth, &Value);
-
- if (Status == AE_NOT_IMPLEMENTED)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "**** Region type %s(%X) not implemented\n",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId));
- }
-
- else if (Status == AE_NOT_EXIST)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "**** Region type %s(%X) does not have a handler\n",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId));
- }
-
- break;
-
-
- default:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, wrong source type - %s\n",
- ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type)));
- Status = AE_AML_INTERNAL;
- break;
- }
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value written=%08X \n", Value));
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExWriteFieldDatumWithUpdateRule
- *
- * PARAMETERS: *ObjDesc - Field to be set
- * Value - Value to store
- *
- * RETURN: Status
- *
- * DESCRIPTION: Apply the field update rule to a field write
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExWriteFieldDatumWithUpdateRule (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 Mask,
- UINT32 FieldValue,
- UINT32 FieldDatumByteOffset)
-{
- ACPI_STATUS Status = AE_OK;
- UINT32 MergedValue;
- UINT32 CurrentValue;
-
-
- FUNCTION_TRACE ("ExWriteFieldDatumWithUpdateRule");
-
-
- /* Start with the new bits */
-
- MergedValue = FieldValue;
-
- /* If the mask is all ones, we don't need to worry about the update rule */
-
- if (Mask != ACPI_UINT32_MAX)
- {
- /* Decode the update rule */
-
- switch (ObjDesc->CommonField.UpdateRule)
- {
- case UPDATE_PRESERVE:
- /*
- * Check if update rule needs to be applied (not if mask is all
- * ones) The left shift drops the bits we want to ignore.
- */
- if ((~Mask << (sizeof (Mask) * 8 -
- ObjDesc->CommonField.AccessBitWidth)) != 0)
- {
- /*
- * Read the current contents of the byte/word/dword containing
- * the field, and merge with the new field value.
- */
- Status = AcpiExReadFieldDatum (ObjDesc, FieldDatumByteOffset,
- &CurrentValue);
- MergedValue |= (CurrentValue & ~Mask);
- }
- break;
-
-
- case UPDATE_WRITE_AS_ONES:
-
- /* Set positions outside the field to all ones */
-
- MergedValue |= ~Mask;
- break;
-
-
- case UPDATE_WRITE_AS_ZEROS:
-
- /* Set positions outside the field to all zeros */
-
- MergedValue &= Mask;
- break;
-
-
- default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "WriteWithUpdateRule: Unknown UpdateRule setting: %x\n",
- ObjDesc->CommonField.UpdateRule));
- return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
- break;
- }
- }
-
-
- /* Write the merged value */
-
- Status = AcpiExWriteFieldDatum (ObjDesc, FieldDatumByteOffset,
- MergedValue);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Mask %X DatumOffset %X Value %X, MergedValue %X\n",
- Mask, FieldDatumByteOffset, FieldValue, MergedValue));
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: AcpiExInsertIntoField
*
* PARAMETERS: *ObjDesc - Field to be set
@@ -848,10 +953,10 @@ AcpiExInsertIntoField (
ACPI_STATUS Status;
UINT32 FieldDatumByteOffset;
UINT32 DatumOffset;
- UINT32 Mask;
- UINT32 MergedDatum;
- UINT32 PreviousRawDatum;
- UINT32 ThisRawDatum;
+ ACPI_INTEGER Mask;
+ ACPI_INTEGER MergedDatum;
+ ACPI_INTEGER PreviousRawDatum;
+ ACPI_INTEGER ThisRawDatum;
UINT32 ByteFieldLength;
UINT32 DatumCount;
@@ -871,8 +976,6 @@ AcpiExInsertIntoField (
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Buffer length %X too small for field %X\n",
BufferLength, ByteFieldLength));
- /* TBD: Need a better error code */
-
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
}
@@ -913,7 +1016,7 @@ AcpiExInsertIntoField (
/* If the field fits in one datum, may need to mask upper bits */
- if ((ObjDesc->CommonField.AccessFlags & AFIELD_SINGLE_DATUM) &&
+ if ((ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM) &&
ObjDesc->CommonField.EndFieldValidBits)
{
/* There are bits above the field, mask them off also */
@@ -928,7 +1031,7 @@ AcpiExInsertIntoField (
/* Apply the update rule (if necessary) and write the datum to the field */
- Status = AcpiExWriteFieldDatumWithUpdateRule (ObjDesc, Mask, MergedDatum,
+ Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum,
FieldDatumByteOffset);
if (ACPI_FAILURE (Status))
{
@@ -938,7 +1041,7 @@ AcpiExInsertIntoField (
/* If the entire field fits within one datum, we are done. */
if ((DatumCount == 1) &&
- (ObjDesc->CommonField.AccessFlags & AFIELD_SINGLE_DATUM))
+ (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM))
{
return_ACPI_STATUS (AE_OK);
}
@@ -978,7 +1081,6 @@ AcpiExInsertIntoField (
(PreviousRawDatum >> ObjDesc->CommonField.DatumValidBits) |
(ThisRawDatum << ObjDesc->CommonField.StartFieldBitOffset);
}
-
else
{
/* Field began aligned on datum boundary */
@@ -1011,21 +1113,20 @@ AcpiExInsertIntoField (
/* Write the last datum with the update rule */
- Status = AcpiExWriteFieldDatumWithUpdateRule (ObjDesc, Mask,
- MergedDatum, FieldDatumByteOffset);
+ Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum,
+ FieldDatumByteOffset);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
}
-
else
{
/* Normal case -- write the completed datum */
- Status = AcpiExWriteFieldDatum (ObjDesc,
- FieldDatumByteOffset, MergedDatum);
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &MergedDatum, ACPI_WRITE);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c
index 29336b2..2015b32 100644
--- a/sys/contrib/dev/acpica/hwsleep.c
+++ b/sys/contrib/dev/acpica/hwsleep.c
@@ -2,7 +2,7 @@
/******************************************************************************
*
* Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
- * $Revision: 22 $
+ * $Revision: 25 $
*
*****************************************************************************/
@@ -122,6 +122,9 @@
#define _COMPONENT ACPI_HARDWARE
MODULE_NAME ("hwsleep")
+static UINT8 SleepTypeA;
+static UINT8 SleepTypeB;
+
/******************************************************************************
*
@@ -214,42 +217,40 @@ AcpiGetFirmwareWakingVector (
return_ACPI_STATUS (AE_OK);
}
+
/******************************************************************************
*
- * FUNCTION: AcpiEnterSleepState
+ * FUNCTION: AcpiEnterSleepStatePrep
*
* PARAMETERS: SleepState - Which sleep state to enter
*
* RETURN: Status
*
- * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
+ * This function must execute with interrupts enabled.
+ * We break sleeping into 2 stages so that OSPM can handle
+ * various OS-specific tasks between the two steps.
*
******************************************************************************/
ACPI_STATUS
-AcpiEnterSleepState (
+AcpiEnterSleepStatePrep (
UINT8 SleepState)
{
ACPI_STATUS Status;
ACPI_OBJECT_LIST ArgList;
ACPI_OBJECT Arg;
- UINT8 TypeA;
- UINT8 TypeB;
- UINT16 PM1AControl;
- UINT16 PM1BControl;
- UINT32 Retry;
-
- FUNCTION_TRACE ("AcpiEnterSleepState");
+ FUNCTION_TRACE ("AcpiEnterSleepStatePrep");
/*
* _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
*/
- Status = AcpiHwObtainSleepTypeRegisterData (SleepState, &TypeA, &TypeB);
+ Status = AcpiHwObtainSleepTypeRegisterData (SleepState, &SleepTypeA, &SleepTypeB);
if (!ACPI_SUCCESS (Status))
{
- return Status;
+ return_ACPI_STATUS (Status);
}
/* run the _PTS and _GTS methods */
@@ -265,11 +266,50 @@ AcpiEnterSleepState (
AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL);
AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepState
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepState (
+ UINT8 SleepState)
+{
+ UINT16 PM1AControl;
+ UINT16 PM1BControl;
+ UINT32 Retry;
+
+
+ FUNCTION_TRACE ("AcpiEnterSleepState");
+
+ if ((SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
+ (SleepTypeB > ACPI_SLEEP_TYPE_MAX))
+ {
+ REPORT_ERROR (("Sleep values out of range: A=%x B=%x\n",
+ SleepTypeA, SleepTypeB));
+ return_ACPI_STATUS (AE_ERROR);
+ }
+
/* clear wake status */
AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1);
- disable ();
+ AcpiHwClearAcpiStatus();
+
+ /* disable arbitration here? */
AcpiHwDisableNonWakeupGpes();
@@ -284,8 +324,8 @@ AcpiEnterSleepState (
/* mask in SLP_TYP */
- PM1AControl |= (TypeA << AcpiHwGetBitShift (SLP_TYPE_X_MASK));
- PM1BControl |= (TypeB << AcpiHwGetBitShift (SLP_TYPE_X_MASK));
+ PM1AControl |= (SleepTypeA << AcpiHwGetBitShift (SLP_TYPE_X_MASK));
+ PM1BControl |= (SleepTypeB << AcpiHwGetBitShift (SLP_TYPE_X_MASK));
/* write #1: fill in SLP_TYP data */
@@ -297,10 +337,6 @@ AcpiEnterSleepState (
PM1AControl |= (1 << AcpiHwGetBitShift (SLP_EN_MASK));
PM1BControl |= (1 << AcpiHwGetBitShift (SLP_EN_MASK));
- /* flush caches */
-
- wbinvd();
-
/* write #2: SLP_TYP + SLP_EN */
AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1A_CONTROL, PM1AControl);
@@ -319,8 +355,9 @@ AcpiEnterSleepState (
/* wait until we enter sleep state */
+ /* spin until we wake */
Retry = 1000;
- do
+ while (!AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, WAK_STS))
{
/*
* Some BIOSes don't set WAK_STS at all,
@@ -330,11 +367,6 @@ AcpiEnterSleepState (
break; /* giving up */
}
}
- while (!AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, WAK_STS));
-
- AcpiHwEnableNonWakeupGpes();
-
- enable ();
return_ACPI_STATUS (AE_OK);
}
@@ -361,6 +393,8 @@ AcpiLeaveSleepState (
FUNCTION_TRACE ("AcpiLeaveSleepState");
+ /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
+ SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
MEMSET (&ArgList, 0, sizeof(ArgList));
ArgList.Count = 1;
diff --git a/sys/contrib/dev/acpica/psparse.c b/sys/contrib/dev/acpica/psparse.c
index 1829586..2cc8625 100644
--- a/sys/contrib/dev/acpica/psparse.c
+++ b/sys/contrib/dev/acpica/psparse.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: psparse - Parser top level AML parse routines
- * $Revision: 104 $
+ * $Revision: 109 $
*
*****************************************************************************/
@@ -152,7 +152,7 @@ extern UINT32 AcpiGbl_ScopeDepth;
*
******************************************************************************/
-static UINT32
+UINT32
AcpiPsGetOpcodeSize (
UINT32 Opcode)
{
@@ -193,31 +193,15 @@ AcpiPsPeekOpcode (
Aml = ParserState->Aml;
Opcode = (UINT16) GET8 (Aml);
- Aml++;
-
- /*
- * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL.
- * These opcodes are no longer recognized. Instead, they are broken into
- * two opcodes.
- *
- *
- * if (Opcode == AML_EXTOP
- * || (Opcode == AML_LNOT
- * && (GET8 (Aml) == AML_LEQUAL
- * || GET8 (Aml) == AML_LGREATER
- * || GET8 (Aml) == AML_LLESS)))
- *
- * extended Opcode, !=, <=, or >=
- */
if (Opcode == AML_EXTOP)
{
/* Extended opcode */
+ Aml++;
Opcode = (UINT16) ((Opcode << 8) | GET8 (Aml));
}
-
return (Opcode);
}
@@ -289,7 +273,7 @@ AcpiPsFindObject (
*
******************************************************************************/
-static BOOLEAN
+BOOLEAN
AcpiPsCompleteThisOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
@@ -304,8 +288,6 @@ AcpiPsCompleteThisOp (
FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op);
-
-
/* Delete this op and the subtree below it if asked to */
if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) &&
@@ -323,23 +305,30 @@ AcpiPsCompleteThisOp (
switch (ParentInfo->Class)
{
- case AML_CLASS_CONTROL: /* IF, ELSE, WHILE only */
+ case AML_CLASS_CONTROL:
break;
- case AML_CLASS_NAMED_OBJECT: /* Scope, method, etc. */
case AML_CLASS_CREATE:
/*
* These opcodes contain TermArg operands. The current
* op must be replace by a placeholder return op
*/
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ return_VALUE (FALSE);
+ }
+ break;
+
+ case AML_CLASS_NAMED_OBJECT:
+
+ /*
+ * These opcodes contain TermArg operands. The current
+ * op must be replace by a placeholder return op
+ */
if ((Op->Parent->Opcode == AML_REGION_OP) ||
- (Op->Parent->Opcode == AML_CREATE_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_BIT_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_BYTE_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_WORD_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_DWORD_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_QWORD_FIELD_OP))
+ (Op->Parent->Opcode == AML_DATA_REGION_OP))
{
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
if (!ReplacementOp)
@@ -347,7 +336,6 @@ AcpiPsCompleteThisOp (
return_VALUE (FALSE);
}
}
-
break;
default:
@@ -404,7 +392,6 @@ AcpiPsCompleteThisOp (
Prev = Next;
}
-
}
/* Now we can actually delete the subtree rooted at op */
@@ -434,7 +421,7 @@ AcpiPsCompleteThisOp (
*
******************************************************************************/
-static ACPI_STATUS
+ACPI_STATUS
AcpiPsNextParseState (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op,
@@ -478,6 +465,7 @@ AcpiPsNextParseState (
case AE_CTRL_TRUE:
+
/*
* Predicate of an IF was true, and we are at the matching ELSE.
* Just close out this package
@@ -714,9 +702,6 @@ AcpiPsParseLoop (
WalkState->Op = NULL;
Status = WalkState->DescendingCallback (WalkState, &Op);
-
- /* TBD: check status here? */
-
if (ACPI_FAILURE (Status))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
@@ -728,6 +713,7 @@ AcpiPsParseLoop (
{
continue;
}
+
Status = AcpiPsNextParseState (WalkState, Op, Status);
if (Status == AE_CTRL_PENDING)
{
@@ -744,7 +730,6 @@ AcpiPsParseLoop (
AcpiPsAppendArg (Op, PreOp.Value.Arg);
AcpiGbl_Depth++;
-
if (Op->Opcode == AML_REGION_OP)
{
/*
@@ -764,7 +749,6 @@ AcpiPsParseLoop (
}
}
-
else
{
/* Not a named opcode, just allocate Op and append to parent */
@@ -776,7 +760,6 @@ AcpiPsParseLoop (
return_ACPI_STATUS (AE_NO_MEMORY);
}
-
if (WalkState->OpInfo->Flags & AML_CREATE)
{
/*
@@ -795,7 +778,7 @@ AcpiPsParseLoop (
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
- WalkState->Op = Op;
+ WalkState->Op = Op;
Status = WalkState->DescendingCallback (WalkState, &Op);
Status = AcpiPsNextParseState (WalkState, Op, Status);
@@ -827,7 +810,6 @@ AcpiPsParseLoop (
WalkState->ArgCount = 0;
-
if (WalkState->ArgTypes) /* Are there any arguments that must be processed? */
{
/* get arguments */
@@ -872,7 +854,6 @@ AcpiPsParseLoop (
INCREMENT_ARG_LIST (WalkState->ArgTypes);
}
-
/* For a method, save the length and address of the body */
if (Op->Opcode == AML_METHOD_OP)
@@ -960,7 +941,6 @@ AcpiPsParseLoop (
CloseThisOp:
-
/*
* Finished one argument of the containing scope
*/
@@ -973,7 +953,6 @@ CloseThisOp:
Op = NULL;
}
-
switch (Status)
{
case AE_OK:
@@ -1019,8 +998,8 @@ CloseThisOp:
{
AcpiPsCompleteThisOp (WalkState, Op);
}
-
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
+
} while (Op);
return_ACPI_STATUS (Status);
@@ -1037,9 +1016,8 @@ CloseThisOp:
WalkState->PrevArgTypes = WalkState->ArgTypes;
/*
- * TEMP:
+ * TBD: TEMP:
*/
-
return_ACPI_STATUS (Status);
break;
}
@@ -1051,19 +1029,14 @@ CloseThisOp:
AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, &WalkState->ArgCount);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
}
-
else
{
Op = NULL;
}
-
}
-
-
- /* ArgCount is non-zero */
-
else
{
+ /* ArgCount is non-zero */
/* complex argument, push Op and prepare for argument */
AcpiPsPushScope (ParserState, Op, WalkState->ArgTypes, WalkState->ArgCount);
@@ -1156,8 +1129,8 @@ AcpiPsParseAml (
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status;
- ACPI_WALK_LIST WalkList;
- ACPI_WALK_LIST *PrevWalkList = AcpiGbl_CurrentWalkList;
+ ACPI_THREAD_STATE *Thread;
+ ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
ACPI_WALK_STATE *PreviousWalkState;
ACPI_OPERAND_OBJECT **CallerReturnDesc = WalkState->CallerReturnDesc;
ACPI_OPERAND_OBJECT *EffectiveReturnDesc = NULL;
@@ -1170,19 +1143,21 @@ AcpiPsParseAml (
WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize));
- /* Create and initialize a new walk list */
+ /* Create and initialize a new thread state */
- WalkList.WalkState = NULL;
- WalkList.AcquiredMutexList.Prev = NULL;
- WalkList.AcquiredMutexList.Next = NULL;
+ Thread = AcpiUtCreateThreadState ();
+ if (!Thread)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
- WalkState->WalkList = &WalkList;
- AcpiDsPushWalkState (WalkState, &WalkList);
+ WalkState->Thread = Thread;
+ AcpiDsPushWalkState (WalkState, Thread);
/* TBD: [Restructure] TEMP until we pass WalkState to the interpreter
*/
- AcpiGbl_CurrentWalkList = &WalkList;
+ AcpiGbl_CurrentWalkList = Thread;
/*
* Execute the walk loop as long as there is a valid Walk State. This
@@ -1211,13 +1186,13 @@ AcpiPsParseAml (
* A method call was detected.
* Transfer control to the called control method
*/
- Status = AcpiDsCallControlMethod (&WalkList, WalkState, NULL);
+ Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
/*
* If the transfer to the new method method call worked, a new walk
* state was created -- get it
*/
- WalkState = AcpiDsGetCurrentWalkState (&WalkList);
+ WalkState = AcpiDsGetCurrentWalkState (Thread);
continue;
}
@@ -1228,7 +1203,7 @@ AcpiPsParseAml (
/* We are done with this walk, move on to the parent if any */
- WalkState = AcpiDsPopWalkState (&WalkList);
+ WalkState = AcpiDsPopWalkState (Thread);
/* Save the last effective return value */
@@ -1263,7 +1238,7 @@ AcpiPsParseAml (
/* Check if we have restarted a preempted walk */
- WalkState = AcpiDsGetCurrentWalkState (&WalkList);
+ WalkState = AcpiDsGetCurrentWalkState (Thread);
if (WalkState)
{
if (ACPI_SUCCESS (Status))
@@ -1309,11 +1284,11 @@ AcpiPsParseAml (
AcpiDsDeleteWalkState (PreviousWalkState);
}
-
/* Normal exit */
AcpiUtRemoveReference (EffectiveReturnDesc);
- AcpiExReleaseAllMutexes ((ACPI_OPERAND_OBJECT *) &WalkList.AcquiredMutexList);
+ AcpiExReleaseAllMutexes (Thread);
+ AcpiUtDeleteGenericState ((ACPI_GENERIC_STATE *) Thread);
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
}
diff --git a/sys/contrib/dev/acpica/rscreate.c b/sys/contrib/dev/acpica/rscreate.c
index 14aaf5d..60edaa5 100644
--- a/sys/contrib/dev/acpica/rscreate.c
+++ b/sys/contrib/dev/acpica/rscreate.c
@@ -266,9 +266,9 @@ AcpiRsCreatePciRoutingTable (
if (BufferSizeNeeded > *OutputBufferLength)
{
+ *OutputBufferLength = BufferSizeNeeded;
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
}
- *OutputBufferLength = BufferSizeNeeded;
/*
* Zero out the return buffer before proceeding
diff --git a/sys/contrib/dev/acpica/tbget.c b/sys/contrib/dev/acpica/tbget.c
index a6c3cf5..ff8538b 100644
--- a/sys/contrib/dev/acpica/tbget.c
+++ b/sys/contrib/dev/acpica/tbget.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: tbget - ACPI Table get* routines
- * $Revision: 56 $
+ * $Revision: 57 $
*
*****************************************************************************/
@@ -467,13 +467,6 @@ AcpiTbGetAllTables (
AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length));
DUMP_BUFFER ((UINT8 *) (AcpiGbl_DSDT + 1), AcpiGbl_DSDT->Length);
- /*
- * Initialize the capabilities flags.
- * Assumes that platform supports ACPI_MODE since we have tables!
- */
- AcpiGbl_SystemFlags |= AcpiHwGetModeCapabilities ();
-
-
/* Always delete the RSDP mapping, we are done with it */
AcpiTbDeleteAcpiTable (ACPI_TABLE_RSDP);
OpenPOWER on IntegriCloud