// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
callq 0x18754
leaq 0x1d754(%rip), %r12     # 0x34ed0
movq 0x18(%r12), %r8
leaq 0x62f5(%rip), %rdx      # 0x1da7d
leaq 0x6312(%rip), %r9       # 0x1daa1
xorl %ebp, %ebp
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
cmpl $0x0, 0xbc(%rbx)
je 0x17839
cmpl $0x1, 0xc8(%rbx)
jne 0x177e9
movq %rbx, %rdi
callq 0x179e2
testl %eax, %eax
je 0x17848
callq 0x18754
movq (%r12), %r8
leaq 0x62dc(%rip), %rdx      # 0x1dab2
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
pushq $-0x1
popq %rbp
jmp 0x17839
callq 0x18754
movq 0x10(%r12), %r8
movl 0xc8(%rbx), %r9d
leaq 0x6322(%rip), %rdx      # 0x1db23
pushq $0x2
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
callq 0x18754
movq 0x18(%r12), %r8
leaq 0x3d03(%rip), %rdx      # 0x1b524
leaq 0x6279(%rip), %r9       # 0x1daa1
xorl %ebp, %ebp
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
movl %ebp, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x18754
movq 0x18(%r12), %r8
leaq 0x6793(%rip), %rdx      # 0x1dfec
leaq 0x67b4(%rip), %r9       # 0x1e014
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
cmpl $0x0, 0xc4(%rbx)
jle 0x178ca
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x178b0
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
je 0x178b0
callq 0x18754
movq (%r12), %r8
movq (%rbx), %r9
leaq 0x625d(%rip), %rdx      # 0x1dafa
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
jmp 0x177e4
movl 0xc4(%rbx), %edi
leaq 0x283(%rip), %rsi       # 0x17b40
movq %rbx, %rdx
callq 0x18cd8
jmp 0x17810
xorl %edi, %edi
movl $0x80000, %esi          # imm = 0x80000
callq 0xd400
movl %eax, %ebp
movl %eax, 0xc4(%rbx)
callq 0x18754
testl %ebp, %ebp
js 0x1798d
movq 0x18(%r12), %r8
movl 0xc4(%rbx), %ecx
movl %ecx, (%rsp)
leaq 0x6754(%rip), %rdx      # 0x1e054
leaq 0x670d(%rip), %r9       # 0x1e014
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
movaps 0x60a3(%rip), %xmm0     # 0x1d9c0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movl $0x1, 0x10(%rdx)
movl 0xc4(%rbx), %eax
movl %eax, 0x14(%rdx)
movl 0xc0(%rbx), %edi
movl $0x3b6e, %esi           # imm = 0x3B6E
xorl %eax, %eax
callq 0xd1a0
movl %eax, %ebp
callq 0x18754
movq %rax, %r14
testl %ebp, %ebp
je 0x179bb
movq (%r12), %r15
callq 0xd070
movl (%rax), %r9d
leaq 0x670a(%rip), %rdx      # 0x1e072
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x19400
movl 0xc4(%rbx), %edi
callq 0xd1b0
andl $0x0, 0xc4(%rbx)
jmp 0x179a6
movq (%r12), %r8
leaq 0x668c(%rip), %rdx      # 0x1e024
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x19400
callq 0x18754
movq (%r12), %r8
leaq 0x6121(%rip), %rdx      # 0x1dad7
jmp 0x177d6
movq 0x18(%r12), %r8
leaq 0x66d6(%rip), %rdx      # 0x1e09d
leaq 0x6646(%rip), %r9       # 0x1e014
pushq $0x3
popq %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %eax, %eax
callq 0x19400
jmp 0x17878