Basic VM and other minor improvements.
Not complete, probably not fully debugged or optimized.
This commit is contained in:
@@ -14,10 +14,10 @@ d = ..
|
||||
# programs, flags, etc.
|
||||
MAKE = exec make
|
||||
CC = exec cc
|
||||
CPPFLAGS = -I$i -I../../kernel/arch/$(ARCH)/include
|
||||
CPPFLAGS = -I$i
|
||||
CFLAGS = $(CPPFLAGS)
|
||||
LDFLAGS = -i
|
||||
LIBS = -lsysutil -lsys -ltimers
|
||||
LIBS = -lsys -ltimers
|
||||
|
||||
OBJ = tty.o console.o vidcopy.o keyboard.o pty.o rs232.o
|
||||
|
||||
@@ -25,7 +25,7 @@ OBJ = tty.o console.o vidcopy.o keyboard.o pty.o rs232.o
|
||||
all build: $(DRIVER)
|
||||
$(DRIVER): $(OBJ)
|
||||
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
|
||||
install -S 8k $(DRIVER)
|
||||
install -S 16k $(DRIVER)
|
||||
|
||||
# install with other drivers
|
||||
install:
|
||||
|
||||
@@ -20,61 +20,27 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/vm.h>
|
||||
#include <sys/video.h>
|
||||
#include <minix/tty.h>
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/sys_config.h>
|
||||
#include "tty.h"
|
||||
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/type.h"
|
||||
|
||||
/* Set this to 1 if you want console output duplicated on the first
|
||||
* serial line.
|
||||
*/
|
||||
#define DUP_CONS_TO_SER 0
|
||||
|
||||
/* Definitions used by the console driver. */
|
||||
#define MONO_BASE 0xB0000L /* base of mono video memory */
|
||||
#define COLOR_BASE 0xB8000L /* base of color video memory */
|
||||
#define MONO_SIZE 0x1000 /* 4K mono video memory */
|
||||
#define COLOR_SIZE 0x4000 /* 16K color video memory */
|
||||
#define EGA_SIZE 0x8000 /* EGA & VGA have at least 32K */
|
||||
#define BLANK_COLOR 0x0700 /* determines cursor color on blank screen */
|
||||
#define SCROLL_UP 0 /* scroll forward */
|
||||
#define SCROLL_DOWN 1 /* scroll backward */
|
||||
#define BLANK_MEM ((u16_t *) 0) /* tells mem_vid_copy() to blank the screen */
|
||||
#define CONS_RAM_WORDS 80 /* video ram buffer size */
|
||||
#define MAX_ESC_PARMS 4 /* number of escape sequence params allowed */
|
||||
|
||||
/* Constants relating to the controller chips. */
|
||||
#define M_6845 0x3B4 /* port for 6845 mono */
|
||||
#define C_6845 0x3D4 /* port for 6845 color */
|
||||
#define INDEX 0 /* 6845's index register */
|
||||
#define DATA 1 /* 6845's data register */
|
||||
#define STATUS 6 /* 6845's status register */
|
||||
#define VID_ORG 12 /* 6845's origin register */
|
||||
#define CURSOR 14 /* 6845's cursor register */
|
||||
|
||||
/* The clock task should provide an interface for this */
|
||||
#define TIMER_FREQ 1193182L /* clock frequency for timer in PC and AT */
|
||||
|
||||
/* Beeper. */
|
||||
#define BEEP_FREQ 0x0533 /* value to put into timer to set beep freq */
|
||||
#define B_TIME 3 /* length of CTRL-G beep is ticks */
|
||||
|
||||
/* definitions used for font management */
|
||||
#define GA_SEQUENCER_INDEX 0x3C4
|
||||
#define GA_SEQUENCER_DATA 0x3C5
|
||||
#define GA_GRAPHICS_INDEX 0x3CE
|
||||
#define GA_GRAPHICS_DATA 0x3CF
|
||||
#define GA_VIDEO_ADDRESS 0xA0000L
|
||||
#define GA_FONT_SIZE 8192
|
||||
|
||||
/* Global variables used by the console driver and assembly support. */
|
||||
PUBLIC int vid_index; /* index of video segment in remote mem map */
|
||||
PUBLIC u16_t vid_seg;
|
||||
PUBLIC vir_bytes vid_off; /* video ram is found at vid_seg:vid_off */
|
||||
PUBLIC unsigned vid_size; /* 0x2000 for color or 0x0800 for mono */
|
||||
PUBLIC phys_bytes vid_size; /* 0x2000 for color or 0x0800 for mono */
|
||||
PUBLIC phys_bytes vid_base;
|
||||
PUBLIC unsigned vid_mask; /* 0x1FFF for color or 0x07FF for mono */
|
||||
PUBLIC unsigned blank_color = BLANK_COLOR; /* display code for blank */
|
||||
|
||||
@@ -87,6 +53,7 @@ PRIVATE unsigned font_lines; /* font lines per character */
|
||||
PRIVATE unsigned scr_width; /* # characters on a line */
|
||||
PRIVATE unsigned scr_lines; /* # lines on the screen */
|
||||
PRIVATE unsigned scr_size; /* # characters on the screen */
|
||||
PUBLIC unsigned info_location; /* location in video memory of struct */
|
||||
|
||||
PRIVATE int disabled_vc = -1; /* Virtual console that was active when
|
||||
* disable_console was called.
|
||||
@@ -95,6 +62,9 @@ PRIVATE int disabled_sm; /* Scroll mode to be restored when re-enabling
|
||||
* console
|
||||
*/
|
||||
|
||||
/* boot_tty_info we use to communicate with the boot code. */
|
||||
struct boot_tty_info boot_tty_info;
|
||||
|
||||
/* Per console data. */
|
||||
typedef struct console {
|
||||
tty_t *c_tty; /* associated TTY struct */
|
||||
@@ -113,11 +83,34 @@ typedef struct console {
|
||||
int *c_esc_parmp; /* pointer to current escape parameter */
|
||||
int c_esc_parmv[MAX_ESC_PARMS]; /* list of escape parameters */
|
||||
u16_t c_ramqueue[CONS_RAM_WORDS]; /* buffer for video RAM */
|
||||
int c_line; /* line no */
|
||||
} console_t;
|
||||
|
||||
#define UPDATEBOOTINFO(ccons, infofield, value) { \
|
||||
if(ccons->c_line == 0) { \
|
||||
boot_tty_info.infofield = value; \
|
||||
mem_vid_copy((u16_t *) &boot_tty_info, \
|
||||
info_location/2, sizeof(boot_tty_info)/2); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define UPDATE_CURSOR(ccons, cursor) { \
|
||||
ccons->c_cur = cursor; \
|
||||
UPDATEBOOTINFO(ccons, conscursor, ccons->c_cur); \
|
||||
if(curcons && ccons == curcons) \
|
||||
set_6845(CURSOR, ccons->c_cur); \
|
||||
}
|
||||
|
||||
#define UPDATE_ORIGIN(ccons, origin) { \
|
||||
ccons->c_org = origin; \
|
||||
UPDATEBOOTINFO(ccons, consorigin, ccons->c_org); \
|
||||
if (curcons && ccons == curcons) \
|
||||
set_6845(VID_ORG, ccons->c_org); \
|
||||
}
|
||||
|
||||
PRIVATE int nr_cons= 1; /* actual number of consoles */
|
||||
PRIVATE console_t cons_table[NR_CONS];
|
||||
PRIVATE console_t *curcons; /* currently visible */
|
||||
PRIVATE console_t *curcons = NULL; /* currently visible */
|
||||
|
||||
/* Color if using a color controller. */
|
||||
#define color (vid_port == C_6845)
|
||||
@@ -142,14 +135,20 @@ FORWARD _PROTOTYPE( void flush, (console_t *cons) );
|
||||
FORWARD _PROTOTYPE( void parse_escape, (console_t *cons, int c) );
|
||||
FORWARD _PROTOTYPE( void scroll_screen, (console_t *cons, int dir) );
|
||||
FORWARD _PROTOTYPE( void set_6845, (int reg, unsigned val) );
|
||||
FORWARD _PROTOTYPE( void get_6845, (int reg, unsigned *val) );
|
||||
FORWARD _PROTOTYPE( void stop_beep, (timer_t *tmrp) );
|
||||
FORWARD _PROTOTYPE( void cons_org0, (void) );
|
||||
FORWARD _PROTOTYPE( void disable_console, (void) );
|
||||
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
|
||||
|
||||
/*===========================================================================*
|
||||
* cons_write *
|
||||
@@ -174,7 +173,7 @@ int try;
|
||||
/* Check quickly for nothing to do, so this can be called often without
|
||||
* unmodular tests elsewhere.
|
||||
*/
|
||||
if ((count = tp->tty_outleft) == 0 || tp->tty_inhibited) return;
|
||||
if ((count = tp->tty_outleft) == 0 || tp->tty_inhibited) return 0;
|
||||
|
||||
/* Copy the user bytes to buf[] for decent addressing. Loop over the
|
||||
* copies, since the user buffer may be much larger than buf[].
|
||||
@@ -228,6 +227,8 @@ int try;
|
||||
tp->tty_outcum);
|
||||
tp->tty_outcum = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -365,9 +366,9 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
|
||||
} else
|
||||
if (!wrap && cons->c_org + scr_size + scr_width >= cons->c_limit) {
|
||||
vid_vid_copy(cons->c_org + scr_width, cons->c_start, chars);
|
||||
cons->c_org = cons->c_start;
|
||||
UPDATE_ORIGIN(cons, cons->c_start);
|
||||
} else {
|
||||
cons->c_org = (cons->c_org + scr_width) & vid_mask;
|
||||
UPDATE_ORIGIN(cons, (cons->c_org + scr_width) & vid_mask);
|
||||
}
|
||||
new_line = (cons->c_org + chars) & vid_mask;
|
||||
} else {
|
||||
@@ -378,9 +379,9 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
|
||||
if (!wrap && cons->c_org < cons->c_start + scr_width) {
|
||||
new_org = cons->c_limit - scr_size;
|
||||
vid_vid_copy(cons->c_org, new_org + scr_width, chars);
|
||||
cons->c_org = new_org;
|
||||
UPDATE_ORIGIN(cons, new_org);
|
||||
} else {
|
||||
cons->c_org = (cons->c_org - scr_width) & vid_mask;
|
||||
UPDATE_ORIGIN(cons, (cons->c_org - scr_width) & vid_mask);
|
||||
}
|
||||
new_line = cons->c_org;
|
||||
}
|
||||
@@ -388,8 +389,6 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
|
||||
blank_color = cons->c_blank;
|
||||
mem_vid_copy(BLANK_MEM, new_line, scr_width);
|
||||
|
||||
/* Set the new video origin. */
|
||||
if (cons == curcons) set_6845(VID_ORG, cons->c_org);
|
||||
flush(cons);
|
||||
}
|
||||
|
||||
@@ -421,10 +420,8 @@ register console_t *cons; /* pointer to console struct */
|
||||
if (cons->c_row < 0) cons->c_row = 0;
|
||||
if (cons->c_row >= scr_lines) cons->c_row = scr_lines - 1;
|
||||
cur = cons->c_org + cons->c_row * scr_width + cons->c_column;
|
||||
if (cur != cons->c_cur) {
|
||||
if (cons == curcons) set_6845(CURSOR, cur);
|
||||
cons->c_cur = cur;
|
||||
}
|
||||
if (cur != cons->c_cur)
|
||||
UPDATE_CURSOR(cons, cur);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -747,6 +744,7 @@ unsigned val; /* 16-bit value to set it to */
|
||||
sys_voutb(char_out, 4); /* do actual output */
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*===========================================================================*
|
||||
* get_6845 *
|
||||
*===========================================================================*/
|
||||
@@ -765,6 +763,7 @@ unsigned *val; /* 16-bit value to set it to */
|
||||
v2 = v;
|
||||
*val = (v1 << 8) | v2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*
|
||||
* beep *
|
||||
@@ -810,8 +809,7 @@ PRIVATE void beep()
|
||||
*===========================================================================*/
|
||||
PUBLIC void do_video(message *m)
|
||||
{
|
||||
int i, n, r, ops, watch, safe = 0;
|
||||
unsigned char c;
|
||||
int r, safe = 0;
|
||||
|
||||
/* Execute the requested device driver function. */
|
||||
r= EINVAL; /* just in case */
|
||||
@@ -827,8 +825,10 @@ PUBLIC void do_video(message *m)
|
||||
break;
|
||||
case DEV_IOCTL_S:
|
||||
safe=1;
|
||||
if (m->TTY_REQUEST == MIOCMAP || m->TTY_REQUEST == MIOCUNMAP)
|
||||
{
|
||||
switch(m->TTY_REQUEST) {
|
||||
case MIOCMAP:
|
||||
case MIOCUNMAP: {
|
||||
#if 0
|
||||
int r, do_map;
|
||||
struct mapreq mapreq;
|
||||
|
||||
@@ -859,8 +859,50 @@ PUBLIC void do_video(message *m)
|
||||
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;
|
||||
struct mapreqvm mapreqvm;
|
||||
void *result;
|
||||
|
||||
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 (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.
|
||||
*/
|
||||
|
||||
if(do_map) {
|
||||
} else {
|
||||
}
|
||||
tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT, r);
|
||||
return;
|
||||
}
|
||||
}
|
||||
r= ENOTTY;
|
||||
break;
|
||||
@@ -940,19 +982,19 @@ tty_t *tp;
|
||||
{
|
||||
/* Initialize the screen driver. */
|
||||
console_t *cons;
|
||||
phys_bytes vid_base;
|
||||
u16_t bios_columns, bios_crtbase, bios_fontlines;
|
||||
u8_t bios_rows;
|
||||
int line;
|
||||
int s;
|
||||
static int vdu_initialized = 0;
|
||||
unsigned page_size;
|
||||
static unsigned page_size;
|
||||
|
||||
/* Associate console and TTY. */
|
||||
line = tp - &tty_table[0];
|
||||
if (line >= nr_cons) return;
|
||||
cons = &cons_table[line];
|
||||
cons->c_tty = tp;
|
||||
cons->c_line = line;
|
||||
tp->tty_priv = cons;
|
||||
|
||||
/* Fill in TTY function hooks. */
|
||||
@@ -987,6 +1029,7 @@ tty_t *tp;
|
||||
}
|
||||
if (machine.vdu_ega) vid_size = EGA_SIZE;
|
||||
wrap = ! machine.vdu_ega;
|
||||
info_location = vid_size - sizeof(struct boot_tty_info);
|
||||
|
||||
s = sys_segctl(&vid_index, &vid_seg, &vid_off, vid_base, vid_size);
|
||||
|
||||
@@ -997,7 +1040,8 @@ tty_t *tp;
|
||||
scr_size = scr_lines * scr_width;
|
||||
|
||||
/* There can be as many consoles as video memory allows. */
|
||||
nr_cons = vid_size / scr_size;
|
||||
nr_cons = (vid_size - sizeof(struct boot_tty_info)/2) / scr_size;
|
||||
|
||||
if (nr_cons > NR_CONS) nr_cons = NR_CONS;
|
||||
if (nr_cons > 1) wrap = 0;
|
||||
page_size = vid_size / nr_cons;
|
||||
@@ -1013,13 +1057,18 @@ tty_t *tp;
|
||||
blank_color = BLANK_COLOR;
|
||||
mem_vid_copy(BLANK_MEM, cons->c_start, scr_size);
|
||||
} else {
|
||||
int i, n;
|
||||
/* Set the cursor of the console vty at the bottom. c_cur
|
||||
* is updated automatically later.
|
||||
*/
|
||||
scroll_screen(cons, SCROLL_UP);
|
||||
cons->c_row = scr_lines - 1;
|
||||
cons->c_column = 0;
|
||||
|
||||
memset(&boot_tty_info, 0, sizeof(boot_tty_info));
|
||||
UPDATE_CURSOR(cons, cons->c_cur);
|
||||
UPDATE_ORIGIN(cons, cons->c_org);
|
||||
boot_tty_info.flags = BTIF_CONSCURSOR | BTIF_CONSORIGIN;
|
||||
boot_tty_info.magic = TTYMAGIC;
|
||||
}
|
||||
select_console(0);
|
||||
cons_ioctl(tp, 0);
|
||||
@@ -1045,9 +1094,9 @@ int c;
|
||||
cons_putk(c);
|
||||
if (c != 0) {
|
||||
kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
|
||||
if (kmess.km_size < KMESS_BUF_SIZE)
|
||||
if (kmess.km_size < _KMESS_BUF_SIZE)
|
||||
kmess.km_size += 1;
|
||||
kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
|
||||
kmess.km_next = (kmess.km_next + 1) % _KMESS_BUF_SIZE;
|
||||
} else {
|
||||
notify(LOG_PROC_NR);
|
||||
}
|
||||
@@ -1060,9 +1109,8 @@ PUBLIC void do_new_kmess(m)
|
||||
message *m;
|
||||
{
|
||||
/* Notification for a new kernel message. */
|
||||
struct kmessages kmess; /* kmessages structure */
|
||||
static struct kmessages kmess; /* kmessages structure */
|
||||
static int prev_next = 0; /* previous next seen */
|
||||
int size, next;
|
||||
int bytes;
|
||||
int r;
|
||||
|
||||
@@ -1081,15 +1129,15 @@ message *m;
|
||||
|
||||
/* Print only the new part. Determine how many new bytes there are with
|
||||
* help of the current and previous 'next' index. Note that the kernel
|
||||
* buffer is circular. This works fine if less then KMESS_BUF_SIZE bytes
|
||||
* is new data; else we miss % KMESS_BUF_SIZE here.
|
||||
* buffer is circular. This works fine if less then _KMESS_BUF_SIZE bytes
|
||||
* is new data; else we miss % _KMESS_BUF_SIZE here.
|
||||
* Check for size being positive, the buffer might as well be emptied!
|
||||
*/
|
||||
if (kmess.km_size > 0) {
|
||||
bytes = ((kmess.km_next + KMESS_BUF_SIZE) - prev_next) % KMESS_BUF_SIZE;
|
||||
bytes = ((kmess.km_next + _KMESS_BUF_SIZE) - prev_next) % _KMESS_BUF_SIZE;
|
||||
r=prev_next; /* start at previous old */
|
||||
while (bytes > 0) {
|
||||
cons_putk( kmess.km_buf[(r%KMESS_BUF_SIZE)] );
|
||||
cons_putk( kmess.km_buf[(r%_KMESS_BUF_SIZE)] );
|
||||
bytes --;
|
||||
r ++;
|
||||
}
|
||||
@@ -1121,6 +1169,8 @@ int safe;
|
||||
int r;
|
||||
if(safe) {
|
||||
r = sys_safecopyfrom(proc_nr, src, offset, (vir_bytes) &c, 1, D);
|
||||
if(r != OK)
|
||||
printf("<tty: proc %d, grant %ld>", proc_nr, src);
|
||||
} else {
|
||||
r = sys_vircopy(proc_nr, D, src+offset, SELF, D, (vir_bytes) &c, 1);
|
||||
}
|
||||
@@ -1132,9 +1182,12 @@ int safe;
|
||||
cons_putk(c);
|
||||
}
|
||||
cons_putk(0); /* always terminate, even with EFAULT */
|
||||
m_ptr->m_type = DIAG_REPL;
|
||||
m_ptr->REP_STATUS = result;
|
||||
send(m_ptr->m_source, m_ptr);
|
||||
|
||||
if(m_ptr->m_type != ASYN_DIAGNOSTICS) {
|
||||
m_ptr->m_type = DIAG_REPL;
|
||||
m_ptr->REP_STATUS = result;
|
||||
send(m_ptr->m_source, m_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -1237,7 +1290,7 @@ PRIVATE void cons_org0()
|
||||
if (n > cons->c_org - cons->c_start)
|
||||
n = cons->c_org - cons->c_start;
|
||||
vid_vid_copy(cons->c_org, cons->c_org - n, scr_size);
|
||||
cons->c_org -= n;
|
||||
UPDATE_ORIGIN(cons, cons->c_org - n);
|
||||
}
|
||||
flush(cons);
|
||||
}
|
||||
@@ -1283,10 +1336,12 @@ PUBLIC void select_console(int cons_line)
|
||||
/* Set the current console to console number 'cons_line'. */
|
||||
|
||||
if (cons_line < 0 || cons_line >= nr_cons) return;
|
||||
|
||||
ccurrent = cons_line;
|
||||
curcons = &cons_table[cons_line];
|
||||
set_6845(VID_ORG, curcons->c_org);
|
||||
set_6845(CURSOR, curcons->c_cur);
|
||||
|
||||
UPDATE_CURSOR(curcons, curcons->c_cur);
|
||||
UPDATE_ORIGIN(curcons, curcons->c_org);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -1358,8 +1413,11 @@ int try;
|
||||
tp->tty_winsize.ws_col= scr_width;
|
||||
tp->tty_winsize.ws_xpixel= scr_width * 8;
|
||||
tp->tty_winsize.ws_ypixel= scr_lines * font_lines;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DUP_CONS_TO_SER
|
||||
#define COM1_BASE 0x3F8
|
||||
#define COM1_THR (COM1_BASE + 0)
|
||||
#define LSR_THRE 0x20
|
||||
@@ -1381,3 +1439,4 @@ PRIVATE void ser_putc(char c)
|
||||
}
|
||||
sys_outb(thr, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,16 +14,11 @@
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <archtypes.h>
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/keymap.h>
|
||||
#include "tty.h"
|
||||
#include "keymaps/us-std.src"
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/config.h"
|
||||
#include "../../kernel/type.h"
|
||||
#include "../../kernel/proc.h"
|
||||
|
||||
int irq_hook_id = -1;
|
||||
int aux_irq_hook_id = -1;
|
||||
@@ -132,10 +127,9 @@ PRIVATE struct kbd_outack
|
||||
|
||||
PRIVATE int kbd_watchdog_set= 0;
|
||||
PRIVATE int kbd_alive= 1;
|
||||
PRIVATE int sticky_alt_mode = 0;
|
||||
PRIVATE timer_t tmr_kbd_wd;
|
||||
|
||||
int sticky_alt_mode = 0;
|
||||
|
||||
FORWARD _PROTOTYPE( void handle_req, (struct kbd *kbdp, message *m) );
|
||||
FORWARD _PROTOTYPE( int handle_status, (struct kbd *kbdp, message *m) );
|
||||
FORWARD _PROTOTYPE( void kbc_cmd0, (int cmd) );
|
||||
@@ -153,6 +147,13 @@ FORWARD _PROTOTYPE( int kb_read, (struct tty *tp, int try) );
|
||||
FORWARD _PROTOTYPE( unsigned map_key, (int scode) );
|
||||
FORWARD _PROTOTYPE( void kbd_watchdog, (timer_t *tmrp) );
|
||||
|
||||
int micro_delay(u32_t usecs)
|
||||
{
|
||||
/* TTY can't use the library micro_delay() as that calls PM. */
|
||||
tickdelay(micros_to_ticks(usecs));
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_kbd *
|
||||
*===========================================================================*/
|
||||
@@ -500,7 +501,6 @@ message *m_ptr;
|
||||
int o, isaux;
|
||||
unsigned char scode;
|
||||
struct kbd *kbdp;
|
||||
static timer_t timer; /* timer must be static! */
|
||||
|
||||
/* Fetch the character from the keyboard hardware and acknowledge it. */
|
||||
if (!scan_keyboard(&scode, &isaux))
|
||||
@@ -637,7 +637,7 @@ PRIVATE void kbd_send()
|
||||
}
|
||||
if (sb & (KB_OUT_FULL|KB_IN_FULL))
|
||||
{
|
||||
printf("not sending 1: sb = 0x%x\n", sb);
|
||||
printf("not sending 1: sb = 0x%lx\n", sb);
|
||||
return;
|
||||
}
|
||||
micro_delay(KBC_IN_DELAY);
|
||||
@@ -646,7 +646,7 @@ PRIVATE void kbd_send()
|
||||
}
|
||||
if (sb & (KB_OUT_FULL|KB_IN_FULL))
|
||||
{
|
||||
printf("not sending 2: sb = 0x%x\n", sb);
|
||||
printf("not sending 2: sb = 0x%lx\n", sb);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -864,10 +864,10 @@ PRIVATE int kbc_read()
|
||||
while (micro_elapsed(&ms) < 1000000);
|
||||
#endif
|
||||
panic("TTY", "kbc_read failed to complete", NO_NUM);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* kb_wait *
|
||||
*===========================================================================*/
|
||||
@@ -876,7 +876,7 @@ PRIVATE int kb_wait()
|
||||
/* Wait until the controller is ready; return zero if this times out. */
|
||||
|
||||
int retries;
|
||||
unsigned long status, temp;
|
||||
unsigned long status;
|
||||
int s, isaux;
|
||||
unsigned char byte;
|
||||
|
||||
@@ -940,6 +940,12 @@ PUBLIC void kb_init_once(void)
|
||||
{
|
||||
int i;
|
||||
u8_t ccb;
|
||||
char env[100];
|
||||
|
||||
if(env_get_param("sticky_alt", env, sizeof(env)-1) == OK
|
||||
&& atoi(env) == 1) {
|
||||
sticky_alt_mode = 1;
|
||||
}
|
||||
|
||||
set_leds(); /* turn off numlock led */
|
||||
scan_keyboard(NULL, NULL); /* discard leftover keystroke */
|
||||
@@ -1020,7 +1026,7 @@ message *m_ptr; /* pointer to the request message */
|
||||
* notifications if it is pressed. At most one binding per key can exist.
|
||||
*/
|
||||
int i;
|
||||
int result;
|
||||
int result = EINVAL;
|
||||
|
||||
switch (m_ptr->FKEY_REQUEST) { /* see what we must do */
|
||||
case FKEY_MAP: /* request for new mapping */
|
||||
@@ -1104,8 +1110,6 @@ message *m_ptr; /* pointer to the request message */
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = EINVAL; /* key cannot be observed */
|
||||
}
|
||||
|
||||
/* Almost done, return result to caller. */
|
||||
@@ -1128,7 +1132,6 @@ int scode; /* scan code for a function key */
|
||||
message m;
|
||||
int key;
|
||||
int proc_nr;
|
||||
int i,s;
|
||||
|
||||
/* Ignore key releases. If this is a key press, get full key code. */
|
||||
if (scode & KEY_RELEASE) return(FALSE); /* key release */
|
||||
@@ -1166,31 +1169,17 @@ int scode; /* scan code for a function key */
|
||||
*===========================================================================*/
|
||||
PRIVATE void show_key_mappings()
|
||||
{
|
||||
int i,s;
|
||||
struct proc proc;
|
||||
|
||||
int i;
|
||||
printf("\n");
|
||||
printf("System information. Known function key mappings to request debug dumps:\n");
|
||||
printf("-------------------------------------------------------------------------\n");
|
||||
for (i=0; i<12; i++) {
|
||||
|
||||
printf(" %sF%d: ", i+1<10? " ":"", i+1);
|
||||
if (fkey_obs[i].proc_nr != NONE) {
|
||||
if ((s=sys_getproc(&proc, fkey_obs[i].proc_nr))!=OK)
|
||||
printf("sys_getproc: %d\n", s);
|
||||
printf("%-14.14s", proc.p_name);
|
||||
} else {
|
||||
printf("%-14.14s", "<none>");
|
||||
}
|
||||
printf("%-14.14s", "<none>");
|
||||
|
||||
printf(" %sShift-F%d: ", i+1<10? " ":"", i+1);
|
||||
if (sfkey_obs[i].proc_nr != NONE) {
|
||||
if ((s=sys_getproc(&proc, sfkey_obs[i].proc_nr))!=OK)
|
||||
printf("sys_getproc: %d\n", s);
|
||||
printf("%-14.14s", proc.p_name);
|
||||
} else {
|
||||
printf("%-14.14s", "<none>");
|
||||
}
|
||||
printf("%-14.14s", "<none>");
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
@@ -1260,12 +1249,6 @@ int *isauxp;
|
||||
#endif
|
||||
}
|
||||
|
||||
int micro_delay(u32_t usecs)
|
||||
{
|
||||
tickdelay(MICROS_TO_TICKS(usecs));
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* kbd_watchdog *
|
||||
*===========================================================================*/
|
||||
|
||||
@@ -4,8 +4,8 @@ LK = /usr/lib/keymaps
|
||||
|
||||
.SUFFIXES: .src .map
|
||||
|
||||
.src.map:
|
||||
$(CC) -DKEYSRC=\"$<\" $(CPROFILE) genmap.c -lsysutil -lsys
|
||||
.src.map:
|
||||
$(CC) -DKEYSRC=\"$<\" genmap.c
|
||||
./a.out > $@
|
||||
@rm -f a.out
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@ message *m_ptr;
|
||||
/* Perform an open/close/read/write call on a /dev/ptypX device. */
|
||||
pty_t *pp = tp->tty_priv;
|
||||
int r;
|
||||
phys_bytes p;
|
||||
int safe = 0;
|
||||
|
||||
switch (m_ptr->m_type) {
|
||||
@@ -108,15 +107,6 @@ message *m_ptr;
|
||||
r = EINVAL;
|
||||
break;
|
||||
}
|
||||
#if DEAD_CODE
|
||||
if (numap_local(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS,
|
||||
m_ptr->COUNT) == 0) {
|
||||
#else
|
||||
if ((r = sys_umap(m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS,
|
||||
m_ptr->COUNT, &p)) != OK) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
pp->rdsendreply = TRUE;
|
||||
pp->rdcaller = m_ptr->m_source;
|
||||
pp->rdproc = m_ptr->IO_ENDPT;
|
||||
@@ -130,12 +120,6 @@ message *m_ptr;
|
||||
return; /* already done */
|
||||
}
|
||||
|
||||
#if DEAD_CODE
|
||||
if (m_ptr->TTY_FLAGS & O_NONBLOCK) {
|
||||
r = EAGAIN; /* don't suspend */
|
||||
pp->rdleft = pp->rdcum = 0;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
r = SUSPEND; /* do suspend */
|
||||
pp->rdsendreply = FALSE;
|
||||
@@ -157,16 +141,6 @@ message *m_ptr;
|
||||
r = EINVAL;
|
||||
break;
|
||||
}
|
||||
#if DEAD_CODE
|
||||
if (numap_local(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS,
|
||||
m_ptr->COUNT) == 0) {
|
||||
r = EFAULT;
|
||||
#else
|
||||
if ((r = sys_umap(m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS,
|
||||
m_ptr->COUNT, &p)) != OK) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
pp->wrsendreply = TRUE;
|
||||
pp->wrcaller = m_ptr->m_source;
|
||||
pp->wrproc = m_ptr->IO_ENDPT;
|
||||
@@ -179,12 +153,6 @@ message *m_ptr;
|
||||
return; /* already done */
|
||||
}
|
||||
|
||||
#if DEAD_CODE
|
||||
if (m_ptr->TTY_FLAGS & O_NONBLOCK) { /* don't suspend */
|
||||
r = pp->wrcum > 0 ? pp->wrcum : EAGAIN;
|
||||
pp->wrleft = pp->wrcum = 0;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
pp->wrsendreply = FALSE; /* do suspend */
|
||||
r = SUSPEND;
|
||||
@@ -244,7 +212,7 @@ int try;
|
||||
*/
|
||||
pty_t *pp = tp->tty_priv;
|
||||
int count, ocount, s;
|
||||
phys_bytes user_phys;
|
||||
|
||||
|
||||
/* PTY closed down? */
|
||||
if (pp->state & PTY_CLOSED) {
|
||||
@@ -259,7 +227,7 @@ int try;
|
||||
tp->tty_outleft = tp->tty_outcum = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* While there is something to do. */
|
||||
@@ -473,6 +441,8 @@ int try;
|
||||
notify(pp->wrcaller);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -485,7 +455,7 @@ int try;
|
||||
/* The tty side has closed, so shut down the pty side. */
|
||||
pty_t *pp = tp->tty_priv;
|
||||
|
||||
if (!(pp->state & PTY_ACTIVE)) return;
|
||||
if (!(pp->state & PTY_ACTIVE)) return 0;
|
||||
|
||||
if (pp->rdleft > 0) {
|
||||
assert(!pp->rdsendreply);
|
||||
@@ -498,6 +468,8 @@ int try;
|
||||
}
|
||||
|
||||
if (pp->state & PTY_CLOSED) pp->state = 0; else pp->state |= TTY_CLOSED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -515,6 +487,8 @@ int try;
|
||||
pp->wrleft= 0;
|
||||
notify(pp->wrcaller);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -529,6 +503,8 @@ int try;
|
||||
|
||||
pp->ocount = 0;
|
||||
pp->otail = pp->ohead;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
||||
@@ -11,21 +11,6 @@
|
||||
|
||||
#if NR_RS_LINES > 0
|
||||
|
||||
#if (MACHINE != IBM_PC) && (MACHINE != ATARI)
|
||||
#error /* rs232.c only supports PC and Atari ST */
|
||||
#endif
|
||||
|
||||
#if (MACHINE == ATARI)
|
||||
#include "staddr.h"
|
||||
#include "stsound.h"
|
||||
#include "stmfp.h"
|
||||
#if (NR_RS_LINES > 1)
|
||||
#error /* Only one physical RS232 line available */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (MACHINE == IBM_PC) /* PC/AT 8250/16450 chip combination */
|
||||
|
||||
/* 8250 constants. */
|
||||
#define UART_FREQ 115200L /* timer frequency */
|
||||
|
||||
@@ -65,46 +50,25 @@
|
||||
#define MS_RLSD 0x80 /* Received Line Signal Detect */
|
||||
#define MS_DRLSD 0x08 /* RLSD Delta */
|
||||
|
||||
#else /* MACHINE == ATARI */ /* Atari ST 68901 USART */
|
||||
#define DATA_BITS_SHIFT 8 /* amount data bits shifted in mode */
|
||||
#define DEF_BAUD 1200 /* default baud rate */
|
||||
|
||||
/* Most of the USART constants are already defined in stmfp.h . The local
|
||||
* definitions made here are for keeping C code changes smaller. --kub
|
||||
*/
|
||||
|
||||
#define UART_FREQ 19200L /* timer frequency */
|
||||
|
||||
/* Line status bits. */
|
||||
#define LS_OVERRUN_ERR R_OE
|
||||
#define LS_PARITY_ERR R_PE
|
||||
#define LS_FRAMING_ERR R_FE
|
||||
#define LS_BREAK_INTERRUPT R_BREAK
|
||||
|
||||
/* Modem status bits. */
|
||||
#define MS_CTS IO_SCTS /* 0x04 */
|
||||
|
||||
#endif /* MACHINE == ATARI */
|
||||
|
||||
#define DATA_BITS_SHIFT 8 /* amount data bits shifted in mode */
|
||||
#define DEF_BAUD 1200 /* default baud rate */
|
||||
|
||||
#define RS_IBUFSIZE 1024 /* RS232 input buffer size */
|
||||
#define RS_OBUFSIZE 1024 /* RS232 output buffer size */
|
||||
#define RS_IBUFSIZE 1024 /* RS232 input buffer size */
|
||||
#define RS_OBUFSIZE 1024 /* RS232 output buffer size */
|
||||
|
||||
/* Input buffer watermarks.
|
||||
* The external device is asked to stop sending when the buffer
|
||||
* exactly reaches high water, or when TTY requests it. Sending restarts
|
||||
* when the input buffer empties below the low watermark.
|
||||
*/
|
||||
#define RS_ILOWWATER (1 * RS_IBUFSIZE / 4)
|
||||
#define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4)
|
||||
#define RS_ILOWWATER (1 * RS_IBUFSIZE / 4)
|
||||
#define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4)
|
||||
|
||||
/* Output buffer low watermark.
|
||||
* TTY is notified when the output buffer empties below the low watermark, so
|
||||
* it may continue filling the buffer if doing a large write.
|
||||
*/
|
||||
#define RS_OLOWWATER (1 * RS_OBUFSIZE / 4)
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
#define RS_OLOWWATER (1 * RS_OBUFSIZE / 4)
|
||||
|
||||
/* Macros to handle flow control.
|
||||
* Interrupts must be off when they are used.
|
||||
@@ -141,36 +105,6 @@
|
||||
#define devhup(rs) \
|
||||
((my_inb(rs->modem_status_port) & (MS_RLSD|MS_DRLSD)) == MS_DRLSD)
|
||||
|
||||
#else /* MACHINE == ATARI */
|
||||
|
||||
/* Macros to handle flow control.
|
||||
* Time is critical - already the function call for lock()/restore() is
|
||||
* annoying.
|
||||
* istart() tells external device we are ready by raising RTS.
|
||||
* istop() tells external device we are not ready by dropping RTS.
|
||||
* DTR is kept high all the time (it probably should be raised by open and
|
||||
* dropped by close of the device). NOTE: The modem lines are active low.
|
||||
*/
|
||||
#define set_porta(msk,val) { register int s = lock(); \
|
||||
SOUND->sd_selr = YM_IOA; \
|
||||
SOUND->sd_wdat = \
|
||||
SOUND->sd_rdat & (msk) | (val); \
|
||||
restore(s); }
|
||||
#define istart(rs) { set_porta( ~(PA_SRTS|PA_SDTR),0 ); \
|
||||
(rs)->idevready = TRUE; }
|
||||
#define istop(rs) { set_porta( ~PA_SDTR, PA_SRTS ); \
|
||||
(rs)->idevready = FALSE; }
|
||||
|
||||
/* Macro to tell if device is ready. The rs->cts field is set to MS_CTS if
|
||||
* CLOCAL is in effect for a line without a CTS wire.
|
||||
*/
|
||||
#define devready(rs) ((~MFP->mf_gpip | rs->cts) & MS_CTS)
|
||||
|
||||
/* Transmitter ready test */
|
||||
#define txready(rs) (MFP->mf_tsr & (T_EMPTY | T_UE))
|
||||
|
||||
#endif /* MACHINE == ATARI */
|
||||
|
||||
/* Types. */
|
||||
typedef unsigned char bool_t; /* boolean */
|
||||
|
||||
@@ -234,11 +168,6 @@ typedef struct rs232 {
|
||||
|
||||
PUBLIC rs232_t rs_lines[NR_RS_LINES];
|
||||
|
||||
/* Table and macro to translate an RS232 line number to its rs_lines entry. */
|
||||
PRIVATE rs232_t *p_rs_addr[NR_RS_LINES];
|
||||
|
||||
#define rs_addr(line) (p_rs_addr[line])
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
/* 8250 base addresses. */
|
||||
PRIVATE port_t addr_8250[] = {
|
||||
@@ -472,7 +401,6 @@ rs232_t *rs; /* which line */
|
||||
}
|
||||
if (divisor == 0) return; /* B0? */
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
/* Compute line control flag bits. */
|
||||
line_controls = 0;
|
||||
if (tp->tty_termios.c_cflag & PARENB) {
|
||||
@@ -502,27 +430,6 @@ rs232_t *rs; /* which line */
|
||||
rs->ostate &= ~ORAW;
|
||||
|
||||
unlock();
|
||||
|
||||
#else /* MACHINE == ATARI */
|
||||
|
||||
line_controls = U_Q16;
|
||||
if (tp->tty_termios.c_cflag & PARENB) {
|
||||
line_controls |= U_PAR;
|
||||
if (!(tp->tty_termios.c_cflag & PARODD)) line_controls |= U_EVEN;
|
||||
}
|
||||
line_controls |= (divisor >= (UART_FREQ / 110)) ? U_ST2 : U_ST1;
|
||||
|
||||
switch (tp->tty_termios.c_cflag & CSIZE) { /* XXX - are U_Dn like CSn? */
|
||||
case CS5: line_controls |= U_D5; break;
|
||||
case CS5: line_controls |= U_D6; break;
|
||||
case CS5: line_controls |= U_D7; break;
|
||||
case CS5: line_controls |= U_D8; break;
|
||||
}
|
||||
lock();
|
||||
MFP->mf_ucr = line_controls;
|
||||
MFP->mf_tddr = divisor;
|
||||
unlock();
|
||||
#endif /* MACHINE == ATARI */
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -536,11 +443,8 @@ tty_t *tp; /* which TTY */
|
||||
|
||||
register rs232_t *rs;
|
||||
int line;
|
||||
#if (MACHINE == IBM_PC)
|
||||
port_t this_8250;
|
||||
int irq;
|
||||
long v;
|
||||
#endif
|
||||
|
||||
/* Associate RS232 and TTY structures. */
|
||||
line = tp - &tty_table[NR_CONS];
|
||||
@@ -550,7 +454,6 @@ tty_t *tp; /* which TTY */
|
||||
/* Set up input queue. */
|
||||
rs->ihead = rs->itail = rs->ibuf;
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
/* Precalculate port numbers for speed. Magic numbers in the code (once). */
|
||||
this_8250 = addr_8250[line];
|
||||
rs->xmit_port = this_8250 + 0;
|
||||
@@ -563,7 +466,6 @@ tty_t *tp; /* which TTY */
|
||||
rs->modem_ctl_port = this_8250 + 4;
|
||||
rs->line_status_port = this_8250 + 5;
|
||||
rs->modem_status_port = this_8250 + 6;
|
||||
#endif
|
||||
|
||||
/* Set up the hardware to a base state, in particular
|
||||
* o turn off DTR (MC_DTR) to try to stop the external device.
|
||||
@@ -580,22 +482,17 @@ tty_t *tp; /* which TTY */
|
||||
*/
|
||||
istop(rs); /* sets modem_ctl_port */
|
||||
rs_config(rs);
|
||||
#if (MACHINE == IBM_PC)
|
||||
sys_outb(rs->int_enab_port, 0);
|
||||
#endif
|
||||
|
||||
/* Clear any harmful leftover interrupts. An output interrupt is harmless
|
||||
* and will occur when interrupts are enabled anyway. Set up the output
|
||||
* queue using the status from clearing the modem status interrupt.
|
||||
*/
|
||||
#if (MACHINE == IBM_PC)
|
||||
sys_inb(rs->line_status_port, &dummy);
|
||||
sys_inb(rs->recv_port, &dummy);
|
||||
#endif
|
||||
rs->ostate = devready(rs) | ORAW | OSWREADY; /* reads modem_ctl_port */
|
||||
rs->ohead = rs->otail = rs->obuf;
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
/* Enable interrupts for both interrupt controller and device. */
|
||||
irq = (line & 1) == 0 ? RS232_IRQ : SECONDARY_IRQ;
|
||||
|
||||
@@ -613,20 +510,6 @@ tty_t *tp; /* which TTY */
|
||||
|
||||
sys_outb(rs->int_enab_port, IE_LINE_STATUS_CHANGE | IE_MODEM_STATUS_CHANGE
|
||||
| IE_RECEIVER_READY | IE_TRANSMITTER_READY);
|
||||
#else /* MACHINE == ATARI */
|
||||
/* Initialize the 68901 chip, then enable interrupts. */
|
||||
MFP->mf_scr = 0x00;
|
||||
MFP->mf_tcdcr |= T_Q004;
|
||||
MFP->mf_rsr = R_ENA;
|
||||
MFP->mf_tsr = T_ENA;
|
||||
MFP->mf_aer = (MFP->mf_aer | (IO_SCTS|IO_SDCD)) ^
|
||||
(MFP->mf_gpip & (IO_SCTS|IO_SDCD));
|
||||
MFP->mf_ddr = (MFP->mf_ddr & ~ (IO_SCTS|IO_SDCD));
|
||||
MFP->mf_iera |= (IA_RRDY|IA_RERR|IA_TRDY|IA_TERR);
|
||||
MFP->mf_imra |= (IA_RRDY|IA_RERR|IA_TRDY|IA_TERR);
|
||||
MFP->mf_ierb |= (IB_SCTS|IB_SDCD);
|
||||
MFP->mf_imrb |= (IB_SCTS|IB_SDCD);
|
||||
#endif /* MACHINE == ATARI */
|
||||
|
||||
/* Fill in TTY function hooks. */
|
||||
tp->tty_devread = rs_read;
|
||||
@@ -721,7 +604,7 @@ int try;
|
||||
if (ostate & ODEVHUP) {
|
||||
sigchar(tp, SIGHUP);
|
||||
tp->tty_termios.c_ospeed = B0; /* Disable further I/O. */
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,6 +627,8 @@ int try;
|
||||
unlock();
|
||||
if ((rs->itail += count) == bufend(rs->ibuf)) rs->itail = rs->ibuf;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -787,7 +672,6 @@ int dummy;
|
||||
{
|
||||
/* The line is closed; optionally hang up. */
|
||||
rs232_t *rs = tp->tty_priv;
|
||||
int r;
|
||||
|
||||
if (tp->tty_termios.c_cflag & HUPCL) {
|
||||
sys_outb(rs->modem_ctl_port, MC_OUT2 | MC_RTS);
|
||||
@@ -797,7 +681,6 @@ int dummy;
|
||||
|
||||
/* Low level (interrupt) routines. */
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
/*===========================================================================*
|
||||
* rs232_handler *
|
||||
*===========================================================================*/
|
||||
@@ -831,50 +714,6 @@ struct rs232 *rs;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* MACHINE == IBM_PC */
|
||||
|
||||
#if (MACHINE == ATARI)
|
||||
/*===========================================================================*
|
||||
* siaint *
|
||||
*===========================================================================*/
|
||||
PRIVATE void siaint(type)
|
||||
int type; /* interrupt type */
|
||||
{
|
||||
/* siaint is the rs232 interrupt procedure for Atari ST's. For ST there are
|
||||
* as much as 5 interrupt lines used for rs232. The trap type byte left on the
|
||||
* stack by the assembler interrupt handler identifies the interrupt cause.
|
||||
*/
|
||||
|
||||
register unsigned char code;
|
||||
register rs232_t *rs = &rs_lines[0];
|
||||
int s = lock();
|
||||
|
||||
switch (type & 0x00FF)
|
||||
{
|
||||
case 0x00: /* receive buffer full */
|
||||
in_int(rs);
|
||||
break;
|
||||
case 0x01: /* receive error */
|
||||
line_int(rs);
|
||||
break;
|
||||
case 0x02: /* transmit buffer empty */
|
||||
out_int(rs);
|
||||
break;
|
||||
case 0x03: /* transmit error */
|
||||
code = MFP->mf_tsr;
|
||||
if (code & ~(T_ENA | T_UE | T_EMPTY))
|
||||
{
|
||||
printf("sia: transmit error: status=%x\r\n", code);
|
||||
/* MFP->mf_udr = lastchar; */ /* retry */
|
||||
}
|
||||
break;
|
||||
case 0x04: /* modem lines change */
|
||||
modem_int(rs);
|
||||
break;
|
||||
}
|
||||
restore(s);
|
||||
}
|
||||
#endif /* MACHINE == ATARI */
|
||||
|
||||
/*===========================================================================*
|
||||
* in_int *
|
||||
@@ -895,11 +734,7 @@ register rs232_t *rs; /* line with input interrupt */
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if (MACHINE == IBM_PC)
|
||||
sys_inb(rs->recv_port, &c);
|
||||
#else /* MACHINE == ATARI */
|
||||
c = MFP->mf_udr;
|
||||
#endif
|
||||
|
||||
if (!(rs->ostate & ORAW)) {
|
||||
if (c == rs->oxoff) {
|
||||
@@ -937,14 +772,8 @@ register rs232_t *rs; /* line with line status interrupt */
|
||||
/* Check for and record errors. */
|
||||
|
||||
unsigned long s;
|
||||
#if (MACHINE == IBM_PC)
|
||||
sys_inb(rs->line_status_port, &s);
|
||||
rs->lstatus = s;
|
||||
#else /* MACHINE == ATARI */
|
||||
rs->lstatus = MFP->mf_rsr;
|
||||
MFP->mf_rsr &= R_ENA;
|
||||
rs->pad = MFP->mf_udr; /* discard char in case of LS_OVERRUN_ERR */
|
||||
#endif /* MACHINE == ATARI */
|
||||
if (rs->lstatus & LS_FRAMING_ERR) ++rs->framing_errors;
|
||||
if (rs->lstatus & LS_OVERRUN_ERR) ++rs->overrun_errors;
|
||||
if (rs->lstatus & LS_PARITY_ERR) ++rs->parity_errors;
|
||||
@@ -961,12 +790,6 @@ register rs232_t *rs; /* line with modem interrupt */
|
||||
* If the device just became ready, restart output.
|
||||
*/
|
||||
|
||||
#if (MACHINE == ATARI)
|
||||
/* Set active edge interrupt so that next change causes a new interrupt */
|
||||
MFP->mf_aer = (MFP->mf_aer | (IO_SCTS|IO_SDCD)) ^
|
||||
(MFP->mf_gpip & (IO_SCTS|IO_SDCD));
|
||||
#endif
|
||||
|
||||
if (devhup(rs)) {
|
||||
rs->ostate |= ODEVHUP;
|
||||
rs->tty->tty_events = 1;
|
||||
@@ -994,11 +817,7 @@ register rs232_t *rs; /* line with output interrupt */
|
||||
|
||||
if (rs->ostate >= (ODEVREADY | OQUEUED | OSWREADY)) {
|
||||
/* Bit test allows ORAW and requires the others. */
|
||||
#if (MACHINE == IBM_PC)
|
||||
sys_outb(rs->xmit_port, *rs->otail);
|
||||
#else /* MACHINE == ATARI */
|
||||
MFP->mf_udr = *rs->otail;
|
||||
#endif
|
||||
if (++rs->otail == bufend(rs->obuf)) rs->otail = rs->obuf;
|
||||
if (--rs->ocount == 0) {
|
||||
rs->ostate ^= (ODONE | OQUEUED); /* ODONE on, OQUEUED off */
|
||||
|
||||
@@ -61,9 +61,9 @@
|
||||
#include <sys/ioc_tty.h>
|
||||
#include <signal.h>
|
||||
#include <minix/callnr.h>
|
||||
#if (CHIP == INTEL)
|
||||
#include <minix/sys_config.h>
|
||||
#include <minix/tty.h>
|
||||
#include <minix/keymap.h>
|
||||
#endif
|
||||
#include "tty.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
@@ -92,6 +92,7 @@ unsigned long rs_irq_set = 0;
|
||||
#if NR_RS_LINES == 0
|
||||
#define rs_init(tp) ((void) 0)
|
||||
#endif
|
||||
|
||||
#if NR_PTYS == 0
|
||||
#define pty_init(tp) ((void) 0)
|
||||
#define do_pty(tp, mp) ((void) 0)
|
||||
@@ -138,17 +139,21 @@ 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 */
|
||||
|
||||
extern PUBLIC unsigned info_location;
|
||||
extern PUBLIC phys_bytes vid_size; /* 0x2000 for color or 0x0800 for mono */
|
||||
extern PUBLIC phys_bytes vid_base;
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* tty_task *
|
||||
*===========================================================================*/
|
||||
PUBLIC void main(void)
|
||||
PUBLIC int main(void)
|
||||
{
|
||||
/* Main routine of the terminal task. */
|
||||
|
||||
message tty_mess; /* buffer for all incoming messages */
|
||||
unsigned line;
|
||||
int r, s;
|
||||
register struct proc *rp;
|
||||
register tty_t *tp;
|
||||
|
||||
/* Get kernel environment (protected_mode, pc_at and ega are needed). */
|
||||
@@ -162,9 +167,8 @@ PUBLIC void main(void)
|
||||
/* Final one-time keyboard initialization. */
|
||||
kb_init_once();
|
||||
|
||||
printf("\n");
|
||||
|
||||
while (TRUE) {
|
||||
int adflag = 0;
|
||||
|
||||
/* Check for and handle any events on any of the ttys. */
|
||||
for (tp = FIRST_TTY; tp < END_TTY; tp++) {
|
||||
@@ -212,14 +216,16 @@ PUBLIC void main(void)
|
||||
continue;
|
||||
}
|
||||
case DIAGNOSTICS: /* a server wants to print some */
|
||||
#if 0
|
||||
if (tty_mess.m_source != LOG_PROC_NR)
|
||||
{
|
||||
printf("WARNING: old DIAGNOSTICS from %d\n",
|
||||
tty_mess.m_source);
|
||||
printf("[%d ", tty_mess.m_source);
|
||||
}
|
||||
#endif
|
||||
do_diagnostics(&tty_mess, 0);
|
||||
continue;
|
||||
case DIAGNOSTICS_S:
|
||||
case ASYN_DIAGNOSTICS:
|
||||
do_diagnostics(&tty_mess, 1);
|
||||
continue;
|
||||
case GET_KMESS:
|
||||
@@ -299,6 +305,8 @@ PUBLIC void main(void)
|
||||
tty_mess.IO_ENDPT, EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -397,7 +405,7 @@ register message *m_ptr; /* pointer to message sent to the task */
|
||||
int safe; /* use safecopies? */
|
||||
{
|
||||
/* A process wants to read from a terminal. */
|
||||
int r, status;
|
||||
int r;
|
||||
|
||||
/* Check if there is already a process hanging in a read, check if the
|
||||
* parameters are correct, do I/O.
|
||||
@@ -775,9 +783,6 @@ message *m_ptr; /* pointer to message sent to task */
|
||||
if ((mode & W_BIT) && tp->tty_outleft != 0 && proc_nr == tp->tty_outproc &&
|
||||
(!tp->tty_out_safe || tp->tty_out_vir_g==(vir_bytes)m_ptr->IO_GRANT)) {
|
||||
/* Process was writing when killed. Clean up output. */
|
||||
#if DEAD_CODE
|
||||
(*tp->tty_ocancel)(tp, 0);
|
||||
#endif
|
||||
r = tp->tty_outcum > 0 ? tp->tty_outcum : EAGAIN;
|
||||
tp->tty_outleft = tp->tty_outcum = tp->tty_outrevived = 0;
|
||||
}
|
||||
@@ -849,9 +854,6 @@ tty_t *tp; /* TTY to check for events. */
|
||||
* messages (in proc.c). This is handled by explicitly checking each line
|
||||
* for fresh input and completed output on each interrupt.
|
||||
*/
|
||||
char *buf;
|
||||
unsigned count;
|
||||
int status;
|
||||
|
||||
do {
|
||||
tp->tty_events = 0;
|
||||
@@ -989,7 +991,6 @@ int count; /* number of input characters */
|
||||
|
||||
int ch, sig, ct;
|
||||
int timeset = FALSE;
|
||||
static unsigned char csize_mask[] = { 0x1F, 0x3F, 0x7F, 0xFF };
|
||||
|
||||
for (ct = 0; ct < count; ct++) {
|
||||
/* Take one character. */
|
||||
@@ -1373,7 +1374,7 @@ tty_t *tp;
|
||||
* sure that an attribute change doesn't affect the processing of current
|
||||
* output. Once output finishes the ioctl is executed as in do_ioctl().
|
||||
*/
|
||||
int result;
|
||||
int result = EINVAL;
|
||||
|
||||
if (tp->tty_outleft > 0) return; /* output not finished */
|
||||
|
||||
@@ -1535,8 +1536,6 @@ PRIVATE void tty_init()
|
||||
|
||||
register tty_t *tp;
|
||||
int s;
|
||||
struct sigaction sa;
|
||||
char env[100];
|
||||
|
||||
/* Initialize the terminal lines. */
|
||||
for (tp = FIRST_TTY,s=0; tp < END_TTY; tp++,s++) {
|
||||
@@ -1566,25 +1565,6 @@ PRIVATE void tty_init()
|
||||
tp->tty_minor = s - (NR_CONS+NR_RS_LINES) + TTYPX_MINOR;
|
||||
}
|
||||
}
|
||||
|
||||
if(env_get_param("sticky_alt", env, sizeof(env)-1) == OK
|
||||
&& atoi(env) == 1) {
|
||||
sticky_alt_mode = 1;
|
||||
}
|
||||
|
||||
|
||||
#if DEAD_CODE
|
||||
/* Install signal handlers. Ask PM to transform signal into message. */
|
||||
sa.sa_handler = SIG_MESS;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
if (sigaction(SIGTERM,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
|
||||
if (sigaction(SIGKMESS,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
|
||||
if (sigaction(SIGKSTOP,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
|
||||
#endif
|
||||
#if DEBUG
|
||||
printf("end of tty_init\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -1670,6 +1650,7 @@ tty_t *tp;
|
||||
int try;
|
||||
{
|
||||
/* Some functions need not be implemented at the device level. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* tty.h - Terminals */
|
||||
|
||||
#include <timers.h>
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/type.h"
|
||||
|
||||
#undef lock
|
||||
#undef unlock
|
||||
@@ -115,8 +113,6 @@ extern unsigned long rs_irq_set;
|
||||
|
||||
extern int panicing; /* From panic.c in sysutil */
|
||||
|
||||
extern int sticky_alt_mode; /* right-alt sticky to switch codepages */
|
||||
|
||||
/* Values for the fields. */
|
||||
#define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */
|
||||
#define ESCAPED 1 /* previous character was LNEXT (^V) */
|
||||
|
||||
Reference in New Issue
Block a user