Subversion Repositories HelenOS-historic

Rev

Rev 625 | Rev 673 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 625 Rev 668
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
/**
29
/**
30
 * This file is meant to contain all wrapper functions for
30
 * This file is meant to contain all wrapper functions for
31
 * all kconsole commands. The point is in separating
31
 * all kconsole commands. The point is in separating
32
 * kconsole specific wrappers from kconsole-unaware functions
32
 * kconsole specific wrappers from kconsole-unaware functions
33
 * from other subsystems.
33
 * from other subsystems.
34
 */
34
 */
35
 
35
 
36
#include <console/cmd.h>
36
#include <console/cmd.h>
37
#include <console/kconsole.h>
37
#include <console/kconsole.h>
38
#include <print.h>
38
#include <print.h>
39
#include <panic.h>
39
#include <panic.h>
40
#include <typedefs.h>
40
#include <typedefs.h>
41
#include <arch/types.h>
41
#include <arch/types.h>
42
#include <list.h>
42
#include <list.h>
43
#include <arch.h>
43
#include <arch.h>
44
#include <func.h>
44
#include <func.h>
45
#include <macros.h>
45
#include <macros.h>
46
#include <debug.h>
46
#include <debug.h>
47
#include <symtab.h>
47
#include <symtab.h>
48
 
48
 
49
#include <mm/tlb.h>
49
#include <mm/tlb.h>
50
#include <arch/mm/tlb.h>
50
#include <arch/mm/tlb.h>
-
 
51
#include <mm/frame.h>
51
 
52
 
52
/** Data and methods for 'help' command. */
53
/** Data and methods for 'help' command. */
53
static int cmd_help(cmd_arg_t *argv);
54
static int cmd_help(cmd_arg_t *argv);
54
static cmd_info_t help_info = {
55
static cmd_info_t help_info = {
55
    .name = "help",
56
    .name = "help",
56
    .description = "List of supported commands.",
57
    .description = "List of supported commands.",
57
    .func = cmd_help,
58
    .func = cmd_help,
58
    .argc = 0
59
    .argc = 0
59
};
60
};
60
 
61
 
61
static cmd_info_t exit_info = {
62
static cmd_info_t exit_info = {
62
    .name = "exit",
63
    .name = "exit",
63
    .description ="Exit kconsole",
64
    .description ="Exit kconsole",
64
    .argc = 0
65
    .argc = 0
65
};
66
};
66
 
67
 
67
/** Data and methods for 'description' command. */
68
/** Data and methods for 'description' command. */
68
static int cmd_desc(cmd_arg_t *argv);
69
static int cmd_desc(cmd_arg_t *argv);
69
static void desc_help(void);
70
static void desc_help(void);
70
static char desc_buf[MAX_CMDLINE+1];
71
static char desc_buf[MAX_CMDLINE+1];
71
static cmd_arg_t desc_argv = {
72
static cmd_arg_t desc_argv = {
72
    .type = ARG_TYPE_STRING,
73
    .type = ARG_TYPE_STRING,
73
    .buffer = desc_buf,
74
    .buffer = desc_buf,
74
    .len = sizeof(desc_buf)
75
    .len = sizeof(desc_buf)
75
};
76
};
76
static cmd_info_t desc_info = {
77
static cmd_info_t desc_info = {
77
    .name = "describe",
78
    .name = "describe",
78
    .description = "Describe specified command.",
79
    .description = "Describe specified command.",
79
    .help = desc_help,
80
    .help = desc_help,
80
    .func = cmd_desc,
81
    .func = cmd_desc,
81
    .argc = 1,
82
    .argc = 1,
82
    .argv = &desc_argv
83
    .argv = &desc_argv
83
};
84
};
84
 
85
 
85
/** Data and methods for 'symaddr' command. */
86
/** Data and methods for 'symaddr' command. */
86
static int cmd_symaddr(cmd_arg_t *argv);
87
static int cmd_symaddr(cmd_arg_t *argv);
87
static char symaddr_buf[MAX_CMDLINE+1];
88
static char symaddr_buf[MAX_CMDLINE+1];
88
static cmd_arg_t symaddr_argv = {
89
static cmd_arg_t symaddr_argv = {
89
    .type = ARG_TYPE_STRING,
90
    .type = ARG_TYPE_STRING,
90
    .buffer = symaddr_buf,
91
    .buffer = symaddr_buf,
91
    .len = sizeof(symaddr_buf)
92
    .len = sizeof(symaddr_buf)
92
};
93
};
93
static cmd_info_t symaddr_info = {
94
static cmd_info_t symaddr_info = {
94
    .name = "symaddr",
95
    .name = "symaddr",
95
    .description = "Return symbol address.",
96
    .description = "Return symbol address.",
96
    .func = cmd_symaddr,
97
    .func = cmd_symaddr,
97
    .argc = 1,
98
    .argc = 1,
98
    .argv = &symaddr_argv
99
    .argv = &symaddr_argv
99
};
100
};
100
 
