coco3: connect graphic IOCTL to rendering routine.
authorBrett Gordon <beretta42@gmail.com>
Mon, 12 Oct 2015 12:58:28 +0000 (08:58 -0400)
committerBrett Gordon <beretta42@gmail.com>
Tue, 13 Oct 2015 13:10:42 +0000 (09:10 -0400)
Kernel/platform-coco3/devtty.c
Kernel/platform-coco3/video.c

index 61cffb9..c26b8ba 100644 (file)
@@ -475,6 +475,15 @@ int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
                if( minor == curminor ) apply_gime( minor );
                return 0;
        }
+       if (arg == GFXIOC_DRAW ){
+               int err;
+               err = gfx_draw_op(arg, ptr);
+               if (err) {
+                       udata.u_error = err;
+                       err = -1;
+               }
+               return err;
+       }
        udata.u_error = ENOTTY;
        return -1;
 
index 1db4556..3c1f1f9 100644 (file)
@@ -1,7 +1,7 @@
 #include <kernel.h>
 #include <devtty.h>
 
-
+extern video_cmd( char *rlt_data);
 
 /* These are routines stolen from the stock vt.c's VT_SIMPLE code, and modified
    to suite multiple vts
@@ -113,3 +113,55 @@ void video_init( )
        memset( (char *)0x2000, ' ', 0x4000 );
        map_for_kernel();
 }
+
+int gfx_draw_op(uarg_t arg, char *ptr)
+{
+       int err=0;
+       int l;
+       int c = 8;      /* 4 x uint16_t */
+       uint16_t *p = (uint16_t *)(char *)0x5e00;
+
+       map_for_video();
+       l = ugetw(ptr);
+       if (l < 6 || l > 512){
+               err = EINVAL;
+               goto ret;
+       }
+       if (arg != GFXIOC_READ)
+               c = l;
+       if (uget((char *)0x5e00, ptr + 2, c)){
+               err = EFAULT;
+               goto ret;
+       }
+       switch(arg) {
+       case GFXIOC_DRAW:
+               /* TODO
+                  if (draw_validate(ptr, l, 256, 192))  - or 128!
+                  return EINVAL */
+               video_cmd( ( char *)0x5e00 );
+               break;
+       case GFXIOC_WRITE:
+       case GFXIOC_READ:
+               err = EFAULT;
+               goto ret;
+               /* Not implemented yet....
+                  if (l < 8)
+                  return EINVAL;
+                  l -= 8;
+                  if (p[0] > 31 || p[1] > 191 || p[2] > 31 || p[3] > 191 ||
+                  p[0] + p[2] > 32 || p[1] + p[3] > 192 ||
+                  (p[2] * p[3]) > l)
+                  return -EFAULT;
+                  if (arg == GFXIOC_READ) {
+                  video_read(buf);
+                  if (uput(buf + 8, ptr, l))
+                  return EFAULT;
+                  return 0;
+                  }
+                  video_write(buf);
+               */
+       }
+ ret:
+       map_for_kernel();
+       return err;
+}