Several aspects have to be considered when adapting a boot loader for a new platform, including:<\/p>
Memory Mappings<\/p> <\/div>
The first important adaptation task revolves around the definition of memory mappings for the boot loader. The standard BSPs included in Windows Embedded CE define the memory configuration in a .bib file, located in a boot loader subdirectory, such as %_WINCEROOT%\Platform\Arubaboard\Src\Boot loader\Eboot\Eboot.bib. The following listing shows an example of an Eboot.bib file, which you can customize to meet your specific requirements.<\/p>
MEMORY<\/code> <\/p>
; Name Start Size Type<\/code> <\/p>
; ------- -------- -------- ----<\/code> <\/p>
; Reserve some RAM before Eboot.<\/code> <\/p>
; This memory will be used later.<\/code> <\/p>
DRV_GLB A0008000 00001000 RESERVED ; Driver globals; 4 KB is sufficient.<\/code> <\/p>
EBOOT A0030000 00020000 RAMIMAGE ; Set aside 128 KB for loader; finalize later.<\/code> <\/p>
RAM A0050000 00010000 RAM ; Free RAM; finalize later.<\/code> <\/p>
CONFIG<\/code> <\/p>
COMPRESSION=OFF<\/code> <\/p>
PROFILE=OFF<\/code> <\/p>
KERNELFIXUPS=ON<\/code> <\/p>
; These configuration options cause the .nb0 file to be created.<\/code> <\/p>
; An .nb0 file may be directly written to flash memory and then<\/code> <\/p>
; booted. Because the loader is linked to execute from RAM,<\/code> <\/p>
; the following configuration options<\/code> <\/p>
; must match the RAMIMAGE section.<\/code> <\/p>
ROMSTART=A0030000<\/code> <\/p>
ROMWIDTH=32<\/code> <\/p>
ROMSIZE=20000<\/code> <\/p>
MODULES<\/code> <\/p>
; Name Path Memory Type<\/code> <\/p>
; ----------- --------------------------------------------- -----------<\/code> <\/p>
nk.exe $(_TARGETPLATROOT)\target\$(_TGTCPU)\$(WINCEDEBUG)\EBOOT.exe EBOOT<\/code> <\/p>
Driver Globals<\/p> <\/div>
Among other things you can use the Eboot.bib file to reserve a memory section for the boot loader to pass information to the operating system during the startup process. This information might reflect the current state of initialized hardware, network communication capabilities if the boot loader supports Ethernet downloads, user and system flags for the operating system, such as to enable Kernel Independent Transport Layer (KITL), and so on. To enable this communication, the boot loader and operating system must share a common region of physical memory, which is referred to as driver globals (DRV_GLB). The above Eboot.bib listing includes a DRV_GLB mapping. The data that the boot loader passes to the operating system in the DRV_GLB region must adhere to a BOOT_ARGS structure that you can define according to your specific requirements.<\/p>
The following procedure illustrates how to pass Ethernet and IP configuration information from the boot loader to the operating system through a DRV_GLB region. To do this, create a header file in the %_WINCEROOT%\Platform\< BSP Name<\/em> >\Src\Inc folder, such as Drv_glob.h, with the following content:<\/p>
#include <\/code> <\/p>
// Debug Ethernet parameters.<\/code> <\/p>
typedef struct _ETH_HARDWARE_SETTINGS {<\/code> <\/p>
EDBG_ADAPTER Adapter; // The NIC to communicate with Platform Builder.<\/code> <\/p>
UCHAR ucEdbgAdapterType; // Type of debug Ethernet adapter.<\/code> <\/p>
UCHAR ucEdbgIRQ; // IRQ line to use for debug Ethernet adapter.<\/code> <\/p>
DWORD dwEdbgBaseAddr; // Base I/O address for debug Ethernet adapter.<\/code> <\/p>
DWORD dwEdbgDebugZone; // EDBG debug zones to be enabled.<\/code> <\/p>
// Base for creating a device name.<\/code> <\/p>
// This will be combined with the EDBG MAC address<\/code> <\/p>
// to generate a unique device name to identify<\/code> <\/p>
// the device to Platform Builder.<\/code> <\/p>
char szPlatformStri ng[EDBG_MAX_DEV_NAMELEN];<\/code> <\/p>
UCHAR ucCpuId; // Type of CPU.<\/code> <\/p>
} ETH_HARDWARE_SETTINGS, *PETH_HARDWARE_SETTINGS;<\/code> <\/p>
// BootArgs - Parameters passed from the boot loader to the OS.<\/code> <\/p>
#define BOOTARG_SIG 0x544F4F42 // "BOOT"<\/code> <\/p>
typedef struct BOOT_ARGS {<\/code> <\/p>
DWORD dwSig;<\/code> <\/p>
DWORD dwLen; // Total length of BootArgs struct.<\/code> <\/p>
UCHAR ucLoaderFlags; // Flags set by boot loader.<\/code> <\/p>
UCHAR ucEshellFlags; // Flags from Eshell.<\/code> <\/p>