Creating Driver Globals and Boot Args (Windows Embedded CE 6.0)


Driver globals is a memory buffer shared by device drivers and the operating system (OS).

Boot args is a memory buffer shared between the boot loader and the OS. The boot args are updated throughout the boot process to carry information such as the network device used for download — including the base address, interrupt, IP address, subnet mask, and MAC address — and other system or user settings.

The driver globals area typically contains the boot args area. This keeps all the global shared data within one page of RAM. The boot args area can contain whatever you find useful. The format and contents are largely up to you. Be sure to store information about the NIC in the boot args area so that the OS can locate it later.

  1. In %_WINCEROOT%\Platform\MyPlatform\Src\Inc, create a header file called Platform_boot.h.

  2. Add the following code sample to the Platform_boot.h file.

    #include <halether.h>
    // Debug ethernet parameters.
    typedef struct _ETH_HARDWARE_SETTINGS
        EDBG_ADAPTER    Adapter;            // The NIC used 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 szPlatformString[EDBG_MAX_DEV_NAMELEN];    
        UCHAR           ucCpuId;            // Type of CPU.
    // Boot args - 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 boot args 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.
    // 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.
  3. In %_WINCEROOT%\Platform\MyPlatform\Src\Inc, create a header file called Drv_glob.h to define the driver globals region.

  4. Add the following code sample to the Drv_glob.h file.

    #include "platform_boot.h"
    typedef struct _DRIVER_GLOBALS
        // TODO: Later, fill in this area with shared information between 
        // drivers and the OS.
        BOOT_ARGS        bootargs;
  5. Modify the .bib file to reserve memory for the driver globals region.

    You must reserve the driver globals region in the .bib file after you have defined this region. Typically, the driver globals, including boot args, is placed in RAM below the boot loader.

    The following code example shows how to perform this procedure.

    ;   Name     Start     Size      Type
    ;   -------  --------  --------  ----
        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.
        ; These cause the .nb0 file to be created. An .nb0 file may be 
        ; directly written to flash and then booted.
        ; Because the loader is linked to execute from RAM,
        ; these must match the RAMIMAGE section.
    ;   Name            Path                                            Memory Type
    ;   --------------  ----------------------------------------------  -----------
        nk.exe          $(_TARGETPLATROOT)\target\$(_TGTCPU)\$(WINCEDEBUG)\EBOOT.exe   EBOOT

    In the previous code example, the DRV_GLB line was added to reserve the driver globals region in the .bib file.

Community Additions