add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / arch / m68k-amiga / hidd / p96gfx / p96call.c
blobba95f38d54ad0fbd41408ff1c75f6edbfd261c1d
1 /*
2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 /* This program generates the p96call.h macroset for gcc-4.5.1 m68k-elf
7 * WARNING: The header generated by this program is designed
8 * to work with GCC 4.5.1 m68k-elf ONLY, and even
9 * then it has only been very lightly tested with
10 * "-O2 -fomit-frame-pointer -ffixed-a6"
12 * If it breaks, you get to keep both pieces.
15 #include <stdio.h>
17 #define GENCALL_MAX (13 + 1) /* Max number of arguments */
19 static void asm_regs_init(int id, int has_bn, const char *jmp, const char *addr)
21 int i;
23 /* Input values */
24 for (i = 0; i < id; i++)
25 printf("\t ULONG _arg%d = (ULONG)__AROS_LCA(a%d); \\\n",
26 i + 1, i + 1);
27 if (has_bn)
28 printf("\t ULONG _bn_arg = (ULONG)bn; \\\n");
30 /* Define registers */
31 printf("\t register volatile ULONG _ret asm(\"%%d0\"); \\\n");
32 for (i = 0; i < id; i++)
33 printf("\t register volatile ULONG __AROS_LTA(a%d) asm(__AROS_LSA(a%d)); \\\n",
34 i + 1, i + 1);
35 if (has_bn)
36 printf("\t register volatile ULONG _bn asm(\"%%a6\"); \\\n");
39 /* Set registers (non FP) */
40 for (i = 1; i <= id; i++)
41 printf("\t if (! __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n"
42 "\t __AROS_LTA(a%d) = _arg%d; } \\\n",
43 i, i, i);
44 if (has_bn)
45 printf("\t if (! __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n"
46 "\t _bn = _bn_arg; } \\\n");
48 /* Set FP register */
49 for (i = 1; i <= id; i++) {
50 int j;
51 printf("\t if ( __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n"
52 "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_arg%d), %s \\\n",
53 i, jmp, i, addr);
54 for (j = 0; j < id; j++)
55 printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1);
56 printf("\t ); }\\\n");
58 if (has_bn) {
59 int j;
60 printf("\t if ( __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n"
61 "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_bn_arg), %s \\\n", jmp, addr);
62 for (j = 0; j < id; j++)
63 printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1);
64 printf("\t ); }\\\n");
66 if (has_bn || id > 0) {
67 int j;
68 printf("\t if (!(0");
69 if (has_bn)
70 printf(" || __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)");
71 for (i = 0; i < id; i++)
72 printf(" || __AROS_ISREG(a%d,__AROS_FP_REG)", i+1);
73 printf(")) {\\\n"
74 "\t asm volatile (\"%s\\n\" : : \"i\" (0), %s \\\n", jmp, addr);
75 for (j = 0; j < id; j++)
76 printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1);
77 printf("\t ); }\\\n");
81 static void asm_regs_exit(int id, int has_bn)
83 /* Get the return code */
84 printf("\t asm volatile (\"\" : \"=r\" (_ret) : : \"%%a0\", \"%%a1\", \"%%d1\", \"cc\", \"memory\"); \\\n");
86 /* Save retval */
87 printf("\t (t)_ret; \\\n");
90 static void p96_lc(int id)
92 int i;
93 char jmp[256];
95 printf("#define P96_LC%d(t,vector,id", id);
96 for (i = 0; i < id; i++)
97 printf(",a%d", i + 1);
98 printf(") \\\n");
99 printf("\t({ APTR _n = (vector);\\\n");
100 snprintf(jmp, sizeof(jmp), "move.l %%3,%%%%sp@-\\n"
101 "pea.l .Lufc%d_%%c2\\n"
102 "move.l %%1, %%%%sp@-\\n"
103 "rts\\n"
104 ".Lufc%d_%%c2:\\n"
105 "addq.l #4,%%%%sp\\n"
106 , id, id);
107 jmp[sizeof(jmp)-1]=0;
108 asm_regs_init(i, 0, jmp, "\"r\" (_n), \"i\" (__LINE__), \"i\" (id)");
110 asm_regs_exit(i, 0);
111 printf("\t })\n\n");
114 int main(int argc, char **argv)
116 int i;
118 printf("/* AUTOGENERATED by p96call.c */\n");
119 printf("/* If you can get this to work for anything other */\n");
120 printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n");
121 printf("\n");
122 printf("#ifndef P96CALL_H\n");
123 printf("#define P96CALL_H\n");
124 printf("\n");
125 printf("/* Call a P96 function */\n");
126 printf("\n");
128 for (i = 0; i < GENCALL_MAX; i++)
129 p96_lc(i);
131 printf("#endif /* P96CALL_H */\n");
132 return 0;