vmware and FPU in kernel
Posted: Mon Apr 06, 2009 4:51 pm
Hi all, long time reader (but rarely a poster).
A little background:
I have been developing a kernel for a while and have decided to put some effort into a video driver. My plan is for the driver itself to offer a few basic drawing primitives to allow for future hardware acceleration. The idea being that it will function a little like display lists where the user space app can queue up "draw rectangle(...); draw line(...); draw bitmap(...);" and then commit that to the video driver.
In addition to this I have a fairly complete, libc and libstdc++ for my kernel land. The libc is something on the order of 80-90% complete and as standards compliant as possible. This includes the FPU ops for example, cos/sin/tan all boil down to the correct x86 FPU instructions. I've tested in user space and they work nicely.
The question
Anyway, I have been attempting to implement the VESA based software version of this and have some good success so far...except for things involving the FPU .
Lines, Squares, Pixels, Bitmaps...all work fine, because they operate on squares. Circles are another story .
I've been attempting to implement some circle drawing stuff which requires (at the least) a floating point division, sine and arccos. Unfortunately, vmware just locks up . I've tried debugging with bochs/qemu with confusing results. My test is I have a command which just does this in my kernel:
vmware: locks up in the sqrt (a little "printf debugging" shows it doesn't seem to enter the sqrt function, so it seems it is dying on the FPU load ops before the call).
qemu: prints correct answer
bochs: prints nan.
Is there anything special I need to do to setup a sane FPU environment in kernel land? I do a fsave/frstor on task switch. And I do an finit early in my kernel's "main" function. What am I missing?
A little background:
I have been developing a kernel for a while and have decided to put some effort into a video driver. My plan is for the driver itself to offer a few basic drawing primitives to allow for future hardware acceleration. The idea being that it will function a little like display lists where the user space app can queue up "draw rectangle(...); draw line(...); draw bitmap(...);" and then commit that to the video driver.
In addition to this I have a fairly complete, libc and libstdc++ for my kernel land. The libc is something on the order of 80-90% complete and as standards compliant as possible. This includes the FPU ops for example, cos/sin/tan all boil down to the correct x86 FPU instructions. I've tested in user space and they work nicely.
The question
Anyway, I have been attempting to implement the VESA based software version of this and have some good success so far...except for things involving the FPU .
Lines, Squares, Pixels, Bitmaps...all work fine, because they operate on squares. Circles are another story .
I've been attempting to implement some circle drawing stuff which requires (at the least) a floating point division, sine and arccos. Unfortunately, vmware just locks up . I've tried debugging with bochs/qemu with confusing results. My test is I have a command which just does this in my kernel:
Code: Select all
double d = sqrt(2.0);
printf("%f\n", d);
qemu: prints correct answer
bochs: prints nan.
Is there anything special I need to do to setup a sane FPU environment in kernel land? I do a fsave/frstor on task switch. And I do an finit early in my kernel's "main" function. What am I missing?