Subversion Repositories HelenOS-historic

Rev

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

Rev 1060 Rev 1072
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 <adt/list.h>
42
#include <adt/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
#include <cpu.h>
48
#include <cpu.h>
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
#include <mm/frame.h>
52
#include <main/version.h>
52
#include <main/version.h>
53
#include <mm/slab.h>
53
#include <mm/slab.h>
54
#include <proc/scheduler.h>
54
#include <proc/scheduler.h>
55
#include <proc/thread.h>
55
#include <proc/thread.h>
56
#include <proc/task.h>
56
#include <proc/task.h>
57
 
57
 
58
/** Data and methods for 'help' command. */
58
/** Data and methods for 'help' command. */
59
static int cmd_help(cmd_arg_t *argv);
59
static int cmd_help(cmd_arg_t *argv);
60
static cmd_info_t help_info = {
60
static cmd_info_t help_info = {
61
    .name = "help",
61
    .name = "help",
62
    .description = "List of supported commands.",
62
    .description = "List of supported commands.",
63
    .func = cmd_help,
63
    .func = cmd_help,
64
    .argc = 0
64
    .argc = 0
65
};
65
};
66
 
66
 
67
static cmd_info_t exit_info = {
67
static cmd_info_t exit_info = {
68
    .name = "exit",
68
    .name = "exit",
69
    .description ="Exit kconsole",
69
    .description ="Exit kconsole",
70
    .argc = 0
70
    .argc = 0
71
};
71
};
72
 
72
 
73
/** Data and methods for 'description' command. */
73
/** Data and methods for 'description' command. */
74
static int cmd_desc(cmd_arg_t *argv);
74
static int cmd_desc(cmd_arg_t *argv);
75
static void desc_help(void);
75
static void desc_help(void);
76
static char desc_buf[MAX_CMDLINE+1];
76
static char desc_buf[MAX_CMDLINE+1];
77
static cmd_arg_t desc_argv = {
77
static cmd_arg_t desc_argv = {
78
    .type = ARG_TYPE_STRING,
78
    .type = ARG_TYPE_STRING,
79
    .buffer = desc_buf,
79
    .buffer = desc_buf,
80
    .len = sizeof(desc_buf)
80
    .len = sizeof(desc_buf)
81
};
81
};
82
static cmd_info_t desc_info = {
82
static cmd_info_t desc_info = {
83
    .name = "describe",
83
    .name = "describe",
84
    .description = "Describe specified command.",
84
    .description = "Describe specified command.",
85
    .help = desc_help,
85
    .help = desc_help,
86
    .func = cmd_desc,
86
    .func = cmd_desc,
87
    .argc = 1,
87
    .argc = 1,
88
    .argv = &desc_argv
88
    .argv = &desc_argv
89
};
89
};
90
 
90
 
91
/** Data and methods for 'symaddr' command. */
91
/** Data and methods for 'symaddr' command. */
92
static int cmd_symaddr(cmd_arg_t *argv);
92
static int cmd_symaddr(cmd_arg_t *argv);
93
static char symaddr_buf[MAX_CMDLINE+1];
93
static char symaddr_buf[MAX_CMDLINE+1];
94
static cmd_arg_t symaddr_argv = {
94
static cmd_arg_t symaddr_argv = {
95
    .type = ARG_TYPE_STRING,
95
    .type = ARG_TYPE_STRING,
96
    .buffer = symaddr_buf,
96
    .buffer = symaddr_buf,
97
    .len = sizeof(symaddr_buf)
97
    .len = sizeof(symaddr_buf)
98
};
98
};
99
static cmd_info_t symaddr_info = {
99
static cmd_info_t symaddr_info = {
100
    .name = "symaddr",
100
    .name = "symaddr",
101
    .description = "Return symbol address.",
101
    .description = "Return symbol address.",
102
    .func = cmd_symaddr,
102
    .func = cmd_symaddr,
103
    .argc = 1,
103
    .argc = 1,
104
    .argv = &symaddr_argv
104
    .argv = &symaddr_argv
105
};
105
};
106
 
106
 
107
static char set_buf[MAX_CMDLINE+1];
107
static char set_buf[MAX_CMDLINE+1];
108
static int cmd_set4(cmd_arg_t *argv);
108
static int cmd_set4(cmd_arg_t *argv);
109
static cmd_arg_t set4_argv[] = {
109
static cmd_arg_t set4_argv[] = {
110
    {
110
    {
111
        .type = ARG_TYPE_STRING,
111
        .type = ARG_TYPE_STRING,
112
        .buffer = set_buf,
112
        .buffer = set_buf,
113
        .len = sizeof(set_buf)
113
        .len = sizeof(set_buf)
114
    },
114
    },
115
    {
115
    {
116
        .type = ARG_TYPE_INT
116
        .type = ARG_TYPE_INT
117
    }
117
    }
118
};
118
};
119
static cmd_info_t set4_info = {
119
static cmd_info_t set4_info = {
120
    .name = "set4",
120
    .name = "set4",
121
    .description = "set <dest_addr> <value> - 4byte version",
121
    .description = "set <dest_addr> <value> - 4byte version",
122
    .func = cmd_set4,
122
    .func = cmd_set4,
123
    .argc = 2,
123
    .argc = 2,
124
    .argv = set4_argv
124
    .argv = set4_argv
125
};
125
};
126
 
126
 
127
/** Data and methods for 'call0' command. */
127
/** Data and methods for 'call0' command. */
128
static char call0_buf[MAX_CMDLINE+1];
128
static char call0_buf[MAX_CMDLINE+1];
129
static char carg1_buf[MAX_CMDLINE+1];
129
static char carg1_buf[MAX_CMDLINE+1];
130
static char carg2_buf[MAX_CMDLINE+1];
130
static char carg2_buf[MAX_CMDLINE+1];
131
static char carg3_buf[MAX_CMDLINE+1];
131
static char carg3_buf[MAX_CMDLINE+1];
132
 
132
 
133
static int cmd_call0(cmd_arg_t *argv);
133
static int cmd_call0(cmd_arg_t *argv);
134
static cmd_arg_t call0_argv = {
134
static cmd_arg_t call0_argv = {
135
    .type = ARG_TYPE_STRING,
135
    .type = ARG_TYPE_STRING,
136
    .buffer = call0_buf,
136
    .buffer = call0_buf,
137
    .len = sizeof(call0_buf)
137
    .len = sizeof(call0_buf)
138
};
138
};
139
static cmd_info_t call0_info = {
139
static cmd_info_t call0_info = {
140
    .name = "call0",
140
    .name = "call0",
141
    .description = "call0 <function> -> call function().",
141
    .description = "call0 <function> -> call function().",
142
    .func = cmd_call0,
142
    .func = cmd_call0,
143
    .argc = 1,
143
    .argc = 1,
144
    .argv = &call0_argv
144
    .argv = &call0_argv
145
};
145
};
146
 
146
 
147
/** Data and methods for 'call1' command. */
147
/** Data and methods for 'call1' command. */
148
static int cmd_call1(cmd_arg_t *argv);
148
static int cmd_call1(cmd_arg_t *argv);
149
static cmd_arg_t call1_argv[] = {
149
static cmd_arg_t call1_argv[] = {
150
    {
150
    {
151
        .type = ARG_TYPE_STRING,
151
        .type = ARG_TYPE_STRING,
152
        .buffer = call0_buf,
152
        .buffer = call0_buf,
153
        .len = sizeof(call0_buf)
153
        .len = sizeof(call0_buf)
154
    },
154
    },
155
    {
155
    {
156
        .type = ARG_TYPE_VAR,
156
        .type = ARG_TYPE_VAR,
157
        .buffer = carg1_buf,
157
        .buffer = carg1_buf,
158
        .len = sizeof(carg1_buf)
158
        .len = sizeof(carg1_buf)
159
    }
159
    }
160
};
160
};
161
static cmd_info_t call1_info = {
161
static cmd_info_t call1_info = {
162
    .name = "call1",
162
    .name = "call1",
163
    .description = "call1 <function> <arg1> -> call function(arg1).",
163
    .description = "call1 <function> <arg1> -> call function(arg1).",
164
    .func = cmd_call1,
164
    .func = cmd_call1,
165
    .argc = 2,
165
    .argc = 2,
166
    .argv = call1_argv
166
    .argv = call1_argv
167
};
167
};
168
 
168
 
169
/** Data and methods for 'call2' command. */
169
/** Data and methods for 'call2' command. */
170
static int cmd_call2(cmd_arg_t *argv);
170
static int cmd_call2(cmd_arg_t *argv);
171
static cmd_arg_t call2_argv[] = {
171
static cmd_arg_t call2_argv[] = {
172
    {
172
    {
173
        .type = ARG_TYPE_STRING,
173
        .type = ARG_TYPE_STRING,
174
        .buffer = call0_buf,
174
        .buffer = call0_buf,
175
        .len = sizeof(call0_buf)
175
        .len = sizeof(call0_buf)
176
    },
176
    },
177
    {
177
    {
178
        .type = ARG_TYPE_VAR,
178
        .type = ARG_TYPE_VAR,
179
        .buffer = carg1_buf,
179
        .buffer = carg1_buf,
180
        .len = sizeof(carg1_buf)
180
        .len = sizeof(carg1_buf)
181
    },
181
    },
182
    {
182
    {
183
        .type = ARG_TYPE_VAR,
183
        .type = ARG_TYPE_VAR,
184
        .buffer = carg2_buf,
184
        .buffer = carg2_buf,
185
        .len = sizeof(carg2_buf)
185
        .len = sizeof(carg2_buf)
186
    }
186
    }
187
};
187
};
188
static cmd_info_t call2_info = {
188
static cmd_info_t call2_info = {
189
    .name = "call2",
189
    .name = "call2",
190
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
190
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
191
    .func = cmd_call2,
191
    .func = cmd_call2,
192
    .argc = 3,
192
    .argc = 3,
193
    .argv = call2_argv
193
    .argv = call2_argv
194
};
194
};
195
 
195
 
196
/** Data and methods for 'call3' command. */
196
/** Data and methods for 'call3' command. */
197
static int cmd_call3(cmd_arg_t *argv);
197
static int cmd_call3(cmd_arg_t *argv);
198
static cmd_arg_t call3_argv[] = {
198
static cmd_arg_t call3_argv[] = {
199
    {
199
    {
200
        .type = ARG_TYPE_STRING,
200
        .type = ARG_TYPE_STRING,
201
        .buffer = call0_buf,
201
        .buffer = call0_buf,
202
        .len = sizeof(call0_buf)
202
        .len = sizeof(call0_buf)
203
    },
203
    },
204
    {
204
    {
205
        .type = ARG_TYPE_VAR,
205
        .type = ARG_TYPE_VAR,
206
        .buffer = carg1_buf,
206
        .buffer = carg1_buf,
207
        .len = sizeof(carg1_buf)
207
        .len = sizeof(carg1_buf)
208
    },
208
    },
209
    {
209
    {
210
        .type = ARG_TYPE_VAR,
210
        .type = ARG_TYPE_VAR,
211
        .buffer = carg2_buf,
211
        .buffer = carg2_buf,
212
        .len = sizeof(carg2_buf)
212
        .len = sizeof(carg2_buf)
213
    },
213
    },
214
    {
214
    {
215
        .type = ARG_TYPE_VAR,
215
        .type = ARG_TYPE_VAR,
216
        .buffer = carg3_buf,
216
        .buffer = carg3_buf,
217
        .len = sizeof(carg3_buf)
217
        .len = sizeof(carg3_buf)
218
    }
218
    }
219
 
219
 
220
};
220
};
221
static cmd_info_t call3_info = {
221
static cmd_info_t call3_info = {
222
    .name = "call3",
222
    .name = "call3",
223
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
223
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
224
    .func = cmd_call3,
224
    .func = cmd_call3,
225
    .argc = 4,
225
    .argc = 4,
226
    .argv = call3_argv
226
    .argv = call3_argv
227
};
227
};
228
 
228
 
229
/** Data and methods for 'halt' command. */
229
/** Data and methods for 'halt' command. */
230
static int cmd_halt(cmd_arg_t *argv);
230
static int cmd_halt(cmd_arg_t *argv);
231
static cmd_info_t halt_info = {
231
static cmd_info_t halt_info = {
232
    .name = "halt",
232
    .name = "halt",
233
    .description = "Halt the kernel.",
233
    .description = "Halt the kernel.",
234
    .func = cmd_halt,
234
    .func = cmd_halt,
235
    .argc = 0
235
    .argc = 0
236
};
236
};
237
 
237
 
238
/** Data and methods for 'tlb' command. */
238
/** Data and methods for 'tlb' command. */
239
static int cmd_tlb(cmd_arg_t *argv);
239
static int cmd_tlb(cmd_arg_t *argv);
240
cmd_info_t tlb_info = {
240
cmd_info_t tlb_info = {
241
    .name = "tlb",
241
    .name = "tlb",
242
    .description = "Print TLB of current processor.",
242
    .description = "Print TLB of current processor.",
243
    .help = NULL,
243
    .help = NULL,
244
    .func = cmd_tlb,
244
    .func = cmd_tlb,
245
    .argc = 0,
245
    .argc = 0,
246
    .argv = NULL
246
    .argv = NULL
247
};
247
};
248
 
248
 
249
static int cmd_threads(cmd_arg_t *argv);
249
static int cmd_threads(cmd_arg_t *argv);
250
static cmd_info_t threads_info = {
250
static cmd_info_t threads_info = {
251
    .name = "threads",
251
    .name = "threads",
252
    .description = "List all threads",
252
    .description = "List all threads",
253
    .func = cmd_threads,
253
    .func = cmd_threads,
254
    .argc = 0
254
    .argc = 0
255
};
255
};
256
 
256
 
257
static int cmd_tasks(cmd_arg_t *argv);
257
static int cmd_tasks(cmd_arg_t *argv);
258
static cmd_info_t tasks_info = {
258
static cmd_info_t tasks_info = {
259
    .name = "tasks",
259
    .name = "tasks",
260
    .description = "List all tasks",
260
    .description = "List all tasks",
261
    .func = cmd_tasks,
261
    .func = cmd_tasks,
262
    .argc = 0
262
    .argc = 0
263
};
263
};
264
 
264
 
265
 
265
 
266
static int cmd_sched(cmd_arg_t *argv);
266
static int cmd_sched(cmd_arg_t *argv);
267
static cmd_info_t sched_info = {
267
static cmd_info_t sched_info = {
268
    .name = "scheduler",
268
    .name = "scheduler",
269
    .description = "List all scheduler information",
269
    .description = "List all scheduler information",
270
    .func = cmd_sched,
270
    .func = cmd_sched,
271
    .argc = 0
271
    .argc = 0
272
};
272
};
273
 
273
 
274
static int cmd_slabs(cmd_arg_t *argv);
274
static int cmd_slabs(cmd_arg_t *argv);
275
static cmd_info_t slabs_info = {
275
static cmd_info_t slabs_info = {
276
    .name = "slabs",
276
    .name = "slabs",
277
    .description = "List SLAB caches.",
277
    .description = "List SLAB caches.",
278
    .func = cmd_slabs,
278
    .func = cmd_slabs,
279
    .argc = 0
279
    .argc = 0
280
};
280
};
281
 
