setPowerState 总是在启动后调用吗?
我正在为 OS X 上的 USB 设备开发内核驱动程序。添加 setPowerState
处理程序后,我注意到它在 start
后立即调用唤醒事件方法被调用。在 OS X 10.6 上,当我加载驱动程序以及插入 USB 设备时,会发生这种情况。kernel.log
显示我在每个方法调用中所做的 iolog 条目:
...(attach device)
MyDriver: Initializing
MyDriver: Probing
MyDriver: Starting
MyDriver: Waking
...(detach device)
MyDriver: Stopping
MyDriver: Freeing
我可以预期每次启动后都会发生唤醒吗?
如果是这样,将我的大部分初始化代码放入 setPowerState
处理程序(知道它将在启动后调用)是否合理?
OS X 10.4 和 10.5 也是如此吗?
I'm developing a kernel driver for a USB device on OS X. After adding the setPowerState
handler, I'm noticing that it's called for a wake event immediately after the start
method is called. This happens on OS X 10.6 when I load the driver, and when I plug the USB device in.
The kernel.log shows the iolog entries I'm making on each method call:
...(attach device)
MyDriver: Initializing
MyDriver: Probing
MyDriver: Starting
MyDriver: Waking
...(detach device)
MyDriver: Stopping
MyDriver: Freeing
Can I expect wakeup to occur after start every time?
If so is it reasonable to put most of my initialization code into the setPowerState
handler, knowing it will be called after start?
Is this true for OS X 10.4 and 10.5 as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以,只要您的驱动程序已正确连接到电源层并已正确初始化电源管理(请参阅下面实施基本电源管理标题下的链接。
这不仅合理,而且是请注意,唯一不在
setPowerState
中且位于start
或其他位置的初始化代码是仅加载一次且具有预期的电源状态处理代码的内容。睡眠和唤醒事件开始
,请参阅此处。Mac
OS X 版本中 setPowerState 之间的唯一区别是,在 Mac OS X 10.5 及更高版本中,setPowerState 在其自己的线程中调用,而10.4 它作为现有线程的一部分被调用。
Yes you can, provide your have your driver is correctly connected to the Power Plane and has correctly initialised Power Managment (see the link below under the Implementing Basic Power Management heading.
It is not only reasonable but it is expected. Note that the only initialization code that make not be in
setPowerState
and that is instart
or elsewhere is stuff that is only loaded the once and has power state handling code for sleep and wake events instart
.For more information see here.
The only difference between setPowerState in Mac OS X versions is that in Mac OS X 10.5 and newer, setPowerState is called in its own thread, whilst 10.4 it is called as part of the existing thread.