1*** Variables ***
2${URI}                                  @https://dl.antmicro.com/projects/renode
3${BIN}                                  ${URI}/shell-demo-miv.elf-s_803248-ea4ddb074325b2cc1aae56800d099c7cf56e592a
4
5${PLATFORM_MIV_EXECUTABLE_ARRAY_MEM}    SEPARATOR=\n
6...                                     """
7...                                     using "platforms/cpus/miv.repl"
8...                                     // Unregister mapped memory
9...                                     ddr: @none
10...                                     // Register array memory and alias as ddr
11...                                     ddr_array: Memory.ArrayMemory @ sysbus 0x80000000 as "ddr"
12...                                     ${SPACE*4}size: 0x4000000
13...                                     """
14
15${PLATFORM_MIV_MIXED_OVERLAPPING}    SEPARATOR=\n
16...                                     """
17...                                     using "platforms/cpus/miv.repl"
18...                                     ddr_overlay: Memory.ArrayMemory @ sysbus new Bus.BusPointRegistration { address: 0x80000000; cpu: cpu }
19...                                     ${SPACE*4}size: 0x100
20...                                     """
21
22*** Keywords ***
23Create Machine From Repl
24    [Arguments]            ${repl_string}
25    Execute Command                 mach create
26    Execute Command                 machine LoadPlatformDescriptionFromString ${repl_string}
27    Create Terminal Tester          sysbus.uart  timeout=1  defaultPauseEmulation=True
28
29Zephyr Console Should Work
30    Wait For Prompt On Uart         uart:~$
31    Write Line To Uart              help
32
33    Wait For Line On Uart           Please press the <Tab> button to see all available commands.
34    Wait For Line On Uart           ou can also use the <Tab> button to prompt or auto-complete all commands or its subcommands.
35    Wait For Line On Uart           You can try to call commands with <-h> or <--help> parameter for more information.
36
37Ensure Mapped Memory Is Overlayed With Array Memory
38    # Overlayed mapped memory area shouldn't be loaded with code
39    ${res0}=  Execute Command       ddr ReadDoubleWord 0x0
40    ${res1}=  Execute Command       sysbus ReadDoubleWord 0x80000000
41    Should Be Equal                 ${res0}  ${res1}
42    Should Contain                  ${res0}  0x00000000
43    # Array memory overlay should be filled with code
44    ${res2}=  Execute Command       ddr_overlay ReadDoubleWord 0x0
45    ${res3}=  Execute Command       sysbus ReadDoubleWord 0x80000000 cpu
46    Should Be Equal                 ${res2}  ${res3}
47    Should Contain                  ${res2}  0x00000297
48
49*** Test Cases ***
50Should Run Zephyr From Array Memory
51    Create Machine From Repl        ${PLATFORM_MIV_EXECUTABLE_ARRAY_MEM}
52    Execute Command                 sysbus LoadELF ${BIN}
53    Zephyr Console Should Work
54
55Should Execute From Mixed Memory Page
56    Create Machine From Repl        ${PLATFORM_MIV_MIXED_OVERLAPPING}
57    # cpu context passed to LoadELF command is important because of the CPU-specific overlay
58    Execute Command                 sysbus LoadELF ${BIN} false true cpu
59    # ensure overlayed mapped memory was not loaded with code and therefore that program executes from the array memory overlay
60    Ensure Mapped Memory Is Overlayed With Array Memory
61    Zephyr Console Should Work
62