// File: /workspace/github_c_makefile_star2_O0/intel[P]pf-bb-config/vrb2/vrb2_cfg_app.c
// Function: vrb2_core_hang_recovery
static void
vrb2_core_hang_recovery(void *dev, uint16_t error_type)
{
	hw_device *accel_dev = (hw_device *)dev;
	uint8_t template_index, *bar0addr = accel_dev->bar0Addr;
	uint16_t engine_idx;
	uint32_t status;
	int eng;

	/* Disabling of Error injection done in *vrb2_device_error* */

	status = vrb2_reg_read(bar0addr, HWPfDmaQmanen);
	if (status > 0)
		LOG(ERR, "HWPfDmaQmanen bitmap updated by HW: %X", status);

	for (eng = 0; eng < 32; eng++) {
		status = vrb2_reg_read(bar0addr, HWPfDmaChrStatus + eng * 0x10);
		if (status > 0)
			LOG(ERR, "HWPfDmaChrStatus: engine %d State Machine 0x%x", eng, status);
	}
	status = vrb2_reg_read(bar0addr, HWPfDmaStatusMemParErr);
	if (status > 0)
		LOG(ERR, "HWPfDmaStatusMemParErr: %x", status);
	status = vrb2_reg_read(bar0addr, HWPfDmaStatusToutProcess);
	if (status > 0)
		LOG(ERR, "HWPfDmaStatusToutProcess bitmap: %x", status);
	bb_acc_set_all_device_status(accel_dev, RTE_BBDEV_DEV_CORRECT_ERR);
	if (error_type == VRB2_ERR_TYPE_PROC_TO) {
		LOG(ERR, "Wait for engine recovery to be completed");
	} else {
		engine_idx = error_type - VRB2_ERR_TYPE_OFFSET;
		if ((engine_idx >= VRB2_IDMAP_FFT) && (engine_idx <= VRB2_IDMAP_FFT_LAST)) {
			LOG(ERR, "Reconfigure FFT engine %d.", engine_idx - VRB2_IDMAP_FFT);
			vrb2_fft_reconfig(bar0addr, engine_idx - VRB2_IDMAP_FFT, false, accel_dev);
		}
		if (engine_idx <= VRB2_IDMAP_MLD_LAST) {
			uint8_t mapping[VRB2_IDMAP_MLD_LAST + 1] = {
					4, 6, 7, 9, 11, 13, 24, 26, 27,
					8, 10, 12, 14, 15, 25, 29, 31, 0, 1, 2, 3, 5};
			template_index = mapping[engine_idx];
			/* Clear the time out report for that engine. */
			vrb2_reg_write(bar0addr, HWPfDmaStatusToutProcess, 1 << engine_idx);
			/* Enable back Qmgr for that engine. */
			vrb2_reg_write(bar0addr, HWPfDmaQmanenSelect, 1 << template_index);
			vrb2_reg_write(bar0addr, HWPfDmaQmanen, 0x0);
			LOG(ERR, "Recovery completed for engine %d on template %d",
					engine_idx, template_index);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0xb80040, %esi         # imm = 0xB80040
callq 0x18b70
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jbe 0x19179
callq 0x1bd70
movq %rax, %rcx
leaq 0x22770(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movl -0x30(%rbp), %r9d
xorl %esi, %esi
leaq 0xc43f(%rip), %rdx      # 0x255af
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0x0, -0x34(%rbp)
cmpl $0x20, -0x34(%rbp)
jge 0x191df
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %esi
shll $0x4, %esi
addl $0xb80c0c, %esi         # imm = 0xB80C0C
callq 0x18b70
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jbe 0x191d2
callq 0x1bd70
movq %rax, %rcx
leaq 0x2271d(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movl -0x34(%rbp), %r9d
movl -0x30(%rbp), %eax
xorl %esi, %esi
leaq 0xc417(%rip), %rdx      # 0x255dd
movl %esi, %edi
movl %eax, (%rsp)
movb $0x0, %al
callq 0x216e0
jmp 0x191d4
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x19180
movq -0x28(%rbp), %rdi
movl $0xb80818, %esi         # imm = 0xB80818
callq 0x18b70
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jbe 0x1921e
callq 0x1bd70
movq %rax, %rcx
leaq 0x226cb(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movl -0x30(%rbp), %r9d
xorl %esi, %esi
leaq 0xc3fe(%rip), %rdx      # 0x25613
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0x28(%rbp), %rdi
movl $0xb80890, %esi         # imm = 0xB80890
callq 0x18b70
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jbe 0x1925d
callq 0x1bd70
movq %rax, %rcx
leaq 0x2268c(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movl -0x30(%rbp), %r9d
xorl %esi, %esi
leaq 0xc3e1(%rip), %rdx      # 0x25635
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0x18(%rbp), %rdi
movl $0x8, %esi
callq 0x21ff0
movzwl -0xa(%rbp), %eax
cmpl $0x8, %eax
jne 0x1929d
callq 0x1bd70
movq %rax, %rcx
leaq 0x2264d(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0xc3d1(%rip), %rdx      # 0x25660
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
jmp 0x193b3
movzwl -0xa(%rbp), %eax
subl $0xa, %eax
movw %ax, -0x2a(%rbp)
movzwl -0x2a(%rbp), %eax
cmpl $0x11, %eax
jl 0x192fd
movzwl -0x2a(%rbp), %eax
cmpl $0x13, %eax
jg 0x192fd
callq 0x1bd70
movq %rax, %rcx
leaq 0x22607(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movzwl -0x2a(%rbp), %r9d
subl $0x11, %r9d
xorl %esi, %esi
leaq 0xc3b2(%rip), %rdx      # 0x25690
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movq -0x28(%rbp), %rdi
movzwl -0x2a(%rbp), %esi
subl $0x11, %esi
movq -0x18(%rbp), %rcx
xorl %edx, %edx
callq 0x1c0f0
movzwl -0x2a(%rbp), %eax
cmpl $0x15, %eax
jg 0x193b1
movq 0xb7df(%rip), %rax      # 0x24af0
movq %rax, -0x50(%rbp)
movq 0xb7dc(%rip), %rax      # 0x24af8
movq %rax, -0x48(%rbp)
movl 0xb7da(%rip), %eax      # 0x24b00
movl %eax, -0x40(%rbp)
movw 0xb7d4(%rip), %ax       # 0x24b04
movw %ax, -0x3c(%rbp)
movzwl -0x2a(%rbp), %eax
movb -0x50(%rbp,%rax), %al
movb %al, -0x19(%rbp)
movq -0x28(%rbp), %rdi
movzwl -0x2a(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl $0xb80890, %esi         # imm = 0xB80890
callq 0x197e0
movq -0x28(%rbp), %rdi
movzbl -0x19(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl $0xb80044, %esi         # imm = 0xB80044
callq 0x197e0
movq -0x28(%rbp), %rdi
movl $0xb80040, %esi         # imm = 0xB80040
xorl %edx, %edx
callq 0x197e0
callq 0x1bd70
movq %rax, %rcx
leaq 0x22540(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movzwl -0x2a(%rbp), %r9d
movzbl -0x19(%rbp), %eax
xorl %esi, %esi
leaq 0xc30d(%rip), %rdx      # 0x256b2
movl %esi, %edi
movl %eax, (%rsp)
movb $0x0, %al
callq 0x216e0
jmp 0x193b3
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)