Subject: Changes for the sun3 cons driver
To: None <glass@sun-lamp.cs.berkeley.edu>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: port-sun3
Date: 03/14/1994 12:31:09
Here are changes to make the cons driver use the EEPROM setting.
I moved this from arch/sun3 to arch/dev just for convenience.
*** arch/sun3/sun3/cons.h Fri Dec 17 01:57:19 1993
--- arch/sun3/dev/cons.h Mon Mar 14 01:36:08 1994
***************
*** 39,44 ****
--- 39,45 ----
*
* from: @(#)cons.h 7.3 (Berkeley) 11/2/90
* cons.h,v 1.2 1993/05/22 07:57:19 cgd Exp
+ * gwr: moved and modified
*/
struct consdev {
*** arch/sun3/sun3/cons.c Tue Mar 1 06:21:51 1994
--- arch/sun3/dev/cons.c Mon Mar 14 01:35:58 1994
***************
*** 40,113 ****
*
* from: @(#)cons.c 7.6 (Berkeley) 5/4/91
* cons.c,v 1.2 1993/05/22 07:57:18 cgd Exp
*/
- #include <sys/systm.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/systm.h>
- #include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/file.h>
#include <sys/conf.h>
! #include "cons.h"
#include "prom.h"
-
#include "zs.h"
int promcnprobe(), promcninit(), promcngetc(), promcnputc();
int zscnprobe(), zscninit(), zscngetc(), zscnputc();
! struct consdev constab[] = {
#if NPROM
! {promcnprobe, promcninit, promcngetc, promcnputc},
#endif
! #if NZS
! {zscnprobe, zscninit, zscngetc, zscnputc},
#endif
- { 0 },
};
- /* end XXX */
struct tty *constty = 0; /* virtual console output device */
struct consdev *cn_tab; /* physical console device info */
struct tty *cn_tty; /* XXX: console tty struct for tprintf */
cninit()
{
! struct consdev *cp;
! cn_tab = NULL;
! /*
! * should add code to use eeprom's console setting XXX
! * when applicable.
! */
/*
- * Collect information about all possible consoles
- * and find the one with highest priority
- */
- for (cp = constab; cp->cn_probe; cp++) {
- (*cp->cn_probe)(cp);
- if (cp->cn_pri > CN_DEAD &&
- (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri))
- cn_tab = cp;
- }
- /*
* No console, we can handle it (really??? XXX)
*/
! if ((cp = cn_tab) == NULL)
return;
/*
* Turn on console
*/
! cn_tty = cp->cn_tp;
! (*cp->cn_init)(cp);
! cn_tty = cp->cn_tp;
}
cnopen(dev, flag, mode, p)
--- 40,166 ----
*
* from: @(#)cons.c 7.6 (Berkeley) 5/4/91
* cons.c,v 1.2 1993/05/22 07:57:18 cgd Exp
+ * gwr: moved and modified
*/
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/file.h>
#include <sys/conf.h>
! #include <machine/mon.h>
! #include <machine/obio.h>
! #include <machine/eeprom.h>
+ #include "cons.h"
#include "prom.h"
#include "zs.h"
int promcnprobe(), promcninit(), promcngetc(), promcnputc();
int zscnprobe(), zscninit(), zscngetc(), zscnputc();
+ static int cn_probe_dead();
! static struct consdev cons_prom = {
#if NPROM
! promcnprobe, promcninit, promcngetc, promcnputc,
! #else
! cn_probe_dead,
#endif
! };
!
! static struct consdev cons_zs = {
! #if NZS
! zscnprobe, zscninit, zscngetc, zscnputc,
! #else
! cn_probe_dead,
#endif
};
+ static struct consdev cons_kbd_scr = {
+ #if 0 /* XXX - not yet */
+ kbd_cnprobe, kbd_cninit, promcngetc, promcnputc,
+ #else
+ cn_probe_dead,
+ #endif
+ };
+
struct tty *constty = 0; /* virtual console output device */
struct consdev *cn_tab; /* physical console device info */
struct tty *cn_tty; /* XXX: console tty struct for tprintf */
+ /*
+ * kern/init_main.c:main() calls consinit() early.
+ * ../sun3/machdep.c:consinit() just calls cninit()
+ */
+
cninit()
{
! struct consdev *cn = NULL;
! u_char eeCons = 0xFF; /* XXX - need an "illegal" value */
+ /* Use EEPROM console selector. */
+ if (eeprom_va == NULL) {
+ mon_printf("cninit: eeprom not yet mapped!\n");
+ } else {
+ eeCons = ((struct eeprom *)eeprom_va)->eeConsole;
+ mon_printf("cninit: eeConsole=0x%x\n", eeCons);
+ }
+ switch (eeCons) {
! case EE_CONS_COLOR:
! case EE_CONS_BW:
! cn = &cons_kbd_scr;
! (*cn->cn_probe)(cn);
! if (cn->cn_pri <= CN_DEAD) {
! mon_printf("cons: keyboard/screen probe failed\n");
! goto probe_failed;
! }
! break;
+ case EE_CONS_TTYA:
+ case EE_CONS_TTYB:
+ cn = &cons_zs;
+ /* Use minor to indicate A or B (major is unused). */
+ cn->cn_dev = makedev(0, (eeCons == EE_CONS_TTYA) ? 0 : 1);
+ (*cn->cn_probe)(cn);
+ if (cn->cn_pri <= CN_DEAD) {
+ mon_printf("cons: tty A or B probe failed\n");
+ goto probe_failed;
+ }
+ break;
+
+ default:
+ mon_printf("cons: unknown EEPROM console code 0x%x\n", eeCons);
+ /* fall through */
+ probe_failed:
+ cn = &cons_prom;
+ (*cn->cn_probe)(cn);
+ if (cn->cn_pri > CN_DEAD) {
+ mon_printf("cons: using PROM console\n");
+ } else {
+ mon_printf("cons: prom console probe failed\n");
+ cn = NULL;
+ }
+ break;
+
+ } /* switch eeCons */
+
/*
* No console, we can handle it (really??? XXX)
*/
! if (cn == NULL)
return;
+ cn_tab = cn;
+
/*
* Turn on console
*/
! cn_tty = cn->cn_tp; /* XXX - Why both before... */
! (*cn->cn_init)(cn);
! cn_tty = cn->cn_tp; /* XXX ... and after? -gwr */
}
cnopen(dev, flag, mode, p)
***************
*** 204,207 ****
--- 257,266 ----
if (c == '\n')
(*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
}
+ }
+
+ static int
+ cn_probe_dead(struct consdev *cn)
+ {
+ cn->cn_pri = CN_DEAD;
}
------------------------------------------------------------------------------