主要来自于ppc750cl(和60x系列类似)的user manual还有ibm的文档以及cache在POWERPC处理板中的应用.pdf(张璟元,陈浩,倪飞,中航飞行自动控制研究所,西安,710061)

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相关资料阅读笔记相关推荐

  1. ffmpeg中的http协议相关代码阅读笔记

    ffmpeg中的http协议相关代码阅读笔记 今天闲来无事,尝试看了下ffmpeg中的相关http协议传输处理代码 先简单说下这个代码在整个仓库里面的位置: ffmpeg/libavformat/ht ...

  2. 强化学习相关论文阅读笔记之稀疏奖励解决方法

    注:该系列文章为强化学习相关论文的阅读笔记,欢迎指正! 论文题目:<深度强化学习中稀疏奖励问题研究综述> 文章目录 1. 论文介绍 2. 论文结构 3. 研究背景 3.1 解决稀疏奖励的必 ...

  3. 华为服务器存储系列,华为 服务器 存储相关资料(示例代码)

    防火墙设备包链接:https://pan.baidu.com/s/1oBB6PDEJBGa8rap2C0qumQ 提取码:ocp0 添加本地连接:hdwwiz windows 2012 R2安装序列号 ...

  4. 谣言检测相关论文阅读笔记:Towards Multi-Modal Sarcasm Detection via Hierarchical Congruity Modeling

    Towards Multi-Modal Sarcasm Detection via Hierarchical Congruity Modeling with Knowledge Enhancement ...

  5. Fuzzing相关论文阅读笔记(一)

    前言 ​ 之前从网上一个博主的博客里面看到有关论文阅读记录的博文,博主在看完每一篇论文后都会进行相关总结和思考记录.个人觉得这是个不错的习惯,遂学习了下,刚好对最近看的几篇论文进行简单的记录. 论文总 ...

  6. 弱监督目标检测相关论文阅读笔记

    弱监督目标检测论文相关 1.传统目标检测 2014年之前->传统的目标检测器:VJ检测器->HOG检测器->DPM 2014年之后->基于深度学习的目标检测器: 双阶段:RCN ...

  7. 谣言检测相关论文阅读笔记:PAKDD2020-SAFE: Similarity-Aware Multi-Modal Fake News Detection

    目录 Abstract 1.Introduction 2.Related Work 3.Methodology 3.1 Multi-modal Feature Extraction 3.2 Modal ...

  8. 特征面提取相关文献阅读笔记(1)上篇

    参考文献: [1]Feng C, Taguchi Y, Kamat V R. Fast plane extraction in organized point clouds using agglome ...

  9. 风格迁移相关论文阅读笔记

    <图像和视频油画风格化研究> 西安交通大学 2011年 论文网址: http://kns.cnki.net/KCMS/detail/detail.aspx?dbcode=CJFQ& ...

  10. 谣言检测相关论文阅读笔记:DDGCN: Dual Dynamic Graph Convolutional Networks for Rumor Detection on Social Media

    来源:AAAI2022 摘要:现有的谣言检测很少同时对消息传播结构和时序信息进行建模,与评论相关的知识信息的动态性也没有涉及.所以本文提出了一个新颖的双动态图卷积网络-DDGCN,该模型能够在一个统一 ...

最新文章

  1. 什么是 CNN?Facebook 员工写给小白的机器学习入门贴彻底火了!
  2. java线程模拟生产者消费者问题
  3. 每日一道算法题-寻找丑数
  4. html5通过api调数据库,使用HTML5数据库API [关闭](Using HTML5 Database API [closed])
  5. [codevs1105][COJ0183][NOIP2005]过河
  6. python io操作需要用到什么硬件_Python I/O 操作(一)
  7. html怎么创建表格,html怎么做表格
  8. 津巴布韦 apn_津巴布韦的回忆-你负担不起回家
  9. Linux tar压缩文件夹,排除该文件夹下的某些文件夹或文件
  10. Linux网络流量监控工具
  11. String类常用方法解析
  12. Latex常见符号对照表
  13. 用Moment.js 计算两个时间直接的间隔
  14. 问题 E: 天宝便利店
  15. 可扩展的交互式可视化框架,用于衡量新闻中的性别偏见
  16. 禾赛科技“梦碎”科创板:营收递增、由盈转亏,在专利官司中败退
  17. VF200(VF101-N)产品重庆平台操作指导书_v2.1.24_20201020
  18. 石油大学网考 在线作业、在线考试 自动答题辅助工具
  19. 微软C#中的CHART图表控件
  20. Python使用百度OCR接口进行验证码图像识别

热门文章

  1. shell 脚本自动设置用户密码
  2. python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客
  3. 学会这3点,你就是老板最喜欢的员工!
  4. 12.MYSQL熟练使用存储过程
  5. RocketMQ快速上手
  6. 亚马逊计划在空中建无人机配送中心
  7. react-native-firebase 通知
  8. 语音识别训练数据集如何部署
  9. 成人高考和自考有什么区别呢
  10. php七牛云amr转mp3,asp.net音频转换之.amr转.mp3(利用七牛转换法)