reference drivers
John Baldwin
jhb at freebsd.org
Thu Oct 13 13:14:55 PDT 2005
On Thursday 13 October 2005 04:03 pm, Michael Honeyfield wrote:
> John Baldwin wrote:
> >>Ok, good to know I am on the right path.
> >>
> >>Where is a good place to look if the foo_mmap() is not actually called?
> >>
> >>I use this routine as a test for mapping a register into user space:
> >>
> >> fd = open( "/dev/bar0", O_RDWR );
> >> reg = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> >> if( reg == MAP_FAILED) {
> >> fprintf( stderr, "can't mmap bar!\n" );
> >> exit(1);
> >> }
> >>
> >>the code takes an arg, and the register I am selecting is there. The
> >>above code snippet works on Linux.
> >
> >You need to make sure d_mmap in your cdevsw is mapped to your mmap
> > function. How do you know that your mmap routine is not being called?
> > Did you add a printf or some such? Did you do so before any error
> > checking that would cause an early return from the function?
>
> Yes, I have d_mmap in cdevsw, as per below:
>
> static struct cdevsw foo_cdevsw = {
> .d_open = foo_open,
> .d_close = foo_close,
> .d_read = foo_read,
> .d_write = foo_write,
> .d_mmap = foo_mmap,
> .d_strategy = NULL,
> .d_dump = NULL,
> .d_version = D_VERSION,
> .d_flags = D_NEEDGIANT,
> .d_name = "foo"
> };
>
> I do have debugging statements inside each function, so I can see from
> dmesg what is happening, or atleast, get a better idea. I use this for
> debugging:
>
> DPRINTF("foo mmap!\n");
>
> The above is inside each function, with it defined as
>
> #define DPRINTF(format, args...) printf(format , ## args);
>
> Since my driver is only in its absolutly early stages of development, it
> very closely resembles the driver given in the url in my first email,
> the only changes are some additional debugging out and my function
> definitions.
>
> I could post those if you think it could help.
>
> Regards
It would probably be easiest if I could just eyeball your driver (with any
uber-secret stuff stripped out). If it makes you more comfortable, you can
send it to privately rather than on the list.
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the freebsd-drivers
mailing list