Выбрать главу

■ Changes in the processor architecture.

■ Location of the boot loader code on the target device.

■ Memory architecture of the platform.

■ Tasks to perform during the boot process.

■ Supported transports for downloading the run-time image.

■ Additional features to be supported.

Memory Mappings

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.

MEMORY

; Name    Start    Size     Type

; ------- -------- -------- ----

; Reserve some RAM before Eboot.

; This memory will be used later.

  DRV_GLB A0008000 00001000 RESERVED ; Driver globals; 4 KB is sufficient.

  EBOOT   A0030000 00020000 RAMIMAGE ; Set aside 128 KB for loader; finalize later.

  RAM     A0050000 00010000 RAM ; Free RAM; finalize later.

CONFIG

 COMPRESSION=OFF

 PROFILE=OFF

 KERNELFIXUPS=ON

 ; These configuration options cause the .nb0 file to be created.

 ; An .nb0 file may be directly written to flash memory and then

 ; booted. Because the loader is linked to execute from RAM,

 ; the following configuration options

 ; must match the RAMIMAGE section.

 ROMSTART=A0030000

 ROMWIDTH=32

 ROMSIZE=20000

MODULES

; Name        Path                                          Memory Type

; ----------- --------------------------------------------- -----------

  nk.exe      $(_TARGETPLATROOT)\target\$(_TGTCPU)\$(WINCEDEBUG)\EBOOT.exe EBOOT

Driver Globals

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.

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>\Src\Inc folder, such as Drv_glob.h, with the following content:

#include <halether.h>

// Debug Ethernet parameters.

typedef struct _ETH_HARDWARE_SETTINGS {

 EDBG_ADAPTER Adapter; // The NIC to communicate with Platform Builder.

 UCHAR ucEdbgAdapterType; // Type of debug Ethernet adapter.

 UCHAR ucEdbgIRQ; // IRQ line to use for debug Ethernet adapter.

 DWORD dwEdbgBaseAddr; // Base I/O address for debug Ethernet adapter.

 DWORD dwEdbgDebugZone; // EDBG debug zones to be enabled.

 // Base for creating a device name.

 // This will be combined with the EDBG MAC address

 // to generate a unique device name to identify

 // the device to Platform Builder.

 char szPlatformStri ng[EDBG_MAX_DEV_NAMELEN];

 UCHAR ucCpuId; // Type of CPU.

} ETH_HARDWARE_SETTINGS, *PETH_HARDWARE_SETTINGS;

// BootArgs - Parameters passed from the boot loader to the OS.

#define BOOTARG_SIG 0x544F4F42 // "BOOT"

typedef struct BOOT_ARGS {

 DWORD dwSig;

 DWORD dwLen; // Total length of BootArgs struct.

 UCHAR ucLoaderFlags; // Flags set by boot loader.

 UCHAR ucEshellFlags; // Flags from Eshell.

 DWORD dwEdbgDebugZone; // Which debug messages are enabled?

 // The following addresses are only valid if LDRFL_JUMPIMG is set and

 // the corresponding bit in ucEshellFlags is set (configured by Eshell, bit

 // definitions in Ethdbg.h).

 EDBG_ADDR EshellHostAddr;   // IP/Ethernet addr and UDP port of host

                             // running Eshell.

 EDBG_ADDR DbgHostAddr;      // IP/Ethernet address and UDP port of host

                             // receiving debug messages.

 EDBG_ADDR CeshHostAddr;     // IP/Ethernet addr and UDP port of host

                             // running Ethernet text shell.

 EDBG_ADDR KdbgHostAddr;     // IP/Ethernet addr and UDP port of host

                             // running kernel debugger.

 ETH_HARDWARE_SETTINGS Edbg; // The debug Ethernet controller.

} BOOT_ARGS, *PBOOT_ARGS;

// Definitions for flags set by the boot loader.

#define LDRFL_USE_EDBG 0x0001 // Set to attempt to use debug Ethernet.

// The following two flags are only looked at if LDRFL_USE_EDBG is set.

#define LDRFL_ADDR_VALID 0x0002 // Set if EdbgAddr member is valid.

#define LDRFL_JUMPIMG    0x0004 // If set, do not communicate with Eshell

                                // to get configuration information,

                                // use ucEshellFlags member instead.

typedef struct _DRIVER_GLOBALS {

 //

 // TODO: Later, fill in this area with shared information between

 // drivers and the OS.

 //

 BOOT_ARGS bootargs;

} DRIVER_GLOBALS, *PDRIVER_GLOBALS;