Commit Graph

437 Commits (8d9e2e5d0a7559764e29e46d85089051788725a1)

Author SHA1 Message Date
Christopher Haster 70ebb6f16b [rtos] Fixed registers clobbered SVC_Handler in IAR
The rtx SVC_Handler for IAR clobbers r0-r3 despite the number of
arguments. However, in the SVC calls, the __swi function is declared
with fewer arguments. IAR doesn't understand that the other registers are
clobbered and stores variables in r0-r3 when multiple SVCs are
dispatched in a single function.

This bug was noticed in osThreadExit, which hard-faults on IAR,
preventing any threads from exiting.
2016-06-11 19:34:20 -05:00
Sam Grove 0b3556db2f Merge pull request #1898 from pan-/fix_nrf51_stack
Adjust the main stack of nrf51 targets to the call stack of thesoftdevice.
2016-06-10 18:00:45 +01:00
Jaeden Amero 829ca3333b RTX: Actively switch to the idle thread
Prevent a switch to a NULL target thread by setting the new task to run
to be the idle task. Otherwise, we get nasty usage fault because we
would be returning from the rt_sys_init SVC with a PSP of 0x20.
2016-06-10 16:56:17 +01:00
Jaeden Amero 58336594ac RTX: Run unprivileged if uVisor is present
As priviliged threading is incompatible with uVisor
2016-06-10 16:56:17 +01:00
Jaeden Amero 43e595aec3 Wrap software_init_hook
Wrap software_init_hook so that it can be used or extended from outside the
RTOS. This is desirable so that code can be added to the software_init_hook
without making the RTOS depend on new features or libraries.
2016-06-10 16:56:17 +01:00
Niklas Hauser 61166870ed RTX: Add context to osThreadCreate/Terminate 2016-06-10 16:56:16 +01:00
Niklas Hauser 259bd28c45 RTX: Add pointer to context to task structure 2016-06-10 16:56:16 +01:00
Jaeden Amero 4cdc4a7b45 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.
2016-06-10 16:56:16 +01:00
Vincent Coubard 06e2139e6a Adjust the main stack of nrf51 targets to the call stack of the
softdevice.

The call stack of the soft device can be 0x600 (1536) bytes long, by
adjusting the stack to a value of 2048 bytes, their is enough room for
the softdevice and RTX kernel to live together in the main stack.

Random issues due to stack overflow were visible with the previous value.
2016-06-10 14:57:51 +01:00
0xc0170 f3f4430b8f RTOS - add config mbed_lib.json file
Defines that rtos is present, this resolves in the macro:
"MBED_CONF_RTOS_PRESENT=1"
2016-06-08 18:41:29 +01:00
Vincent Coubard e46b659799 Merge branch 'master' of https://github.com/mbedmicro/mbed into nrf51_port 2016-06-05 20:46:42 +01:00
Vincent Coubard 000e04d768 RTOS port for nrf51.
The NRF51 doesn't have a systick. When the MCU doesn't have a systick, the
HAL has to export several functions which will be use by the kernel to
manage the tick:

  * os_tick_init provides the initialization function for the alternative
    hardware timer.
  * os_tick_val returns the current value of the alternative hardware timer.
  * os_tick_ovf returns the overflow flag of the alternative hardware timer.
  * os_tick_irqack is an interrupt acknowledge function that is called to
    confirm the alternative hardware timer interrupt.

The HAL should also call OS_Tick_Handler needs to be called as the
hardware timer interrupt function.

In the case of the NRF51, two RTCs are available:
  * RTC0: reserved for soft device
  * RTC1: used by us_ticker.

RTC1 is a 4 channels timers, channel 0 is used for us_ticker, and
in this port channel 1 is used for tick generation.

Implementation notes:
  * RTC1_IRQHandler: has to be written in assembly otherwise a stack
    overflow will occur because the function OS_Tick_Handler never
    returns. This function is called when RTC1 channel IRQ is triggered.
  * tick generation has been optimised for a tick with a duration of
    1000us.
  * us_ticker can still be compiled and used without RTX enabled.

