Re: Safely SHUTDOWN Device from Application

Tech-Archive recommends: Speed Up your PC by fixing your registry



On Sep 22, 6:03 pm, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
If you have only specific applications then you could designate one to be
the app that actually invokes sleep, but you'd still need IPC to have all of
the other apps tell you when they're ready to shut down, and again, you'll
likely need some form of timeout for them as well in case they don't report
in for any reason.

How you handle suspend is very much hardware dependent, so I can't really
tell you where it is.  If you have a power button, it likely generates some
form of interrupt at the processor or maybe a CPLD or whatever.  If you have
suspend currently working fromt hat button then you need to look at the
handler for that interrupt and *that* is where you need to intercept things.

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

"Neo" <pride...@xxxxxxxxx> wrote in message

news:848a4bfe-0159-489d-bd58-2e6324ed8edb@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 19, 10:26 pm, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:



That's going to be very device-specific. The handler for device suspend
needs to be modified to send out the notification. An example of how this
could be done is the way Eurotech does it (not sdaying it's the best way,
just *a* way). You can set a registry option to have the power button
interrupt just set a system event. It's then up to the app to take
whatever
actions it needs and then call the API to actually suspend.

The problem in your case is the arbitrary desire for "any" app to be
notified and given time. How will they be notified (an even is simple
enough)? More important is how will the OS/kernel know when all of those
apps are "done" and are in a safe state? Would they send an event back?
How would the OS know who all should reply back? What if the app is hung
and not responding? There are a *lot* of variables to this - and I can't
see any general solution.

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

"Neo" <pride...@xxxxxxxxx> wrote in message

news:af5092a1-16f1-4c93-b4d8-54ee83b65cb0@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 18, 7:48 pm, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:

Well the first thing you have to define is "shut down". What does that
mean
in your context? CE devices don't generally have a shut down state, but
rather a suspend state. In that case sending a VK_POWEROFF usually is
all
you need (no clue if the emulator supports this though - IIRC Bruce
Eitman
blogged about doing this recently). If you mean "shut all power off"
then
that's going to be device dependent and the OEM would be the only one
who
could tell you how. If you mean a hard reset then a call to
KernelIoControl
is a common way to achieve it, but again the device must have support
for
it.

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

"Neo" <pride...@xxxxxxxxx> wrote in message

news:132d7334-f76b-4d71-b9bd-054b3cb82efd@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi!

I am working with WinCE 5.0 and x86 Emulator. I wish to write an
application to safely shutdown the device. After a few searches I
could note that I need to use IOCTLs (if I'm not wrong!) and there
are existing implementations of Suspend, Reboot but nothing for safely
shutting down the device.I have identified some of the functions that
might be useful like:
void OEMPowerOff(void)
void OALCPUPowerOff(void)
IOCTL_POWER_SET
IOCTL_POWER_GET
IOCTL_REGISTER_POWER_RELATIONSHIP
KernelIOControl()
I wish to know what all things I need to know, apart from these and
how do I put all these things together!

Regards,
-- Neo

By 'Safe Shutdown', I meant that any application writing/reading to/
from the Flash should be notified about the system going down for a
shut down (instead of aborting it) so that the application gets a fair
chance for it's graceful exit and then a regular shutdown (power off)
of the platform should be carried. I think, second part of the issue
(shutting down the platform) might be specific to the Device but, I
think we should be able to perform the 1st step (notifying all the
applications interacting with the Flash resulting in their graceful
exit). How can we achieve this? Please guide me on this.

Thanks,
Neo

Thanks for the reply Chris. What if there are only specific
applications of mine that might deal with the flash and no other user
applications apart from these are going to run on the device? In that
case, is there a mechanism by which we can notify these applications
about the system going for a shutdown? Let's not consider the case
where one of the applications is not responding. By "The handler for
device suspend" - you mean the routine OEMPowerOff(). Am I correct? If
yes, what kind of changes I might require to do?

Warm Regards,
Neo

You mean, the app that we'll write to carry out the shutdown process
will invoke sleep after notifying all the desired (known) applications
about the shutdown using an IPC? (Hence giving them a chance to safely
exit). I did not know prior to this discussion what were the means to
do IPC on WinCE devices. After few searches I find that: Message
Queues, Services.exe and Shared Memory via File Mapping are amongst
the better ways to do that. (Ref: http://blogs.msdn.com/cenet/archive/2005/07/13/438424.aspx).
What mechanism might be appropriate in our case? I think Message
Queues would be both appropriate and relatively easy for a newbie like
me to use? Any comments?

As of now, I don't have the hardware with me. I think I'll need to
find the IOCTL for the Suspend (of the emulator) and find a mapping of
that IOCTL to a routine in the Source, which I can modify. If this
approach is correct, can I use the Call Profiler to know these things?
Or is there a better way to find out this info?

Thanks for all the help,
Neo
.


Quantcast