PowerPC: _IO_BASE & friends

Joel Sherrill joel.sherrill at OARcorp.com
Wed Jan 9 01:20:34 UTC 2002


Till Straumann wrote:
> 
> Joel, I'd like to bring up an issue we talked about
> a while ago, namely the definitions of
> 
> _IO_BASE etc. by libcpu/io.h.
> 
> >> Something else that bothers me are the definitions
> >>
> >> #define _IO_BASE        PREP_ISA_IO_BASE
> >> #define _ISA_MEM_BASE   PREP_ISA_MEM_BASE
> >> #define PCI_DRAM_OFFSET PREP_PCI_DRAM_OFFSET
> >>
> >> found in lib/libcpu/powerpc/shared/include/io.h
> >>
> >> This should be the business of the BSP rather than
> >> the CPU library's!
> >>
> >Sounds reasonable to me also.  Could these be provided
> >by the linker script? This is the most flexible and avoids
> >the use of macros.
> >
> > -- joel
> >
> >> -- Till
> 
> These are my thoughts:
> 
> defining in bsp.h:
> 
>   +  more efficient
>   +  more transparent
>   -  existing code needs to be modified (include bsp.h in addition to
> libcpu/io.h)
>   -  macros should be avoided if possible
> 
> linkcmds:
>   +  no macro needed
>   +  existing source code needs no modification
>   -  less efficient ("lis ry, _IO_BASE at ha; ori ry,ry,_IO_BASE at la; add
> rx,rx,ry";
>       using a macro expands to "addis rx,rx,_IO_BASE at ha")
>   -  less transparent (hard to figure out for a reader where the symbol
> is defined)
> 
> Going beyond _IO_BASE and _ISA_MEM_BASE: should there be a standard
> way for rtems providing memory map info? How can an application or a
> driver
> figure out how to address a PCI or a VME location?

I personally prefer to put this type of information in the linkcmds
especially when it can change.  Many BSPs do this for the default
ROM/RAM size and base.
 
> An example:
> 
> The mvme23xx BSP maps all PCI memory space into ISA memory. Hence,
> to address a particular device on the mvme23xx, I use _ISA_MEM_BASE
> + pci_addr.
> However, on a CHRP platform, PCI memory and ISA memory are disjoint.
> There,
> I might have to use pci_addr to address the same device. This makes it
> complicated to port a driver between different RTEMS BSPs.
> 
> Worst of all, e.g. the libchip/dec21140 driver uses PREP_ISA_MEM_BASE to
> address
> pci memory space :-( which works fine on the mvme23xx but is likely
> to fail if I try to use this driver for a PMC module on a different
> board.
> 
> IMO, there is some work to be done in this area :-)

Sounds like the ISA and PCI base addresses should be defined in
subroutine/macros/linkcmds and the math that is making 
assumptions pushed down to the BSP specific level.  That way,
libchip/libcpu code would only assume it could ask the BSP for
the base addresses, then it would simply use them.  We have had
to do similar tricks in other places.

> Comments?

Nothing I would guarantee. :)
 
> -- Till.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985



More information about the users mailing list