zy1000: switch to pthread
authorØyvind Harboe <oyvind.harboe@zylin.com>
Thu, 3 Mar 2011 09:16:17 +0000 (10:16 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 15 Mar 2011 09:36:17 +0000 (10:36 +0100)
pthreads work under Linux and eCos.

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

index f972191731c751f33b6f4b01509d1a606207af83..71ae6f43740cc7f897e4646e74a9210988d0c303 100644 (file)
@@ -45,6 +45,8 @@
 #include "config.h"
 #endif
 
+#include <pthread.h>
+
 #include <target/embeddedice.h>
 #include <jtag/minidriver.h>
 #include <jtag/interface.h>
@@ -1026,7 +1028,6 @@ static const struct command_registration zy1000_commands[] = {
 };
 
 
-#if !BUILD_ZY1000_MASTER || BUILD_ECOSBOARD
 static int tcp_ip = -1;
 
 /* Write large packets if we can */
@@ -1098,7 +1099,6 @@ static bool readLong(uint32_t *out_data)
        *out_data = data;
        return true;
 }
-#endif
 
 enum ZY1000_CMD
 {
@@ -1353,14 +1353,15 @@ static void writeShiftValue(uint8_t *data, int bits)
 
 #endif
 
-#if BUILD_ECOSBOARD
-static char tcpip_stack[2048];
-static cyg_thread tcpip_thread_object;
-static cyg_handle_t tcpip_thread_handle;
+#if BUILD_ZY1000_MASTER
+
+pthread_t thread;
 
+#if BUILD_ECOSBOARD
 static char watchdog_stack[2048];
 static cyg_thread watchdog_thread_object;
 static cyg_handle_t watchdog_thread_handle;
+#endif
 
 /* Infinite loop peeking & poking */
 static void tcpipserver(void)
@@ -1412,7 +1413,7 @@ static void tcpipserver(void)
 }
 
 
-static void tcpip_server(cyg_addrword_t data)
+static void *tcpip_server(void *data)
 {
        int so_reuseaddr_option = 1;
 
@@ -1474,8 +1475,10 @@ static void tcpip_server(cyg_addrword_t data)
                close(tcp_ip);
 
        }
+       /* Never reached actually */
        close(fd);
 
+       return NULL;
 }
 
 #ifdef WATCHDOG_BASE
@@ -1616,18 +1619,17 @@ int zy1000_init(void)
                return retval;
        zy1000_speed(jtag_speed_var);
 
+#if BUILD_ZY1000_MASTER
+       pthread_create(&thread, NULL, tcpip_server, NULL);
 
 #if BUILD_ECOSBOARD
-       cyg_thread_create(1, tcpip_server, (cyg_addrword_t) 0, "tcip/ip server",
-                       (void *) tcpip_stack, sizeof(tcpip_stack),
-                       &tcpip_thread_handle, &tcpip_thread_object);
-       cyg_thread_resume(tcpip_thread_handle);
 #ifdef WATCHDOG_BASE
        cyg_thread_create(1, watchdog_server, (cyg_addrword_t) 0, "watchdog tcip/ip server",
                        (void *) watchdog_stack, sizeof(watchdog_stack),
                        &watchdog_thread_handle, &watchdog_thread_object);
        cyg_thread_resume(watchdog_thread_handle);
 #endif
+#endif
 #endif
 
        return ERROR_OK;

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)