YDL 1.2 Synergy VGM5 bus address, physical address and virtual ad dress for PMC(PCI) Devices


Subject: YDL 1.2 Synergy VGM5 bus address, physical address and virtual ad dress for PMC(PCI) Devices
From: Chris Fought (CFought@SYSTRAN.com)
Date: Thu May 17 2001 - 14:19:17 MDT


I am currently developing a kernel module to communicate with a PCI memory
device and I have run into a few problems.

1. How do I determine the physical address of my PCI device? I did examine
the IO-mapping.txt file in /usr/scr/linux and it states the following is
true for Power PC:

Physical Address: 0x0
Virtual Memory Address: 0xC0000000
Bus Address 0x80000000

Using lspci -v I find that the bus address of my device is as follows:
memory at 0xF0042100 non-prefectable
memory at 0xF1000000 prefetchable
memory at 0xF2000000 prefetchable

So how do I figure out the physical address for the bus address 0XF1000000
do I just subtract/add 0x80000000 to get the address?

2. I need the physical address because I am trying to obtain it to pass into
remap_page_range() (I need to map all of the memory from my PCI device into
kernel memory and then pass a pointer from the kernel to user space. I tried
using the value of 0x71000000 (which I obtained by subtracting 0x80000000
from 0xF1000000 and it doesn't work:
User mode application:

if( (fd = open( SCR_INT_DEV, O_RDWR )) == -1 )
             rvalue = DEVICE_ERROR;
        else
        {
            paddr = mmap( 0, 0x80000, prot, mmap_flags, fd, 0 );
            if( (int)paddr == -1 )
                rvalue = MAP_ERROR;

(mmap entry point in kernel module)
static int pci_mmap(struct file * file, struct vm_area_struct * vma)
 physical += vma->vm_offset;
  mapped_mem = vma->vm_end - vma->vm_start;

if (remap_page_range(vma->vm_start, 0x71000000, mapped_mem,
vma->vm_page_prot))

This works fine on a Linux 2.2.18 distribution running on an X86 (I
understand that on the Power PC that Phy addr and bus addr aren't the same)

I realize that this is a non-portable way of accessing memory, but our API
requires that it receive a user pointer to directly access memory from our
card. Can anyone please help me or point me to information that might help
me to solve the problem.

Thanks,

Chris Fought



This archive was generated by hypermail 2a24 : Thu May 17 2001 - 13:23:53 MDT