Rev 4011 | Rev 4132 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4011 | Rev 4089 | ||
---|---|---|---|
Line 293... | Line 293... | ||
293 | strncpy(name, output, MAX_SYMBOL_NAME); |
293 | strncpy(name, output, MAX_SYMBOL_NAME); |
294 | return found; |
294 | return found; |
295 | 295 | ||
296 | } |
296 | } |
297 | 297 | ||
298 | static char *clever_readline(const char *prompt, chardev_t *input) |
298 | static char *clever_readline(const char *prompt, indev_t *input) |
299 | { |
299 | { |
300 | static int histposition = 0; |
300 | static int histposition = 0; |
301 | 301 | ||
302 | static char tmp[MAX_CMDLINE + 1]; |
302 | static char tmp[MAX_CMDLINE + 1]; |
303 | int curlen = 0, position = 0; |
303 | int curlen = 0, position = 0; |
Line 454... | Line 454... | ||
454 | } |
454 | } |
455 | current[curlen] = '\0'; |
455 | current[curlen] = '\0'; |
456 | return current; |
456 | return current; |
457 | } |
457 | } |
458 | 458 | ||
- | 459 | bool kconsole_check_poll(void) |
|
- | 460 | { |
|
- | 461 | return check_poll(stdin); |
|
- | 462 | } |
|
- | 463 | ||
459 | /** Kernel console prompt. |
464 | /** Kernel console prompt. |
460 | * |
465 | * |
461 | * @param prompt Kernel console prompt (e.g kconsole/panic). |
466 | * @param prompt Kernel console prompt (e.g kconsole/panic). |
462 | * @param msg Message to display in the beginning. |
467 | * @param msg Message to display in the beginning. |
463 | * @param kcon Wait for keypress to show the prompt |
468 | * @param kcon Wait for keypress to show the prompt |
Line 467... | Line 472... | ||
467 | void kconsole(char *prompt, char *msg, bool kcon) |
472 | void kconsole(char *prompt, char *msg, bool kcon) |
468 | { |
473 | { |
469 | cmd_info_t *cmd_info; |
474 | cmd_info_t *cmd_info; |
470 | count_t len; |
475 | count_t len; |
471 | char *cmdline; |
476 | char *cmdline; |
472 | 477 | ||
473 | if (!stdin) { |
478 | if (!stdin) { |
474 | LOG("No stdin for kernel console"); |
479 | LOG("No stdin for kernel console"); |
475 | return; |
480 | return; |
476 | } |
481 | } |
477 | 482 | ||
478 | if (msg) |
483 | if (msg) |
479 | printf("%s", msg); |
484 | printf("%s", msg); |
480 | 485 | ||
481 | if (kcon) |
486 | if (kcon) |
482 | _getc(stdin); |
487 | _getc(stdin); |
- | 488 | else |
|
- | 489 | printf("Type \"exit\" to leave the console.\n"); |
|
483 | 490 | ||
484 | while (true) { |
491 | while (true) { |
485 | cmdline = clever_readline((char *) prompt, stdin); |
492 | cmdline = clever_readline((char *) prompt, stdin); |
486 | len = strlen(cmdline); |
493 | len = strlen(cmdline); |
487 | if (!len) |
494 | if (!len) |
488 | continue; |
495 | continue; |
489 | 496 | ||
- | 497 | if ((!kcon) && (len == 4) && (strncmp(cmdline, "exit", 4) == 0)) |
|
- | 498 | break; |
|
- | 499 | ||
490 | cmd_info = parse_cmdline(cmdline, len); |
500 | cmd_info = parse_cmdline(cmdline, len); |
491 | if (!cmd_info) |
501 | if (!cmd_info) |
492 | continue; |
502 | continue; |
493 | 503 | ||
494 | if ((!kcon) |
- | |
495 | && (strncmp(cmd_info->name, "exit", min(strlen(cmd_info->name), 5)) == 0)) |
- | |
496 | break; |
- | |
497 | - | ||
498 | (void) cmd_info->func(cmd_info->argv); |
504 | (void) cmd_info->func(cmd_info->argv); |
499 | } |
505 | } |
500 | } |
506 | } |
501 | 507 | ||
502 | /** Kernel console managing thread. |
508 | /** Kernel console managing thread. |