dfs_uffs.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO */
  30. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT */
  31. /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE */
  32. /* enable this ,you need provide a mark_badblock/check_block funciton */
  33. /* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */
  34. #if RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT /* let uffs do soft ecc */
  35. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */
  36. #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO /* nand driver make ecc and do ecc correct */
  37. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_FLASH
  38. #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_NONE
  39. #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */
  40. #else
  41. #error "uffs under rt-thread do not support this ECC mode"
  42. #endif /* RT_CONFIG_UFFS_ECC_MODE */
  43. #if (!CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR)
  44. #define RT_UFFS_MEMORY_ALLOCATOR 1 /* use system memory allocator */
  45. #elif (CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (!CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR)
  46. #define RT_UFFS_MEMORY_ALLOCATOR 0 /* use static memory allocator */
  47. #else
  48. #error "UFFS: CONFIG_USE_STATIC_MEMORY_ALLOCATOR ,CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR are invalid!"
  49. #endif
  50. #if CONFIG_USE_STATIC_MEMORY_ALLOCATOR > 0
  51. #error "dfs_uffs only support CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR"
  52. #endif
  53. #if defined(CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME)
  54. #error "dfs_uffs not support CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME"
  55. #endif
  56. #if (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_FLASH)
  57. #error "when use UFFS_ECC_HW_AUTO, you must use UFFS_LAYOUT_FLASH"
  58. #elif (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_UFFS)
  59. #warning "when use UFFS_ECC_SOFT, it is recommended to use UFFS_LAYOUT_UFFS"
  60. #endif
  61. extern const uffs_FlashOps nand_ops;
  62. extern void uffs_setup_storage(
  63. struct uffs_StorageAttrSt *attr,
  64. struct rt_mtd_nand_device * nand);
  65. extern int dfs_uffs_init(void);
  66. #endif /* DFS_UFFS_H_ */