Skip to content

Commit

Permalink
hosted/platform: Fixed decode_access() to take the AP selected and pr…
Browse files Browse the repository at this point in the history
…operly decode the AP/!DP bit in the address field so we display accesses properly
  • Loading branch information
dragonmux authored and esden committed Oct 11, 2023
1 parent 0ca2fb2 commit 9fe5889
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/platforms/hosted/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,30 +666,30 @@ static void decode_ap_access(const uint8_t ap, const uint8_t addr)
DEBUG_PROTO("Reserved(%02x): ", addr);
}

static void decode_access(const uint16_t addr, const uint8_t rnw, const uint32_t value)
static void decode_access(const uint16_t addr, const uint8_t rnw, const uint8_t apsel, const uint32_t value)
{
if (rnw)
DEBUG_PROTO("Read ");
else
DEBUG_PROTO("Write ");

if (addr < 0x100U)
decode_dp_access(addr & 0xffU, rnw, value);
if (addr & ADIV5_APnDP)
decode_ap_access(apsel, addr & 0xffU);
else
decode_ap_access(addr >> 8U, addr & 0xffU);
decode_dp_access(addr & 0xffU, rnw, value);
}

void adiv5_dp_write(adiv5_debug_port_s *dp, uint16_t addr, uint32_t value)
{
decode_access(addr, ADIV5_LOW_WRITE, value);
decode_access(addr, ADIV5_LOW_WRITE, 0U, value);
DEBUG_PROTO("0x%08" PRIx32 "\n", value);
dp->low_access(dp, ADIV5_LOW_WRITE, addr, value);
}

uint32_t adiv5_dp_read(adiv5_debug_port_s *dp, uint16_t addr)
{
uint32_t ret = dp->dp_read(dp, addr);
decode_access(addr, ADIV5_LOW_READ, 0U);
decode_access(addr, ADIV5_LOW_READ, 0U, 0U);
DEBUG_PROTO("0x%08" PRIx32 "\n", ret);
return ret;
}
Expand All @@ -704,22 +704,22 @@ uint32_t adiv5_dp_error(adiv5_debug_port_s *dp)
uint32_t adiv5_dp_low_access(adiv5_debug_port_s *dp, uint8_t rnw, uint16_t addr, uint32_t value)
{
uint32_t ret = dp->low_access(dp, rnw, addr, value);
decode_access(addr, rnw, value);
decode_access(addr, rnw, 0U, value);
DEBUG_PROTO("0x%08" PRIx32 "\n", rnw ? ret : value);
return ret;
}

uint32_t adiv5_ap_read(adiv5_access_port_s *ap, uint16_t addr)
{
uint32_t ret = ap->dp->ap_read(ap, addr);
decode_access(addr, ADIV5_LOW_READ, 0U);
decode_access(addr, ADIV5_LOW_READ, ap->apsel, 0U);
DEBUG_PROTO("0x%08" PRIx32 "\n", ret);
return ret;
}

void adiv5_ap_write(adiv5_access_port_s *ap, uint16_t addr, uint32_t value)
{
decode_access(addr, ADIV5_LOW_WRITE, value);
decode_access(addr, ADIV5_LOW_WRITE, ap->apsel, value);
DEBUG_PROTO("0x%08" PRIx32 "\n", value);
ap->dp->ap_write(ap, addr, value);
}
Expand Down

0 comments on commit 9fe5889

Please sign in to comment.