aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXander <xander@icth.xyz>2023-06-30 13:54:27 +0200
committerXander <xander@icth.xyz>2023-06-30 13:54:27 +0200
commit560ab0ba6eb33d17df889e4fb1536cbaff6cba49 (patch)
tree863de08b1bc4cd3b1fda887afbd924fea07d0069
parentc5bd05fa070d25ae6700660347bdb59ae84390e6 (diff)
downloadats-os-560ab0ba6eb33d17df889e4fb1536cbaff6cba49.tar.xz
ats-os-560ab0ba6eb33d17df889e4fb1536cbaff6cba49.zip
Calling ats function
-rw-r--r--Makefile30
-rw-r--r--flake.nix2
-rw-r--r--kernel/main.c4
-rw-r--r--kernel/main.dats13
-rw-r--r--main_dats.c5
5 files changed, 42 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 02592c9..4ee4e14 100644
--- a/Makefile
+++ b/Makefile
@@ -8,9 +8,21 @@ assembly_source_files := $(wildcard arch/$(arch)/boot/*.asm)
assembly_object_files := $(patsubst arch/$(arch)/boot/%.asm, \
build/arch/$(arch)/%.o, $(assembly_source_files))
-c_source_files := $(wildcard kernel/*.c)
-c_object_files := $(patsubst kernel/%.c, \
- build/kernel/%.o, $(c_source_files))
+dats_source_files := $(wildcard kernel/*.dats)
+dats_object_files := $(patsubst kernel/%.dats, \
+ build/kernel/%_dats.o, $(dats_source_files))
+
+PATSCC=patscc
+
+INCLUDE_ATS :=
+INCLUDE_ATS += -I${PATSHOME}
+INCLUDE_ATS += -I${PATSHOME}/ccomp/runtime
+
+CLFAGS_ATS :=
+CFLAGS_ATS += -D_ATS_CCOMP_RUNTIME_NONE_
+CFLAGS_ATS += -D_ATS_CCOMP_EXCEPTION_NONE_
+
+CFLAGS=-ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -m64
.PHONY: all clean run iso
@@ -31,15 +43,19 @@ $(iso): $(kernel) $(grub_cfg)
@grub-mkrescue -o $(iso) build/isofiles 2> /dev/null
@rm -r build/isofiles
-$(kernel): $(assembly_object_files) $(linker_script) $(c_object_files)
- @ld -n -T $(linker_script) -o $(kernel) $(assembly_object_files) $(c_object_files) -nostdlib -z noexecstack
+$(kernel): $(assembly_object_files) $(linker_script) $(dats_object_files)
+ @ld -n -T $(linker_script) -o $(kernel) $(assembly_object_files) $(dats_object_files) -nostdlib -z noexecstack
# compile assembly files
build/arch/$(arch)/%.o: arch/$(arch)/boot/%.asm
@mkdir -p $(shell dirname $@)
@nasm -felf64 $< -o $@
-build/kernel/%.o: kernel/%.c
+build/kernel/%_dats.c: $(dats_source_files)
@mkdir -p $(shell dirname $@)
- @gcc -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -m64 -c $< -o $@
+ $(PATSCC) -ccats - $<
+ @mv *_dats.c build/kernel/
+build/kernel/%.o: build/kernel/%.c
+ @mkdir -p $(shell dirname $@)
+ $(CC) $(INCLUDE_ATS) $(CFLAGS) $(CFLAGS_ATS) -O2 -c $< -o $@
diff --git a/flake.nix b/flake.nix
index 4eb04cd..6a36124 100644
--- a/flake.nix
+++ b/flake.nix
@@ -13,7 +13,7 @@
in
{
devShells.default = pkgs.mkShell {
- packages = with pkgs; [ nasm grub2 ];
+ packages = with pkgs; [ nasm grub2 ats2 ];
buildInputs = with pkgs; [ libisoburn ];
};
});
diff --git a/kernel/main.c b/kernel/main.c
deleted file mode 100644
index 6de1868..0000000
--- a/kernel/main.c
+++ /dev/null
@@ -1,4 +0,0 @@
-
-void test(double a) {}
-int main() { test(3.0); }
-
diff --git a/kernel/main.dats b/kernel/main.dats
new file mode 100644
index 0000000..1eb7813
--- /dev/null
+++ b/kernel/main.dats
@@ -0,0 +1,13 @@
+#include "share/atspre_staload.hats"
+
+typedef test = @{test2 = uint8}
+
+extern castfn uint8_of {n: nat} (i: int n): uint8 n
+
+implement main0 () =
+let
+ val t = @{test2 = uint8_of(4)} : test
+in
+ main0 ()
+end
+
diff --git a/main_dats.c b/main_dats.c
new file mode 100644
index 0000000..c334a63
--- /dev/null
+++ b/main_dats.c
@@ -0,0 +1,5 @@
+/* ****** ****** */
+//
+#error(PATSOPT_ERROR_(patsopt(kernel/main.dats): trans3-errors))
+//
+/* ****** ****** */