Subject: cn_tab and consdev redirection from serial terminal to Graphics Card (69030)
To: None <tech-kern@NetBSD.org>
From: anand lalgondar <anandlalgondar@hotmail.com>
List: tech-kern
Date: 11/11/2003 20:00:44
This is a multi-part message in MIME format.

------=_NextPart_000_3b9c_193f_765b
Content-Type: text/plain; format=flowed

Topic: cn_tab and consdev redirection from serial terminal to Graphics Card 
(69030)

List for files:
1. /usr/src/sys/dev/ic/69030.h
2. /usr/src/sys/dev/ic/ctfb.c
3. /usr/src/sys/dev/ic/ctfbvar.h
4. /usr/src/sys/dev/ic/ctfbreg.h
5. /usr/src/sys/dev/ic/ctfb_subr.c
6. /usr/src/sys/dev/pci/ctfb_pci.c

A reference to /dev/ic/igsfb*.* files was made and the driver is completely 
written in similar terms. For reference attached are ctfb.c and ctfb_pci.c 
file as I have got some doubt in these.

The following entries were made in the files listed below to support the 
above driver:

1. /usr/src/sys/conf/files
-----------------------------------------------------------
#  Chips and Technologies 69030 framebuffers
#
device  ctfb: wsemuldisplaydev, wsrasteremulops, rasops8
file    dev/ic/ctfb.c                  ctfb
file    dev/ic/ctfb_subr.c             ctfb
-----------------------------------------------------------

2. /usr/src/sys/dev/pic/files.pci
-----------------------------------------------------------
# Chips and Technologies 69030 framebuffers
# device declaration in sys/conf/files
attach  ctfb at pci with ctfb_pci
file    dev/pci/ctfb_pci.c             ctfb_pci
-----------------------------------------------------------

3. /usr/src/sys/arch/evbmips/conf/files.rbtx4927
-----------------------------------------------------------
#
# Raster Console / WS Console
#
include "dev/rasops/files.rasops"	# Not sure about next comment
include "dev/wscons/files.wscons"       # includes rcons as well
include "dev/wsfont/files.wsfont"       # both rcons and wscons need it
-----------------------------------------------------------

4. /usr/src/sys/arch/evbmips/conf/MYKERNEL
-----------------------------------------------------------
# This entry was taken from /usr/src/sys/arch/sparc/conf/krups
# wscons options
#
# builtin terminal emulations
#options        WSEMUL_SUN              # sun terminal emulation
options         WSEMUL_VT100            # VT100 / VT220 emulation
options         WSEMUL_DEFAULT="\"vt100\""
# different kernel output - see dev/wscons/wsdisplayvar.h
options         WS_KERNEL_FG=WSCOL_GREEN
#options        WS_KERNEL_BG=WSCOL_BLACK
options         WS_KERNEL_COLATTR=WSATTR_HILIT
# compatibility to other console drivers
options         WSDISPLAY_COMPAT_PCVT           # emulate some ioctls
options         WSDISPLAY_COMPAT_SYSCONS        # emulate some ioctls
options         WSDISPLAY_COMPAT_USL            # VT handling
options         WSDISPLAY_COMPAT_RAWKBD         # can get raw scancodes

options         FONT_GALLANT12x22               # PROM font look-alike
-----------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>AND<<<<<<<<<<<<<<<<<<<<<<<<<<
ctfb*           at pci? dev ? function ?        # Chips and Technologies 
69030 Driver
wsdisplay*      at ctfb? console ?
-----------------------------------------------------------

ONLY the following entries are present and I assume that this will insert 
the driver into the kernel.
I am not aware if a major number should be allocated to this device in 
majors.evbmips file. If so how will that be useful?

All most all the files are written by copying igsfb*.* and replacing "igs" 
with "ct" with modification in chipset level. Please let me know if there 
are any licencing issues related to this copying.

But before discussing anything further --- the hardware is initialized to 
1024x768 8bpp. (This is being verified by displaying a character on the 
whole screen by storing the font map in a array of [16][8]). The cursor part 
is not initialized at all. Is it neccesary?



At present the consdev is initialized as:
-----------------------------------------------------------
/*
* Routines to use a txsio as a console.
*/
static struct consdev txsio_cons = {
	NULL, NULL, txsio_cngetc, txsio_cnputc, txsio_cnpollc, NULL, NODEV,
	     CN_NORMAL
};
-----------------------------------------------------------

I got the following dmesg output from the serial terminal w.r.t recognition 
of the C&T 69030HiQVideo Card and some debug messages w.r.t wsdisplay and 
emulation type.
-----------------------------------------------------------
.
.
.
ctfb0 at pci0 dev 18 function 0
PCI_COMMAND_STATUS_REG = 2a001c3
PCI_COMMAND_STATUS_REG = 2a001c3
: Chips and Technologies 69030 (rev. 0x61)
Configured memory space: bus_addr_t = 8000000, bus_size_t = 1000000, FLAG = 
0
sc->sc_memaddr = 0x08000000, iobase = 0x08400000
I/O registers mapped a8400000
        Vendor ID = 102c        Device ID = c30
Video memory succesfully mapped to temph = a8000000
Video memory succesfully zeroed out and un-mapped from temph = a8000000
In ctfb_hw_setup()
SOC: Inside wsdisplay_cnattach()
Terminal Emulation Name = vt100
SOC: In wsemul_vt100_cnattach()
SOC: Out of wsemul_vt100_cnattach()
SOC: In wsdisplay_cnattach(), before initializing cntab
-----------------------------------------------------------

After this message I assume that the ouput terminal will be redirected to 
frambuffer, but it gets stuck. I don't have a consinit function call to 
initialize the "consdev", it is doen in the "txsio serial driver". Please 
take a look at the "ctfb_pci.c" and "ctfb.c" for more information.

One more question that pops up is how does the terminal emulation module 
know to what address (framebuffer address - active display area address) to 
write the ouput data since it is not passed in any of the function call in 
the "ctfb.c" and "ctfb_pci.c files".

I am looking for terminal emulation module or a function that will accept 
the following arguments:
	1. frame buffer starting address (physical/virtual)
	2. vertical resolution
	3. horizontal resolution
	4. bits per pixel
	5. virtual vertical resolution for page swapping
	6. virtual horizontal resoltion for page swapping
If this is already present please redirect me to that point.

I would like redirect the terminal ouput from serial to the frambuffer, and 
keep the terminal input as same.

I would like to convey regards to the following people for providing basic 
clarifications and others also:
	Matthew Orgass
	Nathan J. Williams
	Izumi Tsutsui San
	Valeriy E. Ushakov
	Toru Nishimura San
	.
	Tech-support from asiliant (Ken)
	.

Valeriy E. Ushakov provided information the hardware initialization of the 
Grahpics card as it is doen in igsfb*.* driver
Toru Nishimura San provided exact information on cn_tab in previous mails.

Thank you.

- Anand

PS: Please let me know if anybody requires the remaining files for 
clarification. FONT_GALLANT12x22 - where can I find this module.

_________________________________________________________________
Make fun prints Click here to order. http://www.kodakexpress.co.in  Delivery 
anywhere in India.

------=_NextPart_000_3b9c_193f_765b
Content-Type: text/plain; name="ctfb.c"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="ctfb.c"

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/ioctl.h>
#include <sys/buf.h>
#include <uvm/uvm_extern.h>

#include <machine/bus.h>

#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
#include <dev/wsfont/wsfont.h>
#include <dev/wscons/wsconsio.h>

#include <dev/ic/ctfbreg.h>
#include <dev/ic/ctfbvar.h>


/*
* wsscreen
*/

/* filled from rasops_info in ctfb_common_init */
static struct wsscreen_descr ctfb_stdscreen = {
	"std",			/* name */
	0, 0,			/* ncols, nrows */
	NULL,			/* textops */
	0, 0,			/* fontwidth, fontheight */
	0				/* capabilities */
};

static const struct wsscreen_descr *_ctfb_scrlist[] = {
	&ctfb_stdscreen,
};

static const struct wsscreen_list ctfb_screenlist = {
	sizeof(_ctfb_scrlist) / sizeof(struct wsscreen_descr *),
	_ctfb_scrlist
};

/*
* wsdisplay_accessops
*/

static int	ctfb_ioctl(void *, u_long, caddr_t, int, struct proc *);
static paddr_t	ctfb_mmap(void *, off_t, int);

static int	ctfb_alloc_screen(void *, const struct wsscreen_descr *,
				   void **, int *, int *, long *);
