All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
@ 2016-08-05 10:19 Lv Zheng
  2016-08-05 10:57 ` Igor Mammedov
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Lv Zheng @ 2016-08-05 10:19 UTC (permalink / raw)
  To: Michael S. Tsirkin, Igor Mammedov, Shannon Zhao
  Cc: Lv Zheng, Lv Zheng, qemu-devel, qemu-arm

Changing debugcon port to 0x402 allows the seabios AML table pre-defined
DBUG() control method to be able to dump the AML debugging information to
the re-directed debugging console.

If the debug port number is configurable, users can further specify a
proper IO port number for it to make external BIOS's debugging
facility functioning.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 hw/char/debugcon.c      |    4 ++++
 hw/i386/acpi-build.c    |    3 ++-
 include/sysemu/sysemu.h |    1 +
 qemu-options.hx         |    9 +++++++++
 vl.c                    |   15 +++++++++++++++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
index e7f025e..f966a09 100644
--- a/hw/char/debugcon.c
+++ b/hw/char/debugcon.c
@@ -105,6 +105,10 @@ static void debugcon_isa_realizefn(DeviceState *dev, Error **errp)
         error_propagate(errp, err);
         return;
     }
+    if (debug_port != 0xe9) {
+        qdev_prop_set_uint32(dev, "iobase", debug_port);
+        qdev_prop_set_uint32(dev, "readback", debug_port);
+    }
     memory_region_init_io(&s->io, OBJECT(dev), &debugcon_ops, s,
                           TYPE_ISA_DEBUGCON_DEVICE, 1);
     memory_region_add_subregion(isa_address_space_io(d),
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a26a4bb..14c6224 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1442,7 +1442,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(debug_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/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ee7c760..9e0a30b 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -167,6 +167,7 @@ extern uint8_t qemu_extra_params_fw[2];
 extern QEMUClockType rtc_clock;
 extern const char *mem_path;
 extern int mem_prealloc;
+extern uint32_t debug_port;
 
 #define MAX_NODES 128
 #define NUMA_NODE_UNASSIGNED MAX_NODES
diff --git a/qemu-options.hx b/qemu-options.hx
index a71aaf8..05aedce 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3123,6 +3123,15 @@ The default device is @code{vc} in graphical mode and @code{stdio} in
 non graphical mode.
 ETEXI
 
+DEF("debugport", HAS_ARG, QEMU_OPTION_debugport, \
+    "-debugport n     Specify debug IO port number\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -debugport @var{n}
+@findex -debugport
+Specify the debug IO port number, default is 0xe9.
+ETEXI
+
 DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
     "-pidfile file   write PID to 'file'\n", QEMU_ARCH_ALL)
 STEXI
diff --git a/vl.c b/vl.c
index e7c2c62..710e14d 100644
--- a/vl.c
+++ b/vl.c
@@ -178,6 +178,7 @@ bool boot_strict;
 uint8_t *boot_splash_filedata;
 size_t boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
+uint32_t debug_port = 0xe9;
 
 int icount_align_option;
 
@@ -2584,6 +2585,17 @@ static int debugcon_parse(const char *devname)
     return 0;
 }
 
+static void debugcon_parse_port(const char *arg)
+{
+    uint32_t port;
+
+    port = strtoul(arg, NULL, 0);
+    if (port) {
+        printf("Re-assign debug console to port 0x%08x.\n", port);
+        debug_port = port;
+    }
+}
+
 static gint machine_class_cmp(gconstpointer a, gconstpointer b)
 {
     const MachineClass *mc1 = a, *mc2 = b;
@@ -3580,6 +3592,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_debugcon:
                 add_device_config(DEV_DEBUGCON, optarg);
                 break;
+            case QEMU_OPTION_debugport:
+                debugcon_parse_port(optarg);
+                break;
             case QEMU_OPTION_loadvm:
                 loadvm = optarg;
                 break;
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
  2016-08-05 10:19 [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number Lv Zheng
@ 2016-08-05 10:57 ` Igor Mammedov
  2016-08-05 21:47   ` Zheng, Lv
  2016-08-05 12:15 ` Paolo Bonzini
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Igor Mammedov @ 2016-08-05 10:57 UTC (permalink / raw)
  To: Lv Zheng
  Cc: Michael S. Tsirkin, Shannon Zhao, qemu-arm, Lv Zheng, qemu-devel, armbru

