<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1053373784078711683</id><updated>2011-07-07T16:16:02.254-07:00</updated><category term='linux'/><category term='tools'/><category term='bootloader'/><category term='news'/><category term='debugging'/><category term='wifi'/><category term='performance monitor'/><category term='mistakes'/><category term='fun at work'/><category term='registry'/><category term='cloning'/><category term='videos'/><category term='low power mode'/><category term='celog'/><category term='oal'/><category term='wince'/><category term='nb0'/><category term='monitoring'/><category term='power manager'/><category term='application'/><category term='aboutme'/><category term='activesync'/><category term='help'/><category term='drivers display'/><category term='cetk'/><category term='bluetooth'/><category term='usbclient'/><category term='ndis'/><category term='tutorials'/><category term='Bin'/><category term='drivers'/><category term='wzc'/><category term='pxa'/><category term='kernel'/><category term='keyboard'/><category term='performance'/><category term='network'/><category term='accord'/><category term='interrupt'/><category term='porting'/><title type='text'>WinCE</title><subtitle type='html'>Sharing my experience in windows ce.. :)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>48</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-4677304243654500891</id><published>2010-04-18T22:06:00.001-07:00</published><updated>2010-04-22T05:41:55.945-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nb0'/><category scheme='http://www.blogger.com/atom/ns#' term='Bin'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='mistakes'/><category scheme='http://www.blogger.com/atom/ns#' term='bootloader'/><title type='text'>Extending Boot loader - Pitfalls &amp; Experiences - Part 2</title><content type='html'>&lt;div style="text-align: justify;"&gt;Ok, so for implementing access to a SD Card from boot loader what all we need to implement? Here goes:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;SD Card block read, identification routines&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Routines to identify, validate and read the partition information from MBR&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Routines to perform the FAT (VFAT) data from card.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;If you check out the sources code in U-boot, these functionalities has been divide in to the following modules:&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a href="http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=tree;hb=a47a12becf66f02a56da91c161e2edb625e9f20c"&gt;http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=tree;hb=a47a12becf66f02a56da91c161e2edb625e9f20c&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;pxa_mmc.c (/drivers/mmc/)&lt;/li&gt;&lt;li style="text-align: justify;"&gt;part.c (/disk/)&lt;/li&gt;&lt;li style="text-align: justify;"&gt;part_dos.c (/disk)&lt;/li&gt;&lt;li style="text-align: justify;"&gt;fat.c (fs/fat)&lt;/li&gt;&lt;li style="text-align: justify;"&gt;file.c (fs/fat)&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If you directly take the relevant headers and these source files and compile it along E-Boot, of course, you will end up in lot of error, mostly related to &lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;data types&lt;/li&gt;&lt;li style="text-align: justify;"&gt;use of __attribute__&lt;/li&gt;&lt;li style="text-align: justify;"&gt;structure and macros which are present in Linux headers&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;Once the errors have been resolved (of course, I am going to leave it up to you), I first enabled and invoked the SD CARD detection routines, I was able to detect the SD CARD, but seemed to failing in reading the MBR, on dumping it, I observed that some bits are not the same as the actual data on SDCARD. So I posted the same on to U-boot mailing list.&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://old.nabble.com/-U-Boot--MMC-problem-in-PXA270-hardware-to27206457.html#a27225880"&gt;&lt;/a&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;a href="http://old.nabble.com/-U-Boot--MMC-problem-in-PXA270-hardware-to27206457.html#a27225880"&gt;http://old.nabble.com/-U-Boot--MMC-problem-in-PXA270-hardware-to27206457.html#a27225880&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Then I figured out that the GPIO configuration was getting overridden in another place in code. Corrected it and there it was working like a charm.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Now I enabled, the FAT access module, here again I was stumped with another problem, the compilation was happening properly, but the Flash Image (Eboot.Nb0), was not generating properly. I.e., I observed that there was no change in behavior if I flash the image, with new functionality, also the time stamp on the file was not updating for NB0 file after compilation.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If I disable the new code added, the Image generation was happening properly. So there I was stuck again with another strange problem. So I went through the code again. After some pain staking and careful analysis, I noticed on thing, there were some array declarations like the following, through out the code:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;blockquote&gt;__u8 get_vfatname_block[MAX_CLUSTSIZE];&lt;/blockquote&gt;The macro MAX_CLUSTSIZE, was having the value 65536 . So it is creating an array of very huge size.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So why didn't it create a problem in BIN file creation, instead the problem is showing up NB0 file creation? Answer is very simple:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;blockquote&gt;BIN files are something similar to a loader, i.e. they will have a predefined record format, and will a piece of loader code to unpack the same. On the other hand, NB0 or ROM Image files are like how the Program will be present in memory, when it is loaded.&lt;/blockquote&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;What happened was that, when trying to create spaces for all the arrays that had been declared in code, the NB0 file creation was failing (Although it was not shown as a warning or error while building). The size of Rom Image for boot loader is restricted to 256KBytes in Eboot.bib.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Now to work around this problem, I used the free memory in RAM and changed these arrays to pointers and initialized them to some addresses in RAM. Now, I had the module working , with reading of any content in an SD Card.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Now moving on to USB Client Upgrade implementation, I will explain the things later on in the next post&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-4677304243654500891?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/4677304243654500891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=4677304243654500891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4677304243654500891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4677304243654500891'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2010/04/extending-boot-loader-pitfalls_18.html' title='Extending Boot loader - Pitfalls &amp; Experiences - Part 2'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6387634354294229878</id><published>2010-04-18T20:38:00.000-07:00</published><updated>2010-04-18T22:06:40.095-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='mistakes'/><category scheme='http://www.blogger.com/atom/ns#' term='bootloader'/><title type='text'>Extending Boot loader - Pitfalls &amp; Experiences - Part 1</title><content type='html'>&lt;div style="text-align: justify;"&gt;Sometimes it becomes required to extend the existing boot loader, mostly for implementing functionalities like firmware upgrade over a variety of medium like USB Pen Drive, USB Client or even a Micro SD Card. In most of the cases, the dead lines (of course always it will be like it) will be very close too.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;For the current project, which I am working now, I had to implement such an upgrade over USB Client (which would be used in production team) and a Micro SD Card based upgrade(which will be used by the end users) in the Windows CE Boot loader(E-Boot). &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Previously I was able to port, DAS U-boot and Embedded Linux on the same hardware. Anyone who had worked on U-boot, will definitely know about the advantages and the amount of features that it exports for working on an embedded system hardware. It had the implementation of SD Card access with FAT file system. Now for getting around with the task of firmware upgrade assigned to me, within the time limit, was to make use of the code present in U-boot for MMC Card read operations.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Now that I had chosen what I had to do, I started the analysis of what needs to be done for porting. These were the major difference that I was able to observe between the two systems - Windows CE Boot loader and U-boot:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;ul&gt;&lt;li&gt;Compilers used for building both of them were completely different. E-Boot was using Microsoft's Cross compiler for ARM. While U-Boot was using GNU C Compiler. This itself is one of the major bottlenecks as the constructs used in one compiler might not be available in the other one. For instance, __attribute__ which was used a lot in U-Boot, was specific to GCC.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;The source code of U-Boot was tightly coupled with Linux. The headers that were being used, data structure (for maintaining list etc), were taken from Linux source code.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;The data types (typedefs mostly), available and used were a lot, for the same unsigned char, there were lot of typedefs like uint8_t, u8. Same goes for other types too.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;There were intelligent mechanisms using macros in U-Boot through various header files for almost every platforms that were available today. That made writing new source code virtually easy. &lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Then again the objective of my task was to, integrate the module from U-Boot on to E-Boot.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So how do I achieve this? Will explain the details in next post&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6387634354294229878?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6387634354294229878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6387634354294229878' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6387634354294229878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6387634354294229878'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2010/04/extending-boot-loader-pitfalls.html' title='Extending Boot loader - Pitfalls &amp; Experiences - Part 1'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-2132640274017905572</id><published>2009-09-22T21:42:00.001-07:00</published><updated>2009-09-22T21:49:11.285-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='news'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Windows CE 6.0 R3</title><content type='html'>Microsoft has announced the release of Windows CE 6.0 R3 in market.  The major enhancement is going to be in terms of UI by bringing in native support for Mircosoft Silverlight.&lt;br /&gt;&lt;br /&gt;Downloads will be available by 10/2009. So get ready for an upgrade.&lt;br /&gt;&lt;br /&gt;I am waiting for the release for giving it a try.&lt;br /&gt;&lt;br /&gt;Check the following links for more information&lt;br /&gt;&lt;a href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/default.mspx?WT.mc_ID=FY10_CE"&gt;Mircosoft Page&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Post about &lt;a href="http://www.windowsfordevices.com/c/a/News/Windows-CE-60-R3-BSP-for-TI-OMAP35x-EVM/"&gt;BSquare BSP support for WINCE6.0 R3&lt;/a&gt; in WindowsFordevices.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-2132640274017905572?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/2132640274017905572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=2132640274017905572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2132640274017905572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2132640274017905572'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/09/windows-ce-60-r3.html' title='Windows CE 6.0 R3'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-3172969274352240263</id><published>2009-07-20T21:11:00.000-07:00</published><updated>2009-07-20T21:14:18.285-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='help'/><title type='text'>Social Bookmarking</title><content type='html'>Guys,&lt;br /&gt;&lt;br /&gt;I am putting together a social bookmarking page @ delicious.com. Here I will keep on posting whatever useful information that I will find on Windows CE in internet. Hope it would be useful for you guys :). Here is the link&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;a href="http://delicious.com/vaisakhps/windowsce"&gt;http://delicious.com/vaisakhps/windowsce&lt;/a&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-3172969274352240263?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/3172969274352240263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=3172969274352240263' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3172969274352240263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3172969274352240263'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/07/social-bookmarking.html' title='Social Bookmarking'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6966173947388076094</id><published>2009-06-28T00:36:00.001-07:00</published><updated>2009-06-28T01:29:58.393-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='porting'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='bootloader'/><title type='text'>Porting of a BSP - SDRAM</title><content type='html'>&lt;div style="text-align: justify;"&gt;While working on BSP of Windows CE, we will come across cases when we have to port an existing BSP to another hardware. This hardware may have only minor changes like certain peripherals and reducing and/or increasing of memory. I will explain what needs to be done for some of the scenarios involving porting in the upcoming post.&lt;br /&gt;&lt;br /&gt;In thos post, I will explain how to systematically change the software when the SDRAM in a hardware is changed. For example, the original BSP had a 32-bit SDRAM interface. But the new hardware is having a 16-bit interface instead.&lt;br /&gt;&lt;br /&gt;Before jumping on to changing the code (as the hardware guys will always say, "you just change this bit, it will work straight away...", no pun intented, because it  was always like that in my experience and ended up doing a lot of rework ), you need to prepare somethings before doing that.&lt;br /&gt;&lt;br /&gt;If you are having a ICE (In Circuit Emulator), that would be of great help, as you can test and troubleshoot a lot of key aspects involving this change.&lt;br /&gt;&lt;br /&gt;Do some ground work before jumping in:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Familiarize yourself with the datasheet of the processor which you are using (I have been working on PXA27x on sometime, so will explain based on that).&lt;/li&gt;&lt;li&gt;Prepare some assembly level (or C if you are not familair with assembly routines), which you can run on ICE and check the hardware. Especially whether you are able to access the new SDRAM.&lt;/li&gt;&lt;li&gt;Run some preliminary tests on the SDRAM like writing certain portions of and verifying it.&lt;/li&gt;&lt;li&gt;Scrutinize and tune the SDRAM timing values as they play a very important role in system's performance.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;br /&gt;Now lets get on to the practical side. In PXA27x processor, for changing the sdram access from 32-bit to 16-bit and vice-versa can be done by clearing and setting the DWID0 and DWID2 bits in MDCNFG register depending on which bank the SDRAM located.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Once you are through with these steps, you are confidently start the modification involved in OS.  Till now what I explained, looks good in theory, but needs a lot of analysis and patience.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;While putting together the changes required in the Windows CE BSP, these are the aspects that you need to concentrate on :&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;The memory initialisation for 16-bit interface&lt;/li&gt;&lt;li&gt;The oem address table change (if required to change the SDRAM size)&lt;/li&gt;&lt;li&gt;Memory parameters in the BIB files (especially config_cebase.bib)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;In the mainstone platform the switch to 16-bit mode can be done by setting the macro xlli_SDRAM_16BIT. Check the related code in WINCE600\PLATFORM\COMMON\SRC\SOC\PXA27X_MS_V1\XLLP\SOURCE\xlli_lowlev_init.s.&lt;br /&gt;&lt;br /&gt;In config_cebase.bib, change the memory size considering the new ranges and change the address mapping in oemaddrtab_cfg.inc.&lt;br /&gt;&lt;br /&gt;With these changes, the bootloader and operating system should move into 16-bit SDRAM mode.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Consider any XScale PXA27x BSP based which is based on the Mainstone III platform. Thanks to the Mainstone BSP developers ofcousrse,&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6966173947388076094?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6966173947388076094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6966173947388076094' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6966173947388076094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6966173947388076094'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/porting-of-bsp-sdram.html' title='Porting of a BSP - SDRAM'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5913209533777026826</id><published>2009-06-18T20:33:00.000-07:00</published><updated>2009-06-18T20:47:57.918-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='drivers display'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Accessing DrvEscape</title><content type='html'>In display drivers, DrvEscape is a function to retrieve information from a device that is not available in DDI for example, issuing a DrvEscape to the PXA27X display driver with GETGXINFO parameters will fill in the GAPI data structure.&lt;br /&gt;&lt;br /&gt;For accessing the DrvEscape routines, the following code segment can be used:&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;br /&gt;  {&lt;br /&gt;          HDC hDC = NULL;&lt;br /&gt;          DWORD Status;&lt;br /&gt;          CEDEVICE_POWER_STATE pwrState = D0;&lt;br /&gt;          hDC = CreateDC(NULL, NULL, NULL, NULL);&lt;br /&gt;          if (NULL != hDC)&lt;br /&gt;          {&lt;br /&gt;             pwrState = D0;&lt;br /&gt;             Status= ExtEscape(hDC, IOCTL_POWER_SET,&lt;br /&gt;                                  0, NULL,&lt;br /&gt;                                  sizeof(pwrState), (LPSTR)&amp;amp;pwrState );&lt;br /&gt;              ReleaseDC(NULL,hDC);&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This code will open the display driver and will issue a IOCTL_POWER_SET command to make the display ON. In the PXA27X display driver, uses two display buffers, one for the filling in of graphic data, another a blank buffer , which will be used during D2 to D4 modes.&lt;br /&gt;&lt;br /&gt;So if the display driver is in D2-D4 mode, this DrvEscape will bring the driver into D0. This will be equivalent of using &lt;span id="nsrTitle"&gt;SetDevicePower, but Microsoft is not recommending the usage of such APIs as it restricts the device self-management.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5913209533777026826?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5913209533777026826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5913209533777026826' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5913209533777026826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5913209533777026826'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/accessing-drvescape.html' title='Accessing DrvEscape'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-918063633458505548</id><published>2009-06-12T22:55:00.000-07:00</published><updated>2009-06-12T23:05:57.545-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bluetooth'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Notification for Bluetooth stack Initialisation</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);"&gt;For checking whether the bluetooth stack is up and initialised, you can make use of the manual reset event BTH_NAMEDEVENT_STACK_INITED (L"system/events/bluetooth/StackInitialized").&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You can get more information on this &lt;/span&gt;&lt;a style="color: rgb(0, 0, 0);" href="http://msdn.microsoft.com/en-us/library/aa915818.aspx"&gt;page&lt;/a&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-918063633458505548?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/918063633458505548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=918063633458505548' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/918063633458505548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/918063633458505548'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/notification-for-bluetooth-stack-to-be.html' title='Notification for Bluetooth stack Initialisation'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5522764704682853209</id><published>2009-06-11T21:15:00.001-07:00</published><updated>2009-06-11T21:19:43.109-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><title type='text'>Experiencing system slow down in ROM based FS?</title><content type='html'>If you are experiencing system performance issues in ROM based File systems, here is a nice tweak to boost up the performance. Most of the times, this slowdown will be due to constant registry flushing in to ROM in background.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;[HKEY_LOCAL_MACHINE\init\BootVars]&lt;br /&gt; "&lt;span style="background-color: rgb(59, 151, 211);" &gt;RegistryFlags&lt;/span&gt;"=dword:2&lt;/blockquote&gt;If this variable is set to 1, it will enable aggressive flushing of registry on to ROM. Setting it to 2 will disable background flushing and can improve performance of system significantly.&lt;br /&gt;&lt;br /&gt;Reference: http://msdn.microsoft.com/en-us/library/aa914382.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5522764704682853209?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5522764704682853209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5522764704682853209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5522764704682853209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5522764704682853209'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/experiencing-system-slow-down-in-rom.html' title='Experiencing system slow down in ROM based FS?'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-8181830644895240202</id><published>2009-06-11T21:10:00.000-07:00</published><updated>2009-06-11T21:13:01.644-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oal'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='cloning'/><title type='text'>Cloning OALIOCTL</title><content type='html'>In one of my previous posts, I mentioned about&lt;a href="http://devwince.blogspot.com/2009/06/adding-kernel-ioctl.html"&gt; cloning OALIOCTL&lt;/a&gt;, was thinking of writing about it. But &lt;a href="http://geekswithblogs.net/BruceEitman/Default.aspx"&gt;Bruce &lt;/a&gt;have already written about. And it was my reference too. So&lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/07/02/platform-builder-clone-public-code.aspx"&gt; check it out&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-8181830644895240202?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/8181830644895240202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=8181830644895240202' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/8181830644895240202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/8181830644895240202'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/cloning-oalioctl.html' title='Cloning OALIOCTL'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5339028951599254715</id><published>2009-06-11T20:48:00.000-07:00</published><updated>2009-06-18T20:42:10.983-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><title type='text'>Adding a kernel IOCTL</title><content type='html'>It is assumed that ,  the  OAL code is cloned to the BSP under development, including the ioctl code. For the purpose of explaining the process, the Mainstone III reference platform will be used.&lt;br /&gt;&lt;br /&gt;The BSP specific, ioctl will be located under the directory, MAINSTONEIII\SRC\OAL\OALLIB\ioctl.c.&lt;br /&gt;&lt;br /&gt;Now lets assume that we need to implement an ioctl to flag the backing up of system alarm setting during shutdown.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Define a new function in ioctl.c as:&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt;&lt;pre class="prettyprint"&gt;BOOL OALIoCtlHalAlarmSet&lt;br /&gt;               (   UINT32 code, VOID *pInpBuffer,&lt;br /&gt;                   UINT32 inpSize, VOID *pOutBuffer,&lt;br /&gt;                 UINT32 outSize, UINT32 *pOutSize)&lt;br /&gt;{&lt;br /&gt;g_oalIoCtlUserAlarmSet = TRUE;&lt;br /&gt;return(TRUE);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt; &lt;ul&gt;&lt;li&gt;Define a macro for the new IOCTL.&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt;&lt;pre class="prettyprint"&gt;#define FILE_DEVICE_CUST_OEM   32806&lt;br /&gt;&lt;br /&gt;#define IOCTL_DDK_SET_ALARM_FLAG        \&lt;br /&gt;CTL_CODE(FILE_DEVICE_CUST_OEM, 0x0100, METHOD_BUFFERED, FILE_ANY_ACCESS)&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt; &lt;ul&gt;&lt;li&gt; Modify g_oalIoCtlTable variable in ioctl.c to add the new ioctl mapping:&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt;&lt;pre class="prettyprint"&gt;const OAL_IOCTL_HANDLER g_oalIoCtlTable[] = {&lt;br /&gt;.....&lt;br /&gt;{&lt;br /&gt;IOCTL_DDK_SET_ALARM_FLAG,&lt;br /&gt;0,&lt;br /&gt;OALIoCtlHalAlarmSet&lt;br /&gt;},&lt;br /&gt;#include &lt;oal_ioctl_tab.h&gt;&lt;br /&gt;.....&lt;br /&gt;&lt;/oal_ioctl_tab.h&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;Now we have a kernel ioctl, which can be invoked from any section coming under kernel address space. For making this IOCTL accessible from User space, we need to customise (clone) OALIOCTL, which will be described in another post in detail&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5339028951599254715?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5339028951599254715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5339028951599254715' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5339028951599254715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5339028951599254715'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/adding-kernel-ioctl.html' title='Adding a kernel IOCTL'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6430661964169133909</id><published>2009-06-11T20:46:00.000-07:00</published><updated>2009-06-11T20:47:40.666-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pxa'/><category scheme='http://www.blogger.com/atom/ns#' term='low power mode'/><category scheme='http://www.blogger.com/atom/ns#' term='usbclient'/><title type='text'>USB Client in Sleep mode for PXA</title><content type='html'>&lt;p align="justify"&gt;On resuming from sleep mode of PXA27X, the usb client wont be working straight away. No insertion events will be detected and the device will be shown as an uknown device in PC.&lt;/p&gt; &lt;p align="justify"&gt;For overcoming this situation, we have to clear the OTGPH bit in PSSR (Power Manager Sleep Status Register). This is a write to clear bit.&lt;/p&gt; &lt;p align="justify"&gt;OTGPH will be set when entering sleep mode when writing the PWRMODE register and indicates that the OTG pad is retaining state. So after resuming, the USB OTG, UDC and UHC should be configured, then only clear the OTGPH bit.&lt;/p&gt; &lt;p align="justify"&gt;&lt;em&gt; Referece : Marvell PXA27X Processor Developer Manual, November 3 , 2006&lt;/em&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6430661964169133909?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6430661964169133909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6430661964169133909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6430661964169133909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6430661964169133909'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/usb-client-in-sleep-mode-for-pxa.html' title='USB Client in Sleep mode for PXA'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-3890264434807003382</id><published>2009-06-08T23:37:00.000-07:00</published><updated>2009-06-08T23:42:06.203-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='ndis'/><category scheme='http://www.blogger.com/atom/ns#' term='monitoring'/><title type='text'>Monitoring events for Network interfaces</title><content type='html'>For monitoring events for a network interface, the notification request ioctl IOCTL_NDISUIO_REQUEST_NOTIFICATION in NDISUIO driver can be used.&lt;br /&gt;&lt;br /&gt;By using this Notification mechanism, we can capture events for each network interface in Windows CE such as&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Bind&lt;/li&gt;&lt;li&gt;Unbind&lt;/li&gt;&lt;li&gt;Power Up&lt;/li&gt;&lt;li&gt;Power down&lt;/li&gt;&lt;li&gt;etc...&lt;/li&gt;&lt;/ul&gt;A sample implementation is provided in the NDISPWR driver in PUBLIC code&lt;br /&gt;(WINCE600\PUBLIC\COMMON\OAK\DRIVERS\NETSAMP\NDISPWR)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-3890264434807003382?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/3890264434807003382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=3890264434807003382' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3890264434807003382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3890264434807003382'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/monitoring-events-for-network.html' title='Monitoring events for Network interfaces'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5754212344111042627</id><published>2009-06-07T20:00:00.000-07:00</published><updated>2009-06-07T20:18:41.927-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><title type='text'>Keeping system alive</title><content type='html'>In power manager, the PDD has a certain set of events that it monitors. For eg:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PM_BOOTPHASE2_EVENT&lt;/li&gt;&lt;li&gt;PM_SYSTEM_API_EVENT etc&lt;/li&gt;&lt;/ul&gt;For more information on events each PDD handles, check the Power manager code available in PUBLIC code (WINCE600\PUBLIC\COMMON\OAK\DRIVERS\PM\PDD).&lt;br /&gt;&lt;br /&gt;In those events there is event PM_SYSTEM_TIMEIDLE_RESET (PowerManager/SystemIdleTimerReset), which can used to reset the system activity timer. Check out the following piece of code for doing so.&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;br /&gt;  HANDLE hSysTmrReset = CreateEvent(NULL, FALSE, FALSE, _T("PowerManager/SystemIdleTimerReset"));&lt;br /&gt;  BOOL bExit = FALSE;&lt;br /&gt;  if (INVALID_HANDLE_VALUE != hSysTmrReset )&lt;br /&gt;  {&lt;br /&gt;      while (FALSE == bExit)&lt;br /&gt;      {&lt;br /&gt;          ResetEvent(hSysTmrReset);&lt;br /&gt;          Sleep(1000);&lt;br /&gt;          SetEvent(hSysTmrReset);&lt;br /&gt;       &lt;br /&gt;          RETAILMSG(TRUE, (TEXT("Reset\r\n")));&lt;br /&gt;          Sleep(20000);&lt;br /&gt;      }&lt;br /&gt;      CloseHandle (hSysTmrReset );&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;This system, code will keep the system alive by resetting the timer every 20 seconds. I have tested this code and seems to be working. But needs to analyze the system performance on doing so.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5754212344111042627?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5754212344111042627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5754212344111042627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5754212344111042627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5754212344111042627'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/keeping-system-alive.html' title='Keeping system alive'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-2698659007604082553</id><published>2009-06-03T21:56:00.000-07:00</published><updated>2009-06-03T22:00:25.868-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wzc'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='wifi'/><title type='text'>Enabling agressive scanning for Wifi</title><content type='html'>To enable aggressive scanning for wifi network (preferred or non-preferred ones) in Wireless Zero Configuration in Windows CE, use this registry setting:&lt;br /&gt;&lt;blockquote&gt;[HKEY_LOCAL_MACHINE\Comm\WiFi]&lt;br /&gt;          ScanInterval: dword:5&lt;br /&gt;&lt;/blockquote&gt;This will set WZC to scan for network every 5 seconds. By default, it is set to 60 seconds. Try tuning this value as per your requirement.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-2698659007604082553?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/2698659007604082553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=2698659007604082553' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2698659007604082553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2698659007604082553'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/06/enabling-agressive-scanning-for-wifi.html' title='Enabling agressive scanning for Wifi'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-4130465242595735014</id><published>2009-04-23T23:40:00.000-07:00</published><updated>2009-04-23T23:42:31.799-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='application'/><category scheme='http://www.blogger.com/atom/ns#' term='tools'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Creating Cab Files</title><content type='html'>I found a really cool utility for creating CAB files for a windows ce device - Quick Cab.&lt;br /&gt;Check it out.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;a href="http://forum.xda-developers.com/showthread.php?t=400221"&gt;http://forum.xda-developers.com/showthread.php?t=400221&lt;/a&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-4130465242595735014?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/4130465242595735014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=4130465242595735014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4130465242595735014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4130465242595735014'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/04/creating-cab-files.html' title='Creating Cab Files'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-28632197484527564</id><published>2009-04-15T19:10:00.000-07:00</published><updated>2009-04-15T19:11:00.276-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>War of the worlds</title><content type='html'>Guys check out the heated arguement in this post :)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/mikehall/archive/2005/01/13/352470.aspx"&gt;&lt;blockquote&gt;http://blogs.msdn.com/mikehall/archive/2005/01/13/352470.aspx&lt;/blockquote&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-28632197484527564?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/28632197484527564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=28632197484527564' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/28632197484527564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/28632197484527564'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/04/war-of-worlds.html' title='War of the worlds'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-2700565137679363378</id><published>2009-04-08T00:03:00.000-07:00</published><updated>2009-04-12T21:18:22.141-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='application'/><category scheme='http://www.blogger.com/atom/ns#' term='keyboard'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Keyboard Hooking in Windows CE 6.0</title><content type='html'>&lt;div style="text-align: justify;"&gt;If you want to monitor system wide keyboard events from an application, then we need to use keyboard hooking using the SetWindowsHookEx &amp;amp; UnhookWindowsHookEx functions.  Since we need a system wide hook, we need to place the callback functions in a DLL.&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;typedef struct {&lt;br /&gt; DWORD vkCode;&lt;br /&gt; DWORD scanCode;&lt;br /&gt; DWORD flags;&lt;br /&gt; DWORD time;&lt;br /&gt; ULONG_PTR dwExtraInfo;&lt;br /&gt;} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;&lt;br /&gt;.....&lt;br /&gt;&lt;br /&gt;VOID InitHook ()&lt;br /&gt;{&lt;br /&gt; .....&lt;br /&gt; SetWindowsHookEx(WH_KEYBOARD_LL,hookproc,hinstance,NULL);&lt;br /&gt; .....&lt;br /&gt;}&lt;br /&gt;....&lt;br /&gt;HOOKDLL_API LRESULT CALLBACK hookproc(int ncode,WPARAM wparam,LPARAM lparam)&lt;br /&gt;{&lt;br /&gt;UINT uMsg = 0;&lt;br /&gt;if(ncode&gt;=0)&lt;br /&gt;{&lt;br /&gt;   if((lparam &amp;amp; 0x80000000) == 0x00000000)//Check whether key was pressed(not released).&lt;br /&gt;   {&lt;br /&gt;      switch((((KBDLLHOOKSTRUCT*)lparam)-&gt;vkCode))&lt;br /&gt;      {&lt;br /&gt;         case VK_F1:&lt;br /&gt;            RETAILMSG(1,(TEXT("TRAPPED, F1\r\n")));&lt;br /&gt;            uMsg = WM_USER+755;&lt;br /&gt;            break;&lt;br /&gt;&lt;br /&gt;         case VK_F2:&lt;br /&gt;            RETAILMSG(1,(TEXT("TRAPPED, F2\r\n")));&lt;br /&gt;            uMsg = WM_USER+756;&lt;br /&gt;            break;&lt;br /&gt;&lt;br /&gt;         case VK_F3:&lt;br /&gt;            RETAILMSG(1,(TEXT("TRAPPED, F3\r\n")));&lt;br /&gt;            uMsg = WM_USER+757;&lt;br /&gt;            break;&lt;br /&gt;&lt;br /&gt;         case VK_F4:&lt;br /&gt;            RETAILMSG(1,(TEXT("TRAPPED, F4\r\n")));&lt;br /&gt;            uMsg = WM_USER+758;&lt;br /&gt;            break;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;return ( CallNextHookEx(hook,ncode,wparam,lparam) );//pass control to next hook in the hook chain.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But in Wince 6.0, these APIs have been removed, but is still present in coredll. Hence, they can be accessed using LoadLibrary and GetProcAddress functions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;N.B: Special Thanks &lt;a href="http://www.codeproject.com/script/Membership/View.aspx?mid=2313896"&gt;&lt;span style="font-size:100%;"&gt;Prathamesh S Kulkarni&lt;/span&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/a&gt;on his article on &lt;a href="http://www.codeproject.com/KB/mobile/KeyboardhooksWinCE.aspx"&gt;keyboard hooking&lt;/a&gt; in code project.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-2700565137679363378?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/2700565137679363378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=2700565137679363378' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2700565137679363378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2700565137679363378'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/04/keyboard-hooking-in-windows-ce-60.html' title='Keyboard Hooking in Windows CE 6.0'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-7770388113196845240</id><published>2009-04-07T23:52:00.000-07:00</published><updated>2009-04-08T09:49:21.076-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bluetooth'/><category scheme='http://www.blogger.com/atom/ns#' term='cloning'/><title type='text'>Modifying the bluetooth authentication dialog</title><content type='html'>Hi :)&lt;br /&gt;First of all sorry guys, for the leave of absence, I have been busy lately.&lt;br /&gt;&lt;br /&gt;In one of the tasks assigned for me, I had to bring the system back in to ON mode from idle, when any bluetooth activity happens. Activity in the sense, authentication request or a file transfer start etc.&lt;br /&gt;&lt;br /&gt;File transfer or any other requests (except for pin request), can be tackled my monitoring the &lt;a href="http://devwince.blogspot.com/2009/02/monitoring-for-bluetooth-events.html"&gt;bluetooth stack events&lt;/a&gt;. But an authentication request cannot be obtained using the same. The the authentication ui for bluetooth is located in&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;WINCE600\PUBLIC\COMMON\OAK\DRIVERS\BLUETOOTH\SAMPLE\BTSVC&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Its a service (BTSVC),  and can modified directly or &lt;a href="http://devwince.blogspot.com/2009/01/cloning-public-code.html"&gt;cloned&lt;/a&gt; By AuthenticationDlgProc and the corresponding dialog in the resource file, we can easily modify the behaviour during a bluetooth authentication request. Or a new application can be provided with the same functionality, do doing so , this service must be removed first as only one type of authentication ui will be allowed at a time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-7770388113196845240?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/7770388113196845240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=7770388113196845240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7770388113196845240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7770388113196845240'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/04/modifying-bluetooth-authentication.html' title='Modifying the bluetooth authentication dialog'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6227248705640654318</id><published>2009-02-25T00:45:00.000-08:00</published><updated>2009-06-07T20:13:53.158-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bluetooth'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><title type='text'>Monitoring for bluetooth events</title><content type='html'>Here is a sample code for monitoring incoming connection and authentication requests on a microsoft bluetooth stack:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;br /&gt;DWORD BTActivityMonitor ( LPVOID lpParam )&lt;br /&gt;{&lt;br /&gt;MSGQUEUEOPTIONS mqOptions;&lt;br /&gt;memset (&amp;amp;mqOptions, 0, sizeof(mqOptions));&lt;br /&gt;&lt;br /&gt;mqOptions.dwFlags = 0;&lt;br /&gt;mqOptions.dwSize = sizeof(mqOptions);&lt;br /&gt;mqOptions.dwMaxMessages = 10;&lt;br /&gt;mqOptions.cbMaxMessage = sizeof(BTEVENT);&lt;br /&gt;mqOptions.bReadAccess = TRUE;&lt;br /&gt;&lt;br /&gt;// Create message queue to receive BT events on&lt;br /&gt;HANDLE hMsgQ = CreateMsgQueue(NULL, &amp;amp;mqOptions);&lt;br /&gt;if (! hMsgQ) {&lt;br /&gt;    wprintf(L"Error creating message queue.\r\n");&lt;br /&gt;    goto exit_bt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Listen for all Bluetooth notifi cations&lt;br /&gt;HANDLE hBTNotif = RequestBluetoothNotifications(&lt;br /&gt;                    BTE_CLASS_CONNECTIONS | BTE_CLASS_DEVICE | BTE_CLASS_PAIRING,&lt;br /&gt;                    hMsgQ);&lt;br /&gt;if (! hBTNotif) {&lt;br /&gt;    wprintf(L"Error in call to RequestBluetoothNotifications.\r\n");&lt;br /&gt;    goto exit_bt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;wprintf(L"Waiting for Bluetooth notifications...\r\n");&lt;br /&gt;&lt;br /&gt;while (FALSE == bStop) {&lt;br /&gt;    DWORD dwWait = WaitForSingleObject (hMsgQ, INFINITE);&lt;br /&gt;    if (WAIT_OBJECT_0 == dwWait) {&lt;br /&gt;        //&lt;br /&gt;        // We have got a Bluetooth event!&lt;br /&gt;        //&lt;br /&gt;&lt;br /&gt;        BTEVENT btEvent;&lt;br /&gt;        DWORD dwFlags = 0;&lt;br /&gt;        DWORD dwBytesRead = 0;&lt;br /&gt;&lt;br /&gt;        BOOL fRet = ReadMsgQueue (hMsgQ, &amp;amp;btEvent, sizeof(BTEVENT), &amp;amp;dwBytesRead, 10, &amp;amp;dwFlags);&lt;br /&gt;        if (! fRet) {&lt;br /&gt;            wprintf(L"Error - Failed to read message from queue!\r\n");&lt;br /&gt;            goto exit_bt;&lt;br /&gt;        } else {&lt;br /&gt;            wprintf(L"----------------------------------------\r\n");&lt;br /&gt;            wprintf(L"Got event with id=%d.\r\n", btEvent.dwEventId);&lt;br /&gt;        }&lt;br /&gt;    } else {&lt;br /&gt;        wprintf(L"Error - Unexpected return value from WaitForSingleObject!\r\n");&lt;br /&gt;        goto exit_bt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;exit_bt:&lt;br /&gt;// Stop listening for Bluetooth notifications&lt;br /&gt;if (hBTNotif &amp;amp;&amp;amp; (! StopBluetoothNotifications(hBTNotif))) {&lt;br /&gt;    wprintf(L"Warning! StopBluetoothNotifications returned FALSE.\r\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if (hMsgQ) {&lt;br /&gt;    CloseMsgQueue(hMsgQ);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6227248705640654318?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6227248705640654318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6227248705640654318' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6227248705640654318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6227248705640654318'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/02/monitoring-for-bluetooth-events.html' title='Monitoring for bluetooth events'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-2560751238796456158</id><published>2009-01-06T02:18:00.001-08:00</published><updated>2009-01-06T02:19:45.642-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='cloning'/><title type='text'>Cloning Public Code</title><content type='html'>Here is a nice article by Bruce Eitman for cloning public code&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;a href="https://geekswithblogs.net/BruceEitman/archive/2008/07/02/platform-builder-clone-public-code.aspx"&gt;https://geekswithblogs.net/BruceEitman/archive/2008/07/02/platform-builder-clone-public-code.aspx&lt;/a&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-2560751238796456158?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/2560751238796456158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=2560751238796456158' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2560751238796456158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2560751238796456158'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2009/01/cloning-public-code.html' title='Cloning Public Code'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5417747036566758683</id><published>2008-12-01T19:24:00.000-08:00</published><updated>2008-12-01T19:25:48.025-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><title type='text'>Article about virtual memory</title><content type='html'>&lt;a href="http://blogs.msdn.com/ce_base/archive/2006/10/30/What-is-Virtual-Memory.aspx"&gt;http://blogs.msdn.com/ce_base/archive/2006/10/30/What-is-Virtual-Memory.aspx&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5417747036566758683?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5417747036566758683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5417747036566758683' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5417747036566758683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5417747036566758683'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/12/article-about-virtual-memory.html' title='Article about virtual memory'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6446143863980671151</id><published>2008-11-28T22:05:00.000-08:00</published><updated>2008-11-28T22:32:25.117-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fun at work'/><category scheme='http://www.blogger.com/atom/ns#' term='accord'/><title type='text'>Buona Fortuna - Good Luck Ankit</title><content type='html'>Yesterday was the last day for my team mate Ankit in Accord.&lt;br /&gt;&lt;br /&gt;He is all set to start off a new career and may be even in a new path in his new company - MindTree. All the best for you Ankit&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Q826e5YoAjQ/STDh1LxTjcI/AAAAAAAAEeM/5_fo6EOKg7o/s1600-h/dsc03067.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_Q826e5YoAjQ/STDh1LxTjcI/AAAAAAAAEeM/5_fo6EOKg7o/s400/dsc03067.jpg" alt="" id="BLOGGER_PHOTO_ID_5273963467459759554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Q826e5YoAjQ/STDhVPcHVMI/AAAAAAAAEeE/rRzXMzh3nlA/s1600-h/dsc03060.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_Q826e5YoAjQ/STDhVPcHVMI/AAAAAAAAEeE/rRzXMzh3nlA/s400/dsc03060.jpg" alt="" id="BLOGGER_PHOTO_ID_5273962918688806082" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6446143863980671151?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6446143863980671151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6446143863980671151' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6446143863980671151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6446143863980671151'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/11/buona-fortuna-good-luck-ankit.html' title='Buona Fortuna - Good Luck Ankit'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Q826e5YoAjQ/STDh1LxTjcI/AAAAAAAAEeM/5_fo6EOKg7o/s72-c/dsc03067.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-4411477260528130792</id><published>2008-11-22T11:18:00.001-08:00</published><updated>2009-02-25T00:49:14.292-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='activesync'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='usbclient'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><title type='text'>Dynamically Changing USB Client Function</title><content type='html'>Hi guys,&lt;br /&gt;&lt;br /&gt;Here is a code for changing the current usb client function from Serial to Mass storage dynamically.&lt;br /&gt;&lt;pre class="prettyprint lang-cpp"&gt;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* #FUNCTION&lt;br /&gt;*&lt;br /&gt;* @Function: GetUfnController&lt;br /&gt;* @Return: INVALID_HANDLE_VALUE - USB Function device was not found&lt;br /&gt;*   Otherwise, if found&lt;br /&gt;* @Parameters: &lt;none&gt;&lt;br /&gt;* @Description:&lt;br /&gt;*  Function to get the handle of a USB Client device.&lt;br /&gt;*/&lt;br /&gt;HANDLE GetUfnController()&lt;br /&gt;{&lt;br /&gt;HANDLE hUfn = NULL;&lt;br /&gt;// Get a handle to the bus driver&lt;br /&gt;DEVMGR_DEVICE_INFORMATION di;&lt;br /&gt;memset(&amp;amp;di, 0, sizeof(di));&lt;br /&gt;di.dwSize = sizeof(di);&lt;br /&gt;&lt;br /&gt;#ifdef _SEARCH_WITH_GUID_&lt;br /&gt;BYTE rgbGuidBuffer[sizeof(GUID) + 4]; // +4 because scanf writes longs&lt;br /&gt;memset(&amp;amp;rgbGuidBuffer[0],0,sizeof(GUID) + 4);&lt;br /&gt;LPGUID pguidBus = (LPGUID) rgbGuidBuffer;&lt;br /&gt;LPCTSTR pszBusGuid = _T("E2BDC372-598F-4619-BC50-54B3F7848D35");&lt;br /&gt;// Parse the GUID&lt;br /&gt;if (FALSE == ConvertStringToGuid(&amp;amp;pszBusGuid[0],pguidBus) )&lt;br /&gt;return INVALID_HANDLE_VALUE;&lt;br /&gt;HANDLE hf = FindFirstDevice(DeviceSearchByGuid, pguidBus, &amp;amp;di);&lt;br /&gt;#else&lt;br /&gt;HANDLE hf = FindFirstDevice(DeviceSearchByLegacyName, L"UFN1:", &amp;amp;di);&lt;br /&gt;#endif /* _SEARCH_WITH_GUID_ */&lt;br /&gt;if (hf != INVALID_HANDLE_VALUE) {&lt;br /&gt;hUfn = CreateFile(di.szBusName, GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, 0, NULL);&lt;br /&gt;CloseHandle(hf);&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;hUfn = INVALID_HANDLE_VALUE;&lt;br /&gt;}&lt;br /&gt;return hUfn;&lt;br /&gt;} /* GetUfnController */&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* #FUNCTION&lt;br /&gt;*&lt;br /&gt;* @Function: ChangeClient&lt;br /&gt;* @Return: TRUE - Client Function change was succesful&lt;br /&gt;*   FALSE - Client Function change failed&lt;br /&gt;* @Parameters:&lt;br /&gt;*   hUfn - Handle to the USB client device&lt;br /&gt;*   pszNewClient - New usb function to be loaded&lt;br /&gt;* @Description:&lt;br /&gt;*  Function to switch the active usb client function driver&lt;br /&gt;*/&lt;br /&gt;BOOL ChangeClient(HANDLE hUfn, LPCTSTR pszNewClient)&lt;br /&gt;{&lt;br /&gt;if(hUfn == INVALID_HANDLE_VALUE || pszNewClient == NULL)&lt;br /&gt;return ERROR_INVALID_PARAMETER;&lt;br /&gt;DWORD dwRet = ERROR_SUCCESS;&lt;br /&gt;UFN_CLIENT_NAME ucn;&lt;br /&gt;_tcscpy(ucn.szName, pszNewClient);&lt;br /&gt;BOOL fSuccess = DeviceIoControl(hUfn,&lt;br /&gt;IOCTL_UFN_CHANGE_CURRENT_CLIENT, &amp;amp;ucn, sizeof(ucn), NULL, 0, NULL, NULL);&lt;br /&gt;return fSuccess;&lt;br /&gt;} /* ChangeClient */&lt;br /&gt;&lt;/none&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-4411477260528130792?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/4411477260528130792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=4411477260528130792' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4411477260528130792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4411477260528130792'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/11/dynamically-changing-usb-client.html' title='Dynamically Changing USB Client Function'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-7836261661380457134</id><published>2008-11-22T11:00:00.000-08:00</published><updated>2008-11-23T19:28:27.345-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='activesync'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Enumerating ActiveSync Connections</title><content type='html'>&lt;pre class="prettyprint lang-cpp"&gt;&lt;vaisakhrulez@gmail.com&gt;&lt;na&gt;&lt;windows.h&gt;&lt;commctrl.h&gt;&lt;ras.h&gt;&lt;br /&gt;/*&lt;br /&gt;* #FUNCTION&lt;br /&gt;*&lt;br /&gt;* @Function: ConnectionStatus&lt;br /&gt;* @Return: TRUE - Active sync session is active&lt;br /&gt;*          FALSE - Active sync session is not detected&lt;br /&gt;* @Parameters: &lt;none&gt;&lt;br /&gt;* @Description:&lt;br /&gt;*  Function to Check the connection status of ActiveSync&lt;br /&gt;*/&lt;br /&gt;BOOL ConnectionStatus(VOID)&lt;br /&gt;{&lt;br /&gt;RASCONN   rsconn[10];&lt;br /&gt;DWORD   dwcb, dwConnections;&lt;br /&gt;RASCONNSTATUS rasStatus;&lt;br /&gt;BOOL   bConnected = FALSE;&lt;br /&gt;&lt;br /&gt;// Enumerate active connections&lt;br /&gt;dwcb = sizeof(rsconn);&lt;br /&gt;rsconn[0].dwSize = sizeof(RASCONN);&lt;br /&gt;if(RasEnumConnections(rsconn, &amp;amp;dwcb, &amp;amp;dwConnections) == 0) {&lt;br /&gt;if(dwConnections == 0 || rsconn[0].hrasconn == NULL) {&lt;br /&gt;DBG_PRINT ("No current connections\r\n");&lt;br /&gt;}&lt;br /&gt;else{&lt;br /&gt;// Get first RAS connection status&lt;br /&gt;rasStatus.dwSize = sizeof(rasStatus);&lt;br /&gt;if(RasGetConnectStatus(rsconn[0].hrasconn, &amp;amp;rasStatus) != 0) {&lt;br /&gt; DBG_PRINT ("Could not get RAS connection status\r\n");&lt;br /&gt;}&lt;br /&gt;else{&lt;br /&gt; // Is it connected?&lt;br /&gt; if(rasStatus.rasconnstate != RASCS_Connected) {&lt;br /&gt;  DBG_PRINT("Not connected\r\n");&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  if ((0 == wcscmp(L"direct",rasStatus.szDeviceType)) &amp;amp;&amp;amp;&lt;br /&gt;      (0 == wcscmp(L"Serial on USB",rasStatus.szDeviceName))) {&lt;br /&gt;   DBG_PRINT(TEXT("Got an activesync connection..\r\n"));&lt;br /&gt;   bConnected = TRUE;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;DBG_PRINT ("Could not enumerate RAS connections\r\n");&lt;br /&gt;}&lt;br /&gt;return bConnected;&lt;br /&gt;} /* ConnectionStatus */&lt;br /&gt;&lt;/none&gt;&lt;/ras.h&gt;&lt;/commctrl.h&gt;&lt;/windows.h&gt;&lt;/na&gt;&lt;/vaisakhrulez@gmail.com&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-7836261661380457134?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/7836261661380457134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=7836261661380457134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7836261661380457134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7836261661380457134'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/11/enumerating-activesync-connections.html' title='Enumerating ActiveSync Connections'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-4122201753906742384</id><published>2008-11-17T23:53:00.000-08:00</published><updated>2008-11-18T00:21:02.062-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='cetk'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='performance monitor'/><title type='text'>Remote Tools and CETK over activesync</title><content type='html'>I will explain on how to connect development pc to a board running windows ce 6.0 os image using Activesync. The development board that I used is similar to the Mainstone III development platform (based on a Marvell PXA 270 processor) and activesync is configured to connect over the USB client port.&lt;br /&gt;&lt;br /&gt;Previously when I was trying to connect to my development board using activesync from remote tools, i was getting error message that " Unable to load device side components". The samething happens while I was using CETK. But Sctivesync was connceting properly. Then I started digging into discussion forums for finding a solution to this problem. Here is what I found:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Open C:\Program Files\Common Files\Microsoft Shared\Windows CE Tools\Platman\target\wce600.&lt;/li&gt;&lt;li&gt;Create a folder armV4 and copy the contents of armV4i into this one.&lt;/li&gt;&lt;li&gt;Now Open Kernel Tracker or any remote tools.&lt;/li&gt;&lt;li&gt;Then follow the same steps specified by Sue in her &lt;a href="http://blogs.msdn.com/ce_base/archive/2007/04/02/using-platform-builder-remote-tools-over-activesync.aspx"&gt;blog post&lt;/a&gt;.&lt;/li&gt;&lt;/ol&gt;Presto!!!... There you have your remote tools working over Activesync.&lt;br /&gt;&lt;br /&gt;NOTE: Special Thanks to Sue Loh (&lt;a href="http://blogs.msdn.com/ce_base/archive/2007/04/02/using-platform-builder-remote-tools-over-activesync.aspx"&gt;Windows CE Base Team Blog&lt;/a&gt;) and Yan Sun (&lt;a href="http://groups.google.com/group/microsoft.public.windowsce.platbuilder/browse_thread/thread/a7af4d568659bc3b/8d117876157dc7e5?lnk=gst&amp;amp;q=activesync+remote+6.0#8d117876157dc7e5"&gt;&lt;span id="thread_subject_site"&gt;CE 6.0 and PlatMan remote tools&lt;/span&gt;&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;div class="lf secttl"&gt;   &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-4122201753906742384?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/4122201753906742384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=4122201753906742384' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4122201753906742384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/4122201753906742384'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/11/remote-tools-and-cetk-over-activesync.html' title='Remote Tools and CETK over activesync'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5073595958372884740</id><published>2008-11-11T21:46:00.000-08:00</published><updated>2008-11-14T19:31:00.200-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='celog'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><category scheme='http://www.blogger.com/atom/ns#' term='performance monitor'/><title type='text'>Debugging a booting problem</title><content type='html'>In this post, I will explain about how I debugged a problem in which our development board was taking a lot of time to completly boot up into Windows CE.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The usual bootup time for the development board was around 30-35 seconds, but as we were adding new drivers , the bootup time went up by minutes. The booting was really slow. So I took up this issue. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;As i analyzed the booting up process, it was clear that the Boot phase 1 (loading of FMD) was getting over without any hickups. And slow down seems to have been occuring while drivers are getting loaded and initialized.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;We can follow two strategies for pin pointing this issue:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Remove each driver one-by-one.&lt;/span&gt;&lt;br /&gt;If we are not clear with the source of the problem, then individually eliminating each component one-by-one and observing the behaviour is a straight forward but time consuming way. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Using Celog&lt;/span&gt;&lt;br /&gt;&lt;div&gt;In one of my earlier posts, I have mentioned about a cab file that I created with all the celog settings and files. I installed this file on to the development board and configured the registry to launch 'CeLogFlush.exe' during bootup. Also Celog was configured to dump the data into a local file.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;[HKEY_LOCAL_MACHINE\init]&lt;/div&gt;&lt;div&gt;        "Launch05"="CeLogFlush.exe" -- include celog.dll&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;[HKEY_LOCAL_MACHINE\System\CeLog]&lt;/div&gt;&lt;div&gt;    "Transport"="LocalFile"&lt;/div&gt;&lt;div&gt;    "FileName"="celog.clg"&lt;/div&gt;&lt;div&gt;    "BufferSize"=dword:100000&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// 1MB&lt;/div&gt;&lt;div&gt;    "ZoneCE"=dword:815263&lt;/div&gt;&lt;div&gt;    "FlushTimeout"=dword:1388&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// 5 seconds&lt;/div&gt;&lt;div&gt;    "FileFlags"=dword:1&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;// Keep file open&lt;/div&gt;&lt;div&gt;    "ThreadPriority"=dword:C8&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// Priority increased to 200&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;After the complete system was up, I killed the CeLogFlush.exe using ITaskMgr (a really good task manager application) and took the Celog.clg from the device. This output file will contain only the thread IDs, we need to fix this up using readlog (&lt;a href="http://devwince.blogspot.com/2008/10/fixing-thread-names-in-celog-output.html"&gt;http://devwince.blogspot.com/2008/10/fixing-thread-names-in-celog-output.html&lt;/a&gt;). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we can view this file in &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Windows CE Remote Kernel tracker. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Image1&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Q826e5YoAjQ/SR5CVcJh0lI/AAAAAAAAEcU/qTKyXZU_ckQ/s1600-h/Window1.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_Q826e5YoAjQ/SR5CVcJh0lI/AAAAAAAAEcU/qTKyXZU_ckQ/s400/Window1.JPG" alt="" id="BLOGGER_PHOTO_ID_5268721550170903122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;According the Celog data, the booting process went normally till the 7th second since celogflush was started and all the drivers till that point was loaded and threads have been started (that means the XXX_Init routine was completed successfully). But after that the next thread start only at the 52 seconds mark, which was the battery monitor thread.  And according the driver loading order in registry, the drivers were the power button  monitor and battery driver.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Image2&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Q826e5YoAjQ/SR5B6F4r0EI/AAAAAAAAEcM/Em0kAvPxR0U/s1600-h/Window2.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_Q826e5YoAjQ/SR5B6F4r0EI/AAAAAAAAEcM/Em0kAvPxR0U/s400/Window2.JPG" alt="" id="BLOGGER_PHOTO_ID_5268721080338206786" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When I analyzed the XXX_Init of battery driver, I found out that there was a t_printf statement in the init routine. According to the MSDN documentation t_printf will dump the data onto a console, which is again a driver and is not started yet. So when I removed the t_printf statements, the booting speed was back to normal.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;:)&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5073595958372884740?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5073595958372884740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5073595958372884740' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5073595958372884740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5073595958372884740'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/11/debugging-booting-problem.html' title='Debugging a booting problem'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Q826e5YoAjQ/SR5CVcJh0lI/AAAAAAAAEcU/qTKyXZU_ckQ/s72-c/Window1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-428341559383271147</id><published>2008-11-04T19:43:00.000-08:00</published><updated>2008-11-04T19:45:58.904-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='oal'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>Another nice article about booting</title><content type='html'>&lt;a href="http://blogs.msdn.com/ce_base/archive/2007/11/26/How-does-Windows-Embedded-CE-6.0-start_3F00_.aspx"&gt;&lt;/a&gt;Here is another really informative article by the Windows CE Base team.:)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/ce_base/archive/2007/11/26/How-does-Windows-Embedded-CE-6.0-start_3F00_.aspx"&gt;&lt;blockquote&gt;http://blogs.msdn.com/ce_base/archive/2007/11/26/How-does-Windows-Embedded-CE-6.0-start_3F00_.aspx&lt;/blockquote&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-428341559383271147?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/428341559383271147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=428341559383271147' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/428341559383271147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/428341559383271147'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/11/another-nice-article-about-booting.html' title='Another nice article about booting'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-98490519504769209</id><published>2008-10-25T21:50:00.000-07:00</published><updated>2008-11-18T06:37:53.716-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><title type='text'>Controlling  a Stream Interface Driver</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;Special thanks to Bruce Eitman&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;/*&lt;br /&gt;* Function to query the active drivre list using a search  string&lt;br /&gt;*/&lt;br /&gt;VOID QueryDriver (const WCHAR* lpcParam)&lt;br /&gt;{&lt;br /&gt;                DEVMGR_DEVICE_INFORMATION devmgrInfo;&lt;br /&gt;        &lt;/span&gt;&lt;span style="font-size:85%;"&gt;devmgrInfo.dwSize=sizeof(DEVMGR_DEVICE_INFORMATION);&lt;br /&gt;&lt;/span&gt;       &lt;span style="font-size:85%;"&gt;HANDLE hDevRes = FindFirstDevice (DeviceSearchByDeviceName, lpcParam,&lt;br /&gt;                                                                  &amp;amp;devmgrInfo);&lt;br /&gt;&lt;/span&gt;       &lt;span style="font-size:85%;"&gt;if (INVALID_HANDLE_VALUE != hDevRes)&lt;br /&gt;&lt;/span&gt;       &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;               &lt;span style="font-size:85%;"&gt;do&lt;br /&gt;&lt;/span&gt;               &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;                    &lt;span style="font-size:85%;"&gt;DBG_PRINT(_T("%d , %d , %s, %s, %s, %s\n"),&lt;br /&gt;&lt;/span&gt;                                   &lt;span style="font-size:85%;"&gt;devmgrInfo.hDevice,&lt;br /&gt;&lt;/span&gt;                                   &lt;span style="font-size:85%;"&gt;devmgrInfo.hParentDevice,&lt;br /&gt;&lt;/span&gt;                                   &lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;devmgrInfo.szLegacyName,&lt;br /&gt;&lt;/span&gt;                                   &lt;span style="font-size:85%;"&gt;devmgrInfo.szDeviceKey,&lt;br /&gt;&lt;/span&gt;                                   &lt;span style="font-size:85%;"&gt;devmgrInfo.szDeviceName,&lt;br /&gt;&lt;/span&gt;                                   &lt;span style="font-size:85%;"&gt;devmgrInfo.szLegacyName );&lt;br /&gt;&lt;/span&gt;              &lt;span style="font-size:85%;"&gt;}while (FindNextDevice(hDevRes,&amp;amp;devmgrInfo));&lt;br /&gt;&lt;/span&gt;             &lt;span style="font-size:85%;"&gt;FindClose (hDevRes);&lt;br /&gt;&lt;/span&gt;        &lt;span style="font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;        &lt;span style="font-size:85%;"&gt;else&lt;br /&gt;&lt;/span&gt;       &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;           &lt;span style="font-size:85%;"&gt;DWORD  dwErrorCode = GetLastError();&lt;br /&gt;&lt;/span&gt;           &lt;span style="font-size:85%;"&gt;DBG_PRINT(_T("QueryDriver , code: %d\n"),dwErrorCode);&lt;br /&gt;&lt;/span&gt;       &lt;span style="font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;     &lt;span style="font-size:85%;"&gt;return;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;--------------------&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;blockquote&gt;/*&lt;br /&gt;* Function to load a driver, when provided the driver registry key&lt;br /&gt;*/&lt;br /&gt;VOID LoadDriver (const WCHAR* lpcParam)&lt;br /&gt;{&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;HANDLE hDriverShell = INVALID_HANDLE_VALUE;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    hDriverShell = ActivateDeviceEx( lpcParam,NULL,0,NULL);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    if (hDriverShell != INVALID_HANDLE_VALUE &amp;amp;&amp;amp; hDriverShell != 0)&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    {&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    }&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    else&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    {&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;        DWORD  dwErrorCode = GetLastError();&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;        DBG_PRINT(TEXT("LoadDriver: Failed to activate driver %d\n"), GetLastError() );&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    }&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;    return;&lt;br /&gt;}&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;--------------------&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;/*&lt;br /&gt;* Function to unload a driver, when provided the diver name&lt;br /&gt;*/&lt;br /&gt;VOID UnloadDriver (const WCHAR* lpcParam)&lt;br /&gt;{&lt;br /&gt;        &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;DEVMGR_DEVICE_INFORMATION devmgrInfo;&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;devmgrInfo.dwSize=sizeof(DEVMGR_DEVICE_INFORMATION);&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;HANDLE hDevRes = FindFirstDevice (DeviceSearchByDeviceName, lpcParam, &lt;br /&gt;                                               &amp;amp;devmgrInfo);&lt;br /&gt;        &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;if (INVALID_HANDLE_VALUE != hDevRes)&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;                 &lt;span style="font-size:85%;"&gt;do&lt;br /&gt;&lt;/span&gt;                 &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;                     &lt;span style="font-size:85%;"&gt;DeactivateDevice(devmgrInfo.hDevice);&lt;br /&gt;&lt;/span&gt;                 &lt;span style="font-size:85%;"&gt;}while (FindNextDevice(hDevRes,&amp;amp;devmgrInfo));&lt;br /&gt;&lt;/span&gt;                 &lt;span style="font-size:85%;"&gt;FindClose (hDevRes);&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;else&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;                &lt;span style="font-size:85%;"&gt;DWORD  dwErrorCode = GetLastError();&lt;br /&gt;&lt;/span&gt;                &lt;span style="font-size:85%;"&gt;DBG_PRINT(_T("QueryDriver , code: %d\n"),dwErrorCode);&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;      &lt;span style="font-size:85%;"&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;--------------------&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-98490519504769209?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/98490519504769209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=98490519504769209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/98490519504769209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/98490519504769209'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/10/controlling-stream-interface-driver.html' title='Controlling  a Stream Interface Driver'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-7026304122780429930</id><published>2008-10-13T04:08:00.001-07:00</published><updated>2008-10-13T04:19:10.261-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='celog'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='performance monitor'/><title type='text'>Fixing Thread names in CeLog Output</title><content type='html'>&lt;span id="nsrTitle"&gt;&lt;div style="text-align: justify;"&gt;When you are debugging on a standalone system (i.e. which is not connected to platform builder, using corecon), you may need to get the celog CLG file and review the performace data for the session in &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Kernel Tracker&lt;/span&gt;. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;But the file which you are getting will not have the thread information, it will only have the identifiers for each thread instead of the names. The names of the thread can be acquired using the Readlog utility. First copy the CLG file you obtained from the system into the build release directory and execute the following command :&lt;/div&gt;&lt;div&gt;&lt;blockquote style="text-align: justify;"&gt;Readlog -fixthreads celog.clg output.clg&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Now output.clg file will have the thread names fixed up.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span id="nsrTitle"&gt;Fixing Thread Names With Readlog (&lt;/span&gt;http://msdn.microsoft.com/en-us/library/aa935935.aspx)&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-7026304122780429930?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/7026304122780429930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=7026304122780429930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7026304122780429930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7026304122780429930'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/10/fixing-thread-names-in-celog-output.html' title='Fixing Thread names in CeLog Output'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-1971381102174502027</id><published>2008-09-29T23:34:00.000-07:00</published><updated>2009-04-29T01:05:14.586-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>Interrupt ... whats the big deal??</title><content type='html'>&lt;div&gt;&lt;div style="text-align: justify;"&gt;In most of the discussion forums I have seen that developers are not clear about how interrupts are handled in windows ce. I am familiar with the Xscale and arm architectures. This post will not explain about how to handle or register interrupt in drivers, as it is covered in some of the previous posts. Instead how kernel manages  an interrupt in windows ce 6.0. Lets start off with the concept of EXCEPTIONS in arm architectures.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;"Exceptions are generated by internal and external sources to cause the processor to handle an event, such as an externally generated interrupt or an attempt to execute an Undefined instruction."&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;      &lt;span class="Apple-style-span"  style="font-size:small;"&gt; - I took it from the arm reference manual, couldn't put it in any better way myself:)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;There are seven types of exceptions supported by ARM:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;ol&gt;&lt;li&gt;Reset&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Undefined Instruction&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Software Interrupt&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Prefetch Abort&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Data Abort&lt;br /&gt;&lt;/li&gt;&lt;li&gt;IRQ&lt;br /&gt;&lt;/li&gt;&lt;li&gt;FIQ&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;When an exception occurs, the processor execution is halted and branches to a predefined address called exception vector. For each exception type, there is predefined exception vector, for example, exception vector for Data abort is 0x00000010 and that of reset is 0x00000000. There is also high vectors in which the exception vectors can be moved to an alternative address range(0xFFFF0000-0xFFFF001C), using bit[13] of the coprocessor 15 register 1&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In the exception handler the banked version of register such as R14 and SPSR are used to save and restore the processor state.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Starting point for analyzing the exception handling in Windows ce for ARM architectures can be&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;WINCE600\PRIVATE\WINCEOS\COREOS\NK\KERNEL\ARM\exvector.s&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Defenition to each of this hanlders can be found in armtrap.s (&lt;span class="Apple-style-span" style="font-style: italic;"&gt;WINCE600\PRIVATE\WINCEOS\COREOS\NK\KERNEL\ARM&lt;/span&gt;)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This vector table will be loaded into the higher part of physical page at 0xffff0000 (same as the High vector address), along with other kernel data in ARM_HIGH structure (&lt;span class="Apple-style-span" style="font-style: italic;"&gt;WINCE600\PRIVATE\WINCEOS\COREOS\NK\INC\nkarm.h&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Here are some references that you can start off with&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt; - ARM Architecture Reference Manual&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; font-weight: bold;"&gt;   ( &lt;span class="Apple-style-span" style="font-style: normal; font-weight: normal;"&gt;&lt;a href="http://www.arm.com/miscPDFs/14128.pdf"&gt;http://www.arm.com/miscPDFs/14128.pdf&lt;/a&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-1971381102174502027?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/1971381102174502027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=1971381102174502027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1971381102174502027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1971381102174502027'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/interrupt-whats-big-deal.html' title='Interrupt ... whats the big deal??'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-329337055035394912</id><published>2008-09-24T02:08:00.000-07:00</published><updated>2008-09-24T02:10:16.751-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oal'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='bootloader'/><title type='text'>Understanding the bootup sequence of bootloader and kernel</title><content type='html'>Here is the link to really informative article in MSDN regarding the boot sequence in bootloader and kernel.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa446905.aspx"&gt;&lt;blockquote&gt;http://msdn.microsoft.com/en-us/library/aa446905.aspx&lt;/blockquote&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-329337055035394912?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/329337055035394912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=329337055035394912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/329337055035394912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/329337055035394912'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/understanding-bootup-sequence-of.html' title='Understanding the bootup sequence of bootloader and kernel'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-8685318559708844439</id><published>2008-09-23T20:22:00.000-07:00</published><updated>2008-09-23T21:34:28.334-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><title type='text'>Querying that powerstate of an NIC</title><content type='html'>&lt;div&gt;This one is a continuation of the last post, Here is a code for chcking the current power state of an NIC&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify; "&gt;&lt;blockquote&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;// Returns TRUE if device is enabled otherwise FALSE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;BOOL QueryNIC (wchar_t* InterfaceName)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;TCHAR                           szName[MAX_PATH];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;int                             nChars;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;TCHAR*                          pszAdapter;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;TCHAR                           multiSz[257];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;DWORD                           cbBuffer = sizeof(multiSz);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;CEDEVICE_POWER_STATE Dx = PwrDeviceUnspecified;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;BOOL&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;bDevPowered = TRUE;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;pszAdapter = new TCHAR[wcslen(InterfaceName)+1];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;wcscpy_s(pszAdapter,wcslen(InterfaceName)+1,InterfaceName);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;nChars = _sntprintf_s(szName,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;                                                    MAX_PATH-1,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;                                                   MAX_PATH-1,&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); font-style: italic; "&gt;                                                  &lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;_T("%s\\%s"),&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                                                                  PMCLASS_NDIS_MINIPORT, &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                                                                   pszAdapter);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;szName[MAX_PATH-1]=0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;if(nChars != (-1)) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;::GetDevicePower(szName, POWER_NAME, &amp;amp;Dx);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;if (!IsValidDx(Dx))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;bDevPowered = FALSE;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;if (D4 == Dx)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;bDevPowered = FALSE;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;delete pszAdapter;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;return bDevPowered ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-8685318559708844439?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/8685318559708844439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=8685318559708844439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/8685318559708844439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/8685318559708844439'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/querying-that-powerstate-of-nic.html' title='Querying that powerstate of an NIC'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-7018755382853540297</id><published>2008-09-22T22:36:00.000-07:00</published><updated>2008-09-25T10:41:24.561-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><title type='text'>Controlling an Ethernet Adapter using Power Manager API</title><content type='html'>&lt;div style="text-align: justify;"&gt;i have to thank one person (seriously I forgot this name... i am really bad a remembering names and numbers), he posted an article in codeproject.com regarding this functionality. Then I found more helpful code in completing the circle.. :) &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote style="text-align: justify;"&gt;WINCE600\PUBLIC\COMMON\OAK\DRIVERS\NETSAMP\NDISPWR&lt;/blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;This is a sample program given in windows ce 6.0 showing how to query and the set the power state of network interface using deviceIocontrols (specifically,  ndis ioctls for binding and unbinding the adapter after a power state change) and setDevicePower functions. &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Here is the code for controlling (enabling and disabling, its the same operation as in enabling and disabling a network interface in network connection applet in control panel) an NIC.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Pay attention to the high lighted part of code.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;void ControlNIC(wchar_t* InterfaceName,BOOL bEnable)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;HANDLE                          hNdisPwr;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;NDISPWR_SAVEPOWERSTATE&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SavePowerState;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;TCHAR                           szName[MAX_PATH];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int                             nChars;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;TCHAR*                          pszAdapter;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;TCHAR                           multiSz[257];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;DWORD                           cbBuffer = sizeof(multiSz);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;hNdisPwr = CreateFile((PTCHAR)NDISPWR_DEVICE_NAME,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                          0x00,0x00,NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                         OPEN_EXISTING,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                       FILE_ATTRIBUTE_NORMAL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                | FILE_FLAG_OVERLAPPED,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                        (HANDLE)INVALID_HANDLE_VALUE);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if (hNdisPwr != INVALID_HANDLE_VALUE)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SavePowerState.pwcAdapterName = InterfaceName;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if (bEnable)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SavePowerState.CePowerState   = PwrDeviceUnspecified;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;SavePowerState.CePowerState   = D4;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;BOOL ret = DeviceIoControl(hNdisPwr,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                    IOCTL_NPW_SAVE_POWER_STATE,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                    &amp;amp;SavePowerState,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                    sizeof(NDISPWR_SAVEPOWERSTATE),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                    NULL,0x00,NULL,NULL);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);  font-style: italic; white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                 // TODO: take care of the return value '&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ret &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CloseHandle(hNdisPwr);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style=" font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style=" font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;// Just composing a Class-Qualified Device Name, to pass on to SetDevicePower&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pszAdapter = new TCHAR[wcslen(InterfaceName)+1];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;wcscpy_s(pszAdapter,wcslen(InterfaceName)+1,InterfaceName);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;nChars = _sntprintf_s(szName,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                             MAX_PATH-1,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                             MAX_PATH-1,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                             _T("%s\\%s"),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                           PMCLASS_NDIS_MINIPORT,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                           pszAdapter);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;szName[MAX_PATH-1]=0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;DWORD res = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if(bEnable)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;res = SetDevicePower(szName, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                     POWER_NAME, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                    PwrDeviceUnspecified);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;res = SetDevicePower(szName, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                      POWER_NAME, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                      D4);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;// TODO: take care of the return value 'res'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style=" font-style: italic; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;StringCchCopy(multiSz, (cbBuffer / sizeof(TCHAR))-1, pszAdapter);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;multiSz[::_tcslen(multiSz)+1] = _T('\0'); // Multi sz needs an extra null&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;BOOL bRes;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if (bEnable)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bRes = DoNdisIOControl(IOCTL_NDIS_BIND_ADAPTER,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                          multiSz,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                          (_tcslen(multiSz)+2) * sizeof(TCHAR),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                         NULL,NULL);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bRes = DoNdisIOControl(IOCTL_NDIS_UNBIND_ADAPTER,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                            multiSz, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                           (_tcslen(multiSz)+2) * sizeof(TCHAR), &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;                                                                          NULL,NULL);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;// TODO: take care of the return value '&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bRes &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;While changing the power state of a device, be sure for bind and unbind an adapter so that NDIS can take care of the protocol drivers. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-size:48px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-7018755382853540297?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/7018755382853540297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=7018755382853540297' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7018755382853540297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7018755382853540297'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/controlling-ethernet-adapter-using.html' title='Controlling an Ethernet Adapter using Power Manager API'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-7963016716953545913</id><published>2008-09-17T05:26:00.000-07:00</published><updated>2009-06-28T02:12:13.963-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='pxa'/><category scheme='http://www.blogger.com/atom/ns#' term='low power mode'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><title type='text'>Adding Low Power modes in PXA - P4</title><content type='html'>&lt;div style="text-align: justify;"&gt;So far,we have discussed about how to put pxa into low power mode, how to wake it up, and briefly on how operating system restore things to the prior state after a transition to low power mode. Now lets put the bits and pieces together and see how windows ce does the low power mode transition in case of PXA.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As I have mentioned in the previous posts, we need to add the wakeup configuration first and then put the processor in to the low power mode.&lt;br /&gt;&lt;br /&gt;For purpoes of explaining the concept, I will how to add a wakeup for GPIO 11 which is connected to the activity line of a communication module.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Adding the wakeup source&lt;/span&gt;&lt;br /&gt;1) In OAL interrupt code(intr.c and bsp_cfg.h), add the code for creating a new interrupt corresponding to the wakeup source.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;bsp_cfg.h - Add the new sysintr for the wakeup line&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style: italic;font-size:85%;" &gt;     ....&lt;br /&gt;      #define SYSINTR_COMMMOD_WAKEPUP    (SYSINTR_FIRMWARE+22)&lt;br /&gt;      ....&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt; intr.c - map the sysintr to gpio 11 and add code for managing that&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;        BOOL BSPIntrInit()&lt;br /&gt;      {&lt;br /&gt;          ....&lt;br /&gt;      OALIntrStaticTranslate (SYSINTR_COMMMOD_WAKEPUP,IRQ_GPIOXX_2_GPIO11);&lt;br /&gt;          ....&lt;br /&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;2) In OAL power code (power.c), add code for setting the pwer register. In mainstone bsp, the wakeups are register while OS starts (BSPPowerOffInit function)and the pwer value is written only while going into low power mode (BSPPowerOff).&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;BSPSetWakeSrc function - add a case for gpio 11 and set the gpio11 bit in the pPwer global variable. This variable will be written to the actual PWER register while going into suspend.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;        ......&lt;br /&gt;      case IRQ_GPIOXX_2_GPIO11:&lt;br /&gt;              pPwer-&gt;gpio11 = 1;&lt;br /&gt;              OALMSG(1, ( L"BSPSetWakeSrc: IRQ Communication module source\r\n", irq));&lt;br /&gt;              break;&lt;br /&gt;          ......&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;      BSPGetWakeSrc function - add case for gpio 11 here also.This function to return the IRQ value if the PEDR (Power manager edge detect register) bit for gpio 11 is set.&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-style: italic;font-size:85%;" &gt;  ....&lt;br /&gt;      else if (pPedr-&gt;gpio11)&lt;br /&gt;      {&lt;br /&gt;          *pSrcIrq = IRQ_GPIOXX_2_GPIO11;&lt;br /&gt;      }&lt;br /&gt;      ....&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;blockquote&gt;    BSPPowerOffInit function - use the OALIoCtlHalEnableWake function to set the global variable (g_oalWakeMask, an array) with the sysintr value corresponding to gpio11.&lt;br /&gt;     &lt;span style="font-style: italic;font-size:85%;" &gt; UINT32                 commSysIntr    = SYSINTR_COMMMOD_WAKEPUP;&lt;br /&gt;      ...&lt;br /&gt;&lt;br /&gt;      OALIoCtlHalEnableWake(IOCTL_HAL_ENABLE_WAKE, &amp;amp;commSysIntr, sizeof(commSysIntr), NULL, 0, NULL);&lt;br /&gt;      ...&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  While the BSPPowerOff function finds out which sysintr is mapped as a wakeup using OALPowerWakeSource and OALIntrTranslateSysIntr functions and sets the pwer bits with BSPSetWakeSrc function call.&lt;br /&gt;&lt;br /&gt;  When system resumes, BSPGetWakeSrc is used to get the wake cause and is stored in g_oalWakeSource variable which can be retrieved using  kernel ioctl IOCTL_HAL_GET_WAKE_SOURCE&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-7963016716953545913?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/7963016716953545913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=7963016716953545913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7963016716953545913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/7963016716953545913'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/adding-low-power-modes-in-pxa-p4.html' title='Adding Low Power modes in PXA - P4'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-318209976896654446</id><published>2008-09-17T05:20:00.000-07:00</published><updated>2009-06-28T02:12:05.096-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='pxa'/><category scheme='http://www.blogger.com/atom/ns#' term='low power mode'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><title type='text'>Adding Low Power modes in PXA - P3</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Wakeup Sources&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When PXA is in low power modes such as Standby, Sleep or DeepSleep, the processor can be brought out using "Wakeups".&lt;br /&gt;&lt;br /&gt;Wakeup is an "external or selected internal event". For example, assume that the power button is connected to GPIO0 of the processor, pressing of power button can be a wakeup source to the processor. Not all the GPIOs can act as wakeup for processor. For PXA the GPIO &lt;116,&gt; can act as wakeup sources. Also there are other wakeup sources such as USB host &amp;amp; client, RTC are wakeup sources.&lt;br /&gt;&lt;br /&gt;Now we may not need to wakeup the processor for activity from any of these sources. Hence we can select the required wakeup source using the Power Manager Wake-up Enable (PWER) register. Also for GPIO wakeup sources, the edges needs to be configured using the Power Manager Rising Edge Detect Enable (PRER) and Falling Edge Detect Enable (PFER) register, so that wakeup will only happen for the selected edge of the transition on the GPIO.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt; NOTE: Take special care in configuring the direction of the GPIO which is chosen as a wakeup. If a wakeup source is configured for a GPIO which is configured as output, some undesirable results can happen.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For keypad and usim wakup there are seperate set of registers too for configuring specifics.&lt;br /&gt;&lt;br /&gt;So in short, while configuring a gpio wake source in pxa, the following things should be taken into consideration:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;  PWER, selecting the wakeup source&lt;/li&gt;&lt;li&gt;  PFER and PRER, fo which edge of GPIO transition , system needs to wakeup&lt;/li&gt;&lt;li&gt;  GPDR, gpio should be configured as input&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-318209976896654446?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/318209976896654446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=318209976896654446' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/318209976896654446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/318209976896654446'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/adding-low-power-modes-in-pxa-p3.html' title='Adding Low Power modes in PXA - P3'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-956055913691358256</id><published>2008-09-16T22:26:00.000-07:00</published><updated>2008-09-16T22:41:28.984-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><title type='text'>When things go wrong....</title><content type='html'>I found a useful post by Bruce Eitman, regarding how to debug some NOT SO FRIENDLY issues like data aborts etc.&lt;blockquote&gt;http://geekswithblogs.net/BruceEitman/archive/2008/07/08/summary-of-when-things-go-wrong.aspx&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-956055913691358256?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/956055913691358256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=956055913691358256' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/956055913691358256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/956055913691358256'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/when-things-go-wrong.html' title='When things go wrong....'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6603461133723660105</id><published>2008-09-16T02:10:00.000-07:00</published><updated>2009-06-28T02:11:55.854-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='pxa'/><category scheme='http://www.blogger.com/atom/ns#' term='low power mode'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><title type='text'>Adding Low Power modes in PXA - P2</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Power Modes in PXA&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PXA has the following power modes&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Normal mode&lt;/li&gt;&lt;li&gt;Idle mode&lt;/li&gt;&lt;li&gt;Deep idle mode&lt;/li&gt;&lt;li&gt;Standby mode&lt;/li&gt;&lt;li&gt;Sleep mode&lt;/li&gt;&lt;li&gt;Deep Sleep mode&lt;/li&gt;&lt;/ul&gt;Each mode is characterized by the power domains that will be kept active and the clocks that will be running. For example in Sleep mode all the external low voltage power domains (i.e. domains controlled by PWR_EN pin of PXA) is disabled. While on the other hand, in Deep Sleep mode both the external low voltage and high voltage power domains are disabled as both PWR_EN and SYS_EN pins are de-asserted while entering the low power mode. The choice of which power mode to use for each depends solely on the power consumption requirements of the product.&lt;br /&gt;&lt;br /&gt;In the beginning of the project, we mapped the Standby mode of PXA to POWER_STATE_SUSPEND state of Windows CE. But as we had a tight power consumption requirement for the Suspend mode, we had to re map the state to Sleep mode of PXA instead of standby.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Transition of Power Modes&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For initiating a power mode transition in PXA, we need write in to the coprocessor 14 , register C7 (PWRMODE). Writing the bit pattern for each pattern corresponding to the power mode in to the PWRMODE[M] bits initiates the transition. For eg:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;XllpPmEnterDeepSleep FUNCTION&lt;br /&gt;&lt;br /&gt;        ldr     r3, =0x00000007&lt;br /&gt;        mcr     p14, 0, r3, c7, c0, 0&lt;br /&gt;        nop&lt;br /&gt;        .......&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;A call to this assembly routine will initiate a transition to deep sleep mode.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;Context Restoration&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;While going into low power modes such as Sleep or Deep Sleep, the processor contents can get corrupted.&lt;br /&gt;&lt;br /&gt;Lets take the example of Sleep mode. In Sleep mode, the PC (Program Counter) value is corrupted along with some other set of registers. So in order to tackle this situation, operating systems are doing a context storage and restoration while going into low power mode. It stores the status of all the required registers such as GPIO configurations, level, stack address, core configuration registers in to a memory area. The address of this memory area is kept in a register which will be retained during the low power mode. In the case of PXA, it is the Power Manager Scratch Pad Register (PSPR). This register value will be maintained during a sleep reset, but will be cleared during GPIO, power on , hardware or watch dog resets.&lt;br /&gt;&lt;br /&gt;So while going in to sleep mode, the required information is stored in a data area in RAM and the address to this area is stored in PSPR register. While resuming from sleep mode, the boot loader will check the PSPR register and will restore the configuration that is stored in the data area.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;NOTE:&lt;/span&gt; bear in mind that the data area is in RAM, so the RAM needs to be properly initialized after a sleep reset, otherwise the boot loader can hand while trying to access the restoration area.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6603461133723660105?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6603461133723660105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6603461133723660105' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6603461133723660105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6603461133723660105'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/adding-low-power-modes-in-pxa-p2.html' title='Adding Low Power modes in PXA - P2'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-3766946951479429252</id><published>2008-09-15T23:44:00.000-07:00</published><updated>2009-06-28T02:11:44.947-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='pxa'/><category scheme='http://www.blogger.com/atom/ns#' term='low power mode'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><category scheme='http://www.blogger.com/atom/ns#' term='kernel'/><title type='text'>Adding Low Power modes in PXA - P1</title><content type='html'>For the windows ce project that we were working on had a lot of power states. As it was a PXA based board, with Mainstone III as the reference platform, we had to map these states to that of PXA.&lt;br /&gt;&lt;br /&gt;The  low power mode mappings were chosen as below:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;POWER_STATE_SUSPEND -  Sleep mode of PXA&lt;/li&gt;&lt;li&gt;POWER_STATE_OFF - Deep Sleep mode PXA&lt;/li&gt;&lt;/ul&gt;As you may have noticed in the Mainstone BSP's OAL code (the common soc code for pxa, i.e., WINCE600\PLATFORM\COMMON\SRC\SOC\PXA27X_MS_V1\OAL\POWER\off.c), the OemPowerOff Function uses the Deep Sleep mode of PXA. This function will be invoked from kernel when power manager issues a power off system.&lt;br /&gt;&lt;br /&gt;Now with the new requirement for our software, we had to modify the existing OAL code and the power manager to add and map the new states to that of the PXA.&lt;br /&gt;&lt;br /&gt;In this post I will walk you through on steps involved in adding a wakeup source in OAL.&lt;br /&gt;&lt;br /&gt;We can splits the process in to two parts&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Mapping a SYSINTR value to the wakeup&lt;/li&gt;&lt;li&gt;Adding the wakeup configuration specific to the processor&lt;/li&gt;&lt;/ol&gt;The detailed steps, I will explain in next post...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-3766946951479429252?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/3766946951479429252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=3766946951479429252' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3766946951479429252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3766946951479429252'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/adding-low-power-modes-in-pxa-p1.html' title='Adding Low Power modes in PXA - P1'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-1464565040636089086</id><published>2008-09-15T23:01:00.000-07:00</published><updated>2008-09-16T23:53:18.616-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><category scheme='http://www.blogger.com/atom/ns#' term='performance monitor'/><title type='text'>CeLog</title><content type='html'>&lt;div style="text-align: justify;"&gt;Its one of the most helpful tools that I have used in WinCE BSP development. Celog is an event-tracking tool that logs a set of predefined (  I think configured or filtered would be an  apt word) for this)  CeLog collects the data given by various sources such as applications or drivers in a location configured in registry.&lt;br /&gt;&lt;br /&gt;Using tools such as CeLogFlush.exe, we can periodically collect the data and can be analyzed in a development workstation.&lt;br /&gt;&lt;blockquote&gt;A Special Thanks to Sue Loh, for posting a really helpful and detail documentation in her blog in MSDN for using CeLog along with tools such as kernel tracker.&lt;/blockquote&gt;While working on the wrist pc project, we were experiencing some unexpected slow of system while booting up and running applications and we were pondering in dark just to figure out the cause of the snail's pace performance. Then I came across the tutorial given by Sue Loh in her microsoft blog on using CeLog on a standalone machine.&lt;br /&gt;&lt;br /&gt;Previously I had used Remote Kernel Tracker, which is built into the platform builder for connecting to a development board using CoreCon and use CeLog to gather Kernel Data (such as interrupt, thread switching, events and other information), on a real time basis (well pretty close to real time). But for this the board needs to be connected to over ethernet or serial to a development work station.&lt;br /&gt;&lt;br /&gt;Most of the times problems will arise while testing under real scenarios. So debugging such issues, I came up with a solution. I made a CAB file with the following things:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;celog.dll&lt;/li&gt;&lt;li&gt;  celogflush.exe&lt;/li&gt;&lt;li&gt;ITaskMgr_arm.exe&lt;span style="font-style: italic;"&gt; (A free task manager I found in net, http://urana.info/mobile/wince/itaskmgr/index.html)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;oscapture.exe&lt;/li&gt;&lt;/ul&gt;  (Also added shortcuts in start menu to launch the exes too, just for the ease of use)&lt;br /&gt;&lt;br /&gt;I distributed this cab file among my team and asked them to install in all the boards that we were using. So at any point of the system is showing any slowness, start the 'CeLogFlush.exe' application, which will periodically dump the performance data on to a file. After significant data is gathered, they can use the ITaskMgr_arm.exe to kill the CeLogFlush flush instance and then take the dumped file.&lt;br /&gt;&lt;br /&gt;This file can be opened in Kernel tracker to view the information.&lt;br /&gt;&lt;br /&gt;In later posts I will explain in detail about CeLogFlush and other tools for performance monitoring.&lt;br /&gt;&lt;br /&gt;Regarding how to analyze the performance data, Sue has put up a detailed tutorial in her blog.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-1464565040636089086?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/1464565040636089086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=1464565040636089086' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1464565040636089086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1464565040636089086'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/celog.html' title='CeLog'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-2780293956523459679</id><published>2008-09-08T12:03:00.000-07:00</published><updated>2008-09-08T12:30:42.850-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>Writing IST for an interrupt defined in OAL</title><content type='html'>In my previous post, I have explained how to add an interrupt when source code is available.&lt;br /&gt;&lt;br /&gt;Now I will explain how to handle an interrupt by writing an IST in the driver. For the reason of continuity, I am using the same power button driver and the Wireless Activity Interrupt (as I explain with in post "Adding Interrupt in OAL").&lt;br /&gt;&lt;br /&gt;1. Create an even to be associated with the interrupt&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;blockquote&gt;    HANDLE g_WlanActiveEvent = CreateEvent(NULL, FALSE, FALSE, NULL);&lt;br /&gt;   if( !g_WlanActiveEvent)&lt;br /&gt;   {&lt;br /&gt;       RETAILMSG(1, (TEXT("WlanActivityMonitorStart: Failed to create Intterupt Event\r\n")));&lt;br /&gt;       goto CleanUp;&lt;br /&gt;   }&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;2. Associate the Interrupt with the event using SYSINTR value&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;UINT32 g_SysIntr      = SYSINTR_WLAN;  &lt;br /&gt;......&lt;br /&gt;result = InterruptInitialize(g_SysIntr, g_WlanActiveEvent, NULL, 0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    if(!result)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;        RETAILMSG(1, (TEXT("WlanActivityMonitorStart: InterruptInitialize() failed. GetLastError=0x%x\r&lt;br /&gt;                                 \n"),GetLastError()));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;        goto CleanUp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    }&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;3.  Start a thread for handling the interrupt.&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;blockquote&gt;g_WlanThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) WlanThread, NULL, 0, NULL);&lt;br /&gt;   if ( g_WlanThread == NULL )&lt;br /&gt;   {&lt;br /&gt;       RETAILMSG(1, (TEXT("WlanActivityMonitorStart: Failed to create WlanActive&lt;br /&gt;                                  Intterupt Thread\r\n")));&lt;br /&gt;       goto CleanUp;&lt;br /&gt;   }&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4. In the thread, wait for the event to happen using the WaitForSingleObject or WaitForMultipleObjects API.&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;INT  WlanThread (VOID) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    while(!g_FlagExitThrd)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;        WaitForSingleObject(g_WlanActiveEvent, INFINITE);&lt;/span&gt;&lt;br /&gt;          .............&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    return ERROR_SUCCESS;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;5. Perform the necessary operations to service that interrupt. Here I am pulsing another event to notify some other sets of appication.&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;font-size:85%;"  &gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;font-family:arial;font-size:85%;"  &gt;        WaitForSingleObject(g_WlanActiveEvent, INFINITE);&lt;br /&gt;       InterruptMask(g_SysIntr,TRUE);&lt;br /&gt;&lt;br /&gt;       if (g_WlanEvent)&lt;br /&gt;       {&lt;br /&gt;           RETAILMSG(1, (TEXT("WlanThread: Intterupt \r\n")));&lt;br /&gt;           PulseEvent(g_WlanEvent);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       Sleep (1000); // Sleep to ignore some activity as this line toggles a lot&lt;br /&gt;       InterruptMask(g_SysIntr,FALSE);&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;6. Signal the completion of interrupt handling using InterruptDone&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;blockquote&gt;InterruptDone(g_SysIntr);&lt;/blockquote&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-2780293956523459679?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/2780293956523459679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=2780293956523459679' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2780293956523459679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/2780293956523459679'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/writing-ist-for-interrupt-defined-in.html' title='Writing IST for an interrupt defined in OAL'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-1300041407649183448</id><published>2008-09-08T07:45:00.000-07:00</published><updated>2008-09-08T10:39:59.069-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fun at work'/><title type='text'>Dreams or Nightmares of an embedded systems engineer</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Q826e5YoAjQ/SMU8G96xu2I/AAAAAAAADes/_Ot3alLE4QA/s1600-h/SUndhar.jpg"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_Q826e5YoAjQ/SMU8G96xu2I/AAAAAAAADes/_Ot3alLE4QA/s320/SUndhar.jpg" alt="" id="BLOGGER_PHOTO_ID_5243663431540783970" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;courtesy : Mrs. PV &amp;amp; Mappila sir&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-1300041407649183448?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/1300041407649183448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=1300041407649183448' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1300041407649183448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1300041407649183448'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/dreams-or-nightmares-of-embedded.html' title='Dreams or Nightmares of an embedded systems engineer'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Q826e5YoAjQ/SMU8G96xu2I/AAAAAAAADes/_Ot3alLE4QA/s72-c/SUndhar.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-1757114891983977562</id><published>2008-09-08T03:16:00.001-07:00</published><updated>2008-09-08T09:45:47.627-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='mistakes'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><title type='text'>Common Mistakes made - P2</title><content type='html'>&lt;div style="text-align: justify;"&gt;While going into low power modes of windows while coming back up, restore the processor and peripherals back to the state it was before.&lt;br /&gt;&lt;br /&gt;One problem that we had faced in our project was regarding the restoration of PCCARD timings. Although we were using the original MainstoneIII BSP in Wince6, we had to modify the boot loader and other startup initializations to match the new board which we were designing. On doing so, we commented out the PCCARD timing initializations in xlli_low_level_init.s file.&lt;br /&gt;&lt;br /&gt;On PCCARD socket, we had a Wireless LAN card, which was working properly. But after a suspend-resume cycle, the network adapter was shown as down in the drivers. We couldn't figure out what was the reason for this behaviour. Wasted a lot of precious time in debugging the issue. Using a debug version of the driver from vendor, we were able to figure out that after a suspend-resume cycle, the driver was not able to access the card.&lt;br /&gt;&lt;br /&gt;So we decided to try a reinitialization of the full PCCARD driver. On trying the pccard and wlan was back up in working state. But the entire driver initialization was slowing down the resuming of the system.&lt;br /&gt;&lt;br /&gt;We again analyzed the reinitialization process, then it hit me. I decided to access the pccard attribute memory immediatly after the resuming in OAL. There I came to realize that the problem is way before the OS.&lt;br /&gt;&lt;br /&gt;We did a walk though of the Boot loader code, i.e. the path followed during a sleep reset and found out that the section of code for re-initialization of pccard was commented.&lt;br /&gt;&lt;br /&gt;Although we fixed the problem, we had to waste a lot of precious project development time in debugging the issue.&lt;br /&gt;&lt;br /&gt;So when dealing with low level initializations in bootloader or restoration code, be careful what you are modifying. One way or the other that will come back to  haunt you :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-1757114891983977562?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/1757114891983977562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=1757114891983977562' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1757114891983977562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1757114891983977562'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/common-mistakes-made-p2.html' title='Common Mistakes made - P2'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6923244194914032954</id><published>2008-09-07T11:39:00.000-07:00</published><updated>2008-09-08T03:13:41.764-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='videos'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><title type='text'>Some useful videos from Microsoft Channel9</title><content type='html'>Here are links to some  really good and informational videos, hosted in microsoft channel.&lt;br /&gt;For me, they were really helpful in building up the basic of the windows ce system architecture.&lt;br /&gt;&lt;br /&gt;http://channel9.msdn.com/posts/TravisHobrla/Porting-Drivers-to-Windows-CE-60/&lt;br /&gt;&lt;br /&gt;http://channel9.msdn.com/posts/Rory/Windows-CE-Windows-XP-Embedded-and-Windows-Mobile-Explained/&lt;br /&gt;&lt;br /&gt;http://channel9.msdn.com/posts/Charles/Bor-Ming-Hsieh-and-Sue-Loh-3rd-Generation-Kernel-for-Windows-CE/&lt;br /&gt;&lt;br /&gt;http://channel9.msdn.com/posts/Charles/Juggs-Ravalia--Windows-CE-60-Device-Driver-Model/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6923244194914032954?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6923244194914032954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6923244194914032954' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6923244194914032954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6923244194914032954'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/some-useful-videos-from-microsoftt.html' title='Some useful videos from Microsoft Channel9'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-5244579442082459179</id><published>2008-09-07T11:21:00.000-07:00</published><updated>2008-09-08T00:12:13.307-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oal'/><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><title type='text'>Adding Interrupt in OAL</title><content type='html'>When we are having the whole BSP source, there will be cases in which we may need to add interrupt in OAL. This can be accommodate a new driver or add a new functionality to the existing one.&lt;br /&gt;&lt;br /&gt;For explaining the procedure I am using the Mainstone BSP that is available in windows ce. Lets assume that we want to add an interrupt for Wireless LAN activity. This interrupt line will be a GPIO line which is mapped to GPIO 91 of PXA.&lt;br /&gt;&lt;br /&gt;These are the files that need modification:&lt;br /&gt;  * bsp_cfg.h (Src\Inc)&lt;br /&gt;  * intr.c (OAL)&lt;br /&gt;&lt;br /&gt;In 'bsp_cfg.h', you need to define a SYSINTR (if needed) for the new interrupt that you are about to add.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;            &lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;.............&lt;br /&gt;          #define SYSINTR_PWRBTN          (SYSINTR_FIRMWARE+14) // 30&lt;br /&gt;          #define SYSINTR_WLANACTIVE  (SYSINTR_FIRMWARE+15) // 31 - The new interrupt&lt;br /&gt;           ................&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Now in OAL, intr.c, make the following changes:&lt;br /&gt;            1. In BSPIntrInit() function, add a call to OALIntrStaticTranslate() to map the&lt;br /&gt;                the new SYSINTR v alue to the GPIO.&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                              &lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;............... &lt;br /&gt;                             OALIntrStaticTranslate (SYSINTR_WLAN,IRQ_GPIOXX_2_GPIO91);&lt;br /&gt;                             ...............&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;            2. In BSPIntrEnableIrq(), add the case of enabling the GPIO Interrupt&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                               &lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;"&gt;.................&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                                        else if (irq == IRQ_GPIOXX_2_GPIO91)&lt;br /&gt;                                       {&lt;br /&gt;                                                EnableGPIO91Irq(); // define this function for enabling falling or rising&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;//edge detect and clear edge detect&lt;br /&gt;                                       }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                              .................&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;            3. In BSPIntrDisableIrq(), add the case of enabling the GPIO Interrupt&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                               &lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;"&gt;.................&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                                        else if (irq == IRQ_GPIOXX_2_GPIO91)&lt;br /&gt;                                       {&lt;br /&gt;                                                DisableGPIO91Irq(); // define this function for clearing falling rising&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;               &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                 &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;//edge detect so that interrupt wont come&lt;br /&gt;                                       }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;                              .................&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;           4.  Define the functions for enabling and disabling the gpio interrupt&lt;br /&gt;                     &lt;blockquote&gt;............&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            //~~ Function for disabling gpio91 interrupt&lt;br /&gt;                           static void EnableGPIO91Irq(void)&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;    SETREG32((PULONG)&amp;amp;g_pGPIORegs-&gt;GRER2, XLLP_BIT_27);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;//~~ Function for enabling gpio91 interrupt&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;static void  DisableGPIO91Irq(void)&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;    CLRREG32((PULONG)&amp;amp;g_pGPIORegs-&gt;GEDR2, XLLP_BIT_27);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;    CLRREG32((PULONG)&amp;amp;g_pGPIORegs-&gt;GRER2, XLLP_BIT_27);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;                            &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This is how we add a new interrupt in OAL.&lt;br /&gt;&lt;br /&gt;My friend mukesh has written in his blog, how to dynamically add an interrupt handler, when OAL source code is not available.&lt;br /&gt;&lt;br /&gt;In the next posts, I will explain how to add an IST (Interrupt Service Thread) to take care of this interrupt.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-5244579442082459179?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/5244579442082459179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=5244579442082459179' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5244579442082459179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/5244579442082459179'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/adding-interrupt-in-oal.html' title='Adding Interrupt in OAL'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6866501200778180028</id><published>2008-09-07T11:02:00.000-07:00</published><updated>2008-09-08T00:52:07.076-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='power manager'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><title type='text'>Making a device "Power-Managed"</title><content type='html'>&lt;div style="text-align: justify;"&gt;Power manager uses IOCTLs to interact with Power-Managed devices.  So inorder to make a device power managed implement certain set of IOCTLs in the driver with  registry changes.&lt;br /&gt;&lt;br /&gt;For the purpose of explaining, i am taking the sample of the Power Button driver implemented in Mainstone platform available in windows ce 6.0. Please bear in mind that this driver is already having a function which monitors system power state transitions using Notification Queues. But I am not going to make use of them.&lt;br /&gt;&lt;br /&gt;Here I will briefly describe the steps involved in doing the same. We can divide the changes in to two parts:&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Change in registry settings for driver&lt;/li&gt;&lt;li&gt;Implementing IOCTLs&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Change in registry settings for driver&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now as the documentation for power manager, each power managed device needs to be classified under a certain category i.e Generic power-manageable devices, Power-manageable block devices and Power-manageable NDIS miniports. Each class is identified by a certain GUID(defined in pm.h).  Associating a device to a power manager class is really easy, just by adding a registry entry to the device driver entry, as follows.&lt;br /&gt;&lt;br /&gt;I will make this power button driver as a generic device&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\PWB]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;               "Prefix"="PWB"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;               "Dll"="mainstoneii_pwrbutton.dll"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;               "Order"=dword:3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;              &lt;span style="color: rgb(255, 0, 0);"&gt;"IClass"="{A32942B7-920C-486b-B0E6-92A702A99B35}"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;  ;; we are making it as generic device over here&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;When device manager loads the driver, it will associate the device to the class.&lt;br /&gt;&lt;br /&gt;Now power manager will start issuing the IOCTLs to the driver and query the capabilities of the driver. The details I will explain in the next section.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;Note : &lt;/span&gt;We should atleast implement &lt;span id="nsrTitle"&gt;IOCTL_POWER_CAPABILITIES&lt;/span&gt; in a driver to make it power managed&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Implementing IOCTLs&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The driver needs to implement the following IOCTLs for interacting with power manager:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;IOCTL_POWER_CAPABILITIES **&lt;/li&gt;&lt;li&gt;IOCTL_POWER_GET &lt;/li&gt;&lt;li&gt;IOCTL_POWER_QUERY *&lt;/li&gt;&lt;li&gt;IOCTL_POWER_SET &lt;/li&gt;&lt;li&gt;IOCTL_REGISTER_POWER_RELATIONSHIP *&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;** - This IOCTL is mandatory for the entire thing to work&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;* - rather optional&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When power manager receives a request to register a device driver under a particular device class, it first passes IOCTL_POWER_CAPABILITIES to the driver. If the call returns false, the driver wont be registered otherwise it will be. This IOCTL should return the device capabilities.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt; &lt;/span&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;   &lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;    BOOL IOControl(   .............              )&lt;br /&gt;   {&lt;/span&gt;&lt;br /&gt;      ................&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;         case IOCTL_POWER_CAPABILITIES :&lt;br /&gt;        if (NULL != pOutBuf)&lt;br /&gt;        {&lt;br /&gt;            memcpy(pOutBuf, &amp;amp;PWBDrvPowerCaps, sizeof(PWBDrvPowerCaps));&lt;br /&gt;            *pdwBytesTransferred =  sizeof(PWBDrvPowerCaps);&lt;br /&gt;            OutBufLen = sizeof(PWBDrvPowerCaps);&lt;br /&gt;            dwErr = ERROR_SUCCESS;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            dwErr = ERROR_INVALID_PARAMETER;&lt;br /&gt;        }&lt;br /&gt;        break;        // IOCTL_POWER_CAPABILITIES&lt;br /&gt;&lt;/span&gt;         ...............&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;           if(dwErr != ERROR_SUCCESS) {&lt;br /&gt;               bRc = FALSE;&lt;br /&gt;         } else {&lt;br /&gt;            bRc = TRUE;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;         return bRc;&lt;/span&gt;&lt;br /&gt; }&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;The variable &lt;span style="font-style: italic;font-size:85%;" &gt;PWBDrvPowerCaps &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;"&gt;contains&lt;/span&gt;&lt;/span&gt; the device power capabilities of the driver in a POWER_CAPABILITIES structure.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt; &lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;       POWER_CAPABILITIES PWBDrvPowerCaps =&lt;br /&gt;    {&lt;br /&gt;        DX_MASK(D0) | DX_MASK(D2) | DX_MASK(D3) | DX_MASK(D4),&lt;br /&gt;        0,&lt;br /&gt;        0,&lt;br /&gt;        {&lt;br /&gt;        0x00000000, // D0&lt;br /&gt;        0x00000000, // D1&lt;br /&gt;        0x00000000, // D2&lt;br /&gt;        0x00000000, // D3&lt;br /&gt;        0x00000000  // D4&lt;br /&gt;        },&lt;br /&gt;        {&lt;br /&gt;        0x00000000, // D0&lt;br /&gt;        0x00000000, // D1&lt;br /&gt;        0x00000000, // D2&lt;br /&gt;        0x00000000, // D3&lt;br /&gt;        0x00000000  // D4&lt;br /&gt;        },&lt;br /&gt;        0&lt;br /&gt;    };&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;For information on the meaning of each parameter please refer MSDN. After returning true from the IOCTL, power manager will register this device under the requested class in registry.&lt;br /&gt;&lt;br /&gt;From now on wards, when ever a state change occurs (or is requested) for the device or system, power manager will send the IOCTL_POWER_SET  to the driver and the driver can take care of the same.&lt;br /&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-style: italic;font-size:85%;" &gt;&lt;br /&gt;    case IOCTL_POWER_SET:&lt;br /&gt;    if ( pOutBuf != NULL )&lt;br /&gt;    {&lt;br /&gt;        SetPwbPowerState(*(PCEDEVICE_POWER_STATE) pOutBuf);&lt;br /&gt;        dwErr = ERROR_SUCCESS;&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;        dwErr = ERROR_INVALID_PARAMETER;&lt;br /&gt;    break;  // IOCTL_POWER_SET&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;In SetPwbPowerState&lt;/span&gt;(), you can define the power depending on the paramater.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6866501200778180028?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6866501200778180028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6866501200778180028' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6866501200778180028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6866501200778180028'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/making-device-power-managed.html' title='Making a device &quot;Power-Managed&quot;'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-1069832212111482202</id><published>2008-09-07T09:39:00.000-07:00</published><updated>2008-09-07T10:50:34.345-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='accord'/><title type='text'>My team</title><content type='html'>my teammates..&lt;br /&gt;muku, ambi n ankit&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Q826e5YoAjQ/SMQTumonrQI/AAAAAAAADdU/dQzXYDRsM3Y/s1600-h/DSC01767.jpg"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_Q826e5YoAjQ/SMQTumonrQI/AAAAAAAADdU/dQzXYDRsM3Y/s320/DSC01767.jpg" alt="" id="BLOGGER_PHOTO_ID_5243337557531929858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@ taj gateway with gopu, cimbu, shobin, ambi, me, muku n ankit&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Q826e5YoAjQ/SMQFfhUt6EI/AAAAAAAADdM/RZUZi5IDXTs/s1600-h/DSC01756.jpg"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_Q826e5YoAjQ/SMQFfhUt6EI/AAAAAAAADdM/RZUZi5IDXTs/s320/DSC01756.jpg" alt="" id="BLOGGER_PHOTO_ID_5243321905245448258" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The whole team :)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Q826e5YoAjQ/SMQE_bAzdcI/AAAAAAAADdE/t6bPukA2opQ/s1600-h/DSC01749.jpg"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_Q826e5YoAjQ/SMQE_bAzdcI/AAAAAAAADdE/t6bPukA2opQ/s320/DSC01749.jpg" alt="" id="BLOGGER_PHOTO_ID_5243321353795499458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;work'n'fun&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-1069832212111482202?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/1069832212111482202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=1069832212111482202' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1069832212111482202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/1069832212111482202'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/my-team.html' title='My team'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Q826e5YoAjQ/SMQTumonrQI/AAAAAAAADdU/dQzXYDRsM3Y/s72-c/DSC01767.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-3707524672498258062</id><published>2008-09-07T07:56:00.001-07:00</published><updated>2008-09-07T08:50:49.077-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='mistakes'/><category scheme='http://www.blogger.com/atom/ns#' term='drivers'/><title type='text'>Common Mistakes made - P1</title><content type='html'>This is one the common mistakes that I have made while I was working on windows ce and also saw others making them too....&lt;br /&gt;&lt;br /&gt;                                          "Don't Forget the BIB file"&lt;br /&gt;&lt;br /&gt;When adding extra drivers or other applications in the BSP, we always missed out adding the entry in BIB file. During development from platform builder, we wont notice any problem (if we don't pay attention to the LOG messages). Because while working from a development platform, there will be an extra directory in "My device" folder, called Release. So when the the file is required to be loaded, application or driver dll, it will be loaded from this directory.&lt;br /&gt;&lt;br /&gt;But when the device is in stand alone mode, this Release directory wont be present and the DLL or application will fail to load. Most of the times we were wondering whats happening. We were concentrating only on the registry settings. Didn't notice that the file loading was failing. After some digging around and wasting valuable time, we found out the culprit :)&lt;br /&gt;&lt;br /&gt;So think of this point while adding your drivers ok :)&lt;br /&gt;&lt;br /&gt;Dont miss the BIBle :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-3707524672498258062?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/3707524672498258062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=3707524672498258062' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3707524672498258062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/3707524672498258062'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/common-mistakes-made-p1.html' title='Common Mistakes made - P1'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053373784078711683.post-6353091892764106586</id><published>2008-09-07T07:23:00.000-07:00</published><updated>2008-09-07T08:51:53.105-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wince'/><category scheme='http://www.blogger.com/atom/ns#' term='aboutme'/><title type='text'>First Windows CE Project</title><content type='html'>My first windows CE project was the wrist pc project. Development of a wrist wearable computer for an Italian client. Our aim was to design a board and the software compliant with the specification given by the client.&lt;br /&gt;&lt;br /&gt;The board will have a PXA270  processor from Marvell, with the following peripherals:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;1X USB Host port&lt;/li&gt;&lt;li&gt;1X USB Client port&lt;/li&gt;&lt;li&gt;a 640x480 - 18bpp display&lt;/li&gt;&lt;li&gt;Accelerometer&lt;/li&gt;&lt;li&gt;Ambient Light sensor&lt;/li&gt;&lt;li&gt;Keypad&lt;/li&gt;&lt;li&gt;Micro SD card slot&lt;/li&gt;&lt;li&gt;Wireless LAN&lt;/li&gt;&lt;li&gt;Wireless WAN (Phone module)&lt;/li&gt;&lt;/ul&gt;..... and a lot of other stuff.&lt;br /&gt;&lt;br /&gt;In the team first formed, I was not there. Later on Prashanth added me in to the team for BSP and application development to help out Sundhar and Ambika. Later on Ankit, Mukesh, Gopu and Rajesh joined in to our team. I was kind of a one big happy family ... Although with the occassional "nuclear bomb explosions" by Prashanth, for things not going as smoothly as it was supposed to be. :)&lt;br /&gt;&lt;br /&gt;First itself, I was exhilerated  by the shear size and complexity of the project. Well most part was the excitment. I had no prior experience in Windows CE or in Embedded Systems. The only things that I had ever closer to mircoprocessors or embedded systems was the Microprocessor class which I had in fourth or fifth semester in my college.  And also no one in the company had prior experience in working on windows ce. But Ambika and Sundhar had worked on embedded systems projects before, they have been a great help for me in picking up the pieces.&lt;br /&gt;&lt;br /&gt;We also had one more team working on the design and development of the hardware. We were concentrating on the software aspects of them.&lt;br /&gt;&lt;br /&gt;....&lt;br /&gt;continued in next part&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053373784078711683-6353091892764106586?l=devwince.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devwince.blogspot.com/feeds/6353091892764106586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1053373784078711683&amp;postID=6353091892764106586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6353091892764106586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053373784078711683/posts/default/6353091892764106586'/><link rel='alternate' type='text/html' href='http://devwince.blogspot.com/2008/09/tirst-windows-ce-project.html' title='First Windows CE Project'/><author><name>Vaisakh P S</name><uri>http://www.blogger.com/profile/02782445552012217777</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Q826e5YoAjQ/Sa-K_s-C50I/AAAAAAAAH30/xNv44kltML4/S220/cfightclub18.gif'/></author><thr:total>0</thr:total></entry></feed>
