diff --git a/UNITTESTS/target_h/rtos/Mutex.h b/UNITTESTS/target_h/rtos/Mutex.h deleted file mode 100644 index a92abd8..0000000 --- a/UNITTESTS/target_h/rtos/Mutex.h +++ /dev/null @@ -1,49 +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 __MUTEX_H__ -#define __MUTEX_H__ - -#include -#include "rtos/mbed_rtos_types.h" -#include "rtos/internal/mbed_rtos1_types.h" - -namespace rtos { - -class Mutex { -public: - Mutex(); - - Mutex(const char *name); - - osStatus lock(); - - bool trylock(); - - bool trylock_for(uint32_t millisec); - - bool trylock_until(uint64_t millisec); - - osStatus unlock(); - - osThreadId_t get_owner(); - - ~Mutex(); -}; - -} - -#endif diff --git a/UNITTESTS/target_h/rtos/Semaphore.h b/UNITTESTS/target_h/rtos/Semaphore.h deleted file mode 100644 index aecea8f..0000000 --- a/UNITTESTS/target_h/rtos/Semaphore.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2019 ARM Limited - * 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 SEMAPHORE_H -#define SEMAPHORE_H - -#include -#include "internal/mbed_rtos1_types.h" -#include "rtos/Kernel.h" - -namespace rtos { -class Semaphore { -public: - Semaphore(int32_t count = 0); - Semaphore(int32_t count, uint16_t max_count); - void acquire(); - bool try_acquire(); - bool try_acquire_for(uint32_t millisec); - bool try_acquire_for(Kernel::Clock::duration_u32 rel_time); - bool try_acquire_until(uint64_t millisec); - bool try_acquire_until(Kernel::Clock::time_point abs_time); - osStatus release(void); - ~Semaphore(); -private: - void constructor(int32_t count, uint16_t max_count); -}; -} - -#endif diff --git a/UNITTESTS/target_h/rtos/Thread.h b/UNITTESTS/target_h/rtos/Thread.h deleted file mode 100644 index 1fa8e47..0000000 --- a/UNITTESTS/target_h/rtos/Thread.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef THREAD_H -#define THREAD_H - -#include -#include "cmsis_os.h" -#include "platform/Callback.h" - -#define OS_STACK_SIZE 0 - -namespace rtos { - -class Thread { -public: - - Thread(osPriority priority = osPriorityNormal, - uint32_t stack_size = OS_STACK_SIZE, - unsigned char *stack_mem = nullptr, const char *name = nullptr) - { - } - - Thread(uint32_t tz_module, osPriority priority = osPriorityNormal, - uint32_t stack_size = OS_STACK_SIZE, - unsigned char *stack_mem = nullptr, const char *name = nullptr) - { - } - - osStatus start(mbed::Callback task); - - osStatus join() {return 0;}; - osStatus terminate(); - osStatus set_priority(osPriority priority){return 0;}; - osPriority get_priority() const{return osPriorityNormal;}; - uint32_t flags_set(uint32_t flags){return 0;}; - - /** State of the Thread */ - enum State { - Inactive, /**< NOT USED */ - Ready, /**< Ready to run */ - Running, /**< Running */ - WaitingDelay, /**< Waiting for a delay to occur */ - WaitingJoin, /**< Waiting for thread to join. Only happens when using RTX directly. */ - WaitingThreadFlag, /**< Waiting for a thread flag to be set */ - WaitingEventFlag, /**< Waiting for a event flag to be set */ - WaitingMutex, /**< Waiting for a mutex event to occur */ - WaitingSemaphore, /**< Waiting for a semaphore event to occur */ - WaitingMemoryPool, /**< Waiting for a memory pool */ - WaitingMessageGet, /**< Waiting for message to arrive */ - WaitingMessagePut, /**< Waiting for message to be send */ - WaitingInterval, /**< NOT USED */ - WaitingOr, /**< NOT USED */ - WaitingAnd, /**< NOT USED */ - WaitingMailbox, /**< NOT USED (Mail is implemented as MemoryPool and Queue) */ - - /* Not in sync with RTX below here */ - Deleted, /**< The task has been deleted or not started */ - }; - - State get_state() const { - return Ready; - }; - uint32_t stack_size() const { - return 0; - }; - uint32_t free_stack() const { - return 0; - }; - uint32_t used_stack() const { - return 0; - }; - uint32_t max_stack() const { - return 0; - }; - const char *get_name() const { - return ""; - }; - osThreadId_t get_id() const { - return 0; - }; - virtual ~Thread(); -private: - // Required to share definitions without - // delegated constructors - void constructor(osPriority priority = osPriorityNormal, - uint32_t stack_size = OS_STACK_SIZE, - unsigned char *stack_mem = nullptr, - const char *name = nullptr); -}; -} -#endif diff --git a/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos1_types.h b/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos1_types.h deleted file mode 100644 index 4ff0189..0000000 --- a/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos1_types.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2017, 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_RTOS1_TYPES_H -#define MBED_RTOS1_TYPES_H - -#include "cmsis_os.h" -#include "mbed_rtos_storage.h" - -#endif // MBED_RTOS1_TYPES_H diff --git a/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h b/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h deleted file mode 100644 index c160374..0000000 --- a/UNITTESTS/target_h/rtos/include/rtos/internal/mbed_rtos_storage.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017, 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_RTOS_STORAGE_H -#define MBED_RTOS_STORAGE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "mbed_rtos_types.h" -#include "rtx_os.h" -#include "rtx_lib.h" -#include "mbed_rtx_conf.h" - -typedef os_semaphore_t mbed_rtos_storage_semaphore_t; -typedef os_thread_t mbed_rtos_storage_thread_t; -typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/UNITTESTS/target_h/rtos/rtos.h b/UNITTESTS/target_h/rtos/rtos.h deleted file mode 100644 index b624678..0000000 --- a/UNITTESTS/target_h/rtos/rtos.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018, 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 RTOS_H -#define RTOS_H - -typedef enum { - osTimerOnce = 0, ///< One-shot timer. - osTimerPeriodic = 1 ///< Repeating timer. -} os_timer_type; - -#endif /* RTOS_H */ diff --git a/rtos/tests/UNITTESTS/doubles/CMakeLists.txt b/rtos/tests/UNITTESTS/doubles/CMakeLists.txt index babf17c..ed8440d 100644 --- a/rtos/tests/UNITTESTS/doubles/CMakeLists.txt +++ b/rtos/tests/UNITTESTS/doubles/CMakeLists.txt @@ -5,6 +5,7 @@ target_include_directories(mbed-headers-rtos INTERFACE + . ${mbed-os_SOURCE_DIR}/rtos/include ${mbed-os_SOURCE_DIR}/rtos/include/rtos ) diff --git a/rtos/tests/UNITTESTS/doubles/rtos/Mutex.h b/rtos/tests/UNITTESTS/doubles/rtos/Mutex.h new file mode 100644 index 0000000..a92abd8 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtos/Mutex.h @@ -0,0 +1,49 @@ +/* + * 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 __MUTEX_H__ +#define __MUTEX_H__ + +#include +#include "rtos/mbed_rtos_types.h" +#include "rtos/internal/mbed_rtos1_types.h" + +namespace rtos { + +class Mutex { +public: + Mutex(); + + Mutex(const char *name); + + osStatus lock(); + + bool trylock(); + + bool trylock_for(uint32_t millisec); + + bool trylock_until(uint64_t millisec); + + osStatus unlock(); + + osThreadId_t get_owner(); + + ~Mutex(); +}; + +} + +#endif diff --git a/rtos/tests/UNITTESTS/doubles/rtos/Semaphore.h b/rtos/tests/UNITTESTS/doubles/rtos/Semaphore.h new file mode 100644 index 0000000..aecea8f --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtos/Semaphore.h @@ -0,0 +1,42 @@ +/* Copyright (c) 2019 ARM Limited + * 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 SEMAPHORE_H +#define SEMAPHORE_H + +#include +#include "internal/mbed_rtos1_types.h" +#include "rtos/Kernel.h" + +namespace rtos { +class Semaphore { +public: + Semaphore(int32_t count = 0); + Semaphore(int32_t count, uint16_t max_count); + void acquire(); + bool try_acquire(); + bool try_acquire_for(uint32_t millisec); + bool try_acquire_for(Kernel::Clock::duration_u32 rel_time); + bool try_acquire_until(uint64_t millisec); + bool try_acquire_until(Kernel::Clock::time_point abs_time); + osStatus release(void); + ~Semaphore(); +private: + void constructor(int32_t count, uint16_t max_count); +}; +} + +#endif diff --git a/rtos/tests/UNITTESTS/doubles/rtos/Thread.h b/rtos/tests/UNITTESTS/doubles/rtos/Thread.h new file mode 100644 index 0000000..1fa8e47 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtos/Thread.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2019 ARM Limited + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef THREAD_H +#define THREAD_H + +#include +#include "cmsis_os.h" +#include "platform/Callback.h" + +#define OS_STACK_SIZE 0 + +namespace rtos { + +class Thread { +public: + + Thread(osPriority priority = osPriorityNormal, + uint32_t stack_size = OS_STACK_SIZE, + unsigned char *stack_mem = nullptr, const char *name = nullptr) + { + } + + Thread(uint32_t tz_module, osPriority priority = osPriorityNormal, + uint32_t stack_size = OS_STACK_SIZE, + unsigned char *stack_mem = nullptr, const char *name = nullptr) + { + } + + osStatus start(mbed::Callback task); + + osStatus join() {return 0;}; + osStatus terminate(); + osStatus set_priority(osPriority priority){return 0;}; + osPriority get_priority() const{return osPriorityNormal;}; + uint32_t flags_set(uint32_t flags){return 0;}; + + /** State of the Thread */ + enum State { + Inactive, /**< NOT USED */ + Ready, /**< Ready to run */ + Running, /**< Running */ + WaitingDelay, /**< Waiting for a delay to occur */ + WaitingJoin, /**< Waiting for thread to join. Only happens when using RTX directly. */ + WaitingThreadFlag, /**< Waiting for a thread flag to be set */ + WaitingEventFlag, /**< Waiting for a event flag to be set */ + WaitingMutex, /**< Waiting for a mutex event to occur */ + WaitingSemaphore, /**< Waiting for a semaphore event to occur */ + WaitingMemoryPool, /**< Waiting for a memory pool */ + WaitingMessageGet, /**< Waiting for message to arrive */ + WaitingMessagePut, /**< Waiting for message to be send */ + WaitingInterval, /**< NOT USED */ + WaitingOr, /**< NOT USED */ + WaitingAnd, /**< NOT USED */ + WaitingMailbox, /**< NOT USED (Mail is implemented as MemoryPool and Queue) */ + + /* Not in sync with RTX below here */ + Deleted, /**< The task has been deleted or not started */ + }; + + State get_state() const { + return Ready; + }; + uint32_t stack_size() const { + return 0; + }; + uint32_t free_stack() const { + return 0; + }; + uint32_t used_stack() const { + return 0; + }; + uint32_t max_stack() const { + return 0; + }; + const char *get_name() const { + return ""; + }; + osThreadId_t get_id() const { + return 0; + }; + virtual ~Thread(); +private: + // Required to share definitions without + // delegated constructors + void constructor(osPriority priority = osPriorityNormal, + uint32_t stack_size = OS_STACK_SIZE, + unsigned char *stack_mem = nullptr, + const char *name = nullptr); +}; +} +#endif diff --git a/rtos/tests/UNITTESTS/doubles/rtos/internal/mbed_rtos1_types.h b/rtos/tests/UNITTESTS/doubles/rtos/internal/mbed_rtos1_types.h new file mode 100644 index 0000000..4ff0189 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtos/internal/mbed_rtos1_types.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 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_RTOS1_TYPES_H +#define MBED_RTOS1_TYPES_H + +#include "cmsis_os.h" +#include "mbed_rtos_storage.h" + +#endif // MBED_RTOS1_TYPES_H diff --git a/rtos/tests/UNITTESTS/doubles/rtos/internal/mbed_rtos_storage.h b/rtos/tests/UNITTESTS/doubles/rtos/internal/mbed_rtos_storage.h new file mode 100644 index 0000000..c160374 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtos/internal/mbed_rtos_storage.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 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_RTOS_STORAGE_H +#define MBED_RTOS_STORAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mbed_rtos_types.h" +#include "rtx_os.h" +#include "rtx_lib.h" +#include "mbed_rtx_conf.h" + +typedef os_semaphore_t mbed_rtos_storage_semaphore_t; +typedef os_thread_t mbed_rtos_storage_thread_t; +typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/rtos/tests/UNITTESTS/doubles/rtos/rtos.h b/rtos/tests/UNITTESTS/doubles/rtos/rtos.h new file mode 100644 index 0000000..b624678 --- /dev/null +++ b/rtos/tests/UNITTESTS/doubles/rtos/rtos.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018, 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 RTOS_H +#define RTOS_H + +typedef enum { + osTimerOnce = 0, ///< One-shot timer. + osTimerPeriodic = 1 ///< Repeating timer. +} os_timer_type; + +#endif /* RTOS_H */