当前位置: 首页 > news >正文

成都建设网站报价怎么样做微信公众号

成都建设网站报价,怎么样做微信公众号,做监控的有哪些网站,织梦网站301重定向阅读材料 Xv6代码:memlayout.h、start.c、kernelvec.S教材5.4节 CLINT内存映射 实际上,CLINT还包括若干个MSIP寄存器,用来触发软件中断,但是在Xv6中不考虑软件中断,因此这些寄存器也不用考虑 // core local interr…

阅读材料

  • Xv6代码:memlayout.h、start.c、kernelvec.S
  • 教材5.4节

CLINT内存映射

实际上,CLINT还包括若干个MSIP寄存器,用来触发软件中断,但是在Xv6中不考虑软件中断,因此这些寄存器也不用考虑

// core local interruptor (CLINT), which contains the timer.
#define CLINT 0x2000000L
#define CLINT_MTIMECMP(hartid) (CLINT + 0x4000 + 8*(hartid))
#define CLINT_MTIME (CLINT + 0xBFF8) // cycles since boot.

time_scratch数组

timer_scratch二维数组为每个HART分配了40字节的内存,内存的作用如下图所示

// a scratch area per CPU for machine-mode timer interrupts.
uint64 timer_scratch[NCPU][5];

时钟初始化

该函数被start()函数调用,此时,系统还处于M模式下。该函数完成下列工作:

  1. 初始化mtimecmp寄存器
  2. 保存mtimecmp寄存器MMIO映射到的物理地址到scratch[3]
  3. 保存时钟间隔到scratch[4]
  4. scratch的地址保存到mscratch寄存器当中
  5. timervec汇编函数的地址写入mtvec当中
  6. 使能M模式下的时钟中断和M模式下的全局中断开关
void timerinit()
{// each CPU has a separate source of timer interrupts.int id = r_mhartid();// ask the CLINT for a timer interrupt.int interval = 1000000; // cycles; about 1/10th second in qemu.*(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;// prepare information in scratch[] for timervec.// scratch[0..2] : space for timervec to save registers.// scratch[3] : address of CLINT MTIMECMP register.// scratch[4] : desired interval (in cycles) between timer interrupts.uint64 *scratch = &timer_scratch[id][0];scratch[3] = CLINT_MTIMECMP(id);scratch[4] = interval;w_mscratch((uint64)scratch);// set the machine-mode trap handler.w_mtvec((uint64)timervec);// enable machine-mode interrupts.w_mstatus(r_mstatus() | MSTATUS_MIE);// enable machine-mode timer interrupts.w_mie(r_mie() | MIE_MTIE);
}

 时钟中断处理程序

当发生时钟中断的时候,会跳转到该汇编函数。该函数处理流程如下:

  1. 原子交换a0mscratch寄存器,这样a0将持有sratch数组的首地址
  2. 保存a1a2a3寄存器的值到sratch数组中,因为我们后续要用到这3个寄存器
  3. mtimecmp寄存器加上时钟间隔,用于下次的时钟中断
  4. 手动触发S模式下的软件中断
  5. 恢复a1a2a3寄存器和mscratch寄存器
  6. 执行mret指令返回操作系统
        ## machine-mode timer interrupt.#
.globl timervec
.align 4
timervec:# start.c has set up the memory that mscratch points to:# scratch[0,8,16] : register save area.# scratch[24] : address of CLINT's MTIMECMP register.# scratch[32] : desired interval between interrupts.csrrw a0, mscratch, a0sd a1, 0(a0)sd a2, 8(a0)sd a3, 16(a0)# schedule the next timer interrupt# by adding interval to mtimecmp.ld a1, 24(a0) # CLINT_MTIMECMP(hart)ld a2, 32(a0) # intervalld a3, 0(a1)add a3, a3, a2sd a3, 0(a1)# arrange for a supervisor software interrupt# after this handler returns.li a1, 2csrw sip, a1ld a3, 16(a0)ld a2, 8(a0)ld a1, 0(a0)csrrw a0, mscratch, a0mret

参考资料

3. 处理时钟中断 | XV6 源代码阅读指南 (gitbook.io)

The xv6 Kernel-13 entry.S + start.c_哔哩哔哩_bilibili

http://www.yayakq.cn/news/852623/

相关文章:

  • 重庆档案馆建设网站邯郸今天最新通告
  • 做视频的教学直播网站网站顶部代码
  • 网站建设甲方给乙方的需求方案北京公司提供注册地址
  • 购物网站开发总结报告网站开发 app
  • 建一家网站多少钱家私公司网站建设多少钱
  • 设计外包网站用什么来网站开发好
  • 找做课件的网站h5制作的软件
  • 商务网站建设流程步骤从事网站开发需要什么
  • 网站服务器端口如何做防护国外交互设计网站欣赏
  • 长沙网站搜索排名飞机多少钱一架
  • 常德网站建设网站优化芜湖网站备案咨询电话
  • 请别人做网站有风险吗镜像网站是怎么做的
  • 网站建设ahxkj游戏开发需要学什么编程
  • 如何做医美机构网站观察分析门户网站建设和管理情况
  • 网站开发手机验证码新浪如何上传wordpress
  • 基本型电商网站举例西安网站建设公司哪有
  • 顺德制作网站价格多少oj网站开发
  • 江苏省交通厅门户网站建设管理有做国际网站生意吗
  • 化妆品做的不好的网站免费静态网站托管
  • 工艺品网站源码做网站如何提需求
  • 做公司网站推广鞍山发布
  • 做地方特产的网站邢台网站建设包括哪些
  • 环保网站建设方案为什么有网络却打不开网页
  • 安徽 网站建设建设银行网站能买手机
  • 模型网站推广普通话主题手抄报
  • 手工艺品网站建设策划书网站建设与优化及覆盖率方案
  • 自助网站建设公司电话怎么做网上卖菜网站
  • 做网站下载类似pc蛋蛋的网站建设
  • 均安公司网站建设2022年企业所得税政策
  • 广州工程建设信息网站seo短视频网页入口引流下载