diff --git a/misoc/software/bios/Makefile b/misoc/software/bios/Makefile index 2da8a8d25..8c57907dd 100644 --- a/misoc/software/bios/Makefile +++ b/misoc/software/bios/Makefile @@ -12,8 +12,8 @@ all: bios.bin bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -%.elf: - $(LD) $(LDFLAGS) -T $< -N -o $@ \ +%.elf: ../libbase/crt0-$(CPU).o ../libnet/libnet.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a + $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-$(CPU).o \ $(OBJECTS) \ -L../libnet \ diff --git a/misoc/software/bios/boot.c b/misoc/software/bios/boot.c index f476a42de..a73e568be 100644 --- a/misoc/software/bios/boot.c +++ b/misoc/software/bios/boot.c @@ -18,7 +18,7 @@ extern void boot_helper(unsigned int r1, unsigned int r2, unsigned int r3, unsig static void __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr) { - printf("Executing booted program.\n"); + printf("Executing booted program at 0x%08x\n", addr); uart_sync(); irq_setmask(0); irq_setie(0); diff --git a/misoc/software/common.mak b/misoc/software/common.mak index 9ba59ccdc..7d09363df 100644 --- a/misoc/software/common.mak +++ b/misoc/software/common.mak @@ -44,7 +44,7 @@ endif # Toolchain options # INCLUDES = -I$(MISOC_DIRECTORY)/software/include/base -I$(MISOC_DIRECTORY)/software/include -I$(MISOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY) -COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -ffunction-sections -Wall -fno-builtin -nostdinc $(INCLUDES) +COMMONFLAGS = -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -ffunction-sections -Wall -fno-builtin -nostdinc $(INCLUDES) CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Werror=incompatible-pointer-types CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MISOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding LDFLAGS = --gc-sections -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY) diff --git a/misoc/software/libbase/crt0-or1k.S b/misoc/software/libbase/crt0-or1k.S index 5db4142af..ff77910dc 100644 --- a/misoc/software/libbase/crt0-or1k.S +++ b/misoc/software/libbase/crt0-or1k.S @@ -19,7 +19,18 @@ #include -#define EXCEPTION_STACK_SIZE (4*32) +/* + * OR1K Architecture has a 128 byte "red zone" after the stack that can not be + * touched by exception handlers. GCC uses this red zone for locals and + * temps without needing to change the stack pointer. + */ +#define OR1K_RED_ZONE_SIZE 128 + +/* + * We need 4 bytes (32 bits) * 32 registers space on the stack to save all the + * registers. + */ +#define EXCEPTION_STACK_SIZE ((4*32) + OR1K_RED_ZONE_SIZE) #define HANDLE_EXCEPTION ; \ l.addi r1, r1, -EXCEPTION_STACK_SIZE ; \