drop <minix/termios.h>, use clean <sys/termios.h>
. also implement some netbsd-style tty ioctls . also implement SIGINFO . also import netbsd stty . rename keymap minix CMIN (for ctrl+minus on numeric keypad) to CNMIN; to keep unchanged control character default CMIN in new <sys/ttydefaults.h> . convert CS[5678] logic in rs232 driver to explicit setting of LC bits Change-Id: I9b7d2963fe9aec00fb6e7535ef565b3191fc1c1d
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* Console unsupport for ARM. Just stubs. */
|
||||
#include <minix/ipc.h>
|
||||
#include <termios.h>
|
||||
#include <sys/termios.h>
|
||||
#include "tty.h"
|
||||
|
||||
void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Keyboard unsupport for ARM. Just stubs. */
|
||||
#include <minix/ipc.h>
|
||||
#include <termios.h>
|
||||
#include <sys/termios.h>
|
||||
#include "tty.h"
|
||||
|
||||
void
|
||||
|
||||
@@ -144,7 +144,8 @@ static int rs_read(tty_t *tp, int try);
|
||||
static int rs_icancel(tty_t *tp, int try);
|
||||
static int rs_ocancel(tty_t *tp, int try);
|
||||
static void rs_ostart(rs232_t *rs);
|
||||
static int rs_break(tty_t *tp, int try);
|
||||
static int rs_break_on(tty_t *tp, int try);
|
||||
static int rs_break_off(tty_t *tp, int try);
|
||||
static int rs_close(tty_t *tp, int try);
|
||||
static int rs_open(tty_t *tp, int try);
|
||||
static void rs232_handler(rs232_t *rs);
|
||||
@@ -330,8 +331,11 @@ omap_get_divisor(rs232_t *rs, unsigned int baud)
|
||||
switch(baud) {
|
||||
case B460800: /* Fall through */
|
||||
case B921600: /* Fall through */
|
||||
#if 0
|
||||
case B1843200: /* Fall through */
|
||||
case B3686400: oversampling = 13; break;
|
||||
case B3686400:
|
||||
#endif
|
||||
oversampling = 13; break;
|
||||
default: oversampling = 16;
|
||||
}
|
||||
|
||||
@@ -569,7 +573,8 @@ rs_init(tty_t *tp)
|
||||
tp->tty_icancel = rs_icancel;
|
||||
tp->tty_ocancel = rs_ocancel;
|
||||
tp->tty_ioctl = rs_ioctl;
|
||||
tp->tty_break = rs_break;
|
||||
tp->tty_break_on = rs_break_on;
|
||||
tp->tty_break_off = rs_break_off;
|
||||
tp->tty_open = rs_open;
|
||||
tp->tty_close = rs_close;
|
||||
|
||||
@@ -669,17 +674,26 @@ rs_ostart(rs232_t *rs)
|
||||
}
|
||||
|
||||
static int
|
||||
rs_break(tty_t *tp, int UNUSED(dummy))
|
||||
rs_break_on(tty_t *tp, int UNUSED(dummy))
|
||||
{
|
||||
/* Generate a break condition by setting the BREAK bit for 0.4 sec. */
|
||||
/* Raise break condition */
|
||||
rs232_t *rs = tp->tty_priv;
|
||||
unsigned int lsr;
|
||||
|
||||
lsr = serial_in(rs, OMAP3_LSR);
|
||||
serial_out(rs, OMAP3_LSR, lsr | UART_LSR_BI);
|
||||
/* XXX */
|
||||
/* milli_delay(400); */ /* ouch */
|
||||
serial_out(rs, OMAP3_LSR, lsr);
|
||||
return 0; /* dummy */
|
||||
}
|
||||
|
||||
static int
|
||||
rs_break_off(tty_t *tp, int UNUSED(dummy))
|
||||
{
|
||||
/* Clear break condition */
|
||||
rs232_t *rs = tp->tty_priv;
|
||||
unsigned int lsr;
|
||||
|
||||
lsr = serial_in(rs, OMAP3_LSR);
|
||||
serial_out(rs, OMAP3_LSR, lsr & ~UART_LSR_BI);
|
||||
return 0; /* dummy */
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,16 @@
|
||||
|
||||
#include <minix/drivers.h>
|
||||
#include <termios.h>
|
||||
#include <assert.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/vm.h>
|
||||
#include <sys/video.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/termios.h>
|
||||
#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
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/select.h>
|
||||
#include <termios.h>
|
||||
#include <sys/termios.h>
|
||||
#include <signal.h>
|
||||
#include <machine/archtypes.h>
|
||||
#include <minix/callnr.h>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <minix/drivers.h>
|
||||
#include <termios.h>
|
||||
#include <sys/termios.h>
|
||||
#include <signal.h>
|
||||
#include "tty.h"
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#define IS_IDBITS 6
|
||||
|
||||
/* Line control bits. */
|
||||
#define LC_CS5 0x00 /* LSB0 and LSB1 encoding for CS5 */
|
||||
#define LC_CS6 0x01 /* LSB0 and LSB1 encoding for CS6 */
|
||||
#define LC_CS7 0x02 /* LSB0 and LSB1 encoding for CS7 */
|
||||
#define LC_CS8 0x03 /* LSB0 and LSB1 encoding for CS8 */
|
||||
#define LC_2STOP_BITS 0x04
|
||||
#define LC_PARITY 0x08
|
||||
#define LC_PAREVEN 0x10
|
||||
@@ -191,7 +195,8 @@ static int rs_read(tty_t *tp, int try);
|
||||
static int rs_icancel(tty_t *tp, int try);
|
||||
static int rs_ocancel(tty_t *tp, int try);
|
||||
static void rs_ostart(rs232_t *rs);
|
||||
static int rs_break(tty_t *tp, int try);
|
||||
static int rs_break_on(tty_t *tp, int try);
|
||||
static int rs_break_off(tty_t *tp, int try);
|
||||
static int rs_close(tty_t *tp, int try);
|
||||
static void out_int(rs232_t *rs);
|
||||
static void rs232_handler(rs232_t *rs);
|
||||
@@ -384,8 +389,19 @@ static void rs_config(rs232_t *rs)
|
||||
line_controls |= LC_PARITY;
|
||||
if (!(tp->tty_termios.c_cflag & PARODD)) line_controls |= LC_PAREVEN;
|
||||
}
|
||||
|
||||
if (divisor >= (UART_FREQ / 110)) line_controls |= LC_2STOP_BITS;
|
||||
line_controls |= (tp->tty_termios.c_cflag & CSIZE) >> 2;
|
||||
|
||||
/* which word size is configured? set the bits explicitly. */
|
||||
if((tp->tty_termios.c_cflag & CSIZE) == CS5)
|
||||
line_controls |= LC_CS5;
|
||||
else if((tp->tty_termios.c_cflag & CSIZE) == CS6)
|
||||
line_controls |= LC_CS6;
|
||||
else if((tp->tty_termios.c_cflag & CSIZE) == CS7)
|
||||
line_controls |= LC_CS7;
|
||||
else if((tp->tty_termios.c_cflag & CSIZE) == CS8)
|
||||
line_controls |= LC_CS8;
|
||||
else printf("rs232: warning: no known word size set\n");
|
||||
|
||||
/* Select the baud rate divisor registers and change the rate. */
|
||||
sys_outb(rs->line_ctl_port, LC_ADDRESS_DIVISOR);
|
||||
@@ -500,7 +516,8 @@ void rs_init(tty_t *tp)
|
||||
tp->tty_icancel = rs_icancel;
|
||||
tp->tty_ocancel = rs_ocancel;
|
||||
tp->tty_ioctl = rs_ioctl;
|
||||
tp->tty_break = rs_break;
|
||||
tp->tty_break_on = rs_break_on;
|
||||
tp->tty_break_off = rs_break_off;
|
||||
tp->tty_close = rs_close;
|
||||
|
||||
/* Tell external device we are ready. */
|
||||
@@ -610,11 +627,11 @@ static void rs_ostart(rs232_t *rs)
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* rs_break *
|
||||
* rs_break_on *
|
||||
*===========================================================================*/
|
||||
static int rs_break(tty_t *tp, int UNUSED(dummy))
|
||||
static int rs_break_on(tty_t *tp, int UNUSED(dummy))
|
||||
{
|
||||
/* Generate a break condition by setting the BREAK bit for 0.4 sec. */
|
||||
/* Raise break condition. */
|
||||
rs232_t *rs = tp->tty_priv;
|
||||
u32_t line_controls;
|
||||
int s;
|
||||
@@ -622,10 +639,22 @@ static int rs_break(tty_t *tp, int UNUSED(dummy))
|
||||
if ((s = sys_inb(rs->line_ctl_port, &line_controls)) != OK)
|
||||
printf("TTY: sys_inb() failed: %d", s);
|
||||
sys_outb(rs->line_ctl_port, line_controls | LC_BREAK);
|
||||
/* XXX */
|
||||
/* milli_delay(400); */ /* ouch */
|
||||
printf("RS232 break\n");
|
||||
sys_outb(rs->line_ctl_port, line_controls);
|
||||
return 0; /* dummy */
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* rs_break_off *
|
||||
*===========================================================================*/
|
||||
static int rs_break_off(tty_t *tp, int UNUSED(dummy))
|
||||
{
|
||||
/* Clear break condition. */
|
||||
rs232_t *rs = tp->tty_priv;
|
||||
u32_t line_controls;
|
||||
int s;
|
||||
|
||||
if ((s = sys_inb(rs->line_ctl_port, &line_controls)) != OK)
|
||||
printf("TTY: sys_inb() failed: %d", s);
|
||||
sys_outb(rs->line_ctl_port, line_controls & ~LC_BREAK);
|
||||
return 0; /* dummy */
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('/') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
||||
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', '/', A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
||||
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, C('S') },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', '/', A('/'), '/', C('@') },
|
||||
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CMIN },
|
||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
||||
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <minix/drivers.h>
|
||||
#include <termios.h>
|
||||
#include <assert.h>
|
||||
#include <sys/termios.h>
|
||||
#include <signal.h>
|
||||
#include "tty.h"
|
||||
|
||||
|
||||
+73
-54
@@ -26,8 +26,10 @@
|
||||
#include <minix/drivers.h>
|
||||
#include <minix/driver.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioc_tty.h>
|
||||
#include <sys/kbdio.h>
|
||||
#include <sys/ttycom.h>
|
||||
#include <sys/ttydefaults.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <minix/keymap.h>
|
||||
#include "tty.h"
|
||||
@@ -103,12 +105,29 @@ static struct chardriver tty_tab = {
|
||||
|
||||
/* Default attributes. */
|
||||
static struct termios termios_defaults = {
|
||||
TINPUT_DEF, TOUTPUT_DEF, TCTRL_DEF, TLOCAL_DEF,
|
||||
{
|
||||
TEOF_DEF, TEOL_DEF, TERASE_DEF, TINTR_DEF, TKILL_DEF, TMIN_DEF,
|
||||
TQUIT_DEF, TTIME_DEF, TSUSP_DEF, TSTART_DEF, TSTOP_DEF,
|
||||
TREPRINT_DEF, TLNEXT_DEF, TDISCARD_DEF,
|
||||
}, TSPEED_DEF, TSPEED_DEF,
|
||||
.c_iflag = TTYDEF_IFLAG,
|
||||
.c_oflag = TTYDEF_OFLAG,
|
||||
.c_cflag = TTYDEF_CFLAG,
|
||||
.c_lflag = TTYDEF_LFLAG,
|
||||
.c_ispeed = TTYDEF_SPEED,
|
||||
.c_ospeed = TTYDEF_SPEED,
|
||||
.c_cc = {
|
||||
[VEOF] = CEOF,
|
||||
[VEOL] = CEOL,
|
||||
[VERASE] = CERASE,
|
||||
[VINTR] = CINTR,
|
||||
[VKILL] = CKILL,
|
||||
[VMIN] = CMIN,
|
||||
[VQUIT] = CQUIT,
|
||||
[VTIME] = CTIME,
|
||||
[VSUSP] = CSUSP,
|
||||
[VSTART] = CSTART,
|
||||
[VSTOP] = CSTOP,
|
||||
[VREPRINT] = CREPRINT,
|
||||
[VLNEXT] = CLNEXT,
|
||||
[VDISCARD] = CDISCARD,
|
||||
[VSTATUS] = CSTATUS
|
||||
}
|
||||
};
|
||||
static struct winsize winsize_defaults; /* = all zeroes */
|
||||
|
||||
@@ -600,15 +619,15 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
|
||||
r = OK;
|
||||
switch (request) {
|
||||
case TCGETS:
|
||||
case TIOCGETA:
|
||||
/* Get the termios attributes. */
|
||||
r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &tp->tty_termios,
|
||||
sizeof(struct termios));
|
||||
break;
|
||||
|
||||
case TCSETSW:
|
||||
case TCSETSF:
|
||||
case TCDRAIN:
|
||||
case TIOCSETAW:
|
||||
case TIOCSETAF:
|
||||
case TIOCDRAIN:
|
||||
if (tp->tty_outleft > 0) {
|
||||
if (flags & CDEV_NONBLOCK)
|
||||
return EAGAIN;
|
||||
@@ -619,10 +638,10 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
tp->tty_iogrant = grant;
|
||||
return EDONTREPLY; /* suspend the caller */
|
||||
}
|
||||
if (request == TCDRAIN) break;
|
||||
if (request == TCSETSF) tty_icancel(tp);
|
||||
if (request == TIOCDRAIN) break;
|
||||
if (request == TIOCSETAF) tty_icancel(tp);
|
||||
/*FALL THROUGH*/
|
||||
case TCSETS:
|
||||
case TIOCSETA:
|
||||
/* Set the termios attributes. */
|
||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &tp->tty_termios,
|
||||
sizeof(struct termios));
|
||||
@@ -630,39 +649,25 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
setattr(tp);
|
||||
break;
|
||||
|
||||
case TCFLSH:
|
||||
case TIOCFLUSH:
|
||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &i, sizeof(i));
|
||||
if (r != OK) break;
|
||||
switch (i) {
|
||||
case TCIFLUSH: tty_icancel(tp); break;
|
||||
case TCOFLUSH: (*tp->tty_ocancel)(tp, 0); break;
|
||||
case TCIOFLUSH: tty_icancel(tp); (*tp->tty_ocancel)(tp, 0); break;
|
||||
default: r = EINVAL;
|
||||
}
|
||||
if(i & FREAD) { tty_icancel(tp); }
|
||||
if(i & FWRITE) { (*tp->tty_ocancel)(tp, 0); }
|
||||
break;
|
||||
|
||||
case TCFLOW:
|
||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &i, sizeof(i));
|
||||
if (r != OK) break;
|
||||
switch (i) {
|
||||
case TCOOFF:
|
||||
case TCOON:
|
||||
tp->tty_inhibited = (i == TCOOFF);
|
||||
tp->tty_events = 1;
|
||||
break;
|
||||
case TCIOFF:
|
||||
(*tp->tty_echo)(tp, tp->tty_termios.c_cc[VSTOP]);
|
||||
break;
|
||||
case TCION:
|
||||
(*tp->tty_echo)(tp, tp->tty_termios.c_cc[VSTART]);
|
||||
break;
|
||||
default:
|
||||
r = EINVAL;
|
||||
}
|
||||
case TIOCSTART:
|
||||
tp->tty_inhibited = 0;
|
||||
tp->tty_events = 1;
|
||||
break;
|
||||
|
||||
case TCSBRK:
|
||||
if (tp->tty_break != NULL) (*tp->tty_break)(tp,0);
|
||||
case TIOCSTOP:
|
||||
tp->tty_inhibited = 1;
|
||||
tp->tty_events = 1;
|
||||
break;
|
||||
case TIOCSBRK: /* tcsendbreak - turn break on */
|
||||
if (tp->tty_break_on != NULL) (*tp->tty_break_on)(tp,0);
|
||||
break;
|
||||
case TIOCCBRK: /* tcsendbreak - turn break off */
|
||||
if (tp->tty_break_off != NULL) (*tp->tty_break_off)(tp,0);
|
||||
break;
|
||||
|
||||
case TIOCGWINSZ:
|
||||
@@ -675,7 +680,6 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
sizeof(struct winsize));
|
||||
sigchar(tp, SIGWINCH, 0);
|
||||
break;
|
||||
|
||||
case KIOCBELL:
|
||||
/* Sound bell (only /dev/console). */
|
||||
if (!isconsole(tp))
|
||||
@@ -689,7 +693,17 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||
ticks++;
|
||||
beep_x(bell.kb_pitch, ticks);
|
||||
break;
|
||||
|
||||
case TIOCGETD: /* get line discipline */
|
||||
{
|
||||
int disc = TTYDISC;
|
||||
r = sys_safecopyto(endpt, grant, 0,
|
||||
(vir_bytes) &disc, (vir_bytes) sizeof(disc));
|
||||
break;
|
||||
}
|
||||
case TIOCSETD: /* set line discipline */
|
||||
printf("TTY: TIOCSETD: can't set any other line discipline.\n");
|
||||
r = ENOTTY;
|
||||
break;
|
||||
case KIOCSMAP:
|
||||
/* Load a new keymap (only /dev/console). */
|
||||
if (isconsole(tp)) r = kbd_loadmap(endpt, grant);
|
||||
@@ -1125,11 +1139,16 @@ int count; /* number of input characters */
|
||||
}
|
||||
|
||||
if (tp->tty_termios.c_lflag & ISIG) {
|
||||
/* Check for INTR (^?) and QUIT (^\) characters. */
|
||||
if (ch == tp->tty_termios.c_cc[VINTR]
|
||||
|| ch == tp->tty_termios.c_cc[VQUIT]) {
|
||||
/* Check for INTR, QUIT and STATUS characters. */
|
||||
int sig = -1;
|
||||
if (ch == tp->tty_termios.c_cc[VINTR])
|
||||
sig = SIGINT;
|
||||
if (ch == tp->tty_termios.c_cc[VQUIT]) sig = SIGQUIT;
|
||||
else if(ch == tp->tty_termios.c_cc[VQUIT])
|
||||
sig = SIGQUIT;
|
||||
else if(ch == tp->tty_termios.c_cc[VSTATUS])
|
||||
sig = SIGINFO;
|
||||
|
||||
if(sig >= 0) {
|
||||
sigchar(tp, sig, 1);
|
||||
(void) tty_echo(tp, ch);
|
||||
continue;
|
||||
@@ -1366,8 +1385,8 @@ int *ocount; /* max output chars / output chars used */
|
||||
/* Best guess for the tab length. */
|
||||
tablen = TAB_SIZE - (pos & TAB_MASK);
|
||||
|
||||
if ((tp->tty_termios.c_oflag & (OPOST|XTABS))
|
||||
== (OPOST|XTABS)) {
|
||||
if ((tp->tty_termios.c_oflag & (OPOST|OXTABS))
|
||||
== (OPOST|OXTABS)) {
|
||||
/* Tabs must be expanded. */
|
||||
if (oct >= tablen) {
|
||||
pos += tablen;
|
||||
@@ -1404,7 +1423,7 @@ out_done:
|
||||
static void dev_ioctl(tp)
|
||||
tty_t *tp;
|
||||
{
|
||||
/* The ioctl's TCSETSW, TCSETSF and TCDRAIN wait for output to finish to make
|
||||
/* The ioctl's TCSETSW, TCSETSF and TIOCDRAIN wait for output to finish to make
|
||||
* sure that an attribute change doesn't affect the processing of current
|
||||
* output. Once output finishes the ioctl is executed as in do_ioctl().
|
||||
*/
|
||||
@@ -1412,8 +1431,8 @@ tty_t *tp;
|
||||
|
||||
if (tp->tty_outleft > 0) return; /* output not finished */
|
||||
|
||||
if (tp->tty_ioreq != TCDRAIN) {
|
||||
if (tp->tty_ioreq == TCSETSF) tty_icancel(tp);
|
||||
if (tp->tty_ioreq != TIOCDRAIN) {
|
||||
if (tp->tty_ioreq == TIOCSETAF) tty_icancel(tp);
|
||||
result = sys_safecopyfrom(tp->tty_iocaller, tp->tty_iogrant, 0,
|
||||
(vir_bytes) &tp->tty_termios,
|
||||
(vir_bytes) sizeof(tp->tty_termios));
|
||||
|
||||
+2
-1
@@ -43,7 +43,8 @@ typedef struct tty {
|
||||
devfun_t tty_devwrite; /* routine to start actual device output */
|
||||
devfunarg_t tty_echo; /* routine to echo characters input */
|
||||
devfun_t tty_ocancel; /* cancel any ongoing device output */
|
||||
devfun_t tty_break; /* let the device send a break */
|
||||
devfun_t tty_break_on; /* let the device assert a break */
|
||||
devfun_t tty_break_off; /* let the device de-assert a break */
|
||||
|
||||
/* Terminal parameters and status. */
|
||||
int tty_position; /* current position on the screen for echoing */
|
||||
|
||||
Reference in New Issue
Block a user