Trust zone module identifier added to thread class

Non-Secure threads can access secure calls only when tz_module attribute is set
as 1(OS_SECURE_CALLABLE_THREAD), while thread creation.
Hence adding tz_module as an argument to ctor.
pull/6486/head
Deepika 2017-10-13 11:37:44 -05:00
parent 062164eaad
commit 044dfb122f
2 changed files with 17 additions and 7 deletions

View File

@ -44,7 +44,7 @@ extern "C" void thread_terminate_hook(osThreadId_t id)
namespace rtos {
void Thread::constructor(osPriority priority,
uint32_t stack_size, unsigned char *stack_mem, const char *name) {
uint32_t stack_size, unsigned char *stack_mem, const char *name, uint32_t tz_module) {
const uintptr_t unaligned_mem = reinterpret_cast<uintptr_t>(stack_mem);
const uintptr_t aligned_mem = ALIGN_UP(unaligned_mem, 8);
@ -60,11 +60,12 @@ void Thread::constructor(osPriority priority,
_attr.stack_size = aligned_size;
_attr.name = name ? name : "application_unnamed_thread";
_attr.stack_mem = reinterpret_cast<uint32_t*>(aligned_mem);
_attr.tz_module = tz_module;
}
void Thread::constructor(Callback<void()> task,
osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name) {
constructor(priority, stack_size, stack_mem, name);
osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name, uint32_t tz_module) {
constructor(priority, stack_size, stack_mem, name, tz_module);
switch (start(task)) {
case osErrorResource:

View File

@ -73,6 +73,13 @@ namespace rtos {
* and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
* Additionally the stack memory for this thread will be allocated on the heap, if it wasn't supplied to the constructor.
*/
/* This flag can be used to change the default access of all threads in non-secure mode.
TZ_DEFAULT_ACCESS set to 1, means all non-secure threads have access to call secure functions. */
#ifndef TZ_DEFAULT_ACCESS
#define TZ_DEFAULT_ACCESS 0
#endif
class Thread : private mbed::NonCopyable<Thread> {
public:
/** Allocate a new thread without starting execution
@ -80,13 +87,15 @@ public:
@param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
@param stack_mem pointer to the stack area to be used by this thread (default: NULL).
@param name name to be used for this thread. It has to stay allocated for the lifetime of the thread (default: NULL)
@param tz_module trustzone thread identifier (osThreadAttr_t::tz_module) (default: TZ_DEFAULT_ACCESS)
@note You cannot call this function from ISR context.
*/
Thread(osPriority priority=osPriorityNormal,
uint32_t stack_size=OS_STACK_SIZE,
unsigned char *stack_mem=NULL, const char *name=NULL) {
constructor(priority, stack_size, stack_mem, name);
unsigned char *stack_mem=NULL, const char *name=NULL, uint32_t tz_module=TZ_DEFAULT_ACCESS) {
constructor(priority, stack_size, stack_mem, name, tz_module);
}
/** Create a new thread, and start it executing the specified function.
@ -427,12 +436,12 @@ private:
void constructor(osPriority priority=osPriorityNormal,
uint32_t stack_size=OS_STACK_SIZE,
unsigned char *stack_mem=NULL,
const char *name=NULL);
const char *name=NULL, uint32_t tz_module=TZ_DEFAULT_ACCESS);
void constructor(mbed::Callback<void()> task,
osPriority priority=osPriorityNormal,
uint32_t stack_size=OS_STACK_SIZE,
unsigned char *stack_mem=NULL,
const char *name=NULL);
const char *name=NULL, uint32_t tz_module=TZ_DEFAULT_ACCESS);
static void _thunk(void * thread_ptr);
mbed::Callback<void()> _task;