start.S 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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 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. /* - force invalidation of data and instruction caches */
  436. /*------------------------------------------------------*/
  437. lis r3, CFG_HID0_INIT@h
  438. ori r3, r3, (CFG_HID0_INIT | HID0_ICFI | HID0_DCFI)@l
  439. SYNC
  440. mtspr HID0, r3
  441. lis r3, CFG_HID0_FINAL@h
  442. ori r3, r3, (CFG_HID0_FINAL & ~(HID0_ICFI | HID0_DCFI))@l
  443. SYNC
  444. mtspr HID0, r3
  445. lis r3, CFG_HID2@h
  446. ori r3, r3, CFG_HID2@l
  447. SYNC
  448. mtspr HID2, r3
  449. /* Done! */
  450. /*------------------------------*/
  451. blr
  452. /* setup_bats - set them up to some initial state */
  453. .globl setup_bats
  454. setup_bats:
  455. addis r0, r0, 0x0000
  456. /* IBAT 0 */
  457. addis r4, r0, CFG_IBAT0L@h
  458. ori r4, r4, CFG_IBAT0L@l
  459. addis r3, r0, CFG_IBAT0U@h
  460. ori r3, r3, CFG_IBAT0U@l
  461. mtspr IBAT0L, r4
  462. mtspr IBAT0U, r3
  463. /* DBAT 0 */
  464. addis r4, r0, CFG_DBAT0L@h
  465. ori r4, r4, CFG_DBAT0L@l
  466. addis r3, r0, CFG_DBAT0U@h
  467. ori r3, r3, CFG_DBAT0U@l
  468. mtspr DBAT0L, r4
  469. mtspr DBAT0U, r3
  470. /* IBAT 1 */
  471. addis r4, r0, CFG_IBAT1L@h
  472. ori r4, r4, CFG_IBAT1L@l
  473. addis r3, r0, CFG_IBAT1U@h
  474. ori r3, r3, CFG_IBAT1U@l
  475. mtspr IBAT1L, r4
  476. mtspr IBAT1U, r3
  477. /* DBAT 1 */
  478. addis r4, r0, CFG_DBAT1L@h
  479. ori r4, r4, CFG_DBAT1L@l
  480. addis r3, r0, CFG_DBAT1U@h
  481. ori r3, r3, CFG_DBAT1U@l
  482. mtspr DBAT1L, r4
  483. mtspr DBAT1U, r3
  484. /* IBAT 2 */
  485. addis r4, r0, CFG_IBAT2L@h
  486. ori r4, r4, CFG_IBAT2L@l
  487. addis r3, r0, CFG_IBAT2U@h
  488. ori r3, r3, CFG_IBAT2U@l
  489. mtspr IBAT2L, r4
  490. mtspr IBAT2U, r3
  491. /* DBAT 2 */
  492. addis r4, r0, CFG_DBAT2L@h
  493. ori r4, r4, CFG_DBAT2L@l
  494. addis r3, r0, CFG_DBAT2U@h
  495. ori r3, r3, CFG_DBAT2U@l
  496. mtspr DBAT2L, r4
  497. mtspr DBAT2U, r3
  498. /* IBAT 3 */
  499. addis r4, r0, CFG_IBAT3L@h
  500. ori r4, r4, CFG_IBAT3L@l
  501. addis r3, r0, CFG_IBAT3U@h
  502. ori r3, r3, CFG_IBAT3U@l
  503. mtspr IBAT3L, r4
  504. mtspr IBAT3U, r3
  505. /* DBAT 3 */
  506. addis r4, r0, CFG_DBAT3L@h
  507. ori r4, r4, CFG_DBAT3L@l
  508. addis r3, r0, CFG_DBAT3U@h
  509. ori r3, r3, CFG_DBAT3U@l
  510. mtspr DBAT3L, r4
  511. mtspr DBAT3U, r3
  512. #ifdef CONFIG_HIGH_BATS
  513. /* IBAT 4 */
  514. addis r4, r0, CFG_IBAT4L@h
  515. ori r4, r4, CFG_IBAT4L@l
  516. addis r3, r0, CFG_IBAT4U@h
  517. ori r3, r3, CFG_IBAT4U@l
  518. mtspr IBAT4L, r4
  519. mtspr IBAT4U, r3
  520. /* DBAT 4 */
  521. addis r4, r0, CFG_DBAT4L@h
  522. ori r4, r4, CFG_DBAT4L@l
  523. addis r3, r0, CFG_DBAT4U@h
  524. ori r3, r3, CFG_DBAT4U@l
  525. mtspr DBAT4L, r4
  526. mtspr DBAT4U, r3
  527. /* IBAT 5 */
  528. addis r4, r0, CFG_IBAT5L@h
  529. ori r4, r4, CFG_IBAT5L@l
  530. addis r3, r0, CFG_IBAT5U@h
  531. ori r3, r3, CFG_IBAT5U@l
  532. mtspr IBAT5L, r4
  533. mtspr IBAT5U, r3
  534. /* DBAT 5 */
  535. addis r4, r0, CFG_DBAT5L@h
  536. ori r4, r4, CFG_DBAT5L@l
  537. addis r3, r0, CFG_DBAT5U@h
  538. ori r3, r3, CFG_DBAT5U@l
  539. mtspr DBAT5L, r4
  540. mtspr DBAT5U, r3
  541. /* IBAT 6 */
  542. addis r4, r0, CFG_IBAT6L@h
  543. ori r4, r4, CFG_IBAT6L@l
  544. addis r3, r0, CFG_IBAT6U@h
  545. ori r3, r3, CFG_IBAT6U@l
  546. mtspr IBAT6L, r4
  547. mtspr IBAT6U, r3
  548. /* DBAT 6 */
  549. addis r4, r0, CFG_DBAT6L@h
  550. ori r4, r4, CFG_DBAT6L@l
  551. addis r3, r0, CFG_DBAT6U@h
  552. ori r3, r3, CFG_DBAT6U@l
  553. mtspr DBAT6L, r4
  554. mtspr DBAT6U, r3
  555. /* IBAT 7 */
  556. addis r4, r0, CFG_IBAT7L@h
  557. ori r4, r4, CFG_IBAT7L@l
  558. addis r3, r0, CFG_IBAT7U@h
  559. ori r3, r3, CFG_IBAT7U@l
  560. mtspr IBAT7L, r4
  561. mtspr IBAT7U, r3
  562. /* DBAT 7 */
  563. addis r4, r0, CFG_DBAT7L@h
  564. ori r4, r4, CFG_DBAT7L@l
  565. addis r3, r0, CFG_DBAT7U@h
  566. ori r3, r3, CFG_DBAT7U@l
  567. mtspr DBAT7L, r4
  568. mtspr DBAT7U, r3
  569. #endif
  570. isync
  571. /* invalidate all tlb's
  572. *
  573. * From the 603e User Manual: "The 603e provides the ability to
  574. * invalidate a TLB entry. The TLB Invalidate Entry (tlbie)
  575. * instruction invalidates the TLB entry indexed by the EA, and
  576. * operates on both the instruction and data TLBs simultaneously
  577. * invalidating four TLB entries (both sets in each TLB). The
  578. * index corresponds to bits 15-19 of the EA. To invalidate all
  579. * entries within both TLBs, 32 tlbie instructions should be
  580. * issued, incrementing this field by one each time."
  581. *
  582. * "Note that the tlbia instruction is not implemented on the
  583. * 603e."
  584. *
  585. * bits 15-19 correspond to addresses 0x00000000 to 0x0001F000
  586. * incrementing by 0x1000 each time. The code below is sort of
  587. * based on code in "flush_tlbs" from arch/ppc/kernel/head.S
  588. *
  589. */
  590. lis r3, 0
  591. lis r5, 2
  592. 1:
  593. tlbie r3
  594. addi r3, r3, 0x1000
  595. cmp 0, 0, r3, r5
  596. blt 1b
  597. blr
  598. .globl enable_addr_trans
  599. enable_addr_trans:
  600. /* enable address translation */
  601. mfmsr r5
  602. ori r5, r5, (MSR_IR | MSR_DR)
  603. mtmsr r5
  604. isync
  605. blr
  606. .globl disable_addr_trans
  607. disable_addr_trans:
  608. /* disable address translation */
  609. mflr r4
  610. mfmsr r3
  611. andi. r0, r3, (MSR_IR | MSR_DR)
  612. beqlr
  613. andc r3, r3, r0
  614. mtspr SRR0, r4
  615. mtspr SRR1, r3
  616. rfi
  617. /* Cache functions.
  618. *
  619. * Note: requires that all cache bits in
  620. * HID0 are in the low half word.
  621. */
  622. .globl icache_enable
  623. icache_enable:
  624. mfspr r3, HID0
  625. ori r3, r3, HID0_ICE
  626. li r4, HID0_ICFI|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_ICFI|HID0_ILOCK
  639. andc r3, r3, r4
  640. isync
  641. mtspr HID0, r3 /* clears invalidate, enable and lock */
  642. blr
  643. .globl icache_status
  644. icache_status:
  645. mfspr r3, HID0
  646. rlwinm r3, r3, (31 - HID0_ICE_SHIFT + 1), 31, 31
  647. blr
  648. .globl dcache_enable
  649. dcache_enable:
  650. mfspr r3, HID0
  651. li r5, HID0_DCFI|HID0_DLOCK
  652. andc r3, r3, r5
  653. ori r3, r3, HID0_DCE
  654. sync
  655. mtspr HID0, r3 /* enable, no invalidate */
  656. blr
  657. .globl dcache_disable
  658. dcache_disable:
  659. mflr r4
  660. bl flush_dcache /* uses r3 and r5 */
  661. mfspr r3, HID0
  662. li r5, HID0_DCE|HID0_DLOCK
  663. andc r3, r3, r5
  664. ori r5, r3, HID0_DCFI
  665. sync
  666. mtspr HID0, r5 /* sets invalidate, clears enable and lock */
  667. sync
  668. mtspr HID0, r3 /* clears invalidate */
  669. mtlr r4
  670. blr
  671. .globl dcache_status
  672. dcache_status:
  673. mfspr r3, HID0
  674. rlwinm r3, r3, (31 - HID0_DCE_SHIFT + 1), 31, 31
  675. blr
  676. .globl flush_dcache
  677. flush_dcache:
  678. lis r3, 0
  679. lis r5, CFG_CACHELINE_SIZE
  680. 1: cmp 0, 1, r3, r5
  681. bge 2f
  682. lwz r5, 0(r3)
  683. lis r5, CFG_CACHELINE_SIZE
  684. addi r3, r3, 0x4
  685. b 1b
  686. 2: blr
  687. .globl get_pvr
  688. get_pvr:
  689. mfspr r3, PVR
  690. blr
  691. .globl ppcDWstore
  692. ppcDWstore:
  693. lfd 1, 0(r4)
  694. stfd 1, 0(r3)
  695. blr
  696. .globl ppcDWload
  697. ppcDWload:
  698. lfd 1, 0(r3)
  699. stfd 1, 0(r4)
  700. blr
  701. /*-------------------------------------------------------------------*/
  702. /*
  703. * void relocate_code (addr_sp, gd, addr_moni)
  704. *
  705. * This "function" does not return, instead it continues in RAM
  706. * after relocating the monitor code.
  707. *
  708. * r3 = dest
  709. * r4 = src
  710. * r5 = length in bytes
  711. * r6 = cachelinesize
  712. */
  713. .globl relocate_code
  714. relocate_code:
  715. mr r1, r3 /* Set new stack pointer */
  716. mr r9, r4 /* Save copy of Global Data pointer */
  717. mr r10, r5 /* Save copy of Destination Address */
  718. mr r3, r5 /* Destination Address */
  719. lis r4, CFG_MONITOR_BASE@h /* Source Address */
  720. ori r4, r4, CFG_MONITOR_BASE@l
  721. lwz r5, GOT(__bss_start)
  722. sub r5, r5, r4
  723. li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
  724. /*
  725. * Fix GOT pointer:
  726. *
  727. * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE)
  728. * + Destination Address
  729. *
  730. * Offset:
  731. */
  732. sub r15, r10, r4
  733. /* First our own GOT */
  734. add r14, r14, r15
  735. /* then the one used by the C code */
  736. add r30, r30, r15
  737. /*
  738. * Now relocate code
  739. */
  740. cmplw cr1,r3,r4
  741. addi r0,r5,3
  742. srwi. r0,r0,2
  743. beq cr1,4f /* In place copy is not necessary */
  744. beq 7f /* Protect against 0 count */
  745. mtctr r0
  746. bge cr1,2f
  747. la r8,-4(r4)
  748. la r7,-4(r3)
  749. /* copy */
  750. 1: lwzu r0,4(r8)
  751. stwu r0,4(r7)
  752. bdnz 1b
  753. addi r0,r5,3
  754. srwi. r0,r0,2
  755. mtctr r0
  756. la r8,-4(r4)
  757. la r7,-4(r3)
  758. /* and compare */
  759. 20: lwzu r20,4(r8)
  760. lwzu r21,4(r7)
  761. xor. r22, r20, r21
  762. bne 30f
  763. bdnz 20b
  764. b 4f
  765. /* compare failed */
  766. 30: li r3, 0
  767. blr
  768. 2: slwi r0,r0,2 /* re copy in reverse order ... y do we needed it? */
  769. add r8,r4,r0
  770. add r7,r3,r0
  771. 3: lwzu r0,-4(r8)
  772. stwu r0,-4(r7)
  773. bdnz 3b
  774. /*
  775. * Now flush the cache: note that we must start from a cache aligned
  776. * address. Otherwise we might miss one cache line.
  777. */
  778. 4: cmpwi r6,0
  779. add r5,r3,r5
  780. beq 7f /* Always flush prefetch queue in any case */
  781. subi r0,r6,1
  782. andc r3,r3,r0
  783. mr r4,r3
  784. 5: dcbst 0,r4
  785. add r4,r4,r6
  786. cmplw r4,r5
  787. blt 5b
  788. sync /* Wait for all dcbst to complete on bus */
  789. mr r4,r3
  790. 6: icbi 0,r4
  791. add r4,r4,r6
  792. cmplw r4,r5
  793. blt 6b
  794. 7: sync /* Wait for all icbi to complete on bus */
  795. isync
  796. /*
  797. * We are done. Do not return, instead branch to second part of board
  798. * initialization, now running from RAM.
  799. */
  800. addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
  801. mtlr r0
  802. blr
  803. in_ram:
  804. /*
  805. * Relocation Function, r14 point to got2+0x8000
  806. *
  807. * Adjust got2 pointers, no need to check for 0, this code
  808. * already puts a few entries in the table.
  809. */
  810. li r0,__got2_entries@sectoff@l
  811. la r3,GOT(_GOT2_TABLE_)
  812. lwz r11,GOT(_GOT2_TABLE_)
  813. mtctr r0
  814. sub r11,r3,r11
  815. addi r3,r3,-4
  816. 1: lwzu r0,4(r3)
  817. add r0,r0,r11
  818. stw r0,0(r3)
  819. bdnz 1b
  820. #ifndef CONFIG_NAND_SPL
  821. /*
  822. * Now adjust the fixups and the pointers to the fixups
  823. * in case we need to move ourselves again.
  824. */
  825. 2: li r0,__fixup_entries@sectoff@l
  826. lwz r3,GOT(_FIXUP_TABLE_)
  827. cmpwi r0,0
  828. mtctr r0
  829. addi r3,r3,-4
  830. beq 4f
  831. 3: lwzu r4,4(r3)
  832. lwzux r0,r4,r11
  833. add r0,r0,r11
  834. stw r10,0(r3)
  835. stw r0,0(r4)
  836. bdnz 3b
  837. 4:
  838. #endif
  839. clear_bss:
  840. /*
  841. * Now clear BSS segment
  842. */
  843. lwz r3,GOT(__bss_start)
  844. #if defined(CONFIG_HYMOD)
  845. /*
  846. * For HYMOD - the environment is the very last item in flash.
  847. * The real .bss stops just before environment starts, so only
  848. * clear up to that point.
  849. *
  850. * taken from mods for FADS board
  851. */
  852. lwz r4,GOT(environment)
  853. #else
  854. lwz r4,GOT(_end)
  855. #endif
  856. cmplw 0, r3, r4
  857. beq 6f
  858. li r0, 0
  859. 5:
  860. stw r0, 0(r3)
  861. addi r3, r3, 4
  862. cmplw 0, r3, r4
  863. bne 5b
  864. 6:
  865. mr r3, r9 /* Global Data pointer */
  866. mr r4, r10 /* Destination Address */
  867. bl board_init_r
  868. #ifndef CONFIG_NAND_SPL
  869. /*
  870. * Copy exception vector code to low memory
  871. *
  872. * r3: dest_addr
  873. * r7: source address, r8: end address, r9: target address
  874. */
  875. .globl trap_init
  876. trap_init:
  877. lwz r7, GOT(_start)
  878. lwz r8, GOT(_end_of_vectors)
  879. li r9, 0x100 /* reset vector always at 0x100 */
  880. cmplw 0, r7, r8
  881. bgelr /* return if r7>=r8 - just in case */
  882. mflr r4 /* save link register */
  883. 1:
  884. lwz r0, 0(r7)
  885. stw r0, 0(r9)
  886. addi r7, r7, 4
  887. addi r9, r9, 4
  888. cmplw 0, r7, r8
  889. bne 1b
  890. /*
  891. * relocate `hdlr' and `int_return' entries
  892. */
  893. li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
  894. li r8, Alignment - _start + EXC_OFF_SYS_RESET
  895. 2:
  896. bl trap_reloc
  897. addi r7, r7, 0x100 /* next exception vector */
  898. cmplw 0, r7, r8
  899. blt 2b
  900. li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
  901. bl trap_reloc
  902. li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
  903. bl trap_reloc
  904. li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
  905. li r8, SystemCall - _start + EXC_OFF_SYS_RESET
  906. 3:
  907. bl trap_reloc
  908. addi r7, r7, 0x100 /* next exception vector */
  909. cmplw 0, r7, r8
  910. blt 3b
  911. li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
  912. li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
  913. 4:
  914. bl trap_reloc
  915. addi r7, r7, 0x100 /* next exception vector */
  916. cmplw 0, r7, r8
  917. blt 4b
  918. mfmsr r3 /* now that the vectors have */
  919. lis r7, MSR_IP@h /* relocated into low memory */
  920. ori r7, r7, MSR_IP@l /* MSR[IP] can be turned off */
  921. andc r3, r3, r7 /* (if it was on) */
  922. SYNC /* Some chip revs need this... */
  923. mtmsr r3
  924. SYNC
  925. mtlr r4 /* restore link register */
  926. blr
  927. /*
  928. * Function: relocate entries for one exception vector
  929. */
  930. trap_reloc:
  931. lwz r0, 0(r7) /* hdlr ... */
  932. add r0, r0, r3 /* ... += dest_addr */
  933. stw r0, 0(r7)
  934. lwz r0, 4(r7) /* int_return ... */
  935. add r0, r0, r3 /* ... += dest_addr */
  936. stw r0, 4(r7)
  937. blr
  938. #endif /* !CONFIG_NAND_SPL */
  939. #ifdef CFG_INIT_RAM_LOCK
  940. lock_ram_in_cache:
  941. /* Allocate Initial RAM in data cache.
  942. */
  943. lis r3, (CFG_INIT_RAM_ADDR & ~31)@h
  944. ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l
  945. li r4, ((CFG_INIT_RAM_END & ~31) + \
  946. (CFG_INIT_RAM_ADDR & 31) + 31) / 32
  947. mtctr r4
  948. 1:
  949. dcbz r0, r3
  950. addi r3, r3, 32
  951. bdnz 1b
  952. /* Lock the data cache */
  953. mfspr r0, HID0
  954. ori r0, r0, HID0_DLOCK
  955. sync
  956. mtspr HID0, r0
  957. sync
  958. blr
  959. #ifndef CONFIG_NAND_SPL
  960. .globl unlock_ram_in_cache
  961. unlock_ram_in_cache:
  962. /* invalidate the INIT_RAM section */
  963. lis r3, (CFG_INIT_RAM_ADDR & ~31)@h
  964. ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l
  965. li r4, ((CFG_INIT_RAM_END & ~31) + \
  966. (CFG_INIT_RAM_ADDR & 31) + 31) / 32
  967. mtctr r4
  968. 1: icbi r0, r3
  969. dcbi r0, r3
  970. addi r3, r3, 32
  971. bdnz 1b
  972. sync /* Wait for all icbi to complete on bus */
  973. isync
  974. /* Unlock the data cache and invalidate it */
  975. mfspr r3, HID0
  976. li r5, HID0_DLOCK|HID0_DCFI
  977. andc r3, r3, r5 /* no invalidate, unlock */
  978. ori r5, r3, HID0_DCFI /* invalidate, unlock */
  979. sync
  980. mtspr HID0, r5 /* invalidate, unlock */
  981. sync
  982. mtspr HID0, r3 /* no invalidate, unlock */
  983. blr
  984. #endif /* !CONFIG_NAND_SPL */
  985. #endif /* CFG_INIT_RAM_LOCK */
  986. #ifdef CFG_FLASHBOOT
  987. map_flash_by_law1:
  988. /* When booting from ROM (Flash or EPROM), clear the */
  989. /* Address Mask in OR0 so ROM appears everywhere */
  990. /*----------------------------------------------------*/
  991. lis r3, (CFG_IMMR)@h /* r3 <= CFG_IMMR */
  992. lwz r4, OR0@l(r3)
  993. li r5, 0x7fff /* r5 <= 0x00007FFFF */
  994. and r4, r4, r5
  995. stw r4, OR0@l(r3) /* OR0 <= OR0 & 0x00007FFFF */
  996. /* As MPC8349E User's Manual presented, when RCW[BMS] is set to 0,
  997. * system will boot from 0x0000_0100, and the LBLAWBAR0[BASE_ADDR]
  998. * reset value is 0x00000; when RCW[BMS] is set to 1, system will boot
  999. * from 0xFFF0_0100, and the LBLAWBAR0[BASE_ADDR] reset value is
  1000. * 0xFF800. From the hard resetting to here, the processor fetched and
  1001. * executed the instructions one by one. There is not absolutely
  1002. * jumping happened. Laterly, the u-boot code has to do an absolutely
  1003. * jumping to tell the CPU instruction fetching component what the
  1004. * u-boot TEXT base address is. Because the TEXT base resides in the
  1005. * boot ROM memory space, to garantee the code can run smoothly after
  1006. * that jumping, we must map in the entire boot ROM by Local Access
  1007. * Window. Sometimes, we desire an non-0x00000 or non-0xFF800 starting
  1008. * address for boot ROM, such as 0xFE000000. In this case, the default
  1009. * LBIU Local Access Widow 0 will not cover this memory space. So, we
  1010. * need another window to map in it.
  1011. */
  1012. lis r4, (CFG_FLASH_BASE)@h
  1013. ori r4, r4, (CFG_FLASH_BASE)@l
  1014. stw r4, LBLAWBAR1(r3) /* LBLAWBAR1 <= CFG_FLASH_BASE */
  1015. /* Store 0x80000012 + log2(CFG_FLASH_SIZE) into LBLAWAR1 */
  1016. lis r4, (0x80000012)@h
  1017. ori r4, r4, (0x80000012)@l
  1018. li r5, CFG_FLASH_SIZE
  1019. 1: srawi. r5, r5, 1 /* r5 = r5 >> 1 */
  1020. addi r4, r4, 1
  1021. bne 1b
  1022. stw r4, LBLAWAR1(r3) /* LBLAWAR1 <= 8MB Flash Size */
  1023. blr
  1024. /* Though all the LBIU Local Access Windows and LBC Banks will be
  1025. * initialized in the C code, we'd better configure boot ROM's
  1026. * window 0 and bank 0 correctly at here.
  1027. */
  1028. remap_flash_by_law0:
  1029. /* Initialize the BR0 with the boot ROM starting address. */
  1030. lwz r4, BR0(r3)
  1031. li r5, 0x7FFF
  1032. and r4, r4, r5
  1033. lis r5, (CFG_FLASH_BASE & 0xFFFF8000)@h
  1034. ori r5, r5, (CFG_FLASH_BASE & 0xFFFF8000)@l
  1035. or r5, r5, r4
  1036. stw r5, BR0(r3) /* r5 <= (CFG_FLASH_BASE & 0xFFFF8000) | (BR0 & 0x00007FFF) */
  1037. lwz r4, OR0(r3)
  1038. lis r5, ~((CFG_FLASH_SIZE << 4) - 1)
  1039. or r4, r4, r5
  1040. stw r4, OR0(r3)
  1041. lis r4, (CFG_FLASH_BASE)@h
  1042. ori r4, r4, (CFG_FLASH_BASE)@l
  1043. stw r4, LBLAWBAR0(r3) /* LBLAWBAR0 <= CFG_FLASH_BASE */
  1044. /* Store 0x80000012 + log2(CFG_FLASH_SIZE) into LBLAWAR0 */
  1045. lis r4, (0x80000012)@h
  1046. ori r4, r4, (0x80000012)@l
  1047. li r5, CFG_FLASH_SIZE
  1048. 1: srawi. r5, r5, 1 /* r5 = r5 >> 1 */
  1049. addi r4, r4, 1
  1050. bne 1b
  1051. stw r4, LBLAWAR0(r3) /* LBLAWAR0 <= Flash Size */
  1052. xor r4, r4, r4
  1053. stw r4, LBLAWBAR1(r3)
  1054. stw r4, LBLAWAR1(r3) /* Off LBIU LAW1 */
  1055. blr
  1056. #endif /* CFG_FLASHBOOT */