GEMLIB  0.44.0
gem_aesP.h
1 /*
2  * $Id: gem_aesP.h,v 1.10 2015/08/23 17:32:42 landemarre Exp $
3  */
4 
5 #ifndef _GEM_AES_P_
6 # define _GEM_AES_P_
7 
8 # ifndef _GEMLIB_H_
9 # include "mt_gem.h"
10 # endif
11 
12 
13 #if defined(__GNUC__) && !defined(__NO_INLINE__)
14 
15 static inline void
16 _aes_trap (AESPB * aespb)
17 {
18  __asm__ volatile (
19  "move.l %0,d1\n\t" /* &aespb */
20  "move.w #200,d0\n\t"
21  "trap #2"
22  :
23  : "g"(aespb)
24  : "d0","d1","d2","a0","a1","a2","memory"
25  );
26 }
27 #define AES_TRAP(aespb) _aes_trap(&aespb)
28 
29 #else
30 
31 #if defined(__VBCC__)
32 
33 __regsused("d0/d1/a0/a1") void _aes_trap(__reg("d1")AESPB *) =
34  "\tmove.l\td2,-(sp)\n"
35  "\tmove.l\ta2,-(sp)\n"
36  "\tmove.w\t#200,d0\n"
37  "\ttrap\t#2\n"
38  "\tmove.l\t(sp)+,a2\n"
39  "\tmove.l\t(sp)+,d2";
40 #define AES_TRAP(aespb) _aes_trap(&aespb)
41 
42 #else /* no usage of inlines, go the old way */
43 
44 #define AES_TRAP(aespb) aes(&aespb)
45 
46 #endif /* __VBCC__ */
47 #endif
48 
49 
50 #define AES_PARAMS(a,b,c,d,e) \
51  static short aes_control[AES_CTRLMAX]={a,b,c,d,e}; \
52  short aes_intin[AES_INTINMAX]; \
53  short aes_intout[AES_INTOUTMAX]; \
54  long aes_addrin[AES_ADDRINMAX]; \
55  long aes_addrout[AES_ADDROUTMAX]; \
56  \
57  AESPB aes_params; \
58  aes_params.control = &aes_control[0]; \
59  aes_params.global = &global_aes[0]; \
60  aes_params.intin = &aes_intin[0]; \
61  aes_params.intout = &aes_intout[0]; \
62  aes_params.addrin = &aes_addrin[0]; \
63  aes_params.addrout = &aes_addrout[0]
64 
65 
66 #endif /* _GEM_AES_P_ */
67 
68 
69 /* special feature for AES bindings: pointer in parameters (for return values)
70  * could be NULL (nice idea by Martin Elsasser against dummy variables)
71  */
72 #define CHECK_NULLPTR 1
Definition: mt_gem.h:2084