diff options
Diffstat (limited to 'kern/syscnt.c')
-rw-r--r-- | kern/syscnt.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/kern/syscnt.c b/kern/syscnt.c index 5b479f36..7cceabac 100644 --- a/kern/syscnt.c +++ b/kern/syscnt.c @@ -22,6 +22,7 @@ #include <kern/init.h> #include <kern/list.h> #include <kern/mutex.h> +#include <kern/shell.h> #include <kern/spinlock.h> #include <kern/syscnt.h> @@ -31,13 +32,47 @@ static struct list syscnt_list; static struct mutex syscnt_lock; -void __init +#ifdef X15_SHELL + +static void +syscnt_shell_info(int argc, char **argv) +{ + char *prefix; + + prefix = (argc >= 2) ? argv[1] : NULL; + syscnt_info(prefix); +} + +static struct shell_cmd syscnt_shell_cmds[] = { + SHELL_CMD_INITIALIZER("syscnt_info", syscnt_shell_info, + "syscnt_info [<prefix>]", + "display information about system counters"), +}; + +static int __init +syscnt_setup_shell(void) +{ + SHELL_REGISTER_CMDS(syscnt_shell_cmds); + return 0; +} + +INIT_OP_DEFINE(syscnt_setup_shell, + INIT_OP_DEP(shell_setup, true), + INIT_OP_DEP(syscnt_setup, true)); + +#endif /* X15_SHELL */ + +static int __init syscnt_setup(void) { list_init(&syscnt_list); mutex_init(&syscnt_lock); + return 0; } +INIT_OP_DEFINE(syscnt_setup, + INIT_OP_DEP(mutex_setup, true)); + void __init syscnt_register(struct syscnt *syscnt, const char *name) { @@ -61,8 +96,6 @@ syscnt_info(const char *prefix) prefix_length = (prefix == NULL) ? 0 : strlen(prefix); - printf("syscnt: name value\n"); - mutex_lock(&syscnt_lock); list_for_each_entry(&syscnt_list, syscnt, node) { @@ -77,7 +110,7 @@ syscnt_info(const char *prefix) value = syscnt_read(syscnt); - printf("syscnt: %-30s %17llu\n", syscnt->name, + printf("syscnt: %40s %20llu\n", syscnt->name, (unsigned long long)value); } |