Skip to content

Commit

Permalink
vm_arm: inline memory initializtion module
Browse files Browse the repository at this point in the history
- inline code from the module to simplify VMM. Rationale is that most
  VM will have this kind of fixed memory, so there is no gain if this
  is a module
- support make this kind of memory optional, don't even create a DTB
  node if size is 0
- improve comments

Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed Mar 10, 2023
1 parent a0e54ed commit 90cd0d1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
1 change: 0 additions & 1 deletion arm_vm_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function(DeclareCAmkESARMVM init_component)
)

list(APPEND vm_src ${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/modules/map_frame_hack.c)
list(APPEND vm_src ${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/modules/init_ram.c)

if(VmVirtUart)
list(APPEND vm_src ${ARM_VM_PROJECT_DIR}/components/VM_Arm/src/modules/vuart_init.c)
Expand Down
27 changes: 23 additions & 4 deletions components/VM_Arm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,26 @@ int install_vm_devices(vm_t *vm)
{
int err;

/* Install virtual devices */
if (config_set(CONFIG_VM_PCI_SUPPORT)) {
err = vm_install_vpci(vm, io_ports, pci);
assert(!err);
if (err) {
ZF_LOGE("Failed to install VPCI device");
return -1;
}
}

/* Install and initialize guest RAM. There might be no memory here, because
* this is the exclusive fixed guest memory. Modules may set up other forms
* of guest memory, e.g. memory shared with other VM and memory that is
* mapped on demand.
*/
if (ram_size > 0) {
err = vm_ram_register_at(vm, ram_base, ram_size,
vm->mem.map_one_to_one);
if (err) {
ZF_LOGE("Failed to install RAM");
return -1;
}
}

int max_vmm_modules = (int)(__stop__vmm_module - __start__vmm_module);
Expand Down Expand Up @@ -775,8 +791,11 @@ static int generate_fdt(vm_t *vm, void *fdt_ori, void *gen_fdt, int buf_size, si
return -1;
}

/* generate a memory node (ram_base and ram_size) */
err = fdt_generate_memory_node(gen_fdt, ram_base, ram_size);
/* Generate a memory node. This is done even if ram_size is zero, so there
* is a guarantee that the DTB has a memory node.
*/
err = fdt_generate_memory_node(gen_fdt, (ram_size > 0) ? ram_base : 0,
ram_size);
if (err) {
ZF_LOGE("Couldn't generate memory_node (%d)\n", err);
return -1;
Expand Down
21 changes: 0 additions & 21 deletions components/VM_Arm/src/modules/init_ram.c

This file was deleted.

0 comments on commit 90cd0d1

Please sign in to comment.