Subversion Repositories Kolibri OS

Rev

Rev 868 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. //ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib
  3.  
  4. #include "common.h"
  5.  
  6. #include "ati2d.h"
  7. #include "accel_2d.h"
  8.  
  9. RHD_t rhd;
  10.  
  11. static clip_t  clip;
  12.  
  13. static local_pixmap_t scr_pixmap;
  14.  
  15.  
  16. /*
  17. void STDCALL (*SelectHwCursor)(cursor_t*)__asm__("SelectHwCursor");
  18. void STDCALL (*SetHwCursor)(cursor_t*,int x,int y)__asm__("SetHwCursor");
  19. void STDCALL (*HwCursorRestore)(int x, int y)__asm("HwCursorRestore");
  20. cursor_t* IMPORT (*HwCursorCreate)(void)__asm("HwCursorCreate"); //params eax, ebx, ecx
  21.  
  22. void (__stdcall *old_select)(cursor_t*);
  23. void (__stdcall *old_set)(cursor_t*,int x,int y);
  24. void (__stdcall *old_restore)(int x, int y);
  25. cursor_t* (*old_create)(void);
  26. cursor_t* __create_cursor(void);
  27. */
  28.  
  29. static void Init3DEngine(RHDPtr rhdPtr);
  30.  
  31. u32 __stdcall drvEntry(int action)
  32. {
  33.   RHDPtr rhdPtr;
  34.   u32 retval;
  35.  
  36.   int i;
  37.  
  38.   if(action != 1)
  39.     return 0;
  40.  
  41.   if(!dbg_open("/hd0/2/ati2d.log"))
  42.   {
  43.      printf("Can't open /rd/1/drivers/ati2d.log\nExit\n");
  44.      return 0;
  45.   }
  46.  
  47.   if((rhdPtr=FindPciDevice())==NULL)
  48.   {
  49.     dbgprintf("Device not found\n");
  50.     return 0;
  51.   };
  52.  
  53.   for(i=0;i<6;i++)
  54.   {
  55.     if(rhd.memBase[i])
  56.       dbgprintf("Memory base_%d 0x%x size 0x%x\n",
  57.                 i,rhd.memBase[i],(1<<rhd.memsize[i]));
  58.   };
  59.   for(i=0;i<6;i++)
  60.   {
  61.     if(rhd.ioBase[i])
  62.       dbgprintf("Io base_%d 0x%x size 0x%x\n",
  63.                 i,rhd.ioBase[i],(1<<rhd.memsize[i]));
  64.   };
  65.   if(!RHDPreInit())
  66.     return 0;
  67.  
  68. //  old_select = SelectHwCursor;
  69. //  old_set = SetHwCursor;
  70. //  old_restore = HwCursorRestore ;
  71. //  old_create = HwCursorCreate;
  72.  
  73.   R5xx2DInit();
  74.   rhd.has_tcl = 1;
  75. //  Init3DEngine(&rhd);
  76.  
  77.   //init_r500();
  78.  
  79.  // SelectHwCursor  = r500_SelectCursor;
  80.  // SetHwCursor     = r500_SetCursor;
  81.  // HwCursorCreate  = __create_cursor;
  82.  // HwCursorRestore = r500_CursorRestore;
  83.  
  84.   retval = RegService("HDRAW", srv_2d);
  85.   dbgprintf("reg service %s as: %x\n", "HDRAW", retval);
  86.  
  87. //  retval = RegService("HWCURSOR", srv_cursor);
  88.   return retval;
  89. };
  90.  
  91.  
  92. #define API_VERSION     0x01000100
  93.  
  94. #define SRV_GETVERSION  0
  95.  
  96. /*
  97. int _stdcall srv_cursor(ioctl_t *io)
  98. {
  99.   u32 *inp;
  100.   u32 *outp;
  101.  
  102.   inp = io->input;
  103.   outp = io->output;
  104.  
  105.   switch(io->io_code)
  106.   {
  107.     case SRV_GETVERSION:
  108.       if(io->out_size==4)
  109.       {
  110.         *(u32*)io->output = API_VERSION;
  111.         return 0;
  112.       }
  113.       break;
  114.  
  115.     default:
  116.       return ERR_PARAM;
  117.   };
  118.   return ERR_PARAM;
  119. }
  120. */
  121.  
  122. int _stdcall srv_2d(ioctl_t *io)
  123. {
  124.   u32 *inp;
  125.   u32 *outp;
  126.  
  127.   inp = io->input;
  128.   outp = io->output;
  129.  
  130.   switch(io->io_code)
  131.   {
  132.     case SRV_GETVERSION:
  133.       if(io->out_size==4)
  134.       {
  135.         *outp = API_VERSION;
  136.         return 0;
  137.       }
  138.       break;
  139.  
  140.       case DRAW_RECT:
  141.         if(io->inp_size==6)
  142.           return DrawRect((draw_t*)inp);
  143.         break;
  144.  
  145.       case FILL_RECT:
  146.         if(io->inp_size==9)
  147.           return FillRect((fill_t*)inp);
  148.         break;
  149. /*
  150.       case LINE_2P:
  151.         if(io->inp_size==6)
  152.           return Line2P((draw_t*)inp);
  153.         break;
  154.  
  155.       case BLIT:
  156.         if(io->inp_size==6)
  157.           return Blit((blit_t*)inp);
  158.         break;
  159.  
  160.       case COMPIZ:
  161.         if(io->inp_size==6)
  162.           return RadeonComposite((blit_t*)inp);
  163.         break;
  164. */
  165.       case PX_CREATE:
  166.         if(io->inp_size==7)
  167.           return CreatePixmap((pixmap_t*)inp);
  168.         break;
  169.  
  170.       case PIXBLIT:
  171.         if(io->inp_size==8)
  172.           return PixBlit((pixblit_t*)inp);
  173.         break;
  174.  
  175. //      case PIXLOCK:
  176. //        if(io->inp_size==6)
  177. //          return LockPixmap((userpixmap_t*)inp);
  178. //        break;
  179.  
  180. //      case PIXUNLOCK:
  181. //        if(io->inp_size==6)
  182. //          return UnlockPixmap((userpixmap_t*)inp);
  183. //        break;
  184.  
  185.       case PIXDESTROY:
  186.         if(io->inp_size==6)
  187.           return DestroyPixmap((pixmap_t*)inp);
  188.         break;
  189.  
  190.      case  TRANSBLIT:
  191.         if(io->inp_size==8)
  192.           return TransBlit((pixblit_t*)inp);
  193.         break;
  194.  
  195.  
  196.     default:
  197.       return ERR_PARAM;
  198.   };
  199.   return ERR_PARAM;
  200. }
  201.  
  202.  
  203. #include "init.c"
  204. #include "pci.c"
  205. #include "ati_mem.c"
  206. //#include "cursor.inc"
  207.  
  208. #include "r500.inc"
  209.  
  210. #include "clip.inc"
  211. #include "accel_2d.inc"
  212. #include "accel_3d.inc"
  213.  
  214.  
  215.