]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
PPCBoot / ARMBoot merge:
authorwdenk <wdenk>
Thu, 15 Aug 2002 08:41:42 +0000 (08:41 +0000)
committerwdenk <wdenk>
Thu, 15 Aug 2002 08:41:42 +0000 (08:41 +0000)
- cleanup compile options
- cleanup (some) prototype problems
- use common function to print flash error messages

31 files changed:
arm_config.mk
board/cradle/flash.c
board/dnp1110/flash.c
board/ep7312/flash.c
board/impa7/flash.c
board/lart/flash.c
board/lubbock/flash.c
board/mpl/common/common_util.c
board/mvs1/ppcboot.lds
board/shannon/flash.c
board/smdk2400/flash.c
board/smdk2410/flash.c
board/tqm8xx/ppcboot.lds
common/cmd_boot.c
common/cmd_mem.c
common/cmd_nvedit.c
common/flash.c
config.mk
include/armboot.h [new file with mode: 0644]
include/asm-arm/bitops.h [new file with mode: 0644]
include/asm-arm/byteorder.h [new file with mode: 0644]
include/asm-arm/io.h [new file with mode: 0644]
include/environment.h [new file with mode: 0644]
include/flash.h
include/linux/byteorder/little_endian.h [new file with mode: 0644]
include/ppcboot.h
lib_arm/armlinux.c
lib_arm/board.c
lib_generic/string.c
net/tftp.c
ppc_config.mk

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..73d9625beadea1a39a4073f95da9be2f944806a8 100644 (file)
@@ -0,0 +1,24 @@
+#
+# (C) Copyright 2000-2002
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
index efc5c38e41812685d9fc3fe4ebd96fde5d52d185..bf2dc7edec8aa25500f0cecf860536fcd95b7c19 100644 (file)
@@ -36,7 +36,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
    int i, j;
    ulong size = 0;
