summaryrefslogtreecommitdiff
path: root/source/components/disassembler/dmbuffer.c
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2016-09-30 19:46:13 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2016-09-30 19:46:13 +0000
commit7600ac2283596bd000a29b9347e95346d3b740d7 (patch)
tree71816608dca5b2fd7445b5bd4cba161b0b293fe1 /source/components/disassembler/dmbuffer.c
parentbe99e84498e91a5930864ef7b92b1a7ceb815e44 (diff)
Notes
Diffstat (limited to 'source/components/disassembler/dmbuffer.c')
-rw-r--r--source/components/disassembler/dmbuffer.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c
index 79c37e2e3ea8..42920500ba2d 100644
--- a/source/components/disassembler/dmbuffer.c
+++ b/source/components/disassembler/dmbuffer.c
@@ -529,7 +529,8 @@ AcpiDmIsStringBuffer (
*
* PARAMETERS: Op - Buffer Object to be examined
*
- * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise
+ * RETURN: TRUE if buffer appears to contain data produced via the
+ * ToPLD macro, FALSE otherwise
*
* DESCRIPTION: Determine if a buffer Op contains a _PLD structure
*
@@ -541,12 +542,60 @@ AcpiDmIsPldBuffer (
{
ACPI_NAMESPACE_NODE *Node;
ACPI_PARSE_OBJECT *SizeOp;
+ ACPI_PARSE_OBJECT *ByteListOp;
ACPI_PARSE_OBJECT *ParentOp;
+ UINT64 BufferSize;
+ UINT64 InitializerSize;
- /* Buffer size is the buffer argument */
-
+ /*
+ * Get the BufferSize argument - Buffer(BufferSize)
+ * If the buffer was generated by the ToPld macro, it must
+ * be a BYTE constant.
+ */
SizeOp = Op->Common.Value.Arg;
+ if (SizeOp->Common.AmlOpcode != AML_BYTE_OP)
+ {
+ return (FALSE);
+ }
+
+ /* Check the declared BufferSize, two possibilities */
+
+ BufferSize = SizeOp->Common.Value.Integer;
+ if ((BufferSize != ACPI_PLD_REV1_BUFFER_SIZE) &&
+ (BufferSize != ACPI_PLD_REV2_BUFFER_SIZE))
+ {
+ return (FALSE);
+ }
+
+ /*
+ * Check the initializer list length. This is the actual
+ * number of bytes in the buffer as counted by the AML parser.
+ * The declared BufferSize can be larger than the actual length.
+ * However, for the ToPLD macro, the BufferSize will be the same
+ * as the initializer list length.
+ */
+ ByteListOp = SizeOp->Common.Next;
+ if (!ByteListOp)
+ {
+ return (FALSE); /* Zero-length buffer case */
+ }
+
+ InitializerSize = ByteListOp->Common.Value.Integer;
+ if ((InitializerSize != ACPI_PLD_REV1_BUFFER_SIZE) &&
+ (InitializerSize != ACPI_PLD_REV2_BUFFER_SIZE))
+ {
+ return (FALSE);
+ }
+
+ /* Final size check */
+
+ if (BufferSize != InitializerSize)
+ {
+ return (FALSE);
+ }
+
+ /* Now examine the buffer parent */
ParentOp = Op->Common.Parent;
if (!ParentOp)
@@ -571,8 +620,17 @@ AcpiDmIsPldBuffer (
return (FALSE);
}
- /* Check for proper form: Name(_PLD, Package() {Buffer() {}}) */
-
+ /*
+ * Check for proper form: Name(_PLD, Package() {ToPLD()})
+ *
+ * Note: All other forms such as
+ * Return (Package() {ToPLD()})
+ * Local0 = ToPLD()
+ * etc. are not converted back to the ToPLD macro, because
+ * there is really no deterministic way to disassemble the buffer
+ * back to the ToPLD macro, other than trying to find the "_PLD"
+ * name
+ */
if (ParentOp->Common.AmlOpcode == AML_PACKAGE_OP)
{
ParentOp = ParentOp->Common.Parent;