From: Laudney Ren Date: Fri, 03 Jan 2003 21:19:36 +0800 Subject: [U-Boot-Users] why jump at absolute address in start.S References: <2214.1041574514@msa.cmst.csiro.au> Message-ID: <3E158DE8.4010006@sjtu.edu.cn> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Murray Jensen wrote: > On Fri, 03 Jan 2003 11:47:22 +0800, Laudney Ren 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 at h >> ori r3, r3, CFG_MONITOR_BASE at 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