281
 
282
/** Data and methods for 'zones' command */
282
/** Data and methods for 'zones' command */
283
static int cmd_zones(cmd_arg_t *argv);
283
static int cmd_zones(cmd_arg_t *argv);
284
static cmd_info_t zones_info = {
284
static cmd_info_t zones_info = {
285
    .name = "zones",
285
    .name = "zones",
286
    .description = "List of memory zones.",
286
    .description = "List of memory zones.",
287
    .func = cmd_zones,
287
    .func = cmd_zones,
288
    .argc = 0
288
    .argc = 0
289
};
289
};
290
 
290
 
291
/** Data and methods for 'zone' command */
291
/** Data and methods for 'zone' command */
292
static int cmd_zone(cmd_arg_t *argv);
292
static int cmd_zone(cmd_arg_t *argv);
293
static cmd_arg_t zone_argv = {
293
static cmd_arg_t zone_argv = {
294
    .type = ARG_TYPE_INT,
294
    .type = ARG_TYPE_INT,
295
};
295
};
296
 
296
 
297
static cmd_info_t zone_info = {
297
static cmd_info_t zone_info = {
298
    .name = "zone",
298
    .name = "zone",
299
    .description = "Show memory zone structure.",
299
    .description = "Show memory zone structure.",
300
    .func = cmd_zone,
300
    .func = cmd_zone,
301
    .argc = 1,
301
    .argc = 1,
302
    .argv = &zone_argv
302
    .argv = &zone_argv
303
};
303
};
304
 
304
 
305
static int cmd_hello(cmd_arg_t *argv);
-
 
306
static cmd_info_t hello_info = {
-
 
307
    .name = "hello",
-
 
308
    .description = "Hello Message",
-
 
309
    .func = cmd_hello,
-
 
310
    .argc = 0
-
 
311
};
-
 
312
 
-
 
313
/** Data and methods for 'cpus' command. */
305
/** Data and methods for 'cpus' command. */
314
static int cmd_cpus(cmd_arg_t *argv);
306
static int cmd_cpus(cmd_arg_t *argv);
315
cmd_info_t cpus_info = {
307
cmd_info_t cpus_info = {
316
    .name = "cpus",
308
    .name = "cpus",
317
    .description = "List all processors.",
309
    .description = "List all processors.",
318
    .help = NULL,
310
    .help = NULL,
319
    .func = cmd_cpus,
311
    .func = cmd_cpus,
320
    .argc = 0,
312
    .argc = 0,
321
    .argv = NULL
313
    .argv = NULL
322
};
314
};
323
 
315
 
324
/** Data and methods for 'version' command. */
316
/** Data and methods for 'version' command. */
325
static int cmd_version(cmd_arg_t *argv);
317
static int cmd_version(cmd_arg_t *argv);
326
cmd_info_t version_info = {
318
cmd_info_t version_info = {
327
    .name = "version",
319
    .name = "version",
328
    .description = "Print version information.",
320
    .description = "Print version information.",
329
    .help = NULL,
321
    .help = NULL,
330
    .func = cmd_version,
322
    .func = cmd_version,
331
    .argc = 0,
323
    .argc = 0,
332
    .argv = NULL
324
    .argv = NULL
333
};
325
};
334
 
326
 
335
static cmd_info_t *basic_commands[] = {
327
static cmd_info_t *basic_commands[] = {
336
    &call0_info,
328
    &call0_info,
337
    &call1_info,
329
    &call1_info,
338
    &call2_info,
330
    &call2_info,
339
    &call3_info,
331
    &call3_info,
340
    &cpus_info,
332
    &cpus_info,
341
    &desc_info,
333
    &desc_info,
342
    &exit_info,
334
    &exit_info,
343
    &halt_info,
335
    &halt_info,
344
    &help_info,
336
    &help_info,
345
    &set4_info,
337
    &set4_info,
346
    &slabs_info,
338
    &slabs_info,
347
    &symaddr_info,
339
    &symaddr_info,
348
    &sched_info,
340
    &sched_info,
349
    &threads_info,
341
    &threads_info,
350
    &tasks_info,
342
    &tasks_info,
351
    &tlb_info,
343
    &tlb_info,
352
    &version_info,
344
    &version_info,
353
    &zones_info,
345
    &zones_info,
354
    &zone_info,
346
    &zone_info,
355
    &hello_info,
-
 
356
    NULL
347
    NULL
357
};
348
};
358
 
349
 
359
 
350
 
360
/** Initialize command info structure.
351
/** Initialize command info structure.
361
 *
352
 *
362
 * @param cmd Command info structure.
353
 * @param cmd Command info structure.
363
 *
354
 *
364
 */
355
 */
365
void cmd_initialize(cmd_info_t *cmd)
356
void cmd_initialize(cmd_info_t *cmd)
366
{
357
{
367
    spinlock_initialize(&cmd->lock, "cmd");
358
    spinlock_initialize(&cmd->lock, "cmd");
368
    link_initialize(&cmd->link);
359
    link_initialize(&cmd->link);
369
}
360
}
370
 
361
 
371
/** Initialize and register commands. */
362
/** Initialize and register commands. */
372
void cmd_init(void)
363
void cmd_init(void)
373
{
364
{
374
    int i;
365
    int i;
375
 
366
 
376
    for (i=0;basic_commands[i]; i++) {
367
    for (i=0;basic_commands[i]; i++) {
377
        cmd_initialize(basic_commands[i]);
368
        cmd_initialize(basic_commands[i]);
378
        if (!cmd_register(basic_commands[i]))
369
        if (!cmd_register(basic_commands[i]))
379
            panic("could not register command %s\n",
370
            panic("could not register command %s\n",
380
                  basic_commands[i]->name);
371
                  basic_commands[i]->name);
381
    }
372
    }
382
}
373
}
383
 
374
 
384
 
375
 
385
/** List supported commands.
376
/** List supported commands.
386
 *
377
 *
387
 * @param argv Argument vector.
378
 * @param argv Argument vector.
388
 *
379
 *
389
 * @return 0 on failure, 1 on success.
380
 * @return 0 on failure, 1 on success.
390
 */
381
 */
391
int cmd_help(cmd_arg_t *argv)
382
int cmd_help(cmd_arg_t *argv)
392
{
383
{
393
    link_t *cur;
384
    link_t *cur;
394
 
385
 
395
    spinlock_lock(&cmd_lock);
386
    spinlock_lock(&cmd_lock);
396
   
387
   
397
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
388
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
398
        cmd_info_t *hlp;
389
        cmd_info_t *hlp;
399
       
390
       
400
        hlp = list_get_instance(cur, cmd_info_t, link);
391
        hlp = list_get_instance(cur, cmd_info_t, link);
401
        spinlock_lock(&hlp->lock);
392
        spinlock_lock(&hlp->lock);
402
       
393
       
403
        printf("%s - %s\n", hlp->name, hlp->description);
394
        printf("%s - %s\n", hlp->name, hlp->description);
404
 
395
 
405
        spinlock_unlock(&hlp->lock);
396
        spinlock_unlock(&hlp->lock);
406
    }
397
    }
407
   
398
   
408
    spinlock_unlock(&cmd_lock);
399
    spinlock_unlock(&cmd_lock);
409
 
400
 
410
    return 1;
401
    return 1;
411
}
402
}
412
 
403
 
413
/** Describe specified command.
404
/** Describe specified command.
414
 *
405
 *
415
 * @param argv Argument vector.
406
 * @param argv Argument vector.
416
 *
407
 *
417
 * @return 0 on failure, 1 on success.
408
 * @return 0 on failure, 1 on success.
418
 */
409
 */
419
int cmd_desc(cmd_arg_t *argv)
410
int cmd_desc(cmd_arg_t *argv)
420
{
411
{
421
    link_t *cur;
412
    link_t *cur;
422
 
413
 
423
    spinlock_lock(&cmd_lock);
414
    spinlock_lock(&cmd_lock);
424
   
415
   
425
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
416
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
426
        cmd_info_t *hlp;
417
        cmd_info_t *hlp;
427
       
418
       
428
        hlp = list_get_instance(cur, cmd_info_t, link);
419
        hlp = list_get_instance(cur, cmd_info_t, link);
429
        spinlock_lock(&hlp->lock);
420
        spinlock_lock(&hlp->lock);
430
 
421
 
431
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
422
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
432
            printf("%s - %s\n", hlp->name, hlp->description);
423
            printf("%s - %s\n", hlp->name, hlp->description);
433
            if (hlp->help)
424
            if (hlp->help)
434
                hlp->help();
425
                hlp->help();
435
            spinlock_unlock(&hlp->lock);
426
            spinlock_unlock(&hlp->lock);
436
            break;
427
            break;
437
        }
428
        }
438
 
429
 
439
        spinlock_unlock(&hlp->lock);
430
        spinlock_unlock(&hlp->lock);
440
    }
431
    }
441
   
432
   
442
    spinlock_unlock(&cmd_lock);
433
    spinlock_unlock(&cmd_lock);
443
 
434
 
444
    return 1;
435
    return 1;
445
}
436
}
446
 
437
 
447
/** Search symbol table */
438
/** Search symbol table */
448
int cmd_symaddr(cmd_arg_t *argv)
439
int cmd_symaddr(cmd_arg_t *argv)
449
{
440
{
450
    symtab_print_search(argv->buffer);
441
    symtab_print_search(argv->buffer);
451
   
442
   
452
    return 1;
443
    return 1;
453
}
444
}
454
 
445
 
