1 // from http://vserver.13thfloor.at/Experimental/SYSCALL/syscall_shiny15.h
3 #ifndef __SYSCALL_NEW_H
4 #define __SYSCALL_NEW_H
6 /* Copyright (C) 2005-2007 Herbert Pƶtzl
10 __sysc_seterr ... set error value (def: errno)
11 __sysc_cid(N) ... syscall 'name' id (def: __NR_<N>)
15 __sysc_regs ... the syscall registers (asm load)
16 __sysc_cmd(n) ... the syscall
17 __sysc_reg_cid ... syscall id register (asm load)
18 __sysc_reg_ret ... syscall return register (asm out)
19 __sysc_reg_err ... syscall error register (asm out)
21 __sysc_clbrs ... the clobbered syscall registers
22 __sysc_clobber ... clobbered registers (def: memory)
23 __sysc_max_err ... maximum error number (def: separate)
24 __sysc_errc(r,e)... error condition (def: e)
26 __sysc_type ... type of syscall arguments (def: long)
27 __sysc_acon(n) ... argument constraint (def: "r")
28 __sysc_con_cid ... syscall id constraint (def: "i"/"r")
29 __sysc_con_ret ... return value contraint (def: "=r")
30 __sysc_con_err ... error value contraint (def: "=r")
34 /* some fallback defaults */
37 #define __sysc_seterr(e) do { errno = (e); } while(0)
41 #define __sysc_cid(N) __NR_##N
45 /* *****************************************
46 ALPHA ALPHA ALPHA ALPHA *
47 alpha kernel interface */
49 #if defined(__alpha__)
51 /* The Alpha calling convention doesn't use the stack until
52 after the first six arguments have been passed in registers.
55 args: a1($16), a2($17), a3($18), a4($19), a5($20), a6($21)
57 serr: e0($19) (!=0, err=sret)
61 picr: pr($29) do we need to save that?
64 #define __sysc_cmd(n) "callsys"
66 #define __sysc_reg_cid "$0"
67 #define __sysc_con_cid "v"
68 #define __sysc_reg_ret "$0"
69 #define __sysc_con_ret "=v"
70 #define __sysc_reg_err "$19"
72 #define __sysc_regs "$16", "$17", "$18", "$19", "$20", "$21"
73 #define __sysc_clbrs "$16", "$17", "$18", "memory", "$20", "$21"
74 #define __sysc_clobber "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
75 "$22", "$23", "$24", "$25", "$27", "$28", "memory"
78 /* *****************************************
80 arm kernel interface */
82 #elif defined(__arm__)
84 /* The Arm calling convention uses stack args after four arguments
85 but the Linux kernel gets up to seven arguments in registers.
88 args: a1(r0), a2(r1), a3(r2), a4(r3), a5(r4), a6(r5),
90 serr: (sret >= (unsigned)-EMAXERRNO)
96 #define __sysc_max_err 125
98 #define __sysc_cmd(n) "swi %1"
100 #define __sysc_regs "r0", "r1", "r2", "r3", "r4", "r5"
101 #define __sysc_reg_ret "r0"
103 #warning syscall arch arm not tested yet
107 /* *****************************************
108 CRIS CRIS CRIS CRIS *
109 cris v10 kernel interface */
111 #elif defined(__cris__)
113 /* The Cris calling convention uses stack args after four arguments
114 but the Linux kernel gets up to six arguments in registers.
117 args: a1(r10), a2(r11), a3(r12), a4(r13), a5(mof), a6(srp),
119 serr: (sret >= (unsigned)-EMAXERRNO)
124 #error syscall arch cris not implemented yet
128 /* *****************************************
130 frv kernel interface */
132 #elif defined(__frv__)
134 /* The C calling convention on FR-V uses the gr8-gr13 registers
135 for the first six arguments, the remainder is spilled onto the
136 stack. the linux kernel syscall interface does so too.
139 args: a1(gr8), a2(gr9), a3(gr10), a4(gr11), a5(gr12), a6(gr13)
141 serr: (sret >= (unsigned)-EMAXERRNO)
146 #error syscall arch frv not implemented yet
150 /* *****************************************
151 H8300 H8300 H8300 H8300 *
152 h8/300 kernel interface */
154 #elif defined(__H8300__)
156 /* The H8/300 C calling convention passes the first three
157 arguments in registers. However the linux kernel calling
158 convention passes the first six arguments in registers
162 args: a1(er1), a2(er2), a3(er3), a4(er4), a5(er5), a6(er6)
164 serr: (sret >= (unsigned)-EMAXERRNO)
169 #error syscall arch h8300 not implemented yet
173 /* *****************************************
174 HPPA HPPA HPPA HPPA *
175 hppa/64 kernel interface */
177 #elif defined(__hppa__)
179 /* The hppa calling convention uses r26-r23 for the first 4
180 arguments, the rest is spilled onto the stack. However the
181 Linux kernel passes the first six arguments in the registers
184 The system call number MUST ALWAYS be loaded in the delay
185 slot of the ble instruction, or restarting system calls
189 args: a1(r26), a2(r25), a3(r24), a4(r23), a5(r22), a6(r21)
191 serr: (sret >= (unsigned)-EMAXERRNO)
192 call: ble 0x100(%%sr2, %%r0)
193 clob: r1, r2, (r4), r20, r29, r31, memory
194 picr: pr(r19) do we need to save that?
197 #define __sysc_max_err 4095
199 #define __sysc_cmd(n) \
200 __pasm(n,1,1, "copy %%r19, %%r4" ,)\
201 __casm(n,0,1, "ble 0x100(%%sr2,%%r0)" ,)\
202 __casm(n,0,1, "ldi %1,%%r20" ,)\
203 __pasm(n,1,1, "copy %%r4, %%r19" ,)
205 #define __sysc_regs "r26", "r25", "r24", "r23", "r22", "r21"
208 #define __sysc_clobber "r1", "r2", "r20", "r29", "r31", "memory"
210 #define __sysc_clobber "r1", "r2", "r4", "r20", "r29", "r31", "memory"
213 #warning syscall arch hppa not tested yet
217 /* *****************************************
218 I386 I386 I386 I386 *
219 i386 kernel interface */
221 #elif defined(__i386__)
223 /* The x86 calling convention uses stack args for all arguments,
224 but the Linux kernel passes the first six arguments in the
225 following registers: ebx, ecx, edx, esi, edi, ebp.
228 args: a1(ebx), a2(ecx), a3(edx), a4(esi), a5(edi), a6(ebp)
230 serr: (sret >= (unsigned)-EMAXERRNO)
237 #define __sysc_max_err 129
240 #define __sysc_clbrs "memory", "ebx", "ecx", "edx", "esi", "edi"
242 #define __sysc_clbrs "memory", "memory", "ecx", "edx", "esi", "edi"
245 #define __sysc_cmd(n) \
246 __casm(n,6,1, "movl %7, %%eax" ,)\
247 __casm(n,5,1, "movl %6, %%edi" ,)\
248 __casm(n,4,1, "movl %5, %%esi" ,)\
249 __casm(n,3,1, "movl %4, %%edx" ,)\
250 __casm(n,2,1, "movl %3, %%ecx" ,)\
251 __pasm(n,1,1, "pushl %%ebx" ,)\
252 __casm(n,1,1, "movl %2, %%ebx" ,)\
253 __casm(n,6,1, "pushl %%ebp" ,)\
254 __casm(n,6,1, "movl %%eax, %%ebp" ,)\
255 __casm(n,0,1, "movl %1, %%eax" ,)\
256 __casm(n,0,1, "int $0x80" ,)\
257 __casm(n,6,1, "popl %%ebp" ,)\
258 __pasm(n,1,1, "popl %%ebx" ,)
260 #define __sysc_acon(n) "g"
261 #define __sysc_reg_ret "eax"
262 #define __sysc_con_ret "=a"
266 /* *****************************************
267 IA64 IA64 IA64 IA64 *
268 ia64 kernel interface */
270 #elif defined(__ia64__)
272 /* The ia64 calling convention uses out0-out7 to pass the first
273 eight arguments (mapped via register windows).
276 args: a1(out0), a2(out1), ... a5(out4), a6(out5)
280 clob: out6/7, r2/3/9, r11-r14, r16-r31, p6-p15, f6-f15, b6/7
284 #define __sysc_errc(r,e) ((e) == -1)
286 #define __sysc_cmd(n) "break.i 0x100000"
288 #define __sysc_regs "out0", "out1", "out2", "out3", "out4", "out5"
289 #define __sysc_reg_cid "r15"
290 #define __sysc_reg_ret "r8"
291 #define __sysc_reg_err "r10"
293 #define __sysc_clobber \
294 "out6", "out7", "r2", "r3", "r9", "r11", "r12", "r13", \
295 "r14", "r16", "r17", "r18", "r19", "r20", "r21", "r22", \
296 "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", \
297 "r31", "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", \
298 "p14", "p15", "f6", "f7", "f8", "f9", "f10", "f11", "f12", \
299 "f13", "f14", "f15", "f16", "b6", "b7", "cc", "memory"
301 #warning syscall arch ia64 not tested yet
305 /* *****************************************
306 M32R M32R M32R M32R *
307 m32r kernel interface */
309 #elif defined(__M32R__)
311 /* The m32r calling convention uses r0-r7 to pass the first
312 eight arguments (mapped via register windows).
315 args: a1(r1), a2(r2), a3(r3), a4(r4), a5(r5), a6(r6)
317 serr: (sret >= (unsigned)-EMAXERRNO)
319 clob: out6/7, r2/3/9, r11-r14, r16-r31, p6-p15, f6-f15, b6/7
323 #define __sysc_max_err 125
325 #define __sysc_cmd(n) "trap #2"
327 #define __sysc_regs "r0", "r1", "r2", "r3", "r4", "r5"
328 #define __sysc_reg_cid "r7"
329 #define __sysc_reg_ret "r0"
331 #warning syscall arch m32r not tested yet
335 /* *****************************************
336 M68K M68K M68K M68K *
337 m68k kernel interface */
339 #elif defined(__m68000__)
341 #error syscall arch m68k not implemented yet
345 /* *****************************************
346 MIPS MIPS MIPS MIPS *
347 mips kernel interface */
349 #elif defined(__mips__)
351 /* The ABIO32 calling convention uses a0-a3 to pass the first
352 four arguments, the rest is passed on the userspace stack.
353 The 5th arg starts at 16($sp). The new mips calling abi uses
354 registers a0-a5, restart requires a reload of v0 (#syscall)
356 ABIN32 and ABI64 pass 6 args in a0-a3, t0-t1.
359 args: a1(a0), a2(a1), a3(a2), a4(a3), a5(t0), a6(t1)
363 clob: at, v1, t2-t7, t8-t9
367 #define __sysc_cmd(n) \
368 __casm(n,0,1, "ori $v0,$0,%2" ,)\
369 __casm(n,0,1, "syscall" ,)
371 #define __sysc_regs "a0","a1","a2","a3", "t0", "t1"
372 #define __sysc_reg_ret "v0"
373 #define __sysc_reg_err "a3"
375 #define __sysc_clobber "$1", "$3", "$10", "$11", "$12", \
376 "$13", "$14", "$15", "$24", "$25", "memory"
378 #warning syscall arch mips not tested yet
382 /* *****************************************
384 ppc/64 kernel interface */
386 #elif defined(__powerpc__)
388 /* The powerpc calling convention uses r3-r10 to pass the first
389 eight arguments, the remainder is spilled onto the stack.
392 args: a1(r3), a2(r4), a3(r5), a4(r6), a5(r7), a6(r8)
396 clob: r9-r12, cr0, ctr
400 #define __sysc_errc(r,e) ((e) & 0x10000000)
402 #define __sysc_cmd(n) \
403 __casm(n,0,1, "sc" ,)\
404 __casm(n,0,1, "mfcr %1" ,)
406 #define __sysc_regs "r3", "r4", "r5", "r6", "r7", "r8"
407 #define __sysc_reg_cid "r0"
408 #define __sysc_reg_ret "r3"
410 #define __sysc_clobber "r9", "r10", "r11", "r12", "cr0", "ctr", "memory"
414 /* *****************************************
415 S390 S390 S390 S390 *
416 s390/x kernel interface */
418 #elif defined(__s390__)
420 /* The s390x calling convention passes the first five arguments
421 in r2-r6, the remainder is spilled onto the stack. However
422 the Linux kernel passes the first six arguments in r2-r7.
425 args: a1(r2), a2(r3), a3(r4), a4(r5), a5(r6), a6(r7)
427 serr: (sret >= (unsigned)-EMAXERRNO)
432 #define __sysc_max_err 4095
434 #define __sysc_cmd(n) "svc 0"
436 // #define __sysc_type unsigned long
438 #define __sysc_regs "r2", "r3", "r4", "r5", "r6", "r7"
439 #define __sysc_reg_cid "r1"
440 #define __sysc_reg_ret "r2"
442 #warning syscall arch s390 not tested yet
446 /* *****************************************
448 sh kernel interface */
450 #elif defined(__sh__) && !defined(__SH5__)
452 /* The SuperH calling convention passes the first four arguments
453 in r4-r7, the remainder is spilled onto the stack. However
454 the Linux kernel passes the remainder in r0-r1.
457 args: a1(r4), a2(r5), a3(r6), a4(r7), a5(r0), a6(r1)
459 serr: (sret >= (unsigned)-EMAXERRNO)
460 call: trapa #0x1x (x=#args)
466 #define __sysc_arch "trapa #0x2"
468 #define __sysc_arch "trapa #0x1"
471 #define __sysc_max_err 4095
473 #define __sysc_cmd(n) __sysc_arch #n
475 #define __sysc_regs "r4", "r5", "r6", "r7", "r0", "r1"
476 #define __sysc_reg_cid "r3"
477 #define __sysc_reg_ret "r0"
479 #warning syscall arch sh not tested yet
483 /* *****************************************
484 SH64 SH64 SH64 SH64 *
485 sh64 kernel interface */
487 #elif defined(__sh__) && defined(__SH5__)
489 /* The SuperH-5 calling convention passes the first eight
490 arguments in r2-r9. The Linux kernel uses only six of
491 them as arguments, and the last one for the syscall id.
494 args: a1(r2), a2(r3), a3(r4), a4(r5), a5(r6), a6(r7)
496 serr: (sret >= (unsigned)-EMAXERRNO)
497 call: trapa #0x1x (x=#args)
502 #define __sysc_max_err 4095
504 #define __sysc_cmd(n) \
505 __casm(n,0,1, "movi 0x1" #n ",r9" ,)\
506 __casm(n,0,1, "shori %1,r9" ,)\
507 __casm(n,0,1, "trapa r9" ,)
509 #define __sysc_regs "r2", "r3", "r4", "r5", "r6", "r7"
510 #define __sysc_reg_ret "r9"
512 #warning syscall arch sh64 not tested yet
516 /* *****************************************
517 SPARC64 SPARC64 SPARC64 SPARC64 *
518 sparc64 kernel interface */
520 #elif defined(__sparc__)
522 /* The sparc/64 calling convention uses o0-o5 to pass the first
523 six arguments (mapped via register windows).
526 args: a1(o0), a2(o1), a3(o2), a4(o3), a5(o4), a6(o5)
529 call: ta 0x6d, t 0x10
530 clob: g1-g6, g7?, o7?, f0-f31, cc
535 #define __sysc_arch "ta 0x6d"
537 #define __sysc_arch "ta 0x10"
540 #define __sysc_cmd(n) \
541 __casm(n,0,1, __sysc_arch ,)\
542 __casm(n,0,1, "addx %%g0,%%g0,%1" ,)
544 #define __sysc_regs "o0", "o1", "o2", "o3", "o4", "o5"
545 #define __sysc_reg_cid "g1"
546 #define __sysc_reg_ret "o0"
548 #define __sysc_clobber "g2", "g3", "g4", "g5", "g6", \
549 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", \
550 "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", \
551 "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", \
552 "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", \
553 "f34", "f36", "f38", "f40", "f42", "f44", "f46", "f48", \
554 "f50", "f52", "f54", "f56", "f58", "f60", "f62", \
559 /* *****************************************
560 V850 V850 V850 V850 *
561 v850 kernel interface */
563 #elif defined(__v850__)
565 /* The V850 calling convention passes the first four arguments
566 in registers r6-r9, the rest is spilled onto the stack.
567 but the Linux kernel interface uses r6-r9 and r13/14.
570 args: a1(r6), a2(r7), a3(r8), a4(r9), a5(r13), a6(r14)
572 serr: (sret >= (unsigned)-EMAXERRNO)
574 clob: r1, r5, r11, r15-r19
577 #define __sysc_max_err 515
579 #define __sysc_cmd(n) \
580 __casm(n,4,0, "trap 1" ,"trap 0" )
582 #define __sysc_regs "r6", "r7", "r8", "r9", "r13", "r14"
583 #define __sysc_reg_cid "r12"
584 #define __sysc_reg_ret "r10"
586 #define __sysc_clobber "r1", "r5", "r11", \
587 "r15", "r16", "r17", "r18", "r19", "memory"
589 #warning syscall arch v850 not tested yet
593 /* *****************************************
594 X86_64 X86_64 X86_64 X86_64 *
595 x86_64 kernel interface */
597 #elif defined(__x86_64__)
599 /* The x86_64 calling convention uses rdi, rsi, rdx, rcx, r8, r9
600 but the Linux kernel interface uses rdi, rsi, rdx, r10, r8, r9.
603 args: a1(rdi), a2(rsi), a3(rdx), a4(r10), a5(r8), a6(r9)
605 serr: (err= sret > (unsigned)-EMAXERRNO)
610 #define __sysc_max_err 4095
612 #define __sysc_cmd(n) "syscall"
614 #define __sysc_regs "rdi", "rsi", "rdx", "r10", "r8", "r9"
615 #define __sysc_reg_cid "rax"
616 #define __sysc_reg_ret "rax"
617 #define __sysc_con_ret "=a"
619 #define __sysc_clobber "cc", "r11", "rcx", "memory"
622 #error unknown kernel arch
626 /* implementation defaults */
630 #ifndef __sysc_clobber
631 #define __sysc_clobber "memory"
635 #define __sysc_acon(n) "r"
638 #ifndef __sysc_con_ret
639 #define __sysc_con_ret "=r"
642 #ifndef __sysc_con_err
643 #define __sysc_con_err "=r"
646 #ifndef __sysc_con_cid
647 #ifdef __sysc_reg_cid
648 #define __sysc_con_cid "r"
650 #define __sysc_con_cid "i"
655 #define __sysc_type long
659 #define __sysc_rega(n,...) __arg_##n(__VA_ARGS__)
661 #define __sysc_reg(n) __sysc_rega(n,__sysc_regs)
669 #define __lst_6(x,a1,a2,a3,a4,a5,a6) __lst_5(x,a1,a2,a3,a4,a5),x(6,a6)
670 #define __lst_5(x,a1,a2,a3,a4,a5) __lst_4(x,a1,a2,a3,a4),x(5,a5)
671 #define __lst_4(x,a1,a2,a3,a4) __lst_3(x,a1,a2,a3),x(4,a4)
672 #define __lst_3(x,a1,a2,a3) __lst_2(x,a1,a2),x(3,a3)
673 #define __lst_2(x,a1,a2) __lst_1(x,a1),x(2,a2)
674 #define __lst_1(x,a1) __lst_0(x,*),x(1,a1)
675 #define __lst_0(x,a0)
677 /* argument selection */
680 #define __arg_1(a1,...) a1
681 #define __arg_2(a1,a2,...) a2
682 #define __arg_3(a1,a2,a3,...) a3
683 #define __arg_4(a1,a2,a3,a4,...) a4
684 #define __arg_5(a1,a2,a3,a4,a5,...) a5
685 #define __arg_6(a1,a2,a3,a4,a5,a6) a6
687 /* argument concatenation */
689 #define __con_6(x,a1,a2,a3,a4,a5,a6) __con_5(x,a1,a2,a3,a4,a5)x(6,a6)
690 #define __con_5(x,a1,a2,a3,a4,a5) __con_4(x,a1,a2,a3,a4)x(5,a5)
691 #define __con_4(x,a1,a2,a3,a4) __con_3(x,a1,a2,a3)x(4,a4)
692 #define __con_3(x,a1,a2,a3) __con_2(x,a1,a2)x(3,a3)
693 #define __con_2(x,a1,a2) __con_1(x,a1)x(2,a2)
694 #define __con_1(x,a1) __con_0(x,*)x(1,a1)
695 #define __con_0(x,a0)
699 #define __rem_0(a1,a2,a3,a4,a5,a6) ,a1,a2,a3,a4,a5,a6
700 #define __rem_1(a1,a2,a3,a4,a5,a6) ,a2,a3,a4,a5,a6
701 #define __rem_2(a1,a2,a3,a4,a5,a6) ,a3,a4,a5,a6
702 #define __rem_3(a1,a2,a3,a4,a5,a6) ,a4,a5,a6
703 #define __rem_4(a1,a2,a3,a4,a5,a6) ,a5,a6
704 #define __rem_5(a1,a2,a3,a4,a5,a6) ,a6
708 /* conditional asm */
710 #define __casm_use(q,r,v) v __casm_use_##q##r(__casm_nl(""))
712 #define __casm_use_10(v)
713 #define __casm_use_11(v) v
714 #define __casm_use_12(v)
715 #define __casm_use_13(v) v
717 #define __casm_use_20(v)
718 #define __casm_use_21(v)
719 #define __casm_use_22(v) v
720 #define __casm_use_23(v) v
723 #define __casm_00(v,w,r) __casm_use(1,r,v)
724 #define __casm_01(v,w,r) __casm_use(2,r,w)
725 #define __casm_02(v,w,r) __casm_use(2,r,w)
726 #define __casm_03(v,w,r) __casm_use(2,r,w)
727 #define __casm_04(v,w,r) __casm_use(2,r,w)
728 #define __casm_05(v,w,r) __casm_use(2,r,w)
729 #define __casm_06(v,w,r) __casm_use(2,r,w)
731 #define __casm_10(v,w,r) __casm_use(1,r,v)
732 #define __casm_11(v,w,r) __casm_use(1,r,v)
733 #define __casm_12(v,w,r) __casm_use(2,r,w)
734 #define __casm_13(v,w,r) __casm_use(2,r,w)
735 #define __casm_14(v,w,r) __casm_use(2,r,w)
736 #define __casm_15(v,w,r) __casm_use(2,r,w)
737 #define __casm_16(v,w,r) __casm_use(2,r,w)
739 #define __casm_20(v,w,r) __casm_use(1,r,v)
740 #define __casm_21(v,w,r) __casm_use(1,r,v)
741 #define __casm_22(v,w,r) __casm_use(1,r,v)
742 #define __casm_23(v,w,r) __casm_use(2,r,w)
743 #define __casm_24(v,w,r) __casm_use(2,r,w)
744 #define __casm_25(v,w,r) __casm_use(2,r,w)
745 #define __casm_26(v,w,r) __casm_use(2,r,w)
747 #define __casm_30(v,w,r) __casm_use(1,r,v)
748 #define __casm_31(v,w,r) __casm_use(1,r,v)
749 #define __casm_32(v,w,r) __casm_use(1,r,v)
750 #define __casm_33(v,w,r) __casm_use(1,r,v)
751 #define __casm_34(v,w,r) __casm_use(2,r,w)
752 #define __casm_35(v,w,r) __casm_use(2,r,w)
753 #define __casm_36(v,w,r) __casm_use(2,r,w)
755 #define __casm_40(v,w,r) __casm_use(1,r,v)
756 #define __casm_41(v,w,r) __casm_use(1,r,v)
757 #define __casm_42(v,w,r) __casm_use(1,r,v)
758 #define __casm_43(v,w,r) __casm_use(1,r,v)
759 #define __casm_44(v,w,r) __casm_use(1,r,v)
760 #define __casm_45(v,w,r) __casm_use(2,r,w)
761 #define __casm_46(v,w,r) __casm_use(2,r,w)
763 #define __casm_50(v,w,r) __casm_use(1,r,v)
764 #define __casm_51(v,w,r) __casm_use(1,r,v)
765 #define __casm_52(v,w,r) __casm_use(1,r,v)
766 #define __casm_53(v,w,r) __casm_use(1,r,v)
767 #define __casm_54(v,w,r) __casm_use(1,r,v)
768 #define __casm_55(v,w,r) __casm_use(1,r,v)
769 #define __casm_56(v,w,r) __casm_use(2,r,w)
771 #define __casm_60(v,w,r) __casm_use(1,r,v)
772 #define __casm_61(v,w,r) __casm_use(1,r,v)
773 #define __casm_62(v,w,r) __casm_use(1,r,v)
774 #define __casm_63(v,w,r) __casm_use(1,r,v)
775 #define __casm_64(v,w,r) __casm_use(1,r,v)
776 #define __casm_65(v,w,r) __casm_use(1,r,v)
777 #define __casm_66(v,w,r) __casm_use(1,r,v)
780 /* special PIC handling */
790 #define __casm_nl(v) v "\n\t"
792 #define __casm(n,a,r,v,w) __casm_##n##a(v,w,r)
794 #define __pasm(n,a,r,v,w) __pic(__casm(n,a,r,v,w))
795 #define __nasm(n,a,r,v,w) __nopic(__casm(n,a,r,v,w))
797 #define __sc_cast(v) (__sysc_type)(v)
798 #define __sc_ldef(N) __sysc_type N
799 #define __sc_rdef(N,R) register __sc_ldef(N) __sc_asm (R)
801 #define __sc_scid(N,v) __sc_ldef(N) = __sc_cast(v)
802 #define __sc_areg(N,R,v) __sc_rdef(N,R) = __sc_cast(v)
804 #define __sc_rval(n,v) "r"(__sc_a##n)
805 #define __sc_ival(n,v) __sysc_acon(n)(__sc_cast(v))
806 #define __sc_idef(n,v) __sc_areg(__sc_a##n, __sysc_reg(n), v);
809 #define __sc_cregs(n,...) __rem_##n(__VA_ARGS__)
811 #define __sc_cregs(n,...)
815 #define __sc_input(n,...) __con_##n(__sc_idef,__VA_ARGS__)
816 #define __sc_ivals(n,...) __lst_##n(__sc_rval,__VA_ARGS__)
818 #define __sc_input(n,...)
819 #define __sc_ivals(n,...) __lst_##n(__sc_ival,__VA_ARGS__)
822 #ifdef __sysc_reg_cid
823 #define __sc_cidvar(N) __sc_areg(__sc_id, \
824 __sysc_reg_cid, __sysc_cid(N))
825 #define __sc_cidval(N) __sysc_con_cid (__sc_id)
829 #define __sc_cidval(N) __sysc_con_cid (__sysc_cid(N))
833 #define __sc_cidvar(N)
837 #ifdef __sysc_reg_ret
838 #define __sc_ret __ret
839 #define __sc_def_ret __sc_ldef(ret); __sc_rdef(__sc_ret,__sysc_reg_ret)
842 #define __sc_def_ret __sc_ldef(__sc_ret)
845 #ifdef __sysc_reg_err
846 #define __sc_err __err
847 #define __sc_def_err __sc_ldef(err); __sc_rdef(__sc_err,__sysc_reg_err)
850 #define __sc_def_err __sc_ldef(__sc_err)
854 #ifndef __sysc_max_err
858 #ifdef __sc_complex /* complex result */
860 #define __sc_results __sc_def_ret; __sc_def_err
863 #define __sysc_errc(ret, err) (err)
867 #define __sysc_retv(type, ret, err) \
868 if (__sysc_errc(ret, err)) { \
869 __sysc_seterr(ret); \
875 #define __sc_oregs __sysc_con_ret (__sc_ret), \
876 __sysc_con_err (__sc_err)
877 #define __sc_return(t) ret = __sc_ret; err = __sc_err; \
878 __sysc_retv(t, ret, err)
880 #else /* simple result */
882 #define __sc_results __sc_def_ret
885 #define __sysc_errc(ret) \
886 ((unsigned __sysc_type)(ret) >= \
887 (unsigned __sysc_type)(-(__sysc_max_err)))
891 #define __sysc_retv(type, ret) \
892 if (__sysc_errc(ret)) { \
893 __sysc_seterr(-ret); \
899 #define __sc_oregs __sysc_con_ret (__sc_ret)
900 #define __sc_return(t) ret = __sc_ret; __sysc_retv(t, ret)
902 #endif /* simple/complex */
906 /* the inline syscall */
908 #define __sc_asm __asm__
909 #define __sc_asm_vol __asm__ __volatile__
911 #define __sc_syscall(n,N,...) \
912 __sc_asm_vol (__sysc_cmd(n) \
914 : __sc_cidval(N) __sc_ivals(n,__VA_ARGS__) \
915 : __sysc_clobber __sc_cregs(n,__sysc_clbrs))
918 #define __sc_body(n, type, name, ...) \
920 __sc_results;__sc_cidvar(name); \
921 __sc_input(n,__VA_ARGS__) \
922 __sc_syscall(n,name,__VA_ARGS__); \
927 #define _syscall0(type, name) \
929 __sc_body(0, type, name, *)
931 #define _syscall1(type, name, type1, arg1) \
932 type name(type1 arg1) \
933 __sc_body(1, type, name, arg1)
935 #define _syscall2(type, name, type1, arg1, type2, arg2) \
936 type name(type1 arg1, type2 arg2) \
937 __sc_body(2, type, name, arg1, arg2)
939 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
940 type name(type1 arg1, type2 arg2, type3 arg3) \
941 __sc_body(3, type, name, arg1, arg2, arg3)
943 #define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
945 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
946 __sc_body(4, type, name, arg1, arg2, arg3, arg4)
948 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
949 type4, arg4, type5, arg5) \
950 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
951 __sc_body(5, type, name, arg1, arg2, arg3, arg4, arg5)
953 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
954 type4, arg4, type5, arg5, type6, arg6) \
955 type name(type1 arg1, type2 arg2, type3 arg3, \
956 type4 arg4, type5 arg5, type6 arg6) \
957 __sc_body(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6)
961 #endif /* __SYSCALL_NEW_H */