diff --git a/Depfile b/Depfile index 2a2efa0..dfcb0fc 100644 --- a/Depfile +++ b/Depfile @@ -18,11 +18,11 @@ YACC=bison #TEMPLE=mono /home/felix/projects/temple/bin/Debug/temple.exe # 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 +FLAGS=-g -Wall -Wextra -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 ASFLAGS=-masm=intel -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 -LDFLAGS=-g -m32 -nostdlib -fno-builtin -Tkernel.ld +CCFLAGS=-std=c11 -Dnullptr=0 -fno-stack-protector -ffreestanding -Iinclude +CXXFLAGS=-std=c++11 -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -ffreestanding -Wno-unused-function -Iinclude +LDFLAGS=-nostdlib -fno-builtin -Tkernel.ld -- diff --git a/Makefile b/Makefile index 5d7fe1e..d7680dc 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,11 @@ SRCS_CXX = src/cplusplus.cpp src/vm.cpp csl/casts.cpp csl/cpustatetype.cpp csl/i 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/vm.o obj/casts.o obj/cpustatetype.o obj/io.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 +FLAGS = -g -Wall -Wextra -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 ASFLAGS = -masm=intel -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 -LDFLAGS = -g -m32 -nostdlib -fno-builtin -Tkernel.ld +CCFLAGS = -std=c11 -Dnullptr=0 -fno-stack-protector -ffreestanding -Iinclude +CXXFLAGS = -std=c++11 -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -ffreestanding -Wno-unused-function -Iinclude +LDFLAGS = -nostdlib -fno-builtin -Tkernel.ld # Targets all: kernel diff --git a/kernel.ld b/kernel.ld index 7fcfe93..7f5490d 100644 --- a/kernel.ld +++ b/kernel.ld @@ -32,7 +32,7 @@ SECTIONS end_ctors = .; start_dtors = .; - *(.dtors) + KEEP(*( .fini_array )); end_dtors = .; *(.data) diff --git a/scripts/main.cu b/scripts/main.cu index 3cf7947..5b3f33a 100644 --- a/scripts/main.cu +++ b/scripts/main.cu @@ -55,7 +55,7 @@ BEGIN initKeyboard(); print("Hello World!\n"); - 1 → i; + 1 → i; WHILE i <= 5 DO print(i, "\n"); (i + 1) → i; @@ -92,6 +92,11 @@ BEGIN (scancode & 127u8) → scancode; END + IF scancode = 0x01u8 THEN + shutdown(); + RETURN; + END + # print("[scancode=", scancode, ",breakcode=", breakcode, "]"); IF e0Code THEN diff --git a/scripts/main.cu.spark b/scripts/main.cu.spark index 7a039b0..96588ff 100644 --- a/scripts/main.cu.spark +++ b/scripts/main.cu.spark @@ -1,6 +1,6 @@ ; ============================================= ; compiled with Copper 1.0 -; 2015-10-13 17:50:36 +; 2015-10-14 21:08:00 ; ============================================= ; native method: print(…) @@ -211,8 +211,18 @@ handleKeyboardIRQ: _private_9: - loadg e0Code + load 1 + pushi 3 1 + op2 5 jmp_if_not _private_10 + calln shutdown 0 + + ret + +_private_10: + + loadg e0Code + jmp_if_not _private_11 load 1 pushi 3 42 op2 5 @@ -220,13 +230,13 @@ _private_9: pushi 3 54 op2 5 op2 11 - jmp_if_not _private_12 + jmp_if_not _private_13 pushi 6 0 storeg e0Code ret -_private_12: +_private_13: load 1 callnr toInt32 1 @@ -237,12 +247,12 @@ _private_12: pushi 6 0 storeg e0Code - jmp _private_11 -_private_10: + jmp _private_12 +_private_11: loadg e1Code pushi 2 2 op2 5 - jmp_if_not _private_13 + jmp_if_not _private_14 loadg e1Prev load 1 pushi 3 256 @@ -260,12 +270,12 @@ _private_10: pushi 2 0 storeg e1Code - jmp _private_14 -_private_13: + jmp _private_15 +_private_14: loadg e1Code pushi 2 1 op2 5 - jmp_if_not _private_15 + jmp_if_not _private_16 load 1 callnr toUInt16 1 storeg e1Prev @@ -273,51 +283,51 @@ _private_13: pushi 2 2 storeg e1Code - jmp _private_16 -_private_15: + jmp _private_17 +_private_16: load 1 pushi 3 224 op2 5 - jmp_if_not _private_17 + jmp_if_not _private_18 pushi 6 1 storeg e0Code - jmp _private_18 -_private_17: + jmp _private_19 +_private_18: load 1 pushi 3 225 op2 5 - jmp_if_not _private_19 + jmp_if_not _private_20 pushi 2 1 storeg e1Code - jmp _private_20 -_private_19: + jmp _private_21 +_private_20: load 1 callnr toInt32 1 pushi 2 0 callr translateKeyCode 2 store 2 -_private_20: +_private_21: -_private_18: +_private_19: -_private_16: +_private_17: -_private_14: +_private_15: -_private_11: +_private_12: load 2 pushi 2 0 op2 6 - jmp_if_not _private_21 + jmp_if_not _private_22 load 3 load 2 call handleKeyPress 2 -_private_21: +_private_22: ret ; end of handleKeyboardIRQ @@ -329,10 +339,10 @@ irq: load -1 pushi 2 33 op2 5 - jmp_if_not _private_22 + jmp_if_not _private_23 call handleKeyboardIRQ 0 -_private_22: +_private_23: load -2 destruct diff --git a/src/cplusplus.cpp b/src/cplusplus.cpp index 95a6d77..3152f3e 100644 --- a/src/cplusplus.cpp +++ b/src/cplusplus.cpp @@ -72,8 +72,6 @@ extern "C" void cpp_init() initialiseConstructors(); } - - typedef void (*destructor)(); // Im Linkerskript definiert @@ -85,7 +83,9 @@ extern CompoundType type; extern "C" void cpp_exit() { - for (destructor* i = &start_dtors; i != &end_dtors;++i) + for (destructor* i = &start_dtors; i != &end_dtors;++i) { + kprintf("[dtor:%x]", *i); (*i)(); + } type.~CompoundType(); // TODO: Remove this. This is dirty. Get the destructor to make a clean exit. } diff --git a/src/malloc.c b/src/malloc.c index a11f690..4911f94 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -264,15 +264,19 @@ void free(void *ptr) freeCount++; List *entry = (List*)((char*)ptr - sizeof(List)); - if(entry->used == 0) { - die_extra("free.InvalidBlock", itoa((int)ptr, nullptr, 16)); - } + #if defined(USE_MAGIC_SECURED_MALLOC) if(isValid(entry) == 0) { die_extra("free.InvalidBlockMagic: ", itoa(entry->hash, nullptr, 16)); } #endif + if(entry->used == 0) { + static char buffer[16]; + itoa((int)ptr, buffer, 16); + die_extra("free.InvalidBlock", buffer); + } + if(entry->length > 0x5000) { die_extra("free.InvalidSizedBlock: ", itoa(entry->length, nullptr, 10)); }