#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
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
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;
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;
*/
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;
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
}
/*===========================================================================*
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
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);
*/
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;
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;
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 */
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++) {
tp->tty_minor = s - (NR_CONS+NR_RS_LINES) + TTYPX_MINOR;
}
}
+
}
/*===========================================================================*
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);