1 /* 2 * $Id$ 3 * 4 * Generic command buffer handler. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 * 02111-1307, USA. 20 * 21 * Written by Arnim Laeuger, 2008. 22 * 23 */ 24 25 #ifndef URJ_TAP_CABLE_CMD_XFER_H 26 #define URJ_TAP_CABLE_CMD_XFER_H 27 28 #include <sysdep.h> 29 30 #include <urjtag/cable.h> 31 32 /* description of a command 33 the buffer can contain one or more commands if receive count 34 is zero for all of them */ 35 typedef struct URJ_TAP_CABLE_CX_CMD urj_tap_cable_cx_cmd_t; 36 struct URJ_TAP_CABLE_CX_CMD 37 { 38 urj_tap_cable_cx_cmd_t *next; 39 uint32_t buf_len; 40 uint32_t buf_pos; 41 uint8_t *buf; 42 uint32_t to_recv; 43 }; 44 45 struct URJ_TAP_CABLE_CX_CMD_ROOT 46 { 47 urj_tap_cable_cx_cmd_t *first; 48 urj_tap_cable_cx_cmd_t *last; 49 }; 50 typedef struct URJ_TAP_CABLE_CX_CMD_ROOT urj_tap_cable_cx_cmd_root_t; 51 52 int urj_tap_cable_cx_cmd_space (urj_tap_cable_cx_cmd_root_t *cmd_root, 53 int max_len); 54 int urj_tap_cable_cx_cmd_push (urj_tap_cable_cx_cmd_root_t *cmd_root, 55 uint8_t d); 56 urj_tap_cable_cx_cmd_t 57 *urj_tap_cable_cx_cmd_dequeue (urj_tap_cable_cx_cmd_root_t *cmd_root); 58 void urj_tap_cable_cx_cmd_free (urj_tap_cable_cx_cmd_t *cmd); 59 urj_tap_cable_cx_cmd_t 60 *urj_tap_cable_cx_cmd_queue (urj_tap_cable_cx_cmd_root_t *cmd_root, 61 uint32_t to_recv); 62 void urj_tap_cable_cx_cmd_init (urj_tap_cable_cx_cmd_root_t *cmd_root); 63 void urj_tap_cable_cx_cmd_deinit (urj_tap_cable_cx_cmd_root_t *cmd_root); 64 65 void urj_tap_cable_cx_xfer (urj_tap_cable_cx_cmd_root_t *cmd_root, 66 const urj_tap_cable_cx_cmd_t *out_cmd, 67 urj_cable_t *cable, 68 urj_cable_flush_amount_t how_much); 69 uint8_t urj_tap_cable_cx_xfer_recv (urj_cable_t *cable); 70 71 #endif /* URJ_TAP_CABLE_CMD_XFER_H */ 72