this reason, the new run-time image runs on Device Emulator without further adaption. In practice, however, the underlying hardware is different in most cases, requiring BSP adaptations to start CE successfully.
> Customize the BSP
1. Detach from the target device and close Device Emulator.
2. In Visual Studio, open the init.c source code file that you can find in the %_PLATFORMROOT% DeviceEmulatorCloneSrcOalOallib folder, as illustrated in Figure 5-12.
3. Search for the OAL function OEMGetExtensionDRAM and add the following line of code to print a debug message in the Output window of Visual Studio during system startup.
BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen) {
...
OALMSG(OAL_FUNC, L'++OEMGetExtensionDRAM
'));
// Test message to confirm that our modifications are part of run-time image.
OALMSG(1,(TEXT('This modification is part of the run-time image.
')));
...
}
4. Rebuild the run-time image to includes the changes, and then attach to the device again in order to download and start the new run-time image in Device Emulator. Verify that Windows Embedded CE prints the debug message in the Output window.
Figure 5-12 DeviceEmulatorClone BSP customization
Chapter Review
The adaptation of a BSP is one of the most complicated and critical development tasks that OEMs face when porting Windows Embedded CE 6.0 to a new hardware platform. To facilitate this undertaking, Microsoft provides reference BSPs with Platform Builder and encourages OEMs to start the development process by cloning the most suitable BSP. The PQOAL-based BSPs follow a well-organized folder and file structure to separate platform-agnostic and platform-specific code by processor type and OAL function so that OEMs can focus on platform-specific implementation details without getting side tracked by general aspects of the kernel or operating system.
OEM developers should consider the following recommendations to ensure a successful adaptation of a BSP:
¦ Study the Windows Embedded CE reference BSPs Windows Embedded CE BSPs follow a well-defined architecture with close relationships to the kernel. This makes it necessary to implement numerous APIs that the kernel requires to run the operating system. Knowing these APIs and their purpose is very important. The PQOAL-based architecture is continually evolving.
¦ Clone a BSP Avoid writing a new BSP completely from scratch. Instead, clone a BSP to jump start the adaptation process. By reusing as much code as possible from a reference BSP, you not only shorten development time, but also increase the quality of your solution and provide a solid foundation for efficient handling of future upgrades.
¦ Boot loader and BLCOMMON Use BLCOMMON and related libraries when implementing a boot loader because these libraries provide useful hardware-independent features for downloading run-time images and enabling users to interact with the target device during the startup process.
¦ Memory and BSPs Make sure you thoroughly understand how Windows Embedded CE 6.0 deals with physical and virtual memory. Configure <
¦ Implement power management Implement the OEMIdle function to enable the system to switch the CPU into Idle mode. Consider implementing OEMPowerOff as well, if your platform supports power state transitions into Suspend mode in response to user actions or critical battery levels.
Key Terms
Do you know what these key terms mean? You can check your answers by looking up the terms in the glossary at the end of the book.
¦ PQOAL
¦ Boot loader
¦ KernelIoControl
¦ Driver globals
Suggested Practices
To help you successfully master the exam objectives presented in this chapter, complete the following tasks.
Access the Hardware Registers of a Peripheral Device
Implement a device driver for peripheral hardware and access the hardware registers by using the MmMapIoSpace API to interact with the device. Note that it is not possible to call MmMapIoSpace from an application.
Because Device Emulator emulates an ARM processor in software, you cannot access hardware devices. You must use a genuine hardware platform to perform this suggested practice.
Reorganize Platform Memory Mappings