unified/arm: add unified kernel support for ARM arch
The ARM architecture port is fitted with support for the unified kernel, namely: - the interrupt/exception exit code now pends PendSV if the current thread is not a coop thread and if the scheduler is not locked - fiber_abort is replaced by k_thread_abort(), which takes a thread ID as a parameter (i.e. does not only operate on the current thread) - the _nanokernel.flags cache of _current.flags is not used anymore (could be a source of bugs) and is not needed in the scheduling algo - there is no 'task' field in the _nanokernel anymore: PendSV not calls _get_next_ready_thread instead - the _nanokernel.fiber field is replaced by a more sophisticated ready_q, based on the microkernel's priority-bitmap-based one - thread initialization initializes new fields in the tcs, and does not initialize obsolete ones - nano_private includes nano_internal.h from the unified directory - The FIBER, TASK and PREEMPTIBLE flags do not exist anymore: the thread priority drives the behaviour - the tcs uses a dlist for queuing in both ready and wait queues instead of a custom singly-linked list - other new fields in the tcs include a schedule-lock count, a back-pointer to init data (when the task is static) and a pointer to swap data, needed when a thread pending on _Swap() must be passed more then just one value (e.g. k_stack_pop() needs an error code and data) - the 'fiber' and 'task' fields of _nanokernel are replaced with an O(1) ready queue (taken from the microkernel) - fiberRtnValueSet() is aliased to _set_thread_return_value since it also operates on preempt threads now - _set_thread_return_value_with_data() sets the swap_data field in addition to a return value from _Swap() - convenience aliases are created for shorter names: - _current is defined as _nanokernel.current - _ready_q is defined as _nanokernel.ready_q - _Swap() sets the threads's return code to -EAGAIN before swapping out to prevent timeouts to have to set it (solves hard issues in some kernel objects). Change-Id: I36c03c362bc2908dae064ec67e6b8469fc573983 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
d4006c9ad4
commit
3cf3778d31
9 changed files with 239 additions and 11 deletions
|
@ -34,6 +34,10 @@ _ASM_FILE_PROLOGUE
|
|||
GTEXT(_Swap)
|
||||
GTEXT(__svc)
|
||||
GTEXT(__pendsv)
|
||||
#ifdef CONFIG_KERNEL_V2
|
||||
GTEXT(_get_next_ready_thread)
|
||||
GDATA(_k_neg_eagain)
|
||||
#endif
|
||||
|
||||
GDATA(_nanokernel)
|
||||
|
||||
|
@ -97,6 +101,12 @@ SECTION_FUNC(TEXT, __pendsv)
|
|||
|
||||
/* find out incoming thread (fiber or task) */
|
||||
|
||||
#ifdef CONFIG_KERNEL_V2
|
||||
push {lr}
|
||||
blx _get_next_ready_thread
|
||||
pop {lr}
|
||||
movs.n r2, r0
|
||||
#else
|
||||
/* is there a fiber ready ? */
|
||||
ldr r2, [r1, #__tNANO_fiber_OFFSET]
|
||||
cmp r2, #0
|
||||
|
@ -109,10 +119,13 @@ SECTION_FUNC(TEXT, __pendsv)
|
|||
ldrne.w r0, [r2, #__tTCS_link_OFFSET] /* then */
|
||||
strne.w r0, [r1, #__tNANO_fiber_OFFSET] /* then */
|
||||
ldreq.w r2, [r1, #__tNANO_task_OFFSET] /* else */
|
||||
#endif
|
||||
|
||||
/* r2 contains the new thread */
|
||||
#if !defined(CONFIG_KERNEL_V2)
|
||||
ldr r0, [r2, #__tTCS_flags_OFFSET]
|
||||
str r0, [r1, #__tNANO_flags_OFFSET]
|
||||
#endif
|
||||
str r2, [r1, #__tNANO_current_OFFSET]
|
||||
|
||||
/*
|
||||
|
@ -189,6 +202,18 @@ SECTION_FUNC(TEXT, __svc)
|
|||
_context_switch:
|
||||
#endif
|
||||
|
||||
#if CONFIG_KERNEL_V2
|
||||
/*
|
||||
* Set _Swap()'s default return code to -EAGAIN. This eliminates the
|
||||
* need for the timeout code to invoke fiberRtnValueSet().
|
||||
*/
|
||||
|
||||
mrs r2, PSP /* thread mode, stack frame is on PSP */
|
||||
ldr r3, =_k_neg_eagain
|
||||
ldr r3, [r3, #0]
|
||||
str r3, [r2, #__tESF_a1_OFFSET]
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Unlock interrupts:
|
||||
* - in a SVC call, so protected against context switches
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue