add first pypowersim example
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 12:27:53 +0000 (13:27 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 12:27:53 +0000 (13:27 +0100)
src/test/basic_pypowersim/Makefile [new file with mode: 0644]
src/test/basic_pypowersim/memmap [new file with mode: 0644]
src/test/basic_pypowersim/test.s [new file with mode: 0644]

diff --git a/src/test/basic_pypowersim/Makefile b/src/test/basic_pypowersim/Makefile
new file mode 100644 (file)
index 0000000..f3ddf21
--- /dev/null
@@ -0,0 +1,21 @@
+TOOLCHAIN=powerpc64-linux-gnu
+CC=$(TOOLCHAIN)-gcc
+AS=$(TOOLCHAIN)-as
+AFLAGS=-mpwr9
+
+all: sim
+
+sim: kernel.bin
+       pypowersim -i kernel.bin
+
+clean:
+       rm *.o *.elf *.bin
+
+kernel.elf: test.o
+       $(TOOLCHAIN)-ld $^ -EL -o $@ -T memmap
+
+kernel.bin: kernel.elf
+       $(TOOLCHAIN)-objcopy $< -I elf64-little -O binary $@
+
+%.o: %.s
+       $(AS) $(AFLAGS) -c $< -le -o $@
diff --git a/src/test/basic_pypowersim/memmap b/src/test/basic_pypowersim/memmap
new file mode 100644 (file)
index 0000000..8cc1a16
--- /dev/null
@@ -0,0 +1,11 @@
+
+MEMORY
+{
+    ram  : ORIGIN = 0x20000000, LENGTH = 128M
+}
+
+SECTIONS
+{
+   .text : { *(.text*) } > ram
+   .bss  : { *(.text*) } > ram
+}
diff --git a/src/test/basic_pypowersim/test.s b/src/test/basic_pypowersim/test.s
new file mode 100644 (file)
index 0000000..fb2ec15
--- /dev/null
@@ -0,0 +1,6 @@
+       lis 1, 0xdead
+       ori 1, 1, 0xbeef
+       lis 2, 0x2000
+       ori 2, 2, 0x0100
+       std 1, 0(2)
+       lhz 1, 4(2)