Mapping Local Memory to cPCI address space

Hi,

We are using QNX 4.25 on a Kontron SBC that includes a 21554 PCI interface
chip. Part of the memory local to the Kontron SBC running QNX needs to be
able to reserve a chunk of memory so that we can map it to PCI memory space.
This way, other SBCs on the PCI backplane can access the memory of the
Kontron.

For example, upon power up the PCI BIOS assigns the Kontron board to PCI
address 0xbf000000. Now other SBCs on the backplane can access the Kontron
board via PCI address 0xbf000000. By default, the Kontron SBC leaves the map
value as 0x0000000 and consequently a SBC on the PCI can read/write PCI
address 0xbf000000 and access Kontron local address 0x0000000.

We need to create a QNX program to manage a local memory space we want to
map to the PCI but we don’t know how to do this. Please consider the
following program requirements and post your suggestions to this news group.

  1. Reserve a block of local memory and determine it’s absolute address so
    that absolute address can be used in the PCI to local memory map.
  2. Ensure that block of memory is not deallocated or moved or otherwise
    swapped out by QNX when the managing process is idle.


    BTW. We have experience using QNX 4.25 to access memory, via PCI, located on
    a remote SBC.

Thanks in advance,
Charlie Powell

Charlie Powell wrote:

Hi,

We are using QNX 4.25 on a Kontron SBC that includes a 21554 PCI interface
chip. Part of the memory local to the Kontron SBC running QNX needs to be
able to reserve a chunk of memory so that we can map it to PCI memory space.
This way, other SBCs on the PCI backplane can access the memory of the
Kontron.

For example, upon power up the PCI BIOS assigns the Kontron board to PCI
address 0xbf000000. Now other SBCs on the backplane can access the Kontron
board via PCI address 0xbf000000. By default, the Kontron SBC leaves the map
value as 0x0000000 and consequently a SBC on the PCI can read/write PCI
address 0xbf000000 and access Kontron local address 0x0000000.

We need to create a QNX program to manage a local memory space we want to
map to the PCI but we don’t know how to do this. Please consider the
following program requirements and post your suggestions to this news group.

Firstly, I have not done this, but it seems
straightforward enough.

Assumptions:

  1. You want your “manager” program, to
    allocate some memory and program the 21554
    to map PCI address bf000000 to the corresponding
    physical memory on the Kontron board.

  2. The “manager” program will then
    communicate data into or out of this
    memory using standard QNX message passing.

  1. Reserve a block of local memory and determine it’s absolute address so
    that absolute address can be used in the PCI to local memory map.

This is the only tricky bit (getting the
physical address of the memory your manager
allocated). Fortunately, there is a knowledge
base entry.

http://www.qnx.com/support/sd_bok/solution.qnx?9575

  1. Ensure that block of memory is not deallocated or moved or otherwise
    swapped out by QNX when the managing process is idle.

QNX 4 will not change your vm mappings.
If you want to be sure, you could mmap()
the memory (nothing fancy just -
mmap(0, len, R/W/NO_CACHE, MAP_PRIVATE, fd, 0)).
You can still use the pointer you get from
mmap() as an arg to vtop().

Once you have allocated your memory and
determined its physical address, you simply
need to tell the 21554 to map PCI address
bf000000 to the physical address you obtained
using vtop().

It should be that simple. Now your QNX apps
can read/write the PCI mapped memory via a message
protocol (you could make the “manager” a resource
manager and provide a posix open/read/write
interface).

note: If you wanted to simply make the memory
available as a shared object to other QNX
processes (rather than establish a formal
interface), you could mmap(… MAP_SHARED), instead
of PRIVATE (in which case your "manager"s only job
is to alloc the memory, and program the 21554).