How to fetch data from TSS?
-
- Member
- Posts: 70
- Joined: Fri Nov 19, 2010 6:54 pm
How to fetch data from TSS?
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?
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?
Simple, the TSS is not a data segment. Put a label before the TSS data and use that.
-
- Member
- Posts: 70
- Joined: Fri Nov 19, 2010 6:54 pm
Re: How to fetch data from TSS?
Could you give an example?Thank you very much.Hangin10 wrote:Simple, the TSS is not a data segment. Put a label before the TSS data and use that.
- thepowersgang
- 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?
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.
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
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
-
- Member
- Posts: 70
- Joined: Fri Nov 19, 2010 6:54 pm
Re: How to fetch data from TSS?
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
Re: How to fetch data from TSS?
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.
-
- Member
- Posts: 70
- Joined: Fri Nov 19, 2010 6:54 pm
Re: How to fetch data from TSS?
Could you describe in detail?How to create an alias?and how to access tss?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 write some codes?thanks
-
- Member
- Posts: 223
- Joined: Thu Jul 05, 2007 8:58 am
Re: How to fetch data from TSS?
Please read the required knowledge page on the wiki.
- Combuster
- 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?
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.