integration/export: When csr_base is specified, make CSR regions definition relative to it.

Useful for PCIe based systems when internal CSR base is automatically added by the logic.
This commit is contained in:
Florent Kermarrec 2023-07-17 11:14:17 +02:00
parent 3fc16f54f1
commit 3d101b9749
1 changed files with 4 additions and 3 deletions

View File

@ -257,13 +257,14 @@ def get_csr_header(regions, constants, csr_base=None, with_csr_base_define=True,
r += "#ifndef CSR_ACCESSORS_DEFINED\n"
r += "#include <hw/common.h>\n"
r += "#endif /* ! CSR_ACCESSORS_DEFINED */\n"
csr_base = csr_base if csr_base is not None else regions[next(iter(regions))].origin
_csr_base = regions[next(iter(regions))].origin
csr_base = csr_base if csr_base is not None else _csr_base
if with_csr_base_define:
r += "#ifndef CSR_BASE\n"
r += "\n#ifndef CSR_BASE\n"
r += f"#define CSR_BASE {hex(csr_base)}L\n"
r += "#endif\n"
for name, region in regions.items():
origin = region.origin - csr_base
origin = region.origin - _csr_base
r += "\n/* "+name+" */\n"
r += f"#define CSR_{name.upper()}_BASE {_get_csr_addr(csr_base, origin, with_csr_base_define)}\n"
if not isinstance(region.obj, Memory):