// File: /workspace/github_c_makefile_star2_O1/intel[P]pf-bb-config/vrb2/vrb2_cfg_app.c
// Function: vrb2_device_error
static bool
vrb2_device_error(void *dev, int int_src)
{
	uint16_t eng_type;
	hw_device *accel_dev = (hw_device *)dev;
	uint8_t *bar0addr = accel_dev->bar0Addr;
	bool fatal_error = false, exit_ir = false;

	/* Flag fatal error based on interrupt source */
	if (irdata[int_src].fatal)
		fatal_error = true;
	/* Flag fatal error based on error register */
	if (vrb2_check_error_reg(bar0addr))
		fatal_error = true;

	/* Clear error injection */
	vrb2_reg_write(bar0addr, HWPfHiErrInjectReg, 0);
	vrb2_reg_write(bar0addr, HWPfAramControlStatus, VRB2_ARAM_CONTROL);
	vrb2_reg_write(bar0addr, HWPfDmaCmplTmOutCnt, 0xFFFFFFFF);
	for (eng_type = 0; eng_type < VRB2_ENG_TYPE_NUM; eng_type++)
		vrb2_reg_write(bar0addr, HWPfDmaProcTmOutCnt + eng_type * 4, VRB2_PROC_TIMEOUT);
	vrb2_reg_write(bar0addr, HWPfQmgrAramWatchdogCount, VRB2_QMGR_ARAM_TIMEOUT);
	vrb2_reg_write(bar0addr, HWPfQmgrAxiWatchdogCount, VRB2_QMGR_AXI_TIMEOUT);
	vrb2_reg_write(bar0addr, HWPfQmgrProcessWatchdogCount, VRB2_QMGR_TIMEOUT);
	vrb2_reg_write(bar0addr, HWPfDmaClusterHangThld, VRB2_CLUST_TIMEOUT);
	if (b0_variant)
		vrb2_reg_write(bar0addr, HWPfDmaClusterCtrl, 0x1);

	if (fatal_error && (accel_dev->dev_status[0] != RTE_BBDEV_DEV_FATAL_ERR)) {
		LOG(ERR, "Fatal error");
		/* For these conditions a device fatal error was hit */
		bb_acc_set_all_device_status(accel_dev, RTE_BBDEV_DEV_FATAL_ERR);
		/*
		 * When fatal error is detected, the device may be reset or not according to
		 * the related device attributes.
		 */
		if (accel_dev->auto_reconfig_on_fatal_error) {
			/* Clear back the status register */
			vrb2_reg_fast_write(bar0addr, HWPfHiIosf2axiErrLogReg, 0xFFFFFFFF);
			/* reset and reconfigure the device */
			if (accel_dev->device_reset_using_flr == DEVICE_RESET_USING_FLR) {
				LOG(INFO, "FLR and reconfig");
				if (bb_acc_dev_reset_and_reconfig(accel_dev))
					LOG(ERR, "FLR and reconfig failed");
			} else {
				LOG(INFO, "Cluster reset and reconfig");
				if (bb_acc_cluster_reset_and_reconfig(accel_dev))
					LOG(ERR, "Cluster reset and reconfig failed");
			}
			/* Exit IR since the device was reconfigured. */
			exit_ir = true;
		}
	}

	if (fatal_error && !exit_ir) {
		/* In case of fatal error but not recovered, need to hide this very error
		source so that to prevent flooding the IR with the same cause. */
		vrb2_disable_int_src(bar0addr, int_src);
		if (int_src == VRB2_DMA_CLUSTER_HANG_DETECTED)
			vrb2_disable_int_src(bar0addr, VRB2_CORE_HANG_DETECTED);
	}

	if (!fatal_error)
		LOG(DEBUG, "Non fatal error");

	return exit_ir;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq 0xb0(%rdi), %rdx
movl %esi, 0x14(%rsp)
movl %esi, %eax
shlq $0x4, %rax
leaq 0x1e0be(%rip), %rcx     # 0x327e0
movb 0x9(%rax,%rcx), %al
movb %al, 0x13(%rsp)
movq %rdx, 0x20(%rsp)
movl 0xc84208(%rdx), %r14d
leaq 0x1e2a3(%rip), %r13     # 0x329e0
xorl %ebp, %ebp
movl $0x1, %ebx
leaq 0x7d4b(%rip), %r15      # 0x1c496
xorl %r12d, %r12d
btl %r12d, %r14d
jae 0x1478b
movzbl %bpl, %ebp
cmpb $0x0, 0x9(%r13)
cmovnel %ebx, %ebp
callq 0x16854
leaq 0x1f764(%rip), %rcx     # 0x33ed0
movq (%rcx), %r8
movq (%r13), %rcx
movq %rcx, (%rsp)
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %rax, %rcx
movl %r12d, %r9d
xorl %eax, %eax
callq 0x19ca8
incq %r12
addq $0x10, %r13
cmpq $0x20, %r12
jne 0x1474e
movq 0x20(%rsp), %r13
movl 0xc84004(%r13), %ebx
leaq 0x1e435(%rip), %r14     # 0x32be0
leaq 0x7d1b(%rip), %r15      # 0x1c4cd
xorl %r12d, %r12d
btl %r12d, %ebx
jae 0x147e5
callq 0x16854
leaq 0x1f709(%rip), %rcx     # 0x33ed0
movq (%rcx), %r8
movq (%r14), %rcx
movq %rcx, (%rsp)
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %rax, %rcx
movl %r12d, %r9d
xorl %eax, %eax
callq 0x19ca8
incq %r12
addq $0x10, %r14
cmpq $0x20, %r12
jne 0x147b5
movl $0x40000, 0xc84004(%r13) # imm = 0x40000
movl $0x1, %edi
callq 0xd460
testl $0x1, 0xb80028(%r13)
je 0x1483b
callq 0x16854
leaq 0x1f6b0(%rip), %rcx     # 0x33ed0
movq (%rcx), %r8
leaq 0x7c8a(%rip), %rdx      # 0x1c4b4
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movb $0x1, %bpl
testl $0x1, 0xb80e08(%r13)
movq 0x18(%rsp), %r14
je 0x14874
callq 0x16854
leaq 0x1f677(%rip), %rcx     # 0x33ed0
movq (%rcx), %r8
leaq 0x8964(%rip), %rdx      # 0x1d1c7
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movb $0x1, %bpl
movl $0x0, 0xc84204(%r13)
movl $0x1, %edi
callq 0xd460
movl $0x30, 0x810000(%r13)
movl $0x1, %edi
callq 0xd460
movl $0xffffffff, 0xb80800(%r13) # imm = 0xFFFFFFFF
movl $0x1, %edi
callq 0xd460
movl $0x2e03c0, %ebx         # imm = 0x2E03C0
movl $0x200000, (%r13,%rbx,4) # imm = 0x200000
movl $0x1, %edi
callq 0xd460
incq %rbx
cmpq $0x2e03c6, %rbx         # imm = 0x2E03C6
jne 0x148b8
orb 0x13(%rsp), %bpl
movl $0x800, %ebx            # imm = 0x800
movl %ebx, 0xa00040(%r13)
movl $0x1, %edi
callq 0xd460
movl %ebx, 0xa00048(%r13)
movl $0x1, %edi
callq 0xd460
movl $0x10000000, 0xa00050(%r13) # imm = 0x10000000
movl $0x1, %edi
callq 0xd460
movl $0x100000, 0xb80e04(%r13) # imm = 0x100000
movl $0x1, %edi
callq 0xd460
cmpb $0x1, 0x25ffd(%rip)     # 0x3a931
jne 0x1494b
movl $0x1, 0xb80e00(%r13)
movl $0x1, %edi
callq 0xd460
testb $0x1, %bpl
je 0x1495b
cmpq $0x5, 0xf0(%r14)
jne 0x149d2
xorl %r15d, %r15d
testb %r15b, %r15b
jne 0x1498b
movl %ebp, %eax
xorb $0x1, %al
testb $0x1, %al
jne 0x1498b
movq %r13, %rdi
movl 0x14(%rsp), %ebx
movl %ebx, %esi
callq 0x1689e
cmpl $0x1b, %ebx
jne 0x1498b
movq %r13, %rdi
movl $0x1a, %esi
callq 0x1689e
testb $0x1, %bpl
jne 0x149c0
callq 0x16854
leaq 0x1f533(%rip), %rcx     # 0x33ed0
movq 0x18(%rcx), %r8
leaq 0x87f0(%rip), %rdx      # 0x1d198
leaq 0x8806(%rip), %r9       # 0x1d1b5
movl $0x3, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x16854
leaq 0x1f4f2(%rip), %rcx     # 0x33ed0
movq (%rcx), %r8
leaq 0x7b04(%rip), %rdx      # 0x1c4ec
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movq %r14, %rdi
movl $0x5, %esi
callq 0x1a35f
cmpl $0x0, 0x4f0(%r14)
je 0x1495e
movl $0xffffffff, 0xc84004(%r13) # imm = 0xFFFFFFFF
movl 0x4f4(%r14), %ebx
callq 0x16854
leaq 0x1f49e(%rip), %rcx     # 0x33ed0
movq 0x10(%rcx), %r8
cmpl $0x1, %ebx
jne 0x14a68
leaq 0x7abd(%rip), %rdx      # 0x1c4ff
movl $0x2, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movq %r14, %rdi
callq 0x19fe3
testl %eax, %eax
je 0x14ab3
leaq 0x7ab1(%rip), %r14      # 0x1c517
jmp 0x14a93
leaq 0x7ac7(%rip), %rdx      # 0x1c536
movl $0x2, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movq %r14, %rdi
callq 0x1a161
testl %eax, %eax
je 0x14ab3
leaq 0x7ac5(%rip), %r14      # 0x1c558
callq 0x16854
leaq 0x1f431(%rip), %rcx     # 0x33ed0
movq (%rcx), %r8
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x19ca8
movb $0x1, %r15b
jmp 0x1495e