AM243x MCU+ SDK  09.02.01
sdl_ip_rom_checksum.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2023 Texas Instruments Incorporated.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
43 #ifndef _sdl_ip_rom_checksum_H
44 #define _sdl_ip_rom_checksum_H
45 #include <inttypes.h>
46 #include <stdbool.h>
47 
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 /* Various logical functions */
54 #define SDL_ch(x,y,z) (z ^ (x & (y ^ z))) //this function will (x AND y) XOR (NOT x AND z)
55 #define SDL_Maj(x,y,z) (((x | y) & z) | (x & y))
56 #define SDL_S(x, n) (SDL_ROR64c(x, n)) //Rotate right circular shift by n bits
57 #define SDL_R(x, n) (((uint64_t)(x)&SDL_CONST64(0xFFFFFFFFFFFFFFFFU))>>((uint64_t)n)) // Rotate left circular shift by n bits
58 #define SDL_Sigma0(x) (SDL_S(x, 28) ^ SDL_S(x, 34) ^ SDL_S(x, 39))
59 #define SDL_Sigma1(x) (SDL_S(x, 14) ^ SDL_S(x, 18) ^ SDL_S(x, 41))
60 #define SDL_Gamma0(x) (uint64_t)(SDL_S(x, 1) ^ SDL_S(x, 8) ^ SDL_R(x, 7)) // we perform the left and right shift after that we will perform the XOR of all the results
61 #define SDL_Gamma1(x) (uint64_t)(SDL_S(x, 19) ^ SDL_S(x, 61) ^ SDL_R(x, 6)) // we perform the left and right shift after that we will perform the XOR of all the results
62 #define SDL_BLOCK_SIZE (uint8_t)128 //Size of each block which will be processed;
63 #define SDL_MIN(x, y) ( ((x)<(y))?(x):(y) )
64 #define SDL_CONST64(x) (uint64_t)x
65 
66 
92 typedef struct
93 {
95  uint64_t length;
96 
98  uint64_t state[8];
99 
101  uint32_t curlen;
102 
104  uint8_t buf[128];
106 
108 /********************************************************************************************************
109 * Below are the Declarations of Low Level Functions
110 ********************************************************************************************************/
111 
122 
131 int32_t SDL_ROM_Checksum_process (SDL_ROM_Checksum_obj * md, uint8_t *in, uint32_t inlen);
132 
138 
147 
148 
157 int32_t SDL_ROM_Checksum_compareResult (uint64_t buflen, SDL_ROM_Checksum_obj * md, uint64_t *golden_value);
158 
163 void SDL_memcpy(void *dest, void *src, uint32_t n);
164 
167 #ifdef __cplusplus
168 }
169 #endif
170 #endif /* _sdl_ip_rom_checksum_H */
SDL_ROM_Checksum_compareResult
int32_t SDL_ROM_Checksum_compareResult(uint64_t buflen, SDL_ROM_Checksum_obj *md, uint64_t *golden_value)
This API will compare the resultant hash value of golden value.
SDL_ROM_Checksum_compress
void SDL_ROM_Checksum_compress(SDL_ROM_Checksum_obj *md, uint8_t *buf)
This API is used to compress the data of ROM region and store the result in md->state.
SDL_memcpy
void SDL_memcpy(void *dest, void *src, uint32_t n)
This API will copy source pointer data to destination pointer.
SDL_ROM_Checksum_obj::curlen
uint32_t curlen
Definition: sdl_ip_rom_checksum.h:101
state
uint8_t state
Definition: tisci_pm_clock.h:3
SDL_ROM_Checksum_obj
This structure is used to store the resultant value of ROM Checksum.
Definition: sdl_ip_rom_checksum.h:93
SDL_ROM_Checksum_done
int32_t SDL_ROM_Checksum_done(SDL_ROM_Checksum_obj *md)
This API will increase our data length with the help of padding ( because our algorithm can compress ...
SDL_ROM_Checksum_init
void SDL_ROM_Checksum_init(SDL_ROM_Checksum_obj *const md)
This API will Initialize the buffer where hash value to be stored.
SDL_ROM_Checksum_obj::length
uint64_t length
Definition: sdl_ip_rom_checksum.h:95
SDL_ROM_Checksum_process
int32_t SDL_ROM_Checksum_process(SDL_ROM_Checksum_obj *md, uint8_t *in, uint32_t inlen)
This API is used to process the ROM region data.