Browse Source

Add --help (#179)

pull/181/head
Luís Marques 7 years ago
committed by Andrew Waterman
parent
commit
92d3a34a9b
  1. 49
      pk/pk.c

49
pk/pk.c

@ -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

Loading…
Cancel
Save