36 #include "debug/Intel8254Timer.hh" 44 counter[0] = counter0;
45 counter[1] = counter1;
46 counter[2] = counter2;
52 counter[0] =
new Counter(
this, name +
".counter0", 0);
53 counter[1] =
new Counter(
this, name +
".counter1", 1);
54 counter[2] =
new Counter(
this, name +
".counter2", 2);
62 if (sel == ReadBackCommand)
63 panic(
"PITimer Read-Back Command is not implemented.\n");
65 if (data.rw == LatchCommand)
66 counter[
sel]->latchCount();
68 counter[
sel]->setRW(data.rw);
69 counter[
sel]->setMode(data.mode);
70 counter[
sel]->setBCD(data.bcd);
78 counter[0]->serialize(base +
".counter0", cp);
79 counter[1]->serialize(base +
".counter1", cp);
80 counter[2]->serialize(base +
".counter2", cp);
87 counter[0]->unserialize(base +
".counter0", cp);
88 counter[1]->unserialize(base +
".counter1", cp);
89 counter[2]->unserialize(base +
".counter2", cp);
95 counter[0]->startup();
96 counter[1]->startup();
97 counter[2]->startup();
101 const string &
name,
unsigned int _num)
102 : _name(name), num(_num),
event(this), running(false),
103 initial_count(0), latched_count(0), period(0),
mode(0),
104 output_high(false), latch_on(false), read_byte(LSB),
105 write_byte(LSB), parent(p)
124 int clocks =
event.clocksLeft();
126 warn_once(
"Reading current count from inactive timer.\n");
150 panic(
"Shouldn't be here");
157 return (uint8_t)
count;
164 panic(
"Shouldn't be here");
205 panic(
"Only LSB/MSB read/write is implemented.\n");
213 panic(
"PIT mode %#x is not implemented: \n", mode_val);
222 panic(
"PITimer does not implement BCD counts.\n");
243 Tick event_tick_offset = 0;
246 paramOut(cp, base +
".event_tick_offset", event_tick_offset);
261 Tick event_tick_offset = 0;
263 paramIn(cp, base +
".event_tick_offset", event_tick_offset);
264 offset = event_tick_offset;
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";
#define panic(...)
This implements a cprintf based panic() function.
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 writeControl(const CtrlReg data)
Write control word.
uint16_t initial_count
Initial count value.
const std::string & name()
Tick when() const
Get the time that the event is scheduled.
Programmable Interval Timer (Intel 8254)
Intel8254Timer * parent
Pointer to container.
Intel8254Timer(EventManager *em, const std::string &name, Counter *counter0, Counter *counter1, Counter *counter2)
Overload hash function for BasicBlockRange type.
double s
These variables equal the number of ticks in the unit of time they're named after in a double...
void latchCount()
Latch the current count (if one is not already latched)
void setRW(int rw_val)
Set the read/write mode.
void startup()
Start ticking.
void deschedule(Event &event)
virtual const char * description() const
Event description.
void startup()
Start ticking.
Tick curTick()
The current simulated tick.
bool running
True after startup is called.
bool scheduled() const
Determine if the current event is scheduled.
virtual void counterInterrupt(unsigned int num)
uint8_t mode
Current mode of operation.
bool output_high
Output goes high when the counter reaches zero.
uint64_t Tick
Tick count type.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
uint8_t read_byte
Determine which byte of a 16-bit count value to read/write.
virtual const std::string name() const
int64_t Counter
Statistics counter type.
void setMode(int mode_val)
Set operational mode.
bool latch_on
State of the count latch.
Counter(Intel8254Timer *p, const std::string &name, unsigned int num)
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
bool outputHigh()
Is the output high?
void process()
Event process.
std::ostream CheckpointOut
Counter * counter[3]
PIT has three seperate counters.
int currentCount()
Get the current count for this counter.
void schedule(Event &event, Tick when)
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
uint16_t latched_count
Latched count.
uint8_t read()
Read a count byte.
void write(const uint8_t data)
Write a count byte.
uint16_t period
Interrupt period.
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Tick offset
When to start ticking.