static void	ctfb_free_screen(void *, void *);
static int	ctfb_show_screen(void *, void *, int,
				  void (*) (void *, int, int), void *);

static const struct wsdisplay_accessops ctfb_accessops = {
	ctfb_ioctl,
	ctfb_mmap,
	ctfb_alloc_screen,
	ctfb_free_screen,
	ctfb_show_screen,
	NULL /* load_font */
};

/*
* internal functions
*/
static void	ctfb_common_init(struct ctfb_softc *);
static void	ctfb_update_cmap(struct ctfb_softc *sc, u_int, u_int);

/*
* Finish off the attach.
*/
void
ctfb_common_attach(sc, isconsole)
	struct ctfb_softc *sc;
	int isconsole;
{
	bus_addr_t fbaddr;
	bus_addr_t craddr;
	u_int32_t croffset;
	char *bswap_msg;
	struct rasops_info *ri;
	struct wsemuldisplaydev_attach_args waa;

	/* Frame buffer size  = 4MB */
	sc->sc_vmemsz = 4 << 20;

	/*
	 * Don't map in all N megs, just the amount we need for wsscreen
	 */
	fbaddr = sc->sc_memaddr;
	sc->sc_fbsz = 1024 * 768; /* XXX: 8bpp specific */
	if (bus_space_map(sc->sc_memt, fbaddr, sc->sc_fbsz,
			  sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
			  &sc->sc_fbh) != 0)
	{
		/*
		 * If framebuffer could not be mapped then we cannot continue.
		 * Better to unmap the mapped registers. This will be doen later
		 * bus_space_unmap(sc->sc_iot, sc->sc_ioh, CT_REG_SIZE);
		 */
		printf("unable to map framebuffer\n");
		return;
	}

	/*
	 * 1Kb for cursor data at the very end of video memory
	 */
	croffset = sc->sc_vmemsz - CT_CURSOR_DATA_SIZE;
	craddr = fbaddr + croffset;
	if (bus_space_map(sc->sc_memt, craddr, CT_CURSOR_DATA_SIZE,
			  sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
			  &sc->sc_crh) != 0)
	{
		/*
		 * If framebuffer could not be mapped then we cannot continue.
		 * Better to unmap the mapped registers. This will be doen later
		 * bus_space_unmap(sc->sc_iot, sc->sc_ioh, CT_REG_SIZE);
		 * bus_space_unmap(sc->sc_memt, sc->sc_fbh, sc->sc_fbsz);
		 */
		printf("unable to map cursor sprite region\n");
		return;
	}

/* Cursor Related Issue */
#if 0
	/*
	 * Tell device where cursor sprite data are located in linear
	 * space (it takes data offset in 1k units).
	 */
	croffset >>= 10;
	igs_ext_write(sc->sc_iot, sc->sc_ioh,
		      IGS_EXT_SPRITE_DATA_LO, croffset & 0xff);
	igs_ext_write(sc->sc_iot, sc->sc_ioh,
		      IGS_EXT_SPRITE_DATA_HI, (croffset >> 8) & 0xf);

	memset(&sc->sc_cursor, 0, sizeof(struct igs_hwcursor));
	memset(bus_space_vaddr(sc->sc_memt, sc->sc_crh),
	       0xaa, IGS_CURSOR_DATA_SIZE); /* transparent */

	curctl = igs_ext_read(sc->sc_iot, sc->sc_ioh, IGS_EXT_SPRITE_CTL);
	curctl |= IGS_EXT_SPRITE_64x64;
	curctl &= ~IGS_EXT_SPRITE_VISIBLE;
	igs_ext_write(sc->sc_iot, sc->sc_ioh, IGS_EXT_SPRITE_CTL, curctl);

	/* bit expanders for cursor sprite data */
	igsfb_init_bit_tables(sc);
#endif

	/* alloc and cross-link raster ops */
	ri = malloc(sizeof(struct rasops_info), M_DEVBUF, M_NOWAIT | M_ZERO);
	if (ri == NULL)
		panic("unable to allocate rasops");
	ri->ri_hw = sc;
	sc->sc_ri = ri;

	ctfb_common_init(sc);

	/*
	 * XXX: console attachment needs rethinking
	 */
	if (isconsole) {
		long defattr;
		(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
		wsdisplay_cnattach(&ctfb_stdscreen, ri, 0, 0, defattr);
	}

	printf("%s: %dMB%s, %dx%d, %dbpp\n",
	       sc->sc_dev.dv_xname,
	       (u_int32_t)(sc->sc_vmemsz >> 20),
	       bswap_msg,
	       ri->ri_width, ri->ri_height, ri->ri_depth);

	/* attach wsdisplay */
	waa.console = isconsole;
	waa.scrdata = &ctfb_screenlist;
	waa.accessops = &ctfb_accessops;
	waa.accesscookie = sc;

	config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
}

/*
* I/O and memory are mapped, video enabled, structures allocated.
*/
static void
ctfb_common_init(sc)
	struct ctfb_softc *sc;
{
	// bus_space_tag_t iot = sc->sc_iot;
// 	bus_space_handle_t ioh = sc->sc_ioh;
	struct rasops_info *ri = sc->sc_ri;
	int wsfcookie;
	const u_int8_t *p;
	int i;

	sc->sc_blanked = 0;

	ri->ri_flg = RI_CENTER | RI_CLEAR;

	/* XXX: deduce these from chip registers */
	ri->ri_depth = 8;
	ri->ri_width = 1024;
	ri->ri_height = 768;

	ri->ri_stride = 1024;
	ri->ri_bits = (u_char *)sc->sc_fbh;

	/*
	 * Initialize wsfont related stuff.
	 */
	wsfont_init();

	/* prefer gallant that is identical to the one the prom uses */
	wsfcookie = wsfont_find("Gallant", 12, 22, 0,
				WSDISPLAY_FONTORDER_L2R,
				WSDISPLAY_FONTORDER_L2R);
	if (wsfcookie <= 0) {
#ifdef DIAGNOSTIC
		printf("%s: unable to find font Gallant 12x22\n",
		       sc->sc_dev.dv_xname);
#endif
		/* any font at all? */
		wsfcookie = wsfont_find(NULL, 0, 0, 0,
					WSDISPLAY_FONTORDER_L2R,
					WSDISPLAY_FONTORDER_L2R);
	}

	if (wsfcookie <= 0) {
		printf("%s: unable to find any fonts\n", sc->sc_dev.dv_xname);
		return;
	}

	if (wsfont_lock(wsfcookie, &ri->ri_font) != 0) {
		printf("%s: unable to lock font\n", sc->sc_dev.dv_xname);
		return;
	}
	ri->ri_wsfcookie = wsfcookie;


	/*
	 * Initialize colormap related stuff.
	 */

	/* ANSI color map */
	p = rasops_cmap;
	for (i = 0; i < CT_CMAP_SIZE; ++i, p += 3) { /* software copy */
		sc->sc_cmap.r[i] = p[0];
		sc->sc_cmap.g[i] = p[1];
		sc->sc_cmap.b[i] = p[2];
	}
	ctfb_update_cmap(sc, 0, CT_CMAP_SIZE);

	/* Need to figure out what it does */
#if 0
	/* set overscan color r/g/b (XXX: use defattr's rgb?) */
	igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_RED,   0);
	igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_GREEN, 0);
	igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_BLUE,  0);
