Subversion Repositories HelenOS

Rev

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

Rev 1929 Rev 2019
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
/** @addtogroup genericconsole
29
/** @addtogroup genericconsole
30
 * @{
30
 * @{
31
 */
31
 */
32
 
32
 
33
/**
33
/**
34
 * @file    cmd.c
34
 * @file    cmd.c
35
 * @brief   Kernel console command wrappers.
35
 * @brief   Kernel console command wrappers.
36
 *
36
 *
37
 * This file is meant to contain all wrapper functions for
37
 * This file is meant to contain all wrapper functions for
38
 * all kconsole commands. The point is in separating
38
 * all kconsole commands. The point is in separating
39
 * kconsole specific wrappers from kconsole-unaware functions
39
 * kconsole specific wrappers from kconsole-unaware functions
40
 * from other subsystems.
40
 * from other subsystems.
41
 */
41
 */
42
 
42
 
43
#include <console/cmd.h>
43
#include <console/cmd.h>
44
#include <console/console.h>
44
#include <console/console.h>
45
#include <console/kconsole.h>
45
#include <console/kconsole.h>
46
#include <print.h>
46
#include <print.h>
47
#include <panic.h>
47
#include <panic.h>
48
#include <typedefs.h>
48
#include <typedefs.h>
49
#include <arch/types.h>
49
#include <arch/types.h>
50
#include <adt/list.h>
50
#include <adt/list.h>
51
#include <arch.h>
51
#include <arch.h>
52
#include <func.h>
52
#include <func.h>
53
#include <macros.h>
53
#include <macros.h>
54
#include <debug.h>
54
#include <debug.h>
55
#include <symtab.h>
55
#include <symtab.h>
56
#include <cpu.h>
56
#include <cpu.h>
57
#include <mm/tlb.h>
57
#include <mm/tlb.h>
58
#include <arch/mm/tlb.h>
58
#include <arch/mm/tlb.h>
59
#include <mm/frame.h>
59
#include <mm/frame.h>
60
#include <main/version.h>
60
#include <main/version.h>
61
#include <mm/slab.h>
61
#include <mm/slab.h>
62
#include <proc/scheduler.h>
62
#include <proc/scheduler.h>
63
#include <proc/thread.h>
63
#include <proc/thread.h>
64
#include <proc/task.h>
64
#include <proc/task.h>
65
#include <ipc/ipc.h>
65
#include <ipc/ipc.h>
66
#include <ipc/irq.h>
66
#include <ipc/irq.h>
67
 
67
 
-
 
68
#ifdef CONFIG_TEST
-
 
69
#include <test.h>
-
 
70
#endif
-
 
71
 
68
/* Data and methods for 'help' command. */
72
/* Data and methods for 'help' command. */
69
static int cmd_help(cmd_arg_t *argv);
73
static int cmd_help(cmd_arg_t *argv);
70
static cmd_info_t help_info = {
74
static cmd_info_t help_info = {
71
    .name = "help",
75
    .name = "help",
72
    .description = "List of supported commands.",
76
    .description = "List of supported commands.",
73
    .func = cmd_help,
77
    .func = cmd_help,
74
    .argc = 0
78
    .argc = 0
75
};
79
};
76
 
80
 
77
static cmd_info_t exit_info = {
81
static cmd_info_t exit_info = {
78
    .name = "exit",
82
    .name = "exit",
79
    .description ="Exit kconsole",
83
    .description = "Exit kconsole",
80
    .argc = 0
84
    .argc = 0
81
};
85
};
82
 
86
 
83
static int cmd_continue(cmd_arg_t *argv);
87
static int cmd_continue(cmd_arg_t *argv);
84
static cmd_info_t continue_info = {
88
static cmd_info_t continue_info = {
85
    .name = "continue",
89
    .name = "continue",
86
    .description ="Return console back to userspace.",
90
    .description = "Return console back to userspace.",
87
    .func = cmd_continue,
91
    .func = cmd_continue,
88
    .argc = 0
92
    .argc = 0
89
};
93
};
90
 
94
 
-
 
95
#ifdef CONFIG_TEST
-
 
96
static int cmd_tests(cmd_arg_t *argv);
-
 
97
static cmd_info_t tests_info = {
-
 
98
    .name = "tests",
-
 
99
    .description = "Print available kernel tests.",
-
 
100
    .func = cmd_tests,
-
 
101
    .argc = 0
-
 
102
};
-
 
103
 
-
 
104
static char test_buf[MAX_CMDLINE + 1];
-
 
105
static int cmd_test(cmd_arg_t *argv);
-
 
106
static cmd_arg_t test_argv[] = {
-
 
107
    {
-
 
108
        .type = ARG_TYPE_STRING,
-
 
109
        .buffer = test_buf,
-
 
110
        .len = sizeof(test_buf)
-
 
111
    }
-
 
112
};
-
 
113
static cmd_info_t test_info = {
-
 
114
    .name = "test",
-
 
115
    .description = "Run kernel test.",
-
 
116
    .func = cmd_test,
-
 
117
    .argc = 1,
-
 
118
    .argv = test_argv
-
 
119
};
-
 
120
#endif
-
 
121
 
91
/* Data and methods for 'description' command. */
122
/* Data and methods for 'description' command. */
92
static int cmd_desc(cmd_arg_t *argv);
123
static int cmd_desc(cmd_arg_t *argv);
93
static void desc_help(void);
124
static void desc_help(void);
94
static char desc_buf[MAX_CMDLINE+1];
125
static char desc_buf[MAX_CMDLINE+1];
95
static cmd_arg_t desc_argv = {
126
static cmd_arg_t desc_argv = {
96
    .type = ARG_TYPE_STRING,
127
    .type = ARG_TYPE_STRING,
97
    .buffer = desc_buf,
128
    .buffer = desc_buf,
98
    .len = sizeof(desc_buf)
129
    .len = sizeof(desc_buf)
99
};
130
};
100
static cmd_info_t desc_info = {
131
static cmd_info_t desc_info = {
101
    .name = "describe",
132
    .name = "describe",
102
    .description = "Describe specified command.",
133
    .description = "Describe specified command.",
103
    .help = desc_help,
134
    .help = desc_help,
104
    .func = cmd_desc,
135
    .func = cmd_desc,
105
    .argc = 1,
136
    .argc = 1,
106
    .argv = &desc_argv
137
    .argv = &desc_argv
107
};
138
};
108
 
139
 
109
/* Data and methods for 'symaddr' command. */
140
/* Data and methods for 'symaddr' command. */
110
static int cmd_symaddr(cmd_arg_t *argv);
141
static int cmd_symaddr(cmd_arg_t *argv);
111
static char symaddr_buf[MAX_CMDLINE+1];
142
static char symaddr_buf[MAX_CMDLINE+1];
112
static cmd_arg_t symaddr_argv = {
143
static cmd_arg_t symaddr_argv = {
113
    .type = ARG_TYPE_STRING,
144
    .type = ARG_TYPE_STRING,
114
    .buffer = symaddr_buf,
145
    .buffer = symaddr_buf,
115
    .len = sizeof(symaddr_buf)
146
    .len = sizeof(symaddr_buf)
116
};
147
};
117
static cmd_info_t symaddr_info = {
148
static cmd_info_t symaddr_info = {
118
    .name = "symaddr",
149
    .name = "symaddr",
119
    .description = "Return symbol address.",
150
    .description = "Return symbol address.",
120
    .func = cmd_symaddr,
151
    .func = cmd_symaddr,
121
    .argc = 1,
152
    .argc = 1,
122
    .argv = &symaddr_argv
153
    .argv = &symaddr_argv
123
};
154
};
124
 
155
 
125
static char set_buf[MAX_CMDLINE+1];
156
static char set_buf[MAX_CMDLINE+1];
126
static int cmd_set4(cmd_arg_t *argv);
157
static int cmd_set4(cmd_arg_t *argv);
127
static cmd_arg_t set4_argv[] = {
158
static cmd_arg_t set4_argv[] = {
128
    {
159
    {
129
        .type = ARG_TYPE_STRING,
160
        .type = ARG_TYPE_STRING,
130
        .buffer = set_buf,
161
        .buffer = set_buf,
131
        .len = sizeof(set_buf)
162
        .len = sizeof(set_buf)
132
    },
163
    },
133
    {
164
    {
134
        .type = ARG_TYPE_INT
165
        .type = ARG_TYPE_INT
135
    }
166
    }
136
};
167
};
137
static cmd_info_t set4_info = {
168
static cmd_info_t set4_info = {
138
    .name = "set4",
169
    .name = "set4",
139
    .description = "set <dest_addr> <value> - 4byte version",
170
    .description = "set <dest_addr> <value> - 4byte version",
140
    .func = cmd_set4,
171
    .func = cmd_set4,
141
    .argc = 2,
172
    .argc = 2,
142
    .argv = set4_argv
173
    .argv = set4_argv
143
};
174
};
144
 
175
 
145
/* Data and methods for 'call0' command. */
176
/* Data and methods for 'call0' command. */
146
static char call0_buf[MAX_CMDLINE+1];
177
static char call0_buf[MAX_CMDLINE+1];
147
static char carg1_buf[MAX_CMDLINE+1];
178
static char carg1_buf[MAX_CMDLINE+1];
148
static char carg2_buf[MAX_CMDLINE+1];
179
static char carg2_buf[MAX_CMDLINE+1];
149
static char carg3_buf[MAX_CMDLINE+1];
180
static char carg3_buf[MAX_CMDLINE+1];
150
 
181
 
151
static int cmd_call0(cmd_arg_t *argv);
182
static int cmd_call0(cmd_arg_t *argv);
152
static cmd_arg_t call0_argv = {
183
static cmd_arg_t call0_argv = {
153
    .type = ARG_TYPE_STRING,
184
    .type = ARG_TYPE_STRING,
154
    .buffer = call0_buf,
185
    .buffer = call0_buf,
155
    .len = sizeof(call0_buf)
186
    .len = sizeof(call0_buf)
156
};
187
};
157
static cmd_info_t call0_info = {
188
static cmd_info_t call0_info = {
158
    .name = "call0",
189
    .name = "call0",
159
    .description = "call0 <function> -> call function().",
190
    .description = "call0 <function> -> call function().",
160
    .func = cmd_call0,
191
    .func = cmd_call0,
161
    .argc = 1,
192
    .argc = 1,
162
    .argv = &call0_argv
193
    .argv = &call0_argv
163
};
194
};
164
 
195
 
165
/* Data and methods for 'call1' command. */
196
/* Data and methods for 'call1' command. */
166
static int cmd_call1(cmd_arg_t *argv);
197
static int cmd_call1(cmd_arg_t *argv);
167
static cmd_arg_t call1_argv[] = {
198
static cmd_arg_t call1_argv[] = {
168
    {
199
    {
169
        .type = ARG_TYPE_STRING,
200
        .type = ARG_TYPE_STRING,
170
        .buffer = call0_buf,
201
        .buffer = call0_buf,
171
        .len = sizeof(call0_buf)
202
        .len = sizeof(call0_buf)
172
    },
203
    },
173
    {
204
    {
174
        .type = ARG_TYPE_VAR,
205
        .type = ARG_TYPE_VAR,
175
        .buffer = carg1_buf,
206
        .buffer = carg1_buf,
176
        .len = sizeof(carg1_buf)
207
        .len = sizeof(carg1_buf)
177
    }
208
    }
178
};
209
};
179
static cmd_info_t call1_info = {
210
static cmd_info_t call1_info = {
180
    .name = "call1",
211
    .name = "call1",
181
    .description = "call1 <function> <arg1> -> call function(arg1).",
212
    .description = "call1 <function> <arg1> -> call function(arg1).",
182
    .func = cmd_call1,
213
    .func = cmd_call1,
183
    .argc = 2,
214
    .argc = 2,
184
    .argv = call1_argv
215
    .argv = call1_argv
185
};
216
};
186
 
217
 
187
/* Data and methods for 'call2' command. */
218
/* Data and methods for 'call2' command. */
188
static int cmd_call2(cmd_arg_t *argv);
219
static int cmd_call2(cmd_arg_t *argv);
189
static cmd_arg_t call2_argv[] = {
220
static cmd_arg_t call2_argv[] = {
190
    {
221
    {
191
        .type = ARG_TYPE_STRING,
222
        .type = ARG_TYPE_STRING,
192
        .buffer = call0_buf,
223
        .buffer = call0_buf,
193
        .len = sizeof(call0_buf)
224
        .len = sizeof(call0_buf)
194
    },
225
    },
195
    {
226
    {
196
        .type = ARG_TYPE_VAR,
227
        .type = ARG_TYPE_VAR,
197
        .buffer = carg1_buf,
228
        .buffer = carg1_buf,
198
        .len = sizeof(carg1_buf)
229
        .len = sizeof(carg1_buf)
199
    },
230
    },
200
    {
231
    {
201
        .type = ARG_TYPE_VAR,
232
        .type = ARG_TYPE_VAR,
202
        .buffer = carg2_buf,
233
        .buffer = carg2_buf,
203
        .len = sizeof(carg2_buf)
234
        .len = sizeof(carg2_buf)
204
    }
235
    }
205
};
236
};
206
static cmd_info_t call2_info = {
237
static cmd_info_t call2_info = {
207
    .name = "call2",
238
    .name = "call2",
208
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
239
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
209
    .func = cmd_call2,
240
    .func = cmd_call2,
210
    .argc = 3,
241
    .argc = 3,
211
    .argv = call2_argv
242
    .argv = call2_argv
212
};
243
};
213
 
244
 
214
/* Data and methods for 'call3' command. */
245
/* Data and methods for 'call3' command. */
215
static int cmd_call3(cmd_arg_t *argv);
246
static int cmd_call3(cmd_arg_t *argv);
216
static cmd_arg_t call3_argv[] = {
247
static cmd_arg_t call3_argv[] = {
217
    {
248
    {
218
        .type = ARG_TYPE_STRING,
249
        .type = ARG_TYPE_STRING,
219
        .buffer = call0_buf,
250
        .buffer = call0_buf,
220
        .len = sizeof(call0_buf)
251
        .len = sizeof(call0_buf)
221
    },
252
    },
222
    {
253
    {
223
        .type = ARG_TYPE_VAR,
254
        .type = ARG_TYPE_VAR,
224
        .buffer = carg1_buf,
255
        .buffer = carg1_buf,
225
        .len = sizeof(carg1_buf)
256
        .len = sizeof(carg1_buf)
226
    },
257
    },
227
    {
258
    {
228
        .type = ARG_TYPE_VAR,
259
        .type = ARG_TYPE_VAR,
229
        .buffer = carg2_buf,
260
        .buffer = carg2_buf,
230
        .len = sizeof(carg2_buf)
261
        .len = sizeof(carg2_buf)
231
    },
262
    },
232
    {
263
    {
233
        .type = ARG_TYPE_VAR,
264
        .type = ARG_TYPE_VAR,
234
        .buffer = carg3_buf,
265
        .buffer = carg3_buf,
235
        .len = sizeof(carg3_buf)
266
        .len = sizeof(carg3_buf)
236
    }
267
    }
237
 
268
 
238
};
269
};
239
static cmd_info_t call3_info = {
270
static cmd_info_t call3_info = {
240
    .name = "call3",
271
    .name = "call3",
241
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
272
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
242
    .func = cmd_call3,
273
    .func = cmd_call3,
243
    .argc = 4,
274
    .argc = 4,
244
    .argv = call3_argv
275
    .argv = call3_argv
245
};
276
};
246
 
277
 
247
/* Data and methods for 'halt' command. */
278
/* Data and methods for 'halt' command. */
248
static int cmd_halt(cmd_arg_t *argv);
279
static int cmd_halt(cmd_arg_t *argv);
249
static cmd_info_t halt_info = {
280
static cmd_info_t halt_info = {
250
    .name = "halt",
281
    .name = "halt",
251
    .description = "Halt the kernel.",
282
    .description = "Halt the kernel.",
252
    .func = cmd_halt,
283
    .func = cmd_halt,
253
    .argc = 0
284
    .argc = 0
254
};
285
};
255
 
286
 
256
/* Data and methods for 'tlb' command. */
287
/* Data and methods for 'tlb' command. */
257
static int cmd_tlb(cmd_arg_t *argv);
288
static int cmd_tlb(cmd_arg_t *argv);
258
cmd_info_t tlb_info = {
289
cmd_info_t tlb_info = {
259
    .name = "tlb",
290
    .name = "tlb",
260
    .description = "Print TLB of current processor.",
291
    .description = "Print TLB of current processor.",
261
    .help = NULL,
292
    .help = NULL,
262
    .func = cmd_tlb,
293
    .func = cmd_tlb,
263
    .argc = 0,
294
    .argc = 0,
264
    .argv = NULL
295
    .argv = NULL
265
};
296
};
266
 
297
 
267
static int cmd_threads(cmd_arg_t *argv);
298
static int cmd_threads(cmd_arg_t *argv);
268
static cmd_info_t threads_info = {
299
static cmd_info_t threads_info = {
269
    .name = "threads",
300
    .name = "threads",
270
    .description = "List all threads.",
301
    .description = "List all threads.",
271
    .func = cmd_threads,
302
    .func = cmd_threads,
272
    .argc = 0
303
    .argc = 0
273
};
304
};
274
 
305
 
275
static int cmd_tasks(cmd_arg_t *argv);
306
static int cmd_tasks(cmd_arg_t *argv);
276
static cmd_info_t tasks_info = {
307
static cmd_info_t tasks_info = {
277
    .name = "tasks",
308
    .name = "tasks",
278
    .description = "List all tasks.",
309
    .description = "List all tasks.",
279
    .func = cmd_tasks,
310
    .func = cmd_tasks,
280
    .argc = 0
311
    .argc = 0
281
};
312
};
282
 
313
 
283
 
314
 
284
static int cmd_sched(cmd_arg_t *argv);
315
static int cmd_sched(cmd_arg_t *argv);
285
static cmd_info_t sched_info = {
316
static cmd_info_t sched_info = {
286
    .name = "scheduler",
317
    .name = "scheduler",
287
    .description = "List all scheduler information.",
318
    .description = "List all scheduler information.",
288
    .func = cmd_sched,
319
    .func = cmd_sched,
289
    .argc = 0
320
    .argc = 0
290
};
321
};
291
 
322
 
292
static int cmd_slabs(cmd_arg_t *argv);
323
static int cmd_slabs(cmd_arg_t *argv);
293
static cmd_info_t slabs_info = {
324
static cmd_info_t slabs_info = {
294
    .name = "slabs",
325
    .name = "slabs",
295
    .description = "List slab caches.",
326
    .description = "List slab caches.",
296
    .func = cmd_slabs,
327
    .func = cmd_slabs,
297
    .argc = 0
328
    .argc = 0
298
};
329
};
299
 
330
 
300
/* Data and methods for 'zones' command */
331
/* Data and methods for 'zones' command */
301
static int cmd_zones(cmd_arg_t *argv);
332
static int cmd_zones(cmd_arg_t *argv);
302
static cmd_info_t zones_info = {
333
static cmd_info_t zones_info = {
303
    .name = "zones",
334
    .name = "zones",
304
    .description = "List of memory zones.",
335
    .description = "List of memory zones.",
305
    .func = cmd_zones,
336
    .func = cmd_zones,
306
    .argc = 0
337
    .argc = 0
307
};
338
};
308
 
339
 
309
/* Data and methods for 'ipc_task' command */
340
/* Data and methods for 'ipc_task' command */
310
static int cmd_ipc_task(cmd_arg_t *argv);
341
static int cmd_ipc_task(cmd_arg_t *argv);
311
static cmd_arg_t ipc_task_argv = {
342
static cmd_arg_t ipc_task_argv = {
312
    .type = ARG_TYPE_INT,
343
    .type = ARG_TYPE_INT,
313
};
344
};
314
static cmd_info_t ipc_task_info = {
345
static cmd_info_t ipc_task_info = {
315
    .name = "ipc_task",
346
    .name = "ipc_task",
316
    .description = "ipc_task <taskid> Show IPC information of given task.",
347
    .description = "ipc_task <taskid> Show IPC information of given task.",
317
    .func = cmd_ipc_task,
348
    .func = cmd_ipc_task,
318
    .argc = 1,
349
    .argc = 1,
319
    .argv = &ipc_task_argv
350
    .argv = &ipc_task_argv
320
};
351
};
321
 
352
 
322
/* Data and methods for 'zone' command */
353
/* Data and methods for 'zone' command */
323
static int cmd_zone(cmd_arg_t *argv);
354
static int cmd_zone(cmd_arg_t *argv);
324
static cmd_arg_t zone_argv = {
355
static cmd_arg_t zone_argv = {
325
    .type = ARG_TYPE_INT,
356
    .type = ARG_TYPE_INT,
326
};
357
};
327
 
358
 
328
static cmd_info_t zone_info = {
359
static cmd_info_t zone_info = {
329
    .name = "zone",
360
    .name = "zone",
330
    .description = "Show memory zone structure.",
361
    .description = "Show memory zone structure.",
331
    .func = cmd_zone,
362
    .func = cmd_zone,
332
    .argc = 1,
363
    .argc = 1,
333
    .argv = &zone_argv
364
    .argv = &zone_argv
334
};
365
};
335
 
366
 
336
/* Data and methods for 'cpus' command. */
367
/* Data and methods for 'cpus' command. */
337
static int cmd_cpus(cmd_arg_t *argv);
368
static int cmd_cpus(cmd_arg_t *argv);
338
cmd_info_t cpus_info = {
369
cmd_info_t cpus_info = {
339
    .name = "cpus",
370
    .name = "cpus",
340
    .description = "List all processors.",
371
    .description = "List all processors.",
341
    .help = NULL,
372
    .help = NULL,
342
    .func = cmd_cpus,
373
    .func = cmd_cpus,
343
    .argc = 0,
374
    .argc = 0,
344
    .argv = NULL
375
    .argv = NULL
345
};
376
};
346
 
377
 
347
/* Data and methods for 'version' command. */
378
/* Data and methods for 'version' command. */
348
static int cmd_version(cmd_arg_t *argv);
379
static int cmd_version(cmd_arg_t *argv);
349
cmd_info_t version_info = {
380
cmd_info_t version_info = {
350
    .name = "version",
381
    .name = "version",
351
    .description = "Print version information.",
382
    .description = "Print version information.",
352
    .help = NULL,
383
    .help = NULL,
353
    .func = cmd_version,
384
    .func = cmd_version,
354
    .argc = 0,
385
    .argc = 0,
355
    .argv = NULL
386
    .argv = NULL
356
};
387
};
357
 
388
 
358
static cmd_info_t *basic_commands[] = {
389
static cmd_info_t *basic_commands[] = {
359
    &call0_info,
390
    &call0_info,
360
    &call1_info,
391
    &call1_info,
361
    &call2_info,
392
    &call2_info,
362
    &call3_info,
393
    &call3_info,
363
    &continue_info,
394
    &continue_info,
364
    &cpus_info,
395
    &cpus_info,
365
    &desc_info,
396
    &desc_info,
366
    &exit_info,
397
    &exit_info,
367
    &halt_info,
398
    &halt_info,
368
    &help_info,
399
    &help_info,
369
    &ipc_task_info,
400
    &ipc_task_info,
370
    &set4_info,
401
    &set4_info,
371
    &slabs_info,
402
    &slabs_info,
372
    &symaddr_info,
403
    &symaddr_info,
373
    &sched_info,
404
    &sched_info,
374
    &threads_info,
405
    &threads_info,
375
    &tasks_info,
406
    &tasks_info,
376
    &tlb_info,
407
    &tlb_info,
377
    &version_info,
408
    &version_info,
378
    &zones_info,
409
    &zones_info,
379
    &zone_info,
410
    &zone_info,
-
 
411
#ifdef CONFIG_TEST
-
 
412
    &tests_info,
-
 
413
    &test_info,
-
 
414
#endif
380
    NULL
415
    NULL
381
};
416
};
382
 
417
 
383
 
418
 
384
/** Initialize command info structure.
419
/** Initialize command info structure.
385
 *
420
 *
386
 * @param cmd Command info structure.
421
 * @param cmd Command info structure.
387
 *
422
 *
388
 */
423
 */
389
void cmd_initialize(cmd_info_t *cmd)
424
void cmd_initialize(cmd_info_t *cmd)
390
{
425
{
391
    spinlock_initialize(&cmd->lock, "cmd");
426
    spinlock_initialize(&cmd->lock, "cmd");
392
    link_initialize(&cmd->link);
427
    link_initialize(&cmd->link);
393
}
428
}
394
 
429
 
395
/** Initialize and register commands. */
430
/** Initialize and register commands. */
396
void cmd_init(void)
431
void cmd_init(void)
397
{
432
{
398
    int i;
433
    int i;
399
 
434
 
400
    for (i=0;basic_commands[i]; i++) {
435
    for (i=0;basic_commands[i]; i++) {
401
        cmd_initialize(basic_commands[i]);
436
        cmd_initialize(basic_commands[i]);
402
        if (!cmd_register(basic_commands[i]))
437
        if (!cmd_register(basic_commands[i]))
403
            panic("could not register command %s\n",
438
            panic("could not register command %s\n",
404
                  basic_commands[i]->name);
439
                  basic_commands[i]->name);
405
    }
440
    }
406
}
441
}
407
 
442
 
408
 
443
 
409
/** List supported commands.
444
/** List supported commands.
410
 *
445
 *
411
 * @param argv Argument vector.
446
 * @param argv Argument vector.
412
 *
447
 *
413
 * @return 0 on failure, 1 on success.
448
 * @return 0 on failure, 1 on success.
414
 */
449
 */
415
int cmd_help(cmd_arg_t *argv)
450
int cmd_help(cmd_arg_t *argv)
416
{
451
{
417
    link_t *cur;
452
    link_t *cur;
418
 
453
 
419
    spinlock_lock(&cmd_lock);
454
    spinlock_lock(&cmd_lock);
420
   
455
   
421
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
456
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
422
        cmd_info_t *hlp;
457
        cmd_info_t *hlp;
423
       
458
       
424
        hlp = list_get_instance(cur, cmd_info_t, link);
459
        hlp = list_get_instance(cur, cmd_info_t, link);
425
        spinlock_lock(&hlp->lock);
460
        spinlock_lock(&hlp->lock);
426
       
461
       
427
        printf("%s - %s\n", hlp->name, hlp->description);
462
        printf("%s - %s\n", hlp->name, hlp->description);
428
 
463
 
429
        spinlock_unlock(&hlp->lock);
464
        spinlock_unlock(&hlp->lock);
430
    }
465
    }
431
   
466
   
432
    spinlock_unlock(&cmd_lock);
467
    spinlock_unlock(&cmd_lock);
433
 
468
 
434
    return 1;
469
    return 1;
435
}
470
}
436
 
471
 
437
/** Describe specified command.
472
/** Describe specified command.
438
 *
473
 *
439
 * @param argv Argument vector.
474
 * @param argv Argument vector.
440
 *
475
 *
441
 * @return 0 on failure, 1 on success.
476
 * @return 0 on failure, 1 on success.
442
 */
477
 */
443
int cmd_desc(cmd_arg_t *argv)
478
int cmd_desc(cmd_arg_t *argv)
444
{
479
{
445
    link_t *cur;
480
    link_t *cur;
446
 
481
 
447
    spinlock_lock(&cmd_lock);
482
    spinlock_lock(&cmd_lock);
448
   
483
   
449
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
484
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
450
        cmd_info_t *hlp;
485
        cmd_info_t *hlp;
451
       
486
       
452
        hlp = list_get_instance(cur, cmd_info_t, link);
487
        hlp = list_get_instance(cur, cmd_info_t, link);
453
        spinlock_lock(&hlp->lock);
488
        spinlock_lock(&hlp->lock);
454
 
489
 
455
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
490
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
456
            printf("%s - %s\n", hlp->name, hlp->description);
491
            printf("%s - %s\n", hlp->name, hlp->description);
457
            if (hlp->help)
492
            if (hlp->help)
458
                hlp->help();
493
                hlp->help();
459
            spinlock_unlock(&hlp->lock);
494
            spinlock_unlock(&hlp->lock);
460
            break;
495
            break;
461
        }
496
        }
462
 
497
 
463
        spinlock_unlock(&hlp->lock);
498
        spinlock_unlock(&hlp->lock);
464
    }
499
    }
465
   
500
   
466
    spinlock_unlock(&cmd_lock);
501
    spinlock_unlock(&cmd_lock);
467
 
502
 
468
    return 1;
503
    return 1;
469
}
504
}
470
 
505
 
471
/** Search symbol table */
506
/** Search symbol table */
472
int cmd_symaddr(cmd_arg_t *argv)
507
int cmd_symaddr(cmd_arg_t *argv)
473
{
508
{
474
    symtab_print_search(argv->buffer);
509
    symtab_print_search(argv->buffer);
475
   
510
   
476
    return 1;
511
    return 1;
477
}
512
}
478
 
513
 
479
/** Call function with zero parameters */
514
/** Call function with zero parameters */
480
int cmd_call0(cmd_arg_t *argv)
515
int cmd_call0(cmd_arg_t *argv)
481
{
516
{
482
    uintptr_t symaddr;
517
    uintptr_t symaddr;
483
    char *symbol;
518
    char *symbol;
484
    unative_t (*f)(void);
519
    unative_t (*f)(void);
485
#ifdef ia64
520
#ifdef ia64
486
    struct {
521
    struct {
487
        unative_t f;
522
        unative_t f;
488
        unative_t gp;
523
        unative_t gp;
489
    }fptr;
524
    }fptr;
490
#endif
525
#endif
491
 
526
 
492
    symaddr = get_symbol_addr(argv->buffer);
527
    symaddr = get_symbol_addr(argv->buffer);
493
    if (!symaddr)
528
    if (!symaddr)
494
        printf("Symbol %s not found.\n", argv->buffer);
529
        printf("Symbol %s not found.\n", argv->buffer);
495
    else if (symaddr == (uintptr_t) -1) {
530
    else if (symaddr == (uintptr_t) -1) {
496
        symtab_print_search(argv->buffer);
531
        symtab_print_search(argv->buffer);
497
        printf("Duplicate symbol, be more specific.\n");
532
        printf("Duplicate symbol, be more specific.\n");
498
    } else {
533
    } else {
499
        symbol = get_symtab_entry(symaddr);
534
        symbol = get_symtab_entry(symaddr);
500
        printf("Calling f(): %.*p: %s\n", sizeof(uintptr_t) * 2, symaddr, symbol);
535
        printf("Calling f(): %.*p: %s\n", sizeof(uintptr_t) * 2, symaddr, symbol);
501
#ifdef ia64
536
#ifdef ia64
502
        fptr.f = symaddr;
537
        fptr.f = symaddr;
503
        fptr.gp = ((unative_t *)cmd_call2)[1];
538
        fptr.gp = ((unative_t *)cmd_call2)[1];
504
        f =  (unative_t (*)(void)) &fptr;
539
        f =  (unative_t (*)(void)) &fptr;
505
#else
540
#else
506
        f =  (unative_t (*)(void)) symaddr;
541
        f =  (unative_t (*)(void)) symaddr;
507
#endif
542
#endif
508
        printf("Result: %#zx\n", f());
543
        printf("Result: %#zx\n", f());
509
    }
544
    }
510
   
545
   
511
    return 1;
546
    return 1;
512
}
547
}
513
 
