Adds main.spark with build inclusion and execution.

This commit is contained in:
Felix Queißner 2015-10-07 13:45:07 +02:00
parent 0dec8fa14f
commit 2a5e3220d7
7 changed files with 59 additions and 87 deletions

27
Depfile
View file

@ -2,8 +2,8 @@
Artifact=kernel
TempDir=obj
SourceDir=asm src
AdditionalObjects=obj/main.o obj/firstcode.o
ExternalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/|*.o
AdditionalObjects=obj/main.o
ExternalObjects=conductance/|*.o
LexUseCpp
YaccUseCpp
@ -26,25 +26,18 @@ LDFLAGS=-g -m32 -nostdlib -fno-builtin -Tkernel.ld
--
obj/main.o: scripts/main.ts
obj/main.o: scripts/main.spark
/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/bin/spark \
scripts/main.spark \
obj/main.ca
objcopy -B i386 -I binary -O elf32-i386 \
scripts/main.ts obj/main.o
obj/main.ca obj/main.o
objcopy \
--redefine-sym _binary_scripts_main_ts_start=mainscript_start \
--redefine-sym _binary_scripts_main_ts_end=mainscript_end \
--redefine-sym _binary_scripts_main_ts_size=mainscript_size \
--redefine-sym _binary_obj_main_ca_start=mainscript_start \
--redefine-sym _binary_obj_main_ca_end=mainscript_end \
--redefine-sym _binary_obj_main_ca_size=mainscript_size \
obj/main.o
obj/firstcode.o: /home/felix/projects/Electronics/first-run.ca
cp /home/felix/projects/Electronics/first-run.ca obj/firstrun.ca
objcopy -B i386 -I binary -O elf32-i386 \
obj/firstrun.ca obj/firstcode.o
objcopy \
--redefine-sym _binary_obj_firstrun_ca_start=firstrun_start \
--redefine-sym _binary_obj_firstrun_ca_end=firstrun_end \
--redefine-sym _binary_obj_firstrun_ca_size=firstrun_size \
obj/firstcode.o
.PHONY: run
run:
qemu-system-i386 -serial stdio -kernel kernel

View file

@ -13,7 +13,7 @@ YACC = bison
SRCS_AS = asm/dynamic.S asm/intr_common_handler.S asm/multiboot.S asm/start.S
SRCS_CC = src/console.c src/init.c src/interrupts.c src/malloc.c src/pmm.c src/serial.c src/stdlib.c src/timer.c src/vmm.c
SRCS_CXX = src/cplusplus.cpp src/cpp-test.cpp src/vm.cpp
OBJS = obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o obj/firstcode.o
OBJS = obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o
# Flags
FLAGS = -m32 -DCIRCUIT_OS -Dnullptr=0 -D__cdecl="__attribute__((cdecl))" -mno-sse -mno-sse2 -mno-mmx -I/home/felix/projects/Electronics/Electronics/Conductance -I/home/felix/projects/Electronics/Electronics/Tools
@ -27,10 +27,10 @@ all: kernel
.PHONY: clean
clean:
$(RM) obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o obj/firstcode.o
$(RM) obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o
kernel: obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o obj/firstcode.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/opcodes.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmpointertype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o
$(LD) $(FLAGS) $(LDFLAGS) -o $@ obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o obj/firstcode.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/opcodes.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmpointertype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o
kernel: obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o conductance/assembly.o conductance/compoundtype.o conductance/opcodes.o conductance/string.o conductance/virtualmachine.o conductance/vmpointertype.o conductance/vmprimitivetype.o conductance/vmtype.o conductance/vmvalue.o conductance/vmvoidtype.o
$(LD) $(FLAGS) $(LDFLAGS) -o $@ obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/cpp-test.o obj/vm.o obj/main.o conductance/assembly.o conductance/compoundtype.o conductance/opcodes.o conductance/string.o conductance/virtualmachine.o conductance/vmpointertype.o conductance/vmprimitivetype.o conductance/vmtype.o conductance/vmvalue.o conductance/vmvoidtype.o
# src/console.c
obj/console.o: src/console.c include/console.h include/kstdlib.h \
@ -117,25 +117,18 @@ obj/start.o: asm/start.S
# Custom Targets
obj/main.o: scripts/main.ts
obj/main.o: scripts/main.spark
/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/bin/spark \
scripts/main.spark \
obj/main.ca
objcopy -B i386 -I binary -O elf32-i386 \
scripts/main.ts obj/main.o
obj/main.ca obj/main.o
objcopy \
--redefine-sym _binary_scripts_main_ts_start=mainscript_start \
--redefine-sym _binary_scripts_main_ts_end=mainscript_end \
--redefine-sym _binary_scripts_main_ts_size=mainscript_size \
--redefine-sym _binary_obj_main_ca_start=mainscript_start \
--redefine-sym _binary_obj_main_ca_end=mainscript_end \
--redefine-sym _binary_obj_main_ca_size=mainscript_size \
obj/main.o
obj/firstcode.o: /home/felix/projects/Electronics/first-run.ca
cp /home/felix/projects/Electronics/first-run.ca obj/firstrun.ca
objcopy -B i386 -I binary -O elf32-i386 \
obj/firstrun.ca obj/firstcode.o
objcopy \
--redefine-sym _binary_obj_firstrun_ca_start=firstrun_start \
--redefine-sym _binary_obj_firstrun_ca_end=firstrun_end \
--redefine-sym _binary_obj_firstrun_ca_size=firstrun_size \
obj/firstcode.o
.PHONY: run
run:
qemu-system-i386 -serial stdio -kernel kernel

