Subversion Repositories HelenOS

Rev

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

Rev 4341 Rev 4342
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 <arch/types.h>
48
#include <arch/types.h>
49
#include <adt/list.h>
49
#include <adt/list.h>
50
#include <arch.h>
50
#include <arch.h>
51
#include <config.h>
51
#include <config.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
68
#ifdef CONFIG_TEST
69
#include <test.h>
69
#include <test.h>
70
#endif
70
#endif
71
 
71
 
72
/* Data and methods for 'help' command. */
72
/* Data and methods for 'help' command. */
73
static int cmd_help(cmd_arg_t *argv);
73
static int cmd_help(cmd_arg_t *argv);
74
static cmd_info_t help_info = {
74
static cmd_info_t help_info = {
75
    .name = "help",
75
    .name = "help",
76
    .description = "List of supported commands.",
76
    .description = "List of supported commands.",
77
    .func = cmd_help,
77
    .func = cmd_help,
78
    .argc = 0
78
    .argc = 0
79
};
79
};
80
 
80
 
81
static cmd_info_t exit_info = {
81
static cmd_info_t exit_info = {
82
    .name = "exit",
82
    .name = "exit",
83
    .description = "Exit kconsole.",
83
    .description = "Exit kconsole.",
84
    .argc = 0
84
    .argc = 0
85
};
85
};
86
 
86
 
87
static int cmd_reboot(cmd_arg_t *argv);
87
static int cmd_reboot(cmd_arg_t *argv);
88
static cmd_info_t reboot_info = {
88
static cmd_info_t reboot_info = {
89
    .name = "reboot",
89
    .name = "reboot",
90
    .description = "Reboot.",
90
    .description = "Reboot.",
91
    .func = cmd_reboot,
91
    .func = cmd_reboot,
92
    .argc = 0
92
    .argc = 0
93
};
93
};
94
 
94
 
95
static int cmd_uptime(cmd_arg_t *argv);
95
static int cmd_uptime(cmd_arg_t *argv);
96
static cmd_info_t uptime_info = {
96
static cmd_info_t uptime_info = {
97
    .name = "uptime",
97
    .name = "uptime",
98
    .description = "Print uptime information.",
98
    .description = "Print uptime information.",
99
    .func = cmd_uptime,
99
    .func = cmd_uptime,
100
    .argc = 0
100
    .argc = 0
101
};
101
};
102
 
102
 
103
static int cmd_continue(cmd_arg_t *argv);
103
static int cmd_continue(cmd_arg_t *argv);
104
static cmd_info_t continue_info = {
104
static cmd_info_t continue_info = {
105
    .name = "continue",
105
    .name = "continue",
106
    .description = "Return console back to userspace.",
106
    .description = "Return console back to userspace.",
107
    .func = cmd_continue,
107
    .func = cmd_continue,
108
    .argc = 0
108
    .argc = 0
109
};
109
};
110
 
110
 
111
#ifdef CONFIG_TEST
111
#ifdef CONFIG_TEST
112
static int cmd_tests(cmd_arg_t *argv);
112
static int cmd_tests(cmd_arg_t *argv);
113
static cmd_info_t tests_info = {
113
static cmd_info_t tests_info = {
114
    .name = "tests",
114
    .name = "tests",
115
    .description = "Print available kernel tests.",
115
    .description = "Print available kernel tests.",
116
    .func = cmd_tests,
116
    .func = cmd_tests,
117
    .argc = 0
117
    .argc = 0
118
};
118
};
119
 
119
 
120
static char test_buf[MAX_CMDLINE + 1];
120
static char test_buf[MAX_CMDLINE + 1];
121
static int cmd_test(cmd_arg_t *argv);
121
static int cmd_test(cmd_arg_t *argv);
122
static cmd_arg_t test_argv[] = {
122
static cmd_arg_t test_argv[] = {
123
    {
123
    {
124
        .type = ARG_TYPE_STRING,
124
        .type = ARG_TYPE_STRING,
125
        .buffer = test_buf,
125
        .buffer = test_buf,
126
        .len = sizeof(test_buf)
126
        .len = sizeof(test_buf)
127
    }
127
    }
128
};
128
};
129
static cmd_info_t test_info = {
129
static cmd_info_t test_info = {
130
    .name = "test",
130
    .name = "test",
131
    .description = "Run kernel test.",
131
    .description = "Run kernel test.",
132
    .func = cmd_test,
132
    .func = cmd_test,
133
    .argc = 1,
133
    .argc = 1,
134
    .argv = test_argv
134
    .argv = test_argv
135
};
135
};
136
 
136
 
137
static int cmd_bench(cmd_arg_t *argv);
137
static int cmd_bench(cmd_arg_t *argv);
138
static cmd_arg_t bench_argv[] = {
138
static cmd_arg_t bench_argv[] = {
139
    {
139
    {
140
        .type = ARG_TYPE_STRING,
140
        .type = ARG_TYPE_STRING,
141
        .buffer = test_buf,
141
        .buffer = test_buf,
142
        .len = sizeof(test_buf)
142
        .len = sizeof(test_buf)
143
    },
143
    },
144
    {
144
    {
145
        .type = ARG_TYPE_INT,
145
        .type = ARG_TYPE_INT,
146
    }
146
    }
147
};
147
};
148
static cmd_info_t bench_info = {
148
static cmd_info_t bench_info = {
149
    .name = "bench",
149
    .name = "bench",
150
    .description = "Run kernel test as benchmark.",
150
    .description = "Run kernel test as benchmark.",
151
    .func = cmd_bench,
151
    .func = cmd_bench,
152
    .argc = 2,
152
    .argc = 2,
153
    .argv = bench_argv
153
    .argv = bench_argv
154
};
154
};
155
#endif
155
#endif
156
 
156
 
157
/* Data and methods for 'description' command. */
157
/* Data and methods for 'description' command. */
158
static int cmd_desc(cmd_arg_t *argv);
158
static int cmd_desc(cmd_arg_t *argv);
159
static void desc_help(void);
159
static void desc_help(void);
160
static char desc_buf[MAX_CMDLINE+1];
160
static char desc_buf[MAX_CMDLINE+1];
161
static cmd_arg_t desc_argv = {
161
static cmd_arg_t desc_argv = {
162
    .type = ARG_TYPE_STRING,
162
    .type = ARG_TYPE_STRING,
163
    .buffer = desc_buf,
163
    .buffer = desc_buf,
164
    .len = sizeof(desc_buf)
164
    .len = sizeof(desc_buf)
165
};
165
};
166
static cmd_info_t desc_info = {
166
static cmd_info_t desc_info = {
167
    .name = "describe",
167
    .name = "describe",
168
    .description = "Describe specified command.",
168
    .description = "Describe specified command.",
169
    .help = desc_help,
169
    .help = desc_help,
170
    .func = cmd_desc,
170
    .func = cmd_desc,
171
    .argc = 1,
171
    .argc = 1,
172
    .argv = &desc_argv
172
    .argv = &desc_argv
173
};
173
};
174
 
174
 
175
/* Data and methods for 'symaddr' command. */
175
/* Data and methods for 'symaddr' command. */
176
static int cmd_symaddr(cmd_arg_t *argv);
176
static int cmd_symaddr(cmd_arg_t *argv);
177
static char symaddr_buf[MAX_CMDLINE+1];
177
static char symaddr_buf[MAX_CMDLINE+1];
178
static cmd_arg_t symaddr_argv = {
178
static cmd_arg_t symaddr_argv = {
179
    .type = ARG_TYPE_STRING,
179
    .type = ARG_TYPE_STRING,
180
    .buffer = symaddr_buf,
180
    .buffer = symaddr_buf,
181
    .len = sizeof(symaddr_buf)
181
    .len = sizeof(symaddr_buf)
182
};
182
};
183
static cmd_info_t symaddr_info = {
183
static cmd_info_t symaddr_info = {
184
    .name = "symaddr",
184
    .name = "symaddr",
185
    .description = "Return symbol address.",
185
    .description = "Return symbol address.",
186
    .func = cmd_symaddr,
186
    .func = cmd_symaddr,
187
    .argc = 1,
187
    .argc = 1,
188
    .argv = &symaddr_argv
188
    .argv = &symaddr_argv
189
};
189
};
190
 
190
 
191
static char set_buf[MAX_CMDLINE+1];
191
static char set_buf[MAX_CMDLINE+1];
192
static int cmd_set4(cmd_arg_t *argv);
192
static int cmd_set4(cmd_arg_t *argv);
193
static cmd_arg_t set4_argv[] = {
193
static cmd_arg_t set4_argv[] = {
194
    {
194
    {
195
        .type = ARG_TYPE_STRING,
195
        .type = ARG_TYPE_STRING,
196
        .buffer = set_buf,
196
        .buffer = set_buf,
197
        .len = sizeof(set_buf)
197
        .len = sizeof(set_buf)
198
    },
198
    },
199
    {
199
    {
200
        .type = ARG_TYPE_INT
200
        .type = ARG_TYPE_INT
201
    }
201
    }
202
};
202
};
203
static cmd_info_t set4_info = {
203
static cmd_info_t set4_info = {
204
    .name = "set4",
204
    .name = "set4",
205
    .description = "set <dest_addr> <value> - 4byte version",
205
    .description = "set <dest_addr> <value> - 4byte version",
206
    .func = cmd_set4,
206
    .func = cmd_set4,
207
    .argc = 2,
207
    .argc = 2,
208
    .argv = set4_argv
208
    .argv = set4_argv
209
};
209
};
210
 
210
 
211
/* Data and methods for 'call0' command. */
211
/* Data and methods for 'call0' command. */
212
static char call0_buf[MAX_CMDLINE + 1];
212
static char call0_buf[MAX_CMDLINE + 1];
213
static char carg1_buf[MAX_CMDLINE + 1];
213
static char carg1_buf[MAX_CMDLINE + 1];
214
static char carg2_buf[MAX_CMDLINE + 1];
214
static char carg2_buf[MAX_CMDLINE + 1];
215
static char carg3_buf[MAX_CMDLINE + 1];
215
static char carg3_buf[MAX_CMDLINE + 1];
216
 
216
 
217
static int cmd_call0(cmd_arg_t *argv);
217
static int cmd_call0(cmd_arg_t *argv);
218
static cmd_arg_t call0_argv = {
218
static cmd_arg_t call0_argv = {
219
    .type = ARG_TYPE_STRING,
219
    .type = ARG_TYPE_STRING,
220
    .buffer = call0_buf,
220
    .buffer = call0_buf,
221
    .len = sizeof(call0_buf)
221
    .len = sizeof(call0_buf)
222
};
222
};
223
static cmd_info_t call0_info = {
223
static cmd_info_t call0_info = {
224
    .name = "call0",
224
    .name = "call0",
225
    .description = "call0 <function> -> call function().",
225
    .description = "call0 <function> -> call function().",
226
    .func = cmd_call0,
226
    .func = cmd_call0,
227
    .argc = 1,
227
    .argc = 1,
228
    .argv = &call0_argv
228
    .argv = &call0_argv
229
};
229
};
230
 
230
 
231
/* Data and methods for 'mcall0' command. */
231
/* Data and methods for 'mcall0' command. */
232
static int cmd_mcall0(cmd_arg_t *argv);
232
static int cmd_mcall0(cmd_arg_t *argv);
233
static cmd_arg_t mcall0_argv = {
233
static cmd_arg_t mcall0_argv = {
234
    .type = ARG_TYPE_STRING,
234
    .type = ARG_TYPE_STRING,
235
    .buffer = call0_buf,
235
    .buffer = call0_buf,
236
    .len = sizeof(call0_buf)
236
    .len = sizeof(call0_buf)
237
};
237
};
238
static cmd_info_t mcall0_info = {
238
static cmd_info_t mcall0_info = {
239
    .name = "mcall0",
239
    .name = "mcall0",
240
    .description = "mcall0 <function> -> call function() on each CPU.",
240
    .description = "mcall0 <function> -> call function() on each CPU.",
241
    .func = cmd_mcall0,
241
    .func = cmd_mcall0,
242
    .argc = 1,
242
    .argc = 1,
243
    .argv = &mcall0_argv
243
    .argv = &mcall0_argv
244
};
244
};
245
 
245
 
246
/* Data and methods for 'call1' command. */
246
/* Data and methods for 'call1' command. */
247
static int cmd_call1(cmd_arg_t *argv);
247
static int cmd_call1(cmd_arg_t *argv);
248
static cmd_arg_t call1_argv[] = {
248
static cmd_arg_t call1_argv[] = {
249
    {
249
    {
250
        .type = ARG_TYPE_STRING,
250
        .type = ARG_TYPE_STRING,
251
        .buffer = call0_buf,
251
        .buffer = call0_buf,
252
        .len = sizeof(call0_buf)
252
        .len = sizeof(call0_buf)
253
    },
253
    },
254
    {
254
    {
255
        .type = ARG_TYPE_VAR,
255
        .type = ARG_TYPE_VAR,
256
        .buffer = carg1_buf,
256
        .buffer = carg1_buf,
257
        .len = sizeof(carg1_buf)
257
        .len = sizeof(carg1_buf)
258
    }
258
    }
259
};
259
};
260
static cmd_info_t call1_info = {
260
static cmd_info_t call1_info = {
261
    .name = "call1",
261
    .name = "call1",
262
    .description = "call1 <function> <arg1> -> call function(arg1).",
262
    .description = "call1 <function> <arg1> -> call function(arg1).",
263
    .func = cmd_call1,
263
    .func = cmd_call1,
264
    .argc = 2,
264
    .argc = 2,
265
    .argv = call1_argv
265
    .argv = call1_argv
266
};
266
};
267
 
267
 
268
/* Data and methods for 'call2' command. */
268
/* Data and methods for 'call2' command. */
269
static int cmd_call2(cmd_arg_t *argv);
269
static int cmd_call2(cmd_arg_t *argv);
270
static cmd_arg_t call2_argv[] = {
270
static cmd_arg_t call2_argv[] = {
271
    {
271
    {
272
        .type = ARG_TYPE_STRING,
272
        .type = ARG_TYPE_STRING,
273
        .buffer = call0_buf,
273
        .buffer = call0_buf,
274
        .len = sizeof(call0_buf)
274
        .len = sizeof(call0_buf)
275
    },
275
    },
276
    {
276
    {
277
        .type = ARG_TYPE_VAR,
277
        .type = ARG_TYPE_VAR,
278
        .buffer = carg1_buf,
278
        .buffer = carg1_buf,
279
        .len = sizeof(carg1_buf)
279
        .len = sizeof(carg1_buf)
280
    },
280
    },
281
    {
281
    {
282
        .type = ARG_TYPE_VAR,
282
        .type = ARG_TYPE_VAR,
283
        .buffer = carg2_buf,
283
        .buffer = carg2_buf,
284
        .len = sizeof(carg2_buf)
284
        .len = sizeof(carg2_buf)
285
    }
285
    }
286
};
286
};
287
static cmd_info_t call2_info = {
287
static cmd_info_t call2_info = {
288
    .name = "call2",
288
    .name = "call2",
289
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
289
    .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
290
    .func = cmd_call2,
290
    .func = cmd_call2,
291
    .argc = 3,
291
    .argc = 3,
292
    .argv = call2_argv
292
    .argv = call2_argv
293
};
293
};
294
 
294
 
295
/* Data and methods for 'call3' command. */
295
/* Data and methods for 'call3' command. */
296
static int cmd_call3(cmd_arg_t *argv);
296
static int cmd_call3(cmd_arg_t *argv);
297
static cmd_arg_t call3_argv[] = {
297
static cmd_arg_t call3_argv[] = {
298
    {
298
    {
299
        .type = ARG_TYPE_STRING,
299
        .type = ARG_TYPE_STRING,
300
        .buffer = call0_buf,
300
        .buffer = call0_buf,
301
        .len = sizeof(call0_buf)
301
        .len = sizeof(call0_buf)
302
    },
302
    },
303
    {
303
    {
304
        .type = ARG_TYPE_VAR,
304
        .type = ARG_TYPE_VAR,
305
        .buffer = carg1_buf,
305
        .buffer = carg1_buf,
306
        .len = sizeof(carg1_buf)
306
        .len = sizeof(carg1_buf)
307
    },
307
    },
308
    {
308
    {
309
        .type = ARG_TYPE_VAR,
309
        .type = ARG_TYPE_VAR,
310
        .buffer = carg2_buf,
310
        .buffer = carg2_buf,
311
        .len = sizeof(carg2_buf)
311
        .len = sizeof(carg2_buf)
312
    },
312
    },
313
    {
313
    {
314
        .type = ARG_TYPE_VAR,
314
        .type = ARG_TYPE_VAR,
315
        .buffer = carg3_buf,
315
        .buffer = carg3_buf,
316
        .len = sizeof(carg3_buf)
316
        .len = sizeof(carg3_buf)
317
    }
317
    }
318
 
318
 
319
};
319
};
320
static cmd_info_t call3_info = {
320
static cmd_info_t call3_info = {
321
    .name = "call3",
321
    .name = "call3",
322
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
322
    .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
323
    .func = cmd_call3,
323
    .func = cmd_call3,
324
    .argc = 4,
324
    .argc = 4,
325
    .argv = call3_argv
325
    .argv = call3_argv
326
};
326
};
327
 
327
 
328
/* Data and methods for 'halt' command. */
328
/* Data and methods for 'halt' command. */
329
static int cmd_halt(cmd_arg_t *argv);
329
static int cmd_halt(cmd_arg_t *argv);
330
static cmd_info_t halt_info = {
330
static cmd_info_t halt_info = {
331
    .name = "halt",
331
    .name = "halt",
332
    .description = "Halt the kernel.",
332
    .description = "Halt the kernel.",
333
    .func = cmd_halt,
333
    .func = cmd_halt,
334
    .argc = 0
334
    .argc = 0
335
};
335
};
336
 
336
 
337
/* Data and methods for 'physmem' command. */
337
/* Data and methods for 'physmem' command. */
338
static int cmd_physmem(cmd_arg_t *argv);
338
static int cmd_physmem(cmd_arg_t *argv);
339
cmd_info_t physmem_info = {
339
cmd_info_t physmem_info = {
340
    .name = "physmem",
340
    .name = "physmem",
341
    .description = "Print physical memory configuration.",
341
    .description = "Print physical memory configuration.",
342
    .help = NULL,
342
    .help = NULL,
343
    .func = cmd_physmem,
343
    .func = cmd_physmem,
344
    .argc = 0,
344
    .argc = 0,
345
    .argv = NULL
345
    .argv = NULL
346
};
346
};
347
 
347
 
348
/* Data and methods for 'tlb' command. */
348
/* Data and methods for 'tlb' command. */
349
static int cmd_tlb(cmd_arg_t *argv);
349
static int cmd_tlb(cmd_arg_t *argv);
350
cmd_info_t tlb_info = {
350
cmd_info_t tlb_info = {
351
    .name = "tlb",
351
    .name = "tlb",
352
    .description = "Print TLB of current processor.",
352
    .description = "Print TLB of current processor.",
353
    .help = NULL,
353
    .help = NULL,
354
    .func = cmd_tlb,
354
    .func = cmd_tlb,
355
    .argc = 0,
355
    .argc = 0,
356
    .argv = NULL
356
    .argv = NULL
357
};
357
};
358
 
358
 
359
static int cmd_threads(cmd_arg_t *argv);
359
static int cmd_threads(cmd_arg_t *argv);
360
static cmd_info_t threads_info = {
360
static cmd_info_t threads_info = {
361
    .name = "threads",
361
    .name = "threads",
362
    .description = "List all threads.",
362
    .description = "List all threads.",
363
    .func = cmd_threads,
363
    .func = cmd_threads,
364
    .argc = 0
364
    .argc = 0
365
};
365
};
366
 
366
 
367
static int cmd_tasks(cmd_arg_t *argv);
367
static int cmd_tasks(cmd_arg_t *argv);
368
static cmd_info_t tasks_info = {
368
static cmd_info_t tasks_info = {
369
    .name = "tasks",
369
    .name = "tasks",
370
    .description = "List all tasks.",
370
    .description = "List all tasks.",
371
    .func = cmd_tasks,
371
    .func = cmd_tasks,
372
    .argc = 0
372
    .argc = 0
373
};
373
};
374
 
374
 
375
 
375
 
376
static int cmd_sched(cmd_arg_t *argv);
376
static int cmd_sched(cmd_arg_t *argv);
377
static cmd_info_t sched_info = {
377
static cmd_info_t sched_info = {
378
    .name = "scheduler",
378
    .name = "scheduler",
379
    .description = "List all scheduler information.",
379
    .description = "List all scheduler information.",
380
    .func = cmd_sched,
380
    .func = cmd_sched,
381
    .argc = 0
381
    .argc = 0
382
};
382
};
383
 
383
 
384
static int cmd_slabs(cmd_arg_t *argv);
384
static int cmd_slabs(cmd_arg_t *argv);
385
static cmd_info_t slabs_info = {
385
static cmd_info_t slabs_info = {
386
    .name = "slabs",
386
    .name = "slabs",
387
    .description = "List slab caches.",
387
    .description = "List slab caches.",
388
    .func = cmd_slabs,
388
    .func = cmd_slabs,
389
    .argc = 0
389
    .argc = 0
390
};
390
};
391
 
391
 
392
/* Data and methods for 'zones' command */
392
/* Data and methods for 'zones' command */
393
static int cmd_zones(cmd_arg_t *argv);
393
static int cmd_zones(cmd_arg_t *argv);
394
static cmd_info_t zones_info = {
394
static cmd_info_t zones_info = {
395
    .name = "zones",
395
    .name = "zones",
396
    .description = "List of memory zones.",
396
    .description = "List of memory zones.",
397
    .func = cmd_zones,
397
    .func = cmd_zones,
398
    .argc = 0
398
    .argc = 0
399
};
399
};
400
 
400
 
401
/* Data and methods for 'ipc' command */
401
/* Data and methods for 'ipc' command */
402
static int cmd_ipc(cmd_arg_t *argv);
402
static int cmd_ipc(cmd_arg_t *argv);
403
static cmd_arg_t ipc_argv = {
403
static cmd_arg_t ipc_argv = {
404
    .type = ARG_TYPE_INT,
404
    .type = ARG_TYPE_INT,
405
};
405
};
406
static cmd_info_t ipc_info = {
406
static cmd_info_t ipc_info = {
407
    .name = "ipc",
407
    .name = "ipc",
408
    .description = "ipc <taskid> Show IPC information of given task.",
408
    .description = "ipc <taskid> Show IPC information of given task.",
409
    .func = cmd_ipc,
409
    .func = cmd_ipc,
410
    .argc = 1,
410
    .argc = 1,
411
    .argv = &ipc_argv
411
    .argv = &ipc_argv
412
};
412
};
413
 
413
 
414
/* Data and methods for 'zone' command */
414
/* Data and methods for 'zone' command */
415
static int cmd_zone(cmd_arg_t *argv);
415
static int cmd_zone(cmd_arg_t *argv);
416
static cmd_arg_t zone_argv = {
416
static cmd_arg_t zone_argv = {
417
    .type = ARG_TYPE_INT,
417
    .type = ARG_TYPE_INT,
418
};
418
};
419
 
419
 
420
static cmd_info_t zone_info = {
420
static cmd_info_t zone_info = {
421
    .name = "zone",
421
    .name = "zone",
422
    .description = "Show memory zone structure.",
422
    .description = "Show memory zone structure.",
423
    .func = cmd_zone,
423
    .func = cmd_zone,
424
    .argc = 1,
424
    .argc = 1,
425
    .argv = &zone_argv
425
    .argv = &zone_argv
426
};
426
};
427
 
427
 
428
/* Data and methods for 'cpus' command. */
428
/* Data and methods for 'cpus' command. */
429
static int cmd_cpus(cmd_arg_t *argv);
429
static int cmd_cpus(cmd_arg_t *argv);
430
cmd_info_t cpus_info = {
430
cmd_info_t cpus_info = {
431
    .name = "cpus",
431
    .name = "cpus",
432
    .description = "List all processors.",
432
    .description = "List all processors.",
433
    .help = NULL,
433
    .help = NULL,
434
    .func = cmd_cpus,
434
    .func = cmd_cpus,
435
    .argc = 0,
435
    .argc = 0,
436
    .argv = NULL
436
    .argv = NULL
437
};
437
};
438
 
438
 
439
/* Data and methods for 'version' command. */
439
/* Data and methods for 'version' command. */
440
static int cmd_version(cmd_arg_t *argv);
440
static int cmd_version(cmd_arg_t *argv);
441
cmd_info_t version_info = {
441
cmd_info_t version_info = {
442
    .name = "version",
442
    .name = "version",
443
    .description = "Print version information.",
443
    .description = "Print version information.",
444
    .help = NULL,
444
    .help = NULL,
445
    .func = cmd_version,
445
    .func = cmd_version,
446
    .argc = 0,
446
    .argc = 0,
447
    .argv = NULL
447
    .argv = NULL
448
};
448
};
449
 
449
 
450
static cmd_info_t *basic_commands[] = {
450
static cmd_info_t *basic_commands[] = {
451
    &call0_info,
451
    &call0_info,
452
    &mcall0_info,
452
    &mcall0_info,
453
    &call1_info,
453
    &call1_info,
454
    &call2_info,
454
    &call2_info,
455
    &call3_info,
455
    &call3_info,
456
    &continue_info,
456
    &continue_info,
457
    &cpus_info,
457
    &cpus_info,
458
    &desc_info,
458
    &desc_info,
459
    &exit_info,
459
    &exit_info,
460
    &reboot_info,
460
    &reboot_info,
461
    &uptime_info,
461
    &uptime_info,
462
    &halt_info,
462
    &halt_info,
463
    &help_info,
463
    &help_info,
464
    &ipc_info,
464
    &ipc_info,
465
    &set4_info,
465
    &set4_info,
466
    &slabs_info,
466
    &slabs_info,
467
    &symaddr_info,
467
    &symaddr_info,
468
    &sched_info,
468
    &sched_info,
469
    &threads_info,
469
    &threads_info,
470
    &tasks_info,
470
    &tasks_info,
471
    &physmem_info,
471
    &physmem_info,
472
    &tlb_info,
472
    &tlb_info,
473
    &version_info,
473
    &version_info,
474
    &zones_info,
474
    &zones_info,
475
    &zone_info,
475
    &zone_info,
476
#ifdef CONFIG_TEST
476
#ifdef CONFIG_TEST
477
    &tests_info,
477
    &tests_info,
478
    &test_info,
478
    &test_info,
479
    &bench_info,
479
    &bench_info,
480
#endif
480
#endif
481
    NULL
481
    NULL
482
};
482
};
483
 
483
 
484
 
484
 
485
/** Initialize command info structure.
485
/** Initialize command info structure.
486
 *
486
 *
487
 * @param cmd Command info structure.
487
 * @param cmd Command info structure.
488
 *
488
 *
489
 */
489
 */
490
void cmd_initialize(cmd_info_t *cmd)
490
void cmd_initialize(cmd_info_t *cmd)
491
{
491
{
492
    spinlock_initialize(&cmd->lock, "cmd");
492
    spinlock_initialize(&cmd->lock, "cmd");
493
    link_initialize(&cmd->link);
493
    link_initialize(&cmd->link);
494
}
494
}
495
 
495
 
496
/** Initialize and register commands. */
496
/** Initialize and register commands. */
497
void cmd_init(void)
497
void cmd_init(void)
498
{
498
{
499
    unsigned int i;
499
    unsigned int i;
500
 
500
 
501
    for (i = 0; basic_commands[i]; i++) {
501
    for (i = 0; basic_commands[i]; i++) {
502
        cmd_initialize(basic_commands[i]);
502
        cmd_initialize(basic_commands[i]);
503
        if (!cmd_register(basic_commands[i]))
503
        if (!cmd_register(basic_commands[i]))
504
            printf("Cannot register command %s\n", basic_commands[i]->name);
504
            printf("Cannot register command %s\n", basic_commands[i]->name);
505
    }
505
    }
506
}
506
}
507
 
507
 
508
 
508
 
509
/** List supported commands.
509
/** List supported commands.
510
 *
510
 *
511
 * @param argv Argument vector.
511
 * @param argv Argument vector.
512
 *
512
 *
513
 * @return 0 on failure, 1 on success.
513
 * @return 0 on failure, 1 on success.
514
 */
514
 */
515
int cmd_help(cmd_arg_t *argv)
515
int cmd_help(cmd_arg_t *argv)
516
{
516
{
517
    link_t *cur;
517
    link_t *cur;
518
 
518
 
519
    spinlock_lock(&cmd_lock);
519
    spinlock_lock(&cmd_lock);
520
   
520
   
521
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
521
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
522
        cmd_info_t *hlp;
522
        cmd_info_t *hlp;
523
       
523
       
524
        hlp = list_get_instance(cur, cmd_info_t, link);
524
        hlp = list_get_instance(cur, cmd_info_t, link);
525
        spinlock_lock(&hlp->lock);
525
        spinlock_lock(&hlp->lock);
526
       
526
       
527
        printf("%s - %s\n", hlp->name, hlp->description);
527
        printf("%s - %s\n", hlp->name, hlp->description);
528
 
528
 
529
        spinlock_unlock(&hlp->lock);
529
        spinlock_unlock(&hlp->lock);
530
    }
530
    }
531
   
531
   
532
    spinlock_unlock(&cmd_lock);
532
    spinlock_unlock(&cmd_lock);
533
 
533
 
534
    return 1;
534
    return 1;
535
}
535
}
536
 
536
 
537
 
537
 
538
/** Reboot the system.
538
/** Reboot the system.
539
 *
539
 *
540
 * @param argv Argument vector.
540
 * @param argv Argument vector.
541
 *
541
 *
542
 * @return 0 on failure, 1 on success.
542
 * @return 0 on failure, 1 on success.
543
 */
543
 */
544
int cmd_reboot(cmd_arg_t *argv)
544
int cmd_reboot(cmd_arg_t *argv)
545
{
545
{
546
    reboot();
546
    reboot();
547
   
547
   
548
    /* Not reached */
548
    /* Not reached */
549
    return 1;
549
    return 1;
550
}
550
}
551
 
551
 
552
 
552
 
553
/** Print system uptime information.
553
/** Print system uptime information.
554
 *
554
 *
555
 * @param argv Argument vector.
555
 * @param argv Argument vector.
556
 *
556
 *
557
 * @return 0 on failure, 1 on success.
557
 * @return 0 on failure, 1 on success.
558
 */
558
 */
559
int cmd_uptime(cmd_arg_t *argv)
559
int cmd_uptime(cmd_arg_t *argv)
560
{
560
{
561
    ASSERT(uptime);
561
    ASSERT(uptime);
562
   
562
   
563
    /* This doesn't have to be very accurate */
563
    /* This doesn't have to be very accurate */
564
    unative_t sec = uptime->seconds1;
564
    unative_t sec = uptime->seconds1;
565
   
565
   
566
    printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
566
    printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
567
        sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
567
        sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
568
   
568
   
569
    return 1;
569
    return 1;
570
}
570
}
571
 
571
 
572
/** Describe specified command.
572
/** Describe specified command.
573
 *
573
 *
574
 * @param argv Argument vector.
574
 * @param argv Argument vector.
575
 *
575
 *
576
 * @return 0 on failure, 1 on success.
576
 * @return 0 on failure, 1 on success.
577
 */
577
 */
578
int cmd_desc(cmd_arg_t *argv)
578
int cmd_desc(cmd_arg_t *argv)
579
{
579
{
580
    link_t *cur;
580
    link_t *cur;
581
 
581
 
582
    spinlock_lock(&cmd_lock);
582
    spinlock_lock(&cmd_lock);
583
   
583
   
584
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
584
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
585
        cmd_info_t *hlp;
585
        cmd_info_t *hlp;
586
       
586
       
587
        hlp = list_get_instance(cur, cmd_info_t, link);
587
        hlp = list_get_instance(cur, cmd_info_t, link);
588
        spinlock_lock(&hlp->lock);
588
        spinlock_lock(&hlp->lock);
589
 
589
 
590
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
590
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
591
            printf("%s - %s\n", hlp->name, hlp->description);
591
            printf("%s - %s\n", hlp->name, hlp->description);
592
            if (hlp->help)
592
            if (hlp->help)
593
                hlp->help();
593
                hlp->help();
594
            spinlock_unlock(&hlp->lock);
594
            spinlock_unlock(&hlp->lock);
595
            break;
595
            break;
596
        }
596
        }
597
 
597
 
598
        spinlock_unlock(&hlp->lock);
598
        spinlock_unlock(&hlp->lock);
599
    }
599
    }
600
   
600
   
601
    spinlock_unlock(&cmd_lock);
601
    spinlock_unlock(&cmd_lock);
602
 
602
 
603
    return 1;
603
    return 1;
604
}
604
}
605
 
605
 
606
/** Search symbol table */
606
/** Search symbol table */
607
int cmd_symaddr(cmd_arg_t *argv)
607
int cmd_symaddr(cmd_arg_t *argv)
608
{
608
{
609
    symtab_print_search((char *) argv->buffer);
609
    symtab_print_search((char *) argv->buffer);
610
   
610
   
611
    return 1;
611
    return 1;
612
}
612
}
613
 
613
 
614
/** Call function with zero parameters */
614
/** Call function with zero parameters */
615
int cmd_call0(cmd_arg_t *argv)
615
int cmd_call0(cmd_arg_t *argv)
616
{
616
{
617
    uintptr_t symaddr;
617
    uintptr_t symaddr;
618
    char *symbol;
618
    char *symbol;
619
    unative_t (*f)(void);
619
    unative_t (*fnc)(void);
620
#ifdef ia64
-
 
621
    struct {
-
 
622
        unative_t f;
-
 
623
        unative_t gp;
620
    fncptr_t fptr;
624
    } fptr;
-
 
625
#endif
-
 
626
 
621
   
627
    symaddr = get_symbol_addr((char *) argv->buffer);
622
    symaddr = get_symbol_addr((char *) argv->buffer);
628
    if (!symaddr)
623
    if (!symaddr)
629
        printf("Symbol %s not found.\n", argv->buffer);
624
        printf("Symbol %s not found.\n", argv->buffer);
630
    else if (symaddr == (uintptr_t) -1) {
625
    else if (symaddr == (uintptr_t) -1) {
631
        symtab_print_search((char *) argv->buffer);
626
        symtab_print_search((char *) argv->buffer);
632
        printf("Duplicate symbol, be more specific.\n");
627
        printf("Duplicate symbol, be more specific.\n");
633
    } else {
628
    } else {
634
        symbol = get_symtab_entry(symaddr);
629
        symbol = get_symtab_entry(symaddr);
-
 
630
        fnc = (unative_t (*)(void)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call0);
635
        printf("Calling %s() (%p)\n", symbol, symaddr);
631
        printf("Calling %s() (%p)\n", symbol, symaddr);
636
#ifdef ia64
-
 
637
        fptr.f = symaddr;
-
 
638
        fptr.gp = ((unative_t *)cmd_call2)[1];
-
 
639
        f =  (unative_t (*)(void)) &fptr;
-
 
640
#else
-
 
641
        f =  (unative_t (*)(void)) symaddr;
-
 
642
#endif
-
 
643
        printf("Result: %#" PRIxn "\n", f());
632
        printf("Result: %#" PRIxn "\n", fnc());
644
    }
633
    }
645
   
634
   
646
    return 1;
635
    return 1;
647
}
636
}
648
 
637
 
649
/** Call function with zero parameters on each CPU */
638
/** Call function with zero parameters on each CPU */
650
int cmd_mcall0(cmd_arg_t *argv)
639
int cmd_mcall0(cmd_arg_t *argv)
651
{
640
{
652
    /*
641
    /*
653
     * For each CPU, create a thread which will
642
     * For each CPU, create a thread which will
654
     * call the function.
643
     * call the function.
655
     */
644
     */
656
   
645
   
657
    count_t i;
646
    count_t i;
658
    for (i = 0; i < config.cpu_count; i++) {
647
    for (i = 0; i < config.cpu_count; i++) {
659
        if (!cpus[i].active)
648
        if (!cpus[i].active)
660
            continue;
649
            continue;
661
       
650
       
662
        thread_t *t;
651
        thread_t *t;
663
        if ((t = thread_create((void (*)(void *)) cmd_call0, (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
652
        if ((t = thread_create((void (*)(void *)) cmd_call0, (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
664
            spinlock_lock(&t->lock);
653
            spinlock_lock(&t->lock);
665
            t->cpu = &cpus[i];
654
            t->cpu = &cpus[i];
666
            spinlock_unlock(&t->lock);
655
            spinlock_unlock(&t->lock);
667
            printf("cpu%u: ", i);
656
            printf("cpu%u: ", i);
668
            thread_ready(t);
657
            thread_ready(t);
669
            thread_join(t);
658
            thread_join(t);
670
            thread_detach(t);
659
            thread_detach(t);
671
        } else
660
        } else
672
            printf("Unable to create thread for cpu%u\n", i);
661
            printf("Unable to create thread for cpu%u\n", i);
673
    }
662
    }
674
   
663
   
675
    return 1;
664
    return 1;
676
}
665
}
677
 
666
 
678
/** Call function with one parameter */
667
/** Call function with one parameter */
679
int cmd_call1(cmd_arg_t *argv)
668
int cmd_call1(cmd_arg_t *argv)
680
{
669
{
681
    uintptr_t symaddr;
670
    uintptr_t symaddr;
682
    char *symbol;
671
    char *symbol;
683
    unative_t (*f)(unative_t,...);
672
    unative_t (*fnc)(unative_t, ...);
684
    unative_t arg1 = argv[1].intval;
673
    unative_t arg1 = argv[1].intval;
685
#ifdef ia64
-
 
686
    struct {
-
 
687
        unative_t f;
-
 
688
        unative_t gp;
674
    fncptr_t fptr;
689
    } fptr;
-
 
690
#endif
-
 
691
 
675
   
692
    symaddr = get_symbol_addr((char *) argv->buffer);
676
    symaddr = get_symbol_addr((char *) argv->buffer);
693
    if (!symaddr)
677
    if (!symaddr)
694
        printf("Symbol %s not found.\n", argv->buffer);
678
        printf("Symbol %s not found.\n", argv->buffer);
695
    else if (symaddr == (uintptr_t) -1) {
679
    else if (symaddr == (uintptr_t) -1) {
696
        symtab_print_search((char *) argv->buffer);
680
        symtab_print_search((char *) argv->buffer);
697
        printf("Duplicate symbol, be more specific.\n");
681
        printf("Duplicate symbol, be more specific.\n");
698
    } else {
682
    } else {
699
        symbol = get_symtab_entry(symaddr);
683
        symbol = get_symtab_entry(symaddr);
700
 
-
 
-
 
684
        fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1);
701
        printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
685
        printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
702
#ifdef ia64
-
 
703
        fptr.f = symaddr;
-
 
704
        fptr.gp = ((unative_t *)cmd_call2)[1];
-
 
705
        f =  (unative_t (*)(unative_t,...)) &fptr;
-
 
706
#else
-
 
707
        f =  (unative_t (*)(unative_t,...)) symaddr;
-
 
708
#endif
-
 
709
        printf("Result: %#" PRIxn "\n", f(arg1));
686
        printf("Result: %#" PRIxn "\n", fnc(arg1));
710
    }
687
    }
711
   
688
   
712
    return 1;
689
    return 1;
713
}
690
}
714
 
691
 
715
/** Call function with two parameters */
692
/** Call function with two parameters */
716
int cmd_call2(cmd_arg_t *argv)
693
int cmd_call2(cmd_arg_t *argv)
717
{
694
{
718
    uintptr_t symaddr;
695
    uintptr_t symaddr;
719
    char *symbol;
696
    char *symbol;
720
    unative_t (*f)(unative_t,unative_t,...);
697
    unative_t (*fnc)(unative_t, unative_t, ...);
721
    unative_t arg1 = argv[1].intval;
698
    unative_t arg1 = argv[1].intval;
722
    unative_t arg2 = argv[2].intval;
699
    unative_t arg2 = argv[2].intval;
723
#ifdef ia64
-
 
724
    struct {
-
 
725
        unative_t f;
-
 
726
        unative_t gp;
700
    fncptr_t fptr;
727
    }fptr;
-
 
728
#endif
-
 
729
 
701
   
730
    symaddr = get_symbol_addr((char *) argv->buffer);
702
    symaddr = get_symbol_addr((char *) argv->buffer);
731
    if (!symaddr)
703
    if (!symaddr)
732
        printf("Symbol %s not found.\n", argv->buffer);
704
        printf("Symbol %s not found.\n", argv->buffer);
733
    else if (symaddr == (uintptr_t) -1) {
705
    else if (symaddr == (uintptr_t) -1) {
734
        symtab_print_search((char *) argv->buffer);
706
        symtab_print_search((char *) argv->buffer);
735
        printf("Duplicate symbol, be more specific.\n");
707
        printf("Duplicate symbol, be more specific.\n");
736
    } else {
708
    } else {
737
        symbol = get_symtab_entry(symaddr);
709
        symbol = get_symtab_entry(symaddr);
-
 
710
        fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2);
738
        printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
711
        printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
739
               arg1, arg2, symaddr, symbol);
712
               arg1, arg2, symaddr, symbol);
740
#ifdef ia64
-
 
741
        fptr.f = symaddr;
-
 
742
        fptr.gp = ((unative_t *)cmd_call2)[1];
-
 
743
        f =  (unative_t (*)(unative_t,unative_t,...)) &fptr;
-
 
744
#else
-
 
745
        f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
-
 
746
#endif
-
 
747
        printf("Result: %#" PRIxn "\n", f(arg1, arg2));
713
        printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
748
    }
714
    }
749
   
715
   
750
    return 1;
716
    return 1;
751
}
717
}
752
 
718
 
753
/** Call function with three parameters */
719
/** Call function with three parameters */
754
int cmd_call3(cmd_arg_t *argv)
720
int cmd_call3(cmd_arg_t *argv)
755
{
721
{
756
    uintptr_t symaddr;
722
    uintptr_t symaddr;
757
    char *symbol;
723
    char *symbol;
758
    unative_t (*f)(unative_t,unative_t,unative_t,...);
724
    unative_t (*fnc)(unative_t, unative_t, unative_t, ...);
759
    unative_t arg1 = argv[1].intval;
725
    unative_t arg1 = argv[1].intval;
760
    unative_t arg2 = argv[2].intval;
726
    unative_t arg2 = argv[2].intval;
761
    unative_t arg3 = argv[3].intval;
727
    unative_t arg3 = argv[3].intval;
762
#ifdef ia64
-
 
763
    struct {
-
 
764
        unative_t f;
-
 
765
        unative_t gp;
728
    fncptr_t fptr;
766
    }fptr;
-
 
767
#endif
-
 
768
 
729
   
769
    symaddr = get_symbol_addr((char *) argv->buffer);
730
    symaddr = get_symbol_addr((char *) argv->buffer);
770
    if (!symaddr)
731
    if (!symaddr)
771
        printf("Symbol %s not found.\n", argv->buffer);
732
        printf("Symbol %s not found.\n", argv->buffer);
772
    else if (symaddr == (uintptr_t) -1) {
733
    else if (symaddr == (uintptr_t) -1) {
773
        symtab_print_search((char *) argv->buffer);
734
        symtab_print_search((char *) argv->buffer);
774
        printf("Duplicate symbol, be more specific.\n");
735
        printf("Duplicate symbol, be more specific.\n");
775
    } else {
736
    } else {
776
        symbol = get_symtab_entry(symaddr);
737
        symbol = get_symtab_entry(symaddr);
-
 
738
        fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3);
777
        printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
739
        printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
778
               arg1, arg2, arg3, symaddr, symbol);
740
               arg1, arg2, arg3, symaddr, symbol);
779
#ifdef ia64
-
 
780
        fptr.f = symaddr;
-
 
781
        fptr.gp = ((unative_t *)cmd_call2)[1];
-
 
782
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
-
 
783
#else
-
 
784
        f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
-
 
785
#endif
-
 
786
        printf("Result: %#" PRIxn "\n", f(arg1, arg2, arg3));
741
        printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
787
    }
742
    }
788
   
743
   
789
    return 1;
744
    return 1;
790
}
745
}
791
 
