$ cat arch/arm32/driver/gic_v2.c
/*************************************************************************
> File Name: gic_v2.c
> Author: SuWeishuai
> Mail: suwsl@foxmail.com
> Created Time: Thu 28 Apr 2022 04:18:56 PM CST
************************************************************************/#include"platform.h"#include"reg_ops.h"#include"gic_v2.h"gic_v2_dist_t* gic_dist =0;gic_v2_cpu_t* gic_cpu =0;intgic_v2_init(void){int i =0;unsigned cbar =0;
cbar =sreg_rd(CBAR);
gic_dist =(gic_v2_dist_t*)cbar;
gic_cpu =(gic_v2_cpu_t*)(cbar+0x10000);#if0// The GICD_IPRIORITYRs provide an 8-bit priority field for each interrupt supported by the GIC.for(i =0; i <32; i++){
gic_dist->D_IPRIORITYR[i]=0x5<<3;}#endif// Provides an interrupt priority filter.
gic_cpu->C_PMR =0XF8;#if0// The value of this field controls how the 8-bit interrupt priority field is split into a group priority field// 0X2// Group priority field : Subpriority field// [7:3] : [2:0]// ggggg : sss
gic_cpu->C_BPR =0X2;#endif// The GICD_ISENABLERs provide a Set-enable bit for each interrupt supported by the GIC.// Writing 1 to a Set-enable bit enables forwarding of the corresponding interrupt from the// Distributor to the CPU interfaces.
gic_dist->D_ISENABLER[0]=(1<<29);// Enables the forwarding of pending interrupts from the Distributor to the CPU interfaces.
gic_dist->D_CTLR =0X1;// Enables the signaling of interrupts by the CPU interface to the connected processor
gic_cpu->C_CTLR =0X1;return0;}
名词解释
几个名词
system counter
processor counter
generic timer counter
其中 system counter 和 generic timer counter 一致 , 以后只说 system counter
其中 processor counter 是 processor 运行的 计数
system counter 的频率 是 1MHZ-50MHZ , 可设置
processor counter 的频率更高,可以达到 2GHZ,即处理器的运行频率
The CNTFRQ register indicates the clock frequency of the system counter.
Programming CNTFRQ does not affect the system clock frequency.
However, on system initialization, CNTFRQ must be correctly
programmed with the system clock frequency, to make this value
available to software.
Typically, the system drives the system counter at a fixed frequency and the CNTFRQ register must be programmed
to this value during the system boot process.
写入 CNTFRQ 不影响 system clock frequency , 那会影响什么呢?
既然不影响 system clock frequency , 写入 这个寄存器的目的是什么呢?