Nk.exe Boot Process (Windows CE 5.0)

Send Feedback

During the kernel boot process, the following calls are made in the order shown:

StartUp()

**     KernelStart() / KernelInitialize()**

          <Main kernel initialization function>

**               OEMInitDebugSerial()**

**               OEMInit()**

**          KernelInit()**

**               HeapInit()**

**               InitMemoryPool()**

**               ProcInit()**

**               SchedInit()**

**     FirstSchedule()**

**          SystemStartupFunc()**

          IOCTL_HAL_POSTINIT

For more information about kernel initialization and specific kernel initialization considerations, see Kernel Initialization.

StartUp()

StartUp is the first function called during kernel startup and it is responsible for initializing the CPU to a known state.

The StartUp function performs the following tasks:

  • Performs minimal processor and hardware initialization
  • Disables interrupts, caches, and the memory management unit (MMU)

Once the StartUp function has initialized the CPU, it calls the KernelStart or KernelInitialize function.

The StartUp function, found under %_WINCEROOT%\Platform\<Hardware Platform Name>\Src\Kernel\OAL\Startup.s, is usually written in assembly language and is shared with the boot loader.

KernelStart() / KernelInitialize()

The OEM adaptation layer (OAL) sets up any platform or CPU-specific settings that is required for the kernel to access ROM and RAM. To start the system, it then jumps to KernelInitialize, for x86-based hardware platforms, or KernelStart, for all other hardware platforms. At this point, the MMU and caches should not be enabled.

The KernelStart or KernelInitialize function performs the following tasks:

  • Initializes the first-level page table based on the contents of OEMAddressTable

  • Enables the MMU and caches

    Until the MMU is enabled, the kernel symbolic addresses are invalid and must be translated through the OEMAddressTable to obtain the correct physical addresses.

  • Initializes the stacks for each mode of operation

The implementation of the KernelStart and KernelInitialize function is under the private directory.

Once KernelStart or KernelInitialize has performed all its tasks, it calls the main initialization function for the kernel that you are using.

Main kernel initialization function

The main kernel initialization function is responsible for calling the OEM supplied initialization functions. It also performs the following tasks:

  • Initializes the debug serial port through a call to OEMInitDebugSerial
  • Displays the Windows CE sign-on message through the debug port
  • Initializes the hardware platform through a call to OEMInit

If you have an ARM kernel for example, KernelStart calls ARMInit as the main kernel initialization function.

OEMInitDebugSerial()

OEMInitDebugSerial initializes the debug serial port on the target device.

The debug functions typically communicate with a serial device. Because the boot loader implements the same code, a single implementation can be shared between the OAL and the boot loader.

These are serial debug functions that OEMs need to implement:

The NK banner is displayed after the OEMInitDebugSerial function completes.

OEMInit()

OEMInit is implemented by OEMs to initialize all hardware interfaces for the target device.

At this point in the kernel boot process, interrupts are disabled and the kernel is unable to handle exceptions. The only kernel service available to OEMInit is HookInterrupt. OEMInit can register interrupt service routines (ISRs) by calling HookInterrupt.

At this point in the boot process, the following hardware initialization is usually required:

  • Interrupts
  • System timer
  • KITL interface

Depending on the hardware, optional initialization would include:

  • Bus interfaces

Sample implementations of the OEMInit function can be found in %_WINCEROOT%\Platform\<Hardware Platform Name>\Src\Kernel\OAL\Init.c.

KernelInit()

The KernelInit function encapsulates the initialization of the kernel. It initializes the following parts of the kernel through calls to different initialization functions:

  • Heap
  • Memory pool
  • Kernel process
  • Scheduler

Upon exiting this function, the system is ready to schedule the first thread through SystemStartupFunc.

The implementation of the KernelInit function is under the private directory.

HeapInit()

HeapInit initializes the kernel heap.

The implementation of the HeapInit function is under the private directory.

InitMemoryPool()

InitMemoryPool initializes the kernel memory pool.

The implementation of the InitMemoryPool function is under the private directory.

ProcInit()

ProcInit initializes the Windows CE kernel process.

The implementation of the ProcInit function is under the private directory.

SchedInit()

SchedInit initializes the scheduler and creates the SystemStartupFunc thread.

The implementation of the SchedInit function is under the private directory.

FirstSchedule()

FirstSchedule starts the scheduler.

The implementation of the FirstSchedule function is under the private directory.

SystemStartupFunc()

SystemStartupFunc executes IOCTL_HAL_POSTINIT. Implementation of this function can be handled by OEM code to complete the kernel initialization process.

The implementation of the SystemStartupFunc function is under the private directory.

See Also

Filesys.exe Boot Process | Kernel Overview

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.