Created
February 2, 2012 17:29
-
-
Save singpolyma/1724746 to your computer and use it in GitHub Desktop.
Bare-metal mod (%) with libgcc (not working)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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