summaryrefslogtreecommitdiffstats
path: root/drivers/staging/ccree/cc_pal_types.h
blob: 9b59bbb34515615a063c63d2626a68aa50e89089 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * 
 * 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef CC_PAL_TYPES_H
#define CC_PAL_TYPES_H

/*! 
@file 
@brief This file contains platform-dependent definitions and types. 
@defgroup cc_pal_types CryptoCell PAL platform dependant types
@{
@ingroup cc_pal

*/
 
#include "cc_pal_types_plat.h"

/*! Boolean definition.*/
typedef enum {
	/*! Boolean false definition.*/
	CC_FALSE = 0,
	/*! Boolean true definition.*/
	CC_TRUE = 1
} CCBool;

/*! Success definition. */
#define CC_SUCCESS              0UL
/*! Failure definition. */
#define CC_FAIL		  	1UL

/*! Defintion of 1KB in bytes. */
#define CC_1K_SIZE_IN_BYTES	1024
/*! Defintion of number of bits in a byte. */
#define CC_BITS_IN_BYTE		8
/*! Defintion of number of bits in a 32bits word. */
#define CC_BITS_IN_32BIT_WORD	32
/*! Defintion of number of bytes in a 32bits word. */
#define CC_32BIT_WORD_SIZE	(sizeof(uint32_t))

/*! Success (OK) defintion. */
#define CC_OK   0

/*! Macro that handles unused parameters in the code (to avoid compilation warnings).  */
#define CC_UNUSED_PARAM(prm)  ((void)prm)

/*! Maximal uint32 value.*/
#define CC_MAX_UINT32_VAL 	(0xFFFFFFFF)


/* Minimum and Maximum macros */
#ifdef  min
/*! Definition for minimum. */
#define CC_MIN(a,b) min( a , b )
#else
/*! Definition for minimum. */
#define CC_MIN( a , b ) ( ( (a) < (b) ) ? (a) : (b) )
#endif

#ifdef max    
/*! Definition for maximum. */    
#define CC_MAX(a,b) max( a , b )
#else
/*! Definition for maximum. */    
#define CC_MAX( a , b ) ( ( (a) > (b) ) ? (a) : (b) )
#endif

/*! Macro that calculates number of full bytes from bits (i.e. 7 bits are 1 byte). */    
#define CALC_FULL_BYTES(numBits) 		((numBits)/CC_BITS_IN_BYTE + (((numBits) & (CC_BITS_IN_BYTE-1)) > 0)) 
/*! Macro that calculates number of full 32bits words from bits (i.e. 31 bits are 1 word). */    
#define CALC_FULL_32BIT_WORDS(numBits) 		((numBits)/CC_BITS_IN_32BIT_WORD +  (((numBits) & (CC_BITS_IN_32BIT_WORD-1)) > 0))   
/*! Macro that calculates number of full 32bits words from bytes (i.e. 3 bytes are 1 word). */    
#define CALC_32BIT_WORDS_FROM_BYTES(sizeBytes)  ((sizeBytes)/CC_32BIT_WORD_SIZE + (((sizeBytes) & (CC_32BIT_WORD_SIZE-1)) > 0)) 
/*! Macro that round up bits to 32bits words. */     
#define ROUNDUP_BITS_TO_32BIT_WORD(numBits) 	(CALC_FULL_32BIT_WORDS(numBits) * CC_BITS_IN_32BIT_WORD)
/*! Macro that round up bits to bytes. */    
#define ROUNDUP_BITS_TO_BYTES(numBits) 		(CALC_FULL_BYTES(numBits) * CC_BITS_IN_BYTE)
/*! Macro that round up bytes to 32bits words. */    
#define ROUNDUP_BYTES_TO_32BIT_WORD(sizeBytes) 	(CALC_32BIT_WORDS_FROM_BYTES(sizeBytes) * CC_32BIT_WORD_SIZE)     


/** 
@}
 */
#endif
OpenPOWER on IntegriCloud