board.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. * (C) Copyright 2002-2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2002
  6. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Marius Groeger <mgroeger@sysgo.de>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. /*
  28. * To match the U-Boot user interface on ARM platforms to the U-Boot
  29. * standard (as on PPC platforms), some messages with debug character
  30. * are removed from the default U-Boot build.
  31. *
  32. * Define DEBUG here if you want additional info as shown below
  33. * printed upon startup:
  34. *
  35. * U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274
  36. * IRQ Stack: 00ebff7c
  37. * FIQ Stack: 00ebef7c
  38. */
  39. #include <common.h>
  40. #include <command.h>
  41. #include <malloc.h>
  42. #include <stdio_dev.h>
  43. #include <version.h>
  44. #include <net.h>
  45. #include <serial.h>
  46. #include <nand.h>
  47. #include <onenand_uboot.h>
  48. #include <mmc.h>
  49. #ifdef CONFIG_BITBANGMII
  50. #include <miiphy.h>
  51. #endif
  52. #ifdef CONFIG_DRIVER_SMC91111
  53. #include "../drivers/net/smc91111.h"
  54. #endif
  55. #ifdef CONFIG_DRIVER_LAN91C96
  56. #include "../drivers/net/lan91c96.h"
  57. #endif
  58. DECLARE_GLOBAL_DATA_PTR;
  59. ulong monitor_flash_len;
  60. #ifdef CONFIG_HAS_DATAFLASH
  61. extern int AT91F_DataflashInit(void);
  62. extern void dataflash_print_info(void);
  63. #endif
  64. #ifdef CONFIG_DRIVER_RTL8019
  65. extern void rtl8019_get_enetaddr (uchar * addr);
  66. #endif
  67. #if defined(CONFIG_HARD_I2C) || \
  68. defined(CONFIG_SOFT_I2C)
  69. #include <i2c.h>
  70. #endif
  71. /************************************************************************
  72. * Coloured LED functionality
  73. ************************************************************************
  74. * May be supplied by boards if desired
  75. */
  76. void inline __coloured_LED_init (void) {}
  77. void coloured_LED_init (void) __attribute__((weak, alias("__coloured_LED_init")));
  78. void inline __red_LED_on (void) {}
  79. void red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));
  80. void inline __red_LED_off(void) {}
  81. void red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));
  82. void inline __green_LED_on(void) {}
  83. void green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));
  84. void inline __green_LED_off(void) {}
  85. void green_LED_off(void) __attribute__((weak, alias("__green_LED_off")));
  86. void inline __yellow_LED_on(void) {}
  87. void yellow_LED_on(void) __attribute__((weak, alias("__yellow_LED_on")));
  88. void inline __yellow_LED_off(void) {}
  89. void yellow_LED_off(void) __attribute__((weak, alias("__yellow_LED_off")));
  90. void inline __blue_LED_on(void) {}
  91. void blue_LED_on(void) __attribute__((weak, alias("__blue_LED_on")));
  92. void inline __blue_LED_off(void) {}
  93. void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off")));
  94. /************************************************************************
  95. * Init Utilities *
  96. ************************************************************************
  97. * Some of this code should be moved into the core functions,
  98. * or dropped completely,
  99. * but let's get it working (again) first...
  100. */
  101. #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE)
  102. #define CONFIG_BAUDRATE 115200
  103. #endif
  104. static int init_baudrate (void)
  105. {
  106. char tmp[64]; /* long enough for environment variables */
  107. int i = getenv_f("baudrate", tmp, sizeof (tmp));
  108. gd->baudrate = (i > 0)
  109. ? (int) simple_strtoul (tmp, NULL, 10)
  110. : CONFIG_BAUDRATE;
  111. return (0);
  112. }
  113. static int display_banner (void)
  114. {
  115. printf ("\n\n%s\n\n", version_string);
  116. debug ("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
  117. _TEXT_BASE,
  118. _bss_start_ofs+_TEXT_BASE, _bss_end_ofs+_TEXT_BASE);
  119. #ifdef CONFIG_MODEM_SUPPORT
  120. debug ("Modem Support enabled\n");
  121. #endif
  122. #ifdef CONFIG_USE_IRQ
  123. debug ("IRQ Stack: %08lx\n", IRQ_STACK_START);
  124. debug ("FIQ Stack: %08lx\n", FIQ_STACK_START);
  125. #endif
  126. return (0);
  127. }
  128. /*
  129. * WARNING: this code looks "cleaner" than the PowerPC version, but
  130. * has the disadvantage that you either get nothing, or everything.
  131. * On PowerPC, you might see "DRAM: " before the system hangs - which
  132. * gives a simple yet clear indication which part of the
  133. * initialization if failing.
  134. */
  135. static int display_dram_config (void)
  136. {
  137. int i;
  138. #ifdef DEBUG
  139. puts ("RAM Configuration:\n");
  140. for(i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
  141. printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
  142. print_size (gd->bd->bi_dram[i].size, "\n");
  143. }
  144. #else
  145. ulong size = 0;
  146. for (i=0; i<CONFIG_NR_DRAM_BANKS; i++) {
  147. size += gd->bd->bi_dram[i].size;
  148. }
  149. puts("DRAM: ");
  150. print_size(size, "\n");
  151. #endif
  152. return (0);
  153. }
  154. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  155. static int init_func_i2c (void)
  156. {
  157. puts ("I2C: ");
  158. i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  159. puts ("ready\n");
  160. return (0);
  161. }
  162. #endif
  163. #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
  164. #include <pci.h>
  165. static int arm_pci_init(void)
  166. {
  167. pci_init();
  168. return 0;
  169. }
  170. #endif /* CONFIG_CMD_PCI || CONFIG_PCI */
  171. /*
  172. * Breathe some life into the board...
  173. *
  174. * Initialize a serial port as console, and carry out some hardware
  175. * tests.
  176. *
  177. * The first part of initialization is running from Flash memory;
  178. * its main purpose is to initialize the RAM so that we
  179. * can relocate the monitor code to RAM.
  180. */
  181. /*
  182. * All attempts to come up with a "common" initialization sequence
  183. * that works for all boards and architectures failed: some of the
  184. * requirements are just _too_ different. To get rid of the resulting
  185. * mess of board dependent #ifdef'ed code we now make the whole
  186. * initialization sequence configurable to the user.
  187. *
  188. * The requirements for any new initalization function is simple: it
  189. * receives a pointer to the "global data" structure as it's only
  190. * argument, and returns an integer return code, where 0 means
  191. * "continue" and != 0 means "fatal error, hang the system".
  192. */
  193. typedef int (init_fnc_t) (void);
  194. int print_cpuinfo (void);
  195. void __dram_init_banksize(void)
  196. {
  197. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  198. gd->bd->bi_dram[0].size = gd->ram_size;
  199. }
  200. void dram_init_banksize(void)
  201. __attribute__((weak, alias("__dram_init_banksize")));
  202. init_fnc_t *init_sequence[] = {
  203. #if defined(CONFIG_ARCH_CPU_INIT)
  204. arch_cpu_init, /* basic arch cpu dependent setup */
  205. #endif
  206. #if defined(CONFIG_BOARD_EARLY_INIT_F)
  207. board_early_init_f,
  208. #endif
  209. timer_init, /* initialize timer */
  210. #ifdef CONFIG_FSL_ESDHC
  211. get_clocks,
  212. #endif
  213. env_init, /* initialize environment */
  214. init_baudrate, /* initialze baudrate settings */
  215. serial_init, /* serial communications setup */
  216. console_init_f, /* stage 1 init of console */
  217. display_banner, /* say that we are here */
  218. #if defined(CONFIG_DISPLAY_CPUINFO)
  219. print_cpuinfo, /* display cpu info (and speed) */
  220. #endif
  221. #if defined(CONFIG_DISPLAY_BOARDINFO)
  222. checkboard, /* display board info */
  223. #endif
  224. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  225. init_func_i2c,
  226. #endif
  227. dram_init, /* configure available RAM banks */
  228. NULL,
  229. };
  230. void board_init_f (ulong bootflag)
  231. {
  232. bd_t *bd;
  233. init_fnc_t **init_fnc_ptr;
  234. gd_t *id;
  235. ulong addr, addr_sp;
  236. /* Pointer is writable since we allocated a register for it */
  237. gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
  238. /* compiler optimization barrier needed for GCC >= 3.4 */
  239. __asm__ __volatile__("": : :"memory");
  240. memset ((void*)gd, 0, sizeof (gd_t));
  241. gd->mon_len = _bss_end_ofs;
  242. #ifdef CONFIG_MACH_TYPE
  243. gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
  244. #endif
  245. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  246. if ((*init_fnc_ptr)() != 0) {
  247. hang ();
  248. }
  249. }
  250. debug ("monitor len: %08lX\n", gd->mon_len);
  251. /*
  252. * Ram is setup, size stored in gd !!
  253. */
  254. debug ("ramsize: %08lX\n", gd->ram_size);
  255. #if defined(CONFIG_SYS_MEM_TOP_HIDE)
  256. /*
  257. * Subtract specified amount of memory to hide so that it won't
  258. * get "touched" at all by U-Boot. By fixing up gd->ram_size
  259. * the Linux kernel should now get passed the now "corrected"
  260. * memory size and won't touch it either. This should work
  261. * for arch/ppc and arch/powerpc. Only Linux board ports in
  262. * arch/powerpc with bootwrapper support, that recalculate the
  263. * memory size from the SDRAM controller setup will have to
  264. * get fixed.
  265. */
  266. gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
  267. #endif
  268. addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
  269. #ifdef CONFIG_LOGBUFFER
  270. #ifndef CONFIG_ALT_LB_ADDR
  271. /* reserve kernel log buffer */
  272. addr -= (LOGBUFF_RESERVE);
  273. debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
  274. #endif
  275. #endif
  276. #ifdef CONFIG_PRAM
  277. /*
  278. * reserve protected RAM
  279. */
  280. i = getenv_r ("pram", (char *)tmp, sizeof (tmp));
  281. reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;
  282. addr -= (reg << 10); /* size is in kB */
  283. debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  284. #endif /* CONFIG_PRAM */
  285. #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  286. /* reserve TLB table */
  287. addr -= (4096 * 4);
  288. /* round down to next 64 kB limit */
  289. addr &= ~(0x10000 - 1);
  290. gd->tlb_addr = addr;
  291. debug ("TLB table at: %08lx\n", addr);
  292. #endif
  293. /* round down to next 4 kB limit */
  294. addr &= ~(4096 - 1);
  295. debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
  296. #ifdef CONFIG_LCD
  297. #ifdef CONFIG_FB_ADDR
  298. gd->fb_base = CONFIG_FB_ADDR;
  299. #else
  300. /* reserve memory for LCD display (always full pages) */
  301. addr = lcd_setmem (addr);
  302. gd->fb_base = addr;
  303. #endif /* CONFIG_FB_ADDR */
  304. #endif /* CONFIG_LCD */
  305. /*
  306. * reserve memory for U-Boot code, data & bss
  307. * round down to next 4 kB limit
  308. */
  309. addr -= gd->mon_len;
  310. addr &= ~(4096 - 1);
  311. debug ("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
  312. #ifndef CONFIG_SPL_BUILD
  313. /*
  314. * reserve memory for malloc() arena
  315. */
  316. addr_sp = addr - TOTAL_MALLOC_LEN;
  317. debug ("Reserving %dk for malloc() at: %08lx\n",
  318. TOTAL_MALLOC_LEN >> 10, addr_sp);
  319. /*
  320. * (permanently) allocate a Board Info struct
  321. * and a permanent copy of the "global" data
  322. */
  323. addr_sp -= sizeof (bd_t);
  324. bd = (bd_t *) addr_sp;
  325. gd->bd = bd;
  326. debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
  327. sizeof (bd_t), addr_sp);
  328. addr_sp -= sizeof (gd_t);
  329. id = (gd_t *) addr_sp;
  330. debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
  331. sizeof (gd_t), addr_sp);
  332. /* setup stackpointer for exeptions */
  333. gd->irq_sp = addr_sp;
  334. #ifdef CONFIG_USE_IRQ
  335. addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);
  336. debug ("Reserving %zu Bytes for IRQ stack at: %08lx\n",
  337. CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);
  338. #endif
  339. /* leave 3 words for abort-stack */
  340. addr_sp -= 12;
  341. /* 8-byte alignment for ABI compliance */
  342. addr_sp &= ~0x07;
  343. #else
  344. addr_sp += 128; /* leave 32 words for abort-stack */
  345. gd->irq_sp = addr_sp;
  346. #endif
  347. debug ("New Stack Pointer is: %08lx\n", addr_sp);
  348. #ifdef CONFIG_POST
  349. post_bootmode_init();
  350. post_run (NULL, POST_ROM | post_bootmode_get(0));
  351. #endif
  352. gd->bd->bi_baudrate = gd->baudrate;
  353. /* Ram ist board specific, so move it to board code ... */
  354. dram_init_banksize();
  355. display_dram_config(); /* and display it */
  356. gd->relocaddr = addr;
  357. gd->start_addr_sp = addr_sp;
  358. gd->reloc_off = addr - _TEXT_BASE;
  359. debug ("relocation Offset is: %08lx\n", gd->reloc_off);
  360. memcpy (id, (void *)gd, sizeof (gd_t));
  361. relocate_code (addr_sp, id, addr);
  362. /* NOTREACHED - relocate_code() does not return */
  363. }
  364. #if !defined(CONFIG_SYS_NO_FLASH)
  365. static char *failed = "*** failed ***\n";
  366. #endif
  367. /************************************************************************
  368. *
  369. * This is the next part if the initialization sequence: we are now
  370. * running from RAM and have a "normal" C environment, i. e. global
  371. * data can be written, BSS has been cleared, the stack size in not
  372. * that critical any more, etc.
  373. *
  374. ************************************************************************
  375. */
  376. void board_init_r (gd_t *id, ulong dest_addr)
  377. {
  378. char *s;
  379. bd_t *bd;
  380. ulong malloc_start;
  381. #if !defined(CONFIG_SYS_NO_FLASH)
  382. ulong flash_size;
  383. #endif
  384. gd = id;
  385. bd = gd->bd;
  386. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  387. monitor_flash_len = _end_ofs;
  388. /*
  389. * Enable D$:
  390. * I$, if needed, must be already enabled in start.S
  391. */
  392. dcache_enable();
  393. debug ("monitor flash len: %08lX\n", monitor_flash_len);
  394. board_init(); /* Setup chipselects */
  395. #ifdef CONFIG_SERIAL_MULTI
  396. serial_initialize();
  397. #endif
  398. debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  399. #ifdef CONFIG_LOGBUFFER
  400. logbuff_init_ptrs ();
  401. #endif
  402. #ifdef CONFIG_POST
  403. post_output_backlog ();
  404. #endif
  405. /* The Malloc area is immediately below the monitor copy in DRAM */
  406. malloc_start = dest_addr - TOTAL_MALLOC_LEN;
  407. mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
  408. #if !defined(CONFIG_SYS_NO_FLASH)
  409. puts ("Flash: ");
  410. if ((flash_size = flash_init ()) > 0) {
  411. # ifdef CONFIG_SYS_FLASH_CHECKSUM
  412. print_size (flash_size, "");
  413. /*
  414. * Compute and print flash CRC if flashchecksum is set to 'y'
  415. *
  416. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  417. */
  418. s = getenv ("flashchecksum");
  419. if (s && (*s == 'y')) {
  420. printf (" CRC: %08X",
  421. crc32 (0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)
  422. );
  423. }
  424. putc ('\n');
  425. # else /* !CONFIG_SYS_FLASH_CHECKSUM */
  426. print_size (flash_size, "\n");
  427. # endif /* CONFIG_SYS_FLASH_CHECKSUM */
  428. } else {
  429. puts (failed);
  430. hang ();
  431. }
  432. #endif
  433. #if defined(CONFIG_CMD_NAND)
  434. puts ("NAND: ");
  435. nand_init(); /* go init the NAND */
  436. #endif
  437. #if defined(CONFIG_CMD_ONENAND)
  438. onenand_init();
  439. #endif
  440. #ifdef CONFIG_GENERIC_MMC
  441. puts("MMC: ");
  442. mmc_initialize(bd);
  443. #endif
  444. #ifdef CONFIG_HAS_DATAFLASH
  445. AT91F_DataflashInit();
  446. dataflash_print_info();
  447. #endif
  448. /* initialize environment */
  449. env_relocate ();
  450. #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
  451. arm_pci_init();
  452. #endif
  453. /* IP Address */
  454. gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
  455. stdio_init (); /* get the devices list going. */
  456. jumptable_init ();
  457. #if defined(CONFIG_API)
  458. /* Initialize API */
  459. api_init ();
  460. #endif
  461. console_init_r (); /* fully init console as a device */
  462. #if defined(CONFIG_ARCH_MISC_INIT)
  463. /* miscellaneous arch dependent initialisations */
  464. arch_misc_init ();
  465. #endif
  466. #if defined(CONFIG_MISC_INIT_R)
  467. /* miscellaneous platform dependent initialisations */
  468. misc_init_r ();
  469. #endif
  470. /* set up exceptions */
  471. interrupt_init ();
  472. /* enable exceptions */
  473. enable_interrupts ();
  474. /* Perform network card initialisation if necessary */
  475. #if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
  476. /* XXX: this needs to be moved to board init */
  477. if (getenv ("ethaddr")) {
  478. uchar enetaddr[6];
  479. eth_getenv_enetaddr("ethaddr", enetaddr);
  480. smc_set_mac_addr(enetaddr);
  481. }
  482. #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
  483. /* Initialize from environment */
  484. if ((s = getenv ("loadaddr")) != NULL) {
  485. load_addr = simple_strtoul (s, NULL, 16);
  486. }
  487. #if defined(CONFIG_CMD_NET)
  488. if ((s = getenv ("bootfile")) != NULL) {
  489. copy_filename (BootFile, s, sizeof (BootFile));
  490. }
  491. #endif
  492. #ifdef BOARD_LATE_INIT
  493. board_late_init ();
  494. #endif
  495. #ifdef CONFIG_BITBANGMII
  496. bb_miiphy_init();
  497. #endif
  498. #if defined(CONFIG_CMD_NET)
  499. #if defined(CONFIG_NET_MULTI)
  500. puts ("Net: ");
  501. #endif
  502. eth_initialize(gd->bd);
  503. #if defined(CONFIG_RESET_PHY_R)
  504. debug ("Reset Ethernet PHY\n");
  505. reset_phy();
  506. #endif
  507. #endif
  508. #ifdef CONFIG_POST
  509. post_run (NULL, POST_RAM | post_bootmode_get(0));
  510. #endif
  511. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  512. /*
  513. * Export available size of memory for Linux,
  514. * taking into account the protected RAM at top of memory
  515. */
  516. {
  517. ulong pram;
  518. uchar memsz[32];
  519. #ifdef CONFIG_PRAM
  520. char *s;
  521. if ((s = getenv ("pram")) != NULL) {
  522. pram = simple_strtoul (s, NULL, 10);
  523. } else {
  524. pram = CONFIG_PRAM;
  525. }
  526. #else
  527. pram=0;
  528. #endif
  529. #ifdef CONFIG_LOGBUFFER
  530. #ifndef CONFIG_ALT_LB_ADDR
  531. /* Also take the logbuffer into account (pram is in kB) */
  532. pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
  533. #endif
  534. #endif
  535. sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
  536. setenv ("mem", (char *)memsz);
  537. }
  538. #endif
  539. /* main_loop() can return to retry autoboot, if so just run it again. */
  540. for (;;) {
  541. main_loop ();
  542. }
  543. /* NOTREACHED - no way out of command loop except booting */
  544. }
  545. void hang (void)
  546. {
  547. puts ("### ERROR ### Please RESET the board ###\n");
  548. for (;;);
  549. }