blob: 705d10779cd8d65d8eb0d4f0a37f813c92aa0b01 [file] [log] [blame]
Patrick Williamsc78d8872023-05-10 07:50:56 -05001#ifndef _VPDECC_H_
2#define _VPDECC_H_
3
4#pragma GCC diagnostic ignored "-Wunused-variable"
5#pragma GCC diagnostic ignored "-Wunused-parameter"
6
7#include <stdlib.h>
8
9#define VPD_ECC_OK 0
10#define VPD_ECC_NOT_ENOUGH_BUFFER 1
11#define VPD_ECC_WRONG_ECC_SIZE 2
12#define VPD_ECC_WRONG_BUFFER_SIZE 9
13#define VPD_ECC_UNCORRECTABLE_DATA 90
14#define VPD_ECC_CORRECTABLE_DATA 91
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif
20
Patrick Williamsb7b352a2023-10-20 11:19:19 -050021/* TODO doxygen !!!!!!!! */
Patrick Williamsc78d8872023-05-10 07:50:56 -050022
Patrick Williamsb7b352a2023-10-20 11:19:19 -050023/******************************************************************************/
24/* vpdecc_create_ecc */
25/* */
26/* For a given data block (together with the length of the data block */
27/* this function creates the ECC */
28/* */
29/* @param pData In-Buffer containing the raw VPD data */
Manojkiran Edaaf921752024-06-17 15:10:21 +053030/* (won't be changed) */
Patrick Williamsb7b352a2023-10-20 11:19:19 -050031/* */
32/* @param vDataLength In should contain the length of the
33 * Data */
34/* in the buffer given to vData */
35/* */
36/* @param pEcc Out-Buffer after execution this will be the */
37/* buffer for the calculated Ecc */
38/* */
39/* @param pEccLenght In/Out In : size of buffer */
40/* Out: contains the length of the Ecc
41 */
42/* */
43/* @return Error returncode */
44/******************************************************************************/
45int vpdecc_create_ecc(const unsigned char* data, size_t datalength,
46 unsigned char* ecc, size_t* ecc_buffersize);
Patrick Williamsc78d8872023-05-10 07:50:56 -050047
Patrick Williamsb7b352a2023-10-20 11:19:19 -050048/******************************************************************************/
49/* vpdecc_check_data */
50/* */
51/* For a given data block (together with the ecc) */
52/* this function checks the data for validness */
53/* */
54/* @param pData In-Buffer containing the raw VPD data */
55/* Out-Buffer containing the raw VPD data */
56/* No error : data unchanged
57 */
58/* Correctable error : data corrected
59 */
60/* Uncorrectable error: data unchanged
61 */
62/* */
63/* @param vDataLength In should contain the length of the
64 * Data */
65/* in the buffer given to vData */
66/* */
67/* @param pEcc In-Buffer should contain the Ecc for the data
68 */
69/* */
70/* */
71/* @param vEccLenght In should contain the length of the Ecc
72 */
73/* */
74/* @return Error returncode */
75/******************************************************************************/
76int vpdecc_check_data(unsigned char* data, size_t data_length,
77 const unsigned char* ecc, size_t ecc_length);
Patrick Williamsc78d8872023-05-10 07:50:56 -050078
79#ifdef __cplusplus
80} /* end extern "C" */
81#endif
82
83#endif /* endif _VPDECC_H_ */