Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Mar 1997 15:52:32 -0800
From:      David Greenman <dg@root.com>
To:        Brian McGovern <bmcgover@bmcgover-pc.cisco.com>
Cc:        questions@FreeBSD.org, hackers@FreeBSD.org
Subject:   Re: Question on mapping PCI memory (Repeat) 
Message-ID:  <199703182352.PAA11329@root.com>
In-Reply-To: Your message of "Tue, 18 Mar 1997 15:28:28 EST." <199703182028.PAA00353@bmcgover-pc.cisco.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
>Therefore:
>
>	I am assuming that I can use the pci_map_mem routine, and do
>something like:
>
>        vm_offset_t vaddr, paddr;
>
>  	if (pci_map_mem(config_id, CZ_PCI_PLX9060_MEM, &vaddr, &paddr) == 0)
>          die();
>       
>and then have (unsigned char *)vaddr be a pointer to my virtual memory space,
>which I can then memcpy to, or do things like 
>(unsigned char *)vaddr[index] = 0;   and such.
>
>Also, as an alternative, I can do it the long way, similar to:
>
>	paddr = pci_conf_read(config_id, CZ_PCI_PLX9060_MEM);
>        vaddr = (vm_offset_t)pmap_mapdev(paddr, 72);
>
>Then use vaddr as above as the virtual addresses.
>
>The questions I have are:
>
>1.) Is this correct? If so, yea me. If not, which invokation is incorrect?

   Yes, either way will work.

>2.) Do I have to do anything extra fancy, such as take extra steps to
>align on page boundaries and such, and, if so, how would I go about
>doing that?

   The virtual and physical addresses returned will be on page boundries; you
don't need to do anything special.

>3.) Do I have to worry about locking the virtual memory space down? I assume
>they'd become kernel pages (as this is for a device driver), so they should
>never be "swapped".

   No, the kernel isn't pageable, and even if it were, pages associated with
device memory would never be reclaimed. So in other words, the device memory
will be mapped and stay mapped until you explicitly unmap it.

-DG

David Greenman
Core-team/Principal Architect, The FreeBSD Project



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