linux/drivers/mxc/security/sahara2/sah_driver_interface.c File Reference

Provides a Linux Kernel Module interface to the SAHARA h/w device. More...

Defines

#define SAHARA_VERSION2   2
#define SAHARA_VERSION3   3
#define SAHARA_VERSION4   4

Functions

static int handle_sah_ioctl_dar (fsl_shw_uco_t *user_ctx, uint32_t user_space_desc)
 OS_DEV_INIT (sah_init)
 OS_DEV_SHUTDOWN (sah_cleanup)
 OS_DEV_OPEN (sah_open)
 OS_DEV_CLOSE (sah_release)
 OS_DEV_IOCTL (sah_ioctl)
 OS_DEV_MMAP (sah_mmap)
fsl_shw_return_t sah_handle_registration (fsl_shw_uco_t *user_ctx)
fsl_shw_return_t sah_handle_deregistration (fsl_shw_uco_t *user_ctx)
int sah_get_results_pointers (fsl_shw_uco_t *user_ctx, uint32_t arg)
fsl_shw_return_t sah_get_results_from_pool (volatile fsl_shw_uco_t *user_ctx, sah_results *arg)
int sah_blocking_mode (sah_Head_Desc *entry)
void sahara_timeout_handler (unsigned long data)

Variables

static unsigned interrupt_registered
static os_driver_reg_t reg_handle

Detailed Description

Provides a Linux Kernel Module interface to the SAHARA h/w device.


Define Documentation

#define SAHARA_VERSION2   2

Version register on first deployments

Referenced by OS_DEV_INIT().

#define SAHARA_VERSION3   3

Version register on MX27

Referenced by OS_DEV_INIT().

#define SAHARA_VERSION4   4

Version register on MXC92323

Referenced by OS_DEV_INIT().


Function Documentation

static int handle_sah_ioctl_dar ( fsl_shw_uco_t user_ctx,
uint32_t  user_space_desc 
) [static]

Submits converted descriptor chain to sahara.

Converts descriptor chain to kernel space (from user space) and submits chain to Sahara for processing

Parameters:
user_ctx Pointer to Kernel version of user's ctx
user_space_desc user space address of descriptor chain that is in user space
Returns:
OS status code

References fsl_shw_uco_t::callback, FSL_UCO_BLOCKING_MODE, FSL_UCO_CALLBACK_MODE, os_copy_to_user, OS_ERROR_FAIL_S, OS_ERROR_NO_MEMORY_S, OS_ERROR_OK_S, os_get_process_handle, sah_Head_Desc::result, sah_blocking_mode(), sah_Copy_Descriptors(), sah_Free_Chained_Descriptors(), sah_Queue_Manager_Append_Entry(), sah_Head_Desc::uco_flags, sah_Head_Desc::user_desc, and sah_Head_Desc::user_info.

Referenced by OS_DEV_IOCTL().

OS_DEV_CLOSE ( sah_release   ) 

SAHARA device release function.

This function simply decrements the module usage count.

Parameters:
inode Part of the kernel prototype.
file Part of the kernel prototype.
Returns:
0 - Always returns 0 since this function does not fail.

References os_dev_close_return, os_dev_get_user_private, os_dev_set_user_private, OS_ERROR_OK_S, os_free_memory, and sah_handle_deregistration().

OS_DEV_INIT ( sah_init   ) 

SAHARA device initialisation function.

This function gets called when the module is inserted (insmod) into the running kernel.

Returns:
0 on success
-EBUSY if the device or proc file entry cannot be created.
OS_ERROR_NO_MEMORY_S if kernel memory could not be allocated.
OS_ERROR_FAIL_S if initialisation of proc entry failed

References FSL_RETURN_OK_S, fsl_shw_establish_keystore(), fsl_shw_init_keystore_default(), interrupt_registered, OS_DEV_CLOSE_REF, os_dev_init_return, OS_DEV_IOCTL_REF, OS_DEV_MMAP_REF(), OS_DEV_OPEN_REF, os_driver_add_registration, os_driver_complete_registration, os_driver_init_registration, OS_ERROR_FAIL_S, OS_ERROR_OK_S, OS_FN_CLOSE, OS_FN_IOCTL, OS_FN_MMAP, OS_FN_OPEN, os_printk, sah_HW_Read_Version(), sah_HW_Reset(), sah_Init_Mem_Map(), sah_Intr_Init(), sah_Queue_Manager_Init(), SAHARA_VERSION2, SAHARA_VERSION3, and SAHARA_VERSION4.

OS_DEV_IOCTL ( sah_ioctl   ) 

SAHARA device IO Control function.

This function provides the IO Controls for the SAHARA driver. Three IO Controls are supported:

SAHARA_HWRESET and SAHARA_SET_HA SAHARA_CHK_TEST_MODE

Parameters:
inode Part of the kernel prototype.
filp Part of the kernel prototype.
cmd Part of the kernel prototype.
arg Part of the kernel prototype.
Returns:
0 on success
-EBUSY if the HA bit could not be set due to busy hardware.
-ENOTTY if an unsupported IOCTL was attempted on the device.
-EFAULT if put_user() fails

References handle_sah_ioctl_dar(), os_alloc_memory, os_copy_from_user, os_dev_get_ioctl_arg, os_dev_get_ioctl_op, os_dev_get_user_private, os_dev_ioctl_return, os_dev_set_user_private, OS_ERROR_FAIL_S, OS_ERROR_NO_MEMORY_S, os_free_memory, sah_get_results_pointers(), sah_handle_deregistration(), sah_handle_registration(), sah_HW_Reset(), sah_HW_Set_HA(), and sah_Queue_Manager_Reset_Entries().

