some fixes

This commit is contained in:
Lucia Ceionia 2024-07-31 20:02:36 -05:00
parent 5fa8e0efa3
commit 56152c6d20
5 changed files with 22 additions and 6 deletions

View File

@ -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\ 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 progs.o hexedit.o textedit.o
CFLAGS = -target "i686-elf" -m32 -mgeneral-regs-only -ffreestanding\ 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 LFLAGS = -Wl,--gc-sections -Wl,--print-gc-sections -m32 -nostartfiles -nostdlib
ifeq ($(OUTFILE),) ifeq ($(OUTFILE),)

View File

@ -92,7 +92,7 @@ void IRQ_clear_mask(char IRQline) {
char v86_if = 0; char v86_if = 0;
extern uint16_t error_screen[80*50]; // defined in kernel.c 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 real_test();
extern void jmp_usermode_test(); extern void jmp_usermode_test();
__attribute__((__no_caller_saved_registers__)) __attribute__((__no_caller_saved_registers__))
@ -104,7 +104,7 @@ extern void error_environment(); // defined in kernel.c
extern uint32_t _gpf_eax_save; extern uint32_t _gpf_eax_save;
#define VALID_FLAGS 0xDFF #define VALID_FLAGS 0xDFF
__attribute__ ((interrupt)) __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)); //asm volatile("mov %%ax,%%ds"::"a"(0x10));
uint8_t *ip; uint8_t *ip;
uint16_t *stack; uint16_t *stack;
@ -211,8 +211,9 @@ void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) {
else else
stack[2] &= ~EFLAG_IF; stack[2] &= ~EFLAG_IF;
frame->cs = ivt[ip[1] * 2 + 1]; asm volatile("xchg %bx,%bx");
frame->eip = ivt[ip[1] * 2]; frame->cs = IVT[ip[1] * 2 + 1];
frame->eip = IVT[ip[1] * 2];
break; break;
} }
goto done; goto done;

View File

@ -8,6 +8,6 @@ struct interrupt_frame {
uint32_t es, ds, fs, gs; uint32_t es, ds, fs, gs;
}; };
__attribute__ ((interrupt)) __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(); void setup_interrupts();

View File

@ -146,8 +146,10 @@ void error_environment(uint32_t stack0, uint32_t stack1, uint32_t stack2, uint32
for(;;) { for(;;) {
uint8_t key = get_scancode() & 0xff; uint8_t key = get_scancode() & 0xff;
if (key == KEY_E) { if (key == KEY_E) {
*(uint8_t*)0x800000 = 0x00;
v86_entry = i386LinearToFp(v86TransFlag); v86_entry = i386LinearToFp(v86TransFlag);
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry), &regs); enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry), &regs);
if (*(uint8_t*)0x800000 == 0x88) *(uint32_t*)0xa0000 = 0x01010101;
} }
if (key == KEY_R) break; if (key == KEY_R) break;
} }
@ -554,14 +556,26 @@ void start() {
// Setup system // Setup system
setup_binary(); setup_binary();
vga_text += printStr("bin...", vga_text);
vga_text++;
setup_interrupts(); setup_interrupts();
vga_text += printStr("int...", vga_text);
vga_text++;
setup_tss(); setup_tss();
vga_text += printStr("tss...", vga_text);
vga_text++;
init_paging(); init_paging();
vga_text += printStr("page...", vga_text);
vga_text++;
backup_ivtbios(); backup_ivtbios();
vga_text += printStr("bkup...", vga_text);
vga_text++;
// DL contained disk number, DH contained active partition // DL contained disk number, DH contained active partition
uint8_t SystemPartition = boot_dx >> 8; 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); create_child(GetFreeStack(), (uintptr_t)SystemRun, 1, SystemPartition);
// If this returns, something is *very* wrong, reboot the system // If this returns, something is *very* wrong, reboot the system
// TODO Maybe try to recover? // TODO Maybe try to recover?

View File

@ -2,6 +2,7 @@ OUTPUT_FORMAT(binary)
ENTRY(entry) ENTRY(entry)
SECTIONS { SECTIONS {
IVT = 0x00000;
. = 0x100000; . = 0x100000;
_USERMODE = 0x800000; _USERMODE = 0x800000;
_USERMODE_END = 0x1000000; _USERMODE_END = 0x1000000;