diff --git a/hypervisor/arch/riscv/Makefile b/hypervisor/arch/riscv/Makefile index 26d4f3094..0e5c77074 100644 --- a/hypervisor/arch/riscv/Makefile +++ b/hypervisor/arch/riscv/Makefile @@ -62,19 +62,24 @@ HOST_C_SRCS += arch/riscv/irq.c HOST_C_SRCS += arch/riscv/pgtable.c HOST_C_SRCS += arch/riscv/security.c -#HV guest C source -HOST_C_SRCS += arch/riscv/guest/vm.c - # Virtual platform assembly sources VP_S_SRCS += # Virtual platform C sources VP_C_SRCS += arch/riscv/guest/guest_memory.c +VP_C_SRCS += arch/riscv/guest/vcpu.c +VP_C_SRCS += arch/riscv/guest/vm.c + +VM_CFG_C_SRCS += $(SCENARIO_CFG_DIR)/vm_configurations.c +VM_CFG_C_SRCS += $(BOARD_CFG_DIR)/pci_dev.c +VM_CFG_C_SRCS += $(BOARD_CFG_DIR)/pt_intx.c +VM_CFG_C_SRCS += $(BOARD_INFO_DIR)/board.c HOST_C_OBJS := $(patsubst %.c,$(HV_OBJDIR)/%.o,$(HOST_C_SRCS)) HOST_S_OBJS := $(patsubst %.S,$(HV_OBJDIR)/%.o,$(HOST_S_SRCS)) VP_C_OBJS := $(patsubst %.c,$(HV_OBJDIR)/%.o,$(VP_C_SRCS)) VP_S_OBJS := $(patsubst %.S,$(HV_OBJDIR)/%.o,$(VP_S_SRCS)) +VM_CFG_C_OBJS := $(patsubst %.c,%.o,$(VM_CFG_C_SRCS)) HOST_MOD := $(HV_MODDIR)/host_mod.a VP_MOD := $(HV_MODDIR)/vp_mod.a @@ -85,5 +90,5 @@ MODULES += $(VP_MOD) $(HOST_MOD): $(HOST_C_OBJS) $(HOST_S_OBJS) $(AR) $(ARFLAGS) $(HOST_MOD) $(HOST_C_OBJS) $(HOST_S_OBJS) -$(VP_MOD): $(VP_C_OBJS) $(VP_S_OBJS) - $(AR) $(ARFLAGS) $(VP_MOD) $(VP_C_OBJS) $(VP_S_OBJS) +$(VP_MOD): $(VP_C_OBJS) $(VP_S_OBJS) $(VM_CFG_C_OBJS) + $(AR) $(ARFLAGS) $(VP_MOD) $(VP_C_OBJS) $(VP_S_OBJS) $(VM_CFG_C_OBJS) diff --git a/hypervisor/arch/riscv/dummy.c b/hypervisor/arch/riscv/dummy.c deleted file mode 100644 index 61d94b7b7..000000000 --- a/hypervisor/arch/riscv/dummy.c +++ /dev/null @@ -1,23 +0,0 @@ -#define SBI_EXT_CONSOLE_PUTCHAR 0x01 -#define SBI_EXT_CONSOLE_GETCHAR 0x02 - -#define SBI_FID_CONSOLE_PUTCHAR 0x0 -#define SBI_FID_CONSOLE_GETCHAR 0x0 - -extern long sbi_call(long eid, long fid, long arg0, long arg1, long arg2, long arg3); - -static void sbi_putchar(int ch) { - sbi_call(SBI_EXT_CONSOLE_PUTCHAR, SBI_FID_CONSOLE_PUTCHAR, ch, 0, 0, 0); -} - -static void sbi_puts(const char *str) { - while (*str) { - sbi_putchar(*str); - str++; - } -} - -void print_hello_world(void) { - sbi_puts("Hello World!\n"); -} - diff --git a/hypervisor/arch/riscv/dummy_entry.S b/hypervisor/arch/riscv/dummy_entry.S deleted file mode 100644 index 1ef667c3c..000000000 --- a/hypervisor/arch/riscv/dummy_entry.S +++ /dev/null @@ -1,31 +0,0 @@ -.section .text -.global _start - -_start: - csrci sstatus, 0x2 - li sp, 0x81010000 - call print_hello_world - -wait_loop: - wfi - j wait_loop - -.global sbi_call -sbi_call: - mv t0, a0 - mv t1, a1 - - mv a0, a2 - mv a1, a3 - mv a2, a4 - mv a3, a5 - mv a4, a6 - mv a5, a7 - - mv a6, t1 - mv a7, t0 - - ecall - - ret - diff --git a/hypervisor/arch/riscv/guest/vcpu.c b/hypervisor/arch/riscv/guest/vcpu.c new file mode 100644 index 000000000..c51ec75b3 --- /dev/null +++ b/hypervisor/arch/riscv/guest/vcpu.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2018-2025 Intel Corporation. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include + +int32_t arch_init_vcpu(struct acrn_vcpu *vcpu) +{ + (void)vcpu; + return 0; +} + +void arch_deinit_vcpu(struct acrn_vcpu *vcpu) +{ + (void)vcpu; +} + +void arch_vcpu_thread(struct thread_object *obj) +{ + (void)obj; +} + +void arch_reset_vcpu(struct acrn_vcpu *vcpu) +{ + (void)vcpu; +} + +void arch_context_switch_out(struct thread_object *prev) +{ + (void)prev; +} + +void arch_context_switch_in(struct thread_object *next) +{ + (void)next; +} + +uint64_t arch_build_stack_frame(struct acrn_vcpu *vcpu) +{ + (void)vcpu; + return 0; +} diff --git a/hypervisor/arch/riscv/guest/vm.c b/hypervisor/arch/riscv/guest/vm.c index b9cad6a2d..115a3a2f7 100644 --- a/hypervisor/arch/riscv/guest/vm.c +++ b/hypervisor/arch/riscv/guest/vm.c @@ -4,13 +4,33 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef RISCV_VM_C_ -#define RISCV_VM_C_ +#include +#include +#include +int32_t arch_init_vm(struct acrn_vm *vm, struct acrn_vm_config *vm_config) +{ + (void)vm; + (void)vm_config; + return 0; +} -#include +int32_t arch_deinit_vm(struct acrn_vm *vm) +{ + (void)vm; + return 0; +} + +int32_t arch_reset_vm(struct acrn_vm *vm) +{ + (void)vm; + return 0; +} + +void arch_vm_prepare_bsp(struct acrn_vcpu *vcpu) +{ + (void)vcpu; +} void arch_trigger_level_intr(__unused struct acrn_vm *vm, __unused uint32_t irq, __unused bool assert) {} - -#endif /* RISCV_VM_C_ */ diff --git a/hypervisor/include/arch/riscv/asm/guest/vcpu.h b/hypervisor/include/arch/riscv/asm/guest/vcpu.h index 6b5aceb7b..d26b84a83 100644 --- a/hypervisor/include/arch/riscv/asm/guest/vcpu.h +++ b/hypervisor/include/arch/riscv/asm/guest/vcpu.h @@ -7,11 +7,14 @@ #ifndef RISCV_VCPU_H #define RISCV_VCPU_H +#include +#include -#include -#include +#ifndef ASSEMBLER struct acrn_vcpu_arch { -}; +} __aligned(PAGE_SIZE); + +#endif /* ASSEMBLER */ #endif /* RISCV_VCPU_H */ diff --git a/hypervisor/include/arch/riscv/asm/guest/vm.h b/hypervisor/include/arch/riscv/asm/guest/vm.h index 5d5d19798..85c485a8c 100644 --- a/hypervisor/include/arch/riscv/asm/guest/vm.h +++ b/hypervisor/include/arch/riscv/asm/guest/vm.h @@ -7,15 +7,15 @@ #ifndef RISCV_VM_H_ #define RISCV_VM_H_ - #include #include #define INVALID_PIO_IDX -1U #define UART_PIO_IDX0 INVALID_PIO_IDX +/* FIXME: dummy. to be implemented later */ +#define EMUL_PIO_IDX_MAX 1U struct vm_arch { - }; #endif /* RISCV_VM_H_ */ diff --git a/hypervisor/arch/riscv/guest/dummy_guest.c b/hypervisor/include/arch/riscv/asm/pci_dev.h similarity index 100% rename from hypervisor/arch/riscv/guest/dummy_guest.c rename to hypervisor/include/arch/riscv/asm/pci_dev.h