2008-09-27 08:00:01 -05:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2007-2008 by <EFBFBD>yvind Harboe *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
|
#include "jtag.h"
|
|
|
|
|
#include "bitbang.h"
|
|
|
|
|
#include "../target/embeddedice.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <cyg/hal/hal_io.h> // low level i/o
|
|
|
|
|
#include <cyg/hal/hal_diag.h>
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
#define ZYLIN_VERSION "1.48"
|
|
|
|
|
#define ZYLIN_DATE __DATE__
|
|
|
|
|
#define ZYLIN_TIME __TIME__
|
|
|
|
|
#define ZYLIN_OPENOCD "$Revision: 1241 $"
|
|
|
|
|
#define ZYLIN_OPENOCD_VERSION "Zylin JTAG ZY1000 " ZYLIN_VERSION " " ZYLIN_DATE " " ZYLIN_TIME
|
|
|
|
|
const char *zylin_config_dir="/config/settings";
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
extern int jtag_error;
|
|
|
|
|
|
|
|
|
|
/* low level command set
|
|
|
|
|
*/
|
2008-11-05 01:45:31 -06:00
|
|
|
|
int zy1000_read(void);
|
|
|
|
|
static void zy1000_write(int tck, int tms, int tdi);
|
|
|
|
|
void zy1000_reset(int trst, int srst);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
int zy1000_speed(int speed);
|
|
|
|
|
int zy1000_register_commands(struct command_context_s *cmd_ctx);
|
|
|
|
|
int zy1000_init(void);
|
|
|
|
|
int zy1000_quit(void);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
/* interface commands */
|
2008-11-05 01:45:31 -06:00
|
|
|
|
int zy1000_handle_zy1000_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
static int zy1000_khz(int khz, int *jtag_speed)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (khz==0)
|
|
|
|
|
{
|
|
|
|
|
*jtag_speed=0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*jtag_speed=64000/khz;
|
|
|
|
|
}
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
static int zy1000_speed_div(int speed, int *khz)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (speed==0)
|
|
|
|
|
{
|
|
|
|
|
*khz = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*khz=64000/speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
static bool readPowerDropout()
|
|
|
|
|
{
|
|
|
|
|
cyg_uint32 state;
|
|
|
|
|
// sample and clear power dropout
|
2008-11-26 07:31:26 -06:00
|
|
|
|
HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x80);
|
|
|
|
|
HAL_READ_UINT32(ZY1000_JTAG_BASE+0x10, state);
|
2008-11-05 01:45:31 -06:00
|
|
|
|
bool powerDropout;
|
|
|
|
|
powerDropout = (state & 0x80) != 0;
|
|
|
|
|
return powerDropout;
|
|
|
|
|
}
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
|
|
|
|
|
static bool readSRST()
|
|
|
|
|
{
|
|
|
|
|
cyg_uint32 state;
|
|
|
|
|
// sample and clear SRST sensing
|
2008-11-26 07:31:26 -06:00
|
|
|
|
HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x00000040);
|
|
|
|
|
HAL_READ_UINT32(ZY1000_JTAG_BASE+0x10, state);
|
2008-11-05 01:45:31 -06:00
|
|
|
|
bool srstAsserted;
|
|
|
|
|
srstAsserted = (state & 0x40) != 0;
|
|
|
|
|
return srstAsserted;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 06:09:35 -06:00
|
|
|
|
static int zy1000_srst_asserted(int *srst_asserted)
|
|
|
|
|
{
|
|
|
|
|
*srst_asserted=readSRST();
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
static int zy1000_power_dropout(int *dropout)
|
|
|
|
|
{
|
2008-11-11 06:09:35 -06:00
|
|
|
|
*dropout=readPowerDropout();
|
2008-11-05 01:45:31 -06:00
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jtag_interface_t zy1000_interface =
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
.name = "ZY1000",
|
|
|
|
|
.execute_queue = bitbang_execute_queue,
|
2008-11-05 01:45:31 -06:00
|
|
|
|
.speed = zy1000_speed,
|
|
|
|
|
.register_commands = zy1000_register_commands,
|
|
|
|
|
.init = zy1000_init,
|
|
|
|
|
.quit = zy1000_quit,
|
|
|
|
|
.khz = zy1000_khz,
|
|
|
|
|
.speed_div = zy1000_speed_div,
|
|
|
|
|
.power_dropout = zy1000_power_dropout,
|
2008-11-11 06:09:35 -06:00
|
|
|
|
.srst_asserted = zy1000_srst_asserted,
|
2008-09-27 08:00:01 -05:00
|
|
|
|
};
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
bitbang_interface_t zy1000_bitbang =
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-11-05 01:45:31 -06:00
|
|
|
|
.read = zy1000_read,
|
|
|
|
|
.write = zy1000_write,
|
|
|
|
|
.reset = zy1000_reset
|
2008-09-27 08:00:01 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
static void zy1000_write(int tck, int tms, int tdi)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
int zy1000_read(void)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern bool readSRST();
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
void zy1000_reset(int trst, int srst)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst);
|
|
|
|
|
if(!srst)
|
|
|
|
|
{
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Danger!!! if clk!=0 when in
|
2008-12-13 00:25:50 -06:00
|
|
|
|
* idle in TAP_IDLE, reset halt on str912 will fail.
|
2008-09-27 08:00:01 -05:00
|
|
|
|
*/
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!trst)
|
|
|
|
|
{
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* assert reset */
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000002);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
2008-11-05 01:45:31 -06:00
|
|
|
|
|
2008-09-27 08:00:01 -05:00
|
|
|
|
if (trst||(srst&&(jtag_reset_config & RESET_SRST_PULLS_TRST)))
|
|
|
|
|
{
|
|
|
|
|
waitIdle();
|
2008-12-13 00:59:24 -06:00
|
|
|
|
/* we're now in the RESET state until trst is deasserted */
|
2008-12-13 00:25:50 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x20, TAP_RESET);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
/* We'll get RCLK failure when we assert TRST, so clear any false positives here */
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* wait for srst to float back up */
|
|
|
|
|
if (!srst)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0; i<1000; i++)
|
|
|
|
|
{
|
|
|
|
|
// We don't want to sense our own reset, so we clear here.
|
|
|
|
|
// There is of course a timing hole where we could loose
|
|
|
|
|
// a "real" reset.
|
|
|
|
|
if (!readSRST())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* wait 1ms */
|
|
|
|
|
alive_sleep(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i==1000)
|
|
|
|
|
{
|
|
|
|
|
LOG_USER("SRST didn't deassert after %dms", i);
|
|
|
|
|
} else if (i>1)
|
|
|
|
|
{
|
|
|
|
|
LOG_USER("SRST took %dms to deassert", i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
int zy1000_speed(int speed)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
if(speed == 0)
|
|
|
|
|
{
|
|
|
|
|
/*0 means RCLK*/
|
|
|
|
|
speed = 0;
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x100);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
LOG_DEBUG("jtag_speed using RCLK");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(speed > 8190 || speed < 2)
|
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz");
|
2008-09-27 08:00:01 -05:00
|
|
|
|
return ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed);
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x100);
|
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x1c, speed&~1);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
static bool savePower;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
static void setPower(bool power)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
savePower = power;
|
|
|
|
|
if (power)
|
|
|
|
|
{
|
|
|
|
|
HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x14, 0x8);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x8);
|
|
|
|
|
}
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
int handle_power_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
if (argc > 1)
|
|
|
|
|
{
|
|
|
|
|
return ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(args[0], "on") == 0)
|
|
|
|
|
{
|
|
|
|
|
setPower(1);
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(args[0], "off") == 0)
|
|
|
|
|
{
|
|
|
|
|
setPower(0);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
command_print(cmd_ctx, "arg is \"on\" or \"off\"");
|
|
|
|
|
return ERROR_INVALID_ARGUMENTS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
command_print(cmd_ctx, "Target power %s", savePower ? "on" : "off");
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
/* Give TELNET a way to find out what version this is */
|
|
|
|
|
int handle_zy1000_version_command(struct command_context_s *cmd_ctx, char *cmd,
|
|
|
|
|
char **args, int argc)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
if (argc > 1)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
2008-12-15 05:32:22 -06:00
|
|
|
|
if (argc == 0)
|
2008-12-14 14:33:01 -06:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
command_print(cmd_ctx, ZYLIN_OPENOCD_VERSION);
|
2008-12-14 14:33:01 -06:00
|
|
|
|
}
|
2008-12-15 05:32:22 -06:00
|
|
|
|
else if (strcmp("openocd", args[0]) == 0)
|
2008-12-14 14:33:01 -06:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
int revision;
|
|
|
|
|
revision = atol(ZYLIN_OPENOCD+strlen("XRevision: "));
|
|
|
|
|
command_print(cmd_ctx, "%d", revision);
|
2008-12-14 14:33:01 -06:00
|
|
|
|
}
|
2008-12-15 05:32:22 -06:00
|
|
|
|
else if (strcmp("zy1000", args[0]) == 0)
|
2008-12-14 14:33:01 -06:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
command_print(cmd_ctx, "%s", ZYLIN_VERSION);
|
2008-12-14 14:33:01 -06:00
|
|
|
|
}
|
2008-12-15 05:32:22 -06:00
|
|
|
|
else if (strcmp("date", args[0]) == 0)
|
2008-12-14 14:33:01 -06:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
command_print(cmd_ctx, "%s", ZYLIN_DATE);
|
2008-12-14 14:33:01 -06:00
|
|
|
|
}
|
2008-12-15 05:32:22 -06:00
|
|
|
|
else
|
2008-12-14 14:33:01 -06:00
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2008-12-14 14:33:01 -06:00
|
|
|
|
}
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-12-14 14:33:01 -06:00
|
|
|
|
return ERROR_OK;
|
2008-12-15 05:32:22 -06:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-12-17 08:07:03 -06:00
|
|
|
|
static int
|
|
|
|
|
zylinjtag_Jim_Command_powerstatus(Jim_Interp *interp,
|
|
|
|
|
int argc,
|
|
|
|
|
Jim_Obj * const *argv)
|
|
|
|
|
{
|
|
|
|
|
if (argc != 1)
|
|
|
|
|
{
|
|
|
|
|
Jim_WrongNumArgs(interp, 1, argv, "powerstatus");
|
|
|
|
|
return JIM_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cyg_uint32 status;
|
|
|
|
|
ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, status);
|
|
|
|
|
|
|
|
|
|
Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80)!=0));
|
|
|
|
|
|
|
|
|
|
return JIM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
int zy1000_register_commands(struct command_context_s *cmd_ctx)
|
|
|
|
|
{
|
|
|
|
|
register_command(cmd_ctx, NULL, "power", handle_power_command, COMMAND_ANY,
|
|
|
|
|
"power <on/off> - turn power switch to target on/off. No arguments - print status.");
|
|
|
|
|
register_command(cmd_ctx, NULL, "zy1000_version", handle_zy1000_version_command,
|
|
|
|
|
COMMAND_EXEC, "show zy1000 version numbers");
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-12-17 08:07:03 -06:00
|
|
|
|
Jim_CreateCommand(interp, "powerstatus", zylinjtag_Jim_Command_powerstatus, NULL, NULL);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-17 08:07:03 -06:00
|
|
|
|
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
int zy1000_init(void)
|
|
|
|
|
{
|
2008-12-17 08:55:12 -06:00
|
|
|
|
LOG_USER("%s", ZYLIN_OPENOCD_VERSION);
|
2008-12-15 05:32:22 -06:00
|
|
|
|
|
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x30); // Turn on LED1 & LED2
|
|
|
|
|
|
|
|
|
|
setPower(true); // on by default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
|
|
|
|
|
zy1000_reset(0, 0);
|
|
|
|
|
zy1000_speed(jtag_speed);
|
|
|
|
|
|
|
|
|
|
bitbang_interface = &zy1000_bitbang;
|
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int zy1000_quit(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int interface_jtag_execute_queue(void)
|
|
|
|
|
{
|
|
|
|
|
cyg_uint32 empty;
|
|
|
|
|
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, empty);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
/* clear JTAG error register */
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
if ((empty&0x400)!=0)
|
|
|
|
|
{
|
|
|
|
|
LOG_WARNING("RCLK timeout");
|
|
|
|
|
/* the error is informative only as we don't want to break the firmware if there
|
|
|
|
|
* is a false positive.
|
|
|
|
|
*/
|
|
|
|
|
// return ERROR_FAIL;
|
|
|
|
|
}
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static cyg_uint32 getShiftValue()
|
|
|
|
|
{
|
|
|
|
|
cyg_uint32 value;
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_PEEK(ZY1000_JTAG_BASE+0xc, value);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
VERBOSE(LOG_INFO("getShiftValue %08x", value));
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
#if 0
|
|
|
|
|
static cyg_uint32 getShiftValueFlip()
|
|
|
|
|
{
|
|
|
|
|
cyg_uint32 value;
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_PEEK(ZY1000_JTAG_BASE+0x18, value);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
VERBOSE(LOG_INFO("getShiftValue %08x (flipped)", value));
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static void shiftValueInnerFlip(const enum tap_state state, const enum tap_state endState, int repeat, cyg_uint32 value)
|
|
|
|
|
{
|
2008-12-14 14:33:01 -06:00
|
|
|
|
VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", jtag_state_name(state), jtag_state_name(endState), repeat, value));
|
2008-09-27 08:00:01 -05:00
|
|
|
|
cyg_uint32 a,b;
|
|
|
|
|
a=state;
|
|
|
|
|
b=endState;
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0xc, value);
|
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x8, (1<<15)|(repeat<<8)|(a<<4)|b);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
VERBOSE(getShiftValueFlip());
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern int jtag_check_value(u8 *captured, void *priv);
|
|
|
|
|
|
|
|
|
|
static void gotoEndState()
|
|
|
|
|
{
|
|
|
|
|
setCurrentState(cmd_queue_end_state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static __inline void scanFields(int num_fields, scan_field_t *fields, enum tap_state shiftState, int pause)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int j;
|
|
|
|
|
int k;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_fields; i++)
|
|
|
|
|
{
|
|
|
|
|
cyg_uint32 value;
|
|
|
|
|
|
|
|
|
|
static u8 *in_buff=NULL; /* pointer to buffer for scanned data */
|
|
|
|
|
static int in_buff_size=0;
|
|
|
|
|
u8 *inBuffer=NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// figure out where to store the input data
|
|
|
|
|
int num_bits=fields[i].num_bits;
|
|
|
|
|
if (fields[i].in_value!=NULL)
|
|
|
|
|
{
|
|
|
|
|
inBuffer=fields[i].in_value;
|
|
|
|
|
} else if (fields[i].in_handler!=NULL)
|
|
|
|
|
{
|
|
|
|
|
if (in_buff_size*8<num_bits)
|
|
|
|
|
{
|
|
|
|
|
// we need more space
|
|
|
|
|
if (in_buff!=NULL)
|
|
|
|
|
free(in_buff);
|
|
|
|
|
in_buff=NULL;
|
|
|
|
|
in_buff_size=(num_bits+7)/8;
|
|
|
|
|
in_buff=malloc(in_buff_size);
|
|
|
|
|
if (in_buff==NULL)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("Out of memory");
|
|
|
|
|
jtag_error=ERROR_JTAG_QUEUE_FAILED;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
inBuffer=in_buff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// here we shuffle N bits out/in
|
|
|
|
|
j=0;
|
|
|
|
|
while (j<num_bits)
|
|
|
|
|
{
|
|
|
|
|
enum tap_state pause_state;
|
|
|
|
|
int l;
|
|
|
|
|
k=num_bits-j;
|
2008-12-13 00:25:50 -06:00
|
|
|
|
pause_state=(shiftState==TAP_DRSHIFT)?TAP_DRSHIFT:TAP_IRSHIFT;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
if (k>32)
|
|
|
|
|
{
|
|
|
|
|
k=32;
|
|
|
|
|
/* we have more to shift out */
|
|
|
|
|
} else if (pause&&(i == num_fields-1))
|
|
|
|
|
{
|
|
|
|
|
/* this was the last to shift out this time */
|
2008-12-13 00:25:50 -06:00
|
|
|
|
pause_state=(shiftState==TAP_DRSHIFT)?TAP_DRPAUSE:TAP_IRPAUSE;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we have (num_bits+7)/8 bytes of bits to toggle out.
|
|
|
|
|
// bits are pushed out LSB to MSB
|
|
|
|
|
value=0;
|
|
|
|
|
if (fields[i].out_value!=NULL)
|
|
|
|
|
{
|
|
|
|
|
for (l=0; l<k; l+=8)
|
|
|
|
|
{
|
|
|
|
|
value|=fields[i].out_value[(j+l)/8]<<l;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* mask away unused bits for easier debugging */
|
|
|
|
|
value&=~(((u32)0xffffffff)<<k);
|
|
|
|
|
|
|
|
|
|
shiftValueInner(shiftState, pause_state, k, value);
|
|
|
|
|
|
|
|
|
|
if (inBuffer!=NULL)
|
|
|
|
|
{
|
|
|
|
|
// data in, LSB to MSB
|
|
|
|
|
value=getShiftValue();
|
|
|
|
|
// we're shifting in data to MSB, shift data to be aligned for returning the value
|
|
|
|
|
value >>= 32-k;
|
|
|
|
|
|
|
|
|
|
for (l=0; l<k; l+=8)
|
|
|
|
|
{
|
|
|
|
|
inBuffer[(j+l)/8]=(value>>l)&0xff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
j+=k;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fields[i].in_handler!=NULL)
|
|
|
|
|
{
|
|
|
|
|
// invoke callback
|
|
|
|
|
int r=fields[i].in_handler(inBuffer, fields[i].in_handler_priv, fields+i);
|
|
|
|
|
if (r!=ERROR_OK)
|
|
|
|
|
{
|
2008-12-14 14:33:01 -06:00
|
|
|
|
/* this will cause jtag_execute_queue() to return an error */
|
2008-09-27 08:00:01 -05:00
|
|
|
|
jtag_error=r;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_end_state(enum tap_state state)
|
|
|
|
|
{
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
|
|
|
|
|
{
|
|
|
|
|
|
2008-12-01 08:21:24 -06:00
|
|
|
|
int j;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
int scan_size = 0;
|
2008-12-01 08:21:24 -06:00
|
|
|
|
jtag_tap_t *tap, *nextTap;
|
|
|
|
|
for(tap = jtag_NextEnabledTap(NULL); tap!= NULL; tap=nextTap)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
nextTap=jtag_NextEnabledTap(tap);
|
|
|
|
|
int pause=(nextTap==NULL);
|
|
|
|
|
|
2008-09-27 08:00:01 -05:00
|
|
|
|
int found = 0;
|
2008-11-19 02:22:47 -06:00
|
|
|
|
|
2008-12-01 08:21:24 -06:00
|
|
|
|
scan_size = tap->ir_length;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
/* search the list */
|
|
|
|
|
for (j=0; j < num_fields; j++)
|
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
if (tap == fields[j].tap)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
found = 1;
|
|
|
|
|
|
|
|
|
|
if ((jtag_verify_capture_ir)&&(fields[j].in_handler==NULL))
|
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
jtag_set_check_value(fields+j, tap->expected, tap->expected_mask, NULL);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
} else if (jtag_verify_capture_ir)
|
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
fields[j].in_check_value = tap->expected;
|
|
|
|
|
fields[j].in_check_mask = tap->expected_mask;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
|
scanFields(1, fields+j, TAP_IRSHIFT, pause);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
/* update device information */
|
2008-12-01 08:21:24 -06:00
|
|
|
|
buf_cpy(fields[j].out_value, tap->cur_instr, scan_size);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
2008-12-01 08:21:24 -06:00
|
|
|
|
tap->bypass = 0;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
/* if a device isn't listed, set it to BYPASS */
|
|
|
|
|
u8 ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
|
|
|
|
|
|
|
|
|
|
scan_field_t tmp;
|
|
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
|
|
|
|
tmp.out_value = ones;
|
|
|
|
|
tmp.num_bits = scan_size;
|
2008-12-13 00:25:50 -06:00
|
|
|
|
scanFields(1, &tmp, TAP_IRSHIFT, pause);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
/* update device information */
|
2008-12-01 08:21:24 -06:00
|
|
|
|
buf_cpy(tmp.out_value, tap->cur_instr, scan_size);
|
|
|
|
|
tap->bypass = 1;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gotoEndState();
|
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
|
|
|
|
|
{
|
2008-12-13 00:25:50 -06:00
|
|
|
|
scanFields(num_fields, fields, TAP_IRSHIFT, 1);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
gotoEndState();
|
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*extern jtag_command_t **jtag_get_last_command_p(void);*/
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
|
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
jtag_tap_t *tap, *nextTap;
|
|
|
|
|
for(tap = jtag_NextEnabledTap(NULL); tap!= NULL; tap=nextTap)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
nextTap=jtag_NextEnabledTap(tap);
|
|
|
|
|
int found=0;
|
|
|
|
|
int pause=(nextTap==NULL);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
for (j=0; j < num_fields; j++)
|
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
if (tap == fields[j].tap)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
found = 1;
|
|
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
|
scanFields(1, fields+j, TAP_DRSHIFT, pause);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
scan_field_t tmp;
|
|
|
|
|
/* program the scan field to 1 bit length, and ignore it's value */
|
|
|
|
|
tmp.num_bits = 1;
|
|
|
|
|
tmp.out_value = NULL;
|
|
|
|
|
tmp.out_mask = NULL;
|
|
|
|
|
tmp.in_value = NULL;
|
|
|
|
|
tmp.in_check_value = NULL;
|
|
|
|
|
tmp.in_check_mask = NULL;
|
|
|
|
|
tmp.in_handler = NULL;
|
|
|
|
|
tmp.in_handler_priv = NULL;
|
|
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
|
scanFields(1, &tmp, TAP_DRSHIFT, pause);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gotoEndState();
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
|
|
|
|
|
{
|
2008-12-13 00:25:50 -06:00
|
|
|
|
scanFields(num_fields, fields, TAP_DRSHIFT, 1);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
gotoEndState();
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_tlr()
|
|
|
|
|
{
|
2008-12-13 00:25:50 -06:00
|
|
|
|
setCurrentState(TAP_RESET);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern int jtag_nsrst_delay;
|
|
|
|
|
extern int jtag_ntrst_delay;
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_reset(int req_trst, int req_srst)
|
|
|
|
|
{
|
2008-11-05 01:45:31 -06:00
|
|
|
|
zy1000_reset(req_trst, req_srst);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_runtest(int num_cycles, enum tap_state state)
|
|
|
|
|
{
|
|
|
|
|
/* num_cycles can be 0 */
|
2008-12-13 00:25:50 -06:00
|
|
|
|
setCurrentState(TAP_IDLE);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
/* execute num_cycles, 32 at the time. */
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0; i<num_cycles; i+=32)
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
num=32;
|
|
|
|
|
if (num_cycles-i<num)
|
|
|
|
|
{
|
|
|
|
|
num=num_cycles-i;
|
|
|
|
|
}
|
2008-12-13 00:25:50 -06:00
|
|
|
|
shiftValueInner(TAP_IDLE, TAP_IDLE, num, 0);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if !TEST_MANUAL()
|
|
|
|
|
/* finish in end_state */
|
|
|
|
|
setCurrentState(state);
|
|
|
|
|
#else
|
2008-12-13 00:25:50 -06:00
|
|
|
|
enum tap_state t=TAP_IDLE;
|
2008-09-27 08:00:01 -05:00
|
|
|
|
/* test manual drive code on any target */
|
|
|
|
|
int tms;
|
|
|
|
|
u8 tms_scan = TAP_MOVE(t, state);
|
2008-11-05 01:45:31 -06:00
|
|
|
|
|
2008-09-27 08:00:01 -05:00
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
tms = (tms_scan >> i) & 1;
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x28, tms);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
}
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x20, state);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_sleep(u32 us)
|
|
|
|
|
{
|
|
|
|
|
jtag_sleep(us);
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int interface_jtag_add_pathmove(int num_states, enum tap_state *path)
|
|
|
|
|
{
|
|
|
|
|
int state_count;
|
|
|
|
|
int tms = 0;
|
|
|
|
|
|
|
|
|
|
/*wait for the fifo to be empty*/
|
|
|
|
|
waitIdle();
|
|
|
|
|
|
|
|
|
|
state_count = 0;
|
|
|
|
|
|
|
|
|
|
enum tap_state cur_state=cmd_queue_cur_state;
|
|
|
|
|
|
|
|
|
|
while (num_states)
|
|
|
|
|
{
|
|
|
|
|
if (tap_transitions[cur_state].low == path[state_count])
|
|
|
|
|
{
|
|
|
|
|
tms = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (tap_transitions[cur_state].high == path[state_count])
|
|
|
|
|
{
|
|
|
|
|
tms = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-12-15 05:32:22 -06:00
|
|
|
|
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(path[state_count]));
|
2008-09-27 08:00:01 -05:00
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x28, tms);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
|
|
|
|
|
cur_state = path[state_count];
|
|
|
|
|
state_count++;
|
|
|
|
|
num_states--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
waitIdle();
|
2008-11-26 07:31:26 -06:00
|
|
|
|
ZY1000_POKE(ZY1000_JTAG_BASE+0x20, cur_state);
|
2008-09-27 08:00:01 -05:00
|
|
|
|
return ERROR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-01 08:21:24 -06:00
|
|
|
|
void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, u8 *buffer, int little, int count)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
// static int const reg_addr=0x5;
|
|
|
|
|
enum tap_state end_state=cmd_queue_end_state;
|
2008-12-01 08:21:24 -06:00
|
|
|
|
if (jtag_NextEnabledTap(jtag_NextEnabledTap(NULL))==NULL)
|
2008-09-27 08:00:01 -05:00
|
|
|
|
{
|
|
|
|
|
/* better performance via code duplication */
|
|
|
|
|
if (little)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
2008-12-13 00:25:50 -06:00
|
|
|
|
shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 1));
|
|
|
|
|
shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr|(1<<5));
|
2008-09-27 08:00:01 -05:00
|
|
|
|
buffer+=4;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
2008-12-13 00:25:50 -06:00
|
|
|
|
shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 0));
|
|
|
|
|
shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr|(1<<5));
|
2008-09-27 08:00:01 -05:00
|
|
|
|
buffer+=4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
2008-12-01 08:21:24 -06:00
|
|
|
|
embeddedice_write_reg_inner(tap, reg_addr, fast_target_buffer_get_u32(buffer, little));
|
2008-09-27 08:00:01 -05:00
|
|
|
|
buffer += 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 05:32:22 -06:00
|
|
|
|
int loadFile(const char *fileName, void **data, int *len);
|
|
|
|
|
|
|
|
|
|
/* boolean parameter stored on config */
|
|
|
|
|
int boolParam(char *var)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
char *name = alloc_printf("%s/%s", zylin_config_dir, var);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
|
int len;
|
|
|
|
|
if (loadFile(name, &data, &len) == ERROR_OK)
|
|
|
|
|
{
|
|
|
|
|
if (len > 1)
|
|
|
|
|
len = 1;
|
|
|
|
|
result = strncmp((char *) data, "1", len) == 0;
|
|
|
|
|
free(data);
|
|
|
|
|
}
|
|
|
|
|
free(name);
|
|
|
|
|
return result;
|
|
|
|
|
}
|