From 56152c6d20271c8d1741a8414486d4f71301bb04 Mon Sep 17 00:00:00 2001 From: Lucia Ceionia Date: Wed, 31 Jul 2024 20:02:36 -0500 Subject: [PATCH] some fixes --- Makefile | 2 +- interrupt.c | 9 +++++---- interrupt.h | 2 +- kernel.c | 14 ++++++++++++++ link.ld | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ad23dce..4e3b608 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ objects = entry.o kernel.o task.o handler.o interrupt.o v86.o print.o tss.o gdt. paging.o fault.o tests.o kbd.o helper.o disk.o file.o fs.o dosfs/dosfs.o fs_dos.o\ progs.o hexedit.o textedit.o CFLAGS = -target "i686-elf" -m32 -mgeneral-regs-only -ffreestanding\ - -march=i686 -fno-stack-protector -Wno-int-conversion -nostdlib -c + -march=i686 -fno-stack-protector -Wno-int-conversion -nostdlib -c -g LFLAGS = -Wl,--gc-sections -Wl,--print-gc-sections -m32 -nostartfiles -nostdlib ifeq ($(OUTFILE),) diff --git a/interrupt.c b/interrupt.c index 4f4bf36..a89c27e 100644 --- a/interrupt.c +++ b/interrupt.c @@ -92,7 +92,7 @@ void IRQ_clear_mask(char IRQline) { char v86_if = 0; extern uint16_t error_screen[80*50]; // defined in kernel.c -extern uint16_t *ivt; +extern uint16_t IVT[]; extern void real_test(); extern void jmp_usermode_test(); __attribute__((__no_caller_saved_registers__)) @@ -104,7 +104,7 @@ extern void error_environment(); // defined in kernel.c extern uint32_t _gpf_eax_save; #define VALID_FLAGS 0xDFF __attribute__ ((interrupt)) -void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) { +void gpf_handler_v86(struct interrupt_frame volatile *frame, unsigned long error_code) { //asm volatile("mov %%ax,%%ds"::"a"(0x10)); uint8_t *ip; uint16_t *stack; @@ -211,8 +211,9 @@ void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) { else stack[2] &= ~EFLAG_IF; - frame->cs = ivt[ip[1] * 2 + 1]; - frame->eip = ivt[ip[1] * 2]; + asm volatile("xchg %bx,%bx"); + frame->cs = IVT[ip[1] * 2 + 1]; + frame->eip = IVT[ip[1] * 2]; break; } goto done; diff --git a/interrupt.h b/interrupt.h index 3ee0ba0..0ec3668 100644 --- a/interrupt.h +++ b/interrupt.h @@ -8,6 +8,6 @@ struct interrupt_frame { uint32_t es, ds, fs, gs; }; __attribute__ ((interrupt)) -void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code); +void gpf_handler_v86(struct interrupt_frame volatile *frame, unsigned long error_code); void setup_interrupts(); diff --git a/kernel.c b/kernel.c index 91d9842..25eb48e 100644 --- a/kernel.c +++ b/kernel.c @@ -146,8 +146,10 @@ void error_environment(uint32_t stack0, uint32_t stack1, uint32_t stack2, uint32 for(;;) { uint8_t key = get_scancode() & 0xff; if (key == KEY_E) { + *(uint8_t*)0x800000 = 0x00; v86_entry = i386LinearToFp(v86TransFlag); enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry), ®s); + if (*(uint8_t*)0x800000 == 0x88) *(uint32_t*)0xa0000 = 0x01010101; } if (key == KEY_R) break; } @@ -554,14 +556,26 @@ void start() { // Setup system setup_binary(); + vga_text += printStr("bin...", vga_text); + vga_text++; setup_interrupts(); + vga_text += printStr("int...", vga_text); + vga_text++; setup_tss(); + vga_text += printStr("tss...", vga_text); + vga_text++; init_paging(); + vga_text += printStr("page...", vga_text); + vga_text++; backup_ivtbios(); + vga_text += printStr("bkup...", vga_text); + vga_text++; // DL contained disk number, DH contained active partition uint8_t SystemPartition = boot_dx >> 8; + vga_text = &((uint16_t*)0xb8000)[160]; + vga_text += printStr("Starting Shell...", vga_text); create_child(GetFreeStack(), (uintptr_t)SystemRun, 1, SystemPartition); // If this returns, something is *very* wrong, reboot the system // TODO Maybe try to recover? diff --git a/link.ld b/link.ld index a86b17e..06dd9cf 100644 --- a/link.ld +++ b/link.ld @@ -2,6 +2,7 @@ OUTPUT_FORMAT(binary) ENTRY(entry) SECTIONS { + IVT = 0x00000; . = 0x100000; _USERMODE = 0x800000; _USERMODE_END = 0x1000000;