soc/cpuif: add with_access_functions parameter
When don't necessary need access functions in our csr.h (for example with an X86 CPU)
This commit is contained in:
parent
958f149992
commit
9666629c4f
|
@ -34,7 +34,7 @@ def get_mem_header(regions, flash_boot_address):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def _get_rw_functions(reg_name, reg_base, nwords, busword, read_only):
|
def _get_rw_functions(reg_name, reg_base, nwords, busword, read_only, with_access_functions):
|
||||||
r = ""
|
r = ""
|
||||||
|
|
||||||
r += "#define CSR_"+reg_name.upper()+"_ADDR "+hex(reg_base)+"\n"
|
r += "#define CSR_"+reg_name.upper()+"_ADDR "+hex(reg_base)+"\n"
|
||||||
|
@ -52,6 +52,7 @@ def _get_rw_functions(reg_name, reg_base, nwords, busword, read_only):
|
||||||
else:
|
else:
|
||||||
ctype = "unsigned char"
|
ctype = "unsigned char"
|
||||||
|
|
||||||
|
if with_access_functions:
|
||||||
r += "static inline "+ctype+" "+reg_name+"_read(void) {\n"
|
r += "static inline "+ctype+" "+reg_name+"_read(void) {\n"
|
||||||
if size > 1:
|
if size > 1:
|
||||||
r += "\t"+ctype+" r = MMPTR("+hex(reg_base)+");\n"
|
r += "\t"+ctype+" r = MMPTR("+hex(reg_base)+");\n"
|
||||||
|
@ -74,8 +75,10 @@ def _get_rw_functions(reg_name, reg_base, nwords, busword, read_only):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def get_csr_header(regions, constants):
|
def get_csr_header(regions, constants, with_access_functions=True):
|
||||||
r = "#ifndef __GENERATED_CSR_H\n#define __GENERATED_CSR_H\n#include <hw/common.h>\n"
|
r = "#ifndef __GENERATED_CSR_H\n#define __GENERATED_CSR_H\n"
|
||||||
|
if with_access_functions:
|
||||||
|
r += "#include <hw/common.h>\n"
|
||||||
for name, origin, busword, obj in regions:
|
for name, origin, busword, obj in regions:
|
||||||
if isinstance(obj, Memory):
|
if isinstance(obj, Memory):
|
||||||
r += "#define CSR_"+name.upper()+"_BASE "+hex(origin)+"\n"
|
r += "#define CSR_"+name.upper()+"_BASE "+hex(origin)+"\n"
|
||||||
|
@ -84,7 +87,7 @@ def get_csr_header(regions, constants):
|
||||||
r += "#define CSR_"+name.upper()+"_BASE "+hex(origin)+"\n"
|
r += "#define CSR_"+name.upper()+"_BASE "+hex(origin)+"\n"
|
||||||
for csr in obj:
|
for csr in obj:
|
||||||
nr = (csr.size + busword - 1)//busword
|
nr = (csr.size + busword - 1)//busword
|
||||||
r += _get_rw_functions(name + "_" + csr.name, origin, nr, busword, isinstance(csr, CSRStatus))
|
r += _get_rw_functions(name + "_" + csr.name, origin, nr, busword, isinstance(csr, CSRStatus), with_access_functions)
|
||||||
origin += 4*nr
|
origin += 4*nr
|
||||||
|
|
||||||
r += "\n/* constants */\n"
|
r += "\n/* constants */\n"
|
||||||
|
|
Loading…
Reference in New Issue