Re: Accessing Adapter memory [help wanted]

Michael K. Johnson (johnsonm@nigel.vnet.net)
Tue, 24 Oct 1995 09:32:24 -0500


Mauro Condarelli writes:
>i'm writing a device driver for a PCI device (matrox meteor).
>I'm at the point where i have done all the preparatory work, properly
>recognized the board (via pcibios_*_config_*() functions) and i
>happen to have the physical address of the internal registers i have
>to manipulate.
>This physical address happen to begin at 0xf0000000.

You need to look in mm/vmalloc.c: Here's a quote of a comment:
>/*
> * Remap an arbitrary physical address space into the kernel virtual
> * address space. Needed when the kernel wants to access high addresses
> * directly.
> */
That sounds exactly like what you need.

The function in question is called vremap().
>void * vremap(unsigned long offset, unsigned long size)

Simply call it with the offset in question and the size of
the area. It will return an address in kernel virtual
memory that is mapped to that physical address. size will
be rounded up, if necessary, to the next page boundary,
and offset is required (if I read the code correctly) on
a page boundary, i.e. (offset % PAGE_SIZE == 0) is true.

Enjoy!

michaelkjohnson