101
 
101
static char set_buf[MAX_CMDLINE+1];
102
static char set_buf[MAX_CMDLINE+1];
102
static int cmd_set4(cmd_arg_t *argv);
103
static int cmd_set4(cmd_arg_t *argv);
103
static cmd_arg_t set4_argv[] = {
104
static cmd_arg_t set4_argv[] = {
104
    {
105
    {
105
        .type = ARG_TYPE_STRING,
106
        .type = ARG_TYPE_STRING,
106
        .buffer = set_buf,
107
        .buffer = set_buf,
107
        .len = sizeof(set_buf)
108
        .len = sizeof(set_buf)
108
    },
109
    },
109
    {
110
    {
110
        .type = ARG_TYPE_INT
111
        .type = ARG_TYPE_INT
111
    }
112
    }
112
};
113
};
113
static cmd_info_t set4_info = {
114
static cmd_info_t set4_info = {
114
    .name = "set4",
115
    .name = "set4",
115
    .description = "set <dest_addr> <value> - 4byte version",
116
    .description = "set <dest_addr> <value> - 4byte version",
116
    .func = cmd_set4,
117
    .func = cmd_set4,
117
    .argc = 2,
118
    .argc = 2,
118
    .argv = set4_argv
119
    .argv = set4_argv
119
};
120
};
120
 
121
 
121
 
122
 
-
 
123
 
122
/** Data and methods for 'call0' command. */
124
/** Data and methods for 'call0' command. */
123
static char call0_buf[MAX_CMDLINE+1];
125
static char call0_buf[MAX_CMDLINE+1];
124
static char carg1_buf[MAX_CMDLINE+1];
126
static char carg1_buf[MAX_CMDLINE+1];
125
static char carg2_buf[MAX_CMDLINE+1];
127
static char carg2_buf[MAX_CMDLINE+1];
126
static char carg3_buf[MAX_CMDLINE+1];
128
static char carg3_buf[MAX_CMDLINE+1];
127
 
129
 
128
static int cmd_call0(cmd_arg_t *argv);
130
static int cmd_call0(cmd_arg_t *argv);
129
static cmd_arg_t call0_argv = {
131
static cmd_arg_t call0_argv = {
130
    .type = ARG_TYPE_STRING,
132
    .type = ARG_TYPE_STRING,
131
    .buffer = call0_buf,
133
    .buffer = call0_buf,
132
    .len = sizeof(call0_buf)
134
    .len = sizeof(call0_buf)
133
};
135
};
134
static cmd_info_t call0_info = {
136
static cmd_info_t call0_info = {
135
    .name = "call0",
137
    .name = "call0",
136
    .description = "call0 <function> -> call function().",
138
    .description = "call0 <function> -> call function().",
137
    .func = cmd_call0,
139
    .func = cmd_call0,
138
    .argc = 1,
140
    .argc = 1,
139
    .argv = &call0_argv
141
    .argv = &call0_argv
140
};
142
};
141
 
143
 
142
/** Data and methods for 'call1' command. */
144
/** Data and methods for 'call1' command. */
143
static int cmd_call1(cmd_arg_t *argv);
145
static int cmd_call1(cmd_arg_t *argv);
144
static cmd_arg_t call1_argv[] = {
146
static cmd_arg_t call1_argv[] = {
145
    {
147
    {
146
        .type = ARG_TYPE_STRING,
148
        .type = ARG_TYPE_STRING,
147
        .buffer = call0_buf,
149
        .buffer = call0_buf,
148
        .len = sizeof(call0_buf)
150
        .len = sizeof(call0_buf)
149
    },
151
    },
150
    {
152
    {
151
        .type = ARG_TYPE_VAR,
153
        .type = ARG_TYPE_VAR,
152
        .buffer = carg1_buf,
154
        .buffer = carg1_buf,
153
        .len = sizeof(carg1_buf)
155
        .len = sizeof(carg1_buf)
154
    }
156
    }
155
};
157
};
156
static cmd_info_t call1_info = {
158
static cmd_info_t call1_info = {
157
    .name = "call1",
159
    .name = "call1",
158
    .description = "call1 <function> <arg1> -> call function(arg1).",
160
    .description = "call1 <function> <arg1> -> call function(arg1).",
159
    .func = cmd_call1,
161
    .func = cmd_call1,
160
    .argc = 2,
162
    .argc = 2,
161
    .argv = call1_argv
163
    .argv = call1_argv
162
};
164
};
163
 
