1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# PSn00bSDK syscall wrappers
# (C) 2022-2023 spicyjpeg - MPL licensed
.set noreorder
## Interrupt enable/disable
.section .text.EnterCriticalSection, "ax", @progbits
.global EnterCriticalSection
.type EnterCriticalSection, @function
EnterCriticalSection:
li $a0, 0x01
syscall 0
jr $ra
nop
.section .text.ExitCriticalSection, "ax", @progbits
.global ExitCriticalSection
.type ExitCriticalSection, @function
ExitCriticalSection:
li $a0, 0x02
syscall 0
jr $ra
nop
.section .text.SwEnterCriticalSection, "ax", @progbits
.global SwEnterCriticalSection
.type SwEnterCriticalSection, @function
SwEnterCriticalSection:
mfc0 $a0, $12 # cop0r12 &= ~0x401
li $a1, -1026
and $a1, $a0
mtc0 $a1, $12
andi $a0, 0x0401 # return !((cop0r12_prev & 0x401) < 0x401)
sltiu $v0, $a0, 0x0401
jr $ra
xori $v0, 1
.section .text.SwExitCriticalSection, "ax", @progbits
.global SwExitCriticalSection
.type SwExitCriticalSection, @function
SwExitCriticalSection:
mfc0 $a0, $12 # cop0r12 |= 0x401
nop
ori $a0, 0x0401
mtc0 $a0, $12
nop
jr $ra
nop
## PCDRV (host file access) API
.section .text.PCinit, "ax", @progbits
.global PCinit
.type PCinit, @function
PCinit:
break 0, 0x101 # () -> error
jr $ra
nop
.section .text.PCcreat, "ax", @progbits
.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, "ax", @progbits
.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, "ax", @progbits
.global PCclose
.type PCclose, @function
PCclose:
move $a1, $a0
break 0, 0x104 # (fd, fd) -> error
jr $ra
nop
.section .text.PCread, "ax", @progbits
.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, "ax", @progbits
.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, "ax", @progbits
.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
|