From: Brett Gordon Date: Thu, 22 Oct 2015 17:44:20 +0000 (-0400) Subject: coco3: connect gfxioc through to underlaying assembler code X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3945f1099e86c8b522ecabcf331cca1dedbda900;p=FUZIX.git coco3: connect gfxioc through to underlaying assembler code --- diff --git a/Kernel/platform-coco3/devtty.c b/Kernel/platform-coco3/devtty.c index c26b8bac..fda56ecb 100644 --- a/Kernel/platform-coco3/devtty.c +++ b/Kernel/platform-coco3/devtty.c @@ -128,11 +128,11 @@ static struct display fmodes[] = { 256, 192, /* screen size */ 256, 192, /* buffer size */ 0xFF, 0xFF, /* no pan, scroll */ - FMT_MONO_BW, /* for now just B&W */ + FMT_MONO_WB, /* for now just B&W */ HW_UNACCEL, /* no acceleration */ 0, /* no features */ 0, /* Memory size irrelevant */ - GFX_DRAW, /* only the basics */ + GFX_DRAW|GFX_READ|GFX_WRITE /* only the basics */ } }; @@ -461,29 +461,39 @@ int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) return tty_ioctl(minor, arg, ptr); if (arg >> 8 != 0x03) return vt_ioctl(minor, arg, ptr); - if (arg == GFXIOC_GETINFO) + switch( arg ){ + case GFXIOC_GETINFO: return uput( ptytab[minor-1].fdisp, ptr, sizeof( struct display)); - if (arg == GFXIOC_GETMODE){ - uint8_t m=ugetc(ptr); - if( m > 4 ) goto inval; - return uput( &fmodes[m], ptr, sizeof( struct display)); - } - if (arg == GFXIOC_SETMODE){ - uint8_t m=ugetc(ptr); - if( m > 4 ) goto inval; - memcpy( &(ptytab[minor-1].vmod), &(mode[m]), sizeof( struct mode_s ) ); - 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; + case GFXIOC_GETMODE: + { + uint8_t m=ugetc(ptr); + if( m > 4 ) goto inval; + return uput( &fmodes[m], ptr, sizeof( struct display)); + } + case GFXIOC_SETMODE: + { + uint8_t m=ugetc(ptr); + if( m > 4 ) goto inval; + memcpy( &(ptytab[minor-1].vmod), &(mode[m]), sizeof( struct mode_s ) ); + if( minor == curminor ) apply_gime( minor ); + return 0; } - return err; + case GFXIOC_DRAW: + case GFXIOC_WRITE: + case GFXIOC_READ: + { + int err; + err = gfx_draw_op(arg, ptr); + if (err) { + udata.u_error = err; + err = -1; + } + return err; + } + default: + break; } + udata.u_error = ENOTTY; return -1; diff --git a/Kernel/platform-coco3/video.c b/Kernel/platform-coco3/video.c index e2595844..447c6676 100644 --- a/Kernel/platform-coco3/video.c +++ b/Kernel/platform-coco3/video.c @@ -127,11 +127,12 @@ int gfx_draw_op(uarg_t arg, char *ptr) err = EINVAL; goto ret; } - if (arg != GFXIOC_READ) + if (arg != GFXIOC_READ){ c = l; - if (uget(ptr + 2, (char *)0x5e00, c)){ - err = EFAULT; - goto ret; + if (uget(ptr + 2, (char *)0x5e00, c)){ + err = EFAULT; + goto ret; + } } switch(arg) { case GFXIOC_DRAW: @@ -142,24 +143,25 @@ int gfx_draw_op(uarg_t arg, char *ptr) 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); - */ + if (l < 8){ + err= EINVAL; + break; + } + 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) { + err = -EFAULT; + break; + } + if (arg == GFXIOC_READ) { + video_read( (char *)0x5e00 ); + if (uput( (char *)0x5e00 + 8, ptr, l)){ + err = EFAULT; + break; + } + } + video_write( (char *)0x5e00 ); } ret: map_for_kernel();