diff --git a/.github/workflows/macos-latest.yml b/.github/workflows/macos-latest.yml index d73c8f1..39dad05 100644 --- a/.github/workflows/macos-latest.yml +++ b/.github/workflows/macos-latest.yml @@ -51,6 +51,7 @@ jobs: $MAKE -C samples/notify $MAKE -C samples/notify_debug $MAKE -C samples/ps + $MAKE -C samples/sdk_ver $CMAKE -S samples/hello_cmake -B samples/hello_cmake/build $CMAKE --build samples/hello_cmake/build $MESON setup samples/hello_meson samples/hello_meson/build diff --git a/.github/workflows/ubuntu-latest.yml b/.github/workflows/ubuntu-latest.yml index 50e1cbd..74ba6db 100644 --- a/.github/workflows/ubuntu-latest.yml +++ b/.github/workflows/ubuntu-latest.yml @@ -61,6 +61,7 @@ jobs: $MAKE -C samples/notify $MAKE -C samples/notify_debug $MAKE -C samples/ps + $MAKE -C samples/sdk_ver $CMAKE -S samples/hello_cmake -B samples/hello_cmake/build $CMAKE --build samples/hello_cmake/build $MESON setup samples/hello_meson samples/hello_meson/build @@ -76,6 +77,13 @@ jobs: path: ./ps5-payload-sdk.zip if-no-files-found: error + - name: Upload Samples + uses: actions/upload-artifact@v4 + with: + name: Samples + include-hidden-files: true + path: ./samples + release: needs: build permissions: diff --git a/samples/sdk_ver/.gitignore b/samples/sdk_ver/.gitignore new file mode 100644 index 0000000..beefd66 --- /dev/null +++ b/samples/sdk_ver/.gitignore @@ -0,0 +1,4 @@ +*.elf +*.o +*~ + diff --git a/samples/sdk_ver/Makefile b/samples/sdk_ver/Makefile new file mode 100644 index 0000000..37f9bc4 --- /dev/null +++ b/samples/sdk_ver/Makefile @@ -0,0 +1,48 @@ +# Copyright (C) 2023 John Törnblom +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not see +# . + +PS5_HOST ?= ps5 +PS5_PORT ?= 9021 + +ifdef PS5_PAYLOAD_SDK + include $(PS5_PAYLOAD_SDK)/toolchain/prospero.mk +else + $(error PS5_PAYLOAD_SDK is undefined) +endif + +ELF := sdk_ver.elf + +CFLAGS := -Wall -Werror -g + +all: $(ELF) + +$(ELF): main.c + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm -f $(ELF) + +test: $(ELF) + $(PS5_DEPLOY) -h $(PS5_HOST) -p $(PS5_PORT) $^ + +debug: $(ELF) + gdb-multiarch \ + -ex "set architecture i386:x86-64" \ + -ex "target extended-remote $(PS5_HOST):2159" \ + -ex "file $(ELF)" \ + -ex "remote put $(ELF) /data/$(ELF)" \ + -ex "set remote exec-file /data/$(ELF)" \ + -ex "start" diff --git a/samples/sdk_ver/main.c b/samples/sdk_ver/main.c new file mode 100644 index 0000000..c885b16 --- /dev/null +++ b/samples/sdk_ver/main.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2023 John Törnblom + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This program 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; see the file COPYING. If not, see +. */ + +#include +#include +#include + +// exclude null terminator +#define sizeof_1(a) (sizeof(a) - 1) + +typedef struct notify_request { + char useless1[45]; + char message[1024]; + char useless2[2051]; +} notify_request_t; + +int sceKernelSendNotificationRequest(int, notify_request_t*, size_t, int); + +int +main() { + notify_request_t req; + bzero(&req, sizeof(req)); + const uint32_t sdk = kernel_get_fw_version(); + snprintf(req.message, sizeof_1(req.message), "SDK Version: 0x%08x", sdk); + + return sceKernelSendNotificationRequest(0, &req, sizeof req, 0); +}