aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxapi
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-07-23 23:13:49 +0200
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-07-23 23:13:49 +0200
commit49ee8172ebb6c77071be113a01fc29c48b991479 (patch)
treee3f696b3deb326b7da455bc71d9a0a8d100daa70 /libpsn00b/psxapi
parent5b63607ba4ca12c2a2935ea9618b3ffe6a6d3ab3 (diff)
downloadpsn00bsdk-49ee8172ebb6c77071be113a01fc29c48b991479.tar.gz
Remove MDEC indev example, add more kernel APIs
Diffstat (limited to 'libpsn00b/psxapi')
-rw-r--r--libpsn00b/psxapi/_syscalls.s50
-rw-r--r--libpsn00b/psxapi/stubs.json70
-rw-r--r--libpsn00b/psxapi/sys.s114
3 files changed, 203 insertions, 31 deletions
diff --git a/libpsn00b/psxapi/_syscalls.s b/libpsn00b/psxapi/_syscalls.s
new file mode 100644
index 0000000..24864f3
--- /dev/null
+++ b/libpsn00b/psxapi/_syscalls.s
@@ -0,0 +1,50 @@
+# PSn00bSDK syscall wrappers
+# (C) 2022 spicyjpeg - MPL licensed
+
+.set noreorder
+
+.section .text.EnterCriticalSection
+.global EnterCriticalSection
+.type EnterCriticalSection, @function
+EnterCriticalSection:
+ li $a0, 0x01
+ syscall 0
+
+ jr $ra
+ nop
+
+.section .text.ExitCriticalSection
+.global ExitCriticalSection
+.type ExitCriticalSection, @function
+ExitCriticalSection:
+ li $a0, 0x02
+ syscall 0
+
+ jr $ra
+ nop
+
+.section .text.SwEnterCriticalSection
+.global SwEnterCriticalSection
+.type SwEnterCriticalSection, @function
+SwEnterCriticalSection:
+ mfc0 $a0, $12 # cop0r12 &= ~0x00000401
+ li $a1, -1026
+ and $a0, $a1
+ mtc0 $a0, $12
+ nop
+
+ jr $ra
+ nop
+
+.section .text.SwExitCriticalSection
+.global SwExitCriticalSection
+.type SwExitCriticalSection, @function
+SwExitCriticalSection:
+ mfc0 $a0, $12 # cop0r12 |= 0x00000401
+ nop
+ ori $a0, 0x0401
+ mtc0 $a0, $12
+ nop
+
+ jr $ra
+ nop
diff --git a/libpsn00b/psxapi/stubs.json b/libpsn00b/psxapi/stubs.json
index 9198b06..200cbc7 100644
--- a/libpsn00b/psxapi/stubs.json
+++ b/libpsn00b/psxapi/stubs.json
@@ -133,6 +133,12 @@
},
{
"type": "a",
+ "id": 156,
+ "name": "SetConf",
+ "file": "sys.s"
+ },
+ {
+ "type": "a",
"id": 160,
"name": "_boot",
"file": "sys.s"
@@ -205,12 +211,36 @@
},
{
"type": "b",
+ "id": 7,
+ "name": "DeliverEvent",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
"id": 8,
"name": "OpenEvent",
"file": "sys.s"
},
{
"type": "b",
+ "id": 9,
+ "name": "CloseEvent",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
+ "id": 10,
+ "name": "WaitEvent",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
+ "id": 11,
+ "name": "TestEvent",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
"id": 12,
"name": "EnableEvent",
"file": "sys.s"
@@ -223,6 +253,24 @@
},
{
"type": "b",
+ "id": 14,
+ "name": "OpenTh",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
+ "id": 15,
+ "name": "CloseTh",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
+ "id": 16,
+ "name": "ChangeTh",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
"id": 18,
"name": "InitPAD",
"file": "sys.s"
@@ -259,6 +307,12 @@
},
{
"type": "b",
+ "id": 32,
+ "name": "UnDeliverEvent",
+ "file": "sys.s"
+ },
+ {
+ "type": "b",
"id": 64,
"name": "chdir",
"file": "fs.s"
@@ -391,20 +445,20 @@
},
{
"type": "c",
- "id": 10,
- "name": "ChangeClearRCnt",
+ "id": 7,
+ "name": "InstallExceptionHandlers",
"file": "sys.s"
},
{
- "type": "syscall",
- "id": 1,
- "name": "EnterCriticalSection",
+ "type": "c",
+ "id": 8,
+ "name": "SysInitMemory",
"file": "sys.s"
},
{
- "type": "syscall",
- "id": 2,
- "name": "ExitCriticalSection",
+ "type": "c",
+ "id": 10,
+ "name": "ChangeClearRCnt",
"file": "sys.s"
}
]
diff --git a/libpsn00b/psxapi/sys.s b/libpsn00b/psxapi/sys.s
index e54bd98..e2505e1 100644
--- a/libpsn00b/psxapi/sys.s
+++ b/libpsn00b/psxapi/sys.s
@@ -6,7 +6,7 @@
.set noreorder
-## A0 table functions (7)
+## A0 table functions (8)
.section .text.b_setjmp
.global b_setjmp
@@ -48,6 +48,14 @@ FlushCache:
jr $t2
li $t1, 0x44
+.section .text.SetConf
+.global SetConf
+.type SetConf, @function
+SetConf:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x9c
+
.section .text._boot
.global _boot
.type _boot, @function
@@ -64,7 +72,7 @@ GetSystemInfo:
jr $t2
li $t1, 0xb4
-## B0 table functions (19)
+## B0 table functions (27)
.section .text._kernel_malloc
.global _kernel_malloc
@@ -122,6 +130,14 @@ ResetRCnt:
jr $t2
li $t1, 0x06
+.section .text.DeliverEvent
+.global DeliverEvent
+.type DeliverEvent, @function
+DeliverEvent:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x07
+
.section .text.OpenEvent
.global OpenEvent
.type OpenEvent, @function
@@ -130,6 +146,30 @@ OpenEvent:
jr $t2
li $t1, 0x08
+.section .text.CloseEvent
+.global CloseEvent
+.type CloseEvent, @function
+CloseEvent:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x09
+
+.section .text.WaitEvent
+.global WaitEvent
+.type WaitEvent, @function
+WaitEvent:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x0a
+
+.section .text.TestEvent
+.global TestEvent
+.type TestEvent, @function
+TestEvent:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x0b
+
.section .text.EnableEvent
.global EnableEvent
.type EnableEvent, @function
@@ -146,6 +186,30 @@ DisableEvent:
jr $t2
li $t1, 0x0d
+.section .text.OpenTh
+.global OpenTh
+.type OpenTh, @function
+OpenTh:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x0e
+
+.section .text.CloseTh
+.global CloseTh
+.type CloseTh, @function
+CloseTh:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x0f
+
+.section .text.ChangeTh
+.global ChangeTh
+.type ChangeTh, @function
+ChangeTh:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x10
+
.section .text.InitPAD
.global InitPAD
.type InitPAD, @function
@@ -194,6 +258,14 @@ SetCustomExitFromException:
jr $t2
li $t1, 0x19
+.section .text.UnDeliverEvent
+.global UnDeliverEvent
+.type UnDeliverEvent, @function
+UnDeliverEvent:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x20
+
.section .text.GetC0Table
.global GetC0Table
.type GetC0Table, @function
@@ -218,7 +290,7 @@ ChangeClearPAD:
jr $t2
li $t1, 0x5b
-## C0 table functions (3)
+## C0 table functions (5)
.section .text.SysEnqIntRP
.global SysEnqIntRP
@@ -236,6 +308,22 @@ SysDeqIntRP:
jr $t2
li $t1, 0x03
+.section .text.InstallExceptionHandlers
+.global InstallExceptionHandlers
+.type InstallExceptionHandlers, @function
+InstallExceptionHandlers:
+ li $t2, 0xc0
+ jr $t2
+ li $t1, 0x07
+
+.section .text.SysInitMemory
+.global SysInitMemory
+.type SysInitMemory, @function
+SysInitMemory:
+ li $t2, 0xc0
+ jr $t2
+ li $t1, 0x08
+
.section .text.ChangeClearRCnt
.global ChangeClearRCnt
.type ChangeClearRCnt, @function
@@ -244,23 +332,3 @@ ChangeClearRCnt:
jr $t2
li $t1, 0x0a
-## Syscalls (2)
-
-.section .text.EnterCriticalSection
-.global EnterCriticalSection
-.type EnterCriticalSection, @function
-EnterCriticalSection:
- li $a0, 0x01
- syscall 0
- jr $ra
- nop
-
-.section .text.ExitCriticalSection
-.global ExitCriticalSection
-.type ExitCriticalSection, @function
-ExitCriticalSection:
- li $a0, 0x02
- syscall 0
- jr $ra
- nop
-