diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-01-20 08:39:06 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-01-20 09:19:00 +0100 |
commit | 91ea7ea614c777595661c26cfa3e064182687f91 (patch) | |
tree | e8e10a2371bcdc50d90c065e795cce4c9db08d2a | |
parent | HOSTNAME(1): Add -m flag (diff) | |
download | rtems-libbsd-91ea7ea614c777595661c26cfa3e064182687f91.tar.bz2 |
Add and use rtems_bsd_get_task_priority()
-rw-r--r-- | Makefile | 1 | ||||
-rwxr-xr-x | freebsd-to-rtems.py | 1 | ||||
-rw-r--r-- | libbsd.txt | 8 | ||||
-rw-r--r-- | rtemsbsd/include/machine/rtems-bsd-thread.h | 8 | ||||
-rw-r--r-- | rtemsbsd/include/rtems/bsd/bsd.h | 15 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-get-task-priority.c | 54 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-init.c | 7 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-newproc.c | 6 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-nexus.c | 5 | ||||
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-thread.c | 13 |
10 files changed, 96 insertions, 22 deletions
@@ -71,6 +71,7 @@ LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-conf.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-delay.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-ethernet-addr.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c +LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-task-priority.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-jail.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-kern_synch.c diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py index 31039b66..266c6cf2 100755 --- a/freebsd-to-rtems.py +++ b/freebsd-to-rtems.py @@ -669,6 +669,7 @@ rtems.addRTEMSSourceFiles( 'rtems/rtems-bsd-delay.c', 'rtems/rtems-bsd-get-ethernet-addr.c', 'rtems/rtems-bsd-get-file.c', + 'rtems/rtems-bsd-get-task-priority.c', 'rtems/rtems-bsd-init.c', 'rtems/rtems-bsd-jail.c', 'rtems/rtems-bsd-kern_synch.c', @@ -228,6 +228,14 @@ http://www.freebsd.org/cgi/man.cgi?query=route&apropos=0&sektion=8&manpath=FreeB using `rtems_bsd_command_route()`. For an example please have a look at `testsuite/include/rtems/bsd/test/default-network-init.h`. +=== Task Priorities and Stack Size === + +The default task priority is 96 for the interrupt server task (name "IRQS"), 98 +for the timer server task (name "TIME") and 100 for all other tasks. The +application may provide their own implementation of the +`rtems_bsd_get_task_priority()` function (for example in the module which calls +`rtems_bsd_initialize()`) if different values are desired. + == Network Stack Features http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client diff --git a/rtemsbsd/include/machine/rtems-bsd-thread.h b/rtemsbsd/include/machine/rtems-bsd-thread.h index 41e08efe..64862df2 100644 --- a/rtemsbsd/include/machine/rtems-bsd-thread.h +++ b/rtemsbsd/include/machine/rtems-bsd-thread.h @@ -50,14 +50,6 @@ #define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D') -#define BSD_TASK_PRIORITY_NORMAL 120 - -#define BSD_TASK_PRIORITY_TIMER 110 - -#define BSD_TASK_PRIORITY_INTERRUPT 100 - -#define BSD_TASK_PRIORITY_RESOURCE_OWNER 100 - /* FIXME */ #define BSD_MINIMUM_TASK_STACK_SIZE ((size_t) 32 * 1024) diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h index a9118ecc..6aea27f2 100644 --- a/rtemsbsd/include/rtems/bsd/bsd.h +++ b/rtemsbsd/include/rtems/bsd/bsd.h @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved. + * Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -77,6 +77,19 @@ typedef struct { rtems_status_code rtems_bsd_initialize(void); +/** + * @brief Returns the initial priority for a task specified by its name. + * + * Applications may provide their own implementation of this function. For + * example they can define their implementation in the same module which calls + * rtems_bsd_initialize(). + * + * @param[in] name The task name. + * + * @return The desired initial task priority. + */ +rtems_task_priority rtems_bsd_get_task_priority(const char *name); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/rtemsbsd/rtems/rtems-bsd-get-task-priority.c b/rtemsbsd/rtems/rtems-bsd-get-task-priority.c new file mode 100644 index 00000000..cea62105 --- /dev/null +++ b/rtemsbsd/rtems/rtems-bsd-get-task-priority.c @@ -0,0 +1,54 @@ +/** + * @file + * + * @ingroup rtems_bsd_rtems + * + * @brief TODO. + */ + +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <rtems/bsd/bsd.h> + +#include <string.h> + +rtems_task_priority +rtems_bsd_get_task_priority(const char *name) +{ + if (strcmp(name, "IRQS") == 0) { + return (96); + } else if (strcmp(name, "TIME") == 0) { + return (98); + } else { + return (100); + } +} diff --git a/rtemsbsd/rtems/rtems-bsd-init.c b/rtemsbsd/rtems/rtems-bsd-init.c index c9271fdf..dbc2cc6c 100644 --- a/rtemsbsd/rtems/rtems-bsd-init.c +++ b/rtemsbsd/rtems/rtems-bsd-init.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved. + * Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -76,7 +76,8 @@ struct timeval boottime; rtems_status_code rtems_bsd_initialize(void) { - rtems_status_code sc = RTEMS_SUCCESSFUL; + static const char name[] = "TIME"; + rtems_status_code sc; hz = (int) rtems_clock_get_ticks_per_second(); tick = 1000000 / hz; @@ -88,7 +89,7 @@ rtems_bsd_initialize(void) mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO); sc = rtems_timer_initiate_server( - BSD_TASK_PRIORITY_TIMER, + rtems_bsd_get_task_priority(name), BSD_MINIMUM_TASK_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES ); diff --git a/rtemsbsd/rtems/rtems-bsd-newproc.c b/rtemsbsd/rtems/rtems-bsd-newproc.c index b532f86e..c01b41d2 100644 --- a/rtemsbsd/rtems/rtems-bsd-newproc.c +++ b/rtemsbsd/rtems/rtems-bsd-newproc.c @@ -36,9 +36,7 @@ #include <string.h> #include <stdio.h> #include <rtems.h> - - -static uint32_t networkDaemonPriority = 100; /* XXX */ +#include <rtems/bsd/bsd.h> /* * Structure passed to task-start stub @@ -88,7 +86,7 @@ rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg strncpy (nm, name, 4); sc = rtems_task_create (rtems_build_name(nm[0], nm[1], nm[2], nm[3]), - networkDaemonPriority, + rtems_bsd_get_task_priority(name), stacksize, RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0), RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL, diff --git a/rtemsbsd/rtems/rtems-bsd-nexus.c b/rtemsbsd/rtems/rtems-bsd-nexus.c index 60cc8cd0..a6b99258 100644 --- a/rtemsbsd/rtems/rtems-bsd-nexus.c +++ b/rtemsbsd/rtems/rtems-bsd-nexus.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -69,6 +69,7 @@ static struct rman irq_rman; static int nexus_probe(device_t dev) { + static const char name[] = "IRQS"; rtems_status_code status; int err; const rtems_bsd_device *nd; @@ -77,7 +78,7 @@ nexus_probe(device_t dev) #ifndef DISABLE_INTERRUPT_EXTENSION status = rtems_interrupt_server_initialize( - BSD_TASK_PRIORITY_INTERRUPT, + rtems_bsd_get_task_priority(name), BSD_MINIMUM_TASK_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, diff --git a/rtemsbsd/rtems/rtems-bsd-thread.c b/rtemsbsd/rtems/rtems-bsd-thread.c index bdd9aa54..a05d7437 100644 --- a/rtemsbsd/rtems/rtems-bsd-thread.c +++ b/rtemsbsd/rtems/rtems-bsd-thread.c @@ -7,7 +7,7 @@ */ /* - * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved. + * Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -50,6 +50,8 @@ #include <sys/malloc.h> #include <sys/selinfo.h> +#include <rtems/bsd/bsd.h> + #include <rtems/score/objectimpl.h> #include <rtems/score/statesimpl.h> #include <rtems/score/threaddispatch.h> @@ -246,12 +248,16 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg, int eno = 0; rtems_status_code sc; rtems_id task_id; + struct thread *td; + char name[sizeof(td->td_name)]; BSD_ASSERT(pages >= 0); + vsnprintf(name, sizeof(name), fmt, ap); + sc = rtems_task_create( BSD_TASK_NAME, - BSD_TASK_PRIORITY_NORMAL, + rtems_bsd_get_task_priority(name), BSD_MINIMUM_TASK_STACK_SIZE + (size_t) pages * PAGE_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, @@ -259,14 +265,13 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg, ); if (sc == RTEMS_SUCCESSFUL) { Thread_Control *thread = rtems_bsd_get_thread_by_id(task_id); - struct thread *td; BSD_ASSERT(thread != NULL); td = rtems_bsd_get_thread(thread); BSD_ASSERT(td != NULL); - vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap); + memcpy(td->td_name, name, sizeof(name)); if (rtems_bsd_thread_ready_to_start) { sc = rtems_task_start(task_id, (rtems_task_entry) func, |