From: Brett Gordon Date: Mon, 12 Oct 2015 12:58:28 +0000 (-0400) Subject: coco3: connect graphic IOCTL to rendering routine. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4db94a53e8f749e225c090873ba4f740c97c159a;p=FUZIX.git coco3: connect graphic IOCTL to rendering routine. --- diff --git a/Kernel/platform-coco3/devtty.c b/Kernel/platform-coco3/devtty.c index 61cffb90..c26b8bac 100644 --- a/Kernel/platform-coco3/devtty.c +++ b/Kernel/platform-coco3/devtty.c @@ -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; diff --git a/Kernel/platform-coco3/video.c b/Kernel/platform-coco3/video.c index 1db45563..3c1f1f92 100644 --- a/Kernel/platform-coco3/video.c +++ b/Kernel/platform-coco3/video.c @@ -1,7 +1,7 @@ #include #include - +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; +}