Linux memory management tasks
1) Organize and plan the physical and virtual storage space distribution of the entire system;
2) Create a page table for the virtual storage space (linear address space), that is, establish a mapping relationship between virtual addresses and physical addresses;
3) Set access control attributes for different storage spaces to protect system storage spaces from illegal access;
4) Memory allocation and release.
1 Distribution of physical and virtual storage space in Linux
On a 32-bit microprocessor that supports MMU, the addressing range of Linux physical storage space and virtual storage space is 0x0000_0000~0xFFFF_FFFF, which is 4GB.
However, Linux runs in virtual storage space, and in actual use, physical memory far less than 4GB is mapped to 4GB of virtual memory.
Physical storage space distribution (quoted from "Practical Guide for Linux Kernel Development in Embedded Systems (ARM Platform)")
in:
1) noden, n <= MAX_NUMNODES-1, MAX_NUMNODES In ARM systems, sharp chips support 16 nodes, and others support 4.
2) numnodes is the current number of nodes.
3) In a system with CONFIG_DISCONTIGMEM set, there can be multiple nodes, otherwise only node0 is included.
4) bankn, n <= NR_BANKS-1, NR_BANKS In the ARM system, the sharp chip supports 16 nodes, and the others support 4.
5) mem_init() can release the space occupied by the page frame bit code, hole page descriptor space and free memory of all nodes.
Virtual storage space distribution (quoted from "Practical Guide for Linux Kernel Development in Embedded Systems (ARM Platform)")
1) Linear address space 0x0000_0000~0xFFFF_FFFF, 4GB
User space 0x0000_0000~0xBFFF_FFFF (3GB), kernel space 0xC000_0000~0xFFFF_FFFF (1GB)
2) Low memory: The physical memory mapped by the kernel logical address space is low memory.
The conversion between the physical address and the linear address of the low-end memory physical memory can be performed through __pa(x) and __va(x).
#define __pa(x) __virt_to_phys((unsigned long)(x))
//macro__pa(x)
#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
#define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
//macro __va(x)
#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
3) High-end memory
0xFFFF_FFFF -- --
--|-- //This part is the high-end physical memory, from high_memory to 0xFFFF_FFFF
--|-- //If the actual physical memory is greater than 896MB, high_memory = 896MB
--|-- //If the actual physical memory is less than 896MB, directly allocate high_memory = actual physical memory
--|-- // means 0C000_0000~high_memory corresponds to the actual physical memory address
high_memory --|--
0xC000_0000 -- --
In ARM processors, the conversion from virtual address to physical address can go through only one level of address translation or two levels of address translation.
Previous article:File exchange between host machine and development board
Next article:ARM platform Linux kernel Notes 1
Recommended ReadingLatest update time:2024-11-23 11:14
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Sonoff WiFi Smart Socket Network Service
- How to convert a DC 5V power supply into ±12V
- Live broadcast at 10:00 am today: ADI energy storage system helps build electric vehicle fast charging stations
- Please tell me about the inductance in this boost circuit
- A Ku-Band Balanced Amplifier
- There is no better way to view and visualize your swept 3D spherical pattern results.
- I want to know what device this is.
- [Repost] Understand the difference between PCB and integrated circuit in one article
- Safety Application of A/D Converter in ADuC812
- SPWM wave generation tool