Line 112... |
Line 112... |
int DCR_hit = 0;
|
int DCR_hit = 0;
|
|
|
/* Calculate first 8 matchpoints, result is put into DCR_hit */
|
/* Calculate first 8 matchpoints, result is put into DCR_hit */
|
if (i < 8) {
|
if (i < 8) {
|
unsigned long dcr = mfspr (SPR_DCR(i));
|
unsigned long dcr = mfspr (SPR_DCR(i));
|
unsigned long dcr_ct=dcr&SPR_DCR_CT; // the CT field alone
|
unsigned long dcr_ct = dcr & SPR_DCR_CT; /* the CT field alone */
|
/* Is this matchpoint a propos for the current action? */
|
/* Is this matchpoint a propos for the current action? */
|
if ( ((dcr & SPR_DCR_DP) && dcr_ct) &&// DVR/DCP pair present
|
if ( ((dcr & SPR_DCR_DP) && dcr_ct) && /* DVR/DCP pair present */
|
(((action==DebugInstructionFetch) && (dcr_ct == SPR_DCR_CT_IFEA))
|
(((action==DebugInstructionFetch) && (dcr_ct == SPR_DCR_CT_IFEA)) ||
|
|| ((action==DebugLoadAddress) && ((dcr_ct == SPR_DCR_CT_LEA) || (dcr_ct == SPR_DCR_CT_LSEA)))
|
((action==DebugLoadAddress) && ((dcr_ct == SPR_DCR_CT_LEA) ||
|
|| ((action==DebugStoreAddress) && ((dcr_ct == SPR_DCR_CT_SEA) || (dcr_ct == SPR_DCR_CT_LSEA)))
|
(dcr_ct == SPR_DCR_CT_LSEA))) ||
|
|| ((action==DebugLoadData) && ((dcr_ct == SPR_DCR_CT_LD) || (dcr_ct == SPR_DCR_CT_LSD)))
|
((action==DebugStoreAddress) && ((dcr_ct == SPR_DCR_CT_SEA) ||
|
|| ((action==DebugStoreData) && ((dcr_ct == SPR_DCR_CT_SD) || (dcr_ct == SPR_DCR_CT_LSD)))) )
|
(dcr_ct == SPR_DCR_CT_LSEA))) ||
|
{
|
((action==DebugLoadData) && ((dcr_ct == SPR_DCR_CT_LD) ||
|
|
(dcr_ct == SPR_DCR_CT_LSD))) ||
|
|
((action==DebugStoreData) && ((dcr_ct == SPR_DCR_CT_SD) ||
|
|
(dcr_ct == SPR_DCR_CT_LSD)))) ) {
|
unsigned long op1=udata;
|
unsigned long op1=udata;
|
unsigned long op2 = mfspr (SPR_DVR(i));
|
unsigned long op2 = mfspr (SPR_DVR(i));
|
/* Perform signed comparison? */
|
/* Perform signed comparison? */
|
if (dcr & SPR_DCR_SC) {
|
if (dcr & SPR_DCR_SC) {
|
long sop1 = op1, sop2 = op2; /* Convert to signed */
|
long sop1 = op1, sop2 = op2; /* Convert to signed */
|
Line 150... |
Line 153... |
}
|
}
|
}
|
}
|
}
|
}
|
|
|
/* Chain matchpoints */
|
/* Chain matchpoints */
|
switch(i)
|
switch(i) {
|
{
|
|
case 0:
|
case 0:
|
chain1 = chain2 = DCR_hit;
|
chain1 = chain2 = DCR_hit;
|
break;
|
break;
|
case 8:
|
case 8:
|
chain1 = getsprbits (SPR_DWCR0, SPR_DWCR_COUNT) == getsprbits (SPR_DWCR0, SPR_DWCR_MATCH);
|
chain1 = getsprbits(SPR_DWCR0, SPR_DWCR_COUNT) == getsprbits(SPR_DWCR0,
|
|
SPR_DWCR_MATCH);
|
chain2 = watchpoints & (1 << 7);
|
chain2 = watchpoints & (1 << 7);
|
break;
|
break;
|
case 9:
|
case 9:
|
chain1 = getsprbits (SPR_DWCR1, SPR_DWCR_COUNT) == getsprbits (SPR_DWCR1, SPR_DWCR_MATCH);
|
chain1 = getsprbits(SPR_DWCR1, SPR_DWCR_COUNT) == getsprbits (SPR_DWCR1,
|
|
SPR_DWCR_MATCH);
|
chain2 = watchpoints & (1 << 8);
|
chain2 = watchpoints & (1 << 8);
|
break;
|
break;
|
case 10:
|
case 10:
|
/* TODO: External watchpoint - not yet handled! */
|
/* TODO: External watchpoint - not yet handled! */
|
#if 0
|
#if 0
|
Line 182... |
Line 186... |
|
|
switch(getsprbits (SPR_DMR1, SPR_DMR1_CW0 << i)) {
|
switch(getsprbits (SPR_DMR1, SPR_DMR1_CW0 << i)) {
|
case 0: match = chain1; break;
|
case 0: match = chain1; break;
|
case 1: match = chain1 && chain2; break;
|
case 1: match = chain1 && chain2; break;
|
case 2: match = chain1 || chain2; break;
|
case 2: match = chain1 || chain2; break;
|
default:
|
|
break;
|
|
}
|
}
|
|
|
// Increment counters & generate counter break
|
/* Increment counters & generate counter break */
|
if(match)
|
if(match) {
|
{
|
/* watchpoint did not appear before in this clock cycle */
|
if(!(watchpoints & bit)) // watchpoint did not appear before in this clock cycle
|
if(!(watchpoints & bit)) {
|
{
|
|
int counter = (getsprbits (SPR_DMR2, SPR_DMR2_AWTC) & bit) ? 1 : 0;
|
int counter = (getsprbits (SPR_DMR2, SPR_DMR2_AWTC) & bit) ? 1 : 0;
|
int enabled = counter ? getsprbits (SPR_DMR2, SPR_DMR2_WCE1) : getsprbits (SPR_DMR2, SPR_DMR2_WCE0);
|
int enabled = counter ? getsprbits(SPR_DMR2, SPR_DMR2_WCE1) :
|
|
getsprbits(SPR_DMR2, SPR_DMR2_WCE0);
|
if(enabled)
|
if(enabled)
|
setsprbits (SPR_DWCR0 + counter, SPR_DWCR_COUNT, getsprbits (SPR_DWCR0 + counter, SPR_DWCR_COUNT) + 1);
|
setsprbits(SPR_DWCR0 + counter, SPR_DWCR_COUNT,
|
|
getsprbits(SPR_DWCR0 + counter, SPR_DWCR_COUNT) + 1);
|
watchpoints |= bit;
|
watchpoints |= bit;
|
}
|
}
|
|
|
// should this watchpoint generate a breakpoint?
|
/* should this watchpoint generate a breakpoint? */
|
if(getsprbits (SPR_DMR2, SPR_DMR2_WGB) & bit) breakpoint = 1;
|
if(getsprbits(SPR_DMR2, SPR_DMR2_WGB) & bit)
|
|
breakpoint = 1;
|
}
|
}
|
}
|
}
|
|
|
return breakpoint;
|
return breakpoint;
|
}
|
}
|
|
|
static DebugScanChainIDs current_scan_chain = JTAG_CHAIN_GLOBAL;
|
static DebugScanChainIDs current_scan_chain = JTAG_CHAIN_GLOBAL;
|
|
|