Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit bb8079a5990f0762c0d16b1726a5a1d25b05de0a @rasendubi committed Sep 27, 2015
Showing with 58 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +29 −0 Makefile
  3. +5 −0 bootstrap.s
  4. +9 −0 kernel.nim
  5. +12 −0 panicoverride.nim
@@ -0,0 +1,3 @@
+/*.o
+/nimcache
+/kernel.elf
@@ -0,0 +1,29 @@
+CC := arm-none-eabi-gcc
+LD := arm-none-eabi-ld
+NIM := nim
+
+CFLAGS := -std=c99 -pedantic -Wall -Wextra -march=armv6 -msoft-float \
+ -fPIC -mapcs-frame -ffreestanding
+LDFLAGS := -N -Ttext=0x10000 -nostdlib
+NIMFLAGS := --parallelBuild:1 --deadCodeElim:on --gcc.exe:$(CC) \
+ --noMain --noLinking --gc:none --cpu:arm --os:standalone \
+ --passC:\"$(CFLAGS)\"
+
+QEMU ?= qemu-system-arm
+
+kernel.elf: bootstrap.o nimcache/kernel.o nimcache/stdlib_system.o
+ $(LD) $(LDFLAGS) -o $@ $^
+
+%.o: %.s
+ $(CC) $(CFLAGS) -o $@ -c $^
+
+nimcache/%.o: %.nim
+ $(NIM) $(NIMFLAGS) c $^
+
+.PHONY: clean
+clean:
+ rm -rf *.o nimcache
+
+.PHONY: run
+run: kernel.elf
+ $(QEMU) -M versatilepb -cpu arm1176 -nographic -kernel kernel.elf
@@ -0,0 +1,5 @@
+
+.global _start
+_start:
+ ldr sp, =0x07FFFFFF
+ bl main
@@ -0,0 +1,9 @@
+
+proc main() {.exportc.} =
+ var o {.volatile.}: ptr[char] = cast[ptr[char]](0x101f1000)
+ var str: cstring = "Hello, world!"
+ for i in str:
+ o[] = i
+
+ while true:
+ discard
@@ -0,0 +1,12 @@
+{.push stack_trace: off, profiler:off.}
+
+proc rawoutput(s: string) =
+ var o {.volatile.} = cast[ptr[char]](0x101f1000)
+ for i in s:
+ o[] = i
+
+proc panic(s: string) =
+ while true:
+ discard
+
+{.pop.}

0 comments on commit bb8079a

Please sign in to comment.