165
 
164
/** Data and methods for 'call2' command. */
166
/** Data and methods for 'call2' command. */
165
static int cmd_call2(cmd_arg_t *argv);
167
static int cmd_call2(cmd_arg_t *argv);
166
static cmd_arg_t call2_argv[] = {
168
static cmd_arg_t call2_argv[] = {
167
    {
169
    {
168
        .type = ARG_TYPE_STRING,
170
        .type = ARG_TYPE_STRING,
169
        .buffer = call0_buf,
171
        .buffer = call0_buf,
170
        .len = sizeof(call0_buf)
172
        .len = sizeof(call0_buf)
171
    },
173
    },
172
    {
174
    {
173
        .type = ARG_TYPE_VAR,
175
        .type = ARG_TYPE_VAR,
174
        .buffer = carg1_buf,
176
        .buffer = carg1_buf,
175
        .len = sizeof(carg1_buf)
177
        .len = sizeof(carg1_buf)
176
    },
178
    },
177
    {
179
    {
178
        .type = ARG_TYPE_VAR,
180
        .type = ARG_TYPE_VAR,
179
        .buffer = carg2_buf,
181
        .buffer = carg2_buf,
180
        .len = sizeof(carg2_buf)
182
        .len = sizeof(carg2_buf)
181
    }
183
    }
182
};
184
};
183
static cmd_info_t call2_info = {
185
static cmd_info_t call2_info = {
184
    .name = "call2",
186
    .name = "call2",
185
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
187
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
186
    .func = cmd_call2,
188
    .func = cmd_call2,
187
    .argc = 3,
189
    .argc = 3,
188
    .argv = call2_argv
190
    .argv = call2_argv
189
};
191
};
190
 
192
 
191
/** Data and methods for 'call3' command. */
193
/** Data and methods for 'call3' command. */
192
static int cmd_call3(cmd_arg_t *argv);
194
static int cmd_call3(cmd_arg_t *argv);
193
static cmd_arg_t call3_argv[] = {
195
static cmd_arg_t call3_argv[] = {
194
    {
196
    {
195
        .type = ARG_TYPE_STRING,
197
        .type = ARG_TYPE_STRING,
196
        .buffer = call0_buf,
198
        .buffer = call0_buf,
197
        .len = sizeof(call0_buf)
199
        .len = sizeof(call0_buf)
198
    },
200
    },
199
    {
201
    {
200
        .type = ARG_TYPE_VAR,
202
        .type = ARG_TYPE_VAR,
201
        .buffer = carg1_buf,
203
        .buffer = carg1_buf,
202
        .len = sizeof(carg1_buf)
204
        .len = sizeof(carg1_buf)
203
    },
205
    },
204
    {
206
    {
205
        .type = ARG_TYPE_VAR,
207
        .type = ARG_TYPE_VAR,
206
        .buffer = carg2_buf,
208
        .buffer = carg2_buf,
207
        .len = sizeof(carg2_buf)
209
        .len = sizeof(carg2_buf)
208
    },
210
    },
209
    {
211
    {
210
        .type = ARG_TYPE_VAR,
212
        .type = ARG_TYPE_VAR,
211
        .buffer = carg3_buf,
213
        .buffer = carg3_buf,
212
        .len = sizeof(carg3_buf)
214
        .len = sizeof(carg3_buf)
213
    }
215
    }
214
 
216
 
215
};
217
};
216
static cmd_info_t call3_info = {
218
static cmd_info_t call3_info = {
217
    .name = "call3",
219
    .name = "call3",
218
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
220
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
219
    .func = cmd_call3,
221
    .func = cmd_call3,
220
    .argc = 4,
222
    .argc = 4,
221
    .argv = call3_argv
223
    .argv = call3_argv
222
};
224
};
223
 
225
 
224
/** Data and methods for 'halt' command. */
226
/** Data and methods for 'halt' command. */
225
static int cmd_halt(cmd_arg_t *argv);
227
static int cmd_halt(cmd_arg_t *argv);
226
static cmd_info_t halt_info = {
228
static cmd_info_t halt_info = {
227
    .name = "halt",
229
    .name = "halt",
228
    .description = "Halt the kernel.",
230
    .description = "Halt the kernel.",
229
    .func = cmd_halt,
231
    .func = cmd_halt,
230
    .argc = 0
232
    .argc = 0
231
};
233
};
232
 
