1*** Variables ***
2${UART}                             sysbus.uart
3${BIN}                              @https://dl.antmicro.com/projects/renode/clic/clic_priorities-01.elf-s_14324-be2a3b6105f51eaf9bc08752bea764bcc9aa0f37
4${INT_ENABLE_ADDR}                  0x80002000
5${PLATFORM}                         SEPARATOR=
6...                                 """  ${\n}
7...                                 using "tests/peripherals/CLIC/CLIC-test-platform.repl"  ${\n}
8...                                 clic:  ${\n}
9...                                 ${SPACE*4}machineLevelBits: 0  ${\n}
10...                                 """
11
12*** Keywords ***
13Create Machine
14    Execute Command                 using sysbus
15    Execute Command                 mach create
16    Execute Command                 machine LoadPlatformDescriptionFromString ${PLATFORM}
17    Execute Command                 sysbus LoadELF ${BIN}
18
19*** Test Cases ***
20Should Pass CLIC-priorities-01
21    Create Machine
22    Create Terminal Tester          ${UART}
23    Execute Command                 showAnalyzer uart Antmicro.Renode.Analyzers.LoggingUartAnalyzer
24
25    Wait For Line On Uart           Init complete
26
27    # Trigger the three interrupts.
28    Execute Command                 clic OnGPIO 16 True
29    Execute Command                 clic OnGPIO 17 True
30    Execute Command                 clic OnGPIO 18 True
31
32    # Interrupts are disabled until a non-zero value is written to INT_ENABLE_ADDR.
33    # This forces CLIC to prioritize the interrupts.
34    Execute Command                 sysbus WriteByte ${INT_ENABLE_ADDR} 1
35
36    # Interrupt with the highest priority should be handled first.
37    Wait For Line On Uart           Interrupt 18, priority 3
38    Wait For Line On Uart           Interrupt 16, priority 2
39    Wait For Line On Uart           Interrupt 17, priority 1
40