Skip to content

Commit 9ad59e5

Browse files
committed
ref(mem): change hyp mem management to cope with non-unified plats
Refactored slightly the root pool bitmap base to improve clarity of code Removed the passing of load_addr as argument since it can be defined as a global variable in each arch boot file. Signed-off-by: Daniel Oliveira <[email protected]>
1 parent 9418b9c commit 9ad59e5

File tree

12 files changed

+152
-52
lines changed

12 files changed

+152
-52
lines changed

src/arch/armv8/aarch32/boot.S

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
*/
2424
_barrier: .4byte 0
2525

26+
.balign 4
27+
.global img_addr
28+
img_addr: .4byte 0
29+
2630
/**
2731
* The following code MUST be at the base of the image, as this is bao's entry point. Therefore
2832
* .boot section must also be the first in the linker script. DO NOT implement any code before the
@@ -54,6 +58,8 @@ _reset_handler:
5458
* Get base image load address.
5559
*/
5660
adr r1, _el2_entry
61+
ldr r3, =img_addr
62+
str r1, [r3] // store image load address in img_addr
5763

5864
/**
5965
* Linearize cpu id according to the number of clusters and processors per cluster. We are only
@@ -227,4 +233,3 @@ set_loop:
227233
cmp r5, r3 // last way reached yet?
228234
ble way_loop // if not, iterate way_loop
229235
bx lr
230-

src/arch/armv8/aarch64/boot.S

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
.global _boot_barrier
1818
_boot_barrier: .8byte 0
1919

20+
.balign 8
21+
.global img_addr
22+
img_addr: .8byte 0
23+
2024
/**
2125
* The following code MUST be at the base of the image, as this is bao's entry point. Therefore
2226
* .boot section must also be the first in the linker script. DO NOT implement any code before the
@@ -48,6 +52,9 @@ _reset_handler:
4852
mrs x0, MPIDR_EL1
4953
adrp x1, _image_start
5054

55+
ldr x2, =img_addr
56+
str x1, [x2] // store image load address in img_addr
57+
5158
/*
5259
* Install vector table physical address early, in case exception occurs during this
5360
* initialization.
@@ -221,4 +228,3 @@ set_loop:
221228
cmp x5, x3 // last way reached yet?
222229
ble way_loop // if not, iterate way_loop
223230
ret
224-

src/arch/riscv/boot.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ _extra_allocated_phys_mem_sym: .8byte extra_allocated_phys_mem
7171
*/
7272
_barrier: .8byte 0
7373

74+
.balign 4
75+
.global img_addr
76+
img_addr: .8byte 0
77+
7478
/**
7579
* The following code MUST be at the base of the image, as this is bao's entrypoint. Therefore
7680
* .boot section must also be the first in the linker script. DO NOT implement any code before the
@@ -97,6 +101,10 @@ _reset_handler:
97101

98102
mv a2, a1
99103
la a1, _image_start
104+
105+
LD_SYM a3, img_addr
106+
STORE a1, 0(a3) // store image load address in img_addr
107+
100108
LD_SYM s6, _extra_allocated_phys_mem_sym
101109

102110
/**

src/core/config.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@
55

66
#include <config.h>
77

8-
static void config_adjust_vm_image_addr(paddr_t load_addr)
8+
static void config_adjust_vm_image_addr(void)
99
{
1010
for (size_t i = 0; i < config.vmlist_size; i++) {
1111
struct vm_config* vm_config = &config.vmlist[i];
1212
if (!vm_config->image.separately_loaded) {
13-
vm_config->image.load_addr = (vm_config->image.load_addr - BAO_VAS_BASE) + load_addr;
13+
vm_config->image.load_addr = (vm_config->image.load_addr - BAO_VAS_BASE) + img_addr;
1414
}
1515
}
1616
}
1717

18-
__attribute__((weak)) void config_mem_prot_init(paddr_t load_addr)
19-
{
20-
UNUSED_ARG(load_addr);
21-
}
18+
__attribute__((weak)) void config_mem_prot_init(void) { }
2219

23-
void config_init(paddr_t load_addr)
20+
void config_init(void)
2421
{
25-
config_adjust_vm_image_addr(load_addr);
26-
config_mem_prot_init(load_addr);
22+
config_adjust_vm_image_addr();
23+
config_mem_prot_init();
2724
}

src/core/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ static size_t ipi_cpumsg_handler_num;
3131

3232
struct cpuif cpu_interfaces[PLAT_CPU_NUM];
3333

34-
void cpu_init(cpuid_t cpu_id, paddr_t load_addr)
34+
void cpu_init(cpuid_t cpu_id)
3535
{
3636
cpu()->id = cpu_id;
3737
cpu()->handling_msgs = false;
3838
cpu()->interface = cpu_if(cpu()->id);
3939

40-
cpu_arch_init(cpu_id, load_addr);
40+
cpu_arch_init(cpu_id, img_addr);
4141

4242
list_init(&cpu()->interface->event_list);
4343

src/core/inc/bao.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
console_printk("BAO ERROR: " __VA_ARGS__); \
2323
while (true) { };
2424

25-
void init(cpuid_t cpu_id, paddr_t load_addr);
25+
void init(cpuid_t cpu_id);
26+
27+
/* The address where the Bao image is loaded in memory */
28+
extern const uintptr_t img_addr;
29+
/* The address where the data section is loaded in memory */
30+
extern const uintptr_t data_addr;
2631

2732
#endif /* __ASSEMBLER__ */
2833

src/core/inc/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ extern struct config {
126126

127127
} config;
128128

129-
void config_init(paddr_t load_addr);
130-
void config_mem_prot_init(paddr_t load_addr);
129+
void config_init(void);
130+
void config_mem_prot_init(void);
131131

132132
#endif /* __CONFIG_H__ */

src/core/inc/cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct cpu_synctoken {
6262

6363
extern struct cpu_synctoken cpu_glb_sync;
6464

65-
void cpu_init(cpuid_t cpu_id, paddr_t load_addr);
65+
void cpu_init(cpuid_t cpu_id);
6666
void cpu_send_msg(cpuid_t cpu, struct cpu_msg* msg);
6767
bool cpu_get_msg(struct cpu_msg* msg);
6868
void cpu_msg_handler(void);

src/core/inc/mem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static inline bool all_clrs(colormap_t clrs)
6767
return (masked_colors == 0) || (masked_colors == mask);
6868
}
6969

70-
void mem_init(paddr_t load_addr);
70+
void mem_init(void);
7171
void* mem_alloc_page(size_t num_pages, enum AS_SEC sec, bool phys_aligned);
7272
struct ppages mem_alloc_ppages(colormap_t colors, size_t num_pages, bool aligned);
7373
vaddr_t mem_alloc_map(struct addr_space* as, enum AS_SEC section, struct ppages* page, vaddr_t at,

src/core/init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
#include <platform.h>
1414
#include <vmm.h>
1515

16-
void init(cpuid_t cpu_id, paddr_t load_addr)
16+
void init(cpuid_t cpu_id)
1717
{
1818
/**
1919
* These initializations must be executed first and in fixed order.
2020
*/
2121

22-
cpu_init(cpu_id, load_addr);
23-
mem_init(load_addr);
22+
cpu_init(cpu_id);
23+
mem_init();
2424

2525
/* -------------------------------------------------------------- */
2626

0 commit comments

Comments
 (0)