... after solving the issue with rmode->pmode switching through macros, there seems to be another problem.
Formerly, when executing call SwitchToPmode in my thread below, after the final RET it started to corrupt opcodes and then, "physical memory read error" by Bochs. Then, it threw the exception 0x06. My error handler looks like this:
Code: Select all
invalid_instruction:
mov cx,6
cmp cx,3
jne invalid_instruction
From above, I stated that the "final RET" started to corrupt opcodes. And it did even with the error handler function. Instead of "mov cx,6" it threw this: mov ecx, 0xf9830006 and instead of "cmp cx,3" and "jne invalid_instruction" it threw this -single line- add esi, dword ptr ss:[ebp+0xfffffff8].
But, this same problem has awaited for me again. In my kernel.asm, I call the macro SwitchToPmode and then I call the function "StartShell", which seems to be OK.
My StartShell function looks like this:
Code: Select all
StartShell:
call Keybirq
WriteStr "Hello"
cli
hlt
When I execute the function StartShell, it works, but when I attempt to execute "call KeybIrq", Bochs welcomes me with
bx_dbg_read_linear: physical memory read error (phy=0xbe6f09cc, lin=0x00000000be
6f09cc
and the "call keybirq" looks in Bochs like
(0) [0x00081977] 0010:0000000000003957 (unk. ctxt): call .+0xbe66f050 (0xbe6f09c
c) ; e850f066be.
Now the fun begins: if I attempt to "call" anything in e.g. interrupts.asm, stdio.asm (which is included before gdt.asm and idt.asm again), etc. -> it results in "physical memory read error".
And, after that - INT 0x06 with corrupted opcodes EXACTLY like above.
I suspect the order of include files to be faulty...
I'm welcome for any ideas or hints!