746
 
792
 
747
 
793
/** Print detailed description of 'describe' command. */
748
/** Print detailed description of 'describe' command. */
794
void desc_help(void)
749
void desc_help(void)
795
{
750
{
796
    printf("Syntax: describe command_name\n");
751
    printf("Syntax: describe command_name\n");
797
}
752
}
798
 
753
 
799
/** Halt the kernel.
754
/** Halt the kernel.
800
 *
755
 *
801
 * @param argv Argument vector (ignored).
756
 * @param argv Argument vector (ignored).
802
 *
757
 *
803
 * @return 0 on failure, 1 on success (never returns).
758
 * @return 0 on failure, 1 on success (never returns).
804
 */
759
 */
805
int cmd_halt(cmd_arg_t *argv)
760
int cmd_halt(cmd_arg_t *argv)
806
{
761
{
807
    halt();
762
    halt();
808
    return 1;
763
    return 1;
809
}
764
}
810
 
765
 
811
/** Command for printing TLB contents.
766
/** Command for printing TLB contents.
812
 *
767
 *
813
 * @param argv Not used.
768
 * @param argv Not used.
814
 *
769
 *
815
 * @return Always returns 1.
770
 * @return Always returns 1.
816
 */
771
 */
817
int cmd_tlb(cmd_arg_t *argv)
772
int cmd_tlb(cmd_arg_t *argv)
818
{
773
{
819
    tlb_print();
774
    tlb_print();
820
    return 1;
775
    return 1;
821
}
776
}
822
 
777
 
823
/** Command for printing physical memory configuration.
778
/** Command for printing physical memory configuration.
824
 *
779
 *
825
 * @param argv Not used.
780
 * @param argv Not used.
826
 *
781
 *
827
 * @return Always returns 1.
782
 * @return Always returns 1.
828
 */
783
 */
829
int cmd_physmem(cmd_arg_t *argv)
784
int cmd_physmem(cmd_arg_t *argv)
830
{
785
{
831
    physmem_print();
786
    physmem_print();
832
    return 1;
787
    return 1;
833
}
788
}
834
 
789
 
835
/** Write 4 byte value to address */
790
/** Write 4 byte value to address */
836
int cmd_set4(cmd_arg_t *argv)
791
int cmd_set4(cmd_arg_t *argv)
837
{
792
{
838
    uint32_t *addr;
793
    uint32_t *addr;
839
    uint32_t arg1 = argv[1].intval;
794
    uint32_t arg1 = argv[1].intval;
840
    bool pointer = false;
795
    bool pointer = false;
841
 
796
 
842
    if (((char *)argv->buffer)[0] == '*') {
797
    if (((char *)argv->buffer)[0] == '*') {
843
        addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1);
798
        addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1);
844
        pointer = true;
799
        pointer = true;
845
    } else if (((char *) argv->buffer)[0] >= '0' &&
800
    } else if (((char *) argv->buffer)[0] >= '0' &&
846
           ((char *)argv->buffer)[0] <= '9')
801
           ((char *)argv->buffer)[0] <= '9')
847
        addr = (uint32_t *)atoi((char *)argv->buffer);
802
        addr = (uint32_t *)atoi((char *)argv->buffer);
848
    else
803
    else
849
        addr = (uint32_t *)get_symbol_addr((char *) argv->buffer);
804
        addr = (uint32_t *)get_symbol_addr((char *) argv->buffer);
850
 
805
 
851
    if (!addr)
806
    if (!addr)
852
        printf("Symbol %s not found.\n", argv->buffer);
807
        printf("Symbol %s not found.\n", argv->buffer);
853
    else if (addr == (uint32_t *) -1) {
808
    else if (addr == (uint32_t *) -1) {
854
        symtab_print_search((char *) argv->buffer);
809
        symtab_print_search((char *) argv->buffer);
855
        printf("Duplicate symbol, be more specific.\n");
810
        printf("Duplicate symbol, be more specific.\n");
856
    } else {
811
    } else {
857
        if (pointer)
812
        if (pointer)
858
            addr = (uint32_t *)(*(unative_t *)addr);
813
            addr = (uint32_t *)(*(unative_t *)addr);
859
        printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
814
        printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
860
        *addr = arg1;
815
        *addr = arg1;
861
       
816
       
862
    }
817
    }
863
   
818
   
864
    return 1;
819
    return 1;
865
}
820
}
866
 
821
 
867
/** Command for listings SLAB caches
822
/** Command for listings SLAB caches
868
 *
823
 *
869
 * @param argv Ignores
824
 * @param argv Ignores
870
 *
825
 *
871
 * @return Always 1
826
 * @return Always 1
872
 */
827
 */
873
int cmd_slabs(cmd_arg_t * argv) {
828
int cmd_slabs(cmd_arg_t * argv) {
874
    slab_print_list();
829
    slab_print_list();
875
    return 1;
830
    return 1;
876
}
831
}
877
 
