aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/conf
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-01-06 23:39:12 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-01-07 14:05:06 +0200
commit9cc125fb3cfdc2c8ae7153b5ae0fe705980835fb (patch)
treea1974f9513458acab0bd8d09758259b24b6d7d8c /arch/riscv64/conf
parentf0eba93472e0afecc57180fc0d638eeef8e6f3c6 (diff)
downloadkmi-9cc125fb3cfdc2c8ae7153b5ae0fe705980835fb.tar.gz
kmi-9cc125fb3cfdc2c8ae7153b5ae0fe705980835fb.zip
Allow building with clang
+ Release mode is sort of broken, as lto doesn't work with linker relaxation and turning the relaxation off causes issues with the jump from init to kernel (as I've currently implemented it, could probably be fixed with a manual jump from assembly, I'll add it to my TODO list)
Diffstat (limited to 'arch/riscv64/conf')
-rw-r--r--arch/riscv64/conf/apos.its48
-rw-r--r--arch/riscv64/conf/boot.cmd4
-rwxr-xr-xarch/riscv64/conf/initbin0 -> 968 bytes
-rw-r--r--arch/riscv64/conf/init-link.S31
-rw-r--r--arch/riscv64/conf/initrdbin0 -> 1536 bytes
-rw-r--r--arch/riscv64/conf/kernel-link.S26
-rwxr-xr-xarch/riscv64/conf/mkimage.sh31
-rwxr-xr-xarch/riscv64/conf/rmimage.sh9
-rw-r--r--arch/riscv64/conf/rootfs.fd9
-rw-r--r--arch/riscv64/conf/s.S4
10 files changed, 162 insertions, 0 deletions
diff --git a/arch/riscv64/conf/apos.its b/arch/riscv64/conf/apos.its
new file mode 100644
index 0000000..da48860
--- /dev/null
+++ b/arch/riscv64/conf/apos.its
@@ -0,0 +1,48 @@
+/dts-v1/;
+
+/ {
+ description = "FUCK";
+#address-cells = <1>;
+
+ images {
+ kernel {
+ description = "Garbaggio";
+ data = /incbin/("../../../apos.bin");
+ type = "kernel";
+ arch = "riscv";
+ os = "apos";
+ compression = "none";
+ load = <0x80080000>;
+ entry = <0x80080000>;
+ hash-1 {
+ algo = "sha1";
+ };
+ };
+
+ initrd {
+ description = "Gargabbio initrd";
+ data = /incbin/("initrd");
+ type = "ramdisk";
+ arch = "riscv";
+ os = "apos";
+ compression = "none";
+ load = <0x88300000>;
+ hash-1 {
+ algo = "sha1";
+ };
+ };
+ };
+
+ configurations {
+ default = "config";
+
+ config {
+ description = "Default configuration";
+ kernel = "kernel";
+ ramdisk = "initrd";
+ hash-1 {
+ algo = "sha1";
+ };
+ };
+ };
+};
diff --git a/arch/riscv64/conf/boot.cmd b/arch/riscv64/conf/boot.cmd
new file mode 100644
index 0000000..a7517fd
--- /dev/null
+++ b/arch/riscv64/conf/boot.cmd
@@ -0,0 +1,4 @@
+fdt move ${fdt_addr} ${fdt_addr_r}
+fdt addr ${fdt_addr_r}
+load ${devtype} ${devnum} ${kernel_addr_r} apos.itb
+bootm ${kernel_addr_r} ${kernel_addr_r} ${fdt_addr_r}
diff --git a/arch/riscv64/conf/init b/arch/riscv64/conf/init
new file mode 100755
index 0000000..f05254f
--- /dev/null
+++ b/arch/riscv64/conf/init
Binary files differ
diff --git a/arch/riscv64/conf/init-link.S b/arch/riscv64/conf/init-link.S
new file mode 100644
index 0000000..baabcc6
--- /dev/null
+++ b/arch/riscv64/conf/init-link.S
@@ -0,0 +1,31 @@
+OUTPUT_ARCH(riscv)
+ENTRY(_start)
+
+SECTIONS {
+ . = ABSOLUTE(PM_KERN_BASE);
+ __init_start = .;
+
+ /* objcopy only copies these three sections (as far as I'm aware) into the
+ produces binary, so __init_end should point to the correct location in the
+ final binary
+ */
+ .text ALIGN(4K) : AT(0) {
+ *(.init.start)
+ *(.text*);
+ }
+
+ .rodata : {
+ *(.rodata*)
+ }
+
+ .data : {
+ *(.data*)
+ }
+
+ .bss : {
+ *(.sbss*) *(.bss*) *(COMMON)
+ }
+
+ __init_end = . ;
+ __kernel_size = <KERNEL_SIZE>;
+}
diff --git a/arch/riscv64/conf/initrd b/arch/riscv64/conf/initrd
new file mode 100644
index 0000000..90344c1
--- /dev/null
+++ b/arch/riscv64/conf/initrd
Binary files differ
diff --git a/arch/riscv64/conf/kernel-link.S b/arch/riscv64/conf/kernel-link.S
new file mode 100644
index 0000000..c6a910a
--- /dev/null
+++ b/arch/riscv64/conf/kernel-link.S
@@ -0,0 +1,26 @@
+OUTPUT_ARCH(riscv)
+ENTRY(main)
+
+SECTIONS {
+ . = ABSOLUTE(VM_KERN);
+ __kernel_start = .;
+
+ .text ALIGN(4K) : AT(0) {
+ *(.kernel.start);
+ *(.text*);
+ }
+
+ .rodata : {
+ *(.rodata*)
+ }
+
+ .data : {
+ *(.data*)
+ }
+
+ .bss : {
+ *(.sbss*) *(.bss*) *(COMMON)
+ }
+
+ __kernel_end = .;
+}
diff --git a/arch/riscv64/conf/mkimage.sh b/arch/riscv64/conf/mkimage.sh
new file mode 100755
index 0000000..d097248
--- /dev/null
+++ b/arch/riscv64/conf/mkimage.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+if [ ! -e fs ]; then
+ mkdir fs
+fi
+
+if [ ! -e rootfs.img ]; then
+ virt-make-fs --partition=mbr --type=vfat --size=10M fs rootfs.img
+fi
+
+
+SSIZE=$(fdisk -l rootfs.img | awk '$1=="Units:" {print $8}')
+OFFSET=$(fdisk -l rootfs.img | awk '$1=="rootfs.img1" {print $2}')
+mount -o loop,offset=$((${SSIZE}*${OFFSET})) rootfs.img fs
+
+# not entirely pleased with this solution, although eventually I should probably
+# move `run` out of the kernel repo and into some `aposos` repo with a runtime
+# and proper initrd etc. so this is good enough for now
+../u-boot-apos/tools/mkimage -f arch/riscv64/conf/apos.its fs/apos.itb
+../u-boot-apos/tools/mkimage -A riscv -O apos -T script \
+ -d arch/riscv64/conf/boot.cmd fs/boot.scr
+
+umount -l fs
+
+qemu-system-riscv64 -machine virt \
+ -kernel ../u-boot-apos/u-boot \
+ -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
+ -device virtio-blk-device,drive=hd0 \
+ -drive file=rootfs.img,format=raw,id=hd0 \
+ -S -s -m 2G \
+ -serial stdio
diff --git a/arch/riscv64/conf/rmimage.sh b/arch/riscv64/conf/rmimage.sh
new file mode 100755
index 0000000..8d6457f
--- /dev/null
+++ b/arch/riscv64/conf/rmimage.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -e fs ]; then
+ rm -r fs
+fi
+
+if [ -e rootfs.img ]; then
+ rm rootfs.img
+fi
diff --git a/arch/riscv64/conf/rootfs.fd b/arch/riscv64/conf/rootfs.fd
new file mode 100644
index 0000000..59fb5f8
--- /dev/null
+++ b/arch/riscv64/conf/rootfs.fd
@@ -0,0 +1,9 @@
+label: gpt
+label-id: DBD1F99F-BFA3-D448-828F-0B505DF81F17
+device: rootfs.img
+unit: sectors
+first-lba: 2048
+last-lba: 20446
+sector-size: 512
+
+rootfs.img1 : start= 2048, size= 18399, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=B129DB0D-F225-5C48-AA6D-DD8C049FA72C
diff --git a/arch/riscv64/conf/s.S b/arch/riscv64/conf/s.S
new file mode 100644
index 0000000..80a3a11
--- /dev/null
+++ b/arch/riscv64/conf/s.S
@@ -0,0 +1,4 @@
+.text
+.global _start
+_start:
+ecall