Skip to content

Commit

Permalink
Merge pull request #10 from lovely-bird/riscv_spinal
Browse files Browse the repository at this point in the history
Fix build issue under MinGW cross-compling
  • Loading branch information
Dolu1990 authored Apr 18, 2020
2 parents 4e27f38 + 61756b9 commit 486df52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/jtag/drivers/jtag_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@

#include <jtag/interface.h>
#include <stdio.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "hello.h"
#include <netinet/tcp.h>
#endif
#include <string.h>
#include <fcntl.h>
#include "hello.h"

/* my private tap controller state, which tracks state for calling code */
static tap_state_t jtag_tcp_state;
Expand Down
16 changes: 10 additions & 6 deletions src/target/vexriscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
#include "vexriscv.h"
#include "semihosting_common.h"
#include <stdio.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <yaml.h>
#include <errno.h>
#include "algorithm.h"
Expand Down Expand Up @@ -1056,7 +1060,7 @@ static int vexriscv_network_read(struct vexriscv_common *vexriscv, void *buffer,
if (ret != sizeof(wb_buffer))
return 0;
memcpy(&intermediate, &wb_buffer[16], sizeof(intermediate));
intermediate = be32toh(intermediate);
intermediate = ntohl(intermediate);
memcpy(buffer, &intermediate, sizeof(intermediate));
return 4;
}
Expand Down Expand Up @@ -1101,15 +1105,15 @@ static int vexriscv_network_write(struct vexriscv_common *vexriscv, int is_read,

if (is_read) {
wb_buffer[11] = 1; // Read count
data = htobe32(address);
data = htonl(address);
memcpy(&wb_buffer[16], &data, sizeof(data));
}
else {
wb_buffer[10] = 1; // Write count
address = htobe32(address);
address = htonl(address);
memcpy(&wb_buffer[12], &address, sizeof(address));

data = htobe32(data);
data = htonl(data);
memcpy(&wb_buffer[16], &data, sizeof(data));
}
return write(vexriscv->clientSocket, wb_buffer, sizeof(wb_buffer));
Expand Down

0 comments on commit 486df52

Please sign in to comment.