diff options
author | Michael Neuling <mikey@neuling.org> | 2015-02-20 11:37:50 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-02-23 13:35:48 +1100 |
commit | 6cfaa3ba1015c6ac9cc4a06f878b4289022cff54 (patch) | |
tree | 26a02098ee87fa755edd4ac53016506ca8a9b3a2 /include | |
parent | a0245321db7dce75bc2c69363c846c2089171668 (diff) | |
download | skiboot-6cfaa3ba1015c6ac9cc4a06f878b4289022cff54.zip skiboot-6cfaa3ba1015c6ac9cc4a06f878b4289022cff54.tar.gz skiboot-6cfaa3ba1015c6ac9cc4a06f878b4289022cff54.tar.bz2 |
libffs: Add ECC checking code
Add ECC checking code. This code is based on the hostboot code.
Unused currently, but will be soon. This uses __builtin_parityl() hence adding
libgcc linking previously.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/ecc.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/include/ecc.h b/include/ecc.h new file mode 100644 index 0000000..d5c30cb --- /dev/null +++ b/include/ecc.h @@ -0,0 +1,53 @@ +/* Copyright 2013-2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This is based on the hostboot ecc code */ + +#ifndef __ECC_H +#define __ECC_H + +#include <stdint.h> +#include <skiboot.h> + +/* Bit field identifiers for syndrome calculations. */ +enum eccbitfields +{ + GD = 0xff, //< Good, ECC matches. + UE = 0xfe, //< Uncorrectable. + E0 = 71, //< Error in ECC bit 0 + E1 = 70, //< Error in ECC bit 1 + E2 = 69, //< Error in ECC bit 2 + E3 = 68, //< Error in ECC bit 3 + E4 = 67, //< Error in ECC bit 4 + E5 = 66, //< Error in ECC bit 5 + E6 = 65, //< Error in ECC bit 6 + E7 = 64 //< Error in ECC bit 7 +}; + +extern uint8_t eccmemcpy(uint64_t *dst, uint64_t *src, uint32_t len); + +/* + * Calculate the size of a buffer if ECC is added + * + * We add 1 byte of ecc for every 8 bytes of data. So we need to round up to 8 + * bytes length and then add 1/8 + */ +#define ECC_SIZE(len) (ALIGN_UP((len), 8) >> 3) +#define ECC_BUFFER_SIZE(len) (ALIGN_UP((len), 8) + ECC_SIZE(len)) +#define ECC_BUFFER_SIZE_CHECK(len) ((len) % 9) +#define BUFFER_SIZE_MINUS_ECC(len) ((len) * 8 / 9) + +#endif |