<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
I'm reading the start.S for mpc83xx in u-boot.<BR>
I&nbsp;couldn't understand how the source code below work:<BR>
&nbsp;<BR>
/***************************************************<BR>
map_flash_by_law1:<BR>&nbsp;/* When booting from ROM (Flash or EPROM), clear the&nbsp; */<BR>&nbsp;/* Address Mask in OR0 so ROM appears everywhere&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<BR>&nbsp;/*----------------------------------------------------*/<BR>&nbsp;lis&nbsp;r3, (CFG_IMMR)@h&nbsp; /* r3 &lt;= CFG_IMMR&nbsp;&nbsp;&nbsp; */<BR>&nbsp;lwz&nbsp;r4, <A href="mailto:OR0@l(r3">OR0@l(r3</A>)<BR>&nbsp;li&nbsp;r5, 0x7fff&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* r5 &lt;= 0x00007FFFF */<BR>&nbsp;and&nbsp;r4, r4, r5<BR>&nbsp;stw&nbsp;r4, <A href="mailto:OR0@l(r3">OR0@l(r3</A>)&nbsp;&nbsp;&nbsp;&nbsp; /* OR0 &lt;= OR0 &amp; 0x00007FFFF */<BR>
&nbsp;<BR>
&nbsp;/* As MPC8349E User's Manual presented, when RCW[BMS] is set to 0,<BR>&nbsp; * system will boot from 0x0000_0100, and the LBLAWBAR0[BASE_ADDR]<BR>&nbsp; * reset value is 0x00000; when RCW[BMS] is set to 1, system will boot<BR>&nbsp; * from 0xFFF0_0100, and the LBLAWBAR0[BASE_ADDR] reset value is<BR>&nbsp; * 0xFF800.&nbsp; From the hard resetting to here, the processor fetched and<BR>&nbsp; * executed the instructions one by one.&nbsp; There is not absolutely<BR>&nbsp; * jumping happened.&nbsp; Laterly, the u-boot code has to do an absolutely<BR>&nbsp; * jumping to tell the CPU instruction fetching component what the<BR>&nbsp; * u-boot TEXT base address is.&nbsp; Because the TEXT base resides in the<BR>&nbsp; * boot ROM memory space, to garantee the code can run smoothly after<BR>&nbsp; * that jumping, we must map in the entire boot ROM by Local Access<BR>&nbsp; * Window.&nbsp; Sometimes, we desire an non-0x00000 or non-0xFF800 starting<BR>&nbsp; * address for boot ROM, such as 0xFE000000.&nbsp; In this case, the default<BR>&nbsp; * LBIU Local Access Widow 0 will not cover this memory space.&nbsp; So, we<BR>&nbsp; * need another window to map in it.<BR>&nbsp; */<BR>
<BR>&nbsp;lis r4, (CFG_FLASH_BASE)@h<BR>&nbsp;ori r4, r4, (CFG_FLASH_BASE)@l<BR>&nbsp;stw r4, LBLAWBAR1(r3) /* LBLAWBAR1 &lt;= CFG_FLASH_BASE */<BR>
&nbsp;/* Store 0x80000012 + log2(CFG_FLASH_SIZE) into LBLAWAR1 */<BR>&nbsp;/*0x8000_0000 is used to enable this window*/<BR>&nbsp;/*0x0000_0000-0x0000_0012 is the reserved window size*/<BR>&nbsp;lis r4, (0x80000012)@h<BR>&nbsp;ori r4, r4, (0x80000012)@l<BR>&nbsp;li r5, CFG_FLASH_SIZE<BR>1:&nbsp;srawi. r5, r5, 1&nbsp;/* r5 = r5 &gt;&gt; 1 */<BR>&nbsp;addi r4, r4, 1<BR>&nbsp;bne 1b<BR>
&nbsp;<BR>
&nbsp;stw r4, LBLAWAR1(r3) /* LBLAWAR1 &lt;= Flash Size */<BR>&nbsp;blr<BR>
********************************************************/<BR>
&nbsp;<BR>
the problem is from this segment:<BR>
&nbsp;<BR>
1:&nbsp;srawi. r5, r5, 1&nbsp;/* r5 = r5 &gt;&gt; 1 */<BR>&nbsp;addi r4, r4, 1<BR>&nbsp;bne 1b<BR>
&nbsp;<BR>
How it adjust the flash size to the fit size?<BR>
I define the CFG_FLASH_SIZE equal 1 in the MPC8313ERDB.h<BR><RTE_TEXT></RTE_TEXT><BR><br /><hr />MSN保护盾,十八般武艺保障MSN安全! <a href='http://im.live.cn/safe/' target='_new'>现在就下载!</a></body>
</html>