/*

  • Copyright © 2015-2020, ARM Limited and Contributors. All rights reserved.
  • SPDX-License-Identifier: BSD-3-Clause
    */

#include <assert.h>

#include <drivers/arm/gic_common.h>
#include <lib/mmio.h>

#include “…/common/gic_common_private.h”

1-GIC分发器接口访问器,用于读取整个寄存器

/*******************************************************************************

  • GIC Distributor interface accessors for reading entire registers
    *****************************************************************************/
    /

  • Accessor to read the GIC Distributor IGROUPR corresponding to the interrupt

  • id, 32 interrupt ids at a time.
    */
    unsigned int gicd_read_igroupr(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> IGROUPR_SHIFT;

    return mmio_read_32(base + GICD_IGROUPR + (n << 2));
    }

1-gicd_read_isenabler

访问器读取与中断“id”对应的GIC分发器ISENABLER,一次32个中断id。
/
/

  • Accessor to read the GIC Distributor ISENABLER corresponding to the

  • interrupt id, 32 interrupt ids at a time.
    */
    unsigned int gicd_read_isenabler(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ISENABLER_SHIFT;

    return mmio_read_32(base + GICD_ISENABLER + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor ICENABLER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    unsigned int gicd_read_icenabler(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ICENABLER_SHIFT;

    return mmio_read_32(base + GICD_ICENABLER + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor ISPENDR corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    unsigned int gicd_read_ispendr(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ISPENDR_SHIFT;

    return mmio_read_32(base + GICD_ISPENDR + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor ICPENDR corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    unsigned int gicd_read_icpendr(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ICPENDR_SHIFT;

    return mmio_read_32(base + GICD_ICPENDR + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor ISACTIVER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    unsigned int gicd_read_isactiver(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ISACTIVER_SHIFT;

    return mmio_read_32(base + GICD_ISACTIVER + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor ICACTIVER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ICACTIVER_SHIFT;

    return mmio_read_32(base + GICD_ICACTIVER + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor IPRIORITYR corresponding to the

  • interrupt id, 4 interrupt IDs at a time.
    */
    unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> IPRIORITYR_SHIFT;

    return mmio_read_32(base + GICD_IPRIORITYR + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor ICGFR corresponding to the

  • interrupt id, 16 interrupt IDs at a time.
    */
    unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> ICFGR_SHIFT;

    return mmio_read_32(base + GICD_ICFGR + (n << 2));
    }

/*

  • Accessor to read the GIC Distributor NSACR corresponding to the

  • interrupt id, 16 interrupt IDs at a time.
    */
    unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id)
    {
    unsigned int n = id >> NSACR_SHIFT;

    return mmio_read_32(base + GICD_NSACR + (n << 2));
    }

2-GIC分发器接口访问器,用于写入整个寄存器

/*******************************************************************************

  • GIC Distributor interface accessors for writing entire registers
    *****************************************************************************/
    /

  • Accessor to write the GIC Distributor IGROUPR corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> IGROUPR_SHIFT;

    mmio_write_32(base + GICD_IGROUPR + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ISENABLER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ISENABLER_SHIFT;

    mmio_write_32(base + GICD_ISENABLER + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ICENABLER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ICENABLER_SHIFT;

    mmio_write_32(base + GICD_ICENABLER + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ISPENDR corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_ispendr(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ISPENDR_SHIFT;

    mmio_write_32(base + GICD_ISPENDR + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ICPENDR corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_icpendr(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ICPENDR_SHIFT;

    mmio_write_32(base + GICD_ICPENDR + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ISACTIVER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_isactiver(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ISACTIVER_SHIFT;

    mmio_write_32(base + GICD_ISACTIVER + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ICACTIVER corresponding to the

  • interrupt id, 32 interrupt IDs at a time.
    */
    void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ICACTIVER_SHIFT;

    mmio_write_32(base + GICD_ICACTIVER + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor IPRIORITYR corresponding to the

  • interrupt id, 4 interrupt IDs at a time.
    */
    void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> IPRIORITYR_SHIFT;

    mmio_write_32(base + GICD_IPRIORITYR + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor ICFGR corresponding to the

  • interrupt id, 16 interrupt IDs at a time.
    */
    void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> ICFGR_SHIFT;

    mmio_write_32(base + GICD_ICFGR + (n << 2), val);
    }

/*

  • Accessor to write the GIC Distributor NSACR corresponding to the

  • interrupt id, 16 interrupt IDs at a time.
    */
    void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val)
    {
    unsigned int n = id >> NSACR_SHIFT;

    mmio_write_32(base + GICD_NSACR + (n << 2), val);
    }

3-GIC分配器用于访问与单个中断ID相对应的GIC寄存器的功能

GIC分配器用于访问与单个中断ID相对应的GIC寄存器的功能。这些功能使用按位操作或适当的寄存器访问来修改或返回与单个中断标识相对应的位字段。
/
******************************************************************************

  • GIC Distributor functions for accessing the GIC registers

  • corresponding to a single interrupt ID. These functions use bitwise

  • operations or appropriate register accesses to modify or return

  • the bit-field corresponding the single interrupt ID.
    ******************************************************************************/
    unsigned int gicd_get_igroupr(uintptr_t base, unsigned int id)
    {
    unsigned int bit_num = id & ((1U << IGROUPR_SHIFT) - 1U);
    unsigned int reg_val = gicd_read_igroupr(base, id);

    return (reg_val >> bit_num) & 0x1U;
    }

void gicd_set_igroupr(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << IGROUPR_SHIFT) - 1U);
unsigned int reg_val = gicd_read_igroupr(base, id);

gicd_write_igroupr(base, id, reg_val | (1U << bit_num));

}

void gicd_clr_igroupr(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << IGROUPR_SHIFT) - 1U);
unsigned int reg_val = gicd_read_igroupr(base, id);

gicd_write_igroupr(base, id, reg_val & ~(1U << bit_num));

}

void gicd_set_isenabler(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ISENABLER_SHIFT) - 1U);

gicd_write_isenabler(base, id, (1U << bit_num));

}

void gicd_set_icenabler(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ICENABLER_SHIFT) - 1U);

gicd_write_icenabler(base, id, (1U << bit_num));

}

void gicd_set_ispendr(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ISPENDR_SHIFT) - 1U);

gicd_write_ispendr(base, id, (1U << bit_num));

}

void gicd_set_icpendr(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ICPENDR_SHIFT) - 1U);

gicd_write_icpendr(base, id, (1U << bit_num));

}

unsigned int gicd_get_isactiver(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ISACTIVER_SHIFT) - 1U);
unsigned int reg_val = gicd_read_isactiver(base, id);

return (reg_val >> bit_num) & 0x1U;

}

void gicd_set_isactiver(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ISACTIVER_SHIFT) - 1U);

gicd_write_isactiver(base, id, (1U << bit_num));

}

void gicd_set_icactiver(uintptr_t base, unsigned int id)
{
unsigned int bit_num = id & ((1U << ICACTIVER_SHIFT) - 1U);

gicd_write_icactiver(base, id, (1U << bit_num));

}

void gicd_set_ipriorityr(uintptr_t base, unsigned int id, unsigned int pri)
{
uint8_t val = pri & GIC_PRI_MASK;

mmio_write_8(base + GICD_IPRIORITYR + id, val);

}

void gicd_set_icfgr(uintptr_t base, unsigned int id, unsigned int cfg)
{
/* Interrupt configuration is a 2-bit field */
unsigned int bit_num = id & ((1U << ICFGR_SHIFT) - 1U);
unsigned int bit_shift = bit_num << 1;

uint32_t reg_val = gicd_read_icfgr(base, id);/* Clear the field, and insert required configuration */
reg_val &= ~(GIC_CFG_MASK << bit_shift);
reg_val |= ((cfg & GIC_CFG_MASK) << bit_shift);gicd_write_icfgr(base, id, reg_val);

}

ATF:Gicv源码文件系列-gicdv2_helpers.c相关推荐

  1. ATF:Gicv源码文件系列-gicv2.mk

    这个文件包含了gicv2的源码文件!!! #Copyright © 2020, Arm Limited. All rights reserved. #SPDX-License-Identifier: ...

  2. ATF:Gicv源码文件系列-gicv2.h

    /* Copyright © 2015-2018, ARM Limited and Contributors. All rights reserved. SPDX-License-Identifier ...

  3. ATF:Gicv源码文件系列-gic_common.h

    /* Copyright © 2015-2020, ARM Limited and Contributors. All rights reserved. SPDX-License-Identifier ...

  4. U-Boot 之三 U-Boot 源码文件解析及移植过程详解

      在之前的博文 Linux 之八 完整嵌入式 Linux 环境介绍及搭建说明 中我们说了要一步步搭建整个嵌入式 Linux 运行环境.我所使用的硬件平台及整个要搭建的嵌入式 Linux 环境见博文 ...

  5. Go 学习笔记(2)— 安装目录、工作区、源码文件和标准命令

    GOROOT: Go 语言安装根目录的路径,也就是 GO 语言的安装路径. GOPATH: 若干工作区目录的路径.是我们自己定义的工作空间.在 Go Module 模式之前非常重要,现在基本上用来存放 ...

  6. IntelliJ IDEA for Mac 如何配置项目模块的源代码根目录_源码文件的根目录

    按下组合键 Command + ; 打开[项目结构]配置窗口:然后选择左侧菜单栏的[Modules]:然后在右侧的模块列表中,选择你要配置的模块:接着选择右侧界面中的[Sources]标签. 首先添加 ...

  7. U-Boot 之零 源码文件、启动阶段(TPL、SPL)、FALCON、设备树

      最近,工作重心要从裸机开发转移到嵌入式 Linux 系统开发,在之前的博文 Linux 之八 完整嵌入式 Linux 环境.(交叉)编译工具链.CPU 体系架构.嵌入式系统构建工具 中详细介绍了嵌 ...

  8. ATF:Gicv源码解读系列-gicv2_spis_configure_defaults

    1.gicv2_spis_configure_defaults 用来配置SPI的一些默认的属性,SPI中断 SPI:(shared peripheral interrupt),共享外设中断,该中断来源 ...

  9. C#MUD英雄大作战二、乔峰篇(副源码文件连接)

    目录 开发环境: 编码 源码地址: 开发环境: 系统环境:Win10 开发工具:VS2019 语言:C# 项目:控制台应用(.NET Framework) 编码 英雄类:(更换namespace即可) ...

最新文章

  1. VIDI软件在粗糙金属表面缺陷检测中的应用
  2. Java语言学习概述
  3. CIKM 2021 | 基于异质图学习的搜索广告关键词推荐模型及实践
  4. 专访 YYKit 作者 ibireme: 开源大牛是怎样炼成的
  5. 你真的把数据库事务搞懂了吗,有图有真相,图文并茂!
  6. python 特别慢_Python很慢?不一定哦
  7. Servlet和JSP
  8. vue 中引入使用其他字体
  9. OSS文件存储方案-阿里云
  10. 3、一层、二层、交换机原理、Cisco软件及命令
  11. vim 写入错误,转换失败 (请将 'fenc' 置空以强制执行)
  12. KiCad 5.1.6 泪滴插件安装与使用
  13. SwiftUI TextField 限制只能输入数字
  14. ubuntu ffmpeg 截取视频指定时间范围,坐标范围
  15. JAVA财务保证金管理模块开发-王大师王文峰开发(项目现场驻场开发)
  16. 交换机端口的PVID
  17. iStat Menus 的激活密码
  18. [ pikachu ] 靶场通关之 XSS (二) --- 反射型 XSS 之 get 型
  19. 抖音大火的AI虚拟人,画的猫为啥这么丑?
  20. C++虚继承中的虚基类表

热门文章

  1. 【HTML第二个综合案例】----相亲App注册页面
  2. vs.Net2003无法打开或创建Web应用程序若干解决办法
  3. 软件规模估算常用的5种方法及实用工具。
  4. Leaving fence domain… found dlm lockspace /sys/kernel/dlm/rgmanager
  5. 钽电解电容跟铝电解电容的区别
  6. 2021年中国VR/AR行业市场投融资现状分析:VR/AR技术领域融资实现双增长[图]
  7. 电脑屏幕黑屏的终极解决办法
  8. java面试被虐记录
  9. WINDOWS下输入法中英文切换
  10. python .txt文件转.csv文件-ok