// File: /workspace/github_c_makefile_star2_O3/intel[P]pf-bb-config/config_app.c
// Function: set_device
int set_device(hw_device *device)
{
	if (strcasecmp(device->device_name, "acc100") == 0) {
		device->vendor_id = ACC100_VENDOR_ID;
		device->device_id = ACC100_DEVICE_ID;
		device->ops.conf  = acc100_configure;
		device->ops.device_data  = acc100_device_data;
		device->bar_size = 0x1000000;

		if (device->vfio_mode) {
			device->ops.open = vfio_device_open;
			device->ops.get_bar0_addr = vfio_get_bar0_mapping;
		} else {
			device->ops.get_bar0_addr = uio_get_bar0_mapping;
		}

		if (device->config_file == NULL) {
			device->config_file =
					"acc100/acc100_config_2vf_4g5g.cfg";
		}
		return 0;
	}

	if ((strcasecmp(device->device_name, "acc200") == 0) ||
			(strcasecmp(device->device_name, "vrb1") == 0)) {
		if (strcasecmp(device->device_name, "acc200") == 0)
			printf("Warning: ACC200 was renamed as VRB1, please use VRB1 instead.\n");
		device->vendor_id = VRB1_VENDOR_ID;
		device->device_id = VRB1_DEVICE_ID;
		device->ops.conf = vrb1_configure;
		device->ops.device_data  = vrb1_device_data;
		device->bar_size = 0x1000000;
		if (device->vfio_mode) {
			device->ops.open = vfio_device_open;
			device->ops.flr = vfio_device_reset;
			device->ops.cluster_reset = vrb1_cluster_reset;
			device->ops.enable_intr = vfio_enable_intr;
			device->ops.disable_intr = vfio_disable_intr;
			device->ops.dev_enable_intr = vrb1_enable_intr;
			device->ops.dev_disable_intr = vrb1_disable_intr;
			device->ops.get_bar0_addr = vfio_get_bar0_mapping;
			device->ops.dev_isr = vrb1_irq_handler;
			device->vfio_int_mode = VFIO_PCI_MSI_IRQ_INDEX;
			device->auto_reconfig_on_fatal_error = DEVICE_RESET_AUTO_RECONFIG;
			device->device_reset_using_flr = DEVICE_RESET_USING_CLUSTER;
			device->info_ring_total_size = BB_ACC_INFO_RING_SIZE;
		} else {
			device->ops.get_bar0_addr = uio_get_bar0_mapping;
		}
		if (device->config_file == NULL)
			device->config_file = "vrb1/vrb1_config.cfg";
		if (device->fft_lut_filename == NULL)
			device->fft_lut_filename = "./vrb1/srs_fft_windows_coefficient.bin";
		return 0;
	}

	if (strcasecmp(device->device_name, "vrb2") == 0) {
		device->vendor_id = VRB2_VENDOR_ID;
		device->device_id = VRB2_DEVICE_ID;
		device->ops.conf = vrb2_configure;
		device->ops.device_data  = vrb2_device_data;
		device->bar_size = 0x1000000;

		if (device->vfio_mode) {
			device->ops.open = vfio_device_open;
			device->ops.flr = vfio_device_reset;
			device->ops.cluster_reset = vrb2_cluster_reset;
			device->ops.enable_intr = vfio_enable_intr;
			device->ops.disable_intr = vfio_disable_intr;
			device->ops.dev_enable_intr = vrb2_enable_intr;
			device->ops.dev_disable_intr = vrb2_disable_intr;
			device->ops.get_bar0_addr = vfio_get_bar0_mapping;
			device->ops.dev_isr = vrb2_irq_handler;
			device->vfio_int_mode = VFIO_PCI_MSI_IRQ_INDEX;
			device->auto_reconfig_on_fatal_error = DEVICE_RESET_AUTO_RECONFIG;
			device->device_reset_using_flr = DEVICE_RESET_USING_CLUSTER;
			device->info_ring_total_size = BB_ACC_INFO_RING_SIZE;
		} else {
			device->ops.get_bar0_addr = uio_get_bar0_mapping;
		}

		if (device->config_file == NULL)
			device->config_file = "vrb2/vrb2_config_vf.cfg";
		if (device->fft_lut_filename == NULL)
			device->fft_lut_filename = "./vrb2/srs_fft_windows_coefficient.bin";
		return 0;
	}

	if (strcasecmp(device->device_name, "fpga_lte") == 0) {
		device->vendor_id = FPGA_LTE_FEC_VENDOR_ID;
		device->device_id = FPGA_LTE_FEC_DEVICE_ID;
		device->ops.conf = fpga_lte_configure;
		device->bar_size = 0x1000;

		if (device->vfio_mode) {
			device->ops.open = vfio_device_open;
			device->ops.get_bar0_addr = vfio_get_bar0_mapping;
		} else {
			device->ops.get_bar0_addr = uio_get_bar0_mapping;
		}

		if (device->config_file == NULL) {
			device->config_file = "fpga_lte/fpga_lte_config.cfg";
		}
		return 0;
	}

	if (strcasecmp(device->device_name, "fpga_5gnr") == 0) {
		device->vendor_id = FPGA_5GNR_FEC_VENDOR_ID;
		device->device_id = FPGA_5GNR_FEC_DEVICE_ID;
		device->ops.conf = fpga_5gnr_configure;
		device->bar_size = 0x1000;

		if (device->vfio_mode) {
			device->ops.open = vfio_device_open;
			device->ops.get_bar0_addr = vfio_get_bar0_mapping;
		} else {
			device->ops.get_bar0_addr = uio_get_bar0_mapping;
		}

		if (device->config_file == NULL) {
			device->config_file =
					"fpga_5gnr/fpga_5gnr_config.cfg";
		}
		return 0;
	}

	if (strcasecmp(device->device_name, "agx100") == 0) {
		device->vendor_id = AGX100_VENDOR_ID;
		device->device_id = AGX100_DEVICE_ID;
		device->ops.conf = agx100_configure;
		device->bar_size = 0x1000;

		if (device->vfio_mode) {
			device->ops.open = vfio_device_open;
			device->ops.get_bar0_addr = vfio_get_bar0_mapping;
		} else {
			device->ops.get_bar0_addr = uio_get_bar0_mapping;
		}

		if (device->config_file == NULL) {
			device->config_file =
					"agx100/agx100_config_1vf.cfg";
		}
		return 0;
	}
	return -1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
leaq 0xda87(%rip), %rsi      # 0x1b004
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd665
leaq 0xda99(%rip), %rsi      # 0x1b02d
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd6ba
leaq 0xda89(%rip), %rsi      # 0x1b034
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd6c6
leaq 0xdab3(%rip), %rsi      # 0x1b075
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd7e7
leaq 0xdae0(%rip), %rsi      # 0x1b0b9
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd8a9
leaq 0xdaef(%rip), %rsi      # 0x1b0df
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd8ed
leaq 0xdb01(%rip), %rsi      # 0x1b108
movq %r14, %rdi
callq 0xd060
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0xd9b3
movabsq $0x579900008086, %rax   # imm = 0x579900008086
movq %rax, 0x18(%rbx)
leaq 0x9e2d(%rip), %rax      # 0x17460
movq %rax, 0x38(%rbx)
movl $0x1000, 0xb8(%rbx)     # imm = 0x1000
cmpl $0x0, 0xbc(%rbx)
je 0xd99f
leaq 0xadce(%rip), %rax      # 0x18423
movq %rax, 0x30(%rbx)
leaq 0xb2c6(%rip), %rax      # 0x18926
jmp 0xd9a6
movabsq $0xd5c00008086, %rax    # imm = 0xD5C00008086
movq %rax, 0x18(%rbx)
leaq 0xe94(%rip), %rax       # 0xe50e
movq %rax, 0x38(%rbx)
leaq 0x1fbf(%rip), %rax      # 0xf644
movq %rax, 0x88(%rbx)
movl $0x1000000, 0xb8(%rbx)  # imm = 0x1000000
cmpl $0x0, 0xbc(%rbx)
je 0xd7bf
leaq 0xad79(%rip), %rax      # 0x18423
movq %rax, 0x30(%rbx)
leaq 0xb271(%rip), %rax      # 0x18926
jmp 0xd7c6
leaq 0xde86(%rip), %rdi      # 0x1b547
callq 0xd0c0
movabsq $0x57c000008086, %rax   # imm = 0x57C000008086
movq %rax, 0x18(%rbx)
leaq 0x45f0(%rip), %rax      # 0x11ccb
movq %rax, 0x38(%rbx)
leaq 0x511c(%rip), %rax      # 0x12802
movq %rax, 0x88(%rbx)
movl $0x1000000, 0xb8(%rbx)  # imm = 0x1000000
cmpl $0x0, 0xbc(%rbx)
je 0xd785
leaq 0xad18(%rip), %rax      # 0x18423
movq %rax, 0x30(%rbx)
leaq 0xa449(%rip), %rax      # 0x17b5f
movq %rax, 0x68(%rbx)
leaq 0x415f(%rip), %rax      # 0x11880
movq %rax, 0x70(%rbx)
leaq 0xa4cd(%rip), %rax      # 0x17bf9
movq %rax, 0x40(%rbx)
leaq 0xa9b5(%rip), %rax      # 0x180ec
movq %rax, 0x48(%rbx)
leaq 0x42be(%rip), %rax      # 0x11a00
movq %rax, 0x50(%rbx)
leaq 0x4459(%rip), %rax      # 0x11ba6
movq %rax, 0x58(%rbx)
leaq 0x38a0(%rip), %rax      # 0x10ff8
movq %rax, 0x60(%rbx)
movl $0x1, 0xc8(%rbx)
movq $0x1, 0x4f0(%rbx)
movq $0x1000, 0xa0(%rbx) # imm = 0x1000
leaq 0xb1a3(%rip), %rax      # 0x18926
jmp 0xd78c
leaq 0x23b(%rip), %rax       # 0xd9c7
movq %rax, 0x78(%rbx)
cmpq $0x0, 0x8(%rbx)
jne 0xd7a2
leaq 0xd89b(%rip), %rax      # 0x1b039
movq %rax, 0x8(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x10(%rbx)
jne 0xd9b3
leaq 0xd898(%rip), %rcx      # 0x1b04e
movq %rcx, 0x10(%rbx)
jmp 0xd9b3
leaq 0x201(%rip), %rax       # 0xd9c7
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
jne 0xd9b3
leaq 0xd82d(%rip), %rcx      # 0x1b00b
movq %rcx, 0x8(%rbx)
jmp 0xd9b3
movabsq $0x57c200008086, %rax   # imm = 0x57C200008086
movq %rax, 0x18(%rbx)
leaq 0x772e(%rip), %rax      # 0x14f2a
movq %rax, 0x38(%rbx)
leaq 0x8824(%rip), %rax      # 0x1602b
movq %rax, 0x88(%rbx)
movl $0x1000000, 0xb8(%rbx)  # imm = 0x1000000
cmpl $0x0, 0xbc(%rbx)
je 0xd92d
leaq 0xabf7(%rip), %rax      # 0x18423
movq %rax, 0x30(%rbx)
leaq 0xa328(%rip), %rax      # 0x17b5f
movq %rax, 0x68(%rbx)
leaq 0x7201(%rip), %rax      # 0x14a43
movq %rax, 0x70(%rbx)
leaq 0xa3ac(%rip), %rax      # 0x17bf9
movq %rax, 0x40(%rbx)
leaq 0xa894(%rip), %rax      # 0x180ec
movq %rax, 0x48(%rbx)
leaq 0x7390(%rip), %rax      # 0x14bf3
movq %rax, 0x50(%rbx)
leaq 0x75c7(%rip), %rax      # 0x14e35
movq %rax, 0x58(%rbx)
leaq 0x6217(%rip), %rax      # 0x13a90
movq %rax, 0x60(%rbx)
movl $0x1, 0xc8(%rbx)
movq $0x1, 0x4f0(%rbx)
movq $0x1000, 0xa0(%rbx) # imm = 0x1000
leaq 0xb082(%rip), %rax      # 0x18926
jmp 0xd934
movabsq $0x505200001172, %rax   # imm = 0x505200001172
movq %rax, 0x18(%rbx)
leaq 0x29ee(%rip), %rax      # 0x102ac
movq %rax, 0x38(%rbx)
movl $0x1000, 0xb8(%rbx)     # imm = 0x1000
cmpl $0x0, 0xbc(%rbx)
je 0xd95f
leaq 0xab43(%rip), %rax      # 0x18423
movq %rax, 0x30(%rbx)
leaq 0xb03b(%rip), %rax      # 0x18926
jmp 0xd966
movabsq $0xd8f00008086, %rax    # imm = 0xD8F00008086
movq %rax, 0x18(%rbx)
leaq 0x30aa(%rip), %rax      # 0x109ac
movq %rax, 0x38(%rbx)
movl $0x1000, 0xb8(%rbx)     # imm = 0x1000
cmpl $0x0, 0xbc(%rbx)
je 0xd97f
leaq 0xab03(%rip), %rax      # 0x18423
movq %rax, 0x30(%rbx)
leaq 0xaffb(%rip), %rax      # 0x18926
jmp 0xd986
leaq 0x93(%rip), %rax        # 0xd9c7
movq %rax, 0x78(%rbx)
cmpq $0x0, 0x8(%rbx)
jne 0xd94a
leaq 0xd734(%rip), %rax      # 0x1b07a
movq %rax, 0x8(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x10(%rbx)
jne 0xd9b3
leaq 0xd738(%rip), %rcx      # 0x1b092
jmp 0xd7b6
leaq 0x61(%rip), %rax        # 0xd9c7
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
jne 0xd9b3
leaq 0xd748(%rip), %rcx      # 0x1b0c2
jmp 0xd7de
leaq 0x41(%rip), %rax        # 0xd9c7
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
jne 0xd9b3
leaq 0xd74f(%rip), %rcx      # 0x1b0e9
jmp 0xd7de
leaq 0x21(%rip), %rax        # 0xd9c7
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
je 0xd9bb
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd74d(%rip), %rcx      # 0x1b10f
jmp 0xd7de