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");
46static __attribute__((always_inline))
void leaveCriticalSection() {
47 register int n
asm(
"a0") = 2;
48 __asm__
volatile(
"syscall\n" : :
"r"(n) :
"memory");
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");
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);
67 register int n
asm(
"t1") = 0x13;
68 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
73 register int n
asm(
"t1") = 0x14;
74 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
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);
92 register int n
asm(
"t1") = 0x17;
93 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
94 return ((
int (*)(
const char *,
const char *))0xa0)(
s1,
s2);
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);
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);
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);
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);
122 register int n
asm(
"t1") = 0x1c;
123 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
124 return ((
char *(*)(
const char *,
int c))0xa0)(
s,
c);
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);
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);
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);
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);
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);
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);
165 register int n
asm(
"t1") = 0x33;
166 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
167 return ((
void *(*)(
size_t))0xa0)(
size);
171 register int n
asm(
"t1") = 0x34;
172 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
177 register int n
asm(
"t1") = 0x39;
178 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
182static __attribute__((always_inline))
void syscall__exit(
int code) {
183 register int n
asm(
"t1") = 0x3a;
184 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
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)();
212static __attribute__((always_inline))
void syscall_flushCache() {
213 register int n
asm(
"t1") = 0x44;
214 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
215 ((
void (*)())0xa0)();
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);
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);
231 register int n
asm(
"t1") = 0x7e;
232 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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)();
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)();
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)();
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)();
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)();
267 register int n
asm(
"t1") = 0xa1;
268 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
272static __attribute__((always_inline))
void syscall_enqueueCDRomHandlers() {
273 register int n
asm(
"t1") = 0xa2;
274 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
275 ((
void (*)())0xa0)();
278static __attribute__((always_inline))
void syscall_dequeueCDRomHandlers() {
279 register int n
asm(
"t1") = 0xa3;
280 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
281 ((
void (*)())0xa0)();
284static __attribute__((always_inline))
void syscall_buLowLevelOpCompleted() {
285 register int n
asm(
"t1") = 0xa7;
286 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
287 ((
void (*)())0xa0)();
290static __attribute__((always_inline))
void syscall_buLowLevelOpError1() {
291 register int n
asm(
"t1") = 0xa8;
292 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
293 ((
void (*)())0xa0)();
296static __attribute__((always_inline))
void syscall_buLowLevelOpError2() {
297 register int n
asm(
"t1") = 0xa9;
298 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
299 ((
void (*)())0xa0)();
302static __attribute__((always_inline))
void syscall_buLowLevelOpError3() {
303 register int n
asm(
"t1") = 0xaa;
304 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
305 ((
void (*)())0xa0)();
308static __attribute__((always_inline))
void syscall_buLowLevelOpError4() {
309 register int n
asm(
"t1") = 0xae;
310 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
311 ((
void (*)())0xa0)();
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);
322 register int n
asm(
"t1") = 0x00;
323 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
324 return ((
void *(*)(
unsigned))0xb0)(
size);
328 register int n
asm(
"t1") = 0x01;
329 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
334 register int n
asm(
"t1") = 0x02;
335 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
340 register int n
asm(
"t1") = 0x03;
341 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
342 return ((
int (*)(
uint32_t))0xb0)(timer);
346 register int n
asm(
"t1") = 0x04;
347 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
348 return ((
int (*)(
uint32_t))0xb0)(timer);
352 register int n
asm(
"t1") = 0x05;
353 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
354 return ((
int (*)(
uint32_t))0xb0)(timer);
358 register int n
asm(
"t1") = 0x06;
359 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
360 return ((
int (*)(
uint32_t))0xb0)(timer);
364 register int n
asm(
"t1") = 0x07;
365 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
371 register int n
asm(
"t1") = 0x08;
372 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
377 register int n
asm(
"t1") = 0x09;
378 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
383 register int n
asm(
"t1") = 0x0b;
384 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
385 return ((
int (*)(
uint32_t))0xb0)(event);
389 register int n
asm(
"t1") = 0x0c;
390 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
391 return ((
int (*)(
uint32_t))0xb0)(event);
395 register int n
asm(
"t1") = 0x12;
396 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
400static __attribute__((always_inline))
void syscall_startPad() {
401 register int n
asm(
"t1") = 0x13;
402 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
403 ((
void (*)())0xb0)();
406static __attribute__((always_inline))
void syscall_stopPad() {
407 register int n
asm(
"t1") = 0x14;
408 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
409 ((
void (*)())0xb0)();
412static __attribute__((always_inline, noreturn))
void syscall_returnFromException() {
413 register int n
asm(
"t1") = 0x17;
414 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
419static __attribute__((always_inline))
void syscall_setDefaultExceptionJmpBuf() {
420 register int n
asm(
"t1") = 0x18;
421 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
422 ((
void (*)())0xb0)();
426 register int n
asm(
"t1") = 0x20;
427 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
438 register int n
asm(
"t1") = 0x34;
439 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
449static __attribute__((always_inline))
void syscall_putchar(
int c) {
450 register int n
asm(
"t1") = 0x3d;
451 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
456 register int n
asm(
"t1") = 0x47;
457 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
458 return ((
int (*)(
const struct Device *))0xb0)(device);
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);
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);
474 register int n
asm(
"t1") = 0x4f;
475 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
479static __attribute__((always_inline))
void syscall_mcAllowNewCard() {
480 register int n
asm(
"t1") = 0x50;
481 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
482 ((
void (*)())0xb0)();
486 register int n
asm(
"t1") = 0x51;
487 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
488 return ((uint8_t * (*)(
uint32_t))0xb0)(
c);
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)();
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);
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);
511 register int n
asm(
"t1") = 0x02;
512 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
517 register int n
asm(
"t1") = 0x03;
518 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
522static __attribute__((always_inline))
void syscall_installExceptionHandler() {
523 register int n
asm(
"t1") = 0x07;
524 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
525 ((
void (*)())0xc0)();
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));
535 register int n
asm(
"t1") = 0x0a;
536 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
549 register int n
asm(
"t1") = 0x0d;
550 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
561 register int n
asm(
"t1") = 0x15;
562 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
566static __attribute__((always_inline))
void syscall_cdevscan() {
567 register int n
asm(
"t1") = 0x16;
568 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
569 ((
void (*)())0xc0)();
573 register int n
asm(
"t1") = 0x17;
574 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
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);
584static __attribute__((always_inline))
void syscall_setDeviceStatus(
int status) {
585 register int n
asm(
"t1") = 0x1a;
586 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
590static __attribute__((always_inline))
void syscall_patchA0table() {
591 register int n
asm(
"t1") = 0x1c;
592 __asm__
volatile(
"" :
"=r"(n) :
"r"(n));
593 ((
void (*)())0xc0)();
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)();
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
uint32_t s1
Definition setjmp.h:32
int romsyscall_printf(const char *fmt,...)
static int value
Definition syscalls.h:534
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
static const char * src
Definition syscalls.h:79
static int code2
Definition syscalls.h:266
void uint32_t(classId, spec)