board.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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 <stdio_dev.h>
  31. #include <linux/compiler.h>
  32. #include <asm/immap.h>
  33. #if defined(CONFIG_CMD_IDE)
  34. #include <ide.h>
  35. #endif
  36. #if defined(CONFIG_CMD_SCSI)
  37. #include <scsi.h>
  38. #endif
  39. #if defined(CONFIG_CMD_KGDB)
  40. #include <kgdb.h>
  41. #endif
  42. #ifdef CONFIG_STATUS_LED
  43. #include <status_led.h>
  44. #endif
  45. #include <net.h>
  46. #include <serial.h>
  47. #if defined(CONFIG_CMD_BEDBUG)
  48. #include <cmd_bedbug.h>
  49. #endif
  50. #ifdef CONFIG_SYS_ALLOC_DPRAM
  51. #include <commproc.h>
  52. #endif
  53. #include <version.h>
  54. #if defined(CONFIG_HARD_I2C) || \
  55. defined(CONFIG_SOFT_I2C)
  56. #include <i2c.h>
  57. #endif
  58. #ifdef CONFIG_CMD_SPI
  59. #include <spi.h>
  60. #endif
  61. #ifdef CONFIG_BITBANGMII
  62. #include <miiphy.h>
  63. #endif
  64. #include <nand.h>
  65. DECLARE_GLOBAL_DATA_PTR;
  66. static char *failed = "*** failed ***\n";
  67. #include <environment.h>
  68. extern ulong __init_end;
  69. extern ulong __bss_end;
  70. #if defined(CONFIG_WATCHDOG)
  71. # undef INIT_FUNC_WATCHDOG_INIT
  72. # define INIT_FUNC_WATCHDOG_INIT watchdog_init,
  73. # define WATCHDOG_DISABLE watchdog_disable
  74. extern int watchdog_init(void);
  75. extern int watchdog_disable(void);
  76. #else
  77. # define INIT_FUNC_WATCHDOG_INIT /* undef */
  78. # define WATCHDOG_DISABLE /* undef */
  79. #endif /* CONFIG_WATCHDOG */
  80. ulong monitor_flash_len;
  81. /************************************************************************
  82. * Utilities *
  83. ************************************************************************
  84. */
  85. /*
  86. * All attempts to come up with a "common" initialization sequence
  87. * that works for all boards and architectures failed: some of the
  88. * requirements are just _too_ different. To get rid of the resulting
  89. * mess of board dependend #ifdef'ed code we now make the whole
  90. * initialization sequence configurable to the user.
  91. *
  92. * The requirements for any new initalization function is simple: it
  93. * receives a pointer to the "global data" structure as it's only
  94. * argument, and returns an integer return code, where 0 means
  95. * "continue" and != 0 means "fatal error, hang the system".
  96. */
  97. typedef int (init_fnc_t) (void);
  98. /************************************************************************
  99. * Init Utilities
  100. ************************************************************************
  101. * Some of this code should be moved into the core functions,
  102. * but let's get it working (again) first...
  103. */
  104. static int init_baudrate (void)
  105. {
  106. gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
  107. return 0;
  108. }
  109. /***********************************************************************/
  110. static int init_func_ram (void)
  111. {
  112. int board_type = 0; /* use dummy arg */
  113. puts ("DRAM: ");
  114. if ((gd->ram_size = initdram (board_type)) > 0) {
  115. print_size (gd->ram_size, "\n");
  116. return (0);
  117. }
  118. puts (failed);
  119. return (1);
  120. }
  121. /***********************************************************************/
  122. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || \
  123. defined(CONFIG_SYS_I2C)
  124. static int init_func_i2c (void)
  125. {
  126. puts ("I2C: ");
  127. #ifdef CONFIG_SYS_I2C
  128. i2c_init_all();
  129. #else
  130. i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  131. #endif
  132. puts ("ready\n");
  133. return (0);
  134. }
  135. #endif
  136. #if defined(CONFIG_HARD_SPI)
  137. static int init_func_spi (void)
  138. {
  139. puts ("SPI: ");
  140. spi_init ();
  141. puts ("ready\n");
  142. return (0);
  143. }
  144. #endif
  145. /***********************************************************************/
  146. /************************************************************************
  147. * Initialization sequence *
  148. ************************************************************************
  149. */
  150. init_fnc_t *init_sequence[] = {
  151. get_clocks,
  152. env_init,
  153. init_baudrate,
  154. serial_init,
  155. console_init_f,
  156. display_options,
  157. checkcpu,
  158. checkboard,
  159. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || \
  160. defined(CONFIG_SYS_I2C)
  161. init_func_i2c,
  162. #endif
  163. #if defined(CONFIG_HARD_SPI)
  164. init_func_spi,
  165. #endif
  166. init_func_ram,
  167. #if defined(CONFIG_SYS_DRAM_TEST)
  168. testdram,
  169. #endif /* CONFIG_SYS_DRAM_TEST */
  170. INIT_FUNC_WATCHDOG_INIT
  171. NULL, /* Terminate this list */
  172. };
  173. /************************************************************************
  174. *
  175. * This is the first part of the initialization sequence that is
  176. * implemented in C, but still running from ROM.
  177. *
  178. * The main purpose is to provide a (serial) console interface as
  179. * soon as possible (so we can see any error messages), and to
  180. * initialize the RAM so that we can relocate the monitor code to
  181. * RAM.
  182. *
  183. * Be aware of the restrictions: global data is read-only, BSS is not
  184. * initialized, and stack space is limited to a few kB.
  185. *
  186. ************************************************************************
  187. */
  188. void
  189. board_init_f (ulong bootflag)
  190. {
  191. bd_t *bd;
  192. ulong len, addr, addr_sp;
  193. ulong *paddr;
  194. gd_t *id;
  195. init_fnc_t **init_fnc_ptr;
  196. #ifdef CONFIG_PRAM
  197. ulong reg;
  198. #endif
  199. /* Pointer is writable since we allocated a register for it */
  200. gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
  201. /* compiler optimization barrier needed for GCC >= 3.4 */
  202. __asm__ __volatile__("": : :"memory");
  203. /* Clear initial global data */
  204. memset ((void *) gd, 0, sizeof (gd_t));
  205. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  206. if ((*init_fnc_ptr)() != 0) {
  207. hang ();
  208. }
  209. }
  210. /*
  211. * Now that we have DRAM mapped and working, we can
  212. * relocate the code and continue running from DRAM.
  213. *
  214. * Reserve memory at end of RAM for (top down in that order):
  215. * - protected RAM
  216. * - LCD framebuffer
  217. * - monitor code
  218. * - board info struct
  219. */
  220. len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
  221. addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
  222. #ifdef CONFIG_LOGBUFFER
  223. /* reserve kernel log buffer */
  224. addr -= (LOGBUFF_RESERVE);
  225. debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
  226. #endif
  227. #ifdef CONFIG_PRAM
  228. /*
  229. * reserve protected RAM
  230. */
  231. reg = getenv_ulong("pram", 10, CONFIG_PRAM);
  232. addr -= (reg << 10); /* size is in kB */
  233. debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  234. #endif /* CONFIG_PRAM */
  235. /* round down to next 4 kB limit */
  236. addr &= ~(4096 - 1);
  237. debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
  238. #ifdef CONFIG_LCD
  239. #ifdef CONFIG_FB_ADDR
  240. gd->fb_base = CONFIG_FB_ADDR;
  241. #else
  242. /* reserve memory for LCD display (always full pages) */
  243. addr = lcd_setmem (addr);
  244. gd->fb_base = addr;
  245. #endif /* CONFIG_FB_ADDR */
  246. #endif /* CONFIG_LCD */
  247. /*
  248. * reserve memory for U-Boot code, data & bss
  249. * round down to next 4 kB limit
  250. */
  251. addr -= len;
  252. addr &= ~(4096 - 1);
  253. debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
  254. /*
  255. * reserve memory for malloc() arena
  256. */
  257. addr_sp = addr - TOTAL_MALLOC_LEN;
  258. debug ("Reserving %dk for malloc() at: %08lx\n",
  259. TOTAL_MALLOC_LEN >> 10, addr_sp);
  260. /*
  261. * (permanently) allocate a Board Info struct
  262. * and a permanent copy of the "global" data
  263. */
  264. addr_sp -= sizeof (bd_t);
  265. bd = (bd_t *) addr_sp;
  266. gd->bd = bd;
  267. debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
  268. sizeof (bd_t), addr_sp);
  269. addr_sp -= sizeof (gd_t);
  270. id = (gd_t *) addr_sp;
  271. debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
  272. sizeof (gd_t), addr_sp);
  273. /* Reserve memory for boot params. */
  274. addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN;
  275. bd->bi_boot_params = addr_sp;
  276. debug ("Reserving %dk for boot parameters at: %08lx\n",
  277. CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp);
  278. /*
  279. * Finally, we set up a new (bigger) stack.
  280. *
  281. * Leave some safety gap for SP, force alignment on 16 byte boundary
  282. * Clear initial stack frame
  283. */
  284. addr_sp -= 16;
  285. addr_sp &= ~0xF;
  286. paddr = (ulong *)addr_sp;
  287. *paddr-- = 0;
  288. *paddr-- = 0;
  289. addr_sp = (ulong)paddr;
  290. debug ("Stack Pointer at: %08lx\n", addr_sp);
  291. /*
  292. * Save local variables to board info struct
  293. */
  294. bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */
  295. bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
  296. #ifdef CONFIG_SYS_INIT_RAM_ADDR
  297. bd->bi_sramstart = CONFIG_SYS_INIT_RAM_ADDR; /* start of SRAM memory */
  298. bd->bi_sramsize = CONFIG_SYS_INIT_RAM_SIZE; /* size of SRAM memory */
  299. #endif
  300. bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
  301. bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
  302. WATCHDOG_RESET ();
  303. bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
  304. bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
  305. #ifdef CONFIG_PCI
  306. bd->bi_pcifreq = gd->pci_clk; /* PCI Freq in Hz */
  307. #endif
  308. #ifdef CONFIG_EXTRA_CLOCK
  309. bd->bi_inpfreq = gd->arch.inp_clk; /* input Freq in Hz */
  310. bd->bi_vcofreq = gd->arch.vco_clk; /* vco Freq in Hz */
  311. bd->bi_flbfreq = gd->arch.flb_clk; /* flexbus Freq in Hz */
  312. #endif
  313. bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
  314. #ifdef CONFIG_SYS_EXTBDINFO
  315. strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
  316. strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
  317. #endif
  318. WATCHDOG_RESET ();
  319. #ifdef CONFIG_POST
  320. post_bootmode_init();
  321. post_run (NULL, POST_ROM | post_bootmode_get(0));
  322. #endif
  323. WATCHDOG_RESET();
  324. memcpy (id, (void *)gd, sizeof (gd_t));
  325. debug ("Start relocate of code from %08x to %08lx\n", CONFIG_SYS_MONITOR_BASE, addr);
  326. relocate_code (addr_sp, id, addr);
  327. /* NOTREACHED - jump_to_ram() does not return */
  328. }
  329. /************************************************************************
  330. *
  331. * This is the next part if the initialization sequence: we are now
  332. * running from RAM and have a "normal" C environment, i. e. global
  333. * data can be written, BSS has been cleared, the stack size in not
  334. * that critical any more, etc.
  335. *
  336. ************************************************************************
  337. */
  338. void board_init_r (gd_t *id, ulong dest_addr)
  339. {
  340. char *s __maybe_unused;
  341. bd_t *bd;
  342. #ifndef CONFIG_ENV_IS_NOWHERE
  343. extern char * env_name_spec;
  344. #endif
  345. #ifndef CONFIG_SYS_NO_FLASH
  346. ulong flash_size;
  347. #endif
  348. gd = id; /* initialize RAM version of global data */
  349. bd = gd->bd;
  350. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  351. WATCHDOG_RESET ();
  352. gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
  353. serial_initialize();
  354. debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  355. monitor_flash_len = (ulong)&__init_end - dest_addr;
  356. #if defined(CONFIG_NEEDS_MANUAL_RELOC)
  357. /*
  358. * We have to relocate the command table manually
  359. */
  360. fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
  361. ll_entry_count(cmd_tbl_t, cmd));
  362. #endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
  363. /* there are some other pointer constants we must deal with */
  364. #ifndef CONFIG_ENV_IS_NOWHERE
  365. env_name_spec += gd->reloc_off;
  366. #endif
  367. WATCHDOG_RESET ();
  368. #ifdef CONFIG_LOGBUFFER
  369. logbuff_init_ptrs ();
  370. #endif
  371. #ifdef CONFIG_POST
  372. post_output_backlog ();
  373. post_reloc ();
  374. #endif
  375. WATCHDOG_RESET();
  376. #if 0
  377. /* instruction cache enabled in cpu_init_f() for faster relocation */
  378. icache_enable (); /* it's time to enable the instruction cache */
  379. #endif
  380. /*
  381. * Setup trap handlers
  382. */
  383. trap_init (CONFIG_SYS_SDRAM_BASE);
  384. /* The Malloc area is immediately below the monitor copy in DRAM */
  385. mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
  386. TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
  387. #if !defined(CONFIG_SYS_NO_FLASH)
  388. puts ("Flash: ");
  389. if ((flash_size = flash_init ()) > 0) {
  390. # ifdef CONFIG_SYS_FLASH_CHECKSUM
  391. print_size (flash_size, "");
  392. /*
  393. * Compute and print flash CRC if flashchecksum is set to 'y'
  394. *
  395. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  396. */
  397. if (getenv_yesno("flashchecksum") == 1) {
  398. printf (" CRC: %08X",
  399. crc32 (0,
  400. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  401. flash_size)
  402. );
  403. }
  404. putc ('\n');
  405. # else /* !CONFIG_SYS_FLASH_CHECKSUM */
  406. print_size (flash_size, "\n");
  407. # endif /* CONFIG_SYS_FLASH_CHECKSUM */
  408. } else {
  409. puts (failed);
  410. hang ();
  411. }
  412. bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */
  413. bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
  414. bd->bi_flashoffset = 0;
  415. #else /* CONFIG_SYS_NO_FLASH */
  416. bd->bi_flashsize = 0;
  417. bd->bi_flashstart = 0;
  418. bd->bi_flashoffset = 0;
  419. #endif /* !CONFIG_SYS_NO_FLASH */
  420. WATCHDOG_RESET ();
  421. /* initialize higher level parts of CPU like time base and timers */
  422. cpu_init_r ();
  423. WATCHDOG_RESET ();
  424. #ifdef CONFIG_SPI
  425. # if !defined(CONFIG_ENV_IS_IN_EEPROM)
  426. spi_init_f ();
  427. # endif
  428. spi_init_r ();
  429. #endif
  430. #if defined(CONFIG_SYS_I2C)
  431. /* Adjust I2C subsystem pointers after relocation */
  432. i2c_reloc_fixup();
  433. #endif
  434. /* relocate environment function pointers etc. */
  435. env_relocate ();
  436. WATCHDOG_RESET ();
  437. #if defined(CONFIG_PCI)
  438. /*
  439. * Do pci configuration
  440. */
  441. pci_init ();
  442. #endif
  443. /** leave this here (after malloc(), environment and PCI are working) **/
  444. /* Initialize stdio devices */
  445. stdio_init ();
  446. /* Initialize the jump table for applications */
  447. jumptable_init ();
  448. /* Initialize the console (after the relocation and devices init) */
  449. console_init_r ();
  450. #if defined(CONFIG_MISC_INIT_R)
  451. /* miscellaneous platform dependent initialisations */
  452. misc_init_r ();
  453. #endif
  454. #if defined(CONFIG_CMD_KGDB)
  455. WATCHDOG_RESET ();
  456. puts ("KGDB: ");
  457. kgdb_init ();
  458. #endif
  459. debug ("U-Boot relocated to %08lx\n", dest_addr);
  460. /*
  461. * Enable Interrupts
  462. */
  463. interrupt_init ();
  464. /* Must happen after interrupts are initialized since
  465. * an irq handler gets installed
  466. */
  467. timer_init();
  468. #ifdef CONFIG_STATUS_LED
  469. status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
  470. #endif
  471. udelay (20);
  472. /* Insert function pointers now that we have relocated the code */
  473. /* Initialize from environment */
  474. load_addr = getenv_ulong("loadaddr", 16, load_addr);
  475. WATCHDOG_RESET ();
  476. #if defined(CONFIG_CMD_DOC)
  477. WATCHDOG_RESET ();
  478. puts ("DOC: ");
  479. doc_init ();
  480. #endif
  481. #if defined(CONFIG_CMD_NAND)
  482. WATCHDOG_RESET ();
  483. puts ("NAND: ");
  484. nand_init(); /* go init the NAND */
  485. #endif
  486. #ifdef CONFIG_BITBANGMII
  487. bb_miiphy_init();
  488. #endif
  489. #if defined(CONFIG_CMD_NET)
  490. WATCHDOG_RESET();
  491. #if defined(FEC_ENET)
  492. eth_init(bd);
  493. #endif
  494. puts ("Net: ");
  495. eth_initialize (bd);
  496. #endif
  497. #ifdef CONFIG_POST
  498. post_run (NULL, POST_RAM | post_bootmode_get(0));
  499. #endif
  500. #if defined(CONFIG_CMD_PCMCIA) \
  501. && !defined(CONFIG_CMD_IDE)
  502. WATCHDOG_RESET ();
  503. puts ("PCMCIA:");
  504. pcmcia_init ();
  505. #endif
  506. #if defined(CONFIG_CMD_IDE)
  507. WATCHDOG_RESET ();
  508. puts ("IDE: ");
  509. ide_init ();
  510. #endif
  511. #ifdef CONFIG_LAST_STAGE_INIT
  512. WATCHDOG_RESET ();
  513. /*
  514. * Some parts can be only initialized if all others (like
  515. * Interrupts) are up and running (i.e. the PC-style ISA
  516. * keyboard).
  517. */
  518. last_stage_init ();
  519. #endif
  520. #if defined(CONFIG_CMD_BEDBUG)
  521. WATCHDOG_RESET ();
  522. bedbug_init ();
  523. #endif
  524. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  525. /*
  526. * Export available size of memory for Linux,
  527. * taking into account the protected RAM at top of memory
  528. */
  529. {
  530. ulong pram = 0;
  531. char memsz[32];
  532. #ifdef CONFIG_PRAM
  533. pram = getenv_ulong("pram", 10, CONFIG_PRAM);
  534. #endif
  535. #ifdef CONFIG_LOGBUFFER
  536. /* Also take the logbuffer into account (pram is in kB) */
  537. pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
  538. #endif
  539. sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
  540. setenv ("mem", memsz);
  541. }
  542. #endif
  543. #ifdef CONFIG_MODEM_SUPPORT
  544. {
  545. extern int do_mdm_init;
  546. do_mdm_init = gd->do_mdm_init;
  547. }
  548. #endif
  549. #ifdef CONFIG_WATCHDOG
  550. /* disable watchdog if environment is set */
  551. if ((s = getenv ("watchdog")) != NULL) {
  552. if (strncmp (s, "off", 3) == 0) {
  553. WATCHDOG_DISABLE ();
  554. }
  555. }
  556. #endif /* CONFIG_WATCHDOG*/
  557. /* Initialization complete - start the monitor */
  558. /* main_loop() can return to retry autoboot, if so just run it again. */
  559. for (;;) {
  560. WATCHDOG_RESET ();
  561. main_loop ();
  562. }
  563. /* NOTREACHED - no way out of command loop except booting */
  564. }