aboutsummaryrefslogtreecommitdiff
path: root/libflash/ecc.h
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-02-24 08:58:50 +0800
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-02-26 16:29:04 +1100
commit7c4cea4a1690489233a14c2df01ddcc8f8e9ff8b (patch)
treefd0493a660d3eb32c745190a75e86541a471edaa /libflash/ecc.h
parent46bc7ec7d4857f50908dd1daf914766057b86d7c (diff)
downloadskiboot-7c4cea4a1690489233a14c2df01ddcc8f8e9ff8b.zip
skiboot-7c4cea4a1690489233a14c2df01ddcc8f8e9ff8b.tar.gz
skiboot-7c4cea4a1690489233a14c2df01ddcc8f8e9ff8b.tar.bz2
libflash: move ecc.h into libflash/
The ecc.h header is used by libflash, so should sit in libflash, to allow non-skiboot tools to access it. This change is a simple move of the header file - no changes are made to the header itself. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-By: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash/ecc.h')
-rw-r--r--libflash/ecc.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/libflash/ecc.h b/libflash/ecc.h
new file mode 100644
index 0000000..d5c30cb
--- /dev/null
+++ b/libflash/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