Direct addressing of physical address

Direct addressing of physical address

Post by SYSTEM Ran Golde 296 » Mon, 13 Jan 1997 04:00:00



I need to address directly absolute memory adresses (in a dedicated dual
port memory interface card). I can't use /dev/mem OR /de/kmem since the
application suppose to run at real time (both /dev/?mem would act as
buffered io).

Using :

unsigned long *pAddr;

pAddr = (unsigned long *) 0xD0000;
printf("%ld\n", *pAddr) OR *pAddr=val

        both causes SEGMENTATION violation (even as su).

I tried mprotect without succsess.

I'd be gratefull for any clues.


 
 
 

Direct addressing of physical address

Post by Ingo Molna » Tue, 14 Jan 1997 04:00:00



: Using :

: unsigned long *pAddr;
: pAddr = (unsigned long *) 0xD0000;
: printf("%ld\n", *pAddr) OR *pAddr=val

you dont have those pages mapped into your virtual space, at least not
for ring 3 usage. You will have to switch to ring 0 to access those
pages.

: I need to address directly absolute memory adresses (in a dedicated dual
: port memory interface card). I can't use /dev/mem OR /de/kmem since the
: application suppose to run at real time (both /dev/?mem would act as
: buffered io).

depends. It wont act as libc buffered io, if you use 'write()'. On a typical
Pentium system, kernel entry and exit last around 1 usecs. If this is acceptable
for your application, then use /dev/mem.

if you write to /dev/mem, then the following happens:

 libc calls write(&buffer)       20 cycles
 system enters the kernel        80 cycles

 the /dev/mem specific write() routine simply copies your user-space buffer into
 the physical location. No blocking, no buffering happens. Memory to memory copy.

 system leaves the kernel        20 cycles

Now, if you need >really fast< access to that piece of memory, then you should
write a driver for this card, it's very simple, just look at the kernel code,
copy the source of a similar driver (you CAN do it due to the GPL), and change
it to your needs.

additionaly, if you want to simply 'get access' to ring 0 pages, then a new
feature has to be implemented: ring 0 processes.

-- mingo

 
 
 

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

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

2. tcsh's sane (?) TTY

3. "Kernel logical address" vs "Physical address"

4. Apache running slow intermittently

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

6. PPP and my modem

7. virtual address to physical address

8. Sun Sparc SBUS ethernet & Linux

9. Map physical address to virtual address

10. physical address from virtual address

11. determining the physical address of a given user address

12. Mapping Kernel Virtual address to Physical address

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