FreeNOS
IntelPIC.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBARCH_INTEL_PIC_H
19 #define __LIBARCH_INTEL_PIC_H
20 
21 #include <Types.h>
22 #include <BitOperations.h>
23 #include <IntController.h>
24 #include "IntelIO.h"
25 
40 class IntelPIC : public IntController
41 {
42  private:
43 
50  static const uint InterruptBase = 32;
51 
53  static const uint MasterBase = 0x20;
54 
56  static const uint SlaveBase = 0xa0;
57 
61  enum Registers
62  {
63  Command = 0x0,
64  Data = 0x1
65  };
66 
71  {
72  Init1 = (1 << 4) | (1 << 0),
73  CascadeMode = (0),
75  Mode8086 = (1),
76  EndOfInterrupt = (0x20)
77  };
78 
79  public:
80 
84  IntelPIC();
85 
92 
100  virtual Result enable(uint irq);
101 
109  virtual Result disable(uint irq);
110 
122  virtual Result clear(uint irq);
123 
124  private:
125 
128 
131 };
132 
139 #endif /* __LIBARCH_INTEL_PIC_H */
IntController
Interrupt controller interface.
Definition: IntController.h:35
IntelIO.h
IntelPIC::Registers
Registers
Hardware registers.
Definition: IntelPIC.h:61
Types.h
IntelPIC
Intel 8259 Programmable Interrupt Controller (PIC).
Definition: IntelPIC.h:40
IntelPIC::IntelPIC
IntelPIC()
Constructor.
Definition: IntelPIC.cpp:20
IntelPIC::m_slave
IntelIO m_slave
I/O instance for slave.
Definition: IntelPIC.h:130
BitOperations.h
IntelPIC::InterruptBase
static const uint InterruptBase
Base offset for interrupt vectors from the PIC.
Definition: IntelPIC.h:50
uint
unsigned int uint
Unsigned integer number.
Definition: Types.h:44
IntelPIC::CommandFlags
CommandFlags
Command Register Flags.
Definition: IntelPIC.h:70
IntelPIC::m_master
IntelIO m_master
I/O instance for master.
Definition: IntelPIC.h:127
IntelPIC::Mode8086
@ Mode8086
Definition: IntelPIC.h:75
IntelPIC::enable
virtual Result enable(uint irq)
Enable hardware interrupt (IRQ).
Definition: IntelPIC.cpp:55
IntelPIC::Init1
@ Init1
Definition: IntelPIC.h:72
IntelPIC::EndOfInterrupt
@ EndOfInterrupt
Definition: IntelPIC.h:76
IntelPIC::CascadeMode
@ CascadeMode
Definition: IntelPIC.h:73
IntelPIC::initialize
Result initialize()
Initialize the PIC.
Definition: IntelPIC.cpp:28
IntelPIC::Command
@ Command
Definition: IntelPIC.h:63
IntelPIC::SlaveBase
static const uint SlaveBase
Slave PIC I/O port base offset.
Definition: IntelPIC.h:56
IntController.h
IntelPIC::clear
virtual Result clear(uint irq)
Clear hardware interrupt (IRQ).
Definition: IntelPIC.cpp:81
IntelPIC::disable
virtual Result disable(uint irq)
Disable hardware interrupt (IRQ).
Definition: IntelPIC.cpp:68
IntelIO
Intel I/O functions.
Definition: IntelIO.h:38
IntelPIC::MasterBase
static const uint MasterBase
Master PIC I/O port base offset.
Definition: IntelPIC.h:53
IntelPIC::Data
@ Data
Definition: IntelPIC.h:64
IntelPIC::LevelTriggered
@ LevelTriggered
Definition: IntelPIC.h:74
IntController::Result
Result
Result codes.
Definition: IntController.h:42