455
/** Call function with zero parameters */
446
/** Call function with zero parameters */
456
int cmd_call0(cmd_arg_t *argv)
447
int cmd_call0(cmd_arg_t *argv)
457
{
448
{
458
    __address symaddr;
449
    __address symaddr;
459
    char *symbol;
450
    char *symbol;
460
    __native (*f)(void);
451
    __native (*f)(void);
461
 
452
 
462
    symaddr = get_symbol_addr(argv->buffer);
453
    symaddr = get_symbol_addr(argv->buffer);
463
    if (!symaddr)
454
    if (!symaddr)
464
        printf("Symbol %s not found.\n", argv->buffer);
455
        printf("Symbol %s not found.\n", argv->buffer);
465
    else if (symaddr == (__address) -1) {
456
    else if (symaddr == (__address) -1) {
466
        symtab_print_search(argv->buffer);
457
        symtab_print_search(argv->buffer);
467
        printf("Duplicate symbol, be more specific.\n");
458
        printf("Duplicate symbol, be more specific.\n");
468
    } else {
459
    } else {
469
        symbol = get_symtab_entry(symaddr);
460
        symbol = get_symtab_entry(symaddr);
470
        printf("Calling f(): 0x%p: %s\n", symaddr, symbol);
461
        printf("Calling f(): 0x%p: %s\n", symaddr, symbol);
471
        f =  (__native (*)(void)) symaddr;
462
        f =  (__native (*)(void)) symaddr;
472
        printf("Result: 0x%p\n", f());
463
        printf("Result: 0x%p\n", f());
473
    }
464
    }
474
   
465
   
475
    return 1;
466
    return 1;
476
}
467
}
477
 
468
 
478
/** Call function with one parameter */
469
/** Call function with one parameter */
479
int cmd_call1(cmd_arg_t *argv)
470
int cmd_call1(cmd_arg_t *argv)
480
{
471
{
481
    __address symaddr;
472
    __address symaddr;
482
    char *symbol;
473
    char *symbol;
483
    __native (*f)(__native,...);
474
    __native (*f)(__native,...);
484
    __native arg1 = argv[1].intval;
475
    __native arg1 = argv[1].intval;
485
 
476
 
486
    symaddr = get_symbol_addr(argv->buffer);
477
    symaddr = get_symbol_addr(argv->buffer);
487
    if (!symaddr)
478
    if (!symaddr)
488
        printf("Symbol %s not found.\n", argv->buffer);
479
        printf("Symbol %s not found.\n", argv->buffer);
489
    else if (symaddr == (__address) -1) {
480
    else if (symaddr == (__address) -1) {
490
        symtab_print_search(argv->buffer);
481
        symtab_print_search(argv->buffer);
491
        printf("Duplicate symbol, be more specific.\n");
482
        printf("Duplicate symbol, be more specific.\n");
492
    } else {
483
    } else {
493
        symbol = get_symtab_entry(symaddr);
484
        symbol = get_symtab_entry(symaddr);
494
        printf("Calling f(0x%x): 0x%p: %s\n", arg1, symaddr, symbol);
485
        printf("Calling f(0x%x): 0x%p: %s\n", arg1, symaddr, symbol);
495
        f =  (__native (*)(__native,...)) symaddr;
486
        f =  (__native (*)(__native,...)) symaddr;
496
        printf("Result: 0x%p\n", f(arg1));
487
        printf("Result: 0x%p\n", f(arg1));
497
    }
488
    }
498
   
489
   
499
    return 1;
490
    return 1;
500
}
491
}
501
 
492
 
502
/** Call function with two parameters */
493
/** Call function with two parameters */
503
int cmd_call2(cmd_arg_t *argv)
494
int cmd_call2(cmd_arg_t *argv)
504
{
495
{
505
    __address symaddr;
496
    __address symaddr;
506
    char *symbol;
497
    char *symbol;
507
    __native (*f)(__native,__native,...);
498
    __native (*f)(__native,__native,...);
508
    __native arg1 = argv[1].intval;
499
    __native arg1 = argv[1].intval;
509
    __native arg2 = argv[2].intval;
500
    __native arg2 = argv[2].intval;
510
 
501
 
511
    symaddr = get_symbol_addr(argv->buffer);
502
    symaddr = get_symbol_addr(argv->buffer);
512
    if (!symaddr)
503
    if (!symaddr)
513
        printf("Symbol %s not found.\n", argv->buffer);
504
        printf("Symbol %s not found.\n", argv->buffer);
514
    else if (symaddr == (__address) -1) {
505
    else if (symaddr == (__address) -1) {
515
        symtab_print_search(argv->buffer);
506
        symtab_print_search(argv->buffer);
516
        printf("Duplicate symbol, be more specific.\n");
507
        printf("Duplicate symbol, be more specific.\n");
517
    } else {
508
    } else {
518
        symbol = get_symtab_entry(symaddr);
509
        symbol = get_symtab_entry(symaddr);
519
        printf("Calling f(0x%x,0x%x): 0x%p: %s\n",
510
        printf("Calling f(0x%x,0x%x): 0x%p: %s\n",
520
               arg1, arg2, symaddr, symbol);
511
               arg1, arg2, symaddr, symbol);
521
        f =  (__native (*)(__native,__native,...)) symaddr;
512
        f =  (__native (*)(__native,__native,...)) symaddr;
522
        printf("Result: 0x%p\n", f(arg1, arg2));
513
        printf("Result: 0x%p\n", f(arg1, arg2));
523
    }
514
    }
524
   
515
   
525
    return 1;
516
    return 1;
526
}
517
}
527
 
518
 
528
/** Call function with three parameters */
519
/** Call function with three parameters */
529
int cmd_call3(cmd_arg_t *argv)
520
int cmd_call3(cmd_arg_t *argv)
530
{
521
{
531
    __address symaddr;
522
    __address symaddr;
532
    char *symbol;
523
    char *symbol;
533
    __native (*f)(__native,__native,__native,...);
524
    __native (*f)(__native,__native,__native,...);
534
    __native arg1 = argv[1].intval;
525
    __native arg1 = argv[1].intval;
535
    __native arg2 = argv[2].intval;
526
    __native arg2 = argv[2].intval;
536
    __native arg3 = argv[3].intval;
527
    __native arg3 = argv[3].intval;
537
 
528
 
538
    symaddr = get_symbol_addr(argv->buffer);
529
    symaddr = get_symbol_addr(argv->buffer);
539
    if (!symaddr)
530
    if (!symaddr)
540
        printf("Symbol %s not found.\n", argv->buffer);
531
        printf("Symbol %s not found.\n", argv->buffer);
541
    else if (symaddr == (__address) -1) {
532
    else if (symaddr == (__address) -1) {
542
        symtab_print_search(argv->buffer);
533
        symtab_print_search(argv->buffer);
543
        printf("Duplicate symbol, be more specific.\n");
534
        printf("Duplicate symbol, be more specific.\n");
544
    } else {
535
    } else {
545
        symbol = get_symtab_entry(symaddr);
536
        symbol = get_symtab_entry(symaddr);
546
        printf("Calling f(0x%x,0x%x, 0x%x): 0x%p: %s\n",
537
        printf("Calling f(0x%x,0x%x, 0x%x): 0x%p: %s\n",
547
               arg1, arg2, arg3, symaddr, symbol);
538
               arg1, arg2, arg3, symaddr, symbol);
548
        f =  (__native (*)(__native,__native,__native,...)) symaddr;
539
        f =  (__native (*)(__native,__native,__native,...)) symaddr;
549
        printf("Result: 0x%p\n", f(arg1, arg2, arg3));
540
        printf("Result: 0x%p\n", f(arg1, arg2, arg3));
550
    }
541
    }
551
   
542
   
552
    return 1;
543
    return 1;
553
}
544
}
554
 
545
 
555
 
546
 
556
/** Print detailed description of 'describe' command. */
547
/** Print detailed description of 'describe' command. */
557
void desc_help(void)
548
void desc_help(void)
558
{
549
{
559
    printf("Syntax: describe command_name\n");
550
    printf("Syntax: describe command_name\n");
560
}
551
}
561
 
552
 
562
/** Halt the kernel.
553
/** Halt the kernel.
563
 *
554
 *
564
 * @param argv Argument vector (ignored).
555
 * @param argv Argument vector (ignored).
565
 *
556
 *
566
 * @return 0 on failure, 1 on success (never returns).
557
 * @return 0 on failure, 1 on success (never returns).
567
 */
558
 */
568
int cmd_halt(cmd_arg_t *argv)
559
int cmd_halt(cmd_arg_t *argv)
569
{
560
{
570
    halt();
561
    halt();
571
    return 1;
562
    return 1;
572
}
563
}
573
 
564
 
574
/** Command for printing TLB contents.
565
/** Command for printing TLB contents.
575
 *
566
 *
576
 * @param argv Not used.
567
 * @param argv Not used.
577
 *
568
 *
578
 * @return Always returns 1.
569
 * @return Always returns 1.
579
 */
570
 */
580
int cmd_tlb(cmd_arg_t *argv)
571
int cmd_tlb(cmd_arg_t *argv)
581
{
572
{
582
    tlb_print();
573
    tlb_print();
583
    return 1;
574
    return 1;
584
}
575
}
585
 
576
 
586
/** Write 4 byte value to address */
577
/** Write 4 byte value to address */
587
int cmd_set4(cmd_arg_t *argv)
578
int cmd_set4(cmd_arg_t *argv)
588
{
579
{
589
    __u32 *addr ;
580
    __u32 *addr ;
590
    __u32 arg1 = argv[1].intval;
581
    __u32 arg1 = argv[1].intval;
591
    bool pointer = false;
582
    bool pointer = false;
592
 
583
 
593
    if (((char *)argv->buffer)[0] == '*') {
584
    if (((char *)argv->buffer)[0] == '*') {
594
        addr = (__u32 *) get_symbol_addr(argv->buffer+1);
585
        addr = (__u32 *) get_symbol_addr(argv->buffer+1);
595
        pointer = true;
586
        pointer = true;
596
    } else if (((char *)argv->buffer)[0] >= '0' &&
587
    } else if (((char *)argv->buffer)[0] >= '0' &&
597
           ((char *)argv->buffer)[0] <= '9')
588
           ((char *)argv->buffer)[0] <= '9')
598
        addr = (__u32 *)atoi((char *)argv->buffer);
589
        addr = (__u32 *)atoi((char *)argv->buffer);
599
    else
590
    else
600
        addr = (__u32 *)get_symbol_addr(argv->buffer);
591
        addr = (__u32 *)get_symbol_addr(argv->buffer);
601
 
592
 
602
    if (!addr)
593
    if (!addr)
603
        printf("Symbol %s not found.\n", argv->buffer);
594
        printf("Symbol %s not found.\n", argv->buffer);
604
    else if (addr == (__u32 *) -1) {
595
    else if (addr == (__u32 *) -1) {
605
        symtab_print_search(argv->buffer);
596
        symtab_print_search(argv->buffer);
606
        printf("Duplicate symbol, be more specific.\n");
597
        printf("Duplicate symbol, be more specific.\n");
607
    } else {
598
    } else {
608
        if (pointer)
599
        if (pointer)
609
            addr = (__u32 *)(*(__native *)addr);
600
            addr = (__u32 *)(*(__native *)addr);
610
        printf("Writing 0x%x -> 0x%p\n", arg1, addr);
601
        printf("Writing 0x%x -> 0x%p\n", arg1, addr);
611
        *addr = arg1;
602
        *addr = arg1;
612
       
603
       
613
    }
604
    }
614
   
605
   
615
    return 1;
606
    return 1;
616
}
607
}
617
 
