OpenCores
URL https://opencores.org/ocsvn/de1_olpcl2294_system/de1_olpcl2294_system/trunk

Subversion Repositories de1_olpcl2294_system

[/] [de1_olpcl2294_system/] [trunk/] [sw/] [ecos/] [shell/] [dbg_sh.c] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 qaztronic
//
2
//
3
//
4
 
5
#include <stdio.h>
6
#include "LPC22xx.h"
7
 
8
#include <cyg/error/codes.h>
9
#include <cyg/io/io.h>
10
#include <cyg/io/ttyio.h>
11
 
12
#include "lib_dbg_sh.h"
13
#include "parse.h"
14
 
15 10 qaztronic
#include "shell_cmds.h"
16 7 qaztronic
 
17
 
18
//--------------------------------------------------------------------------
19
//
20
//
21
RedBoot_cmd("help",
22
            "Help about help?",
23
            "[<topic>]",
24
            do_help
25
    );
26
 
27
void
28
show_help(struct cmd *cmd, struct cmd *cmd_end, char *which, char *pre)
29
{
30
    bool show;
31
    int len = 0;
32
 
33
    if (which) {
34
        len = strlen(which);
35
    }
36
    while (cmd != cmd_end) {
37
        show = true;
38
        if (which && (strncasecmp(which, cmd->str, len) != 0)) {
39
            show = false;
40
        }
41
        if (show) {
42
            printf("%s\n  %s %s %s\n", cmd->help, pre, cmd->str, cmd->usage);
43
            if ((cmd->sub_cmds != (struct cmd *)0) && (which != (char *)0)) {
44
                show_help(cmd->sub_cmds, cmd->sub_cmds_end, 0, cmd->str);
45
            }
46
        }
47
        cmd++;
48
    }
49
}
50
 
51
void
52
do_help(int argc, char *argv[])
53
{
54
    struct cmd *cmd;
55
    char *which = (char *)0;
56
 
57
    if (!scan_opts(argc, argv, 1, 0, 0, (void *)&which, OPTION_ARG_TYPE_STR, "<topic>")) {
58
        printf("Invalid argument\n");
59
        return;
60
    }
61
    cmd = __RedBoot_CMD_TAB__;
62
    show_help(cmd, &__RedBoot_CMD_TAB_END__, which, "");
63
    return;
64
}
65
 
66
 
67
void dbg_sh(void)
68
{
69
  char buffer[256];
70
 
71
  char *command;
72
  struct cmd *cmd;
73
 
74
  int argc;
75
  char *argv[16];
76
 
77
  while(1)
78
  {
79
    printf( "dbg_sh> " );
80
 
81
    gets( buffer );
82
    command = buffer;
83
 
84
    if( strlen(command) > 0 )
85
    {
86
      if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0)
87
      {
88
          (cmd->fun)(argc, argv);
89
      } else
90
      {
91
          printf("** Error: Illegal command: \"%s\"\n", argv[0]);
92
      }
93
    }
94
  }
95
}
96
 
97
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.