Windows CE Kernel

A collection of posts about the Windows CE Kernel
Platform Builder: Communicating Between the Bootloader and the OS
In the article Platform Builder: Setting Default Memory Divisions, I discussed using pOEMCalcFSPages() or pfnCalcFSPages() to set the memory division between storage and program memory. In that article I presented the following function: DWORD OEMCalcFSPages(DWORD dwMemPages, DWORD dwDefaultFSPages) { DWORD Percent = 50; return ( dwMemPages * Percent ) / 100; } Then I suggested that with enough knowledge of your BSP and an imagination, you could dynamically set the percent value instead of using ......

Posted On Friday, December 11, 2009 12:34 PM | Comments (1)

Platform Builder: Setting Default Memory Divisions
Windows CE divides the system RAM into two parts; storage memory and program memory. These two parts are equally divided by default. The problem with that is that some systems need to store files than they need program space, and some systems need more program space than storage. The division can be changed dynamically at run time, which I discussed in Windows CE: Automatically setting the Object Store Size But the device OEM can change the division default in two ways: 1. FSRAMPERCENT in config.bib ......

Posted On Wednesday, December 9, 2009 2:37 PM | Comments (4)

Platform Builder: Setting the Default Thread Quantum
The default thread quantum, the amount of time that the schedule allows a thread to run before scheduling a different thread to run, has been set to 100 milliseconds since Windows CE 3.0. Prior to Windows CE 3.0 the quantum was shorter (if memory serves me right it was 25 ms.) The change to 100 ms was made to improve real time performance. The longer quantum allows most real time threads to run as long as they need to service hardware, but stops them if they get greedy to allow other threads to run. ......

Posted On Tuesday, October 13, 2009 1:04 PM | Comments (2)

Windows CE: OEMInterruptEnable() and OEMInterruptDisable()
The functions OEMInterruptEnable() and OEMInterruptDisable() are functions that a Windows CE device OEM must provide to enable and disable single interrupts. These functions receive as a parameter a SYSINTR value. They must map the SYSINTR value to an IRQ and then enable or disable the correct interrupt. These functions are called indirectly by drivers. Drivers call functions like InterruptInitialize(), InterruptDone(), InterruptDisable(), and InterruptMask(). InterruptInitialize(), InterruptDone() ......

Posted On Monday, June 15, 2009 10:36 PM | Comments (0)

Windows CE: OEMInterruptHandler()
OEMInterruptHandler() is a required kernel function for ARM processors. When an interrupt occurs, the kernel calls OEMInterruptHandler() to determine which interrupt needs to be serviced. OEMInterruptHander() then returns the SYSINTR value associated with the interrupt. OEMInterruptHandler() allows Windows CE to handle interrupts on various CPUs and board designs. There are many ways to write OEMInterruptHandler(), and the implementation will vary based on the CPU being used. Each CPU potentially ......

Posted On Wednesday, June 10, 2009 9:06 PM | Comments (0)

Windows CE: Kernel Interrupt Handling
What happens when an interrupt occurs? This article will focus on what the kernel does when the interrupt occurs, so this will assume that the interrupt is initialized and enabled. 1. IRQ is signaled in hardware 2. A vectored function is called in the kernel – the calling of the function is controlled by hardware, so the implementation is CPU family dependent. The vector table is initialized by the Kernel when it starts. 3. Interrupts are disabled 4. OEMInterruptHandler() is called to determine the ......

Posted On Monday, June 8, 2009 8:38 PM | Comments (4)

Platform Builder: Problems with .NET CF 3.5 and Windows CE 6.0
A customer contacted me a few weeks ago to tell me that their managed code application failed when running on Windows CE 6.0 with the .NET CompactFramework 3.5. It ran fine on Windows CE 5.0 with .NET CF 3.5 and on Windows CE 6.0 with .NET CF 2.0. The problem was really odd because it showed up in different ways, but usually there was an error message similar to: File or assembly name 'System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=3BE235DF1C8D... or one of its dependencies, ......

Posted On Friday, May 15, 2009 10:06 PM | Comments (5)

Windows CE: Cleaning the Registry Hive
Do you ever need to put a Windows CE system to its factory state? I know that we do. Sometimes it is because the system has been used for testing or burn in. If the system doesn’t have any persistent store, this can easily be handled by resetting the device. But if the system uses the hive based registry on a persistent file system, returning the device to its factory state can be more difficult. The following are ways that I know have been used to erase the hive registry: 1. Reformat the persistent ......

Posted On Tuesday, April 28, 2009 9:47 PM | Comments (4)

Platform Builder: OEMIoControl: Unsupported Code
There are several KernelIoControl() IOCTLS that are called during boot up that are optional. That is the OEM can choose to implement them or not depending on whether the IOCTLs add value to the system. The problem comes when running a debug build of the kernel. Any KernelIoControl() that is passed to OEMIoControl() and not handled will be noted in the debug output. Example: OEMIoControl: Unsupported Code 0x10100b4 - device 0x0101 func 45 While not specifically outputting that these are error or warning ......

Posted On Friday, March 13, 2009 11:18 PM | Comments (0)

