]> rtime.felk.cvut.cz Git - l4.git/blobdiff - kernel/fiasco/src/kern/irq_mgr.cpp
Update
[l4.git] / kernel / fiasco / src / kern / irq_mgr.cpp
index 77221fee88f4d58ebfde41eec3dc7732b398d1e2..f8a054b540171bada6ebfc1e2f329457585563f9 100644 (file)
@@ -2,9 +2,11 @@ INTERFACE:
 
 #include "types.h"
 #include "irq_chip.h"
+#include "l4_types.h"
+#include <cxx/type_traits>
 
 /**
- * Interface used to manage harware IRQs on a platform.
+ * Interface used to manage hardware IRQs on a platform.
  *
  * The main purpose of this interface is to allow an
  * abstract mapping of global IRQ numbers to a chip
@@ -14,6 +16,12 @@ INTERFACE:
 class Irq_mgr
 {
 public:
+  struct Msi_info
+  {
+    Unsigned64 addr;
+    Unsigned32 data;
+  };
+
   /**
    * Chip and pin for an IRQ pin.
    */
@@ -51,9 +59,10 @@ public:
   /** Get the message to use for a given MSI.
    * \pre The IRQ pin needs to be already allocated before using this function.
    */
-  virtual Mword msg(Mword irqnum) const { (void)irqnum; return 0; }
+  virtual int msg(Mword irqnum, Unsigned64, Msi_info *) const
+  { (void)irqnum; return -L4_err::EPerm; }
 
-  virtual void set_cpu(Mword irqnum, unsigned cpu) const;
+  virtual void set_cpu(Mword irqnum, Cpu_number cpu) const;
 
   /// The pointer to the single global instance of the actual IRQ manager.
   static Irq_mgr *mgr;
@@ -68,12 +77,8 @@ class Irq_mgr_single_chip : public Irq_mgr
 public:
   Irq_mgr_single_chip() {}
 
-  template<typename A1>
-  explicit Irq_mgr_single_chip(A1 const &a1) : c(a1) {}
-
-  template<typename A1, typename A2>
-  Irq_mgr_single_chip(A1 const &a1, A2 const &a2) : c(a1, a2) {}
-
+  template< typename... A >
+  explicit Irq_mgr_single_chip(A&&... args) : c(cxx::forward<A>(args)...) {}
 
   Irq chip(Mword irqnum) const { return Irq(&c, irqnum); }
   unsigned nr_irqs() const { return c.nr_irqs(); }
@@ -92,13 +97,18 @@ IMPLEMENT inline Irq_mgr::~Irq_mgr() {}
 
 PUBLIC inline
 bool
-Irq_mgr::alloc(Irq_base *irq, Mword pin)
+Irq_mgr::alloc(Irq_base *irq, Mword global_irq)
 {
-  Irq i = chip(pin);
+  Irq i = chip(global_irq);
   if (!i.chip)
     return false;
 
-  return i.chip->alloc(irq, i.pin);
+  if (i.chip->alloc(irq, i.pin))
+    {
+      i.chip->set_cpu(i.pin, Cpu_number::boot_cpu());
+      return true;
+    }
+  return false;
 }
 
 PUBLIC inline
@@ -125,7 +135,11 @@ Irq_mgr::irq(Mword irqnum) const
 
 IMPLEMENT
 void
-Irq_mgr::set_cpu(Mword irqnum, unsigned cpu) const
+Irq_mgr::set_cpu(Mword irqnum, Cpu_number cpu) const
 {
-  WARNX(Warning, "IRQ%ld: ignoring CPU setting (%d).\n", irqnum, cpu);
+  Irq i = chip(irqnum);
+  if (!i.chip)
+    return;
+
+  return i.chip->set_cpu(i.pin, cpu);
 }