I know I am missing out on something. But I want to know what!
Thanks in advance.
Position independent code is code that can operate "anywhere" in memory, all
of the calls and jumps use relative addressing so that the code can execute
anywhere in memory.
To call romInit.s Position Independent Code is really incorrect ( though
that's what WIND calls it). romInit.s is actually written to execute at a
specific position: ROM_TEXT_ADRS - just as you pointed out.
Here is what is different about it... romInit, romStart, usrInit, and the
rest of the VxWorks binary image are compiled into a single binary image
placed in contiguous memory in RAM not ROM. The location of this image is
determined by the type of image you are building (bootRom, VxWorks,
VxWorks_romCompressed, etc) and several MACROs (usually RAM_HIGH_ADRS and/or
RAM_LOW_ADRS)
If you look at the symbol map for the VxWorks image you've built (use the
nmXYZ binary tool, where XYZ refers to your arch id 68k, ppc, etc) you will
notice that the symbol for romInit is actually placed in RAM at or near
either RAM_HIGH_ADRS or RAM_LOW_ADRS.
So the compiler/linker have placed romInit in RAM, but you want to execute
them in ROM. So the math works out like this:
romInit compiler assigned address = 0x100000 ( just using a random address
here)
romStart compiler assigned address = 0x1002a0
Actual execution location of romInit is at ROM_TEXT_ADRS = 0xfff00000
When the board boots up, there is nothing in RAM. Through some means the
CPU begins executing code at or before ROM_TEXT_ADRS. When the romInit
routine (compiled to be located in RAM, but actually place in ROM) needs to
call romStart, it must call romStart in ROM not at the compiler assigned
address in RAM.
so the address for romStart must be calculated:
rom location of RomStart(ROM) = RomStart(RAM) - romInit(RAM) + ROM_TEXT_ADR
= 0x1002a0 - 0x100000 + 0xfff00000
= Offset between romInit and romStart +
Address of romInit in ROM
= 0x2a0 + 0xfff00000
= 0xfff002a0
Hopefully this answers your questions.
This might also help you understand why the Makefiles and config.h must be
agree in their definition of
ROM_TEXT_ADRS
RAM_HIGH_ADRS
RAM_LOW_ADRS
ROM_SIZE
The compiler uses those assignments to place the code in specific places in
memory. The config.h file uses these defines to locate code and data in
memory during execution.
Dave
----------------------------------------------
T h e P T R G r o u p, I n c.
----------------------------------------------
->->->-> ->->->->-> ->->->->
-> -> ->
->->->-> -> ->->->->
-> -> -> ->
-> -> -> ->
----------------------------------------------
Embedded, Real-Time Solutions, and Training
www.ThePTRGroup.com
----------------------------------------------
_______________________________________________
VxWorks Users Group mailing list
VxWe...@lbl.gov
http://www-csg.lbl.gov/vxworks/
> Position independent code is code that can operate "anywhere" in memory, all
> of the calls and jumps use relative addressing so that the code can execute
> anywhere in memory.
>
> To call romInit.s Position Independent Code is really incorrect ( though
> that's what WIND calls it). romInit.s is actually written to execute at a
> specific position: ROM_TEXT_ADRS - just as you pointed out.
No, the code at the start of romInit.s is (usually) hand coded to
remain entirely position independentm hence it is perfectly legitimate
to call it position independent code. It could run at any address, and
during development & testing often will be run from another address
(in RAM).
HTH,
John...
=====
Contribute to the VxWorks Cookbook at: http://books.bluedonkey.org/
Best Regards,
Ganesh Okade
Sunlux Technologies Ltd.
Bangalore, India
www.sunlux-india.com
I don't want to get into semantics, but I would consider position
independent code to be code that AFTER it is fully linked, can be loaded and
executed anywhere in memory. A good example of this is the interrupt entry
and exit code stubs that are pre-pended and appended to user interrupt
/exception handlers.
This is not the case with romInit.s. This file (and romStart.c) are written
to be relocatable via compilation. After the code is fully linked -
regardless of where it was placed by the compiler, it will execute in memory
relative to ROM_TEXT_ADRS, but only at that address. True, by modifying
ROM_TEXT_ADRS in config.h and the Makefile, I can relocate romInit to
execute at some other place in memory. But this does not meet my definition
of position independent code, it simply means the code is relocatable (via
compilation).
Again, this might just be an opinion (and everyone has one of those :) ) and
it certainly gets into semantics. But I wanted to clarify my explanation.
Thanks
Dave
Hello,
HTH,
John...
Martin Roth
Motorola Israel
"David Bryan" <Da...@ThePTRGroup.com> wrote in message
news:mailman.93.106614...@csg.lbl.gov...