Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 08 Sep 2002 13:24:25 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        bms@spc.org
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: PCMCIA questions: mapping attribute and common memory?
Message-ID:  <20020908.132425.21514062.imp@bsdimp.com>
In-Reply-To: <20020908190057.GE3235@spc.org>
References:  <20020906093215.GI15218@spc.org> <20020906.235110.108188889.imp@bsdimp.com> <20020908190057.GE3235@spc.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20020908190057.GE3235@spc.org>
            Bruce M Simpson <bms@spc.org> writes:
: Many thanks! The only other question I have is - how would I go about
: doing a bus_space_mmap() to be able to copy the attribute memory off
: to a calling process?

I just re-read this, and you could also be asking how to implement a
read function for your device...

In that case, you'd have to do something like the crd driver does.
Since you already have the window picked out, I've removed the pick a
window code.  I'm also assuming that you have only 1 4k window and
that you don't have to move it around.

static  int
crdread(dev_t dev, struct uio *uio, int ioflag)
{
	if (uio->uio_offset > 0x1000)
		return (EIO);
        while (uio->uio_resid && error == 0) {
                offs = (unsigned int)uio->uio_offset & (0x1000 - 1);
                p = rman_get_virtual(am_res) + offs;
                count = MIN(0x1000 - offs, uio->uio_resid);
                error = uiomove(p, count, uio);
        }
        return (error);
}

I don't recall if uiomove does anything to optimize the memory moving,
but if it does, or if your data is non-linear, you'll have to uiomove
it one byte at a time into userland.

Warner

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020908.132425.21514062.imp>