adjust SMP port to also use ULONG = 8 bytes

This commit is contained in:
2026-04-02 10:48:43 +02:00
parent eda2a85dc1
commit c16e6b0446
10 changed files with 52 additions and 44 deletions

View File

@@ -18,23 +18,23 @@ _tx_thread_smp_protect:
la t1, _tx_thread_smp_protection
/* If this hart already owns protection, just nest the count. */
LWU t3, 4(t1) // Pickup owning hart
LOAD t3, 1*REGBYTES(t1) // Pickup owning hart
beq t3, t2, _owned // Already owned by this hart
/* Try to get the protection. */
LWU t4, 0(t1) // Pickup protection flag
LOAD t4, 0(t1) // Pickup protection flag
bnez t4, _protection_busy // If set, protection is busy
li t4, 1 // Build lock value
amoswap.w.aq t5, t4, (t1) // Attempt to get protection
AMOSWAP_AQ t5, t4, (t1) // Attempt to get protection
bnez t5, _protection_busy // If old value != 0, retry
fence rw, rw // Ensure lock acquisition is visible
sw t2, 4(t1) // Save owning hart
STORE t2, 1*REGBYTES(t1) // Save owning hart
_owned:
LWU t5, 8(t1) // Pickup ownership count
LOAD t5, 2*REGBYTES(t1) // Pickup ownership count
addi t5, t5, 1 // Increment ownership count
sw t5, 8(t1) // Store ownership count
STORE t5, 2*REGBYTES(t1) // Store ownership count
fence rw, rw // Publish owner/count before return
ret