#endif

	/* TODO: compute term size based on font dimensions? */
	rasops_init(ri, 34, 80);

	ctfb_stdscreen.nrows = ri->ri_rows;
	ctfb_stdscreen.ncols = ri->ri_cols;
	ctfb_stdscreen.textops = &ri->ri_ops;
	ctfb_stdscreen.capabilities = ri->ri_caps;
}

/*
* wsdisplay_accessops: ioctl()
*/
static int
ctfb_ioctl(v, cmd, data, flag, p)
	void *v;
	u_long cmd;
	caddr_t data;
	int flag;
	struct proc *p;
{

	return (EPASSTHROUGH);
}

/*
* wsdisplay_accessops: mmap()
*   XXX: allow mmapping i/o mapped i/o regs if INSECURE???
*/
static paddr_t
ctfb_mmap(v, offset, prot)
	void *v;
	off_t offset;
	int prot;
{
	struct ctfb_softc *sc = v;

	if (offset >= sc->sc_memsz || offset < 0)
		return (-1);

	return (bus_space_mmap(sc->sc_memt, sc->sc_memaddr, offset, prot,
			       sc->sc_memflags | BUS_SPACE_MAP_LINEAR));
}

/*
* Propagate specified part of the software cmap copy to device.
*/
static void
ctfb_update_cmap(sc, index, count)
	struct ctfb_softc *sc;
	u_int index, count;
{
	bus_space_tag_t t;
	bus_space_handle_t h;
	u_int last, i;

	if (index >= CT_CMAP_SIZE)
		return;

	last = index + count;
	if (last > CT_CMAP_SIZE)
		last = CT_CMAP_SIZE;

	t = sc->sc_iot;
	h = sc->sc_ioh;

	/* start palette writing, index is autoincremented by hardware */
	bus_space_write_1(t, h, DAC_WRITE_INDEX, index);

	for (i = index; i < last; ++i) {
		bus_space_write_1(t, h, DAC_DATA_REG, sc->sc_cmap.r[i]);
		bus_space_write_1(t, h, DAC_DATA_REG, sc->sc_cmap.g[i]);
		bus_space_write_1(t, h, DAC_DATA_REG, sc->sc_cmap.b[i]);
	}
}

