// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0x18, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x7be2
movq %rsi, %r14
movq %rdi, %rbx
callq 0x730f
testl %eax, %eax
je 0x7be2
testl $0x5001, 0x188(%rbx)    # imm = 0x5001
sete %bpl
jne 0x8187
testb $0x40, 0x1(%r14)
je 0x7c13
cmpl $0x0, 0x4(%rbx)
je 0x7be9
movl 0x18c(%rbx), %esi
movl 0x190(%rbx), %edx
leaq 0x4500(%rip), %rdi      # 0xc0d9
xorl %eax, %eax
callq 0x2050
jmp 0x7c13
xorl %ebp, %ebp
jmp 0x8195
cmpl $0x1027401, 0x19c(%rbx) # imm = 0x1027401
jne 0x7bff
movl $0x1017402, 0x19c(%rbx) # imm = 0x1017402
movl 0x19c(%rbx), %esi
leaq 0x44d6(%rip), %rdi      # 0xc0e2
xorl %eax, %eax
callq 0x2050
movl (%r14), %eax
btl $0xc, %eax
jae 0x7c81
btl $0xe, %eax
jae 0x7c2c
movl $0x5f, %edi
callq 0x2200
movl 0x188(%rbx), %eax
testb $0x20, %al
jne 0x7c4c
testl $0x2800, %eax           # imm = 0x2800
je 0x7c55
movl 0x1f8(%rbx), %eax
movzbl 0x218(%rbx), %ecx
jmp 0x7c68
movzwl 0x198(%rbx), %esi
jmp 0x7c73
btl $0x9, %eax
jae 0x7c81
movl 0x1f8(%rbx), %eax
movzbl 0x205(%rbx), %ecx
andl $0xf, %ecx
shll $0x4, %eax
movzwl %ax, %esi
orl %ecx, %esi
leaq 0x4463(%rip), %rdi      # 0xc0dd
xorl %eax, %eax
callq 0x2050
movl (%r14), %eax
btl $0xd, %eax
jae 0x7cd3
testl $0x5000, %eax           # imm = 0x5000
je 0x7c9b
movl $0x5f, %edi
callq 0x2200
cmpl $0x0, 0x4(%rbx)
je 0x7cbf
movzwl 0x1a8(%rbx), %esi
movzwl 0x1aa(%rbx), %edx
leaq 0x4423(%rip), %rdi      # 0xc0d9
xorl %eax, %eax
callq 0x2050
jmp 0x7cd3
movl 0x1a0(%rbx), %esi
leaq 0x4416(%rip), %rdi      # 0xc0e2
xorl %eax, %eax
callq 0x2050
testb $0x70, 0x1(%r14)
je 0x7ce9
movl $0xa, %edi
callq 0x2200
jmp 0x8187
movl 0x18c(%rbx), %esi
leaq 0x43f1(%rip), %rdi      # 0xc0e7
xorl %eax, %eax
callq 0x2050
movl 0x190(%rbx), %esi
leaq 0x43f0(%rip), %rdi      # 0xc0fa
xorl %eax, %eax
callq 0x2050
movl 0x198(%rbx), %esi
leaq 0x43f0(%rip), %rdi      # 0xc10e
xorl %eax, %eax
callq 0x2050
movl 0x19c(%rbx), %esi
leaq 0x43ef(%rip), %rdi      # 0xc121
xorl %eax, %eax
callq 0x2050
movl 0x1a0(%rbx), %esi
leaq 0x43ee(%rip), %rdi      # 0xc134
xorl %eax, %eax
callq 0x2050
movzbl 0x1cb(%rbx), %esi
movl %esi, %eax
andl $-0x10, %eax
cmpl $0x40, %eax
leaq 0x43e2(%rip), %rax      # 0xc145
leaq 0x43f2(%rip), %rdi      # 0xc15c
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2050
movzwl 0x1a8(%rbx), %esi
movzwl 0x1aa(%rbx), %edx
leaq 0x43e5(%rip), %rdi      # 0xc16f
xorl %eax, %eax
callq 0x2050
movzwl 0x1ac(%rbx), %esi
movzwl 0x1ae(%rbx), %edx
leaq 0x43e2(%rip), %rdi      # 0xc188
xorl %eax, %eax
callq 0x2050
testb $0x10, (%r14)
je 0x8187
movl 0x188(%rbx), %eax
testb $0x20, %al
jne 0x7e90
testl $0x2800, %eax           # imm = 0x2800
je 0x807b
movzbl 0x204(%rbx), %esi
leaq 0x4536(%rip), %rdi      # 0xc314
xorl %eax, %eax
callq 0x2050
movzbl 0x205(%rbx), %esi
leaq 0x4533(%rip), %rdi      # 0xc326
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movq %rsp, %r14
movdqa %xmm0, (%r14)
movq 0x207(%rbx), %rax
movq %rax, (%r14)
leaq 0x4525(%rip), %rdi      # 0xc33c
movq %r14, %rsi
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movdqa %xmm0, (%r14)
movl 0x21d(%rbx), %eax
movl %eax, (%r14)
leaq 0x4512(%rip), %rdi      # 0xc34c
movq %r14, %rsi
xorl %eax, %eax
callq 0x2050
movzbl 0x217(%rbx), %esi
leaq 0x450c(%rip), %rdi      # 0xc35e
xorl %eax, %eax
callq 0x2050
movzbl 0x218(%rbx), %esi
leaq 0x450e(%rip), %rdi      # 0xc375
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movdqa %xmm0, (%r14)
movq 0x229(%rbx), %rax
movq %rax, (%r14)
leaq 0x4507(%rip), %rdi      # 0xc38f
movq %r14, %rsi
jmp 0x8180
movl 0x1f8(%rbx), %esi
leaq 0x4306(%rip), %rdi      # 0xc1a3
xorl %eax, %eax
callq 0x2050
movl 0x1fc(%rbx), %esi
leaq 0x430a(%rip), %rdi      # 0xc1bb
xorl %eax, %eax
callq 0x2050
movl 0x204(%rbx), %esi
leaq 0x4308(%rip), %rdi      # 0xc1cd
xorl %eax, %eax
callq 0x2050
movl 0x208(%rbx), %esi
leaq 0x4306(%rip), %rdi      # 0xc1df
xorl %eax, %eax
callq 0x2050
movl 0x20c(%rbx), %esi
leaq 0x430a(%rip), %rdi      # 0xc1f7
xorl %eax, %eax
callq 0x2050
movl 0x210(%rbx), %esi
leaq 0x430e(%rip), %rdi      # 0xc20f
xorl %eax, %eax
callq 0x2050
movl 0x214(%rbx), %esi
leaq 0x430b(%rip), %rdi      # 0xc220
xorl %eax, %eax
callq 0x2050
movl 0x218(%rbx), %esi
leaq 0x430d(%rip), %rdi      # 0xc236
xorl %eax, %eax
callq 0x2050
leaq 0x4318(%rip), %rdi      # 0xc24f
xorl %eax, %eax
callq 0x2050
cmpl $0x2, 0x21c(%rbx)
jne 0x7fdc
leaq 0x430e(%rip), %rdi      # 0xc260
xorl %eax, %eax
callq 0x2050
movl 0x234(%rbx), %esi
leaq 0x4304(%rip), %rdi      # 0xc26a
xorl %eax, %eax
callq 0x2050
movl 0x238(%rbx), %esi
leaq 0x4307(%rip), %rdi      # 0xc281
xorl %eax, %eax
callq 0x2050
movl 0x250(%rbx), %esi
leaq 0x4307(%rip), %rdi      # 0xc295
xorl %eax, %eax
callq 0x2050
movl 0x254(%rbx), %esi
leaq 0x430e(%rip), %rdi      # 0xc2b0
xorl %eax, %eax
callq 0x2050
movl 0x244(%rbx), %esi
leaq 0x4310(%rip), %rdi      # 0xc2c6
xorl %eax, %eax
callq 0x2050
movl 0x248(%rbx), %esi
leaq 0x4315(%rip), %rdi      # 0xc2df
xorl %eax, %eax
callq 0x2050
movl 0x258(%rbx), %esi
jmp 0x8068
leaq 0x4329(%rip), %rdi      # 0xc30c
xorl %eax, %eax
callq 0x2050
movl 0x234(%rbx), %esi
leaq 0x4273(%rip), %rdi      # 0xc26a
xorl %eax, %eax
callq 0x2050
movl 0x238(%rbx), %esi
leaq 0x4276(%rip), %rdi      # 0xc281
xorl %eax, %eax
callq 0x2050
movl 0x23c(%rbx), %esi
leaq 0x4276(%rip), %rdi      # 0xc295
xorl %eax, %eax
callq 0x2050
movl 0x240(%rbx), %esi
leaq 0x427d(%rip), %rdi      # 0xc2b0
xorl %eax, %eax
callq 0x2050
movl 0x244(%rbx), %esi
leaq 0x427f(%rip), %rdi      # 0xc2c6
xorl %eax, %eax
callq 0x2050
movl 0x248(%rbx), %esi
leaq 0x4284(%rip), %rdi      # 0xc2df
xorl %eax, %eax
callq 0x2050
movl 0x24c(%rbx), %esi
leaq 0x4285(%rip), %rdi      # 0xc2f4
xorl %eax, %eax
callq 0x2050
jmp 0x8187
btl $0x9, %eax
jae 0x8187
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, (%rsp)
movzbl 0x204(%rbx), %esi
leaq 0x4305(%rip), %rdi      # 0xc3a1
xorl %eax, %eax
callq 0x2050
movzbl 0x205(%rbx), %esi
leaq 0x42c4(%rip), %rdi      # 0xc375
xorl %eax, %eax
callq 0x2050
movzbl 0x206(%rbx), %esi
leaq 0x42ed(%rip), %rdi      # 0xc3b3
xorl %eax, %eax
callq 0x2050
movzbl 0x207(%rbx), %esi
leaq 0x42e8(%rip), %rdi      # 0xc3c3
xorl %eax, %eax
callq 0x2050
movdqu 0x208(%rbx), %xmm0
pcmpeqb (%rsp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x811c
leaq 0x208(%rbx), %rax
movdqu (%rax), %xmm0
movq %rsp, %rsi
movdqa %xmm0, (%rsi)
leaq 0x42ce(%rip), %rdi      # 0xc3e1
xorl %eax, %eax
callq 0x2050
jmp 0x8128
leaq 0x45c0(%rip), %rdi      # 0xc6e3
callq 0x2270
leaq 0x42c1(%rip), %rdi      # 0xc3f0
xorl %eax, %eax
callq 0x2050
leaq 0x42c1(%rip), %r14      # 0xc3fe
xorl %r15d, %r15d
movzbl 0x218(%rbx,%r15), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2050
incq %r15
cmpq $0x8, %r15
jne 0x8140
movl $0xa, %edi
callq 0x2200
pxor %xmm0, %xmm0
movq %rsp, %rsi
movdqa %xmm0, (%rsi)
movl 0x220(%rbx), %eax
movl %eax, (%rsi)
leaq 0x41cc(%rip), %rdi      # 0xc34c
xorl %eax, %eax
callq 0x2050
testq %rbx, %rbx
je 0x8195
movq %rbx, %rdi
callq *0x2a0(%rbx)
movzbl %bpl, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq