diff --git a/apps/Arm/odroid_vm/CMakeLists.txt b/apps/Arm/odroid_vm/CMakeLists.txt index 553674fa..13e708b2 100644 --- a/apps/Arm/odroid_vm/CMakeLists.txt +++ b/apps/Arm/odroid_vm/CMakeLists.txt @@ -32,29 +32,27 @@ add_subdirectory(components/spi) add_subdirectory(components/clk) add_subdirectory(components/timer) -set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux") - # Different device tree if compiling with VmVUSB if(VmVUSB) - set(device_tree_src "linux-secure-vusb-dtb") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-vusb-dtb") else() - set(device_tree_src "linux-secure-dtb") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-dtb") endif() + # Sed the device tree updating the rootfs name +set(linux_dtb "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT "${linux_dtb}" COMMAND bash -c - "sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} > linux/linux-dtb" + "sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${device_tree_src} > ${linux_dtb}" VERBATIM + DEPENDS "${device_tree_src}" ) -# Create custom target for setting the dtb -add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") -# Add Linux VM images into file server -AddToFileServer("linux" "${linux_binary_name}") -AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) -DefineCAmkESVMFileServer() +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +DefineCAmkESVMFileServer(FILES "linux:${CAMKES_ARM_LINUX_DIR}/linux" "linux-dtb:${linux_dtb}") # Declare odroid root server DeclareCAmkESRootserver( diff --git a/apps/Arm/vm_cross_connector/CMakeLists.txt b/apps/Arm/vm_cross_connector/CMakeLists.txt index 64697289..4560c29d 100644 --- a/apps/Arm/vm_cross_connector/CMakeLists.txt +++ b/apps/Arm/vm_cross_connector/CMakeLists.txt @@ -37,8 +37,6 @@ elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt") endif() endif() -AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") - if(BUILD_CROSSVM) set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs.cpio.gz") # Checkout and configure linux to build crossvm module @@ -195,17 +193,16 @@ AddFileToOverlayDir( overlay ) -# Construct new rootfs +# Construct new rootfs. AddOverlayDirToRootfs( overlay ${rootfs_file} "buildroot" "rootfs_install" output_overlayed_rootfs_location - rootfs_target + rootfs_target # helper CMake target to be created, not used GZIP ) -AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target) AddCamkesCPPFlag( cpp_flags @@ -218,7 +215,14 @@ AddCamkesCPPFlag( VmVirtioNetVirtqueue ) -DefineCAmkESVMFileServer() +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'rootfs_target'. +DefineCAmkESVMFileServer( + FILES "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux" + "linux-initrd:${output_overlayed_rootfs_location}" +) CAmkESAddImportPath(${KernelARMPlatform}) diff --git a/apps/Arm/vm_introspect/CMakeLists.txt b/apps/Arm/vm_introspect/CMakeLists.txt index 8db76bbf..fecb68a6 100644 --- a/apps/Arm/vm_introspect/CMakeLists.txt +++ b/apps/Arm/vm_introspect/CMakeLists.txt @@ -54,8 +54,6 @@ elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt") endif() -AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") - set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs_crossvm.cpio.gz") ExternalProject_Add( @@ -104,11 +102,18 @@ AddOverlayDirToRootfs( "buildroot" "rootfs_install" output_overlayed_rootfs_location - rootfs_target + rootfs_target # helper CMake target to be created, not used GZIP ) -AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target) +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'rootfs_target'. +DefineCAmkESVMFileServer( + FILES "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux" + "linux-initrd:${output_overlayed_rootfs_location}" +) AddCamkesCPPFlag( cpp_flags @@ -121,8 +126,6 @@ AddCamkesCPPFlag( VmVirtioNetVirtqueue ) -DefineCAmkESVMFileServer() - CAmkESAddImportPath(${KernelARMPlatform}) # Define our VM Component with out cross vm dataports glue code diff --git a/apps/Arm/vm_minimal/CMakeLists.txt b/apps/Arm/vm_minimal/CMakeLists.txt index 406e9c11..1cd61a77 100644 --- a/apps/Arm/vm_minimal/CMakeLists.txt +++ b/apps/Arm/vm_minimal/CMakeLists.txt @@ -12,78 +12,80 @@ include(${CAMKES_ARM_VM_HELPERS_PATH}) set(cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm") +# On some platforms, there is no dedicated rootfs, because it's part of the +# Linux kernel image. +set(rootfs_file "") + # Create our CPP Flags based on ARM VM config variables if("${KernelARMPlatform}" STREQUAL "tk1") set(cpp_flags "-DKERNELARMPLATFORM_TK1") # Different device tree if compiling with Tk1Insecure if(Tk1Insecure) - set(device_tree_src "linux-tk1-nonsecured.dts") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-nonsecured.dts") else() - set(device_tree_src "linux-tk1-secure.dts") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-secure.dts") endif() + # kernel image contains rootfs if(VmTk1InitrdRootfs) - set(linux_binary_name "linux-tk1-initrd") + set(linux_image "${CAMKES_ARM_LINUX_DIR}/linux-tk1-initrd") else() - set(linux_binary_name "linux-tk1-debian") + set(linux_image "${CAMKES_ARM_LINUX_DIR}/linux-tk1-debian") endif() + + set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT "${dtb_file}" COMMAND - dtc -I dts -O dtb -o linux/linux-dtb ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} + dtc -I dts -O dtb -o ${dtb_file} ${device_tree_src} VERBATIM - DEPENDS ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} + DEPENDS ${device_tree_src} ) - # Create custom target for setting the dtb - add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") - - # Add Linux VM images into file server - AddToFileServer("linux" "${CAMKES_ARM_LINUX_DIR}/${linux_binary_name}") - AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) + # There is no need to create an explicit target there, any step that uses + # 'dtb_file' and lists it properly as dependency will make CMake run the + # command above to create (or update) it. elseif("${KernelARMPlatform}" STREQUAL "tx1") set(cpp_flags "-DKERNELARMPLATFORM_TX1") - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/tx1/linux") - AddToFileServer("linux-dtb" "${CAMKES_VM_IMAGES_DIR}/tx1/linux-dtb") + # kernel image contains rootfs + set(linux_image "${CAMKES_VM_IMAGES_DIR}/tx1/linux") + set(dtb_file "${CAMKES_VM_IMAGES_DIR}/tx1/linux-dtb") elseif("${KernelARMPlatform}" STREQUAL "exynos5422") find_package(camkes-vm-linux REQUIRED) include(${CAMKES_VM_LINUX_HELPERS_PATH}) set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux") - # Generate overlayed rootfs + set(linux_image "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux") set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/exynos5422/rootfs.cpio.gz") - AddToFileServer("linux-initrd" ${rootfs_file}) + # Updated dtb based on initrd UpdateDtbFromInitrd( "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux-dtb" ${rootfs_file} "0x4d700000" - dtb_gen_target - output_dtb_location + target_gen_dtb # helper CMake target to be created, not used + dtb_file ) - AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) elseif("${KernelARMPlatform}" STREQUAL "tx2") find_package(camkes-vm-linux REQUIRED) include(${CAMKES_VM_LINUX_HELPERS_PATH}) set(cpp_flags "-DKERNELARMPLATFORM_TX2") - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/tx2/linux") + set(linux_image "${CAMKES_VM_IMAGES_DIR}/tx2/linux") set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/tx2/rootfs.cpio.gz") - AddToFileServer("linux-initrd" ${rootfs_file}) + # Updated dtb based on initrd UpdateDtbFromInitrd( "${CAMKES_VM_IMAGES_DIR}/tx2/linux-dtb" ${rootfs_file} "0xf7000000" - dtb_gen_target - output_dtb_location + target_gen_dtb # helper CMake target to be created, not used + dtb_file ) - AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt") @@ -98,18 +100,18 @@ elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt") include(${CAMKES_VM_LINUX_HELPERS_PATH}) set(cpp_flags "-DKERNELARMPLATFORM_QEMU-ARM-VIRT") - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/linux") + set(linux_image "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/linux") set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/rootfs.cpio.gz") - AddToFileServer("linux-initrd" ${rootfs_file}) + # Updated dtb based on initrd UpdateDtbFromInitrd( "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/linux-dtb" ${rootfs_file} "0x4d700000" - dtb_gen_target - output_dtb_location + target_gen_dtb # helper CMake target to be created, not used + dtb_file ) - AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) + include(simulation) set(SIMULATION ON CACHE BOOL "Generate simulation script to run qemu with the proper arguments") if(SIMULATION) @@ -125,18 +127,17 @@ elseif("${KernelARMPlatform}" STREQUAL "odroidc2") CAMKES_ROOT_DTB_FILE_PATH "${CAMKES_VM_IMAGES_DIR}/odroidc2/camkes-linux-dtb" CACHE STRING "" ) - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/odroidc2/linux") + set(linux_image "${CAMKES_VM_IMAGES_DIR}/odroidc2/linux") set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/odroidc2/rootfs.cpio.gz") - AddToFileServer("linux-initrd" ${rootfs_file}) + # Updated dtb based on initrd UpdateDtbFromInitrd( "${CAMKES_VM_IMAGES_DIR}/odroidc2/linux-dtb" ${rootfs_file} "0x2d700000" - dtb_gen_target - output_dtb_location + target_gen_dtb # helper CMake target to be created, not used + dtb_file ) - AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) elseif("${KernelARMPlatform}" STREQUAL "zcu102") @@ -147,25 +148,24 @@ elseif("${KernelARMPlatform}" STREQUAL "zcu102") ) endif() - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux") - AddToFileServer( - "linux-initrd" + set(linux_image "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux") + set( + rootfs_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/rootfs-minimal.cpio.gz" ) set(dts_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux.dts") - + set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT ${dtb_file} COMMAND - dtc -q -I dts -O dtb -o linux/linux-dtb ${dts_file} + dtc -q -I dts -O dtb -o ${dtb_file} ${dts_file} VERBATIM DEPENDS ${dts_file} ) - - # Create custom target for setting the dtb - add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") - AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) + # There is no need to create an explicit target there, any step that uses + # 'dtb_file' and lists it properly as dependency will make CMake run the + # command above to create (or update) it. list(APPEND cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm/plat_include/zynqmp") @@ -174,7 +174,16 @@ endif() AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure) -DefineCAmkESVMFileServer() +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'target_gen_dtb' +set(cpio_files "linux:${linux_image}" "linux-dtb:${dtb_file}") +if(rootfs_file) + list(APPEND cpio_files "linux-initrd:${rootfs_file}") +endif() + +DefineCAmkESVMFileServer(FILES ${cpio_files}) CAmkESAddImportPath(${KernelARMPlatform}) diff --git a/apps/Arm/vm_multi/CMakeLists.txt b/apps/Arm/vm_multi/CMakeLists.txt index 7ca536ee..ab0b0d06 100644 --- a/apps/Arm/vm_multi/CMakeLists.txt +++ b/apps/Arm/vm_multi/CMakeLists.txt @@ -13,7 +13,7 @@ find_package(camkes-vm-linux REQUIRED) include(${CAMKES_VM_LINUX_HELPERS_PATH}) if("${PLATFORM}" STREQUAL "exynos5422") -# Create our CPP Flags based on ARM VM config variables + # Create our CPP Flags based on ARM VM config variables set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") elseif("${PLATFORM}" STREQUAL "qemu-arm-virt") set(cpp_flags "-DKERNELARMPLATFORM_QEMU-ARM-VIRT") @@ -46,7 +46,7 @@ AddOverlayDirToRootfs( "buildroot" "rootfs_install" vm0_output_overlayed_rootfs_location - rootfs_target_vm0 + rootfs_target_vm0 # helper CMake target to be created, not used GZIP ) @@ -69,28 +69,22 @@ AddOverlayDirToRootfs( "buildroot" "rootfs_install" client_output_overlayed_rootfs_location - rootfs_target_client_vm + rootfs_target_client_vm # helper CMake target to be created, not used GZIP ) -AddToFileServer( - "linux-initrd-vm0" - "${vm0_output_overlayed_rootfs_location}" - DEPENDS - rootfs_target_vm0 -) -AddToFileServer( - "linux-initrd-vm-client" - "${client_output_overlayed_rootfs_location}" - DEPENDS - rootfs_target_client_vm -) - -AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") - AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB VmVchan Tk1DeviceFwd Tk1Insecure) -DefineCAmkESVMFileServer() +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper targets +# 'rootfs_target_vm0' and 'rootfs_target_client_vm' +DefineCAmkESVMFileServer( + FILES + "linux-initrd-vm0:${vm0_output_overlayed_rootfs_location}" + "linux-initrd-vm-client:${client_output_overlayed_rootfs_location}" + "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux" +) CAmkESAddImportPath(${KernelARMPlatform}) diff --git a/apps/Arm/vm_serial_server/CMakeLists.txt b/apps/Arm/vm_serial_server/CMakeLists.txt index 1547aef0..df72cced 100644 --- a/apps/Arm/vm_serial_server/CMakeLists.txt +++ b/apps/Arm/vm_serial_server/CMakeLists.txt @@ -16,7 +16,6 @@ include(${CAMKES_VM_LINUX_HELPERS_PATH}) # Create our CPP Flags based on ARM VM config variables set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") -AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux") # Generate overlayed rootfs set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/exynos5422/rootfs.cpio.gz") AddFileToOverlayDir( @@ -32,25 +31,31 @@ AddOverlayDirToRootfs( "buildroot" "rootfs_install" output_overlayed_rootfs_location - rootfs_target + rootfs_target # helper CMake target to be created, not used GZIP ) -AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target) + # Updated dtb based on generated initrd UpdateDtbFromInitrd( "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux-dtb-virtcon" ${output_overlayed_rootfs_location} "0x4d700000" - dtb_gen_target + dtb_gen_target # helper CMake target to be created, not used output_dtb_location - DEPENDS - rootfs_target ) -AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure) -DefineCAmkESVMFileServer() +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper targets +# 'rootfs_target' and 'dtb_gen_target' +DefineCAmkESVMFileServer( + FILES + "linux:${CAMKES_VM_IMAGES_DIR}/exynos5422/linux" + "linux-initrd:${output_overlayed_rootfs_location}" + "linux-dtb:${output_dtb_location}" +) CAmkESAddImportPath(exynos5422) diff --git a/apps/Arm/vm_virtio_net/CMakeLists.txt b/apps/Arm/vm_virtio_net/CMakeLists.txt index ca3859c4..9716b555 100644 --- a/apps/Arm/vm_virtio_net/CMakeLists.txt +++ b/apps/Arm/vm_virtio_net/CMakeLists.txt @@ -15,9 +15,15 @@ include(${CAMKES_VM_LINUX_HELPERS_PATH}) set(cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm") +# Set defaults, platform may overwrite this belwo set(dtb_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux-dtb") +set(linux_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs.cpio.gz") +# For some platforms, the DTB must contains the rootfs location and size. +set(rootfs_address "") +set(dtb_file_patched "${dtb_file}") + if("${KernelARMPlatform}" STREQUAL "exynos5422") # Create our CPP Flags based on ARM VM config variables set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") @@ -35,26 +41,26 @@ elseif("${KernelARMPlatform}" STREQUAL "zcu102") message(FATAL_ERROR "Petalinux 2022_1 is the only supported version for this application") endif() - set(dts_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux.dts") + set(linux_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux") set( rootfs_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/rootfs-minimal.cpio.gz" ) + set(dts_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux.dts") + set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT ${dtb_file} COMMAND - dtc -q -I dts -O dtb -o linux/linux-dtb ${dts_file} + dtc -q -I dts -O dtb -o ${dtb_file} ${dts_file} VERBATIM DEPENDS ${dts_file} ) - - # Create custom target for setting the dtb - add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") - AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) + # There is no need to create an explicit target there, any step that uses + # 'dtb_file' and lists it properly as dependency will make CMake run the + # command above to create (or update) it. list(APPEND cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm/plat_include/zynqmp") - CAmkESAddImportPath(${KernelARMPlatform}/${VmZynqmpPetalinuxVersion}) endif() @@ -116,27 +122,25 @@ AddOverlayDirToRootfs( "buildroot" "rootfs_install" output_overlayed_rootfs_location - rootfs_target + target_gen_rootfs # helper CMake target to be created, not used GZIP ) -AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target) - -if("${KernelARMPlatform}" STREQUAL "zcu102") - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux") -else() - # Updated dtb based on generated initrd +set(cpio_files "linux:${linux_file}" "linux-initrd:${output_overlayed_rootfs_location}") +if(rootfs_address) + # Updated dtb based on generated initrd. There is no need to explicitly + # depend on 'target_gen_rootfs' here, there is an implicit dependency on + # the file that 'output_overlayed_rootfs_location' refers to. UpdateDtbFromInitrd( ${dtb_file} ${output_overlayed_rootfs_location} ${rootfs_address} - dtb_gen_target - output_dtb_location - DEPENDS - rootfs_target + target_gen_dtb # helper CMake target to be created, not used + dtb_file_patched # output, overwrite default ) - AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") - AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) + list(APPEND cpio_files "linux-dtb:${dtb_file_patched}") +else() + list(APPEND cpio_files "linux-dtb:${dtb_file}") endif() AddCamkesCPPFlag( @@ -149,7 +153,11 @@ AddCamkesCPPFlag( VmVirtioNetVirtqueue ) -DefineCAmkESVMFileServer() +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper targets +# 'target_gen_rootfs' or 'target_gen_dtb' +DefineCAmkESVMFileServer(FILES ${cpio_files}) CAmkESAddImportPath(${KernelARMPlatform}) diff --git a/apps/x86/cma34cr_centos/CMakeLists.txt b/apps/x86/cma34cr_centos/CMakeLists.txt index 4c389037..e6e9a67f 100644 --- a/apps/x86/cma34cr_centos/CMakeLists.txt +++ b/apps/x86/cma34cr_centos/CMakeLists.txt @@ -18,21 +18,28 @@ DeclareCAmkESVM(Init0 EXTRA_SOURCES ${init0_extra} EXTRA_LIBS ethdrivers) # Declare C162 Kernel DecompressLinuxKernel( - decompress_linux decompressed_kernel ${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/bzimage + decompress_linux # helper CMake target to be created, not used + decompressed_kernel + ${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/bzimage ) -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS decompress_linux) - -# Declare C162 Rootfs -AddToFileServer("rootfs.cpio" ${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/rootfs.cpio) # Provided by find_package(util_libs) include(${LWIP_HELPERS}) # Declare lwipopts.h include AddLWIPConfiguration(${CMAKE_CURRENT_SOURCE_DIR}/lwip_include) -# Initialise CAmkES Root Server with addition CPP includes -DeclareCAmkESVMRootServer( - cma34cr_centos.camkes +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'decompress_linux'. +DefineCAmkESVMFileServer( + FILES "bzimage:${decompressed_kernel}" + "rootfs.cpio:${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/rootfs.cpio" +) + +# Declare CAmkES Root Server +DeclareCAmkESRootserver( + "cma34cr_centos.camkes" CPP_INCLUDES ${CAMKES_VM_DIR}/components/StringReverse/include ${CAMKES_VM_DIR}/components/Ethdriver/include diff --git a/apps/x86/cma34cr_ubuntu/CMakeLists.txt b/apps/x86/cma34cr_ubuntu/CMakeLists.txt index 84855785..44c22076 100644 --- a/apps/x86/cma34cr_ubuntu/CMakeLists.txt +++ b/apps/x86/cma34cr_ubuntu/CMakeLists.txt @@ -20,11 +20,20 @@ DeclareCAmkESVM(Init0) # Declare C162 Kernel GetArchSpecificLinuxKernelFile("32" kernel_file) -DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) - -# Declare C162 Rootfs -AddToFileServer("rootfs.cpio" ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_linux/rootfs.cpio) - -# Initialise CAmkES Root Server with addition CPP includes -DeclareCAmkESVMRootServer(cma34cr_ubuntu.camkes) +DecompressLinuxKernel( + extract_linux_kernel # helper CMake target to be created, not used + decompressed_kernel + ${kernel_file} +) + +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'extract_linux_kernel'. +DefineCAmkESVMFileServer( + FILES "bzimage:${decompressed_kernel}" + "rootfs.cpio:${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_linux/rootfs.cpio" +) + +# Declare CAmkES Root Server +DeclareCAmkESRootserver("cma34cr_centos.camkes") diff --git a/apps/x86/minimal/CMakeLists.txt b/apps/x86/minimal/CMakeLists.txt index e15612cf..0f0254b3 100644 --- a/apps/x86/minimal/CMakeLists.txt +++ b/apps/x86/minimal/CMakeLists.txt @@ -24,16 +24,22 @@ GetDefaultLinuxKernelFile(kernel_file) GetDefaultLinuxRootfsFile(rootfs_file) # Decompress Linux Kernel image and add to file server -DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) +DecompressLinuxKernel( + extract_linux_kernel # helper CMake target to be created, not used + decompressed_kernel + ${kernel_file} +) -# Add rootfs images into file server -AddToFileServer("rootfs.cpio" ${rootfs_file}) +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'extract_linux_kernel'. +DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "rootfs.cpio:${rootfs_file}") -# Initialise CAmkES Root Server with addition CPP includes -DeclareCAmkESVMRootServer(minimal.camkes) +# Declare CAmkES Root Server +DeclareCAmkESRootserver("minimal.camkes" CPP_INCLUDES "${VM_PROJECT_DIR}/components/VM") if(SIMULATION) - include(simulation) + include(simulation) GenerateSimulateScript() -endif() \ No newline at end of file +endif() diff --git a/apps/x86/minimal_64/CMakeLists.txt b/apps/x86/minimal_64/CMakeLists.txt index d4d1a1f8..91274b67 100644 --- a/apps/x86/minimal_64/CMakeLists.txt +++ b/apps/x86/minimal_64/CMakeLists.txt @@ -21,14 +21,20 @@ GetDefaultLinuxKernelFile(kernel_file) GetDefaultLinuxRootfsFile(rootfs_file) # Decompress Linux Kernel image and add to file server -DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) - -# Add rootfs images into file server -AddToFileServer("rootfs.cpio" ${rootfs_file}) - -# Initialise CAmkES Root Server with addition CPP includes -DeclareCAmkESVMRootServer(minimal.camkes) +DecompressLinuxKernel( + extract_linux_kernel # helper CMake target to be created, not used + decompressed_kernel + ${kernel_file} +) + +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'extract_linux_kernel'. +DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "rootfs.cpio:${rootfs_file}") + +# Declare CAmkES Root Server +DeclareCAmkESRootserver("minimal.camkes" CPP_INCLUDES "${VM_PROJECT_DIR}/components/VM") if(SIMULATION) include(simulation) diff --git a/apps/x86/optiplex9020/CMakeLists.txt b/apps/x86/optiplex9020/CMakeLists.txt index 8ae43a20..1b21b293 100644 --- a/apps/x86/optiplex9020/CMakeLists.txt +++ b/apps/x86/optiplex9020/CMakeLists.txt @@ -25,13 +25,22 @@ GetArchDefaultLinuxKernelFile("32" kernel_file) GetArchDefaultLinuxRootfsFile("32" rootfs_file) # Decompress Linux Kernel image -DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) - -# Add Linux VM images into file server -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) -AddToFileServer("rootfs.cpio" ${rootfs_file}) +DecompressLinuxKernel( + extract_linux_kernel # helper CMake target to be created, not used + decompressed_kernel + ${kernel_file} +) -# Initialise CAmkES Root Server with additional CPP includes -DeclareCAmkESVMRootServer( - optiplex9020.camkes CPP_INCLUDES ${CAMKES_VM_DIR}/components/StringReverse/include +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'extract_linux_kernel'. +DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "rootfs.cpio:${rootfs_file}") + +# Declare CAmkES Root Server +DeclareCAmkESRootserver( + "optiplex9020.camkes" + CPP_INCLUDES + "${VM_PROJECT_DIR}/components/VM" + "${CAMKES_VM_DIR}/components/StringReverse/include" ) diff --git a/apps/x86/virtio_blk_sample/CMakeLists.txt b/apps/x86/virtio_blk_sample/CMakeLists.txt index e6160dcd..f6f6cd76 100644 --- a/apps/x86/virtio_blk_sample/CMakeLists.txt +++ b/apps/x86/virtio_blk_sample/CMakeLists.txt @@ -21,12 +21,20 @@ GetDefaultLinuxKernelFile(kernel_file) GetDefaultLinuxRootfsFile(rootfs_file) # Decompress Linux Kernel image and add to file server -DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) - -AddToFileServer("rootfs.cpio" ${rootfs_file}) - -DeclareCAmkESVMRootServer(virtio_blk_sample.camkes) +DecompressLinuxKernel( + extract_linux_kernel # helper CMake target to be created, not used + decompressed_kernel + ${kernel_file} +) + +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper target +# 'extract_linux_kernel'. +DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "rootfs.cpio:${rootfs_file}") + +# Declare CAmkES Root Server +DeclareCAmkESRootserver("virtio_blk_sample.camkes") if(SIMULATION) include(simulation) diff --git a/apps/x86/zmq_samples/CMakeLists.txt b/apps/x86/zmq_samples/CMakeLists.txt index aa6e69ec..4b35e913 100644 --- a/apps/x86/zmq_samples/CMakeLists.txt +++ b/apps/x86/zmq_samples/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(camkes-vm-linux REQUIRED) include(${CAMKES_VM_LINUX_HELPERS_PATH}) if(CAKEML_FILTER) + set(zmq_camkes "zmq_cakeml.camkes") include("libs/cakeml_helpers.cmake") # Number of vms. @@ -37,6 +38,7 @@ if(CAKEML_FILTER) 50 ) else() + set(zmq_camkes "zmq_samples.camkes") # Number of vms. set(NumberVMs 3) endif() @@ -133,39 +135,43 @@ AddZMQBinary(worker) AddZMQBinary(pub) AddZMQBinary(sub) +set(rootfs_images "") + foreach(i RANGE ${NumberVMsLess1}) + set(overlay_target "overlay_vm${i}") + set(rootfs_target "rootfs_target_vm${i}") if(NOT CAKEML_FILTER) AddFileToOverlayDir( "S91zmq_bench" ${CMAKE_CURRENT_SOURCE_DIR}/src/user/zmq_bench_${i}.sh "etc/init.d" - overlay_vm${i} + "${overlay_target}" ) endif() # Add the buildroot overlay to our bare rootfs image AddOverlayDirToRootfs( - overlay_vm${i} - ${rootfs_file} + "${overlay_target}" + "${rootfs_file}" "buildroot" "rootfs_install" - output_rootfs_location_vm${i} - rootfs_target_vm${i} - ) - AddToFileServer( - "vm${i}_rootfs.cpio" - "${output_rootfs_location_vm${i}}" - DEPENDS - rootfs_target_vm${i} + rootfs_img + "${rootfs_target}" # helper CMake target to be created, not used ) + list(APPEND rootfs_images "vm${i}_rootfs.cpio:${rootfs_img}") endforeach() # Decompress Linux Kernel image and add to file server -DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) -AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) +DecompressLinuxKernel( + extract_linux_kernel # helper CMake target to be created, not used + decompressed_kernel + ${kernel_file} +) + +# Create file server with VM images. There is an implicit dependency on the +# input files, so the rules above will be invoked to generate/update the files. +# There is no need to specify an explicit dependency on the helper targets +# 'extract_linux_kernel' and each '${rootfs_target}' +DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "${rootfs_images}") # Initialise CAmkES Root Server with addition CPP includes -if(CAKEML_FILTER) - DeclareCAmkESVMRootServer(zmq_cakeml.camkes) -else() - DeclareCAmkESVMRootServer(zmq_samples.camkes) -endif() +DeclareCAmkESRootserver("${zmq_camkes}" CPP_INCLUDES "${VM_PROJECT_DIR}/components/VM")