/*
* wsdisplay_accessops: alloc_screen()
*/
static int
ctfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
	void *v;
	const struct wsscreen_descr *type;
	void **cookiep;
	int *curxp, *curyp;
	long *attrp;
{

	/* TODO */
	return (ENOMEM);
}


/*
* wsdisplay_accessops: free_screen()
*/
static void
ctfb_free_screen(v, cookie)
	void *v;
	void *cookie;
{

	/* TODO */
	return;
}


/*
* wsdisplay_accessops: show_screen()
*/
static int
ctfb_show_screen(v, cookie, waitok, cb, cbarg)
	void *v;
	void *cookie;
	int waitok;
	void (*cb)(void *, int, int);
	void *cbarg;
{

	return (0);
}



------=_NextPart_000_3b9c_193f_765b
Content-Type: text/plain; name="ctfb_pci.c"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="ctfb_pci.c"

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/buf.h>

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

#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcidevs.h>

#include <dev/wscons/wsconsio.h>
#include <dev/ic/ctfbreg.h>
#include <dev/ic/ctfbvar.h>

#define CT_DEBUG

#ifdef CT_DEBUG
#define DPRINTF(x)	if (CTdebug) printf x
#define DPRINTFN(n,x)	if (CTdebug>(n)) printf x
int	CTdebug = 0;
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
#endif

static int	ctfb_pci_match(struct device *, struct cfdata *, void *);
static void	ctfb_pci_attach(struct device *, struct device *, void *);

CFATTACH_DECL(ctfb_pci, sizeof(struct ctfb_softc),
    ctfb_pci_match, ctfb_pci_attach, NULL, NULL);

static int
ctfb_pci_match(parent, match, aux)
	struct device *parent;
	struct cfdata *match;
	void *aux;
{
	struct pci_attach_args *pa = aux;

	/* PCI_VENDOR_CHIPS = 0x102c = Chips and Technologies */
	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_CHIPS)
		return (0);

	/* PCI_PRODUCT_CHIPS_69030 = 0x0c30 = 69030 */
	if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CHIPS_69030)
		return (1);

	return (0);
}

