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