While I was debugging more, I saw that:
Quote:
00808511372e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00808511372e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
At least that explains the triple fault. Looks like firstly it called #GP handler, then it failed, so it called #DF handler, then it failed too, then boom! Triple fault...
Then:
Quote:
00801480972i[CPU0 ] CPU is in protected mode (active)
00801480972i[CPU0 ] CS.mode = 32 bit
00801480972i[CPU0 ] SS.mode = 32 bit
00801480972i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
00801480972i[CPU0 ] | DS:0000( 0000| 0| 3) 00000000 0000ffff 0 0
00801480972i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00801480972i[CPU0 ] | ES:0000( 0000| 0| 3) 00004100 0000ffff 0 0
00801480972i[CPU0 ] | FS:0000( 0000| 0| 3) 000089e0 0000ffff 0 0
00801480972i[CPU0 ] | GS:0000( 0000| 0| 3) 00043090 0000ffff 0 0
Selectors wrecked with no reason...
And, do I need a new TSS for v8086 mode tasks? I'm using only one TSS that stores ESP0 and SS0 when an interrupt occurs for both user and v8086 mode (lol v8086 mode tasks are also user mode) tasks.
This is how I set the TSS:
Code:
tss0.ss0 = 0x10;
tss0.cs = 0x08;
tss0.ss = 0x10;
tss0.ds = 0x10;
tss0.es = 0x10;
tss0.fs = 0x10;
tss0.gs = 0x10;
Looks like setting ss, ds, es, fs, gs has no effect.
That is the info tss just before the triple fault:
Quote:
tr:s=0x2b, base=0x000000000014f060, valid=1
ss:esp(0): 0x0010:0x00155360
ss:esp(1): 0x0000:0x00000000
ss:esp(2): 0x0000:0x00000000
cr3: 0x00000000
eip: 0x00000000
eflags: 0x00000000
cs: 0x0008 ds: 0x0010 ss: 0x0010
es: 0x0010 fs: 0x0010 gs: 0x0010
eax: 0x00000000 ebx: 0x00000000 ecx: 0x00000000 edx: 0x00000000
esi: 0x00000000 edi: 0x00000000 ebp: 0x00000000 esp: 0x00000000
ldt: 0x0000
i/o map: 0x0068
And this is how the GDT looks like:
Quote:
GDT[0x00]=??? descriptor hi=0x00000000, lo=0x00000000
GDT[0x01]=Code segment, base=0x00000000, limit=0xffffffff, Execute/Read, Non-Conforming, Accessed, 32-bit
GDT[0x02]=Data segment, base=0x00000000, limit=0xffffffff, Read/Write, Accessed
GDT[0x03]=Code segment, base=0x00000000, limit=0xffffffff, Execute/Read, Non-Conforming, Accessed, 32-bit
GDT[0x04]=Data segment, base=0x00000000, limit=0xffffffff, Read/Write, Accessed
GDT[0x05]=32-Bit TSS (Busy) at 0x0014f060, length 0x00068
If I set all segment selectors to their correct values in Bochs with set reg = 16, then continue executing, it results with a #GP, with that:
Quote:
00794446885e[CPU0 ] iret: return CS selector null
Looks like I'm getting closer to fully understand whats going wrong, I'm going to look at the task switch code again
Thanks in advance...