Subversion Repositories HelenOS-historic

Rev

Rev 589 | Rev 594 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 589 Rev 591
1
/*
1
/*
2
 * Copyright (C) 2005 Jakub Jermar
2
 * Copyright (C) 2005 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <console/kconsole.h>
29
#include <console/kconsole.h>
30
#include <console/console.h>
30
#include <console/console.h>
31
#include <console/chardev.h>
31
#include <console/chardev.h>
32
#include <print.h>
32
#include <print.h>
33
#include <panic.h>
33
#include <panic.h>
34
#include <typedefs.h>
34
#include <typedefs.h>
35
#include <arch/types.h>
35
#include <arch/types.h>
36
#include <list.h>
36
#include <list.h>
37
#include <arch.h>
37
#include <arch.h>
38
#include <func.h>
38
#include <func.h>
39
#include <macros.h>
39
#include <macros.h>
40
#include <debug.h>
40
#include <debug.h>
41
#include <symtab.h>
41
#include <symtab.h>
42
 
42
 
43
#define MAX_CMDLINE 256
43
#define MAX_CMDLINE 256
44
 
44
 
45
/** Simple kernel console.
45
/** Simple kernel console.
46
 *
46
 *
47
 * The console is realized by kernel thread kconsole.
47
 * The console is realized by kernel thread kconsole.
48
 * It doesn't understand any useful command on its own,
48
 * It doesn't understand any useful command on its own,
49
 * but makes it possible for other kernel subsystems to
49
 * but makes it possible for other kernel subsystems to
50
 * register their own commands.
50
 * register their own commands.
51
 */
51
 */
52
 
52
 
53
/** Locking.
53
/** Locking.
54
 *
54
 *
55
 * There is a list of cmd_info_t structures. This list
55
 * There is a list of cmd_info_t structures. This list
56
 * is protected by cmd_lock spinlock. Note that specially
56
 * is protected by cmd_lock spinlock. Note that specially
57
 * the link elements of cmd_info_t are protected by
57
 * the link elements of cmd_info_t are protected by
58
 * this lock.
58
 * this lock.
59
 *
59
 *
60
 * Each cmd_info_t also has its own lock, which protects
60
 * Each cmd_info_t also has its own lock, which protects
61
 * all elements thereof except the link element.
61
 * all elements thereof except the link element.
62
 *
62
 *
63
 * cmd_lock must be acquired before any cmd_info lock.
63
 * cmd_lock must be acquired before any cmd_info lock.
64
 * When locking two cmd info structures, structure with
64
 * When locking two cmd info structures, structure with
65
 * lower address must be locked first.
65
 * lower address must be locked first.
66
 */
66
 */
67
 
67
 
68
spinlock_t cmd_lock;    /**< Lock protecting command list. */
68
spinlock_t cmd_lock;    /**< Lock protecting command list. */
69
link_t cmd_head;    /**< Command list. */
69
link_t cmd_head;    /**< Command list. */
70
 
70
 
71
static cmd_info_t *parse_cmdline(char *cmdline, size_t len);
71
static cmd_info_t *parse_cmdline(char *cmdline, size_t len);
72
static bool parse_argument(char *cmdline, size_t len, index_t *start, index_t *end);
72
static bool parse_argument(char *cmdline, size_t len, index_t *start, index_t *end);
73
 
73
 
74
/** Data and methods for 'help' command. */
74
/** Data and methods for 'help' command. */
75
static int cmd_help(cmd_arg_t *argv);
75
static int cmd_help(cmd_arg_t *argv);
76
static cmd_info_t help_info = {
76
static cmd_info_t help_info = {
77
    .name = "help",
77
    .name = "help",
78
    .description = "List of supported commands.",
78
    .description = "List of supported commands.",
79
    .func = cmd_help,
79
    .func = cmd_help,
80
    .argc = 0
80
    .argc = 0
81
};
81
};
82
 
82
 
83
/** Data and methods for 'description' command. */
83
/** Data and methods for 'description' command. */
84
static int cmd_desc(cmd_arg_t *argv);
84
static int cmd_desc(cmd_arg_t *argv);
85
static void desc_help(void);
85
static void desc_help(void);
86
static char desc_buf[MAX_CMDLINE+1];
86
static char desc_buf[MAX_CMDLINE+1];
87
static cmd_arg_t desc_argv = {
87
static cmd_arg_t desc_argv = {
88
    .type = ARG_TYPE_STRING,
88
    .type = ARG_TYPE_STRING,
89
    .buffer = desc_buf,
89
    .buffer = desc_buf,
90
    .len = sizeof(desc_buf)
90
    .len = sizeof(desc_buf)
91
};
91
};
92
static cmd_info_t desc_info = {
92
static cmd_info_t desc_info = {
93
    .name = "describe",
93
    .name = "describe",
94
    .description = "Describe specified command.",
94
    .description = "Describe specified command.",
95
    .help = desc_help,
95
    .help = desc_help,
96
    .func = cmd_desc,
96
    .func = cmd_desc,
97
    .argc = 1,
97
    .argc = 1,
98
    .argv = &desc_argv
98
    .argv = &desc_argv
99
};
99
};
100
 
100
 
101
/** Data and methods for 'symaddr' command. */
101
/** Data and methods for 'symaddr' command. */
102
static int cmd_symaddr(cmd_arg_t *argv);
102
static int cmd_symaddr(cmd_arg_t *argv);
103
static char symaddr_buf[MAX_CMDLINE+1];
103
static char symaddr_buf[MAX_CMDLINE+1];
104
static cmd_arg_t symaddr_argv = {
104
static cmd_arg_t symaddr_argv = {
105
    .type = ARG_TYPE_STRING,
105
    .type = ARG_TYPE_STRING,
106
    .buffer = symaddr_buf,
106
    .buffer = symaddr_buf,
107
    .len = sizeof(symaddr_buf)
107
    .len = sizeof(symaddr_buf)
108
};
108
};
109
static cmd_info_t symaddr_info = {
109
static cmd_info_t symaddr_info = {
110
    .name = "symaddr",
110
    .name = "symaddr",
111
    .description = "Return symbol address.",
111
    .description = "Return symbol address.",
112
    .func = cmd_symaddr,
112
    .func = cmd_symaddr,
113
    .argc = 1,
113
    .argc = 1,
114
    .argv = &symaddr_argv
114
    .argv = &symaddr_argv
115
};
115
};
116
 
