From 0cf1e058926225088f2d8c530b93f342c5ca5671 Mon Sep 17 00:00:00 2001 From: AKuHAK Date: Fri, 29 Jan 2021 11:52:10 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bd45d1..eb54295 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,105 @@ # PS2Client -![CI](https://github.com/ps2dev/ps2client/workflows/CI/badge.svg) \ No newline at end of file +![CI](https://github.com/ps2dev/ps2client/workflows/CI/badge.svg) + + +## PS2CLIENT USAGE AND INFORMATION + +### THE INTRODUCTION + +These programs, ps2client & fsclient, are command line tools used for interacting with a ps2 system running ps2link and/or ps2netfs. It will allow you to send various commands as well as respond to requests for data. This program was written and tested under Linux, Cygwin and Mac OS X but should compile on any reasonably unixlike system. + +### BUILDING THE CLIENTS +Building and installing is very simple: + +`make clean; make install` + +There are some build options, however: + +`PREFIX=/dir` + +Install directory, defaults to: `$PS2DEV`. `/bin` will be automatically appended. +The software will be installed to the `/bin` sub-directory, under `PREFIX` (`PREFIX/bin`). + +These options can be used as follows: + +`make clean; make PREFIX=/new/path/prefix install` + +### BUILDING WINDOWS BINARIES +For building windows binaries on Unix system, you need to setup mingw cross-compiler and win32 threads. +Build command: + +`make -f Makefile.mingw32` + +### BASIC CLIENT USAGE +Basic usage: + +``` +ps2client [-h hostname] [-t timeout] [arguments] +fsclient [-h hostname] +``` + +**[-h hostname]** + +The address of the remote ps2. This can be an IP or a hostname. If none is given, the environment variable `$PS2HOSTNAME` will be checked for a valid address. If this variable isn't set, a default of 192.168.0.10 will be used. + +**[-t timeout]** + +An idle timeout period in seconds that the client will wait before exiting. This is useful to allow a script to continue after calling ps2client to send a command to ps2link or ps2netfs. + +### PS2LINK COMMANDS +- `reset` + +Send a reset request to ps2link. + +- `execiop [arguments]` + +Tell ps2link to load and execute a file on the IOP. + +- `execee [arguments]` + +Tell ps2link to load and execute a file on the EE. + +- `poweroff` + +Send a poweroff request to ps2link. + +- `scrdump` + +Tell ps2link to dump exceptions to the screen. + +- `netdump` + +Tell ps2link to dump execetions to the network console. + +- `dumpmem ` + +Dump the contents of memory into a file. + +- `startvu ` + +Tell the specified vector unit to start operation. + +- `stopvu ` + +Tell the specified vector unit to stop operation. + +- `dumpreg ` + +Dump the registers of a given type into a file. + +- `gsexec ` + +Tell ps2link to load and send a file to the GS. + +- `writemem ` + +Write the contents of a file into memory. + +- `iopexcep` + +I really don't know! OH NOES!! + +- `listen` + +Listen to the ps2link network console. From 46ca19beecc512d05729b3595318d179e772b937 Mon Sep 17 00:00:00 2001 From: AKuHAK Date: Fri, 29 Jan 2021 11:56:25 +0200 Subject: [PATCH 2/4] Fixed identation and formatting --- .editorconfig | 20 ++++++++++++++++++++ Makefile | 2 +- doc/license.txt | 8 ++++---- doc/ps2link-protocol.txt | 2 +- src/fsclient.c | 2 +- src/network.c | 2 +- src/ps2link.c | 18 +++++++++--------- src/ps2netfs.h | 26 +++++++++++++------------- 8 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4b27880 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# EditorConfig: http://EditorConfig.org + +# Top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# 1 space indentation +[*.{c,h,js,css,html}] +indent_style = space +indent_size = 1 + +# Tab indentation +[Makefile*] +indent_style = tab diff --git a/Makefile b/Makefile index 25bff02..c4f39a0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ else LIBS = -lwsock32 -lpthreadGC2 endif - + ifeq "x$(PREFIX)" "x" PREFIX = $(PS2DEV) endif diff --git a/doc/license.txt b/doc/license.txt index 2fb97cb..c109b49 100644 --- a/doc/license.txt +++ b/doc/license.txt @@ -14,17 +14,17 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. The name of the author(s) may not be used to endorse or promote products + * 3. The name of the author(s) may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. diff --git a/doc/ps2link-protocol.txt b/doc/ps2link-protocol.txt index 674e05f..7dc4443 100644 --- a/doc/ps2link-protocol.txt +++ b/doc/ps2link-protocol.txt @@ -31,7 +31,7 @@ tell it what to do. These are simple commands sent as single packets for executing programs, resetting ps2link or other things. This list may grow as time goes on and new functionality is added to ps2link. - + ---------------------------- 0xBABE0201 (reset command) ---------------------------- diff --git a/src/fsclient.c b/src/fsclient.c index a90b66b..86606fa 100644 --- a/src/fsclient.c +++ b/src/fsclient.c @@ -236,7 +236,7 @@ if (!strcmp(temp, "pfs")) { printf(" pfs - Playstation File System.\n"); } else if (!strcmp(temp, "dev9x")) { printf(" dev9x - Blah blah blah.\n"); } else - // + // { printf(" %s\n", temp); } // Increment temp. diff --git a/src/network.c b/src/network.c index 561d9c7..e599e7d 100644 --- a/src/network.c +++ b/src/network.c @@ -23,7 +23,7 @@ // Start up winsock. if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) { return -1; } - // End function. + // End function. return 0; } diff --git a/src/ps2link.c b/src/ps2link.c index 1e133e1..c60a702 100644 --- a/src/ps2link.c +++ b/src/ps2link.c @@ -555,13 +555,13 @@ // Perform the request. // do we need to use mode in here: request->mode ? - + #ifdef _WIN32 - result = mkdir(request->name); + result = mkdir(request->name); #else result = mkdir(request->name, request->mode); #endif - + // Send the response. return ps2link_response_mkdir(result); } @@ -589,10 +589,10 @@ int ps2link_request_getstat(void *packet) { // Fix the arguments. fix_pathname(request->name); - + // Fetch the entry's statistics. ret = stat(request->name, &stats); - + if (ret == 0) { // Convert the mode. mode = (stats.st_mode & 0x07); @@ -601,7 +601,7 @@ int ps2link_request_getstat(void *packet) { if (S_ISLNK(stats.st_mode)) { mode |= 0x08; } #endif if (S_ISREG(stats.st_mode)) { mode |= 0x10; } - + // Convert the creation time. loctime = localtime(&(stats.st_ctime)); ctime[6] = (unsigned char)loctime->tm_year; @@ -610,7 +610,7 @@ int ps2link_request_getstat(void *packet) { ctime[3] = (unsigned char)loctime->tm_hour; ctime[2] = (unsigned char)loctime->tm_min; ctime[1] = (unsigned char)loctime->tm_sec; - + // Convert the access time. loctime = localtime(&(stats.st_atime)); atime[6] = (unsigned char)loctime->tm_year; @@ -619,7 +619,7 @@ int ps2link_request_getstat(void *packet) { atime[3] = (unsigned char)loctime->tm_hour; atime[2] = (unsigned char)loctime->tm_min; atime[1] = (unsigned char)loctime->tm_sec; - + // Convert the last modified time. loctime = localtime(&(stats.st_mtime)); mtime[6] = (unsigned char)loctime->tm_year; @@ -629,7 +629,7 @@ int ps2link_request_getstat(void *packet) { mtime[2] = (unsigned char)loctime->tm_min; mtime[1] = (unsigned char)loctime->tm_sec; } - + return ps2link_response_getstat(ret, mode, 0, stats.st_size, ctime, atime, mtime, 0); } diff --git a/src/ps2netfs.h b/src/ps2netfs.h index 095056f..e79594a 100644 --- a/src/ps2netfs.h +++ b/src/ps2netfs.h @@ -63,27 +63,27 @@ #define PS2NETFS_COMMAND_DEVLIST 0xBEEF8F21 int ps2netfs_command_open(char *pathname, int flags); - + int ps2netfs_command_close(int fd); - + int ps2netfs_command_read(int fd, void *buffer, int size); - + int ps2netfs_command_write(int fd, void *buffer, int size); - + int ps2netfs_command_lseek(int fd, int offset, int whence); - + // ioctl - unimplemented int ps2netfs_command_delete(char *pathname, int flags); - + int ps2netfs_command_mkdir(char *pathname, int flags); - + int ps2netfs_command_rmdir(char *pathname, int flags); - + int ps2netfs_command_dopen(char *pathname, int flags); - + int ps2netfs_command_dclose(int dd); - + int ps2netfs_command_dread(int dd, DIRENT *dirent); // getstat - unimplemented @@ -97,9 +97,9 @@ // chdir - unimplemented int ps2netfs_command_sync(char *device, int flags); - + int ps2netfs_command_mount(char *device, char *fsname, int flags, char *argv, int argc); - + int ps2netfs_command_umount(char *device, int flags); // lseek64 - unimplemented @@ -117,5 +117,5 @@ // fstype - unimplemented int ps2netfs_command_devlist(char *pathname, int flags, char *devlist); - + #endif From 68e555f2cf5df287d4ff12fa8a76404001285d53 Mon Sep 17 00:00:00 2001 From: AKuHAK Date: Fri, 29 Jan 2021 12:07:49 +0200 Subject: [PATCH 3/4] Fixed mingw32 compilation --- Makefile.mingw32 | 17 ++++++++--------- doc/readme-mingw32.txt | 28 ++-------------------------- src/fsclient.c | 2 -- src/network.c | 5 +---- src/network.h | 1 + src/ps2netfs.c | 2 -- 6 files changed, 12 insertions(+), 43 deletions(-) diff --git a/Makefile.mingw32 b/Makefile.mingw32 index ab83b80..d677303 100644 --- a/Makefile.mingw32 +++ b/Makefile.mingw32 @@ -1,7 +1,6 @@ - GCC = i586-mingw32msvc-gcc -Wall - INC = -I ../pthreads-win32 - LIB = -lwsock32 -lpthreadGC2 -L ../pthreads-win32 + #CC = i686-w64-mingw32.static-gcc -Wall + LIB = -lwsock32 -lpthread ifeq "x$(PREFIX)" "x" PREFIX = $(PS2DEV) @@ -19,22 +18,22 @@ OFILES += obj/network.o obj/network.o: src/network.c src/network.h @mkdir -p obj - $(GCC) $(INC) -c src/network.c -o obj/network.o + $(CC) $(INC) -c src/network.c -o obj/network.o OFILES += obj/ps2link.o obj/ps2link.o: src/ps2link.c src/ps2link.h @mkdir -p obj - $(GCC) $(INC) -c src/ps2link.c -o obj/ps2link.o + $(CC) $(INC) -c src/ps2link.c -o obj/ps2link.o OFILES += obj/ps2netfs.o obj/ps2netfs.o: src/ps2netfs.c @mkdir -p obj - $(GCC) $(INC) -c src/ps2netfs.c -o obj/ps2netfs.o + $(CC) $(INC) -c src/ps2netfs.c -o obj/ps2netfs.o OFILES += obj/utility.o obj/utility.o: src/utility.c src/utility.h @mkdir -p obj - $(GCC) $(INC) -c src/utility.c -o obj/utility.o + $(CC) $(INC) -c src/utility.c -o obj/utility.o ##################### ## CLIENT PROGRAMS ## @@ -42,8 +41,8 @@ bin/fsclient.exe: $(OFILES) src/fsclient.c @mkdir -p bin - $(GCC) $(INC) $(OFILES) src/fsclient.c -o bin/fsclient.exe $(LIB) + $(CC) $(INC) $(OFILES) src/fsclient.c -o bin/fsclient.exe $(LIB) bin/ps2client.exe: $(OFILES) src/ps2client.c @mkdir -p bin - $(GCC) $(INC) $(OFILES) src/ps2client.c -o bin/ps2client.exe $(LIB) + $(CC) $(INC) $(OFILES) src/ps2client.c -o bin/ps2client.exe $(LIB) diff --git a/doc/readme-mingw32.txt b/doc/readme-mingw32.txt index 515d9a7..4bd49ad 100644 --- a/doc/readme-mingw32.txt +++ b/doc/readme-mingw32.txt @@ -8,29 +8,5 @@ ---------------------------------- Since now, ps2client uses the pthread library to work, you need the - pthreads-win32 native library to compile ps2client using a mingw32 - compiler. You want to download the prebuilt binaries and headers - from ftp://sources.redhat.com/pub/pthreads-win32 and put them - in the ../pthreads-win32 directory. You need the following files: - - libpthreadGC2.a - pthread.h - pthreadGC2.dll - sched.h - semaphore.h - - Note that if you're using a linux host to cross compile, you probably - want to dos2unix *.h before compiling. - - ------------------ - MORE INFORMATION - ------------------ - - If you want to get into the wonderful world of homebrew ps2 - development, there's a few places you can check out: - - http://www.ps2dev.org - News, tutorials and documentation. - - http://forums.ps2dev.org - The official ps2dev forums. - - #ps2dev on efnet (IRC) - Come banter in realtime. + threads support. For example you can use MXE/MinGW-w64 with win32 + threads. diff --git a/src/fsclient.c b/src/fsclient.c index 86606fa..b448c89 100644 --- a/src/fsclient.c +++ b/src/fsclient.c @@ -6,8 +6,6 @@ #include #ifndef _WIN32 #include -#else - #include #endif #include "utility.h" #include "ps2netfs.h" diff --git a/src/network.c b/src/network.c index e599e7d..d0d877c 100644 --- a/src/network.c +++ b/src/network.c @@ -1,8 +1,5 @@ -#ifdef _WIN32 - #include - #include -#else +#ifndef _WIN32 #include #include #include diff --git a/src/network.h b/src/network.h index 8b0f22e..a592757 100644 --- a/src/network.h +++ b/src/network.h @@ -3,6 +3,7 @@ #ifdef _WIN32 #include + #include #else #include #endif diff --git a/src/ps2netfs.c b/src/ps2netfs.c index ebfe2a2..d654aa4 100644 --- a/src/ps2netfs.c +++ b/src/ps2netfs.c @@ -3,8 +3,6 @@ #include #ifndef _WIN32 #include -#else - #include #endif #include "utility.h" #include "network.h" From e1af223c77d16a0af7b3f938e18f0cf57ca38b83 Mon Sep 17 00:00:00 2001 From: AKuHAK Date: Fri, 29 Jan 2021 12:16:28 +0200 Subject: [PATCH 4/4] Fixed Github action *Now Github actions are working *Each commit will produce a pre-release with all binaries *tags will produce Release Draft which should be reviewed by human before posting --- .github/workflows/compilation.yml | 111 +++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 32 deletions(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 0b40320..3a3e715 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -3,8 +3,6 @@ name: CI on: push: pull_request: - repository_dispatch: - types: [run_build] jobs: build: @@ -12,45 +10,94 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest] - - steps: + + steps: - uses: actions/checkout@v2 - - - name: Runs all the stages in the shell + + - name: Compile native versions run: | - export PS2DEV=$PWD/ps2dev - export PS2SDK=$PS2DEV/ps2sdk - export GSKIT=$PS2DEV/gsKit - export PATH=$PATH:$PS2DEV/bin:$PS2DEV/ee/bin:$PS2DEV/iop/bin:$PS2DEV/dvp/bin:$PS2SDK/bin - make clean all install - + make --debug + - name: Get short SHA id: slug run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" - - - name: Compress bin folder - run: | - tar -zcvf bin.tar.gz ps2dev/bin - + + - name: Create tar archive (keep executable bit) + run: tar -zcvf ps2client-${{ steps.slug.outputs.sha8 }}-${{matrix.os}}.tar.gz bin + - uses: actions/upload-artifact@v2 with: name: ps2client-${{ steps.slug.outputs.sha8 }}-${{matrix.os}} - path: ps2dev/bin/ + path: | + *tar.gz + + build-win: + runs-on: ubuntu-latest + container: dockcross/windows-static-x86:latest - - name: Extract tag name - if: startsWith(github.ref, 'refs/tags/') - id: tag - uses: actions/github-script@0.9.0 + steps: + - uses: actions/checkout@v2 + + - name: Compile windows version with cross-compilator + run: | + make -f Makefile.mingw32 --trace + + - name: Get short SHA + id: slug + run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" + + - name: Create tar archive + run: tar -zcvf ps2client-${{ steps.slug.outputs.sha8 }}-windows-latest.tar.gz bin + + - uses: actions/upload-artifact@v2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - return context.payload.ref.replace(/\/refs\/tags\//, ''); + name: ps2client-${{ steps.slug.outputs.sha8 }}-windows-latest + path: | + *tar.gz + + release: + needs: [build, build-win] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' + steps: + - uses: actions/checkout@v2 - - name: Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 + - name: Get short SHA + id: slug + run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" + + - name: Download Mac artifact + uses: actions/download-artifact@v2 + with: + name: ps2client-${{ steps.slug.outputs.sha8 }}-macos-latest + + - name: Download Ubuntu artifact + uses: actions/download-artifact@v2 + with: + name: ps2client-${{ steps.slug.outputs.sha8 }}-ubuntu-latest + + - name: Download Windows artifact + uses: actions/download-artifact@v2 + with: + name: ps2client-${{ steps.slug.outputs.sha8 }}-windows-latest + + - name: Create pre-release + if: github.ref == 'refs/heads/master' + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: true + automatic_release_tag: "latest" + title: "Development build" + files: | + *tar.gz + + - name: Create Tagged Release Draft + if: startsWith(github.ref, 'refs/tags/v') + uses: marvinpinto/action-automatic-releases@latest with: - files: ps2dev.tar.gz - tag_name: ${{ steps.tag.outputs.result }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + draft: true + files: | + *tar.gz