AM62Px MCU+ SDK  09.01.00
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 
42 #ifndef _sdl_ip_rom_checksum_H
43 #define _sdl_ip_rom_checksum_H
44 #include <inttypes.h>
45 #include <stdbool.h>
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51 
52 /* Various logical functions */
53 #define SDL_ch(x,y,z) (z ^ (x & (y ^ z))) //this function will (x AND y) XOR (NOT x AND z)
54 #define SDL_Maj(x,y,z) (((x | y) & z) | (x & y))
55 #define SDL_S(x, n) (SDL_ROR64c(x, n)) //Rotate right circular shift by n bits
56 #define SDL_R(x, n) (((uint64_t)(x)&SDL_CONST64(0xFFFFFFFFFFFFFFFFU))>>((uint64_t)n)) // Rotate left circular shift by n bits
57 #define SDL_Sigma0(x) (SDL_S(x, 28) ^ SDL_S(x, 34) ^ SDL_S(x, 39))
58 #define SDL_Sigma1(x) (SDL_S(x, 14) ^ SDL_S(x, 18) ^ SDL_S(x, 41))
59 #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
60 #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
61 #define SDL_BLOCK_SIZE (uint8_t)128 //Size of each block which will be processed;
62 #define SDL_MIN(x, y) ( ((x)<(y))?(x):(y) )
63 #define SDL_CONST64(x) (uint64_t)x
64 
65 
91 typedef struct
92 {
94  uint64_t length;
95 
97  uint64_t state[8];
98 
100  uint32_t curlen;
101 
103  uint8_t buf[128];
105 
107 /********************************************************************************************************
108 * Below are the Declarations of Low Level Functions
109 ********************************************************************************************************/
110 
121 
130 int32_t SDL_ROM_Checksum_process (SDL_ROM_Checksum_obj * md, uint8_t *in, uint32_t inlen);
131 
137 
146 
147 
156 int32_t SDL_ROM_Checksum_compareResult (uint64_t buflen, SDL_ROM_Checksum_obj * md, uint64_t *golden_value);
157 
162 void SDL_memcpy(void *dest, void *src, uint32_t n);
163 
166 #ifdef __cplusplus
167 }
168 #endif
169 #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:100
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:92
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:94
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.