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 #include <stdlib.h> 21 22 #define VPD_ECC_OK 0 23 #define VPD_ECC_NOT_ENOUGH_BUFFER 1 24 #define VPD_ECC_WRONG_ECC_SIZE 2 25 #define VPD_ECC_WRONG_BUFFER_SIZE 9 26 #define VPD_ECC_UNCORRECTABLE_DATA 90 27 #define VPD_ECC_CORRECTABLE_DATA 91 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* TODO doxygen !!!!!!!! */ 34 35 /******************************************************************************/ 36 /* vpdecc_create_ecc */ 37 /* */ 38 /* For a given data block (together with the length of the data block */ 39 /* this function creates the ECC */ 40 /* */ 41 /* @param pData In-Buffer containing the raw VPD data */ 42 /* (wont't be changed) */ 43 /* */ 44 /* @param vDataLength In should contain the length of the Data */ 45 /* in the buffer given to vData */ 46 /* */ 47 /* @param pEcc Out-Buffer after execution this will be the */ 48 /* buffer for the calculated Ecc */ 49 /* */ 50 /* @param pEccLenght In/Out In : size of buffer */ 51 /* Out: contains the length of the Ecc */ 52 /* */ 53 /* @return Error returncode */ 54 /******************************************************************************/ 55 int vpdecc_create_ecc(const unsigned char* data, size_t datalength, 56 unsigned char* ecc, size_t* ecc_buffersize); 57 58 /******************************************************************************/ 59 /* vpdecc_check_data */ 60 /* */ 61 /* For a given data block (together with the ecc) */ 62 /* this function checks the data for validness */ 63 /* */ 64 /* @param pData In-Buffer containing the raw VPD data */ 65 /* Out-Buffer containing the raw VPD data */ 66 /* No error : data unchanged */ 67 /* Correctable error : data corrected */ 68 /* Uncorrectable error: data unchanged */ 69 /* */ 70 /* @param vDataLength In should contain the length of the Data */ 71 /* in the buffer given to vData */ 72 /* */ 73 /* @param pEcc In-Buffer should contain the Ecc for the data */ 74 /* */ 75 /* */ 76 /* @param vEccLenght In should contain the length of the Ecc */ 77 /* */ 78 /* @return Error returncode */ 79 /******************************************************************************/ 80 int vpdecc_check_data(unsigned char* data, size_t data_length, 81 const unsigned char* ecc, size_t ecc_length); 82 83 #ifdef __cplusplus 84 } /* end extern "C" */ 85 #endif 86 87 #endif /* endif _VPDECC_H_ */ 88