1:name: Cortex-A53
2:description: This script runs Linux (with Coreboot and ATF) on a 64-bit ARM Cortex-A53.
3
4$bin?=@https://dl.antmicro.com/projects/renode/coreboot-linux-armv8a-gicv3-multicore.rom-s_67108864-02cf8d5b31d105603e63306ac07517a48134bfed
5$name?="ARM Cortex-A53"
6
7using sysbus
8mach create $name
9
10machine LoadPlatformDescription @platforms/cpus/cortex-a53-gicv3_smp.repl
11
12showAnalyzer uart0
13
14# Based on https://github.com/ARM-software/arm-trusted-firmware/blob/5436047a0e1f32543042d6de9f1f6a3edcd47591/plat/qemu/qemu/include/platform_def.h#L107C1-L115C35
15set py_virt_trusted_mailbox_hook
16"""
17from Antmicro.Renode.Peripherals.CPU import RegisterValue
18
19PLAT_VIRT_TRUSTED_MAILBOX_BASE = 0x0e000000
20PLAT_VIRT_HOLD_BASE = PLAT_VIRT_TRUSTED_MAILBOX_BASE + 0x8
21PLAT_VIRT_HOLD_ENTRY_SIZE = 0x8
22
23PLAT_VIRT_HOLD_STATE_WAIT = 0
24PLAT_VIRT_HOLD_STATE_GO = 1
25
26_cpus = filter(lambda cpu: str(type(cpu)) == "<type 'ARMv8A'>", emulationManager.Instance.CurrentEmulation.Machines[0].SystemBus.GetCPUs())
27cpus = {cpu.MultiprocessingId: cpu for cpu in _cpus}
28
29idx = (address - PLAT_VIRT_HOLD_BASE) // PLAT_VIRT_HOLD_ENTRY_SIZE
30
31secure_entrypoint = self.ReadQuadWord(PLAT_VIRT_TRUSTED_MAILBOX_BASE);
32
33if value == PLAT_VIRT_HOLD_STATE_GO:
34    cpus[idx].PC = RegisterValue.Create(secure_entrypoint, 64)
35    cpus[idx].IsHalted = False
36    cpu.InfoLog("CPU %d started at PC: 0x%x" % (idx, secure_entrypoint))
37elif value == PLAT_VIRT_HOLD_STATE_WAIT:
38    cpus[idx].IsHalted = True
39    cpu.InfoLog("CPU %d halted")
40"""
41
42macro reset
43"""
44    # Preconfigure UART to see Coreboot and ATF boot logs.
45    uart0 WriteDoubleWord 0x30 0x301
46    uart0 WriteDoubleWord 0x2c 0x40
47
48    sysbus LoadBinary $bin 0x0
49
50    sysbus LoadSymbolsFrom @https://dl.antmicro.com/projects/renode/coreboot-bootblock-armv8a-gicv3-multicore.elf-s_45992-e566f9ef7c7f1357a6a5f4e433b42eae686b2773
51    sysbus LoadSymbolsFrom @https://dl.antmicro.com/projects/renode/coreboot-romstage-armv8a-gicv3-multicore.elf-s_53824-78204652d3be096534a1e3036f308ff0c93f5423
52    sysbus LoadSymbolsFrom @https://dl.antmicro.com/projects/renode/coreboot-ramstage-armv8a-gicv3-multicore.elf-s_147352-4d8d77fcee90f90eceebef782140189b21169778
53    sysbus LoadSymbolsFrom @https://dl.antmicro.com/projects/renode/bl31-atf-armv8a-gicv3-multicore.elf-s_1259192-f31a6120e8881925b3290ddd7ac2bc008f56460a
54    sysbus LoadSymbolsFrom @https://dl.antmicro.com/projects/renode/vmlinux-armv8a-gicv3-multicore-s_14825032-9d3f0ca4dc4b246cc648bb45bb36d8c2317bc41b
55
56    sysbus AddWatchpointHook 0x0e000008 QuadWord Write $py_virt_trusted_mailbox_hook # CPU 0 Mailbox
57    sysbus AddWatchpointHook 0x0e000010 QuadWord Write $py_virt_trusted_mailbox_hook # CPU 1 Mailbox
58    sysbus AddWatchpointHook 0x0e000018 QuadWord Write $py_virt_trusted_mailbox_hook # CPU 2 Mailbox
59    sysbus AddWatchpointHook 0x0e000020 QuadWord Write $py_virt_trusted_mailbox_hook # CPU 3 Mailbox
60"""
61runMacro $reset
62