234
 
233
/** Data and methods for 'ptlb' command. */
235
/** Data and methods for 'ptlb' command. */
234
static int cmd_ptlb(cmd_arg_t *argv);
236
static int cmd_ptlb(cmd_arg_t *argv);
235
cmd_info_t ptlb_info = {
237
cmd_info_t ptlb_info = {
236
    .name = "ptlb",
238
    .name = "ptlb",
237
    .description = "Print TLB of current processor.",
239
    .description = "Print TLB of current processor.",
238
    .help = NULL,
240
    .help = NULL,
239
    .func = cmd_ptlb,
241
    .func = cmd_ptlb,
240
    .argc = 0,
242
    .argc = 0,
241
    .argv = NULL
243
    .argv = NULL
242
};
244
};
243
 
245
 
-
 
246
 
-
 
247
/** Data and methods for 'zones' command */
-
 
248
static int cmd_zones(cmd_arg_t *argv);
-
 
249
static cmd_info_t zones_info = {
-
 
250
    .name = "zones",
-
 
251
    .description = "List of memory zones.",
-
 
252
    .func = cmd_zones,
-
 
253
    .argc = 0
-
 
254
};
-
 
255
 
-
 
256
/** Data and methods for 'zone' command */
-
 
257
static int cmd_zone(cmd_arg_t *argv);
-
 
258
static char zone_buf[MAX_CMDLINE+1];
-
 
259
static cmd_arg_t zone_argv = {
-
 
260
    .type = ARG_TYPE_INT,
-
 
261
    .buffer = zone_buf,
-
 
262
    .len = sizeof(zone_buf)
-
 
263
};
-
 
264
 
-
 
265
 
-
 
266
static cmd_info_t zone_info = {
-
 
267
    .name = "zone",
-
 
268
    .description = "Show memory zone structure.",
-
 
269
    .func = cmd_zone,
-
 
270
    .argc = 1,
-
 
271
    .argv = &zone_argv
-
 
272
};
-
 
273
 
-
 
274
 
-
 
275
 
244
/** Initialize command info structure.
276
/** Initialize command info structure.
245
 *
277
 *
246
 * @param cmd Command info structure.
278
 * @param cmd Command info structure.
247
 *
279
 *
248
 */
280
 */
249
void cmd_initialize(cmd_info_t *cmd)
281
void cmd_initialize(cmd_info_t *cmd)
250
{
282
{
251
    spinlock_initialize(&cmd->lock, "cmd");
283
    spinlock_initialize(&cmd->lock, "cmd");
252
    link_initialize(&cmd->link);
284
    link_initialize(&cmd->link);
253
}
285
}
254
 
286
 
