1 /* 2 * $Id$ 3 * 4 * Copyright (C) 2003 ETC s.r.o. 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 Marcel Telka <marcel@telka.sk>, 2003. 22 * 23 */ 24 25 #ifndef URJ_CHAIN_H 26 #define URJ_CHAIN_H 27 28 #include "types.h" 29 30 #include "pod.h" 31 #include "bsdl.h" 32 #include "error.h" 33 34 #define URJ_CHAIN_EXITMODE_SHIFT 0 35 #define URJ_CHAIN_EXITMODE_IDLE 1 36 #define URJ_CHAIN_EXITMODE_EXIT1 2 37 #define URJ_CHAIN_EXITMODE_UPDATE 3 38 39 struct URJ_CHAIN 40 { 41 int state; 42 urj_parts_t *parts; 43 int total_instr_len; 44 int active_part; 45 urj_cable_t *cable; 46 urj_bsdl_globs_t bsdl; 47 int main_part; 48 }; 49 50 urj_chain_t *urj_tap_chain_alloc (void); 51 void urj_tap_chain_free (urj_chain_t *chain); 52 /** 53 * Connect the chain to the specified cable. 54 * 55 * @param chain chain object to connect 56 * @param drivername name of cable driver 57 * @param params additional driver-specific parameters 58 * 59 * @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error 60 */ 61 int urj_tap_chain_connect (urj_chain_t *chain, const char *drivername, char *params[]); 62 void urj_tap_chain_disconnect (urj_chain_t *chain); 63 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ 64 int urj_tap_chain_clock (urj_chain_t *chain, int tms, int tdi, int n); 65 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ 66 int urj_tap_chain_defer_clock (urj_chain_t *chain, int tms, int tdi, int n); 67 /** @return trst = 0 or 1 on success; -1 on error */ 68 int urj_tap_chain_set_trst (urj_chain_t *chain, int trst); 69 /** @return 0 or 1 on success; -1 on error */ 70 int urj_tap_chain_get_trst (urj_chain_t *chain); 71 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ 72 int urj_tap_chain_shift_instructions (urj_chain_t *chain); 73 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ 74 int urj_tap_chain_shift_instructions_mode (urj_chain_t *chain, 75 int capture_output, int capture, 76 int chain_exit); 77 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ 78 int urj_tap_chain_shift_data_registers (urj_chain_t *chain, 79 int capture_output); 80 /** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error */ 81 int urj_tap_chain_shift_data_registers_mode (urj_chain_t *chain, 82 int capture_output, int capture, 83 int chain_exit); 84 void urj_tap_chain_flush (urj_chain_t *chain); 85 /** @return 0 or 1 on success; -1 on failure */ 86 int urj_tap_chain_set_pod_signal (urj_chain_t *chain, int mask, int val); 87 /** @return 0 or 1 on success; -1 on failure */ 88 int urj_tap_chain_get_pod_signal (urj_chain_t *chain, urj_pod_sigsel_t sig); 89 /** 90 * Check whether a chain has an active part 91 * 92 * @return NULL on error, and sets urj_error. 93 */ 94 urj_part_t *urj_tap_chain_active_part (urj_chain_t *chain); 95 void urj_tap_chain_wait_ready (urj_chain_t *chain); 96 97 typedef struct 98 { 99 urj_chain_t **chains; 100 int size; /* allocated chains array size */ 101 } 102 urj_chains_t; 103 104 #endif /* URJ_CHAIN_H */ 105