home *** CD-ROM | disk | FTP | other *** search
- /*
- * Common part of gemlib bindings
- *
- * ++jrb bammi@cadence.com
- * modified: mj -- ntomczak@vm.ucs.ualberta.ca
- */
- #define __IN_COMMON_C
- #include "common.h"
-
- /*
- * the common interface to aes
- * int __aes__(coded control);
- * unsigned long coded control;
- * coded control: (1 byte for each element of control in the long)
- * DD CC BB AA
- * DD : aes opcode
- * CC : sizeof _int_in
- * BB : sizeof _int_out
- * AA : sizeof _addrin
- *
- * Note: sizeof _addrout is needed only for rsrc_gaddr and is special
- * cased below.
- *
- * output: the value (int)_intout[0]
- */
-
- #ifdef __OLD__
- int __aes__(unsigned long coded_control)
- {
- register unsigned char *p = (unsigned char *)&coded_control;
- register unsigned short *q = &_control[0];
-
- /* decode control */
- do
- {
- *q++ = (unsigned short)(*p++);
- } while(q < &_control[4]);
-
- /* only rsrc_gaddr() needs this */
- *q = (_control[0] == 112) ? 1 : 0;
-
- /* call aes */
- __asm__ volatile
- (" movl %0, d1
- movw #0xc8, d0
- trap #2"
- : /* no outputs */
- : "g"(&_aesparams[0]) /* inputs */
- : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */
- );
- return (int)_int_out[0];
- }
- #else
- extern int (*__aes__)(unsigned long coded_control);
- /*
- * new more efficient coding thanks to Thomas Koenig (UI0T@DKAUNI2.BITNET)
- * "I made use here of the movep instruction for the 680xx, which transfers
- * data from a data register to alternate bytes of memory. The odd
- * address makes sure that these bytes are transferred to the lower half
- * of the words."
- */
- int _user_aes(unsigned long coded_control)
- {
-
- /* call aes */
- __asm__ volatile
- (" movel %1, d1
- moval %0@, a0 | lea %0@, a0 seems to moval %0,a0 why???
- moveq #0, d0
- movepl d0, a0@(0) | clear high bytes of control array
- movepl d1, a0@(1)
- movl %0, d1
- movw #0xc8,d0 | note -- no movq here, it sign extends
- trap #2
- movl %0, __aesparams"
- : /* no outputs */
- : "a"(_aesparams), "g"(coded_control) /* inputs */
- : "d0", "d1", "a0" /* clobbered regs */
- );
- __aes__=&_user_aes;
- return (int)_int_out[0];
- }
-
- #endif /* __OLD__ */
-