aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2022-03-07 22:17:50 +0100
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2022-03-07 22:17:50 +0100
commit93f0a6d23ebed50833f565f949f351c2b80853ac (patch)
tree4b6776e61dfe67955d0787251394b86bc8b72819
parent6174931fe58b1dc0fc64029dbe3abefc81aa67d5 (diff)
downloadpsn00bsdk-93f0a6d23ebed50833f565f949f351c2b80853ac.tar.gz
Fix critical ldscript bug and CI, add BIOS setjmp
-rw-r--r--.github/workflows/build.yml28
-rw-r--r--examples/io/system573/k573io.c5
-rw-r--r--examples/io/system573/k573io.h3
-rw-r--r--libpsn00b/include/psxapi.h12
-rw-r--r--libpsn00b/ldscripts/dll.ld1
-rw-r--r--libpsn00b/ldscripts/exe.ld11
-rw-r--r--libpsn00b/psxapi/stubs.json12
-rw-r--r--libpsn00b/psxapi/sys.s18
-rw-r--r--libpsn00b/readme.txt67
9 files changed, 94 insertions, 63 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b2ca311..6f42e41 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,6 +16,9 @@ env:
jobs:
# This is based on doc/toolchain.md, no surprises here other than the cache.
+ # Since actions/cache@v2 has bugs when restoring on Windows caches created on
+ # Linux, v1 is used instead.
+ # https://github.com/actions/cache/issues/576
build-gcc:
name: Build GCC toolchain
runs-on: ubuntu-latest
@@ -23,7 +26,7 @@ jobs:
steps:
- name: Initialize toolchain cache
id: _cache
- uses: actions/cache@v2
+ uses: actions/cache@v1
with:
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
@@ -83,25 +86,19 @@ jobs:
# No surprises here either. The GitHub Actions VMs even come with most of the
# dependencies required to build PSn00bSDK preinstalled.
- # NOTE: the workaround to allow the toolchain cache to be loaded (see below)
- # doesn't seem to work on Windows Server 2022 currently.
build-sdk-windows:
name: Build PSn00bSDK on Windows
- runs-on: windows-2019
+ runs-on: windows-2022
needs: build-gcc
steps:
- # Due to a bug in the cache action (and in order to use Ninja and pacman)
- # the directories MSys2 stores binaries in must be added to PATH. For
- # some reason they are not present in PATH by default.
- # https://github.com/actions/cache/issues/576
- name: Add MSys2 to PATH
run: |
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Initialize toolchain cache
- uses: actions/cache@v2
+ uses: actions/cache@v1
with:
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
@@ -118,7 +115,7 @@ jobs:
- name: Build and package PSn00bSDK
run: |
- cmake --preset ci -S sdk -G "Visual Studio 16 2019" -DPSN00BSDK_TC=${{ github.workspace }}\gcc\windows
+ cmake --preset ci -S sdk -G "Visual Studio 17 2022" -DPSN00BSDK_TC=${{ github.workspace }}\gcc\windows
cmake --build build
cmake --build build -t package
@@ -144,7 +141,7 @@ jobs:
steps:
- name: Initialize toolchain cache
- uses: actions/cache@v2
+ uses: actions/cache@v1
with:
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
@@ -178,12 +175,6 @@ jobs:
name: psn00bsdk-linux-deb
path: build/packages/*.deb
- - name: Upload build artifacts (RPM)
- uses: actions/upload-artifact@v2
- with:
- name: psn00bsdk-linux-rpm
- path: build/packages/*.rpm
-
# This job takes care of creating a new release and upload the build
# artifacts if the last commit is associated to a tag.
create-release:
@@ -194,7 +185,7 @@ jobs:
steps:
- name: Initialize toolchain cache
if: ${{ github.ref_type == 'tag' }}
- uses: actions/cache@v2
+ uses: actions/cache@v1
with:
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
@@ -236,4 +227,3 @@ jobs:
psn00bsdk-windows-nsis/*
psn00bsdk-linux/*
psn00bsdk-linux-deb/*
- psn00bsdk-linux-rpm/*
diff --git a/examples/io/system573/k573io.c b/examples/io/system573/k573io.c
index a8748d6..bc13852 100644
--- a/examples/io/system573/k573io.c
+++ b/examples/io/system573/k573io.c
@@ -11,6 +11,7 @@
#include <stdint.h>
#include <psxgpu.h>
+#include <hwregs_c.h>
#include "k573io.h"
@@ -116,8 +117,8 @@ void K573_SetBoardType(K573_IOBoardType type) {
//K573_DDRStageCommand(0x000001, 22);
void K573_Init(void) {
- EXP1_ADDR = 0x1f000000;
- EXP1_CTRL = 0x24173f47; // 573 BIOS uses this value
+ EXP1_ADDR = 0x1f000000;
+ EXP1_DELAY_SIZE = 0x24173f47; // 573 BIOS uses this value
K573_RESET_WATCHDOG();
}
diff --git a/examples/io/system573/k573io.h b/examples/io/system573/k573io.h
index cf125e2..7095a7c 100644
--- a/examples/io/system573/k573io.h
+++ b/examples/io/system573/k573io.h
@@ -10,9 +10,6 @@
/* Register definitions */
-#define EXP1_ADDR *((volatile uint32_t *) 0x1f801000)
-#define EXP1_CTRL *((volatile uint32_t *) 0x1f801008)
-
#define K573_BANK_SWITCH *((volatile uint16_t *) 0x1f500000)
#define K573_IDE_RESET *((volatile uint16_t *) 0x1f560000)
#define K573_WATCHDOG *((volatile uint16_t *) 0x1f5c0000)
diff --git a/libpsn00b/include/psxapi.h b/libpsn00b/include/psxapi.h
index e7c2e1e..1298d29 100644
--- a/libpsn00b/include/psxapi.h
+++ b/libpsn00b/include/psxapi.h
@@ -121,6 +121,12 @@ struct EXEC {
unsigned int sp,fp,rp,ret,base;
};
+struct JMP_BUF {
+ unsigned int ra, sp, fp;
+ unsigned int s0, s1, s2, s3, s4, s5, s6, s7;
+ unsigned int gp;
+};
+
// Not recommended to use these functions to install IRQ handlers
typedef struct {
@@ -211,6 +217,12 @@ void ChangeClearRCnt(int t, int m);
int Exec(struct EXEC *exec, int argc, char **argv);
void FlushCache(void);
+// BIOS setjmp functions
+void b_setjmp(struct JMP_BUF *buf);
+void b_longjmp(struct JMP_BUF *buf, int param);
+void SetDefaultExitFromException(void);
+void SetCustomExitFromException(struct JMP_BUF *buf);
+
// Misc functions
int GetSystemInfo(int index);
void *GetB0Table(void);
diff --git a/libpsn00b/ldscripts/dll.ld b/libpsn00b/ldscripts/dll.ld
index a03a504..15158e4 100644
--- a/libpsn00b/ldscripts/dll.ld
+++ b/libpsn00b/ldscripts/dll.ld
@@ -86,6 +86,7 @@ SECTIONS {
* as we don't have to worry about managing .bss separately from the
* main DLL blob.
*/
+ . = ALIGN((. != 0) ? 4 : 1);
__bss_start = .;
*(.bss .bss.* .gnu.linkonce.b.*)
diff --git a/libpsn00b/ldscripts/exe.ld b/libpsn00b/ldscripts/exe.ld
index c6b9f29..583d76a 100644
--- a/libpsn00b/ldscripts/exe.ld
+++ b/libpsn00b/ldscripts/exe.ld
@@ -82,6 +82,11 @@ SECTIONS {
/* BSS sections, i.e. uninitialized variables */
+ /*
+ * Align all BSS sections to 4 bytes to ensure _start() doesn't perform
+ * unaligned memory accesses when clearing them.
+ */
+ . = ALIGN((. != 0) ? 4 : 1);
__bss_start = .;
.sbss (NOLOAD) : {
@@ -91,13 +96,9 @@ SECTIONS {
.bss (NOLOAD) : {
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
-
- /*
- * This crap was in the stock GCC linker script.
- */
- . = ALIGN((. != 0) ? 4 : 1);
} > APP_RAM
+ . = ALIGN((. != 0) ? 4 : 1);
_end = .;
/* Dummy section */
diff --git a/libpsn00b/psxapi/stubs.json b/libpsn00b/psxapi/stubs.json
index 14ef935..9198b06 100644
--- a/libpsn00b/psxapi/stubs.json
+++ b/libpsn00b/psxapi/stubs.json
@@ -49,6 +49,18 @@
},
{
"type": "a",
+ "id": 19,
+ "name": "b_setjmp",
+ "file": "sys.s"
+ },
+ {
+ "type": "a",
+ "id": 20,
+ "name": "b_longjmp",
+ "file": "sys.s"
+ },
+ {
+ "type": "a",
"id": 57,
"name": "b_InitHeap",
"file": "sys.s"
diff --git a/libpsn00b/psxapi/sys.s b/libpsn00b/psxapi/sys.s
index ef57124..e54bd98 100644
--- a/libpsn00b/psxapi/sys.s
+++ b/libpsn00b/psxapi/sys.s
@@ -6,7 +6,23 @@
.set noreorder
-## A0 table functions (5)
+## A0 table functions (7)
+
+.section .text.b_setjmp
+.global b_setjmp
+.type b_setjmp, @function
+b_setjmp:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x13
+
+.section .text.b_longjmp
+.global b_longjmp
+.type b_longjmp, @function
+b_longjmp:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x14
.section .text.b_InitHeap
.global b_InitHeap
diff --git a/libpsn00b/readme.txt b/libpsn00b/readme.txt
index cfff733..6a6be5a 100644
--- a/libpsn00b/readme.txt
+++ b/libpsn00b/readme.txt
@@ -18,33 +18,39 @@ recommended version as that is what LibPSn00b is most tested most on.
Brief summary of libraries:
- libc - Standard C library. Covers only a small subset of the full
- standard C library such as basic string and memory manipulation
- functions. Should include libgcc to avoid libc/libgcc linker
- hell (endless cross referencing).
-
- psxgpu - GPU library for video, graphics control, and interrupt service
- subsystem that other libraries that uses interrupts depend on.
-
- psxgte - GTE library for hardware accelerated vector transformations
- that are integral for high performance 3D graphics on the PS1
- (it is a Geometry Transformation Engine, NOT Transfer Engine).
-
- psxapi - Provides function calls for using functions provided by the PS1
- BIOS.
-
- psxetc - Provides some miscellaneous features used by the other libraries
- as well as a dynamic linker for loading DLLs at runtime.
-
- psxspu - SPU library (work in progress). Currently supports hardware
- init, sample data upload via DMA and playing sound samples.
- Lacks support for reverb and a sequenced music subsystem.
-
- psxcd - CD-ROM library for loading files, parsing directories
- (PSn00bSDK addition), CD Audio/XA playback with provisions for
- data streaming. Also supports multi-session discs (must be
- selected manually).
-
+ libc - Standard C library. Covers only a small subset of the full
+ standard C library such as basic string and memory manipulation
+ functions. Should include libgcc to avoid libc/libgcc linker
+ hell (endless cross referencing).
+
+ psxgpu - GPU library for video, graphics control, and interrupt service
+ subsystem that other libraries that uses interrupts depend on.
+
+ psxgte - GTE library for hardware accelerated vector transformations
+ that are integral for high performance 3D graphics on the PS1
+ (it is a Geometry Transformation Engine, NOT Transfer Engine).
+
+ psxapi - Provides function calls for using functions provided by the PS1
+ BIOS.
+
+ psxetc - Provides some miscellaneous features used by the other libraries
+ as well as a dynamic linker for loading DLLs at runtime.
+
+ psxspu - SPU library (work in progress). Currently supports hardware
+ init, sample data upload via DMA and playing sound samples.
+ Lacks support for reverb and a sequenced music subsystem.
+
+ psxcd - CD-ROM library for loading files, parsing directories
+ (PSn00bSDK addition), CD Audio/XA playback with provisions for
+ data streaming. Also supports multi-session discs (must be
+ selected manually).
+
+ psxpress - Experimental MDEC library. Currently provides APIs to feed data
+ to the MDEC and retrieve decoded images, as well as a
+ decompressor for the Huffman encoding used in FMVs encoded using
+ Sony tools. A custom decompressor based on arithmetic coding
+ might be implemented in the future.
+
Each library has its own readme file that contains a todo list, credits
and some additional details of the library. Changes of all the libraries
must be covered in the changelog.txt file.
@@ -52,7 +58,7 @@ Brief summary of libraries:
Compiling:
- Refer to INSTALL.md in the parent directory for up-to-date installation
+ Refer to installation.md in the doc directory for up-to-date installation
instructions.
--- THE SECTION BELOW IS OUTDATED AND ONLY KEPT FOR REFERENCE ---
@@ -144,11 +150,6 @@ LibPSn00b Library to-do list:
psxmcrd - Better and faster memory card library with provisions for
low-level card access. The psxpad library would provide
communication routines for the card library.
-
- psxpress - MDEC and data decompression library. May use DEFLATE or LZ77
- for compressing MDEC data instead of Huffman as used in the
- official libraries. It may yield better compression which may
- potentially result in higher quality FMVs.
psxexp - Support library for various devices connected to the serial or
expansion port, including both official ones (e.g. PCMCIA cards