diff mbox

[V9,09/16] xen: add a 8259 Interrupt Controller

Message ID 1295965760-31508-10-git-send-email-anthony.perard@citrix.com
State New
Headers show

Commit Message

Anthony PERARD Jan. 25, 2011, 2:29 p.m. UTC
From: Anthony PERARD <anthony.perard@citrix.com>

Introduce a 8259 Interrupt Controller for target-xen; every set_irq
call makes a Xen hypercall.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 hw/xen_common.h     |    2 ++
 hw/xen_machine_fv.c |    5 ++---
 xen-all.c           |   12 ++++++++++++
 3 files changed, 16 insertions(+), 3 deletions(-)

Comments

Anthony Liguori Jan. 26, 2011, 11:04 p.m. UTC | #1
On 01/25/2011 08:29 AM, anthony.perard@citrix.com wrote:
> From: Anthony PERARD<anthony.perard@citrix.com>
>
> Introduce a 8259 Interrupt Controller for target-xen; every set_irq
> call makes a Xen hypercall.
>
> Signed-off-by: Anthony PERARD<anthony.perard@citrix.com>
> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> ---
>   hw/xen_common.h     |    2 ++
>   hw/xen_machine_fv.c |    5 ++---
>   xen-all.c           |   12 ++++++++++++
>   3 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/hw/xen_common.h b/hw/xen_common.h
> index b98d107..0cc935a 100644
> --- a/hw/xen_common.h
> +++ b/hw/xen_common.h
> @@ -42,4 +42,6 @@ static inline int xc_fd(xc_interface *xen_xc)
>   }
>   #endif
>
> +qemu_irq *i8259_xen_init(void);
> +
>   #endif /* QEMU_HW_XEN_COMMON_H */
> diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
> index 2f51625..0a90312 100644
> --- a/hw/xen_machine_fv.c
> +++ b/hw/xen_machine_fv.c
> @@ -37,6 +37,7 @@
>   #include "xen_common.h"
>   #include "xen/hvm/hvm_info_table.h"
>   #include "xen_platform.h"
> +#include "xen_common.h"
>
>   #define MAX_IDE_BUS 2
>
> @@ -52,7 +53,6 @@ static void xen_init_fv(ram_addr_t ram_size,
>       PCIBus *pci_bus;
>       PCII440FXState *i440fx_state;
>       int piix3_devfn = -1;
> -    qemu_irq *cpu_irq;
>       qemu_irq *isa_irq;
>       qemu_irq *i8259;
>       qemu_irq *cmos_s3;
> @@ -76,8 +76,7 @@ static void xen_init_fv(ram_addr_t ram_size,
>       env = cpu_init(cpu_model);
>       env->halted = 1;
>
> -    cpu_irq = pc_allocate_cpu_irq();
> -    i8259 = i8259_init(cpu_irq[0]);
> +    i8259 = i8259_xen_init();
>       isa_irq_state = qemu_mallocz(sizeof (*isa_irq_state));
>       isa_irq_state->i8259 = i8259;
>
> diff --git a/xen-all.c b/xen-all.c
> index 8a51873..205cbc4 100644
> --- a/xen-all.c
> +++ b/xen-all.c
> @@ -43,6 +43,18 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
>       }
>   }
>
> +/* i8259 */
> +
> +static void i8259_set_irq(void *opaque, int irq, int level)
> +{
> +    xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
> +}
> +
> +qemu_irq *i8259_xen_init(void)
> +{
> +    return qemu_allocate_irqs(i8259_set_irq, NULL, 16);
> +}
> +
>    


I think it would make more sense to just call it a Xen interrupt 
controller as it's clearly not an i8259.  Xen may emulate an i8259 in 
the kernel but this has nothing to do with that AFAIK.

Regards,

Anthony Liguori

>   /* Initialise Xen */
>
>   int xen_init(int smp_cpus)
>
Anthony PERARD Jan. 27, 2011, 5:19 p.m. UTC | #2
On Wed, 26 Jan 2011, Anthony Liguori wrote:

