diff options
Diffstat (limited to 'libpsn00b/psxapi')
| -rw-r--r-- | libpsn00b/psxapi/_syscalls.s | 111 | ||||
| -rw-r--r-- | libpsn00b/psxapi/drivers.s | 32 | ||||
| -rw-r--r-- | libpsn00b/psxapi/fs.s | 18 | ||||
| -rw-r--r-- | libpsn00b/psxapi/stdio.s | 36 | ||||
| -rw-r--r-- | libpsn00b/psxapi/stubs.json | 62 | ||||
| -rw-r--r-- | libpsn00b/psxapi/sys.s | 58 |
6 files changed, 258 insertions, 59 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 diff --git a/libpsn00b/psxapi/drivers.s b/libpsn00b/psxapi/drivers.s index d991f90..c601201 100644 --- a/libpsn00b/psxapi/drivers.s +++ b/libpsn00b/psxapi/drivers.s @@ -32,10 +32,10 @@ _96_remove: jr $t2 li $t1, 0x72 -.section .text.AddDummyTty -.global AddDummyTty -.type AddDummyTty, @function -AddDummyTty: +.section .text.add_nullcon_driver +.global add_nullcon_driver +.type add_nullcon_driver, @function +add_nullcon_driver: li $t2, 0xa0 jr $t2 li $t1, 0x99 @@ -66,26 +66,26 @@ _card_clear: ## B0 table functions (12) -.section .text.AddDev -.global AddDev -.type AddDev, @function -AddDev: +.section .text.AddDrv +.global AddDrv +.type AddDrv, @function +AddDrv: li $t2, 0xb0 jr $t2 li $t1, 0x47 -.section .text.DelDev -.global DelDev -.type DelDev, @function -DelDev: +.section .text.DelDrv +.global DelDrv +.type DelDrv, @function +DelDrv: li $t2, 0xb0 jr $t2 li $t1, 0x48 -.section .text.ListDev -.global ListDev -.type ListDev, @function -ListDev: +.section .text.ListDrv +.global ListDrv +.type ListDrv, @function +ListDrv: li $t2, 0xb0 jr $t2 li $t1, 0x49 diff --git a/libpsn00b/psxapi/fs.s b/libpsn00b/psxapi/fs.s index f225d64..8b6d57a 100644 --- a/libpsn00b/psxapi/fs.s +++ b/libpsn00b/psxapi/fs.s @@ -6,12 +6,12 @@ .set noreorder -## B0 table functions (5) +## B0 table functions (6) -.section .text.chdir -.global chdir -.type chdir, @function -chdir: +.section .text.cd +.global cd +.type cd, @function +cd: li $t2, 0xb0 jr $t2 li $t1, 0x40 @@ -48,3 +48,11 @@ erase: jr $t2 li $t1, 0x45 +.section .text.undelete +.global undelete +.type undelete, @function +undelete: + li $t2, 0xb0 + jr $t2 + li $t1, 0x46 + diff --git a/libpsn00b/psxapi/stdio.s b/libpsn00b/psxapi/stdio.s index e65f871..14c6d03 100644 --- a/libpsn00b/psxapi/stdio.s +++ b/libpsn00b/psxapi/stdio.s @@ -6,7 +6,7 @@ .set noreorder -## A0 table functions (13) +## A0 table functions (14) .section .text.open .global open @@ -16,10 +16,10 @@ open: jr $t2 li $t1, 0x00 -.section .text.seek -.global seek -.type seek, @function -seek: +.section .text.lseek +.global lseek +.type lseek, @function +lseek: li $t2, 0xa0 jr $t2 li $t1, 0x01 @@ -56,6 +56,14 @@ ioctl: jr $t2 li $t1, 0x05 +.section .text.isatty +.global isatty +.type isatty, @function +isatty: + li $t2, 0xa0 + jr $t2 + li $t1, 0x07 + .section .text.getc .global getc .type getc, @function @@ -112,3 +120,21 @@ printf: jr $t2 li $t1, 0x3f +## B0 table functions (2) + +.section .text._get_errno +.global _get_errno +.type _get_errno, @function +_get_errno: + li $t2, 0xb0 + jr $t2 + li $t1, 0x54 + +.section .text._get_error +.global _get_error +.type _get_error, @function +_get_error: + li $t2, 0xb0 + jr $t2 + li $t1, 0x55 + diff --git a/libpsn00b/psxapi/stubs.json b/libpsn00b/psxapi/stubs.json index 50ffb55..afa83c6 100644 --- a/libpsn00b/psxapi/stubs.json +++ b/libpsn00b/psxapi/stubs.json @@ -8,7 +8,7 @@ { "type": "a", "id": 1, - "name": "seek", + "name": "lseek", "file": "stdio.s" }, { @@ -37,6 +37,12 @@ }, { "type": "a", + "id": 7, + "name": "isatty", + "file": "stdio.s" + }, + { + "type": "a", "id": 8, "name": "getc", "file": "stdio.s" @@ -109,6 +115,12 @@ }, { "type": "a", + "id": 81, + "name": "LoadExec", + "file": "sys.s" + }, + { + "type": "a", "id": 85, "name": "_bu_init", "file": "drivers.s" @@ -128,7 +140,7 @@ { "type": "a", "id": 153, - "name": "AddDummyTty", + "name": "add_nullcon_driver", "file": "drivers.s" }, { @@ -139,6 +151,18 @@ }, { "type": "a", + "id": 157, + "name": "GetConf", + "file": "sys.s" + }, + { + "type": "a", + "id": 159, + "name": "SetMem", + "file": "sys.s" + }, + { + "type": "a", "id": 160, "name": "_boot", "file": "sys.s" @@ -170,13 +194,13 @@ { "type": "b", "id": 0, - "name": "_kernel_malloc", + "name": "alloc_kernel_memory", "file": "sys.s" }, { "type": "b", "id": 1, - "name": "_kernel_free", + "name": "free_kernel_memory", "file": "sys.s" }, { @@ -296,13 +320,13 @@ { "type": "b", "id": 24, - "name": "SetDefaultExitFromException", + "name": "ResetEntryInt", "file": "sys.s" }, { "type": "b", "id": 25, - "name": "SetCustomExitFromException", + "name": "HookEntryInt", "file": "sys.s" }, { @@ -314,7 +338,7 @@ { "type": "b", "id": 64, - "name": "chdir", + "name": "cd", "file": "fs.s" }, { @@ -343,20 +367,26 @@ }, { "type": "b", + "id": 70, + "name": "undelete", + "file": "fs.s" + }, + { + "type": "b", "id": 71, - "name": "AddDev", + "name": "AddDrv", "file": "drivers.s" }, { "type": "b", "id": 72, - "name": "DelDev", + "name": "DelDrv", "file": "drivers.s" }, { "type": "b", "id": 73, - "name": "ListDev", + "name": "ListDrv", "file": "drivers.s" }, { @@ -397,6 +427,18 @@ }, { "type": "b", + "id": 84, + "name": "_get_errno", + "file": "stdio.s" + }, + { + "type": "b", + "id": 85, + "name": "_get_error", + "file": "stdio.s" + }, + { + "type": "b", "id": 86, "name": "GetC0Table", "file": "sys.s" diff --git a/libpsn00b/psxapi/sys.s b/libpsn00b/psxapi/sys.s index e2505e1..40dcdff 100644 --- a/libpsn00b/psxapi/sys.s +++ b/libpsn00b/psxapi/sys.s @@ -6,7 +6,7 @@ .set noreorder -## A0 table functions (8) +## A0 table functions (11) .section .text.b_setjmp .global b_setjmp @@ -48,6 +48,14 @@ FlushCache: jr $t2 li $t1, 0x44 +.section .text.LoadExec +.global LoadExec +.type LoadExec, @function +LoadExec: + li $t2, 0xa0 + jr $t2 + li $t1, 0x51 + .section .text.SetConf .global SetConf .type SetConf, @function @@ -56,6 +64,22 @@ SetConf: jr $t2 li $t1, 0x9c +.section .text.GetConf +.global GetConf +.type GetConf, @function +GetConf: + li $t2, 0xa0 + jr $t2 + li $t1, 0x9d + +.section .text.SetMem +.global SetMem +.type SetMem, @function +SetMem: + li $t2, 0xa0 + jr $t2 + li $t1, 0x9f + .section .text._boot .global _boot .type _boot, @function @@ -74,18 +98,18 @@ GetSystemInfo: ## B0 table functions (27) -.section .text._kernel_malloc -.global _kernel_malloc -.type _kernel_malloc, @function -_kernel_malloc: +.section .text.alloc_kernel_memory +.global alloc_kernel_memory +.type alloc_kernel_memory, @function +alloc_kernel_memory: li $t2, 0xb0 jr $t2 li $t1, 0x00 -.section .text._kernel_free -.global _kernel_free -.type _kernel_free, @function -_kernel_free: +.section .text.free_kernel_memory +.global free_kernel_memory +.type free_kernel_memory, @function +free_kernel_memory: li $t2, 0xb0 jr $t2 li $t1, 0x01 @@ -242,18 +266,18 @@ ReturnFromException: jr $t2 li $t1, 0x17 -.section .text.SetDefaultExitFromException -.global SetDefaultExitFromException -.type SetDefaultExitFromException, @function -SetDefaultExitFromException: +.section .text.ResetEntryInt +.global ResetEntryInt +.type ResetEntryInt, @function +ResetEntryInt: li $t2, 0xb0 jr $t2 li $t1, 0x18 -.section .text.SetCustomExitFromException -.global SetCustomExitFromException -.type SetCustomExitFromException, @function -SetCustomExitFromException: +.section .text.HookEntryInt +.global HookEntryInt +.type HookEntryInt, @function +HookEntryInt: li $t2, 0xb0 jr $t2 li $t1, 0x19 |
