FreeNOS
IntelPIT.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_PIT_H
19#define __LIBARCH_INTEL_PIT_H
20
21#include <Types.h>
22#include <BitOperations.h>
23#include <Timer.h>
24#include "IntelIO.h"
25
40class IntelPIT : public Timer
41{
42 private:
43
45 static const uint OscillatorFreq = 1193182;
46
48 static const uint InterruptNumber = 0;
49
54 {
55 Control = 0x43,
56 Channel0Data = 0x40
57 };
58
63 {
66 AccessLowHigh = (3 << 4),
67 SquareWave = (3 << 1),
68 RateGenerator = (2 << 1),
69 };
70
71 public:
72
76 IntelPIT();
77
90
103 virtual Result setFrequency(Size hertz);
104
111
112 private:
113
122
123 private:
124
127};
128
135#endif /* __LIBARCH_INTEL_PIT_H */
u32 flags
Definition IntelACPI.h:3
Intel I/O functions.
Definition IntelIO.h:39
Intel 8254 Programmable Interrupt Timer (PIT).
Definition IntelPIT.h:41
Result setControl(ControlFlags flags)
Set Control register.
Definition IntelPIT.cpp:76
ControlFlags
Control Register Flags.
Definition IntelPIT.h:63
@ SquareWave
Definition IntelPIT.h:67
@ RateGenerator
Definition IntelPIT.h:68
@ LatchedRead
Definition IntelPIT.h:65
@ AccessLowHigh
Definition IntelPIT.h:66
@ Channel0
Definition IntelPIT.h:64
Result waitTrigger()
Busy wait for one trigger period.
Definition IntelPIT.cpp:58
IntelIO m_io
I/O instance.
Definition IntelPIT.h:126
static const uint OscillatorFreq
Oscillator frequency in hertz used by the PIT.
Definition IntelPIT.h:45
uint getCounter()
Get current timer counter.
Definition IntelPIT.cpp:26
static const uint InterruptNumber
The IRQ vector for channel 0 is fixed to IRQ0.
Definition IntelPIT.h:48
IntelPIT()
Constructor.
Definition IntelPIT.cpp:20
Registers
Hardware registers.
Definition IntelPIT.h:54
@ Channel0Data
Definition IntelPIT.h:56
@ Control
Definition IntelPIT.h:55
virtual Result setFrequency(Size hertz)
Set interrupt frequency.
Definition IntelPIT.cpp:37
Represents a configurable timer device.
Definition Timer.h:36
Result
Result codes.
Definition Timer.h:53
unsigned int uint
Unsigned integer number.
Definition Types.h:44
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128