madwifi: handle frame classification properly if eth->h_proto contains the protocol...
[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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,7 +127,11 @@
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 @@ -139,12 +143,15 @@
873 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
874 endif
875 endif
876 +
877 +LDSCRIPT_BOOTSTRAP := $(TOPDIR)/board/$(BOARDDIR)/u-boot-bootstrap.lds
878 +
879 OBJCFLAGS += --gap-fill=0xff
880
881 gccincdir := $(shell $(CC) -print-file-name=include)
882
883 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
884 - -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
885 + -D__KERNEL__ -DUBOOT_RAM_TEXT_BASE=$(UBOOT_RAM_TEXT_BASE) \
886
887 ifneq ($(OBJTREE),$(SRCTREE))
888 CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
889 @@ -180,7 +187,8 @@
890
891 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
892
893 -LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
894 +LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(UBOOT_RAM_TEXT_BASE) $(PLATFORM_LDFLAGS)
895 +LDFLAGS_BOOTSTRAP += -Bstatic -T $(LDSCRIPT_BOOTSTRAP) -Ttext $(BOOTSTRAP_TEXT_BASE) $(PLATFORM_LDFLAGS)
896
897 # Location of a usable BFD library, where we define "usable" as
898 # "built for ${HOST}, supports ${TARGET}". Sensible values are
899 @@ -214,12 +222,19 @@
900 export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
901 AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
902 MAKE
903 -export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
904 +export UBOOT_RAM_TEXT_BASE BOOTSTRAP_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
905
906 #########################################################################
907
908 ifndef REMOTE_BUILD
909
910 +%_bootstrap.s: %_bootstrap.S
911 + $(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
912 +%_bootstrap.o: %_bootstrap.S
913 + $(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
914 +%_bootstrap.o: %_bootstrap.c
915 + $(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
916 +
917 %.s: %.S
918 $(CPP) $(AFLAGS) -o $@ $<
919 %.o: %.S
920 @@ -229,12 +244,20 @@
921
922 else
923
924 +$(obj)%_bootstrap.s: %_bootstrap.S
925 + $(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
926 +$(obj)%_bootstrap.o: %_bootstrap.S
927 + $(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
928 +$(obj)%_bootstrap.o: %_bootstrap.c
929 + $(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
930 +
931 $(obj)%.s: %.S
932 $(CPP) $(AFLAGS) -o $@ $<
933 $(obj)%.o: %.S
934 $(CC) $(AFLAGS) -c -o $@ $<
935 $(obj)%.o: %.c
936 $(CC) $(CFLAGS) -c -o $@ $<
937 +
938 endif
939
940 #########################################################################
941 --- a/drivers/Makefile
942 +++ b/drivers/Makefile
943 @@ -50,7 +50,7 @@
944 videomodes.o w83c553f.o \
945 ks8695eth.o \
946 pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o \
947 - rpx_pcmcia.o
948 + rpx_pcmcia.o ifx_sw.o
949
950 SRCS := $(COBJS:.o=.c)
951 OBJS := $(addprefix $(obj),$(COBJS))
952 --- a/include/asm-mips/mipsregs.h
953 +++ b/include/asm-mips/mipsregs.h
954 @@ -48,6 +48,7 @@
955 #define CP0_CAUSE $13
956 #define CP0_EPC $14
957 #define CP0_PRID $15
958 +#define CP0_EBASE $15,1
959 #define CP0_CONFIG $16
960 #define CP0_LLADDR $17
961 #define CP0_WATCHLO $18
962 @@ -330,11 +331,32 @@
963 # define KSU_USER 0x00000010
964 # define KSU_SUPERVISOR 0x00000008
965 # define KSU_KERNEL 0x00000000
966 +#ifdef CONFIG_DANUBE /* MIPS 24KE */
967 +/* bits 5 & 6 & 7: reserved */
968 +/* bits 8~15: IM0~7 */
969 +/* bits 16: reserved */
970 +#define ST0_CEE 0x00020000
971 +/* bits 18: always 0 */
972 +#define ST0_NMI 0x00080000
973 +#define ST0_SR 0x00100000
974 +#define ST0_TS 0x00200000
975 +#define ST0_BEV 0x00400000
976 +/* bits 23: reserved */
977 +#define ST0_MX 0x01000000
978 +#define ST0_RE 0x02000000
979 +#define ST0_FR 0x04000000
980 +#define ST0_RP 0x08000000
981 +#define ST0_CU0 0x10000000
982 +#define ST0_CU1 0x20000000
983 +#define ST0_CU2 0x40000000
984 +#define ST0_CU3 0x80000000
985 +#else
986 #define ST0_UX 0x00000020
987 #define ST0_SX 0x00000040
988 #define ST0_KX 0x00000080
989 #define ST0_DE 0x00010000
990 #define ST0_CE 0x00020000
991 +#endif
992
993 /*
994 * Bitfields in the R[23]000 cp0 status register.
995 @@ -471,6 +493,14 @@
996 #define CAUSEF_BD (1 << 31)
997
998 /*
999 + * Bits in the coprocessor 0 EBase register
1000 + */
1001 +#define EBASEB_CPUNUM 0
1002 +#define EBASEF_CPUNUM (0x3ff << EBASEB_CPUNUM)
1003 +#define EBASEB_EXPBASE 12
1004 +#define EBASEF_EXPBASE (0x3ffff << EBASEB_EXPBASE)
1005 +
1006 +/*
1007 * Bits in the coprozessor 0 config register.
1008 */
1009 #define CONF_CM_CACHABLE_NO_WA 0
1010 @@ -544,4 +574,10 @@
1011 #define CEB_KERNEL 2 /* Count events in kernel mode EXL = ERL = 0 */
1012 #define CEB_EXL 1 /* Count events with EXL = 1, ERL = 0 */
1013
1014 +/*
1015 + * Bits in ErrCtl register
1016 + */
1017 +#define ECCB_WST 29
1018 +#define ECCF_WST (0x1 << ECCB_WST)
1019 +
1020 #endif /* _ASM_MIPSREGS_H */
1021 --- a/include/cmd_confdefs.h
1022 +++ b/include/cmd_confdefs.h
1023 @@ -94,6 +94,7 @@
1024 #define CFG_CMD_EXT2 0x1000000000000000ULL /* EXT2 Support */
1025 #define CFG_CMD_SNTP 0x2000000000000000ULL /* SNTP support */
1026 #define CFG_CMD_DISPLAY 0x4000000000000000ULL /* Display support */
1027 +#define CFG_CMD_DHRYSTONE 0x8000000000000000ULL /* Dhrystone benchmark support */
1028
1029 #define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFULL /* ALL commands */
1030
1031 @@ -141,6 +142,7 @@
1032 CFG_CMD_SPI | \
1033 CFG_CMD_UNIVERSE | \
1034 CFG_CMD_USB | \
1035 + CFG_CMD_DHRYSTONE | \
1036 CFG_CMD_VFD )
1037
1038 /* Default configuration
1039 --- /dev/null
1040 +++ b/include/config.h
1041 @@ -0,0 +1,2 @@
1042 +/* Automatically generated - do not edit */
1043 +#include <configs/danube.h>
1044 --- /dev/null
1045 +++ b/include/config.mk
1046 @@ -0,0 +1,5 @@
1047 +ARCH = mips
1048 +CPU = mips
1049 +BOARD = danube
1050 +VENDOR = ifx
1051 +SOC = danube
1052 --- a/include/flash.h
1053 +++ b/include/flash.h
1054 @@ -79,7 +79,7 @@
1055 extern unsigned long flash_init (void);
1056 extern void flash_print_info (flash_info_t *);
1057 extern int flash_erase (flash_info_t *, int, int);
1058 -extern int flash_sect_erase (ulong addr_first, ulong addr_last);
1059 +extern int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase);
1060 extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
1061
1062 /* common/flash.c */
1063 @@ -299,6 +299,10 @@
1064 #define TOSH_ID_FVT160 0xC2 /* TC58FVT160 ID (16 M, top ) */
1065 #define TOSH_ID_FVB160 0x43 /* TC58FVT160 ID (16 M, bottom ) */
1066
1067 +#define MX_ID_29LV320AB 0x22A822A8 /* MXIC MX29LV320AB ID (32 M, bottom ) joelin */
1068 +#define MX_ID_29LV160BB 0x22492249 /* MXIC MX29LV160BB ID (16 M, bottom ) joelin */
1069 +#define MX_ID_29LV640BB 0x22cb22cb /* MXIC MX29LV640BB ID (64 M, bottom ) joelin */
1070 +
1071 /*-----------------------------------------------------------------------
1072 * Internal FLASH identification codes
1073 *
1074 @@ -422,6 +426,10 @@
1075 #define FLASH_S29GL064M 0x00F0 /* Spansion S29GL064M-R6 */
1076 #define FLASH_S29GL128N 0x00F1 /* Spansion S29GL128N */
1077
1078 +#define FLASH_29LV320AB 0x00B0 /* MXIC MX29LV320AB( 32M = 4M x 16 ) joelin 10/07/2004*/
1079 +#define FLASH_29LV160BB 0x00B1 /* MXIC MX29LV160BB( 16M = 2M x 16 ) joelin 11/22/2004*/
1080 +#define FLASH_29LV640BB 0x00B2 /* MXIC MX29LV640BB( 64M = 8M x 16 ) liupeng*/
1081 +
1082 #define FLASH_UNKNOWN 0xFFFF /* unknown flash type */
1083
1084
1085 --- a/include/image.h
1086 +++ b/include/image.h
1087 @@ -132,6 +132,7 @@
1088 #define IH_COMP_NONE 0 /* No Compression Used */
1089 #define IH_COMP_GZIP 1 /* gzip Compression Used */
1090 #define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
1091 +#define IH_COMP_LZMA 3 /* lzma Compression Used */
1092
1093 #define IH_MAGIC 0x27051956 /* Image Magic Number */
1094 #define IH_NMLEN 32 /* Image Name Length */
1095 --- /dev/null
1096 +++ b/include/syscall.h
1097 @@ -0,0 +1,42 @@
1098 +#ifndef __MON_SYS_CALL_H__
1099 +#define __MON_SYS_CALL_H__
1100 +
1101 +#ifndef __ASSEMBLY__
1102 +
1103 +#include <common.h>
1104 +
1105 +/* These are declarations of system calls available in C code */
1106 +int mon_getc(void);
1107 +int mon_tstc(void);
1108 +void mon_putc(const char);
1109 +void mon_puts(const char*);
1110 +void mon_printf(const char* fmt, ...);
1111 +void mon_install_hdlr(int, interrupt_handler_t*, void*);
1112 +void mon_free_hdlr(int);
1113 +void *mon_malloc(size_t);
1114 +void mon_free(void*);
1115 +void mon_udelay(unsigned long);
1116 +unsigned long mon_get_timer(unsigned long);
1117 +
1118 +#endif /* ifndef __ASSEMBLY__ */
1119 +
1120 +#define NR_SYSCALLS 11 /* number of syscalls */
1121 +
1122 +
1123 +/*
1124 + * Make sure these functions are in the same order as they
1125 + * appear in the "examples/syscall.S" file !!!
1126 + */
1127 +#define SYSCALL_GETC 0
1128 +#define SYSCALL_TSTC 1
1129 +#define SYSCALL_PUTC 2
1130 +#define SYSCALL_PUTS 3
1131 +#define SYSCALL_PRINTF 4
1132 +#define SYSCALL_INSTALL_HDLR 5
1133 +#define SYSCALL_FREE_HDLR 6
1134 +#define SYSCALL_MALLOC 7
1135 +#define SYSCALL_FREE 8
1136 +#define SYSCALL_UDELAY 9
1137 +#define SYSCALL_GET_TIMER 10
1138 +
1139 +#endif
1140 --- /dev/null
1141 +++ b/ld_uboot.conf
1142 @@ -0,0 +1,8 @@
1143 +TAG_DWNLD()
1144 +{
1145 + 0xA0B00000 "u-boot.bin" /* Download u-boot image */
1146 +};
1147 +TAG_START()
1148 +{
1149 + 0xA0B00000
1150 +}; /* Start u-boot image */
1151 --- a/lib_generic/Makefile
1152 +++ b/lib_generic/Makefile
1153 @@ -28,7 +28,7 @@
1154 COBJS = bzlib.o bzlib_crctable.o bzlib_decompress.o \
1155 bzlib_randtable.o bzlib_huffman.o \
1156 crc32.o ctype.o display_options.o ldiv.o \
1157 - string.o vsprintf.o zlib.o
1158 + string.o vsprintf.o zlib.o LzmaDecode.o LzmaWrapper.o
1159
1160 SRCS := $(COBJS:.o=.c)
1161 OBJS := $(addprefix $(obj),$(COBJS))
1162 --- a/lib_mips/board.c
1163 +++ b/lib_mips/board.c
1164 @@ -29,9 +29,30 @@
1165 #include <net.h>
1166 #include <environment.h>
1167
1168 +#ifdef CFG_BOOTSTRAP_CODE
1169 +//#include <asm/danube.h>
1170 +#undef CONFIG_MICROBZIP2
1171 +
1172 +#ifdef CONFIG_BZIP2
1173 +#include <bzlib.h>
1174 +#endif
1175 +
1176 +#ifdef CONFIG_MICROBZIP2
1177 +#include <micro_bzlib.h>
1178 +#endif
1179 +
1180 +#ifdef CONFIG_LZMA
1181 +#include <LzmaWrapper.h>
1182 +#endif
1183 +#endif //CFG_BOOTSTRAP_CODE
1184 +
1185 DECLARE_GLOBAL_DATA_PTR;
1186
1187 -#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1188 +#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < BOOTSTRAP_CFG_MONITOR_BASE) || \
1189 + (CFG_ENV_ADDR >= (BOOTSTRAP_CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
1190 + defined(CFG_ENV_IS_IN_NVRAM) && defined(CFG_BOOTSTRAP_CODE)
1191 +#define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
1192 +#elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1193 (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
1194 defined(CFG_ENV_IS_IN_NVRAM)
1195 #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
1196 @@ -39,21 +60,24 @@
1197 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
1198 #endif
1199
1200 -#undef DEBUG
1201 -
1202 extern int timer_init(void);
1203 -
1204 extern int incaip_set_cpuclk(void);
1205
1206 +#ifdef CFG_BOOTSTRAP_CODE
1207 +extern ulong uboot_end_data_bootstrap;
1208 +extern ulong uboot_end_bootstrap;
1209 +#else //CFG_BOOTSTRAP_CODE
1210 extern ulong uboot_end_data;
1211 extern ulong uboot_end;
1212 +#endif //CFG_BOOTSTRAP_CODE
1213
1214 ulong monitor_flash_len;
1215
1216 -const char version_string[] =
1217 - U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
1218 +const char version_string[] = U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
1219
1220 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1221 static char *failed = "*** failed ***\n";
1222 +#endif
1223
1224 /*
1225 * Begin and End of memory area for malloc(), and current "brk"
1226 @@ -62,14 +86,15 @@
1227 static ulong mem_malloc_end;
1228 static ulong mem_malloc_brk;
1229
1230 -
1231 /*
1232 * The Malloc area is immediately below the monitor copy in DRAM
1233 */
1234 -static void mem_malloc_init (void)
1235 -{
1236 +#ifdef CFG_BOOTSTRAP_CODE
1237 +static void mem_malloc_init (ulong dest_addr) {
1238 +#else //CFG_BOOTSTRAP_CODE
1239 +static void mem_malloc_init (void) {
1240 ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
1241 -
1242 +#endif //CFG_BOOTSTRAP_CODE
1243 mem_malloc_end = dest_addr;
1244 mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
1245 mem_malloc_brk = mem_malloc_start;
1246 @@ -79,6 +104,25 @@
1247 mem_malloc_end - mem_malloc_start);
1248 }
1249
1250 +#ifdef CFG_BOOTSTRAP_CODE
1251 +void *malloc(unsigned int size) {
1252 + if(size < (mem_malloc_end - mem_malloc_start)) {
1253 + mem_malloc_start += size;
1254 + debug ("malloc : size required = 0x%08lx and pointer = 0x%08lx\n",size,mem_malloc_start - size);
1255 + return (void *)(mem_malloc_start - size);
1256 + }
1257 + return NULL;
1258 +}
1259 +
1260 +void *realloc(void *src,unsigned int size) {
1261 + return NULL;
1262 +}
1263 +
1264 +void free(void *src) {
1265 + return;
1266 +}
1267 +#endif //CFG_BOOTSTRAP_CODE
1268 +
1269 void *sbrk (ptrdiff_t increment)
1270 {
1271 ulong old = mem_malloc_brk;
1272 @@ -99,42 +143,58 @@
1273 #else
1274 int board_type = 0; /* use dummy arg */
1275 #endif
1276 - puts ("DRAM: ");
1277
1278 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1279 +#ifdef CONFIG_USE_DDR_RAM
1280 + puts ("DDR-DRAM: ");
1281 +#else
1282 + puts ("DRAM: ");
1283 +#endif
1284 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1285 if ((gd->ram_size = initdram (board_type)) > 0) {
1286 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1287 print_size (gd->ram_size, "\n");
1288 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1289 return (0);
1290 }
1291 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1292 puts (failed);
1293 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1294 return (1);
1295 }
1296
1297 +#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
1298 static int display_banner(void)
1299 {
1300 -
1301 printf ("\n\n%s\n\n", version_string);
1302 return (0);
1303 }
1304 +#endif
1305
1306 +#ifndef CFG_BOOTSTRAP_CODE
1307 static void display_flash_config(ulong size)
1308 {
1309 puts ("Flash: ");
1310 print_size (size, "\n");
1311 }
1312 +#endif //CFG_BOOTSTRAP_CODE
1313
1314 -
1315 +#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
1316 static int init_baudrate (void)
1317 {
1318 +#ifndef CFG_BOOTSTRAP_CODE
1319 char tmp[64]; /* long enough for environment variables */
1320 int i = getenv_r ("baudrate", tmp, sizeof (tmp));
1321
1322 gd->baudrate = (i > 0)
1323 ? (int) simple_strtoul (tmp, NULL, 10)
1324 : CONFIG_BAUDRATE;
1325 -
1326 +#else //CFG_BOOTSTRAP_CODE
1327 + gd->baudrate = CONFIG_BAUDRATE;
1328 +#endif //CFG_BOOTSTRAP_CODE
1329 return (0);
1330 }
1331 -
1332 +#endif
1333
1334 /*
1335 * Breath some life into the board...
1336 @@ -159,27 +219,49 @@
1337 typedef int (init_fnc_t) (void);
1338
1339 init_fnc_t *init_sequence[] = {
1340 +#ifdef CFG_BOOTSTRAP_CODE
1341 + //fuse_prg,
1342 + //timer_init,
1343 + //env_init, /* initialize environment */
1344 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1345 + init_baudrate, /* initialze baudrate settings */
1346 + serial_init, /* serial communications setup */
1347 + console_init_f,
1348 + display_banner, /* say that we are here */
1349 + checkboard,
1350 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1351 + init_func_ram,
1352 + NULL,
1353 +#else /********** CFG_BOOTSTRAP_CODE **********/
1354 timer_init,
1355 - env_init, /* initialize environment */
1356 -#ifdef CONFIG_INCA_IP
1357 - incaip_set_cpuclk, /* set cpu clock according to environment variable */
1358 -#endif
1359 init_baudrate, /* initialze baudrate settings */
1360 serial_init, /* serial communications setup */
1361 console_init_f,
1362 display_banner, /* say that we are here */
1363 checkboard,
1364 init_func_ram,
1365 + env_init, /* initialize environment */
1366 NULL,
1367 +#endif //CFG_BOOTSTRAP_CODE
1368 };
1369
1370 +#ifdef CFG_BOOTSTRAP_CODE
1371 +extern void bootstrap_relocate_code(ulong addr_sp, gd_t *id, ulong addr);
1372
1373 +void bootstrap_board_init_f(ulong bootflag)
1374 +#else
1375 void board_init_f(ulong bootflag)
1376 +#endif
1377 {
1378 gd_t gd_data, *id;
1379 bd_t *bd;
1380 init_fnc_t **init_fnc_ptr;
1381 - ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE;
1382 +#ifdef CFG_BOOTSTRAP_CODE
1383 + ulong addr, addr_sp, len = (ulong)&uboot_end_bootstrap - BOOTSTRAP_CFG_MONITOR_BASE;
1384 + ulong lzmaImageaddr = 0;
1385 +#else //CFG_BOOTSTRAP_CODE
1386 + ulong addr, addr_sp, len = CFG_MONITOR_LEN;
1387 +#endif //CFG_BOOTSTRAP_CODE
1388 ulong *s;
1389 #ifdef CONFIG_PURPLE
1390 void copy_code (ulong);
1391 @@ -219,13 +301,12 @@
1392 addr -= len;
1393 addr &= ~(16 * 1024 - 1);
1394
1395 - debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
1396 + debug ("Reserving %d Bytes for U-Boot at: %08lx\n", len, addr);
1397
1398 /* Reserve memory for malloc() arena.
1399 */
1400 addr_sp = addr - TOTAL_MALLOC_LEN;
1401 - debug ("Reserving %dk for malloc() at: %08lx\n",
1402 - TOTAL_MALLOC_LEN >> 10, addr_sp);
1403 + debug ("Reserving %d Bytes for malloc() at: %08lx\n", TOTAL_MALLOC_LEN, addr_sp);
1404
1405 /*
1406 * (permanently) allocate a Board Info struct
1407 @@ -234,20 +315,17 @@
1408 addr_sp -= sizeof(bd_t);
1409 bd = (bd_t *)addr_sp;
1410 gd->bd = bd;
1411 - debug ("Reserving %d Bytes for Board Info at: %08lx\n",
1412 - sizeof(bd_t), addr_sp);
1413 + debug ("Reserving %d Bytes for Board Info at: %08lx\n", sizeof(bd_t), addr_sp);
1414
1415 addr_sp -= sizeof(gd_t);
1416 id = (gd_t *)addr_sp;
1417 - debug ("Reserving %d Bytes for Global Data at: %08lx\n",
1418 - sizeof (gd_t), addr_sp);
1419 + debug ("Reserving %d Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp);
1420
1421 /* Reserve memory for boot params.
1422 */
1423 addr_sp -= CFG_BOOTPARAMS_LEN;
1424 bd->bi_boot_params = addr_sp;
1425 - debug ("Reserving %dk for boot params() at: %08lx\n",
1426 - CFG_BOOTPARAMS_LEN >> 10, addr_sp);
1427 + debug ("Reserving %dk for boot params() at: %08lx\n", CFG_BOOTPARAMS_LEN >> 10, addr_sp);
1428
1429 /*
1430 * Finally, we set up a new (bigger) stack.
1431 @@ -279,7 +357,16 @@
1432 copy_code(addr);
1433 #endif
1434
1435 +#ifdef CFG_BOOTSTRAP_CODE
1436 + lzmaImageaddr = (ulong)&uboot_end_data_bootstrap;
1437 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1438 + puts("\n BOOTSTRAP: relocate_code start");
1439 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1440 + bootstrap_relocate_code (addr_sp, id, addr);
1441 +#else //CFG_BOOTSTRAP_CODE
1442 + puts("\n relocate_code start");
1443 relocate_code (addr_sp, id, addr);
1444 +#endif //CFG_BOOTSTRAP_CODE
1445
1446 /* NOTREACHED - relocate_code() does not return */
1447 }
1448 @@ -292,7 +379,110 @@
1449 *
1450 ************************************************************************
1451 */
1452 +#ifdef CFG_BOOTSTRAP_CODE
1453 +void bootstrap_board_init_r (gd_t *id, ulong dest_addr) {
1454 + int i;
1455 + ulong addr;
1456 + ulong data, len, checksum;
1457 + ulong *len_ptr;
1458 + image_header_t header;
1459 + image_header_t *hdr = &header;
1460 + unsigned int destLen;
1461 + int (*fn)(void);
1462 +
1463 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1464 + puts("\n BOOTSTRAP: relocate_code finish.\n");
1465 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1466 +
1467 + /* initialize malloc() area */
1468 + mem_malloc_init(dest_addr);
1469 +
1470 + addr = (char *)(BOOTSTRAP_CFG_MONITOR_BASE + ((ulong)&uboot_end_data_bootstrap - dest_addr));
1471 + memmove (&header, (char *)addr, sizeof(image_header_t));
1472 +
1473 + if (ntohl(hdr->ih_magic) != IH_MAGIC) {
1474 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1475 + printf ("Bad Magic Number at address 0x%08lx\n",addr);
1476 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1477 + return;
1478 + }
1479
1480 + data = (ulong)&header;
1481 + len = sizeof(image_header_t);
1482 +
1483 + checksum = ntohl(hdr->ih_hcrc);
1484 + hdr->ih_hcrc = 0;
1485 + if (crc32 (0, (unsigned char *)data, len) != checksum) {
1486 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1487 + printf ("Bad Header Checksum\n");
1488 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1489 + return;
1490 + }
1491 +
1492 + data = addr + sizeof(image_header_t);
1493 + len = ntohl(hdr->ih_size);
1494 + len_ptr = (ulong *)data;
1495 +
1496 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1497 + debug ("Disabling all the interrupts\n");
1498 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1499 + disable_interrupts();
1500 +
1501 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1502 + debug (" Uncompressing UBoot Image ... \n" );
1503 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1504 + /*
1505 + * If we've got less than 4 MB of malloc() space,
1506 + * use slower decompression algorithm which requires
1507 + * at most 2300 KB of memory.
1508 + */
1509 + destLen = 0x0;
1510 +
1511 +#ifdef CONFIG_BZIP2
1512 + i = BZ2_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1513 + 0x400000, (char *)data, len,
1514 + CFG_MALLOC_LEN < (4096 * 1024), 0);
1515 + if (i != BZ_OK) {
1516 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1517 + printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1518 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1519 + return;
1520 + }
1521 +#elif CONFIG_MICROBZIP2
1522 + i = micro_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1523 + &destLen, (char *)data, len,
1524 + CFG_MALLOC_LEN < (4096 * 1024), 0);
1525 + if (i != RETVAL_OK) {
1526 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1527 + printf ("MICRO_BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1528 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1529 + return;
1530 + }
1531 +#elif CONFIG_LZMA
1532 + i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &destLen);
1533 + if (i != LZMA_RESULT_OK) {
1534 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1535 + printf ("LZMA ERROR %d - must RESET board to recover\n", i);
1536 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1537 + return;
1538 + }
1539 +#else
1540 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1541 + printf ("NONE Compressing u-boot body!!\n");
1542 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1543 + memmove ((void *)ntohl(hdr->ih_load), (uchar *)data, len);
1544 + destLen = len;
1545 +#endif
1546 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1547 + debug (" Uncompression completed successfully with destLen %d.\n ",destLen );
1548 + debug ("Head: Jumping to u-boot in the ram at 0x%08lx\n", CFG_MONITOR_BASE);
1549 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1550 +
1551 + fn = ntohl(hdr->ih_load);
1552 + (*fn)();
1553 + hang ();
1554 +}
1555 +#else //CFG_BOOTSTRAP_CODE
1556 void board_init_r (gd_t *id, ulong dest_addr)
1557 {
1558 cmd_tbl_t *cmdtp;
1559 @@ -305,6 +495,8 @@
1560 bd_t *bd;
1561 int i;
1562
1563 + puts("\n relocate_code finish.\n");
1564 +
1565 gd = id;
1566 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
1567
1568 @@ -321,12 +513,10 @@
1569 ulong addr;
1570
1571 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
1572 -#if 0
1573 - printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
1574 - cmdtp->name, (ulong) (cmdtp->cmd), addr);
1575 -#endif
1576 - cmdtp->cmd =
1577 - (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1578 +
1579 + debug ("Command \"%s\": 0x%08lx => 0x%08lx\n", cmdtp->name, (ulong) (cmdtp->cmd), addr);
1580 +
1581 + cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1582
1583 addr = (ulong)(cmdtp->name) + gd->reloc_off;
1584 cmdtp->name = (char *)addr;
1585 @@ -363,7 +553,13 @@
1586 /* initialize malloc() area */
1587 mem_malloc_init();
1588 malloc_bin_reloc();
1589 +#if (CONFIG_COMMANDS & CFG_CMD_NAND)
1590 + nand_init(); /* go init the NAND */
1591 +#endif
1592
1593 +#ifdef CONFIG_SPI
1594 + spi_init_f(); /* go init the SPI flash */
1595 +#endif
1596 /* relocate environment function pointers etc. */
1597 env_relocate();
1598
1599 @@ -424,9 +620,12 @@
1600
1601 /* NOTREACHED - no way out of command loop except booting */
1602 }
1603 +#endif //CFG_BOOTSTRAP_CODE
1604
1605 void hang (void)
1606 {
1607 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1608 puts ("### ERROR ### Please RESET the board ###\n");
1609 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1610 for (;;);
1611 }
1612 --- a/lib_mips/time.c
1613 +++ b/lib_mips/time.c
1614 @@ -80,6 +80,19 @@
1615 /*NOP*/;
1616 }
1617
1618 +#ifndef CFG_BOOTSTRAP_CODE
1619 +void mdelay (unsigned long msec)
1620 +{
1621 + int i,j;
1622 + for(i=0;i<msec;i++)
1623 + {
1624 + udelay(1000);
1625 +
1626 + }
1627 +
1628 +}
1629 +#endif
1630 +
1631 /*
1632 * This function is derived from PowerPC code (read timebase as long long).
1633 * On MIPS it just returns the timer value.
1634 --- a/net/eth.c
1635 +++ b/net/eth.c
1636 @@ -25,6 +25,9 @@
1637 #include <command.h>
1638 #include <net.h>
1639 #include <miiphy.h>
1640 +#if defined(CONFIG_IFX_MIPS)
1641 +# include "ifx_eth.c"
1642 +#endif
1643
1644 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
1645
1646 @@ -54,6 +57,9 @@
1647 extern int skge_initialize(bd_t*);
1648 extern int tsec_initialize(bd_t*, int, char *);
1649 extern int npe_initialize(bd_t *);
1650 +#if defined(CONFIG_IFX_MIPS)
1651 + IFX_ETH_INITIALIZE_EXTERN
1652 +#endif
1653
1654 static struct eth_device *eth_devices, *eth_current;
1655
1656 @@ -235,7 +241,9 @@
1657 #if defined(CONFIG_RTL8169)
1658 rtl8169_initialize(bis);
1659 #endif
1660 -
1661 +#if defined(CONFIG_IFX_MIPS)
1662 + IFX_ETH_INITIALIZE(bis)
1663 +#endif
1664 if (!eth_devices) {
1665 puts ("No ethernet found.\n");
1666 } else {
1667 --- a/tools/mkimage.c
1668 +++ b/tools/mkimage.c
1669 @@ -28,6 +28,7 @@
1670 #ifndef __WIN32__
1671 #include <netinet/in.h> /* for host / network byte order conversions */
1672 #endif
1673 +#include <sys/types.h>
1674 #include <sys/mman.h>
1675 #include <sys/stat.h>
1676 #include <time.h>
1677 @@ -138,6 +139,7 @@
1678 { IH_COMP_NONE, "none", "uncompressed", },
1679 { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
1680 { IH_COMP_GZIP, "gzip", "gzip compressed", },
1681 + { IH_COMP_LZMA, "lzma", "lzma compressed", },
1682 { -1, "", "", },
1683 };
1684
1685 @@ -445,7 +447,7 @@
1686 }
1687
1688 /* We're a bit of paranoid */
1689 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1690 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1691 (void) fdatasync (ifd);
1692 #else
1693 (void) fsync (ifd);
1694 @@ -495,7 +497,7 @@
1695 (void) munmap((void *)ptr, sbuf.st_size);
1696
1697 /* We're a bit of paranoid */
1698 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1699 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1700 (void) fdatasync (ifd);
1701 #else
1702 (void) fsync (ifd);
1703 --- a/cpu/mips/cache.S
1704 +++ b/cpu/mips/cache.S
1705 @@ -29,7 +29,9 @@
1706 #include <asm/mipsregs.h>
1707 #include <asm/addrspace.h>
1708 #include <asm/cacheops.h>
1709 -
1710 +#if defined(CONFIG_IFX_MIPS)
1711 +# include "danube/ifx_cache.S"
1712 +#endif
1713
1714 /* 16KB is the maximum size of instruction and data caches on
1715 * MIPS 4K.
1716 @@ -155,6 +157,9 @@
1717 */
1718
1719 mtc0 zero, CP0_TAGLO
1720 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_INVALID_TAG)
1721 + IFX_CACHE_EXTRA_INVALID_TAG
1722 +#endif
1723
1724 /*
1725 * The caches are probably in an indeterminate state,
1726 @@ -171,6 +176,9 @@
1727 move a1, a2
1728 icacheopn(a0,a1,a2,a3,121,(Index_Store_Tag_I,Fill))
1729
1730 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_OPERATION)
1731 + IFX_CACHE_EXTRA_OPERATION
1732 +#else
1733 /* To support Orion/R4600, we initialise the data cache in 3 passes.
1734 */
1735
1736 @@ -200,6 +208,7 @@
1737 move a3, t5 # dcacheLineSize
1738 move a1, a2
1739 icacheop(a0,a1,a2,a3,Index_Store_Tag_D)
1740 +#endif
1741
1742 j ra
1743 .end mips_cache_reset
1744 --- a/cpu/mips/config.mk
1745 +++ b/cpu/mips/config.mk
1746 @@ -20,20 +20,26 @@
1747 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1748 # MA 02111-1307 USA
1749 #
1750 -v=$(shell \
1751 -$(CROSS_COMPILE)as --version|grep "GNU assembler"|awk '{print $$3}'|awk -F . '{print $$2}')
1752 -MIPSFLAGS=$(shell \
1753 -if [ "$v" -lt "14" ]; then \
1754 - echo "-mcpu=4kc"; \
1755 -else \
1756 - echo "-march=4kc -mtune=4kc"; \
1757 -fi)
1758
1759 +ifndef PLATFORM_CPU
1760 +PLATFORM_CPU = mips32
1761 +endif
1762 +
1763 +MIPSFLAGS +=$(call cc-option,-march=$(PLATFORM_CPU) -mtune=$(PLATFORM_CPU),-mcpu=$(PLATFORM_CPU))
1764 +
1765 +ifeq ($(CROSS_COMPILE_UCLIBC),1)
1766 +ifneq (,$(findstring mipsel,$(CROSS_COMIPLE)))
1767 +ENDIANNESS = -el
1768 +else
1769 +ENDIANNESS = -eb
1770 +endif
1771 +else
1772 ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
1773 ENDIANNESS = -EL
1774 else
1775 ENDIANNESS = -EB
1776 endif
1777 +endif
1778
1779 MIPSFLAGS += $(ENDIANNESS) -mabicalls
1780
1781 --- a/cpu/mips/cpu.c
1782 +++ b/cpu/mips/cpu.c
1783 @@ -23,7 +23,12 @@
1784
1785 #include <common.h>
1786 #include <command.h>
1787 -#include <asm/inca-ip.h>
1788 +#if defined(CONFIG_INCA_IP)
1789 +# include <asm/inca-ip.h>
1790 +#elif defined(CONFIG_IFX_MIPS)
1791 +# include <asm/danube.h>
1792 +# include "danube/ifx_cpu.c"
1793 +#endif
1794 #include <asm/mipsregs.h>
1795
1796 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1797 @@ -34,6 +39,8 @@
1798 void (*f)(void) = (void *) 0xbfc00000;
1799
1800 f();
1801 +#elif defined(CONFIG_IFX_MIPS)
1802 + IFX_CPU_RESET;
1803 #endif
1804 fprintf(stderr, "*** reset failed ***\n");
1805 return 0;
1806 --- a/cpu/mips/incaip_clock.c
1807 +++ b/cpu/mips/incaip_clock.c
1808 @@ -22,8 +22,9 @@
1809 */
1810
1811 #include <common.h>
1812 -#include <asm/inca-ip.h>
1813
1814 +#ifdef CONFIG_INCA_IP
1815 +#include <asm/inca-ip.h>
1816
1817 /*******************************************************************************
1818 *
1819 @@ -114,3 +115,5 @@
1820
1821 return 0;
1822 }
1823 +
1824 +#endif /* CONFIG_INCA_IP */
1825 --- a/cpu/mips/start.S
1826 +++ b/cpu/mips/start.S
1827 @@ -27,7 +27,9 @@
1828 #include <version.h>
1829 #include <asm/regdef.h>
1830 #include <asm/mipsregs.h>
1831 -
1832 +#if defined(CONFIG_IFX_MIPS)
1833 +# include "danube/ifx_start.S"
1834 +#endif
1835
1836 #define RVECENT(f,n) \
1837 b f; nop
1838 @@ -36,15 +38,24 @@
1839 li k0,bev
1840
1841 .set noreorder
1842 -
1843 +#ifdef CFG_BOOTSTRAP_CODE
1844 + .globl _start_bootstrap
1845 +#else
1846 .globl _start
1847 +#endif
1848 .text
1849 +#ifdef CFG_BOOTSTRAP_CODE
1850 +_start_bootstrap:
1851 +#else
1852 _start:
1853 +#endif
1854 RVECENT(reset,0) /* U-boot entry point */
1855 RVECENT(reset,1) /* software reboot */
1856 -#if defined(CONFIG_INCA_IP)
1857 +#if defined(CONFIG_INCA_IP) || defined(CONFIG_INCA_IP2)
1858 .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1859 .word 0x00000000 /* phase of the flash */
1860 +#elif defined(CONFIG_IFX_MIPS) && defined(IFX_EBU_BOOTCFG_DWORD)
1861 + IFX_EBU_BOOTCFG_DWORD
1862 #elif defined(CONFIG_PURPLE)
1863 .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1864 .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1865 @@ -181,6 +192,9 @@
1866 * 128 * 8 == 1024 == 0x400
1867 * so this is address R_VEC+0x400 == 0xbfc00400
1868 */
1869 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_MORE_RESERVED_VECTORS)
1870 + IFX_MORE_RESERVED_VECTORS
1871 +#else
1872 #ifdef CONFIG_PURPLE
1873 /* 0xbfc00400 */
1874 .word 0xdc870000
1875 @@ -205,8 +219,12 @@
1876 .word 0x00000000
1877 .word 0x00000000
1878 #endif /* CONFIG_PURPLE */
1879 +#endif /* CONFIG_IFX_MIPS */
1880 .align 4
1881 reset:
1882 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_RESET_PRECHECK)
1883 + IFX_RESET_PRECHECK
1884 +#endif
1885
1886 /* Clear watch registers.
1887 */
1888 @@ -226,6 +244,10 @@
1889 /* CAUSE register */
1890 mtc0 zero, CP0_CAUSE
1891
1892 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU_EXTRA_INIT)
1893 + IFX_CPU_EXTRA_INIT
1894 +#endif
1895 +
1896 /* Init Timer */
1897 mtc0 zero, CP0_COUNT
1898 mtc0 zero, CP0_COMPARE
1899 @@ -252,12 +274,26 @@
1900 nop
1901 #endif
1902
1903 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_SKIP_LOWLEVEL_INIT)
1904 + IFX_SKIP_LOWLEVEL_INIT
1905 +#endif
1906 +#ifdef CFG_BOOTSTRAP_CODE
1907 /* Initialize any external memory.
1908 */
1909 la t9, lowlevel_init
1910 jalr t9
1911 nop
1912 +#endif
1913 +lowlevel_init_done:
1914 +
1915 + beq s0, zero, init_cache_0
1916 + nop
1917 +
1918 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_CPU1_INIT)
1919 + IFX_CPU1_INIT
1920 +#endif
1921
1922 +init_cache_0:
1923 /* Initialize caches...
1924 */
1925 la t9, mips_cache_reset
1926 @@ -266,7 +302,11 @@
1927
1928 /* ... and enable them.
1929 */
1930 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_OPER_MODE)
1931 + IFX_CACHE_OPER_MODE
1932 +#else
1933 li t0, CONF_CM_CACHABLE_NONCOHERENT
1934 +#endif
1935 mtc0 t0, CP0_CONFIG
1936
1937
1938 @@ -280,13 +320,38 @@
1939 li t0, CFG_SDRAM_BASE + CFG_INIT_SP_OFFSET
1940 la sp, 0(t0)
1941
1942 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_BOOT_CLEAR)
1943 + IFX_BOOT_CLEAR
1944 +#endif
1945 +
1946 +#ifdef CFG_BOOTSTRAP_CODE
1947 + la t9, bootstrap_board_init_f
1948 +#else
1949 la t9, board_init_f
1950 +#endif
1951 j t9
1952 nop
1953
1954 +#ifdef CFG_BOOTSTRAP_CODE
1955 +/*
1956 + * void jump_unconditional (addr)
1957 + * This function simply jumps to the location pointed by a0.
1958 + * a0 = target_location
1959 + *
1960 + */
1961 + .globl jump_unconditional
1962 + .ent jump_unconditional
1963 +jump_unconditional:
1964 + move t9, a0
1965 + j t9
1966 + nop
1967 + .end jump_unconditional
1968 +
1969 +#endif
1970
1971 /*
1972 * void relocate_code (addr_sp, gd, addr_moni)
1973 + * void bootstrap_relocate_code (addr_sp, gd, addr_moni)
1974 *
1975 * This "function" does not return, instead it continues in RAM
1976 * after relocating the monitor code.
1977 @@ -295,12 +360,22 @@
1978 * a1 = gd
1979 * a2 = destination address
1980 */
1981 +#ifdef CFG_BOOTSTRAP_CODE
1982 + .globl bootstrap_relocate_code
1983 + .ent bootstrap_relocate_code
1984 +bootstrap_relocate_code:
1985 +#else
1986 .globl relocate_code
1987 .ent relocate_code
1988 relocate_code:
1989 +#endif
1990 move sp, a0 /* Set new stack pointer */
1991
1992 +#ifdef CFG_BOOTSTRAP_CODE
1993 + li t0, BOOTSTRAP_CFG_MONITOR_BASE
1994 +#else
1995 li t0, CFG_MONITOR_BASE
1996 +#endif
1997 la t3, in_ram
1998 lw t2, -12(t3) /* t2 <-- uboot_end_data */
1999 move t1, a2
2000 @@ -311,7 +386,11 @@
2001 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
2002 */
2003 move t6, gp
2004 +#ifdef CFG_BOOTSTRAP_CODE
2005 + sub gp, BOOTSTRAP_CFG_MONITOR_BASE
2006 +#else
2007 sub gp, CFG_MONITOR_BASE
2008 +#endif
2009 add gp, a2 /* gp now adjusted */
2010 sub t6, gp, t6 /* t6 <-- relocation offset */
2011
2012 @@ -337,12 +416,21 @@
2013
2014 /* Jump to where we've relocated ourselves.
2015 */
2016 +#ifdef CFG_BOOTSTRAP_CODE
2017 + addi t0, a2, in_ram - _start_bootstrap
2018 +#else
2019 addi t0, a2, in_ram - _start
2020 +#endif
2021 j t0
2022 nop
2023
2024 +#ifdef CFG_BOOTSTRAP_CODE
2025 + .word uboot_end_data_bootstrap
2026 + .word uboot_end_bootstrap
2027 +#else
2028 .word uboot_end_data
2029 .word uboot_end
2030 +#endif
2031 .word num_got_entries
2032
2033 in_ram:
2034 @@ -374,12 +462,19 @@
2035 sw zero, 0(t1) /* delay slot */
2036
2037 move a0, a1
2038 +#ifdef CFG_BOOTSTRAP_CODE
2039 + la t9, bootstrap_board_init_r
2040 +#else
2041 la t9, board_init_r
2042 +#endif
2043 j t9
2044 move a1, a2 /* delay slot */
2045
2046 +#ifdef CFG_BOOTSTRAP_CODE
2047 + .end bootstrap_relocate_code
2048 +#else
2049 .end relocate_code
2050 -
2051 +#endif
2052
2053 /* Exception handlers.
2054 */
2055 @@ -388,3 +483,20 @@
2056
2057 romExcHandle:
2058 b romExcHandle
2059 +
2060 +romEjtagHandle:
2061 +#ifdef CFG_BOOTSTRAP_CODE
2062 + deret
2063 + nop
2064 +#endif /* CFG_BOOTSTRAP_CODE */
2065 +1:
2066 + b 1b
2067 +
2068 + /* Additional handlers.
2069 + */
2070 +#if defined(CONFIG_IFX_MIPS)
2071 +#if defined(IFX_MIPS_HANDLER_1)
2072 +ifx_mips_handler_1:
2073 + IFX_MIPS_HANDLER_1
2074 +#endif
2075 +#endif
This page took 0.121409 seconds and 5 git commands to generate.