PowerPC60x系列的L2 cache相关资料阅读笔记
来源:互联网 发布:java opencv图像识别 编辑:程序博客网 时间:2024/05/13 16:50
L2 Cache Control
L2 Cache的配置,主要是由两个寄存器来进行控制,一个是L2 Cache ControlRegister(L2CR),一个是HID4寄存器的L2FM区域。
L2CR寄存器
L2缓存控制寄存器(L2 cachecontrol register,L2CR)是用来配置和使能L2 cache的寄存器。L2CR是一个管理权限(supervisor)级别的读写的硬件实现相关的寄存器,他的SPR编号是1017。他在上电reset的时候会被cleared.下标描述了L2CR的位。
0:L2E 用来使能L2
1:L2CE L2 double biterror checkstop enable,双位错误检查使能
2-8:保留位,可以用来进行L2时钟的设置
9:L2D0 设置该位的话,L2 cache仅能进行数据操作(指令cache会绕过L2 cache)。注意的是没有办法让L2只进行指令操作。
10:L2I L2全局无效。设置L2I位通过清除L2的状态位使L2cache 全局无效
11:保留位
12:L2WT L2写透(write-through),默认是copy-back模式。
13:L2TS L2测试支持。设置该位会导致dcbf和dcbst的引起的L1 data cache的写操作会被只写入L2 cache,并且被标记有效,而不是写入总线并在L2 cache中标记为无效。如果L2TS被设置了,单节拍的store操作如果在L2中miss,也会被忽略。
14-30:保留
31:L2IP :L2全局无效in progress(只读),这个位用来表示L2的全局无效化是不是正在进行。换句话说如果我们进行一个全局无效化操作,首先应该把L2CR[L2I]置为1,这个时候就开始判断L2CR[IP]位,如果IP位变为1,则表示全局无效化操作完成,如果没有就继续判断。如果IP变为0,那么说明全局无效化完成,可以把L2I位清除。
另外,HID4有一个L2FM域
个人理解一个L2 cache的初始化的过程应该是这样的吧(IBM手册的官方步骤见下):
首先明确L2CR的SPR编号为1017,上电的时候被默认全部清零。
这个时候L2 cache应该是默认不使能。
设置L2CR[L2I]位为1,执行L2cache的全局无效化操作。判断L2CR的IP位为1时表示执行完毕,这个时候把L2I清零,再把L2 cache使能就完成了初始化。
L2 cache初始化和配置
在上电或者一个硬重置(hard reset)之后,L2 cache初始状态是disabled。他必须在系统启动时,在使用之前就必须被初始化。另外,如果L2 cache是被软件动态的disabled的,那么在他被重新enable前也必须进行初始化。初始化和使能应该遵循以下的步骤:
1.保证中断被屏蔽,并且动态电源管理(dynamic power management)是被disabled的(HID0[DPM]=0)
2.按照下一节讲的步骤进行一个L2的全局无效化操作。
3.disable L1的instruction cache,使用下面的instruction 序列:
mfsprrX, HID0 ; save current HID0
rlwinm rY, rX, 0,17,15 ; clear bit 16
mtspr HID0, rY ; disable icache
isync
4. Set configuration bits in the L2CR, as appropriate
按照需要设置L2CR的位
5. Enable the L2 (L2CR[L2E] = 1)
使能L2(L2CR[L2E] = 1)
6. Restore the L1 instruction cache to its previous configuration using
重新把L1的instructioncache设置到之前的状态,使用以下语句:
mtspr HID0, rX ; restore HID0
isync
7. Unmask interrupts and enable dynamic power management, asappropriate.
根据需要,设置不屏蔽中断(Unmask interrups),重新使能动态电源管理。
在一般的操作中,L2 cache可以按照“先禁能L1 指令cache,后改变L2CR,然后使能L1instruction cahe”的步骤进行重新设置,比如说如果要使能L2的data only mode,那么可以使用以下的步骤:
- 1.屏蔽中断
- 2.按照上面的步骤禁能L1 instruction cache.
- 3.设置L2CR[L2DO]位为1
- 4.按上面的步骤重新恢复L1的instruction cache
- 5.使能中断
L2 cache的全局无效化(GlobalInvalidation)
注意:这段我觉得其实原文可能比翻译更好,所以保留了原文供人参考。
The L2 cache supports a global invalidation function in which allbits of the L2 tags (tag data bits, tag status bits, and LRU bit) are cleared.It is performed by an on-chip hardware state machine that sequentially cycles throughthe L2 tags. The global invalidation function is controlled through L2CR[L2I],and it must be performed only while the L2 cache is disabled (note thatL2CR[CE] must be cleared before invalidation starts). The 750CL can continueoperation during a global invalidation provided the L2 cache has been properlydisabled before the global invalidation operation starts.
L2 cache支持一种全局无效化功能,这个功能可以把所有L2 tags(tagdata bits,tag status bits,和LRU bit)清除。他由硬件实现。全局无效化功能被L2CR寄存器的[l2I]位控制,并且他只有在L2cache被禁能的情况下才能使用(注意L2CR[CE]必须在无效化开始之前被清零)。750CL可以在L2全局无效化开始前禁能并且在进行全局无效化的情况下继续操作。
一个L2 cache的全局无效化的操作是按照下列步骤进行的:
The sequence for performing a global invalidation of the L2 cache is asfollows:
1. Execute a sync instruction to finish any pending store operations in the load/storeunit, disable the L2 cache by clearing L2CR[L2E], and execute anadditional sync instructionafter disabling the L2 cache to ensure that any pending operations in the L2cache unit have completed.
执行一个sync指令来完成前面没完成的store操作,通过清除L2CR[L2E]来禁能L2cache,并且也在之后执行一个sync保证之前L2 cache 单元里的操作已经完成。
2. Initiate the global invalidation operation by setting the L2CR[L2I] bit to1.
初始化全局无效操作,通过设置L2CR[L2I]位为1,。
3. Monitor the L2CR[L2IP] bit to determine when the global invalidation operationis complete (indicated by the clearing of L2CR[L2IP]). The global invalidationrequiresapproximately 32K core clock cycles to complete.
监控L2CR[L2IP]位来判断全局无效化操作什么时候完成(通过L2CR[L2IP]位为0指示)。全局无效化操作,大约需要32K的核心时钟周期来完成。
4. After L2CR[L2IP] is cleared, the process of initializing the L2 can proceedas described in the previous section. Never perform a global invalidation ofthe L2 cache while in dynamic power management enable mode. Be sure the HID0[DPM]bit is zero. Also ensure that the processor is in a tight uninterruptablesoftware loop monitoring the end of the global invalidate, so that an L1 datacache miss cannot occur that would initiate a reload from system memory duringthe global invalidate operation.
在L2CR[L2IP]被清零过后,初始化L2的过程可以按照上一步讲的那样继续下去了。永远不要在动态电源管理模式打开的情况下进行一个L2 cache的全局无效化,保证HID0[DPM]位为0。同时也要确保处理器在一个不断监控着全局无效化结束的软件的循环当中,这样L1 data cache的miss不会导致在全局无效化操作过程中从内存中重取数据(最后这句话我是直译的,但是其实感觉不通顺,原文也没读懂)。
顺便在https://www.ibm.com/developerworks/library/pa-ppccache/上也有关于Cache的介绍,里面有关于L2 Cache初始化的示例代码:
!
! Assuming interrupts are disabled,disable L2, perform global invalidate, enable.
!
mfspr r3,L2CR !Read L2CR
rlwinm r3,r3,0,1,31 !Clear L2CR[L2E] (bit 0)
mtspr L2CR,r3 !Write L2CR
isync
oris r3,r3,31 !Set bit 10, Global Invalidate /////个人意见这句话应该写错了,不是31,而是32,欢迎大家探讨。
mtspr L2CR,r3 !Write L2CR
isync
loop1:
mfspr r3,L2CR !Read L2CR
rlwinm r3,r3,0,31,31 !Mask bit 31 - Invalidate in progress
cmpi 0,r3,0 !Still in progress?
bc loop1 !loop until invalidate completes
mfspr r3,L2CR !Read L2CR
oris r3,r3,32768 !Set enable bit
mtspr L2CR,r3
isync
中间找到有一段话是这么说的:
Programming Note:
The HID4 register contains several control bits that affect the operation of the L2 cache.
The HID4 register must be initialized before enabling the L2 cache. In particular, HID4[L2_CCFI] must be set to 1 for correct operation of the L2 cache.
就是说在使能L2 cache之前的时候HID4[L2_CCFI]要置为1,又去找了下HID4的L2_CCFI位,是这么说的:
L2CFI - L2 complete castout prior to L2 flash invalidate
0 - L2 flash invalidate operations begin immediately after writing L2CR[L2I]
1 - L2 flash invalidate operations are delayed until after the L2 castout buffer is emptied. Setting this bit to 1 avoids the potential for the flash invalidate to cause incorrect address information in a pending L2 castout.
大意是说如果设置为0的话,L2CR[L2I]写成1之后就会开始执行无效化操作,而写作0的话会有延迟,默认在上电的时候这一位会是0(The HID4 register controls enhanced features of the 750CL. On startup (when HRESET is negated), the initial state of this register is 0x‘8000 0000’. That is, bit [0] is initialized to ‘1’, and all other bits are initialized to ‘0’.)因为后面谈L2 cache和一些示例代码里面都没有再提到,所以感觉上来说这个不是特别重要。不过还是先记下来,如果有问题了,再试试按照说的这么做。
- PowerPC60x系列的L2 cache相关资料阅读笔记
- 关闭L2 cache的方法
- Cache, L2 Cache, CacheRangeFlush
- ARM cortex-A9 的L2 Cache lockdown
- 软件工程相关阅读资料收集
- 【阅读】jQuery.Deferred相关资料
- cache的相关知识
- C64x L1 L2 cache
- 二级缓存(L2 CACHE)
- L1 L2 L3 cache
- MyBatis L2 Cache ---ignite
- Mybatis 源码系列 相关资料
- IDEA的笔记(L2 )
- 关于“缓存着色(cache coloring, page coloring)”技术的相关资料介绍
- 关于“缓存着色(cache coloring, page coloring)”技术的相关资料介绍
- LDA主题模型相关阅读资料
- make menuconfig关闭imx6q开发板的L1 cache/L2 cache
- Solr入门之官方文档6.0阅读笔记系列(八) 相关过滤器
- C++ primer 第五版 中文版 练习 10.33
- 1026. Table Tennis (30)
- jquery combotree\datagrid 包引用
- 使用csc命令手动编译cs文件
- GCAM初步运行
- PowerPC60x系列的L2 cache相关资料阅读笔记
- Android的ListView中的长按事件触发点击事件
- Linux内存管理之mmap详解
- sqlite3使用总结
- 9. Palindrome Number
- Unable to compile class for JSP
- [java] 6、获取本地机器网络地址信息
- Android使用fitsSystemWindows属性实现–状态栏【status_bar】各版本适配方案
- Caused by: java.lang.NoClassDefFoundError: zgd.project.R$styleable