/* * This file is part of the Black Magic Debug project. * * Copyright (C) 2019 Black Sphere Technologies Ltd. * Written by Dave Marples * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef _REMOTE_ #define _REMOTE_ #include #include "general.h" /* * Commands to remote end, and responses * ===================================== * * All commands as sent as ASCII and begin with !, ending with #. * Parameters are hex digits and format is per command. * * !# * - 2 digit ASCII value * - x digits (according to command) ASCII value * * So, for example; * * SI - swdptap_seq_in_parity * tt - Ticks * e.g. SI21 : Request input with parity, 33 ticks * resp: K - hex value returned. * resp: F - hex value returned, bad parity. * X - error occured * * The whole protocol is defined in this header file. Parameters have * to be marshalled in remote.c, swdptap.c and jtagtap.c, so be * careful to ensure the parameter handling matches the protocol * definition when anything is changed. */ /* Protocol error messages */ #define REMOTE_ERROR_UNRECOGNISED 1 #define REMOTE_ERROR_WRONGLEN 2 /* Start and end of message identifiers */ #define REMOTE_SOM '!' #define REMOTE_EOM '#' #define REMOTE_RESP '&' /* Generic protocol elements */ #define REMOTE_START 'A' #define REMOTE_TDITDO_TMS 'D' #define REMOTE_TDITDO_NOTMS 'd' #define REMOTE_IN_PAR 'I' #define REMOTE_IN 'i' #define REMOTE_NEXT 'N' #define REMOTE_OUT_PAR 'O' #define REMOTE_OUT 'o' #define REMOTE_PWR_SET 'P' #define REMOTE_PWR_GET 'p' #define REMOTE_RESET 'R' #define REMOTE_INIT 'S' #define REMOTE_TMS 'T' #define REMOTE_VOLTAGE 'V' #define REMOTE_SRST_SET 'Z' #define REMOTE_SRST_GET 'z' /* Protocol response options */ #define REMOTE_RESP_OK 'K' #define REMOTE_RESP_PARERR 'P' #define REMOTE_RESP_ERR 'E' #define REMOTE_RESP_NOTSUP 'N' /* Generic protocol elements */ #define REMOTE_GEN_PACKET 'G' #define REMOTE_START_STR (char []){ '+', REMOTE_EOM, REMOTE_SOM, REMOTE_GEN_PACKET, REMOTE_START, REMOTE_EOM, 0 } #define REMOTE_VOLTAGE_STR (char []){ REMOTE_SOM, REMOTE_GEN_PACKET, REMOTE_VOLTAGE, REMOTE_EOM, 0 } #define REMOTE_SRST_SET_STR (char []){ REMOTE_SOM, REMOTE_GEN_PACKET, REMOTE_SRST_SET, '%', 'c', REMOTE_EOM, 0 } #define REMOTE_SRST_GET_STR (char []){ REMOTE_SOM, REMOTE_GEN_PACKET, REMOTE_SRST_GET, REMOTE_EOM, 0 } #define REMOTE_PWR_SET_STR (char []){ REMOTE_SOM, REMOTE_GEN_PACKET, REMOTE_PWR_SET, '%', 'c', REMOTE_EOM, 0 } #define REMOTE_PWR_GET_STR (char []){ REMOTE_SOM, REMOTE_GEN_PACKET, REMOTE_PWR_GET, REMOTE_EOM, 0 } /* SWDP protocol elements */ #define REMOTE_SWDP_PACKET 'S' #define REMOTE_SWDP_INIT_STR (char []){ REMOTE_SOM, REMOTE_SWDP_PACKET, REMOTE_INIT, REMOTE_EOM, 0 } #define REMOTE_SWDP_IN_PAR_STR (char []){ REMOTE_SOM, REMOTE_SWDP_PACKET, REMOTE_IN_PAR, \ '%','0','2','x',REMOTE_EOM, 0 } #define REMOTE_SWDP_IN_STR (char []){ REMOTE_SOM, REMOTE_SWDP_PACKET, REMOTE_IN, \ '%','0','2','x',REMOTE_EOM, 0 } #define REMOTE_SWDP_OUT_STR (char []){ REMOTE_SOM, REMOTE_SWDP_PACKET, REMOTE_OUT, \ '%','0','2','x','%','x',REMOTE_EOM, 0 } #define REMOTE_SWDP_OUT_PAR_STR (char []){ REMOTE_SOM, REMOTE_SWDP_PACKET, REMOTE_OUT_PAR, \ '%','0','2','x','%','x',REMOTE_EOM, 0 } /* JTAG protocol elements */ #define REMOTE_JTAG_PACKET 'J' #define REMOTE_JTAG_INIT_STR (char []){ '+',REMOTE_EOM, REMOTE_SOM, REMOTE_JTAG_PACKET, REMOTE_INIT, REMOTE_EOM, 0 } #define REMOTE_JTAG_RESET_STR (char []){ '+',REMOTE_EOM, REMOTE_SOM, REMOTE_JTAG_PACKET, REMOTE_RESET, REMOTE_EOM, 0 } #define REMOTE_JTAG_TMS_STR (char []){ REMOTE_SOM, REMOTE_JTAG_PACKET, REMOTE_TMS, \ '%','0','2','x','%','x',REMOTE_EOM, 0 } #define REMOTE_JTAG_TDIDO_STR (char []){ REMOTE_SOM, REMOTE_JTAG_PACKET, '%', 'c', \ '%','0','2','x','%','l', 'x', REMOTE_EOM, 0 } #define REMOTE_JTAG_NEXT (char []){ REMOTE_SOM, REMOTE_JTAG_PACKET, REMOTE_NEXT, \ '%','c','%','c',REMOTE_EOM, 0 } uint64_t remotehston(uint32_t limit, char *s); void remotePacketProcess(uint8_t i, char *packet); #endif