Partager via


Sharing Code Between the Boot Loader and the OAL (Windows Embedded CE 6.0)

1/5/2010

Sharing code can minimize duplication of some routines used by both the boot loader and the OAL.

To share code between the boot loader and the OAL

  1. In %_WINCEROOT%\Platform\MyPlatform\Src\Kernel\OAL, create one source file called Debug.c, which contains the code.

  2. To share the code with the boot loader, create another file called Boot_debug.c in %_WINCEROOT%\Platform\MyPlatform\Src\BootLoader\Eboot.

    The Boot_debug.c file should contain only the following code:

    #include "\\..\\kernel\\oal\\debug.c"
    

    Using #ifdef BOOTLOADER in the source code, you can conditionally compile the code to use physical memory addresses in the boot loader, or virtual memory addresses in the OAL.

    For example, assuming your peripherals are physically located at 0x40000000 and mapped to 0xB0000000 in OEMAddressTable, you would need to add 0x70000000 to the register addresses when running with virtual memory enabled.

    **The following code example shows how to do this.

    void OEMInitDebugSerial(void) 
    {
       #ifdef BOOTLOADER    
           UINT32 va_periph_offset = 0x00000000;  // Boot loader uses physical addresses.
       #else    
           UINT32 va_periph_offset = 0x70000000;  // Kernel startup uses virtual addresses.
       #endif
    
           volatile UART1reg   *s2410UART1   = (UART1reg *) va_periph_offset + UART1_BASE;
           volatile IOPreg     *s2410IOP     = (IOPreg *)   va_periph_offset + IOP_BASE;
    
    ...
    }
    

See Also

Tasks

How to Develop an OEM Adaptation Layer