Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Mar 1997 15:28:28 -0500
From:      Brian McGovern <bmcgover@bmcgover-pc.cisco.com>
To:        questions@freebsd.org, hackers@freebsd.org
Subject:   Question on mapping PCI memory (Repeat)
Message-ID:  <199703182028.PAA00353@bmcgover-pc.cisco.com>

next in thread | raw e-mail | index | archive | help
I apologize for re-asking this question, but ES here recently reparitioned my
harddrive, and I lost all of my mail, including the answer to this question.

Assume:

	I have a PCI card. It has 3 configuration registers at various
offsets that are defined by the constants CZ_PCI_PLX9060_MEM, 
CZ_PCI_MEMORY_WINDOW, CZ_PCI_IRQ. I wish to be able to map the first two, which
are memory addresses of dual ported ram on the card (I assume physical 
addresses), to virtual address space, so I can access it from the kernel.

Major premise:
	I think I know how to do it.

Minor premise:
	I probably have no clue, and I'm screwing it up.

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?

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?

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".


Any other comments are also welcome. Thanks.
		-Brian



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