Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Oct 2005 09:03:49 +1300
From:      Michael Honeyfield <michael@endace.com>
To:        freebsd-drivers@freebsd.org
Subject:   Re: reference drivers
Message-ID:  <434EBDA5.9070507@endace.com>
In-Reply-To: <200510131052.54692.jhb@freebsd.org>
References:  <434983A6.8040403@endace.com> <200510121532.54474.jhb@freebsd.org> <434D7A42.1080005@endace.com> <200510131052.54692.jhb@freebsd.org>

index | next in thread | previous in thread | raw e-mail

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

-- 
Michael Honeyfield
TECHNICAL SUPPORT
____________________________________________________

Endace Technology

michael@endace.com
http://www.endace.com



home | help

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