116
 
117
/** Call0 - call function with no parameters */
117
/** Call0 - call function with no parameters */
118
static char call0_buf[MAX_CMDLINE+1];
118
static char call0_buf[MAX_CMDLINE+1];
119
static char carg1_buf[MAX_CMDLINE+1];
119
static char carg1_buf[MAX_CMDLINE+1];
120
static char carg2_buf[MAX_CMDLINE+1];
120
static char carg2_buf[MAX_CMDLINE+1];
-
 
121
static char carg3_buf[MAX_CMDLINE+1];
121
 
122
 
122
static int cmd_call0(cmd_arg_t *argv);
123
static int cmd_call0(cmd_arg_t *argv);
123
static cmd_arg_t call0_argv = {
124
static cmd_arg_t call0_argv = {
124
    .type = ARG_TYPE_STRING,
125
    .type = ARG_TYPE_STRING,
125
    .buffer = call0_buf,
126
    .buffer = call0_buf,
126
    .len = sizeof(call0_buf)
127
    .len = sizeof(call0_buf)
127
};
128
};
128
static cmd_info_t call0_info = {
129
static cmd_info_t call0_info = {
129
    .name = "call0",
130
    .name = "call0",
130
    .description = "call0 <function> -> call function().",
131
    .description = "call0 <function> -> call function().",
131
    .func = cmd_call0,
132
    .func = cmd_call0,
132
    .argc = 1,
133
    .argc = 1,
133
    .argv = &call0_argv
134
    .argv = &call0_argv
134
};
135
};
135
 
136
 
136
static int cmd_call1(cmd_arg_t *argv);
137
static int cmd_call1(cmd_arg_t *argv);
137
static cmd_arg_t call1_argv[] = {
138
static cmd_arg_t call1_argv[] = {
138
    {
139
    {
139
        .type = ARG_TYPE_STRING,
140
        .type = ARG_TYPE_STRING,
140
        .buffer = call0_buf,
141
        .buffer = call0_buf,
141
        .len = sizeof(call0_buf)
142
        .len = sizeof(call0_buf)
142
    },
143
    },
143
    {
144
    {
144
        .type = ARG_TYPE_VAR,
145
        .type = ARG_TYPE_VAR,
145
        .buffer = carg1_buf,
146
        .buffer = carg1_buf,
146
        .len = sizeof(carg1_buf)
147
        .len = sizeof(carg1_buf)
147
    }
148
    }
148
};
149
};
149
static cmd_info_t call1_info = {
150
static cmd_info_t call1_info = {
150
    .name = "call1",
151
    .name = "call1",
151
    .description = "call1 <function> <arg1> -> call function(arg1).",
152
    .description = "call1 <function> <arg1> -> call function(arg1).",
152
    .func = cmd_call1,
153
    .func = cmd_call1,
153
    .argc = 2,
154
    .argc = 2,
154
    .argv = call1_argv
155
    .argv = call1_argv
155
};
156
};
156
 
157
 
157
static int cmd_call2(cmd_arg_t *argv);
158
static int cmd_call2(cmd_arg_t *argv);
158
static cmd_arg_t call2_argv[] = {
159
static cmd_arg_t call2_argv[] = {
159
    {
160
    {
160
        .type = ARG_TYPE_STRING,
161
        .type = ARG_TYPE_STRING,
161
        .buffer = call0_buf,
162
        .buffer = call0_buf,
162
        .len = sizeof(call0_buf)
163
        .len = sizeof(call0_buf)
163
    },
164
    },
164
    {
165
    {
165
        .type = ARG_TYPE_VAR,
166
        .type = ARG_TYPE_VAR,
166
        .buffer = carg1_buf,
167
        .buffer = carg1_buf,
167
        .len = sizeof(carg1_buf)
168
        .len = sizeof(carg1_buf)
168
    },
169
    },
169
    {
170
    {
170
        .type = ARG_TYPE_VAR,
171
        .type = ARG_TYPE_VAR,
171
        .buffer = carg2_buf,
172
        .buffer = carg2_buf,
172
        .len = sizeof(carg2_buf)
173
        .len = sizeof(carg2_buf)
173
    }
174
    }
174
};
175
};
175
static cmd_info_t call2_info = {
176
static cmd_info_t call2_info = {
176
    .name = "call2",
177
    .name = "call2",
177
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
178
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
178
    .func = cmd_call2,
179
    .func = cmd_call2,
179
    .argc = 3,
180
    .argc = 3,
180
    .argv = call2_argv
181
    .argv = call2_argv
181
};
182
};
182
 
183
 
-
 
184
static int cmd_call3(cmd_arg_t *argv);
-
 
185
static cmd_arg_t call3_argv[] = {
-
 
186
    {
-
 
187
        .type = ARG_TYPE_STRING,
-
 
188
        .buffer = call0_buf,
-
 
189
        .len = sizeof(call0_buf)
-
 
190
    },
-
 
191
    {
-
 
192
        .type = ARG_TYPE_VAR,
-
 
193
        .buffer = carg1_buf,
-
 
194
        .len = sizeof(carg1_buf)
-
 
195
    },
-
 
196
    {
-
 
197
        .type = ARG_TYPE_VAR,
-
 
198
        .buffer = carg2_buf,
-
 
199
        .len = sizeof(carg2_buf)
-
 
200
    },
-
 
201
    {
-
 
202
        .type = ARG_TYPE_VAR,
-
 
203
        .buffer = carg3_buf,
-
 
204
        .len = sizeof(carg3_buf)
-
 
205
    }
-
 
206
 
-
 
207
};
-
 
208
static cmd_info_t call3_info = {
-
 
209
    .name = "call3",
-
 
210
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
-
 
211
    .func = cmd_call3,
-
 
212
    .argc = 4,
-
 
213
    .argv = call3_argv
-
 
214
};
183
 
215
 
184
/** Data and methods for 'halt' command. */
216
/** Data and methods for 'halt' command. */
185
static int cmd_halt(cmd_arg_t *argv);
217
static int cmd_halt(cmd_arg_t *argv);
186
static cmd_info_t halt_info = {
218
static cmd_info_t halt_info = {
187
    .name = "halt",
219
    .name = "halt",
188
    .description = "Halt the kernel.",
220
    .description = "Halt the kernel.",
189
    .func = cmd_halt,
221
    .func = cmd_halt,
190
    .argc = 0
222
    .argc = 0
191
};
223
};
192
 
224
 
193
/** Initialize kconsole data structures. */
225
/** Initialize kconsole data structures. */
194
void kconsole_init(void)
226
void kconsole_init(void)
195
{
227
{
196
    spinlock_initialize(&cmd_lock, "kconsole_cmd");
228
    spinlock_initialize(&cmd_lock, "kconsole_cmd");
197
    list_initialize(&cmd_head);
229
    list_initialize(&cmd_head);
198
   
230
   
199
    spinlock_initialize(&help_info.lock, "kconsole_help");
231
    spinlock_initialize(&help_info.lock, "kconsole_help");
200
    link_initialize(&help_info.link);
232
    link_initialize(&help_info.link);
201
    if (!cmd_register(&help_info))
233
    if (!cmd_register(&help_info))
202
        panic("could not register command %s\n", help_info.name);
234
        panic("could not register command %s\n", help_info.name);
203
 
235
 
204
 
236
 
205
    spinlock_initialize(&desc_info.lock, "kconsole_desc");
237
    spinlock_initialize(&desc_info.lock, "kconsole_desc");
206
    link_initialize(&desc_info.link);
238
    link_initialize(&desc_info.link);
207
    if (!cmd_register(&desc_info))
239
    if (!cmd_register(&desc_info))
208
        panic("could not register command %s\n", desc_info.name);
240
        panic("could not register command %s\n", desc_info.name);
209
   
241
   
210
    spinlock_initialize(&symaddr_info.lock, "kconsole_symaddr");
242
    spinlock_initialize(&symaddr_info.lock, "kconsole_symaddr");
211
    link_initialize(&symaddr_info.link);
243
    link_initialize(&symaddr_info.link);
212
    if (!cmd_register(&symaddr_info))
244
    if (!cmd_register(&symaddr_info))
213
        panic("could not register command %s\n", symaddr_info.name);
245
        panic("could not register command %s\n", symaddr_info.name);
214
 
246
 
215
    spinlock_initialize(&call0_info.lock, "kconsole_call0");
247
    spinlock_initialize(&call0_info.lock, "kconsole_call0");
216
    link_initialize(&call0_info.link);
248
    link_initialize(&call0_info.link);
217
    if (!cmd_register(&call0_info))
249
    if (!cmd_register(&call0_info))
218
        panic("could not register command %s\n", call0_info.name);
250
        panic("could not register command %s\n", call0_info.name);
219
 
251
 
220
    spinlock_initialize(&call1_info.lock, "kconsole_call1");
252
    spinlock_initialize(&call1_info.lock, "kconsole_call1");
221
    link_initialize(&call1_info.link);
253
    link_initialize(&call1_info.link);
222
    if (!cmd_register(&call1_info))
254
    if (!cmd_register(&call1_info))
223
        panic("could not register command %s\n", call1_info.name);
255
        panic("could not register command %s\n", call1_info.name);
224
 
256
 
225
 
257
 
226
    spinlock_initialize(&call2_info.lock, "kconsole_call2");
258
    spinlock_initialize(&call2_info.lock, "kconsole_call2");
227
    link_initialize(&call2_info.link);
259
    link_initialize(&call2_info.link);
228
    if (!cmd_register(&call2_info))
260
    if (!cmd_register(&call2_info))
229
        panic("could not register command %s\n", call2_info.name);
261
        panic("could not register command %s\n", call2_info.name);
-
 
262
 
-
 
263
    spinlock_initialize(&call3_info.lock, "kconsole_call3");
-
 
264
    link_initialize(&call3_info.link);
-
 
265
    if (!cmd_register(&call3_info))
-
 
266
        panic("could not register command %s\n", call3_info.name);
230
   
267
   
231
    spinlock_initialize(&halt_info.lock, "kconsole_halt");
268
    spinlock_initialize(&halt_info.lock, "kconsole_halt");
232
    link_initialize(&halt_info.link);
269
    link_initialize(&halt_info.link);
233
    if (!cmd_register(&halt_info))
270
    if (!cmd_register(&halt_info))
234
        panic("could not register command %s\n", halt_info.name);
271
        panic("could not register command %s\n", halt_info.name);
235
}
272
}
236
 
273
 
237
 
274
 
238
/** Register kconsole command.
275
/** Register kconsole command.
239
 *
276
 *
240
 * @param cmd Structure describing the command.
277
 * @param cmd Structure describing the command.
241
 *
278
 *
242
 * @return 0 on failure, 1 on success.
279
 * @return 0 on failure, 1 on success.
243
 */
280
 */
244
int cmd_register(cmd_info_t *cmd)
281
int cmd_register(cmd_info_t *cmd)
245
{
282
{
246
    ipl_t ipl;
283
    ipl_t ipl;
247
    link_t *cur;
284
    link_t *cur;
248
   
285
   
249
    spinlock_lock(&cmd_lock);
286
    spinlock_lock(&cmd_lock);
250
   
287
   
251
    /*
288
    /*
252
     * Make sure the command is not already listed.
289
     * Make sure the command is not already listed.
253
     */
290
     */
254
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
291
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
255
        cmd_info_t *hlp;
292
        cmd_info_t *hlp;
256
       
293
       
257
        hlp = list_get_instance(cur, cmd_info_t, link);
294
        hlp = list_get_instance(cur, cmd_info_t, link);
258
 
295
 
259
        if (hlp == cmd) {
296
        if (hlp == cmd) {
260
            /* The command is already there. */
297
            /* The command is already there. */
261
            spinlock_unlock(&cmd_lock);
298
            spinlock_unlock(&cmd_lock);
262
            return 0;
299
            return 0;
263
        }
300
        }
264
 
301
 
265
        /* Avoid deadlock. */
302
        /* Avoid deadlock. */
266
        if (hlp < cmd) {
303
        if (hlp < cmd) {
267
            spinlock_lock(&hlp->lock);
304
            spinlock_lock(&hlp->lock);
268
            spinlock_lock(&cmd->lock);
305
            spinlock_lock(&cmd->lock);
269
        } else {
306
        } else {
270
            spinlock_lock(&cmd->lock);
307
            spinlock_lock(&cmd->lock);
271
            spinlock_lock(&hlp->lock);
308
            spinlock_lock(&hlp->lock);
272
        }
309
        }
273
       
310
       
274
        if ((strncmp(hlp->name, cmd->name, strlen(cmd->name)) == 0)) {
311
        if ((strncmp(hlp->name, cmd->name, strlen(cmd->name)) == 0)) {
275
            /* The command is already there. */
312
            /* The command is already there. */
276
            spinlock_unlock(&hlp->lock);
313
            spinlock_unlock(&hlp->lock);
277
            spinlock_unlock(&cmd->lock);
314
            spinlock_unlock(&cmd->lock);
278
            spinlock_unlock(&cmd_lock);
315
            spinlock_unlock(&cmd_lock);
279
            return 0;
316
            return 0;
280
        }
317
        }
281
       
318
       
282
        spinlock_unlock(&hlp->lock);
319
        spinlock_unlock(&hlp->lock);
283
        spinlock_unlock(&cmd->lock);
320
        spinlock_unlock(&cmd->lock);
284
    }
321
    }
285
   
322
   
286
    /*
323
    /*
287
     * Now the command can be added.
324
     * Now the command can be added.
288
     */
325
     */
289
    list_append(&cmd->link, &cmd_head);
326
    list_append(&cmd->link, &cmd_head);
290
   
327
   
291
    spinlock_unlock(&cmd_lock);
328
    spinlock_unlock(&cmd_lock);
292
    return 1;
329
    return 1;
293
}
330
}
294
 
331
 
295
/** Kernel console managing thread.
332
/** Kernel console managing thread.
296
 *
333
 *
297
 * @param arg Not used.
334
 * @param arg Not used.
298
 */
335
 */
299
void kconsole(void *arg)
336
void kconsole(void *arg)
300
{
337
{
301
    char cmdline[MAX_CMDLINE+1];
338
    char cmdline[MAX_CMDLINE+1];
302
    cmd_info_t *cmd_info;
339
    cmd_info_t *cmd_info;
303
    count_t len;
340
    count_t len;
304
 
341
 
305
    if (!stdin) {
342
    if (!stdin) {
306
        printf("%s: no stdin\n", __FUNCTION__);
343
        printf("%s: no stdin\n", __FUNCTION__);
307
        return;
344
        return;
308
    }
345
    }
309
   
346
   
310
    while (true) {
347
    while (true) {
311
        printf("%s> ", __FUNCTION__);
348
        printf("%s> ", __FUNCTION__);
312
        if (!(len = gets(stdin, cmdline, sizeof(cmdline))))
349
        if (!(len = gets(stdin, cmdline, sizeof(cmdline))))
313
            continue;
350
            continue;
314
        cmdline[len] = '\0';
351
        cmdline[len] = '\0';
315
        cmd_info = parse_cmdline(cmdline, len);
352
        cmd_info = parse_cmdline(cmdline, len);
316
        if (!cmd_info)
353
        if (!cmd_info)
317
            continue;
354
            continue;
318
        (void) cmd_info->func(cmd_info->argv);
355
        (void) cmd_info->func(cmd_info->argv);
319
    }
356
    }
320
}
357
}
321
 
358
 
