Skip to content

Commit 65971eb

Browse files
author
Axel Heider
committed
vm_arm: inline init_ram module
- inline code from the module to simplify VMM. - define a weak function vm_init_ram() instead. - improve comments. Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
1 parent c372ff4 commit 65971eb

3 files changed

Lines changed: 32 additions & 25 deletions

File tree

arm_vm_helpers.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ function(DeclareCAmkESARMVM init_component)
4747
${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/fdt_manipulation.c
4848
${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/crossvm.c
4949
${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/modules/map_frame_hack.c
50-
${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/modules/init_ram.c
5150
)
5251

5352
if(VmVirtUart)

components/VM_Arm/src/main.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,31 @@ static void irq_handler(void *data, ps_irq_acknowledge_fn_t acknowledge_fn, void
679679
}
680680
}
681681

682+
/* Default RAM initialization. Modules can overwrite this weak function with a
683+
* custom initialization, e.g. to use memory shared with other components or
684+
* mapped on demand.
685+
*/
686+
WEAK int vm_init_ram(vm_t *vm, const vm_config_t *vm_config)
687+
{
688+
/* A VM without RAM is highly unusual and unlikely to work. But there might
689+
* be special VM configurations where modules create specific RAM areas. In
690+
* this case, this weak RAM init function here should be overwritten also,
691+
* that's why we print the warning.
692+
*/
693+
if (0 == vm_config->ram.size) {
694+
ZF_LOGW("no standard RAM defined");
695+
return 0;
696+
}
697+
698+
int err = vm_ram_register_at(vm, vm_config->ram.base, vm_config->ram.size,
699+
vm->mem.map_one_to_one);
700+
if (err) {
701+
ZF_LOGE("RAM registration failed (%d)", err);
702+
return -1;
703+
}
704+
705+
return 0;
706+
}
682707

683708
/* Force the _vmm_module section to be created even if no modules are defined. */
684709
static USED SECTION("_vmm_module") struct {} dummy_module;
@@ -689,6 +714,13 @@ static int install_vm_devices(vm_t *vm, const vm_config_t *vm_config)
689714
{
690715
int err;
691716

717+
/* Initialize guest RAM. */
718+
err = vm_init_ram(vm, vm_config);
719+
if (err) {
720+
ZF_LOGE("Failed to initialize RAM (%d)", err);
721+
return -1;
722+
}
723+
692724
/* Install virtual devices */
693725
if (config_set(CONFIG_VM_PCI_SUPPORT)) {
694726
err = vm_install_vpci(vm, io_ports, pci);

components/VM_Arm/src/modules/init_ram.c

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)