From: Philip Homburg Date: Wed, 9 Nov 2005 15:45:48 +0000 (+0000) Subject: Added /dev/video for mapping video memory. X-Git-Tag: v3.1.2a~508 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/migration-4to9?a=commitdiff_plain;h=5556281540effc60615f56191bc584be1ff1a553;p=minix.git Added /dev/video for mapping video memory. --- diff --git a/drivers/tty/console.c b/drivers/tty/console.c index 15deeb98d..18ff7c36f 100644 --- a/drivers/tty/console.c +++ b/drivers/tty/console.c @@ -18,6 +18,8 @@ #include "../drivers.h" #include +#include +#include #include #include #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 * *===========================================================================*/ diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index bcf8e2ebe..4da224165 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -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) { diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index 433d4ed88..6809029b4 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -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) );