Patchwork [RFC,v4,01/30,SeaBIOS] Add ACPI_EXTRACT_DEVICE* macros

login
register
mail settings
Submitter Vasilis Liaskovitis
Date Dec. 18, 2012, 12:41 p.m.
Message ID <1355834518-17989-2-git-send-email-vasilis.liaskovitis@profitbricks.com>
Download mbox | patch
Permalink /patch/207134/
State New
Headers show

Comments

Vasilis Liaskovitis - Dec. 18, 2012, 12:41 p.m.
This allows to extract the beginning, end and name of a Device object.
---
 tools/acpi_extract.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
liguang - March 20, 2013, 3:28 a.m.
seems these changes is in seebios now.

在 2012-12-18二的 13:41 +0100,Vasilis Liaskovitis写道:
> This allows to extract the beginning, end and name of a Device object.
> ---
>  tools/acpi_extract.py |   28 ++++++++++++++++++++++++++++
>  1 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/acpi_extract.py b/tools/acpi_extract.py
> index 3295678..3191f53 100755
> --- a/tools/acpi_extract.py
> +++ b/tools/acpi_extract.py
> @@ -217,6 +217,28 @@ def aml_package_start(offset):
>      offset += 1
>      return offset + aml_pkglen_bytes(offset) + 1
>  
> +def aml_device_start(offset):
> +    #0x5B 0x82 DeviceOp PkgLength NameString ProcID
> +    if ((aml[offset] != 0x5B) or (aml[offset + 1] != 0x82)):
> +        die( "Name offset 0x%x: expected 0x5B 0x83 actual 0x%x 0x%x" %
> +             (offset, aml[offset], aml[offset + 1]));
> +    return offset
> +
> +def aml_device_string(offset):
> +    #0x5B 0x82 DeviceOp PkgLength NameString ProcID
> +    start = aml_device_start(offset)
> +    offset += 2
> +    pkglenbytes = aml_pkglen_bytes(offset)
> +    offset += pkglenbytes
> +    return offset
> +
> +def aml_device_end(offset):
> +    start = aml_device_start(offset)
> +    offset += 2
> +    pkglenbytes = aml_pkglen_bytes(offset)
> +    pkglen = aml_pkglen(offset)
> +    return offset + pkglen
> +
>  lineno = 0
>  for line in fileinput.input():
>      # Strip trailing newline
> @@ -307,6 +329,12 @@ for i in range(len(asl)):
>          offset = aml_processor_end(offset)
>      elif (directive == "ACPI_EXTRACT_PKG_START"):
>          offset = aml_package_start(offset)
> +    elif (directive == "ACPI_EXTRACT_DEVICE_START"):
> +        offset = aml_device_start(offset)
> +    elif (directive == "ACPI_EXTRACT_DEVICE_STRING"):
> +        offset = aml_device_string(offset)
> +    elif (directive == "ACPI_EXTRACT_DEVICE_END"):
> +        offset = aml_device_end(offset)
>      else:
>          die("Unsupported directive %s" % directive)
>

Patch

diff --git a/tools/acpi_extract.py b/tools/acpi_extract.py
index 3295678..3191f53 100755
--- a/tools/acpi_extract.py
+++ b/tools/acpi_extract.py
@@ -217,6 +217,28 @@  def aml_package_start(offset):
     offset += 1
     return offset + aml_pkglen_bytes(offset) + 1
 
+def aml_device_start(offset):
+    #0x5B 0x82 DeviceOp PkgLength NameString ProcID
+    if ((aml[offset] != 0x5B) or (aml[offset + 1] != 0x82)):
+        die( "Name offset 0x%x: expected 0x5B 0x83 actual 0x%x 0x%x" %
+             (offset, aml[offset], aml[offset + 1]));
+    return offset
+
+def aml_device_string(offset):
+    #0x5B 0x82 DeviceOp PkgLength NameString ProcID
+    start = aml_device_start(offset)
+    offset += 2
+    pkglenbytes = aml_pkglen_bytes(offset)
+    offset += pkglenbytes
+    return offset
+
+def aml_device_end(offset):
+    start = aml_device_start(offset)
+    offset += 2
+    pkglenbytes = aml_pkglen_bytes(offset)
+    pkglen = aml_pkglen(offset)
+    return offset + pkglen
+
 lineno = 0
 for line in fileinput.input():
     # Strip trailing newline
@@ -307,6 +329,12 @@  for i in range(len(asl)):
         offset = aml_processor_end(offset)
     elif (directive == "ACPI_EXTRACT_PKG_START"):
         offset = aml_package_start(offset)
+    elif (directive == "ACPI_EXTRACT_DEVICE_START"):
+        offset = aml_device_start(offset)
+    elif (directive == "ACPI_EXTRACT_DEVICE_STRING"):
+        offset = aml_device_string(offset)
+    elif (directive == "ACPI_EXTRACT_DEVICE_END"):
+        offset = aml_device_end(offset)
     else:
         die("Unsupported directive %s" % directive)