Skip to content

Commit

Permalink
Merge pull request #2160 from OPAE/rrojo/cpeng-heartbeat
Browse files Browse the repository at this point in the history
cpeng: add heartbeat command
  • Loading branch information
fpgamatt committed Aug 6, 2021
2 parents 4b8ce45 + 57ec982 commit 784caf8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
55 changes: 55 additions & 0 deletions ofs/apps/cpeng/hps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,65 @@ class cpeng : public opae::afu_test::command
std::shared_ptr<spdlog::logger> log_;
};


class heartbeat : public opae::afu_test::command
{
public:
heartbeat()
{
}
virtual ~heartbeat(){}
virtual const char *name() const
{
return "heartbeat";
}

virtual const char *description() const
{
return "Check for HPS heartbeat";
}

virtual const char *afu_id() const
{
return cpeng_guid;
}

virtual int run(opae::afu_test::afu *afu, __attribute__((unused)) CLI::App *app)
{
log_ = spdlog::get(this->name());
ofs_cpeng cpeng;

// Initialize cpeng driver
ofs_cpeng_init(&cpeng, afu->handle()->c_type());
return check_heartbeat(&cpeng);
}


private:
int check_heartbeat(ofs_cpeng *cpeng)
{
uint64_t value = 0;
while (true) {
std::this_thread::sleep_for(msec(1000));
auto next = ofs_cpeng_hps2host_rsp(cpeng);
if (next <= value) {
log_->warn("could not detect heartbeat, value: 0x{:x}", next);
} else {
log_->info("heartbeat value: 0x{:x}", next);
}
value = next;
}
return 0;
}

std::shared_ptr<spdlog::logger> log_;
};

int main(int argc, char *argv[])
{
opae::afu_test::afu hps(cpeng_guid);
hps.register_command<cpeng>();
hps.register_command<heartbeat>();
hps.main(argc, argv);
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions ofs/umd/cpeng/ofs_cpeng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ api: |
return CSR_HPS2HOST_RSP_SHDW.KERNEL_VFY_SHDW
def hps_ssbl_verify() -> int:
return CSR_HPS2HOST_RSP_SHDW.SSBL_VFY_SHDW
def hps2host_rsp() -> uint64_t:
return CSR_HPS2HOST_RSP_SHDW.value
def ce_soft_reset():
CSR_CE_SFTRST.CE_SFTRST = 1
def image_complete():
Expand Down

0 comments on commit 784caf8

Please sign in to comment.