Updated PCI IDs to latest snapshot.
[tangerine.git] / compiler / include / aros / shcommands_notembedded.h
blob730d673612d30b7eb18bc86f0cef4fa86de117e3
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef SHCOMMANDS_EMBEDDED_H
7 #define SHCOMMANDS_EMBEDDED_H
9 #include <dos/dos.h>
10 #include <dos/rdargs.h>
11 #include <proto/dos.h>
12 #include <proto/exec.h>
13 #include <aros/asmcall.h>
15 #define _stringify(x) #x
16 #define stringify(x) _stringify(x)
18 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
19 # define AMIGANATIVETRICK \
20 asm("\t.text \n" \
21 "\tmove.l 4.w,a6 \n" \
22 "\tjra __entry(pc) \n");
23 #else
24 # define AMIGANATIVETRICK
25 #endif
27 #if SH_GLOBAL_DOSBASE
28 # define DECLARE_DOSBase_global extern struct DosLibrary *DOSBase;
29 # define DEFINE_DOSBase_global struct DosLibrary *DOSBase;
30 # define DEFINE_DOSBase_local
31 #else
32 # define DECLARE_DOSBase_global
33 # define DEFINE_DOSBase_local struct DosLibrary *DOSBase;
34 # define DEFINE_DOSBase_global
35 #endif
37 #define CALL_main(name) name##_main(__shargs, argstr, SysBase, DOSBase)
38 #define DECLARE_main(name) \
39 static ULONG name##_main(IPTR *__shargs, char * __argstr, \
40 struct ExecBase *SysBase, \
41 struct DosLibrary *DOSBase)
42 #define DEFINE_main(name) DECLARE_main(name)
44 #define SHArg(name) (*(SHA_##name##_type *)&__shargs[SHA_##name])
45 #define SHArgLine() __argstr
47 #define __SHA_ENUM(type, abbr, name, modf, def, help) SHA_##name
48 #define __SHA_DEF(type, abbr, name, modf, def, help) (IPTR)(def)
49 #define __SHA_OPT(type, abbr, name, modf, def, help) \
50 stringify(abbr) stringify(name) stringify(modf)
51 #define __SHA_TYPEDEF(type, abbr, name, modf, def, help) \
52 typedef type SHA_##name##_type
55 #define __AROS_SH_ARGS(name, version, numargs, defl, templ, help) \
56 AMIGANATIVETRICK \
57 DECLARE_main(name); \
58 DECLARE_DOSBase_global \
60 AROS_UFH3(__startup static LONG, _entry, \
61 AROS_UFHA(char *,argstr,A0), \
62 AROS_UFHA(ULONG,argsize,D0), \
63 AROS_UFHA(struct ExecBase *,SysBase,A6) \
64 ) \
65 { \
66 AROS_USERFUNC_INIT \
68 DEFINE_DOSBase_local \
70 LONG __retcode = RETURN_FAIL; \
71 IPTR __shargs[numargs] = defl; \
72 struct RDArgs *__rda = NULL; \
73 struct RDArgs *__rda2 = NULL; \
75 DOSBase = (struct DosLibrary *) OpenLibrary(DOSNAME, 37); \
77 if (!DOSBase) \
78 { \
79 SetIoErr(ERROR_INVALID_RESIDENT_LIBRARY); \
80 goto __exit; \
81 } \
83 if (help[0]) \
84 { \
85 __rda2 = (struct RDArgs *)AllocDosObject(DOS_RDARGS, NULL); \
86 if (!__rda2) \
87 { \
88 PrintFault(IoErr(), stringify(name)); \
89 goto __exit; \
90 } \
91 __rda2->RDA_ExtHelp = help; \
92 } \
94 __rda = ReadArgs(templ, __shargs, __rda2); \
96 if (!__rda) \
97 { \
98 PrintFault(IoErr(), stringify(name)); \
99 goto __exit; \
102 __retcode = CALL_main(name); \
104 __exit: \
105 if (__rda) FreeArgs(__rda); \
106 if (help[0] && __rda2) FreeDosObject(DOS_RDARGS, __rda2); \
107 if (DOSBase) CloseLibrary((struct Library *)DOSBase); \
109 return __retcode; \
111 AROS_USERFUNC_EXIT \
114 DEFINE_DOSBase_global \
116 __used static const UBYTE name##_version[] = "$VER: " \
117 stringify(name) " " \
118 stringify(version) " " \
119 "(" __DATE__ ")\n"; \
121 DEFINE_main(name) \
124 #define AROS_SHCOMMAND_INIT
126 #define AROS_SHCOMMAND_EXIT \
130 #define __DEF(x...) {x}
132 #define __AROS_SH0(name, version, help) \
133 __AROS_SH_ARGS(name, version, 1, {0}, "", help) \
136 #define __AROS_SH1(name, version, help, a1) \
137 __AROS_SH_ARGS(name, version, 1, \
138 __DEF(__SHA_DEF(a1)), \
139 __SHA_OPT(a1), \
140 help) \
142 __SHA_TYPEDEF(a1); \
143 enum {__SHA_ENUM(a1)};
145 #define __AROS_SH2(name, version, help, a1, a2) \
146 __AROS_SH_ARGS(name, version, 2, \
147 __DEF(__SHA_DEF(a1), __SHA_DEF(a2)), \
148 __SHA_OPT(a1) "," __SHA_OPT(a2), \
149 help) \
151 __SHA_TYPEDEF(a1); \
152 __SHA_TYPEDEF(a2); \
153 enum {__SHA_ENUM(a1), __SHA_ENUM(a2)};
155 #define __AROS_SH3(name, version, help, a1, a2, a3) \
156 __AROS_SH_ARGS(name, version, 3, \
157 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
158 __SHA_DEF(a3)), \
159 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
160 __SHA_OPT(a3), \
161 help) \
163 __SHA_TYPEDEF(a1); \
164 __SHA_TYPEDEF(a2); \
165 __SHA_TYPEDEF(a3); \
166 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), \
167 __SHA_ENUM(a3)};
169 #define __AROS_SH4(name, version, help, a1, a2, a3, a4) \
170 __AROS_SH_ARGS(name, version, 4, \
171 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
172 __SHA_DEF(a3), __SHA_DEF(a4)), \
173 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
174 __SHA_OPT(a3) "," __SHA_OPT(a4), \
175 help) \
177 __SHA_TYPEDEF(a1); \
178 __SHA_TYPEDEF(a2); \
179 __SHA_TYPEDEF(a3); \
180 __SHA_TYPEDEF(a4); \
181 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), \
182 __SHA_ENUM(a3), __SHA_ENUM(a4)};
184 #define __AROS_SH5(name, version, help, a1, a2, a3, a4, a5) \
185 __AROS_SH_ARGS(name, version, 5, \
186 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
187 __SHA_DEF(a3), __SHA_DEF(a4), \
188 __SHA_DEF(a5)), \
189 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
190 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
191 __SHA_OPT(a5), \
192 help) \
194 __SHA_TYPEDEF(a1); \
195 __SHA_TYPEDEF(a2); \
196 __SHA_TYPEDEF(a3); \
197 __SHA_TYPEDEF(a4); \
198 __SHA_TYPEDEF(a5); \
199 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
200 __SHA_ENUM(a4), __SHA_ENUM(a5)};
202 #define __AROS_SH6(name, version, help, a1, a2, a3, a4, a5, a6) \
203 __AROS_SH_ARGS(name, version, 6, \
204 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
205 __SHA_DEF(a3), __SHA_DEF(a4), \
206 __SHA_DEF(a5), __SHA_DEF(a6)), \
207 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
208 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
209 __SHA_OPT(a5) "," __SHA_OPT(a6), \
210 help) \
212 __SHA_TYPEDEF(a1); \
213 __SHA_TYPEDEF(a2); \
214 __SHA_TYPEDEF(a3); \
215 __SHA_TYPEDEF(a4); \
216 __SHA_TYPEDEF(a5); \
217 __SHA_TYPEDEF(a6); \
218 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
219 __SHA_ENUM(a4), __SHA_ENUM(a5), __SHA_ENUM(a6)};
221 #define __AROS_SH7(name, version, help, a1, a2, a3, a4, a5, \
222 a6, a7) \
223 __AROS_SH_ARGS(name, version, 7, \
224 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
225 __SHA_DEF(a3), __SHA_DEF(a4), \
226 __SHA_DEF(a5), __SHA_DEF(a6), \
227 __SHA_DEF(a7)), \
228 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
229 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
230 __SHA_OPT(a5) "," __SHA_OPT(a6) "," \
231 __SHA_OPT(a7), \
232 help) \
234 __SHA_TYPEDEF(a1); \
235 __SHA_TYPEDEF(a2); \
236 __SHA_TYPEDEF(a3); \
237 __SHA_TYPEDEF(a4); \
238 __SHA_TYPEDEF(a5); \
239 __SHA_TYPEDEF(a6); \
240 __SHA_TYPEDEF(a7); \
241 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
242 __SHA_ENUM(a4), __SHA_ENUM(a5), __SHA_ENUM(a6), \
243 __SHA_ENUM(a7)};
245 #define __AROS_SH8(name, version, help, a1, a2, a3, a4, a5, \
246 a6, a7, a8) \
247 __AROS_SH_ARGS(name, version, 8, \
248 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
249 __SHA_DEF(a3), __SHA_DEF(a4), \
250 __SHA_DEF(a5), __SHA_DEF(a6), \
251 __SHA_DEF(a7), __SHA_DEF(a8)), \
252 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
253 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
254 __SHA_OPT(a5) "," __SHA_OPT(a6) "," \
255 __SHA_OPT(a7) "," __SHA_OPT(a8), \
256 help) \
258 __SHA_TYPEDEF(a1); \
259 __SHA_TYPEDEF(a2); \
260 __SHA_TYPEDEF(a3); \
261 __SHA_TYPEDEF(a4); \
262 __SHA_TYPEDEF(a5); \
263 __SHA_TYPEDEF(a6); \
264 __SHA_TYPEDEF(a7); \
265 __SHA_TYPEDEF(a8); \
266 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
267 __SHA_ENUM(a4), __SHA_ENUM(a5), __SHA_ENUM(a6), \
268 __SHA_ENUM(a7), __SHA_ENUM(a8)};
271 #define __AROS_SH10(name, version, help, a1, a2, a3, a4, a5, \
272 a6, a7, a8, a9, a10) \
273 __AROS_SH_ARGS(name, version, 10, \
274 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
275 __SHA_DEF(a3), __SHA_DEF(a4), \
276 __SHA_DEF(a5), __SHA_DEF(a6), \
277 __SHA_DEF(a7), __SHA_DEF(a8), \
278 __SHA_DEF(a9), __SHA_DEF(a10)), \
279 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
280 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
281 __SHA_OPT(a5) "," __SHA_OPT(a6) "," \
282 __SHA_OPT(a7) "," __SHA_OPT(a8) "," \
283 __SHA_OPT(a9) "," __SHA_OPT(a10), \
284 help) \
286 __SHA_TYPEDEF(a1); \
287 __SHA_TYPEDEF(a2); \
288 __SHA_TYPEDEF(a3); \
289 __SHA_TYPEDEF(a4); \
290 __SHA_TYPEDEF(a5); \
291 __SHA_TYPEDEF(a6); \
292 __SHA_TYPEDEF(a7); \
293 __SHA_TYPEDEF(a8); \
294 __SHA_TYPEDEF(a9); \
295 __SHA_TYPEDEF(a10); \
296 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
297 __SHA_ENUM(a4), __SHA_ENUM(a5), __SHA_ENUM(a6), \
298 __SHA_ENUM(a7), __SHA_ENUM(a8), __SHA_ENUM(a9), \
299 __SHA_ENUM(a10)};
301 #define __AROS_SH11(name, version, help, a1, a2, a3, a4, a5, \
302 a6, a7, a8, a9, a10, \
303 a11) \
304 __AROS_SH_ARGS(name, version, 11, \
305 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
306 __SHA_DEF(a3), __SHA_DEF(a4), \
307 __SHA_DEF(a5), __SHA_DEF(a6), \
308 __SHA_DEF(a7), __SHA_DEF(a8), \
309 __SHA_DEF(a9), __SHA_DEF(a10), \
310 __SHA_DEF(a11)), \
311 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
312 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
313 __SHA_OPT(a5) "," __SHA_OPT(a6) "," \
314 __SHA_OPT(a7) "," __SHA_OPT(a8) "," \
315 __SHA_OPT(a9) "," __SHA_OPT(a10) "." \
316 __SHA_OPT(a11), help) \
318 __SHA_TYPEDEF(a1); \
319 __SHA_TYPEDEF(a2); \
320 __SHA_TYPEDEF(a3); \
321 __SHA_TYPEDEF(a4); \
322 __SHA_TYPEDEF(a5); \
323 __SHA_TYPEDEF(a6); \
324 __SHA_TYPEDEF(a7); \
325 __SHA_TYPEDEF(a8); \
326 __SHA_TYPEDEF(a9); \
327 __SHA_TYPEDEF(a10); \
328 __SHA_TYPEDEF(a11); \
329 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
330 __SHA_ENUM(a4), __SHA_ENUM(a5), __SHA_ENUM(a6), \
331 __SHA_ENUM(a7), __SHA_ENUM(a8), __SHA_ENUM(a9), \
332 __SHA_ENUM(a10), __SHA_ENUM(a11)};
334 #define __AROS_SH12(name, version, help, a1, a2, a3, a4, a5, \
335 a6, a7, a8, a9, a10, \
336 a11, a12) \
337 __AROS_SH_ARGS(name, version, 12, \
338 __DEF(__SHA_DEF(a1), __SHA_DEF(a2), \
339 __SHA_DEF(a3), __SHA_DEF(a4), \
340 __SHA_DEF(a5), __SHA_DEF(a6), \
341 __SHA_DEF(a7), __SHA_DEF(a8), \
342 __SHA_DEF(a9), __SHA_DEF(a10), \
343 __SHA_DEF(a11), __SHA_DEF(a12)), \
344 __SHA_OPT(a1) "," __SHA_OPT(a2) "," \
345 __SHA_OPT(a3) "," __SHA_OPT(a4) "," \
346 __SHA_OPT(a5) "," __SHA_OPT(a6) "," \
347 __SHA_OPT(a7) "," __SHA_OPT(a8) "," \
348 __SHA_OPT(a9) "," __SHA_OPT(a10) "." \
349 __SHA_OPT(a11) "," __SHA_OPT(a12), \
350 help) \
352 __SHA_TYPEDEF(a1); \
353 __SHA_TYPEDEF(a2); \
354 __SHA_TYPEDEF(a3); \
355 __SHA_TYPEDEF(a4); \
356 __SHA_TYPEDEF(a5); \
357 __SHA_TYPEDEF(a6); \
358 __SHA_TYPEDEF(a7); \
359 __SHA_TYPEDEF(a8); \
360 __SHA_TYPEDEF(a9); \
361 __SHA_TYPEDEF(a10); \
362 __SHA_TYPEDEF(a11); \
363 __SHA_TYPEDEF(a12); \
364 enum {__SHA_ENUM(a1), __SHA_ENUM(a2), __SHA_ENUM(a3), \
365 __SHA_ENUM(a4), __SHA_ENUM(a5), __SHA_ENUM(a6), \
366 __SHA_ENUM(a7), __SHA_ENUM(a8), __SHA_ENUM(a9), \
367 __SHA_ENUM(a10), __SHA_ENUM(a11), __SHA_ENUM(a12)};
369 #define AROS_SHA(type, abbr, name, modf, def) type,abbr,name,modf,def,""
370 #define AROS_SHAH(type, abbr, name, modf, def, help) type,abbr,name,modf,def,"\t" __SHA_OPT(type,abbr,name,modf,def,help) "\t\t" help "\n"
372 #define __AROS_SHA(type, abbr, name, modf, def, help) type,abbr,name,modf,def,help
374 #define AROS_SH12(name, version, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) \
375 __AROS_SH12(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6), __AROS_SHA(a7), __AROS_SHA(a8), __AROS_SHA(a9), __AROS_SHA(a10), __AROS_SHA(a11), __AROS_SHA(a12))
376 #define AROS_SH11(name, version, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
377 __AROS_SH11(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6), __AROS_SHA(a7), __AROS_SHA(a8), __AROS_SHA(a9), __AROS_SHA(a10), __AROS_SHA(a11))
378 #define AROS_SH10(name, version, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)\
379 __AROS_SH10(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6), __AROS_SHA(a7), __AROS_SHA(a8), __AROS_SHA(a9), __AROS_SHA(a10))
380 #define AROS_SH9(name, version, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
381 __AROS_SH9(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6), __AROS_SHA(a7), __AROS_SHA(a8), __AROS_SHA(a9))
382 #define AROS_SH8(name, version, a1, a2, a3, a4, a5, a6, a7, a8) \
383 __AROS_SH8(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6), __AROS_SHA(a7), __AROS_SHA(a8))
384 #define AROS_SH7(name, version, a1, a2, a3, a4, a5, a6, a7) \
385 __AROS_SH7(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6), __AROS_SHA(a7))
386 #define AROS_SH6(name, version, a1, a2, a3, a4, a5, a6) \
387 __AROS_SH6(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5), __AROS_SHA(a6))
388 #define AROS_SH5(name, version, a1, a2, a3, a4, a5) \
389 __AROS_SH5(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4), __AROS_SHA(a5))
390 #define AROS_SH4(name, version, a1, a2, a3, a4) \
391 __AROS_SH4(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3), __AROS_SHA(a4))
392 #define AROS_SH3(name, version, a1, a2, a3) \
393 __AROS_SH3(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2), __AROS_SHA(a3))
394 #define AROS_SH2(name, version, a1, a2) \
395 __AROS_SH2(name, version, "", __AROS_SHA(a1), __AROS_SHA(a2))
396 #define AROS_SH1(name, version, a1) \
397 __AROS_SH1(name, version, "", __AROS_SHA(a1))
398 #define AROS_SH0(name, version) \
399 __AROS_SH0(name, version, "")
401 #define __SH_HELP(name, help) stringify(name) ": " help "\n"
402 #define __SHA_HELP(type, abbr, name, modf, def, help) help
404 #define AROS_SH1H(name, version, help, a1) \
405 __AROS_SH1(name, version, __SH_HELP(name, help) __SHA_HELP(a1), __AROS_SHA(a1))
406 #define AROS_SH0H(name, version, help) \
407 __AROS_SH0(name, version, __SH_HELP(name, help))
409 #endif /* SHCOMMANDS_NOTEMBEDDED_H */