]> Zhao Yanbai Git Server - minix.git/commitdiff
- hz dynamic
authorBen Gras <ben@minix3.org>
Mon, 8 Dec 2008 16:40:29 +0000 (16:40 +0000)
committerBen Gras <ben@minix3.org>
Mon, 8 Dec 2008 16:40:29 +0000 (16:40 +0000)
 - new map /dev/video implementation
 - ser_putc into library

drivers/tty/console.c
drivers/tty/keyboard.c
drivers/tty/tty.c
drivers/tty/tty.h

index f7abd263d5557297d68aaf097a922b22641b4276..999ce97528ce784b6b22fd912da0d38950670f68 100644 (file)
@@ -25,6 +25,7 @@
 #include <minix/callnr.h>
 #include <minix/com.h>
 #include <minix/sys_config.h>
+#include <minix/vm.h>
 #include "tty.h"
 
 /* Set this to 1 if you want console output duplicated on the first
@@ -142,10 +143,6 @@ FORWARD _PROTOTYPE( void reenable_console, (void)                  );
 FORWARD _PROTOTYPE( int ga_program, (struct sequence *seq)             );
 FORWARD _PROTOTYPE( int cons_ioctl, (tty_t *tp, int)                   );
 
-#if DUP_CONS_TO_SER
-FORWARD _PROTOTYPE( void ser_putc, (char c)                            );
-#endif
-
 #if 0
 FORWARD _PROTOTYPE( void get_6845, (int reg, unsigned *val)            );
 #endif
@@ -826,47 +823,6 @@ PUBLIC void do_video(message *m)
            case DEV_IOCTL_S:
                safe=1;
                switch(m->TTY_REQUEST) {
-                 case MIOCMAP:
-                 case MIOCUNMAP: {
-#if 0
-                       int r, do_map;
-                       struct mapreq mapreq;
-
-                       do_map= (m->REQUEST == MIOCMAP);        /* else unmap */
-
-                       /* Get request structure */
-                       if(safe) {
-                          r = sys_safecopyfrom(m->IO_ENDPT,
-                               (vir_bytes)m->ADDRESS, 0, (vir_bytes) &mapreq,
-                               sizeof(mapreq), D);
-                       } else {
-                         r= sys_vircopy(m->IO_ENDPT, D,
-                               (vir_bytes)m->ADDRESS,
-                               SELF, D, (vir_bytes)&mapreq, sizeof(mapreq));
-                       }
-                       if (r != OK)
-                       {
-                               tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT,
-                                       r);
-                               return;
-                       }
-
-                       /* In safe ioctl mode, the POSITION field contains
-                        * the endpt number of the original requestor.
-                        * IO_ENDPT is always FS.
-                        */
-
-                       r= sys_vm_map(safe ? m->POSITION : m->IO_ENDPT,
-                         do_map, (phys_bytes)mapreq.base, mapreq.size,
-                         mapreq.offset);
-#else
-                       r = ENOSYS;
-                       printf("tty: %ld used old MIOCMAP interface\n",
-                               safe ? m->POSITION : m->IO_ENDPT);
-#endif
-                       tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT, r);
-                       return;
-                  }
                  case TIOCMAPMEM:
                  case TIOCUNMAPMEM: {
                        int r, do_map;
@@ -876,17 +832,18 @@ PUBLIC void do_video(message *m)
                        do_map= (m->REQUEST == TIOCMAPMEM);     /* else unmap */
 
                        /* Get request structure */
-                       if(safe) {
-                          r = sys_safecopyfrom(m->IO_ENDPT,
-                               (vir_bytes)m->ADDRESS, 0, (vir_bytes) &mapreqvm,
-                               sizeof(mapreqvm), D);
-                       } else {
-                         r= sys_vircopy(m->IO_ENDPT, D,
-                               (vir_bytes)m->ADDRESS,
-                               SELF, D, (vir_bytes)&mapreqvm,sizeof(mapreqvm));
+                       if(!safe) {
+                               printf("tty: safecopy only\n");
+                               return;
                        }
+
+                       r = sys_safecopyfrom(m->IO_ENDPT,
+                         (vir_bytes)m->ADDRESS, 0, (vir_bytes) &mapreqvm,
+                         sizeof(mapreqvm), D);
+
                        if (r != OK)
                        {
+                               printf("tty: sys_safecopyfrom failed\n");
                                tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT,
                                        r);
                                return;
@@ -898,7 +855,17 @@ PUBLIC void do_video(message *m)
                         */
 
                        if(do_map) {
+                               mapreqvm.vaddr_ret = vm_map_phys(m->POSITION,
+                               (void *) mapreqvm.phys_offset, mapreqvm.size);
+                               if((r = sys_safecopyto(m->IO_ENDPT,
+                                 (vir_bytes)m->ADDRESS, 0,
+                                 (vir_bytes) &mapreqvm,
+                                 sizeof(mapreqvm), D)) != OK) {
+                                 printf("tty: sys_safecopyto failed\n");
+                               }
                        } else {
+                               r = vm_unmap_phys(m->POSITION, 
+                                       mapreqvm.vaddr, mapreqvm.size);
                        }
                        tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT, r);
                        return;
@@ -1267,10 +1234,12 @@ PUBLIC void toggle_scroll()
 PUBLIC void cons_stop()
 {
 /* Prepare for halt or reboot. */
+  select_console(0);
+#if 0
   cons_org0();
   softscroll = 1;
-  select_console(0);
   cons_table[0].c_attr = cons_table[0].c_blank = BLANK_COLOR;
+#endif
 }
 
 /*===========================================================================*
@@ -1417,26 +1386,3 @@ int try;
   return 0;
 }
 
-#if DUP_CONS_TO_SER
-#define COM1_BASE      0x3F8
-#define COM1_THR       (COM1_BASE + 0)
-#define                LSR_THRE        0x20
-#define COM1_LSR       (COM1_BASE + 5)
-
-PRIVATE void ser_putc(char c)
-{
-       unsigned long b;
-       int i;
-       int lsr, thr;
-
-       lsr= COM1_LSR;
-       thr= COM1_THR;
-       for (i= 0; i<10000; i++)
-       {
-               sys_inb(lsr, &b);
-               if (b & LSR_THRE)
-                       break;
-       }
-       sys_outb(thr, c);
-}
-#endif
index 5ff44c89bd5cf858beec819ae8317e145d64afb4..12a20d214acbec10cd3601c225635ff7cd417c90 100644 (file)
@@ -371,8 +371,8 @@ message *m;
                        if (r != OK)
                                break;
 
-                       ticks= bell.kb_duration.tv_usec * HZ / 1000000;
-                       ticks += bell.kb_duration.tv_sec * HZ;
+                       ticks= bell.kb_duration.tv_usec * system_hz / 1000000;
+                       ticks += bell.kb_duration.tv_sec * system_hz;
                        if (!ticks)
                                ticks++;
                        beep_x(bell.kb_pitch, ticks);
@@ -669,7 +669,7 @@ PRIVATE void kbd_send()
                 */
                if ((r= getuptime(&now)) != OK)
                        panic("TTY","Keyboard couldn't get clock's uptime.", r);
-               tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+HZ, kbd_watchdog,
+               tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+system_hz, kbd_watchdog,
                        NULL);
                if (tty_timers->tmr_exp_time != tty_next_timeout) {
                        tty_next_timeout = tty_timers->tmr_exp_time;
@@ -1269,7 +1269,7 @@ timer_t *tmrp;
 
        if ((r= getuptime(&now)) != OK)
                panic("TTY","Keyboard couldn't get clock's uptime.", r);
-       tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+HZ, kbd_watchdog,
+       tmrs_settimer(&tty_timers, &tmr_kbd_wd, now+system_hz, kbd_watchdog,
                NULL);
        if (tty_timers->tmr_exp_time != tty_next_timeout) {
                tty_next_timeout = tty_timers->tmr_exp_time;
index 15dac4ee15aa5450b7823a26f64adc52a603b60b..53d31a7bf208eaccf6e904e3ff0790859a446f2a 100644 (file)
@@ -138,6 +138,7 @@ PUBLIC int ccurrent;                        /* currently active console */
 PUBLIC timer_t *tty_timers;            /* queue of TTY timers */
 PUBLIC clock_t tty_next_timeout;       /* time that the next alarm is due */
 PUBLIC struct machine machine;         /* kernel environment variables */
+PUBLIC u32_t system_hz;
 
 extern PUBLIC unsigned info_location;
 extern PUBLIC phys_bytes vid_size;     /* 0x2000 for color or 0x0800 for mono */
@@ -1537,6 +1538,8 @@ PRIVATE void tty_init()
   register tty_t *tp;
   int s;
 
+  system_hz = sys_hz();
+
   /* Initialize the terminal lines. */
   for (tp = FIRST_TTY,s=0; tp < END_TTY; tp++,s++) {
 
@@ -1565,6 +1568,7 @@ PRIVATE void tty_init()
                tp->tty_minor = s - (NR_CONS+NR_RS_LINES) + TTYPX_MINOR;
        }
   }
+
 }
 
 /*===========================================================================*
@@ -1621,7 +1625,7 @@ int enable;                       /* set timer if true, otherwise unset */
   if ((s=getuptime(&now)) != OK)
        panic("TTY","Couldn't get uptime from clock.", s);
   if (enable) {
-       exp_time = now + tty_ptr->tty_termios.c_cc[VTIME] * (HZ/10);
+       exp_time = now + tty_ptr->tty_termios.c_cc[VTIME] * (system_hz/10);
        /* Set a new timer for enabling the TTY events flags. */
        tmrs_settimer(&tty_timers, &tty_ptr->tty_tmr, 
                exp_time, tty_timed_out, NULL);  
index 22c059d2c6719c9589e3090e52cef572087e63cc..d2add844811735b316bf767b11bfcf5d0297f17e 100644 (file)
@@ -107,6 +107,7 @@ typedef struct tty {
 extern tty_t tty_table[NR_CONS+NR_RS_LINES+NR_PTYS];
 extern int ccurrent;           /* currently visible console */
 extern int irq_hook_id;                /* hook id for keyboard irq */
+extern u32_t system_hz;                /* system clock frequency */
 
 extern unsigned long kbd_irq_set;
 extern unsigned long rs_irq_set;