diff --git a/UNITTESTS/target_h/cmsis.h b/UNITTESTS/target_h/cmsis.h deleted file mode 100644 index a3fa570..0000000 --- a/UNITTESTS/target_h/cmsis.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MBED_CMSIS_H -#define MBED_CMSIS_H - -#include -static inline uint32_t __RBIT(uint32_t x) -{ - x = ((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1); - x = ((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2); - x = ((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4); - x = ((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8); - x = (x >> 16) | (x << 16); - return x; -} - -#endif diff --git a/UNITTESTS/target_h/cmsis_compiler.h b/UNITTESTS/target_h/cmsis_compiler.h deleted file mode 100644 index a431b39..0000000 --- a/UNITTESTS/target_h/cmsis_compiler.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ diff --git a/UNITTESTS/target_h/cmsis_os.h b/UNITTESTS/target_h/cmsis_os.h deleted file mode 100644 index 4e8b557..0000000 --- a/UNITTESTS/target_h/cmsis_os.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CMSIS_OS_H_ -#define CMSIS_OS_H_ - -#include "mbed_rtos_types.h" - -#define osPriority osPriority_t - -#define osThreadId osThreadId_t - -typedef struct { -} osEvent; - -typedef int32_t osStatus; -#endif diff --git a/UNITTESTS/target_h/cmsis_os2.h b/UNITTESTS/target_h/cmsis_os2.h deleted file mode 100644 index 6c7d6d3..0000000 --- a/UNITTESTS/target_h/cmsis_os2.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CMSIS_OS2_H__ -#define __CMSIS_OS2_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -//If conflicts, then remove these, copied from cmsis_os.h -typedef int32_t osStatus; - - -//These are from cmsis_os2.h -typedef void *osSemaphoreId_t; - -typedef struct { - const char *name; ///< name of the semaphore - uint32_t attr_bits; ///< attribute bits - void *cb_mem; ///< memory for control block - uint32_t cb_size; ///< size of provided memory for control block -} osSemaphoreAttr_t; - -/// Status code values returned by CMSIS-RTOS functions. -typedef enum { - osOK = 0, ///< Operation completed successfully. - osError = -1, ///< Unspecified RTOS error: run-time error but no other error message fits. - osErrorTimeout = -2, ///< Operation not completed within the timeout period. - osErrorResource = -3, ///< Resource not available. - osErrorParameter = -4, ///< Parameter error. - osErrorNoMemory = -5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation. - osErrorISR = -6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines. - osStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. -} osStatus_t; - -//Thread -typedef enum { - osPriorityNormal = 24 ///< Priority: normal -} osPriority_t; - -typedef void *osThreadId_t; - -typedef void *osMutexId_t; - -typedef void *osEventFlagsId_t; - -/// Attributes structure for thread. -typedef struct { - int unused; -} osThreadAttr_t; - -#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value. - -// Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait). -#define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default). -#define osFlagsWaitAll 0x00000001U ///< Wait for all flags. -#define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for. - -// Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx). -#define osFlagsError 0x80000000U ///< Error indicator. -#define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1). -#define osFlagsErrorTimeout 0xFFFFFFFEU ///< osErrorTimeout (-2). -#define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3). -#define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4). -#define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6). - -// Thread attributes (attr_bits in \ref osThreadAttr_t). -#define osThreadDetached 0x00000000U ///< Thread created in detached mode (default) -#define osThreadJoinable 0x00000001U ///< Thread created in joinable mode - -// Mutex attributes (attr_bits in \ref osMutexAttr_t). -#define osMutexRecursive 0x00000001U ///< Recursive mutex. -#define osMutexPrioInherit 0x00000002U ///< Priority inherit protocol. -#define osMutexRobust 0x00000008U ///< Robust mutex. - -/// Acquire a Mutex or timeout if it is locked. -/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. -/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. -/// \return status code that indicates the execution status of the function. -osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout); - -/// Release a Mutex that was acquired by \ref osMutexAcquire. -/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. -/// \return status code that indicates the execution status of the function. -osStatus_t osMutexRelease(osMutexId_t mutex_id); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/UNITTESTS/target_h/mbed_rtx.h b/UNITTESTS/target_h/mbed_rtx.h deleted file mode 100644 index a431b39..0000000 --- a/UNITTESTS/target_h/mbed_rtx.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ diff --git a/UNITTESTS/target_h/mbed_rtx_conf.h b/UNITTESTS/target_h/mbed_rtx_conf.h deleted file mode 100644 index 17620e8..0000000 --- a/UNITTESTS/target_h/mbed_rtx_conf.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OS_STACK_SIZE -#define OS_STACK_SIZE 0 -#endif diff --git a/UNITTESTS/target_h/rtx_lib.h b/UNITTESTS/target_h/rtx_lib.h deleted file mode 100644 index 2b2368f..0000000 --- a/UNITTESTS/target_h/rtx_lib.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __RTX_LIB_H__ -#define __RTX_LIB_H__ - -#include "rtx_os.h" - -#define os_semaphore_t osRtxSemaphore_t -#define os_thread_t osRtxThread_t - -#endif diff --git a/UNITTESTS/target_h/rtx_os.h b/UNITTESTS/target_h/rtx_os.h deleted file mode 100644 index f280c67..0000000 --- a/UNITTESTS/target_h/rtx_os.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) , Arm Limited and affiliates. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __RTX_OS__ -#define __RTX_OS__ - -#include "inttypes.h" - -typedef struct osRtxSemaphore_s { - uint8_t id; ///< Object Identifier - uint8_t state; ///< Object State - uint8_t flags; ///< Object Flags - uint8_t reserved; - const char *name; ///< Object Name - uint16_t tokens; ///< Current number of tokens - uint16_t max_tokens; ///< Maximum number of tokens -} osRtxSemaphore_t; - -typedef struct osRtxThread_s { - uint8_t id; ///< Object Identifier - uint8_t state; ///< Object State - uint8_t flags; ///< Object Flags - uint8_t attr; ///< Object Attributes - const char *name; ///< Object Name - struct osRtxThread_s *thread_next; ///< Link pointer to next Thread in Object list - struct osRtxThread_s *thread_prev; ///< Link pointer to previous Thread in Object list - struct osRtxThread_s *delay_next; ///< Link pointer to next Thread in Delay list - struct osRtxThread_s *delay_prev; ///< Link pointer to previous Thread in Delay list - struct osRtxThread_s *thread_join; ///< Thread waiting to Join - uint32_t delay; ///< Delay Time - int8_t priority; ///< Thread Priority - int8_t priority_base; ///< Base Priority - uint8_t stack_frame; ///< Stack Frame (EXC_RETURN[7..0]) - uint8_t flags_options; ///< Thread/Event Flags Options - uint32_t wait_flags; ///< Waiting Thread/Event Flags - uint32_t thread_flags; ///< Thread Flags - struct osRtxMutex_s *mutex_list; ///< Link pointer to list of owned Mutexes - void *stack_mem; ///< Stack Memory - uint32_t stack_size; ///< Stack Size - uint32_t sp; ///< Current Stack Pointer - uint32_t thread_addr; ///< Thread entry address - uint32_t tz_memory; ///< TrustZone Memory Identifier - void *context; ///< Context for OsEventObserver objects -} osRtxThread_t; - -typedef struct { - uint8_t id; ///< Object Identifier - uint8_t state; ///< Object State - uint8_t flags; ///< Object Flags - uint8_t reserved; - const char *name; ///< Object Name - osRtxThread_t *thread_list; ///< Waiting Threads List - uint32_t event_flags; ///< Event Flags -} osRtxEventFlags_t; - -#endif diff --git a/cmsis/CMakeLists.txt b/cmsis/CMakeLists.txt index b2442a6..ecfe69c 100644 --- a/cmsis/CMakeLists.txt +++ b/cmsis/CMakeLists.txt @@ -4,3 +4,6 @@ add_subdirectory(CMSIS_5) add_subdirectory(device) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + add_subdirectory(tests/UNITTESTS/doubles) +endif() diff --git a/cmsis/tests/UNITTESTS/.mbedignore b/cmsis/tests/UNITTESTS/.mbedignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/cmsis/tests/UNITTESTS/.mbedignore @@ -0,0 +1 @@ +* diff --git a/cmsis/tests/UNITTESTS/doubles/CMakeLists.txt b/cmsis/tests/UNITTESTS/doubles/CMakeLists.txt new file mode 100644 index 0000000..f220a6f --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2021 Arm Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-headers-cmsis INTERFACE) + +target_include_directories(mbed-headers-cmsis + INTERFACE + . +) diff --git a/cmsis/tests/UNITTESTS/doubles/cmsis.h b/cmsis/tests/UNITTESTS/doubles/cmsis.h new file mode 100644 index 0000000..a3fa570 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/cmsis.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MBED_CMSIS_H +#define MBED_CMSIS_H + +#include +static inline uint32_t __RBIT(uint32_t x) +{ + x = ((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1); + x = ((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2); + x = ((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4); + x = ((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8); + x = (x >> 16) | (x << 16); + return x; +} + +#endif diff --git a/cmsis/tests/UNITTESTS/doubles/cmsis_compiler.h b/cmsis/tests/UNITTESTS/doubles/cmsis_compiler.h new file mode 100644 index 0000000..a431b39 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/cmsis_compiler.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/cmsis/tests/UNITTESTS/doubles/cmsis_os.h b/cmsis/tests/UNITTESTS/doubles/cmsis_os.h new file mode 100644 index 0000000..4e8b557 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/cmsis_os.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CMSIS_OS_H_ +#define CMSIS_OS_H_ + +#include "mbed_rtos_types.h" + +#define osPriority osPriority_t + +#define osThreadId osThreadId_t + +typedef struct { +} osEvent; + +typedef int32_t osStatus; +#endif diff --git a/cmsis/tests/UNITTESTS/doubles/cmsis_os2.h b/cmsis/tests/UNITTESTS/doubles/cmsis_os2.h new file mode 100644 index 0000000..6c7d6d3 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/cmsis_os2.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_OS2_H__ +#define __CMSIS_OS2_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +//If conflicts, then remove these, copied from cmsis_os.h +typedef int32_t osStatus; + + +//These are from cmsis_os2.h +typedef void *osSemaphoreId_t; + +typedef struct { + const char *name; ///< name of the semaphore + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osSemaphoreAttr_t; + +/// Status code values returned by CMSIS-RTOS functions. +typedef enum { + osOK = 0, ///< Operation completed successfully. + osError = -1, ///< Unspecified RTOS error: run-time error but no other error message fits. + osErrorTimeout = -2, ///< Operation not completed within the timeout period. + osErrorResource = -3, ///< Resource not available. + osErrorParameter = -4, ///< Parameter error. + osErrorNoMemory = -5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation. + osErrorISR = -6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines. + osStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osStatus_t; + +//Thread +typedef enum { + osPriorityNormal = 24 ///< Priority: normal +} osPriority_t; + +typedef void *osThreadId_t; + +typedef void *osMutexId_t; + +typedef void *osEventFlagsId_t; + +/// Attributes structure for thread. +typedef struct { + int unused; +} osThreadAttr_t; + +#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value. + +// Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait). +#define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default). +#define osFlagsWaitAll 0x00000001U ///< Wait for all flags. +#define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for. + +// Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx). +#define osFlagsError 0x80000000U ///< Error indicator. +#define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1). +#define osFlagsErrorTimeout 0xFFFFFFFEU ///< osErrorTimeout (-2). +#define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3). +#define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4). +#define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6). + +// Thread attributes (attr_bits in \ref osThreadAttr_t). +#define osThreadDetached 0x00000000U ///< Thread created in detached mode (default) +#define osThreadJoinable 0x00000001U ///< Thread created in joinable mode + +// Mutex attributes (attr_bits in \ref osMutexAttr_t). +#define osMutexRecursive 0x00000001U ///< Recursive mutex. +#define osMutexPrioInherit 0x00000002U ///< Priority inherit protocol. +#define osMutexRobust 0x00000008U ///< Robust mutex. + +/// Acquire a Mutex or timeout if it is locked. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout); + +/// Release a Mutex that was acquired by \ref osMutexAcquire. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexRelease(osMutexId_t mutex_id); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cmsis/tests/UNITTESTS/doubles/mbed_rtx.h b/cmsis/tests/UNITTESTS/doubles/mbed_rtx.h new file mode 100644 index 0000000..a431b39 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/mbed_rtx.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/cmsis/tests/UNITTESTS/doubles/mbed_rtx_conf.h b/cmsis/tests/UNITTESTS/doubles/mbed_rtx_conf.h new file mode 100644 index 0000000..17620e8 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/mbed_rtx_conf.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OS_STACK_SIZE +#define OS_STACK_SIZE 0 +#endif diff --git a/cmsis/tests/UNITTESTS/doubles/rtx_lib.h b/cmsis/tests/UNITTESTS/doubles/rtx_lib.h new file mode 100644 index 0000000..2b2368f --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/rtx_lib.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __RTX_LIB_H__ +#define __RTX_LIB_H__ + +#include "rtx_os.h" + +#define os_semaphore_t osRtxSemaphore_t +#define os_thread_t osRtxThread_t + +#endif diff --git a/cmsis/tests/UNITTESTS/doubles/rtx_os.h b/cmsis/tests/UNITTESTS/doubles/rtx_os.h new file mode 100644 index 0000000..f280c67 --- /dev/null +++ b/cmsis/tests/UNITTESTS/doubles/rtx_os.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __RTX_OS__ +#define __RTX_OS__ + +#include "inttypes.h" + +typedef struct osRtxSemaphore_s { + uint8_t id; ///< Object Identifier + uint8_t state; ///< Object State + uint8_t flags; ///< Object Flags + uint8_t reserved; + const char *name; ///< Object Name + uint16_t tokens; ///< Current number of tokens + uint16_t max_tokens; ///< Maximum number of tokens +} osRtxSemaphore_t; + +typedef struct osRtxThread_s { + uint8_t id; ///< Object Identifier + uint8_t state; ///< Object State + uint8_t flags; ///< Object Flags + uint8_t attr; ///< Object Attributes + const char *name; ///< Object Name + struct osRtxThread_s *thread_next; ///< Link pointer to next Thread in Object list + struct osRtxThread_s *thread_prev; ///< Link pointer to previous Thread in Object list + struct osRtxThread_s *delay_next; ///< Link pointer to next Thread in Delay list + struct osRtxThread_s *delay_prev; ///< Link pointer to previous Thread in Delay list + struct osRtxThread_s *thread_join; ///< Thread waiting to Join + uint32_t delay; ///< Delay Time + int8_t priority; ///< Thread Priority + int8_t priority_base; ///< Base Priority + uint8_t stack_frame; ///< Stack Frame (EXC_RETURN[7..0]) + uint8_t flags_options; ///< Thread/Event Flags Options + uint32_t wait_flags; ///< Waiting Thread/Event Flags + uint32_t thread_flags; ///< Thread Flags + struct osRtxMutex_s *mutex_list; ///< Link pointer to list of owned Mutexes + void *stack_mem; ///< Stack Memory + uint32_t stack_size; ///< Stack Size + uint32_t sp; ///< Current Stack Pointer + uint32_t thread_addr; ///< Thread entry address + uint32_t tz_memory; ///< TrustZone Memory Identifier + void *context; ///< Context for OsEventObserver objects +} osRtxThread_t; + +typedef struct { + uint8_t id; ///< Object Identifier + uint8_t state; ///< Object State + uint8_t flags; ///< Object Flags + uint8_t reserved; + const char *name; ///< Object Name + osRtxThread_t *thread_list; ///< Waiting Threads List + uint32_t event_flags; ///< Event Flags +} osRtxEventFlags_t; + +#endif diff --git a/platform/tests/UNITTESTS/doubles/CMakeLists.txt b/platform/tests/UNITTESTS/doubles/CMakeLists.txt index 3171096..cb8bd7f 100644 --- a/platform/tests/UNITTESTS/doubles/CMakeLists.txt +++ b/platform/tests/UNITTESTS/doubles/CMakeLists.txt @@ -10,6 +10,10 @@ ${mbed-os_SOURCE_DIR}/platform/randlib/include/ ${mbed-os_SOURCE_DIR}/platform/mbed-trace/include ) +target_link_libraries(mbed-headers-platform + INTERFACE + mbed-headers-cmsis +) add_library(mbed-stubs-platform) target_sources(mbed-stubs-platform