548
 
514
/** Call function with one parameter */
549
/** Call function with one parameter */
515
int cmd_call1(cmd_arg_t *argv)
550
int cmd_call1(cmd_arg_t *argv)
516
{
551
{
517
    uintptr_t symaddr;
552
    uintptr_t symaddr;
518
    char *symbol;
553
    char *symbol;
519
    unative_t (*f)(unative_t,...);
554
    unative_t (*f)(unative_t,...);
520
    unative_t arg1 = argv[1].intval;
555
    unative_t arg1 = argv[1].intval;
521
#ifdef ia64
556
#ifdef ia64
522
    struct {
557
    struct {
523
        unative_t f;
558
        unative_t f;
524
        unative_t gp;
559
        unative_t gp;
525
    }fptr;
560
    }fptr;
526
#endif
561
#endif
527
 
562
 
528
    symaddr = get_symbol_addr(argv->buffer);
563
    symaddr = get_symbol_addr(argv->buffer);
529
    if (!symaddr)
564
    if (!symaddr)
530
        printf("Symbol %s not found.\n", argv->buffer);
565
        printf("Symbol %s not found.\n", argv->buffer);
531
    else if (symaddr == (uintptr_t) -1) {
566
    else if (symaddr == (uintptr_t) -1) {
532
        symtab_print_search(argv->buffer);
567
        symtab_print_search(argv->buffer);
533
        printf("Duplicate symbol, be more specific.\n");
568
        printf("Duplicate symbol, be more specific.\n");
534
    } else {
569
    } else {
535
        symbol = get_symtab_entry(symaddr);
570
        symbol = get_symtab_entry(symaddr);
536
 
571
 
537
        printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol);
572
        printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol);
538
#ifdef ia64
573
#ifdef ia64
539
        fptr.f = symaddr;
574
        fptr.f = symaddr;
540
        fptr.gp = ((unative_t *)cmd_call2)[1];
575
        fptr.gp = ((unative_t *)cmd_call2)[1];
541
        f =  (unative_t (*)(unative_t,...)) &fptr;
576
        f =  (unative_t (*)(unative_t,...)) &fptr;
542
#else
577
#else
543
        f =  (unative_t (*)(unative_t,...)) symaddr;
578
        f =  (unative_t (*)(unative_t,...)) symaddr;
544
#endif
579
#endif
545
        printf("Result: %#zx\n", f(arg1));
580
        printf("Result: %#zx\n", f(arg1));
546
    }
581
    }
547
   
582
   
548
    return 1;
583
    return 1;
549
}
584
}
550
 
585
 
551
/** Call function with two parameters */
586
/** Call function with two parameters */
552
int cmd_call2(cmd_arg_t *argv)
587
int cmd_call2(cmd_arg_t *argv)
553
{
588
{
554
    uintptr_t symaddr;
589
    uintptr_t symaddr;
555
    char *symbol;
590
    char *symbol;
556
    unative_t (*f)(unative_t,unative_t,...);
591
    unative_t (*f)(unative_t,unative_t,...);
557
    unative_t arg1 = argv[1].intval;
592
    unative_t arg1 = argv[1].intval;
558
    unative_t arg2 = argv[2].intval;
593
    unative_t arg2 = argv[2].intval;
559
#ifdef ia64
594
#ifdef ia64
560
    struct {
595
    struct {
561
        unative_t f;
596
        unative_t f;
562
        unative_t gp;
597
        unative_t gp;
563
    }fptr;
598
    }fptr;
564
#endif
599
#endif
565
 
600
 
566
    symaddr = get_symbol_addr(argv->buffer);
601
    symaddr = get_symbol_addr(argv->buffer);
567
    if (!symaddr)
602
    if (!symaddr)
568
        printf("Symbol %s not found.\n", argv->buffer);
603
        printf("Symbol %s not found.\n", argv->buffer);
569
    else if (symaddr == (uintptr_t) -1) {
604
    else if (symaddr == (uintptr_t) -1) {
570
        symtab_print_search(argv->buffer);
605
        symtab_print_search(argv->buffer);
571
        printf("Duplicate symbol, be more specific.\n");
606
        printf("Duplicate symbol, be more specific.\n");
572
    } else {
607
    } else {
573
        symbol = get_symtab_entry(symaddr);
608
        symbol = get_symtab_entry(symaddr);
574
        printf("Calling f(0x%zx,0x%zx): %.*p: %s\n",
609
        printf("Calling f(0x%zx,0x%zx): %.*p: %s\n",
575
               arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol);
610
               arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol);
576
#ifdef ia64
611
#ifdef ia64
577
        fptr.f = symaddr;
612
        fptr.f = symaddr;
578
        fptr.gp = ((unative_t *)cmd_call2)[1];
613
        fptr.gp = ((unative_t *)cmd_call2)[1];
579
        f =  (unative_t (*)(unative_t,unative_t,...)) &fptr;
614
        f =  (unative_t (*)(unative_t,unative_t,...)) &fptr;
580
#else
615
#else
581
        f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
616
        f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
582
#endif
617
#endif
583
        printf("Result: %#zx\n", f(arg1, arg2));
618
        printf("Result: %#zx\n", f(arg1, arg2));
584
    }
619
    }
585
   
620
   
586
    return 1;
621
    return 1;
587
}
622
}
588
 
623
 
