]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A5_SAMA5D2x_Xplained_IAR/AtmelFiles/target/sama5d2/component/component_sha.h
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D2x_Xplained_IAR / AtmelFiles / target / sama5d2 / component / component_sha.h
1 /* ---------------------------------------------------------------------------- */\r
2 /*                  Atmel Microcontroller Software Support                      */\r
3 /*                       SAM Software Package License                           */\r
4 /* ---------------------------------------------------------------------------- */\r
5 /* Copyright (c) 2015, Atmel Corporation                                        */\r
6 /*                                                                              */\r
7 /* All rights reserved.                                                         */\r
8 /*                                                                              */\r
9 /* Redistribution and use in source and binary forms, with or without           */\r
10 /* modification, are permitted provided that the following condition is met:    */\r
11 /*                                                                              */\r
12 /* - Redistributions of source code must retain the above copyright notice,     */\r
13 /* this list of conditions and the disclaimer below.                            */\r
14 /*                                                                              */\r
15 /* Atmel's name may not be used to endorse or promote products derived from     */\r
16 /* this software without specific prior written permission.                     */\r
17 /*                                                                              */\r
18 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */\r
19 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */\r
20 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */\r
21 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */\r
22 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */\r
23 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */\r
24 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */\r
25 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */\r
26 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */\r
27 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */\r
28 /* ---------------------------------------------------------------------------- */\r
29 \r
30 #ifndef _SAMA5D2_SHA_COMPONENT_\r
31 #define _SAMA5D2_SHA_COMPONENT_\r
32 \r
33 /* ============================================================================= */\r
34 /**  SOFTWARE API DEFINITION FOR Secure Hash Algorithm */\r
35 /* ============================================================================= */\r
36 /** \addtogroup SAMA5D2_SHA Secure Hash Algorithm */\r
37 /*@{*/\r
38 \r
39 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))\r
40 /** \brief Sha hardware registers */\r
41 typedef struct {\r
42   __O  uint32_t SHA_CR;          /**< \brief (Sha Offset: 0x00) Control Register */\r
43   __IO uint32_t SHA_MR;          /**< \brief (Sha Offset: 0x04) Mode Register */\r
44   __I  uint32_t Reserved1[2];\r
45   __O  uint32_t SHA_IER;         /**< \brief (Sha Offset: 0x10) Interrupt Enable Register */\r
46   __O  uint32_t SHA_IDR;         /**< \brief (Sha Offset: 0x14) Interrupt Disable Register */\r
47   __I  uint32_t SHA_IMR;         /**< \brief (Sha Offset: 0x18) Interrupt Mask Register */\r
48   __I  uint32_t SHA_ISR;         /**< \brief (Sha Offset: 0x1C) Interrupt Status Register */\r
49   __IO uint32_t SHA_MSR;         /**< \brief (Sha Offset: 0x20) Message Size Register */\r
50   __I  uint32_t Reserved2[3];\r
51   __IO uint32_t SHA_BCR;         /**< \brief (Sha Offset: 0x30) Bytes Count Register */\r
52   __I  uint32_t Reserved3[3];\r
53   __O  uint32_t SHA_IDATAR[16];  /**< \brief (Sha Offset: 0x40) Input Data 0 Register */\r
54   __IO uint32_t SHA_IODATAR[16]; /**< \brief (Sha Offset: 0x80) Input/Output Data 0 Register */\r
55   __I  uint32_t SHA_VERSION;     /**< \brief (Sha Offset: 0xFC) Version Register */\r
56 } Sha;\r
57 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */\r
58 /* -------- SHA_CR : (SHA Offset: 0x00) Control Register -------- */\r
59 #define SHA_CR_START (0x1u << 0) /**< \brief (SHA_CR) Start Processing */\r
60 #define SHA_CR_FIRST (0x1u << 4) /**< \brief (SHA_CR) First Block of a Message */\r
61 #define SHA_CR_SWRST (0x1u << 8) /**< \brief (SHA_CR) Software Reset */\r
62 #define SHA_CR_WUIHV (0x1u << 12) /**< \brief (SHA_CR) Write User Initial Hash Values */\r
63 #define SHA_CR_WUIEHV (0x1u << 13) /**< \brief (SHA_CR) Write User Initial or Expected Hash Values */\r
64 /* -------- SHA_MR : (SHA Offset: 0x04) Mode Register -------- */\r
65 #define SHA_MR_SMOD_Pos 0\r
66 #define SHA_MR_SMOD_Msk (0x3u << SHA_MR_SMOD_Pos) /**< \brief (SHA_MR) Start Mode */\r
67 #define SHA_MR_SMOD(value) ((SHA_MR_SMOD_Msk & ((value) << SHA_MR_SMOD_Pos)))\r
68 #define   SHA_MR_SMOD_MANUAL_START (0x0u << 0) /**< \brief (SHA_MR) Manual Mode */\r
69 #define   SHA_MR_SMOD_AUTO_START (0x1u << 0) /**< \brief (SHA_MR) Auto Mode */\r
70 #define   SHA_MR_SMOD_IDATAR0_START (0x2u << 0) /**< \brief (SHA_MR) SHA_IDATAR0 access only Auto Mode */\r
71 #define SHA_MR_PROCDLY (0x1u << 4) /**< \brief (SHA_MR) Processing Delay */\r
72 #define   SHA_MR_PROCDLY_SHORTEST (0x0u << 4) /**< \brief (SHA_MR) SHA processing runtime is the shortest one */\r
73 #define   SHA_MR_PROCDLY_LONGEST (0x1u << 4) /**< \brief (SHA_MR) SHA processing runtime is the longest one (reduces the SHA bandwidth requirement, reduces the system bus overload) */\r
74 #define SHA_MR_UIHV (0x1u << 5) /**< \brief (SHA_MR) User Initial Hash Value Registers */\r
75 #define SHA_MR_UIEHV (0x1u << 6) /**< \brief (SHA_MR) User Initial or Expected Hash Value Registers */\r
76 #define SHA_MR_ALGO_Pos 8\r
77 #define SHA_MR_ALGO_Msk (0xfu << SHA_MR_ALGO_Pos) /**< \brief (SHA_MR) SHA Algorithm */\r
78 #define SHA_MR_ALGO(value) ((SHA_MR_ALGO_Msk & ((value) << SHA_MR_ALGO_Pos)))\r
79 #define   SHA_MR_ALGO_SHA1 (0x0u << 8) /**< \brief (SHA_MR) SHA1 algorithm processed */\r
80 #define   SHA_MR_ALGO_SHA256 (0x1u << 8) /**< \brief (SHA_MR) SHA256 algorithm processed */\r
81 #define   SHA_MR_ALGO_SHA384 (0x2u << 8) /**< \brief (SHA_MR) SHA384 algorithm processed */\r
82 #define   SHA_MR_ALGO_SHA512 (0x3u << 8) /**< \brief (SHA_MR) SHA512 algorithm processed */\r
83 #define   SHA_MR_ALGO_SHA224 (0x4u << 8) /**< \brief (SHA_MR) SHA224 algorithm processed */\r
84 #define   SHA_MR_ALGO_HMAC_SHA1 (0x8u << 8) /**< \brief (SHA_MR) HMAC algorithm with SHA1 Hash processed */\r
85 #define   SHA_MR_ALGO_HMAC_SHA256 (0x9u << 8) /**< \brief (SHA_MR) HMAC algorithm with SHA256 Hash processed */\r
86 #define   SHA_MR_ALGO_HMAC_SHA384 (0xAu << 8) /**< \brief (SHA_MR) HMAC algorithm with SHA384 Hash processed */\r
87 #define   SHA_MR_ALGO_HMAC_SHA512 (0xBu << 8) /**< \brief (SHA_MR) HMAC algorithm with SHA512 Hash processed */\r
88 #define   SHA_MR_ALGO_HMAC_SHA224 (0xCu << 8) /**< \brief (SHA_MR) HMAC algorithm with SHA224 Hash processed */\r
89 #define SHA_MR_DUALBUFF (0x1u << 16) /**< \brief (SHA_MR) Dual Input Buffer */\r
90 #define   SHA_MR_DUALBUFF_INACTIVE (0x0u << 16) /**< \brief (SHA_MR) SHA_IDATARx and SHA_IODATARx cannot be written during processing of previous block. */\r
91 #define   SHA_MR_DUALBUFF_ACTIVE (0x1u << 16) /**< \brief (SHA_MR) SHA_IDATARx and SHA_IODATARx can be written during processing of previous block when SMOD value = 2. It speeds up the overall runtime of large files. */\r
92 #define SHA_MR_CHECK_Pos 24\r
93 #define SHA_MR_CHECK_Msk (0x3u << SHA_MR_CHECK_Pos) /**< \brief (SHA_MR) Hash Check */\r
94 #define SHA_MR_CHECK(value) ((SHA_MR_CHECK_Msk & ((value) << SHA_MR_CHECK_Pos)))\r
95 #define   SHA_MR_CHECK_NO_CHECK (0x0u << 24) /**< \brief (SHA_MR) No check is performed */\r
96 #define   SHA_MR_CHECK_CHECK_EHV (0x1u << 24) /**< \brief (SHA_MR) Check is performed with expected hash stored in internal expected hash value registers. */\r
97 #define   SHA_MR_CHECK_CHECK_MESSAGE (0x2u << 24) /**< \brief (SHA_MR) Check is performed with expected hash provided after the message. */\r
98 #define SHA_MR_CHKCNT_Pos 28\r
99 #define SHA_MR_CHKCNT_Msk (0xfu << SHA_MR_CHKCNT_Pos) /**< \brief (SHA_MR) Check Counter */\r
100 #define SHA_MR_CHKCNT(value) ((SHA_MR_CHKCNT_Msk & ((value) << SHA_MR_CHKCNT_Pos)))\r
101 /* -------- SHA_IER : (SHA Offset: 0x10) Interrupt Enable Register -------- */\r
102 #define SHA_IER_DATRDY (0x1u << 0) /**< \brief (SHA_IER) Data Ready Interrupt Enable */\r
103 #define SHA_IER_URAD (0x1u << 8) /**< \brief (SHA_IER) Unspecified Register Access Detection Interrupt Enable */\r
104 #define SHA_IER_CHECKF (0x1u << 16) /**< \brief (SHA_IER) Check Done Interrupt Enable */\r
105 /* -------- SHA_IDR : (SHA Offset: 0x14) Interrupt Disable Register -------- */\r
106 #define SHA_IDR_DATRDY (0x1u << 0) /**< \brief (SHA_IDR) Data Ready Interrupt Disable */\r
107 #define SHA_IDR_URAD (0x1u << 8) /**< \brief (SHA_IDR) Unspecified Register Access Detection Interrupt Disable */\r
108 #define SHA_IDR_CHECKF (0x1u << 16) /**< \brief (SHA_IDR) Check Done Interrupt Disable */\r
109 /* -------- SHA_IMR : (SHA Offset: 0x18) Interrupt Mask Register -------- */\r
110 #define SHA_IMR_DATRDY (0x1u << 0) /**< \brief (SHA_IMR) Data Ready Interrupt Mask */\r
111 #define SHA_IMR_URAD (0x1u << 8) /**< \brief (SHA_IMR) Unspecified Register Access Detection Interrupt Mask */\r
112 #define SHA_IMR_CHECKF (0x1u << 16) /**< \brief (SHA_IMR) Check Done Interrupt Mask */\r
113 /* -------- SHA_ISR : (SHA Offset: 0x1C) Interrupt Status Register -------- */\r
114 #define SHA_ISR_DATRDY (0x1u << 0) /**< \brief (SHA_ISR) Data Ready (cleared by writing a 1 to bit SWRST or START in SHA_CR, or by reading SHA_IODATARx) */\r
115 #define SHA_ISR_WRDY (0x1u << 4) /**< \brief (SHA_ISR) Input Data Register Write Ready */\r
116 #define SHA_ISR_URAD (0x1u << 8) /**< \brief (SHA_ISR) Unspecified Register Access Detection Status (cleared by writing a 1 to SWRST bit in SHA_CR) */\r
117 #define SHA_ISR_URAT_Pos 12\r
118 #define SHA_ISR_URAT_Msk (0x7u << SHA_ISR_URAT_Pos) /**< \brief (SHA_ISR) Unspecified Register Access Type (cleared by writing a 1 to SWRST bit in SHA_CR) */\r
119 #define SHA_ISR_CHECKF (0x1u << 16) /**< \brief (SHA_ISR) Check Done Status (cleared by writing START or SWRST bits in SHA_CR or by reading SHA_IODATARx) */\r
120 #define SHA_ISR_CHKST_Pos 20\r
121 #define SHA_ISR_CHKST_Msk (0xfu << SHA_ISR_CHKST_Pos) /**< \brief (SHA_ISR) Check Status (cleared by writing START or SWRST bits in SHA_CR or by reading SHA_IODATARx) */\r
122 /* -------- SHA_MSR : (SHA Offset: 0x20) Message Size Register -------- */\r
123 #define SHA_MSR_MSGSIZE_Pos 0\r
124 #define SHA_MSR_MSGSIZE_Msk (0xffffffffu << SHA_MSR_MSGSIZE_Pos) /**< \brief (SHA_MSR) Message Size */\r
125 #define SHA_MSR_MSGSIZE(value) ((SHA_MSR_MSGSIZE_Msk & ((value) << SHA_MSR_MSGSIZE_Pos)))\r
126 /* -------- SHA_BCR : (SHA Offset: 0x30) Bytes Count Register -------- */\r
127 #define SHA_BCR_BYTCNT_Pos 0\r
128 #define SHA_BCR_BYTCNT_Msk (0xffffffffu << SHA_BCR_BYTCNT_Pos) /**< \brief (SHA_BCR) Remaining Byte Count Before Auto Padding */\r
129 #define SHA_BCR_BYTCNT(value) ((SHA_BCR_BYTCNT_Msk & ((value) << SHA_BCR_BYTCNT_Pos)))\r
130 /* -------- SHA_IDATAR[16] : (SHA Offset: 0x40) Input Data 0 Register -------- */\r
131 #define SHA_IDATAR_IDATA_Pos 0\r
132 #define SHA_IDATAR_IDATA_Msk (0xffffffffu << SHA_IDATAR_IDATA_Pos) /**< \brief (SHA_IDATAR[16]) Input Data */\r
133 #define SHA_IDATAR_IDATA(value) ((SHA_IDATAR_IDATA_Msk & ((value) << SHA_IDATAR_IDATA_Pos)))\r
134 /* -------- SHA_IODATAR[16] : (SHA Offset: 0x80) Input/Output Data 0 Register -------- */\r
135 #define SHA_IODATAR_IODATA_Pos 0\r
136 #define SHA_IODATAR_IODATA_Msk (0xffffffffu << SHA_IODATAR_IODATA_Pos) /**< \brief (SHA_IODATAR[16]) Input/Output Data */\r
137 #define SHA_IODATAR_IODATA(value) ((SHA_IODATAR_IODATA_Msk & ((value) << SHA_IODATAR_IODATA_Pos)))\r
138 /* -------- SHA_VERSION : (SHA Offset: 0xFC) Version Register -------- */\r
139 #define SHA_VERSION_VERSION_Pos 0\r
140 #define SHA_VERSION_VERSION_Msk (0xfffu << SHA_VERSION_VERSION_Pos) /**< \brief (SHA_VERSION) Version of the Hardware Module */\r
141 #define SHA_VERSION_MFN_Pos 16\r
142 #define SHA_VERSION_MFN_Msk (0x7u << SHA_VERSION_MFN_Pos) /**< \brief (SHA_VERSION) Metal Fix Number */\r
143 \r
144 /*@}*/\r
145 \r
146 \r
147 #endif /* _SAMA5D2_SHA_COMPONENT_ */\r