Add a copy of DEMCR to Cortex-M private data to preserve over 'run'.
This commit is contained in:
parent
7be4866239
commit
9137c2d058
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||
* Copyright (C) 2012 Black Sphere Technologies Ltd.
|
||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -217,6 +217,8 @@ struct cortexm_priv {
|
|||
/* Breakpoint unit status */
|
||||
uint32_t hw_breakpoint[CORTEXM_MAX_BREAKPOINTS];
|
||||
unsigned hw_breakpoint_max;
|
||||
/* Copy of DEMCR for vector-catch */
|
||||
uint32_t demcr;
|
||||
};
|
||||
|
||||
/* Register number tables */
|
||||
|
@ -346,9 +348,14 @@ cortexm_probe(struct target_s *target)
|
|||
target->tdesc = tdesc_cortex_mf;
|
||||
}
|
||||
|
||||
ap->priv = calloc(1, sizeof(struct cortexm_priv));
|
||||
struct cortexm_priv *priv = calloc(1, sizeof(*priv));
|
||||
ap->priv = priv;
|
||||
ap->priv_free = free;
|
||||
|
||||
/* Default vectors to catch */
|
||||
priv->demcr = CORTEXM_DEMCR_TRCENA | CORTEXM_DEMCR_VC_HARDERR |
|
||||
CORTEXM_DEMCR_VC_CORERESET;
|
||||
|
||||
#define PROBE(x) \
|
||||
do { if (!(x)(target)) return 0; else target_check_error(target); } while (0)
|
||||
|
||||
|
@ -378,9 +385,7 @@ cortexm_attach(struct target_s *target)
|
|||
while(!target_halt_wait(target));
|
||||
|
||||
/* Request halt on reset */
|
||||
adiv5_ap_mem_write(ap, CORTEXM_DEMCR,
|
||||
CORTEXM_DEMCR_TRCENA | CORTEXM_DEMCR_VC_HARDERR |
|
||||
CORTEXM_DEMCR_VC_CORERESET);
|
||||
adiv5_ap_mem_write(ap, CORTEXM_DEMCR, priv->demcr);
|
||||
|
||||
/* Reset DFSR flags */
|
||||
adiv5_ap_mem_write(ap, CORTEXM_DFSR, CORTEXM_DFSR_RESETALL);
|
||||
|
@ -807,9 +812,9 @@ cortexm_check_hw_wp(struct target_s *target, uint32_t *addr)
|
|||
static bool cortexm_vector_catch(target *t, int argc, char *argv[])
|
||||
{
|
||||
ADIv5_AP_t *ap = adiv5_target_ap(t);
|
||||
struct cortexm_priv *priv = ap->priv;
|
||||
const char *vectors[] = {"reset", NULL, NULL, NULL, "mm", "nocp",
|
||||
"chk", "stat", "bus", "int", "hard"};
|
||||
uint32_t demcr = adiv5_ap_mem_read(ap, CORTEXM_DEMCR);
|
||||
uint32_t tmp = 0;
|
||||
unsigned i, j;
|
||||
|
||||
|
@ -824,18 +829,18 @@ static bool cortexm_vector_catch(target *t, int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (argv[1][0] == 'e')
|
||||
demcr |= tmp;
|
||||
priv->demcr |= tmp;
|
||||
else
|
||||
demcr &= ~tmp;
|
||||
priv->demcr &= ~tmp;
|
||||
|
||||
adiv5_ap_mem_write(ap, CORTEXM_DEMCR, demcr);
|
||||
adiv5_ap_mem_write(ap, CORTEXM_DEMCR, priv->demcr);
|
||||
}
|
||||
|
||||
gdb_out("Catching vectors: ");
|
||||
for (i = 0; i < sizeof(vectors) / sizeof(char*); i++) {
|
||||
if (!vectors[i])
|
||||
continue;
|
||||
if (demcr & (1 << i))
|
||||
if (priv->demcr & (1 << i))
|
||||
gdb_outf("%s ", vectors[i]);
|
||||
}
|
||||
gdb_out("\n");
|
||||
|
|
Loading…
Reference in New Issue