[BACK]Return to tacons.c CVS log [TXT][DIR] Up to [local] / funnyos / arch / testarm / dev

File: [local] / funnyos / arch / testarm / dev / tacons.c (download)

Revision 1.7, Fri Jan 11 15:25:20 2008 UTC (16 years, 4 months ago) by nbrk
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +15 -2 lines

interrupt handler for tacons;
not usable since some things are missed in fcons now

/*
 * $Id: tacons.c,v 1.7 2008/01/11 15:25:20 nbrk Exp $
 */
#include <sys/types.h>
#include <sys/device.h>
#include <sys/bus.h>

#include <arch/testarm/dev/taconsreg.h>
#include <arch/testarm/dev/taconsvar.h>
#include <dev/fcons/fconsvar.h>
#include <libkern/printf.h>

/*
 * testarm console support.
 */

int 	tacons_attach(struct device *, uint32_t, uint8_t);
char 	tacons_getc(void *);
void 	tacons_putc(void *, char);
void 	tacons_early_putc(char);
void	tacons_interrupt(struct device *self);

struct driver tacons_dr = {
	sizeof(struct tacons_dd),
	tacons_attach,
	NULL,
	tacons_interrupt
};


int
tacons_attach(struct device *self, uint32_t loc, uint8_t flags)
{
	struct tacons_dd *ddp = self->dv_devdata;
	struct fcons_handle *fhp = &ddp->td_fh;

	/* aquire bus handle from parent */
	ddp->td_bhp = self->dv_parent->dv_aux;

	/* all reads/writes will use this addr; in testarm cons this is the same addr for getc/putc */
	ddp->td_ioaddr = loc;

	/* we export struct fcons_handle */
	fhp->getc = tacons_getc;
	fhp->putc = tacons_putc;

	/* give our dd to fcons_handle */
	fhp->fh_ownerdd = ddp;

	self->dv_aux = fhp;

	printf("testarm simple console (non-blocking, halt)\n");

	return(0);
}


char
tacons_getc(void *ddp)
{
	/*
	 * Get a character from the console.
	 * Remember that this console is non-blocking.
	 */
	struct tacons_dd *tdp = ddp;
	
	return( bus_read_1(tdp->td_bhp, tdp->td_ioaddr) );
}


void
tacons_putc(void *ddp, char ch)
{
	/*
	 * Write a character to the console.
	 */
	struct tacons_dd *tdp = ddp;

	bus_write_1(tdp->td_bhp, tdp->td_ioaddr, ch);
}


void
tacons_early_putc(char ch)
{
	/*
	 * put a character on the unconfigured console device.
	 * This will be used during devconfig until fcons/0 is configured.
	 */

	*(char *)(TACONS_REG_BASE + TACONS_OFF_IO) = ch;
}


void
tacons_interrupt(struct device *self)
{
	struct tacons_dd *ddp = (struct tacons_dd *)self->dv_devdata;
	char ch;

	ch = bus_read_1(ddp->td_bhp, ddp->td_ioaddr);

	fcons_ienqueue(ch);
}