Exception 7 - CoProcessor

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
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Exception 7 - CoProcessor

Post by prajwal »

I'm getting Exception 7 when trying to Use CoProcessor (80287/387) after doing Context Switch... Reason it says is that the context of CoProcessor is not changed...

How to do this? Where will I get Info on this
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Exception 7 - CoProcessor

Post by JAAman »

after a context switch the CPU will throw an exception when executing a FPU instruction

the reason for this is so that the OS can switch the context of the FPU for the next process -- and the context doesn't need to be changed on every task-swap because most processes wont use the FPU (or use it only occasionally)
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Re: Exception 7 - CoProcessor

Post by prajwal »

If at all the FPU is used after context switch, then is it necessary to change
the FPU context? if Yes how to do this?

I'm using GCC compiler to compile the OS code.... the GCC would have
generated instuctions telling CPU to use FPU. Is there any option to GCC
telling not to generate code to use CoProcessor.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Exception 7 - CoProcessor

Post by JAAman »

normally the FPU is not used much in the kernel, though it may depend on what your doing
GCC will only generate FPU statements if you are doing floating point math

you can switch the FPU context by saving and restoring the registers just like you do with the CPU context but there are some instructions to help you though i can't remember what they are right now (check intel vol.3)
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Re: Exception 7 - CoProcessor

Post by prajwal »

Thanks for clarifying my doubt
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Exception 7 - CoProcessor

Post by Da_Maestro »

When you change contexts, you can set a flag to tell the processor that you are changing the FPU context. I've forgotten which flag this is (NT?). When you set that, the CPU won't through exception 7. But remember this means that you have to change FPU context on every context switch. On older processors this can get intensive....
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Exception 7 - CoProcessor

Post by JAAman »

no its not NT (which is in the FLAGS register)

its TS (which is in CR0)

check exception 7: vol.3, pg 5-29
and

CR0.TS: vol.3, pg 2-14
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Re: Exception 7 - CoProcessor

Post by prajwal »

Where can I get this Info (links) online "check exception 7: vol.3, pg 5-29 "
Intel Programmers Refermce manual says to go thru
Intel System Software Writers Guide to see a sample of Changing
FPU Context on Exception 7.
But I Serached to my level best for Intel System Software Writers Giude on net...
I didn't find....

Where can i get this....?
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Exception 7 - CoProcessor

Post by JAAman »

not sure, never heard of "intel system software writers guide"

the references i gave were for

IA-32 Intel Architecture Software Developer's Manual:
Volume 3:System Programming Guide
section 5
page 29

and

IA-32 Intel Architecture Software Developer's Manual:
Volume 3:System Programming Guide
section 2
page 14
Post Reply