Skip to content

Commit 76a565e

Browse files
committed
feat(scripts): generate data memory derived macros
Signed-off-by: Daniel Oliveira <[email protected]>
1 parent 1b55188 commit 76a565e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

scripts/config_defs_gen.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ int main() {
3636
printf("#define CONFIG_HYP_BASE_ADDR PLAT_BASE_ADDR\n");
3737
}
3838

39+
if(config.hyp.data_relocate) {
40+
printf("#define CONFIG_HYP_DATA_ADDR (0x%lx)\n", config.hyp.data_addr);
41+
} else {
42+
printf("#define CONFIG_HYP_DATA_ADDR PLAT_DATA_ADDR\n");
43+
}
44+
3945
printf("#define CONFIG_REMIO_DEV_NUM %ld\n", remio_dev_num());
4046

4147
return 0;

scripts/platform_defs_gen.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ int main() {
1818
printf("#define PLAT_CPU_NUM (%ld)\n", platform.cpu_num);
1919
printf("#define PLAT_BASE_ADDR (0x%lx)\n", platform.regions[0].base);
2020

21+
for(size_t i = 1; i < platform.region_num; i++)
22+
{
23+
/*
24+
* Selects the first memory region with RWX (read, write, execute) permissions, and defines
25+
* it as PLAT_DATA_ADDR. This region is considered the main data memory that Bao will use
26+
* for its own purposes.
27+
*/
28+
if(platform.regions[i].perms == MEM_RWX)
29+
{
30+
printf("#define PLAT_DATA_ADDR (0x%lx)\n", platform.regions[i].base);
31+
break;
32+
}
33+
}
34+
2135
for(size_t i = 0; i < platform.region_num; i++)
2236
{
2337
size_t reg_size;

src/core/inc/config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ extern struct config {
110110
bool relocate;
111111
paddr_t base_addr;
112112

113+
/**
114+
* Only meaningful for non-unified platforms. In such platforms, the hypervisor expects a
115+
* base address for data memory and will default to the first RWX region defined in the
116+
* target platform's description. If the user wishes to relocate it to another address,
117+
* they must set data_relocate to true and provide the new base address.
118+
*/
119+
bool data_relocate;
120+
paddr_t data_addr;
121+
113122
/* Hypervisor colors */
114123
colormap_t colors;
115124
} hyp;

0 commit comments

Comments
 (0)