Exemple #1
0
static ssize_t _osprd_write(struct file *filp, char __user *usr, size_t size,
			loff_t *loff) {
	osprd_info_t *d = file2osprd(filp);
	if (d == NULL) {
		return blkdev_write(filp, usr, size, loff);
	}

	char *buf  = (char*)kmalloc(size, GFP_KERNEL);
	if (buf == NULL) {
		return -ENOMEM;
	}

	if (copy_from_user(buf, usr, size) != 0) {
		kfree(buf);
		return -EFAULT;
	}
	//eprintk("WRITE buf: %s\npasswd_hash: %d\n", buf, d->passwd_hash);
	xor_cipher(buf, size, d->passwd_hash);
	//eprintk("WRITE buf: %s\npasswd_hash: %d\n", buf, d->passwd_hash);

	if (copy_to_user(usr, buf, size) != 0) {
		kfree(buf);
		return -EFAULT;
	}

	kfree(buf);
	return blkdev_write(filp, usr, size, loff);
}
Exemple #2
0
void sec_cfg_save (U8* src)
{
    U32 i       = 0;

    blkdev_t    *bootdev = NULL;


    /* --------------------- */
    /* write sec cfg          */
    /* --------------------- */

    SMSG("[%s] write '0x%x'\n",MOD,sec_cfg_info.addr);

    if (NULL == (bootdev = blkdev_get(CFG_BOOT_DEV))) 
    {
        SMSG("[%s] can't find boot device(%d)\n", MOD, CFG_BOOT_DEV);
        ASSERT(0);
    }
#ifndef MTK_EMMC_SUPPORT
    nand_erase_data(sec_cfg_info.addr, g_nand_chip.chipsize, get_sec_cfg_cnt_size());
#endif
    blkdev_write(bootdev, sec_cfg_info.addr, get_sec_cfg_cnt_size(), (u8*)src, sec_cfg_info.part_id);

    /* dump first 8 bytes for debugging */
    for(i=0;i<8;i++)
        SMSG("0x%x,",src[i]);
    SMSG("\n");
 
}
Exemple #3
0
/******************************************************************************
 *  WRITE IMAGE FOR S-BOOT USAGE (FROM NAND or eMMC DEVICE)
 ******************************************************************************/
static U32 sec_util_write_image (U8* img_name, U8 *buf, U32 offset, U32 size)
{
    BOOL ret            = SEC_OK;
    U32 i               = 0;
    U32 cnt             = 0;

    U32 now_offset      = 0;
    U32 total_pages     = 0;
    U32 start_offset    = offset;
    blkdev_t *bootdev   = NULL;
    part_t *part        = NULL;
    U64 dest;


    if (NULL == (bootdev = blkdev_get(CFG_BOOT_DEV))) 
    {
        SMSG("[%s] can't find boot device(%d)\n", MOD, CFG_BOOT_DEV);
        ASSERT(0);
    }

    /* ======================== */
    /* get part info            */
    /* ======================== */
    /* part_get should be device abstraction function */    
    if(NULL == (part = part_get (sec2plname(img_name))))
    {
        SMSG("[%s] part_get fail\n", MOD);
        ASSERT(0);        
    }

    /* ======================== */
    /* write part data           */
    /* ======================== */
    /* part_load should be device abstraction function */ 
    if(TRUE == bDumpPartInfo)
    {
        SMSG("[%s] part load '0x%x'\n", MOD, part->startblk * bootdev->blksz);
        bDumpPartInfo = FALSE;
    }
    dest = part->startblk * bootdev->blksz + offset;
    
    if (-1 == blkdev_write(bootdev, dest, size, buf))
    {
        SMSG("[%s] part_store fail\n", MOD);
        ASSERT(0);        
    }
    
    return ret;
}