]> git.sur5r.net Git - u-boot/blobdiff - lib_ppc/board.c
Removed tools/gdb from "make all" target. Added make target "gdbtools"
[u-boot] / lib_ppc / board.c
index bba62d820d2036c53b6e811a94e8b933787f9a67..977d03ec7b680c776385c010c1851d40957cba7d 100644 (file)
 #include <command.h>
 #include <malloc.h>
 #include <devices.h>
-#include <syscall.h>
 #ifdef CONFIG_8xx
 #include <mpc8xx.h>
 #endif
 #ifdef CONFIG_5xx
 #include <mpc5xx.h>
 #endif
+#ifdef CONFIG_MPC5XXX
+#include <mpc5xxx.h>
+#endif
 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
 #include <ide.h>
 #endif
@@ -46,9 +48,6 @@
 #include <status_led.h>
 #endif
 #include <net.h>
-#if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
-#include <cmd_bedbug.h>
-#endif
 #ifdef CFG_ALLOC_DPRAM
 #if !defined(CONFIG_8260)
 #include <commproc.h>
@@ -93,6 +92,14 @@ extern flash_info_t flash_info[];
 #define        TOTAL_MALLOC_LEN        CFG_MALLOC_LEN
 #endif
 
+extern ulong __init_end;
+extern ulong _end;
+ulong monitor_flash_len;
+
+#if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
+#include <bedbug/type.h>
+#endif
+
 /*
  * Begin and End of memory area for malloc(), and current "brk"
  */
@@ -148,37 +155,6 @@ char *strmhz (char *buf, long hz)
        return (buf);
 }
 
