aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/stats.c')
-rw-r--r--firmware/stats.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/firmware/stats.c b/firmware/stats.c
index c7b1b8e..21f97d5 100644
--- a/firmware/stats.c
+++ b/firmware/stats.c
@@ -1,14 +1,6 @@
-#include <stdint.h>
-#include <stdbool.h>
-#define OUTPORT 0x10000000
+#include "firmware.h"
-static void print_str(const char *p)
-{
- while (*p != 0)
- *((volatile uint32_t*)OUTPORT) = *(p++);
-}
-
-static void print_dec(int val, int digits, bool zero_pad)
+static void stats_print_dec(int val, int digits, bool zero_pad)
{
char buffer[32];
char *p = buffer;
@@ -22,7 +14,7 @@ static void print_dec(int val, int digits, bool zero_pad)
}
while (p != buffer) {
if (p[-1] == ' ' && p[-2] == ' ') p[-1] = '.';
- *((volatile uint32_t*)OUTPORT) = *(--p);
+ print_chr(*(--p));
}
}
@@ -31,13 +23,13 @@ void stats()
int num_cycles, num_instr;
asm("rdcycle %0; rdinstret %1;" : "=r"(num_cycles), "=r"(num_instr));
print_str("Cycle counter ........");
- print_dec(num_cycles, 8, false);
+ stats_print_dec(num_cycles, 8, false);
print_str("\nInstruction counter ..");
- print_dec(num_instr, 8, false);
+ stats_print_dec(num_instr, 8, false);
print_str("\nCPI: ");
- print_dec((num_cycles / num_instr), 0, false);
+ stats_print_dec((num_cycles / num_instr), 0, false);
print_str(".");
- print_dec(((100 * num_cycles) / num_instr) % 100, 2, true);
+ stats_print_dec(((100 * num_cycles) / num_instr) % 100, 2, true);
print_str("\n");
}