1*** Variables ***
2${UART}                         sysbus.mmuart0
3${SCRIPT}                       ${CURDIR}/../../scripts/single-node/polarfire-soc.resc
4
5*** Keywords ***
6Prepare Machine
7    Execute Command           mach create
8    Execute Command           machine LoadPlatformDescription @platforms/cpus/polarfire-soc.repl
9    Execute Command           sysbus LoadELF ${binary}
10
11Run Should Ignore Writing Other Values Test
12    [Arguments]                 ${path}
13    Execute Command             $bin = ${path}
14    Execute Script              ${SCRIPT}
15    Execute Command             machine SetSerialExecution True
16    Create Terminal Tester      ${UART}
17    Start Emulation
18
19    Wait For Line On Uart       The system will reset after WD0 Times out.
20    Wait For Line On Uart       H0 MVRP PLIC
21    Wait For Line On Uart       H0 timeout PLIC
22
23    Wait For Line On Uart       The system will reset after WD0 Times out.
24
25
26*** Test Cases ***
27Should Fire NMI When Writing Any Value Into Forbidden Region When Forbidden Region Is Enabled
28    Execute Command             $bin = @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-a.elf-s_3353960-dd65a2a6d435d49509523cf68058af7027c69f02
29    Execute Script              ${SCRIPT}
30    Execute Command             machine SetSerialExecution True
31    Create Terminal Tester      ${UART}
32    Create Log Tester           0
33    Execute Command             logLevel -1
34    Start Emulation
35
36    Wait For Line On Uart       The system will reset after WD0 Times out.
37    Wait For Line On Uart       H0 timeout PLIC
38
39    Wait For Line On Uart       The system will reset after WD0 Times out.
40    Should Not Be In Log        Switching state to RefreshRegion.
41    Should Not Be In Log        Refreshing watchdog.
42
43
44Should Refresh Watchdog By Writing Refresh Key Into Refresh Region When Forbidden Region Is Enabled
45    Execute Command             $bin = @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-b.elf-s_3353976-d0a8861250d15dbba1e25fb51797e72f82460453
46    Execute Script              ${SCRIPT}
47    Execute Command             machine SetSerialExecution True
48    Create Terminal Tester      ${UART}
49    Create Log Tester           0
50    Execute Command             logLevel -1
51    Start Emulation
52
53    Wait For Line On Uart       The system will reset after WD0 Times out.
54    Wait For Line On Uart       H0 MVRP PLIC
55    Wait For Line On Uart       H0 MVRP Local
56
57    Should Not Be In Log        Watchdog reset triggered!
58
59
60Should Ignore Writing Other Values Into Refresh Region When Forbidden Region Is Enabled
61    Execute Command             $bin = @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-c.elf-s_3353976-2227f483cde453795dad468e3913e1a9a8dde7dc
62    Execute Script              ${SCRIPT}
63    Execute Command             machine SetSerialExecution True
64    Create Terminal Tester      ${UART}
65    Create Log Tester           0
66    Execute Command             logLevel -1
67    Start Emulation
68
69    Wait For Line On Uart       The system will reset after WD0 Times out.
70    Wait For Line On Uart       H0 MVRP PLIC
71    Wait For Line On Uart       H0 timeout PLIC
72
73    Should Not Be In Log        Refreshing watchdog.
74
75
76Should Refresh Watchdog By Writing Refresh Key Into Forbidden Region When Forbidden Region Is Disabled
77    Execute Command             $bin = @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-d-forbidden.elf-s_3353960-d197eb0f96c99c4ae244c315875d6d353d2c43ad
78    Execute Script              ${SCRIPT}
79    Execute Command             machine SetSerialExecution True
80    Create Terminal Tester      ${UART}
81    Create Log Tester           0
82    Execute Command             logLevel -1
83    Start Emulation
84
85    Wait For Line On Uart       The system will reset after WD0 Times out.
86
87    Wait For Log Entry          Switching state to ForbiddenRegion.   timeout=3
88    Should Not Be In Log        Switching state to RefreshRegion.
89
90
91Should Refresh Watchdog By Writing Refresh Key Into Refresh Region When Forbidden Region Is Disabled
92    Execute Command             $bin = @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-d-refresh.elf-s_3353976-f3fd8998a7f9ae641fd786dd36b83b9074189010
93    Execute Script              ${SCRIPT}
94    Execute Command             machine SetSerialExecution True
95    Create Terminal Tester      ${UART}
96    Create Log Tester           0
97    Execute Command             logLevel -1
98    Start Emulation
99
100    Wait For Line On Uart       The system will reset after WD0 Times out.
101    Wait For Line On Uart       H0 MVRP PLIC
102    Wait For Line On Uart       H0 MVRP Local
103
104    Wait For Log Entry          Refreshing watchdog.   timeout=3
105    Should Not Be In Log        Watchdog reset triggered!
106
107
108Should Ignore Writing Other Values Into Forbidden Region When Forbidden Region Is Disabled
109    Run Should Ignore Writing Other Values Test                    @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-e-forbidden.elf-s_3353960-2f4c36d3170f74f57c7b7f18823ad1c6d2f1f0a4
110
111
112Should Ignore Writing Other Values Into Refresh Region When Forbidden Region Is Disabled
113    Run Should Ignore Writing Other Values Test                    @https://dl.antmicro.com/projects/renode/mpfs-watchdog-interrupt_case-e-refresh.elf-s_3353960-c66342498de3d6efc69d0b338fba83322385d77c
114