// File: /workspace/github_cpp_makefile_star2_O3/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 0x8123
movq %rsi, %r15
movq %rdi, %r14
callq 0x725d
testl %eax, %eax
je 0x8123
xorl %ebx, %ebx
testl $0x5001, 0x188(%r14) # imm = 0x5001
sete %bpl
jne 0x8116
testb $0x40, 0x1(%r15)
je 0x7b6b
cmpl $0x0, 0x4(%r14)
je 0x7b3e
movl 0x18c(%r14), %esi
movl 0x190(%r14), %edx
leaq 0x45a4(%rip), %rdi      # 0xc0d9
xorl %eax, %eax
callq 0x2050
jmp 0x7b6b
movl 0x19c(%r14), %esi
cmpl $0x1027401, %esi        # imm = 0x1027401
jne 0x7b5d
movl $0x1017402, 0x19c(%r14) # imm = 0x1017402
movl $0x1017402, %esi        # imm = 0x1017402
leaq 0x457e(%rip), %rdi      # 0xc0e2
xorl %eax, %eax
callq 0x2050
movl (%r15), %eax
btl $0xc, %eax
jae 0x7bdf
btl $0xe, %eax
jae 0x7b84
movl $0x5f, %edi
callq 0x2200
movl 0x188(%r14), %eax
testb $0x20, %al
jne 0x7ba7
testl $0x2800, %eax           # imm = 0x2800
je 0x7bb1
movl 0x1f8(%r14), %eax
movzbl 0x218(%r14), %ecx
jmp 0x7bc6
movzwl 0x198(%r14), %esi
jmp 0x7bd1
btl $0x9, %eax
jae 0x7bdf
movl 0x1f8(%r14), %eax
movzbl 0x205(%r14), %ecx
andl $0xf, %ecx
shll $0x4, %eax
movzwl %ax, %esi
orl %ecx, %esi
leaq 0x4505(%rip), %rdi      # 0xc0dd
xorl %eax, %eax
callq 0x2050
movl (%r15), %eax
btl $0xd, %eax
jae 0x7c35
testl $0x5000, %eax           # imm = 0x5000
je 0x7bf9
movl $0x5f, %edi
callq 0x2200
cmpl $0x0, 0x4(%r14)
je 0x7c20
movzwl 0x1a8(%r14), %esi
movzwl 0x1aa(%r14), %edx
leaq 0x44c2(%rip), %rdi      # 0xc0d9
xorl %eax, %eax
callq 0x2050
jmp 0x7c35
movl 0x1a0(%r14), %esi
leaq 0x44b4(%rip), %rdi      # 0xc0e2
xorl %eax, %eax
callq 0x2050
testb $0x70, 0x1(%r15)
je 0x7c4b
movl $0xa, %edi
callq 0x2200
jmp 0x8116
movl 0x18c(%r14), %esi
leaq 0x448e(%rip), %rdi      # 0xc0e7
xorl %eax, %eax
callq 0x2050
movl 0x190(%r14), %esi
leaq 0x448c(%rip), %rdi      # 0xc0fa
xorl %eax, %eax
callq 0x2050
movl 0x198(%r14), %esi
leaq 0x448b(%rip), %rdi      # 0xc10e
xorl %eax, %eax
callq 0x2050
movl 0x19c(%r14), %esi
leaq 0x4489(%rip), %rdi      # 0xc121
xorl %eax, %eax
callq 0x2050
movl 0x1a0(%r14), %esi
leaq 0x4487(%rip), %rdi      # 0xc134
xorl %eax, %eax
callq 0x2050
movzbl 0x1cb(%r14), %esi
movl %esi, %eax
andl $-0x10, %eax
cmpl $0x40, %eax
leaq 0x447a(%rip), %rax      # 0xc145
leaq 0x448a(%rip), %rdi      # 0xc15c
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2050
movzwl 0x1a8(%r14), %esi
movzwl 0x1aa(%r14), %edx
leaq 0x447b(%rip), %rdi      # 0xc16f
xorl %eax, %eax
callq 0x2050
movzwl 0x1ac(%r14), %esi
movzwl 0x1ae(%r14), %edx
leaq 0x4476(%rip), %rdi      # 0xc188
xorl %eax, %eax
callq 0x2050
testb $0x10, (%r15)
je 0x8116
movl 0x188(%r14), %eax
testb $0x20, %al
jne 0x7e02
testl $0x2800, %eax           # imm = 0x2800
je 0x8004
movzbl 0x204(%r14), %esi
leaq 0x45c8(%rip), %rdi      # 0xc314
xorl %eax, %eax
callq 0x2050
movzbl 0x205(%r14), %esi
leaq 0x45c4(%rip), %rdi      # 0xc326
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movq %rsp, %r15
movdqa %xmm0, (%r15)
movq 0x207(%r14), %rax
movq %rax, (%r15)
leaq 0x45b6(%rip), %rdi      # 0xc33c
movq %r15, %rsi
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movdqa %xmm0, (%r15)
movl 0x21d(%r14), %eax
movl %eax, (%r15)
leaq 0x45a2(%rip), %rdi      # 0xc34c
movq %r15, %rsi
xorl %eax, %eax
callq 0x2050
movzbl 0x217(%r14), %esi
leaq 0x459b(%rip), %rdi      # 0xc35e
xorl %eax, %eax
callq 0x2050
movzbl 0x218(%r14), %esi
leaq 0x459c(%rip), %rdi      # 0xc375
xorl %eax, %eax
callq 0x2050
pxor %xmm0, %xmm0
movdqa %xmm0, (%r15)
movq 0x229(%r14), %rax
movq %rax, (%r15)
leaq 0x4595(%rip), %rdi      # 0xc38f
movq %r15, %rsi
jmp 0x810f
movl 0x1f8(%r14), %esi
leaq 0x4393(%rip), %rdi      # 0xc1a3
xorl %eax, %eax
callq 0x2050
movl 0x1fc(%r14), %esi
leaq 0x4396(%rip), %rdi      # 0xc1bb
xorl %eax, %eax
callq 0x2050
movl 0x204(%r14), %esi
leaq 0x4393(%rip), %rdi      # 0xc1cd
xorl %eax, %eax
callq 0x2050
movl 0x208(%r14), %esi
leaq 0x4390(%rip), %rdi      # 0xc1df
xorl %eax, %eax
callq 0x2050
movl 0x20c(%r14), %esi
leaq 0x4393(%rip), %rdi      # 0xc1f7
xorl %eax, %eax
callq 0x2050
movl 0x210(%r14), %esi
leaq 0x4396(%rip), %rdi      # 0xc20f
xorl %eax, %eax
callq 0x2050
movl 0x214(%r14), %esi
leaq 0x4392(%rip), %rdi      # 0xc220
xorl %eax, %eax
callq 0x2050
movl 0x218(%r14), %esi
leaq 0x4393(%rip), %rdi      # 0xc236
xorl %eax, %eax
callq 0x2050
leaq 0x439e(%rip), %rdi      # 0xc24f
xorl %eax, %eax
callq 0x2050
cmpl $0x2, 0x21c(%r14)
jne 0x7f5e
leaq 0x4393(%rip), %rdi      # 0xc260
xorl %eax, %eax
callq 0x2050
movl 0x234(%r14), %esi
leaq 0x4388(%rip), %rdi      # 0xc26a
xorl %eax, %eax
callq 0x2050
movl 0x238(%r14), %esi
leaq 0x438a(%rip), %rdi      # 0xc281
xorl %eax, %eax
callq 0x2050
movl 0x250(%r14), %esi
leaq 0x4389(%rip), %rdi      # 0xc295
xorl %eax, %eax
callq 0x2050
movl 0x254(%r14), %esi
leaq 0x438f(%rip), %rdi      # 0xc2b0
xorl %eax, %eax
callq 0x2050
movl 0x244(%r14), %esi
leaq 0x4390(%rip), %rdi      # 0xc2c6
xorl %eax, %eax
callq 0x2050
movl 0x248(%r14), %esi
leaq 0x4394(%rip), %rdi      # 0xc2df
xorl %eax, %eax
callq 0x2050
movl 0x258(%r14), %esi
jmp 0x7ff1
leaq 0x43a7(%rip), %rdi      # 0xc30c
xorl %eax, %eax
callq 0x2050
movl 0x234(%r14), %esi
leaq 0x42f0(%rip), %rdi      # 0xc26a
xorl %eax, %eax
callq 0x2050
movl 0x238(%r14), %esi
leaq 0x42f2(%rip), %rdi      # 0xc281
xorl %eax, %eax
callq 0x2050
movl 0x23c(%r14), %esi
leaq 0x42f1(%rip), %rdi      # 0xc295
xorl %eax, %eax
callq 0x2050
movl 0x240(%r14), %esi
leaq 0x42f7(%rip), %rdi      # 0xc2b0
xorl %eax, %eax
callq 0x2050
movl 0x244(%r14), %esi
leaq 0x42f8(%rip), %rdi      # 0xc2c6
xorl %eax, %eax
callq 0x2050
movl 0x248(%r14), %esi
leaq 0x42fc(%rip), %rdi      # 0xc2df
xorl %eax, %eax
callq 0x2050
movl 0x24c(%r14), %esi
leaq 0x42fc(%rip), %rdi      # 0xc2f4
xorl %eax, %eax
callq 0x2050
jmp 0x8116
btl $0x9, %eax
jae 0x8116
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, (%rsp)
movzbl 0x204(%r14), %esi
leaq 0x437b(%rip), %rdi      # 0xc3a1
xorl %eax, %eax
callq 0x2050
movzbl 0x205(%r14), %esi
leaq 0x4339(%rip), %rdi      # 0xc375
xorl %eax, %eax
callq 0x2050
movzbl 0x206(%r14), %esi
leaq 0x4361(%rip), %rdi      # 0xc3b3
xorl %eax, %eax
callq 0x2050
movzbl 0x207(%r14), %esi
leaq 0x435b(%rip), %rdi      # 0xc3c3
xorl %eax, %eax
callq 0x2050
movdqu 0x208(%r14), %xmm0
pcmpeqb (%rsp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x80aa
leaq 0x208(%r14), %rax
movdqu (%rax), %xmm0
movq %rsp, %rsi
movdqa %xmm0, (%rsi)
leaq 0x4340(%rip), %rdi      # 0xc3e1
xorl %eax, %eax
callq 0x2050
jmp 0x80b6
leaq 0x4632(%rip), %rdi      # 0xc6e3
callq 0x2270
leaq 0x4333(%rip), %rdi      # 0xc3f0
xorl %eax, %eax
callq 0x2050
leaq 0x4333(%rip), %r15      # 0xc3fe
xorl %r12d, %r12d
movzbl 0x218(%r14,%r12), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2050
incq %r12
cmpq $0x8, %r12
jne 0x80ce
movl $0xa, %edi
callq 0x2200
pxor %xmm0, %xmm0
movq %rsp, %rsi
movdqa %xmm0, (%rsi)
movl 0x220(%r14), %eax
movl %eax, (%rsi)
leaq 0x423d(%rip), %rdi      # 0xc34c
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