[rtems-libbsd commit] Add and use rtems_bsd_get_task_stack_size()
Sebastian Huber
sebh at rtems.org
Tue Jan 20 08:21:32 UTC 2015
Module: rtems-libbsd
Branch: master
Commit: 33a15c304bf9ae77697eb7383972125526e9bd7c
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=33a15c304bf9ae77697eb7383972125526e9bd7c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Jan 20 08:57:36 2015 +0100
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(-)
diff --git a/Makefile b/Makefile
index b7d3a6f..8bcd347 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 266c6cf..d2fc217 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 13ff893..718ac10 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 64862df..2f99ad1 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 6aea27f..2e161e9 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 0000000..0eb8021
--- /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
+ * <rtems at 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>
+
+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 dbc2cc6..b585f7a 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 a6b9925..f7e4eba 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 a05d743..4fd5184 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 2fd13ea..4c835b5 100644
--- a/testsuite/thread01/test_main.c
+++ b/testsuite/thread01/test_main.c
@@ -43,6 +43,8 @@
#include <sys/kthread.h>
#include <sys/errno.h>
+#include <rtems/bsd/bsd.h>
+
#include <rtems.h>
#include <rtems/libcsupport.h>
#include <rtems/score/threaddispatch.h>
@@ -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()");
More information about the vc
mailing list