-static void syscalls_init (void)
-{
-       ulong *addr;
-
-       syscall_tbl[SYSCALL_MALLOC] = (void *) malloc;
-       syscall_tbl[SYSCALL_FREE] = (void *) free;
-
-       syscall_tbl[SYSCALL_INSTALL_HDLR] = (void *) irq_install_handler;
-       syscall_tbl[SYSCALL_FREE_HDLR] = (void *) irq_free_handler;
-       syscall_tbl[SYSCALL_GET_TIMER] = (void *)get_timer;
-       syscall_tbl[SYSCALL_UDELAY] = (void *)udelay;
-
-       addr = (ulong *) 0xc00;         /* syscall ISR addr */
-
-       /* patch ISR code */
-       *addr++ |= (ulong) syscall_tbl >> 16;
-       *addr++ |= (ulong) syscall_tbl & 0xFFFF;
-       *addr++ |= NR_SYSCALLS >> 16;
-       *addr++ |= NR_SYSCALLS & 0xFFFF;
-
-#ifndef CONFIG_5XX
-       flush_cache (0x0C00, 0x10);
-#endif
-       /* Initialize syscalls stack pointer                                 */
-       addr = (ulong *) 0xCFC;
-       *addr = (ulong)addr;
-#ifndef CONFIG_5xx
-       flush_cache ((ulong)addr, 0x10);
-#endif
-}
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -299,6 +275,9 @@ init_fnc_t *init_sequence[] = {
        prt_8260_clks,
 #endif /* CONFIG_8260 */
        checkcpu,
+#if defined(CONFIG_MPC5XXX)
+       prt_mpc5xxx_clks,
+#endif /* CONFIG_MPC5XXX */
        checkboard,
        INIT_FUNC_WATCHDOG_INIT
 #if defined(CONFIG_BMW)                || \
@@ -377,22 +356,13 @@ void board_init_f (ulong bootflag)
         * relocate the code and continue running from DRAM.
         *
         * Reserve memory at end of RAM for (top down in that order):
-         *  - kernel log buffer
+        *  - kernel log buffer
         *  - protected RAM
         *  - LCD framebuffer
         *  - monitor code
         *  - board info struct
         */
-       len = get_endaddr () - CFG_MONITOR_BASE;
-
-       if (len > CFG_MONITOR_LEN) {
-               printf ("*** U-Boot size %ld > reserved memory (%d)\n",
-                               len, CFG_MONITOR_LEN);
-               hang ();
-       }
-
-       if (CFG_MONITOR_LEN > len)
-               len = CFG_MONITOR_LEN;
+       len = (ulong)&_end - CFG_MONITOR_BASE;
 
 #ifndef        CONFIG_VERY_BIG_RAM
        addr = CFG_SDRAM_BASE + gd->ram_size;
@@ -405,9 +375,7 @@ void board_init_f (ulong bootflag)
 #ifdef CONFIG_LOGBUFFER
        /* reserve kernel log buffer */
        addr -= (LOGBUFF_RESERVE);
-# ifdef DEBUG
-       printf ("Reserving %ldk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
-# endif
+       debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
 #endif
 
 #ifdef CONFIG_PRAM
@@ -417,16 +385,12 @@ void board_init_f (ulong bootflag)
        i = getenv_r ("pram", tmp, sizeof (tmp));
        reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
        addr -= (reg << 10);            /* size is in kB */
-# ifdef DEBUG
-       printf ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
-# endif
+       debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
 #endif /* CONFIG_PRAM */
 
        /* round down to next 4 kB limit */
        addr &= ~(4096 - 1);
-#ifdef DEBUG
-       printf ("Top of RAM usable for U-Boot at: %08lx\n", addr);
-#endif
+       debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
 
 #ifdef CONFIG_LCD
        /* reserve memory for LCD display (always full pages) */
@@ -447,9 +411,7 @@ void board_init_f (ulong bootflag)
        addr -= len;
        addr &= ~(4096 - 1);
 
-#ifdef DEBUG
-       printf ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
-#endif
+       debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
 
 #ifdef CONFIG_AMIGAONEG3SE
        gd->relocaddr = addr;
@@ -459,10 +421,8 @@ void board_init_f (ulong bootflag)
         * reserve memory for malloc() arena
         */
        addr_sp = addr - TOTAL_MALLOC_LEN;
-#ifdef DEBUG
-       printf ("Reserving %dk for malloc() at: %08lx\n",
+       debug ("Reserving %dk for malloc() at: %08lx\n",
                        TOTAL_MALLOC_LEN >> 10, addr_sp);
-#endif
 
        /*
         * (permanently) allocate a Board Info struct
@@ -471,16 +431,12 @@ void board_init_f (ulong bootflag)
        addr_sp -= sizeof (bd_t);
        bd = (bd_t *) addr_sp;
        gd->bd = bd;
-#ifdef DEBUG
-       printf ("Reserving %d Bytes for Board Info at: %08lx\n",
+       debug ("Reserving %d Bytes for Board Info at: %08lx\n",
                        sizeof (bd_t), addr_sp);
-#endif
        addr_sp -= sizeof (gd_t);
        id = (gd_t *) addr_sp;
-#ifdef DEBUG
-       printf ("Reserving %d Bytes for Global Data at: %08lx\n",
+       debug ("Reserving %d Bytes for Global Data at: %08lx\n",
                        sizeof (gd_t), addr_sp);
-#endif
 
        /*
         * Finally, we set up a new (bigger) stack.
@@ -492,9 +448,7 @@ void board_init_f (ulong bootflag)
        addr_sp &= ~0xF;
        *((ulong *) addr_sp)-- = 0;
        *((ulong *) addr_sp)-- = 0;
-#ifdef DEBUG
-       printf ("Stack Pointer at: %08lx\n", addr_sp);
-#endif
+       debug ("Stack Pointer at: %08lx\n", addr_sp);
 
        /*
         * Save local variables to board info struct
@@ -514,6 +468,9 @@ void board_init_f (ulong bootflag)
 #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx)
        bd->bi_immr_base = CFG_IMMR;    /* base  of IMMR register     */
 #endif
+#if defined(CONFIG_MPC5XXX)
+       bd->bi_mbar_base = CFG_MBAR;    /* base of internal registers */
+#endif
 
        bd->bi_bootflags = bootflag;    /* boot / reboot flag (for LynxOS)    */
 
@@ -526,7 +483,10 @@ void board_init_f (ulong bootflag)
        bd->bi_sccfreq = gd->scc_clk;
        bd->bi_vco     = gd->vco_out;
 #endif /* CONFIG_8260 */
-
+#if defined(CONFIG_MPC5XXX)
+       bd->bi_ipbfreq = gd->ipb_clk;
+       bd->bi_pcifreq = gd->pci_clk;
+#endif /* CONFIG_MPC5XXX */
        bd->bi_baudrate = gd->baudrate; /* Console Baudrate     */
 
 #ifdef CFG_EXTBDINFO
@@ -540,9 +500,7 @@ void board_init_f (ulong bootflag)
 #endif
 #endif
 
-#ifdef DEBUG
-       printf ("New Stack Pointer is: %08lx\n", addr_sp);
-#endif
+       debug ("New Stack Pointer is: %08lx\n", addr_sp);
 
        WATCHDOG_RESET ();
 
@@ -553,7 +511,7 @@ void board_init_f (ulong bootflag)
 
        WATCHDOG_RESET();
 
-       memcpy (id, gd, sizeof (gd_t));
+       memcpy (id, (void *)gd, sizeof (gd_t));
 
        relocate_code (addr_sp, id, addr);
 
@@ -574,7 +532,6 @@ void board_init_f (ulong bootflag)
 void board_init_r (gd_t *id, ulong dest_addr)
 {
        DECLARE_GLOBAL_DATA_PTR;
-
        cmd_tbl_t *cmdtp;
        char *s, *e;
        bd_t *bd;
@@ -593,20 +550,19 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
 
-#ifdef DEBUG
-       printf ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
-#endif
+       debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
 
        WATCHDOG_RESET ();
 
        gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
 
+       monitor_flash_len = (ulong)&__init_end - dest_addr;
+
        /*
         * We have to relocate the command table manually
         */
-       for (cmdtp = &cmd_tbl[0]; cmdtp->name; cmdtp++) {
+       for (cmdtp = &__u_boot_cmd_start; cmdtp !=  &__u_boot_cmd_end; cmdtp++) {
                ulong addr;
-
                addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
 #if 0
                printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
@@ -705,7 +661,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
        bd->bi_flashoffset = 0;
 #elif CFG_MONITOR_BASE == CFG_FLASH_BASE
-       bd->bi_flashoffset = CFG_MONITOR_LEN;   /* reserved area for startup monitor  */
+       bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor  */
 #else
        bd->bi_flashoffset = 0;
 #endif
@@ -739,10 +695,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        /*
         * Fill in missing fields of bd_info.
-         * We do this here, where we have "normal" access to the
-         * environment; we used to do this still running from ROM,
-         * where had to use getenv_r(), which can be pretty slow when
-         * the environment is in EEPROM.
+        * We do this here, where we have "normal" access to the
+        * environment; we used to do this still running from ROM,
+        * where had to use getenv_r(), which can be pretty slow when
+        * the environment is in EEPROM.
         */
        s = getenv ("ethaddr");
 #if defined (CONFIG_MBX) || defined (CONFIG_RPXCLASSIC) || defined(CONFIG_IAD210)
@@ -810,19 +766,16 @@ void board_init_r (gd_t *id, ulong dest_addr)
        /* Initialize devices */
        devices_init ();
 
-       /* allocate syscalls table (console_init_r will fill it in */
-       syscall_tbl = (void **) malloc (NR_SYSCALLS * sizeof (void *));
+       /* Initialize the jump table for applications */
+       jumptable_init ();
 
        /* Initialize the console (after the relocation and devices init) */
        console_init_r ();
-/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
-       syscalls_init ();
 
 #if defined(CONFIG_CCM)                || \
     defined(CONFIG_COGENT)     || \
     defined(CONFIG_CPCI405)    || \
     defined(CONFIG_EVB64260)   || \
-    defined(CONFIG_HYMOD)      || \
     defined(CONFIG_KUP4K)      || \
     defined(CONFIG_LWMON)      || \
     defined(CONFIG_PCU_E)      || \
@@ -852,9 +805,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
     defined(CONFIG_SPD823TS)   )
 
        WATCHDOG_RESET ();
-# ifdef DEBUG
-       puts ("Reset Ethernet PHY\n");
-# endif
+       debug ("Reset Ethernet PHY\n");
        reset_phy ();
 #endif
 
@@ -864,9 +815,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        kgdb_init ();
 #endif
 
-#ifdef DEBUG
-       printf ("U-Boot relocated to %08lx\n", dest_addr);
-#endif
+       debug ("U-Boot relocated to %08lx\n", dest_addr);
 
        /*
         * Enable Interrupts
@@ -927,10 +876,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #ifdef CONFIG_POST
        post_run (NULL, POST_RAM | post_bootmode_get(0));
-       if (post_bootmode_get(0) & POST_POWERFAIL) {
-               post_bootmode_clear();
-               board_poweroff();
-       }
 #endif
 
 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE)