1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /*! 8 @addtogroup cc_pal_types 9 @{ 10 */ 11 12 /*! 13 @file 14 @brief This file contains definitions and types of CryptoCell PAL platform-dependent APIs. 15 */ 16 17 #ifndef CC_PAL_TYPES_H 18 #define CC_PAL_TYPES_H 19 20 #include "cc_pal_types_plat.h" 21 22 /*! Boolean types.*/ 23 typedef enum { 24 /*! Boolean false definition.*/ 25 CC_FALSE = 0, 26 /*! Boolean true definition.*/ 27 CC_TRUE = 1 28 } CCBool; 29 30 /*! Success definition. */ 31 #define CC_SUCCESS 0UL 32 /*! Failure definition. */ 33 #define CC_FAIL 1UL 34 35 /*! Success (OK) definition. */ 36 #define CC_OK 0 37 38 /*! Handles unused parameters in the code, to avoid compilation warnings. */ 39 #define CC_UNUSED_PARAM(prm) ((void)prm) 40 41 /*! The maximal uint32 value.*/ 42 #define CC_MAX_UINT32_VAL (0xFFFFFFFF) 43 44 45 /* Minimal and Maximal macros */ 46 #ifdef min 47 /*! Definition for minimal calculation. */ 48 #define CC_MIN(a,b) min( a , b ) 49 #else 50 /*! Definition for minimal calculation. */ 51 #define CC_MIN( a , b ) ( ( (a) < (b) ) ? (a) : (b) ) 52 #endif 53 54 #ifdef max 55 /*! Definition for maximal calculation. */ 56 #define CC_MAX(a,b) max( a , b ) 57 #else 58 /*! Definition for maximal calculation.. */ 59 #define CC_MAX( a , b ) ( ( (a) > (b) ) ? (a) : (b) ) 60 #endif 61 62 /*! This macro calculates the number of full bytes from bits, where seven bits 63 are one byte. */ 64 #define CALC_FULL_BYTES(numBits) ((numBits)/CC_BITS_IN_BYTE + (((numBits) & (CC_BITS_IN_BYTE-1)) > 0)) 65 /*! This macro calculates the number of full 32-bit words from bits, where 66 31 bits are one word. */ 67 #define CALC_FULL_32BIT_WORDS(numBits) ((numBits)/CC_BITS_IN_32BIT_WORD + (((numBits) & (CC_BITS_IN_32BIT_WORD-1)) > 0)) 68 /*! This macro calculates the number of full 32-bit words from bytes, where 69 three bytes are one word. */ 70 #define CALC_32BIT_WORDS_FROM_BYTES(sizeBytes) ((sizeBytes)/CC_32BIT_WORD_SIZE + (((sizeBytes) & (CC_32BIT_WORD_SIZE-1)) > 0)) 71 /*! This macro calculates the number of full 32-bit words from 64-bits 72 dwords. */ 73 #define CALC_32BIT_WORDS_FROM_64BIT_DWORD(sizeWords) (sizeWords * CC_32BIT_WORD_IN_64BIT_DWORD) 74 /*! This macro rounds up bits to 32-bit words. */ 75 #define ROUNDUP_BITS_TO_32BIT_WORD(numBits) (CALC_FULL_32BIT_WORDS(numBits) * CC_BITS_IN_32BIT_WORD) 76 /*! This macro rounds up bits to bytes. */ 77 #define ROUNDUP_BITS_TO_BYTES(numBits) (CALC_FULL_BYTES(numBits) * CC_BITS_IN_BYTE) 78 /*! This macro rounds up bytes to 32-bit words. */ 79 #define ROUNDUP_BYTES_TO_32BIT_WORD(sizeBytes) (CALC_32BIT_WORDS_FROM_BYTES(sizeBytes) * CC_32BIT_WORD_SIZE) 80 /*! Definition of 1 KB in bytes. */ 81 #define CC_1K_SIZE_IN_BYTES 1024 82 /*! Definition of number of bits in a byte. */ 83 #define CC_BITS_IN_BYTE 8 84 /*! Definition of number of bits in a 32-bits word. */ 85 #define CC_BITS_IN_32BIT_WORD 32 86 /*! Definition of number of bytes in a 32-bits word. */ 87 #define CC_32BIT_WORD_SIZE 4 88 /*! Definition of number of 32-bits words in a 64-bits dword. */ 89 #define CC_32BIT_WORD_IN_64BIT_DWORD 2 90 91 92 /*! 93 @} 94 */ 95 #endif 96 97