Subject: Re: should cngetc block?
To: Bill Studenmund <wrstuden@netbsd.org>
From: Kin Cho <kin@neoscale.com>
List: tech-kern
Date: 02/08/2002 11:12:40
Bill Studenmund <wrstuden@netbsd.org> writes:

> 	cnopen(<console dev for your port>, FREAD | FWRITE | <other opts>
> 		0, curproc);

What can I use for <console dev for your port>?  I tried using
cn_tab->cn_dev but that's forbidden in cnopen because cn_dev is
alrady set to our "com0" device in com_attach_subr in
com.c:

		cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);

> /*
>  * Set up a uio to do a read, then call cnread()
>  */

I have no experience with uio.  Searching around, here's what I
come up with:

            struct iovec aiov;
            struct uio auio;
            int buf[2];			// code and lsr as stored in comintr?
            aiov.iov_base = buf;
            aiov.iov_len = sizeof(buf);
            auio.uio_iov = &aiov;
            auio.uio_iovcnt = 1;
            auio.uio_offset = 0;
            auio.uio_resid = 0;
            auio.uio_segflg = UIO_SYSSPACE;
            auio.uio_rw = UIO_READ;
            auio.uio_procp = curproc;
	    ret = cnread(<dev>, &auio, 0);

I doubt that iov_len, uio_offset, and uio_resid are right.
Any suggestion what they should be?

-kin