374 lines
15 KiB
C
374 lines
15 KiB
C
/*
|
|
******************************************************************************
|
|
* INTERPEAK INTERNAL API HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipfreescale_coldfire.h,v $ $Revision: 1.13 $
|
|
* $Source: /home/interpeak/CVSRoot/ipfreescale/src/ipfreescale_coldfire.h,v $
|
|
* $Author: lob $ $Date: 2009-01-20 10:35:56 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPFREESCALE_COLDFIRE_H
|
|
#define IPFREESCALE_COLDFIRE_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipfreescale_config.h"
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include <ipcom_type.h>
|
|
#include <ipcom_cstyle.h>
|
|
#include <ipcom_list.h>
|
|
#include <ipcom_os.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#ifdef IPFREESCALE_USE_STATISTICS
|
|
#define IPFREESCALE_STATS(ch, var) ipfreescale_coldfire.channel[ch].stats.var
|
|
#else
|
|
#define IPFREESCALE_STATS(ch, var) IP_NOOP
|
|
#endif
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Coldfire Security Engine Controller (SEC)
|
|
*===========================================================================
|
|
*
|
|
*/
|
|
|
|
/* Bit definitions and macros for SMCR */
|
|
#define IPFREESCALE_COLDFIRE_SMCR_CURR_CHAN(x) (((x)&0x0000000F)<<4)
|
|
#define IPFREESCALE_COLDFIRE_SMCR_SWR (0x01000000)
|
|
#define IPFREESCALE_COLDFIRE_SMCR_CURR_CHAN_1 (0x00000010)
|
|
#define IPFREESCALE_COLDFIRE_SMCR_CURR_CHAN_2 (0x00000020)
|
|
|
|
/* Bit definitions and macros for MCF_SEC_SIMRH */
|
|
#define IPFREESCALE_COLDFIRE_SIMRH_AERR (0x08000000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRH_CHA0DN (0x10000000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRH_CHA0ERR (0x20000000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRH_CHA1DN (0x40000000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRH_CHA1ERR (0x80000000)
|
|
|
|
/* Bit definitions and macros for MCF_SEC_SIMRL */
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_TEA (0x00000040)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_DEUDN (0x00000100)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_DEUERR (0x00000200)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_AESUDN (0x00001000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_AESUERR (0x00002000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_MDEUDN (0x00010000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_MDEUERR (0x00020000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_AFEUDN (0x00100000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_AFEUERR (0x00200000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_RNGDN (0x01000000)
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_RNGERR (0x02000000)
|
|
|
|
/* Bit definitions and macros for MCF_SEC_SISRH */
|
|
#define IPFREESCALE_COLDFIRE_SISRH_CHA0DN (0x10000000)
|
|
#define IPFREESCALE_COLDFIRE_SISRH_CHA1DN (0x40000000)
|
|
|
|
/* Bit definitions and macros for MCF_SEC_SICRH */
|
|
#define IPFREESCALE_COLDFIRE_SICRH_CHA0DN (0x10000000)
|
|
#define IPFREESCALE_COLDFIRE_SICRH_CHA1DN (0x40000000)
|
|
|
|
/* Bit definitions and macros for IPFREESCALE_COLDFIRE_CCCRn */
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_RST (0x00000001)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_CDIE (0x00000002)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_NT (0x00000004)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_NE (0x00000008)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_WE (0x00000010)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE(x) (((x)&0x00000007)<<8)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_2 (0x00000000)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_8 (0x00000100)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_16 (0x00000200)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_24 (0x00000300)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_32 (0x00000400)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_40 (0x00000500)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_48 (0x00000600)
|
|
#define IPFREESCALE_COLDFIRE_CCCRn_BURST_SIZE_56 (0x00000700)
|
|
|
|
/* Bit definitions and macros for IPFREESCALE_COLDFIRE_CCPSRLn */
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_PAIR_PTR(x) (((x)&0x000000FF)<<0)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_EUERR (0x00000100)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_SERR (0x00000200)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_DERR (0x00000400)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_PERR (0x00001000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_TEA (0x00002000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_SD (0x00010000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_PD (0x00020000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_SRD (0x00040000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_PRD (0x00080000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_SG (0x00100000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_PG (0x00200000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_SR (0x00400000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_PR (0x00800000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_MO (0x01000000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_MI (0x02000000)
|
|
#define IPFREESCALE_COLDFIRE_CCPSRLn_STAT (0x04000000)
|
|
|
|
#define IPFREESCALE_COLDFIRE_SIMRH_OFFSET 0x021008
|
|
#define IPFREESCALE_COLDFIRE_SIMRL_OFFSET 0x02100C
|
|
#define IPFREESCALE_COLDFIRE_SISRH_OFFSET 0x021010
|
|
#define IPFREESCALE_COLDFIRE_SISRL_OFFSET 0x021014
|
|
#define IPFREESCALE_COLDFIRE_SICRH_OFFSET 0x021018
|
|
#define IPFREESCALE_COLDFIRE_SICRL_OFFSET 0x02101C
|
|
#define IPFREESCALE_COLDFIRE_SMCR_OFFSET 0x021030
|
|
|
|
#define IPFREESCALE_COLDFIRE_AFRCR_OFFSET 0x028018
|
|
#define IPFREESCALE_COLDFIRE_AFSR_OFFSET 0x028028
|
|
#define IPFREESCALE_COLDFIRE_DRCR_OFFSET 0x02A018
|
|
#define IPFREESCALE_COLDFIRE_DSR_OFFSET 0x02A028
|
|
#define IPFREESCALE_COLDFIRE_MDRCR_OFFSET 0x02C018
|
|
#define IPFREESCALE_COLDFIRE_MDSR_OFFSET 0x02C028
|
|
#define IPFREESCALE_COLDFIRE_RNGRCR_OFFSET 0x02E018
|
|
#define IPFREESCALE_COLDFIRE_RNGSR_OFFSET 0x02E028
|
|
#define IPFREESCALE_COLDFIRE_AESRCR_OFFSET 0x032018
|
|
#define IPFREESCALE_COLDFIRE_AESSR_OFFSET 0x032028
|
|
|
|
#define IPFREESCALE_COLDFIRE_CCCR_OFFSET 0x02200C
|
|
#define IPFREESCALE_COLDFIRE_CCPSRH_OFFSET 0x022010
|
|
#define IPFREESCALE_COLDFIRE_CCPSRL_OFFSET 0x022014
|
|
#define IPFREESCALE_COLDFIRE_FR_OFFSET 0x02204C
|
|
|
|
#define IPFREESCALE_COLDFIRE_CHANNEL_OFFSET 0x001000
|
|
|
|
#define IPFREESCALE_MCF_JTAGID_OFFSET 0x000050
|
|
#define IPFREESCALE_MCF_JTAGID_PROCESSOR 0x0FFFFFFF
|
|
#define IPFREESCALE_MCF_JTAGID_MCF5485 0x0800C01D
|
|
#define IPFREESCALE_MCF_JTAGID_MCF5475 0x0801201D
|
|
|
|
#define IPFREESCALE_COLDFIRE_RCR_SR 0x01000000
|
|
#define IPFREESCALE_COLDFIRE_SR_RD 0x01000000
|
|
#define IPFREESCALE_COLDFIRE_SR_ID 0x02000000
|
|
|
|
#define IPFREESCALE_COLDFIRE_EU_NONE 0x00
|
|
#define IPFREESCALE_COLDFIRE_EU_AFEU 0x01
|
|
#define IPFREESCALE_COLDFIRE_EU_DEU 0x02
|
|
#define IPFREESCALE_COLDFIRE_EU_MDEU 0x03
|
|
#define IPFREESCALE_COLDFIRE_EU_RNG 0x04
|
|
#define IPFREESCALE_COLDFIRE_EU_AESU 0x06
|
|
|
|
#define IPFREESCALE_COLDFIRE_COMMON_NONSNOOP_NO_AFEU 0x01
|
|
#define IPFREESCALE_COLDFIRE_COMMON_NONSNOOP_AFEU 0x05
|
|
#define IPFREESCALE_COLDFIRE_MAXWAIT 1000000
|
|
#define IPFREESCALE_COLDFIRE_NUM_CHANNELS 2
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* IPFREESCALE_COLDFIRE_ESP_...
|
|
*===========================================================================
|
|
* Descriptor headers for ipsec esp
|
|
*
|
|
*/
|
|
#define IPFREESCALE_COLDFIRE_ESP_ENCRYPT_DES_CBC_MD5 0x20531e20
|
|
#define IPFREESCALE_COLDFIRE_ESP_DECRYPT_DES_CBC_MD5 0x20431e22
|
|
#define IPFREESCALE_COLDFIRE_ESP_ENCRYPT_DES_CBC_SHA1 0x20531c20
|
|
#define IPFREESCALE_COLDFIRE_ESP_DECRYPT_DES_CBC_SHA1 0x20431c22
|
|
#define IPFREESCALE_COLDFIRE_ESP_ENCRYPT_3DES_CBC_MD5 0x20731e20
|
|
#define IPFREESCALE_COLDFIRE_ESP_DECRYPT_3DES_CBC_MD5 0x20631e22
|
|
#define IPFREESCALE_COLDFIRE_ESP_ENCRYPT_3DES_CBC_SHA1 0x20731c20
|
|
#define IPFREESCALE_COLDFIRE_ESP_DECRYPT_3DES_CBC_SHA1 0x20631c22
|
|
#define IPFREESCALE_COLDFIRE_ESP_ENCRYPT_AES_CBC_MD5 0x60331e20
|
|
#define IPFREESCALE_COLDFIRE_ESP_DECRYPT_AES_CBC_MD5 0x60231e22
|
|
#define IPFREESCALE_COLDFIRE_ESP_ENCRYPT_AES_CBC_SHA1 0x60331c20
|
|
#define IPFREESCALE_COLDFIRE_ESP_DECRYPT_AES_CBC_SHA1 0x60231c22
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipfreescale_coldfire_descriptor
|
|
*===========================================================================
|
|
* Descriptor definition for SEC.
|
|
*/
|
|
typedef struct Ipfreescale_coldfire_descriptor_struct
|
|
{
|
|
Ip_u32 hdr;
|
|
Ip_u32 len_1;
|
|
Ip_u8 *ptr_1;
|
|
Ip_u32 len_2;
|
|
Ip_u8 *ptr_2;
|
|
Ip_u32 len_3;
|
|
Ip_u8 *ptr_3;
|
|
Ip_u32 len_4;
|
|
Ip_u8 *ptr_4;
|
|
Ip_u32 len_5;
|
|
Ip_u8 *ptr_5;
|
|
Ip_u32 len_6;
|
|
Ip_u8 *ptr_6;
|
|
Ip_u32 len_7;
|
|
Ip_u8 *ptr_7;
|
|
struct Ipfreescale_coldfire_descriptor_struct *next;
|
|
}
|
|
Ipfreescale_coldfire_descriptor;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipfreescale_coldfire_stats
|
|
*===========================================================================
|
|
* Statistics structure for SEC.
|
|
*/
|
|
typedef struct Ipfreescale_coldfire_stats_struct
|
|
{
|
|
/* Usage counters */
|
|
int u_deu;
|
|
int u_aesu;
|
|
int u_afeu;
|
|
int u_mdeu;
|
|
int u_rng;
|
|
|
|
/* Error counters */
|
|
int e_tmo;
|
|
int e_euerr;
|
|
int e_serr;
|
|
int e_derr;
|
|
int e_perr;
|
|
int e_tea;
|
|
}
|
|
Ipfreescale_coldfire_stats;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipfreescale_coldfire_channel_data
|
|
*===========================================================================
|
|
* SEC channel data.
|
|
*/
|
|
typedef struct Ipfreescale_coldfire_channel_data_struct
|
|
{
|
|
/* True if in use */
|
|
Ip_bool in_use;
|
|
|
|
/* Registers */
|
|
IP_VOLATILE Ip_u32 *cccr;
|
|
IP_VOLATILE Ip_u32 *ccpsrh;
|
|
IP_VOLATILE Ip_u32 *ccpsrl;
|
|
IP_VOLATILE Ip_u32 *fr;
|
|
|
|
#ifdef IPFREESCALE_USE_STATISTICS
|
|
/* Statistics */
|
|
Ipfreescale_coldfire_stats stats;
|
|
#endif
|
|
}
|
|
Ipfreescale_coldfire_channel_data;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipfreescale_coldfire_data
|
|
*===========================================================================
|
|
* SEC data.
|
|
*/
|
|
typedef struct Ipfreescale_coldfire_data_struct
|
|
{
|
|
/* Channel resource mutex */
|
|
Ipcom_mutex chmtx;
|
|
|
|
/* Registers */
|
|
IP_VOLATILE Ip_u32 *jtagid;
|
|
IP_VOLATILE Ip_u32 *mcr;
|
|
IP_VOLATILE Ip_u32 *simrh;
|
|
IP_VOLATILE Ip_u32 *simrl;
|
|
IP_VOLATILE Ip_u32 *sisrh;
|
|
IP_VOLATILE Ip_u32 *sisrl;
|
|
IP_VOLATILE Ip_u32 *sicrh;
|
|
IP_VOLATILE Ip_u32 *sicrl;
|
|
IP_VOLATILE Ip_u32 *afrcr;
|
|
IP_VOLATILE Ip_u32 *afsr;
|
|
IP_VOLATILE Ip_u32 *drcr;
|
|
IP_VOLATILE Ip_u32 *dsr;
|
|
IP_VOLATILE Ip_u32 *mdrcr;
|
|
IP_VOLATILE Ip_u32 *mdsr;
|
|
IP_VOLATILE Ip_u32 *rngrcr;
|
|
IP_VOLATILE Ip_u32 *rngsr;
|
|
IP_VOLATILE Ip_u32 *aesrcr;
|
|
IP_VOLATILE Ip_u32 *aessr;
|
|
|
|
/* Channel structures */
|
|
Ipfreescale_coldfire_channel_data channel[IPFREESCALE_COLDFIRE_NUM_CHANNELS];
|
|
}
|
|
Ipfreescale_coldfire_data;
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_EXTERN IP_GLOBAL Ipfreescale_coldfire_data ipfreescale_coldfire;
|
|
|
|
IP_EXTERN IP_CONST Ip_u8 ipfreescale_parity_odd[256];
|
|
|
|
IP_GLOBAL void ipfreescale_coldfire_yield_task(void);
|
|
IP_GLOBAL int ipfreescale_coldfire_reserve_channel(void);
|
|
IP_GLOBAL void ipfreescale_coldfire_release_channel(int ch);
|
|
IP_GLOBAL int ipfreescale_coldfire_engage(Ipfreescale_coldfire_descriptor *dp, int ch, int peu, int seu);
|
|
IP_GLOBAL void ipfreescale_coldfire_flush_descriptor(Ipfreescale_coldfire_descriptor *descr);
|
|
IP_GLOBAL void ipfreescale_coldfire_print_stats(char *where);
|
|
IP_GLOBAL void ipfreescale_coldfire_clear_stats(void);
|
|
|
|
IP_GLOBAL Ip_err ipfreescale_coldfire_init(void);
|
|
|
|
IP_GLOBAL int ipfreescale_coldfire_random_gen(Ip_u8 *data, Ip_u32 length);
|
|
IP_GLOBAL int ipfreescale_coldfire_md5_digest(IP_CONST Ip_u8 *data, Ip_u32 length, Ip_u8 *digest);
|
|
IP_GLOBAL int ipfreescale_coldfire_sha1_digest(IP_CONST Ip_u8 *data, Ip_u32 length, Ip_u8 *digest);
|
|
IP_GLOBAL int ipfreescale_coldfire_des_cbc_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc);
|
|
IP_GLOBAL int ipfreescale_coldfire_des_ecb_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc);
|
|
IP_GLOBAL int ipfreescale_coldfire_3des_cbc_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc);
|
|
IP_GLOBAL int ipfreescale_coldfire_3des_ecb_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc);
|
|
IP_GLOBAL int ipfreescale_coldfire_aes_cbc_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u32 keylen, Ip_u8 *iv, int enc);
|
|
IP_GLOBAL int ipfreescale_coldfire_aes_ecb_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u32 keylen, int enc);
|
|
IP_GLOBAL int ipfreescale_coldfire_rc4_cipher(Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u32 keylen, Ip_u8 *ctxi, Ip_u8 *ctxo);
|
|
|
|
#ifdef IPIPSEC2
|
|
IP_GLOBAL int ipfreescale_ipsec_coldfire_esp_input(Ip_u32 hdr, Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt);
|
|
IP_GLOBAL int ipfreescale_ipsec_coldfire_esp_output(Ip_u32 hdr, Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|