nios2: implement fiberRtnValueSet()

The return value of _Swap() is often treated as a "don't care" value and thus
often ignored. However, there are cases when it is desirable to have a
meaningful return value. This meaningful value can be assigned via
fiberRtnValueSet(). To that end, a new field has been added to the coop
register struct to store this value for when _Swap() needs to return that
meaningful value.

Change-Id: Ic4967fa7d602850c09ebde18e8bfd4c97cda9ec8
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-06-23 20:10:01 -07:00 committed by Inaky Perez-Gonzalez
commit 8a8a2928e5
3 changed files with 15 additions and 6 deletions

View file

@ -93,15 +93,24 @@ BRANCH_LABEL(next_chosen)
ldw ra, __tTCS_coopReg_OFFSET + __t_coop_ra_OFFSET(r11)
ldw sp, __tTCS_coopReg_OFFSET + __t_coop_sp_OFFSET(r11)
/* Restore interrupt state in status.PIE */
ldw r2, __tTCS_coopReg_OFFSET + __t_coop_key_OFFSET(r11)
andi r3, r2, NIOS2_STATUS_PIE_MSK
/* Load return value into r2 (return value register). garbage
* unless someone previously called fiberRtnValueSet(). Do this
* before we potentially unlock interrupts.
*/
ldw r2, __tTCS_coopReg_OFFSET + __t_coop_retval_OFFSET(r11)
/* irq_unlock(fiber->coopReg.key);
* key was supplied as argument to _Swap()
*/
ldw r3, __tTCS_coopReg_OFFSET + __t_coop_key_OFFSET(r11)
andi r3, r3, NIOS2_STATUS_PIE_MSK
beq r3, zero, no_unlock
rdctl r3, status
ori r3, r3, NIOS2_STATUS_PIE_MSK
wrctl status, r3
BRANCH_LABEL(no_unlock)
ret