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
41f038e0
authored
8 years ago
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use of FreeRTOS malloc and free, small changes
parent
269af5d7
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
35 additions
and
43 deletions
+35
-43
CMakeCommon/SetCompilerFlags.cmake
+1
-1
TC_Toolchain.cmake
+7
-7
base_c/CMakeLists.txt
+6
-6
base_c/include/embb/base/c/internal/config.h
+2
-2
base_c/src/core_set.c
+2
-2
base_c/src/log.c
+3
-0
base_c/src/memory_allocation.c
+4
-4
base_c/src/thread.c
+10
-21
partest.tar
+0
-0
No files found.
CMakeCommon/SetCompilerFlags.cmake
View file @
41f038e0
...
...
@@ -30,7 +30,7 @@ function(SetGNUCompilerFlags compiler_libs)
set
(
compiler_libs PARENT_SCOPE
)
set
(
common_flags
"-fno-common -Os -std=c99"
)
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"
)
set
(
target_flags
"-DAPPKIT_TC277TFT -
DEMBB_DEBUG -
fshort-double -mcpu=tc27xx -mversion-info"
)
if
(
WARNINGS_ARE_ERRORS STREQUAL ON
)
set
(
warning_flags
"
${
warning_flags
}
-Werror"
)
...
...
This diff is collapsed.
Click to expand it.
TC_Toolchain.cmake
View file @
41f038e0
# this one is important
SET
(
CMAKE_SYSTEM_NAME Generic
)
#this one not so much
SET
(
CMAKE_SYSTEM_VERSION 1
)
SET
(
CMAKE_SYSTEM_PROCESSOR __TriCore__
)
#
A
dd __TriCore__ to compiler flags
#
a
dd __TriCore__ to compiler flags
add_definitions
(
-D__TriCore__
)
#Add __TriCore__ to cmake flags
add_definitions
(
-DEMBB_OS_FREERTOS
)
# add __TriCore__ to cmake flags
set
(
__TriCore__ 1
)
set
(
EMBB_OS_FREERTOS 1
)
# specify the cross compiler
SET
(
CMAKE_C_COMPILER C:/HighTec/toolchains/tricore/v4.6.6.0-infineon-1.1/bin/tricore-gcc.exe
)
SET
(
CMAKE_CXX_COMPILER C:/HighTec/toolchains/tricore/v4.6.6.0-infineon-1.1/bin/tricore-g++.exe
)
#
where is the
target environment
# 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_TC27x
/
)
# path to FreeRTOS
SET
(
FREE_RTOS_LIB_PATH C:/Data/Projekte/FreeRTOS_TC27x
)
# search for programs in the build host directories
SET
(
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH
)
...
...
This diff is collapsed.
Click to expand it.
base_c/CMakeLists.txt
View file @
41f038e0
...
...
@@ -73,12 +73,12 @@ if(MSVC)
endif
()
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
}
)
file
(
GLOB_RECURSE FREE_RTOS_HEADERS
"
${
FREE_RTOS_LIB_PATH
}
/*.h"
)
if
(
DEFINED EMBB_OS_FREERTOS
)
#
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})
file
(
GLOB_RECURSE FREE_RTOS_HEADERS
"
${
FREE_RTOS_LIB_PATH
}
/*.h"
)
endif
()
## CONFIGURATION
...
...
This diff is collapsed.
Click to expand it.
base_c/include/embb/base/c/internal/config.h
View file @
41f038e0
...
...
@@ -47,7 +47,7 @@
#if defined(_M_IA64) || defined(_IA64)
#define EMBB_PLATFORM_CACHE_LINE_SIZE 128
#elif defined(__TriCore__)
#define EMBB_PLATFORM_CACHE_LINE_SIZE
32
#define EMBB_PLATFORM_CACHE_LINE_SIZE
16
#else
#define EMBB_PLATFORM_CACHE_LINE_SIZE 64
#endif
...
...
@@ -97,7 +97,7 @@
#if defined(EMBB_PLATFORM_COMPILER_MSVC)
#define EMBB_PLATFORM_THREADING_WINTHREADS
#elif defined(EMBB_PLATFORM_COMPILER_GNUC)
#if defined(EMBB_
PLATFORM_ARCH_TC
)
#if defined(EMBB_
OS_FREERTOS
)
#define EMBB_PLATFORM_THREADING_RTOSTASKS
#else
#define EMBB_PLATFORM_THREADING_POSIXTHREADS
...
...
This diff is collapsed.
Click to expand it.
base_c/src/core_set.c
View file @
41f038e0
...
...
@@ -127,7 +127,7 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) {
#ifdef EMBB_PLATFORM_THREADING_RTOSTASKS
#ifdef __TriCore__
#define CORE_COUNT
1
#define CORE_COUNT
2 //scm34681: 3
#endif
...
...
@@ -137,7 +137,7 @@ unsigned int embb_core_count_available() {
void
embb_core_set_init
(
embb_core_set_t
*
core_set
,
int
initializer
)
{
// scm34681: rework
void
embb_core_set_init
(
embb_core_set_t
*
core_set
,
int
initializer
)
{
assert
(
core_set
!=
NULL
);
assert
(
embb_core_count_available
()
<
64
&&
"Core sets are only supported up to 64 processors!"
);
...
...
This diff is collapsed.
Click to expand it.
base_c/src/log.c
View file @
41f038e0
...
...
@@ -102,12 +102,15 @@ void embb_log_write_internal(
channel_str
,
log_level_str
,
msg_buffer
);
embb_log_global_log_function
(
log_context
,
buffer
);
#elif defined(EMBB_PLATFORM_COMPILER_GNUC)
#if defined(EMBB_OS_FREERTOS)
#else
char
msg_buffer
[
400
];
char
buffer
[
500
];
vsnprintf
(
msg_buffer
,
sizeof
(
msg_buffer
),
message
,
argp
);
snprintf
(
buffer
,
sizeof
(
buffer
),
"[%s] - [%s] %s"
,
channel_str
,
log_level_str
,
msg_buffer
);
embb_log_global_log_function
(
log_context
,
buffer
);
#endif
#else
embb_log_global_log_function
(
log_context
,
"["
);
embb_log_global_log_function
(
log_context
,
channel_str
);
...
...
This diff is collapsed.
Click to expand it.
base_c/src/memory_allocation.c
View file @
41f038e0
...
...
@@ -44,7 +44,7 @@ enum {
void
*
embb_alloc
(
size_t
bytes
)
{
size_t
bytes_to_allocate
=
2
*
sizeof
(
size_t
)
+
bytes
;
void
*
allocated
=
m
alloc
(
bytes_to_allocate
);
void
*
allocated
=
pvPortM
alloc
(
bytes_to_allocate
);
if
(
allocated
==
NULL
)
return
NULL
;
...
...
@@ -75,7 +75,7 @@ void embb_free(void * ptr) {
embb_atomic_fetch_and_add_long
(
&
embb_bytes_allocated
,
(
long
)(
0
-
(
size_t
)(
*
bytes_allocated
)));
f
ree
((
size_t
*
)
ptr
-
2
);
vPortF
ree
((
size_t
*
)
ptr
-
2
);
}
void
*
embb_alloc_aligned
(
size_t
alignment
,
size_t
size
)
{
...
...
@@ -98,7 +98,7 @@ void* embb_alloc_aligned(size_t alignment, size_t size) {
size_t
bytes_to_allocate
=
(
n
+
1
)
*
alignment
+
(
additional_bytes
-
1
);
char
*
allocated
=
(
char
*
)
m
alloc
(
bytes_to_allocate
);
char
*
allocated
=
(
char
*
)
pvPortM
alloc
(
bytes_to_allocate
);
if
(
allocated
==
NULL
)
return
NULL
;
...
...
@@ -147,7 +147,7 @@ void embb_free_aligned(void* ptr) {
embb_atomic_fetch_and_add_long
(
&
embb_bytes_allocated
,
(
long
)((
long
)
0
-
ptr_conv
[
-
3
]));
f
ree
((
void
*
)
ptr_conv
[
-
2
]);
vPortF
ree
((
void
*
)
ptr_conv
[
-
2
]);
}
size_t
embb_get_bytes_allocated
()
{
...
...
This diff is collapsed.
Click to expand it.
base_c/src/thread.c
View file @
41f038e0
...
...
@@ -304,6 +304,7 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) {
#ifdef EMBB_PLATFORM_THREADING_RTOSTASKS
#include <FreeRTOS/task.h>
#include <FreeRTOS/core_set.h>
/**
* Used to wrap client thread start function and argument when calling internal
...
...
@@ -347,6 +348,7 @@ void embb_thread_yield() {
int
embb_thread_create
(
embb_thread_t
*
thread
,
const
embb_core_set_t
*
core_set
,
embb_thread_start_t
func
,
void
*
arg
)
{
int
status
;
core_set_t
rtos_core_set
;
if
(
thread
==
NULL
)
{
return
EMBB_ERROR
;
}
...
...
@@ -357,15 +359,18 @@ embb_thread_start_t func, void *arg) {
return
EMBB_NOMEM
;
}
rtos_core_set
.
rep
=
core_set
->
rep
;
thread
->
embb_internal_arg
->
func
=
func
;
thread
->
embb_internal_arg
->
arg
=
arg
;
status
=
xTaskCreate
(
(
TaskFunction_t
)
embb_internal_thread_start
,
// entry function
"EMBB_Task"
,
// task name (not needed)
500
,
// stack size
status
=
TaskCreateWithCoreSet
(
(
TaskFunction_t
)
embb_internal_thread_start
,
// entry function
500
,
// stack depth
rtos_core_set
,
// core set
thread
->
embb_internal_arg
,
// parameters
1
,
// priority
thread
->
embb_internal_handle
);
// thread handle
thread
->
embb_internal_handle
// thread handle
);
if
(
status
!=
1
)
{
...
...
@@ -374,22 +379,6 @@ embb_thread_start_t func, void *arg) {
return
EMBB_ERROR
;
}
/*if (core_set != NULL) { // scm34681: implement core affinity
DWORD_PTR core_mask = 0;
DWORD bit_mask = 1;
assert(embb_core_count_available() < 64);
for (unsigned int i = 0; i < embb_core_count_available(); i++) {
if (embb_core_set_contains(core_set, i)) {
core_mask |= bit_mask;
}
bit_mask <<= 1;
}
if (SetThreadAffinityMask(thread->embb_internal_handle, core_mask)
== (DWORD_PTR)NULL) {
return EMBB_ERROR;
}
}*/
return
EMBB_SUCCESS
;
}
...
...
This diff is collapsed.
Click to expand it.
partest.tar
View file @
41f038e0
No preview for this file type
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