diff options
author | Palmer Dabbelt <palmer@dabbelt.com> | 2017-03-24 18:21:56 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmer@dabbelt.com> | 2017-04-26 09:10:49 -0700 |
commit | 8dea2908b71dfca60e80113203c6e62806b34851 (patch) | |
tree | 7db5d55fc695a7ea855dda219020cb3e8364a39a /src/flash | |
parent | 3dc066382bebce5a86a72a095c17b1eaa58b0b89 (diff) | |
download | riscv-openocd-8dea2908b71dfca60e80113203c6e62806b34851.zip riscv-openocd-8dea2908b71dfca60e80113203c6e62806b34851.tar.gz riscv-openocd-8dea2908b71dfca60e80113203c6e62806b34851.tar.bz2 |
Add 64-bit and multihart support
This is a major rewrite of the RISC-V v0.13 OpenOCD port. This
shouldn't have any meaningful effect on the v0.11 support, but it does
add generic versions of many functions that will allow me to later
refactor the v0.11 support so it's easier to maintain both ports. This
started as an emergency feature branch and went on for a long time, so
it's all been squashed down into one commit so there isn't a big set of
broken commits lying around. The changes are:
* You can pass "-rtos riscv" to the target in OpenOCD's configuration
file, which enables multi-hart mode. This uses OpenOCD's RTOS
support to control all the harts from the debug module using commands
like "info threads" in GDB. This support is still expermental.
* There is support for RV64I, but due to OpenOCD limitations we only
support 32-bit physical addresses. I hope to remedy this by rebasing
onto the latest OpenOCD release, which I've heard should fix this.
* This matches the latest draft version of the RISC-V debug spec, as of
April 26th. This version fixes a number of spec bugs and should be
close to the final debug spec.
Diffstat (limited to 'src/flash')
-rw-r--r-- | src/flash/nor/fespi.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c index 2437bf3..1320043 100644 --- a/src/flash/nor/fespi.c +++ b/src/flash/nor/fespi.c @@ -42,6 +42,7 @@ #include <jtag/jtag.h> #include <helper/time_support.h> #include <target/algorithm.h> +#include "target/riscv/riscv.h" /* Register offsets */ @@ -121,24 +122,28 @@ #define FESPI_READ_REG(a) (_FESPI_READ_REG(a)) -#define _FESPI_READ_REG(a) \ -{ \ +#define _FESPI_READ_REG(a) \ +{ \ int __a; \ - uint32_t __v; \ - \ - __a = target_read_u32(target, ctrl_base + (a), &__v); \ - if (__a != ERROR_OK) \ + uint32_t __v; \ + \ + __a = target_read_u32(target, ctrl_base + (a), &__v); \ + if (__a != ERROR_OK) { \ + LOG_ERROR("FESPI_READ_REG error"); \ return __a; \ + } \ __v; \ } -#define FESPI_WRITE_REG(a, v) \ -{ \ +#define FESPI_WRITE_REG(a, v) \ +{ \ int __r; \ - \ - __r = target_write_u32(target, ctrl_base + (a), (v)); \ - if (__r != ERROR_OK) \ + \ + __r = target_write_u32(target, ctrl_base + (a), (v)); \ + if (__r != ERROR_OK) { \ + LOG_ERROR("FESPI_WRITE_REG error"); \ return __r; \ + } \ } #define FESPI_DISABLE_HW_MODE() FESPI_WRITE_REG(FESPI_REG_FCTRL, \ @@ -779,12 +784,13 @@ static int steps_execute(struct algorithm_steps *as, struct fespi_flash_bank *fespi_info = bank->driver_priv; uint32_t ctrl_base = fespi_info->ctrl_base; uint8_t *data_buf = malloc(data_wa->size); + int xlen = riscv_xlen(target); struct reg_param reg_params[2]; - init_reg_param(®_params[0], "x10", 32, PARAM_OUT); - init_reg_param(®_params[1], "x11", 32, PARAM_OUT); - buf_set_u32(reg_params[0].value, 0, 32, ctrl_base); - buf_set_u32(reg_params[1].value, 0, 32, data_wa->address); + init_reg_param(®_params[0], "x10", xlen, PARAM_OUT); + init_reg_param(®_params[1], "x11", xlen, PARAM_OUT); + buf_set_u64(reg_params[0].value, 0, xlen, ctrl_base); + buf_set_u64(reg_params[1].value, 0, xlen, data_wa->address); while (!as_empty(as)) { keep_alive(); unsigned bytes = as_compile(as, data_buf, data_wa->size); |