On Fri,  5 Aug 2016 18:19:39 +0800
Lv Zheng <lv.zheng@intel.com> wrote:

> Changing debugcon port to 0x402 allows the seabios AML table pre-defined
> DBUG() control method to be able to dump the AML debugging information to
> the re-directed debugging console.
> 
> If the debug port number is configurable, users can further specify a
> proper IO port number for it to make external BIOS's debugging
> facility functioning.

there is no need for yet another CLI option that is being added here,
just use usual '-device isa-debugcon,iobase=0x402,chardev=seabios"

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
  2016-08-05 10:19 [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number Lv Zheng
  2016-08-05 10:57 ` Igor Mammedov
@ 2016-08-05 12:15 ` Paolo Bonzini
  2016-08-05 21:48   ` Zheng, Lv
  2016-08-07  6:00 ` Michael S. Tsirkin
  2016-08-08  7:26 ` [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method Lv Zheng
  3 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2016-08-05 12:15 UTC (permalink / raw)
  To: Lv Zheng, Michael S. Tsirkin, Igor Mammedov, Shannon Zhao
  Cc: qemu-arm, Lv Zheng, qemu-devel



On 05/08/2016 12:19, Lv Zheng wrote:
> Changing debugcon port to 0x402 allows the seabios AML table pre-defined
> DBUG() control method to be able to dump the AML debugging information to
> the re-directed debugging console.
> 
> If the debug port number is configurable, users can further specify a
> proper IO port number for it to make external BIOS's debugging
> facility functioning.
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>

You can do this with

   -global isa-debugcon.iobase=0x402

Paolo

> ---
>  hw/char/debugcon.c      |    4 ++++
>  hw/i386/acpi-build.c    |    3 ++-
>  include/sysemu/sysemu.h |    1 +
>  qemu-options.hx         |    9 +++++++++
>  vl.c                    |   15 +++++++++++++++
>  5 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
> index e7f025e..f966a09 100644
> --- a/hw/char/debugcon.c
> +++ b/hw/char/debugcon.c
> @@ -105,6 +105,10 @@ static void debugcon_isa_realizefn(DeviceState *dev, Error **errp)
>          error_propagate(errp, err);
>          return;
>      }
> +    if (debug_port != 0xe9) {
> +        qdev_prop_set_uint32(dev, "iobase", debug_port);
> +        qdev_prop_set_uint32(dev, "readback", debug_port);
> +    }
>      memory_region_init_io(&s->io, OBJECT(dev), &debugcon_ops, s,
>                            TYPE_ISA_DEBUGCON_DEVICE, 1);
>      memory_region_add_subregion(isa_address_space_io(d),
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index a26a4bb..14c6224 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1442,7 +1442,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(debug_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/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index ee7c760..9e0a30b 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -167,6 +167,7 @@ extern uint8_t qemu_extra_params_fw[2];
>  extern QEMUClockType rtc_clock;
>  extern const char *mem_path;
>  extern int mem_prealloc;
> +extern uint32_t debug_port;
>  
>  #define MAX_NODES 128
>  #define NUMA_NODE_UNASSIGNED MAX_NODES
> diff --git a/qemu-options.hx b/qemu-options.hx
> index a71aaf8..05aedce 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3123,6 +3123,15 @@ The default device is @code{vc} in graphical mode and @code{stdio} in
>  non graphical mode.
>  ETEXI
>  
> +DEF("debugport", HAS_ARG, QEMU_OPTION_debugport, \
> +    "-debugport n     Specify debug IO port number\n",
> +    QEMU_ARCH_ALL)
> +STEXI
> +@item -debugport @var{n}
> +@findex -debugport
> +Specify the debug IO port number, default is 0xe9.
> +ETEXI
> +
>  DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
>      "-pidfile file   write PID to 'file'\n", QEMU_ARCH_ALL)
>  STEXI
> diff --git a/vl.c b/vl.c
> index e7c2c62..710e14d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -178,6 +178,7 @@ bool boot_strict;
>  uint8_t *boot_splash_filedata;
>  size_t boot_splash_filedata_size;
>  uint8_t qemu_extra_params_fw[2];
> +uint32_t debug_port = 0xe9;
>  
>  int icount_align_option;
>  
> @@ -2584,6 +2585,17 @@ static int debugcon_parse(const char *devname)
>      return 0;
>  }
>  
> +static void debugcon_parse_port(const char *arg)
> +{
> +    uint32_t port;
> +
> +    port = strtoul(arg, NULL, 0);
> +    if (port) {
> +        printf("Re-assign debug console to port 0x%08x.\n", port);
> +        debug_port = port;
> +    }
> +}
> +
>  static gint machine_class_cmp(gconstpointer a, gconstpointer b)
>  {
>      const MachineClass *mc1 = a, *mc2 = b;
> @@ -3580,6 +3592,9 @@ int main(int argc, char **argv, char **envp)
>              case QEMU_OPTION_debugcon:
>                  add_device_config(DEV_DEBUGCON, optarg);
>                  break;
> +            case QEMU_OPTION_debugport:
> +                debugcon_parse_port(optarg);
> +                break;
>              case QEMU_OPTION_loadvm:
>                  loadvm = optarg;
>                  break;
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
  2016-08-05 10:57 ` Igor Mammedov
@ 2016-08-05 21:47   ` Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2016-08-05 21:47 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Michael S. Tsirkin, Shannon Zhao, qemu-arm, Lv Zheng, qemu-devel, armbru

Hi,

> From: Igor Mammedov [mailto:imammedo@redhat.com]
> Subject: Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to
> allow changing debug console port number
> 
> On Fri,  5 Aug 2016 18:19:39 +0800
> Lv Zheng <lv.zheng@intel.com> wrote:
> 
> > Changing debugcon port to 0x402 allows the seabios AML table pre-
> defined
> > DBUG() control method to be able to dump the AML debugging
> information to
> > the re-directed debugging console.
> >
> > If the debug port number is configurable, users can further specify a
> > proper IO port number for it to make external BIOS's debugging
> > facility functioning.
> 
> there is no need for yet another CLI option that is being added here,
> just use usual '-device isa-debugcon,iobase=0x402,chardev=seabios"
> 

[Lv Zheng] 
OK, thanks for the information.

However, I feel that there are still improvements we can do here:
1. synchronizing DSDT's DBG operation region to debugcon iobase in acpi-build.c;
2. the readback should be automatically corrected by the isa-debugcon.iobase.
What do you think of this?
And if one of the above stuffs is useful, do you need me to send a revised patch?

Cheers
Lv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
  2016-08-05 12:15 ` Paolo Bonzini
@ 2016-08-05 21:48   ` Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2016-08-05 21:48 UTC (permalink / raw)
  To: Paolo Bonzini, Michael S. Tsirkin, Igor Mammedov, Shannon Zhao
  Cc: qemu-arm, Lv Zheng, qemu-devel

Hi,

> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo
> Bonzini
> Subject: Re: [PATCH] debugcon: Add -debugport option to allow changing
> debug console port number
> 
> 
> 
> On 05/08/2016 12:19, Lv Zheng wrote:
> > Changing debugcon port to 0x402 allows the seabios AML table pre-
> defined
> > DBUG() control method to be able to dump the AML debugging
> information to
> > the re-directed debugging console.
> >
> > If the debug port number is configurable, users can further specify a
> > proper IO port number for it to make external BIOS's debugging
> > facility functioning.
> >
> > Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> 
> You can do this with
> 
>    -global isa-debugcon.iobase=0x402
[Lv Zheng] 
Thanks for the information. :)

Best regards
Lv


> 
> Paolo
> 
> > ---
> >  hw/char/debugcon.c      |    4 ++++
> >  hw/i386/acpi-build.c    |    3 ++-
> >  include/sysemu/sysemu.h |    1 +
> >  qemu-options.hx         |    9 +++++++++
> >  vl.c                    |   15 +++++++++++++++
> >  5 files changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
> > index e7f025e..f966a09 100644
> > --- a/hw/char/debugcon.c
> > +++ b/hw/char/debugcon.c
> > @@ -105,6 +105,10 @@ static void debugcon_isa_realizefn(DeviceState
> *dev, Error **errp)
> >          error_propagate(errp, err);
> >          return;
> >      }
> > +    if (debug_port != 0xe9) {
> > +        qdev_prop_set_uint32(dev, "iobase", debug_port);
> > +        qdev_prop_set_uint32(dev, "readback", debug_port);
> > +    }
> >      memory_region_init_io(&s->io, OBJECT(dev), &debugcon_ops, s,
> >                            TYPE_ISA_DEBUGCON_DEVICE, 1);
> >      memory_region_add_subregion(isa_address_space_io(d),
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index a26a4bb..14c6224 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1442,7 +1442,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(debug_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/sysemu/sysemu.h b/include/sysemu/sysemu.h
> > index ee7c760..9e0a30b 100644
> > --- a/include/sysemu/sysemu.h
> > +++ b/include/sysemu/sysemu.h
> > @@ -167,6 +167,7 @@ extern uint8_t qemu_extra_params_fw[2];
> >  extern QEMUClockType rtc_clock;
> >  extern const char *mem_path;
> >  extern int mem_prealloc;
> > +extern uint32_t debug_port;
> >
> >  #define MAX_NODES 128
> >  #define NUMA_NODE_UNASSIGNED MAX_NODES
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index a71aaf8..05aedce 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -3123,6 +3123,15 @@ The default device is @code{vc} in graphical
> mode and @code{stdio} in
> >  non graphical mode.
> >  ETEXI
> >
> > +DEF("debugport", HAS_ARG, QEMU_OPTION_debugport, \
> > +    "-debugport n     Specify debug IO port number\n",
> > +    QEMU_ARCH_ALL)
> > +STEXI
> > +@item -debugport @var{n}
> > +@findex -debugport
> > +Specify the debug IO port number, default is 0xe9.
> > +ETEXI
> > +
> >  DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
> >      "-pidfile file   write PID to 'file'\n", QEMU_ARCH_ALL)
> >  STEXI
> > diff --git a/vl.c b/vl.c
> > index e7c2c62..710e14d 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -178,6 +178,7 @@ bool boot_strict;
> >  uint8_t *boot_splash_filedata;
> >  size_t boot_splash_filedata_size;
> >  uint8_t qemu_extra_params_fw[2];
> > +uint32_t debug_port = 0xe9;
> >
> >  int icount_align_option;
> >
> > @@ -2584,6 +2585,17 @@ static int debugcon_parse(const char
> *devname)
> >      return 0;
> >  }
> >
> > +static void debugcon_parse_port(const char *arg)
> > +{
> > +    uint32_t port;
> > +
> > +    port = strtoul(arg, NULL, 0);
> > +    if (port) {
> > +        printf("Re-assign debug console to port 0x%08x.\n", port);
> > +        debug_port = port;
> > +    }
> > +}
> > +
> >  static gint machine_class_cmp(gconstpointer a, gconstpointer b)
> >  {
> >      const MachineClass *mc1 = a, *mc2 = b;
> > @@ -3580,6 +3592,9 @@ int main(int argc, char **argv, char **envp)
> >              case QEMU_OPTION_debugcon:
> >                  add_device_config(DEV_DEBUGCON, optarg);
> >                  break;
> > +            case QEMU_OPTION_debugport:
> > +                debugcon_parse_port(optarg);
> > +                break;
> >              case QEMU_OPTION_loadvm:
> >                  loadvm = optarg;
> >                  break;
> >

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
  2016-08-05 10:19 [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number Lv Zheng
  2016-08-05 10:57 ` Igor Mammedov
  2016-08-05 12:15 ` Paolo Bonzini
@ 2016-08-07  6:00 ` Michael S. Tsirkin
  2016-08-08  1:36   ` Zheng, Lv
  2016-08-08  7:26 ` [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method Lv Zheng
  3 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2016-08-07  6:00 UTC (permalink / raw)
  To: Lv Zheng; +Cc: Igor Mammedov, Shannon Zhao, Lv Zheng, qemu-devel, qemu-arm

On Fri, Aug 05, 2016 at 06:19:39PM +0800, Lv Zheng wrote:
> Changing debugcon port to 0x402 allows the seabios AML table pre-defined
> DBUG() control method to be able to dump the AML debugging information to
> the re-directed debugging console.
> 
> If the debug port number is configurable, users can further specify a
> proper IO port number for it to make external BIOS's debugging
> facility functioning.
> 
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>

This doesn't look like a reasonable interface.

How will user know which io ports are safe to use,
to avoid e.g. conflicts with pci devices?



> ---
>  hw/char/debugcon.c      |    4 ++++
>  hw/i386/acpi-build.c    |    3 ++-
>  include/sysemu/sysemu.h |    1 +
>  qemu-options.hx         |    9 +++++++++
>  vl.c                    |   15 +++++++++++++++
>  5 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
> index e7f025e..f966a09 100644
> --- a/hw/char/debugcon.c
> +++ b/hw/char/debugcon.c
> @@ -105,6 +105,10 @@ static void debugcon_isa_realizefn(DeviceState *dev, Error **errp)
>          error_propagate(errp, err);
>          return;
>      }
> +    if (debug_port != 0xe9) {
> +        qdev_prop_set_uint32(dev, "iobase", debug_port);
> +        qdev_prop_set_uint32(dev, "readback", debug_port);
> +    }
>      memory_region_init_io(&s->io, OBJECT(dev), &debugcon_ops, s,
>                            TYPE_ISA_DEBUGCON_DEVICE, 1);
>      memory_region_add_subregion(isa_address_space_io(d),
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index a26a4bb..14c6224 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1442,7 +1442,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(debug_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/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index ee7c760..9e0a30b 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -167,6 +167,7 @@ extern uint8_t qemu_extra_params_fw[2];
>  extern QEMUClockType rtc_clock;
>  extern const char *mem_path;
>  extern int mem_prealloc;
> +extern uint32_t debug_port;
>  
>  #define MAX_NODES 128
>  #define NUMA_NODE_UNASSIGNED MAX_NODES
> diff --git a/qemu-options.hx b/qemu-options.hx
> index a71aaf8..05aedce 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3123,6 +3123,15 @@ The default device is @code{vc} in graphical mode and @code{stdio} in
>  non graphical mode.
>  ETEXI
>  
> +DEF("debugport", HAS_ARG, QEMU_OPTION_debugport, \
> +    "-debugport n     Specify debug IO port number\n",
> +    QEMU_ARCH_ALL)
> +STEXI
> +@item -debugport @var{n}
> +@findex -debugport
> +Specify the debug IO port number, default is 0xe9.
> +ETEXI
> +
>  DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
>      "-pidfile file   write PID to 'file'\n", QEMU_ARCH_ALL)
>  STEXI
> diff --git a/vl.c b/vl.c
> index e7c2c62..710e14d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -178,6 +178,7 @@ bool boot_strict;
>  uint8_t *boot_splash_filedata;
>  size_t boot_splash_filedata_size;
>  uint8_t qemu_extra_params_fw[2];
> +uint32_t debug_port = 0xe9;
>  
>  int icount_align_option;
>  
> @@ -2584,6 +2585,17 @@ static int debugcon_parse(const char *devname)
>      return 0;
>  }
>  
> +static void debugcon_parse_port(const char *arg)
> +{
> +    uint32_t port;
> +
> +    port = strtoul(arg, NULL, 0);
> +    if (port) {
> +        printf("Re-assign debug console to port 0x%08x.\n", port);
> +        debug_port = port;
> +    }
> +}
> +
>  static gint machine_class_cmp(gconstpointer a, gconstpointer b)
>  {
>      const MachineClass *mc1 = a, *mc2 = b;
> @@ -3580,6 +3592,9 @@ int main(int argc, char **argv, char **envp)
>              case QEMU_OPTION_debugcon:
>                  add_device_config(DEV_DEBUGCON, optarg);
>                  break;
> +            case QEMU_OPTION_debugport:
> +                debugcon_parse_port(optarg);
> +                break;
>              case QEMU_OPTION_loadvm:
>                  loadvm = optarg;
>                  break;
> -- 
> 1.7.10

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number
  2016-08-07  6:00 ` Michael S. Tsirkin
@ 2016-08-08  1:36   ` Zheng, Lv
  0 siblings, 0 replies; 10+ messages in thread
From: Zheng, Lv @ 2016-08-08  1:36 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Igor Mammedov, Shannon Zhao, Lv Zheng, qemu-devel, qemu-arm

Hi, Michael

> From: Michael S. Tsirkin [mailto:mst@redhat.com]
> Subject: Re: [PATCH] debugcon: Add -debugport option to allow changing
> debug console port number
> 
> On Fri, Aug 05, 2016 at 06:19:39PM +0800, Lv Zheng wrote:
> > Changing debugcon port to 0x402 allows the seabios AML table pre-
> defined
> > DBUG() control method to be able to dump the AML debugging
> information to
> > the re-directed debugging console.
> >
> > If the debug port number is configurable, users can further specify a
> > proper IO port number for it to make external BIOS's debugging
> > facility functioning.
> >
> > Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> 
> This doesn't look like a reasonable interface.
> 
> How will user know which io ports are safe to use,
> to avoid e.g. conflicts with pci devices?
> 
[Lv Zheng] 
OK, I'll just correct the acpi-build.c.

Thanks
Lv

> 
> 
> > ---
> >  hw/char/debugcon.c      |    4 ++++
> >  hw/i386/acpi-build.c    |    3 ++-
> >  include/sysemu/sysemu.h |    1 +
> >  qemu-options.hx         |    9 +++++++++
> >  vl.c                    |   15 +++++++++++++++
> >  5 files changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c
> > index e7f025e..f966a09 100644
> > --- a/hw/char/debugcon.c
> > +++ b/hw/char/debugcon.c
> > @@ -105,6 +105,10 @@ static void debugcon_isa_realizefn(DeviceState
> *dev, Error **errp)
> >          error_propagate(errp, err);
> >          return;
> >      }
> > +    if (debug_port != 0xe9) {
> > +        qdev_prop_set_uint32(dev, "iobase", debug_port);
> > +        qdev_prop_set_uint32(dev, "readback", debug_port);
> > +    }
> >      memory_region_init_io(&s->io, OBJECT(dev), &debugcon_ops, s,
> >                            TYPE_ISA_DEBUGCON_DEVICE, 1);
> >      memory_region_add_subregion(isa_address_space_io(d),
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index a26a4bb..14c6224 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1442,7 +1442,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(debug_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/sysemu/sysemu.h b/include/sysemu/sysemu.h
> > index ee7c760..9e0a30b 100644
> > --- a/include/sysemu/sysemu.h
> > +++ b/include/sysemu/sysemu.h
> > @@ -167,6 +167,7 @@ extern uint8_t qemu_extra_params_fw[2];
> >  extern QEMUClockType rtc_clock;
> >  extern const char *mem_path;
> >  extern int mem_prealloc;
> > +extern uint32_t debug_port;
> >
> >  #define MAX_NODES 128
> >  #define NUMA_NODE_UNASSIGNED MAX_NODES
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index a71aaf8..05aedce 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -3123,6 +3123,15 @@ The default device is @code{vc} in graphical
> mode and @code{stdio} in
> >  non graphical mode.
> >  ETEXI
> >
> > +DEF("debugport", HAS_ARG, QEMU_OPTION_debugport, \
> > +    "-debugport n     Specify debug IO port number\n",
> > +    QEMU_ARCH_ALL)
> > +STEXI
> > +@item -debugport @var{n}
> > +@findex -debugport
> > +Specify the debug IO port number, default is 0xe9.
> > +ETEXI
> > +
> >  DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
> >      "-pidfile file   write PID to 'file'\n", QEMU_ARCH_ALL)
> >  STEXI
> > diff --git a/vl.c b/vl.c
> > index e7c2c62..710e14d 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -178,6 +178,7 @@ bool boot_strict;
> >  uint8_t *boot_splash_filedata;
> >  size_t boot_splash_filedata_size;
> >  uint8_t qemu_extra_params_fw[2];
> > +uint32_t debug_port = 0xe9;
> >
> >  int icount_align_option;
> >
> > @@ -2584,6 +2585,17 @@ static int debugcon_parse(const char
> *devname)
> >      return 0;
> >  }
> >
> > +static void debugcon_parse_port(const char *arg)
> > +{
> > +    uint32_t port;
> > +
> > +    port = strtoul(arg, NULL, 0);
> > +    if (port) {
> > +        printf("Re-assign debug console to port 0x%08x.\n", port);
> > +        debug_port = port;
> > +    }
> > +}
> > +
> >  static gint machine_class_cmp(gconstpointer a, gconstpointer b)
> >  {
> >      const MachineClass *mc1 = a, *mc2 = b;
> > @@ -3580,6 +3592,9 @@ int main(int argc, char **argv, char **envp)
> >              case QEMU_OPTION_debugcon:
> >                  add_device_config(DEV_DEBUGCON, optarg);
> >                  break;
> > +            case QEMU_OPTION_debugport:
> > +                debugcon_parse_port(optarg);
> > +                break;
> >              case QEMU_OPTION_loadvm:
> >                  loadvm = optarg;
> >                  break;
> > --
> > 1.7.10

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method
  2016-08-05 10:19 [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number Lv Zheng
                   ` (2 preceding siblings ...)
  2016-08-07  6:00 ` Michael S. Tsirkin
@ 2016-08-08  7:26 ` Lv Zheng
  2016-08-08  9:02   ` Paolo Bonzini
  2016-08-08  9:30   ` Igor Mammedov
  3 siblings, 2 replies; 10+ messages in thread
From: Lv Zheng @ 2016-08-08  7:26 UTC (permalink / raw)
  To: Michael S. Tsirkin, Igor Mammedov, Shannon Zhao
  Cc: Lv Zheng, Lv Zheng, qemu-devel, qemu-arm

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
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method
  2016-08-08  7:26 ` [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method Lv Zheng
@ 2016-08-08  9:02   ` Paolo Bonzini
  2016-08-08  9:30   ` Igor Mammedov
  1 sibling, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2016-08-08  9:02 UTC (permalink / raw)
  To: Lv Zheng, Michael S. Tsirkin, Igor Mammedov, Shannon Zhao
  Cc: qemu-arm, Lv Zheng, qemu-devel



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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method
  2016-08-08  7:26 ` [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method Lv Zheng
  2016-08-08  9:02   ` Paolo Bonzini
@ 2016-08-08  9:30   ` Igor Mammedov
  1 sibling, 0 replies; 10+ messages in thread
From: Igor Mammedov @ 2016-08-08  9:30 UTC (permalink / raw)
  To: Lv Zheng; +Cc: Michael S. Tsirkin, Shannon Zhao, qemu-arm, Lv Zheng, qemu-devel

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-08-08  9:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-05 10:19 [Qemu-devel] [PATCH] debugcon: Add -debugport option to allow changing debug console port number Lv Zheng
2016-08-05 10:57 ` Igor Mammedov
2016-08-05 21:47   ` Zheng, Lv
2016-08-05 12:15 ` Paolo Bonzini
2016-08-05 21:48   ` Zheng, Lv
2016-08-07  6:00 ` Michael S. Tsirkin
2016-08-08  1:36   ` Zheng, Lv
2016-08-08  7:26 ` [Qemu-devel] [PATCH v2] ACPI: Enable AML DBUG() control method Lv Zheng
2016-08-08  9:02   ` Paolo Bonzini
2016-08-08  9:30   ` Igor Mammedov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.