summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDietmar Eggemann <dietmar.eggemann@arm.com>2012-03-15 15:33:37 +0000
committerDietmar Eggemann <dietmar.eggemann@arm.com>2012-05-22 10:43:46 +0100
commitc34718bf4123a1007ee7e5928cd33d43ca3afa45 (patch)
tree00bbf014ee554d4825f7e71f92bb1cf09c48d643
parente04a36300f5899c1d661005d91752167005c6796 (diff)
Debug: Added support for Save & Restore of v7 Debug context
Removed dependency of debug S&R code on the APPF repository, moved the data structure to save context to context.h and added calls to save and restore the debug context. Signed-off-by: Achin Gupta <achin.gupta@arm.com> Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
-rw-r--r--acsr/v7_c.c138
-rwxr-xr-xbig-little/Makefile2
-rw-r--r--big-little/include/context.h14
-rw-r--r--big-little/switcher/context/ns_context.c5
4 files changed, 81 insertions, 78 deletions
diff --git a/acsr/v7_c.c b/acsr/v7_c.c
index c802bfc..1c23ac0 100644
--- a/acsr/v7_c.c
+++ b/acsr/v7_c.c
@@ -26,9 +26,9 @@
* but a different approach should be taken with an external debugger (cp14).
*/
-#include "appf_types.h"
-#include "appf_internals.h"
-#include "appf_helpers.h"
+#include "bakery.h"
+#include "helpers.h"
+#include "context.h"
#define DIDR_VERSION_SHIFT 16
#define DIDR_VERSION_MASK 0xF
@@ -52,71 +52,59 @@
#define OSDLR_LOCKED 0x00000001
typedef volatile struct { /* Registers Save? */
- appf_u32 const didr; /* 0 Read only */
- appf_u32 dscr_i; /* 1 ignore - use dscr_e instead */
- appf_u32 const dummy1[3]; /* 2-4 ignore */
- appf_u32 dtrrx_dtrtx_i; /* 5 ignore */
- appf_u32 wfar; /* 6 ignore - transient information */
- appf_u32 vcr; /* 7 Save */
- appf_u32 const dummy2; /* 8 ignore */
- appf_u32 ecr; /* 9 ignore */
- appf_u32 dsccr; /* 10 ignore */
- appf_u32 dsmcr; /* 11 ignore */
- appf_u32 const dummy3[20]; /* 12-31 ignore */
- appf_u32 dtrrx_e; /* 32 ignore */
- appf_u32 itr_pcsr; /* 33 ignore */
- appf_u32 dscr_e; /* 34 Save */
- appf_u32 dtrtx_e; /* 35 ignore */
- appf_u32 drcr; /* 36 ignore */
- appf_u32 eacr; /* 37 Save - V7.1 only */
- appf_u32 const dummy4[2]; /* 38-39 ignore */
- appf_u32 pcsr; /* 40 ignore */
- appf_u32 cidsr; /* 41 ignore */
- appf_u32 vidsr; /* 42 ignore */
- appf_u32 const dummy5[21]; /* 43-63 ignore */
- appf_u32 bvr[16]; /* 64-79 Save */
- appf_u32 bcr[16]; /* 80-95 Save */
- appf_u32 wvr[16]; /* 96-111 Save */
- appf_u32 wcr[16]; /* 112-127 Save */
- appf_u32 const dummy6[16]; /* 128-143 ignore */
- appf_u32 bxvr[16]; /* 144-159 Save if have Virtualization extensions */
- appf_u32 const dummy7[32]; /* 160-191 ignore */
- appf_u32 oslar; /* 192 If oslsr[0] is 1, unlock before save/restore */
- appf_u32 const oslsr; /* 193 ignore */
- appf_u32 ossrr; /* 194 ignore */
- appf_u32 const dummy8; /* 195 ignore */
- appf_u32 prcr; /* 196 ignore */
- appf_u32 prsr; /* 197 clear SPD on restore */
- appf_u32 const dummy9[762]; /* 198-959 ignore */
- appf_u32 itctrl; /* 960 ignore */
- appf_u32 const dummy10[39]; /* 961-999 ignore */
- appf_u32 claimset; /* 1000 Restore claim bits to here */
- appf_u32 claimclr; /* 1001 Save claim bits from here */
- appf_u32 const dummy11[2]; /* 1002-1003 ignore */
- appf_u32 lar; /* 1004 Unlock before restore */
- appf_u32 const lsr; /* 1005 ignore */
- appf_u32 const authstatus; /* 1006 Read only */
- appf_u32 const dummy12; /* 1007 ignore */
- appf_u32 const devid2; /* 1008 Read only */
- appf_u32 const devid1; /* 1009 Read only */
- appf_u32 const devid; /* 1010 Read only */
- appf_u32 const devtype; /* 1011 Read only */
- appf_u32 const pid[8]; /* 1012-1019 Read only */
- appf_u32 const cid[4]; /* 1020-1023 Read only */
+ unsigned const didr; /* 0 Read only */
+ unsigned dscr_i; /* 1 ignore - use dscr_e instead */
+ unsigned const dummy1[3]; /* 2-4 ignore */
+ unsigned dtrrx_dtrtx_i; /* 5 ignore */
+ unsigned wfar; /* 6 ignore - transient information */
+ unsigned vcr; /* 7 Save */
+ unsigned const dummy2; /* 8 ignore */
+ unsigned ecr; /* 9 ignore */
+ unsigned dsccr; /* 10 ignore */
+ unsigned dsmcr; /* 11 ignore */
+ unsigned const dummy3[20]; /* 12-31 ignore */
+ unsigned dtrrx_e; /* 32 ignore */
+ unsigned itr_pcsr; /* 33 ignore */
+ unsigned dscr_e; /* 34 Save */
+ unsigned dtrtx_e; /* 35 ignore */
+ unsigned drcr; /* 36 ignore */
+ unsigned eacr; /* 37 Save - V7.1 only */
+ unsigned const dummy4[2]; /* 38-39 ignore */
+ unsigned pcsr; /* 40 ignore */
+ unsigned cidsr; /* 41 ignore */
+ unsigned vidsr; /* 42 ignore */
+ unsigned const dummy5[21]; /* 43-63 ignore */
+ unsigned bvr[16]; /* 64-79 Save */
+ unsigned bcr[16]; /* 80-95 Save */
+ unsigned wvr[16]; /* 96-111 Save */
+ unsigned wcr[16]; /* 112-127 Save */
+ unsigned const dummy6[16]; /* 128-143 ignore */
+ unsigned bxvr[16]; /* 144-159 Save if have Virtualization extensions */
+ unsigned const dummy7[32]; /* 160-191 ignore */
+ unsigned oslar; /* 192 If oslsr[0] is 1, unlock before save/restore */
+ unsigned const oslsr; /* 193 ignore */
+ unsigned ossrr; /* 194 ignore */
+ unsigned const dummy8; /* 195 ignore */
+ unsigned prcr; /* 196 ignore */
+ unsigned prsr; /* 197 clear SPD on restore */
+ unsigned const dummy9[762]; /* 198-959 ignore */
+ unsigned itctrl; /* 960 ignore */
+ unsigned const dummy10[39]; /* 961-999 ignore */
+ unsigned claimset; /* 1000 Restore claim bits to here */
+ unsigned claimclr; /* 1001 Save claim bits from here */
+ unsigned const dummy11[2]; /* 1002-1003 ignore */
+ unsigned lar; /* 1004 Unlock before restore */
+ unsigned const lsr; /* 1005 ignore */
+ unsigned const authstatus; /* 1006 Read only */
+ unsigned const dummy12; /* 1007 ignore */
+ unsigned const devid2; /* 1008 Read only */
+ unsigned const devid1; /* 1009 Read only */
+ unsigned const devid; /* 1010 Read only */
+ unsigned const devtype; /* 1011 Read only */
+ unsigned const pid[8]; /* 1012-1019 Read only */
+ unsigned const cid[4]; /* 1020-1023 Read only */
} debug_registers_t;
-typedef struct {
- appf_u32 vcr;
- appf_u32 dscr_e;
- appf_u32 eacr;
- appf_u32 bvr[16];
- appf_u32 bcr[16];
- appf_u32 wvr[16];
- appf_u32 wcr[16];
- appf_u32 bxvr[16];
- appf_u32 claim;
-} debug_context_t; /* total size 86 * 4 = 344 bytes */
-
debug_registers_t *read_debug_address(void)
{
unsigned drar, dsar;
@@ -140,12 +128,12 @@ debug_registers_t *read_debug_address(void)
* - OSDLR is NOT locked, or the debugger would not work properly
*/
-void save_v7_debug(appf_u32 * context)
+void save_v7_debug(unsigned * context)
{
debug_registers_t *dbg = (void *)read_debug_address();
debug_context_t *ctx = (void *)context;
unsigned v71, num_bps, num_wps, i;
- appf_u32 didr;
+ unsigned didr, virtext_present = (read_id_pfr1() >> 12) & 0xf;
if (!dbg) {
return;
@@ -174,9 +162,8 @@ void save_v7_debug(appf_u32 * context)
for (i = 0; i < num_bps; ++i) {
ctx->bvr[i] = dbg->bvr[i];
ctx->bcr[i] = dbg->bcr[i];
-#ifdef VIRTUALIZATION
- ctx->bxvr[i] = dbg->bxvr[i]; /* TODO: don't save the ones that don't exist */
-#endif
+ if (virtext_present)
+ ctx->bxvr[i] = dbg->bxvr[i];
}
num_wps = 1 + ((didr >> DIDR_WP_SHIFT) & DIDR_WP_MASK);
@@ -194,12 +181,12 @@ void save_v7_debug(appf_u32 * context)
}
}
-void restore_v7_debug(appf_u32 * context)
+void restore_v7_debug(unsigned * context)
{
debug_registers_t *dbg = (void *)read_debug_address();
debug_context_t *ctx = (void *)context;
unsigned v71, num_bps, num_wps, i;
- appf_u32 didr;
+ unsigned didr, virtext_present = (read_id_pfr1() >> 12) & 0xf;;
if (!dbg) {
return;
@@ -238,9 +225,8 @@ void restore_v7_debug(appf_u32 * context)
for (i = 0; i < num_bps; ++i) {
dbg->bvr[i] = ctx->bvr[i];
dbg->bcr[i] = ctx->bcr[i];
-#ifdef VIRTUALIZATION
- dbg->bxvr[i] = ctx->bxvr[i]; /* TODO: don't restore the ones that don't exist */
-#endif
+ if (virtext_present)
+ dbg->bxvr[i] = ctx->bxvr[i];
}
num_wps = 1 + ((didr >> DIDR_WP_SHIFT) & DIDR_WP_MASK);
diff --git a/big-little/Makefile b/big-little/Makefile
index 7c7896d..a60831b 100755
--- a/big-little/Makefile
+++ b/big-little/Makefile
@@ -61,7 +61,7 @@ vpath %.c switcher switcher/trigger switcher/context common/ lib/ secure_world
vpath %.s switcher switcher/trigger switcher/context common/ lib/ secure_world/ ../acsr
SWITCHER_OBJS = ns_context.o hyp_setup.o pagetable_setup.o virt_helpers.o sync_switchover.o \
- vgiclib.o vgic_handle.o uart.o v7.o gic.o handle_switchover.o tube.o ipi.o \
+ vgiclib.o vgic_handle.o uart.o v7.o gic.o handle_switchover.o tube.o ipi.o v7_c.o \
virt_events.o bakery.o vgic_setup.o async_switchover.o hyp_vectors.o helpers.o
SECURE_ENTRY_POINT = monmode_vector_table
diff --git a/big-little/include/context.h b/big-little/include/context.h
index 5beaa42..9742ca8 100644
--- a/big-little/include/context.h
+++ b/big-little/include/context.h
@@ -25,6 +25,18 @@
#include "misc.h"
+typedef struct {
+ unsigned vcr;
+ unsigned dscr_e;
+ unsigned eacr;
+ unsigned bvr[16];
+ unsigned bcr[16];
+ unsigned wvr[16];
+ unsigned wcr[16];
+ unsigned bxvr[16];
+ unsigned claim;
+} debug_context_t; /* total size 86 * 4 = 344 bytes */
+
typedef struct ns_gic_cpu_context {
unsigned int gic_cpu_if_regs[32]; /* GIC context local to the CPU */
unsigned int gic_dist_if_pvt_regs[32]; /* GIC SGI/PPI context local to the CPU */
@@ -70,7 +82,7 @@ typedef struct ns_cpu_context {
gic_cpu_context gic_cpu_ctx; /* Per cpu GIC distributor and interface context */
unsigned int endianess; /* Per cpu endianess */
unsigned int vfp_regs[34]; /* Dummy entry for VFP context. */
- unsigned int debug_regs[32]; /* Dummy entry for Debug context. TODO */
+ debug_context_t debug_ctx; /* Entry for Debug context. */
} cpu_context;
typedef struct ns_global_context {
diff --git a/big-little/switcher/context/ns_context.c b/big-little/switcher/context/ns_context.c
index 2f16592..1e193ac 100644
--- a/big-little/switcher/context/ns_context.c
+++ b/big-little/switcher/context/ns_context.c
@@ -101,6 +101,7 @@ void save_context(unsigned first_cpu, unsigned op_type)
unsigned *pmon_context = ns_cpu_ctx->pmon_regs;
unsigned *gp_context = ns_cpu_ctx->banked_cpu_regs;
unsigned *vfp_context = ns_cpu_ctx->vfp_regs;
+ debug_context_t *debug_context = &ns_cpu_ctx->debug_ctx;
banked_cp15_context *cp15_context = &ns_cpu_ctx->banked_cp15_regs;
gic_cpu_context *gic_pvt_context = &ns_cpu_ctx->gic_cpu_ctx;
generic_timer_context *cp15_timer_ctx = &ns_cpu_ctx->cp15_timer_ctx;
@@ -175,6 +176,8 @@ void save_context(unsigned first_cpu, unsigned op_type)
}
+ save_v7_debug((unsigned *) debug_context);
+
/*
* Disable the GIC CPU interface tp prevent interrupts from waking
* the core from wfi() subsequently.
@@ -226,6 +229,7 @@ void restore_context(unsigned first_cpu, unsigned op_type)
unsigned *pmon_context = ns_cpu_ctx->pmon_regs;
unsigned *gp_context = ns_cpu_ctx->banked_cpu_regs;
unsigned *vfp_context = ns_cpu_ctx->vfp_regs;
+ debug_context_t *debug_context = &ns_cpu_ctx->debug_ctx;
gic_cpu_context *gic_pvt_context = &ns_cpu_ctx->gic_cpu_ctx;
generic_timer_context *cp15_timer_ctx = &ns_cpu_ctx->cp15_timer_ctx;
banked_cp15_context *cp15_context = &ns_cpu_ctx->banked_cp15_regs;
@@ -295,6 +299,7 @@ void restore_context(unsigned first_cpu, unsigned op_type)
restore_generic_timer((unsigned *)cp15_timer_ctx, 0x1);
}
+ restore_v7_debug((unsigned *) debug_context);
vgic_loadstate(cpu_id);
SetupVirtualisor(first_cpu);