restructure: code+libs under src/, runtime resources under data/

Separate the two concerns the repo root was mixing:
- src/   — bs/, modules/, libs/ (code + vendored libs)
- data/  — fpga_registry.yaml, probes.yaml, bsdl_files/, bscan_proxies/,
           scripts/ (everything the tool reads at runtime, CWD-relative)
- doc/   — kept at the root

CMake: repoint DIR_MODULES/DIR_LIBS and add_subdirectory at src/; emit
the binary at the build/ root (build/bs) via CMAKE_RUNTIME_OUTPUT_DIRECTORY
instead of the nested build/src/bs/. The jtag_core ../../libs path still
resolves since modules and libs moved together.

Runtime default paths now point under data/ (fpga.c, probes.c, script.c
bsdl_files lookup, init.c config.script). Docs (README/tutorial/CLAUDE)
updated for the new layout, src/ module paths, and ./build/bs.

Validated on the IGLOO2/FlashPro: profiles, autoinit, and svf_play all
work run from the repo root.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 15:03:25 +02:00
parent cc2ee5d92c
commit d1bdce91dc
84 changed files with 138 additions and 129 deletions

View File

@@ -0,0 +1,202 @@
/*
* JTAG Core library
* Copyright (c) 2008 - 2024 Viveris Technologies
*
* JTAG Core library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* JTAG Core library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with JTAG Core library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file network.c
* @brief Basic/generic network functions wrapper.
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <stdint.h>
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <commctrl.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(s) close (s)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
#include <unistd.h>
#include <dirent.h>
#ifdef OSX
# include <mach-o/dyld.h>
#endif
#endif
#include "network.h"
#include "os_interface.h"
void * network_connect(char * address,unsigned short port)
{
genos_tcp_stat * tcp_stat;
#ifdef WIN32
int iResult;
#endif
tcp_stat = malloc(sizeof(genos_tcp_stat));
if(tcp_stat)
{
memset(tcp_stat,0,sizeof(genos_tcp_stat));
#ifdef WIN32
iResult = WSAStartup(MAKEWORD(2,2), &tcp_stat->wsaData);
if (iResult != NO_ERROR)
{
free(tcp_stat);
return (void*)NULL;
}
#endif
tcp_stat->m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (tcp_stat->m_socket == INVALID_SOCKET)
{
#ifdef WIN32
WSACleanup();
#endif
free(tcp_stat);
return (void*)NULL;
}
tcp_stat->clientService.sin_family = AF_INET;
tcp_stat->clientService.sin_addr.s_addr = inet_addr(address);
tcp_stat->clientService.sin_port = htons(port);
if (connect(tcp_stat->m_socket, (SOCKADDR*)&tcp_stat->clientService, sizeof(tcp_stat->clientService)) == SOCKET_ERROR)
{
#ifdef WIN32
WSACleanup();
#else
close(tcp_stat->m_socket);
#endif
free(tcp_stat);
return (void*)NULL;
}
return (void*)tcp_stat;
}
return (void*)NULL;
}
int network_read(void * network_connection, unsigned char * buffer, int size,int timeout)
{
int bytesRecv;
int offset;
genos_tcp_stat * tcp_stat;
tcp_stat = (genos_tcp_stat *)network_connection;
offset=0;
while(offset < size)
{
bytesRecv = recv(tcp_stat->m_socket, (char*)&buffer[offset], size - offset, 0);
if(bytesRecv == SOCKET_ERROR)
{
return -1;
}
else
{
offset += bytesRecv;
}
}
return size;
}
int network_read2(void * network_connection, unsigned char * buffer, int size,int timeout)
{
int bytesRecv;
int offset;
genos_tcp_stat * tcp_stat;
tcp_stat = (genos_tcp_stat *)network_connection;
offset=0;
bytesRecv = recv(tcp_stat->m_socket, (char*)&buffer[offset], size - offset, 0);
return bytesRecv;
}
int network_write(void * network_connection, unsigned char * buffer, int size,int timeout)
{
int bytesSent;
int offset;
genos_tcp_stat * tcp_stat;
tcp_stat = (genos_tcp_stat *)network_connection;
offset = 0;
while(offset < size)
{
bytesSent = send(tcp_stat->m_socket, (char*)&buffer[offset], size - offset, 0);
if(bytesSent == SOCKET_ERROR)
{
return -1;
}
else
{
offset += bytesSent;
}
}
return size;
}
int network_close(void * network_connection)
{
genos_tcp_stat * tcp_stat;
tcp_stat = (genos_tcp_stat *)network_connection;
closesocket (tcp_stat->m_socket);
#ifdef WIN32
WSACleanup();
#endif
free(tcp_stat);
return 0;
}