From 0544bb04468bc99232d9cad31d2238d23488e524 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 27 Jan 2007 07:43:59 +0000 Subject: [PATCH] well, should imho work, i bet it wont though! --- jtag/parallel.c | 118 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 7 deletions(-) diff --git a/jtag/parallel.c b/jtag/parallel.c index 759daea..9020606 100644 --- a/jtag/parallel.c +++ b/jtag/parallel.c @@ -1,19 +1,123 @@ /* - * jtag via parallel + * doing jtag via the + * + * 'low cost jtag parallel programming cable' * * author: hackbard@hackdaworld.org * */ -#define XILINX_LOW_COST_CABLE 0x00 +#include +#include +#include +#include -#define ALTERA_BYTE_BLASTER +#define PARPORT 0x378 +#define TMS (1<<2) /* d2 */ +#define TDI (1<<0) /* d0 */ +#define TCK (1<<1) /* d1 */ +#define TDO (1<<4) /* select in */ +#define JTAG_INITIALIZED 0x01 -#include -#include -#include +#define FALSE 0 +#define TRUE 1 -#include +typedef unsigned char u8; +typedef unsigned short int u16; +typedef unsigned int u32; + +typedef struct s_jtag { + u16 port; + u8 status; +} t_jtag; + +int jtag_set_port(t_jtag *jtag,u16 port) { + + jtag->port=port; + + return 0; +} + +int jtag_init(t_jtag *jtag) { + + int ret; + u8 out; + + out=0; + + /* permissions */ + ret=ioperm(jtag->port,2,TRUE); + if(ret<0) { + perror("ioperm"); + return -1; + } + + /* set tck to zero */ + outb(out,jtag->port); + + return 0; +} + +u8 jtag_act(t_jtag *jtag,u8 tms,u8 tdi) { + + u8 out; + u8 tdo; + int i; + + out=0; + + if(tms) out|=(1<port); + + /* with tck low */ + outb(out,jtag->port); + + tdo=inb(jtag->port+1); +printf("%0x2 %c | ",tdo,((tdo<0x20)|(tdo>0x7e))?'.':tdo); +for(i=0;i<8;i++) printf("%d ",((tdo<<(7-i))&0x01)?1:0); +printf("\n"); + + return tdo; +} + +int jtag_reset(t_jtag *jtag) { + + int i; + + for(i=0;i<5;i++) jtag_act(jtag,1,0); + + return 0; +} + +int jtag_shift_dr(t_jtag *jtag) { + + /* assume 'test logic reset' status */ + + jtag_act(jtag,0,0); + jtag_act(jtag,1,0); + jtag_act(jtag,0,0); + jtag_act(jtag,0,0); + + return 0; +} + +int main(int argc,char **argv) { + + t_jtag jtag; + int i; + + jtag_init(&jtag); + + jtag_reset(&jtag); + + jtag_shift_dr(&jtag); + + for(i=0;i<32;i++) jtag_act(&jtag,0,0); + return 0; +} -- 2.39.5