xref: /openbmc/openpower-vpd-parser/vpdecc/vpdecc.h (revision abe481e189bf716ec0e1914159e8c25ac404d753)
1 #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
17 extern "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_ */
84