Subject: Re: XalphaNetBSD no go -> unusable console
To: None <kpneal@pobox.com>
From: R. C. Dowdeswell <elric@mabelode.imrryr.org>
List: port-alpha
Date: 11/02/2001 13:13:30
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <24062.1004724787.1@mabelode.imrryr.org>

On 712498376 seconds since the Beginning of the UNIX epoch
kpneal@pobox.com wrote:
>

>I have no XF86Config file. 

Yep, XalphaNetBSD requires no config:  just a keyboard, a mouse and
a TGA.  :-)

>A second later the screen switches from white on black text to
>black text on white background (like when Amiga UNIX finishes booting).
>That's it, the console is now unusable. Logging in remotely shows
>that there is no X server running. Rebooting works fine.

Hmmm, yes.  The X server is not resetting the colormap back to its
original state one exit.  I attach a program that will manipulate
the colormap.  You can change it to whatever you want.  :-)

>Am I stuck until I can get a mouse working with this box? Or is there
>some other reason I'm losing my console. And does anyone have a
>working XF86Config file I can crib? (Or is that needed?)

Probably you are.  You could hack the X server to change the lack
of a mouse into a warning rather than an error to get X working,
though.  Perhaps we should do that.

 == Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/  ==
 == The Unofficial NetBSD Web Pages        http://www.Imrryr.ORG/NetBSD/  ==
 == The NetBSD Project                            http://www.NetBSD.ORG/  ==
 == Ponte, Inc.                                    http://www.ponte.com/  ==

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <24062.1004724787.2@mabelode.imrryr.org>

/* */

/*-
 * Copyright (c) 2000 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Roland C. Dowdeswell.
 *
 * 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.
 * 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 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.
 */

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/ioctl.h>
#include <sys/types.h>
#include <dev/wscons/wsconsio.h>

int	setcmap(int, u_char, u_char, u_char, u_char);
void	usage();

char *prognam = NULL;

int
main(int argc, char **argv)
{
	extern	int optind;
	extern	char *optarg;
	int	ch;
	int	fd;
	int	xflag = 0;
	int	ret;
	char	*filename = NULL;
	char	*tmp1;
	char	*tmp2;
	u_char	idx, rval, gval, bval;

	prognam = strdup(*argv);

	while ((ch = getopt(argc, argv, "f:x")) != -1)
		switch (ch) {
		case 'f':
			filename = strdup(optarg);
			break;
		case 'x':
			xflag = 1;
			break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (filename == NULL)
		filename = strdup("/dev/ttyE0");

	if (argc != 2)
		usage();

	idx = strtol(argv[0], NULL, xflag?16:0);

	tmp1 = argv[1];
	rval = (u_char)strtol(tmp1, &tmp2, xflag?16:0);
	if (!tmp2 || *tmp2 != ':')
		usage();

	tmp1 = tmp2 + 1;
	gval = strtol(tmp1, &tmp2, xflag?16:0);
	if (!tmp2 || *tmp2 != ':')
		usage();

	tmp1 = tmp2 + 1;
	bval = strtol(tmp1, &tmp2, xflag?16:0);

	fd = open(filename, O_RDWR, 0);
	if (fd == -1) {
		perror("open");
		fprintf(stderr, "fbopen(\"%s\") failed\n", filename);
		exit(-1);
	}

	ret = setcmap(fd, idx, rval, gval, bval);
	if (ret && !xflag) {
		fprintf(stderr, "setcmap(%d, %d, %d, %d, %d) failed\n",
		    fd, idx, rval, gval, bval);
		exit(-1);
	} else if (ret) {
		fprintf(stderr, "setcmap(%d, 0x%x, 0x%x, 0x%x, 0x%x) failed\n",
		    fd, idx, rval, gval, bval);
		exit(-1);
	}
	return 0;
}

int
setcmap(int fd, u_char idx, u_char rval, u_char gval, u_char bval)
{
	struct	wsdisplay_cmap cmap;
	int	ret;

	cmap.index = idx;
	cmap.count = 1;
	cmap.red = &rval;
	cmap.green = &gval;
	cmap.blue = &bval;

	ret = ioctl(fd, WSDISPLAYIO_PUTCMAP, &cmap);
	if (ret == -1) {
		perror("ioctl");
		return -1;
	}
}

void
usage()
{
	fprintf(stderr, "usage:\n%s [-x] entry rval:gval:bval\n", prognam);
	exit(-1);
}

------- =_aaaaaaaaaa0--