1 /******************************************************************************
2  *
3  * IBM Confidential
4  *
5  * Licensed Internal Code Source Materials
6  *
7  * IBM Flexible Support Processor Licensed Internal Code
8  *
9  * (c) Copyright IBM Corp. 2004
10  *
11  * The source code is for this program is not published or otherwise divested
12  * of its trade secrets, irrespective of what has been deposited with the
13  * U.S. Copyright Office.
14  *
15  *****************************************************************************/
16 
17 #ifndef _VPDECC_H_
18 #define _VPDECC_H_
19 
20 #pragma GCC diagnostic ignored "-Wunused-variable"
21 #pragma GCC diagnostic ignored "-Wunused-parameter"
22 
23 #include <stdlib.h>
24 
25 #define VPD_ECC_OK 0
26 #define VPD_ECC_NOT_ENOUGH_BUFFER 1
27 #define VPD_ECC_WRONG_ECC_SIZE 2
28 #define VPD_ECC_WRONG_BUFFER_SIZE 9
29 #define VPD_ECC_UNCORRECTABLE_DATA 90
30 #define VPD_ECC_CORRECTABLE_DATA 91
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /* TODO  doxygen !!!!!!!! */
37 
38 /******************************************************************************/
39 /* vpdecc_create_ecc                                                          */
40 /*                                                                            */
41 /* For a given data block (together with the length of the data block         */
42 /* this function creates the ECC                                              */
43 /*                                                                            */
44 /* @param     pData           In-Buffer containing the raw VPD data           */
45 /*                                            (wont't be changed)             */
46 /*                                                                            */
47 /* @param     vDataLength     In        should contain the length of the Data */
48 /*                                      in the buffer given to vData          */
49 /*                                                                            */
50 /* @param     pEcc            Out-Buffer after execution this will be the     */
51 /*                                      buffer for the calculated Ecc         */
52 /*                                                                            */
53 /* @param     pEccLenght      In/Out    In : size of buffer                   */
54 /*                                      Out: contains the length of the Ecc   */
55 /*                                                                            */
56 /* @return Error returncode                                                   */
57 /******************************************************************************/
58 int vpdecc_create_ecc(const unsigned char* data, size_t datalength,
59                       unsigned char* ecc, size_t* ecc_buffersize);
60 
61 /******************************************************************************/
62 /* vpdecc_check_data                                                          */
63 /*                                                                            */
64 /* For a given data block (together with the ecc)                             */
65 /* this function checks the data for validness                                */
66 /*                                                                            */
67 /* @param     pData           In-Buffer containing the raw VPD data           */
68 /*                            Out-Buffer containing the raw VPD data          */
69 /*                                      No error           : data unchanged   */
70 /*                                      Correctable error  : data corrected   */
71 /*                                      Uncorrectable error: data unchanged   */
72 /*                                                                            */
73 /* @param     vDataLength     In        should contain the length of the Data */
74 /*                                      in the buffer given to vData          */
75 /*                                                                            */
76 /* @param     pEcc            In-Buffer should contain the Ecc for the data   */
77 /*                                                                            */
78 /*                                                                            */
79 /* @param     vEccLenght      In        should contain the length of the Ecc  */
80 /*                                                                            */
81 /* @return Error returncode                                                   */
82 /******************************************************************************/
83 int vpdecc_check_data(unsigned char* data, size_t data_length,
84                       const unsigned char* ecc, size_t ecc_length);
85 
86 #ifdef __cplusplus
87 } /* end extern "C" */
88 #endif
89 
90 #endif /* endif _VPDECC_H_ */
91