csr: Fix definition(s) of CSR_BASE in generated headers
CSR_BASE is currently defined twice. Once in mem.h as the base of the CSR region in the SoC address space, and once in csr.h as the base address for all CSRs. This fixes two issues with those definitions: - The mem.h one is unconditional which prevents an external redefinition (which is useful under some circumstances such as when using an address decoder outside of LiteX with a standalone core). - The csr.h one is actually the origin of the first CSR region rather than the origin of the CSR region in the SoC space. They are usually the same ... unless you don't have CSR bank 0 in which case the csr.h one becomes different. This causes conflicts with the mem.h definition and breaks projects using a standalone cores. The first one is fixed by adding the #ifndef/#endif around the definition of the memory regions, the second one by passing the csr_base to use to get_csr_header() Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
f8bb500a43
commit
c78caeb998
|
@ -136,8 +136,11 @@ class Builder:
|
|||
export.get_soc_header(self.soc.constants))
|
||||
write_to_file(
|
||||
os.path.join(self.generated_dir, "csr.h"),
|
||||
export.get_csr_header(self.soc.csr_regions,
|
||||
self.soc.constants)
|
||||
export.get_csr_header(
|
||||
regions = self.soc.csr_regions,
|
||||
constants = self.soc.constants,
|
||||
csr_base = self.soc.mem_regions['csr'].origin
|
||||
)
|
||||
)
|
||||
write_to_file(
|
||||
os.path.join(self.generated_dir, "git.h"),
|
||||
|
|
|
@ -118,8 +118,10 @@ def get_mem_header(regions):
|
|||
r = generated_banner("//")
|
||||
r += "#ifndef __GENERATED_MEM_H\n#define __GENERATED_MEM_H\n\n"
|
||||
for name, region in regions.items():
|
||||
r += "#ifndef {name}\n".format(name=name.upper())
|
||||
r += "#define {name}_BASE 0x{base:08x}L\n#define {name}_SIZE 0x{size:08x}\n\n".format(
|
||||
name=name.upper(), base=region.origin, size=region.length)
|
||||
r += "#endif\n"
|
||||
r += "#endif\n"
|
||||
return r
|
||||
|
||||
|
|
Loading…
Reference in New Issue