Integrates conductance into CircuitOS. Adds loading of assembly file with code execution. Fixes bugs everywhere (including evil memory leak in Vector<>::resize.
This commit is contained in:
parent
a9aa739757
commit
cdfb67af82
17 changed files with 285 additions and 49 deletions
15
Depfile
15
Depfile
|
@ -2,7 +2,7 @@
|
||||||
Artifact=kernel
|
Artifact=kernel
|
||||||
TempDir=obj
|
TempDir=obj
|
||||||
SourceDir=asm src
|
SourceDir=asm src
|
||||||
AdditionalObjects=obj/main.o
|
AdditionalObjects=obj/main.o obj/firstcode.o
|
||||||
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o
|
||||||
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o
|
||||||
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o
|
||||||
|
@ -10,6 +10,7 @@ AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Deb
|
||||||
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o
|
||||||
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o
|
||||||
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o
|
||||||
|
AdditionalObjects=/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.o
|
||||||
|
|
||||||
LexUseCpp
|
LexUseCpp
|
||||||
YaccUseCpp
|
YaccUseCpp
|
||||||
|
@ -28,9 +29,10 @@ FLAGS=-m32 -DCONDUCTANCE_64BIT -DCIRCUIT_OS -Dnullptr=0 -D__cdecl="__attribute__
|
||||||
ASFLAGS=-masm=intel
|
ASFLAGS=-masm=intel
|
||||||
CCFLAGS=-g -std=c11 -Dnullptr=0 -Wall -g -fno-stack-protector -ffreestanding -Iinclude
|
CCFLAGS=-g -std=c11 -Dnullptr=0 -Wall -g -fno-stack-protector -ffreestanding -Iinclude
|
||||||
CXXFLAGS=-g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude
|
CXXFLAGS=-g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude
|
||||||
LDFLAGS=-g -m32 -nostdlib -fno-builtin -Tkernel.ld -L/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/ -lConductance
|
LDFLAGS=-g -m32 -nostdlib -fno-builtin -Tkernel.ld
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
obj/main.o: scripts/main.ts
|
obj/main.o: scripts/main.ts
|
||||||
objcopy -B i386 -I binary -O elf32-i386 \
|
objcopy -B i386 -I binary -O elf32-i386 \
|
||||||
scripts/main.ts obj/main.o
|
scripts/main.ts obj/main.o
|
||||||
|
@ -40,6 +42,15 @@ obj/main.o: scripts/main.ts
|
||||||
--redefine-sym _binary_scripts_main_ts_size=mainscript_size \
|
--redefine-sym _binary_scripts_main_ts_size=mainscript_size \
|
||||||
obj/main.o
|
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
|
.PHONY: run
|
||||||
run:
|
run:
|
||||||
|
|
47
Makefile
47
Makefile
|
@ -13,32 +13,32 @@ YACC = bison
|
||||||
SRCS_AS = asm/dynamic.S asm/intr_common_handler.S asm/multiboot.S asm/start.S
|
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_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
|
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 /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.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 obj/firstcode.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.o
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
FLAGS = -m32 -DCONDUCTANCE_64BIT -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
|
FLAGS = -m32 -DCONDUCTANCE_64BIT -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
|
||||||
ASFLAGS = -masm=intel
|
ASFLAGS = -masm=intel
|
||||||
CCFLAGS = -g -std=c11 -Dnullptr=0 -Wall -g -fno-stack-protector -ffreestanding -Iinclude
|
CCFLAGS = -g -std=c11 -Dnullptr=0 -Wall -g -fno-stack-protector -ffreestanding -Iinclude
|
||||||
CXXFLAGS = -g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude
|
CXXFLAGS = -g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude
|
||||||
LDFLAGS = -g -m32 -nostdlib -fno-builtin -Tkernel.ld -L/home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/ -lConductance
|
LDFLAGS = -g -m32 -nostdlib -fno-builtin -Tkernel.ld
|
||||||
|
|
||||||
# Targets
|
# Targets
|
||||||
all: kernel
|
all: kernel
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
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 /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.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 obj/firstcode.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.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 /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.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 obj/firstcode.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.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 /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.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/virtualmachine.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/assembly.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvalue.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmprimitivetype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/compoundtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/vmvoidtype.o /home/felix/projects/Electronics/build-Electronics-Desktop-Debug/Conductance/string.o
|
||||||
|
|
||||||
# src/console.c
|
# src/console.c
|
||||||
obj/console.o: src/console.c include/console.h include/stdlib.h \
|
obj/console.o: src/console.c include/console.h include/kstdlib.h \
|
||||||
include/varargs.h include/config.h include/malloc.h
|
include/varargs.h include/config.h include/malloc.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/console.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/console.c
|
||||||
|
|
||||||
# src/init.c
|
# src/init.c
|
||||||
obj/init.o: src/init.c include/kernel.h include/stdlib.h include/varargs.h \
|
obj/init.o: src/init.c include/kernel.h include/kstdlib.h include/varargs.h \
|
||||||
include/config.h include/malloc.h include/console.h include/interrupts.h \
|
include/config.h include/malloc.h include/console.h include/interrupts.h \
|
||||||
include/cpustate.h include/pmm.h include/multiboot.h include/vmm.h \
|
include/cpustate.h include/pmm.h include/multiboot.h include/vmm.h \
|
||||||
include/timer.h include/serial.h
|
include/timer.h include/serial.h
|
||||||
|
@ -46,29 +46,29 @@ obj/init.o: src/init.c include/kernel.h include/stdlib.h include/varargs.h \
|
||||||
|
|
||||||
# src/interrupts.c
|
# src/interrupts.c
|
||||||
obj/interrupts.o: src/interrupts.c include/interrupts.h include/cpustate.h \
|
obj/interrupts.o: src/interrupts.c include/interrupts.h include/cpustate.h \
|
||||||
include/console.h include/stdlib.h include/varargs.h include/config.h \
|
include/console.h include/kstdlib.h include/varargs.h include/config.h \
|
||||||
include/malloc.h include/io.h src/intr_stubs.h
|
include/malloc.h include/io.h src/intr_stubs.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/interrupts.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/interrupts.c
|
||||||
|
|
||||||
# src/malloc.c
|
# src/malloc.c
|
||||||
obj/malloc.o: src/malloc.c include/kernel.h include/stdlib.h \
|
obj/malloc.o: src/malloc.c include/config.h include/kernel.h \
|
||||||
include/varargs.h include/config.h include/malloc.h include/console.h \
|
include/kstdlib.h include/varargs.h include/malloc.h include/console.h \
|
||||||
include/serial.h
|
include/serial.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/malloc.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/malloc.c
|
||||||
|
|
||||||
# src/pmm.c
|
# src/pmm.c
|
||||||
obj/pmm.o: src/pmm.c include/pmm.h include/multiboot.h include/kernel.h \
|
obj/pmm.o: src/pmm.c include/pmm.h include/multiboot.h include/kernel.h \
|
||||||
include/stdlib.h include/varargs.h include/config.h include/malloc.h \
|
include/kstdlib.h include/varargs.h include/config.h include/malloc.h \
|
||||||
include/console.h
|
include/console.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/pmm.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/pmm.c
|
||||||
|
|
||||||
# src/serial.c
|
# src/serial.c
|
||||||
obj/serial.o: src/serial.c include/io.h include/serial.h include/stdlib.h \
|
obj/serial.o: src/serial.c include/io.h include/serial.h include/kstdlib.h \
|
||||||
include/varargs.h include/config.h include/malloc.h
|
include/varargs.h include/config.h include/malloc.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/serial.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/serial.c
|
||||||
|
|
||||||
# src/stdlib.c
|
# src/stdlib.c
|
||||||
obj/stdlib.o: src/stdlib.c include/stdlib.h include/varargs.h \
|
obj/stdlib.o: src/stdlib.c include/kstdlib.h include/varargs.h \
|
||||||
include/config.h include/malloc.h include/kernel.h
|
include/config.h include/malloc.h include/kernel.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/stdlib.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/stdlib.c
|
||||||
|
|
||||||
|
@ -79,24 +79,23 @@ obj/timer.o: src/timer.c include/timer.h include/kernel.h \
|
||||||
|
|
||||||
# src/vmm.c
|
# src/vmm.c
|
||||||
obj/vmm.o: src/vmm.c include/config.h include/vmm.h include/pmm.h \
|
obj/vmm.o: src/vmm.c include/config.h include/vmm.h include/pmm.h \
|
||||||
include/multiboot.h include/stdlib.h include/varargs.h include/malloc.h \
|
include/multiboot.h include/kstdlib.h include/varargs.h include/malloc.h \
|
||||||
include/console.h include/kernel.h
|
include/console.h include/kernel.h
|
||||||
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/vmm.c
|
$(CC) $(FLAGS) $(CCFLAGS) -o $@ -c src/vmm.c
|
||||||
|
|
||||||
# src/cplusplus.cpp
|
# src/cplusplus.cpp
|
||||||
obj/cplusplus.o: src/cplusplus.cpp include/stdlib.h include/varargs.h \
|
obj/cplusplus.o: src/cplusplus.cpp include/kstdlib.h include/varargs.h \
|
||||||
include/config.h include/malloc.h include/console.h include/ker/new.hpp
|
include/config.h include/malloc.h include/console.h include/ker/new.hpp
|
||||||
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ -c src/cplusplus.cpp
|
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ -c src/cplusplus.cpp
|
||||||
|
|
||||||
# src/cpp-test.cpp
|
# src/cpp-test.cpp
|
||||||
obj/cpp-test.o: src/cpp-test.cpp include/console.h include/ker/string.hpp \
|
obj/cpp-test.o: src/cpp-test.cpp include/console.h include/ker/string.hpp \
|
||||||
include/stdlib.h include/varargs.h include/config.h include/malloc.h \
|
include/ker/vector.hpp include/ker/dictionary.hpp include/kernel.h \
|
||||||
include/string.h include/ker/vector.hpp include/ker/new.hpp \
|
include/ker/pair.hpp
|
||||||
include/ker/dictionary.hpp include/kernel.h include/ker/pair.hpp
|
|
||||||
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ -c src/cpp-test.cpp
|
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ -c src/cpp-test.cpp
|
||||||
|
|
||||||
# src/vm.cpp
|
# src/vm.cpp
|
||||||
obj/vm.o: src/vm.cpp include/stdlib.h include/varargs.h include/config.h \
|
obj/vm.o: src/vm.cpp include/kstdlib.h include/varargs.h include/config.h \
|
||||||
include/malloc.h include/timer.h include/dynamic.h include/console.h
|
include/malloc.h include/timer.h include/dynamic.h include/console.h
|
||||||
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ -c src/vm.cpp
|
$(CXX) $(FLAGS) $(CXXFLAGS) -o $@ -c src/vm.cpp
|
||||||
|
|
||||||
|
@ -117,6 +116,7 @@ obj/start.o: asm/start.S
|
||||||
$(AS) $(FLAGS) $(ASFLAGS) -o $@ -c asm/start.S
|
$(AS) $(FLAGS) $(ASFLAGS) -o $@ -c asm/start.S
|
||||||
|
|
||||||
# Custom Targets
|
# Custom Targets
|
||||||
|
|
||||||
obj/main.o: scripts/main.ts
|
obj/main.o: scripts/main.ts
|
||||||
objcopy -B i386 -I binary -O elf32-i386 \
|
objcopy -B i386 -I binary -O elf32-i386 \
|
||||||
scripts/main.ts obj/main.o
|
scripts/main.ts obj/main.o
|
||||||
|
@ -126,6 +126,15 @@ obj/main.o: scripts/main.ts
|
||||||
--redefine-sym _binary_scripts_main_ts_size=mainscript_size \
|
--redefine-sym _binary_scripts_main_ts_size=mainscript_size \
|
||||||
obj/main.o
|
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
|
.PHONY: run
|
||||||
run:
|
run:
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#if defined(CIRCUIT_OS)
|
#if defined(CIRCUIT_OS)
|
||||||
#include <kstdlib.h>
|
#include <kstdlib.h>
|
||||||
#error "???"
|
|
||||||
#else
|
#else
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -224,10 +223,7 @@ namespace ker
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static String from(const T &)
|
static String from(const T &);
|
||||||
{
|
|
||||||
return "Not implemented yet";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace ker
|
||||||
|
|
||||||
if(current > size) {
|
if(current > size) {
|
||||||
// "Downgrade"
|
// "Downgrade"
|
||||||
for(int32_t i = static_cast<int32_t>(this->mLength) - 1; i > static_cast<int32_t>(size); i--) {
|
for(int32_t i = static_cast<int32_t>(this->mLength) - 1; i >= static_cast<int32_t>(size); i--) {
|
||||||
this->mData[i].~T();
|
this->mData[i].~T();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
||||||
|
|
||||||
char *itoa(int value, char *str, int base);
|
char *itoa(int value, char *str, int base);
|
||||||
int atoi(const char *str);
|
int atoi(const char *str);
|
||||||
float atof(const char *str);
|
// float atof(const char *str);
|
||||||
|
|
||||||
void exit(int errorCode);
|
void exit(int errorCode);
|
||||||
|
|
||||||
|
|
138
ker/string.cpp
Normal file
138
ker/string.cpp
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "../include/ker/string.hpp"
|
||||||
|
|
||||||
|
#define SPEC(type) template<> String String::from<type>(const type &val)
|
||||||
|
|
||||||
|
static void reverse(char *str, int length)
|
||||||
|
{
|
||||||
|
int start = 0;
|
||||||
|
int end = length -1;
|
||||||
|
while (start < end)
|
||||||
|
{
|
||||||
|
char tmp = *(str+start);
|
||||||
|
*(str+start) = *(str+end);
|
||||||
|
*(str+end) = tmp;
|
||||||
|
start++;
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *_itoa(int num, char *str, int base, bool useUnsigned)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int isNegative = 0;
|
||||||
|
|
||||||
|
if(str == nullptr) {
|
||||||
|
static char tmp[64];
|
||||||
|
str = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle 0 explicitely, otherwise empty string is printed for 0 */
|
||||||
|
if (num == 0)
|
||||||
|
{
|
||||||
|
str[i++] = '0';
|
||||||
|
str[i] = '\0';
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In standard itoa(), negative numbers are handled only with
|
||||||
|
// base 10. Otherwise numbers are considered unsigned.
|
||||||
|
if ((useUnsigned == false) && (num < 0) && (base == 10))
|
||||||
|
{
|
||||||
|
isNegative = 1;
|
||||||
|
num = -num;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process individual digits
|
||||||
|
while (num != 0)
|
||||||
|
{
|
||||||
|
int rem = num % base;
|
||||||
|
str[i++] = (rem > 9)? (rem-10) + 'A' : rem + '0';
|
||||||
|
num = num/base;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If number is negative, append '-'
|
||||||
|
if (isNegative)
|
||||||
|
{
|
||||||
|
str[i++] = '-';
|
||||||
|
}
|
||||||
|
str[i] = '\0'; // Append string terminator
|
||||||
|
|
||||||
|
// Reverse the string
|
||||||
|
reverse(str, i);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ker
|
||||||
|
{
|
||||||
|
SPEC(bool)
|
||||||
|
{
|
||||||
|
return val ? "true" : "false";
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(String)
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(int8_t) {
|
||||||
|
static char buffer[16];
|
||||||
|
_itoa(val, buffer, 10, false);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(int16_t) {
|
||||||
|
static char buffer[16];
|
||||||
|
_itoa(val, buffer, 10, false);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(int32_t) {
|
||||||
|
static char buffer[16];
|
||||||
|
_itoa(val, buffer, 10, false);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(uint8_t) {
|
||||||
|
static char buffer[16];
|
||||||
|
_itoa(val, buffer, 10, true);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(uint16_t) {
|
||||||
|
static char buffer[16];
|
||||||
|
_itoa(val, buffer, 10, true);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(uint32_t) {
|
||||||
|
static char buffer[16];
|
||||||
|
_itoa(val, buffer, 10, true);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(float) {
|
||||||
|
(void)val;
|
||||||
|
return "f32";
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONDUCTANCE_64BIT)
|
||||||
|
|
||||||
|
SPEC(int64_t)
|
||||||
|
{
|
||||||
|
return "i64";
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(uint64_t)
|
||||||
|
{
|
||||||
|
return "u64";
|
||||||
|
}
|
||||||
|
|
||||||
|
SPEC(double)
|
||||||
|
{
|
||||||
|
return "f64";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
|
#include <inttypes.h>
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "stdlib.h"
|
#include "kstdlib.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <ker/new.hpp>
|
#include <ker/new.hpp>
|
||||||
|
@ -71,3 +71,25 @@ extern "C" void cpp_init()
|
||||||
{
|
{
|
||||||
initialiseConstructors();
|
initialiseConstructors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*destructor)();
|
||||||
|
/*
|
||||||
|
// Im Linkerskript definiert
|
||||||
|
extern "C" destructor start_dtors;
|
||||||
|
extern "C" destructor end_dtors;
|
||||||
|
|
||||||
|
extern "C" void initialiseDestructors();
|
||||||
|
|
||||||
|
// Ruft die Konstruktoren für globale/statische Objekte auf
|
||||||
|
void initialiseDestructors()
|
||||||
|
{
|
||||||
|
for (destructor* i = &start_dtors;i != &end_dtors;++i)
|
||||||
|
(*i)();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
extern "C" void cpp_exit()
|
||||||
|
{
|
||||||
|
initialiseConstructors();
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <interrupts.h>
|
#include <interrupts.h>
|
||||||
#include <pmm.h>
|
#include <pmm.h>
|
||||||
|
@ -143,6 +143,8 @@ static void dumpMB(const MultibootStructure *mbHeader)
|
||||||
|
|
||||||
void cpp_init();
|
void cpp_init();
|
||||||
|
|
||||||
|
void cpp_exit();
|
||||||
|
|
||||||
void putsuccess()
|
void putsuccess()
|
||||||
{
|
{
|
||||||
int y; kgetpos(nullptr, &y);
|
int y; kgetpos(nullptr, &y);
|
||||||
|
@ -210,6 +212,8 @@ void init(const MultibootStructure *mbHeader)
|
||||||
|
|
||||||
irq_disable();
|
irq_disable();
|
||||||
|
|
||||||
|
cpp_exit();
|
||||||
|
|
||||||
kputs("\x12\x04" "CircuitOS stopped." "\x12\x07" "\n");
|
kputs("\x12\x04" "CircuitOS stopped." "\x12\x07" "\n");
|
||||||
|
|
||||||
#if defined(ENABLE_MALLOC_MONITORING)
|
#if defined(ENABLE_MALLOC_MONITORING)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "stdlib.h"
|
#include "kstdlib.h"
|
||||||
#include "cpustate.h"
|
#include "cpustate.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
|
12
src/malloc.c
12
src/malloc.c
|
@ -1,5 +1,6 @@
|
||||||
|
#include <config.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
|
@ -38,13 +39,17 @@ static uint32_t hash(List *list)
|
||||||
|
|
||||||
static int isValid(List *list)
|
static int isValid(List *list)
|
||||||
{
|
{
|
||||||
|
#if defined(USE_MAGIC_SECURED_MALLOC)
|
||||||
return list->hash == hash(list);
|
return list->hash == hash(list);
|
||||||
|
#else
|
||||||
|
return 1; // Yes, it is always valid. What a pity....
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t mallocCount = 0, freeCount = 0;
|
size_t mallocCount = 0, freeCount = 0;
|
||||||
size_t allocatedMemory = 0;
|
size_t allocatedMemory = 0;
|
||||||
|
|
||||||
static const size_t minimumAllocSize = 2 * sizeof(List);
|
static const size_t minimumAllocSize = 1; // 2 * sizeof(List);
|
||||||
static char * const malloc_heap_start = (char *)0x400000;
|
static char * const malloc_heap_start = (char *)0x400000;
|
||||||
static char * const malloc_heap_end = (char *)0x800000;
|
static char * const malloc_heap_end = (char *)0x800000;
|
||||||
|
|
||||||
|
@ -196,7 +201,10 @@ void *malloc(size_t len)
|
||||||
cursor->allocationFile = file;
|
cursor->allocationFile = file;
|
||||||
cursor->allocationLine = line;
|
cursor->allocationLine = line;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_MAGIC_SECURED_MALLOC)
|
||||||
cursor->hash = hash(cursor);
|
cursor->hash = hash(cursor);
|
||||||
|
#endif
|
||||||
|
|
||||||
allocatedMemory += len;
|
allocatedMemory += len;
|
||||||
mallocCount++;
|
mallocCount++;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "pmm.h"
|
#include "pmm.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "stdlib.h"
|
#include "kstdlib.h"
|
||||||
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <varargs.h>
|
#include <varargs.h>
|
||||||
|
|
||||||
// Funktion zum initialisieren eines COM-Ports
|
// Funktion zum initialisieren eines COM-Ports
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
|
|
||||||
void exit(int errorCode)
|
void exit(int errorCode)
|
||||||
|
|
65
src/vm.cpp
65
src/vm.cpp
|
@ -1,4 +1,4 @@
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
#include <dynamic.h>
|
#include <dynamic.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
|
@ -11,6 +11,10 @@ extern "C" {
|
||||||
extern const char mainscript_start;
|
extern const char mainscript_start;
|
||||||
extern const char mainscript_end;
|
extern const char mainscript_end;
|
||||||
extern const char mainscript_size;
|
extern const char mainscript_size;
|
||||||
|
|
||||||
|
extern const char firstrun_start;
|
||||||
|
extern const char firstrun_end;
|
||||||
|
extern const char firstrun_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printVMValue(const VMValue &value)
|
void printVMValue(const VMValue &value)
|
||||||
|
@ -45,25 +49,68 @@ ExceptionCode printArguments(VMValue &, const VMArray &args)
|
||||||
return ExceptionCode::None;
|
return ExceptionCode::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct dtortest {
|
||||||
|
void *mem;
|
||||||
|
|
||||||
|
dtortest() : mem(malloc(42)) { }
|
||||||
|
~dtortest() { free(mem); }
|
||||||
|
};
|
||||||
|
|
||||||
extern "C" void vm_start()
|
extern "C" void vm_start()
|
||||||
{
|
{
|
||||||
struct {
|
|
||||||
const char *ptr;
|
/*
|
||||||
uint32_t size;
|
}
|
||||||
} mainfile {
|
|
||||||
&mainscript_start,
|
void code()
|
||||||
(uint32_t)&mainscript_size
|
{
|
||||||
};
|
//*/
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const char *ptr;
|
||||||
|
uint32_t size;
|
||||||
|
} firstrun {
|
||||||
|
&firstrun_start,
|
||||||
|
(uint32_t)&firstrun_size
|
||||||
|
};
|
||||||
|
|
||||||
VirtualMachine vm;
|
VirtualMachine vm;
|
||||||
vm.import("print") = printArguments;
|
vm.import("print") = printArguments;
|
||||||
|
|
||||||
|
Assembly *assembly = vm.load(firstrun.ptr, firstrun.size);
|
||||||
|
if(assembly == nullptr) {
|
||||||
|
kprintf("failed to load assembly :(\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
kprintf("Assembly:\n");
|
||||||
|
kprintf(" Name: %s\n", assembly->name().str());
|
||||||
|
kprintf(" Author: %s\n", assembly->author().str());
|
||||||
|
kprintf(" Description: %s\n", assembly->description().str());
|
||||||
|
//*/
|
||||||
|
/*
|
||||||
|
kprintf("Type list:\n");
|
||||||
|
for(const auto &type : vm.types()) {
|
||||||
|
kprintf("%s: %x\n", type.first.str(), vm.type(type.first));
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
|
||||||
|
Process *process = vm.createProcess(assembly);
|
||||||
|
if(process == nullptr) {
|
||||||
|
kprintf("Failed to create process.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
while(vm.step())
|
while(vm.step())
|
||||||
{
|
{
|
||||||
kprintf(".");
|
// kprintf(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process->release();
|
||||||
|
assembly->release();
|
||||||
|
|
||||||
kprintf("\n");
|
kprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <vmm.h>
|
#include <vmm.h>
|
||||||
#include <pmm.h>
|
#include <pmm.h>
|
||||||
#include <stdlib.h>
|
#include <kstdlib.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ HEADERS += \
|
||||||
include/kernel.h \
|
include/kernel.h \
|
||||||
include/multiboot.h \
|
include/multiboot.h \
|
||||||
include/pmm.h \
|
include/pmm.h \
|
||||||
include/stdlib.h \
|
include/kstdlib.h \
|
||||||
include/varargs.h \
|
include/varargs.h \
|
||||||
include/vmm.h \
|
include/vmm.h \
|
||||||
include/timer.h \
|
include/timer.h \
|
||||||
|
@ -34,7 +34,7 @@ HEADERS += \
|
||||||
include/ker/pair.hpp \
|
include/ker/pair.hpp \
|
||||||
include/ker/vector.hpp \
|
include/ker/vector.hpp \
|
||||||
include/ker/dictionary.hpp \
|
include/ker/dictionary.hpp \
|
||||||
include/string.h \
|
include/kstring.h \
|
||||||
include/ker/new.hpp \
|
include/ker/new.hpp \
|
||||||
include/dynamic.h \
|
include/dynamic.h \
|
||||||
include/config.h \
|
include/config.h \
|
||||||
|
|
Loading…
Reference in a new issue