832
 
878
 
833
 
879
/** Command for listings Thread information
834
/** Command for listings Thread information
880
 *
835
 *
881
 * @param argv Ignores
836
 * @param argv Ignores
882
 *
837
 *
883
 * @return Always 1
838
 * @return Always 1
884
 */
839
 */
885
int cmd_threads(cmd_arg_t * argv) {
840
int cmd_threads(cmd_arg_t * argv) {
886
    thread_print_list();
841
    thread_print_list();
887
    return 1;
842
    return 1;
888
}
843
}
889
 
844
 
890
/** Command for listings Task information
845
/** Command for listings Task information
891
 *
846
 *
892
 * @param argv Ignores
847
 * @param argv Ignores
893
 *
848
 *
894
 * @return Always 1
849
 * @return Always 1
895
 */
850
 */
896
int cmd_tasks(cmd_arg_t * argv) {
851
int cmd_tasks(cmd_arg_t * argv) {
897
    task_print_list();
852
    task_print_list();
898
    return 1;
853
    return 1;
899
}
854
}
900
 
855
 
901
/** Command for listings Thread information
856
/** Command for listings Thread information
902
 *
857
 *
903
 * @param argv Ignores
858
 * @param argv Ignores
904
 *
859
 *
905
 * @return Always 1
860
 * @return Always 1
906
 */
861
 */
907
int cmd_sched(cmd_arg_t * argv) {
862
int cmd_sched(cmd_arg_t * argv) {
908
    sched_print_list();
863
    sched_print_list();
909
    return 1;
864
    return 1;
910
}
865
}
911
 
866
 
912
/** Command for listing memory zones
867
/** Command for listing memory zones
913
 *
868
 *
914
 * @param argv Ignored
869
 * @param argv Ignored
915
 *
870
 *
916
 * return Always 1
871
 * return Always 1
917
 */
872
 */
918
int cmd_zones(cmd_arg_t * argv) {
873
int cmd_zones(cmd_arg_t * argv) {
919
    zone_print_list();
874
    zone_print_list();
920
    return 1;
875
    return 1;
921
}
876
}
922
 
877
 
923
/** Command for memory zone details
878
/** Command for memory zone details
924
 *
879
 *
925
 * @param argv Integer argument from cmdline expected
880
 * @param argv Integer argument from cmdline expected
926
 *
881
 *
927
 * return Always 1
882
 * return Always 1
928
 */
883
 */
929
int cmd_zone(cmd_arg_t * argv) {
884
int cmd_zone(cmd_arg_t * argv) {
930
    zone_print_one(argv[0].intval);
885
    zone_print_one(argv[0].intval);
931
    return 1;
886
    return 1;
932
}
887
}
933
 
888
 
934
/** Command for printing task ipc details
889
/** Command for printing task ipc details
935
 *
890
 *
936
 * @param argv Integer argument from cmdline expected
891
 * @param argv Integer argument from cmdline expected
937
 *
892
 *
938
 * return Always 1
893
 * return Always 1
939
 */
894
 */
940
int cmd_ipc(cmd_arg_t * argv) {
895
int cmd_ipc(cmd_arg_t * argv) {
941
    ipc_print_task(argv[0].intval);
896
    ipc_print_task(argv[0].intval);
942
    return 1;
897
    return 1;
943
}
898
}
944
 
899
 
945
 
900
 
946
/** Command for listing processors.
901
/** Command for listing processors.
947
 *
902
 *
948
 * @param argv Ignored.
903
 * @param argv Ignored.
949
 *
904
 *
950
 * return Always 1.
905
 * return Always 1.
951
 */
906
 */
952
int cmd_cpus(cmd_arg_t *argv)
907
int cmd_cpus(cmd_arg_t *argv)
953
{
908
{
954
    cpu_list();
909
    cpu_list();
955
    return 1;
910
    return 1;
956
}
911
}
957
 
912
 
958
/** Command for printing kernel version.
913
/** Command for printing kernel version.
959
 *
914
 *
960
 * @param argv Ignored.
915
 * @param argv Ignored.
961
 *
916
 *
962
 * return Always 1.
917
 * return Always 1.
963
 */
918
 */
964
int cmd_version(cmd_arg_t *argv)
919
int cmd_version(cmd_arg_t *argv)
965
{
920
{
966
    version_print();
921
    version_print();
967
    return 1;
922
    return 1;
968
}
923
}
969
 
924
 
970
/** Command for returning console back to userspace.
925
/** Command for returning console back to userspace.
971
 *
926
 *
972
 * @param argv Ignored.
927
 * @param argv Ignored.
973
 *
928
 *
974
 * return Always 1.
929
 * return Always 1.
975
 */
930
 */
976
int cmd_continue(cmd_arg_t *argv)
931
int cmd_continue(cmd_arg_t *argv)
977
{
932
{
978
    printf("The kernel will now relinquish the console.\n");
933
    printf("The kernel will now relinquish the console.\n");
979
    release_console();
934
    release_console();
980
   
935
   
981
    if ((kconsole_notify) && (kconsole_irq.notif_cfg.notify))
936
    if ((kconsole_notify) && (kconsole_irq.notif_cfg.notify))
982
        ipc_irq_send_msg_0(&kconsole_irq);
937
        ipc_irq_send_msg_0(&kconsole_irq);
983
   
938
   
984
    return 1;
939
    return 1;
985
}
940
}
986
 
941
 
987
#ifdef CONFIG_TEST
942
#ifdef CONFIG_TEST
988
/** Command for printing kernel tests list.
943
/** Command for printing kernel tests list.
989
 *
944
 *
990
 * @param argv Ignored.
945
 * @param argv Ignored.
991
 *
946
 *
992
 * return Always 1.
947
 * return Always 1.
993
 */
948
 */
994
int cmd_tests(cmd_arg_t *argv)
949
int cmd_tests(cmd_arg_t *argv)
995
{
950
{
996
    test_t *test;
951
    test_t *test;
997
   
952
   
998
    for (test = tests; test->name != NULL; test++)
953
    for (test = tests; test->name != NULL; test++)
999
        printf("%s\t\t%s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)"));
954
        printf("%-10s %s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)"));
1000
   
955
   
1001
    printf("*\t\tRun all safe tests\n");
956
    printf("%-10s Run all safe tests\n", "*");
1002
    return 1;
957
    return 1;
1003
}
958
}
1004
 
959
 
1005
static bool run_test(const test_t *test)
960
static bool run_test(const test_t *test)
1006
{
961
{
1007
    printf("%s\t\t%s\n", test->name, test->desc);
962
    printf("%s\t\t%s\n", test->name, test->desc);
1008
   
963
   
1009
    /* Update and read thread accounting
964
    /* Update and read thread accounting
1010
       for benchmarking */
965
       for benchmarking */
1011
    ipl_t ipl = interrupts_disable();
966
    ipl_t ipl = interrupts_disable();
1012
    spinlock_lock(&TASK->lock);
967
    spinlock_lock(&TASK->lock);
1013
    uint64_t t0 = task_get_accounting(TASK);
968
    uint64_t t0 = task_get_accounting(TASK);
1014
    spinlock_unlock(&TASK->lock);
969
    spinlock_unlock(&TASK->lock);
1015
    interrupts_restore(ipl);
970
    interrupts_restore(ipl);
1016
   
971
   
1017
    /* Execute the test */
972
    /* Execute the test */
1018
    char * ret = test->entry(false);
973
    char * ret = test->entry(false);
1019
   
974
   
1020
    /* Update and read thread accounting */
975
    /* Update and read thread accounting */
1021
    ipl = interrupts_disable();
976
    ipl = interrupts_disable();
1022
    spinlock_lock(&TASK->lock);
977
    spinlock_lock(&TASK->lock);
1023
    uint64_t dt = task_get_accounting(TASK) - t0;
978
    uint64_t dt = task_get_accounting(TASK) - t0;
1024
    spinlock_unlock(&TASK->lock);
979
    spinlock_unlock(&TASK->lock);
1025
    interrupts_restore(ipl);
980
    interrupts_restore(ipl);
1026
   
981
   
1027
    uint64_t cycles;
982
    uint64_t cycles;
1028
    char suffix;
983
    char suffix;
1029
    order(dt, &cycles, &suffix);
984
    order(dt, &cycles, &suffix);
1030
       
985
       
1031
    printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix);
986
    printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix);
