http://blog.csdn.net/mr_raptor/article/details/7338051
This experimental source code contains three parts:
miniOS source code: in the miniOS_xxxx (development board name) project directory.
miniOS application marquee: in the miniOS_app_led project directory.
miniOS application printing program: in the miniOS_app_print project directory.
# miniOS source code: http://download.csdn.net/detail/mr_raptor/4179593
# Download the program: http://download.csdn.net/detail/mr_raptor/4382941
Steps:
(1) Compile the miniOS_xxxx project in ADS, select Norflash to start, and then burn minios_org.bin to address 0 in Norflash through H-Jtag.
(2) Compile the applications miniOS_app_led and miniOS_app_print, select Norflash to start, and burn miniOS_app_print.bin to address 0x10000 and miniOS_app_led.bin to address 0x20000 through H-Jtag.
(3) Start the development board, and you can see the miniiOS startup information. miniOS supports up to 62 processes at the same time (on the 2440 development board with 64M memory). After miniiOS is started, by default only the system kernel process is running. You can press the K1 key to create a new process, up to 62 processes can be created. Press the K2 key to kill a random process. Press the K6 key to start the marquee process.
(4) If you want to write a program and have miniiOS start it, you should write the program according to the writing rules. If system calls are required, you should also implement the system call interface yourself.
Analysis of the miniiOS code is divided into the following chapters:
1. miniOS memory distribution
2. Important header file description
3. Start code analysis
4. MMU and memory protection implementation
5. Kernel timer and interrupt processing
6. CPU mode switching
7. Process Scheduling and Context Switching Technology
8. Software interrupts and system calls
9. System debugging, optimization and areas for improvement
Let’s look at Section 1:
Memory distribution diagram of miniOS V2.0:
The kernel address space in the Linux kernel is divided into:
- Direct Memory Region: Low-end physical memory
- Dynamic memory mapping area (VMalloc Region) is: high-end physical memory
- Other mapping areas
In miniOS, the virtual address space is divided into two parts:
- User program space: 0x0 ~ 0x80000000
- Kernel management space: 0x80000000 ~ 0xC0000000
>> Each process in the user program space uses 32M of virtual address space, and the relationship between its space address and its PID is as follows:
PID * 32M = PID's process space
Among them, the 0~32M space is the process space No. 0, which is actually the address space currently running.
The reason for this design is that after the ARM CPU turns on the MMU, the address below 32M is used as the in-process space. When the address is higher than 32M, the MMU will convert it. For details, please refer to: MMU and Memory Management Chapter.
Each process space is 32M. When switching processes in the future, you only need to perform linear shifts according to the relationship defined above, which reduces the complexity of process switching.
The actual physical memory space of each process is 1M, that is, each process has only 1M of physical address space. When the user program exceeds 1M, the program cannot run (of course, there is no program that exceeds 1M). Their mapping relationship is as follows:
0x30000000 ~ 0x34000000 ----> 0x0 ~ 0x80000000
>>The kernel management address space can be divided into the following parts:
- Physical memory fully mapped area: 0x80000000 ~ 0x84000000
- Peripheral register address mapping area: 0x98000000 ~ 0xB0000000
- Boot ROM mapping area: 0xC0100000 ~ 0xC0000000
>> The physical memory fully mapped area is mainly used to manage the actual address space of the process. It is actually a linear offset address (0x50000000) from 0x30000000 to 0x80000000. When we need to operate the user space in the kernel space, using this fully mapped area is very convenient. For example, when loading a program into the process space, its virtual address can be known through simple calculations.
For example: when starting process No. 5, its physical address is placed in the 5M space starting from 0x30000000, then its virtual address is 0x30000000 + 5M + 0x50000000 (offset address).
>> The peripheral register address mapping area is used to operate the peripheral registers. When the peripheral registers are used, their virtual addresses can be obtained through simple addition and subtraction operations.
>> Start ROM mapping area, used to map NOR FLASH.
Physical memory space structure:
As can be seen from the above figure, the physical space of process 0 (0x30000000 ~ 0x30100000) actually has other uses besides storing OS code.
- The page table is placed at memory address 0x30000000
- The OS code is placed at 0x300F0000, which is intentional.
The initial 1MB of physical memory address 0x30000000~0x30100000 is the kernel process address space 0, which is actually the OS code area, kernel stack area and page table area.
Since the OS code is placed in physical memory at 0x300F0000, it is mapped to virtual address 0x800F0000, so the running address of the OS code set in ADS is 0x800F0000.
Previous article:S3C2440 system interrupt
Next article:mini6410 interrupt controller-VIC interrupt controller
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Last day! Answer questions to win prizes! Practical sharing | Design a reliable switching power supply from scratch
- micropython update: 2021.4
- The battery voltage is pulled down
- Is there any abnormal sound from the common mode inductor?
- There's a problem with the project
- bq27411-g1 (single-cell fuel gauge) bq27541 (single-cell fuel gauge) bq27546-g1 (single-cell fuel gauge)
- Playing with circuits (2) - Killing LM5175
- A post in the Audiophile Academy. I just want to ask why there is no loop phase shift when a resistor is added before the decoupling capacitor.
- TI teaches you how to overcome the three common problems in high-speed amplifier design
- Signal correlation operation and algorithm analysis in single chip microcomputer program application