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