board.c 16 KB

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