Subject: Re: Qube2700, Restore-CD with custom Kernel & 2nd NIC
To: None <port-cobalt@NetBSD.org>
From: Dennis Chernoivanov <cdi@mawhrin.net>
List: port-cobalt
Date: 01/29/2004 07:25:37
--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


On Thu, Jan 29, 2004 at 12:06:19AM +0100, Axel Morhenn wrote:
> after installing the basic 1.6.1-distri i did an install of the whole
> /usr/src (to /usr/cvs/src) from cvs. after that i build the toolset for
> cross-compile. is it that what you mean with 'userland' ? sorry, long time

 I meant you may need to re-build and re-install the whole distribution,
all the programs which './build.sh -m cobalt release' builds.

> could u please tell me how to modify the kernel-source in that way u did
> with your testing-kernels @ netbsd.org to plott the booting-messages via lcd
> ?

 Attached. It was a hack to console.c, you need to comment out com0 device in
conf/GENERIC to make it work.

SY,
--cdi

--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="console.c"

/*	$NetBSD: console.c,v 1.1 2000/03/19 23:07:44 soren Exp $	*/

/*
 * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
 *
 * 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.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
 */


#include <sys/param.h>
#include <sys/user.h>
#include <sys/uio.h> 
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/tty.h>
#include <sys/termios.h>

#include <machine/conf.h>
#include <machine/bus.h>

#include <dev/cons.h>

#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>

#include "com.h"

cons_decl(null);

dev_type_cnprobe(comcnprobe);
dev_type_cninit(comcninit);

int	console_present = 0;	/* Do we have a console? */

static struct tty *nulltty;	/* No-op console TTY. */

static void kcomputc(int);
void kcomprint(const char *s);

/*
 * Configured console devices: COM and no-op.
 */
struct	consdev	constab[] = {
#if NCOM > 0
	{ comcnprobe, comcninit, },
#endif
	cons_init(null),
	{ 0 }
};

/*
 * COM console.
 */
#if NCOM > 0
#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */

void
comcnprobe(cn)
	struct consdev *cn;
{
	/*
	 * Linux code has a comment that serial console must be probed
	 * early, otherwise the value which allows to detect serial port
	 * could be overwritten. Okay, probe here and record the result
	 * for the future use.
	 */
	console_present = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x0020001c);
	cn->cn_pri = (console_present != 0) ? CN_NORMAL : CN_DEAD;
}

void
comcninit(cn)
	struct consdev *cn;
{
	comcnattach(0, 0x1c800000, 115200, COM_FREQ * 10, CONMODE);
}
#endif

/*
 * NULL (no-op) console.
 */
void
nullcnprobe(cn)
	struct consdev *cn;
{
	cn->cn_dev = NODEV;
	cn->cn_pri = CN_NULL;
}

void
nullcninit(cn)
	struct consdev *cn;
{
	if ((cn->cn_pri != CN_NULL) || (cn->cn_dev != NODEV))
		return;
	/*
	 * Allocate tty (mostly to have sane ioctl()).
	 */
	nulltty = ttymalloc();
	nulltty->t_dev = makedev(35, 0);

	tty_attach(nulltty);
	cn->cn_dev = nulltty->t_dev;
}

int
nullcngetc(dev)
	dev_t dev;
{
	for(;;);
	return (0);
}

void
nullcnputc(dev, c)
	dev_t dev;
	int c;
{
	kcomputc(c);
}

/*
 * NULL (no-op) device.
 */
int
nulldevopen(dev, flag, mode, p)
	dev_t dev;
	int flag, mode;
	struct proc *p;
{
	return (0);
}

int
nulldevclose(dev, flag, mode, p)
	dev_t dev;
	int flag, mode;
	struct proc *p;
{
	return (0);
}

int
nulldevread(dev, uio, flag)
	dev_t dev;
	struct uio *uio;
	int flag;
{
	for(;;);
	return (0);
}

int
nulldevwrite(dev, uio, flag)
	dev_t dev;
	struct uio *uio;
	int flag;
{
	int i;
	int error;

#define NULLCN_BUFSIZE	4096
	char buf[4096];
	int len = (uio->uio_resid > NULLCN_BUFSIZE) ? NULLCN_BUFSIZE
						    : uio->uio_resid;

	if ( (error = uiomove((void*)buf, len, uio)) != 0)
		return (error);

	for (i = 0; i < len; i++)
		kcomputc(buf[i]);

	return (0);
}

int
nulldevioctl(dev, cmd, data, flag, p)
	dev_t dev;
	u_long cmd;
	caddr_t data;
	int flag;
	struct proc *p;
{
	int error;

	error = (*nulltty->t_linesw->l_ioctl)(nulltty, cmd, data, flag, p);
	if (error != EPASSTHROUGH)
		return (error);

	error = ttioctl(nulltty, cmd, data, flag, p);
	if (error != EPASSTHROUGH)
		return (error);

	return (0);
}

int
nulldevpoll(dev, events, p)
	dev_t dev;
	int events;
	struct proc *p;
{
	return (ENXIO);
}

void
consinit()
{
	cninit();
}

void
kcomprint(const char *s)
{
	for (; *s; s++)
		kcomputc(*s);
}

#define LCD_HACK	1
/*#define COM_HACK	1*/
#if defined(COM_HACK)
struct NS16550
{
	volatile unsigned char rbr;  /* 0 */
	volatile unsigned char ier;  /* 1 */
	volatile unsigned char fcr;  /* 2 */
	volatile unsigned char lcr;  /* 3 */
	volatile unsigned char mcr;  /* 4 */
	volatile unsigned char lsr;  /* 5 */
	volatile unsigned char msr;  /* 6 */
	volatile unsigned char scr;  /* 7 */
};

#define thr rbr
#define iir fcr
#define dll rbr
#define dlm ier

#define LSR_DR   0x01  /* Data ready */
#define LSR_OE   0x02  /* Overrun */
#define LSR_PE   0x04  /* Parity error */
#define LSR_FE   0x08  /* Framing error */
#define LSR_BI   0x10  /* Break */
#define LSR_THRE 0x20  /* Xmit holding register empty */
#define LSR_TEMT 0x40  /* Xmitter empty */
#define LSR_ERR  0x80  /* Error */

static void
kcomputc(c)
	int c;
{
	struct NS16550 *com_port = (void*)0xbc800000;
	while ((com_port->lsr & LSR_THRE) == 0)
		;
	com_port->thr = c;
}
#elif defined(LCD_HACK)
#define LCD_INST	0xBF000000
#define LCD_DATA	0xBF000010

#define lcd_write(x)	(*(volatile u_int32_t *) LCD_DATA) = ((x) << 24)
#define lcd_inst(x)	(*(volatile u_int32_t *) LCD_INST) = ((x) << 24)
#define lcd_read()	((*(volatile u_int32_t *) LCD_DATA) >> 24)
#define led_set(x)	(*(volatile unsigned char *) LED_ADDR) = ((char)x)

void
kcomputc(c)
	int c;
{
	static int column;
	static int row;

redraw:
	if (row == 0) {
		if (column == 0)
			lcd_inst(0x80);

		if (column++ < 16)
			lcd_write(c);
		else {
			row = 1;
			column = 0;
		}
	}

	if (row == 1) {
		if (column == 0)
			lcd_inst(0xC0);
		if (column++ < 16)
			lcd_write(c);
		else {
			row = column = 0;
			goto redraw;
		}
	}

	delay(200);
}
#endif

--LZvS9be/3tNcYl/X--