Go to the documentation of this file.
32 #include "debug/Intel8254Timer.hh"
40 counter[0] = counter0;
41 counter[1] = counter1;
42 counter[2] = counter2;
48 counter[0] =
new Counter(
this,
name +
".counter0", 0);
49 counter[1] =
new Counter(
this,
name +
".counter1", 1);
50 counter[2] =
new Counter(
this,
name +
".counter2", 2);
58 if (
sel == ReadBackCommand)
59 panic(
"PITimer Read-Back Command is not implemented.\n");
97 const string &
name,
unsigned int _num)
98 : _name(
name), num(_num),
event(this), running(false),
99 initial_count(0), latched_count(0), period(0),
mode(0),
100 output_high(false), latch_on(false), read_byte(LSB),
101 write_byte(LSB), parent(
p)
113 latched_count = currentCount();
120 int clocks =
event.clocksLeft();
122 warn_once(
"Reading current count from inactive timer.\n");
138 return (uint8_t)latched_count;
143 return latched_count >> 8;
146 panic(
"Shouldn't be here");
149 uint16_t
count = currentCount();
153 return (uint8_t)
count;
160 panic(
"Shouldn't be here");
168 switch (write_byte) {
170 initial_count = (initial_count & 0xFF00) |
data;
172 if (
event.scheduled())
173 parent->deschedule(
event);
179 initial_count = (initial_count & 0x00FF) | (
data << 8);
183 period = initial_count - 1;
185 period = initial_count;
187 offset = period *
event.getInterval();
189 if (running && (period > 0))
201 panic(
"Only LSB/MSB read/write is implemented.\n");
209 panic(
"PIT mode %#x is not implemented: \n", mode_val);
218 panic(
"PITimer does not implement BCD counts.\n");
239 Tick event_tick_offset = 0;
240 if (
event.scheduled())
241 event_tick_offset =
event.when() -
curTick();
257 Tick event_tick_offset = 0;
258 assert(!
event.scheduled());
260 offset = event_tick_offset;
267 if ((period > 0) && (
offset > 0))
291 panic(
"Unimplemented PITimer mode.\n");
300 panic(
"Timer can't be set to go off instantly.\n");
311 return (when() -
curTick() + interval - 1) / interval;
317 return "Intel 8254 Interval timer";
Counter * counter[3]
PIT has three seperate counters.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
uint8_t read()
Read a count byte.
double s
These variables equal the number of ticks in the unit of time they're named after in a double.
int currentCount()
Get the current count for this counter.
Intel8254Timer(EventManager *em, const std::string &name, Counter *counter0, Counter *counter1, Counter *counter2)
uint16_t period
Interrupt period.
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
void setBCD(int bcd_val)
Set count encoding.
void startup()
Start ticking.
void latchCount()
Latch the current count (if one is not already latched)
void setRW(int rw_val)
Set the read/write mode.
uint64_t Tick
Tick count type.
void writeControl(const CtrlReg data)
Write control word.
Intel8254Timer * parent
Pointer to container.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
void process()
Event process.
void setMode(int mode_val)
Set operational mode.
int64_t Counter
Statistics counter type.
bool output_high
Output goes high when the counter reaches zero.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
void schedule(Event &event, Tick when)
void startup()
Start ticking.
Tick offset
When to start ticking.
Programmable Interval Timer (Intel 8254)
uint8_t mode
Current mode of operation.
Counter(Intel8254Timer *p, const std::string &name, unsigned int num)
const std::string & name()
void write(const uint8_t data)
Write a count byte.
virtual const std::string name() const
virtual const char * description() const
Event description.
virtual void counterInterrupt(unsigned int num)
Overload hash function for BasicBlockRange type.
bool outputHigh()
Is the output high?
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
std::ostream CheckpointOut
#define panic(...)
This implements a cprintf based panic() function.
Tick curTick()
The current simulated tick.
Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17