/*
* Note, that the chip may still be not enabled (e.g. RBTX4927 PROM
* doesn't bother to init the chip if PROM output goes to serial).
*/
static void
ctfb_pci_attach(parent, self, aux)
	struct device *parent, *self;
	void *aux;
{
	struct ctfb_softc *sc = (struct ctfb_softc *)self;
	struct pci_attach_args *pa = aux;
	pci_chipset_tag_t pc = pa->pa_pc;
	pcitag_t tag = pa->pa_tag;
	pcireg_t reg;

	bus_addr_t iobase;
	int ioflags;
	char devinfo[256];

	int isconsole;

	/*
	 * The video chipset must be enabled before any registers can be loaded.
	 * This is done by setting by setting PCI04[1:0] = 11 for PCI busses.
	 */
	reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
	printf("\nPCI_COMMAND_STATUS_REG = %x\n", reg);
	pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, 
reg|PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE);
	printf("PCI_COMMAND_STATUS_REG = %x\n", reg);

	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
	printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));

	/*
	 * Configure memory space first since for 69030 we use
	 * memory-mapped i/o access.  Note that we are NOT mapping any
	 * of it yet.  (XXX: search for memory BAR?)
	 */
	sc->sc_memt = pa->pa_memt;
	if (pci_mapreg_info(pa->pa_pc, pa->pa_tag,
		PCI_MAPREG_START, PCI_MAPREG_TYPE_MEM,
		&sc->sc_memaddr, &sc->sc_memsz, &sc->sc_memflags) != 0)
	{
		printf("unable to configure memory space\n");
		return;
	}
	else
		printf("Configured memory space: bus_addr_t = %x, bus_size_t = %x, FLAG = 
%x\n",
				(unsigned int)sc->sc_memaddr, (unsigned int)sc->sc_memsz, (unsigned 
int)sc->sc_memflags);

	/*
	 * Configure I/O space.  On 69030 use MMIO.
	 * At present map for pipeline-A i.e, 0x400000
	 */
	sc->sc_iot = sc->sc_memt;
	iobase = CT_PIPEA_MMIO_SELECT | sc->sc_memaddr;
	ioflags = sc->sc_memflags;
	printf("sc->sc_memaddr = 0x%08x, iobase = 0x%08x\n",
	       (u_int32_t)sc->sc_memaddr,
	       (u_int32_t)iobase);

	/*
	 * Map I/O registers.  This is done in bus glue, not in common
	 * code because on e.g. ISA bus we'd need to access registers
	 * to obtain/program linear memory location.
	 */
	if (bus_space_map(sc->sc_iot,
			  iobase, CT_REG_SIZE, ioflags,
			  &sc->sc_ioh) != 0)
	{
		printf("unable to map I/O registers\n");
		return;
	}
	else
		printf("I/O registers mapped %x\n", (unsigned int)sc->sc_ioh);

	ctfb_hw_setup(sc);

	isconsole = 1;
	ctfb_common_attach(sc, isconsole);
}


------=_NextPart_000_3b9c_193f_765b
Content-Type: text/plain; name="mail1.txt"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="mail1.txt"

Topic: cn_tab and consdev redirection from serial terminal to Graphics Card 
(69030)

List for files:
1. /usr/src/sys/dev/ic/69030.h
2. /usr/src/sys/dev/ic/ctfb.c
3. /usr/src/sys/dev/ic/ctfbvar.h
4. /usr/src/sys/dev/ic/ctfbreg.h
5. /usr/src/sys/dev/ic/ctfb_subr.c
6. /usr/src/sys/dev/pci/ctfb_pci.c

A reference to /dev/ic/igsfb*.* files was made and the driver is completely 
written in similar terms. For reference attached are ctfb.c and ctfb_pci.c 
file as I have got some doubt in these.

The following entries were made in the files listed below to support the 
above driver:

1. /usr/src/sys/conf/files
-----------------------------------------------------------
#  Chips and Technologies 69030 framebuffers
#
device  ctfb: wsemuldisplaydev, wsrasteremulops, rasops8
file    dev/ic/ctfb.c                  ctfb
file    dev/ic/ctfb_subr.c             ctfb
-----------------------------------------------------------

2. /usr/src/sys/dev/pic/files.pci
-----------------------------------------------------------
# Chips and Technologies 69030 framebuffers
# device declaration in sys/conf/files
attach  ctfb at pci with ctfb_pci
file    dev/pci/ctfb_pci.c             ctfb_pci
-----------------------------------------------------------

3. /usr/src/sys/arch/evbmips/conf/files.rbtx4927
-----------------------------------------------------------
#
# Raster Console / WS Console
#
include "dev/rasops/files.rasops"	# Not sure about next comment
include "dev/wscons/files.wscons"       # includes rcons as well
include "dev/wsfont/files.wsfont"       # both rcons and wscons need it
-----------------------------------------------------------

4. /usr/src/sys/arch/evbmips/conf/MYKERNEL
-----------------------------------------------------------
# This entry was taken from /usr/src/sys/arch/sparc/conf/krups
# wscons options
#
# builtin terminal emulations
#options        WSEMUL_SUN              # sun terminal emulation
options         WSEMUL_VT100            # VT100 / VT220 emulation
options         WSEMUL_DEFAULT="\"vt100\""
# different kernel output - see dev/wscons/wsdisplayvar.h
options         WS_KERNEL_FG=WSCOL_GREEN
#options        WS_KERNEL_BG=WSCOL_BLACK
options         WS_KERNEL_COLATTR=WSATTR_HILIT
# compatibility to other console drivers
options         WSDISPLAY_COMPAT_PCVT           # emulate some ioctls
options         WSDISPLAY_COMPAT_SYSCONS        # emulate some ioctls
options         WSDISPLAY_COMPAT_USL            # VT handling
options         WSDISPLAY_COMPAT_RAWKBD         # can get raw scancodes

