Skip to content

Commit

Permalink
Via a patch from jkunz, put back the ofbus and ofcons code for now, u…
Browse files Browse the repository at this point in the history
…ntil

we write a better way to handle the console.
  • Loading branch information
garbled committed Oct 17, 2007
1 parent 4bcdf2d commit af56fc9
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 29 deletions.
11 changes: 7 additions & 4 deletions sys/arch/ofppc/conf/GENERIC
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.97.16.3 2007/10/03 19:24:35 garbled Exp $
# $NetBSD: GENERIC,v 1.97.16.4 2007/10/17 17:23:57 garbled Exp $
#
# GENERIC machine description file
#
Expand All @@ -22,7 +22,7 @@ include "arch/ofppc/conf/std.ofppc"

options INCLUDE_CONFIG_FILE # embed config file in kernel binary

#ident "GENERIC-$Revision: 1.97.16.3 $"
#ident "GENERIC-$Revision: 1.97.16.4 $"

maxusers 32

Expand Down Expand Up @@ -166,8 +166,11 @@ config netbsd root on ? type ?
mainbus* at root

# Generic OpenFirmware bus support
#ofbus* at mainbus?
#ofbus* at ofbus?
ofbus* at mainbus?
ofbus* at ofbus?
# Generic OpenFirmware console support
ofcons* at ofbus?


# CPUs
cpu* at mainbus?
Expand Down
4 changes: 2 additions & 2 deletions sys/arch/ofppc/conf/files.ofppc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: files.ofppc,v 1.26.10.2 2007/06/21 18:49:37 garbled Exp $
# $NetBSD: files.ofppc,v 1.26.10.3 2007/10/17 17:23:58 garbled Exp $
#
# NetBSD/ofppc configuration info
#
Expand Down Expand Up @@ -76,7 +76,7 @@ include "dev/wscons/files.wscons"
include "dev/wsfb/files.wsfb"

define mainbus {}
device mainbus: mainbus
device mainbus: mainbus, ofbus
attach mainbus at root
file arch/ofppc/ofppc/mainbus.c mainbus

Expand Down
120 changes: 97 additions & 23 deletions sys/arch/ofppc/ofppc/machdep.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* $NetBSD: machdep.c,v 1.91.10.3 2007/10/03 19:27:41 garbled Exp $ */
/* $NetBSD: machdep.c,v 1.91.10.4 2007/10/17 17:23:58 garbled Exp $ */

/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Tim Rightnour
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
Expand All @@ -17,27 +15,24 @@
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.91.10.3 2007/10/03 19:27:41 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.91.10.4 2007/10/17 17:23:58 garbled Exp $");

#include <sys/param.h>
#include <sys/buf.h>
Expand All @@ -48,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.91.10.3 2007/10/03 19:27:41 garbled Ex
#include <uvm/uvm_extern.h>

#include <dev/ofw/openfirm.h>
#include <dev/cons.h>

#include <machine/autoconf.h>
#include <machine/pmap.h>
Expand All @@ -59,14 +55,19 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.91.10.3 2007/10/03 19:27:41 garbled Ex
#include <powerpc/oea/bat.h>
#include <powerpc/ofw_cons.h>


struct pmap ofw_pmap;
char bootpath[256];

void ofwppc_batinit(void);
void ofppc_bootstrap_console(void);

void
initppc(u_int startkernel, u_int endkernel, char *args)
{
/* Initialize the bootstrap console. */
ofppc_bootstrap_console();
printf( "\n\nHallo Welt!\n\n");
ofwoea_initppc(startkernel, endkernel, args);
map_isa_ioregs();
}
Expand All @@ -77,11 +78,13 @@ cpu_startup(void)
oea_startup(NULL);
}

/*
void
consinit(void)
{
ofwoea_consinit();
}
*/

void
dumpsys(void)
Expand Down Expand Up @@ -135,3 +138,74 @@ cpu_reboot(int howto, char *what)
*ap1 = 0;
ppc_boot(str);
}

/*
* XXX
* The following code is subject to die at a later date. This is the only
* remaining code in this file subject to the Tools GmbH copyright.
*/

void
consinit()
{

(*cn_tab->cn_probe)(cn_tab);
}

void ofcons_cnprobe(struct consdev *);
int ofppc_cngetc(dev_t);
void ofppc_cnputc(dev_t, int);

struct consdev ofppc_bootcons = {
ofcons_cnprobe, NULL, ofppc_cngetc, ofppc_cnputc, nullcnpollc, NULL,
NULL, NULL, makedev(0,0), 1,
};

int ofppc_stdin_ihandle, ofppc_stdout_ihandle;
int ofppc_stdin_phandle, ofppc_stdout_phandle;

void
ofppc_bootstrap_console(void)
{
int chosen;
char data[4];

chosen = OF_finddevice("/chosen");

if (OF_getprop(chosen, "stdin", data, sizeof(data)) != sizeof(int))
goto nocons;
ofppc_stdin_ihandle = of_decode_int(data);
ofppc_stdin_phandle = OF_instance_to_package(ofppc_stdin_ihandle);

if (OF_getprop(chosen, "stdout", data, sizeof(data)) != sizeof(int))
goto nocons;
ofppc_stdout_ihandle = of_decode_int(data);
ofppc_stdout_phandle = OF_instance_to_package(ofppc_stdout_ihandle);

cn_tab = &ofppc_bootcons;

nocons:
return;
}

int
ofppc_cngetc(dev_t dev)
{
u_char ch = '\0';
int l;

while ((l = OF_read(ofppc_stdin_ihandle, &ch, 1)) != 1)
if (l != -2 && l != 0)
return (-1);

return (ch);
}

void
ofppc_cnputc(dev_t dev, int c)
{
char ch = c;

OF_write(ofppc_stdout_ihandle, &ch, 1);
}

0 comments on commit af56fc9

Please sign in to comment.