322
static int parse_int_arg(char *text, size_t len, __native *result)
359
static int parse_int_arg(char *text, size_t len, __native *result)
323
{
360
{
324
    char symname[MAX_SYMBOL_NAME];
361
    char symname[MAX_SYMBOL_NAME];
325
    __address symaddr;
362
    __address symaddr;
326
    bool isaddr = false;
363
    bool isaddr = false;
327
    bool isptr = false;
364
    bool isptr = false;
328
   
365
   
329
    /* If we get a name, try to find it in symbol table */
366
    /* If we get a name, try to find it in symbol table */
330
    if (text[0] < '0' | text[0] > '9') {
367
    if (text[0] < '0' | text[0] > '9') {
331
        if (text[0] == '&') {
368
        if (text[0] == '&') {
332
            isaddr = true;
369
            isaddr = true;
333
            text++;len--;
370
            text++;len--;
334
        } else if (text[0] == '*') {
371
        } else if (text[0] == '*') {
335
            isptr = true;
372
            isptr = true;
336
            text++;len--;
373
            text++;len--;
337
        }
374
        }
338
        strncpy(symname, text, min(len+1, MAX_SYMBOL_NAME));
375
        strncpy(symname, text, min(len+1, MAX_SYMBOL_NAME));
339
        symaddr = get_symbol_addr(symname);
376
        symaddr = get_symbol_addr(symname);
340
        if (!symaddr) {
377
        if (!symaddr) {
341
            printf("Symbol %s not found.\n",symname);
378
            printf("Symbol %s not found.\n",symname);
342
            return -1;
379
            return -1;
343
        }
380
        }
344
        if (symaddr == (__address) -1) {
381
        if (symaddr == (__address) -1) {
345
            printf("Duplicate symbol %s.\n",symname);
382
            printf("Duplicate symbol %s.\n",symname);
346
            symtab_print_search(symname);
383
            symtab_print_search(symname);
347
            return -1;
384
            return -1;
348
        }
385
        }
349
        if (isaddr)
386
        if (isaddr)
350
            *result = (__native)symaddr;
387
            *result = (__native)symaddr;
351
        else if (isptr)
388
        else if (isptr)
352
            *result = **((__native **)symaddr);
389
            *result = **((__native **)symaddr);
353
        else
390
        else
354
            *result = *((__native *)symaddr);
391
            *result = *((__native *)symaddr);
355
    } else /* It's a number - convert it */
392
    } else /* It's a number - convert it */
356
        *result = atoi(text);
393
        *result = atoi(text);
357
    return 0;
394
    return 0;
358
}
395
}
359
 
396
 
360
/** Parse command line.
397
/** Parse command line.
361
 *
398
 *
362
 * @param cmdline Command line as read from input device.
399
 * @param cmdline Command line as read from input device.
363
 * @param len Command line length.
400
 * @param len Command line length.
364
 *
401
 *
365
 * @return Structure describing the command.
402
 * @return Structure describing the command.
366
 */
403
 */
367
cmd_info_t *parse_cmdline(char *cmdline, size_t len)
404
cmd_info_t *parse_cmdline(char *cmdline, size_t len)
368
{
405
{
369
    index_t start = 0, end = 0;
406
    index_t start = 0, end = 0;
370
    cmd_info_t *cmd = NULL;
407
    cmd_info_t *cmd = NULL;
371
    link_t *cur;
408
    link_t *cur;
372
    ipl_t ipl;
409
    ipl_t ipl;
373
    int i;
410
    int i;
374
   
411
   
375
    if (!parse_argument(cmdline, len, &start, &end)) {
412
    if (!parse_argument(cmdline, len, &start, &end)) {
376
        /* Command line did not contain alphanumeric word. */
413
        /* Command line did not contain alphanumeric word. */
377
        return NULL;
414
        return NULL;
378
    }
415
    }
379
 
416
 
380
    spinlock_lock(&cmd_lock);
417
    spinlock_lock(&cmd_lock);
381
   
418
   
382
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
419
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
383
        cmd_info_t *hlp;
420
        cmd_info_t *hlp;
384
       
421
       
385
        hlp = list_get_instance(cur, cmd_info_t, link);
422
        hlp = list_get_instance(cur, cmd_info_t, link);
386
        spinlock_lock(&hlp->lock);
423
        spinlock_lock(&hlp->lock);
387
       
424
       
388
        if (strncmp(hlp->name, &cmdline[start], (end - start) + 1) == 0) {
425
        if (strncmp(hlp->name, &cmdline[start], (end - start) + 1) == 0) {
389
            cmd = hlp;
426
            cmd = hlp;
390
            break;
427
            break;
391
        }
428
        }
392
       
429
       
393
        spinlock_unlock(&hlp->lock);
430
        spinlock_unlock(&hlp->lock);
394
    }
431
    }
395
   
432
   
396
    spinlock_unlock(&cmd_lock);
433
    spinlock_unlock(&cmd_lock);
397
   
434
   
398
    if (!cmd) {
435
    if (!cmd) {
399
        /* Unknown command. */
436
        /* Unknown command. */
400
        printf("Unknown command.\n");
437
        printf("Unknown command.\n");
401
        return NULL;
438
        return NULL;
402
    }
439
    }
403
 
440
 
404
    /* cmd == hlp is locked */
441
    /* cmd == hlp is locked */
405
   
442
   
406
    /*
443
    /*
407
     * The command line must be further analyzed and
444
     * The command line must be further analyzed and
408
     * the parameters therefrom must be matched and
445
     * the parameters therefrom must be matched and
409
     * converted to those specified in the cmd info
446
     * converted to those specified in the cmd info
410
     * structure.
447
     * structure.
411
     */
448
     */
412
 
449
 
413
    for (i = 0; i < cmd->argc; i++) {
450
    for (i = 0; i < cmd->argc; i++) {
414
        char *buf;
451
        char *buf;
415
        start = end + 1;
452
        start = end + 1;
416
        if (!parse_argument(cmdline, len, &start, &end)) {
453
        if (!parse_argument(cmdline, len, &start, &end)) {
417
            printf("Too few arguments.\n");
454
            printf("Too few arguments.\n");
418
            spinlock_unlock(&cmd->lock);
455
            spinlock_unlock(&cmd->lock);
419
            return NULL;
456
            return NULL;
420
        }
457
        }
421
       
458
       
422
        switch (cmd->argv[i].type) {
459
        switch (cmd->argv[i].type) {
423
        case ARG_TYPE_STRING:
460
        case ARG_TYPE_STRING:
424
                buf = cmd->argv[i].buffer;
461
                buf = cmd->argv[i].buffer;
425
                strncpy(buf, (const char *) &cmdline[start], min((end - start) + 2, cmd->argv[i].len));
462
                strncpy(buf, (const char *) &cmdline[start], min((end - start) + 2, cmd->argv[i].len));
426
            buf[min((end - start) + 1, cmd->argv[i].len - 1)] = '\0';
463
            buf[min((end - start) + 1, cmd->argv[i].len - 1)] = '\0';
427
            break;
464
            break;
428
        case ARG_TYPE_INT:
465
        case ARG_TYPE_INT:
429
            if (parse_int_arg(cmdline+start, end-start+1,
466
            if (parse_int_arg(cmdline+start, end-start+1,
430
                      &cmd->argv[i].intval))
467
                      &cmd->argv[i].intval))
431
                return NULL;
468
                return NULL;
432
            break;
469
            break;
433
        case ARG_TYPE_VAR:
470
        case ARG_TYPE_VAR:
434
            if (start != end && cmdline[start] == '"' && cmdline[end] == '"') {
471
            if (start != end && cmdline[start] == '"' && cmdline[end] == '"') {
435
                buf = cmd->argv[i].buffer;
472
                buf = cmd->argv[i].buffer;
436
                strncpy(buf, (const char *) &cmdline[start+1],
473
                strncpy(buf, (const char *) &cmdline[start+1],
437
                    min((end-start), cmd->argv[i].len));
474
                    min((end-start), cmd->argv[i].len));
438
                buf[min((end - start), cmd->argv[i].len - 1)] = '\0';
475
                buf[min((end - start), cmd->argv[i].len - 1)] = '\0';
439
                cmd->argv[i].intval = (__native) buf;
476
                cmd->argv[i].intval = (__native) buf;
440
                cmd->argv[i].vartype = ARG_TYPE_STRING;
477
                cmd->argv[i].vartype = ARG_TYPE_STRING;
441
            } else if (!parse_int_arg(cmdline+start, end-start+1,
478
            } else if (!parse_int_arg(cmdline+start, end-start+1,
442
                         &cmd->argv[i].intval))
479
                         &cmd->argv[i].intval))
443
                cmd->argv[i].vartype = ARG_TYPE_INT;
480
                cmd->argv[i].vartype = ARG_TYPE_INT;
444
            else {
481
            else {
445
                printf("Unrecognized variable argument.\n");
482
                printf("Unrecognized variable argument.\n");
446
                return NULL;
483
                return NULL;
447
            }
484
            }
448
            break;
485
            break;
449
        case ARG_TYPE_INVALID:
486
        case ARG_TYPE_INVALID:
450
        default:
487
        default:
451
            printf("invalid argument type\n");
488
            printf("invalid argument type\n");
452
            return NULL;
489
            return NULL;
453
            break;
490
            break;
454
        }
491
        }
455
    }
492
    }
456
   
493
   
457
    start = end + 1;
494
    start = end + 1;
458
    if (parse_argument(cmdline, len, &start, &end)) {
495
    if (parse_argument(cmdline, len, &start, &end)) {
459
        printf("Too many arguments.\n");
496
        printf("Too many arguments.\n");
460
        spinlock_unlock(&cmd->lock);
497
        spinlock_unlock(&cmd->lock);
461
        return NULL;
498
        return NULL;
462
    }
499
    }
463
   
500
   
464
    spinlock_unlock(&cmd->lock);
501
    spinlock_unlock(&cmd->lock);
465
    return cmd;
502
    return cmd;
466
}
503
}
467
 
504
 
468
/** Parse argument.
505
/** Parse argument.
469
 *
506
 *
470
 * Find start and end positions of command line argument.
507
 * Find start and end positions of command line argument.
471
 *
508
 *
472
 * @param cmdline Command line as read from the input device.
509
 * @param cmdline Command line as read from the input device.
473
 * @param len Number of characters in cmdline.
510
 * @param len Number of characters in cmdline.
474
 * @param start On entry, 'start' contains pointer to the index
511
 * @param start On entry, 'start' contains pointer to the index
475
 *        of first unprocessed character of cmdline.
512
 *        of first unprocessed character of cmdline.
476
 *        On successful exit, it marks beginning of the next argument.
513
 *        On successful exit, it marks beginning of the next argument.
477
 * @param end Undefined on entry. On exit, 'end' points to the last character
514
 * @param end Undefined on entry. On exit, 'end' points to the last character
478
 *        of the next argument.
515
 *        of the next argument.
479
 *
516
 *
480
 * @return false on failure, true on success.
517
 * @return false on failure, true on success.
481
 */
518
 */
482
bool parse_argument(char *cmdline, size_t len, index_t *start, index_t *end)
519
bool parse_argument(char *cmdline, size_t len, index_t *start, index_t *end)
483
{
520
{
484
    int i;
521
    int i;
485
    bool found_start = false;
522
    bool found_start = false;
486
   
523
   
487
    ASSERT(start != NULL);
524
    ASSERT(start != NULL);
488
    ASSERT(end != NULL);
525
    ASSERT(end != NULL);
489
   
526
   
490
    for (i = *start; i < len; i++) {
527
    for (i = *start; i < len; i++) {
491
        if (!found_start) {
528
        if (!found_start) {
492
            if (is_white(cmdline[i]))
529
            if (is_white(cmdline[i]))
493
                (*start)++;
530
                (*start)++;
494
            else
531
            else
495
                found_start = true;
532
                found_start = true;
496
        } else {
533
        } else {
497
            if (is_white(cmdline[i]))
534
            if (is_white(cmdline[i]))
498
                break;
535
                break;
499
        }
536
        }
500
    }
537
    }
501
    *end = i - 1;
538
    *end = i - 1;
502
 
539
 
503
    return found_start;
540
    return found_start;
504
}
541
}
505
 
542
 
506
 
543
 
507
/** List supported commands.
544
/** List supported commands.
508
 *
545
 *
509
 * @param argv Argument vector.
546
 * @param argv Argument vector.
510
 *
547
 *
511
 * @return 0 on failure, 1 on success.
548
 * @return 0 on failure, 1 on success.
512
 */
