From: Alan Cox Date: Sun, 25 Nov 2018 18:41:33 +0000 (+0000) Subject: zxdiv: Add graphic ioctls and fix swapmap_add misuse X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b5500fd3e766e6db046d724cc03bd7c4ba83aca9;p=FUZIX.git zxdiv: Add graphic ioctls and fix swapmap_add misuse --- diff --git a/Kernel/platform-zxdiv/devices.c b/Kernel/platform-zxdiv/devices.c index de6f9cae..90c608d1 100644 --- a/Kernel/platform-zxdiv/devices.c +++ b/Kernel/platform-zxdiv/devices.c @@ -7,6 +7,7 @@ #include #include #include +#include struct devsw dev_tab[] = /* The device driver switch table */ { @@ -15,7 +16,7 @@ struct devsw dev_tab[] = /* The device driver switch table */ /* 1: /dev/fd Floppy disc block devices: nope */ { no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, /* 2: /dev/tty TTY devices */ - { tty_open, tty_close, tty_read, tty_write, vt_ioctl }, + { tty_open, tty_close, tty_read, tty_write, gfx_ioctl }, /* 3: /dev/lpr Printer devices */ { no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, /* 4: /dev/mem etc System devices (one offs) */ diff --git a/Kernel/platform-zxdiv/devtty.c b/Kernel/platform-zxdiv/devtty.c index 14e57cc6..bce0705a 100644 --- a/Kernel/platform-zxdiv/devtty.c +++ b/Kernel/platform-zxdiv/devtty.c @@ -6,6 +6,7 @@ #include #include #include +#include char tbuf1[TTYSIZ]; @@ -202,3 +203,53 @@ static void keydecode(void) /* This is used by the vt asm code, but needs to live in the kernel */ uint16_t cursorpos; + +static struct display specdisplay = { + 0, + 256, 192, + 256, 192, + 0xFF, 0xFF, + FMT_SPECTRUM, + HW_UNACCEL, + GFX_VBLANK|GFX_MAPPABLE|GFX_TEXT, + 0 +}; + +static struct videomap specmap = { + 0, + 0, + 0x4000, + 6912, + 0, + 0, + 0, + MAP_FBMEM|MAP_FBMEM_SIMPLE +}; + +/* + * Graphics ioctls. Very minimal for this platform. It's a single fixed + * mode with direct memory mapping. + */ +int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) +{ + if (minor != 1 || arg >> 8 != 0x03) + return vt_ioctl(minor, arg, ptr); + switch(arg) { + case GFXIOC_GETINFO: + return uput(&specdisplay, ptr, sizeof(struct display)); + case GFXIOC_MAP: + return uput(&specmap, ptr, sizeof(struct videomap)); + case GFXIOC_UNMAP: + return 0; + case GFXIOC_WAITVB: + /* Our system clock is vblank */ + psleep(&timer_interrupt); + chksigs(); + if (udata.u_cursig) { + udata.u_error = EINTR; + return -1; + } + return 0; + } + return -1; +} diff --git a/Kernel/platform-zxdiv/devtty.h b/Kernel/platform-zxdiv/devtty.h index 039589fd..49ea085b 100644 --- a/Kernel/platform-zxdiv/devtty.h +++ b/Kernel/platform-zxdiv/devtty.h @@ -10,4 +10,6 @@ extern uint8_t keymap[8]; extern uint8_t keyboard[8][5]; extern uint8_t shiftkeyboard[8][5]; +extern int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr); + #endif diff --git a/Kernel/platform-zxdiv/discard.c b/Kernel/platform-zxdiv/discard.c index a3f30999..d9d930e6 100644 --- a/Kernel/platform-zxdiv/discard.c +++ b/Kernel/platform-zxdiv/discard.c @@ -43,6 +43,6 @@ void platform_swap_found(uint8_t letter, uint8_t m) n = MAX_SWAPS; #ifdef SWAPDEV while (n) - swapmap_add(n--); + swapmap_init(n--); #endif } diff --git a/Kernel/platform-zxdiv/main.c b/Kernel/platform-zxdiv/main.c index 20a2ccee..e2529e66 100644 --- a/Kernel/platform-zxdiv/main.c +++ b/Kernel/platform-zxdiv/main.c @@ -21,6 +21,7 @@ void platform_interrupt(void) { tty_pollirq(); timer_interrupt(); + wakeup(&timer_interrupt); } /*