From e42f33ede1025438a175321d4e8cb9a372397070 Mon Sep 17 00:00:00 2001 From: "Gabriel L. Somlo" Date: Mon, 8 Jul 2019 09:43:40 -0400 Subject: [PATCH] soc_core: additional csr_alignment follow-up fixes - Update a few additional places to use DFII_ADDR_SHIFT instead of a hard-coded 4, which assumed 32-bit alignment. - Force 64-bit alignment Rocket -- the only supported configuration! This is a fixup for commit f4770219, tested on Rocket and 64bit Linux. Signed-off-by: Gabriel Somlo --- litex/soc/integration/soc_core.py | 5 ++++- litex/soc/software/bios/sdram.c | 2 +- litex/soc/software/libbase/id.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/litex/soc/integration/soc_core.py b/litex/soc/integration/soc_core.py index 00de250f..6f5b3cf7 100644 --- a/litex/soc/integration/soc_core.py +++ b/litex/soc/integration/soc_core.py @@ -186,11 +186,14 @@ class SoCCore(Module): # Parameters managment --------------------------------------------------------------------- - # FIXME: RocketChip reserves the first 256Mbytes for internal use, change default mem_map + # NOTE: RocketChip reserves the first 256Mbytes for internal use, + # so we must change default mem_map; + # Also, CSRs *must* be 64-bit aligned. if cpu_type == "rocket": self.soc_mem_map["rom"] = 0x10000000 self.soc_mem_map["sram"] = 0x11000000 self.soc_mem_map["csr"] = 0x12000000 + csr_alignment = 64 if cpu_type == "None": cpu_type = None diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index 5cb4929d..0af3e4fc 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -536,7 +536,7 @@ static void read_level(int module) /* Write test pattern */ for(p=0;p #include +#define DFII_ADDR_SHIFT CONFIG_CSR_ALIGNMENT/8 void get_ident(char *ident) { #ifdef CSR_IDENTIFIER_MEM_BASE int i; for(i=0;i<256;i++) - ident[i] = MMPTR(CSR_IDENTIFIER_MEM_BASE + 4*i); + ident[i] = MMPTR(CSR_IDENTIFIER_MEM_BASE + DFII_ADDR_SHIFT*i); #else ident[0] = 0; #endif -- 2.30.2