549
 */
513
int cmd_help(cmd_arg_t *argv)
550
int cmd_help(cmd_arg_t *argv)
514
{
551
{
515
    link_t *cur;
552
    link_t *cur;
516
    ipl_t ipl;
553
    ipl_t ipl;
517
 
554
 
518
    spinlock_lock(&cmd_lock);
555
    spinlock_lock(&cmd_lock);
519
   
556
   
520
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
557
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
521
        cmd_info_t *hlp;
558
        cmd_info_t *hlp;
522
       
559
       
523
        hlp = list_get_instance(cur, cmd_info_t, link);
560
        hlp = list_get_instance(cur, cmd_info_t, link);
524
        spinlock_lock(&hlp->lock);
561
        spinlock_lock(&hlp->lock);
525
       
562
       
526
        printf("%s - %s\n", hlp->name, hlp->description);
563
        printf("%s - %s\n", hlp->name, hlp->description);
527
 
564
 
528
        spinlock_unlock(&hlp->lock);
565
        spinlock_unlock(&hlp->lock);
529
    }
566
    }
530
   
567
   
531
    spinlock_unlock(&cmd_lock);
568
    spinlock_unlock(&cmd_lock);
532
 
569
 
533
    return 1;
570
    return 1;
534
}
571
}
535
 
572
 
536
/** Describe specified command.
573
/** Describe specified command.
537
 *
574
 *
538
 * @param argv Argument vector.
575
 * @param argv Argument vector.
539
 *
576
 *
540
 * @return 0 on failure, 1 on success.
577
 * @return 0 on failure, 1 on success.
541
 */
578
 */
542
int cmd_desc(cmd_arg_t *argv)
579
int cmd_desc(cmd_arg_t *argv)
543
{
580
{
544
    link_t *cur;
581
    link_t *cur;
545
    ipl_t ipl;
582
    ipl_t ipl;
546
 
583
 
547
    spinlock_lock(&cmd_lock);
584
    spinlock_lock(&cmd_lock);
548
   
585
   
549
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
586
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
550
        cmd_info_t *hlp;
587
        cmd_info_t *hlp;
551
       
588
       
552
        hlp = list_get_instance(cur, cmd_info_t, link);
589
        hlp = list_get_instance(cur, cmd_info_t, link);
553
        spinlock_lock(&hlp->lock);
590
        spinlock_lock(&hlp->lock);
554
 
591
 
555
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
592
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
556
            printf("%s - %s\n", hlp->name, hlp->description);
593
            printf("%s - %s\n", hlp->name, hlp->description);
557
            if (hlp->help)
594
            if (hlp->help)
558
                hlp->help();
595
                hlp->help();
559
            spinlock_unlock(&hlp->lock);
596
            spinlock_unlock(&hlp->lock);
560
            break;
597
            break;
561
        }
598
        }
562
 
599
 
563
        spinlock_unlock(&hlp->lock);
600
        spinlock_unlock(&hlp->lock);
564
    }
601
    }
565
   
602
   
566
    spinlock_unlock(&cmd_lock);
603
    spinlock_unlock(&cmd_lock);
567
 
604
 
568
    return 1;
605
    return 1;
569
}
606
}
570
 
607
 
571
/** Search symbol table */
608
/** Search symbol table */
572
int cmd_symaddr(cmd_arg_t *argv)
609
int cmd_symaddr(cmd_arg_t *argv)
573
{
610
{
574
    __address symaddr;
611
    __address symaddr;
575
    char *symbol;
612
    char *symbol;
576
 
613
 
577
    symtab_print_search(argv->buffer);
614
    symtab_print_search(argv->buffer);
578
   
615
   
579
    return 1;
616
    return 1;
580
}
617
}
581
 
618
 
582
/** Call function with zero parameters */
619
/** Call function with zero parameters */
583
int cmd_call0(cmd_arg_t *argv)
620
int cmd_call0(cmd_arg_t *argv)
584
{
621
{
585
    __address symaddr;
622
    __address symaddr;
586
    char *symbol;
623
    char *symbol;
587
    __native (*f)(void);
624
    __native (*f)(void);
588
 
625
 
589
    symaddr = get_symbol_addr(argv->buffer);
626
    symaddr = get_symbol_addr(argv->buffer);
590
    if (!symaddr)
627
    if (!symaddr)
591
        printf("Symbol %s not found.\n", argv->buffer);
628
        printf("Symbol %s not found.\n", argv->buffer);
592
    else if (symaddr == (__address) -1) {
629
    else if (symaddr == (__address) -1) {
593
        symtab_print_search(argv->buffer);
630
        symtab_print_search(argv->buffer);
594
        printf("Duplicate symbol, be more specific.\n");
631
        printf("Duplicate symbol, be more specific.\n");
595
    } else {
632
    } else {
596
        symbol = get_symtab_entry(symaddr);
633
        symbol = get_symtab_entry(symaddr);
597
        printf("Calling f(): 0x%p: %s\n", symaddr, symbol);
634
        printf("Calling f(): 0x%p: %s\n", symaddr, symbol);
598
        f =  (__native (*)(void)) symaddr;
635
        f =  (__native (*)(void)) symaddr;
599
        printf("Result: 0x%X\n", f());
636
        printf("Result: 0x%X\n", f());
600
    }
637
    }
601
   
638
   
602
    return 1;
639
    return 1;
603
}
640
}
604
 
641
 
