switching tasks
switching tasks
I know this is probably obvious but I just can not get it to work
i want to jmp to the TSS selector(no call gate) but well I can not really figure out what the instruction is to do it
i want to jmp to the TSS selector(no call gate) but well I can not really figure out what the instruction is to do it
Re:switching tasks
I'm just going out on a limb, but it'd be:
jmp TaskSelectorSeg:CodeLocation
jmp TaskSelectorSeg:CodeLocation
Re:switching tasks
See the Intel Manual, volume 3, section 6.1.3 "Executing a Task", and also the instruction reference for call and jmp. If you are following those instructions properly, you have 3 places where the problem could be:
- Bad selector, possibly not pointing to the correct GDT entry.
- Bad GDT entry, check all fields (especially start and limit).
- Bad TSS, check that you're writing values to the correct locations (if you're using a c struct, make sure it matches the Intel manuals), and make sure the processor state is valid (ie. SS, ESP, CS, DS, EIP are set, SS0 and ESP0 are set for non-ring 0 tasks).
Other people may want to add to that but I think thats a good start for narrowing down the bug. Also, consider the possibility that the task switch is working but the new task is crashing almost immediately because of a non-TSS related bug.
I've tried to cover all the bases here, so pick from the above whatever is relevant to you.
- Bad selector, possibly not pointing to the correct GDT entry.
- Bad GDT entry, check all fields (especially start and limit).
- Bad TSS, check that you're writing values to the correct locations (if you're using a c struct, make sure it matches the Intel manuals), and make sure the processor state is valid (ie. SS, ESP, CS, DS, EIP are set, SS0 and ESP0 are set for non-ring 0 tasks).
Other people may want to add to that but I think thats a good start for narrowing down the bug. Also, consider the possibility that the task switch is working but the new task is crashing almost immediately because of a non-TSS related bug.
I've tried to cover all the bases here, so pick from the above whatever is relevant to you.
Re:switching tasks
Also, I've had a few instances in TASM (I think) where a jump that included the selector address was actually output as a simple jump with the offset, which of course caused all worlds of annoyance.
Re:switching tasks
I don't know TASM at all but what about
[tt]jmp far seg:offset[/tt]
[tt]jmp far seg:offset[/tt]
Re:switching tasks
You can as well do "jmp tss:12345678". The offset part is required, but not used.
Re:switching tasks
ok I am trying to initialize my multitasking and i have the TSS loadded and everything just nothing changes(I have different segments for non-tss) so I'm pretty sure I need to jmp to the task and the intel manual is crap on executing tasks it just says "jmp to the TSS selector"
my current code is this
jmp 0x18:0 and my TSS is in selector 3(or 0x18)
it is actually like jmping to that for some reason though; it jmps to like a lower offset and the ending error is this:
I temporarily disable my IDT so it would show more than just "General Protection Fault"
edit2:nvm the segments don't change so its not working
my current code is this
jmp 0x18:0 and my TSS is in selector 3(or 0x18)
it is actually like jmping to that for some reason though; it jmps to like a lower offset and the ending error is this:
Code: Select all
00004300154i[CPU0 ] LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
00004300154e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00004300154i[SYS ] Last time is 1149649796
00004300154i[CPU0 ] protected mode
00004300154i[CPU0 ] CS.d_b = 32 bit
00004300154i[CPU0 ] SS.d_b = 32 bit
00004300154i[CPU0 ] | EAX=00000019 EBX=00000fff ECX=00000003 EDX=00000104
00004300154i[CPU0 ] | ESP=00000790 EBP=000007ec ESI=00000fff EDI=00163000
00004300154i[CPU0 ] | IOPL=0 NV UP DI PL NZ NA PO NC
00004300154i[CPU0 ] | SEG selector base limit G D
00004300154i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00004300154i[CPU0 ] | CS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00004300154i[CPU0 ] | DS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00004300154i[CPU0 ] | SS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00004300154i[CPU0 ] | ES:0008( 0001| 0| 0) 00000000 000fffff 1 1
00004300154i[CPU0 ] | FS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00004300154i[CPU0 ] | GS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00004300154i[CPU0 ] | EIP=000001fb (000001fb)
00004300154i[CPU0 ] | CR0=0x80000011 CR1=0 CR2=0x00000000
00004300154i[CPU0 ] | CR3=0x0009e000 CR4=0x00000000
edit2:nvm the segments don't change so its not working