Windows CE: Detecting Timer Interrupt Failures
I have written about problems with timer interrupt handlers before in Windows CE: Why does my system halt for 20 minutes? But that is really aimed at the OEM responsible for writing the interrupt service routine for the timer interrupt. Today, I have been fielding questions from an end user who thinks that he might have this problem. He needs to convince the OEM that the OEM has the problem and needs to fix it. Of course the first thing to do is determine if he really does have the problem. Let’s ......

Posted On Sunday, February 8, 2009 10:40 PM | Comments (11)

Platform Builder: How to Determine the Baud Rate of the Serial Debug Port
Every once in a while, someone finds my blog by searching for how to determine the baud rate of the serial debug port. So I thought that I would look into how to answer that for them. First, try 38400, 8 bit, no parity, 1 stop bit and no handshaking. This is a common setting for the serial debug port. Second, read the documentation for your board if you bought it in a system from an OEM. Last, look in the code. If you need to do this, then you must be the OEM and using a BSP from either Microsoft ......

Posted On Monday, January 12, 2009 11:08 PM | Comments (0)

Platform Builder: KernelRelocate()
KernelRelocate() copies initialized global variables to RAM, and sets uninitialized global variables to zero. KernelRelocate() is called from both the bootloader and the kernel. If you are more familiar with writing applications that run within an Operating System (OS) then needing KernelRelocate() is different. When you run an application within an OS, initialization of global variables is automatically performed for the application by the OS. But, the bootloader and the kernel are the OS, so they ......

Posted On Friday, January 2, 2009 1:32 PM | Comments (0)

Platform Builder: Handling Noncontiguous RAM
Someone recently posted a question to the Platform Builder newsgroup (microsoft.public.windowsce... on the msnews.microsoft.com NNTP server) asking about how to set up noncontiguous RAM. Seemed like the answers were going okay until someone replied with: “Besides OEMGetExtensionDRAM function, you can also map the two separate physical memory sections into single one virtual memory in oemaddrtab_cfg.inc. From system view, it has only one memory section and the only thing you need to do is ......

Posted On Sunday, December 21, 2008 9:06 PM | Comments (6)

Windows CE: The Case of the Missed Interrupt
I was recently working on an interrupt that was asserted, but the system didn’t respond by handling the interrupt. The interrupt that wasn’t being handled came from a CPLD into a GPIO pin. The CPLD asserts the interrupt in response to several external events. I thought that this would make a good example of what not to do in an ISR. If only one of the external events was triggering, then the interrupt seemed to work well. If more than one triggered, not necessarily at the same time, then eventually ......

Posted On Thursday, November 6, 2008 1:49 PM | Comments (2)

Platform Builder: Understanding the Serial Debug Port
Recently, there have been a few questions in the newsgroups about the serial debug port. The questions were along the lines of: · Which COM port do I use for debug output? · How do I change the COM port that is used for debug output? These are actually quite common questions, so I thought I would address these. Every CPU and/or UART is different so I won’t give you a how to lesson, but I will provide you with enough information to look inside your BSP to figure it out for yourself. First, let’s address ......

Posted On Monday, September 8, 2008 9:32 PM | Comments (2)

Windows CE: Number of Processes and Threads
Once in a while I am asked how many processes can run at any time in a Windows CE system. It is also one of my interview questions when interviewing a candidate with Windows CE experience, and the follow on question is how many threads can run at one time? Number of Processes: Then number of processes is controlled by the kernel and was changed for Windows CE 6.0 to be 32K processes. Pretty impressive, but I suspect that the limit is much smaller because on most, if not all, Windows CE systems you ......

Posted On Wednesday, August 6, 2008 10:37 PM | Comments (1)

Platform Builder: Clone Public Code
I recently wrote an article about modifying the behavior of KernelIoControl when called by User Mode code. In that article, I stated that you need to clone the Public oemioctl code to your platform. Sounds so simple doesn’t it, and really it isn’t that difficult if you know what you are doing, but for the rest of you I thought that I would walk through the process of cloning code. Many of us use the term “clone code” but what does it really mean? Cloning code means to copy the code to another build ......

Posted On Wednesday, July 2, 2008 2:32 PM | Comments (29)

Windows CE 6.0: User Mode KernelIoControl
Windows CE 6.0 introduces some new security features including new meaning for User Mode and Kernel Mode. Loosely speaking, Kernel Mode has access to the system’s resources and User Mode is greatly restricted. One of the new restrictions on User Mode code is that calls to KernelIoControl are limited to the following OEMIoControl IOCTLs: IOCTL_HAL_GET_CACHE_INFO IOCTL_HAL_GET_DEVICE_INFO IOCTL_HAL_GET_DEVICEID IOCTL_HAL_GET_UUID IOCTL_PROCESSOR_INFORMATION As an OEM you can change this to allow access ......

Posted On Tuesday, July 1, 2008 2:21 AM | Comments (5)

Windows CE: Why does my system halt for 20 minutes?
I don't know how many systems are affected by this problem, but apparently there are still some. I do know that the reference BSP for the Intel PXA25x processor boards has a problem. This problem is still biting people because there have recently been questions about it in the Platform Builder newsgroup. The cause is really quite simple. A shared resource with nothing to protect it from interrupts during read-modify-write operations. In this case, there are two sets of code that access the time match ......

Posted On Monday, May 12, 2008 6:26 PM | Comments (0)