From: Gabriel Somlo Date: Fri, 29 May 2020 15:54:10 +0000 (-0400) Subject: csr: fix simple accessor alignment X-Git-Tag: 24jan2021_ls180~261^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e1b17d459c1966dd561ad5262a7cb9299575191;p=litex.git csr: fix simple accessor alignment MMPTR should always follow CSR alignment, NOT CSR data width. (the latter merely indicates how many bits within a MMPTR are actually populated). Fixup for commit #4a5072a. Signed-off-by: Gabriel Somlo --- diff --git a/litex/soc/software/include/hw/common.h b/litex/soc/software/include/hw/common.h index 3db167dd..b976bd9e 100644 --- a/litex/soc/software/include/hw/common.h +++ b/litex/soc/software/include/hw/common.h @@ -37,12 +37,12 @@ /* CSR subregisters (a.k.a. "simple CSRs") are embedded inside native CPU-word * aligned locations: */ -#if CONFIG_CSR_DATA_WIDTH == 32 -#define MMPTR(a) (*((volatile unsigned int *)(a))) -#elif CONFIG_CSR_DATA_WIDTH == 8 -#define MMPTR(a) (*((volatile unsigned char *)(a))) +#if CONFIG_CSR_ALIGNMENT == 32 +#define MMPTR(a) (*((volatile uint32_t *)(a))) +#elif CONFIG_CSR_ALIGNMENT == 64 +#define MMPTR(a) (*((volatile uint64_t *)(a))) #else -#error Unsupported CSR data width +#error Unsupported CSR alignment #endif static inline void csr_write_simple(unsigned long v, unsigned long a)