diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-09-25 10:48:14 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-09-25 10:57:56 +0200 |
commit | 6604dc893e784ba55c315eac1e455189dbbd8164 (patch) | |
tree | a59f578a04537cab0cbac4cf7598f01b8825232b /rtemsbsd | |
parent | BSD_ASSERT(): Optimize (diff) | |
download | rtems-libbsd-6604dc893e784ba55c315eac1e455189dbbd8164.tar.bz2 |
Delete rtems_bsd_thread_chain
Rely on RTEMS object registration for threads.
Diffstat (limited to 'rtemsbsd')
-rw-r--r-- | rtemsbsd/include/machine/rtems-bsd-thread.h | 2 | ||||
-rw-r--r-- | rtemsbsd/include/rtems/bsd/bsd.h | 2 | ||||
-rw-r--r-- | rtemsbsd/include/rtems/netcmds-config.h | 31 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-panic.c | 29 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-shell.c | 84 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-thread.c | 14 |
6 files changed, 68 insertions, 94 deletions
diff --git a/rtemsbsd/include/machine/rtems-bsd-thread.h b/rtemsbsd/include/machine/rtems-bsd-thread.h index 81aef32e..41e08efe 100644 --- a/rtemsbsd/include/machine/rtems-bsd-thread.h +++ b/rtemsbsd/include/machine/rtems-bsd-thread.h @@ -68,8 +68,6 @@ struct sleepqueue { void *sq_wchan; }; -extern rtems_chain_control rtems_bsd_thread_chain; - struct thread * rtems_bsd_get_thread(const Thread_Control *thread); diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h index 71565457..af03b443 100644 --- a/rtemsbsd/include/rtems/bsd/bsd.h +++ b/rtemsbsd/include/rtems/bsd/bsd.h @@ -70,8 +70,6 @@ extern const size_t rtems_bsd_nexus_device_count; rtems_status_code rtems_bsd_initialize(void); -void rtems_bsd_shell_initialize(void); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/rtemsbsd/include/rtems/netcmds-config.h b/rtemsbsd/include/rtems/netcmds-config.h index 199afbea..d9ccd69c 100644 --- a/rtemsbsd/include/rtems/netcmds-config.h +++ b/rtemsbsd/include/rtems/netcmds-config.h @@ -18,17 +18,24 @@ #include <rtems/shell.h> -/* - * Externs for all command definition structures - */ -// #if RTEMS_NETWORKING - extern rtems_shell_cmd_t rtems_shell_PING_Command; - extern rtems_shell_cmd_t rtems_shell_PING6_Command; - - extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command; - extern rtems_shell_cmd_t rtems_shell_ROUTE_Command; - extern rtems_shell_cmd_t rtems_shell_NETSTAT_Command; - extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command; -// #endif +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern rtems_shell_cmd_t rtems_shell_BSD_Command; + +extern rtems_shell_cmd_t rtems_shell_PING_Command; +extern rtems_shell_cmd_t rtems_shell_PING6_Command; + +extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command; +extern rtems_shell_cmd_t rtems_shell_ROUTE_Command; +extern rtems_shell_cmd_t rtems_shell_NETSTAT_Command; +extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command; + +extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif diff --git a/rtemsbsd/rtems/rtems-bsd-panic.c b/rtemsbsd/rtems/rtems-bsd-panic.c index 9634e193..1fc65f08 100644 --- a/rtemsbsd/rtems/rtems-bsd-panic.c +++ b/rtemsbsd/rtems/rtems-bsd-panic.c @@ -43,38 +43,13 @@ #include <rtems/bsd/sys/param.h> #include <rtems/bsd/sys/types.h> #include <sys/systm.h> -#include <sys/kernel.h> -#include <rtems/bsd/sys/lock.h> -#include <sys/mutex.h> -#include <sys/proc.h> - -static void -suspend_all_threads(void) -{ - const rtems_chain_control *chain = &rtems_bsd_thread_chain; - const rtems_chain_node *node = rtems_chain_immutable_first(chain); - rtems_id self = rtems_task_self(); - - while (!rtems_chain_is_tail(chain, node)) { - const struct thread *td = (const struct thread *) node; - rtems_id id = rtems_bsd_get_task_id(td); - - if (id != self) { - rtems_task_suspend(id); - } - - node = rtems_chain_immutable_next(node); - } - - rtems_task_suspend(RTEMS_SELF); -} void panic(const char *fmt, ...) { va_list ap; - printf("*** BSD PANIC *** "); + printf("\n*** BSD PANIC *** "); va_start(ap, fmt); vprintf(fmt, ap); @@ -82,7 +57,7 @@ panic(const char *fmt, ...) printf("\n"); - suspend_all_threads(); + rtems_task_suspend(RTEMS_SELF); /* FIXME */ rtems_fatal_error_occurred(0xdeadbeef); diff --git a/rtemsbsd/rtems/rtems-bsd-shell.c b/rtemsbsd/rtems/rtems-bsd-shell.c index 7ccb170c..25daf626 100644 --- a/rtemsbsd/rtems/rtems-bsd-shell.c +++ b/rtemsbsd/rtems/rtems-bsd-shell.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved. + * Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -46,67 +46,71 @@ #include <sys/systm.h> #include <sys/proc.h> -#include <rtems/bsd/bsd.h> -#include <rtems/shell.h> +#include <inttypes.h> + +#include <rtems/netcmds-config.h> static void -rtems_bsd_dump_thread(void) +rtems_bsd_dump_thread(Thread_Control *thread) { - const rtems_chain_control *chain = &rtems_bsd_thread_chain; - const rtems_chain_node *node = rtems_chain_immutable_first(chain); - - printf("thread dump:\n"); + const struct thread *td = rtems_bsd_get_thread(thread); - while (!rtems_chain_is_tail(chain, node)) { - const struct thread *td = (const struct thread *) node; + if (td != NULL) { + char buf[5]; + const char *name = td->td_name; - printf("\t%s: 0x%08x\n", td->td_name, rtems_bsd_get_task_id(td)); + if (name == NULL || name[0] == '\0') { + rtems_object_get_name(thread->Object.id, sizeof(buf), &buf[0]); + name = &buf[0]; + } - node = rtems_chain_immutable_next(node); + fprintf( + stdout, + " 0x%08" PRIx32 " | %8" PRIu32 " | %s\n", + thread->Object.id, + thread->current_priority, + name + ); } } -static const char rtems_bsd_usage [] = - "bsd {all|condvar|thread|callout}"; +static void +rtems_bsd_dump_threads(void) +{ + fprintf( + stdout, + "-------------------------------------------------------------------------------\n" + " BSD THREADS\n" + "------------+----------+-------------------------------------------------------\n" + " ID | PRIORITY | NAME\n" + "------------+----------+-------------------------------------------------------\n" + ); + + rtems_iterate_over_all_threads(rtems_bsd_dump_thread); + + fprintf( + stdout, + "------------+----------+-------------------------------------------------------\n" + ); +} + +static const char rtems_bsd_usage[] = "bsd"; #define CMP(s) all || strcasecmp(argv [1], s) == 0 static int rtems_bsd_info(int argc, char **argv) { - bool usage = true; - - if (argc == 2) { - bool all = false; - - if (CMP("all")) { - all = true; - } - - if (CMP("thread")) { - rtems_bsd_dump_thread(); - usage = false; - } - } - - if (usage) { - puts(rtems_bsd_usage); - } + rtems_bsd_dump_threads(); return 0; } -static rtems_shell_cmd_t rtems_bsd_info_command = { +rtems_shell_cmd_t rtems_shell_BSD_Command = { .name = "bsd", - .usage = rtems_bsd_usage, + .usage = &rtems_bsd_usage[0], .topic = "bsp", .command = rtems_bsd_info, .alias = NULL, .next = NULL }; - -void -rtems_bsd_shell_initialize(void) -{ - rtems_shell_add_cmd_struct(&rtems_bsd_info_command); -} diff --git a/rtemsbsd/rtems/rtems-bsd-thread.c b/rtemsbsd/rtems/rtems-bsd-thread.c index d233b5e2..bdd9aa54 100644 --- a/rtemsbsd/rtems/rtems-bsd-thread.c +++ b/rtemsbsd/rtems/rtems-bsd-thread.c @@ -57,8 +57,6 @@ #include <rtems/score/threadimpl.h> #include <rtems/score/threadqimpl.h> -RTEMS_CHAIN_DEFINE_EMPTY(rtems_bsd_thread_chain); - static size_t rtems_bsd_extension_index; static CHAIN_DEFINE_EMPTY(rtems_bsd_thread_delay_start_chain); @@ -162,15 +160,14 @@ rtems_bsd_extension_thread_create( Thread_Control *created ) { - bool ok = true; + bool ok; if (rtems_bsd_is_bsd_thread(created)) { struct thread *td = rtems_bsd_thread_create(created, 0); ok = td != NULL; - if (ok) { - rtems_chain_append(&rtems_bsd_thread_chain, &td->td_node); - } + } else { + ok = true; } return ok; @@ -186,11 +183,6 @@ rtems_bsd_extension_thread_delete( if (td != NULL) { seltdfini(td); - - if (rtems_bsd_is_bsd_thread(deleted)) { - rtems_chain_extract(&td->td_node); - } - free(td->td_sleepqueue, M_TEMP); free(td, M_TEMP); } |