options         FONT_GALLANT12x22               # PROM font look-alike
-----------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>AND<<<<<<<<<<<<<<<<<<<<<<<<<<
ctfb*           at pci? dev ? function ?        # Chips and Technologies 
69030 Driver
wsdisplay*      at ctfb? console ?
-----------------------------------------------------------

ONLY the following entries are present and I assume that this will insert 
the driver into the kernel.
I am not aware if a major number should be allocated to this device in 
majors.evbmips file. If so how will that be useful?

All most all the files are written by copying igsfb*.* and replacing "igs" 
with "ct" with modification in chipset level. Please let me know if there 
are any licencing issues related to this copying.

But before discussing anything further --- the hardware is initialized to 
1024x768 8bpp. (This is being verified by displaying a character on the 
whole screen by storing the font map in a array of [16][8]). The cursor part 
is not initialized at all. Is it neccesary?



At present the consdev is initialized as:
-----------------------------------------------------------
/*
* Routines to use a txsio as a console.
*/
static struct consdev txsio_cons = {
	NULL, NULL, txsio_cngetc, txsio_cnputc, txsio_cnpollc, NULL, NODEV,
	     CN_NORMAL
};
-----------------------------------------------------------

I got the following dmesg output from the serial terminal w.r.t recognition 
of the C&T 69030HiQVideo Card and some debug messages w.r.t wsdisplay and 
emulation type.
-----------------------------------------------------------
.
.
.
ctfb0 at pci0 dev 18 function 0
PCI_COMMAND_STATUS_REG = 2a001c3
PCI_COMMAND_STATUS_REG = 2a001c3
: Chips and Technologies 69030 (rev. 0x61)
Configured memory space: bus_addr_t = 8000000, bus_size_t = 1000000, FLAG = 
0
sc->sc_memaddr = 0x08000000, iobase = 0x08400000
I/O registers mapped a8400000
        Vendor ID = 102c        Device ID = c30
Video memory succesfully mapped to temph = a8000000
Video memory succesfully zeroed out and un-mapped from temph = a8000000
In ctfb_hw_setup()
SOC: Inside wsdisplay_cnattach()
Terminal Emulation Name = vt100
SOC: In wsemul_vt100_cnattach()
SOC: Out of wsemul_vt100_cnattach()
SOC: In wsdisplay_cnattach(), before initializing cntab
-----------------------------------------------------------

After this message I assume that the ouput terminal will be redirected to 
frambuffer, but it gets stuck. I don't have a consinit function call to 
initialize the "consdev", it is doen in the "txsio serial driver". Please 
take a look at the "ctfb_pci.c" and "ctfb.c" for more information.

One more question that pops up is how does the terminal emulation module 
know to what address (framebuffer address - active display area address) to 
write the ouput data since it is not passed in any of the function call in 
the "ctfb.c" and "ctfb_pci.c files".

I am looking for terminal emulation module or a function that will accept 
the following arguments:
	1. frame buffer starting address (physical/virtual)
	2. vertical resolution
	3. horizontal resolution
	4. bits per pixel
	5. virtual vertical resolution for page swapping
	6. virtual horizontal resoltion for page swapping
If this is already present please redirect me to that point.

I would like redirect the terminal ouput from serial to the frambuffer, and 
keep the terminal input as same.

I would like to convey regards to the following people for providing basic 
clarifications and others also:
	Matthew Orgass
	Nathan J. Williams
	Izumi Tsutsui San
	Valeriy E. Ushakov
	Toru Nishimura San
	.
	Tech-support from asiliant (Ken)
	.

Valeriy E. Ushakov provided information the hardware initialization of the 
Grahpics card as it is doen in igsfb*.* driver
Toru Nishimura San provided exact information on cn_tab in previous mails.

Thank you.

- Anand

PS: Please let me know if anybody requires the remaining files for 
clarification.

------=_NextPart_000_3b9c_193f_765b--