]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ia32/irq_chip_pic.cpp
Update
[l4.git] / kernel / fiasco / src / kern / ia32 / irq_chip_pic.cpp
1 INTERFACE:
2
3 #include "i8259.h"
4 #include "io.h"
5 #include "irq_chip_ia32.h"
6 #include "irq_mgr.h"
7
8 /**
9  * IRQ Chip based on the IA32 legacy PIC.
10  *
11  * 16 Vectors starting from Base_vector are statically assigned.
12  */
13 class Irq_chip_ia32_pic :
14   public Irq_chip_i8259<Io>,
15   private Irq_chip_ia32,
16   private Irq_mgr
17 {
18   friend class Irq_chip_ia32;
19 public:
20   bool reserve(Mword pin) override { return Irq_chip_ia32::reserve(pin); }
21   Irq_base *irq(Mword pin) const override { return Irq_chip_ia32::irq(pin); }
22
23 private:
24   enum { Base_vector = 0x20 };
25 };
26
27
28 IMPLEMENTATION:
29
30 #include <cassert>
31
32 #include "boot_alloc.h"
33 #include "cpu_lock.h"
34 #include "globalconfig.h"
35 #include "globals.h"
36 #include "irq_mgr.h"
37 #include "pic.h"
38
39 PUBLIC
40 bool
41 Irq_chip_ia32_pic::alloc(Irq_base *irq, Mword irqn) override
42 {
43   // no mor than 16 IRQs
44   if (irqn > 0xf)
45     return false;
46
47   // PIC uses 16 vectors from Base_vector statically
48   unsigned vector = Base_vector + irqn;
49   return valloc<Irq_chip_ia32_pic>(irq, irqn, vector);
50 }
51
52 PUBLIC
53 void
54 Irq_chip_ia32_pic::unbind(Irq_base *irq) override
55 {
56   extern char entry_int_pic_ignore[];
57   mask(irq->pin());
58   vfree(irq, &entry_int_pic_ignore);
59   Irq_chip::unbind(irq);
60 }
61
62 PRIVATE
63 Irq_mgr::Irq
64 Irq_chip_ia32_pic::chip(Mword irq) const override
65 {
66   if (irq < 16)
67     return Irq(const_cast<Irq_chip_ia32_pic*>(this), irq);
68
69   return Irq();
70 }
71
72 PUBLIC
73 unsigned
74 Irq_chip_ia32_pic::nr_irqs() const override
75 { return 16; }
76
77 PUBLIC
78 unsigned
79 Irq_chip_ia32_pic::nr_msis() const override
80 { return 0; }
81
82
83 // ------------------------------------------------------------------------
84 IMPLEMENTATION [ux]:
85
86 PUBLIC static FIASCO_INIT
87 void
88 Irq_chip_ia32_pic::init()
89 {
90   Irq_mgr::mgr = new Boot_object<Pic_irq_mgr>();
91 }
92
93 // ------------------------------------------------------------------------
94 IMPLEMENTATION [!ux]:
95
96 #include "koptions.h"
97
98 PUBLIC
99 Irq_chip_ia32_pic::Irq_chip_ia32_pic()
100 : Irq_chip_i8259<Io>(0x20, 0xa0), Irq_chip_ia32(16)
101 {
102   Irq_mgr::mgr = this;
103   bool sfn = !Koptions::o()->opt(Koptions::F_nosfn);
104   init(Base_vector, sfn,
105        Config::Pic_prio_modify
106        && (int)Config::Scheduler_mode == Config::SCHED_RTC);
107
108   reserve(2); // reserve cascade irq
109   reserve(7); // reserve spurious vect
110 }