589
/** Call function with three parameters */
624
/** Call function with three parameters */
590
int cmd_call3(cmd_arg_t *argv)
625
int cmd_call3(cmd_arg_t *argv)
591
{
626
{
592
    uintptr_t symaddr;
627
    uintptr_t symaddr;
593
    char *symbol;
628
    char *symbol;
594
    unative_t (*f)(unative_t,unative_t,unative_t,...);
629
    unative_t (*f)(unative_t,unative_t,unative_t,...);
595
    unative_t arg1 = argv[1].intval;
630
    unative_t arg1 = argv[1].intval;
596
    unative_t arg2 = argv[2].intval;
631
    unative_t arg2 = argv[2].intval;
597
    unative_t arg3 = argv[3].intval;
632
    unative_t arg3 = argv[3].intval;
598
#ifdef ia64
633
#ifdef ia64
599
    struct {
634
    struct {
600
        unative_t f;
635
        unative_t f;
601
        unative_t gp;
636
        unative_t gp;
602
    }fptr;
637
    }fptr;
603
#endif
638
#endif
604
 
639
 
605
    symaddr = get_symbol_addr(argv->buffer);
640
    symaddr = get_symbol_addr(argv->buffer);
606
    if (!symaddr)
641
    if (!symaddr)
607
        printf("Symbol %s not found.\n", argv->buffer);
642
        printf("Symbol %s not found.\n", argv->buffer);
608
    else if (symaddr == (uintptr_t) -1) {
643
    else if (symaddr == (uintptr_t) -1) {
609
        symtab_print_search(argv->buffer);
644
        symtab_print_search(argv->buffer);
610
        printf("Duplicate symbol, be more specific.\n");
645
        printf("Duplicate symbol, be more specific.\n");
611
    } else {
646
    } else {
612
        symbol = get_symtab_entry(symaddr);
647
        symbol = get_symtab_entry(symaddr);
613
        printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n",
648
        printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n",
614
               arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol);
649
               arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol);
615
#ifdef ia64
650
#ifdef ia64
616
        fptr.f = symaddr;
651
        fptr.f = symaddr;
617
        fptr.gp = ((unative_t *)cmd_call2)[1];
652
        fptr.gp = ((unative_t *)cmd_call2)[1];
618
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
653
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
619
#else
654
#else
620
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
655
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
621
#endif
656
#endif
622
        printf("Result: %#zx\n", f(arg1, arg2, arg3));
657
        printf("Result: %#zx\n", f(arg1, arg2, arg3));
623
    }
658
    }
624
   
659
   
625
    return 1;
660
    return 1;
626
}
661
}
627
 
662
 
628
 
663
 
629
/** Print detailed description of 'describe' command. */
664
/** Print detailed description of 'describe' command. */
630
void desc_help(void)
665
void desc_help(void)
631
{
666
{
632
    printf("Syntax: describe command_name\n");
667
    printf("Syntax: describe command_name\n");
633
}
668
}
634
 
669
 
635
/** Halt the kernel.
670
/** Halt the kernel.
636
 *
671
 *
637
 * @param argv Argument vector (ignored).
672
 * @param argv Argument vector (ignored).
638
 *
673
 *
639
 * @return 0 on failure, 1 on success (never returns).
674
 * @return 0 on failure, 1 on success (never returns).
640
 */
675
 */
641
int cmd_halt(cmd_arg_t *argv)
676
int cmd_halt(cmd_arg_t *argv)
642
{
677
{
643
    halt();
678
    halt();
644
    return 1;
679
    return 1;
645
}
680
}
646
 
681
 
647
/** Command for printing TLB contents.
682
/** Command for printing TLB contents.
648
 *
683
 *
649
 * @param argv Not used.
684
 * @param argv Not used.
650
 *
685
 *
651
 * @return Always returns 1.
686
 * @return Always returns 1.
652
 */
687
 */
653
int cmd_tlb(cmd_arg_t *argv)
688
int cmd_tlb(cmd_arg_t *argv)
654
{
689
{
655
    tlb_print();
690
    tlb_print();
656
    return 1;
691
    return 1;
657
}
692
}
658
 
693
 
659
/** Write 4 byte value to address */
694
/** Write 4 byte value to address */
660
int cmd_set4(cmd_arg_t *argv)
695
int cmd_set4(cmd_arg_t *argv)
661
{
696
{
662
    uint32_t *addr ;
697
    uint32_t *addr ;
663
    uint32_t arg1 = argv[1].intval;
698
    uint32_t arg1 = argv[1].intval;
664
    bool pointer = false;
699
    bool pointer = false;
665
 
700
 
666
    if (((char *)argv->buffer)[0] == '*') {
701
    if (((char *)argv->buffer)[0] == '*') {
667
        addr = (uint32_t *) get_symbol_addr(argv->buffer+1);
702
        addr = (uint32_t *) get_symbol_addr(argv->buffer+1);
668
        pointer = true;
703
        pointer = true;
669
    } else if (((char *)argv->buffer)[0] >= '0' &&
704
    } else if (((char *)argv->buffer)[0] >= '0' &&
670
           ((char *)argv->buffer)[0] <= '9')
705
           ((char *)argv->buffer)[0] <= '9')
671
        addr = (uint32_t *)atoi((char *)argv->buffer);
706
        addr = (uint32_t *)atoi((char *)argv->buffer);
672
    else
707
    else
673
        addr = (uint32_t *)get_symbol_addr(argv->buffer);
708
        addr = (uint32_t *)get_symbol_addr(argv->buffer);
674
 
709
 
675
    if (!addr)
710
    if (!addr)
676
        printf("Symbol %s not found.\n", argv->buffer);
711
        printf("Symbol %s not found.\n", argv->buffer);
677
    else if (addr == (uint32_t *) -1) {
712
    else if (addr == (uint32_t *) -1) {
678
        symtab_print_search(argv->buffer);
713
        symtab_print_search(argv->buffer);
679
        printf("Duplicate symbol, be more specific.\n");
714
        printf("Duplicate symbol, be more specific.\n");
680
    } else {
715
    } else {
681
        if (pointer)
716
        if (pointer)
682
            addr = (uint32_t *)(*(unative_t *)addr);
717
            addr = (uint32_t *)(*(unative_t *)addr);
683
        printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr);
718
        printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr);
684
        *addr = arg1;
719
        *addr = arg1;
685
       
720
       
686
    }
721
    }
687
   
722
   
688
    return 1;
723
    return 1;
689
}
724
}
690
 
725
 
691
/** Command for listings SLAB caches
726
/** Command for listings SLAB caches
692
 *
727
 *
693
 * @param argv Ignores
728
 * @param argv Ignores
694
 *
729
 *
695
 * @return Always 1
730
 * @return Always 1
696
 */
731
 */
697
int cmd_slabs(cmd_arg_t * argv) {
732
int cmd_slabs(cmd_arg_t * argv) {
698
    slab_print_list();
733
    slab_print_list();
699
    return 1;
734
    return 1;
700
}
735
}
701
 
736
 
702
 
737
 
703
/** Command for listings Thread information
738
/** Command for listings Thread information
704
 *
739
 *
705
 * @param argv Ignores
740
 * @param argv Ignores
706
 *
741
 *
707
 * @return Always 1
742
 * @return Always 1
708
 */
