📄 sec2.h
字号:
/**************************************************************************** * Sec2.h - Top-level driver include file for SEC2 security processor **************************************************************************** * Copyright (c) 2003-2005 Freescale Semiconductor * All Rights Reserved. Proprietary and Confidential. * * NOTICE: The information contained in this file is proprietary * to Freescale Semiconductor and is being made available to * Freescale's customers under strict license agreements. * Use or disclosure of this information is permissible only * under the terms of the existing license agreement. ***************************************************************************//* Revision History: * 1.0 Aug 24,2003 dgs adapted from the final version of mpc18x * Jun 02,2004 sec - add "generic" linked list for scatter description * Aug 23,2004 sec - add TLS support for T2.1 * 1.1.0 Nov 04,2004 sec - merge linux changes from prior versions * 1.1.1 Dec 15,2004 sec - remove old, unused diagnostics * 1.2 Jan 27,2005 sec - remove obsolete names and non-pad IPsec request defs, * add hash chain support */ #ifndef SEC2_H#define SEC2_H#ifdef _cplusplusextern "C" {#endif/* General types for the driver, if they don't exist elsewhere */#ifndef BOOLEAN#define BOOLEAN int#endif#ifndef TRUE#define TRUE (1)#endif#ifndef FALSE#define FALSE (0)#endif#ifndef offsetof#define offsetof(s,m) (size_t)&(((s *)0)->m)#endif/* IOCTL function code offsets *//* Each defines an IOCTL request to be added to a system-defined offset */#define SEC2_PROC_REQ (1) /* Process request */#define SEC2_GET_STATUS (2) /* Read delayed status */#define SEC2_MALLOC (13) /* Allocate driver storage block */#define SEC2_FREE (14) /* Free a driver storage block */#define SEC2_COPYFROM (15) /* Driver buffer copy function */#define SEC2_COPYTO (16) /* Opposing buffer copy function *//* Base IOCTL function index, assume 0 to 0x7ff reserved for the host OS */#define SEC2_IOCTL_INDEX (0x800)/* Computed IOCTL constants for use */#define IOCTL_PROC_REQ (SEC2_IOCTL_INDEX + SEC2_PROC_REQ)#define IOCTL_GET_STATUS (SEC2_IOCTL_INDEX + SEC2_GET_STATUS)#define IOCTL_MALLOC (SEC2_IOCTL_INDEX + SEC2_MALLOC)#define IOCTL_FREE (SEC2_IOCTL_INDEX + SEC2_FREE)#define IOCTL_COPYFROM (SEC2_IOCTL_INDEX + SEC2_COPYFROM)#define IOCTL_COPYTO (SEC2_IOCTL_INDEX + SEC2_COPYTO)/* Defined the internal "geometry* of the security block in question *//* Will be obsoleted in the near future in favor of dynamic configuration *//* based on the rev mask of the T2.x core */#define SEC2_NUM_CHANNELS (4) /* Channels configured */#define SEC2_NUM_DESAS (1) /* DES cipher accelerators */#define SEC2_NUM_AESAS (1) /* AES cipher accelerators */#define SEC2_NUM_MDHAS (1) /* MD-x message digest accelerators */#define SEC2_NUM_AFHAS (1) /* ARC-4 accelerators */#define SEC2_NUM_RNGAS (1) /* Random-number generators */#define SEC2_NUM_PKHAS (1) /* Public-key accelerators *//* Total number of accelerator blocks configured */#define NUM_CHAS (SEC2_NUM_AFHAS+SEC2_NUM_DESAS+SEC2_NUM_MDHAS+SEC2_NUM_RNGAS+SEC2_NUM_PKHAS \ +SEC2_NUM_AESAS)#ifdef VXWORKS#define vxworksDrvName "/dev/sec2"#endif/* General error/status codes for ioctl() function returns, and for the *//* status field of the general-purpose part of the request struct *//* all OK */#define SEC2_SUCCESS (int)(0x00000000) /*20060920*//*error occur*/#define SEC2_ERROR (int)(0x00000001)/* Driver memory allocation problem */#define SEC2_MEMORY_ALLOCATION (int)(0xE004FFFF)/*20060920*//* Channel spec out-of-range. Here for legacy *//* compatibility, not relevant to SEC2 */#define SEC2_INVALID_CHANNEL (int)(0xE004FFFE)/*20060920*//* Requested cipher type not supported on *//* this hardware. This technically indicates *//* a driver problem of some sort */#define SEC2_INVALID_CHA_TYPE (int)(0xE004FFFD)/*20060920*//* Operation type specified in the request *//* block does not exist */#define SEC2_INVALID_OPERATION_ID (int)(0xE004FFFC)/*20060920*//* Requested channel not available for use *//* This error exists for legacy compatibility *//* but is meaningless for SEC2 because of the *//* lack of static channel support */#define SEC2_CHANNEL_NOT_AVAILABLE (int)(0xE004FFFB)/*20060920*//* Requested cipher type already in use by *//* some other request */#define SEC2_CHA_NOT_AVAILABLE (int)(0xE004FFFA)/*20060920*//* At least one data length in the request is invalid *//* This is likely an alignment issue */#define SEC2_INVALID_LENGTH (int)(0xE004FFF9)/*20060920*//* An address in the request struct is misaligned */#define SEC2_OUTPUT_BUFFER_ALIGNMENT (int)(0xE004FFF8)/*20060920*//* Driver has internal address translation err */#define SEC2_ADDRESS_PROBLEM (int)(0xE004FFF6)/*20060920*//* Driver has run out of request entries */#define SEC2_INSUFFICIENT_REQS (int)(0xE004FFF5)/*20060920*/#define SEC2_CHANNEL_ERROR (int)(0xE004FFF3)/* An accelerator is in error state after a request */#define SEC2_CHA_ERROR (int)(0xE004FFF2)/*20060920*//* Specified request was NULL */#define SEC2_NULL_REQUEST (int)(0xE004FFF1)/*20060920*//* Timeout during request execution */#define SEC2_REQUEST_TIMED_OUT (int)(0xE004FFF0)/*20060920*//* Driver ran out of memory in the course of processing */#define SEC2_MALLOC_FAILED (int)(0xE004FFEF)/*20060920*//* Driver failed to free a block while processing */#define SEC2_FREE_FAILED (int)(0xE004FFEE)/*20060920*//* Driver encountered a parity error in the input data */#define SEC2_PARITY_SYSTEM_ERROR (int)(0xE004FFED)/*20060920*/#define SEC2_INCOMPLETE_POINTER (int)(0xE004FFEC)/*20060920*/#define SEC2_TEA_ERROR (int)(0xE004FFEB)/*20060920*//* While trying to build a scatter-gather fragment list *//* for a specified request, the driver ran out of *//* entries to store into */#define SEC2_FRAGMENT_POOL_EXHAUSTED (int)(0xE004FFEA)/*20060920*//* Driver attempted to stuff too many DPDs into the *//* fetch FIFO. This indicates an internal driver error */#define SEC2_FETCH_FIFO_OVERFLOW (int)(0xE004FFE9)/*20060920*//* Hardware failed while trying to acquire mastership *//* of the bus */#define SEC2_BUS_MASTER_ERROR (int)(0xE004FFE8)/*20060920*//* While composing a scatter descriptor, the driver *//* encountered an error, most likely a bad pointer in *//* the specification list */#define SEC2_SCATTER_LIST_ERROR (int)(0xE004FFE7)/*20060920*//* Driver encountered an unidentfiable condition */#define SEC2_UNKNOWN_ERROR (int)(0xE004FFE6)/*20060920*//* Security device not found at the specified location *//* This is a legacy error left over from earlier revs */#define SEC2_IO_CARD_NOT_FOUND (-1000)/* Driver can't allocate a buffer */#define SEC2_IO_MEMORY_ALLOCATE_ERROR (-1001)/* Driver has a problem with register I/O */#define SEC2_IO_IO_ERROR (-1002)/* System can't attach driver to the OS dispatch table */#define SEC2_IO_VXWORKS_DRIVER_TABLE_ADD_ERROR (-1003)/* Driver can't use a needed interrupt ID */#define SEC2_IO_INTERRUPT_ALLOCATE_ERROR (-1004)/* Driver can't use peripheral base region */#define SEC2_CANNOT_SETUP_BAR0_ERROR (-1008)/* Driver can't initialize message queue */#define SEC2_VXWORKS_CANNOT_CREATE_QUEUE (-1009)/* Request was cancelled by external means */#define SEC2_CANCELLED_REQUEST (-1010)/* User passed a null request pointer to IOCTL_PROC_REQ */#define SEC2_INVALID_ADDRESS (-1011)#include "Sec2Notify.h"/* MALLOC_REQ structure used on allocation requests to the driver Used by KernelMalloc() Used also by the Dispatch function that calls KernelMalloc() and KernelFree()*/typedef struct{ unsigned long sz; /*!< Number of bytes to allocate Zero means to use the default. A value of zero can be used to avoid fragmentation. */ void *ptr; /*!< Pointer to the adress that is to be returned by a call to KernelMalloc() or a pointer to an address that is to be freed when calling KernelFree() */ char *to; /* copy to */ char *from; /* copy from */ int pid; /* pid */} MALLOC_REQ;/* Basic scatter/gather linked list form for general-purpose use *//* This is used by the requestor to identify scatter buffer fragments to the driver *//* for any pointer in a request. It's constructed in common NULL-terminated linked *//* list form */typedef struct _sec2scatterFragment{ void *next; /* next fragment in list, NULL if none */ void *fragment; /* physical location of fragment */ unsigned short size; /* size of this fragment */} EXT_SCATTER_ELEMENT;/* Extracts the request type from an OpId */#define DESC_TYPE_MASK (0xFF00)/* Extracts the request group from an OpId */#define DESC_NUM_MASK (0x00FF)#if 0/* * Common request block for all request headers * This macro contains the common portion of all request blocks * It's composed as follows: * opId - Type of operation requested * scatterBufs - Map of scattered buffers, returned from MarkScatterBuffers() * notifyFlags - if bits set, notify pointers are actuall PIDs for a completion signal * channel - Obsolete for T2.x, holdover from 2.x * notify - Handler for normal completion * pNotifyCtx - Context for handler * notify_on_error - Handler for error completion * ctxNotifyOnErr - returned device context if error * status - Driver completion status * nextReq - Next request in list, if any */ #define COMMON_REQ_PREAMBLE \ unsigned long opId; \ unsigned char scatterBufs; \ unsigned char notifyFlags; \ unsigned char reserved; \ unsigned char channel; \ SEC_NOTIFY_ROUTINE notify; \ SEC_NOTIFY_CTX pNotifyCtx; \ SEC_NOTIFY_ON_ERROR_ROUTINE notify_on_error; \ SEC_NOTIFY_ON_ERROR_CTX ctxNotifyOnErr; \ int status; \ void *nextReq;/* This gets used by driver functions that need access to just the request *//* header without knowing the remaining request-type-specific content */typedef struct { COMMON_REQ_PREAMBLE } GENERIC_REQ;#endif/* Bits for use with notifyFlags in the request header */#define NOTIFY_IS_PID (0x01) /* "notify" is a PID, not a pointer */#define NOTIFY_ERROR_IS_PID (0x02) /* "notify_on_error" is a PID, not a pointer *//* * RNG_REQ - Random-Number generator request block * rngBytes - number of bytes to return * rngData - pointer to user's random data buffer */ #if 0typedef struct{ COMMON_REQ_PREAMBLE unsigned long rngBytes; unsigned char *rngData;} RNG_REQ;#endif#define NUM_RNGA_DESC (1)#define DPD_RNG_GROUP (0x1000)/* Get random data from the RNG */#define DPD_RNG_GETRN (DPD_RNG_GROUP + 0)#if 0/* * DES_LOADCTX_CRYPT_REQ - DES request with context load * These are basically CBC (cipher-block-chain) operations * */ typedef struct{ COMMON_REQ_PREAMBLE unsigned long inIvBytes; /* 0 or 8 bytes */ unsigned char *inIvData; unsigned long keyBytes; /* 8, 16, or 24 bytes */ unsigned char *keyData;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -