Ejemplo n.º 1
0
//======================================================================
//  check partition table info command
//======================================================================
void check_pt_cmd (void)
{
    DM_ERRCODE_PACKET errp = { DM_ERROR_PKT_PATN, 0 };
    DM_PKT_TYPE pkt_type;
    char buffer[DM_CMD_MAX_SIZE];
    int i;
#ifdef DEBUG
    print ("DM_PARTITION_INFO_PACKET\n");
    print (": pattern %x\n", g_img_dl_pt_info.pattern);
    print (": part_num = %d\n", g_img_dl_pt_info.part_num);
    for (i = 0; i < PART_MAX_COUNT; i++)
    {
        print (": part_info[%d].part_name = %s\n", i, g_img_dl_pt_info.part_info[i].part_name);
        print (": part_info[%d].start_addr = %x\n", i, g_img_dl_pt_info.part_info[i].start_addr);
        print (": part_info[%d].part_len = %x\n", i, g_img_dl_pt_info.part_info[i].part_len);
        print (": part_info[%d].part_visibility = %x\n", i, g_img_dl_pt_info.part_info[i].part_visibility);
        print (": part_info[%d].dl_selected = %x\n", i, g_img_dl_pt_info.part_info[i].dl_selected);
        print ("\n");
    }
#endif    
    //==================================================
    // check if specified partitions can be downloaded
    //==================================================
#if CFG_PMT_SUPPORT
    errp.err_code = new_part_tab ((u8 *) &g_img_dl_pt_info);
#else
    print("%s : PMT is not supported\n", MOD);
    errp.err_code = DM_ERR_OK;
#endif
    mt_usbtty_putcn (DM_SZ_ERR_CODE_PKT, (u8 *) & errp, TRUE);

    if (errp.err_code != DM_ERR_OK)
    {

        print ("\n%s : the specified partitions can not be downloaded, err_code = %d\n", MOD, errp.err_code);
       
        //================================
        // receive REBOOT packet
        //================================
        reset_dm_descriptor ();
        mt_usbtty_getcn (DM_SZ_REBOOT_STR, buffer);
        pkt_type = judge_pkt_type ((const void *) buffer);
        
        if (pkt_type == DM_PKT_REBT)
        {
            //print ("%s : received REBOOT packet\n", MOD);
            dm_ctx.dm_status = DM_STATUS_REBOOT;
        } 
        else   
        {
            //print ("%s : do not received REBOOT packet\n", MOD);
            dm_ctx.dm_status = DM_STATUS_START;
        }
    }
    else
    {
        dm_ctx.dm_status = DM_STATUS_START;
    }
}
Ejemplo n.º 2
0
static long pmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	long ret = 0;		/* , i=0; */
	ulong version = PT_SIG;

	void __user *uarg = (void __user *)arg;

	pr_debug("PMT IOCTL: Enter\n");


	if (false == g_bInitDone) {
		pr_debug("ERROR: NAND Flash Not initialized !!\n");
		ret = -EFAULT;
		goto exit;
	}

	switch (cmd) {
	case PMT_READ:
		pr_debug("PMT IOCTL: PMT_READ\n");
		ret = read_pmt(uarg);
		break;
	case PMT_WRITE:
		pr_debug("PMT IOCTL: PMT_WRITE\n");
		if (copy_from_user(&pmtctl, uarg, sizeof(DM_PARTITION_INFO_PACKET))) {
			ret = -EFAULT;
			goto exit;
		}
		new_part_tab((u8 *) &pmtctl, (struct mtd_info *)&host->mtd);
		update_part_tab((struct mtd_info *)&host->mtd);

		break;
	case PMT_VERSION:
		if (copy_to_user((void __user *)arg, &version, PT_SIG_SIZE))
			ret = -EFAULT;
		else
			ret = 0;
		break;
	default:
		ret = -EINVAL;
	}
exit:
	return ret;
}
Ejemplo n.º 3
0
static long pmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    long ret = 0;               // , i=0;

    void __user *uarg = (void __user *)arg;
    printk(KERN_INFO "PMT IOCTL: Enter\n");
    if (copy_from_user(&pmtctl, uarg, sizeof(DM_PARTITION_INFO_PACKET)))
    {
        ret = -EFAULT;
        goto exit;
    }

    if (false == g_bInitDone)
    {
        printk(KERN_INFO "ERROR: NAND Flash Not initialized !!\n");
        ret = -EFAULT;
        goto exit;
    }

    switch (cmd)
    {
      case PMT_READ:
          printk(KERN_INFO "PMT IOCTL: PMT_READ\n");

          break;
      case PMT_WRITE:
          printk(KERN_INFO "PMT IOCTL: PMT_WRITE\n");
          new_part_tab((u8 *) & pmtctl, (struct mtd_info *)&host->mtd);
          update_part_tab((struct mtd_info *)&host->mtd);

          break;
      default:
          ret = -EINVAL;
    }
  exit:
    return ret;
}