Skip to content

Commit

Permalink
Adding uptime to ci.
Browse files Browse the repository at this point in the history
 * Moved uptime from pattern into own service.
 * Made pattern use uptime service.
 * Add uptime to ci.
  • Loading branch information
mithro committed Jan 14, 2017
1 parent f85a83e commit 3892837
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 9 deletions.
1 change: 1 addition & 0 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ OBJECTS=\
tofe_eeprom.o \
version.o \
version_data.o \
uptime.o \


CFLAGS += \
Expand Down
2 changes: 2 additions & 0 deletions firmware/ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "telnet.h"
#include "tofe_eeprom.h"
#include "version.h"
#include "uptime.h"

#include "ci.h"

Expand Down Expand Up @@ -920,6 +921,7 @@ void ci_service(void)
wputs("");
}
else if(strcmp(token, "reboot") == 0) reboot();
else if(strcmp(token, "uptime") == 0 || strcmp(token, "u") == 0) uptime_print();
#ifdef CSR_ETHPHY_MDIO_W_ADDR
else if(strcmp(token, "mdio_status") == 0)
mdio_status();
Expand Down
2 changes: 2 additions & 0 deletions firmware/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "processor.h"
#include "telnet.h"
#include "tofe_eeprom.h"
#include "uptime.h"
#include "version.h"

#define HDD_LED 0x01
Expand Down Expand Up @@ -124,6 +125,7 @@ int main(void)

ci_prompt();
while(1) {
uptime_service();
processor_service();
ci_service();

Expand Down
10 changes: 1 addition & 9 deletions firmware/pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,8 @@ void pattern_fill_framebuffer(int h_active, int m_active)
void pattern_service(void)
{
static int last_event;
static int seconds;
char buffer[16];

if(elapsed(&last_event, SYSTEM_CLOCK_FREQUENCY)) {
sprintf(buffer, "uptime %02d:%02d:%02d",
(seconds/3600)%24,
(seconds/60)%60,
seconds%60);
pattern_draw_text(1, 6, buffer);
seconds++;
pattern_draw_text(1, 6, uptime_str());
}
flush_l2_cache();
}
38 changes: 38 additions & 0 deletions firmware/uptime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdio.h>
#include <string.h>
#include <time.h>

#include <generated/csr.h>

#include "uptime.h"

static int uptime_seconds = 0;
void uptime_service(void)
{
static int last_event;

if(elapsed(&last_event, SYSTEM_CLOCK_FREQUENCY)) {
uptime_seconds++;
}
}

int uptime(void)
{
return uptime_seconds;
}

void uptime_print(void)
{
printf(uptime_str());
printf("\n\r");
}

const char* uptime_str(void)
{
static char buffer[16];
sprintf(buffer, "uptime %02d:%02d:%02d",
(uptime_seconds/3600)%24,
(uptime_seconds/60)%60,
uptime_seconds%60);
return buffer;
}
10 changes: 10 additions & 0 deletions firmware/uptime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __UPTIME_H
#define __UPTIME_H

void uptime_service(void);
int uptime(void);

void uptime_print(void);
const char* uptime_str(void);

#endif /* __CONFIG_H */

0 comments on commit 3892837

Please sign in to comment.