32#include "debug/Intel8254Timer.hh"
41 {
this,
name +
".counter0", 0},
42 {
this,
name +
".counter1", 1},
43 {
this,
name +
".counter2", 2}
52 if (
sel == ReadBackCommand) {
53 ReadBackCommandVal rb_val =
static_cast<uint8_t
>(
data);
56 "Latching the PIT status byte is not implemented.");
60 if (
bits((uint8_t)rb_val.select, counter.index()))
103 const std::string &
name,
unsigned int _num)
113Intel8254Timer::Counter::latchCount()
124Intel8254Timer::Counter::currentCount()
126 int clocks =
event.clocksLeft();
128 warn_once(
"Reading current count from inactive timer.\n");
138Intel8254Timer::Counter::read()
152 panic(
"Shouldn't be here");
159 return (uint8_t)
count;
166 panic(
"Shouldn't be here");
172Intel8254Timer::Counter::write(
const uint8_t
data)
178 if (
event.scheduled())
204Intel8254Timer::Counter::setRW(
int rw_val)
207 panic(
"Only LSB/MSB read/write is implemented.\n");
211Intel8254Timer::Counter::setMode(
int mode_val)
214 warn_once(
"SoftwareStrobe mode is used and it is not well tested\n");
217 panic(
"PIT mode %#x is not implemented: \n", mode_val);
223Intel8254Timer::Counter::setBCD(
int bcd_val)
226 panic(
"PITimer does not implement BCD counts.\n");
230Intel8254Timer::Counter::outputHigh()
236Intel8254Timer::Counter::serialize(
248 Tick event_tick_offset = 0;
249 if (
event.scheduled())
250 event_tick_offset =
event.when() -
curTick();
266 Tick event_tick_offset = 0;
267 assert(!
event.scheduled());
269 offset = event_tick_offset;
273Intel8254Timer::Counter::startup()
282Intel8254Timer::Counter::CounterEvent::CounterEvent(
Counter* c_ptr)
289Intel8254Timer::Counter::CounterEvent::process()
301 panic(
"Unimplemented PITimer mode.\n");
307Intel8254Timer::Counter::CounterEvent::setTo(
int clocks)
310 panic(
"Timer can't be set to go off instantly.\n");
317Intel8254Timer::Counter::CounterEvent::clocksLeft()
325Intel8254Timer::Counter::CounterEvent::description()
const
327 return "Intel 8254 Interval timer";
331Intel8254Timer::Counter::CounterEvent::getInterval()
Counter * counter
Pointer back to Counter.
friend class Counter
All counters are of 64-bit values.
uint16_t initial_count
Initial count value.
uint16_t period
Interrupt period.
uint16_t latched_count
Latched count.
uint8_t read_byte
Determine which byte of a 16-bit count value to read/write.
Intel8254Timer * parent
Pointer to container.
bool output_high
Output goes high when the counter reaches zero.
const std::string & name() const
bool latch_on
State of the count latch.
uint8_t mode
Current mode of operation.
bool running
True after startup is called.
Tick offset
When to start ticking.
int currentCount()
Get the current count for this counter.
const std::string & name() const
Intel8254Timer(EventManager *em, const std::string &name)
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
std::array< Counter, 3 > counters
PIT has three seperate counters.
void startup()
Start ticking.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
void writeControl(const CtrlReg data)
Write control word.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
bool scheduled() const
Determine if the current event is scheduled.
EventManager(EventManager &em)
Event manger manages events in the event queue.
Tick when() const
Get the time that the event is scheduled.
#define panic(...)
This implements a cprintf based panic() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
double s
These variables equal the number of ticks in the unit of time they're named after in a double.
Copyright (c) 2024 Arm Limited All rights reserved.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
uint64_t Tick
Tick count type.