YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

Post by Chris Fough » Wed, 23 May 2001 00:15:33



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

 
 
 

YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

Post by Chris Fough » Wed, 23 May 2001 00:15:33


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

 
 
 

YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

Post by Chris Fough » Wed, 23 May 2001 00:15:33


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

 
 
 

YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

Post by Chris Fough » Wed, 23 May 2001 00:15:33


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

 
 
 

YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

Post by Chris Fough » Wed, 23 May 2001 00:15:33


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

 
 
 

YDL 1.2 Synergy VGM5 Virtual Address, Physical Address, Bus Address and remap_page_range (HELP!)

Post by Chris Fough » Wed, 23 May 2001 00:15:33


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

 
 
 

1. User virtual address to physical address translation -- how?

Hiya,

I'd appreciate an early curtailment of my need to turn user virtual
addresses to physical addresses (from withing a driver module).  My
assumptions and searches have mounted to the following:

1) User virtual addresses != kernel virtual addresses (no prizes)
2) __va() & __pa() are dumb macros for kernel/physical address
traslation.
3) copy_to_user() and friends are written in assembler so I'm kind of
knackered with them. Unless I have a decade of free time.
4) I assume that the user pages are swapped in (using a machine with
no disk, let alone swap).

For additional bonus trivia:
o) I'm running some 2.2.1 kernel on a MIPS (playstation) for this test
but will ultimately be running on a diskless set-top-box with a
2.4.current kernel.

I saw something in a real old post about current->mm, and will have to
read a pile more on this.  I have the Rubini book and will have a look
at what this is.  Hopffully it'll provide me with a VMA struct that I
can use to knab out the page descriptor for the user VM and then do
the kernel __pa() translation for each page in teh VMA.

If you know a solution, a pointer to a website, some good structures
available from within kernel space, whatever, I'd appreciate it.

TIA

James
[James dot Irwin at zarlink dot com dot no dot spamming dot please]

2. runtime error

3. virtual address to physical address

4. Afterstep Installation

5. Map physical address to virtual address

6. nispasswd file to nis+ ?

7. physical address from virtual address

8. better fonts?

9. Mapping Kernel Virtual address to Physical address

10. Getting the physical address of a user virtual address.

11. "Kernel logical address" vs "Physical address"

12. Direct addressing of physical address

13. determining the physical address of a given user address