29
scripts/main.spark Normal file
View file

@ -0,0 +1,29 @@
.name OS
.author "Felix Queißner"
.descr "The main file of the operating system"
main:
pushi 0
pusht "Hello World from Conductance!\n"
calln print 1
_loop:
load 0
pushi 5
comp_less
jmp_if_not _end
load 0
pushi 1
add
store 0
pusht "counter: "
load 0
pusht "\n"
calln print 3
jmp _loop
_end:
ret

View file

@ -1,45 +0,0 @@
VAR global : INT;
OBJ timer : "/sys/timer";
OBJ console : "/sys/console";
VAR ptr : PTR(INT);
VAR pptr : PTR(PTR(INT));
PUB main() | i : INT, str : TEXT
BEGIN
0 -> i;
# Testing pointer referencing / dereferencing as rvalue
15 -> global;
REF(global) -> ptr;
console.printInt(VAL(ptr));
# Testing lvalue pointer assignment
REF(global) -> ptr;
25 -> VAL(ptr);
console.printInt(global);
# Testing double pointers
REF(ptr) -> pptr;
35 -> VAL(VAL(pptr));
console.printInt(global);
"Hello " -> str;
console.printStr(str + "World!");
WHILE ((i + 1) -> i) <= fun() DO
BEGIN
hlp(i, fun() - i);
timer.sleep(2);
END
END
PRI hlp(i : INT, j : INT)
BEGIN
console.print2Int(i, j);
END
PUB fun() -> i : INT
BEGIN
5 -> i;
END

View file

@ -208,6 +208,8 @@ void init(const MultibootStructure *mbHeader)
timer_add_callback(1, update_statusbar);
kputs("\n");
vm_start();
irq_disable();

View file

@ -69,15 +69,15 @@ void code()
struct {
const char *ptr;
uint32_t size;
} firstrun {
&firstrun_start,
(uint32_t)&firstrun_size
} mainAssembly {
&mainscript_start,
(uint32_t)&mainscript_size
};
VirtualMachine vm;
vm.import("print") = printArguments;
Assembly *assembly = vm.load(firstrun.ptr, firstrun.size);
Assembly *assembly = vm.load(mainAssembly.ptr, mainAssembly.size);
if(assembly == nullptr) {
kprintf("failed to load assembly :(\n");
return;

View file

@ -50,9 +50,9 @@ DISTFILES += \
kernel.ld \
Depfile \
Makefile.new \
scripts/main.ts \
asm/dynamic.S \
README.md
README.md \
scripts/main.spark
INCLUDEPATH += $$quote("/home/felix/projects/Electronics/Electronics/Conductance")
DEPENDPATH += $$quote("/home/felix/projects/Electronics/Electronics/Conductance")