Console support.

This commit is contained in:
tsubai 1998-07-02 18:58:32 +00:00
parent f1b1f5211a
commit a8ce5c2403
6 changed files with 28 additions and 181 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.5 1998/06/26 01:54:02 lukem Exp $
# $NetBSD: GENERIC,v 1.6 1998/07/02 18:58:32 tsubai Exp $
#
# POWERMAC config file
#
@ -108,6 +108,8 @@ pchb* at pci? dev ? function ? # PCI-Host bridges
#ppb* at pci? dev ? function ? # PCI-PCI bridges
#pci* at ppb? bus ?
ofcons0 at pci? dev ? function ? # Openfirmware console
#de* at pci? dev ? function ? # DEC 21x4x-based Ethernet
ep* at pci? dev ? function ?
ne* at pci? dev ? function ? # NE2000-compatible Ethernet
@ -122,10 +124,6 @@ zsc0 at obio0
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
grfati0 at pci? dev ? function ? # ATY,mach64
grf0 at grfati0
ite0 at grf0
sd* at scsibus? target ? lun ? # SCSI disks
st* at scsibus? target ? lun ? # SCSI tape drives
cd* at scsibus? target ? lun ? # SCSI CD-ROM drives

View File

@ -101,3 +101,7 @@ device ite: tty
attach ite at grf
file arch/macppc/dev/ite.c ite needs-flag
file arch/macppc/dev/font_8x16.c ite
device ofcons: tty
attach ofcons at pci
file arch/macppc/dev/ofcons.c ofcons needs-flag

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb.c,v 1.1 1998/05/15 10:15:47 tsubai Exp $ */
/* $NetBSD: adb.c,v 1.2 1998/07/02 18:58:32 tsubai Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -183,7 +183,7 @@ adb_handoff(event)
adb_enqevent(event);
} else {
if (event->def_addr == 2)
ite_intr(event);
kbd_intr(event);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ite.c,v 1.1 1998/05/15 10:15:49 tsubai Exp $ */
/* $NetBSD: ite.c,v 1.2 1998/07/02 18:58:32 tsubai Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -67,9 +67,6 @@
#include <machine/bus.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 <machine/grfioctl.h>
@ -162,10 +159,6 @@ static int bell_freq = 1880; /* frequency */
static int bell_length = 10; /* duration */
static int bell_volume = 100; /* volume */
/* For polled ADB mode */
static int polledkey;
extern int adb_polling;
struct tty *ite_tty; /* Our tty */
static void (*putpixel) __P((int x, int y, int *c, int num));
@ -877,46 +870,6 @@ ite_putchar(ch)
}
/*
* Keyboard support functions
*/
static int
ite_pollforchar()
{
int s;
register int intbits;
s = splhigh();
polledkey = -1;
adb_polling = 1;
/* pretend we're VIA interrupt dispatcher */
while (polledkey == -1) {
adb_intr_cuda();
#if 0
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;
}
#endif
}
adb_polling = 0;
splx(s);
return polledkey;
}
/*
* Autoconfig attachment
*/
@ -1140,71 +1093,6 @@ itestop(struct tty * tp, int flag)
splx(s);
}
int
ite_intr(adb_event_t * event)
{
static int shift = 0, control = 0, capslock = 0;
int key, press, val, state;
char str[10], *s;
key = event->u.k.key;
press = ADBK_PRESS(key);
val = ADBK_KEYVAL(key);
/*printf("ite_intr: (%x %x ", press, val);*/
if (val == ADBK_SHIFT)
shift = press;
else if (val == ADBK_CAPSLOCK)
capslock = !capslock;
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 (capslock && isealpha(keyboard[val][1]))
state = 1;
if (shift)
state = 1;
if (control)
state = 2;
str[0] = keyboard[val][state];
str[1] = '\0';
break;
}
if (adb_polling)
polledkey = str[0];
else
for (s = str; *s; s++)
(*linesw[ite_tty->t_line].l_rint)(*s, ite_tty);
}
/*printf("%x) ", str[0]);*/
return 0;
}
/*
* Console functions
*/
@ -1291,8 +1179,6 @@ void
itecninit(struct consdev * cp)
{
int node, options;
int len;
vm_offset_t pa;
u_int reg[5];
extern int console_node;
@ -1309,22 +1195,7 @@ itecninit(struct consdev * cp)
OF_getprop(node, "linebytes", &videorowbytes, sizeof(videorowbytes));
OF_getprop(node, "assigned-addresses", reg, sizeof(reg));
/*
* XXX This should not be here.
*
* we cannot use kmem_alloc_...
*/
len = videorowbytes * height;
pa = reg[2];
while (len > 0) {
pmap_enter(pmap_kernel(), pa, pa,
VM_PROT_READ|VM_PROT_WRITE, 1);
pa += NBPG;
len -= NBPG;
}
videoaddr = reg[2] + 0x400; /* XXX ATI only */
videosize = width | (height << 16);
ite_initted = 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: zs.c,v 1.1 1998/05/15 10:15:49 tsubai Exp $ */
/* $NetBSD: zs.c,v 1.2 1998/07/02 18:58:32 tsubai Exp $ */
/*
* Copyright (c) 1996 Bill Studenmund
@ -281,6 +281,15 @@ zsc_attach(parent, self, aux)
if (zsaddr[zsc_unit] == NULL)
panic("zs_attach: zs%d not mapped\n", zsc_unit);
if (zsc_unit == 0) {
struct consdev cd;
cd.cn_pri = CN_DEAD;
zscnprobe(&cd);
if (cd.cn_pri != CN_DEAD)
zscninit(cn_tab);
}
if ((zs_hwflags[zsc_unit][0] | zs_hwflags[zsc_unit][1]) &
ZS_HWFLAG_CONSOLE) {
@ -1065,8 +1074,8 @@ zs_abort(cs)
#endif
}
static int ofccngetc __P((dev_t));
static void ofccnputc __P((dev_t, int));
extern int ofccngetc __P((dev_t));
extern void ofccnputc __P((dev_t, int));
struct consdev consdev_zs = {
zscnprobe,
@ -1076,8 +1085,6 @@ struct consdev consdev_zs = {
zscnpollc,
};
struct consdev *cn_tab = &consdev_zs;
void
zscnprobe(struct consdev * cp)
{
@ -1088,6 +1095,7 @@ zscnprobe(struct consdev * cp)
if (console_node == -1)
return;
bzero(type, sizeof(type));
l = OF_getprop(console_node, "device_type", type, sizeof(type));
if (l == -1 || l >= sizeof(type) - 1)
return;
@ -1096,9 +1104,6 @@ zscnprobe(struct consdev * cp)
cp->cn_pri = CN_REMOTE;
}
static int stdin, stdout;
void
zscninit(cd)
struct consdev *cd;
@ -1106,16 +1111,13 @@ zscninit(cd)
int chosen;
int sz;
int unit = 0;
int stdout;
char name[32];
chosen = OF_finddevice("/chosen");
if (chosen == -1)
return;
sz = OF_getprop(chosen, "stdin", &stdin, sizeof(stdin));
if (sz != sizeof(stdin))
return;
sz = OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
if (sz != sizeof(stdout))
return;
@ -1130,27 +1132,3 @@ zscninit(cd)
cd->cn_dev = makedev(zs_major, unit);
}
static int
ofccngetc(dev)
dev_t dev;
{
u_char ch;
int sz;
sz = OF_read(stdin, &ch, 1);
if (sz <= 0)
return -1;
return ch;
}
static void
ofccnputc(dev, c)
dev_t dev;
int c;
{
u_char ch = c;
OF_write(stdout, &ch, 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.3 1998/06/24 15:13:43 tsubai Exp $ */
/* $NetBSD: conf.c,v 1.4 1998/07/02 18:58:32 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -105,12 +105,8 @@ cdev_decl(vnd);
cdev_decl(ccd);
#include "adb.h"
cdev_decl(adb);
#define cdev_rtc_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), \
dev_init(c,n,read), dev_init(c,n,write), \
(dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
0, seltrue, (dev_type_mmap((*))) enodev }
#include "ofcons.h"
cdev_decl(ofc);
struct cdevsw cdevsw[] = {
cdev_cn_init(1,cn), /* 0: virtual console */
@ -120,7 +116,7 @@ struct cdevsw cdevsw[] = {
cdev_ptc_init(NPTY,ptc), /* 4: pseudo tty master */
cdev_log_init(1,log), /* 5: /dev/klog */
cdev_swap_init(1,sw), /* 6: /dev/drum pseudo device */
cdev_notdef(), /* 7: Openfirmware console */
cdev_tty_init(NOFCONS,ofc), /* 7: Openfirmware console */
cdev_notdef(), /* 8: Openfirmware disk */
cdev_notdef(), /* 9: Openfirmware RTC */
cdev_bpftun_init(NBPFILTER,bpf),/* 10: Berkeley packet filter */