743
 */
709
int cmd_threads(cmd_arg_t * argv) {
744
int cmd_threads(cmd_arg_t * argv) {
710
    thread_print_list();
745
    thread_print_list();
711
    return 1;
746
    return 1;
712
}
747
}
713
 
748
 
714
/** Command for listings Task information
749
/** Command for listings Task information
715
 *
750
 *
716
 * @param argv Ignores
751
 * @param argv Ignores
717
 *
752
 *
718
 * @return Always 1
753
 * @return Always 1
719
 */
754
 */
720
int cmd_tasks(cmd_arg_t * argv) {
755
int cmd_tasks(cmd_arg_t * argv) {
721
    task_print_list();
756
    task_print_list();
722
    return 1;
757
    return 1;
723
}
758
}
724
 
759
 
725
/** Command for listings Thread information
760
/** Command for listings Thread information
726
 *
761
 *
727
 * @param argv Ignores
762
 * @param argv Ignores
728
 *
763
 *
729
 * @return Always 1
764
 * @return Always 1
730
 */
765
 */
731
int cmd_sched(cmd_arg_t * argv) {
766
int cmd_sched(cmd_arg_t * argv) {
732
    sched_print_list();
767
    sched_print_list();
733
    return 1;
768
    return 1;
734
}
769
}
735
 
770
 
736
/** Command for listing memory zones
771
/** Command for listing memory zones
737
 *
772
 *
738
 * @param argv Ignored
773
 * @param argv Ignored
739
 *
774
 *
740
 * return Always 1
775
 * return Always 1
741
 */
776
 */
742
int cmd_zones(cmd_arg_t * argv) {
777
int cmd_zones(cmd_arg_t * argv) {
743
    zone_print_list();
778
    zone_print_list();
744
    return 1;
779
    return 1;
745
}
780
}
746
 
781
 
747
/** Command for memory zone details
782
/** Command for memory zone details
748
 *
783
 *
749
 * @param argv Integer argument from cmdline expected
784
 * @param argv Integer argument from cmdline expected
750
 *
785
 *
751
 * return Always 1
786
 * return Always 1
752
 */
787
 */
753
int cmd_zone(cmd_arg_t * argv) {
788
int cmd_zone(cmd_arg_t * argv) {
754
    zone_print_one(argv[0].intval);
789
    zone_print_one(argv[0].intval);
755
    return 1;
790
    return 1;
756
}
791
}
757
 
792
 
758
/** Command for printing task ipc details
793
/** Command for printing task ipc details
759
 *
794
 *
760
 * @param argv Integer argument from cmdline expected
795
 * @param argv Integer argument from cmdline expected
761
 *
796
 *
762
 * return Always 1
797
 * return Always 1
763
 */
798
 */
764
int cmd_ipc_task(cmd_arg_t * argv) {
799
int cmd_ipc_task(cmd_arg_t * argv) {
765
    ipc_print_task(argv[0].intval);
800
    ipc_print_task(argv[0].intval);
766
    return 1;
801
    return 1;
767
}
802
}
768
 
803
 
769
 
804
 
770
/** Command for listing processors.
805
/** Command for listing processors.
771
 *
806
 *
772
 * @param argv Ignored.
807
 * @param argv Ignored.
773
 *
808
 *
774
 * return Always 1.
809
 * return Always 1.
775
 */
810
 */
776
int cmd_cpus(cmd_arg_t *argv)
811
int cmd_cpus(cmd_arg_t *argv)
777
{
812
{
778
    cpu_list();
813
    cpu_list();
779
    return 1;
814
    return 1;
780
}
815
}
781
 
816
 
782
/** Command for printing kernel version.
817
/** Command for printing kernel version.
783
 *
818
 *
784
 * @param argv Ignored.
819
 * @param argv Ignored.
785
 *
820
 *
786
 * return Always 1.
821
 * return Always 1.
787
 */
822
 */
788
int cmd_version(cmd_arg_t *argv)
823
int cmd_version(cmd_arg_t *argv)
789
{
824
{
790
    version_print();
825
    version_print();
791
    return 1;
826
    return 1;
792
}
827
}
793
 
828
 
794
/** Command for returning console back to userspace.
829
/** Command for returning console back to userspace.
795
 *
830
 *
796
 * @param argv Ignored.
831
 * @param argv Ignored.
797
 *
832
 *
798
 * return Always 1.
833
 * return Always 1.
799
 */
834
 */
800
int cmd_continue(cmd_arg_t *argv)
835
int cmd_continue(cmd_arg_t *argv)
801
{
836
{
802
    printf("The kernel will now relinquish the console.\n");
837
    printf("The kernel will now relinquish the console.\n");
803
    printf("Use userspace controls to redraw the screen.\n");
838
    printf("Use userspace controls to redraw the screen.\n");
804
    arch_release_console();
839
    arch_release_console();
805
    return 1;
840
    return 1;
-
 
841
}
-
 
842
 
-
 
843
/** Command for printing kernel tests list.
-
 
844
 *
-
 
845
 * @param argv Ignored.
-
 
846
 *
-
 
847
 * return Always 1.
-
 
848
 */
-
 
849
int cmd_tests(cmd_arg_t *argv)
-
 
850
{
-
 
851
    test_t *test;
-
 
852
   
-
 
853
    for (test = tests; test->name != NULL; test++)
-
 
854
        printf("%s\t%s\n", test->name, test->desc);
-
 
855
   
-
 
856
    return 1;
-
 
857
}
-
 
858
 
-
 
859
/** Command for returning kernel tests
-
 
860
 *
-
 
861
 * @param argv Argument vector.
-
 
862
 *
-
 
863
 * return Always 1.
-
 
864
 */
-
 
865
int cmd_test(cmd_arg_t *argv)
-
 
866
{
-
 
867
    bool fnd = false;
-
 
868
    test_t *test;
-
 
869
   
-
 
870
    for (test = tests; test->name != NULL; test++) {
-
 
871
        if (strcmp(test->name, argv->buffer) == 0) {
-
 
872
            fnd = true;
-
 
873
            test->entry();
-
 
874
            break;
-
 
875
        }
-
 
876
    }
-
 
877
   
-
 
878
    if (!fnd)
-
 
879
        printf("Unknown test.\n");
-
 
880
   
-
 
881
    return 1;
806
}
882
}
807
 
883
 
808
/** @}
884
/** @}
809
 */
885
 */
810
 
886