aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-10-19 14:15:28 +0200
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-10-19 14:15:28 +0200
commit783014e53254fe17102a34c30120eeabf5227a47 (patch)
tree6c3e498295ddd293769b85e7b7cbecd80ce32be7 /libpsn00b/libc
parente08a3d9366f8ca14a76b3dd569dac1fb9f569748 (diff)
downloadpsn00bsdk-783014e53254fe17102a34c30120eeabf5227a47.tar.gz
Clean up SDK debug logging, fix getTPage()
Diffstat (limited to 'libpsn00b/libc')
-rw-r--r--libpsn00b/libc/_start.s18
-rw-r--r--libpsn00b/libc/_stubs.s27
-rw-r--r--libpsn00b/libc/abort.c21
3 files changed, 40 insertions, 26 deletions
diff --git a/libpsn00b/libc/_start.s b/libpsn00b/libc/_start.s
deleted file mode 100644
index 56075c8..0000000
--- a/libpsn00b/libc/_start.s
+++ /dev/null
@@ -1,18 +0,0 @@
-# PSn00bSDK _start() trampoline
-# (C) 2022 spicyjpeg - MPL licensed
-#
-# This file provides a weak function that can be easily overridden to e.g. set
-# $sp or perform additional initialization before the "real" _start()
-# (_start_inner()) is called.
-
-.set noreorder
-.section .text
-
-.global _start
-.type _start, @function
-.weak _start
-_start:
- la $gp, _gp
-
- j _start_inner
- nop
diff --git a/libpsn00b/libc/_stubs.s b/libpsn00b/libc/_stubs.s
new file mode 100644
index 0000000..aa7bfbe
--- /dev/null
+++ b/libpsn00b/libc/_stubs.s
@@ -0,0 +1,27 @@
+# PSn00bSDK _start() trampoline and logging endpoint
+# (C) 2022 spicyjpeg - MPL licensed
+#
+# This file provides a weak function that can be easily overridden to e.g. set
+# $sp or perform additional initialization before the "real" _start() function
+# (_start_inner()) is called. The _sdk_log_inner() function called by other
+# libraries to log debug messages can also be overridden in a similar way.
+
+.set noreorder
+
+.section .text._start
+.global _start
+.type _start, @function
+.weak _start
+_start:
+ la $gp, _gp
+ j _start_inner
+ nop
+
+.section .text._sdk_log_inner
+.global _sdk_log_inner
+.type _sdk_log_inner, @function
+.weak _sdk_log_inner
+_sdk_log_inner:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x3f
diff --git a/libpsn00b/libc/abort.c b/libpsn00b/libc/abort.c
index 2db5016..9a4661a 100644
--- a/libpsn00b/libc/abort.c
+++ b/libpsn00b/libc/abort.c
@@ -1,19 +1,24 @@
+/*
+ * PSn00bSDK assert macro and internal logging
+ * (C) 2022 spicyjpeg - MPL licensed
+ */
-#include <psxetc.h>
+#include <assert.h>
+#include <psxapi.h>
-/* Standard abort */
+/* Internal function used by assert() macro */
-void abort(void) {
- _sdk_log("abort()\n");
+void _assert_abort(const char *file, int line, const char *expr) {
+ _sdk_log_inner("%s:%d: assert(%s)\n", file, line, expr);
for (;;)
__asm__ volatile("");
}
-/* Internal function used by assert() macro */
+/* Standard abort */
-void _assert_abort(const char *file, int line, const char *expr) {
- _sdk_log("%s:%d: assert(%s)\n", file, line, expr);
+void abort(void) {
+ _sdk_log_inner("abort()\n");
for (;;)
__asm__ volatile("");
@@ -22,7 +27,7 @@ void _assert_abort(const char *file, int line, const char *expr) {
/* Pure virtual function call (C++) */
void __cxa_pure_virtual(void) {
- _sdk_log("__cxa_pure_virtual()\n");
+ _sdk_log_inner("__cxa_pure_virtual()\n");
for (;;)
__asm__ volatile("");