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