#include <string.h>
#include <unistd.h>
#include <sys/select.h>
-#include <sys/types.h> /* See NOTES */
+#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
connfd = accept(listenfd, (struct sockaddr*)NULL, NULL);
close(listenfd);
- setsockopt(connfd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+ setsockopt(connfd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
return connfd;
}
-/*
-
-static void accept_conn_cb(struct evconnlistener *listener, evutil_socket_t fd, struct sockaddr *address, int socklen, void *ctx)
-{
- struct session_s *s = (struct session_s*)ctx;
- struct timeval tv = {1, 0};
-
- s->fd = fd;
- s->ev = event_new(base, fd, EV_READ | EV_PERSIST , event_handler, s);
- event_add(s->ev, &tv);
-}
-
-static int jtagremote_new(void **sess, char *args)
-{
- int ret = RC_OK;
- struct session_s *s = NULL;
- char *cport = NULL;
- int port;
- struct evconnlistener *listener;
- struct sockaddr_in sin;
-
- if(!sess) {
- ret = RC_INVARG;
- goto out;
- }
-
- ret = litex_sim_module_get_args(args, "port", &cport);
- if(RC_OK != ret)
- goto out;
-
- printf("Found port %s\n", cport);
- sscanf(cport, "%d", &port);
- free(cport);
- if(!port) {
- ret = RC_ERROR;
- fprintf(stderr, "Invalid port selected!\n");
- goto out;
- }
-
- s=(struct session_s*)malloc(sizeof(struct session_s));
- if(!s) {
- ret = RC_NOENMEM;
- goto out;
- }
- memset(s, 0, sizeof(struct session_s));
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = htonl(0);
- sin.sin_port = htons(port);
- listener = evconnlistener_new_bind(base, accept_conn_cb, s, LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, (struct sockaddr*)&sin, sizeof(sin));
- if (!listener) {
- ret=RC_ERROR;
- eprintf("Can't bind port %d\n!\n", port);
- goto out;
- }
- evconnlistener_set_error_cb(listener, accept_error_cb);
-
-out:
- *sess=(void*)s;
- return ret;
-}
-
-*/
-
} // extern "C"
+/* main function which polls the socket and talks openocd jtagremote protocol.
+ dead simple: incoming number 0-7 sets TCK, TMS and TDK. request "R"
+ indicates that receiver wants to know the status of TDO.
+ "Q" means "quit socket".
+*/
void read_openocd_jtagremote(cxxrtl_design::p_add &top, int sock)
{
char c;
/* read and process incoming jtag */
read_openocd_jtagremote(top, sock);
- // check that the output is correct
+ // quick check that the output is correct (it's an adder: go figure)
/*
top.p_a.set<uint8_t>(5);
top.p_b.set<uint8_t>(3);