Page 1 of 1

How to fetch data from TSS?

Posted: Thu Feb 17, 2011 8:29 pm
by leetow2003
I want to fetch data from TSS,
first I define TSS in GDT:
dseg segment use16
gdt label byte
dummy descriptor <>
demotss descriptor <104,,,89h,>
demotss_sel =demotss-gdt
....
dseg ends

then I define the TSS segment:
DEMOTSSSEG SEGMENT PARA USE16
DW ?,0
DD ?
DW ?,0
DD ?
DW ?,0
DD ?
DW ?,0
DD 0 ;CR3
DD ? ;EIP
DW ?,? ;eflag
DD ? ;eax
DD ? ;ecx
DD ? ;edx
DD ? ;ebx
DD ? ;esp
DD ? ;ebp
DD ? ;esi
DD ? ;edi
DW ?, 0 ;es
DW ?, 0 ;cs
DW ?, 0 ;ss
DW ?, 0 ;ds
DW ?, 0 ;fs
DW ?, 0 ;gs
DW ?, 0
DW 0
DW $ + 2
DB 0FFH
DEMOTSSSEG ENDS

and then I initialize it:
mov bx,16
mov ax,DEMOTSSSEG
mul bx
mov demotss.basel,ax
mov demotss.basem,dl
mov demotss.baseh,dh

at last in p-mode:
mov ax,demotss_sel
LTR ax
mov ax,demotss_sel
mov ds,ax ;===error
mov ax,[2]
but I find when I add the instruction:mov ds,ax
the PC always restart,why?How to correct it?

Re: How to fetch data from TSS?

Posted: Thu Feb 17, 2011 10:40 pm
by Hangin10
Simple, the TSS is not a data segment. Put a label before the TSS data and use that.

Re: How to fetch data from TSS?

Posted: Thu Feb 17, 2011 11:07 pm
by leetow2003
Hangin10 wrote:Simple, the TSS is not a data segment. Put a label before the TSS data and use that.
Could you give an example?Thank you very much.

Re: How to fetch data from TSS?

Posted: Thu Feb 17, 2011 11:14 pm
by thepowersgang
no, we cannot give an example. If you do not know how to put a label at a location, you have bigger problems.

Also, please use code tags when posting source code to the forums.

Re: How to fetch data from TSS?

Posted: Fri Feb 18, 2011 2:30 am
by leetow2003
thepowersgang wrote:no, we cannot give an example. If you do not know how to put a label at a location, you have bigger problems.

Also, please use code tags when posting source code to the forums.

Code: Select all

DEMOTSSSEG SEGMENT PARA USE16
var1 DW ?,0 
var2 DD ? 
etc
DEMOTSSSEG ENDS
but I don't how to use it,could you tell me?

Re: How to fetch data from TSS?

Posted: Fri Feb 18, 2011 2:43 am
by rdos
When I create a TSS selector, I also create an alias with the same base & size. When I need to access the TSS, I use the alias. Both the TSS and the alias are kept in the thread-control block. If you are using a flat memory model, you can just save the base of the TSS, and access it through the base instead.

Re: How to fetch data from TSS?

Posted: Fri Feb 18, 2011 3:40 am
by leetow2003
rdos wrote:When I create a TSS selector, I also create an alias with the same base & size. When I need to access the TSS, I use the alias. Both the TSS and the alias are kept in the thread-control block. If you are using a flat memory model, you can just save the base of the TSS, and access it through the base instead.
Could you describe in detail?How to create an alias?and how to access tss?
Could you write some codes?thanks

Re: How to fetch data from TSS?

Posted: Fri Feb 18, 2011 7:30 am
by davidv1992
Please read the required knowledge page on the wiki.

Re: How to fetch data from TSS?

Posted: Fri Feb 18, 2011 9:15 am
by Combuster
Agreed. I've checked your posting history and it shows repeated lack of basic programming experience, and repeated ignorance of the other rules. Please come back after you have spent a few years learning to solve (simple) problems and you know to read documents. In your current state you won't be able to manage more than poking around existing code.