// File: /workspace/github_c_makefile_star2_O0/intel[P]pf-bb-config/vrb1/vrb1_cfg_app.c
// Function: vrb1_device_error
static bool
vrb1_device_error(void *dev, int int_src)
{
	uint32_t err_status;
	uint16_t i;
	hw_device *accel_dev = (hw_device *)dev;
	uint8_t *bar0addr = accel_dev->bar0Addr;
	bool fatal_error = false;

	err_status = vrb1_reg_read(bar0addr, HWPfHiErrStatusReg);
	for (i = 0; i < 32; i++) {
		if (((err_status >> i) & 0x1) == 0x1) {
			if (histatus[i].fatal)
				fatal_error = true;
			LOG(ERR, "HI Device Error: %d %s", i, histatus[i].name);
		}
	}

	err_status = vrb1_reg_read(bar0addr, HWPfDmaAxiStatus);
	if ((err_status & 0x1) == 0x1) {
		fatal_error = true;
		LOG(ERR, "Stop AXI asserted");
	}
	err_status = vrb1_reg_read(bar0addr, HWPfHiIosf2axiErrLogReg);
	for (i = 0; i < 32; i++)
		if (((err_status >> i) & 0x1) == 0x1)
			LOG(ERR, "Ext Device Error: %d %s", i, extError[i].name);

	/* Clear error injection */
	if (fatal_error) {
		vrb1_reg_fast_write(bar0addr, HWPfHiErrInjectReg, 0);
		vrb1_reg_fast_write(bar0addr, HWPfAramControlStatus, VRB1_ARAM_CONTROL);
		vrb1_reg_fast_write(bar0addr, HWPfDmaCmplTmOutCnt, 0xFFFFFFFF);
		vrb1_reg_fast_write(bar0addr, HWPfDmaProcTmOutCnt, VRB1_PROC_TIMEOUT);
		vrb1_reg_fast_write(bar0addr, HWPfQmgrAramWatchdogCount, 0xFFFFFFFF);
		vrb1_reg_fast_write(bar0addr, HWPfQmgrAxiWatchdogCount, 0xFFFFFFFF);
		vrb1_reg_fast_write(bar0addr, HWPfQmgrProcessWatchdogCount, 0xFFFFFFFF);
	}
	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 */
			vrb1_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_cluster_reset_and_flr_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");
			}
		}
	}
	return fatal_error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movq -0x28(%rbp), %rdi
movl $0xc84208, %esi         # imm = 0xC84208
callq 0x13540
movl %eax, -0x10(%rbp)
movw $0x0, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
cmpl $0x20, %eax
jge 0x138f4
movl -0x10(%rbp), %eax
movzwl -0x12(%rbp), %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x1, %eax
jne 0x138e1
movzwl -0x12(%rbp), %eax
movl %eax, %ecx
leaq 0x271c4(%rip), %rax     # 0x3aa50
shlq $0x4, %rcx
addq %rcx, %rax
testb $0x1, 0x9(%rax)
je 0x1389d
movb $0x1, -0x29(%rbp)
callq 0x16250
movq %rax, %rcx
leaq 0x28024(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movzwl -0x12(%rbp), %r9d
movzwl -0x12(%rbp), %eax
movl %eax, %edx
leaq 0x2718f(%rip), %rax     # 0x3aa50
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rax), %rax
xorl %esi, %esi
leaq 0x10bf5(%rip), %rdx     # 0x244c9
movl %esi, %edi
movq %rax, (%rsp)
movb $0x0, %al
callq 0x216e0
jmp 0x138e3
movw -0x12(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0x13861
movq -0x28(%rbp), %rdi
movl $0xb80028, %esi         # imm = 0xB80028
callq 0x13540
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0x1, %eax
cmpl $0x1, %eax
jne 0x13938
movb $0x1, -0x29(%rbp)
callq 0x16250
movq %rax, %rcx
leaq 0x27fad(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x10bb8(%rip), %rdx     # 0x244e7
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0x28(%rbp), %rdi
movl $0xc84004, %esi         # imm = 0xC84004
callq 0x13540
movl %eax, -0x10(%rbp)
movw $0x0, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
cmpl $0x20, %eax
jge 0x139bd
movl -0x10(%rbp), %eax
movzwl -0x12(%rbp), %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x1, %eax
jne 0x139ad
callq 0x16250
movq %rax, %rcx
leaq 0x27f58(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movzwl -0x12(%rbp), %r9d
movzwl -0x12(%rbp), %eax
movl %eax, %edx
leaq 0x272c3(%rip), %rax     # 0x3ac50
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rax), %rax
xorl %esi, %esi
leaq 0x10b60(%rip), %rdx     # 0x24500
movl %esi, %edi
movq %rax, (%rsp)
movb $0x0, %al
callq 0x216e0
jmp 0x139af
movw -0x12(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x12(%rbp)
jmp 0x1394f
testb $0x1, -0x29(%rbp)
je 0x13a49
movq -0x28(%rbp), %rdi
movl $0xc84204, %esi         # imm = 0xC84204
xorl %edx, %edx
callq 0x14210
movq -0x28(%rbp), %rdi
movl $0x810000, %esi         # imm = 0x810000
movl $0x30, %edx
callq 0x14210
movq -0x28(%rbp), %rdi
movl $0xb80800, %esi         # imm = 0xB80800
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x14210
movq -0x28(%rbp), %rdi
movl $0xb80804, %esi         # imm = 0xB80804
movl $0x2000, %edx           # imm = 0x2000
callq 0x14210
movq -0x28(%rbp), %rdi
movl $0xa00040, %esi         # imm = 0xA00040
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x14210
movq -0x28(%rbp), %rdi
movl $0xa00048, %esi         # imm = 0xA00048
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x14210
movq -0x28(%rbp), %rdi
movl $0xa00050, %esi         # imm = 0xA00050
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x14210
testb $0x1, -0x29(%rbp)
je 0x13b84
movq -0x20(%rbp), %rax
cmpq $0x5, 0xf0(%rax)
je 0x13b84
callq 0x16250
movq %rax, %rcx
leaq 0x27e5c(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x10a9f(%rip), %rdx     # 0x2451f
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0x20(%rbp), %rdi
movl $0x5, %esi
callq 0x21ff0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x4f0(%rax)
je 0x13b82
movq -0x28(%rbp), %rdi
movl $0xc84004, %esi         # imm = 0xC84004
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x14210
movq -0x20(%rbp), %rax
cmpl $0x1, 0x4f4(%rax)
jne 0x13b24
callq 0x16250
movq %rax, %rcx
leaq 0x27df9(%rip), %rax     # 0x3b8d0
movq 0x10(%rax), %r8
movl $0x2, %edi
xorl %esi, %esi
leaq 0x10a49(%rip), %rdx     # 0x24532
movb $0x0, %al
callq 0x216e0
movq -0x20(%rbp), %rdi
callq 0x21e70
cmpl $0x0, %eax
je 0x13b22
callq 0x16250
movq %rax, %rcx
leaq 0x27dc3(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x10a31(%rip), %rdx     # 0x2454a
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
jmp 0x13b80
callq 0x16250
movq %rax, %rcx
leaq 0x27d9d(%rip), %rax     # 0x3b8d0
movq 0x10(%rax), %r8
movl $0x2, %edi
xorl %esi, %esi
leaq 0x10a24(%rip), %rdx     # 0x24569
movb $0x0, %al
callq 0x216e0
movq -0x20(%rbp), %rdi
callq 0x21d30
cmpl $0x0, %eax
je 0x13b7e
callq 0x16250
movq %rax, %rcx
leaq 0x27d67(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x10a16(%rip), %rdx     # 0x2458b
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
jmp 0x13b80
jmp 0x13b82
jmp 0x13b84
movb -0x29(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nop