board.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /*
  2. * (C) Copyright 2003
  3. * Josef Baumgartner <josef.baumgartner@telex.de>
  4. *
  5. * (C) Copyright 2000-2002
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <malloc.h>
  30. #include <devices.h>
  31. #ifdef CONFIG_M5272
  32. #include <asm/immap_5272.h>
  33. #endif
  34. #if (CONFIG_COMMANDS & CFG_CMD_IDE)
  35. #include <ide.h>
  36. #endif
  37. #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
  38. #include <scsi.h>
  39. #endif
  40. #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
  41. #include <kgdb.h>
  42. #endif
  43. #ifdef CONFIG_STATUS_LED
  44. #include <status_led.h>
  45. #endif
  46. #include <net.h>
  47. #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
  48. #include <cmd_bedbug.h>
  49. #endif
  50. #ifdef CFG_ALLOC_DPRAM
  51. #include <commproc.h>
  52. #endif
  53. #include <version.h>
  54. static char *failed = "*** failed ***\n";
  55. #ifdef CONFIG_PCU_E
  56. extern flash_info_t flash_info[];
  57. #endif
  58. #include <environment.h>
  59. #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
  60. (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
  61. defined(CFG_ENV_IS_IN_NVRAM)
  62. #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
  63. #else
  64. #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
  65. #endif
  66. extern ulong __init_end;
  67. extern ulong _end;
  68. extern void timer_init(void);
  69. #if defined(CONFIG_WATCHDOG)
  70. # define INIT_FUNC_WATCHDOG_INIT watchdog_init,
  71. # define WATCHDOG_DISABLE watchdog_disable
  72. extern int watchdog_init(void);
  73. extern int watchdog_disable(void);
  74. #else
  75. # define INIT_FUNC_WATCHDOG_INIT /* undef */
  76. # define WATCHDOG_DISABLE /* undef */
  77. #endif /* CONFIG_WATCHDOG */
  78. ulong monitor_flash_len;
  79. /*
  80. * Begin and End of memory area for malloc(), and current "brk"
  81. */
  82. static ulong mem_malloc_start = 0;
  83. static ulong mem_malloc_end = 0;
  84. static ulong mem_malloc_brk = 0;
  85. /************************************************************************
  86. * Utilities *
  87. ************************************************************************
  88. */
  89. /*
  90. * The Malloc area is immediately below the monitor copy in DRAM
  91. */
  92. static void mem_malloc_init (void)
  93. {
  94. DECLARE_GLOBAL_DATA_PTR;
  95. ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
  96. mem_malloc_end = dest_addr;
  97. mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
  98. mem_malloc_brk = mem_malloc_start;
  99. memset ((void *) mem_malloc_start,
  100. 0,
  101. mem_malloc_end - mem_malloc_start);
  102. }
  103. void *sbrk (ptrdiff_t increment)
  104. {
  105. ulong old = mem_malloc_brk;
  106. ulong new = old + increment;
  107. if ((new < mem_malloc_start) ||
  108. (new > mem_malloc_end) ) {
  109. return (NULL);
  110. }
  111. mem_malloc_brk = new;
  112. return ((void *)old);
  113. }
  114. char *strmhz(char *buf, long hz)
  115. {
  116. long l, n;
  117. long m;
  118. n = hz / 1000000L;
  119. l = sprintf (buf, "%ld", n);
  120. m = (hz % 1000000L) / 1000L;
  121. if (m != 0)
  122. sprintf (buf+l, ".%03ld", m);
  123. return (buf);
  124. }
  125. /*
  126. * All attempts to come up with a "common" initialization sequence
  127. * that works for all boards and architectures failed: some of the
  128. * requirements are just _too_ different. To get rid of the resulting
  129. * mess of board dependend #ifdef'ed code we now make the whole
  130. * initialization sequence configurable to the user.
  131. *
  132. * The requirements for any new initalization function is simple: it
  133. * receives a pointer to the "global data" structure as it's only
  134. * argument, and returns an integer return code, where 0 means
  135. * "continue" and != 0 means "fatal error, hang the system".
  136. */
  137. typedef int (init_fnc_t) (void);
  138. /************************************************************************
  139. * Init Utilities *
  140. ************************************************************************
  141. * Some of this code should be moved into the core functions,
  142. * but let's get it working (again) first...
  143. */
  144. static int init_baudrate (void)
  145. {
  146. DECLARE_GLOBAL_DATA_PTR;
  147. uchar tmp[64]; /* long enough for environment variables */
  148. int i = getenv_r ("baudrate", tmp, sizeof (tmp));
  149. gd->baudrate = (i > 0)
  150. ? (int) simple_strtoul (tmp, NULL, 10)
  151. : CONFIG_BAUDRATE;
  152. return (0);
  153. }
  154. /***********************************************************************/
  155. static int init_func_ram (void)
  156. {
  157. DECLARE_GLOBAL_DATA_PTR;
  158. int board_type = 0; /* use dummy arg */
  159. puts ("DRAM: ");
  160. if ((gd->ram_size = initdram (board_type)) > 0) {
  161. print_size (gd->ram_size, "\n");
  162. return (0);
  163. }
  164. puts (failed);
  165. return (1);
  166. }
  167. /***********************************************************************/
  168. /************************************************************************
  169. * Initialization sequence *
  170. ************************************************************************
  171. */
  172. init_fnc_t *init_sequence[] = {
  173. env_init,
  174. init_baudrate,
  175. serial_init,
  176. console_init_f,
  177. display_options,
  178. checkcpu,
  179. checkboard,
  180. init_func_ram,
  181. #if defined(CFG_DRAM_TEST)
  182. testdram,
  183. #endif /* CFG_DRAM_TEST */
  184. INIT_FUNC_WATCHDOG_INIT
  185. NULL, /* Terminate this list */
  186. };
  187. /************************************************************************
  188. *
  189. * This is the first part of the initialization sequence that is
  190. * implemented in C, but still running from ROM.
  191. *
  192. * The main purpose is to provide a (serial) console interface as
  193. * soon as possible (so we can see any error messages), and to
  194. * initialize the RAM so that we can relocate the monitor code to
  195. * RAM.
  196. *
  197. * Be aware of the restrictions: global data is read-only, BSS is not
  198. * initialized, and stack space is limited to a few kB.
  199. *
  200. ************************************************************************
  201. */
  202. void
  203. board_init_f (ulong bootflag)
  204. {
  205. DECLARE_GLOBAL_DATA_PTR;
  206. bd_t *bd;
  207. ulong len, addr, addr_sp;
  208. gd_t *id;
  209. init_fnc_t **init_fnc_ptr;
  210. #ifdef CONFIG_PRAM
  211. int i;
  212. ulong reg;
  213. uchar tmp[64]; /* long enough for environment variables */
  214. #endif
  215. /* Pointer is writable since we allocated a register for it */
  216. gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  217. /* compiler optimization barrier needed for GCC >= 3.4 */
  218. __asm__ __volatile__("": : :"memory");
  219. /* Clear initial global data */
  220. memset ((void *) gd, 0, sizeof (gd_t));
  221. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  222. if ((*init_fnc_ptr)() != 0) {
  223. hang ();
  224. }
  225. }
  226. /*
  227. * Now that we have DRAM mapped and working, we can
  228. * relocate the code and continue running from DRAM.
  229. *
  230. * Reserve memory at end of RAM for (top down in that order):
  231. * - protected RAM
  232. * - LCD framebuffer
  233. * - monitor code
  234. * - board info struct
  235. */
  236. len = (ulong)&_end - CFG_MONITOR_BASE;
  237. addr = CFG_SDRAM_BASE + gd->ram_size;
  238. #ifdef CONFIG_LOGBUFFER
  239. /* reserve kernel log buffer */
  240. addr -= (LOGBUFF_RESERVE);
  241. debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
  242. #endif
  243. #ifdef CONFIG_PRAM
  244. /*
  245. * reserve protected RAM
  246. */
  247. i = getenv_r ("pram", tmp, sizeof (tmp));
  248. reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
  249. addr -= (reg << 10); /* size is in kB */
  250. debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  251. #endif /* CONFIG_PRAM */
  252. /*
  253. * reserve memory for U-Boot code, data & bss
  254. * round down to next 4 kB limit
  255. */
  256. addr -= len;
  257. addr &= ~(4096 - 1);
  258. debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
  259. /*
  260. * reserve memory for malloc() arena
  261. */
  262. addr_sp = addr - TOTAL_MALLOC_LEN;
  263. debug ("Reserving %dk for malloc() at: %08lx\n",
  264. TOTAL_MALLOC_LEN >> 10, addr_sp);
  265. /*
  266. * (permanently) allocate a Board Info struct
  267. * and a permanent copy of the "global" data
  268. */
  269. addr_sp -= sizeof (bd_t);
  270. bd = (bd_t *) addr_sp;
  271. gd->bd = bd;
  272. debug ("Reserving %d Bytes for Board Info at: %08lx\n",
  273. sizeof (bd_t), addr_sp);
  274. addr_sp -= sizeof (gd_t);
  275. id = (gd_t *) addr_sp;
  276. debug ("Reserving %d Bytes for Global Data at: %08lx\n",
  277. sizeof (gd_t), addr_sp);
  278. /* Reserve memory for boot params. */
  279. addr_sp -= CFG_BOOTPARAMS_LEN;
  280. bd->bi_boot_params = addr_sp;
  281. debug ("Reserving %dk for boot parameters at: %08lx\n",
  282. CFG_BOOTPARAMS_LEN >> 10, addr_sp);
  283. /*
  284. * Finally, we set up a new (bigger) stack.
  285. *
  286. * Leave some safety gap for SP, force alignment on 16 byte boundary
  287. * Clear initial stack frame
  288. */
  289. addr_sp -= 16;
  290. addr_sp &= ~0xF;
  291. *((ulong *) addr_sp)-- = 0;
  292. *((ulong *) addr_sp)-- = 0;
  293. debug ("Stack Pointer at: %08lx\n", addr_sp);
  294. /*
  295. * Save local variables to board info struct
  296. */
  297. bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */
  298. bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
  299. bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */
  300. bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
  301. WATCHDOG_RESET ();
  302. bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
  303. bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
  304. bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
  305. #ifdef CFG_EXTBDINFO
  306. strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
  307. strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
  308. #endif
  309. WATCHDOG_RESET ();
  310. #ifdef CONFIG_POST
  311. post_bootmode_init();
  312. post_run (NULL, POST_ROM | post_bootmode_get(0));
  313. #endif
  314. WATCHDOG_RESET();
  315. memcpy (id, (void *)gd, sizeof (gd_t));
  316. debug ("Start relocate of code from %08x to %08lx\n", CFG_MONITOR_BASE, addr);
  317. relocate_code (addr_sp, id, addr);
  318. /* NOTREACHED - jump_to_ram() does not return */
  319. }
  320. /************************************************************************
  321. *
  322. * This is the next part if the initialization sequence: we are now
  323. * running from RAM and have a "normal" C environment, i. e. global
  324. * data can be written, BSS has been cleared, the stack size in not
  325. * that critical any more, etc.
  326. *
  327. ************************************************************************
  328. */
  329. void board_init_r (gd_t *id, ulong dest_addr)
  330. {
  331. DECLARE_GLOBAL_DATA_PTR;
  332. cmd_tbl_t *cmdtp;
  333. char *s, *e;
  334. bd_t *bd;
  335. int i;
  336. extern void malloc_bin_reloc (void);
  337. #ifndef CFG_ENV_IS_NOWHERE
  338. extern char * env_name_spec;
  339. #endif
  340. #ifndef CFG_NO_FLASH
  341. ulong flash_size;
  342. #endif
  343. gd = id; /* initialize RAM version of global data */
  344. bd = gd->bd;
  345. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  346. debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  347. WATCHDOG_RESET ();
  348. gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
  349. monitor_flash_len = (ulong)&__init_end - dest_addr;
  350. /*
  351. * We have to relocate the command table manually
  352. */
  353. for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
  354. ulong addr;
  355. addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
  356. #if 0
  357. printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
  358. cmdtp->name, (ulong) (cmdtp->cmd), addr);
  359. #endif
  360. cmdtp->cmd =
  361. (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
  362. addr = (ulong)(cmdtp->name) + gd->reloc_off;
  363. cmdtp->name = (char *)addr;
  364. if (cmdtp->usage) {
  365. addr = (ulong)(cmdtp->usage) + gd->reloc_off;
  366. cmdtp->usage = (char *)addr;
  367. }
  368. #ifdef CFG_LONGHELP
  369. if (cmdtp->help) {
  370. addr = (ulong)(cmdtp->help) + gd->reloc_off;
  371. cmdtp->help = (char *)addr;
  372. }
  373. #endif
  374. }
  375. /* there are some other pointer constants we must deal with */
  376. #ifndef CFG_ENV_IS_NOWHERE
  377. env_name_spec += gd->reloc_off;
  378. #endif
  379. WATCHDOG_RESET ();
  380. #ifdef CONFIG_LOGBUFFER
  381. logbuff_init_ptrs ();
  382. #endif
  383. #ifdef CONFIG_POST
  384. post_output_backlog ();
  385. post_reloc ();
  386. #endif
  387. WATCHDOG_RESET();
  388. #if 0
  389. /* instruction cache enabled in cpu_init_f() for faster relocation */
  390. icache_enable (); /* it's time to enable the instruction cache */
  391. #endif
  392. /*
  393. * Setup trap handlers
  394. */
  395. trap_init (0);
  396. #if !defined(CFG_NO_FLASH)
  397. puts ("FLASH: ");
  398. if ((flash_size = flash_init ()) > 0) {
  399. # ifdef CFG_FLASH_CHECKSUM
  400. print_size (flash_size, "");
  401. /*
  402. * Compute and print flash CRC if flashchecksum is set to 'y'
  403. *
  404. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  405. */
  406. s = getenv ("flashchecksum");
  407. if (s && (*s == 'y')) {
  408. printf (" CRC: %08lX",
  409. crc32 (0,
  410. (const unsigned char *) CFG_FLASH_BASE,
  411. flash_size)
  412. );
  413. }
  414. putc ('\n');
  415. # else /* !CFG_FLASH_CHECKSUM */
  416. print_size (flash_size, "\n");
  417. # endif /* CFG_FLASH_CHECKSUM */
  418. } else {
  419. puts (failed);
  420. hang ();
  421. }
  422. bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */
  423. bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
  424. bd->bi_flashoffset = 0;
  425. #else /* CFG_NO_FLASH */
  426. bd->bi_flashsize = 0;
  427. bd->bi_flashstart = 0;
  428. bd->bi_flashoffset = 0;
  429. #endif /* !CFG_NO_FLASH */
  430. WATCHDOG_RESET ();
  431. /* initialize higher level parts of CPU like time base and timers */
  432. cpu_init_r ();
  433. WATCHDOG_RESET ();
  434. /* initialize malloc() area */
  435. mem_malloc_init ();
  436. malloc_bin_reloc ();
  437. #ifdef CONFIG_SPI
  438. # if !defined(CFG_ENV_IS_IN_EEPROM)
  439. spi_init_f ();
  440. # endif
  441. spi_init_r ();
  442. #endif
  443. /* relocate environment function pointers etc. */
  444. env_relocate ();
  445. /*
  446. * Fill in missing fields of bd_info.
  447. * We do this here, where we have "normal" access to the
  448. * environment; we used to do this still running from ROM,
  449. * where had to use getenv_r(), which can be pretty slow when
  450. * the environment is in EEPROM.
  451. */
  452. s = getenv ("ethaddr");
  453. for (i = 0; i < 6; ++i) {
  454. bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  455. if (s)
  456. s = (*e) ? e + 1 : e;
  457. }
  458. /* IP Address */
  459. bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
  460. WATCHDOG_RESET ();
  461. /** leave this here (after malloc(), environment and PCI are working) **/
  462. /* Initialize devices */
  463. devices_init ();
  464. /* Initialize the jump table for applications */
  465. jumptable_init ();
  466. /* Initialize the console (after the relocation and devices init) */
  467. console_init_r ();
  468. #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
  469. WATCHDOG_RESET ();
  470. puts ("KGDB: ");
  471. kgdb_init ();
  472. #endif
  473. debug ("U-Boot relocated to %08lx\n", dest_addr);
  474. /*
  475. * Enable Interrupts
  476. */
  477. interrupt_init ();
  478. /* Must happen after interrupts are initialized since
  479. * an irq handler gets installed
  480. */
  481. timer_init();
  482. #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
  483. serial_buffered_init();
  484. #endif
  485. #ifdef CONFIG_STATUS_LED
  486. status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
  487. #endif
  488. udelay (20);
  489. set_timer (0);
  490. /* Insert function pointers now that we have relocated the code */
  491. /* Initialize from environment */
  492. if ((s = getenv ("loadaddr")) != NULL) {
  493. load_addr = simple_strtoul (s, NULL, 16);
  494. }
  495. #if (CONFIG_COMMANDS & CFG_CMD_NET)
  496. if ((s = getenv ("bootfile")) != NULL) {
  497. copy_filename (BootFile, s, sizeof (BootFile));
  498. }
  499. #endif /* CFG_CMD_NET */
  500. WATCHDOG_RESET ();
  501. #if (CONFIG_COMMANDS & CFG_CMD_DOC)
  502. WATCHDOG_RESET ();
  503. puts ("DOC: ");
  504. doc_init ();
  505. #endif
  506. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  507. WATCHDOG_RESET ();
  508. puts ("NAND:");
  509. nand_init(); /* go init the NAND */
  510. #endif
  511. #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(FEC_ENET)
  512. WATCHDOG_RESET();
  513. eth_init(bd);
  514. #endif
  515. #ifdef CONFIG_POST
  516. post_run (NULL, POST_RAM | post_bootmode_get(0));
  517. #endif
  518. #ifdef CONFIG_LAST_STAGE_INIT
  519. WATCHDOG_RESET ();
  520. /*
  521. * Some parts can be only initialized if all others (like
  522. * Interrupts) are up and running (i.e. the PC-style ISA
  523. * keyboard).
  524. */
  525. last_stage_init ();
  526. #endif
  527. #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
  528. WATCHDOG_RESET ();
  529. bedbug_init ();
  530. #endif
  531. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  532. /*
  533. * Export available size of memory for Linux,
  534. * taking into account the protected RAM at top of memory
  535. */
  536. {
  537. ulong pram;
  538. uchar memsz[32];
  539. #ifdef CONFIG_PRAM
  540. char *s;
  541. if ((s = getenv ("pram")) != NULL) {
  542. pram = simple_strtoul (s, NULL, 10);
  543. } else {
  544. pram = CONFIG_PRAM;
  545. }
  546. #else
  547. pram=0;
  548. #endif
  549. #ifdef CONFIG_LOGBUFFER
  550. /* Also take the logbuffer into account (pram is in kB) */
  551. pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
  552. #endif
  553. sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
  554. setenv ("mem", memsz);
  555. }
  556. #endif
  557. #ifdef CONFIG_MODEM_SUPPORT
  558. {
  559. extern int do_mdm_init;
  560. do_mdm_init = gd->do_mdm_init;
  561. }
  562. #endif
  563. #ifdef CONFIG_WATCHDOG
  564. /* disable watchdog if environment is set */
  565. if ((s = getenv ("watchdog")) != NULL) {
  566. if (strncmp (s, "off", 3) == 0) {
  567. WATCHDOG_DISABLE ();
  568. }
  569. }
  570. #endif /* CONFIG_WATCHDOG*/
  571. /* Initialization complete - start the monitor */
  572. /* main_loop() can return to retry autoboot, if so just run it again. */
  573. for (;;) {
  574. WATCHDOG_RESET ();
  575. main_loop ();
  576. }
  577. /* NOTREACHED - no way out of command loop except booting */
  578. }
  579. void hang(void)
  580. {
  581. puts ("### ERROR ### Please RESET the board ###\n");
  582. for (;;);
  583. }