1997-05-12 11:53:58 +04:00
|
|
|
/* $NetBSD: ite.c,v 1.36 1997/05/12 07:53:58 scottr Exp $ */
|
1994-10-26 11:45:48 +03:00
|
|
|
|
1994-07-08 11:55:46 +04: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
|
1994-07-08 11:55:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
1994-07-21 10:35:49 +04:00
|
|
|
* running. Some (very small) parts are based on hp300's 4.4 ite.c,
|
|
|
|
* hence the above copyright.
|
1994-07-08 11:55:46 +04:00
|
|
|
*
|
|
|
|
* -- Brad and Lawrence, June 26th, 1994
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1996-08-05 05:26:31 +04:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <dev/cons.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
#include <sys/conf.h>
|
1996-08-05 05:26:31 +04:00
|
|
|
#include <sys/device.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/malloc.h>
|
1996-08-05 05:26:31 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/tty.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-02-20 03:23:25 +03:00
|
|
|
#include <machine/bus.h>
|
1994-09-29 06:33:13 +03:00
|
|
|
#include <machine/cpu.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
#include <machine/frame.h>
|
1997-02-20 03:23:25 +03:00
|
|
|
#include <machine/viareg.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
#define KEYBOARD_ARRAY
|
1994-07-30 08:21:42 +04:00
|
|
|
#include <machine/keyboard.h>
|
|
|
|
#include <machine/adbsys.h>
|
1994-12-04 02:33:55 +03:00
|
|
|
#include <machine/iteioctl.h>
|
1996-08-05 05:26:31 +04:00
|
|
|
#include <machine/grfioctl.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-05-05 10:15:56 +04:00
|
|
|
#include "../mac68k/macrom.h"
|
|
|
|
|
1996-08-05 05:26:31 +04:00
|
|
|
#include "nubus.h"
|
1996-05-05 10:15:56 +04:00
|
|
|
#include "itevar.h"
|
1996-08-05 05:26:31 +04:00
|
|
|
#include "grfvar.h"
|
1996-05-05 10:15:56 +04:00
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
#include "6x10.h"
|
|
|
|
#define CHARWIDTH 6
|
|
|
|
#define CHARHEIGHT 10
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
/* Local function prototypes */
|
|
|
|
static inline void putpixel1 __P((int, int, int *, int));
|
|
|
|
static void putpixel2 __P((int, int, int *, int));
|
|
|
|
static void putpixel4 __P((int, int, int *, int));
|
|
|
|
static void putpixel8 __P((int, int, int *, int));
|
1997-04-08 08:47:08 +04:00
|
|
|
static void putpixel16 __P((int, int, int *, int));
|
|
|
|
static void putpixel32 __P((int, int, int *, int));
|
1996-05-07 19:52:19 +04:00
|
|
|
static void reversepixel1 __P((int, int, int));
|
|
|
|
static void writechar __P((char, int, int, int));
|
|
|
|
static void drawcursor __P((void));
|
|
|
|
static void erasecursor __P((void));
|
|
|
|
static void scrollup __P((void));
|
|
|
|
static void scrolldown __P((void));
|
|
|
|
static void clear_screen __P((int));
|
|
|
|
static void clear_line __P((int));
|
|
|
|
static void reset_tabs __P((void));
|
|
|
|
static void vt100_reset __P((void));
|
|
|
|
static void putc_normal __P((char));
|
|
|
|
static void putc_esc __P((char));
|
|
|
|
static void putc_gotpars __P((char));
|
|
|
|
static void putc_getpars __P((char));
|
|
|
|
static void putc_square __P((char));
|
|
|
|
static void ite_putchar __P((char));
|
|
|
|
static int ite_pollforchar __P((void));
|
1996-12-16 19:17:02 +03:00
|
|
|
static int itematch __P((struct device *, struct cfdata *, void *));
|
1996-05-07 19:52:19 +04:00
|
|
|
static void iteattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-10-13 07:21:13 +04:00
|
|
|
#define dprintf if (0) printf
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
#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 */
|
1994-07-21 10:35:49 +04:00
|
|
|
} vt100state = ESnormal;
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
/* From Booter via locore */
|
|
|
|
long videoaddr;
|
|
|
|
long videorowbytes;
|
|
|
|
long videobitdepth;
|
1997-05-12 11:53:58 +04:00
|
|
|
u_long videosize;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
/* Calculated by itecninit() */
|
1996-05-25 04:56:38 +04:00
|
|
|
static int ite_initted = 0;
|
1996-05-07 19:52:19 +04:00
|
|
|
static int width, height; /* width, height in pixels */
|
|
|
|
static int scrcols, scrrows; /* width, height in characters */
|
|
|
|
static int screenrowbytes; /* number of visible bytes per row */
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
/* VT100 emulation */
|
|
|
|
#define MAXPARS 16 /* max number of VT100 op parameters */
|
|
|
|
static int par[MAXPARS], numpars; /* parameter array, # of parameters */
|
|
|
|
static int x = 0, y = 0; /* current VT100 cursor location */
|
|
|
|
static int savex, savey; /* saved cursor location */
|
|
|
|
static int hanging_cursor; /* cursor waiting for more output */
|
|
|
|
static int attr; /* current video attribute */
|
|
|
|
static char tab_stops[255]; /* tab stops */
|
|
|
|
static int scrreg_top; /* scroll region */
|
|
|
|
static int scrreg_bottom;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-02-11 10:51:18 +03:00
|
|
|
/* Console bell parameters */
|
|
|
|
static int bell_freq = 1880; /* frequency */
|
|
|
|
static int bell_length = 10; /* duration */
|
|
|
|
static int bell_volume = 100; /* volume */
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
/* For polled ADB mode */
|
|
|
|
static int polledkey;
|
|
|
|
extern int adb_polling;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-11-19 10:17:47 +03:00
|
|
|
extern u_int32_t mac68k_vidphys;
|
1996-08-05 05:26:31 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
struct tty *ite_tty; /* Our tty */
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
static void (*putpixel) __P((int x, int y, int *c, int num));
|
|
|
|
static void (*reversepixel) __P((int x, int y, int num));
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-04-14 05:02:47 +04:00
|
|
|
/* For capslock key functionality */
|
|
|
|
#define isealpha(ch) (((ch)>='A'&&(ch)<='Z')||((ch)>='a'&&(ch)<='z')||((ch)>=0xC0&&(ch)<=0xFF))
|
1995-07-17 05:24:34 +04:00
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
/*
|
|
|
|
* Bitmap handling functions
|
|
|
|
*/
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static inline void
|
1996-05-07 19:52:19 +04:00
|
|
|
putpixel1(xx, yy, c, num)
|
|
|
|
int xx, yy;
|
|
|
|
int *c;
|
|
|
|
int num;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_int i, mask;
|
|
|
|
u_char *sc;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
sc = (u_char *)videoaddr;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
|
|
|
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
|
1996-05-07 19:52:19 +04:00
|
|
|
putpixel2(xx, yy, c, num)
|
|
|
|
int xx, yy;
|
|
|
|
int *c;
|
|
|
|
int num;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_int i, mask;
|
|
|
|
u_char *sc;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
sc = (u_char *)videoaddr;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
|
|
|
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
|
1996-05-07 19:52:19 +04:00
|
|
|
putpixel4(xx, yy, c, num)
|
|
|
|
int xx, yy;
|
|
|
|
int *c;
|
|
|
|
int num;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_int i, mask;
|
|
|
|
u_char *sc;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
sc = (u_char *)videoaddr;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
|
|
|
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
|
1996-05-07 19:52:19 +04:00
|
|
|
putpixel8(xx, yy, c, num)
|
|
|
|
int xx, yy;
|
|
|
|
int *c;
|
|
|
|
int num;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_char *sc;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
sc = (u_char *)videoaddr;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
|
|
|
sc += yy * videorowbytes + xx;
|
|
|
|
while (num--) {
|
1995-04-21 06:47:35 +04:00
|
|
|
*sc = *c++ & 0xff;
|
1994-07-21 10:35:49 +04:00
|
|
|
sc += videorowbytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-04-08 08:47:08 +04:00
|
|
|
static void
|
|
|
|
putpixel16(xx, yy, c, num)
|
|
|
|
int xx, yy;
|
|
|
|
int *c;
|
|
|
|
int num;
|
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_short *sc;
|
|
|
|
int videorowshorts;
|
|
|
|
u_char uc;
|
1997-04-08 08:47:08 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
sc = (u_short *)videoaddr;
|
1997-04-08 08:47:08 +04:00
|
|
|
|
|
|
|
videorowshorts = videorowbytes >> 1;
|
|
|
|
sc += yy * videorowshorts + xx;
|
|
|
|
while (num--) {
|
|
|
|
uc = (*c++ & 0xff);
|
|
|
|
*sc = (uc << 8) | uc;
|
|
|
|
sc += videorowshorts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
putpixel32(xx, yy, c, num)
|
|
|
|
int xx, yy;
|
|
|
|
int *c;
|
|
|
|
int num;
|
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_long *sc;
|
|
|
|
int videorowlongs;
|
|
|
|
u_char uc;
|
1997-04-08 08:47:08 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
sc = (u_long *)videoaddr;
|
1997-04-08 08:47:08 +04:00
|
|
|
|
|
|
|
videorowlongs = videorowbytes >> 2;
|
|
|
|
sc += yy * videorowlongs + xx;
|
|
|
|
while (num--) {
|
|
|
|
uc = (*c++ & 0xff);
|
|
|
|
*sc = (uc << 24) | (uc << 16) | (uc << 8) | uc;
|
|
|
|
sc += videorowlongs;
|
1997-05-12 11:53:58 +04:00
|
|
|
}
|
1997-04-08 08:47:08 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
reversepixel1(xx, yy, num)
|
|
|
|
int xx, yy, num;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_int mask;
|
|
|
|
u_char *sc;
|
|
|
|
u_long *sl;
|
|
|
|
u_short *ss;
|
|
|
|
int videorowshorts;
|
|
|
|
int videorowlongs;
|
|
|
|
|
|
|
|
sc = (u_char *)videoaddr;
|
1995-04-21 06:47:35 +04:00
|
|
|
mask = 0; /* Get rid of warning from compiler */
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
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;
|
1997-04-08 08:47:08 +04:00
|
|
|
case 16:
|
|
|
|
videorowshorts = videorowbytes >> 1;
|
1997-05-12 11:53:58 +04:00
|
|
|
ss = (u_short *)videoaddr;
|
1997-04-08 08:47:08 +04:00
|
|
|
ss += yy * videorowshorts + xx;
|
|
|
|
while (num--) {
|
|
|
|
*ss ^= 0xffff;
|
|
|
|
ss += videorowshorts;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 32:
|
|
|
|
videorowlongs = videorowbytes >> 2;
|
1997-05-12 11:53:58 +04:00
|
|
|
sl = (u_long *)videoaddr;
|
1997-04-08 08:47:08 +04:00
|
|
|
sl += yy * videorowlongs + xx;
|
|
|
|
while (num--) {
|
|
|
|
*sl ^= 0xffffffff;
|
|
|
|
sl += videorowlongs;
|
|
|
|
}
|
|
|
|
return;
|
1995-04-21 06:47:35 +04:00
|
|
|
default:
|
|
|
|
panic("reversepixel(): unsupported bit depth");
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1994-07-21 10:35:49 +04:00
|
|
|
|
|
|
|
while (num--) {
|
|
|
|
*sc ^= mask;
|
|
|
|
sc += videorowbytes;
|
|
|
|
}
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
writechar(ch, x, y, attr)
|
|
|
|
char ch;
|
|
|
|
int x, y, attr;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1996-05-07 19:52:19 +04:00
|
|
|
int i, j, mask, rev, col[CHARHEIGHT];
|
1997-05-12 11:53:58 +04:00
|
|
|
u_char *c;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
ch &= 0x7F;
|
|
|
|
x *= CHARWIDTH;
|
|
|
|
y *= CHARHEIGHT;
|
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
rev = (attr & ATTR_REVERSE) ? 255 : 0;
|
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
c = &Font6x10[ch * CHARHEIGHT];
|
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
switch (videobitdepth) {
|
|
|
|
case 1:
|
1994-07-08 11:55:46 +04:00
|
|
|
for (j = 0; j < CHARWIDTH; j++) {
|
1995-04-21 06:47:35 +04:00
|
|
|
mask = 1 << (CHARWIDTH - 1 - j);
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = 0; i < CHARHEIGHT; i++)
|
1995-04-21 06:47:35 +04:00
|
|
|
col[i] = ((c[i] & mask) ? 255 : 0) ^ rev;
|
|
|
|
putpixel1(x + j, y, col, CHARHEIGHT);
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
if (attr & ATTR_UNDER) {
|
|
|
|
col[0] = 255;
|
1996-05-07 19:52:19 +04:00
|
|
|
for (j = 0; j < CHARWIDTH; j++)
|
1995-04-21 06:47:35 +04:00
|
|
|
putpixel1(x + j, y + CHARHEIGHT - 1, col, 1);
|
|
|
|
}
|
|
|
|
break;
|
1994-07-21 10:35:49 +04:00
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
1997-04-08 08:47:08 +04:00
|
|
|
case 16:
|
|
|
|
case 32:
|
1994-07-21 10:35:49 +04:00
|
|
|
for (j = 0; j < CHARWIDTH; j++) {
|
1995-04-21 06:47:35 +04:00
|
|
|
mask = 1 << (CHARWIDTH - 1 - j);
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = 0; i < CHARHEIGHT; i++)
|
1995-04-21 06:47:35 +04:00
|
|
|
col[i] = ((c[i] & mask) ? 255 : 0) ^ rev;
|
|
|
|
putpixel(x + j, y, col, CHARHEIGHT);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
if (attr & ATTR_UNDER) {
|
|
|
|
col[0] = 255;
|
1996-05-07 19:52:19 +04:00
|
|
|
for (j = 0; j < CHARWIDTH; j++)
|
1995-04-21 06:47:35 +04:00
|
|
|
putpixel(x + j, y + CHARHEIGHT - 1, col, 1);
|
|
|
|
}
|
|
|
|
break;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
drawcursor()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_int j, X, Y;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
X = x * CHARWIDTH;
|
|
|
|
Y = y * CHARHEIGHT;
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
for (j = 0; j < CHARWIDTH; j++)
|
1995-04-21 06:47:35 +04:00
|
|
|
reversepixel(X + j, Y, CHARHEIGHT);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
erasecursor()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_int j, X, Y;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
X = x * CHARWIDTH;
|
|
|
|
Y = y * CHARHEIGHT;
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
for (j = 0; j < CHARWIDTH; j++)
|
1995-04-21 06:47:35 +04:00
|
|
|
reversepixel(X + j, Y, CHARHEIGHT);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
scrollup()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_char *from, *to;
|
|
|
|
u_int linebytes;
|
|
|
|
u_short i;
|
1996-05-07 19:52:19 +04:00
|
|
|
|
|
|
|
linebytes = videorowbytes * CHARHEIGHT;
|
1997-05-12 11:53:58 +04:00
|
|
|
to = (u_char *)videoaddr + (scrreg_top * linebytes);
|
1996-05-07 19:52:19 +04:00
|
|
|
from = to + linebytes;
|
|
|
|
|
|
|
|
for (i = (scrreg_bottom - scrreg_top) * CHARHEIGHT; i > 0; i--) {
|
|
|
|
ovbcopy(from, to, screenrowbytes);
|
|
|
|
from += videorowbytes;
|
|
|
|
to += videorowbytes;
|
|
|
|
}
|
|
|
|
for (i = CHARHEIGHT; i > 0; i--) {
|
|
|
|
bzero(to, screenrowbytes);
|
|
|
|
to += videorowbytes;
|
1994-07-31 10:45:50 +04:00
|
|
|
}
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
scrolldown()
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_char *from, *to;
|
|
|
|
u_int linebytes;
|
|
|
|
u_short i;
|
1996-05-07 19:52:19 +04:00
|
|
|
|
|
|
|
linebytes = videorowbytes * CHARHEIGHT;
|
1997-05-12 11:53:58 +04:00
|
|
|
to = (u_char *)videoaddr + ((scrreg_bottom + 1) * linebytes);
|
1996-05-07 19:52:19 +04:00
|
|
|
from = to - linebytes;
|
|
|
|
|
|
|
|
for (i = (scrreg_bottom - scrreg_top) * CHARHEIGHT; i > 0; i--) {
|
|
|
|
from -= videorowbytes;
|
|
|
|
to -= videorowbytes;
|
|
|
|
ovbcopy(from, to, screenrowbytes);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = CHARHEIGHT; i > 0; i--) {
|
|
|
|
to -= videorowbytes;
|
|
|
|
bzero(to, screenrowbytes);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
clear_screen(which)
|
|
|
|
int which;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_char *p;
|
|
|
|
u_short len, i;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
p = (u_char *)videoaddr;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
switch (which) {
|
1995-04-21 06:47:35 +04:00
|
|
|
case 0: /* To end of screen */
|
1996-05-07 19:52:19 +04:00
|
|
|
if (x > 0) {
|
|
|
|
clear_line(0);
|
|
|
|
if (y < scrrows)
|
|
|
|
y++;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
p += y * videorowbytes * CHARHEIGHT;
|
|
|
|
len = scrrows - y;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 1: /* To start of screen */
|
1996-05-07 19:52:19 +04:00
|
|
|
if (x > 0) {
|
|
|
|
clear_line(1);
|
|
|
|
if (y > 0)
|
|
|
|
y--;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
len = y;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 2: /* Whole screen */
|
1996-12-18 06:06:06 +03:00
|
|
|
default:
|
1996-05-07 19:52:19 +04:00
|
|
|
len = scrrows;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = len * CHARHEIGHT; i > 0; i--) {
|
|
|
|
bzero(p, screenrowbytes);
|
|
|
|
p += videorowbytes;
|
|
|
|
}
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
clear_line(which)
|
|
|
|
int which;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_char *to;
|
|
|
|
u_int linebytes;
|
1996-05-07 19:52:19 +04:00
|
|
|
int start, end, i;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1996-11-10 12:35:04 +03:00
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
/*
|
|
|
|
* 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) {
|
1996-05-05 10:15:56 +04:00
|
|
|
default:
|
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 */
|
1996-11-10 12:35:04 +03:00
|
|
|
linebytes = videorowbytes * CHARHEIGHT;
|
1997-05-12 11:53:58 +04:00
|
|
|
to = (u_char *)videoaddr + (y * linebytes);
|
1996-11-10 12:35:04 +03:00
|
|
|
|
|
|
|
for (i = CHARHEIGHT; i > 0; i--) {
|
|
|
|
bzero(to, screenrowbytes);
|
|
|
|
to += videorowbytes;
|
|
|
|
}
|
|
|
|
return;
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = start; i < end; i++)
|
1995-04-21 06:47:35 +04:00
|
|
|
writechar(' ', i, y, ATTR_NONE);
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-07-17 05:24:34 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
reset_tabs()
|
1995-07-17 05:24:34 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = 0; i<= scrcols; i++)
|
1995-07-17 05:24:34 +04:00
|
|
|
tab_stops[i] = ((i % 8) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
vt100_reset()
|
1995-07-17 05:24:34 +04:00
|
|
|
{
|
1996-05-05 10:15:56 +04:00
|
|
|
reset_tabs();
|
1996-11-10 12:35:04 +03:00
|
|
|
scrreg_top = 0;
|
|
|
|
scrreg_bottom = scrrows - 1;
|
1995-07-17 05:24:34 +04:00
|
|
|
attr = ATTR_NONE;
|
|
|
|
}
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
putc_normal(ch)
|
|
|
|
char ch;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
|
|
|
switch (ch) {
|
1995-07-17 05:24:34 +04:00
|
|
|
case '\a': /* Beep */
|
1997-02-11 10:51:18 +03:00
|
|
|
mac68k_ring_bell(bell_freq, bell_length, bell_volume);
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 127: /* Delete */
|
|
|
|
case '\b': /* Backspace */
|
1996-05-07 19:52:19 +04:00
|
|
|
if (hanging_cursor)
|
1995-04-21 06:47:35 +04:00
|
|
|
hanging_cursor = 0;
|
1996-05-07 19:52:19 +04:00
|
|
|
else if (x > 0)
|
|
|
|
x--;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case '\t': /* Tab */
|
|
|
|
do {
|
|
|
|
ite_putchar(' ');
|
1996-05-05 10:15:56 +04:00
|
|
|
x++;
|
|
|
|
} while ((tab_stops[x] == 0) && (x < scrcols));
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case '\n': /* Line feed */
|
1996-11-10 12:35:04 +03:00
|
|
|
if (y == scrreg_bottom)
|
1995-04-21 06:47:35 +04:00
|
|
|
scrollup();
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-07-17 05:24:34 +04:00
|
|
|
y++;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case '\r': /* Carriage return */
|
|
|
|
x = 0;
|
|
|
|
hanging_cursor = 0;
|
|
|
|
break;
|
|
|
|
case '\e': /* Escape */
|
|
|
|
vt100state = ESesc;
|
|
|
|
hanging_cursor = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (ch >= ' ') {
|
1994-07-21 10:35:49 +04:00
|
|
|
if (hanging_cursor) {
|
1995-04-21 06:47:35 +04:00
|
|
|
x = 0;
|
1996-11-10 12:35:04 +03:00
|
|
|
if (y == scrreg_bottom)
|
1995-04-21 06:47:35 +04:00
|
|
|
scrollup();
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-07-17 05:24:34 +04:00
|
|
|
y++;
|
1994-07-21 10:35:49 +04:00
|
|
|
hanging_cursor = 0;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
writechar(ch, x, y, attr);
|
1996-05-07 19:52:19 +04:00
|
|
|
|
|
|
|
if (x == scrcols - 1)
|
1995-04-21 06:47:35 +04:00
|
|
|
hanging_cursor = 1;
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-04-21 06:47:35 +04:00
|
|
|
x++;
|
1995-07-17 05:24:34 +04:00
|
|
|
if (x >= scrcols) { /* can we ever get here? */
|
1995-04-21 06:47:35 +04:00
|
|
|
x = 0;
|
|
|
|
y++;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
}
|
|
|
|
break;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
putc_esc(ch)
|
|
|
|
char ch;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
|
|
|
vt100state = ESnormal;
|
|
|
|
|
|
|
|
switch (ch) {
|
1995-04-21 06:47:35 +04:00
|
|
|
case '[':
|
|
|
|
vt100state = ESsquare;
|
|
|
|
break;
|
1996-11-10 12:35:04 +03:00
|
|
|
case '(':
|
|
|
|
vt100state = ESsetG0;
|
|
|
|
break;
|
|
|
|
case ')':
|
|
|
|
vt100state = ESsetG1;
|
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
case 'D': /* Line feed */
|
1996-11-10 12:35:04 +03:00
|
|
|
if (y == scrreg_bottom)
|
1995-07-17 05:24:34 +04:00
|
|
|
scrollup();
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-07-17 05:24:34 +04:00
|
|
|
y++;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 'H': /* Set tab stop */
|
1995-07-17 05:24:34 +04:00
|
|
|
tab_stops[x] = 1;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 'M': /* Cursor up */
|
1996-11-10 12:35:04 +03:00
|
|
|
if (y == scrreg_top)
|
1995-04-21 06:47:35 +04:00
|
|
|
scrolldown();
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-04-21 06:47:35 +04:00
|
|
|
y--;
|
|
|
|
break;
|
1995-07-17 05:24:34 +04:00
|
|
|
case '>':
|
|
|
|
vt100_reset();
|
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
case '7': /* Save cursor */
|
|
|
|
savex = x;
|
|
|
|
savey = y;
|
|
|
|
break;
|
|
|
|
case '8': /* Restore cursor */
|
|
|
|
x = savex;
|
|
|
|
y = savey;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Rest not supported */
|
|
|
|
break;
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
putc_gotpars(ch)
|
|
|
|
char ch;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1996-05-07 19:52:19 +04:00
|
|
|
int i;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
|
|
|
vt100state = ESnormal;
|
|
|
|
switch (ch) {
|
1995-04-21 06:47:35 +04:00
|
|
|
case 'A': /* Up */
|
1995-07-17 05:24:34 +04:00
|
|
|
i = par[0];
|
|
|
|
do {
|
1996-11-10 12:35:04 +03:00
|
|
|
if (y == scrreg_top)
|
1995-07-17 05:24:34 +04:00
|
|
|
scrolldown();
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-07-17 05:24:34 +04:00
|
|
|
y--;
|
|
|
|
i--;
|
|
|
|
} while (i > 0);
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 'B': /* Down */
|
1995-07-17 05:24:34 +04:00
|
|
|
i = par[0];
|
|
|
|
do {
|
1996-11-10 12:35:04 +03:00
|
|
|
if (y == scrreg_bottom)
|
1995-07-17 05:24:34 +04:00
|
|
|
scrollup();
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1995-07-17 05:24:34 +04:00
|
|
|
y++;
|
|
|
|
i--;
|
|
|
|
} while (i > 0);
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 'C': /* Right */
|
1995-07-09 19:36:41 +04:00
|
|
|
x+= par[0] ? par[0] : 1;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 'D': /* Left */
|
1995-07-09 19:36:41 +04:00
|
|
|
x-= par[0] ? par[0] : 1;
|
1995-04-21 06:47:35 +04:00
|
|
|
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;
|
1996-11-10 12:35:04 +03:00
|
|
|
case 'L': /* Add line */
|
|
|
|
if (scrreg_top < scrreg_bottom) {
|
|
|
|
i = scrreg_top;
|
|
|
|
scrreg_top = y;
|
|
|
|
scrolldown();
|
|
|
|
scrreg_top = i;
|
|
|
|
} else
|
|
|
|
clear_line(0);
|
|
|
|
break;
|
|
|
|
case 'M': /* Delete line */
|
|
|
|
if (scrreg_top < scrreg_bottom) {
|
|
|
|
i = scrreg_top;
|
|
|
|
scrreg_top = y;
|
|
|
|
scrollup();
|
|
|
|
scrreg_top = i;
|
|
|
|
} else
|
|
|
|
clear_line(0);
|
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
case 'g': /* Clear tab stops */
|
1996-05-07 19:52:19 +04:00
|
|
|
if (numpars >= 1 && par[0] == 3)
|
1995-07-17 05:24:34 +04:00
|
|
|
reset_tabs();
|
1995-04-21 06:47:35 +04:00
|
|
|
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;
|
1996-11-10 12:35:04 +03:00
|
|
|
case 21:
|
|
|
|
attr &= ~ATTR_BOLD;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
attr &= ~ATTR_UNDER;
|
|
|
|
break;
|
|
|
|
case 27:
|
|
|
|
attr &= ~ATTR_REVERSE;
|
|
|
|
break;
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'r': /* Set scroll region */
|
1995-07-17 05:24:34 +04:00
|
|
|
/* ensure top < bottom, and both within limits */
|
1996-05-07 19:52:19 +04:00
|
|
|
if ((numpars > 0) && (par[0] < scrrows))
|
1996-11-10 12:35:04 +03:00
|
|
|
scrreg_top = par[0] - 1;
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1996-11-10 12:35:04 +03:00
|
|
|
scrreg_top = 0;
|
1996-05-07 19:52:19 +04:00
|
|
|
if ((numpars > 1) && (par[1] <= scrrows) && (par[1] > par[0]))
|
1996-11-10 12:35:04 +03:00
|
|
|
scrreg_bottom = par[1] - 1;
|
1996-05-07 19:52:19 +04:00
|
|
|
else
|
1996-11-10 12:35:04 +03:00
|
|
|
scrreg_bottom = scrrows - 1;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
putc_getpars(ch)
|
|
|
|
char ch;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1996-11-10 12:35:04 +03:00
|
|
|
switch (ch) {
|
|
|
|
case '?':
|
1994-07-21 10:35:49 +04:00
|
|
|
/* Not supported */
|
|
|
|
return;
|
1996-11-10 12:35:04 +03:00
|
|
|
case '[':
|
1994-07-21 10:35:49 +04:00
|
|
|
vt100state = ESnormal;
|
|
|
|
/* Not supported */
|
|
|
|
return;
|
1996-11-10 12:35:04 +03:00
|
|
|
default:
|
|
|
|
if (ch == ';' && numpars < MAXPARS - 1)
|
|
|
|
numpars++;
|
|
|
|
else if (ch >= '0' && ch <= '9') {
|
|
|
|
par[numpars] *= 10;
|
|
|
|
par[numpars] += ch - '0';
|
|
|
|
} else {
|
|
|
|
numpars++;
|
|
|
|
vt100state = ESgotpars;
|
|
|
|
putc_gotpars(ch);
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
}
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
putc_square(ch)
|
|
|
|
char ch;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
u_short i;
|
1994-07-21 10:35:49 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
for (i = 0; i < MAXPARS; i++)
|
1994-07-21 10:35:49 +04:00
|
|
|
par[i] = 0;
|
|
|
|
|
|
|
|
numpars = 0;
|
|
|
|
vt100state = ESgetpars;
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
putc_getpars(ch);
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-05-07 19:52:19 +04:00
|
|
|
ite_putchar(ch)
|
|
|
|
char ch;
|
1994-07-21 10:35:49 +04:00
|
|
|
{
|
|
|
|
switch (vt100state) {
|
1996-05-07 19:52:19 +04:00
|
|
|
default:
|
|
|
|
vt100state = ESnormal; /* FALLTHROUGH */
|
1995-04-21 06:47:35 +04:00
|
|
|
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;
|
1994-07-21 10:35:49 +04:00
|
|
|
}
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
if (x >= scrcols)
|
1994-07-21 10:35:49 +04:00
|
|
|
x = scrcols - 1;
|
1996-05-07 19:52:19 +04:00
|
|
|
if (x < 0)
|
1994-07-08 11:55:46 +04:00
|
|
|
x = 0;
|
1996-05-07 19:52:19 +04:00
|
|
|
if (y >= scrrows)
|
1994-07-21 10:35:49 +04:00
|
|
|
y = scrrows - 1;
|
1996-05-07 19:52:19 +04:00
|
|
|
if (y < 0)
|
1994-07-21 10:35:49 +04:00
|
|
|
y = 0;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
/*
|
|
|
|
* Keyboard support functions
|
|
|
|
*/
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static int
|
1996-05-07 19:52:19 +04:00
|
|
|
ite_pollforchar()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1996-05-07 19:52:19 +04:00
|
|
|
int s;
|
1995-04-21 06:47:35 +04:00
|
|
|
register int intbits;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
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) {
|
1994-12-04 02:33:55 +03:00
|
|
|
mrg_adbintr();
|
1994-07-08 11:55:46 +04:00
|
|
|
via_reg(VIA1, vIFR) = V1IF_ADBRDY;
|
|
|
|
}
|
1994-12-04 02:33:55 +03:00
|
|
|
if (intbits & 0x10) {
|
|
|
|
mrg_pmintr();
|
|
|
|
via_reg(VIA1, vIFR) = 0x10;
|
|
|
|
}
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
adb_polling = 0;
|
|
|
|
|
1994-07-31 10:45:50 +04:00
|
|
|
splx(s);
|
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
return polledkey;
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
/*
|
1996-05-07 19:52:19 +04:00
|
|
|
* Autoconfig attachment
|
1994-07-08 11:55:46 +04:00
|
|
|
*/
|
1996-05-07 19:52:19 +04:00
|
|
|
|
|
|
|
struct cfattach ite_ca = {
|
|
|
|
sizeof(struct device), itematch, iteattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver ite_cd = {
|
|
|
|
NULL, "ite", DV_TTY
|
|
|
|
};
|
1996-05-05 10:15:56 +04:00
|
|
|
|
|
|
|
static int
|
1996-12-16 19:17:02 +03:00
|
|
|
itematch(parent, cf, aux)
|
1996-08-05 05:26:31 +04:00
|
|
|
struct device *parent;
|
1996-12-16 19:17:02 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1996-05-05 10:15:56 +04:00
|
|
|
{
|
1996-08-05 05:26:31 +04:00
|
|
|
struct grfbus_attach_args *ga = aux;
|
|
|
|
struct grfmode *gm = ga->ga_grfmode;
|
|
|
|
vm_offset_t pa;
|
|
|
|
|
|
|
|
if (strcmp(ga->ga_name, "ite"))
|
|
|
|
return 0;
|
1997-04-21 00:31:18 +04:00
|
|
|
pa = pmap_extract(pmap_kernel(), (vm_offset_t)(gm->fbbase + gm->fboff));
|
1996-08-05 05:26:31 +04:00
|
|
|
|
1997-04-21 00:31:18 +04:00
|
|
|
return (pa == (vm_offset_t)mac68k_vidphys);
|
1996-05-05 10:15:56 +04:00
|
|
|
}
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static void
|
1996-08-05 05:26:31 +04:00
|
|
|
iteattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
1996-05-05 10:15:56 +04:00
|
|
|
void *aux;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1996-10-13 07:21:13 +04:00
|
|
|
printf(" (minimal console)\n");
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
/*
|
|
|
|
* Tty handling functions
|
|
|
|
*/
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1996-05-07 19:52:19 +04:00
|
|
|
iteopen(dev, mode, devtype, p)
|
|
|
|
dev_t dev;
|
|
|
|
int mode;
|
|
|
|
int devtype;
|
|
|
|
struct proc *p;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
|
|
|
register struct tty *tp;
|
|
|
|
register int error;
|
|
|
|
|
1997-05-12 11:53:58 +04:00
|
|
|
dprintf("iteopen(): enter(0x%x)\n", (int)dev);
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1996-05-25 04:56:38 +04:00
|
|
|
if (!ite_initted)
|
|
|
|
return (ENXIO);
|
|
|
|
|
1996-06-01 04:13:39 +04:00
|
|
|
if (ite_tty == NULL) {
|
1994-07-08 11:55:46 +04:00
|
|
|
tp = ite_tty = ttymalloc();
|
1996-06-01 04:13:39 +04:00
|
|
|
tty_attach(tp);
|
|
|
|
} else
|
1994-07-08 11:55:46 +04:00
|
|
|
tp = ite_tty;
|
1995-04-21 06:47:35 +04:00
|
|
|
if ((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) == (TS_ISOPEN | TS_XCLUDE)
|
1994-07-08 11:55:46 +04:00
|
|
|
&& p->p_ucred->cr_uid != 0)
|
|
|
|
return (EBUSY);
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
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;
|
1994-07-08 11:55:46 +04:00
|
|
|
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;
|
1994-07-08 11:55:46 +04:00
|
|
|
ttsetwater(tp);
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
error = (*linesw[tp->t_line].l_open) (dev, tp);
|
1994-07-08 11:55:46 +04:00
|
|
|
tp->t_winsize.ws_row = scrrows;
|
|
|
|
tp->t_winsize.ws_col = scrcols;
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteopen(): exit(%d)\n", error);
|
1994-07-08 11:55:46 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1996-05-07 19:52:19 +04:00
|
|
|
iteclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag;
|
|
|
|
int mode;
|
|
|
|
struct proc *p;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
dprintf("iteclose: enter (%d)\n", (int)dev);
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
(*linesw[ite_tty->t_line].l_close) (ite_tty, flag);
|
|
|
|
ttyclose(ite_tty);
|
1994-07-08 11:55:46 +04:00
|
|
|
#if 0
|
1995-04-21 06:47:35 +04:00
|
|
|
ttyfree(ite_tty);
|
|
|
|
ite_tty = (struct tty *) 0;
|
1994-07-08 11:55:46 +04:00
|
|
|
#endif
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteclose: exit\n");
|
1994-07-08 11:55:46 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1996-05-07 19:52:19 +04:00
|
|
|
iteread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flag;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteread: enter\n");
|
|
|
|
return (*linesw[ite_tty->t_line].l_read) (ite_tty, uio, flag);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1996-05-07 19:52:19 +04:00
|
|
|
itewrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int flag;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("itewrite: enter\n");
|
|
|
|
return (*linesw[ite_tty->t_line].l_write) (ite_tty, uio, flag);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-20 19:27:43 +04:00
|
|
|
struct tty *
|
|
|
|
itetty(dev)
|
1996-05-07 19:52:19 +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
|
1996-05-07 19:52:19 +04:00
|
|
|
iteioctl(dev, cmd, addr, flag, p)
|
|
|
|
dev_t dev;
|
|
|
|
int cmd;
|
|
|
|
caddr_t addr;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
|
|
|
register struct tty *tp = ite_tty;
|
1996-05-07 19:52:19 +04:00
|
|
|
int error;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteioctl: enter(%d, 0x%x)\n", cmd, cmd);
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, addr, flag, p);
|
1994-07-08 11:55:46 +04:00
|
|
|
if (error >= 0) {
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteioctl: exit(%d)\n", error);
|
1994-07-08 11:55:46 +04:00
|
|
|
return (error);
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
error = ttioctl(tp, cmd, addr, flag, p);
|
|
|
|
if (error >= 0) {
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteioctl: exit(%d)\n", error);
|
1994-07-08 11:55:46 +04:00
|
|
|
return (error);
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
switch (cmd) {
|
1996-05-07 19:52:19 +04:00
|
|
|
case ITEIOC_RINGBELL:
|
1997-02-11 10:51:18 +03:00
|
|
|
return mac68k_ring_bell(bell_freq, bell_length, bell_volume);
|
1996-05-07 19:52:19 +04:00
|
|
|
case ITEIOC_SETBELL:
|
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
struct bellparams *bp = (void *)addr;
|
1994-12-04 02:33:55 +03:00
|
|
|
|
1997-02-11 10:51:18 +03:00
|
|
|
/* Do some sanity checks. */
|
|
|
|
if (bp->freq < 10 || bp->freq > 40000)
|
|
|
|
return (EINVAL);
|
|
|
|
if (bp->len < 0 || bp->len > 3600)
|
|
|
|
return (EINVAL);
|
|
|
|
if (bp->vol < 0 || bp->vol > 100)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
bell_freq = bp->freq;
|
|
|
|
bell_length = bp->len;
|
|
|
|
bell_volume = bp->vol;
|
1994-12-04 02:33:55 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
case ITEIOC_GETBELL:
|
|
|
|
{
|
1997-05-12 11:53:58 +04:00
|
|
|
struct bellparams *bp = (void *)addr;
|
1994-12-04 02:33:55 +03:00
|
|
|
|
1997-02-11 10:51:18 +03:00
|
|
|
bell_freq = bp->freq;
|
|
|
|
bell_length = bp->len;
|
|
|
|
bell_volume = bp->vol;
|
1994-12-04 02:33:55 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
dprintf("iteioctl: exit(ENOTTY)\n");
|
1994-07-08 11:55:46 +04:00
|
|
|
return (ENOTTY);
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void
|
|
|
|
itestart(register struct tty * tp)
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
|
|
|
register int cc, s;
|
|
|
|
|
|
|
|
s = spltty();
|
1995-04-21 06:47:35 +04:00
|
|
|
if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) {
|
1994-07-08 11:55:46 +04:00
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
|
|
|
|
cc = tp->t_outq.c_cc;
|
1994-07-21 10:35:49 +04:00
|
|
|
splx(s);
|
1995-04-21 06:47:35 +04:00
|
|
|
erasecursor();
|
1996-05-07 19:52:19 +04:00
|
|
|
while (cc-- > 0)
|
1995-04-21 06:47:35 +04:00
|
|
|
ite_putchar(getc(&tp->t_outq));
|
|
|
|
drawcursor();
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
s = spltty();
|
1994-07-08 11:55:46 +04:00
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void
|
|
|
|
itestop(struct tty * tp, int flag)
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1996-05-07 19:52:19 +04:00
|
|
|
int s;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
s = spltty();
|
1996-05-07 19:52:19 +04:00
|
|
|
if (tp->t_state & TS_BUSY)
|
|
|
|
if ((tp->t_state & TS_TTSTOP) == 0)
|
1994-07-08 11:55:46 +04:00
|
|
|
tp->t_state |= TS_FLUSH;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
|
|
|
ite_intr(adb_event_t * event)
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1997-04-14 05:02:47 +04:00
|
|
|
static int shift = 0, control = 0, capslock = 0;
|
1996-05-07 19:52:19 +04:00
|
|
|
int key, press, val, state;
|
|
|
|
char str[10], *s;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
key = event->u.k.key;
|
1995-04-21 06:47:35 +04:00
|
|
|
press = ADBK_PRESS(key);
|
|
|
|
val = ADBK_KEYVAL(key);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
if (val == ADBK_SHIFT)
|
1994-07-08 11:55:46 +04:00
|
|
|
shift = press;
|
1997-04-14 05:02:47 +04:00
|
|
|
else if (val == ADBK_CAPSLOCK)
|
|
|
|
capslock = !capslock;
|
1996-05-07 19:52:19 +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;
|
1997-04-14 05:02:47 +04:00
|
|
|
if (capslock && isealpha(keyboard[val][1]))
|
|
|
|
state = 1;
|
1996-05-07 19:52:19 +04:00
|
|
|
if (shift)
|
|
|
|
state = 1;
|
|
|
|
if (control)
|
|
|
|
state = 2;
|
|
|
|
str[0] = keyboard[val][state];
|
|
|
|
str[1] = '\0';
|
|
|
|
break;
|
1996-05-05 10:15:56 +04:00
|
|
|
}
|
1996-05-07 19:52:19 +04:00
|
|
|
if (adb_polling)
|
|
|
|
polledkey = str[0];
|
|
|
|
else
|
|
|
|
for (s = str; *s; s++)
|
|
|
|
(*linesw[ite_tty->t_line].l_rint)(*s, ite_tty);
|
1996-05-05 10:15:56 +04:00
|
|
|
}
|
|
|
|
return 0;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Console functions
|
|
|
|
*/
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
|
|
|
itecnprobe(struct consdev * cp)
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1996-05-07 19:52:19 +04:00
|
|
|
int maj, unit;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
/* locate the major number */
|
1996-05-07 19:52:19 +04:00
|
|
|
for (maj = 0; maj < nchrdev; maj++)
|
|
|
|
if (cdevsw[maj].d_open == iteopen)
|
1994-07-08 11:55:46 +04:00
|
|
|
break;
|
|
|
|
|
1996-05-07 19:52:19 +04:00
|
|
|
if (maj == nchrdev)
|
1995-04-21 06:47:35 +04:00
|
|
|
panic("itecnprobe(): did not find iteopen().");
|
1996-05-07 19:52:19 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
unit = 0; /* hardcode first device as console. */
|
1994-07-08 11:55:46 +04:00
|
|
|
|
|
|
|
/* initialize required fields */
|
1995-04-21 06:47:35 +04:00
|
|
|
cp->cn_dev = makedev(maj, unit);
|
1994-07-08 11:55:46 +04:00
|
|
|
cp->cn_pri = CN_INTERNAL;
|
1996-05-05 10:15:56 +04:00
|
|
|
|
|
|
|
return 0;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1997-04-08 08:47:08 +04:00
|
|
|
void
|
|
|
|
itereset()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1996-05-25 04:56:38 +04:00
|
|
|
ite_initted = 1;
|
1994-07-08 11:55:46 +04:00
|
|
|
width = videosize & 0xffff;
|
|
|
|
height = (videosize >> 16) & 0xffff;
|
|
|
|
scrrows = height / CHARHEIGHT;
|
|
|
|
scrcols = width / CHARWIDTH;
|
|
|
|
|
1994-07-21 10:35:49 +04:00
|
|
|
switch (videobitdepth) {
|
1995-04-21 06:47:35 +04:00
|
|
|
default:
|
|
|
|
case 1:
|
1996-08-05 05:26:31 +04:00
|
|
|
putpixel = putpixel1;
|
1995-04-21 06:47:35 +04:00
|
|
|
reversepixel = reversepixel1;
|
1996-05-07 19:52:19 +04:00
|
|
|
screenrowbytes = (width + 7) >> 3;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
putpixel = putpixel2;
|
|
|
|
reversepixel = reversepixel1;
|
1996-05-07 19:52:19 +04:00
|
|
|
screenrowbytes = (width + 3) >> 2;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
putpixel = putpixel4;
|
|
|
|
reversepixel = reversepixel1;
|
1996-05-07 19:52:19 +04:00
|
|
|
screenrowbytes = (width + 1) >> 1;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
putpixel = putpixel8;
|
|
|
|
reversepixel = reversepixel1;
|
1996-05-07 19:52:19 +04:00
|
|
|
screenrowbytes = width;
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
1997-04-08 08:47:08 +04:00
|
|
|
case 16:
|
|
|
|
putpixel = putpixel16;
|
|
|
|
reversepixel = reversepixel1;
|
|
|
|
screenrowbytes = width*2;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
putpixel = putpixel32;
|
|
|
|
reversepixel = reversepixel1;
|
|
|
|
screenrowbytes = width*4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
vt100_reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
itecninit(struct consdev * cp)
|
|
|
|
{
|
|
|
|
if (ite_initted)
|
|
|
|
return 0;
|
1996-08-05 05:26:31 +04:00
|
|
|
|
1997-04-08 08:47:08 +04:00
|
|
|
ite_initted = 1;
|
|
|
|
itereset();
|
1996-05-05 10:15:56 +04:00
|
|
|
return iteon(cp->cn_dev, 0);
|
1995-03-26 19:52:21 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1995-03-26 19:52:21 +04:00
|
|
|
iteon(dev_t dev, int flags)
|
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
erasecursor();
|
|
|
|
clear_screen(2);
|
|
|
|
drawcursor();
|
1996-05-05 10:15:56 +04:00
|
|
|
return 0;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1995-03-26 19:52:21 +04:00
|
|
|
iteoff(dev_t dev, int flags)
|
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
erasecursor();
|
|
|
|
clear_screen(2);
|
1996-05-05 10:15:56 +04:00
|
|
|
return 0;
|
1995-03-26 19:52:21 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1994-07-08 11:55:46 +04:00
|
|
|
itecngetc(dev_t dev)
|
|
|
|
{
|
|
|
|
/* Oh, man... */
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
return ite_pollforchar();
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
int
|
1994-07-08 11:55:46 +04:00
|
|
|
itecnputc(dev_t dev, int c)
|
|
|
|
{
|
1996-05-18 22:53:50 +04:00
|
|
|
extern dev_t mac68k_zsdev;
|
|
|
|
extern int zscnputc __P((dev_t dev, int c));
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
erasecursor();
|
|
|
|
ite_putchar(c);
|
|
|
|
drawcursor();
|
1994-09-29 06:33:13 +03:00
|
|
|
if (mac68k_machine.serial_boot_echo)
|
1996-05-18 22:53:50 +04:00
|
|
|
zscnputc(mac68k_zsdev, c);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-05-05 10:15:56 +04:00
|
|
|
return c;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|