605
/** Call function with one parameter */
642
/** Call function with one parameter */
606
int cmd_call1(cmd_arg_t *argv)
643
int cmd_call1(cmd_arg_t *argv)
607
{
644
{
608
    __address symaddr;
645
    __address symaddr;
609
    char *symbol;
646
    char *symbol;
610
    __native (*f)(__native);
647
    __native (*f)(__native);
611
    __native arg1 = argv[1].intval;
648
    __native arg1 = argv[1].intval;
612
 
649
 
613
    symaddr = get_symbol_addr(argv->buffer);
650
    symaddr = get_symbol_addr(argv->buffer);
614
    if (!symaddr)
651
    if (!symaddr)
615
        printf("Symbol %s not found.\n", argv->buffer);
652
        printf("Symbol %s not found.\n", argv->buffer);
616
    else if (symaddr == (__address) -1) {
653
    else if (symaddr == (__address) -1) {
617
        symtab_print_search(argv->buffer);
654
        symtab_print_search(argv->buffer);
618
        printf("Duplicate symbol, be more specific.\n");
655
        printf("Duplicate symbol, be more specific.\n");
619
    } else {
656
    } else {
620
        symbol = get_symtab_entry(symaddr);
657
        symbol = get_symtab_entry(symaddr);
621
        printf("Calling f(0x%x): 0x%p: %s\n", arg1, symaddr, symbol);
658
        printf("Calling f(0x%x): 0x%p: %s\n", arg1, symaddr, symbol);
622
        f =  (__native (*)(__native)) symaddr;
659
        f =  (__native (*)(__native)) symaddr;
623
        printf("Result: 0x%x\n", f(arg1));
660
        printf("Result: 0x%x\n", f(arg1));
624
    }
661
    }
625
   
662
   
626
    return 1;
663
    return 1;
627
}
664
}
628
 
665
 
629
/** Call function with two parameters */
666
/** Call function with two parameters */
630
int cmd_call2(cmd_arg_t *argv)
667
int cmd_call2(cmd_arg_t *argv)
631
{
668
{
632
    __address symaddr;
669
    __address symaddr;
633
    char *symbol;
670
    char *symbol;
634
    __native (*f)(__native,__native);
671
    __native (*f)(__native,__native);
635
    __native arg1 = argv[1].intval;
672
    __native arg1 = argv[1].intval;
636
    __native arg2 = argv[2].intval;
673
    __native arg2 = argv[2].intval;
637
 
674
 
638
    symaddr = get_symbol_addr(argv->buffer);
675
    symaddr = get_symbol_addr(argv->buffer);
639
    if (!symaddr)
676
    if (!symaddr)
640
        printf("Symbol %s not found.\n", argv->buffer);
677
        printf("Symbol %s not found.\n", argv->buffer);
641
    else if (symaddr == (__address) -1) {
678
    else if (symaddr == (__address) -1) {
642
        symtab_print_search(argv->buffer);
679
        symtab_print_search(argv->buffer);
643
        printf("Duplicate symbol, be more specific.\n");
680
        printf("Duplicate symbol, be more specific.\n");
644
    } else {
681
    } else {
645
        symbol = get_symtab_entry(symaddr);
682
        symbol = get_symtab_entry(symaddr);
646
        printf("Calling f(0x%x,0x%x): 0x%p: %s\n",
683
        printf("Calling f(0x%x,0x%x): 0x%p: %s\n",
647
               arg1, arg2, symaddr, symbol);
684
               arg1, arg2, symaddr, symbol);
648
        f =  (__native (*)(__native,__native)) symaddr;
685
        f =  (__native (*)(__native,__native)) symaddr;
649
        printf("Result: 0x%x\n", f(arg1, arg2));
686
        printf("Result: 0x%x\n", f(arg1, arg2));
650
    }
687
    }
-
 
688
   
-
 
689
    return 1;
-
 
690
}
-
 
691
 
-
 
692
/** Call function with three parameters */
-
 
693
int cmd_call3(cmd_arg_t *argv)
-
 
694
{
-
 
695
    __address symaddr;
-
 
696
    char *symbol;
-
 
697
    __native (*f)(__native,__native,__native);
-
 
698
    __native arg1 = argv[1].intval;
-
 
699
    __native arg2 = argv[2].intval;
-
 
700
    __native arg3 = argv[3].intval;
-
 
701
 
-
 
702
    symaddr = get_symbol_addr(argv->buffer);
-
 
703
    if (!symaddr)
-
 
704
        printf("Symbol %s not found.\n", argv->buffer);
-
 
705
    else if (symaddr == (__address) -1) {
-
 
706
        symtab_print_search(argv->buffer);
-
 
707
        printf("Duplicate symbol, be more specific.\n");
-
 
708
    } else {
-
 
709
        symbol = get_symtab_entry(symaddr);
-
 
710
        printf("Calling f(0x%x,0x%x, 0x%x): 0x%p: %s\n",
-
 
711
               arg1, arg2, arg3, symaddr, symbol);
-
 
712
        f =  (__native (*)(__native,__native,__native)) symaddr;
-
 
713
        printf("Result: 0x%x\n", f(arg1, arg2, arg3));
-
 
714
    }
651
   
715
   
652
    return 1;
716
    return 1;
653
}
717
}
654
 
718
 
655
 
719
 
656
/** Print detailed description of 'describe' command. */
720
/** Print detailed description of 'describe' command. */
657
void desc_help(void)
721
void desc_help(void)
658
{
722
{
659
    printf("Syntax: describe command_name\n");
723
    printf("Syntax: describe command_name\n");
660
}
724
}
661
 
725
 
662
/** Halt the kernel.
726
/** Halt the kernel.
663
 *
727
 *
664
 * @param argv Argument vector (ignored).
728
 * @param argv Argument vector (ignored).
665
 *
729
 *
666
 * @return 0 on failure, 1 on success (never returns).
730
 * @return 0 on failure, 1 on success (never returns).
667
 */
731
 */
668
int cmd_halt(cmd_arg_t *argv)
732
int cmd_halt(cmd_arg_t *argv)
669
{
733
{
670
    halt();
734
    halt();
671
    return 1;
735
    return 1;
672
}
736
}
673
 
737