diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index 3b8916507..e2fabb35d 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -121,16 +121,27 @@ def get_mem_header(regions): r = generated_banner("//") r += "#ifndef __GENERATED_MEM_H\n#define __GENERATED_MEM_H\n\n" for name, region in regions.items(): - r += "#ifndef {name}\n".format(name=name.upper()) - r += "#define {name}_BASE 0x{base:08x}L\n#define {name}_SIZE 0x{size:08x}\n\n".format( + r += "#ifndef {name}_BASE\n".format(name=name.upper()) + r += "#define {name}_BASE 0x{base:08x}L\n#define {name}_SIZE 0x{size:08x}\n".format( name=name.upper(), base=region.origin, size=region.length) - r += "#endif\n" + r += "#endif\n\n" + + r += "#ifndef MEM_REGIONS\n" + r += "#define MEM_REGIONS \""; + for name, region in regions.items(): + r += f"{name.upper()} {' '*(8-len(name))} 0x{region.origin:08x} 0x{region.size:x} \\n" + r = r[:-2] + r += "\"\n" + r += "#endif\n" + r += "#endif\n" return r def get_soc_header(constants, with_access_functions=True): r = generated_banner("//") r += "#ifndef __GENERATED_SOC_H\n#define __GENERATED_SOC_H\n" + + for name, value in constants.items(): if value is None: r += "#define "+name+"\n" diff --git a/litex/soc/software/bios/cmds/cmd_mem.c b/litex/soc/software/bios/cmds/cmd_mem.c index d434c42d2..cb01a3926 100644 --- a/litex/soc/software/bios/cmds/cmd_mem.c +++ b/litex/soc/software/bios/cmds/cmd_mem.c @@ -5,10 +5,25 @@ #include #include +#include #include "../command.h" #include "../helpers.h" +/** + * Command "mem_list" + * + * Memory list + * + */ +static void mem_list_handler(int nb_params, char **params) +{ + printf("Available memory regions:\n"); + puts(MEM_REGIONS); +} + +define_command(mem_list, mem_list_handler, "List available memory regions", MEM_CMDS); + /** * Command "mem_read" *