From: ljsebald <ljs...@us...> - 2023-06-06 02:03:45
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "An ethernet program loader for the Dreamcast.". The branch, master has been updated via 42808da661163387f678ddb99819f27c5b11b95c (commit) from ad916bc823652e2d361f12ec5b35611d821d57e4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 42808da661163387f678ddb99819f27c5b11b95c Author: Andress Barajas <and...@gm...> Date: Mon Jun 5 19:02:31 2023 -0700 #3 Changed logging and fixed spacing (#4) ----------------------------------------------------------------------- Summary of changes: host-src/tool/Makefile | 16 ++++++++-------- host-src/tool/dc-tool.c | 43 ++++++++++++++++++++++--------------------- host-src/tool/syscalls.c | 4 +++- host-src/tool/utils.c | 19 +++++++++++++++++++ host-src/tool/utils.h | 6 ++++++ make-cd/Makefile | 3 +++ target-src/1st_read/Makefile | 10 +++++++--- 7 files changed, 68 insertions(+), 33 deletions(-) create mode 100644 host-src/tool/utils.c create mode 100644 host-src/tool/utils.h diff --git a/host-src/tool/Makefile b/host-src/tool/Makefile index a5e24b4..418d4c7 100644 --- a/host-src/tool/Makefile +++ b/host-src/tool/Makefile @@ -6,26 +6,26 @@ LDFLAGS = $(HOSTLDFLAGS) INCLUDE = ifeq ($(WITH_BFD),1) - CFLAGS += -DWITH_BFD - LDFLAGS = -L$(BFDLIB) -lbfd -liberty -lintl -lz - INCLUDE += -I$(BFDINCLUDE) + CFLAGS += -DWITH_BFD + LDFLAGS = -L$(BFDLIB) -lbfd -liberty -lintl -lz + INCLUDE += -I$(BFDINCLUDE) else - LDFLAGS = -L$(ELFLIB) -lelf - INCLUDE += -I$(ELFINCLUDE) + LDFLAGS = -L$(ELFLIB) -lelf + INCLUDE += -I$(ELFINCLUDE) endif # Additional libraries for MinGW/MSYS ifdef MINGW32 - LDFLAGS += -lws2_32 -lwsock32 -liconv + LDFLAGS += -lws2_32 -lwsock32 -liconv endif ifdef STANDALONE_BINARY - LDFLAGS += -static + LDFLAGS += -static endif DCTOOL = dc-tool-ip$(EXECUTABLEEXTENSION) -OBJECTS = dc-tool.o syscalls.o unlink.o +OBJECTS = dc-tool.o syscalls.o unlink.o utils.o .c.o: $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index 9f5c38c..198ab6d 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -52,6 +52,8 @@ #include "dc-io.h" #include "commands.h" +#include "utils.h" + int _nl_msg_cat_cntr; #define DEBUG(x, ...) fprintf(stderr, "DEBUG: "); fprintf(stderr, x, __VA_ARGS__) @@ -450,8 +452,8 @@ int start_ws() WSADATA wsaData; int failed = 0; failed = WSAStartup(MAKEWORD(2,2), &wsaData); - if ( failed != NO_ERROR ) { - perror("WSAStartup"); + if (failed != NO_ERROR) { + log_error("WSAStartup"); return 1; } @@ -471,7 +473,7 @@ int open_socket(char *hostname) #else if (dcsocket == INVALID_SOCKET) { #endif - perror("socket"); + log_error("socket"); return -1; } @@ -482,14 +484,14 @@ int open_socket(char *hostname) host = gethostbyname(hostname); if (!host) { - perror("gethostbyname"); + log_error("gethostbyname"); return -1; } memcpy((char *)&sin.sin_addr, host->h_addr, host->h_length); if (connect(dcsocket, (struct sockaddr *)&sin, sizeof(sin)) < 0) { - perror("connect"); + log_error("connect"); return -1; } @@ -498,7 +500,7 @@ int open_socket(char *hostname) int failed = 0; failed = ioctlsocket(dcsocket, FIONBIO, &flags); if (failed == SOCKET_ERROR) { - perror("ioctlsocket"); + log_error("ioctlsocket"); return -1; } #else @@ -621,7 +623,7 @@ unsigned int upload(char *filename, unsigned int address) } if((inputfd = open(filename, O_RDONLY | O_BINARY)) < 0) { - perror(filename); + log_error(filename); return -1; } @@ -690,7 +692,7 @@ unsigned int upload(char *filename, unsigned int address) inputfd = open(filename, O_RDONLY | O_BINARY); if (inputfd < 0) { - perror(filename); + log_error(filename); return -1; } @@ -732,7 +734,7 @@ int download(char *filename, unsigned int address, outputfd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (outputfd < 0) { - perror(filename); + log_error(filename); return -1; } @@ -783,13 +785,12 @@ int do_console(char *path, char *isofile) if (isofile) { isofd = open(isofile, O_RDONLY | O_BINARY); if (isofd < 0) - perror(isofile); + log_error(isofile); } #ifndef __MINGW32__ - if (path) - if (chroot(path)) - perror(path); + if (path && chroot(path)) + log_error(path); #endif while (1) { @@ -865,7 +866,7 @@ int open_gdb_socket(int port) #else if (gdb_server_socket < 0) { #endif - perror( "error creating gdb server socket" ); + log_error( "error creating gdb server socket" ); return -1; } @@ -875,7 +876,7 @@ int open_gdb_socket(int port) #else if (checkbind < 0) { #endif - perror( "error binding gdb server socket" ); + log_error( "error binding gdb server socket" ); return -1; } @@ -885,7 +886,7 @@ int open_gdb_socket(int port) #else if (checklisten < 0) { #endif - perror( "error listening to gdb server socket" ); + log_error( "error listening to gdb server socket" ); return -1; } @@ -1015,21 +1016,21 @@ int main(int argc, char *argv[]) } if (quiet) - printf("Quiet download\n"); + printf("Quiet download\n"); if (cdfs_redir & (!console)) - console = 1; + console = 1; if (console & (command=='x')) - printf("Console enabled\n"); + printf("Console enabled\n"); #ifndef __MINGW32__ if (path) - printf("Chroot enabled\n"); + printf("Chroot enabled\n"); #endif if (cdfs_redir & (command=='x')) - printf("Cdfs redirection enabled\n"); + printf("Cdfs redirection enabled\n"); if (open_socket(hostname)<0) { diff --git a/host-src/tool/syscalls.c b/host-src/tool/syscalls.c index a848e0d..9eac90e 100644 --- a/host-src/tool/syscalls.c +++ b/host-src/tool/syscalls.c @@ -41,6 +41,8 @@ #include "dcload-types.h" #include "commands.h" +#include "utils.h" + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -493,7 +495,7 @@ int dc_gdbpacket(unsigned char * buffer) socket_fd = accept( gdb_server_socket, NULL, NULL ); if ( socket_fd == 0) { - perror("error accepting gdb server connection"); + log_error("error accepting gdb server connection"); return -1; } } diff --git a/host-src/tool/utils.c b/host-src/tool/utils.c new file mode 100644 index 0000000..99ff462 --- /dev/null +++ b/host-src/tool/utils.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#ifdef __MINGW32__ +#include <windows.h> +#endif + +void log_error( const char * prefix ) { + perror( prefix ); + +#ifdef __MINGW32__ + DWORD dwError = WSAGetLastError(); + if ( dwError ) { + TCHAR *err = NULL; + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&err, 0, NULL); + fprintf(stderr, "WSAGetLastError: %d / %s\n", dwError, err); + LocalFree(err); + } +#endif +} diff --git a/host-src/tool/utils.h b/host-src/tool/utils.h new file mode 100644 index 0000000..554bb87 --- /dev/null +++ b/host-src/tool/utils.h @@ -0,0 +1,6 @@ +#ifndef __UTILS_H__ +#define __UTILS_H__ + +void log_error( const char * prefix ); + +#endif /* __UTILS_H__ */ diff --git a/make-cd/Makefile b/make-cd/Makefile index 87a2dbd..e6bc9f8 100644 --- a/make-cd/Makefile +++ b/make-cd/Makefile @@ -9,6 +9,9 @@ TOUCH = touch all: $(1ST_READ) audio.raw burn-audio data.raw burn-data +$(1ST_READ): + cd ../target-src && make + audio.raw: $(DD) if=/dev/zero of=audio.raw bs=2352 count=300 diff --git a/target-src/1st_read/Makefile b/target-src/1st_read/Makefile index df173f1..3938051 100644 --- a/target-src/1st_read/Makefile +++ b/target-src/1st_read/Makefile @@ -6,7 +6,7 @@ all: rm-elf $(TARGET) .PHONY : clean clean: - -rm -f $(TARGET) 1st_read.bin loader.elf + -rm -f $(TARGET) loader.bin loader.elf .PHONY : distclean distclean: clean @@ -19,5 +19,9 @@ loader.elf: loader.s disable.s ../dcload/dcload.bin ../dcload/exception.bin $(TARGETCC) $(TARGETCFLAGS) -o $@ loader.s disable.s -nostartfiles \ -nostdlib -Ttext=0x8c010000 -Wa,-I../dcload -1st_read.bin: loader.elf - $(TARGETOBJCOPY) -R .stack -O binary $^ $@ +loader.bin: loader.elf + $(TARGETOBJCOPY) -O binary $^ $@ + +# 1st_read.bin +$(TARGET): loader.bin + $(KOS_BASE)/utils/scramble/scramble $< $@ hooks/post-receive -- An ethernet program loader for the Dreamcast. |