[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.3, Tue Oct 16 20:35:30 2007 UTC (16 years, 7 months ago) by init
Branch: MAIN
Changes since 1.2: +6 -6 lines

consoleops -> fcons_handle

/*
 * $Id: tacons.c,v 1.3 2007/10/16 20:35:30 init Exp $
 */
#include <sys/types.h>
#include <sys/device.h>
#include <sys/bus.h>

#include <arch/testarm/dev/taconsreg.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);

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


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_consops;

	/* 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;

	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;

	return( bus_write_1(tdp->td_dhp, 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;
}