Check for 10-bit address over flow when auto-incrementing.
Clean up whitespace.
This commit is contained in:
parent
8f04241aa8
commit
1d16d6c34c
46
src/adiv5.c
46
src/adiv5.c
|
@ -187,6 +187,7 @@ static int
|
|||
ap_mem_read_words(struct target_s *target, uint32_t *dest, uint32_t src, int len)
|
||||
{
|
||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||
uint32_t osrc = src;
|
||||
|
||||
len >>= 2;
|
||||
|
||||
|
@ -195,10 +196,20 @@ ap_mem_read_words(struct target_s *target, uint32_t *dest, uint32_t src, int len
|
|||
ADIV5_AP_TAR, src);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP, ADIV5_LOW_READ,
|
||||
ADIV5_AP_DRW, 0);
|
||||
while(--len)
|
||||
while(--len) {
|
||||
*dest++ = adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_READ, ADIV5_AP_DRW, 0);
|
||||
src += 4;
|
||||
/* Check for 10 bit address overflow */
|
||||
if ((src ^ osrc) & 0xfffffc00) {
|
||||
osrc = src;
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_WRITE, ADIV5_AP_TAR, src);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_READ, ADIV5_AP_DRW, 0);
|
||||
}
|
||||
|
||||
}
|
||||
*dest++ = adiv5_dp_low_access(ap->dp, ADIV5_LOW_DP, ADIV5_LOW_READ,
|
||||
ADIV5_DP_RDBUFF, 0);
|
||||
|
||||
|
@ -209,7 +220,8 @@ static int
|
|||
ap_mem_read_bytes(struct target_s *target, uint8_t *dest, uint32_t src, int len)
|
||||
{
|
||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||
uint32_t tmp = src;
|
||||
uint32_t tmp;
|
||||
uint32_t osrc = src;
|
||||
|
||||
adiv5_ap_write(ap, ADIV5_AP_CSW, 0xA2000050);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP, ADIV5_LOW_WRITE,
|
||||
|
@ -219,6 +231,16 @@ ap_mem_read_bytes(struct target_s *target, uint8_t *dest, uint32_t src, int len)
|
|||
while(--len) {
|
||||
tmp = adiv5_dp_low_access(ap->dp, 1, 1, ADIV5_AP_DRW, 0);
|
||||
*dest++ = (tmp >> ((src++ & 0x3) << 3) & 0xFF);
|
||||
|
||||
src++;
|
||||
/* Check for 10 bit address overflow */
|
||||
if ((src ^ osrc) & 0xfffffc00) {
|
||||
osrc = src;
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_WRITE, ADIV5_AP_TAR, src);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_READ, ADIV5_AP_DRW, 0);
|
||||
}
|
||||
}
|
||||
tmp = adiv5_dp_low_access(ap->dp, 0, 1, ADIV5_DP_RDBUFF, 0);
|
||||
*dest++ = (tmp >> ((src++ & 0x3) << 3) & 0xFF);
|
||||
|
@ -231,15 +253,24 @@ static int
|
|||
ap_mem_write_words(struct target_s *target, uint32_t dest, const uint32_t *src, int len)
|
||||
{
|
||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||
uint32_t odest = dest;
|
||||
|
||||
len >>= 2;
|
||||
|
||||
adiv5_ap_write(ap, ADIV5_AP_CSW, 0xA2000052);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP, ADIV5_LOW_WRITE,
|
||||
ADIV5_AP_TAR, dest);
|
||||
while(len--)
|
||||
while(len--) {
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP, ADIV5_LOW_WRITE,
|
||||
ADIV5_AP_DRW, *src++);
|
||||
dest += 4;
|
||||
/* Check for 10 bit address overflow */
|
||||
if ((dest ^ odest) & 0xfffffc00) {
|
||||
odest = dest;
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_WRITE, ADIV5_AP_TAR, dest);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -248,6 +279,7 @@ static int
|
|||
ap_mem_write_bytes(struct target_s *target, uint32_t dest, const uint8_t *src, int len)
|
||||
{
|
||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||
uint32_t odest = dest;
|
||||
|
||||
adiv5_ap_write(ap, ADIV5_AP_CSW, 0xA2000050);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP, ADIV5_LOW_WRITE,
|
||||
|
@ -256,6 +288,14 @@ ap_mem_write_bytes(struct target_s *target, uint32_t dest, const uint8_t *src, i
|
|||
uint32_t tmp = (uint32_t)*src++ << ((dest++ & 3) << 3);
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP, ADIV5_LOW_WRITE,
|
||||
ADIV5_AP_DRW, tmp);
|
||||
|
||||
dest ++;
|
||||
/* Check for 10 bit address overflow */
|
||||
if ((dest ^ odest) & 0xfffffc00) {
|
||||
odest = dest;
|
||||
adiv5_dp_low_access(ap->dp, ADIV5_LOW_AP,
|
||||
ADIV5_LOW_WRITE, ADIV5_AP_TAR, dest);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue