// File: /workspace/github_c_makefile_star2_O0/intel[P]pf-bb-config/bb_acc_vfio.c
// Function: vfio_enable_intr
int vfio_enable_intr(void *dev)
{
	hw_device *hwd = (hw_device *)dev;

	LOG(DEBUG, "VFIO enable interrupts");

	if (!hwd->vfio_mode)
		return 0;

	switch (hwd->vfio_int_mode) {
	case VFIO_PCI_MSI_IRQ_INDEX:
		if (vfio_set_bus_master(hwd)) {
			LOG(ERR, "vfio enable bus master failed");
			return -1;
		}

		if (vfio_enable_msi(hwd)) {
			LOG(ERR, "vfio enable MSI intr failed");
			return -1;
		}

		if ((hwd->ops.dev_enable_intr) && (hwd->ops.dev_enable_intr(hwd))) {
			LOG(ERR, "vfio enable %s device intr failed", hwd->device_name);
			return -1;
		}

		/* register isr callback for intr event */
		event_add_fd(hwd->irq_event_fd, vfio_intr_handler, hwd);
		break;

	case VFIO_PCI_INTX_IRQ_INDEX:
	case VFIO_PCI_MSIX_IRQ_INDEX:
	case VFIO_PCI_ERR_IRQ_INDEX:
	default:
		LOG(INFO, "Not supported irq index (%d)", hwd->vfio_int_mode);
		break;
	}

	LOG(DEBUG, "Done");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
callq 0x20230
movq %rax, %rcx
leaq 0x1cead(%rip), %rax     # 0x3b8d0
movq 0x18(%rax), %r8
movl $0x3, %edi
xorl %esi, %esi
leaq 0x703a(%rip), %rdx      # 0x25a6f
leaq 0x7057(%rip), %r9       # 0x25a93
movb $0x0, %al
callq 0x216e0
movq -0x18(%rbp), %rax
cmpl $0x0, 0xbc(%rax)
jne 0x1ea5c
movl $0x0, -0x4(%rbp)
jmp 0x1ebe9
movq -0x18(%rbp), %rax
movl 0xc8(%rax), %eax
movl %eax, -0x1c(%rbp)
testl %eax, %eax
je 0x1eb7e
jmp 0x1ea73
movl -0x1c(%rbp), %eax
subl $0x1, %eax
je 0x1ea91
jmp 0x1ea7d
movl -0x1c(%rbp), %eax
addl $-0x2, %eax
subl $0x2, %eax
jb 0x1eb7e
jmp 0x1eb80
movq -0x18(%rbp), %rdi
callq 0x1ec00
cmpl $0x0, %eax
je 0x1eacf
callq 0x20230
movq %rax, %rcx
leaq 0x1ce22(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x6fea(%rip), %rdx      # 0x25aa4
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ebe9
movq -0x18(%rbp), %rdi
callq 0x1ee20
cmpl $0x0, %eax
je 0x1eb0d
callq 0x20230
movq %rax, %rcx
leaq 0x1cde4(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
xorl %esi, %esi
leaq 0x6fd1(%rip), %rdx      # 0x25ac9
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ebe9
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x1eb62
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
je 0x1eb62
callq 0x20230
movq %rax, %rcx
leaq 0x1cd96(%rip), %rax     # 0x3b8d0
movq (%rax), %r8
movq -0x18(%rbp), %rax
movq (%rax), %r9
xorl %esi, %esi
leaq 0x6f9f(%rip), %rdx      # 0x25aec
movl %esi, %edi
movb $0x0, %al
callq 0x216e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ebe9
movq -0x18(%rbp), %rax
movl 0xc4(%rax), %edi
movq -0x18(%rbp), %rdx
leaq 0x4b9(%rip), %rsi       # 0x1f030
callq 0x20bc0
jmp 0x1ebb3
jmp 0x1eb80
callq 0x20230
movq %rax, %rcx
leaq 0x1cd41(%rip), %rax     # 0x3b8d0
movq 0x10(%rax), %r8
movq -0x18(%rbp), %rax
movl 0xc8(%rax), %r9d
movl $0x2, %edi
xorl %esi, %esi
leaq 0x6f69(%rip), %rdx      # 0x25b15
movb $0x0, %al
callq 0x216e0
callq 0x20230
movq %rax, %rcx
leaq 0x1cd0e(%rip), %rax     # 0x3b8d0
movq 0x18(%rax), %r8
movl $0x3, %edi
xorl %esi, %esi
leaq 0x4aee(%rip), %rdx      # 0x236c2
leaq 0x6eb8(%rip), %r9       # 0x25a93
movb $0x0, %al
callq 0x216e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)