#define TEST_MANUAL() 0
#define VERBOSE(a)
-#if BUILD_ECOSBOARD
+#if BUILD_ZY1000_MASTER
+#if BUILD_ECOSBOARD
#include <cyg/hal/hal_io.h> // low level i/o
#include <cyg/hal/hal_intr.h> // low level i/o
#define ZY1000_PEEK(a, b) HAL_READ_UINT32(a, b)
#define ZY1000_POKE(a, b) HAL_WRITE_UINT32(a, b)
+#else
+#define ZY1000_PEEK(a, b) do {b = *( ( volatile uint32_t *)(a) );} while (0)
+#define ZY1000_POKE(a, b) do {*( ( volatile uint32_t *)(a) ) = b;} while (0)
+extern volatile void *zy1000_jtag_master;
+#define ZY1000_JTAG_BASE ((unsigned long)zy1000_jtag_master)
+#endif
#else
-#if BUILD_ECOSBOARD
+#if BUILD_ZY1000_MASTER
// FIFO empty?
static __inline__ void waitIdle(void)
{
}
}
-#if BUILD_ECOSBOARD
+#if BUILD_ZY1000_MASTER
#define interface_jtag_add_callback(callback, in) callback(in)
#define interface_jtag_add_callback4(callback, in, data1, data2, data3) jtag_set_error(callback(in, data1, data2, data3))
#else
return ERROR_OK;
}
-#if !BUILD_ECOSBOARD
+#if !BUILD_ZY1000_MASTER
static char *tcp_server = "notspecified";
static int jim_zy1000_server(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
"With no arguments, prints status.",
.usage = "('on'|'off)",
},
+#if BUILD_ZY1000_MASTER
#if BUILD_ECOSBOARD
{
.name = "zy1000_version",
.help = "Print version info for zy1000.",
.usage = "['openocd'|'zy1000'|'date'|'time'|'pcb'|'fpga']",
},
+#endif
#else
{
.name = "zy1000_server",
};
+#if !BUILD_ZY1000_MASTER || BUILD_ECOSBOARD
static int tcp_ip = -1;
/* Write large packets if we can */
*out_data = data;
return true;
}
+#endif
enum ZY1000_CMD
{
};
-#if !BUILD_ECOSBOARD
+#if !BUILD_ZY1000_MASTER
#include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
}
#endif
+#endif
+
+#if BUILD_ZY1000_MASTER
int interface_jtag_add_sleep(uint32_t us)
{
jtag_sleep(us);
return ERROR_OK;
}
-
#endif
+#if BUILD_ZY1000_MASTER && !BUILD_ECOSBOARD
+volatile void *zy1000_jtag_master;
+#include <sys/mman.h>
+#endif
int zy1000_init(void)
{
#if BUILD_ECOSBOARD
LOG_USER("%s", ZYLIN_OPENOCD_VERSION);
+#else
+ int fd;
+ if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
+ {
+ LOG_ERROR("No access to /dev/mem");
+ return ERROR_FAIL;
+ }
+#ifndef REGISTERS_BASE
+#define REGISTERS_BASE 0x9002000
+#define REGISTERS_SPAN 128
+#endif
+
+ zy1000_jtag_master = mmap(0, REGISTERS_SPAN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, REGISTERS_BASE);
+
+ if(zy1000_jtag_master == (void *) -1)
+ {
+ close(fd);
+ LOG_ERROR("No access to /dev/mem");
+ return ERROR_FAIL;
+ }
#endif
+
+
ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x30); // Turn on LED1 & LED2
setPower(true); // on by default