608
 
618
/** Command for listings SLAB caches
609
/** Command for listings SLAB caches
619
 *
610
 *
620
 * @param argv Ignores
611
 * @param argv Ignores
621
 *
612
 *
622
 * @return Always 1
613
 * @return Always 1
623
 */
614
 */
624
int cmd_slabs(cmd_arg_t * argv) {
615
int cmd_slabs(cmd_arg_t * argv) {
625
    slab_print_list();
616
    slab_print_list();
626
    return 1;
617
    return 1;
627
}
618
}
628
 
619
 
629
 
620
 
630
/** Command for listings Thread information
621
/** Command for listings Thread information
631
 *
622
 *
632
 * @param argv Ignores
623
 * @param argv Ignores
633
 *
624
 *
634
 * @return Always 1
625
 * @return Always 1
635
 */
626
 */
636
int cmd_threads(cmd_arg_t * argv) {
627
int cmd_threads(cmd_arg_t * argv) {
637
    thread_print_list();
628
    thread_print_list();
638
    return 1;
629
    return 1;
639
}
630
}
640
 
631
 
641
/** Command for listings Task information
632
/** Command for listings Task information
642
 *
633
 *
643
 * @param argv Ignores
634
 * @param argv Ignores
644
 *
635
 *
645
 * @return Always 1
636
 * @return Always 1
646
 */
637
 */
647
int cmd_tasks(cmd_arg_t * argv) {
638
int cmd_tasks(cmd_arg_t * argv) {
648
    task_print_list();
639
    task_print_list();
649
    return 1;
640
    return 1;
650
}
641
}
651
 
642
 
652
/** Command for listings Thread information
643
/** Command for listings Thread information
653
 *
644
 *
654
 * @param argv Ignores
645
 * @param argv Ignores
655
 *
646
 *
656
 * @return Always 1
647
 * @return Always 1
657
 */
648
 */
658
int cmd_sched(cmd_arg_t * argv) {
649
int cmd_sched(cmd_arg_t * argv) {
659
    sched_print_list();
650
    sched_print_list();
660
    return 1;
651
    return 1;
661
}
652
}
662
 
653
 
663
/** Command for listing memory zones
654
/** Command for listing memory zones
664
 *
655
 *
665
 * @param argv Ignored
656
 * @param argv Ignored
666
 *
657
 *
667
 * return Always 1
658
 * return Always 1
668
 */
659
 */
669
int cmd_zones(cmd_arg_t * argv) {
660
int cmd_zones(cmd_arg_t * argv) {
670
    zone_print_list();
661
    zone_print_list();
671
    return 1;
662
    return 1;
672
}
663
}
673
 
664
 
674
/** Command for memory zone details
665
/** Command for memory zone details
675
 *
666
 *
676
 * @param argv Integer argument from cmdline expected
667
 * @param argv Integer argument from cmdline expected
677
 *
668
 *
678
 * return Always 1
669
 * return Always 1
679
 */
670
 */
680
int cmd_zone(cmd_arg_t * argv) {
671
int cmd_zone(cmd_arg_t * argv) {
681
    zone_print_one(argv[0].intval);
672
    zone_print_one(argv[0].intval);
682
    return 1;
673
    return 1;
683
}
674
}
684
 
675
 
685
/** Command for listing processors.
676
/** Command for listing processors.
686
 *
677
 *
687
 * @param argv Ignored.
678
 * @param argv Ignored.
688
 *
679
 *
689
 * return Always 1.
680
 * return Always 1.
690
 */
681
 */
691
int cmd_cpus(cmd_arg_t *argv)
682
int cmd_cpus(cmd_arg_t *argv)
692
{
683
{
693
    cpu_list();
684
    cpu_list();
694
    return 1;
685
    return 1;
695
}
686
}
696
 
687
 
697
/** Command for printing kernel version.
688
/** Command for printing kernel version.
698
 *
689
 *
699
 * @param argv Ignored.
690
 * @param argv Ignored.
700
 *
691
 *
701
 * return Always 1.
692
 * return Always 1.
702
 */
693
 */
703
int cmd_version(cmd_arg_t *argv)
694
int cmd_version(cmd_arg_t *argv)
704
{
695
{
705
    version_print();
696
    version_print();
706
    return 1;
697
    return 1;
707
}
-
 
708
 
-
 
709
 
-
 
710
int cmd_hello(cmd_arg_t *argv)
-
 
711
{
-
 
712
    printf("\nHello, World !!!\n");
-
 
713
    return 1;
-
 
714
}
698
}
715
 
699