Solaris 2.1 X86 mmap driver problem

Solaris 2.1 X86 mmap driver problem

Post by Doug Ans » Fri, 18 Feb 1994 01:18:21



Hi:

I've tried to write a solaris 2.1 X86 mmap driver that allows me to mmap my Mach32
ATI's framebuffer region into user space. The framebuffer region is 4megs in
size. Not being the Solaris kernel guru, I have the following questions:

1. I've noticed that when I try to mmap(2) the 4Meg region, my device driver xxmmap(9E)
gets called for each 4k page of the 4Meg region.  My xxmmap(9E) routine then calls
ddi_mmap_regs(9F). Each ddi_map_reg() call has the "size" parameter set to the total
register length I've specified in my driver.conf(4).  Why is the kernel calling my xxmmap(9E)
routine that many times?  Should I be calling ddi_map_regs(9F) on each invocation of
xxmmap(9E)?

2. When my test program does a munmap(2) call, how do I relate that to a driver function
that should do a ddi_unmap_regs(9F)? I'd rather not put the ddi_unmap_reg(9F) in my
xxclose(9E) routine as many legitimate uses of mmaping involve closing the device
after the mmap(2) is established. If there is no way to relate munmap(2) to any driver
routine, then how does the kernel clean up the region?  What is ddi_unmap_reg(9F) then
used for?

Any help/comments/suggestions are greatly appreciated.

Doug Anson
--
-------------------------------------------
Doug Anson                                      

Phone:    713.560.1274
FAX:      713.560.1277
SNAIL:    Landmark Graphics Corporation LGC    
          15150 Memorial Drive
          Houston, TX 77079                    
-------------------------------------------

 
 
 

Solaris 2.1 X86 mmap driver problem

Post by Dan Mi » Sat, 19 Feb 1994 09:02:05



>Hi:

>I've tried to write a solaris 2.1 X86 mmap driver that allows me to mmap my Mach32
>ATI's framebuffer region into user space. The framebuffer region is 4megs in
>size. Not being the Solaris kernel guru, I have the following questions:

>1. I've noticed that when I try to mmap(2) the 4Meg region, my device driver xxmmap(9E)
>gets called for each 4k page of the 4Meg region.  My xxmmap(9E) routine then calls
>ddi_mmap_regs(9F). Each ddi_map_reg() call has the "size" parameter set to the total
>register length I've specified in my driver.conf(4).  Why is the kernel calling my xxmmap(9E)
>routine that many times?

The manual page mmap(9E) states:      
     An mmap() routine checks if the offset is within  the  range
     of pages supported by the device. For example, a device that
     has 512 bytes of memory that can be mapped into  user  space
     should  not support offsets greater than 512.  If the offset
     does not exist, then -1 is returned.   If  the  offset  does
     exist,    mmap()    returns    the    value    returned   by
     hat_getkpfnum(9F) for the page at offset off in the device's
     memory.

So it calls you once for each page by design.  

Quote:>  Should I be calling ddi_map_regs(9F) on each invocation of
>xxmmap(9E)?

Probably not; I suspect what the above implies is that you call
ddi_map_regs(9F) for the whole card in your attach(9E) entry point, and then
use hat_getkpfnum(9F) to return the physical page.  I won't guarantee
this will work, but it's what I'd try first.

You might want to get the DDK; it talks about memory-mapping drivers.

Quote:

>2. When my test program does a munmap(2) call, how do I relate that to a driver function
>that should do a ddi_unmap_regs(9F)? I'd rather not put the ddi_unmap_reg(9F) in my
>xxclose(9E) routine as many legitimate uses of mmaping involve closing the device
>after the mmap(2) is established. If there is no way to relate munmap(2) to any driver
>routine, then how does the kernel clean up the region?  

The user mapping disappears; your driver's kernel mapping remains until
the driver is unloaded.  Several users may map your device at the same
time.

Quote:> What is ddi_unmap_reg(9F) then
>used for?

When you detach(9E) and undo everything done in attach(9E).

Quote:>Any help/comments/suggestions are greatly appreciated.

Hope it helped.
>Doug Anson
>--
>-------------------------------------------
>Doug Anson                                  

>Phone:        713.560.1274
>FAX:          713.560.1277
>SNAIL:    Landmark Graphics Corporation LGC
>      15150 Memorial Drive
>      Houston, TX 77079                    
>-------------------------------------------


 
 
 

1. mmap(), Solaris 2.1 x86, and > real memory.

Hello!

Hopefully someone can answer this for me.

Is it possible to mmap() addresses that are greater than real memory?

I'm trying to mmap the 4MB linear appature on a Mach32 VLB board back
into user address space.  The usual location the Mach32 board decodes
its appature is at 124Mb, obviously there's not that much memory in the
machine.  So is there a way to mmap() from 124Mb to 128Mb back into
user space?

a basic open()/mmap() of /dev/mem doesn't allow it. It returns
the expect error (Invalid address or something like that).
The /dev/vtXX devices only seem to allow access from 0xA0000, to 0xFFFFF.

Perhaps there's a ioctl() someplace that I'm missing that tells
the memory device driver to turn off its range checking?

Many thanks!

David Holland
--
David Holland

Dream another dream, this dream is over. (Van Halen)

2. Top 10 posters comp.unix.shell

3. MMAP Solaris x86 driver problem

4. how to fix a directory without .. entry ?

5. XFree86 2.1 for solaris x86 2.1

6. [Fwd: pc.nfsd with PAM support]

7. X driver for S3 for Solaris 2.1-X86?

8. Voice over modem

9. Solaris 2.1: elx-driver (x86) bug???????

10. Solaris x86 2.1 HP JetStore 2000 over SCSI, Driver?

11. Video driver for Solaris 2.1 x86 OEM version

12. Solaris 2.1 printing sucks (was Re: problem with lpstat with Solaris 2.1)

13. Chinon CDROM & Solaris 2.1 x86 problem