-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14396 from LDong-Arm/tfm_os_wrapper
TF-M: Switch to vanilla TF-M's OS wrapper
- Loading branch information
Showing
13 changed files
with
518 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/VERSION.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
706a1e6db255 | ||
8635d8a23341 |
26 changes: 26 additions & 0 deletions
26
...URE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/os_wrapper/common.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2017-2019, Arm Limited. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
*/ | ||
|
||
#ifndef __OS_WRAPPER_COMMON_H__ | ||
#define __OS_WRAPPER_COMMON_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stdint.h> | ||
|
||
#define OS_WRAPPER_SUCCESS (0x0) | ||
#define OS_WRAPPER_ERROR (0xFFFFFFFFU) | ||
#define OS_WRAPPER_WAIT_FOREVER (0xFFFFFFFFU) | ||
#define OS_WRAPPER_DEFAULT_STACK_SIZE (-1) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __OS_WRAPPER_COMMON_H__ */ |
62 changes: 62 additions & 0 deletions
62
...TURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/os_wrapper/mutex.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2017-2019, Arm Limited. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
*/ | ||
|
||
#ifndef __OS_WRAPPER_MUTEX_H__ | ||
#define __OS_WRAPPER_MUTEX_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "common.h" | ||
|
||
/** | ||
* \brief Creates a mutex for mutual exclusion of resources | ||
* | ||
* \return The handle of the created mutex on success or NULL on error | ||
*/ | ||
void *os_wrapper_mutex_create(void); | ||
|
||
/** | ||
* \brief Acquires a mutex that is created by \ref os_wrapper_mutex_create() | ||
* | ||
* \param[in] handle The handle of the mutex to acquire. Should be one of the | ||
* handles returned by \ref os_wrapper_mutex_create() | ||
* \param[in] timeout The maximum amount of time(in tick periods) for the | ||
* thread to wait for the mutex to be available. | ||
* If timeout is zero, the function will return immediately. | ||
* Setting timeout to \ref OS_WRAPPER_WAIT_FOREVER will | ||
* cause the thread to wait indefinitely | ||
* | ||
* \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error | ||
*/ | ||
uint32_t os_wrapper_mutex_acquire(void *handle, uint32_t timeout); | ||
|
||
/** | ||
* \brief Releases the mutex acquired previously | ||
* | ||
* \param[in] handle The handle of the mutex that has been acquired | ||
* | ||
* \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error | ||
*/ | ||
uint32_t os_wrapper_mutex_release(void *handle); | ||
|
||
/** | ||
* \brief Deletes a mutex that is created by \ref os_wrapper_mutex_create() | ||
* | ||
* \param[in] handle The handle of the mutex to be deleted | ||
* | ||
* \return \ref OS_WRAPPER_SUCCESS on success or \ref OS_WRAPPER_ERROR on error | ||
*/ | ||
uint32_t os_wrapper_mutex_delete(void *handle); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __OS_WRAPPER_MUTEX_H__ */ |
64 changes: 64 additions & 0 deletions
64
..._EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/os_wrapper/semaphore.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2017-2020, Arm Limited. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
*/ | ||
|
||
#ifndef __OS_WRAPPER_SEMAPHORE_H__ | ||
#define __OS_WRAPPER_SEMAPHORE_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "common.h" | ||
|
||
/** | ||
* \brief Creates a new semaphore | ||
* | ||
* \param[in] max_count Highest count of the semaphore | ||
* \param[in] initial_count Starting count of the available semaphore | ||
* \param[in] name Name of the semaphore | ||
* | ||
* \return Returns handle of the semaphore created, or NULL in case of error | ||
*/ | ||
void *os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count, | ||
const char *name); | ||
|
||
/** | ||
* \brief Acquires the semaphore | ||
* | ||
* \param[in] hanlde Semaphore handle | ||
* \param[in] timeout Timeout value | ||
* | ||
* \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or | ||
* \ref OS_WRAPPER_ERROR in case of error | ||
*/ | ||
uint32_t os_wrapper_semaphore_acquire(void *handle, uint32_t timeout); | ||
|
||
/** | ||
* \brief Releases the semaphore | ||
* | ||
* \param[in] hanlde Semaphore handle | ||
* | ||
* \return \ref OS_WRAPPER_SUCCESS in case of successful release, or | ||
* \ref OS_WRAPPER_ERROR in case of error | ||
*/ | ||
uint32_t os_wrapper_semaphore_release(void *handle); | ||
|
||
/** | ||
* \brief Deletes the semaphore | ||
* | ||
* \param[in] handle Semaphore handle | ||
* | ||
* \return \ref OS_WRAPPER_SUCCESS in case of successful release, or | ||
* \ref OS_WRAPPER_ERROR in case of error | ||
*/ | ||
uint32_t os_wrapper_semaphore_delete(void *handle); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __OS_WRAPPER_SEMAPHORE_H__ */ |
103 changes: 103 additions & 0 deletions
103
...URE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/include/os_wrapper/thread.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright (c) 2017-2020, Arm Limited. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
*/ | ||
|
||
#ifndef __OS_WRAPPER_THREAD_H__ | ||
#define __OS_WRAPPER_THREAD_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "common.h" | ||
|
||
/* prototype for the thread entry function */ | ||
typedef void (*os_wrapper_thread_func) (void *argument); | ||
|
||
/** | ||
* \brief Creates a new thread | ||
* | ||
* \param[in] name Name of the thread | ||
* \param[in] stack_size Size of stack to be allocated for this thread. It can | ||
* be \ref OS_WRAPPER_DEFAULT_STACK_SIZE to use the | ||
* default value provided by the underlying RTOS | ||
* \param[in] func Pointer to the function invoked by thread | ||
* \param[in] arg Argument to pass to the function invoked by thread | ||
* \param[in] priority Initial thread priority | ||
* | ||
* \return Returns the thread handle created, or NULL in case of error | ||
*/ | ||
void *os_wrapper_thread_new(const char *name, int32_t stack_size, | ||
os_wrapper_thread_func func, void *arg, | ||
uint32_t priority); | ||
/** | ||
* \brief Gets current thread handle | ||
* | ||
* \return Returns the thread handle, or NULL in case of error | ||
*/ | ||
void *os_wrapper_thread_get_handle(void); | ||
|
||
/** | ||
* \brief Gets thread priority | ||
* | ||
* \param[in] handle Thread handle | ||
* \param[out] priority The priority of the thread | ||
* | ||
* \return Returns \ref OS_WRAPPER_SUCCESS on success, or \ref OS_WRAPPER_ERROR | ||
* in case of error | ||
*/ | ||
uint32_t os_wrapper_thread_get_priority(void *handle, uint32_t *priority); | ||
|
||
/** | ||
* \brief Exits the calling thread | ||
*/ | ||
void os_wrapper_thread_exit(void); | ||
|
||
/** | ||
* \brief Set the event flags for synchronizing a thread specified by handle. | ||
* | ||
* \note This function may not be allowed to be called from Interrupt Service | ||
* Routines. | ||
* | ||
* \param[in] handle Thread handle to be notified | ||
* \param[in] flags Event flags value | ||
* | ||
* \return Returns \ref OS_WRAPPER_SUCCESS on success, or \ref OS_WRAPPER_ERROR | ||
* in case of error | ||
*/ | ||
uint32_t os_wrapper_thread_set_flag(void *handle, uint32_t flags); | ||
|
||
/** | ||
* \brief Set the event flags in an interrupt handler for synchronizing a thread | ||
* specified by handle. | ||
* | ||
* \param[in] handle Thread handle to be notified | ||
* \param[in] flags Event flags value | ||
* | ||
* \return Returns \ref OS_WRAPPER_SUCCESS on success, or \ref OS_WRAPPER_ERROR | ||
* in case of error | ||
*/ | ||
uint32_t os_wrapper_thread_set_flag_isr(void *handle, uint32_t flags); | ||
|
||
/** | ||
* \brief Wait for the event flags for synchronizing threads. | ||
* | ||
* \note This function may not be allowed to be called from Interrupt Service | ||
* Routines. | ||
* | ||
* \param[in] flags Specify the flags to wait for | ||
* \param[in] timeout Timeout value | ||
* | ||
* \return Returns \ref OS_WRAPPER_SUCCESS on success, or \ref OS_WRAPPER_ERROR | ||
* in case of error | ||
*/ | ||
uint32_t os_wrapper_thread_wait_flag(uint32_t flags, uint32_t timeout); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __OS_WRAPPER_THREAD_H__ */ |
Oops, something went wrong.