Changeset 109bc1c7 in rtems


Ignore:
Timestamp:
Jun 29, 2018, 6:07:02 AM (11 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
79d69ae
Parents:
5235238
git-author:
Sebastian Huber <sebastian.huber@…> (06/29/18 06:07:02)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/29/18 08:04:38)
Message:

riscv: Add SMP context switch support

Update #3433.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/cpu/riscv/riscv-context-switch.S

    r5235238 r109bc1c7  
    8181        sw      a3, RISCV_CONTEXT_ISR_DISPATCH_DISABLE(a0)
    8282
     83#ifdef RTEMS_SMP
     84        /*
     85         * The executing thread no longer executes on this processor.  Switch
     86         * the stack to the temporary interrupt stack of this processor.  Mark
     87         * the context of the executing thread as not executing.
     88         */
     89        addi    sp, a2, PER_CPU_INTERRUPT_FRAME_AREA + CPU_INTERRUPT_FRAME_SIZE
     90        amoswap.w.rl    zero, zero, RISCV_CONTEXT_IS_EXECUTING(a0)
     91
     92.Ltry_update_is_executing:
     93
     94        /* Try to update the is executing indicator of the heir context */
     95        li      a3, 1
     96        amoswap.w.aq    a3, a3, RISCV_CONTEXT_IS_EXECUTING(a1)
     97        bnez    a3, .Lcheck_is_executing
     98#endif
     99
    83100.Lrestore:
     101
    84102        lw      a3, RISCV_CONTEXT_ISR_DISPATCH_DISABLE(a1)
    85103
     
    125143        GET_SELF_CPU_CONTROL    a2
    126144        j       .Lrestore
     145
     146#ifdef RTEMS_SMP
     147.Lcheck_is_executing:
     148
     149        /* Check the is executing indicator of the heir context */
     150        lw      a3, RISCV_CONTEXT_IS_EXECUTING(a1)
     151        beqz    a3, .Ltry_update_is_executing
     152
     153        /* We may have a new heir */
     154
     155        /* Read the executing and heir */
     156        lw      a4, PER_CPU_OFFSET_EXECUTING(a2)
     157        lw      a5, PER_CPU_OFFSET_HEIR(a2)
     158
     159        /*
     160         * Update the executing only if necessary to avoid cache line
     161         * monopolization.
     162         */
     163        beq     a4, a5, .Ltry_update_is_executing
     164
     165        /* Calculate the heir context pointer */
     166        sub     a4, a1, a4
     167        add     a1, a5, a4
     168
     169        /* Update the executing */
     170        sw      a5, PER_CPU_OFFSET_EXECUTING(a2)
     171
     172        j       .Ltry_update_is_executing
     173#endif
Note: See TracChangeset for help on using the changeset viewer.