Ameba-D User Manual
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
52
30
...
3
2
1
0
31
IPC0_IRQ30
IPC0_IRQ3
IPC0_IRQ2
IPC0_IRQ1
IPC0_IRQ0
IPC0_IRR
NVIC1
IRQx
KM4
30
...
3
2
1
0
31
IPC1_IRQ30
IPC1_IRQ3
IPC1_IRQ2
IPC1_IRQ1
IPC1_IRQ0
IPC1_IRR
NVIC0
KM0
IRQx
Fig 7-2 IPC interrupt request
7.2.3
Hardware Semaphore
The hardware semaphore is used for a mutual exclusion mechanism. It can be accessed by both cores in atomic operation. When reading for
any reason, the current value is returned and the bit is cleared. The bit is set again following any write.
As Fig 7-3 shows, each hardware semaphore uses 2 bits of an IPC0_SEM register. One bit is named as ‘CPUID’, which is used to indicate who
owns this semaphore. Another bit is named as ‘Free’, which is used to indicate the status of the semaphore − free or occupied.
‘CPUID’ bit is a read-only bit, it is set automatically by hardware when ‘Free’ bit is set.
‘Free’ bit is a R/W bit, and writing a ‘0’ has not any effect on this register. The following is the specification for this bit:
0: When writing 1, hardware sets CPUID.
1: When writing 1, hardware clears ‘CPUID’ bit and ‘Free’ bit, and just owner CPU can clear these bits.
Se
m
a.
0
Free: R/W, write 0 no effect
0: Free, hardware will set CPUID when write 1
1: Occupied, hardware will clear Free & CPUID when owner CPU write 1
CPUID: RO
1: KM4
0: KM0
F0
O0
Free-0
CPUID-0
Free-1
CPUID-1
...
Free-F
CPUID-F
Se
m
a.
15
Fig 7-3 IPC hardware semaphore mechanism
For example, The KM4 wants to access a shared ring buffer structure, it takes the following steps:
(1)
KM4 reads the IPC0_SEM[0] to check the ‘Free’ bit of this semaphore. If this semaphore is occupied (‘Free’ bit = 1), means the
corresponding resource is in using. The software needs to wait this semaphore to be free. If the semaphore is free (‘Free’ bit = 0), then go
to the next step.
(2)
KM4 writes a ‘1’ to IPC0_SEM[0], hardware helps to set the CPUID if writing is success for this CPU.
(3)
KM4 reads the IPC0_SEM[1] to check if the ‘CPUID’ bit is equal to its CPUID. If matched, means it has acquired this semaphore
successfully (another CPU is forbidden to clear this bit). Otherwise, the semaphore acquisition is failed. It may be caused by another CPU
which also tries to acquire this semaphore at the same time and this semaphore has been gotten by another CPU.
(4)
KM4 accesses the shared ring buffer structure.
(5)
KM4 writes a ‘1’ to IPC0_SEM[0], hardware helps to clear the CPUID and ‘Free’ bit, so that another CPU can get this semaphore if needed.
you can give interrupt (IPC
_IRR) to peer CPU for the semaphore free.
Realtek confidential files
The document authorized to
SZ99iot
2019-05-15 10:08:03