mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software/bios: add new mem_list command to list available memory regions.
This is useful to know the memory regions available and use the mem_xy commands on them: List the memory regions: litex> mem_list Available memory regions: ROM 0x00000000 0x8000 SRAM 0x01000000 0x2000 MAIN_RAM 0x40000000 0x10000000 CSR 0x82000000 0x10000 Test 0x1000 bytes of MAIN_RAM: litex> mem_test 0x40000000 0x1000 Memtest at 0x40000000 (4KiB)... Write: 0x40000000-0x40001000 4KiB Read: 0x40000000-0x40001000 4KiB Memtest OK Test speed on 0x1000 bytes of MAIN_RAM: litex> mem_speed 0x40000000 0x1000 Memspeed at 0x40000000 (4KiB)... Write speed: 352KiB/s Read speed: 288KiB/s
This commit is contained in:
parent
b3a0b4b60d
commit
1a338b602a
2 changed files with 29 additions and 3 deletions
|
@ -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"
|
||||
|
|
|
@ -5,10 +5,25 @@
|
|||
#include <memtest.h>
|
||||
|
||||
#include <generated/csr.h>
|
||||
#include <generated/mem.h>
|
||||
|
||||
#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"
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue