Implementing the OEMInit Function
The OEMInit function is responsible for initializing the board-level hardware. During OEMInit, you must initialize all hardware peripherals needed to support the platform, initiate the debug KITL transport, and set any kernel variables that are required by the kernel to enable or alter functionality. For more information about KITL initialization, see Adding KITL Initialization Code.
The OEMInit function contains much of the functionality present in the OEMPlatformInit function in the boot loader. For more information, see Implementing the OEMPlatformInit Function.
The following list shows the suggested initialization tasks for the OEMInit function:
Initialize interrupt mapping tables. These are two private OAL tables that map between physical interrupts — interrupt requests (IRQs) — and logical interrupts — SYSINTR values. The following code example shows how to initialize the interrupt mapping tables:
for (i = 0; i <= IRQ_MAXIMUM; i++) { IRQToSysIntr[i] = SYSINTR_UNDEFINED; } for (i = 0; i < SYSINTR_MAXIMUM; i++) { SysIntrToIRQ[i] = IRQ_UNDEFINED; }
Create any initial static mappings required by the OAL. For example, SYSINTR_OS_TICK might map to hardware IRQ_OS_TICK, as shown in the following code example:
SysIntrToIRQ[SYSINTR_OS_TICK] = IRQ_OS_TICK; IRQToSysIntr[IRQ_OS_TICK] = SYSINTR_OS_TICK;
For more information about Windows CE interrupts, see Interrupts and Defining an Interrupt Identifier.
Configure the system timer, real-time clock (RTC), or any other timekeeping device by implementing the InitClock function and calling it from OEMInit. For more information, see System Tick Timer Initialization.
Configure any CPU-level and board-level interrupt controllers.
Provide LED debug support. While optional, it is helpful when debugging the kernel.
If necessary for your CPU type, call the HookInterrupt function to register one or more interrupt service routines (ISRs). The HookInterrupt function associates an ISR with an interrupt request line (IRQ) value. OEMInit must register the ISR for the system tick. This is the base functionality required by the kernel to schedule threads. For more information, see System Tick Timer Implementation.
Note HookInterrupt is not required or possible for ARM-based platforms. There are only two interrupts and they are handled by OEMInterruptHandler and OEMInterruptHandlerFIQ.
The following code example shows how you can register the interval-timer ISR,
TimerISR
, for hardware interrupt 5.void OEMInit(void) { ... HookInterrupt(5, TimerISR); // Hook timer interrupt ... }
Mask all unconfigured interrupt sources at the CPU-level and board-level. This prevents interrupts from accidentally being delivered during the kernel initialization.
Leave the 1-millisecond (ms) system tick unmasked, so that timekeeping and thread scheduling function properly.
The following list shows optional features that you can implement in the OEMInit function:
- Logging functions
- Registry functions
- Secure loader functions
- Save and restore coprocessor registers
- High performance counters
- System halt
- Event tracking
- Detection of idle time
- User notification alarm
- Multiple execute-in-place (XIP) regions
- Default thread quantum
- Enable debug IO control
- Erasing the object store
- Supporting CPU utilization functionality
- Object store cold boot
- ARM FPU support
- Zeroing memory
See Also
How to Develop an OEM Adaptation Layer
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.