
Murray Jensen wrote:
On Fri, 03 Jan 2003 11:47:22 +0800, Laudney Ren bren@sjtu.edu.cn
writes:
I'm reading cpu/mpc8xx/start.S and found the following:
/* * Calculate absolute address in FLASH and jump there */ lis r3, CFG_MONITOR_BASE@h ori r3, r3, CFG_MONITOR_BASE@l addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET mtlr r3 blr
Why do we need to calculate the absolutely address? Why should we do it here, instead of everywhere?
This code jumps to the address that the boot device will appear at
after you
program the memory controller registers, so that the boot device will not disappear out from underneath you.
Murray:
I was very very very moved when I found you wrote such a detailed answer, providing so much background information, which would be precious to this list.
Actually, I know all the necessary background information, nearly everything about MPC8xx reset and so forth. Finally, one sentence in your reply inspired me: "the boot device will not disappear out from beneath you."
Right, absolutely. That's the VERY REASON!
When MPC8xx is reset, it starts to execute machine code at 0x100. At this time, all the address space is filled with copies of flash ROM images. For our board, which has 2M flash ROM, we'll get the same results when we read range 0x0 to 0x1fffff or 0x200000 to 0x3fffff and so on.
It's like a row of bricks which are the same. It makes no difference that which one you are standing on. Until the moment, in section _in_flash, we take away all the other bricks except one. If we haven't stood on the finally chosen brick, we'll fall. That's exactly what "disappear underneath" means.
So, thanks for your enthusiastic reply. We guys really appreciate your help.
Happy New Year!
Laudney