// File: /workspace/github_c_makefile_star2_O2/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 0xda77(%rip), %rsi      # 0x1b004
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd62f
leaq 0xda89(%rip), %rsi      # 0x1b02d
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd684
leaq 0xda79(%rip), %rsi      # 0x1b034
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd690
leaq 0xdaa3(%rip), %rsi      # 0x1b075
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd7b1
leaq 0xdad0(%rip), %rsi      # 0x1b0b9
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd873
leaq 0xdadf(%rip), %rsi      # 0x1b0df
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd8ba
leaq 0xdaf1(%rip), %rsi      # 0x1b108
movq %r14, %rdi
callq 0xd060
testl %eax, %eax
je 0xd937
pushq $-0x1
popq %rax
jmp 0xd9cb
movabsq $0xd5c00008086, %rax    # imm = 0xD5C00008086
movq %rax, 0x18(%rbx)
leaq 0xe4a(%rip), %rax       # 0xe48e
movq %rax, 0x38(%rbx)
leaq 0x1eee(%rip), %rax      # 0xf53d
movq %rax, 0x88(%rbx)
movl $0x1000000, 0xb8(%rbx)  # imm = 0x1000000
cmpl $0x0, 0xbc(%rbx)
je 0xd789
leaq 0xa8f1(%rip), %rax      # 0x17f65
movq %rax, 0x30(%rbx)
leaq 0xadd1(%rip), %rax      # 0x18450
jmp 0xd790
leaq 0xdebc(%rip), %rdi      # 0x1b547
callq 0xd0c0
movabsq $0x57c000008086, %rax   # imm = 0x57C000008086
movq %rax, 0x18(%rbx)
leaq 0x4433(%rip), %rax      # 0x11ad8
movq %rax, 0x38(%rbx)
leaq 0x4f22(%rip), %rax      # 0x125d2
movq %rax, 0x88(%rbx)
movl $0x1000000, 0xb8(%rbx)  # imm = 0x1000000
cmpl $0x0, 0xbc(%rbx)
je 0xd74f
leaq 0xa890(%rip), %rax      # 0x17f65
movq %rax, 0x30(%rbx)
leaq 0x9fe7(%rip), %rax      # 0x176c7
movq %rax, 0x68(%rbx)
leaq 0x3fe3(%rip), %rax      # 0x116ce
movq %rax, 0x70(%rbx)
leaq 0xa06b(%rip), %rax      # 0x17761
movq %rax, 0x40(%rbx)
leaq 0xa53e(%rip), %rax      # 0x17c3f
movq %rax, 0x48(%rbx)
leaq 0x4110(%rip), %rax      # 0x1181c
movq %rax, 0x50(%rbx)
leaq 0x42a6(%rip), %rax      # 0x119bd
movq %rax, 0x58(%rbx)
leaq 0x372a(%rip), %rax      # 0x10e4c
movq %rax, 0x60(%rbx)
movl $0x1, 0xc8(%rbx)
movq $0x1, 0x4f0(%rbx)
movq $0x1000, 0xa0(%rbx) # imm = 0x1000
leaq 0xad03(%rip), %rax      # 0x18450
jmp 0xd756
leaq 0x289(%rip), %rax       # 0xd9df
movq %rax, 0x78(%rbx)
cmpq $0x0, 0x8(%rbx)
jne 0xd76c
leaq 0xd8d1(%rip), %rax      # 0x1b039
movq %rax, 0x8(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x10(%rbx)
jne 0xd9cb
leaq 0xd8ce(%rip), %rcx      # 0x1b04e
movq %rcx, 0x10(%rbx)
jmp 0xd9cb
leaq 0x24f(%rip), %rax       # 0xd9df
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
jne 0xd9cb
leaq 0xd863(%rip), %rcx      # 0x1b00b
movq %rcx, 0x8(%rbx)
jmp 0xd9cb
movabsq $0x57c200008086, %rax   # imm = 0x57C200008086
movq %rax, 0x18(%rbx)
leaq 0x7405(%rip), %rax      # 0x14bcb
movq %rax, 0x38(%rbx)
leaq 0x8267(%rip), %rax      # 0x15a38
movq %rax, 0x88(%rbx)
movl $0x1000000, 0xb8(%rbx)  # imm = 0x1000000
cmpl $0x0, 0xbc(%rbx)
je 0xd901
leaq 0xa76f(%rip), %rax      # 0x17f65
movq %rax, 0x30(%rbx)
leaq 0x9ec6(%rip), %rax      # 0x176c7
movq %rax, 0x68(%rbx)
leaq 0x6efd(%rip), %rax      # 0x14709
movq %rax, 0x70(%rbx)
leaq 0x9f4a(%rip), %rax      # 0x17761
movq %rax, 0x40(%rbx)
leaq 0xa41d(%rip), %rax      # 0x17c3f
movq %rax, 0x48(%rbx)
leaq 0x7076(%rip), %rax      # 0x148a3
movq %rax, 0x50(%rbx)
leaq 0x729f(%rip), %rax      # 0x14ad7
movq %rax, 0x58(%rbx)
leaq 0x5fd5(%rip), %rax      # 0x13818
movq %rax, 0x60(%rbx)
movl $0x1, 0xc8(%rbx)
movq $0x1, 0x4f0(%rbx)
movq $0x1000, 0xa0(%rbx) # imm = 0x1000
leaq 0xabe2(%rip), %rax      # 0x18450
jmp 0xd908
movabsq $0x505200001172, %rax   # imm = 0x505200001172
movq %rax, 0x18(%rbx)
leaq 0x28f0(%rip), %rax      # 0x10178
movq %rax, 0x38(%rbx)
movl $0x1000, 0xb8(%rbx)     # imm = 0x1000
cmpl $0x0, 0xbc(%rbx)
je 0xd977
leaq 0xa6bb(%rip), %rax      # 0x17f65
movq %rax, 0x30(%rbx)
leaq 0xab9b(%rip), %rax      # 0x18450
jmp 0xd97e
movabsq $0xd8f00008086, %rax    # imm = 0xD8F00008086
movq %rax, 0x18(%rbx)
leaq 0x2f6d(%rip), %rax      # 0x1083c
movq %rax, 0x38(%rbx)
movl $0x1000, 0xb8(%rbx)     # imm = 0x1000
cmpl $0x0, 0xbc(%rbx)
je 0xd997
leaq 0xa674(%rip), %rax      # 0x17f65
movq %rax, 0x30(%rbx)
leaq 0xab54(%rip), %rax      # 0x18450
jmp 0xd99e
leaq 0xd7(%rip), %rax        # 0xd9df
movq %rax, 0x78(%rbx)
cmpq $0x0, 0x8(%rbx)
jne 0xd91e
leaq 0xd760(%rip), %rax      # 0x1b07a
movq %rax, 0x8(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x10(%rbx)
jne 0xd9cb
leaq 0xd760(%rip), %rcx      # 0x1b092
jmp 0xd780
movabsq $0x579900008086, %rax   # imm = 0x579900008086
movq %rax, 0x18(%rbx)
leaq 0x96d0(%rip), %rax      # 0x1701c
movq %rax, 0x38(%rbx)
movl $0x1000, 0xb8(%rbx)     # imm = 0x1000
cmpl $0x0, 0xbc(%rbx)
je 0xd9b7
leaq 0xa5fb(%rip), %rax      # 0x17f65
movq %rax, 0x30(%rbx)
leaq 0xaadb(%rip), %rax      # 0x18450
jmp 0xd9be
leaq 0x61(%rip), %rax        # 0xd9df
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
jne 0xd9cb
leaq 0xd730(%rip), %rcx      # 0x1b0c2
jmp 0xd7a8
leaq 0x41(%rip), %rax        # 0xd9df
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
jne 0xd9cb
leaq 0xd737(%rip), %rcx      # 0x1b0e9
jmp 0xd7a8
leaq 0x21(%rip), %rax        # 0xd9df
movq %rax, 0x78(%rbx)
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
je 0xd9d3
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd735(%rip), %rcx      # 0x1b10f
jmp 0xd7a8