diff mbox

[v2] ACPI: Enable AML DBUG() control method

Message ID 5d4b5e6b17eadf92b61e9ef6f3118f7658bb99d0.1470641028.git.lv.zheng@intel.com
State New
Headers show

Commit Message

Lv Zheng Aug. 8, 2016, 7:26 a.m. UTC
This patch enables DBUG() control method, making it independent of seabios.

DBUG() is defined in the default DSDT, and is used to dump the AML
debugging information to the debug port. Thus it can be used by the ACPI
open source community developers to probe the de-facto standard AML
interpreter behavior.

But the debug IO port address used in DBUG() (DBG operation region field)
is currently not synchronized to any debugging facility implemented in
qemu.

Originally, we managed to use this feature by specifying
"-global isa-debugcon.iobase=0x402 -debugcon stdio" to make it working with
the debug console device. Note that the "iobase=0x402" implies that this
feature is currently dependent on seabios.

But since the AML tables are now provided by qemu itself, this feature
shouldn't be dependent on any BIOS rom. This patch thus changes DBG AML
generation code using isa-debugcon iobase so that we can always use this
feature by only specifying "-debugcon stdio".

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 hw/char/debugcon.c         |   23 +++++++++++++++++++++++
 hw/i386/acpi-build.c       |    4 +++-
 include/hw/char/debugcon.h |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/char/debugcon.h

Comments

Paolo Bonzini Aug. 8, 2016, 9:02 a.m. UTC | #1
On 08/08/2016 09:26, Lv Zheng wrote:
> This patch enables DBUG() control method, making it independent of seabios.
> 
> DBUG() is defined in the default DSDT, and is used to dump the AML
> debugging information to the debug port. Thus it can be used by the ACPI
> open source community developers to probe the de-facto standard AML
> interpreter behavior.
> 
> But the debug IO port address used in DBUG() (DBG operation region field)
> is currently not synchronized to any debugging facility implemented in
> qemu.
> 
> Originally, we managed to use this feature by specifying
> "-global isa-debugcon.iobase=0x402 -debugcon stdio" to make it working with
> the debug console device. Note that the "iobase=0x402" implies that this
> feature is currently dependent on seabios.
> 
> But since the AML tables are now provided by qemu itself, this feature
> shouldn't be dependent on any BIOS rom. This patch thus changes DBG AML
> generation code using isa-debugcon iobase so that we can always use this
> feature by only specifying "-debugcon stdio".
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> ---
>  hw/char/debugcon.c         |   23 +++++++++++++++++++++++
>  hw/i386/acpi-build.c       |    4 +++-
>  include/hw/char/debugcon.h |   33 +++++++++++++++++++++++++++++++++
>  3 files changed, 59 insertions(+), 1 deletion(-)
>  create mode 100644 include/hw/char/debugcon.h
> 
> diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
> index e7f025e..7f70ec3 100644
> --- a/hw/char/debugcon.c
> +++ b/hw/char/debugcon.c
> @@ -30,6 +30,7 @@
>  #include "sysemu/char.h"
>  #include "hw/isa/isa.h"
>  #include "hw/i386/pc.h"
> +#include "hw/char/debugcon.h"
>  
>  #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
>  #define ISA_DEBUGCON_DEVICE(obj) \
> @@ -134,6 +135,28 @@ static const TypeInfo debugcon_isa_info = {
>      .class_init    = debugcon_isa_class_initfn,
>  };
>  
> +static Object *debugcon_isa_find(void)
> +{
> +    bool ambig;
> +    Object *o = object_resolve_path_type("", TYPE_ISA_DEBUGCON_DEVICE,
> +                                         &ambig);
> +
> +    if (ambig) {
> +        return NULL;
> +    }
> +    return o;
> +}
> +
> +uint32_t debugcon_get_port(void)
> +{
> +    Object *obj = debugcon_isa_find();
> +
> +    if (obj) {
> +        return object_property_get_int(obj, "iobase", &error_abort);
> +    }
> +    return 0xe9;
> +}
> +
>  static void debugcon_register_types(void)
>  {
>      type_register_static(&debugcon_isa_info);
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index a26a4bb..ce7cbc5 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -44,6 +44,7 @@
>  #include "hw/acpi/tpm.h"
>  #include "sysemu/tpm_backend.h"
>  #include "hw/timer/mc146818rtc_regs.h"
> +#include "hw/char/debugcon.h"
>  #include "sysemu/numa.h"
>  
>  /* Supported chipsets: */
> @@ -1442,7 +1443,8 @@ static void build_dbg_aml(Aml *table)
>      Aml *idx = aml_local(2);
>  
>      aml_append(scope,
> -       aml_operation_region("DBG", AML_SYSTEM_IO, aml_int(0x0402), 0x01));
> +       aml_operation_region("DBG", AML_SYSTEM_IO,
> +                            aml_int(debugcon_get_port()), 0x01));
>      field = aml_field("DBG", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
>      aml_append(field, aml_named_field("DBGB", 8));
>      aml_append(scope, field);
> diff --git a/include/hw/char/debugcon.h b/include/hw/char/debugcon.h
> new file mode 100644
> index 0000000..a2420fd
> --- /dev/null
> +++ b/include/hw/char/debugcon.h
> @@ -0,0 +1,33 @@
> +/*
> + * QEMU debug console emulation
> + *
> + * Copyright (c) 2016 Lv Zheng <lv.zheng@intel.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#ifndef HW_DEBUGCON_H
> +#define HW_DEBUGCON_H
> +
> +#include "hw/hw.h"
> +#include "sysemu/sysemu.h"
> +
> +extern uint32_t debugcon_get_port(void);
> +
> +#endif
> 

This should be okay, but will have to wait for QEMU 2.8.

Thanks,

Paolo
Igor Mammedov Aug. 8, 2016, 9:30 a.m. UTC | #2
On Mon,  8 Aug 2016 15:26:59 +0800
Lv Zheng <lv.zheng@intel.com> wrote:

> This patch enables DBUG() control method, making it independent of seabios.
> 
> DBUG() is defined in the default DSDT, and is used to dump the AML
> debugging information to the debug port. Thus it can be used by the ACPI
> open source community developers to probe the de-facto standard AML
> interpreter behavior.
> 
> But the debug IO port address used in DBUG() (DBG operation region field)
> is currently not synchronized to any debugging facility implemented in
> qemu.
> 
> Originally, we managed to use this feature by specifying
> "-global isa-debugcon.iobase=0x402 -debugcon stdio" to make it working with
> the debug console device. Note that the "iobase=0x402" implies that this
> feature is currently dependent on seabios.
> 
> But since the AML tables are now provided by qemu itself, this feature
> shouldn't be dependent on any BIOS rom. This patch thus changes DBG AML
> generation code using isa-debugcon iobase so that we can always use this
> feature by only specifying "-debugcon stdio".
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> ---
>  hw/char/debugcon.c         |   23 +++++++++++++++++++++++
>  hw/i386/acpi-build.c       |    4 +++-
>  include/hw/char/debugcon.h |   33 +++++++++++++++++++++++++++++++++
>  3 files changed, 59 insertions(+), 1 deletion(-)
>  create mode 100644 include/hw/char/debugcon.h
> 
> diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
> index e7f025e..7f70ec3 100644
> --- a/hw/char/debugcon.c
> +++ b/hw/char/debugcon.c
> @@ -30,6 +30,7 @@
>  #include "sysemu/char.h"
>  #include "hw/isa/isa.h"
>  #include "hw/i386/pc.h"
> +#include "hw/char/debugcon.h"
>  
>  #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
>  #define ISA_DEBUGCON_DEVICE(obj) \
> @@ -134,6 +135,28 @@ static const TypeInfo debugcon_isa_info = {
>      .class_init    = debugcon_isa_class_initfn,
>  };
>  
> +static Object *debugcon_isa_find(void)
> +{
> +    bool ambig;
> +    Object *o = object_resolve_path_type("", TYPE_ISA_DEBUGCON_DEVICE,
> +                                         &ambig);
> +
> +    if (ambig) {
> +        return NULL;
maybe there should be error_abort with some nice error message here?

> +    }
> +    return o;
> +}
> +
> +uint32_t debugcon_get_port(void)
> +{
> +    Object *obj = debugcon_isa_find();
> +
> +    if (obj) {
> +        return object_property_get_int(obj, "iobase", &error_abort);
> +    }
> +    return 0xe9;
Why default to new 0xe9 port instead of the old default value 0x0402?

> +}
> +
>  static void debugcon_register_types(void)
>  {
>      type_register_static(&debugcon_isa_info);
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index a26a4bb..ce7cbc5 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -44,6 +44,7 @@
>  #include "hw/acpi/tpm.h"
>  #include "sysemu/tpm_backend.h"
>  #include "hw/timer/mc146818rtc_regs.h"
> +#include "hw/char/debugcon.h"
>  #include "sysemu/numa.h"
>  
>  /* Supported chipsets: */
> @@ -1442,7 +1443,8 @@ static void build_dbg_aml(Aml *table)
>      Aml *idx = aml_local(2);
>  
>      aml_append(scope,
> -       aml_operation_region("DBG", AML_SYSTEM_IO, aml_int(0x0402), 0x01));
> +       aml_operation_region("DBG", AML_SYSTEM_IO,
> +                            aml_int(debugcon_get_port()), 0x01));
I suggest making DBG empty NOP method or remove it completely 
if isa-debugcon is not present.

