diff options
author | Luís Marques <luismarques@lowrisc.org> | 2019-10-23 19:04:57 +0100 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2019-10-23 11:04:57 -0700 |
commit | 92d3a34a9b8d70e08b52164a5ca24dfd93a76af1 (patch) | |
tree | bc701693be9266945cb23282360383e14f188909 /pk | |
parent | 43969b149eb3be5fe18daa7c69a02467e6f16d15 (diff) | |
download | pk-92d3a34a9b8d70e08b52164a5ca24dfd93a76af1.zip pk-92d3a34a9b8d70e08b52164a5ca24dfd93a76af1.tar.gz pk-92d3a34a9b8d70e08b52164a5ca24dfd93a76af1.tar.bz2 |
Add --help (#179)
Diffstat (limited to 'pk')
-rw-r--r-- | pk/pk.c | 49 |
1 files changed, 35 insertions, 14 deletions
@@ -11,22 +11,43 @@ elf_info current; long disabled_hart_mask; -static void handle_option(const char* s) +static void help() { - switch (s[1]) - { - case 's': // print cycle count upon termination - current.cycle0 = 1; - break; - - case 'p': // disable demand paging - demand_paging = 0; - break; - - default: - panic("unrecognized option: `%c'", s[1]); - break; + printk("Proxy kernel\n\n"); + printk("usage: pk [pk options] <user program> [program options]\n"); + printk("Options:\n"); + printk(" -h, --help Print this help message\n"); + printk(" -p Disable on-demand program paging\n"); + printk(" -s Print cycles upon termination\n"); + + shutdown(0); +} + +static void suggest_help() +{ + printk("Try 'pk --help' for more information.\n"); + shutdown(1); +} + +static void handle_option(const char* arg) +{ + if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { + help(); + return; } + + if (strcmp(arg, "-s") == 0) { // print cycle count upon termination + current.cycle0 = 1; + return; + } + + if (strcmp(arg, "-p") == 0) { // disable demand paging + demand_paging = 0; + return; + } + + panic("unrecognized option: `%s'", arg); + suggest_help(); } #define MAX_ARGS 256 |