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