# Configuration for gem5 running on ARM64

#@TYPE: Machine
#@NAME: Gem5 arm64 machine
#@DESCRIPTION: Machine configuration for Gem5 arm64

TUNE_FEATURES = "aarch64"

require conf/machine/include/arm/arch-armv8a.inc

MACHINE_FEATURES = "optee pci"

KERNEL_IMAGETYPES = "Image vmlinux"
KERNEL_IMAGETYPE = "Image"

IMAGE_FSTYPES += "tar.bz2 ext4"

SERIAL_CONSOLES = "115200;ttyAMA0"

EXTRA_IMAGEDEPENDS += "virtual/gem5-bootloader"

PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto"
PREFERRED_VERSION_linux-yocto ?= "5.4%"


# Uncomment the following if you need to build gem5 provided bootloader, else
# using standard bootloader by Linux aarch64
# Use gem5 provided bootloader
# PREFERRED_PROVIDER_virtual/gem5-bootloader = "gem5-aarch64-bootloader"

# use the dtb stored in the kernel recipe
# KERNEL_DEVICETREE ?= "gem5-arm64/armv8_gem5_v2_4cpu.dtb"

# Use Linux aarch64 boot wrapper with FDT support and generated
# dtb (gem5-aarch64-dtb.bb)
PREFERRED_PROVIDER_virtual/gem5-bootloader = "boot-wrapper-aarch64"

BOOT_WRAPPER_AARCH64_CMDLINE ?= "\
    earlyprintk=pl011,0x1c090000 console=ttyAMA0 root=/dev/vda rw mem=1G \
    "
# Use baremetal profile and axf file so dtb is in axf file
GEM5_RUN_PROFILE = "configs/example/arm/baremetal.py"
GEM5_RUN_KERNEL = "linux-system.axf"
GEM5_RUN_EXTRA = ""
GEM5_RUN_DTB = ""
GEM5_RUN_CMDLINE = ""

EXTRA_IMAGEDEPENDS += "gem5-aarch64-native"

# As this is a virtual target that will not be used in the real world there is
# no need for real SSH keys.  Disable rng-tools (which takes too long to
# initialise) and install the pre-generated keys.
PACKAGECONFIG:remove:pn-openssh = "rng-tools"
MACHINE_EXTRA_RRECOMMENDS += "ssh-pregen-hostkeys"
