summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--atos/Makefile15
-rw-r--r--atos/arch/rv64/jh7110/Makefile28
-rw-r--r--atos/arch/rv64/jh7110/dev/link.ld32
-rw-r--r--atos/arch/rv64/jh7110/ke/head.S10
-rw-r--r--atos/boot/rv64/jh7110/Makefile11
-rwxr-xr-xbuild.sh66
-rw-r--r--dev/build.env9
-rw-r--r--mk/atos.mk39
9 files changed, 213 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5b89a7f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+*.d
+/out
diff --git a/atos/Makefile b/atos/Makefile
new file mode 100644
index 0000000..eea25c3
--- /dev/null
+++ b/atos/Makefile
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+.PHONY: all
+all: boot
+
+.PHONY: boot
+boot: machine
+ cd boot/$(CONFIG_ARCH)/$(CONFIG_CHIP); $(MAKE)
+
+.PHONY: machine
+machine:
+ cd arch/$(CONFIG_ARCH)/$(CONFIG_CHIP); $(MAKE)
diff --git a/atos/arch/rv64/jh7110/Makefile b/atos/arch/rv64/jh7110/Makefile
new file mode 100644
index 0000000..2e9f989
--- /dev/null
+++ b/atos/arch/rv64/jh7110/Makefile
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+include ../../../../mk/atos.mk
+
+ASMFILES = $(shell find . -name "*.S")
+ASMOFILES = $(ASMFILES:.S=.S.o)
+MISC_OFILES = $(shell find $(GLOBAL_ROOT)/atos -name "*.o")
+CFLAGS = $(INTERNAL_CFLAGS)
+
+KERNEL_ELF_OUT = $(GLOBAL_ROOT)/out/atos.sys
+KERNEL_BIN_OUT = $(GLOBAL_ROOT)/out/atos.bin
+
+.PHONY: all
+all: $(KERNEL_ELF_OUT)
+ $(PROMPT) "OBJCOPY" $(KERNEL_BIN_OUT)
+ $(OBJCOPY) -O binary $(KERNEL_ELF_OUT) $(KERNEL_BIN_OUT)
+
+.PHONY: $(KERNEL_ELF_OUT)
+$(KERNEL_ELF_OUT): $(ASMOFILES)
+ $(PROMPT) "LD" $(KERNEL_ELF_OUT)
+ $(LD) -Tdev/link.ld $(MISC_OFILES) -o $(KERNEL_ELF_OUT)
+
+%.S.o: %.S
+ $(PROMPT) "CC" $<
+ $(CC) -c $< $(CFLAGS) -o $@
diff --git a/atos/arch/rv64/jh7110/dev/link.ld b/atos/arch/rv64/jh7110/dev/link.ld
new file mode 100644
index 0000000..c425651
--- /dev/null
+++ b/atos/arch/rv64/jh7110/dev/link.ld
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2026, Apollo Telephone Laboratories.
+ * Provided under the BSD-3 clause.
+ */
+
+ENTRY(MdHartEntry)
+
+SECTIONS {
+ . = 0x42200000;
+
+ .text : {
+ *(.text .text.*)
+ }
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ .rodata : {
+ *(.rodata .rodata.*)
+ }
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ .data : {
+ *(.data .data.*)
+ }
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ .bss : {
+ *(.bss .bss.*)
+ }
+}
diff --git a/atos/arch/rv64/jh7110/ke/head.S b/atos/arch/rv64/jh7110/ke/head.S
new file mode 100644
index 0000000..bc4a5ae
--- /dev/null
+++ b/atos/arch/rv64/jh7110/ke/head.S
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2026, Apollo Telephone Laboratories.
+ * Provided under the BSD-3 clause.
+ */
+
+ .text
+ .globl MdHartEntry
+MdHartEntry:
+1: wfi
+ j 1b
diff --git a/atos/boot/rv64/jh7110/Makefile b/atos/boot/rv64/jh7110/Makefile
new file mode 100644
index 0000000..122fdba
--- /dev/null
+++ b/atos/boot/rv64/jh7110/Makefile
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+IMG_PATH = $(GLOBAL_ROOT)/out/cirrus.img
+
+.PHONY: all
+all:
+ mkfs.fat -C $(IMG_PATH) 4096
+ mcopy -i $(IMG_PATH) $(GLOBAL_ROOT)/out/atos.bin ::
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..b2d4f65
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+MAKE=make
+
+#
+# Check if all the dependencies are installed on the host
+# machine.
+#
+# $@: Dependencies installed on the machine
+#
+check_deps() {
+ for dep in $@
+ do
+ printf "Checking if $dep is installed... "
+ which $dep &>/dev/null
+ if [ $? -ne 0 ]
+ then
+ echo "no"
+ echo "fatal: Please install '$dep'!"
+ exit 1
+ fi
+ echo "yes"
+ done
+}
+
+#
+# Prepare the build environment
+#
+build_prepare() {
+ source dev/build.env
+
+ check_deps \
+ make \
+ clang \
+ rsync \
+ llvm-objcopy \
+ ld.lld
+}
+
+#
+# Build a directory
+#
+# $1: Directory to build
+# $2: Subsystem name
+#
+build_dir() {
+ pushd $1
+ echo "[*] Building $2..."
+ $MAKE
+ popd
+}
+
+build_run() {
+ mkdir -p out
+
+ build_dir \
+ atos \
+ "kernel"
+}
+
+build_prepare
+build_run
diff --git a/dev/build.env b/dev/build.env
new file mode 100644
index 0000000..1deb0b7
--- /dev/null
+++ b/dev/build.env
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+export GLOBAL_ROOT=$PWD
+export CONFIG_ARCH=rv64
+export CONFIG_CHIP=jh7110
+export CONFIG_BOOT_PROTO=machine
diff --git a/mk/atos.mk b/mk/atos.mk
new file mode 100644
index 0000000..fb5d98c
--- /dev/null
+++ b/mk/atos.mk
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+.SILENT:
+
+PROMPT = printf "%s\t\t%s\n"
+
+ifeq ($(CONFIG_ARCH),rv64)
+ CC_TARGET = riscv64-unknown-elf
+else
+ CC_TARGET =
+endif
+
+CC = \
+ clang
+LD = \
+ ld.lld
+OBJCOPY = \
+ llvm-objcopy
+
+INTERNAL_CFLAGS = \
+ -Wall \
+ -pedantic \
+ -MMD \
+ -nostdlib \
+ -nostdinc \
+ -ffreestanding \
+ -D_KERNEL \
+ -D_ARCH='"$(CONFIG_ARCH)"' \
+ -D_CHIP='"$(CONFIG_CHIP)"' \
+ -target $(CC_TARGET)
+
+ifeq ($(CONFIG_ARCH),rv64)
+ INTERNAL_CFLAGS += \
+ -mabi=lp64d \
+ -mcmodel=medany
+endif