remote: Fixed several clang-tidy warnings caused by bad (reserved) function naming

This commit is contained in:
dragonmux 2022-07-18 00:00:50 +01:00 committed by Piotr Esden-Tempski
parent deadf9a78d
commit 1b39173780
1 changed files with 64 additions and 68 deletions

View File

@ -61,68 +61,64 @@ uint64_t remotehston(uint32_t limit, char *s)
} }
#if PC_HOSTED == 0 #if PC_HOSTED == 0
static void _send_buf(uint8_t* buffer, size_t len) static void remote_send_buf(uint8_t *buffer, size_t len)
{ {
uint8_t* p = buffer; uint8_t *p = buffer;
char hex[2]; char hex[2];
do { do {
hexify(hex, (const void*)p++, 1); hexify(hex, (const void *)p++, 1);
gdb_if_putchar(hex[0], 0); gdb_if_putchar(hex[0], 0);
gdb_if_putchar(hex[1], 0); gdb_if_putchar(hex[1], 0);
} while (p<(buffer+len)); } while (p < (buffer + len));
} }
static void _respond_buf(char respCode, uint8_t* buffer, size_t len) static void remote_respond_buf(char respCode, uint8_t *buffer, size_t len)
{ {
gdb_if_putchar(REMOTE_RESP, 0); gdb_if_putchar(REMOTE_RESP, 0);
gdb_if_putchar(respCode, 0); gdb_if_putchar(respCode, 0);
_send_buf(buffer, len); remote_send_buf(buffer, len);
gdb_if_putchar(REMOTE_EOM, 1); gdb_if_putchar(REMOTE_EOM, 1);
} }
static void _respond(char respCode, uint64_t param)
/* Send response to far end */ /* Send response to far end */
static void remote_respond(char respCode, uint64_t param)
{ {
char buf[35]; /*Response, code, EOM and 2*16 hex nibbles*/ char buf[35]; /*Response, code, EOM and 2*16 hex nibbles*/
char *p=buf; char *p = buf;
gdb_if_putchar(REMOTE_RESP,0); gdb_if_putchar(REMOTE_RESP, 0);
gdb_if_putchar(respCode,0); gdb_if_putchar(respCode, 0);
do { do {
*p++=NTOH((param&0x0f)); *p++ = NTOH((param & 0x0f));
param>>=4; param >>= 4;
} } while (param);
while (param);
/* At this point the number to print is the buf, but backwards, so spool it out */ /* At this point the number to print is the buf, but backwards, so spool it out */
do { do {
gdb_if_putchar(*--p,0); gdb_if_putchar(*--p, 0);
} while (p>buf); } while (p > buf);
gdb_if_putchar(REMOTE_EOM,1); gdb_if_putchar(REMOTE_EOM, 1);
} }
static void _respondS(char respCode, const char *s) static void remote_respond_string(char respCode, const char *s)
/* Send response to far end */ /* Send response to far end */
{ {
gdb_if_putchar(REMOTE_RESP,0); gdb_if_putchar(REMOTE_RESP, 0);
gdb_if_putchar(respCode,0); gdb_if_putchar(respCode, 0);
while (*s) { while (*s) {
/* Just clobber illegal characters so they don't disturb the protocol */ /* Just clobber illegal characters so they don't disturb the protocol */
if ((*s=='$') || (*s==REMOTE_SOM) || (*s==REMOTE_EOM)) if ((*s == '$') || (*s == REMOTE_SOM) || (*s == REMOTE_EOM))
gdb_if_putchar(' ', 0); gdb_if_putchar(' ', 0);
else else
gdb_if_putchar(*s, 0); gdb_if_putchar(*s, 0);
s++; s++;
} }
gdb_if_putchar(REMOTE_EOM,1); gdb_if_putchar(REMOTE_EOM, 1);
} }
static ADIv5_DP_t remote_dp = { static ADIv5_DP_t remote_dp = {
@ -146,40 +142,40 @@ static void remotePacketProcessSWD(unsigned i, char *packet)
remote_dp.low_access = firmware_swdp_low_access; remote_dp.low_access = firmware_swdp_low_access;
remote_dp.abort = firmware_swdp_abort; remote_dp.abort = firmware_swdp_abort;
swdptap_init(&remote_dp); swdptap_init(&remote_dp);
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
} else { } else {
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN);
} }
break; break;
case REMOTE_IN_PAR: /* SI = In parity ============================= */ case REMOTE_IN_PAR: /* SI = In parity ============================= */
ticks=remotehston(2,&packet[2]); ticks=remotehston(2,&packet[2]);
badParity = remote_dp.seq_in_parity(&param, ticks); badParity = remote_dp.seq_in_parity(&param, ticks);
_respond(badParity?REMOTE_RESP_PARERR:REMOTE_RESP_OK,param); remote_respond(badParity?REMOTE_RESP_PARERR:REMOTE_RESP_OK,param);
break; break;
case REMOTE_IN: /* Si = In ======================================= */ case REMOTE_IN: /* Si = In ======================================= */
ticks=remotehston(2,&packet[2]); ticks=remotehston(2,&packet[2]);
param = remote_dp.seq_in(ticks); param = remote_dp.seq_in(ticks);
_respond(REMOTE_RESP_OK,param); remote_respond(REMOTE_RESP_OK,param);
break; break;
case REMOTE_OUT: /* So= Out ====================================== */ case REMOTE_OUT: /* So= Out ====================================== */
ticks=remotehston(2,&packet[2]); ticks=remotehston(2,&packet[2]);
param=remotehston(-1, &packet[4]); param=remotehston(-1, &packet[4]);
remote_dp.seq_out(param, ticks); remote_dp.seq_out(param, ticks);
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
case REMOTE_OUT_PAR: /* SO = Out parity ========================== */ case REMOTE_OUT_PAR: /* SO = Out parity ========================== */
ticks=remotehston(2,&packet[2]); ticks=remotehston(2,&packet[2]);
param=remotehston(-1, &packet[4]); param=remotehston(-1, &packet[4]);
remote_dp.seq_out_parity(param, ticks); remote_dp.seq_out_parity(param, ticks);
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
default: default:
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED);
break; break;
} }
} }
@ -197,12 +193,12 @@ static void remotePacketProcessJTAG(unsigned i, char *packet)
remote_dp.low_access = fw_adiv5_jtagdp_low_access; remote_dp.low_access = fw_adiv5_jtagdp_low_access;
remote_dp.abort = adiv5_jtagdp_abort; remote_dp.abort = adiv5_jtagdp_abort;
jtagtap_init(); jtagtap_init();
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
case REMOTE_RESET: /* JR = reset ================================= */ case REMOTE_RESET: /* JR = reset ================================= */
jtag_proc.jtagtap_reset(); jtag_proc.jtagtap_reset();
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
case REMOTE_TMS: /* JT = TMS Sequence ============================ */ case REMOTE_TMS: /* JT = TMS Sequence ============================ */
@ -210,10 +206,10 @@ static void remotePacketProcessJTAG(unsigned i, char *packet)
MS=remotehston(2,&packet[4]); MS=remotehston(2,&packet[4]);
if (i<4) { if (i<4) {
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN);
} else { } else {
jtag_proc.jtagtap_tms_seq( MS, ticks); jtag_proc.jtagtap_tms_seq( MS, ticks);
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
} }
break; break;
@ -221,7 +217,7 @@ static void remotePacketProcessJTAG(unsigned i, char *packet)
case REMOTE_TDITDO_NOTMS: case REMOTE_TDITDO_NOTMS:
if (i<5) { if (i<5) {
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN);
} else { } else {
ticks=remotehston(2,&packet[2]); ticks=remotehston(2,&packet[2]);
DI=remotehston(-1,&packet[4]); DI=remotehston(-1,&packet[4]);
@ -231,22 +227,22 @@ static void remotePacketProcessJTAG(unsigned i, char *packet)
if (ticks < 64) if (ticks < 64)
DO &= (1LL << ticks) - 1; DO &= (1LL << ticks) - 1;
_respond(REMOTE_RESP_OK, DO); remote_respond(REMOTE_RESP_OK, DO);
} }
break; break;
case REMOTE_NEXT: /* JN = NEXT ======================================== */ case REMOTE_NEXT: /* JN = NEXT ======================================== */
if (i != 4) if (i != 4)
_respond(REMOTE_RESP_ERR, REMOTE_ERROR_WRONGLEN); remote_respond(REMOTE_RESP_ERR, REMOTE_ERROR_WRONGLEN);
else { else {
uint32_t dat = jtag_proc.jtagtap_next(packet[2] == '1', packet[3] == '1'); uint32_t dat = jtag_proc.jtagtap_next(packet[2] == '1', packet[3] == '1');
_respond(REMOTE_RESP_OK, dat); remote_respond(REMOTE_RESP_OK, dat);
} }
break; break;
case REMOTE_ADD_JTAG_DEV: /* JJ = fill firmware jtag_devs */ case REMOTE_ADD_JTAG_DEV: /* JJ = fill firmware jtag_devs */
if (i < 22) { if (i < 22) {
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_WRONGLEN);
} else { } else {
memset(&jtag_dev, 0, sizeof(jtag_dev)); memset(&jtag_dev, 0, sizeof(jtag_dev));
uint8_t index = remotehston(2, &packet[ 2]); uint8_t index = remotehston(2, &packet[ 2]);
@ -257,12 +253,12 @@ static void remotePacketProcessJTAG(unsigned i, char *packet)
jtag_dev.ir_postscan = remotehston(2, &packet[12]); jtag_dev.ir_postscan = remotehston(2, &packet[12]);
jtag_dev.current_ir = remotehston(8, &packet[14]); jtag_dev.current_ir = remotehston(8, &packet[14]);
jtag_add_device(index, &jtag_dev); jtag_add_device(index, &jtag_dev);
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
} }
break; break;
default: default:
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED);
break; break;
} }
} }
@ -274,24 +270,24 @@ static void remotePacketProcessGEN(unsigned i, char *packet)
uint32_t freq; uint32_t freq;
switch (packet[1]) { switch (packet[1]) {
case REMOTE_VOLTAGE: case REMOTE_VOLTAGE:
_respondS(REMOTE_RESP_OK, platform_target_voltage()); remote_respond_string(REMOTE_RESP_OK, platform_target_voltage());
break; break;
case REMOTE_NRST_SET: case REMOTE_NRST_SET:
platform_nrst_set_val(packet[2] == '1'); platform_nrst_set_val(packet[2] == '1');
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
case REMOTE_NRST_GET: case REMOTE_NRST_GET:
_respond(REMOTE_RESP_OK, platform_nrst_get_val()); remote_respond(REMOTE_RESP_OK, platform_nrst_get_val());
break; break;
case REMOTE_FREQ_SET: case REMOTE_FREQ_SET:
platform_max_frequency_set( remotehston(8, packet + 2)); platform_max_frequency_set( remotehston(8, packet + 2));
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
case REMOTE_FREQ_GET: case REMOTE_FREQ_GET:
freq = platform_max_frequency_get(); freq = platform_max_frequency_get();
_respond_buf(REMOTE_RESP_OK, (uint8_t*)&freq, 4); remote_respond_buf(REMOTE_RESP_OK, (uint8_t*)&freq, 4);
break; break;
case REMOTE_PWR_SET: case REMOTE_PWR_SET:
@ -302,21 +298,21 @@ static void remotePacketProcessGEN(unsigned i, char *packet)
/* want to enable target power, but voltage > 0.5V sensed /* want to enable target power, but voltage > 0.5V sensed
* on the pin -> cancel * on the pin -> cancel
*/ */
_respond(REMOTE_RESP_ERR, 0); remote_respond(REMOTE_RESP_ERR, 0);
} else { } else {
platform_target_set_power(packet[2] == '1'); platform_target_set_power(packet[2] == '1');
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
} }
#else #else
_respond(REMOTE_RESP_NOTSUP, 0); remote_respond(REMOTE_RESP_NOTSUP, 0);
#endif #endif
break; break;
case REMOTE_PWR_GET: case REMOTE_PWR_GET:
#ifdef PLATFORM_HAS_POWER_SWITCH #ifdef PLATFORM_HAS_POWER_SWITCH
_respond(REMOTE_RESP_OK, platform_target_get_power()); remote_respond(REMOTE_RESP_OK, platform_target_get_power());
#else #else
_respond(REMOTE_RESP_NOTSUP, 0); remote_respond(REMOTE_RESP_NOTSUP, 0);
#endif #endif
break; break;
@ -324,11 +320,11 @@ static void remotePacketProcessGEN(unsigned i, char *packet)
# define PLATFORM_IDENT() BOARD_IDENT # define PLATFORM_IDENT() BOARD_IDENT
#endif #endif
case REMOTE_START: case REMOTE_START:
_respondS(REMOTE_RESP_OK, PLATFORM_IDENT "" FIRMWARE_VERSION); remote_respond_string(REMOTE_RESP_OK, PLATFORM_IDENT "" FIRMWARE_VERSION);
break; break;
default: default:
_respond(REMOTE_RESP_ERR, REMOTE_ERROR_UNRECOGNISED); remote_respond(REMOTE_RESP_ERR, REMOTE_ERROR_UNRECOGNISED);
break; break;
} }
} }
@ -344,7 +340,7 @@ static void remotePacketProcessHL(unsigned i, char *packet)
void *src = (void *)(((uint32_t)packet + 7) & ~7); void *src = (void *)(((uint32_t)packet + 7) & ~7);
char index = packet[1]; char index = packet[1];
if (index == REMOTE_HL_CHECK) { if (index == REMOTE_HL_CHECK) {
_respond(REMOTE_RESP_OK, REMOTE_HL_VERSION); remote_respond(REMOTE_RESP_OK, REMOTE_HL_VERSION);
return; return;
} }
packet += 2; packet += 2;
@ -357,7 +353,7 @@ static void remotePacketProcessHL(unsigned i, char *packet)
packet += 2; packet += 2;
uint16_t addr16 = remotehston(4, packet); uint16_t addr16 = remotehston(4, packet);
uint32_t data = adiv5_dp_read(&remote_dp, addr16); uint32_t data = adiv5_dp_read(&remote_dp, addr16);
_respond_buf(REMOTE_RESP_OK, (uint8_t*)&data, 4); remote_respond_buf(REMOTE_RESP_OK, (uint8_t*)&data, 4);
break; break;
case REMOTE_LOW_ACCESS: /* HL = Low level access */ case REMOTE_LOW_ACCESS: /* HL = Low level access */
packet += 2; packet += 2;
@ -365,13 +361,13 @@ static void remotePacketProcessHL(unsigned i, char *packet)
packet += 4; packet += 4;
uint32_t value = remotehston(8, packet); uint32_t value = remotehston(8, packet);
data = remote_dp.low_access(&remote_dp, remote_ap.apsel, addr16, value); data = remote_dp.low_access(&remote_dp, remote_ap.apsel, addr16, value);
_respond_buf(REMOTE_RESP_OK, (uint8_t*)&data, 4); remote_respond_buf(REMOTE_RESP_OK, (uint8_t*)&data, 4);
break; break;
case REMOTE_AP_READ: /* Ha = Read from AP register*/ case REMOTE_AP_READ: /* Ha = Read from AP register*/
packet += 2; packet += 2;
addr16 = remotehston(4, packet); addr16 = remotehston(4, packet);
data = adiv5_ap_read(&remote_ap, addr16); data = adiv5_ap_read(&remote_ap, addr16);
_respond_buf(REMOTE_RESP_OK, (uint8_t*)&data, 4); remote_respond_buf(REMOTE_RESP_OK, (uint8_t*)&data, 4);
break; break;
case REMOTE_AP_WRITE: /* Ha = Write to AP register*/ case REMOTE_AP_WRITE: /* Ha = Write to AP register*/
packet += 2; packet += 2;
@ -379,7 +375,7 @@ static void remotePacketProcessHL(unsigned i, char *packet)
packet += 4; packet += 4;
value = remotehston(8, packet); value = remotehston(8, packet);
adiv5_ap_write(&remote_ap, addr16, value); adiv5_ap_write(&remote_ap, addr16, value);
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
case REMOTE_AP_MEM_READ: /* HM = Read from Mem and set csw */ case REMOTE_AP_MEM_READ: /* HM = Read from Mem and set csw */
packet += 2; packet += 2;
@ -394,10 +390,10 @@ static void remotePacketProcessHL(unsigned i, char *packet)
packet += 8; packet += 8;
adiv5_mem_read(&remote_ap, src, address, count); adiv5_mem_read(&remote_ap, src, address, count);
if (remote_ap.dp->fault == 0) { if (remote_ap.dp->fault == 0) {
_respond_buf(REMOTE_RESP_OK, src, count); remote_respond_buf(REMOTE_RESP_OK, src, count);
break; break;
} }
_respond(REMOTE_RESP_ERR, 0); remote_respond(REMOTE_RESP_ERR, 0);
remote_ap.dp->fault = 0; remote_ap.dp->fault = 0;
break; break;
case REMOTE_AP_MEM_WRITE_SIZED: /* Hm = Write to memory and set csw */ case REMOTE_AP_MEM_WRITE_SIZED: /* Hm = Write to memory and set csw */
@ -415,7 +411,7 @@ static void remotePacketProcessHL(unsigned i, char *packet)
packet += 8; packet += 8;
if (len & ((1 << align) - 1)) { if (len & ((1 << align) - 1)) {
/* len and align do not fit*/ /* len and align do not fit*/
_respond(REMOTE_RESP_ERR, 0); remote_respond(REMOTE_RESP_ERR, 0);
break; break;
} }
/* Read as stream of hexified bytes*/ /* Read as stream of hexified bytes*/
@ -423,14 +419,14 @@ static void remotePacketProcessHL(unsigned i, char *packet)
adiv5_mem_write_sized(&remote_ap, dest, src, len, align); adiv5_mem_write_sized(&remote_ap, dest, src, len, align);
if (remote_ap.dp->fault) { if (remote_ap.dp->fault) {
/* Errors handles on hosted side.*/ /* Errors handles on hosted side.*/
_respond(REMOTE_RESP_ERR, 0); remote_respond(REMOTE_RESP_ERR, 0);
remote_ap.dp->fault = 0; remote_ap.dp->fault = 0;
break; break;
} }
_respond(REMOTE_RESP_OK, 0); remote_respond(REMOTE_RESP_OK, 0);
break; break;
default: default:
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED);
break; break;
} }
SET_IDLE_STATE(1); SET_IDLE_STATE(1);
@ -457,7 +453,7 @@ void remotePacketProcess(unsigned i, char *packet)
break; break;
default: /* Oh dear, unrecognised, return an error */ default: /* Oh dear, unrecognised, return an error */
_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED); remote_respond(REMOTE_RESP_ERR,REMOTE_ERROR_UNRECOGNISED);
break; break;
} }
} }