Page 1 of 1

switching tasks

Posted: Tue Jun 06, 2006 5:51 pm
by earlz
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

Re:switching tasks

Posted: Tue Jun 06, 2006 7:54 pm
by Cjmovie
I'm just going out on a limb, but it'd be:

jmp TaskSelectorSeg:CodeLocation

Re:switching tasks

Posted: Tue Jun 06, 2006 9:08 pm
by earlz
i tried that but it doesn't go where it should; unless my tss is wrong

Re:switching tasks

Posted: Wed Jun 07, 2006 7:19 am
by paulbarker
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.

Re:switching tasks

Posted: Wed Jun 07, 2006 7:53 am
by Kemp
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

Posted: Wed Jun 07, 2006 9:09 am
by MidasLazy
I don't know TASM at all but what about

[tt]jmp far seg:offset[/tt]

Re:switching tasks

Posted: Wed Jun 07, 2006 10:51 am
by Dex4u
What about " jmp USER1_TSS:0"

Re:switching tasks

Posted: Wed Jun 07, 2006 10:59 am
by ti_mo_n
You can as well do "jmp tss:12345678". The offset part is required, but not used.

Re:switching tasks

Posted: Wed Jun 07, 2006 1:08 pm
by earlz
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:

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
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

Re:switching tasks

Posted: Wed Jun 07, 2006 3:35 pm
by Dex4u
Maybe these may help.