linux kernel中cache代码解读
生活随笔
收集整理的這篇文章主要介紹了
linux kernel中cache代码解读
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、 在kernel中調(diào)用__dma_flush_range,底層是如何操作的呢?
/* remove any dirty cache lines on the kernel alias */__dma_flush_range(ptr, ptr + size); /** __dma_flush_range(start, end)* - start - virtual start address of region* - end - virtual end address of region*/ ENTRY(__dma_flush_range)dcache_line_size x2, x3 //獲取cache line size, 保存在x2中sub x3, x2, #1 //x3=x2-1,用于對(duì)其的Maskbic x0, x0, x3 //地址對(duì)齊,x0就是__dma_flush_range(ptr, ptr + size)中的ptr虛擬地址 1: dc civac, x0 // invalid一行cache line,下面這一段是一個(gè)循環(huán)add x0, x0, x2 //x0 = x0 + cache line sizecmp x0, x1 //比較x0和__dma_flush_range(ptr, ptr + size)中的ptr+sizeb.lo 1bdsb syret ENDPIPROC(__dma_flush_range) /** dcache_line_size - get the minimum D-cache line size from the CTR register.*/.macro dcache_line_size, reg, tmpmrs \tmp, ctr_el0 // read CTRubfm \tmp, \tmp, #16, #19 // cache line size encodingmov \reg, #4 // bytes per wordlsl \reg, \reg, \tmp // actual cache line size附上civac的寄存器和指令:
最后總結(jié)一下,__dma_flush_range(ptr, ptr+size)其實(shí)就是 invalid cache這一段虛擬地址
總結(jié)
以上是生活随笔為你收集整理的linux kernel中cache代码解读的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux kernel变长数组使用示例
- 下一篇: linux kernel使用技巧