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