aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b
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 /libpsn00b
parent6174931fe58b1dc0fc64029dbe3abefc81aa67d5 (diff)
downloadpsn00bsdk-93f0a6d23ebed50833f565f949f351c2b80853ac.tar.gz
Fix critical ldscript bug and CI, add BIOS setjmp
Diffstat (limited to 'libpsn00b')
-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
6 files changed, 82 insertions, 39 deletions
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