Skip to content

Commit b6215f6

Browse files
committed
feat(mem): add image and data addresses global variables
These variables must be initialized in the boot.S of each arch. Both are global variables, therefore we removed the passing as argument of the load address throughout the internal APIs of Bao. Signed-off-by: Daniel Oliveira <[email protected]>
1 parent 0a8e82b commit b6215f6

File tree

12 files changed

+49
-39
lines changed

12 files changed

+49
-39
lines changed

src/arch/armv8/aarch32/boot.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ _reset_handler:
5454
* Get base image load address.
5555
*/
5656
adr r1, _el2_entry
57+
ldr r3, =img_addr
58+
str r1, [r3] // store image load address in img_addr
5759

5860
/**
5961
* Linearize cpu id according to the number of clusters and processors per cluster. We are only
@@ -227,4 +229,3 @@ set_loop:
227229
cmp r5, r3 // last way reached yet?
228230
ble way_loop // if not, iterate way_loop
229231
bx lr
230-

src/arch/armv8/aarch64/boot.S

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ _reset_handler:
4848
mrs x0, MPIDR_EL1
4949
adrp x1, _image_start
5050

51+
ldr x2, =img_addr
52+
str x1, [x2] // store image load address in img_addr
53+
5154
/*
5255
* Install vector table physical address early, in case exception occurs during this
5356
* initialization.
@@ -221,4 +224,3 @@ set_loop:
221224
cmp x5, x3 // last way reached yet?
222225
ble way_loop // if not, iterate way_loop
223226
ret
224-

src/arch/riscv/boot.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ _reset_handler:
9797

9898
mv a2, a1
9999
la a1, _image_start
100+
101+
LD_SYM a3, img_addr
102+
STORE a1, 0(a3) // store image load address in img_addr
103+
100104
LD_SYM s6, _extra_allocated_phys_mem_sym
101105

102106
/**

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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);
2626

2727
#endif /* __ASSEMBLER__ */
2828

src/core/inc/config.h

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

136136
} config;
137137

138-
void config_init(paddr_t load_addr);
139-
void config_mem_prot_init(paddr_t load_addr);
138+
void config_init(void);
139+
void config_mem_prot_init(void);
140140

141141
#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: 7 additions & 2 deletions
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,
@@ -95,6 +95,11 @@ bool mem_translate(struct addr_space* as, vaddr_t va, paddr_t* pa);
9595

9696
extern struct list page_pool_list;
9797

98-
#endif /* |__ASSEMBLER__ */
98+
/* The address where the Bao image is loaded in memory */
99+
extern vaddr_t img_addr;
100+
/* The address where the data section is loaded in memory */
101+
extern vaddr_t data_addr;
102+
103+
#endif /* __ASSEMBLER__ */
99104

100105
#endif /* __MEM_H__ */

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)