Ejemplo n.º 1
0
static int wp_diag_device_op_open(struct inode *inode, struct file *filp)
{
	int rc;

	int cfg_val;
//SW2-5-1-MP-DbgCfgTool-03*[
	int boot_mode;

	struct wp_diag_context *ctxt = &_wp_context;

	rc = nonseekable_open(inode, filp);
	if (rc < 0)
		return rc;
	
	boot_mode = fih_read_boot_mode_from_smem();

        if(boot_mode != APPS_MODE_FTM) {
		rc = DbgCfgGetByBit(DEBUG_MODEM_LOGGER_CFG, (int*)&cfg_val);
		if ((rc == 0) && (cfg_val == 1) && (boot_mode != APPS_MODE_RECOVERY)) {
			printk(KERN_INFO "wp_diag: Embedded QxDM Enabled. %s", __FUNCTION__);
			INIT_LIST_HEAD(&_wp_context.read_q);
			spin_lock_init(&_wp_context.read_q_lock);
			init_waitqueue_head(&_wp_context.wait_q);
			_wp_context.read_q_count = 0;
	
			rc = smd_open("DIAG", &ctxt->ch, ctxt, wp_smd_diag_notify);
			_wp_context.configured = 1;
			return 0;
		} else {
			printk(KERN_INFO "wp_diag: Embedded QxDM Disabled. %s", __FUNCTION__);
			return -EFAULT;
		}
	}
	else {
		printk(KERN_INFO "wp_diag: Embedded QxDM Disabled due to FTM image. %s", __FUNCTION__);
		return -EFAULT;
	}
//SW2-5-1-MP-DbgCfgTool-03*]
}
Ejemplo n.º 2
0
static int __init dbgcfgtool_init(void)
{

    int ret = 0, value = 0;  //Div6-PT2-Core-BH-DbgCfgToolPorting-01*
    char tempcfg[]  = {  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    //Div6-PT2-Core-BH-DbgCfgToolPorting-01+[
    int *pointer = (int *)localcfg;
    int *pointer_temp = (int *)tempcfg; //SW2-5-1-MP-DbgCfgTool-01+
    int error_fatal_option = 0;
    //Div6-PT2-Core-BH-DbgCfgToolPorting-01+]
 
    write_buf= NULL;

    pfnWriteDbgConfiguration = fih_write_fihdbg_config_nv; 
    pfnReadDbgConfiguration  = fih_read_fihdbg_config_nv;

    //Matt- sysinfo_debugfs_init();  //Div6-PT2-Core-BH-LinuxVer-02+

    ret = pfnReadDbgConfiguration(tempcfg);

    if( ret == 0 )
    {
        if( memcmp(tempcfg,localcfg,FIH_DEBUG_CFG_LEN) == 0 )
        {
//Div6-PT2-Core-BH-DbgCfgTool-01+[
// DbgCfg has been initialized in appsboot, not need any more here
#if 0
            printk(KERN_INFO "[dbgcfgtool] %s() LINE:%d, Initialize dbgcfg data\n", __func__, __LINE__);
            memset(localcfg,0,FIH_DEBUG_CFG_LEN);
            localcfg[FIH_DEBUG_CFG_LEN-1] = GenerateCheckSumByChar(tempcfg,FIH_DEBUG_CFG_LEN-1);
            
            ret = pfnWriteDbgConfiguration(localcfg);
            
            if ( ret == 0 )
            {
                printk(KERN_INFO "[dbgcfgtool] %s() LINE:%d, Initialize dbgcfg data successful.\n", __func__, __LINE__);
            }
            else
            {
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, Initialize dbgcfg data failed.(ret: %d)\n", __func__, __LINE__, ret);
            }
#endif			
//Div6-PT2-Core-BH-DbgCfgTool-01+]
        }
        else if( GenerateCheckSumByChar(tempcfg,FIH_DEBUG_CFG_LEN-1) == tempcfg[FIH_DEBUG_CFG_LEN-1] )
        {
            memcpy(localcfg,tempcfg,FIH_DEBUG_CFG_LEN);
            printk(KERN_INFO "[dbgcfgtool] %s() LINE:%d, Check sum is correct.\n", __func__, __LINE__);
        }
        else
        {
            ret = -1;        
            printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, Data crash in storage.(ret: %d)\n", __func__, __LINE__, ret);
            printk(KERN_INFO "[dbgcfgtool] tempcfg: 0x%08x 0x%08x 0x%08x 0x%08x\n", pointer_temp[0], pointer_temp[1], pointer_temp[2], pointer_temp[3]); //SW2-5-1-MP-DbgCfgTool-01+
        }
        
        if( ret == 0 )
        {
            dbgcfg_data_has_initialized = 1;
            //Div6-PT2-Core-BH-DbgCfgToolPorting-01+[
            //Initialize global flag for kernel debug
            ret = DbgCfgGetByBit(DEBUG_CPU_USAGE_CFG, (int*)&value);
            
            if (ret == 0)
            {
                debug_cpu_usage_enable = value;
            }
            else
            {
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, Initialize debug_cpu_usage_enable failed.(ret: %d)\n", __func__, __LINE__, ret);
            }

            ret = DbgCfgGetByBit(DEBUG_RPCMSG_CFG, (int*)&value);
            
            if (ret == 0)
            {
                debug_rpcmsg_enable = value;
            }
            else
            {
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, Initialize debug_rpcmsg_enable failed.(ret: %d)\n", __func__, __LINE__, ret);
            }

            printk(KERN_INFO "[dbgcfgtool] localcfg: 0x%08x 0x%08x 0x%08x 0x%08x\n", pointer[0], pointer[1], pointer[2], pointer[3]);

            ret = DbgCfgGetErrorAction(&error_fatal_option);

            if(ret != 0)
            {
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, Fail to call DbgCfgGetErrorAction.(ret: %d)\n", __func__, __LINE__, ret);
            }
            //Div6-PT2-Core-BH-DbgCfgToolPorting-01+]
          
            ret = misc_register(&dbgcfgtool_dev);
            if ( ret )
            {
                printk(KERN_ERR "Cannot register miscdev on minor(MISC_DYNAMIC_MINOR)=%d (err=%d)\n", MISC_DYNAMIC_MINOR, ret);
            }
        }
    }        
    else
    {
        printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, Fail to read debug configurations.(ret: %d)\n", __func__, __LINE__, ret);    
    }

    return ret;
}
Ejemplo n.º 3
0
int dbgcfgtool_ioctl(
    struct inode *inode,
    struct file *filp,
    unsigned int cmd,
    unsigned long arg)
{
    int ret = 0;
    dbgcfg_ioctl_arg DbgArg,*pDbgArg = (dbgcfg_ioctl_arg *)arg;

    switch( cmd ) {

        case DBG_IOCTL_CMD_GET_DBGCFG_GROUP:
            if (copy_from_user(&DbgArg, (void*)pDbgArg, sizeof(dbgcfg_ioctl_arg)))
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_from_user failed in DBG_IOCTL_CMD_GET_DBGCFG_GROUP.(ret: %d)\n", __func__, __LINE__, ret);
            }

            ret = DbgCfgGetByGroup(DbgArg.id.group_id, &(DbgArg.value));

            if( ret != 0 )
            {
                printk(KERN_ERR "dbgcfgtool_ioctl: Fail to call DbgCfgGetByGroup(), ret=%d.\n",ret);
            }
            else 
            {
                /* Filter out checksum */
                if (DbgArg.id.group_id == FIH_DEBUG_CMD_DATA_SIZE-2)  //Last group
                {
                    DbgArg.value = DbgArg.value & ~CHECK_SUM_MASK;
                }

                if (copy_to_user(pDbgArg, &DbgArg, sizeof(dbgcfg_ioctl_arg)))
                {
                    ret = -EINVAL;
                    printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_to_user failed in DBG_IOCTL_CMD_GET_DBGCFG_GROUP.(ret: %d)\n", __func__, __LINE__, ret);
                }
            }
            break;
        case DBG_IOCTL_CMD_SET_DBGCFG_GROUP:
            if (copy_from_user(&DbgArg, (void*)pDbgArg, sizeof(dbgcfg_ioctl_arg)))
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_from_user failed in DBG_IOCTL_CMD_SET_DBGCFG_GROUP.(ret: %d)\n", __func__, __LINE__, ret);
            }

            ret = DbgCfgSetByGroup(DbgArg.id.group_id, DbgArg.value);

            if( ret != 0 )
            {
                printk(KERN_ERR "dbgcfgtool_ioctl: Fail to call DbgCfgSetByGroup(), ret=%d.\n",ret);
            }

            break;
        case DBG_IOCTL_CMD_GET_DBGCFG_BIT:
            if (copy_from_user(&DbgArg, (void*)pDbgArg, sizeof(dbgcfg_ioctl_arg)))
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_to_user failed in DBG_IOCTL_CMD_GET_DBGCFG_BIT.(ret: %d)\n", __func__, __LINE__, ret);
            }

            ret = DbgCfgGetByBit(DbgArg.id.bit_id, &(DbgArg.value));

            if( ret != 0 )
            {
                printk(KERN_ERR "dbgcfgtool_ioctl: Fail to call DbgCfgGetByBit(), ret=%d.\n",ret);
            }

            if (copy_to_user(pDbgArg, &DbgArg, sizeof(dbgcfg_ioctl_arg)))
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_to_user failed in DBG_IOCTL_CMD_GET_DBGCFG_BIT.(ret: %d)\n", __func__, __LINE__, ret);
            }
            break;
        //Div6-PT2-Core-BH-DbgCfgToolPorting-01+[
        case DBG_IOCTL_CMD_GET_ERROR_ACTION:

            ret = DbgCfgGetErrorAction(&(DbgArg.value));

            if( ret != 0 )
            {
                printk(KERN_ERR "dbgcfgtool_ioctl: Fail to call DbgCfgGetErrorAction(), ret=%d.\n",ret);
            }
            else
            {
                error_fatal_option_has_initialized = 1;
            }

            if (copy_to_user(pDbgArg, &DbgArg, sizeof(dbgcfg_ioctl_arg)))
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_to_user failed in DBG_IOCTL_CMD_GET_ERROR_ACTION.(ret: %d)\n", __func__, __LINE__, ret);
            }
            break;
        case DBG_IOCTL_CMD_SET_ERROR_ACTION:
            if (copy_from_user(&DbgArg, (void*)pDbgArg, sizeof(dbgcfg_ioctl_arg)))
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, copy_to_user failed in DBG_IOCTL_CMD_GET_DBGCFG_BIT.(ret: %d)\n", __func__, __LINE__, ret);
            }

            if (!error_fatal_option_has_initialized)
            {
                ret = -EINVAL;
                printk(KERN_ERR "[dbgcfgtool] %s() LINE:%d, error_fatal_option isn't initialized.\n", __func__, __LINE__);
            }
            else
            {
                //SW2-5-1-MP-Modem_Debug_NV-00- ret = DbgCfgSetErrorAction(DbgArg.value);
                ret = fih_write_modem_debug_nv(DbgArg.value); //SW2-5-1-MP-Modem_Debug_NV-00+
            }

            if( ret != 0 )
            {
                printk(KERN_ERR "dbgcfgtool_ioctl: Fail to call DbgCfgGetErrorAction(), ret=%d.\n",ret);
            }

            break;
        //Div6-PT2-Core-BH-DbgCfgToolPorting-01+]
        default:
            printk(KERN_ERR "[dbgcfgtool_ioctl] Unknown IOCTL(Line: %d).\n", __LINE__);
            ret = -EINVAL;
    }
    return ret;
}