1032
   
987
   
1033
    if (ret == NULL) {
988
    if (ret == NULL) {
1034
        printf("Test passed\n");
989
        printf("Test passed\n");
1035
        return true;
990
        return true;
1036
    }
991
    }
1037
 
992
 
1038
    printf("%s\n", ret);
993
    printf("%s\n", ret);
1039
    return false;
994
    return false;
1040
}
995
}
1041
 
996
 
1042
static bool run_bench(const test_t *test, const uint32_t cnt)
997
static bool run_bench(const test_t *test, const uint32_t cnt)
1043
{
998
{
1044
    uint32_t i;
999
    uint32_t i;
1045
    bool ret = true;
1000
    bool ret = true;
1046
    uint64_t cycles;
1001
    uint64_t cycles;
1047
    char suffix;
1002
    char suffix;
1048
   
1003
   
1049
    if (cnt < 1)
1004
    if (cnt < 1)
1050
        return true;
1005
        return true;
1051
   
1006
   
1052
    uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt, 0);
1007
    uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt, 0);
1053
    if (data == NULL) {
1008
    if (data == NULL) {
1054
        printf("Error allocating memory for statistics\n");
1009
        printf("Error allocating memory for statistics\n");
1055
        return false;
1010
        return false;
1056
    }
1011
    }
1057
   
1012
   
1058
    for (i = 0; i < cnt; i++) {
1013
    for (i = 0; i < cnt; i++) {
1059
        printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
1014
        printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
1060
       
1015
       
1061
        /* Update and read thread accounting
1016
        /* Update and read thread accounting
1062
           for benchmarking */
1017
           for benchmarking */
1063
        ipl_t ipl = interrupts_disable();
1018
        ipl_t ipl = interrupts_disable();
1064
        spinlock_lock(&TASK->lock);
1019
        spinlock_lock(&TASK->lock);
1065
        uint64_t t0 = task_get_accounting(TASK);
1020
        uint64_t t0 = task_get_accounting(TASK);
1066
        spinlock_unlock(&TASK->lock);
1021
        spinlock_unlock(&TASK->lock);
1067
        interrupts_restore(ipl);
1022
        interrupts_restore(ipl);
1068
       
1023
       
1069
        /* Execute the test */
1024
        /* Execute the test */
1070
        char * ret = test->entry(true);
1025
        char * ret = test->entry(true);
1071
       
1026
       
1072
        /* Update and read thread accounting */
1027
        /* Update and read thread accounting */
1073
        ipl = interrupts_disable();
1028
        ipl = interrupts_disable();
1074
        spinlock_lock(&TASK->lock);
1029
        spinlock_lock(&TASK->lock);
1075
        uint64_t dt = task_get_accounting(TASK) - t0;
1030
        uint64_t dt = task_get_accounting(TASK) - t0;
1076
        spinlock_unlock(&TASK->lock);
1031
        spinlock_unlock(&TASK->lock);
1077
        interrupts_restore(ipl);
1032
        interrupts_restore(ipl);
1078
       
1033
       
1079
        if (ret != NULL) {
1034
        if (ret != NULL) {
1080
            printf("%s\n", ret);
1035
            printf("%s\n", ret);
1081
            ret = false;
1036
            ret = false;
1082
            break;
1037
            break;
1083
        }
1038
        }
1084
       
1039
       
1085
        data[i] = dt;
1040
        data[i] = dt;
1086
        order(dt, &cycles, &suffix);
1041
        order(dt, &cycles, &suffix);
1087
        printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix);
1042
        printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix);
1088
    }
1043
    }
1089
   
1044
   
1090
    if (ret) {
1045
    if (ret) {
1091
        printf("\n");
1046
        printf("\n");
1092
       
1047
       
1093
        uint64_t sum = 0;
1048
        uint64_t sum = 0;
1094
       
1049
       
1095
        for (i = 0; i < cnt; i++) {
1050
        for (i = 0; i < cnt; i++) {
1096
            sum += data[i];
1051
            sum += data[i];
1097
        }
1052
        }
1098
       
1053
       
1099
        order(sum / (uint64_t) cnt, &cycles, &suffix);
1054
        order(sum / (uint64_t) cnt, &cycles, &suffix);
1100
        printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);
1055
        printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);
1101
    }
1056
    }
1102
   
1057
   
1103
    free(data);
1058
    free(data);
1104
   
1059
   
1105
    return ret;
1060
    return ret;
1106
}
1061
}
1107
 
1062
 
1108
/** Command for returning kernel tests
1063
/** Command for returning kernel tests
1109
 *
1064
 *
1110
 * @param argv Argument vector.
1065
 * @param argv Argument vector.
1111
 *
1066
 *
1112
 * return Always 1.
1067
 * return Always 1.
1113
 */
1068
 */
1114
int cmd_test(cmd_arg_t *argv)
1069
int cmd_test(cmd_arg_t *argv)
1115
{
1070
{
1116
    test_t *test;
1071
    test_t *test;
1117
   
1072
   
1118
    if (strcmp((char *) argv->buffer, "*") == 0) {
1073
    if (strcmp((char *) argv->buffer, "*") == 0) {
1119
        for (test = tests; test->name != NULL; test++) {
1074
        for (test = tests; test->name != NULL; test++) {
1120
            if (test->safe) {
1075
            if (test->safe) {
1121
                printf("\n");
1076
                printf("\n");
1122
                if (!run_test(test))
1077
                if (!run_test(test))
1123
                    break;
1078
                    break;
1124
            }
1079
            }
1125
        }
1080
        }
1126
    } else {
1081
    } else {
1127
        bool fnd = false;
1082
        bool fnd = false;
1128
       
1083
       
1129
        for (test = tests; test->name != NULL; test++) {
1084
        for (test = tests; test->name != NULL; test++) {
1130
            if (strcmp(test->name, (char *) argv->buffer) == 0) {
1085
            if (strcmp(test->name, (char *) argv->buffer) == 0) {
1131
                fnd = true;
1086
                fnd = true;
1132
                run_test(test);
1087
                run_test(test);
1133
                break;
1088
                break;
1134
            }
1089
            }
1135
        }
1090
        }
1136
       
1091
       
1137
        if (!fnd)
1092
        if (!fnd)
1138
            printf("Unknown test\n");
1093
            printf("Unknown test\n");
1139
    }
1094
    }
1140
   
1095
   
1141
    return 1;
1096
    return 1;
1142
}
1097
}
1143
 
1098
 
1144
/** Command for returning kernel tests as benchmarks
1099
/** Command for returning kernel tests as benchmarks
1145
 *
1100
 *
1146
 * @param argv Argument vector.
1101
 * @param argv Argument vector.
1147
 *
1102
 *
1148
 * return Always 1.
1103
 * return Always 1.
1149
 */
1104
 */
1150
int cmd_bench(cmd_arg_t *argv)
1105
int cmd_bench(cmd_arg_t *argv)
1151
{
1106
{
1152
    test_t *test;
1107
    test_t *test;
1153
    uint32_t cnt = argv[1].intval;
1108
    uint32_t cnt = argv[1].intval;
1154
   
1109
   
1155
    bool fnd = false;
1110
    bool fnd = false;
1156
   
1111
   
1157
    for (test = tests; test->name != NULL; test++) {
1112
    for (test = tests; test->name != NULL; test++) {
1158
        if (strcmp(test->name, (char *) argv->buffer) == 0) {
1113
        if (strcmp(test->name, (char *) argv->buffer) == 0) {
1159
            fnd = true;
1114
            fnd = true;
1160
           
1115
           
1161
            if (test->safe)
1116
            if (test->safe)
1162
                run_bench(test, cnt);
1117
                run_bench(test, cnt);
1163
            else
1118
            else
1164
                printf("Unsafe test\n");
1119
                printf("Unsafe test\n");
1165
           
1120
           
1166
            break;
1121
            break;
1167
        }
1122
        }
1168
    }
1123
    }
1169
       
1124
       
1170
    if (!fnd)
1125
    if (!fnd)
1171
        printf("Unknown test\n");
1126
        printf("Unknown test\n");
1172
 
1127
 
1173
    return 1;
1128
    return 1;
1174
}
1129
}
1175
 
1130
 
1176
#endif
1131
#endif
1177
 
1132
 
1178
/** @}
1133
/** @}
1179
 */
1134
 */
1180
 
1135