Rev 552 | Rev 582 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 552 | Rev 579 | ||
---|---|---|---|
Line 147... | Line 147... | ||
147 | int cmd_register(cmd_info_t *cmd) |
147 | int cmd_register(cmd_info_t *cmd) |
148 | { |
148 | { |
149 | ipl_t ipl; |
149 | ipl_t ipl; |
150 | link_t *cur; |
150 | link_t *cur; |
151 | 151 | ||
152 | ipl = interrupts_disable(); |
- | |
153 | spinlock_lock(&cmd_lock); |
152 | spinlock_lock(&cmd_lock); |
154 | 153 | ||
155 | /* |
154 | /* |
156 | * Make sure the command is not already listed. |
155 | * Make sure the command is not already listed. |
157 | */ |
156 | */ |
Line 161... | Line 160... | ||
161 | hlp = list_get_instance(cur, cmd_info_t, link); |
160 | hlp = list_get_instance(cur, cmd_info_t, link); |
162 | 161 | ||
163 | if (hlp == cmd) { |
162 | if (hlp == cmd) { |
164 | /* The command is already there. */ |
163 | /* The command is already there. */ |
165 | spinlock_unlock(&cmd_lock); |
164 | spinlock_unlock(&cmd_lock); |
166 | interrupts_restore(ipl); |
- | |
167 | return 0; |
165 | return 0; |
168 | } |
166 | } |
169 | 167 | ||
170 | /* Avoid deadlock. */ |
168 | /* Avoid deadlock. */ |
171 | if (hlp < cmd) { |
169 | if (hlp < cmd) { |
Line 179... | Line 177... | ||
179 | if ((strncmp(hlp->name, cmd->name, strlen(cmd->name)) == 0)) { |
177 | if ((strncmp(hlp->name, cmd->name, strlen(cmd->name)) == 0)) { |
180 | /* The command is already there. */ |
178 | /* The command is already there. */ |
181 | spinlock_unlock(&hlp->lock); |
179 | spinlock_unlock(&hlp->lock); |
182 | spinlock_unlock(&cmd->lock); |
180 | spinlock_unlock(&cmd->lock); |
183 | spinlock_unlock(&cmd_lock); |
181 | spinlock_unlock(&cmd_lock); |
184 | interrupts_restore(ipl); |
- | |
185 | return 0; |
182 | return 0; |
186 | } |
183 | } |
187 | 184 | ||
188 | spinlock_unlock(&hlp->lock); |
185 | spinlock_unlock(&hlp->lock); |
189 | spinlock_unlock(&cmd->lock); |
186 | spinlock_unlock(&cmd->lock); |
Line 193... | Line 190... | ||
193 | * Now the command can be added. |
190 | * Now the command can be added. |
194 | */ |
191 | */ |
195 | list_append(&cmd->link, &cmd_head); |
192 | list_append(&cmd->link, &cmd_head); |
196 | 193 | ||
197 | spinlock_unlock(&cmd_lock); |
194 | spinlock_unlock(&cmd_lock); |
198 | interrupts_restore(ipl); |
- | |
199 | return 1; |
195 | return 1; |
200 | } |
196 | } |
201 | 197 | ||
202 | /** Kernel console managing thread. |
198 | /** Kernel console managing thread. |
203 | * |
199 | * |
Line 244... | Line 240... | ||
244 | if (!parse_argument(cmdline, len, &start, &end)) { |
240 | if (!parse_argument(cmdline, len, &start, &end)) { |
245 | /* Command line did not contain alphanumeric word. */ |
241 | /* Command line did not contain alphanumeric word. */ |
246 | return NULL; |
242 | return NULL; |
247 | } |
243 | } |
248 | 244 | ||
249 | ipl = interrupts_disable(); |
- | |
250 | spinlock_lock(&cmd_lock); |
245 | spinlock_lock(&cmd_lock); |
251 | 246 | ||
252 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
247 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
253 | cmd_info_t *hlp; |
248 | cmd_info_t *hlp; |
254 | 249 | ||
Line 266... | Line 261... | ||
266 | spinlock_unlock(&cmd_lock); |
261 | spinlock_unlock(&cmd_lock); |
267 | 262 | ||
268 | if (!cmd) { |
263 | if (!cmd) { |
269 | /* Unknown command. */ |
264 | /* Unknown command. */ |
270 | printf("Unknown command.\n"); |
265 | printf("Unknown command.\n"); |
271 | interrupts_restore(ipl); |
- | |
272 | return NULL; |
266 | return NULL; |
273 | } |
267 | } |
274 | 268 | ||
275 | /* cmd == hlp is locked */ |
269 | /* cmd == hlp is locked */ |
276 | 270 | ||
Line 285... | Line 279... | ||
285 | char *buf; |
279 | char *buf; |
286 | start = end + 1; |
280 | start = end + 1; |
287 | if (!parse_argument(cmdline, len, &start, &end)) { |
281 | if (!parse_argument(cmdline, len, &start, &end)) { |
288 | printf("Too few arguments.\n"); |
282 | printf("Too few arguments.\n"); |
289 | spinlock_unlock(&cmd->lock); |
283 | spinlock_unlock(&cmd->lock); |
290 | interrupts_restore(ipl); |
- | |
291 | return NULL; |
284 | return NULL; |
292 | } |
285 | } |
293 | 286 | ||
294 | switch (cmd->argv[i].type) { |
287 | switch (cmd->argv[i].type) { |
295 | case ARG_TYPE_STRING: |
288 | case ARG_TYPE_STRING: |
Line 307... | Line 300... | ||
307 | 300 | ||
308 | start = end + 1; |
301 | start = end + 1; |
309 | if (parse_argument(cmdline, len, &start, &end)) { |
302 | if (parse_argument(cmdline, len, &start, &end)) { |
310 | printf("Too many arguments.\n"); |
303 | printf("Too many arguments.\n"); |
311 | spinlock_unlock(&cmd->lock); |
304 | spinlock_unlock(&cmd->lock); |
312 | interrupts_restore(ipl); |
- | |
313 | return NULL; |
305 | return NULL; |
314 | } |
306 | } |
315 | 307 | ||
316 | spinlock_unlock(&cmd->lock); |
308 | spinlock_unlock(&cmd->lock); |
317 | interrupts_restore(ipl); |
- | |
318 | return cmd; |
309 | return cmd; |
319 | } |
310 | } |
320 | 311 | ||
321 | /** Parse argument. |
312 | /** Parse argument. |
322 | * |
313 | * |
Line 366... | Line 357... | ||
366 | int cmd_help(cmd_arg_t *argv) |
357 | int cmd_help(cmd_arg_t *argv) |
367 | { |
358 | { |
368 | link_t *cur; |
359 | link_t *cur; |
369 | ipl_t ipl; |
360 | ipl_t ipl; |
370 | 361 | ||
371 | ipl = interrupts_disable(); |
- | |
372 | spinlock_lock(&cmd_lock); |
362 | spinlock_lock(&cmd_lock); |
373 | 363 | ||
374 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
364 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
375 | cmd_info_t *hlp; |
365 | cmd_info_t *hlp; |
376 | 366 | ||
Line 381... | Line 371... | ||
381 | 371 | ||
382 | spinlock_unlock(&hlp->lock); |
372 | spinlock_unlock(&hlp->lock); |
383 | } |
373 | } |
384 | 374 | ||
385 | spinlock_unlock(&cmd_lock); |
375 | spinlock_unlock(&cmd_lock); |
386 | interrupts_restore(ipl); |
- | |
387 | 376 | ||
388 | return 1; |
377 | return 1; |
389 | } |
378 | } |
390 | 379 | ||
391 | /** Describe specified command. |
380 | /** Describe specified command. |
Line 397... | Line 386... | ||
397 | int cmd_desc(cmd_arg_t *argv) |
386 | int cmd_desc(cmd_arg_t *argv) |
398 | { |
387 | { |
399 | link_t *cur; |
388 | link_t *cur; |
400 | ipl_t ipl; |
389 | ipl_t ipl; |
401 | 390 | ||
402 | ipl = interrupts_disable(); |
- | |
403 | spinlock_lock(&cmd_lock); |
391 | spinlock_lock(&cmd_lock); |
404 | 392 | ||
405 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
393 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
406 | cmd_info_t *hlp; |
394 | cmd_info_t *hlp; |
407 | 395 | ||
Line 418... | Line 406... | ||
418 | 406 | ||
419 | spinlock_unlock(&hlp->lock); |
407 | spinlock_unlock(&hlp->lock); |
420 | } |
408 | } |
421 | 409 | ||
422 | spinlock_unlock(&cmd_lock); |
410 | spinlock_unlock(&cmd_lock); |
423 | interrupts_restore(ipl); |
- | |
424 | 411 | ||
425 | return 1; |
412 | return 1; |
426 | } |
413 | } |
427 | 414 | ||
428 | /** Print detailed description of 'describe' command. */ |
415 | /** Print detailed description of 'describe' command. */ |