📄 jflash.cpp.orig
字号:
// Preset to default values (all others set in cotullajtag.h)
pin[nCS0_OUT] = 1;
pin[nCS1_OUT] = 1;
pin[nCS2_OUT] = 1;
pin[nCS3_OUT] = 1;
pin[nCS4_OUT] = 1;
pin[nCS5_OUT] = 1;
}
/*
*******************************************************************************
*
* FUNCTION: mem_output_enable
*
* DESCRIPTION: enable or disable memory output. This pin is connected to
* the output enables of the memory device.
*
* INPUT PARAMETERS: int - enable or disable
*
* RETURNS: void
*
*******************************************************************************
*/
void mem_output_enable(int endis)
{
if (endis == ENABLE)
{
pin[nOE_OUT] = 0;
}
else
{
pin[nOE_OUT] = 1;
}
}
/*
*******************************************************************************
*
* FUNCTION: mem_write_enable
*
* DESCRIPTION: enable or disable memory writes. This pin is connected to
* the write enables of the memory device.
*
* INPUT PARAMETERS: int - enable or disable
*
* RETURNS: void
*
*******************************************************************************
*/
void mem_write_enable(int endis)
{
if (endis == ENABLE)
{
pin[nWE_OUT] = 0;
}
else
{
pin[nWE_OUT] = 1;
}
}
/*
*******************************************************************************
*
* FUNCTION: mem_data_driver
*
* DESCRIPTION: Sets memory data pins to DRIVE or HIZ.
*
* INPUT PARAMETERS: int - drive or highz
*
* RETURNS: void
*
*******************************************************************************
*/
void mem_data_driver(int df)
{
#ifndef ASSABET_PLATFORM
if (df == DRIVE)
{
pin[mdupper_ctrl] = 1;
pin[mdlower_ctrl] = 1;
}
else
{
pin[mdupper_ctrl] = 0;
pin[mdlower_ctrl] = 0;
}
#else
if (df == DRIVE)
{
pin[D31_0_EN] = 0;
}
else
{
pin[D31_0_EN] = 1;
}
#endif // !ASSABET_PLATFORM
}
/*
*******************************************************************************
*
* FUNCTION: mem_rw_mode
*
* DESCRIPTION: Sets memory mode to READ or WRITE.
*
* INPUT PARAMETERS: int - READ or WRITE
*
* RETURNS: void
*
*******************************************************************************
*/
void mem_rw_mode(int rw)
{
if (rw == WRITE)
{
pin[RD_nWR_OUT] = 0;
}
else
{
pin[RD_nWR_OUT] = 1;
}
}
/*
*******************************************************************************
*
* FUNCTION: pre_IRSCAN
*
* DESCRIPTION: Sets up the state machine to accept an IR SCAN
*
* INPUT PARAMETERS: void
*
* RETURNS: void
*
*******************************************************************************
*/
void pre_IRSCAN()
{
#ifdef DEBUG
printf("begin pre-IR scan code\n");
#endif
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,1,IGNORE_PORT);
putp(1,1,IGNORE_PORT); //select IR scan
putp(1,0,IGNORE_PORT); //capture IR
putp(1,0,IGNORE_PORT); //shift IR
}
/*
*******************************************************************************
*
* FUNCTION: post_IRSCAN
*
* DESCRIPTION: Get back to IDLE after scanning in the instruction
*
* INPUT PARAMETERS: void
*
* RETURNS: void
*
*******************************************************************************
*/
void post_IRSCAN()
{
#ifdef DEBUG
printf("begin post-IR scan code\n");
#endif
//putp(1,1,IGNORE_PORT); //Exit1-IR
putp(1,1,IGNORE_PORT); //Update-IR
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
}
/*
*******************************************************************************
*
* FUNCTION: pre_DRSCAN
*
* DESCRIPTION: Sets up the state machine to accept an DR SCAN
*
* INPUT PARAMETERS: void
*
* RETURNS: void
*
*******************************************************************************
*/
void pre_DRSCAN()
{
#ifdef DEBUG
printf("begin pre-DR scan code\n");
#endif
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,1,IGNORE_PORT); //select DR scan
putp(1,0,IGNORE_PORT); //capture DR
// putp(1,0,IGNORE_PORT); //shift DR
}
/*
*******************************************************************************
*
* FUNCTION: post_DRSCAN
*
* DESCRIPTION: Get back to IDLE after scanning in the data register
*
* INPUT PARAMETERS: void
*
* RETURNS: void
*
*******************************************************************************
*/
void post_DRSCAN()
{
#ifdef DEBUG
printf("begin post-DR scan code\n");
#endif
putp(1,1,IGNORE_PORT); //Exit1-DR
putp(1,1,IGNORE_PORT); //Update-DR
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
putp(1,0,IGNORE_PORT); //Run-Test/Idle
}
/*
*******************************************************************************
*
* FUNCTION: controller_scan_code
*
* DESCRIPTION: clocks in a specified cotulla IR scan code
*
* INPUT PARAMETERS: int instruction code
* int read or ignore port
* int continue or terminate instruction stream
*
* RETURNS: void
*
*******************************************************************************
*/
int controller_scan_code(int code, int rp, int ct)
{
int i;
int outval = 0;
int tms = 0;
#ifdef DEBUG
printf("begin controller scan code\n");
#endif
for (i = 0; i < COTULLA_IRLENGTH; i++)
{
if (ct == TERMINATE)
{
if (i == COTULLA_IRLENGTH -1)
{
tms = 1;
}
}
outval |= putp(((code & (1 << i)) >> i), tms, rp) << (COTULLA_IRLENGTH - i - 1);
}
#ifdef DEBUG
printf("Controller IR value: %X\n", outval);
#endif
return outval;
}
/*
*******************************************************************************
*
* FUNCTION: PZ_scan_code
*
* DESCRIPTION: clocks in a specified PZxxxx IR scan code
*
* INPUT PARAMETERS: int code
*
* RETURNS: void
*
*******************************************************************************
*/
int PZ_scan_code(int code, int rp, int ct)
{
int i;
int outval = 0;
int tms = 0;
#ifdef DEBUG
printf("begin PZ scan code\n");
#endif
for (i = 0; i < PZ_IRLENGTH; i++)
{
if (ct == TERMINATE)
{
if (i == PZ_IRLENGTH -1)
{
tms = 1;
}
}
outval |= putp(((code & (1 << i)) >> i), tms, rp) << (PZ_IRLENGTH - i - 1);
}
return outval;
}
/*
*******************************************************************************
*
* FUNCTION: jtag_test
*
* DESCRIPTION: tests the JTAG connection by reading the steady state
* instruction register.
*
* INPUT PARAMETERS: void
*
* RETURNS: int - 0 if passed
*
*******************************************************************************
*/
void jtag_test()
{
// set all devices into bypass mode as a safe instruction
pre_IRSCAN();
#ifdef SANDGATE_PLATFORM
if (controller_scan_code(COT_BYPASS, READ_PORT, CONTINUE) != 0x1)
{
error_out("Jtag test failure. Check connections and power.\n");
}
PZ_scan_code(PZ_BYPASS, IGNORE_PORT, CONTINUE); // PZ3128
PZ_scan_code(PZ_BYPASS, IGNORE_PORT, TERMINATE); // PZ3032
#endif //SANDGATE_PLATFORM
#ifdef ASSABET_PLATFORM
#ifndef LUBBOCK_SA1110
if (controller_scan_code(SA_BYPASS, READ_PORT, CONTINUE) != 0x1)
{
error_out("Jtag test failure. Check connections and power.\n");
}
PZ_scan_code(PZ_BYPASS, IGNORE_PORT, CONTINUE); // PZ3128
PZ_scan_code(PZ_BYPASS, IGNORE_PORT, TERMINATE); // PZ3032
#else
if (controller_scan_code(SA_BYPASS, READ_PORT, TERMINATE) != 0x1)
{
error_out("Jtag test failure. Check connections and power.\n");
}
#endif
#endif //SANDGATE_PLATFORM
#ifdef LUBBOCK_PLATFORM
if (controller_scan_code(COT_BYPASS, READ_PORT, TERMINATE) != 0x1)
{
error_out("Jtag test failure. Check connections and power.\n");
}
#endif //LUBBOCK_PLATFORM
post_IRSCAN();
printf("JTAG Test Passed\n");
}
/*
*******************************************************************************
*
* FUNCTION: dump_chain
*
* DESCRIPTION: This is a debug routine that dumps the contents of the
* current boundary chain to the standard I/O.
*
* INPUT PARAMETERS: void
*
* RETURNS: void
*
*******************************************************************************
*/
void dump_chain()
{
DWORD addrdat = 0;
DWORD obusdat = 0;
DWORD ibusdat = 0;
int i;
printf("------------------------------------------------------\n");
for(i = 0; i < 32; i++) // convert serial data to single DWORD
{
obusdat = obusdat | (DWORD)((int)pin[dat_order[i]] << i);
}
printf("Data Bus (Output) = %X\n", obusdat);
for(i = 0; i < 32; i++) // convert serial data to single DWORD
{
ibusdat = ibusdat | (DWORD)((int)pin[input_dat_order[i]] << i);
}
printf("Data Bus (Input) = %X\n", ibusdat);
for(i = 0; i < 26; i++) // convert address data into single DWORD
{
addrdat = addrdat | (DWORD)((int)pin[addr_order[i]] << i);
}
printf("Address Bus = %X\n", addrdat);
printf("Flash address is: %X\n",addrdat >> 2);
printf("Chip Select 0 = %d\n", (int)pin[nCS0_OUT]);
printf("Chip Select 1 = %d\n", (int)pin[nCS1_OUT]);
printf("Chip Select 2 = %d\n", (int)pin[nCS2_OUT]);
printf("Chip Select 3 = %d\n", (int)pin[nCS3_OUT]);
printf("Chip Select 4 = %d\n", (int)pin[nCS4_OUT]);
printf("Chip Select 5 = %d\n", (int)pin[nCS5_OUT]);
printf("Mem Out Enable = %d\n", (int)pin[nOE_OUT]);
printf("Mem Write Enable = %d\n", (int)pin[nWE_OUT]);
printf("Mem READ/WRITE Mode = %d\n", (int)pin[RD_nWR_OUT]);
printf("------------------------------------------------------\n");
}
/*
*******************************************************************************
*
* FUNCTION: invert_workbuf (not used at this time)
*
* DESCRIPTION: inverts the workbuffer
*
* INPUT PARAMETERS: void
*
* RETURNS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -