I am rewriting my bootloader for better stability, and management of a 32bit PE kernel and kernel level drivers.
For the most part, everything is going fine--I have paging set up, IDT, GDT. PMode, and a basic TSS that I may use for v86 mode.
I cannot seem to be able to switch into a v86 task, though...
Code: Select all
; Protected mode code:
push dword 0x0 ; real mode gs
push dword 0x0 ; real mode fs
push dword 0x0 ; real mode ds
push dword 0x0 ; real mode es
push dword 0x9000 ; real mode ss
push dword 0xf000 ; real mode esp
push dword 100111001000000010b ; real mode eflags (Enables v8086 mode bit, ring3, interrupt enable flag)
push dword 0x0 ; real mode cs
push dword V86_Test ; real mode eip
iretd
Here is V86_Task:
Code: Select all
; rmode code:
V86_Test:
jmp $
As the segment registers are not set (No matter what I do), I get errors from Bochs, which then provokes a triple fault (Ignoring my IDT)...
Code: Select all
00001119702e[CPU ] seg = DS
00001119702e[CPU ] seg->selector.value = 0000
...repeated 1000's of times...
00001122367e[CPU ] write_virtual_checks: valid bit = 0
00001122367e[CPU ] CS: 0008
00001122367e[CPU ] IP: 132d
00001122367e[CPU ] seg = DS
...repeated 1000's of times...
00001122367e[CPU ] seg->selector.value = 0000
00001122367e[CPU ] write_virtual_checks: valid bit = 0
00001122367e[CPU ] CS: 0008
00001122367e[CPU ] IP: 132d
00001122367p[CPU ] >>PANIC<< exception(): 3rd (13) exception with no resolution
00001122367i[SYS ] Last time is 1191897309
00001122367i[CPU ] protected mode
00001122367i[CPU ] CS.d_b = 32 bit
00001122367i[CPU ] SS.d_b = 32 bit
00001122367i[CPU ] | EAX=00000010 EBX=00001350 ECX=00150010 EDX=00000fff
00001122367i[CPU ] | ESP=00000a04 EBP=00000000 ESI=00000796 EDI=00001350
00001122367i[CPU ] | IOPL=3 NV UP DI PL NZ NA PO NC
00001122367i[CPU ] | SEG selector base limit G D
00001122367i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00001122367i[CPU ] | DS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001122367i[CPU ] | ES:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001122367i[CPU ] | FS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001122367i[CPU ] | GS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001122367i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001122367i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00001122367i[CPU ] | EIP=0000132d (0000132d)
00001122367i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x00000000
00001122367i[CPU ] | CR3=0x0009c000 CR4=0x00000000
00001122367i[ ] restoring default signal behavior
00001122367i[CTRL ] quit_sim called with exit code 1
I have also read up the Intel docs and searched around alot to see if I am missing something, but everything looks correct...
Here is one of the things I found while debugging, that may help.
If I set the ESP0 DWORD inside of the TSS Segment to 0, Bochs only gives me this error:
Code: Select all
00001119697p[CPU ] >>PANIC<< exception(): 3rd (13) exception with no resolution
00001119697i[SYS ] Last time is 1191897764
00001119697i[CPU ] v8086 mode
00001119697i[CPU ] CS.d_b = 32 bit
00001119697i[CPU ] SS.d_b = 32 bit
00001119697i[CPU ] | EAX=00000010 EBX=00001608 ECX=00150010 EDX=00000fff
00001119697i[CPU ] | ESP=0000f000 EBP=00000000 ESI=00000796 EDI=00000005
00001119697i[CPU ] | IOPL=3 NV UP EI PL NZ NA PO NC
00001119697i[CPU ] | SEG selector base limit G D
00001119697i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00001119697i[CPU ] | DS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001119697i[CPU ] | ES:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001119697i[CPU ] | FS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001119697i[CPU ] | GS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00001119697i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001119697i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00001119697i[CPU ] | EIP=000007b1 (000007b1)
00001119697i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0xfffffffc
00001119697i[CPU ] | CR3=0x0009c000 CR4=0x00000000
00001119697i[ ] restoring default signal behavior
00001119697i[CTRL ] quit_sim called with exit code 1
I'm tired and have been working on this for hours right now, and cannot for the life of me figure out the problem
If anyone would like me to post more code, I will be happy to.
Does anyone have any suggestions that I can try (That I hopefully have not already tried)?
Thanks