This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to create a new platform?


On Thu, Feb 17, 2000 at 09:04:18AM +0100, Jesper Skov wrote:

> Grant> Next, I need to modify the linker command file for my target to
> Grant> add "glue" sections and add some "provides" to set the
> Grant> addresses of peripherals.  I can do this by adding lines to
> Grant> mlt_arm_mustang_ram.mlt or I can delete the .mlt file and edit
> Grant> the .ldi file directly -- right?
> 
> Two answers:
>  1) Addresses of peripherals should be defined in header files, not in
>     the linker script.

I guess I've always operated under the philosophy that it is
the linker's job to determine where things are located in the
memory map.  It seems a bit inconsistent to use the linker
command file to determine the location of most of code and data
objects but then hard-wire the addresses of a few of them into
the source code.

If I've got two targets that differ only in their memory maps,
I generally want those differences to happen at the linking
stage, not at the compiling stage.

BTW, how do you force a variable to a specified address in a
header file?  I can't find an appropriate __attribute__.  For
example, I have a structure named uart0, and I want it located
at address 0x3604000.  In the linker command file this is
accomplished simply enough with an assignment statement:

In C source:

   extern UartType uart0;
   
   [...]
   
   if (uart0.status & UartRxDataReady)
      c = uart0.rxData;

In the linker command file:

   Uart0 =0x3604000;


Do you prefer the "declare a pointer and then type-cast a
hard-wired constant value" method?

   const UartType Uart0Ptr = (UartType*) 0x3604000;

   if (uart0Ptr->status & UartRxDataReady)
      c = uart0Ptr->.rxData;

For most of the processors I've used in the past, the pointer
dereferencing generates larger code.  [Once you've spend a
couple weeks trying to trim a couple hundred bytes from a
binary, you have a hard time breaking the habit of not using
memory that you don't have to.] 

The previous example allows the compiler to generate references
to absolute locations in memory, which on some processors
results in smaller and faster code.

Of course on some processors (like the ARM) everything is done
via pointers anyway since there is no direct addressing mode --
and if you write functions that take pointers to the device in
question, you end up with the same code either way.

>  2) mlt is the master file. You should create new files using the
>     ConfigTool's memory map editor. It will also generate the .h and
>     .ldi files for you.

What is ConfigTool?  Is that something that runs under NT?  I
tried editing the mlt file and then re-running the tcl
configuration script, but that didn't seem to have any effect.

-- 
Grant Edwards
grante@visi.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]