Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

mxc_scc.c File Reference


Detailed Description

This is the driver code for the Security Controller (SCC). It has no device driver interface, so no user programs may access it. Its interaction with the Linux kernel is from calls to scc_init() when the driver is loaded, and scc_cleanup() should the driver be unloaded. The driver uses locking and (task-sleep/task-wakeup) functions of the kernel. It also registers itself to handle the interrupt line(s) from the SCC.

Other drivers in the kernel may use the remaining API functions to get at the services of the SCC. The main service provided is the Secure Memory, which allows encoding and decoding of secrets with a per-chip secret key.

The SCC is single-threaded, and so is this module. When the scc_crypt() routine is called, it will lock out other accesses to the function. If another task is already in the module, the subsequent caller will spin on a lock waiting for the other access to finish.

Note that long crypto operations could cause a task to spin for a while, preventing other kernel work (other than interrupt processing) to get done.

The external (kernel module) interface is through the following functions:

All other functions are internal to the driver.

Definition in file mxc_scc.c.

#include "sahara2/include/fsl_platform.h"
#include "sahara2/include/portable_os.h"
#include "mxc_scc_internals.h"
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/err.h>

Go to the source code of this file.

Defines

#define SCM_ACCESS_ERRORS

Functions

static scc_return_t check_register_accessible (uint32_t register_offset, uint32_t smn_status, uint32_t scm_status)
static scc_return_t check_register_offset (uint32_t register_offset)
static uint32_t copy_from_scc (const uint32_t from, uint8_t *to, unsigned long count_bytes, uint16_t *crc)
static uint32_t copy_to_scc (const uint8_t *from, uint32_t to, unsigned long count_bytes, uint16_t *crc)
static int is_cipher_done (void)
static int offset_within_scm (uint32_t register_offset)
static int offset_within_smn (uint32_t register_offset)
 OS_DEV_ISR (scc_irq)
scc_return_t scc_alloc_slot (uint32_t value_size_bytes, uint64_t owner_id, uint32_t *slot)
static void scc_cleanup (void)
scc_return_t scc_crypt (unsigned long count_in_bytes, const uint8_t *data_in, const uint8_t *init_vector, scc_enc_dec_t direction, scc_crypto_mode_t crypto_mode, scc_verify_t check_mode, uint8_t *data_out, unsigned long *count_out_bytes)
scc_return_t scc_dealloc_slot (uint64_t owner_id, uint32_t slot)
static scc_return_t scc_decrypt (uint32_t count_in_bytes, const uint8_t *data_in, uint32_t scm_control, uint8_t *data_out, int verify_crc, unsigned long *count_out_bytes)
scc_return_t scc_decrypt_slot (uint64_t owner_id, uint32_t slot, uint32_t length, const uint8_t *black_data)
static uint32_t scc_do_crypto (int byte_count, uint32_t scm_control)
static scc_return_t scc_encrypt (uint32_t count_in_bytes, const uint8_t *data_in, uint32_t scm_control, uint8_t *data_out, int add_crc, unsigned long *count_out_bytes)
scc_return_t scc_encrypt_slot (uint64_t owner_id, uint32_t slot, uint32_t length, uint8_t *black_data)
scc_config_tscc_get_configuration (void)
scc_return_t scc_get_slot_info (uint64_t owner_id, uint32_t slot, uint32_t *address, uint32_t *value_size_bytes, uint32_t *slot_size_bytes)
static uint32_t scc_grab_config_values (void)
static int scc_init (void)
static void scc_init_ccitt_crc (void)
scc_return_t scc_load_slot (uint64_t owner_id, uint32_t slot, const uint8_t *key_data, uint32_t key_length)
scc_return_t scc_monitor_security_failure (void callback_func(void))
static void scc_perform_callbacks (void)
scc_return_t scc_read_register (int register_offset, uint32_t *value)
scc_return_t scc_read_slot (uint64_t owner_id, uint32_t slot, uint32_t key_length, uint8_t *key_data)
void scc_set_sw_alarm (void)
void scc_stop_monitoring_security_failure (void callback_func(void))
static scc_return_t scc_strip_padding (uint8_t *from, unsigned *count_bytes_stripped)
static uint32_t scc_update_state (void)
scc_return_t scc_verify_slot_access (uint64_t owner_id, uint32_t slot, uint32_t access_len)
static void scc_wait_completion (void)
scc_return_t scc_write_register (int register_offset, uint32_t value)
scc_return_t scc_zeroize_memories (void)
static int setup_interrupt_handling (void)
static scc_return_t verify_slot_access (uint64_t owner_id, uint32_t slot, uint32_t access_len)

Variables

static enum scc_status scc_availability = SCC_STATUS_INITIAL
static volatile void * scc_base
static uint8_t scc_block_padding [8]
static void(* scc_callbacks [SCC_CALLBACK_SIZE])(void)
static spinlock_t scc_callbacks_lock = SPIN_LOCK_UNLOCKED
static scc_config_t scc_configuration
static uint16_t scc_crc_lookup_table [256]
static spinlock_t scc_crypto_lock = SPIN_LOCK_UNLOCKED
static struct scc_key_slot scc_key_info [SCC_KEY_SLOTS]
static uint32_t scc_memory_size_bytes
static uint32_t scm_highest_memory_address
static int scm_irq_set = 0
static int smn_irq_set = 0


Generated by  Doxygen 1.6.0   Back to index