FreeNOS
IntelAPIC.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_APIC_H
19#define __LIBARCH_INTEL_APIC_H
20
21#include <Types.h>
22#include <BitOperations.h>
23#include <IntController.h>
24#include <Timer.h>
25#include "IntelIO.h"
26
28class MemoryContext;
29class IntelPIT;
30
45class IntelAPIC : public IntController, public Timer
46{
47 using Timer::start;
48
49 public:
50
52 static const uint IOBase = 0xfee00000;
53
55 static const uint TimerVector = 48;
56
57 private:
58
63 {
64 Identifier = 0x20,
65 Version = 0x30,
71 InService = 0x100,
72 TriggerMode = 0x180,
73 IntRequest = 0x200,
74 ErrorStatus = 0x280,
75 IntCommand1 = 0x300,
76 IntCommand2 = 0x310,
77 Timer = 0x320,
79 PerfCounters = 0x340,
80 LocalInt0 = 0x350,
81 LocalInt1 = 0x360,
82 Error = 0x370,
83 InitialCount = 0x380,
84 CurrentCount = 0x390,
85 DivideConfig = 0x3e0
86 };
87
92 {
93 APICEnable = 0x100
94 };
95
100 {
101 Divide16 = 3
102 };
103
108 {
109 TimerMasked = (1 << 16),
110 PeriodicMode = (1 << 17)
111 };
112
113 public:
114
118 IntelAPIC();
119
125 IntelIO & getIO();
126
132 uint getCounter() const;
133
139 virtual Timer::Result initialize();
140
147 virtual Timer::Result wait(u32 microseconds) const;
148
156
164 Timer::Result start(uint initialCounter, uint hertz);
165
175 virtual Timer::Result start();
176
182 virtual Timer::Result stop();
183
190 virtual IntController::Result enable(uint irq);
191
199
210 virtual IntController::Result clear(uint irq);
211
220
230
231 private:
232
235
238};
239
246#endif /* __LIBARCH_INTEL_APIC_H */
u8 coreId
Definition IntelACPI.h:1
Interrupt controller interface.
Result
Result codes.
Intel Advanced Programmable Interrupt Controller (APIC)
Definition IntelAPIC.h:46
virtual IntController::Result enable(uint irq)
Enable hardware interrupt (IRQ).
virtual Timer::Result initialize()
Initialize the APIC.
virtual IntController::Result disable(uint irq)
Disable hardware interrupt (IRQ).
IntelAPIC()
Constructor.
Definition IntelAPIC.cpp:36
virtual Timer::Result wait(u32 microseconds) const
Busy wait a number of microseconds.
Definition IntelAPIC.cpp:93
DivideConfigFlags
Timer Divide Configuration Register flags.
Definition IntelAPIC.h:100
virtual Timer::Result stop()
Stop the APIC timer.
uint m_initialCounter
Saved initial counter value for APIC timer.
Definition IntelAPIC.h:237
virtual Timer::Result start()
(Re)start the APIC timer.
IntController::Result sendStartupIPI(uint cpuId, Address addr)
Send startup Intercore-Processor-Interrupt.
IntController::Result sendIPI(uint coreId, uint vector)
Send Intercore-Processor-Interrupt.
SpuriousIntVecFlags
Spurious Interrupt Vector Register flags.
Definition IntelAPIC.h:92
IntelIO & getIO()
Get I/O object.
Definition IntelAPIC.cpp:45
static const uint IOBase
APIC memory mapped I/O register base offset (physical address).
Definition IntelAPIC.h:52
static const uint TimerVector
APIC timer interrupt vector is fixed at 48.
Definition IntelAPIC.h:55
TimerFlags
Timer Register flags.
Definition IntelAPIC.h:108
virtual IntController::Result clear(uint irq)
Clear hardware interrupt (IRQ).
uint getCounter() const
Get timer initial counter.
Definition IntelAPIC.cpp:50
IntelIO m_io
I/O object.
Definition IntelAPIC.h:234
Registers
Hardware registers.
Definition IntelAPIC.h:63
@ DivideConfig
Definition IntelAPIC.h:85
@ InitialCount
Definition IntelAPIC.h:83
@ ErrorStatus
Definition IntelAPIC.h:74
@ PerfCounters
Definition IntelAPIC.h:79
@ IntCommand1
Definition IntelAPIC.h:75
@ IntCommand2
Definition IntelAPIC.h:76
@ EndOfInterrupt
Definition IntelAPIC.h:69
@ TaskPriority
Definition IntelAPIC.h:66
@ TriggerMode
Definition IntelAPIC.h:72
@ ArbitrationPriority
Definition IntelAPIC.h:67
@ CurrentCount
Definition IntelAPIC.h:84
@ ThermalSensor
Definition IntelAPIC.h:78
@ SpuriousIntVec
Definition IntelAPIC.h:70
@ ProcessorPriority
Definition IntelAPIC.h:68
Intel I/O functions.
Definition IntelIO.h:39
Intel 8254 Programmable Interrupt Timer (PIT).
Definition IntelPIT.h:41
Virtual memory abstract interface.
Represents a configurable timer device.
Definition Timer.h:36
virtual Result start()
Start the timer.
Definition Timer.cpp:64
Result
Result codes.
Definition Timer.h:53
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned long Address
A memory address.
Definition Types.h:131
slong Error
Error code defined in Error.h.
Definition Types.h:159
unsigned int uint
Unsigned integer number.
Definition Types.h:44