Document directory
- 1. Inconsistent Processor Architecture
- 2. hardware resources are usually limited
- 3. A wide variety of external devices
- 4. Real-time and reliability requirements
- Bootstrap program:
- Configuration file:
- Device Driver:
- BSP:
- System Call and coredii. dll:
- A. Process
- B. threads
The hierarchical architecture of WinCE
Application Layer
Operating system layer
OEM Layer
Hardware Layer
Application Layer:
Including Internet client services, third-party applications, WinCE applications, and user interfaces
Operating system layer:
Including applications and services, coredll, Object Storage, media technology, GWES, Device Manager, network, and Kernel
OEM layer:
Includes the OEM abstraction layer, driver, bootloader, and configuration file.
For example:
Next, we will introduce more layers: 1) hardware layer: embedded hardware usually has the following features: 1. the processor architecture is not uniform. The processor ranges from 8 to 128 bits, the processing capability varies from several kHz to several MHz or even several GHz, and the instruction set and structure are more important. Most of our mobile phones are ARM-based, and many network devices use power PCs. MIPS, sh, and other CPUs also have a place in the embedded field. 2. hardware resources are usually restricted in embedded systems. Not only are the CPU computing capacity limited, but the Memory RAM is also very small. Many do not have output devices, simple LEDs, and some use dry batteries. It is worth noting that, because embedded hardware is "adequate", not all embedded device resources are scarce. Some entertainment devices (Sony's PS3) Use 128-bit CPUs to enhance their graphics processing capabilities, and some aerospace devices far surpass PCs. 3. A wide range of external devices, except for mouse and keyboard printers, cannot meet embedded requirements. Some embedded systems require sensors to obtain parameters. 4. Real-time and reliability requirements in some embedded systems have high requirements on real-time and reliability, otherwise it will cause a major catastrophic loss. 2) OEM layer: the OEM layer is a layer of hardware-related code logically located between the hardware and the operating system. His main role is to abstract specific hardware and abstract unified interfaces. Then, the wince kernel can use these interfaces to communicate with the hardware. The OEM layer consists of the OEM abstraction layer, boot program, configuration file, and driver modules. The OEM abstraction layer (oal) is the main body of the entire OEM layer. It contains highly hardware-related code. OAL is mainly responsible for the communication between the wince kernel and hardware. After the boot program directs the operating system to an end, oal initializes the hardware platform, including interrupt service routines, real-time clock, timer, and internal debugging. The oal code is physically a part of the kernel and will eventually become part of the kernel after compilation and connection. Bootstrap program: bootloader is a piece of code executed on the hardware development board. Its main function is to initialize the hardware, load the operating system image to the memory, and then jump to the Operating System code for execution. Bootloader can obtain operating system images through serial port, USB, and Ethernet. For example, common Ethernet (eboot ). Configuration Files: These configuration files are generally related to the operating system image and source code. For example, how to compile and configure the final Operating System image. Device Drivers: There are many types of device drivers, such as battery, video card, sound card, and USB drivers. BSP: A concept corresponding to the OEM layer is BSP. BSP is a layer between the main board hardware and the operating system. It can also be said to be a part of the operating system. In fact, we only talk about the OEM layer when talking about the architecture. OEM and BSP are equivalent. Different operating systems have different definitions of BSP. I hardly talked about BSP on a PC, because the PC uses a unified x86 system architecture, so the BSP of a certain operating system is single and definite, so it makes no sense. Some people compare BSP with the BIOS on the PC motherboard, which is actually very different. BIOS is mainly responsible for self-check when the computer is turned on, drawing system devices and loading Operating System Code. It is fixed and cannot be changed. BSP is bound with the operating system, and some BIOS work is similar at the beginning, but most of them are different. BSP can be used to add drivers unrelated to the system, or even to the upper-layer development, but not to the BIOS. 3) at the operating system layer, the operating system layer implements the main functions of Wince as an operating system. At this layer, WinCE implements process management, thread management, scheduling, physical memory, virtual memory, file system, and device management. The basic functions of the operating system are implemented in several independent processes (exe), which are roughly as follows: dependencies 1 and 3 are essential. System Call and coredii. dll: coredll. dll are not a separate process. It is a dynamic link library loaded by all user processes. All applications cannot directly deal with the operating system or hardware. If the application wants to access the services provided by wince, it can only use coredll. dll. The following describes the detailed process of system calling. A. When the system is called, it directly calls a packaging function in coredll. dll, which is required for the real system call. Coredll. dll is loaded by all the processes of wince. Therefore, this step is actually just a function call within the process. B. coredll. dll will initiate an exception, also known as software interruption. In short, exceptions return new applications with high execution permissions to the operating system. C. The operating system kernel captures all exceptions. When the operating system obtains this exception, it obtains the CPU again. On wince, nk.exewill process this software, and the application process for this kind of system calling will start and be transferred to nk.exe. D.next, access the different system calls of nk.exegion. Find the specific progress of the system, which may be nk.exe or not, if not. E. The process implementing the system call will get the execution opportunity and then return. F. when the execution of the System Call process ends, the whole system call ends. The application can return the result from the call to coredll. dll and continue the execution. It is worth mentioning that some functions of coredll. dll are not packaged functions called by the system, such as string processing. If not, self-traps and process execution jumps are not required. For example, execute in the worker graphical interface thread and return after execution. Figure: 110000nk.exe provides core functions such as Process Creation and loading, thread scheduling, interrupt processing, and memory management. 2、gwes.exe is responsible for the graphic interface, which manages user input (keyboard, mouse, touch screen) and reality. 32.16filesys.exe is responsible for the object storage process, including the file system, database system, and system registry. 4、device.exe uninstall and manage all drivers not managed by gwes.exe. At the same time, it also provides the system with implementation of all related driver APIs. 52.16service.exe system service process. For example, FTP and HTTP. 4) A common misunderstanding of the application layer is that the application has low gold content and the underlying layer has a technical level. In fact, the value of a system is measured, A very important criterion is to see how the application runs on it. Without application support, powerful and well-designed operating systems can only be toys. A. A process is a dynamic execution instance of the program. There are many differences between a process and a program: 1. A process is a dynamic concept, while a program is a static concept. 2. A process has been created, executed, and completed throughout its lifecycle, the program is just a file. 3. A program can correspond to multiple processes, and a process can only correspond to one program. For example, when multiple Internet browser pages are opened, the memory will have multiple access paths, but each access path corresponds to only iee.exe in wince. The process itself does not participate in System Scheduling and has no priority or context. When the process actually participates in system scheduling, the thread is only the container of the thread, each process has a main thread. Because wince only supports 32 processes running at the same time, each process has 32 MB virtual address space, also known as a slot. When the system starts, filesys.exe gwex.exe device.exe occupies multiple slots and less than 30 slots can be used. Therefore, multiple threads are not required.
In addition, WinCE does not support environment variables and the current directory. The following code is incorrect. _ Wfopen (L "% WINDOWS \ myfie.txt", l "W"); _ wfopen (L "myfie.txt", l "W "); one solution is to use the getmodule () function to obtain the directory where the current execution file is located, and then splice the file to be opened to the path to obtain the complete path. The reference code is as follows:
Dworddwlen;
Tcharszpath [max_path];
Dwlen=Getmodulefilename (null, szpath, max_path); // get the current Module Directory
If(!Dwlen)
{
Return0;
}
While(Szpath [-- dwlen]! = _ T ('\\'))
{
Szpath [dwlen] = _ T ('\ 0 ');
}
Wcscat (szpath, _ T ("myfie.txt "));//
B. threads
(Leave it to the next lecture on the operating system .)