summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/jffs2.h
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2019-10-04 16:11:30 -0500
committerJoel Sherrill <joel@rtems.org>2023-03-15 13:29:12 -0500
commit5db68a5859e2ec04b6e49ed2a04243a1b78358eb (patch)
tree35c3799d588865447b4b18e0cab0c76a8f2e7249 /cpukit/include/rtems/jffs2.h
parentcpukit/jffs2: Import wbuf.c from upstream (diff)
downloadrtems-5db68a5859e2ec04b6e49ed2a04243a1b78358eb.tar.bz2
cpukit/jffs2: Add support for NAND under JFFS2
This adds write buffer and bad block support required for JFFS2 operation on NAND devices. This also adds the minor modifications necessary for RTEMS support in the Linux header stubs and in wbuf.c. Memory and NOR backed applications should experience no difference in operation since they do not expose the callbacks required for write buffer support.
Diffstat (limited to 'cpukit/include/rtems/jffs2.h')
-rw-r--r--cpukit/include/rtems/jffs2.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/cpukit/include/rtems/jffs2.h b/cpukit/include/rtems/jffs2.h
index 1cf9a01c6e..e1dee9b582 100644
--- a/cpukit/include/rtems/jffs2.h
+++ b/cpukit/include/rtems/jffs2.h
@@ -230,6 +230,99 @@ typedef int (*rtems_jffs2_flash_erase)(
);
/**
+ * @brief Flash bad block check operation.
+ *
+ * This operation checks whether a block is bad.
+ *
+ * @param[in, out] self The flash control.
+ * @param[in] offset The offset in bytes of the block to check.
+ * @param[out] The result of the bad block check.
+ *
+ * @retval 0 Successful operation.
+ * @retval -EIO An error occurred. Please note that the value is negative.
+ * @retval other All other values are reserved and must not be used.
+ */
+typedef int (*rtems_jffs2_flash_block_is_bad)(
+ rtems_jffs2_flash_control *self,
+ uint32_t offset,
+ bool *bad
+);
+
+/**
+ * @brief Flash bad block mark operation.
+ *
+ * This operation marks a block bad.
+ *
+ * @param[in, out] self The flash control.
+ * @param[in] offset The offset in bytes of the block to mark bad.
+ *
+ * @retval 0 Successful operation.
+ * @retval -EIO An error occurred. Please note that the value is negative.
+ * @retval other All other values are reserved and must not be used.
+ */
+typedef int (*rtems_jffs2_flash_block_mark_bad)(
+ rtems_jffs2_flash_control *self,
+ uint32_t offset
+);
+
+/**
+ * @brief Flash oob write.
+ *
+ * This operation writes the out-of-band/spare bytes for the block matching
+ * the given offset in bytes.
+ *
+ * @param[in, out] self The flash control.
+ * @param[in] offset The offset to erase from the flash begin in bytes.
+ * @param[in] pointer to the buffer which will be written to the oob/spare bytes.
+ * @param[in] length of the buffer which will be written to the oob/spare bytes.
+ *
+ * @retval 0 Successful operation.
+ * @retval -EIO An error occurred. Please note that the value is negative.
+ * @retval other All other values are reserved and must not be used.
+ */
+typedef int (*rtems_jffs2_flash_oob_write)(
+ rtems_jffs2_flash_control *self,
+ uint32_t offset,
+ uint8_t *oobbuf,
+ uint32_t obblen
+);
+
+/**
+ * @brief Flash oob read.
+ *
+ * This operation reads the out-of-band/spare bytes for the block matching
+ * the given offset in bytes.
+ *
+ * @param[in, out] self The flash control.
+ * @param[in] offset The offset to erase from the flash begin in bytes.
+ * @param[out] pointer to the buffer which will have the oob/spare bytes data written to it.
+ * @param[in] length of the buffer which will hold the oob/spare bytes.
+ *
+ * @retval 0 Successful operation.
+ * @retval -EIO An error occurred. Please note that the value is negative.
+ * @retval other All other values are reserved and must not be used.
+ */
+typedef int (*rtems_jffs2_flash_oob_read)(
+ rtems_jffs2_flash_control *self,
+ uint32_t offset,
+ uint8_t *oobbuf,
+ uint32_t obblen
+);
+
+/**
+ * @brief Flash get oob size.
+ *
+ * This operation gets the size of the out-of-band/spare bytes for each page.
+ *
+ * @param[in, out] self The flash control.
+ *
+ * @retval The size of the OOB/spare area available to each page
+ */
+typedef uint32_t (*rtems_jffs2_flash_get_oob_size)(
+ rtems_jffs2_flash_control *self
+);
+
+/**
* @brief Flash destroy operation.
*
* The flash destroy operation is called during unmount of the file system
@@ -274,6 +367,14 @@ struct rtems_jffs2_flash_control {
uint32_t flash_size;
/**
+ * @brief The size in bytes of the minimum write size for the flash device.
+ *
+ * It must be an integral divisor into the block size. This is only applicable
+ * for NAND devices.
+ */
+ uint32_t write_size;
+
+ /**
* @brief Read from flash operation.
*/
rtems_jffs2_flash_read read;
@@ -289,6 +390,31 @@ struct rtems_jffs2_flash_control {
rtems_jffs2_flash_erase erase;
/**
+ * @brief Flash bad block check operation.
+ */
+ rtems_jffs2_flash_block_is_bad block_is_bad;
+
+ /**
+ * @brief Flash bad block mark operation.
+ */
+ rtems_jffs2_flash_block_mark_bad block_mark_bad;
+
+ /**
+ * @brief Flash oob bytes write operation.
+ */
+ rtems_jffs2_flash_oob_write oob_write;
+
+ /**
+ * @brief Flash oob bytes read operation.
+ */
+ rtems_jffs2_flash_oob_read oob_read;
+
+ /**
+ * @brief Flash get oob bytes per page operation.
+ */
+ rtems_jffs2_flash_get_oob_size get_oob_size;
+
+ /**
* @brief Flash destroy operation.
*
* This operation is optional and the pointer may be @c NULL.
@@ -608,6 +734,27 @@ typedef struct {
*/
#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3)
+/**
+ * Default delayed-write servicing task priority.
+ */
+#define RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT 15
+
+/**
+ * JFFS2 configuration definition. See confdefs.h for support on using this
+ * structure.
+ */
+typedef struct rtems_jffs2_config {
+ rtems_task_priority delayed_write_priority; /**< Priority of the delayed write
+ * task. */
+} rtems_jffs2_config;
+
+/**
+ * External reference to the configuration.
+ *
+ * The configuration is provided by the application.
+ */
+extern const rtems_jffs2_config jffs2_config;
+
/** @} */
#ifdef __cplusplus