Functional Description

Message Transmit

Between every two processors, one processor has 2 sets of channels to communicate with the other processor. Channel index of Tx channels and the corresponding Rx channels are one-to-one mapping.

  • REG_TX_DATA of CPUn is used by CPUn to transmit data to CPUm, once 1 is written to the channel x (x could be 0 ~ M, where M means max channel index), the corresponding bit in REG_RX_DATA of CPUm will be set. The Rx full bit of channel x in REG_ISR of CPUm will be set at the same time.

  • Writing 1 to channel x in REG_ISR of CPUm clears the Rx full interrupt of channel x, the corresponding channel x Tx empty interrupt bit in REG_ISR of CPUn will be set automatically.

IPC message transmitting mapping shows the IPC transmit mapping from CPUn to CPUm, and IPC message receiving mapping shows the IPC mapping from CPUm to CPUn after receiving data.

../../../_images/ipc_message_transmitting_mapping.svg

IPC message transmitting mapping

../../../_images/ipc_message_receive_mapping.svg

IPC message receiving mapping

IPC without Handshake

As there are Rx Full and Tx Empty interrupts for each processor, these functions can be used to realize message transmission and handshake.

IPC message transmission flow without handshake shows the interrupt messaging protocol of IPC without waiting for a handshake from receiver, and steps are summarized in IPC message transmission steps without handshake. It takes the message transmission from CPUn to CPUm for example.

../../../_images/ipc_message_transmission_flow_without_handshake.svg

IPC message transmission flow without handshake

IPC message transmission steps without handshake

Step

Description

1

Check the Tx data status of the channel 0 in CPUn IPC Tx Data Register

2

CPUn writes data to the Common Memory

3

Write 1 to idle channel 0 in IPC Tx Data Register

4

The CPUn IPC Tx Data Register write operation

  • Map to CPUm IPC Rx Data Register

  • Clear the Tx Empty interrupt bit in the CPUn Interrupt Status Register

  • Set the Rx Full interrupt bit in the CPUm Interrupt Status Register

5

If the Rx Full interrupt mask is enabled in CPUm Interrupt Mask Register, a Rx Full interrupt request will be generated to CPUm.

6

After checking Rx Full channel, CPUm performs a data read from the corresponding Common Memory

7

After finishing the interrupt handler, CPUm writes 1 to CPUm Interrupt Status Register to clear the Rx Full interrupt

8

The CPUm Interrupt Status Register write operation

  • Clear the Rx Full interrupt status bit in the CPUm Status Register

  • Set Tx Empty interrupt status bit in the CPUn Status Register

9

Clear the channel 0 bit in CPUm IPC Rx Data Register and CPUn IPC Tx Data Register automatically

IPC with Handshake

IPC message transmission flow with handshake shows the interrupt messaging protocol of IPC with waiting for a handshake from receiver, and steps are summarized in IPC message transmission steps with handshake. It takes the message transmission from CPUn to CPUm for example.

../../../_images/ipc_message_transmission_flow_with_handshake.svg

IPC message transmission flow with handshake

IPC message transmission steps with handshake

Step

Description

1

Check the Tx data status of the channel 0 in CPUn IPC Tx Data Register

2

CPUn writes data to the Common Memory

3

Write 1 to idle channel 0 in IPC Tx Data Register.

4

The CPUn IPC Tx Data Register write operation

  • Map to CPUm IPC Rx Data Register

  • Set the Rx Full interrupt bit in the CPUm Interrupt Status Register

5

If the Rx Full interrupt mask is enabled in CPUm Interrupt Mask Register, a Rx Full interrupt request will be generated to CPUm.

6

After checking Rx Full channel, CPUm performs a data read from the corresponding Common Memory

7

After finishing the interrupt handler, CPUm write 1 to CPUm Interrupt Status Register to clear the Rx Full interrupt

8

The IPC Interrupt Status Register write operation

  • Clear the Rx Full interrupt status bit in the CPUm Status Register

  • Set Tx Empty interrupt status bit in the CPUn Status Register

9

Clear the channel 0 bit in CPUm IPC Rx Data Register and CPUn IPC Tx Data Register automatically

10

If Tx Empty mask is enabled in CPUn Interrupt Mask Register, the setting of the Tx Empty bit in the CPUn Status Register generates a Tx Empty interrupt to CPUn

11

CPUn writes 1 to CPUn Interrupt Status Register to clear the Tx Empty interrupt

Hardware Semaphore

Overview

The hardware semaphore is used for a mutual exclusion mechanism. It can be accessed by the cores in an atomic operation.

Traditionally, the software takes three steps to use the semaphore: read -> write -> read.

  1. The first read operation of the CPU is to poll the current semaphore to check whether it is occupied or not.

  2. If this semaphore is free, the CPU will compete it by writing.

  3. The last read operation is to check whether the CPU has already occupied this semaphore because maybe several CPUs or threads write to compete the same semaphore.

The above flow executed by software is offloaded to hardware. The following figure illustrates the hardware semaphore mechanism.

../../../_images/ipc_hardware_semaphore_mechanism.svg
  • The address mapping is responsible for mapping the N bit semaphore status to N x 4 address space, where N represents the total number of hardware semaphore.

  • The read set logic is responsible for determining the status of the semaphore to be read after receiving the read request. If the corresponding semaphore register is 0, the read set logic will set the semaphore register first, then return 0 to the read request.

  • The write clear logic is responsible for clearing the status of the semaphore to 0 after receiving write request.

  • The semaphore register has N bits, and each bit in the register represents a semaphore. This register can be read directly, or read/written through the address mapped register.

    • If the semaphore register is read through the address mapped register, the status of only one bit can be read at a time, and this bit will be set synchronously when it is 0.

    • If the semaphore register is read directly, the read does not change the status of the semaphore, and all the N bits can be read at a time.

RTL8721Dx:

N equals {{IC_PARAM_IPC_SEMA}}.

Address Mapping

If the bit[0] of the semaphore register can be acquired and released through the base address of address mapping, the bit[1] can be acquired and released through (base address + 4) accordingly. Thus the address of the entire access window ranges from 0 to ( N x 4 - 1), where N is the total number of hardware semaphore.

Acquire Flow

If the software wants to acquire the semaphore 0, it can directly read the base address of the access window register.

  • If the bit is 0 when the hardware receives the read request, the hardware will set this bit and return 0 synchronously. At this time, the acquire flow will be regarded as successful by software.

  • If the bit is 1 when the hardware receives the read request, the hardware will directly return 1. At this time, the acquire flow will be regarded as failed by software.

Release Flow

If the software wants to release the semaphore 0, it can directly write the base address of the access window register. The hardware will clear this bit after receiving the write command.

Inquire Flow

If the software wants to inquire the semaphore status, it can directly read the semaphore registers (without address mapping). This operation only returns the semaphore status, but does not change it.