Page 1 of 1

Switching to task

Posted: Tue Oct 22, 2013 5:25 pm
by Jane1991c
Hey, I have succesfully loaded task0 with ltr instruction.
I have also prepared task1, here are parts of code:

Code: Select all

...

mov word [tss_1+4ch], 8 ; cs
mov word [tss_1+20h], proc_1 ;eip
mov word [tss_1+50h], 24 ;ss
mov word [tss_1+38h], 128 ;esp
mov word [tss_1+54h], 16
mov word [tss_1+48h], 32

cli
;enter PM Mode here


mov ax, 48
ltr ax

call dword 0x00000038 ; selector = 56 for tss1

loopme:
jmp loopme

proc1:
mov ax, 1h
iret

my gdt:
1. null
2. program, selector = 8
3. data, selector = 16
4. stack, sel = 24
5. screen, sel=32
6.my extra seg, sel=40
7. tss0, sel=48
8. tss1, sel=56

error:
00015175139e[CPU0 ] branch_near32: offset outside of CS limits
00015175139e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00015175139e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
What is wrong ? It seems it didnt use my selector 56. Why ?

Re: Switching to task

Posted: Tue Oct 22, 2013 6:10 pm
by Nable
> word > eip
> word > esp
Can you see any inconsistency here? So, upper words of 32-bit fields contain garbage.
There are also too many "magic" constants in this piece of code, so my static analyzer refused to check it further.

Re: Switching to task

Posted: Wed Oct 23, 2013 1:35 am
by Jane1991c
Nable wrote:> word > eip
> word > esp
Can you see any inconsistency here? So, upper words of 32-bit fields contain garbage.
There are also too many "magic" constants in this piece of code, so my static analyzer refused to check it further.
Dunno if i understood you properly, but here is version that fills whole value. Same error returned "branch_near32: offset outside of CS limits"


Code: Select all

...

; init tss_1
mov word [tss_1+4ch], 0x00000008 ; cs

mov word [tss_1+20h], 0x00000000
mov word [tss_1+20h], zadanie_1 ;eip

mov word [tss_1+50h], 0x00000018 ;24 ;ss
mov word [tss_1+38h], 0x00000080 ;128 ;esp
mov word [tss_1+54h], 0x00000010 ;16
mov word [tss_1+48h], 0x00000020 ;32

cli
;enter PM Mode here


mov ax, 48
ltr ax

call dword 0x00000038 ; selector = 56 for tss1

loopme:
jmp loopme

proc1:
mov ax, 1h
iret

tss_0	times 104 db 0
tss_1	times 104 db 0
I have noticed while debugging such instruction in bochs:
call .-32864 (0x00000038) ; that is my call dword 0x00000038

Seems like it dont understand that i want to run new task than normal procedure, whats wrong ?

What is wrong ?

PROBLEM SOLVED, REASON: WRONG EIP WAS SET BECOUSE OF ORG DECLARATION IN FILE, THANKS FOR HELP!

Re: Switching to task

Posted: Sat Oct 26, 2013 1:36 pm
by Combuster
here is (the) version that fills (the) whole value
mov word [tss_1+48h], 0x00000020 ;32
WRONG.

Start with proving mathematically that "0000000000000000" is a different number than "0" - and as much as that is an impossibility, so qualifies your change as nonsense. "mov word" explicitly says to do a 16-bit transfer - not whatever number you put there. On a real machine you are likely going to get garbage values for the remaining 16 bits.



Also, you didn't read the forum rules properly because you used colours. That also means that you missed all the requirements and useful tips on problem solving as well. Please go read them.