Exemplo n.º 1
0
static int
scc2_test_alloc_part(unsigned long scc_data)
{
    scc_partition_access acc;
    int status;

    status = copy_from_user(&acc, (void*)scc_data, sizeof(acc));

    if (status == 0) {
        acc.scc_status = scc_allocate_partition(acc.smid,
                                                 &acc.part_no,
                                                 (void*)&acc.virt_address,
                                                 &acc.phys_address);
        status = copy_to_user((void*)scc_data, &acc, sizeof(acc));
    }

    return status;
}
void *fsl_shw_smalloc(fsl_shw_uco_t * user_ctx,
		      uint32_t size, const uint8_t * UMID, uint32_t permissions)
{
#ifdef FSL_HAVE_SCC2
	int part_no;
	void *part_base;
	uint32_t part_phys;
	scc_config_t *scc_configuration;

	/* Check that the memory size requested is correct */
	scc_configuration = scc_get_configuration();
	if (size != scc_configuration->partition_size_bytes) {
		return NULL;
	}

	/* Attempt to grab a partition. */
	if (scc_allocate_partition(0, &part_no, &part_base, &part_phys)
	    != SCC_RET_OK) {
		return NULL;
	}
	printk(KERN_ALERT "In fsh_shw_smalloc (km): partition_base:%p "
	       "partition_base_phys: %p\n", part_base, (void *)part_phys);

	/* these bits should be in a separate function */
	printk(KERN_ALERT "writing UMID and MAP to secure the partition\n");

	scc_engage_partition(part_base, UMID, permissions);

	(void)user_ctx;		/* unused param warning */

	return part_base;
#else				/* FSL_HAVE_SCC2 */
	(void)user_ctx;
	(void)size;
	(void)UMID;
	(void)permissions;
	return NULL;
#endif				/* FSL_HAVE_SCC2 */

}