Startup (OAL) (Compact 7)
3/12/2014
Some of the startup tasks performed by the OAL include initializing the CPU, jumping to the entry point of kernel.dll, and then initializing other components of the system at the kernel’s request. For details about the tasks that the OAL performs, see OEM Adaptation Layer.
The OAL startup code is located in Platform\<BSP Name>\Src\OAL\Oallib. It is linked into oal.lib.
The following table lists the main OAL startup functions; you will need to customize them to your hardware platform. In addition to these functions, initialization functions such as OALCacheGlobalsInit, OALTimerInit, OALIntrInit, and OEMKitlStartup are listed in the tables in the following sections: Cache (OAL), Timer (OAL), Interrupts (OAL) and KITL Code Overview.
Purpose | Function name | Typical file name |
---|---|---|
Puts the CPU in a known state |
StartUp |
startup.s |
Initializes hardware interfaces |
init.c |
The following figure shows an example of the system startup sequence beginning where the boot loader left off. The OAL starts the kernel, and then the kernel calls OAL functions to initialize various components.
Below is a description of the OAL and kernel startup sequence shown in the figure.
- At the end of the boot process, the boot loader jumps to the OAL’s StartUp function, which is the entry point of the run-time image. (For details on what led up to this point, see Startup (Boot Loader).) The StartUp function flushes the cache and calls KernelStart, which is a CPU architecture-specific function implemented by the kernel.
- The KernelStart function performs minimal initialization, turns on the memory management unit (MMU), initializes the kernel global variables, and then jumps to the entry point of kernel.dll. The entry point of kernel.dll is a CPU architecture-specific kernel function that performs the rest of the initialization. The KernelStart function never returns.
- In the kernel initialization function, the kernel exchanges global pointers with the OAL. From this point on, the kernel has access to all functions and variables that are defined by the OAL in the OEMGLOBAL structure, and the OAL has access to all functions and variables that are defined by the kernel in the NKGLOBAL structure. The kernel initialization function also performs additional CPU setup, such as setting up interrupt vectors and enabling the cache.
- The kernel initialization function then calls the OEMInitDebugSerial function to initialize the debug serial port on the device. The serial port initialization process is similar to the one performed by the boot loader.
- The kernel initialization function then calls the OEMInit function, at which time optional functions in the OEMGLOBAL structure are initialized or overridden if applicable. The OEMInit function also performs any other hardware-specific initialization, such as initializing additional global variables, initializing a watchdog timer, and initializing coprocessors. To do this initializing, the OEMInit function calls several board support package (BSP) functions, such as those described below.
- The OEMInit function calls the OALCacheGlobalsInit function to initialize the global variables that hold the cache parameters.
- The OEMInit function initializes the interrupt hardware by calling the OALIntrInit function, which in turn calls the OALIntrMapInit function to initialize the mappings between interrupt requests (IRQs) and SYSINTR logical interrupts.
- The OEMInit function calls the OALTimerInit function, which initializes the timer state structure.
- The OEMInit function calls the OALPCIInit function, which initializes the PCI bus, if there is one.
- The OEMInit function calls the kernel’s KITLIoctl function with the IOCTL_KITL_STARTUP IOCTL. The KITLIoctl function then calls the OEMKitlStartup function. For the continuation of the KITL startup procedure, see KITL Code Overview.
- After the OEMInit function returns, the kernel initialization function calls the KernelInit function, which completes the kernel initialization by setting up the heap, initializing threads, and so on. The KernelInit function then schedules the first thread, and the OS startup sequence is complete.