diff --git a/auto_zvm.sh b/auto_zvm.sh deleted file mode 100755 index d67301e4f55d479d9ef0fcd4f790defe5730b652..0000000000000000000000000000000000000000 --- a/auto_zvm.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# operation string and platform string -OPS=$1 -PLAT=$2 - -ops_build="build" -ops_debug="debug" - -plat_qemu="qemu" -plat_fvp="fvp" -plat_rk3568="rk3568" - -if [[ "$1" != "$ops_build" && "$1" != "$ops_debug" ]]; then - echo "Invalid build command. " - echo "Please use either 'build' or 'debug'." - exit 1 -fi -if [[ "$2" != "$plat_qemu" && "$2" != "$plat_rk3568" && "$2" != "$plat_fvp" ]]; then - echo "Invalid platform." - echo "Please use either 'qemu', 'rk3568', or 'fvp'." - exit 1 -fi - -# Build system -if [ "$OPS" = "$ops_build" ]; then - rm -rf build/ - if [ "$PLAT" = "$plat_qemu" ]; then - west build -b qemu_cortex_max_smp samples/_zvm - elif [ "$PLAT" = "$plat_fvp" ]; then - west build -b fvp_cortex_a55x4_a75x2_smp samples/_zvm \ - -DARMFVP_BL1_FILE=$(pwd)/zvm_config/fvp_platform/hub/bl1.bin \ - -DARMFVP_FIP_FILE=$(pwd)/zvm_config/fvp_platform/hub/fip.bin - elif [ "$PLAT" = "$plat_rk3568" ]; then - west build -b roc_rk3568_pc_smp samples/_zvm - cp build/zephyr/zvm_host.bin ../../tftp_ser - else - echo "Error arguments for this auto.sh! \n Please input command like: ./auto_build.sh build qemu. " - fi - -elif [ "$OPS" = "$ops_debug" ]; then - if [ "$PLAT" = "$plat_qemu" ]; then - $(pwd)/zvm_config/qemu_platform/hub/qemu-system-aarch64 \ - -cpu max -m 4G -nographic -machine virt,virtualization=on,gic-version=3 \ - -net none -pidfile qemu.pid -chardev stdio,id=con,mux=on \ - -serial chardev:con -mon chardev=con,mode=readline -serial pty -serial pty -smp cpus=4 \ - -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/zephyr.bin,addr=0xf2000000,force-raw=on \ - -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/Image,addr=0xf3000000,force-raw=on \ - -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/Image,addr=0xe0000000,force-raw=on \ - -device loader,file=$(pwd)/zvm_config/qemu_platform/hub/linux-qemu-virtio.dtb,addr=0xf2a00000 \ - -kernel $(pwd)/build/zephyr/zvm_host.elf - -### using gdb to connect it: -# gdb-multiarch -q -ex 'file ./build/zephyr/zvm_host.elf' -ex 'target remote localhost:1234' - - elif [ "$PLAT" = "$plat_fvp" ]; then -# /opt/arm/developmentstudio-2021.2/bin/FVP_Base_Cortex-A55x4+Cortex-A75x2 \ - /path-to/FVP_Base_RevC-2xAEMvA \ - -C pctl.startup=0.0.0.* \ - -C bp.secure_memory=0 \ - -C cache_state_modelled=0 \ - -C bp.pl011_uart0.untimed_fifos=1 -C bp.pl011_uart0.unbuffered_output=1 -C bp.pl011_uart0.out_file=uart0.log \ - -C bp.pl011_uart1.out_file=uart1.log \ - -C bp.terminal_0.terminal_command=/usr/bin/gnome-terminal -C bp.terminal_0.mode=raw \ - -C bp.terminal_1.terminal_command=/usr/bin/gnome-terminal -C bp.terminal_1.mode=raw \ - -C bp.secureflashloader.fname=/path-to/bl1.bin \ - -C bp.flashloader0.fname=/path-to/fip.bin \ - -C bp.ve_sysregs.mmbSiteDefault=0 -C bp.ve_sysregs.exit_on_shutdown=1 \ - --data cluster0.cpu0=/path-to/zephyr.bin@0xa0000000 \ - --data cluster0.cpu0=/path-to/Image@0xb0000000 \ - --data cluster0.cpu0=/path-to/fvp-base-gicv3-psci.dtb@0xc0000000 \ - --cpulimit 4 \ - --iris-server - else - echo "Error arguments for this auto.sh! \n Please input command like: ./z_auto.sh build qemu. " - fi -fi diff --git a/include/virtualization/tools/elfloader.h b/include/virtualization/tools/elfloader.h index 5e46878264db1b79e99535c6e1e4a908e9d1c047..5592f220ab6ed7703d54c41406358520aaeda8da 100644 --- a/include/virtualization/tools/elfloader.h +++ b/include/virtualization/tools/elfloader.h @@ -76,6 +76,6 @@ typedef struct { * @param vm_info : z_vm_info strcut. * @return int : return code. */ -int elf_loader(void *src_addr, void *dest_addr, struct z_vm_info *vm_info); +int elf_loader(void *p_src_addr,void *src_addr, void *dest_addr, struct z_vm_info *vm_info); #endif /* __ELFLOADER_H_ */ diff --git a/samples/_zvm/prj.conf b/samples/_zvm/prj.conf index de39c5e2438624701d59d419b86880400670fc57..4dcef13bec15556eb7f07e4f8ab24f0f52349dd7 100644 --- a/samples/_zvm/prj.conf +++ b/samples/_zvm/prj.conf @@ -4,7 +4,7 @@ # ZVM CONFIG_ZVM=y CONFIG_NO_OPTIMIZATIONS=y - +CONFIG_ZVM_ELF_LOADER=y # Shell CONFIG_SHELL=y CONFIG_SHELL_GETOPT=y diff --git a/soc/arm64/qemu_cortex_max/mmu_regions.c b/soc/arm64/qemu_cortex_max/mmu_regions.c index a7cd789cedf3f43cf9a3f40840a4b7a2d9938d53..434cd94d31062e437e2b4131a400b4e8b038cd13 100644 --- a/soc/arm64/qemu_cortex_max/mmu_regions.c +++ b/soc/arm64/qemu_cortex_max/mmu_regions.c @@ -26,8 +26,13 @@ static const struct arm_mmu_region mmu_regions[] = { DT_REG_SIZE(DT_INST(0, arm_pl011)), MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + MMU_REGION_FLAT_ENTRY("ELF-Zephyr.elf", + DT_REG_ADDR(DT_NODELABEL(zephyr_ddr)), + DT_REG_SIZE(DT_NODELABEL(zephyr_ddr)), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + #if defined(CONFIG_ZVM) - MMU_REGION_FLAT_ENTRY("UART1", + MMU_REGION_FLAT_ENTRY("UART1", DT_REG_ADDR(DT_INST(1, arm_pl011)), DT_REG_SIZE(DT_INST(1, arm_pl011)), MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), diff --git a/subsys/virtualization/os/os.c b/subsys/virtualization/os/os.c index 565686329b4f55d45eb6efd8f142d99fe5ee5339..9efd12fcb660b48243d13477678b21634c1b8e7b 100644 --- a/subsys/virtualization/os/os.c +++ b/subsys/virtualization/os/os.c @@ -125,7 +125,7 @@ int get_os_info_by_id(struct getopt_state *state, struct z_vm_info *vm_info) #if defined(CONFIG_SOC_QEMU_CORTEX_MAX) #ifdef CONFIG_ZVM_ELF_LOADER - ret = elf_loader((void *)tmp_vm_info.vm_image_base, NULL, vm_info); + ret = elf_loader((void *)tmp_vm_info.vm_image_base,(void *)tmp_vm_info.vm_virt_base, NULL, vm_info); #else vm_info->entry_point = tmp_vm_info.entry_point; #endif /* CONFIG_ZVM_ELFLOADER */ @@ -171,7 +171,7 @@ out: #if defined(CONFIG_SOC_QEMU_CORTEX_MAX) #ifdef CONFIG_ZVM_ELF_LOADER - ret = elf_loader((void *)tmp_vm_info.vm_image_base, NULL, vm_info); + ret = elf_loader((void *)tmp_vm_info.vm_image_base,(void *)tmp_vm_info.vm_virt_base, NULL, vm_info); #else vm_info->entry_point = tmp_vm_info.entry_point; #endif /* CONFIG_ZVM_ELFLOADER */ diff --git a/subsys/virtualization/tools/elfloader.c b/subsys/virtualization/tools/elfloader.c index 1477022490c2dc4423669ef79f872b3f1539f5f3..74b10f27a55f9d0106032d2bce8093837ad7111c 100644 --- a/subsys/virtualization/tools/elfloader.c +++ b/subsys/virtualization/tools/elfloader.c @@ -171,7 +171,7 @@ static el_status elf_init(el_ctx *ctx, void *src) } -static el_status elf_load(el_ctx *ctx, el_alloc_cb alloc, void *src) +static el_status elf_load(el_ctx *ctx, el_alloc_cb alloc, void *p_src,void *src) { el_status rv = EL_OK; @@ -183,7 +183,7 @@ static el_status elf_load(el_ctx *ctx, el_alloc_cb alloc, void *src) Elf_Phdr ph; unsigned i = 0; for(;;) { - if ((rv = elf_findphdr(ctx, &ph, PT_LOAD, &i, src))){ + if ((rv = elf_findphdr(ctx, &ph, PT_LOAD, &i, p_src))){ return rv; } @@ -206,7 +206,7 @@ static el_status elf_load(el_ctx *ctx, el_alloc_cb alloc, void *src) } /* read loaded portion */ - if ((rv = el_pread(ctx, dest, src+ph.p_offset, ph.p_filesz))){ + if ((rv = el_pread(ctx, dest, p_src+ph.p_offset, ph.p_filesz))){ return rv; } @@ -346,7 +346,7 @@ static el_status elf_relocate(el_ctx *ctx, void *src) /** * @brief load vm's elf file for debug it's elf file */ -int elf_loader(void *src_addr, void *dest_addr, struct z_vm_info *vm_info) +int elf_loader(void *p_src_addr,void *src_addr, void *dest_addr, struct z_vm_info *vm_info) { ARG_UNUSED(dest_addr); @@ -357,7 +357,7 @@ int elf_loader(void *src_addr, void *dest_addr, struct z_vm_info *vm_info) ctx.pread = file_pread; /* Init elf struct */ - ret = elf_init(&ctx, src_addr); + ret = elf_init(&ctx, p_src_addr); if (ret) { ZVM_LOG_WARN("Elf_loader struct init error, status: %d", ret); return -ret; @@ -372,7 +372,7 @@ int elf_loader(void *src_addr, void *dest_addr, struct z_vm_info *vm_info) /* set base load addr for vm elf file */ ctx.base_load_vaddr = ctx.base_load_paddr = (uintptr_t) buf; - ret = elf_load(&ctx, alloccb, src_addr); + ret = elf_load(&ctx, alloccb, p_src_addr,src_addr); if (ret) { ZVM_LOG_WARN("Elf_loader addr load error, status: %d", ret); return -ret; @@ -396,7 +396,7 @@ int elf_loader(void *src_addr, void *dest_addr, struct z_vm_info *vm_info) /* k_free(buf); */ /* copy the block to aimed address */ - if (memcpy((void*)src_addr, buf, ctx.memsz - (uint64_t)src_addr)== NULL) { + if (memcpy((void*)p_src_addr, buf, ctx.memsz - (uint64_t)src_addr)== NULL) { return -1; }