libbase/crt0-lm32.S: Add provisions for loading .data from flash.

:100644 100644 e0cd7153 34428845 M	litex/soc/software/libbase/crt0-lm32.S
This commit is contained in:
William D. Jones 2018-09-21 10:14:50 -04:00
parent 01ae7d4235
commit 9d4da737ff
2 changed files with 24 additions and 2 deletions

View File

@ -4,7 +4,7 @@ include $(SOC_DIRECTORY)/software/common.mak
OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \
system.o id.o uart.o time.o qsort.o strtod.o spiflash.o strcasecmp.o
all: crt0-$(CPU).o libbase.a libbase-nofloat.a
all: crt0-$(CPU).o crt0-$(CPU)-flash.o libbase.a libbase-nofloat.a
libbase.a: $(OBJECTS) vsnprintf.o
$(AR) crs libbase.a $(OBJECTS) vsnprintf.o
@ -24,8 +24,11 @@ vsnprintf-nofloat.o: $(LIBBASE_DIRECTORY)/vsnprintf.c
%.o: $(LIBBASE_DIRECTORY)/%.S
$(assemble)
crt0-$(CPU)-flash.o: $(LIBBASE_DIRECTORY)/crt0-$(CPU).S
$(CC) -c -DFLASH_DATA_SECTION $(CFLAGS) -o $@ $<
.PHONY: all clean
clean:
$(RM) $(OBJECTS) crt0-$(CPU).o vsnprintf.o vsnprintf-nofloat.o
$(RM) $(OBJECTS) crt0-$(CPU).o crt0-$(CPU)-flash.o vsnprintf.o vsnprintf-nofloat.o
$(RM) libbase.a libbase-nofloat.a .*~ *~

View File

@ -112,6 +112,25 @@ _crt0:
mvhi sp, hi(_fstack)
ori sp, sp, lo(_fstack)
#ifdef FLASH_DATA_SECTION
/* Load DATA */
mvhi r1, hi(_erodata)
ori r1, r1, lo(_erodata)
mvhi r2, hi(_fdata)
ori r2, r2, lo(_fdata)
mvhi r3, hi(_edata)
ori r3, r3, lo(_edata)
.moveDATA:
be r2, r3, .doBSS
lw r4, (r1+0)
sw (r2+0), r4
/* _edata is aligned to 16 bytes. Use word-xfers. */
addi r1, r1, 4
addi r2, r2, 4
bi .moveDATA
#endif
.doBSS:
/* Clear BSS */
mvhi r1, hi(_fbss)
ori r1, r1, lo(_fbss)