[ECOS] Memory mapping routines in ecos

Nick Garnett nickg@ecoscentric.com
Tue Jul 25 09:17:00 GMT 2006

Surendra <surenreddy@gmail.com> writes:

> Hi,
> I am writing a ecos device driver for a PCI chipset on an i386 target.
> I want to know what are the appropriate HAL function calls to achieve
> the following ?
> 1. Allocate uncached memory address reagion for DMA
> 2. Convert PCI bus specific address to cpu address and vice versa.
> 3. Physical to Virtual - Virtual to Physical address
> I have already found the following MACROs defined in hal_arch.h that
> may have been defined for this purpose. But these MACROs do nothing.
> // Memory access macros
> #define CYGARC_CACHED_ADDRESS(x)                       (x)
> #define CYGARC_UNCACHED_ADDRESS(x)                     (x)
> #define CYGARC_PHYSICAL_ADDRESS(x)                     (x)
> #define CYGARC_VIRTUAL_ADDRESS(x)                      (x)
> Any suggestions ?
> Also, can anyone please explain what Logical, Physical and Virtual
> address mean in ecos?

The IA32 processors go to a lot of effort to ensure that there is a
coherent view of memory from all accessors -- CPU, PCI, DMA etc. For
this reason there is no need for these macros to do anything, the
hardware does it all. So to answer your questions:

1. Any memory you allocate will work. There is no need to specially
   allocate uncached memory.

2. On the PC hardware the PCI address space is mapped 1-1 onto the
   CPU physical address space. So no need to translate anything.

3. eCos doesn't use the MMU, so the mapping virtual to physical is

The definition of address types in eCos are as follows:

Virtual - Mapped through the MMU, the addresses visible to the
        CPU. The same memory may be visible in both cached and
        uncached versions at different virtual addresses.

Physical - The actual bus addresses of the various memory and device
        blocks. Physical addresses are needed to pass to DMA
        controllers and other direct access devices.

PCI Address - Within the PCI address space. The values that get put
        into the device BAR registers, and which need to be passed to
        any PCI DMA controllers. These addresses depend on the setup
        of various apertures between the physical and PCI address
        spaces. Generally, the translation from virtual to PCI
        addresses in handled in the PCI library.

Nick Garnett                                 eCos Kernel Architect
http://www.ecoscentric.com            The eCos and RedBoot experts

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list