blob: 999519245725d5c951e929db412e4e5481524eac [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
21 /* TODO doxygen !!!!!!!! */
22
23 /******************************************************************************/
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 */
30 /* (wont't be changed) */
31 /* */
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 /******************************************************************************/
45 int vpdecc_create_ecc(const unsigned char* data, size_t datalength,
46 unsigned char* ecc, size_t* ecc_buffersize);
47
48 /******************************************************************************/
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 /******************************************************************************/
76 int vpdecc_check_data(unsigned char* data, size_t data_length,
77 const unsigned char* ecc, size_t ecc_length);
78
79#ifdef __cplusplus
80} /* end extern "C" */
81#endif
82
83#endif /* endif _VPDECC_H_ */