OS_DEV_MMAP ( sah_mmap   ) 

This function implements the smalloc() function for userspace programs, by making a call to the SCC2 mmap() function that acquires a region of secure memory on behalf of the user, and then maps it into the users memory space. Currently, the only memory size supported is that of a single SCC2 partition. Requests for other sized memory regions will fail.

References FSL_RETURN_OK_S, map_user_memory(), os_alloc_memory, os_dev_get_user_private, os_dev_set_user_private, OS_ERROR_BAD_ARG_S, OS_ERROR_FAIL_S, OS_ERROR_NO_MEMORY_S, OS_ERROR_OK_S, sah_handle_registration(), and scc_get_configuration().

OS_DEV_OPEN ( sah_open   ) 

SAHARA device open function.

This function simply increments the module usage count.

Parameters:
inode Part of the kernel prototype.
file Part of the kernel prototype.
Returns:
0 - Always returns 0 since any number of calls to this function are allowed.

References os_dev_open_return, and os_dev_set_user_private.

OS_DEV_SHUTDOWN ( sah_cleanup   ) 

SAHARA device clean-up function.

This function gets called when the module is removed (rmmod) from the running kernel.

Returns:
void

References fsl_shw_release_keystore(), interrupt_registered, os_dev_shutdown_return, os_driver_remove_registration, sah_Intr_Release(), sah_Queue_Manager_Close(), and sah_Stop_Mem_Map().

int sah_blocking_mode ( sah_Head_Desc entry  ) 

SAHARA PROCFS read function.

This function is called when a thread attempts to read from the /proc/sahara file. Upon read, statistics and information about the state of the driver are returned in nthe supplied buffer.

Parameters:
buf Anything written to this buffer will be returned to the user-space process that is reading from this proc entry.
start Part of the kernel prototype.
offset Part of the kernel prototype.
count The size of the buf argument.
eof An integer which is set to one to tell the user-space process that there is no more data to read.
data Part of the kernel prototype.
Returns:
The number of bytes written to the proc entry.

Block user call until processing is complete.

Parameters:
entry The user's request.
Returns:
An OS error code, or 0 if no error

References desc_queue_lock, FSL_RETURN_INTERNAL_ERROR_S, main_queue, os_lock_save_context, os_unlock_restore_context, sah_Head_Desc::result, sah_DePhysicalise_Descriptors(), sah_Queue_Manager_Append_Entry(), and sah_Queue_Remove_Any_Entry().

Referenced by adaptor_Exec_Descriptor_Chain(), and handle_sah_ioctl_dar().

fsl_shw_return_t sah_get_results_from_pool ( volatile fsl_shw_uco_t user_ctx,
sah_results arg 
)

Extract results from results pool.

Extracts results from results pool

Parameters:
user_ctx information about this user
[in,out] arg contains input parameters and fields that the driver fills in
Returns:
status code

References sah_results::actual, desc_queue_lock, sah_Head_Desc::fault_address, FSL_RETURN_OK_S, os_lock_save_context, os_unlock_restore_context, sah_Head_Desc::result, sah_results::results, sah_DePhysicalise_Descriptors(), sah_Queue_Remove_Entry(), and sah_Head_Desc::user_ref.

Referenced by sah_get_results(), and sah_get_results_pointers().

int sah_get_results_pointers ( fsl_shw_uco_t user_ctx,
uint32_t  arg 
)

Sets up memory to extract results from results pool.

Sets up memory to extract results from results pool

Parameters:
user_ctx information about this user
[in,out] arg contains input parameters and fields that the driver fills in
Returns:
os error code or 0 on success

References sah_results::actual, FSL_RETURN_OK_S, os_alloc_memory, os_copy_from_user, os_copy_to_user, OS_ERROR_FAIL_S, OS_ERROR_NO_MEMORY_S, os_free_memory, sah_results::requested, sah_results::results, sah_Free_Chained_Descriptors(), sah_get_results_from_pool(), and sah_Head_Desc::user_desc.

Referenced by OS_DEV_IOCTL().

fsl_shw_return_t sah_handle_deregistration ( fsl_shw_uco_t user_ctx  ) 

Deregister a user.

Deregister a user

Parameters:
user_ctx information about this user
Returns:
status code

References FSL_RETURN_ERROR_S, FSL_RETURN_OK_S, fsl_shw_spo_t::kernel_base, OS_ERROR_OK_S, unmap_user_memory(), and fsl_shw_spo_t::user_base.

Referenced by OS_DEV_CLOSE(), OS_DEV_IOCTL(), and sah_deregister().

fsl_shw_return_t sah_handle_registration ( fsl_shw_uco_t user_ctx  ) 

Register a user.

Register a user

Parameters:
user_ctx information about this user
Returns:
status code

References FSL_RETURN_OK_S.

Referenced by OS_DEV_IOCTL(), OS_DEV_MMAP(), and sah_register().

void sahara_timeout_handler ( unsigned long  data  ) 

If interrupt does not return in a reasonable time, time out, trigger interrupt, and continue with process

Parameters:
data ignored

References sah_Handle_Interrupt().


Variable Documentation

unsigned interrupt_registered [static]

Boolean flag for whether interrupt handler needs to be released on exit

Referenced by OS_DEV_INIT(), and OS_DEV_SHUTDOWN().

OS-dependent handle used for registering user interface of a driver.

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen