Skip to content

Instantly share code, notes, and snippets.

@singpolyma
Created February 2, 2012 17:29
Show Gist options
  • Save singpolyma/1724746 to your computer and use it in GitHub Desktop.
Save singpolyma/1724746 to your computer and use it in GitHub Desktop.
Bare-metal mod (%) with libgcc (not working)
/* We need to set up the stack pointer before C code can run
This memory address is the end of the on-board 128MB of
RAM for QEMU versatilepb */
.global _start
_start:
ldr sp, =0x07FFFFFF
bl main
#define UART0 ((volatile unsigned int*)0x101f1000)
int main(void) {
unsigned int task_count = 0;
unsigned int current_task = 1;
task_count = 2;
current_task = (current_task + 1) % task_count; /* This line causes the emulator to hang */
*UART0 = current_task;
*UART0 = 0;
*UART0 = 0;
*UART0 = 0;
*UART0 = 0;
while(1);
return 0;
}
CC=arm-linux-gnueabi-gcc
LD=arm-linux-gnueabi-ld
CFLAGS=-ansi -pedantic -Wall -Wextra -march=armv6 -msoft-float -fPIC -mapcs-frame -marm
LDFLAGS=-N -Ttext=0x10000 -L/usr/lib/gcc/arm-linux-gnueabi/4.6.1/
kernel.elf: bootstrap.o kernel.o
.PHONY: clean
clean:
$(RM) *.elf *.o
.SUFFIXES: .s .o .elf
.s.o:
$(CC) $(CFLAGS) -o $@ -c $^
.o.elf:
$(LD) $(LDFLAGS) -o $@ $^ -'(' -lgcc -lgcc_eh -lc -')'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment