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 { 35 #endif 36 37 /* TODO doxygen !!!!!!!! */ 38 39 /******************************************************************************/ 40 /* vpdecc_create_ecc */ 41 /* */ 42 /* For a given data block (together with the length of the data block */ 43 /* this function creates the ECC */ 44 /* */ 45 /* @param pData In-Buffer containing the raw VPD data */ 46 /* (wont't be changed) */ 47 /* */ 48 /* @param vDataLength In should contain the length of the 49 * Data */ 50 /* in the buffer given to vData */ 51 /* */ 52 /* @param pEcc Out-Buffer after execution this will be the */ 53 /* buffer for the calculated Ecc */ 54 /* */ 55 /* @param pEccLenght In/Out In : size of buffer */ 56 /* Out: contains the length of the Ecc 57 */ 58 /* */ 59 /* @return Error returncode */ 60 /******************************************************************************/ 61 int vpdecc_create_ecc(const unsigned char* data, size_t datalength, 62 unsigned char* ecc, size_t* ecc_buffersize); 63 64 /******************************************************************************/ 65 /* vpdecc_check_data */ 66 /* */ 67 /* For a given data block (together with the ecc) */ 68 /* this function checks the data for validness */ 69 /* */ 70 /* @param pData In-Buffer containing the raw VPD data */ 71 /* Out-Buffer containing the raw VPD data */ 72 /* No error : data unchanged 73 */ 74 /* Correctable error : data corrected 75 */ 76 /* Uncorrectable error: data unchanged 77 */ 78 /* */ 79 /* @param vDataLength In should contain the length of the 80 * Data */ 81 /* in the buffer given to vData */ 82 /* */ 83 /* @param pEcc In-Buffer should contain the Ecc for the data 84 */ 85 /* */ 86 /* */ 87 /* @param vEccLenght In should contain the length of the Ecc 88 */ 89 /* */ 90 /* @return Error returncode */ 91 /******************************************************************************/ 92 int vpdecc_check_data(unsigned char* data, size_t data_length, 93 const unsigned char* ecc, size_t ecc_length); 94 95 #ifdef __cplusplus 96 } /* end extern "C" */ 97 #endif 98 99 #endif /* endif _VPDECC_H_ */ 100