diff mbox

[v19,4/7] pvpanic: pass configurable ioport to seabios

Message ID 41b83b75f11879953c8951654321b4ce5a4e2132.1366250561.git.hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao April 18, 2013, 2:14 a.m. UTC
This lets seabios patch the corresponding SSDT entry.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 hw/misc/pvpanic.c         | 14 ++++++++++++++
 hw/nvram/fw_cfg.c         |  8 +++++++-
 include/hw/nvram/fw_cfg.h |  2 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

Comments

Markus Armbruster April 18, 2013, 9:22 a.m. UTC | #1
Hu Tao <hutao@cn.fujitsu.com> writes:

> This lets seabios patch the corresponding SSDT entry.
>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/misc/pvpanic.c         | 14 ++++++++++++++
>  hw/nvram/fw_cfg.c         |  8 +++++++-
>  include/hw/nvram/fw_cfg.h |  2 ++
>  3 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
> index c3adcdf..23599a3 100644
> --- a/hw/misc/pvpanic.c
> +++ b/hw/misc/pvpanic.c
> @@ -18,6 +18,8 @@
>  #include <sysemu/sysemu.h>
>  #include <sysemu/kvm.h>
>  
> +#include "hw/nvram/fw_cfg.h"
> +
>  /* The bit of supported pv event */
>  #define PVPANIC_F_PANICKED      0
>  
> @@ -86,10 +88,22 @@ static const MemoryRegionOps pvpanic_ops = {
>  static int pvpanic_isa_initfn(ISADevice *dev)
>  {
>      PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
> +    static bool port_configured;
> +    void *fw_cfg;
>  
>      memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1);
>      isa_register_ioport(dev, &s->io, s->ioport);
>  
> +    if (!port_configured) {
> +        fw_cfg = object_resolve_path("/machine/fw_cfg", NULL);
> +        if (fw_cfg) {
> +            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
> +                            g_memdup(&s->ioport, sizeof(s->ioport)),
> +                            sizeof(s->ioport));
> +            port_configured = true;
> +        }
> +    }
> +
>      return 0;
>  }
>  
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 97bba87..1a7e49c 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -489,11 +489,17 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
>      dev = qdev_create(NULL, "fw_cfg");
>      qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
>      qdev_prop_set_uint32(dev, "data_iobase", data_port);
> -    qdev_init_nofail(dev);
>      d = SYS_BUS_DEVICE(dev);
>  
>      s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
>  
> +    if (!object_resolve_path("/machine/fw_cfg", NULL)) {
> +        object_property_add_child(qdev_get_machine(), "fw_cfg", OBJECT(s),
> +                                  NULL);
> +    }
> +
> +    qdev_init_nofail(dev);
> +
>      if (ctl_addr) {
>          sysbus_mmio_map(d, 0, ctl_addr);
>      }
> diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
> index 05c8df1..07cc941 100644
> --- a/include/hw/nvram/fw_cfg.h
> +++ b/include/hw/nvram/fw_cfg.h
> @@ -1,6 +1,8 @@
>  #ifndef FW_CFG_H
>  #define FW_CFG_H
>  
> +#include "exec/hwaddr.h"
> +
>  #define FW_CFG_SIGNATURE        0x00
>  #define FW_CFG_ID               0x01
>  #define FW_CFG_UUID             0x02

