Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bunch of small fixes #56

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions misoc/software/bios/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be merged with the bios.elf rule?

$(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \
../libbase/crt0-$(CPU).o \
$(OBJECTS) \
-L../libnet \
Expand Down
2 changes: 1 addition & 1 deletion misoc/software/bios/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion misoc/software/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion misoc/software/libbase/crt0-or1k.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@

#include <spr-defs.h>

#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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just GCC, any ABI-compliant compiler (e.g. Clang) can use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change this to The red zone is generally used for ......?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The red zone is used for". That's its only purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, technically you could use it for anything your heart desires... Maybe I should just remove the The red zone is used for bit and just have a link to the wikipedia article at https://en.wikipedia.org/wiki/Red_zone_(computing) ?

* 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 ; \
Expand Down