dfs_uffs.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * File : dfs_uffs.h
  3. * This file is part of Device File System in RT-Thread RTOS
  4. * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2012-03-30 prife the first version
  23. */
  24. #ifndef DFS_UFFS_H_
  25. #define DFS_UFFS_H_
  26. #include "uffs_config.h"
  27. #include "uffs/uffs_public.h"
  28. /* the UFFS ECC mode opitons */
  29. #ifndef RT_UFFS_ECC_MODE
  30. #define RT_UFFS_ECC_MODE 1
  31. #endif
  32. /*
  33. * RT_UFFS_ECC_MODE:
  34. * 0, Do not use ECC
  35. * 1, UFFS calculate the ECC
  36. * 2, Flash driver(or by hardware) calculate the ECC
  37. * 3, Hardware calculate the ECC and automatically write to spare.
  38. */
  39. #if RT_UFFS_ECC_MODE == 0
  40. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE
  41. #elif RT_UFFS_ECC_MODE == 1
  42. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT
  43. #elif RT_UFFS_ECC_MODE == 2
  44. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW
  45. #elif RT_UFFS_ECC_MODE == 3
  46. #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO
  47. #endif
  48. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO */
  49. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT */
  50. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE */
  51. /* enable this ,you need provide a mark_badblock/check_block funciton */
  52. /* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */
  53. #if RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT /* let uffs do soft ecc */
  54. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */
  55. #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO /* nand driver make ecc and do ecc correct */
  56. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_FLASH
  57. #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_NONE
  58. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */
  59. #else
  60. #error "uffs under rt-thread do not support this ECC mode"
  61. #endif /* RT_CONFIG_UFFS_ECC_MODE */
  62. #if (!CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR)
  63. #define RT_UFFS_MEMORY_ALLOCATOR 1 /* use system memory allocator */
  64. #elif (CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (!CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR)
  65. #define RT_UFFS_MEMORY_ALLOCATOR 0 /* use static memory allocator */
  66. #else
  67. #error "UFFS: CONFIG_USE_STATIC_MEMORY_ALLOCATOR ,CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR are invalid!"
  68. #endif
  69. #if CONFIG_USE_STATIC_MEMORY_ALLOCATOR > 0
  70. #error "dfs_uffs only support CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR"
  71. #endif
  72. #if defined(CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME)
  73. #error "dfs_uffs not support CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME"
  74. #endif
  75. #if (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_FLASH)
  76. #error "when use UFFS_ECC_HW_AUTO, you must use UFFS_LAYOUT_FLASH"
  77. #elif (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_UFFS)
  78. #warning "when use UFFS_ECC_SOFT, it is recommended to use UFFS_LAYOUT_UFFS"
  79. #endif
  80. extern const uffs_FlashOps nand_ops;
  81. extern void uffs_setup_storage(
  82. struct uffs_StorageAttrSt *attr,
  83. struct rt_mtd_nand_device * nand);
  84. extern int dfs_uffs_init(void);
  85. #endif /* DFS_UFFS_H_ */