NetBSD/sys/arch/mac68k/dev/ite.c

1011 lines
19 KiB
C
Raw Normal View History

1995-04-21 06:47:35 +04:00
/* $NetBSD: ite.c,v 1.14 1995/04/21 02:47:57 briggs Exp $ */
1994-10-26 11:45:48 +03:00
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah $Hdr: ite.c 1.28 92/12/20$
*
1994-10-26 11:45:48 +03:00
* @(#)ite.c 8.2 (Berkeley) 1/12/94
*/
/*
* ite.c
*
* The ite module handles the system console; that is, stuff printed
* by the kernel and by user programs while "desktop" and X aren't
* running. Some (very small) parts are based on hp300's 4.4 ite.c,
* hence the above copyright.
*
* -- Brad and Lawrence, June 26th, 1994
*
*/
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <dev/cons.h>
#include "../mac68k/via.h"
#include <machine/cpu.h>
#include <machine/frame.h>
#define KEYBOARD_ARRAY
#include <machine/keyboard.h>
#include <machine/adbsys.h>
#include <machine/iteioctl.h>
#include "6x10.h"
#define CHARWIDTH 6
#define CHARHEIGHT 10
#define dprintf if (0) printf
#define ATTR_NONE 0
#define ATTR_BOLD 1
#define ATTR_UNDER 2
#define ATTR_REVERSE 4
enum vt100state_e {
1995-04-21 06:47:35 +04:00
ESnormal, /* Nothing yet */
ESesc, /* Got ESC */
ESsquare, /* Got ESC [ */
ESgetpars, /* About to get or getting the parameters */
ESgotpars, /* Finished getting the parameters */
ESfunckey, /* Function key */
EShash, /* DEC-specific stuff (screen align, etc.) */
ESsetG0, /* Specify the G0 character set */
ESsetG1, /* Specify the G1 character set */
ESignore /* Ignore this sequence */
} vt100state = ESnormal;
/* Received from MacBSDBoot, stored by Locore: */
1995-04-21 06:47:35 +04:00
long videoaddr;
long videorowbytes;
long videobitdepth;
unsigned long videosize;
/* Calculated in itecninit(): */
1995-04-21 06:47:35 +04:00
static int width, height, scrrows, scrcols;
static void (*putpixel) (int x, int y, int *c, int num);
static void (*reversepixel) (int x, int y, int num);
/* VT100 state: */
#define MAXPARS 16
1995-04-21 06:47:35 +04:00
static int x = 0, y = 0, savex, savey;
static int par[MAXPARS], numpars, hanging_cursor, attr;
/* Our tty: */
1995-04-21 06:47:35 +04:00
struct tty *ite_tty;
/* For polled ADB mode: */
static int polledkey;
extern int adb_polling;
/* Misc */
1995-04-21 06:47:35 +04:00
void itestart();
static void ite_putchar(char ch);
/*
* Bitmap handling functions
*/
1995-04-21 06:47:35 +04:00
static inline void
putpixel1(int xx, int yy, int *c, int num)
{
1995-04-21 06:47:35 +04:00
unsigned int i, mask;
unsigned char *sc;
1995-04-21 06:47:35 +04:00
sc = (unsigned char *) videoaddr;
i = 7 - (xx & 7);
mask = ~(1 << i);
sc += yy * videorowbytes + (xx >> 3);
while (num--) {
*sc &= mask;
*sc |= (*c++ & 1) << i;
sc += videorowbytes;
}
}
1995-04-21 06:47:35 +04:00
static void
putpixel2(int xx, int yy, int *c, int num)
{
1995-04-21 06:47:35 +04:00
unsigned int i, mask;
unsigned char *sc;
1995-04-21 06:47:35 +04:00
sc = (unsigned char *) videoaddr;
i = 6 - ((xx & 3) << 1);
mask = ~(3 << i);
sc += yy * videorowbytes + (xx >> 2);
while (num--) {
*sc &= mask;
*sc |= (*c++ & 3) << i;
sc += videorowbytes;
}
}
1995-04-21 06:47:35 +04:00
static void
putpixel4(int xx, int yy, int *c, int num)
{
1995-04-21 06:47:35 +04:00
unsigned int i, mask;
unsigned char *sc;
1995-04-21 06:47:35 +04:00
sc = (unsigned char *) videoaddr;
i = 4 - ((xx & 1) << 2);
mask = ~(15 << i);
sc += yy * videorowbytes + (xx >> 1);
while (num--) {
*sc &= mask;
*sc |= (*c++ & 15) << i;
sc += videorowbytes;
}
}
1995-04-21 06:47:35 +04:00
static void
putpixel8(int xx, int yy, int *c, int num)
{
1995-04-21 06:47:35 +04:00
unsigned char *sc;
1995-04-21 06:47:35 +04:00
sc = (unsigned char *) videoaddr;
sc += yy * videorowbytes + xx;
while (num--) {
1995-04-21 06:47:35 +04:00
*sc = *c++ & 0xff;
sc += videorowbytes;
}
}
1995-04-21 06:47:35 +04:00
static void
reversepixel1(int xx, int yy, int num)
{
1995-04-21 06:47:35 +04:00
unsigned int mask;
unsigned char *sc;
1995-04-21 06:47:35 +04:00
sc = (unsigned char *) videoaddr;
mask = 0; /* Get rid of warning from compiler */
switch (videobitdepth) {
1995-04-21 06:47:35 +04:00
case 1:
mask = 1 << (7 - (xx & 7));
sc += yy * videorowbytes + (xx >> 3);
break;
case 2:
mask = 3 << (6 - ((xx & 3) << 1));
sc += yy * videorowbytes + (xx >> 2);
break;
case 4:
mask = 15 << (4 - ((xx & 1) << 2));
sc += yy * videorowbytes + (xx >> 1);
break;
case 8:
mask = 255;
sc += yy * videorowbytes + xx;
break;
default:
panic("reversepixel(): unsupported bit depth");
}
while (num--) {
*sc ^= mask;
sc += videorowbytes;
}
}
1995-04-21 06:47:35 +04:00
static void
writechar(char ch, int x, int y, int attr)
{
1995-04-21 06:47:35 +04:00
int i, j, mask, rev, col[CHARHEIGHT];
unsigned char *c;
ch &= 0x7F;
x *= CHARWIDTH;
y *= CHARHEIGHT;
rev = (attr & ATTR_REVERSE) ? 255 : 0;
c = &Font6x10[ch * CHARHEIGHT];
switch (videobitdepth) {
case 1:
for (j = 0; j < CHARWIDTH; j++) {
1995-04-21 06:47:35 +04:00
mask = 1 << (CHARWIDTH - 1 - j);
for (i = 0; i < CHARHEIGHT; i++) {
col[i] = ((c[i] & mask) ? 255 : 0) ^ rev;
}
putpixel1(x + j, y, col, CHARHEIGHT);
}
1995-04-21 06:47:35 +04:00
if (attr & ATTR_UNDER) {
col[0] = 255;
for (j = 0; j < CHARWIDTH; j++) {
putpixel1(x + j, y + CHARHEIGHT - 1, col, 1);
}
}
break;
case 2:
case 4:
case 8:
for (j = 0; j < CHARWIDTH; j++) {
1995-04-21 06:47:35 +04:00
mask = 1 << (CHARWIDTH - 1 - j);
for (i = 0; i < CHARHEIGHT; i++) {
col[i] = ((c[i] & mask) ? 255 : 0) ^ rev;
}
putpixel(x + j, y, col, CHARHEIGHT);
}
1995-04-21 06:47:35 +04:00
if (attr & ATTR_UNDER) {
col[0] = 255;
for (j = 0; j < CHARWIDTH; j++) {
putpixel(x + j, y + CHARHEIGHT - 1, col, 1);
}
}
break;
}
}
1995-04-21 06:47:35 +04:00
static void
drawcursor(void)
{
1995-04-21 06:47:35 +04:00
int j, X, Y;
X = x * CHARWIDTH;
Y = y * CHARHEIGHT;
for (j = 0; j < CHARWIDTH; j++) {
1995-04-21 06:47:35 +04:00
reversepixel(X + j, Y, CHARHEIGHT);
}
}
1995-04-21 06:47:35 +04:00
static void
erasecursor(void)
{
1995-04-21 06:47:35 +04:00
int j, X, Y;
X = x * CHARWIDTH;
Y = y * CHARHEIGHT;
for (j = 0; j < CHARWIDTH; j++) {
1995-04-21 06:47:35 +04:00
reversepixel(X + j, Y, CHARHEIGHT);
}
}
1995-04-21 06:47:35 +04:00
static void
scrollup(void)
{
1995-04-21 06:47:35 +04:00
unsigned long *from, *to;
int i, linelongs, tocopy, copying;
linelongs = videorowbytes * CHARHEIGHT / 4;
1995-04-21 06:47:35 +04:00
to = (unsigned long *) videoaddr;
from = to + linelongs;
tocopy = (scrrows - 1) * linelongs;
while (tocopy > 0) {
copying = (tocopy > 16383) ? 16383 : tocopy;
1995-04-21 06:47:35 +04:00
bcopy(from, to, copying * 4);
from += copying;
to += copying;
tocopy -= copying;
}
1995-04-21 06:47:35 +04:00
to = (unsigned long *) videoaddr;
bzero(to + (scrrows - 1) * linelongs, linelongs * sizeof(long));
}
1995-04-21 06:47:35 +04:00
static void
scrolldown(void)
{
1995-04-21 06:47:35 +04:00
unsigned long *from, *to;
int i, linelongs;
linelongs = videorowbytes * CHARHEIGHT / 4;
1995-04-21 06:47:35 +04:00
to = (unsigned long *) videoaddr + linelongs * scrrows;
from = to - linelongs;
for (i = (scrrows - 1) * linelongs; i > 0; i--) {
*--to = *--from;
}
for (i = linelongs; i > 0; i--) {
*--to = 0;
}
}
1995-04-21 06:47:35 +04:00
static void
clear_screen(int which)
{
1995-04-21 06:47:35 +04:00
unsigned long *p;
int i, linelongs;
1995-04-21 06:47:35 +04:00
p = (unsigned long *) videoaddr;
linelongs = videorowbytes * CHARHEIGHT / 4;
switch (which) {
1995-04-21 06:47:35 +04:00
case 0: /* To end of screen */
p += y * linelongs;
i = (scrrows - y) * linelongs;
break;
case 1: /* To start of screen */
i = y * linelongs;
break;
case 2: /* Whole screen */
i = scrrows * linelongs;
break;
}
1995-04-21 06:47:35 +04:00
bzero(p, i * sizeof(long));
}
1995-04-21 06:47:35 +04:00
static void
clear_line(int which)
{
1995-04-21 06:47:35 +04:00
int start, end, i;
/*
* This routine runs extremely slowly. I don't think it's
* used all that often, except for To end of line. I'll go
* back and speed this up when I speed up the whole ite
* module. --LK
*/
switch (which) {
1995-04-21 06:47:35 +04:00
case 0: /* To end of line */
start = x;
end = scrcols;
break;
case 1: /* To start of line */
start = 0;
end = x;
break;
case 2: /* Whole line */
start = 0;
end = scrcols;
break;
}
for (i = start; i < end; i++) {
1995-04-21 06:47:35 +04:00
writechar(' ', i, y, ATTR_NONE);
}
}
1995-04-21 06:47:35 +04:00
static void
putc_normal(char ch)
{
switch (ch) {
1995-04-21 06:47:35 +04:00
case '\a': /* Beep */
asc_ringbell();
break;
case 127: /* Delete */
case '\b': /* Backspace */
if (hanging_cursor) {
hanging_cursor = 0;
} else
if (x > 0) {
x--;
}
break;
case '\t': /* Tab */
do {
ite_putchar(' ');
} while (x % 8 != 0);
break;
case '\n': /* Line feed */
y++;
if (y >= scrrows) {
scrollup();
y = scrrows - 1;
}
break;
case '\r': /* Carriage return */
x = 0;
hanging_cursor = 0;
break;
case '\e': /* Escape */
vt100state = ESesc;
hanging_cursor = 0;
break;
default:
if (ch >= ' ') {
if (hanging_cursor) {
1995-04-21 06:47:35 +04:00
x = 0;
y++;
if (y >= scrrows) {
scrollup();
y = scrrows - 1;
}
hanging_cursor = 0;
}
1995-04-21 06:47:35 +04:00
writechar(ch, x, y, attr);
if (x == scrcols - 1) {
hanging_cursor = 1;
} else {
x++;
}
1995-04-21 06:47:35 +04:00
if (x >= scrcols) {
x = 0;
y++;
}
1995-04-21 06:47:35 +04:00
}
break;
}
}
1995-04-21 06:47:35 +04:00
static void
putc_esc(char ch)
{
vt100state = ESnormal;
switch (ch) {
1995-04-21 06:47:35 +04:00
case '[':
vt100state = ESsquare;
break;
case 'D': /* Line feed */
y++;
break;
case 'H': /* Set tab stop */
/* Not supported */
break;
case 'M': /* Cursor up */
if (y == 0) {
scrolldown();
} else {
y--;
}
break;
case '7': /* Save cursor */
savex = x;
savey = y;
break;
case '8': /* Restore cursor */
x = savex;
y = savey;
break;
default:
/* Rest not supported */
break;
}
}
1995-04-21 06:47:35 +04:00
static void
putc_gotpars(char ch)
{
1995-04-21 06:47:35 +04:00
int i;
vt100state = ESnormal;
switch (ch) {
1995-04-21 06:47:35 +04:00
case 'A': /* Up */
y--;
break;
case 'B': /* Down */
y++;
break;
case 'C': /* Right */
x++;
break;
case 'D': /* Left */
x--;
break;
case 'H': /* Set cursor position */
x = par[1] - 1;
y = par[0] - 1;
hanging_cursor = 0;
break;
case 'J': /* Clear part of screen */
clear_screen(par[0]);
break;
case 'K': /* Clear part of line */
clear_line(par[0]);
break;
case 'g': /* Clear tab stops */
/* Not supported */
break;
case 'm': /* Set attribute */
for (i = 0; i < numpars; i++) {
switch (par[i]) {
case 0:
attr = ATTR_NONE;
break;
case 1:
attr |= ATTR_BOLD;
break;
case 4:
attr |= ATTR_UNDER;
break;
case 7:
attr |= ATTR_REVERSE;
break;
}
1995-04-21 06:47:35 +04:00
}
break;
case 'r': /* Set scroll region */
/* Not supported */
break;
}
}
1995-04-21 06:47:35 +04:00
static void
putc_getpars(char ch)
{
if (ch == '?') {
/* Not supported */
return;
}
if (ch == '[') {
vt100state = ESnormal;
/* Not supported */
return;
}
if (ch == ';' && numpars < MAXPARS - 1) {
numpars++;
1995-04-21 06:47:35 +04:00
} else
if (ch >= '0' && ch <= '9') {
par[numpars] *= 10;
par[numpars] += ch - '0';
} else {
numpars++;
vt100state = ESgotpars;
putc_gotpars(ch);
}
}
1995-04-21 06:47:35 +04:00
static void
putc_square(char ch)
{
1995-04-21 06:47:35 +04:00
int i;
for (i = 0; i < MAXPARS; i++) {
par[i] = 0;
}
numpars = 0;
vt100state = ESgetpars;
1995-04-21 06:47:35 +04:00
putc_getpars(ch);
}
1995-04-21 06:47:35 +04:00
static void
ite_putchar(char ch)
{
switch (vt100state) {
1995-04-21 06:47:35 +04:00
default:vt100state = ESnormal; /* FALLTHROUGH */
case ESnormal:
putc_normal(ch);
break;
case ESesc:
putc_esc(ch);
break;
case ESsquare:
putc_square(ch);
break;
case ESgetpars:
putc_getpars(ch);
break;
case ESgotpars:
putc_gotpars(ch);
break;
}
if (x >= scrcols) {
x = scrcols - 1;
}
if (x < 0) {
x = 0;
}
if (y >= scrrows) {
y = scrrows - 1;
}
if (y < 0) {
y = 0;
}
}
/*
* Keyboard support functions
*/
1995-04-21 06:47:35 +04:00
static int
ite_dopollkey(int key)
{
polledkey = key;
return 0;
}
1995-04-21 06:47:35 +04:00
static int
ite_pollforchar(void)
{
1995-04-21 06:47:35 +04:00
int s;
register int intbits;
s = splhigh();
polledkey = -1;
adb_polling = 1;
/* pretend we're VIA interrupt dispatcher */
while (polledkey == -1) {
intbits = via_reg(VIA1, vIFR);
if (intbits & V1IF_ADBRDY) {
mrg_adbintr();
via_reg(VIA1, vIFR) = V1IF_ADBRDY;
}
if (intbits & 0x10) {
mrg_pmintr();
via_reg(VIA1, vIFR) = 0x10;
}
}
adb_polling = 0;
splx(s);
return polledkey;
}
/*
* Tty handling functions
*/
1995-04-21 06:47:35 +04:00
static void
iteattach(struct device * parent, struct device * dev, void *aux)
{
1995-04-21 06:47:35 +04:00
printf(" (minimal console)\n");
}
extern int matchbyname();
1995-04-21 06:47:35 +04:00
struct cfdriver itecd = {
NULL, "ite", matchbyname, iteattach, DV_TTY, sizeof(struct device)
};
1995-04-21 06:47:35 +04:00
int
iteopen(dev_t dev, int mode, int devtype, struct proc * p)
{
register struct tty *tp;
register int error;
1995-04-21 06:47:35 +04:00
int first = 0;
1995-04-21 06:47:35 +04:00
dprintf("iteopen(): enter(0x%x)\n", (int) dev);
if (ite_tty == NULL)
tp = ite_tty = ttymalloc();
else
tp = ite_tty;
1995-04-21 06:47:35 +04:00
if ((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) == (TS_ISOPEN | TS_XCLUDE)
&& p->p_ucred->cr_uid != 0)
return (EBUSY);
tp->t_oproc = itestart;
tp->t_param = NULL;
tp->t_dev = dev;
if ((tp->t_state & TS_ISOPEN) == 0) {
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
1995-04-21 06:47:35 +04:00
tp->t_cflag = CS8 | CREAD;
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
1995-04-21 06:47:35 +04:00
tp->t_state = TS_ISOPEN | TS_CARR_ON;
ttsetwater(tp);
}
1995-04-21 06:47:35 +04:00
error = (*linesw[tp->t_line].l_open) (dev, tp);
tp->t_winsize.ws_row = scrrows;
tp->t_winsize.ws_col = scrcols;
1995-04-21 06:47:35 +04:00
dprintf("iteopen(): exit(%d)\n", error);
return (error);
}
1995-04-21 06:47:35 +04:00
int
iteclose(dev_t dev, int flag, int mode, struct proc * p)
{
1995-04-21 06:47:35 +04:00
dprintf("iteclose: enter (%d)\n", (int) dev);
(*linesw[ite_tty->t_line].l_close) (ite_tty, flag);
ttyclose(ite_tty);
#if 0
1995-04-21 06:47:35 +04:00
ttyfree(ite_tty);
ite_tty = (struct tty *) 0;
#endif
1995-04-21 06:47:35 +04:00
dprintf("iteclose: exit\n");
return 0;
}
1995-04-21 06:47:35 +04:00
int
iteread(dev_t dev, struct uio * uio, int flag)
{
1995-04-21 06:47:35 +04:00
dprintf("iteread: enter\n");
return (*linesw[ite_tty->t_line].l_read) (ite_tty, uio, flag);
dprintf("iteread: exit\n");
}
1995-04-21 06:47:35 +04:00
int
itewrite(dev_t dev, struct uio * uio, int flag)
{
1995-04-21 06:47:35 +04:00
dprintf("itewrite: enter\n");
return (*linesw[ite_tty->t_line].l_write) (ite_tty, uio, flag);
dprintf("itewrite: exit\n");
}
1995-04-20 19:27:43 +04:00
struct tty *
itetty(dev)
1995-04-21 06:47:35 +04:00
dev_t dev;
1995-04-20 19:27:43 +04:00
{
return (ite_tty);
}
1995-04-21 06:47:35 +04:00
int
iteioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc * p)
{
register struct tty *tp = ite_tty;
1995-04-21 06:47:35 +04:00
int error;
1995-04-21 06:47:35 +04:00
dprintf("iteioctl: enter(%d, 0x%x)\n", cmd, cmd);
error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, addr, flag, p);
if (error >= 0) {
1995-04-21 06:47:35 +04:00
dprintf("iteioctl: exit(%d)\n", error);
return (error);
}
error = ttioctl(tp, cmd, addr, flag, p);
if (error >= 0) {
1995-04-21 06:47:35 +04:00
dprintf("iteioctl: exit(%d)\n", error);
return (error);
}
switch (cmd) {
1995-04-21 06:47:35 +04:00
case ITEIOC_RINGBELL:{
asc_ringbell();
return (0);
}
1995-04-21 06:47:35 +04:00
case ITEIOC_SETBELL:{
struct bellparams *bp = (void *) addr;
asc_setbellparams(bp->freq, bp->len, bp->vol);
return (0);
}
1995-04-21 06:47:35 +04:00
case ITEIOC_GETBELL:{
struct bellparams *bp = (void *) addr;
asc_getbellparams(&bp->freq, &bp->len, &bp->vol);
return (0);
}
}
1995-04-21 06:47:35 +04:00
dprintf("iteioctl: exit(ENOTTY)\n");
return (ENOTTY);
}
1995-04-21 06:47:35 +04:00
void
itestart(register struct tty * tp)
{
register int cc, s;
1995-04-21 06:47:35 +04:00
int hiwat = 0, hadcursor = 0;
s = spltty();
1995-04-21 06:47:35 +04:00
if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) {
splx(s);
return;
}
tp->t_state |= TS_BUSY;
cc = tp->t_outq.c_cc;
splx(s);
1995-04-21 06:47:35 +04:00
erasecursor();
while (cc-- > 0) {
1995-04-21 06:47:35 +04:00
ite_putchar(getc(&tp->t_outq));
}
1995-04-21 06:47:35 +04:00
drawcursor();
s = spltty();
tp->t_state &= ~TS_BUSY;
splx(s);
}
1995-04-21 06:47:35 +04:00
void
itestop(struct tty * tp, int flag)
{
1995-04-21 06:47:35 +04:00
int s;
1995-04-21 06:47:35 +04:00
s = spltty();
if (tp->t_state & TS_BUSY) {
if ((tp->t_state & TS_TTSTOP) == 0) {
tp->t_state |= TS_FLUSH;
}
}
splx(s);
}
1995-04-21 06:47:35 +04:00
int
ite_intr(adb_event_t * event)
{
1995-04-21 06:47:35 +04:00
static int shift = 0, control = 0;
int key, press, val, state;
char str[10], *s;
key = event->u.k.key;
1995-04-21 06:47:35 +04:00
press = ADBK_PRESS(key);
val = ADBK_KEYVAL(key);
if (val == ADBK_SHIFT) {
shift = press;
1995-04-21 06:47:35 +04:00
} else
if (val == ADBK_CONTROL) {
control = press;
} else
if (press) {
switch (val) {
case ADBK_UP:
str[0] = '\e';
str[1] = 'O';
str[2] = 'A';
str[3] = '\0';
break;
case ADBK_DOWN:
str[0] = '\e';
str[1] = 'O';
str[2] = 'B';
str[3] = '\0';
break;
case ADBK_RIGHT:
str[0] = '\e';
str[1] = 'O';
str[2] = 'C';
str[3] = '\0';
break;
case ADBK_LEFT:
str[0] = '\e';
str[1] = 'O';
str[2] = 'D';
str[3] = '\0';
break;
default:
state = 0;
if (shift) {
state = 1;
}
if (control) {
state = 2;
}
str[0] = keyboard[val][state];
str[1] = '\0';
break;
}
1995-04-21 06:47:35 +04:00
if (adb_polling) {
polledkey = str[0];
} else {
for (s = str; *s; s++) {
(*linesw[ite_tty->t_line].l_rint) (*s, ite_tty);
}
}
}
}
/*
* Console functions
*/
1995-04-21 06:47:35 +04:00
int
itecnprobe(struct consdev * cp)
{
1995-04-21 06:47:35 +04:00
int maj, unit;
/* locate the major number */
for (maj = 0; maj < nchrdev; maj++) {
if (cdevsw[maj].d_open == iteopen) {
break;
}
}
if (maj == nchrdev) {
1995-04-21 06:47:35 +04:00
panic("itecnprobe(): did not find iteopen().");
}
1995-04-21 06:47:35 +04:00
unit = 0; /* hardcode first device as console. */
/* initialize required fields */
1995-04-21 06:47:35 +04:00
cp->cn_dev = makedev(maj, unit);
cp->cn_pri = CN_INTERNAL;
}
1995-04-21 06:47:35 +04:00
int
itecninit(struct consdev * cp)
{
width = videosize & 0xffff;
height = (videosize >> 16) & 0xffff;
scrrows = height / CHARHEIGHT;
scrcols = width / CHARWIDTH;
switch (videobitdepth) {
1995-04-21 06:47:35 +04:00
default:
case 1:
putpixel = putpixel2;
reversepixel = reversepixel1;
break;
case 2:
putpixel = putpixel2;
reversepixel = reversepixel1;
break;
case 4:
putpixel = putpixel4;
reversepixel = reversepixel1;
break;
case 8:
putpixel = putpixel8;
reversepixel = reversepixel1;
break;
}
iteon(cp->cn_dev, 0);
}
1995-04-21 06:47:35 +04:00
int
iteon(dev_t dev, int flags)
{
1995-04-21 06:47:35 +04:00
erasecursor();
clear_screen(2);
drawcursor();
}
1995-04-21 06:47:35 +04:00
int
iteoff(dev_t dev, int flags)
{
1995-04-21 06:47:35 +04:00
erasecursor();
clear_screen(2);
}
1995-04-21 06:47:35 +04:00
int
itecngetc(dev_t dev)
{
/* Oh, man... */
1995-04-21 06:47:35 +04:00
return ite_pollforchar();
}
1995-04-21 06:47:35 +04:00
int
itecnputc(dev_t dev, int c)
{
1995-04-21 06:47:35 +04:00
extern dev_t mac68k_serdev;
int s;
/* s = splhigh (); */
1995-04-21 06:47:35 +04:00
erasecursor();
ite_putchar(c);
drawcursor();
if (mac68k_machine.serial_boot_echo)
sercnputc(mac68k_serdev, c);
/* splx (s); */
}