Main Page | Data Structures | File List | Data Fields | Globals

des_io.h

Go to the documentation of this file.
00001 
00008 /****************************************************************************
00009 *
00010 *     Axis 2 PCI Linux Kernel driver
00011 *     File:    des_io.h
00012 *     Version: 1.0
00013 *     Copyright 2004 Heber Limited (http://www.heber.co.uk)
00014 *
00015 *     This program is free software; you can redistribute it and/or modify it
00016 *     under the terms of the GNU General Public License as published by the
00017 *     Free Software Foundation; either version 2, or (at your option) any
00018 *     later version.
00019 *
00020 *     This program is distributed in the hope that it will be useful, but
00021 *     WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023 *     General Public License for more details.
00024 *
00025 *     You should have received a copy of the GNU General Public License along
00026 *     with this program; if not, write to the Free Software Foundation, Inc.,
00027 *     675 Mass Ave, Cambridge, MA 02139, USA.
00028 *
00029 *     Changes:
00030 *
00031 ****************************************************************************/
00032 #ifndef AXIS_DES_IO_H
00033 #define AXIS_DES_IO_H
00034 #ifndef _LINUX_KERNEL_H
00035 
00036 #include <linux/kernel.h>
00037 #include <linux/sched.h>
00038 #include <linux/version.h>
00039 #include <linux/module.h>
00040 #include <linux/proc_fs.h>
00041 #include <linux/delay.h>
00042 #include <linux/pci.h>
00043 #include <linux/list.h>
00044 #include <linux/ioport.h>
00045 #include <linux/serial.h>
00046 #include <linux/interrupt.h>
00047 #include <linux/string.h>
00048 #include <linux/spinlock.h>
00049 #include <linux/mtd/mtd.h>
00050 #include <linux/crypto.h>
00051 #include <asm/uaccess.h>
00052 
00053 #endif  //_LINUX_KERNEL_H
00054 
00055 #ifndef AXIS_HARDWARE_H
00056 #include "axis_hardware.h"
00057 #endif //AXIS_HARDWARE_H
00058 
00059 
00060 #define DES_A_REG                           (0x50+CONTROL_OFFSET)
00061 #define DES_B_REG                           (0x54+CONTROL_OFFSET)
00062 #define DES_C_REG                           (0x58+CONTROL_OFFSET)
00063 #define DES_D_REG                           (0x5C+CONTROL_OFFSET)
00064 
00065 #define DES_A_BUFFER                        (0)
00066 #define DES_B_BUFFER                        (0x200)
00067 #define DES_C_BUFFER                        (0x400)
00068 #define DES_D_BUFFER                        (0x600)
00069 
00070 #define DES_START_BIT   (1<<0)
00071 #define DES_ENCRYPT_BIT (1<<1)
00072 #define DES_MASTER_BIT  (1<<2)
00073 
00074 
00075 
00076 #define HEBER_DES3_BLOCK_SIZE           8
00077 #define HEBER_DES3_KEY_SIZE             24
00078 
00079 /*----------------------des related defines ----------------------*/
00080 #define NUMBER_OF_KEY_STORES 16
00081 #define NUMBER_OF_DES_CHANNELS 3 //keep channel 4 for key management
00082 #define MAX_DES_OPS 512
00083 #define KEY_SIZE 192
00084 #define INTERNAL_KEY_SIZE 0x20  // gate array has space for 256 bits per key
00085 
00086 
00087 /*
00088 The system has to deal with having a finite number of hardware key stores less than
00089 the possible number of transactions so hardware key storage must be reused.
00090 
00091 The solution each device has an array of axis_des_hardware_key structures each hardware key
00092 has a lock. If locked the key is either in use or scheuled for use and cannot be freed. The
00093 age member allows the use of a LRU algorithm to reclaim hardware keys.
00094 
00095 Each file operations structure has a software key storage associated with it. A write operation will
00096 cause the system to check if it has a current hardware key if it doesn't it will request (waiting if necessary)
00097 one.
00098 The key will be locked and if its not loaded it will be loaded.
00099 Once the key is loaded the operation will be queued upon a DES buffer. Once a DES buffer becomes available
00100 the operation is started and waits for completion.
00101 On completion the results are copied either back to kernel memory or to a buffer. The DES buffer is unlocked
00102 as is the hardware key storage.
00103 
00104 */
00105 
00106 struct axis_des_key;
00107 
00116 struct axis_des_hardware_key
00117 {
00118     unsigned        lock    ;               
00119     unsigned        loaded  ;               
00120     unsigned long   age     ;               
00121     unsigned char * address ;               
00122     unsigned char * register_address;       
00123     unsigned        index   ;               
00124     struct axis_des_key * software_key ;    
00126 };
00134 struct axis_des_hardware_channel
00135 {
00136     unsigned            lock    ;               
00137     unsigned char *     buffer_address  ;       
00138     unsigned char *     register_address;       
00139     wait_queue_head_t   queue       ;           
00140     volatile int                done        ;   
00141     volatile unsigned long      start_time ;    
00142 };
00143 
00151 struct axis_des_key
00152 {
00153     unsigned char Key0[8]               ;   
00154     unsigned char Key1[8]               ;   
00155     unsigned char Key2[8]               ;   
00156     int encrypt                         ;   
00157     int master                          ;   
00158     int raw                         ;   
00159     struct axis_des_hardware_key * hardware_key ;
00160 };
00161 
00172 struct crypto_state
00173 {
00174     struct axis_des_key  key ;                      
00175     struct axis_pci_device_entry * device ;         
00176 } ;
00177 
00184 struct axis_des_op
00185 {
00186     unsigned long flags ;                       ;   
00187     struct axis_des_key * key                   ;   
00188     struct axis_des_hardware_channel * channel  ;   
00189     unsigned int no_to_do                       ;   
00190     unsigned char * buffer                      ;   
00191     struct axis_pci_device_entry * device       ;   
00192     unsigned char local[512]                    ;   
00193 };
00194 
00195 
00196 //export function to initialise DES hardware key structures
00197 void init_axis_des_hardware_key(struct axis_des_hardware_key * ptr,
00198                                             unsigned char * addr,
00199                                             unsigned char * reg,int index);
00200 
00201 //export function to initialise DES hardware channel structures
00202 void init_axis_des_hardware_channel(struct axis_des_hardware_channel * ptr,
00203                                                 unsigned char * reg,
00204                                                 unsigned char * buffer,
00205                                                 unsigned index);
00206 
00207 
00208 void init_axis_des_core(struct axis_pci_device_entry * device);
00209 //export file operations structure for cypto device
00210 extern struct file_operations crypto_file_operations ;
00211 
00212 #endif  //AXIS_DES_IO_H
00213 

Generated on Fri Jan 28 12:33:47 2005 for Axis Kernel Driver by doxygen 1.3.6