More information about alternative timer as RTX Kernel Timer:
https://www.keil.com/pack/doc/CMSIS/RTX/html/_timer_tick.html
2016-06-03 10:13:10 +01:00
Martin Kojtal f68cdcb695 Merge pull request #1802 from theotherjimmy/callback-rtos
Adopt Callback class in rtos Threads
2016-06-02 17:08:59 +01:00
Martin Kojtal 7643399c1d Merge pull request #1835 from stevew817/feature/rtos_support_efm32
[Silicon Labs] Disable RTOS support for EFM32ZG
2016-06-02 11:51:00 +01:00
Steven Cooreman 0015943bd9 Remove RTOS support for EFM32 Zero Gecko because of too little RAM 2016-06-02 10:06:26 +02:00
Martin Kojtal 5df96fbec3 Merge pull request #1815 from stevew817/feature/rtos_support_efm32
[Silicon Labs] Provide RTOS support for EFM32 targets
2016-06-02 08:08:20 +01:00
Christopher Haster e079c2e0e9 Added support for Callback to Thread lifetime 2016-06-01 12:11:05 -05:00
Martin Kojtal 02b0267143 Merge pull request #1765 from c1728p9/thread_safe
Thread safe
2016-06-01 18:01:18 +01:00
Martin Kojtal 2db84dadcb Merge pull request #1785 from geky/thread-lifetime
Add lifetime management to threads
2016-06-01 11:42:28 +01:00
Christopher Haster 0180125293 Adopt Callback class in rtos Threads 2016-05-31 20:39:39 -05:00
Russ Butler 5b23d9b268 Remove assembler directives
Remove the assembler directives from the inline assembly in
RTX_CM_lib.h since these can have unintended side effects in
the surrounding C code.
2016-05-31 16:17:50 -05:00
Russ Butler 793f9c566a Add partial thread safety to GCC
Add lock functions so that malloc and environment variable access are
thread safe.  Add the compiler option "-o thread-safe" to use the full
version of newlib which is thread safe.

Note that this patch does NOT make file access thread safe.
2016-05-31 16:16:59 -05:00
Russ Butler bd216c37cb Make the IAR standard library thread safe
Add the locks and flags necessary to make the IAR standard library
thread safe.  These changes consist of:
-Add compiler flag "--guard_calls" to ensure C++ function-static
    variables with dynamic initializers are initialized in a
    thread safe manner
-Add the linker flag "--threaded_lib" so the thread safe version of
    the standard library is used
-Implement mutex functions required for IAR thread safety
-Create a set of stub functions in retarget.c for when the rtos is not present
2016-05-31 14:41:21 -05:00
Steven Cooreman cc34a7bada Provide initial RTOS support for EFM32 targets 2016-05-30 14:14:36 +02:00
Neil Thiessen 0fd3721d2e [RTOS] Fixed online compiler macro warnings
Added an #ifndef directive to the __MBED_CMSIS_RTOS_CM and __CMSIS_RTOS macro definitions in order to prevent "Incompatible redefinition of macro" warnings from the online compiler.
2016-05-27 10:10:52 -06:00
geky 57bc433986 Fixed NULL usage on non-pointer member in thread
per @theotherjimmy
2016-05-26 16:24:32 -05:00
Christopher Haster 1ab7d73805 Added Thread::start and Thread::join for managing lifetime of threads
- Allows threads to started separately from when they are declared,
  avoiding the need to dynamically allocate threads at runtime.
- Allows multiple threads to join without forceful termination. Allowing
  threads to synchronize on cleanup.
2016-05-25 17:23:18 -05:00
0xc0170 327bd41632 Merge branch 'master' of https://github.com/neilt6/mbed into neilt6-master 2016-05-23 10:41:32 +01:00
0xc0170 daf5c9ee86 RTX - ARM7 init sequence update 2016-05-23 09:50:24 +01:00
0xc0170 607c9d119b RTX - ARMCC pre_main - pop fix 2016-05-23 09:50:16 +01:00
0xc0170 8420e13246 RTX - pre_main for GCC C function 2016-05-23 09:50:11 +01:00
Martin Kojtal 230be00443 ARMCC ulib - initalize RTOS before the standard library C++ init
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:50:05 +01:00
Russ Butler 87176751a8 IAR - Initialize RTOS before standard library
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:50:00 +01:00
Russ Butler a5ace8dea0 GCC - Initialize RTOS before standard library
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:49:55 +01:00
Russ Butler ac727e270e ARMCC - Initialize RTOS before standard library
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:49:48 +01:00
Russ Butler a0fd520408 Remove dead CodeSourcery init code
The CodeSourcery compiler is not longer supported.  This patch removes
the CodeSourcery init code in RTX_CM_lib.h.
2016-05-23 09:49:44 +01:00
Mihail Stoyanov d9734e5a32 Simplify layout:
* /libraries/mbed -> /hal
* /libraries/rtos -> /rtos
2016-05-23 09:13:59 +01:00