Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

gem_vdiP.h

00001 /*
00002  *  $Id: gem_vdiP.h,v 1.10 2003/09/22 19:07:45 a_bercegeay Exp $
00003  */
00004 
00005 #ifndef _GEM_VDI_P_
00006 # define _GEM_VDI_P_
00007 
00008 # ifndef _GEMLIB_H_
00009 #  include "mt_gem.h"
00010 # endif
00011 
00012 
00013 #define vdi_control_ptr(n)   *((void**)(vdi_control +n))
00014 #define vdi_intin_ptr(n)     *((void**)(vdi_intin   +n))
00015 #define vdi_intout_long(n)   *((long*) (vdi_intout  +n))
00016 
00017 #if defined(__GNUC_INLINE__) && (__GNUC__ > 2 || __GNUC_MINOR__ > 5)
00018 
00019 static inline void
00020 _vdi_trap_esc (VDIPB * vdipb,
00021                long cntrl_0_1, long cntrl_3, long cntrl_5, short handle)
00022 {
00023     __asm__ volatile (
00024         "movea.l    %0,a0\n\t"  /* &vdipb */
00025         "move.l a0,d1\n\t"
00026         "move.l (a0),a0\n\t"    /* vdipb->control */
00027         "move.l %1,(a0)+\n\t"   /* cntrl_0, cntrl_1 */
00028         "move.l %2,(a0)+\n\t"   /* cntrl_2, cntrl_3 */
00029         "move.l %3,(a0)+\n\t"   /* cntrl_4, cntrl_5 */
00030         "move.w %4,(a0)\n\t"    /* handle */
00031         "move.w #115,d0\n\t"    /* 0x0073 */
00032         "trap   #2"
00033         :
00034         : "a"(vdipb), "g"(cntrl_0_1), "g"(cntrl_3), "g"(cntrl_5), "g"(handle)
00035         : "a0", "d0", "d1", "memory"
00036     );
00037 }
00038 #define VDI_TRAP_ESC(vdipb, handle, opcode, subop, cntrl_1, cntrl_3) \
00039     _vdi_trap_esc (&vdipb, (opcode##uL<<16)|cntrl_1, cntrl_3, subop, handle)
00040 
00041 static inline void
00042 _vdi_trap_00 (VDIPB * vdipb, long cntrl_0_1, short handle)
00043 {
00044     __asm__ volatile (
00045         "movea.l %0,a0\n\t" /* &vdipb */
00046         "move.l  a0,d1\n\t"
00047         "move.l  (a0),a0\n\t"   /* vdipb->control */
00048         "move.l  %1,(a0)+\n\t"  /* cntrl_0, cntrl_1 */
00049         "eor.l   d0,d0\n\t"
00050         "move.l  d0,(a0)+\n\t"  /* cntrl_2, cntrl_3 */
00051         "move.l  d0,(a0)+\n\t"  /* cntrl_4, cntrl_5 */
00052         "move.w  %2,(a0)\n\t"   /* handle */
00053         "move.w  #115,d0\n\t"   /* 0x0073 */
00054         "trap    #2"
00055         :
00056         : "a"(vdipb), "g"(cntrl_0_1), "g"(handle)
00057         : "a0", "d0","d1","memory"
00058     );
00059 }
00060 #define VDI_TRAP_00(vdipb, handle, opcode) \
00061     _vdi_trap_00 (&vdipb, (opcode##uL<<16), handle)
00062 
00063 
00064 #else /* no usage of gnu inlines, go the old way */
00065 
00066 #define VDI_TRAP_ESC(vdipb, handle, opcode, subop, cntrl_1, cntrl_3) \
00067     vdi_control[0] = opcode;  \
00068     vdi_control[1] = cntrl_1; \
00069     vdi_control[3] = cntrl_3; \
00070     vdi_control[5] = subop;   \
00071     vdi_control[6] = handle;  \
00072     vdi (&vdipb);
00073 
00074 #define VDI_TRAP_00(vdipb, handle, opcode) \
00075     VDI_TRAP_ESC (vdipb, handle, opcode, 0, 0, 0)
00076 #endif
00077 
00078 
00079 #define VDI_TRAP(vdipb, handle, opcode, cntrl_1, cntrl_3) \
00080     VDI_TRAP_ESC(vdipb, handle, opcode, 0, cntrl_1, cntrl_3)
00081 
00082 #define VDI_PARAMS(a,b,c,d,e) \
00083     VDIPB vdi_params;         \
00084     vdi_params.control = a;   \
00085     vdi_params.intin   = b;   \
00086     vdi_params.ptsin   = c;   \
00087     vdi_params.intout  = d;   \
00088     vdi_params.ptsout  = e;
00089 
00090 
00091 /* special feature for VDI bindings: pointer in parameters (for return values)
00092  * could be NULL (nice idea by Martin Elsasser against dummy variables) 
00093  */
00094 #define CHECK_NULLPTR 1
00095 
00096 /* special feature for VDI bindings: set VDIPB::intout and VDIPB::ptsout to
00097  * vdi_dummy array intead of NULL against crashes if some crazy VDI drivers
00098  * tries to write something in ptsout/intout.
00099  */ 
00100 #define USE_VDI_DUMMY 1
00101 
00102 #if USE_VDI_DUMMY
00103     /* use dummy array vdi_dummy[] from vdi_dummy.c */
00104     extern short vdi_dummy[];
00105 #else
00106     /* replace vdi_dummy in VDIPB by NULL pointer */
00107     #define vdi_dummy 0L
00108 #endif
00109 
00110 # endif /* _GEM_VDI_P_ */

Generated on Wed Nov 3 22:42:18 2004 for GEMLIB by  doxygen 1.3.9.1