zy1000: add support for Linux host
authorØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 7 Sep 2010 18:27:45 +0000 (20:27 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 20 Sep 2010 18:45:16 +0000 (20:45 +0200)
used /dev/mem and mmem() to memory map JTAG registers
into user space and used new configure options to exclude
eCos specific code.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/jtag/zy1000/jtag_minidriver.h
src/jtag/zy1000/zy1000.c

index 4e99d3cbf71d770f5ccd0049c4f89b9bd2e65554..543fd9bbae0c99cc3cc6b5fa33e7be5b74ed41b2 100644 (file)
 #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
 
@@ -41,7 +48,7 @@ extern uint32_t zy1000_tcpin(uint32_t address);
 
 
 
-#if BUILD_ECOSBOARD
+#if BUILD_ZY1000_MASTER
 // FIFO empty?
 static __inline__ void waitIdle(void)
 {
@@ -228,7 +235,7 @@ static __inline__ void interface_jtag_add_dr_out(struct jtag_tap *target_tap,
        }
 }
 
-#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
index 3ecd0f9bd31ecf292ccc5b4f8e148753495679e3..c939d7f29b5bbc62e86d7133e69ee1031d0a91b6 100644 (file)
@@ -321,7 +321,7 @@ COMMAND_HANDLER(handle_power_command)
        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)
 {
@@ -1002,6 +1002,7 @@ static const struct command_registration zy1000_commands[] = {
                        "With no arguments, prints status.",
                .usage = "('on'|'off)",
        },
+#if BUILD_ZY1000_MASTER
 #if BUILD_ECOSBOARD
        {
                .name = "zy1000_version",
@@ -1010,6 +1011,7 @@ static const struct command_registration zy1000_commands[] = {
                .help = "Print version info for zy1000.",
                .usage = "['openocd'|'zy1000'|'date'|'time'|'pcb'|'fpga']",
        },
+#endif
 #else
        {
                .name = "zy1000_server",
@@ -1038,6 +1040,7 @@ static const struct command_registration zy1000_commands[] = {
 };
 
 
+#if !BUILD_ZY1000_MASTER || BUILD_ECOSBOARD
 static int tcp_ip = -1;
 
 /* Write large packets if we can */
@@ -1106,6 +1109,7 @@ static bool readLong(uint32_t *out_data)
        *out_data = data;
        return true;
 }
+#endif
 
 enum ZY1000_CMD
 {
@@ -1116,7 +1120,7 @@ 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() */
@@ -1566,21 +1570,49 @@ static void watchdog_server(cyg_addrword_t data)
 }
 #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

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)