Line 10... |
Line 10... |
|
|
namespace debugger {
|
namespace debugger {
|
|
|
GPTimers::GPTimers(const char *name) : IService(name) {
|
GPTimers::GPTimers(const char *name) : IService(name) {
|
registerInterface(static_cast<IMemoryOperation *>(this));
|
registerInterface(static_cast<IMemoryOperation *>(this));
|
registerAttribute("BaseAddress", &baseAddress_);
|
|
registerAttribute("Length", &length_);
|
|
registerAttribute("IrqLine", &irqLine_);
|
|
registerAttribute("IrqControl", &irqctrl_);
|
registerAttribute("IrqControl", &irqctrl_);
|
registerAttribute("ClkSource", &clksrc_);
|
registerAttribute("ClkSource", &clksrc_);
|
|
|
baseAddress_.make_uint64(0);
|
|
length_.make_uint64(0);
|
|
irqLine_.make_uint64(0);
|
|
irqctrl_.make_string("");
|
|
clksrc_.make_string("");
|
|
|
|
|
|
memset(®s_, 0, sizeof(regs_));
|
memset(®s_, 0, sizeof(regs_));
|
|
dbg_irq_cnt_ = 0;
|
}
|
}
|
|
|
GPTimers::~GPTimers() {
|
GPTimers::~GPTimers() {
|
}
|
}
|
|
|
Line 37... |
Line 28... |
if (!iclk_) {
|
if (!iclk_) {
|
RISCV_error("Can't find IClock interface %s", clksrc_.to_string());
|
RISCV_error("Can't find IClock interface %s", clksrc_.to_string());
|
}
|
}
|
|
|
iwire_ = static_cast<IWire *>(
|
iwire_ = static_cast<IWire *>(
|
RISCV_get_service_iface(irqctrl_.to_string(), IFACE_WIRE));
|
RISCV_get_service_port_iface(irqctrl_[0u].to_string(),
|
|
irqctrl_[1].to_string(),
|
|
IFACE_WIRE));
|
if (!iwire_) {
|
if (!iwire_) {
|
RISCV_error("Can't find IWire interface %s", irqctrl_.to_string());
|
RISCV_error("Can't find IWire interface %s", irqctrl_[0u].to_string());
|
}
|
}
|
}
|
}
|
|
|
void GPTimers::b_transport(Axi4TransactionType *trans) {
|
ETransStatus GPTimers::b_transport(Axi4TransactionType *trans) {
|
uint64_t mask = (length_.to_uint64() - 1);
|
uint64_t mask = (length_.to_uint64() - 1);
|
uint64_t off = ((trans->addr - getBaseAddress()) & mask) / 4;
|
uint64_t off = ((trans->addr - getBaseAddress()) & mask) / 4;
|
trans->response = MemResp_Valid;
|
trans->response = MemResp_Valid;
|
if (trans->action == MemAction_Write) {
|
if (trans->action == MemAction_Write) {
|
for (uint64_t i = 0; i < trans->xsize/4; i++) {
|
for (uint64_t i = 0; i < trans->xsize/4; i++) {
|
Line 119... |
Line 112... |
default:
|
default:
|
trans->rpayload.b32[i] = ~0;
|
trans->rpayload.b32[i] = ~0;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
return TRANS_OK;
|
}
|
}
|
|
|
void GPTimers::stepCallback(uint64_t t) {
|
void GPTimers::stepCallback(uint64_t t) {
|
iwire_->raiseLine(irqLine_.to_int());
|
iwire_->raiseLine();
|
|
RISCV_info("Raise interrupt cnt=%d", dbg_irq_cnt_++);
|
if (regs_.timer[0].control & TIMER_CONTROL_ENA) {
|
if (regs_.timer[0].control & TIMER_CONTROL_ENA) {
|
iclk_->registerStepCallback(static_cast<IClockListener *>(this),
|
iclk_->registerStepCallback(static_cast<IClockListener *>(this),
|
t + regs_.timer[0].init_value);
|
t + regs_.timer[0].init_value);
|
}
|
}
|
}
|
}
|