Commit Graph

326 Commits (8b6a7aacc5d2b90ba40d89c8eeb680ebee81ea18)

Author SHA1 Message Date
Russ Butler 0c4e50abb3 Add ConditionVariable to mbed rtos
Add the ConditionVariable class to mbed rtos to provide easier and
safer synchronization.
2017-11-02 21:02:27 -05:00
Jimmy Brisson 3a05b63f1e
Merge pull request #5158 from YarivCol/master
RTOS : added empty and full functions to Mail and Queue
2017-11-02 10:46:06 -05:00
Jaeden Amero 75ad20b65f RTX5: uVisor: Switch threads very carefully
uVisor doesn't set the PSP of the target thread. The RTOS sets the PSP
of the target thread from the target thread's TCB. However, when
interrupts of higher priority than PendSV happen between the call to
uVisor to switch boxes, and the RTOS setting PSP, the uVisor vIRQ
interrupt handler will attempt to use an invalid PSP (the PSP from
before the box and thread switch). This leads to a crash. Make box and
thread switching atomic by disabling interrupts immediately before the
box switching until immediately after the new PSP is set.
2017-11-01 09:25:43 +00:00
Jaeden Amero 474f6c63ba RTX5: uVisor: Use OsEventObserver 2017-11-01 09:25:43 +00:00
Jaeden Amero 12a47f0031 RTX5: uVisor: Extend thread control block with context
OsEventObserver objects expect a context to be maintained per thread on
their behalf. Add this context to the thread control block and extend
the thread creation functions with the ability to supply a context.
2017-11-01 09:25:43 +00:00
Jaeden Amero f363ccbb59 RTX5: uVisor: Add OsEventObserver
Add the OsEventObserver mechanism. A client interested in receiving
notifications on certain OS events can register to receive notifications
with osRegisterForOsEvents. This is useful for clients like the secure
memory allocator, which observes thread switching events in order to
swap in and out different memory allocator objects.
2017-11-01 09:25:42 +00:00
Jaeden Amero 372b7b8b47 RTX5: uVisor: Defer to uVisor for SVCall priority
Only set the SVCall priority if uVisor is not present. If uVisor is
present, keep using whatever priorities it has already set up.
2017-11-01 09:25:42 +00:00
Bartek Szatkowski b8aa068def CMSIS/RTX: Rename asm files to upper case .S 2017-11-01 09:25:42 +00:00
Bartek Szatkowski 4523b5d266 CMSIS/RTX: Allow overwriting _mutex_initialize symbol for ARMC 2017-11-01 09:25:42 +00:00
Bartek Szatkowski 3f97e57364 CMSIS/RTX: Remove os_tick_gtim.c
This implementation of timer conflicts with the default ptim, we will
keep the default and let the timer override the implmenetation if
needed.
2017-11-01 09:25:42 +00:00
Bartek Szatkowski 1b131edd69 CMSIS/RTX: Patch RTX so irq_cm4f.s files work with no FPU targets 2017-11-01 09:25:42 +00:00
Bartek Szatkowski 5d6abd6572 CMSIS/RTX: Patch RTX includes to match mbed OS scheme 2017-11-01 09:25:42 +00:00
Bartek Szatkowski d5933f198c CMSIS/RTX: Patch RTX4 to preserve osThreadDef compatibility
mbed OS used older RTX4 version and with osThreadDef accepting only 3
parameters, to preserve compatibility we hardcode the 'instances'
parameter to 1.
2017-11-01 09:25:42 +00:00
Bartek Szatkowski a03591d6e3 CMSIS/RTX: Update CMSIS and RTX to 22b68c
This includes Cortex A support and directory reshuffle.
2017-11-01 09:25:42 +00:00
Russ Butler d98a011749 Ensure Thread stack is 8 byte aligned
Ensure both the stack and stack size used in the Thread class are
aligned to 8 bytes. This prevents the runtime error
"Thread 0 error -11: Unknown" due to incorrect stack alignment.
2017-10-31 11:58:18 -05:00
Senthil Ramakrishnan 3ad298488c Doxygen comment updates and fixes 2017-10-26 15:36:26 -05:00
Anna Bridge 9c1fd48529 Merge pull request #5278 from maciejbocianski/heap_and_stack_tests
Move heap_and_stack tests to TESTS/mbed_bootstrap
2017-10-20 10:25:07 +01:00
Martin Kojtal cbb8a1f994 Merge pull request #4947 from fkjagodzinski/rtostimer_tests
Rtostimer tests
2017-10-19 16:46:12 +01:00
Maciej Bocianski 9ab2a1df32 Move heap_and_stack tests 2017-10-13 08:23:55 +02:00
Russ Butler 209b9a9e62 Add error if OS tickrate is changed
The current mbed-os drivers rely on a tickrate of 1ms for timing.
This means that if OS_TICK_FREQ is set to any value other than 1000
then mbed-os driver will no longer delay for the correct amount of
time. To prevent this from happening this patch triggers a compile
time error if a tickrate other than 1m is used.
2017-10-05 16:31:14 -05:00
Jimmy Brisson 93459011b0 Merge pull request #5105 from deepikabhavnani/m33_files
Cortex-M33: Add RTX5 context switcher files
2017-10-02 10:38:35 -05:00
Jimmy Brisson b83b0b1678 Merge pull request #5098 from maciejbocianski/signal_fix
Doxygen comment fix for Thread class
2017-10-02 10:37:55 -05:00
Jimmy Brisson 74e592757f Merge pull request #5078 from v2422/master
Enable access to kernel tick information in ISR
2017-09-29 10:10:46 -05:00
Maciej Bocianski a3a73cb281 Doxygen comment fix for Thread class 2017-09-29 15:51:41 +02:00
Martin Kojtal 1fed1d003e Merge pull request #4684 from deepikabhavnani/thread_stack_issue
Add thread terminate hook
2017-09-22 11:31:39 +01:00
YarivCol ba7045392c fix doc in the function empty 2017-09-21 05:07:42 -07:00
YarivCol cf2378ecbd Added empty, full function to Queue and Mail 2017-09-21 03:09:45 -07:00
Anna Bridge 02a10e5974 Merge pull request #5094 from deepikabhavnani/m23_armc6
ARMC6 support for Cortex-M23
2017-09-19 10:25:33 +01:00
Deepika e235772ed5 Replaced older version of assembly file with 2016-2017 version from RTX 2017-09-14 23:15:12 -05:00
Deepika a2b53011be Added thread terminate hook
Hook was added in RTX4 code to assist test framework to log thread info on
thread terminate, which was not working with RTX5.
2017-09-14 16:21:48 -05:00
Jaeden Amero 0d34c3636e mbed_rtx_idle: uVisor: Don't attempt to sleep
When uVisor is enabled, don't attempt to sleep. Attempting to sleep will
fail, as per <https://github.com/ARMmbed/uvisor/issues/420>.
2017-09-14 17:20:23 +01:00
Deepika 1916000472 [Cortex-M33] Added RTX5 context switcher files 2017-09-14 10:07:18 -05:00
Deepika 60c600ac11 ARMC6 support for Cortex-M23 2017-09-13 17:07:05 -05:00
Anna Bridge 7b428916f5 Merge pull request #4949 from theotherjimmy/feature-armc5+armc6
NEW TOOLCHAIN: Add the ARMC6 Compiler
2017-09-13 10:39:15 +01:00
Viller Hsiao 6c5af87c73 Enable access to kernel tick information in ISR
The osKernelGetTickCount() is the only function to get kernel tick information,
however it's not allowed to access in ISR.

It's already enabled in API v2.1.1.
2017-09-12 17:54:35 +08:00
Jimmy Brisson 922bf1b619 Update mbed OS to handle ARMC6 requirements 2017-09-11 13:20:32 -05:00
Deepika 9422c351e4 Initial RTX and tools support for Cortex M-23/M-33 devices 2017-09-11 11:43:26 -05:00
Anna Bridge cab660d980 Merge pull request #4938 from deepikabhavnani/IAR_fixes
Update IAR to version 8
2017-09-11 17:28:38 +01:00
Russ Butler c3eae587eb Add tickless support for devices without SysTick
Some Cortex-M0 devices, such as the nrf51, don't have the SysTick.
Instead, these targets use a software interrupt to simulate SysTick.
Add the hooks in the tickless code to support these devices. Targets
which do not have SysTick should now define NO_SYSTICK in targets.json
and implement mbed_get_m0_tick_irqn to add os suport.

This patch also removes os tick handling from the existing devices
(nrf51) since this is now handled in common code.
2017-09-07 21:35:04 -05:00
Russ Butler e44d94fa1e Add initial support for tickless RTX
Add support for tickless by replacing RTX's SysTick timer code with
with code which uses an mbed timer along with suspending and
resuming the kernel in the idle loop. Tickless is enabled on a
per-target basis by defining the macro MBED_TICKLESS.
2017-09-07 21:34:57 -05:00
Jimmy Brisson e12f116ec1 Merge pull request #4912 from 0xc0170/dev_sleep_drivers
Add sleep manager API
2017-09-07 18:26:49 -05:00
Martin Kojtal 39f31c3195 idle loop: add deepsleep locks
For backward compability, we invoke just sleep mode. Adding critical section to complete
lock/unlock deepsleep section.
2017-09-07 15:35:07 +01:00
Deepika 7d98eebf2a __IAR_SYSTEMS_ICC__ macro had issues when 7.5 and 8.11 both workbench are installed 2017-09-06 09:51:17 -05:00
Deepika fe2646d183 Added new locking init requirement for v8.x
The application must call void __iar_Initlocks(void); before any
lock is used.
2017-09-06 09:51:16 -05:00
Deepika 6c1ad4a4e4 Use correct IAR toolchain macro 2017-09-06 09:51:16 -05:00
Deepika 22afcfacbd _MAX_LOCK define is moved to DLib_Threads.h 2017-09-06 09:51:15 -05:00
Russ Butler b2384b1629 Remove use of internal RTX types
Make calls to cmsis-os to get thread state, stack size, and max stack
usage rather than accessing internal RTX data directly. Wrap RTX5
specific code in OS_BACKEND_RTX5.

Also refactor the code to use mbed types rather than RTX types:
os_timer_t -> mbed_rtos_storage_timer_t
os_event_flags_t -> mbed_rtos_storage_event_flags_t
osRtxMutex_t -> mbed_rtos_storage_thread_t
2017-09-04 11:26:38 -05:00
Filip Jagodzinski 4b0cf636be RTOS: RtosTimer: Improve API docs 2017-09-04 16:10:53 +02:00
Russ Butler ac22225ad9 Move Cortex specific RTX behind TARGET_CORTEX
Update directory structure to include RTX for only cortex targets, and
for all cortex targets. This patch accomplishes this by moving mbed-os
specific RTX files and RTX itself into rtos/TARGET_CORTEX along with
removing TARGET_CORTEX_M from the RTX5 directory.

The old directory structure:

rtos/rtx5/<mbed-os specific RTX files>
rtos/rtx5/TARGET_CORTEX_M/*
rtos/rtx4/*
rtos/<mbed-os specific RTX files>

Is re-arranged to:

rtos/TARGET_CORTEX/rtx5/*
rtos/TARGET_CORTEX/rtx4/*
rtos/TARGET_CORTEX/<mbed-os specific rtx files>

This both encapsulates RTX code more cleanly and makes it easier to
experiment with non-cortex cmsis-os2 backends, such as a posix
based cmsis-os2 backend.

Note - A potentially better name for the CORTEX_M directory would be
something like FEATURE_RTX5 since this directory only contains RTX5
related files. This cannot be done because there is not an easy way
to turn this feature on, since it cannot be done from mbed_lib.json.
2017-08-31 19:55:54 -05:00
Jimmy Brisson 3e00a22d78 Merge pull request #4941 from mprse/fix_mem_pool_header_file
Update of MemoryPool.h header file.
2017-08-24 10:18:18 -05:00
Przemyslaw Stekiel 5abbccb45c Fix pool buffer size, update free() description, add assertion in MemoryPool.h header file.
Provide fix for pool buffer size: pool block size must be
a multiple of 4 bytes.
Add assertion to forbid creation of MemoryPool object with queue size equal to 0.
Update description of free() function. Add information about
statuses returned by this function.
2017-08-21 18:09:51 +01:00
Bartek Szatkowski b0ad73ea41 RTOS: Changes to the EvenFlags API, doxy and tests 2017-08-15 13:33:32 +01:00
YarivCol c532a9a06d RTOS: Add EventFlags class
EventFlags class is a wrapper for Event Flag functionality introduced in
RTOS2/RTX5.
2017-08-15 13:27:30 +01:00
Jimmy Brisson 99a8467b70 Merge pull request #4817 from c1728p9/move_rtx_handlers
Move RTX error handlers into RTX handler file
2017-08-14 11:44:19 -05:00
Jimmy Brisson a81783e177 Merge pull request #4752 from bulislaw/queue_tests
RTOS: Queue tests & docs rework
2017-08-07 10:27:11 -05:00
Russ Butler 46f6f52299 Move RTX error handlers into RTX handler file
Move the RTX error handlers out of mbed_retarget.cpp and into an the
dedicated RTX handler file.
2017-07-27 10:08:39 -05:00
Jimmy Brisson c5c470e22c Merge pull request #4729 from bulislaw/mutex_tests
RTOS: Mutex: Rework tests
2017-07-27 09:40:26 -05:00
Bartek Szatkowski a1736e6341 Boot: Provide dynamic mutexes for ARM toolchain
ARM toolchain requires variable number of dynamic mutexes. We use combination of
RTX mutex pool and heap allocation to achieve that.
2017-07-21 10:09:53 +01:00
Jimmy Brisson 160940b30e Merge pull request #4682 from bulislaw/sem_tests
Test: RTOS: Semaphore: Rework tests
2017-07-17 11:06:48 -05:00
Jimmy Brisson 18bb6fdc1f Merge pull request #4620 from bulislaw/thread_tests
Extend tests for RTOS Thread class
2017-07-17 11:03:34 -05:00
Bartek Szatkowski ffd1c031a6 RTOS: Queue: Improve API docs 2017-07-12 15:39:54 +01:00
Bartek Szatkowski 0935683187 RTOS: Mutex: Improve API docs 2017-07-12 11:02:12 +01:00
Bartek Szatkowski 2963308349 RTOS: Semaphore: Improve API docs 2017-07-11 15:01:40 +01:00
Bartek Szatkowski 739a429820 Test: RTOS: Semaphore: Rework tests 2017-07-11 15:01:39 +01:00
Kevin Gilbert 4d1ad1d3d5 Fix typo runnig_thread -> running_thread 2017-06-30 17:24:43 -05:00
Jimmy Brisson 2ffd264bba Merge pull request #4601 from pan-/fix_memory_pool_destructor
rtos: Fix MemoryPool and Queue destructor
2017-06-29 11:07:38 -05:00
Bartek Szatkowski 0b359263d8 RTOS: Thread: Update thread state docs 2017-06-29 13:01:22 +01:00
Bartek Szatkowski 4c489e686b RTOS: Thread: Fix how free stack is calculated 2017-06-29 13:01:21 +01:00
Bartek Szatkowski 505beb773f RTOS: Thread: Fix return value for signal_wait
Signal wait was always returning success even in case of error.
2017-06-29 12:58:44 +01:00
Bartek Szatkowski af1832d4c7 RTOS: Thread: Update docs; make singal_clr static as it's affects running thread 2017-06-29 12:58:44 +01:00
Bartek Szatkowski 8cc21ea505 RTX: Fixed RTXv5 mutex owner list handling.
The prev-pointer of the running threads mutex list was not set when
multiple mutexes are acquired at a time. This leads to a corrupted list
if the mutexes are not freed in reversed order.

Original commit for CMSIS_5:
commit 729f6ab08540342b7de7612fac103539d5b2f168
Author: Jonatan Antoni <jonatan.antoni@arm.com>
Date:   Wed Apr 19 15:38:43 2017 +0200
2017-06-27 14:39:34 +01:00
Vincent Coubard e690ee04e0 rtos: Add missing Queue destructor. 2017-06-21 11:21:34 +01:00
Vincent Coubard b49fbf1d91 rtos: Add missing destructor for MemoryPool objects. 2017-06-21 11:14:50 +01:00
Vincent Coubard 3119c4238d rtos Thread: Remove private copy constructor and assignment operators in favor of the NonCopyable traits. 2017-06-20 16:23:44 +01:00
Vincent Coubard 4d5f805cde rtos: Tag non value type as NonCopyable.
The types marked are: Mail, MemoryPool, Mutex, Queue, RtosTimer and Semaphore.
2017-06-20 16:23:44 +01:00
Jimmy Brisson 77b6127a71 Merge pull request #4579 from geky/rtos-unbreak-semaphore
RTOS: Fix semaphore
2017-06-19 15:32:48 -05:00
Christopher Haster 6b02ceab5d rtos: Unbreak semaphore, trade assert for saturation with original limit
Before rtx 5, the max count on semaphores was UINT16_MAX, aftewards it
was decreased to 1024 with an assert on overflow.

This is especially problematic for semaphores used for signaling, since
there is no replacement currently available in C++.
2017-06-16 17:18:40 -05:00
Vincent Coubard fd7eff202c RTOS: Allow per target definition of OS_IDLE_THREAD_STACK_SIZE.
The stack required for the idle thread is highly dependent on the
target because it will call the sleep function which is target
specific.

While 256 bytes of stack is enough for most targets, others like the
NRF52840 might require more.

With this change, target maintainers can specify the idle thread stack
size in their mbed_rtx.h file.
2017-06-16 10:11:12 +01:00
Russ Butler fc18250b1f Increase background stack size to fix overflow
Bump the background stack size to 512 bytes to fix stack overflows on
the NRF52 and so it is the same size as it was before the switch to
RTX5.
2017-06-14 17:31:52 -05:00
Martin Kojtal d3cf5fb999 Merge pull request #4445 from theotherjimmy/fix-exporters
Fixes for exporter issues
2017-06-09 15:04:01 +01:00
Jimmy Brisson fc6c2b85ff Upcase assembly file suffix for preprocesssing 2017-06-09 00:03:23 -05:00
Kevin Gilbert 567589f138 Resolve Doxygen errors from RTOS. Fixed minor Doxygen bug in FileSystemHandle.h as well 2017-06-08 15:51:04 -05:00
Jaeden Amero 778d6822bf RTX5: uVisor: Switch threads very carefully
uVisor doesn't set the PSP of the target thread. The RTOS sets the PSP
of the target thread from the target thread's TCB. However, when
interrupts of higher priority than PendSV happen between the call to
uVisor to switch boxes, and the RTOS setting PSP, the uVisor vIRQ
interrupt handler will attempt to use an invalid PSP (the PSP from
before the box and thread switch). This leads to a crash. Make box and
thread switching atomic by disabling interrupts immediately before the
box switching until immediately after the new PSP is set.
2017-06-04 14:41:59 +01:00
Russ Butler cabc1e0911 Fix Thread class synchronization
Prevent osTheadTerminate from being called on an already terminated
thread. Also make sure the thread termination process is properly
synchronized.
2017-06-02 23:50:38 -05:00
Russ Butler 96bd943ea2 RTX5: Enable priority inheritance and robust mode
Add the attribute flash to enable priority inheritance and robust mode.
The robust flag allows mutexes held by terminated threads to be
properly released.
2017-06-02 23:50:36 -05:00
Russ Butler e48e599a9d Fix RTOS function prototypes by adding extern "C"
Wrap the file mbed_rtos_storage.h in extern "C". This allows the
functions inside rtx_lib.h to have correct definitions when included
in a C++ file.

This is required for the RTX5 error trapping.
2017-06-02 23:50:32 -05:00
Bartosz Szatkowski 39a1b39ce1 Bump number of ARMC mutexes to fix PAL test failure 2017-05-30 18:55:56 +01:00
Yuguo Zou f03509c6cb Add up OS_MUTEX_NUM for ARMCC compiler
CI shield test (SPI test) may need 7 mutexes
2017-05-30 18:55:56 +01:00
Bartek Szatkowski 80cb65e094 Add more verbose RTOS error messages 2017-05-30 18:55:56 +01:00
Bartek Szatkowski a8229b5351 Make sure all RTOS attribute structures are 0-ed before use 2017-05-30 18:55:56 +01:00
Bartek Szatkowski 0064df1ce6 Add name parameter for C++ mutex wrapper 2017-05-30 18:55:55 +01:00
Bartek Szatkowski e66f9ee818 Fix IAR coding style and thread/mutex namingin mbed_boot.c 2017-05-30 18:55:55 +01:00
Bartek Szatkowski b01f13d1a0 Make sure all system threads and mutexes have clear names 2017-05-30 18:55:55 +01:00
Bartek Szatkowski 05548e786d Rename directories rtx->rtx4 rtx2->rtx5 2017-05-30 18:55:55 +01:00
Bartek Szatkowski 535ee8ba25 Make stack sizes configurable by the app
Application can overwrite stack sizes by defining main-stack-size and
thread-stack-size in mbed_app.json
2017-05-30 18:55:55 +01:00
Bartek Szatkowski b793a3fb89 Update codebase for CMSIS5/RTX5
Update all of mbed-os to use RTX5.
2017-05-30 18:55:52 +01:00
Bartek Szatkowski 7b022f8785 Modify CMSIS 5 so it is suitable for mbed-os
Make changes to the files taken from RTX5/CMSIS5 so they work
with mbed-os and uvisor.
2017-05-30 18:53:38 +01:00
Jaeden Amero 7ae2e6e9ec RTX5: uVisor: Use OsEventObserver 2017-05-30 18:53:38 +01:00
Jaeden Amero 24c60f6cc7 RTX5: uVisor: Extend thread control block with context
OsEventObserver objects expect a context to be maintained per thread on
their behalf. Add this context to the thread control block and extend
the thread creation functions with the ability to supply a context.
2017-05-30 18:53:38 +01:00
Jaeden Amero 756e0cae99 RTX5: uVisor: Add OsEventObserver
Add the OsEventObserver mechanism. A client interested in receiving
notifications on certain OS events can register to receive notifications
with osRegisterForOsEvents. This is useful for clients like the secure
memory allocator, which observes thread switching events in order to
swap in and out different memory allocator objects.
2017-05-30 18:53:38 +01:00