Go to the documentation of this file.
32 #include "debug/Intel8254Timer.hh"
56 if (
sel == ReadBackCommand)
57 panic(
"PITimer Read-Back Command is not implemented.\n");
95 const std::string &
name,
unsigned int _num)
96 : _name(
name), num(_num),
event(this), running(false),
97 initial_count(0), latched_count(0), period(0),
mode(0),
98 output_high(false), latch_on(false), read_byte(LSB),
99 write_byte(LSB), parent(
p)
111 latched_count = currentCount();
118 int clocks =
event.clocksLeft();
120 warn_once(
"Reading current count from inactive timer.\n");
136 return (uint8_t)latched_count;
141 return latched_count >> 8;
144 panic(
"Shouldn't be here");
147 uint16_t
count = currentCount();
151 return (uint8_t)
count;
158 panic(
"Shouldn't be here");
166 switch (write_byte) {
168 initial_count = (initial_count & 0xFF00) |
data;
170 if (
event.scheduled())
171 parent->deschedule(
event);
177 initial_count = (initial_count & 0x00FF) | (
data << 8);
181 period = initial_count - 1;
183 period = initial_count;
185 offset = period *
event.getInterval();
187 if (running && (period > 0))
199 panic(
"Only LSB/MSB read/write is implemented.\n");
207 panic(
"PIT mode %#x is not implemented: \n", mode_val);
216 panic(
"PITimer does not implement BCD counts.\n");
238 Tick event_tick_offset = 0;
239 if (
event.scheduled())
240 event_tick_offset =
event.when() -
curTick();
256 Tick event_tick_offset = 0;
257 assert(!
event.scheduled());
259 offset = event_tick_offset;
266 if ((period > 0) && (
offset > 0))
290 panic(
"Unimplemented PITimer mode.\n");
299 panic(
"Timer can't be set to go off instantly.\n");
310 return (when() -
curTick() + interval - 1) / interval;
316 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 process()
Event process.
const std::string & name() const
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 paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
void write(const uint8_t data)
Write a count byte.
virtual const char * description() const
Event description.
virtual void counterInterrupt(unsigned int num)
bool outputHigh()
Is the output high?
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
std::ostream CheckpointOut
Tick curTick()
The universal simulation clock.
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
#define panic(...)
This implements a cprintf based panic() function.
Generated on Tue Jun 22 2021 15:28:28 for gem5 by doxygen 1.8.17