dfs_uffs.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2012-03-30 prife the first version
  9. */
  10. #ifndef DFS_UFFS_H_
  11. #define DFS_UFFS_H_
  12. #include "uffs_config.h"
  13. #include "uffs/uffs_public.h"
  14. /* the UFFS ECC mode opitons */
  15. #ifndef RT_UFFS_ECC_MODE
  16. #define RT_UFFS_ECC_MODE 1
  17. #endif
  18. /*
  19. * RT_UFFS_ECC_MODE:
  20. * 0, Do not use ECC
  21. * 1, UFFS calculate the ECC
  22. * 2, Flash driver(or by hardware) calculate the ECC
  23. * 3, Hardware calculate the ECC and automatically write to spare.
  24. */
  25. #if RT_UFFS_ECC_MODE == 0
  26. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE
  27. #elif RT_UFFS_ECC_MODE == 1
  28. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT
  29. #elif RT_UFFS_ECC_MODE == 2
  30. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW
  31. #elif RT_UFFS_ECC_MODE == 3
  32. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO
  33. #endif
  34. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO */
  35. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT */
  36. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE */
  37. /* enable this ,you need provide a mark_badblock/check_block funciton */
  38. /* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */
  39. #if RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT /* let uffs do soft ecc */
  40. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */
  41. #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO /* nand driver make ecc and do ecc correct */
  42. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_FLASH
  43. #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_NONE
  44. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */
  45. #else
  46. #error "uffs under rt-thread do not support this ECC mode"
  47. #endif /* RT_CONFIG_UFFS_ECC_MODE */
  48. #if (!CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR)
  49. #define RT_UFFS_MEMORY_ALLOCATOR 1 /* use system memory allocator */
  50. #elif (CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (!CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR)
  51. #define RT_UFFS_MEMORY_ALLOCATOR 0 /* use static memory allocator */
  52. #else
  53. #error "UFFS: CONFIG_USE_STATIC_MEMORY_ALLOCATOR ,CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR are invalid!"
  54. #endif
  55. #if CONFIG_USE_STATIC_MEMORY_ALLOCATOR > 0
  56. #error "dfs_uffs only support CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR"
  57. #endif
  58. #if defined(CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME)
  59. #error "dfs_uffs not support CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME"
  60. #endif
  61. #if (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_FLASH)
  62. #error "when use UFFS_ECC_HW_AUTO, you must use UFFS_LAYOUT_FLASH"
  63. #elif (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_UFFS)
  64. #warning "when use UFFS_ECC_SOFT, it is recommended to use UFFS_LAYOUT_UFFS"
  65. #endif
  66. extern const uffs_FlashOps nand_ops;
  67. extern void uffs_setup_storage(
  68. struct uffs_StorageAttrSt *attr,
  69. struct rt_mtd_nand_device *nand);
  70. extern int dfs_uffs_init(void);
  71. #endif /* DFS_UFFS_H_ */