index a28dbaac015e0c56c0d97d627b8ac8010115b8a1..1186298697195c46f7fe45e6893e555514c4f78c 100644 (file)
@@ -69,7 +69,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
@@ -294,7 +294,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
 
        if (info->protect[sect] == 0)
        {       /* not protected */
-           vulong *addr = (vulong *)(info->start[sect]);
+           vu_long *addr = (vu_long *)(info->start[sect]);
 
            *addr = PUZZLE_TO_FLASH(CMD_STATUS_RESET);
            *addr = PUZZLE_TO_FLASH(CMD_ERASE_SETUP);
@@ -349,7 +349,7 @@ outahere:
 
 volatile static int write_word (flash_info_t *info, ulong dest, ulong data)
 {
-    vulong *addr = (vulong *)dest;
+    vu_long *addr = (vu_long *)dest;
     ulong result;
     int rc = ERR_OK;
     int cflag, iflag;
@@ -444,7 +444,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
      * handle word aligned part
      */
     while (cnt >= 4) {
-       data = *((vulong*)src);
+       data = *((vu_long*)src);
        if ((rc = write_word(info, wp, data)) != 0) {
            return (rc);
        }
index 95af01a94b736e87afa1a9df361873fe1ca7ad0e..8183773816df4272f305f25f8b9b5a688d9b812d 100644 (file)
@@ -33,7 +33,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
index 2b02e2d56629fbd93cacc364371cfe453077266e..6637fc7414cbe91e4663914ace0715498d811c79 100644 (file)
@@ -34,7 +34,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
@@ -175,7 +175,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
        reset_timer_masked();
        
        if (info->protect[sect] == 0) { /* not protected */
-           vulong *addr = (vulong *)(info->start[sect]);
+           vu_long *addr = (vu_long *)(info->start[sect]);
            
            *addr = 0x00200020; /* erase setup */
            *addr = 0x00D000D0; /* erase confirm */
@@ -213,7 +213,7 @@ outahere:
 
 static int write_word (flash_info_t *info, ulong dest, ulong data)
 {
-    vulong *addr = (vulong *)dest;
+    vu_long *addr = (vu_long *)dest;
     ulong barf;
     int rc = ERR_OK;
     int flag;
@@ -336,7 +336,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
      * handle word aligned part
      */
     while (cnt >= 4) {
-       data = *((vulong*)src);
+       data = *((vu_long*)src);
        if ((rc = write_word(info, wp, data)) != 0) {
            return (rc);
        }
index 091daa5c83c5d5b606924cf89792bd538ed7ffb5..64d101f113cb0f7c5e0688787df08dc1cd0ee82d 100644 (file)
@@ -69,7 +69,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
@@ -294,7 +294,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
 
        if (info->protect[sect] == 0)
        {       /* not protected */
-           vulong *addr = (vulong *)(info->start[sect]);
+           vu_long *addr = (vu_long *)(info->start[sect]);
 
            *addr = PUZZLE_TO_FLASH(CMD_STATUS_RESET);
            *addr = PUZZLE_TO_FLASH(CMD_ERASE_SETUP);
@@ -349,7 +349,7 @@ outahere:
 
 volatile static int write_word (flash_info_t *info, ulong dest, ulong data)
 {
-    vulong *addr = (vulong *)dest;
+    vu_long *addr = (vu_long *)dest;
     ulong result;
     int rc = ERR_OK;
     int cflag, iflag;
@@ -444,7 +444,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
      * handle word aligned part
      */
     while (cnt >= 4) {
-       data = *((vulong*)src);
+       data = *((vu_long*)src);
        if ((rc = write_word(info, wp, data)) != 0) {
            return (rc);
        }
index 7465dced77dc35112585d2f219e80988ac33c5d3..0c73a017c18f720ff8834eb9c7f97a9d89e720f9 100644 (file)
@@ -36,7 +36,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
index 6ab0819b3f5863d6c62d676d830e4d1a4e73f2c7..3561582d461c3e5c7bd907a5e682d371bb68065d 100644 (file)
@@ -66,16 +66,13 @@ int mpl_prg(unsigned long src,unsigned long size)
                                start,i,info->start[i]);
        flash_erase (info, i, info->sector_count-1);
        printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",src,size);
-       switch (rc = flash_write ((uchar *)src, start, size))
-       {
-               case 0: printf ("OK programming done\n"); return 0;
-               case 1: printf ("ERROR Timeout writing to Flash\n"); return 1;
-               case 2: printf ("ERROR Flash not Erased\n"); return 1;
-               case 4: printf ("ERROR Can't write to protected Flash sectors\n"); return 1;
-               case 8: printf ("ERROR Outside available Flash\n"); return 1;
-               default:        printf ("ERROR %s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); return 1;
+       if ((rc = flash_write ((uchar *)src, start, size)) != 0) {
+               puts ("ERROR ");
+               flash_perror (rc);
+               return (1);
        }
-  return 1;
+       puts ("OK programming done\n");
+       return 0;
 }
 
 
index fbf47ba05ec19d2cfd2977b9b06e6e146b3ffb31..cd3de9c2824798b3895d88cf3ac0e4637ca6052b 100644 (file)
@@ -33,46 +33,41 @@ SECTIONS
   .hash          : { *(.hash)          }
   .dynsym        : { *(.dynsym)                }
   .dynstr        : { *(.dynstr)                }
-  .rel.text      : { *(.rel.text)              }
+  .rel.text      : { *(.rel.text)      }
   .rela.text     : { *(.rela.text)     }
-  .rel.data      : { *(.rel.data)              }
+  .rel.data      : { *(.rel.data)      }
   .rela.data     : { *(.rela.data)     }
   .rel.rodata    : { *(.rel.rodata)    }
   .rela.rodata   : { *(.rela.rodata)   }
-  .rel.got       : { *(.rel.got)               }
-  .rela.got      : { *(.rela.got)              }
+  .rel.got       : { *(.rel.got)       }
+  .rela.got      : { *(.rela.got)      }
   .rel.ctors     : { *(.rel.ctors)     }
   .rela.ctors    : { *(.rela.ctors)    }
   .rel.dtors     : { *(.rel.dtors)     }
   .rela.dtors    : { *(.rela.dtors)    }
-  .rel.bss       : { *(.rel.bss)               }
-  .rela.bss      : { *(.rela.bss)              }
-  .rel.plt       : { *(.rel.plt)               }
-  .rela.plt      : { *(.rela.plt)              }
-  .init          : { *(.init)  }
+  .rel.bss       : { *(.rel.bss)       }
+  .rela.bss      : { *(.rela.bss)      }
+  .rel.plt       : { *(.rel.plt)       }
+  .rela.plt      : { *(.rela.plt)      }
+  .init          : { *(.init)          }
   .plt : { *(.plt) }
   .text      :
   {
     /* WARNING - the following is hand-optimized to fit within */
     /* the sector layout of our flash chips!   XXX FIXME XXX   */
 
-    cpu/mpc8xx/start.o (.text)
-    common/dlmalloc.o  (.text)
-    lib_ppc/ppcstring.o        (.text)
+    cpu/mpc8xx/start.o         (.text)
+    cpu/mpc8xx/speed.o         (.text)
+    common/dlmalloc.o          (.text)
+    lib_ppc/ppcstring.o                (.text)
     lib_generic/vsprintf.o     (.text)
     lib_generic/crc32.o                (.text)
     lib_generic/zlib.o         (.text)
-  
     lib_generic/ctype.o                (.text) 
-    lib_ppc/extable.o  (.text) 
-    lib_generic/ldiv.o         (.text) 
-    lib_ppc/kgdb.o             (.text) 
     lib_generic/string.o       (.text) 
+    lib_ppc/extable.o          (.text) 
+    lib_ppc/kgdb.o             (.text) 
     lib_ppc/ticks.o            (.text) 
-    lib_ppc/time.o             (.text) 
-  /*
-  lib_generic/display_options.o (.text) 
-   */
 
   . = env_offset;
     common/environment.o(.text)
index debfbe98c3f0ce43bac0aa6453be49eebb1c0966..ad44a202a08dd79875bb97124501119c10eaa1f9 100644 (file)
@@ -56,7 +56,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
@@ -234,7 +234,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
 
        if (info->protect[sect] == 0)
        {       /* not protected */
-           vulong *addr = (vulong *)(info->start[sect]);
+           vu_long *addr = (vu_long *)(info->start[sect]);
 
            MEM_FLASH_ADDR1 = CMD_UNLOCK1;
            MEM_FLASH_ADDR2 = CMD_UNLOCK2;
@@ -316,7 +316,7 @@ outahere:
 
 volatile static int write_word (flash_info_t *info, ulong dest, ulong data)
 {
-    vulong *addr = (vulong *)dest;
+    vu_long *addr = (vu_long *)dest;
     ulong result;
     int rc = ERR_OK;
     int cflag, iflag;
@@ -443,7 +443,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
      * handle word aligned part
      */
     while (cnt >= 4) {
-       data = *((vulong*)src);
+       data = *((vu_long*)src);
        if ((rc = write_word(info, wp, data)) != 0) {
            return (rc);
        }
index 6b0e4693777116a4a3399fbab2ea5c0fe5fca88a..5220e10bebc652282d6331757787652a75c5620a 100644 (file)
@@ -58,7 +58,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
@@ -68,7 +68,7 @@ ulong flash_init(bd_t *bd)
        ulong flashbase = 0;
        flash_info[i].flash_id =
          (INTEL_MANUFACT & FLASH_VENDMASK) |
-         (INTEL_ID_28F640JA3 & FLASH_TYPEMASK);
+         (INTEL_ID_28F640J3A & FLASH_TYPEMASK);
        flash_info[i].size = FLASH_BANK_SIZE;
        flash_info[i].sector_count = CFG_MAX_FLASH_SECT;
        memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
@@ -116,8 +116,8 @@ void flash_print_info  (flash_info_t *info)
 
     switch (info->flash_id & FLASH_TYPEMASK)
     {
-    case (INTEL_ID_28F640JA3 & FLASH_TYPEMASK):
-       printf("2x 28F640JA3 (64Mbit)\n");
+    case (INTEL_ID_28F640J3A & FLASH_TYPEMASK):
+       printf("2x 28F640J3A (64Mbit)\n");
        break;
     default:
        printf("Unknown Chip Type\n");
@@ -281,7 +281,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
 
        if (info->protect[sect] == 0)
        {       /* not protected */
-           vulong *addr = (vulong *)(info->start[sect]);
+           vu_long *addr = (vu_long *)(info->start[sect]);
            ulong bsR7, bsR7_2, bsR5, bsR5_2;
 
            /* *addr = CMD_STATUS_RESET; */
@@ -353,7 +353,7 @@ outahere:
 
 volatile static int write_word (flash_info_t *info, ulong dest, ulong data)
 {
-    vulong *addr = (vulong *)dest;
+    vu_long *addr = (vu_long *)dest;
     ulong result;
     int rc = ERR_OK;
     int iflag;
@@ -459,7 +459,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
      * handle word aligned part
      */
     while (cnt >= 4) {
-       data = *((vulong*)src);
+       data = *((vu_long*)src);
        if ((rc = write_word(info, wp, data)) != 0) {
            return (rc);
        }
index 2ef07223d22d37335066433fc6b817bea475445d..4c00ba24fb70cdd8a6e3ed008b1a806d39abf218 100644 (file)
@@ -56,7 +56,7 @@ flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
 /*-----------------------------------------------------------------------
  */
 
-ulong flash_init(bd_t *bd)
+ulong flash_init(void)
 {
     int i, j;
     ulong size = 0;
index cbebb1ef2f57ec290e2ac2a1c96376e6b67f8450..fb241cd551e498d10743eb668cbe7a783e493e01 100644 (file)
@@ -33,46 +33,42 @@ SECTIONS
   .hash          : { *(.hash)          }
   .dynsym        : { *(.dynsym)                }
   .dynstr        : { *(.dynstr)                }
-  .rel.text      : { *(.rel.text)              }
+  .rel.text      : { *(.rel.text)      }
   .rela.text     : { *(.rela.text)     }
-  .rel.data      : { *(.rel.data)              }
+  .rel.data      : { *(.rel.data)      }
   .rela.data     : { *(.rela.data)     }
   .rel.rodata    : { *(.rel.rodata)    }
   .rela.rodata   : { *(.rela.rodata)   }
-  .rel.got       : { *(.rel.got)               }
-  .rela.got      : { *(.rela.got)              }
+  .rel.got       : { *(.rel.got)       }
+  .rela.got      : { *(.rela.got)      }
   .rel.ctors     : { *(.rel.ctors)     }
   .rela.ctors    : { *(.rela.ctors)    }
   .rel.dtors     : { *(.rel.dtors)     }
   .rela.dtors    : { *(.rela.dtors)    }
-  .rel.bss       : { *(.rel.bss)               }
-  .rela.bss      : { *(.rela.bss)              }
-  .rel.plt       : { *(.rel.plt)               }
-  .rela.plt      : { *(.rela.plt)              }
-  .init          : { *(.init)  }
+  .rel.bss       : { *(.rel.bss)       }
+  .rela.bss      : { *(.rela.bss)      }
+  .rel.plt       : { *(.rel.plt)       }
+  .rela.plt      : { *(.rela.plt)      }
+  .init          : { *(.init)          }
   .plt : { *(.plt) }
   .text      :
   {
     /* WARNING - the following is hand-optimized to fit within */
     /* the sector layout of our flash chips!   XXX FIXME XXX   */
 
-    cpu/mpc8xx/start.o                 (.text)
-    common/dlmalloc.o                  (.text)
-    lib_ppc/ppcstring.o                        (.text)
-    lib_generic/vsprintf.o             (.text)
-    lib_generic/crc32.o                        (.text)
-    lib_generic/zlib.o                 (.text)
-  /*  lib_generic/display_options.o    (.text)
-    lib_generic/ldiv.o                 (.text)
-  */
-    lib_generic/string.o               (.text)
-    lib_ppc/cache.o                    (.text)
-    lib_ppc/extable.o                  (.text)
-    lib_ppc/time.o                     (.text)
-    lib_ppc/ticks.o                    (.text)
+    cpu/mpc8xx/start.o         (.text)
+    cpu/mpc8xx/traps.o         (.text)
+    common/dlmalloc.o          (.text)
+    lib_ppc/ppcstring.o                (.text)
+    lib_generic/vsprintf.o     (.text)
+    lib_generic/crc32.o                (.text)
+    lib_generic/zlib.o         (.text)
+    lib_ppc/cache.o            (.text)
+    lib_ppc/time.o             (.text)
+    lib_ppc/ticks.o            (.text)
 
     . = env_offset;
-    common/environment.o(.text)
+    common/environment.o       (.text)
 
     *(.text)
     *(.fixup)
index a646b527f75c3f20e9a360020b9b8ba163391845..cd80c86b7e428e4641c1aa23d7731d37122bec1a 100644 (file)
@@ -253,18 +253,9 @@ load_serial (ulong offset)
                    if (addr2info(store_addr)) {
                        int rc;
 
-                       switch (rc=flash_write((uchar *)binbuf,store_addr,binlen))
-                       {
-                       case 0: break;
-                       case 1: printf ("\nError: Timeout writing to Flash\n");
-                               return (~0);
-                       case 2: printf ("\nError: Flash not Erased\n");
-                               return (~0);
-                       case 4: printf ("\nError: Can't write to protected Flash sectors\n");
-                               return (~0);
-                       default:
-                               printf ("%s[%d] FIXME: rc=%d\n",
-                                       __FILE__,__LINE__,rc);
+                       rc = flash_write((uchar *)binbuf,store_addr,binlen);
+                       if (rc != 0) {
+                               flash_perror (rc);
                                return (~0);
                        }
                    } else {
index 3eaa629f955c955a2648b19b4eff32d809980dde..8aa9622ba4e5aceebc2a1754bdcd855d953689ef 100644 (file)
@@ -304,23 +304,14 @@ int do_mem_cp    (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                int rc;
 
                printf ("Copy to Flash... ");
-               switch (rc = flash_write ((uchar *)addr, dest, count*size)) {
-               case 0: printf ("done\n");
-                       return 0;
-               case 1: printf ("Timeout writing to Flash\n");
-                       return 1;
-               case 2: printf ("Flash not Erased\n");
-                       return 1;
-               case 4: printf ("Can't write to protected Flash sectors\n");
-                       return 1;
-               case 8: printf ("Outside available Flash\n");
-                       return 1;
-               case 16:printf ("Size must be aligned (multiple of 8?)\n");
-                       return 1;
-               default:
-                       printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
-                       return 1;
+
+               rc = flash_write ((uchar *)addr, dest, count*size);
+               if (rc != 0) {
+                       flash_perror (rc);
+                       return (1);
                }
+               puts ("done\n");
+               return 0;
        }
 #endif
 
index 3abb6e6e26b0f7b3e4bd544094f5042c47dadd32..871b109599a8cb953aa5324bbcf38e6b36044386 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000, 2001
+ * (C) Copyright 2000-2002
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  * MA 02111-1307 USA
  */
 
-/*
+/**************************************************************************
+ *
  * Support for persistent environment data
+ *
+ * The "environment" is stored as a list of '\0' terminated
+ * "name=value" strings. The end of the list is marked by a double
+ * '\0'. New entries are always added at the end. Deleting an entry
+ * shifts the remaining entries to the front. Replacing an entry is a
+ * combination of deleting the old value and adding the new one.
+ * 
+ * The environment is preceeded by a 32 bit CRC over the data part.
+ *
+ **************************************************************************
  */
 
 /*
@@ -46,6 +57,7 @@
 
 #include <ppcboot.h>
 #include <command.h>
+#include <environment.h>
 #include <cmd_nvedit.h>
 #include <linux/stddef.h>
 #if (CONFIG_COMMANDS & CFG_CMD_NET)
 static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE;
 #define        N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0]))
 
-/************************************************************************
- *
- * The environment storages is simply a list of '\0'-terminated
- * "name=value" strings, the end of the list marked by a double '\0'.
- * New entries are always added at the end. Deleting an entry shifts
- * the remaining entries to the front. Replacing an entry is a
- * combination of deleting the old and adding the new value.
- *
- * The environment is preceeded by a 32 bit CRC over the data part.
- *
- ************************************************************************
- */
-
 /*---------------------------------------------------------------------*/
 #undef DEBUG_ENV
 
@@ -89,31 +88,10 @@ static const unsigned long baudrate_table[] = CFG_BAUDRATE_TABLE;
 /*---------------------------------------------------------------------*/
 
 
-#if defined(CFG_ENV_IS_IN_FLASH)
-# ifndef  CFG_ENV_ADDR
-#  define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
-# endif
-# ifndef  CFG_ENV_SIZE
-#  define CFG_ENV_SIZE CFG_ENV_SECT_SIZE
-# endif
-# if (CFG_ENV_ADDR >= CFG_MONITOR_BASE) && \
-     (CFG_ENV_ADDR+CFG_ENV_SIZE) <= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)
-#  define ENV_IS_EMBEDDED
-# endif
-#endif /* CFG_ENV_IS_IN_FLASH */
-
-#define ENV_SIZE (CFG_ENV_SIZE - sizeof(long))
-
 #if !defined(ENV_IS_EMBEDDED)
 #include <malloc.h>
 #endif
 
-
-typedef        struct environment_s {
-       ulong   crc;                    /* CRC32 over data bytes        */
-       uchar   data[ENV_SIZE];
-} env_t;
-
 /*---  NVRAM  ----------------------------------------------------------*/
 #ifdef CFG_ENV_IS_IN_NVRAM                     /* Environment is in NVRAM      */
 
@@ -923,23 +901,12 @@ int saveenv(void)
                return 1;
 
        puts ("Writing to Flash... ");
-       switch (rc = flash_write(env_buffer, (ulong)flash_sect_addr, len)) {
-       case 0: puts ("done\n");
-               break;
-       case 1: puts ("Timeout writing to Flash\n");
-               rcode = 1;
-               break;
-       case 2: puts ("Flash not Erased\n");
-               rcode = 1;
-               break;
-       case 4: puts ("Can't write to protected Flash sectors\n");
-               rcode = 1;
-               break;
-       case 8: puts ("Outside available Flash\n");
-               return 1;
-       default:
-               printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
+       rc = flash_write(env_buffer, (ulong)flash_sect_addr, len);
+       if (rc != 0) {
+               flash_perror (rc);
                rcode = 1;
+       } else {
+               puts ("done\n");
        }
 
        /* try to re-protect */
index 956589276de28d4962071bad088a628b38f58707..b777a9f4be08b38e2cfb8d7dafd81410ba80d2aa 100644 (file)
@@ -179,4 +179,41 @@ flash_write (uchar *src, ulong addr, ulong cnt)
 /*-----------------------------------------------------------------------
  */
 
+void flash_perror (int err)
+{
+       switch (err) {
+       case ERR_OK:
+               break;
+       case ERR_TIMOUT:
+               puts ("Timeout writing to Flash\n");
+               break;
+       case ERR_NOT_ERASED:
+               puts ("Flash not Erased\n");
+               break;
+       case ERR_PROTECTED:
+               puts ("Can't write to protected Flash sectors\n");
+               break;
+       case ERR_INVAL:
+               puts ("Outside available Flash\n");
+               break;
+       case ERR_ALIGN:
+               puts ("Start and/or end address not on sector boundary\n");
+               break;
+       case ERR_UNKNOWN_FLASH_VENDOR:
+               puts ("Unknown Vendor of Flash\n");
+               break;
+       case ERR_UNKNOWN_FLASH_TYPE:
+               puts ("Unknown Type of Flash\n");
+               break;
+       case ERR_PROG_ERROR:
+               puts ("General Flash Programming Error\n");
+               break;
+       default:
+               printf ("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err);
+               break;
+       }
+}
+
+/*-----------------------------------------------------------------------
+ */
 #endif /* !CFG_NO_FLASH */
index fc5ead5d60a25141ea10f541bba9e90f19b2900f..ad76611622cc88c80a4c1927678217fcc9db8453 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -95,7 +95,7 @@ RANLIB        = $(CROSS_COMPILE)RANLIB
 
 RELFLAGS= $(PLATFORM_RELFLAGS)
 DBGFLAGS= -g #-DDEBUG
-OPTFLAGS= -Os -fomit-frame-pointer
+OPTFLAGS= -Os #-fomit-frame-pointer
 #LDSCRIPT := board/$(BOARDDIR)/ppcboot.lds.debug
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/ppcboot.lds
 OBJCFLAGS := --gap-fill=0xff
diff --git a/include/armboot.h b/include/armboot.h
new file mode 100644 (file)
index 0000000..e6cb10b
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ * 
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <azu@sysgo.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _ARMBOOT_H_
+#define _ARMBOOT_H_    1
+
+#include <environment.h>
+
+typedef struct bd_info {
+    int                        bi_baudrate;    /* serial console baudrate */
+    unsigned long      bi_ip_addr;     /* IP Address */
+    unsigned char      bi_enetaddr[6]; /* Ethernet adress */
+    struct environment_s              *bi_env;
+    ulong              bi_arch_number; /* unique id for this board */
+    ulong              bi_boot_params; /* where this board expects params */
+    struct                             /* RAM configuration */
+    { 
+       ulong start;
+       ulong size;
+    }                  bi_dram[CONFIG_NR_DRAM_BANKS];
+    struct bd_info_ext bi_ext;         /* board specific extension */
+} bd_t;
+
+#define bi_env_data bi_env->data
+#define bi_env_crc  bi_env->crc
+
+/* for the following variables, see start.S */
+extern ulong _armboot_start; /* code start */
+extern ulong _armboot_end;   /* code end */ 
+extern ulong IRQ_STACK_START; /* top of IRQ stack */
+extern ulong FIQ_STACK_START; /* top of FIQ stack */
+extern ulong _armboot_real_end; /* first usable RAM address */
+
+/* ------------------------------------------------------------ */
+/* Here is a list of some prototypes which are incompatible to */
+/* the PPCBoot implementation                                  */
+/* To be fixed!                                                        */
+/* ------------------------------------------------------------ */
+/* common/cmd_nvedit.c */
+void   env_init        (bd_t *bd);
+void   env_relocate    (bd_t *bd);
+char   *getenv         (bd_t *bd, uchar *);
+void   setenv          (bd_t *bd, char *, char *);
+
+/* cpu/.../cpu.c */
+void cpu_init(bd_t *bd);
+void cleanup_before_linux(bd_t *bd);
+
+/* board/.../... */
+int board_init(bd_t *);
+int dram_init(bd_t *bd);
+
+/* arm/display_options.c */
+void display_banner(bd_t *bd);
+void display_dram_config(bd_t *bd);
+void display_flash_config(bd_t *bd, ulong size);
+
+/* $(CPU)/serial.c */
+void   serial_init     (bd_t *);
+void   serial_setbrg   (bd_t *, int);
+void   serial_putc     (const char);
+void   serial_puts     (const char *);
+void   serial_addr     (unsigned int);
+int    serial_getc     (void);
+int    serial_tstc     (void);
+
+/* cpu/.../interrupt.c */
+void   reset_timer_masked      (void);
+ulong  get_timer_masked        (void);
+void   udelay_masked           (unsigned long usec);
+
+#if 0 /*------------------------------------------------------------*/
+/* arm/crc32.c */
+ulong  crc32           (ulong, const unsigned char *, uint);
+ulong  crc32_no_comp   (ulong crc, const unsigned char *, uint);
+
+/*
+ * Don't define some stuff private to armboot target code
+ */
+#ifndef HOST_TOOLS
+
+/* board/.../env.c */
+int    board_env_getchar(bd_t * bd, int index, uchar *c);
+int    board_env_save  (bd_t * bd, env_t *data, int size);
+int    board_env_copy  (bd_t * bd, env_t *data, int size);
+uchar *        board_env_getaddr(bd_t * bd, int index);
+
+/*
+ * Function Prototypes
+ */
+void   hang            (void);
+void   start_armboot   (void);
+void   main_loop       (bd_t *);
+int    run_command     (const char *cmd, bd_t *, int flag);
+int    readline        (const char *const prompt);
+void   reset_cmd_timeout(void);
+
+
+/* arm/string.c */
+char * strcpy          (char * dest,const char *src);
+char * strncpy         (char * dest,const char *src, size_t count);
+size_t strlen          (const char *);
+size_t strnlen         (const char * s, size_t count);
+int    strncmp         (const char * cs, const char * ct, size_t count);
+int    strcmp          (const char * cs, const char * ct);
+void * memcpy          (void * dest, const void *src, size_t count);
+int    memcmp          (const void * dest, const void *src, size_t count);
+void * memset          (void * s, char c, size_t count);
+void * memmove         (void * dest, const void *src, size_t count);
+char * strchr          (const char * s, int c);
+
+/* arm/vsprintf.c */
+ulong  simple_strtoul  (const char *cp,char **endp,unsigned int base);
+long   simple_strtol   (const char *cp,char **endp,unsigned int base);
+void   panic           (const char *fmt, ...);
+int    sprintf         (char * buf, const char *fmt, ...);
+int    vsprintf        (char *buf, const char *fmt, va_list args);
+
+void    udelay         (unsigned long);
+
+int    ctrlc           (void);
+int    had_ctrlc       (void);
+void   clear_ctrlc     (void);
+int    disable_ctrlc   (int);
+
+int    console_assign  (int file, char *devname);
+
+/* */
+int    icache_status (void);
+void   icache_enable (void);
+void   icache_disable(void);
+int    dcache_status (void);
+void   dcache_enable (void);
+void   dcache_disable(void);
+
+/* common/cmd_bootm.c */
+void print_image_hdr (image_header_t *hdr);
+
+/* cpu/.../interrupt.c */
+void   enable_interrupts       (void);
+int    disable_interrupts      (void);
+void   interrupt_init          (bd_t *bd);
+void   reset_timer             (void);
+ulong  get_timer               (ulong base);
+void   set_timer               (ulong t);
+
+extern ulong load_addr;
+
+/*
+ * STDIO based functions (can always be used)
+ */
+
+/* serial stuff */
+void   serial_printf (const char *fmt, ...);
+
+/* stdin */
+int    getc(void);
+int    tstc(void);
+
+/* stdout */
+void   putc(const char c);
+void   puts(const char *s);
+void   printf(const char *fmt, ...);
+
+/* stderr */
+#define eputc(c)               fputc(stderr, c)
+#define eputs(s)               fputs(stderr, s)
+#define eprintf(fmt,args...)   fprintf(stderr,fmt ,##args)
+
+/*
+ * FILE based functions (can only be used AFTER relocation!)
+ */
+
+#define stdin          0
+#define stdout         1
+#define stderr         2
+#define MAX_FILES      3
+
+void   fprintf(int file, const char *fmt, ...);
+void   fputs(int file, const char *s);
+void   fputc(int file, const char c);
+int    ftstc(int file);
+int    fgetc(int file);
+
+/* Byte swapping stuff */
+#define SWAP16(x)      ((((x) & 0xff) << 8) | ((x) >> 8))
+#define SWAP16c(x)     ((((x) & 0xff) << 8) | ((x) >> 8))
+#define SWAP32(x)       ( \
+                       (((x) >> 24) & 0x000000ff) | \
+                       (((x) >>  8) & 0x0000ff00) | \
+                       (((x) <<  8) & 0x00ff0000) | \
+                       (((x) << 24) & 0xff000000) )
+
+#endif /* HOST_TOOLS */
+#endif /* 0 ------------------------------------------------------------*/
+
+#endif /* _ARMBOOT_H_ */
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
new file mode 100644 (file)
index 0000000..d6419dd
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright 1995, Russell King.
+ * Various bits and pieces copyrights include:
+ *  Linus Torvalds (test_bit).
+ *
+ * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
+ *
+ * Please note that the code in this file should never be included
+ * from user space.  Many of these are not implemented in assembler
+ * since they would be too costly.  Also, they require priviledged
+ * instructions (which are not available from user mode) to ensure
+ * that they are atomic.
+ */
+
+#ifndef __ASM_ARM_BITOPS_H
+#define __ASM_ARM_BITOPS_H
+
+#ifdef __KERNEL__
+
+#define smp_mb__before_clear_bit()     do { } while (0)
+#define smp_mb__after_clear_bit()      do { } while (0)
+
+/*
+ * Function prototypes to keep gcc -Wall happy.
+ */
+extern void set_bit(int nr, volatile void * addr);
+
+static inline void __set_bit(int nr, volatile void *addr)
+{
+       ((unsigned char *) addr)[nr >> 3] |= (1U << (nr & 7));
+}
+
+extern void clear_bit(int nr, volatile void * addr);
+
+static inline void __clear_bit(int nr, volatile void *addr)
+{
+       ((unsigned char *) addr)[nr >> 3] &= ~(1U << (nr & 7));
+}
+
+extern void change_bit(int nr, volatile void * addr);
+
+static inline void __change_bit(int nr, volatile void *addr)
+{
+       ((unsigned char *) addr)[nr >> 3] ^= (1U << (nr & 7));
+}
+
+extern int test_and_set_bit(int nr, volatile void * addr);
+
+static inline int __test_and_set_bit(int nr, volatile void *addr)
+{
+       unsigned int mask = 1 << (nr & 7);
+       unsigned int oldval;
+
+       oldval = ((unsigned char *) addr)[nr >> 3];
+       ((unsigned char *) addr)[nr >> 3] = oldval | mask;
+       return oldval & mask;
+}
+
+extern int test_and_clear_bit(int nr, volatile void * addr);
+
+static inline int __test_and_clear_bit(int nr, volatile void *addr)
+{
+       unsigned int mask = 1 << (nr & 7);
+       unsigned int oldval;
+
+       oldval = ((unsigned char *) addr)[nr >> 3];
+       ((unsigned char *) addr)[nr >> 3] = oldval & ~mask;
+       return oldval & mask;
+}
+
+extern int test_and_change_bit(int nr, volatile void * addr);
+
+static inline int __test_and_change_bit(int nr, volatile void *addr)
+{
+       unsigned int mask = 1 << (nr & 7);
+       unsigned int oldval;
+
+       oldval = ((unsigned char *) addr)[nr >> 3];
+       ((unsigned char *) addr)[nr >> 3] = oldval ^ mask;
+       return oldval & mask;
+}
+
+extern int find_first_zero_bit(void * addr, unsigned size);
+extern int find_next_zero_bit(void * addr, int size, int offset);
+
+/*
+ * This routine doesn't need to be atomic.
+ */
+static inline int test_bit(int nr, const void * addr)
+{
+    return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
+}      
+
+/*
+ * ffz = Find First Zero in word. Undefined if no zero exists,
+ * so code should check against ~0UL first..
+ */
+static inline unsigned long ffz(unsigned long word)
+{
+       int k;
+
+       word = ~word;
+       k = 31;
+       if (word & 0x0000ffff) { k -= 16; word <<= 16; }
+       if (word & 0x00ff0000) { k -= 8;  word <<= 8;  }
+       if (word & 0x0f000000) { k -= 4;  word <<= 4;  }
+       if (word & 0x30000000) { k -= 2;  word <<= 2;  }
+       if (word & 0x40000000) { k -= 1; }
+        return k;
+}
+
+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+#define ffs(x) generic_ffs(x)
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+#define hweight32(x) generic_hweight32(x)
+#define hweight16(x) generic_hweight16(x)
+#define hweight8(x) generic_hweight8(x)
+
+#define ext2_set_bit                   test_and_set_bit
+#define ext2_clear_bit                 test_and_clear_bit
+#define ext2_test_bit                  test_bit
+#define ext2_find_first_zero_bit       find_first_zero_bit
+#define ext2_find_next_zero_bit                find_next_zero_bit
+
+/* Bitmap functions for the minix filesystem. */
+#define minix_test_and_set_bit(nr,addr)        test_and_set_bit(nr,addr)
+#define minix_set_bit(nr,addr)         set_bit(nr,addr)
+#define minix_test_and_clear_bit(nr,addr)      test_and_clear_bit(nr,addr)
+#define minix_test_bit(nr,addr)                test_bit(nr,addr)
+#define minix_find_first_zero_bit(addr,size)   find_first_zero_bit(addr,size)
+
+#endif /* __KERNEL__ */
+
+#endif /* _ARM_BITOPS_H */
diff --git a/include/asm-arm/byteorder.h b/include/asm-arm/byteorder.h
new file mode 100644 (file)
index 0000000..d648a19
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  linux/include/asm-arm/byteorder.h
+ *
+ * ARM Endian-ness.  In little endian mode, the data bus is connected such
+ * that byte accesses appear as:
+ *  0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
+ * and word accesses (data or instruction) appear as:
+ *  d0...d31
+ *
+ * When in big endian mode, byte accesses appear as:
+ *  0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
+ * and word accesses (data or instruction) appear as:
+ *  d0...d31
+ */
+#ifndef __ASM_ARM_BYTEORDER_H
+#define __ASM_ARM_BYTEORDER_H
+
+
+#include <asm/types.h>
+
+#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
+#  define __BYTEORDER_HAS_U64__
+#  define __SWAB_64_THRU_32__
+#endif
+
+#ifdef __ARMEB__
+#include <linux/byteorder/big_endian.h>
+#else
+#include <linux/byteorder/little_endian.h>
+#endif
+
+#endif
+
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
new file mode 100644 (file)
index 0000000..cff09e5
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ *  linux/include/asm-arm/io.h
+ *
+ *  Copyright (C) 1996-2000 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Modifications:
+ *  16-Sep-1996        RMK     Inlined the inx/outx functions & optimised for both
+ *                     constant addresses and variable addresses.
+ *  04-Dec-1997        RMK     Moved a lot of this stuff to the new architecture
+ *                     specific IO header files.
+ *  27-Mar-1999        PJB     Second parameter of memcpy_toio is const..
+ *  04-Apr-1999        PJB     Added check_signature.
+ *  12-Dec-1999        RMK     More cleanups
+ *  18-Jun-2000 RMK    Removed virt_to_* and friends definitions
+ */
+#ifndef __ASM_ARM_IO_H
+#define __ASM_ARM_IO_H
+
+#ifdef __KERNEL__
+
+#include <linux/types.h>
+#include <asm/memory.h>
+#include <asm/arch/hardware.h>
+
+/*
+ * Generic virtual read/write.  Note that we don't support half-word
+ * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
+ * to the architecture specific code.
+ */
+#define __arch_getb(a)                 (*(volatile unsigned char *)(a))
+#define __arch_getl(a)                 (*(volatile unsigned int  *)(a))
+
+#define __arch_putb(v,a)               (*(volatile unsigned char *)(a) = (v))
+#define __arch_putl(v,a)               (*(volatile unsigned int  *)(a) = (v))
+
+extern void __raw_writesb(unsigned int addr, const void *data, int bytelen);
+extern void __raw_writesw(unsigned int addr, const void *data, int wordlen);
+extern void __raw_writesl(unsigned int addr, const void *data, int longlen);
+
+extern void __raw_readsb(unsigned int addr, void *data, int bytelen);
+extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
+extern void __raw_readsl(unsigned int addr, void *data, int longlen);
+
+#define __raw_writeb(v,a)              __arch_putb(v,a)
+#define __raw_writew(v,a)              __arch_putw(v,a)
+#define __raw_writel(v,a)              __arch_putl(v,a)
+
+#define __raw_readb(a)                 __arch_getb(a)
+#define __raw_readw(a)                 __arch_getw(a)
+#define __raw_readl(a)                 __arch_getl(a)
+
+/*
+ * The compiler seems to be incapable of optimising constants
+ * properly.  Spell it out to the compiler in some cases.
+ * These are only valid for small values of "off" (< 1<<12)
+ */
+#define __raw_base_writeb(val,base,off)        __arch_base_putb(val,base,off)
+#define __raw_base_writew(val,base,off)        __arch_base_putw(val,base,off)
+#define __raw_base_writel(val,base,off)        __arch_base_putl(val,base,off)
+
+#define __raw_base_readb(base,off)     __arch_base_getb(base,off)
+#define __raw_base_readw(base,off)     __arch_base_getw(base,off)
+#define __raw_base_readl(base,off)     __arch_base_getl(base,off)
+
+/*
+ * Now, pick up the machine-defined IO definitions
+ */
+#include <asm/arch/io.h>
+
+/*
+ * IO definitions.  We define {out,in,outs,ins}[bwl] if __io is defined
+ * by the machine.  Otherwise, these definitions are left for the machine
+ * specific header files to pick up.
+ *
+ * Note that we prevent GCC re-ordering or caching values in expressions
+ * by introducing sequence points into the in*() definitions.  Note that
+ * __raw_* do not guarantee this behaviour.
+ */
+#ifdef __io
+#define outb(v,p)                      __raw_writeb(v,__io(p))
+#define outw(v,p)                      __raw_writew(v,__io(p))
+#define outl(v,p)                      __raw_writel(v,__io(p))
+
+#define inb(p)         ({ unsigned int __v = __raw_readb(__io(p)); __v; })
+#define inw(p)         ({ unsigned int __v = __raw_readw(__io(p)); __v; })
+#define inl(p)         ({ unsigned int __v = __raw_readl(__io(p)); __v; })
+
+#define outsb(p,d,l)                   __raw_writesb(__io(p),d,l)
+#define outsw(p,d,l)                   __raw_writesw(__io(p),d,l)
+#define outsl(p,d,l)                   __raw_writesl(__io(p),d,l)
+
+#define insb(p,d,l)                    __raw_readsb(__io(p),d,l)
+#define insw(p,d,l)                    __raw_readsw(__io(p),d,l)
+#define insl(p,d,l)                    __raw_readsl(__io(p),d,l)
+#endif
+
+#define outb_p(val,port)               outb((val),(port))
+#define outw_p(val,port)               outw((val),(port))
+#define outl_p(val,port)               outl((val),(port))
+#define inb_p(port)                    inb((port))
+#define inw_p(port)                    inw((port))
+#define inl_p(port)                    inl((port))
+
+#define outsb_p(port,from,len)         outsb(port,from,len)
+#define outsw_p(port,from,len)         outsw(port,from,len)
+#define outsl_p(port,from,len)         outsl(port,from,len)
+#define insb_p(port,to,len)            insb(port,to,len)
+#define insw_p(port,to,len)            insw(port,to,len)
+#define insl_p(port,to,len)            insl(port,to,len)
+
+/*
+ * ioremap and friends.
+ *
+ * ioremap takes a PCI memory address, as specified in
+ * linux/Documentation/IO-mapping.txt.  If you want a
+ * physical address, use __ioremap instead.
+ */
+extern void * __ioremap(unsigned long offset, size_t size, unsigned long flags);
+extern void __iounmap(void *addr);
+
+/*
+ * Generic ioremap support.
+ *
+ * Define:
+ *  iomem_valid_addr(off,size)
+ *  iomem_to_phys(off)
+ */
+#ifdef iomem_valid_addr
+#define __arch_ioremap(off,sz,nocache)                         \
+ ({                                                            \
+       unsigned long _off = (off), _size = (sz);               \
+       void *_ret = (void *)0;                                 \
+       if (iomem_valid_addr(_off, _size))                      \
+               _ret = __ioremap(iomem_to_phys(_off),_size,0);  \
+       _ret;                                                   \
+ })
+
+#define __arch_iounmap __iounmap
+#endif
+
+#define ioremap(off,sz)                        __arch_ioremap((off),(sz),0)
+#define ioremap_nocache(off,sz)                __arch_ioremap((off),(sz),1)
+#define iounmap(_addr)                 __arch_iounmap(_addr)
+
+/*
+ * DMA-consistent mapping functions.  These allocate/free a region of
+ * uncached, unwrite-buffered mapped memory space for use with DMA
+ * devices.  This is the "generic" version.  The PCI specific version
+ * is in pci.h
+ */
+extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle);
+extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
+extern void consistent_sync(void *vaddr, size_t size, int rw);
+
+/*
+ * String version of IO memory access ops:
+ */
+extern void _memcpy_fromio(void *, unsigned long, size_t);
+extern void _memcpy_toio(unsigned long, const void *, size_t);
+extern void _memset_io(unsigned long, int, size_t);
+
+extern void __readwrite_bug(const char *fn);
+
+/*
+ * If this architecture has PCI memory IO, then define the read/write
+ * macros.  These should only be used with the cookie passed from
+ * ioremap.
+ */
+#ifdef __mem_pci
+
+#define readb(addr) ({ unsigned int __v = __raw_readb(__mem_pci(addr)); __v; })
+#define readw(addr) ({ unsigned int __v = __raw_readw(__mem_pci(addr)); __v; })
+#define readl(addr) ({ unsigned int __v = __raw_readl(__mem_pci(addr)); __v; })
+
+#define writeb(val,addr)               __raw_writeb(val,__mem_pci(addr))
+#define writew(val,addr)               __raw_writew(val,__mem_pci(addr))
+#define writel(val,addr)               __raw_writel(val,__mem_pci(addr))
+
+#define memset_io(a,b,c)               _memset_io(__mem_pci(a),(b),(c))
+#define memcpy_fromio(a,b,c)           _memcpy_fromio((a),__mem_pci(b),(c))
+#define memcpy_toio(a,b,c)             _memcpy_toio(__mem_pci(a),(b),(c))
+
+#define eth_io_copy_and_sum(a,b,c,d) \
+                               eth_copy_and_sum((a),__mem_pci(b),(c),(d))
+
+static inline int
+check_signature(unsigned long io_addr, const unsigned char *signature,
+               int length)
+{
+       int retval = 0;
+       do {
+               if (readb(io_addr) != *signature)
+                       goto out;
+               io_addr++;
+               signature++;
+               length--;
+       } while (length);
+       retval = 1;
+out:
+       return retval;
+}
+
+#elif !defined(readb)
+
+#define readb(addr)                    (__readwrite_bug("readb"),0)
+#define readw(addr)                    (__readwrite_bug("readw"),0)
+#define readl(addr)                    (__readwrite_bug("readl"),0)
+#define writeb(v,addr)                 __readwrite_bug("writeb")
+#define writew(v,addr)                 __readwrite_bug("writew")
+#define writel(v,addr)                 __readwrite_bug("writel")
+
+#define eth_io_copy_and_sum(a,b,c,d)   __readwrite_bug("eth_io_copy_and_sum")
+
+#define check_signature(io,sig,len)    (0)
+
+#endif /* __mem_pci */
+
+/*
+ * remap a physical address `phys' of size `size' with page protection `prot'
+ * into virtual address `from'
+ */
+#define io_remap_page_range(from,phys,size,prot) \
+               remap_page_range(from,phys,size,prot)
+
+
+/*
+ * If this architecture has ISA IO, then define the isa_read/isa_write
+ * macros.
+ */
+#ifdef __mem_isa
+
+#define isa_readb(addr)                        __raw_readb(__mem_isa(addr))
+#define isa_readw(addr)                        __raw_readw(__mem_isa(addr))
+#define isa_readl(addr)                        __raw_readl(__mem_isa(addr))
+#define isa_writeb(val,addr)           __raw_writeb(val,__mem_isa(addr))
+#define isa_writew(val,addr)           __raw_writew(val,__mem_isa(addr))
+#define isa_writel(val,addr)           __raw_writel(val,__mem_isa(addr))
+#define isa_memset_io(a,b,c)           _memset_io(__mem_isa(a),(b),(c))
+#define isa_memcpy_fromio(a,b,c)       _memcpy_fromio((a),__mem_isa(b),(c))
+#define isa_memcpy_toio(a,b,c)         _memcpy_toio(__mem_isa((a)),(b),(c))
+
+#define isa_eth_io_copy_and_sum(a,b,c,d) \
+                               eth_copy_and_sum((a),__mem_isa(b),(c),(d))
+
+static inline int
+isa_check_signature(unsigned long io_addr, const unsigned char *signature,
+                   int length)
+{
+       int retval = 0;
+       do {
+               if (isa_readb(io_addr) != *signature)
+                       goto out;
+               io_addr++;
+               signature++;
+               length--;
+       } while (length);
+       retval = 1;
+out:
+       return retval;
+}
+
+#else  /* __mem_isa */
+
+#define isa_readb(addr)                        (__readwrite_bug("isa_readb"),0)
+#define isa_readw(addr)                        (__readwrite_bug("isa_readw"),0)
+#define isa_readl(addr)                        (__readwrite_bug("isa_readl"),0)
+#define isa_writeb(val,addr)           __readwrite_bug("isa_writeb")
+#define isa_writew(val,addr)           __readwrite_bug("isa_writew")
+#define isa_writel(val,addr)           __readwrite_bug("isa_writel")
+#define isa_memset_io(a,b,c)           __readwrite_bug("isa_memset_io")
+#define isa_memcpy_fromio(a,b,c)       __readwrite_bug("isa_memcpy_fromio")
+#define isa_memcpy_toio(a,b,c)         __readwrite_bug("isa_memcpy_toio")
+
+#define isa_eth_io_copy_and_sum(a,b,c,d) \
+                               __readwrite_bug("isa_eth_io_copy_and_sum")
+
+#define isa_check_signature(io,sig,len)        (0)
+
+#endif /* __mem_isa */
+#endif /* __KERNEL__ */
+#endif /* __ASM_ARM_IO_H */
diff --git a/include/environment.h b/include/environment.h
new file mode 100644 (file)
index 0000000..e300c4e
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _ENVIRONMENT_H_
+#define _ENVIRONMENT_H_        1
+
+/**************************************************************************
+ *
+ * The "environment" is stored as a list of '\0' terminated
+ * "name=value" strings. The end of the list is marked by a double
+ * '\0'. New entries are always added at the end. Deleting an entry
+ * shifts the remaining entries to the front. Replacing an entry is a
+ * combination of deleting the old value and adding the new one.
+ * 
+ * The environment is preceeded by a 32 bit CRC over the data part.
+ *
+ **************************************************************************
+ */
+
+#if defined(CFG_ENV_IS_IN_FLASH)
+# ifndef  CFG_ENV_ADDR
+#  define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
+# endif
+# ifndef  CFG_ENV_SIZE
+#  define CFG_ENV_SIZE CFG_ENV_SECT_SIZE
+# endif
+# if (CFG_ENV_ADDR >= CFG_MONITOR_BASE) && \
+     (CFG_ENV_ADDR+CFG_ENV_SIZE) <= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)
+#  define ENV_IS_EMBEDDED
+# endif
+#endif /* CFG_ENV_IS_IN_FLASH */
+
+#define ENV_SIZE (CFG_ENV_SIZE - sizeof(long))
+
+typedef        struct environment_s {
+       ulong   crc;                    /* CRC32 over data bytes        */
+       uchar   data[CFG_ENV_SIZE - sizeof(ulong)];
+} env_t;
+
+#endif /* _ENVIRONMENT_H_ */
index 77e740179f416ce9e2f4ace75d8d29a840a8f43a..fe6e955cf203c693564f49b49c013c8695eacc84 100644 (file)
@@ -36,13 +36,13 @@ typedef struct {
        ulong   start[CFG_MAX_FLASH_SECT];   /* physical sector start addresses */
        uchar   protect[CFG_MAX_FLASH_SECT]; /* sector protection status        */
 #ifdef CFG_FLASH_CFI
-       uchar   portwidth;              /* the width of the port                */
-       uchar   chipwidth;              /* the width of the chip                */
-       ushort  buffer_size;            /* # of bytes in write buffer           */
-       ulong   erase_blk_tout;         /* maximum block erase timeout          */
-       ulong   write_tout;             /* maximum write timeout                */
-       ulong   buffer_write_tout;      /* maximum buffer write timeout         */
-        
+       uchar   portwidth;              /* the width of the port                */
+       uchar   chipwidth;              /* the width of the chip                */
+       ushort  buffer_size;            /* # of bytes in write buffer           */
+       ulong   erase_blk_tout;         /* maximum block erase timeout          */
+       ulong   write_tout;             /* maximum write timeout                */
+       ulong   buffer_write_tout;      /* maximum buffer write timeout         */
+
 #endif
 } flash_info_t;
 
@@ -83,12 +83,15 @@ extern int flash_real_protect(flash_info_t *info, long sector, int prot);
 /*-----------------------------------------------------------------------
  * return codes from flash_write():
  */
-#define ERR_OK          0
-#define ERR_TIMOUT      1
-#define ERR_NOT_ERASED  2
-#define ERR_PROTECTED   4
-#define ERR_INVAL       8
-#define ERR_ALIGN       16
+#define ERR_OK                         0
+#define ERR_TIMOUT                     1
+#define ERR_NOT_ERASED                 2
+#define ERR_PROTECTED                  4
+#define ERR_INVAL                      8
+#define ERR_ALIGN                      16
+#define ERR_UNKNOWN_FLASH_VENDOR       32
+#define ERR_UNKNOWN_FLASH_TYPE         64
+#define ERR_PROG_ERROR                 128
 
 /*-----------------------------------------------------------------------
  * Protection Flags for flash_protect():
@@ -122,7 +125,7 @@ extern int flash_real_protect(flash_info_t *info, long sector, int prot);
 
 #define AMD_ID_F080B   0xD5            /* 29F080  ID  ( 1 M)                   */
 #define AMD_ID_F016D   0xAD            /* 29F016  ID  ( 2 M x 8)               */
-#define AMD_ID_LV116DT 0xC7            /* 29LV116DT   ( 2 M x 8, top boot sect) */ 
+#define AMD_ID_LV116DT 0xC7            /* 29LV116DT   ( 2 M x 8, top boot sect) */
 
 #define AMD_ID_LV400T  0x22B922B9      /* 29LV400T ID ( 4 M, top boot sector)  */
 #define AMD_ID_LV400B  0x22BA22BA      /* 29LV400B ID ( 4 M, bottom boot sect) */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
new file mode 100644 (file)
index 0000000..1431663
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
+#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
+
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+#ifndef __LITTLE_ENDIAN_BITFIELD
+#define __LITTLE_ENDIAN_BITFIELD
+#endif
+
+#include <linux/byteorder/swab.h>
+
+#define __constant_htonl(x) ___constant_swab32((x))
+#define __constant_ntohl(x) ___constant_swab32((x))
+#define __constant_htons(x) ___constant_swab16((x))
+#define __constant_ntohs(x) ___constant_swab16((x))
+#define __constant_cpu_to_le64(x) ((__u64)(x))
+#define __constant_le64_to_cpu(x) ((__u64)(x))
+#define __constant_cpu_to_le32(x) ((__u32)(x))
+#define __constant_le32_to_cpu(x) ((__u32)(x))
+#define __constant_cpu_to_le16(x) ((__u16)(x))
+#define __constant_le16_to_cpu(x) ((__u16)(x))
+#define __constant_cpu_to_be64(x) ___constant_swab64((x))
+#define __constant_be64_to_cpu(x) ___constant_swab64((x))
+#define __constant_cpu_to_be32(x) ___constant_swab32((x))
+#define __constant_be32_to_cpu(x) ___constant_swab32((x))
+#define __constant_cpu_to_be16(x) ___constant_swab16((x))
+#define __constant_be16_to_cpu(x) ___constant_swab16((x))
+#define __cpu_to_le64(x) ((__u64)(x))
+#define __le64_to_cpu(x) ((__u64)(x))
+#define __cpu_to_le32(x) ((__u32)(x))
+#define __le32_to_cpu(x) ((__u32)(x))
+#define __cpu_to_le16(x) ((__u16)(x))
+#define __le16_to_cpu(x) ((__u16)(x))
+#define __cpu_to_be64(x) __swab64((x))
+#define __be64_to_cpu(x) __swab64((x))
+#define __cpu_to_be32(x) __swab32((x))
+#define __be32_to_cpu(x) __swab32((x))
+#define __cpu_to_be16(x) __swab16((x))
+#define __be16_to_cpu(x) __swab16((x))
+#define __cpu_to_le64p(x) (*(__u64*)(x))
+#define __le64_to_cpup(x) (*(__u64*)(x))
+#define __cpu_to_le32p(x) (*(__u32*)(x))
+#define __le32_to_cpup(x) (*(__u32*)(x))
+#define __cpu_to_le16p(x) (*(__u16*)(x))
+#define __le16_to_cpup(x) (*(__u16*)(x))
+#define __cpu_to_be64p(x) __swab64p((x))
+#define __be64_to_cpup(x) __swab64p((x))
+#define __cpu_to_be32p(x) __swab32p((x))
+#define __be32_to_cpup(x) __swab32p((x))
+#define __cpu_to_be16p(x) __swab16p((x))
+#define __be16_to_cpup(x) __swab16p((x))
+#define __cpu_to_le64s(x) do {} while (0)
+#define __le64_to_cpus(x) do {} while (0)
+#define __cpu_to_le32s(x) do {} while (0)
+#define __le32_to_cpus(x) do {} while (0)
+#define __cpu_to_le16s(x) do {} while (0)
+#define __le16_to_cpus(x) do {} while (0)
+#define __cpu_to_be64s(x) __swab64s((x))
+#define __be64_to_cpus(x) __swab64s((x))
+#define __cpu_to_be32s(x) __swab32s((x))
+#define __be32_to_cpus(x) __swab32s((x))
+#define __cpu_to_be16s(x) __swab16s((x))
+#define __be16_to_cpus(x) __swab16s((x))
+
+#include <linux/byteorder/generic.h>
+
+#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
index 4dbdc7643b8e9589a8c5faa2de8f4e65e0a9b7f7..bbb1010eedcd5bce73d1f1399c02402b821dcd5f 100644 (file)
@@ -62,6 +62,8 @@ typedef volatile unsigned char        vu_char;
 
 typedef        void (interrupt_handler_t)(void *);
 
+#ifdef CONFIG_PPC              /* PowerPC version */
+
 /* A Board Information structure that is given to a program when
  * ppcboot starts it up.
  */
@@ -152,6 +154,11 @@ typedef    struct  init_data {
 #endif
 } init_data_t;
 
+#endif /* CONFIG_PPC */
+
+#ifdef CONFIG_ARM
+# include <armboot.h>
+#endif
 
 /* enable common handling for all TQM8xxL boards */
 #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \
@@ -165,6 +172,31 @@ typedef    struct  init_data {
 /*
  * Function Prototypes
  */
+
+/* ------------------------------------------------------------ */
+/* Here is a list of some prototypes which are incompatible to */
+/* the ARMBoot implementation                                  */
+/* To be fixed!                                                        */
+/* ------------------------------------------------------------ */
+#ifdef CONFIG_PPC
+/* $(CPU)/serial.c */
+void   serial_init   (ulong, int);
+void   serial_setbrg (ulong, int);
+void   serial_putc   (const char);
+void   serial_puts   (const char *);
+void   serial_addr   (unsigned int);
+int    serial_getc   (void);
+int    serial_tstc   (void);
+# if CONFIG_SERIAL_SOFTWARE_FIFO
+void   serial_buffered_init (void);
+void   serial_buffered_putc (const char);
+void   serial_buffered_puts (const char *);
+int    serial_buffered_getc (void);
+int    serial_buffered_tstc (void);
+# endif /* CONFIG_SERIAL_SOFTWARE_FIFO */
+#endif /* CONFIG_PPC */
+
+
 void   hang          (void);
 
 
@@ -189,11 +221,15 @@ char *    strmhz(char *buf, long hz);
 int    last_stage_init(void);
 #endif
 
+/* common/flash.c */
+void flash_perror (int);
+
 /* common/cmd_bootm.c */
 void print_image_hdr (image_header_t *hdr);
 
 extern ulong load_addr;                /* Default Load Address */
 
+#ifdef CONFIG_PPC              /* ARM version in armboot.h - to be fixed! */
 /* common/cmd_nvedit.c */
 void   env_init (init_data_t *);
 void   env_relocate (ulong);
@@ -201,6 +237,7 @@ char        *getenv (uchar *);
 int      getenv_r (uchar *name, uchar *buf, unsigned len);
 int    saveenv(void);
 void inline  setenv (char *, char *);
+#endif /* CONFIG_PPC */
 
 #if defined(CONFIG_PCI)                || \
     defined(CONFIG_BAB750)     || \
@@ -349,22 +386,6 @@ void       board_postclk_init(void); /* after clocks/timebase, before env/serial */
 int testdram(void);
 #endif /* CFG_DRAM_TEST */
 
-/* $(CPU)/serial.c */
-void   serial_init   (ulong, int);
-void   serial_setbrg (ulong, int);
-void   serial_putc   (const char);
-void   serial_puts   (const char *);
-void   serial_addr   (unsigned int);
-int    serial_getc   (void);
-int    serial_tstc   (void);
-#if CONFIG_SERIAL_SOFTWARE_FIFO
-void   serial_buffered_init (void);
-void   serial_buffered_putc (const char);
-void   serial_buffered_puts (const char *);
-int    serial_buffered_getc (void);
-int    serial_buffered_tstc (void);
-#endif
-
 /* $(CPU)/start.S */
 #ifdef CONFIG_8xx
 uint   get_immr      (uint);
index 4198d841ac58fe0c79dfb3b4a7302b355723b888..ff43f66005368908360df68a53591d8a85504221 100644 (file)
  *
  */
 
-#include "armboot.h"
-#include "command.h"
-#include "cmd_boot.h"
-#include "image.h"
-#include "malloc.h"
-#include "zlib.h"
+#include <ppcboot.h>
+#include <command.h>
+#include <cmd_boot.h>
+#include <image.h>
+#include <zlib.h>
+#include <asm/byteorder.h>
 
 #include <asm/setup.h>
 #define tag_size(type)  ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
 #define tag_next(t)     ((struct tag *)((u32 *)(t) + (t)->hdr.size))
 
+#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
+    defined (CONFIG_CMDLINE_TAG) || \
+    defined (CONFIG_INITRD_TAG)
 static void setup_start_tag(bd_t *bd);
 static void setup_memory_tags(bd_t *bd);
 static void setup_commandline_tag(bd_t *bd, char *commandline);
@@ -41,11 +44,12 @@ static void setup_ramdisk_tag(bd_t *bd);
 static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end);
 static void setup_end_tag(bd_t *bd);
 
-extern image_header_t header;           /* from cmd_bootm.c */
-
-#undef DEBUG
 
 static struct tag *params;
+#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
+
+extern image_header_t header;           /* from cmd_bootm.c */
+
 
 void boot_linux(cmd_tbl_t *cmdtp,
                bd_t *bd, int flag,
@@ -57,9 +61,11 @@ void boot_linux(cmd_tbl_t *cmdtp,
     ulong len = 0, checksum;
     ulong initrd_start, initrd_end;
     ulong data;
-    char *commandline = getenv(bd, "bootargs");
     void (*theKernel)(int zero, int arch);
     image_header_t *hdr = &header;
+#ifdef CONFIG_CMDLINE_TAG
+    char *commandline = getenv("bootargs");
+#endif
 
     /*
      * Check if there is an initrd image
@@ -72,7 +78,7 @@ void boot_linux(cmd_tbl_t *cmdtp,
        /* Copy header so we can blank CRC field for re-calculation */
        memcpy (&header, (char *)addr, sizeof(image_header_t));
        
-       if (SWAP32(hdr->ih_magic) != IH_MAGIC) {
+       if (ntohl(hdr->ih_magic) != IH_MAGIC) {
            printf ("Bad Magic Number\n");
            do_reset (cmdtp, bd, flag, argc, argv);
        }
@@ -80,7 +86,7 @@ void boot_linux(cmd_tbl_t *cmdtp,
        data = (ulong)&header;
        len  = sizeof(image_header_t);
        
-       checksum = SWAP32(hdr->ih_hcrc);
+       checksum = ntohl(hdr->ih_hcrc);
        hdr->ih_hcrc = 0;
        
        if (crc32 (0, (char *)data, len) != checksum) {
@@ -91,14 +97,14 @@ void boot_linux(cmd_tbl_t *cmdtp,
        print_image_hdr (hdr);
        
        data = addr + sizeof(image_header_t);
-       len  = SWAP32(hdr->ih_size);
+       len  = ntohl(hdr->ih_size);
        
        if (verify) {
            ulong csum = 0;
 
            printf ("   Verifying Checksum ... ");
            csum = crc32 (0, (char *)data, len);
-           if (csum != SWAP32(hdr->ih_dcrc)) {
+           if (csum != ntohl(hdr->ih_dcrc)) {
                printf ("Bad Data CRC\n");
                do_reset (cmdtp, bd, flag, argc, argv);
            }
@@ -116,7 +122,7 @@ void boot_linux(cmd_tbl_t *cmdtp,
         * Now check if we have a multifile image
         */
     } else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
-       ulong tail    = SWAP32(len_ptr[0]) % 4;
+       ulong tail    = ntohl(len_ptr[0]) % 4;
        int i;
        
        /* skip kernel length and terminator */
@@ -125,12 +131,12 @@ void boot_linux(cmd_tbl_t *cmdtp,
        for (i=1; len_ptr[i]; ++i)
          data += 4;
        /* add kernel length, and align */
-       data += SWAP32(len_ptr[0]);
+       data += ntohl(len_ptr[0]);
        if (tail) {
            data += 4 - tail;
        }
        
-       len   = SWAP32(len_ptr[1]);
+       len   = ntohl(len_ptr[1]);
        
     } else {
        /*
@@ -157,7 +163,7 @@ void boot_linux(cmd_tbl_t *cmdtp,
        initrd_end = 0;
     }
     
-    theKernel = (void (*)(int, int))SWAP32(hdr->ih_ep);
+    theKernel = (void (*)(int, int))ntohl(hdr->ih_ep);
    
 #ifdef DEBUG
     printf ("## Transferring control to Linux (at address %08lx) ...\n",
@@ -192,6 +198,9 @@ void boot_linux(cmd_tbl_t *cmdtp,
 }
 
 
+#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
+    defined (CONFIG_CMDLINE_TAG) || \
+    defined (CONFIG_INITRD_TAG)
 static void setup_start_tag(bd_t *bd)
 {
     params = (struct tag *)bd->bi_boot_params;
@@ -271,15 +280,17 @@ static void setup_ramdisk_tag(bd_t *bd)
     params->hdr.size = tag_size(tag_ramdisk);
     
     params->u.ramdisk.start = 0;
-    //params->u.ramdisk.size = RAMDISK_SIZE;
+    /*params->u.ramdisk.size = RAMDISK_SIZE; */
     params->u.ramdisk.flags = 1;       /* automatically load ramdisk */
     
     params = tag_next(params);
 }
-#endif
+#endif /* 0 */
 
 static void setup_end_tag(bd_t *bd)
 {
     params->hdr.tag = ATAG_NONE;
     params->hdr.size = 0;
 }
+
+#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
index 70f9de373cdb43a82ef4e9b0345ea981baa52166..7d97fe1f6b00f941768668f2b12cda14bcefec0c 100644 (file)
  * MA 02111-1307 USA
  */
 
-#include "armboot.h"
-#include "command.h"
-#include "devices.h"
-#include "version.h"
+#include <ppcboot.h>
+#include <command.h>
+#include <devices.h>
+#include <version.h>
 
 #ifdef CONFIG_DRIVER_CS8900
 extern void cs8900_get_enetaddr(uchar *addr);
@@ -105,7 +105,7 @@ void start_armboot(void)
     display_dram_config(&bd);
 
     /* configure available FLASH banks */
-    size = flash_init(&bd);
+    size = flash_init();
     display_flash_config(&bd, size);
 
     /* armboot_end is defined in the board-specific linker script */
index c78da6c7e720b9dd8f55846caedbad63fd1c5ff6..d3bd31967a9659e9fc016c8538af17aaa8e61a4d 100644 (file)
@@ -9,10 +9,15 @@
  * as inline code in <asm-xx/string.h>
  *
  * These are buggy as well..
+ *
+ * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
+ * -  Added strsep() which will replace strtok() soon (because strsep() is
+ *    reentrant and should be faster). Use only strsep() in new code, please.
  */
-
 #include <linux/types.h>
 #include <linux/string.h>
+#include <linux/ctype.h>
 #include <malloc.h>
 
 #define __HAVE_ARCH_BCOPY
 #define __HAVE_ARCH_STRLEN
 #define __HAVE_ARCH_STRNCPY
 
-char * ___strtok = NULL;
+#ifndef __HAVE_ARCH_STRNICMP
+/**
+ * strnicmp - Case insensitive, length-limited string comparison
+ * @s1: One string
+ * @s2: The other string
+ * @len: the maximum number of characters to compare
+ */
+int strnicmp(const char *s1, const char *s2, size_t len)
+{
+       /* Yes, Virginia, it had better be unsigned */
+       unsigned char c1, c2;
+
+       c1 = 0; c2 = 0;
+       if (len) {
+               do {
+                       c1 = *s1; c2 = *s2;
+                       s1++; s2++;
+                       if (!c1)
+                               break;
+                       if (!c2)
+                               break;
+                       if (c1 == c2)
+                               continue;
+                       c1 = tolower(c1);
+                       c2 = tolower(c2);
+                       if (c1 != c2)
+                               break;
+               } while (--len);
+       }
+       return (int)c1 - (int)c2;
+}
+#endif
+
+char * ___strtok;
 
 #ifndef __HAVE_ARCH_STRCPY
+/**
+ * strcpy - Copy a %NUL terminated string
+ * @dest: Where to copy the string to
+ * @src: Where to copy the string from
+ */
 char * strcpy(char * dest,const char *src)
 {
        char *tmp = dest;
@@ -40,6 +83,16 @@ char * strcpy(char * dest,const char *src)
 #endif
 
 #ifndef __HAVE_ARCH_STRNCPY
+/**
+ * strncpy - Copy a length-limited, %NUL-terminated string
+ * @dest: Where to copy the string to
+ * @src: Where to copy the string from
+ * @count: The maximum number of bytes to copy
+ *
+ * Note that unlike userspace strncpy, this does not %NUL-pad the buffer.
+ * However, the result is not %NUL-terminated if the source exceeds
+ * @count bytes.
+ */
 char * strncpy(char * dest,const char *src,size_t count)
 {
        char *tmp = dest;
@@ -52,6 +105,11 @@ char * strncpy(char * dest,const char *src,size_t count)
 #endif
 
 #ifndef __HAVE_ARCH_STRCAT
+/**
+ * strcat - Append one %NUL-terminated string to another
+ * @dest: The string to be appended to
+ * @src: The string to append to it
+ */
 char * strcat(char * dest, const char * src)
 {
        char *tmp = dest;
@@ -66,6 +124,15 @@ char * strcat(char * dest, const char * src)
 #endif
 
 #ifndef __HAVE_ARCH_STRNCAT
+/**
+ * strncat - Append a length-limited, %NUL-terminated string to another
+ * @dest: The string to be appended to
+ * @src: The string to append to it
+ * @count: The maximum numbers of bytes to copy
+ *
+ * Note that in contrast to strncpy, strncat ensures the result is
+ * terminated.
+ */
 char * strncat(char *dest, const char *src, size_t count)
 {
        char *tmp = dest;
@@ -86,6 +153,11 @@ char * strncat(char *dest, const char *src, size_t count)
 #endif
 
 #ifndef __HAVE_ARCH_STRCMP
+/**
+ * strcmp - Compare two strings
+ * @cs: One string
+ * @ct: Another string
+ */
 int strcmp(const char * cs,const char * ct)
 {
        register signed char __res;
@@ -100,6 +172,12 @@ int strcmp(const char * cs,const char * ct)
 #endif
 
 #ifndef __HAVE_ARCH_STRNCMP
+/**
+ * strncmp - Compare two length-limited strings
+ * @cs: One string
+ * @ct: Another string
+ * @count: The maximum number of bytes to compare
+ */
 int strncmp(const char * cs,const char * ct,size_t count)
 {
        register signed char __res = 0;
@@ -115,6 +193,11 @@ int strncmp(const char * cs,const char * ct,size_t count)
 #endif
 
 #ifndef __HAVE_ARCH_STRCHR
+/**
+ * strchr - Find the first occurrence of a character in a string
+ * @s: The string to be searched
+ * @c: The character to search for
+ */
 char * strchr(const char * s, int c)
 {
        for(; *s != (char) c; ++s)
@@ -125,6 +208,11 @@ char * strchr(const char * s, int c)
 #endif
 
 #ifndef __HAVE_ARCH_STRRCHR
+/**
+ * strrchr - Find the last occurrence of a character in a string
+ * @s: The string to be searched
+ * @c: The character to search for
+ */
 char * strrchr(const char * s, int c)
 {
        const char *p = s + strlen(s);
@@ -137,6 +225,10 @@ char * strrchr(const char * s, int c)
 #endif
 
 #ifndef __HAVE_ARCH_STRLEN
+/**
+ * strlen - Find the length of a string
+ * @s: The string to be sized
+ */
 size_t strlen(const char * s)
 {
        const char *sc;
@@ -148,6 +240,11 @@ size_t strlen(const char * s)
 #endif
 
 #ifndef __HAVE_ARCH_STRNLEN
+/**
+ * strnlen - Find the length of a length-limited string
+ * @s: The string to be sized
+ * @count: The maximum number of bytes to search
+ */
 size_t strnlen(const char * s, size_t count)
 {
        const char *sc;
@@ -174,6 +271,12 @@ char * strdup(const char *s)
 #endif
 
 #ifndef __HAVE_ARCH_STRSPN
+/**
+ * strspn - Calculate the length of the initial substring of @s which only
+ *     contain letters in @accept
+ * @s: The string to be searched
+ * @accept: The string to search for
+ */
 size_t strspn(const char *s, const char *accept)
 {
        const char *p;
@@ -195,6 +298,11 @@ size_t strspn(const char *s, const char *accept)
 #endif
 
 #ifndef __HAVE_ARCH_STRPBRK
+/**
+ * strpbrk - Find the first occurrence of a set of characters
+ * @cs: The string to be searched
+ * @ct: The characters to search for
+ */
 char * strpbrk(const char * cs,const char * ct)
 {
        const char *sc1,*sc2;
@@ -210,6 +318,13 @@ char * strpbrk(const char * cs,const char * ct)
 #endif
 
 #ifndef __HAVE_ARCH_STRTOK
+/**
+ * strtok - Split a string into tokens
+ * @s: The string to be searched
+ * @ct: The characters to search for
+ *
+ * WARNING: strtok is deprecated, use strsep instead.
+ */
 char * strtok(char * s,const char * ct)
 {
        char *sbegin, *send;
@@ -231,8 +346,44 @@ char * strtok(char * s,const char * ct)
 }
 #endif
 
+#ifndef __HAVE_ARCH_STRSEP
+/**
+ * strsep - Split a string into tokens
+ * @s: The string to be searched
+ * @ct: The characters to search for
+ *
+ * strsep() updates @s to point after the token, ready for the next call.
+ *
+ * It returns empty tokens, too, behaving exactly like the libc function
+ * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
+ * Same semantics, slimmer shape. ;)
+ */
+char * strsep(char **s, const char *ct)
+{
+       char *sbegin = *s, *end;
+
+       if (sbegin == NULL)
+               return NULL;
+
+       end = strpbrk(sbegin, ct);
+       if (end)
+               *end++ = '\0';
+       *s = end;
+
+       return sbegin;
+}
+#endif
+
 #ifndef __HAVE_ARCH_MEMSET
-void * memset(void * s,char c,size_t count)
+/**
+ * memset - Fill a region of memory with the given value
+ * @s: Pointer to the start of the area.
+ * @c: The byte to fill the area with
+ * @count: The size of the area.
+ *
+ * Do not use memset() to access IO space, use memset_io() instead.
+ */
+void * memset(void * s,int c,size_t count)
 {
        char *xs = (char *) s;
 
@@ -244,6 +395,18 @@ void * memset(void * s,char c,size_t count)
 #endif
 
 #ifndef __HAVE_ARCH_BCOPY
+/**
+ * bcopy - Copy one area of memory to another
+ * @src: Where to copy from
+ * @dest: Where to copy to
+ * @count: The size of the area.
+ *
+ * Note that this is the same as memcpy(), with the arguments reversed.
+ * memcpy() is the standard, bcopy() is a legacy BSD function.
+ *
+ * You should not use this function to access IO space, use memcpy_toio()
+ * or memcpy_fromio() instead.
+ */
 char * bcopy(const char * src, char * dest, int count)
 {
        char *tmp = dest;
@@ -256,6 +419,15 @@ char * bcopy(const char * src, char * dest, int count)
 #endif
 
 #ifndef __HAVE_ARCH_MEMCPY
+/**
+ * memcpy - Copy one area of memory to another
+ * @dest: Where to copy to
+ * @src: Where to copy from
+ * @count: The size of the area.
+ *
+ * You should not use this function to access IO space, use memcpy_toio()
+ * or memcpy_fromio() instead.
+ */
 void * memcpy(void * dest,const void *src,size_t count)
 {
        char *tmp = (char *) dest, *s = (char *) src;
@@ -268,6 +440,14 @@ void * memcpy(void * dest,const void *src,size_t count)
 #endif
 
 #ifndef __HAVE_ARCH_MEMMOVE
+/**
+ * memmove - Copy one area of memory to another
+ * @dest: Where to copy to
+ * @src: Where to copy from
+ * @count: The size of the area.
+ *
+ * Unlike memcpy(), memmove() copes with overlapping areas.
+ */
 void * memmove(void * dest,const void *src,size_t count)
 {
        char *tmp, *s;
@@ -290,10 +470,16 @@ void * memmove(void * dest,const void *src,size_t count)
 #endif
 
 #ifndef __HAVE_ARCH_MEMCMP
+/**
+ * memcmp - Compare two areas of memory
+ * @cs: One area of memory
+ * @ct: Another area of memory
+ * @count: The size of the area.
+ */
 int memcmp(const void * cs,const void * ct,size_t count)
 {
        const unsigned char *su1, *su2;
-       signed char res = 0;
+       int res = 0;
 
        for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
                if ((res = *su1 - *su2) != 0)
@@ -302,10 +488,16 @@ int memcmp(const void * cs,const void * ct,size_t count)
 }
 #endif
 
-/*
- * find the first occurrence of byte 'c', or 1 past the area if none
- */
 #ifndef __HAVE_ARCH_MEMSCAN
+/**
+ * memscan - Find a character in an area of memory.
+ * @addr: The memory area
+ * @c: The byte to search for
+ * @size: The size of the area.
+ *
+ * returns the address of the first occurrence of @c, or 1 byte past
+ * the area if @c is not found
+ */
 void * memscan(void * addr, int c, size_t size)
 {
        unsigned char * p = (unsigned char *) addr;
@@ -321,6 +513,11 @@ void * memscan(void * addr, int c, size_t size)
 #endif
 
 #ifndef __HAVE_ARCH_STRSTR
+/**
+ * strstr - Find the first substring in a %NUL terminated string
+ * @s1: The string to be searched
+ * @s2: The string to search for
+ */
 char * strstr(const char * s1,const char * s2)
 {
        int l1, l2;
@@ -338,3 +535,26 @@ char * strstr(const char * s1,const char * s2)
        return NULL;
 }
 #endif
+
+#ifndef __HAVE_ARCH_MEMCHR
+/**
+ * memchr - Find a character in an area of memory.
+ * @s: The memory area
+ * @c: The byte to search for
+ * @n: The size of the area.
+ *
+ * returns the address of the first occurrence of @c, or %NULL
+ * if @c is not found
+ */
+void *memchr(const void *s, int c, size_t n)
+{
+       const unsigned char *p = s;
+       while (n-- != 0) {
+               if ((unsigned char)c == *p++) {
+                       return (void *)(p-1);
+               }
+       }
+       return NULL;
+}
+
+#endif
index 6721117dc38febce6748c51ae0c8b1c95bdd2370..1be066cf549e5f6dce15cbcca9d7587504a09bc5 100644 (file)
@@ -70,31 +70,17 @@ store_block (unsigned block, uchar * src, unsigned len)
 
        if (rc) { /* Flash is destination for this packet */
                rc = flash_write ((uchar *)src, (ulong)(load_addr+offset), len);
-               switch (rc) {
-               case 0: /* OK */
-                       break;
-               case 1: printf ("Timeout writing to Flash\n");
-                       break;
-               case 2: printf ("Flash not Erased\n");
-                       break;
-               case 4: printf ("Can't write to protected Flash sectors\n");
-                       break;
-               case 8: printf ("Outside available Flash\n");
-                       break;
-               case 16:printf ("Size must be aligned (multiple of 8?)\n");
-                       break;
-               default:
-                       printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
-                       break;
-               }
                if (rc) {
+                       flash_perror (rc);
                        NetState = NETLOOP_FAIL;
                        return;
                }
        }
        else
 #endif /* CFG_DIRECT_FLASH_TFTP */
-       (void)memcpy((void *)(load_addr + offset), src, len);
+       {
+               (void)memcpy((void *)(load_addr + offset), src, len);
+       }
 
        if (NetBootFileXferSize < newsize)
                NetBootFileXferSize = newsize;
index 3064c845e306c5742f6ce8b27174dcd9ebbf7fd4..a5a5bdd284cc0c98ac99289e1084ee08cdb18edd 100644 (file)
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2002
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this