Commit d6b65580 authored by Alessandro Rubini's avatar Alessandro Rubini

wrc_main: maintain an uptime counter, with 1s resolution, at 0x000000a0

This counter can be read through etherbone, to check that the software
is properly running. Feature asked by GSI.

The cost is 84 bytes in code.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent e505a960
......@@ -110,6 +110,11 @@ _reset_handler:
.short 0x89ab, 0xcdef
/* Pointer to structures, for the dumping tool */
.word softpll, fifo_log, ppi_static, 0
.org 0xa0
.global uptime_sec
uptime_sec:
.word 0
.extern _irq_entry
.org 0xc0
......
......@@ -168,6 +168,9 @@ void init_hw_after_reset(void)
int main(void)
{
extern uint32_t uptime_sec;
uint32_t j, lastj, fraction = 0;
check_reset();
wrc_ui_mode = UI_SHELL_MODE;
_endram = ENDRAM_MAGIC;
......@@ -181,10 +184,20 @@ int main(void)
//try to read and execute init script from EEPROM
shell_boot_script();
lastj = timer_get_tics();
for (;;) {
int l_status = wrc_check_link();
/* count uptime, in seconds, for remote polling */
j = timer_get_tics();
fraction += j -lastj;
lastj = j;
while (fraction > TICS_PER_SECOND) {
fraction -= TICS_PER_SECOND;
uptime_sec++;
}
switch (l_status) {
#ifdef CONFIG_ETHERBONE
case LINK_WENT_UP:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment