start.S 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. /*
  2. * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
  3. * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
  4. * Copyright (C) 2000, 2001,2002 Wolfgang Denk <wd@denx.de>
  5. * Copyright Freescale Semiconductor, Inc. 2004, 2006, 2008.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. /*
  26. * U-Boot - Startup Code for MPC83xx PowerPC based Embedded Boards
  27. */
  28. #include <config.h>
  29. #include <mpc83xx.h>
  30. #include <version.h>
  31. #define CONFIG_83XX 1 /* needed for Linux kernel header files*/
  32. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  33. #include <ppc_asm.tmpl>
  34. #include <ppc_defs.h>
  35. #include <asm/cache.h>
  36. #include <asm/mmu.h>
  37. #ifndef CONFIG_IDENT_STRING
  38. #define CONFIG_IDENT_STRING "MPC83XX"
  39. #endif
  40. /* We don't want the MMU yet.
  41. */
  42. #undef MSR_KERNEL
  43. /*
  44. * Floating Point enable, Machine Check and Recoverable Interr.
  45. */
  46. #ifdef DEBUG
  47. #define MSR_KERNEL (MSR_FP|MSR_RI)
  48. #else
  49. #define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI)
  50. #endif
  51. #if !defined(CONFIG_NAND_SPL) && !defined(CFG_RAMBOOT)
  52. #define CFG_FLASHBOOT
  53. #endif
  54. /*
  55. * Set up GOT: Global Offset Table
  56. *
  57. * Use r14 to access the GOT
  58. */
  59. START_GOT
  60. GOT_ENTRY(_GOT2_TABLE_)
  61. GOT_ENTRY(__bss_start)
  62. GOT_ENTRY(_end)
  63. #ifndef CONFIG_NAND_SPL
  64. GOT_ENTRY(_FIXUP_TABLE_)
  65. GOT_ENTRY(_start)
  66. GOT_ENTRY(_start_of_vectors)
  67. GOT_ENTRY(_end_of_vectors)
  68. GOT_ENTRY(transfer_to_handler)
  69. #endif
  70. END_GOT
  71. /*
  72. * The Hard Reset Configuration Word (HRCW) table is in the first 64
  73. * (0x40) bytes of flash. It has 8 bytes, but each byte is repeated 8
  74. * times so the processor can fetch it out of flash whether the flash
  75. * is 8, 16, 32, or 64 bits wide (hardware trickery).
  76. */
  77. .text
  78. #define _HRCW_TABLE_ENTRY(w) \
  79. .fill 8,1,(((w)>>24)&0xff); \
  80. .fill 8,1,(((w)>>16)&0xff); \
  81. .fill 8,1,(((w)>> 8)&0xff); \
  82. .fill 8,1,(((w) )&0xff)
  83. _HRCW_TABLE_ENTRY(CFG_HRCW_LOW)
  84. _HRCW_TABLE_ENTRY(CFG_HRCW_HIGH)
  85. /*
  86. * Magic number and version string - put it after the HRCW since it
  87. * cannot be first in flash like it is in many other processors.
  88. */
  89. .long 0x27051956 /* U-Boot Magic Number */
  90. .globl version_string
  91. version_string:
  92. .ascii U_BOOT_VERSION
  93. .ascii " (", __DATE__, " - ", __TIME__, ")"
  94. .ascii " ", CONFIG_IDENT_STRING, "\0"
  95. #ifndef CONFIG_DEFAULT_IMMR
  96. #error CONFIG_DEFAULT_IMMR must be defined
  97. #endif /* CFG_DEFAULT_IMMR */
  98. #ifndef CFG_IMMR
  99. #define CFG_IMMR CONFIG_DEFAULT_IMMR
  100. #endif /* CFG_IMMR */
  101. /*
  102. * After configuration, a system reset exception is executed using the
  103. * vector at offset 0x100 relative to the base set by MSR[IP]. If
  104. * MSR[IP] is 0, the base address is 0x00000000. If MSR[IP] is 1, the
  105. * base address is 0xfff00000. In the case of a Power On Reset or Hard
  106. * Reset, the value of MSR[IP] is determined by the CIP field in the
  107. * HRCW.
  108. *
  109. * Other bits in the HRCW set up the Base Address and Port Size in BR0.
  110. * This determines the location of the boot ROM (flash or EPROM) in the
  111. * processor's address space at boot time. As long as the HRCW is set up
  112. * so that we eventually end up executing the code below when the
  113. * processor executes the reset exception, the actual values used should
  114. * not matter.
  115. *
  116. * Once we have got here, the address mask in OR0 is cleared so that the
  117. * bottom 32K of the boot ROM is effectively repeated all throughout the
  118. * processor's address space, after which we can jump to the absolute
  119. * address at which the boot ROM was linked at compile time, and proceed
  120. * to initialise the memory controller without worrying if the rug will
  121. * be pulled out from under us, so to speak (it will be fine as long as
  122. * we configure BR0 with the same boot ROM link address).
  123. */
  124. . = EXC_OFF_SYS_RESET
  125. .globl _start
  126. _start: /* time t 0 */
  127. li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH*/
  128. nop
  129. b boot_cold
  130. . = EXC_OFF_SYS_RESET + 0x10
  131. .globl _start_warm
  132. _start_warm:
  133. li r21, BOOTFLAG_WARM /* Software reboot */
  134. b boot_warm
  135. boot_cold: /* time t 3 */
  136. lis r4, CONFIG_DEFAULT_IMMR@h
  137. nop
  138. boot_warm: /* time t 5 */
  139. mfmsr r5 /* save msr contents */
  140. lis r3, CFG_IMMR@h
  141. ori r3, r3, CFG_IMMR@l
  142. stw r3, IMMRBAR(r4)
  143. /* Initialise the E300 processor core */
  144. /*------------------------------------------*/
  145. bl init_e300_core
  146. #ifdef CFG_FLASHBOOT
  147. /* Inflate flash location so it appears everywhere, calculate */
  148. /* the absolute address in final location of the FLASH, jump */
  149. /* there and deflate the flash size back to minimal size */
  150. /*------------------------------------------------------------*/
  151. bl map_flash_by_law1
  152. lis r4, (CFG_MONITOR_BASE)@h
  153. ori r4, r4, (CFG_MONITOR_BASE)@l
  154. addi r5, r4, in_flash - _start + EXC_OFF_SYS_RESET
  155. mtlr r5
  156. blr
  157. in_flash:
  158. #if 1 /* Remapping flash with LAW0. */
  159. bl remap_flash_by_law0
  160. #endif
  161. #endif /* CFG_FLASHBOOT */
  162. /* setup the bats */
  163. bl setup_bats
  164. sync
  165. /*
  166. * Cache must be enabled here for stack-in-cache trick.
  167. * This means we need to enable the BATS.
  168. * This means:
  169. * 1) for the EVB, original gt regs need to be mapped
  170. * 2) need to have an IBAT for the 0xf region,
  171. * we are running there!
  172. * Cache should be turned on after BATs, since by default
  173. * everything is write-through.
  174. * The init-mem BAT can be reused after reloc. The old
  175. * gt-regs BAT can be reused after board_init_f calls
  176. * board_early_init_f (EVB only).
  177. */
  178. /* enable address translation */
  179. bl enable_addr_trans
  180. sync
  181. /* enable and invalidate the data cache */
  182. bl dcache_enable
  183. sync
  184. #ifdef CFG_INIT_RAM_LOCK
  185. bl lock_ram_in_cache
  186. sync
  187. #endif
  188. /* set up the stack pointer in our newly created
  189. * cache-ram (r1) */
  190. lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h
  191. ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l
  192. li r0, 0 /* Make room for stack frame header and */
  193. stwu r0, -4(r1) /* clear final stack frame so that */
  194. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  195. /* let the C-code set up the rest */
  196. /* */
  197. /* Be careful to keep code relocatable & stack humble */
  198. /*------------------------------------------------------*/
  199. GET_GOT /* initialize GOT access */
  200. /* r3: IMMR */
  201. lis r3, CFG_IMMR@h
  202. /* run low-level CPU init code (in Flash)*/
  203. bl cpu_init_f
  204. /* r3: BOOTFLAG */
  205. mr r3, r21
  206. /* run 1st part of board init code (in Flash)*/
  207. bl board_init_f
  208. #ifndef CONFIG_NAND_SPL
  209. /*
  210. * Vector Table
  211. */
  212. .globl _start_of_vectors
  213. _start_of_vectors:
  214. /* Machine check */
  215. STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  216. /* Data Storage exception. */
  217. STD_EXCEPTION(0x300, DataStorage, UnknownException)
  218. /* Instruction Storage exception. */
  219. STD_EXCEPTION(0x400, InstStorage, UnknownException)
  220. /* External Interrupt exception. */
  221. #ifndef FIXME
  222. STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
  223. #endif
  224. /* Alignment exception. */
  225. . = 0x600
  226. Alignment:
  227. EXCEPTION_PROLOG(SRR0, SRR1)
  228. mfspr r4,DAR
  229. stw r4,_DAR(r21)
  230. mfspr r5,DSISR
  231. stw r5,_DSISR(r21)
  232. addi r3,r1,STACK_FRAME_OVERHEAD
  233. li r20,MSR_KERNEL
  234. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  235. rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
  236. lwz r6,GOT(transfer_to_handler)
  237. mtlr r6
  238. blrl
  239. .L_Alignment:
  240. .long AlignmentException - _start + EXC_OFF_SYS_RESET
  241. .long int_return - _start + EXC_OFF_SYS_RESET
  242. /* Program check exception */
  243. . = 0x700
  244. ProgramCheck:
  245. EXCEPTION_PROLOG(SRR0, SRR1)
  246. addi r3,r1,STACK_FRAME_OVERHEAD
  247. li r20,MSR_KERNEL
  248. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  249. rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
  250. lwz r6,GOT(transfer_to_handler)
  251. mtlr r6
  252. blrl
  253. .L_ProgramCheck:
  254. .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
  255. .long int_return - _start + EXC_OFF_SYS_RESET
  256. STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
  257. /* I guess we could implement decrementer, and may have
  258. * to someday for timekeeping.
  259. */
  260. STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
  261. STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
  262. STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
  263. STD_EXCEPTION(0xc00, SystemCall, UnknownException)
  264. STD_EXCEPTION(0xd00, SingleStep, UnknownException)
  265. STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
  266. STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
  267. STD_EXCEPTION(0x1000, InstructionTLBMiss, UnknownException)
  268. STD_EXCEPTION(0x1100, DataLoadTLBMiss, UnknownException)
  269. STD_EXCEPTION(0x1200, DataStoreTLBMiss, UnknownException)
  270. #ifdef DEBUG
  271. . = 0x1300
  272. /*
  273. * This exception occurs when the program counter matches the
  274. * Instruction Address Breakpoint Register (IABR).
  275. *
  276. * I want the cpu to halt if this occurs so I can hunt around
  277. * with the debugger and look at things.
  278. *
  279. * When DEBUG is defined, both machine check enable (in the MSR)
  280. * and checkstop reset enable (in the reset mode register) are
  281. * turned off and so a checkstop condition will result in the cpu
  282. * halting.
  283. *
  284. * I force the cpu into a checkstop condition by putting an illegal
  285. * instruction here (at least this is the theory).
  286. *
  287. * well - that didnt work, so just do an infinite loop!
  288. */
  289. 1: b 1b
  290. #else
  291. STD_EXCEPTION(0x1300, InstructionBreakpoint, DebugException)
  292. #endif
  293. STD_EXCEPTION(0x1400, SMI, UnknownException)
  294. STD_EXCEPTION(0x1500, Trap_15, UnknownException)
  295. STD_EXCEPTION(0x1600, Trap_16, UnknownException)
  296. STD_EXCEPTION(0x1700, Trap_17, UnknownException)
  297. STD_EXCEPTION(0x1800, Trap_18, UnknownException)
  298. STD_EXCEPTION(0x1900, Trap_19, UnknownException)
  299. STD_EXCEPTION(0x1a00, Trap_1a, UnknownException)
  300. STD_EXCEPTION(0x1b00, Trap_1b, UnknownException)
  301. STD_EXCEPTION(0x1c00, Trap_1c, UnknownException)
  302. STD_EXCEPTION(0x1d00, Trap_1d, UnknownException)
  303. STD_EXCEPTION(0x1e00, Trap_1e, UnknownException)
  304. STD_EXCEPTION(0x1f00, Trap_1f, UnknownException)
  305. STD_EXCEPTION(0x2000, Trap_20, UnknownException)
  306. STD_EXCEPTION(0x2100, Trap_21, UnknownException)
  307. STD_EXCEPTION(0x2200, Trap_22, UnknownException)
  308. STD_EXCEPTION(0x2300, Trap_23, UnknownException)
  309. STD_EXCEPTION(0x2400, Trap_24, UnknownException)
  310. STD_EXCEPTION(0x2500, Trap_25, UnknownException)
  311. STD_EXCEPTION(0x2600, Trap_26, UnknownException)
  312. STD_EXCEPTION(0x2700, Trap_27, UnknownException)
  313. STD_EXCEPTION(0x2800, Trap_28, UnknownException)
  314. STD_EXCEPTION(0x2900, Trap_29, UnknownException)
  315. STD_EXCEPTION(0x2a00, Trap_2a, UnknownException)
  316. STD_EXCEPTION(0x2b00, Trap_2b, UnknownException)
  317. STD_EXCEPTION(0x2c00, Trap_2c, UnknownException)
  318. STD_EXCEPTION(0x2d00, Trap_2d, UnknownException)
  319. STD_EXCEPTION(0x2e00, Trap_2e, UnknownException)
  320. STD_EXCEPTION(0x2f00, Trap_2f, UnknownException)
  321. .globl _end_of_vectors
  322. _end_of_vectors:
  323. . = 0x3000
  324. /*
  325. * This code finishes saving the registers to the exception frame
  326. * and jumps to the appropriate handler for the exception.
  327. * Register r21 is pointer into trap frame, r1 has new stack pointer.
  328. */
  329. .globl transfer_to_handler
  330. transfer_to_handler:
  331. stw r22,_NIP(r21)
  332. lis r22,MSR_POW@h
  333. andc r23,r23,r22
  334. stw r23,_MSR(r21)
  335. SAVE_GPR(7, r21)
  336. SAVE_4GPRS(8, r21)
  337. SAVE_8GPRS(12, r21)
  338. SAVE_8GPRS(24, r21)
  339. mflr r23
  340. andi. r24,r23,0x3f00 /* get vector offset */
  341. stw r24,TRAP(r21)
  342. li r22,0
  343. stw r22,RESULT(r21)
  344. lwz r24,0(r23) /* virtual address of handler */
  345. lwz r23,4(r23) /* where to go when done */
  346. mtspr SRR0,r24
  347. mtspr SRR1,r20
  348. mtlr r23
  349. SYNC
  350. rfi /* jump to handler, enable MMU */
  351. int_return:
  352. mfmsr r28 /* Disable interrupts */
  353. li r4,0
  354. ori r4,r4,MSR_EE
  355. andc r28,r28,r4
  356. SYNC /* Some chip revs need this... */
  357. mtmsr r28
  358. SYNC
  359. lwz r2,_CTR(r1)
  360. lwz r0,_LINK(r1)
  361. mtctr r2
  362. mtlr r0
  363. lwz r2,_XER(r1)
  364. lwz r0,_CCR(r1)
  365. mtspr XER,r2
  366. mtcrf 0xFF,r0
  367. REST_10GPRS(3, r1)
  368. REST_10GPRS(13, r1)
  369. REST_8GPRS(23, r1)
  370. REST_GPR(31, r1)
  371. lwz r2,_NIP(r1) /* Restore environment */
  372. lwz r0,_MSR(r1)
  373. mtspr SRR0,r2
  374. mtspr SRR1,r0
  375. lwz r0,GPR0(r1)
  376. lwz r2,GPR2(r1)
  377. lwz r1,GPR1(r1)
  378. SYNC
  379. rfi
  380. #endif /* !CONFIG_NAND_SPL */
  381. /*
  382. * This code initialises the E300 processor core
  383. * (conforms to PowerPC 603e spec)
  384. * Note: expects original MSR contents to be in r5.
  385. */
  386. .globl init_e300_core
  387. init_e300_core: /* time t 10 */
  388. /* Initialize machine status; enable machine check interrupt */
  389. /*-----------------------------------------------------------*/
  390. li r3, MSR_KERNEL /* Set ME and RI flags */
  391. rlwimi r3, r5, 0, 25, 25 /* preserve IP bit set by HRCW */
  392. #ifdef DEBUG
  393. rlwimi r3, r5, 0, 21, 22 /* debugger might set SE & BE bits */
  394. #endif
  395. SYNC /* Some chip revs need this... */
  396. mtmsr r3
  397. SYNC
  398. mtspr SRR1, r3 /* Make SRR1 match MSR */
  399. lis r3, CFG_IMMR@h
  400. #if defined(CONFIG_WATCHDOG)
  401. /* Initialise the Wathcdog values and reset it (if req) */
  402. /*------------------------------------------------------*/
  403. lis r4, CFG_WATCHDOG_VALUE
  404. ori r4, r4, (SWCRR_SWEN | SWCRR_SWRI | SWCRR_SWPR)
  405. stw r4, SWCRR(r3)
  406. /* and reset it */
  407. li r4, 0x556C
  408. sth r4, SWSRR@l(r3)
  409. li r4, -0x55C7
  410. sth r4, SWSRR@l(r3)
  411. #else
  412. /* Disable Wathcdog */
  413. /*-------------------*/
  414. lwz r4, SWCRR(r3)
  415. /* Check to see if its enabled for disabling
  416. once disabled by SW you can't re-enable */
  417. andi. r4, r4, 0x4
  418. beq 1f
  419. xor r4, r4, r4
  420. stw r4, SWCRR(r3)
  421. 1:
  422. #endif /* CONFIG_WATCHDOG */
  423. #if defined(CONFIG_MASK_AER_AO)
  424. /* Write the Arbiter Event Enable to mask Address Only traps. */
  425. /* This prevents the dcbz instruction from being trapped when */
  426. /* HID0_ABE Address Broadcast Enable is set and the MEMORY */
  427. /* COHERENCY bit is set in the WIMG bits, which is often */
  428. /* needed for PCI operation. */
  429. lwz r4, 0x0808(r3)
  430. rlwinm r0, r4, 0, ~AER_AO
  431. stw r0, 0x0808(r3)
  432. #endif /* CONFIG_MASK_AER_AO */
  433. /* Initialize the Hardware Implementation-dependent Registers */
  434. /* HID0 also contains cache control */
  435. /*------------------------------------------------------*/
  436. lis r3, CFG_HID0_INIT@h
  437. ori r3, r3, CFG_HID0_INIT@l
  438. SYNC
  439. mtspr HID0, r3
  440. lis r3, CFG_HID0_FINAL@h
  441. ori r3, r3, CFG_HID0_FINAL@l
  442. SYNC
  443. mtspr HID0, r3
  444. lis r3, CFG_HID2@h
  445. ori r3, r3, CFG_HID2@l
  446. SYNC
  447. mtspr HID2, r3
  448. /* Done! */
  449. /*------------------------------*/
  450. blr
  451. /* setup_bats - set them up to some initial state */
  452. .globl setup_bats
  453. setup_bats:
  454. addis r0, r0, 0x0000
  455. /* IBAT 0 */
  456. addis r4, r0, CFG_IBAT0L@h
  457. ori r4, r4, CFG_IBAT0L@l
  458. addis r3, r0, CFG_IBAT0U@h
  459. ori r3, r3, CFG_IBAT0U@l
  460. mtspr IBAT0L, r4
  461. mtspr IBAT0U, r3
  462. /* DBAT 0 */
  463. addis r4, r0, CFG_DBAT0L@h
  464. ori r4, r4, CFG_DBAT0L@l
  465. addis r3, r0, CFG_DBAT0U@h
  466. ori r3, r3, CFG_DBAT0U@l
  467. mtspr DBAT0L, r4
  468. mtspr DBAT0U, r3
  469. /* IBAT 1 */
  470. addis r4, r0, CFG_IBAT1L@h
  471. ori r4, r4, CFG_IBAT1L@l
  472. addis r3, r0, CFG_IBAT1U@h
  473. ori r3, r3, CFG_IBAT1U@l
  474. mtspr IBAT1L, r4
  475. mtspr IBAT1U, r3
  476. /* DBAT 1 */
  477. addis r4, r0, CFG_DBAT1L@h
  478. ori r4, r4, CFG_DBAT1L@l
  479. addis r3, r0, CFG_DBAT1U@h
  480. ori r3, r3, CFG_DBAT1U@l
  481. mtspr DBAT1L, r4
  482. mtspr DBAT1U, r3
  483. /* IBAT 2 */
  484. addis r4, r0, CFG_IBAT2L@h
  485. ori r4, r4, CFG_IBAT2L@l
  486. addis r3, r0, CFG_IBAT2U@h
  487. ori r3, r3, CFG_IBAT2U@l
  488. mtspr IBAT2L, r4
  489. mtspr IBAT2U, r3
  490. /* DBAT 2 */
  491. addis r4, r0, CFG_DBAT2L@h
  492. ori r4, r4, CFG_DBAT2L@l
  493. addis r3, r0, CFG_DBAT2U@h
  494. ori r3, r3, CFG_DBAT2U@l
  495. mtspr DBAT2L, r4
  496. mtspr DBAT2U, r3
  497. /* IBAT 3 */
  498. addis r4, r0, CFG_IBAT3L@h
  499. ori r4, r4, CFG_IBAT3L@l
  500. addis r3, r0, CFG_IBAT3U@h
  501. ori r3, r3, CFG_IBAT3U@l
  502. mtspr IBAT3L, r4
  503. mtspr IBAT3U, r3
  504. /* DBAT 3 */
  505. addis r4, r0, CFG_DBAT3L@h
  506. ori r4, r4, CFG_DBAT3L@l
  507. addis r3, r0, CFG_DBAT3U@h
  508. ori r3, r3, CFG_DBAT3U@l
  509. mtspr DBAT3L, r4
  510. mtspr DBAT3U, r3
  511. #ifdef CONFIG_HIGH_BATS
  512. /* IBAT 4 */
  513. addis r4, r0, CFG_IBAT4L@h
  514. ori r4, r4, CFG_IBAT4L@l
  515. addis r3, r0, CFG_IBAT4U@h
  516. ori r3, r3, CFG_IBAT4U@l
  517. mtspr IBAT4L, r4
  518. mtspr IBAT4U, r3
  519. /* DBAT 4 */
  520. addis r4, r0, CFG_DBAT4L@h
  521. ori r4, r4, CFG_DBAT4L@l
  522. addis r3, r0, CFG_DBAT4U@h
  523. ori r3, r3, CFG_DBAT4U@l
  524. mtspr DBAT4L, r4
  525. mtspr DBAT4U, r3
  526. /* IBAT 5 */
  527. addis r4, r0, CFG_IBAT5L@h
  528. ori r4, r4, CFG_IBAT5L@l
  529. addis r3, r0, CFG_IBAT5U@h
  530. ori r3, r3, CFG_IBAT5U@l
  531. mtspr IBAT5L, r4
  532. mtspr IBAT5U, r3
  533. /* DBAT 5 */
  534. addis r4, r0, CFG_DBAT5L@h
  535. ori r4, r4, CFG_DBAT5L@l
  536. addis r3, r0, CFG_DBAT5U@h
  537. ori r3, r3, CFG_DBAT5U@l
  538. mtspr DBAT5L, r4
  539. mtspr DBAT5U, r3
  540. /* IBAT 6 */
  541. addis r4, r0, CFG_IBAT6L@h
  542. ori r4, r4, CFG_IBAT6L@l
  543. addis r3, r0, CFG_IBAT6U@h
  544. ori r3, r3, CFG_IBAT6U@l
  545. mtspr IBAT6L, r4
  546. mtspr IBAT6U, r3
  547. /* DBAT 6 */
  548. addis r4, r0, CFG_DBAT6L@h
  549. ori r4, r4, CFG_DBAT6L@l
  550. addis r3, r0, CFG_DBAT6U@h
  551. ori r3, r3, CFG_DBAT6U@l
  552. mtspr DBAT6L, r4
  553. mtspr DBAT6U, r3
  554. /* IBAT 7 */
  555. addis r4, r0, CFG_IBAT7L@h
  556. ori r4, r4, CFG_IBAT7L@l
  557. addis r3, r0, CFG_IBAT7U@h
  558. ori r3, r3, CFG_IBAT7U@l
  559. mtspr IBAT7L, r4
  560. mtspr IBAT7U, r3
  561. /* DBAT 7 */
  562. addis r4, r0, CFG_DBAT7L@h
  563. ori r4, r4, CFG_DBAT7L@l
  564. addis r3, r0, CFG_DBAT7U@h
  565. ori r3, r3, CFG_DBAT7U@l
  566. mtspr DBAT7L, r4
  567. mtspr DBAT7U, r3
  568. #endif
  569. isync
  570. /* invalidate all tlb's
  571. *
  572. * From the 603e User Manual: "The 603e provides the ability to
  573. * invalidate a TLB entry. The TLB Invalidate Entry (tlbie)
  574. * instruction invalidates the TLB entry indexed by the EA, and
  575. * operates on both the instruction and data TLBs simultaneously
  576. * invalidating four TLB entries (both sets in each TLB). The
  577. * index corresponds to bits 15-19 of the EA. To invalidate all
  578. * entries within both TLBs, 32 tlbie instructions should be
  579. * issued, incrementing this field by one each time."
  580. *
  581. * "Note that the tlbia instruction is not implemented on the
  582. * 603e."
  583. *
  584. * bits 15-19 correspond to addresses 0x00000000 to 0x0001F000
  585. * incrementing by 0x1000 each time. The code below is sort of
  586. * based on code in "flush_tlbs" from arch/ppc/kernel/head.S
  587. *
  588. */
  589. lis r3, 0
  590. lis r5, 2
  591. 1:
  592. tlbie r3
  593. addi r3, r3, 0x1000
  594. cmp 0, 0, r3, r5
  595. blt 1b
  596. blr
  597. .globl enable_addr_trans
  598. enable_addr_trans:
  599. /* enable address translation */
  600. mfmsr r5
  601. ori r5, r5, (MSR_IR | MSR_DR)
  602. mtmsr r5
  603. isync
  604. blr
  605. .globl disable_addr_trans
  606. disable_addr_trans:
  607. /* disable address translation */
  608. mflr r4
  609. mfmsr r3
  610. andi. r0, r3, (MSR_IR | MSR_DR)
  611. beqlr
  612. andc r3, r3, r0
  613. mtspr SRR0, r4
  614. mtspr SRR1, r3
  615. rfi
  616. /* Cache functions.
  617. *
  618. * Note: requires that all cache bits in
  619. * HID0 are in the low half word.
  620. */
  621. .globl icache_enable
  622. icache_enable:
  623. mfspr r3, HID0
  624. ori r3, r3, HID0_ICE
  625. lis r4, 0
  626. ori r4, r4, HID0_ILOCK
  627. andc r3, r3, r4
  628. ori r4, r3, HID0_ICFI
  629. isync
  630. mtspr HID0, r4 /* sets enable and invalidate, clears lock */
  631. isync
  632. mtspr HID0, r3 /* clears invalidate */
  633. blr
  634. .globl icache_disable
  635. icache_disable:
  636. mfspr r3, HID0
  637. lis r4, 0
  638. ori r4, r4, HID0_ICE|HID0_ILOCK
  639. andc r3, r3, r4
  640. ori r4, r3, HID0_ICFI
  641. isync
  642. mtspr HID0, r4 /* sets invalidate, clears enable and lock*/
  643. isync
  644. mtspr HID0, r3 /* clears invalidate */
  645. blr
  646. .globl icache_status
  647. icache_status:
  648. mfspr r3, HID0
  649. rlwinm r3, r3, (31 - HID0_ICE_SHIFT + 1), 31, 31
  650. blr
  651. .globl dcache_enable
  652. dcache_enable:
  653. mfspr r3, HID0
  654. li r5, HID0_DCFI|HID0_DLOCK
  655. andc r3, r3, r5
  656. mtspr HID0, r3 /* no invalidate, unlock */
  657. ori r3, r3, HID0_DCE
  658. ori r5, r3, HID0_DCFI
  659. mtspr HID0, r5 /* enable + invalidate */
  660. mtspr HID0, r3 /* enable */
  661. sync
  662. blr
  663. .globl dcache_disable
  664. dcache_disable:
  665. mfspr r3, HID0
  666. lis r4, 0
  667. ori r4, r4, HID0_DCE|HID0_DLOCK
  668. andc r3, r3, r4
  669. ori r4, r3, HID0_DCI
  670. sync
  671. mtspr HID0, r4 /* sets invalidate, clears enable and lock */
  672. sync
  673. mtspr HID0, r3 /* clears invalidate */
  674. blr
  675. .globl dcache_status
  676. dcache_status:
  677. mfspr r3, HID0
  678. rlwinm r3, r3, (31 - HID0_DCE_SHIFT + 1), 31, 31
  679. blr
  680. .globl get_pvr
  681. get_pvr:
  682. mfspr r3, PVR
  683. blr
  684. .globl ppcDWstore
  685. ppcDWstore:
  686. lfd 1, 0(r4)
  687. stfd 1, 0(r3)
  688. blr
  689. .globl ppcDWload
  690. ppcDWload:
  691. lfd 1, 0(r3)
  692. stfd 1, 0(r4)
  693. blr
  694. /*-------------------------------------------------------------------*/
  695. /*
  696. * void relocate_code (addr_sp, gd, addr_moni)
  697. *
  698. * This "function" does not return, instead it continues in RAM
  699. * after relocating the monitor code.
  700. *
  701. * r3 = dest
  702. * r4 = src
  703. * r5 = length in bytes
  704. * r6 = cachelinesize
  705. */
  706. .globl relocate_code
  707. relocate_code:
  708. mr r1, r3 /* Set new stack pointer */
  709. mr r9, r4 /* Save copy of Global Data pointer */
  710. mr r10, r5 /* Save copy of Destination Address */
  711. mr r3, r5 /* Destination Address */
  712. lis r4, CFG_MONITOR_BASE@h /* Source Address */
  713. ori r4, r4, CFG_MONITOR_BASE@l
  714. lwz r5, GOT(__bss_start)
  715. sub r5, r5, r4
  716. li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
  717. /*
  718. * Fix GOT pointer:
  719. *
  720. * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE)
  721. * + Destination Address
  722. *
  723. * Offset:
  724. */
  725. sub r15, r10, r4
  726. /* First our own GOT */
  727. add r14, r14, r15
  728. /* then the one used by the C code */
  729. add r30, r30, r15
  730. /*
  731. * Now relocate code
  732. */
  733. cmplw cr1,r3,r4
  734. addi r0,r5,3
  735. srwi. r0,r0,2
  736. beq cr1,4f /* In place copy is not necessary */
  737. beq 7f /* Protect against 0 count */
  738. mtctr r0
  739. bge cr1,2f
  740. la r8,-4(r4)
  741. la r7,-4(r3)
  742. /* copy */
  743. 1: lwzu r0,4(r8)
  744. stwu r0,4(r7)
  745. bdnz 1b
  746. addi r0,r5,3
  747. srwi. r0,r0,2
  748. mtctr r0
  749. la r8,-4(r4)
  750. la r7,-4(r3)
  751. /* and compare */
  752. 20: lwzu r20,4(r8)
  753. lwzu r21,4(r7)
  754. xor. r22, r20, r21
  755. bne 30f
  756. bdnz 20b
  757. b 4f
  758. /* compare failed */
  759. 30: li r3, 0
  760. blr
  761. 2: slwi r0,r0,2 /* re copy in reverse order ... y do we needed it? */
  762. add r8,r4,r0
  763. add r7,r3,r0
  764. 3: lwzu r0,-4(r8)
  765. stwu r0,-4(r7)
  766. bdnz 3b
  767. /*
  768. * Now flush the cache: note that we must start from a cache aligned
  769. * address. Otherwise we might miss one cache line.
  770. */
  771. 4: cmpwi r6,0
  772. add r5,r3,r5
  773. beq 7f /* Always flush prefetch queue in any case */
  774. subi r0,r6,1
  775. andc r3,r3,r0
  776. mr r4,r3
  777. 5: dcbst 0,r4
  778. add r4,r4,r6
  779. cmplw r4,r5
  780. blt 5b
  781. sync /* Wait for all dcbst to complete on bus */
  782. mr r4,r3
  783. 6: icbi 0,r4
  784. add r4,r4,r6
  785. cmplw r4,r5
  786. blt 6b
  787. 7: sync /* Wait for all icbi to complete on bus */
  788. isync
  789. /*
  790. * We are done. Do not return, instead branch to second part of board
  791. * initialization, now running from RAM.
  792. */
  793. addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
  794. mtlr r0
  795. blr
  796. in_ram:
  797. /*
  798. * Relocation Function, r14 point to got2+0x8000
  799. *
  800. * Adjust got2 pointers, no need to check for 0, this code
  801. * already puts a few entries in the table.
  802. */
  803. li r0,__got2_entries@sectoff@l
  804. la r3,GOT(_GOT2_TABLE_)
  805. lwz r11,GOT(_GOT2_TABLE_)
  806. mtctr r0
  807. sub r11,r3,r11
  808. addi r3,r3,-4
  809. 1: lwzu r0,4(r3)
  810. add r0,r0,r11
  811. stw r0,0(r3)
  812. bdnz 1b
  813. #ifndef CONFIG_NAND_SPL
  814. /*
  815. * Now adjust the fixups and the pointers to the fixups
  816. * in case we need to move ourselves again.
  817. */
  818. 2: li r0,__fixup_entries@sectoff@l
  819. lwz r3,GOT(_FIXUP_TABLE_)
  820. cmpwi r0,0
  821. mtctr r0
  822. addi r3,r3,-4
  823. beq 4f
  824. 3: lwzu r4,4(r3)
  825. lwzux r0,r4,r11
  826. add r0,r0,r11
  827. stw r10,0(r3)
  828. stw r0,0(r4)
  829. bdnz 3b
  830. 4:
  831. #endif
  832. clear_bss:
  833. /*
  834. * Now clear BSS segment
  835. */
  836. lwz r3,GOT(__bss_start)
  837. #if defined(CONFIG_HYMOD)
  838. /*
  839. * For HYMOD - the environment is the very last item in flash.
  840. * The real .bss stops just before environment starts, so only
  841. * clear up to that point.
  842. *
  843. * taken from mods for FADS board
  844. */
  845. lwz r4,GOT(environment)
  846. #else
  847. lwz r4,GOT(_end)
  848. #endif
  849. cmplw 0, r3, r4
  850. beq 6f
  851. li r0, 0
  852. 5:
  853. stw r0, 0(r3)
  854. addi r3, r3, 4
  855. cmplw 0, r3, r4
  856. bne 5b
  857. 6:
  858. mr r3, r9 /* Global Data pointer */
  859. mr r4, r10 /* Destination Address */
  860. bl board_init_r
  861. #ifndef CONFIG_NAND_SPL
  862. /*
  863. * Copy exception vector code to low memory
  864. *
  865. * r3: dest_addr
  866. * r7: source address, r8: end address, r9: target address
  867. */
  868. .globl trap_init
  869. trap_init:
  870. lwz r7, GOT(_start)
  871. lwz r8, GOT(_end_of_vectors)
  872. li r9, 0x100 /* reset vector always at 0x100 */
  873. cmplw 0, r7, r8
  874. bgelr /* return if r7>=r8 - just in case */
  875. mflr r4 /* save link register */
  876. 1:
  877. lwz r0, 0(r7)
  878. stw r0, 0(r9)
  879. addi r7, r7, 4
  880. addi r9, r9, 4
  881. cmplw 0, r7, r8
  882. bne 1b
  883. /*
  884. * relocate `hdlr' and `int_return' entries
  885. */
  886. li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
  887. li r8, Alignment - _start + EXC_OFF_SYS_RESET
  888. 2:
  889. bl trap_reloc
  890. addi r7, r7, 0x100 /* next exception vector */
  891. cmplw 0, r7, r8
  892. blt 2b
  893. li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
  894. bl trap_reloc
  895. li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
  896. bl trap_reloc
  897. li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
  898. li r8, SystemCall - _start + EXC_OFF_SYS_RESET
  899. 3:
  900. bl trap_reloc
  901. addi r7, r7, 0x100 /* next exception vector */
  902. cmplw 0, r7, r8
  903. blt 3b
  904. li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
  905. li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
  906. 4:
  907. bl trap_reloc
  908. addi r7, r7, 0x100 /* next exception vector */
  909. cmplw 0, r7, r8
  910. blt 4b
  911. mfmsr r3 /* now that the vectors have */
  912. lis r7, MSR_IP@h /* relocated into low memory */
  913. ori r7, r7, MSR_IP@l /* MSR[IP] can be turned off */
  914. andc r3, r3, r7 /* (if it was on) */
  915. SYNC /* Some chip revs need this... */
  916. mtmsr r3
  917. SYNC
  918. mtlr r4 /* restore link register */
  919. blr
  920. /*
  921. * Function: relocate entries for one exception vector
  922. */
  923. trap_reloc:
  924. lwz r0, 0(r7) /* hdlr ... */
  925. add r0, r0, r3 /* ... += dest_addr */
  926. stw r0, 0(r7)
  927. lwz r0, 4(r7) /* int_return ... */
  928. add r0, r0, r3 /* ... += dest_addr */
  929. stw r0, 4(r7)
  930. blr
  931. #endif /* !CONFIG_NAND_SPL */
  932. #ifdef CFG_INIT_RAM_LOCK
  933. lock_ram_in_cache:
  934. /* Allocate Initial RAM in data cache.
  935. */
  936. lis r3, (CFG_INIT_RAM_ADDR & ~31)@h
  937. ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l
  938. li r4, ((CFG_INIT_RAM_END & ~31) + \
  939. (CFG_INIT_RAM_ADDR & 31) + 31) / 32
  940. mtctr r4
  941. 1:
  942. dcbz r0, r3
  943. addi r3, r3, 32
  944. bdnz 1b
  945. /* Lock the data cache */
  946. mfspr r0, HID0
  947. ori r0, r0, 0x1000
  948. sync
  949. mtspr HID0, r0
  950. sync
  951. blr
  952. #ifndef CONFIG_NAND_SPL
  953. .globl unlock_ram_in_cache
  954. unlock_ram_in_cache:
  955. /* invalidate the INIT_RAM section */
  956. lis r3, (CFG_INIT_RAM_ADDR & ~31)@h
  957. ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l
  958. li r4, ((CFG_INIT_RAM_END & ~31) + \
  959. (CFG_INIT_RAM_ADDR & 31) + 31) / 32
  960. mtctr r4
  961. 1: icbi r0, r3
  962. dcbi r0, r3
  963. addi r3, r3, 32
  964. bdnz 1b
  965. sync /* Wait for all icbi to complete on bus */
  966. isync
  967. /* Unlock the data cache and invalidate it */
  968. mfspr r3, HID0
  969. li r5, HID0_DLOCK|HID0_DCFI
  970. andc r3, r3, r5 /* no invalidate, unlock */
  971. ori r5, r3, HID0_DCFI /* invalidate, unlock */
  972. mtspr HID0, r5 /* invalidate, unlock */
  973. mtspr HID0, r3 /* no invalidate, unlock */
  974. sync
  975. blr
  976. #endif /* !CONFIG_NAND_SPL */
  977. #endif /* CFG_INIT_RAM_LOCK */
  978. #ifdef CFG_FLASHBOOT
  979. map_flash_by_law1:
  980. /* When booting from ROM (Flash or EPROM), clear the */
  981. /* Address Mask in OR0 so ROM appears everywhere */
  982. /*----------------------------------------------------*/
  983. lis r3, (CFG_IMMR)@h /* r3 <= CFG_IMMR */
  984. lwz r4, OR0@l(r3)
  985. li r5, 0x7fff /* r5 <= 0x00007FFFF */
  986. and r4, r4, r5
  987. stw r4, OR0@l(r3) /* OR0 <= OR0 & 0x00007FFFF */
  988. /* As MPC8349E User's Manual presented, when RCW[BMS] is set to 0,
  989. * system will boot from 0x0000_0100, and the LBLAWBAR0[BASE_ADDR]
  990. * reset value is 0x00000; when RCW[BMS] is set to 1, system will boot
  991. * from 0xFFF0_0100, and the LBLAWBAR0[BASE_ADDR] reset value is
  992. * 0xFF800. From the hard resetting to here, the processor fetched and
  993. * executed the instructions one by one. There is not absolutely
  994. * jumping happened. Laterly, the u-boot code has to do an absolutely
  995. * jumping to tell the CPU instruction fetching component what the
  996. * u-boot TEXT base address is. Because the TEXT base resides in the
  997. * boot ROM memory space, to garantee the code can run smoothly after
  998. * that jumping, we must map in the entire boot ROM by Local Access
  999. * Window. Sometimes, we desire an non-0x00000 or non-0xFF800 starting
  1000. * address for boot ROM, such as 0xFE000000. In this case, the default
  1001. * LBIU Local Access Widow 0 will not cover this memory space. So, we
  1002. * need another window to map in it.
  1003. */
  1004. lis r4, (CFG_FLASH_BASE)@h
  1005. ori r4, r4, (CFG_FLASH_BASE)@l
  1006. stw r4, LBLAWBAR1(r3) /* LBLAWBAR1 <= CFG_FLASH_BASE */
  1007. /* Store 0x80000012 + log2(CFG_FLASH_SIZE) into LBLAWAR1 */
  1008. lis r4, (0x80000012)@h
  1009. ori r4, r4, (0x80000012)@l
  1010. li r5, CFG_FLASH_SIZE
  1011. 1: srawi. r5, r5, 1 /* r5 = r5 >> 1 */
  1012. addi r4, r4, 1
  1013. bne 1b
  1014. stw r4, LBLAWAR1(r3) /* LBLAWAR1 <= 8MB Flash Size */
  1015. blr
  1016. /* Though all the LBIU Local Access Windows and LBC Banks will be
  1017. * initialized in the C code, we'd better configure boot ROM's
  1018. * window 0 and bank 0 correctly at here.
  1019. */
  1020. remap_flash_by_law0:
  1021. /* Initialize the BR0 with the boot ROM starting address. */
  1022. lwz r4, BR0(r3)
  1023. li r5, 0x7FFF
  1024. and r4, r4, r5
  1025. lis r5, (CFG_FLASH_BASE & 0xFFFF8000)@h
  1026. ori r5, r5, (CFG_FLASH_BASE & 0xFFFF8000)@l
  1027. or r5, r5, r4
  1028. stw r5, BR0(r3) /* r5 <= (CFG_FLASH_BASE & 0xFFFF8000) | (BR0 & 0x00007FFF) */
  1029. lwz r4, OR0(r3)
  1030. lis r5, ~((CFG_FLASH_SIZE << 4) - 1)
  1031. or r4, r4, r5
  1032. stw r4, OR0(r3)
  1033. lis r4, (CFG_FLASH_BASE)@h
  1034. ori r4, r4, (CFG_FLASH_BASE)@l
  1035. stw r4, LBLAWBAR0(r3) /* LBLAWBAR0 <= CFG_FLASH_BASE */
  1036. /* Store 0x80000012 + log2(CFG_FLASH_SIZE) into LBLAWAR0 */
  1037. lis r4, (0x80000012)@h
  1038. ori r4, r4, (0x80000012)@l
  1039. li r5, CFG_FLASH_SIZE
  1040. 1: srawi. r5, r5, 1 /* r5 = r5 >> 1 */
  1041. addi r4, r4, 1
  1042. bne 1b
  1043. stw r4, LBLAWAR0(r3) /* LBLAWAR0 <= Flash Size */
  1044. xor r4, r4, r4
  1045. stw r4, LBLAWBAR1(r3)
  1046. stw r4, LBLAWAR1(r3) /* Off LBIU LAW1 */
  1047. blr
  1048. #endif /* CFG_FLASHBOOT */