Linux系统驱动之异常向量表的安装与调用
2023-04-18 14:41:14 时间
资料下载
coding无法使用浏览器打开,必须用git工具下载:
git clone https://e.coding.net/weidongshan/linux/doc_and_source_for_drivers.git
视频观看
异常向量表的安装与调用
1. 回顾中断的发生、处理过程
- 中断发生的硬件过程
- 中断处理的软件处理流程
- CPU执行完当前指令,检查到发生了中断,跳到向量表
- 保存现场、执行GIC提供的处理函数、恢复现场
2. 异常向量表的安装
2.1 复制向量表
- 汇编代码
// archarmkernelhead.S
1. bl __lookup_processor_type
......
2. bl __create_page_tables
3. ldr r13, =__mmap_switched
4. b __enable_mmu
b __turn_mmu_on
mov r3, r13
ret r3
5. __mmap_switched: // archarmkernelhead-common.S
6. b start_kernel
- 复制向量表
start_kernel // initmain.c
setup_arch(&command_line); // archarmkernelsetup.c
paging_init(mdesc); // archarmmmmmu.c
devicemaps_init(mdesc); // archarmmmmmu.c
vectors = early_alloc(PAGE_SIZE * 2); // 1.分配新向量表
early_trap_init(vectors); // 2.从代码把向量表复制到新向量表
// 3. 映射新向量表到虚拟地址0xffff0000
/*
* Create a mapping for the machine vectors at the high-vectors
* location (0xffff0000). If we aren't using high-vectors, also
* create a mapping at the low-vectors virtual address.
*/
map.pfn = __phys_to_pfn(virt_to_phys(vectors));
map.virtual = 0xffff0000;
map.length = PAGE_SIZE;
#ifdef CONFIG_KUSER_HELPERS
map.type = MT_HIGH_VECTORS;
#else
map.type = MT_LOW_VECTORS;
#endif
create_mapping(&map);
2.2 向量表在哪
上面代码中可以看到代码中向量表位于__vectors_start
,它在arch/arm/kernel/vmlinux.lds
中定义:
__vectors_start = .;
.vectors 0xffff0000 : AT(__vectors_start) {
*(.vectors)
}
. = __vectors_start + SIZEOF(.vectors);
__vectors_end = .;
__stubs_start = .;
.stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
*(.stubs)
}
在代码里搜.vectors
,可以找到向量表:
3. 中断向量
发生中断时,CPU跳到向量表去执行b vector_irq
。
vector_irq函数使用宏来定义:
4. 处理流程
5. 处理函数
相关文章
- 【TFS-CLUB社区 第4期赠书活动】〖Flask Web全栈开发实战〗等你来拿,参与评论,即可有机获得
- bug处理记录:com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value at [Source:
- 自从用了 OkHttp,别的都完全不想用了!
- Web实训项目--网页设计(附源码)
- 每日算法之二叉搜索树的后序遍历序列
- 【第二趴】uni-app开发工具(手把手带你安装HBuilderX、搭建第一个多端项目初体验)
- Http、Https简介和Session、token的请求流程
- 【前端开发环境安装、配置、项目搭建全教程】
- 前端知识——css之flex布局
- 两种方案解决ERROR in Conflict: Multiple assets emit different content to the same filename index.html 的问题
- 每日算法之栈的压入、弹出序列
- Mybatis 入门实战(4)--Mybatis-Plus 使用
- VUE3&TS: Vue3+TS的项目搭建
- Vmware Workstation17 安装centos7(详细教程)
- SpringCloud Alibaba(七) - JWT(JSON Web Token)
- vue3 antd项目实战——table表格的自定义筛选【纯前端filters过滤、自定义筛选table表格数据】
- 每日算法之树的子结构
- React脚手架工具创建项目的详细介绍
- 每日算法之链表中环的入口结点
- 从零入门开源框架---若依(前后端分离版)