BSP Template

The Microsoft CE Base Team has posted a Board Support Package (BSP) template on their blog here.  While it’s clearly a work in progress, its great documentation on what entry points are both required and optional in a Windows CE BSP.  Check it out, if only to browse the code.

Posted in Windows CE | Comments Off

Windows Mobile 6.1 Memory Management Changes

I just returned from the Microsoft TechEd conference in Orlando.  While there, I gave two talks and presented a Preconference tutorial. During the preconference tutorial, I discussed changes to the Windows Mobile 6.1 memory model.  Here is a short summary of the changes.

Despite the implication of the “6.x” version number, Windows Mobile 6.1, like Windows Mobile 6 and Windows Mobile 5 are based on a modified Windows CE 5.0 kernel, not the newer Windows Embedded CE 6 kernel.  The “old” kernel uses the slot based model for memory management shown in the figure below.

Processes are assigned a “slot” from 2 to 32 allowing up to 31 processes. (The kernel is counted as the 32nd process.)  The process with the currently running thread is cloned into slot 0.  This allows each application to act as if it is running in slot 0 since when a thread in a process is running that process is in slot 0.  Slot 1 is used to load DLLs that have been bundled with the system.  Slot 63, at the top of the Large Memory Area, is used to store resource only DLLs, those DLLs that have no code, only resource data such as fonts and strings.  More detail on this memory model, and the problems associated with it can be found in a white paper I wrote a while back titled Windows CE Advanced Memory Management.  (For those interested in Windows Embedded CE 6, I wrote paper on CE 6 memory management here.)

The problem with memory in Windows Mobile has always been the vast number of DLLs in the system.  DLLs are loaded from the top of slot 1 down.  Since there are so many DLLs in the system, not only do they fill up slot 1, they encroach into slot 0.  This leaves only about 18-20 Meg of virtual space for each application.  This problem is most acute in the Device Manager process space where dozens of device drivers, each with their own interrupt service thread, tended to consume most of the virtual space in that process.

This slot arrangement remained pretty constant from Windows Mobile 2003 to Windows Mobile 6.0.  However, with the release of Windows Mobile 6.1, things were changed to reduce the DLL pressure and to help out in the Device Manager process space.

In Windows Mobile 6.1, the stacks for the device manager are no longer allocated in the processes’ slot.  Instead, the operating system uses slot 59, at the top of the Large Memory Area, for the device manager thread stacks.

In addition to the stack move, changes were also made in where DLLs are placed.  While execute-in-place(XIP) DLLs are still loaded from the top of Slot 1, any DLL that is larger than 64 KB and isn’t XIP is loaded in slot 60.  If the 32 MB of slot 60 fills up with DLLs, the OS uses slot 61 for the DLLs.   This additional 64 MB of DLLs space should go a long way in reducing the problem of too many DLLs in Windows Mobile systems.  The new memory map now looks like this:

The shared heap slot was added in Windows CE/Windows Mobile 5 but its addition wasn’t an attempt to solve the DLL problems with Windows Mobile. While in this diagram it looks like the large memory area has been shrunk significantly, it really hasn’t.  The LMA size, which is close to 1 GB was only reduced 128 MB.

To take advantage of this change, OEMs who build Windows Mobile systems need to adjust how they assign DLLs in their .BIB files.  Now, large DLLs should be moved from the MODULES section of the .BIB to the FILES section.  This change prevents the tools from converting those DLLs to XIP.  DLLs smaller than 64 KB should be left in the MODULES section.

Third party application developers really don’t have to do anything to take advantage of this new arrangement.  It has always been good practice to combine DLL code into a few, large DLLs.  Now, if that DLL is larger than 64 KB, it’ll be loaded in one of the upper slots.  This won’t change the way DLLs operate, its just you may notice some rather unusual base addresses for DLLs when you start debugging your application on Windows Mobile 6.1.

Posted in Windows Mobile | Comments Off

Welcome

Hi,

My name is Doug Boling and I’ve been working on Windows CE since before it was released by Microsoft in 1996. I’ve written a book on Windows CE called appropriately enough Programming Microsoft Embedded Windows CE The book is now in it’s 4th edition. You can find the book on Amazon here.

These days I spend my time consulting and teaching classes on Windows CE and Windows Mobile systems.

After years of resistance, I’ve finally been assimilated into the blogging world. I hope to use this blog to provide useful information on Windows Embedded CE, Windows Phone and the old Windows Mobile platform and to occasionally vent on things that matter to me. I hope the information in the blog will be useful. We’ll see how things turn out.

Doug

Posted in Uncategorized | Comments Off