cybercat
驱动牛犊
驱动牛犊
  • 注册日期2001-03-27
  • 最后登录2005-07-29
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:4213回复:6

在设备驱动程序中(WDM or Kernel Mode)中如何使用浮点数

楼主#
更多 发布于:2001-03-29 08:00
在设备驱动程序中(WDM or Kernel Mode)中如何使用浮点数
rayyang2000
管理员
管理员
  • 注册日期2001-03-23
  • 最后登录2012-09-13
  • 粉丝3
  • 关注0
  • 积分1036分
  • 威望925点
  • 贡献值3点
  • 好评度823点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2001-03-29 08:22
在DDK的help里面查FLOATOBJ_Xxx
天天coding-debugging中----超稀饭memory dump file ======================================================== [b]Windows Device Driver Development and Consulting Service[/b] [color=blue][url]http://www.ybwork.com[/url][/color] ========================================================
znsoft
管理员
管理员
  • 注册日期2001-03-23
  • 最后登录2023-10-25
  • 粉丝300
  • 关注6
  • 积分910分
  • 威望14796点
  • 贡献值7点
  • 好评度2410点
  • 原创分5分
  • 专家分100分
  • 社区居民
  • 最爱沙发
  • 社区明星
板凳#
发布于:2001-03-29 08:40
在专栏文章中有一篇文章是介绍这个的. 用float作关键字搜索一下。
http://www.zndev.com 免费源码交换网 ----------------------------- 软件创造价值,驱动提供力量! 淡泊以明志,宁静以致远。 ---------------------------------- 勤用搜索,多查资料,先搜再问。
cxf
cxf
驱动牛犊
驱动牛犊
  • 注册日期2001-03-23
  • 最后登录2002-02-21
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2001-04-07 14:58
没有搜索到,是不是在本站恢复之前的帖子?
dazzy
驱动中牛
驱动中牛
  • 注册日期2001-03-23
  • 最后登录2008-08-12
  • 粉丝1
  • 关注0
  • 积分0分
  • 威望10点
  • 贡献值1点
  • 好评度10点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2001-04-08 17:36
Using Floating Point or MMX in a WDM Driver
Kernel-mode WDM drivers for Windows Me, Windows 98, Windows 98 SE, and Windows 2000 must follow certain guidelines for using floating-point operations, MMX, 3DNOW!, or Intel's SSE extensions.

Kernel-mode WDM drivers must wrap use of the floating-point unit (FPU) between calls to KeSaveFloatingPointState and KeRestoreFloatingPointState. (See the Kernel-Mode Drivers Reference in the Windows 2000 DDK for details.) Failure to use these routines can cause calculation errors in concurrent user-mode applications.

KeSaveFloatingPointState saves the FPU state of the currently running application in a system-provided buffer and reinitializes the FPU for the driver. The routine takes a single parameter, a driver-allocated buffer, which provides support for nested calls. If KeSaveFloatingPointState is called twice at the same IRQL without an intervening call to KeRestoreFloatingPointState, the nonvolatile FPU state is saved in the driver-allocated buffer. (The caller must save volatile state from ST0-ST7, MMX0-MMX7, and XMMI0-XMMI7.)

If the system is low on memory, KeSaveFloatingPointState can fail. Drivers must check the returned status and, if a failure occurs, must not access the FPU.

When a driver has finished using the FPU, it calls KeRestoreFloatingPointState to restore the previous application state.

The following example shows how a WDM driver should wrap its FPU access:

KFLOATING_SAVE     saveData;
NTSTATUS         status;
double         floatValue;

status = KeSaveFloatingPointState(&saveData);

if (NT_SUCCESS(status)) {

    floatValue = 1.0;
    KeRestoreFloatingPointState(&saveData);
}
In the example, the assignment to the floating-point variable occurs between calls to KeSaveFloatingPointState and KeRestoreFloatingPointState. Because any assignment to a floating-point variable uses the FPU, drivers must ensure that KeSaveFloatingPointState has returned without error before initializing such a variable.

On Windows 2000, WDM drivers can call KeSaveFloatingPointState at IRQL <= DISPATCH_LEVEL. However, use of floating-point operations is not supported in interrupt service routines (ISRs). On Windows 2000, the FPU is set to long real precision (that is, double or 53-bit), with all exceptions masked, upon return from KeSaveFloatingPointState.

On Windows Me, Windows 98, and Windows 98 SE, drivers that use the FPU must adhere to the following guidelines:

Access the FPU only from passive-level work items or worker threads.
Do not call KeSaveFloatingPointState or attempt to use the FPU or MMX from a DPC, from an IOCTL handler, or from any other handler called from user mode. Do not try to circumvent this rule; there is no driver-implementable workaround that is guaranteed to operate correctly on all processors.
Reload the FPU control word with 0x27F after KeSaveFloatingPointState returns. Doing so ensures that the FPU is set to long real precision (double or 53-bit), with all exceptions masked, as on Windows 2000.
For Windows 98 and Windows 98 SE only, always call KeSaveFloatingPointState at IRQL PASSIVE_LEVEL. Calling this routine at IRQL DISPATCH_LEVEL can cause a system crash.
cybercat
驱动牛犊
驱动牛犊
  • 注册日期2001-03-27
  • 最后登录2005-07-29
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2001-04-08 21:50
谢谢各位的帮助,我终于可以把我的控制代码加到设备驱动里了
hero_wzhj
驱动牛犊
驱动牛犊
  • 注册日期2002-12-20
  • 最后登录2003-06-21
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2003-06-21 15:43
游客

返回顶部