>      field = aml_field("DBG", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
>      aml_append(field, aml_named_field("DBGB", 8));
>      aml_append(scope, field);
> diff --git a/include/hw/char/debugcon.h b/include/hw/char/debugcon.h
> new file mode 100644
> index 0000000..a2420fd
> --- /dev/null
> +++ b/include/hw/char/debugcon.h
> @@ -0,0 +1,33 @@
> +/*
> + * QEMU debug console emulation
> + *
> + * Copyright (c) 2016 Lv Zheng <lv.zheng@intel.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#ifndef HW_DEBUGCON_H
> +#define HW_DEBUGCON_H
> +
> +#include "hw/hw.h"
> +#include "sysemu/sysemu.h"
> +
> +extern uint32_t debugcon_get_port(void);
> +
> +#endif
diff mbox

Patch

diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
index e7f025e..7f70ec3 100644
--- a/hw/char/debugcon.c
+++ b/hw/char/debugcon.c
@@ -30,6 +30,7 @@ 
 #include "sysemu/char.h"
 #include "hw/isa/isa.h"
 #include "hw/i386/pc.h"
+#include "hw/char/debugcon.h"
 
 #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon"
 #define ISA_DEBUGCON_DEVICE(obj) \
@@ -134,6 +135,28 @@  static const TypeInfo debugcon_isa_info = {
     .class_init    = debugcon_isa_class_initfn,
 };
 
+static Object *debugcon_isa_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", TYPE_ISA_DEBUGCON_DEVICE,
+                                         &ambig);
+
+    if (ambig) {
+        return NULL;
+    }
+    return o;
+}
+
+uint32_t debugcon_get_port(void)
+{
+    Object *obj = debugcon_isa_find();
+
+    if (obj) {
+        return object_property_get_int(obj, "iobase", &error_abort);
+    }
+    return 0xe9;
+}
+
 static void debugcon_register_types(void)
 {
     type_register_static(&debugcon_isa_info);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a26a4bb..ce7cbc5 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -44,6 +44,7 @@ 
 #include "hw/acpi/tpm.h"
 #include "sysemu/tpm_backend.h"
 #include "hw/timer/mc146818rtc_regs.h"
+#include "hw/char/debugcon.h"
 #include "sysemu/numa.h"
 
 /* Supported chipsets: */
@@ -1442,7 +1443,8 @@  static void build_dbg_aml(Aml *table)
     Aml *idx = aml_local(2);
 
     aml_append(scope,
-       aml_operation_region("DBG", AML_SYSTEM_IO, aml_int(0x0402), 0x01));
+       aml_operation_region("DBG", AML_SYSTEM_IO,
+                            aml_int(debugcon_get_port()), 0x01));
     field = aml_field("DBG", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
     aml_append(field, aml_named_field("DBGB", 8));
     aml_append(scope, field);
diff --git a/include/hw/char/debugcon.h b/include/hw/char/debugcon.h
new file mode 100644
index 0000000..a2420fd
--- /dev/null
+++ b/include/hw/char/debugcon.h
@@ -0,0 +1,33 @@ 
+/*
+ * QEMU debug console emulation
+ *
+ * Copyright (c) 2016 Lv Zheng <lv.zheng@intel.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef HW_DEBUGCON_H
+#define HW_DEBUGCON_H
+
+#include "hw/hw.h"
+#include "sysemu/sysemu.h"
+
+extern uint32_t debugcon_get_port(void);
+
+#endif