From 33a15c304bf9ae77697eb7383972125526e9bd7c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 20 Jan 2015 08:57:36 +0100 Subject: Add and use rtems_bsd_get_task_stack_size() --- Makefile | 1 + freebsd-to-rtems.py | 1 + libbsd.txt | 4 +++ rtemsbsd/include/machine/rtems-bsd-thread.h | 3 -- rtemsbsd/include/rtems/bsd/bsd.h | 13 ++++++++ rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c | 46 ++++++++++++++++++++++++++ rtemsbsd/rtems/rtems-bsd-init.c | 2 +- rtemsbsd/rtems/rtems-bsd-nexus.c | 2 +- rtemsbsd/rtems/rtems-bsd-thread.c | 3 +- testsuite/thread01/test_main.c | 4 ++- 10 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c diff --git a/Makefile b/Makefile index b7d3a6fd..8bcd3471 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ 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-get-task-stack-size.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 266c6cf2..d2fc217e 100755 --- a/freebsd-to-rtems.py +++ b/freebsd-to-rtems.py @@ -670,6 +670,7 @@ rtems.addRTEMSSourceFiles( 'rtems/rtems-bsd-get-ethernet-addr.c', 'rtems/rtems-bsd-get-file.c', 'rtems/rtems-bsd-get-task-priority.c', + 'rtems/rtems-bsd-get-task-stack-size.c', 'rtems/rtems-bsd-init.c', 'rtems/rtems-bsd-jail.c', 'rtems/rtems-bsd-kern_synch.c', diff --git a/libbsd.txt b/libbsd.txt index 13ff893b..718ac10e 100644 --- a/libbsd.txt +++ b/libbsd.txt @@ -236,6 +236,10 @@ 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. +The task stack size is determined by the `rtems_bsd_get_task_stack_size()` +function which may be provided by the application in case the default is not +appropriate. + == 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 64862df2..2f99ad10 100644 --- a/rtemsbsd/include/machine/rtems-bsd-thread.h +++ b/rtemsbsd/include/machine/rtems-bsd-thread.h @@ -50,9 +50,6 @@ #define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D') -/* FIXME */ -#define BSD_MINIMUM_TASK_STACK_SIZE ((size_t) 32 * 1024) - struct sleepqueue { Thread_queue_Control sq_blocked; LIST_ENTRY(sleepqueue) sq_hash; diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h index 6aea27f2..2e161e97 100644 --- a/rtemsbsd/include/rtems/bsd/bsd.h +++ b/rtemsbsd/include/rtems/bsd/bsd.h @@ -90,6 +90,19 @@ rtems_status_code rtems_bsd_initialize(void); */ rtems_task_priority rtems_bsd_get_task_priority(const char *name); +/** + * @brief Returns the stack size 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 task stack size. + */ +size_t rtems_bsd_get_task_stack_size(const char *name); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c b/rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c new file mode 100644 index 00000000..0eb80210 --- /dev/null +++ b/rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c @@ -0,0 +1,46 @@ +/** + * @file + * + * @ingroup rtems_bsd_rtems + * + * @brief TODO. + */ + +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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 + +size_t +rtems_bsd_get_task_stack_size(const char *name) +{ + return 32 * 1024; +} diff --git a/rtemsbsd/rtems/rtems-bsd-init.c b/rtemsbsd/rtems/rtems-bsd-init.c index dbc2cc6c..b585f7a5 100644 --- a/rtemsbsd/rtems/rtems-bsd-init.c +++ b/rtemsbsd/rtems/rtems-bsd-init.c @@ -90,7 +90,7 @@ rtems_bsd_initialize(void) sc = rtems_timer_initiate_server( rtems_bsd_get_task_priority(name), - BSD_MINIMUM_TASK_STACK_SIZE, + rtems_bsd_get_task_stack_size(name), RTEMS_DEFAULT_ATTRIBUTES ); if (sc != RTEMS_SUCCESSFUL) { diff --git a/rtemsbsd/rtems/rtems-bsd-nexus.c b/rtemsbsd/rtems/rtems-bsd-nexus.c index a6b99258..f7e4eba5 100644 --- a/rtemsbsd/rtems/rtems-bsd-nexus.c +++ b/rtemsbsd/rtems/rtems-bsd-nexus.c @@ -79,7 +79,7 @@ nexus_probe(device_t dev) #ifndef DISABLE_INTERRUPT_EXTENSION status = rtems_interrupt_server_initialize( rtems_bsd_get_task_priority(name), - BSD_MINIMUM_TASK_STACK_SIZE, + rtems_bsd_get_task_stack_size(name), RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, NULL diff --git a/rtemsbsd/rtems/rtems-bsd-thread.c b/rtemsbsd/rtems/rtems-bsd-thread.c index a05d7437..4fd5184c 100644 --- a/rtemsbsd/rtems/rtems-bsd-thread.c +++ b/rtemsbsd/rtems/rtems-bsd-thread.c @@ -258,7 +258,8 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg, sc = rtems_task_create( BSD_TASK_NAME, rtems_bsd_get_task_priority(name), - BSD_MINIMUM_TASK_STACK_SIZE + (size_t) pages * PAGE_SIZE, + rtems_bsd_get_task_stack_size(name) + + (size_t) pages * PAGE_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id diff --git a/testsuite/thread01/test_main.c b/testsuite/thread01/test_main.c index 2fd13ea2..4c835b5a 100644 --- a/testsuite/thread01/test_main.c +++ b/testsuite/thread01/test_main.c @@ -43,6 +43,8 @@ #include #include +#include + #include #include #include @@ -210,7 +212,7 @@ test_kthread_add(void) { rtems_resource_snapshot snapshot; void *greedy; - uintptr_t take_away = 2 * BSD_MINIMUM_TASK_STACK_SIZE; + uintptr_t take_away = 2 * rtems_bsd_get_task_stack_size(""); puts("test kthread_add()"); -- cgit v1.2.3