From: Gabriel Somlo Date: Thu, 6 Feb 2020 23:30:22 +0000 (-0500) Subject: Add 'volatile' qualifier to new CSR accessors X-Git-Tag: 24jan2021_ls180~645^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=173117ad4b7c84d6f591bf7a4f916301c7dc1d06;p=litex.git Add 'volatile' qualifier to new CSR accessors Through their use of the MMPTR() macro, the "classic" csr_[read|write]simple() accsessors identify the MMIO subregister with the 'volatile' qualifier. Adjust the new, csr_[rd|wr]_uint[8|16|32|64]() accessors to also utilize the 'volatile' qualifier. Since accesses are implicit (a[i], where a is an 'unsigned long *'), change 'a' to be a 'volatile unsigned long *' instead. No difference was noticed in opcodes generated using the gcc9 risc-v cross-compiler on x86_64 with standard LiteX cflags (vexriscv and rocket were tested), but since reports exist that 'volatile' matters on some combinations of compilers and targets, add the 'volatile' qualifier just to be on the safe side. Signed-off-by: Gabriel Somlo = CSR_DW_BYTES) { \ /* one or more subregisters per element */ \ @@ -176,7 +176,7 @@ static inline void csr_wr_uint64(uint64_t v, unsigned long a) #define _csr_wr_buf(a, buf, cnt) \ { \ int i, j, nsubs, n_sub_elem; \ - unsigned long *addr = (unsigned long *)(a); \ + volatile unsigned long *addr = (volatile unsigned long *)(a); \ uint64_t v; \ if (sizeof(buf[0]) >= CSR_DW_BYTES) { \ /* one or more subregisters per element */ \