System Initialization of OEM Adaptation Layers in Wince

xiaoxiao2021-03-06  38

OF: Fu Linlin Source: NEW YORK OAL (OEM Adaptation Layer) both OEM adaptation layer between the Windows CE kernel and hardware, the logically Physically OAL code is compiled modules (.LIB) and Other kernel library links are connected together to form a core executable file NK.exe for Windows CE. The Windows CE core exposes a large number of functions and global variables in the OAL layer, using these functions and global variable OEMs to write interrupt processing, RTC, power management, debug port, general purpose I / O control code, etc. Figure 1 is more intuitively describing the structure of the OAL. The subdirectory of the CE installation directory contains partial source code of the OAL. In most cases, the developer can modify the OAL, and even do not need to be modified. By reading this article, developers can understand the structure of OAL, exposed interface features, can achieve even enhanced OAL features on this basis.

Figure 1 OAL structure diagram

Because the OAL layer code is related to the system initialization work when the CE starts, this article is clues in the start of CE. Other OAL knowledge is explained in the next article. First, start jump to startup () after the Boot Loader decompresses the CE kernel image file (nk.bin), and the Startup function belongs to the OAL layer. At this time, the CE operating system has not run. There are two main features of the Startup function. First, the initialization CPU is known (KNOWN State), and the other is to call the kernel initialization function (the X86 platform is kernelInitialize, other platforms are kernelstart). Initializing the CPU work is different from the CPU, if it is an ARM series, including setting the CPU for administrator mode, disabling the MMU, Clear instructions, and data buffers, detects the starting cause, configures the GPIO and memory controller, initialize RTC Save the OemaddResSTable address, etc. Call KernetStart after execution. If it is an X86 series, including setting the CPU to protect the mode, initialize the memory controller, save the OemaddResStable address. Call KerNetInitialize after execution. Second, the function of the kernel initialization function is also different due to the difference in CPU, but there are some functions, such as initializing the serial port (for output debugging information), call the Oeminit function, etc. For the X86 series, the initialization work also includes reading OEMADDRESSTABLE content in addition to the above functions, determining paging size, core weight, initialization interrupt, initialization page table, memory initialization, and other initialization. For other series of CPUs, please refer to the CE help documentation. 1. Serial debug: The serial debug function includes OeminitDebugserial, OemWriteBugbyte, etc. From the source code from OEMINITDEBUGSERIAL, it can be seen that the system determines from boot_arg_ptr_location to the structure of the first address, which is the serial port of the current connection, and then configure this serial port. If your device's serial port I / O address settings and CE default, you can get the CPU control to get the debug information through the serial port during the CE kernel. 2. Oeminit Generally initializes all peripheral hardware, initializing system Ticks, and RTC (Real Time Clock) in Oeminit, initializing Kitl (KERNEL INDEpendent Transport Layer). For example, the Oeminit function of the I486 platform, which first associates all IRQ and interrupt IDs, then initialize the PCI bus, network adapter, power management, PIC (programmable interrupt controller), system clock, and finally detects whether to extend memory. In addition, if OEM enhances the functionality of the function pointer or global variable to the global variable, it is to be implemented in this function (explained in detail below). 3. Detecting extended memory We all know that set the total amount of RAM in the CE system in the config.bib configuration file (if you don't know, please refer to my article Platform Builder Tour Series), pay attention to this RAM is not the size of the total physical memory. . The PB-compiled kernel contains a variable ulramend that will give Ulramend in the start address RAM size defined in config.bib. During the startup of the CE kernel, Ulramend's value assigns to the global variable MainMemoryEndaddress, the CE kernel gets the total amount of RAM from accessing MainMemoryEndadDress.

If the RAM is attached to the CE-based device, the value of MainMemoryEndadDress does not include this additional RAM, and the result CE kernel cannot know that RAM has been added. In order to let the CE kernel understand the information of additional RAM, OEM should write a function to detect the total amount of RAM and assume the total value to MainMemoryEndaddress. OAL exposes a function pointer PNkenumextensionDram, OEM should assign the written function address to this function pointer. If OEM does not prepare yourself writing a memory detection function, you can call OEMGETEXTENSIONDRAM. From the help document, it is seen that the OEMGETEXTENSIONDRAM can detect the total amount of memory, but CE is not specifically written in the source code for the X86 platform (see% _winceroot% / public / common / oak / csp / i486 / oal / cfwpc.c). That is, call OEMGETEXTENSIONDRAM on the X86 platform is not detected. If the OEM is interested in writing a function of detecting the total amount of RAM, you can call the ready-made functions ISDRAM. This function is also saved in cfwpc.c. Third, the kernel initialization function is executed, start executing as follows: 1. The kernel creates the event object system / fsready synchronized with FILESYS.EXE, and then launches FileSys.exe. The meaning of starting filesys.exe is to let FileSys.exe read the registry data. 2. The kernel is waiting for the event system / fsready to be triggered. This event is triggered by FileSys.exe after doing a series of work. This series of work is as follows: 2. First test This is a cold start or hot start, if it is cold start, then initialized object storage memory area. 2.2 Call the OEMIOCONTROL function, I / O control code is ioctl_hal_init_rtc, which is to initialize the RTC. 2.3 Initializing the Database Subsystem and API, File System API, Message Queue API. 2.4 If the operating system mirror (NK.bin) includes a RAM file system, then create a RAM file system after reading the content of the initobj.dat file. 2.5 Initialize the registry (form a registry in memory). 2.6 If Device.exe is not started, read the value of "DLL" under HKEY_LOCAL_MACHINE / System / StorageManager (this value is the file name of the .dll where the Storage Manager is located) and load it into memory. After loading, create a thread dedicated to initialize the storage manager, and the thread ends after initialization. 2.7 Initialize NLS (National Language Support). For NLS, please refer to my article "CE Chinese Input Method Editor". 2.8 Set local ID for the database engine. 2.9 Read the initdb.ini file, install the database in the object store. 2.10 Trigger the System / FSReady event, then FileSys.exe is in the waiting state, waiting for the internal verification notification to it. 3. At this point, the registry already exists in memory, the kernel begins to read the following position data:

转载请注明原文地址:https://www.9cbs.com/read-62533.html

New Post(0)