// File: /workspace/github_cpp_makefile_star2_O2/chenhn123[P]wdt_util_src/wdt_ct/wdt_dev_api.cpp
// Function: show_info(WdtDevice*, ExecParam*)
int show_info(WDT_DEV *pdev, EXEC_PARAM *pparam)
{
	BOARD_INFO	*pinfo = &pdev->board_info;	
	int ret = 0;

	if (!pdev || !pparam)
		return 0;

	if (!init_n_scan_device(pdev, pparam, 0))
		return 0;

	ret = !(pinfo->dev_type & (FW_MAYBE_ISP | FW_WDT8760_2_ISP));

	if (!ret)
		goto info_exit;

	if (pparam->argus & OPTION_HW_ID) {
		if (pdev->is_legacy)
			printf("%04x%04x", pinfo->vid, pinfo->pid);
		else {
			// to fix the temporary HWID issue, only happened in early build of Fleex.
			if (pinfo->hardware_id == 0x01027401)
				pinfo->hardware_id = 0x01017402;
			printf("%08x", pinfo->hardware_id);
		}
	}

	if (pparam->argus & OPTION_FW_VER) {
		if (pparam->argus & OPTION_HW_ID)
			printf("_");

		if (pdev->board_info.dev_type & FW_WDT8755) {
			printf("%04x", pinfo->firmware_id & 0xFFFF);
        	} else if (pdev->board_info.dev_type & FW_WDT8760_2) {
        		int fwrev = pinfo->dev_info.w8760_feature_devinfo.firmware_id & 0x0FFF;
        		int fwrexext = pinfo->dev_info.w8760_feature_devinfo.firmware_rev_ext & 0x000F;
        		int versionOuput = (fwrev << 4 | fwrexext);
			printf("%04x", versionOuput);
		}
		else if (pdev->board_info.dev_type & FW_WDT8790) {
			int fwrev = pinfo->dev_info.w8790_feature_devinfo.firmware_version & 0x0FFF;
                        int fwrexext = pinfo->dev_info.w8790_feature_devinfo.firmware_revision_ext & 0x000F;
                        int versionOuput = (fwrev << 4 | fwrexext);
                        printf("%04x", versionOuput);

		}
	}	
		
	if (pparam->argus & OPTION_CFG_CHKSUM) {
		if (pparam->argus & (OPTION_FW_VER | OPTION_HW_ID))
			printf("_");
		
		if (pdev->is_legacy)
			printf("%04x%04x", pinfo->sys_param.xmls_id1, pinfo->sys_param.xmls_id2);
		else 
			printf("%08x", pinfo->serial_no);
	}

	if (pparam->argus & (OPTION_HW_ID | OPTION_FW_VER | OPTION_CFG_CHKSUM)) {
		printf("\n");
		goto info_exit;
	}
	
	if (ret) {
		printf("Vendor_ID: 0x%04x\n", pinfo->vid);
		printf("Product_ID: 0x%04x\n", pinfo->pid);
		printf("Firmware_ID: 0x%x\n", pinfo->firmware_id);
		printf("Hardware_ID: 0x%x\n", pinfo->hardware_id);		
		printf("Serial_No: 0x%x\n", pinfo->serial_no);
		if ((pinfo->platform_id[1] & 0xF0) == 0x40)
			printf("Platform_ID: 0x%x(TC)\n", pinfo->platform_id[1]);			
		else
			printf("Platform_ID: 0x%x\n", pinfo->platform_id[1]);
		printf("XmlId1: %x   XmlId2: %x\n", pinfo->sys_param.xmls_id1, pinfo->sys_param.xmls_id2);
		printf("Param: phy_x %d, phy_y %d\n", pinfo->sys_param.Phy_Frmbuf_W, pinfo->sys_param.Phy_Frmbuf_H);
	} 

	if (pparam->argus & OPTION_EXTRA_INFO) {
		if (pinfo->dev_type & FW_WDT8755) {
			printf("\nprotocol_version 0x%x\n", pinfo->dev_info.w8755_dev_info.protocol_version);
			printf("firmware_id 0x%x\n", pinfo->dev_info.w8755_dev_info.firmware_id);
			printf("config_size 0x%x\n", pinfo->dev_info.w8755_dev_info.config_size);
			printf("parameter_map_sum 0x%x\n", pinfo->dev_info.w8755_dev_info.parameter_map_sum);
			printf("firmware_revision 0x%x\n", pinfo->dev_info.w8755_dev_info.firmware_revision);
			printf("max_points 0x%x\n", pinfo->dev_info.w8755_dev_info.max_points); 
			printf("bytes_per_point 0x%x\n", pinfo->dev_info.w8755_dev_info.bytes_per_point);	
			printf("customer_config_id 0x%x\n", pinfo->dev_info.w8755_dev_info.customer_config_id); 	
			printf("boot_partition: ");

			if (pinfo->dev_info.w8755_dev_info.boot_partition == W8755_BP_SECONDARY) 
			{
				printf("Secondary");
				printf("\n\nfastboot_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.fastboot_addr);
				printf("library_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.library_addr);
				printf("firmware_image_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.secondary_image_address);
				printf("parameter_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.secondary_param_addr);
				printf("ate_firmware_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.ate_firmware_addr);
				printf("recovery_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.recovery_addr);
				printf("param_clone_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.secondary_param_clone_addr);

			}
			else 
			{
				printf("Primary");
				printf("\n\nfastboot_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.fastboot_addr);
				printf("library_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.library_addr);
				printf("firmware_image_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.firmware_image_addr);
				printf("parameter_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.parameter_addr);
				printf("ate_firmware_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.ate_firmware_addr);
				printf("recovery_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.recovery_addr);
				printf("param_clone_addr: 0x%X\n", pinfo->sec_header.w8755_sec_header.param_clone_addr);
			}



		} else if (pinfo->dev_type & FW_WDT8760_2) {
			char str[16];	
			printf("\nMax_points 0x%X\n", pinfo->dev_info.w8760_feature_devinfo.n_touches_usb);
			printf("Bytes_per_point 0x%X\n", pinfo->dev_info.w8760_feature_devinfo.n_bytes_touch);		
			memset(str, 0, 16);
			memcpy(str, pinfo->dev_info.w8760_feature_devinfo.platform_id, 8);
			printf("Platform_id %s\n", str);
			memset(str, 0, 16);
			memcpy(str, pinfo->dev_info.w8760_feature_devinfo.program_name_fourcc, 4);
			printf("ProgramFourcc %s\n", str);
			printf("ProtocolRevision 0x%X\n", pinfo->dev_info.w8760_feature_devinfo.protocol_version);
			printf("FirmwareRevisionExt 0x%X\n", pinfo->dev_info.w8760_feature_devinfo.firmware_rev_ext);
			memset(str, 0, 16);
			memcpy(str, pinfo->dev_info.w8760_feature_devinfo.part_number_ext, 8);		
			printf("PartNumberExt %s\n", str);
		 }else if (pinfo->dev_type & FW_WDT8790) {
			char str[16] ;
			memset(str, 0xff, sizeof(str));
			printf("\nMaxTouches 0x%X\n", pinfo->dev_info.w8790_feature_devinfo.max_touches);
			printf("FirmwareRevisionExt 0x%X\n", pinfo->dev_info.w8790_feature_devinfo.firmware_revision_ext);
			printf("Partition 0x%X\n", pinfo->dev_info.w8790_feature_devinfo.partition);
			printf("PartitionFormatRevision 0x%X\n", pinfo->dev_info.w8790_feature_devinfo.partition_format_revision);

			if(memcmp(str, pinfo->dev_info.w8790_feature_devinfo.part_number, sizeof(str)) == 0)
				printf("PartNumber all 0xFF \n");
			else
			{
				memset(str, '\0', sizeof(str));
				memcpy(str, pinfo->dev_info.w8790_feature_devinfo.part_number, sizeof(pinfo->dev_info.w8790_feature_devinfo.part_number));
				printf("PartNumber %s\n", str);
			}
			printf("RomSignature ");
			for (int idx = 0; idx < 8; idx++)
				printf("%02X", pinfo->dev_info.w8790_feature_devinfo.rom_signature[idx]);
			printf("\n");
			memset(str, '\0', sizeof(str));
			memcpy(str, pinfo->dev_info.w8790_feature_devinfo.program_name_fourcc, 4);
			printf("ProgramFourcc %s\n", str);

		 }

	}

info_exit:	
	close_device(pdev);
	
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
xorl %ebx, %ebx
orb %al, %cl
jne 0x7738
movq %rsi, %r15
movq %rdi, %r14
callq 0x692c
testl %eax, %eax
je 0x7738
xorl %ebx, %ebx
testw $0x5001, 0x188(%r14)    # imm = 0x5001
sete %bpl
jne 0x772b
testb $0x40, 0x1(%r15)
je 0x7189
cmpl $0x0, 0x4(%r14)
je 0x715c
movl 0x18c(%r14), %esi
movl 0x190(%r14), %edx
leaq 0x3f86(%rip), %rdi      # 0xb0d9
xorl %eax, %eax
callq 0x2050
jmp 0x7189
movl 0x19c(%r14), %esi
cmpl $0x1027401, %esi        # imm = 0x1027401
jne 0x717b
movl $0x1017402, 0x19c(%r14) # imm = 0x1017402
movl $0x1017402, %esi        # imm = 0x1017402
leaq 0x3f60(%rip), %rdi      # 0xb0e2
xorl %eax, %eax
callq 0x2050
movl (%r15), %eax
btl $0xc, %eax
jae 0x71fa
btl $0xe, %eax
jae 0x71a0
pushq $0x5f
popq %rdi
callq 0x2200
movl 0x188(%r14), %eax
testb $0x20, %al
jne 0x71c2
testw $0x2800, %ax            # imm = 0x2800
je 0x71cc
movl 0x1f8(%r14), %eax
movzbl 0x218(%r14), %ecx
jmp 0x71e1
movzwl 0x198(%r14), %esi
jmp 0x71ec
btl $0x9, %eax
jae 0x71fa
movl 0x1f8(%r14), %eax
movzbl 0x205(%r14), %ecx
andl $0xf, %ecx
shll $0x4, %eax
movzwl %ax, %esi
orl %ecx, %esi
leaq 0x3eea(%rip), %rdi      # 0xb0dd
xorl %eax, %eax
callq 0x2050
movl (%r15), %eax
btl $0xd, %eax
jae 0x724d
testw $0x5000, %ax            # imm = 0x5000
je 0x7211
pushq $0x5f
popq %rdi
callq 0x2200
cmpl $0x0, 0x4(%r14)
je 0x7238
movzwl 0x1a8(%r14), %esi
movzwl 0x1aa(%r14), %edx
leaq 0x3eaa(%rip), %rdi      # 0xb0d9
xorl %eax, %eax
callq 0x2050
jmp 0x724d
movl 0x1a0(%r14), %esi
leaq 0x3e9c(%rip), %rdi      # 0xb0e2
xorl %eax, %eax
callq 0x2050
testb $0x70, 0x1(%r15)
je 0x7261
pushq $0xa
popq %rdi
callq 0x2200
jmp 0x772b
movl 0x18c(%r14), %esi
leaq 0x3e78(%rip), %rdi      # 0xb0e7
xorl %eax, %eax
callq 0x2050
movl 0x190(%r14), %esi
leaq 0x3e76(%rip), %rdi      # 0xb0fa
xorl %eax, %eax
callq 0x2050
movl 0x198(%r14), %esi
leaq 0x3e75(%rip), %rdi      # 0xb10e
xorl %eax, %eax
callq 0x2050
movl 0x19c(%r14), %esi
leaq 0x3e73(%rip), %rdi      # 0xb121
xorl %eax, %eax
callq 0x2050
movl 0x1a0(%r14), %esi
leaq 0x3e71(%rip), %rdi      # 0xb134
xorl %eax, %eax
callq 0x2050
movzbl 0x1cb(%r14), %esi
movl %esi, %eax
andl $-0x10, %eax
cmpl $0x40, %eax
leaq 0x3e64(%rip), %rax      # 0xb145
leaq 0x3e74(%rip), %rdi      # 0xb15c
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2050
movzwl 0x1a8(%r14), %esi
movzwl 0x1aa(%r14), %edx
leaq 0x3e65(%rip), %rdi      # 0xb16f
xorl %eax, %eax
callq 0x2050
movzwl 0x1ac(%r14), %esi
movzwl 0x1ae(%r14), %edx
leaq 0x3e60(%rip), %rdi      # 0xb188
xorl %eax, %eax
callq 0x2050
testb $0x10, (%r15)
je 0x772b
movl 0x188(%r14), %eax
testb $0x20, %al
jne 0x7417
testw $0x2800, %ax            # imm = 0x2800
je 0x7619
movzbl 0x204(%r14), %esi
leaq 0x3fb3(%rip), %rdi      # 0xb314
xorl %eax, %eax
callq 0x2050
movzbl 0x205(%r14), %esi
leaq 0x3faf(%rip), %rdi      # 0xb326
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movq %rsp, %r15
movdqa %xmm0, (%r15)
movq 0x207(%r14), %rax
movq %rax, (%r15)
leaq 0x3fa1(%rip), %rdi      # 0xb33c
movq %r15, %rsi
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movdqa %xmm0, (%r15)
movl 0x21d(%r14), %eax
movl %eax, (%r15)
leaq 0x3f8d(%rip), %rdi      # 0xb34c
movq %r15, %rsi
xorl %eax, %eax
callq 0x2050
movzbl 0x217(%r14), %esi
leaq 0x3f86(%rip), %rdi      # 0xb35e
xorl %eax, %eax
callq 0x2050
movzbl 0x218(%r14), %esi
leaq 0x3f87(%rip), %rdi      # 0xb375
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movdqa %xmm0, (%r15)
movq 0x229(%r14), %rax
movq %rax, (%r15)
leaq 0x3f80(%rip), %rdi      # 0xb38f
movq %r15, %rsi
jmp 0x7724
movl 0x1f8(%r14), %esi
leaq 0x3d7e(%rip), %rdi      # 0xb1a3
xorl %eax, %eax
callq 0x2050
movl 0x1fc(%r14), %esi
leaq 0x3d81(%rip), %rdi      # 0xb1bb
xorl %eax, %eax
callq 0x2050
movl 0x204(%r14), %esi
leaq 0x3d7e(%rip), %rdi      # 0xb1cd
xorl %eax, %eax
callq 0x2050
movl 0x208(%r14), %esi
leaq 0x3d7b(%rip), %rdi      # 0xb1df
xorl %eax, %eax
callq 0x2050
movl 0x20c(%r14), %esi
leaq 0x3d7e(%rip), %rdi      # 0xb1f7
xorl %eax, %eax
callq 0x2050
movl 0x210(%r14), %esi
leaq 0x3d81(%rip), %rdi      # 0xb20f
xorl %eax, %eax
callq 0x2050
movl 0x214(%r14), %esi
leaq 0x3d7d(%rip), %rdi      # 0xb220
xorl %eax, %eax
callq 0x2050
movl 0x218(%r14), %esi
leaq 0x3d7e(%rip), %rdi      # 0xb236
xorl %eax, %eax
callq 0x2050
leaq 0x3d89(%rip), %rdi      # 0xb24f
xorl %eax, %eax
callq 0x2050
cmpl $0x2, 0x21c(%r14)
jne 0x7573
leaq 0x3d7e(%rip), %rdi      # 0xb260
xorl %eax, %eax
callq 0x2050
movl 0x234(%r14), %esi
leaq 0x3d73(%rip), %rdi      # 0xb26a
xorl %eax, %eax
callq 0x2050
movl 0x238(%r14), %esi
leaq 0x3d75(%rip), %rdi      # 0xb281
xorl %eax, %eax
callq 0x2050
movl 0x250(%r14), %esi
leaq 0x3d74(%rip), %rdi      # 0xb295
xorl %eax, %eax
callq 0x2050
movl 0x254(%r14), %esi
leaq 0x3d7a(%rip), %rdi      # 0xb2b0
xorl %eax, %eax
callq 0x2050
movl 0x244(%r14), %esi
leaq 0x3d7b(%rip), %rdi      # 0xb2c6
xorl %eax, %eax
callq 0x2050
movl 0x248(%r14), %esi
leaq 0x3d7f(%rip), %rdi      # 0xb2df
xorl %eax, %eax
callq 0x2050
movl 0x258(%r14), %esi
jmp 0x7606
leaq 0x3d92(%rip), %rdi      # 0xb30c
xorl %eax, %eax
callq 0x2050
movl 0x234(%r14), %esi
leaq 0x3cdb(%rip), %rdi      # 0xb26a
xorl %eax, %eax
callq 0x2050
movl 0x238(%r14), %esi
leaq 0x3cdd(%rip), %rdi      # 0xb281
xorl %eax, %eax
callq 0x2050
movl 0x23c(%r14), %esi
leaq 0x3cdc(%rip), %rdi      # 0xb295
xorl %eax, %eax
callq 0x2050
movl 0x240(%r14), %esi
leaq 0x3ce2(%rip), %rdi      # 0xb2b0
xorl %eax, %eax
callq 0x2050
movl 0x244(%r14), %esi
leaq 0x3ce3(%rip), %rdi      # 0xb2c6
xorl %eax, %eax
callq 0x2050
movl 0x248(%r14), %esi
leaq 0x3ce7(%rip), %rdi      # 0xb2df
xorl %eax, %eax
callq 0x2050
movl 0x24c(%r14), %esi
leaq 0x3ce7(%rip), %rdi      # 0xb2f4
xorl %eax, %eax
callq 0x2050
jmp 0x772b
btl $0x9, %eax
jae 0x772b
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, (%rsp)
movzbl 0x204(%r14), %esi
leaq 0x3d66(%rip), %rdi      # 0xb3a1
xorl %eax, %eax
callq 0x2050
movzbl 0x205(%r14), %esi
leaq 0x3d24(%rip), %rdi      # 0xb375
xorl %eax, %eax
callq 0x2050
movzbl 0x206(%r14), %esi
leaq 0x3d4c(%rip), %rdi      # 0xb3b3
xorl %eax, %eax
callq 0x2050
movzbl 0x207(%r14), %esi
leaq 0x3d46(%rip), %rdi      # 0xb3c3
xorl %eax, %eax
callq 0x2050
movdqu 0x208(%r14), %xmm0
pcmpeqb (%rsp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x76bf
leaq 0x208(%r14), %rax
movdqu (%rax), %xmm0
movq %rsp, %rsi
movdqa %xmm0, (%rsi)
leaq 0x3d2b(%rip), %rdi      # 0xb3e1
xorl %eax, %eax
callq 0x2050
jmp 0x76cb
leaq 0x401d(%rip), %rdi      # 0xb6e3
callq 0x2270
leaq 0x3d1e(%rip), %rdi      # 0xb3f0
xorl %eax, %eax
callq 0x2050
leaq 0x3d1e(%rip), %r15      # 0xb3fe
xorl %r12d, %r12d
cmpq $0x8, %r12
je 0x7701
movzbl 0x218(%r14,%r12), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2050
incq %r12
jmp 0x76e3
pushq $0xa
popq %rdi
callq 0x2200
pxor %xmm0, %xmm0
movq %rsp, %rsi
movdqa %xmm0, (%rsi)
movl 0x220(%r14), %eax
movl %eax, (%rsi)
leaq 0x3c28(%rip), %rdi      # 0xb34c
xorl %eax, %eax
callq 0x2050
movb %bpl, %bl
movq %r14, %rdi
callq *0x2a0(%r14)
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq