How-To: LM32 Soft-CPU - Handle the ECA message-signaled interrupts (MSIs)

Introduction

The ECA unit is capable to send MSI on certain conditions, such as:
  • producing valid actions in its action channel on reception of timing messages.

ECA evaluates incoming timing messages against pre-configured action rules in its condition table. If event identifier match between the timing message and existing action rules is detected, then ECA produces actions at the designated time, outputs them to dedicated action channel and sends MSI to hooked interrupt handler.

Set up ECA for generating MSIs

In order to enable MSI generation both the condition table and MSI registers in action channel must be properly configured:
  • conditions to produce actions in dedicated action channel
  • destination path of MSI handler

Handling MSIs

Once ECA sends MSI to a handler specified in the destination path it disables the generation of MSIs temporarily until pending action in the action channel is handled.

Every time an action is output, it is held in a queue connected to an action channel for further handling. When the action is picked up and desired task is done by a handler, then it must be popped from the queue, otherwise the queue will overflow. With the popping the valid flag of that action is reset. However that's still not sufficient to enable interrupt generation. ECA action channels have a set of condition counters for its actions: valid, overflow and failed. Eventually these counters must be read and cleared to enable the generation of MSIs.

Therefore, the handling of ECA MSIs requires two steps:
  • read and clear action channel counters
  • pop pending actions from a queue connected to that action channel

Example code

An example for handling MSIs caused by ECA is given in:
  • <path/to>/bel_projects/modules/lm32-example/ecaMsiExample.c

Important: This example assumes that ECA is configured with action rules for LM32 and fed timing messages by using saftlib-tools.

The example sets up an interrupt handler and configures ECA for generating MSIs. On pending MSI, the interrupt handler reads and clears the valid action counter of the action channel for LM32, pops the pending action and prints event id, deadline, parameter and action flag.

eca msi handling.png

Figure 1. The topology of WB devices and their interaction in generating/handling of MSIs

All required steps to run the example is given in below section.

Instructions to run the example

The following components are required to run the example:

  • target board: SCU3
  • eb-tools on target board: eb-fwload, eb-reset, eb-console, eb-read

1. Set action rules to ECA for its LM32 channel on target SCU and verify it. The event id is "0x1122334455667788" and event tag is "0x42".

saft-ecpu-ctl tr0 -d -c 0x1122334455667788 0xFFFFFFFFFFFFFFFF 0 0x42
Action sink configured and disowned...

saft-ecpu-ctl tr0 -l
/de/gsi/saftlib/tr0/embedded_cpu/_424238335:
  Event ID: 0x1122334455667788
  Mask:     0xffffffffffffffff
  Tag:      0x42
  Offset:   0
  Owner:

2. Locate the example on local host (ecaMsiExample.c)
cd <path/to>/bel_projects/modules/lm32-example

3. Build example firmware and copy output binary from local host to target SCU
make clean && make TARGET=ecaMsiExample && scp ecaMsiExample.bin root@scuxl0304.acc:.

4. Start console to show the debug output of LM32 firmware
eb-console dev/wbm0

5. Load firmware on target SCU (second terminal is required)
eb-reset dev/wbm0 cpuhalt 0 && eb-fwload dev/wbm0 u 0x0 ecaMsiExample.bin && eb-reset dev/wbm0 cpureset 0

6. Check ECA settings

Important: Assume that the eb-ls tool has found ECA channel control at address 0x20000300 and queue for LM32 channel at 0x20000100.
eb-read dev/wbm0 0x20000380/4 (channel selection, must be 0x3 for LM32 channel)
eb-read dev/wbm0 0x200003a8/4 (destination path of interrupt handler, must be 0x00000000 for LM32)
eb-read dev/wbm0 0x200003a0/4 (MSI enable, must be 0x1)

Optionally one can read the valid counter and/or check if any pending action is in a queue connected to LM32 channel.
eb-read dev/wbm0 0x200003b4/4 (valid counter, returns 0x0 if no action has been output since last read)
eb-read dev/wbm0 0x20000108/4 (action flag, returns 0x0 if last action was already popped)

7. Inject a timing message with id "0x1122334455667788", arbitrary parameter and null offset. Check the console output.

saft-ctl -p tr0 inject 0x1122334455667788 0x8877887766556642 0

In case of MSI is sent and handled by LM32, then the console should print something similar to:
idle: elapsed 10000 ms
idle: elapsed 10000 ms
 MSI: 00040000
Adr:  00000000
Sel:  f
Cnt:  0
valCnt=1
EvtID: 0x1122334455667788; deadline: 0x1589f3f1761b1200; param: 0x8877887766556642; flag: 0x00000010
idle: elapsed 10000 ms
idle: elapsed 10000 ms

-- EnkhboldOchirsuren - 11 Mar 2019
I Attachment ActionSorted ascending Size Date Who Comment
eca_msi_handling.pngpng eca_msi_handling.png manage 144 K 13 Mar 2019 - 13:06 EnkhboldOchirsuren Topology of WB devices and their interaction in generating/handling of MSIs
Topic revision: r4 - 15 Apr 2019, DietrichBeck
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback