@@ -44,7 +44,7 @@ def get_mem_header(regions, flash_boot_address):
44
44
return r
45
45
46
46
47
- def get_mem_rust (regions , flash_boot_address ):
47
+ def get_mem_rust (regions , groups , flash_boot_address ):
48
48
r = "// Include this file as:\n "
49
49
r += "// include!(concat!(env!(\" BUILDINC_DIRECTORY\" ), \" /generated/mem.rs\" ));\n "
50
50
r += "#[allow(dead_code)]\n "
@@ -54,9 +54,27 @@ def get_mem_rust(regions, flash_boot_address):
54
54
format (name = name .upper (), base = base )
55
55
r += " pub const {name}_SIZE: usize = 0x{size:08x};\n \n " . \
56
56
format (name = name .upper (), size = size )
57
+
58
+ if groups :
59
+ r += " pub struct MemoryRegion {\n "
60
+ r += " pub base: usize,\n "
61
+ r += " pub size: usize,\n "
62
+ r += " }\n \n "
63
+
64
+ for group_name , group_members in groups :
65
+ r += (" pub static " + group_name .upper () +
66
+ ": [MemoryRegion; " + str (len (group_members )) + "] = [\n " )
67
+ for member in group_members :
68
+ r += " MemoryRegion { "
69
+ r += "base: " + member .upper ()+ "_BASE, "
70
+ r += "size: " + member .upper ()+ "_SIZE, "
71
+ r += "},\n "
72
+ r += " ];\n \n "
73
+
57
74
if flash_boot_address is not None :
58
75
r += " pub const FLASH_BOOT_ADDRESS: usize = 0x{:08x};\n \n " . \
59
76
format (flash_boot_address )
77
+
60
78
r += "}\n "
61
79
return r
62
80
@@ -229,7 +247,7 @@ def get_csr_rust(regions, groups, constants):
229
247
r += " pub " + csr .name + "_read: fn() -> " + rstype + ",\n "
230
248
if not is_readonly (csr ):
231
249
r += " pub " + csr .name + "_write: fn(" + rstype + "),\n " ;
232
- r += " }; \n \n "
250
+ r += " }\n \n "
233
251
234
252
r += (" pub static " + group_name .upper () +
235
253
": [" + struct_name + "; " + str (len (group_members )) + "] = [\n " )
0 commit comments