Subversion Repositories HelenOS

Rev

Rev 3343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3343 Rev 3742
Line 399... Line 399...
399
    }
399
    }
400
    current[curlen] = '\0';
400
    current[curlen] = '\0';
401
    return current;
401
    return current;
402
}
402
}
403
 
403
 
404
/** Kernel console managing thread.
404
/** Kernel console prompt.
405
 *
405
 *
406
 * @param prompt Kernel console prompt (e.g kconsole/panic).
406
 * @param prompt Kernel console prompt (e.g kconsole/panic).
-
 
407
 * @param msg    Message to display in the beginning.
-
 
408
 * @param kcon   Wait for keypress to show the prompt
-
 
409
 *               and never exit.
-
 
410
 *
407
 */
411
 */
408
void kconsole(void *prompt)
412
void kconsole(char *prompt, char *msg, bool kcon)
409
{
413
{
410
    cmd_info_t *cmd_info;
414
    cmd_info_t *cmd_info;
411
    count_t len;
415
    count_t len;
412
    char *cmdline;
416
    char *cmdline;
413
 
417
 
414
    if (!stdin) {
418
    if (!stdin) {
415
        printf("%s: no stdin\n", __func__);
419
        LOG("No stdin for kernel console");
416
        return;
420
        return;
417
    }
421
    }
418
   
422
   
-
 
423
    if (msg)
-
 
424
        printf("%s", msg);
-
 
425
   
-
 
426
    if (kcon)
-
 
427
        _getc(stdin);
-
 
428
   
419
    while (true) {
429
    while (true) {
420
        cmdline = clever_readline((char *) prompt, stdin);
430
        cmdline = clever_readline((char *) prompt, stdin);
421
        len = strlen(cmdline);
431
        len = strlen(cmdline);
422
        if (!len)
432
        if (!len)
423
            continue;
433
            continue;
-
 
434
       
424
        cmd_info = parse_cmdline(cmdline, len);
435
        cmd_info = parse_cmdline(cmdline, len);
425
        if (!cmd_info)
436
        if (!cmd_info)
426
            continue;
437
            continue;
-
 
438
       
427
        if (strncmp(cmd_info->name, "exit",
439
        if ((!kcon)
428
            min(strlen(cmd_info->name), 5)) == 0)
440
            && (strncmp(cmd_info->name, "exit", min(strlen(cmd_info->name), 5)) == 0))
429
            break;
441
            break;
-
 
442
       
430
        (void) cmd_info->func(cmd_info->argv);
443
        (void) cmd_info->func(cmd_info->argv);
431
    }
444
    }
432
}
445
}
433
 
446
 
-
 
447
/** Kernel console managing thread.
-
 
448
 *
-
 
449
 */
-
 
450
void kconsole_thread(void *data)
-
 
451
{
-
 
452
    kconsole("kconsole", "Kernel console ready (press any key to activate)\n", true);
-
 
453
}
-
 
454
 
434
static int parse_int_arg(char *text, size_t len, unative_t *result)
455
static int parse_int_arg(char *text, size_t len, unative_t *result)
435
{
456
{
436
    static char symname[MAX_SYMBOL_NAME];
457
    static char symname[MAX_SYMBOL_NAME];
437
    uintptr_t symaddr;
458
    uintptr_t symaddr;
438
    bool isaddr = false;
459
    bool isaddr = false;