How do I know what hexadecimal value goes into ax for ltr?

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
chrissacchi
Posts: 15
Joined: Sat Sep 15, 2012 5:02 pm
Libera.chat IRC: csacchi

How do I know what hexadecimal value goes into ax for ltr?

Post by chrissacchi »

How do I know what hexadecimal value goes into the AX for LTR (Load Task Register)? My TSS is the 7th entry for my data section of my GDT. Which value do I use?

bochs prints the one message that is important to look at:

Code: Select all

LTR: doesn't point to an available TSS descriptor!
https://github.com/christophersacchi/RazorOS
"... you notice that this scanner will... woah!"
"Moving right along!"
"That must be, uh. That must be why we're not shipping Windows 98 yet..."
"Absolutely. Absolutely."
feryno
Member
Member
Posts: 73
Joined: Thu Feb 09, 2012 6:53 am
Location: Czechoslovakia
Contact:

Re: How do I know what hexadecimal value goes into ax for lt

Post by feryno »

Hi chrissacchi,
did you execute the LTR AX only once or more times (more times e.g. in case of multitasking)?
If bochs reports the error message for the first LTR AX then you have an error/mistake in your GDT/TSS or you put wrong value into AX, if the error message appears at the second LTR AX (with the same AX value and the first LTR AX passed OK) then you need to implement this:
When executing the LTR for the first time - the available task changes to busy task (1 bit in GDT changes from 0 to 1). If you want to do LTR for the second time then change busy task to available task before executing the LTR AX (just change 1 bit from 1 to 0 in GDT - refer to CPU manuals).
hypervisor-based solutions developer (Intel, AMD)
chrissacchi
Posts: 15
Joined: Sat Sep 15, 2012 5:02 pm
Libera.chat IRC: csacchi

Re: How do I know what hexadecimal value goes into ax for lt

Post by chrissacchi »

I executed it only once, but I don't know which value to put in AX for the LTR instruction. Is there a specific way to find out?
https://github.com/christophersacchi/RazorOS
"... you notice that this scanner will... woah!"
"Moving right along!"
"That must be, uh. That must be why we're not shipping Windows 98 yet..."
"Absolutely. Absolutely."
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: How do I know what hexadecimal value goes into ax for lt

Post by AJ »

Hi,

Just looking at the error output, is your GDT limit correct? You can find how to use LTR in the intel Software Developers Manuals.

Cheers,
Adam
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: How do I know what hexadecimal value goes into ax for lt

Post by egos »

chrissacchi wrote:I executed it only once, but I don't know which value to put in AX for the LTR instruction. Is there a specific way to find out?
Do you know what a selector is? In simplest case it's an offset of descriptor in GDT.
Last edited by egos on Sat Mar 14, 2015 11:57 am, edited 1 time in total.
If you have seen bad English in my words, tell me what's wrong, please.
Mohsen
Posts: 8
Joined: Tue Feb 18, 2014 11:25 am

Re: How do I know what hexadecimal value goes into ax for lt

Post by Mohsen »

you can tell the selector by multiplying your entry number which is 7 (remember to start counting from zero) by the size of each GDT entry which is 8 so your selector is 0x38.
If it works please tell me.
Post Reply