2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
39 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
42 #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
45 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
48 #ifdef CONFIG_STATUS_LED
49 #include <status_led.h>
52 #ifdef CFG_ALLOC_DPRAM
53 #if !defined(CONFIG_8260)
58 #if defined(CONFIG_BAB7xx)
62 #if defined(CONFIG_POST)
65 #if defined(CONFIG_LOGBUFFER)
69 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
72 #if defined(CONFIG_HARD_I2C) || \
73 defined(CONFIG_SOFT_I2C)
76 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
77 void nand_init (void);
80 static char *failed = "*** failed ***\n";
82 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
83 extern flash_info_t flash_info[];
86 #include <environment.h>
88 #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
89 (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
90 defined(CFG_ENV_IS_IN_NVRAM)
91 #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
93 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
96 extern ulong __init_end;
98 ulong monitor_flash_len;
100 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
101 #include <bedbug/type.h>
105 * Begin and End of memory area for malloc(), and current "brk"
107 static ulong mem_malloc_start = 0;
108 static ulong mem_malloc_end = 0;
109 static ulong mem_malloc_brk = 0;
111 /************************************************************************
113 ************************************************************************
117 * The Malloc area is immediately below the monitor copy in DRAM
119 static void mem_malloc_init (void)
121 DECLARE_GLOBAL_DATA_PTR;
123 ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
125 mem_malloc_end = dest_addr;
126 mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
127 mem_malloc_brk = mem_malloc_start;
129 memset ((void *) mem_malloc_start,
131 mem_malloc_end - mem_malloc_start);
134 void *sbrk (ptrdiff_t increment)
136 ulong old = mem_malloc_brk;
137 ulong new = old + increment;
139 if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
142 mem_malloc_brk = new;
143 return ((void *) old);
146 char *strmhz (char *buf, long hz)
152 l = sprintf (buf, "%ld", n);
153 m = (hz % 1000000L) / 1000L;
155 sprintf (buf + l, ".%03ld", m);
159 static void syscalls_init (void)
163 syscall_tbl[SYSCALL_MALLOC] = (void *) malloc;
164 syscall_tbl[SYSCALL_FREE] = (void *) free;
166 syscall_tbl[SYSCALL_INSTALL_HDLR] = (void *) irq_install_handler;
167 syscall_tbl[SYSCALL_FREE_HDLR] = (void *) irq_free_handler;
168 syscall_tbl[SYSCALL_GET_TIMER] = (void *)get_timer;
169 syscall_tbl[SYSCALL_UDELAY] = (void *)udelay;
171 addr = (ulong *) 0xc00; /* syscall ISR addr */
174 *addr++ |= (ulong) syscall_tbl >> 16;
175 *addr++ |= (ulong) syscall_tbl & 0xFFFF;
176 *addr++ |= NR_SYSCALLS >> 16;
177 *addr++ |= NR_SYSCALLS & 0xFFFF;
180 flush_cache (0x0C00, 0x10);
182 /* Initialize syscalls stack pointer */
183 addr = (ulong *) 0xCFC;
186 flush_cache ((ulong)addr, 0x10);
191 * All attempts to come up with a "common" initialization sequence
192 * that works for all boards and architectures failed: some of the
193 * requirements are just _too_ different. To get rid of the resulting
194 * mess of board dependend #ifdef'ed code we now make the whole
195 * initialization sequence configurable to the user.
197 * The requirements for any new initalization function is simple: it
198 * receives a pointer to the "global data" structure as it's only
199 * argument, and returns an integer return code, where 0 means
200 * "continue" and != 0 means "fatal error, hang the system".
202 typedef int (init_fnc_t) (void);
204 /************************************************************************
206 ************************************************************************
207 * Some of this code should be moved into the core functions,
208 * but let's get it working (again) first...
211 static int init_baudrate (void)
213 DECLARE_GLOBAL_DATA_PTR;
215 uchar tmp[64]; /* long enough for environment variables */
216 int i = getenv_r ("baudrate", tmp, sizeof (tmp));
218 gd->baudrate = (i > 0)
219 ? (int) simple_strtoul (tmp, NULL, 10)
224 /***********************************************************************/
226 static int init_func_ram (void)
228 DECLARE_GLOBAL_DATA_PTR;
230 #ifdef CONFIG_BOARD_TYPES
231 int board_type = gd->board_type;
233 int board_type = 0; /* use dummy arg */
237 if ((gd->ram_size = initdram (board_type)) > 0) {
238 print_size (gd->ram_size, "\n");
245 /***********************************************************************/
247 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
248 static int init_func_i2c (void)
251 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
257 /***********************************************************************/
259 #if defined(CONFIG_WATCHDOG)
260 static int init_func_watchdog_init (void)
262 puts (" Watchdog enabled\n");
266 # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
268 static int init_func_watchdog_reset (void)
273 # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset,
275 # define INIT_FUNC_WATCHDOG_INIT /* undef */
276 # define INIT_FUNC_WATCHDOG_RESET /* undef */
277 #endif /* CONFIG_WATCHDOG */
279 /************************************************************************
280 * Initialization sequence *
281 ************************************************************************
284 init_fnc_t *init_sequence[] = {
286 #if defined(CONFIG_BOARD_PRE_INIT)
287 board_pre_init, /* very early board init code (fpga boot, etc.) */
290 get_clocks, /* get CPU and bus clocks (etc.) */
292 #ifdef CFG_ALLOC_DPRAM
293 #if !defined(CONFIG_8260)
297 #if defined(CONFIG_BOARD_POSTCLK_INIT)
305 #if defined(CONFIG_8260)
308 #endif /* CONFIG_8260 */
310 #if defined(CONFIG_MPC5XXX)
312 #endif /* CONFIG_MPC5XXX */
314 INIT_FUNC_WATCHDOG_INIT
315 #if defined(CONFIG_BMW) || \
316 defined(CONFIG_COGENT) || \
317 defined(CONFIG_HYMOD) || \
318 defined(CONFIG_RSD_PROTO) || \
322 INIT_FUNC_WATCHDOG_RESET
323 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
326 #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
332 INIT_FUNC_WATCHDOG_RESET
334 #if defined(CFG_DRAM_TEST)
336 #endif /* CFG_DRAM_TEST */
337 INIT_FUNC_WATCHDOG_RESET
339 NULL, /* Terminate this list */
342 /************************************************************************
344 * This is the first part of the initialization sequence that is
345 * implemented in C, but still running from ROM.
347 * The main purpose is to provide a (serial) console interface as
348 * soon as possible (so we can see any error messages), and to
349 * initialize the RAM so that we can relocate the monitor code to
352 * Be aware of the restrictions: global data is read-only, BSS is not
353 * initialized, and stack space is limited to a few kB.
355 ************************************************************************
358 void board_init_f (ulong bootflag)
360 DECLARE_GLOBAL_DATA_PTR;
363 ulong len, addr, addr_sp;
365 init_fnc_t **init_fnc_ptr;
369 uchar tmp[64]; /* long enough for environment variables */
372 /* Pointer is writable since we allocated a register for it */
373 gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
376 /* Clear initial global data */
377 memset ((void *) gd, 0, sizeof (gd_t));
380 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
381 if ((*init_fnc_ptr) () != 0) {
387 * Now that we have DRAM mapped and working, we can
388 * relocate the code and continue running from DRAM.
390 * Reserve memory at end of RAM for (top down in that order):
391 * - kernel log buffer
395 * - board info struct
397 len = (ulong)&_end - CFG_MONITOR_BASE;
399 #ifndef CONFIG_VERY_BIG_RAM
400 addr = CFG_SDRAM_BASE + gd->ram_size;
402 /* only allow stack below 256M */
403 addr = CFG_SDRAM_BASE +
404 (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size;
407 #ifdef CONFIG_LOGBUFFER
408 /* reserve kernel log buffer */
409 addr -= (LOGBUFF_RESERVE);
410 debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
415 * reserve protected RAM
417 i = getenv_r ("pram", tmp, sizeof (tmp));
418 reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
419 addr -= (reg << 10); /* size is in kB */
420 debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
421 #endif /* CONFIG_PRAM */
423 /* round down to next 4 kB limit */
425 debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
428 /* reserve memory for LCD display (always full pages) */
429 addr = lcd_setmem (addr);
431 #endif /* CONFIG_LCD */
433 #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx)
434 /* reserve memory for video display (always full pages) */
435 addr = video_setmem (addr);
437 #endif /* CONFIG_VIDEO */
440 * reserve memory for U-Boot code, data & bss
441 * round down to next 4 kB limit
446 debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
448 #ifdef CONFIG_AMIGAONEG3SE
449 gd->relocaddr = addr;
453 * reserve memory for malloc() arena
455 addr_sp = addr - TOTAL_MALLOC_LEN;
456 debug ("Reserving %dk for malloc() at: %08lx\n",
457 TOTAL_MALLOC_LEN >> 10, addr_sp);
460 * (permanently) allocate a Board Info struct
461 * and a permanent copy of the "global" data
463 addr_sp -= sizeof (bd_t);
464 bd = (bd_t *) addr_sp;
466 debug ("Reserving %d Bytes for Board Info at: %08lx\n",
467 sizeof (bd_t), addr_sp);
468 addr_sp -= sizeof (gd_t);
469 id = (gd_t *) addr_sp;
470 debug ("Reserving %d Bytes for Global Data at: %08lx\n",
471 sizeof (gd_t), addr_sp);
474 * Finally, we set up a new (bigger) stack.
476 * Leave some safety gap for SP, force alignment on 16 byte boundary
477 * Clear initial stack frame
481 *((ulong *) addr_sp)-- = 0;
482 *((ulong *) addr_sp)-- = 0;
483 debug ("Stack Pointer at: %08lx\n", addr_sp);
486 * Save local variables to board info struct
489 bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */
490 bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
493 bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */
494 bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */
496 bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */
497 bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */
500 #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx)
501 bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */
503 #if defined(CONFIG_MPC5XXX)
504 bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */
507 bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
510 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
511 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
512 #if defined(CONFIG_8260)
513 bd->bi_cpmfreq = gd->cpm_clk;
514 bd->bi_brgfreq = gd->brg_clk;
515 bd->bi_sccfreq = gd->scc_clk;
516 bd->bi_vco = gd->vco_out;
517 #endif /* CONFIG_8260 */
518 #if defined(CONFIG_MPC5XXX)
519 bd->bi_ipbfreq = gd->ipb_clk;
520 bd->bi_pcifreq = gd->pci_clk;
521 #endif /* CONFIG_MPC5XXX */
522 bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
525 strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
526 strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
528 bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
529 bd->bi_plb_busfreq = gd->bus_clk;
530 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
531 bd->bi_pci_busfreq = get_PCI_freq ();
535 debug ("New Stack Pointer is: %08lx\n", addr_sp);
540 post_bootmode_init();
541 post_run (NULL, POST_ROM | post_bootmode_get(0));
546 memcpy (id, gd, sizeof (gd_t));
548 relocate_code (addr_sp, id, addr);
550 /* NOTREACHED - relocate_code() does not return */
554 /************************************************************************
556 * This is the next part if the initialization sequence: we are now
557 * running from RAM and have a "normal" C environment, i. e. global
558 * data can be written, BSS has been cleared, the stack size in not
559 * that critical any more, etc.
561 ************************************************************************
564 void board_init_r (gd_t *id, ulong dest_addr)
566 DECLARE_GLOBAL_DATA_PTR;
571 extern void malloc_bin_reloc (void);
572 #ifndef CFG_ENV_IS_NOWHERE
573 extern char * env_name_spec;
580 gd = id; /* initialize RAM version of global data */
583 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
585 debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
589 gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
591 monitor_flash_len = (ulong)&__init_end - dest_addr;
594 * We have to relocate the command table manually
596 for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
598 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
600 printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
601 cmdtp->name, (ulong) (cmdtp->cmd), addr);
604 (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
606 addr = (ulong)(cmdtp->name) + gd->reloc_off;
607 cmdtp->name = (char *)addr;
610 addr = (ulong)(cmdtp->usage) + gd->reloc_off;
611 cmdtp->usage = (char *)addr;
615 addr = (ulong)(cmdtp->help) + gd->reloc_off;
616 cmdtp->help = (char *)addr;
620 /* there are some other pointer constants we must deal with */
621 #ifndef CFG_ENV_IS_NOWHERE
622 env_name_spec += gd->reloc_off;
627 #ifdef CONFIG_LOGBUFFER
628 logbuff_init_ptrs ();
631 post_output_backlog ();
637 #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || defined (CONFIG_FLAGADM)
638 icache_enable (); /* it's time to enable the instruction cache */
641 #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45)
643 * Do PCI configuration on BAB7xx and CPC45 _before_ the flash
644 * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus
649 #if defined(CONFIG_BAB7xx)
651 * Initialise the ISA bridge
653 initialise_w83c553f ();
656 asm ("sync ; isync");
659 * Setup trap handlers
661 trap_init (dest_addr);
663 #if !defined(CFG_NO_FLASH)
666 if ((flash_size = flash_init ()) > 0) {
667 #ifdef CFG_FLASH_CHECKSUM
668 print_size (flash_size, "");
670 * Compute and print flash CRC if flashchecksum is set to 'y'
672 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
674 s = getenv ("flashchecksum");
675 if (s && (*s == 'y')) {
676 printf (" CRC: %08lX",
678 (const unsigned char *) CFG_FLASH_BASE,
684 print_size (flash_size, "\n");
685 #endif /* CFG_FLASH_CHECKSUM */
691 bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */
692 bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
693 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
694 bd->bi_flashoffset = 0;
695 #elif CFG_MONITOR_BASE == CFG_FLASH_BASE
696 bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */
698 bd->bi_flashoffset = 0;
702 bd->bi_flashsize = 0;
703 bd->bi_flashstart = 0;
704 bd->bi_flashoffset = 0;
705 #endif /* !CFG_NO_FLASH */
709 /* initialize higher level parts of CPU like time base and timers */
714 /* initialize malloc() area */
719 # if !defined(CFG_ENV_IS_IN_EEPROM)
725 /* relocate environment function pointers etc. */
729 * Fill in missing fields of bd_info.
730 * We do this here, where we have "normal" access to the
731 * environment; we used to do this still running from ROM,
732 * where had to use getenv_r(), which can be pretty slow when
733 * the environment is in EEPROM.
735 s = getenv ("ethaddr");
736 #if defined (CONFIG_MBX) || defined (CONFIG_RPXCLASSIC) || defined(CONFIG_IAD210)
738 board_get_enetaddr (bd->bi_enetaddr);
741 for (i = 0; i < 6; ++i) {
742 bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
744 s = (*e) ? e + 1 : e;
747 if ((gd->board_type >> 16) == 2)
748 bd->bi_ethspeed = gd->board_type & 0xFFFF;
750 bd->bi_ethspeed = 0xFFFF;
754 load_sernum_ethaddr ();
757 #if defined(CFG_GT_6426x) || defined(CONFIG_PN62)
758 /* handle the 2nd ethernet address */
760 s = getenv ("eth1addr");
762 for (i = 0; i < 6; ++i) {
763 bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
765 s = (*e) ? e + 1 : e;
768 #if defined(CFG_GT_6426x)
769 /* handle the 3rd ethernet address */
771 s = getenv ("eth2addr");
773 for (i = 0; i < 6; ++i) {
774 bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
776 s = (*e) ? e + 1 : e;
781 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
783 load_sernum_ethaddr ();
786 bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
790 #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx)
792 * Do pci configuration
797 /** leave this here (after malloc(), environment and PCI are working) **/
798 /* Initialize devices */
801 /* allocate syscalls table (console_init_r will fill it in */
802 syscall_tbl = (void **) malloc (NR_SYSCALLS * sizeof (void *));
804 /* Initialize the console (after the relocation and devices init) */
806 /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
809 #if defined(CONFIG_CCM) || \
810 defined(CONFIG_COGENT) || \
811 defined(CONFIG_CPCI405) || \
812 defined(CONFIG_EVB64260) || \
813 defined(CONFIG_KUP4K) || \
814 defined(CONFIG_LWMON) || \
815 defined(CONFIG_PCU_E) || \
816 defined(CONFIG_W7O) || \
817 defined(CONFIG_MISC_INIT_R)
818 /* miscellaneous platform dependent initialisations */
823 if (bd->bi_ethspeed != 0xFFFF)
824 hermes_start_lxt980 ((int) bd->bi_ethspeed);
827 #if (CONFIG_COMMANDS & CFG_CMD_NET) && ( \
828 defined(CONFIG_CCM) || \
829 defined(CONFIG_ELPT860) || \
830 defined(CONFIG_EP8260) || \
831 defined(CONFIG_IP860) || \
832 defined(CONFIG_IVML24) || \
833 defined(CONFIG_IVMS8) || \
834 defined(CONFIG_LWMON) || \
835 defined(CONFIG_MPC8260ADS) || \
836 defined(CONFIG_MPC8266ADS) || \
837 defined(CONFIG_PCU_E) || \
838 defined(CONFIG_RPXSUPER) || \
839 defined(CONFIG_SPD823TS) )
842 debug ("Reset Ethernet PHY\n");
846 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
852 debug ("U-Boot relocated to %08lx\n", dest_addr);
859 /* Must happen after interrupts are initialized since
860 * an irq handler gets installed
862 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
863 serial_buffered_init();
866 #ifdef CONFIG_STATUS_LED
867 status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
874 /* Insert function pointers now that we have relocated the code */
876 /* Initialize from environment */
877 if ((s = getenv ("loadaddr")) != NULL) {
878 load_addr = simple_strtoul (s, NULL, 16);
880 #if (CONFIG_COMMANDS & CFG_CMD_NET)
881 if ((s = getenv ("bootfile")) != NULL) {
882 copy_filename (BootFile, s, sizeof (BootFile));
884 #endif /* CFG_CMD_NET */
888 #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
894 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
900 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
902 nand_init(); /* go init the NAND */
905 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
912 post_run (NULL, POST_RAM | post_bootmode_get(0));
915 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE)
921 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
923 # ifdef CONFIG_IDE_8xx_PCCARD
929 #endif /* CFG_CMD_IDE */
931 #ifdef CONFIG_LAST_STAGE_INIT
934 * Some parts can be only initialized if all others (like
935 * Interrupts) are up and running (i.e. the PC-style ISA
941 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
946 #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
948 * Export available size of memory for Linux,
949 * taking into account the protected RAM at top of memory
957 if ((s = getenv ("pram")) != NULL) {
958 pram = simple_strtoul (s, NULL, 10);
965 #ifdef CONFIG_LOGBUFFER
966 /* Also take the logbuffer into account (pram is in kB) */
967 pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
969 sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
970 setenv ("mem", memsz);
974 #ifdef CONFIG_MODEM_SUPPORT
976 extern int do_mdm_init;
977 do_mdm_init = gd->do_mdm_init;
981 /* Initialization complete - start the monitor */
983 /* main_loop() can return to retry autoboot, if so just run it again. */
989 /* NOTREACHED - no way out of command loop except booting */
994 puts ("### ERROR ### Please RESET the board ###\n");
998 #ifdef CONFIG_MODEM_SUPPORT
999 /* called from main loop (common/main.c) */
1000 extern void dbg(const char *fmt, ...);
1006 extern char console_buffer[];
1007 static inline void mdm_readline(char *buf, int bufsiz);
1008 extern void enable_putc(void);
1009 extern int hwflow_onoff(int);
1011 enable_putc(); /* enable serial_putc() */
1013 #ifdef CONFIG_HWFLOW
1014 init_str = getenv("mdm_flow_control");
1015 if (init_str && (strcmp(init_str, "rts/cts") == 0))
1022 sprintf(env_str, "mdm_init%d", i);
1023 if ((init_str = getenv(env_str)) != NULL) {
1024 serial_puts(init_str);
1027 mdm_readline(console_buffer, CFG_CBSIZE);
1028 dbg("ini%d: [%s]", i, console_buffer);
1030 if ((strcmp(console_buffer, "OK") == 0) ||
1031 (strcmp(console_buffer, "ERROR") == 0)) {
1032 dbg("ini%d: cmd done", i);
1034 } else /* in case we are originating call ... */
1035 if (strncmp(console_buffer, "CONNECT", 7) == 0) {
1036 dbg("ini%d: connect", i);
1041 break; /* no init string - stop modem init */
1048 /* final stage - wait for connect */
1049 for(;i > 1;) { /* if 'i' > 1 - wait for connection
1050 message from modem */
1051 mdm_readline(console_buffer, CFG_CBSIZE);
1052 dbg("ini_f: [%s]", console_buffer);
1053 if (strncmp(console_buffer, "CONNECT", 7) == 0) {
1054 dbg("ini_f: connected");
1062 /* 'inline' - We have to do it fast */
1063 static inline void mdm_readline(char *buf, int bufsiz)
1074 /* dbg("(%c)", c); */
1086 return; /* sanity check */
1096 #if 0 /* We could use plain global data, but the resulting code is bigger */
1098 * Pointer to initial global data area
1100 * Here we initialize it.
1102 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
1103 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
1104 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
1107 /************************************************************************/