Commit ff3d9c3c authored by Mark Allyn's avatar Mark Allyn Committed by Greg Kroah-Hartman

staging: sep: SEP update

This is basically a rewrite so there isn't a nice easy to present way of
providing this as a patch series. This patch is a pull of Mark's new driver into
the upstream staging area. On top of that are a series of patches by
Andy Shevchenko to make it build on the current tree, fix a few things and
even get it passed sparse.

The new driver supports the kernel crypto layer, passes the coding style checks,
passes human taste checks and has proper kernel-doc formatted comments.

I've then folded back in some later fixes it was missing that got applied to
to the kernel tree.

This should be ready for more serious review with a view to migration from
the staging tree shortly.
Signed-off-by: default avatarMark Allyn <mark.a.allyn@intel.com>
[Forward port and some bug fixing]
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
[Fold and tweaks for 3.2]
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent dcd6c922
......@@ -3,7 +3,8 @@ config DX_SEP
depends on PCI
help
Discretix SEP driver; used for the security processor subsystem
on bard the Intel Mobile Internet Device.
on board the Intel Mobile Internet Device and adds SEP availability
to the kernel crypto infrastructure
The driver's name is sep_driver.
......
obj-$(CONFIG_DX_SEP) := sep_driver.o
ccflags-y += -I$(srctree)/$(src)
obj-$(CONFIG_DX_SEP) += sep_driver.o
sep_driver-objs := sep_crypto.o sep_main.o
Todo's so far (from Alan Cox)
- Check whether it can be plugged into any of the kernel crypto API
interfaces - Crypto API 'glue' is still not ready to submit
- Clean up un-needed debug prints - Started to work on this
- Clean up unused ioctls
- Clean up unused fields in ioctl structures
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
*
* sep_crypto.h - Crypto interface structures
*
* Copyright(c) 2009-2011 Intel Corporation. All rights reserved.
* Contributions(c) 2009-2010 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Mark Allyn mark.a.allyn@intel.com
* Jayant Mangalampalli jayant.mangalampalli@intel.com
*
* CHANGES:
*
* 2009.06.26 Initial publish
* 2011.02.22 Enable Kernel Crypto
*
*/
/* Constants for SEP (from vendor) */
#define SEP_START_MSG_TOKEN 0x02558808
#define SEP_DES_IV_SIZE_WORDS 2
#define SEP_DES_IV_SIZE_BYTES (SEP_DES_IV_SIZE_WORDS * \
sizeof(u32))
#define SEP_DES_KEY_SIZE_WORDS 2
#define SEP_DES_KEY_SIZE_BYTES (SEP_DES_KEY_SIZE_WORDS * \
sizeof(u32))
#define SEP_DES_BLOCK_SIZE 8
#define SEP_DES_DUMMY_SIZE 16
#define SEP_DES_INIT_OPCODE 0x10
#define SEP_DES_BLOCK_OPCODE 0x11
#define SEP_AES_BLOCK_SIZE_WORDS 4
#define SEP_AES_BLOCK_SIZE_BYTES \
(SEP_AES_BLOCK_SIZE_WORDS * sizeof(u32))
#define SEP_AES_DUMMY_BLOCK_SIZE 16
#define SEP_AES_IV_SIZE_WORDS SEP_AES_BLOCK_SIZE_WORDS
#define SEP_AES_IV_SIZE_BYTES \
(SEP_AES_IV_SIZE_WORDS * sizeof(u32))
#define SEP_AES_KEY_128_SIZE 16
#define SEP_AES_KEY_192_SIZE 24
#define SEP_AES_KEY_256_SIZE 32
#define SEP_AES_KEY_512_SIZE 64
#define SEP_AES_MAX_KEY_SIZE_WORDS 16
#define SEP_AES_MAX_KEY_SIZE_BYTES \
(SEP_AES_MAX_KEY_SIZE_WORDS * sizeof(u32))
#define SEP_AES_WRAP_MIN_SIZE 8
#define SEP_AES_WRAP_MAX_SIZE 0x10000000
#define SEP_AES_WRAP_BLOCK_SIZE_WORDS 2
#define SEP_AES_WRAP_BLOCK_SIZE_BYTES \
(SEP_AES_WRAP_BLOCK_SIZE_WORDS * sizeof(u32))
#define SEP_AES_SECRET_RKEK1 0x1
#define SEP_AES_SECRET_RKEK2 0x2
#define SEP_AES_INIT_OPCODE 0x2
#define SEP_AES_BLOCK_OPCODE 0x3
#define SEP_AES_FINISH_OPCODE 0x4
#define SEP_AES_WRAP_OPCODE 0x6
#define SEP_AES_UNWRAP_OPCODE 0x7
#define SEP_AES_XTS_FINISH_OPCODE 0x8
#define SEP_HASH_RESULT_SIZE_WORDS 16
#define SEP_MD5_DIGEST_SIZE_WORDS 4
#define SEP_MD5_DIGEST_SIZE_BYTES \
(SEP_MD5_DIGEST_SIZE_WORDS * sizeof(u32))
#define SEP_SHA1_DIGEST_SIZE_WORDS 5
#define SEP_SHA1_DIGEST_SIZE_BYTES \
(SEP_SHA1_DIGEST_SIZE_WORDS * sizeof(u32))
#define SEP_SHA224_DIGEST_SIZE_WORDS 7
#define SEP_SHA224_DIGEST_SIZE_BYTES \
(SEP_SHA224_DIGEST_SIZE_WORDS * sizeof(u32))
#define SEP_SHA256_DIGEST_SIZE_WORDS 8
#define SEP_SHA256_DIGEST_SIZE_BYTES \
(SEP_SHA256_DIGEST_SIZE_WORDS * sizeof(u32))
#define SEP_SHA384_DIGEST_SIZE_WORDS 12
#define SEP_SHA384_DIGEST_SIZE_BYTES \
(SEP_SHA384_DIGEST_SIZE_WORDS * sizeof(u32))
#define SEP_SHA512_DIGEST_SIZE_WORDS 16
#define SEP_SHA512_DIGEST_SIZE_BYTES \
(SEP_SHA512_DIGEST_SIZE_WORDS * sizeof(u32))
#define SEP_HASH_BLOCK_SIZE_WORDS 16
#define SEP_HASH_BLOCK_SIZE_BYTES \
(SEP_HASH_BLOCK_SIZE_WORDS * sizeof(u32))
#define SEP_SHA2_BLOCK_SIZE_WORDS 32
#define SEP_SHA2_BLOCK_SIZE_BYTES \
(SEP_SHA2_BLOCK_SIZE_WORDS * sizeof(u32))
#define SEP_HASH_INIT_OPCODE 0x20
#define SEP_HASH_UPDATE_OPCODE 0x21
#define SEP_HASH_FINISH_OPCODE 0x22
#define SEP_HASH_SINGLE_OPCODE 0x23
#define SEP_HOST_ERROR 0x0b000000
#define SEP_OK 0x0
#define SEP_INVALID_START (SEP_HOST_ERROR + 0x3)
#define SEP_WRONG_OPCODE (SEP_HOST_ERROR + 0x1)
#define SEP_TRANSACTION_WAIT_TIME 5
#define SEP_QUEUE_LENGTH 10
/* Macros */
#ifndef __LITTLE_ENDIAN
#define CHG_ENDIAN(val) \
(((val) >> 24) | \
(((val) & 0x00FF0000) >> 8) | \
(((val) & 0x0000FF00) << 8) | \
(((val) & 0x000000FF) << 24))
#else
#define CHG_ENDIAN(val) val
#endif
/* Enums for SEP (from vendor) */
enum des_numkey {
DES_KEY_1 = 1,
DES_KEY_2 = 2,
DES_KEY_3 = 3,
SEP_NUMKEY_OPTIONS,
SEP_NUMKEY_LAST = 0x7fffffff,
};
enum des_enc_mode {
SEP_DES_ENCRYPT = 0,
SEP_DES_DECRYPT = 1,
SEP_DES_ENC_OPTIONS,
SEP_DES_ENC_LAST = 0x7fffffff,
};
enum des_op_mode {
SEP_DES_ECB = 0,
SEP_DES_CBC = 1,
SEP_OP_OPTIONS,
SEP_OP_LAST = 0x7fffffff,
};
enum aes_keysize {
AES_128 = 0,
AES_192 = 1,
AES_256 = 2,
AES_512 = 3,
AES_SIZE_OPTIONS,
AEA_SIZE_LAST = 0x7FFFFFFF,
};
enum aes_enc_mode {
SEP_AES_ENCRYPT = 0,
SEP_AES_DECRYPT = 1,
SEP_AES_ENC_OPTIONS,
SEP_AES_ENC_LAST = 0x7FFFFFFF,
};
enum aes_op_mode {
SEP_AES_ECB = 0,
SEP_AES_CBC = 1,
SEP_AES_MAC = 2,
SEP_AES_CTR = 3,
SEP_AES_XCBC = 4,
SEP_AES_CMAC = 5,
SEP_AES_XTS = 6,
SEP_AES_OP_OPTIONS,
SEP_AES_OP_LAST = 0x7FFFFFFF,
};
enum hash_op_mode {
SEP_HASH_SHA1 = 0,
SEP_HASH_SHA224 = 1,
SEP_HASH_SHA256 = 2,
SEP_HASH_SHA384 = 3,
SEP_HASH_SHA512 = 4,
SEP_HASH_MD5 = 5,
SEP_HASH_OPTIONS,
SEP_HASH_LAST_MODE = 0x7FFFFFFF,
};
/* Structures for SEP (from vendor) */
struct sep_des_internal_key {
u32 key1[SEP_DES_KEY_SIZE_WORDS];
u32 key2[SEP_DES_KEY_SIZE_WORDS];
u32 key3[SEP_DES_KEY_SIZE_WORDS];
};
struct sep_des_internal_context {
u32 iv_context[SEP_DES_IV_SIZE_WORDS];
struct sep_des_internal_key context_key;
enum des_numkey nbr_keys;
enum des_enc_mode encryption;
enum des_op_mode operation;
u8 dummy_block[SEP_DES_DUMMY_SIZE];
};
struct sep_des_private_context {
u32 valid_tag;
u32 iv;
u8 ctx_buf[sizeof(struct sep_des_internal_context)];
};
/* This is the structure passed to SEP via msg area */
struct sep_des_key {
u32 key1[SEP_DES_KEY_SIZE_WORDS];
u32 key2[SEP_DES_KEY_SIZE_WORDS];
u32 key3[SEP_DES_KEY_SIZE_WORDS];
u32 pad[SEP_DES_KEY_SIZE_WORDS];
};
struct sep_aes_internal_context {
u32 aes_ctx_iv[SEP_AES_IV_SIZE_WORDS];
u32 aes_ctx_key[SEP_AES_MAX_KEY_SIZE_WORDS / 2];
enum aes_keysize keysize;
enum aes_enc_mode encmode;
enum aes_op_mode opmode;
u8 secret_key;
u32 no_add_blocks;
u32 last_block_size;
u32 last_block[SEP_AES_BLOCK_SIZE_WORDS];
u32 prev_iv[SEP_AES_BLOCK_SIZE_WORDS];
u32 remaining_size;
union {
struct {
u32 dkey1[SEP_AES_BLOCK_SIZE_WORDS];
u32 dkey2[SEP_AES_BLOCK_SIZE_WORDS];
u32 dkey3[SEP_AES_BLOCK_SIZE_WORDS];
} cmac_data;
struct {
u32 xts_key[SEP_AES_MAX_KEY_SIZE_WORDS / 2];
u32 temp1[SEP_AES_BLOCK_SIZE_WORDS];
u32 temp2[SEP_AES_BLOCK_SIZE_WORDS];
} xtx_data;
} s_data;
u8 dummy_block[SEP_AES_DUMMY_BLOCK_SIZE];
};
struct sep_aes_private_context {
u32 valid_tag;
u32 aes_iv;
u32 op_mode;
u8 cbuff[sizeof(struct sep_aes_internal_context)];
};
struct sep_hash_internal_context {
u32 hash_result[SEP_HASH_RESULT_SIZE_WORDS];
enum hash_op_mode hash_opmode;
u32 previous_data[SEP_SHA2_BLOCK_SIZE_WORDS];
u16 prev_update_bytes;
u32 total_proc_128bit[4];
u16 op_mode_block_size;
u8 dummy_aes_block[SEP_AES_DUMMY_BLOCK_SIZE];
};
struct sep_hash_private_context {
u32 valid_tag;
u32 iv;
u8 internal_context[sizeof(struct sep_hash_internal_context)];
};
/* Context structures for crypto API */
struct sep_block_ctx {
struct sep_device *sep;
u32 done;
unsigned char iv[100];
enum des_enc_mode des_encmode;
enum des_op_mode des_opmode;
enum aes_enc_mode aes_encmode;
enum aes_op_mode aes_opmode;
u32 init_opcode;
u32 block_opcode;
size_t data_length;
size_t ivlen;
struct ablkcipher_walk walk;
struct sep_des_private_context des_private_ctx;
struct sep_aes_private_context aes_private_ctx;
};
struct sep_hash_ctx {
u32 done;
unsigned char *buf;
size_t buflen;
unsigned char *dgst;
int digest_size_words;
int digest_size_bytes;
int block_size_words;
int block_size_bytes;
struct scatterlist *sg;
enum hash_op_mode hash_opmode;
struct sep_hash_private_context hash_private_ctx;
};
struct sep_system_ctx {
struct sep_device *sep_used;
union key_t {
struct sep_des_key des;
u32 aes[SEP_AES_MAX_KEY_SIZE_WORDS];
} key;
int i_own_sep; /* Do I have custody of the sep? */
size_t keylen;
enum des_numkey des_nbr_keys;
enum aes_keysize aes_key_size;
u32 key_sent; /* Indicate if key is sent to sep */
u32 last_block; /* Indicate that this is the final block */
struct sep_call_status call_status;
struct build_dcb_struct_kernel dcb_input_data;
struct sep_dma_context *dma_ctx;
void *dmatables_region;
size_t nbytes;
struct sep_dcblock *dcb_region;
struct sep_queue_info *queue_elem;
int msg_len_words;
unsigned char msg[SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES];
void *msgptr;
struct scatterlist *src_sg;
struct scatterlist *dst_sg;
struct scatterlist *src_sg_hold;
struct scatterlist *dst_sg_hold;
struct ahash_request *current_hash_req;
struct ablkcipher_request *current_cypher_req;
enum type_of_request current_request;
enum hash_stage current_hash_stage;
int done_with_transaction;
unsigned long end_time;
};
/* work queue structures */
struct sep_work_struct {
struct work_struct work;
void (*callback)(void *);
void *data;
};
/* Functions */
int sep_crypto_setup(void);
void sep_crypto_takedown(void);
......@@ -5,8 +5,8 @@
*
* sep_dev.h - Security Processor Device Structures
*
* Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
* Contributions(c) 2009,2010 Discretix. All rights reserved.
* Copyright(c) 2009-2011 Intel Corporation. All rights reserved.
* Contributions(c) 2009-2011 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
......@@ -28,6 +28,7 @@
*
* CHANGES
* 2010.09.14 upgrade to Medfield
* 2011.02.22 enable kernel crypto
*/
struct sep_device {
......@@ -36,33 +37,21 @@ struct sep_device {
/* character device file */
struct cdev sep_cdev;
struct cdev sep_daemon_cdev;
struct cdev sep_singleton_cdev;
/* devices (using misc dev) */
struct miscdevice miscdev_sep;
struct miscdevice miscdev_singleton;
struct miscdevice miscdev_daemon;
/* major / minor numbers of device */
dev_t sep_devno;
dev_t sep_daemon_devno;
dev_t sep_singleton_devno;
struct mutex sep_mutex;
struct mutex ioctl_mutex;
/* guards command sent counter */
spinlock_t snd_rply_lck;
/* guards driver memory usage in fastcall if */
struct semaphore sep_doublebuf;
/* flags to indicate use and lock status of sep */
u32 pid_doing_transaction;
unsigned long in_use_flags;
/* request daemon alread open */
unsigned long request_daemon_open;
/* 1 = Moorestown; 0 = Medfield */
int mrst;
/* address of the shared memory allocated during init for SEP driver
(coherent alloc) */
dma_addr_t shared_bus;
......@@ -74,36 +63,78 @@ struct sep_device {
dma_addr_t reg_physical_end;
void __iomem *reg_addr;
/* wait queue head (event) of the driver */
wait_queue_head_t event;
wait_queue_head_t event_request_daemon;
wait_queue_head_t event_mmap;
/* wait queue heads of the driver */
wait_queue_head_t event_interrupt;
wait_queue_head_t event_transactions;
struct sep_caller_id_entry
caller_id_table[SEP_CALLER_ID_TABLE_NUM_ENTRIES];
struct list_head sep_queue_status;
u32 sep_queue_num;
spinlock_t sep_queue_lock;
/* access flag for singleton device */
unsigned long singleton_access_flag;
/* Is this in use? */
u32 in_use;
/* indicates whether power save is set up */
u32 power_save_setup;
/* Power state */
u32 power_state;
/* transaction counter that coordinates the
transactions between SEP and HOST */
unsigned long send_ct;
/* counter for the messages from sep */
unsigned long reply_ct;
/* counter for the number of bytes allocated in the pool for the
current transaction */
long data_pool_bytes_allocated;
u32 num_of_data_allocations;
/* The following are used for kernel crypto client requests */
u32 in_kernel; /* Set for kernel client request */
struct tasklet_struct finish_tasklet;
enum type_of_request current_request;
enum hash_stage current_hash_stage;
struct ahash_request *current_hash_req;
struct ablkcipher_request *current_cypher_req;
struct sep_system_ctx *sctx;
spinlock_t busy_lock;
struct workqueue_struct *workqueue;
};
/* number of the lli tables created in the current transaction */
u32 num_lli_tables_created;
extern struct sep_device *sep_dev;
/* number of data control blocks */
u32 nr_dcb_creat;
/**
* SEP message header for a transaction
* @reserved: reserved memory (two words)
* @token: SEP message token
* @msg_len: message length
* @opcpde: message opcode
*/
struct sep_msgarea_hdr {
u32 reserved[2];
u32 token;
u32 msg_len;
u32 opcode;
};
struct sep_dma_resource dma_res_arr[SEP_MAX_NUM_SYNC_DMA_OPS];
/**
* sep_queue_data - data to be maintained in status queue for a transaction
* @opcode : transaction opcode
* @size : message size
* @pid: owner process
* @name: owner process name
*/
struct sep_queue_data {
u32 opcode;
u32 size;
s32 pid;
u8 name[TASK_COMM_LEN];
};
/** sep_queue_info - maintains status info of all transactions
* @list: head of list
* @sep_queue_data : data for transaction
*/
struct sep_queue_info {
struct list_head list;
struct sep_queue_data data;
};
static inline void sep_write_reg(struct sep_device *dev, int reg, u32 value)
......
......@@ -2,8 +2,8 @@
*
* sep_driver_api.h - Security Processor Driver api definitions
*
* Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
* Contributions(c) 2009,2010 Discretix. All rights reserved.
* Copyright(c) 2009-2011 Intel Corporation. All rights reserved.
* Contributions(c) 2009-2011 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
......@@ -26,6 +26,7 @@
* CHANGES:
*
* 2010.09.14 Upgrade to Medfield
* 2011.02.22 Enable kernel crypto
*
*/
......@@ -37,26 +38,30 @@
#define SEP_DRIVER_SRC_REQ 2
#define SEP_DRIVER_SRC_PRINTF 3
/*-------------------------------------------
TYPEDEFS
----------------------------------------------*/
struct alloc_struct {
/* offset from start of shared pool area */
u32 offset;
/* number of bytes to allocate */
u32 num_bytes;
};
/* command struct for getting caller id value and address */
struct caller_id_struct {
/* pid of the process */
u32 pid;
/* virtual address of the caller id hash */
aligned_u64 callerIdAddress;
/* caller id hash size in bytes */
u32 callerIdSizeInBytes;
/* Power state */
#define SEP_DRIVER_POWERON 1
#define SEP_DRIVER_POWEROFF 2
/* Following enums are used only for kernel crypto api */
enum type_of_request {
NO_REQUEST,
AES_CBC,
AES_ECB,
DES_CBC,
DES_ECB,
DES3_ECB,
DES3_CBC,
SHA1,
MD5,
SHA224,
SHA256
};
enum hash_stage {
HASH_INIT,
HASH_UPDATE,
HASH_FINISH,
HASH_DIGEST
};
/*
......@@ -83,11 +88,6 @@ struct sep_dcblock {
u8 tail_data[68];
};
struct sep_caller_id_entry {
int pid;
unsigned char callerIdHash[SEP_CALLER_ID_HASH_SIZE_IN_BYTES];
};
/*
command structure for building dcb block (currently for ext app only
*/
......@@ -104,6 +104,33 @@ struct build_dcb_struct {
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
u32 tail_block_size;
/* which application calls the driver DX or applet */
u32 is_applet;
};
/*
command structure for building dcb block for kernel crypto
*/
struct build_dcb_struct_kernel {
/* address value of the data in */
void *app_in_address;
/* size of data in */
ssize_t data_in_size;
/* address of the data out */
void *app_out_address;
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
u32 block_size;
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
u32 tail_block_size;
/* which application calls the driver DX or applet */
u32 is_applet;
struct scatterlist *src_sg;
struct scatterlist *dst_sg;
};
/**
......@@ -147,6 +174,10 @@ struct sep_dma_resource {
/* number of entries of the output mapp array */
u32 out_map_num_entries;
/* Scatter list for kernel operations */
struct scatterlist *src_sg;
struct scatterlist *dst_sg;
};
......@@ -169,10 +200,173 @@ struct sep_lli_entry {
u32 block_size;
};
/*----------------------------------------------------------------
IOCTL command defines
-----------------------------------------------------------------*/
/*
* header format for each fastcall write operation
*/
struct sep_fastcall_hdr {
u32 magic;
u32 msg_len;
u32 num_dcbs;
};
/*
* structure used in file pointer's private data field
* to track the status of the calls to the various
* driver interface
*/
struct sep_call_status {
unsigned long status;
};
/*
* format of dma context buffer used to store all DMA-related
* context information of a particular transaction
*/
struct sep_dma_context {
/* number of data control blocks */
u32 nr_dcb_creat;
/* number of the lli tables created in the current transaction */
u32 num_lli_tables_created;
/* size of currently allocated dma tables region */
u32 dmatables_len;
/* size of input data */
u32 input_data_len;
struct sep_dma_resource dma_res_arr[SEP_MAX_NUM_SYNC_DMA_OPS];
/* Scatter gather for kernel crypto */
struct scatterlist *src_sg;
struct scatterlist *dst_sg;
};
/*
* format for file pointer's private_data field
*/
struct sep_private_data {
struct sep_queue_info *my_queue_elem;
struct sep_device *device;
struct sep_call_status call_status;
struct sep_dma_context *dma_ctx;
};
/* Functions used by sep_crypto */
/**
* sep_queue_status_remove - Removes transaction from status queue
* @sep: SEP device
* @sep_queue_info: pointer to status queue
*
* This function will removes information about transaction from the queue.
*/
void sep_queue_status_remove(struct sep_device *sep,
struct sep_queue_info **queue_elem);
/**
* sep_queue_status_add - Adds transaction to status queue
* @sep: SEP device
* @opcode: transaction opcode
* @size: input data size
* @pid: pid of current process
* @name: current process name
* @name_len: length of name (current process)
*
* This function adds information about about transaction started to the status
* queue.
*/
struct sep_queue_info *sep_queue_status_add(
struct sep_device *sep,
u32 opcode,
u32 size,
u32 pid,
u8 *name, size_t name_len);
/**
* sep_create_dcb_dmatables_context_kernel - Creates DCB & MLLI/DMA table context
* for kernel crypto
* @sep: SEP device
* @dcb_region: DCB region buf to create for current transaction
* @dmatables_region: MLLI/DMA tables buf to create for current transaction
* @dma_ctx: DMA context buf to create for current transaction
* @user_dcb_args: User arguments for DCB/MLLI creation
* @num_dcbs: Number of DCBs to create
*/
int sep_create_dcb_dmatables_context_kernel(struct sep_device *sep,
struct sep_dcblock **dcb_region,
void **dmatables_region,
struct sep_dma_context **dma_ctx,
const struct build_dcb_struct_kernel *dcb_data,
const u32 num_dcbs);
/**
* sep_activate_dcb_dmatables_context - Takes DCB & DMA tables
* contexts into use
* @sep: SEP device
* @dcb_region: DCB region copy
* @dmatables_region: MLLI/DMA tables copy
* @dma_ctx: DMA context for current transaction
*/
ssize_t sep_activate_dcb_dmatables_context(struct sep_device *sep,
struct sep_dcblock **dcb_region,
void **dmatables_region,
struct sep_dma_context *dma_ctx);
/**
* sep_prepare_input_output_dma_table_in_dcb - prepare control blocks
* @app_in_address: unsigned long; for data buffer in (user space)
* @app_out_address: unsigned long; for data buffer out (user space)
* @data_in_size: u32; for size of data
* @block_size: u32; for block size
* @tail_block_size: u32; for size of tail block
* @isapplet: bool; to indicate external app
* @is_kva: bool; kernel buffer; only used for kernel crypto module
*
* This function prepares the linked DMA tables and puts the
* address for the linked list of tables inta a DCB (data control
* block) the address of which is known by the SEP hardware
* Note that all bus addresses that are passed to the SEP
* are in 32 bit format; the SEP is a 32 bit device
*/
int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
unsigned long app_in_address,
unsigned long app_out_address,
u32 data_in_size,
u32 block_size,
u32 tail_block_size,
bool isapplet,
bool is_kva,
struct sep_dcblock *dcb_region,
void **dmatables_region,
struct sep_dma_context **dma_ctx,
struct scatterlist *src_sg,
struct scatterlist *dst_sg);
/**
* sep_free_dma_table_data_handler - free DMA table
* @sep: pointere to struct sep_device
* @dma_ctx: dma context
*
* Handles the request to free DMA table for synchronic actions
*/
int sep_free_dma_table_data_handler(struct sep_device *sep,
struct sep_dma_context **dma_ctx);
/**
* sep_send_command_handler - kick off a command
* @sep: SEP being signalled
*
* This function raises interrupt to SEP that signals that is has a new
* command from the host
*
* Note that this function does fall under the ioctl lock
*/
int sep_send_command_handler(struct sep_device *sep);
/**
* sep_wait_transaction - Used for synchronizing transactions
* @sep: SEP device
*/
int sep_wait_transaction(struct sep_device *sep);
/**
* IOCTL command defines
*/
/* magic number 1 of the sep IOCTL command */
#define SEP_IOC_MAGIC_NUMBER 's'
......@@ -180,36 +374,16 @@ struct sep_lli_entry {
#define SEP_IOCSENDSEPCOMMAND \
_IO(SEP_IOC_MAGIC_NUMBER, 0)
/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPRPLYCOMMAND \
_IO(SEP_IOC_MAGIC_NUMBER, 1)
/* allocate memory in data pool */
#define SEP_IOCALLOCDATAPOLL \
_IOW(SEP_IOC_MAGIC_NUMBER, 2, struct alloc_struct)
/* free dynamic data aalocated during table creation */
#define SEP_IOCFREEDMATABLEDATA \
_IO(SEP_IOC_MAGIC_NUMBER, 7)
/* get the static pool area addersses (physical and virtual) */
#define SEP_IOCGETSTATICPOOLADDR \
_IO(SEP_IOC_MAGIC_NUMBER, 8)
/* end transaction command */
#define SEP_IOCENDTRANSACTION \
_IO(SEP_IOC_MAGIC_NUMBER, 15)
#define SEP_IOCRARPREPAREMESSAGE \
_IOW(SEP_IOC_MAGIC_NUMBER, 20, struct rar_hndl_to_bus_struct)
#define SEP_IOCTLSETCALLERID \
_IOW(SEP_IOC_MAGIC_NUMBER, 34, struct caller_id_struct)
#define SEP_IOCPREPAREDCB \
_IOW(SEP_IOC_MAGIC_NUMBER, 35, struct build_dcb_struct)
#define SEP_IOCFREEDCB \
_IO(SEP_IOC_MAGIC_NUMBER, 36)
struct sep_device;
#endif
......@@ -2,8 +2,8 @@
*
* sep_driver_config.h - Security Processor Driver configuration
*
* Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
* Contributions(c) 2009,2010 Discretix. All rights reserved.
* Copyright(c) 2009-2011 Intel Corporation. All rights reserved.
* Contributions(c) 2009-2011 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
......@@ -26,6 +26,7 @@
* CHANGES:
*
* 2010.06.26 Upgrade to Medfield
* 2011.02.22 Enable kernel crypto
*
*/
......@@ -48,6 +49,8 @@
/* the mode for running on the ARM1172 Evaluation platform (flag is 1) */
#define SEP_DRIVER_ARM_DEBUG_MODE 0
/* Critical message area contents for sanity checking */
#define SEP_START_MSG_TOKEN 0x02558808
/*-------------------------------------------
INTERNAL DATA CONFIGURATION
-------------------------------------------*/
......@@ -65,21 +68,17 @@
#define SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE 16
/* flag that signifies tah the lock is
currently held by the process (struct file) */
currently held by the proccess (struct file) */
#define SEP_DRIVER_OWN_LOCK_FLAG 1
/* flag that signifies tah the lock is currently NOT
held by the process (struct file) */
held by the proccess (struct file) */
#define SEP_DRIVER_DISOWN_LOCK_FLAG 0
/* indicates whether driver has mapped/unmapped shared area */
#define SEP_REQUEST_DAEMON_MAPPED 1
#define SEP_REQUEST_DAEMON_UNMAPPED 0
#define SEP_DEV_NAME "sep_sec_driver"
#define SEP_DEV_SINGLETON "sep_sec_singleton_driver"
#define SEP_DEV_DAEMON "sep_req_daemon_driver"
/*--------------------------------------------------------
SHARED AREA memory total size is 36K
it is divided is following:
......@@ -90,7 +89,7 @@ held by the process (struct file) */
}
DATA_POOL_AREA 12K }
SYNCHRONIC_DMA_TABLES_AREA 5K
SYNCHRONIC_DMA_TABLES_AREA 29K
placeholder until drver changes
FLOW_DMA_TABLES_AREA 4K
......@@ -108,6 +107,12 @@ held by the process (struct file) */
#define SEP_DEV_DAEMON "sep_req_daemon_driver"
/*
the minimum length of the message - includes 2 reserved fields
at the start, then token, message size and opcode fields. all dwords
*/
#define SEP_DRIVER_MIN_MESSAGE_SIZE_IN_BYTES (5*sizeof(u32))
/*
the maximum length of the message - the rest of the message shared
area will be dedicated to the dma lli tables
......@@ -124,7 +129,7 @@ held by the process (struct file) */
#define SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES (16 * 1024)
/* the size of the message shared area in pages */
#define SYNCHRONIC_DMA_TABLES_AREA_SIZE_BYTES (1024 * 5)
#define SYNCHRONIC_DMA_TABLES_AREA_SIZE_BYTES (1024 * 29)
/* Placeholder until driver changes */
#define SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES (1024 * 4)
......@@ -132,6 +137,9 @@ held by the process (struct file) */
/* system data (time, caller id etc') pool */
#define SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES (1024 * 3)
/* Offset of the sep printf buffer in the message area */
#define SEP_DRIVER_PRINTF_OFFSET_IN_BYTES (5888)
/* the size in bytes of the time memory */
#define SEP_DRIVER_TIME_MEMORY_SIZE_IN_BYTES 8
......@@ -223,10 +231,10 @@ held by the process (struct file) */
#define SEP_ALREADY_INITIALIZED_ERR 12
/* bit that locks access to the shared area */
#define SEP_MMAP_LOCK_BIT 0
#define SEP_TRANSACTION_STARTED_LOCK_BIT 0
/* bit that lock access to the poll - after send_command */
#define SEP_SEND_MSG_LOCK_BIT 1
#define SEP_WORKING_LOCK_BIT 1
/* the token that defines the static pool address address */
#define SEP_STATIC_POOL_VAL_TOKEN 0xABBAABBA
......@@ -240,4 +248,51 @@ held by the process (struct file) */
/* Time limit for SEP to finish */
#define WAIT_TIME 10
/* Delay for pm runtime suspend (reduces pm thrashing with bursty traffic */
#define SUSPEND_DELAY 10
/* Number of delays to wait until scu boots after runtime resume */
#define SCU_DELAY_MAX 50
/* Delay for each iteration (usec) wait for scu boots after runtime resume */
#define SCU_DELAY_ITERATION 10
/*
* Bits used in struct sep_call_status to check that
* driver's APIs are called in valid order
*/
/* Bit offset which indicates status of sep_write() */
#define SEP_FASTCALL_WRITE_DONE_OFFSET 0
/* Bit offset which indicates status of sep_mmap() */
#define SEP_LEGACY_MMAP_DONE_OFFSET 1
/* Bit offset which indicates status of the SEP_IOCSENDSEPCOMMAND ioctl */
#define SEP_LEGACY_SENDMSG_DONE_OFFSET 2
/* Bit offset which indicates status of sep_poll() */
#define SEP_LEGACY_POLL_DONE_OFFSET 3
/* Bit offset which indicates status of the SEP_IOCENDTRANSACTION ioctl */
#define SEP_LEGACY_ENDTRANSACTION_DONE_OFFSET 4
/*
* Used to limit number of concurrent processes
* allowed to allocte dynamic buffers in fastcall
* interface.
*/
#define SEP_DOUBLEBUF_USERS_LIMIT 3
/* Identifier for valid fastcall header */
#define SEP_FC_MAGIC 0xFFAACCAA
/*
* Used for enabling driver runtime power management.
* Useful for enabling/disabling it during performance
* testing
*/
#define SEP_ENABLE_RUNTIME_PM
#endif /* SEP DRIVER CONFIG */
......@@ -2,8 +2,8 @@
*
* sep_driver_hw_defs.h - Security Processor Driver hardware definitions
*
* Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
* Contributions(c) 2009,2010 Discretix. All rights reserved.
* Copyright(c) 2009-2011 Intel Corporation. All rights reserved.
* Contributions(c) 2009-2011 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
......@@ -26,6 +26,7 @@
* CHANGES:
*
* 2010.09.20 Upgrade to Medfield
* 2011.02.22 Enable kernel crypto
*
*/
......@@ -42,181 +43,9 @@
/* cf registers */
#define HW_R0B_ADDR_0_REG_ADDR 0x0000UL
#define HW_R0B_ADDR_1_REG_ADDR 0x0004UL
#define HW_R0B_ADDR_2_REG_ADDR 0x0008UL
#define HW_R0B_ADDR_3_REG_ADDR 0x000cUL
#define HW_R0B_ADDR_4_REG_ADDR 0x0010UL
#define HW_R0B_ADDR_5_REG_ADDR 0x0014UL
#define HW_R0B_ADDR_6_REG_ADDR 0x0018UL
#define HW_R0B_ADDR_7_REG_ADDR 0x001cUL
#define HW_R0B_ADDR_8_REG_ADDR 0x0020UL
#define HW_R2B_ADDR_0_REG_ADDR 0x0080UL
#define HW_R2B_ADDR_1_REG_ADDR 0x0084UL
#define HW_R2B_ADDR_2_REG_ADDR 0x0088UL
#define HW_R2B_ADDR_3_REG_ADDR 0x008cUL
#define HW_R2B_ADDR_4_REG_ADDR 0x0090UL
#define HW_R2B_ADDR_5_REG_ADDR 0x0094UL
#define HW_R2B_ADDR_6_REG_ADDR 0x0098UL
#define HW_R2B_ADDR_7_REG_ADDR 0x009cUL
#define HW_R2B_ADDR_8_REG_ADDR 0x00a0UL
#define HW_R3B_REG_ADDR 0x00C0UL
#define HW_R4B_REG_ADDR 0x0100UL
#define HW_CSA_ADDR_0_REG_ADDR 0x0140UL
#define HW_CSA_ADDR_1_REG_ADDR 0x0144UL
#define HW_CSA_ADDR_2_REG_ADDR 0x0148UL
#define HW_CSA_ADDR_3_REG_ADDR 0x014cUL
#define HW_CSA_ADDR_4_REG_ADDR 0x0150UL
#define HW_CSA_ADDR_5_REG_ADDR 0x0154UL
#define HW_CSA_ADDR_6_REG_ADDR 0x0158UL
#define HW_CSA_ADDR_7_REG_ADDR 0x015cUL
#define HW_CSA_ADDR_8_REG_ADDR 0x0160UL
#define HW_CSA_REG_ADDR 0x0140UL
#define HW_SINB_REG_ADDR 0x0180UL
#define HW_SOUTB_REG_ADDR 0x0184UL
#define HW_PKI_CONTROL_REG_ADDR 0x01C0UL
#define HW_PKI_STATUS_REG_ADDR 0x01C4UL
#define HW_PKI_BUSY_REG_ADDR 0x01C8UL
#define HW_PKI_A_1025_REG_ADDR 0x01CCUL
#define HW_PKI_SDMA_CTL_REG_ADDR 0x01D0UL
#define HW_PKI_SDMA_OFFSET_REG_ADDR 0x01D4UL
#define HW_PKI_SDMA_POINTERS_REG_ADDR 0x01D8UL
#define HW_PKI_SDMA_DLENG_REG_ADDR 0x01DCUL
#define HW_PKI_SDMA_EXP_POINTERS_REG_ADDR 0x01E0UL
#define HW_PKI_SDMA_RES_POINTERS_REG_ADDR 0x01E4UL
#define HW_PKI_CLR_REG_ADDR 0x01E8UL
#define HW_PKI_SDMA_BUSY_REG_ADDR 0x01E8UL
#define HW_PKI_SDMA_FIRST_EXP_N_REG_ADDR 0x01ECUL
#define HW_PKI_SDMA_MUL_BY1_REG_ADDR 0x01F0UL
#define HW_PKI_SDMA_RMUL_SEL_REG_ADDR 0x01F4UL
#define HW_DES_KEY_0_REG_ADDR 0x0208UL
#define HW_DES_KEY_1_REG_ADDR 0x020CUL
#define HW_DES_KEY_2_REG_ADDR 0x0210UL
#define HW_DES_KEY_3_REG_ADDR 0x0214UL
#define HW_DES_KEY_4_REG_ADDR 0x0218UL
#define HW_DES_KEY_5_REG_ADDR 0x021CUL
#define HW_DES_CONTROL_0_REG_ADDR 0x0220UL
#define HW_DES_CONTROL_1_REG_ADDR 0x0224UL
#define HW_DES_IV_0_REG_ADDR 0x0228UL
#define HW_DES_IV_1_REG_ADDR 0x022CUL
#define HW_AES_KEY_0_ADDR_0_REG_ADDR 0x0400UL
#define HW_AES_KEY_0_ADDR_1_REG_ADDR 0x0404UL
#define HW_AES_KEY_0_ADDR_2_REG_ADDR 0x0408UL
#define HW_AES_KEY_0_ADDR_3_REG_ADDR 0x040cUL
#define HW_AES_KEY_0_ADDR_4_REG_ADDR 0x0410UL
#define HW_AES_KEY_0_ADDR_5_REG_ADDR 0x0414UL
#define HW_AES_KEY_0_ADDR_6_REG_ADDR 0x0418UL
#define HW_AES_KEY_0_ADDR_7_REG_ADDR 0x041cUL
#define HW_AES_KEY_0_REG_ADDR 0x0400UL
#define HW_AES_IV_0_ADDR_0_REG_ADDR 0x0440UL
#define HW_AES_IV_0_ADDR_1_REG_ADDR 0x0444UL
#define HW_AES_IV_0_ADDR_2_REG_ADDR 0x0448UL
#define HW_AES_IV_0_ADDR_3_REG_ADDR 0x044cUL
#define HW_AES_IV_0_REG_ADDR 0x0440UL
#define HW_AES_CTR1_ADDR_0_REG_ADDR 0x0460UL
#define HW_AES_CTR1_ADDR_1_REG_ADDR 0x0464UL
#define HW_AES_CTR1_ADDR_2_REG_ADDR 0x0468UL
#define HW_AES_CTR1_ADDR_3_REG_ADDR 0x046cUL
#define HW_AES_CTR1_REG_ADDR 0x0460UL
#define HW_AES_SK_REG_ADDR 0x0478UL
#define HW_AES_MAC_OK_REG_ADDR 0x0480UL
#define HW_AES_PREV_IV_0_ADDR_0_REG_ADDR 0x0490UL
#define HW_AES_PREV_IV_0_ADDR_1_REG_ADDR 0x0494UL
#define HW_AES_PREV_IV_0_ADDR_2_REG_ADDR 0x0498UL
#define HW_AES_PREV_IV_0_ADDR_3_REG_ADDR 0x049cUL
#define HW_AES_PREV_IV_0_REG_ADDR 0x0490UL
#define HW_AES_CONTROL_REG_ADDR 0x04C0UL
#define HW_HASH_H0_REG_ADDR 0x0640UL
#define HW_HASH_H1_REG_ADDR 0x0644UL
#define HW_HASH_H2_REG_ADDR 0x0648UL
#define HW_HASH_H3_REG_ADDR 0x064CUL
#define HW_HASH_H4_REG_ADDR 0x0650UL
#define HW_HASH_H5_REG_ADDR 0x0654UL
#define HW_HASH_H6_REG_ADDR 0x0658UL
#define HW_HASH_H7_REG_ADDR 0x065CUL
#define HW_HASH_H8_REG_ADDR 0x0660UL
#define HW_HASH_H9_REG_ADDR 0x0664UL
#define HW_HASH_H10_REG_ADDR 0x0668UL
#define HW_HASH_H11_REG_ADDR 0x066CUL
#define HW_HASH_H12_REG_ADDR 0x0670UL
#define HW_HASH_H13_REG_ADDR 0x0674UL
#define HW_HASH_H14_REG_ADDR 0x0678UL
#define HW_HASH_H15_REG_ADDR 0x067CUL
#define HW_HASH_CONTROL_REG_ADDR 0x07C0UL
#define HW_HASH_PAD_EN_REG_ADDR 0x07C4UL
#define HW_HASH_PAD_CFG_REG_ADDR 0x07C8UL
#define HW_HASH_CUR_LEN_0_REG_ADDR 0x07CCUL
#define HW_HASH_CUR_LEN_1_REG_ADDR 0x07D0UL
#define HW_HASH_CUR_LEN_2_REG_ADDR 0x07D4UL
#define HW_HASH_CUR_LEN_3_REG_ADDR 0x07D8UL
#define HW_HASH_PARAM_REG_ADDR 0x07DCUL
#define HW_HASH_INT_BUSY_REG_ADDR 0x07E0UL
#define HW_HASH_SW_RESET_REG_ADDR 0x07E4UL
#define HW_HASH_ENDIANESS_REG_ADDR 0x07E8UL
#define HW_HASH_DATA_REG_ADDR 0x07ECUL
#define HW_DRNG_CONTROL_REG_ADDR 0x0800UL
#define HW_DRNG_VALID_REG_ADDR 0x0804UL
#define HW_DRNG_DATA_REG_ADDR 0x0808UL
#define HW_RND_SRC_EN_REG_ADDR 0x080CUL
#define HW_AES_CLK_ENABLE_REG_ADDR 0x0810UL
#define HW_DES_CLK_ENABLE_REG_ADDR 0x0814UL
#define HW_HASH_CLK_ENABLE_REG_ADDR 0x0818UL
#define HW_PKI_CLK_ENABLE_REG_ADDR 0x081CUL
#define HW_CLK_STATUS_REG_ADDR 0x0824UL
#define HW_CLK_ENABLE_REG_ADDR 0x0828UL
#define HW_DRNG_SAMPLE_REG_ADDR 0x0850UL
#define HW_RND_SRC_CTL_REG_ADDR 0x0858UL
#define HW_CRYPTO_CTL_REG_ADDR 0x0900UL
#define HW_CRYPTO_STATUS_REG_ADDR 0x090CUL
#define HW_CRYPTO_BUSY_REG_ADDR 0x0910UL
#define HW_AES_BUSY_REG_ADDR 0x0914UL
#define HW_DES_BUSY_REG_ADDR 0x0918UL
#define HW_HASH_BUSY_REG_ADDR 0x091CUL
#define HW_CONTENT_REG_ADDR 0x0924UL
#define HW_VERSION_REG_ADDR 0x0928UL
#define HW_CONTEXT_ID_REG_ADDR 0x0930UL
#define HW_DIN_BUFFER_REG_ADDR 0x0C00UL
#define HW_DIN_MEM_DMA_BUSY_REG_ADDR 0x0c20UL
#define HW_SRC_LLI_MEM_ADDR_REG_ADDR 0x0c24UL
#define HW_SRC_LLI_WORD0_REG_ADDR 0x0C28UL
#define HW_SRC_LLI_WORD1_REG_ADDR 0x0C2CUL
#define HW_SRAM_SRC_ADDR_REG_ADDR 0x0c30UL
#define HW_DIN_SRAM_BYTES_LEN_REG_ADDR 0x0c34UL
#define HW_DIN_SRAM_DMA_BUSY_REG_ADDR 0x0C38UL
#define HW_WRITE_ALIGN_REG_ADDR 0x0C3CUL
#define HW_OLD_DATA_REG_ADDR 0x0C48UL
#define HW_WRITE_ALIGN_LAST_REG_ADDR 0x0C4CUL
#define HW_DOUT_BUFFER_REG_ADDR 0x0C00UL
#define HW_DST_LLI_WORD0_REG_ADDR 0x0D28UL
#define HW_DST_LLI_WORD1_REG_ADDR 0x0D2CUL
#define HW_DST_LLI_MEM_ADDR_REG_ADDR 0x0D24UL
#define HW_DOUT_MEM_DMA_BUSY_REG_ADDR 0x0D20UL
#define HW_SRAM_DEST_ADDR_REG_ADDR 0x0D30UL
#define HW_DOUT_SRAM_BYTES_LEN_REG_ADDR 0x0D34UL
#define HW_DOUT_SRAM_DMA_BUSY_REG_ADDR 0x0D38UL
#define HW_READ_ALIGN_REG_ADDR 0x0D3CUL
#define HW_READ_LAST_DATA_REG_ADDR 0x0D44UL
#define HW_RC4_THRU_CPU_REG_ADDR 0x0D4CUL
#define HW_AHB_SINGLE_REG_ADDR 0x0E00UL
#define HW_SRAM_DATA_REG_ADDR 0x0F00UL
#define HW_SRAM_ADDR_REG_ADDR 0x0F04UL
#define HW_SRAM_DATA_READY_REG_ADDR 0x0F08UL
#define HW_HOST_IRR_REG_ADDR 0x0A00UL
#define HW_HOST_IMR_REG_ADDR 0x0A04UL
#define HW_HOST_ICR_REG_ADDR 0x0A08UL
#define HW_HOST_SEP_SRAM_THRESHOLD_REG_ADDR 0x0A10UL
#define HW_HOST_SEP_BUSY_REG_ADDR 0x0A14UL
#define HW_HOST_SEP_LCS_REG_ADDR 0x0A18UL
#define HW_HOST_CC_SW_RST_REG_ADDR 0x0A40UL
#define HW_HOST_SEP_SW_RST_REG_ADDR 0x0A44UL
#define HW_HOST_FLOW_DMA_SW_INT0_REG_ADDR 0x0A80UL
#define HW_HOST_FLOW_DMA_SW_INT1_REG_ADDR 0x0A84UL
#define HW_HOST_FLOW_DMA_SW_INT2_REG_ADDR 0x0A88UL
#define HW_HOST_FLOW_DMA_SW_INT3_REG_ADDR 0x0A8cUL
#define HW_HOST_FLOW_DMA_SW_INT4_REG_ADDR 0x0A90UL
#define HW_HOST_FLOW_DMA_SW_INT5_REG_ADDR 0x0A94UL
#define HW_HOST_FLOW_DMA_SW_INT6_REG_ADDR 0x0A98UL
#define HW_HOST_FLOW_DMA_SW_INT7_REG_ADDR 0x0A9cUL
#define HW_HOST_SEP_HOST_GPR0_REG_ADDR 0x0B00UL
#define HW_HOST_SEP_HOST_GPR1_REG_ADDR 0x0B04UL
#define HW_HOST_SEP_HOST_GPR2_REG_ADDR 0x0B08UL
......@@ -225,9 +54,6 @@
#define HW_HOST_HOST_SEP_GPR1_REG_ADDR 0x0B84UL
#define HW_HOST_HOST_SEP_GPR2_REG_ADDR 0x0B88UL
#define HW_HOST_HOST_SEP_GPR3_REG_ADDR 0x0B8CUL
#define HW_HOST_HOST_ENDIAN_REG_ADDR 0x0B90UL
#define HW_HOST_HOST_COMM_CLK_EN_REG_ADDR 0x0B94UL
#define HW_CLR_SRAM_BUSY_REG_REG_ADDR 0x0F0CUL
#define HW_CC_SRAM_BASE_ADDRESS 0x5800UL
#define HW_SRAM_DATA_READY_REG_ADDR 0x0F08UL
#endif /* ifndef HW_DEFS */
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* If TRACE_SYSTEM is defined, that will be the directory created
* in the ftrace directory under /sys/kernel/debug/tracing/events/<system>
*
* The define_trace.h below will also look for a file name of
* TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here.
* In this case, it would look for sample.h
*
* If the header name will be different than the system name
* (as in this case), then you can override the header name that
* define_trace.h will look up by defining TRACE_INCLUDE_FILE
*
* This file is called trace-events-sample.h but we want the system
* to be called "sample". Therefore we must define the name of this
* file:
*
* #define TRACE_INCLUDE_FILE trace-events-sample
*
* As we do an the bottom of this file.
*
* Notice that TRACE_SYSTEM should be defined outside of #if
* protection, just like TRACE_INCLUDE_FILE.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sep
/*
* Notice that this file is not protected like a normal header.
* We also must allow for rereading of this file. The
*
* || defined(TRACE_HEADER_MULTI_READ)
*
* serves this purpose.
*/
#if !defined(_TRACE_SEP_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SEP_EVENTS_H
#ifdef SEP_PERF_DEBUG
#define SEP_TRACE_FUNC_IN() trace_sep_func_start(__func__, 0)
#define SEP_TRACE_FUNC_OUT(branch) trace_sep_func_end(__func__, branch)
#define SEP_TRACE_EVENT(branch) trace_sep_misc_event(__func__, branch)
#else
#define SEP_TRACE_FUNC_IN()
#define SEP_TRACE_FUNC_OUT(branch)
#define SEP_TRACE_EVENT(branch)
#endif
/*
* All trace headers should include tracepoint.h, until we finally
* make it into a standard header.
*/
#include <linux/tracepoint.h>
/*
* The TRACE_EVENT macro is broken up into 5 parts.
*
* name: name of the trace point. This is also how to enable the tracepoint.
* A function called trace_foo_bar() will be created.
*
* proto: the prototype of the function trace_foo_bar()
* Here it is trace_foo_bar(char *foo, int bar).
*
* args: must match the arguments in the prototype.
* Here it is simply "foo, bar".
*
* struct: This defines the way the data will be stored in the ring buffer.
* There are currently two types of elements. __field and __array.
* a __field is broken up into (type, name). Where type can be any
* type but an array.
* For an array. there are three fields. (type, name, size). The
* type of elements in the array, the name of the field and the size
* of the array.
*
* __array( char, foo, 10) is the same as saying char foo[10].
*
* fast_assign: This is a C like function that is used to store the items
* into the ring buffer.
*
* printk: This is a way to print out the data in pretty print. This is
* useful if the system crashes and you are logging via a serial line,
* the data can be printed to the console using this "printk" method.
*
* Note, that for both the assign and the printk, __entry is the handler
* to the data structure in the ring buffer, and is defined by the
* TP_STRUCT__entry.
*/
TRACE_EVENT(sep_func_start,
TP_PROTO(const char *name, int branch),
TP_ARGS(name, branch),
TP_STRUCT__entry(
__array(char, name, 20)
__field(int, branch)
),
TP_fast_assign(
strncpy(__entry->name, name, 20);
__entry->branch = branch;
),
TP_printk("func_start %s %d", __entry->name, __entry->branch)
);
TRACE_EVENT(sep_func_end,
TP_PROTO(const char *name, int branch),
TP_ARGS(name, branch),
TP_STRUCT__entry(
__array(char, name, 20)
__field(int, branch)
),
TP_fast_assign(
strncpy(__entry->name, name, 20);
__entry->branch = branch;
),
TP_printk("func_end %s %d", __entry->name, __entry->branch)
);
TRACE_EVENT(sep_misc_event,
TP_PROTO(const char *name, int branch),
TP_ARGS(name, branch),
TP_STRUCT__entry(
__array(char, name, 20)
__field(int, branch)
),
TP_fast_assign(
strncpy(__entry->name, name, 20);
__entry->branch = branch;
),
TP_printk("misc_event %s %d", __entry->name, __entry->branch)
);
#endif
/***** NOTICE! The #if protection ends here. *****/
/*
* There are several ways I could have done this. If I left out the
* TRACE_INCLUDE_PATH, then it would default to the kernel source
* include/trace/events directory.
*
* I could specify a path from the define_trace.h file back to this
* file.
*
* #define TRACE_INCLUDE_PATH ../../samples/trace_events
*
* But the safest and easiest way to simply make it use the directory
* that the file is in is to add in the Makefile:
*
* CFLAGS_trace-events-sample.o := -I$(src)
*
* This will make sure the current path is part of the include
* structure for our file so that define_trace.h can find it.
*
* I could have made only the top level directory the include:
*
* CFLAGS_trace-events-sample.o := -I$(PWD)
*
* And then let the path to this directory be the TRACE_INCLUDE_PATH:
*
* #define TRACE_INCLUDE_PATH samples/trace_events
*
* But then if something defines "samples" or "trace_events" as a macro
* then we could risk that being converted too, and give us an unexpected
* result.
*/
#undef TRACE_INCLUDE_PATH
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_PATH .
/*
* TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
*/
#define TRACE_INCLUDE_FILE sep_trace_events
#include <trace/define_trace.h>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment