Nugget
Loading...
Searching...
No Matches
syscalls.h
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2020 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <stdarg.h>
30#include <stddef.h>
31#include <stdint.h>
32
36
37struct JmpBuf;
38
39#ifndef PS1_PC_PORT
40static __attribute__((always_inline)) int enterCriticalSection() {
41 register int n asm("a0") = 1;
42 register int r asm("v0");
43 __asm__ volatile("syscall\n" : "=r"(r) : "r"(n) : "memory");
44 return r;
45}
46
47static __attribute__((always_inline)) void leaveCriticalSection() {
48 register int n asm("a0") = 2;
49 __asm__ volatile("syscall\n" : : "r"(n) : "memory");
50}
51
52static __attribute__((always_inline)) int changeThreadSubFunction(uint32_t address) {
53 register int n asm("a0") = 3;
54 register int tcb asm("a1") = address;
55 register int r asm("v0");
56 __asm__ volatile("syscall\n" : "=r"(r) : "r"(n), "r"(tcb) : "memory");
57 return r;
58}
59
60/* A0 table */
61static __attribute__((always_inline)) size_t syscall_write(int fd, const void *buf, size_t size) {
62 register int n asm("t1") = 0x03;
63 __asm__ volatile("" : "=r"(n) : "r"(n));
64 return ((size_t(*)(int, const void *, size_t))0xa0)(fd, buf, size);
65}
66
67static __attribute__((always_inline, returns_twice)) int syscall_setjmp(struct JmpBuf *buf) {
68 register int n asm("t1") = 0x13;
69 __asm__ volatile("" : "=r"(n) : "r"(n));
70 return ((int (*)(struct JmpBuf *buf))0xa0)(buf);
71}
72
73static __attribute__((always_inline, noreturn)) void syscall_longjmp(struct JmpBuf *buf, int ret) {
74 register int n asm("t1") = 0x14;
75 __asm__ volatile("" : "=r"(n) : "r"(n));
76 ((void (*)(struct JmpBuf *, int))0xa0)(buf, ret);
78}
79
80static __attribute__((always_inline)) char *syscall_strcat(char *dst, const char *src) {
81 register int n asm("t1") = 0x15;
82 __asm__ volatile("" : "=r"(n) : "r"(n));
83 return ((char *(*)(char *, const char *))0xa0)(dst, src);
84}
85
86static __attribute__((always_inline)) char *syscall_strncat(char *dst, const char *src, size_t size) {
87 register int n asm("t1") = 0x16;
88 __asm__ volatile("" : "=r"(n) : "r"(n));
89 return ((char *(*)(char *, const char *, size_t))0xa0)(dst, src, size);
90}
91
92static __attribute__((always_inline)) int syscall_strcmp(const char *s1, const char *s2) {
93 register int n asm("t1") = 0x17;
94 __asm__ volatile("" : "=r"(n) : "r"(n));
95 return ((int (*)(const char *, const char *))0xa0)(s1, s2);
96}
97
98static __attribute__((always_inline)) int syscall_strncmp(const char *s1, const char *s2, size_t size) {
99 register int n asm("t1") = 0x18;
100 __asm__ volatile("" : "=r"(n) : "r"(n));
101 return ((int (*)(const char *, const char *, size_t))0xa0)(s1, s2, size);
102}
103
104static __attribute__((always_inline)) char *syscall_strcpy(char *dst, const char *src) {
105 register int n asm("t1") = 0x19;
106 __asm__ volatile("" : "=r"(n) : "r"(n));
107 return ((char *(*)(char *, const char *))0xa0)(dst, src);
108}
109
110static __attribute__((always_inline)) char *syscall_strncpy(char *dst, const char *src, size_t size) {
111 register int n asm("t1") = 0x1a;
112 __asm__ volatile("" : "=r"(n) : "r"(n));
113 return ((char *(*)(char *, const char *, size_t))0xa0)(dst, src, size);
114}
115
116static __attribute__((always_inline)) size_t syscall_strlen(const char *s) {
117 register int n asm("t1") = 0x1b;
118 __asm__ volatile("" : "=r"(n) : "r"(n));
119 return ((size_t(*)(const char *))0xa0)(s);
120}
121
122static __attribute__((always_inline)) char *syscall_index(const char *s, int c) {
123 register int n asm("t1") = 0x1c;
124 __asm__ volatile("" : "=r"(n) : "r"(n));
125 return ((char *(*)(const char *, int c))0xa0)(s, c);
126}
127
128static __attribute__((always_inline)) char *syscall_rindex(const char *s, int c) {
129 register int n asm("t1") = 0x1d;
130 __asm__ volatile("" : "=r"(n) : "r"(n));
131 return ((char *(*)(const char *, int c))0xa0)(s, c);
132}
133
134static __attribute__((always_inline)) char *syscall_strchr(const char *s, int c) {
135 register int n asm("t1") = 0x1e;
136 __asm__ volatile("" : "=r"(n) : "r"(n));
137 return ((char *(*)(const char *, int c))0xa0)(s, c);
138}
139
140static __attribute__((always_inline)) char *syscall_strrchr(const char *s, int c) {
141 register int n asm("t1") = 0x1f;
142 __asm__ volatile("" : "=r"(n) : "r"(n));
143 return ((char *(*)(const char *, int c))0xa0)(s, c);
144}
145
146static __attribute__((always_inline)) void *syscall_memcpy(void *dst, const void *src, size_t count) {
147 register int n asm("t1") = 0x2a;
148 __asm__ volatile("" : "=r"(n) : "r"(n));
149 return ((void *(*)(void *, const void *, size_t))0xa0)(dst, src, count);
150}
151
152static __attribute__((always_inline)) void *syscall_memset(void *dst, int c, size_t count) {
153 register int n asm("t1") = 0x2b;
154 __asm__ volatile("" : "=r"(n) : "r"(n));
155 return ((void *(*)(void *, int, size_t))0xa0)(dst, c, count);
156}
157
158static __attribute__((always_inline)) void syscall_qsort(void *base, size_t nel, size_t width,
159 int (*compar)(const void *, const void *)) {
160 register int n asm("t1") = 0x31;
161 __asm__ volatile("" : "=r"(n) : "r"(n));
162 ((void (*)(void *, size_t, size_t, int (*)(const void *, const void *)))0xa0)(base, nel, width, compar);
163}
164
165static __attribute__((always_inline)) void *syscall_userMalloc(size_t size) {
166 register int n asm("t1") = 0x33;
167 __asm__ volatile("" : "=r"(n) : "r"(n));
168 return ((void *(*)(size_t))0xa0)(size);
169}
170
171static __attribute__((always_inline)) void syscall_userFree(void *ptr) {
172 register int n asm("t1") = 0x34;
173 __asm__ volatile("" : "=r"(n) : "r"(n));
174 ((void (*)(void *))0xa0)(ptr);
175}
176
177static __attribute__((always_inline)) void syscall_userInitheap(void *ptr, size_t size) {
178 register int n asm("t1") = 0x39;
179 __asm__ volatile("" : "=r"(n) : "r"(n));
180 ((void (*)(void *, size_t))0xa0)(ptr, size);
181}
182
183static __attribute__((always_inline)) void syscall__exit(int code) {
184 register int n asm("t1") = 0x3a;
185 __asm__ volatile("" : "=r"(n) : "r"(n));
186 ((void (*)(int))0xa0)(code);
187}
188
189static __attribute__((always_inline)) void syscall_puts(const char *msg) {
190 register int n asm("t1") = 0x3e;
191 __asm__ volatile("" : "=r"(n) : "r"(n));
192 ((void (*)(const char *))0xa0)(msg);
193}
194
195// doing this one in raw inline assembly would prove tricky,
196// and there's already enough voodoo in this file.
197// this is syscall a0:3f
198#ifdef __cplusplus
199extern "C" {
200#endif
201int romsyscall_printf(const char *fmt, ...);
202int ramsyscall_printf(const char *fmt, ...);
203#ifdef __cplusplus
204}
205#endif
206
207static __attribute__((always_inline)) int syscall_unresolvedException() {
208 register int n asm("t1") = 0x40;
209 __asm__ volatile("" : "=r"(n) : "r"(n));
210 return ((int (*)())0xa0)();
211}
212
213static __attribute__((always_inline)) void syscall_flushCache() {
214 register int n asm("t1") = 0x44;
215 __asm__ volatile("" : "=r"(n) : "r"(n));
216 ((void (*)())0xa0)();
217}
218
219static __attribute__((always_inline)) int syscall_cdromSeekL(uint8_t *msf) {
220 register int n asm("t1") = 0x78;
221 __asm__ volatile("" : "=r"(n) : "r"(n));
222 return ((int (*)(uint8_t *))0xa0)(msf);
223}
224
225static __attribute__((always_inline)) int syscall_cdromGetStatus(uint8_t *ptr) {
226 register int n asm("t1") = 0x7c;
227 __asm__ volatile("" : "=r"(n) : "r"(n));
228 return ((int (*)(uint8_t *))0xa0)(ptr);
229}
230
231static __attribute__((always_inline)) int syscall_cdromRead(int count, void *buffer, uint32_t mode) {
232 register int n asm("t1") = 0x7e;
233 __asm__ volatile("" : "=r"(n) : "r"(n));
234 return ((int (*)(int, void *, uint32_t))0xa0)(count, buffer, mode);
235}
236
237static __attribute__((always_inline)) int syscall_cdromInnerInit() {
238 register int n asm("t1") = 0x95;
239 __asm__ volatile("" : "=r"(n) : "r"(n));
240 return ((int (*)())0xa0)();
241}
242
243static __attribute__((always_inline)) int syscall_addCDRomDevice() {
244 register int n asm("t1") = 0x96;
245 __asm__ volatile("" : "=r"(n) : "r"(n));
246 return ((int (*)())0xa0)();
247}
248
249static __attribute__((always_inline)) int syscall_addMemoryCardDevice() {
250 register int n asm("t1") = 0x97;
251 __asm__ volatile("" : "=r"(n) : "r"(n));
252 return ((int (*)())0xa0)();
253}
254
255static __attribute__((always_inline)) int syscall_addConsoleDevice() {
256 register int n asm("t1") = 0x98;
257 __asm__ volatile("" : "=r"(n) : "r"(n));
258 return ((int (*)())0xa0)();
259}
260
261static __attribute__((always_inline)) int syscall_addDummyConsoleDevice() {
262 register int n asm("t1") = 0x99;
263 __asm__ volatile("" : "=r"(n) : "r"(n));
264 return ((int (*)())0xa0)();
265}
266
267static __attribute__((always_inline)) void syscall_exception(int code1, int code2) {
268 register int n asm("t1") = 0xa1;
269 __asm__ volatile("" : "=r"(n) : "r"(n));
270 ((void (*)(int, int))0xa0)(code1, code2);
271}
272
273static __attribute__((always_inline)) void syscall_enqueueCDRomHandlers() {
274 register int n asm("t1") = 0xa2;
275 __asm__ volatile("" : "=r"(n) : "r"(n));
276 ((void (*)())0xa0)();
277}
278
279static __attribute__((always_inline)) void syscall_dequeueCDRomHandlers() {
280 register int n asm("t1") = 0xa3;
281 __asm__ volatile("" : "=r"(n) : "r"(n));
282 ((void (*)())0xa0)();
283}
284
285static __attribute__((always_inline)) void syscall_buLowLevelOpCompleted() {
286 register int n asm("t1") = 0xa7;
287 __asm__ volatile("" : "=r"(n) : "r"(n));
288 ((void (*)())0xa0)();
289}
290
291static __attribute__((always_inline)) void syscall_buLowLevelOpError1() {
292 register int n asm("t1") = 0xa8;
293 __asm__ volatile("" : "=r"(n) : "r"(n));
294 ((void (*)())0xa0)();
295}
296
297static __attribute__((always_inline)) void syscall_buLowLevelOpError2() {
298 register int n asm("t1") = 0xa9;
299 __asm__ volatile("" : "=r"(n) : "r"(n));
300 ((void (*)())0xa0)();
301}
302
303static __attribute__((always_inline)) void syscall_buLowLevelOpError3() {
304 register int n asm("t1") = 0xaa;
305 __asm__ volatile("" : "=r"(n) : "r"(n));
306 ((void (*)())0xa0)();
307}
308
309static __attribute__((always_inline)) void syscall_buLowLevelOpError4() {
310 register int n asm("t1") = 0xae;
311 __asm__ volatile("" : "=r"(n) : "r"(n));
312 ((void (*)())0xa0)();
313}
314
315static __attribute__((always_inline)) int syscall_ioabortraw(int code) {
316 register int n asm("t1") = 0xb2;
317 __asm__ volatile("" : "=r"(n) : "r"(n));
318 return ((int (*)(int))0xa0)(code);
319}
320
321/* B0 table */
322static __attribute__((always_inline)) void *syscall_kmalloc(unsigned size) {
323 register int n asm("t1") = 0x00;
324 __asm__ volatile("" : "=r"(n) : "r"(n));
325 return ((void *(*)(unsigned))0xb0)(size);
326}
327
328static __attribute__((always_inline)) void syscall_kfree(void *ptr) {
329 register int n asm("t1") = 0x01;
330 __asm__ volatile("" : "=r"(n) : "r"(n));
331 ((void (*)(void *))0xb0)(ptr);
332}
333
334static __attribute__((always_inline)) int syscall_initTimer(uint32_t timer, uint16_t target, uint16_t flags) {
335 register int n asm("t1") = 0x02;
336 __asm__ volatile("" : "=r"(n) : "r"(n));
337 return ((int (*)(uint32_t, uint16_t, uint16_t))0xb0)(timer, target, flags);
338}
339
340static __attribute__((always_inline)) int syscall_getTimer(uint32_t timer) {
341 register int n asm("t1") = 0x03;
342 __asm__ volatile("" : "=r"(n) : "r"(n));
343 return ((int (*)(uint32_t))0xb0)(timer);
344}
345
346static __attribute__((always_inline)) int syscall_enableTimerIRQ(uint32_t timer) {
347 register int n asm("t1") = 0x04;
348 __asm__ volatile("" : "=r"(n) : "r"(n));
349 return ((int (*)(uint32_t))0xb0)(timer);
350}
351
352static __attribute__((always_inline)) int syscall_disableTimerIRQ(uint32_t timer) {
353 register int n asm("t1") = 0x05;
354 __asm__ volatile("" : "=r"(n) : "r"(n));
355 return ((int (*)(uint32_t))0xb0)(timer);
356}
357
358static __attribute__((always_inline)) int syscall_restartTimer(uint32_t timer) {
359 register int n asm("t1") = 0x06;
360 __asm__ volatile("" : "=r"(n) : "r"(n));
361 return ((int (*)(uint32_t))0xb0)(timer);
362}
363
364static __attribute__((always_inline)) void syscall_deliverEvent(uint32_t classId, uint32_t spec) {
365 register int n asm("t1") = 0x07;
366 __asm__ volatile("" : "=r"(n) : "r"(n));
367 ((void (*)(uint32_t, uint32_t))0xb0)(classId, spec);
368}
369
370static __attribute__((always_inline)) uint32_t syscall_openEvent(uint32_t classId, uint32_t spec, uint32_t mode,
371 void (*handler)()) {
372 register int n asm("t1") = 0x08;
373 __asm__ volatile("" : "=r"(n) : "r"(n));
374 return ((uint32_t(*)(uint32_t, uint32_t, uint32_t, void (*)()))0xb0)(classId, spec, mode, handler);
375}
376
377static __attribute__((always_inline)) int syscall_closeEvent(uint32_t event) {
378 register int n asm("t1") = 0x09;
379 __asm__ volatile("" : "=r"(n) : "r"(n));
380 return ((uint32_t(*)(uint32_t))0xb0)(event);
381}
382
383static __attribute__((always_inline)) int syscall_testEvent(uint32_t event) {
384 register int n asm("t1") = 0x0b;
385 __asm__ volatile("" : "=r"(n) : "r"(n));
386 return ((int (*)(uint32_t))0xb0)(event);
387}
388
389static __attribute__((always_inline)) int syscall_enableEvent(uint32_t event) {
390 register int n asm("t1") = 0x0c;
391 __asm__ volatile("" : "=r"(n) : "r"(n));
392 return ((int (*)(uint32_t))0xb0)(event);
393}
394
395static __attribute__((always_inline)) void syscall_initPad(void *buffer1, size_t size1, void *buffer2, size_t size2) {
396 register int n asm("t1") = 0x12;
397 __asm__ volatile("" : "=r"(n) : "r"(n));
398 ((void (*)(void *, size_t, void *, size_t))0xb0)(buffer1, size1, buffer2, size2);
399}
400
401static __attribute__((always_inline)) void syscall_startPad() {
402 register int n asm("t1") = 0x13;
403 __asm__ volatile("" : "=r"(n) : "r"(n));
404 ((void (*)())0xb0)();
405}
406
407static __attribute__((always_inline)) void syscall_stopPad() {
408 register int n asm("t1") = 0x14;
409 __asm__ volatile("" : "=r"(n) : "r"(n));
410 ((void (*)())0xb0)();
411}
412
413static __attribute__((always_inline, noreturn)) void syscall_returnFromException() {
414 register int n asm("t1") = 0x17;
415 __asm__ volatile("" : "=r"(n) : "r"(n));
416 ((__attribute__((noreturn)) void (*)())0xb0)();
418}
419
420static __attribute__((always_inline)) void syscall_setDefaultExceptionJmpBuf() {
421 register int n asm("t1") = 0x18;
422 __asm__ volatile("" : "=r"(n) : "r"(n));
423 ((void (*)())0xb0)();
424}
425
426static __attribute__((always_inline)) void syscall_undeliverEvent(uint32_t classId, uint32_t mode) {
427 register int n asm("t1") = 0x20;
428 __asm__ volatile("" : "=r"(n) : "r"(n));
429 ((void (*)(uint32_t, uint32_t))0xb0)(classId, mode);
430}
431
432static __attribute__((always_inline)) int syscall_open(const char *filename, int mode) {
433 register int n asm("t1") = 0x32;
434 __asm__ volatile("" : "=r"(n) : "r"(n));
435 return ((int (*)(const char *, int))0xb0)(filename, mode);
436}
437
438static __attribute__((always_inline)) int syscall_read(int fd, void *buffer, int size) {
439 register int n asm("t1") = 0x34;
440 __asm__ volatile("" : "=r"(n) : "r"(n));
441 return ((int (*)(int, void *, int))0xb0)(fd, buffer, size);
442}
443
444static __attribute__((always_inline)) int syscall_close(int fd) {
445 register int n asm("t1") = 0x36;
446 __asm__ volatile("" : "=r"(n) : "r"(n));
447 return ((int (*)(int))0xb0)(fd);
448}
449
450static __attribute__((always_inline)) void syscall_putchar(int c) {
451 register int n asm("t1") = 0x3d;
452 __asm__ volatile("" : "=r"(n) : "r"(n));
453 ((void (*)(int))0xb0)(c);
454}
455
456static __attribute__((always_inline)) int syscall_addDevice(const struct Device *device) {
457 register int n asm("t1") = 0x47;
458 __asm__ volatile("" : "=r"(n) : "r"(n));
459 return ((int (*)(const struct Device *))0xb0)(device);
460}
461
462static __attribute__((always_inline)) int syscall_cardInfoInternal(int deviceID) {
463 register int n asm("t1") = 0x4d;
464 __asm__ volatile("" : "=r"(n) : "r"(n));
465 return ((int (*)(int))0xb0)(deviceID);
466}
467
468static __attribute__((always_inline)) int syscall_mcWriteSector(int deviceID, int sector, const uint8_t *buffer) {
469 register int n asm("t1") = 0x4e;
470 __asm__ volatile("" : "=r"(n) : "r"(n));
471 return ((int (*)(int, int, const uint8_t *))0xb0)(deviceID, sector, buffer);
472}
473
474static __attribute__((always_inline)) int syscall_mcReadSector(int deviceID, int sector, uint8_t *buffer) {
475 register int n asm("t1") = 0x4f;
476 __asm__ volatile("" : "=r"(n) : "r"(n));
477 return ((int (*)(int, int, uint8_t *))0xb0)(deviceID, sector, buffer);
478}
479
480static __attribute__((always_inline)) void syscall_mcAllowNewCard() {
481 register int n asm("t1") = 0x50;
482 __asm__ volatile("" : "=r"(n) : "r"(n));
483 ((void (*)())0xb0)();
484}
485
486static __attribute__((always_inline)) const uint8_t *syscall_Krom2RawAdd(uint32_t c) {
487 register int n asm("t1") = 0x51;
488 __asm__ volatile("" : "=r"(n) : "r"(n));
489 return ((uint8_t * (*)(uint32_t))0xb0)(c);
490}
491
492static __attribute__((always_inline)) int syscall_mcGetLastDevice() {
493 register int n asm("t1") = 0x58;
494 __asm__ volatile("" : "=r"(n) : "r"(n));
495 return ((int (*)())0xb0)();
496}
497
498/* C0 table */
499static __attribute__((always_inline)) int syscall_enqueueRCntIrqs(int priority) {
500 register int n asm("t1") = 0x00;
501 __asm__ volatile("" : "=r"(n) : "r"(n));
502 return ((int (*)(int))0xc0)(priority);
503}
504
505static __attribute__((always_inline)) int syscall_enqueueSyscallHandler(int priority) {
506 register int n asm("t1") = 0x01;
507 __asm__ volatile("" : "=r"(n) : "r"(n));
508 return ((int (*)(int))0xc0)(priority);
509}
510
511static __attribute__((always_inline)) int syscall_sysEnqIntRP(int priority, struct HandlerInfo *info) {
512 register int n asm("t1") = 0x02;
513 __asm__ volatile("" : "=r"(n) : "r"(n));
514 return ((int (*)(int, struct HandlerInfo *))0xc0)(priority, info);
515}
516
517static __attribute__((always_inline)) int syscall_sysDeqIntRP(int priority, struct HandlerInfo *info) {
518 register int n asm("t1") = 0x03;
519 __asm__ volatile("" : "=r"(n) : "r"(n));
520 return ((int (*)(int, struct HandlerInfo *))0xc0)(priority, info);
521}
522
523static __attribute__((always_inline)) void syscall_installExceptionHandler() {
524 register int n asm("t1") = 0x07;
525 __asm__ volatile("" : "=r"(n) : "r"(n));
526 ((void (*)())0xc0)();
527}
528
529static __attribute__((always_inline)) void syscall_kernInitheap(void *base, size_t size) {
530 register int n asm("t1") = 0x08;
531 __asm__ volatile("" : "=r"(n) : "r"(n));
532 ((void (*)(void *, size_t))0xc0)(base, size);
533}
534
535static __attribute__((always_inline)) int syscall_setTimerAutoAck(uint32_t timer, int value) {
536 register int n asm("t1") = 0x0a;
537 __asm__ volatile("" : "=r"(n) : "r"(n));
538 return ((int (*)(uint32_t, int))0xc0)(timer, value);
539}
540
541static __attribute__((always_inline)) int syscall_enqueueIrqHandler(int priority) {
542 register int n asm("t1") = 0x0c;
543 __asm__ volatile("" : "=r"(n) : "r"(n));
544 return ((int (*)(int))0xc0)(priority);
545}
546
547// This syscall is broken beyond repair, as the kernel code contains a race
548// condition that can cause the kernel to lose IRQs. Please don't use it.
549static __attribute__((always_inline)) void syscall_setIrqAutoAck(uint32_t irq, int value) {
550 register int n asm("t1") = 0x0d;
551 __asm__ volatile("" : "=r"(n) : "r"(n));
552 ((void (*)(uint32_t, int))0xc0)(irq, value);
553}
554
555static __attribute__((always_inline)) void syscall_setupFileIO(int installTTY) {
556 register int n asm("t1") = 0x12;
557 __asm__ volatile("" : "=r"(n) : "r"(n));
558 ((void (*)(int))0xc0)(installTTY);
559}
560
561static __attribute__((always_inline)) void syscall_cdevinput(struct CircularBuffer *circ, int c) {
562 register int n asm("t1") = 0x15;
563 __asm__ volatile("" : "=r"(n) : "r"(n));
564 ((void (*)(struct CircularBuffer *, int))0xc0)(circ, c);
565}
566
567static __attribute__((always_inline)) void syscall_cdevscan() {
568 register int n asm("t1") = 0x16;
569 __asm__ volatile("" : "=r"(n) : "r"(n));
570 ((void (*)())0xc0)();
571}
572
573static __attribute__((always_inline)) int syscall_circgetc(struct CircularBuffer *circ) {
574 register int n asm("t1") = 0x17;
575 __asm__ volatile("" : "=r"(n) : "r"(n));
576 return ((int (*)(struct CircularBuffer *))0xc0)(circ);
577}
578
579static __attribute__((always_inline)) int syscall_ioabort(const char *msg) {
580 register int n asm("t1") = 0x19;
581 __asm__ volatile("" : "=r"(n) : "r"(n));
582 return ((int (*)(const char *))0xc0)(msg);
583}
584
585static __attribute__((always_inline)) void syscall_setDeviceStatus(int status) {
586 register int n asm("t1") = 0x1a;
587 __asm__ volatile("" : "=r"(n) : "r"(n));
588 ((void (*)(int))0xc0)(status);
589}
590
591static __attribute__((always_inline)) void syscall_patchA0table() {
592 register int n asm("t1") = 0x1c;
593 __asm__ volatile("" : "=r"(n) : "r"(n));
594 ((void (*)())0xc0)();
595}
596
597static __attribute__((always_inline)) int syscall_getDeviceStatus() {
598 register int n asm("t1") = 0x1d;
599 __asm__ volatile("" : "=r"(n) : "r"(n));
600 return ((int (*)())0xc0)();
601}
602#endif // #ifdef PS1_PC_PORT
volatile uint32_t * ptr
Definition cop0.c:80
uint32_t r
Definition cpu.c:222
fptr __preinit_array_start[] __attribute__((weak))
Definition cxxglue.c:76
int n
Definition dcache.c:225
ramsyscall_printf("=== e01_kseg1_reads_no_fill ===\n")
syscall_qsort(input, size, sizeof(input[0]), icmp)
char * s
Definition string.c:48
Definition circularbuffer.h:37
Definition device.h:62
Definition handlers.h:33
Definition setjmp.h:31
uint32_t s1
Definition setjmp.h:32
Definition xprintf.c:112
int romsyscall_printf(const char *fmt,...)
static int value
Definition syscalls.h:535
__builtin_unreachable()
static void * buffer
Definition syscalls.h:231
static uint32_t spec
Definition syscalls.h:364
static size_t nel
Definition syscalls.h:158
static size_t size_t width
Definition syscalls.h:158
static size_t size1
Definition syscalls.h:395
static uint16_t target
Definition syscalls.h:334
static const char * s2
Definition syscalls.h:92
static const void size_t count
Definition syscalls.h:146
static int ret
Definition syscalls.h:73
static uint32_t uint32_t void(* handler)())
Definition syscalls.h:371
static int c
Definition syscalls.h:122
static struct HandlerInfo * info
Definition syscalls.h:511
static const void * buf
Definition syscalls.h:61
static int sector
Definition syscalls.h:468
static size_t void size_t size2
Definition syscalls.h:395
static const void size_t size
Definition syscalls.h:61
static uint16_t uint16_t flags
Definition syscalls.h:334
static size_t size_t int(* compar)(const void *, const void *))
Definition syscalls.h:159
static size_t void * buffer2
Definition syscalls.h:395
void void(ptr, size)
static const char * src
Definition syscalls.h:80
static void uint32_t mode
Definition syscalls.h:231
void int(code1, code2)
static int code2
Definition syscalls.h:267
void uint32_t(classId, spec)