
RM0453 Rev 2
367/1454
RM0453
Hardware semaphore (HSEM)
377
1-step (read) lock procedure
The 1-step procedure consists in a read to lock and check the semaphore in a single step,
carried out from the HSEM_RLRx register.
•
Read lock semaphore with the AHB bus master COREID.
•
If read COREID matches and PROCID = 0, then lock is put in place. If COREID
matches and PROCID is not 0, this means that another process from the same
COREID has locked the semaphore with a 2-step (write) procedure.
•
Else retry (the semaphore has been locked by another process, AHB bus master ID).
A semaphore can only be locked when it is free. When read locking a free semaphore,
PROCID is 0. Read locking a locked semaphore returns the COREID and PROCID that
locked it. All read locks, including the first one that locks the semaphore, return the COREID
that locks or locked the semaphore.
Note:
The 1-step procedure must not be used when running multiple processes of the same AHB
bus master ID. All processes using the same semaphore read the same status. When only
one process locks the semaphore, each process of that AHB bus master ID reads the
semaphore as locked by itself with the COREID.
8.3.4 HSEM
write/read/read lock register address
For each semaphore, two AHB register addresses are provided, separated in two banks of
32-bit semaphore registers, spaced by a 0x80 address offset.
In the first register address bank the semaphore can be written (locked/unlocked) and read
through the HSEM_Rx registers.
In the second register address bank the semaphore can be read (locked) through the
HSEM_RLRx registers.
8.3.5
HSEM unlock procedures
Unlocking a semaphore is a protected process, to prevent accidental clearing by a AHB bus
master ID or by a process not having the semaphore lock right. The procedure consists in
writing to the semaphore HSEM_Rx register with the corresponding COREID and PROCID
and LOCK = 0. When unlocked the semaphore, the COREID, and the PROCID are all 0.
When unlocked, an interrupt may be generated to signal the event. To this end, the
semaphore interrupt shall be enabled.
The unlock procedure consists in a write to the semaphore HSEM_Rx register with
matching COREID regardless on how the semaphore has been locked (1-step or 2-step).
•
Write semaphore with PROCID, COREID, and LOCK = 0
•
If the written data matches the semaphore PROCID and COREID and the AHB bus
master ID , the semaphore is unlocked and an interrupt may be generated when
enabled, else write is ignored, semaphore remains locked and no interrupt is generated
(the semaphore is locked by another process, AHB bus master ID or the written data
does not match the AHB bus master signaling).
Note:
Different processes of the same AHB bus master ID can write any PROCID value.
Preventing other processes of the same AHB bus master ID from unlocking a semaphore
must be ensured by software, handling the PROCID correctly.