255
/** Initialize and register commands. */
287
/** Initialize and register commands. */
256
void cmd_init(void)
288
void cmd_init(void)
257
{
289
{
258
    cmd_initialize(&help_info);
290
    cmd_initialize(&help_info);
259
    if (!cmd_register(&help_info))
291
    if (!cmd_register(&help_info))
260
        panic("could not register command %s\n", help_info.name);
292
        panic("could not register command %s\n", help_info.name);
261
 
293
 
262
    cmd_initialize(&desc_info);
294
    cmd_initialize(&desc_info);
263
    if (!cmd_register(&desc_info))
295
    if (!cmd_register(&desc_info))
264
        panic("could not register command %s\n", desc_info.name);
296
        panic("could not register command %s\n", desc_info.name);
265
 
297
 
266
    cmd_initialize(&exit_info);
298
    cmd_initialize(&exit_info);
267
    if (!cmd_register(&exit_info))
299
    if (!cmd_register(&exit_info))
268
        panic("could not register command %s\n", exit_info.name);
300
        panic("could not register command %s\n", exit_info.name);
269
   
301
   
270
    cmd_initialize(&symaddr_info);
302
    cmd_initialize(&symaddr_info);
271
    if (!cmd_register(&symaddr_info))
303
    if (!cmd_register(&symaddr_info))
272
        panic("could not register command %s\n", symaddr_info.name);
304
        panic("could not register command %s\n", symaddr_info.name);
273
 
305
 
274
    cmd_initialize(&call0_info);
306
    cmd_initialize(&call0_info);
275
    if (!cmd_register(&call0_info))
307
    if (!cmd_register(&call0_info))
276
        panic("could not register command %s\n", call0_info.name);
308
        panic("could not register command %s\n", call0_info.name);
277
 
309
 
278
    cmd_initialize(&call1_info);
310
    cmd_initialize(&call1_info);
279
    if (!cmd_register(&call1_info))
311
    if (!cmd_register(&call1_info))
280
        panic("could not register command %s\n", call1_info.name);
312
        panic("could not register command %s\n", call1_info.name);
281
 
313
 
282
    cmd_initialize(&call2_info);
314
    cmd_initialize(&call2_info);
283
    if (!cmd_register(&call2_info))
315
    if (!cmd_register(&call2_info))
284
        panic("could not register command %s\n", call2_info.name);
316
        panic("could not register command %s\n", call2_info.name);
285
 
317
 
286
    cmd_initialize(&call3_info);
318
    cmd_initialize(&call3_info);
287
    if (!cmd_register(&call3_info))
319
    if (!cmd_register(&call3_info))
288
        panic("could not register command %s\n", call3_info.name);
320
        panic("could not register command %s\n", call3_info.name);
289
 
321
 
290
    cmd_initialize(&set4_info);
322
    cmd_initialize(&set4_info);
291
    if (!cmd_register(&set4_info))
323
    if (!cmd_register(&set4_info))
292
        panic("could not register command %s\n", set4_info.name);
324
        panic("could not register command %s\n", set4_info.name);
293
   
325
   
294
    cmd_initialize(&halt_info);
326
    cmd_initialize(&halt_info);
295
    if (!cmd_register(&halt_info))
327
    if (!cmd_register(&halt_info))
296
        panic("could not register command %s\n", halt_info.name);
328
        panic("could not register command %s\n", halt_info.name);
297
 
329
 
298
    cmd_initialize(&ptlb_info);
330
    cmd_initialize(&ptlb_info);
299
    if (!cmd_register(&ptlb_info))
331
    if (!cmd_register(&ptlb_info))
300
        panic("could not register command %s\n", ptlb_info.name);
332
        panic("could not register command %s\n", ptlb_info.name);
-
 
333
 
-
 
334
    cmd_initialize(&zones_info);
-
 
335
    if (!cmd_register(&zones_info))
-
 
336
        panic("could not register command %s\n", zones_info.name);
-
 
337
 
-
 
338
    cmd_initialize(&zone_info);
-
 
339
    if (!cmd_register(&zone_info))
-
 
340
        panic("could not register command %s\n", zone_info.name);
-
 
341
 
-
 
342
 
301
}
343
}
302
 
344
 
303
 
345
 
304
/** List supported commands.
346
/** List supported commands.
305
 *
347
 *
306
 * @param argv Argument vector.
348
 * @param argv Argument vector.
307
 *
349
 *
308
 * @return 0 on failure, 1 on success.
350
 * @return 0 on failure, 1 on success.
309
 */
351
 */
310
int cmd_help(cmd_arg_t *argv)
352
int cmd_help(cmd_arg_t *argv)
311
{
353
{
312
    link_t *cur;
354
    link_t *cur;
313
 
355
 
314
    spinlock_lock(&cmd_lock);
356
    spinlock_lock(&cmd_lock);
315
   
357
   
316
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
358
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
317
        cmd_info_t *hlp;
359
        cmd_info_t *hlp;
318
       
360
       
319
        hlp = list_get_instance(cur, cmd_info_t, link);
361
        hlp = list_get_instance(cur, cmd_info_t, link);
320
        spinlock_lock(&hlp->lock);
362
        spinlock_lock(&hlp->lock);
321
       
363
       
322
        printf("%s - %s\n", hlp->name, hlp->description);
364
        printf("%s - %s\n", hlp->name, hlp->description);
323
 
365
 
324
        spinlock_unlock(&hlp->lock);
366
        spinlock_unlock(&hlp->lock);
325
    }
367
    }
326
   
368
   
327
    spinlock_unlock(&cmd_lock);
369
    spinlock_unlock(&cmd_lock);
328
 
370
 
329
    return 1;
371
    return 1;
330
}
372
}
331
 
373
 
332
/** Describe specified command.
374
/** Describe specified command.
333
 *
375
 *
334
 * @param argv Argument vector.
376
 * @param argv Argument vector.
335
 *
377
 *
336
 * @return 0 on failure, 1 on success.
378
 * @return 0 on failure, 1 on success.
337
 */
379
 */
338
int cmd_desc(cmd_arg_t *argv)
380
int cmd_desc(cmd_arg_t *argv)
339
{
381
{
340
    link_t *cur;
382
    link_t *cur;
341
 
383
 
342
    spinlock_lock(&cmd_lock);
384
    spinlock_lock(&cmd_lock);
343
   
385
   
344
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
386
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
345
        cmd_info_t *hlp;
387
        cmd_info_t *hlp;
346
       
388
       
347
        hlp = list_get_instance(cur, cmd_info_t, link);
389
        hlp = list_get_instance(cur, cmd_info_t, link);
348
        spinlock_lock(&hlp->lock);
390
        spinlock_lock(&hlp->lock);
349
 
391
 
350
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
392
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
351
            printf("%s - %s\n", hlp->name, hlp->description);
393
            printf("%s - %s\n", hlp->name, hlp->description);
352
            if (hlp->help)
394
            if (hlp->help)
353
                hlp->help();
395
                hlp->help();
354
            spinlock_unlock(&hlp->lock);
396
            spinlock_unlock(&hlp->lock);
355
            break;
397
            break;
356
        }
398
        }
357
 
399
 
358
        spinlock_unlock(&hlp->lock);
400
        spinlock_unlock(&hlp->lock);
359
    }
401
    }
360
   
402
   
361
    spinlock_unlock(&cmd_lock);
403
    spinlock_unlock(&cmd_lock);
362
 
404
 
363
    return 1;
405
    return 1;
364
}
406
}
365
 
407
 
366
/** Search symbol table */
408
/** Search symbol table */
367
int cmd_symaddr(cmd_arg_t *argv)
409
int cmd_symaddr(cmd_arg_t *argv)
368
{
410
{
369
    symtab_print_search(argv->buffer);
411
    symtab_print_search(argv->buffer);
370
   
412
   
371
    return 1;
413
    return 1;
372
}
414
}
373
 
415
 
374
/** Call function with zero parameters */
416
/** Call function with zero parameters */
375
int cmd_call0(cmd_arg_t *argv)
417
int cmd_call0(cmd_arg_t *argv)
376
{
418
{
377
    __address symaddr;
419
    __address symaddr;
378
    char *symbol;
420
    char *symbol;
379
    __native (*f)(void);
421
    __native (*f)(void);
380
 
422
 
381
    symaddr = get_symbol_addr(argv->buffer);
423
    symaddr = get_symbol_addr(argv->buffer);
382
    if (!symaddr)
424
    if (!symaddr)
383
        printf("Symbol %s not found.\n", argv->buffer);
425
        printf("Symbol %s not found.\n", argv->buffer);
384
    else if (symaddr == (__address) -1) {
426
    else if (symaddr == (__address) -1) {
385
        symtab_print_search(argv->buffer);
427
        symtab_print_search(argv->buffer);
386
        printf("Duplicate symbol, be more specific.\n");
428
        printf("Duplicate symbol, be more specific.\n");
387
    } else {
429
    } else {
388
        symbol = get_symtab_entry(symaddr);
430
        symbol = get_symtab_entry(symaddr);
389
        printf("Calling f(): 0x%p: %s\n", symaddr, symbol);
431
        printf("Calling f(): 0x%p: %s\n", symaddr, symbol);
390
        f =  (__native (*)(void)) symaddr;
432
        f =  (__native (*)(void)) symaddr;
391
        printf("Result: 0x%p\n", f());
433
        printf("Result: 0x%p\n", f());
392
    }
434
    }
393
   
435
   
394
    return 1;
436
    return 1;
395
}
437
}
396
 
438
 
397
/** Call function with one parameter */
439
/** Call function with one parameter */
398
int cmd_call1(cmd_arg_t *argv)
440
int cmd_call1(cmd_arg_t *argv)
399
{
441
{
400
    __address symaddr;
442
    __address symaddr;
401
    char *symbol;
443
    char *symbol;
402
    __native (*f)(__native);
444
    __native (*f)(__native);
403
    __native arg1 = argv[1].intval;
445
    __native arg1 = argv[1].intval;
404
 
446
 
405
    symaddr = get_symbol_addr(argv->buffer);
447
    symaddr = get_symbol_addr(argv->buffer);
406
    if (!symaddr)
448
    if (!symaddr)
407
        printf("Symbol %s not found.\n", argv->buffer);
449
        printf("Symbol %s not found.\n", argv->buffer);
408
    else if (symaddr == (__address) -1) {
450
    else if (symaddr == (__address) -1) {
409
        symtab_print_search(argv->buffer);
451
        symtab_print_search(argv->buffer);
410
        printf("Duplicate symbol, be more specific.\n");
452
        printf("Duplicate symbol, be more specific.\n");
411
    } else {
453
    } else {
412
        symbol = get_symtab_entry(symaddr);
454
        symbol = get_symtab_entry(symaddr);
413
        printf("Calling f(0x%x): 0x%p: %s\n", arg1, symaddr, symbol);
455
        printf("Calling f(0x%x): 0x%p: %s\n", arg1, symaddr, symbol);
414
        f =  (__native (*)(__native)) symaddr;
456
        f =  (__native (*)(__native)) symaddr;
415
        printf("Result: 0x%p\n", f(arg1));
457
        printf("Result: 0x%p\n", f(arg1));
416
    }
458
    }
417
   
459
   
418
    return 1;
460
    return 1;
419
}
461
}
420
 
462
 
421
/** Call function with two parameters */
463
/** Call function with two parameters */
422
int cmd_call2(cmd_arg_t *argv)
464
int cmd_call2(cmd_arg_t *argv)
423
{
465
{
424
    __address symaddr;
466
    __address symaddr;
425
    char *symbol;
467
    char *symbol;
426
    __native (*f)(__native,__native);
468
    __native (*f)(__native,__native);
427
    __native arg1 = argv[1].intval;
469
    __native arg1 = argv[1].intval;
428
    __native arg2 = argv[2].intval;
470
    __native arg2 = argv[2].intval;
429
 
471
 
430
    symaddr = get_symbol_addr(argv->buffer);
472
    symaddr = get_symbol_addr(argv->buffer);
431
    if (!symaddr)
473
    if (!symaddr)
432
        printf("Symbol %s not found.\n", argv->buffer);
474
        printf("Symbol %s not found.\n", argv->buffer);
433
    else if (symaddr == (__address) -1) {
475
    else if (symaddr == (__address) -1) {
434
        symtab_print_search(argv->buffer);
476
        symtab_print_search(argv->buffer);
435
        printf("Duplicate symbol, be more specific.\n");
477
        printf("Duplicate symbol, be more specific.\n");
436
    } else {
478
    } else {
437
        symbol = get_symtab_entry(symaddr);
479
        symbol = get_symtab_entry(symaddr);
438
        printf("Calling f(0x%x,0x%x): 0x%p: %s\n",
480
        printf("Calling f(0x%x,0x%x): 0x%p: %s\n",
439
               arg1, arg2, symaddr, symbol);
481
               arg1, arg2, symaddr, symbol);
440
        f =  (__native (*)(__native,__native)) symaddr;
482
        f =  (__native (*)(__native,__native)) symaddr;
441
        printf("Result: 0x%p\n", f(arg1, arg2));
483
        printf("Result: 0x%p\n", f(arg1, arg2));
442
    }
484
    }
443
   
485
   
444
    return 1;
486
    return 1;
445
}
487
}
446
 
488
 
447
/** Call function with three parameters */
489
/** Call function with three parameters */
448
int cmd_call3(cmd_arg_t *argv)
490
int cmd_call3(cmd_arg_t *argv)
449
{
491
{
450
    __address symaddr;
492
    __address symaddr;
451
    char *symbol;
493
    char *symbol;
452
    __native (*f)(__native,__native,__native);
494
    __native (*f)(__native,__native,__native);
453
    __native arg1 = argv[1].intval;
495
    __native arg1 = argv[1].intval;
454
    __native arg2 = argv[2].intval;
496
    __native arg2 = argv[2].intval;
455
    __native arg3 = argv[3].intval;
497
    __native arg3 = argv[3].intval;
456
 
498
 
457
    symaddr = get_symbol_addr(argv->buffer);
499
    symaddr = get_symbol_addr(argv->buffer);
458
    if (!symaddr)
500
    if (!symaddr)
459
        printf("Symbol %s not found.\n", argv->buffer);
501
        printf("Symbol %s not found.\n", argv->buffer);
460
    else if (symaddr == (__address) -1) {
502
    else if (symaddr == (__address) -1) {
461
        symtab_print_search(argv->buffer);
503
        symtab_print_search(argv->buffer);
462
        printf("Duplicate symbol, be more specific.\n");
504
        printf("Duplicate symbol, be more specific.\n");
463
    } else {
505
    } else {
464
        symbol = get_symtab_entry(symaddr);
506
        symbol = get_symtab_entry(symaddr);
465
        printf("Calling f(0x%x,0x%x, 0x%x): 0x%p: %s\n",
507
        printf("Calling f(0x%x,0x%x, 0x%x): 0x%p: %s\n",
466
               arg1, arg2, arg3, symaddr, symbol);
508
               arg1, arg2, arg3, symaddr, symbol);
467
        f =  (__native (*)(__native,__native,__native)) symaddr;
509
        f =  (__native (*)(__native,__native,__native)) symaddr;
468
        printf("Result: 0x%p\n", f(arg1, arg2, arg3));
510
        printf("Result: 0x%p\n", f(arg1, arg2, arg3));
469
    }
511
    }
470
   
512
   
471
    return 1;
513
    return 1;
472
}
514
}
473
 
515
 
474
 
516
 
475
/** Print detailed description of 'describe' command. */
517
/** Print detailed description of 'describe' command. */
476
void desc_help(void)
518
void desc_help(void)
477
{
519
{
478
    printf("Syntax: describe command_name\n");
520
    printf("Syntax: describe command_name\n");
479
}
521
}
480
 
522
 
481
/** Halt the kernel.
523
/** Halt the kernel.
482
 *
524
 *
483
 * @param argv Argument vector (ignored).
525
 * @param argv Argument vector (ignored).
484
 *
526
 *
485
 * @return 0 on failure, 1 on success (never returns).
527
 * @return 0 on failure, 1 on success (never returns).
486
 */
528
 */
487
int cmd_halt(cmd_arg_t *argv)
529
int cmd_halt(cmd_arg_t *argv)
488
{
530
{
489
    halt();
531
    halt();
490
    return 1;
532
    return 1;
491
}
533
}
492
 
534
 
493
/** Command for printing TLB contents.
535
/** Command for printing TLB contents.
494
 *
536
 *
495
 * @param argv Not used.
537
 * @param argv Not used.
496
 *
538
 *
497
 * @return Always returns 1.
539
 * @return Always returns 1.
498
 */
540
 */
499
int cmd_ptlb(cmd_arg_t *argv)
541
int cmd_ptlb(cmd_arg_t *argv)
500
{
542
{
501
    tlb_print();
543
    tlb_print();
502
    return 1;
544
    return 1;
503
}
545
}
504
 
546
 
505
/** Write 4 byte value to address */
547
/** Write 4 byte value to address */
506
int cmd_set4(cmd_arg_t *argv)
548
int cmd_set4(cmd_arg_t *argv)
507
{
549
{
508
    __u32 *addr ;
550
    __u32 *addr ;
509
    __u32 arg1 = argv[1].intval;
551
    __u32 arg1 = argv[1].intval;
510
    bool pointer = false;
552
    bool pointer = false;
511
 
553
 
512
    if (((char *)argv->buffer)[0] == '*') {
554
    if (((char *)argv->buffer)[0] == '*') {
513
        addr = (__u32 *) get_symbol_addr(argv->buffer+1);
555
        addr = (__u32 *) get_symbol_addr(argv->buffer+1);
514
        pointer = true;
556
        pointer = true;
515
    } else if (((char *)argv->buffer)[0] >= '0' &&
557
    } else if (((char *)argv->buffer)[0] >= '0' &&
516
           ((char *)argv->buffer)[0] <= '9')
558
           ((char *)argv->buffer)[0] <= '9')
517
        addr = (__u32 *)atoi((char *)argv->buffer);
559
        addr = (__u32 *)atoi((char *)argv->buffer);
518
    else
560
    else
519
        addr = (__u32 *)get_symbol_addr(argv->buffer);
561
        addr = (__u32 *)get_symbol_addr(argv->buffer);
520
 
562
 
521
    if (!addr)
563
    if (!addr)
522
        printf("Symbol %s not found.\n", argv->buffer);
564
        printf("Symbol %s not found.\n", argv->buffer);
523
    else if (addr == (__u32 *) -1) {
565
    else if (addr == (__u32 *) -1) {
524
        symtab_print_search(argv->buffer);
566
        symtab_print_search(argv->buffer);
525
        printf("Duplicate symbol, be more specific.\n");
567
        printf("Duplicate symbol, be more specific.\n");
526
    } else {
568
    } else {
527
        if (pointer)
569
        if (pointer)
528
            addr = (__u32 *)(*(__native *)addr);
570
            addr = (__u32 *)(*(__native *)addr);
529
        printf("Writing 0x%x -> 0x%p\n", arg1, addr);
571
        printf("Writing 0x%x -> 0x%p\n", arg1, addr);
530
        *addr = arg1;
572
        *addr = arg1;
531
       
573
       
532
    }
574
    }
533
   
575
   
534
    return 1;
576
    return 1;
535
}
577
}
-
 
578
 
-
 
579
 
-
 
580
int cmd_zones(cmd_arg_t * argv) {
-
 
581
    printf("Zones listing not implemented\n");
-
 
582
    return 1;
-
 
583
}
-
 
584
int cmd_zone(cmd_arg_t * argv) {
-
 
585
    printf("Zone details not implemented\n");
-
 
586
    return 1;
-
 
587
}
-
 
588
 
536
 
589