zxdiv: Add graphic ioctls and fix swapmap_add misuse
authorAlan Cox <alan@linux.intel.com>
Sun, 25 Nov 2018 18:41:33 +0000 (18:41 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 25 Nov 2018 18:41:33 +0000 (18:41 +0000)
Kernel/platform-zxdiv/devices.c
Kernel/platform-zxdiv/devtty.c
Kernel/platform-zxdiv/devtty.h
Kernel/platform-zxdiv/discard.c
Kernel/platform-zxdiv/main.c

index de6f9ca..90c608d 100644 (file)
@@ -7,6 +7,7 @@
 #include <devide.h>
 #include <devsd.h>
 #include <blkdev.h>
+#include <devtty.h>
 
 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) */
index 14e57cc..bce0705 100644 (file)
@@ -6,6 +6,7 @@
 #include <keycode.h>
 #include <vt.h>
 #include <tty.h>
+#include <graphics.h>
 
 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;
+}
index 039589f..49ea085 100644 (file)
@@ -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
index a3f3099..d9d930e 100644 (file)
@@ -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
 }
index 20a2cce..e2529e6 100644 (file)
@@ -21,6 +21,7 @@ void platform_interrupt(void)
 {
  tty_pollirq();
  timer_interrupt();
+ wakeup(&timer_interrupt);
 }
 
 /*