rp: re-grouped the target-specific commands to the bottom of the implementation

This commit is contained in:
dragonmux 2022-07-31 16:37:22 +01:00 committed by Piotr Esden-Tempski
parent ae982cae6b
commit efb2e99408
1 changed files with 35 additions and 35 deletions

View File

@ -380,21 +380,6 @@ static int rp_flash_write(struct target_flash *f, target_addr dest, const void *
return ret; return ret;
} }
static bool rp_cmd_reset_usb_boot(target *t, int argc, const char **argv)
{
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
if (argc > 2) {
ps->regs[1] = atoi(argv[2]);
} else if (argc < 3) {
ps->regs[0] = atoi(argv[1]);
} else {
ps->regs[0] = 0;
ps->regs[1] = 0;
}
rp_rom_call(t, ps->regs, ps->reset_usb_boot, 0);
return true;
}
static bool rp_mass_erase(target *t) static bool rp_mass_erase(target *t)
{ {
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage; struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
@ -404,26 +389,6 @@ static bool rp_mass_erase(target *t)
return result; return result;
} }
static bool rp_cmd_erase_sector(target *t, int argc, const char **argv)
{
uint32_t start = t->flash->start;
uint32_t length;
if (argc == 3) {
start = strtoul(argv[1], NULL, 0);
length = strtoul(argv[2], NULL, 0);
} else if (argc == 2)
length = strtoul(argv[1], NULL, 0);
else
return -1;
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
ps->is_monitor = true;
const bool result = rp_flash_erase(t->flash, start, length) == 0;
ps->is_monitor = false;
return result;
}
static void rp_ssel_active(target *t, bool active) static void rp_ssel_active(target *t, bool active)
{ {
const uint32_t qspi_ctrl_outover_low = 2UL << 8; const uint32_t qspi_ctrl_outover_low = 2UL << 8;
@ -525,6 +490,41 @@ static bool rp_attach(target *t)
return true; return true;
} }
static bool rp_cmd_erase_sector(target *t, int argc, const char **argv)
{
uint32_t start = t->flash->start;
uint32_t length;
if (argc == 3) {
start = strtoul(argv[1], NULL, 0);
length = strtoul(argv[2], NULL, 0);
} else if (argc == 2)
length = strtoul(argv[1], NULL, 0);
else
return -1;
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
ps->is_monitor = true;
const bool result = rp_flash_erase(t->flash, start, length) == 0;
ps->is_monitor = false;
return result;
}
static bool rp_cmd_reset_usb_boot(target *t, int argc, const char **argv)
{
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
if (argc > 2) {
ps->regs[1] = atoi(argv[2]);
} else if (argc < 3) {
ps->regs[0] = atoi(argv[1]);
} else {
ps->regs[0] = 0;
ps->regs[1] = 0;
}
rp_rom_call(t, ps->regs, ps->reset_usb_boot, 0);
return true;
}
static bool rp_rescue_do_reset(target *t) static bool rp_rescue_do_reset(target *t)
{ {
ADIv5_AP_t *ap = (ADIv5_AP_t *)t->priv; ADIv5_AP_t *ap = (ADIv5_AP_t *)t->priv;