csr: use external csr_readl()/csr_writel() if present
If the variable CSR_ACCESSORS_DEFINED is set, then use external csr_readl() and csr_writel() instead of locally-generated inline functions. With this patch, csr.h can be used with etherbone.h and litex_server to prototype drivers remotely. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
9a252e367c
commit
6f25a0d8a1
|
@ -147,7 +147,16 @@ def get_csr_header(regions, constants, with_access_functions=True, with_shadow_b
|
||||||
r = "#ifndef __GENERATED_CSR_H\n#define __GENERATED_CSR_H\n"
|
r = "#ifndef __GENERATED_CSR_H\n#define __GENERATED_CSR_H\n"
|
||||||
if with_access_functions:
|
if with_access_functions:
|
||||||
r += "#include <stdint.h>\n"
|
r += "#include <stdint.h>\n"
|
||||||
|
r += "#ifdef CSR_ACCESSORS_DEFINED\n"
|
||||||
|
r += "extern void csr_writeb(uint8_t value, uint32_t addr);\n"
|
||||||
|
r += "extern uint8_t csr_readb(uint32_t addr);\n"
|
||||||
|
r += "extern void csr_writew(uint16_t value, uint32_t addr);\n"
|
||||||
|
r += "extern uint16_t csr_readw(uint32_t addr);\n"
|
||||||
|
r += "extern void csr_writel(uint32_t value, uint32_t addr);\n"
|
||||||
|
r += "extern uint32_t csr_readl(uint32_t addr);\n"
|
||||||
|
r += "#else /* ! CSR_ACCESSORS_DEFINED */\n"
|
||||||
r += "#include <hw/common.h>\n"
|
r += "#include <hw/common.h>\n"
|
||||||
|
r += "#endif /* ! CSR_ACCESSORS_DEFINED */\n"
|
||||||
for name, origin, busword, obj in regions:
|
for name, origin, busword, obj in regions:
|
||||||
if not with_shadow_base:
|
if not with_shadow_base:
|
||||||
origin &= (~shadow_base)
|
origin &= (~shadow_base)
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* To overwrite CSR accessors, define extern, non-inlined versions
|
||||||
|
* of csr_read[bwl]() and csr_write[bwl](), and define
|
||||||
|
* CSR_ACCESSORS_DEFINED.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CSR_ACCESSORS_DEFINED
|
||||||
|
#define CSR_ACCESSORS_DEFINED
|
||||||
|
|
||||||
#ifdef __ASSEMBLER__
|
#ifdef __ASSEMBLER__
|
||||||
#define MMPTR(x) x
|
#define MMPTR(x) x
|
||||||
#else /* ! __ASSEMBLER__ */
|
#else /* ! __ASSEMBLER__ */
|
||||||
|
@ -39,4 +47,6 @@ static inline uint32_t csr_readl(uint32_t addr)
|
||||||
}
|
}
|
||||||
#endif /* ! __ASSEMBLER__ */
|
#endif /* ! __ASSEMBLER__ */
|
||||||
|
|
||||||
|
#endif /* ! CSR_ACCESSORS_DEFINED */
|
||||||
|
|
||||||
#endif /* __HW_COMMON_H */
|
#endif /* __HW_COMMON_H */
|
||||||
|
|
Loading…
Reference in New Issue