jtag.h (2347B)
1 /* jtag transport 2 * 3 * Copyright 2015 Brian Swetland <swetland@frotz.net> 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef _JTAG_H_ 19 #define _JTAG_H_ 20 21 #define JTAG_RESET 0 22 #define JTAG_IDLE 1 23 #define JTAG_DRSELECT 2 24 #define JTAG_DRCAPTURE 3 25 #define JTAG_DRSHIFT 4 26 #define JTAG_DREXIT1 5 27 #define JTAG_DRPAUSE 6 28 #define JTAG_DREXIT2 7 29 #define JTAG_DRUPDATE 8 30 #define JTAG_IRSELECT 9 31 #define JTAG_IRCAPTURE 10 32 #define JTAG_IRSHIFT 11 33 #define JTAG_IREXIT1 12 34 #define JTAG_IRPAUSE 13 35 #define JTAG_IREXIT2 14 36 #define JTAG_IRUPDATE 15 37 #define JTAG_UNKNOWN 16 38 39 40 #define JTAG_MAX_WORDS 256 41 #define JTAG_MAX_BITS ((JTAG_MAX_WORDS) * 4) 42 #define JTAG_MAX_RESULTS 256 43 44 typedef struct jtag_txn { 45 u32 tms[JTAG_MAX_WORDS]; 46 u32 tdi[JTAG_MAX_WORDS]; 47 u32 tdo[JTAG_MAX_WORDS]; 48 u8 bits[JTAG_MAX_RESULTS]; 49 u64 *ptr[JTAG_MAX_RESULTS]; 50 unsigned txc; 51 unsigned rxc; 52 unsigned bitcount; 53 int status; 54 u32 ir_pre; 55 u32 ir_post; 56 u32 dr_pre; 57 u32 dr_post; 58 unsigned state; 59 } jtag_txn; 60 61 62 void jtag_txn_init(jtag_txn *tx); 63 int jtag_txn_exec(jtag_txn *t); 64 65 void jtag_txn_move(jtag_txn *t, unsigned dst); 66 67 // clock out 5+ TMS 1s and get to RESET, then IDLE from anywhere 68 void jtag_any_to_rti(jtag_txn *t); 69 70 // scan into IR or DR and end in IDLE state 71 void jtag_ir(jtag_txn *t, unsigned count, u64 ir); 72 void jtag_dr(jtag_txn *t, unsigned count, u64 dr, u64 *out); 73 74 // scan into IR or DR but end in PauseIR or PauseDR state, not IDLE 75 void jtag_ir_p(jtag_txn *t, unsigned count, u64 ir); 76 void jtag_dr_p(jtag_txn *t, unsigned count, u64 dr, u64 *out); 77 78 void jtag_cjtag_open(jtag_txn *t); 79 void jtag_cjtag_cmd(jtag_txn *t, unsigned cp0, unsigned cp1); 80 81 // clock raw TMS/TDI bit streams, does not check or update t->state 82 void jtag_txn_append(jtag_txn *t, unsigned count, u64 tms, u64 tdi, u64 *tdo); 83 84 85 #endif 86