gem5  v21.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
intel_8254_timer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004, 2005
3  * The Regents of The University of Michigan
4  * All Rights Reserved
5  *
6  * This code is part of the M5 simulator.
7  *
8  * Permission is granted to use, copy, create derivative works and
9  * redistribute this software and such derivative works for any
10  * purpose, so long as the copyright notice above, this grant of
11  * permission, and the disclaimer below appear in all copies made; and
12  * so long as the name of The University of Michigan is not used in
13  * any advertising or publicity pertaining to the use or distribution
14  * of this software without specific, written prior authorization.
15  *
16  * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE
17  * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND
18  * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER
19  * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE
22  * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT,
23  * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM
24  * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
25  * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH
26  * DAMAGES.
27  */
28 
29 #ifndef __DEV_8254_HH__
30 #define __DEV_8254_HH__
31 
32 #include <iostream>
33 #include <string>
34 
35 #include "base/bitunion.hh"
36 #include "base/types.hh"
37 #include "base/trace.hh"
38 #include "debug/Intel8254Timer.hh"
39 #include "sim/eventq.hh"
40 #include "sim/serialize.hh"
41 
42 namespace gem5
43 {
44 
47 {
48  protected:
49  BitUnion8(CtrlReg)
50  Bitfield<7, 6> sel;
51  Bitfield<5, 4> rw;
52  Bitfield<3, 1> mode;
53  Bitfield<0> bcd;
54  EndBitUnion(CtrlReg)
55 
56  enum SelectVal
57  {
58  SelectCounter0,
59  SelectCounter1,
60  SelectCounter2,
61  ReadBackCommand
62  };
63 
65  {
70  };
71 
72  enum ModeVal
73  {
80  };
81 
83  class Counter
84  {
86  class CounterEvent : public Event
87  {
88  private:
92 
93  public:
95 
97  void process();
98 
100  virtual const char *description() const;
101 
102  friend class Counter;
103 
104  void setTo(int clocks);
105 
106  int clocksLeft();
107 
108  Tick getInterval();
109  };
110 
111  private:
112  std::string _name;
113  const std::string &name() const { return _name; }
114 
115  unsigned int num;
116 
118 
120  bool running;
121 
123  uint16_t initial_count;
124 
126  uint16_t latched_count;
127 
129  uint16_t period;
130 
133 
135  uint8_t mode;
136 
139 
141  bool latch_on;
142 
144  enum {LSB, MSB};
145 
148 
151 
152  public:
153  Counter(Intel8254Timer *p, const std::string &name, unsigned int num);
154 
156  void latchCount();
157 
159  int currentCount();
160 
162  void setRW(int rw_val);
163 
165  void setMode(int mode_val);
166 
168  void setBCD(int bcd_val);
169 
171  uint8_t read();
172 
174  void write(const uint8_t data);
175 
177  bool outputHigh();
178 
184  void serialize(const std::string &base, CheckpointOut &cp) const;
185 
192  void unserialize(const std::string &base, CheckpointIn &cp);
193 
195  void startup();
196  };
197 
198  protected:
199  std::string _name;
200  const std::string &name() const { return _name; }
201 
204 
205  virtual void
206  counterInterrupt(unsigned int num)
207  {
208  DPRINTF(Intel8254Timer, "Timer interrupt from counter %d.\n", num);
209  }
210 
211  public:
212 
213  virtual
215  {}
216 
217  Intel8254Timer(EventManager *em, const std::string &name,
218  Counter *counter0, Counter *counter1, Counter *counter2);
219 
220  Intel8254Timer(EventManager *em, const std::string &name);
221 
223  void writeControl(const CtrlReg data);
224 
225  uint8_t
226  readCounter(unsigned int num)
227  {
228  assert(num < 3);
229  return counter[num]->read();
230  }
231 
232  void
233  writeCounter(unsigned int num, const uint8_t data)
234  {
235  assert(num < 3);
236  counter[num]->write(data);
237  }
238 
239  bool
240  outputHigh(unsigned int num)
241  {
242  assert(num < 3);
243  return counter[num]->outputHigh();
244  }
245 
251  void serialize(const std::string &base, CheckpointOut &cp) const;
252 
259  void unserialize(const std::string &base, CheckpointIn &cp);
260 
262  void startup();
263 };
264 
265 } // namespace gem5
266 
267 #endif // __DEV_8254_HH__
gem5::Intel8254Timer::SoftwareStrobe
@ SoftwareStrobe
Definition: intel_8254_timer.hh:78
data
const char data[]
Definition: circlebuf.test.cc:48
serialize.hh
gem5::Intel8254Timer::Counter::latchCount
void latchCount()
Latch the current count (if one is not already latched)
Definition: intel_8254_timer.cc:110
gem5::Intel8254Timer::mode
Bitfield< 3, 1 > mode
Definition: intel_8254_timer.hh:52
gem5::Intel8254Timer::~Intel8254Timer
virtual ~Intel8254Timer()
Definition: intel_8254_timer.hh:214
gem5::Intel8254Timer::Counter::mode
uint8_t mode
Current mode of operation.
Definition: intel_8254_timer.hh:135
gem5::Intel8254Timer
Programmable Interval Timer (Intel 8254)
Definition: intel_8254_timer.hh:46
gem5::Intel8254Timer::RateGen
@ RateGen
Definition: intel_8254_timer.hh:76
gem5::Intel8254Timer::Counter::CounterEvent::interval
Tick interval
Definition: intel_8254_timer.hh:91
gem5::Intel8254Timer::_name
std::string _name
Definition: intel_8254_timer.hh:199
gem5::Intel8254Timer::Counter::CounterEvent::process
void process()
Event process.
Definition: intel_8254_timer.cc:284
gem5::Intel8254Timer::Counter::_name
std::string _name
Definition: intel_8254_timer.hh:112
gem5::Intel8254Timer::Counter::currentCount
int currentCount()
Get the current count for this counter.
Definition: intel_8254_timer.cc:121
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::Intel8254Timer::bcd
Bitfield< 0 > bcd
Definition: intel_8254_timer.hh:53
gem5::Intel8254Timer::startup
void startup()
Start ticking.
Definition: intel_8254_timer.cc:92
gem5::Intel8254Timer::writeCounter
void writeCounter(unsigned int num, const uint8_t data)
Definition: intel_8254_timer.hh:233
gem5::Intel8254Timer::LatchCommand
@ LatchCommand
Definition: intel_8254_timer.hh:66
gem5::Intel8254Timer::EndBitUnion
EndBitUnion(CtrlReg) enum SelectVal
Definition: intel_8254_timer.hh:54
gem5::Intel8254Timer::Counter
Counter element for PIT.
Definition: intel_8254_timer.hh:83
gem5::Intel8254Timer::Counter::CounterEvent::counter
Counter * counter
Pointer back to Counter.
Definition: intel_8254_timer.hh:90
gem5::X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
gem5::Intel8254Timer::Counter::CounterEvent::CounterEvent
CounterEvent(Counter *)
Definition: intel_8254_timer.cc:277
gem5::Intel8254Timer::Counter::name
const std::string & name() const
Definition: intel_8254_timer.hh:113
gem5::Intel8254Timer::BitUnion8
BitUnion8(CtrlReg) Bitfield< 7
gem5::Intel8254Timer::Counter::initial_count
uint16_t initial_count
Initial count value.
Definition: intel_8254_timer.hh:123
gem5::Intel8254Timer::Counter::parent
Intel8254Timer * parent
Pointer to container.
Definition: intel_8254_timer.hh:150
gem5::X86ISA::em
Bitfield< 2 > em
Definition: misc.hh:608
gem5::EventManager
Definition: eventq.hh:987
gem5::Intel8254Timer::OneShot
@ OneShot
Definition: intel_8254_timer.hh:75
gem5::Intel8254Timer::Counter::CounterEvent::description
virtual const char * description() const
Event description.
Definition: intel_8254_timer.cc:319
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::Event
Definition: eventq.hh:251
gem5::Intel8254Timer::TwoPhase
@ TwoPhase
Definition: intel_8254_timer.hh:69
gem5::Intel8254Timer::Counter::setMode
void setMode(int mode_val)
Set operational mode.
Definition: intel_8254_timer.cc:208
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Intel8254Timer::MsbOnly
@ MsbOnly
Definition: intel_8254_timer.hh:68
bitunion.hh
gem5::Intel8254Timer::Counter::num
unsigned int num
Definition: intel_8254_timer.hh:115
gem5::Intel8254Timer::Intel8254Timer
Intel8254Timer(EventManager *em, const std::string &name, Counter *counter0, Counter *counter1, Counter *counter2)
Definition: intel_8254_timer.cc:39
gem5::Intel8254Timer::counterInterrupt
virtual void counterInterrupt(unsigned int num)
Definition: intel_8254_timer.hh:206
gem5::Intel8254Timer::readCounter
uint8_t readCounter(unsigned int num)
Definition: intel_8254_timer.hh:226
gem5::Intel8254Timer::outputHigh
bool outputHigh(unsigned int num)
Definition: intel_8254_timer.hh:240
gem5::Intel8254Timer::name
const std::string & name() const
Definition: intel_8254_timer.hh:200
gem5::Intel8254Timer::serialize
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Definition: intel_8254_timer.cc:74
gem5::Intel8254Timer::Counter::latched_count
uint16_t latched_count
Latched count.
Definition: intel_8254_timer.hh:126
gem5::Intel8254Timer::Counter::CounterEvent::clocksLeft
int clocksLeft()
Definition: intel_8254_timer.cc:311
gem5::Intel8254Timer::Counter::CounterEvent
Event for counter interrupt.
Definition: intel_8254_timer.hh:86
gem5::Intel8254Timer::ModeVal
ModeVal
Definition: intel_8254_timer.hh:72
gem5::Intel8254Timer::Counter::CounterEvent::setTo
void setTo(int clocks)
Definition: intel_8254_timer.cc:301
gem5::Intel8254Timer::Counter::read
uint8_t read()
Read a count byte.
Definition: intel_8254_timer.cc:135
gem5::Intel8254Timer::Counter::write_byte
uint8_t write_byte
Definition: intel_8254_timer.hh:147
gem5::Intel8254Timer::Counter::event
CounterEvent event
Definition: intel_8254_timer.hh:117
gem5::Intel8254Timer::Counter::Counter
Counter(Intel8254Timer *p, const std::string &name, unsigned int num)
Definition: intel_8254_timer.cc:99
gem5::Intel8254Timer::Counter::output_high
bool output_high
Output goes high when the counter reaches zero.
Definition: intel_8254_timer.hh:138
gem5::Intel8254Timer::HardwareStrobe
@ HardwareStrobe
Definition: intel_8254_timer.hh:79
gem5::Intel8254Timer::Counter::CounterEvent::getInterval
Tick getInterval()
Definition: intel_8254_timer.cc:325
gem5::Intel8254Timer::Counter::startup
void startup()
Start ticking.
Definition: intel_8254_timer.cc:268
types.hh
gem5::Intel8254Timer::InitTc
@ InitTc
Definition: intel_8254_timer.hh:74
gem5::Intel8254Timer::rw
Bitfield< 5, 4 > rw
Definition: intel_8254_timer.hh:51
gem5::Intel8254Timer::SquareWave
@ SquareWave
Definition: intel_8254_timer.hh:77
gem5::Intel8254Timer::Counter::unserialize
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Definition: intel_8254_timer.cc:250
gem5::statistics::Counter
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
gem5::Intel8254Timer::ReadWriteVal
ReadWriteVal
Definition: intel_8254_timer.hh:64
gem5::Intel8254Timer::Counter::LSB
@ LSB
Definition: intel_8254_timer.hh:144
gem5::Intel8254Timer::Counter::setRW
void setRW(int rw_val)
Set the read/write mode.
Definition: intel_8254_timer.cc:201
gem5::Intel8254Timer::Counter::serialize
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Definition: intel_8254_timer.cc:231
gem5::Intel8254Timer::Counter::latch_on
bool latch_on
State of the count latch.
Definition: intel_8254_timer.hh:141
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::Intel8254Timer::Counter::read_byte
uint8_t read_byte
Determine which byte of a 16-bit count value to read/write.
Definition: intel_8254_timer.hh:147
trace.hh
gem5::Intel8254Timer::Counter::outputHigh
bool outputHigh()
Is the output high?
Definition: intel_8254_timer.cc:225
gem5::Intel8254Timer::sel
sel
Definition: intel_8254_timer.hh:50
gem5::Intel8254Timer::unserialize
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Definition: intel_8254_timer.cc:83
gem5::Intel8254Timer::Counter::period
uint16_t period
Interrupt period.
Definition: intel_8254_timer.hh:129
gem5::Intel8254Timer::Counter::MSB
@ MSB
Definition: intel_8254_timer.hh:144
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::Intel8254Timer::counter
Counter * counter[3]
PIT has three seperate counters.
Definition: intel_8254_timer.hh:203
gem5::Intel8254Timer::writeControl
void writeControl(const CtrlReg data)
Write control word.
Definition: intel_8254_timer.cc:57
gem5::Intel8254Timer::LsbOnly
@ LsbOnly
Definition: intel_8254_timer.hh:67
gem5::Intel8254Timer::Counter::setBCD
void setBCD(int bcd_val)
Set count encoding.
Definition: intel_8254_timer.cc:218
gem5::Intel8254Timer::Counter::write
void write(const uint8_t data)
Write a count byte.
Definition: intel_8254_timer.cc:169
gem5::Intel8254Timer::Counter::offset
Tick offset
When to start ticking.
Definition: intel_8254_timer.hh:132
gem5::Intel8254Timer::Counter::running
bool running
True after startup is called.
Definition: intel_8254_timer.hh:120
eventq.hh

Generated on Tue Sep 7 2021 14:53:46 for gem5 by doxygen 1.8.17