How to understand __setup_mmu of linux 2.6.35

0

I'm reading the source code of Linux 2.6.35 in arm arch(NXP i.mx283 - ARM926EJS).

now, at arch/arm/boot/compressed/head.S:__setup_mmu label.

 515                 /* r4存储着内核解压后的地址 */
 516                 /* r3 = r4 - 16384 = 0x40008000 - 16384*/                                                                                                                      
 517 __setup_mmu:    sub     r3, r4, #16384          @ Page directory size                                                                                                          
 518                 /* r3 = 0x40004000 */
 519                 bic     r3, r3, #0xff           @ Align the pointer                                                                                                            
 520                 /* r3 = 0x40004000 页目录地址 */                                                                                                                               
 521                 bic     r3, r3, #0x3f00                                                                                                                                        
 522 /*
 523  * Initialise the page tables, turning on the cacheable and bufferable                                                                                                         
 524  * bits for the RAM area only.
 525  */             
 526 /*              
 527  * 初始化页表,打开cacheble和bufferable位仅在RAM区域                                                                                                                           
 528  */             
 529                 /* r0 = 0x40004000 */
 530                 mov     r0, r3
 531                 /* r9 = 0x1000 */
 532                 mov     r9, r0, lsr #18
 533                 /* r9 = 0x40000000,起始地址 */                                                                                                                                
 534                 mov     r9, r9, lsl #18         @ start of RAM                                                                                                                 
 535                 /* r10 = 0x50000000 */
 536                 /* 一个合理的RAM大小256M,结束地址 */                                                                                                                          
 537                 add     r10, r9, #0x10000000    @ a reasonable RAM size                                                                                                        
 538                 /* r1 = 0x12 */ 
 539                 mov     r1, #0x12
 540                 /* r1 = 0xC12,要写入的数据 */
 541                 orr     r1, r1, #3 << 10
 542                 /* r2 = 0x40008000 */
 543                 add     r2, r3, #16384
 544                 /* 比较r1和r9中的内容, r1 = 0xC12, r9 = 0x40000000 */
 545 1:              cmp     r1, r9                  @ if virt > start of RAM
 546                 /* 如果r1 > r9的话,r1 = 0xC1E */
 547                 orrhs   r1, r1, #0x0c           @ set cacheable, bufferable
 548                 /* 比较r1和r10中的内容,r1 = 0xC12,r10 = 0x50000000 */
 549                 cmp     r1, r10                 @ if virt > end of RAM
 550                 /* r1 = 0xc12 */
 551                 bichs   r1, r1, #0x0c           @ clear cacheable, bufferable
 552                 /* 存储r1中的数据0xc12到r0指向的地址0x40004000中,然后r0地址+4写入r0中 */
 553                 str     r1, [r0], #4            @ 1:1 mapping
 554                 /* 0xc12 + 1M */
 555                 add     r1, r1, #1048576
 556                 /* 测试指针r0是否等于r2,内核解压地址 */
 557                 teq     r0, r2
 558                 bne     1b
 559 /*
 560  * If ever we are running from Flash, then we surely want the cache
 561  * to be enabled also for our execution instance...  We map 2MB of it
 562  * so there is no map overlap problem for up to 1 MB compressed kernel.
 563  * If the execution is in RAM then we would only be duplicating the above.
 564  */
 565  /* 如果我们从Flash上运行,然后我们一定想要cache被打开并执行我们的实例
 566   * 我们映射2M,这样不会有映射重叠问题,为了提升到1M解压内核。
 567   * 如果执行在RAM上,然后我们只应被复制到下面。
 568   */
 569                 mov     r1, #0x1e
 570                 orr     r1, r1, #3 << 10
 571                 mov     r2, pc, lsr #20
 572                 orr     r1, r1, r2, lsl #20
 573                 add     r0, r3, r2, lsl #2
 574                 str     r1, [r0], #4
 575                 add     r1, r1, #1048576
 576                 str     r1, [r0]
 577                 mov     pc, lr
 578 ENDPROC(__setup_mmu)

my opinion:

r1 = 0xC12 r9 = 0x40000000

r1 is never large than r9, so line 547 is never be execute.

but, it's maybe not right.

my question: how to understand all of the __setup_mmu

linux
arm
asked on Stack Overflow Jul 29, 2020 by 天田南 • edited Jul 29, 2020 by 天田南

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0