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;

StartUp Entry Point and Main Function

The StartUp entry point of the boot loader must be located in linear memory at the address where the CPU begins fetching code for execution because this routine carries out the initialization of the hardware. If the adaptation is based on a reference BSP for the same processor chipset, then most of the CPU-related and memory controller-related code can remain unchanged. On the other hand, if the CPU architecture is different, you must adapt the startup routine to perform the following tasks:

1. Put the CPU in the right mode.

2. Disable all interrupts.

3. Initialize the memory controller.

4. Setup caches, Translation Lookaside Buffers (TLBs), and Memory Management Unit (MMU).

5. Copy the boot loader from flash memory into RAM for faster execution.

6. Jump to the C code in the main function.

The StartUp routine eventually calls the main function of the boot loader, and if the boot loader is based on BLCOMMON, then this function in turn calls BootLoaderMain, which initializes the download transport by calling OEM platform functions. The advantage of using the standard libraries provided by Microsoft is that the modifications required to adapt a BSP to a new hardware platform are componentized, isolated, and minimized.

Serial Debug Output

The next step in the boot loader adaptation is the initialization of the serial debug output. This is an important part of the boot process because it enables the user to interact with the boot loader and the developer to analyze debug messages, as discussed in Chapter 4, 'Debugging and Testing the System.'

Table 5-2 lists the OEM platform functions required to support serial debug output in the boot loader.

Table 5-2 Serial debug output functions

Function Description
OEMDebugInit Initializes the UART on the platform.
OEMWriteDebugString Writes a string to the debug UART.
OEMWriteDebugByte Writes a byte to the debug UART, used by OEMWriteDebugString.
OEMReadDebugByte Reads a byte from the debug UART.

Platform Initialization

Once the CPU and the debug serial output are initialized, you can turn your attention to the remaining hardware initialization tasks. The OEMPlatformInit routine performs these remaining tasks, including:

¦ Initializing the real-time clock.

¦ Setting up external memory, particularly flash memory.

¦ Initializing the network controller.

Downloading via Ethernet

If the hardware platform includes a network controller, then the boot loader can download the run-time image over Ethernet. Table 5-3 lists the functions that you must implement to support Ethernet-based communication.

Table 5-3 Ethernet support functions

Function Description
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату