fsl_shw_return_t get_capabilities(fsl_shw_uco_t * user_ctx,
				  fsl_shw_pco_t * capabilities)
{
	scc_config_t *scc_capabilities;

	/* Fill in the Sahara2 capabilities. */
	memcpy(capabilities, &sahara2_capabilities, sizeof(fsl_shw_pco_t));

	/* Fill in the SCC portion of the capabilities object */
	scc_capabilities = scc_get_configuration();
	capabilities->scc_driver_major = scc_capabilities->driver_major_version;
	capabilities->scc_driver_minor = scc_capabilities->driver_minor_version;
	capabilities->scm_version = scc_capabilities->scm_version;
	capabilities->smn_version = scc_capabilities->smn_version;
	capabilities->block_size_bytes = scc_capabilities->block_size_bytes;

#ifdef FSL_HAVE_SCC
	capabilities->scc_info.black_ram_size_blocks =
	    scc_capabilities->black_ram_size_blocks;
	capabilities->scc_info.red_ram_size_blocks =
	    scc_capabilities->red_ram_size_blocks;
#elif defined(FSL_HAVE_SCC2)
	capabilities->scc2_info.partition_size_bytes =
	    scc_capabilities->partition_size_bytes;
	capabilities->scc2_info.partition_count =
	    scc_capabilities->partition_count;
#endif

	return FSL_RETURN_OK_S;
}
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 */

}
Example #3
0
/**
 * Internal routine to handle ioctl command #SCC2_GET_CONFIGURATION.
 *
 * @param scc_data Address is user space of scc_configuration_access
 * which is passed with the ioctl() system call.
 *
 * @return 0 on success, IOCTL_xxx on failure.
 *
 * This function does not access the SCC, it just passes up static,
 * previously retrieved information.
 *
 */
static int
scc2_test_get_configuration(unsigned long scc_data)
{
    int error_code = IOCTL_SCC2_OK;

#ifdef SCC2_DEBUG
    printk("SCC2 TEST: Configuration\n");
#endif

    /* now copy out (write) the data into user space */
    /** @todo make sure scc_get_configuration never returns null! */
    if (copy_to_user((void *)scc_data, scc_get_configuration(),
                     sizeof(scc_config_t))) {
#ifdef SCC2_DEBUG
        printk("SCC2 TEST: Error writing data to user\n");
#endif
        error_code = -IOCTL_SCC2_IMPROPER_ADDR;
    }

    return error_code;

} /* scc2_get_configuration */