> On 01/25/2011 08:29 AM, anthony.perard@citrix.com wrote:
> > From: Anthony PERARD<anthony.perard@citrix.com>
> >
> > Introduce a 8259 Interrupt Controller for target-xen; every set_irq
> > call makes a Xen hypercall.
> >
> > Signed-off-by: Anthony PERARD<anthony.perard@citrix.com>
> > Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> > ---
> >   hw/xen_common.h     |    2 ++
> >   hw/xen_machine_fv.c |    5 ++---
> >   xen-all.c           |   12 ++++++++++++
> >   3 files changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/xen_common.h b/hw/xen_common.h
> > index b98d107..0cc935a 100644
> > --- a/hw/xen_common.h
> > +++ b/hw/xen_common.h
> > @@ -42,4 +42,6 @@ static inline int xc_fd(xc_interface *xen_xc)
> >   }
> >   #endif
> >
> > +qemu_irq *i8259_xen_init(void);
> > +
> >   #endif /* QEMU_HW_XEN_COMMON_H */
> > diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
> > index 2f51625..0a90312 100644
> > --- a/hw/xen_machine_fv.c
> > +++ b/hw/xen_machine_fv.c
> > @@ -37,6 +37,7 @@
> >   #include "xen_common.h"
> >   #include "xen/hvm/hvm_info_table.h"
> >   #include "xen_platform.h"
> > +#include "xen_common.h"
> >
> >   #define MAX_IDE_BUS 2
> >
> > @@ -52,7 +53,6 @@ static void xen_init_fv(ram_addr_t ram_size,
> >       PCIBus *pci_bus;
> >       PCII440FXState *i440fx_state;
> >       int piix3_devfn = -1;
> > -    qemu_irq *cpu_irq;
> >       qemu_irq *isa_irq;
> >       qemu_irq *i8259;
> >       qemu_irq *cmos_s3;
> > @@ -76,8 +76,7 @@ static void xen_init_fv(ram_addr_t ram_size,
> >       env = cpu_init(cpu_model);
> >       env->halted = 1;
> >
> > -    cpu_irq = pc_allocate_cpu_irq();
> > -    i8259 = i8259_init(cpu_irq[0]);
> > +    i8259 = i8259_xen_init();
> >       isa_irq_state = qemu_mallocz(sizeof (*isa_irq_state));
> >       isa_irq_state->i8259 = i8259;
> >
> > diff --git a/xen-all.c b/xen-all.c
> > index 8a51873..205cbc4 100644
> > --- a/xen-all.c
> > +++ b/xen-all.c
> > @@ -43,6 +43,18 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
> >       }
> >   }
> >
> > +/* i8259 */
> > +
> > +static void i8259_set_irq(void *opaque, int irq, int level)
> > +{
> > +    xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
> > +}
> > +
> > +qemu_irq *i8259_xen_init(void)
> > +{
> > +    return qemu_allocate_irqs(i8259_set_irq, NULL, 16);
> > +}
> > +
> >
>
>
> I think it would make more sense to just call it a Xen interrupt
> controller as it's clearly not an i8259.  Xen may emulate an i8259 in
> the kernel but this has nothing to do with that AFAIK.
>
> Regards,
>
> Anthony Liguori

I will do that.

Thanks,
diff mbox

Patch

diff --git a/hw/xen_common.h b/hw/xen_common.h
index b98d107..0cc935a 100644
--- a/hw/xen_common.h
+++ b/hw/xen_common.h
@@ -42,4 +42,6 @@  static inline int xc_fd(xc_interface *xen_xc)
 }
 #endif
 
+qemu_irq *i8259_xen_init(void);
+
 #endif /* QEMU_HW_XEN_COMMON_H */
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index 2f51625..0a90312 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -37,6 +37,7 @@ 
 #include "xen_common.h"
 #include "xen/hvm/hvm_info_table.h"
 #include "xen_platform.h"
+#include "xen_common.h"
 
 #define MAX_IDE_BUS 2
 
@@ -52,7 +53,6 @@  static void xen_init_fv(ram_addr_t ram_size,
     PCIBus *pci_bus;
     PCII440FXState *i440fx_state;
     int piix3_devfn = -1;
-    qemu_irq *cpu_irq;
     qemu_irq *isa_irq;
     qemu_irq *i8259;
     qemu_irq *cmos_s3;
@@ -76,8 +76,7 @@  static void xen_init_fv(ram_addr_t ram_size,
     env = cpu_init(cpu_model);
     env->halted = 1;
 
-    cpu_irq = pc_allocate_cpu_irq();
-    i8259 = i8259_init(cpu_irq[0]);
+    i8259 = i8259_xen_init();
     isa_irq_state = qemu_mallocz(sizeof (*isa_irq_state));
     isa_irq_state->i8259 = i8259;
 
diff --git a/xen-all.c b/xen-all.c
index 8a51873..205cbc4 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -43,6 +43,18 @@  void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
     }
 }
 
+/* i8259 */
+
+static void i8259_set_irq(void *opaque, int irq, int level)
+{
+    xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
+}
+
+qemu_irq *i8259_xen_init(void)
+{
+    return qemu_allocate_irqs(i8259_set_irq, NULL, 16);
+}
+
 /* Initialise Xen */
 
 int xen_init(int smp_cpus)