]> Zhao Yanbai Git Server - minix.git/commitdiff
Added /dev/video for mapping video memory.
authorPhilip Homburg <philip@cs.vu.nl>
Wed, 9 Nov 2005 15:45:48 +0000 (15:45 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Wed, 9 Nov 2005 15:45:48 +0000 (15:45 +0000)
drivers/tty/console.c
drivers/tty/tty.c
drivers/tty/tty.h

index 15deeb98de0b4f742924f4f2edd6ebbd7d594db3..18ff7c36f42ec9dfa24cc049bb1fc0ee71c5de81 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "../drivers.h"
 #include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/vm.h>
 #include <minix/callnr.h>
 #include <minix/com.h>
 #include "tty.h"
@@ -766,6 +768,61 @@ PRIVATE void beep()
 }
 
 
+/*===========================================================================*
+ *                             do_video                                     *
+ *===========================================================================*/
+PUBLIC void do_video(message *m)
+{
+       int i, n, r, ops, watch;
+       unsigned char c;
+
+       /* Execute the requested device driver function. */
+       r= EINVAL;      /* just in case */
+       switch (m->m_type) {
+           case DEV_OPEN:
+               /* Should grant IOPL */
+               r= OK;
+               break;
+           case DEV_CLOSE:
+               r= OK;
+               break;
+           case DEV_IOCTL:
+               if (m->TTY_REQUEST == MIOCMAP || m->TTY_REQUEST == MIOCUNMAP)
+               {
+                       int r, do_map;
+                       struct mapreq mapreq;
+
+                       do_map= (m->REQUEST == MIOCMAP);        /* else unmap */
+
+                       /* Get request structure */
+                       r= sys_vircopy(m->PROC_NR, D,
+                               (vir_bytes)m->ADDRESS,
+                               SELF, D, (vir_bytes)&mapreq, sizeof(mapreq));
+                       if (r != OK)
+                       {
+                               tty_reply(TASK_REPLY, m->m_source, m->PROC_NR,
+                                       r);
+                               return;
+                       }
+                       r= sys_vm_map(m->PROC_NR, do_map,
+                               (phys_bytes)mapreq.base, mapreq.size,
+                               mapreq.offset);
+                       tty_reply(TASK_REPLY, m->m_source, m->PROC_NR, r);
+                       return;
+               }
+               r= ENOTTY;
+               break;
+
+           default:            
+               printf(
+               "Warning, TTY(video) got unexpected request %d from %d\n",
+                       m->m_type, m->m_source);
+               r= EINVAL;
+       }
+       tty_reply(TASK_REPLY, m->m_source, m->PROC_NR, r);
+}
+
+
 /*===========================================================================*
  *                             beep_x                                       *
  *===========================================================================*/
index bcf8e2ebeef3d00d5c2133d592c28f2777616259..4da224165fd1e56248f96b9b7f18b3b64cc0ba1b 100644 (file)
@@ -272,6 +272,9 @@ PUBLIC void main(void)
        } else if (line == KBDAUX_MINOR) {
                do_kbdaux(&tty_mess);
                continue;
+       } else if (line == VIDEO_MINOR) {
+               do_video(&tty_mess);
+               continue;
        } else if ((line - CONS_MINOR) < NR_CONS) {
                tp = tty_addr(line - CONS_MINOR);
        } else if (line == LOG_MINOR) {
index 433d4ed88ec62a391237b5d8804f1db546d01b55..6809029b4f53ae4e4cf54eb462f85721ed51d863 100644 (file)
@@ -9,10 +9,11 @@
 
 /* First minor numbers for the various classes of TTY devices. */
 #define CONS_MINOR        0
-#define KBD_MINOR        13
-#define KBDAUX_MINOR     14
 #define LOG_MINOR        15
 #define RS232_MINOR      16
+#define KBD_MINOR       127
+#define KBDAUX_MINOR    126
+#define VIDEO_MINOR     125
 #define TTYPX_MINOR     128
 #define PTYPX_MINOR     192
 
@@ -167,6 +168,7 @@ _PROTOTYPE( void toggle_scroll, (void)                                      );
 _PROTOTYPE( int con_loadfont, (message *m)                             );
 _PROTOTYPE( void select_console, (int cons_line)                       );
 _PROTOTYPE( void beep_x, ( unsigned freq, clock_t dur)                 );
+_PROTOTYPE( void do_video, (message *m)                                        );
 
 /* keyboard.c */
 _PROTOTYPE( void kb_init, (struct tty *tp)                             );