Why is the include necessary?
Hu Tao April 19, 2013, 6:50 a.m. UTC | #2
On Thu, Apr 18, 2013 at 11:22:56AM +0200, Markus Armbruster wrote:
> Hu Tao <hutao@cn.fujitsu.com> writes:
> 
> > This lets seabios patch the corresponding SSDT entry.
> >
> > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> > ---
> >  hw/misc/pvpanic.c         | 14 ++++++++++++++
> >  hw/nvram/fw_cfg.c         |  8 +++++++-
> >  include/hw/nvram/fw_cfg.h |  2 ++
> >  3 files changed, 23 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
> > index c3adcdf..23599a3 100644
> > --- a/hw/misc/pvpanic.c
> > +++ b/hw/misc/pvpanic.c
> > @@ -18,6 +18,8 @@
> >  #include <sysemu/sysemu.h>
> >  #include <sysemu/kvm.h>
> >  
> > +#include "hw/nvram/fw_cfg.h"
> > +
> >  /* The bit of supported pv event */
> >  #define PVPANIC_F_PANICKED      0
> >  
> > @@ -86,10 +88,22 @@ static const MemoryRegionOps pvpanic_ops = {
> >  static int pvpanic_isa_initfn(ISADevice *dev)
> >  {
> >      PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
> > +    static bool port_configured;
> > +    void *fw_cfg;
> >  
> >      memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1);
> >      isa_register_ioport(dev, &s->io, s->ioport);
> >  
> > +    if (!port_configured) {
> > +        fw_cfg = object_resolve_path("/machine/fw_cfg", NULL);
> > +        if (fw_cfg) {
> > +            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
> > +                            g_memdup(&s->ioport, sizeof(s->ioport)),
> > +                            sizeof(s->ioport));
> > +            port_configured = true;
> > +        }
> > +    }
> > +
> >      return 0;
> >  }
> >  
> > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> > index 97bba87..1a7e49c 100644
> > --- a/hw/nvram/fw_cfg.c
> > +++ b/hw/nvram/fw_cfg.c
> > @@ -489,11 +489,17 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
> >      dev = qdev_create(NULL, "fw_cfg");
> >      qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
> >      qdev_prop_set_uint32(dev, "data_iobase", data_port);
> > -    qdev_init_nofail(dev);
> >      d = SYS_BUS_DEVICE(dev);
> >  
> >      s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
> >  
> > +    if (!object_resolve_path("/machine/fw_cfg", NULL)) {
> > +        object_property_add_child(qdev_get_machine(), "fw_cfg", OBJECT(s),
> > +                                  NULL);
> > +    }
> > +
> > +    qdev_init_nofail(dev);
> > +
> >      if (ctl_addr) {
> >          sysbus_mmio_map(d, 0, ctl_addr);
> >      }
> > diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
> > index 05c8df1..07cc941 100644
> > --- a/include/hw/nvram/fw_cfg.h
> > +++ b/include/hw/nvram/fw_cfg.h
> > @@ -1,6 +1,8 @@
> >  #ifndef FW_CFG_H
> >  #define FW_CFG_H
> >  
> > +#include "exec/hwaddr.h"
> > +
> >  #define FW_CFG_SIGNATURE        0x00
> >  #define FW_CFG_ID               0x01
> >  #define FW_CFG_UUID             0x02
> 
> Why is the include necessary?

Withou it gcc gives error like this:

In file included from hw/misc/pvpanic.c:21:0:
qemu/include/hw/nvram/fw_cfg.h:68:25: error: unknown type name ‘hwaddr’
qemu/include/hw/nvram/fw_cfg.h:68:42: error: unknown type name ‘hwaddr’
Markus Armbruster April 19, 2013, 8:27 a.m. UTC | #3
Hu Tao <hutao@cn.fujitsu.com> writes:

> On Thu, Apr 18, 2013 at 11:22:56AM +0200, Markus Armbruster wrote:
>> Hu Tao <hutao@cn.fujitsu.com> writes:
>> 
>> > This lets seabios patch the corresponding SSDT entry.
[...]
>> > diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
>> > index 05c8df1..07cc941 100644
>> > --- a/include/hw/nvram/fw_cfg.h
>> > +++ b/include/hw/nvram/fw_cfg.h
>> > @@ -1,6 +1,8 @@
>> >  #ifndef FW_CFG_H
>> >  #define FW_CFG_H
>> >  
>> > +#include "exec/hwaddr.h"
>> > +
>> >  #define FW_CFG_SIGNATURE        0x00
>> >  #define FW_CFG_ID               0x01
>> >  #define FW_CFG_UUID             0x02
>> 
>> Why is the include necessary?
>
> Withou it gcc gives error like this:
>
> In file included from hw/misc/pvpanic.c:21:0:
> qemu/include/hw/nvram/fw_cfg.h:68:25: error: unknown type name ‘hwaddr’
> qemu/include/hw/nvram/fw_cfg.h:68:42: error: unknown type name ‘hwaddr’

Okay, your change makes sense, but it doesn't belong into this patch.
Put it into a separate one if you need to respin anyway.
Michael S. Tsirkin May 30, 2013, 1 p.m. UTC | #4
On Thu, Apr 18, 2013 at 10:14:43AM +0800, Hu Tao wrote:
> This lets seabios patch the corresponding SSDT entry.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/misc/pvpanic.c         | 14 ++++++++++++++
>  hw/nvram/fw_cfg.c         |  8 +++++++-
>  include/hw/nvram/fw_cfg.h |  2 ++
>  3 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
> index c3adcdf..23599a3 100644
> --- a/hw/misc/pvpanic.c
> +++ b/hw/misc/pvpanic.c
> @@ -18,6 +18,8 @@
>  #include <sysemu/sysemu.h>
>  #include <sysemu/kvm.h>
>  
> +#include "hw/nvram/fw_cfg.h"
> +
>  /* The bit of supported pv event */
>  #define PVPANIC_F_PANICKED      0
>  
> @@ -86,10 +88,22 @@ static const MemoryRegionOps pvpanic_ops = {
>  static int pvpanic_isa_initfn(ISADevice *dev)
>  {
>      PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
> +    static bool port_configured;
> +    void *fw_cfg;
>  
>      memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1);
>      isa_register_ioport(dev, &s->io, s->ioport);
>  
> +    if (!port_configured) {
> +        fw_cfg = object_resolve_path("/machine/fw_cfg", NULL);
> +        if (fw_cfg) {
> +            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
> +                            g_memdup(&s->ioport, sizeof(s->ioport)),
> +                            sizeof(s->ioport));
> +            port_configured = true;
> +        }
> +    }
> +
>      return 0;
>  }
>  

Sorry about missing this when this was posted/applied.
Wouldn't it make more sense to have /machine/fw_cfg
string in a header.


> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 97bba87..1a7e49c 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -489,11 +489,17 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
>      dev = qdev_create(NULL, "fw_cfg");
>      qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
>      qdev_prop_set_uint32(dev, "data_iobase", data_port);
> -    qdev_init_nofail(dev);
>      d = SYS_BUS_DEVICE(dev);
>  
>      s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
>  
> +    if (!object_resolve_path("/machine/fw_cfg", NULL)) {

Why is this tested here?
Should be an assert(!object_resolve_path("/machine/fw_cfg", NULL))
surely?

> +        object_property_add_child(qdev_get_machine(), "fw_cfg", OBJECT(s),
> +                                  NULL);
> +    }
> +
> +    qdev_init_nofail(dev);
> +
>      if (ctl_addr) {
>          sysbus_mmio_map(d, 0, ctl_addr);
>      }
> diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
> index 05c8df1..07cc941 100644
> --- a/include/hw/nvram/fw_cfg.h
> +++ b/include/hw/nvram/fw_cfg.h
> @@ -1,6 +1,8 @@
>  #ifndef FW_CFG_H
>  #define FW_CFG_H
>  
> +#include "exec/hwaddr.h"
> +
>  #define FW_CFG_SIGNATURE        0x00
>  #define FW_CFG_ID               0x01
>  #define FW_CFG_UUID             0x02
> -- 
> 1.8.1.4
diff mbox

Patch

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index c3adcdf..23599a3 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -18,6 +18,8 @@ 
 #include <sysemu/sysemu.h>
 #include <sysemu/kvm.h>
 
+#include "hw/nvram/fw_cfg.h"
+
 /* The bit of supported pv event */
 #define PVPANIC_F_PANICKED      0
 
@@ -86,10 +88,22 @@  static const MemoryRegionOps pvpanic_ops = {
 static int pvpanic_isa_initfn(ISADevice *dev)
 {
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
+    static bool port_configured;
+    void *fw_cfg;
 
     memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1);
     isa_register_ioport(dev, &s->io, s->ioport);
 
+    if (!port_configured) {
+        fw_cfg = object_resolve_path("/machine/fw_cfg", NULL);
+        if (fw_cfg) {
+            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
+                            g_memdup(&s->ioport, sizeof(s->ioport)),
+                            sizeof(s->ioport));
+            port_configured = true;
+        }
+    }
+
     return 0;
 }
 
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 97bba87..1a7e49c 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -489,11 +489,17 @@  FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
     dev = qdev_create(NULL, "fw_cfg");
     qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
     qdev_prop_set_uint32(dev, "data_iobase", data_port);
-    qdev_init_nofail(dev);
     d = SYS_BUS_DEVICE(dev);
 
     s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
 
+    if (!object_resolve_path("/machine/fw_cfg", NULL)) {
+        object_property_add_child(qdev_get_machine(), "fw_cfg", OBJECT(s),
+                                  NULL);
+    }
+
+    qdev_init_nofail(dev);
+
     if (ctl_addr) {
         sysbus_mmio_map(d, 0, ctl_addr);
     }
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 05c8df1..07cc941 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -1,6 +1,8 @@ 
 #ifndef FW_CFG_H
 #define FW_CFG_H
 
+#include "exec/hwaddr.h"
+
 #define FW_CFG_SIGNATURE        0x00
 #define FW_CFG_ID               0x01
 #define FW_CFG_UUID             0x02