Go to the documentation of this file.
32 #include "debug/Intel8254Timer.hh"
61 if (
sel == ReadBackCommand)
62 panic(
"PITimer Read-Back Command is not implemented.\n");
100 const std::string &
name,
unsigned int _num)
101 : _name(
name), num(_num),
event(this), running(false),
102 initial_count(0), latched_count(0), period(0),
mode(0),
103 output_high(false), latch_on(false), read_byte(LSB),
104 write_byte(LSB), parent(
p)
116 latched_count = currentCount();
123 int clocks =
event.clocksLeft();
125 warn_once(
"Reading current count from inactive timer.\n");
141 return (uint8_t)latched_count;
146 return latched_count >> 8;
149 panic(
"Shouldn't be here");
152 uint16_t
count = currentCount();
156 return (uint8_t)
count;
163 panic(
"Shouldn't be here");
171 switch (write_byte) {
173 initial_count = (initial_count & 0xFF00) |
data;
175 if (
event.scheduled())
176 parent->deschedule(
event);
182 initial_count = (initial_count & 0x00FF) | (
data << 8);
186 period = initial_count - 1;
188 period = initial_count;
190 offset = period *
event.getInterval();
192 if (running && (period > 0))
204 panic(
"Only LSB/MSB read/write is implemented.\n");
212 panic(
"PIT mode %#x is not implemented: \n", mode_val);
221 panic(
"PITimer does not implement BCD counts.\n");
243 Tick event_tick_offset = 0;
244 if (
event.scheduled())
245 event_tick_offset =
event.when() -
curTick();
246 paramOut(cp,
base +
".event_tick_offset", event_tick_offset);
252 paramIn(cp,
base +
".initial_count", initial_count);
253 paramIn(cp,
base +
".latched_count", latched_count);
261 Tick event_tick_offset = 0;
262 assert(!
event.scheduled());
263 paramIn(cp,
base +
".event_tick_offset", event_tick_offset);
264 offset = event_tick_offset;
271 if ((period > 0) && (
offset > 0))
295 panic(
"Unimplemented PITimer mode.\n");
304 panic(
"Timer can't be set to go off instantly.\n");
315 return (when() -
curTick() + interval - 1) / interval;
321 return "Intel 8254 Interval timer";
Tick curTick()
The universal simulation clock.
int64_t Counter
Statistics counter type.
void latchCount()
Latch the current count (if one is not already latched)
uint8_t mode
Current mode of operation.
Programmable Interval Timer (Intel 8254)
void process()
Event process.
int currentCount()
Get the current count for this counter.
void startup()
Start ticking.
void schedule(Event &event, Tick when)
Intel8254Timer * parent
Pointer to container.
virtual const char * description() const
Event description.
void setMode(int mode_val)
Set operational mode.
uint64_t Tick
Tick count type.
Intel8254Timer(EventManager *em, const std::string &name, Counter *counter0, Counter *counter1, Counter *counter2)
virtual void counterInterrupt(unsigned int num)
const std::string & name() const
const std::string & name()
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
uint8_t read()
Read a count byte.
Counter(Intel8254Timer *p, const std::string &name, unsigned int num)
bool output_high
Output goes high when the counter reaches zero.
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
void startup()
Start ticking.
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
void setRW(int rw_val)
Set the read/write mode.
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
std::ostream CheckpointOut
bool outputHigh()
Is the output high?
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
uint16_t period
Interrupt period.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Counter * counter[3]
PIT has three seperate counters.
void writeControl(const CtrlReg data)
Write control word.
void setBCD(int bcd_val)
Set count encoding.
void write(const uint8_t data)
Write a count byte.
Tick offset
When to start ticking.
#define panic(...)
This implements a cprintf based panic() function.
double s
These variables equal the number of ticks in the unit of time they're named after in a double.
Generated on Tue Sep 7 2021 14:53:46 for gem5 by doxygen 1.8.17