aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxapi/_syscalls.s
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2023-05-11 23:42:43 +0200
committerGitHub <noreply@github.com>2023-05-11 23:42:43 +0200
commit04d7728350cbd04dd86cd894e906c98673e3f9a7 (patch)
tree08e8c7dd495d1c4c6fcf5f7ba6b4b10693dc42f6 /libpsn00b/psxapi/_syscalls.s
parenteaec942f56ceec9c14de5c4185a02602abadd50a (diff)
parent58a8306d24fe29d965aa8b40ddc37c3163c0a2f9 (diff)
downloadpsn00bsdk-04d7728350cbd04dd86cd894e906c98673e3f9a7.tar.gz
Merge pull request #70 from Lameguy64/v0.23-wip
Header cleanups, PCDRV, more safety checks, libc and mkpsxiso fixes (v0.23)
Diffstat (limited to 'libpsn00b/psxapi/_syscalls.s')
-rw-r--r--libpsn00b/psxapi/_syscalls.s111
1 files changed, 105 insertions, 6 deletions
diff --git a/libpsn00b/psxapi/_syscalls.s b/libpsn00b/psxapi/_syscalls.s
index 6eaed72..5062b15 100644
--- a/libpsn00b/psxapi/_syscalls.s
+++ b/libpsn00b/psxapi/_syscalls.s
@@ -1,26 +1,28 @@
# PSn00bSDK syscall wrappers
-# (C) 2022 spicyjpeg - MPL licensed
+# (C) 2022-2023 spicyjpeg - MPL licensed
.set noreorder
+## Interrupt enable/disable
+
.section .text.EnterCriticalSection
.global EnterCriticalSection
.type EnterCriticalSection, @function
EnterCriticalSection:
- li $a0, 0x01
+ li $a0, 0x01
syscall 0
- jr $ra
+ jr $ra
nop
.section .text.ExitCriticalSection
.global ExitCriticalSection
.type ExitCriticalSection, @function
ExitCriticalSection:
- li $a0, 0x02
+ li $a0, 0x02
syscall 0
- jr $ra
+ jr $ra
nop
.section .text.SwEnterCriticalSection
@@ -31,7 +33,7 @@ SwEnterCriticalSection:
li $a1, -1026
and $a1, $a0
mtc0 $a1, $12
- andi $a0, 0x0401 # return ((cop0r12_prev & 0x401) == 0x401)
+ andi $a0, 0x0401 # return !((cop0r12_prev & 0x401) < 0x401)
sltiu $v0, $a0, 0x0401
jr $ra
@@ -49,3 +51,100 @@ SwExitCriticalSection:
jr $ra
nop
+
+## PCDRV (host file access) API
+
+.section .text.PCinit
+.global PCinit
+.type PCinit, @function
+PCinit:
+ break 0, 0x101 # () -> error
+
+ jr $ra
+ nop
+
+.section .text.PCcreat
+.global PCcreat
+.type PCcreat, @function
+PCcreat:
+ li $a2, 0
+ move $a1, $a0
+ break 0, 0x102 # (path, path, 0) -> error, fd
+
+ bgez $v0, .Lcreate_ok # if (error < 0) fd = error
+ nop
+ move $v1, $v0
+.Lcreate_ok:
+ jr $ra # return fd
+ move $v0, $v1
+
+.section .text.PCopen
+.global PCopen
+.type PCopen, @function
+PCopen:
+ move $a2, $a1
+ move $a1, $a0
+ break 0, 0x103 # (path, path, mode) -> error, fd
+
+ bgez $v0, .Lopen_ok # if (error < 0) fd = error
+ nop
+ move $v1, $v0
+.Lopen_ok:
+ jr $ra # return fd
+ move $v0, $v1
+
+.section .text.PCclose
+.global PCclose
+.type PCclose, @function
+PCclose:
+ move $a1, $a0
+ break 0, 0x104 # (fd, fd) -> error
+
+ jr $ra
+ nop
+
+.section .text.PCread
+.global PCread
+.type PCread, @function
+PCread:
+ move $a3, $a1
+ move $a1, $a0
+ break 0, 0x105 # (fd, fd, length, data) -> error, length
+
+ bgez $v0, .Lread_ok # if (error < 0) length = error
+ nop
+ move $v1, $v0
+.Lread_ok:
+ jr $ra # return length
+ move $v0, $v1
+
+.section .text.PCwrite
+.global PCwrite
+.type PCwrite, @function
+PCwrite:
+ move $a3, $a1
+ move $a1, $a0
+ break 0, 0x106 # (fd, fd, length, data) -> error, length
+
+ bgez $v0, .Lwrite_ok # if (error < 0) length = error
+ nop
+ move $v1, $v0
+.Lwrite_ok:
+ jr $ra # return length
+ move $v0, $v1
+
+.section .text.PClseek
+.global PClseek
+.type PClseek, @function
+PClseek:
+ move $a3, $a2
+ move $a2, $a1
+ move $a1, $a0
+ break 0, 0x107 # (fd, fd, offset, mode) -> error, offset
+
+ bgez $v0, .Lseek_ok # if (error < 0) offset = error
+ nop
+ move $v1, $v0
+.Lseek_ok:
+ jr $ra # return offset
+ move $v0, $v1