board.c 17 KB

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