Implementation of miniiOS, a small multitasking operating system

Publisher:760802csyLatest update time:2016-04-26 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
About miniiOS

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.

Reference address:Implementation of miniiOS, a small multitasking operating system

Previous article:S3C2440 system interrupt
Next article:mini6410 interrupt controller-VIC interrupt controller

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号