Qnx equivalant of virt_to_bus()

Hello,

I’m porting a driver from linux to Qnx. In the driver I need to change
the local address to Pci and vice versa.

Is there any direct function which can do that for me? Or any other
way of doing this?

In fact I’m looking for substitutes of linux virt_to_bus() and
bus_to_virt() call in Qnx.

Any pointer will be of great help.

Thanks,
Saumendra

Ashwin,
Use the mmap function to map physical memory into a program’s address
space. Use mem_offset to get the physical address of a region of a
program’s address space.

Ashwin Mylavarapu wrote:

Hello,

I’m porting a driver from linux to Qnx. In the driver I need to change
the local address to Pci and vice versa.

Is there any direct function which can do that for me? Or any other
way of doing this?

In fact I’m looking for substitutes of linux virt_to_bus() and
bus_to_virt() call in Qnx.

Any pointer will be of great help.

Thanks,
Saumendra

Ashwin Mylavarapu <mylavarapu.ashwin@gmail.com> wrote:

Hello,

I’m porting a driver from linux to Qnx. In the driver I need to change
the local address to Pci and vice versa.

Is there any direct function which can do that for me? Or any other
way of doing this?

In fact I’m looking for substitutes of linux virt_to_bus() and
bus_to_virt() call in Qnx.

When you do a pci_attach_device(), it fills in a pci_dev_info structure with
a bunch of information. You want to look at the elements:

uint64_t CpuMemTranslation
The CPU-to-PCI memory translation (pci_addr = cpu_addr - translation).

uint64_t CpuBmstrTranslation
The translation from the CPU busmaster address to the PCI busmaster
address (pci_addr = cpu_addr + translation).

(On x86 the above will both be 0, on other platforms they may be non-zero.)

Combined with the mem_offset() to get a physical address for memory.
(Note: for DMA operations, you need to specifically allocate physically
contiguous memory, using mmap(), rather than just malloc()ing it, since
malloc()ed memory may not be physically contiguous.)

-David


David Gibbs
QNX Training Services
dagibbs@qnx.com

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:ctof96$bm7$1@inn.qnx.com

Ashwin Mylavarapu <> mylavarapu.ashwin@gmail.com> > wrote:
Hello,

I’m porting a driver from linux to Qnx. In the driver I need to change
the local address to Pci and vice versa.

Is there any direct function which can do that for me? Or any other
way of doing this?

In fact I’m looking for substitutes of linux virt_to_bus() and
bus_to_virt() call in Qnx.

When you do a pci_attach_device(), it fills in a pci_dev_info structure
with
a bunch of information. You want to look at the elements:

uint64_t CpuMemTranslation
The CPU-to-PCI memory translation (pci_addr = cpu_addr - translation).

uint64_t CpuBmstrTranslation
The translation from the CPU busmaster address to the PCI busmaster
address (pci_addr = cpu_addr + translation).

(On x86 the above will both be 0, on other platforms they may be
non-zero.)

I wonder what is going to happen the day QNX6 supports NUMA ( non-unified
memory architectur ),
hahahaha (devil like sound )

Combined with the mem_offset() to get a physical address for memory.
(Note: for DMA operations, you need to specifically allocate physically
contiguous memory, using mmap(), rather than just malloc()ing it, since
malloc()ed memory may not be physically contiguous.)

-David


David Gibbs
QNX Training Services
dagibbs@qnx.com

Mario Charest wrote:

I wonder what is going to happen the day QNX6 supports NUMA ( non-unified
memory architectur ),
hahahaha (devil like sound )

Won’t be that far off actually.


Cheers,
Adam

QNX Software Systems
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>