From 580f912629e6c140177f2930cf99e0c393b051a4 Mon Sep 17 00:00:00 2001 From: Dale Rahn Date: Tue, 20 Aug 2002 02:50:44 +0000 Subject: Add a pseudo openfirmware console device for early debugging purposes and to allow UKC to work properly. ok miod@ --- sys/arch/macppc/include/powerpc.h | 3 +- sys/arch/macppc/macppc/machdep.c | 15 ++++---- sys/arch/macppc/macppc/ofw_machdep.c | 67 +++++++++++++++++++++++++++++++++++- sys/arch/macppc/macppc/ofw_machdep.h | 5 ++- 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/sys/arch/macppc/include/powerpc.h b/sys/arch/macppc/include/powerpc.h index 12deaff95c6..632d6fa07a7 100644 --- a/sys/arch/macppc/include/powerpc.h +++ b/sys/arch/macppc/include/powerpc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: powerpc.h,v 1.3 2002/03/14 03:15:55 millert Exp $ */ +/* $OpenBSD: powerpc.h,v 1.4 2002/08/20 02:50:43 drahn Exp $ */ /* $NetBSD: powerpc.h,v 1.1 1996/09/30 16:34:30 ws Exp $ */ /* @@ -76,7 +76,6 @@ struct firmware { #endif }; extern struct firmware *fw; -void ofwconprobe(void); int ppc_open_pci_bridge(void); void ppc_close_pci_bridge(int); void install_extint(void (*handler) (void)); diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c index e76cf0d1fa4..bf1dadcbe2a 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.37 2002/07/23 17:53:24 drahn Exp $ */ +/* $OpenBSD: machdep.c,v 1.38 2002/08/20 02:50:43 drahn Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -67,10 +67,6 @@ #include -#include - -#include - #include #include #include @@ -80,6 +76,11 @@ #include #include +#include + +#include +#include + #include "adb.h" #if NADB > 0 #include @@ -458,7 +459,7 @@ where = 3; /* * Now we can set up the console as mapping is enabled. */ - consinit(); + ofwconsinit(); /* while using openfirmware, run userconfig */ if (boothowto & RB_CONFIG) { #ifdef BOOT_CONFIG @@ -470,8 +471,8 @@ where = 3; /* * Replace with real console. */ - cninit(); ofwconprobe(); + consinit(); #if NIPKDB > 0 /* diff --git a/sys/arch/macppc/macppc/ofw_machdep.c b/sys/arch/macppc/macppc/ofw_machdep.c index 8be7694105b..02a61092e67 100644 --- a/sys/arch/macppc/macppc/ofw_machdep.c +++ b/sys/arch/macppc/macppc/ofw_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_machdep.c,v 1.11 2002/06/09 04:13:13 drahn Exp $ */ +/* $OpenBSD: ofw_machdep.c,v 1.12 2002/08/20 02:50:43 drahn Exp $ */ /* $NetBSD: ofw_machdep.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */ /* @@ -619,3 +619,68 @@ of_setbrightness(brightness) /* XXX this routine should also save the brightness settings in the nvram */ #endif } + +#include + +cons_decl(ofw); + +/* + * Console support functions + */ +void +ofwcnprobe(cd) + struct consdev *cd; +{ + cd->cn_pri = CN_DEAD; +} + +void +ofwcninit(cd) + struct consdev *cd; +{ +} +void +ofwcnputc(dev, c) + dev_t dev; + int c; +{ + char ch = c; + + OF_write(OF_stdout, &ch, 1); +} +int +ofwcngetc(dev) + dev_t dev; +{ + unsigned char ch = '\0'; + int l; + + while ((l = OF_read(OF_stdin, &ch, 1)) != 1) + if (l != -2 && l != 0) + return -1; + return ch; +} + +void +ofwcnpollc(dev, on) + dev_t dev; + int on; +{ +} + +struct consdev consdev_ofw = { + ofwcnprobe, + ofwcninit, + ofwcngetc, + ofwcnputc, + ofwcnpollc, + NULL, +}; + +void +ofwconsinit() +{ + struct consdev *cp; + cp = &consdev_ofw; + cn_tab = cp; +} diff --git a/sys/arch/macppc/macppc/ofw_machdep.h b/sys/arch/macppc/macppc/ofw_machdep.h index 2d1d202b435..30c789efabe 100644 --- a/sys/arch/macppc/macppc/ofw_machdep.h +++ b/sys/arch/macppc/macppc/ofw_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_machdep.h,v 1.1 2002/05/22 21:00:00 miod Exp $ */ +/* $OpenBSD: ofw_machdep.h,v 1.2 2002/08/20 02:50:43 drahn Exp $ */ /* * Copyright (c) 2002, Miodrag Vallat. @@ -40,6 +40,9 @@ extern int cons_display_ofh; extern u_int32_t cons_addr; extern int cons_backlight_available; +void ofwconprobe(void); +void ofwconsinit(void); + /* * For some reason, setting the brightness under 0x29 from OF switches the * backlight off, and it won't be switched on again until you set the -- cgit v1.2.3