Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
29d124d0
authored
Nov 14, 2016
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added FreeRTOS implementation
parent
dd88ea03
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
131 additions
and
34 deletions
+131
-34
CMakeCommon/SetCompilerFlags.cmake
+45
-30
CMakeLists.txt
+7
-1
TC_Toolchain.cmake
+5
-1
base_c/include/embb/base/c/internal/config.h
+9
-1
base_c/include/embb/base/c/internal/platform.h
+26
-1
base_c/src/condition_variable.c
+4
-0
base_c/src/core_set.c
+26
-0
base_c/src/memory_allocation.c
+9
-0
base_c/src/mutex.c
+0
-0
base_c/src/thread.c
+0
-0
No files found.
CMakeCommon/SetCompilerFlags.cmake
View file @
29d124d0
...
...
@@ -26,36 +26,51 @@
#
function
(
SetGNUCompilerFlags compiler_libs
)
if
(
CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX
)
set
(
compiler_libs pthread rt PARENT_SCOPE
)
# -Wall -> All warnings
# -Wextra -> Even more warnings
# -Werror -> Warnings are errors
set
(
warning_flags
"-Wall -Wextra"
)
if
(
WARNINGS_ARE_ERRORS STREQUAL ON
)
set
(
warning_flags
"
${
warning_flags
}
-Werror"
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCC
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-pthread -std=c99
${
warning_flags
}
"
PARENT_SCOPE
)
set
(
CMAKE_C_FLAGS_DEBUG
"
${
CMAKE_C_FLAGS_DEBUG
}
-DEMBB_DEBUG"
PARENT_SCOPE
)
set
(
CMAKE_C_FLAGS_RELEASE
"
${
CMAKE_C_FLAGS_RELEASE
}
-DNDEBUG"
PARENT_SCOPE
)
set
(
CMAKE_C_FLAGS_COVERAGE
"
${
CMAKE_C_FLAGS_COVERAGE
}
-O0 -fprofile-arcs -ftest-coverage"
PARENT_SCOPE
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-pthread -std=c++03
${
warning_flags
}
"
PARENT_SCOPE
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DEMBB_DEBUG"
PARENT_SCOPE
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
-DNDEBUG"
PARENT_SCOPE
)
set
(
CMAKE_CXX_FLAGS_COVERAGE
"
${
CMAKE_CXX_FLAGS_COVERAGE
}
-O0 -fprofile-arcs -ftest-coverage"
PARENT_SCOPE
)
endif
()
if
(
DEFINED CMAKE_SYSTEM_PROCESSOR
)
set
(
compiler_libs PARENT_SCOPE
)
set
(
common_flags
"-fno-common -Os"
)
set
(
warning_flags
"-W -Wall -Wextra -Wdiv-by-zero -Warray-bounds -Wcast-align -Wignored-qualifiers -Wformat -Wformat-security"
)
set
(
target_flags
"-DAPPKIT_TC277TFT -fshort-double -mcpu=tc27xx -mversion-info"
)
if
(
WARNINGS_ARE_ERRORS STREQUAL ON
)
set
(
warning_flags
"
${
warning_flags
}
-Werror"
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCC
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
common_flags
}
${
warning_flags
}
${
target_flags
}
"
PARENT_SCOPE
)
endif
()
else
()
set
(
compiler_libs pthread rt PARENT_SCOPE
)
# -Wall -> All warnings
# -Wextra -> Even more warnings
# -Werror -> Warnings are errors
set
(
warning_flags
"-Wall -Wextra"
)
if
(
WARNINGS_ARE_ERRORS STREQUAL ON
)
set
(
warning_flags
"
${
warning_flags
}
-Werror"
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCC
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-pthread -std=c99
${
warning_flags
}
"
PARENT_SCOPE
)
set
(
CMAKE_C_FLAGS_DEBUG
"
${
CMAKE_C_FLAGS_DEBUG
}
-DEMBB_DEBUG"
PARENT_SCOPE
)
set
(
CMAKE_C_FLAGS_RELEASE
"
${
CMAKE_C_FLAGS_RELEASE
}
-DNDEBUG"
PARENT_SCOPE
)
set
(
CMAKE_C_FLAGS_COVERAGE
"
${
CMAKE_C_FLAGS_COVERAGE
}
-O0 -fprofile-arcs -ftest-coverage"
PARENT_SCOPE
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-pthread -std=c++03
${
warning_flags
}
"
PARENT_SCOPE
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DEMBB_DEBUG"
PARENT_SCOPE
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
-DNDEBUG"
PARENT_SCOPE
)
set
(
CMAKE_CXX_FLAGS_COVERAGE
"
${
CMAKE_CXX_FLAGS_COVERAGE
}
-O0 -fprofile-arcs -ftest-coverage"
PARENT_SCOPE
)
endif
()
endif
()
endif
()
endfunction
()
...
...
CMakeLists.txt
View file @
29d124d0
...
...
@@ -76,7 +76,7 @@ endif()
# The set option will be converted to uppercase letters by cmake!! --> ON/OFF
# Note that the help string (second argument) cannot be printed by cmake.
#
option
(
BUILD_TESTS
"Specify whether tests should be built"
O
N
)
option
(
BUILD_TESTS
"Specify whether tests should be built"
O
FF
)
option
(
BUILD_EXAMPLES
"Specify whether examples should be built"
OFF
)
option
(
USE_EXCEPTIONS
"Specify whether exceptions should be activated in C++"
ON
)
option
(
INSTALL_DOCS
"Specify whether Doxygen docs should be installed"
ON
)
...
...
@@ -104,6 +104,12 @@ else()
endif
()
message
(
" (set with command line option -DUSE_AUTOMATIC_INITIALIZATION=ON/OFF)"
)
set
(
CMAKE_CXX_STANDARD_LIBRARIES
${
FREE_RTOS_LIB_PATH
}
/iRom/libFreeRTOS_Lib.a
)
set
(
CMAKE_C_STANDARD_LIBRARIES
${
FREE_RTOS_LIB_PATH
}
/iRom/libFreeRTOS_Lib.a
)
set
(
CMAKE_INSTALL_RPATH FREE_RTOS_LIB_PATH
)
set
(
__TriCore__ 1
)
include
(
CMakeCommon/SetCompilerFlags.cmake
)
SetGNUCompilerFlags
(
compiler_libs compiler_flags
)
SetVisualStudioCompilerFlags
(
compiler_libs compiler_flags
)
...
...
TC_Toolchain.cmake
View file @
29d124d0
...
...
@@ -2,7 +2,8 @@
SET
(
CMAKE_SYSTEM_NAME Generic
)
#this one not so much
SET
(
CMAKE_SYSTEM_VERSION 1
)
SET
(
CMAKE_SYSTEM_PROCESSOR TriCore
)
SET
(
CMAKE_SYSTEM_PROCESSOR __TriCore__
)
SET
(
__TriCore__ 1
)
# specify the cross compiler
SET
(
CMAKE_C_COMPILER C:/HighTec/toolchains/tricore/v4.6.6.0-infineon-1.1/bin/tricore-gcc.exe
)
...
...
@@ -11,6 +12,9 @@ SET(CMAKE_CXX_COMPILER C:/HighTec/toolchains/tricore/v4.6.6.0-infineon-1.1/bin/t
# where is the target environment
SET
(
CMAKE_FIND_ROOT_PATH C:/HighTec/toolchains/tricore/v4.6.6.0-infineon-1.1
)
SET
(
FREE_RTOS_LIB_PATH C:/data/projekte/freeRTOS_lib/
)
# search for programs in the build host directories
SET
(
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH
)
# for libraries and headers in the target directories
...
...
base_c/include/embb/base/c/internal/config.h
View file @
29d124d0
...
...
@@ -46,6 +46,8 @@
*/
#if defined(_M_IA64) || defined(_IA64)
#define EMBB_PLATFORM_CACHE_LINE_SIZE 128
#elif defined(__TriCore__)
#define EMBB_PLATFORM_CACHE_LINE_SIZE 32
#else
#define EMBB_PLATFORM_CACHE_LINE_SIZE 64
#endif
...
...
@@ -86,6 +88,8 @@
#define EMBB_PLATFORM_ARCH_X86
#elif defined(__arm__)
#define EMBB_PLATFORM_ARCH_ARM
#elif defined(__TriCore__)
#define EMBB_PLATFORM_ARCH_TC
#else
#define EMBB_PLATFORM_ARCH_UNKNOWN
#endif
...
...
@@ -93,7 +97,11 @@
#if defined(EMBB_PLATFORM_COMPILER_MSVC)
#define EMBB_PLATFORM_THREADING_WINTHREADS
#elif defined(EMBB_PLATFORM_COMPILER_GNUC)
#define EMBB_PLATFORM_THREADING_POSIXTHREADS
#if defined(EMBB_PLATFORM_ARCH_TC)
#define EMBB_PLATFORM_THREADING_RTOSTASKS
#else
#define EMBB_PLATFORM_THREADING_POSIXTHREADS
#endif
#else
#error "No thread implementation could be determined"
#endif
...
...
base_c/include/embb/base/c/internal/platform.h
View file @
29d124d0
...
...
@@ -71,6 +71,7 @@ typedef CONDITION_VARIABLE embb_condition_t;
#define EMBB_THREAD_SPECIFIC static __declspec(thread)
/* EMBB_PLATFORM_THREADING_WINTHREADS */
#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS
#include <pthread.h>
...
...
@@ -95,7 +96,31 @@ typedef pthread_cond_t embb_condition_t;
#define EMBB_THREAD_SPECIFIC __thread
#else
/* EMBB_PLATFORM_THREADING_POSIXTHREADS */
/* EMBB_PLATFORM_THREADING_POSIXTHREADS */
#elif defined EMBB_PLATFORM_THREADING_RTOSTASKS
#include <FreeRTOS/task.h>
#include <FreeRTOS/semphr.h>
struct
embb_internal_thread_arg_t
;
/**
* Opaque handle for a thread.
*/
typedef
struct
embb_thread_t
{
TaskHandle_t
embb_internal_handle
;
struct
embb_internal_thread_arg_t
*
embb_internal_arg
;
}
embb_thread_t
;
typedef
TaskStatus_t
embb_thread_id_t
;
typedef
SemaphoreHandle_t
embb_mutex_t
;
typedef
SemaphoreHandle_t
embb_condition_t
;
// scm34681: implement FreeRTOS condition variable
#define EMBB_DURATION_MIN_NANOSECONDS 1000
#define EMBB_THREAD_SPECIFIC
#else
/* EMBB_PLATFORM_THREADING_RTOSTASKS */
#error "No threading platform defined!"
...
...
base_c/src/condition_variable.c
View file @
29d124d0
...
...
@@ -185,3 +185,7 @@ int embb_condition_destroy(embb_condition_t* condition_var) {
}
#endif
/* EMBB_PLATFORM_THREADING_POSIXTHREADS */
#ifdef EMBB_PLATFORM_THREADING_RTOSTASKS
#endif
/* EMBB_PLATFORM_THREADING_RTOSTASKS */
base_c/src/core_set.c
View file @
29d124d0
...
...
@@ -125,6 +125,32 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) {
#endif
/* EMBB_PLATFORM_THREADING_POSIXTHREADS */
#ifdef EMBB_PLATFORM_THREADING_RTOSTASKS
#ifdef __TriCore__
#define CORE_COUNT 3
#endif
unsigned
int
embb_core_count_available
()
{
return
CORE_COUNT
;
}
void
embb_core_set_init
(
embb_core_set_t
*
core_set
,
int
initializer
)
{
// scm34681: rework
assert
(
core_set
!=
NULL
);
assert
(
embb_core_count_available
()
<
64
&&
"Core sets are only supported up to 64 processors!"
);
if
(
initializer
==
0
)
{
embb_bitset_clear_all
(
&
core_set
->
rep
);
}
else
{
embb_bitset_set_n
(
&
core_set
->
rep
,
embb_core_count_available
());
}
}
#endif EMBB_PLATFORM_THREADING_RTOSTASKS
void
embb_core_set_add
(
embb_core_set_t
*
core_set
,
unsigned
int
core_number
)
{
assert
(
core_set
!=
NULL
);
assert
(
core_number
<
embb_core_count_available
());
...
...
base_c/src/memory_allocation.c
View file @
29d124d0
...
...
@@ -178,6 +178,14 @@ void *embb_alloc_aligned(size_t alignment, size_t size) {
*/
malloc_addr
=
_aligned_malloc
(
size
,
alignment
);
#elif defined EMBB_PLATFORM_COMPILER_GNUC
#ifdef __TRICORE__
/*
* The TriCore Toolchain uses obsolete function memalign() for
* aligned memory allocation.
*/
#include <malloc.h> // scm3681: rework
malloc_addr
=
memalign
(
alignment
,
size
);
#else
/* __TRICORE__ */
/*
* From the Documentation:
* The posix_memalign() function shall allocate size bytes aligned on a
...
...
@@ -190,6 +198,7 @@ void *embb_alloc_aligned(size_t alignment, size_t size) {
int
status
=
posix_memalign
(
&
malloc_addr
,
alignment
,
size
);
EMBB_UNUSED
(
status
);
#endif
#endif
return
malloc_addr
;
}
...
...
base_c/src/mutex.c
View file @
29d124d0
This diff is collapsed.
Click to expand it.
base_c/src/thread.c
View file @
29d124d0
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment