Пример #1
0
void diag_process_hdlc(void *data, unsigned len)
{
	struct diag_hdlc_decode_type hdlc;
	int ret, type = 0;
#ifdef DIAG_DEBUG
	int i;
	printk(KERN_INFO "\n HDLC decode function, len of data  %d\n", len);
#endif
	hdlc.dest_ptr = driver->hdlc_buf;
	hdlc.dest_size = USB_MAX_OUT_BUF;
	hdlc.src_ptr = data;
	hdlc.src_size = len;
	hdlc.src_idx = 0;
	hdlc.dest_idx = 0;
	hdlc.escaping = 0;

	ret = diag_hdlc_decode(&hdlc);

	if (ret)
		type = diag_process_apps_pkt(driver->hdlc_buf,
							  hdlc.dest_idx - 3);
	else if (driver->debug_flag) {
		printk(KERN_ERR "Packet dropped due to bad HDLC coding/CRC"
				" errors or partial packet received, packet"
				" length = %d\n", len);
		print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1,
					   DUMP_PREFIX_ADDRESS, data, len, 1);
		driver->debug_flag = 0;
	}
#ifdef CONFIG_DIAG_NO_MODEM
	if (type == 1) { /* implies this packet is NOT meant for apps */
		if (driver->chqdsp)
			smd_write(driver->chqdsp, driver->hdlc_buf,
							 hdlc.dest_idx - 3);
		type = 0;
	}
#endif /* NO MODEM present */

#ifdef DIAG_DEBUG
	printk(KERN_INFO "\n hdlc.dest_idx = %d", hdlc.dest_idx);
	for (i = 0; i < hdlc.dest_idx; i++)
		printk(KERN_DEBUG "\t%x", *(((unsigned char *)
							driver->hdlc_buf)+i));
#endif /* DIAG DEBUG */
	/* ignore 2 bytes for CRC, one for 7E and send */
	if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) {
		APPEND_DEBUG('g');
		smd_write(driver->ch, driver->hdlc_buf, hdlc.dest_idx - 3);
		APPEND_DEBUG('h');
#ifdef DIAG_DEBUG
		printk(KERN_INFO "writing data to SMD, pkt length %d\n", len);
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16,
			       1, DUMP_PREFIX_ADDRESS, data, len, 1);
#endif /* DIAG DEBUG */
	}

}
Пример #2
0
void diag_process_hdlc(void *data, unsigned len)
{
	struct diag_hdlc_decode_type hdlc;
	int ret, type = 0;
#ifdef DIAG_DEBUG
	int i;
#endif

	pr_debug("diag: HDLC decode fn, len of data  %d\n", len);
	hdlc.dest_ptr = driver->hdlc_buf;
	hdlc.dest_size = USB_MAX_OUT_BUF;
	hdlc.src_ptr = data;
	hdlc.src_size = len;
	hdlc.src_idx = 0;
	hdlc.dest_idx = 0;
	hdlc.escaping = 0;

	ret = diag_hdlc_decode(&hdlc);

	if (ret)
		type = diag_process_apps_pkt(driver->hdlc_buf,
							  hdlc.dest_idx - 3);
	else if (driver->debug_flag) {
		printk(KERN_ERR "Packet dropped due to bad HDLC coding/CRC"
				" errors or partial packet received, packet"
				" length = %d\n", len);
		print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1,
					   DUMP_PREFIX_ADDRESS, data, len, 1);
		driver->debug_flag = 0;
	}
	/* send error responses from APPS for Central Routing */
	if (type == 1 && chk_config_get_id() == AO8960_TOOLS_ID) {
		diag_send_error_rsp(hdlc.dest_idx);
		type = 0;
	}
	/* implies this packet is NOT meant for apps */
	if (!(driver->ch) && type == 1) {
		if (chk_config_get_id() == AO8960_TOOLS_ID) {
			diag_send_error_rsp(hdlc.dest_idx);
		} else { /* APQ 8060, Let Q6 respond */
			if (driver->chqdsp)
				smd_write(driver->chqdsp, driver->hdlc_buf,
						  hdlc.dest_idx - 3);
		}
		type = 0;
	}

#ifdef DIAG_DEBUG
	pr_debug("diag: hdlc.dest_idx = %d", hdlc.dest_idx);
	for (i = 0; i < hdlc.dest_idx; i++)
		printk(KERN_DEBUG "\t%x", *(((unsigned char *)
							driver->hdlc_buf)+i));
#endif /* DIAG DEBUG */
	/* ignore 2 bytes for CRC, one for 7E and send */
	if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) {
		APPEND_DEBUG('g');
#ifdef CONFIG_MODEM_DIAG_MASTER
		smd_write(driver->ch, data, len);
#else
		smd_write(driver->ch, driver->hdlc_buf, hdlc.dest_idx - 3);
#endif
		APPEND_DEBUG('h');
#ifdef DIAG_DEBUG
		printk(KERN_INFO "writing data to SMD, pkt length %d\n", len);
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16,
			       1, DUMP_PREFIX_ADDRESS, data, len, 1);
#endif /* DIAG DEBUG */
	}
}
Пример #3
0
void diag_process_hdlc(void *data, unsigned len)
{
	struct diag_hdlc_decode_type hdlc;
	int ret, type = 0;
#ifdef CONFIG_LGE_DIAG
	unsigned int nTempLen = 0;  
#endif
// LGE_CHANGE [2011.07.22] M3S : for remove compile warnig
//#if defined(DIAG_DEBUG) || defined(CONFIG_DIAG_OVER_USB)
#if defined(DIAG_DEBUD)
	int i;
	pr_debug("\n HDLC decode function, len of data  %d\n", len);
#endif
	hdlc.dest_ptr = driver->hdlc_buf;
	hdlc.dest_size = USB_MAX_OUT_BUF;
	hdlc.src_ptr = data;
	hdlc.src_size = len;
	hdlc.src_idx = 0;
	hdlc.dest_idx = 0;
	hdlc.escaping = 0;

#ifdef CONFIG_LGE_DIAG
	if( len > 2 )
  	{
    	if( hdlc.src_ptr[len -1] == 0x7E && hdlc.src_ptr[len -2] == 0x7E)
		{
      		len--;
     	 	hdlc.src_size--;
    	}
  	}

	do
    {
      	ret = diag_hdlc_decode(&hdlc);

      	nTempLen = hdlc.dest_idx;

      	if(ret)
      	{
        	hdlc.dest_idx = 0;    /* Initialize for the next packet */
      	}

      	if( hdlc.src_idx >= hdlc.src_size)
		{
			//ret = 1;
        	break;
      	}
      	else
      	{
      		if(nTempLen > 1)
				break;
			ret = 0; 
      	}
    }while ( ret == 0 );
    
  	if (ret)
  	{
		type = diag_process_apps_pkt(driver->hdlc_buf, nTempLen - 3);
  	}
	
	/* ignore 2 bytes for CRC, one for 7E and send */
	if ((driver->ch) && (ret) && (type) && (nTempLen > 3))
	{
		smd_write(driver->ch, driver->hdlc_buf, nTempLen - 3);
#ifdef DIAG_DEBUG
		printk(KERN_INFO "writing data to SMD, pkt length %d\n", len);
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1);
#endif /* DIAG DEBUG */
	}
#else /*CONFIG_LGE_DIAG*/
	ret = diag_hdlc_decode(&hdlc);

	if (ret)
		type = diag_process_apps_pkt(driver->hdlc_buf,
							  hdlc.dest_idx - 3);
	else if (driver->debug_flag) {
		printk(KERN_ERR "Packet dropped due to bad HDLC coding/CRC"
				" errors or partial packet received, packet"
				" length = %d\n", len);
		print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1,
					   DUMP_PREFIX_ADDRESS, data, len, 1);
		driver->debug_flag = 0;
	}
	/* implies this packet is NOT meant for apps */
	if (!(driver->ch) && type == 1 && chk_config_get_id()) {
		if (chk_config_get_id() == AO8960_TOOLS_ID) {
#if defined(CONFIG_DIAG_OVER_USB)
			driver->apps_rsp_buf[0] = 0x13;
			for (i = 0; i < hdlc.dest_idx; i++)
				driver->apps_rsp_buf[i+1] =
							 *(driver->hdlc_buf+i);
			ENCODE_RSP_AND_SEND(hdlc.dest_idx - 3);
#endif
		} else { /* APQ 8060, Let Q6 respond */
			if (driver->chqdsp)
				smd_write(driver->chqdsp, driver->hdlc_buf,
						  hdlc.dest_idx - 3);
		}
		type = 0;
	}

#ifdef DIAG_DEBUG
	printk(KERN_INFO "\n hdlc.dest_idx = %d", hdlc.dest_idx);
	for (i = 0; i < hdlc.dest_idx; i++)
		printk(KERN_DEBUG "\t%x", *(((unsigned char *)
							driver->hdlc_buf)+i));
#endif /* DIAG DEBUG */
	/* ignore 2 bytes for CRC, one for 7E and send */
	if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) {
		APPEND_DEBUG('g');
		smd_write(driver->ch, driver->hdlc_buf, hdlc.dest_idx - 3);
		APPEND_DEBUG('h');
#ifdef DIAG_DEBUG
		printk(KERN_INFO "writing data to SMD, pkt length %d\n", len);
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16,
			       1, DUMP_PREFIX_ADDRESS, data, len, 1);
#endif /* DIAG DEBUG */
	}
#endif /*CONFIG_LGE_DIAG*/
}
Пример #4
0
void diag_process_hdlc(void *data, unsigned len)
{
	struct diag_hdlc_decode_type hdlc;
	int ret, type = 0;
#if HPST_FUN
	unsigned char *buf_9k = NULL;
	int path;
#endif
#ifdef DIAG_DEBUG
	int i;
	printk(KERN_INFO "\n HDLC decode function, len of data  %d\n", len);
#endif
	hdlc.dest_ptr = driver->hdlc_buf;
	hdlc.dest_size = USB_MAX_OUT_BUF;
	hdlc.src_ptr = data;
	hdlc.src_size = len;
	hdlc.src_idx = 0;
	hdlc.dest_idx = 0;
	hdlc.escaping = 0;

	ret = diag_hdlc_decode(&hdlc);

	if (ret) {
		type = diag_process_apps_pkt(driver->hdlc_buf,
							  hdlc.dest_idx - 3);
	} else if (driver->debug_flag) {
		printk(KERN_ERR "Packet dropped due to bad HDLC coding/CRC"
				" errors or partial packet received, packet"
				" length = %d\n", len);
		print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1,
					   DUMP_PREFIX_ADDRESS, data, len, 1);
		driver->debug_flag = 0;
	}
#ifdef DIAG_DEBUG
	printk(KERN_INFO "\n hdlc.dest_idx = %d \n", hdlc.dest_idx);
	for (i = 0; i < hdlc.dest_idx; i++)
		printk(KERN_DEBUG "\t%x", *(((unsigned char *)
							driver->hdlc_buf)+i));
#endif
	/* ignore 2 bytes for CRC, one for 7E and send */
	if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) {
		APPEND_DEBUG('g');

#if HPST_FUN
/* check for hpst*/
		path = checkcmd_modem_hpst(data);

		switch (path) {
		case DM7K9K:
				printk(KERN_INFO "%s:DM7K9K\n", __func__);
				print_hex_dump(KERN_DEBUG, "HPST:DM Packet Data"
				" write to radio ", 16, 1, DUMP_PREFIX_ADDRESS, data, 16, 1);
				smd_write(driver->ch, data, len);
				buf_9k = kzalloc(len, GFP_KERNEL);
				memcpy(buf_9k, data, len);
				msm_sdio_diag_write((void *)buf_9k, len);
				buf_9k = NULL;
				break;
		case DM9KONLY:
				printk(KERN_INFO "%s:DM9KONLY\n", __func__);
				print_hex_dump(KERN_DEBUG, "HPST:DM Packet Data"
				" write to radio ", 16, 1, DUMP_PREFIX_ADDRESS, data, 16, 1);
				buf_9k = kzalloc(len, GFP_KERNEL);
				memcpy(buf_9k, data, len);
				msm_sdio_diag_write((void *)buf_9k, len);
				buf_9k = NULL;
				break;
		case DM7K9KDIFF:
				printk(KERN_INFO "%s:DM7K9KDIFF", __func__);
				print_hex_dump(KERN_DEBUG, "HPST:DM Packet Data"
				" write to radio ", 16, 1, DUMP_PREFIX_ADDRESS, data, 16, 1);
				if (((*(((uint8_t *)data)+3)) & 0xC0) == 0xC0) {
					printk(KERN_INFO "%s:DM7K9KDIFF to 9K\n", __func__);
					buf_9k = kzalloc(len, GFP_KERNEL);
					memcpy(buf_9k, data, len);
					msm_sdio_diag_write((void *)buf_9k, len);
					buf_9k = NULL;
				} else {
					printk(KERN_INFO "%s:DM7K9KDIFF to 7K\n", __func__);
					smd_write(driver->ch, data, len);
				}
				break;
		case DM7KONLY:
				printk(KERN_INFO "%s:DM7KONLY\n", __func__);
				print_hex_dump(KERN_DEBUG, "HPST:DM Packet Data"
				" write to radio ", 16, 1, DUMP_PREFIX_ADDRESS, data, 16, 1);
				smd_write(driver->ch, data, len);
				break;
		case NO_PST:
			smd_write(driver->ch, data, len);
			break;

		case NO_DEF_ID:
		case NO_DEF_ITEM:
		default:
				print_hex_dump(KERN_DEBUG, "HPST:DM Packet Data"
				" can't write to radio ", 16, 1, DUMP_PREFIX_ADDRESS, data, 16, 1);
		}
#else
		smd_write(driver->ch, data, len);
#endif
		APPEND_DEBUG('h');
#ifdef DIAG_DEBUG
		printk(KERN_INFO "writing data to SMD, pkt length %d \n", len);
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16,
			       1, DUMP_PREFIX_ADDRESS, data, len, 1);
#endif
	}

}