5360099fb2d3cd54343b7255a749a565227a79c9
[10.03/openwrt.git] / package / uboot-ifxmips / patches / 100-ifx.patch
1 --- a/Makefile
2 +++ b/Makefile
3 @@ -24,7 +24,7 @@
4  VERSION = 1
5  PATCHLEVEL = 1
6  SUBLEVEL = 5
7 -EXTRAVERSION =
8 +EXTRAVERSION = -IFX-LXDB
9  U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
10  VERSION_FILE = $(obj)include/version_autogenerated.h
11  
12 @@ -44,6 +44,25 @@ export       HOSTARCH HOSTOS
13  # Deal with colliding definitions from tcsh etc.
14  VENDOR=
15  
16 +# Default algorithm form compressing u-boot.bin
17 +ifndef COMPRESS
18 +COMPRESS=none
19 +COMPRESS_FILE=$(obj)u-boot.img
20 +else
21 +ifeq ($(COMPRESS),lzma)
22 +COMPRESS_FILE=$(obj)u-boot.limg
23 +endif
24 +ifeq ($(COMPRESS),bz2)
25 +COMPRESS_FILE=$(obj)u-boot.bzimg
26 +endif
27 +ifeq ($(COMPRESS),gzip)
28 +COMPRESS_FILE=$(obj)u-boot.zimg
29 +endif
30 +ifeq ($(COMPRESS),none)
31 +COMPRESS_FILE=$(obj)u-boot.img
32 +endif
33 +endif
34 +
35  #########################################################################
36  #
37  # U-boot build supports producing a object files to the separate external
38 @@ -164,6 +183,11 @@ include $(TOPDIR)/config.mk
39  # U-Boot objects....order is important (i.e. start must be first)
40  
41  OBJS  = cpu/$(CPU)/start.o
42 +OBJS_BOOTSTRAP  = cpu/$(CPU)/start_bootstrap.o
43 +
44 +cpu/$(CPU)/start_bootstrap.S: cpu/$(CPU)/start.S
45 +       ln -s start.S cpu/$(CPU)/start_bootstrap.S
46 +
47  ifeq ($(CPU),i386)
48  OBJS += cpu/$(CPU)/start16.o
49  OBJS += cpu/$(CPU)/reset.o
50 @@ -183,6 +207,7 @@ OBJS += cpu/$(CPU)/cplbhdlr.o       cpu/$(CPU)
51  endif
52  
53  OBJS := $(addprefix $(obj),$(OBJS))
54 +OBJS_BOOTSTRAP := $(addprefix $(obj),$(OBJS_BOOTSTRAP))
55  
56  LIBS  = lib_generic/libgeneric.a
57  LIBS += board/$(BOARDDIR)/lib$(BOARD).a
58 @@ -206,15 +231,24 @@ LIBS += common/libcommon.a
59  LIBS += $(BOARDLIBS)
60  
61  LIBS := $(addprefix $(obj),$(LIBS))
62 +
63 +LIBS_BOOTSTRAP  = lib_bootstrap/libbootstrap.a
64 +LIBS_BOOTSTRAP+= board/$(BOARDDIR)/lib$(BOARD).a
65 +#LIBS_BOOTSTRAP+= board/ifx/libifx.a
66 +LIBS_BOOTSTRAP+= cpu/$(CPU)/lib$(CPU).a
67 +
68 +LIBS_BOOTSTRAP := $(addprefix $(obj),$(LIBS_BOOTSTRAP))
69 +
70  .PHONY : $(LIBS)
71 +.PHONY : $(obj)lib_bootstrap/libbootstrap.a
72  
73  # Add GCC lib
74  PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
75  
76  # The "tools" are needed early, so put this first
77  # Don't include stuff already done in $(LIBS)
78 +         #examples
79  SUBDIRS        = tools \
80 -         examples \
81           post \
82           post/cpu
83  .PHONY : $(SUBDIRS)
84 @@ -226,14 +260,75 @@ endif
85  
86  __OBJS := $(subst $(obj),,$(OBJS))
87  __LIBS := $(subst $(obj),,$(LIBS))
88 +__LIBS_BOOTSTRAP := $(subst $(obj),,$(LIBS_BOOTSTRAP))
89 +
90 +#__HEAD_OBJS := $(subst $(obj),,$(HEAD_OBJS))
91 +#__HEAD_LIBS := $(subst $(obj),,$(HEAD_LIBS))
92  
93  #########################################################################
94  #########################################################################
95  
96  ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)
97 +#IFX_ALL = $(obj)u-boot.ifx $(obj)head.srec $(obj)head.bin $(obj)head $(obj)head.map $(COMPRESS_FILE) $(obj)u-boot.srec
98 +IFX_ALL = $(obj)u-boot.srec $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)System.map $(obj)bootstrap.bin $(obj)System_bootstrap.map
99 +IFX_BOOTSTRAP = $(obj)bootstrap.bin
100  
101  all:           $(ALL)
102  
103 +ifx_all:       $(IFX_ALL)
104 +
105 +ifx_bootstrap: $(IFX_BOOTSTRAP)
106 +
107 +$(obj)u-boot.ifx: $(obj)bootstrap.bin $(obj)u-boot.lzimg
108 +               @cat $(obj)bootstrap.bin > $(obj)u-boot.ifx
109 +               @cat $(obj)u-boot.lzimg >> $(obj)u-boot.ifx
110 +
111 +$(obj)u-boot.lzimg: $(obj)u-boot.bin $(obj)System.map
112 +               @lzma e $(obj)u-boot.bin $(obj)u-boot.lzma
113 +               $(obj)tools/mkimage -A mips -T firmware -C lzma \
114 +               -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
115 +               -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
116 +               -n 'u-boot image' -d $(obj)u-boot.lzma $@
117 +
118 +$(obj)ld_uboot.img: $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)bootstrap.bin
119 +               @  cp -f $(obj)u-boot.ifx $(obj)u-boot.bin
120 +               @ ./mkbootimg.incaip2 $(obj)ld_uboot.img < ld_uboot.conf
121 +
122 +$(obj)u-boot.zimg:     $(obj)u-boot.bin $(obj)System.map
123 +               gzip $(obj)u-boot.bin
124 +               $(obj)tools/mkimage -A $(ARCH) -T firmware -C gzip \
125 +               -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
126 +               -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
127 +               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
128 +                        sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
129 +               -d u-boot.gz $@
130 +
131 +$(obj)u-boot.bzimg:    $(obj)u-boot.bin $(obj)System.map
132 +               bzip $(obj)u-boot.bin
133 +               $(obj)tools/mkimage -A $(ARCH) -T firmware -C bzip2 \
134 +               -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
135 +               -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
136 +               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
137 +                       sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
138 +               -d u-boot.bz2 $@
139 +
140 +$(obj)u-boot.limg:     $(obj)u-boot.bin $(obj)System.map
141 +               @lzma e $(obj)u-boot.bin $(obj)u-boot.lzma
142 +               $(obj)tools/mkimage -A $(ARCH) -T firmware -C lzma \
143 +               -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
144 +               -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
145 +               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
146 +                       sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
147 +               -d u-boot.lzma $@
148 +
149 +$(obj)u-boot.img:      $(obj)u-boot.bin $(obj)System.map
150 +               $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
151 +               -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
152 +               -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
153 +               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
154 +                       sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
155 +               -d u-boot.bin $@
156 +
157  $(obj)u-boot.hex:      $(obj)u-boot
158                 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
159  
160 @@ -243,28 +338,33 @@ $(obj)u-boot.srec:        $(obj)u-boot
161  $(obj)u-boot.bin:      $(obj)u-boot
162                 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
163  
164 -$(obj)u-boot.img:      $(obj)u-boot.bin
165 -               ./tools/mkimage -A $(ARCH) -T firmware -C none \
166 -               -a $(TEXT_BASE) -e 0 \
167 -               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
168 -                       sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
169 -               -d $< $@
170 -
171  $(obj)u-boot.dis:      $(obj)u-boot
172                 $(OBJDUMP) -d $< > $@
173  
174 -$(obj)u-boot:          depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
175 +$(obj)u-boot:  depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
176                 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
177                 cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
178                         --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
179                         -Map u-boot.map -o u-boot
180  
181 +$(obj)bootstrap.bin:   $(obj)bootstrap
182 +               $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
183 +
184 +$(obj)bootstrap :              depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LDSCRIPT_BOOTSTRAP)
185 +               UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
186 +               $(LD) $(LDFLAGS_BOOTSTRAP) $$UNDEF_SYM $(OBJS_BOOTSTRAP) \
187 +                       --start-group $(__LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \
188 +                       -Map bootstrap.map -o bootstrap
189 +
190  $(OBJS):
191                 $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
192  
193  $(LIBS):
194                 $(MAKE) -C $(dir $(subst $(obj),,$@))
195  
196 +$(obj)lib_bootstrap/libbootstrap.a:
197 +               $(MAKE) -C $(dir $(subst $(obj),,$@))
198 +
199  $(SUBDIRS):
200                 $(MAKE) -C $@ all
201  
202 @@ -310,7 +410,12 @@ etags:
203  $(obj)System.map:      $(obj)u-boot
204                 @$(NM) $< | \
205                 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
206 -               sort > $(obj)System.map
207 +               sort > $@
208 +
209 +$(obj)System_bootstrap.map:    $(obj)bootstrap
210 +               @$(NM) $< | \
211 +               grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
212 +               sort > $@
213  
214  #########################################################################
215  else
216 @@ -2032,7 +2137,20 @@ sc520_spunk_rel_config   :       unconfig
217  # MIPS
218  #========================================================================
219  #########################################################################
220 -## MIPS32 4Kc
221 +## Infineon MIPS generic u-boot config
222 +#########################################################################
223 +danube_config: unconfig
224 +       @$(MKCONFIG) $(@:_config=) mips mips danube ifx danube
225 +
226 +amazon_config: unconfig
227 +       @$(MKCONFIG) $(@:_config=) mips mips amazon
228 +
229 +
230 +incaip2_config:        unconfig
231 +       @$(MKCONFIG) $(@:_config=) mips mips incaip2
232 +
233 +#########################################################################
234 +## MIPS32 4kc
235  #########################################################################
236  
237  xtract_incaip = $(subst _100MHz,,$(subst _133MHz,,$(subst _150MHz,,$(subst _config,,$1))))
238 @@ -2254,7 +2372,7 @@ clobber:  clean
239                 | xargs -0 rm -f
240         rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS $(obj)include/version_autogenerated.h
241         rm -fr $(obj)*.*~
242 -       rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
243 +       rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL) $(IFX_ALL)
244         rm -f $(obj)tools/crc32.c $(obj)tools/environment.c $(obj)tools/env/crc32.c
245         rm -f $(obj)tools/inca-swap-bytes $(obj)cpu/mpc824x/bedbug_603e.c
246         rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
247 --- a/common/cmd_bootm.c
248 +++ b/common/cmd_bootm.c
249 @@ -31,6 +31,7 @@
250  #include <malloc.h>
251  #include <zlib.h>
252  #include <bzlib.h>
253 +#include <LzmaWrapper.h>
254  #include <environment.h>
255  #include <asm/byteorder.h>
256  
257 @@ -79,6 +80,8 @@ DECLARE_GLOBAL_DATA_PTR;
258  # define CHUNKSZ (64 * 1024)
259  #endif
260  
261 +#ifndef CFG_HEAD_CODE
262 +
263  int  gunzip (void *, int, unsigned char *, unsigned long *);
264  
265  static void *zalloc(void *, unsigned, unsigned);
266 @@ -341,6 +344,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag
267  #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
268                 }
269                 break;
270 +#ifndef CONFIG_REMOVE_GZIP
271         case IH_COMP_GZIP:
272                 printf ("   Uncompressing %s ... ", name);
273                 if (gunzip ((void *)ntohl(hdr->ih_load), unc_len,
274 @@ -350,6 +354,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag
275                         do_reset (cmdtp, flag, argc, argv);
276                 }
277                 break;
278 +#endif /* CONFIG_REMOVE_GZIP */
279  #ifdef CONFIG_BZIP2
280         case IH_COMP_BZIP2:
281                 printf ("   Uncompressing %s ... ", name);
282 @@ -369,6 +374,18 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag
283                 }
284                 break;
285  #endif /* CONFIG_BZIP2 */
286 +#ifdef CONFIG_LZMA
287 +       case IH_COMP_LZMA:
288 +               printf ("   Uncompressing %s ... ", name);
289 +               i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &unc_len);
290 +               if (i != LZMA_RESULT_OK) {
291 +                       printf ("LZMA ERROR %d - must RESET board to recover\n", i);
292 +                       SHOW_BOOT_PROGRESS (-6);
293 +                       udelay(100000);
294 +                       do_reset (cmdtp, flag, argc, argv);
295 +               }
296 +               break;
297 +#endif /* CONFIG_LZMA */
298         default:
299                 if (iflag)
300                         enable_interrupts();
301 @@ -1176,6 +1193,8 @@ U_BOOT_CMD(
302  );
303  #endif /* CFG_CMD_IMLS */
304  
305 +#endif /* ! CFG_HEAD_CODE */
306 +
307  void
308  print_image_hdr (image_header_t *hdr)
309  {
310 @@ -1270,12 +1289,15 @@ print_type (image_header_t *hdr)
311         case IH_COMP_NONE:      comp = "uncompressed";          break;
312         case IH_COMP_GZIP:      comp = "gzip compressed";       break;
313         case IH_COMP_BZIP2:     comp = "bzip2 compressed";      break;
314 +       case IH_COMP_LZMA:      comp = "lzma compressed";       break;
315         default:                comp = "unknown compression";   break;
316         }
317  
318         printf ("%s %s %s (%s)", arch, os, type, comp);
319  }
320  
321 +#ifndef CFG_HEAD_CODE
322 +
323  #define        ZALLOC_ALIGNMENT        16
324  
325  static void *zalloc(void *x, unsigned items, unsigned size)
326 @@ -1427,3 +1449,5 @@ do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int 
327  }
328  
329  #endif /* CONFIG_LYNXKDI */
330 +
331 +#endif /* ! CFG_HEAD_CODE */
332 --- a/common/cmd_flash.c
333 +++ b/common/cmd_flash.c
334 @@ -196,9 +196,17 @@ addr_spec(char *arg1, char *arg2, ulong 
335  }
336  
337  static int
338 -flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
339 -                       int *s_first, int *s_last,
340 -                       int *s_count )
341 +flash_fill_sect_ranges(
342 +       ulong *addr_first_sect_start,
343 +       ulong addr_first,
344 +       ulong *addr_last_sect_end,
345 +       ulong addr_last,
346 +       int *s_first,
347 +       int *s_last,
348 +       int *bPartialStart,
349 +       int *bPartialEnd,
350 +       int *s_count,
351 +       unsigned int bPartialErase)
352  {
353         flash_info_t *info;
354         ulong bank;
355 @@ -211,9 +219,7 @@ flash_fill_sect_ranges (ulong addr_first
356                 s_last [bank] = -1;     /* last  sector to erase        */
357         }
358  
359 -       for (bank=0,info=&flash_info[0];
360 -            (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last);
361 -            ++bank, ++info) {
362 +       for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) {
363                 ulong b_end;
364                 int sect;
365                 short s_end;
366 @@ -225,7 +231,6 @@ flash_fill_sect_ranges (ulong addr_first
367                 b_end = info->start[0] + info->size - 1;        /* bank end addr */
368                 s_end = info->sector_count - 1;                 /* last sector   */
369  
370 -
371                 for (sect=0; sect < info->sector_count; ++sect) {
372                         ulong end;      /* last address in current sect */
373  
374 @@ -238,11 +243,21 @@ flash_fill_sect_ranges (ulong addr_first
375  
376                         if (addr_first == info->start[sect]) {
377                                 s_first[bank] = sect;
378 +                       } else if (addr_first > info->start[sect] && addr_first <= end && bPartialErase) {
379 +                               *addr_first_sect_start = info->start[sect];
380 +                               s_first[bank] = sect;
381 +                               *bPartialStart = 1;
382                         }
383 +
384                         if (addr_last  == end) {
385                                 s_last[bank]  = sect;
386 +                       } else if (addr_last >= info->start[sect] && addr_last < end && bPartialErase) {
387 +                               *addr_last_sect_end = end;
388 +                               s_last[bank] = sect;
389 +                               *bPartialEnd = 1;
390                         }
391                 }
392 +
393                 if (s_first[bank] >= 0) {
394                         if (s_last[bank] < 0) {
395                                 if (addr_last > b_end) {
396 @@ -316,6 +331,8 @@ int do_flerase (cmd_tbl_t *cmdtp, int fl
397         struct part_info *part;
398         u8 dev_type, dev_num, pnum;
399  #endif
400 +       unsigned int bPartialErase = 0;
401 +
402         int rcode = 0;
403  
404         if (argc < 2) {
405 @@ -369,7 +386,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int fl
406         }
407  #endif
408  
409 -       if (argc != 3) {
410 +       if (argc != 4) {
411                 printf ("Usage:\n%s\n", cmdtp->usage);
412                 return 1;
413         }
414 @@ -397,11 +414,117 @@ int do_flerase (cmd_tbl_t *cmdtp, int fl
415                 return 1;
416         }
417  
418 -       rcode = flash_sect_erase(addr_first, addr_last);
419 +       printf ("Erase Flash from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
420 +       if(argc == 4) {
421 +               bPartialErase = simple_strtoul(argv[3], NULL, 10);
422 +       }
423 +
424 +       rcode = flash_sect_erase(addr_first, addr_last, bPartialErase);
425         return rcode;
426  }
427  
428 -int flash_sect_erase (ulong addr_first, ulong addr_last)
429 +int flerase_Partial(
430 +       ulong addr_first_sect_start,
431 +       ulong addr_first,
432 +       ulong addr_last_sect_end,
433 +       ulong addr_last,
434 +       flash_info_t *info,
435 +       int first_sect,
436 +       int last_sect,
437 +       int bFirstPartial,
438 +       int bLastPartial) {
439 +       unsigned int firstMemLen = 0;
440 +       unsigned int lastMemLen = 0;
441 +       unsigned int sectMemLen = 0;
442 +       uchar *pSavedFirstMem = NULL;
443 +       uchar *pSavedLastMem = NULL;
444 +       uchar *pSavedSectMem = NULL;
445 +       int bSectPartial = 0;
446 +       int rt_code = 0;
447 +
448 +       debug("%s ... 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%p, %d, %d, %d, %d\n", __FUNCTION__, addr_first_sect_start, addr_first, addr_last_sect_end, addr_last, info, first_sect, last_sect, bFirstPartial, bLastPartial);
449 +
450 +       if (bFirstPartial && bLastPartial && (first_sect == last_sect))
451 +       {
452 +               ulong b_end = info->start[0] + info->size - 1;
453 +               ulong end = (first_sect == (info->sector_count - 1)) ? b_end : info->start[first_sect + 1] - 1;
454 +               sectMemLen = end - info->start[first_sect] + 1;
455 +               pSavedSectMem = (uchar *)calloc(sectMemLen, sizeof(char));
456 +               if (pSavedSectMem == NULL)
457 +               {
458 +                       debug("calloc %u FAILED\n", sectMemLen);
459 +                       rt_code = 1;
460 +                       goto ret;
461 +               }
462 +               memset(pSavedSectMem, 0xff, sectMemLen);
463 +               bSectPartial = 1;
464 +               memcpy(pSavedSectMem, (uchar *)addr_first_sect_start, addr_first - addr_first_sect_start);
465 +               memcpy(pSavedSectMem + (addr_last - info->start[first_sect]) + 1, addr_last + 1, end - addr_last);
466 +       }
467 +       else
468 +       {
469 +               if (bFirstPartial){
470 +                       firstMemLen = addr_first - addr_first_sect_start + 1;
471 +                       pSavedFirstMem = (uchar *)calloc(firstMemLen,sizeof(char));
472 +                       memcpy(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1);
473 +               }
474 +               if (bLastPartial){
475 +                       lastMemLen = addr_last_sect_end - addr_last + 1;
476 +                       pSavedLastMem = (uchar *)calloc(lastMemLen,sizeof(char));
477 +                       memcpy(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1);
478 +               }
479 +       }
480 +
481 +       if (bFirstPartial){
482 +               if(flash_erase (info, first_sect, first_sect)) {
483 +                       printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, first_sect);
484 +                       rt_code = 1;
485 +                       goto ret;
486 +               }
487 +               debug("%s ... erase sector %d done!\n", __FUNCTION__, first_sect);
488 +       }
489 +
490 +       if (bLastPartial && first_sect != last_sect){
491 +               if(flash_erase (info, last_sect, last_sect)) {
492 +                       printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, last_sect);
493 +                       rt_code = 1;
494 +                       goto ret;
495 +               }
496 +               debug("%s ... erase sector %d done!\n", __FUNCTION__, last_sect);
497 +       }
498 +
499 +       if (bFirstPartial && bLastPartial && (first_sect == last_sect))
500 +       {
501 +               flash_write(pSavedSectMem, (uchar *)addr_first_sect_start, sectMemLen);
502 +               debug("flash_write from 0x%08x with len %u\n", addr_first_sect_start, sectMemLen);
503 +       }
504 +       else
505 +       {
506 +               if (bFirstPartial){
507 +                       if(flash_write(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1)) {
508 +                               printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_first_sect_start,firstMemLen - 1);
509 +                               rt_code = 1;
510 +                               goto ret;
511 +                       }
512 +               }
513 +               if (bLastPartial){
514 +                       if(flash_write(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1)) {
515 +                               printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_last, lastMemLen - 1);
516 +                               rt_code = 1;
517 +                       }
518 +               }
519 +       }
520 +ret:
521 +       if (bFirstPartial)
522 +               free(pSavedFirstMem);
523 +       if (bLastPartial)
524 +               free(pSavedLastMem);
525 +       if (bSectPartial)
526 +               free(pSavedSectMem);
527 +       return rt_code;
528 +}
529 +
530 +int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase)
531  {
532         flash_info_t *info;
533         ulong bank;
534 @@ -413,27 +536,66 @@ int flash_sect_erase (ulong addr_first, 
535         int erased = 0;
536         int planned;
537         int rcode = 0;
538 -
539 -       rcode = flash_fill_sect_ranges (addr_first, addr_last,
540 -                                       s_first, s_last, &planned );
541 +       int bPartialStart = 0;          // Start sector has to be erased partially
542 +       int bPartialEnd = 0;            // End sector has to be erased partially
543 +       ulong addr_first_sect_start = 0;// Sector start address of location addr_start
544 +       ulong addr_last_sect_end = 0;   // Sector end address of location addr_last
545 +
546 +       rcode = flash_fill_sect_ranges (
547 +                       &addr_first_sect_start,
548 +                       addr_first,
549 +                       &addr_last_sect_end,
550 +                       addr_last,
551 +                       s_first,
552 +                       s_last,
553 +                       &bPartialStart,
554 +                       &bPartialEnd,
555 +                       &planned,
556 +                       bPartialErase );
557  
558         if (planned && (rcode == 0)) {
559 -               for (bank=0,info=&flash_info[0];
560 -                    (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0);
561 -                    ++bank, ++info) {
562 +               for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0); ++bank, ++info) {
563 +                       ulong b_end = info->start[0] + info->size - 1;  /* bank end addr */
564                         if (s_first[bank]>=0) {
565 -                               erased += s_last[bank] - s_first[bank] + 1;
566 -                               debug ("Erase Flash from 0x%08lx to 0x%08lx "
567 -                                       "in Bank # %ld ",
568 -                                       info->start[s_first[bank]],
569 -                                       (s_last[bank] == info->sector_count) ?
570 -                                               info->start[0] + info->size - 1:
571 -                                               info->start[s_last[bank]+1] - 1,
572 -                                       bank+1);
573 -                               rcode = flash_erase (info, s_first[bank], s_last[bank]);
574 +                               if(bPartialErase) {
575 +                                       rcode = flerase_Partial(
576 +                                                       addr_first_sect_start,
577 +                                                       addr_first,
578 +                                                       addr_last_sect_end,
579 +                                                       addr_last,
580 +                                                       info,
581 +                                                       s_first[bank],
582 +                                                       s_last[bank],
583 +                                                       bPartialStart,
584 +                                                       bPartialEnd);
585 +                               }
586 +
587 +                               //Erase full sectores
588 +                               if (bPartialStart)
589 +                                       s_first[bank] += 1;
590 +                               if (bPartialEnd)
591 +                                       s_last[bank] -= 1;
592 +                               if (s_last[bank] >= s_first[bank]) {
593 +                                       erased += s_last[bank] - s_first[bank] + 1;
594 +                                       debug ("Erase Flash from 0x%08lx to 0x%08lx in Bank # %ld ",
595 +                                               info->start[s_first[bank]],
596 +                                               (s_last[bank] == info->sector_count) ?
597 +                                                       info->start[0] + info->size - 1:
598 +                                                       info->start[s_last[bank]+1] - 1,
599 +                                               bank + 1);
600 +                                       rcode = flash_erase (info, s_first[bank], s_last[bank]);
601 +                               }
602                         }
603                 }
604 -               printf ("Erased %d sectors\n", erased);
605 +
606 +               if (erased && !bPartialErase) {
607 +                       printf ("Erased %d sectors\n", erased);
608 +               } else if (bPartialErase){
609 +                       printf ("Partial erased from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
610 +               } else {
611 +                       printf ("Error: start and/or end address not on sector boundary\n");
612 +                       rcode = 1;
613 +               }
614         } else if (rcode == 0) {
615                 puts ("Error: start and/or end address"
616                         " not on sector boundary\n");
617 @@ -629,8 +791,22 @@ int flash_sect_protect (int p, ulong add
618         int protected, i;
619         int planned;
620         int rcode;
621 -
622 -       rcode = flash_fill_sect_ranges( addr_first, addr_last, s_first, s_last, &planned );
623 +       int bPartialStart = 0;          // Start sector has to be erased partially
624 +       int bPartialEnd = 0;            // End sector has to be erased partially
625 +       ulong addr_first_sect_start = 0;// Sector start address of location addr_start
626 +       ulong addr_last_sect_end = 0;   // Sector end address of location addr_last
627 +
628 +       rcode = flash_fill_sect_ranges (
629 +                       &addr_first_sect_start,
630 +                       addr_first,
631 +                       &addr_last_sect_end,
632 +                       addr_last,
633 +                       s_first,
634 +                       s_last,
635 +                       &bPartialStart,
636 +                       &bPartialEnd,
637 +                       &planned,
638 +                       1 );
639  
640         protected = 0;
641  
642 @@ -690,7 +866,7 @@ U_BOOT_CMD(
643  );
644  
645  U_BOOT_CMD(
646 -       erase,   3,   1,  do_flerase,
647 +       erase,   4,   1,  do_flerase,
648         "erase   - erase FLASH memory\n",
649         "start end\n"
650         "    - erase FLASH from addr 'start' to addr 'end'\n"
651 --- a/common/cmd_nvedit.c
652 +++ b/common/cmd_nvedit.c
653 @@ -540,8 +540,19 @@ int do_saveenv (cmd_tbl_t *cmdtp, int fl
654         extern char * env_name_spec;
655  
656         printf ("Saving Environment to %s...\n", env_name_spec);
657 -
658 +#if 1
659 +       if(saveenv() == 0) {
660 +#ifdef UBOOT_ENV_COPY
661 +               saveenv_copy();
662 +#else
663 +               ;
664 +#endif //UBOOT_ENV_COPY
665 +       } else
666 +               return 1;
667 +       return 0;
668 +#else
669         return (saveenv() ? 1 : 0);
670 +#endif
671  }
672  
673  
674 --- a/common/console.c
675 +++ b/common/console.c
676 @@ -324,7 +324,7 @@ inline void dbg(const char *fmt, ...)
677  #endif
678  
679  /** U-Boot INIT FUNCTIONS *************************************************/
680 -
681 +#ifndef CFG_HEAD_CODE
682  int console_assign (int file, char *devname)
683  {
684         int flag, i;
685 @@ -357,7 +357,7 @@ int console_assign (int file, char *devn
686  
687         return -1;
688  }
689 -
690 +#endif //CFG_HEAD_CODE
691  /* Called before relocation - use serial functions */
692  int console_init_f (void)
693  {
694 @@ -392,6 +392,7 @@ device_t *search_device (int flags, char
695  }
696  #endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
697  
698 +#ifndef CFG_HEAD_CODE
699  #ifdef CFG_CONSOLE_IS_IN_ENV
700  /* Called after the relocation - use desired console functions */
701  int console_init_r (void)
702 @@ -570,3 +571,4 @@ int console_init_r (void)
703  }
704  
705  #endif /* CFG_CONSOLE_IS_IN_ENV */
706 +#endif //CFG_HEAD_CODE
707 --- a/common/devices.c
708 +++ b/common/devices.c
709 @@ -39,6 +39,7 @@ DECLARE_GLOBAL_DATA_PTR;
710  list_t devlist = 0;
711  device_t *stdio_devices[] = { NULL, NULL, NULL };
712  char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
713 +#ifndef CFG_HEAD_CODE
714  
715  #if defined(CONFIG_SPLASH_SCREEN) && !defined(CFG_DEVICE_NULLDEV)
716  #define        CFG_DEVICE_NULLDEV      1
717 @@ -214,3 +215,5 @@ int devices_done (void)
718  
719         return 0;
720  }
721 +#endif //CFG_HEAD_CODE
722 +
723 --- a/common/env_common.c
724 +++ b/common/env_common.c
725 @@ -219,7 +219,9 @@ void env_relocate (void)
726          * We must allocate a buffer for the environment
727          */
728         env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
729 -       DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
730 +       if(!env_ptr)
731 +               DEBUGF ("malloc env_ptr error!!\n");
732 +       DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__, __LINE__, env_ptr);
733  #endif
734  
735         /*
736 @@ -227,6 +229,10 @@ void env_relocate (void)
737          */
738         env_get_char = env_get_char_memory;
739  
740 +       //leejack
741 +       DEBUGF ("%s[%d] gd->env_valid=%d\n", __FUNCTION__, __LINE__, gd->env_valid);
742 +       DEBUGF ("%s[%d] CFG_ENV_SIZE=%d\n", __FUNCTION__, __LINE__, CFG_ENV_SIZE);
743 +
744         if (gd->env_valid == 0) {
745  #if defined(CONFIG_GTH)        || defined(CFG_ENV_IS_NOWHERE)  /* Environment not changable */
746                 puts ("Using default environment\n\n");
747 @@ -242,18 +248,17 @@ void env_relocate (void)
748                 }
749  
750                 memset (env_ptr, 0, sizeof(env_t));
751 -               memcpy (env_ptr->data,
752 -                       default_environment,
753 -                       sizeof(default_environment));
754 +               memcpy (env_ptr->data, default_environment, sizeof(default_environment));
755 +
756  #ifdef CFG_REDUNDAND_ENVIRONMENT
757                 env_ptr->flags = 0xFF;
758  #endif
759                 env_crc_update ();
760                 gd->env_valid = 1;
761 -       }
762 -       else {
763 +       } else {
764                 env_relocate_spec ();
765         }
766 +
767         gd->env_addr = (ulong)&(env_ptr->data);
768  
769  #ifdef CONFIG_AMIGAONEG3SE
770 --- a/common/env_flash.c
771 +++ b/common/env_flash.c
772 @@ -66,7 +66,6 @@ static env_t *flash_addr = (env_t *)CFG_
773  #endif
774  
775  #else /* ! ENV_IS_EMBEDDED */
776 -
777  env_t *env_ptr = (env_t *)CFG_ENV_ADDR;
778  #ifdef CMD_SAVEENV
779  static env_t *flash_addr = (env_t *)CFG_ENV_ADDR;
780 @@ -201,6 +200,7 @@ int saveenv(void)
781         debug (" %08lX ... %08lX ...",
782                 (ulong)&(flash_addr_new->data),
783                 sizeof(env_ptr->data)+(ulong)&(flash_addr_new->data));
784 +
785         if ((rc = flash_write((char *)env_ptr->data,
786                         (ulong)&(flash_addr_new->data),
787                         sizeof(env_ptr->data))) ||
788 @@ -256,7 +256,6 @@ Done:
789  #endif /* CMD_SAVEENV */
790  
791  #else /* ! CFG_ENV_ADDR_REDUND */
792 -
793  int  env_init(void)
794  {
795  #ifdef CONFIG_OMAP2420H4
796 @@ -280,6 +279,52 @@ bad_flash:
797  
798  #ifdef CMD_SAVEENV
799  
800 +#ifdef UBOOT_ENV_COPY
801 +int saveenv_copy(void) {
802 +       uchar *env_buffer = (char *)env_ptr;
803 +       char *kernel_addr;
804 +       char *rootfs_addr;
805 +       char *rootfs_size;
806 +       ulong start_addr,end_addr,rootfs_end_addr;
807 +       ulong flash_start;
808 +
809 +       kernel_addr = getenv("f_kernel_addr");
810 +       end_addr = simple_strtoul(kernel_addr,NULL,16) - 1;
811 +       start_addr = end_addr - CFG_ENV_SIZE - sizeof(UBOOTCONFIG_COPY_HEADER) + 1;
812 +
813 +       rootfs_addr = getenv("f_rootfs_addr");
814 +       rootfs_size = getenv("f_rootfs_size");
815 +       rootfs_end_addr = simple_strtoul(rootfs_addr,NULL,16) + simple_strtoul(rootfs_size,NULL,16);
816 +
817 +       if(rootfs_end_addr >= start_addr)
818 +       {
819 +               printf("Can not copy the environment at 0x%08lx as no space left.\nf_kernel_addr = 0x%08lx while rootfs_end_addr = 0x%08lx\n",start_addr,end_addr,rootfs_end_addr);
820 +               return 1;
821 +       }
822 +
823 +       debug ("Protect off %08lX ... %08lX\n", (ulong)rootfs_end_addr, end_addr);
824 +       if (flash_sect_protect (0, rootfs_end_addr, end_addr))
825 +               return 1;
826 +
827 +       //delete the old environment copy, if found
828 +       flash_start = rootfs_end_addr;
829 +       while(flash_start + sizeof(UBOOTCONFIG_COPY_HEADER) + ENV_SIZE < end_addr)
830 +       {
831 +               if(strncmp((char *)flash_start,UBOOTCONFIG_COPY_HEADER,sizeof(UBOOTCONFIG_COPY_HEADER)) == 0)
832 +               {
833 +                       flash_sect_erase(flash_start,flash_start + sizeof(UBOOTCONFIG_COPY_HEADER),1);
834 +               }
835 +               flash_start += 1;
836 +       }
837 +       flash_sect_erase(start_addr,end_addr,1);
838 +       flash_write(UBOOTCONFIG_COPY_HEADER,start_addr,sizeof(UBOOTCONFIG_COPY_HEADER));
839 +       flash_write(env_buffer,start_addr + sizeof(UBOOTCONFIG_COPY_HEADER), CFG_ENV_SIZE);
840 +       flash_sect_protect (1, rootfs_end_addr, end_addr);
841 +       printf("saved copy of the env at 0x%08lx\n",start_addr);
842 +       return 0;
843 +}
844 +#endif //UBOOT_ENV_COPY
845 +
846  int saveenv(void)
847  {
848         int     len, rc;
849 @@ -331,7 +376,7 @@ int saveenv(void)
850                 return 1;
851  
852         puts ("Erasing Flash...");
853 -       if (flash_sect_erase (flash_sect_addr, end_addr))
854 +       if (flash_sect_erase (flash_sect_addr, end_addr, 1))
855                 return 1;
856  
857         puts ("Writing to Flash... ");
858 --- a/config.mk
859 +++ b/config.mk
860 @@ -127,10 +127,15 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
861  OBJDUMP = $(CROSS_COMPILE)objdump
862  RANLIB = $(CROSS_COMPILE)RANLIB
863  
864 +ifneq (,$(findstring s,$(MAKEFLAGS)))
865 +ARFLAGS = cr
866 +else
867  ARFLAGS = crv
868 +endif
869  RELFLAGS= $(PLATFORM_RELFLAGS)
870  DBGFLAGS= -g # -DDEBUG
871  OPTFLAGS= -Os #-fomit-frame-pointer
872 +OWRT_FLAGS?=
873  ifndef LDSCRIPT
874  #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
875  ifeq ($(CONFIG_NAND_U_BOOT),y)
876 @@ -139,12 +144,15 @@ else
877  LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
878  endif
879  endif
880 +
881 +LDSCRIPT_BOOTSTRAP := $(TOPDIR)/board/$(BOARDDIR)/u-boot-bootstrap.lds
882 +
883  OBJCFLAGS += --gap-fill=0xff
884  
885  gccincdir := $(shell $(CC) -print-file-name=include)
886  
887 -CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
888 -       -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE)           \
889 +CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)        $(OWRT_FLAGS)   \
890 +       -D__KERNEL__ -DUBOOT_RAM_TEXT_BASE=$(UBOOT_RAM_TEXT_BASE)               \
891  
892  ifneq ($(OBJTREE),$(SRCTREE))
893  CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
894 @@ -180,7 +188,8 @@ endif
895  
896  AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
897  
898 -LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
899 +LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(UBOOT_RAM_TEXT_BASE) $(PLATFORM_LDFLAGS)
900 +LDFLAGS_BOOTSTRAP += -Bstatic -T $(LDSCRIPT_BOOTSTRAP) -Ttext $(BOOTSTRAP_TEXT_BASE) $(PLATFORM_LDFLAGS)
901  
902  # Location of a usable BFD library, where we define "usable" as
903  # "built for ${HOST}, supports ${TARGET}".  Sensible values are
904 @@ -214,12 +223,19 @@ endif
905  export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
906         AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
907         MAKE
908 -export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
909 +export UBOOT_RAM_TEXT_BASE BOOTSTRAP_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
910  
911  #########################################################################
912  
913  ifndef REMOTE_BUILD
914  
915 +%_bootstrap.s: %_bootstrap.S
916 +       $(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
917 +%_bootstrap.o: %_bootstrap.S
918 +       $(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
919 +%_bootstrap.o: %_bootstrap.c
920 +       $(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
921 +
922  %.s:   %.S
923         $(CPP) $(AFLAGS) -o $@ $<
924  %.o:   %.S
925 @@ -229,12 +245,20 @@ ifndef REMOTE_BUILD
926  
927  else
928  
929 +$(obj)%_bootstrap.s:   %_bootstrap.S
930 +       $(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
931 +$(obj)%_bootstrap.o:   %_bootstrap.S
932 +       $(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
933 +$(obj)%_bootstrap.o:   %_bootstrap.c
934 +       $(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
935 +
936  $(obj)%.s:     %.S
937         $(CPP) $(AFLAGS) -o $@ $<
938  $(obj)%.o:     %.S
939         $(CC) $(AFLAGS) -c -o $@ $<
940  $(obj)%.o:     %.c
941         $(CC) $(CFLAGS) -c -o $@ $<
942 +
943  endif
944  
945  #########################################################################
946 --- a/drivers/Makefile
947 +++ b/drivers/Makefile
948 @@ -50,7 +50,7 @@ COBJS = 3c589.o 5701rls.o ali512x.o \
949           videomodes.o w83c553f.o \
950           ks8695eth.o \
951           pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o  \
952 -         rpx_pcmcia.o
953 +         rpx_pcmcia.o ifx_sw.o
954  
955  SRCS   := $(COBJS:.o=.c)
956  OBJS   := $(addprefix $(obj),$(COBJS))
957 --- a/include/asm-mips/mipsregs.h
958 +++ b/include/asm-mips/mipsregs.h
959 @@ -48,6 +48,7 @@
960  #define CP0_CAUSE $13
961  #define CP0_EPC $14
962  #define CP0_PRID $15
963 +#define CP0_EBASE $15,1
964  #define CP0_CONFIG $16
965  #define CP0_LLADDR $17
966  #define CP0_WATCHLO $18
967 @@ -330,11 +331,32 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
968  #  define KSU_USER             0x00000010
969  #  define KSU_SUPERVISOR       0x00000008
970  #  define KSU_KERNEL           0x00000000
971 +#ifdef CONFIG_DANUBE   /* MIPS 24KE */
972 +/* bits 5 & 6 & 7: reserved */
973 +/* bits 8~15: IM0~7 */
974 +/* bits 16: reserved */
975 +#define ST0_CEE                        0x00020000
976 +/* bits 18: always 0 */
977 +#define ST0_NMI                        0x00080000
978 +#define ST0_SR                 0x00100000
979 +#define ST0_TS                 0x00200000
980 +#define ST0_BEV                        0x00400000
981 +/* bits 23: reserved */
982 +#define ST0_MX                 0x01000000
983 +#define ST0_RE                 0x02000000
984 +#define ST0_FR                 0x04000000
985 +#define ST0_RP                 0x08000000
986 +#define ST0_CU0                        0x10000000
987 +#define ST0_CU1                        0x20000000
988 +#define ST0_CU2                        0x40000000
989 +#define ST0_CU3                        0x80000000
990 +#else
991  #define ST0_UX                 0x00000020
992  #define ST0_SX                 0x00000040
993  #define ST0_KX                         0x00000080
994  #define ST0_DE                 0x00010000
995  #define ST0_CE                 0x00020000
996 +#endif
997  
998  /*
999   * Bitfields in the R[23]000 cp0 status register.
1000 @@ -471,6 +493,14 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
1001  #define  CAUSEF_BD             (1   << 31)
1002  
1003  /*
1004 + * Bits in the coprocessor 0 EBase register
1005 + */
1006 +#define EBASEB_CPUNUM          0
1007 +#define EBASEF_CPUNUM          (0x3ff << EBASEB_CPUNUM)
1008 +#define EBASEB_EXPBASE         12
1009 +#define EBASEF_EXPBASE         (0x3ffff << EBASEB_EXPBASE)
1010 +
1011 +/*
1012   * Bits in the coprozessor 0 config register.
1013   */
1014  #define CONF_CM_CACHABLE_NO_WA         0
1015 @@ -544,4 +574,10 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
1016  #define CEB_KERNEL     2       /* Count events in kernel mode EXL = ERL = 0 */
1017  #define CEB_EXL                1       /* Count events with EXL = 1, ERL = 0 */
1018  
1019 +/*
1020 + * Bits in ErrCtl register
1021 + */
1022 +#define ECCB_WST       29
1023 +#define ECCF_WST       (0x1 << ECCB_WST)
1024 +
1025  #endif /* _ASM_MIPSREGS_H */
1026 --- a/include/cmd_confdefs.h
1027 +++ b/include/cmd_confdefs.h
1028 @@ -94,6 +94,7 @@
1029  #define CFG_CMD_EXT2   0x1000000000000000ULL   /* EXT2 Support                 */
1030  #define CFG_CMD_SNTP   0x2000000000000000ULL   /* SNTP support                 */
1031  #define CFG_CMD_DISPLAY        0x4000000000000000ULL   /* Display support              */
1032 +#define CFG_CMD_DHRYSTONE      0x8000000000000000ULL   /* Dhrystone benchmark support          */
1033  
1034  #define CFG_CMD_ALL    0xFFFFFFFFFFFFFFFFULL   /* ALL commands                 */
1035  
1036 @@ -141,6 +142,7 @@
1037                         CFG_CMD_SPI     | \
1038                         CFG_CMD_UNIVERSE | \
1039                         CFG_CMD_USB     | \
1040 +                       CFG_CMD_DHRYSTONE | \
1041                         CFG_CMD_VFD     )
1042  
1043  /* Default configuration
1044 --- /dev/null
1045 +++ b/include/config.h
1046 @@ -0,0 +1,2 @@
1047 +/* Automatically generated - do not edit */
1048 +#include <configs/danube.h>
1049 --- /dev/null
1050 +++ b/include/config.mk
1051 @@ -0,0 +1,5 @@
1052 +ARCH   = mips
1053 +CPU    = mips
1054 +BOARD  = danube
1055 +VENDOR = ifx
1056 +SOC    = danube
1057 --- a/include/flash.h
1058 +++ b/include/flash.h
1059 @@ -79,7 +79,7 @@ typedef struct {
1060  extern unsigned long flash_init (void);
1061  extern void flash_print_info (flash_info_t *);
1062  extern int flash_erase (flash_info_t *, int, int);
1063 -extern int flash_sect_erase (ulong addr_first, ulong addr_last);
1064 +extern int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase);
1065  extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
1066  
1067  /* common/flash.c */
1068 @@ -131,7 +131,9 @@ extern void flash_read_factory_serial(fl
1069  #define MT2_MANUFACT   0x002C002C      /* alternate MICRON manufacturer ID*/
1070  #define EXCEL_MANUFACT 0x004A004A      /* Excel Semiconductor                  */
1071  
1072 -                                       /* Micron Technologies (INTEL compat.)  */
1073 +#define        EON_ID_EN29LV320B 0x22f9
1074 +#define FLASH_29LV320B 0xE0
1075 +/* Micron Technologies (INTEL compat.) */
1076  #define MT_ID_28F400_T 0x44704470      /* 28F400B3 ID ( 4 M, top boot sector)  */
1077  #define MT_ID_28F400_B 0x44714471      /* 28F400B3 ID ( 4 M, bottom boot sect) */
1078  
1079 @@ -299,6 +301,10 @@ extern void flash_read_factory_serial(fl
1080  #define TOSH_ID_FVT160 0xC2            /* TC58FVT160 ID (16 M, top )           */
1081  #define TOSH_ID_FVB160 0x43            /* TC58FVT160 ID (16 M, bottom )        */
1082  
1083 +#define MX_ID_29LV320AB 0x22A822A8      /* MXIC  MX29LV320AB ID (32 M, bottom ) joelin       */
1084 +#define MX_ID_29LV160BB 0x22492249      /* MXIC  MX29LV160BB ID (16 M, bottom ) joelin       */
1085 +#define MX_ID_29LV640BB 0x22cb22cb      /* MXIC  MX29LV640BB ID (64 M, bottom ) joelin       */
1086 +
1087  /*-----------------------------------------------------------------------
1088   * Internal FLASH identification codes
1089   *
1090 @@ -422,6 +428,10 @@ extern void flash_read_factory_serial(fl
1091  #define FLASH_S29GL064M 0x00F0         /* Spansion S29GL064M-R6                */
1092  #define FLASH_S29GL128N 0x00F1         /* Spansion S29GL128N                   */
1093  
1094 +#define FLASH_29LV320AB 0x00B0          /* MXIC MX29LV320AB( 32M = 4M x 16 ) joelin 10/07/2004*/
1095 +#define FLASH_29LV160BB 0x00B1          /* MXIC MX29LV160BB( 16M = 2M x 16 ) joelin 11/22/2004*/
1096 +#define FLASH_29LV640BB 0x00B2          /* MXIC MX29LV640BB( 64M = 8M x 16 ) liupeng*/
1097 +
1098  #define FLASH_UNKNOWN  0xFFFF          /* unknown flash type                   */
1099  
1100  
1101 --- a/include/image.h
1102 +++ b/include/image.h
1103 @@ -132,6 +132,7 @@
1104  #define IH_COMP_NONE           0       /*  No   Compression Used       */
1105  #define IH_COMP_GZIP           1       /* gzip  Compression Used       */
1106  #define IH_COMP_BZIP2          2       /* bzip2 Compression Used       */
1107 +#define IH_COMP_LZMA           3       /* lzma Compression Used        */
1108  
1109  #define IH_MAGIC       0x27051956      /* Image Magic Number           */
1110  #define IH_NMLEN               32      /* Image Name Length            */
1111 --- /dev/null
1112 +++ b/include/syscall.h
1113 @@ -0,0 +1,42 @@
1114 +#ifndef __MON_SYS_CALL_H__
1115 +#define __MON_SYS_CALL_H__
1116 +
1117 +#ifndef __ASSEMBLY__
1118 +
1119 +#include <common.h>
1120 +
1121 +/* These are declarations of system calls available in C code */
1122 +int  mon_getc(void);
1123 +int  mon_tstc(void);
1124 +void mon_putc(const char);
1125 +void mon_puts(const char*);
1126 +void mon_printf(const char* fmt, ...);
1127 +void mon_install_hdlr(int, interrupt_handler_t*, void*);
1128 +void mon_free_hdlr(int);
1129 +void *mon_malloc(size_t);
1130 +void mon_free(void*);
1131 +void mon_udelay(unsigned long);
1132 +unsigned long mon_get_timer(unsigned long);
1133 +
1134 +#endif    /* ifndef __ASSEMBLY__ */
1135 +
1136 +#define NR_SYSCALLS            11        /* number of syscalls */
1137 +
1138 +
1139 +/*
1140 + * Make sure these functions are in the same order as they
1141 + * appear in the "examples/syscall.S" file !!!
1142 + */
1143 +#define SYSCALL_GETC           0
1144 +#define SYSCALL_TSTC           1
1145 +#define SYSCALL_PUTC           2
1146 +#define SYSCALL_PUTS           3
1147 +#define SYSCALL_PRINTF         4
1148 +#define SYSCALL_INSTALL_HDLR   5
1149 +#define SYSCALL_FREE_HDLR      6
1150 +#define SYSCALL_MALLOC         7
1151 +#define SYSCALL_FREE           8
1152 +#define SYSCALL_UDELAY         9
1153 +#define SYSCALL_GET_TIMER     10
1154 +
1155 +#endif
1156 --- /dev/null
1157 +++ b/ld_uboot.conf
1158 @@ -0,0 +1,8 @@
1159 +TAG_DWNLD()
1160 +{
1161 +   0xA0B00000 "u-boot.bin" /* Download u-boot image */
1162 +};
1163 +TAG_START()
1164 +{
1165 +   0xA0B00000
1166 +}; /* Start u-boot image */
1167 --- a/lib_generic/Makefile
1168 +++ b/lib_generic/Makefile
1169 @@ -28,7 +28,7 @@ LIB   = $(obj)libgeneric.a
1170  COBJS  = bzlib.o bzlib_crctable.o bzlib_decompress.o \
1171           bzlib_randtable.o bzlib_huffman.o \
1172           crc32.o ctype.o display_options.o ldiv.o \
1173 -         string.o vsprintf.o zlib.o
1174 +         string.o vsprintf.o zlib.o LzmaDecode.o LzmaWrapper.o
1175  
1176  SRCS   := $(COBJS:.o=.c)
1177  OBJS   := $(addprefix $(obj),$(COBJS))
1178 --- a/lib_mips/board.c
1179 +++ b/lib_mips/board.c
1180 @@ -29,9 +29,30 @@
1181  #include <net.h>
1182  #include <environment.h>
1183  
1184 +#ifdef CFG_BOOTSTRAP_CODE
1185 +//#include <asm/danube.h>
1186 +#undef CONFIG_MICROBZIP2
1187 +
1188 +#ifdef CONFIG_BZIP2
1189 +#include <bzlib.h>
1190 +#endif
1191 +
1192 +#ifdef CONFIG_MICROBZIP2
1193 +#include <micro_bzlib.h>
1194 +#endif
1195 +
1196 +#ifdef CONFIG_LZMA
1197 +#include <LzmaWrapper.h>
1198 +#endif
1199 +#endif //CFG_BOOTSTRAP_CODE
1200 +
1201  DECLARE_GLOBAL_DATA_PTR;
1202  
1203 -#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1204 +#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < BOOTSTRAP_CFG_MONITOR_BASE) || \
1205 +       (CFG_ENV_ADDR >= (BOOTSTRAP_CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
1206 +    defined(CFG_ENV_IS_IN_NVRAM) && defined(CFG_BOOTSTRAP_CODE)
1207 +#define        TOTAL_MALLOC_LEN        (CFG_MALLOC_LEN + CFG_ENV_SIZE)
1208 +#elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1209        (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
1210      defined(CFG_ENV_IS_IN_NVRAM)
1211  #define        TOTAL_MALLOC_LEN        (CFG_MALLOC_LEN + CFG_ENV_SIZE)
1212 @@ -39,21 +60,24 @@ DECLARE_GLOBAL_DATA_PTR;
1213  #define        TOTAL_MALLOC_LEN        CFG_MALLOC_LEN
1214  #endif
1215  
1216 -#undef DEBUG
1217 -
1218  extern int timer_init(void);
1219 -
1220  extern int incaip_set_cpuclk(void);
1221  
1222 +#ifdef CFG_BOOTSTRAP_CODE
1223 +extern ulong uboot_end_data_bootstrap;
1224 +extern ulong uboot_end_bootstrap;
1225 +#else //CFG_BOOTSTRAP_CODE
1226  extern ulong uboot_end_data;
1227  extern ulong uboot_end;
1228 +#endif //CFG_BOOTSTRAP_CODE
1229  
1230  ulong monitor_flash_len;
1231  
1232 -const char version_string[] =
1233 -       U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
1234 +const char version_string[] = U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
1235  
1236 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1237  static char *failed = "*** failed ***\n";
1238 +#endif
1239  
1240  /*
1241   * Begin and End of memory area for malloc(), and current "brk"
1242 @@ -62,14 +86,15 @@ static ulong mem_malloc_start;
1243  static ulong mem_malloc_end;
1244  static ulong mem_malloc_brk;
1245  
1246 -
1247  /*
1248   * The Malloc area is immediately below the monitor copy in DRAM
1249   */
1250 -static void mem_malloc_init (void)
1251 -{
1252 +#ifdef CFG_BOOTSTRAP_CODE
1253 +static void mem_malloc_init (ulong dest_addr) {
1254 +#else //CFG_BOOTSTRAP_CODE
1255 +static void mem_malloc_init (void) {
1256         ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
1257 -
1258 +#endif //CFG_BOOTSTRAP_CODE
1259         mem_malloc_end = dest_addr;
1260         mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
1261         mem_malloc_brk = mem_malloc_start;
1262 @@ -79,6 +104,25 @@ static void mem_malloc_init (void)
1263                 mem_malloc_end - mem_malloc_start);
1264  }
1265  
1266 +#ifdef CFG_BOOTSTRAP_CODE
1267 +void *malloc(unsigned int size) {
1268 +       if(size < (mem_malloc_end - mem_malloc_start)) {
1269 +               mem_malloc_start += size;
1270 +               debug ("malloc : size required = 0x%08lx and pointer = 0x%08lx\n",size,mem_malloc_start - size);
1271 +               return (void *)(mem_malloc_start - size);
1272 +       }
1273 +       return NULL;
1274 +}
1275 +
1276 +void *realloc(void *src,unsigned int size) {
1277 +       return NULL;
1278 +}
1279 +
1280 +void free(void *src) {
1281 +       return;
1282 +}
1283 +#endif //CFG_BOOTSTRAP_CODE
1284 +
1285  void *sbrk (ptrdiff_t increment)
1286  {
1287         ulong old = mem_malloc_brk;
1288 @@ -99,42 +143,58 @@ static int init_func_ram (void)
1289  #else
1290         int board_type = 0;     /* use dummy arg */
1291  #endif
1292 -       puts ("DRAM:  ");
1293  
1294 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1295 +#ifdef CONFIG_USE_DDR_RAM
1296 +       puts ("DDR-DRAM:  ");
1297 +#else
1298 +       puts ("DRAM:  ");
1299 +#endif
1300 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1301         if ((gd->ram_size = initdram (board_type)) > 0) {
1302 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1303                 print_size (gd->ram_size, "\n");
1304 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1305                 return (0);
1306         }
1307 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1308         puts (failed);
1309 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1310         return (1);
1311  }
1312  
1313 +#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
1314  static int display_banner(void)
1315  {
1316 -
1317         printf ("\n\n%s\n\n", version_string);
1318         return (0);
1319  }
1320 +#endif
1321  
1322 +#ifndef CFG_BOOTSTRAP_CODE
1323  static void display_flash_config(ulong size)
1324  {
1325         puts ("Flash: ");
1326         print_size (size, "\n");
1327  }
1328 +#endif //CFG_BOOTSTRAP_CODE
1329  
1330 -
1331 +#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
1332  static int init_baudrate (void)
1333  {
1334 +#ifndef CFG_BOOTSTRAP_CODE
1335         char tmp[64];   /* long enough for environment variables */
1336         int i = getenv_r ("baudrate", tmp, sizeof (tmp));
1337  
1338         gd->baudrate = (i > 0)
1339                         ? (int) simple_strtoul (tmp, NULL, 10)
1340                         : CONFIG_BAUDRATE;
1341 -
1342 +#else //CFG_BOOTSTRAP_CODE
1343 +       gd->baudrate = CONFIG_BAUDRATE;
1344 +#endif //CFG_BOOTSTRAP_CODE
1345         return (0);
1346  }
1347 -
1348 +#endif
1349  
1350  /*
1351   * Breath some life into the board...
1352 @@ -159,27 +219,49 @@ static int init_baudrate (void)
1353  typedef int (init_fnc_t) (void);
1354  
1355  init_fnc_t *init_sequence[] = {
1356 +#ifdef CFG_BOOTSTRAP_CODE
1357 +       //fuse_prg,
1358 +       //timer_init,
1359 +       //env_init,             /* initialize environment */
1360 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1361 +       init_baudrate,          /* initialze baudrate settings */
1362 +       serial_init,            /* serial communications setup */
1363 +       console_init_f,
1364 +       display_banner,         /* say that we are here */
1365 +       checkboard,
1366 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1367 +       init_func_ram,
1368 +       NULL,
1369 +#else /********** CFG_BOOTSTRAP_CODE **********/
1370         timer_init,
1371 -       env_init,               /* initialize environment */
1372 -#ifdef CONFIG_INCA_IP
1373 -       incaip_set_cpuclk,      /* set cpu clock according to environment variable */
1374 -#endif
1375         init_baudrate,          /* initialze baudrate settings */
1376         serial_init,            /* serial communications setup */
1377         console_init_f,
1378         display_banner,         /* say that we are here */
1379         checkboard,
1380         init_func_ram,
1381 +       env_init,               /* initialize environment */
1382         NULL,
1383 +#endif //CFG_BOOTSTRAP_CODE
1384  };
1385  
1386 +#ifdef CFG_BOOTSTRAP_CODE
1387 +extern void bootstrap_relocate_code(ulong addr_sp, gd_t *id, ulong addr);
1388  
1389 +void bootstrap_board_init_f(ulong bootflag)
1390 +#else
1391  void board_init_f(ulong bootflag)
1392 +#endif
1393  {
1394         gd_t gd_data, *id;
1395         bd_t *bd;
1396         init_fnc_t **init_fnc_ptr;
1397 -       ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE;
1398 +#ifdef CFG_BOOTSTRAP_CODE
1399 +       ulong addr, addr_sp, len = (ulong)&uboot_end_bootstrap - BOOTSTRAP_CFG_MONITOR_BASE;
1400 +       ulong lzmaImageaddr = 0;
1401 +#else //CFG_BOOTSTRAP_CODE
1402 +       ulong addr, addr_sp, len = CFG_MONITOR_LEN;
1403 +#endif //CFG_BOOTSTRAP_CODE
1404         ulong *s;
1405  #ifdef CONFIG_PURPLE
1406         void copy_code (ulong);
1407 @@ -219,13 +301,12 @@ void board_init_f(ulong bootflag)
1408         addr -= len;
1409         addr &= ~(16 * 1024 - 1);
1410  
1411 -       debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
1412 +       debug ("Reserving %d Bytes for U-Boot at: %08lx\n", len, addr);
1413  
1414          /* Reserve memory for malloc() arena.
1415          */
1416         addr_sp = addr - TOTAL_MALLOC_LEN;
1417 -       debug ("Reserving %dk for malloc() at: %08lx\n",
1418 -                       TOTAL_MALLOC_LEN >> 10, addr_sp);
1419 +       debug ("Reserving %d Bytes for malloc() at: %08lx\n", TOTAL_MALLOC_LEN, addr_sp);
1420  
1421         /*
1422          * (permanently) allocate a Board Info struct
1423 @@ -234,20 +315,17 @@ void board_init_f(ulong bootflag)
1424         addr_sp -= sizeof(bd_t);
1425         bd = (bd_t *)addr_sp;
1426         gd->bd = bd;
1427 -       debug ("Reserving %d Bytes for Board Info at: %08lx\n",
1428 -                       sizeof(bd_t), addr_sp);
1429 +       debug ("Reserving %d Bytes for Board Info at: %08lx\n", sizeof(bd_t), addr_sp);
1430  
1431         addr_sp -= sizeof(gd_t);
1432         id = (gd_t *)addr_sp;
1433 -       debug ("Reserving %d Bytes for Global Data at: %08lx\n",
1434 -                       sizeof (gd_t), addr_sp);
1435 +       debug ("Reserving %d Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp);
1436  
1437         /* Reserve memory for boot params.
1438          */
1439         addr_sp -= CFG_BOOTPARAMS_LEN;
1440         bd->bi_boot_params = addr_sp;
1441 -       debug ("Reserving %dk for boot params() at: %08lx\n",
1442 -                       CFG_BOOTPARAMS_LEN >> 10, addr_sp);
1443 +       debug ("Reserving %dk for boot params() at: %08lx\n", CFG_BOOTPARAMS_LEN >> 10, addr_sp);
1444  
1445         /*
1446          * Finally, we set up a new (bigger) stack.
1447 @@ -279,7 +357,16 @@ void board_init_f(ulong bootflag)
1448         copy_code(addr);
1449  #endif
1450  
1451 +#ifdef CFG_BOOTSTRAP_CODE
1452 +       lzmaImageaddr = (ulong)&uboot_end_data_bootstrap;
1453 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1454 +       puts("\n BOOTSTRAP: relocate_code start");
1455 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1456 +       bootstrap_relocate_code (addr_sp, id, addr);
1457 +#else //CFG_BOOTSTRAP_CODE
1458 +       puts("\n relocate_code start");
1459         relocate_code (addr_sp, id, addr);
1460 +#endif //CFG_BOOTSTRAP_CODE
1461  
1462         /* NOTREACHED - relocate_code() does not return */
1463  }
1464 @@ -292,7 +379,110 @@ void board_init_f(ulong bootflag)
1465   *
1466   ************************************************************************
1467   */
1468 +#ifdef CFG_BOOTSTRAP_CODE
1469 +void bootstrap_board_init_r (gd_t *id, ulong dest_addr) {
1470 +       int i;
1471 +       ulong   addr;
1472 +       ulong   data, len, checksum;
1473 +       ulong  *len_ptr;
1474 +       image_header_t header;
1475 +       image_header_t *hdr = &header;
1476 +       unsigned int destLen;
1477 +       int (*fn)(void);
1478 +
1479 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1480 +       puts("\n BOOTSTRAP: relocate_code finish.\n");
1481 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1482 +
1483 +       /* initialize malloc() area */
1484 +       mem_malloc_init(dest_addr);
1485 +
1486 +       addr = (char *)(BOOTSTRAP_CFG_MONITOR_BASE + ((ulong)&uboot_end_data_bootstrap - dest_addr));
1487 +       memmove (&header, (char *)addr, sizeof(image_header_t));
1488 +
1489 +       if (ntohl(hdr->ih_magic) != IH_MAGIC) {
1490 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1491 +               printf ("Bad Magic Number at address 0x%08lx\n",addr);
1492 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1493 +               return;
1494 +       }
1495  
1496 +       data = (ulong)&header;
1497 +       len  = sizeof(image_header_t);
1498 +
1499 +       checksum = ntohl(hdr->ih_hcrc);
1500 +       hdr->ih_hcrc = 0;
1501 +       if (crc32 (0, (unsigned char *)data, len) != checksum) {
1502 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1503 +               printf ("Bad Header Checksum\n");
1504 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1505 +               return;
1506 +       }
1507 +
1508 +       data = addr + sizeof(image_header_t);
1509 +       len  = ntohl(hdr->ih_size);
1510 +       len_ptr = (ulong *)data;
1511 +
1512 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1513 +       debug ("Disabling all the interrupts\n");
1514 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1515 +       disable_interrupts();
1516 +
1517 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1518 +       debug ("   Uncompressing UBoot Image ... \n" );
1519 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1520 +       /*
1521 +        * If we've got less than 4 MB of malloc() space,
1522 +        * use slower decompression algorithm which requires
1523 +        * at most 2300 KB of memory.
1524 +        */
1525 +       destLen = 0x0;
1526 +
1527 +#ifdef CONFIG_BZIP2
1528 +       i = BZ2_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1529 +                                       0x400000, (char *)data, len,
1530 +                                       CFG_MALLOC_LEN < (4096 * 1024), 0);
1531 +       if (i != BZ_OK) {
1532 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1533 +                       printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1534 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1535 +                       return;
1536 +       }
1537 +#elif CONFIG_MICROBZIP2
1538 +       i = micro_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1539 +                                       &destLen, (char *)data, len,
1540 +                                       CFG_MALLOC_LEN < (4096 * 1024), 0);
1541 +       if (i != RETVAL_OK) {
1542 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1543 +               printf ("MICRO_BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1544 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1545 +               return;
1546 +       }
1547 +#elif CONFIG_LZMA
1548 +       i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &destLen);
1549 +       if (i != LZMA_RESULT_OK) {
1550 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1551 +               printf ("LZMA ERROR %d - must RESET board to recover\n", i);
1552 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1553 +               return;
1554 +       }
1555 +#else
1556 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1557 +       printf ("NONE Compressing u-boot body!!\n");
1558 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1559 +       memmove ((void *)ntohl(hdr->ih_load), (uchar *)data, len);
1560 +       destLen = len;
1561 +#endif
1562 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1563 +       debug ("   Uncompression completed successfully with destLen %d.\n ",destLen );
1564 +       debug ("Head: Jumping to u-boot in the ram at 0x%08lx\n", CFG_MONITOR_BASE);
1565 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1566 +
1567 +       fn = ntohl(hdr->ih_load);
1568 +       (*fn)();
1569 +       hang ();
1570 +}
1571 +#else //CFG_BOOTSTRAP_CODE
1572  void board_init_r (gd_t *id, ulong dest_addr)
1573  {
1574         cmd_tbl_t *cmdtp;
1575 @@ -305,6 +495,8 @@ void board_init_r (gd_t *id, ulong dest_
1576         bd_t *bd;
1577         int i;
1578  
1579 +       puts("\n relocate_code finish.\n");
1580 +
1581         gd = id;
1582         gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
1583  
1584 @@ -321,12 +513,10 @@ void board_init_r (gd_t *id, ulong dest_
1585                 ulong addr;
1586  
1587                 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
1588 -#if 0
1589 -               printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
1590 -                               cmdtp->name, (ulong) (cmdtp->cmd), addr);
1591 -#endif
1592 -               cmdtp->cmd =
1593 -                       (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1594 +
1595 +               debug ("Command \"%s\": 0x%08lx => 0x%08lx\n", cmdtp->name, (ulong) (cmdtp->cmd), addr);
1596 +
1597 +               cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1598  
1599                 addr = (ulong)(cmdtp->name) + gd->reloc_off;
1600                 cmdtp->name = (char *)addr;
1601 @@ -363,7 +553,13 @@ void board_init_r (gd_t *id, ulong dest_
1602         /* initialize malloc() area */
1603         mem_malloc_init();
1604         malloc_bin_reloc();
1605 +#if (CONFIG_COMMANDS & CFG_CMD_NAND)
1606 +       nand_init();    /* go init the NAND */
1607 +#endif
1608  
1609 +#ifdef CONFIG_SPI
1610 +       spi_init_f();            /* go init the SPI flash */
1611 +#endif
1612         /* relocate environment function pointers etc. */
1613         env_relocate();
1614  
1615 @@ -424,9 +620,12 @@ void board_init_r (gd_t *id, ulong dest_
1616  
1617         /* NOTREACHED - no way out of command loop except booting */
1618  }
1619 +#endif //CFG_BOOTSTRAP_CODE
1620  
1621  void hang (void)
1622  {
1623 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1624         puts ("### ERROR ### Please RESET the board ###\n");
1625 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1626         for (;;);
1627  }
1628 --- a/lib_mips/time.c
1629 +++ b/lib_mips/time.c
1630 @@ -80,6 +80,19 @@ void udelay (unsigned long usec)
1631                 /*NOP*/;
1632  }
1633  
1634 +#ifndef CFG_BOOTSTRAP_CODE
1635 +void mdelay (unsigned long msec)
1636 +{
1637 +       int i,j;
1638 +       for(i=0;i<msec;i++)
1639 +       {
1640 +          udelay(1000);
1641 +
1642 +       }
1643 +
1644 +}
1645 +#endif
1646 +
1647  /*
1648   * This function is derived from PowerPC code (read timebase as long long).
1649   * On MIPS it just returns the timer value.
1650 --- a/net/eth.c
1651 +++ b/net/eth.c
1652 @@ -25,6 +25,9 @@
1653  #include <command.h>
1654  #include <net.h>
1655  #include <miiphy.h>
1656 +#if defined(CONFIG_IFX_MIPS)
1657 +#       include "ifx_eth.c"
1658 +#endif
1659  
1660  #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
1661  
1662 @@ -54,6 +57,9 @@ extern int scc_initialize(bd_t*);
1663  extern int skge_initialize(bd_t*);
1664  extern int tsec_initialize(bd_t*, int, char *);
1665  extern int npe_initialize(bd_t *);
1666 +#if defined(CONFIG_IFX_MIPS)
1667 +       IFX_ETH_INITIALIZE_EXTERN
1668 +#endif
1669  
1670  static struct eth_device *eth_devices, *eth_current;
1671  
1672 @@ -235,7 +241,9 @@ int eth_initialize(bd_t *bis)
1673  #if defined(CONFIG_RTL8169)
1674         rtl8169_initialize(bis);
1675  #endif
1676 -
1677 +#if defined(CONFIG_IFX_MIPS)
1678 +       IFX_ETH_INITIALIZE(bis)
1679 +#endif
1680         if (!eth_devices) {
1681                 puts ("No ethernet found.\n");
1682         } else {
1683 --- a/tools/mkimage.c
1684 +++ b/tools/mkimage.c
1685 @@ -28,6 +28,7 @@
1686  #ifndef __WIN32__
1687  #include <netinet/in.h>                /* for host / network byte order conversions    */
1688  #endif
1689 +#include <sys/types.h>
1690  #include <sys/mman.h>
1691  #include <sys/stat.h>
1692  #include <time.h>
1693 @@ -138,6 +139,7 @@ table_entry_t comp_name[] = {
1694      {  IH_COMP_NONE,   "none",         "uncompressed",         },
1695      {  IH_COMP_BZIP2,  "bzip2",        "bzip2 compressed",     },
1696      {  IH_COMP_GZIP,   "gzip",         "gzip compressed",      },
1697 +    {  IH_COMP_LZMA,   "lzma",         "lzma compressed",      },
1698      {  -1,             "",             "",                     },
1699  };
1700  
1701 @@ -445,7 +447,7 @@ NXTARG:             ;
1702         }
1703  
1704         /* We're a bit of paranoid */
1705 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1706 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1707         (void) fdatasync (ifd);
1708  #else
1709         (void) fsync (ifd);
1710 @@ -495,7 +497,7 @@ NXTARG:             ;
1711         (void) munmap((void *)ptr, sbuf.st_size);
1712  
1713         /* We're a bit of paranoid */
1714 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1715 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1716         (void) fdatasync (ifd);
1717  #else
1718         (void) fsync (ifd);
1719 --- a/cpu/mips/cache.S
1720 +++ b/cpu/mips/cache.S
1721 @@ -29,7 +29,9 @@
1722  #include <asm/mipsregs.h>
1723  #include <asm/addrspace.h>
1724  #include <asm/cacheops.h>
1725 -
1726 +#if defined(CONFIG_IFX_MIPS)
1727 +#      include "danube/ifx_cache.S"
1728 +#endif
1729  
1730         /* 16KB is the maximum size of instruction and data caches on
1731          * MIPS 4K.
1732 @@ -155,6 +157,9 @@ mips_cache_reset:
1733          */
1734  
1735         mtc0    zero, CP0_TAGLO
1736 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_INVALID_TAG)
1737 +       IFX_CACHE_EXTRA_INVALID_TAG
1738 +#endif
1739  
1740     /*
1741      * The caches are probably in an indeterminate state,
1742 @@ -171,6 +176,9 @@ mips_cache_reset:
1743         move    a1, a2
1744         icacheopn(a0,a1,a2,a3,121,(Index_Store_Tag_I,Fill))
1745  
1746 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_OPERATION)
1747 +       IFX_CACHE_EXTRA_OPERATION
1748 +#else
1749         /* To support Orion/R4600, we initialise the data cache in 3 passes.
1750          */
1751  
1752 @@ -200,6 +208,7 @@ mips_cache_reset:
1753         move    a3, t5          # dcacheLineSize
1754         move    a1, a2
1755         icacheop(a0,a1,a2,a3,Index_Store_Tag_D)
1756 +#endif
1757  
1758         j  ra
1759         .end  mips_cache_reset
1760 --- a/cpu/mips/config.mk
1761 +++ b/cpu/mips/config.mk
1762 @@ -20,20 +20,26 @@
1763  # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1764  # MA 02111-1307 USA
1765  #
1766 -v=$(shell \
1767 -$(CROSS_COMPILE)as --version|grep "GNU assembler"|awk '{print $$3}'|awk -F . '{print $$2}')
1768 -MIPSFLAGS=$(shell \
1769 -if [ "$v" -lt "14" ]; then \
1770 -       echo "-mcpu=4kc"; \
1771 -else \
1772 -       echo "-march=4kc -mtune=4kc"; \
1773 -fi)
1774  
1775 +ifndef PLATFORM_CPU
1776 +PLATFORM_CPU = mips32
1777 +endif
1778 +
1779 +MIPSFLAGS +=$(call cc-option,-march=$(PLATFORM_CPU) -mtune=$(PLATFORM_CPU),-mcpu=$(PLATFORM_CPU))
1780 +
1781 +ifeq ($(CROSS_COMPILE_UCLIBC),1)
1782 +ifneq (,$(findstring mipsel,$(CROSS_COMIPLE)))
1783 +ENDIANNESS = -el
1784 +else
1785 +ENDIANNESS = -eb
1786 +endif
1787 +else
1788  ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
1789  ENDIANNESS = -EL
1790  else
1791  ENDIANNESS = -EB
1792  endif
1793 +endif
1794  
1795  MIPSFLAGS += $(ENDIANNESS) -mabicalls
1796  
1797 --- a/cpu/mips/cpu.c
1798 +++ b/cpu/mips/cpu.c
1799 @@ -23,7 +23,12 @@
1800  
1801  #include <common.h>
1802  #include <command.h>
1803 -#include <asm/inca-ip.h>
1804 +#if defined(CONFIG_INCA_IP)
1805 +#      include <asm/inca-ip.h>
1806 +#elif defined(CONFIG_IFX_MIPS)
1807 +#      include <asm/danube.h>
1808 +#      include "danube/ifx_cpu.c"
1809 +#endif
1810  #include <asm/mipsregs.h>
1811  
1812  int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1813 @@ -34,6 +39,8 @@ int do_reset(cmd_tbl_t *cmdtp, int flag,
1814         void (*f)(void) = (void *) 0xbfc00000;
1815  
1816         f();
1817 +#elif defined(CONFIG_IFX_MIPS)
1818 +       IFX_CPU_RESET;
1819  #endif
1820         fprintf(stderr, "*** reset failed ***\n");
1821         return 0;
1822 --- a/cpu/mips/incaip_clock.c
1823 +++ b/cpu/mips/incaip_clock.c
1824 @@ -22,8 +22,9 @@
1825   */
1826  
1827  #include <common.h>
1828 -#include <asm/inca-ip.h>
1829  
1830 +#ifdef CONFIG_INCA_IP
1831 +#include <asm/inca-ip.h>
1832  
1833  /*******************************************************************************
1834  *
1835 @@ -114,3 +115,5 @@ int incaip_set_cpuclk (void)
1836  
1837         return 0;
1838  }
1839 +
1840 +#endif /* CONFIG_INCA_IP */
1841 --- a/cpu/mips/start.S
1842 +++ b/cpu/mips/start.S
1843 @@ -27,7 +27,9 @@
1844  #include <version.h>
1845  #include <asm/regdef.h>
1846  #include <asm/mipsregs.h>
1847 -
1848 +#if defined(CONFIG_IFX_MIPS)
1849 +#      include "danube/ifx_start.S"
1850 +#endif
1851  
1852  #define RVECENT(f,n) \
1853     b f; nop
1854 @@ -36,15 +38,24 @@
1855     li k0,bev
1856  
1857         .set noreorder
1858 -
1859 +#ifdef CFG_BOOTSTRAP_CODE
1860 +       .globl _start_bootstrap
1861 +#else
1862         .globl _start
1863 +#endif
1864         .text
1865 +#ifdef CFG_BOOTSTRAP_CODE
1866 +_start_bootstrap:
1867 +#else
1868  _start:
1869 +#endif
1870         RVECENT(reset,0)        /* U-boot entry point */
1871         RVECENT(reset,1)        /* software reboot */
1872 -#if defined(CONFIG_INCA_IP)
1873 +#if defined(CONFIG_INCA_IP) || defined(CONFIG_INCA_IP2)
1874         .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1875         .word 0x00000000           /* phase of the flash                    */
1876 +#elif defined(CONFIG_IFX_MIPS) && defined(IFX_EBU_BOOTCFG_DWORD)
1877 +       IFX_EBU_BOOTCFG_DWORD
1878  #elif defined(CONFIG_PURPLE)
1879         .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1880         .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1881 @@ -181,6 +192,9 @@ _start:
1882          * 128 * 8 == 1024 == 0x400
1883          * so this is address R_VEC+0x400 == 0xbfc00400
1884          */
1885 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_MORE_RESERVED_VECTORS)
1886 +       IFX_MORE_RESERVED_VECTORS
1887 +#else
1888  #ifdef CONFIG_PURPLE
1889  /* 0xbfc00400 */
1890         .word   0xdc870000
1891 @@ -205,8 +219,12 @@ _start:
1892         .word   0x00000000
1893         .word   0x00000000
1894  #endif /* CONFIG_PURPLE */
1895 +#endif /* CONFIG_IFX_MIPS */
1896         .align 4
1897  reset:
1898 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_RESET_PRECHECK)
1899 +       IFX_RESET_PRECHECK
1900 +#endif
1901  
1902         /* Clear watch registers.
1903          */
1904 @@ -226,6 +244,10 @@ reset:
1905         /* CAUSE register */
1906         mtc0    zero, CP0_CAUSE
1907  
1908 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU_EXTRA_INIT)
1909 +       IFX_CPU_EXTRA_INIT
1910 +#endif
1911 +
1912         /* Init Timer */
1913         mtc0    zero, CP0_COUNT
1914         mtc0    zero, CP0_COMPARE
1915 @@ -252,12 +274,26 @@ reset:
1916         nop
1917  #endif
1918  
1919 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_SKIP_LOWLEVEL_INIT)
1920 +       IFX_SKIP_LOWLEVEL_INIT
1921 +#endif
1922 +#ifdef CFG_BOOTSTRAP_CODE
1923         /* Initialize any external memory.
1924          */
1925         la      t9, lowlevel_init
1926         jalr    t9
1927         nop
1928 +#endif
1929 +lowlevel_init_done:
1930 +
1931 +       beq     s0, zero, init_cache_0
1932 +       nop
1933 +
1934 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_CPU1_INIT)
1935 +        IFX_CPU1_INIT
1936 +#endif
1937  
1938 +init_cache_0:
1939         /* Initialize caches...
1940          */
1941         la      t9, mips_cache_reset
1942 @@ -266,7 +302,11 @@ reset:
1943  
1944         /* ... and enable them.
1945          */
1946 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_OPER_MODE)
1947 +       IFX_CACHE_OPER_MODE
1948 +#else
1949         li      t0, CONF_CM_CACHABLE_NONCOHERENT
1950 +#endif
1951         mtc0    t0, CP0_CONFIG
1952  
1953  
1954 @@ -280,13 +320,38 @@ reset:
1955         li      t0, CFG_SDRAM_BASE + CFG_INIT_SP_OFFSET
1956         la      sp, 0(t0)
1957  
1958 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_BOOT_CLEAR)
1959 +       IFX_BOOT_CLEAR
1960 +#endif
1961 +
1962 +#ifdef CFG_BOOTSTRAP_CODE
1963 +       la      t9, bootstrap_board_init_f
1964 +#else
1965         la      t9, board_init_f
1966 +#endif
1967         j       t9
1968         nop
1969  
1970 +#ifdef CFG_BOOTSTRAP_CODE
1971 +/*
1972 + * void jump_unconditional (addr)
1973 + * This function simply jumps to the location pointed by a0.
1974 + * a0 = target_location
1975 + *
1976 + */
1977 +       .globl  jump_unconditional
1978 +       .ent    jump_unconditional
1979 +jump_unconditional:
1980 +       move t9, a0
1981 +       j       t9
1982 +       nop
1983 +       .end    jump_unconditional
1984 +
1985 +#endif
1986  
1987  /*
1988   * void relocate_code (addr_sp, gd, addr_moni)
1989 + * void bootstrap_relocate_code (addr_sp, gd, addr_moni)
1990   *
1991   * This "function" does not return, instead it continues in RAM
1992   * after relocating the monitor code.
1993 @@ -295,12 +360,22 @@ reset:
1994   * a1 = gd
1995   * a2 = destination address
1996   */
1997 +#ifdef CFG_BOOTSTRAP_CODE
1998 +       .globl  bootstrap_relocate_code
1999 +       .ent    bootstrap_relocate_code
2000 +bootstrap_relocate_code:
2001 +#else
2002         .globl  relocate_code
2003         .ent    relocate_code
2004  relocate_code:
2005 +#endif
2006         move    sp, a0          /* Set new stack pointer                */
2007  
2008 +#ifdef CFG_BOOTSTRAP_CODE
2009 +       li      t0, BOOTSTRAP_CFG_MONITOR_BASE
2010 +#else
2011         li      t0, CFG_MONITOR_BASE
2012 +#endif
2013         la      t3, in_ram
2014         lw      t2, -12(t3)     /* t2 <-- uboot_end_data        */
2015         move    t1, a2
2016 @@ -311,7 +386,11 @@ relocate_code:
2017          * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
2018          */
2019         move    t6, gp
2020 +#ifdef CFG_BOOTSTRAP_CODE
2021 +       sub     gp, BOOTSTRAP_CFG_MONITOR_BASE
2022 +#else
2023         sub     gp, CFG_MONITOR_BASE
2024 +#endif
2025         add     gp, a2                  /* gp now adjusted              */
2026         sub     t6, gp, t6              /* t6 <-- relocation offset     */
2027  
2028 @@ -337,12 +416,21 @@ relocate_code:
2029  
2030         /* Jump to where we've relocated ourselves.
2031          */
2032 +#ifdef CFG_BOOTSTRAP_CODE
2033 +       addi    t0, a2, in_ram - _start_bootstrap
2034 +#else
2035         addi    t0, a2, in_ram - _start
2036 +#endif
2037         j       t0
2038         nop
2039  
2040 +#ifdef CFG_BOOTSTRAP_CODE
2041 +       .word   uboot_end_data_bootstrap
2042 +       .word   uboot_end_bootstrap
2043 +#else
2044         .word   uboot_end_data
2045         .word   uboot_end
2046 +#endif
2047         .word   num_got_entries
2048  
2049  in_ram:
2050 @@ -374,12 +462,19 @@ in_ram:
2051         sw      zero, 0(t1)     /* delay slot                   */
2052  
2053         move    a0, a1
2054 +#ifdef CFG_BOOTSTRAP_CODE
2055 +       la      t9, bootstrap_board_init_r
2056 +#else
2057         la      t9, board_init_r
2058 +#endif
2059         j       t9
2060         move    a1, a2          /* delay slot                   */
2061  
2062 +#ifdef CFG_BOOTSTRAP_CODE
2063 +       .end    bootstrap_relocate_code
2064 +#else
2065         .end    relocate_code
2066 -
2067 +#endif
2068  
2069         /* Exception handlers.
2070          */
2071 @@ -388,3 +483,20 @@ romReserved:
2072  
2073  romExcHandle:
2074         b romExcHandle
2075 +
2076 +romEjtagHandle:
2077 +#ifdef CFG_BOOTSTRAP_CODE
2078 +       deret
2079 +       nop
2080 +#endif /* CFG_BOOTSTRAP_CODE */
2081 +1:
2082 +       b 1b
2083 +
2084 +       /* Additional handlers.
2085 +        */
2086 +#if defined(CONFIG_IFX_MIPS)
2087 +#if defined(IFX_MIPS_HANDLER_1)
2088 +ifx_mips_handler_1:
2089 +       IFX_MIPS_HANDLER_1
2090 +#endif
2091 +#endif
2092 --- a/tools/Makefile
2093 +++ b/tools/Makefile
2094 @@ -21,7 +21,7 @@
2095  # MA 02111-1307 USA
2096  #
2097  
2098 -BIN_FILES      = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
2099 +BIN_FILES      = mkimage$(SFX)
2100  
2101  OBJ_LINKS      = environment.o crc32.o
2102  OBJ_FILES      = img2srec.o mkimage.o envcrc.o gen_eth_addr.o bmp_logo.o