ARM platform Linux kernel Notes 2

Publisher:trendsetter10Latest update time:2024-09-03 Source: cnblogs Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.


Reference address:ARM platform Linux kernel Notes 2

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

OK6410A Development Board (VIII) 8 linux-5.11 OK6410A Detailed analysis of the start_kernel runtime stack
include/asm-generic/vmlinux.lds.h  376 #define INIT_TASK_DATA(align)                                                     377     . = ALIGN(align);                                                             378     __start_init_task = .;                                                        379     init_thread_unio
[Microcontroller]
mini2440 u-boot linux kernel boot,Mini2440 uboot,kernel,root file system construction
According to the manual of mini2440, I have learned that the construction process of uboot, kernel and root file system is as follows. The specific details are not considered for the time being, only the entire compilation and burning process is considered. First of all, our host machine must have nfs server and tft
[Microcontroller]
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号