diff --git a/src/kernel/interrupts/interruptDescriptors.asm b/src/kernel/interrupts/interruptDescriptors.asm index f003f4d..342cf25 100644 --- a/src/kernel/interrupts/interruptDescriptors.asm +++ b/src/kernel/interrupts/interruptDescriptors.asm @@ -2,6 +2,7 @@ extern onInterrupt extern temporaryESP +extern handleSyscallEnd global interruptStack interruptStack: resb 1024 @@ -15,9 +16,10 @@ exceptionAbort: mov ebx, [esp+24] - jmp $ - mov eax, 0x500000 - mov cr3, eax + cmp ecx, 0x500000 + je $ + mov ecx, 0x500000 + mov cr3, ecx mov eax, [temporaryESP] mov esp, eax pop ebp @@ -29,8 +31,8 @@ push ebx push ecx push edx - mov eax, cr3 - push eax + mov ecx, cr3 + push ecx .checkException: mov eax, [esp+20] cmp eax, 31 diff --git a/src/kernel/interrupts/interruptDescriptors.asm b/src/kernel/interrupts/interruptDescriptors.asm index f003f4d..342cf25 100644 --- a/src/kernel/interrupts/interruptDescriptors.asm +++ b/src/kernel/interrupts/interruptDescriptors.asm @@ -2,6 +2,7 @@ extern onInterrupt extern temporaryESP +extern handleSyscallEnd global interruptStack interruptStack: resb 1024 @@ -15,9 +16,10 @@ exceptionAbort: mov ebx, [esp+24] - jmp $ - mov eax, 0x500000 - mov cr3, eax + cmp ecx, 0x500000 + je $ + mov ecx, 0x500000 + mov cr3, ecx mov eax, [temporaryESP] mov esp, eax pop ebp @@ -29,8 +31,8 @@ push ebx push ecx push edx - mov eax, cr3 - push eax + mov ecx, cr3 + push ecx .checkException: mov eax, [esp+20] cmp eax, 31 diff --git a/src/userland/crashTest/Makefile b/src/userland/crashTest/Makefile new file mode 100644 index 0000000..700f612 --- /dev/null +++ b/src/userland/crashTest/Makefile @@ -0,0 +1,29 @@ +CC = i686-elf-gcc +CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I ../../include -I include -Wno-discarded-qualifiers -fms-extensions -Wno-shift-count-overflow -O0 +LD = i686-elf-ld +LD_FLAGS = -z max-page-size=0x1000 -T ../link.ld +AS = nasm +ASFlAGS = -felf32 + +BUILD_FOLDER = build + +SOURCE_FILES := $(shell find . -name '*.c' -or -name '*.asm' -or -name '*.s') +OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) + +../../../initrd/crashTest: $(OBJS) ../../../build/hlib.o + @echo "linking user programm crash test" + @$(LD) $(LD_FLAGS) -o $@ $(OBJS) + +$(BUILD_FOLDER)/%.asm.o: %.asm + @echo "asembling $<" + @mkdir -p $(dir $@) + @$(AS) $(ASFlAGS) $< -o $@ + +$(BUILD_FOLDER)/%.c.o: %.c + @echo "compiling $<" + @mkdir -p $(dir $@) + @$(CC) $(CCFLAGS) -r $< -o $@ + +clean: + @echo "clearing build folder" + @rm -r $(BUILD_FOLDER) diff --git a/src/kernel/interrupts/interruptDescriptors.asm b/src/kernel/interrupts/interruptDescriptors.asm index f003f4d..342cf25 100644 --- a/src/kernel/interrupts/interruptDescriptors.asm +++ b/src/kernel/interrupts/interruptDescriptors.asm @@ -2,6 +2,7 @@ extern onInterrupt extern temporaryESP +extern handleSyscallEnd global interruptStack interruptStack: resb 1024 @@ -15,9 +16,10 @@ exceptionAbort: mov ebx, [esp+24] - jmp $ - mov eax, 0x500000 - mov cr3, eax + cmp ecx, 0x500000 + je $ + mov ecx, 0x500000 + mov cr3, ecx mov eax, [temporaryESP] mov esp, eax pop ebp @@ -29,8 +31,8 @@ push ebx push ecx push edx - mov eax, cr3 - push eax + mov ecx, cr3 + push ecx .checkException: mov eax, [esp+20] cmp eax, 31 diff --git a/src/userland/crashTest/Makefile b/src/userland/crashTest/Makefile new file mode 100644 index 0000000..700f612 --- /dev/null +++ b/src/userland/crashTest/Makefile @@ -0,0 +1,29 @@ +CC = i686-elf-gcc +CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I ../../include -I include -Wno-discarded-qualifiers -fms-extensions -Wno-shift-count-overflow -O0 +LD = i686-elf-ld +LD_FLAGS = -z max-page-size=0x1000 -T ../link.ld +AS = nasm +ASFlAGS = -felf32 + +BUILD_FOLDER = build + +SOURCE_FILES := $(shell find . -name '*.c' -or -name '*.asm' -or -name '*.s') +OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) + +../../../initrd/crashTest: $(OBJS) ../../../build/hlib.o + @echo "linking user programm crash test" + @$(LD) $(LD_FLAGS) -o $@ $(OBJS) + +$(BUILD_FOLDER)/%.asm.o: %.asm + @echo "asembling $<" + @mkdir -p $(dir $@) + @$(AS) $(ASFlAGS) $< -o $@ + +$(BUILD_FOLDER)/%.c.o: %.c + @echo "compiling $<" + @mkdir -p $(dir $@) + @$(CC) $(CCFLAGS) -r $< -o $@ + +clean: + @echo "clearing build folder" + @rm -r $(BUILD_FOLDER) diff --git a/src/userland/crashTest/main.c b/src/userland/crashTest/main.c new file mode 100644 index 0000000..10c23b9 --- /dev/null +++ b/src/userland/crashTest/main.c @@ -0,0 +1,10 @@ +#define ALLOC_MAIN + +#include +#include + +int32_t main() { + printf("doing a crash test now . . . "); + printf("0/0 = %i", 0 / 0); + return 0; +} diff --git a/src/kernel/interrupts/interruptDescriptors.asm b/src/kernel/interrupts/interruptDescriptors.asm index f003f4d..342cf25 100644 --- a/src/kernel/interrupts/interruptDescriptors.asm +++ b/src/kernel/interrupts/interruptDescriptors.asm @@ -2,6 +2,7 @@ extern onInterrupt extern temporaryESP +extern handleSyscallEnd global interruptStack interruptStack: resb 1024 @@ -15,9 +16,10 @@ exceptionAbort: mov ebx, [esp+24] - jmp $ - mov eax, 0x500000 - mov cr3, eax + cmp ecx, 0x500000 + je $ + mov ecx, 0x500000 + mov cr3, ecx mov eax, [temporaryESP] mov esp, eax pop ebp @@ -29,8 +31,8 @@ push ebx push ecx push edx - mov eax, cr3 - push eax + mov ecx, cr3 + push ecx .checkException: mov eax, [esp+20] cmp eax, 31 diff --git a/src/userland/crashTest/Makefile b/src/userland/crashTest/Makefile new file mode 100644 index 0000000..700f612 --- /dev/null +++ b/src/userland/crashTest/Makefile @@ -0,0 +1,29 @@ +CC = i686-elf-gcc +CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I ../../include -I include -Wno-discarded-qualifiers -fms-extensions -Wno-shift-count-overflow -O0 +LD = i686-elf-ld +LD_FLAGS = -z max-page-size=0x1000 -T ../link.ld +AS = nasm +ASFlAGS = -felf32 + +BUILD_FOLDER = build + +SOURCE_FILES := $(shell find . -name '*.c' -or -name '*.asm' -or -name '*.s') +OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) + +../../../initrd/crashTest: $(OBJS) ../../../build/hlib.o + @echo "linking user programm crash test" + @$(LD) $(LD_FLAGS) -o $@ $(OBJS) + +$(BUILD_FOLDER)/%.asm.o: %.asm + @echo "asembling $<" + @mkdir -p $(dir $@) + @$(AS) $(ASFlAGS) $< -o $@ + +$(BUILD_FOLDER)/%.c.o: %.c + @echo "compiling $<" + @mkdir -p $(dir $@) + @$(CC) $(CCFLAGS) -r $< -o $@ + +clean: + @echo "clearing build folder" + @rm -r $(BUILD_FOLDER) diff --git a/src/userland/crashTest/main.c b/src/userland/crashTest/main.c new file mode 100644 index 0000000..10c23b9 --- /dev/null +++ b/src/userland/crashTest/main.c @@ -0,0 +1,10 @@ +#define ALLOC_MAIN + +#include +#include + +int32_t main() { + printf("doing a crash test now . . . "); + printf("0/0 = %i", 0 / 0); + return 0; +} diff --git a/src/userland/loader/main.c b/src/userland/loader/main.c index dce3d9b..16c169e 100644 --- a/src/userland/loader/main.c +++ b/src/userland/loader/main.c @@ -13,5 +13,6 @@ printf("test print string: '%s', number: %i, hex: 0x%x", "hello world", 1234, 0xB105F00D); log("finished loading essential modules"); + loadFromInitrd("crashTest"); return 0; }