armv8(aarch64)linux内核中flush_dcache_all函数详细分析 (2)

* .macro  restore_irqs, olddaif                                                                                                                                          

     * msrdaif, \olddaif

    . * endm

        */

    restore_irqs x9

      //x1存储ccsidr_el1内容,低三位是(Log2(Number of bytes in cache line)) – 4

      //4x2=(Log2(Numberof bytes in cache line))

    and x2, x1, #7          // extract the length of the cachelines

    add x2, x2, #4          // add 4 (line length offset)

    mov x4, #0x3ff

      //逻辑右移3位,提取bits[12:3](Associativityof cache) – 1,

      //x4存储cacheway

    and x4, x4, x1, lsr #3     // find maximum number on the way size

      //计算x4前面0的个数,存到x5

    clz x5, x4              // find bit position of way sizeincrement

      //提取bits[27:13]位:(Number of sets in cache) - 1

    mov x7, #0x7fff

      //x7中存储cache中的set

    and x7, x7, x1, lsr #13     // extract max number of the index size

loop2:

      //把x4值备份

    mov x9, x4              // create working copy of max waysize

loop3:

      //把需要操作哪个way存储到x6

    lsl x6, x9, x5

      //确定操作哪一级的哪个way(x10指定操作哪一级cache)

    orr x11, x10, x6            // factor way and cache number intox11

      //确定操作哪个set

    lsl x6, x7, x2

    orr x11, x11, x6            // factor index number into x11

      //x11中存储了哪一级cache(10),哪一路cache(x9),哪个set(x7)

    dc  cisw, x11           // clean & invalidate by set/way

      //way数-1

    subs   x9, x9, #1          // decrementthe way

    b.ge   loop3

    subs   x7, x7, #1          // decrementthe index

    b.ge   loop2

skip:

    add x10, x10, #2            // increment cache number,

//为什么加2不是1?见loop1标号处解释

    cmp x3, x10

    b.gt   loop1

finished:

    mov x10, #0             // swith back to cache level 0

    msr csselr_el1, x10         // select current cache level incsselr

    dsb sy

    isb

    ret

ENDPROC(__flush_dcache_all)

 

 

 如果你对此有疑问,欢迎留言讨论。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgjxpy.html