arm_adi_v5: enhance command error reporting

avoid the usage of ERROR_COMMAND_SYNTAX_ERROR when
ERROR_COMMAND_ARGUMENT_INVALID is more adequate.

Change-Id: Ic9aaedb93fedd45efee1b39f8ea20185f01af2da
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5654
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tarek BOCHKATI 2020-05-31 11:12:05 +01:00 committed by Antonio Borneo
parent 93e4bed056
commit cdb6918c87
1 changed files with 32 additions and 17 deletions

View File

@ -1610,8 +1610,10 @@ COMMAND_HANDLER(handle_dap_info_command)
break;
case 1:
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
if (apsel > DP_APSEL_MAX)
return ERROR_COMMAND_SYNTAX_ERROR;
if (apsel > DP_APSEL_MAX) {
command_print(CMD, "Invalid AP number");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
@ -1633,8 +1635,10 @@ COMMAND_HANDLER(dap_baseaddr_command)
case 1:
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
/* AP address is in bits 31:24 of DP_SELECT */
if (apsel > DP_APSEL_MAX)
return ERROR_COMMAND_SYNTAX_ERROR;
if (apsel > DP_APSEL_MAX) {
command_print(CMD, "Invalid AP number");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
@ -1692,8 +1696,10 @@ COMMAND_HANDLER(dap_apsel_command)
case 1:
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
/* AP address is in bits 31:24 of DP_SELECT */
if (apsel > DP_APSEL_MAX)
return ERROR_COMMAND_SYNTAX_ERROR;
if (apsel > DP_APSEL_MAX) {
command_print(CMD, "Invalid AP number");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
@ -1722,7 +1728,7 @@ COMMAND_HANDLER(dap_apcsw_command)
if (csw_val & (CSW_SIZE_MASK | CSW_ADDRINC_MASK)) {
LOG_ERROR("CSW value cannot include 'Size' and 'AddrInc' bit-fields");
return ERROR_COMMAND_SYNTAX_ERROR;
return ERROR_COMMAND_ARGUMENT_INVALID;
}
apcsw = csw_val;
break;
@ -1731,7 +1737,7 @@ COMMAND_HANDLER(dap_apcsw_command)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], csw_mask);
if (csw_mask & (CSW_SIZE_MASK | CSW_ADDRINC_MASK)) {
LOG_ERROR("CSW mask cannot include 'Size' and 'AddrInc' bit-fields");
return ERROR_COMMAND_SYNTAX_ERROR;
return ERROR_COMMAND_ARGUMENT_INVALID;
}
apcsw = (apcsw & ~csw_mask) | (csw_val & csw_mask);
break;
@ -1758,8 +1764,10 @@ COMMAND_HANDLER(dap_apid_command)
case 1:
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
/* AP address is in bits 31:24 of DP_SELECT */
if (apsel > DP_APSEL_MAX)
return ERROR_COMMAND_SYNTAX_ERROR;
if (apsel > DP_APSEL_MAX) {
command_print(CMD, "Invalid AP number");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
@ -1789,13 +1797,18 @@ COMMAND_HANDLER(dap_apreg_command)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
/* AP address is in bits 31:24 of DP_SELECT */
if (apsel > DP_APSEL_MAX)
return ERROR_COMMAND_SYNTAX_ERROR;
if (apsel > DP_APSEL_MAX) {
command_print(CMD, "Invalid AP number");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
ap = dap_ap(dap, apsel);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], reg);
if (reg >= 256 || (reg & 3))
return ERROR_COMMAND_SYNTAX_ERROR;
if (reg >= 256 || (reg & 3)) {
command_print(CMD, "Invalid reg value (should be less than 256 and 4 bytes aligned)");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
if (CMD_ARGC == 3) {
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value);
@ -1839,8 +1852,10 @@ COMMAND_HANDLER(dap_dpreg_command)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], reg);
if (reg >= 256 || (reg & 3))
return ERROR_COMMAND_SYNTAX_ERROR;
if (reg >= 256 || (reg & 3)) {
command_print(CMD, "Invalid reg value (should be less than 256 and 4 bytes aligned)");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
if (CMD_ARGC == 2) {
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value);
@ -1871,7 +1886,7 @@ COMMAND_HANDLER(dap_ti_be_32_quirks_command)
case 1:
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], enable);
if (enable > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
return ERROR_COMMAND_ARGUMENT_INVALID;
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;