diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-10-05 17:18:56 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-10-05 17:18:56 -0600 |
| commit | cf32fe6cf81040e04036f0fcf72f814ab891bb8a (patch) | |
| tree | a1e1c50ab905ce6b7b85dcffc98c09995d72e693 /demo/main.c | |
| parent | d406720cecd7328f595255e65b6fd6b6814cefe4 (diff) | |
demo: implement perf command
Diffstat (limited to 'demo/main.c')
| -rw-r--r-- | demo/main.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/demo/main.c b/demo/main.c index 988ef55..89347ad 100644 --- a/demo/main.c +++ b/demo/main.c @@ -6,6 +6,11 @@ struct cpu *__cpus[] = { &cpu0, &cpu1, &cpu2, &cpu3 }; static volatile unsigned boot_done; +static void unknown_command(const char *cmd) +{ + print("unknown command '%s'", cmd); +} + static void cmd_run(char **tokens) { unsigned mask; @@ -55,6 +60,27 @@ static void cmd_cache(char **tokens) cache_debug(cpu, ptr); } +static void cmd_perf(char **tokens) +{ + unsigned cpu; + const char *cmd; + + if (parse_cpu(tokens, &cpu) < 0) + return; + else if (!(cmd = strtok_input(tokens))) { + unexpected_eof(); + return; + } else if (expect_end(tokens) < 0) + return; + + if (!strcmp(cmd, "clear")) + perf_clear(cpu); + else if (!strcmp(cmd, "show")) + perf_show(cpu); + else + unknown_command(cmd); +} + static void bsp_main(void) { boot_done = 0; @@ -83,8 +109,10 @@ static void bsp_main(void) cmd_write(&tokens); else if (!strcmp(cmd, "cache")) cmd_cache(&tokens); + else if (!strcmp(cmd, "perf")) + cmd_perf(&tokens); else - print("unknown command '%s'", cmd); + unknown_command(cmd); } } |
