Arm-linux memory management (4)

Publisher:自在自由Latest update time:2022-06-15 Source: eefocusKeywords:Arm Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The previous article mainly focused on data structures related to specific systems, and left a question at the end:


So, how do these data structures work? In particular, how does the ARM-Linux kernel establish address mappings based on these data structures?


1. Let's start with the initialization of the system. After the system is booted, the CPU enters the main entrance of the kernel, which is the starting point of the code segment stext. In stext, the CPU first reads the CPU model and the machine model from itself, stores the relevant information in the two global variables processor_id and machine_arch_type, and then goes to start_kernel().


asmlinkage void __init start_kernel(void)

{


......


setup_arch(&command_line);


The code of this function depends on the specific CPU model, and it mainly completes the following operations during the system initialization phase:

......


mem_init();

kmem_cache_sizes_init();


.......



For the MMU, a specific page directory is a specific mapping, but for the kernel some additional information is needed. From the kernel's perspective, a specific mapping is described and managed by an mm_struct data structure, among which the kernel's mm_struct data structure init_mm has special importance:


struct mm_struct init_mm = INIT_MM(init_mm);



#define INIT_MM(name)

{

mm_rb:  RB_ROOT,

pgd: swapper_pg_dir,

mm_users:  ATOMIC_INIT(2),

mm_count:  ATOMIC_INIT(1),

mmap_sem:  __RWSEM_INITIALIZER(name.mmap_sem),

page_table_lock: SPIN_LOCK_UNLOCKED, 

mmlist:  LIST_HEAD_INIT(name.mmlist),

}


The correct term should be the mm_struct data structure of the kernel thread, or the mapping of the kernel thread, because this mapping does not contain any user space mappings. All kernel threads in the system share the same mapping, which is init_mm. In particular, the mm_struct data structure of the kernel thread init is init_mm.


Each process or thread has a process control block, which contains a pointer mm pointing to its own mm_struct data structure. In the mm_struct structure, there is a pointer pgd pointing to its first-level page directory.


/*

 * We place the page tables 16K below TEXTADDR.  Therefore, we must make sure

 * that TEXTADDR is correctly set.  Currently, we expect the least significant

 * "short" to be 0x8000, but we could probably relax this restriction to

 * TEXTADDR > PAGE_OFFSET + 0x4000

 *

 * Note that swapper_pg_dir is the virtual address of the page tables, and

 * pgtbl gives us a position-independent reference to these tables.  We can

 * do this because stext == TEXTADDR

 *

 * swapper_pg_dir, pgtbl and krnladr are all closely related.

 */

#if (TEXTADDR & 0xffff) != 0x8000

#error TEXTADDR must start at 0xXXXX8000

#endif



.globl  SYMBOL_NAME(swapper_pg_dir)

.equ SYMBOL_NAME(swapper_pg_dir), TEXTADDR - 0x4000



.macro  pgtbl, reg, rambase

adr reg, stext

sub reg, reg, #0x4000

.endm



/*


/*




Keywords:Arm Reference address:Arm-linux memory management (4)

Previous article:Analysis of nandflash driver under Linux (1)——Based on s3c6410 platform
Next article:Linux serial terminal ttySAC, Linux serial terminal driver - S3C6410 platform

Recommended ReadingLatest update time:2024-11-16 14:32

ARM bare metal learning 1: S3C2440 clock system
1. Clock Generation The system clock diagram of S3C2440 is as follows: The main clock source of S3C2440A is provided by an external clock (EXTCLK) or an external crystal oscillator (XTIPll). The input clock source is selected by the mode control pins OM3 and OM2. At the rising edge of the reset signal, the state of
[Microcontroller]
ARM bare metal learning 1: S3C2440 clock system
Design of ADSL2+ Tester Based on ARM
  introduction   In recent years, Asymmetric Digital Subscriber Line (ADSL) has been widely used around the world as an ideal solution to the "last mile" problem of the network. In China, ADSL services have become one of the main sources of revenue for operators. However, since the existing telephone lines are designe
[Test Measurement]
Design of ADSL2+ Tester Based on ARM
Design of HPI interface between ARM and DSP in video surveillance system
1 Introduction 无忧电子开发网 http://wwww.51kaifa.com As network technology, image processing technology and embedded technology become more mature, video surveillance technology has been widely used. Banks, factories, governments, schools and other departments are all equipped with monitoring sy
[Microcontroller]
Design of HPI interface between ARM and DSP in video surveillance system
Detailed analysis of the ARM Linux boot process
The analysis of the ARM Linux boot process is what I want to introduce. The portability of embedded Linux allows us to see it in various electronic products. The Linux boot process is also different for processors with different architectures. This article takes the S3C2410 ARM processor as an example to analyze in de
[Microcontroller]
ARM uses the terms flush and clean to refer to the basic operations on the cache.
Clearing the cache means clearing all the data stored in the cache. For the processor, the clear operation is to clear the valid bit of the corresponding cache line. When there is a change in the memory configuration, the whole or part of the cache may need to be cleared. Sometimes the term invalidate is used instead
[Microcontroller]
Transplantation and Implementation of uC/OS-II on ARM System
0 Preface When developing embedded systems, embedded development platforms based on ARM and uC/OS-II are generally chosen because ARM microprocessors have the advantages of fast processing speed, ultra-low power consumption, low price, and wide application prospects . After porting uC/OS-II to the ARM system, the ad
[Microcontroller]
Transplantation and Implementation of uC/OS-II on ARM System
Is Nvidia's $40 billion acquisition of ARM going to fail?
Nvidia is likely to fail to complete its $40 billion acquisition of British chip design company ARM by the preset deadline of March 2022 as European regulators are reluctant to consider the case before the summer holidays, according to people familiar with the matter.    Nvidia announced its acquisition of ARM last ye
[Semiconductor design/manufacturing]
Design of intelligent caller display based on ARM
0 Introduction At present, there are two ways for my country's telephone network switches to transmit caller identification information CID (Calling Identity Delivery). The more commonly used one is FSK (Frequency Shift Keying) and the other is DTMF (Dual Tone Multi-Frequency). By mastering the corresponding pr
[Microcontroller]
Design of intelligent caller display based on ARM
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号