【Xilinx】SynchronousInterruptHandler错误排查笔记

一、ArmV8的异常处理

在基于A53的MPSOC系列上,相比zynq系列原有的中断向量处理方式做了大幅度修改

ARMv8-A系列定义了一系列的异常等级,从EL0到EL3。随着n的增加,软件的执行权限也相应的增加;

EL0被称为无特权执行;
EL2提供了对虚拟化的支持
EL3提供了安全状态切换功能(安全状态与非安装状态之间的切换)

注意,EL0和EL1是必须实现的,EL2和EL3是可选的。而且一个PE中实现的EL可以不连续,例如只实现了EL0、EL1和EL3。

在这里插入图片描述

二、64位lscript.ld的修改

左边是32位的lscript.ld,右边是64位的lscript.ld,主要的差异部分如下图
在这里插入图片描述
在这里插入图片描述

三、asm_vectors.S的修改

在项目文件夹下搜索到asm_vectors.S
例如psu_cortexa53_0\standalone_psu_cortexa53_0\bsp\psu_cortexa53_0\libsrc\standalone_v7_3\src\asm_vectors.S,根据项目版本不同,路径可能有差异,仅供参考

可以看到中断向量表,对应表中的4个地址
在这里插入图片描述

EL0的Synchronous offset是0x0。其他EL级别,Synchronous offset是0x200,IRQ or vIRQ offset是0x280, FIQ or vFIQ offset是0x300,SError or vSError offset是0x380,
MPSoC A53启动后,在EL0,执行的第一条代码是“b _boot”。

	b	_boot
.org (VBAR + 0x200)
	b	SynchronousInterruptHandler

.org (VBAR + 0x280)
	b	IRQInterruptHandler

.org (VBAR + 0x300)
	b	FIQInterruptHandler

.org (VBAR + 0x380)
	b	SErrorInterruptHandler

四、SynchronousInterruptHandler函数解析

以下是SynchronousInterruptHandler函数的内容
它会判断ESR_EL3的取bit26-bit31,6个bit,判断是不是000111,如果不是则跳转到死循环

SynchronousInterruptHandler:
	saveregister

/* Check if the Synchronous abort is occurred due to floating point access. */
.if (EL3 == 1)
	mrs	x0, ESR_EL3
.else
	mrs	x0, ESR_EL1
.endif
	and	x0, x0, #(0x3F << 26)
	mov	x1, #(0x7 << 26)
	cmp	x0, x1
/* If exception is not due to floating point access go to synchronous handler */
	bne	synchronoushandler

/*
 * If excpetion occurred due to floating point access, Enable the floating point
 * access i.e. do not trap floating point instruction
 */
 .if (EL3 == 1)
	mrs	x1,CPTR_EL3
	bic	x1, x1, #(0x1<<10)
	msr	CPTR_EL3, x1
.else
	mrs	x1,CPACR_EL1
	orr	x1, x1, #(0x1<<20)
	msr	CPACR_EL1, x1
.endif
	isb

/* If the floating point access was previously enabled, store FPU context
 * registers(storefloat).
 */
	ldr	x0, =FPUStatus
	ldrb	w1,[x0]
	cbnz	w1, storefloat
/*
 * If the floating point access was not enabled previously, save the status of
 * floating point accessibility i.e. enabled and store floating point context
 * array address(FPUContext) to FPUContextBase.
 */
	mov	w1, #0x1
	strb	w1, [x0]
	ldr	x0, =FPUContext
	ldr	x1, =FPUContextBase
	str	x0,[x1]
	b	restorecontext
storefloat:
	savefloatregister
	b	restorecontext
synchronoushandler:
	bl	SynchronousInterrupt
restorecontext:
	restoreregister
	eret

五、ESR_EL3的错误代码解释

EC, bits [31:26]
Exception Class. Indicates the reason for the exception that this register holds information about.

For each EC value, the table references a subsection that gives information about:

The cause of the exception, for example the configuration required to enable the trap.
The encoding of the associated ISS.
Possible values of the EC field are:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 21
    评论
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值