How to fetch data from TSS?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

How to fetch data from TSS?

Post 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?
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: How to fetch data from TSS?

Post by Hangin10 »

Simple, the TSS is not a data segment. Put a label before the TSS data and use that.
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

Re: How to fetch data from TSS?

Post 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.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: How to fetch data from TSS?

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

Re: How to fetch data from TSS?

Post 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?
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: How to fetch data from TSS?

Post 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.
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

Re: How to fetch data from TSS?

Post 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
davidv1992
Member
Member
Posts: 223
Joined: Thu Jul 05, 2007 8:58 am

Re: How to fetch data from TSS?

Post by davidv1992 »

Please read the required knowledge page on the wiki.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to fetch data from TSS?

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply